// This file is generated by the effect-codex-app-server package. Do not edit manually.
// Upstream protocol ref: 07b695190f30a450e4921f71f77473e564395c59

import * as Schema from "effect/Schema";

export type ApplyPatchApprovalParams__FileChange =
  | { readonly content: string; readonly type: "add" }
  | { readonly content: string; readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update"; readonly unified_diff: string };
export const ApplyPatchApprovalParams__FileChange = Schema.Union(
  [
    Schema.Struct({
      content: Schema.String,
      type: Schema.Literal("add").annotate({ title: "AddFileChangeType" }),
    }).annotate({ title: "AddFileChange" }),
    Schema.Struct({
      content: Schema.String,
      type: Schema.Literal("delete").annotate({ title: "DeleteFileChangeType" }),
    }).annotate({ title: "DeleteFileChange" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdateFileChangeType" }),
      unified_diff: Schema.String,
    }).annotate({ title: "UpdateFileChange" }),
  ],
  { mode: "oneOf" },
);

export type ApplyPatchApprovalParams__ThreadId = string;
export const ApplyPatchApprovalParams__ThreadId = Schema.String;

export type ApplyPatchApprovalResponse__NetworkPolicyRuleAction = "allow" | "deny";
export const ApplyPatchApprovalResponse__NetworkPolicyRuleAction = Schema.Literals([
  "allow",
  "deny",
]);

export type ChatgptAuthTokensRefreshParams__ChatgptAuthTokensRefreshReason = "unauthorized";
export const ChatgptAuthTokensRefreshParams__ChatgptAuthTokensRefreshReason =
  Schema.Literal("unauthorized");

export type ClientRequest__AbsolutePathBuf = string;
export const ClientRequest__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type ClientRequest__AddCreditsNudgeCreditType = "credits" | "usage_limit";
export const ClientRequest__AddCreditsNudgeCreditType = Schema.Literals(["credits", "usage_limit"]);

export type ClientRequest__ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
export const ClientRequest__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type ClientRequest__AppsListParams = {
  readonly cursor?: string | null;
  readonly forceRefetch?: boolean;
  readonly limit?: number | null;
  readonly threadId?: string | null;
};
export const ClientRequest__AppsListParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  forceRefetch: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "When true, bypass app caches and fetch the latest data from sources.",
    }),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a reasonable server-side value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  threadId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional thread id used to evaluate app feature gating from that thread's config.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ description: "EXPERIMENTAL - list available apps/connectors." });

export type ClientRequest__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const ClientRequest__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__CancelLoginAccountParams = { readonly loginId: string };
export const ClientRequest__CancelLoginAccountParams = Schema.Struct({ loginId: Schema.String });

export type ClientRequest__ClientInfo = {
  readonly name: string;
  readonly title?: string | null;
  readonly version: string;
};
export const ClientRequest__ClientInfo = Schema.Struct({
  name: Schema.String,
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  version: Schema.String,
});

export type ClientRequest__CommandExecResizeParams = {
  readonly processId: string;
  readonly size: { readonly cols: number; readonly rows: number };
};
export const ClientRequest__CommandExecResizeParams = Schema.Struct({
  processId: Schema.String.annotate({
    description:
      "Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
  }),
  size: Schema.Struct({
    cols: Schema.Number.annotate({
      description: "Terminal width in character cells.",
      format: "uint16",
    })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    rows: Schema.Number.annotate({
      description: "Terminal height in character cells.",
      format: "uint16",
    })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({ description: "PTY size in character cells for `command/exec` PTY sessions." }),
}).annotate({ description: "Resize a running PTY-backed `command/exec` session." });

export type ClientRequest__CommandExecTerminalSize = {
  readonly cols: number;
  readonly rows: number;
};
export const ClientRequest__CommandExecTerminalSize = Schema.Struct({
  cols: Schema.Number.annotate({
    description: "Terminal width in character cells.",
    format: "uint16",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  rows: Schema.Number.annotate({
    description: "Terminal height in character cells.",
    format: "uint16",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
}).annotate({ description: "PTY size in character cells for `command/exec` PTY sessions." });

export type ClientRequest__CommandExecTerminateParams = { readonly processId: string };
export const ClientRequest__CommandExecTerminateParams = Schema.Struct({
  processId: Schema.String.annotate({
    description:
      "Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
  }),
}).annotate({ description: "Terminate a running `command/exec` session." });

export type ClientRequest__CommandExecWriteParams = {
  readonly closeStdin?: boolean;
  readonly deltaBase64?: string | null;
  readonly processId: string;
};
export const ClientRequest__CommandExecWriteParams = Schema.Struct({
  closeStdin: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "Close stdin after writing `deltaBase64`, if present.",
    }),
  ),
  deltaBase64: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional base64-encoded stdin bytes to write." }),
      Schema.Null,
    ]),
  ),
  processId: Schema.String.annotate({
    description:
      "Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
  }),
}).annotate({
  description: "Write stdin bytes to a running `command/exec` session, close stdin, or both.",
});

export type ClientRequest__CommandMigration = { readonly name: string };
export const ClientRequest__CommandMigration = Schema.Struct({ name: Schema.String });

export type ClientRequest__ConfigReadParams = {
  readonly cwd?: string | null;
  readonly includeLayers?: boolean;
};
export const ClientRequest__ConfigReadParams = Schema.Struct({
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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).",
      }),
      Schema.Null,
    ]),
  ),
  includeLayers: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
});

export type ClientRequest__ExperimentalFeatureEnablementSetParams = {
  readonly enablement: { readonly [x: string]: boolean };
};
export const ClientRequest__ExperimentalFeatureEnablementSetParams = Schema.Struct({
  enablement: Schema.Record(Schema.String, Schema.Boolean).annotate({
    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.",
  }),
});

export type ClientRequest__ExperimentalFeatureListParams = {
  readonly cursor?: string | null;
  readonly limit?: number | null;
};
export const ClientRequest__ExperimentalFeatureListParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a reasonable server-side value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
});

export type ClientRequest__ExternalAgentConfigDetectParams = {
  readonly cwds?: ReadonlyArray<string> | null;
  readonly includeHome?: boolean;
};
export const ClientRequest__ExternalAgentConfigDetectParams = Schema.Struct({
  cwds: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description: "Zero or more working directories to include for repo-scoped detection.",
      }),
      Schema.Null,
    ]),
  ),
  includeHome: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "If true, include detection under the user's home (~/.claude, ~/.codex, etc.).",
    }),
  ),
});

export type ClientRequest__ExternalAgentConfigMigrationItemType =
  | "AGENTS_MD"
  | "CONFIG"
  | "SKILLS"
  | "PLUGINS"
  | "MCP_SERVER_CONFIG"
  | "SUBAGENTS"
  | "HOOKS"
  | "COMMANDS"
  | "SESSIONS";
export const ClientRequest__ExternalAgentConfigMigrationItemType = Schema.Literals([
  "AGENTS_MD",
  "CONFIG",
  "SKILLS",
  "PLUGINS",
  "MCP_SERVER_CONFIG",
  "SUBAGENTS",
  "HOOKS",
  "COMMANDS",
  "SESSIONS",
]);

export type ClientRequest__FeedbackUploadParams = {
  readonly classification: string;
  readonly extraLogFiles?: ReadonlyArray<string> | null;
  readonly includeLogs: boolean;
  readonly reason?: string | null;
  readonly tags?: { readonly [x: string]: string } | null;
  readonly threadId?: string | null;
};
export const ClientRequest__FeedbackUploadParams = Schema.Struct({
  classification: Schema.String,
  extraLogFiles: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  includeLogs: Schema.Boolean,
  reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  tags: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]),
  ),
  threadId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ClientRequest__FileSystemAccessMode = "read" | "write" | "none";
export const ClientRequest__FileSystemAccessMode = Schema.Literals(["read", "write", "none"]);

export type ClientRequest__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const ClientRequest__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__FsCopyParams = {
  readonly destinationPath: string;
  readonly recursive?: boolean;
  readonly sourcePath: string;
};
export const ClientRequest__FsCopyParams = Schema.Struct({
  destinationPath: Schema.String.annotate({
    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.",
  }),
  recursive: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "Required for directory copies; ignored for file copies.",
    }),
  ),
  sourcePath: Schema.String.annotate({
    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.",
  }),
}).annotate({ description: "Copy a file or directory tree on the host filesystem." });

export type ClientRequest__FsCreateDirectoryParams = {
  readonly path: string;
  readonly recursive?: boolean | null;
};
export const ClientRequest__FsCreateDirectoryParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
  recursive: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description: "Whether parent directories should also be created. Defaults to `true`.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ description: "Create a directory on the host filesystem." });

export type ClientRequest__FsGetMetadataParams = { readonly path: string };
export const ClientRequest__FsGetMetadataParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({ description: "Request metadata for an absolute path." });

export type ClientRequest__FsReadDirectoryParams = { readonly path: string };
export const ClientRequest__FsReadDirectoryParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({ description: "List direct child names for a directory." });

export type ClientRequest__FsReadFileParams = { readonly path: string };
export const ClientRequest__FsReadFileParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({ description: "Read a file from the host filesystem." });

export type ClientRequest__FsRemoveParams = {
  readonly force?: boolean | null;
  readonly path: string;
  readonly recursive?: boolean | null;
};
export const ClientRequest__FsRemoveParams = Schema.Struct({
  force: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description: "Whether missing paths should be ignored. Defaults to `true`.",
      }),
      Schema.Null,
    ]),
  ),
  path: Schema.String.annotate({
    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.",
  }),
  recursive: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description: "Whether directory removal should recurse. Defaults to `true`.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ description: "Remove a file or directory tree from the host filesystem." });

export type ClientRequest__FsUnwatchParams = { readonly watchId: string };
export const ClientRequest__FsUnwatchParams = Schema.Struct({
  watchId: Schema.String.annotate({
    description: "Watch identifier previously provided to `fs/watch`.",
  }),
}).annotate({ description: "Stop filesystem watch notifications for a prior `fs/watch`." });

export type ClientRequest__FsWatchParams = { readonly path: string; readonly watchId: string };
export const ClientRequest__FsWatchParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
  watchId: Schema.String.annotate({
    description: "Connection-scoped watch identifier used for `fs/unwatch` and `fs/changed`.",
  }),
}).annotate({ description: "Start filesystem watch notifications for an absolute path." });

export type ClientRequest__FsWriteFileParams = {
  readonly dataBase64: string;
  readonly path: string;
};
export const ClientRequest__FsWriteFileParams = Schema.Struct({
  dataBase64: Schema.String.annotate({ description: "File contents encoded as base64." }),
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({ description: "Write a file on the host filesystem." });

export type ClientRequest__FuzzyFileSearchParams = {
  readonly cancellationToken?: string | null;
  readonly query: string;
  readonly roots: ReadonlyArray<string>;
};
export const ClientRequest__FuzzyFileSearchParams = Schema.Struct({
  cancellationToken: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  query: Schema.String,
  roots: Schema.Array(Schema.String),
});

export type ClientRequest__GetAccountParams = { readonly refreshToken?: boolean };
export const ClientRequest__GetAccountParams = Schema.Struct({
  refreshToken: Schema.optionalKey(
    Schema.Boolean.annotate({
      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`.",
      default: false,
    }),
  ),
});

export type ClientRequest__HookMigration = { readonly name: string };
export const ClientRequest__HookMigration = Schema.Struct({ name: Schema.String });

export type ClientRequest__HooksListParams = { readonly cwds?: ReadonlyArray<string> };
export const ClientRequest__HooksListParams = Schema.Struct({
  cwds: Schema.optionalKey(
    Schema.Array(Schema.String).annotate({
      description: "When empty, defaults to the current session working directory.",
    }),
  ),
});

export type ClientRequest__ImageDetail = "auto" | "low" | "high" | "original";
export const ClientRequest__ImageDetail = Schema.Literals(["auto", "low", "high", "original"]);

export type ClientRequest__InitializeCapabilities = {
  readonly experimentalApi?: boolean;
  readonly optOutNotificationMethods?: ReadonlyArray<string> | null;
};
export const ClientRequest__InitializeCapabilities = Schema.Struct({
  experimentalApi: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "Opt into receiving experimental API methods and fields.",
      default: false,
    }),
  ),
  optOutNotificationMethods: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Exact notification method names that should be suppressed for this connection (for example `thread/started`).",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ description: "Client-declared capabilities negotiated during initialize." });

export type ClientRequest__LocalShellAction = {
  readonly command: ReadonlyArray<string>;
  readonly env?: { readonly [x: string]: string } | null;
  readonly timeout_ms?: number | null;
  readonly type: "exec";
  readonly user?: string | null;
  readonly working_directory?: string | null;
};
export const ClientRequest__LocalShellAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.Array(Schema.String),
      env: Schema.optionalKey(
        Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]),
      ),
      timeout_ms: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint64" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(0)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("exec").annotate({ title: "ExecLocalShellActionType" }),
      user: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      working_directory: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "ExecLocalShellAction" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__LocalShellStatus = "completed" | "in_progress" | "incomplete";
export const ClientRequest__LocalShellStatus = Schema.Literals([
  "completed",
  "in_progress",
  "incomplete",
]);

export type ClientRequest__LoginAccountParams =
  | { readonly apiKey: string; readonly type: "apiKey" }
  | { readonly codexStreamlinedLogin?: boolean; readonly type: "chatgpt" }
  | { readonly type: "chatgptDeviceCode" }
  | {
      readonly accessToken: string;
      readonly chatgptAccountId: string;
      readonly chatgptPlanType?: string | null;
      readonly type: "chatgptAuthTokens";
    };
export const ClientRequest__LoginAccountParams = Schema.Union(
  [
    Schema.Struct({
      apiKey: Schema.String,
      type: Schema.Literal("apiKey").annotate({ title: "ApiKeyLoginAccountParamsType" }),
    }).annotate({ title: "ApiKeyLoginAccountParams" }),
    Schema.Struct({
      codexStreamlinedLogin: Schema.optionalKey(Schema.Boolean),
      type: Schema.Literal("chatgpt").annotate({ title: "ChatgptLoginAccountParamsType" }),
    }).annotate({ title: "ChatgptLoginAccountParams" }),
    Schema.Struct({
      type: Schema.Literal("chatgptDeviceCode").annotate({
        title: "ChatgptDeviceCodeLoginAccountParamsType",
      }),
    }).annotate({ title: "ChatgptDeviceCodeLoginAccountParams" }),
    Schema.Struct({
      accessToken: Schema.String.annotate({
        description:
          "Access token (JWT) supplied by the client. This token is used for backend API requests and email extraction.",
      }),
      chatgptAccountId: Schema.String.annotate({
        description: "Workspace/account identifier supplied by the client.",
      }),
      chatgptPlanType: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            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`.",
          }),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("chatgptAuthTokens").annotate({
        title: "ChatgptAuthTokensLoginAccountParamsType",
      }),
    }).annotate({
      title: "ChatgptAuthTokensLoginAccountParams",
      description:
        "[UNSTABLE] FOR OPENAI INTERNAL USE ONLY - DO NOT USE. The access token must contain the same scopes that Codex-managed ChatGPT auth tokens have.",
    }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__MarketplaceAddParams = {
  readonly refName?: string | null;
  readonly source: string;
  readonly sparsePaths?: ReadonlyArray<string> | null;
};
export const ClientRequest__MarketplaceAddParams = Schema.Struct({
  refName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  source: Schema.String,
  sparsePaths: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
});

export type ClientRequest__MarketplaceRemoveParams = { readonly marketplaceName: string };
export const ClientRequest__MarketplaceRemoveParams = Schema.Struct({
  marketplaceName: Schema.String,
});

export type ClientRequest__MarketplaceUpgradeParams = { readonly marketplaceName?: string | null };
export const ClientRequest__MarketplaceUpgradeParams = Schema.Struct({
  marketplaceName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ClientRequest__McpResourceReadParams = {
  readonly server: string;
  readonly threadId?: string | null;
  readonly uri: string;
};
export const ClientRequest__McpResourceReadParams = Schema.Struct({
  server: Schema.String,
  threadId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  uri: Schema.String,
});

export type ClientRequest__McpServerMigration = { readonly name: string };
export const ClientRequest__McpServerMigration = Schema.Struct({ name: Schema.String });

export type ClientRequest__McpServerOauthLoginParams = {
  readonly name: string;
  readonly scopes?: ReadonlyArray<string> | null;
  readonly timeoutSecs?: number | null;
};
export const ClientRequest__McpServerOauthLoginParams = Schema.Struct({
  name: Schema.String,
  scopes: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  timeoutSecs: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
});

export type ClientRequest__McpServerStatusDetail = "full" | "toolsAndAuthOnly";
export const ClientRequest__McpServerStatusDetail = Schema.Literals(["full", "toolsAndAuthOnly"]);

export type ClientRequest__McpServerToolCallParams = {
  readonly _meta?: unknown;
  readonly arguments?: unknown;
  readonly server: string;
  readonly threadId: string;
  readonly tool: string;
};
export const ClientRequest__McpServerToolCallParams = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  arguments: Schema.optionalKey(Schema.Unknown),
  server: Schema.String,
  threadId: Schema.String,
  tool: Schema.String,
});

export type ClientRequest__MergeStrategy = "replace" | "upsert";
export const ClientRequest__MergeStrategy = Schema.Literals(["replace", "upsert"]);

export type ClientRequest__MessagePhase = "commentary" | "final_answer";
export const ClientRequest__MessagePhase = Schema.Literals(["commentary", "final_answer"]).annotate(
  {
    description:
      'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
  },
);

export type ClientRequest__ModeKind = "plan" | "default";
export const ClientRequest__ModeKind = Schema.Literals(["plan", "default"]).annotate({
  description: "Initial collaboration mode to use when the TUI starts.",
});

export type ClientRequest__ModelListParams = {
  readonly cursor?: string | null;
  readonly includeHidden?: boolean | null;
  readonly limit?: number | null;
};
export const ClientRequest__ModelListParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  includeHidden: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description: "When true, include models that are hidden from the default picker list.",
      }),
      Schema.Null,
    ]),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a reasonable server-side value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
});

export type ClientRequest__ModelProviderCapabilitiesReadParams = {};
export const ClientRequest__ModelProviderCapabilitiesReadParams = Schema.Struct({});

export type ClientRequest__PermissionProfileNetworkPermissions = { readonly enabled: boolean };
export const ClientRequest__PermissionProfileNetworkPermissions = Schema.Struct({
  enabled: Schema.Boolean,
});

export type ClientRequest__Personality = "none" | "friendly" | "pragmatic";
export const ClientRequest__Personality = Schema.Literals(["none", "friendly", "pragmatic"]);

export type ClientRequest__PluginListMarketplaceKind =
  | "local"
  | "workspace-directory"
  | "shared-with-me";
export const ClientRequest__PluginListMarketplaceKind = Schema.Literals([
  "local",
  "workspace-directory",
  "shared-with-me",
]);

export type ClientRequest__PluginShareDeleteParams = { readonly remotePluginId: string };
export const ClientRequest__PluginShareDeleteParams = Schema.Struct({
  remotePluginId: Schema.String,
});

export type ClientRequest__PluginShareDiscoverability = "LISTED" | "UNLISTED" | "PRIVATE";
export const ClientRequest__PluginShareDiscoverability = Schema.Literals([
  "LISTED",
  "UNLISTED",
  "PRIVATE",
]);

export type ClientRequest__PluginShareListParams = {};
export const ClientRequest__PluginShareListParams = Schema.Struct({});

export type ClientRequest__PluginSharePrincipalType = "user" | "group" | "workspace";
export const ClientRequest__PluginSharePrincipalType = Schema.Literals([
  "user",
  "group",
  "workspace",
]);

export type ClientRequest__PluginSkillReadParams = {
  readonly remoteMarketplaceName: string;
  readonly remotePluginId: string;
  readonly skillName: string;
};
export const ClientRequest__PluginSkillReadParams = Schema.Struct({
  remoteMarketplaceName: Schema.String,
  remotePluginId: Schema.String,
  skillName: Schema.String,
});

export type ClientRequest__PluginUninstallParams = { readonly pluginId: string };
export const ClientRequest__PluginUninstallParams = Schema.Struct({ pluginId: Schema.String });

export type ClientRequest__PluginsMigration = {
  readonly marketplaceName: string;
  readonly pluginNames: ReadonlyArray<string>;
};
export const ClientRequest__PluginsMigration = Schema.Struct({
  marketplaceName: Schema.String,
  pluginNames: Schema.Array(Schema.String),
});

export type ClientRequest__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const ClientRequest__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type ClientRequest__ReasoningItemContent =
  | { readonly text: string; readonly type: "reasoning_text" }
  | { readonly text: string; readonly type: "text" };
export const ClientRequest__ReasoningItemContent = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("reasoning_text").annotate({
        title: "ReasoningTextReasoningItemContentType",
      }),
    }).annotate({ title: "ReasoningTextReasoningItemContent" }),
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("text").annotate({ title: "TextReasoningItemContentType" }),
    }).annotate({ title: "TextReasoningItemContent" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__ReasoningItemReasoningSummary = {
  readonly text: string;
  readonly type: "summary_text";
};
export const ClientRequest__ReasoningItemReasoningSummary = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("summary_text").annotate({
        title: "SummaryTextReasoningItemReasoningSummaryType",
      }),
    }).annotate({ title: "SummaryTextReasoningItemReasoningSummary" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__ReasoningSummary = "auto" | "concise" | "detailed" | "none";
export const ClientRequest__ReasoningSummary = Schema.Union(
  [
    Schema.Literals(["auto", "concise", "detailed"]),
    Schema.Literal("none").annotate({ description: "Option to disable reasoning summaries." }),
  ],
  { mode: "oneOf" },
).annotate({
  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",
});

export type ClientRequest__RequestId = string | number;
export const ClientRequest__RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]);

export type ClientRequest__ResponsesApiWebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "open_page"; readonly url?: string | null }
  | {
      readonly pattern?: string | null;
      readonly type: "find_in_page";
      readonly url?: string | null;
    }
  | { readonly type: "other" };
export const ClientRequest__ResponsesApiWebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchResponsesApiWebSearchActionType" }),
    }).annotate({ title: "SearchResponsesApiWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("open_page").annotate({
        title: "OpenPageResponsesApiWebSearchActionType",
      }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageResponsesApiWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("find_in_page").annotate({
        title: "FindInPageResponsesApiWebSearchActionType",
      }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageResponsesApiWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherResponsesApiWebSearchActionType" }),
    }).annotate({ title: "OtherResponsesApiWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__ReviewDelivery = "inline" | "detached";
export const ClientRequest__ReviewDelivery = Schema.Literals(["inline", "detached"]);

export type ClientRequest__ReviewTarget =
  | { readonly type: "uncommittedChanges" }
  | { readonly branch: string; readonly type: "baseBranch" }
  | { readonly sha: string; readonly title?: string | null; readonly type: "commit" }
  | { readonly instructions: string; readonly type: "custom" };
export const ClientRequest__ReviewTarget = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("uncommittedChanges").annotate({
        title: "UncommittedChangesReviewTargetType",
      }),
    }).annotate({
      title: "UncommittedChangesReviewTarget",
      description: "Review the working tree: staged, unstaged, and untracked files.",
    }),
    Schema.Struct({
      branch: Schema.String,
      type: Schema.Literal("baseBranch").annotate({ title: "BaseBranchReviewTargetType" }),
    }).annotate({
      title: "BaseBranchReviewTarget",
      description: "Review changes between the current branch and the given base branch.",
    }),
    Schema.Struct({
      sha: Schema.String,
      title: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Optional human-readable label (e.g., commit subject) for UIs.",
          }),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("commit").annotate({ title: "CommitReviewTargetType" }),
    }).annotate({
      title: "CommitReviewTarget",
      description: "Review the changes introduced by a specific commit.",
    }),
    Schema.Struct({
      instructions: Schema.String,
      type: Schema.Literal("custom").annotate({ title: "CustomReviewTargetType" }),
    }).annotate({
      title: "CustomReviewTarget",
      description: "Arbitrary instructions, equivalent to the old free-form prompt.",
    }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__SandboxMode = "read-only" | "workspace-write" | "danger-full-access";
export const ClientRequest__SandboxMode = Schema.Literals([
  "read-only",
  "workspace-write",
  "danger-full-access",
]);

export type ClientRequest__SessionMigration = {
  readonly cwd: string;
  readonly path: string;
  readonly title?: string | null;
};
export const ClientRequest__SessionMigration = Schema.Struct({
  cwd: Schema.String,
  path: Schema.String,
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ClientRequest__SkillsListExtraRootsForCwd = {
  readonly cwd: string;
  readonly extraUserRoots: ReadonlyArray<string>;
};
export const ClientRequest__SkillsListExtraRootsForCwd = Schema.Struct({
  cwd: Schema.String,
  extraUserRoots: Schema.Array(Schema.String),
});

export type ClientRequest__SortDirection = "asc" | "desc";
export const ClientRequest__SortDirection = Schema.Literals(["asc", "desc"]);

export type ClientRequest__SubagentMigration = { readonly name: string };
export const ClientRequest__SubagentMigration = Schema.Struct({ name: Schema.String });

export type ClientRequest__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const ClientRequest__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ClientRequest__ThreadApproveGuardianDeniedActionParams = {
  readonly event: unknown;
  readonly threadId: string;
};
export const ClientRequest__ThreadApproveGuardianDeniedActionParams = Schema.Struct({
  event: Schema.Unknown.annotate({
    description: "Serialized `codex_protocol::protocol::GuardianAssessmentEvent`.",
  }),
  threadId: Schema.String,
});

export type ClientRequest__ThreadArchiveParams = { readonly threadId: string };
export const ClientRequest__ThreadArchiveParams = Schema.Struct({ threadId: Schema.String });

export type ClientRequest__ThreadCompactStartParams = { readonly threadId: string };
export const ClientRequest__ThreadCompactStartParams = Schema.Struct({ threadId: Schema.String });

export type ClientRequest__ThreadInjectItemsParams = {
  readonly items: ReadonlyArray<unknown>;
  readonly threadId: string;
};
export const ClientRequest__ThreadInjectItemsParams = Schema.Struct({
  items: Schema.Array(Schema.Unknown).annotate({
    description: "Raw Responses API items to append to the thread's model-visible history.",
  }),
  threadId: Schema.String,
});

export type ClientRequest__ThreadListCwdFilter = string | ReadonlyArray<string>;
export const ClientRequest__ThreadListCwdFilter = Schema.Union([
  Schema.String,
  Schema.Array(Schema.String),
]);

export type ClientRequest__ThreadLoadedListParams = {
  readonly cursor?: string | null;
  readonly limit?: number | null;
};
export const ClientRequest__ThreadLoadedListParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to no limit.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
});

export type ClientRequest__ThreadMetadataGitInfoUpdateParams = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const ClientRequest__ThreadMetadataGitInfoUpdateParams = Schema.Struct({
  branch: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Omit to leave the stored branch unchanged, set to `null` to clear it, or provide a non-empty string to replace it.",
      }),
      Schema.Null,
    ]),
  ),
  originUrl: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Omit to leave the stored origin URL unchanged, set to `null` to clear it, or provide a non-empty string to replace it.",
      }),
      Schema.Null,
    ]),
  ),
  sha: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Omit to leave the stored commit unchanged, set to `null` to clear it, or provide a non-empty string to replace it.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ClientRequest__ThreadReadParams = {
  readonly includeTurns?: boolean;
  readonly threadId: string;
};
export const ClientRequest__ThreadReadParams = Schema.Struct({
  includeTurns: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "When true, include turns and their items from rollout history.",
      default: false,
    }),
  ),
  threadId: Schema.String,
});

export type ClientRequest__ThreadRollbackParams = {
  readonly numTurns: number;
  readonly threadId: string;
};
export const ClientRequest__ThreadRollbackParams = Schema.Struct({
  numTurns: Schema.Number.annotate({
    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.",
    format: "uint32",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  threadId: Schema.String,
});

export type ClientRequest__ThreadSetNameParams = {
  readonly name: string;
  readonly threadId: string;
};
export const ClientRequest__ThreadSetNameParams = Schema.Struct({
  name: Schema.String,
  threadId: Schema.String,
});

export type ClientRequest__ThreadShellCommandParams = {
  readonly command: string;
  readonly threadId: string;
};
export const ClientRequest__ThreadShellCommandParams = Schema.Struct({
  command: Schema.String.annotate({
    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.",
  }),
  threadId: Schema.String,
});

export type ClientRequest__ThreadSortKey = "created_at" | "updated_at";
export const ClientRequest__ThreadSortKey = Schema.Literals(["created_at", "updated_at"]);

export type ClientRequest__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const ClientRequest__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type ClientRequest__ThreadSourceKind =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "subAgent"
  | "subAgentReview"
  | "subAgentCompact"
  | "subAgentThreadSpawn"
  | "subAgentOther"
  | "unknown";
export const ClientRequest__ThreadSourceKind = Schema.Literals([
  "cli",
  "vscode",
  "exec",
  "appServer",
  "subAgent",
  "subAgentReview",
  "subAgentCompact",
  "subAgentThreadSpawn",
  "subAgentOther",
  "unknown",
]);

export type ClientRequest__ThreadStartSource = "startup" | "clear";
export const ClientRequest__ThreadStartSource = Schema.Literals(["startup", "clear"]);

export type ClientRequest__ThreadUnarchiveParams = { readonly threadId: string };
export const ClientRequest__ThreadUnarchiveParams = Schema.Struct({ threadId: Schema.String });

export type ClientRequest__ThreadUnsubscribeParams = { readonly threadId: string };
export const ClientRequest__ThreadUnsubscribeParams = Schema.Struct({ threadId: Schema.String });

export type ClientRequest__TurnInterruptParams = {
  readonly threadId: string;
  readonly turnId: string;
};
export const ClientRequest__TurnInterruptParams = Schema.Struct({
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ClientRequest__WindowsSandboxSetupMode = "elevated" | "unelevated";
export const ClientRequest__WindowsSandboxSetupMode = Schema.Literals(["elevated", "unelevated"]);

export type CommandExecutionRequestApprovalParams__AbsolutePathBuf = string;
export const CommandExecutionRequestApprovalParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type CommandExecutionRequestApprovalParams__AdditionalNetworkPermissions = {
  readonly enabled?: boolean | null;
};
export const CommandExecutionRequestApprovalParams__AdditionalNetworkPermissions = Schema.Struct({
  enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
});

export type CommandExecutionRequestApprovalParams__FileSystemAccessMode = "read" | "write" | "none";
export const CommandExecutionRequestApprovalParams__FileSystemAccessMode = Schema.Literals([
  "read",
  "write",
  "none",
]);

export type CommandExecutionRequestApprovalParams__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const CommandExecutionRequestApprovalParams__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type CommandExecutionRequestApprovalParams__NetworkApprovalProtocol =
  | "http"
  | "https"
  | "socks5Tcp"
  | "socks5Udp";
export const CommandExecutionRequestApprovalParams__NetworkApprovalProtocol = Schema.Literals([
  "http",
  "https",
  "socks5Tcp",
  "socks5Udp",
]);

export type CommandExecutionRequestApprovalParams__NetworkPolicyRuleAction = "allow" | "deny";
export const CommandExecutionRequestApprovalParams__NetworkPolicyRuleAction = Schema.Literals([
  "allow",
  "deny",
]);

export type CommandExecutionRequestApprovalResponse__NetworkPolicyRuleAction = "allow" | "deny";
export const CommandExecutionRequestApprovalResponse__NetworkPolicyRuleAction = Schema.Literals([
  "allow",
  "deny",
]);

export type DynamicToolCallResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const DynamicToolCallResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type ExecCommandApprovalParams__ParsedCommand =
  | { readonly cmd: string; readonly name: string; readonly path: string; readonly type: "read" }
  | { readonly cmd: string; readonly path?: string | null; readonly type: "list_files" }
  | {
      readonly cmd: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly cmd: string; readonly type: "unknown" };
export const ExecCommandApprovalParams__ParsedCommand = Schema.Union(
  [
    Schema.Struct({
      cmd: Schema.String,
      name: Schema.String,
      path: Schema.String.annotate({
        description:
          "(Best effort) Path to the file being read by the command. When possible, this is an absolute path, though when relative, it should be resolved against the `cwd`` that will be used to run the command to derive the absolute path.",
      }),
      type: Schema.Literal("read").annotate({ title: "ReadParsedCommandType" }),
    }).annotate({ title: "ReadParsedCommand" }),
    Schema.Struct({
      cmd: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("list_files").annotate({ title: "ListFilesParsedCommandType" }),
    }).annotate({ title: "ListFilesParsedCommand" }),
    Schema.Struct({
      cmd: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchParsedCommandType" }),
    }).annotate({ title: "SearchParsedCommand" }),
    Schema.Struct({
      cmd: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownParsedCommandType" }),
    }).annotate({ title: "UnknownParsedCommand" }),
  ],
  { mode: "oneOf" },
);

export type ExecCommandApprovalParams__ThreadId = string;
export const ExecCommandApprovalParams__ThreadId = Schema.String;

export type ExecCommandApprovalResponse__NetworkPolicyRuleAction = "allow" | "deny";
export const ExecCommandApprovalResponse__NetworkPolicyRuleAction = Schema.Literals([
  "allow",
  "deny",
]);

export type FileChangeRequestApprovalResponse__FileChangeApprovalDecision =
  | "accept"
  | "acceptForSession"
  | "decline"
  | "cancel";
export const FileChangeRequestApprovalResponse__FileChangeApprovalDecision = Schema.Literals([
  "accept",
  "acceptForSession",
  "decline",
  "cancel",
]);

export type FuzzyFileSearchResponse__FuzzyFileSearchMatchType = "file" | "directory";
export const FuzzyFileSearchResponse__FuzzyFileSearchMatchType = Schema.Literals([
  "file",
  "directory",
]);

export type FuzzyFileSearchSessionUpdatedNotification__FuzzyFileSearchMatchType =
  | "file"
  | "directory";
export const FuzzyFileSearchSessionUpdatedNotification__FuzzyFileSearchMatchType = Schema.Literals([
  "file",
  "directory",
]);

export type JSONRPCError__JSONRPCErrorError = {
  readonly code: number;
  readonly data?: unknown;
  readonly message: string;
};
export const JSONRPCError__JSONRPCErrorError = Schema.Struct({
  code: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  data: Schema.optionalKey(Schema.Unknown),
  message: Schema.String,
});

export type JSONRPCError__RequestId = string | number;
export const JSONRPCError__RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]);

export type JSONRPCMessage__JSONRPCErrorError = {
  readonly code: number;
  readonly data?: unknown;
  readonly message: string;
};
export const JSONRPCMessage__JSONRPCErrorError = Schema.Struct({
  code: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  data: Schema.optionalKey(Schema.Unknown),
  message: Schema.String,
});

export type JSONRPCMessage__JSONRPCNotification = {
  readonly method: string;
  readonly params?: unknown;
};
export const JSONRPCMessage__JSONRPCNotification = Schema.Struct({
  method: Schema.String,
  params: Schema.optionalKey(Schema.Unknown),
}).annotate({ description: "A notification which does not expect a response." });

export type JSONRPCMessage__RequestId = string | number;
export const JSONRPCMessage__RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]);

export type JSONRPCMessage__W3cTraceContext = {
  readonly traceparent?: string | null;
  readonly tracestate?: string | null;
};
export const JSONRPCMessage__W3cTraceContext = Schema.Struct({
  traceparent: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  tracestate: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type JSONRPCRequest__RequestId = string | number;
export const JSONRPCRequest__RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]);

export type JSONRPCRequest__W3cTraceContext = {
  readonly traceparent?: string | null;
  readonly tracestate?: string | null;
};
export const JSONRPCRequest__W3cTraceContext = Schema.Struct({
  traceparent: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  tracestate: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type JSONRPCResponse__RequestId = string | number;
export const JSONRPCResponse__RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]);

export type McpServerElicitationRequestParams__McpElicitationArrayType = "array";
export const McpServerElicitationRequestParams__McpElicitationArrayType = Schema.Literal("array");

export type McpServerElicitationRequestParams__McpElicitationBooleanType = "boolean";
export const McpServerElicitationRequestParams__McpElicitationBooleanType =
  Schema.Literal("boolean");

export type McpServerElicitationRequestParams__McpElicitationConstOption = {
  readonly const: string;
  readonly title: string;
};
export const McpServerElicitationRequestParams__McpElicitationConstOption = Schema.Struct({
  const: Schema.String,
  title: Schema.String,
});

export type McpServerElicitationRequestParams__McpElicitationNumberType = "number" | "integer";
export const McpServerElicitationRequestParams__McpElicitationNumberType = Schema.Literals([
  "number",
  "integer",
]);

export type McpServerElicitationRequestParams__McpElicitationObjectType = "object";
export const McpServerElicitationRequestParams__McpElicitationObjectType = Schema.Literal("object");

export type McpServerElicitationRequestParams__McpElicitationStringFormat =
  | "email"
  | "uri"
  | "date"
  | "date-time";
export const McpServerElicitationRequestParams__McpElicitationStringFormat = Schema.Literals([
  "email",
  "uri",
  "date",
  "date-time",
]);

export type McpServerElicitationRequestParams__McpElicitationStringType = "string";
export const McpServerElicitationRequestParams__McpElicitationStringType = Schema.Literal("string");

export type McpServerElicitationRequestResponse__McpServerElicitationAction =
  | "accept"
  | "decline"
  | "cancel";
export const McpServerElicitationRequestResponse__McpServerElicitationAction = Schema.Literals([
  "accept",
  "decline",
  "cancel",
]);

export type PermissionsRequestApprovalParams__AbsolutePathBuf = string;
export const PermissionsRequestApprovalParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type PermissionsRequestApprovalParams__AdditionalNetworkPermissions = {
  readonly enabled?: boolean | null;
};
export const PermissionsRequestApprovalParams__AdditionalNetworkPermissions = Schema.Struct({
  enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
});

export type PermissionsRequestApprovalParams__FileSystemAccessMode = "read" | "write" | "none";
export const PermissionsRequestApprovalParams__FileSystemAccessMode = Schema.Literals([
  "read",
  "write",
  "none",
]);

export type PermissionsRequestApprovalParams__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const PermissionsRequestApprovalParams__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type PermissionsRequestApprovalResponse__AbsolutePathBuf = string;
export const PermissionsRequestApprovalResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type PermissionsRequestApprovalResponse__AdditionalNetworkPermissions = {
  readonly enabled?: boolean | null;
};
export const PermissionsRequestApprovalResponse__AdditionalNetworkPermissions = Schema.Struct({
  enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
});

export type PermissionsRequestApprovalResponse__FileSystemAccessMode = "read" | "write" | "none";
export const PermissionsRequestApprovalResponse__FileSystemAccessMode = Schema.Literals([
  "read",
  "write",
  "none",
]);

export type PermissionsRequestApprovalResponse__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const PermissionsRequestApprovalResponse__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__AbsolutePathBuf = string;
export const ServerNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type ServerNotification__AccountLoginCompletedNotification = {
  readonly error?: string | null;
  readonly loginId?: string | null;
  readonly success: boolean;
};
export const ServerNotification__AccountLoginCompletedNotification = Schema.Struct({
  error: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  loginId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  success: Schema.Boolean,
});

export type ServerNotification__AdditionalNetworkPermissions = {
  readonly enabled?: boolean | null;
};
export const ServerNotification__AdditionalNetworkPermissions = Schema.Struct({
  enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
});

export type ServerNotification__AgentMessageDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__AgentMessageDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__AgentPath = string;
export const ServerNotification__AgentPath = Schema.String;

export type ServerNotification__AppBranding = {
  readonly category?: string | null;
  readonly developer?: string | null;
  readonly isDiscoverableApp: boolean;
  readonly privacyPolicy?: string | null;
  readonly termsOfService?: string | null;
  readonly website?: string | null;
};
export const ServerNotification__AppBranding = Schema.Struct({
  category: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developer: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  isDiscoverableApp: Schema.Boolean,
  privacyPolicy: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  termsOfService: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  website: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ description: "EXPERIMENTAL - app metadata returned by app-list APIs." });

export type ServerNotification__AppReview = { readonly status: string };
export const ServerNotification__AppReview = Schema.Struct({ status: Schema.String });

export type ServerNotification__AppScreenshot = {
  readonly fileId?: string | null;
  readonly url?: string | null;
  readonly userPrompt: string;
};
export const ServerNotification__AppScreenshot = Schema.Struct({
  fileId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  userPrompt: Schema.String,
});

export type ServerNotification__AuthMode =
  | "apikey"
  | "chatgpt"
  | "chatgptAuthTokens"
  | "agentIdentity";
export const ServerNotification__AuthMode = Schema.Literals([
  "apikey",
  "chatgpt",
  "chatgptAuthTokens",
  "agentIdentity",
]).annotate({ description: "Authentication mode for OpenAI-backed providers." });

export type ServerNotification__AutoReviewDecisionSource = "agent";
export const ServerNotification__AutoReviewDecisionSource = Schema.Literal("agent").annotate({
  description: "[UNSTABLE] Source that produced a terminal approval auto-review decision.",
});

export type ServerNotification__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const ServerNotification__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type ServerNotification__CommandExecOutputDeltaNotification = {
  readonly capReached: boolean;
  readonly deltaBase64: string;
  readonly processId: string;
  readonly stream: "stdout" | "stderr";
};
export const ServerNotification__CommandExecOutputDeltaNotification = Schema.Struct({
  capReached: Schema.Boolean.annotate({
    description:
      "`true` on the final streamed chunk for a stream when `outputBytesCap` truncated later output on that stream.",
  }),
  deltaBase64: Schema.String.annotate({ description: "Base64-encoded output bytes." }),
  processId: Schema.String.annotate({
    description:
      "Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
  }),
  stream: Schema.Literals(["stdout", "stderr"]).annotate({
    description: "Stream label for `command/exec/outputDelta` notifications.",
  }),
}).annotate({
  description:
    "Base64-encoded output chunk emitted for a streaming `command/exec` request.\n\nThese notifications are connection-scoped. If the originating connection closes, the server terminates the process.",
});

export type ServerNotification__CommandExecutionOutputDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__CommandExecutionOutputDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const ServerNotification__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type ServerNotification__ContextCompactedNotification = {
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__ContextCompactedNotification = Schema.Struct({
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ description: "Deprecated: Use `ContextCompaction` item type instead." });

export type ServerNotification__CreditsSnapshot = {
  readonly balance?: string | null;
  readonly hasCredits: boolean;
  readonly unlimited: boolean;
};
export const ServerNotification__CreditsSnapshot = Schema.Struct({
  balance: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  hasCredits: Schema.Boolean,
  unlimited: Schema.Boolean,
});

export type ServerNotification__DeprecationNoticeNotification = {
  readonly details?: string | null;
  readonly summary: string;
};
export const ServerNotification__DeprecationNoticeNotification = Schema.Struct({
  details: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional extra guidance, such as migration steps or rationale.",
      }),
      Schema.Null,
    ]),
  ),
  summary: Schema.String.annotate({ description: "Concise summary of what is deprecated." }),
});

export type ServerNotification__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const ServerNotification__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const ServerNotification__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type ServerNotification__ExternalAgentConfigImportCompletedNotification = {};
export const ServerNotification__ExternalAgentConfigImportCompletedNotification = Schema.Struct({});

export type ServerNotification__FileChangeOutputDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__FileChangeOutputDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  description:
    "Deprecated legacy notification for `apply_patch` textual output.\n\nThe server no longer emits this notification.",
});

export type ServerNotification__FileSystemAccessMode = "read" | "write" | "none";
export const ServerNotification__FileSystemAccessMode = Schema.Literals(["read", "write", "none"]);

export type ServerNotification__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const ServerNotification__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__FuzzyFileSearchMatchType = "file" | "directory";
export const ServerNotification__FuzzyFileSearchMatchType = Schema.Literals(["file", "directory"]);

export type ServerNotification__FuzzyFileSearchSessionCompletedNotification = {
  readonly sessionId: string;
};
export const ServerNotification__FuzzyFileSearchSessionCompletedNotification = Schema.Struct({
  sessionId: Schema.String,
});

export type ServerNotification__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const ServerNotification__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ServerNotification__GuardianApprovalReviewStatus =
  | "inProgress"
  | "approved"
  | "denied"
  | "timedOut"
  | "aborted";
export const ServerNotification__GuardianApprovalReviewStatus = Schema.Literals([
  "inProgress",
  "approved",
  "denied",
  "timedOut",
  "aborted",
]).annotate({ description: "[UNSTABLE] Lifecycle state for an approval auto-review." });

export type ServerNotification__GuardianCommandSource = "shell" | "unifiedExec";
export const ServerNotification__GuardianCommandSource = Schema.Literals(["shell", "unifiedExec"]);

export type ServerNotification__GuardianRiskLevel = "low" | "medium" | "high" | "critical";
export const ServerNotification__GuardianRiskLevel = Schema.Literals([
  "low",
  "medium",
  "high",
  "critical",
]).annotate({ description: "[UNSTABLE] Risk level assigned by approval auto-review." });

export type ServerNotification__GuardianUserAuthorization = "unknown" | "low" | "medium" | "high";
export const ServerNotification__GuardianUserAuthorization = Schema.Literals([
  "unknown",
  "low",
  "medium",
  "high",
]).annotate({ description: "[UNSTABLE] Authorization level assigned by approval auto-review." });

export type ServerNotification__GuardianWarningNotification = {
  readonly message: string;
  readonly threadId: string;
};
export const ServerNotification__GuardianWarningNotification = Schema.Struct({
  message: Schema.String.annotate({
    description: "Concise guardian warning message for the user.",
  }),
  threadId: Schema.String.annotate({ description: "Thread target for the guardian warning." }),
});

export type ServerNotification__HookEventName =
  | "preToolUse"
  | "permissionRequest"
  | "postToolUse"
  | "preCompact"
  | "postCompact"
  | "sessionStart"
  | "userPromptSubmit"
  | "stop";
export const ServerNotification__HookEventName = Schema.Literals([
  "preToolUse",
  "permissionRequest",
  "postToolUse",
  "preCompact",
  "postCompact",
  "sessionStart",
  "userPromptSubmit",
  "stop",
]);

export type ServerNotification__HookExecutionMode = "sync" | "async";
export const ServerNotification__HookExecutionMode = Schema.Literals(["sync", "async"]);

export type ServerNotification__HookHandlerType = "command" | "prompt" | "agent";
export const ServerNotification__HookHandlerType = Schema.Literals(["command", "prompt", "agent"]);

export type ServerNotification__HookOutputEntryKind =
  | "warning"
  | "stop"
  | "feedback"
  | "context"
  | "error";
export const ServerNotification__HookOutputEntryKind = Schema.Literals([
  "warning",
  "stop",
  "feedback",
  "context",
  "error",
]);

export type ServerNotification__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const ServerNotification__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type ServerNotification__HookRunStatus =
  | "running"
  | "completed"
  | "failed"
  | "blocked"
  | "stopped";
export const ServerNotification__HookRunStatus = Schema.Literals([
  "running",
  "completed",
  "failed",
  "blocked",
  "stopped",
]);

export type ServerNotification__HookScope = "thread" | "turn";
export const ServerNotification__HookScope = Schema.Literals(["thread", "turn"]);

export type ServerNotification__McpServerOauthLoginCompletedNotification = {
  readonly error?: string | null;
  readonly name: string;
  readonly success: boolean;
};
export const ServerNotification__McpServerOauthLoginCompletedNotification = Schema.Struct({
  error: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  success: Schema.Boolean,
});

export type ServerNotification__McpServerStartupState =
  | "starting"
  | "ready"
  | "failed"
  | "cancelled";
export const ServerNotification__McpServerStartupState = Schema.Literals([
  "starting",
  "ready",
  "failed",
  "cancelled",
]);

export type ServerNotification__McpToolCallError = { readonly message: string };
export const ServerNotification__McpToolCallError = Schema.Struct({ message: Schema.String });

export type ServerNotification__McpToolCallProgressNotification = {
  readonly itemId: string;
  readonly message: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__McpToolCallProgressNotification = Schema.Struct({
  itemId: Schema.String,
  message: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const ServerNotification__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type ServerNotification__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const ServerNotification__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type ServerNotification__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const ServerNotification__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type ServerNotification__MessagePhase = "commentary" | "final_answer";
export const ServerNotification__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type ServerNotification__ModelRerouteReason = "highRiskCyberActivity";
export const ServerNotification__ModelRerouteReason = Schema.Literal("highRiskCyberActivity");

export type ServerNotification__ModelVerification = "trustedAccessForCyber";
export const ServerNotification__ModelVerification = Schema.Literal("trustedAccessForCyber");

export type ServerNotification__NetworkApprovalProtocol =
  | "http"
  | "https"
  | "socks5Tcp"
  | "socks5Udp";
export const ServerNotification__NetworkApprovalProtocol = Schema.Literals([
  "http",
  "https",
  "socks5Tcp",
  "socks5Udp",
]);

export type ServerNotification__NonSteerableTurnKind = "review" | "compact";
export const ServerNotification__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type ServerNotification__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const ServerNotification__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type ServerNotification__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const ServerNotification__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__PlanDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__PlanDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  description:
    "EXPERIMENTAL - proposed plan streaming deltas for plan items. Clients should not assume concatenated deltas match the completed plan item content.",
});

export type ServerNotification__PlanType =
  | "free"
  | "go"
  | "plus"
  | "pro"
  | "prolite"
  | "team"
  | "self_serve_business_usage_based"
  | "business"
  | "enterprise_cbp_usage_based"
  | "enterprise"
  | "edu"
  | "unknown";
export const ServerNotification__PlanType = Schema.Literals([
  "free",
  "go",
  "plus",
  "pro",
  "prolite",
  "team",
  "self_serve_business_usage_based",
  "business",
  "enterprise_cbp_usage_based",
  "enterprise",
  "edu",
  "unknown",
]);

export type ServerNotification__ProcessExitedNotification = {
  readonly exitCode: number;
  readonly processHandle: string;
  readonly stderr: string;
  readonly stderrCapReached: boolean;
  readonly stdout: string;
  readonly stdoutCapReached: boolean;
};
export const ServerNotification__ProcessExitedNotification = Schema.Struct({
  exitCode: Schema.Number.annotate({ description: "Process exit code.", format: "int32" }).check(
    Schema.isInt(),
  ),
  processHandle: Schema.String.annotate({
    description: "Client-supplied, connection-scoped `processHandle` from `process/spawn`.",
  }),
  stderr: Schema.String.annotate({
    description:
      "Buffered stderr capture.\n\nEmpty when stderr was streamed via `process/outputDelta`.",
  }),
  stderrCapReached: Schema.Boolean.annotate({
    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: Schema.String.annotate({
    description:
      "Buffered stdout capture.\n\nEmpty when stdout was streamed via `process/outputDelta`.",
  }),
  stdoutCapReached: Schema.Boolean.annotate({
    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.",
  }),
}).annotate({ description: "Final process exit notification for `process/spawn`." });

export type ServerNotification__ProcessOutputDeltaNotification = {
  readonly capReached: boolean;
  readonly deltaBase64: string;
  readonly processHandle: string;
  readonly stream: "stdout" | "stderr";
};
export const ServerNotification__ProcessOutputDeltaNotification = Schema.Struct({
  capReached: Schema.Boolean.annotate({
    description:
      "True on the final streamed chunk for this stream when output was truncated by `outputBytesCap`.",
  }),
  deltaBase64: Schema.String.annotate({ description: "Base64-encoded output bytes." }),
  processHandle: Schema.String.annotate({
    description: "Client-supplied, connection-scoped `processHandle` from `process/spawn`.",
  }),
  stream: Schema.Literals(["stdout", "stderr"]).annotate({
    description: "Stream label for `process/outputDelta` notifications.",
  }),
}).annotate({
  description: "Base64-encoded output chunk emitted for a streaming `process/spawn` request.",
});

export type ServerNotification__RateLimitReachedType =
  | "rate_limit_reached"
  | "workspace_owner_credits_depleted"
  | "workspace_member_credits_depleted"
  | "workspace_owner_usage_limit_reached"
  | "workspace_member_usage_limit_reached";
export const ServerNotification__RateLimitReachedType = Schema.Literals([
  "rate_limit_reached",
  "workspace_owner_credits_depleted",
  "workspace_member_credits_depleted",
  "workspace_owner_usage_limit_reached",
  "workspace_member_usage_limit_reached",
]);

export type ServerNotification__RateLimitWindow = {
  readonly resetsAt?: number | null;
  readonly usedPercent: number;
  readonly windowDurationMins?: number | null;
};
export const ServerNotification__RateLimitWindow = Schema.Struct({
  resetsAt: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  usedPercent: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
  windowDurationMins: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
});

export type ServerNotification__RealtimeConversationVersion = "v1" | "v2";
export const ServerNotification__RealtimeConversationVersion = Schema.Literals(["v1", "v2"]);

export type ServerNotification__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const ServerNotification__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type ServerNotification__ReasoningSummaryPartAddedNotification = {
  readonly itemId: string;
  readonly summaryIndex: number;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__ReasoningSummaryPartAddedNotification = Schema.Struct({
  itemId: Schema.String,
  summaryIndex: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__ReasoningSummaryTextDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly summaryIndex: number;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__ReasoningSummaryTextDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  summaryIndex: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__ReasoningTextDeltaNotification = {
  readonly contentIndex: number;
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__ReasoningTextDeltaNotification = Schema.Struct({
  contentIndex: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__RemoteControlConnectionStatus =
  | "disabled"
  | "connecting"
  | "connected"
  | "errored";
export const ServerNotification__RemoteControlConnectionStatus = Schema.Literals([
  "disabled",
  "connecting",
  "connected",
  "errored",
]);

export type ServerNotification__RequestId = string | number;
export const ServerNotification__RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]);

export type ServerNotification__SkillsChangedNotification = {};
export const ServerNotification__SkillsChangedNotification = Schema.Struct({}).annotate({
  description:
    "Notification emitted when watched local skill files change.\n\nTreat this as an invalidation signal and re-run `skills/list` with the client's current parameters when refreshed skill metadata is needed.",
});

export type ServerNotification__TerminalInteractionNotification = {
  readonly itemId: string;
  readonly processId: string;
  readonly stdin: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__TerminalInteractionNotification = Schema.Struct({
  itemId: Schema.String,
  processId: Schema.String,
  stdin: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const ServerNotification__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ServerNotification__TextPosition = { readonly column: number; readonly line: number };
export const ServerNotification__TextPosition = Schema.Struct({
  column: Schema.Number.annotate({
    description: "1-based column number (in Unicode scalar values).",
    format: "uint",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  line: Schema.Number.annotate({ description: "1-based line number.", format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type ServerNotification__ThreadActiveFlag = "waitingOnApproval" | "waitingOnUserInput";
export const ServerNotification__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type ServerNotification__ThreadArchivedNotification = { readonly threadId: string };
export const ServerNotification__ThreadArchivedNotification = Schema.Struct({
  threadId: Schema.String,
});

export type ServerNotification__ThreadClosedNotification = { readonly threadId: string };
export const ServerNotification__ThreadClosedNotification = Schema.Struct({
  threadId: Schema.String,
});

export type ServerNotification__ThreadGoalClearedNotification = { readonly threadId: string };
export const ServerNotification__ThreadGoalClearedNotification = Schema.Struct({
  threadId: Schema.String,
});

export type ServerNotification__ThreadGoalStatus =
  | "active"
  | "paused"
  | "budgetLimited"
  | "complete";
export const ServerNotification__ThreadGoalStatus = Schema.Literals([
  "active",
  "paused",
  "budgetLimited",
  "complete",
]);

export type ServerNotification__ThreadId = string;
export const ServerNotification__ThreadId = Schema.String;

export type ServerNotification__ThreadNameUpdatedNotification = {
  readonly threadId: string;
  readonly threadName?: string | null;
};
export const ServerNotification__ThreadNameUpdatedNotification = Schema.Struct({
  threadId: Schema.String,
  threadName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ServerNotification__ThreadRealtimeAudioChunk = {
  readonly data: string;
  readonly itemId?: string | null;
  readonly numChannels: number;
  readonly sampleRate: number;
  readonly samplesPerChannel?: number | null;
};
export const ServerNotification__ThreadRealtimeAudioChunk = Schema.Struct({
  data: Schema.String,
  itemId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  numChannels: Schema.Number.annotate({ format: "uint16" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  sampleRate: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  samplesPerChannel: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint32" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
}).annotate({ description: "EXPERIMENTAL - thread realtime audio chunk." });

export type ServerNotification__ThreadRealtimeClosedNotification = {
  readonly reason?: string | null;
  readonly threadId: string;
};
export const ServerNotification__ThreadRealtimeClosedNotification = Schema.Struct({
  reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
}).annotate({ description: "EXPERIMENTAL - emitted when thread realtime transport closes." });

export type ServerNotification__ThreadRealtimeErrorNotification = {
  readonly message: string;
  readonly threadId: string;
};
export const ServerNotification__ThreadRealtimeErrorNotification = Schema.Struct({
  message: Schema.String,
  threadId: Schema.String,
}).annotate({ description: "EXPERIMENTAL - emitted when thread realtime encounters an error." });

export type ServerNotification__ThreadRealtimeItemAddedNotification = {
  readonly item: unknown;
  readonly threadId: string;
};
export const ServerNotification__ThreadRealtimeItemAddedNotification = Schema.Struct({
  item: Schema.Unknown,
  threadId: Schema.String,
}).annotate({
  description: "EXPERIMENTAL - raw non-audio thread realtime item emitted by the backend.",
});

export type ServerNotification__ThreadRealtimeSdpNotification = {
  readonly sdp: string;
  readonly threadId: string;
};
export const ServerNotification__ThreadRealtimeSdpNotification = Schema.Struct({
  sdp: Schema.String,
  threadId: Schema.String,
}).annotate({
  description: "EXPERIMENTAL - emitted with the remote SDP for a WebRTC realtime session.",
});

export type ServerNotification__ThreadRealtimeTranscriptDeltaNotification = {
  readonly delta: string;
  readonly role: string;
  readonly threadId: string;
};
export const ServerNotification__ThreadRealtimeTranscriptDeltaNotification = Schema.Struct({
  delta: Schema.String.annotate({ description: "Live transcript delta from the realtime event." }),
  role: Schema.String,
  threadId: Schema.String,
}).annotate({
  description:
    "EXPERIMENTAL - flat transcript delta emitted whenever realtime transcript text changes.",
});

export type ServerNotification__ThreadRealtimeTranscriptDoneNotification = {
  readonly role: string;
  readonly text: string;
  readonly threadId: string;
};
export const ServerNotification__ThreadRealtimeTranscriptDoneNotification = Schema.Struct({
  role: Schema.String,
  text: Schema.String.annotate({ description: "Final complete text for the transcript part." }),
  threadId: Schema.String,
}).annotate({
  description:
    "EXPERIMENTAL - final transcript text emitted when realtime completes a transcript part.",
});

export type ServerNotification__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const ServerNotification__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type ServerNotification__ThreadUnarchivedNotification = { readonly threadId: string };
export const ServerNotification__ThreadUnarchivedNotification = Schema.Struct({
  threadId: Schema.String,
});

export type ServerNotification__TokenUsageBreakdown = {
  readonly cachedInputTokens: number;
  readonly inputTokens: number;
  readonly outputTokens: number;
  readonly reasoningOutputTokens: number;
  readonly totalTokens: number;
};
export const ServerNotification__TokenUsageBreakdown = Schema.Struct({
  cachedInputTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  inputTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  outputTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  reasoningOutputTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  totalTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
});

export type ServerNotification__TurnDiffUpdatedNotification = {
  readonly diff: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__TurnDiffUpdatedNotification = Schema.Struct({
  diff: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  description:
    "Notification that the turn-level unified diff has changed. Contains the latest aggregated diff across all file changes in the turn.",
});

export type ServerNotification__TurnPlanStepStatus = "pending" | "inProgress" | "completed";
export const ServerNotification__TurnPlanStepStatus = Schema.Literals([
  "pending",
  "inProgress",
  "completed",
]);

export type ServerNotification__TurnStatus = "completed" | "interrupted" | "failed" | "inProgress";
export const ServerNotification__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type ServerNotification__WarningNotification = {
  readonly message: string;
  readonly threadId?: string | null;
};
export const ServerNotification__WarningNotification = Schema.Struct({
  message: Schema.String.annotate({ description: "Concise warning message for the user." }),
  threadId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional thread target when the warning applies to a specific thread.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ServerNotification__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const ServerNotification__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__WindowsSandboxSetupMode = "elevated" | "unelevated";
export const ServerNotification__WindowsSandboxSetupMode = Schema.Literals([
  "elevated",
  "unelevated",
]);

export type ServerNotification__WindowsWorldWritableWarningNotification = {
  readonly extraCount: number;
  readonly failedScan: boolean;
  readonly samplePaths: ReadonlyArray<string>;
};
export const ServerNotification__WindowsWorldWritableWarningNotification = Schema.Struct({
  extraCount: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  failedScan: Schema.Boolean,
  samplePaths: Schema.Array(Schema.String),
});

export type ServerRequest__AbsolutePathBuf = string;
export const ServerRequest__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type ServerRequest__AdditionalNetworkPermissions = { readonly enabled?: boolean | null };
export const ServerRequest__AdditionalNetworkPermissions = Schema.Struct({
  enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
});

export type ServerRequest__ChatgptAuthTokensRefreshReason = "unauthorized";
export const ServerRequest__ChatgptAuthTokensRefreshReason = Schema.Literal("unauthorized");

export type ServerRequest__DynamicToolCallParams = {
  readonly arguments: unknown;
  readonly callId: string;
  readonly namespace?: string | null;
  readonly threadId: string;
  readonly tool: string;
  readonly turnId: string;
};
export const ServerRequest__DynamicToolCallParams = Schema.Struct({
  arguments: Schema.Unknown,
  callId: Schema.String,
  namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
  tool: Schema.String,
  turnId: Schema.String,
});

export type ServerRequest__FileChange =
  | { readonly content: string; readonly type: "add" }
  | { readonly content: string; readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update"; readonly unified_diff: string };
export const ServerRequest__FileChange = Schema.Union(
  [
    Schema.Struct({
      content: Schema.String,
      type: Schema.Literal("add").annotate({ title: "AddFileChangeType" }),
    }).annotate({ title: "AddFileChange" }),
    Schema.Struct({
      content: Schema.String,
      type: Schema.Literal("delete").annotate({ title: "DeleteFileChangeType" }),
    }).annotate({ title: "DeleteFileChange" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdateFileChangeType" }),
      unified_diff: Schema.String,
    }).annotate({ title: "UpdateFileChange" }),
  ],
  { mode: "oneOf" },
);

export type ServerRequest__FileChangeRequestApprovalParams = {
  readonly grantRoot?: string | null;
  readonly itemId: string;
  readonly reason?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerRequest__FileChangeRequestApprovalParams = Schema.Struct({
  grantRoot: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "[UNSTABLE] When set, the agent is asking the user to allow writes under this root for the remainder of the session (unclear if this is honored today).",
      }),
      Schema.Null,
    ]),
  ),
  itemId: Schema.String,
  reason: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional explanatory reason (e.g. request for extra write access).",
      }),
      Schema.Null,
    ]),
  ),
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerRequest__FileSystemAccessMode = "read" | "write" | "none";
export const ServerRequest__FileSystemAccessMode = Schema.Literals(["read", "write", "none"]);

export type ServerRequest__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const ServerRequest__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type ServerRequest__McpElicitationArrayType = "array";
export const ServerRequest__McpElicitationArrayType = Schema.Literal("array");

export type ServerRequest__McpElicitationBooleanType = "boolean";
export const ServerRequest__McpElicitationBooleanType = Schema.Literal("boolean");

export type ServerRequest__McpElicitationConstOption = {
  readonly const: string;
  readonly title: string;
};
export const ServerRequest__McpElicitationConstOption = Schema.Struct({
  const: Schema.String,
  title: Schema.String,
});

export type ServerRequest__McpElicitationNumberType = "number" | "integer";
export const ServerRequest__McpElicitationNumberType = Schema.Literals(["number", "integer"]);

export type ServerRequest__McpElicitationObjectType = "object";
export const ServerRequest__McpElicitationObjectType = Schema.Literal("object");

export type ServerRequest__McpElicitationStringFormat = "email" | "uri" | "date" | "date-time";
export const ServerRequest__McpElicitationStringFormat = Schema.Literals([
  "email",
  "uri",
  "date",
  "date-time",
]);

export type ServerRequest__McpElicitationStringType = "string";
export const ServerRequest__McpElicitationStringType = Schema.Literal("string");

export type ServerRequest__NetworkApprovalProtocol = "http" | "https" | "socks5Tcp" | "socks5Udp";
export const ServerRequest__NetworkApprovalProtocol = Schema.Literals([
  "http",
  "https",
  "socks5Tcp",
  "socks5Udp",
]);

export type ServerRequest__NetworkPolicyRuleAction = "allow" | "deny";
export const ServerRequest__NetworkPolicyRuleAction = Schema.Literals(["allow", "deny"]);

export type ServerRequest__ParsedCommand =
  | { readonly cmd: string; readonly name: string; readonly path: string; readonly type: "read" }
  | { readonly cmd: string; readonly path?: string | null; readonly type: "list_files" }
  | {
      readonly cmd: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly cmd: string; readonly type: "unknown" };
export const ServerRequest__ParsedCommand = Schema.Union(
  [
    Schema.Struct({
      cmd: Schema.String,
      name: Schema.String,
      path: Schema.String.annotate({
        description:
          "(Best effort) Path to the file being read by the command. When possible, this is an absolute path, though when relative, it should be resolved against the `cwd`` that will be used to run the command to derive the absolute path.",
      }),
      type: Schema.Literal("read").annotate({ title: "ReadParsedCommandType" }),
    }).annotate({ title: "ReadParsedCommand" }),
    Schema.Struct({
      cmd: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("list_files").annotate({ title: "ListFilesParsedCommandType" }),
    }).annotate({ title: "ListFilesParsedCommand" }),
    Schema.Struct({
      cmd: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchParsedCommandType" }),
    }).annotate({ title: "SearchParsedCommand" }),
    Schema.Struct({
      cmd: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownParsedCommandType" }),
    }).annotate({ title: "UnknownParsedCommand" }),
  ],
  { mode: "oneOf" },
);

export type ServerRequest__RequestId = string | number;
export const ServerRequest__RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]);

export type ServerRequest__ThreadId = string;
export const ServerRequest__ThreadId = Schema.String;

export type ServerRequest__ToolRequestUserInputOption = {
  readonly description: string;
  readonly label: string;
};
export const ServerRequest__ToolRequestUserInputOption = Schema.Struct({
  description: Schema.String,
  label: Schema.String,
}).annotate({
  description: "EXPERIMENTAL. Defines a single selectable option for request_user_input.",
});

export type ToolRequestUserInputParams__ToolRequestUserInputOption = {
  readonly description: string;
  readonly label: string;
};
export const ToolRequestUserInputParams__ToolRequestUserInputOption = Schema.Struct({
  description: Schema.String,
  label: Schema.String,
}).annotate({
  description: "EXPERIMENTAL. Defines a single selectable option for request_user_input.",
});

export type ToolRequestUserInputResponse__ToolRequestUserInputAnswer = {
  readonly answers: ReadonlyArray<string>;
};
export const ToolRequestUserInputResponse__ToolRequestUserInputAnswer = Schema.Struct({
  answers: Schema.Array(Schema.String),
}).annotate({
  description: "EXPERIMENTAL. Captures a user's answer to a request_user_input question.",
});

export type V1InitializeParams__ClientInfo = {
  readonly name: string;
  readonly title?: string | null;
  readonly version: string;
};
export const V1InitializeParams__ClientInfo = Schema.Struct({
  name: Schema.String,
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  version: Schema.String,
});

export type V1InitializeParams__InitializeCapabilities = {
  readonly experimentalApi?: boolean;
  readonly optOutNotificationMethods?: ReadonlyArray<string> | null;
};
export const V1InitializeParams__InitializeCapabilities = Schema.Struct({
  experimentalApi: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "Opt into receiving experimental API methods and fields.",
      default: false,
    }),
  ),
  optOutNotificationMethods: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Exact notification method names that should be suppressed for this connection (for example `thread/started`).",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ description: "Client-declared capabilities negotiated during initialize." });

export type V2AccountRateLimitsUpdatedNotification__CreditsSnapshot = {
  readonly balance?: string | null;
  readonly hasCredits: boolean;
  readonly unlimited: boolean;
};
export const V2AccountRateLimitsUpdatedNotification__CreditsSnapshot = Schema.Struct({
  balance: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  hasCredits: Schema.Boolean,
  unlimited: Schema.Boolean,
});

export type V2AccountRateLimitsUpdatedNotification__PlanType =
  | "free"
  | "go"
  | "plus"
  | "pro"
  | "prolite"
  | "team"
  | "self_serve_business_usage_based"
  | "business"
  | "enterprise_cbp_usage_based"
  | "enterprise"
  | "edu"
  | "unknown";
export const V2AccountRateLimitsUpdatedNotification__PlanType = Schema.Literals([
  "free",
  "go",
  "plus",
  "pro",
  "prolite",
  "team",
  "self_serve_business_usage_based",
  "business",
  "enterprise_cbp_usage_based",
  "enterprise",
  "edu",
  "unknown",
]);

export type V2AccountRateLimitsUpdatedNotification__RateLimitReachedType =
  | "rate_limit_reached"
  | "workspace_owner_credits_depleted"
  | "workspace_member_credits_depleted"
  | "workspace_owner_usage_limit_reached"
  | "workspace_member_usage_limit_reached";
export const V2AccountRateLimitsUpdatedNotification__RateLimitReachedType = Schema.Literals([
  "rate_limit_reached",
  "workspace_owner_credits_depleted",
  "workspace_member_credits_depleted",
  "workspace_owner_usage_limit_reached",
  "workspace_member_usage_limit_reached",
]);

export type V2AccountRateLimitsUpdatedNotification__RateLimitWindow = {
  readonly resetsAt?: number | null;
  readonly usedPercent: number;
  readonly windowDurationMins?: number | null;
};
export const V2AccountRateLimitsUpdatedNotification__RateLimitWindow = Schema.Struct({
  resetsAt: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  usedPercent: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
  windowDurationMins: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
});

export type V2AccountUpdatedNotification__AuthMode =
  | "apikey"
  | "chatgpt"
  | "chatgptAuthTokens"
  | "agentIdentity";
export const V2AccountUpdatedNotification__AuthMode = Schema.Literals([
  "apikey",
  "chatgpt",
  "chatgptAuthTokens",
  "agentIdentity",
]).annotate({ description: "Authentication mode for OpenAI-backed providers." });

export type V2AccountUpdatedNotification__PlanType =
  | "free"
  | "go"
  | "plus"
  | "pro"
  | "prolite"
  | "team"
  | "self_serve_business_usage_based"
  | "business"
  | "enterprise_cbp_usage_based"
  | "enterprise"
  | "edu"
  | "unknown";
export const V2AccountUpdatedNotification__PlanType = Schema.Literals([
  "free",
  "go",
  "plus",
  "pro",
  "prolite",
  "team",
  "self_serve_business_usage_based",
  "business",
  "enterprise_cbp_usage_based",
  "enterprise",
  "edu",
  "unknown",
]);

export type V2AppListUpdatedNotification__AppBranding = {
  readonly category?: string | null;
  readonly developer?: string | null;
  readonly isDiscoverableApp: boolean;
  readonly privacyPolicy?: string | null;
  readonly termsOfService?: string | null;
  readonly website?: string | null;
};
export const V2AppListUpdatedNotification__AppBranding = Schema.Struct({
  category: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developer: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  isDiscoverableApp: Schema.Boolean,
  privacyPolicy: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  termsOfService: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  website: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ description: "EXPERIMENTAL - app metadata returned by app-list APIs." });

export type V2AppListUpdatedNotification__AppReview = { readonly status: string };
export const V2AppListUpdatedNotification__AppReview = Schema.Struct({ status: Schema.String });

export type V2AppListUpdatedNotification__AppScreenshot = {
  readonly fileId?: string | null;
  readonly url?: string | null;
  readonly userPrompt: string;
};
export const V2AppListUpdatedNotification__AppScreenshot = Schema.Struct({
  fileId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  userPrompt: Schema.String,
});

export type V2AppsListResponse__AppBranding = {
  readonly category?: string | null;
  readonly developer?: string | null;
  readonly isDiscoverableApp: boolean;
  readonly privacyPolicy?: string | null;
  readonly termsOfService?: string | null;
  readonly website?: string | null;
};
export const V2AppsListResponse__AppBranding = Schema.Struct({
  category: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developer: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  isDiscoverableApp: Schema.Boolean,
  privacyPolicy: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  termsOfService: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  website: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ description: "EXPERIMENTAL - app metadata returned by app-list APIs." });

export type V2AppsListResponse__AppReview = { readonly status: string };
export const V2AppsListResponse__AppReview = Schema.Struct({ status: Schema.String });

export type V2AppsListResponse__AppScreenshot = {
  readonly fileId?: string | null;
  readonly url?: string | null;
  readonly userPrompt: string;
};
export const V2AppsListResponse__AppScreenshot = Schema.Struct({
  fileId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  userPrompt: Schema.String,
});

export type V2CancelLoginAccountResponse__CancelLoginAccountStatus = "canceled" | "notFound";
export const V2CancelLoginAccountResponse__CancelLoginAccountStatus = Schema.Literals([
  "canceled",
  "notFound",
]);

export type V2CommandExecParams__AbsolutePathBuf = string;
export const V2CommandExecParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2CommandExecParams__CommandExecTerminalSize = {
  readonly cols: number;
  readonly rows: number;
};
export const V2CommandExecParams__CommandExecTerminalSize = Schema.Struct({
  cols: Schema.Number.annotate({
    description: "Terminal width in character cells.",
    format: "uint16",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  rows: Schema.Number.annotate({
    description: "Terminal height in character cells.",
    format: "uint16",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
}).annotate({ description: "PTY size in character cells for `command/exec` PTY sessions." });

export type V2CommandExecParams__FileSystemAccessMode = "read" | "write" | "none";
export const V2CommandExecParams__FileSystemAccessMode = Schema.Literals(["read", "write", "none"]);

export type V2CommandExecParams__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const V2CommandExecParams__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type V2CommandExecParams__PermissionProfileNetworkPermissions = {
  readonly enabled: boolean;
};
export const V2CommandExecParams__PermissionProfileNetworkPermissions = Schema.Struct({
  enabled: Schema.Boolean,
});

export type V2ConfigBatchWriteParams__MergeStrategy = "replace" | "upsert";
export const V2ConfigBatchWriteParams__MergeStrategy = Schema.Literals(["replace", "upsert"]);

export type V2ConfigReadResponse__AbsolutePathBuf = string;
export const V2ConfigReadResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ConfigReadResponse__AnalyticsConfig = {
  readonly enabled?: boolean | null;
  readonly [x: string]: unknown;
};
export const V2ConfigReadResponse__AnalyticsConfig = Schema.StructWithRest(
  Schema.Struct({ enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])) }),
  [Schema.Record(Schema.String, Schema.Unknown)],
);

export type V2ConfigReadResponse__AppToolApproval = "auto" | "prompt" | "approve";
export const V2ConfigReadResponse__AppToolApproval = Schema.Literals(["auto", "prompt", "approve"]);

export type V2ConfigReadResponse__AppToolsConfig = {};
export const V2ConfigReadResponse__AppToolsConfig = Schema.Struct({});

export type V2ConfigReadResponse__ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
export const V2ConfigReadResponse__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2ConfigReadResponse__AppsDefaultConfig = {
  readonly destructive_enabled?: boolean;
  readonly enabled?: boolean;
  readonly open_world_enabled?: boolean;
};
export const V2ConfigReadResponse__AppsDefaultConfig = Schema.Struct({
  destructive_enabled: Schema.optionalKey(Schema.Boolean.annotate({ default: true })),
  enabled: Schema.optionalKey(Schema.Boolean.annotate({ default: true })),
  open_world_enabled: Schema.optionalKey(Schema.Boolean.annotate({ default: true })),
});

export type V2ConfigReadResponse__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2ConfigReadResponse__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2ConfigReadResponse__ForcedLoginMethod = "chatgpt" | "api";
export const V2ConfigReadResponse__ForcedLoginMethod = Schema.Literals(["chatgpt", "api"]);

export type V2ConfigReadResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ConfigReadResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ConfigReadResponse__ReasoningSummary = "auto" | "concise" | "detailed" | "none";
export const V2ConfigReadResponse__ReasoningSummary = Schema.Union(
  [
    Schema.Literals(["auto", "concise", "detailed"]),
    Schema.Literal("none").annotate({ description: "Option to disable reasoning summaries." }),
  ],
  { mode: "oneOf" },
).annotate({
  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",
});

export type V2ConfigReadResponse__SandboxMode =
  | "read-only"
  | "workspace-write"
  | "danger-full-access";
export const V2ConfigReadResponse__SandboxMode = Schema.Literals([
  "read-only",
  "workspace-write",
  "danger-full-access",
]);

export type V2ConfigReadResponse__SandboxWorkspaceWrite = {
  readonly exclude_slash_tmp?: boolean;
  readonly exclude_tmpdir_env_var?: boolean;
  readonly network_access?: boolean;
  readonly writable_roots?: ReadonlyArray<string>;
};
export const V2ConfigReadResponse__SandboxWorkspaceWrite = Schema.Struct({
  exclude_slash_tmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  exclude_tmpdir_env_var: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  network_access: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  writable_roots: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
});

export type V2ConfigReadResponse__Verbosity = "low" | "medium" | "high";
export const V2ConfigReadResponse__Verbosity = Schema.Literals(["low", "medium", "high"]).annotate({
  description:
    "Controls output length/detail on GPT-5 models via the Responses API. Serialized with lowercase values to match the OpenAI API.",
});

export type V2ConfigReadResponse__WebSearchContextSize = "low" | "medium" | "high";
export const V2ConfigReadResponse__WebSearchContextSize = Schema.Literals([
  "low",
  "medium",
  "high",
]);

export type V2ConfigReadResponse__WebSearchLocation = {
  readonly city?: string | null;
  readonly country?: string | null;
  readonly region?: string | null;
  readonly timezone?: string | null;
};
export const V2ConfigReadResponse__WebSearchLocation = Schema.Struct({
  city: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  country: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  region: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  timezone: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ConfigReadResponse__WebSearchMode = "disabled" | "cached" | "live";
export const V2ConfigReadResponse__WebSearchMode = Schema.Literals(["disabled", "cached", "live"]);

export type V2ConfigRequirementsReadResponse__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2ConfigRequirementsReadResponse__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2ConfigRequirementsReadResponse__ConfiguredHookHandler =
  | {
      readonly async: boolean;
      readonly command: string;
      readonly statusMessage?: string | null;
      readonly timeoutSec?: number | null;
      readonly type: "command";
    }
  | { readonly type: "prompt" }
  | { readonly type: "agent" };
export const V2ConfigRequirementsReadResponse__ConfiguredHookHandler = Schema.Union(
  [
    Schema.Struct({
      async: Schema.Boolean,
      command: Schema.String,
      statusMessage: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      timeoutSec: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint64" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(0)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("command").annotate({ title: "CommandConfiguredHookHandlerType" }),
    }).annotate({ title: "CommandConfiguredHookHandler" }),
    Schema.Struct({
      type: Schema.Literal("prompt").annotate({ title: "PromptConfiguredHookHandlerType" }),
    }).annotate({ title: "PromptConfiguredHookHandler" }),
    Schema.Struct({
      type: Schema.Literal("agent").annotate({ title: "AgentConfiguredHookHandlerType" }),
    }).annotate({ title: "AgentConfiguredHookHandler" }),
  ],
  { mode: "oneOf" },
);

export type V2ConfigRequirementsReadResponse__NetworkDomainPermission = "allow" | "deny";
export const V2ConfigRequirementsReadResponse__NetworkDomainPermission = Schema.Literals([
  "allow",
  "deny",
]);

export type V2ConfigRequirementsReadResponse__NetworkUnixSocketPermission = "allow" | "none";
export const V2ConfigRequirementsReadResponse__NetworkUnixSocketPermission = Schema.Literals([
  "allow",
  "none",
]);

export type V2ConfigRequirementsReadResponse__ResidencyRequirement = "us";
export const V2ConfigRequirementsReadResponse__ResidencyRequirement = Schema.Literal("us");

export type V2ConfigRequirementsReadResponse__SandboxMode =
  | "read-only"
  | "workspace-write"
  | "danger-full-access";
export const V2ConfigRequirementsReadResponse__SandboxMode = Schema.Literals([
  "read-only",
  "workspace-write",
  "danger-full-access",
]);

export type V2ConfigRequirementsReadResponse__WebSearchMode = "disabled" | "cached" | "live";
export const V2ConfigRequirementsReadResponse__WebSearchMode = Schema.Literals([
  "disabled",
  "cached",
  "live",
]);

export type V2ConfigValueWriteParams__MergeStrategy = "replace" | "upsert";
export const V2ConfigValueWriteParams__MergeStrategy = Schema.Literals(["replace", "upsert"]);

export type V2ConfigWarningNotification__TextPosition = {
  readonly column: number;
  readonly line: number;
};
export const V2ConfigWarningNotification__TextPosition = Schema.Struct({
  column: Schema.Number.annotate({
    description: "1-based column number (in Unicode scalar values).",
    format: "uint",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  line: Schema.Number.annotate({ description: "1-based line number.", format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ConfigWriteResponse__AbsolutePathBuf = string;
export const V2ConfigWriteResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ConfigWriteResponse__WriteStatus = "ok" | "okOverridden";
export const V2ConfigWriteResponse__WriteStatus = Schema.Literals(["ok", "okOverridden"]);

export type V2ErrorNotification__NonSteerableTurnKind = "review" | "compact";
export const V2ErrorNotification__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type V2ExperimentalFeatureListResponse__ExperimentalFeature = {
  readonly announcement?: string | null;
  readonly defaultEnabled: boolean;
  readonly description?: string | null;
  readonly displayName?: string | null;
  readonly enabled: boolean;
  readonly name: string;
  readonly stage: "beta" | "underDevelopment" | "stable" | "deprecated" | "removed";
};
export const V2ExperimentalFeatureListResponse__ExperimentalFeature = Schema.Struct({
  announcement: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Announcement copy shown to users when the feature is introduced. Null when this feature is not in beta.",
      }),
      Schema.Null,
    ]),
  ),
  defaultEnabled: Schema.Boolean.annotate({
    description: "Whether this feature is enabled by default.",
  }),
  description: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Short summary describing what the feature does. Null when this feature is not in beta.",
      }),
      Schema.Null,
    ]),
  ),
  displayName: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "User-facing display name shown in the experimental features UI. Null when this feature is not in beta.",
      }),
      Schema.Null,
    ]),
  ),
  enabled: Schema.Boolean.annotate({
    description: "Whether this feature is currently enabled in the loaded config.",
  }),
  name: Schema.String.annotate({
    description: "Stable key used in config.toml and CLI flag toggles.",
  }),
  stage: Schema.Literals(["beta", "underDevelopment", "stable", "deprecated", "removed"]).annotate({
    description: "Lifecycle stage of this feature flag.",
  }),
});

export type V2ExternalAgentConfigDetectResponse__CommandMigration = { readonly name: string };
export const V2ExternalAgentConfigDetectResponse__CommandMigration = Schema.Struct({
  name: Schema.String,
});

export type V2ExternalAgentConfigDetectResponse__ExternalAgentConfigMigrationItemType =
  | "AGENTS_MD"
  | "CONFIG"
  | "SKILLS"
  | "PLUGINS"
  | "MCP_SERVER_CONFIG"
  | "SUBAGENTS"
  | "HOOKS"
  | "COMMANDS"
  | "SESSIONS";
export const V2ExternalAgentConfigDetectResponse__ExternalAgentConfigMigrationItemType =
  Schema.Literals([
    "AGENTS_MD",
    "CONFIG",
    "SKILLS",
    "PLUGINS",
    "MCP_SERVER_CONFIG",
    "SUBAGENTS",
    "HOOKS",
    "COMMANDS",
    "SESSIONS",
  ]);

export type V2ExternalAgentConfigDetectResponse__HookMigration = { readonly name: string };
export const V2ExternalAgentConfigDetectResponse__HookMigration = Schema.Struct({
  name: Schema.String,
});

export type V2ExternalAgentConfigDetectResponse__McpServerMigration = { readonly name: string };
export const V2ExternalAgentConfigDetectResponse__McpServerMigration = Schema.Struct({
  name: Schema.String,
});

export type V2ExternalAgentConfigDetectResponse__PluginsMigration = {
  readonly marketplaceName: string;
  readonly pluginNames: ReadonlyArray<string>;
};
export const V2ExternalAgentConfigDetectResponse__PluginsMigration = Schema.Struct({
  marketplaceName: Schema.String,
  pluginNames: Schema.Array(Schema.String),
});

export type V2ExternalAgentConfigDetectResponse__SessionMigration = {
  readonly cwd: string;
  readonly path: string;
  readonly title?: string | null;
};
export const V2ExternalAgentConfigDetectResponse__SessionMigration = Schema.Struct({
  cwd: Schema.String,
  path: Schema.String,
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ExternalAgentConfigDetectResponse__SubagentMigration = { readonly name: string };
export const V2ExternalAgentConfigDetectResponse__SubagentMigration = Schema.Struct({
  name: Schema.String,
});

export type V2ExternalAgentConfigImportParams__CommandMigration = { readonly name: string };
export const V2ExternalAgentConfigImportParams__CommandMigration = Schema.Struct({
  name: Schema.String,
});

export type V2ExternalAgentConfigImportParams__ExternalAgentConfigMigrationItemType =
  | "AGENTS_MD"
  | "CONFIG"
  | "SKILLS"
  | "PLUGINS"
  | "MCP_SERVER_CONFIG"
  | "SUBAGENTS"
  | "HOOKS"
  | "COMMANDS"
  | "SESSIONS";
export const V2ExternalAgentConfigImportParams__ExternalAgentConfigMigrationItemType =
  Schema.Literals([
    "AGENTS_MD",
    "CONFIG",
    "SKILLS",
    "PLUGINS",
    "MCP_SERVER_CONFIG",
    "SUBAGENTS",
    "HOOKS",
    "COMMANDS",
    "SESSIONS",
  ]);

export type V2ExternalAgentConfigImportParams__HookMigration = { readonly name: string };
export const V2ExternalAgentConfigImportParams__HookMigration = Schema.Struct({
  name: Schema.String,
});

export type V2ExternalAgentConfigImportParams__McpServerMigration = { readonly name: string };
export const V2ExternalAgentConfigImportParams__McpServerMigration = Schema.Struct({
  name: Schema.String,
});

export type V2ExternalAgentConfigImportParams__PluginsMigration = {
  readonly marketplaceName: string;
  readonly pluginNames: ReadonlyArray<string>;
};
export const V2ExternalAgentConfigImportParams__PluginsMigration = Schema.Struct({
  marketplaceName: Schema.String,
  pluginNames: Schema.Array(Schema.String),
});

export type V2ExternalAgentConfigImportParams__SessionMigration = {
  readonly cwd: string;
  readonly path: string;
  readonly title?: string | null;
};
export const V2ExternalAgentConfigImportParams__SessionMigration = Schema.Struct({
  cwd: Schema.String,
  path: Schema.String,
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ExternalAgentConfigImportParams__SubagentMigration = { readonly name: string };
export const V2ExternalAgentConfigImportParams__SubagentMigration = Schema.Struct({
  name: Schema.String,
});

export type V2FileChangePatchUpdatedNotification__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2FileChangePatchUpdatedNotification__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2FsChangedNotification__AbsolutePathBuf = string;
export const V2FsChangedNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsReadDirectoryResponse__FsReadDirectoryEntry = {
  readonly fileName: string;
  readonly isDirectory: boolean;
  readonly isFile: boolean;
};
export const V2FsReadDirectoryResponse__FsReadDirectoryEntry = Schema.Struct({
  fileName: Schema.String.annotate({
    description: "Direct child entry name only, not an absolute or relative path.",
  }),
  isDirectory: Schema.Boolean.annotate({
    description: "Whether this entry resolves to a directory.",
  }),
  isFile: Schema.Boolean.annotate({
    description: "Whether this entry resolves to a regular file.",
  }),
}).annotate({ description: "A directory entry returned by `fs/readDirectory`." });

export type V2GetAccountRateLimitsResponse__CreditsSnapshot = {
  readonly balance?: string | null;
  readonly hasCredits: boolean;
  readonly unlimited: boolean;
};
export const V2GetAccountRateLimitsResponse__CreditsSnapshot = Schema.Struct({
  balance: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  hasCredits: Schema.Boolean,
  unlimited: Schema.Boolean,
});

export type V2GetAccountRateLimitsResponse__PlanType =
  | "free"
  | "go"
  | "plus"
  | "pro"
  | "prolite"
  | "team"
  | "self_serve_business_usage_based"
  | "business"
  | "enterprise_cbp_usage_based"
  | "enterprise"
  | "edu"
  | "unknown";
export const V2GetAccountRateLimitsResponse__PlanType = Schema.Literals([
  "free",
  "go",
  "plus",
  "pro",
  "prolite",
  "team",
  "self_serve_business_usage_based",
  "business",
  "enterprise_cbp_usage_based",
  "enterprise",
  "edu",
  "unknown",
]);

export type V2GetAccountRateLimitsResponse__RateLimitReachedType =
  | "rate_limit_reached"
  | "workspace_owner_credits_depleted"
  | "workspace_member_credits_depleted"
  | "workspace_owner_usage_limit_reached"
  | "workspace_member_usage_limit_reached";
export const V2GetAccountRateLimitsResponse__RateLimitReachedType = Schema.Literals([
  "rate_limit_reached",
  "workspace_owner_credits_depleted",
  "workspace_member_credits_depleted",
  "workspace_owner_usage_limit_reached",
  "workspace_member_usage_limit_reached",
]);

export type V2GetAccountRateLimitsResponse__RateLimitWindow = {
  readonly resetsAt?: number | null;
  readonly usedPercent: number;
  readonly windowDurationMins?: number | null;
};
export const V2GetAccountRateLimitsResponse__RateLimitWindow = Schema.Struct({
  resetsAt: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  usedPercent: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
  windowDurationMins: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
});

export type V2GetAccountResponse__PlanType =
  | "free"
  | "go"
  | "plus"
  | "pro"
  | "prolite"
  | "team"
  | "self_serve_business_usage_based"
  | "business"
  | "enterprise_cbp_usage_based"
  | "enterprise"
  | "edu"
  | "unknown";
export const V2GetAccountResponse__PlanType = Schema.Literals([
  "free",
  "go",
  "plus",
  "pro",
  "prolite",
  "team",
  "self_serve_business_usage_based",
  "business",
  "enterprise_cbp_usage_based",
  "enterprise",
  "edu",
  "unknown",
]);

export type V2HookCompletedNotification__AbsolutePathBuf = string;
export const V2HookCompletedNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2HookCompletedNotification__HookEventName =
  | "preToolUse"
  | "permissionRequest"
  | "postToolUse"
  | "preCompact"
  | "postCompact"
  | "sessionStart"
  | "userPromptSubmit"
  | "stop";
export const V2HookCompletedNotification__HookEventName = Schema.Literals([
  "preToolUse",
  "permissionRequest",
  "postToolUse",
  "preCompact",
  "postCompact",
  "sessionStart",
  "userPromptSubmit",
  "stop",
]);

export type V2HookCompletedNotification__HookExecutionMode = "sync" | "async";
export const V2HookCompletedNotification__HookExecutionMode = Schema.Literals(["sync", "async"]);

export type V2HookCompletedNotification__HookHandlerType = "command" | "prompt" | "agent";
export const V2HookCompletedNotification__HookHandlerType = Schema.Literals([
  "command",
  "prompt",
  "agent",
]);

export type V2HookCompletedNotification__HookOutputEntryKind =
  | "warning"
  | "stop"
  | "feedback"
  | "context"
  | "error";
export const V2HookCompletedNotification__HookOutputEntryKind = Schema.Literals([
  "warning",
  "stop",
  "feedback",
  "context",
  "error",
]);

export type V2HookCompletedNotification__HookRunStatus =
  | "running"
  | "completed"
  | "failed"
  | "blocked"
  | "stopped";
export const V2HookCompletedNotification__HookRunStatus = Schema.Literals([
  "running",
  "completed",
  "failed",
  "blocked",
  "stopped",
]);

export type V2HookCompletedNotification__HookScope = "thread" | "turn";
export const V2HookCompletedNotification__HookScope = Schema.Literals(["thread", "turn"]);

export type V2HooksListResponse__AbsolutePathBuf = string;
export const V2HooksListResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2HooksListResponse__HookErrorInfo = {
  readonly message: string;
  readonly path: string;
};
export const V2HooksListResponse__HookErrorInfo = Schema.Struct({
  message: Schema.String,
  path: Schema.String,
});

export type V2HooksListResponse__HookEventName =
  | "preToolUse"
  | "permissionRequest"
  | "postToolUse"
  | "preCompact"
  | "postCompact"
  | "sessionStart"
  | "userPromptSubmit"
  | "stop";
export const V2HooksListResponse__HookEventName = Schema.Literals([
  "preToolUse",
  "permissionRequest",
  "postToolUse",
  "preCompact",
  "postCompact",
  "sessionStart",
  "userPromptSubmit",
  "stop",
]);

export type V2HooksListResponse__HookHandlerType = "command" | "prompt" | "agent";
export const V2HooksListResponse__HookHandlerType = Schema.Literals(["command", "prompt", "agent"]);

export type V2HooksListResponse__HookSource =
  | "system"
  | "user"
  | "project"
  | "mdm"
  | "sessionFlags"
  | "plugin"
  | "cloudRequirements"
  | "legacyManagedConfigFile"
  | "legacyManagedConfigMdm"
  | "unknown";
export const V2HooksListResponse__HookSource = Schema.Literals([
  "system",
  "user",
  "project",
  "mdm",
  "sessionFlags",
  "plugin",
  "cloudRequirements",
  "legacyManagedConfigFile",
  "legacyManagedConfigMdm",
  "unknown",
]);

export type V2HooksListResponse__HookTrustStatus = "managed" | "untrusted" | "trusted" | "modified";
export const V2HooksListResponse__HookTrustStatus = Schema.Literals([
  "managed",
  "untrusted",
  "trusted",
  "modified",
]);

export type V2HookStartedNotification__AbsolutePathBuf = string;
export const V2HookStartedNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2HookStartedNotification__HookEventName =
  | "preToolUse"
  | "permissionRequest"
  | "postToolUse"
  | "preCompact"
  | "postCompact"
  | "sessionStart"
  | "userPromptSubmit"
  | "stop";
export const V2HookStartedNotification__HookEventName = Schema.Literals([
  "preToolUse",
  "permissionRequest",
  "postToolUse",
  "preCompact",
  "postCompact",
  "sessionStart",
  "userPromptSubmit",
  "stop",
]);

export type V2HookStartedNotification__HookExecutionMode = "sync" | "async";
export const V2HookStartedNotification__HookExecutionMode = Schema.Literals(["sync", "async"]);

export type V2HookStartedNotification__HookHandlerType = "command" | "prompt" | "agent";
export const V2HookStartedNotification__HookHandlerType = Schema.Literals([
  "command",
  "prompt",
  "agent",
]);

export type V2HookStartedNotification__HookOutputEntryKind =
  | "warning"
  | "stop"
  | "feedback"
  | "context"
  | "error";
export const V2HookStartedNotification__HookOutputEntryKind = Schema.Literals([
  "warning",
  "stop",
  "feedback",
  "context",
  "error",
]);

export type V2HookStartedNotification__HookRunStatus =
  | "running"
  | "completed"
  | "failed"
  | "blocked"
  | "stopped";
export const V2HookStartedNotification__HookRunStatus = Schema.Literals([
  "running",
  "completed",
  "failed",
  "blocked",
  "stopped",
]);

export type V2HookStartedNotification__HookScope = "thread" | "turn";
export const V2HookStartedNotification__HookScope = Schema.Literals(["thread", "turn"]);

export type V2ItemCompletedNotification__AbsolutePathBuf = string;
export const V2ItemCompletedNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ItemCompletedNotification__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ItemCompletedNotification__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ItemCompletedNotification__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ItemCompletedNotification__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ItemCompletedNotification__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ItemCompletedNotification__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemCompletedNotification__DynamicToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ItemCompletedNotification__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ItemCompletedNotification__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ItemCompletedNotification__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ItemCompletedNotification__McpToolCallError = { readonly message: string };
export const V2ItemCompletedNotification__McpToolCallError = Schema.Struct({
  message: Schema.String,
});

export type V2ItemCompletedNotification__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ItemCompletedNotification__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ItemCompletedNotification__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ItemCompletedNotification__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ItemCompletedNotification__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ItemCompletedNotification__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ItemCompletedNotification__MessagePhase = "commentary" | "final_answer";
export const V2ItemCompletedNotification__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ItemCompletedNotification__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ItemCompletedNotification__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ItemCompletedNotification__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ItemCompletedNotification__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemCompletedNotification__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ItemCompletedNotification__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ItemCompletedNotification__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ItemCompletedNotification__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ItemCompletedNotification__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ItemCompletedNotification__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf = string;
export const V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf =
  Schema.String.annotate({
    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.",
  });

export type V2ItemGuardianApprovalReviewCompletedNotification__AdditionalNetworkPermissions = {
  readonly enabled?: boolean | null;
};
export const V2ItemGuardianApprovalReviewCompletedNotification__AdditionalNetworkPermissions =
  Schema.Struct({ enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])) });

export type V2ItemGuardianApprovalReviewCompletedNotification__AutoReviewDecisionSource = "agent";
export const V2ItemGuardianApprovalReviewCompletedNotification__AutoReviewDecisionSource =
  Schema.Literal("agent").annotate({
    description: "[UNSTABLE] Source that produced a terminal approval auto-review decision.",
  });

export type V2ItemGuardianApprovalReviewCompletedNotification__FileSystemAccessMode =
  | "read"
  | "write"
  | "none";
export const V2ItemGuardianApprovalReviewCompletedNotification__FileSystemAccessMode =
  Schema.Literals(["read", "write", "none"]);

export type V2ItemGuardianApprovalReviewCompletedNotification__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const V2ItemGuardianApprovalReviewCompletedNotification__FileSystemSpecialPath =
  Schema.Union(
    [
      Schema.Struct({ kind: Schema.Literal("root") }).annotate({
        title: "RootFileSystemSpecialPath",
      }),
      Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
        title: "MinimalFileSystemSpecialPath",
      }),
      Schema.Struct({
        kind: Schema.Literal("project_roots"),
        subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      }).annotate({ title: "KindFileSystemSpecialPath" }),
      Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
        title: "TmpdirFileSystemSpecialPath",
      }),
      Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
        title: "SlashTmpFileSystemSpecialPath",
      }),
      Schema.Struct({
        kind: Schema.Literal("unknown"),
        path: Schema.String,
        subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      }),
    ],
    { mode: "oneOf" },
  );

export type V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReviewStatus =
  | "inProgress"
  | "approved"
  | "denied"
  | "timedOut"
  | "aborted";
export const V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReviewStatus =
  Schema.Literals(["inProgress", "approved", "denied", "timedOut", "aborted"]).annotate({
    description: "[UNSTABLE] Lifecycle state for an approval auto-review.",
  });

export type V2ItemGuardianApprovalReviewCompletedNotification__GuardianCommandSource =
  | "shell"
  | "unifiedExec";
export const V2ItemGuardianApprovalReviewCompletedNotification__GuardianCommandSource =
  Schema.Literals(["shell", "unifiedExec"]);

export type V2ItemGuardianApprovalReviewCompletedNotification__GuardianRiskLevel =
  | "low"
  | "medium"
  | "high"
  | "critical";
export const V2ItemGuardianApprovalReviewCompletedNotification__GuardianRiskLevel = Schema.Literals(
  ["low", "medium", "high", "critical"],
).annotate({ description: "[UNSTABLE] Risk level assigned by approval auto-review." });

export type V2ItemGuardianApprovalReviewCompletedNotification__GuardianUserAuthorization =
  | "unknown"
  | "low"
  | "medium"
  | "high";
export const V2ItemGuardianApprovalReviewCompletedNotification__GuardianUserAuthorization =
  Schema.Literals(["unknown", "low", "medium", "high"]).annotate({
    description: "[UNSTABLE] Authorization level assigned by approval auto-review.",
  });

export type V2ItemGuardianApprovalReviewCompletedNotification__NetworkApprovalProtocol =
  | "http"
  | "https"
  | "socks5Tcp"
  | "socks5Udp";
export const V2ItemGuardianApprovalReviewCompletedNotification__NetworkApprovalProtocol =
  Schema.Literals(["http", "https", "socks5Tcp", "socks5Udp"]);

export type V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf = string;
export const V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf =
  Schema.String.annotate({
    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.",
  });

export type V2ItemGuardianApprovalReviewStartedNotification__AdditionalNetworkPermissions = {
  readonly enabled?: boolean | null;
};
export const V2ItemGuardianApprovalReviewStartedNotification__AdditionalNetworkPermissions =
  Schema.Struct({ enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])) });

export type V2ItemGuardianApprovalReviewStartedNotification__FileSystemAccessMode =
  | "read"
  | "write"
  | "none";
export const V2ItemGuardianApprovalReviewStartedNotification__FileSystemAccessMode =
  Schema.Literals(["read", "write", "none"]);

export type V2ItemGuardianApprovalReviewStartedNotification__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const V2ItemGuardianApprovalReviewStartedNotification__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReviewStatus =
  | "inProgress"
  | "approved"
  | "denied"
  | "timedOut"
  | "aborted";
export const V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReviewStatus =
  Schema.Literals(["inProgress", "approved", "denied", "timedOut", "aborted"]).annotate({
    description: "[UNSTABLE] Lifecycle state for an approval auto-review.",
  });

export type V2ItemGuardianApprovalReviewStartedNotification__GuardianCommandSource =
  | "shell"
  | "unifiedExec";
export const V2ItemGuardianApprovalReviewStartedNotification__GuardianCommandSource =
  Schema.Literals(["shell", "unifiedExec"]);

export type V2ItemGuardianApprovalReviewStartedNotification__GuardianRiskLevel =
  | "low"
  | "medium"
  | "high"
  | "critical";
export const V2ItemGuardianApprovalReviewStartedNotification__GuardianRiskLevel = Schema.Literals([
  "low",
  "medium",
  "high",
  "critical",
]).annotate({ description: "[UNSTABLE] Risk level assigned by approval auto-review." });

export type V2ItemGuardianApprovalReviewStartedNotification__GuardianUserAuthorization =
  | "unknown"
  | "low"
  | "medium"
  | "high";
export const V2ItemGuardianApprovalReviewStartedNotification__GuardianUserAuthorization =
  Schema.Literals(["unknown", "low", "medium", "high"]).annotate({
    description: "[UNSTABLE] Authorization level assigned by approval auto-review.",
  });

export type V2ItemGuardianApprovalReviewStartedNotification__NetworkApprovalProtocol =
  | "http"
  | "https"
  | "socks5Tcp"
  | "socks5Udp";
export const V2ItemGuardianApprovalReviewStartedNotification__NetworkApprovalProtocol =
  Schema.Literals(["http", "https", "socks5Tcp", "socks5Udp"]);

export type V2ItemStartedNotification__AbsolutePathBuf = string;
export const V2ItemStartedNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ItemStartedNotification__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ItemStartedNotification__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ItemStartedNotification__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ItemStartedNotification__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ItemStartedNotification__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ItemStartedNotification__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemStartedNotification__DynamicToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ItemStartedNotification__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ItemStartedNotification__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ItemStartedNotification__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ItemStartedNotification__McpToolCallError = { readonly message: string };
export const V2ItemStartedNotification__McpToolCallError = Schema.Struct({
  message: Schema.String,
});

export type V2ItemStartedNotification__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ItemStartedNotification__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ItemStartedNotification__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ItemStartedNotification__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ItemStartedNotification__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ItemStartedNotification__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ItemStartedNotification__MessagePhase = "commentary" | "final_answer";
export const V2ItemStartedNotification__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ItemStartedNotification__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ItemStartedNotification__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ItemStartedNotification__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ItemStartedNotification__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemStartedNotification__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ItemStartedNotification__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ItemStartedNotification__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ItemStartedNotification__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ItemStartedNotification__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ItemStartedNotification__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ListMcpServerStatusParams__McpServerStatusDetail = "full" | "toolsAndAuthOnly";
export const V2ListMcpServerStatusParams__McpServerStatusDetail = Schema.Literals([
  "full",
  "toolsAndAuthOnly",
]);

export type V2ListMcpServerStatusResponse__McpAuthStatus =
  | "unsupported"
  | "notLoggedIn"
  | "bearerToken"
  | "oAuth";
export const V2ListMcpServerStatusResponse__McpAuthStatus = Schema.Literals([
  "unsupported",
  "notLoggedIn",
  "bearerToken",
  "oAuth",
]);

export type V2ListMcpServerStatusResponse__Resource = {
  readonly _meta?: unknown;
  readonly annotations?: unknown;
  readonly description?: string | null;
  readonly icons?: ReadonlyArray<unknown> | null;
  readonly mimeType?: string | null;
  readonly name: string;
  readonly size?: number | null;
  readonly title?: string | null;
  readonly uri: string;
};
export const V2ListMcpServerStatusResponse__Resource = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  annotations: Schema.optionalKey(Schema.Unknown),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  icons: Schema.optionalKey(Schema.Union([Schema.Array(Schema.Unknown), Schema.Null])),
  mimeType: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  size: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  uri: Schema.String,
}).annotate({ description: "A known resource that the server is capable of reading." });

export type V2ListMcpServerStatusResponse__ResourceTemplate = {
  readonly annotations?: unknown;
  readonly description?: string | null;
  readonly mimeType?: string | null;
  readonly name: string;
  readonly title?: string | null;
  readonly uriTemplate: string;
};
export const V2ListMcpServerStatusResponse__ResourceTemplate = Schema.Struct({
  annotations: Schema.optionalKey(Schema.Unknown),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  mimeType: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  uriTemplate: Schema.String,
}).annotate({ description: "A template description for resources available on the server." });

export type V2ListMcpServerStatusResponse__Tool = {
  readonly _meta?: unknown;
  readonly annotations?: unknown;
  readonly description?: string | null;
  readonly icons?: ReadonlyArray<unknown> | null;
  readonly inputSchema: unknown;
  readonly name: string;
  readonly outputSchema?: unknown;
  readonly title?: string | null;
};
export const V2ListMcpServerStatusResponse__Tool = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  annotations: Schema.optionalKey(Schema.Unknown),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  icons: Schema.optionalKey(Schema.Union([Schema.Array(Schema.Unknown), Schema.Null])),
  inputSchema: Schema.Unknown,
  name: Schema.String,
  outputSchema: Schema.optionalKey(Schema.Unknown),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ description: "Definition for a tool the client can call." });

export type V2MarketplaceAddResponse__AbsolutePathBuf = string;
export const V2MarketplaceAddResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2MarketplaceRemoveResponse__AbsolutePathBuf = string;
export const V2MarketplaceRemoveResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2MarketplaceUpgradeResponse__AbsolutePathBuf = string;
export const V2MarketplaceUpgradeResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2MarketplaceUpgradeResponse__MarketplaceUpgradeErrorInfo = {
  readonly marketplaceName: string;
  readonly message: string;
};
export const V2MarketplaceUpgradeResponse__MarketplaceUpgradeErrorInfo = Schema.Struct({
  marketplaceName: Schema.String,
  message: Schema.String,
});

export type V2McpResourceReadResponse__ResourceContent =
  | {
      readonly _meta?: unknown;
      readonly mimeType?: string | null;
      readonly text: string;
      readonly uri: string;
    }
  | {
      readonly _meta?: unknown;
      readonly blob: string;
      readonly mimeType?: string | null;
      readonly uri: string;
    };
export const V2McpResourceReadResponse__ResourceContent = Schema.Union([
  Schema.Struct({
    _meta: Schema.optionalKey(Schema.Unknown),
    mimeType: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    text: Schema.String,
    uri: Schema.String.annotate({ description: "The URI of this resource." }),
  }),
  Schema.Struct({
    _meta: Schema.optionalKey(Schema.Unknown),
    blob: Schema.String,
    mimeType: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    uri: Schema.String.annotate({ description: "The URI of this resource." }),
  }),
]).annotate({ description: "Contents returned when reading a resource from an MCP server." });

export type V2McpServerStatusUpdatedNotification__McpServerStartupState =
  | "starting"
  | "ready"
  | "failed"
  | "cancelled";
export const V2McpServerStatusUpdatedNotification__McpServerStartupState = Schema.Literals([
  "starting",
  "ready",
  "failed",
  "cancelled",
]);

export type V2ModelListResponse__InputModality = "text" | "image";
export const V2ModelListResponse__InputModality = Schema.Literals(["text", "image"]).annotate({
  description: "Canonical user-input modality tags advertised by a model.",
});

export type V2ModelListResponse__ModelAvailabilityNux = { readonly message: string };
export const V2ModelListResponse__ModelAvailabilityNux = Schema.Struct({ message: Schema.String });

export type V2ModelListResponse__ModelServiceTier = {
  readonly description: string;
  readonly id: string;
  readonly name: string;
};
export const V2ModelListResponse__ModelServiceTier = Schema.Struct({
  description: Schema.String,
  id: Schema.String,
  name: Schema.String,
});

export type V2ModelListResponse__ModelUpgradeInfo = {
  readonly migrationMarkdown?: string | null;
  readonly model: string;
  readonly modelLink?: string | null;
  readonly upgradeCopy?: string | null;
};
export const V2ModelListResponse__ModelUpgradeInfo = Schema.Struct({
  migrationMarkdown: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  model: Schema.String,
  modelLink: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  upgradeCopy: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ModelListResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ModelListResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ModelReroutedNotification__ModelRerouteReason = "highRiskCyberActivity";
export const V2ModelReroutedNotification__ModelRerouteReason =
  Schema.Literal("highRiskCyberActivity");

export type V2ModelVerificationNotification__ModelVerification = "trustedAccessForCyber";
export const V2ModelVerificationNotification__ModelVerification =
  Schema.Literal("trustedAccessForCyber");

export type V2PluginInstallParams__AbsolutePathBuf = string;
export const V2PluginInstallParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2PluginInstallResponse__AppSummary = {
  readonly description?: string | null;
  readonly id: string;
  readonly installUrl?: string | null;
  readonly name: string;
  readonly needsAuth: boolean;
};
export const V2PluginInstallResponse__AppSummary = Schema.Struct({
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  id: Schema.String,
  installUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  needsAuth: Schema.Boolean,
}).annotate({ description: "EXPERIMENTAL - app metadata summary for plugin responses." });

export type V2PluginInstallResponse__PluginAuthPolicy = "ON_INSTALL" | "ON_USE";
export const V2PluginInstallResponse__PluginAuthPolicy = Schema.Literals(["ON_INSTALL", "ON_USE"]);

export type V2PluginListParams__AbsolutePathBuf = string;
export const V2PluginListParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2PluginListParams__PluginListMarketplaceKind =
  | "local"
  | "workspace-directory"
  | "shared-with-me";
export const V2PluginListParams__PluginListMarketplaceKind = Schema.Literals([
  "local",
  "workspace-directory",
  "shared-with-me",
]);

export type V2PluginListResponse__AbsolutePathBuf = string;
export const V2PluginListResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2PluginListResponse__MarketplaceInterface = { readonly displayName?: string | null };
export const V2PluginListResponse__MarketplaceInterface = Schema.Struct({
  displayName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2PluginListResponse__PluginAuthPolicy = "ON_INSTALL" | "ON_USE";
export const V2PluginListResponse__PluginAuthPolicy = Schema.Literals(["ON_INSTALL", "ON_USE"]);

export type V2PluginListResponse__PluginInstallPolicy =
  | "NOT_AVAILABLE"
  | "AVAILABLE"
  | "INSTALLED_BY_DEFAULT";
export const V2PluginListResponse__PluginInstallPolicy = Schema.Literals([
  "NOT_AVAILABLE",
  "AVAILABLE",
  "INSTALLED_BY_DEFAULT",
]);

export type V2PluginListResponse__PluginSharePrincipalType = "user" | "group" | "workspace";
export const V2PluginListResponse__PluginSharePrincipalType = Schema.Literals([
  "user",
  "group",
  "workspace",
]);

export type V2PluginReadParams__AbsolutePathBuf = string;
export const V2PluginReadParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2PluginReadResponse__AbsolutePathBuf = string;
export const V2PluginReadResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2PluginReadResponse__AppSummary = {
  readonly description?: string | null;
  readonly id: string;
  readonly installUrl?: string | null;
  readonly name: string;
  readonly needsAuth: boolean;
};
export const V2PluginReadResponse__AppSummary = Schema.Struct({
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  id: Schema.String,
  installUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  needsAuth: Schema.Boolean,
}).annotate({ description: "EXPERIMENTAL - app metadata summary for plugin responses." });

export type V2PluginReadResponse__HookEventName =
  | "preToolUse"
  | "permissionRequest"
  | "postToolUse"
  | "preCompact"
  | "postCompact"
  | "sessionStart"
  | "userPromptSubmit"
  | "stop";
export const V2PluginReadResponse__HookEventName = Schema.Literals([
  "preToolUse",
  "permissionRequest",
  "postToolUse",
  "preCompact",
  "postCompact",
  "sessionStart",
  "userPromptSubmit",
  "stop",
]);

export type V2PluginReadResponse__PluginAuthPolicy = "ON_INSTALL" | "ON_USE";
export const V2PluginReadResponse__PluginAuthPolicy = Schema.Literals(["ON_INSTALL", "ON_USE"]);

export type V2PluginReadResponse__PluginInstallPolicy =
  | "NOT_AVAILABLE"
  | "AVAILABLE"
  | "INSTALLED_BY_DEFAULT";
export const V2PluginReadResponse__PluginInstallPolicy = Schema.Literals([
  "NOT_AVAILABLE",
  "AVAILABLE",
  "INSTALLED_BY_DEFAULT",
]);

export type V2PluginReadResponse__PluginSharePrincipalType = "user" | "group" | "workspace";
export const V2PluginReadResponse__PluginSharePrincipalType = Schema.Literals([
  "user",
  "group",
  "workspace",
]);

export type V2PluginShareListResponse__AbsolutePathBuf = string;
export const V2PluginShareListResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2PluginShareListResponse__PluginAuthPolicy = "ON_INSTALL" | "ON_USE";
export const V2PluginShareListResponse__PluginAuthPolicy = Schema.Literals([
  "ON_INSTALL",
  "ON_USE",
]);

export type V2PluginShareListResponse__PluginInstallPolicy =
  | "NOT_AVAILABLE"
  | "AVAILABLE"
  | "INSTALLED_BY_DEFAULT";
export const V2PluginShareListResponse__PluginInstallPolicy = Schema.Literals([
  "NOT_AVAILABLE",
  "AVAILABLE",
  "INSTALLED_BY_DEFAULT",
]);

export type V2PluginShareListResponse__PluginSharePrincipalType = "user" | "group" | "workspace";
export const V2PluginShareListResponse__PluginSharePrincipalType = Schema.Literals([
  "user",
  "group",
  "workspace",
]);

export type V2PluginShareSaveParams__AbsolutePathBuf = string;
export const V2PluginShareSaveParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2PluginShareSaveParams__PluginShareDiscoverability = "LISTED" | "UNLISTED" | "PRIVATE";
export const V2PluginShareSaveParams__PluginShareDiscoverability = Schema.Literals([
  "LISTED",
  "UNLISTED",
  "PRIVATE",
]);

export type V2PluginShareSaveParams__PluginSharePrincipalType = "user" | "group" | "workspace";
export const V2PluginShareSaveParams__PluginSharePrincipalType = Schema.Literals([
  "user",
  "group",
  "workspace",
]);

export type V2PluginShareUpdateTargetsParams__PluginSharePrincipalType =
  | "user"
  | "group"
  | "workspace";
export const V2PluginShareUpdateTargetsParams__PluginSharePrincipalType = Schema.Literals([
  "user",
  "group",
  "workspace",
]);

export type V2PluginShareUpdateTargetsResponse__PluginSharePrincipalType =
  | "user"
  | "group"
  | "workspace";
export const V2PluginShareUpdateTargetsResponse__PluginSharePrincipalType = Schema.Literals([
  "user",
  "group",
  "workspace",
]);

export type V2RawResponseItemCompletedNotification__ImageDetail =
  | "auto"
  | "low"
  | "high"
  | "original";
export const V2RawResponseItemCompletedNotification__ImageDetail = Schema.Literals([
  "auto",
  "low",
  "high",
  "original",
]);

export type V2RawResponseItemCompletedNotification__LocalShellAction = {
  readonly command: ReadonlyArray<string>;
  readonly env?: { readonly [x: string]: string } | null;
  readonly timeout_ms?: number | null;
  readonly type: "exec";
  readonly user?: string | null;
  readonly working_directory?: string | null;
};
export const V2RawResponseItemCompletedNotification__LocalShellAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.Array(Schema.String),
      env: Schema.optionalKey(
        Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]),
      ),
      timeout_ms: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint64" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(0)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("exec").annotate({ title: "ExecLocalShellActionType" }),
      user: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      working_directory: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "ExecLocalShellAction" }),
  ],
  { mode: "oneOf" },
);

export type V2RawResponseItemCompletedNotification__LocalShellStatus =
  | "completed"
  | "in_progress"
  | "incomplete";
export const V2RawResponseItemCompletedNotification__LocalShellStatus = Schema.Literals([
  "completed",
  "in_progress",
  "incomplete",
]);

export type V2RawResponseItemCompletedNotification__MessagePhase = "commentary" | "final_answer";
export const V2RawResponseItemCompletedNotification__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2RawResponseItemCompletedNotification__ReasoningItemContent =
  | { readonly text: string; readonly type: "reasoning_text" }
  | { readonly text: string; readonly type: "text" };
export const V2RawResponseItemCompletedNotification__ReasoningItemContent = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("reasoning_text").annotate({
        title: "ReasoningTextReasoningItemContentType",
      }),
    }).annotate({ title: "ReasoningTextReasoningItemContent" }),
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("text").annotate({ title: "TextReasoningItemContentType" }),
    }).annotate({ title: "TextReasoningItemContent" }),
  ],
  { mode: "oneOf" },
);

export type V2RawResponseItemCompletedNotification__ReasoningItemReasoningSummary = {
  readonly text: string;
  readonly type: "summary_text";
};
export const V2RawResponseItemCompletedNotification__ReasoningItemReasoningSummary = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("summary_text").annotate({
        title: "SummaryTextReasoningItemReasoningSummaryType",
      }),
    }).annotate({ title: "SummaryTextReasoningItemReasoningSummary" }),
  ],
  { mode: "oneOf" },
);

export type V2RawResponseItemCompletedNotification__ResponsesApiWebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "open_page"; readonly url?: string | null }
  | {
      readonly pattern?: string | null;
      readonly type: "find_in_page";
      readonly url?: string | null;
    }
  | { readonly type: "other" };
export const V2RawResponseItemCompletedNotification__ResponsesApiWebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchResponsesApiWebSearchActionType" }),
    }).annotate({ title: "SearchResponsesApiWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("open_page").annotate({
        title: "OpenPageResponsesApiWebSearchActionType",
      }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageResponsesApiWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("find_in_page").annotate({
        title: "FindInPageResponsesApiWebSearchActionType",
      }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageResponsesApiWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherResponsesApiWebSearchActionType" }),
    }).annotate({ title: "OtherResponsesApiWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2RemoteControlStatusChangedNotification__RemoteControlConnectionStatus =
  | "disabled"
  | "connecting"
  | "connected"
  | "errored";
export const V2RemoteControlStatusChangedNotification__RemoteControlConnectionStatus =
  Schema.Literals(["disabled", "connecting", "connected", "errored"]);

export type V2ReviewStartParams__ReviewDelivery = "inline" | "detached";
export const V2ReviewStartParams__ReviewDelivery = Schema.Literals(["inline", "detached"]);

export type V2ReviewStartParams__ReviewTarget =
  | { readonly type: "uncommittedChanges" }
  | { readonly branch: string; readonly type: "baseBranch" }
  | { readonly sha: string; readonly title?: string | null; readonly type: "commit" }
  | { readonly instructions: string; readonly type: "custom" };
export const V2ReviewStartParams__ReviewTarget = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("uncommittedChanges").annotate({
        title: "UncommittedChangesReviewTargetType",
      }),
    }).annotate({
      title: "UncommittedChangesReviewTarget",
      description: "Review the working tree: staged, unstaged, and untracked files.",
    }),
    Schema.Struct({
      branch: Schema.String,
      type: Schema.Literal("baseBranch").annotate({ title: "BaseBranchReviewTargetType" }),
    }).annotate({
      title: "BaseBranchReviewTarget",
      description: "Review changes between the current branch and the given base branch.",
    }),
    Schema.Struct({
      sha: Schema.String,
      title: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Optional human-readable label (e.g., commit subject) for UIs.",
          }),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("commit").annotate({ title: "CommitReviewTargetType" }),
    }).annotate({
      title: "CommitReviewTarget",
      description: "Review the changes introduced by a specific commit.",
    }),
    Schema.Struct({
      instructions: Schema.String,
      type: Schema.Literal("custom").annotate({ title: "CustomReviewTargetType" }),
    }).annotate({
      title: "CustomReviewTarget",
      description: "Arbitrary instructions, equivalent to the old free-form prompt.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ReviewStartResponse__AbsolutePathBuf = string;
export const V2ReviewStartResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ReviewStartResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ReviewStartResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ReviewStartResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ReviewStartResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ReviewStartResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ReviewStartResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ReviewStartResponse__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ReviewStartResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ReviewStartResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ReviewStartResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ReviewStartResponse__McpToolCallError = { readonly message: string };
export const V2ReviewStartResponse__McpToolCallError = Schema.Struct({ message: Schema.String });

export type V2ReviewStartResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ReviewStartResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ReviewStartResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ReviewStartResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ReviewStartResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ReviewStartResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ReviewStartResponse__MessagePhase = "commentary" | "final_answer";
export const V2ReviewStartResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ReviewStartResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ReviewStartResponse__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type V2ReviewStartResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ReviewStartResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ReviewStartResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ReviewStartResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ReviewStartResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ReviewStartResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ReviewStartResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ReviewStartResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ReviewStartResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ReviewStartResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ReviewStartResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ReviewStartResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2SendAddCreditsNudgeEmailParams__AddCreditsNudgeCreditType = "credits" | "usage_limit";
export const V2SendAddCreditsNudgeEmailParams__AddCreditsNudgeCreditType = Schema.Literals([
  "credits",
  "usage_limit",
]);

export type V2SendAddCreditsNudgeEmailResponse__AddCreditsNudgeEmailStatus =
  | "sent"
  | "cooldown_active";
export const V2SendAddCreditsNudgeEmailResponse__AddCreditsNudgeEmailStatus = Schema.Literals([
  "sent",
  "cooldown_active",
]);

export type V2ServerRequestResolvedNotification__RequestId = string | number;
export const V2ServerRequestResolvedNotification__RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]);

export type V2SkillsConfigWriteParams__AbsolutePathBuf = string;
export const V2SkillsConfigWriteParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2SkillsListParams__SkillsListExtraRootsForCwd = {
  readonly cwd: string;
  readonly extraUserRoots: ReadonlyArray<string>;
};
export const V2SkillsListParams__SkillsListExtraRootsForCwd = Schema.Struct({
  cwd: Schema.String,
  extraUserRoots: Schema.Array(Schema.String),
});

export type V2SkillsListResponse__AbsolutePathBuf = string;
export const V2SkillsListResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2SkillsListResponse__SkillErrorInfo = {
  readonly message: string;
  readonly path: string;
};
export const V2SkillsListResponse__SkillErrorInfo = Schema.Struct({
  message: Schema.String,
  path: Schema.String,
});

export type V2SkillsListResponse__SkillScope = "user" | "repo" | "system" | "admin";
export const V2SkillsListResponse__SkillScope = Schema.Literals([
  "user",
  "repo",
  "system",
  "admin",
]);

export type V2SkillsListResponse__SkillToolDependency = {
  readonly command?: string | null;
  readonly description?: string | null;
  readonly transport?: string | null;
  readonly type: string;
  readonly url?: string | null;
  readonly value: string;
};
export const V2SkillsListResponse__SkillToolDependency = Schema.Struct({
  command: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  transport: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: Schema.String,
  url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  value: Schema.String,
});

export type V2ThreadForkParams__AbsolutePathBuf = string;
export const V2ThreadForkParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadForkParams__ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
export const V2ThreadForkParams__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2ThreadForkParams__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2ThreadForkParams__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkParams__SandboxMode =
  | "read-only"
  | "workspace-write"
  | "danger-full-access";
export const V2ThreadForkParams__SandboxMode = Schema.Literals([
  "read-only",
  "workspace-write",
  "danger-full-access",
]);

export type V2ThreadForkParams__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadForkParams__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadForkResponse__AbsolutePathBuf = string;
export const V2ThreadForkResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadForkResponse__AgentPath = string;
export const V2ThreadForkResponse__AgentPath = Schema.String;

export type V2ThreadForkResponse__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2ThreadForkResponse__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadForkResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadForkResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadForkResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadForkResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadForkResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadForkResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadForkResponse__FileSystemAccessMode = "read" | "write" | "none";
export const V2ThreadForkResponse__FileSystemAccessMode = Schema.Literals([
  "read",
  "write",
  "none",
]);

export type V2ThreadForkResponse__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const V2ThreadForkResponse__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadForkResponse__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadForkResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadForkResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadForkResponse__McpToolCallError = { readonly message: string };
export const V2ThreadForkResponse__McpToolCallError = Schema.Struct({ message: Schema.String });

export type V2ThreadForkResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadForkResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadForkResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadForkResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadForkResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadForkResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadForkResponse__MessagePhase = "commentary" | "final_answer";
export const V2ThreadForkResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadForkResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadForkResponse__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type V2ThreadForkResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadForkResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadForkResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadForkResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__PermissionProfileNetworkPermissions = {
  readonly enabled: boolean;
};
export const V2ThreadForkResponse__PermissionProfileNetworkPermissions = Schema.Struct({
  enabled: Schema.Boolean,
});

export type V2ThreadForkResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadForkResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadForkResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadForkResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadForkResponse__ThreadActiveFlag = "waitingOnApproval" | "waitingOnUserInput";
export const V2ThreadForkResponse__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadForkResponse__ThreadId = string;
export const V2ThreadForkResponse__ThreadId = Schema.String;

export type V2ThreadForkResponse__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadForkResponse__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadForkResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadForkResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadForkResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadForkResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadGoalUpdatedNotification__ThreadGoalStatus =
  | "active"
  | "paused"
  | "budgetLimited"
  | "complete";
export const V2ThreadGoalUpdatedNotification__ThreadGoalStatus = Schema.Literals([
  "active",
  "paused",
  "budgetLimited",
  "complete",
]);

export type V2ThreadListParams__SortDirection = "asc" | "desc";
export const V2ThreadListParams__SortDirection = Schema.Literals(["asc", "desc"]);

export type V2ThreadListParams__ThreadListCwdFilter = string | ReadonlyArray<string>;
export const V2ThreadListParams__ThreadListCwdFilter = Schema.Union([
  Schema.String,
  Schema.Array(Schema.String),
]);

export type V2ThreadListParams__ThreadSortKey = "created_at" | "updated_at";
export const V2ThreadListParams__ThreadSortKey = Schema.Literals(["created_at", "updated_at"]);

export type V2ThreadListParams__ThreadSourceKind =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "subAgent"
  | "subAgentReview"
  | "subAgentCompact"
  | "subAgentThreadSpawn"
  | "subAgentOther"
  | "unknown";
export const V2ThreadListParams__ThreadSourceKind = Schema.Literals([
  "cli",
  "vscode",
  "exec",
  "appServer",
  "subAgent",
  "subAgentReview",
  "subAgentCompact",
  "subAgentThreadSpawn",
  "subAgentOther",
  "unknown",
]);

export type V2ThreadListResponse__AbsolutePathBuf = string;
export const V2ThreadListResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadListResponse__AgentPath = string;
export const V2ThreadListResponse__AgentPath = Schema.String;

export type V2ThreadListResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadListResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadListResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadListResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadListResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadListResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadListResponse__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadListResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadListResponse__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadListResponse__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadListResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadListResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadListResponse__McpToolCallError = { readonly message: string };
export const V2ThreadListResponse__McpToolCallError = Schema.Struct({ message: Schema.String });

export type V2ThreadListResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadListResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadListResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadListResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadListResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadListResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadListResponse__MessagePhase = "commentary" | "final_answer";
export const V2ThreadListResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadListResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadListResponse__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type V2ThreadListResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadListResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadListResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadListResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadListResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadListResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadListResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadListResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadListResponse__ThreadActiveFlag = "waitingOnApproval" | "waitingOnUserInput";
export const V2ThreadListResponse__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadListResponse__ThreadId = string;
export const V2ThreadListResponse__ThreadId = Schema.String;

export type V2ThreadListResponse__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadListResponse__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadListResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadListResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadListResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadListResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateParams__ThreadMetadataGitInfoUpdateParams = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadMetadataUpdateParams__ThreadMetadataGitInfoUpdateParams = Schema.Struct({
  branch: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Omit to leave the stored branch unchanged, set to `null` to clear it, or provide a non-empty string to replace it.",
      }),
      Schema.Null,
    ]),
  ),
  originUrl: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Omit to leave the stored origin URL unchanged, set to `null` to clear it, or provide a non-empty string to replace it.",
      }),
      Schema.Null,
    ]),
  ),
  sha: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Omit to leave the stored commit unchanged, set to `null` to clear it, or provide a non-empty string to replace it.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadMetadataUpdateResponse__AbsolutePathBuf = string;
export const V2ThreadMetadataUpdateResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadMetadataUpdateResponse__AgentPath = string;
export const V2ThreadMetadataUpdateResponse__AgentPath = Schema.String;

export type V2ThreadMetadataUpdateResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadMetadataUpdateResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadMetadataUpdateResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadMetadataUpdateResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadMetadataUpdateResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadMetadataUpdateResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateResponse__DynamicToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadMetadataUpdateResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadMetadataUpdateResponse__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadMetadataUpdateResponse__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadMetadataUpdateResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadMetadataUpdateResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadMetadataUpdateResponse__McpToolCallError = { readonly message: string };
export const V2ThreadMetadataUpdateResponse__McpToolCallError = Schema.Struct({
  message: Schema.String,
});

export type V2ThreadMetadataUpdateResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadMetadataUpdateResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadMetadataUpdateResponse__McpToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadMetadataUpdateResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadMetadataUpdateResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadMetadataUpdateResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadMetadataUpdateResponse__MessagePhase = "commentary" | "final_answer";
export const V2ThreadMetadataUpdateResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadMetadataUpdateResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadMetadataUpdateResponse__NonSteerableTurnKind = Schema.Literals([
  "review",
  "compact",
]);

export type V2ThreadMetadataUpdateResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadMetadataUpdateResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadMetadataUpdateResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadMetadataUpdateResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadMetadataUpdateResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadMetadataUpdateResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadMetadataUpdateResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadMetadataUpdateResponse__ThreadActiveFlag =
  | "waitingOnApproval"
  | "waitingOnUserInput";
export const V2ThreadMetadataUpdateResponse__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadMetadataUpdateResponse__ThreadId = string;
export const V2ThreadMetadataUpdateResponse__ThreadId = Schema.String;

export type V2ThreadMetadataUpdateResponse__ThreadSource =
  | "user"
  | "subagent"
  | "memory_consolidation";
export const V2ThreadMetadataUpdateResponse__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadMetadataUpdateResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadMetadataUpdateResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadMetadataUpdateResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadMetadataUpdateResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__AbsolutePathBuf = string;
export const V2ThreadReadResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadReadResponse__AgentPath = string;
export const V2ThreadReadResponse__AgentPath = Schema.String;

export type V2ThreadReadResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadReadResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadReadResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadReadResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadReadResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadReadResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadReadResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadReadResponse__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadReadResponse__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadReadResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadReadResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadReadResponse__McpToolCallError = { readonly message: string };
export const V2ThreadReadResponse__McpToolCallError = Schema.Struct({ message: Schema.String });

export type V2ThreadReadResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadReadResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadReadResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadReadResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadReadResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadReadResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadReadResponse__MessagePhase = "commentary" | "final_answer";
export const V2ThreadReadResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadReadResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadReadResponse__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type V2ThreadReadResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadReadResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadReadResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadReadResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadReadResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadReadResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadReadResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadReadResponse__ThreadActiveFlag = "waitingOnApproval" | "waitingOnUserInput";
export const V2ThreadReadResponse__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadReadResponse__ThreadId = string;
export const V2ThreadReadResponse__ThreadId = Schema.String;

export type V2ThreadReadResponse__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadReadResponse__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadReadResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadReadResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadReadResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadReadResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRealtimeOutputAudioDeltaNotification__ThreadRealtimeAudioChunk = {
  readonly data: string;
  readonly itemId?: string | null;
  readonly numChannels: number;
  readonly sampleRate: number;
  readonly samplesPerChannel?: number | null;
};
export const V2ThreadRealtimeOutputAudioDeltaNotification__ThreadRealtimeAudioChunk = Schema.Struct(
  {
    data: Schema.String,
    itemId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    numChannels: Schema.Number.annotate({ format: "uint16" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    sampleRate: Schema.Number.annotate({ format: "uint32" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    samplesPerChannel: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "uint32" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
        Schema.Null,
      ]),
    ),
  },
).annotate({ description: "EXPERIMENTAL - thread realtime audio chunk." });

export type V2ThreadRealtimeStartedNotification__RealtimeConversationVersion = "v1" | "v2";
export const V2ThreadRealtimeStartedNotification__RealtimeConversationVersion = Schema.Literals([
  "v1",
  "v2",
]);

export type V2ThreadResumeParams__AbsolutePathBuf = string;
export const V2ThreadResumeParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadResumeParams__ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
export const V2ThreadResumeParams__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2ThreadResumeParams__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2ThreadResumeParams__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__ImageDetail = "auto" | "low" | "high" | "original";
export const V2ThreadResumeParams__ImageDetail = Schema.Literals([
  "auto",
  "low",
  "high",
  "original",
]);

export type V2ThreadResumeParams__LocalShellAction = {
  readonly command: ReadonlyArray<string>;
  readonly env?: { readonly [x: string]: string } | null;
  readonly timeout_ms?: number | null;
  readonly type: "exec";
  readonly user?: string | null;
  readonly working_directory?: string | null;
};
export const V2ThreadResumeParams__LocalShellAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.Array(Schema.String),
      env: Schema.optionalKey(
        Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]),
      ),
      timeout_ms: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint64" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(0)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("exec").annotate({ title: "ExecLocalShellActionType" }),
      user: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      working_directory: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "ExecLocalShellAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__LocalShellStatus = "completed" | "in_progress" | "incomplete";
export const V2ThreadResumeParams__LocalShellStatus = Schema.Literals([
  "completed",
  "in_progress",
  "incomplete",
]);

export type V2ThreadResumeParams__MessagePhase = "commentary" | "final_answer";
export const V2ThreadResumeParams__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadResumeParams__Personality = "none" | "friendly" | "pragmatic";
export const V2ThreadResumeParams__Personality = Schema.Literals(["none", "friendly", "pragmatic"]);

export type V2ThreadResumeParams__ReasoningItemContent =
  | { readonly text: string; readonly type: "reasoning_text" }
  | { readonly text: string; readonly type: "text" };
export const V2ThreadResumeParams__ReasoningItemContent = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("reasoning_text").annotate({
        title: "ReasoningTextReasoningItemContentType",
      }),
    }).annotate({ title: "ReasoningTextReasoningItemContent" }),
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("text").annotate({ title: "TextReasoningItemContentType" }),
    }).annotate({ title: "TextReasoningItemContent" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__ReasoningItemReasoningSummary = {
  readonly text: string;
  readonly type: "summary_text";
};
export const V2ThreadResumeParams__ReasoningItemReasoningSummary = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("summary_text").annotate({
        title: "SummaryTextReasoningItemReasoningSummaryType",
      }),
    }).annotate({ title: "SummaryTextReasoningItemReasoningSummary" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__ResponsesApiWebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "open_page"; readonly url?: string | null }
  | {
      readonly pattern?: string | null;
      readonly type: "find_in_page";
      readonly url?: string | null;
    }
  | { readonly type: "other" };
export const V2ThreadResumeParams__ResponsesApiWebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchResponsesApiWebSearchActionType" }),
    }).annotate({ title: "SearchResponsesApiWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("open_page").annotate({
        title: "OpenPageResponsesApiWebSearchActionType",
      }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageResponsesApiWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("find_in_page").annotate({
        title: "FindInPageResponsesApiWebSearchActionType",
      }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageResponsesApiWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherResponsesApiWebSearchActionType" }),
    }).annotate({ title: "OtherResponsesApiWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__SandboxMode =
  | "read-only"
  | "workspace-write"
  | "danger-full-access";
export const V2ThreadResumeParams__SandboxMode = Schema.Literals([
  "read-only",
  "workspace-write",
  "danger-full-access",
]);

export type V2ThreadResumeResponse__AbsolutePathBuf = string;
export const V2ThreadResumeResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadResumeResponse__AgentPath = string;
export const V2ThreadResumeResponse__AgentPath = Schema.String;

export type V2ThreadResumeResponse__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2ThreadResumeResponse__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadResumeResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadResumeResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadResumeResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadResumeResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadResumeResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadResumeResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadResumeResponse__FileSystemAccessMode = "read" | "write" | "none";
export const V2ThreadResumeResponse__FileSystemAccessMode = Schema.Literals([
  "read",
  "write",
  "none",
]);

export type V2ThreadResumeResponse__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const V2ThreadResumeResponse__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadResumeResponse__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadResumeResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadResumeResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadResumeResponse__McpToolCallError = { readonly message: string };
export const V2ThreadResumeResponse__McpToolCallError = Schema.Struct({ message: Schema.String });

export type V2ThreadResumeResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadResumeResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadResumeResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadResumeResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadResumeResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadResumeResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadResumeResponse__MessagePhase = "commentary" | "final_answer";
export const V2ThreadResumeResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadResumeResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadResumeResponse__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type V2ThreadResumeResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadResumeResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadResumeResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadResumeResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__PermissionProfileNetworkPermissions = {
  readonly enabled: boolean;
};
export const V2ThreadResumeResponse__PermissionProfileNetworkPermissions = Schema.Struct({
  enabled: Schema.Boolean,
});

export type V2ThreadResumeResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadResumeResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadResumeResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadResumeResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadResumeResponse__ThreadActiveFlag = "waitingOnApproval" | "waitingOnUserInput";
export const V2ThreadResumeResponse__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadResumeResponse__ThreadId = string;
export const V2ThreadResumeResponse__ThreadId = Schema.String;

export type V2ThreadResumeResponse__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadResumeResponse__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadResumeResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadResumeResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadResumeResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadResumeResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__AbsolutePathBuf = string;
export const V2ThreadRollbackResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadRollbackResponse__AgentPath = string;
export const V2ThreadRollbackResponse__AgentPath = Schema.String;

export type V2ThreadRollbackResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadRollbackResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadRollbackResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadRollbackResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadRollbackResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadRollbackResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadRollbackResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadRollbackResponse__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadRollbackResponse__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadRollbackResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadRollbackResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadRollbackResponse__McpToolCallError = { readonly message: string };
export const V2ThreadRollbackResponse__McpToolCallError = Schema.Struct({ message: Schema.String });

export type V2ThreadRollbackResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadRollbackResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadRollbackResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadRollbackResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadRollbackResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadRollbackResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadRollbackResponse__MessagePhase = "commentary" | "final_answer";
export const V2ThreadRollbackResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadRollbackResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadRollbackResponse__NonSteerableTurnKind = Schema.Literals([
  "review",
  "compact",
]);

export type V2ThreadRollbackResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadRollbackResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadRollbackResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadRollbackResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadRollbackResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadRollbackResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadRollbackResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadRollbackResponse__ThreadActiveFlag = "waitingOnApproval" | "waitingOnUserInput";
export const V2ThreadRollbackResponse__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadRollbackResponse__ThreadId = string;
export const V2ThreadRollbackResponse__ThreadId = Schema.String;

export type V2ThreadRollbackResponse__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadRollbackResponse__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadRollbackResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadRollbackResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadRollbackResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadRollbackResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__AbsolutePathBuf = string;
export const V2ThreadStartedNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadStartedNotification__AgentPath = string;
export const V2ThreadStartedNotification__AgentPath = Schema.String;

export type V2ThreadStartedNotification__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadStartedNotification__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadStartedNotification__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadStartedNotification__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadStartedNotification__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadStartedNotification__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__DynamicToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadStartedNotification__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadStartedNotification__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadStartedNotification__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadStartedNotification__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadStartedNotification__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadStartedNotification__McpToolCallError = { readonly message: string };
export const V2ThreadStartedNotification__McpToolCallError = Schema.Struct({
  message: Schema.String,
});

export type V2ThreadStartedNotification__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadStartedNotification__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadStartedNotification__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadStartedNotification__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadStartedNotification__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadStartedNotification__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadStartedNotification__MessagePhase = "commentary" | "final_answer";
export const V2ThreadStartedNotification__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadStartedNotification__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadStartedNotification__NonSteerableTurnKind = Schema.Literals([
  "review",
  "compact",
]);

export type V2ThreadStartedNotification__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadStartedNotification__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadStartedNotification__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadStartedNotification__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadStartedNotification__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadStartedNotification__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadStartedNotification__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadStartedNotification__ThreadActiveFlag =
  | "waitingOnApproval"
  | "waitingOnUserInput";
export const V2ThreadStartedNotification__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadStartedNotification__ThreadId = string;
export const V2ThreadStartedNotification__ThreadId = Schema.String;

export type V2ThreadStartedNotification__ThreadSource =
  | "user"
  | "subagent"
  | "memory_consolidation";
export const V2ThreadStartedNotification__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadStartedNotification__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadStartedNotification__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadStartedNotification__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadStartedNotification__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartParams__AbsolutePathBuf = string;
export const V2ThreadStartParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadStartParams__ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
export const V2ThreadStartParams__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2ThreadStartParams__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2ThreadStartParams__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartParams__Personality = "none" | "friendly" | "pragmatic";
export const V2ThreadStartParams__Personality = Schema.Literals(["none", "friendly", "pragmatic"]);

export type V2ThreadStartParams__SandboxMode =
  | "read-only"
  | "workspace-write"
  | "danger-full-access";
export const V2ThreadStartParams__SandboxMode = Schema.Literals([
  "read-only",
  "workspace-write",
  "danger-full-access",
]);

export type V2ThreadStartParams__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadStartParams__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadStartParams__ThreadStartSource = "startup" | "clear";
export const V2ThreadStartParams__ThreadStartSource = Schema.Literals(["startup", "clear"]);

export type V2ThreadStartResponse__AbsolutePathBuf = string;
export const V2ThreadStartResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadStartResponse__AgentPath = string;
export const V2ThreadStartResponse__AgentPath = Schema.String;

export type V2ThreadStartResponse__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2ThreadStartResponse__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadStartResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadStartResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadStartResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadStartResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadStartResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadStartResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadStartResponse__FileSystemAccessMode = "read" | "write" | "none";
export const V2ThreadStartResponse__FileSystemAccessMode = Schema.Literals([
  "read",
  "write",
  "none",
]);

export type V2ThreadStartResponse__FileSystemSpecialPath =
  | { readonly kind: "root" }
  | { readonly kind: "minimal" }
  | { readonly kind: "project_roots"; readonly subpath?: string | null }
  | { readonly kind: "tmpdir" }
  | { readonly kind: "slash_tmp" }
  | { readonly kind: "unknown"; readonly path: string; readonly subpath?: string | null };
export const V2ThreadStartResponse__FileSystemSpecialPath = Schema.Union(
  [
    Schema.Struct({ kind: Schema.Literal("root") }).annotate({
      title: "RootFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("minimal") }).annotate({
      title: "MinimalFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("project_roots"),
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "KindFileSystemSpecialPath" }),
    Schema.Struct({ kind: Schema.Literal("tmpdir") }).annotate({
      title: "TmpdirFileSystemSpecialPath",
    }),
    Schema.Struct({ kind: Schema.Literal("slash_tmp") }).annotate({
      title: "SlashTmpFileSystemSpecialPath",
    }),
    Schema.Struct({
      kind: Schema.Literal("unknown"),
      path: Schema.String,
      subpath: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadStartResponse__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadStartResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadStartResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadStartResponse__McpToolCallError = { readonly message: string };
export const V2ThreadStartResponse__McpToolCallError = Schema.Struct({ message: Schema.String });

export type V2ThreadStartResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadStartResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadStartResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadStartResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadStartResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadStartResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadStartResponse__MessagePhase = "commentary" | "final_answer";
export const V2ThreadStartResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadStartResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadStartResponse__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type V2ThreadStartResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadStartResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadStartResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadStartResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__PermissionProfileNetworkPermissions = {
  readonly enabled: boolean;
};
export const V2ThreadStartResponse__PermissionProfileNetworkPermissions = Schema.Struct({
  enabled: Schema.Boolean,
});

export type V2ThreadStartResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadStartResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadStartResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadStartResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadStartResponse__ThreadActiveFlag = "waitingOnApproval" | "waitingOnUserInput";
export const V2ThreadStartResponse__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadStartResponse__ThreadId = string;
export const V2ThreadStartResponse__ThreadId = Schema.String;

export type V2ThreadStartResponse__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadStartResponse__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadStartResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadStartResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadStartResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadStartResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStatusChangedNotification__ThreadActiveFlag =
  | "waitingOnApproval"
  | "waitingOnUserInput";
export const V2ThreadStatusChangedNotification__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadTokenUsageUpdatedNotification__TokenUsageBreakdown = {
  readonly cachedInputTokens: number;
  readonly inputTokens: number;
  readonly outputTokens: number;
  readonly reasoningOutputTokens: number;
  readonly totalTokens: number;
};
export const V2ThreadTokenUsageUpdatedNotification__TokenUsageBreakdown = Schema.Struct({
  cachedInputTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  inputTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  outputTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  reasoningOutputTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  totalTokens: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
});

export type V2ThreadUnarchiveResponse__AbsolutePathBuf = string;
export const V2ThreadUnarchiveResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2ThreadUnarchiveResponse__AgentPath = string;
export const V2ThreadUnarchiveResponse__AgentPath = Schema.String;

export type V2ThreadUnarchiveResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2ThreadUnarchiveResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2ThreadUnarchiveResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadUnarchiveResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadUnarchiveResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2ThreadUnarchiveResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadUnarchiveResponse__DynamicToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadUnarchiveResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadUnarchiveResponse__GitInfo = {
  readonly branch?: string | null;
  readonly originUrl?: string | null;
  readonly sha?: string | null;
};
export const V2ThreadUnarchiveResponse__GitInfo = Schema.Struct({
  branch: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  originUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadUnarchiveResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2ThreadUnarchiveResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2ThreadUnarchiveResponse__McpToolCallError = { readonly message: string };
export const V2ThreadUnarchiveResponse__McpToolCallError = Schema.Struct({
  message: Schema.String,
});

export type V2ThreadUnarchiveResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2ThreadUnarchiveResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2ThreadUnarchiveResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadUnarchiveResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadUnarchiveResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2ThreadUnarchiveResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2ThreadUnarchiveResponse__MessagePhase = "commentary" | "final_answer";
export const V2ThreadUnarchiveResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2ThreadUnarchiveResponse__NonSteerableTurnKind = "review" | "compact";
export const V2ThreadUnarchiveResponse__NonSteerableTurnKind = Schema.Literals([
  "review",
  "compact",
]);

export type V2ThreadUnarchiveResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2ThreadUnarchiveResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2ThreadUnarchiveResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2ThreadUnarchiveResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadUnarchiveResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2ThreadUnarchiveResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2ThreadUnarchiveResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2ThreadUnarchiveResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadUnarchiveResponse__ThreadActiveFlag =
  | "waitingOnApproval"
  | "waitingOnUserInput";
export const V2ThreadUnarchiveResponse__ThreadActiveFlag = Schema.Literals([
  "waitingOnApproval",
  "waitingOnUserInput",
]);

export type V2ThreadUnarchiveResponse__ThreadId = string;
export const V2ThreadUnarchiveResponse__ThreadId = Schema.String;

export type V2ThreadUnarchiveResponse__ThreadSource = "user" | "subagent" | "memory_consolidation";
export const V2ThreadUnarchiveResponse__ThreadSource = Schema.Literals([
  "user",
  "subagent",
  "memory_consolidation",
]);

export type V2ThreadUnarchiveResponse__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2ThreadUnarchiveResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2ThreadUnarchiveResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2ThreadUnarchiveResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadUnsubscribeResponse__ThreadUnsubscribeStatus =
  | "notLoaded"
  | "notSubscribed"
  | "unsubscribed";
export const V2ThreadUnsubscribeResponse__ThreadUnsubscribeStatus = Schema.Literals([
  "notLoaded",
  "notSubscribed",
  "unsubscribed",
]);

export type V2TurnCompletedNotification__AbsolutePathBuf = string;
export const V2TurnCompletedNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2TurnCompletedNotification__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2TurnCompletedNotification__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2TurnCompletedNotification__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2TurnCompletedNotification__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2TurnCompletedNotification__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2TurnCompletedNotification__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnCompletedNotification__DynamicToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2TurnCompletedNotification__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnCompletedNotification__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2TurnCompletedNotification__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2TurnCompletedNotification__McpToolCallError = { readonly message: string };
export const V2TurnCompletedNotification__McpToolCallError = Schema.Struct({
  message: Schema.String,
});

export type V2TurnCompletedNotification__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2TurnCompletedNotification__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2TurnCompletedNotification__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2TurnCompletedNotification__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnCompletedNotification__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2TurnCompletedNotification__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2TurnCompletedNotification__MessagePhase = "commentary" | "final_answer";
export const V2TurnCompletedNotification__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2TurnCompletedNotification__NonSteerableTurnKind = "review" | "compact";
export const V2TurnCompletedNotification__NonSteerableTurnKind = Schema.Literals([
  "review",
  "compact",
]);

export type V2TurnCompletedNotification__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2TurnCompletedNotification__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2TurnCompletedNotification__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2TurnCompletedNotification__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnCompletedNotification__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2TurnCompletedNotification__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2TurnCompletedNotification__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2TurnCompletedNotification__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2TurnCompletedNotification__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2TurnCompletedNotification__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2TurnCompletedNotification__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2TurnCompletedNotification__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnPlanUpdatedNotification__TurnPlanStepStatus =
  | "pending"
  | "inProgress"
  | "completed";
export const V2TurnPlanUpdatedNotification__TurnPlanStepStatus = Schema.Literals([
  "pending",
  "inProgress",
  "completed",
]);

export type V2TurnStartedNotification__AbsolutePathBuf = string;
export const V2TurnStartedNotification__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2TurnStartedNotification__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2TurnStartedNotification__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2TurnStartedNotification__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2TurnStartedNotification__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2TurnStartedNotification__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2TurnStartedNotification__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartedNotification__DynamicToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2TurnStartedNotification__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnStartedNotification__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2TurnStartedNotification__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2TurnStartedNotification__McpToolCallError = { readonly message: string };
export const V2TurnStartedNotification__McpToolCallError = Schema.Struct({
  message: Schema.String,
});

export type V2TurnStartedNotification__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2TurnStartedNotification__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2TurnStartedNotification__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2TurnStartedNotification__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnStartedNotification__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2TurnStartedNotification__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2TurnStartedNotification__MessagePhase = "commentary" | "final_answer";
export const V2TurnStartedNotification__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2TurnStartedNotification__NonSteerableTurnKind = "review" | "compact";
export const V2TurnStartedNotification__NonSteerableTurnKind = Schema.Literals([
  "review",
  "compact",
]);

export type V2TurnStartedNotification__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2TurnStartedNotification__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2TurnStartedNotification__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2TurnStartedNotification__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartedNotification__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2TurnStartedNotification__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2TurnStartedNotification__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2TurnStartedNotification__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2TurnStartedNotification__TurnStatus =
  | "completed"
  | "interrupted"
  | "failed"
  | "inProgress";
export const V2TurnStartedNotification__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2TurnStartedNotification__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2TurnStartedNotification__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartParams__AbsolutePathBuf = string;
export const V2TurnStartParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2TurnStartParams__ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
export const V2TurnStartParams__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2TurnStartParams__AskForApproval =
  | "untrusted"
  | "on-failure"
  | "on-request"
  | "never"
  | {
      readonly granular: {
        readonly mcp_elicitations: boolean;
        readonly request_permissions?: boolean;
        readonly rules: boolean;
        readonly sandbox_approval: boolean;
        readonly skill_approval?: boolean;
      };
    };
export const V2TurnStartParams__AskForApproval = Schema.Union(
  [
    Schema.Literals(["untrusted", "on-failure", "on-request", "never"]),
    Schema.Struct({
      granular: Schema.Struct({
        mcp_elicitations: Schema.Boolean,
        request_permissions: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        rules: Schema.Boolean,
        sandbox_approval: Schema.Boolean,
        skill_approval: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      }),
    }).annotate({ title: "GranularAskForApproval" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartParams__ModeKind = "plan" | "default";
export const V2TurnStartParams__ModeKind = Schema.Literals(["plan", "default"]).annotate({
  description: "Initial collaboration mode to use when the TUI starts.",
});

export type V2TurnStartParams__Personality = "none" | "friendly" | "pragmatic";
export const V2TurnStartParams__Personality = Schema.Literals(["none", "friendly", "pragmatic"]);

export type V2TurnStartParams__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2TurnStartParams__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2TurnStartParams__ReasoningSummary = "auto" | "concise" | "detailed" | "none";
export const V2TurnStartParams__ReasoningSummary = Schema.Union(
  [
    Schema.Literals(["auto", "concise", "detailed"]),
    Schema.Literal("none").annotate({ description: "Option to disable reasoning summaries." }),
  ],
  { mode: "oneOf" },
).annotate({
  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",
});

export type V2TurnStartParams__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2TurnStartParams__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2TurnStartResponse__AbsolutePathBuf = string;
export const V2TurnStartResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2TurnStartResponse__CollabAgentStatus =
  | "pendingInit"
  | "running"
  | "interrupted"
  | "completed"
  | "errored"
  | "shutdown"
  | "notFound";
export const V2TurnStartResponse__CollabAgentStatus = Schema.Literals([
  "pendingInit",
  "running",
  "interrupted",
  "completed",
  "errored",
  "shutdown",
  "notFound",
]);

export type V2TurnStartResponse__CommandExecutionStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2TurnStartResponse__CommandExecutionStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2TurnStartResponse__DynamicToolCallOutputContentItem =
  | { readonly text: string; readonly type: "inputText" }
  | { readonly imageUrl: string; readonly type: "inputImage" };
export const V2TurnStartResponse__DynamicToolCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("inputText").annotate({
        title: "InputTextDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextDynamicToolCallOutputContentItem" }),
    Schema.Struct({
      imageUrl: Schema.String,
      type: Schema.Literal("inputImage").annotate({
        title: "InputImageDynamicToolCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageDynamicToolCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartResponse__DynamicToolCallStatus = "inProgress" | "completed" | "failed";
export const V2TurnStartResponse__DynamicToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnStartResponse__HookPromptFragment = {
  readonly hookRunId: string;
  readonly text: string;
};
export const V2TurnStartResponse__HookPromptFragment = Schema.Struct({
  hookRunId: Schema.String,
  text: Schema.String,
});

export type V2TurnStartResponse__McpToolCallError = { readonly message: string };
export const V2TurnStartResponse__McpToolCallError = Schema.Struct({ message: Schema.String });

export type V2TurnStartResponse__McpToolCallResult = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly structuredContent?: unknown;
};
export const V2TurnStartResponse__McpToolCallResult = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  structuredContent: Schema.optionalKey(Schema.Unknown),
});

export type V2TurnStartResponse__McpToolCallStatus = "inProgress" | "completed" | "failed";
export const V2TurnStartResponse__McpToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnStartResponse__MemoryCitationEntry = {
  readonly lineEnd: number;
  readonly lineStart: number;
  readonly note: string;
  readonly path: string;
};
export const V2TurnStartResponse__MemoryCitationEntry = Schema.Struct({
  lineEnd: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  lineStart: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  note: Schema.String,
  path: Schema.String,
});

export type V2TurnStartResponse__MessagePhase = "commentary" | "final_answer";
export const V2TurnStartResponse__MessagePhase = Schema.Literals([
  "commentary",
  "final_answer",
]).annotate({
  description:
    'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
});

export type V2TurnStartResponse__NonSteerableTurnKind = "review" | "compact";
export const V2TurnStartResponse__NonSteerableTurnKind = Schema.Literals(["review", "compact"]);

export type V2TurnStartResponse__PatchApplyStatus =
  | "inProgress"
  | "completed"
  | "failed"
  | "declined";
export const V2TurnStartResponse__PatchApplyStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
  "declined",
]);

export type V2TurnStartResponse__PatchChangeKind =
  | { readonly type: "add" }
  | { readonly type: "delete" }
  | { readonly move_path?: string | null; readonly type: "update" };
export const V2TurnStartResponse__PatchChangeKind = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("add").annotate({ title: "AddPatchChangeKindType" }),
    }).annotate({ title: "AddPatchChangeKind" }),
    Schema.Struct({
      type: Schema.Literal("delete").annotate({ title: "DeletePatchChangeKindType" }),
    }).annotate({ title: "DeletePatchChangeKind" }),
    Schema.Struct({
      move_path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("update").annotate({ title: "UpdatePatchChangeKindType" }),
    }).annotate({ title: "UpdatePatchChangeKind" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartResponse__ReasoningEffort =
  | "none"
  | "minimal"
  | "low"
  | "medium"
  | "high"
  | "xhigh";
export const V2TurnStartResponse__ReasoningEffort = Schema.Literals([
  "none",
  "minimal",
  "low",
  "medium",
  "high",
  "xhigh",
]).annotate({
  description:
    "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
});

export type V2TurnStartResponse__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2TurnStartResponse__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2TurnStartResponse__TurnStatus = "completed" | "interrupted" | "failed" | "inProgress";
export const V2TurnStartResponse__TurnStatus = Schema.Literals([
  "completed",
  "interrupted",
  "failed",
  "inProgress",
]);

export type V2TurnStartResponse__WebSearchAction =
  | {
      readonly queries?: ReadonlyArray<string> | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly type: "openPage"; readonly url?: string | null }
  | { readonly pattern?: string | null; readonly type: "findInPage"; readonly url?: string | null }
  | { readonly type: "other" };
export const V2TurnStartResponse__WebSearchAction = Schema.Union(
  [
    Schema.Struct({
      queries: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchWebSearchActionType" }),
    }).annotate({ title: "SearchWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("openPage").annotate({ title: "OpenPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "OpenPageWebSearchAction" }),
    Schema.Struct({
      pattern: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("findInPage").annotate({ title: "FindInPageWebSearchActionType" }),
      url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    }).annotate({ title: "FindInPageWebSearchAction" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherWebSearchActionType" }),
    }).annotate({ title: "OtherWebSearchAction" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnSteerParams__TextElement = {
  readonly byteRange: { readonly end: number; readonly start: number };
  readonly placeholder?: string | null;
};
export const V2TurnSteerParams__TextElement = Schema.Struct({
  byteRange: Schema.Struct({
    end: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    start: Schema.Number.annotate({ format: "uint" })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({
    description: "Byte range in the parent `text` buffer that this element occupies.",
  }),
  placeholder: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional human-readable placeholder for the element, displayed in the UI.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2WindowsSandboxReadinessResponse__WindowsSandboxReadiness =
  | "ready"
  | "notConfigured"
  | "updateRequired";
export const V2WindowsSandboxReadinessResponse__WindowsSandboxReadiness = Schema.Literals([
  "ready",
  "notConfigured",
  "updateRequired",
]);

export type V2WindowsSandboxSetupCompletedNotification__WindowsSandboxSetupMode =
  | "elevated"
  | "unelevated";
export const V2WindowsSandboxSetupCompletedNotification__WindowsSandboxSetupMode = Schema.Literals([
  "elevated",
  "unelevated",
]);

export type V2WindowsSandboxSetupStartParams__AbsolutePathBuf = string;
export const V2WindowsSandboxSetupStartParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2WindowsSandboxSetupStartParams__WindowsSandboxSetupMode = "elevated" | "unelevated";
export const V2WindowsSandboxSetupStartParams__WindowsSandboxSetupMode = Schema.Literals([
  "elevated",
  "unelevated",
]);

export type ApplyPatchApprovalResponse__NetworkPolicyAmendment = {
  readonly action: ApplyPatchApprovalResponse__NetworkPolicyRuleAction;
  readonly host: string;
};
export const ApplyPatchApprovalResponse__NetworkPolicyAmendment = Schema.Struct({
  action: ApplyPatchApprovalResponse__NetworkPolicyRuleAction,
  host: Schema.String,
});

export type ClientRequest__PermissionProfileModificationParams = {
  readonly path: ClientRequest__AbsolutePathBuf;
  readonly type: "additionalWritableRoot";
};
export const ClientRequest__PermissionProfileModificationParams = Schema.Union(
  [
    Schema.Struct({
      path: ClientRequest__AbsolutePathBuf,
      type: Schema.Literal("additionalWritableRoot").annotate({
        title: "AdditionalWritableRootPermissionProfileModificationParamsType",
      }),
    }).annotate({
      title: "AdditionalWritableRootPermissionProfileModificationParams",
      description: "Additional concrete directory that should be writable.",
    }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__PluginInstallParams = {
  readonly marketplacePath?: ClientRequest__AbsolutePathBuf | null;
  readonly pluginName: string;
  readonly remoteMarketplaceName?: string | null;
};
export const ClientRequest__PluginInstallParams = Schema.Struct({
  marketplacePath: Schema.optionalKey(Schema.Union([ClientRequest__AbsolutePathBuf, Schema.Null])),
  pluginName: Schema.String,
  remoteMarketplaceName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ClientRequest__PluginReadParams = {
  readonly marketplacePath?: ClientRequest__AbsolutePathBuf | null;
  readonly pluginName: string;
  readonly remoteMarketplaceName?: string | null;
};
export const ClientRequest__PluginReadParams = Schema.Struct({
  marketplacePath: Schema.optionalKey(Schema.Union([ClientRequest__AbsolutePathBuf, Schema.Null])),
  pluginName: Schema.String,
  remoteMarketplaceName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ClientRequest__SandboxPolicy =
  | { readonly type: "dangerFullAccess" }
  | { readonly networkAccess?: boolean; readonly type: "readOnly" }
  | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
  | {
      readonly excludeSlashTmp?: boolean;
      readonly excludeTmpdirEnvVar?: boolean;
      readonly networkAccess?: boolean;
      readonly type: "workspaceWrite";
      readonly writableRoots?: ReadonlyArray<ClientRequest__AbsolutePathBuf>;
    };
export const ClientRequest__SandboxPolicy = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("dangerFullAccess").annotate({
        title: "DangerFullAccessSandboxPolicyType",
      }),
    }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
    }).annotate({ title: "ReadOnlySandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(
        Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
      ),
      type: Schema.Literal("externalSandbox").annotate({
        title: "ExternalSandboxSandboxPolicyType",
      }),
    }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
    Schema.Struct({
      excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("workspaceWrite").annotate({ title: "WorkspaceWriteSandboxPolicyType" }),
      writableRoots: Schema.optionalKey(
        Schema.Array(ClientRequest__AbsolutePathBuf).annotate({ default: [] }),
      ),
    }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__SkillsConfigWriteParams = {
  readonly enabled: boolean;
  readonly name?: string | null;
  readonly path?: ClientRequest__AbsolutePathBuf | null;
};
export const ClientRequest__SkillsConfigWriteParams = Schema.Struct({
  enabled: Schema.Boolean,
  name: Schema.optionalKey(
    Schema.Union([Schema.String.annotate({ description: "Name-based selector." }), Schema.Null]),
  ),
  path: Schema.optionalKey(
    Schema.Union([ClientRequest__AbsolutePathBuf, Schema.Null]).annotate({
      description: "Path-based selector.",
    }),
  ),
});

export type ClientRequest__SendAddCreditsNudgeEmailParams = {
  readonly creditType: ClientRequest__AddCreditsNudgeCreditType;
};
export const ClientRequest__SendAddCreditsNudgeEmailParams = Schema.Struct({
  creditType: ClientRequest__AddCreditsNudgeCreditType,
});

export type ClientRequest__FileSystemPath =
  | { readonly path: ClientRequest__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | { readonly type: "special"; readonly value: ClientRequest__FileSystemSpecialPath };
export const ClientRequest__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: ClientRequest__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: ClientRequest__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__ContentItem =
  | { readonly text: string; readonly type: "input_text" }
  | {
      readonly detail?: ClientRequest__ImageDetail | null;
      readonly image_url: string;
      readonly type: "input_image";
    }
  | { readonly text: string; readonly type: "output_text" };
export const ClientRequest__ContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("input_text").annotate({ title: "InputTextContentItemType" }),
    }).annotate({ title: "InputTextContentItem" }),
    Schema.Struct({
      detail: Schema.optionalKey(Schema.Union([ClientRequest__ImageDetail, Schema.Null])),
      image_url: Schema.String,
      type: Schema.Literal("input_image").annotate({ title: "InputImageContentItemType" }),
    }).annotate({ title: "InputImageContentItem" }),
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("output_text").annotate({ title: "OutputTextContentItemType" }),
    }).annotate({ title: "OutputTextContentItem" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__FunctionCallOutputContentItem =
  | { readonly text: string; readonly type: "input_text" }
  | {
      readonly detail?: ClientRequest__ImageDetail | null;
      readonly image_url: string;
      readonly type: "input_image";
    };
export const ClientRequest__FunctionCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("input_text").annotate({
        title: "InputTextFunctionCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextFunctionCallOutputContentItem" }),
    Schema.Struct({
      detail: Schema.optionalKey(Schema.Union([ClientRequest__ImageDetail, Schema.Null])),
      image_url: Schema.String,
      type: Schema.Literal("input_image").annotate({
        title: "InputImageFunctionCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageFunctionCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type ClientRequest__InitializeParams = {
  readonly capabilities?: ClientRequest__InitializeCapabilities | null;
  readonly clientInfo: ClientRequest__ClientInfo;
};
export const ClientRequest__InitializeParams = Schema.Struct({
  capabilities: Schema.optionalKey(
    Schema.Union([ClientRequest__InitializeCapabilities, Schema.Null]),
  ),
  clientInfo: ClientRequest__ClientInfo,
});

export type ClientRequest__ListMcpServerStatusParams = {
  readonly cursor?: string | null;
  readonly detail?: ClientRequest__McpServerStatusDetail | null;
  readonly limit?: number | null;
};
export const ClientRequest__ListMcpServerStatusParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  detail: Schema.optionalKey(
    Schema.Union([ClientRequest__McpServerStatusDetail, Schema.Null]).annotate({
      description:
        "Controls how much MCP inventory data to fetch for each server. Defaults to `Full` when omitted.",
    }),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a server-defined value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
});

export type ClientRequest__ConfigEdit = {
  readonly keyPath: string;
  readonly mergeStrategy: ClientRequest__MergeStrategy;
  readonly value: unknown;
};
export const ClientRequest__ConfigEdit = Schema.Struct({
  keyPath: Schema.String,
  mergeStrategy: ClientRequest__MergeStrategy,
  value: Schema.Unknown,
});

export type ClientRequest__ConfigValueWriteParams = {
  readonly expectedVersion?: string | null;
  readonly filePath?: string | null;
  readonly keyPath: string;
  readonly mergeStrategy: ClientRequest__MergeStrategy;
  readonly value: unknown;
};
export const ClientRequest__ConfigValueWriteParams = Schema.Struct({
  expectedVersion: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  filePath: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Path to the config file to write; defaults to the user's `config.toml` when omitted.",
      }),
      Schema.Null,
    ]),
  ),
  keyPath: Schema.String,
  mergeStrategy: ClientRequest__MergeStrategy,
  value: Schema.Unknown,
});

export type ClientRequest__PluginListParams = {
  readonly cwds?: ReadonlyArray<ClientRequest__AbsolutePathBuf> | null;
  readonly marketplaceKinds?: ReadonlyArray<ClientRequest__PluginListMarketplaceKind> | null;
};
export const ClientRequest__PluginListParams = Schema.Struct({
  cwds: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ClientRequest__AbsolutePathBuf).annotate({
        description:
          "Optional working directories used to discover repo marketplaces. When omitted, only home-scoped marketplaces and the official curated marketplace are considered.",
      }),
      Schema.Null,
    ]),
  ),
  marketplaceKinds: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ClientRequest__PluginListMarketplaceKind).annotate({
        description:
          "Optional marketplace kind filter. When omitted, only local marketplaces are queried, plus the default remote catalog when enabled by feature flag.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ClientRequest__PluginShareTarget = {
  readonly principalId: string;
  readonly principalType: ClientRequest__PluginSharePrincipalType;
};
export const ClientRequest__PluginShareTarget = Schema.Struct({
  principalId: Schema.String,
  principalType: ClientRequest__PluginSharePrincipalType,
});

export type ClientRequest__Settings = {
  readonly developer_instructions?: string | null;
  readonly model: string;
  readonly reasoning_effort?: ClientRequest__ReasoningEffort | null;
};
export const ClientRequest__Settings = Schema.Struct({
  developer_instructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  model: Schema.String,
  reasoning_effort: Schema.optionalKey(Schema.Union([ClientRequest__ReasoningEffort, Schema.Null])),
}).annotate({ description: "Settings for a collaboration mode." });

export type ClientRequest__ReviewStartParams = {
  readonly delivery?: ClientRequest__ReviewDelivery | null;
  readonly target: ClientRequest__ReviewTarget;
  readonly threadId: string;
};
export const ClientRequest__ReviewStartParams = Schema.Struct({
  delivery: Schema.optionalKey(
    Schema.Union([ClientRequest__ReviewDelivery, Schema.Null]).annotate({
      description:
        "Where to run the review: inline (default) on the current thread or detached on a new thread (returned in `reviewThreadId`).",
    }),
  ),
  target: ClientRequest__ReviewTarget,
  threadId: Schema.String,
});

export type ClientRequest__ThreadResumeParams = {
  readonly approvalPolicy?: ClientRequest__AskForApproval | null;
  readonly approvalsReviewer?: ClientRequest__ApprovalsReviewer | null;
  readonly baseInstructions?: string | null;
  readonly config?: { readonly [x: string]: unknown } | null;
  readonly cwd?: string | null;
  readonly developerInstructions?: string | null;
  readonly model?: string | null;
  readonly modelProvider?: string | null;
  readonly personality?: ClientRequest__Personality | null;
  readonly sandbox?: ClientRequest__SandboxMode | null;
  readonly serviceTier?: string | null;
  readonly threadId: string;
};
export const ClientRequest__ThreadResumeParams = Schema.Struct({
  approvalPolicy: Schema.optionalKey(Schema.Union([ClientRequest__AskForApproval, Schema.Null])),
  approvalsReviewer: Schema.optionalKey(
    Schema.Union([ClientRequest__ApprovalsReviewer, Schema.Null]).annotate({
      description:
        "Override where approval requests are routed for review on this thread and subsequent turns.",
    }),
  ),
  baseInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  config: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.Unknown), Schema.Null]),
  ),
  cwd: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developerInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  model: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Configuration overrides for the resumed thread, if any.",
      }),
      Schema.Null,
    ]),
  ),
  modelProvider: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  personality: Schema.optionalKey(Schema.Union([ClientRequest__Personality, Schema.Null])),
  sandbox: Schema.optionalKey(Schema.Union([ClientRequest__SandboxMode, Schema.Null])),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
}).annotate({
  description:
    "There are three ways to resume a thread: 1. By thread_id: load the thread from disk by thread_id and resume it. 2. By history: instantiate the thread from memory and resume it. 3. By path: load the thread from disk by path and resume it.\n\nThe precedence is: history > path > thread_id. If using history or path, the thread_id param will be ignored.\n\nPrefer using thread_id whenever possible.",
});

export type ClientRequest__SkillsListParams = {
  readonly cwds?: ReadonlyArray<string>;
  readonly forceReload?: boolean;
  readonly perCwdExtraUserRoots?: ReadonlyArray<ClientRequest__SkillsListExtraRootsForCwd> | null;
};
export const ClientRequest__SkillsListParams = Schema.Struct({
  cwds: Schema.optionalKey(
    Schema.Array(Schema.String).annotate({
      description: "When empty, defaults to the current session working directory.",
    }),
  ),
  forceReload: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "When true, bypass the skills cache and re-scan skills from disk.",
    }),
  ),
  perCwdExtraUserRoots: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ClientRequest__SkillsListExtraRootsForCwd).annotate({
        description: "Optional per-cwd extra roots to scan as user-scoped skills.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ClientRequest__MigrationDetails = {
  readonly commands?: ReadonlyArray<ClientRequest__CommandMigration>;
  readonly hooks?: ReadonlyArray<ClientRequest__HookMigration>;
  readonly mcpServers?: ReadonlyArray<ClientRequest__McpServerMigration>;
  readonly plugins?: ReadonlyArray<ClientRequest__PluginsMigration>;
  readonly sessions?: ReadonlyArray<ClientRequest__SessionMigration>;
  readonly subagents?: ReadonlyArray<ClientRequest__SubagentMigration>;
};
export const ClientRequest__MigrationDetails = Schema.Struct({
  commands: Schema.optionalKey(
    Schema.Array(ClientRequest__CommandMigration).annotate({ default: [] }),
  ),
  hooks: Schema.optionalKey(Schema.Array(ClientRequest__HookMigration).annotate({ default: [] })),
  mcpServers: Schema.optionalKey(
    Schema.Array(ClientRequest__McpServerMigration).annotate({ default: [] }),
  ),
  plugins: Schema.optionalKey(
    Schema.Array(ClientRequest__PluginsMigration).annotate({ default: [] }),
  ),
  sessions: Schema.optionalKey(
    Schema.Array(ClientRequest__SessionMigration).annotate({ default: [] }),
  ),
  subagents: Schema.optionalKey(
    Schema.Array(ClientRequest__SubagentMigration).annotate({ default: [] }),
  ),
});

export type ClientRequest__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<ClientRequest__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const ClientRequest__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(ClientRequest__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__ThreadMetadataUpdateParams = {
  readonly gitInfo?: ClientRequest__ThreadMetadataGitInfoUpdateParams | null;
  readonly threadId: string;
};
export const ClientRequest__ThreadMetadataUpdateParams = Schema.Struct({
  gitInfo: Schema.optionalKey(
    Schema.Union([ClientRequest__ThreadMetadataGitInfoUpdateParams, Schema.Null]).annotate({
      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.",
    }),
  ),
  threadId: Schema.String,
});

export type ClientRequest__ThreadForkParams = {
  readonly approvalPolicy?: ClientRequest__AskForApproval | null;
  readonly approvalsReviewer?: ClientRequest__ApprovalsReviewer | null;
  readonly baseInstructions?: string | null;
  readonly config?: { readonly [x: string]: unknown } | null;
  readonly cwd?: string | null;
  readonly developerInstructions?: string | null;
  readonly ephemeral?: boolean;
  readonly model?: string | null;
  readonly modelProvider?: string | null;
  readonly sandbox?: ClientRequest__SandboxMode | null;
  readonly serviceTier?: string | null;
  readonly threadId: string;
  readonly threadSource?: ClientRequest__ThreadSource | null;
};
export const ClientRequest__ThreadForkParams = Schema.Struct({
  approvalPolicy: Schema.optionalKey(Schema.Union([ClientRequest__AskForApproval, Schema.Null])),
  approvalsReviewer: Schema.optionalKey(
    Schema.Union([ClientRequest__ApprovalsReviewer, Schema.Null]).annotate({
      description:
        "Override where approval requests are routed for review on this thread and subsequent turns.",
    }),
  ),
  baseInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  config: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.Unknown), Schema.Null]),
  ),
  cwd: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developerInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  ephemeral: Schema.optionalKey(Schema.Boolean),
  model: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Configuration overrides for the forked thread, if any.",
      }),
      Schema.Null,
    ]),
  ),
  modelProvider: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sandbox: Schema.optionalKey(Schema.Union([ClientRequest__SandboxMode, Schema.Null])),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
  threadSource: Schema.optionalKey(
    Schema.Union([ClientRequest__ThreadSource, Schema.Null]).annotate({
      description:
        "Optional client-supplied analytics source classification for this forked thread.",
    }),
  ),
}).annotate({
  description:
    "There are two ways to fork a thread: 1. By thread_id: load the thread from disk by thread_id and fork it into a new thread. 2. By path: load the thread from disk by path and fork it into a new thread.\n\nIf using path, the thread_id param will be ignored.\n\nPrefer using thread_id whenever possible.",
});

export type ClientRequest__ThreadListParams = {
  readonly archived?: boolean | null;
  readonly cursor?: string | null;
  readonly cwd?: ClientRequest__ThreadListCwdFilter | null;
  readonly limit?: number | null;
  readonly modelProviders?: ReadonlyArray<string> | null;
  readonly searchTerm?: string | null;
  readonly sortDirection?: ClientRequest__SortDirection | null;
  readonly sortKey?: ClientRequest__ThreadSortKey | null;
  readonly sourceKinds?: ReadonlyArray<ClientRequest__ThreadSourceKind> | null;
  readonly useStateDbOnly?: boolean;
};
export const ClientRequest__ThreadListParams = Schema.Struct({
  archived: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description:
          "Optional archived filter; when set to true, only archived threads are returned. If false or null, only non-archived threads are returned.",
      }),
      Schema.Null,
    ]),
  ),
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  cwd: Schema.optionalKey(
    Schema.Union([ClientRequest__ThreadListCwdFilter, Schema.Null]).annotate({
      description:
        "Optional cwd filter or filters; when set, only threads whose session cwd exactly matches one of these paths are returned.",
    }),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a reasonable server-side value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  modelProviders: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Optional provider filter; when set, only sessions recorded under these providers are returned. When present but empty, includes all providers.",
      }),
      Schema.Null,
    ]),
  ),
  searchTerm: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional substring filter for the extracted thread title.",
      }),
      Schema.Null,
    ]),
  ),
  sortDirection: Schema.optionalKey(
    Schema.Union([ClientRequest__SortDirection, Schema.Null]).annotate({
      description: "Optional sort direction; defaults to descending (newest first).",
    }),
  ),
  sortKey: Schema.optionalKey(
    Schema.Union([ClientRequest__ThreadSortKey, Schema.Null]).annotate({
      description: "Optional sort key; defaults to created_at.",
    }),
  ),
  sourceKinds: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ClientRequest__ThreadSourceKind).annotate({
        description:
          "Optional source filter; when set, only sessions from these source kinds are returned. When omitted or empty, defaults to interactive sources.",
      }),
      Schema.Null,
    ]),
  ),
  useStateDbOnly: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "If true, return from the state DB without scanning JSONL rollouts to repair thread metadata. Omitted or false preserves scan-and-repair behavior.",
    }),
  ),
});

export type ClientRequest__ThreadStartParams = {
  readonly approvalPolicy?: ClientRequest__AskForApproval | null;
  readonly approvalsReviewer?: ClientRequest__ApprovalsReviewer | null;
  readonly baseInstructions?: string | null;
  readonly config?: { readonly [x: string]: unknown } | null;
  readonly cwd?: string | null;
  readonly developerInstructions?: string | null;
  readonly ephemeral?: boolean | null;
  readonly model?: string | null;
  readonly modelProvider?: string | null;
  readonly personality?: ClientRequest__Personality | null;
  readonly sandbox?: ClientRequest__SandboxMode | null;
  readonly serviceName?: string | null;
  readonly serviceTier?: string | null;
  readonly sessionStartSource?: ClientRequest__ThreadStartSource | null;
  readonly threadSource?: ClientRequest__ThreadSource | null;
};
export const ClientRequest__ThreadStartParams = Schema.Struct({
  approvalPolicy: Schema.optionalKey(Schema.Union([ClientRequest__AskForApproval, Schema.Null])),
  approvalsReviewer: Schema.optionalKey(
    Schema.Union([ClientRequest__ApprovalsReviewer, Schema.Null]).annotate({
      description:
        "Override where approval requests are routed for review on this thread and subsequent turns.",
    }),
  ),
  baseInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  config: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.Unknown), Schema.Null]),
  ),
  cwd: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developerInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  ephemeral: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  model: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  modelProvider: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  personality: Schema.optionalKey(Schema.Union([ClientRequest__Personality, Schema.Null])),
  sandbox: Schema.optionalKey(Schema.Union([ClientRequest__SandboxMode, Schema.Null])),
  serviceName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sessionStartSource: Schema.optionalKey(
    Schema.Union([ClientRequest__ThreadStartSource, Schema.Null]),
  ),
  threadSource: Schema.optionalKey(
    Schema.Union([ClientRequest__ThreadSource, Schema.Null]).annotate({
      description: "Optional client-supplied analytics source classification for this thread.",
    }),
  ),
});

export type ClientRequest__WindowsSandboxSetupStartParams = {
  readonly cwd?: ClientRequest__AbsolutePathBuf | null;
  readonly mode: ClientRequest__WindowsSandboxSetupMode;
};
export const ClientRequest__WindowsSandboxSetupStartParams = Schema.Struct({
  cwd: Schema.optionalKey(Schema.Union([ClientRequest__AbsolutePathBuf, Schema.Null])),
  mode: ClientRequest__WindowsSandboxSetupMode,
});

export type CommandExecutionRequestApprovalParams__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: CommandExecutionRequestApprovalParams__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const CommandExecutionRequestApprovalParams__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: CommandExecutionRequestApprovalParams__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type CommandExecutionRequestApprovalParams__FileSystemPath =
  | { readonly path: CommandExecutionRequestApprovalParams__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | {
      readonly type: "special";
      readonly value: CommandExecutionRequestApprovalParams__FileSystemSpecialPath;
    };
export const CommandExecutionRequestApprovalParams__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: CommandExecutionRequestApprovalParams__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: CommandExecutionRequestApprovalParams__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type CommandExecutionRequestApprovalParams__NetworkApprovalContext = {
  readonly host: string;
  readonly protocol: CommandExecutionRequestApprovalParams__NetworkApprovalProtocol;
};
export const CommandExecutionRequestApprovalParams__NetworkApprovalContext = Schema.Struct({
  host: Schema.String,
  protocol: CommandExecutionRequestApprovalParams__NetworkApprovalProtocol,
});

export type CommandExecutionRequestApprovalParams__NetworkPolicyAmendment = {
  readonly action: CommandExecutionRequestApprovalParams__NetworkPolicyRuleAction;
  readonly host: string;
};
export const CommandExecutionRequestApprovalParams__NetworkPolicyAmendment = Schema.Struct({
  action: CommandExecutionRequestApprovalParams__NetworkPolicyRuleAction,
  host: Schema.String,
});

export type CommandExecutionRequestApprovalResponse__NetworkPolicyAmendment = {
  readonly action: CommandExecutionRequestApprovalResponse__NetworkPolicyRuleAction;
  readonly host: string;
};
export const CommandExecutionRequestApprovalResponse__NetworkPolicyAmendment = Schema.Struct({
  action: CommandExecutionRequestApprovalResponse__NetworkPolicyRuleAction,
  host: Schema.String,
});

export type ExecCommandApprovalResponse__NetworkPolicyAmendment = {
  readonly action: ExecCommandApprovalResponse__NetworkPolicyRuleAction;
  readonly host: string;
};
export const ExecCommandApprovalResponse__NetworkPolicyAmendment = Schema.Struct({
  action: ExecCommandApprovalResponse__NetworkPolicyRuleAction,
  host: Schema.String,
});

export type FuzzyFileSearchResponse__FuzzyFileSearchResult = {
  readonly file_name: string;
  readonly indices?: ReadonlyArray<number> | null;
  readonly match_type: FuzzyFileSearchResponse__FuzzyFileSearchMatchType;
  readonly path: string;
  readonly root: string;
  readonly score: number;
};
export const FuzzyFileSearchResponse__FuzzyFileSearchResult = Schema.Struct({
  file_name: Schema.String,
  indices: Schema.optionalKey(
    Schema.Union([
      Schema.Array(
        Schema.Number.annotate({ format: "uint32" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
      ),
      Schema.Null,
    ]),
  ),
  match_type: FuzzyFileSearchResponse__FuzzyFileSearchMatchType,
  path: Schema.String,
  root: Schema.String,
  score: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
}).annotate({ description: "Superset of [`codex_file_search::FileMatch`]" });

export type FuzzyFileSearchSessionUpdatedNotification__FuzzyFileSearchResult = {
  readonly file_name: string;
  readonly indices?: ReadonlyArray<number> | null;
  readonly match_type: FuzzyFileSearchSessionUpdatedNotification__FuzzyFileSearchMatchType;
  readonly path: string;
  readonly root: string;
  readonly score: number;
};
export const FuzzyFileSearchSessionUpdatedNotification__FuzzyFileSearchResult = Schema.Struct({
  file_name: Schema.String,
  indices: Schema.optionalKey(
    Schema.Union([
      Schema.Array(
        Schema.Number.annotate({ format: "uint32" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
      ),
      Schema.Null,
    ]),
  ),
  match_type: FuzzyFileSearchSessionUpdatedNotification__FuzzyFileSearchMatchType,
  path: Schema.String,
  root: Schema.String,
  score: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
}).annotate({ description: "Superset of [`codex_file_search::FileMatch`]" });

export type JSONRPCMessage__JSONRPCError = {
  readonly error: JSONRPCMessage__JSONRPCErrorError;
  readonly id: JSONRPCMessage__RequestId;
};
export const JSONRPCMessage__JSONRPCError = Schema.Struct({
  error: JSONRPCMessage__JSONRPCErrorError,
  id: JSONRPCMessage__RequestId,
}).annotate({ description: "A response to a request that indicates an error occurred." });

export type JSONRPCMessage__JSONRPCResponse = {
  readonly id: JSONRPCMessage__RequestId;
  readonly result: unknown;
};
export const JSONRPCMessage__JSONRPCResponse = Schema.Struct({
  id: JSONRPCMessage__RequestId,
  result: Schema.Unknown,
}).annotate({ description: "A successful (non-error) response to a request." });

export type JSONRPCMessage__JSONRPCRequest = {
  readonly id: JSONRPCMessage__RequestId;
  readonly method: string;
  readonly params?: unknown;
  readonly trace?: JSONRPCMessage__W3cTraceContext | null;
};
export const JSONRPCMessage__JSONRPCRequest = Schema.Struct({
  id: JSONRPCMessage__RequestId,
  method: Schema.String,
  params: Schema.optionalKey(Schema.Unknown),
  trace: Schema.optionalKey(
    Schema.Union([JSONRPCMessage__W3cTraceContext, Schema.Null]).annotate({
      description: "Optional W3C Trace Context for distributed tracing.",
    }),
  ),
}).annotate({ description: "A request that expects a response." });

export type McpServerElicitationRequestParams__McpElicitationBooleanSchema = {
  readonly default?: boolean | null;
  readonly description?: string | null;
  readonly title?: string | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationBooleanType;
};
export const McpServerElicitationRequestParams__McpElicitationBooleanSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: McpServerElicitationRequestParams__McpElicitationBooleanType,
});

export type McpServerElicitationRequestParams__McpElicitationTitledEnumItems = {
  readonly anyOf: ReadonlyArray<McpServerElicitationRequestParams__McpElicitationConstOption>;
};
export const McpServerElicitationRequestParams__McpElicitationTitledEnumItems = Schema.Struct({
  anyOf: Schema.Array(McpServerElicitationRequestParams__McpElicitationConstOption),
});

export type McpServerElicitationRequestParams__McpElicitationNumberSchema = {
  readonly default?: number | null;
  readonly description?: string | null;
  readonly maximum?: number | null;
  readonly minimum?: number | null;
  readonly title?: string | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationNumberType;
};
export const McpServerElicitationRequestParams__McpElicitationNumberSchema = Schema.Struct({
  default: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "double" }).check(Schema.isFinite()),
      Schema.Null,
    ]),
  ),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  maximum: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "double" }).check(Schema.isFinite()),
      Schema.Null,
    ]),
  ),
  minimum: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "double" }).check(Schema.isFinite()),
      Schema.Null,
    ]),
  ),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: McpServerElicitationRequestParams__McpElicitationNumberType,
});

export type McpServerElicitationRequestParams__McpElicitationLegacyTitledEnumSchema = {
  readonly default?: string | null;
  readonly description?: string | null;
  readonly enum: ReadonlyArray<string>;
  readonly enumNames?: ReadonlyArray<string> | null;
  readonly title?: string | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationStringType;
};
export const McpServerElicitationRequestParams__McpElicitationLegacyTitledEnumSchema =
  Schema.Struct({
    default: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    enum: Schema.Array(Schema.String),
    enumNames: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
    title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    type: McpServerElicitationRequestParams__McpElicitationStringType,
  });

export type McpServerElicitationRequestParams__McpElicitationStringSchema = {
  readonly default?: string | null;
  readonly description?: string | null;
  readonly format?: McpServerElicitationRequestParams__McpElicitationStringFormat | null;
  readonly maxLength?: number | null;
  readonly minLength?: number | null;
  readonly title?: string | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationStringType;
};
export const McpServerElicitationRequestParams__McpElicitationStringSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  format: Schema.optionalKey(
    Schema.Union([McpServerElicitationRequestParams__McpElicitationStringFormat, Schema.Null]),
  ),
  maxLength: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint32" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  minLength: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint32" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: McpServerElicitationRequestParams__McpElicitationStringType,
});

export type McpServerElicitationRequestParams__McpElicitationTitledSingleSelectEnumSchema = {
  readonly default?: string | null;
  readonly description?: string | null;
  readonly oneOf: ReadonlyArray<McpServerElicitationRequestParams__McpElicitationConstOption>;
  readonly title?: string | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationStringType;
};
export const McpServerElicitationRequestParams__McpElicitationTitledSingleSelectEnumSchema =
  Schema.Struct({
    default: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    oneOf: Schema.Array(McpServerElicitationRequestParams__McpElicitationConstOption),
    title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    type: McpServerElicitationRequestParams__McpElicitationStringType,
  });

export type McpServerElicitationRequestParams__McpElicitationUntitledEnumItems = {
  readonly enum: ReadonlyArray<string>;
  readonly type: McpServerElicitationRequestParams__McpElicitationStringType;
};
export const McpServerElicitationRequestParams__McpElicitationUntitledEnumItems = Schema.Struct({
  enum: Schema.Array(Schema.String),
  type: McpServerElicitationRequestParams__McpElicitationStringType,
});

export type McpServerElicitationRequestParams__McpElicitationUntitledSingleSelectEnumSchema = {
  readonly default?: string | null;
  readonly description?: string | null;
  readonly enum: ReadonlyArray<string>;
  readonly title?: string | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationStringType;
};
export const McpServerElicitationRequestParams__McpElicitationUntitledSingleSelectEnumSchema =
  Schema.Struct({
    default: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    enum: Schema.Array(Schema.String),
    title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    type: McpServerElicitationRequestParams__McpElicitationStringType,
  });

export type PermissionsRequestApprovalParams__FileSystemPath =
  | { readonly path: PermissionsRequestApprovalParams__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | {
      readonly type: "special";
      readonly value: PermissionsRequestApprovalParams__FileSystemSpecialPath;
    };
export const PermissionsRequestApprovalParams__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: PermissionsRequestApprovalParams__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: PermissionsRequestApprovalParams__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type PermissionsRequestApprovalResponse__FileSystemPath =
  | { readonly path: PermissionsRequestApprovalResponse__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | {
      readonly type: "special";
      readonly value: PermissionsRequestApprovalResponse__FileSystemSpecialPath;
    };
export const PermissionsRequestApprovalResponse__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: PermissionsRequestApprovalResponse__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: PermissionsRequestApprovalResponse__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: ServerNotification__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const ServerNotification__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: ServerNotification__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__FsChangedNotification = {
  readonly changedPaths: ReadonlyArray<ServerNotification__AbsolutePathBuf>;
  readonly watchId: string;
};
export const ServerNotification__FsChangedNotification = Schema.Struct({
  changedPaths: Schema.Array(ServerNotification__AbsolutePathBuf).annotate({
    description: "File or directory paths associated with this event.",
  }),
  watchId: Schema.String.annotate({
    description: "Watch identifier previously provided to `fs/watch`.",
  }),
}).annotate({ description: "Filesystem watch notification emitted for `fs/watch` subscribers." });

export type ServerNotification__AppMetadata = {
  readonly categories?: ReadonlyArray<string> | null;
  readonly developer?: string | null;
  readonly firstPartyRequiresInstall?: boolean | null;
  readonly firstPartyType?: string | null;
  readonly review?: ServerNotification__AppReview | null;
  readonly screenshots?: ReadonlyArray<ServerNotification__AppScreenshot> | null;
  readonly seoDescription?: string | null;
  readonly showInComposerWhenUnlinked?: boolean | null;
  readonly subCategories?: ReadonlyArray<string> | null;
  readonly version?: string | null;
  readonly versionId?: string | null;
  readonly versionNotes?: string | null;
};
export const ServerNotification__AppMetadata = Schema.Struct({
  categories: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  developer: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  firstPartyRequiresInstall: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  firstPartyType: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  review: Schema.optionalKey(Schema.Union([ServerNotification__AppReview, Schema.Null])),
  screenshots: Schema.optionalKey(
    Schema.Union([Schema.Array(ServerNotification__AppScreenshot), Schema.Null]),
  ),
  seoDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  showInComposerWhenUnlinked: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  subCategories: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  version: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  versionId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  versionNotes: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ServerNotification__CollabAgentState = {
  readonly message?: string | null;
  readonly status: ServerNotification__CollabAgentStatus;
};
export const ServerNotification__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: ServerNotification__CollabAgentStatus,
});

export type ServerNotification__FileSystemPath =
  | { readonly path: ServerNotification__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | { readonly type: "special"; readonly value: ServerNotification__FileSystemSpecialPath };
export const ServerNotification__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: ServerNotification__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: ServerNotification__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__FuzzyFileSearchResult = {
  readonly file_name: string;
  readonly indices?: ReadonlyArray<number> | null;
  readonly match_type: ServerNotification__FuzzyFileSearchMatchType;
  readonly path: string;
  readonly root: string;
  readonly score: number;
};
export const ServerNotification__FuzzyFileSearchResult = Schema.Struct({
  file_name: Schema.String,
  indices: Schema.optionalKey(
    Schema.Union([
      Schema.Array(
        Schema.Number.annotate({ format: "uint32" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
      ),
      Schema.Null,
    ]),
  ),
  match_type: ServerNotification__FuzzyFileSearchMatchType,
  path: Schema.String,
  root: Schema.String,
  score: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
}).annotate({ description: "Superset of [`codex_file_search::FileMatch`]" });

export type ServerNotification__GuardianApprovalReview = {
  readonly rationale?: string | null;
  readonly riskLevel?: ServerNotification__GuardianRiskLevel | null;
  readonly status: ServerNotification__GuardianApprovalReviewStatus;
  readonly userAuthorization?: ServerNotification__GuardianUserAuthorization | null;
};
export const ServerNotification__GuardianApprovalReview = Schema.Struct({
  rationale: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  riskLevel: Schema.optionalKey(Schema.Union([ServerNotification__GuardianRiskLevel, Schema.Null])),
  status: ServerNotification__GuardianApprovalReviewStatus,
  userAuthorization: Schema.optionalKey(
    Schema.Union([ServerNotification__GuardianUserAuthorization, Schema.Null]),
  ),
}).annotate({
  description:
    "[UNSTABLE] Temporary approval auto-review payload used by `item/autoApprovalReview/*` notifications. This shape is expected to change soon.",
});

export type ServerNotification__HookOutputEntry = {
  readonly kind: ServerNotification__HookOutputEntryKind;
  readonly text: string;
};
export const ServerNotification__HookOutputEntry = Schema.Struct({
  kind: ServerNotification__HookOutputEntryKind,
  text: Schema.String,
});

export type ServerNotification__McpServerStatusUpdatedNotification = {
  readonly error?: string | null;
  readonly name: string;
  readonly status: ServerNotification__McpServerStartupState;
};
export const ServerNotification__McpServerStatusUpdatedNotification = Schema.Struct({
  error: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  status: ServerNotification__McpServerStartupState,
});

export type ServerNotification__MemoryCitation = {
  readonly entries: ReadonlyArray<ServerNotification__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const ServerNotification__MemoryCitation = Schema.Struct({
  entries: Schema.Array(ServerNotification__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type ServerNotification__ModelReroutedNotification = {
  readonly fromModel: string;
  readonly reason: ServerNotification__ModelRerouteReason;
  readonly threadId: string;
  readonly toModel: string;
  readonly turnId: string;
};
export const ServerNotification__ModelReroutedNotification = Schema.Struct({
  fromModel: Schema.String,
  reason: ServerNotification__ModelRerouteReason,
  threadId: Schema.String,
  toModel: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__ModelVerificationNotification = {
  readonly threadId: string;
  readonly turnId: string;
  readonly verifications: ReadonlyArray<ServerNotification__ModelVerification>;
};
export const ServerNotification__ModelVerificationNotification = Schema.Struct({
  threadId: Schema.String,
  turnId: Schema.String,
  verifications: Schema.Array(ServerNotification__ModelVerification),
});

export type ServerNotification__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: ServerNotification__NonSteerableTurnKind;
      };
    };
export const ServerNotification__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({ turnKind: ServerNotification__NonSteerableTurnKind }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type ServerNotification__FileUpdateChange = {
  readonly diff: string;
  readonly kind: ServerNotification__PatchChangeKind;
  readonly path: string;
};
export const ServerNotification__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: ServerNotification__PatchChangeKind,
  path: Schema.String,
});

export type ServerNotification__AccountUpdatedNotification = {
  readonly authMode?: ServerNotification__AuthMode | null;
  readonly planType?: ServerNotification__PlanType | null;
};
export const ServerNotification__AccountUpdatedNotification = Schema.Struct({
  authMode: Schema.optionalKey(Schema.Union([ServerNotification__AuthMode, Schema.Null])),
  planType: Schema.optionalKey(Schema.Union([ServerNotification__PlanType, Schema.Null])),
});

export type ServerNotification__RateLimitSnapshot = {
  readonly credits?: ServerNotification__CreditsSnapshot | null;
  readonly limitId?: string | null;
  readonly limitName?: string | null;
  readonly planType?: ServerNotification__PlanType | null;
  readonly primary?: ServerNotification__RateLimitWindow | null;
  readonly rateLimitReachedType?: ServerNotification__RateLimitReachedType | null;
  readonly secondary?: ServerNotification__RateLimitWindow | null;
};
export const ServerNotification__RateLimitSnapshot = Schema.Struct({
  credits: Schema.optionalKey(Schema.Union([ServerNotification__CreditsSnapshot, Schema.Null])),
  limitId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  limitName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  planType: Schema.optionalKey(Schema.Union([ServerNotification__PlanType, Schema.Null])),
  primary: Schema.optionalKey(Schema.Union([ServerNotification__RateLimitWindow, Schema.Null])),
  rateLimitReachedType: Schema.optionalKey(
    Schema.Union([ServerNotification__RateLimitReachedType, Schema.Null]),
  ),
  secondary: Schema.optionalKey(Schema.Union([ServerNotification__RateLimitWindow, Schema.Null])),
});

export type ServerNotification__ThreadRealtimeStartedNotification = {
  readonly realtimeSessionId?: string | null;
  readonly threadId: string;
  readonly version: ServerNotification__RealtimeConversationVersion;
};
export const ServerNotification__ThreadRealtimeStartedNotification = Schema.Struct({
  realtimeSessionId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
  version: ServerNotification__RealtimeConversationVersion,
}).annotate({ description: "EXPERIMENTAL - emitted when thread realtime startup is accepted." });

export type ServerNotification__RemoteControlStatusChangedNotification = {
  readonly environmentId?: string | null;
  readonly status: ServerNotification__RemoteControlConnectionStatus;
};
export const ServerNotification__RemoteControlStatusChangedNotification = Schema.Struct({
  environmentId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: ServerNotification__RemoteControlConnectionStatus,
}).annotate({
  description: "Current remote-control connection status and environment id exposed to clients.",
});

export type ServerNotification__ServerRequestResolvedNotification = {
  readonly requestId: ServerNotification__RequestId;
  readonly threadId: string;
};
export const ServerNotification__ServerRequestResolvedNotification = Schema.Struct({
  requestId: ServerNotification__RequestId,
  threadId: Schema.String,
});

export type ServerNotification__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<ServerNotification__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const ServerNotification__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(ServerNotification__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__TextRange = {
  readonly end: ServerNotification__TextPosition;
  readonly start: ServerNotification__TextPosition;
};
export const ServerNotification__TextRange = Schema.Struct({
  end: ServerNotification__TextPosition,
  start: ServerNotification__TextPosition,
});

export type ServerNotification__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<ServerNotification__ThreadActiveFlag>;
      readonly type: "active";
    };
export const ServerNotification__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(ServerNotification__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__ThreadGoal = {
  readonly createdAt: number;
  readonly objective: string;
  readonly status: ServerNotification__ThreadGoalStatus;
  readonly threadId: string;
  readonly timeUsedSeconds: number;
  readonly tokenBudget?: number | null;
  readonly tokensUsed: number;
  readonly updatedAt: number;
};
export const ServerNotification__ThreadGoal = Schema.Struct({
  createdAt: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  objective: Schema.String,
  status: ServerNotification__ThreadGoalStatus,
  threadId: Schema.String,
  timeUsedSeconds: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  tokenBudget: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  tokensUsed: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  updatedAt: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
});

export type ServerNotification__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: ServerNotification__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: ServerNotification__ThreadId;
      };
    }
  | { readonly other: string };
export const ServerNotification__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(Schema.Union([ServerNotification__AgentPath, Schema.Null])),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: ServerNotification__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__ThreadRealtimeOutputAudioDeltaNotification = {
  readonly audio: ServerNotification__ThreadRealtimeAudioChunk;
  readonly threadId: string;
};
export const ServerNotification__ThreadRealtimeOutputAudioDeltaNotification = Schema.Struct({
  audio: ServerNotification__ThreadRealtimeAudioChunk,
  threadId: Schema.String,
}).annotate({ description: "EXPERIMENTAL - streamed output audio emitted by thread realtime." });

export type ServerNotification__ThreadTokenUsage = {
  readonly last: ServerNotification__TokenUsageBreakdown;
  readonly modelContextWindow?: number | null;
  readonly total: ServerNotification__TokenUsageBreakdown;
};
export const ServerNotification__ThreadTokenUsage = Schema.Struct({
  last: ServerNotification__TokenUsageBreakdown,
  modelContextWindow: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  total: ServerNotification__TokenUsageBreakdown,
});

export type ServerNotification__TurnPlanStep = {
  readonly status: ServerNotification__TurnPlanStepStatus;
  readonly step: string;
};
export const ServerNotification__TurnPlanStep = Schema.Struct({
  status: ServerNotification__TurnPlanStepStatus,
  step: Schema.String,
});

export type ServerNotification__WindowsSandboxSetupCompletedNotification = {
  readonly error?: string | null;
  readonly mode: ServerNotification__WindowsSandboxSetupMode;
  readonly success: boolean;
};
export const ServerNotification__WindowsSandboxSetupCompletedNotification = Schema.Struct({
  error: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  mode: ServerNotification__WindowsSandboxSetupMode,
  success: Schema.Boolean,
});

export type ServerRequest__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: ServerRequest__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const ServerRequest__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: ServerRequest__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type ServerRequest__ChatgptAuthTokensRefreshParams = {
  readonly previousAccountId?: string | null;
  readonly reason: ServerRequest__ChatgptAuthTokensRefreshReason;
};
export const ServerRequest__ChatgptAuthTokensRefreshParams = Schema.Struct({
  previousAccountId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Workspace/account identifier that Codex was previously using.\n\nClients that manage multiple accounts/workspaces can use this as a hint to refresh the token for the correct workspace.\n\nThis may be `null` when the prior auth state did not include a workspace identifier (`chatgpt_account_id`).",
      }),
      Schema.Null,
    ]),
  ),
  reason: ServerRequest__ChatgptAuthTokensRefreshReason,
});

export type ServerRequest__FileSystemPath =
  | { readonly path: ServerRequest__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | { readonly type: "special"; readonly value: ServerRequest__FileSystemSpecialPath };
export const ServerRequest__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: ServerRequest__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: ServerRequest__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type ServerRequest__McpElicitationBooleanSchema = {
  readonly default?: boolean | null;
  readonly description?: string | null;
  readonly title?: string | null;
  readonly type: ServerRequest__McpElicitationBooleanType;
};
export const ServerRequest__McpElicitationBooleanSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: ServerRequest__McpElicitationBooleanType,
});

export type ServerRequest__McpElicitationTitledEnumItems = {
  readonly anyOf: ReadonlyArray<ServerRequest__McpElicitationConstOption>;
};
export const ServerRequest__McpElicitationTitledEnumItems = Schema.Struct({
  anyOf: Schema.Array(ServerRequest__McpElicitationConstOption),
});

export type ServerRequest__McpElicitationNumberSchema = {
  readonly default?: number | null;
  readonly description?: string | null;
  readonly maximum?: number | null;
  readonly minimum?: number | null;
  readonly title?: string | null;
  readonly type: ServerRequest__McpElicitationNumberType;
};
export const ServerRequest__McpElicitationNumberSchema = Schema.Struct({
  default: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "double" }).check(Schema.isFinite()),
      Schema.Null,
    ]),
  ),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  maximum: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "double" }).check(Schema.isFinite()),
      Schema.Null,
    ]),
  ),
  minimum: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "double" }).check(Schema.isFinite()),
      Schema.Null,
    ]),
  ),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: ServerRequest__McpElicitationNumberType,
});

export type ServerRequest__McpElicitationLegacyTitledEnumSchema = {
  readonly default?: string | null;
  readonly description?: string | null;
  readonly enum: ReadonlyArray<string>;
  readonly enumNames?: ReadonlyArray<string> | null;
  readonly title?: string | null;
  readonly type: ServerRequest__McpElicitationStringType;
};
export const ServerRequest__McpElicitationLegacyTitledEnumSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  enum: Schema.Array(Schema.String),
  enumNames: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: ServerRequest__McpElicitationStringType,
});

export type ServerRequest__McpElicitationStringSchema = {
  readonly default?: string | null;
  readonly description?: string | null;
  readonly format?: ServerRequest__McpElicitationStringFormat | null;
  readonly maxLength?: number | null;
  readonly minLength?: number | null;
  readonly title?: string | null;
  readonly type: ServerRequest__McpElicitationStringType;
};
export const ServerRequest__McpElicitationStringSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  format: Schema.optionalKey(
    Schema.Union([ServerRequest__McpElicitationStringFormat, Schema.Null]),
  ),
  maxLength: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint32" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  minLength: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint32" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: ServerRequest__McpElicitationStringType,
});

export type ServerRequest__McpElicitationTitledSingleSelectEnumSchema = {
  readonly default?: string | null;
  readonly description?: string | null;
  readonly oneOf: ReadonlyArray<ServerRequest__McpElicitationConstOption>;
  readonly title?: string | null;
  readonly type: ServerRequest__McpElicitationStringType;
};
export const ServerRequest__McpElicitationTitledSingleSelectEnumSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  oneOf: Schema.Array(ServerRequest__McpElicitationConstOption),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: ServerRequest__McpElicitationStringType,
});

export type ServerRequest__McpElicitationUntitledEnumItems = {
  readonly enum: ReadonlyArray<string>;
  readonly type: ServerRequest__McpElicitationStringType;
};
export const ServerRequest__McpElicitationUntitledEnumItems = Schema.Struct({
  enum: Schema.Array(Schema.String),
  type: ServerRequest__McpElicitationStringType,
});

export type ServerRequest__McpElicitationUntitledSingleSelectEnumSchema = {
  readonly default?: string | null;
  readonly description?: string | null;
  readonly enum: ReadonlyArray<string>;
  readonly title?: string | null;
  readonly type: ServerRequest__McpElicitationStringType;
};
export const ServerRequest__McpElicitationUntitledSingleSelectEnumSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  enum: Schema.Array(Schema.String),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: ServerRequest__McpElicitationStringType,
});

export type ServerRequest__NetworkApprovalContext = {
  readonly host: string;
  readonly protocol: ServerRequest__NetworkApprovalProtocol;
};
export const ServerRequest__NetworkApprovalContext = Schema.Struct({
  host: Schema.String,
  protocol: ServerRequest__NetworkApprovalProtocol,
});

export type ServerRequest__NetworkPolicyAmendment = {
  readonly action: ServerRequest__NetworkPolicyRuleAction;
  readonly host: string;
};
export const ServerRequest__NetworkPolicyAmendment = Schema.Struct({
  action: ServerRequest__NetworkPolicyRuleAction,
  host: Schema.String,
});

export type ServerRequest__ApplyPatchApprovalParams = {
  readonly callId: string;
  readonly conversationId: ServerRequest__ThreadId;
  readonly fileChanges: { readonly [x: string]: ServerRequest__FileChange };
  readonly grantRoot?: string | null;
  readonly reason?: string | null;
};
export const ServerRequest__ApplyPatchApprovalParams = Schema.Struct({
  callId: Schema.String.annotate({
    description:
      "Use to correlate this with [codex_protocol::protocol::PatchApplyBeginEvent] and [codex_protocol::protocol::PatchApplyEndEvent].",
  }),
  conversationId: ServerRequest__ThreadId,
  fileChanges: Schema.Record(Schema.String, ServerRequest__FileChange),
  grantRoot: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "When set, the agent is asking the user to allow writes under this root for the remainder of the session (unclear if this is honored today).",
      }),
      Schema.Null,
    ]),
  ),
  reason: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional explanatory reason (e.g. request for extra write access).",
      }),
      Schema.Null,
    ]),
  ),
});

export type ServerRequest__ExecCommandApprovalParams = {
  readonly approvalId?: string | null;
  readonly callId: string;
  readonly command: ReadonlyArray<string>;
  readonly conversationId: ServerRequest__ThreadId;
  readonly cwd: string;
  readonly parsedCmd: ReadonlyArray<ServerRequest__ParsedCommand>;
  readonly reason?: string | null;
};
export const ServerRequest__ExecCommandApprovalParams = Schema.Struct({
  approvalId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Identifier for this specific approval callback." }),
      Schema.Null,
    ]),
  ),
  callId: Schema.String.annotate({
    description:
      "Use to correlate this with [codex_protocol::protocol::ExecCommandBeginEvent] and [codex_protocol::protocol::ExecCommandEndEvent].",
  }),
  command: Schema.Array(Schema.String),
  conversationId: ServerRequest__ThreadId,
  cwd: Schema.String,
  parsedCmd: Schema.Array(ServerRequest__ParsedCommand),
  reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ServerRequest__ToolRequestUserInputQuestion = {
  readonly header: string;
  readonly id: string;
  readonly isOther?: boolean;
  readonly isSecret?: boolean;
  readonly options?: ReadonlyArray<ServerRequest__ToolRequestUserInputOption> | null;
  readonly question: string;
};
export const ServerRequest__ToolRequestUserInputQuestion = Schema.Struct({
  header: Schema.String,
  id: Schema.String,
  isOther: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  isSecret: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  options: Schema.optionalKey(
    Schema.Union([Schema.Array(ServerRequest__ToolRequestUserInputOption), Schema.Null]),
  ),
  question: Schema.String,
}).annotate({
  description: "EXPERIMENTAL. Represents one request_user_input question and its required options.",
});

export type ToolRequestUserInputParams__ToolRequestUserInputQuestion = {
  readonly header: string;
  readonly id: string;
  readonly isOther?: boolean;
  readonly isSecret?: boolean;
  readonly options?: ReadonlyArray<ToolRequestUserInputParams__ToolRequestUserInputOption> | null;
  readonly question: string;
};
export const ToolRequestUserInputParams__ToolRequestUserInputQuestion = Schema.Struct({
  header: Schema.String,
  id: Schema.String,
  isOther: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  isSecret: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  options: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ToolRequestUserInputParams__ToolRequestUserInputOption),
      Schema.Null,
    ]),
  ),
  question: Schema.String,
}).annotate({
  description: "EXPERIMENTAL. Represents one request_user_input question and its required options.",
});

export type V2AccountRateLimitsUpdatedNotification__RateLimitSnapshot = {
  readonly credits?: V2AccountRateLimitsUpdatedNotification__CreditsSnapshot | null;
  readonly limitId?: string | null;
  readonly limitName?: string | null;
  readonly planType?: V2AccountRateLimitsUpdatedNotification__PlanType | null;
  readonly primary?: V2AccountRateLimitsUpdatedNotification__RateLimitWindow | null;
  readonly rateLimitReachedType?: V2AccountRateLimitsUpdatedNotification__RateLimitReachedType | null;
  readonly secondary?: V2AccountRateLimitsUpdatedNotification__RateLimitWindow | null;
};
export const V2AccountRateLimitsUpdatedNotification__RateLimitSnapshot = Schema.Struct({
  credits: Schema.optionalKey(
    Schema.Union([V2AccountRateLimitsUpdatedNotification__CreditsSnapshot, Schema.Null]),
  ),
  limitId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  limitName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  planType: Schema.optionalKey(
    Schema.Union([V2AccountRateLimitsUpdatedNotification__PlanType, Schema.Null]),
  ),
  primary: Schema.optionalKey(
    Schema.Union([V2AccountRateLimitsUpdatedNotification__RateLimitWindow, Schema.Null]),
  ),
  rateLimitReachedType: Schema.optionalKey(
    Schema.Union([V2AccountRateLimitsUpdatedNotification__RateLimitReachedType, Schema.Null]),
  ),
  secondary: Schema.optionalKey(
    Schema.Union([V2AccountRateLimitsUpdatedNotification__RateLimitWindow, Schema.Null]),
  ),
});

export type V2AppListUpdatedNotification__AppMetadata = {
  readonly categories?: ReadonlyArray<string> | null;
  readonly developer?: string | null;
  readonly firstPartyRequiresInstall?: boolean | null;
  readonly firstPartyType?: string | null;
  readonly review?: V2AppListUpdatedNotification__AppReview | null;
  readonly screenshots?: ReadonlyArray<V2AppListUpdatedNotification__AppScreenshot> | null;
  readonly seoDescription?: string | null;
  readonly showInComposerWhenUnlinked?: boolean | null;
  readonly subCategories?: ReadonlyArray<string> | null;
  readonly version?: string | null;
  readonly versionId?: string | null;
  readonly versionNotes?: string | null;
};
export const V2AppListUpdatedNotification__AppMetadata = Schema.Struct({
  categories: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  developer: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  firstPartyRequiresInstall: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  firstPartyType: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  review: Schema.optionalKey(Schema.Union([V2AppListUpdatedNotification__AppReview, Schema.Null])),
  screenshots: Schema.optionalKey(
    Schema.Union([Schema.Array(V2AppListUpdatedNotification__AppScreenshot), Schema.Null]),
  ),
  seoDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  showInComposerWhenUnlinked: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  subCategories: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  version: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  versionId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  versionNotes: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2AppsListResponse__AppMetadata = {
  readonly categories?: ReadonlyArray<string> | null;
  readonly developer?: string | null;
  readonly firstPartyRequiresInstall?: boolean | null;
  readonly firstPartyType?: string | null;
  readonly review?: V2AppsListResponse__AppReview | null;
  readonly screenshots?: ReadonlyArray<V2AppsListResponse__AppScreenshot> | null;
  readonly seoDescription?: string | null;
  readonly showInComposerWhenUnlinked?: boolean | null;
  readonly subCategories?: ReadonlyArray<string> | null;
  readonly version?: string | null;
  readonly versionId?: string | null;
  readonly versionNotes?: string | null;
};
export const V2AppsListResponse__AppMetadata = Schema.Struct({
  categories: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  developer: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  firstPartyRequiresInstall: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  firstPartyType: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  review: Schema.optionalKey(Schema.Union([V2AppsListResponse__AppReview, Schema.Null])),
  screenshots: Schema.optionalKey(
    Schema.Union([Schema.Array(V2AppsListResponse__AppScreenshot), Schema.Null]),
  ),
  seoDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  showInComposerWhenUnlinked: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  subCategories: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  version: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  versionId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  versionNotes: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2CommandExecParams__SandboxPolicy =
  | { readonly type: "dangerFullAccess" }
  | { readonly networkAccess?: boolean; readonly type: "readOnly" }
  | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
  | {
      readonly excludeSlashTmp?: boolean;
      readonly excludeTmpdirEnvVar?: boolean;
      readonly networkAccess?: boolean;
      readonly type: "workspaceWrite";
      readonly writableRoots?: ReadonlyArray<V2CommandExecParams__AbsolutePathBuf>;
    };
export const V2CommandExecParams__SandboxPolicy = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("dangerFullAccess").annotate({
        title: "DangerFullAccessSandboxPolicyType",
      }),
    }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
    }).annotate({ title: "ReadOnlySandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(
        Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
      ),
      type: Schema.Literal("externalSandbox").annotate({
        title: "ExternalSandboxSandboxPolicyType",
      }),
    }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
    Schema.Struct({
      excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("workspaceWrite").annotate({ title: "WorkspaceWriteSandboxPolicyType" }),
      writableRoots: Schema.optionalKey(
        Schema.Array(V2CommandExecParams__AbsolutePathBuf).annotate({ default: [] }),
      ),
    }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
  ],
  { mode: "oneOf" },
);

export type V2CommandExecParams__FileSystemPath =
  | { readonly path: V2CommandExecParams__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | { readonly type: "special"; readonly value: V2CommandExecParams__FileSystemSpecialPath };
export const V2CommandExecParams__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: V2CommandExecParams__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: V2CommandExecParams__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type V2ConfigBatchWriteParams__ConfigEdit = {
  readonly keyPath: string;
  readonly mergeStrategy: V2ConfigBatchWriteParams__MergeStrategy;
  readonly value: unknown;
};
export const V2ConfigBatchWriteParams__ConfigEdit = Schema.Struct({
  keyPath: Schema.String,
  mergeStrategy: V2ConfigBatchWriteParams__MergeStrategy,
  value: Schema.Unknown,
});

export type V2ConfigReadResponse__ConfigLayerSource =
  | { readonly domain: string; readonly key: string; readonly type: "mdm" }
  | { readonly file: string; readonly type: "system" }
  | { readonly file: string; readonly type: "user" }
  | { readonly dotCodexFolder: V2ConfigReadResponse__AbsolutePathBuf; readonly type: "project" }
  | { readonly type: "sessionFlags" }
  | {
      readonly file: V2ConfigReadResponse__AbsolutePathBuf;
      readonly type: "legacyManagedConfigTomlFromFile";
    }
  | { readonly type: "legacyManagedConfigTomlFromMdm" };
export const V2ConfigReadResponse__ConfigLayerSource = Schema.Union(
  [
    Schema.Struct({
      domain: Schema.String,
      key: Schema.String,
      type: Schema.Literal("mdm").annotate({ title: "MdmConfigLayerSourceType" }),
    }).annotate({
      title: "MdmConfigLayerSource",
      description: "Managed preferences layer delivered by MDM (macOS only).",
    }),
    Schema.Struct({
      file: Schema.String.annotate({
        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.",
      }),
      type: Schema.Literal("system").annotate({ title: "SystemConfigLayerSourceType" }),
    }).annotate({
      title: "SystemConfigLayerSource",
      description: "Managed config layer from a file (usually `managed_config.toml`).",
    }),
    Schema.Struct({
      file: Schema.String.annotate({
        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.",
      }),
      type: Schema.Literal("user").annotate({ title: "UserConfigLayerSourceType" }),
    }).annotate({
      title: "UserConfigLayerSource",
      description:
        "User config layer from $CODEX_HOME/config.toml. This layer is special in that it is expected to be: - writable by the user - generally outside the workspace directory",
    }),
    Schema.Struct({
      dotCodexFolder: V2ConfigReadResponse__AbsolutePathBuf,
      type: Schema.Literal("project").annotate({ title: "ProjectConfigLayerSourceType" }),
    }).annotate({
      title: "ProjectConfigLayerSource",
      description:
        "Path to a .codex/ folder within a project. There could be multiple of these between `cwd` and the project/repo root.",
    }),
    Schema.Struct({
      type: Schema.Literal("sessionFlags").annotate({ title: "SessionFlagsConfigLayerSourceType" }),
    }).annotate({
      title: "SessionFlagsConfigLayerSource",
      description: "Session-layer overrides supplied via `-c`/`--config`.",
    }),
    Schema.Struct({
      file: V2ConfigReadResponse__AbsolutePathBuf,
      type: Schema.Literal("legacyManagedConfigTomlFromFile").annotate({
        title: "LegacyManagedConfigTomlFromFileConfigLayerSourceType",
      }),
    }).annotate({
      title: "LegacyManagedConfigTomlFromFileConfigLayerSource",
      description:
        '`managed_config.toml` was designed to be a config that was loaded as the last layer on top of everything else. This scheme did not quite work out as intended, but we keep this variant as a "best effort" while we phase out `managed_config.toml` in favor of `requirements.toml`.',
    }),
    Schema.Struct({
      type: Schema.Literal("legacyManagedConfigTomlFromMdm").annotate({
        title: "LegacyManagedConfigTomlFromMdmConfigLayerSourceType",
      }),
    }).annotate({ title: "LegacyManagedConfigTomlFromMdmConfigLayerSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ConfigReadResponse__WebSearchToolConfig = {
  readonly allowed_domains?: ReadonlyArray<string> | null;
  readonly context_size?: V2ConfigReadResponse__WebSearchContextSize | null;
  readonly location?: V2ConfigReadResponse__WebSearchLocation | null;
};
export const V2ConfigReadResponse__WebSearchToolConfig = Schema.Struct({
  allowed_domains: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  context_size: Schema.optionalKey(
    Schema.Union([V2ConfigReadResponse__WebSearchContextSize, Schema.Null]),
  ),
  location: Schema.optionalKey(
    Schema.Union([V2ConfigReadResponse__WebSearchLocation, Schema.Null]),
  ),
});

export type V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup = {
  readonly hooks: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookHandler>;
  readonly matcher?: string | null;
};
export const V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup = Schema.Struct({
  hooks: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookHandler),
  matcher: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ConfigRequirementsReadResponse__ConfigRequirements = {
  readonly allowedApprovalPolicies?: ReadonlyArray<V2ConfigRequirementsReadResponse__AskForApproval> | null;
  readonly allowedSandboxModes?: ReadonlyArray<V2ConfigRequirementsReadResponse__SandboxMode> | null;
  readonly allowedWebSearchModes?: ReadonlyArray<V2ConfigRequirementsReadResponse__WebSearchMode> | null;
  readonly enforceResidency?: V2ConfigRequirementsReadResponse__ResidencyRequirement | null;
  readonly featureRequirements?: { readonly [x: string]: boolean } | null;
};
export const V2ConfigRequirementsReadResponse__ConfigRequirements = Schema.Struct({
  allowedApprovalPolicies: Schema.optionalKey(
    Schema.Union([Schema.Array(V2ConfigRequirementsReadResponse__AskForApproval), Schema.Null]),
  ),
  allowedSandboxModes: Schema.optionalKey(
    Schema.Union([Schema.Array(V2ConfigRequirementsReadResponse__SandboxMode), Schema.Null]),
  ),
  allowedWebSearchModes: Schema.optionalKey(
    Schema.Union([Schema.Array(V2ConfigRequirementsReadResponse__WebSearchMode), Schema.Null]),
  ),
  enforceResidency: Schema.optionalKey(
    Schema.Union([V2ConfigRequirementsReadResponse__ResidencyRequirement, Schema.Null]),
  ),
  featureRequirements: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.Boolean), Schema.Null]),
  ),
});

export type V2ConfigWarningNotification__TextRange = {
  readonly end: V2ConfigWarningNotification__TextPosition;
  readonly start: V2ConfigWarningNotification__TextPosition;
};
export const V2ConfigWarningNotification__TextRange = Schema.Struct({
  end: V2ConfigWarningNotification__TextPosition,
  start: V2ConfigWarningNotification__TextPosition,
});

export type V2ConfigWriteResponse__ConfigLayerSource =
  | { readonly domain: string; readonly key: string; readonly type: "mdm" }
  | { readonly file: string; readonly type: "system" }
  | { readonly file: string; readonly type: "user" }
  | { readonly dotCodexFolder: V2ConfigWriteResponse__AbsolutePathBuf; readonly type: "project" }
  | { readonly type: "sessionFlags" }
  | {
      readonly file: V2ConfigWriteResponse__AbsolutePathBuf;
      readonly type: "legacyManagedConfigTomlFromFile";
    }
  | { readonly type: "legacyManagedConfigTomlFromMdm" };
export const V2ConfigWriteResponse__ConfigLayerSource = Schema.Union(
  [
    Schema.Struct({
      domain: Schema.String,
      key: Schema.String,
      type: Schema.Literal("mdm").annotate({ title: "MdmConfigLayerSourceType" }),
    }).annotate({
      title: "MdmConfigLayerSource",
      description: "Managed preferences layer delivered by MDM (macOS only).",
    }),
    Schema.Struct({
      file: Schema.String.annotate({
        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.",
      }),
      type: Schema.Literal("system").annotate({ title: "SystemConfigLayerSourceType" }),
    }).annotate({
      title: "SystemConfigLayerSource",
      description: "Managed config layer from a file (usually `managed_config.toml`).",
    }),
    Schema.Struct({
      file: Schema.String.annotate({
        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.",
      }),
      type: Schema.Literal("user").annotate({ title: "UserConfigLayerSourceType" }),
    }).annotate({
      title: "UserConfigLayerSource",
      description:
        "User config layer from $CODEX_HOME/config.toml. This layer is special in that it is expected to be: - writable by the user - generally outside the workspace directory",
    }),
    Schema.Struct({
      dotCodexFolder: V2ConfigWriteResponse__AbsolutePathBuf,
      type: Schema.Literal("project").annotate({ title: "ProjectConfigLayerSourceType" }),
    }).annotate({
      title: "ProjectConfigLayerSource",
      description:
        "Path to a .codex/ folder within a project. There could be multiple of these between `cwd` and the project/repo root.",
    }),
    Schema.Struct({
      type: Schema.Literal("sessionFlags").annotate({ title: "SessionFlagsConfigLayerSourceType" }),
    }).annotate({
      title: "SessionFlagsConfigLayerSource",
      description: "Session-layer overrides supplied via `-c`/`--config`.",
    }),
    Schema.Struct({
      file: V2ConfigWriteResponse__AbsolutePathBuf,
      type: Schema.Literal("legacyManagedConfigTomlFromFile").annotate({
        title: "LegacyManagedConfigTomlFromFileConfigLayerSourceType",
      }),
    }).annotate({
      title: "LegacyManagedConfigTomlFromFileConfigLayerSource",
      description:
        '`managed_config.toml` was designed to be a config that was loaded as the last layer on top of everything else. This scheme did not quite work out as intended, but we keep this variant as a "best effort" while we phase out `managed_config.toml` in favor of `requirements.toml`.',
    }),
    Schema.Struct({
      type: Schema.Literal("legacyManagedConfigTomlFromMdm").annotate({
        title: "LegacyManagedConfigTomlFromMdmConfigLayerSourceType",
      }),
    }).annotate({ title: "LegacyManagedConfigTomlFromMdmConfigLayerSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ErrorNotification__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ErrorNotification__NonSteerableTurnKind;
      };
    };
export const V2ErrorNotification__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ErrorNotification__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ExternalAgentConfigDetectResponse__MigrationDetails = {
  readonly commands?: ReadonlyArray<V2ExternalAgentConfigDetectResponse__CommandMigration>;
  readonly hooks?: ReadonlyArray<V2ExternalAgentConfigDetectResponse__HookMigration>;
  readonly mcpServers?: ReadonlyArray<V2ExternalAgentConfigDetectResponse__McpServerMigration>;
  readonly plugins?: ReadonlyArray<V2ExternalAgentConfigDetectResponse__PluginsMigration>;
  readonly sessions?: ReadonlyArray<V2ExternalAgentConfigDetectResponse__SessionMigration>;
  readonly subagents?: ReadonlyArray<V2ExternalAgentConfigDetectResponse__SubagentMigration>;
};
export const V2ExternalAgentConfigDetectResponse__MigrationDetails = Schema.Struct({
  commands: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigDetectResponse__CommandMigration).annotate({ default: [] }),
  ),
  hooks: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigDetectResponse__HookMigration).annotate({ default: [] }),
  ),
  mcpServers: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigDetectResponse__McpServerMigration).annotate({ default: [] }),
  ),
  plugins: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigDetectResponse__PluginsMigration).annotate({ default: [] }),
  ),
  sessions: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigDetectResponse__SessionMigration).annotate({ default: [] }),
  ),
  subagents: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigDetectResponse__SubagentMigration).annotate({ default: [] }),
  ),
});

export type V2ExternalAgentConfigImportParams__MigrationDetails = {
  readonly commands?: ReadonlyArray<V2ExternalAgentConfigImportParams__CommandMigration>;
  readonly hooks?: ReadonlyArray<V2ExternalAgentConfigImportParams__HookMigration>;
  readonly mcpServers?: ReadonlyArray<V2ExternalAgentConfigImportParams__McpServerMigration>;
  readonly plugins?: ReadonlyArray<V2ExternalAgentConfigImportParams__PluginsMigration>;
  readonly sessions?: ReadonlyArray<V2ExternalAgentConfigImportParams__SessionMigration>;
  readonly subagents?: ReadonlyArray<V2ExternalAgentConfigImportParams__SubagentMigration>;
};
export const V2ExternalAgentConfigImportParams__MigrationDetails = Schema.Struct({
  commands: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigImportParams__CommandMigration).annotate({ default: [] }),
  ),
  hooks: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigImportParams__HookMigration).annotate({ default: [] }),
  ),
  mcpServers: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigImportParams__McpServerMigration).annotate({ default: [] }),
  ),
  plugins: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigImportParams__PluginsMigration).annotate({ default: [] }),
  ),
  sessions: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigImportParams__SessionMigration).annotate({ default: [] }),
  ),
  subagents: Schema.optionalKey(
    Schema.Array(V2ExternalAgentConfigImportParams__SubagentMigration).annotate({ default: [] }),
  ),
});

export type V2FileChangePatchUpdatedNotification__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2FileChangePatchUpdatedNotification__PatchChangeKind;
  readonly path: string;
};
export const V2FileChangePatchUpdatedNotification__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2FileChangePatchUpdatedNotification__PatchChangeKind,
  path: Schema.String,
});

export type V2GetAccountRateLimitsResponse__RateLimitSnapshot = {
  readonly credits?: V2GetAccountRateLimitsResponse__CreditsSnapshot | null;
  readonly limitId?: string | null;
  readonly limitName?: string | null;
  readonly planType?: V2GetAccountRateLimitsResponse__PlanType | null;
  readonly primary?: V2GetAccountRateLimitsResponse__RateLimitWindow | null;
  readonly rateLimitReachedType?: V2GetAccountRateLimitsResponse__RateLimitReachedType | null;
  readonly secondary?: V2GetAccountRateLimitsResponse__RateLimitWindow | null;
};
export const V2GetAccountRateLimitsResponse__RateLimitSnapshot = Schema.Struct({
  credits: Schema.optionalKey(
    Schema.Union([V2GetAccountRateLimitsResponse__CreditsSnapshot, Schema.Null]),
  ),
  limitId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  limitName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  planType: Schema.optionalKey(
    Schema.Union([V2GetAccountRateLimitsResponse__PlanType, Schema.Null]),
  ),
  primary: Schema.optionalKey(
    Schema.Union([V2GetAccountRateLimitsResponse__RateLimitWindow, Schema.Null]),
  ),
  rateLimitReachedType: Schema.optionalKey(
    Schema.Union([V2GetAccountRateLimitsResponse__RateLimitReachedType, Schema.Null]),
  ),
  secondary: Schema.optionalKey(
    Schema.Union([V2GetAccountRateLimitsResponse__RateLimitWindow, Schema.Null]),
  ),
});

export type V2GetAccountResponse__Account =
  | { readonly type: "apiKey" }
  | {
      readonly email: string;
      readonly planType: V2GetAccountResponse__PlanType;
      readonly type: "chatgpt";
    }
  | { readonly type: "amazonBedrock" };
export const V2GetAccountResponse__Account = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("apiKey").annotate({ title: "ApiKeyAccountType" }),
    }).annotate({ title: "ApiKeyAccount" }),
    Schema.Struct({
      email: Schema.String,
      planType: V2GetAccountResponse__PlanType,
      type: Schema.Literal("chatgpt").annotate({ title: "ChatgptAccountType" }),
    }).annotate({ title: "ChatgptAccount" }),
    Schema.Struct({
      type: Schema.Literal("amazonBedrock").annotate({ title: "AmazonBedrockAccountType" }),
    }).annotate({ title: "AmazonBedrockAccount" }),
  ],
  { mode: "oneOf" },
);

export type V2HookCompletedNotification__HookOutputEntry = {
  readonly kind: V2HookCompletedNotification__HookOutputEntryKind;
  readonly text: string;
};
export const V2HookCompletedNotification__HookOutputEntry = Schema.Struct({
  kind: V2HookCompletedNotification__HookOutputEntryKind,
  text: Schema.String,
});

export type V2HooksListResponse__HookMetadata = {
  readonly command?: string | null;
  readonly currentHash: string;
  readonly displayOrder: number;
  readonly enabled: boolean;
  readonly eventName: V2HooksListResponse__HookEventName;
  readonly handlerType: V2HooksListResponse__HookHandlerType;
  readonly isManaged: boolean;
  readonly key: string;
  readonly matcher?: string | null;
  readonly pluginId?: string | null;
  readonly source: V2HooksListResponse__HookSource;
  readonly sourcePath: V2HooksListResponse__AbsolutePathBuf;
  readonly statusMessage?: string | null;
  readonly timeoutSec: number;
  readonly trustStatus: V2HooksListResponse__HookTrustStatus;
};
export const V2HooksListResponse__HookMetadata = Schema.Struct({
  command: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  currentHash: Schema.String,
  displayOrder: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  enabled: Schema.Boolean,
  eventName: V2HooksListResponse__HookEventName,
  handlerType: V2HooksListResponse__HookHandlerType,
  isManaged: Schema.Boolean,
  key: Schema.String,
  matcher: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  pluginId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  source: V2HooksListResponse__HookSource,
  sourcePath: V2HooksListResponse__AbsolutePathBuf,
  statusMessage: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  timeoutSec: Schema.Number.annotate({ format: "uint64" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  trustStatus: V2HooksListResponse__HookTrustStatus,
});

export type V2HookStartedNotification__HookOutputEntry = {
  readonly kind: V2HookStartedNotification__HookOutputEntryKind;
  readonly text: string;
};
export const V2HookStartedNotification__HookOutputEntry = Schema.Struct({
  kind: V2HookStartedNotification__HookOutputEntryKind,
  text: Schema.String,
});

export type V2ItemCompletedNotification__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ItemCompletedNotification__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ItemCompletedNotification__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ItemCompletedNotification__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemCompletedNotification__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ItemCompletedNotification__CollabAgentStatus;
};
export const V2ItemCompletedNotification__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ItemCompletedNotification__CollabAgentStatus,
});

export type V2ItemCompletedNotification__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ItemCompletedNotification__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ItemCompletedNotification__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ItemCompletedNotification__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ItemCompletedNotification__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ItemCompletedNotification__PatchChangeKind;
  readonly path: string;
};
export const V2ItemCompletedNotification__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ItemCompletedNotification__PatchChangeKind,
  path: Schema.String,
});

export type V2ItemCompletedNotification__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ItemCompletedNotification__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ItemCompletedNotification__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ItemCompletedNotification__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemGuardianApprovalReviewCompletedNotification__FileSystemPath =
  | {
      readonly path: V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf;
      readonly type: "path";
    }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | {
      readonly type: "special";
      readonly value: V2ItemGuardianApprovalReviewCompletedNotification__FileSystemSpecialPath;
    };
export const V2ItemGuardianApprovalReviewCompletedNotification__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: V2ItemGuardianApprovalReviewCompletedNotification__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReview = {
  readonly rationale?: string | null;
  readonly riskLevel?: V2ItemGuardianApprovalReviewCompletedNotification__GuardianRiskLevel | null;
  readonly status: V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReviewStatus;
  readonly userAuthorization?: V2ItemGuardianApprovalReviewCompletedNotification__GuardianUserAuthorization | null;
};
export const V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReview =
  Schema.Struct({
    rationale: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    riskLevel: Schema.optionalKey(
      Schema.Union([
        V2ItemGuardianApprovalReviewCompletedNotification__GuardianRiskLevel,
        Schema.Null,
      ]),
    ),
    status: V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReviewStatus,
    userAuthorization: Schema.optionalKey(
      Schema.Union([
        V2ItemGuardianApprovalReviewCompletedNotification__GuardianUserAuthorization,
        Schema.Null,
      ]),
    ),
  }).annotate({
    description:
      "[UNSTABLE] Temporary approval auto-review payload used by `item/autoApprovalReview/*` notifications. This shape is expected to change soon.",
  });

export type V2ItemGuardianApprovalReviewStartedNotification__FileSystemPath =
  | {
      readonly path: V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf;
      readonly type: "path";
    }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | {
      readonly type: "special";
      readonly value: V2ItemGuardianApprovalReviewStartedNotification__FileSystemSpecialPath;
    };
export const V2ItemGuardianApprovalReviewStartedNotification__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: V2ItemGuardianApprovalReviewStartedNotification__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReview = {
  readonly rationale?: string | null;
  readonly riskLevel?: V2ItemGuardianApprovalReviewStartedNotification__GuardianRiskLevel | null;
  readonly status: V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReviewStatus;
  readonly userAuthorization?: V2ItemGuardianApprovalReviewStartedNotification__GuardianUserAuthorization | null;
};
export const V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReview =
  Schema.Struct({
    rationale: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    riskLevel: Schema.optionalKey(
      Schema.Union([
        V2ItemGuardianApprovalReviewStartedNotification__GuardianRiskLevel,
        Schema.Null,
      ]),
    ),
    status: V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReviewStatus,
    userAuthorization: Schema.optionalKey(
      Schema.Union([
        V2ItemGuardianApprovalReviewStartedNotification__GuardianUserAuthorization,
        Schema.Null,
      ]),
    ),
  }).annotate({
    description:
      "[UNSTABLE] Temporary approval auto-review payload used by `item/autoApprovalReview/*` notifications. This shape is expected to change soon.",
  });

export type V2ItemStartedNotification__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ItemStartedNotification__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ItemStartedNotification__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ItemStartedNotification__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemStartedNotification__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ItemStartedNotification__CollabAgentStatus;
};
export const V2ItemStartedNotification__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ItemStartedNotification__CollabAgentStatus,
});

export type V2ItemStartedNotification__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ItemStartedNotification__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ItemStartedNotification__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ItemStartedNotification__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ItemStartedNotification__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ItemStartedNotification__PatchChangeKind;
  readonly path: string;
};
export const V2ItemStartedNotification__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ItemStartedNotification__PatchChangeKind,
  path: Schema.String,
});

export type V2ItemStartedNotification__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ItemStartedNotification__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ItemStartedNotification__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ItemStartedNotification__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ListMcpServerStatusResponse__McpServerStatus = {
  readonly authStatus: V2ListMcpServerStatusResponse__McpAuthStatus;
  readonly name: string;
  readonly resourceTemplates: ReadonlyArray<V2ListMcpServerStatusResponse__ResourceTemplate>;
  readonly resources: ReadonlyArray<V2ListMcpServerStatusResponse__Resource>;
  readonly tools: { readonly [x: string]: V2ListMcpServerStatusResponse__Tool };
};
export const V2ListMcpServerStatusResponse__McpServerStatus = Schema.Struct({
  authStatus: V2ListMcpServerStatusResponse__McpAuthStatus,
  name: Schema.String,
  resourceTemplates: Schema.Array(V2ListMcpServerStatusResponse__ResourceTemplate),
  resources: Schema.Array(V2ListMcpServerStatusResponse__Resource),
  tools: Schema.Record(Schema.String, V2ListMcpServerStatusResponse__Tool),
});

export type V2ModelListResponse__ReasoningEffortOption = {
  readonly description: string;
  readonly reasoningEffort: V2ModelListResponse__ReasoningEffort;
};
export const V2ModelListResponse__ReasoningEffortOption = Schema.Struct({
  description: Schema.String,
  reasoningEffort: V2ModelListResponse__ReasoningEffort,
});

export type V2PluginListResponse__MarketplaceLoadErrorInfo = {
  readonly marketplacePath: V2PluginListResponse__AbsolutePathBuf;
  readonly message: string;
};
export const V2PluginListResponse__MarketplaceLoadErrorInfo = Schema.Struct({
  marketplacePath: V2PluginListResponse__AbsolutePathBuf,
  message: Schema.String,
});

export type V2PluginListResponse__PluginInterface = {
  readonly brandColor?: string | null;
  readonly capabilities: ReadonlyArray<string>;
  readonly category?: string | null;
  readonly composerIcon?: V2PluginListResponse__AbsolutePathBuf | null;
  readonly composerIconUrl?: string | null;
  readonly defaultPrompt?: ReadonlyArray<string> | null;
  readonly developerName?: string | null;
  readonly displayName?: string | null;
  readonly logo?: V2PluginListResponse__AbsolutePathBuf | null;
  readonly logoUrl?: string | null;
  readonly longDescription?: string | null;
  readonly privacyPolicyUrl?: string | null;
  readonly screenshotUrls: ReadonlyArray<string>;
  readonly screenshots: ReadonlyArray<V2PluginListResponse__AbsolutePathBuf>;
  readonly shortDescription?: string | null;
  readonly termsOfServiceUrl?: string | null;
  readonly websiteUrl?: string | null;
};
export const V2PluginListResponse__PluginInterface = Schema.Struct({
  brandColor: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  capabilities: Schema.Array(Schema.String),
  category: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  composerIcon: Schema.optionalKey(
    Schema.Union([V2PluginListResponse__AbsolutePathBuf, Schema.Null]).annotate({
      description: "Local composer icon path, resolved from the installed plugin package.",
    }),
  ),
  composerIconUrl: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Remote composer icon URL from the plugin catalog." }),
      Schema.Null,
    ]),
  ),
  defaultPrompt: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Starter prompts for the plugin. Capped at 3 entries with a maximum of 128 characters per entry.",
      }),
      Schema.Null,
    ]),
  ),
  developerName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  displayName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  logo: Schema.optionalKey(
    Schema.Union([V2PluginListResponse__AbsolutePathBuf, Schema.Null]).annotate({
      description: "Local logo path, resolved from the installed plugin package.",
    }),
  ),
  logoUrl: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Remote logo URL from the plugin catalog." }),
      Schema.Null,
    ]),
  ),
  longDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  privacyPolicyUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  screenshotUrls: Schema.Array(Schema.String).annotate({
    description: "Remote screenshot URLs from the plugin catalog.",
  }),
  screenshots: Schema.Array(V2PluginListResponse__AbsolutePathBuf).annotate({
    description: "Local screenshot paths, resolved from the installed plugin package.",
  }),
  shortDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  termsOfServiceUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  websiteUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2PluginListResponse__PluginSource =
  | { readonly path: V2PluginListResponse__AbsolutePathBuf; readonly type: "local" }
  | {
      readonly path?: string | null;
      readonly refName?: string | null;
      readonly sha?: string | null;
      readonly type: "git";
      readonly url: string;
    }
  | { readonly type: "remote" };
export const V2PluginListResponse__PluginSource = Schema.Union(
  [
    Schema.Struct({
      path: V2PluginListResponse__AbsolutePathBuf,
      type: Schema.Literal("local").annotate({ title: "LocalPluginSourceType" }),
    }).annotate({ title: "LocalPluginSource" }),
    Schema.Struct({
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      refName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("git").annotate({ title: "GitPluginSourceType" }),
      url: Schema.String,
    }).annotate({ title: "GitPluginSource" }),
    Schema.Struct({
      type: Schema.Literal("remote").annotate({ title: "RemotePluginSourceType" }),
    }).annotate({
      title: "RemotePluginSource",
      description:
        "The plugin is available in the remote catalog. Download metadata is kept server-side and is not exposed through the app-server API.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2PluginListResponse__PluginSharePrincipal = {
  readonly name: string;
  readonly principalId: string;
  readonly principalType: V2PluginListResponse__PluginSharePrincipalType;
};
export const V2PluginListResponse__PluginSharePrincipal = Schema.Struct({
  name: Schema.String,
  principalId: Schema.String,
  principalType: V2PluginListResponse__PluginSharePrincipalType,
});

export type V2PluginReadResponse__PluginInterface = {
  readonly brandColor?: string | null;
  readonly capabilities: ReadonlyArray<string>;
  readonly category?: string | null;
  readonly composerIcon?: V2PluginReadResponse__AbsolutePathBuf | null;
  readonly composerIconUrl?: string | null;
  readonly defaultPrompt?: ReadonlyArray<string> | null;
  readonly developerName?: string | null;
  readonly displayName?: string | null;
  readonly logo?: V2PluginReadResponse__AbsolutePathBuf | null;
  readonly logoUrl?: string | null;
  readonly longDescription?: string | null;
  readonly privacyPolicyUrl?: string | null;
  readonly screenshotUrls: ReadonlyArray<string>;
  readonly screenshots: ReadonlyArray<V2PluginReadResponse__AbsolutePathBuf>;
  readonly shortDescription?: string | null;
  readonly termsOfServiceUrl?: string | null;
  readonly websiteUrl?: string | null;
};
export const V2PluginReadResponse__PluginInterface = Schema.Struct({
  brandColor: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  capabilities: Schema.Array(Schema.String),
  category: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  composerIcon: Schema.optionalKey(
    Schema.Union([V2PluginReadResponse__AbsolutePathBuf, Schema.Null]).annotate({
      description: "Local composer icon path, resolved from the installed plugin package.",
    }),
  ),
  composerIconUrl: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Remote composer icon URL from the plugin catalog." }),
      Schema.Null,
    ]),
  ),
  defaultPrompt: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Starter prompts for the plugin. Capped at 3 entries with a maximum of 128 characters per entry.",
      }),
      Schema.Null,
    ]),
  ),
  developerName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  displayName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  logo: Schema.optionalKey(
    Schema.Union([V2PluginReadResponse__AbsolutePathBuf, Schema.Null]).annotate({
      description: "Local logo path, resolved from the installed plugin package.",
    }),
  ),
  logoUrl: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Remote logo URL from the plugin catalog." }),
      Schema.Null,
    ]),
  ),
  longDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  privacyPolicyUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  screenshotUrls: Schema.Array(Schema.String).annotate({
    description: "Remote screenshot URLs from the plugin catalog.",
  }),
  screenshots: Schema.Array(V2PluginReadResponse__AbsolutePathBuf).annotate({
    description: "Local screenshot paths, resolved from the installed plugin package.",
  }),
  shortDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  termsOfServiceUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  websiteUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2PluginReadResponse__PluginSource =
  | { readonly path: V2PluginReadResponse__AbsolutePathBuf; readonly type: "local" }
  | {
      readonly path?: string | null;
      readonly refName?: string | null;
      readonly sha?: string | null;
      readonly type: "git";
      readonly url: string;
    }
  | { readonly type: "remote" };
export const V2PluginReadResponse__PluginSource = Schema.Union(
  [
    Schema.Struct({
      path: V2PluginReadResponse__AbsolutePathBuf,
      type: Schema.Literal("local").annotate({ title: "LocalPluginSourceType" }),
    }).annotate({ title: "LocalPluginSource" }),
    Schema.Struct({
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      refName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("git").annotate({ title: "GitPluginSourceType" }),
      url: Schema.String,
    }).annotate({ title: "GitPluginSource" }),
    Schema.Struct({
      type: Schema.Literal("remote").annotate({ title: "RemotePluginSourceType" }),
    }).annotate({
      title: "RemotePluginSource",
      description:
        "The plugin is available in the remote catalog. Download metadata is kept server-side and is not exposed through the app-server API.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2PluginReadResponse__SkillInterface = {
  readonly brandColor?: string | null;
  readonly defaultPrompt?: string | null;
  readonly displayName?: string | null;
  readonly iconLarge?: V2PluginReadResponse__AbsolutePathBuf | null;
  readonly iconSmall?: V2PluginReadResponse__AbsolutePathBuf | null;
  readonly shortDescription?: string | null;
};
export const V2PluginReadResponse__SkillInterface = Schema.Struct({
  brandColor: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  defaultPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  displayName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  iconLarge: Schema.optionalKey(Schema.Union([V2PluginReadResponse__AbsolutePathBuf, Schema.Null])),
  iconSmall: Schema.optionalKey(Schema.Union([V2PluginReadResponse__AbsolutePathBuf, Schema.Null])),
  shortDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2PluginReadResponse__PluginHookSummary = {
  readonly eventName: V2PluginReadResponse__HookEventName;
  readonly key: string;
};
export const V2PluginReadResponse__PluginHookSummary = Schema.Struct({
  eventName: V2PluginReadResponse__HookEventName,
  key: Schema.String,
});

export type V2PluginReadResponse__PluginSharePrincipal = {
  readonly name: string;
  readonly principalId: string;
  readonly principalType: V2PluginReadResponse__PluginSharePrincipalType;
};
export const V2PluginReadResponse__PluginSharePrincipal = Schema.Struct({
  name: Schema.String,
  principalId: Schema.String,
  principalType: V2PluginReadResponse__PluginSharePrincipalType,
});

export type V2PluginShareListResponse__PluginInterface = {
  readonly brandColor?: string | null;
  readonly capabilities: ReadonlyArray<string>;
  readonly category?: string | null;
  readonly composerIcon?: V2PluginShareListResponse__AbsolutePathBuf | null;
  readonly composerIconUrl?: string | null;
  readonly defaultPrompt?: ReadonlyArray<string> | null;
  readonly developerName?: string | null;
  readonly displayName?: string | null;
  readonly logo?: V2PluginShareListResponse__AbsolutePathBuf | null;
  readonly logoUrl?: string | null;
  readonly longDescription?: string | null;
  readonly privacyPolicyUrl?: string | null;
  readonly screenshotUrls: ReadonlyArray<string>;
  readonly screenshots: ReadonlyArray<V2PluginShareListResponse__AbsolutePathBuf>;
  readonly shortDescription?: string | null;
  readonly termsOfServiceUrl?: string | null;
  readonly websiteUrl?: string | null;
};
export const V2PluginShareListResponse__PluginInterface = Schema.Struct({
  brandColor: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  capabilities: Schema.Array(Schema.String),
  category: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  composerIcon: Schema.optionalKey(
    Schema.Union([V2PluginShareListResponse__AbsolutePathBuf, Schema.Null]).annotate({
      description: "Local composer icon path, resolved from the installed plugin package.",
    }),
  ),
  composerIconUrl: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Remote composer icon URL from the plugin catalog." }),
      Schema.Null,
    ]),
  ),
  defaultPrompt: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Starter prompts for the plugin. Capped at 3 entries with a maximum of 128 characters per entry.",
      }),
      Schema.Null,
    ]),
  ),
  developerName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  displayName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  logo: Schema.optionalKey(
    Schema.Union([V2PluginShareListResponse__AbsolutePathBuf, Schema.Null]).annotate({
      description: "Local logo path, resolved from the installed plugin package.",
    }),
  ),
  logoUrl: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Remote logo URL from the plugin catalog." }),
      Schema.Null,
    ]),
  ),
  longDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  privacyPolicyUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  screenshotUrls: Schema.Array(Schema.String).annotate({
    description: "Remote screenshot URLs from the plugin catalog.",
  }),
  screenshots: Schema.Array(V2PluginShareListResponse__AbsolutePathBuf).annotate({
    description: "Local screenshot paths, resolved from the installed plugin package.",
  }),
  shortDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  termsOfServiceUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  websiteUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2PluginShareListResponse__PluginSource =
  | { readonly path: V2PluginShareListResponse__AbsolutePathBuf; readonly type: "local" }
  | {
      readonly path?: string | null;
      readonly refName?: string | null;
      readonly sha?: string | null;
      readonly type: "git";
      readonly url: string;
    }
  | { readonly type: "remote" };
export const V2PluginShareListResponse__PluginSource = Schema.Union(
  [
    Schema.Struct({
      path: V2PluginShareListResponse__AbsolutePathBuf,
      type: Schema.Literal("local").annotate({ title: "LocalPluginSourceType" }),
    }).annotate({ title: "LocalPluginSource" }),
    Schema.Struct({
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      refName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      sha: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("git").annotate({ title: "GitPluginSourceType" }),
      url: Schema.String,
    }).annotate({ title: "GitPluginSource" }),
    Schema.Struct({
      type: Schema.Literal("remote").annotate({ title: "RemotePluginSourceType" }),
    }).annotate({
      title: "RemotePluginSource",
      description:
        "The plugin is available in the remote catalog. Download metadata is kept server-side and is not exposed through the app-server API.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2PluginShareListResponse__PluginSharePrincipal = {
  readonly name: string;
  readonly principalId: string;
  readonly principalType: V2PluginShareListResponse__PluginSharePrincipalType;
};
export const V2PluginShareListResponse__PluginSharePrincipal = Schema.Struct({
  name: Schema.String,
  principalId: Schema.String,
  principalType: V2PluginShareListResponse__PluginSharePrincipalType,
});

export type V2PluginShareSaveParams__PluginShareTarget = {
  readonly principalId: string;
  readonly principalType: V2PluginShareSaveParams__PluginSharePrincipalType;
};
export const V2PluginShareSaveParams__PluginShareTarget = Schema.Struct({
  principalId: Schema.String,
  principalType: V2PluginShareSaveParams__PluginSharePrincipalType,
});

export type V2PluginShareUpdateTargetsParams__PluginShareTarget = {
  readonly principalId: string;
  readonly principalType: V2PluginShareUpdateTargetsParams__PluginSharePrincipalType;
};
export const V2PluginShareUpdateTargetsParams__PluginShareTarget = Schema.Struct({
  principalId: Schema.String,
  principalType: V2PluginShareUpdateTargetsParams__PluginSharePrincipalType,
});

export type V2PluginShareUpdateTargetsResponse__PluginSharePrincipal = {
  readonly name: string;
  readonly principalId: string;
  readonly principalType: V2PluginShareUpdateTargetsResponse__PluginSharePrincipalType;
};
export const V2PluginShareUpdateTargetsResponse__PluginSharePrincipal = Schema.Struct({
  name: Schema.String,
  principalId: Schema.String,
  principalType: V2PluginShareUpdateTargetsResponse__PluginSharePrincipalType,
});

export type V2RawResponseItemCompletedNotification__ContentItem =
  | { readonly text: string; readonly type: "input_text" }
  | {
      readonly detail?: V2RawResponseItemCompletedNotification__ImageDetail | null;
      readonly image_url: string;
      readonly type: "input_image";
    }
  | { readonly text: string; readonly type: "output_text" };
export const V2RawResponseItemCompletedNotification__ContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("input_text").annotate({ title: "InputTextContentItemType" }),
    }).annotate({ title: "InputTextContentItem" }),
    Schema.Struct({
      detail: Schema.optionalKey(
        Schema.Union([V2RawResponseItemCompletedNotification__ImageDetail, Schema.Null]),
      ),
      image_url: Schema.String,
      type: Schema.Literal("input_image").annotate({ title: "InputImageContentItemType" }),
    }).annotate({ title: "InputImageContentItem" }),
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("output_text").annotate({ title: "OutputTextContentItemType" }),
    }).annotate({ title: "OutputTextContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2RawResponseItemCompletedNotification__FunctionCallOutputContentItem =
  | { readonly text: string; readonly type: "input_text" }
  | {
      readonly detail?: V2RawResponseItemCompletedNotification__ImageDetail | null;
      readonly image_url: string;
      readonly type: "input_image";
    };
export const V2RawResponseItemCompletedNotification__FunctionCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("input_text").annotate({
        title: "InputTextFunctionCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextFunctionCallOutputContentItem" }),
    Schema.Struct({
      detail: Schema.optionalKey(
        Schema.Union([V2RawResponseItemCompletedNotification__ImageDetail, Schema.Null]),
      ),
      image_url: Schema.String,
      type: Schema.Literal("input_image").annotate({
        title: "InputImageFunctionCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageFunctionCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ReviewStartResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ReviewStartResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ReviewStartResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ReviewStartResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ReviewStartResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ReviewStartResponse__CollabAgentStatus;
};
export const V2ReviewStartResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ReviewStartResponse__CollabAgentStatus,
});

export type V2ReviewStartResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ReviewStartResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ReviewStartResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ReviewStartResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ReviewStartResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ReviewStartResponse__NonSteerableTurnKind;
      };
    };
export const V2ReviewStartResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ReviewStartResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ReviewStartResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ReviewStartResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ReviewStartResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ReviewStartResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ReviewStartResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ReviewStartResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ReviewStartResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ReviewStartResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2SkillsListResponse__SkillInterface = {
  readonly brandColor?: string | null;
  readonly defaultPrompt?: string | null;
  readonly displayName?: string | null;
  readonly iconLarge?: V2SkillsListResponse__AbsolutePathBuf | null;
  readonly iconSmall?: V2SkillsListResponse__AbsolutePathBuf | null;
  readonly shortDescription?: string | null;
};
export const V2SkillsListResponse__SkillInterface = Schema.Struct({
  brandColor: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  defaultPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  displayName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  iconLarge: Schema.optionalKey(Schema.Union([V2SkillsListResponse__AbsolutePathBuf, Schema.Null])),
  iconSmall: Schema.optionalKey(Schema.Union([V2SkillsListResponse__AbsolutePathBuf, Schema.Null])),
  shortDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2SkillsListResponse__SkillDependencies = {
  readonly tools: ReadonlyArray<V2SkillsListResponse__SkillToolDependency>;
};
export const V2SkillsListResponse__SkillDependencies = Schema.Struct({
  tools: Schema.Array(V2SkillsListResponse__SkillToolDependency),
});

export type V2ThreadForkParams__PermissionProfileModificationParams = {
  readonly path: V2ThreadForkParams__AbsolutePathBuf;
  readonly type: "additionalWritableRoot";
};
export const V2ThreadForkParams__PermissionProfileModificationParams = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadForkParams__AbsolutePathBuf,
      type: Schema.Literal("additionalWritableRoot").annotate({
        title: "AdditionalWritableRootPermissionProfileModificationParamsType",
      }),
    }).annotate({
      title: "AdditionalWritableRootPermissionProfileModificationParams",
      description: "Additional concrete directory that should be writable.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__ActivePermissionProfileModification = {
  readonly path: V2ThreadForkResponse__AbsolutePathBuf;
  readonly type: "additionalWritableRoot";
};
export const V2ThreadForkResponse__ActivePermissionProfileModification = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadForkResponse__AbsolutePathBuf,
      type: Schema.Literal("additionalWritableRoot").annotate({
        title: "AdditionalWritableRootActivePermissionProfileModificationType",
      }),
    }).annotate({
      title: "AdditionalWritableRootActivePermissionProfileModification",
      description: "Additional concrete directory that should be writable.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadForkResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadForkResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadForkResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadForkResponse__CollabAgentStatus;
};
export const V2ThreadForkResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadForkResponse__CollabAgentStatus,
});

export type V2ThreadForkResponse__FileSystemPath =
  | { readonly path: V2ThreadForkResponse__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | { readonly type: "special"; readonly value: V2ThreadForkResponse__FileSystemSpecialPath };
export const V2ThreadForkResponse__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadForkResponse__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: V2ThreadForkResponse__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadForkResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadForkResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadForkResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadForkResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadForkResponse__NonSteerableTurnKind;
      };
    };
export const V2ThreadForkResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadForkResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadForkResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadForkResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadForkResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadForkResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadForkResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadForkResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadForkResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadForkResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadForkResponse__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadForkResponse__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadForkResponse__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadForkResponse__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadForkResponse__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadGoalUpdatedNotification__ThreadGoal = {
  readonly createdAt: number;
  readonly objective: string;
  readonly status: V2ThreadGoalUpdatedNotification__ThreadGoalStatus;
  readonly threadId: string;
  readonly timeUsedSeconds: number;
  readonly tokenBudget?: number | null;
  readonly tokensUsed: number;
  readonly updatedAt: number;
};
export const V2ThreadGoalUpdatedNotification__ThreadGoal = Schema.Struct({
  createdAt: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  objective: Schema.String,
  status: V2ThreadGoalUpdatedNotification__ThreadGoalStatus,
  threadId: Schema.String,
  timeUsedSeconds: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  tokenBudget: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  tokensUsed: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  updatedAt: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
});

export type V2ThreadListResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadListResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadListResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadListResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadListResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadListResponse__CollabAgentStatus;
};
export const V2ThreadListResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadListResponse__CollabAgentStatus,
});

export type V2ThreadListResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadListResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadListResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadListResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadListResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadListResponse__NonSteerableTurnKind;
      };
    };
export const V2ThreadListResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadListResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadListResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadListResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadListResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadListResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadListResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadListResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadListResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadListResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadListResponse__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadListResponse__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadListResponse__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadListResponse__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadListResponse__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadListResponse__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadMetadataUpdateResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadMetadataUpdateResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadMetadataUpdateResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadMetadataUpdateResponse__CollabAgentStatus;
};
export const V2ThreadMetadataUpdateResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadMetadataUpdateResponse__CollabAgentStatus,
});

export type V2ThreadMetadataUpdateResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadMetadataUpdateResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadMetadataUpdateResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadMetadataUpdateResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadMetadataUpdateResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadMetadataUpdateResponse__NonSteerableTurnKind;
      };
    };
export const V2ThreadMetadataUpdateResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadMetadataUpdateResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadMetadataUpdateResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadMetadataUpdateResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadMetadataUpdateResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadMetadataUpdateResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadMetadataUpdateResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadMetadataUpdateResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadMetadataUpdateResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadMetadataUpdateResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateResponse__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadMetadataUpdateResponse__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadMetadataUpdateResponse__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadMetadataUpdateResponse__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadMetadataUpdateResponse__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadMetadataUpdateResponse__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadReadResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadReadResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadReadResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadReadResponse__CollabAgentStatus;
};
export const V2ThreadReadResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadReadResponse__CollabAgentStatus,
});

export type V2ThreadReadResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadReadResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadReadResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadReadResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadReadResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadReadResponse__NonSteerableTurnKind;
      };
    };
export const V2ThreadReadResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadReadResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadReadResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadReadResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadReadResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadReadResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadReadResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadReadResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadReadResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadReadResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadReadResponse__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadReadResponse__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadReadResponse__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadReadResponse__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadReadResponse__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__PermissionProfileModificationParams = {
  readonly path: V2ThreadResumeParams__AbsolutePathBuf;
  readonly type: "additionalWritableRoot";
};
export const V2ThreadResumeParams__PermissionProfileModificationParams = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadResumeParams__AbsolutePathBuf,
      type: Schema.Literal("additionalWritableRoot").annotate({
        title: "AdditionalWritableRootPermissionProfileModificationParamsType",
      }),
    }).annotate({
      title: "AdditionalWritableRootPermissionProfileModificationParams",
      description: "Additional concrete directory that should be writable.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__ContentItem =
  | { readonly text: string; readonly type: "input_text" }
  | {
      readonly detail?: V2ThreadResumeParams__ImageDetail | null;
      readonly image_url: string;
      readonly type: "input_image";
    }
  | { readonly text: string; readonly type: "output_text" };
export const V2ThreadResumeParams__ContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("input_text").annotate({ title: "InputTextContentItemType" }),
    }).annotate({ title: "InputTextContentItem" }),
    Schema.Struct({
      detail: Schema.optionalKey(Schema.Union([V2ThreadResumeParams__ImageDetail, Schema.Null])),
      image_url: Schema.String,
      type: Schema.Literal("input_image").annotate({ title: "InputImageContentItemType" }),
    }).annotate({ title: "InputImageContentItem" }),
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("output_text").annotate({ title: "OutputTextContentItemType" }),
    }).annotate({ title: "OutputTextContentItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__FunctionCallOutputContentItem =
  | { readonly text: string; readonly type: "input_text" }
  | {
      readonly detail?: V2ThreadResumeParams__ImageDetail | null;
      readonly image_url: string;
      readonly type: "input_image";
    };
export const V2ThreadResumeParams__FunctionCallOutputContentItem = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      type: Schema.Literal("input_text").annotate({
        title: "InputTextFunctionCallOutputContentItemType",
      }),
    }).annotate({ title: "InputTextFunctionCallOutputContentItem" }),
    Schema.Struct({
      detail: Schema.optionalKey(Schema.Union([V2ThreadResumeParams__ImageDetail, Schema.Null])),
      image_url: Schema.String,
      type: Schema.Literal("input_image").annotate({
        title: "InputImageFunctionCallOutputContentItemType",
      }),
    }).annotate({ title: "InputImageFunctionCallOutputContentItem" }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadResumeResponse__ActivePermissionProfileModification = {
  readonly path: V2ThreadResumeResponse__AbsolutePathBuf;
  readonly type: "additionalWritableRoot";
};
export const V2ThreadResumeResponse__ActivePermissionProfileModification = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadResumeResponse__AbsolutePathBuf,
      type: Schema.Literal("additionalWritableRoot").annotate({
        title: "AdditionalWritableRootActivePermissionProfileModificationType",
      }),
    }).annotate({
      title: "AdditionalWritableRootActivePermissionProfileModification",
      description: "Additional concrete directory that should be writable.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadResumeResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadResumeResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadResumeResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadResumeResponse__CollabAgentStatus;
};
export const V2ThreadResumeResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadResumeResponse__CollabAgentStatus,
});

export type V2ThreadResumeResponse__FileSystemPath =
  | { readonly path: V2ThreadResumeResponse__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | { readonly type: "special"; readonly value: V2ThreadResumeResponse__FileSystemSpecialPath };
export const V2ThreadResumeResponse__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadResumeResponse__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: V2ThreadResumeResponse__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadResumeResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadResumeResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadResumeResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadResumeResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadResumeResponse__NonSteerableTurnKind;
      };
    };
export const V2ThreadResumeResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadResumeResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadResumeResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadResumeResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadResumeResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadResumeResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadResumeResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadResumeResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadResumeResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadResumeResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadResumeResponse__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadResumeResponse__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadResumeResponse__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadResumeResponse__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadResumeResponse__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadRollbackResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadRollbackResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadRollbackResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadRollbackResponse__CollabAgentStatus;
};
export const V2ThreadRollbackResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadRollbackResponse__CollabAgentStatus,
});

export type V2ThreadRollbackResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadRollbackResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadRollbackResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadRollbackResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadRollbackResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadRollbackResponse__NonSteerableTurnKind;
      };
    };
export const V2ThreadRollbackResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadRollbackResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadRollbackResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadRollbackResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadRollbackResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadRollbackResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadRollbackResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadRollbackResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadRollbackResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadRollbackResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadRollbackResponse__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadRollbackResponse__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadRollbackResponse__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadRollbackResponse__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadRollbackResponse__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadStartedNotification__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadStartedNotification__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadStartedNotification__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadStartedNotification__CollabAgentStatus;
};
export const V2ThreadStartedNotification__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadStartedNotification__CollabAgentStatus,
});

export type V2ThreadStartedNotification__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadStartedNotification__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadStartedNotification__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadStartedNotification__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadStartedNotification__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadStartedNotification__NonSteerableTurnKind;
      };
    };
export const V2ThreadStartedNotification__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadStartedNotification__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadStartedNotification__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadStartedNotification__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadStartedNotification__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadStartedNotification__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadStartedNotification__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadStartedNotification__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadStartedNotification__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadStartedNotification__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadStartedNotification__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadStartedNotification__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadStartedNotification__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadStartedNotification__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadStartedNotification__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartParams__PermissionProfileModificationParams = {
  readonly path: V2ThreadStartParams__AbsolutePathBuf;
  readonly type: "additionalWritableRoot";
};
export const V2ThreadStartParams__PermissionProfileModificationParams = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadStartParams__AbsolutePathBuf,
      type: Schema.Literal("additionalWritableRoot").annotate({
        title: "AdditionalWritableRootPermissionProfileModificationParamsType",
      }),
    }).annotate({
      title: "AdditionalWritableRootPermissionProfileModificationParams",
      description: "Additional concrete directory that should be writable.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__ActivePermissionProfileModification = {
  readonly path: V2ThreadStartResponse__AbsolutePathBuf;
  readonly type: "additionalWritableRoot";
};
export const V2ThreadStartResponse__ActivePermissionProfileModification = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadStartResponse__AbsolutePathBuf,
      type: Schema.Literal("additionalWritableRoot").annotate({
        title: "AdditionalWritableRootActivePermissionProfileModificationType",
      }),
    }).annotate({
      title: "AdditionalWritableRootActivePermissionProfileModification",
      description: "Additional concrete directory that should be writable.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadStartResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadStartResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadStartResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadStartResponse__CollabAgentStatus;
};
export const V2ThreadStartResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadStartResponse__CollabAgentStatus,
});

export type V2ThreadStartResponse__FileSystemPath =
  | { readonly path: V2ThreadStartResponse__AbsolutePathBuf; readonly type: "path" }
  | { readonly pattern: string; readonly type: "glob_pattern" }
  | { readonly type: "special"; readonly value: V2ThreadStartResponse__FileSystemSpecialPath };
export const V2ThreadStartResponse__FileSystemPath = Schema.Union(
  [
    Schema.Struct({
      path: V2ThreadStartResponse__AbsolutePathBuf,
      type: Schema.Literal("path").annotate({ title: "PathFileSystemPathType" }),
    }).annotate({ title: "PathFileSystemPath" }),
    Schema.Struct({
      pattern: Schema.String,
      type: Schema.Literal("glob_pattern").annotate({ title: "GlobPatternFileSystemPathType" }),
    }).annotate({ title: "GlobPatternFileSystemPath" }),
    Schema.Struct({
      type: Schema.Literal("special").annotate({ title: "SpecialFileSystemPathType" }),
      value: V2ThreadStartResponse__FileSystemSpecialPath,
    }).annotate({ title: "SpecialFileSystemPath" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadStartResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadStartResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadStartResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadStartResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadStartResponse__NonSteerableTurnKind;
      };
    };
export const V2ThreadStartResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadStartResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadStartResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadStartResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadStartResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadStartResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadStartResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadStartResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadStartResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadStartResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadStartResponse__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadStartResponse__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadStartResponse__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadStartResponse__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadStartResponse__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStatusChangedNotification__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadStatusChangedNotification__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadStatusChangedNotification__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadStatusChangedNotification__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadTokenUsageUpdatedNotification__ThreadTokenUsage = {
  readonly last: V2ThreadTokenUsageUpdatedNotification__TokenUsageBreakdown;
  readonly modelContextWindow?: number | null;
  readonly total: V2ThreadTokenUsageUpdatedNotification__TokenUsageBreakdown;
};
export const V2ThreadTokenUsageUpdatedNotification__ThreadTokenUsage = Schema.Struct({
  last: V2ThreadTokenUsageUpdatedNotification__TokenUsageBreakdown,
  modelContextWindow: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  total: V2ThreadTokenUsageUpdatedNotification__TokenUsageBreakdown,
});

export type V2ThreadUnarchiveResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2ThreadUnarchiveResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2ThreadUnarchiveResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2ThreadUnarchiveResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadUnarchiveResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2ThreadUnarchiveResponse__CollabAgentStatus;
};
export const V2ThreadUnarchiveResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2ThreadUnarchiveResponse__CollabAgentStatus,
});

export type V2ThreadUnarchiveResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2ThreadUnarchiveResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2ThreadUnarchiveResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2ThreadUnarchiveResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2ThreadUnarchiveResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2ThreadUnarchiveResponse__NonSteerableTurnKind;
      };
    };
export const V2ThreadUnarchiveResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2ThreadUnarchiveResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2ThreadUnarchiveResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2ThreadUnarchiveResponse__PatchChangeKind;
  readonly path: string;
};
export const V2ThreadUnarchiveResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2ThreadUnarchiveResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2ThreadUnarchiveResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2ThreadUnarchiveResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2ThreadUnarchiveResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2ThreadUnarchiveResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadUnarchiveResponse__SubAgentSource =
  | "review"
  | "compact"
  | "memory_consolidation"
  | {
      readonly thread_spawn: {
        readonly agent_nickname?: string | null;
        readonly agent_path?: V2ThreadUnarchiveResponse__AgentPath | null;
        readonly agent_role?: string | null;
        readonly depth: number;
        readonly parent_thread_id: V2ThreadUnarchiveResponse__ThreadId;
      };
    }
  | { readonly other: string };
export const V2ThreadUnarchiveResponse__SubAgentSource = Schema.Union(
  [
    Schema.Literals(["review", "compact", "memory_consolidation"]),
    Schema.Struct({
      thread_spawn: Schema.Struct({
        agent_nickname: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        agent_path: Schema.optionalKey(
          Schema.Union([V2ThreadUnarchiveResponse__AgentPath, Schema.Null]),
        ),
        agent_role: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        depth: Schema.Number.annotate({ format: "int32" }).check(Schema.isInt()),
        parent_thread_id: V2ThreadUnarchiveResponse__ThreadId,
      }),
    }).annotate({ title: "ThreadSpawnSubAgentSource" }),
    Schema.Struct({ other: Schema.String }).annotate({ title: "OtherSubAgentSource" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnCompletedNotification__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2TurnCompletedNotification__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2TurnCompletedNotification__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2TurnCompletedNotification__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnCompletedNotification__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2TurnCompletedNotification__CollabAgentStatus;
};
export const V2TurnCompletedNotification__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2TurnCompletedNotification__CollabAgentStatus,
});

export type V2TurnCompletedNotification__MemoryCitation = {
  readonly entries: ReadonlyArray<V2TurnCompletedNotification__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2TurnCompletedNotification__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2TurnCompletedNotification__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2TurnCompletedNotification__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2TurnCompletedNotification__NonSteerableTurnKind;
      };
    };
export const V2TurnCompletedNotification__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2TurnCompletedNotification__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2TurnCompletedNotification__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2TurnCompletedNotification__PatchChangeKind;
  readonly path: string;
};
export const V2TurnCompletedNotification__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2TurnCompletedNotification__PatchChangeKind,
  path: Schema.String,
});

export type V2TurnCompletedNotification__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2TurnCompletedNotification__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2TurnCompletedNotification__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2TurnCompletedNotification__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnPlanUpdatedNotification__TurnPlanStep = {
  readonly status: V2TurnPlanUpdatedNotification__TurnPlanStepStatus;
  readonly step: string;
};
export const V2TurnPlanUpdatedNotification__TurnPlanStep = Schema.Struct({
  status: V2TurnPlanUpdatedNotification__TurnPlanStepStatus,
  step: Schema.String,
});

export type V2TurnStartedNotification__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2TurnStartedNotification__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2TurnStartedNotification__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2TurnStartedNotification__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartedNotification__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2TurnStartedNotification__CollabAgentStatus;
};
export const V2TurnStartedNotification__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2TurnStartedNotification__CollabAgentStatus,
});

export type V2TurnStartedNotification__MemoryCitation = {
  readonly entries: ReadonlyArray<V2TurnStartedNotification__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2TurnStartedNotification__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2TurnStartedNotification__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2TurnStartedNotification__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2TurnStartedNotification__NonSteerableTurnKind;
      };
    };
export const V2TurnStartedNotification__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2TurnStartedNotification__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2TurnStartedNotification__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2TurnStartedNotification__PatchChangeKind;
  readonly path: string;
};
export const V2TurnStartedNotification__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2TurnStartedNotification__PatchChangeKind,
  path: Schema.String,
});

export type V2TurnStartedNotification__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2TurnStartedNotification__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2TurnStartedNotification__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2TurnStartedNotification__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartParams__PermissionProfileModificationParams = {
  readonly path: V2TurnStartParams__AbsolutePathBuf;
  readonly type: "additionalWritableRoot";
};
export const V2TurnStartParams__PermissionProfileModificationParams = Schema.Union(
  [
    Schema.Struct({
      path: V2TurnStartParams__AbsolutePathBuf,
      type: Schema.Literal("additionalWritableRoot").annotate({
        title: "AdditionalWritableRootPermissionProfileModificationParamsType",
      }),
    }).annotate({
      title: "AdditionalWritableRootPermissionProfileModificationParams",
      description: "Additional concrete directory that should be writable.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartParams__SandboxPolicy =
  | { readonly type: "dangerFullAccess" }
  | { readonly networkAccess?: boolean; readonly type: "readOnly" }
  | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
  | {
      readonly excludeSlashTmp?: boolean;
      readonly excludeTmpdirEnvVar?: boolean;
      readonly networkAccess?: boolean;
      readonly type: "workspaceWrite";
      readonly writableRoots?: ReadonlyArray<V2TurnStartParams__AbsolutePathBuf>;
    };
export const V2TurnStartParams__SandboxPolicy = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("dangerFullAccess").annotate({
        title: "DangerFullAccessSandboxPolicyType",
      }),
    }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
    }).annotate({ title: "ReadOnlySandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(
        Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
      ),
      type: Schema.Literal("externalSandbox").annotate({
        title: "ExternalSandboxSandboxPolicyType",
      }),
    }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
    Schema.Struct({
      excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("workspaceWrite").annotate({ title: "WorkspaceWriteSandboxPolicyType" }),
      writableRoots: Schema.optionalKey(
        Schema.Array(V2TurnStartParams__AbsolutePathBuf).annotate({ default: [] }),
      ),
    }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartParams__Settings = {
  readonly developer_instructions?: string | null;
  readonly model: string;
  readonly reasoning_effort?: V2TurnStartParams__ReasoningEffort | null;
};
export const V2TurnStartParams__Settings = Schema.Struct({
  developer_instructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  model: Schema.String,
  reasoning_effort: Schema.optionalKey(
    Schema.Union([V2TurnStartParams__ReasoningEffort, Schema.Null]),
  ),
}).annotate({ description: "Settings for a collaboration mode." });

export type V2TurnStartParams__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2TurnStartParams__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2TurnStartParams__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2TurnStartParams__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartResponse__CommandAction =
  | {
      readonly command: string;
      readonly name: string;
      readonly path: V2TurnStartResponse__AbsolutePathBuf;
      readonly type: "read";
    }
  | { readonly command: string; readonly path?: string | null; readonly type: "listFiles" }
  | {
      readonly command: string;
      readonly path?: string | null;
      readonly query?: string | null;
      readonly type: "search";
    }
  | { readonly command: string; readonly type: "unknown" };
export const V2TurnStartResponse__CommandAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      name: Schema.String,
      path: V2TurnStartResponse__AbsolutePathBuf,
      type: Schema.Literal("read").annotate({ title: "ReadCommandActionType" }),
    }).annotate({ title: "ReadCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("listFiles").annotate({ title: "ListFilesCommandActionType" }),
    }).annotate({ title: "ListFilesCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      path: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      query: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("search").annotate({ title: "SearchCommandActionType" }),
    }).annotate({ title: "SearchCommandAction" }),
    Schema.Struct({
      command: Schema.String,
      type: Schema.Literal("unknown").annotate({ title: "UnknownCommandActionType" }),
    }).annotate({ title: "UnknownCommandAction" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartResponse__CollabAgentState = {
  readonly message?: string | null;
  readonly status: V2TurnStartResponse__CollabAgentStatus;
};
export const V2TurnStartResponse__CollabAgentState = Schema.Struct({
  message: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2TurnStartResponse__CollabAgentStatus,
});

export type V2TurnStartResponse__MemoryCitation = {
  readonly entries: ReadonlyArray<V2TurnStartResponse__MemoryCitationEntry>;
  readonly threadIds: ReadonlyArray<string>;
};
export const V2TurnStartResponse__MemoryCitation = Schema.Struct({
  entries: Schema.Array(V2TurnStartResponse__MemoryCitationEntry),
  threadIds: Schema.Array(Schema.String),
});

export type V2TurnStartResponse__CodexErrorInfo =
  | "contextWindowExceeded"
  | "usageLimitExceeded"
  | "serverOverloaded"
  | "cyberPolicy"
  | "internalServerError"
  | "unauthorized"
  | "badRequest"
  | "threadRollbackFailed"
  | "sandboxError"
  | "other"
  | { readonly httpConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamConnectionFailed: { readonly httpStatusCode?: number | null } }
  | { readonly responseStreamDisconnected: { readonly httpStatusCode?: number | null } }
  | { readonly responseTooManyFailedAttempts: { readonly httpStatusCode?: number | null } }
  | {
      readonly activeTurnNotSteerable: {
        readonly turnKind: V2TurnStartResponse__NonSteerableTurnKind;
      };
    };
export const V2TurnStartResponse__CodexErrorInfo = Schema.Union(
  [
    Schema.Literals([
      "contextWindowExceeded",
      "usageLimitExceeded",
      "serverOverloaded",
      "cyberPolicy",
      "internalServerError",
      "unauthorized",
      "badRequest",
      "threadRollbackFailed",
      "sandboxError",
      "other",
    ]),
    Schema.Struct({
      httpConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({ title: "HttpConnectionFailedCodexErrorInfo" }),
    Schema.Struct({
      responseStreamConnectionFailed: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamConnectionFailedCodexErrorInfo",
      description: "Failed to connect to the response SSE stream.",
    }),
    Schema.Struct({
      responseStreamDisconnected: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseStreamDisconnectedCodexErrorInfo",
      description:
        "The response SSE stream disconnected in the middle of a turn before completion.",
    }),
    Schema.Struct({
      responseTooManyFailedAttempts: Schema.Struct({
        httpStatusCode: Schema.optionalKey(
          Schema.Union([
            Schema.Number.annotate({ format: "uint16" })
              .check(Schema.isInt())
              .check(Schema.isGreaterThanOrEqualTo(0)),
            Schema.Null,
          ]),
        ),
      }),
    }).annotate({
      title: "ResponseTooManyFailedAttemptsCodexErrorInfo",
      description: "Reached the retry limit for responses.",
    }),
    Schema.Struct({
      activeTurnNotSteerable: Schema.Struct({
        turnKind: V2TurnStartResponse__NonSteerableTurnKind,
      }),
    }).annotate({
      title: "ActiveTurnNotSteerableCodexErrorInfo",
      description:
        "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  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.",
});

export type V2TurnStartResponse__FileUpdateChange = {
  readonly diff: string;
  readonly kind: V2TurnStartResponse__PatchChangeKind;
  readonly path: string;
};
export const V2TurnStartResponse__FileUpdateChange = Schema.Struct({
  diff: Schema.String,
  kind: V2TurnStartResponse__PatchChangeKind,
  path: Schema.String,
});

export type V2TurnStartResponse__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2TurnStartResponse__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2TurnStartResponse__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2TurnStartResponse__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnSteerParams__UserInput =
  | {
      readonly text: string;
      readonly text_elements?: ReadonlyArray<V2TurnSteerParams__TextElement>;
      readonly type: "text";
    }
  | { readonly type: "image"; readonly url: string }
  | { readonly path: string; readonly type: "localImage" }
  | { readonly name: string; readonly path: string; readonly type: "skill" }
  | { readonly name: string; readonly path: string; readonly type: "mention" };
export const V2TurnSteerParams__UserInput = Schema.Union(
  [
    Schema.Struct({
      text: Schema.String,
      text_elements: Schema.optionalKey(
        Schema.Array(V2TurnSteerParams__TextElement).annotate({
          description: "UI-defined spans within `text` used to render or persist special elements.",
          default: [],
        }),
      ),
      type: Schema.Literal("text").annotate({ title: "TextUserInputType" }),
    }).annotate({ title: "TextUserInput" }),
    Schema.Struct({
      type: Schema.Literal("image").annotate({ title: "ImageUserInputType" }),
      url: Schema.String,
    }).annotate({ title: "ImageUserInput" }),
    Schema.Struct({
      path: Schema.String,
      type: Schema.Literal("localImage").annotate({ title: "LocalImageUserInputType" }),
    }).annotate({ title: "LocalImageUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("skill").annotate({ title: "SkillUserInputType" }),
    }).annotate({ title: "SkillUserInput" }),
    Schema.Struct({
      name: Schema.String,
      path: Schema.String,
      type: Schema.Literal("mention").annotate({ title: "MentionUserInputType" }),
    }).annotate({ title: "MentionUserInput" }),
  ],
  { mode: "oneOf" },
);

export type ApplyPatchApprovalResponse__ReviewDecision =
  | "approved"
  | {
      readonly approved_execpolicy_amendment: {
        readonly proposed_execpolicy_amendment: ReadonlyArray<string>;
      };
    }
  | "approved_for_session"
  | {
      readonly network_policy_amendment: {
        readonly network_policy_amendment: ApplyPatchApprovalResponse__NetworkPolicyAmendment;
      };
    }
  | "denied"
  | "timed_out"
  | "abort";
export const ApplyPatchApprovalResponse__ReviewDecision = Schema.Union(
  [
    Schema.Literal("approved").annotate({
      description: "User has approved this command and the agent should execute it.",
    }),
    Schema.Struct({
      approved_execpolicy_amendment: Schema.Struct({
        proposed_execpolicy_amendment: Schema.Array(Schema.String),
      }),
    }).annotate({
      title: "ApprovedExecpolicyAmendmentReviewDecision",
      description:
        "User has approved this command and wants to apply the proposed execpolicy amendment so future matching commands are permitted.",
    }),
    Schema.Literal("approved_for_session").annotate({
      description:
        "User has approved this request and wants future prompts in the same session-scoped approval cache to be automatically approved for the remainder of the session.",
    }),
    Schema.Struct({
      network_policy_amendment: Schema.Struct({
        network_policy_amendment: ApplyPatchApprovalResponse__NetworkPolicyAmendment,
      }),
    }).annotate({
      title: "NetworkPolicyAmendmentReviewDecision",
      description:
        "User chose to persist a network policy rule (allow/deny) for future requests to the same host.",
    }),
    Schema.Literal("denied").annotate({
      description:
        "User has denied this command and the agent should not execute it, but it should continue the session and try something else.",
    }),
    Schema.Literal("timed_out").annotate({
      description: "Automatic approval review timed out before reaching a decision.",
    }),
    Schema.Literal("abort").annotate({
      description:
        "User has denied this command and the agent should not do anything until the user's next command.",
    }),
  ],
  { mode: "oneOf" },
).annotate({ description: "User's decision in response to an ExecApprovalRequest." });

export type ClientRequest__CommandExecParams = {
  readonly command: ReadonlyArray<string>;
  readonly cwd?: string | null;
  readonly disableOutputCap?: boolean;
  readonly disableTimeout?: boolean;
  readonly env?: { readonly [x: string]: string | null } | null;
  readonly outputBytesCap?: number | null;
  readonly processId?: string | null;
  readonly sandboxPolicy?: ClientRequest__SandboxPolicy | null;
  readonly size?: ClientRequest__CommandExecTerminalSize | null;
  readonly streamStdin?: boolean;
  readonly streamStdoutStderr?: boolean;
  readonly timeoutMs?: number | null;
  readonly tty?: boolean;
};
export const ClientRequest__CommandExecParams = Schema.Struct({
  command: Schema.Array(Schema.String).annotate({
    description: "Command argv vector. Empty arrays are rejected.",
  }),
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional working directory. Defaults to the server cwd.",
      }),
      Schema.Null,
    ]),
  ),
  disableOutputCap: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Disable stdout/stderr capture truncation for this request.\n\nCannot be combined with `outputBytesCap`.",
    }),
  ),
  disableTimeout: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Disable the timeout entirely for this request.\n\nCannot be combined with `timeoutMs`.",
    }),
  ),
  env: Schema.optionalKey(
    Schema.Union([
      Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Null])).annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  outputBytesCap: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description:
          "Optional per-stream stdout/stderr capture cap in bytes.\n\nWhen omitted, the server default applies. Cannot be combined with `disableOutputCap`.",
        format: "uint",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  processId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  sandboxPolicy: Schema.optionalKey(
    Schema.Union([ClientRequest__SandboxPolicy, Schema.Null]).annotate({
      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`.",
    }),
  ),
  size: Schema.optionalKey(
    Schema.Union([ClientRequest__CommandExecTerminalSize, Schema.Null]).annotate({
      description: "Optional initial PTY size in character cells. Only valid when `tty` is true.",
    }),
  ),
  streamStdin: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Allow follow-up `command/exec/write` requests to write stdin bytes.\n\nRequires a client-supplied `processId`.",
    }),
  ),
  streamStdoutStderr: Schema.optionalKey(
    Schema.Boolean.annotate({
      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`.",
    }),
  ),
  timeoutMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description:
          "Optional timeout in milliseconds.\n\nWhen omitted, the server default applies. Cannot be combined with `disableTimeout`.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  tty: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "Enable PTY mode.\n\nThis implies `streamStdin` and `streamStdoutStderr`.",
    }),
  ),
}).annotate({
  description:
    "Run a standalone command (argv vector) in the server sandbox without creating a thread or turn.\n\nThe final `command/exec` response is deferred until the process exits and is sent only after all `command/exec/outputDelta` notifications for that connection have been emitted.",
});

export type ClientRequest__FileSystemSandboxEntry = {
  readonly access: ClientRequest__FileSystemAccessMode;
  readonly path: ClientRequest__FileSystemPath;
};
export const ClientRequest__FileSystemSandboxEntry = Schema.Struct({
  access: ClientRequest__FileSystemAccessMode,
  path: ClientRequest__FileSystemPath,
});

export type ClientRequest__FunctionCallOutputBody =
  | string
  | ReadonlyArray<ClientRequest__FunctionCallOutputContentItem>;
export const ClientRequest__FunctionCallOutputBody = Schema.Union([
  Schema.String,
  Schema.Array(ClientRequest__FunctionCallOutputContentItem),
]);

export type ClientRequest__ConfigBatchWriteParams = {
  readonly edits: ReadonlyArray<ClientRequest__ConfigEdit>;
  readonly expectedVersion?: string | null;
  readonly filePath?: string | null;
  readonly reloadUserConfig?: boolean;
};
export const ClientRequest__ConfigBatchWriteParams = Schema.Struct({
  edits: Schema.Array(ClientRequest__ConfigEdit),
  expectedVersion: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  filePath: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Path to the config file to write; defaults to the user's `config.toml` when omitted.",
      }),
      Schema.Null,
    ]),
  ),
  reloadUserConfig: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "When true, hot-reload the updated user config into all loaded threads after writing.",
    }),
  ),
});

export type ClientRequest__PluginShareSaveParams = {
  readonly discoverability?: ClientRequest__PluginShareDiscoverability | null;
  readonly pluginPath: ClientRequest__AbsolutePathBuf;
  readonly remotePluginId?: string | null;
  readonly shareTargets?: ReadonlyArray<ClientRequest__PluginShareTarget> | null;
};
export const ClientRequest__PluginShareSaveParams = Schema.Struct({
  discoverability: Schema.optionalKey(
    Schema.Union([ClientRequest__PluginShareDiscoverability, Schema.Null]),
  ),
  pluginPath: ClientRequest__AbsolutePathBuf,
  remotePluginId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  shareTargets: Schema.optionalKey(
    Schema.Union([Schema.Array(ClientRequest__PluginShareTarget), Schema.Null]),
  ),
});

export type ClientRequest__PluginShareUpdateTargetsParams = {
  readonly remotePluginId: string;
  readonly shareTargets: ReadonlyArray<ClientRequest__PluginShareTarget>;
};
export const ClientRequest__PluginShareUpdateTargetsParams = Schema.Struct({
  remotePluginId: Schema.String,
  shareTargets: Schema.Array(ClientRequest__PluginShareTarget),
});

export type ClientRequest__ExternalAgentConfigMigrationItem = {
  readonly cwd?: string | null;
  readonly description: string;
  readonly details?: ClientRequest__MigrationDetails | null;
  readonly itemType: ClientRequest__ExternalAgentConfigMigrationItemType;
};
export const ClientRequest__ExternalAgentConfigMigrationItem = Schema.Struct({
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Null or empty means home-scoped migration; non-empty means repo-scoped migration.",
      }),
      Schema.Null,
    ]),
  ),
  description: Schema.String,
  details: Schema.optionalKey(Schema.Union([ClientRequest__MigrationDetails, Schema.Null])),
  itemType: ClientRequest__ExternalAgentConfigMigrationItemType,
});

export type ClientRequest__TurnStartParams = {
  readonly approvalPolicy?: ClientRequest__AskForApproval | null;
  readonly approvalsReviewer?: ClientRequest__ApprovalsReviewer | null;
  readonly cwd?: string | null;
  readonly effort?: ClientRequest__ReasoningEffort | null;
  readonly input: ReadonlyArray<ClientRequest__UserInput>;
  readonly model?: string | null;
  readonly outputSchema?: unknown;
  readonly personality?: ClientRequest__Personality | null;
  readonly sandboxPolicy?: ClientRequest__SandboxPolicy | null;
  readonly serviceTier?: string | null;
  readonly summary?: ClientRequest__ReasoningSummary | null;
  readonly threadId: string;
};
export const ClientRequest__TurnStartParams = Schema.Struct({
  approvalPolicy: Schema.optionalKey(
    Schema.Union([ClientRequest__AskForApproval, Schema.Null]).annotate({
      description: "Override the approval policy for this turn and subsequent turns.",
    }),
  ),
  approvalsReviewer: Schema.optionalKey(
    Schema.Union([ClientRequest__ApprovalsReviewer, Schema.Null]).annotate({
      description:
        "Override where approval requests are routed for review on this turn and subsequent turns.",
    }),
  ),
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Override the working directory for this turn and subsequent turns.",
      }),
      Schema.Null,
    ]),
  ),
  effort: Schema.optionalKey(
    Schema.Union([ClientRequest__ReasoningEffort, Schema.Null]).annotate({
      description: "Override the reasoning effort for this turn and subsequent turns.",
    }),
  ),
  input: Schema.Array(ClientRequest__UserInput),
  model: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Override the model for this turn and subsequent turns.",
      }),
      Schema.Null,
    ]),
  ),
  outputSchema: Schema.optionalKey(
    Schema.Unknown.annotate({
      description:
        "Optional JSON Schema used to constrain the final assistant message for this turn.",
    }),
  ),
  personality: Schema.optionalKey(
    Schema.Union([ClientRequest__Personality, Schema.Null]).annotate({
      description: "Override the personality for this turn and subsequent turns.",
    }),
  ),
  sandboxPolicy: Schema.optionalKey(
    Schema.Union([ClientRequest__SandboxPolicy, Schema.Null]).annotate({
      description: "Override the sandbox policy for this turn and subsequent turns.",
    }),
  ),
  serviceTier: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Override the service tier for this turn and subsequent turns.",
      }),
      Schema.Null,
    ]),
  ),
  summary: Schema.optionalKey(
    Schema.Union([ClientRequest__ReasoningSummary, Schema.Null]).annotate({
      description: "Override the reasoning summary for this turn and subsequent turns.",
    }),
  ),
  threadId: Schema.String,
});

export type ClientRequest__TurnSteerParams = {
  readonly expectedTurnId: string;
  readonly input: ReadonlyArray<ClientRequest__UserInput>;
  readonly threadId: string;
};
export const ClientRequest__TurnSteerParams = Schema.Struct({
  expectedTurnId: Schema.String.annotate({
    description:
      "Required active turn id precondition. The request fails when it does not match the currently active turn.",
  }),
  input: Schema.Array(ClientRequest__UserInput),
  threadId: Schema.String,
});

export type CommandExecutionRequestApprovalParams__FileSystemSandboxEntry = {
  readonly access: CommandExecutionRequestApprovalParams__FileSystemAccessMode;
  readonly path: CommandExecutionRequestApprovalParams__FileSystemPath;
};
export const CommandExecutionRequestApprovalParams__FileSystemSandboxEntry = Schema.Struct({
  access: CommandExecutionRequestApprovalParams__FileSystemAccessMode,
  path: CommandExecutionRequestApprovalParams__FileSystemPath,
});

export type CommandExecutionRequestApprovalResponse__CommandExecutionApprovalDecision =
  | "accept"
  | "acceptForSession"
  | {
      readonly acceptWithExecpolicyAmendment: {
        readonly execpolicy_amendment: ReadonlyArray<string>;
      };
    }
  | {
      readonly applyNetworkPolicyAmendment: {
        readonly network_policy_amendment: CommandExecutionRequestApprovalResponse__NetworkPolicyAmendment;
      };
    }
  | "decline"
  | "cancel";
export const CommandExecutionRequestApprovalResponse__CommandExecutionApprovalDecision =
  Schema.Union(
    [
      Schema.Literal("accept").annotate({ description: "User approved the command." }),
      Schema.Literal("acceptForSession").annotate({
        description:
          "User approved the command and future prompts in the same session-scoped approval cache should run without prompting.",
      }),
      Schema.Struct({
        acceptWithExecpolicyAmendment: Schema.Struct({
          execpolicy_amendment: Schema.Array(Schema.String),
        }),
      }).annotate({
        title: "AcceptWithExecpolicyAmendmentCommandExecutionApprovalDecision",
        description:
          "User approved the command, and wants to apply the proposed execpolicy amendment so future matching commands can run without prompting.",
      }),
      Schema.Struct({
        applyNetworkPolicyAmendment: Schema.Struct({
          network_policy_amendment: CommandExecutionRequestApprovalResponse__NetworkPolicyAmendment,
        }),
      }).annotate({
        title: "ApplyNetworkPolicyAmendmentCommandExecutionApprovalDecision",
        description: "User chose a persistent network policy rule (allow/deny) for this host.",
      }),
      Schema.Literal("decline").annotate({
        description: "User denied the command. The agent will continue the turn.",
      }),
      Schema.Literal("cancel").annotate({
        description: "User denied the command. The turn will also be immediately interrupted.",
      }),
    ],
    { mode: "oneOf" },
  );

export type ExecCommandApprovalResponse__ReviewDecision =
  | "approved"
  | {
      readonly approved_execpolicy_amendment: {
        readonly proposed_execpolicy_amendment: ReadonlyArray<string>;
      };
    }
  | "approved_for_session"
  | {
      readonly network_policy_amendment: {
        readonly network_policy_amendment: ExecCommandApprovalResponse__NetworkPolicyAmendment;
      };
    }
  | "denied"
  | "timed_out"
  | "abort";
export const ExecCommandApprovalResponse__ReviewDecision = Schema.Union(
  [
    Schema.Literal("approved").annotate({
      description: "User has approved this command and the agent should execute it.",
    }),
    Schema.Struct({
      approved_execpolicy_amendment: Schema.Struct({
        proposed_execpolicy_amendment: Schema.Array(Schema.String),
      }),
    }).annotate({
      title: "ApprovedExecpolicyAmendmentReviewDecision",
      description:
        "User has approved this command and wants to apply the proposed execpolicy amendment so future matching commands are permitted.",
    }),
    Schema.Literal("approved_for_session").annotate({
      description:
        "User has approved this request and wants future prompts in the same session-scoped approval cache to be automatically approved for the remainder of the session.",
    }),
    Schema.Struct({
      network_policy_amendment: Schema.Struct({
        network_policy_amendment: ExecCommandApprovalResponse__NetworkPolicyAmendment,
      }),
    }).annotate({
      title: "NetworkPolicyAmendmentReviewDecision",
      description:
        "User chose to persist a network policy rule (allow/deny) for future requests to the same host.",
    }),
    Schema.Literal("denied").annotate({
      description:
        "User has denied this command and the agent should not execute it, but it should continue the session and try something else.",
    }),
    Schema.Literal("timed_out").annotate({
      description: "Automatic approval review timed out before reaching a decision.",
    }),
    Schema.Literal("abort").annotate({
      description:
        "User has denied this command and the agent should not do anything until the user's next command.",
    }),
  ],
  { mode: "oneOf" },
).annotate({ description: "User's decision in response to an ExecApprovalRequest." });

export type McpServerElicitationRequestParams__McpElicitationTitledMultiSelectEnumSchema = {
  readonly default?: ReadonlyArray<string> | null;
  readonly description?: string | null;
  readonly items: McpServerElicitationRequestParams__McpElicitationTitledEnumItems;
  readonly maxItems?: number | null;
  readonly minItems?: number | null;
  readonly title?: string | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationArrayType;
};
export const McpServerElicitationRequestParams__McpElicitationTitledMultiSelectEnumSchema =
  Schema.Struct({
    default: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
    description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    items: McpServerElicitationRequestParams__McpElicitationTitledEnumItems,
    maxItems: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "uint64" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
        Schema.Null,
      ]),
    ),
    minItems: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "uint64" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
        Schema.Null,
      ]),
    ),
    title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    type: McpServerElicitationRequestParams__McpElicitationArrayType,
  });

export type McpServerElicitationRequestParams__McpElicitationUntitledMultiSelectEnumSchema = {
  readonly default?: ReadonlyArray<string> | null;
  readonly description?: string | null;
  readonly items: McpServerElicitationRequestParams__McpElicitationUntitledEnumItems;
  readonly maxItems?: number | null;
  readonly minItems?: number | null;
  readonly title?: string | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationArrayType;
};
export const McpServerElicitationRequestParams__McpElicitationUntitledMultiSelectEnumSchema =
  Schema.Struct({
    default: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
    description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    items: McpServerElicitationRequestParams__McpElicitationUntitledEnumItems,
    maxItems: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "uint64" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
        Schema.Null,
      ]),
    ),
    minItems: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "uint64" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
        Schema.Null,
      ]),
    ),
    title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    type: McpServerElicitationRequestParams__McpElicitationArrayType,
  });

export type McpServerElicitationRequestParams__McpElicitationSingleSelectEnumSchema =
  | McpServerElicitationRequestParams__McpElicitationUntitledSingleSelectEnumSchema
  | McpServerElicitationRequestParams__McpElicitationTitledSingleSelectEnumSchema;
export const McpServerElicitationRequestParams__McpElicitationSingleSelectEnumSchema = Schema.Union(
  [
    McpServerElicitationRequestParams__McpElicitationUntitledSingleSelectEnumSchema,
    McpServerElicitationRequestParams__McpElicitationTitledSingleSelectEnumSchema,
  ],
);

export type PermissionsRequestApprovalParams__FileSystemSandboxEntry = {
  readonly access: PermissionsRequestApprovalParams__FileSystemAccessMode;
  readonly path: PermissionsRequestApprovalParams__FileSystemPath;
};
export const PermissionsRequestApprovalParams__FileSystemSandboxEntry = Schema.Struct({
  access: PermissionsRequestApprovalParams__FileSystemAccessMode,
  path: PermissionsRequestApprovalParams__FileSystemPath,
});

export type PermissionsRequestApprovalResponse__FileSystemSandboxEntry = {
  readonly access: PermissionsRequestApprovalResponse__FileSystemAccessMode;
  readonly path: PermissionsRequestApprovalResponse__FileSystemPath;
};
export const PermissionsRequestApprovalResponse__FileSystemSandboxEntry = Schema.Struct({
  access: PermissionsRequestApprovalResponse__FileSystemAccessMode,
  path: PermissionsRequestApprovalResponse__FileSystemPath,
});

export type ServerNotification__AppInfo = {
  readonly appMetadata?: ServerNotification__AppMetadata | null;
  readonly branding?: ServerNotification__AppBranding | null;
  readonly description?: string | null;
  readonly distributionChannel?: string | null;
  readonly id: string;
  readonly installUrl?: string | null;
  readonly isAccessible?: boolean;
  readonly isEnabled?: boolean;
  readonly labels?: { readonly [x: string]: string } | null;
  readonly logoUrl?: string | null;
  readonly logoUrlDark?: string | null;
  readonly name: string;
  readonly pluginDisplayNames?: ReadonlyArray<string>;
};
export const ServerNotification__AppInfo = Schema.Struct({
  appMetadata: Schema.optionalKey(Schema.Union([ServerNotification__AppMetadata, Schema.Null])),
  branding: Schema.optionalKey(Schema.Union([ServerNotification__AppBranding, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  distributionChannel: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  id: Schema.String,
  installUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  isAccessible: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  isEnabled: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Whether this app is enabled in config.toml. Example: ```toml [apps.bad_app] enabled = false ```",
      default: true,
    }),
  ),
  labels: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]),
  ),
  logoUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  logoUrlDark: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  pluginDisplayNames: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
}).annotate({ description: "EXPERIMENTAL - app metadata returned by app-list APIs." });

export type ServerNotification__FileSystemSandboxEntry = {
  readonly access: ServerNotification__FileSystemAccessMode;
  readonly path: ServerNotification__FileSystemPath;
};
export const ServerNotification__FileSystemSandboxEntry = Schema.Struct({
  access: ServerNotification__FileSystemAccessMode,
  path: ServerNotification__FileSystemPath,
});

export type ServerNotification__FuzzyFileSearchSessionUpdatedNotification = {
  readonly files: ReadonlyArray<ServerNotification__FuzzyFileSearchResult>;
  readonly query: string;
  readonly sessionId: string;
};
export const ServerNotification__FuzzyFileSearchSessionUpdatedNotification = Schema.Struct({
  files: Schema.Array(ServerNotification__FuzzyFileSearchResult),
  query: Schema.String,
  sessionId: Schema.String,
});

export type ServerNotification__HookRunSummary = {
  readonly completedAt?: number | null;
  readonly displayOrder: number;
  readonly durationMs?: number | null;
  readonly entries: ReadonlyArray<ServerNotification__HookOutputEntry>;
  readonly eventName: ServerNotification__HookEventName;
  readonly executionMode: ServerNotification__HookExecutionMode;
  readonly handlerType: ServerNotification__HookHandlerType;
  readonly id: string;
  readonly scope: ServerNotification__HookScope;
  readonly source?:
    | "system"
    | "user"
    | "project"
    | "mdm"
    | "sessionFlags"
    | "plugin"
    | "cloudRequirements"
    | "legacyManagedConfigFile"
    | "legacyManagedConfigMdm"
    | "unknown";
  readonly sourcePath: ServerNotification__AbsolutePathBuf;
  readonly startedAt: number;
  readonly status: ServerNotification__HookRunStatus;
  readonly statusMessage?: string | null;
};
export const ServerNotification__HookRunSummary = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  displayOrder: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  durationMs: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  entries: Schema.Array(ServerNotification__HookOutputEntry),
  eventName: ServerNotification__HookEventName,
  executionMode: ServerNotification__HookExecutionMode,
  handlerType: ServerNotification__HookHandlerType,
  id: Schema.String,
  scope: ServerNotification__HookScope,
  source: Schema.optionalKey(
    Schema.Literals([
      "system",
      "user",
      "project",
      "mdm",
      "sessionFlags",
      "plugin",
      "cloudRequirements",
      "legacyManagedConfigFile",
      "legacyManagedConfigMdm",
      "unknown",
    ]).annotate({ default: "unknown" }),
  ),
  sourcePath: ServerNotification__AbsolutePathBuf,
  startedAt: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  status: ServerNotification__HookRunStatus,
  statusMessage: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ServerNotification__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: ServerNotification__CodexErrorInfo | null;
  readonly message: string;
};
export const ServerNotification__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([ServerNotification__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type ServerNotification__FileChangePatchUpdatedNotification = {
  readonly changes: ReadonlyArray<ServerNotification__FileUpdateChange>;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__FileChangePatchUpdatedNotification = Schema.Struct({
  changes: Schema.Array(ServerNotification__FileUpdateChange),
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__AccountRateLimitsUpdatedNotification = {
  readonly rateLimits: ServerNotification__RateLimitSnapshot;
};
export const ServerNotification__AccountRateLimitsUpdatedNotification = Schema.Struct({
  rateLimits: ServerNotification__RateLimitSnapshot,
});

export type ServerNotification__ThreadItem =
  | {
      readonly content: ReadonlyArray<ServerNotification__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<ServerNotification__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: ServerNotification__MemoryCitation | null;
      readonly phase?: ServerNotification__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<ServerNotification__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: ServerNotification__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<ServerNotification__FileUpdateChange>;
      readonly id: string;
      readonly status: ServerNotification__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: ServerNotification__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: ServerNotification__McpToolCallResult | null;
      readonly server: string;
      readonly status: ServerNotification__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<ServerNotification__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: ServerNotification__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: ServerNotification__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: ServerNotification__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: ServerNotification__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: ServerNotification__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: ServerNotification__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const ServerNotification__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(ServerNotification__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(ServerNotification__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([ServerNotification__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([ServerNotification__MessagePhase, Schema.Null])),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(ServerNotification__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: ServerNotification__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(ServerNotification__FileUpdateChange),
      id: Schema.String,
      status: ServerNotification__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(Schema.Union([ServerNotification__McpToolCallError, Schema.Null])),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([ServerNotification__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: ServerNotification__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(ServerNotification__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: ServerNotification__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(Schema.String, ServerNotification__CollabAgentState).annotate({
        description: "Last known status of the target agents, when available.",
      }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([ServerNotification__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(Schema.Union([ServerNotification__WebSearchAction, Schema.Null])),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: ServerNotification__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([ServerNotification__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__ConfigWarningNotification = {
  readonly details?: string | null;
  readonly path?: string | null;
  readonly range?: ServerNotification__TextRange | null;
  readonly summary: string;
};
export const ServerNotification__ConfigWarningNotification = Schema.Struct({
  details: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional extra guidance or error details." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional path to the config file that triggered the warning.",
      }),
      Schema.Null,
    ]),
  ),
  range: Schema.optionalKey(
    Schema.Union([ServerNotification__TextRange, Schema.Null]).annotate({
      description: "Optional range for the error location inside the config file.",
    }),
  ),
  summary: Schema.String.annotate({ description: "Concise summary of the warning." }),
});

export type ServerNotification__ThreadStatusChangedNotification = {
  readonly status: ServerNotification__ThreadStatus;
  readonly threadId: string;
};
export const ServerNotification__ThreadStatusChangedNotification = Schema.Struct({
  status: ServerNotification__ThreadStatus,
  threadId: Schema.String,
});

export type ServerNotification__ThreadGoalUpdatedNotification = {
  readonly goal: ServerNotification__ThreadGoal;
  readonly threadId: string;
  readonly turnId?: string | null;
};
export const ServerNotification__ThreadGoalUpdatedNotification = Schema.Struct({
  goal: ServerNotification__ThreadGoal,
  threadId: Schema.String,
  turnId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ServerNotification__ThreadTokenUsageUpdatedNotification = {
  readonly threadId: string;
  readonly tokenUsage: ServerNotification__ThreadTokenUsage;
  readonly turnId: string;
};
export const ServerNotification__ThreadTokenUsageUpdatedNotification = Schema.Struct({
  threadId: Schema.String,
  tokenUsage: ServerNotification__ThreadTokenUsage,
  turnId: Schema.String,
});

export type ServerNotification__TurnPlanUpdatedNotification = {
  readonly explanation?: string | null;
  readonly plan: ReadonlyArray<ServerNotification__TurnPlanStep>;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__TurnPlanUpdatedNotification = Schema.Struct({
  explanation: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  plan: Schema.Array(ServerNotification__TurnPlanStep),
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerRequest__FileSystemSandboxEntry = {
  readonly access: ServerRequest__FileSystemAccessMode;
  readonly path: ServerRequest__FileSystemPath;
};
export const ServerRequest__FileSystemSandboxEntry = Schema.Struct({
  access: ServerRequest__FileSystemAccessMode,
  path: ServerRequest__FileSystemPath,
});

export type ServerRequest__McpElicitationTitledMultiSelectEnumSchema = {
  readonly default?: ReadonlyArray<string> | null;
  readonly description?: string | null;
  readonly items: ServerRequest__McpElicitationTitledEnumItems;
  readonly maxItems?: number | null;
  readonly minItems?: number | null;
  readonly title?: string | null;
  readonly type: ServerRequest__McpElicitationArrayType;
};
export const ServerRequest__McpElicitationTitledMultiSelectEnumSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  items: ServerRequest__McpElicitationTitledEnumItems,
  maxItems: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint64" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  minItems: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint64" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: ServerRequest__McpElicitationArrayType,
});

export type ServerRequest__McpElicitationUntitledMultiSelectEnumSchema = {
  readonly default?: ReadonlyArray<string> | null;
  readonly description?: string | null;
  readonly items: ServerRequest__McpElicitationUntitledEnumItems;
  readonly maxItems?: number | null;
  readonly minItems?: number | null;
  readonly title?: string | null;
  readonly type: ServerRequest__McpElicitationArrayType;
};
export const ServerRequest__McpElicitationUntitledMultiSelectEnumSchema = Schema.Struct({
  default: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  items: ServerRequest__McpElicitationUntitledEnumItems,
  maxItems: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint64" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  minItems: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint64" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  title: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  type: ServerRequest__McpElicitationArrayType,
});

export type ServerRequest__McpElicitationSingleSelectEnumSchema =
  | ServerRequest__McpElicitationUntitledSingleSelectEnumSchema
  | ServerRequest__McpElicitationTitledSingleSelectEnumSchema;
export const ServerRequest__McpElicitationSingleSelectEnumSchema = Schema.Union([
  ServerRequest__McpElicitationUntitledSingleSelectEnumSchema,
  ServerRequest__McpElicitationTitledSingleSelectEnumSchema,
]);

export type ServerRequest__CommandExecutionRequestApprovalParams = {
  readonly approvalId?: string | null;
  readonly command?: string | null;
  readonly commandActions?: ReadonlyArray<ServerRequest__CommandAction> | null;
  readonly cwd?: ServerRequest__AbsolutePathBuf | null;
  readonly itemId: string;
  readonly networkApprovalContext?: ServerRequest__NetworkApprovalContext | null;
  readonly proposedExecpolicyAmendment?: ReadonlyArray<string> | null;
  readonly proposedNetworkPolicyAmendments?: ReadonlyArray<ServerRequest__NetworkPolicyAmendment> | null;
  readonly reason?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerRequest__CommandExecutionRequestApprovalParams = Schema.Struct({
  approvalId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Unique identifier for this specific approval callback.\n\nFor regular shell/unified_exec approvals, this is null.\n\nFor zsh-exec-bridge subcommand approvals, multiple callbacks can belong to one parent `itemId`, so `approvalId` is a distinct opaque callback id (a UUID) used to disambiguate routing.",
      }),
      Schema.Null,
    ]),
  ),
  command: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "The command to be executed." }),
      Schema.Null,
    ]),
  ),
  commandActions: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ServerRequest__CommandAction).annotate({
        description: "Best-effort parsed command actions for friendly display.",
      }),
      Schema.Null,
    ]),
  ),
  cwd: Schema.optionalKey(
    Schema.Union([ServerRequest__AbsolutePathBuf, Schema.Null]).annotate({
      description: "The command's working directory.",
    }),
  ),
  itemId: Schema.String,
  networkApprovalContext: Schema.optionalKey(
    Schema.Union([ServerRequest__NetworkApprovalContext, Schema.Null]).annotate({
      description: "Optional context for a managed-network approval prompt.",
    }),
  ),
  proposedExecpolicyAmendment: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Optional proposed execpolicy amendment to allow similar commands without prompting.",
      }),
      Schema.Null,
    ]),
  ),
  proposedNetworkPolicyAmendments: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ServerRequest__NetworkPolicyAmendment).annotate({
        description:
          "Optional proposed network policy amendments (allow/deny host) for future requests.",
      }),
      Schema.Null,
    ]),
  ),
  reason: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional explanatory reason (e.g. request for network access).",
      }),
      Schema.Null,
    ]),
  ),
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerRequest__ToolRequestUserInputParams = {
  readonly itemId: string;
  readonly questions: ReadonlyArray<ServerRequest__ToolRequestUserInputQuestion>;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerRequest__ToolRequestUserInputParams = Schema.Struct({
  itemId: Schema.String,
  questions: Schema.Array(ServerRequest__ToolRequestUserInputQuestion),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ description: "EXPERIMENTAL. Params sent with a request_user_input event." });

export type V2AppListUpdatedNotification__AppInfo = {
  readonly appMetadata?: V2AppListUpdatedNotification__AppMetadata | null;
  readonly branding?: V2AppListUpdatedNotification__AppBranding | null;
  readonly description?: string | null;
  readonly distributionChannel?: string | null;
  readonly id: string;
  readonly installUrl?: string | null;
  readonly isAccessible?: boolean;
  readonly isEnabled?: boolean;
  readonly labels?: { readonly [x: string]: string } | null;
  readonly logoUrl?: string | null;
  readonly logoUrlDark?: string | null;
  readonly name: string;
  readonly pluginDisplayNames?: ReadonlyArray<string>;
};
export const V2AppListUpdatedNotification__AppInfo = Schema.Struct({
  appMetadata: Schema.optionalKey(
    Schema.Union([V2AppListUpdatedNotification__AppMetadata, Schema.Null]),
  ),
  branding: Schema.optionalKey(
    Schema.Union([V2AppListUpdatedNotification__AppBranding, Schema.Null]),
  ),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  distributionChannel: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  id: Schema.String,
  installUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  isAccessible: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  isEnabled: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Whether this app is enabled in config.toml. Example: ```toml [apps.bad_app] enabled = false ```",
      default: true,
    }),
  ),
  labels: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]),
  ),
  logoUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  logoUrlDark: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  pluginDisplayNames: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
}).annotate({ description: "EXPERIMENTAL - app metadata returned by app-list APIs." });

export type V2AppsListResponse__AppInfo = {
  readonly appMetadata?: V2AppsListResponse__AppMetadata | null;
  readonly branding?: V2AppsListResponse__AppBranding | null;
  readonly description?: string | null;
  readonly distributionChannel?: string | null;
  readonly id: string;
  readonly installUrl?: string | null;
  readonly isAccessible?: boolean;
  readonly isEnabled?: boolean;
  readonly labels?: { readonly [x: string]: string } | null;
  readonly logoUrl?: string | null;
  readonly logoUrlDark?: string | null;
  readonly name: string;
  readonly pluginDisplayNames?: ReadonlyArray<string>;
};
export const V2AppsListResponse__AppInfo = Schema.Struct({
  appMetadata: Schema.optionalKey(Schema.Union([V2AppsListResponse__AppMetadata, Schema.Null])),
  branding: Schema.optionalKey(Schema.Union([V2AppsListResponse__AppBranding, Schema.Null])),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  distributionChannel: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  id: Schema.String,
  installUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  isAccessible: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  isEnabled: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Whether this app is enabled in config.toml. Example: ```toml [apps.bad_app] enabled = false ```",
      default: true,
    }),
  ),
  labels: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]),
  ),
  logoUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  logoUrlDark: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  pluginDisplayNames: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
}).annotate({ description: "EXPERIMENTAL - app metadata returned by app-list APIs." });

export type V2CommandExecParams__FileSystemSandboxEntry = {
  readonly access: V2CommandExecParams__FileSystemAccessMode;
  readonly path: V2CommandExecParams__FileSystemPath;
};
export const V2CommandExecParams__FileSystemSandboxEntry = Schema.Struct({
  access: V2CommandExecParams__FileSystemAccessMode,
  path: V2CommandExecParams__FileSystemPath,
});

export type V2ConfigReadResponse__ConfigLayer = {
  readonly config: unknown;
  readonly disabledReason?: string | null;
  readonly name: V2ConfigReadResponse__ConfigLayerSource;
  readonly version: string;
};
export const V2ConfigReadResponse__ConfigLayer = Schema.Struct({
  config: Schema.Unknown,
  disabledReason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: V2ConfigReadResponse__ConfigLayerSource,
  version: Schema.String,
});

export type V2ConfigReadResponse__ConfigLayerMetadata = {
  readonly name: V2ConfigReadResponse__ConfigLayerSource;
  readonly version: string;
};
export const V2ConfigReadResponse__ConfigLayerMetadata = Schema.Struct({
  name: V2ConfigReadResponse__ConfigLayerSource,
  version: Schema.String,
});

export type V2ConfigReadResponse__ToolsV2 = {
  readonly view_image?: boolean | null;
  readonly web_search?: V2ConfigReadResponse__WebSearchToolConfig | null;
};
export const V2ConfigReadResponse__ToolsV2 = Schema.Struct({
  view_image: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  web_search: Schema.optionalKey(
    Schema.Union([V2ConfigReadResponse__WebSearchToolConfig, Schema.Null]),
  ),
});

export type V2ConfigWriteResponse__ConfigLayerMetadata = {
  readonly name: V2ConfigWriteResponse__ConfigLayerSource;
  readonly version: string;
};
export const V2ConfigWriteResponse__ConfigLayerMetadata = Schema.Struct({
  name: V2ConfigWriteResponse__ConfigLayerSource,
  version: Schema.String,
});

export type V2ErrorNotification__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ErrorNotification__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ErrorNotification__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ErrorNotification__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ExternalAgentConfigDetectResponse__ExternalAgentConfigMigrationItem = {
  readonly cwd?: string | null;
  readonly description: string;
  readonly details?: V2ExternalAgentConfigDetectResponse__MigrationDetails | null;
  readonly itemType: V2ExternalAgentConfigDetectResponse__ExternalAgentConfigMigrationItemType;
};
export const V2ExternalAgentConfigDetectResponse__ExternalAgentConfigMigrationItem = Schema.Struct({
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Null or empty means home-scoped migration; non-empty means repo-scoped migration.",
      }),
      Schema.Null,
    ]),
  ),
  description: Schema.String,
  details: Schema.optionalKey(
    Schema.Union([V2ExternalAgentConfigDetectResponse__MigrationDetails, Schema.Null]),
  ),
  itemType: V2ExternalAgentConfigDetectResponse__ExternalAgentConfigMigrationItemType,
});

export type V2ExternalAgentConfigImportParams__ExternalAgentConfigMigrationItem = {
  readonly cwd?: string | null;
  readonly description: string;
  readonly details?: V2ExternalAgentConfigImportParams__MigrationDetails | null;
  readonly itemType: V2ExternalAgentConfigImportParams__ExternalAgentConfigMigrationItemType;
};
export const V2ExternalAgentConfigImportParams__ExternalAgentConfigMigrationItem = Schema.Struct({
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Null or empty means home-scoped migration; non-empty means repo-scoped migration.",
      }),
      Schema.Null,
    ]),
  ),
  description: Schema.String,
  details: Schema.optionalKey(
    Schema.Union([V2ExternalAgentConfigImportParams__MigrationDetails, Schema.Null]),
  ),
  itemType: V2ExternalAgentConfigImportParams__ExternalAgentConfigMigrationItemType,
});

export type V2HookCompletedNotification__HookRunSummary = {
  readonly completedAt?: number | null;
  readonly displayOrder: number;
  readonly durationMs?: number | null;
  readonly entries: ReadonlyArray<V2HookCompletedNotification__HookOutputEntry>;
  readonly eventName: V2HookCompletedNotification__HookEventName;
  readonly executionMode: V2HookCompletedNotification__HookExecutionMode;
  readonly handlerType: V2HookCompletedNotification__HookHandlerType;
  readonly id: string;
  readonly scope: V2HookCompletedNotification__HookScope;
  readonly source?:
    | "system"
    | "user"
    | "project"
    | "mdm"
    | "sessionFlags"
    | "plugin"
    | "cloudRequirements"
    | "legacyManagedConfigFile"
    | "legacyManagedConfigMdm"
    | "unknown";
  readonly sourcePath: V2HookCompletedNotification__AbsolutePathBuf;
  readonly startedAt: number;
  readonly status: V2HookCompletedNotification__HookRunStatus;
  readonly statusMessage?: string | null;
};
export const V2HookCompletedNotification__HookRunSummary = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  displayOrder: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  durationMs: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  entries: Schema.Array(V2HookCompletedNotification__HookOutputEntry),
  eventName: V2HookCompletedNotification__HookEventName,
  executionMode: V2HookCompletedNotification__HookExecutionMode,
  handlerType: V2HookCompletedNotification__HookHandlerType,
  id: Schema.String,
  scope: V2HookCompletedNotification__HookScope,
  source: Schema.optionalKey(
    Schema.Literals([
      "system",
      "user",
      "project",
      "mdm",
      "sessionFlags",
      "plugin",
      "cloudRequirements",
      "legacyManagedConfigFile",
      "legacyManagedConfigMdm",
      "unknown",
    ]).annotate({ default: "unknown" }),
  ),
  sourcePath: V2HookCompletedNotification__AbsolutePathBuf,
  startedAt: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  status: V2HookCompletedNotification__HookRunStatus,
  statusMessage: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2HooksListResponse__HooksListEntry = {
  readonly cwd: string;
  readonly errors: ReadonlyArray<V2HooksListResponse__HookErrorInfo>;
  readonly hooks: ReadonlyArray<V2HooksListResponse__HookMetadata>;
  readonly warnings: ReadonlyArray<string>;
};
export const V2HooksListResponse__HooksListEntry = Schema.Struct({
  cwd: Schema.String,
  errors: Schema.Array(V2HooksListResponse__HookErrorInfo),
  hooks: Schema.Array(V2HooksListResponse__HookMetadata),
  warnings: Schema.Array(Schema.String),
});

export type V2HookStartedNotification__HookRunSummary = {
  readonly completedAt?: number | null;
  readonly displayOrder: number;
  readonly durationMs?: number | null;
  readonly entries: ReadonlyArray<V2HookStartedNotification__HookOutputEntry>;
  readonly eventName: V2HookStartedNotification__HookEventName;
  readonly executionMode: V2HookStartedNotification__HookExecutionMode;
  readonly handlerType: V2HookStartedNotification__HookHandlerType;
  readonly id: string;
  readonly scope: V2HookStartedNotification__HookScope;
  readonly source?:
    | "system"
    | "user"
    | "project"
    | "mdm"
    | "sessionFlags"
    | "plugin"
    | "cloudRequirements"
    | "legacyManagedConfigFile"
    | "legacyManagedConfigMdm"
    | "unknown";
  readonly sourcePath: V2HookStartedNotification__AbsolutePathBuf;
  readonly startedAt: number;
  readonly status: V2HookStartedNotification__HookRunStatus;
  readonly statusMessage?: string | null;
};
export const V2HookStartedNotification__HookRunSummary = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  displayOrder: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  durationMs: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
  entries: Schema.Array(V2HookStartedNotification__HookOutputEntry),
  eventName: V2HookStartedNotification__HookEventName,
  executionMode: V2HookStartedNotification__HookExecutionMode,
  handlerType: V2HookStartedNotification__HookHandlerType,
  id: Schema.String,
  scope: V2HookStartedNotification__HookScope,
  source: Schema.optionalKey(
    Schema.Literals([
      "system",
      "user",
      "project",
      "mdm",
      "sessionFlags",
      "plugin",
      "cloudRequirements",
      "legacyManagedConfigFile",
      "legacyManagedConfigMdm",
      "unknown",
    ]).annotate({ default: "unknown" }),
  ),
  sourcePath: V2HookStartedNotification__AbsolutePathBuf,
  startedAt: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  status: V2HookStartedNotification__HookRunStatus,
  statusMessage: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ItemCompletedNotification__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ItemCompletedNotification__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ItemCompletedNotification__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ItemCompletedNotification__MemoryCitation | null;
      readonly phase?: V2ItemCompletedNotification__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ItemCompletedNotification__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ItemCompletedNotification__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ItemCompletedNotification__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ItemCompletedNotification__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ItemCompletedNotification__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ItemCompletedNotification__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ItemCompletedNotification__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ItemCompletedNotification__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ItemCompletedNotification__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: {
        readonly [x: string]: V2ItemCompletedNotification__CollabAgentState;
      };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ItemCompletedNotification__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ItemCompletedNotification__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ItemCompletedNotification__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ItemCompletedNotification__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ItemCompletedNotification__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ItemCompletedNotification__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ItemCompletedNotification__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ItemCompletedNotification__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2ItemCompletedNotification__MessagePhase, Schema.Null]),
      ),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ItemCompletedNotification__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ItemCompletedNotification__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ItemCompletedNotification__FileUpdateChange),
      id: Schema.String,
      status: V2ItemCompletedNotification__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ItemCompletedNotification__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ItemCompletedNotification__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ItemCompletedNotification__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ItemCompletedNotification__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ItemCompletedNotification__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(
        Schema.String,
        V2ItemCompletedNotification__CollabAgentState,
      ).annotate({ description: "Last known status of the target agents, when available." }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ItemCompletedNotification__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ItemCompletedNotification__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ItemCompletedNotification__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ItemCompletedNotification__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ItemGuardianApprovalReviewCompletedNotification__FileSystemSandboxEntry = {
  readonly access: V2ItemGuardianApprovalReviewCompletedNotification__FileSystemAccessMode;
  readonly path: V2ItemGuardianApprovalReviewCompletedNotification__FileSystemPath;
};
export const V2ItemGuardianApprovalReviewCompletedNotification__FileSystemSandboxEntry =
  Schema.Struct({
    access: V2ItemGuardianApprovalReviewCompletedNotification__FileSystemAccessMode,
    path: V2ItemGuardianApprovalReviewCompletedNotification__FileSystemPath,
  });

export type V2ItemGuardianApprovalReviewStartedNotification__FileSystemSandboxEntry = {
  readonly access: V2ItemGuardianApprovalReviewStartedNotification__FileSystemAccessMode;
  readonly path: V2ItemGuardianApprovalReviewStartedNotification__FileSystemPath;
};
export const V2ItemGuardianApprovalReviewStartedNotification__FileSystemSandboxEntry =
  Schema.Struct({
    access: V2ItemGuardianApprovalReviewStartedNotification__FileSystemAccessMode,
    path: V2ItemGuardianApprovalReviewStartedNotification__FileSystemPath,
  });

export type V2ItemStartedNotification__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ItemStartedNotification__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ItemStartedNotification__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ItemStartedNotification__MemoryCitation | null;
      readonly phase?: V2ItemStartedNotification__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ItemStartedNotification__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ItemStartedNotification__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ItemStartedNotification__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ItemStartedNotification__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ItemStartedNotification__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ItemStartedNotification__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ItemStartedNotification__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ItemStartedNotification__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ItemStartedNotification__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ItemStartedNotification__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ItemStartedNotification__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ItemStartedNotification__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ItemStartedNotification__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ItemStartedNotification__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ItemStartedNotification__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ItemStartedNotification__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ItemStartedNotification__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ItemStartedNotification__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2ItemStartedNotification__MessagePhase, Schema.Null]),
      ),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ItemStartedNotification__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ItemStartedNotification__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ItemStartedNotification__FileUpdateChange),
      id: Schema.String,
      status: V2ItemStartedNotification__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ItemStartedNotification__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ItemStartedNotification__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ItemStartedNotification__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ItemStartedNotification__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ItemStartedNotification__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(
        Schema.String,
        V2ItemStartedNotification__CollabAgentState,
      ).annotate({ description: "Last known status of the target agents, when available." }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ItemStartedNotification__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ItemStartedNotification__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ItemStartedNotification__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ItemStartedNotification__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ModelListResponse__Model = {
  readonly additionalSpeedTiers?: ReadonlyArray<string>;
  readonly availabilityNux?: V2ModelListResponse__ModelAvailabilityNux | null;
  readonly defaultReasoningEffort: V2ModelListResponse__ReasoningEffort;
  readonly description: string;
  readonly displayName: string;
  readonly hidden: boolean;
  readonly id: string;
  readonly inputModalities?: ReadonlyArray<V2ModelListResponse__InputModality>;
  readonly isDefault: boolean;
  readonly model: string;
  readonly serviceTiers?: ReadonlyArray<V2ModelListResponse__ModelServiceTier>;
  readonly supportedReasoningEfforts: ReadonlyArray<V2ModelListResponse__ReasoningEffortOption>;
  readonly supportsPersonality?: boolean;
  readonly upgrade?: string | null;
  readonly upgradeInfo?: V2ModelListResponse__ModelUpgradeInfo | null;
};
export const V2ModelListResponse__Model = Schema.Struct({
  additionalSpeedTiers: Schema.optionalKey(
    Schema.Array(Schema.String).annotate({
      description: "Deprecated: use `serviceTiers` instead.",
      default: [],
    }),
  ),
  availabilityNux: Schema.optionalKey(
    Schema.Union([V2ModelListResponse__ModelAvailabilityNux, Schema.Null]),
  ),
  defaultReasoningEffort: V2ModelListResponse__ReasoningEffort,
  description: Schema.String,
  displayName: Schema.String,
  hidden: Schema.Boolean,
  id: Schema.String,
  inputModalities: Schema.optionalKey(
    Schema.Array(V2ModelListResponse__InputModality).annotate({ default: ["text", "image"] }),
  ),
  isDefault: Schema.Boolean,
  model: Schema.String,
  serviceTiers: Schema.optionalKey(
    Schema.Array(V2ModelListResponse__ModelServiceTier).annotate({ default: [] }),
  ),
  supportedReasoningEfforts: Schema.Array(V2ModelListResponse__ReasoningEffortOption),
  supportsPersonality: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
  upgrade: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  upgradeInfo: Schema.optionalKey(
    Schema.Union([V2ModelListResponse__ModelUpgradeInfo, Schema.Null]),
  ),
});

export type V2PluginListResponse__PluginShareContext = {
  readonly creatorAccountUserId?: string | null;
  readonly creatorName?: string | null;
  readonly remotePluginId: string;
  readonly shareTargets?: ReadonlyArray<V2PluginListResponse__PluginSharePrincipal> | null;
  readonly shareUrl?: string | null;
};
export const V2PluginListResponse__PluginShareContext = Schema.Struct({
  creatorAccountUserId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  creatorName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  remotePluginId: Schema.String,
  shareTargets: Schema.optionalKey(
    Schema.Union([Schema.Array(V2PluginListResponse__PluginSharePrincipal), Schema.Null]),
  ),
  shareUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2PluginReadResponse__SkillSummary = {
  readonly description: string;
  readonly enabled: boolean;
  readonly interface?: V2PluginReadResponse__SkillInterface | null;
  readonly name: string;
  readonly path?: V2PluginReadResponse__AbsolutePathBuf | null;
  readonly shortDescription?: string | null;
};
export const V2PluginReadResponse__SkillSummary = Schema.Struct({
  description: Schema.String,
  enabled: Schema.Boolean,
  interface: Schema.optionalKey(Schema.Union([V2PluginReadResponse__SkillInterface, Schema.Null])),
  name: Schema.String,
  path: Schema.optionalKey(Schema.Union([V2PluginReadResponse__AbsolutePathBuf, Schema.Null])),
  shortDescription: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2PluginReadResponse__PluginShareContext = {
  readonly creatorAccountUserId?: string | null;
  readonly creatorName?: string | null;
  readonly remotePluginId: string;
  readonly shareTargets?: ReadonlyArray<V2PluginReadResponse__PluginSharePrincipal> | null;
  readonly shareUrl?: string | null;
};
export const V2PluginReadResponse__PluginShareContext = Schema.Struct({
  creatorAccountUserId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  creatorName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  remotePluginId: Schema.String,
  shareTargets: Schema.optionalKey(
    Schema.Union([Schema.Array(V2PluginReadResponse__PluginSharePrincipal), Schema.Null]),
  ),
  shareUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2PluginShareListResponse__PluginShareContext = {
  readonly creatorAccountUserId?: string | null;
  readonly creatorName?: string | null;
  readonly remotePluginId: string;
  readonly shareTargets?: ReadonlyArray<V2PluginShareListResponse__PluginSharePrincipal> | null;
  readonly shareUrl?: string | null;
};
export const V2PluginShareListResponse__PluginShareContext = Schema.Struct({
  creatorAccountUserId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  creatorName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  remotePluginId: Schema.String,
  shareTargets: Schema.optionalKey(
    Schema.Union([Schema.Array(V2PluginShareListResponse__PluginSharePrincipal), Schema.Null]),
  ),
  shareUrl: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2RawResponseItemCompletedNotification__FunctionCallOutputBody =
  | string
  | ReadonlyArray<V2RawResponseItemCompletedNotification__FunctionCallOutputContentItem>;
export const V2RawResponseItemCompletedNotification__FunctionCallOutputBody = Schema.Union([
  Schema.String,
  Schema.Array(V2RawResponseItemCompletedNotification__FunctionCallOutputContentItem),
]);

export type V2ReviewStartResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ReviewStartResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ReviewStartResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ReviewStartResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ReviewStartResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ReviewStartResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ReviewStartResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ReviewStartResponse__MemoryCitation | null;
      readonly phase?: V2ReviewStartResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ReviewStartResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ReviewStartResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ReviewStartResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ReviewStartResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ReviewStartResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ReviewStartResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ReviewStartResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ReviewStartResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ReviewStartResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ReviewStartResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ReviewStartResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ReviewStartResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ReviewStartResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ReviewStartResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ReviewStartResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ReviewStartResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ReviewStartResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ReviewStartResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([V2ReviewStartResponse__MessagePhase, Schema.Null])),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ReviewStartResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ReviewStartResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ReviewStartResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ReviewStartResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ReviewStartResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ReviewStartResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ReviewStartResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ReviewStartResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ReviewStartResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(Schema.String, V2ReviewStartResponse__CollabAgentState).annotate({
        description: "Last known status of the target agents, when available.",
      }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ReviewStartResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ReviewStartResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ReviewStartResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ReviewStartResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2SkillsListResponse__SkillMetadata = {
  readonly dependencies?: V2SkillsListResponse__SkillDependencies | null;
  readonly description: string;
  readonly enabled: boolean;
  readonly interface?: V2SkillsListResponse__SkillInterface | null;
  readonly name: string;
  readonly path: V2SkillsListResponse__AbsolutePathBuf;
  readonly scope: V2SkillsListResponse__SkillScope;
  readonly shortDescription?: string | null;
};
export const V2SkillsListResponse__SkillMetadata = Schema.Struct({
  dependencies: Schema.optionalKey(
    Schema.Union([V2SkillsListResponse__SkillDependencies, Schema.Null]),
  ),
  description: Schema.String,
  enabled: Schema.Boolean,
  interface: Schema.optionalKey(Schema.Union([V2SkillsListResponse__SkillInterface, Schema.Null])),
  name: Schema.String,
  path: V2SkillsListResponse__AbsolutePathBuf,
  scope: V2SkillsListResponse__SkillScope,
  shortDescription: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Legacy short_description from SKILL.md. Prefer SKILL.json interface.short_description.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ThreadForkResponse__FileSystemSandboxEntry = {
  readonly access: V2ThreadForkResponse__FileSystemAccessMode;
  readonly path: V2ThreadForkResponse__FileSystemPath;
};
export const V2ThreadForkResponse__FileSystemSandboxEntry = Schema.Struct({
  access: V2ThreadForkResponse__FileSystemAccessMode,
  path: V2ThreadForkResponse__FileSystemPath,
});

export type V2ThreadForkResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadForkResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadForkResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadForkResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadForkResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadForkResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadForkResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadForkResponse__MemoryCitation | null;
      readonly phase?: V2ThreadForkResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadForkResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadForkResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadForkResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadForkResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadForkResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadForkResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadForkResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadForkResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadForkResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ThreadForkResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadForkResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadForkResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadForkResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadForkResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadForkResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadForkResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadForkResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadForkResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([V2ThreadForkResponse__MessagePhase, Schema.Null])),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadForkResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadForkResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadForkResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadForkResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadForkResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadForkResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadForkResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadForkResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadForkResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(Schema.String, V2ThreadForkResponse__CollabAgentState).annotate({
        description: "Last known status of the target agents, when available.",
      }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadForkResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadForkResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadForkResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadForkResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadListResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadListResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadListResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadListResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadListResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadListResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadListResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadListResponse__MemoryCitation | null;
      readonly phase?: V2ThreadListResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadListResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadListResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadListResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadListResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadListResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadListResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadListResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadListResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadListResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ThreadListResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadListResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadListResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadListResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadListResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadListResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadListResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadListResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadListResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([V2ThreadListResponse__MessagePhase, Schema.Null])),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadListResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadListResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadListResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadListResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadListResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadListResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadListResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadListResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadListResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(Schema.String, V2ThreadListResponse__CollabAgentState).annotate({
        description: "Last known status of the target agents, when available.",
      }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadListResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadListResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadListResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadListResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadMetadataUpdateResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadMetadataUpdateResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadMetadataUpdateResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadMetadataUpdateResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadMetadataUpdateResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadMetadataUpdateResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadMetadataUpdateResponse__MemoryCitation | null;
      readonly phase?: V2ThreadMetadataUpdateResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadMetadataUpdateResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadMetadataUpdateResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadMetadataUpdateResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadMetadataUpdateResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadMetadataUpdateResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadMetadataUpdateResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadMetadataUpdateResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadMetadataUpdateResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadMetadataUpdateResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: {
        readonly [x: string]: V2ThreadMetadataUpdateResponse__CollabAgentState;
      };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadMetadataUpdateResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadMetadataUpdateResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadMetadataUpdateResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadMetadataUpdateResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadMetadataUpdateResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadMetadataUpdateResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadMetadataUpdateResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadMetadataUpdateResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2ThreadMetadataUpdateResponse__MessagePhase, Schema.Null]),
      ),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadMetadataUpdateResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadMetadataUpdateResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadMetadataUpdateResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadMetadataUpdateResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadMetadataUpdateResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadMetadataUpdateResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadMetadataUpdateResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadMetadataUpdateResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadMetadataUpdateResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(
        Schema.String,
        V2ThreadMetadataUpdateResponse__CollabAgentState,
      ).annotate({ description: "Last known status of the target agents, when available." }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadMetadataUpdateResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadMetadataUpdateResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadMetadataUpdateResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadMetadataUpdateResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadReadResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadReadResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadReadResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadReadResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadReadResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadReadResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadReadResponse__MemoryCitation | null;
      readonly phase?: V2ThreadReadResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadReadResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadReadResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadReadResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadReadResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadReadResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadReadResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadReadResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadReadResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadReadResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ThreadReadResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadReadResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadReadResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadReadResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadReadResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadReadResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadReadResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadReadResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadReadResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([V2ThreadReadResponse__MessagePhase, Schema.Null])),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadReadResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadReadResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadReadResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadReadResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadReadResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadReadResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadReadResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadReadResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadReadResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(Schema.String, V2ThreadReadResponse__CollabAgentState).annotate({
        description: "Last known status of the target agents, when available.",
      }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadReadResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadReadResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadReadResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadReadResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__FunctionCallOutputBody =
  | string
  | ReadonlyArray<V2ThreadResumeParams__FunctionCallOutputContentItem>;
export const V2ThreadResumeParams__FunctionCallOutputBody = Schema.Union([
  Schema.String,
  Schema.Array(V2ThreadResumeParams__FunctionCallOutputContentItem),
]);

export type V2ThreadResumeResponse__FileSystemSandboxEntry = {
  readonly access: V2ThreadResumeResponse__FileSystemAccessMode;
  readonly path: V2ThreadResumeResponse__FileSystemPath;
};
export const V2ThreadResumeResponse__FileSystemSandboxEntry = Schema.Struct({
  access: V2ThreadResumeResponse__FileSystemAccessMode,
  path: V2ThreadResumeResponse__FileSystemPath,
});

export type V2ThreadResumeResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadResumeResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadResumeResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadResumeResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadResumeResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadResumeResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadResumeResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadResumeResponse__MemoryCitation | null;
      readonly phase?: V2ThreadResumeResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadResumeResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadResumeResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadResumeResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadResumeResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadResumeResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadResumeResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadResumeResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadResumeResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadResumeResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ThreadResumeResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadResumeResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadResumeResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadResumeResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadResumeResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadResumeResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadResumeResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadResumeResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadResumeResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([V2ThreadResumeResponse__MessagePhase, Schema.Null])),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadResumeResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadResumeResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadResumeResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadResumeResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadResumeResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadResumeResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadResumeResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadResumeResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadResumeResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(Schema.String, V2ThreadResumeResponse__CollabAgentState).annotate(
        { description: "Last known status of the target agents, when available." },
      ),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadResumeResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadResumeResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadResumeResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadResumeResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadRollbackResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadRollbackResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadRollbackResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadRollbackResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadRollbackResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadRollbackResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadRollbackResponse__MemoryCitation | null;
      readonly phase?: V2ThreadRollbackResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadRollbackResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadRollbackResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadRollbackResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadRollbackResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadRollbackResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadRollbackResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadRollbackResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadRollbackResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadRollbackResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ThreadRollbackResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadRollbackResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadRollbackResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadRollbackResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadRollbackResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadRollbackResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadRollbackResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadRollbackResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadRollbackResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2ThreadRollbackResponse__MessagePhase, Schema.Null]),
      ),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadRollbackResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadRollbackResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadRollbackResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadRollbackResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadRollbackResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadRollbackResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadRollbackResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadRollbackResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadRollbackResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(
        Schema.String,
        V2ThreadRollbackResponse__CollabAgentState,
      ).annotate({ description: "Last known status of the target agents, when available." }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadRollbackResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadRollbackResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadRollbackResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadRollbackResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadStartedNotification__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadStartedNotification__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadStartedNotification__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadStartedNotification__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadStartedNotification__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadStartedNotification__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadStartedNotification__MemoryCitation | null;
      readonly phase?: V2ThreadStartedNotification__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadStartedNotification__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadStartedNotification__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadStartedNotification__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadStartedNotification__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadStartedNotification__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadStartedNotification__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadStartedNotification__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadStartedNotification__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadStartedNotification__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: {
        readonly [x: string]: V2ThreadStartedNotification__CollabAgentState;
      };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadStartedNotification__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadStartedNotification__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadStartedNotification__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadStartedNotification__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadStartedNotification__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadStartedNotification__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadStartedNotification__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadStartedNotification__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2ThreadStartedNotification__MessagePhase, Schema.Null]),
      ),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadStartedNotification__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadStartedNotification__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadStartedNotification__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadStartedNotification__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadStartedNotification__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadStartedNotification__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadStartedNotification__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadStartedNotification__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadStartedNotification__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(
        Schema.String,
        V2ThreadStartedNotification__CollabAgentState,
      ).annotate({ description: "Last known status of the target agents, when available." }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadStartedNotification__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadStartedNotification__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadStartedNotification__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadStartedNotification__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__FileSystemSandboxEntry = {
  readonly access: V2ThreadStartResponse__FileSystemAccessMode;
  readonly path: V2ThreadStartResponse__FileSystemPath;
};
export const V2ThreadStartResponse__FileSystemSandboxEntry = Schema.Struct({
  access: V2ThreadStartResponse__FileSystemAccessMode,
  path: V2ThreadStartResponse__FileSystemPath,
});

export type V2ThreadStartResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadStartResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadStartResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadStartResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadStartResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadStartResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadStartResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadStartResponse__MemoryCitation | null;
      readonly phase?: V2ThreadStartResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadStartResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadStartResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadStartResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadStartResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadStartResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadStartResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadStartResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadStartResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadStartResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ThreadStartResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadStartResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadStartResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadStartResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadStartResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadStartResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadStartResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadStartResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadStartResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([V2ThreadStartResponse__MessagePhase, Schema.Null])),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadStartResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadStartResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadStartResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadStartResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadStartResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadStartResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadStartResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadStartResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadStartResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(Schema.String, V2ThreadStartResponse__CollabAgentState).annotate({
        description: "Last known status of the target agents, when available.",
      }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadStartResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadStartResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadStartResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadStartResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadUnarchiveResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2ThreadUnarchiveResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2ThreadUnarchiveResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2ThreadUnarchiveResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2ThreadUnarchiveResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2ThreadUnarchiveResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2ThreadUnarchiveResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2ThreadUnarchiveResponse__MemoryCitation | null;
      readonly phase?: V2ThreadUnarchiveResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2ThreadUnarchiveResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2ThreadUnarchiveResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2ThreadUnarchiveResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2ThreadUnarchiveResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2ThreadUnarchiveResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2ThreadUnarchiveResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2ThreadUnarchiveResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2ThreadUnarchiveResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2ThreadUnarchiveResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2ThreadUnarchiveResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2ThreadUnarchiveResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2ThreadUnarchiveResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2ThreadUnarchiveResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2ThreadUnarchiveResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2ThreadUnarchiveResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadUnarchiveResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2ThreadUnarchiveResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2ThreadUnarchiveResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2ThreadUnarchiveResponse__MessagePhase, Schema.Null]),
      ),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2ThreadUnarchiveResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2ThreadUnarchiveResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2ThreadUnarchiveResponse__FileUpdateChange),
      id: Schema.String,
      status: V2ThreadUnarchiveResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2ThreadUnarchiveResponse__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2ThreadUnarchiveResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2ThreadUnarchiveResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadUnarchiveResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2ThreadUnarchiveResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(
        Schema.String,
        V2ThreadUnarchiveResponse__CollabAgentState,
      ).annotate({ description: "Last known status of the target agents, when available." }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2ThreadUnarchiveResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadUnarchiveResponse__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2ThreadUnarchiveResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2ThreadUnarchiveResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnCompletedNotification__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2TurnCompletedNotification__CodexErrorInfo | null;
  readonly message: string;
};
export const V2TurnCompletedNotification__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2TurnCompletedNotification__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2TurnCompletedNotification__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2TurnCompletedNotification__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2TurnCompletedNotification__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2TurnCompletedNotification__MemoryCitation | null;
      readonly phase?: V2TurnCompletedNotification__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2TurnCompletedNotification__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2TurnCompletedNotification__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2TurnCompletedNotification__FileUpdateChange>;
      readonly id: string;
      readonly status: V2TurnCompletedNotification__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2TurnCompletedNotification__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2TurnCompletedNotification__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2TurnCompletedNotification__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2TurnCompletedNotification__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2TurnCompletedNotification__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: {
        readonly [x: string]: V2TurnCompletedNotification__CollabAgentState;
      };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2TurnCompletedNotification__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2TurnCompletedNotification__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2TurnCompletedNotification__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2TurnCompletedNotification__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2TurnCompletedNotification__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2TurnCompletedNotification__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2TurnCompletedNotification__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2TurnCompletedNotification__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2TurnCompletedNotification__MessagePhase, Schema.Null]),
      ),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2TurnCompletedNotification__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2TurnCompletedNotification__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2TurnCompletedNotification__FileUpdateChange),
      id: Schema.String,
      status: V2TurnCompletedNotification__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2TurnCompletedNotification__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2TurnCompletedNotification__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2TurnCompletedNotification__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2TurnCompletedNotification__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2TurnCompletedNotification__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(
        Schema.String,
        V2TurnCompletedNotification__CollabAgentState,
      ).annotate({ description: "Last known status of the target agents, when available." }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2TurnCompletedNotification__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2TurnCompletedNotification__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2TurnCompletedNotification__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2TurnCompletedNotification__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartedNotification__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2TurnStartedNotification__CodexErrorInfo | null;
  readonly message: string;
};
export const V2TurnStartedNotification__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2TurnStartedNotification__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2TurnStartedNotification__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2TurnStartedNotification__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2TurnStartedNotification__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2TurnStartedNotification__MemoryCitation | null;
      readonly phase?: V2TurnStartedNotification__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2TurnStartedNotification__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2TurnStartedNotification__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2TurnStartedNotification__FileUpdateChange>;
      readonly id: string;
      readonly status: V2TurnStartedNotification__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2TurnStartedNotification__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2TurnStartedNotification__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2TurnStartedNotification__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2TurnStartedNotification__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2TurnStartedNotification__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2TurnStartedNotification__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2TurnStartedNotification__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2TurnStartedNotification__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2TurnStartedNotification__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2TurnStartedNotification__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2TurnStartedNotification__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2TurnStartedNotification__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2TurnStartedNotification__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2TurnStartedNotification__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2TurnStartedNotification__MessagePhase, Schema.Null]),
      ),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2TurnStartedNotification__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2TurnStartedNotification__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2TurnStartedNotification__FileUpdateChange),
      id: Schema.String,
      status: V2TurnStartedNotification__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(
        Schema.Union([V2TurnStartedNotification__McpToolCallError, Schema.Null]),
      ),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2TurnStartedNotification__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2TurnStartedNotification__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2TurnStartedNotification__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2TurnStartedNotification__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(
        Schema.String,
        V2TurnStartedNotification__CollabAgentState,
      ).annotate({ description: "Last known status of the target agents, when available." }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2TurnStartedNotification__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2TurnStartedNotification__WebSearchAction, Schema.Null]),
      ),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2TurnStartedNotification__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2TurnStartedNotification__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartResponse__TurnError = {
  readonly additionalDetails?: string | null;
  readonly codexErrorInfo?: V2TurnStartResponse__CodexErrorInfo | null;
  readonly message: string;
};
export const V2TurnStartResponse__TurnError = Schema.Struct({
  additionalDetails: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  codexErrorInfo: Schema.optionalKey(
    Schema.Union([V2TurnStartResponse__CodexErrorInfo, Schema.Null]),
  ),
  message: Schema.String,
});

export type V2TurnStartResponse__ThreadItem =
  | {
      readonly content: ReadonlyArray<V2TurnStartResponse__UserInput>;
      readonly id: string;
      readonly type: "userMessage";
    }
  | {
      readonly fragments: ReadonlyArray<V2TurnStartResponse__HookPromptFragment>;
      readonly id: string;
      readonly type: "hookPrompt";
    }
  | {
      readonly id: string;
      readonly memoryCitation?: V2TurnStartResponse__MemoryCitation | null;
      readonly phase?: V2TurnStartResponse__MessagePhase | null;
      readonly text: string;
      readonly type: "agentMessage";
    }
  | { readonly id: string; readonly text: string; readonly type: "plan" }
  | {
      readonly content?: ReadonlyArray<string>;
      readonly id: string;
      readonly summary?: ReadonlyArray<string>;
      readonly type: "reasoning";
    }
  | {
      readonly aggregatedOutput?: string | null;
      readonly command: string;
      readonly commandActions: ReadonlyArray<V2TurnStartResponse__CommandAction>;
      readonly cwd: string;
      readonly durationMs?: number | null;
      readonly exitCode?: number | null;
      readonly id: string;
      readonly processId?: string | null;
      readonly source?: "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
      readonly status: V2TurnStartResponse__CommandExecutionStatus;
      readonly type: "commandExecution";
    }
  | {
      readonly changes: ReadonlyArray<V2TurnStartResponse__FileUpdateChange>;
      readonly id: string;
      readonly status: V2TurnStartResponse__PatchApplyStatus;
      readonly type: "fileChange";
    }
  | {
      readonly arguments: unknown;
      readonly durationMs?: number | null;
      readonly error?: V2TurnStartResponse__McpToolCallError | null;
      readonly id: string;
      readonly mcpAppResourceUri?: string | null;
      readonly result?: V2TurnStartResponse__McpToolCallResult | null;
      readonly server: string;
      readonly status: V2TurnStartResponse__McpToolCallStatus;
      readonly tool: string;
      readonly type: "mcpToolCall";
    }
  | {
      readonly arguments: unknown;
      readonly contentItems?: ReadonlyArray<V2TurnStartResponse__DynamicToolCallOutputContentItem> | null;
      readonly durationMs?: number | null;
      readonly id: string;
      readonly namespace?: string | null;
      readonly status: V2TurnStartResponse__DynamicToolCallStatus;
      readonly success?: boolean | null;
      readonly tool: string;
      readonly type: "dynamicToolCall";
    }
  | {
      readonly agentsStates: { readonly [x: string]: V2TurnStartResponse__CollabAgentState };
      readonly id: string;
      readonly model?: string | null;
      readonly prompt?: string | null;
      readonly reasoningEffort?: V2TurnStartResponse__ReasoningEffort | null;
      readonly receiverThreadIds: ReadonlyArray<string>;
      readonly senderThreadId: string;
      readonly status: "inProgress" | "completed" | "failed";
      readonly tool: "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent";
      readonly type: "collabAgentToolCall";
    }
  | {
      readonly action?: V2TurnStartResponse__WebSearchAction | null;
      readonly id: string;
      readonly query: string;
      readonly type: "webSearch";
    }
  | {
      readonly id: string;
      readonly path: V2TurnStartResponse__AbsolutePathBuf;
      readonly type: "imageView";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revisedPrompt?: string | null;
      readonly savedPath?: V2TurnStartResponse__AbsolutePathBuf | null;
      readonly status: string;
      readonly type: "imageGeneration";
    }
  | { readonly id: string; readonly review: string; readonly type: "enteredReviewMode" }
  | { readonly id: string; readonly review: string; readonly type: "exitedReviewMode" }
  | { readonly id: string; readonly type: "contextCompaction" };
export const V2TurnStartResponse__ThreadItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2TurnStartResponse__UserInput),
      id: Schema.String,
      type: Schema.Literal("userMessage").annotate({ title: "UserMessageThreadItemType" }),
    }).annotate({ title: "UserMessageThreadItem" }),
    Schema.Struct({
      fragments: Schema.Array(V2TurnStartResponse__HookPromptFragment),
      id: Schema.String,
      type: Schema.Literal("hookPrompt").annotate({ title: "HookPromptThreadItemType" }),
    }).annotate({ title: "HookPromptThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      memoryCitation: Schema.optionalKey(
        Schema.Union([V2TurnStartResponse__MemoryCitation, Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([V2TurnStartResponse__MessagePhase, Schema.Null])),
      text: Schema.String,
      type: Schema.Literal("agentMessage").annotate({ title: "AgentMessageThreadItemType" }),
    }).annotate({ title: "AgentMessageThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      text: Schema.String,
      type: Schema.Literal("plan").annotate({ title: "PlanThreadItemType" }),
    }).annotate({
      title: "PlanThreadItem",
      description:
        "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
    }),
    Schema.Struct({
      content: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      id: Schema.String,
      summary: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningThreadItemType" }),
    }).annotate({ title: "ReasoningThreadItem" }),
    Schema.Struct({
      aggregatedOutput: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "The command's output, aggregated from stdout and stderr.",
          }),
          Schema.Null,
        ]),
      ),
      command: Schema.String.annotate({ description: "The command to be executed." }),
      commandActions: Schema.Array(V2TurnStartResponse__CommandAction).annotate({
        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: Schema.String.annotate({
        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.",
      }),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the command execution in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      exitCode: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The command's exit code.",
            format: "int32",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      processId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Identifier for the underlying PTY process (when available).",
          }),
          Schema.Null,
        ]),
      ),
      source: Schema.optionalKey(
        Schema.Literals([
          "agent",
          "userShell",
          "unifiedExecStartup",
          "unifiedExecInteraction",
        ]).annotate({ default: "agent" }),
      ),
      status: V2TurnStartResponse__CommandExecutionStatus,
      type: Schema.Literal("commandExecution").annotate({
        title: "CommandExecutionThreadItemType",
      }),
    }).annotate({ title: "CommandExecutionThreadItem" }),
    Schema.Struct({
      changes: Schema.Array(V2TurnStartResponse__FileUpdateChange),
      id: Schema.String,
      status: V2TurnStartResponse__PatchApplyStatus,
      type: Schema.Literal("fileChange").annotate({ title: "FileChangeThreadItemType" }),
    }).annotate({ title: "FileChangeThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the MCP tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      error: Schema.optionalKey(Schema.Union([V2TurnStartResponse__McpToolCallError, Schema.Null])),
      id: Schema.String,
      mcpAppResourceUri: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      result: Schema.optionalKey(
        Schema.Union([V2TurnStartResponse__McpToolCallResult, Schema.Null]),
      ),
      server: Schema.String,
      status: V2TurnStartResponse__McpToolCallStatus,
      tool: Schema.String,
      type: Schema.Literal("mcpToolCall").annotate({ title: "McpToolCallThreadItemType" }),
    }).annotate({ title: "McpToolCallThreadItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      contentItems: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2TurnStartResponse__DynamicToolCallOutputContentItem),
          Schema.Null,
        ]),
      ),
      durationMs: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({
            description: "The duration of the dynamic tool call in milliseconds.",
            format: "int64",
          }).check(Schema.isInt()),
          Schema.Null,
        ]),
      ),
      id: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: V2TurnStartResponse__DynamicToolCallStatus,
      success: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
      tool: Schema.String,
      type: Schema.Literal("dynamicToolCall").annotate({ title: "DynamicToolCallThreadItemType" }),
    }).annotate({ title: "DynamicToolCallThreadItem" }),
    Schema.Struct({
      agentsStates: Schema.Record(Schema.String, V2TurnStartResponse__CollabAgentState).annotate({
        description: "Last known status of the target agents, when available.",
      }),
      id: Schema.String.annotate({ description: "Unique identifier for this collab tool call." }),
      model: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Model requested for the spawned agent, when applicable.",
          }),
          Schema.Null,
        ]),
      ),
      prompt: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Prompt text sent as part of the collab tool call, when available.",
          }),
          Schema.Null,
        ]),
      ),
      reasoningEffort: Schema.optionalKey(
        Schema.Union([V2TurnStartResponse__ReasoningEffort, Schema.Null]).annotate({
          description: "Reasoning effort requested for the spawned agent, when applicable.",
        }),
      ),
      receiverThreadIds: Schema.Array(Schema.String).annotate({
        description:
          "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
      }),
      senderThreadId: Schema.String.annotate({
        description: "Thread ID of the agent issuing the collab request.",
      }),
      status: Schema.Literals(["inProgress", "completed", "failed"]).annotate({
        description: "Current status of the collab tool call.",
      }),
      tool: Schema.Literals([
        "spawnAgent",
        "sendInput",
        "resumeAgent",
        "wait",
        "closeAgent",
      ]).annotate({ description: "Name of the collab tool that was invoked." }),
      type: Schema.Literal("collabAgentToolCall").annotate({
        title: "CollabAgentToolCallThreadItemType",
      }),
    }).annotate({ title: "CollabAgentToolCallThreadItem" }),
    Schema.Struct({
      action: Schema.optionalKey(Schema.Union([V2TurnStartResponse__WebSearchAction, Schema.Null])),
      id: Schema.String,
      query: Schema.String,
      type: Schema.Literal("webSearch").annotate({ title: "WebSearchThreadItemType" }),
    }).annotate({ title: "WebSearchThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      path: V2TurnStartResponse__AbsolutePathBuf,
      type: Schema.Literal("imageView").annotate({ title: "ImageViewThreadItemType" }),
    }).annotate({ title: "ImageViewThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revisedPrompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      savedPath: Schema.optionalKey(
        Schema.Union([V2TurnStartResponse__AbsolutePathBuf, Schema.Null]),
      ),
      status: Schema.String,
      type: Schema.Literal("imageGeneration").annotate({ title: "ImageGenerationThreadItemType" }),
    }).annotate({ title: "ImageGenerationThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("enteredReviewMode").annotate({
        title: "EnteredReviewModeThreadItemType",
      }),
    }).annotate({ title: "EnteredReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      review: Schema.String,
      type: Schema.Literal("exitedReviewMode").annotate({
        title: "ExitedReviewModeThreadItemType",
      }),
    }).annotate({ title: "ExitedReviewModeThreadItem" }),
    Schema.Struct({
      id: Schema.String,
      type: Schema.Literal("contextCompaction").annotate({
        title: "ContextCompactionThreadItemType",
      }),
    }).annotate({ title: "ContextCompactionThreadItem" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__PermissionProfileFileSystemPermissions =
  | {
      readonly entries: ReadonlyArray<ClientRequest__FileSystemSandboxEntry>;
      readonly globScanMaxDepth?: number | null;
      readonly type: "restricted";
    }
  | { readonly type: "unrestricted" };
export const ClientRequest__PermissionProfileFileSystemPermissions = Schema.Union(
  [
    Schema.Struct({
      entries: Schema.Array(ClientRequest__FileSystemSandboxEntry),
      globScanMaxDepth: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(1)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("restricted").annotate({
        title: "RestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "RestrictedPermissionProfileFileSystemPermissions" }),
    Schema.Struct({
      type: Schema.Literal("unrestricted").annotate({
        title: "UnrestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "UnrestrictedPermissionProfileFileSystemPermissions" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__ExternalAgentConfigImportParams = {
  readonly migrationItems: ReadonlyArray<ClientRequest__ExternalAgentConfigMigrationItem>;
};
export const ClientRequest__ExternalAgentConfigImportParams = Schema.Struct({
  migrationItems: Schema.Array(ClientRequest__ExternalAgentConfigMigrationItem),
});

export type CommandExecutionRequestApprovalParams__AdditionalFileSystemPermissions = {
  readonly entries?: ReadonlyArray<CommandExecutionRequestApprovalParams__FileSystemSandboxEntry> | null;
  readonly globScanMaxDepth?: number | null;
  readonly read?: ReadonlyArray<CommandExecutionRequestApprovalParams__AbsolutePathBuf> | null;
  readonly write?: ReadonlyArray<CommandExecutionRequestApprovalParams__AbsolutePathBuf> | null;
};
export const CommandExecutionRequestApprovalParams__AdditionalFileSystemPermissions = Schema.Struct(
  {
    entries: Schema.optionalKey(
      Schema.Union([
        Schema.Array(CommandExecutionRequestApprovalParams__FileSystemSandboxEntry),
        Schema.Null,
      ]),
    ),
    globScanMaxDepth: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "uint" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(1)),
        Schema.Null,
      ]),
    ),
    read: Schema.optionalKey(
      Schema.Union([
        Schema.Array(CommandExecutionRequestApprovalParams__AbsolutePathBuf).annotate({
          description: "This will be removed in favor of `entries`.",
        }),
        Schema.Null,
      ]),
    ),
    write: Schema.optionalKey(
      Schema.Union([
        Schema.Array(CommandExecutionRequestApprovalParams__AbsolutePathBuf).annotate({
          description: "This will be removed in favor of `entries`.",
        }),
        Schema.Null,
      ]),
    ),
  },
);

export type McpServerElicitationRequestParams__McpElicitationMultiSelectEnumSchema =
  | McpServerElicitationRequestParams__McpElicitationUntitledMultiSelectEnumSchema
  | McpServerElicitationRequestParams__McpElicitationTitledMultiSelectEnumSchema;
export const McpServerElicitationRequestParams__McpElicitationMultiSelectEnumSchema = Schema.Union([
  McpServerElicitationRequestParams__McpElicitationUntitledMultiSelectEnumSchema,
  McpServerElicitationRequestParams__McpElicitationTitledMultiSelectEnumSchema,
]);

export type PermissionsRequestApprovalParams__AdditionalFileSystemPermissions = {
  readonly entries?: ReadonlyArray<PermissionsRequestApprovalParams__FileSystemSandboxEntry> | null;
  readonly globScanMaxDepth?: number | null;
  readonly read?: ReadonlyArray<PermissionsRequestApprovalParams__AbsolutePathBuf> | null;
  readonly write?: ReadonlyArray<PermissionsRequestApprovalParams__AbsolutePathBuf> | null;
};
export const PermissionsRequestApprovalParams__AdditionalFileSystemPermissions = Schema.Struct({
  entries: Schema.optionalKey(
    Schema.Union([
      Schema.Array(PermissionsRequestApprovalParams__FileSystemSandboxEntry),
      Schema.Null,
    ]),
  ),
  globScanMaxDepth: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(1)),
      Schema.Null,
    ]),
  ),
  read: Schema.optionalKey(
    Schema.Union([
      Schema.Array(PermissionsRequestApprovalParams__AbsolutePathBuf).annotate({
        description: "This will be removed in favor of `entries`.",
      }),
      Schema.Null,
    ]),
  ),
  write: Schema.optionalKey(
    Schema.Union([
      Schema.Array(PermissionsRequestApprovalParams__AbsolutePathBuf).annotate({
        description: "This will be removed in favor of `entries`.",
      }),
      Schema.Null,
    ]),
  ),
});

export type PermissionsRequestApprovalResponse__AdditionalFileSystemPermissions = {
  readonly entries?: ReadonlyArray<PermissionsRequestApprovalResponse__FileSystemSandboxEntry> | null;
  readonly globScanMaxDepth?: number | null;
  readonly read?: ReadonlyArray<PermissionsRequestApprovalResponse__AbsolutePathBuf> | null;
  readonly write?: ReadonlyArray<PermissionsRequestApprovalResponse__AbsolutePathBuf> | null;
};
export const PermissionsRequestApprovalResponse__AdditionalFileSystemPermissions = Schema.Struct({
  entries: Schema.optionalKey(
    Schema.Union([
      Schema.Array(PermissionsRequestApprovalResponse__FileSystemSandboxEntry),
      Schema.Null,
    ]),
  ),
  globScanMaxDepth: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(1)),
      Schema.Null,
    ]),
  ),
  read: Schema.optionalKey(
    Schema.Union([
      Schema.Array(PermissionsRequestApprovalResponse__AbsolutePathBuf).annotate({
        description: "This will be removed in favor of `entries`.",
      }),
      Schema.Null,
    ]),
  ),
  write: Schema.optionalKey(
    Schema.Union([
      Schema.Array(PermissionsRequestApprovalResponse__AbsolutePathBuf).annotate({
        description: "This will be removed in favor of `entries`.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ServerNotification__AppListUpdatedNotification = {
  readonly data: ReadonlyArray<ServerNotification__AppInfo>;
};
export const ServerNotification__AppListUpdatedNotification = Schema.Struct({
  data: Schema.Array(ServerNotification__AppInfo),
}).annotate({ description: "EXPERIMENTAL - notification emitted when the app list changes." });

export type ServerNotification__AdditionalFileSystemPermissions = {
  readonly entries?: ReadonlyArray<ServerNotification__FileSystemSandboxEntry> | null;
  readonly globScanMaxDepth?: number | null;
  readonly read?: ReadonlyArray<ServerNotification__AbsolutePathBuf> | null;
  readonly write?: ReadonlyArray<ServerNotification__AbsolutePathBuf> | null;
};
export const ServerNotification__AdditionalFileSystemPermissions = Schema.Struct({
  entries: Schema.optionalKey(
    Schema.Union([Schema.Array(ServerNotification__FileSystemSandboxEntry), Schema.Null]),
  ),
  globScanMaxDepth: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(1)),
      Schema.Null,
    ]),
  ),
  read: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ServerNotification__AbsolutePathBuf).annotate({
        description: "This will be removed in favor of `entries`.",
      }),
      Schema.Null,
    ]),
  ),
  write: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ServerNotification__AbsolutePathBuf).annotate({
        description: "This will be removed in favor of `entries`.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ServerNotification__HookCompletedNotification = {
  readonly run: ServerNotification__HookRunSummary;
  readonly threadId: string;
  readonly turnId?: string | null;
};
export const ServerNotification__HookCompletedNotification = Schema.Struct({
  run: ServerNotification__HookRunSummary,
  threadId: Schema.String,
  turnId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ServerNotification__HookStartedNotification = {
  readonly run: ServerNotification__HookRunSummary;
  readonly threadId: string;
  readonly turnId?: string | null;
};
export const ServerNotification__HookStartedNotification = Schema.Struct({
  run: ServerNotification__HookRunSummary,
  threadId: Schema.String,
  turnId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ServerNotification__ErrorNotification = {
  readonly error: ServerNotification__TurnError;
  readonly threadId: string;
  readonly turnId: string;
  readonly willRetry: boolean;
};
export const ServerNotification__ErrorNotification = Schema.Struct({
  error: ServerNotification__TurnError,
  threadId: Schema.String,
  turnId: Schema.String,
  willRetry: Schema.Boolean,
});

export type ServerNotification__ItemCompletedNotification = {
  readonly completedAtMs: number;
  readonly item: ServerNotification__ThreadItem;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__ItemCompletedNotification = Schema.Struct({
  completedAtMs: Schema.Number.annotate({
    description: "Unix timestamp (in milliseconds) when this item lifecycle completed.",
    format: "int64",
  }).check(Schema.isInt()),
  item: ServerNotification__ThreadItem,
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__ItemStartedNotification = {
  readonly item: ServerNotification__ThreadItem;
  readonly startedAtMs: number;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__ItemStartedNotification = Schema.Struct({
  item: ServerNotification__ThreadItem,
  startedAtMs: Schema.Number.annotate({
    description: "Unix timestamp (in milliseconds) when this item lifecycle started.",
    format: "int64",
  }).check(Schema.isInt()),
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerNotification__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: ServerNotification__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<ServerNotification__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: ServerNotification__TurnStatus;
};
export const ServerNotification__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([ServerNotification__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(ServerNotification__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: ServerNotification__TurnStatus,
});

export type ServerRequest__AdditionalFileSystemPermissions = {
  readonly entries?: ReadonlyArray<ServerRequest__FileSystemSandboxEntry> | null;
  readonly globScanMaxDepth?: number | null;
  readonly read?: ReadonlyArray<ServerRequest__AbsolutePathBuf> | null;
  readonly write?: ReadonlyArray<ServerRequest__AbsolutePathBuf> | null;
};
export const ServerRequest__AdditionalFileSystemPermissions = Schema.Struct({
  entries: Schema.optionalKey(
    Schema.Union([Schema.Array(ServerRequest__FileSystemSandboxEntry), Schema.Null]),
  ),
  globScanMaxDepth: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(1)),
      Schema.Null,
    ]),
  ),
  read: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ServerRequest__AbsolutePathBuf).annotate({
        description: "This will be removed in favor of `entries`.",
      }),
      Schema.Null,
    ]),
  ),
  write: Schema.optionalKey(
    Schema.Union([
      Schema.Array(ServerRequest__AbsolutePathBuf).annotate({
        description: "This will be removed in favor of `entries`.",
      }),
      Schema.Null,
    ]),
  ),
});

export type ServerRequest__McpElicitationMultiSelectEnumSchema =
  | ServerRequest__McpElicitationUntitledMultiSelectEnumSchema
  | ServerRequest__McpElicitationTitledMultiSelectEnumSchema;
export const ServerRequest__McpElicitationMultiSelectEnumSchema = Schema.Union([
  ServerRequest__McpElicitationUntitledMultiSelectEnumSchema,
  ServerRequest__McpElicitationTitledMultiSelectEnumSchema,
]);

export type V2CommandExecParams__PermissionProfileFileSystemPermissions =
  | {
      readonly entries: ReadonlyArray<V2CommandExecParams__FileSystemSandboxEntry>;
      readonly globScanMaxDepth?: number | null;
      readonly type: "restricted";
    }
  | { readonly type: "unrestricted" };
export const V2CommandExecParams__PermissionProfileFileSystemPermissions = Schema.Union(
  [
    Schema.Struct({
      entries: Schema.Array(V2CommandExecParams__FileSystemSandboxEntry),
      globScanMaxDepth: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(1)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("restricted").annotate({
        title: "RestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "RestrictedPermissionProfileFileSystemPermissions" }),
    Schema.Struct({
      type: Schema.Literal("unrestricted").annotate({
        title: "UnrestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "UnrestrictedPermissionProfileFileSystemPermissions" }),
  ],
  { mode: "oneOf" },
);

export type V2ConfigReadResponse__ProfileV2 = {
  readonly approval_policy?: V2ConfigReadResponse__AskForApproval | null;
  readonly approvals_reviewer?: V2ConfigReadResponse__ApprovalsReviewer | null;
  readonly chatgpt_base_url?: string | null;
  readonly model?: string | null;
  readonly model_provider?: string | null;
  readonly model_reasoning_effort?: V2ConfigReadResponse__ReasoningEffort | null;
  readonly model_reasoning_summary?: V2ConfigReadResponse__ReasoningSummary | null;
  readonly model_verbosity?: V2ConfigReadResponse__Verbosity | null;
  readonly service_tier?: string | null;
  readonly tools?: V2ConfigReadResponse__ToolsV2 | null;
  readonly web_search?: V2ConfigReadResponse__WebSearchMode | null;
  readonly [x: string]: unknown;
};
export const V2ConfigReadResponse__ProfileV2 = Schema.StructWithRest(
  Schema.Struct({
    approval_policy: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__AskForApproval, Schema.Null]),
    ),
    approvals_reviewer: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__ApprovalsReviewer, Schema.Null]).annotate({
        description:
          "[UNSTABLE] Optional profile-level override for where approval requests are routed for review. If omitted, the enclosing config default is used.",
      }),
    ),
    chatgpt_base_url: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    model: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    model_provider: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    model_reasoning_effort: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__ReasoningEffort, Schema.Null]),
    ),
    model_reasoning_summary: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__ReasoningSummary, Schema.Null]),
    ),
    model_verbosity: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__Verbosity, Schema.Null]),
    ),
    service_tier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    tools: Schema.optionalKey(Schema.Union([V2ConfigReadResponse__ToolsV2, Schema.Null])),
    web_search: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__WebSearchMode, Schema.Null]),
    ),
  }),
  [Schema.Record(Schema.String, Schema.Unknown)],
);

export type V2ConfigWriteResponse__OverriddenMetadata = {
  readonly effectiveValue: unknown;
  readonly message: string;
  readonly overridingLayer: V2ConfigWriteResponse__ConfigLayerMetadata;
};
export const V2ConfigWriteResponse__OverriddenMetadata = Schema.Struct({
  effectiveValue: Schema.Unknown,
  message: Schema.String,
  overridingLayer: V2ConfigWriteResponse__ConfigLayerMetadata,
});

export type V2ItemGuardianApprovalReviewCompletedNotification__AdditionalFileSystemPermissions = {
  readonly entries?: ReadonlyArray<V2ItemGuardianApprovalReviewCompletedNotification__FileSystemSandboxEntry> | null;
  readonly globScanMaxDepth?: number | null;
  readonly read?: ReadonlyArray<V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf> | null;
  readonly write?: ReadonlyArray<V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf> | null;
};
export const V2ItemGuardianApprovalReviewCompletedNotification__AdditionalFileSystemPermissions =
  Schema.Struct({
    entries: Schema.optionalKey(
      Schema.Union([
        Schema.Array(V2ItemGuardianApprovalReviewCompletedNotification__FileSystemSandboxEntry),
        Schema.Null,
      ]),
    ),
    globScanMaxDepth: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "uint" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(1)),
        Schema.Null,
      ]),
    ),
    read: Schema.optionalKey(
      Schema.Union([
        Schema.Array(V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf).annotate({
          description: "This will be removed in favor of `entries`.",
        }),
        Schema.Null,
      ]),
    ),
    write: Schema.optionalKey(
      Schema.Union([
        Schema.Array(V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf).annotate({
          description: "This will be removed in favor of `entries`.",
        }),
        Schema.Null,
      ]),
    ),
  });

export type V2ItemGuardianApprovalReviewStartedNotification__AdditionalFileSystemPermissions = {
  readonly entries?: ReadonlyArray<V2ItemGuardianApprovalReviewStartedNotification__FileSystemSandboxEntry> | null;
  readonly globScanMaxDepth?: number | null;
  readonly read?: ReadonlyArray<V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf> | null;
  readonly write?: ReadonlyArray<V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf> | null;
};
export const V2ItemGuardianApprovalReviewStartedNotification__AdditionalFileSystemPermissions =
  Schema.Struct({
    entries: Schema.optionalKey(
      Schema.Union([
        Schema.Array(V2ItemGuardianApprovalReviewStartedNotification__FileSystemSandboxEntry),
        Schema.Null,
      ]),
    ),
    globScanMaxDepth: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "uint" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(1)),
        Schema.Null,
      ]),
    ),
    read: Schema.optionalKey(
      Schema.Union([
        Schema.Array(V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf).annotate({
          description: "This will be removed in favor of `entries`.",
        }),
        Schema.Null,
      ]),
    ),
    write: Schema.optionalKey(
      Schema.Union([
        Schema.Array(V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf).annotate({
          description: "This will be removed in favor of `entries`.",
        }),
        Schema.Null,
      ]),
    ),
  });

export type V2PluginListResponse__PluginSummary = {
  readonly authPolicy: V2PluginListResponse__PluginAuthPolicy;
  readonly availability?: "DISABLED_BY_ADMIN" | "AVAILABLE";
  readonly enabled: boolean;
  readonly id: string;
  readonly installPolicy: V2PluginListResponse__PluginInstallPolicy;
  readonly installed: boolean;
  readonly interface?: V2PluginListResponse__PluginInterface | null;
  readonly keywords?: ReadonlyArray<string>;
  readonly name: string;
  readonly shareContext?: V2PluginListResponse__PluginShareContext | null;
  readonly source: V2PluginListResponse__PluginSource;
};
export const V2PluginListResponse__PluginSummary = Schema.Struct({
  authPolicy: V2PluginListResponse__PluginAuthPolicy,
  availability: Schema.optionalKey(
    Schema.Literals(["DISABLED_BY_ADMIN", "AVAILABLE"]).annotate({
      description: "Availability state for installing and using the plugin.",
      default: "AVAILABLE",
    }),
  ),
  enabled: Schema.Boolean,
  id: Schema.String,
  installPolicy: V2PluginListResponse__PluginInstallPolicy,
  installed: Schema.Boolean,
  interface: Schema.optionalKey(Schema.Union([V2PluginListResponse__PluginInterface, Schema.Null])),
  keywords: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
  name: Schema.String,
  shareContext: Schema.optionalKey(
    Schema.Union([V2PluginListResponse__PluginShareContext, Schema.Null]).annotate({
      description: "Remote sharing context associated with this plugin when available.",
    }),
  ),
  source: V2PluginListResponse__PluginSource,
});

export type V2PluginReadResponse__PluginSummary = {
  readonly authPolicy: V2PluginReadResponse__PluginAuthPolicy;
  readonly availability?: "DISABLED_BY_ADMIN" | "AVAILABLE";
  readonly enabled: boolean;
  readonly id: string;
  readonly installPolicy: V2PluginReadResponse__PluginInstallPolicy;
  readonly installed: boolean;
  readonly interface?: V2PluginReadResponse__PluginInterface | null;
  readonly keywords?: ReadonlyArray<string>;
  readonly name: string;
  readonly shareContext?: V2PluginReadResponse__PluginShareContext | null;
  readonly source: V2PluginReadResponse__PluginSource;
};
export const V2PluginReadResponse__PluginSummary = Schema.Struct({
  authPolicy: V2PluginReadResponse__PluginAuthPolicy,
  availability: Schema.optionalKey(
    Schema.Literals(["DISABLED_BY_ADMIN", "AVAILABLE"]).annotate({
      description: "Availability state for installing and using the plugin.",
      default: "AVAILABLE",
    }),
  ),
  enabled: Schema.Boolean,
  id: Schema.String,
  installPolicy: V2PluginReadResponse__PluginInstallPolicy,
  installed: Schema.Boolean,
  interface: Schema.optionalKey(Schema.Union([V2PluginReadResponse__PluginInterface, Schema.Null])),
  keywords: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
  name: Schema.String,
  shareContext: Schema.optionalKey(
    Schema.Union([V2PluginReadResponse__PluginShareContext, Schema.Null]).annotate({
      description: "Remote sharing context associated with this plugin when available.",
    }),
  ),
  source: V2PluginReadResponse__PluginSource,
});

export type V2PluginShareListResponse__PluginSummary = {
  readonly authPolicy: V2PluginShareListResponse__PluginAuthPolicy;
  readonly availability?: "DISABLED_BY_ADMIN" | "AVAILABLE";
  readonly enabled: boolean;
  readonly id: string;
  readonly installPolicy: V2PluginShareListResponse__PluginInstallPolicy;
  readonly installed: boolean;
  readonly interface?: V2PluginShareListResponse__PluginInterface | null;
  readonly keywords?: ReadonlyArray<string>;
  readonly name: string;
  readonly shareContext?: V2PluginShareListResponse__PluginShareContext | null;
  readonly source: V2PluginShareListResponse__PluginSource;
};
export const V2PluginShareListResponse__PluginSummary = Schema.Struct({
  authPolicy: V2PluginShareListResponse__PluginAuthPolicy,
  availability: Schema.optionalKey(
    Schema.Literals(["DISABLED_BY_ADMIN", "AVAILABLE"]).annotate({
      description: "Availability state for installing and using the plugin.",
      default: "AVAILABLE",
    }),
  ),
  enabled: Schema.Boolean,
  id: Schema.String,
  installPolicy: V2PluginShareListResponse__PluginInstallPolicy,
  installed: Schema.Boolean,
  interface: Schema.optionalKey(
    Schema.Union([V2PluginShareListResponse__PluginInterface, Schema.Null]),
  ),
  keywords: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
  name: Schema.String,
  shareContext: Schema.optionalKey(
    Schema.Union([V2PluginShareListResponse__PluginShareContext, Schema.Null]).annotate({
      description: "Remote sharing context associated with this plugin when available.",
    }),
  ),
  source: V2PluginShareListResponse__PluginSource,
});

export type V2RawResponseItemCompletedNotification__ResponseItem =
  | {
      readonly content: ReadonlyArray<V2RawResponseItemCompletedNotification__ContentItem>;
      readonly id?: string | null;
      readonly phase?: V2RawResponseItemCompletedNotification__MessagePhase | null;
      readonly role: string;
      readonly type: "message";
    }
  | {
      readonly content?: ReadonlyArray<V2RawResponseItemCompletedNotification__ReasoningItemContent> | null;
      readonly encrypted_content?: string | null;
      readonly summary: ReadonlyArray<V2RawResponseItemCompletedNotification__ReasoningItemReasoningSummary>;
      readonly type: "reasoning";
    }
  | {
      readonly action: V2RawResponseItemCompletedNotification__LocalShellAction;
      readonly call_id?: string | null;
      readonly id?: string | null;
      readonly status: V2RawResponseItemCompletedNotification__LocalShellStatus;
      readonly type: "local_shell_call";
    }
  | {
      readonly arguments: string;
      readonly call_id: string;
      readonly id?: string | null;
      readonly name: string;
      readonly namespace?: string | null;
      readonly type: "function_call";
    }
  | {
      readonly arguments: unknown;
      readonly call_id?: string | null;
      readonly execution: string;
      readonly id?: string | null;
      readonly status?: string | null;
      readonly type: "tool_search_call";
    }
  | {
      readonly call_id: string;
      readonly output: V2RawResponseItemCompletedNotification__FunctionCallOutputBody;
      readonly type: "function_call_output";
    }
  | {
      readonly call_id: string;
      readonly id?: string | null;
      readonly input: string;
      readonly name: string;
      readonly status?: string | null;
      readonly type: "custom_tool_call";
    }
  | {
      readonly call_id: string;
      readonly name?: string | null;
      readonly output: V2RawResponseItemCompletedNotification__FunctionCallOutputBody;
      readonly type: "custom_tool_call_output";
    }
  | {
      readonly call_id?: string | null;
      readonly execution: string;
      readonly status: string;
      readonly tools: ReadonlyArray<unknown>;
      readonly type: "tool_search_output";
    }
  | {
      readonly action?: V2RawResponseItemCompletedNotification__ResponsesApiWebSearchAction | null;
      readonly id?: string | null;
      readonly status?: string | null;
      readonly type: "web_search_call";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revised_prompt?: string | null;
      readonly status: string;
      readonly type: "image_generation_call";
    }
  | { readonly encrypted_content: string; readonly type: "compaction" }
  | { readonly encrypted_content?: string | null; readonly type: "context_compaction" }
  | { readonly type: "other" };
export const V2RawResponseItemCompletedNotification__ResponseItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2RawResponseItemCompletedNotification__ContentItem),
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      phase: Schema.optionalKey(
        Schema.Union([V2RawResponseItemCompletedNotification__MessagePhase, Schema.Null]),
      ),
      role: Schema.String,
      type: Schema.Literal("message").annotate({ title: "MessageResponseItemType" }),
    }).annotate({ title: "MessageResponseItem" }),
    Schema.Struct({
      content: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2RawResponseItemCompletedNotification__ReasoningItemContent),
          Schema.Null,
        ]),
      ),
      encrypted_content: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      summary: Schema.Array(V2RawResponseItemCompletedNotification__ReasoningItemReasoningSummary),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningResponseItemType" }),
    }).annotate({ title: "ReasoningResponseItem" }),
    Schema.Struct({
      action: V2RawResponseItemCompletedNotification__LocalShellAction,
      call_id: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({ description: "Set when using the Responses API." }),
          Schema.Null,
        ]),
      ),
      id: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Legacy id field retained for compatibility with older payloads.",
            writeOnly: true,
          }),
          Schema.Null,
        ]),
      ),
      status: V2RawResponseItemCompletedNotification__LocalShellStatus,
      type: Schema.Literal("local_shell_call").annotate({
        title: "LocalShellCallResponseItemType",
      }),
    }).annotate({ title: "LocalShellCallResponseItem" }),
    Schema.Struct({
      arguments: Schema.String,
      call_id: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      name: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("function_call").annotate({ title: "FunctionCallResponseItemType" }),
    }).annotate({ title: "FunctionCallResponseItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      call_id: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      execution: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("tool_search_call").annotate({
        title: "ToolSearchCallResponseItemType",
      }),
    }).annotate({ title: "ToolSearchCallResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      output: V2RawResponseItemCompletedNotification__FunctionCallOutputBody,
      type: Schema.Literal("function_call_output").annotate({
        title: "FunctionCallOutputResponseItemType",
      }),
    }).annotate({ title: "FunctionCallOutputResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      input: Schema.String,
      name: Schema.String,
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("custom_tool_call").annotate({
        title: "CustomToolCallResponseItemType",
      }),
    }).annotate({ title: "CustomToolCallResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      name: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      output: V2RawResponseItemCompletedNotification__FunctionCallOutputBody,
      type: Schema.Literal("custom_tool_call_output").annotate({
        title: "CustomToolCallOutputResponseItemType",
      }),
    }).annotate({ title: "CustomToolCallOutputResponseItem" }),
    Schema.Struct({
      call_id: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      execution: Schema.String,
      status: Schema.String,
      tools: Schema.Array(Schema.Unknown),
      type: Schema.Literal("tool_search_output").annotate({
        title: "ToolSearchOutputResponseItemType",
      }),
    }).annotate({ title: "ToolSearchOutputResponseItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([
          V2RawResponseItemCompletedNotification__ResponsesApiWebSearchAction,
          Schema.Null,
        ]),
      ),
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("web_search_call").annotate({ title: "WebSearchCallResponseItemType" }),
    }).annotate({ title: "WebSearchCallResponseItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revised_prompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: Schema.String,
      type: Schema.Literal("image_generation_call").annotate({
        title: "ImageGenerationCallResponseItemType",
      }),
    }).annotate({ title: "ImageGenerationCallResponseItem" }),
    Schema.Struct({
      encrypted_content: Schema.String,
      type: Schema.Literal("compaction").annotate({ title: "CompactionResponseItemType" }),
    }).annotate({ title: "CompactionResponseItem" }),
    Schema.Struct({
      encrypted_content: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("context_compaction").annotate({
        title: "ContextCompactionResponseItemType",
      }),
    }).annotate({ title: "ContextCompactionResponseItem" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherResponseItemType" }),
    }).annotate({ title: "OtherResponseItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ReviewStartResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ReviewStartResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ReviewStartResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ReviewStartResponse__TurnStatus;
};
export const V2ReviewStartResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ReviewStartResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ReviewStartResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ReviewStartResponse__TurnStatus,
});

export type V2SkillsListResponse__SkillsListEntry = {
  readonly cwd: string;
  readonly errors: ReadonlyArray<V2SkillsListResponse__SkillErrorInfo>;
  readonly skills: ReadonlyArray<V2SkillsListResponse__SkillMetadata>;
};
export const V2SkillsListResponse__SkillsListEntry = Schema.Struct({
  cwd: Schema.String,
  errors: Schema.Array(V2SkillsListResponse__SkillErrorInfo),
  skills: Schema.Array(V2SkillsListResponse__SkillMetadata),
});

export type V2ThreadForkResponse__PermissionProfileFileSystemPermissions =
  | {
      readonly entries: ReadonlyArray<V2ThreadForkResponse__FileSystemSandboxEntry>;
      readonly globScanMaxDepth?: number | null;
      readonly type: "restricted";
    }
  | { readonly type: "unrestricted" };
export const V2ThreadForkResponse__PermissionProfileFileSystemPermissions = Schema.Union(
  [
    Schema.Struct({
      entries: Schema.Array(V2ThreadForkResponse__FileSystemSandboxEntry),
      globScanMaxDepth: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(1)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("restricted").annotate({
        title: "RestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "RestrictedPermissionProfileFileSystemPermissions" }),
    Schema.Struct({
      type: Schema.Literal("unrestricted").annotate({
        title: "UnrestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "UnrestrictedPermissionProfileFileSystemPermissions" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadForkResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadForkResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadForkResponse__TurnStatus;
};
export const V2ThreadForkResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadForkResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadForkResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadForkResponse__TurnStatus,
});

export type V2ThreadListResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadListResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadListResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadListResponse__TurnStatus;
};
export const V2ThreadListResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadListResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadListResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadListResponse__TurnStatus,
});

export type V2ThreadMetadataUpdateResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadMetadataUpdateResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadMetadataUpdateResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadMetadataUpdateResponse__TurnStatus;
};
export const V2ThreadMetadataUpdateResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadMetadataUpdateResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadMetadataUpdateResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadMetadataUpdateResponse__TurnStatus,
});

export type V2ThreadReadResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadReadResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadReadResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadReadResponse__TurnStatus;
};
export const V2ThreadReadResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadReadResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadReadResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadReadResponse__TurnStatus,
});

export type V2ThreadResumeResponse__PermissionProfileFileSystemPermissions =
  | {
      readonly entries: ReadonlyArray<V2ThreadResumeResponse__FileSystemSandboxEntry>;
      readonly globScanMaxDepth?: number | null;
      readonly type: "restricted";
    }
  | { readonly type: "unrestricted" };
export const V2ThreadResumeResponse__PermissionProfileFileSystemPermissions = Schema.Union(
  [
    Schema.Struct({
      entries: Schema.Array(V2ThreadResumeResponse__FileSystemSandboxEntry),
      globScanMaxDepth: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(1)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("restricted").annotate({
        title: "RestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "RestrictedPermissionProfileFileSystemPermissions" }),
    Schema.Struct({
      type: Schema.Literal("unrestricted").annotate({
        title: "UnrestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "UnrestrictedPermissionProfileFileSystemPermissions" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadResumeResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadResumeResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadResumeResponse__TurnStatus;
};
export const V2ThreadResumeResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadResumeResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadResumeResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadResumeResponse__TurnStatus,
});

export type V2ThreadRollbackResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadRollbackResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadRollbackResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadRollbackResponse__TurnStatus;
};
export const V2ThreadRollbackResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadRollbackResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadRollbackResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadRollbackResponse__TurnStatus,
});

export type V2ThreadStartedNotification__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadStartedNotification__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadStartedNotification__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadStartedNotification__TurnStatus;
};
export const V2ThreadStartedNotification__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadStartedNotification__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadStartedNotification__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadStartedNotification__TurnStatus,
});

export type V2ThreadStartResponse__PermissionProfileFileSystemPermissions =
  | {
      readonly entries: ReadonlyArray<V2ThreadStartResponse__FileSystemSandboxEntry>;
      readonly globScanMaxDepth?: number | null;
      readonly type: "restricted";
    }
  | { readonly type: "unrestricted" };
export const V2ThreadStartResponse__PermissionProfileFileSystemPermissions = Schema.Union(
  [
    Schema.Struct({
      entries: Schema.Array(V2ThreadStartResponse__FileSystemSandboxEntry),
      globScanMaxDepth: Schema.optionalKey(
        Schema.Union([
          Schema.Number.annotate({ format: "uint" })
            .check(Schema.isInt())
            .check(Schema.isGreaterThanOrEqualTo(1)),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("restricted").annotate({
        title: "RestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "RestrictedPermissionProfileFileSystemPermissions" }),
    Schema.Struct({
      type: Schema.Literal("unrestricted").annotate({
        title: "UnrestrictedPermissionProfileFileSystemPermissionsType",
      }),
    }).annotate({ title: "UnrestrictedPermissionProfileFileSystemPermissions" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadStartResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadStartResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadStartResponse__TurnStatus;
};
export const V2ThreadStartResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadStartResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadStartResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadStartResponse__TurnStatus,
});

export type V2ThreadUnarchiveResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2ThreadUnarchiveResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2ThreadUnarchiveResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2ThreadUnarchiveResponse__TurnStatus;
};
export const V2ThreadUnarchiveResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2ThreadUnarchiveResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2ThreadUnarchiveResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2ThreadUnarchiveResponse__TurnStatus,
});

export type V2TurnCompletedNotification__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2TurnCompletedNotification__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2TurnCompletedNotification__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2TurnCompletedNotification__TurnStatus;
};
export const V2TurnCompletedNotification__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2TurnCompletedNotification__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2TurnCompletedNotification__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2TurnCompletedNotification__TurnStatus,
});

export type V2TurnStartedNotification__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2TurnStartedNotification__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2TurnStartedNotification__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2TurnStartedNotification__TurnStatus;
};
export const V2TurnStartedNotification__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2TurnStartedNotification__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2TurnStartedNotification__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2TurnStartedNotification__TurnStatus,
});

export type V2TurnStartResponse__Turn = {
  readonly completedAt?: number | null;
  readonly durationMs?: number | null;
  readonly error?: V2TurnStartResponse__TurnError | null;
  readonly id: string;
  readonly items: ReadonlyArray<V2TurnStartResponse__ThreadItem>;
  readonly itemsView?: "notLoaded" | "summary" | "full";
  readonly startedAt?: number | null;
  readonly status: V2TurnStartResponse__TurnStatus;
};
export const V2TurnStartResponse__Turn = Schema.Struct({
  completedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn completed.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  durationMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Duration between turn start and completion in milliseconds, if known.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  error: Schema.optionalKey(
    Schema.Union([V2TurnStartResponse__TurnError, Schema.Null]).annotate({
      description: "Only populated when the Turn's status is failed.",
    }),
  ),
  id: Schema.String,
  items: Schema.Array(V2TurnStartResponse__ThreadItem).annotate({
    description: "Thread items currently included in this turn payload.",
  }),
  itemsView: Schema.optionalKey(
    Schema.Literals(["notLoaded", "summary", "full"]).annotate({
      description: "Describes how much of `items` has been loaded for this turn.",
      default: "full",
    }),
  ),
  startedAt: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Unix timestamp (in seconds) when the turn started.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  status: V2TurnStartResponse__TurnStatus,
});

export type McpServerElicitationRequestParams__McpElicitationEnumSchema =
  | McpServerElicitationRequestParams__McpElicitationSingleSelectEnumSchema
  | McpServerElicitationRequestParams__McpElicitationMultiSelectEnumSchema
  | McpServerElicitationRequestParams__McpElicitationLegacyTitledEnumSchema;
export const McpServerElicitationRequestParams__McpElicitationEnumSchema = Schema.Union([
  McpServerElicitationRequestParams__McpElicitationSingleSelectEnumSchema,
  McpServerElicitationRequestParams__McpElicitationMultiSelectEnumSchema,
  McpServerElicitationRequestParams__McpElicitationLegacyTitledEnumSchema,
]);

export type PermissionsRequestApprovalParams__RequestPermissionProfile = {
  readonly fileSystem?: PermissionsRequestApprovalParams__AdditionalFileSystemPermissions | null;
  readonly network?: PermissionsRequestApprovalParams__AdditionalNetworkPermissions | null;
};
export const PermissionsRequestApprovalParams__RequestPermissionProfile = Schema.Struct({
  fileSystem: Schema.optionalKey(
    Schema.Union([PermissionsRequestApprovalParams__AdditionalFileSystemPermissions, Schema.Null]),
  ),
  network: Schema.optionalKey(
    Schema.Union([PermissionsRequestApprovalParams__AdditionalNetworkPermissions, Schema.Null]),
  ),
});

export type PermissionsRequestApprovalResponse__GrantedPermissionProfile = {
  readonly fileSystem?: PermissionsRequestApprovalResponse__AdditionalFileSystemPermissions | null;
  readonly network?: PermissionsRequestApprovalResponse__AdditionalNetworkPermissions | null;
};
export const PermissionsRequestApprovalResponse__GrantedPermissionProfile = Schema.Struct({
  fileSystem: Schema.optionalKey(
    Schema.Union([
      PermissionsRequestApprovalResponse__AdditionalFileSystemPermissions,
      Schema.Null,
    ]),
  ),
  network: Schema.optionalKey(
    Schema.Union([PermissionsRequestApprovalResponse__AdditionalNetworkPermissions, Schema.Null]),
  ),
});

export type ServerNotification__RequestPermissionProfile = {
  readonly fileSystem?: ServerNotification__AdditionalFileSystemPermissions | null;
  readonly network?: ServerNotification__AdditionalNetworkPermissions | null;
};
export const ServerNotification__RequestPermissionProfile = Schema.Struct({
  fileSystem: Schema.optionalKey(
    Schema.Union([ServerNotification__AdditionalFileSystemPermissions, Schema.Null]),
  ),
  network: Schema.optionalKey(
    Schema.Union([ServerNotification__AdditionalNetworkPermissions, Schema.Null]),
  ),
});

export type ServerNotification__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: ServerNotification__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: ServerNotification__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<ServerNotification__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: ServerNotification__ThreadSource | null;
  readonly turns: ReadonlyArray<ServerNotification__Turn>;
  readonly updatedAt: number;
};
export const ServerNotification__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([ServerNotification__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: ServerNotification__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(ServerNotification__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([ServerNotification__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(ServerNotification__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type ServerNotification__TurnCompletedNotification = {
  readonly threadId: string;
  readonly turn: ServerNotification__Turn;
};
export const ServerNotification__TurnCompletedNotification = Schema.Struct({
  threadId: Schema.String,
  turn: ServerNotification__Turn,
});

export type ServerNotification__TurnStartedNotification = {
  readonly threadId: string;
  readonly turn: ServerNotification__Turn;
};
export const ServerNotification__TurnStartedNotification = Schema.Struct({
  threadId: Schema.String,
  turn: ServerNotification__Turn,
});

export type ServerRequest__RequestPermissionProfile = {
  readonly fileSystem?: ServerRequest__AdditionalFileSystemPermissions | null;
  readonly network?: ServerRequest__AdditionalNetworkPermissions | null;
};
export const ServerRequest__RequestPermissionProfile = Schema.Struct({
  fileSystem: Schema.optionalKey(
    Schema.Union([ServerRequest__AdditionalFileSystemPermissions, Schema.Null]),
  ),
  network: Schema.optionalKey(
    Schema.Union([ServerRequest__AdditionalNetworkPermissions, Schema.Null]),
  ),
});

export type ServerRequest__McpElicitationEnumSchema =
  | ServerRequest__McpElicitationSingleSelectEnumSchema
  | ServerRequest__McpElicitationMultiSelectEnumSchema
  | ServerRequest__McpElicitationLegacyTitledEnumSchema;
export const ServerRequest__McpElicitationEnumSchema = Schema.Union([
  ServerRequest__McpElicitationSingleSelectEnumSchema,
  ServerRequest__McpElicitationMultiSelectEnumSchema,
  ServerRequest__McpElicitationLegacyTitledEnumSchema,
]);

export type V2ConfigReadResponse__Config = {
  readonly analytics?: V2ConfigReadResponse__AnalyticsConfig | null;
  readonly approval_policy?: V2ConfigReadResponse__AskForApproval | null;
  readonly approvals_reviewer?: V2ConfigReadResponse__ApprovalsReviewer | null;
  readonly compact_prompt?: string | null;
  readonly developer_instructions?: string | null;
  readonly forced_chatgpt_workspace_id?: string | null;
  readonly forced_login_method?: V2ConfigReadResponse__ForcedLoginMethod | null;
  readonly instructions?: string | null;
  readonly model?: string | null;
  readonly model_auto_compact_token_limit?: number | null;
  readonly model_context_window?: number | null;
  readonly model_provider?: string | null;
  readonly model_reasoning_effort?: V2ConfigReadResponse__ReasoningEffort | null;
  readonly model_reasoning_summary?: V2ConfigReadResponse__ReasoningSummary | null;
  readonly model_verbosity?: V2ConfigReadResponse__Verbosity | null;
  readonly profile?: string | null;
  readonly profiles?: { readonly [x: string]: V2ConfigReadResponse__ProfileV2 };
  readonly review_model?: string | null;
  readonly sandbox_mode?: V2ConfigReadResponse__SandboxMode | null;
  readonly sandbox_workspace_write?: V2ConfigReadResponse__SandboxWorkspaceWrite | null;
  readonly service_tier?: string | null;
  readonly tools?: V2ConfigReadResponse__ToolsV2 | null;
  readonly web_search?: V2ConfigReadResponse__WebSearchMode | null;
  readonly [x: string]: unknown;
};
export const V2ConfigReadResponse__Config = Schema.StructWithRest(
  Schema.Struct({
    analytics: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__AnalyticsConfig, Schema.Null]),
    ),
    approval_policy: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__AskForApproval, Schema.Null]),
    ),
    approvals_reviewer: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__ApprovalsReviewer, Schema.Null]).annotate({
        description:
          "[UNSTABLE] Optional default for where approval requests are routed for review.",
      }),
    ),
    compact_prompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    developer_instructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    forced_chatgpt_workspace_id: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    forced_login_method: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__ForcedLoginMethod, Schema.Null]),
    ),
    instructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    model: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    model_auto_compact_token_limit: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
        Schema.Null,
      ]),
    ),
    model_context_window: Schema.optionalKey(
      Schema.Union([
        Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
        Schema.Null,
      ]),
    ),
    model_provider: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    model_reasoning_effort: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__ReasoningEffort, Schema.Null]),
    ),
    model_reasoning_summary: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__ReasoningSummary, Schema.Null]),
    ),
    model_verbosity: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__Verbosity, Schema.Null]),
    ),
    profile: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    profiles: Schema.optionalKey(
      Schema.Record(Schema.String, V2ConfigReadResponse__ProfileV2).annotate({ default: {} }),
    ),
    review_model: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    sandbox_mode: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__SandboxMode, Schema.Null]),
    ),
    sandbox_workspace_write: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__SandboxWorkspaceWrite, Schema.Null]),
    ),
    service_tier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    tools: Schema.optionalKey(Schema.Union([V2ConfigReadResponse__ToolsV2, Schema.Null])),
    web_search: Schema.optionalKey(
      Schema.Union([V2ConfigReadResponse__WebSearchMode, Schema.Null]),
    ),
  }),
  [Schema.Record(Schema.String, Schema.Unknown)],
);

export type V2ItemGuardianApprovalReviewCompletedNotification__RequestPermissionProfile = {
  readonly fileSystem?: V2ItemGuardianApprovalReviewCompletedNotification__AdditionalFileSystemPermissions | null;
  readonly network?: V2ItemGuardianApprovalReviewCompletedNotification__AdditionalNetworkPermissions | null;
};
export const V2ItemGuardianApprovalReviewCompletedNotification__RequestPermissionProfile =
  Schema.Struct({
    fileSystem: Schema.optionalKey(
      Schema.Union([
        V2ItemGuardianApprovalReviewCompletedNotification__AdditionalFileSystemPermissions,
        Schema.Null,
      ]),
    ),
    network: Schema.optionalKey(
      Schema.Union([
        V2ItemGuardianApprovalReviewCompletedNotification__AdditionalNetworkPermissions,
        Schema.Null,
      ]),
    ),
  });

export type V2ItemGuardianApprovalReviewStartedNotification__RequestPermissionProfile = {
  readonly fileSystem?: V2ItemGuardianApprovalReviewStartedNotification__AdditionalFileSystemPermissions | null;
  readonly network?: V2ItemGuardianApprovalReviewStartedNotification__AdditionalNetworkPermissions | null;
};
export const V2ItemGuardianApprovalReviewStartedNotification__RequestPermissionProfile =
  Schema.Struct({
    fileSystem: Schema.optionalKey(
      Schema.Union([
        V2ItemGuardianApprovalReviewStartedNotification__AdditionalFileSystemPermissions,
        Schema.Null,
      ]),
    ),
    network: Schema.optionalKey(
      Schema.Union([
        V2ItemGuardianApprovalReviewStartedNotification__AdditionalNetworkPermissions,
        Schema.Null,
      ]),
    ),
  });

export type V2PluginListResponse__PluginMarketplaceEntry = {
  readonly interface?: V2PluginListResponse__MarketplaceInterface | null;
  readonly name: string;
  readonly path?: V2PluginListResponse__AbsolutePathBuf | null;
  readonly plugins: ReadonlyArray<V2PluginListResponse__PluginSummary>;
};
export const V2PluginListResponse__PluginMarketplaceEntry = Schema.Struct({
  interface: Schema.optionalKey(
    Schema.Union([V2PluginListResponse__MarketplaceInterface, Schema.Null]),
  ),
  name: Schema.String,
  path: Schema.optionalKey(
    Schema.Union([V2PluginListResponse__AbsolutePathBuf, Schema.Null]).annotate({
      description:
        "Local marketplace file path when the marketplace is backed by a local file. Remote-only catalog marketplaces do not have a local path.",
    }),
  ),
  plugins: Schema.Array(V2PluginListResponse__PluginSummary),
});

export type V2PluginReadResponse__PluginDetail = {
  readonly apps: ReadonlyArray<V2PluginReadResponse__AppSummary>;
  readonly description?: string | null;
  readonly hooks: ReadonlyArray<V2PluginReadResponse__PluginHookSummary>;
  readonly marketplaceName: string;
  readonly marketplacePath?: V2PluginReadResponse__AbsolutePathBuf | null;
  readonly mcpServers: ReadonlyArray<string>;
  readonly skills: ReadonlyArray<V2PluginReadResponse__SkillSummary>;
  readonly summary: V2PluginReadResponse__PluginSummary;
};
export const V2PluginReadResponse__PluginDetail = Schema.Struct({
  apps: Schema.Array(V2PluginReadResponse__AppSummary),
  description: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  hooks: Schema.Array(V2PluginReadResponse__PluginHookSummary),
  marketplaceName: Schema.String,
  marketplacePath: Schema.optionalKey(
    Schema.Union([V2PluginReadResponse__AbsolutePathBuf, Schema.Null]),
  ),
  mcpServers: Schema.Array(Schema.String),
  skills: Schema.Array(V2PluginReadResponse__SkillSummary),
  summary: V2PluginReadResponse__PluginSummary,
});

export type V2PluginShareListResponse__PluginShareListItem = {
  readonly localPluginPath?: V2PluginShareListResponse__AbsolutePathBuf | null;
  readonly plugin: V2PluginShareListResponse__PluginSummary;
  readonly shareUrl: string;
};
export const V2PluginShareListResponse__PluginShareListItem = Schema.Struct({
  localPluginPath: Schema.optionalKey(
    Schema.Union([V2PluginShareListResponse__AbsolutePathBuf, Schema.Null]),
  ),
  plugin: V2PluginShareListResponse__PluginSummary,
  shareUrl: Schema.String,
});

export type V2ThreadForkResponse__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadForkResponse__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadForkResponse__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadForkResponse__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadForkResponse__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadForkResponse__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadForkResponse__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadForkResponse__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadForkResponse__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadForkResponse__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadForkResponse__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadForkResponse__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type V2ThreadListResponse__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadListResponse__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadListResponse__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadListResponse__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadListResponse__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadListResponse__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadListResponse__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadListResponse__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadListResponse__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadListResponse__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadListResponse__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadListResponse__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type V2ThreadMetadataUpdateResponse__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadMetadataUpdateResponse__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadMetadataUpdateResponse__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadMetadataUpdateResponse__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadMetadataUpdateResponse__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadMetadataUpdateResponse__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadMetadataUpdateResponse__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadMetadataUpdateResponse__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadMetadataUpdateResponse__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadMetadataUpdateResponse__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadMetadataUpdateResponse__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadMetadataUpdateResponse__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type V2ThreadReadResponse__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadReadResponse__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadReadResponse__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadReadResponse__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadReadResponse__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadReadResponse__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadReadResponse__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadReadResponse__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadReadResponse__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadReadResponse__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadReadResponse__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadReadResponse__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type V2ThreadResumeResponse__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadResumeResponse__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadResumeResponse__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadResumeResponse__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadResumeResponse__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadResumeResponse__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadResumeResponse__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadResumeResponse__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadResumeResponse__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadResumeResponse__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadResumeResponse__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadResumeResponse__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type V2ThreadStartedNotification__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadStartedNotification__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadStartedNotification__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadStartedNotification__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadStartedNotification__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadStartedNotification__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadStartedNotification__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadStartedNotification__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadStartedNotification__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadStartedNotification__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadStartedNotification__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadStartedNotification__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type V2ThreadStartResponse__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadStartResponse__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadStartResponse__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadStartResponse__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadStartResponse__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadStartResponse__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadStartResponse__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadStartResponse__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadStartResponse__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadStartResponse__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadStartResponse__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadStartResponse__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type V2ThreadUnarchiveResponse__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadUnarchiveResponse__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadUnarchiveResponse__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadUnarchiveResponse__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadUnarchiveResponse__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadUnarchiveResponse__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadUnarchiveResponse__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadUnarchiveResponse__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadUnarchiveResponse__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadUnarchiveResponse__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadUnarchiveResponse__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadUnarchiveResponse__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type McpServerElicitationRequestParams__McpElicitationPrimitiveSchema =
  | McpServerElicitationRequestParams__McpElicitationEnumSchema
  | McpServerElicitationRequestParams__McpElicitationStringSchema
  | McpServerElicitationRequestParams__McpElicitationNumberSchema
  | McpServerElicitationRequestParams__McpElicitationBooleanSchema;
export const McpServerElicitationRequestParams__McpElicitationPrimitiveSchema = Schema.Union([
  McpServerElicitationRequestParams__McpElicitationEnumSchema,
  McpServerElicitationRequestParams__McpElicitationStringSchema,
  McpServerElicitationRequestParams__McpElicitationNumberSchema,
  McpServerElicitationRequestParams__McpElicitationBooleanSchema,
]);

export type ServerNotification__GuardianApprovalReviewAction =
  | {
      readonly command: string;
      readonly cwd: ServerNotification__AbsolutePathBuf;
      readonly source: ServerNotification__GuardianCommandSource;
      readonly type: "command";
    }
  | {
      readonly argv: ReadonlyArray<string>;
      readonly cwd: ServerNotification__AbsolutePathBuf;
      readonly program: string;
      readonly source: ServerNotification__GuardianCommandSource;
      readonly type: "execve";
    }
  | {
      readonly cwd: ServerNotification__AbsolutePathBuf;
      readonly files: ReadonlyArray<ServerNotification__AbsolutePathBuf>;
      readonly type: "applyPatch";
    }
  | {
      readonly host: string;
      readonly port: number;
      readonly protocol: ServerNotification__NetworkApprovalProtocol;
      readonly target: string;
      readonly type: "networkAccess";
    }
  | {
      readonly connectorId?: string | null;
      readonly connectorName?: string | null;
      readonly server: string;
      readonly toolName: string;
      readonly toolTitle?: string | null;
      readonly type: "mcpToolCall";
    }
  | {
      readonly permissions: ServerNotification__RequestPermissionProfile;
      readonly reason?: string | null;
      readonly type: "requestPermissions";
    };
export const ServerNotification__GuardianApprovalReviewAction = Schema.Union(
  [
    Schema.Struct({
      command: Schema.String,
      cwd: ServerNotification__AbsolutePathBuf,
      source: ServerNotification__GuardianCommandSource,
      type: Schema.Literal("command").annotate({
        title: "CommandGuardianApprovalReviewActionType",
      }),
    }).annotate({ title: "CommandGuardianApprovalReviewAction" }),
    Schema.Struct({
      argv: Schema.Array(Schema.String),
      cwd: ServerNotification__AbsolutePathBuf,
      program: Schema.String,
      source: ServerNotification__GuardianCommandSource,
      type: Schema.Literal("execve").annotate({ title: "ExecveGuardianApprovalReviewActionType" }),
    }).annotate({ title: "ExecveGuardianApprovalReviewAction" }),
    Schema.Struct({
      cwd: ServerNotification__AbsolutePathBuf,
      files: Schema.Array(ServerNotification__AbsolutePathBuf),
      type: Schema.Literal("applyPatch").annotate({
        title: "ApplyPatchGuardianApprovalReviewActionType",
      }),
    }).annotate({ title: "ApplyPatchGuardianApprovalReviewAction" }),
    Schema.Struct({
      host: Schema.String,
      port: Schema.Number.annotate({ format: "uint16" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      protocol: ServerNotification__NetworkApprovalProtocol,
      target: Schema.String,
      type: Schema.Literal("networkAccess").annotate({
        title: "NetworkAccessGuardianApprovalReviewActionType",
      }),
    }).annotate({ title: "NetworkAccessGuardianApprovalReviewAction" }),
    Schema.Struct({
      connectorId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      connectorName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      server: Schema.String,
      toolName: Schema.String,
      toolTitle: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("mcpToolCall").annotate({
        title: "McpToolCallGuardianApprovalReviewActionType",
      }),
    }).annotate({ title: "McpToolCallGuardianApprovalReviewAction" }),
    Schema.Struct({
      permissions: ServerNotification__RequestPermissionProfile,
      reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("requestPermissions").annotate({
        title: "RequestPermissionsGuardianApprovalReviewActionType",
      }),
    }).annotate({ title: "RequestPermissionsGuardianApprovalReviewAction" }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__ThreadStartedNotification = {
  readonly thread: ServerNotification__Thread;
};
export const ServerNotification__ThreadStartedNotification = Schema.Struct({
  thread: ServerNotification__Thread,
});

export type ServerRequest__PermissionsRequestApprovalParams = {
  readonly cwd: ServerRequest__AbsolutePathBuf;
  readonly itemId: string;
  readonly permissions: ServerRequest__RequestPermissionProfile;
  readonly reason?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerRequest__PermissionsRequestApprovalParams = Schema.Struct({
  cwd: ServerRequest__AbsolutePathBuf,
  itemId: Schema.String,
  permissions: ServerRequest__RequestPermissionProfile,
  reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
  turnId: Schema.String,
});

export type ServerRequest__McpElicitationPrimitiveSchema =
  | ServerRequest__McpElicitationEnumSchema
  | ServerRequest__McpElicitationStringSchema
  | ServerRequest__McpElicitationNumberSchema
  | ServerRequest__McpElicitationBooleanSchema;
export const ServerRequest__McpElicitationPrimitiveSchema = Schema.Union([
  ServerRequest__McpElicitationEnumSchema,
  ServerRequest__McpElicitationStringSchema,
  ServerRequest__McpElicitationNumberSchema,
  ServerRequest__McpElicitationBooleanSchema,
]);

export type V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReviewAction =
  | {
      readonly command: string;
      readonly cwd: V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf;
      readonly source: V2ItemGuardianApprovalReviewCompletedNotification__GuardianCommandSource;
      readonly type: "command";
    }
  | {
      readonly argv: ReadonlyArray<string>;
      readonly cwd: V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf;
      readonly program: string;
      readonly source: V2ItemGuardianApprovalReviewCompletedNotification__GuardianCommandSource;
      readonly type: "execve";
    }
  | {
      readonly cwd: V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf;
      readonly files: ReadonlyArray<V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf>;
      readonly type: "applyPatch";
    }
  | {
      readonly host: string;
      readonly port: number;
      readonly protocol: V2ItemGuardianApprovalReviewCompletedNotification__NetworkApprovalProtocol;
      readonly target: string;
      readonly type: "networkAccess";
    }
  | {
      readonly connectorId?: string | null;
      readonly connectorName?: string | null;
      readonly server: string;
      readonly toolName: string;
      readonly toolTitle?: string | null;
      readonly type: "mcpToolCall";
    }
  | {
      readonly permissions: V2ItemGuardianApprovalReviewCompletedNotification__RequestPermissionProfile;
      readonly reason?: string | null;
      readonly type: "requestPermissions";
    };
export const V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReviewAction =
  Schema.Union(
    [
      Schema.Struct({
        command: Schema.String,
        cwd: V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf,
        source: V2ItemGuardianApprovalReviewCompletedNotification__GuardianCommandSource,
        type: Schema.Literal("command").annotate({
          title: "CommandGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "CommandGuardianApprovalReviewAction" }),
      Schema.Struct({
        argv: Schema.Array(Schema.String),
        cwd: V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf,
        program: Schema.String,
        source: V2ItemGuardianApprovalReviewCompletedNotification__GuardianCommandSource,
        type: Schema.Literal("execve").annotate({
          title: "ExecveGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "ExecveGuardianApprovalReviewAction" }),
      Schema.Struct({
        cwd: V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf,
        files: Schema.Array(V2ItemGuardianApprovalReviewCompletedNotification__AbsolutePathBuf),
        type: Schema.Literal("applyPatch").annotate({
          title: "ApplyPatchGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "ApplyPatchGuardianApprovalReviewAction" }),
      Schema.Struct({
        host: Schema.String,
        port: Schema.Number.annotate({ format: "uint16" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
        protocol: V2ItemGuardianApprovalReviewCompletedNotification__NetworkApprovalProtocol,
        target: Schema.String,
        type: Schema.Literal("networkAccess").annotate({
          title: "NetworkAccessGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "NetworkAccessGuardianApprovalReviewAction" }),
      Schema.Struct({
        connectorId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        connectorName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        server: Schema.String,
        toolName: Schema.String,
        toolTitle: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        type: Schema.Literal("mcpToolCall").annotate({
          title: "McpToolCallGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "McpToolCallGuardianApprovalReviewAction" }),
      Schema.Struct({
        permissions: V2ItemGuardianApprovalReviewCompletedNotification__RequestPermissionProfile,
        reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        type: Schema.Literal("requestPermissions").annotate({
          title: "RequestPermissionsGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "RequestPermissionsGuardianApprovalReviewAction" }),
    ],
    { mode: "oneOf" },
  );

export type V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReviewAction =
  | {
      readonly command: string;
      readonly cwd: V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf;
      readonly source: V2ItemGuardianApprovalReviewStartedNotification__GuardianCommandSource;
      readonly type: "command";
    }
  | {
      readonly argv: ReadonlyArray<string>;
      readonly cwd: V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf;
      readonly program: string;
      readonly source: V2ItemGuardianApprovalReviewStartedNotification__GuardianCommandSource;
      readonly type: "execve";
    }
  | {
      readonly cwd: V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf;
      readonly files: ReadonlyArray<V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf>;
      readonly type: "applyPatch";
    }
  | {
      readonly host: string;
      readonly port: number;
      readonly protocol: V2ItemGuardianApprovalReviewStartedNotification__NetworkApprovalProtocol;
      readonly target: string;
      readonly type: "networkAccess";
    }
  | {
      readonly connectorId?: string | null;
      readonly connectorName?: string | null;
      readonly server: string;
      readonly toolName: string;
      readonly toolTitle?: string | null;
      readonly type: "mcpToolCall";
    }
  | {
      readonly permissions: V2ItemGuardianApprovalReviewStartedNotification__RequestPermissionProfile;
      readonly reason?: string | null;
      readonly type: "requestPermissions";
    };
export const V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReviewAction =
  Schema.Union(
    [
      Schema.Struct({
        command: Schema.String,
        cwd: V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf,
        source: V2ItemGuardianApprovalReviewStartedNotification__GuardianCommandSource,
        type: Schema.Literal("command").annotate({
          title: "CommandGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "CommandGuardianApprovalReviewAction" }),
      Schema.Struct({
        argv: Schema.Array(Schema.String),
        cwd: V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf,
        program: Schema.String,
        source: V2ItemGuardianApprovalReviewStartedNotification__GuardianCommandSource,
        type: Schema.Literal("execve").annotate({
          title: "ExecveGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "ExecveGuardianApprovalReviewAction" }),
      Schema.Struct({
        cwd: V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf,
        files: Schema.Array(V2ItemGuardianApprovalReviewStartedNotification__AbsolutePathBuf),
        type: Schema.Literal("applyPatch").annotate({
          title: "ApplyPatchGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "ApplyPatchGuardianApprovalReviewAction" }),
      Schema.Struct({
        host: Schema.String,
        port: Schema.Number.annotate({ format: "uint16" })
          .check(Schema.isInt())
          .check(Schema.isGreaterThanOrEqualTo(0)),
        protocol: V2ItemGuardianApprovalReviewStartedNotification__NetworkApprovalProtocol,
        target: Schema.String,
        type: Schema.Literal("networkAccess").annotate({
          title: "NetworkAccessGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "NetworkAccessGuardianApprovalReviewAction" }),
      Schema.Struct({
        connectorId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        connectorName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        server: Schema.String,
        toolName: Schema.String,
        toolTitle: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        type: Schema.Literal("mcpToolCall").annotate({
          title: "McpToolCallGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "McpToolCallGuardianApprovalReviewAction" }),
      Schema.Struct({
        permissions: V2ItemGuardianApprovalReviewStartedNotification__RequestPermissionProfile,
        reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
        type: Schema.Literal("requestPermissions").annotate({
          title: "RequestPermissionsGuardianApprovalReviewActionType",
        }),
      }).annotate({ title: "RequestPermissionsGuardianApprovalReviewAction" }),
    ],
    { mode: "oneOf" },
  );

export type McpServerElicitationRequestParams__McpElicitationSchema = {
  readonly $schema?: string | null;
  readonly properties: {
    readonly [x: string]: McpServerElicitationRequestParams__McpElicitationPrimitiveSchema;
  };
  readonly required?: ReadonlyArray<string> | null;
  readonly type: McpServerElicitationRequestParams__McpElicitationObjectType;
};
export const McpServerElicitationRequestParams__McpElicitationSchema = Schema.Struct({
  $schema: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  properties: Schema.Record(
    Schema.String,
    McpServerElicitationRequestParams__McpElicitationPrimitiveSchema,
  ),
  required: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  type: McpServerElicitationRequestParams__McpElicitationObjectType,
}).annotate({
  description:
    "Typed form schema for MCP `elicitation/create` requests.\n\nThis matches the `requestedSchema` shape from the MCP 2025-11-25 `ElicitRequestFormParams` schema.",
});

export type ServerNotification__ItemGuardianApprovalReviewCompletedNotification = {
  readonly action: ServerNotification__GuardianApprovalReviewAction;
  readonly decisionSource: ServerNotification__AutoReviewDecisionSource;
  readonly review: ServerNotification__GuardianApprovalReview;
  readonly reviewId: string;
  readonly targetItemId?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__ItemGuardianApprovalReviewCompletedNotification = Schema.Struct({
  action: ServerNotification__GuardianApprovalReviewAction,
  decisionSource: ServerNotification__AutoReviewDecisionSource,
  review: ServerNotification__GuardianApprovalReview,
  reviewId: Schema.String.annotate({ description: "Stable identifier for this review." }),
  targetItemId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  description:
    "[UNSTABLE] Temporary notification payload for approval auto-review. This shape is expected to change soon.",
});

export type ServerNotification__ItemGuardianApprovalReviewStartedNotification = {
  readonly action: ServerNotification__GuardianApprovalReviewAction;
  readonly review: ServerNotification__GuardianApprovalReview;
  readonly reviewId: string;
  readonly targetItemId?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const ServerNotification__ItemGuardianApprovalReviewStartedNotification = Schema.Struct({
  action: ServerNotification__GuardianApprovalReviewAction,
  review: ServerNotification__GuardianApprovalReview,
  reviewId: Schema.String.annotate({ description: "Stable identifier for this review." }),
  targetItemId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  description:
    "[UNSTABLE] Temporary notification payload for approval auto-review. This shape is expected to change soon.",
});

export type ServerRequest__McpElicitationSchema = {
  readonly $schema?: string | null;
  readonly properties: { readonly [x: string]: ServerRequest__McpElicitationPrimitiveSchema };
  readonly required?: ReadonlyArray<string> | null;
  readonly type: ServerRequest__McpElicitationObjectType;
};
export const ServerRequest__McpElicitationSchema = Schema.Struct({
  $schema: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  properties: Schema.Record(Schema.String, ServerRequest__McpElicitationPrimitiveSchema),
  required: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  type: ServerRequest__McpElicitationObjectType,
}).annotate({
  description:
    "Typed form schema for MCP `elicitation/create` requests.\n\nThis matches the `requestedSchema` shape from the MCP 2025-11-25 `ElicitRequestFormParams` schema.",
});

export type ServerRequest__McpServerElicitationRequestParams =
  | {
      readonly _meta?: unknown;
      readonly message: string;
      readonly mode: "form";
      readonly requestedSchema: ServerRequest__McpElicitationSchema;
      readonly serverName: string;
      readonly threadId: string;
      readonly turnId?: string | null;
    }
  | {
      readonly _meta?: unknown;
      readonly elicitationId: string;
      readonly message: string;
      readonly mode: "url";
      readonly url: string;
      readonly serverName: string;
      readonly threadId: string;
      readonly turnId?: string | null;
    };
export const ServerRequest__McpServerElicitationRequestParams = Schema.Union(
  [
    Schema.Struct({
      _meta: Schema.optionalKey(Schema.Unknown),
      message: Schema.String,
      mode: Schema.Literal("form"),
      requestedSchema: ServerRequest__McpElicitationSchema,
      serverName: Schema.String,
      threadId: Schema.String,
      turnId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description:
              "Active Codex turn when this elicitation was observed, if app-server could correlate one.\n\nThis is nullable because MCP models elicitation as a standalone server-to-client request identified by the MCP server request id. It may be triggered during a turn, but turn context is app-server correlation rather than part of the protocol identity of the elicitation itself.",
          }),
          Schema.Null,
        ]),
      ),
    }),
    Schema.Struct({
      _meta: Schema.optionalKey(Schema.Unknown),
      elicitationId: Schema.String,
      message: Schema.String,
      mode: Schema.Literal("url"),
      url: Schema.String,
      serverName: Schema.String,
      threadId: Schema.String,
      turnId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description:
              "Active Codex turn when this elicitation was observed, if app-server could correlate one.\n\nThis is nullable because MCP models elicitation as a standalone server-to-client request identified by the MCP server request id. It may be triggered during a turn, but turn context is app-server correlation rather than part of the protocol identity of the elicitation itself.",
          }),
          Schema.Null,
        ]),
      ),
    }),
  ],
  { mode: "oneOf" },
);

export type ApplyPatchApprovalParams = {
  readonly callId: string;
  readonly conversationId: ApplyPatchApprovalParams__ThreadId;
  readonly fileChanges: { readonly [x: string]: ApplyPatchApprovalParams__FileChange };
  readonly grantRoot?: string | null;
  readonly reason?: string | null;
};
export const ApplyPatchApprovalParams = Schema.Struct({
  callId: Schema.String.annotate({
    description:
      "Use to correlate this with [codex_protocol::protocol::PatchApplyBeginEvent] and [codex_protocol::protocol::PatchApplyEndEvent].",
  }),
  conversationId: ApplyPatchApprovalParams__ThreadId,
  fileChanges: Schema.Record(Schema.String, ApplyPatchApprovalParams__FileChange),
  grantRoot: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "When set, the agent is asking the user to allow writes under this root for the remainder of the session (unclear if this is honored today).",
      }),
      Schema.Null,
    ]),
  ),
  reason: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional explanatory reason (e.g. request for extra write access).",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ApplyPatchApprovalParams" });

export type ApplyPatchApprovalResponse = {
  readonly decision: ApplyPatchApprovalResponse__ReviewDecision;
};
export const ApplyPatchApprovalResponse = Schema.Struct({
  decision: ApplyPatchApprovalResponse__ReviewDecision,
}).annotate({ title: "ApplyPatchApprovalResponse" });

export type ChatgptAuthTokensRefreshParams = {
  readonly previousAccountId?: string | null;
  readonly reason: ChatgptAuthTokensRefreshParams__ChatgptAuthTokensRefreshReason;
};
export const ChatgptAuthTokensRefreshParams = Schema.Struct({
  previousAccountId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Workspace/account identifier that Codex was previously using.\n\nClients that manage multiple accounts/workspaces can use this as a hint to refresh the token for the correct workspace.\n\nThis may be `null` when the prior auth state did not include a workspace identifier (`chatgpt_account_id`).",
      }),
      Schema.Null,
    ]),
  ),
  reason: ChatgptAuthTokensRefreshParams__ChatgptAuthTokensRefreshReason,
}).annotate({ title: "ChatgptAuthTokensRefreshParams" });

export type ChatgptAuthTokensRefreshResponse = {
  readonly accessToken: string;
  readonly chatgptAccountId: string;
  readonly chatgptPlanType?: string | null;
};
export const ChatgptAuthTokensRefreshResponse = Schema.Struct({
  accessToken: Schema.String,
  chatgptAccountId: Schema.String,
  chatgptPlanType: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "ChatgptAuthTokensRefreshResponse" });

export type ClientNotification = { readonly method: "initialized" };
export const ClientNotification = Schema.Union(
  [
    Schema.Struct({
      method: Schema.Literal("initialized").annotate({ title: "InitializedNotificationMethod" }),
    }).annotate({ title: "InitializedNotification" }),
  ],
  { mode: "oneOf" },
).annotate({ title: "ClientNotification" });

export type ClientRequest =
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "initialize";
      readonly params: ClientRequest__InitializeParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/start";
      readonly params: ClientRequest__ThreadStartParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/resume";
      readonly params: ClientRequest__ThreadResumeParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/fork";
      readonly params: ClientRequest__ThreadForkParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/archive";
      readonly params: ClientRequest__ThreadArchiveParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/unsubscribe";
      readonly params: ClientRequest__ThreadUnsubscribeParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/name/set";
      readonly params: ClientRequest__ThreadSetNameParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/metadata/update";
      readonly params: ClientRequest__ThreadMetadataUpdateParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/unarchive";
      readonly params: ClientRequest__ThreadUnarchiveParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/compact/start";
      readonly params: ClientRequest__ThreadCompactStartParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/shellCommand";
      readonly params: ClientRequest__ThreadShellCommandParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/approveGuardianDeniedAction";
      readonly params: ClientRequest__ThreadApproveGuardianDeniedActionParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/rollback";
      readonly params: ClientRequest__ThreadRollbackParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/list";
      readonly params: ClientRequest__ThreadListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/loaded/list";
      readonly params: ClientRequest__ThreadLoadedListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/read";
      readonly params: ClientRequest__ThreadReadParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "thread/inject_items";
      readonly params: ClientRequest__ThreadInjectItemsParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "skills/list";
      readonly params: ClientRequest__SkillsListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "hooks/list";
      readonly params: ClientRequest__HooksListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "marketplace/add";
      readonly params: ClientRequest__MarketplaceAddParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "marketplace/remove";
      readonly params: ClientRequest__MarketplaceRemoveParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "marketplace/upgrade";
      readonly params: ClientRequest__MarketplaceUpgradeParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/list";
      readonly params: ClientRequest__PluginListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/read";
      readonly params: ClientRequest__PluginReadParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/skill/read";
      readonly params: ClientRequest__PluginSkillReadParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/share/save";
      readonly params: ClientRequest__PluginShareSaveParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/share/updateTargets";
      readonly params: ClientRequest__PluginShareUpdateTargetsParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/share/list";
      readonly params: ClientRequest__PluginShareListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/share/delete";
      readonly params: ClientRequest__PluginShareDeleteParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "app/list";
      readonly params: ClientRequest__AppsListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/readFile";
      readonly params: ClientRequest__FsReadFileParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/writeFile";
      readonly params: ClientRequest__FsWriteFileParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/createDirectory";
      readonly params: ClientRequest__FsCreateDirectoryParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/getMetadata";
      readonly params: ClientRequest__FsGetMetadataParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/readDirectory";
      readonly params: ClientRequest__FsReadDirectoryParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/remove";
      readonly params: ClientRequest__FsRemoveParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/copy";
      readonly params: ClientRequest__FsCopyParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/watch";
      readonly params: ClientRequest__FsWatchParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fs/unwatch";
      readonly params: ClientRequest__FsUnwatchParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "skills/config/write";
      readonly params: ClientRequest__SkillsConfigWriteParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/install";
      readonly params: ClientRequest__PluginInstallParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "plugin/uninstall";
      readonly params: ClientRequest__PluginUninstallParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "turn/start";
      readonly params: ClientRequest__TurnStartParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "turn/steer";
      readonly params: ClientRequest__TurnSteerParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "turn/interrupt";
      readonly params: ClientRequest__TurnInterruptParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "review/start";
      readonly params: ClientRequest__ReviewStartParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "model/list";
      readonly params: ClientRequest__ModelListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "modelProvider/capabilities/read";
      readonly params: ClientRequest__ModelProviderCapabilitiesReadParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "experimentalFeature/list";
      readonly params: ClientRequest__ExperimentalFeatureListParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "experimentalFeature/enablement/set";
      readonly params: ClientRequest__ExperimentalFeatureEnablementSetParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "mcpServer/oauth/login";
      readonly params: ClientRequest__McpServerOauthLoginParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "config/mcpServer/reload";
      readonly params?: null;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "mcpServerStatus/list";
      readonly params: ClientRequest__ListMcpServerStatusParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "mcpServer/resource/read";
      readonly params: ClientRequest__McpResourceReadParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "mcpServer/tool/call";
      readonly params: ClientRequest__McpServerToolCallParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "windowsSandbox/setupStart";
      readonly params: ClientRequest__WindowsSandboxSetupStartParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "windowsSandbox/readiness";
      readonly params?: null;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "account/login/start";
      readonly params: ClientRequest__LoginAccountParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "account/login/cancel";
      readonly params: ClientRequest__CancelLoginAccountParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "account/logout";
      readonly params?: null;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "account/rateLimits/read";
      readonly params?: null;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "account/sendAddCreditsNudgeEmail";
      readonly params: ClientRequest__SendAddCreditsNudgeEmailParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "feedback/upload";
      readonly params: ClientRequest__FeedbackUploadParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "command/exec";
      readonly params: ClientRequest__CommandExecParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "command/exec/write";
      readonly params: ClientRequest__CommandExecWriteParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "command/exec/terminate";
      readonly params: ClientRequest__CommandExecTerminateParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "command/exec/resize";
      readonly params: ClientRequest__CommandExecResizeParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "config/read";
      readonly params: ClientRequest__ConfigReadParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "externalAgentConfig/detect";
      readonly params: ClientRequest__ExternalAgentConfigDetectParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "externalAgentConfig/import";
      readonly params: ClientRequest__ExternalAgentConfigImportParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "config/value/write";
      readonly params: ClientRequest__ConfigValueWriteParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "config/batchWrite";
      readonly params: ClientRequest__ConfigBatchWriteParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "configRequirements/read";
      readonly params?: null;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "account/read";
      readonly params: ClientRequest__GetAccountParams;
    }
  | {
      readonly id: ClientRequest__RequestId;
      readonly method: "fuzzyFileSearch";
      readonly params: ClientRequest__FuzzyFileSearchParams;
    };
export const ClientRequest = Schema.Union(
  [
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("initialize").annotate({ title: "InitializeRequestMethod" }),
      params: ClientRequest__InitializeParams,
    }).annotate({ title: "InitializeRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/start").annotate({ title: "Thread/startRequestMethod" }),
      params: ClientRequest__ThreadStartParams,
    }).annotate({ title: "Thread/startRequest", description: "NEW APIs" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/resume").annotate({ title: "Thread/resumeRequestMethod" }),
      params: ClientRequest__ThreadResumeParams,
    }).annotate({ title: "Thread/resumeRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/fork").annotate({ title: "Thread/forkRequestMethod" }),
      params: ClientRequest__ThreadForkParams,
    }).annotate({ title: "Thread/forkRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/archive").annotate({ title: "Thread/archiveRequestMethod" }),
      params: ClientRequest__ThreadArchiveParams,
    }).annotate({ title: "Thread/archiveRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/unsubscribe").annotate({
        title: "Thread/unsubscribeRequestMethod",
      }),
      params: ClientRequest__ThreadUnsubscribeParams,
    }).annotate({ title: "Thread/unsubscribeRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/name/set").annotate({ title: "Thread/name/setRequestMethod" }),
      params: ClientRequest__ThreadSetNameParams,
    }).annotate({ title: "Thread/name/setRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/metadata/update").annotate({
        title: "Thread/metadata/updateRequestMethod",
      }),
      params: ClientRequest__ThreadMetadataUpdateParams,
    }).annotate({ title: "Thread/metadata/updateRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/unarchive").annotate({
        title: "Thread/unarchiveRequestMethod",
      }),
      params: ClientRequest__ThreadUnarchiveParams,
    }).annotate({ title: "Thread/unarchiveRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/compact/start").annotate({
        title: "Thread/compact/startRequestMethod",
      }),
      params: ClientRequest__ThreadCompactStartParams,
    }).annotate({ title: "Thread/compact/startRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/shellCommand").annotate({
        title: "Thread/shellCommandRequestMethod",
      }),
      params: ClientRequest__ThreadShellCommandParams,
    }).annotate({ title: "Thread/shellCommandRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/approveGuardianDeniedAction").annotate({
        title: "Thread/approveGuardianDeniedActionRequestMethod",
      }),
      params: ClientRequest__ThreadApproveGuardianDeniedActionParams,
    }).annotate({ title: "Thread/approveGuardianDeniedActionRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/rollback").annotate({ title: "Thread/rollbackRequestMethod" }),
      params: ClientRequest__ThreadRollbackParams,
    }).annotate({ title: "Thread/rollbackRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/list").annotate({ title: "Thread/listRequestMethod" }),
      params: ClientRequest__ThreadListParams,
    }).annotate({ title: "Thread/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/loaded/list").annotate({
        title: "Thread/loaded/listRequestMethod",
      }),
      params: ClientRequest__ThreadLoadedListParams,
    }).annotate({ title: "Thread/loaded/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/read").annotate({ title: "Thread/readRequestMethod" }),
      params: ClientRequest__ThreadReadParams,
    }).annotate({ title: "Thread/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("thread/inject_items").annotate({
        title: "Thread/injectItemsRequestMethod",
      }),
      params: ClientRequest__ThreadInjectItemsParams,
    }).annotate({
      title: "Thread/injectItemsRequest",
      description:
        "Append raw Responses API items to the thread history without starting a user turn.",
    }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("skills/list").annotate({ title: "Skills/listRequestMethod" }),
      params: ClientRequest__SkillsListParams,
    }).annotate({ title: "Skills/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("hooks/list").annotate({ title: "Hooks/listRequestMethod" }),
      params: ClientRequest__HooksListParams,
    }).annotate({ title: "Hooks/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("marketplace/add").annotate({ title: "Marketplace/addRequestMethod" }),
      params: ClientRequest__MarketplaceAddParams,
    }).annotate({ title: "Marketplace/addRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("marketplace/remove").annotate({
        title: "Marketplace/removeRequestMethod",
      }),
      params: ClientRequest__MarketplaceRemoveParams,
    }).annotate({ title: "Marketplace/removeRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("marketplace/upgrade").annotate({
        title: "Marketplace/upgradeRequestMethod",
      }),
      params: ClientRequest__MarketplaceUpgradeParams,
    }).annotate({ title: "Marketplace/upgradeRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/list").annotate({ title: "Plugin/listRequestMethod" }),
      params: ClientRequest__PluginListParams,
    }).annotate({ title: "Plugin/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/read").annotate({ title: "Plugin/readRequestMethod" }),
      params: ClientRequest__PluginReadParams,
    }).annotate({ title: "Plugin/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/skill/read").annotate({
        title: "Plugin/skill/readRequestMethod",
      }),
      params: ClientRequest__PluginSkillReadParams,
    }).annotate({ title: "Plugin/skill/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/share/save").annotate({
        title: "Plugin/share/saveRequestMethod",
      }),
      params: ClientRequest__PluginShareSaveParams,
    }).annotate({ title: "Plugin/share/saveRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/share/updateTargets").annotate({
        title: "Plugin/share/updateTargetsRequestMethod",
      }),
      params: ClientRequest__PluginShareUpdateTargetsParams,
    }).annotate({ title: "Plugin/share/updateTargetsRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/share/list").annotate({
        title: "Plugin/share/listRequestMethod",
      }),
      params: ClientRequest__PluginShareListParams,
    }).annotate({ title: "Plugin/share/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/share/delete").annotate({
        title: "Plugin/share/deleteRequestMethod",
      }),
      params: ClientRequest__PluginShareDeleteParams,
    }).annotate({ title: "Plugin/share/deleteRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("app/list").annotate({ title: "App/listRequestMethod" }),
      params: ClientRequest__AppsListParams,
    }).annotate({ title: "App/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/readFile").annotate({ title: "Fs/readFileRequestMethod" }),
      params: ClientRequest__FsReadFileParams,
    }).annotate({ title: "Fs/readFileRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/writeFile").annotate({ title: "Fs/writeFileRequestMethod" }),
      params: ClientRequest__FsWriteFileParams,
    }).annotate({ title: "Fs/writeFileRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/createDirectory").annotate({
        title: "Fs/createDirectoryRequestMethod",
      }),
      params: ClientRequest__FsCreateDirectoryParams,
    }).annotate({ title: "Fs/createDirectoryRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/getMetadata").annotate({ title: "Fs/getMetadataRequestMethod" }),
      params: ClientRequest__FsGetMetadataParams,
    }).annotate({ title: "Fs/getMetadataRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/readDirectory").annotate({
        title: "Fs/readDirectoryRequestMethod",
      }),
      params: ClientRequest__FsReadDirectoryParams,
    }).annotate({ title: "Fs/readDirectoryRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/remove").annotate({ title: "Fs/removeRequestMethod" }),
      params: ClientRequest__FsRemoveParams,
    }).annotate({ title: "Fs/removeRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/copy").annotate({ title: "Fs/copyRequestMethod" }),
      params: ClientRequest__FsCopyParams,
    }).annotate({ title: "Fs/copyRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/watch").annotate({ title: "Fs/watchRequestMethod" }),
      params: ClientRequest__FsWatchParams,
    }).annotate({ title: "Fs/watchRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fs/unwatch").annotate({ title: "Fs/unwatchRequestMethod" }),
      params: ClientRequest__FsUnwatchParams,
    }).annotate({ title: "Fs/unwatchRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("skills/config/write").annotate({
        title: "Skills/config/writeRequestMethod",
      }),
      params: ClientRequest__SkillsConfigWriteParams,
    }).annotate({ title: "Skills/config/writeRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/install").annotate({ title: "Plugin/installRequestMethod" }),
      params: ClientRequest__PluginInstallParams,
    }).annotate({ title: "Plugin/installRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("plugin/uninstall").annotate({
        title: "Plugin/uninstallRequestMethod",
      }),
      params: ClientRequest__PluginUninstallParams,
    }).annotate({ title: "Plugin/uninstallRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("turn/start").annotate({ title: "Turn/startRequestMethod" }),
      params: ClientRequest__TurnStartParams,
    }).annotate({ title: "Turn/startRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("turn/steer").annotate({ title: "Turn/steerRequestMethod" }),
      params: ClientRequest__TurnSteerParams,
    }).annotate({ title: "Turn/steerRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("turn/interrupt").annotate({ title: "Turn/interruptRequestMethod" }),
      params: ClientRequest__TurnInterruptParams,
    }).annotate({ title: "Turn/interruptRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("review/start").annotate({ title: "Review/startRequestMethod" }),
      params: ClientRequest__ReviewStartParams,
    }).annotate({ title: "Review/startRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("model/list").annotate({ title: "Model/listRequestMethod" }),
      params: ClientRequest__ModelListParams,
    }).annotate({ title: "Model/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("modelProvider/capabilities/read").annotate({
        title: "ModelProvider/capabilities/readRequestMethod",
      }),
      params: ClientRequest__ModelProviderCapabilitiesReadParams,
    }).annotate({ title: "ModelProvider/capabilities/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("experimentalFeature/list").annotate({
        title: "ExperimentalFeature/listRequestMethod",
      }),
      params: ClientRequest__ExperimentalFeatureListParams,
    }).annotate({ title: "ExperimentalFeature/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("experimentalFeature/enablement/set").annotate({
        title: "ExperimentalFeature/enablement/setRequestMethod",
      }),
      params: ClientRequest__ExperimentalFeatureEnablementSetParams,
    }).annotate({ title: "ExperimentalFeature/enablement/setRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("mcpServer/oauth/login").annotate({
        title: "McpServer/oauth/loginRequestMethod",
      }),
      params: ClientRequest__McpServerOauthLoginParams,
    }).annotate({ title: "McpServer/oauth/loginRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("config/mcpServer/reload").annotate({
        title: "Config/mcpServer/reloadRequestMethod",
      }),
      params: Schema.optionalKey(Schema.Null),
    }).annotate({ title: "Config/mcpServer/reloadRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("mcpServerStatus/list").annotate({
        title: "McpServerStatus/listRequestMethod",
      }),
      params: ClientRequest__ListMcpServerStatusParams,
    }).annotate({ title: "McpServerStatus/listRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("mcpServer/resource/read").annotate({
        title: "McpServer/resource/readRequestMethod",
      }),
      params: ClientRequest__McpResourceReadParams,
    }).annotate({ title: "McpServer/resource/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("mcpServer/tool/call").annotate({
        title: "McpServer/tool/callRequestMethod",
      }),
      params: ClientRequest__McpServerToolCallParams,
    }).annotate({ title: "McpServer/tool/callRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("windowsSandbox/setupStart").annotate({
        title: "WindowsSandbox/setupStartRequestMethod",
      }),
      params: ClientRequest__WindowsSandboxSetupStartParams,
    }).annotate({ title: "WindowsSandbox/setupStartRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("windowsSandbox/readiness").annotate({
        title: "WindowsSandbox/readinessRequestMethod",
      }),
      params: Schema.optionalKey(Schema.Null),
    }).annotate({ title: "WindowsSandbox/readinessRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("account/login/start").annotate({
        title: "Account/login/startRequestMethod",
      }),
      params: ClientRequest__LoginAccountParams,
    }).annotate({ title: "Account/login/startRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("account/login/cancel").annotate({
        title: "Account/login/cancelRequestMethod",
      }),
      params: ClientRequest__CancelLoginAccountParams,
    }).annotate({ title: "Account/login/cancelRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("account/logout").annotate({ title: "Account/logoutRequestMethod" }),
      params: Schema.optionalKey(Schema.Null),
    }).annotate({ title: "Account/logoutRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("account/rateLimits/read").annotate({
        title: "Account/rateLimits/readRequestMethod",
      }),
      params: Schema.optionalKey(Schema.Null),
    }).annotate({ title: "Account/rateLimits/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("account/sendAddCreditsNudgeEmail").annotate({
        title: "Account/sendAddCreditsNudgeEmailRequestMethod",
      }),
      params: ClientRequest__SendAddCreditsNudgeEmailParams,
    }).annotate({ title: "Account/sendAddCreditsNudgeEmailRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("feedback/upload").annotate({ title: "Feedback/uploadRequestMethod" }),
      params: ClientRequest__FeedbackUploadParams,
    }).annotate({ title: "Feedback/uploadRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("command/exec").annotate({ title: "Command/execRequestMethod" }),
      params: ClientRequest__CommandExecParams,
    }).annotate({
      title: "Command/execRequest",
      description: "Execute a standalone command (argv vector) under the server's sandbox.",
    }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("command/exec/write").annotate({
        title: "Command/exec/writeRequestMethod",
      }),
      params: ClientRequest__CommandExecWriteParams,
    }).annotate({
      title: "Command/exec/writeRequest",
      description: "Write stdin bytes to a running `command/exec` session or close stdin.",
    }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("command/exec/terminate").annotate({
        title: "Command/exec/terminateRequestMethod",
      }),
      params: ClientRequest__CommandExecTerminateParams,
    }).annotate({
      title: "Command/exec/terminateRequest",
      description: "Terminate a running `command/exec` session by client-supplied `processId`.",
    }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("command/exec/resize").annotate({
        title: "Command/exec/resizeRequestMethod",
      }),
      params: ClientRequest__CommandExecResizeParams,
    }).annotate({
      title: "Command/exec/resizeRequest",
      description:
        "Resize a running PTY-backed `command/exec` session by client-supplied `processId`.",
    }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("config/read").annotate({ title: "Config/readRequestMethod" }),
      params: ClientRequest__ConfigReadParams,
    }).annotate({ title: "Config/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("externalAgentConfig/detect").annotate({
        title: "ExternalAgentConfig/detectRequestMethod",
      }),
      params: ClientRequest__ExternalAgentConfigDetectParams,
    }).annotate({ title: "ExternalAgentConfig/detectRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("externalAgentConfig/import").annotate({
        title: "ExternalAgentConfig/importRequestMethod",
      }),
      params: ClientRequest__ExternalAgentConfigImportParams,
    }).annotate({ title: "ExternalAgentConfig/importRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("config/value/write").annotate({
        title: "Config/value/writeRequestMethod",
      }),
      params: ClientRequest__ConfigValueWriteParams,
    }).annotate({ title: "Config/value/writeRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("config/batchWrite").annotate({
        title: "Config/batchWriteRequestMethod",
      }),
      params: ClientRequest__ConfigBatchWriteParams,
    }).annotate({ title: "Config/batchWriteRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("configRequirements/read").annotate({
        title: "ConfigRequirements/readRequestMethod",
      }),
      params: Schema.optionalKey(Schema.Null),
    }).annotate({ title: "ConfigRequirements/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("account/read").annotate({ title: "Account/readRequestMethod" }),
      params: ClientRequest__GetAccountParams,
    }).annotate({ title: "Account/readRequest" }),
    Schema.Struct({
      id: ClientRequest__RequestId,
      method: Schema.Literal("fuzzyFileSearch").annotate({ title: "FuzzyFileSearchRequestMethod" }),
      params: ClientRequest__FuzzyFileSearchParams,
    }).annotate({ title: "FuzzyFileSearchRequest" }),
  ],
  { mode: "oneOf" },
).annotate({ title: "ClientRequest", description: "Request from the client to the server." });

export type ClientRequest__ByteRange = { readonly end: number; readonly start: number };
export const ClientRequest__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type ClientRequest__CollaborationMode = {
  readonly mode: ClientRequest__ModeKind;
  readonly settings: ClientRequest__Settings;
};
export const ClientRequest__CollaborationMode = Schema.Struct({
  mode: ClientRequest__ModeKind,
  settings: ClientRequest__Settings,
}).annotate({ description: "Collaboration mode for a Codex session." });

export type ClientRequest__DynamicToolSpec = {
  readonly deferLoading?: boolean;
  readonly description: string;
  readonly inputSchema: unknown;
  readonly name: string;
  readonly namespace?: string | null;
};
export const ClientRequest__DynamicToolSpec = Schema.Struct({
  deferLoading: Schema.optionalKey(Schema.Boolean),
  description: Schema.String,
  inputSchema: Schema.Unknown,
  name: Schema.String,
  namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type ClientRequest__NetworkAccess = "restricted" | "enabled";
export const ClientRequest__NetworkAccess = Schema.Literals(["restricted", "enabled"]);

export type ClientRequest__PermissionProfile =
  | {
      readonly fileSystem: ClientRequest__PermissionProfileFileSystemPermissions;
      readonly network: ClientRequest__PermissionProfileNetworkPermissions;
      readonly type: "managed";
    }
  | { readonly type: "disabled" }
  | {
      readonly network: ClientRequest__PermissionProfileNetworkPermissions;
      readonly type: "external";
    };
export const ClientRequest__PermissionProfile = Schema.Union(
  [
    Schema.Struct({
      fileSystem: ClientRequest__PermissionProfileFileSystemPermissions,
      network: ClientRequest__PermissionProfileNetworkPermissions,
      type: Schema.Literal("managed").annotate({ title: "ManagedPermissionProfileType" }),
    }).annotate({
      title: "ManagedPermissionProfile",
      description: "Codex owns sandbox construction for this profile.",
    }),
    Schema.Struct({
      type: Schema.Literal("disabled").annotate({ title: "DisabledPermissionProfileType" }),
    }).annotate({
      title: "DisabledPermissionProfile",
      description: "Do not apply an outer sandbox.",
    }),
    Schema.Struct({
      network: ClientRequest__PermissionProfileNetworkPermissions,
      type: Schema.Literal("external").annotate({ title: "ExternalPermissionProfileType" }),
    }).annotate({
      title: "ExternalPermissionProfile",
      description: "Filesystem isolation is enforced by an external caller.",
    }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__PermissionProfileSelectionParams = {
  readonly id: string;
  readonly modifications?: ReadonlyArray<ClientRequest__PermissionProfileModificationParams> | null;
  readonly type: "profile";
};
export const ClientRequest__PermissionProfileSelectionParams = Schema.Union(
  [
    Schema.Struct({
      id: Schema.String,
      modifications: Schema.optionalKey(
        Schema.Union([
          Schema.Array(ClientRequest__PermissionProfileModificationParams),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("profile").annotate({
        title: "ProfilePermissionProfileSelectionParamsType",
      }),
    }).annotate({
      title: "ProfilePermissionProfileSelectionParams",
      description:
        "Select a named built-in or user-defined profile and optionally apply bounded modifications that Codex knows how to validate.",
    }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__ProcessTerminalSize = { readonly cols: number; readonly rows: number };
export const ClientRequest__ProcessTerminalSize = Schema.Struct({
  cols: Schema.Number.annotate({
    description: "Terminal width in character cells.",
    format: "uint16",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  rows: Schema.Number.annotate({
    description: "Terminal height in character cells.",
    format: "uint16",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
}).annotate({ description: "PTY size in character cells for `process/spawn` PTY sessions." });

export type ClientRequest__RealtimeOutputModality = "text" | "audio";
export const ClientRequest__RealtimeOutputModality = Schema.Literals(["text", "audio"]);

export type ClientRequest__RealtimeVoice =
  | "alloy"
  | "arbor"
  | "ash"
  | "ballad"
  | "breeze"
  | "cedar"
  | "coral"
  | "cove"
  | "echo"
  | "ember"
  | "juniper"
  | "maple"
  | "marin"
  | "sage"
  | "shimmer"
  | "sol"
  | "spruce"
  | "vale"
  | "verse";
export const ClientRequest__RealtimeVoice = Schema.Literals([
  "alloy",
  "arbor",
  "ash",
  "ballad",
  "breeze",
  "cedar",
  "coral",
  "cove",
  "echo",
  "ember",
  "juniper",
  "maple",
  "marin",
  "sage",
  "shimmer",
  "sol",
  "spruce",
  "vale",
  "verse",
]);

export type ClientRequest__ResponseItem =
  | {
      readonly content: ReadonlyArray<ClientRequest__ContentItem>;
      readonly id?: string | null;
      readonly phase?: ClientRequest__MessagePhase | null;
      readonly role: string;
      readonly type: "message";
    }
  | {
      readonly content?: ReadonlyArray<ClientRequest__ReasoningItemContent> | null;
      readonly encrypted_content?: string | null;
      readonly summary: ReadonlyArray<ClientRequest__ReasoningItemReasoningSummary>;
      readonly type: "reasoning";
    }
  | {
      readonly action: ClientRequest__LocalShellAction;
      readonly call_id?: string | null;
      readonly id?: string | null;
      readonly status: ClientRequest__LocalShellStatus;
      readonly type: "local_shell_call";
    }
  | {
      readonly arguments: string;
      readonly call_id: string;
      readonly id?: string | null;
      readonly name: string;
      readonly namespace?: string | null;
      readonly type: "function_call";
    }
  | {
      readonly arguments: unknown;
      readonly call_id?: string | null;
      readonly execution: string;
      readonly id?: string | null;
      readonly status?: string | null;
      readonly type: "tool_search_call";
    }
  | {
      readonly call_id: string;
      readonly output: ClientRequest__FunctionCallOutputBody;
      readonly type: "function_call_output";
    }
  | {
      readonly call_id: string;
      readonly id?: string | null;
      readonly input: string;
      readonly name: string;
      readonly status?: string | null;
      readonly type: "custom_tool_call";
    }
  | {
      readonly call_id: string;
      readonly name?: string | null;
      readonly output: ClientRequest__FunctionCallOutputBody;
      readonly type: "custom_tool_call_output";
    }
  | {
      readonly call_id?: string | null;
      readonly execution: string;
      readonly status: string;
      readonly tools: ReadonlyArray<unknown>;
      readonly type: "tool_search_output";
    }
  | {
      readonly action?: ClientRequest__ResponsesApiWebSearchAction | null;
      readonly id?: string | null;
      readonly status?: string | null;
      readonly type: "web_search_call";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revised_prompt?: string | null;
      readonly status: string;
      readonly type: "image_generation_call";
    }
  | { readonly encrypted_content: string; readonly type: "compaction" }
  | { readonly encrypted_content?: string | null; readonly type: "context_compaction" }
  | { readonly type: "other" };
export const ClientRequest__ResponseItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(ClientRequest__ContentItem),
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([ClientRequest__MessagePhase, Schema.Null])),
      role: Schema.String,
      type: Schema.Literal("message").annotate({ title: "MessageResponseItemType" }),
    }).annotate({ title: "MessageResponseItem" }),
    Schema.Struct({
      content: Schema.optionalKey(
        Schema.Union([Schema.Array(ClientRequest__ReasoningItemContent), Schema.Null]),
      ),
      encrypted_content: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      summary: Schema.Array(ClientRequest__ReasoningItemReasoningSummary),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningResponseItemType" }),
    }).annotate({ title: "ReasoningResponseItem" }),
    Schema.Struct({
      action: ClientRequest__LocalShellAction,
      call_id: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({ description: "Set when using the Responses API." }),
          Schema.Null,
        ]),
      ),
      id: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Legacy id field retained for compatibility with older payloads.",
            writeOnly: true,
          }),
          Schema.Null,
        ]),
      ),
      status: ClientRequest__LocalShellStatus,
      type: Schema.Literal("local_shell_call").annotate({
        title: "LocalShellCallResponseItemType",
      }),
    }).annotate({ title: "LocalShellCallResponseItem" }),
    Schema.Struct({
      arguments: Schema.String,
      call_id: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      name: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("function_call").annotate({ title: "FunctionCallResponseItemType" }),
    }).annotate({ title: "FunctionCallResponseItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      call_id: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      execution: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("tool_search_call").annotate({
        title: "ToolSearchCallResponseItemType",
      }),
    }).annotate({ title: "ToolSearchCallResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      output: ClientRequest__FunctionCallOutputBody,
      type: Schema.Literal("function_call_output").annotate({
        title: "FunctionCallOutputResponseItemType",
      }),
    }).annotate({ title: "FunctionCallOutputResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      input: Schema.String,
      name: Schema.String,
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("custom_tool_call").annotate({
        title: "CustomToolCallResponseItemType",
      }),
    }).annotate({ title: "CustomToolCallResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      name: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      output: ClientRequest__FunctionCallOutputBody,
      type: Schema.Literal("custom_tool_call_output").annotate({
        title: "CustomToolCallOutputResponseItemType",
      }),
    }).annotate({ title: "CustomToolCallOutputResponseItem" }),
    Schema.Struct({
      call_id: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      execution: Schema.String,
      status: Schema.String,
      tools: Schema.Array(Schema.Unknown),
      type: Schema.Literal("tool_search_output").annotate({
        title: "ToolSearchOutputResponseItemType",
      }),
    }).annotate({ title: "ToolSearchOutputResponseItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([ClientRequest__ResponsesApiWebSearchAction, Schema.Null]),
      ),
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("web_search_call").annotate({ title: "WebSearchCallResponseItemType" }),
    }).annotate({ title: "WebSearchCallResponseItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revised_prompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: Schema.String,
      type: Schema.Literal("image_generation_call").annotate({
        title: "ImageGenerationCallResponseItemType",
      }),
    }).annotate({ title: "ImageGenerationCallResponseItem" }),
    Schema.Struct({
      encrypted_content: Schema.String,
      type: Schema.Literal("compaction").annotate({ title: "CompactionResponseItemType" }),
    }).annotate({ title: "CompactionResponseItem" }),
    Schema.Struct({
      encrypted_content: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("context_compaction").annotate({
        title: "ContextCompactionResponseItemType",
      }),
    }).annotate({ title: "ContextCompactionResponseItem" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherResponseItemType" }),
    }).annotate({ title: "OtherResponseItem" }),
  ],
  { mode: "oneOf" },
);

export type ClientRequest__ThreadGoalStatus = "active" | "paused" | "budgetLimited" | "complete";
export const ClientRequest__ThreadGoalStatus = Schema.Literals([
  "active",
  "paused",
  "budgetLimited",
  "complete",
]);

export type ClientRequest__ThreadMemoryMode = "enabled" | "disabled";
export const ClientRequest__ThreadMemoryMode = Schema.Literals(["enabled", "disabled"]);

export type ClientRequest__ThreadRealtimeAudioChunk = {
  readonly data: string;
  readonly itemId?: string | null;
  readonly numChannels: number;
  readonly sampleRate: number;
  readonly samplesPerChannel?: number | null;
};
export const ClientRequest__ThreadRealtimeAudioChunk = Schema.Struct({
  data: Schema.String,
  itemId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  numChannels: Schema.Number.annotate({ format: "uint16" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  sampleRate: Schema.Number.annotate({ format: "uint32" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  samplesPerChannel: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint32" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
}).annotate({ description: "EXPERIMENTAL - thread realtime audio chunk." });

export type ClientRequest__ThreadRealtimeStartTransport =
  | { readonly type: "websocket" }
  | { readonly sdp: string; readonly type: "webrtc" };
export const ClientRequest__ThreadRealtimeStartTransport = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("websocket").annotate({
        title: "WebsocketThreadRealtimeStartTransportType",
      }),
    }).annotate({ title: "WebsocketThreadRealtimeStartTransport" }),
    Schema.Struct({
      sdp: Schema.String.annotate({
        description:
          "SDP offer generated by a WebRTC RTCPeerConnection after configuring audio and the realtime events data channel.",
      }),
      type: Schema.Literal("webrtc").annotate({ title: "WebrtcThreadRealtimeStartTransportType" }),
    }).annotate({ title: "WebrtcThreadRealtimeStartTransport" }),
  ],
  { mode: "oneOf" },
).annotate({ description: "EXPERIMENTAL - transport used by thread realtime." });

export type ClientRequest__TurnEnvironmentParams = {
  readonly cwd: ClientRequest__AbsolutePathBuf;
  readonly environmentId: string;
};
export const ClientRequest__TurnEnvironmentParams = Schema.Struct({
  cwd: ClientRequest__AbsolutePathBuf,
  environmentId: Schema.String,
});

export type ClientRequest__TurnItemsView = "notLoaded" | "summary" | "full";
export const ClientRequest__TurnItemsView = Schema.Literals(["notLoaded", "summary", "full"]);

export type CommandExecutionRequestApprovalParams = {
  readonly approvalId?: string | null;
  readonly command?: string | null;
  readonly commandActions?: ReadonlyArray<CommandExecutionRequestApprovalParams__CommandAction> | null;
  readonly cwd?: CommandExecutionRequestApprovalParams__AbsolutePathBuf | null;
  readonly itemId: string;
  readonly networkApprovalContext?: CommandExecutionRequestApprovalParams__NetworkApprovalContext | null;
  readonly proposedExecpolicyAmendment?: ReadonlyArray<string> | null;
  readonly proposedNetworkPolicyAmendments?: ReadonlyArray<CommandExecutionRequestApprovalParams__NetworkPolicyAmendment> | null;
  readonly reason?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const CommandExecutionRequestApprovalParams = Schema.Struct({
  approvalId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Unique identifier for this specific approval callback.\n\nFor regular shell/unified_exec approvals, this is null.\n\nFor zsh-exec-bridge subcommand approvals, multiple callbacks can belong to one parent `itemId`, so `approvalId` is a distinct opaque callback id (a UUID) used to disambiguate routing.",
      }),
      Schema.Null,
    ]),
  ),
  command: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "The command to be executed." }),
      Schema.Null,
    ]),
  ),
  commandActions: Schema.optionalKey(
    Schema.Union([
      Schema.Array(CommandExecutionRequestApprovalParams__CommandAction).annotate({
        description: "Best-effort parsed command actions for friendly display.",
      }),
      Schema.Null,
    ]),
  ),
  cwd: Schema.optionalKey(
    Schema.Union([CommandExecutionRequestApprovalParams__AbsolutePathBuf, Schema.Null]).annotate({
      description: "The command's working directory.",
    }),
  ),
  itemId: Schema.String,
  networkApprovalContext: Schema.optionalKey(
    Schema.Union([
      CommandExecutionRequestApprovalParams__NetworkApprovalContext,
      Schema.Null,
    ]).annotate({ description: "Optional context for a managed-network approval prompt." }),
  ),
  proposedExecpolicyAmendment: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Optional proposed execpolicy amendment to allow similar commands without prompting.",
      }),
      Schema.Null,
    ]),
  ),
  proposedNetworkPolicyAmendments: Schema.optionalKey(
    Schema.Union([
      Schema.Array(CommandExecutionRequestApprovalParams__NetworkPolicyAmendment).annotate({
        description:
          "Optional proposed network policy amendments (allow/deny host) for future requests.",
      }),
      Schema.Null,
    ]),
  ),
  reason: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional explanatory reason (e.g. request for network access).",
      }),
      Schema.Null,
    ]),
  ),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "CommandExecutionRequestApprovalParams" });

export type CommandExecutionRequestApprovalParams__AdditionalPermissionProfile = {
  readonly fileSystem?: CommandExecutionRequestApprovalParams__AdditionalFileSystemPermissions | null;
  readonly network?: CommandExecutionRequestApprovalParams__AdditionalNetworkPermissions | null;
};
export const CommandExecutionRequestApprovalParams__AdditionalPermissionProfile = Schema.Struct({
  fileSystem: Schema.optionalKey(
    Schema.Union([
      CommandExecutionRequestApprovalParams__AdditionalFileSystemPermissions,
      Schema.Null,
    ]),
  ),
  network: Schema.optionalKey(
    Schema.Union([
      CommandExecutionRequestApprovalParams__AdditionalNetworkPermissions,
      Schema.Null,
    ]).annotate({ description: "Partial overlay used for per-command permission requests." }),
  ),
});

export type CommandExecutionRequestApprovalParams__CommandExecutionApprovalDecision =
  | "accept"
  | "acceptForSession"
  | {
      readonly acceptWithExecpolicyAmendment: {
        readonly execpolicy_amendment: ReadonlyArray<string>;
      };
    }
  | {
      readonly applyNetworkPolicyAmendment: {
        readonly network_policy_amendment: CommandExecutionRequestApprovalParams__NetworkPolicyAmendment;
      };
    }
  | "decline"
  | "cancel";
export const CommandExecutionRequestApprovalParams__CommandExecutionApprovalDecision = Schema.Union(
  [
    Schema.Literal("accept").annotate({ description: "User approved the command." }),
    Schema.Literal("acceptForSession").annotate({
      description:
        "User approved the command and future prompts in the same session-scoped approval cache should run without prompting.",
    }),
    Schema.Struct({
      acceptWithExecpolicyAmendment: Schema.Struct({
        execpolicy_amendment: Schema.Array(Schema.String),
      }),
    }).annotate({
      title: "AcceptWithExecpolicyAmendmentCommandExecutionApprovalDecision",
      description:
        "User approved the command, and wants to apply the proposed execpolicy amendment so future matching commands can run without prompting.",
    }),
    Schema.Struct({
      applyNetworkPolicyAmendment: Schema.Struct({
        network_policy_amendment: CommandExecutionRequestApprovalParams__NetworkPolicyAmendment,
      }),
    }).annotate({
      title: "ApplyNetworkPolicyAmendmentCommandExecutionApprovalDecision",
      description: "User chose a persistent network policy rule (allow/deny) for this host.",
    }),
    Schema.Literal("decline").annotate({
      description: "User denied the command. The agent will continue the turn.",
    }),
    Schema.Literal("cancel").annotate({
      description: "User denied the command. The turn will also be immediately interrupted.",
    }),
  ],
  { mode: "oneOf" },
);

export type CommandExecutionRequestApprovalResponse = {
  readonly decision: CommandExecutionRequestApprovalResponse__CommandExecutionApprovalDecision;
};
export const CommandExecutionRequestApprovalResponse = Schema.Struct({
  decision: CommandExecutionRequestApprovalResponse__CommandExecutionApprovalDecision,
}).annotate({ title: "CommandExecutionRequestApprovalResponse" });

export type DynamicToolCallParams = {
  readonly arguments: unknown;
  readonly callId: string;
  readonly namespace?: string | null;
  readonly threadId: string;
  readonly tool: string;
  readonly turnId: string;
};
export const DynamicToolCallParams = Schema.Struct({
  arguments: Schema.Unknown,
  callId: Schema.String,
  namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
  tool: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "DynamicToolCallParams" });

export type DynamicToolCallResponse = {
  readonly contentItems: ReadonlyArray<DynamicToolCallResponse__DynamicToolCallOutputContentItem>;
  readonly success: boolean;
};
export const DynamicToolCallResponse = Schema.Struct({
  contentItems: Schema.Array(DynamicToolCallResponse__DynamicToolCallOutputContentItem),
  success: Schema.Boolean,
}).annotate({ title: "DynamicToolCallResponse" });

export type ExecCommandApprovalParams = {
  readonly approvalId?: string | null;
  readonly callId: string;
  readonly command: ReadonlyArray<string>;
  readonly conversationId: ExecCommandApprovalParams__ThreadId;
  readonly cwd: string;
  readonly parsedCmd: ReadonlyArray<ExecCommandApprovalParams__ParsedCommand>;
  readonly reason?: string | null;
};
export const ExecCommandApprovalParams = Schema.Struct({
  approvalId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Identifier for this specific approval callback." }),
      Schema.Null,
    ]),
  ),
  callId: Schema.String.annotate({
    description:
      "Use to correlate this with [codex_protocol::protocol::ExecCommandBeginEvent] and [codex_protocol::protocol::ExecCommandEndEvent].",
  }),
  command: Schema.Array(Schema.String),
  conversationId: ExecCommandApprovalParams__ThreadId,
  cwd: Schema.String,
  parsedCmd: Schema.Array(ExecCommandApprovalParams__ParsedCommand),
  reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "ExecCommandApprovalParams" });

export type ExecCommandApprovalResponse = {
  readonly decision: ExecCommandApprovalResponse__ReviewDecision;
};
export const ExecCommandApprovalResponse = Schema.Struct({
  decision: ExecCommandApprovalResponse__ReviewDecision,
}).annotate({ title: "ExecCommandApprovalResponse" });

export type FileChangeRequestApprovalParams = {
  readonly grantRoot?: string | null;
  readonly itemId: string;
  readonly reason?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const FileChangeRequestApprovalParams = Schema.Struct({
  grantRoot: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "[UNSTABLE] When set, the agent is asking the user to allow writes under this root for the remainder of the session (unclear if this is honored today).",
      }),
      Schema.Null,
    ]),
  ),
  itemId: Schema.String,
  reason: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional explanatory reason (e.g. request for extra write access).",
      }),
      Schema.Null,
    ]),
  ),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "FileChangeRequestApprovalParams" });

export type FileChangeRequestApprovalResponse = {
  readonly decision: FileChangeRequestApprovalResponse__FileChangeApprovalDecision;
};
export const FileChangeRequestApprovalResponse = Schema.Struct({
  decision: FileChangeRequestApprovalResponse__FileChangeApprovalDecision,
}).annotate({ title: "FileChangeRequestApprovalResponse" });

export type FuzzyFileSearchParams = {
  readonly cancellationToken?: string | null;
  readonly query: string;
  readonly roots: ReadonlyArray<string>;
};
export const FuzzyFileSearchParams = Schema.Struct({
  cancellationToken: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  query: Schema.String,
  roots: Schema.Array(Schema.String),
}).annotate({ title: "FuzzyFileSearchParams" });

export type FuzzyFileSearchResponse = {
  readonly files: ReadonlyArray<FuzzyFileSearchResponse__FuzzyFileSearchResult>;
};
export const FuzzyFileSearchResponse = Schema.Struct({
  files: Schema.Array(FuzzyFileSearchResponse__FuzzyFileSearchResult),
}).annotate({ title: "FuzzyFileSearchResponse" });

export type FuzzyFileSearchSessionCompletedNotification = { readonly sessionId: string };
export const FuzzyFileSearchSessionCompletedNotification = Schema.Struct({
  sessionId: Schema.String,
}).annotate({ title: "FuzzyFileSearchSessionCompletedNotification" });

export type FuzzyFileSearchSessionUpdatedNotification = {
  readonly files: ReadonlyArray<FuzzyFileSearchSessionUpdatedNotification__FuzzyFileSearchResult>;
  readonly query: string;
  readonly sessionId: string;
};
export const FuzzyFileSearchSessionUpdatedNotification = Schema.Struct({
  files: Schema.Array(FuzzyFileSearchSessionUpdatedNotification__FuzzyFileSearchResult),
  query: Schema.String,
  sessionId: Schema.String,
}).annotate({ title: "FuzzyFileSearchSessionUpdatedNotification" });

export type GetAuthStatusParams = {
  readonly includeToken?: boolean | null;
  readonly refreshToken?: boolean | null;
};
export const GetAuthStatusParams = Schema.Struct({
  includeToken: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  refreshToken: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
}).annotate({ title: "GetAuthStatusParams" });

export type GetAuthStatusResponse = {
  readonly authMethod: unknown | null;
  readonly authToken: string | null;
  readonly requiresOpenaiAuth: boolean | null;
};
export const GetAuthStatusResponse = Schema.Struct({
  authMethod: Schema.Union([Schema.Unknown, Schema.Null]),
  authToken: Schema.Union([Schema.String, Schema.Null]),
  requiresOpenaiAuth: Schema.Union([Schema.Boolean, Schema.Null]),
}).annotate({ title: "GetAuthStatusResponse" });

export type GetConversationSummaryParams =
  | { readonly rolloutPath: string }
  | { readonly conversationId: string };
export const GetConversationSummaryParams = Schema.Union(
  [Schema.Struct({ rolloutPath: Schema.String }), Schema.Struct({ conversationId: Schema.String })],
  { mode: "oneOf" },
).annotate({ title: "GetConversationSummaryParams" });

export type GetConversationSummaryResponse = { readonly summary: unknown };
export const GetConversationSummaryResponse = Schema.Struct({ summary: Schema.Unknown }).annotate({
  title: "GetConversationSummaryResponse",
});

export type GitDiffToRemoteParams = { readonly cwd: string };
export const GitDiffToRemoteParams = Schema.Struct({ cwd: Schema.String }).annotate({
  title: "GitDiffToRemoteParams",
});

export type GitDiffToRemoteResponse = { readonly sha: string; readonly diff: string };
export const GitDiffToRemoteResponse = Schema.Struct({
  sha: Schema.String,
  diff: Schema.String,
}).annotate({ title: "GitDiffToRemoteResponse" });

export type JSONRPCError = {
  readonly error: JSONRPCError__JSONRPCErrorError;
  readonly id: JSONRPCError__RequestId;
};
export const JSONRPCError = Schema.Struct({
  error: JSONRPCError__JSONRPCErrorError,
  id: JSONRPCError__RequestId,
}).annotate({
  title: "JSONRPCError",
  description: "A response to a request that indicates an error occurred.",
});

export type JSONRPCErrorError = {
  readonly code: number;
  readonly data?: unknown;
  readonly message: string;
};
export const JSONRPCErrorError = Schema.Struct({
  code: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  data: Schema.optionalKey(Schema.Unknown),
  message: Schema.String,
}).annotate({ title: "JSONRPCErrorError" });

export type JSONRPCMessage =
  | JSONRPCMessage__JSONRPCRequest
  | JSONRPCMessage__JSONRPCNotification
  | JSONRPCMessage__JSONRPCResponse
  | JSONRPCMessage__JSONRPCError;
export const JSONRPCMessage = Schema.Union([
  JSONRPCMessage__JSONRPCRequest,
  JSONRPCMessage__JSONRPCNotification,
  JSONRPCMessage__JSONRPCResponse,
  JSONRPCMessage__JSONRPCError,
]).annotate({
  title: "JSONRPCMessage",
  description:
    "Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.",
});

export type JSONRPCNotification = { readonly method: string; readonly params?: unknown };
export const JSONRPCNotification = Schema.Struct({
  method: Schema.String,
  params: Schema.optionalKey(Schema.Unknown),
}).annotate({
  title: "JSONRPCNotification",
  description: "A notification which does not expect a response.",
});

export type JSONRPCRequest = {
  readonly id: JSONRPCRequest__RequestId;
  readonly method: string;
  readonly params?: unknown;
  readonly trace?: JSONRPCRequest__W3cTraceContext | null;
};
export const JSONRPCRequest = Schema.Struct({
  id: JSONRPCRequest__RequestId,
  method: Schema.String,
  params: Schema.optionalKey(Schema.Unknown),
  trace: Schema.optionalKey(
    Schema.Union([JSONRPCRequest__W3cTraceContext, Schema.Null]).annotate({
      description: "Optional W3C Trace Context for distributed tracing.",
    }),
  ),
}).annotate({ title: "JSONRPCRequest", description: "A request that expects a response." });

export type JSONRPCResponse = { readonly id: JSONRPCResponse__RequestId; readonly result: unknown };
export const JSONRPCResponse = Schema.Struct({
  id: JSONRPCResponse__RequestId,
  result: Schema.Unknown,
}).annotate({
  title: "JSONRPCResponse",
  description: "A successful (non-error) response to a request.",
});

export type McpServerElicitationRequestParams =
  | {
      readonly _meta?: unknown;
      readonly message: string;
      readonly mode: "form";
      readonly requestedSchema: McpServerElicitationRequestParams__McpElicitationSchema;
      readonly serverName: string;
      readonly threadId: string;
      readonly turnId?: string | null;
    }
  | {
      readonly _meta?: unknown;
      readonly elicitationId: string;
      readonly message: string;
      readonly mode: "url";
      readonly url: string;
      readonly serverName: string;
      readonly threadId: string;
      readonly turnId?: string | null;
    };
export const McpServerElicitationRequestParams = Schema.Union(
  [
    Schema.Struct({
      _meta: Schema.optionalKey(Schema.Unknown),
      message: Schema.String,
      mode: Schema.Literal("form"),
      requestedSchema: McpServerElicitationRequestParams__McpElicitationSchema,
      serverName: Schema.String,
      threadId: Schema.String,
      turnId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description:
              "Active Codex turn when this elicitation was observed, if app-server could correlate one.\n\nThis is nullable because MCP models elicitation as a standalone server-to-client request identified by the MCP server request id. It may be triggered during a turn, but turn context is app-server correlation rather than part of the protocol identity of the elicitation itself.",
          }),
          Schema.Null,
        ]),
      ),
    }).annotate({ title: "McpServerElicitationRequestParams" }),
    Schema.Struct({
      _meta: Schema.optionalKey(Schema.Unknown),
      elicitationId: Schema.String,
      message: Schema.String,
      mode: Schema.Literal("url"),
      url: Schema.String,
      serverName: Schema.String,
      threadId: Schema.String,
      turnId: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description:
              "Active Codex turn when this elicitation was observed, if app-server could correlate one.\n\nThis is nullable because MCP models elicitation as a standalone server-to-client request identified by the MCP server request id. It may be triggered during a turn, but turn context is app-server correlation rather than part of the protocol identity of the elicitation itself.",
          }),
          Schema.Null,
        ]),
      ),
    }).annotate({ title: "McpServerElicitationRequestParams" }),
  ],
  { mode: "oneOf" },
);

export type McpServerElicitationRequestResponse = {
  readonly _meta?: unknown;
  readonly action: McpServerElicitationRequestResponse__McpServerElicitationAction;
  readonly content?: unknown;
};
export const McpServerElicitationRequestResponse = Schema.Struct({
  _meta: Schema.optionalKey(
    Schema.Unknown.annotate({
      description: "Optional client metadata for form-mode action handling.",
    }),
  ),
  action: McpServerElicitationRequestResponse__McpServerElicitationAction,
  content: Schema.optionalKey(
    Schema.Unknown.annotate({
      description:
        "Structured user input for accepted elicitations, mirroring RMCP `CreateElicitationResult`.\n\nThis is nullable because decline/cancel responses have no content.",
    }),
  ),
}).annotate({ title: "McpServerElicitationRequestResponse" });

export type PermissionsRequestApprovalParams = {
  readonly cwd: PermissionsRequestApprovalParams__AbsolutePathBuf;
  readonly itemId: string;
  readonly permissions: PermissionsRequestApprovalParams__RequestPermissionProfile;
  readonly reason?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const PermissionsRequestApprovalParams = Schema.Struct({
  cwd: PermissionsRequestApprovalParams__AbsolutePathBuf,
  itemId: Schema.String,
  permissions: PermissionsRequestApprovalParams__RequestPermissionProfile,
  reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "PermissionsRequestApprovalParams" });

export type PermissionsRequestApprovalResponse = {
  readonly permissions: PermissionsRequestApprovalResponse__GrantedPermissionProfile;
  readonly scope?: "turn" | "session";
  readonly strictAutoReview?: boolean | null;
};
export const PermissionsRequestApprovalResponse = Schema.Struct({
  permissions: PermissionsRequestApprovalResponse__GrantedPermissionProfile,
  scope: Schema.optionalKey(Schema.Literals(["turn", "session"]).annotate({ default: "turn" })),
  strictAutoReview: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description:
          "Review every subsequent command in this turn before normal sandboxed execution.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "PermissionsRequestApprovalResponse" });

export type PermissionsRequestApprovalResponse__PermissionGrantScope = "turn" | "session";
export const PermissionsRequestApprovalResponse__PermissionGrantScope = Schema.Literals([
  "turn",
  "session",
]);

export type RequestId = string | number;
export const RequestId = Schema.Union([
  Schema.String,
  Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
]).annotate({ title: "RequestId" });

export type ServerNotification =
  | { readonly method: "error"; readonly params: ServerNotification__ErrorNotification }
  | {
      readonly method: "thread/started";
      readonly params: ServerNotification__ThreadStartedNotification;
    }
  | {
      readonly method: "thread/status/changed";
      readonly params: ServerNotification__ThreadStatusChangedNotification;
    }
  | {
      readonly method: "thread/archived";
      readonly params: ServerNotification__ThreadArchivedNotification;
    }
  | {
      readonly method: "thread/unarchived";
      readonly params: ServerNotification__ThreadUnarchivedNotification;
    }
  | {
      readonly method: "thread/closed";
      readonly params: ServerNotification__ThreadClosedNotification;
    }
  | {
      readonly method: "skills/changed";
      readonly params: ServerNotification__SkillsChangedNotification;
    }
  | {
      readonly method: "thread/name/updated";
      readonly params: ServerNotification__ThreadNameUpdatedNotification;
    }
  | {
      readonly method: "thread/goal/updated";
      readonly params: ServerNotification__ThreadGoalUpdatedNotification;
    }
  | {
      readonly method: "thread/goal/cleared";
      readonly params: ServerNotification__ThreadGoalClearedNotification;
    }
  | {
      readonly method: "thread/tokenUsage/updated";
      readonly params: ServerNotification__ThreadTokenUsageUpdatedNotification;
    }
  | {
      readonly method: "turn/started";
      readonly params: ServerNotification__TurnStartedNotification;
    }
  | {
      readonly method: "hook/started";
      readonly params: ServerNotification__HookStartedNotification;
    }
  | {
      readonly method: "turn/completed";
      readonly params: ServerNotification__TurnCompletedNotification;
    }
  | {
      readonly method: "hook/completed";
      readonly params: ServerNotification__HookCompletedNotification;
    }
  | {
      readonly method: "turn/diff/updated";
      readonly params: ServerNotification__TurnDiffUpdatedNotification;
    }
  | {
      readonly method: "turn/plan/updated";
      readonly params: ServerNotification__TurnPlanUpdatedNotification;
    }
  | {
      readonly method: "item/started";
      readonly params: ServerNotification__ItemStartedNotification;
    }
  | {
      readonly method: "item/autoApprovalReview/started";
      readonly params: ServerNotification__ItemGuardianApprovalReviewStartedNotification;
    }
  | {
      readonly method: "item/autoApprovalReview/completed";
      readonly params: ServerNotification__ItemGuardianApprovalReviewCompletedNotification;
    }
  | {
      readonly method: "item/completed";
      readonly params: ServerNotification__ItemCompletedNotification;
    }
  | {
      readonly method: "item/agentMessage/delta";
      readonly params: ServerNotification__AgentMessageDeltaNotification;
    }
  | {
      readonly method: "item/plan/delta";
      readonly params: ServerNotification__PlanDeltaNotification;
    }
  | {
      readonly method: "command/exec/outputDelta";
      readonly params: ServerNotification__CommandExecOutputDeltaNotification;
    }
  | {
      readonly method: "process/outputDelta";
      readonly params: ServerNotification__ProcessOutputDeltaNotification;
    }
  | {
      readonly method: "process/exited";
      readonly params: ServerNotification__ProcessExitedNotification;
    }
  | {
      readonly method: "item/commandExecution/outputDelta";
      readonly params: ServerNotification__CommandExecutionOutputDeltaNotification;
    }
  | {
      readonly method: "item/commandExecution/terminalInteraction";
      readonly params: ServerNotification__TerminalInteractionNotification;
    }
  | {
      readonly method: "item/fileChange/outputDelta";
      readonly params: ServerNotification__FileChangeOutputDeltaNotification;
    }
  | {
      readonly method: "item/fileChange/patchUpdated";
      readonly params: ServerNotification__FileChangePatchUpdatedNotification;
    }
  | {
      readonly method: "serverRequest/resolved";
      readonly params: ServerNotification__ServerRequestResolvedNotification;
    }
  | {
      readonly method: "item/mcpToolCall/progress";
      readonly params: ServerNotification__McpToolCallProgressNotification;
    }
  | {
      readonly method: "mcpServer/oauthLogin/completed";
      readonly params: ServerNotification__McpServerOauthLoginCompletedNotification;
    }
  | {
      readonly method: "mcpServer/startupStatus/updated";
      readonly params: ServerNotification__McpServerStatusUpdatedNotification;
    }
  | {
      readonly method: "account/updated";
      readonly params: ServerNotification__AccountUpdatedNotification;
    }
  | {
      readonly method: "account/rateLimits/updated";
      readonly params: ServerNotification__AccountRateLimitsUpdatedNotification;
    }
  | {
      readonly method: "app/list/updated";
      readonly params: ServerNotification__AppListUpdatedNotification;
    }
  | {
      readonly method: "remoteControl/status/changed";
      readonly params: ServerNotification__RemoteControlStatusChangedNotification;
    }
  | {
      readonly method: "externalAgentConfig/import/completed";
      readonly params: ServerNotification__ExternalAgentConfigImportCompletedNotification;
    }
  | { readonly method: "fs/changed"; readonly params: ServerNotification__FsChangedNotification }
  | {
      readonly method: "item/reasoning/summaryTextDelta";
      readonly params: ServerNotification__ReasoningSummaryTextDeltaNotification;
    }
  | {
      readonly method: "item/reasoning/summaryPartAdded";
      readonly params: ServerNotification__ReasoningSummaryPartAddedNotification;
    }
  | {
      readonly method: "item/reasoning/textDelta";
      readonly params: ServerNotification__ReasoningTextDeltaNotification;
    }
  | {
      readonly method: "thread/compacted";
      readonly params: ServerNotification__ContextCompactedNotification;
    }
  | {
      readonly method: "model/rerouted";
      readonly params: ServerNotification__ModelReroutedNotification;
    }
  | {
      readonly method: "model/verification";
      readonly params: ServerNotification__ModelVerificationNotification;
    }
  | { readonly method: "warning"; readonly params: ServerNotification__WarningNotification }
  | {
      readonly method: "guardianWarning";
      readonly params: ServerNotification__GuardianWarningNotification;
    }
  | {
      readonly method: "deprecationNotice";
      readonly params: ServerNotification__DeprecationNoticeNotification;
    }
  | {
      readonly method: "configWarning";
      readonly params: ServerNotification__ConfigWarningNotification;
    }
  | {
      readonly method: "fuzzyFileSearch/sessionUpdated";
      readonly params: ServerNotification__FuzzyFileSearchSessionUpdatedNotification;
    }
  | {
      readonly method: "fuzzyFileSearch/sessionCompleted";
      readonly params: ServerNotification__FuzzyFileSearchSessionCompletedNotification;
    }
  | {
      readonly method: "thread/realtime/started";
      readonly params: ServerNotification__ThreadRealtimeStartedNotification;
    }
  | {
      readonly method: "thread/realtime/itemAdded";
      readonly params: ServerNotification__ThreadRealtimeItemAddedNotification;
    }
  | {
      readonly method: "thread/realtime/transcript/delta";
      readonly params: ServerNotification__ThreadRealtimeTranscriptDeltaNotification;
    }
  | {
      readonly method: "thread/realtime/transcript/done";
      readonly params: ServerNotification__ThreadRealtimeTranscriptDoneNotification;
    }
  | {
      readonly method: "thread/realtime/outputAudio/delta";
      readonly params: ServerNotification__ThreadRealtimeOutputAudioDeltaNotification;
    }
  | {
      readonly method: "thread/realtime/sdp";
      readonly params: ServerNotification__ThreadRealtimeSdpNotification;
    }
  | {
      readonly method: "thread/realtime/error";
      readonly params: ServerNotification__ThreadRealtimeErrorNotification;
    }
  | {
      readonly method: "thread/realtime/closed";
      readonly params: ServerNotification__ThreadRealtimeClosedNotification;
    }
  | {
      readonly method: "windows/worldWritableWarning";
      readonly params: ServerNotification__WindowsWorldWritableWarningNotification;
    }
  | {
      readonly method: "windowsSandbox/setupCompleted";
      readonly params: ServerNotification__WindowsSandboxSetupCompletedNotification;
    }
  | {
      readonly method: "account/login/completed";
      readonly params: ServerNotification__AccountLoginCompletedNotification;
    };
export const ServerNotification = Schema.Union(
  [
    Schema.Struct({
      method: Schema.Literal("error").annotate({ title: "ErrorNotificationMethod" }),
      params: ServerNotification__ErrorNotification,
    }).annotate({ title: "ErrorNotification", description: "NEW NOTIFICATIONS" }),
    Schema.Struct({
      method: Schema.Literal("thread/started").annotate({
        title: "Thread/startedNotificationMethod",
      }),
      params: ServerNotification__ThreadStartedNotification,
    }).annotate({ title: "Thread/startedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/status/changed").annotate({
        title: "Thread/status/changedNotificationMethod",
      }),
      params: ServerNotification__ThreadStatusChangedNotification,
    }).annotate({ title: "Thread/status/changedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/archived").annotate({
        title: "Thread/archivedNotificationMethod",
      }),
      params: ServerNotification__ThreadArchivedNotification,
    }).annotate({ title: "Thread/archivedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/unarchived").annotate({
        title: "Thread/unarchivedNotificationMethod",
      }),
      params: ServerNotification__ThreadUnarchivedNotification,
    }).annotate({ title: "Thread/unarchivedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/closed").annotate({
        title: "Thread/closedNotificationMethod",
      }),
      params: ServerNotification__ThreadClosedNotification,
    }).annotate({ title: "Thread/closedNotification" }),
    Schema.Struct({
      method: Schema.Literal("skills/changed").annotate({
        title: "Skills/changedNotificationMethod",
      }),
      params: ServerNotification__SkillsChangedNotification,
    }).annotate({ title: "Skills/changedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/name/updated").annotate({
        title: "Thread/name/updatedNotificationMethod",
      }),
      params: ServerNotification__ThreadNameUpdatedNotification,
    }).annotate({ title: "Thread/name/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/goal/updated").annotate({
        title: "Thread/goal/updatedNotificationMethod",
      }),
      params: ServerNotification__ThreadGoalUpdatedNotification,
    }).annotate({ title: "Thread/goal/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/goal/cleared").annotate({
        title: "Thread/goal/clearedNotificationMethod",
      }),
      params: ServerNotification__ThreadGoalClearedNotification,
    }).annotate({ title: "Thread/goal/clearedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/tokenUsage/updated").annotate({
        title: "Thread/tokenUsage/updatedNotificationMethod",
      }),
      params: ServerNotification__ThreadTokenUsageUpdatedNotification,
    }).annotate({ title: "Thread/tokenUsage/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("turn/started").annotate({ title: "Turn/startedNotificationMethod" }),
      params: ServerNotification__TurnStartedNotification,
    }).annotate({ title: "Turn/startedNotification" }),
    Schema.Struct({
      method: Schema.Literal("hook/started").annotate({ title: "Hook/startedNotificationMethod" }),
      params: ServerNotification__HookStartedNotification,
    }).annotate({ title: "Hook/startedNotification" }),
    Schema.Struct({
      method: Schema.Literal("turn/completed").annotate({
        title: "Turn/completedNotificationMethod",
      }),
      params: ServerNotification__TurnCompletedNotification,
    }).annotate({ title: "Turn/completedNotification" }),
    Schema.Struct({
      method: Schema.Literal("hook/completed").annotate({
        title: "Hook/completedNotificationMethod",
      }),
      params: ServerNotification__HookCompletedNotification,
    }).annotate({ title: "Hook/completedNotification" }),
    Schema.Struct({
      method: Schema.Literal("turn/diff/updated").annotate({
        title: "Turn/diff/updatedNotificationMethod",
      }),
      params: ServerNotification__TurnDiffUpdatedNotification,
    }).annotate({ title: "Turn/diff/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("turn/plan/updated").annotate({
        title: "Turn/plan/updatedNotificationMethod",
      }),
      params: ServerNotification__TurnPlanUpdatedNotification,
    }).annotate({ title: "Turn/plan/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/started").annotate({ title: "Item/startedNotificationMethod" }),
      params: ServerNotification__ItemStartedNotification,
    }).annotate({ title: "Item/startedNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/autoApprovalReview/started").annotate({
        title: "Item/autoApprovalReview/startedNotificationMethod",
      }),
      params: ServerNotification__ItemGuardianApprovalReviewStartedNotification,
    }).annotate({ title: "Item/autoApprovalReview/startedNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/autoApprovalReview/completed").annotate({
        title: "Item/autoApprovalReview/completedNotificationMethod",
      }),
      params: ServerNotification__ItemGuardianApprovalReviewCompletedNotification,
    }).annotate({ title: "Item/autoApprovalReview/completedNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/completed").annotate({
        title: "Item/completedNotificationMethod",
      }),
      params: ServerNotification__ItemCompletedNotification,
    }).annotate({ title: "Item/completedNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/agentMessage/delta").annotate({
        title: "Item/agentMessage/deltaNotificationMethod",
      }),
      params: ServerNotification__AgentMessageDeltaNotification,
    }).annotate({ title: "Item/agentMessage/deltaNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/plan/delta").annotate({
        title: "Item/plan/deltaNotificationMethod",
      }),
      params: ServerNotification__PlanDeltaNotification,
    }).annotate({
      title: "Item/plan/deltaNotification",
      description: "EXPERIMENTAL - proposed plan streaming deltas for plan items.",
    }),
    Schema.Struct({
      method: Schema.Literal("command/exec/outputDelta").annotate({
        title: "Command/exec/outputDeltaNotificationMethod",
      }),
      params: ServerNotification__CommandExecOutputDeltaNotification,
    }).annotate({
      title: "Command/exec/outputDeltaNotification",
      description:
        "Stream base64-encoded stdout/stderr chunks for a running `command/exec` session.",
    }),
    Schema.Struct({
      method: Schema.Literal("process/outputDelta").annotate({
        title: "Process/outputDeltaNotificationMethod",
      }),
      params: ServerNotification__ProcessOutputDeltaNotification,
    }).annotate({
      title: "Process/outputDeltaNotification",
      description:
        "Stream base64-encoded stdout/stderr chunks for a running `process/spawn` session.",
    }),
    Schema.Struct({
      method: Schema.Literal("process/exited").annotate({
        title: "Process/exitedNotificationMethod",
      }),
      params: ServerNotification__ProcessExitedNotification,
    }).annotate({
      title: "Process/exitedNotification",
      description: "Final exit notification for a `process/spawn` session.",
    }),
    Schema.Struct({
      method: Schema.Literal("item/commandExecution/outputDelta").annotate({
        title: "Item/commandExecution/outputDeltaNotificationMethod",
      }),
      params: ServerNotification__CommandExecutionOutputDeltaNotification,
    }).annotate({ title: "Item/commandExecution/outputDeltaNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/commandExecution/terminalInteraction").annotate({
        title: "Item/commandExecution/terminalInteractionNotificationMethod",
      }),
      params: ServerNotification__TerminalInteractionNotification,
    }).annotate({ title: "Item/commandExecution/terminalInteractionNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/fileChange/outputDelta").annotate({
        title: "Item/fileChange/outputDeltaNotificationMethod",
      }),
      params: ServerNotification__FileChangeOutputDeltaNotification,
    }).annotate({
      title: "Item/fileChange/outputDeltaNotification",
      description: "Deprecated legacy apply_patch output stream notification.",
    }),
    Schema.Struct({
      method: Schema.Literal("item/fileChange/patchUpdated").annotate({
        title: "Item/fileChange/patchUpdatedNotificationMethod",
      }),
      params: ServerNotification__FileChangePatchUpdatedNotification,
    }).annotate({ title: "Item/fileChange/patchUpdatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("serverRequest/resolved").annotate({
        title: "ServerRequest/resolvedNotificationMethod",
      }),
      params: ServerNotification__ServerRequestResolvedNotification,
    }).annotate({ title: "ServerRequest/resolvedNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/mcpToolCall/progress").annotate({
        title: "Item/mcpToolCall/progressNotificationMethod",
      }),
      params: ServerNotification__McpToolCallProgressNotification,
    }).annotate({ title: "Item/mcpToolCall/progressNotification" }),
    Schema.Struct({
      method: Schema.Literal("mcpServer/oauthLogin/completed").annotate({
        title: "McpServer/oauthLogin/completedNotificationMethod",
      }),
      params: ServerNotification__McpServerOauthLoginCompletedNotification,
    }).annotate({ title: "McpServer/oauthLogin/completedNotification" }),
    Schema.Struct({
      method: Schema.Literal("mcpServer/startupStatus/updated").annotate({
        title: "McpServer/startupStatus/updatedNotificationMethod",
      }),
      params: ServerNotification__McpServerStatusUpdatedNotification,
    }).annotate({ title: "McpServer/startupStatus/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("account/updated").annotate({
        title: "Account/updatedNotificationMethod",
      }),
      params: ServerNotification__AccountUpdatedNotification,
    }).annotate({ title: "Account/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("account/rateLimits/updated").annotate({
        title: "Account/rateLimits/updatedNotificationMethod",
      }),
      params: ServerNotification__AccountRateLimitsUpdatedNotification,
    }).annotate({ title: "Account/rateLimits/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("app/list/updated").annotate({
        title: "App/list/updatedNotificationMethod",
      }),
      params: ServerNotification__AppListUpdatedNotification,
    }).annotate({ title: "App/list/updatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("remoteControl/status/changed").annotate({
        title: "RemoteControl/status/changedNotificationMethod",
      }),
      params: ServerNotification__RemoteControlStatusChangedNotification,
    }).annotate({ title: "RemoteControl/status/changedNotification" }),
    Schema.Struct({
      method: Schema.Literal("externalAgentConfig/import/completed").annotate({
        title: "ExternalAgentConfig/import/completedNotificationMethod",
      }),
      params: ServerNotification__ExternalAgentConfigImportCompletedNotification,
    }).annotate({ title: "ExternalAgentConfig/import/completedNotification" }),
    Schema.Struct({
      method: Schema.Literal("fs/changed").annotate({ title: "Fs/changedNotificationMethod" }),
      params: ServerNotification__FsChangedNotification,
    }).annotate({ title: "Fs/changedNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/reasoning/summaryTextDelta").annotate({
        title: "Item/reasoning/summaryTextDeltaNotificationMethod",
      }),
      params: ServerNotification__ReasoningSummaryTextDeltaNotification,
    }).annotate({ title: "Item/reasoning/summaryTextDeltaNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/reasoning/summaryPartAdded").annotate({
        title: "Item/reasoning/summaryPartAddedNotificationMethod",
      }),
      params: ServerNotification__ReasoningSummaryPartAddedNotification,
    }).annotate({ title: "Item/reasoning/summaryPartAddedNotification" }),
    Schema.Struct({
      method: Schema.Literal("item/reasoning/textDelta").annotate({
        title: "Item/reasoning/textDeltaNotificationMethod",
      }),
      params: ServerNotification__ReasoningTextDeltaNotification,
    }).annotate({ title: "Item/reasoning/textDeltaNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/compacted").annotate({
        title: "Thread/compactedNotificationMethod",
      }),
      params: ServerNotification__ContextCompactedNotification,
    }).annotate({
      title: "Thread/compactedNotification",
      description: "Deprecated: Use `ContextCompaction` item type instead.",
    }),
    Schema.Struct({
      method: Schema.Literal("model/rerouted").annotate({
        title: "Model/reroutedNotificationMethod",
      }),
      params: ServerNotification__ModelReroutedNotification,
    }).annotate({ title: "Model/reroutedNotification" }),
    Schema.Struct({
      method: Schema.Literal("model/verification").annotate({
        title: "Model/verificationNotificationMethod",
      }),
      params: ServerNotification__ModelVerificationNotification,
    }).annotate({ title: "Model/verificationNotification" }),
    Schema.Struct({
      method: Schema.Literal("warning").annotate({ title: "WarningNotificationMethod" }),
      params: ServerNotification__WarningNotification,
    }).annotate({ title: "WarningNotification" }),
    Schema.Struct({
      method: Schema.Literal("guardianWarning").annotate({
        title: "GuardianWarningNotificationMethod",
      }),
      params: ServerNotification__GuardianWarningNotification,
    }).annotate({ title: "GuardianWarningNotification" }),
    Schema.Struct({
      method: Schema.Literal("deprecationNotice").annotate({
        title: "DeprecationNoticeNotificationMethod",
      }),
      params: ServerNotification__DeprecationNoticeNotification,
    }).annotate({ title: "DeprecationNoticeNotification" }),
    Schema.Struct({
      method: Schema.Literal("configWarning").annotate({
        title: "ConfigWarningNotificationMethod",
      }),
      params: ServerNotification__ConfigWarningNotification,
    }).annotate({ title: "ConfigWarningNotification" }),
    Schema.Struct({
      method: Schema.Literal("fuzzyFileSearch/sessionUpdated").annotate({
        title: "FuzzyFileSearch/sessionUpdatedNotificationMethod",
      }),
      params: ServerNotification__FuzzyFileSearchSessionUpdatedNotification,
    }).annotate({ title: "FuzzyFileSearch/sessionUpdatedNotification" }),
    Schema.Struct({
      method: Schema.Literal("fuzzyFileSearch/sessionCompleted").annotate({
        title: "FuzzyFileSearch/sessionCompletedNotificationMethod",
      }),
      params: ServerNotification__FuzzyFileSearchSessionCompletedNotification,
    }).annotate({ title: "FuzzyFileSearch/sessionCompletedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/realtime/started").annotate({
        title: "Thread/realtime/startedNotificationMethod",
      }),
      params: ServerNotification__ThreadRealtimeStartedNotification,
    }).annotate({ title: "Thread/realtime/startedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/realtime/itemAdded").annotate({
        title: "Thread/realtime/itemAddedNotificationMethod",
      }),
      params: ServerNotification__ThreadRealtimeItemAddedNotification,
    }).annotate({ title: "Thread/realtime/itemAddedNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/realtime/transcript/delta").annotate({
        title: "Thread/realtime/transcript/deltaNotificationMethod",
      }),
      params: ServerNotification__ThreadRealtimeTranscriptDeltaNotification,
    }).annotate({ title: "Thread/realtime/transcript/deltaNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/realtime/transcript/done").annotate({
        title: "Thread/realtime/transcript/doneNotificationMethod",
      }),
      params: ServerNotification__ThreadRealtimeTranscriptDoneNotification,
    }).annotate({ title: "Thread/realtime/transcript/doneNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/realtime/outputAudio/delta").annotate({
        title: "Thread/realtime/outputAudio/deltaNotificationMethod",
      }),
      params: ServerNotification__ThreadRealtimeOutputAudioDeltaNotification,
    }).annotate({ title: "Thread/realtime/outputAudio/deltaNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/realtime/sdp").annotate({
        title: "Thread/realtime/sdpNotificationMethod",
      }),
      params: ServerNotification__ThreadRealtimeSdpNotification,
    }).annotate({ title: "Thread/realtime/sdpNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/realtime/error").annotate({
        title: "Thread/realtime/errorNotificationMethod",
      }),
      params: ServerNotification__ThreadRealtimeErrorNotification,
    }).annotate({ title: "Thread/realtime/errorNotification" }),
    Schema.Struct({
      method: Schema.Literal("thread/realtime/closed").annotate({
        title: "Thread/realtime/closedNotificationMethod",
      }),
      params: ServerNotification__ThreadRealtimeClosedNotification,
    }).annotate({ title: "Thread/realtime/closedNotification" }),
    Schema.Struct({
      method: Schema.Literal("windows/worldWritableWarning").annotate({
        title: "Windows/worldWritableWarningNotificationMethod",
      }),
      params: ServerNotification__WindowsWorldWritableWarningNotification,
    }).annotate({
      title: "Windows/worldWritableWarningNotification",
      description:
        "Notifies the user of world-writable directories on Windows, which cannot be protected by the sandbox.",
    }),
    Schema.Struct({
      method: Schema.Literal("windowsSandbox/setupCompleted").annotate({
        title: "WindowsSandbox/setupCompletedNotificationMethod",
      }),
      params: ServerNotification__WindowsSandboxSetupCompletedNotification,
    }).annotate({ title: "WindowsSandbox/setupCompletedNotification" }),
    Schema.Struct({
      method: Schema.Literal("account/login/completed").annotate({
        title: "Account/login/completedNotificationMethod",
      }),
      params: ServerNotification__AccountLoginCompletedNotification,
    }).annotate({ title: "Account/login/completedNotification" }),
  ],
  { mode: "oneOf" },
).annotate({
  title: "ServerNotification",
  description: "Notification sent from the server to the client.",
});

export type ServerNotification__ByteRange = { readonly end: number; readonly start: number };
export const ServerNotification__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type ServerNotification__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const ServerNotification__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type ServerNotification__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
export const ServerNotification__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type ServerNotification__CommandExecOutputStream = "stdout" | "stderr";
export const ServerNotification__CommandExecOutputStream = Schema.Literals([
  "stdout",
  "stderr",
]).annotate({ description: "Stream label for `command/exec/outputDelta` notifications." });

export type ServerNotification__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const ServerNotification__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type ServerNotification__HookSource =
  | "system"
  | "user"
  | "project"
  | "mdm"
  | "sessionFlags"
  | "plugin"
  | "cloudRequirements"
  | "legacyManagedConfigFile"
  | "legacyManagedConfigMdm"
  | "unknown";
export const ServerNotification__HookSource = Schema.Literals([
  "system",
  "user",
  "project",
  "mdm",
  "sessionFlags",
  "plugin",
  "cloudRequirements",
  "legacyManagedConfigFile",
  "legacyManagedConfigMdm",
  "unknown",
]);

export type ServerNotification__ProcessOutputStream = "stdout" | "stderr";
export const ServerNotification__ProcessOutputStream = Schema.Literals([
  "stdout",
  "stderr",
]).annotate({ description: "Stream label for `process/outputDelta` notifications." });

export type ServerNotification__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: ServerNotification__SubAgentSource };
export const ServerNotification__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: ServerNotification__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type ServerNotification__TurnItemsView = "notLoaded" | "summary" | "full";
export const ServerNotification__TurnItemsView = Schema.Literals(["notLoaded", "summary", "full"]);

export type ServerRequest =
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "item/commandExecution/requestApproval";
      readonly params: ServerRequest__CommandExecutionRequestApprovalParams;
    }
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "item/fileChange/requestApproval";
      readonly params: ServerRequest__FileChangeRequestApprovalParams;
    }
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "item/tool/requestUserInput";
      readonly params: ServerRequest__ToolRequestUserInputParams;
    }
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "mcpServer/elicitation/request";
      readonly params: ServerRequest__McpServerElicitationRequestParams;
    }
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "item/permissions/requestApproval";
      readonly params: ServerRequest__PermissionsRequestApprovalParams;
    }
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "item/tool/call";
      readonly params: ServerRequest__DynamicToolCallParams;
    }
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "account/chatgptAuthTokens/refresh";
      readonly params: ServerRequest__ChatgptAuthTokensRefreshParams;
    }
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "applyPatchApproval";
      readonly params: ServerRequest__ApplyPatchApprovalParams;
    }
  | {
      readonly id: ServerRequest__RequestId;
      readonly method: "execCommandApproval";
      readonly params: ServerRequest__ExecCommandApprovalParams;
    };
export const ServerRequest = Schema.Union(
  [
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("item/commandExecution/requestApproval").annotate({
        title: "Item/commandExecution/requestApprovalRequestMethod",
      }),
      params: ServerRequest__CommandExecutionRequestApprovalParams,
    }).annotate({
      title: "Item/commandExecution/requestApprovalRequest",
      description:
        "NEW APIs Sent when approval is requested for a specific command execution. This request is used for Turns started via turn/start.",
    }),
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("item/fileChange/requestApproval").annotate({
        title: "Item/fileChange/requestApprovalRequestMethod",
      }),
      params: ServerRequest__FileChangeRequestApprovalParams,
    }).annotate({
      title: "Item/fileChange/requestApprovalRequest",
      description:
        "Sent when approval is requested for a specific file change. This request is used for Turns started via turn/start.",
    }),
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("item/tool/requestUserInput").annotate({
        title: "Item/tool/requestUserInputRequestMethod",
      }),
      params: ServerRequest__ToolRequestUserInputParams,
    }).annotate({
      title: "Item/tool/requestUserInputRequest",
      description: "EXPERIMENTAL - Request input from the user for a tool call.",
    }),
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("mcpServer/elicitation/request").annotate({
        title: "McpServer/elicitation/requestRequestMethod",
      }),
      params: ServerRequest__McpServerElicitationRequestParams,
    }).annotate({
      title: "McpServer/elicitation/requestRequest",
      description: "Request input for an MCP server elicitation.",
    }),
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("item/permissions/requestApproval").annotate({
        title: "Item/permissions/requestApprovalRequestMethod",
      }),
      params: ServerRequest__PermissionsRequestApprovalParams,
    }).annotate({
      title: "Item/permissions/requestApprovalRequest",
      description: "Request approval for additional permissions from the user.",
    }),
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("item/tool/call").annotate({ title: "Item/tool/callRequestMethod" }),
      params: ServerRequest__DynamicToolCallParams,
    }).annotate({
      title: "Item/tool/callRequest",
      description: "Execute a dynamic tool call on the client.",
    }),
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("account/chatgptAuthTokens/refresh").annotate({
        title: "Account/chatgptAuthTokens/refreshRequestMethod",
      }),
      params: ServerRequest__ChatgptAuthTokensRefreshParams,
    }).annotate({ title: "Account/chatgptAuthTokens/refreshRequest" }),
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("applyPatchApproval").annotate({
        title: "ApplyPatchApprovalRequestMethod",
      }),
      params: ServerRequest__ApplyPatchApprovalParams,
    }).annotate({
      title: "ApplyPatchApprovalRequest",
      description:
        "DEPRECATED APIs below Request to approve a patch. This request is used for Turns started via the legacy APIs (i.e. SendUserTurn, SendUserMessage).",
    }),
    Schema.Struct({
      id: ServerRequest__RequestId,
      method: Schema.Literal("execCommandApproval").annotate({
        title: "ExecCommandApprovalRequestMethod",
      }),
      params: ServerRequest__ExecCommandApprovalParams,
    }).annotate({
      title: "ExecCommandApprovalRequest",
      description:
        "Request to exec a command. This request is used for Turns started via the legacy APIs (i.e. SendUserTurn, SendUserMessage).",
    }),
  ],
  { mode: "oneOf" },
).annotate({
  title: "ServerRequest",
  description: "Request initiated from the server and sent to the client.",
});

export type ServerRequest__AdditionalPermissionProfile = {
  readonly fileSystem?: ServerRequest__AdditionalFileSystemPermissions | null;
  readonly network?: ServerRequest__AdditionalNetworkPermissions | null;
};
export const ServerRequest__AdditionalPermissionProfile = Schema.Struct({
  fileSystem: Schema.optionalKey(
    Schema.Union([ServerRequest__AdditionalFileSystemPermissions, Schema.Null]),
  ),
  network: Schema.optionalKey(
    Schema.Union([ServerRequest__AdditionalNetworkPermissions, Schema.Null]).annotate({
      description: "Partial overlay used for per-command permission requests.",
    }),
  ),
});

export type ServerRequest__CommandExecutionApprovalDecision =
  | "accept"
  | "acceptForSession"
  | {
      readonly acceptWithExecpolicyAmendment: {
        readonly execpolicy_amendment: ReadonlyArray<string>;
      };
    }
  | {
      readonly applyNetworkPolicyAmendment: {
        readonly network_policy_amendment: ServerRequest__NetworkPolicyAmendment;
      };
    }
  | "decline"
  | "cancel";
export const ServerRequest__CommandExecutionApprovalDecision = Schema.Union(
  [
    Schema.Literal("accept").annotate({ description: "User approved the command." }),
    Schema.Literal("acceptForSession").annotate({
      description:
        "User approved the command and future prompts in the same session-scoped approval cache should run without prompting.",
    }),
    Schema.Struct({
      acceptWithExecpolicyAmendment: Schema.Struct({
        execpolicy_amendment: Schema.Array(Schema.String),
      }),
    }).annotate({
      title: "AcceptWithExecpolicyAmendmentCommandExecutionApprovalDecision",
      description:
        "User approved the command, and wants to apply the proposed execpolicy amendment so future matching commands can run without prompting.",
    }),
    Schema.Struct({
      applyNetworkPolicyAmendment: Schema.Struct({
        network_policy_amendment: ServerRequest__NetworkPolicyAmendment,
      }),
    }).annotate({
      title: "ApplyNetworkPolicyAmendmentCommandExecutionApprovalDecision",
      description: "User chose a persistent network policy rule (allow/deny) for this host.",
    }),
    Schema.Literal("decline").annotate({
      description: "User denied the command. The agent will continue the turn.",
    }),
    Schema.Literal("cancel").annotate({
      description: "User denied the command. The turn will also be immediately interrupted.",
    }),
  ],
  { mode: "oneOf" },
);

export type ToolRequestUserInputParams = {
  readonly itemId: string;
  readonly questions: ReadonlyArray<ToolRequestUserInputParams__ToolRequestUserInputQuestion>;
  readonly threadId: string;
  readonly turnId: string;
};
export const ToolRequestUserInputParams = Schema.Struct({
  itemId: Schema.String,
  questions: Schema.Array(ToolRequestUserInputParams__ToolRequestUserInputQuestion),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  title: "ToolRequestUserInputParams",
  description: "EXPERIMENTAL. Params sent with a request_user_input event.",
});

export type ToolRequestUserInputResponse = {
  readonly answers: {
    readonly [x: string]: ToolRequestUserInputResponse__ToolRequestUserInputAnswer;
  };
};
export const ToolRequestUserInputResponse = Schema.Struct({
  answers: Schema.Record(Schema.String, ToolRequestUserInputResponse__ToolRequestUserInputAnswer),
}).annotate({
  title: "ToolRequestUserInputResponse",
  description: "EXPERIMENTAL. Response payload mapping question ids to answers.",
});

export type V1InitializeParams = {
  readonly capabilities?: V1InitializeParams__InitializeCapabilities | null;
  readonly clientInfo: V1InitializeParams__ClientInfo;
};
export const V1InitializeParams = Schema.Struct({
  capabilities: Schema.optionalKey(
    Schema.Union([V1InitializeParams__InitializeCapabilities, Schema.Null]),
  ),
  clientInfo: V1InitializeParams__ClientInfo,
}).annotate({ title: "InitializeParams" });

export type V1InitializeResponse = {
  readonly codexHome: string;
  readonly platformFamily: string;
  readonly platformOs: string;
  readonly userAgent: string;
};
export const V1InitializeResponse = Schema.Struct({
  codexHome: Schema.String.annotate({
    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.",
  }),
  platformFamily: Schema.String.annotate({
    description:
      'Platform family for the running app-server target, for example `"unix"` or `"windows"`.',
  }),
  platformOs: Schema.String.annotate({
    description:
      'Operating system for the running app-server target, for example `"macos"`, `"linux"`, or `"windows"`.',
  }),
  userAgent: Schema.String,
}).annotate({ title: "InitializeResponse" });

export type V1InitializeResponse__AbsolutePathBuf = string;
export const V1InitializeResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2AccountLoginCompletedNotification = {
  readonly error?: string | null;
  readonly loginId?: string | null;
  readonly success: boolean;
};
export const V2AccountLoginCompletedNotification = Schema.Struct({
  error: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  loginId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  success: Schema.Boolean,
}).annotate({ title: "AccountLoginCompletedNotification" });

export type V2AccountRateLimitsUpdatedNotification = {
  readonly rateLimits: V2AccountRateLimitsUpdatedNotification__RateLimitSnapshot;
};
export const V2AccountRateLimitsUpdatedNotification = Schema.Struct({
  rateLimits: V2AccountRateLimitsUpdatedNotification__RateLimitSnapshot,
}).annotate({ title: "AccountRateLimitsUpdatedNotification" });

export type V2AccountUpdatedNotification = {
  readonly authMode?: V2AccountUpdatedNotification__AuthMode | null;
  readonly planType?: V2AccountUpdatedNotification__PlanType | null;
};
export const V2AccountUpdatedNotification = Schema.Struct({
  authMode: Schema.optionalKey(Schema.Union([V2AccountUpdatedNotification__AuthMode, Schema.Null])),
  planType: Schema.optionalKey(Schema.Union([V2AccountUpdatedNotification__PlanType, Schema.Null])),
}).annotate({ title: "AccountUpdatedNotification" });

export type V2AgentMessageDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2AgentMessageDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "AgentMessageDeltaNotification" });

export type V2AppListUpdatedNotification = {
  readonly data: ReadonlyArray<V2AppListUpdatedNotification__AppInfo>;
};
export const V2AppListUpdatedNotification = Schema.Struct({
  data: Schema.Array(V2AppListUpdatedNotification__AppInfo),
}).annotate({
  title: "AppListUpdatedNotification",
  description: "EXPERIMENTAL - notification emitted when the app list changes.",
});

export type V2AppsListParams = {
  readonly cursor?: string | null;
  readonly forceRefetch?: boolean;
  readonly limit?: number | null;
  readonly threadId?: string | null;
};
export const V2AppsListParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  forceRefetch: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "When true, bypass app caches and fetch the latest data from sources.",
    }),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a reasonable server-side value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  threadId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional thread id used to evaluate app feature gating from that thread's config.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({
  title: "AppsListParams",
  description: "EXPERIMENTAL - list available apps/connectors.",
});

export type V2AppsListResponse = {
  readonly data: ReadonlyArray<V2AppsListResponse__AppInfo>;
  readonly nextCursor?: string | null;
};
export const V2AppsListResponse = Schema.Struct({
  data: Schema.Array(V2AppsListResponse__AppInfo),
  nextCursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "AppsListResponse", description: "EXPERIMENTAL - app list response." });

export type V2CancelLoginAccountParams = { readonly loginId: string };
export const V2CancelLoginAccountParams = Schema.Struct({ loginId: Schema.String }).annotate({
  title: "CancelLoginAccountParams",
});

export type V2CancelLoginAccountResponse = {
  readonly status: V2CancelLoginAccountResponse__CancelLoginAccountStatus;
};
export const V2CancelLoginAccountResponse = Schema.Struct({
  status: V2CancelLoginAccountResponse__CancelLoginAccountStatus,
}).annotate({ title: "CancelLoginAccountResponse" });

export type V2CommandExecOutputDeltaNotification = {
  readonly capReached: boolean;
  readonly deltaBase64: string;
  readonly processId: string;
  readonly stream: "stdout" | "stderr";
};
export const V2CommandExecOutputDeltaNotification = Schema.Struct({
  capReached: Schema.Boolean.annotate({
    description:
      "`true` on the final streamed chunk for a stream when `outputBytesCap` truncated later output on that stream.",
  }),
  deltaBase64: Schema.String.annotate({ description: "Base64-encoded output bytes." }),
  processId: Schema.String.annotate({
    description:
      "Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
  }),
  stream: Schema.Literals(["stdout", "stderr"]).annotate({
    description: "Stream label for `command/exec/outputDelta` notifications.",
  }),
}).annotate({
  title: "CommandExecOutputDeltaNotification",
  description:
    "Base64-encoded output chunk emitted for a streaming `command/exec` request.\n\nThese notifications are connection-scoped. If the originating connection closes, the server terminates the process.",
});

export type V2CommandExecOutputDeltaNotification__CommandExecOutputStream = "stdout" | "stderr";
export const V2CommandExecOutputDeltaNotification__CommandExecOutputStream = Schema.Literals([
  "stdout",
  "stderr",
]).annotate({ description: "Stream label for `command/exec/outputDelta` notifications." });

export type V2CommandExecParams = {
  readonly command: ReadonlyArray<string>;
  readonly cwd?: string | null;
  readonly disableOutputCap?: boolean;
  readonly disableTimeout?: boolean;
  readonly env?: { readonly [x: string]: string | null } | null;
  readonly outputBytesCap?: number | null;
  readonly processId?: string | null;
  readonly sandboxPolicy?: V2CommandExecParams__SandboxPolicy | null;
  readonly size?: V2CommandExecParams__CommandExecTerminalSize | null;
  readonly streamStdin?: boolean;
  readonly streamStdoutStderr?: boolean;
  readonly timeoutMs?: number | null;
  readonly tty?: boolean;
};
export const V2CommandExecParams = Schema.Struct({
  command: Schema.Array(Schema.String).annotate({
    description: "Command argv vector. Empty arrays are rejected.",
  }),
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional working directory. Defaults to the server cwd.",
      }),
      Schema.Null,
    ]),
  ),
  disableOutputCap: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Disable stdout/stderr capture truncation for this request.\n\nCannot be combined with `outputBytesCap`.",
    }),
  ),
  disableTimeout: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Disable the timeout entirely for this request.\n\nCannot be combined with `timeoutMs`.",
    }),
  ),
  env: Schema.optionalKey(
    Schema.Union([
      Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Null])).annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  outputBytesCap: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description:
          "Optional per-stream stdout/stderr capture cap in bytes.\n\nWhen omitted, the server default applies. Cannot be combined with `disableOutputCap`.",
        format: "uint",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  processId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  sandboxPolicy: Schema.optionalKey(
    Schema.Union([V2CommandExecParams__SandboxPolicy, Schema.Null]).annotate({
      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`.",
    }),
  ),
  size: Schema.optionalKey(
    Schema.Union([V2CommandExecParams__CommandExecTerminalSize, Schema.Null]).annotate({
      description: "Optional initial PTY size in character cells. Only valid when `tty` is true.",
    }),
  ),
  streamStdin: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "Allow follow-up `command/exec/write` requests to write stdin bytes.\n\nRequires a client-supplied `processId`.",
    }),
  ),
  streamStdoutStderr: Schema.optionalKey(
    Schema.Boolean.annotate({
      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`.",
    }),
  ),
  timeoutMs: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description:
          "Optional timeout in milliseconds.\n\nWhen omitted, the server default applies. Cannot be combined with `disableTimeout`.",
        format: "int64",
      }).check(Schema.isInt()),
      Schema.Null,
    ]),
  ),
  tty: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "Enable PTY mode.\n\nThis implies `streamStdin` and `streamStdoutStderr`.",
    }),
  ),
}).annotate({
  title: "CommandExecParams",
  description:
    "Run a standalone command (argv vector) in the server sandbox without creating a thread or turn.\n\nThe final `command/exec` response is deferred until the process exits and is sent only after all `command/exec/outputDelta` notifications for that connection have been emitted.",
});

export type V2CommandExecParams__NetworkAccess = "restricted" | "enabled";
export const V2CommandExecParams__NetworkAccess = Schema.Literals(["restricted", "enabled"]);

export type V2CommandExecParams__PermissionProfile =
  | {
      readonly fileSystem: V2CommandExecParams__PermissionProfileFileSystemPermissions;
      readonly network: V2CommandExecParams__PermissionProfileNetworkPermissions;
      readonly type: "managed";
    }
  | { readonly type: "disabled" }
  | {
      readonly network: V2CommandExecParams__PermissionProfileNetworkPermissions;
      readonly type: "external";
    };
export const V2CommandExecParams__PermissionProfile = Schema.Union(
  [
    Schema.Struct({
      fileSystem: V2CommandExecParams__PermissionProfileFileSystemPermissions,
      network: V2CommandExecParams__PermissionProfileNetworkPermissions,
      type: Schema.Literal("managed").annotate({ title: "ManagedPermissionProfileType" }),
    }).annotate({
      title: "ManagedPermissionProfile",
      description: "Codex owns sandbox construction for this profile.",
    }),
    Schema.Struct({
      type: Schema.Literal("disabled").annotate({ title: "DisabledPermissionProfileType" }),
    }).annotate({
      title: "DisabledPermissionProfile",
      description: "Do not apply an outer sandbox.",
    }),
    Schema.Struct({
      network: V2CommandExecParams__PermissionProfileNetworkPermissions,
      type: Schema.Literal("external").annotate({ title: "ExternalPermissionProfileType" }),
    }).annotate({
      title: "ExternalPermissionProfile",
      description: "Filesystem isolation is enforced by an external caller.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2CommandExecResizeParams = {
  readonly processId: string;
  readonly size: { readonly cols: number; readonly rows: number };
};
export const V2CommandExecResizeParams = Schema.Struct({
  processId: Schema.String.annotate({
    description:
      "Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
  }),
  size: Schema.Struct({
    cols: Schema.Number.annotate({
      description: "Terminal width in character cells.",
      format: "uint16",
    })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
    rows: Schema.Number.annotate({
      description: "Terminal height in character cells.",
      format: "uint16",
    })
      .check(Schema.isInt())
      .check(Schema.isGreaterThanOrEqualTo(0)),
  }).annotate({ description: "PTY size in character cells for `command/exec` PTY sessions." }),
}).annotate({
  title: "CommandExecResizeParams",
  description: "Resize a running PTY-backed `command/exec` session.",
});

export type V2CommandExecResizeParams__CommandExecTerminalSize = {
  readonly cols: number;
  readonly rows: number;
};
export const V2CommandExecResizeParams__CommandExecTerminalSize = Schema.Struct({
  cols: Schema.Number.annotate({
    description: "Terminal width in character cells.",
    format: "uint16",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  rows: Schema.Number.annotate({
    description: "Terminal height in character cells.",
    format: "uint16",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
}).annotate({ description: "PTY size in character cells for `command/exec` PTY sessions." });

export type V2CommandExecResizeResponse = {};
export const V2CommandExecResizeResponse = Schema.Struct({}).annotate({
  title: "CommandExecResizeResponse",
  description: "Empty success response for `command/exec/resize`.",
});

export type V2CommandExecResponse = {
  readonly exitCode: number;
  readonly stderr: string;
  readonly stdout: string;
};
export const V2CommandExecResponse = Schema.Struct({
  exitCode: Schema.Number.annotate({ description: "Process exit code.", format: "int32" }).check(
    Schema.isInt(),
  ),
  stderr: Schema.String.annotate({
    description:
      "Buffered stderr capture.\n\nEmpty when stderr was streamed via `command/exec/outputDelta`.",
  }),
  stdout: Schema.String.annotate({
    description:
      "Buffered stdout capture.\n\nEmpty when stdout was streamed via `command/exec/outputDelta`.",
  }),
}).annotate({
  title: "CommandExecResponse",
  description: "Final buffered result for `command/exec`.",
});

export type V2CommandExecTerminateParams = { readonly processId: string };
export const V2CommandExecTerminateParams = Schema.Struct({
  processId: Schema.String.annotate({
    description:
      "Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
  }),
}).annotate({
  title: "CommandExecTerminateParams",
  description: "Terminate a running `command/exec` session.",
});

export type V2CommandExecTerminateResponse = {};
export const V2CommandExecTerminateResponse = Schema.Struct({}).annotate({
  title: "CommandExecTerminateResponse",
  description: "Empty success response for `command/exec/terminate`.",
});

export type V2CommandExecutionOutputDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2CommandExecutionOutputDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "CommandExecutionOutputDeltaNotification" });

export type V2CommandExecWriteParams = {
  readonly closeStdin?: boolean;
  readonly deltaBase64?: string | null;
  readonly processId: string;
};
export const V2CommandExecWriteParams = Schema.Struct({
  closeStdin: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "Close stdin after writing `deltaBase64`, if present.",
    }),
  ),
  deltaBase64: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional base64-encoded stdin bytes to write." }),
      Schema.Null,
    ]),
  ),
  processId: Schema.String.annotate({
    description:
      "Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
  }),
}).annotate({
  title: "CommandExecWriteParams",
  description: "Write stdin bytes to a running `command/exec` session, close stdin, or both.",
});

export type V2CommandExecWriteResponse = {};
export const V2CommandExecWriteResponse = Schema.Struct({}).annotate({
  title: "CommandExecWriteResponse",
  description: "Empty success response for `command/exec/write`.",
});

export type V2ConfigBatchWriteParams = {
  readonly edits: ReadonlyArray<V2ConfigBatchWriteParams__ConfigEdit>;
  readonly expectedVersion?: string | null;
  readonly filePath?: string | null;
  readonly reloadUserConfig?: boolean;
};
export const V2ConfigBatchWriteParams = Schema.Struct({
  edits: Schema.Array(V2ConfigBatchWriteParams__ConfigEdit),
  expectedVersion: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  filePath: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Path to the config file to write; defaults to the user's `config.toml` when omitted.",
      }),
      Schema.Null,
    ]),
  ),
  reloadUserConfig: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "When true, hot-reload the updated user config into all loaded threads after writing.",
    }),
  ),
}).annotate({ title: "ConfigBatchWriteParams" });

export type V2ConfigReadParams = { readonly cwd?: string | null; readonly includeLayers?: boolean };
export const V2ConfigReadParams = Schema.Struct({
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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).",
      }),
      Schema.Null,
    ]),
  ),
  includeLayers: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
}).annotate({ title: "ConfigReadParams" });

export type V2ConfigReadResponse = {
  readonly config: V2ConfigReadResponse__Config;
  readonly layers?: ReadonlyArray<V2ConfigReadResponse__ConfigLayer> | null;
  readonly origins: { readonly [x: string]: V2ConfigReadResponse__ConfigLayerMetadata };
};
export const V2ConfigReadResponse = Schema.Struct({
  config: V2ConfigReadResponse__Config,
  layers: Schema.optionalKey(
    Schema.Union([Schema.Array(V2ConfigReadResponse__ConfigLayer), Schema.Null]),
  ),
  origins: Schema.Record(Schema.String, V2ConfigReadResponse__ConfigLayerMetadata),
}).annotate({ title: "ConfigReadResponse" });

export type V2ConfigReadResponse__AppConfig = {
  readonly default_tools_approval_mode?: V2ConfigReadResponse__AppToolApproval | null;
  readonly default_tools_enabled?: boolean | null;
  readonly destructive_enabled?: boolean | null;
  readonly enabled?: boolean;
  readonly open_world_enabled?: boolean | null;
  readonly tools?: V2ConfigReadResponse__AppToolsConfig | null;
};
export const V2ConfigReadResponse__AppConfig = Schema.Struct({
  default_tools_approval_mode: Schema.optionalKey(
    Schema.Union([V2ConfigReadResponse__AppToolApproval, Schema.Null]),
  ),
  default_tools_enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  destructive_enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  enabled: Schema.optionalKey(Schema.Boolean.annotate({ default: true })),
  open_world_enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  tools: Schema.optionalKey(Schema.Union([V2ConfigReadResponse__AppToolsConfig, Schema.Null])),
});

export type V2ConfigReadResponse__AppsConfig = {
  readonly _default?: V2ConfigReadResponse__AppsDefaultConfig | null;
};
export const V2ConfigReadResponse__AppsConfig = Schema.Struct({
  _default: Schema.optionalKey(
    Schema.Union([V2ConfigReadResponse__AppsDefaultConfig, Schema.Null]),
  ),
});

export type V2ConfigReadResponse__AppToolConfig = {
  readonly approval_mode?: V2ConfigReadResponse__AppToolApproval | null;
  readonly enabled?: boolean | null;
};
export const V2ConfigReadResponse__AppToolConfig = Schema.Struct({
  approval_mode: Schema.optionalKey(
    Schema.Union([V2ConfigReadResponse__AppToolApproval, Schema.Null]),
  ),
  enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
});

export type V2ConfigRequirementsReadResponse = {
  readonly requirements?: V2ConfigRequirementsReadResponse__ConfigRequirements | null;
};
export const V2ConfigRequirementsReadResponse = Schema.Struct({
  requirements: Schema.optionalKey(
    Schema.Union([V2ConfigRequirementsReadResponse__ConfigRequirements, Schema.Null]).annotate({
      description:
        "Null if no requirements are configured (e.g. no requirements.toml/MDM entries).",
    }),
  ),
}).annotate({ title: "ConfigRequirementsReadResponse" });

export type V2ConfigRequirementsReadResponse__ApprovalsReviewer =
  | "user"
  | "auto_review"
  | "guardian_subagent";
export const V2ConfigRequirementsReadResponse__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2ConfigRequirementsReadResponse__ManagedHooksRequirements = {
  readonly PermissionRequest: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup>;
  readonly PostCompact: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup>;
  readonly PostToolUse: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup>;
  readonly PreCompact: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup>;
  readonly PreToolUse: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup>;
  readonly SessionStart: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup>;
  readonly Stop: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup>;
  readonly UserPromptSubmit: ReadonlyArray<V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup>;
  readonly managedDir?: string | null;
  readonly windowsManagedDir?: string | null;
};
export const V2ConfigRequirementsReadResponse__ManagedHooksRequirements = Schema.Struct({
  PermissionRequest: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup),
  PostCompact: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup),
  PostToolUse: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup),
  PreCompact: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup),
  PreToolUse: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup),
  SessionStart: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup),
  Stop: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup),
  UserPromptSubmit: Schema.Array(V2ConfigRequirementsReadResponse__ConfiguredHookMatcherGroup),
  managedDir: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  windowsManagedDir: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ConfigRequirementsReadResponse__NetworkRequirements = {
  readonly allowLocalBinding?: boolean | null;
  readonly allowUnixSockets?: ReadonlyArray<string> | null;
  readonly allowUpstreamProxy?: boolean | null;
  readonly allowedDomains?: ReadonlyArray<string> | null;
  readonly dangerouslyAllowAllUnixSockets?: boolean | null;
  readonly dangerouslyAllowNonLoopbackProxy?: boolean | null;
  readonly deniedDomains?: ReadonlyArray<string> | null;
  readonly domains?: {
    readonly [x: string]: V2ConfigRequirementsReadResponse__NetworkDomainPermission;
  } | null;
  readonly enabled?: boolean | null;
  readonly httpPort?: number | null;
  readonly managedAllowedDomainsOnly?: boolean | null;
  readonly socksPort?: number | null;
  readonly unixSockets?: {
    readonly [x: string]: V2ConfigRequirementsReadResponse__NetworkUnixSocketPermission;
  } | null;
};
export const V2ConfigRequirementsReadResponse__NetworkRequirements = Schema.Struct({
  allowLocalBinding: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  allowUnixSockets: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description: "Legacy compatibility view derived from `unix_sockets`.",
      }),
      Schema.Null,
    ]),
  ),
  allowUpstreamProxy: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  allowedDomains: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description: "Legacy compatibility view derived from `domains`.",
      }),
      Schema.Null,
    ]),
  ),
  dangerouslyAllowAllUnixSockets: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  dangerouslyAllowNonLoopbackProxy: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  deniedDomains: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description: "Legacy compatibility view derived from `domains`.",
      }),
      Schema.Null,
    ]),
  ),
  domains: Schema.optionalKey(
    Schema.Union([
      Schema.Record(
        Schema.String,
        V2ConfigRequirementsReadResponse__NetworkDomainPermission,
      ).annotate({ description: "Canonical network permission map for `experimental_network`." }),
      Schema.Null,
    ]),
  ),
  enabled: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  httpPort: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint16" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  managedAllowedDomainsOnly: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description:
          "When true, only managed allowlist entries are respected while managed network enforcement is active.",
      }),
      Schema.Null,
    ]),
  ),
  socksPort: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({ format: "uint16" })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  unixSockets: Schema.optionalKey(
    Schema.Union([
      Schema.Record(
        Schema.String,
        V2ConfigRequirementsReadResponse__NetworkUnixSocketPermission,
      ).annotate({
        description: "Canonical unix socket permission map for `experimental_network`.",
      }),
      Schema.Null,
    ]),
  ),
});

export type V2ConfigValueWriteParams = {
  readonly expectedVersion?: string | null;
  readonly filePath?: string | null;
  readonly keyPath: string;
  readonly mergeStrategy: V2ConfigValueWriteParams__MergeStrategy;
  readonly value: unknown;
};
export const V2ConfigValueWriteParams = Schema.Struct({
  expectedVersion: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  filePath: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Path to the config file to write; defaults to the user's `config.toml` when omitted.",
      }),
      Schema.Null,
    ]),
  ),
  keyPath: Schema.String,
  mergeStrategy: V2ConfigValueWriteParams__MergeStrategy,
  value: Schema.Unknown,
}).annotate({ title: "ConfigValueWriteParams" });

export type V2ConfigWarningNotification = {
  readonly details?: string | null;
  readonly path?: string | null;
  readonly range?: V2ConfigWarningNotification__TextRange | null;
  readonly summary: string;
};
export const V2ConfigWarningNotification = Schema.Struct({
  details: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional extra guidance or error details." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional path to the config file that triggered the warning.",
      }),
      Schema.Null,
    ]),
  ),
  range: Schema.optionalKey(
    Schema.Union([V2ConfigWarningNotification__TextRange, Schema.Null]).annotate({
      description: "Optional range for the error location inside the config file.",
    }),
  ),
  summary: Schema.String.annotate({ description: "Concise summary of the warning." }),
}).annotate({ title: "ConfigWarningNotification" });

export type V2ConfigWriteResponse = {
  readonly filePath: string;
  readonly overriddenMetadata?: V2ConfigWriteResponse__OverriddenMetadata | null;
  readonly status: V2ConfigWriteResponse__WriteStatus;
  readonly version: string;
};
export const V2ConfigWriteResponse = Schema.Struct({
  filePath: Schema.String.annotate({
    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.",
  }),
  overriddenMetadata: Schema.optionalKey(
    Schema.Union([V2ConfigWriteResponse__OverriddenMetadata, Schema.Null]),
  ),
  status: V2ConfigWriteResponse__WriteStatus,
  version: Schema.String,
}).annotate({ title: "ConfigWriteResponse" });

export type V2ContextCompactedNotification = { readonly threadId: string; readonly turnId: string };
export const V2ContextCompactedNotification = Schema.Struct({
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  title: "ContextCompactedNotification",
  description: "Deprecated: Use `ContextCompaction` item type instead.",
});

export type V2DeprecationNoticeNotification = {
  readonly details?: string | null;
  readonly summary: string;
};
export const V2DeprecationNoticeNotification = Schema.Struct({
  details: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional extra guidance, such as migration steps or rationale.",
      }),
      Schema.Null,
    ]),
  ),
  summary: Schema.String.annotate({ description: "Concise summary of what is deprecated." }),
}).annotate({ title: "DeprecationNoticeNotification" });

export type V2ErrorNotification = {
  readonly error: V2ErrorNotification__TurnError;
  readonly threadId: string;
  readonly turnId: string;
  readonly willRetry: boolean;
};
export const V2ErrorNotification = Schema.Struct({
  error: V2ErrorNotification__TurnError,
  threadId: Schema.String,
  turnId: Schema.String,
  willRetry: Schema.Boolean,
}).annotate({ title: "ErrorNotification" });

export type V2ExperimentalFeatureEnablementSetParams = {
  readonly enablement: { readonly [x: string]: boolean };
};
export const V2ExperimentalFeatureEnablementSetParams = Schema.Struct({
  enablement: Schema.Record(Schema.String, Schema.Boolean).annotate({
    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.",
  }),
}).annotate({ title: "ExperimentalFeatureEnablementSetParams" });

export type V2ExperimentalFeatureEnablementSetResponse = {
  readonly enablement: { readonly [x: string]: boolean };
};
export const V2ExperimentalFeatureEnablementSetResponse = Schema.Struct({
  enablement: Schema.Record(Schema.String, Schema.Boolean).annotate({
    description: "Feature enablement entries updated by this request.",
  }),
}).annotate({ title: "ExperimentalFeatureEnablementSetResponse" });

export type V2ExperimentalFeatureListParams = {
  readonly cursor?: string | null;
  readonly limit?: number | null;
};
export const V2ExperimentalFeatureListParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a reasonable server-side value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ExperimentalFeatureListParams" });

export type V2ExperimentalFeatureListResponse = {
  readonly data: ReadonlyArray<V2ExperimentalFeatureListResponse__ExperimentalFeature>;
  readonly nextCursor?: string | null;
};
export const V2ExperimentalFeatureListResponse = Schema.Struct({
  data: Schema.Array(V2ExperimentalFeatureListResponse__ExperimentalFeature),
  nextCursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ExperimentalFeatureListResponse" });

export type V2ExperimentalFeatureListResponse__ExperimentalFeatureStage =
  | "beta"
  | "underDevelopment"
  | "stable"
  | "deprecated"
  | "removed";
export const V2ExperimentalFeatureListResponse__ExperimentalFeatureStage = Schema.Literals([
  "beta",
  "underDevelopment",
  "stable",
  "deprecated",
  "removed",
]);

export type V2ExternalAgentConfigDetectParams = {
  readonly cwds?: ReadonlyArray<string> | null;
  readonly includeHome?: boolean;
};
export const V2ExternalAgentConfigDetectParams = Schema.Struct({
  cwds: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description: "Zero or more working directories to include for repo-scoped detection.",
      }),
      Schema.Null,
    ]),
  ),
  includeHome: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "If true, include detection under the user's home (~/.claude, ~/.codex, etc.).",
    }),
  ),
}).annotate({ title: "ExternalAgentConfigDetectParams" });

export type V2ExternalAgentConfigDetectResponse = {
  readonly items: ReadonlyArray<V2ExternalAgentConfigDetectResponse__ExternalAgentConfigMigrationItem>;
};
export const V2ExternalAgentConfigDetectResponse = Schema.Struct({
  items: Schema.Array(V2ExternalAgentConfigDetectResponse__ExternalAgentConfigMigrationItem),
}).annotate({ title: "ExternalAgentConfigDetectResponse" });

export type V2ExternalAgentConfigImportCompletedNotification = {};
export const V2ExternalAgentConfigImportCompletedNotification = Schema.Struct({}).annotate({
  title: "ExternalAgentConfigImportCompletedNotification",
});

export type V2ExternalAgentConfigImportParams = {
  readonly migrationItems: ReadonlyArray<V2ExternalAgentConfigImportParams__ExternalAgentConfigMigrationItem>;
};
export const V2ExternalAgentConfigImportParams = Schema.Struct({
  migrationItems: Schema.Array(V2ExternalAgentConfigImportParams__ExternalAgentConfigMigrationItem),
}).annotate({ title: "ExternalAgentConfigImportParams" });

export type V2ExternalAgentConfigImportResponse = {};
export const V2ExternalAgentConfigImportResponse = Schema.Struct({}).annotate({
  title: "ExternalAgentConfigImportResponse",
});

export type V2FeedbackUploadParams = {
  readonly classification: string;
  readonly extraLogFiles?: ReadonlyArray<string> | null;
  readonly includeLogs: boolean;
  readonly reason?: string | null;
  readonly tags?: { readonly [x: string]: string } | null;
  readonly threadId?: string | null;
};
export const V2FeedbackUploadParams = Schema.Struct({
  classification: Schema.String,
  extraLogFiles: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  includeLogs: Schema.Boolean,
  reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  tags: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.String), Schema.Null]),
  ),
  threadId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "FeedbackUploadParams" });

export type V2FeedbackUploadResponse = { readonly threadId: string };
export const V2FeedbackUploadResponse = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "FeedbackUploadResponse",
});

export type V2FileChangeOutputDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2FileChangeOutputDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  title: "FileChangeOutputDeltaNotification",
  description:
    "Deprecated legacy notification for `apply_patch` textual output.\n\nThe server no longer emits this notification.",
});

export type V2FileChangePatchUpdatedNotification = {
  readonly changes: ReadonlyArray<V2FileChangePatchUpdatedNotification__FileUpdateChange>;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2FileChangePatchUpdatedNotification = Schema.Struct({
  changes: Schema.Array(V2FileChangePatchUpdatedNotification__FileUpdateChange),
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "FileChangePatchUpdatedNotification" });

export type V2FsChangedNotification = {
  readonly changedPaths: ReadonlyArray<V2FsChangedNotification__AbsolutePathBuf>;
  readonly watchId: string;
};
export const V2FsChangedNotification = Schema.Struct({
  changedPaths: Schema.Array(V2FsChangedNotification__AbsolutePathBuf).annotate({
    description: "File or directory paths associated with this event.",
  }),
  watchId: Schema.String.annotate({
    description: "Watch identifier previously provided to `fs/watch`.",
  }),
}).annotate({
  title: "FsChangedNotification",
  description: "Filesystem watch notification emitted for `fs/watch` subscribers.",
});

export type V2FsCopyParams = {
  readonly destinationPath: string;
  readonly recursive?: boolean;
  readonly sourcePath: string;
};
export const V2FsCopyParams = Schema.Struct({
  destinationPath: Schema.String.annotate({
    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.",
  }),
  recursive: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "Required for directory copies; ignored for file copies.",
    }),
  ),
  sourcePath: Schema.String.annotate({
    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.",
  }),
}).annotate({
  title: "FsCopyParams",
  description: "Copy a file or directory tree on the host filesystem.",
});

export type V2FsCopyParams__AbsolutePathBuf = string;
export const V2FsCopyParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsCopyResponse = {};
export const V2FsCopyResponse = Schema.Struct({}).annotate({
  title: "FsCopyResponse",
  description: "Successful response for `fs/copy`.",
});

export type V2FsCreateDirectoryParams = {
  readonly path: string;
  readonly recursive?: boolean | null;
};
export const V2FsCreateDirectoryParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
  recursive: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description: "Whether parent directories should also be created. Defaults to `true`.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({
  title: "FsCreateDirectoryParams",
  description: "Create a directory on the host filesystem.",
});

export type V2FsCreateDirectoryParams__AbsolutePathBuf = string;
export const V2FsCreateDirectoryParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsCreateDirectoryResponse = {};
export const V2FsCreateDirectoryResponse = Schema.Struct({}).annotate({
  title: "FsCreateDirectoryResponse",
  description: "Successful response for `fs/createDirectory`.",
});

export type V2FsGetMetadataParams = { readonly path: string };
export const V2FsGetMetadataParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({
  title: "FsGetMetadataParams",
  description: "Request metadata for an absolute path.",
});

export type V2FsGetMetadataParams__AbsolutePathBuf = string;
export const V2FsGetMetadataParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsGetMetadataResponse = {
  readonly createdAtMs: number;
  readonly isDirectory: boolean;
  readonly isFile: boolean;
  readonly isSymlink: boolean;
  readonly modifiedAtMs: number;
};
export const V2FsGetMetadataResponse = Schema.Struct({
  createdAtMs: Schema.Number.annotate({
    description: "File creation time in Unix milliseconds when available, otherwise `0`.",
    format: "int64",
  }).check(Schema.isInt()),
  isDirectory: Schema.Boolean.annotate({
    description: "Whether the path resolves to a directory.",
  }),
  isFile: Schema.Boolean.annotate({ description: "Whether the path resolves to a regular file." }),
  isSymlink: Schema.Boolean.annotate({
    description: "Whether the path itself is a symbolic link.",
  }),
  modifiedAtMs: Schema.Number.annotate({
    description: "File modification time in Unix milliseconds when available, otherwise `0`.",
    format: "int64",
  }).check(Schema.isInt()),
}).annotate({
  title: "FsGetMetadataResponse",
  description: "Metadata returned by `fs/getMetadata`.",
});

export type V2FsReadDirectoryParams = { readonly path: string };
export const V2FsReadDirectoryParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({
  title: "FsReadDirectoryParams",
  description: "List direct child names for a directory.",
});

export type V2FsReadDirectoryParams__AbsolutePathBuf = string;
export const V2FsReadDirectoryParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsReadDirectoryResponse = {
  readonly entries: ReadonlyArray<V2FsReadDirectoryResponse__FsReadDirectoryEntry>;
};
export const V2FsReadDirectoryResponse = Schema.Struct({
  entries: Schema.Array(V2FsReadDirectoryResponse__FsReadDirectoryEntry).annotate({
    description: "Direct child entries in the requested directory.",
  }),
}).annotate({
  title: "FsReadDirectoryResponse",
  description: "Directory entries returned by `fs/readDirectory`.",
});

export type V2FsReadFileParams = { readonly path: string };
export const V2FsReadFileParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({ title: "FsReadFileParams", description: "Read a file from the host filesystem." });

export type V2FsReadFileParams__AbsolutePathBuf = string;
export const V2FsReadFileParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsReadFileResponse = { readonly dataBase64: string };
export const V2FsReadFileResponse = Schema.Struct({
  dataBase64: Schema.String.annotate({ description: "File contents encoded as base64." }),
}).annotate({
  title: "FsReadFileResponse",
  description: "Base64-encoded file contents returned by `fs/readFile`.",
});

export type V2FsRemoveParams = {
  readonly force?: boolean | null;
  readonly path: string;
  readonly recursive?: boolean | null;
};
export const V2FsRemoveParams = Schema.Struct({
  force: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description: "Whether missing paths should be ignored. Defaults to `true`.",
      }),
      Schema.Null,
    ]),
  ),
  path: Schema.String.annotate({
    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.",
  }),
  recursive: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description: "Whether directory removal should recurse. Defaults to `true`.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({
  title: "FsRemoveParams",
  description: "Remove a file or directory tree from the host filesystem.",
});

export type V2FsRemoveParams__AbsolutePathBuf = string;
export const V2FsRemoveParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsRemoveResponse = {};
export const V2FsRemoveResponse = Schema.Struct({}).annotate({
  title: "FsRemoveResponse",
  description: "Successful response for `fs/remove`.",
});

export type V2FsUnwatchParams = { readonly watchId: string };
export const V2FsUnwatchParams = Schema.Struct({
  watchId: Schema.String.annotate({
    description: "Watch identifier previously provided to `fs/watch`.",
  }),
}).annotate({
  title: "FsUnwatchParams",
  description: "Stop filesystem watch notifications for a prior `fs/watch`.",
});

export type V2FsUnwatchResponse = {};
export const V2FsUnwatchResponse = Schema.Struct({}).annotate({
  title: "FsUnwatchResponse",
  description: "Successful response for `fs/unwatch`.",
});

export type V2FsWatchParams = { readonly path: string; readonly watchId: string };
export const V2FsWatchParams = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
  watchId: Schema.String.annotate({
    description: "Connection-scoped watch identifier used for `fs/unwatch` and `fs/changed`.",
  }),
}).annotate({
  title: "FsWatchParams",
  description: "Start filesystem watch notifications for an absolute path.",
});

export type V2FsWatchParams__AbsolutePathBuf = string;
export const V2FsWatchParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsWatchResponse = { readonly path: string };
export const V2FsWatchResponse = Schema.Struct({
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({ title: "FsWatchResponse", description: "Successful response for `fs/watch`." });

export type V2FsWatchResponse__AbsolutePathBuf = string;
export const V2FsWatchResponse__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsWriteFileParams = { readonly dataBase64: string; readonly path: string };
export const V2FsWriteFileParams = Schema.Struct({
  dataBase64: Schema.String.annotate({ description: "File contents encoded as base64." }),
  path: Schema.String.annotate({
    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.",
  }),
}).annotate({ title: "FsWriteFileParams", description: "Write a file on the host filesystem." });

export type V2FsWriteFileParams__AbsolutePathBuf = string;
export const V2FsWriteFileParams__AbsolutePathBuf = Schema.String.annotate({
  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.",
});

export type V2FsWriteFileResponse = {};
export const V2FsWriteFileResponse = Schema.Struct({}).annotate({
  title: "FsWriteFileResponse",
  description: "Successful response for `fs/writeFile`.",
});

export type V2GetAccountParams = { readonly refreshToken?: boolean };
export const V2GetAccountParams = Schema.Struct({
  refreshToken: Schema.optionalKey(
    Schema.Boolean.annotate({
      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`.",
      default: false,
    }),
  ),
}).annotate({ title: "GetAccountParams" });

export type V2GetAccountRateLimitsResponse = {
  readonly rateLimits: {
    readonly credits?: V2GetAccountRateLimitsResponse__CreditsSnapshot | null;
    readonly limitId?: string | null;
    readonly limitName?: string | null;
    readonly planType?: V2GetAccountRateLimitsResponse__PlanType | null;
    readonly primary?: V2GetAccountRateLimitsResponse__RateLimitWindow | null;
    readonly rateLimitReachedType?: V2GetAccountRateLimitsResponse__RateLimitReachedType | null;
    readonly secondary?: V2GetAccountRateLimitsResponse__RateLimitWindow | null;
  };
  readonly rateLimitsByLimitId?: {
    readonly [x: string]: V2GetAccountRateLimitsResponse__RateLimitSnapshot;
  } | null;
};
export const V2GetAccountRateLimitsResponse = Schema.Struct({
  rateLimits: Schema.Struct({
    credits: Schema.optionalKey(
      Schema.Union([V2GetAccountRateLimitsResponse__CreditsSnapshot, Schema.Null]),
    ),
    limitId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    limitName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
    planType: Schema.optionalKey(
      Schema.Union([V2GetAccountRateLimitsResponse__PlanType, Schema.Null]),
    ),
    primary: Schema.optionalKey(
      Schema.Union([V2GetAccountRateLimitsResponse__RateLimitWindow, Schema.Null]),
    ),
    rateLimitReachedType: Schema.optionalKey(
      Schema.Union([V2GetAccountRateLimitsResponse__RateLimitReachedType, Schema.Null]),
    ),
    secondary: Schema.optionalKey(
      Schema.Union([V2GetAccountRateLimitsResponse__RateLimitWindow, Schema.Null]),
    ),
  }).annotate({
    description: "Backward-compatible single-bucket view; mirrors the historical payload.",
  }),
  rateLimitsByLimitId: Schema.optionalKey(
    Schema.Union([
      Schema.Record(Schema.String, V2GetAccountRateLimitsResponse__RateLimitSnapshot).annotate({
        description: "Multi-bucket view keyed by metered `limit_id` (for example, `codex`).",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "GetAccountRateLimitsResponse" });

export type V2GetAccountResponse = {
  readonly account?: V2GetAccountResponse__Account | null;
  readonly requiresOpenaiAuth: boolean;
};
export const V2GetAccountResponse = Schema.Struct({
  account: Schema.optionalKey(Schema.Union([V2GetAccountResponse__Account, Schema.Null])),
  requiresOpenaiAuth: Schema.Boolean,
}).annotate({ title: "GetAccountResponse" });

export type V2GuardianWarningNotification = { readonly message: string; readonly threadId: string };
export const V2GuardianWarningNotification = Schema.Struct({
  message: Schema.String.annotate({
    description: "Concise guardian warning message for the user.",
  }),
  threadId: Schema.String.annotate({ description: "Thread target for the guardian warning." }),
}).annotate({ title: "GuardianWarningNotification" });

export type V2HookCompletedNotification = {
  readonly run: V2HookCompletedNotification__HookRunSummary;
  readonly threadId: string;
  readonly turnId?: string | null;
};
export const V2HookCompletedNotification = Schema.Struct({
  run: V2HookCompletedNotification__HookRunSummary,
  threadId: Schema.String,
  turnId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "HookCompletedNotification" });

export type V2HookCompletedNotification__HookSource =
  | "system"
  | "user"
  | "project"
  | "mdm"
  | "sessionFlags"
  | "plugin"
  | "cloudRequirements"
  | "legacyManagedConfigFile"
  | "legacyManagedConfigMdm"
  | "unknown";
export const V2HookCompletedNotification__HookSource = Schema.Literals([
  "system",
  "user",
  "project",
  "mdm",
  "sessionFlags",
  "plugin",
  "cloudRequirements",
  "legacyManagedConfigFile",
  "legacyManagedConfigMdm",
  "unknown",
]);

export type V2HooksListParams = { readonly cwds?: ReadonlyArray<string> };
export const V2HooksListParams = Schema.Struct({
  cwds: Schema.optionalKey(
    Schema.Array(Schema.String).annotate({
      description: "When empty, defaults to the current session working directory.",
    }),
  ),
}).annotate({ title: "HooksListParams" });

export type V2HooksListResponse = {
  readonly data: ReadonlyArray<V2HooksListResponse__HooksListEntry>;
};
export const V2HooksListResponse = Schema.Struct({
  data: Schema.Array(V2HooksListResponse__HooksListEntry),
}).annotate({ title: "HooksListResponse" });

export type V2HookStartedNotification = {
  readonly run: V2HookStartedNotification__HookRunSummary;
  readonly threadId: string;
  readonly turnId?: string | null;
};
export const V2HookStartedNotification = Schema.Struct({
  run: V2HookStartedNotification__HookRunSummary,
  threadId: Schema.String,
  turnId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "HookStartedNotification" });

export type V2HookStartedNotification__HookSource =
  | "system"
  | "user"
  | "project"
  | "mdm"
  | "sessionFlags"
  | "plugin"
  | "cloudRequirements"
  | "legacyManagedConfigFile"
  | "legacyManagedConfigMdm"
  | "unknown";
export const V2HookStartedNotification__HookSource = Schema.Literals([
  "system",
  "user",
  "project",
  "mdm",
  "sessionFlags",
  "plugin",
  "cloudRequirements",
  "legacyManagedConfigFile",
  "legacyManagedConfigMdm",
  "unknown",
]);

export type V2ItemCompletedNotification = {
  readonly completedAtMs: number;
  readonly item: V2ItemCompletedNotification__ThreadItem;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2ItemCompletedNotification = Schema.Struct({
  completedAtMs: Schema.Number.annotate({
    description: "Unix timestamp (in milliseconds) when this item lifecycle completed.",
    format: "int64",
  }).check(Schema.isInt()),
  item: V2ItemCompletedNotification__ThreadItem,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "ItemCompletedNotification" });

export type V2ItemCompletedNotification__ByteRange = {
  readonly end: number;
  readonly start: number;
};
export const V2ItemCompletedNotification__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ItemCompletedNotification__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ItemCompletedNotification__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ItemCompletedNotification__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ItemCompletedNotification__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ItemCompletedNotification__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ItemCompletedNotification__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ItemGuardianApprovalReviewCompletedNotification = {
  readonly action: V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReviewAction;
  readonly decisionSource: V2ItemGuardianApprovalReviewCompletedNotification__AutoReviewDecisionSource;
  readonly review: V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReview;
  readonly reviewId: string;
  readonly targetItemId?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2ItemGuardianApprovalReviewCompletedNotification = Schema.Struct({
  action: V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReviewAction,
  decisionSource: V2ItemGuardianApprovalReviewCompletedNotification__AutoReviewDecisionSource,
  review: V2ItemGuardianApprovalReviewCompletedNotification__GuardianApprovalReview,
  reviewId: Schema.String.annotate({ description: "Stable identifier for this review." }),
  targetItemId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  title: "ItemGuardianApprovalReviewCompletedNotification",
  description:
    "[UNSTABLE] Temporary notification payload for approval auto-review. This shape is expected to change soon.",
});

export type V2ItemGuardianApprovalReviewStartedNotification = {
  readonly action: V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReviewAction;
  readonly review: V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReview;
  readonly reviewId: string;
  readonly targetItemId?: string | null;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2ItemGuardianApprovalReviewStartedNotification = Schema.Struct({
  action: V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReviewAction,
  review: V2ItemGuardianApprovalReviewStartedNotification__GuardianApprovalReview,
  reviewId: Schema.String.annotate({ description: "Stable identifier for this review." }),
  targetItemId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  title: "ItemGuardianApprovalReviewStartedNotification",
  description:
    "[UNSTABLE] Temporary notification payload for approval auto-review. This shape is expected to change soon.",
});

export type V2ItemStartedNotification = {
  readonly item: V2ItemStartedNotification__ThreadItem;
  readonly startedAtMs: number;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2ItemStartedNotification = Schema.Struct({
  item: V2ItemStartedNotification__ThreadItem,
  startedAtMs: Schema.Number.annotate({
    description: "Unix timestamp (in milliseconds) when this item lifecycle started.",
    format: "int64",
  }).check(Schema.isInt()),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "ItemStartedNotification" });

export type V2ItemStartedNotification__ByteRange = { readonly end: number; readonly start: number };
export const V2ItemStartedNotification__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ItemStartedNotification__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ItemStartedNotification__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ItemStartedNotification__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ItemStartedNotification__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ItemStartedNotification__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ItemStartedNotification__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ListMcpServerStatusParams = {
  readonly cursor?: string | null;
  readonly detail?: V2ListMcpServerStatusParams__McpServerStatusDetail | null;
  readonly limit?: number | null;
};
export const V2ListMcpServerStatusParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  detail: Schema.optionalKey(
    Schema.Union([V2ListMcpServerStatusParams__McpServerStatusDetail, Schema.Null]).annotate({
      description:
        "Controls how much MCP inventory data to fetch for each server. Defaults to `Full` when omitted.",
    }),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a server-defined value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ListMcpServerStatusParams" });

export type V2ListMcpServerStatusResponse = {
  readonly data: ReadonlyArray<V2ListMcpServerStatusResponse__McpServerStatus>;
  readonly nextCursor?: string | null;
};
export const V2ListMcpServerStatusResponse = Schema.Struct({
  data: Schema.Array(V2ListMcpServerStatusResponse__McpServerStatus),
  nextCursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ListMcpServerStatusResponse" });

export type V2LoginAccountParams =
  | { readonly apiKey: string; readonly type: "apiKey" }
  | { readonly codexStreamlinedLogin?: boolean; readonly type: "chatgpt" }
  | { readonly type: "chatgptDeviceCode" }
  | {
      readonly accessToken: string;
      readonly chatgptAccountId: string;
      readonly chatgptPlanType?: string | null;
      readonly type: "chatgptAuthTokens";
    };
export const V2LoginAccountParams = Schema.Union(
  [
    Schema.Struct({
      apiKey: Schema.String,
      type: Schema.Literal("apiKey").annotate({ title: "ApiKeyv2::LoginAccountParamsType" }),
    }).annotate({ title: "ApiKeyv2::LoginAccountParams" }),
    Schema.Struct({
      codexStreamlinedLogin: Schema.optionalKey(Schema.Boolean),
      type: Schema.Literal("chatgpt").annotate({ title: "Chatgptv2::LoginAccountParamsType" }),
    }).annotate({ title: "Chatgptv2::LoginAccountParams" }),
    Schema.Struct({
      type: Schema.Literal("chatgptDeviceCode").annotate({
        title: "ChatgptDeviceCodev2::LoginAccountParamsType",
      }),
    }).annotate({ title: "ChatgptDeviceCodev2::LoginAccountParams" }),
    Schema.Struct({
      accessToken: Schema.String.annotate({
        description:
          "Access token (JWT) supplied by the client. This token is used for backend API requests and email extraction.",
      }),
      chatgptAccountId: Schema.String.annotate({
        description: "Workspace/account identifier supplied by the client.",
      }),
      chatgptPlanType: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            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`.",
          }),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("chatgptAuthTokens").annotate({
        title: "ChatgptAuthTokensv2::LoginAccountParamsType",
      }),
    }).annotate({
      title: "ChatgptAuthTokensv2::LoginAccountParams",
      description:
        "[UNSTABLE] FOR OPENAI INTERNAL USE ONLY - DO NOT USE. The access token must contain the same scopes that Codex-managed ChatGPT auth tokens have.",
    }),
  ],
  { mode: "oneOf" },
).annotate({ title: "LoginAccountParams" });

export type V2LoginAccountResponse =
  | { readonly type: "apiKey" }
  | { readonly authUrl: string; readonly loginId: string; readonly type: "chatgpt" }
  | {
      readonly loginId: string;
      readonly type: "chatgptDeviceCode";
      readonly userCode: string;
      readonly verificationUrl: string;
    }
  | { readonly type: "chatgptAuthTokens" };
export const V2LoginAccountResponse = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("apiKey").annotate({ title: "ApiKeyv2::LoginAccountResponseType" }),
    }).annotate({ title: "ApiKeyv2::LoginAccountResponse" }),
    Schema.Struct({
      authUrl: Schema.String.annotate({
        description: "URL the client should open in a browser to initiate the OAuth flow.",
      }),
      loginId: Schema.String,
      type: Schema.Literal("chatgpt").annotate({ title: "Chatgptv2::LoginAccountResponseType" }),
    }).annotate({ title: "Chatgptv2::LoginAccountResponse" }),
    Schema.Struct({
      loginId: Schema.String,
      type: Schema.Literal("chatgptDeviceCode").annotate({
        title: "ChatgptDeviceCodev2::LoginAccountResponseType",
      }),
      userCode: Schema.String.annotate({
        description: "One-time code the user must enter after signing in.",
      }),
      verificationUrl: Schema.String.annotate({
        description:
          "URL the client should open in a browser to complete device code authorization.",
      }),
    }).annotate({ title: "ChatgptDeviceCodev2::LoginAccountResponse" }),
    Schema.Struct({
      type: Schema.Literal("chatgptAuthTokens").annotate({
        title: "ChatgptAuthTokensv2::LoginAccountResponseType",
      }),
    }).annotate({ title: "ChatgptAuthTokensv2::LoginAccountResponse" }),
  ],
  { mode: "oneOf" },
).annotate({ title: "LoginAccountResponse" });

export type V2LogoutAccountResponse = {};
export const V2LogoutAccountResponse = Schema.Struct({}).annotate({
  title: "LogoutAccountResponse",
});

export type V2MarketplaceAddParams = {
  readonly refName?: string | null;
  readonly source: string;
  readonly sparsePaths?: ReadonlyArray<string> | null;
};
export const V2MarketplaceAddParams = Schema.Struct({
  refName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  source: Schema.String,
  sparsePaths: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
}).annotate({ title: "MarketplaceAddParams" });

export type V2MarketplaceAddResponse = {
  readonly alreadyAdded: boolean;
  readonly installedRoot: V2MarketplaceAddResponse__AbsolutePathBuf;
  readonly marketplaceName: string;
};
export const V2MarketplaceAddResponse = Schema.Struct({
  alreadyAdded: Schema.Boolean,
  installedRoot: V2MarketplaceAddResponse__AbsolutePathBuf,
  marketplaceName: Schema.String,
}).annotate({ title: "MarketplaceAddResponse" });

export type V2MarketplaceRemoveParams = { readonly marketplaceName: string };
export const V2MarketplaceRemoveParams = Schema.Struct({ marketplaceName: Schema.String }).annotate(
  { title: "MarketplaceRemoveParams" },
);

export type V2MarketplaceRemoveResponse = {
  readonly installedRoot?: V2MarketplaceRemoveResponse__AbsolutePathBuf | null;
  readonly marketplaceName: string;
};
export const V2MarketplaceRemoveResponse = Schema.Struct({
  installedRoot: Schema.optionalKey(
    Schema.Union([V2MarketplaceRemoveResponse__AbsolutePathBuf, Schema.Null]),
  ),
  marketplaceName: Schema.String,
}).annotate({ title: "MarketplaceRemoveResponse" });

export type V2MarketplaceUpgradeParams = { readonly marketplaceName?: string | null };
export const V2MarketplaceUpgradeParams = Schema.Struct({
  marketplaceName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "MarketplaceUpgradeParams" });

export type V2MarketplaceUpgradeResponse = {
  readonly errors: ReadonlyArray<V2MarketplaceUpgradeResponse__MarketplaceUpgradeErrorInfo>;
  readonly selectedMarketplaces: ReadonlyArray<string>;
  readonly upgradedRoots: ReadonlyArray<V2MarketplaceUpgradeResponse__AbsolutePathBuf>;
};
export const V2MarketplaceUpgradeResponse = Schema.Struct({
  errors: Schema.Array(V2MarketplaceUpgradeResponse__MarketplaceUpgradeErrorInfo),
  selectedMarketplaces: Schema.Array(Schema.String),
  upgradedRoots: Schema.Array(V2MarketplaceUpgradeResponse__AbsolutePathBuf),
}).annotate({ title: "MarketplaceUpgradeResponse" });

export type V2McpResourceReadParams = {
  readonly server: string;
  readonly threadId?: string | null;
  readonly uri: string;
};
export const V2McpResourceReadParams = Schema.Struct({
  server: Schema.String,
  threadId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  uri: Schema.String,
}).annotate({ title: "McpResourceReadParams" });

export type V2McpResourceReadResponse = {
  readonly contents: ReadonlyArray<V2McpResourceReadResponse__ResourceContent>;
};
export const V2McpResourceReadResponse = Schema.Struct({
  contents: Schema.Array(V2McpResourceReadResponse__ResourceContent),
}).annotate({ title: "McpResourceReadResponse" });

export type V2McpServerOauthLoginCompletedNotification = {
  readonly error?: string | null;
  readonly name: string;
  readonly success: boolean;
};
export const V2McpServerOauthLoginCompletedNotification = Schema.Struct({
  error: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  success: Schema.Boolean,
}).annotate({ title: "McpServerOauthLoginCompletedNotification" });

export type V2McpServerOauthLoginParams = {
  readonly name: string;
  readonly scopes?: ReadonlyArray<string> | null;
  readonly timeoutSecs?: number | null;
};
export const V2McpServerOauthLoginParams = Schema.Struct({
  name: Schema.String,
  scopes: Schema.optionalKey(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
  timeoutSecs: Schema.optionalKey(
    Schema.Union([Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()), Schema.Null]),
  ),
}).annotate({ title: "McpServerOauthLoginParams" });

export type V2McpServerOauthLoginResponse = { readonly authorizationUrl: string };
export const V2McpServerOauthLoginResponse = Schema.Struct({
  authorizationUrl: Schema.String,
}).annotate({ title: "McpServerOauthLoginResponse" });

export type V2McpServerRefreshResponse = {};
export const V2McpServerRefreshResponse = Schema.Struct({}).annotate({
  title: "McpServerRefreshResponse",
});

export type V2McpServerStatusUpdatedNotification = {
  readonly error?: string | null;
  readonly name: string;
  readonly status: V2McpServerStatusUpdatedNotification__McpServerStartupState;
};
export const V2McpServerStatusUpdatedNotification = Schema.Struct({
  error: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  name: Schema.String,
  status: V2McpServerStatusUpdatedNotification__McpServerStartupState,
}).annotate({ title: "McpServerStatusUpdatedNotification" });

export type V2McpServerToolCallParams = {
  readonly _meta?: unknown;
  readonly arguments?: unknown;
  readonly server: string;
  readonly threadId: string;
  readonly tool: string;
};
export const V2McpServerToolCallParams = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  arguments: Schema.optionalKey(Schema.Unknown),
  server: Schema.String,
  threadId: Schema.String,
  tool: Schema.String,
}).annotate({ title: "McpServerToolCallParams" });

export type V2McpServerToolCallResponse = {
  readonly _meta?: unknown;
  readonly content: ReadonlyArray<unknown>;
  readonly isError?: boolean | null;
  readonly structuredContent?: unknown;
};
export const V2McpServerToolCallResponse = Schema.Struct({
  _meta: Schema.optionalKey(Schema.Unknown),
  content: Schema.Array(Schema.Unknown),
  isError: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  structuredContent: Schema.optionalKey(Schema.Unknown),
}).annotate({ title: "McpServerToolCallResponse" });

export type V2McpToolCallProgressNotification = {
  readonly itemId: string;
  readonly message: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2McpToolCallProgressNotification = Schema.Struct({
  itemId: Schema.String,
  message: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "McpToolCallProgressNotification" });

export type V2ModelListParams = {
  readonly cursor?: string | null;
  readonly includeHidden?: boolean | null;
  readonly limit?: number | null;
};
export const V2ModelListParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  includeHidden: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description: "When true, include models that are hidden from the default picker list.",
      }),
      Schema.Null,
    ]),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a reasonable server-side value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ModelListParams" });

export type V2ModelListResponse = {
  readonly data: ReadonlyArray<V2ModelListResponse__Model>;
  readonly nextCursor?: string | null;
};
export const V2ModelListResponse = Schema.Struct({
  data: Schema.Array(V2ModelListResponse__Model),
  nextCursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ModelListResponse" });

export type V2ModelProviderCapabilitiesReadParams = {};
export const V2ModelProviderCapabilitiesReadParams = Schema.Struct({}).annotate({
  title: "ModelProviderCapabilitiesReadParams",
});

export type V2ModelProviderCapabilitiesReadResponse = {
  readonly imageGeneration: boolean;
  readonly namespaceTools: boolean;
  readonly webSearch: boolean;
};
export const V2ModelProviderCapabilitiesReadResponse = Schema.Struct({
  imageGeneration: Schema.Boolean,
  namespaceTools: Schema.Boolean,
  webSearch: Schema.Boolean,
}).annotate({ title: "ModelProviderCapabilitiesReadResponse" });

export type V2ModelReroutedNotification = {
  readonly fromModel: string;
  readonly reason: V2ModelReroutedNotification__ModelRerouteReason;
  readonly threadId: string;
  readonly toModel: string;
  readonly turnId: string;
};
export const V2ModelReroutedNotification = Schema.Struct({
  fromModel: Schema.String,
  reason: V2ModelReroutedNotification__ModelRerouteReason,
  threadId: Schema.String,
  toModel: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "ModelReroutedNotification" });

export type V2ModelVerificationNotification = {
  readonly threadId: string;
  readonly turnId: string;
  readonly verifications: ReadonlyArray<V2ModelVerificationNotification__ModelVerification>;
};
export const V2ModelVerificationNotification = Schema.Struct({
  threadId: Schema.String,
  turnId: Schema.String,
  verifications: Schema.Array(V2ModelVerificationNotification__ModelVerification),
}).annotate({ title: "ModelVerificationNotification" });

export type V2PlanDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2PlanDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  title: "PlanDeltaNotification",
  description:
    "EXPERIMENTAL - proposed plan streaming deltas for plan items. Clients should not assume concatenated deltas match the completed plan item content.",
});

export type V2PluginInstallParams = {
  readonly marketplacePath?: V2PluginInstallParams__AbsolutePathBuf | null;
  readonly pluginName: string;
  readonly remoteMarketplaceName?: string | null;
};
export const V2PluginInstallParams = Schema.Struct({
  marketplacePath: Schema.optionalKey(
    Schema.Union([V2PluginInstallParams__AbsolutePathBuf, Schema.Null]),
  ),
  pluginName: Schema.String,
  remoteMarketplaceName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "PluginInstallParams" });

export type V2PluginInstallResponse = {
  readonly appsNeedingAuth: ReadonlyArray<V2PluginInstallResponse__AppSummary>;
  readonly authPolicy: V2PluginInstallResponse__PluginAuthPolicy;
};
export const V2PluginInstallResponse = Schema.Struct({
  appsNeedingAuth: Schema.Array(V2PluginInstallResponse__AppSummary),
  authPolicy: V2PluginInstallResponse__PluginAuthPolicy,
}).annotate({ title: "PluginInstallResponse" });

export type V2PluginListParams = {
  readonly cwds?: ReadonlyArray<V2PluginListParams__AbsolutePathBuf> | null;
  readonly marketplaceKinds?: ReadonlyArray<V2PluginListParams__PluginListMarketplaceKind> | null;
};
export const V2PluginListParams = Schema.Struct({
  cwds: Schema.optionalKey(
    Schema.Union([
      Schema.Array(V2PluginListParams__AbsolutePathBuf).annotate({
        description:
          "Optional working directories used to discover repo marketplaces. When omitted, only home-scoped marketplaces and the official curated marketplace are considered.",
      }),
      Schema.Null,
    ]),
  ),
  marketplaceKinds: Schema.optionalKey(
    Schema.Union([
      Schema.Array(V2PluginListParams__PluginListMarketplaceKind).annotate({
        description:
          "Optional marketplace kind filter. When omitted, only local marketplaces are queried, plus the default remote catalog when enabled by feature flag.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "PluginListParams" });

export type V2PluginListResponse = {
  readonly featuredPluginIds?: ReadonlyArray<string>;
  readonly marketplaceLoadErrors?: ReadonlyArray<V2PluginListResponse__MarketplaceLoadErrorInfo>;
  readonly marketplaces: ReadonlyArray<V2PluginListResponse__PluginMarketplaceEntry>;
};
export const V2PluginListResponse = Schema.Struct({
  featuredPluginIds: Schema.optionalKey(Schema.Array(Schema.String).annotate({ default: [] })),
  marketplaceLoadErrors: Schema.optionalKey(
    Schema.Array(V2PluginListResponse__MarketplaceLoadErrorInfo).annotate({ default: [] }),
  ),
  marketplaces: Schema.Array(V2PluginListResponse__PluginMarketplaceEntry),
}).annotate({ title: "PluginListResponse" });

export type V2PluginListResponse__PluginAvailability = "DISABLED_BY_ADMIN" | "AVAILABLE";
export const V2PluginListResponse__PluginAvailability = Schema.Literals([
  "DISABLED_BY_ADMIN",
  "AVAILABLE",
]);

export type V2PluginReadParams = {
  readonly marketplacePath?: V2PluginReadParams__AbsolutePathBuf | null;
  readonly pluginName: string;
  readonly remoteMarketplaceName?: string | null;
};
export const V2PluginReadParams = Schema.Struct({
  marketplacePath: Schema.optionalKey(
    Schema.Union([V2PluginReadParams__AbsolutePathBuf, Schema.Null]),
  ),
  pluginName: Schema.String,
  remoteMarketplaceName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "PluginReadParams" });

export type V2PluginReadResponse = { readonly plugin: V2PluginReadResponse__PluginDetail };
export const V2PluginReadResponse = Schema.Struct({
  plugin: V2PluginReadResponse__PluginDetail,
}).annotate({ title: "PluginReadResponse" });

export type V2PluginReadResponse__PluginAvailability = "DISABLED_BY_ADMIN" | "AVAILABLE";
export const V2PluginReadResponse__PluginAvailability = Schema.Literals([
  "DISABLED_BY_ADMIN",
  "AVAILABLE",
]);

export type V2PluginShareDeleteParams = { readonly remotePluginId: string };
export const V2PluginShareDeleteParams = Schema.Struct({ remotePluginId: Schema.String }).annotate({
  title: "PluginShareDeleteParams",
});

export type V2PluginShareDeleteResponse = {};
export const V2PluginShareDeleteResponse = Schema.Struct({}).annotate({
  title: "PluginShareDeleteResponse",
});

export type V2PluginShareListParams = {};
export const V2PluginShareListParams = Schema.Struct({}).annotate({
  title: "PluginShareListParams",
});

export type V2PluginShareListResponse = {
  readonly data: ReadonlyArray<V2PluginShareListResponse__PluginShareListItem>;
};
export const V2PluginShareListResponse = Schema.Struct({
  data: Schema.Array(V2PluginShareListResponse__PluginShareListItem),
}).annotate({ title: "PluginShareListResponse" });

export type V2PluginShareListResponse__PluginAvailability = "DISABLED_BY_ADMIN" | "AVAILABLE";
export const V2PluginShareListResponse__PluginAvailability = Schema.Literals([
  "DISABLED_BY_ADMIN",
  "AVAILABLE",
]);

export type V2PluginShareSaveParams = {
  readonly discoverability?: V2PluginShareSaveParams__PluginShareDiscoverability | null;
  readonly pluginPath: V2PluginShareSaveParams__AbsolutePathBuf;
  readonly remotePluginId?: string | null;
  readonly shareTargets?: ReadonlyArray<V2PluginShareSaveParams__PluginShareTarget> | null;
};
export const V2PluginShareSaveParams = Schema.Struct({
  discoverability: Schema.optionalKey(
    Schema.Union([V2PluginShareSaveParams__PluginShareDiscoverability, Schema.Null]),
  ),
  pluginPath: V2PluginShareSaveParams__AbsolutePathBuf,
  remotePluginId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  shareTargets: Schema.optionalKey(
    Schema.Union([Schema.Array(V2PluginShareSaveParams__PluginShareTarget), Schema.Null]),
  ),
}).annotate({ title: "PluginShareSaveParams" });

export type V2PluginShareSaveResponse = {
  readonly remotePluginId: string;
  readonly shareUrl: string;
};
export const V2PluginShareSaveResponse = Schema.Struct({
  remotePluginId: Schema.String,
  shareUrl: Schema.String,
}).annotate({ title: "PluginShareSaveResponse" });

export type V2PluginShareUpdateTargetsParams = {
  readonly remotePluginId: string;
  readonly shareTargets: ReadonlyArray<V2PluginShareUpdateTargetsParams__PluginShareTarget>;
};
export const V2PluginShareUpdateTargetsParams = Schema.Struct({
  remotePluginId: Schema.String,
  shareTargets: Schema.Array(V2PluginShareUpdateTargetsParams__PluginShareTarget),
}).annotate({ title: "PluginShareUpdateTargetsParams" });

export type V2PluginShareUpdateTargetsResponse = {
  readonly principals: ReadonlyArray<V2PluginShareUpdateTargetsResponse__PluginSharePrincipal>;
};
export const V2PluginShareUpdateTargetsResponse = Schema.Struct({
  principals: Schema.Array(V2PluginShareUpdateTargetsResponse__PluginSharePrincipal),
}).annotate({ title: "PluginShareUpdateTargetsResponse" });

export type V2PluginSkillReadParams = {
  readonly remoteMarketplaceName: string;
  readonly remotePluginId: string;
  readonly skillName: string;
};
export const V2PluginSkillReadParams = Schema.Struct({
  remoteMarketplaceName: Schema.String,
  remotePluginId: Schema.String,
  skillName: Schema.String,
}).annotate({ title: "PluginSkillReadParams" });

export type V2PluginSkillReadResponse = { readonly contents?: string | null };
export const V2PluginSkillReadResponse = Schema.Struct({
  contents: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "PluginSkillReadResponse" });

export type V2PluginUninstallParams = { readonly pluginId: string };
export const V2PluginUninstallParams = Schema.Struct({ pluginId: Schema.String }).annotate({
  title: "PluginUninstallParams",
});

export type V2PluginUninstallResponse = {};
export const V2PluginUninstallResponse = Schema.Struct({}).annotate({
  title: "PluginUninstallResponse",
});

export type V2ProcessExitedNotification = {
  readonly exitCode: number;
  readonly processHandle: string;
  readonly stderr: string;
  readonly stderrCapReached: boolean;
  readonly stdout: string;
  readonly stdoutCapReached: boolean;
};
export const V2ProcessExitedNotification = Schema.Struct({
  exitCode: Schema.Number.annotate({ description: "Process exit code.", format: "int32" }).check(
    Schema.isInt(),
  ),
  processHandle: Schema.String.annotate({
    description: "Client-supplied, connection-scoped `processHandle` from `process/spawn`.",
  }),
  stderr: Schema.String.annotate({
    description:
      "Buffered stderr capture.\n\nEmpty when stderr was streamed via `process/outputDelta`.",
  }),
  stderrCapReached: Schema.Boolean.annotate({
    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: Schema.String.annotate({
    description:
      "Buffered stdout capture.\n\nEmpty when stdout was streamed via `process/outputDelta`.",
  }),
  stdoutCapReached: Schema.Boolean.annotate({
    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.",
  }),
}).annotate({
  title: "ProcessExitedNotification",
  description: "Final process exit notification for `process/spawn`.",
});

export type V2ProcessOutputDeltaNotification = {
  readonly capReached: boolean;
  readonly deltaBase64: string;
  readonly processHandle: string;
  readonly stream: "stdout" | "stderr";
};
export const V2ProcessOutputDeltaNotification = Schema.Struct({
  capReached: Schema.Boolean.annotate({
    description:
      "True on the final streamed chunk for this stream when output was truncated by `outputBytesCap`.",
  }),
  deltaBase64: Schema.String.annotate({ description: "Base64-encoded output bytes." }),
  processHandle: Schema.String.annotate({
    description: "Client-supplied, connection-scoped `processHandle` from `process/spawn`.",
  }),
  stream: Schema.Literals(["stdout", "stderr"]).annotate({
    description: "Stream label for `process/outputDelta` notifications.",
  }),
}).annotate({
  title: "ProcessOutputDeltaNotification",
  description: "Base64-encoded output chunk emitted for a streaming `process/spawn` request.",
});

export type V2ProcessOutputDeltaNotification__ProcessOutputStream = "stdout" | "stderr";
export const V2ProcessOutputDeltaNotification__ProcessOutputStream = Schema.Literals([
  "stdout",
  "stderr",
]).annotate({ description: "Stream label for `process/outputDelta` notifications." });

export type V2RawResponseItemCompletedNotification = {
  readonly item: V2RawResponseItemCompletedNotification__ResponseItem;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2RawResponseItemCompletedNotification = Schema.Struct({
  item: V2RawResponseItemCompletedNotification__ResponseItem,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "RawResponseItemCompletedNotification" });

export type V2ReasoningSummaryPartAddedNotification = {
  readonly itemId: string;
  readonly summaryIndex: number;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2ReasoningSummaryPartAddedNotification = Schema.Struct({
  itemId: Schema.String,
  summaryIndex: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "ReasoningSummaryPartAddedNotification" });

export type V2ReasoningSummaryTextDeltaNotification = {
  readonly delta: string;
  readonly itemId: string;
  readonly summaryIndex: number;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2ReasoningSummaryTextDeltaNotification = Schema.Struct({
  delta: Schema.String,
  itemId: Schema.String,
  summaryIndex: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "ReasoningSummaryTextDeltaNotification" });

export type V2ReasoningTextDeltaNotification = {
  readonly contentIndex: number;
  readonly delta: string;
  readonly itemId: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2ReasoningTextDeltaNotification = Schema.Struct({
  contentIndex: Schema.Number.annotate({ format: "int64" }).check(Schema.isInt()),
  delta: Schema.String,
  itemId: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "ReasoningTextDeltaNotification" });

export type V2RemoteControlStatusChangedNotification = {
  readonly environmentId?: string | null;
  readonly status: V2RemoteControlStatusChangedNotification__RemoteControlConnectionStatus;
};
export const V2RemoteControlStatusChangedNotification = Schema.Struct({
  environmentId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  status: V2RemoteControlStatusChangedNotification__RemoteControlConnectionStatus,
}).annotate({
  title: "RemoteControlStatusChangedNotification",
  description: "Current remote-control connection status and environment id exposed to clients.",
});

export type V2ReviewStartParams = {
  readonly delivery?: V2ReviewStartParams__ReviewDelivery | null;
  readonly target: V2ReviewStartParams__ReviewTarget;
  readonly threadId: string;
};
export const V2ReviewStartParams = Schema.Struct({
  delivery: Schema.optionalKey(
    Schema.Union([V2ReviewStartParams__ReviewDelivery, Schema.Null]).annotate({
      description:
        "Where to run the review: inline (default) on the current thread or detached on a new thread (returned in `reviewThreadId`).",
    }),
  ),
  target: V2ReviewStartParams__ReviewTarget,
  threadId: Schema.String,
}).annotate({ title: "ReviewStartParams" });

export type V2ReviewStartResponse = {
  readonly reviewThreadId: string;
  readonly turn: V2ReviewStartResponse__Turn;
};
export const V2ReviewStartResponse = Schema.Struct({
  reviewThreadId: Schema.String.annotate({
    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: V2ReviewStartResponse__Turn,
}).annotate({ title: "ReviewStartResponse" });

export type V2ReviewStartResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2ReviewStartResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ReviewStartResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ReviewStartResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ReviewStartResponse__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ReviewStartResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ReviewStartResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ReviewStartResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ReviewStartResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ReviewStartResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2SendAddCreditsNudgeEmailParams = {
  readonly creditType: V2SendAddCreditsNudgeEmailParams__AddCreditsNudgeCreditType;
};
export const V2SendAddCreditsNudgeEmailParams = Schema.Struct({
  creditType: V2SendAddCreditsNudgeEmailParams__AddCreditsNudgeCreditType,
}).annotate({ title: "SendAddCreditsNudgeEmailParams" });

export type V2SendAddCreditsNudgeEmailResponse = {
  readonly status: V2SendAddCreditsNudgeEmailResponse__AddCreditsNudgeEmailStatus;
};
export const V2SendAddCreditsNudgeEmailResponse = Schema.Struct({
  status: V2SendAddCreditsNudgeEmailResponse__AddCreditsNudgeEmailStatus,
}).annotate({ title: "SendAddCreditsNudgeEmailResponse" });

export type V2ServerRequestResolvedNotification = {
  readonly requestId: V2ServerRequestResolvedNotification__RequestId;
  readonly threadId: string;
};
export const V2ServerRequestResolvedNotification = Schema.Struct({
  requestId: V2ServerRequestResolvedNotification__RequestId,
  threadId: Schema.String,
}).annotate({ title: "ServerRequestResolvedNotification" });

export type V2SkillsChangedNotification = {};
export const V2SkillsChangedNotification = Schema.Struct({}).annotate({
  title: "SkillsChangedNotification",
  description:
    "Notification emitted when watched local skill files change.\n\nTreat this as an invalidation signal and re-run `skills/list` with the client's current parameters when refreshed skill metadata is needed.",
});

export type V2SkillsConfigWriteParams = {
  readonly enabled: boolean;
  readonly name?: string | null;
  readonly path?: V2SkillsConfigWriteParams__AbsolutePathBuf | null;
};
export const V2SkillsConfigWriteParams = Schema.Struct({
  enabled: Schema.Boolean,
  name: Schema.optionalKey(
    Schema.Union([Schema.String.annotate({ description: "Name-based selector." }), Schema.Null]),
  ),
  path: Schema.optionalKey(
    Schema.Union([V2SkillsConfigWriteParams__AbsolutePathBuf, Schema.Null]).annotate({
      description: "Path-based selector.",
    }),
  ),
}).annotate({ title: "SkillsConfigWriteParams" });

export type V2SkillsConfigWriteResponse = { readonly effectiveEnabled: boolean };
export const V2SkillsConfigWriteResponse = Schema.Struct({
  effectiveEnabled: Schema.Boolean,
}).annotate({ title: "SkillsConfigWriteResponse" });

export type V2SkillsListParams = {
  readonly cwds?: ReadonlyArray<string>;
  readonly forceReload?: boolean;
  readonly perCwdExtraUserRoots?: ReadonlyArray<V2SkillsListParams__SkillsListExtraRootsForCwd> | null;
};
export const V2SkillsListParams = Schema.Struct({
  cwds: Schema.optionalKey(
    Schema.Array(Schema.String).annotate({
      description: "When empty, defaults to the current session working directory.",
    }),
  ),
  forceReload: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "When true, bypass the skills cache and re-scan skills from disk.",
    }),
  ),
  perCwdExtraUserRoots: Schema.optionalKey(
    Schema.Union([
      Schema.Array(V2SkillsListParams__SkillsListExtraRootsForCwd).annotate({
        description: "Optional per-cwd extra roots to scan as user-scoped skills.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "SkillsListParams" });

export type V2SkillsListResponse = {
  readonly data: ReadonlyArray<V2SkillsListResponse__SkillsListEntry>;
};
export const V2SkillsListResponse = Schema.Struct({
  data: Schema.Array(V2SkillsListResponse__SkillsListEntry),
}).annotate({ title: "SkillsListResponse" });

export type V2TerminalInteractionNotification = {
  readonly itemId: string;
  readonly processId: string;
  readonly stdin: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2TerminalInteractionNotification = Schema.Struct({
  itemId: Schema.String,
  processId: Schema.String,
  stdin: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "TerminalInteractionNotification" });

export type V2ThreadApproveGuardianDeniedActionParams = {
  readonly event: unknown;
  readonly threadId: string;
};
export const V2ThreadApproveGuardianDeniedActionParams = Schema.Struct({
  event: Schema.Unknown.annotate({
    description: "Serialized `codex_protocol::protocol::GuardianAssessmentEvent`.",
  }),
  threadId: Schema.String,
}).annotate({ title: "ThreadApproveGuardianDeniedActionParams" });

export type V2ThreadApproveGuardianDeniedActionResponse = {};
export const V2ThreadApproveGuardianDeniedActionResponse = Schema.Struct({}).annotate({
  title: "ThreadApproveGuardianDeniedActionResponse",
});

export type V2ThreadArchivedNotification = { readonly threadId: string };
export const V2ThreadArchivedNotification = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "ThreadArchivedNotification",
});

export type V2ThreadArchiveParams = { readonly threadId: string };
export const V2ThreadArchiveParams = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "ThreadArchiveParams",
});

export type V2ThreadArchiveResponse = {};
export const V2ThreadArchiveResponse = Schema.Struct({}).annotate({
  title: "ThreadArchiveResponse",
});

export type V2ThreadClosedNotification = { readonly threadId: string };
export const V2ThreadClosedNotification = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "ThreadClosedNotification",
});

export type V2ThreadCompactStartParams = { readonly threadId: string };
export const V2ThreadCompactStartParams = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "ThreadCompactStartParams",
});

export type V2ThreadCompactStartResponse = {};
export const V2ThreadCompactStartResponse = Schema.Struct({}).annotate({
  title: "ThreadCompactStartResponse",
});

export type V2ThreadForkParams = {
  readonly approvalPolicy?: V2ThreadForkParams__AskForApproval | null;
  readonly approvalsReviewer?: V2ThreadForkParams__ApprovalsReviewer | null;
  readonly baseInstructions?: string | null;
  readonly config?: { readonly [x: string]: unknown } | null;
  readonly cwd?: string | null;
  readonly developerInstructions?: string | null;
  readonly ephemeral?: boolean;
  readonly model?: string | null;
  readonly modelProvider?: string | null;
  readonly sandbox?: V2ThreadForkParams__SandboxMode | null;
  readonly serviceTier?: string | null;
  readonly threadId: string;
  readonly threadSource?: V2ThreadForkParams__ThreadSource | null;
};
export const V2ThreadForkParams = Schema.Struct({
  approvalPolicy: Schema.optionalKey(
    Schema.Union([V2ThreadForkParams__AskForApproval, Schema.Null]),
  ),
  approvalsReviewer: Schema.optionalKey(
    Schema.Union([V2ThreadForkParams__ApprovalsReviewer, Schema.Null]).annotate({
      description:
        "Override where approval requests are routed for review on this thread and subsequent turns.",
    }),
  ),
  baseInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  config: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.Unknown), Schema.Null]),
  ),
  cwd: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developerInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  ephemeral: Schema.optionalKey(Schema.Boolean),
  model: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Configuration overrides for the forked thread, if any.",
      }),
      Schema.Null,
    ]),
  ),
  modelProvider: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sandbox: Schema.optionalKey(Schema.Union([V2ThreadForkParams__SandboxMode, Schema.Null])),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadForkParams__ThreadSource, Schema.Null]).annotate({
      description:
        "Optional client-supplied analytics source classification for this forked thread.",
    }),
  ),
}).annotate({
  title: "ThreadForkParams",
  description:
    "There are two ways to fork a thread: 1. By thread_id: load the thread from disk by thread_id and fork it into a new thread. 2. By path: load the thread from disk by path and fork it into a new thread.\n\nIf using path, the thread_id param will be ignored.\n\nPrefer using thread_id whenever possible.",
});

export type V2ThreadForkParams__PermissionProfileSelectionParams = {
  readonly id: string;
  readonly modifications?: ReadonlyArray<V2ThreadForkParams__PermissionProfileModificationParams> | null;
  readonly type: "profile";
};
export const V2ThreadForkParams__PermissionProfileSelectionParams = Schema.Union(
  [
    Schema.Struct({
      id: Schema.String,
      modifications: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadForkParams__PermissionProfileModificationParams),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("profile").annotate({
        title: "ProfilePermissionProfileSelectionParamsType",
      }),
    }).annotate({
      title: "ProfilePermissionProfileSelectionParams",
      description:
        "Select a named built-in or user-defined profile and optionally apply bounded modifications that Codex knows how to validate.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse = {
  readonly approvalPolicy: V2ThreadForkResponse__AskForApproval;
  readonly approvalsReviewer: "user" | "auto_review" | "guardian_subagent";
  readonly cwd: V2ThreadForkResponse__AbsolutePathBuf;
  readonly instructionSources?: ReadonlyArray<V2ThreadForkResponse__AbsolutePathBuf>;
  readonly model: string;
  readonly modelProvider: string;
  readonly reasoningEffort?: V2ThreadForkResponse__ReasoningEffort | null;
  readonly sandbox:
    | { readonly type: "dangerFullAccess" }
    | { readonly networkAccess?: boolean; readonly type: "readOnly" }
    | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
    | {
        readonly excludeSlashTmp?: boolean;
        readonly excludeTmpdirEnvVar?: boolean;
        readonly networkAccess?: boolean;
        readonly type: "workspaceWrite";
        readonly writableRoots?: ReadonlyArray<V2ThreadForkResponse__AbsolutePathBuf>;
      };
  readonly serviceTier?: string | null;
  readonly thread: V2ThreadForkResponse__Thread;
};
export const V2ThreadForkResponse = Schema.Struct({
  approvalPolicy: V2ThreadForkResponse__AskForApproval,
  approvalsReviewer: Schema.Literals(["user", "auto_review", "guardian_subagent"]).annotate({
    description:
      "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
  }),
  cwd: V2ThreadForkResponse__AbsolutePathBuf,
  instructionSources: Schema.optionalKey(
    Schema.Array(V2ThreadForkResponse__AbsolutePathBuf).annotate({
      description: "Instruction source files currently loaded for this thread.",
      default: [],
    }),
  ),
  model: Schema.String,
  modelProvider: Schema.String,
  reasoningEffort: Schema.optionalKey(
    Schema.Union([V2ThreadForkResponse__ReasoningEffort, Schema.Null]),
  ),
  sandbox: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("dangerFullAccess").annotate({
          title: "DangerFullAccessSandboxPolicyType",
        }),
      }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
      Schema.Struct({
        networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
      }).annotate({ title: "ReadOnlySandboxPolicy" }),
      Schema.Struct({
        networkAccess: Schema.optionalKey(
          Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
        ),
        type: Schema.Literal("externalSandbox").annotate({
          title: "ExternalSandboxSandboxPolicyType",
        }),
      }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
      Schema.Struct({
        excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        type: Schema.Literal("workspaceWrite").annotate({
          title: "WorkspaceWriteSandboxPolicyType",
        }),
        writableRoots: Schema.optionalKey(
          Schema.Array(V2ThreadForkResponse__AbsolutePathBuf).annotate({ default: [] }),
        ),
      }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description:
      "Legacy sandbox policy retained for compatibility. Experimental clients should prefer `permissionProfile` when they need exact runtime permissions.",
  }),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  thread: V2ThreadForkResponse__Thread,
}).annotate({ title: "ThreadForkResponse" });

export type V2ThreadForkResponse__ActivePermissionProfile = {
  readonly extends?: string | null;
  readonly id: string;
  readonly modifications?: ReadonlyArray<V2ThreadForkResponse__ActivePermissionProfileModification>;
};
export const V2ThreadForkResponse__ActivePermissionProfile = Schema.Struct({
  extends: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Parent profile identifier once permissions profiles support inheritance. This is currently always `null`.",
      }),
      Schema.Null,
    ]),
  ),
  id: Schema.String.annotate({
    description:
      "Identifier from `default_permissions` or the implicit built-in default, such as `:workspace` or a user-defined `[permissions.<id>]` profile.",
  }),
  modifications: Schema.optionalKey(
    Schema.Array(V2ThreadForkResponse__ActivePermissionProfileModification).annotate({
      description:
        "Bounded user-requested modifications applied on top of the named profile, if any.",
      default: [],
    }),
  ),
});

export type V2ThreadForkResponse__ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
export const V2ThreadForkResponse__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2ThreadForkResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2ThreadForkResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadForkResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadForkResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadForkResponse__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadForkResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadForkResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadForkResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadForkResponse__NetworkAccess = "restricted" | "enabled";
export const V2ThreadForkResponse__NetworkAccess = Schema.Literals(["restricted", "enabled"]);

export type V2ThreadForkResponse__PermissionProfile =
  | {
      readonly fileSystem: V2ThreadForkResponse__PermissionProfileFileSystemPermissions;
      readonly network: V2ThreadForkResponse__PermissionProfileNetworkPermissions;
      readonly type: "managed";
    }
  | { readonly type: "disabled" }
  | {
      readonly network: V2ThreadForkResponse__PermissionProfileNetworkPermissions;
      readonly type: "external";
    };
export const V2ThreadForkResponse__PermissionProfile = Schema.Union(
  [
    Schema.Struct({
      fileSystem: V2ThreadForkResponse__PermissionProfileFileSystemPermissions,
      network: V2ThreadForkResponse__PermissionProfileNetworkPermissions,
      type: Schema.Literal("managed").annotate({ title: "ManagedPermissionProfileType" }),
    }).annotate({
      title: "ManagedPermissionProfile",
      description: "Codex owns sandbox construction for this profile.",
    }),
    Schema.Struct({
      type: Schema.Literal("disabled").annotate({ title: "DisabledPermissionProfileType" }),
    }).annotate({
      title: "DisabledPermissionProfile",
      description: "Do not apply an outer sandbox.",
    }),
    Schema.Struct({
      network: V2ThreadForkResponse__PermissionProfileNetworkPermissions,
      type: Schema.Literal("external").annotate({ title: "ExternalPermissionProfileType" }),
    }).annotate({
      title: "ExternalPermissionProfile",
      description: "Filesystem isolation is enforced by an external caller.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__SandboxPolicy =
  | { readonly type: "dangerFullAccess" }
  | { readonly networkAccess?: boolean; readonly type: "readOnly" }
  | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
  | {
      readonly excludeSlashTmp?: boolean;
      readonly excludeTmpdirEnvVar?: boolean;
      readonly networkAccess?: boolean;
      readonly type: "workspaceWrite";
      readonly writableRoots?: ReadonlyArray<V2ThreadForkResponse__AbsolutePathBuf>;
    };
export const V2ThreadForkResponse__SandboxPolicy = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("dangerFullAccess").annotate({
        title: "DangerFullAccessSandboxPolicyType",
      }),
    }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
    }).annotate({ title: "ReadOnlySandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(
        Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
      ),
      type: Schema.Literal("externalSandbox").annotate({
        title: "ExternalSandboxSandboxPolicyType",
      }),
    }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
    Schema.Struct({
      excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("workspaceWrite").annotate({ title: "WorkspaceWriteSandboxPolicyType" }),
      writableRoots: Schema.optionalKey(
        Schema.Array(V2ThreadForkResponse__AbsolutePathBuf).annotate({ default: [] }),
      ),
    }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadForkResponse__SubAgentSource };
export const V2ThreadForkResponse__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadForkResponse__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadForkResponse__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadForkResponse__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadForkResponse__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadForkResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadForkResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadGoalClearedNotification = { readonly threadId: string };
export const V2ThreadGoalClearedNotification = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "ThreadGoalClearedNotification",
});

export type V2ThreadGoalUpdatedNotification = {
  readonly goal: V2ThreadGoalUpdatedNotification__ThreadGoal;
  readonly threadId: string;
  readonly turnId?: string | null;
};
export const V2ThreadGoalUpdatedNotification = Schema.Struct({
  goal: V2ThreadGoalUpdatedNotification__ThreadGoal,
  threadId: Schema.String,
  turnId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "ThreadGoalUpdatedNotification" });

export type V2ThreadInjectItemsParams = {
  readonly items: ReadonlyArray<unknown>;
  readonly threadId: string;
};
export const V2ThreadInjectItemsParams = Schema.Struct({
  items: Schema.Array(Schema.Unknown).annotate({
    description: "Raw Responses API items to append to the thread's model-visible history.",
  }),
  threadId: Schema.String,
}).annotate({ title: "ThreadInjectItemsParams" });

export type V2ThreadInjectItemsResponse = {};
export const V2ThreadInjectItemsResponse = Schema.Struct({}).annotate({
  title: "ThreadInjectItemsResponse",
});

export type V2ThreadListParams = {
  readonly archived?: boolean | null;
  readonly cursor?: string | null;
  readonly cwd?: V2ThreadListParams__ThreadListCwdFilter | null;
  readonly limit?: number | null;
  readonly modelProviders?: ReadonlyArray<string> | null;
  readonly searchTerm?: string | null;
  readonly sortDirection?: V2ThreadListParams__SortDirection | null;
  readonly sortKey?: V2ThreadListParams__ThreadSortKey | null;
  readonly sourceKinds?: ReadonlyArray<V2ThreadListParams__ThreadSourceKind> | null;
  readonly useStateDbOnly?: boolean;
};
export const V2ThreadListParams = Schema.Struct({
  archived: Schema.optionalKey(
    Schema.Union([
      Schema.Boolean.annotate({
        description:
          "Optional archived filter; when set to true, only archived threads are returned. If false or null, only non-archived threads are returned.",
      }),
      Schema.Null,
    ]),
  ),
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  cwd: Schema.optionalKey(
    Schema.Union([V2ThreadListParams__ThreadListCwdFilter, Schema.Null]).annotate({
      description:
        "Optional cwd filter or filters; when set, only threads whose session cwd exactly matches one of these paths are returned.",
    }),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to a reasonable server-side value.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
  modelProviders: Schema.optionalKey(
    Schema.Union([
      Schema.Array(Schema.String).annotate({
        description:
          "Optional provider filter; when set, only sessions recorded under these providers are returned. When present but empty, includes all providers.",
      }),
      Schema.Null,
    ]),
  ),
  searchTerm: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional substring filter for the extracted thread title.",
      }),
      Schema.Null,
    ]),
  ),
  sortDirection: Schema.optionalKey(
    Schema.Union([V2ThreadListParams__SortDirection, Schema.Null]).annotate({
      description: "Optional sort direction; defaults to descending (newest first).",
    }),
  ),
  sortKey: Schema.optionalKey(
    Schema.Union([V2ThreadListParams__ThreadSortKey, Schema.Null]).annotate({
      description: "Optional sort key; defaults to created_at.",
    }),
  ),
  sourceKinds: Schema.optionalKey(
    Schema.Union([
      Schema.Array(V2ThreadListParams__ThreadSourceKind).annotate({
        description:
          "Optional source filter; when set, only sessions from these source kinds are returned. When omitted or empty, defaults to interactive sources.",
      }),
      Schema.Null,
    ]),
  ),
  useStateDbOnly: Schema.optionalKey(
    Schema.Boolean.annotate({
      description:
        "If true, return from the state DB without scanning JSONL rollouts to repair thread metadata. Omitted or false preserves scan-and-repair behavior.",
    }),
  ),
}).annotate({ title: "ThreadListParams" });

export type V2ThreadListResponse = {
  readonly backwardsCursor?: string | null;
  readonly data: ReadonlyArray<V2ThreadListResponse__Thread>;
  readonly nextCursor?: string | null;
};
export const V2ThreadListResponse = Schema.Struct({
  backwardsCursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        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.",
      }),
      Schema.Null,
    ]),
  ),
  data: Schema.Array(V2ThreadListResponse__Thread),
  nextCursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Opaque cursor to pass to the next call to continue after the last item. if None, there are no more items to return.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ThreadListResponse" });

export type V2ThreadListResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2ThreadListResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadListResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadListResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadListResponse__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadListResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadListResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadListResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadListResponse__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadListResponse__SubAgentSource };
export const V2ThreadListResponse__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadListResponse__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadListResponse__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadListResponse__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadListResponse__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadListResponse__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadListResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadListResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadLoadedListParams = {
  readonly cursor?: string | null;
  readonly limit?: number | null;
};
export const V2ThreadLoadedListParams = Schema.Struct({
  cursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Opaque pagination cursor returned by a previous call.",
      }),
      Schema.Null,
    ]),
  ),
  limit: Schema.optionalKey(
    Schema.Union([
      Schema.Number.annotate({
        description: "Optional page size; defaults to no limit.",
        format: "uint32",
      })
        .check(Schema.isInt())
        .check(Schema.isGreaterThanOrEqualTo(0)),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ThreadLoadedListParams" });

export type V2ThreadLoadedListResponse = {
  readonly data: ReadonlyArray<string>;
  readonly nextCursor?: string | null;
};
export const V2ThreadLoadedListResponse = Schema.Struct({
  data: Schema.Array(Schema.String).annotate({
    description: "Thread ids for sessions currently loaded in memory.",
  }),
  nextCursor: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Opaque cursor to pass to the next call to continue after the last item. if None, there are no more items to return.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "ThreadLoadedListResponse" });

export type V2ThreadMetadataUpdateParams = {
  readonly gitInfo?: V2ThreadMetadataUpdateParams__ThreadMetadataGitInfoUpdateParams | null;
  readonly threadId: string;
};
export const V2ThreadMetadataUpdateParams = Schema.Struct({
  gitInfo: Schema.optionalKey(
    Schema.Union([
      V2ThreadMetadataUpdateParams__ThreadMetadataGitInfoUpdateParams,
      Schema.Null,
    ]).annotate({
      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.",
    }),
  ),
  threadId: Schema.String,
}).annotate({ title: "ThreadMetadataUpdateParams" });

export type V2ThreadMetadataUpdateResponse = {
  readonly thread: V2ThreadMetadataUpdateResponse__Thread;
};
export const V2ThreadMetadataUpdateResponse = Schema.Struct({
  thread: V2ThreadMetadataUpdateResponse__Thread,
}).annotate({ title: "ThreadMetadataUpdateResponse" });

export type V2ThreadMetadataUpdateResponse__ByteRange = {
  readonly end: number;
  readonly start: number;
};
export const V2ThreadMetadataUpdateResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadMetadataUpdateResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadMetadataUpdateResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadMetadataUpdateResponse__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadMetadataUpdateResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadMetadataUpdateResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadMetadataUpdateResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadMetadataUpdateResponse__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadMetadataUpdateResponse__SubAgentSource };
export const V2ThreadMetadataUpdateResponse__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadMetadataUpdateResponse__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateResponse__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadMetadataUpdateResponse__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadMetadataUpdateResponse__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadMetadataUpdateResponse__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadMetadataUpdateResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadMetadataUpdateResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadNameUpdatedNotification = {
  readonly threadId: string;
  readonly threadName?: string | null;
};
export const V2ThreadNameUpdatedNotification = Schema.Struct({
  threadId: Schema.String,
  threadName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
}).annotate({ title: "ThreadNameUpdatedNotification" });

export type V2ThreadReadParams = { readonly includeTurns?: boolean; readonly threadId: string };
export const V2ThreadReadParams = Schema.Struct({
  includeTurns: Schema.optionalKey(
    Schema.Boolean.annotate({
      description: "When true, include turns and their items from rollout history.",
      default: false,
    }),
  ),
  threadId: Schema.String,
}).annotate({ title: "ThreadReadParams" });

export type V2ThreadReadResponse = { readonly thread: V2ThreadReadResponse__Thread };
export const V2ThreadReadResponse = Schema.Struct({
  thread: V2ThreadReadResponse__Thread,
}).annotate({ title: "ThreadReadResponse" });

export type V2ThreadReadResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2ThreadReadResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadReadResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadReadResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadReadResponse__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
export const V2ThreadReadResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadReadResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadReadResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadReadResponse__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadReadResponse__SubAgentSource };
export const V2ThreadReadResponse__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadReadResponse__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadReadResponse__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadReadResponse__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadReadResponse__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadReadResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadReadResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadRealtimeClosedNotification = {
  readonly reason?: string | null;
  readonly threadId: string;
};
export const V2ThreadRealtimeClosedNotification = Schema.Struct({
  reason: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
}).annotate({
  title: "ThreadRealtimeClosedNotification",
  description: "EXPERIMENTAL - emitted when thread realtime transport closes.",
});

export type V2ThreadRealtimeErrorNotification = {
  readonly message: string;
  readonly threadId: string;
};
export const V2ThreadRealtimeErrorNotification = Schema.Struct({
  message: Schema.String,
  threadId: Schema.String,
}).annotate({
  title: "ThreadRealtimeErrorNotification",
  description: "EXPERIMENTAL - emitted when thread realtime encounters an error.",
});

export type V2ThreadRealtimeItemAddedNotification = {
  readonly item: unknown;
  readonly threadId: string;
};
export const V2ThreadRealtimeItemAddedNotification = Schema.Struct({
  item: Schema.Unknown,
  threadId: Schema.String,
}).annotate({
  title: "ThreadRealtimeItemAddedNotification",
  description: "EXPERIMENTAL - raw non-audio thread realtime item emitted by the backend.",
});

export type V2ThreadRealtimeOutputAudioDeltaNotification = {
  readonly audio: V2ThreadRealtimeOutputAudioDeltaNotification__ThreadRealtimeAudioChunk;
  readonly threadId: string;
};
export const V2ThreadRealtimeOutputAudioDeltaNotification = Schema.Struct({
  audio: V2ThreadRealtimeOutputAudioDeltaNotification__ThreadRealtimeAudioChunk,
  threadId: Schema.String,
}).annotate({
  title: "ThreadRealtimeOutputAudioDeltaNotification",
  description: "EXPERIMENTAL - streamed output audio emitted by thread realtime.",
});

export type V2ThreadRealtimeSdpNotification = { readonly sdp: string; readonly threadId: string };
export const V2ThreadRealtimeSdpNotification = Schema.Struct({
  sdp: Schema.String,
  threadId: Schema.String,
}).annotate({
  title: "ThreadRealtimeSdpNotification",
  description: "EXPERIMENTAL - emitted with the remote SDP for a WebRTC realtime session.",
});

export type V2ThreadRealtimeStartedNotification = {
  readonly realtimeSessionId?: string | null;
  readonly threadId: string;
  readonly version: V2ThreadRealtimeStartedNotification__RealtimeConversationVersion;
};
export const V2ThreadRealtimeStartedNotification = Schema.Struct({
  realtimeSessionId: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
  version: V2ThreadRealtimeStartedNotification__RealtimeConversationVersion,
}).annotate({
  title: "ThreadRealtimeStartedNotification",
  description: "EXPERIMENTAL - emitted when thread realtime startup is accepted.",
});

export type V2ThreadRealtimeTranscriptDeltaNotification = {
  readonly delta: string;
  readonly role: string;
  readonly threadId: string;
};
export const V2ThreadRealtimeTranscriptDeltaNotification = Schema.Struct({
  delta: Schema.String.annotate({ description: "Live transcript delta from the realtime event." }),
  role: Schema.String,
  threadId: Schema.String,
}).annotate({
  title: "ThreadRealtimeTranscriptDeltaNotification",
  description:
    "EXPERIMENTAL - flat transcript delta emitted whenever realtime transcript text changes.",
});

export type V2ThreadRealtimeTranscriptDoneNotification = {
  readonly role: string;
  readonly text: string;
  readonly threadId: string;
};
export const V2ThreadRealtimeTranscriptDoneNotification = Schema.Struct({
  role: Schema.String,
  text: Schema.String.annotate({ description: "Final complete text for the transcript part." }),
  threadId: Schema.String,
}).annotate({
  title: "ThreadRealtimeTranscriptDoneNotification",
  description:
    "EXPERIMENTAL - final transcript text emitted when realtime completes a transcript part.",
});

export type V2ThreadResumeParams = {
  readonly approvalPolicy?: V2ThreadResumeParams__AskForApproval | null;
  readonly approvalsReviewer?: V2ThreadResumeParams__ApprovalsReviewer | null;
  readonly baseInstructions?: string | null;
  readonly config?: { readonly [x: string]: unknown } | null;
  readonly cwd?: string | null;
  readonly developerInstructions?: string | null;
  readonly model?: string | null;
  readonly modelProvider?: string | null;
  readonly personality?: V2ThreadResumeParams__Personality | null;
  readonly sandbox?: V2ThreadResumeParams__SandboxMode | null;
  readonly serviceTier?: string | null;
  readonly threadId: string;
};
export const V2ThreadResumeParams = Schema.Struct({
  approvalPolicy: Schema.optionalKey(
    Schema.Union([V2ThreadResumeParams__AskForApproval, Schema.Null]),
  ),
  approvalsReviewer: Schema.optionalKey(
    Schema.Union([V2ThreadResumeParams__ApprovalsReviewer, Schema.Null]).annotate({
      description:
        "Override where approval requests are routed for review on this thread and subsequent turns.",
    }),
  ),
  baseInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  config: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.Unknown), Schema.Null]),
  ),
  cwd: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developerInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  model: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Configuration overrides for the resumed thread, if any.",
      }),
      Schema.Null,
    ]),
  ),
  modelProvider: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  personality: Schema.optionalKey(Schema.Union([V2ThreadResumeParams__Personality, Schema.Null])),
  sandbox: Schema.optionalKey(Schema.Union([V2ThreadResumeParams__SandboxMode, Schema.Null])),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  threadId: Schema.String,
}).annotate({
  title: "ThreadResumeParams",
  description:
    "There are three ways to resume a thread: 1. By thread_id: load the thread from disk by thread_id and resume it. 2. By history: instantiate the thread from memory and resume it. 3. By path: load the thread from disk by path and resume it.\n\nThe precedence is: history > path > thread_id. If using history or path, the thread_id param will be ignored.\n\nPrefer using thread_id whenever possible.",
});

export type V2ThreadResumeParams__PermissionProfileSelectionParams = {
  readonly id: string;
  readonly modifications?: ReadonlyArray<V2ThreadResumeParams__PermissionProfileModificationParams> | null;
  readonly type: "profile";
};
export const V2ThreadResumeParams__PermissionProfileSelectionParams = Schema.Union(
  [
    Schema.Struct({
      id: Schema.String,
      modifications: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadResumeParams__PermissionProfileModificationParams),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("profile").annotate({
        title: "ProfilePermissionProfileSelectionParamsType",
      }),
    }).annotate({
      title: "ProfilePermissionProfileSelectionParams",
      description:
        "Select a named built-in or user-defined profile and optionally apply bounded modifications that Codex knows how to validate.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeParams__ResponseItem =
  | {
      readonly content: ReadonlyArray<V2ThreadResumeParams__ContentItem>;
      readonly id?: string | null;
      readonly phase?: V2ThreadResumeParams__MessagePhase | null;
      readonly role: string;
      readonly type: "message";
    }
  | {
      readonly content?: ReadonlyArray<V2ThreadResumeParams__ReasoningItemContent> | null;
      readonly encrypted_content?: string | null;
      readonly summary: ReadonlyArray<V2ThreadResumeParams__ReasoningItemReasoningSummary>;
      readonly type: "reasoning";
    }
  | {
      readonly action: V2ThreadResumeParams__LocalShellAction;
      readonly call_id?: string | null;
      readonly id?: string | null;
      readonly status: V2ThreadResumeParams__LocalShellStatus;
      readonly type: "local_shell_call";
    }
  | {
      readonly arguments: string;
      readonly call_id: string;
      readonly id?: string | null;
      readonly name: string;
      readonly namespace?: string | null;
      readonly type: "function_call";
    }
  | {
      readonly arguments: unknown;
      readonly call_id?: string | null;
      readonly execution: string;
      readonly id?: string | null;
      readonly status?: string | null;
      readonly type: "tool_search_call";
    }
  | {
      readonly call_id: string;
      readonly output: V2ThreadResumeParams__FunctionCallOutputBody;
      readonly type: "function_call_output";
    }
  | {
      readonly call_id: string;
      readonly id?: string | null;
      readonly input: string;
      readonly name: string;
      readonly status?: string | null;
      readonly type: "custom_tool_call";
    }
  | {
      readonly call_id: string;
      readonly name?: string | null;
      readonly output: V2ThreadResumeParams__FunctionCallOutputBody;
      readonly type: "custom_tool_call_output";
    }
  | {
      readonly call_id?: string | null;
      readonly execution: string;
      readonly status: string;
      readonly tools: ReadonlyArray<unknown>;
      readonly type: "tool_search_output";
    }
  | {
      readonly action?: V2ThreadResumeParams__ResponsesApiWebSearchAction | null;
      readonly id?: string | null;
      readonly status?: string | null;
      readonly type: "web_search_call";
    }
  | {
      readonly id: string;
      readonly result: string;
      readonly revised_prompt?: string | null;
      readonly status: string;
      readonly type: "image_generation_call";
    }
  | { readonly encrypted_content: string; readonly type: "compaction" }
  | { readonly encrypted_content?: string | null; readonly type: "context_compaction" }
  | { readonly type: "other" };
export const V2ThreadResumeParams__ResponseItem = Schema.Union(
  [
    Schema.Struct({
      content: Schema.Array(V2ThreadResumeParams__ContentItem),
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      phase: Schema.optionalKey(Schema.Union([V2ThreadResumeParams__MessagePhase, Schema.Null])),
      role: Schema.String,
      type: Schema.Literal("message").annotate({ title: "MessageResponseItemType" }),
    }).annotate({ title: "MessageResponseItem" }),
    Schema.Struct({
      content: Schema.optionalKey(
        Schema.Union([Schema.Array(V2ThreadResumeParams__ReasoningItemContent), Schema.Null]),
      ),
      encrypted_content: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      summary: Schema.Array(V2ThreadResumeParams__ReasoningItemReasoningSummary),
      type: Schema.Literal("reasoning").annotate({ title: "ReasoningResponseItemType" }),
    }).annotate({ title: "ReasoningResponseItem" }),
    Schema.Struct({
      action: V2ThreadResumeParams__LocalShellAction,
      call_id: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({ description: "Set when using the Responses API." }),
          Schema.Null,
        ]),
      ),
      id: Schema.optionalKey(
        Schema.Union([
          Schema.String.annotate({
            description: "Legacy id field retained for compatibility with older payloads.",
            writeOnly: true,
          }),
          Schema.Null,
        ]),
      ),
      status: V2ThreadResumeParams__LocalShellStatus,
      type: Schema.Literal("local_shell_call").annotate({
        title: "LocalShellCallResponseItemType",
      }),
    }).annotate({ title: "LocalShellCallResponseItem" }),
    Schema.Struct({
      arguments: Schema.String,
      call_id: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      name: Schema.String,
      namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("function_call").annotate({ title: "FunctionCallResponseItemType" }),
    }).annotate({ title: "FunctionCallResponseItem" }),
    Schema.Struct({
      arguments: Schema.Unknown,
      call_id: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      execution: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("tool_search_call").annotate({
        title: "ToolSearchCallResponseItemType",
      }),
    }).annotate({ title: "ToolSearchCallResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      output: V2ThreadResumeParams__FunctionCallOutputBody,
      type: Schema.Literal("function_call_output").annotate({
        title: "FunctionCallOutputResponseItemType",
      }),
    }).annotate({ title: "FunctionCallOutputResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      input: Schema.String,
      name: Schema.String,
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("custom_tool_call").annotate({
        title: "CustomToolCallResponseItemType",
      }),
    }).annotate({ title: "CustomToolCallResponseItem" }),
    Schema.Struct({
      call_id: Schema.String,
      name: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      output: V2ThreadResumeParams__FunctionCallOutputBody,
      type: Schema.Literal("custom_tool_call_output").annotate({
        title: "CustomToolCallOutputResponseItemType",
      }),
    }).annotate({ title: "CustomToolCallOutputResponseItem" }),
    Schema.Struct({
      call_id: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      execution: Schema.String,
      status: Schema.String,
      tools: Schema.Array(Schema.Unknown),
      type: Schema.Literal("tool_search_output").annotate({
        title: "ToolSearchOutputResponseItemType",
      }),
    }).annotate({ title: "ToolSearchOutputResponseItem" }),
    Schema.Struct({
      action: Schema.optionalKey(
        Schema.Union([V2ThreadResumeParams__ResponsesApiWebSearchAction, Schema.Null]),
      ),
      id: Schema.optionalKey(
        Schema.Union([Schema.String.annotate({ writeOnly: true }), Schema.Null]),
      ),
      status: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("web_search_call").annotate({ title: "WebSearchCallResponseItemType" }),
    }).annotate({ title: "WebSearchCallResponseItem" }),
    Schema.Struct({
      id: Schema.String,
      result: Schema.String,
      revised_prompt: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      status: Schema.String,
      type: Schema.Literal("image_generation_call").annotate({
        title: "ImageGenerationCallResponseItemType",
      }),
    }).annotate({ title: "ImageGenerationCallResponseItem" }),
    Schema.Struct({
      encrypted_content: Schema.String,
      type: Schema.Literal("compaction").annotate({ title: "CompactionResponseItemType" }),
    }).annotate({ title: "CompactionResponseItem" }),
    Schema.Struct({
      encrypted_content: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
      type: Schema.Literal("context_compaction").annotate({
        title: "ContextCompactionResponseItemType",
      }),
    }).annotate({ title: "ContextCompactionResponseItem" }),
    Schema.Struct({
      type: Schema.Literal("other").annotate({ title: "OtherResponseItemType" }),
    }).annotate({ title: "OtherResponseItem" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse = {
  readonly approvalPolicy: V2ThreadResumeResponse__AskForApproval;
  readonly approvalsReviewer: "user" | "auto_review" | "guardian_subagent";
  readonly cwd: V2ThreadResumeResponse__AbsolutePathBuf;
  readonly instructionSources?: ReadonlyArray<V2ThreadResumeResponse__AbsolutePathBuf>;
  readonly model: string;
  readonly modelProvider: string;
  readonly reasoningEffort?: V2ThreadResumeResponse__ReasoningEffort | null;
  readonly sandbox:
    | { readonly type: "dangerFullAccess" }
    | { readonly networkAccess?: boolean; readonly type: "readOnly" }
    | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
    | {
        readonly excludeSlashTmp?: boolean;
        readonly excludeTmpdirEnvVar?: boolean;
        readonly networkAccess?: boolean;
        readonly type: "workspaceWrite";
        readonly writableRoots?: ReadonlyArray<V2ThreadResumeResponse__AbsolutePathBuf>;
      };
  readonly serviceTier?: string | null;
  readonly thread: V2ThreadResumeResponse__Thread;
};
export const V2ThreadResumeResponse = Schema.Struct({
  approvalPolicy: V2ThreadResumeResponse__AskForApproval,
  approvalsReviewer: Schema.Literals(["user", "auto_review", "guardian_subagent"]).annotate({
    description:
      "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
  }),
  cwd: V2ThreadResumeResponse__AbsolutePathBuf,
  instructionSources: Schema.optionalKey(
    Schema.Array(V2ThreadResumeResponse__AbsolutePathBuf).annotate({
      description: "Instruction source files currently loaded for this thread.",
      default: [],
    }),
  ),
  model: Schema.String,
  modelProvider: Schema.String,
  reasoningEffort: Schema.optionalKey(
    Schema.Union([V2ThreadResumeResponse__ReasoningEffort, Schema.Null]),
  ),
  sandbox: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("dangerFullAccess").annotate({
          title: "DangerFullAccessSandboxPolicyType",
        }),
      }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
      Schema.Struct({
        networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
      }).annotate({ title: "ReadOnlySandboxPolicy" }),
      Schema.Struct({
        networkAccess: Schema.optionalKey(
          Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
        ),
        type: Schema.Literal("externalSandbox").annotate({
          title: "ExternalSandboxSandboxPolicyType",
        }),
      }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
      Schema.Struct({
        excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        type: Schema.Literal("workspaceWrite").annotate({
          title: "WorkspaceWriteSandboxPolicyType",
        }),
        writableRoots: Schema.optionalKey(
          Schema.Array(V2ThreadResumeResponse__AbsolutePathBuf).annotate({ default: [] }),
        ),
      }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description:
      "Legacy sandbox policy retained for compatibility. Experimental clients should prefer `permissionProfile` when they need exact runtime permissions.",
  }),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  thread: V2ThreadResumeResponse__Thread,
}).annotate({ title: "ThreadResumeResponse" });

export type V2ThreadResumeResponse__ActivePermissionProfile = {
  readonly extends?: string | null;
  readonly id: string;
  readonly modifications?: ReadonlyArray<V2ThreadResumeResponse__ActivePermissionProfileModification>;
};
export const V2ThreadResumeResponse__ActivePermissionProfile = Schema.Struct({
  extends: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Parent profile identifier once permissions profiles support inheritance. This is currently always `null`.",
      }),
      Schema.Null,
    ]),
  ),
  id: Schema.String.annotate({
    description:
      "Identifier from `default_permissions` or the implicit built-in default, such as `:workspace` or a user-defined `[permissions.<id>]` profile.",
  }),
  modifications: Schema.optionalKey(
    Schema.Array(V2ThreadResumeResponse__ActivePermissionProfileModification).annotate({
      description:
        "Bounded user-requested modifications applied on top of the named profile, if any.",
      default: [],
    }),
  ),
});

export type V2ThreadResumeResponse__ApprovalsReviewer =
  | "user"
  | "auto_review"
  | "guardian_subagent";
export const V2ThreadResumeResponse__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2ThreadResumeResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2ThreadResumeResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadResumeResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadResumeResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadResumeResponse__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadResumeResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadResumeResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadResumeResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadResumeResponse__NetworkAccess = "restricted" | "enabled";
export const V2ThreadResumeResponse__NetworkAccess = Schema.Literals(["restricted", "enabled"]);

export type V2ThreadResumeResponse__PermissionProfile =
  | {
      readonly fileSystem: V2ThreadResumeResponse__PermissionProfileFileSystemPermissions;
      readonly network: V2ThreadResumeResponse__PermissionProfileNetworkPermissions;
      readonly type: "managed";
    }
  | { readonly type: "disabled" }
  | {
      readonly network: V2ThreadResumeResponse__PermissionProfileNetworkPermissions;
      readonly type: "external";
    };
export const V2ThreadResumeResponse__PermissionProfile = Schema.Union(
  [
    Schema.Struct({
      fileSystem: V2ThreadResumeResponse__PermissionProfileFileSystemPermissions,
      network: V2ThreadResumeResponse__PermissionProfileNetworkPermissions,
      type: Schema.Literal("managed").annotate({ title: "ManagedPermissionProfileType" }),
    }).annotate({
      title: "ManagedPermissionProfile",
      description: "Codex owns sandbox construction for this profile.",
    }),
    Schema.Struct({
      type: Schema.Literal("disabled").annotate({ title: "DisabledPermissionProfileType" }),
    }).annotate({
      title: "DisabledPermissionProfile",
      description: "Do not apply an outer sandbox.",
    }),
    Schema.Struct({
      network: V2ThreadResumeResponse__PermissionProfileNetworkPermissions,
      type: Schema.Literal("external").annotate({ title: "ExternalPermissionProfileType" }),
    }).annotate({
      title: "ExternalPermissionProfile",
      description: "Filesystem isolation is enforced by an external caller.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__SandboxPolicy =
  | { readonly type: "dangerFullAccess" }
  | { readonly networkAccess?: boolean; readonly type: "readOnly" }
  | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
  | {
      readonly excludeSlashTmp?: boolean;
      readonly excludeTmpdirEnvVar?: boolean;
      readonly networkAccess?: boolean;
      readonly type: "workspaceWrite";
      readonly writableRoots?: ReadonlyArray<V2ThreadResumeResponse__AbsolutePathBuf>;
    };
export const V2ThreadResumeResponse__SandboxPolicy = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("dangerFullAccess").annotate({
        title: "DangerFullAccessSandboxPolicyType",
      }),
    }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
    }).annotate({ title: "ReadOnlySandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(
        Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
      ),
      type: Schema.Literal("externalSandbox").annotate({
        title: "ExternalSandboxSandboxPolicyType",
      }),
    }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
    Schema.Struct({
      excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("workspaceWrite").annotate({ title: "WorkspaceWriteSandboxPolicyType" }),
      writableRoots: Schema.optionalKey(
        Schema.Array(V2ThreadResumeResponse__AbsolutePathBuf).annotate({ default: [] }),
      ),
    }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadResumeResponse__SubAgentSource };
export const V2ThreadResumeResponse__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadResumeResponse__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadResumeResponse__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadResumeResponse__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadResumeResponse__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadResumeResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadResumeResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadRollbackParams = { readonly numTurns: number; readonly threadId: string };
export const V2ThreadRollbackParams = Schema.Struct({
  numTurns: Schema.Number.annotate({
    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.",
    format: "uint32",
  })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  threadId: Schema.String,
}).annotate({ title: "ThreadRollbackParams" });

export type V2ThreadRollbackResponse = {
  readonly thread: {
    readonly agentNickname?: string | null;
    readonly agentRole?: string | null;
    readonly cliVersion: string;
    readonly createdAt: number;
    readonly cwd: string;
    readonly ephemeral: boolean;
    readonly forkedFromId?: string | null;
    readonly gitInfo?: V2ThreadRollbackResponse__GitInfo | null;
    readonly id: string;
    readonly modelProvider: string;
    readonly name?: string | null;
    readonly path?: string | null;
    readonly preview: string;
    readonly sessionId: string;
    readonly source:
      | "cli"
      | "vscode"
      | "exec"
      | "appServer"
      | "unknown"
      | { readonly custom: string }
      | { readonly subAgent: V2ThreadRollbackResponse__SubAgentSource };
    readonly status:
      | { readonly type: "notLoaded" }
      | { readonly type: "idle" }
      | { readonly type: "systemError" }
      | {
          readonly activeFlags: ReadonlyArray<V2ThreadRollbackResponse__ThreadActiveFlag>;
          readonly type: "active";
        };
    readonly threadSource?: V2ThreadRollbackResponse__ThreadSource | null;
    readonly turns: ReadonlyArray<V2ThreadRollbackResponse__Turn>;
    readonly updatedAt: number;
  };
};
export const V2ThreadRollbackResponse = Schema.Struct({
  thread: Schema.Struct({
    agentNickname: Schema.optionalKey(
      Schema.Union([
        Schema.String.annotate({
          description:
            "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
        }),
        Schema.Null,
      ]),
    ),
    agentRole: Schema.optionalKey(
      Schema.Union([
        Schema.String.annotate({
          description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
        }),
        Schema.Null,
      ]),
    ),
    cliVersion: Schema.String.annotate({
      description: "Version of the CLI that created the thread.",
    }),
    createdAt: Schema.Number.annotate({
      description: "Unix timestamp (in seconds) when the thread was created.",
      format: "int64",
    }).check(Schema.isInt()),
    cwd: Schema.String.annotate({
      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.",
    }),
    ephemeral: Schema.Boolean.annotate({
      description: "Whether the thread is ephemeral and should not be materialized on disk.",
    }),
    forkedFromId: Schema.optionalKey(
      Schema.Union([
        Schema.String.annotate({
          description: "Source thread id when this thread was created by forking another thread.",
        }),
        Schema.Null,
      ]),
    ),
    gitInfo: Schema.optionalKey(
      Schema.Union([V2ThreadRollbackResponse__GitInfo, Schema.Null]).annotate({
        description: "Optional Git metadata captured when the thread was created.",
      }),
    ),
    id: Schema.String,
    modelProvider: Schema.String.annotate({
      description: "Model provider used for this thread (for example, 'openai').",
    }),
    name: Schema.optionalKey(
      Schema.Union([
        Schema.String.annotate({ description: "Optional user-facing thread title." }),
        Schema.Null,
      ]),
    ),
    path: Schema.optionalKey(
      Schema.Union([
        Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
        Schema.Null,
      ]),
    ),
    preview: Schema.String.annotate({
      description: "Usually the first user message in the thread, if available.",
    }),
    sessionId: Schema.String.annotate({
      description: "Session id shared by threads that belong to the same session tree.",
    }),
    source: Schema.Union(
      [
        Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
        Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
        Schema.Struct({ subAgent: V2ThreadRollbackResponse__SubAgentSource }).annotate({
          title: "SubAgentSessionSource",
        }),
      ],
      { mode: "oneOf" },
    ).annotate({
      description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
    }),
    status: Schema.Union(
      [
        Schema.Struct({
          type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
        }).annotate({ title: "NotLoadedThreadStatus" }),
        Schema.Struct({
          type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
        }).annotate({ title: "IdleThreadStatus" }),
        Schema.Struct({
          type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
        }).annotate({ title: "SystemErrorThreadStatus" }),
        Schema.Struct({
          activeFlags: Schema.Array(V2ThreadRollbackResponse__ThreadActiveFlag),
          type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
        }).annotate({ title: "ActiveThreadStatus" }),
      ],
      { mode: "oneOf" },
    ).annotate({ description: "Current runtime status for the thread." }),
    threadSource: Schema.optionalKey(
      Schema.Union([V2ThreadRollbackResponse__ThreadSource, Schema.Null]).annotate({
        description: "Optional analytics source classification for this thread.",
      }),
    ),
    turns: Schema.Array(V2ThreadRollbackResponse__Turn).annotate({
      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.",
    }),
    updatedAt: Schema.Number.annotate({
      description: "Unix timestamp (in seconds) when the thread was last updated.",
      format: "int64",
    }).check(Schema.isInt()),
  }).annotate({
    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`.",
  }),
}).annotate({ title: "ThreadRollbackResponse" });

export type V2ThreadRollbackResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2ThreadRollbackResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadRollbackResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadRollbackResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadRollbackResponse__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadRollbackResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadRollbackResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadRollbackResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadRollbackResponse__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadRollbackResponse__SubAgentSource };
export const V2ThreadRollbackResponse__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadRollbackResponse__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__Thread = {
  readonly agentNickname?: string | null;
  readonly agentRole?: string | null;
  readonly cliVersion: string;
  readonly createdAt: number;
  readonly cwd: string;
  readonly ephemeral: boolean;
  readonly forkedFromId?: string | null;
  readonly gitInfo?: V2ThreadRollbackResponse__GitInfo | null;
  readonly id: string;
  readonly modelProvider: string;
  readonly name?: string | null;
  readonly path?: string | null;
  readonly preview: string;
  readonly sessionId: string;
  readonly source:
    | "cli"
    | "vscode"
    | "exec"
    | "appServer"
    | "unknown"
    | { readonly custom: string }
    | { readonly subAgent: V2ThreadRollbackResponse__SubAgentSource };
  readonly status:
    | { readonly type: "notLoaded" }
    | { readonly type: "idle" }
    | { readonly type: "systemError" }
    | {
        readonly activeFlags: ReadonlyArray<V2ThreadRollbackResponse__ThreadActiveFlag>;
        readonly type: "active";
      };
  readonly threadSource?: V2ThreadRollbackResponse__ThreadSource | null;
  readonly turns: ReadonlyArray<V2ThreadRollbackResponse__Turn>;
  readonly updatedAt: number;
};
export const V2ThreadRollbackResponse__Thread = Schema.Struct({
  agentNickname: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  agentRole: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
      }),
      Schema.Null,
    ]),
  ),
  cliVersion: Schema.String.annotate({
    description: "Version of the CLI that created the thread.",
  }),
  createdAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was created.",
    format: "int64",
  }).check(Schema.isInt()),
  cwd: Schema.String.annotate({
    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.",
  }),
  ephemeral: Schema.Boolean.annotate({
    description: "Whether the thread is ephemeral and should not be materialized on disk.",
  }),
  forkedFromId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Source thread id when this thread was created by forking another thread.",
      }),
      Schema.Null,
    ]),
  ),
  gitInfo: Schema.optionalKey(
    Schema.Union([V2ThreadRollbackResponse__GitInfo, Schema.Null]).annotate({
      description: "Optional Git metadata captured when the thread was created.",
    }),
  ),
  id: Schema.String,
  modelProvider: Schema.String.annotate({
    description: "Model provider used for this thread (for example, 'openai').",
  }),
  name: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "Optional user-facing thread title." }),
      Schema.Null,
    ]),
  ),
  path: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({ description: "[UNSTABLE] Path to the thread on disk." }),
      Schema.Null,
    ]),
  ),
  preview: Schema.String.annotate({
    description: "Usually the first user message in the thread, if available.",
  }),
  sessionId: Schema.String.annotate({
    description: "Session id shared by threads that belong to the same session tree.",
  }),
  source: Schema.Union(
    [
      Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
      Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
      Schema.Struct({ subAgent: V2ThreadRollbackResponse__SubAgentSource }).annotate({
        title: "SubAgentSessionSource",
      }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description: "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
  }),
  status: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
      }).annotate({ title: "NotLoadedThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
      }).annotate({ title: "IdleThreadStatus" }),
      Schema.Struct({
        type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
      }).annotate({ title: "SystemErrorThreadStatus" }),
      Schema.Struct({
        activeFlags: Schema.Array(V2ThreadRollbackResponse__ThreadActiveFlag),
        type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
      }).annotate({ title: "ActiveThreadStatus" }),
    ],
    { mode: "oneOf" },
  ).annotate({ description: "Current runtime status for the thread." }),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadRollbackResponse__ThreadSource, Schema.Null]).annotate({
      description: "Optional analytics source classification for this thread.",
    }),
  ),
  turns: Schema.Array(V2ThreadRollbackResponse__Turn).annotate({
    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.",
  }),
  updatedAt: Schema.Number.annotate({
    description: "Unix timestamp (in seconds) when the thread was last updated.",
    format: "int64",
  }).check(Schema.isInt()),
});

export type V2ThreadRollbackResponse__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadRollbackResponse__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadRollbackResponse__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadRollbackResponse__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadRollbackResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadRollbackResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadSetNameParams = { readonly name: string; readonly threadId: string };
export const V2ThreadSetNameParams = Schema.Struct({
  name: Schema.String,
  threadId: Schema.String,
}).annotate({ title: "ThreadSetNameParams" });

export type V2ThreadSetNameResponse = {};
export const V2ThreadSetNameResponse = Schema.Struct({}).annotate({
  title: "ThreadSetNameResponse",
});

export type V2ThreadShellCommandParams = { readonly command: string; readonly threadId: string };
export const V2ThreadShellCommandParams = Schema.Struct({
  command: Schema.String.annotate({
    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.",
  }),
  threadId: Schema.String,
}).annotate({ title: "ThreadShellCommandParams" });

export type V2ThreadShellCommandResponse = {};
export const V2ThreadShellCommandResponse = Schema.Struct({}).annotate({
  title: "ThreadShellCommandResponse",
});

export type V2ThreadStartedNotification = { readonly thread: V2ThreadStartedNotification__Thread };
export const V2ThreadStartedNotification = Schema.Struct({
  thread: V2ThreadStartedNotification__Thread,
}).annotate({ title: "ThreadStartedNotification" });

export type V2ThreadStartedNotification__ByteRange = {
  readonly end: number;
  readonly start: number;
};
export const V2ThreadStartedNotification__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadStartedNotification__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadStartedNotification__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadStartedNotification__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadStartedNotification__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadStartedNotification__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadStartedNotification__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadStartedNotification__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadStartedNotification__SubAgentSource };
export const V2ThreadStartedNotification__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadStartedNotification__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadStartedNotification__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadStartedNotification__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadStartedNotification__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartedNotification__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadStartedNotification__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadStartParams = {
  readonly approvalPolicy?: V2ThreadStartParams__AskForApproval | null;
  readonly approvalsReviewer?: V2ThreadStartParams__ApprovalsReviewer | null;
  readonly baseInstructions?: string | null;
  readonly config?: { readonly [x: string]: unknown } | null;
  readonly cwd?: string | null;
  readonly developerInstructions?: string | null;
  readonly ephemeral?: boolean | null;
  readonly model?: string | null;
  readonly modelProvider?: string | null;
  readonly personality?: V2ThreadStartParams__Personality | null;
  readonly sandbox?: V2ThreadStartParams__SandboxMode | null;
  readonly serviceName?: string | null;
  readonly serviceTier?: string | null;
  readonly sessionStartSource?: V2ThreadStartParams__ThreadStartSource | null;
  readonly threadSource?: V2ThreadStartParams__ThreadSource | null;
};
export const V2ThreadStartParams = Schema.Struct({
  approvalPolicy: Schema.optionalKey(
    Schema.Union([V2ThreadStartParams__AskForApproval, Schema.Null]),
  ),
  approvalsReviewer: Schema.optionalKey(
    Schema.Union([V2ThreadStartParams__ApprovalsReviewer, Schema.Null]).annotate({
      description:
        "Override where approval requests are routed for review on this thread and subsequent turns.",
    }),
  ),
  baseInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  config: Schema.optionalKey(
    Schema.Union([Schema.Record(Schema.String, Schema.Unknown), Schema.Null]),
  ),
  cwd: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  developerInstructions: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  ephemeral: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Null])),
  model: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  modelProvider: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  personality: Schema.optionalKey(Schema.Union([V2ThreadStartParams__Personality, Schema.Null])),
  sandbox: Schema.optionalKey(Schema.Union([V2ThreadStartParams__SandboxMode, Schema.Null])),
  serviceName: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  sessionStartSource: Schema.optionalKey(
    Schema.Union([V2ThreadStartParams__ThreadStartSource, Schema.Null]),
  ),
  threadSource: Schema.optionalKey(
    Schema.Union([V2ThreadStartParams__ThreadSource, Schema.Null]).annotate({
      description: "Optional client-supplied analytics source classification for this thread.",
    }),
  ),
}).annotate({ title: "ThreadStartParams" });

export type V2ThreadStartParams__DynamicToolSpec = {
  readonly deferLoading?: boolean;
  readonly description: string;
  readonly inputSchema: unknown;
  readonly name: string;
  readonly namespace?: string | null;
};
export const V2ThreadStartParams__DynamicToolSpec = Schema.Struct({
  deferLoading: Schema.optionalKey(Schema.Boolean),
  description: Schema.String,
  inputSchema: Schema.Unknown,
  name: Schema.String,
  namespace: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
});

export type V2ThreadStartParams__PermissionProfileSelectionParams = {
  readonly id: string;
  readonly modifications?: ReadonlyArray<V2ThreadStartParams__PermissionProfileModificationParams> | null;
  readonly type: "profile";
};
export const V2ThreadStartParams__PermissionProfileSelectionParams = Schema.Union(
  [
    Schema.Struct({
      id: Schema.String,
      modifications: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2ThreadStartParams__PermissionProfileModificationParams),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("profile").annotate({
        title: "ProfilePermissionProfileSelectionParamsType",
      }),
    }).annotate({
      title: "ProfilePermissionProfileSelectionParams",
      description:
        "Select a named built-in or user-defined profile and optionally apply bounded modifications that Codex knows how to validate.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartParams__TurnEnvironmentParams = {
  readonly cwd: V2ThreadStartParams__AbsolutePathBuf;
  readonly environmentId: string;
};
export const V2ThreadStartParams__TurnEnvironmentParams = Schema.Struct({
  cwd: V2ThreadStartParams__AbsolutePathBuf,
  environmentId: Schema.String,
});

export type V2ThreadStartResponse = {
  readonly approvalPolicy: V2ThreadStartResponse__AskForApproval;
  readonly approvalsReviewer: "user" | "auto_review" | "guardian_subagent";
  readonly cwd: V2ThreadStartResponse__AbsolutePathBuf;
  readonly instructionSources?: ReadonlyArray<V2ThreadStartResponse__AbsolutePathBuf>;
  readonly model: string;
  readonly modelProvider: string;
  readonly reasoningEffort?: V2ThreadStartResponse__ReasoningEffort | null;
  readonly sandbox:
    | { readonly type: "dangerFullAccess" }
    | { readonly networkAccess?: boolean; readonly type: "readOnly" }
    | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
    | {
        readonly excludeSlashTmp?: boolean;
        readonly excludeTmpdirEnvVar?: boolean;
        readonly networkAccess?: boolean;
        readonly type: "workspaceWrite";
        readonly writableRoots?: ReadonlyArray<V2ThreadStartResponse__AbsolutePathBuf>;
      };
  readonly serviceTier?: string | null;
  readonly thread: V2ThreadStartResponse__Thread;
};
export const V2ThreadStartResponse = Schema.Struct({
  approvalPolicy: V2ThreadStartResponse__AskForApproval,
  approvalsReviewer: Schema.Literals(["user", "auto_review", "guardian_subagent"]).annotate({
    description:
      "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
  }),
  cwd: V2ThreadStartResponse__AbsolutePathBuf,
  instructionSources: Schema.optionalKey(
    Schema.Array(V2ThreadStartResponse__AbsolutePathBuf).annotate({
      description: "Instruction source files currently loaded for this thread.",
      default: [],
    }),
  ),
  model: Schema.String,
  modelProvider: Schema.String,
  reasoningEffort: Schema.optionalKey(
    Schema.Union([V2ThreadStartResponse__ReasoningEffort, Schema.Null]),
  ),
  sandbox: Schema.Union(
    [
      Schema.Struct({
        type: Schema.Literal("dangerFullAccess").annotate({
          title: "DangerFullAccessSandboxPolicyType",
        }),
      }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
      Schema.Struct({
        networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
      }).annotate({ title: "ReadOnlySandboxPolicy" }),
      Schema.Struct({
        networkAccess: Schema.optionalKey(
          Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
        ),
        type: Schema.Literal("externalSandbox").annotate({
          title: "ExternalSandboxSandboxPolicyType",
        }),
      }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
      Schema.Struct({
        excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
        type: Schema.Literal("workspaceWrite").annotate({
          title: "WorkspaceWriteSandboxPolicyType",
        }),
        writableRoots: Schema.optionalKey(
          Schema.Array(V2ThreadStartResponse__AbsolutePathBuf).annotate({ default: [] }),
        ),
      }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
    ],
    { mode: "oneOf" },
  ).annotate({
    description:
      "Legacy sandbox policy retained for compatibility. Experimental clients should prefer `permissionProfile` when they need exact runtime permissions.",
  }),
  serviceTier: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  thread: V2ThreadStartResponse__Thread,
}).annotate({ title: "ThreadStartResponse" });

export type V2ThreadStartResponse__ActivePermissionProfile = {
  readonly extends?: string | null;
  readonly id: string;
  readonly modifications?: ReadonlyArray<V2ThreadStartResponse__ActivePermissionProfileModification>;
};
export const V2ThreadStartResponse__ActivePermissionProfile = Schema.Struct({
  extends: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description:
          "Parent profile identifier once permissions profiles support inheritance. This is currently always `null`.",
      }),
      Schema.Null,
    ]),
  ),
  id: Schema.String.annotate({
    description:
      "Identifier from `default_permissions` or the implicit built-in default, such as `:workspace` or a user-defined `[permissions.<id>]` profile.",
  }),
  modifications: Schema.optionalKey(
    Schema.Array(V2ThreadStartResponse__ActivePermissionProfileModification).annotate({
      description:
        "Bounded user-requested modifications applied on top of the named profile, if any.",
      default: [],
    }),
  ),
});

export type V2ThreadStartResponse__ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
export const V2ThreadStartResponse__ApprovalsReviewer = Schema.Literals([
  "user",
  "auto_review",
  "guardian_subagent",
]).annotate({
  description:
    "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
});

export type V2ThreadStartResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2ThreadStartResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadStartResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadStartResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadStartResponse__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadStartResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadStartResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadStartResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadStartResponse__NetworkAccess = "restricted" | "enabled";
export const V2ThreadStartResponse__NetworkAccess = Schema.Literals(["restricted", "enabled"]);

export type V2ThreadStartResponse__PermissionProfile =
  | {
      readonly fileSystem: V2ThreadStartResponse__PermissionProfileFileSystemPermissions;
      readonly network: V2ThreadStartResponse__PermissionProfileNetworkPermissions;
      readonly type: "managed";
    }
  | { readonly type: "disabled" }
  | {
      readonly network: V2ThreadStartResponse__PermissionProfileNetworkPermissions;
      readonly type: "external";
    };
export const V2ThreadStartResponse__PermissionProfile = Schema.Union(
  [
    Schema.Struct({
      fileSystem: V2ThreadStartResponse__PermissionProfileFileSystemPermissions,
      network: V2ThreadStartResponse__PermissionProfileNetworkPermissions,
      type: Schema.Literal("managed").annotate({ title: "ManagedPermissionProfileType" }),
    }).annotate({
      title: "ManagedPermissionProfile",
      description: "Codex owns sandbox construction for this profile.",
    }),
    Schema.Struct({
      type: Schema.Literal("disabled").annotate({ title: "DisabledPermissionProfileType" }),
    }).annotate({
      title: "DisabledPermissionProfile",
      description: "Do not apply an outer sandbox.",
    }),
    Schema.Struct({
      network: V2ThreadStartResponse__PermissionProfileNetworkPermissions,
      type: Schema.Literal("external").annotate({ title: "ExternalPermissionProfileType" }),
    }).annotate({
      title: "ExternalPermissionProfile",
      description: "Filesystem isolation is enforced by an external caller.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__SandboxPolicy =
  | { readonly type: "dangerFullAccess" }
  | { readonly networkAccess?: boolean; readonly type: "readOnly" }
  | { readonly networkAccess?: "restricted" | "enabled"; readonly type: "externalSandbox" }
  | {
      readonly excludeSlashTmp?: boolean;
      readonly excludeTmpdirEnvVar?: boolean;
      readonly networkAccess?: boolean;
      readonly type: "workspaceWrite";
      readonly writableRoots?: ReadonlyArray<V2ThreadStartResponse__AbsolutePathBuf>;
    };
export const V2ThreadStartResponse__SandboxPolicy = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("dangerFullAccess").annotate({
        title: "DangerFullAccessSandboxPolicyType",
      }),
    }).annotate({ title: "DangerFullAccessSandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("readOnly").annotate({ title: "ReadOnlySandboxPolicyType" }),
    }).annotate({ title: "ReadOnlySandboxPolicy" }),
    Schema.Struct({
      networkAccess: Schema.optionalKey(
        Schema.Literals(["restricted", "enabled"]).annotate({ default: "restricted" }),
      ),
      type: Schema.Literal("externalSandbox").annotate({
        title: "ExternalSandboxSandboxPolicyType",
      }),
    }).annotate({ title: "ExternalSandboxSandboxPolicy" }),
    Schema.Struct({
      excludeSlashTmp: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      excludeTmpdirEnvVar: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      networkAccess: Schema.optionalKey(Schema.Boolean.annotate({ default: false })),
      type: Schema.Literal("workspaceWrite").annotate({ title: "WorkspaceWriteSandboxPolicyType" }),
      writableRoots: Schema.optionalKey(
        Schema.Array(V2ThreadStartResponse__AbsolutePathBuf).annotate({ default: [] }),
      ),
    }).annotate({ title: "WorkspaceWriteSandboxPolicy" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadStartResponse__SubAgentSource };
export const V2ThreadStartResponse__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadStartResponse__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadStartResponse__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadStartResponse__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadStartResponse__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadStartResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadStartResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadStatusChangedNotification = {
  readonly status: V2ThreadStatusChangedNotification__ThreadStatus;
  readonly threadId: string;
};
export const V2ThreadStatusChangedNotification = Schema.Struct({
  status: V2ThreadStatusChangedNotification__ThreadStatus,
  threadId: Schema.String,
}).annotate({ title: "ThreadStatusChangedNotification" });

export type V2ThreadTokenUsageUpdatedNotification = {
  readonly threadId: string;
  readonly tokenUsage: V2ThreadTokenUsageUpdatedNotification__ThreadTokenUsage;
  readonly turnId: string;
};
export const V2ThreadTokenUsageUpdatedNotification = Schema.Struct({
  threadId: Schema.String,
  tokenUsage: V2ThreadTokenUsageUpdatedNotification__ThreadTokenUsage,
  turnId: Schema.String,
}).annotate({ title: "ThreadTokenUsageUpdatedNotification" });

export type V2ThreadUnarchivedNotification = { readonly threadId: string };
export const V2ThreadUnarchivedNotification = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "ThreadUnarchivedNotification",
});

export type V2ThreadUnarchiveParams = { readonly threadId: string };
export const V2ThreadUnarchiveParams = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "ThreadUnarchiveParams",
});

export type V2ThreadUnarchiveResponse = { readonly thread: V2ThreadUnarchiveResponse__Thread };
export const V2ThreadUnarchiveResponse = Schema.Struct({
  thread: V2ThreadUnarchiveResponse__Thread,
}).annotate({ title: "ThreadUnarchiveResponse" });

export type V2ThreadUnarchiveResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2ThreadUnarchiveResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2ThreadUnarchiveResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2ThreadUnarchiveResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2ThreadUnarchiveResponse__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2ThreadUnarchiveResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2ThreadUnarchiveResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2ThreadUnarchiveResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2ThreadUnarchiveResponse__SessionSource =
  | "cli"
  | "vscode"
  | "exec"
  | "appServer"
  | "unknown"
  | { readonly custom: string }
  | { readonly subAgent: V2ThreadUnarchiveResponse__SubAgentSource };
export const V2ThreadUnarchiveResponse__SessionSource = Schema.Union(
  [
    Schema.Literals(["cli", "vscode", "exec", "appServer", "unknown"]),
    Schema.Struct({ custom: Schema.String }).annotate({ title: "CustomSessionSource" }),
    Schema.Struct({ subAgent: V2ThreadUnarchiveResponse__SubAgentSource }).annotate({
      title: "SubAgentSessionSource",
    }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadUnarchiveResponse__ThreadStatus =
  | { readonly type: "notLoaded" }
  | { readonly type: "idle" }
  | { readonly type: "systemError" }
  | {
      readonly activeFlags: ReadonlyArray<V2ThreadUnarchiveResponse__ThreadActiveFlag>;
      readonly type: "active";
    };
export const V2ThreadUnarchiveResponse__ThreadStatus = Schema.Union(
  [
    Schema.Struct({
      type: Schema.Literal("notLoaded").annotate({ title: "NotLoadedThreadStatusType" }),
    }).annotate({ title: "NotLoadedThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("idle").annotate({ title: "IdleThreadStatusType" }),
    }).annotate({ title: "IdleThreadStatus" }),
    Schema.Struct({
      type: Schema.Literal("systemError").annotate({ title: "SystemErrorThreadStatusType" }),
    }).annotate({ title: "SystemErrorThreadStatus" }),
    Schema.Struct({
      activeFlags: Schema.Array(V2ThreadUnarchiveResponse__ThreadActiveFlag),
      type: Schema.Literal("active").annotate({ title: "ActiveThreadStatusType" }),
    }).annotate({ title: "ActiveThreadStatus" }),
  ],
  { mode: "oneOf" },
);

export type V2ThreadUnarchiveResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2ThreadUnarchiveResponse__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2ThreadUnsubscribeParams = { readonly threadId: string };
export const V2ThreadUnsubscribeParams = Schema.Struct({ threadId: Schema.String }).annotate({
  title: "ThreadUnsubscribeParams",
});

export type V2ThreadUnsubscribeResponse = {
  readonly status: V2ThreadUnsubscribeResponse__ThreadUnsubscribeStatus;
};
export const V2ThreadUnsubscribeResponse = Schema.Struct({
  status: V2ThreadUnsubscribeResponse__ThreadUnsubscribeStatus,
}).annotate({ title: "ThreadUnsubscribeResponse" });

export type V2TurnCompletedNotification = {
  readonly threadId: string;
  readonly turn: V2TurnCompletedNotification__Turn;
};
export const V2TurnCompletedNotification = Schema.Struct({
  threadId: Schema.String,
  turn: V2TurnCompletedNotification__Turn,
}).annotate({ title: "TurnCompletedNotification" });

export type V2TurnCompletedNotification__ByteRange = {
  readonly end: number;
  readonly start: number;
};
export const V2TurnCompletedNotification__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2TurnCompletedNotification__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2TurnCompletedNotification__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2TurnCompletedNotification__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2TurnCompletedNotification__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnCompletedNotification__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2TurnCompletedNotification__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2TurnCompletedNotification__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2TurnCompletedNotification__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2TurnDiffUpdatedNotification = {
  readonly diff: string;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2TurnDiffUpdatedNotification = Schema.Struct({
  diff: Schema.String,
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({
  title: "TurnDiffUpdatedNotification",
  description:
    "Notification that the turn-level unified diff has changed. Contains the latest aggregated diff across all file changes in the turn.",
});

export type V2TurnInterruptParams = { readonly threadId: string; readonly turnId: string };
export const V2TurnInterruptParams = Schema.Struct({
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "TurnInterruptParams" });

export type V2TurnInterruptResponse = {};
export const V2TurnInterruptResponse = Schema.Struct({}).annotate({
  title: "TurnInterruptResponse",
});

export type V2TurnPlanUpdatedNotification = {
  readonly explanation?: string | null;
  readonly plan: ReadonlyArray<V2TurnPlanUpdatedNotification__TurnPlanStep>;
  readonly threadId: string;
  readonly turnId: string;
};
export const V2TurnPlanUpdatedNotification = Schema.Struct({
  explanation: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  plan: Schema.Array(V2TurnPlanUpdatedNotification__TurnPlanStep),
  threadId: Schema.String,
  turnId: Schema.String,
}).annotate({ title: "TurnPlanUpdatedNotification" });

export type V2TurnStartedNotification = {
  readonly threadId: string;
  readonly turn: V2TurnStartedNotification__Turn;
};
export const V2TurnStartedNotification = Schema.Struct({
  threadId: Schema.String,
  turn: V2TurnStartedNotification__Turn,
}).annotate({ title: "TurnStartedNotification" });

export type V2TurnStartedNotification__ByteRange = { readonly end: number; readonly start: number };
export const V2TurnStartedNotification__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2TurnStartedNotification__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2TurnStartedNotification__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2TurnStartedNotification__CollabAgentToolCallStatus =
  | "inProgress"
  | "completed"
  | "failed";
export const V2TurnStartedNotification__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnStartedNotification__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2TurnStartedNotification__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2TurnStartedNotification__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2TurnStartedNotification__TurnItemsView = Schema.Literals([
  "notLoaded",
  "summary",
  "full",
]);

export type V2TurnStartParams = {
  readonly approvalPolicy?: V2TurnStartParams__AskForApproval | null;
  readonly approvalsReviewer?: V2TurnStartParams__ApprovalsReviewer | null;
  readonly cwd?: string | null;
  readonly effort?: V2TurnStartParams__ReasoningEffort | null;
  readonly input: ReadonlyArray<V2TurnStartParams__UserInput>;
  readonly model?: string | null;
  readonly outputSchema?: unknown;
  readonly personality?: V2TurnStartParams__Personality | null;
  readonly sandboxPolicy?: V2TurnStartParams__SandboxPolicy | null;
  readonly serviceTier?: string | null;
  readonly summary?: V2TurnStartParams__ReasoningSummary | null;
  readonly threadId: string;
};
export const V2TurnStartParams = Schema.Struct({
  approvalPolicy: Schema.optionalKey(
    Schema.Union([V2TurnStartParams__AskForApproval, Schema.Null]).annotate({
      description: "Override the approval policy for this turn and subsequent turns.",
    }),
  ),
  approvalsReviewer: Schema.optionalKey(
    Schema.Union([V2TurnStartParams__ApprovalsReviewer, Schema.Null]).annotate({
      description:
        "Override where approval requests are routed for review on this turn and subsequent turns.",
    }),
  ),
  cwd: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Override the working directory for this turn and subsequent turns.",
      }),
      Schema.Null,
    ]),
  ),
  effort: Schema.optionalKey(
    Schema.Union([V2TurnStartParams__ReasoningEffort, Schema.Null]).annotate({
      description: "Override the reasoning effort for this turn and subsequent turns.",
    }),
  ),
  input: Schema.Array(V2TurnStartParams__UserInput),
  model: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Override the model for this turn and subsequent turns.",
      }),
      Schema.Null,
    ]),
  ),
  outputSchema: Schema.optionalKey(
    Schema.Unknown.annotate({
      description:
        "Optional JSON Schema used to constrain the final assistant message for this turn.",
    }),
  ),
  personality: Schema.optionalKey(
    Schema.Union([V2TurnStartParams__Personality, Schema.Null]).annotate({
      description: "Override the personality for this turn and subsequent turns.",
    }),
  ),
  sandboxPolicy: Schema.optionalKey(
    Schema.Union([V2TurnStartParams__SandboxPolicy, Schema.Null]).annotate({
      description: "Override the sandbox policy for this turn and subsequent turns.",
    }),
  ),
  serviceTier: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Override the service tier for this turn and subsequent turns.",
      }),
      Schema.Null,
    ]),
  ),
  summary: Schema.optionalKey(
    Schema.Union([V2TurnStartParams__ReasoningSummary, Schema.Null]).annotate({
      description: "Override the reasoning summary for this turn and subsequent turns.",
    }),
  ),
  threadId: Schema.String,
}).annotate({ title: "TurnStartParams" });

export type V2TurnStartParams__ByteRange = { readonly end: number; readonly start: number };
export const V2TurnStartParams__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2TurnStartParams__CollaborationMode = {
  readonly mode: V2TurnStartParams__ModeKind;
  readonly settings: V2TurnStartParams__Settings;
};
export const V2TurnStartParams__CollaborationMode = Schema.Struct({
  mode: V2TurnStartParams__ModeKind,
  settings: V2TurnStartParams__Settings,
}).annotate({ description: "Collaboration mode for a Codex session." });

export type V2TurnStartParams__NetworkAccess = "restricted" | "enabled";
export const V2TurnStartParams__NetworkAccess = Schema.Literals(["restricted", "enabled"]);

export type V2TurnStartParams__PermissionProfileSelectionParams = {
  readonly id: string;
  readonly modifications?: ReadonlyArray<V2TurnStartParams__PermissionProfileModificationParams> | null;
  readonly type: "profile";
};
export const V2TurnStartParams__PermissionProfileSelectionParams = Schema.Union(
  [
    Schema.Struct({
      id: Schema.String,
      modifications: Schema.optionalKey(
        Schema.Union([
          Schema.Array(V2TurnStartParams__PermissionProfileModificationParams),
          Schema.Null,
        ]),
      ),
      type: Schema.Literal("profile").annotate({
        title: "ProfilePermissionProfileSelectionParamsType",
      }),
    }).annotate({
      title: "ProfilePermissionProfileSelectionParams",
      description:
        "Select a named built-in or user-defined profile and optionally apply bounded modifications that Codex knows how to validate.",
    }),
  ],
  { mode: "oneOf" },
);

export type V2TurnStartParams__TurnEnvironmentParams = {
  readonly cwd: V2TurnStartParams__AbsolutePathBuf;
  readonly environmentId: string;
};
export const V2TurnStartParams__TurnEnvironmentParams = Schema.Struct({
  cwd: V2TurnStartParams__AbsolutePathBuf,
  environmentId: Schema.String,
});

export type V2TurnStartResponse = { readonly turn: V2TurnStartResponse__Turn };
export const V2TurnStartResponse = Schema.Struct({ turn: V2TurnStartResponse__Turn }).annotate({
  title: "TurnStartResponse",
});

export type V2TurnStartResponse__ByteRange = { readonly end: number; readonly start: number };
export const V2TurnStartResponse__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2TurnStartResponse__CollabAgentTool =
  | "spawnAgent"
  | "sendInput"
  | "resumeAgent"
  | "wait"
  | "closeAgent";
export const V2TurnStartResponse__CollabAgentTool = Schema.Literals([
  "spawnAgent",
  "sendInput",
  "resumeAgent",
  "wait",
  "closeAgent",
]);

export type V2TurnStartResponse__CollabAgentToolCallStatus = "inProgress" | "completed" | "failed";
export const V2TurnStartResponse__CollabAgentToolCallStatus = Schema.Literals([
  "inProgress",
  "completed",
  "failed",
]);

export type V2TurnStartResponse__CommandExecutionSource =
  | "agent"
  | "userShell"
  | "unifiedExecStartup"
  | "unifiedExecInteraction";
export const V2TurnStartResponse__CommandExecutionSource = Schema.Literals([
  "agent",
  "userShell",
  "unifiedExecStartup",
  "unifiedExecInteraction",
]);

export type V2TurnStartResponse__TurnItemsView = "notLoaded" | "summary" | "full";
export const V2TurnStartResponse__TurnItemsView = Schema.Literals(["notLoaded", "summary", "full"]);

export type V2TurnSteerParams = {
  readonly expectedTurnId: string;
  readonly input: ReadonlyArray<V2TurnSteerParams__UserInput>;
  readonly threadId: string;
};
export const V2TurnSteerParams = Schema.Struct({
  expectedTurnId: Schema.String.annotate({
    description:
      "Required active turn id precondition. The request fails when it does not match the currently active turn.",
  }),
  input: Schema.Array(V2TurnSteerParams__UserInput),
  threadId: Schema.String,
}).annotate({ title: "TurnSteerParams" });

export type V2TurnSteerParams__ByteRange = { readonly end: number; readonly start: number };
export const V2TurnSteerParams__ByteRange = Schema.Struct({
  end: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  start: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
});

export type V2TurnSteerResponse = { readonly turnId: string };
export const V2TurnSteerResponse = Schema.Struct({ turnId: Schema.String }).annotate({
  title: "TurnSteerResponse",
});

export type V2WarningNotification = { readonly message: string; readonly threadId?: string | null };
export const V2WarningNotification = Schema.Struct({
  message: Schema.String.annotate({ description: "Concise warning message for the user." }),
  threadId: Schema.optionalKey(
    Schema.Union([
      Schema.String.annotate({
        description: "Optional thread target when the warning applies to a specific thread.",
      }),
      Schema.Null,
    ]),
  ),
}).annotate({ title: "WarningNotification" });

export type V2WindowsSandboxReadinessResponse = {
  readonly status: V2WindowsSandboxReadinessResponse__WindowsSandboxReadiness;
};
export const V2WindowsSandboxReadinessResponse = Schema.Struct({
  status: V2WindowsSandboxReadinessResponse__WindowsSandboxReadiness,
}).annotate({ title: "WindowsSandboxReadinessResponse" });

export type V2WindowsSandboxSetupCompletedNotification = {
  readonly error?: string | null;
  readonly mode: V2WindowsSandboxSetupCompletedNotification__WindowsSandboxSetupMode;
  readonly success: boolean;
};
export const V2WindowsSandboxSetupCompletedNotification = Schema.Struct({
  error: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
  mode: V2WindowsSandboxSetupCompletedNotification__WindowsSandboxSetupMode,
  success: Schema.Boolean,
}).annotate({ title: "WindowsSandboxSetupCompletedNotification" });

export type V2WindowsSandboxSetupStartParams = {
  readonly cwd?: V2WindowsSandboxSetupStartParams__AbsolutePathBuf | null;
  readonly mode: V2WindowsSandboxSetupStartParams__WindowsSandboxSetupMode;
};
export const V2WindowsSandboxSetupStartParams = Schema.Struct({
  cwd: Schema.optionalKey(
    Schema.Union([V2WindowsSandboxSetupStartParams__AbsolutePathBuf, Schema.Null]),
  ),
  mode: V2WindowsSandboxSetupStartParams__WindowsSandboxSetupMode,
}).annotate({ title: "WindowsSandboxSetupStartParams" });

export type V2WindowsSandboxSetupStartResponse = { readonly started: boolean };
export const V2WindowsSandboxSetupStartResponse = Schema.Struct({
  started: Schema.Boolean,
}).annotate({ title: "WindowsSandboxSetupStartResponse" });

export type V2WindowsWorldWritableWarningNotification = {
  readonly extraCount: number;
  readonly failedScan: boolean;
  readonly samplePaths: ReadonlyArray<string>;
};
export const V2WindowsWorldWritableWarningNotification = Schema.Struct({
  extraCount: Schema.Number.annotate({ format: "uint" })
    .check(Schema.isInt())
    .check(Schema.isGreaterThanOrEqualTo(0)),
  failedScan: Schema.Boolean,
  samplePaths: Schema.Array(Schema.String),
}).annotate({ title: "WindowsWorldWritableWarningNotification" });
