// GENERATED by tools/gen — DO NOT EDIT.

///|
fn json_array_matches(value : Json, predicate : (Json) -> Bool) -> Bool {
  match value {
    @json.Json::Array(items) => items.length() > 0 && items.all(predicate)
    _ => false
  }
}

///|
fn[T : @json.FromJson] required_field(
  obj : Map[String, Json],
  key : String,
  path : @json.JsonPath,
) -> T raise @json.JsonDecodeError {
  let field_path = path.add_key(key)
  match obj.get(key) {
    Option::None =>
      raise @json.JsonDecodeError::JsonDecodeError(
        (field_path, "required だが欠落: " + field_path.to_string()),
      )
    Option::Some(value) => @json.from_json(value, path=field_path)
  }
}

///|
fn[T] nullable_presence(value : T?) -> @sdkjson.Presence[T] {
  match value {
    Option::Some(value) => @sdkjson.Presence::Value(value)
    Option::None => @sdkjson.Presence::Null
  }
}

///|
fn[T : @json.FromJson] decode_nullable_field(
  obj : Map[String, Json],
  key : String,
  path : @json.JsonPath,
) -> T? raise @json.JsonDecodeError {
  let raw : Json = required_field(obj, key, path)
  match raw {
    @json.Json::Null => Option::None
    value => Option::Some(@json.from_json(value, path=path.add_key(key)))
  }
}

///|
/// A required field with a non-null default in the spec: absent decodes as that default.
fn[T : @json.FromJson] decode_defaulted_field(
  obj : Map[String, Json],
  key : String,
  path : @json.JsonPath,
  default : Json,
) -> T raise @json.JsonDecodeError {
  match obj.get(key) {
    Option::Some(value) => @json.from_json(value, path=path.add_key(key))
    Option::None => @json.from_json(default, path=path.add_key(key))
  }
}

///|
///
/// Generated representation of APIError.
#derive(Eq, @debug.Debug)
pub(all) struct APIError {
  message : String
  type_ : String
}

///|
pub extend APIError with Eq::{equal, not_equal}

///|
pub extend APIError with @debug.Debug::{to_repr}

///|
///
/// Creates a APIError with omitted optional fields absent.
pub fn APIError::new(message~ : String, type_~ : String) -> APIError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend APIError with ToJson::{to_json}

///|
pub impl ToJson for APIError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend APIError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for APIError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Specifies who can invoke a tool. Values: direct: The model can call this tool directly. code_execution_20250825: The tool can be called from the code execution environment (v1). code_execution_20260120: The tool can be called from the code execution environment (v2 with persistence). code_execution_20260521: The tool can be called from the code execution environment (v2 with persistence).
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum AllowedCaller {
  Direct
  CodeExecution20250825
  CodeExecution20260120
  CodeExecution20260521
  Custom(String)
}

///|
pub extend AllowedCaller with Eq::{equal, not_equal}

///|
pub extend AllowedCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend AllowedCaller with ToJson::{to_json}

///|
pub impl ToJson for AllowedCaller with fn to_json(self) {
  let raw = match self {
    AllowedCaller::Direct => "direct"
    AllowedCaller::CodeExecution20250825 => "code_execution_20250825"
    AllowedCaller::CodeExecution20260120 => "code_execution_20260120"
    AllowedCaller::CodeExecution20260521 => "code_execution_20260521"
    AllowedCaller::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend AllowedCaller with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for AllowedCaller with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "direct" => Option::Some(AllowedCaller::Direct)
        "code_execution_20250825" =>
          Option::Some(AllowedCaller::CodeExecution20250825)
        "code_execution_20260120" =>
          Option::Some(AllowedCaller::CodeExecution20260120)
        "code_execution_20260521" =>
          Option::Some(AllowedCaller::CodeExecution20260521)
        _ => Option::None
      }
    },
    raw => AllowedCaller::Custom(raw),
  )
}

///|
///
/// The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CacheControlEphemeralTtl {
  Value5m
  Value1h
  Custom(String)
}

///|
pub extend CacheControlEphemeralTtl with Eq::{equal, not_equal}

///|
pub extend CacheControlEphemeralTtl with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend CacheControlEphemeralTtl with ToJson::{to_json}

///|
pub impl ToJson for CacheControlEphemeralTtl with fn to_json(self) {
  let raw = match self {
    CacheControlEphemeralTtl::Value5m => "5m"
    CacheControlEphemeralTtl::Value1h => "1h"
    CacheControlEphemeralTtl::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend CacheControlEphemeralTtl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheControlEphemeralTtl with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "5m" => Option::Some(CacheControlEphemeralTtl::Value5m)
        "1h" => Option::Some(CacheControlEphemeralTtl::Value1h)
        _ => Option::None
      }
    },
    raw => CacheControlEphemeralTtl::Custom(raw),
  )
}

///|
///
/// Generated representation of CacheControlEphemeral.
#derive(Eq, @debug.Debug)
pub(all) struct CacheControlEphemeral {
  ttl : CacheControlEphemeralTtl?
  type_ : String
}

///|
pub extend CacheControlEphemeral with Eq::{equal, not_equal}

///|
pub extend CacheControlEphemeral with @debug.Debug::{to_repr}

///|
///
/// Creates a CacheControlEphemeral with omitted optional fields absent.
pub fn CacheControlEphemeral::new(
  type_~ : String,
  ttl? : CacheControlEphemeralTtl,
) -> CacheControlEphemeral {
  { ttl, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend CacheControlEphemeral with ToJson::{to_json}

///|
pub impl ToJson for CacheControlEphemeral with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("ttl", self.ttl)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CacheControlEphemeral with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheControlEphemeral with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    ttl: @sdkjson.opt_field(obj, "ttl", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestBashCodeExecutionToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestBashCodeExecutionToolResultBlockCacheControl with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestBashCodeExecutionToolResultBlockCacheControl with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestBashCodeExecutionToolResultBlockCacheControl with ToJson::{
  to_json,
}

///|
pub impl ToJson for RequestBashCodeExecutionToolResultBlockCacheControl with fn to_json(
  self,
) {
  match self {
    RequestBashCodeExecutionToolResultBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestBashCodeExecutionToolResultBlockCacheControl::Unknown(_, value) =>
      value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestBashCodeExecutionToolResultBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestBashCodeExecutionToolResultBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestBashCodeExecutionToolResultBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other =>
      RequestBashCodeExecutionToolResultBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated string enum BashCodeExecutionToolResultErrorCode.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum BashCodeExecutionToolResultErrorCode {
  InvalidToolInput
  Unavailable
  TooManyRequests
  ExecutionTimeExceeded
  OutputFileTooLarge
  Unknown(String)
}

///|
pub extend BashCodeExecutionToolResultErrorCode with Eq::{equal, not_equal}

///|
pub extend BashCodeExecutionToolResultErrorCode with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend BashCodeExecutionToolResultErrorCode with ToJson::{to_json}

///|
pub impl ToJson for BashCodeExecutionToolResultErrorCode with fn to_json(self) {
  let raw = match self {
    BashCodeExecutionToolResultErrorCode::InvalidToolInput =>
      "invalid_tool_input"
    BashCodeExecutionToolResultErrorCode::Unavailable => "unavailable"
    BashCodeExecutionToolResultErrorCode::TooManyRequests => "too_many_requests"
    BashCodeExecutionToolResultErrorCode::ExecutionTimeExceeded =>
      "execution_time_exceeded"
    BashCodeExecutionToolResultErrorCode::OutputFileTooLarge =>
      "output_file_too_large"
    BashCodeExecutionToolResultErrorCode::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend BashCodeExecutionToolResultErrorCode with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BashCodeExecutionToolResultErrorCode with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "invalid_tool_input" =>
          Option::Some(BashCodeExecutionToolResultErrorCode::InvalidToolInput)
        "unavailable" =>
          Option::Some(BashCodeExecutionToolResultErrorCode::Unavailable)
        "too_many_requests" =>
          Option::Some(BashCodeExecutionToolResultErrorCode::TooManyRequests)
        "execution_time_exceeded" =>
          Option::Some(
            BashCodeExecutionToolResultErrorCode::ExecutionTimeExceeded,
          )
        "output_file_too_large" =>
          Option::Some(BashCodeExecutionToolResultErrorCode::OutputFileTooLarge)
        _ => Option::None
      }
    },
    raw => BashCodeExecutionToolResultErrorCode::Unknown(raw),
  )
}

///|
///
/// Generated representation of RequestBashCodeExecutionToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct RequestBashCodeExecutionToolResultError {
  error_code : BashCodeExecutionToolResultErrorCode
  type_ : String
}

///|
pub extend RequestBashCodeExecutionToolResultError with Eq::{equal, not_equal}

///|
pub extend RequestBashCodeExecutionToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestBashCodeExecutionToolResultError with omitted optional fields absent.
pub fn RequestBashCodeExecutionToolResultError::new(
  error_code~ : BashCodeExecutionToolResultErrorCode,
  type_~ : String,
) -> RequestBashCodeExecutionToolResultError {
  { error_code, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestBashCodeExecutionToolResultError with ToJson::{to_json}

///|
pub impl ToJson for RequestBashCodeExecutionToolResultError with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestBashCodeExecutionToolResultError with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestBashCodeExecutionToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestBashCodeExecutionOutputBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestBashCodeExecutionOutputBlock {
  file_id : String
}

///|
pub extend RequestBashCodeExecutionOutputBlock with Eq::{equal, not_equal}

///|
pub extend RequestBashCodeExecutionOutputBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestBashCodeExecutionOutputBlock with omitted optional fields absent.
pub fn RequestBashCodeExecutionOutputBlock::new(
  file_id~ : String,
) -> RequestBashCodeExecutionOutputBlock {
  { file_id, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestBashCodeExecutionOutputBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestBashCodeExecutionOutputBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("file_id", self.file_id)
  .field("type", "bash_code_execution_output")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestBashCodeExecutionOutputBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestBashCodeExecutionOutputBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { file_id: required_field(obj, "file_id", path), }
}

///|
///
/// Generated representation of RequestBashCodeExecutionResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestBashCodeExecutionResultBlock {
  content : Array[RequestBashCodeExecutionOutputBlock]
  return_code : Int32
  stderr : String
  stdout : String
  type_ : String
}

///|
pub extend RequestBashCodeExecutionResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestBashCodeExecutionResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestBashCodeExecutionResultBlock with omitted optional fields absent.
pub fn RequestBashCodeExecutionResultBlock::new(
  content~ : Array[RequestBashCodeExecutionOutputBlock],
  return_code~ : Int32,
  stderr~ : String,
  stdout~ : String,
  type_~ : String,
) -> RequestBashCodeExecutionResultBlock {
  { content, return_code, stderr, stdout, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestBashCodeExecutionResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestBashCodeExecutionResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("return_code", self.return_code)
  .field("stderr", self.stderr)
  .field("stdout", self.stdout)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestBashCodeExecutionResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestBashCodeExecutionResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    return_code: required_field(obj, "return_code", path),
    stderr: required_field(obj, "stderr", path),
    stdout: required_field(obj, "stdout", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union RequestBashCodeExecutionToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestBashCodeExecutionToolResultBlockContent {
  BashCodeExecutionToolResultError(RequestBashCodeExecutionToolResultError)
  BashCodeExecutionResult(RequestBashCodeExecutionResultBlock)
  Unknown(String, Json)
}

///|
pub extend RequestBashCodeExecutionToolResultBlockContent with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestBashCodeExecutionToolResultBlockContent with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestBashCodeExecutionToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for RequestBashCodeExecutionToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    RequestBashCodeExecutionToolResultBlockContent::BashCodeExecutionToolResultError(
      value,
    ) => @json.Json::Json(value)
    RequestBashCodeExecutionToolResultBlockContent::BashCodeExecutionResult(
      value,
    ) => @json.Json::Json(value)
    RequestBashCodeExecutionToolResultBlockContent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestBashCodeExecutionToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestBashCodeExecutionToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "bash_code_execution_tool_result_error" =>
      RequestBashCodeExecutionToolResultBlockContent::BashCodeExecutionToolResultError(
        @json.from_json(value, path~),
      )
    "bash_code_execution_result" =>
      RequestBashCodeExecutionToolResultBlockContent::BashCodeExecutionResult(
        @json.from_json(value, path~),
      )
    other =>
      RequestBashCodeExecutionToolResultBlockContent::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestBashCodeExecutionToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestBashCodeExecutionToolResultBlock {
  cache_control : @sdkjson.Presence[
    RequestBashCodeExecutionToolResultBlockCacheControl,
  ]
  content : RequestBashCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend RequestBashCodeExecutionToolResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestBashCodeExecutionToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestBashCodeExecutionToolResultBlock with omitted optional fields absent.
pub fn RequestBashCodeExecutionToolResultBlock::new(
  content~ : RequestBashCodeExecutionToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
  cache_control? : RequestBashCodeExecutionToolResultBlockCacheControl,
) -> RequestBashCodeExecutionToolResultBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    content,
    tool_use_id,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestBashCodeExecutionToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestBashCodeExecutionToolResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestBashCodeExecutionToolResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestBashCodeExecutionToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestCodeExecutionToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestCodeExecutionToolResultBlockCacheControl with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestCodeExecutionToolResultBlockCacheControl with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestCodeExecutionToolResultBlockCacheControl with ToJson::{
  to_json,
}

///|
pub impl ToJson for RequestCodeExecutionToolResultBlockCacheControl with fn to_json(
  self,
) {
  match self {
    RequestCodeExecutionToolResultBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestCodeExecutionToolResultBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestCodeExecutionToolResultBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestCodeExecutionToolResultBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestCodeExecutionToolResultBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other =>
      RequestCodeExecutionToolResultBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated string enum CodeExecutionToolResultErrorCode.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CodeExecutionToolResultErrorCode {
  InvalidToolInput
  Unavailable
  TooManyRequests
  ExecutionTimeExceeded
  Unknown(String)
}

///|
pub extend CodeExecutionToolResultErrorCode with Eq::{equal, not_equal}

///|
pub extend CodeExecutionToolResultErrorCode with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend CodeExecutionToolResultErrorCode with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionToolResultErrorCode with fn to_json(self) {
  let raw = match self {
    CodeExecutionToolResultErrorCode::InvalidToolInput => "invalid_tool_input"
    CodeExecutionToolResultErrorCode::Unavailable => "unavailable"
    CodeExecutionToolResultErrorCode::TooManyRequests => "too_many_requests"
    CodeExecutionToolResultErrorCode::ExecutionTimeExceeded =>
      "execution_time_exceeded"
    CodeExecutionToolResultErrorCode::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend CodeExecutionToolResultErrorCode with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CodeExecutionToolResultErrorCode with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "invalid_tool_input" =>
          Option::Some(CodeExecutionToolResultErrorCode::InvalidToolInput)
        "unavailable" =>
          Option::Some(CodeExecutionToolResultErrorCode::Unavailable)
        "too_many_requests" =>
          Option::Some(CodeExecutionToolResultErrorCode::TooManyRequests)
        "execution_time_exceeded" =>
          Option::Some(CodeExecutionToolResultErrorCode::ExecutionTimeExceeded)
        _ => Option::None
      }
    },
    raw => CodeExecutionToolResultErrorCode::Unknown(raw),
  )
}

///|
///
/// Generated representation of RequestCodeExecutionToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct RequestCodeExecutionToolResultError {
  error_code : CodeExecutionToolResultErrorCode
  type_ : String
}

///|
pub extend RequestCodeExecutionToolResultError with Eq::{equal, not_equal}

///|
pub extend RequestCodeExecutionToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestCodeExecutionToolResultError with omitted optional fields absent.
pub fn RequestCodeExecutionToolResultError::new(
  error_code~ : CodeExecutionToolResultErrorCode,
  type_~ : String,
) -> RequestCodeExecutionToolResultError {
  { error_code, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestCodeExecutionToolResultError with ToJson::{to_json}

///|
pub impl ToJson for RequestCodeExecutionToolResultError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestCodeExecutionToolResultError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestCodeExecutionToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestCodeExecutionOutputBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestCodeExecutionOutputBlock {
  file_id : String
}

///|
pub extend RequestCodeExecutionOutputBlock with Eq::{equal, not_equal}

///|
pub extend RequestCodeExecutionOutputBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestCodeExecutionOutputBlock with omitted optional fields absent.
pub fn RequestCodeExecutionOutputBlock::new(
  file_id~ : String,
) -> RequestCodeExecutionOutputBlock {
  { file_id, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestCodeExecutionOutputBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestCodeExecutionOutputBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("file_id", self.file_id)
  .field("type", "code_execution_output")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestCodeExecutionOutputBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestCodeExecutionOutputBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { file_id: required_field(obj, "file_id", path), }
}

///|
///
/// Generated representation of RequestCodeExecutionResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestCodeExecutionResultBlock {
  content : Array[RequestCodeExecutionOutputBlock]
  return_code : Int32
  stderr : String
  stdout : String
  type_ : String
}

///|
pub extend RequestCodeExecutionResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestCodeExecutionResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestCodeExecutionResultBlock with omitted optional fields absent.
pub fn RequestCodeExecutionResultBlock::new(
  content~ : Array[RequestCodeExecutionOutputBlock],
  return_code~ : Int32,
  stderr~ : String,
  stdout~ : String,
  type_~ : String,
) -> RequestCodeExecutionResultBlock {
  { content, return_code, stderr, stdout, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestCodeExecutionResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestCodeExecutionResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("return_code", self.return_code)
  .field("stderr", self.stderr)
  .field("stdout", self.stdout)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestCodeExecutionResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestCodeExecutionResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    return_code: required_field(obj, "return_code", path),
    stderr: required_field(obj, "stderr", path),
    stdout: required_field(obj, "stdout", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// The output and exit code of Python code that Claude ran with the code execution tool, with standard output in encrypted form, sent back in a later request.
#derive(Eq, @debug.Debug)
pub(all) struct RequestEncryptedCodeExecutionResultBlock {
  content : Array[RequestCodeExecutionOutputBlock]
  encrypted_stdout : String
  return_code : Int32
  stderr : String
  type_ : String
}

///|
pub extend RequestEncryptedCodeExecutionResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestEncryptedCodeExecutionResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestEncryptedCodeExecutionResultBlock with omitted optional fields absent.
pub fn RequestEncryptedCodeExecutionResultBlock::new(
  content~ : Array[RequestCodeExecutionOutputBlock],
  encrypted_stdout~ : String,
  return_code~ : Int32,
  stderr~ : String,
  type_~ : String,
) -> RequestEncryptedCodeExecutionResultBlock {
  { content, encrypted_stdout, return_code, stderr, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestEncryptedCodeExecutionResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestEncryptedCodeExecutionResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("encrypted_stdout", self.encrypted_stdout)
  .field("return_code", self.return_code)
  .field("stderr", self.stderr)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestEncryptedCodeExecutionResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestEncryptedCodeExecutionResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    encrypted_stdout: required_field(obj, "encrypted_stdout", path),
    return_code: required_field(obj, "return_code", path),
    stderr: required_field(obj, "stderr", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union RequestCodeExecutionToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestCodeExecutionToolResultBlockContent {
  CodeExecutionToolResultError(RequestCodeExecutionToolResultError)
  CodeExecutionResult(RequestCodeExecutionResultBlock)
  EncryptedCodeExecutionResult(RequestEncryptedCodeExecutionResultBlock)
  Unknown(String, Json)
}

///|
pub extend RequestCodeExecutionToolResultBlockContent with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestCodeExecutionToolResultBlockContent with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestCodeExecutionToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for RequestCodeExecutionToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    RequestCodeExecutionToolResultBlockContent::CodeExecutionToolResultError(
      value,
    ) => @json.Json::Json(value)
    RequestCodeExecutionToolResultBlockContent::CodeExecutionResult(value) =>
      @json.Json::Json(value)
    RequestCodeExecutionToolResultBlockContent::EncryptedCodeExecutionResult(
      value,
    ) => @json.Json::Json(value)
    RequestCodeExecutionToolResultBlockContent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestCodeExecutionToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestCodeExecutionToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_tool_result_error" =>
      RequestCodeExecutionToolResultBlockContent::CodeExecutionToolResultError(
        @json.from_json(value, path~),
      )
    "code_execution_result" =>
      RequestCodeExecutionToolResultBlockContent::CodeExecutionResult(
        @json.from_json(value, path~),
      )
    "encrypted_code_execution_result" =>
      RequestCodeExecutionToolResultBlockContent::EncryptedCodeExecutionResult(
        @json.from_json(value, path~),
      )
    other => RequestCodeExecutionToolResultBlockContent::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestCodeExecutionToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestCodeExecutionToolResultBlock {
  cache_control : @sdkjson.Presence[
    RequestCodeExecutionToolResultBlockCacheControl,
  ]
  content : RequestCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend RequestCodeExecutionToolResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestCodeExecutionToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestCodeExecutionToolResultBlock with omitted optional fields absent.
pub fn RequestCodeExecutionToolResultBlock::new(
  content~ : RequestCodeExecutionToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
  cache_control? : RequestCodeExecutionToolResultBlockCacheControl,
) -> RequestCodeExecutionToolResultBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    content,
    tool_use_id,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestCodeExecutionToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestCodeExecutionToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestCodeExecutionToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestCodeExecutionToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestContainerUploadBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestContainerUploadBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestContainerUploadBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestContainerUploadBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestContainerUploadBlockCacheControl with fn to_json(
  self,
) {
  match self {
    RequestContainerUploadBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestContainerUploadBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestContainerUploadBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestContainerUploadBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestContainerUploadBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestContainerUploadBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory.
#derive(Eq, @debug.Debug)
pub(all) struct RequestContainerUploadBlock {
  cache_control : @sdkjson.Presence[RequestContainerUploadBlockCacheControl]
  file_id : String
  type_ : String
}

///|
pub extend RequestContainerUploadBlock with Eq::{equal, not_equal}

///|
pub extend RequestContainerUploadBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestContainerUploadBlock with omitted optional fields absent.
pub fn RequestContainerUploadBlock::new(
  file_id~ : String,
  type_~ : String,
  cache_control? : RequestContainerUploadBlockCacheControl,
) -> RequestContainerUploadBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    file_id,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestContainerUploadBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestContainerUploadBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .field("file_id", self.file_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestContainerUploadBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestContainerUploadBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    file_id: required_field(obj, "file_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestDocumentBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestDocumentBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestDocumentBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestDocumentBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestDocumentBlockCacheControl with fn to_json(self) {
  match self {
    RequestDocumentBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestDocumentBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestDocumentBlockCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestDocumentBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestDocumentBlockCacheControl::Ephemeral(@json.from_json(value, path~))
    other => RequestDocumentBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestCitationsConfig.
#derive(Eq, @debug.Debug)
pub(all) struct RequestCitationsConfig {
  enabled : Bool?
}

///|
pub extend RequestCitationsConfig with Eq::{equal, not_equal}

///|
pub extend RequestCitationsConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestCitationsConfig with omitted optional fields absent.
pub fn RequestCitationsConfig::new(enabled? : Bool) -> RequestCitationsConfig {
  { enabled, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestCitationsConfig with ToJson::{to_json}

///|
pub impl ToJson for RequestCitationsConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new().opt("enabled", self.enabled).build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestCitationsConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestCitationsConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { enabled: @sdkjson.opt_field(obj, "enabled", path), }
}

///|
///
/// Generated representation of Base64PDFSource.
#derive(Eq, @debug.Debug)
pub(all) struct Base64PDFSource {
  data : String
  type_ : String
}

///|
pub extend Base64PDFSource with Eq::{equal, not_equal}

///|
pub extend Base64PDFSource with @debug.Debug::{to_repr}

///|
///
/// Creates a Base64PDFSource with omitted optional fields absent.
pub fn Base64PDFSource::new(data~ : String, type_~ : String) -> Base64PDFSource {
  { data, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend Base64PDFSource with ToJson::{to_json}

///|
pub impl ToJson for Base64PDFSource with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("data", self.data)
  .field("media_type", "application/pdf")
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend Base64PDFSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Base64PDFSource with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    data: required_field(obj, "data", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestImageBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestImageBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestImageBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestImageBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestImageBlockCacheControl with fn to_json(self) {
  match self {
    RequestImageBlockCacheControl::Ephemeral(value) => @json.Json::Json(value)
    RequestImageBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestImageBlockCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestImageBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestImageBlockCacheControl::Ephemeral(@json.from_json(value, path~))
    other => RequestImageBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated string enum Base64ImageSourceMediaType.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum Base64ImageSourceMediaType {
  ImageJpeg
  ImagePng
  ImageGif
  ImageWebp
  Custom(String)
}

///|
pub extend Base64ImageSourceMediaType with Eq::{equal, not_equal}

///|
pub extend Base64ImageSourceMediaType with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend Base64ImageSourceMediaType with ToJson::{to_json}

///|
pub impl ToJson for Base64ImageSourceMediaType with fn to_json(self) {
  let raw = match self {
    Base64ImageSourceMediaType::ImageJpeg => "image/jpeg"
    Base64ImageSourceMediaType::ImagePng => "image/png"
    Base64ImageSourceMediaType::ImageGif => "image/gif"
    Base64ImageSourceMediaType::ImageWebp => "image/webp"
    Base64ImageSourceMediaType::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend Base64ImageSourceMediaType with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Base64ImageSourceMediaType with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "image/jpeg" => Option::Some(Base64ImageSourceMediaType::ImageJpeg)
        "image/png" => Option::Some(Base64ImageSourceMediaType::ImagePng)
        "image/gif" => Option::Some(Base64ImageSourceMediaType::ImageGif)
        "image/webp" => Option::Some(Base64ImageSourceMediaType::ImageWebp)
        _ => Option::None
      }
    },
    raw => Base64ImageSourceMediaType::Custom(raw),
  )
}

///|
///
/// Generated representation of Base64ImageSource.
#derive(Eq, @debug.Debug)
pub(all) struct Base64ImageSource {
  data : String
  media_type : Base64ImageSourceMediaType
  type_ : String
}

///|
pub extend Base64ImageSource with Eq::{equal, not_equal}

///|
pub extend Base64ImageSource with @debug.Debug::{to_repr}

///|
///
/// Creates a Base64ImageSource with omitted optional fields absent.
pub fn Base64ImageSource::new(
  data~ : String,
  media_type~ : Base64ImageSourceMediaType,
  type_~ : String,
) -> Base64ImageSource {
  { data, media_type, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend Base64ImageSource with ToJson::{to_json}

///|
pub impl ToJson for Base64ImageSource with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("data", self.data)
  .field("media_type", self.media_type)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend Base64ImageSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Base64ImageSource with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    data: required_field(obj, "data", path),
    media_type: required_field(obj, "media_type", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of FileImageSource.
#derive(Eq, @debug.Debug)
pub(all) struct FileImageSource {
  file_id : String
  type_ : String
}

///|
pub extend FileImageSource with Eq::{equal, not_equal}

///|
pub extend FileImageSource with @debug.Debug::{to_repr}

///|
///
/// Creates a FileImageSource with omitted optional fields absent.
pub fn FileImageSource::new(
  file_id~ : String,
  type_~ : String,
) -> FileImageSource {
  { file_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend FileImageSource with ToJson::{to_json}

///|
pub impl ToJson for FileImageSource with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("file_id", self.file_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend FileImageSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for FileImageSource with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    file_id: required_field(obj, "file_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of URLImageSource.
#derive(Eq, @debug.Debug)
pub(all) struct URLImageSource {
  type_ : String
  url : String
}

///|
pub extend URLImageSource with Eq::{equal, not_equal}

///|
pub extend URLImageSource with @debug.Debug::{to_repr}

///|
///
/// Creates a URLImageSource with omitted optional fields absent.
pub fn URLImageSource::new(type_~ : String, url~ : String) -> URLImageSource {
  { type_, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend URLImageSource with ToJson::{to_json}

///|
pub impl ToJson for URLImageSource with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend URLImageSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for URLImageSource with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// Generated tagged union RequestImageBlockSource.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestImageBlockSource {
  Base64(Base64ImageSource)
  File(FileImageSource)
  Url(URLImageSource)
  Unknown(String, Json)
}

///|
pub extend RequestImageBlockSource with Eq::{equal, not_equal}

///|
pub extend RequestImageBlockSource with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestImageBlockSource with ToJson::{to_json}

///|
pub impl ToJson for RequestImageBlockSource with fn to_json(self) {
  match self {
    RequestImageBlockSource::Base64(value) => @json.Json::Json(value)
    RequestImageBlockSource::File(value) => @json.Json::Json(value)
    RequestImageBlockSource::Url(value) => @json.Json::Json(value)
    RequestImageBlockSource::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestImageBlockSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestImageBlockSource with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "base64" => RequestImageBlockSource::Base64(@json.from_json(value, path~))
    "file" => RequestImageBlockSource::File(@json.from_json(value, path~))
    "url" => RequestImageBlockSource::Url(@json.from_json(value, path~))
    other => RequestImageBlockSource::Unknown(other, value)
  }
}

///|
///
/// What the server does when this image exceeds the model's maximum image size. `"downsize"` (the default) scales the image down to fit, which changes the dimensions the model observes without telling you. `"error"` instead rejects the request with a 400 error naming the image's dimensions and the largest dimensions that fit, so you can scale the image deliberately — your image is never silently scaled down.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestImageTransformationsOversizedImage {
  Downsize
  Error
  Custom(String)
}

///|
pub extend RequestImageTransformationsOversizedImage with Eq::{equal, not_equal}

///|
pub extend RequestImageTransformationsOversizedImage with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this string enum as JSON.
pub extend RequestImageTransformationsOversizedImage with ToJson::{to_json}

///|
pub impl ToJson for RequestImageTransformationsOversizedImage with fn to_json(
  self,
) {
  let raw = match self {
    RequestImageTransformationsOversizedImage::Downsize => "downsize"
    RequestImageTransformationsOversizedImage::Error => "error"
    RequestImageTransformationsOversizedImage::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend RequestImageTransformationsOversizedImage with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestImageTransformationsOversizedImage with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "downsize" =>
          Option::Some(RequestImageTransformationsOversizedImage::Downsize)
        "error" =>
          Option::Some(RequestImageTransformationsOversizedImage::Error)
        _ => Option::None
      }
    },
    raw => RequestImageTransformationsOversizedImage::Custom(raw),
  )
}

///|
///
/// Configures the transformations the server applies to this image before the model observes it. Each key names a condition the server transforms images for; its value selects the transformation applied. Omitted keys keep their default behavior, and an empty object is equivalent to omitting the field.
#derive(Eq, @debug.Debug)
pub(all) struct RequestImageTransformations {
  oversized_image : RequestImageTransformationsOversizedImage?
}

///|
pub extend RequestImageTransformations with Eq::{equal, not_equal}

///|
pub extend RequestImageTransformations with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestImageTransformations with omitted optional fields absent.
pub fn RequestImageTransformations::new(
  oversized_image? : RequestImageTransformationsOversizedImage,
) -> RequestImageTransformations {
  { oversized_image, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestImageTransformations with ToJson::{to_json}

///|
pub impl ToJson for RequestImageTransformations with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("oversized_image", self.oversized_image)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestImageTransformations with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestImageTransformations with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { oversized_image: @sdkjson.opt_field(obj, "oversized_image", path), }
}

///|
///
/// Generated representation of RequestImageBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestImageBlock {
  cache_control : @sdkjson.Presence[RequestImageBlockCacheControl]
  source : RequestImageBlockSource
  transformations : @sdkjson.Presence[RequestImageTransformations]
  type_ : String
}

///|
pub extend RequestImageBlock with Eq::{equal, not_equal}

///|
pub extend RequestImageBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestImageBlock with omitted optional fields absent.
pub fn RequestImageBlock::new(
  source~ : RequestImageBlockSource,
  type_~ : String,
  cache_control? : RequestImageBlockCacheControl,
  transformations? : RequestImageTransformations,
) -> RequestImageBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    source,
    transformations: @sdkjson.Presence::from_option(transformations),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestImageBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestImageBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .field("source", self.source)
  .presence("transformations", self.transformations)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestImageBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestImageBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    source: required_field(obj, "source", path),
    transformations: @sdkjson.presence_field(obj, "transformations", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestTextBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestTextBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestTextBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestTextBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestTextBlockCacheControl with fn to_json(self) {
  match self {
    RequestTextBlockCacheControl::Ephemeral(value) => @json.Json::Json(value)
    RequestTextBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestTextBlockCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestTextBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestTextBlockCacheControl::Ephemeral(@json.from_json(value, path~))
    other => RequestTextBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestCharLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct RequestCharLocationCitation {
  cited_text : String
  document_index : Int32
  document_title : String?
  end_char_index : Int32
  start_char_index : Int32
  type_ : String
}

///|
pub extend RequestCharLocationCitation with Eq::{equal, not_equal}

///|
pub extend RequestCharLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestCharLocationCitation with omitted optional fields absent.
pub fn RequestCharLocationCitation::new(
  cited_text~ : String,
  document_index~ : Int32,
  end_char_index~ : Int32,
  start_char_index~ : Int32,
  type_~ : String,
  document_title? : String,
) -> RequestCharLocationCitation {
  {
    cited_text,
    document_index,
    document_title,
    end_char_index,
    start_char_index,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestCharLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for RequestCharLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("document_index", self.document_index)
  .presence(
    "document_title",
    nullable_presence(self.document_title.map(value => value)),
  )
  .field("end_char_index", self.end_char_index)
  .field("start_char_index", self.start_char_index)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestCharLocationCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestCharLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    document_index: required_field(obj, "document_index", path),
    document_title: decode_nullable_field(obj, "document_title", path),
    end_char_index: required_field(obj, "end_char_index", path),
    start_char_index: required_field(obj, "start_char_index", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestContentBlockLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct RequestContentBlockLocationCitation {
  cited_text : String
  document_index : Int32
  document_title : String?
  end_block_index : Int32
  start_block_index : Int32
  type_ : String
}

///|
pub extend RequestContentBlockLocationCitation with Eq::{equal, not_equal}

///|
pub extend RequestContentBlockLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestContentBlockLocationCitation with omitted optional fields absent.
pub fn RequestContentBlockLocationCitation::new(
  cited_text~ : String,
  document_index~ : Int32,
  end_block_index~ : Int32,
  start_block_index~ : Int32,
  type_~ : String,
  document_title? : String,
) -> RequestContentBlockLocationCitation {
  {
    cited_text,
    document_index,
    document_title,
    end_block_index,
    start_block_index,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestContentBlockLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for RequestContentBlockLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("document_index", self.document_index)
  .presence(
    "document_title",
    nullable_presence(self.document_title.map(value => value)),
  )
  .field("end_block_index", self.end_block_index)
  .field("start_block_index", self.start_block_index)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestContentBlockLocationCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestContentBlockLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    document_index: required_field(obj, "document_index", path),
    document_title: decode_nullable_field(obj, "document_title", path),
    end_block_index: required_field(obj, "end_block_index", path),
    start_block_index: required_field(obj, "start_block_index", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestPageLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct RequestPageLocationCitation {
  cited_text : String
  document_index : Int32
  document_title : String?
  end_page_number : Int32
  start_page_number : Int32
  type_ : String
}

///|
pub extend RequestPageLocationCitation with Eq::{equal, not_equal}

///|
pub extend RequestPageLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestPageLocationCitation with omitted optional fields absent.
pub fn RequestPageLocationCitation::new(
  cited_text~ : String,
  document_index~ : Int32,
  end_page_number~ : Int32,
  start_page_number~ : Int32,
  type_~ : String,
  document_title? : String,
) -> RequestPageLocationCitation {
  {
    cited_text,
    document_index,
    document_title,
    end_page_number,
    start_page_number,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestPageLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for RequestPageLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("document_index", self.document_index)
  .presence(
    "document_title",
    nullable_presence(self.document_title.map(value => value)),
  )
  .field("end_page_number", self.end_page_number)
  .field("start_page_number", self.start_page_number)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestPageLocationCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestPageLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    document_index: required_field(obj, "document_index", path),
    document_title: decode_nullable_field(obj, "document_title", path),
    end_page_number: required_field(obj, "end_page_number", path),
    start_page_number: required_field(obj, "start_page_number", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestSearchResultLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct RequestSearchResultLocationCitation {
  cited_text : String
  end_block_index : Int32
  search_result_index : Int32
  source : String
  start_block_index : Int32
  title : String?
  type_ : String
}

///|
pub extend RequestSearchResultLocationCitation with Eq::{equal, not_equal}

///|
pub extend RequestSearchResultLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestSearchResultLocationCitation with omitted optional fields absent.
pub fn RequestSearchResultLocationCitation::new(
  cited_text~ : String,
  end_block_index~ : Int32,
  search_result_index~ : Int32,
  source~ : String,
  start_block_index~ : Int32,
  type_~ : String,
  title? : String,
) -> RequestSearchResultLocationCitation {
  {
    cited_text,
    end_block_index,
    search_result_index,
    source,
    start_block_index,
    title,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestSearchResultLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for RequestSearchResultLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("end_block_index", self.end_block_index)
  .field("search_result_index", self.search_result_index)
  .field("source", self.source)
  .field("start_block_index", self.start_block_index)
  .presence("title", nullable_presence(self.title.map(value => value)))
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestSearchResultLocationCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestSearchResultLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    end_block_index: required_field(obj, "end_block_index", path),
    search_result_index: required_field(obj, "search_result_index", path),
    source: required_field(obj, "source", path),
    start_block_index: required_field(obj, "start_block_index", path),
    title: decode_nullable_field(obj, "title", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestWebSearchResultLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct RequestWebSearchResultLocationCitation {
  cited_text : String
  encrypted_index : String
  title : String?
  type_ : String
  url : String
}

///|
pub extend RequestWebSearchResultLocationCitation with Eq::{equal, not_equal}

///|
pub extend RequestWebSearchResultLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestWebSearchResultLocationCitation with omitted optional fields absent.
pub fn RequestWebSearchResultLocationCitation::new(
  cited_text~ : String,
  encrypted_index~ : String,
  type_~ : String,
  url~ : String,
  title? : String,
) -> RequestWebSearchResultLocationCitation {
  { cited_text, encrypted_index, title, type_, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestWebSearchResultLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for RequestWebSearchResultLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("encrypted_index", self.encrypted_index)
  .presence("title", nullable_presence(self.title.map(value => value)))
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestWebSearchResultLocationCitation with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestWebSearchResultLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    encrypted_index: required_field(obj, "encrypted_index", path),
    title: decode_nullable_field(obj, "title", path),
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// Generated tagged union RequestTextBlockCitationsItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestTextBlockCitationsItem {
  CharLocation(RequestCharLocationCitation)
  ContentBlockLocation(RequestContentBlockLocationCitation)
  PageLocation(RequestPageLocationCitation)
  SearchResultLocation(RequestSearchResultLocationCitation)
  WebSearchResultLocation(RequestWebSearchResultLocationCitation)
  Unknown(String, Json)
}

///|
pub extend RequestTextBlockCitationsItem with Eq::{equal, not_equal}

///|
pub extend RequestTextBlockCitationsItem with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestTextBlockCitationsItem with ToJson::{to_json}

///|
pub impl ToJson for RequestTextBlockCitationsItem with fn to_json(self) {
  match self {
    RequestTextBlockCitationsItem::CharLocation(value) =>
      @json.Json::Json(value)
    RequestTextBlockCitationsItem::ContentBlockLocation(value) =>
      @json.Json::Json(value)
    RequestTextBlockCitationsItem::PageLocation(value) =>
      @json.Json::Json(value)
    RequestTextBlockCitationsItem::SearchResultLocation(value) =>
      @json.Json::Json(value)
    RequestTextBlockCitationsItem::WebSearchResultLocation(value) =>
      @json.Json::Json(value)
    RequestTextBlockCitationsItem::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestTextBlockCitationsItem with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestTextBlockCitationsItem with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "char_location" =>
      RequestTextBlockCitationsItem::CharLocation(@json.from_json(value, path~))
    "content_block_location" =>
      RequestTextBlockCitationsItem::ContentBlockLocation(
        @json.from_json(value, path~),
      )
    "page_location" =>
      RequestTextBlockCitationsItem::PageLocation(@json.from_json(value, path~))
    "search_result_location" =>
      RequestTextBlockCitationsItem::SearchResultLocation(
        @json.from_json(value, path~),
      )
    "web_search_result_location" =>
      RequestTextBlockCitationsItem::WebSearchResultLocation(
        @json.from_json(value, path~),
      )
    other => RequestTextBlockCitationsItem::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestTextBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestTextBlock {
  cache_control : @sdkjson.Presence[RequestTextBlockCacheControl]
  citations : @sdkjson.Presence[Array[RequestTextBlockCitationsItem]]
  text : String
  type_ : String
}

///|
pub extend RequestTextBlock with Eq::{equal, not_equal}

///|
pub extend RequestTextBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestTextBlock with omitted optional fields absent.
pub fn RequestTextBlock::new(
  text~ : String,
  type_~ : String,
  cache_control? : RequestTextBlockCacheControl,
  citations? : Array[RequestTextBlockCitationsItem],
) -> RequestTextBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    citations: @sdkjson.Presence::from_option(citations),
    text,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestTextBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestTextBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .presence("citations", self.citations)
  .field("text", self.text)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestTextBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestTextBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    citations: @sdkjson.presence_field(obj, "citations", path),
    text: required_field(obj, "text", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ContentBlockSourceContentValueArrayItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ContentBlockSourceContentValueArrayItem {
  Image(RequestImageBlock)
  Text(RequestTextBlock)
  Unknown(String, Json)
}

///|
pub extend ContentBlockSourceContentValueArrayItem with Eq::{equal, not_equal}

///|
pub extend ContentBlockSourceContentValueArrayItem with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ContentBlockSourceContentValueArrayItem with ToJson::{to_json}

///|
pub impl ToJson for ContentBlockSourceContentValueArrayItem with fn to_json(
  self,
) {
  match self {
    ContentBlockSourceContentValueArrayItem::Image(value) =>
      @json.Json::Json(value)
    ContentBlockSourceContentValueArrayItem::Text(value) =>
      @json.Json::Json(value)
    ContentBlockSourceContentValueArrayItem::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ContentBlockSourceContentValueArrayItem with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ContentBlockSourceContentValueArrayItem with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "image" =>
      ContentBlockSourceContentValueArrayItem::Image(
        @json.from_json(value, path~),
      )
    "text" =>
      ContentBlockSourceContentValueArrayItem::Text(
        @json.from_json(value, path~),
      )
    other => ContentBlockSourceContentValueArrayItem::Unknown(other, value)
  }
}

///|
///
/// Generated untagged union ContentBlockSourceContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ContentBlockSourceContent {
  Text(String)
  ValueArray(Array[ContentBlockSourceContentValueArrayItem])
}

///|
pub extend ContentBlockSourceContent with Eq::{equal, not_equal}

///|
pub extend ContentBlockSourceContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend ContentBlockSourceContent with ToJson::{to_json}

///|
pub impl ToJson for ContentBlockSourceContent with fn to_json(self) {
  match self {
    ContentBlockSourceContent::Text(value) => @json.Json::Json(value)
    ContentBlockSourceContent::ValueArray(value) => @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend ContentBlockSourceContent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContentBlockSourceContent with fn from_json(
  value,
  path,
) {
  if value is @json.Json::String(_) {
    let decoded : String = @json.from_json(value, path~)
    return ContentBlockSourceContent::Text(decoded)
  }
  if json_array_matches(value, item => item is @json.Json::Object(_)) {
    let decoded : Array[ContentBlockSourceContentValueArrayItem] = @json.from_json(
      value,
      path~,
    )
    return ContentBlockSourceContent::ValueArray(decoded)
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (path, "JSON shape does not match any ContentBlockSourceContent variant"),
  )
}

///|
///
/// Generated representation of ContentBlockSource.
#derive(Eq, @debug.Debug)
pub(all) struct ContentBlockSource {
  content : ContentBlockSourceContent
  type_ : String
}

///|
pub extend ContentBlockSource with Eq::{equal, not_equal}

///|
pub extend ContentBlockSource with @debug.Debug::{to_repr}

///|
///
/// Creates a ContentBlockSource with omitted optional fields absent.
pub fn ContentBlockSource::new(
  content~ : ContentBlockSourceContent,
  type_~ : String,
) -> ContentBlockSource {
  { content, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ContentBlockSource with ToJson::{to_json}

///|
pub impl ToJson for ContentBlockSource with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ContentBlockSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContentBlockSource with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of FileDocumentSource.
#derive(Eq, @debug.Debug)
pub(all) struct FileDocumentSource {
  file_id : String
  type_ : String
}

///|
pub extend FileDocumentSource with Eq::{equal, not_equal}

///|
pub extend FileDocumentSource with @debug.Debug::{to_repr}

///|
///
/// Creates a FileDocumentSource with omitted optional fields absent.
pub fn FileDocumentSource::new(
  file_id~ : String,
  type_~ : String,
) -> FileDocumentSource {
  { file_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend FileDocumentSource with ToJson::{to_json}

///|
pub impl ToJson for FileDocumentSource with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("file_id", self.file_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend FileDocumentSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for FileDocumentSource with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    file_id: required_field(obj, "file_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of PlainTextSource.
#derive(Eq, @debug.Debug)
pub(all) struct PlainTextSource {
  data : String
  type_ : String
}

///|
pub extend PlainTextSource with Eq::{equal, not_equal}

///|
pub extend PlainTextSource with @debug.Debug::{to_repr}

///|
///
/// Creates a PlainTextSource with omitted optional fields absent.
pub fn PlainTextSource::new(data~ : String, type_~ : String) -> PlainTextSource {
  { data, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend PlainTextSource with ToJson::{to_json}

///|
pub impl ToJson for PlainTextSource with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("data", self.data)
  .field("media_type", "text/plain")
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend PlainTextSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for PlainTextSource with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    data: required_field(obj, "data", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of URLPDFSource.
#derive(Eq, @debug.Debug)
pub(all) struct URLPDFSource {
  type_ : String
  url : String
}

///|
pub extend URLPDFSource with Eq::{equal, not_equal}

///|
pub extend URLPDFSource with @debug.Debug::{to_repr}

///|
///
/// Creates a URLPDFSource with omitted optional fields absent.
pub fn URLPDFSource::new(type_~ : String, url~ : String) -> URLPDFSource {
  { type_, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend URLPDFSource with ToJson::{to_json}

///|
pub impl ToJson for URLPDFSource with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend URLPDFSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for URLPDFSource with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// Generated tagged union RequestDocumentBlockSource.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestDocumentBlockSource {
  Base64(Base64PDFSource)
  Content(ContentBlockSource)
  File(FileDocumentSource)
  Text(PlainTextSource)
  Url(URLPDFSource)
  Unknown(String, Json)
}

///|
pub extend RequestDocumentBlockSource with Eq::{equal, not_equal}

///|
pub extend RequestDocumentBlockSource with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestDocumentBlockSource with ToJson::{to_json}

///|
pub impl ToJson for RequestDocumentBlockSource with fn to_json(self) {
  match self {
    RequestDocumentBlockSource::Base64(value) => @json.Json::Json(value)
    RequestDocumentBlockSource::Content(value) => @json.Json::Json(value)
    RequestDocumentBlockSource::File(value) => @json.Json::Json(value)
    RequestDocumentBlockSource::Text(value) => @json.Json::Json(value)
    RequestDocumentBlockSource::Url(value) => @json.Json::Json(value)
    RequestDocumentBlockSource::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestDocumentBlockSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestDocumentBlockSource with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "base64" =>
      RequestDocumentBlockSource::Base64(@json.from_json(value, path~))
    "content" =>
      RequestDocumentBlockSource::Content(@json.from_json(value, path~))
    "file" => RequestDocumentBlockSource::File(@json.from_json(value, path~))
    "text" => RequestDocumentBlockSource::Text(@json.from_json(value, path~))
    "url" => RequestDocumentBlockSource::Url(@json.from_json(value, path~))
    other => RequestDocumentBlockSource::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestDocumentBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestDocumentBlock {
  cache_control : @sdkjson.Presence[RequestDocumentBlockCacheControl]
  citations : @sdkjson.Presence[RequestCitationsConfig]
  context : @sdkjson.Presence[String]
  source : RequestDocumentBlockSource
  title : @sdkjson.Presence[String]
  type_ : String
}

///|
pub extend RequestDocumentBlock with Eq::{equal, not_equal}

///|
pub extend RequestDocumentBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestDocumentBlock with omitted optional fields absent.
pub fn RequestDocumentBlock::new(
  source~ : RequestDocumentBlockSource,
  type_~ : String,
  cache_control? : RequestDocumentBlockCacheControl,
  citations? : RequestCitationsConfig,
  context? : String,
  title? : String,
) -> RequestDocumentBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    citations: @sdkjson.Presence::from_option(citations),
    context: @sdkjson.Presence::from_option(context),
    source,
    title: @sdkjson.Presence::from_option(title),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestDocumentBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestDocumentBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .presence("citations", self.citations)
  .presence("context", self.context)
  .field("source", self.source)
  .presence("title", self.title)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestDocumentBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestDocumentBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    citations: @sdkjson.presence_field(obj, "citations", path),
    context: @sdkjson.presence_field(obj, "context", path),
    source: required_field(obj, "source", path),
    title: @sdkjson.presence_field(obj, "title", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestRedactedThinkingBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestRedactedThinkingBlock {
  data : String
  type_ : String
}

///|
pub extend RequestRedactedThinkingBlock with Eq::{equal, not_equal}

///|
pub extend RequestRedactedThinkingBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestRedactedThinkingBlock with omitted optional fields absent.
pub fn RequestRedactedThinkingBlock::new(
  data~ : String,
  type_~ : String,
) -> RequestRedactedThinkingBlock {
  { data, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestRedactedThinkingBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestRedactedThinkingBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("data", self.data)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestRedactedThinkingBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestRedactedThinkingBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    data: required_field(obj, "data", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestSearchResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestSearchResultBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestSearchResultBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestSearchResultBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestSearchResultBlockCacheControl with fn to_json(self) {
  match self {
    RequestSearchResultBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestSearchResultBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestSearchResultBlockCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestSearchResultBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestSearchResultBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestSearchResultBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestSearchResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestSearchResultBlock {
  cache_control : @sdkjson.Presence[RequestSearchResultBlockCacheControl]
  citations : RequestCitationsConfig?
  content : Array[RequestTextBlock]
  source : String
  title : String
  type_ : String
}

///|
pub extend RequestSearchResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestSearchResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestSearchResultBlock with omitted optional fields absent.
pub fn RequestSearchResultBlock::new(
  content~ : Array[RequestTextBlock],
  source~ : String,
  title~ : String,
  type_~ : String,
  cache_control? : RequestSearchResultBlockCacheControl,
  citations? : RequestCitationsConfig,
) -> RequestSearchResultBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    citations,
    content,
    source,
    title,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestSearchResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestSearchResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .opt("citations", self.citations)
  .field("content", self.content)
  .field("source", self.source)
  .field("title", self.title)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestSearchResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestSearchResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    citations: @sdkjson.opt_field(obj, "citations", path),
    content: required_field(obj, "content", path),
    source: required_field(obj, "source", path),
    title: required_field(obj, "title", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestServerToolUseBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestServerToolUseBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestServerToolUseBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestServerToolUseBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestServerToolUseBlockCacheControl with fn to_json(self) {
  match self {
    RequestServerToolUseBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestServerToolUseBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestServerToolUseBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestServerToolUseBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestServerToolUseBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestServerToolUseBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Tool invocation generated by a server-side tool.
#derive(Eq, @debug.Debug)
pub(all) struct ServerToolCaller {
  tool_id : String
  type_ : String
}

///|
pub extend ServerToolCaller with Eq::{equal, not_equal}

///|
pub extend ServerToolCaller with @debug.Debug::{to_repr}

///|
///
/// Creates a ServerToolCaller with omitted optional fields absent.
pub fn ServerToolCaller::new(
  tool_id~ : String,
  type_~ : String,
) -> ServerToolCaller {
  { tool_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ServerToolCaller with ToJson::{to_json}

///|
pub impl ToJson for ServerToolCaller with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("tool_id", self.tool_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ServerToolCaller with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ServerToolCaller with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    tool_id: required_field(obj, "tool_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ServerToolCaller20260120.
#derive(Eq, @debug.Debug)
pub(all) struct ServerToolCaller20260120 {
  tool_id : String
  type_ : String
}

///|
pub extend ServerToolCaller20260120 with Eq::{equal, not_equal}

///|
pub extend ServerToolCaller20260120 with @debug.Debug::{to_repr}

///|
///
/// Creates a ServerToolCaller20260120 with omitted optional fields absent.
pub fn ServerToolCaller20260120::new(
  tool_id~ : String,
  type_~ : String,
) -> ServerToolCaller20260120 {
  { tool_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ServerToolCaller20260120 with ToJson::{to_json}

///|
pub impl ToJson for ServerToolCaller20260120 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("tool_id", self.tool_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ServerToolCaller20260120 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ServerToolCaller20260120 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    tool_id: required_field(obj, "tool_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Tool invocation directly from the model.
#derive(Eq, @debug.Debug)
pub(all) struct DirectCaller {
  type_ : String
}

///|
pub extend DirectCaller with Eq::{equal, not_equal}

///|
pub extend DirectCaller with @debug.Debug::{to_repr}

///|
///
/// Creates a DirectCaller with omitted optional fields absent.
pub fn DirectCaller::new(type_~ : String) -> DirectCaller {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend DirectCaller with ToJson::{to_json}

///|
pub impl ToJson for DirectCaller with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend DirectCaller with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for DirectCaller with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// Generated tagged union RequestServerToolUseBlockCaller.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestServerToolUseBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
}

///|
pub extend RequestServerToolUseBlockCaller with Eq::{equal, not_equal}

///|
pub extend RequestServerToolUseBlockCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestServerToolUseBlockCaller with ToJson::{to_json}

///|
pub impl ToJson for RequestServerToolUseBlockCaller with fn to_json(self) {
  match self {
    RequestServerToolUseBlockCaller::CodeExecution20250825(value) =>
      @json.Json::Json(value)
    RequestServerToolUseBlockCaller::CodeExecution20260120(value) =>
      @json.Json::Json(value)
    RequestServerToolUseBlockCaller::Direct(value) => @json.Json::Json(value)
    RequestServerToolUseBlockCaller::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestServerToolUseBlockCaller with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestServerToolUseBlockCaller with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_20250825" =>
      RequestServerToolUseBlockCaller::CodeExecution20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      RequestServerToolUseBlockCaller::CodeExecution20260120(
        @json.from_json(value, path~),
      )
    "direct" =>
      RequestServerToolUseBlockCaller::Direct(@json.from_json(value, path~))
    other => RequestServerToolUseBlockCaller::Unknown(other, value)
  }
}

///|
///
/// Generated string enum RequestServerToolUseBlockName.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestServerToolUseBlockName {
  WebSearch
  WebFetch
  CodeExecution
  BashCodeExecution
  TextEditorCodeExecution
  ToolSearchToolRegex
  ToolSearchToolBm25
  Custom(String)
}

///|
pub extend RequestServerToolUseBlockName with Eq::{equal, not_equal}

///|
pub extend RequestServerToolUseBlockName with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend RequestServerToolUseBlockName with ToJson::{to_json}

///|
pub impl ToJson for RequestServerToolUseBlockName with fn to_json(self) {
  let raw = match self {
    RequestServerToolUseBlockName::WebSearch => "web_search"
    RequestServerToolUseBlockName::WebFetch => "web_fetch"
    RequestServerToolUseBlockName::CodeExecution => "code_execution"
    RequestServerToolUseBlockName::BashCodeExecution => "bash_code_execution"
    RequestServerToolUseBlockName::TextEditorCodeExecution =>
      "text_editor_code_execution"
    RequestServerToolUseBlockName::ToolSearchToolRegex =>
      "tool_search_tool_regex"
    RequestServerToolUseBlockName::ToolSearchToolBm25 => "tool_search_tool_bm25"
    RequestServerToolUseBlockName::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend RequestServerToolUseBlockName with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestServerToolUseBlockName with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "web_search" => Option::Some(RequestServerToolUseBlockName::WebSearch)
        "web_fetch" => Option::Some(RequestServerToolUseBlockName::WebFetch)
        "code_execution" =>
          Option::Some(RequestServerToolUseBlockName::CodeExecution)
        "bash_code_execution" =>
          Option::Some(RequestServerToolUseBlockName::BashCodeExecution)
        "text_editor_code_execution" =>
          Option::Some(RequestServerToolUseBlockName::TextEditorCodeExecution)
        "tool_search_tool_regex" =>
          Option::Some(RequestServerToolUseBlockName::ToolSearchToolRegex)
        "tool_search_tool_bm25" =>
          Option::Some(RequestServerToolUseBlockName::ToolSearchToolBm25)
        _ => Option::None
      }
    },
    raw => RequestServerToolUseBlockName::Custom(raw),
  )
}

///|
///
/// Generated representation of RequestServerToolUseBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestServerToolUseBlock {
  cache_control : @sdkjson.Presence[RequestServerToolUseBlockCacheControl]
  caller : RequestServerToolUseBlockCaller?
  id : String
  input : Json
  name : RequestServerToolUseBlockName
  type_ : String
}

///|
pub extend RequestServerToolUseBlock with Eq::{equal, not_equal}

///|
pub extend RequestServerToolUseBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestServerToolUseBlock with omitted optional fields absent.
pub fn RequestServerToolUseBlock::new(
  id~ : String,
  input~ : Json,
  name~ : RequestServerToolUseBlockName,
  type_~ : String,
  cache_control? : RequestServerToolUseBlockCacheControl,
  caller? : RequestServerToolUseBlockCaller,
) -> RequestServerToolUseBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    caller,
    id,
    input,
    name,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestServerToolUseBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestServerToolUseBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .opt("caller", self.caller)
  .field("id", self.id)
  .field("input", self.input)
  .field("name", self.name)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestServerToolUseBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestServerToolUseBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    caller: @sdkjson.opt_field(obj, "caller", path),
    id: required_field(obj, "id", path),
    input: required_field(obj, "input", path),
    name: required_field(obj, "name", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestTextEditorCodeExecutionToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestTextEditorCodeExecutionToolResultBlockCacheControl with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestTextEditorCodeExecutionToolResultBlockCacheControl with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestTextEditorCodeExecutionToolResultBlockCacheControl with ToJson::{
  to_json,
}

///|
pub impl ToJson for RequestTextEditorCodeExecutionToolResultBlockCacheControl with fn to_json(
  self,
) {
  match self {
    RequestTextEditorCodeExecutionToolResultBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestTextEditorCodeExecutionToolResultBlockCacheControl::Unknown(_, value) =>
      value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestTextEditorCodeExecutionToolResultBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestTextEditorCodeExecutionToolResultBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestTextEditorCodeExecutionToolResultBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other =>
      RequestTextEditorCodeExecutionToolResultBlockCacheControl::Unknown(
        other, value,
      )
  }
}

///|
///
/// Generated string enum TextEditorCodeExecutionToolResultErrorCode.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum TextEditorCodeExecutionToolResultErrorCode {
  InvalidToolInput
  Unavailable
  TooManyRequests
  ExecutionTimeExceeded
  FileNotFound
  Unknown(String)
}

///|
pub extend TextEditorCodeExecutionToolResultErrorCode with Eq::{
  equal,
  not_equal,
}

///|
pub extend TextEditorCodeExecutionToolResultErrorCode with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this string enum as JSON.
pub extend TextEditorCodeExecutionToolResultErrorCode with ToJson::{to_json}

///|
pub impl ToJson for TextEditorCodeExecutionToolResultErrorCode with fn to_json(
  self,
) {
  let raw = match self {
    TextEditorCodeExecutionToolResultErrorCode::InvalidToolInput =>
      "invalid_tool_input"
    TextEditorCodeExecutionToolResultErrorCode::Unavailable => "unavailable"
    TextEditorCodeExecutionToolResultErrorCode::TooManyRequests =>
      "too_many_requests"
    TextEditorCodeExecutionToolResultErrorCode::ExecutionTimeExceeded =>
      "execution_time_exceeded"
    TextEditorCodeExecutionToolResultErrorCode::FileNotFound => "file_not_found"
    TextEditorCodeExecutionToolResultErrorCode::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend TextEditorCodeExecutionToolResultErrorCode with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for TextEditorCodeExecutionToolResultErrorCode with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "invalid_tool_input" =>
          Option::Some(
            TextEditorCodeExecutionToolResultErrorCode::InvalidToolInput,
          )
        "unavailable" =>
          Option::Some(TextEditorCodeExecutionToolResultErrorCode::Unavailable)
        "too_many_requests" =>
          Option::Some(
            TextEditorCodeExecutionToolResultErrorCode::TooManyRequests,
          )
        "execution_time_exceeded" =>
          Option::Some(
            TextEditorCodeExecutionToolResultErrorCode::ExecutionTimeExceeded,
          )
        "file_not_found" =>
          Option::Some(TextEditorCodeExecutionToolResultErrorCode::FileNotFound)
        _ => Option::None
      }
    },
    raw => TextEditorCodeExecutionToolResultErrorCode::Unknown(raw),
  )
}

///|
///
/// Generated representation of RequestTextEditorCodeExecutionToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct RequestTextEditorCodeExecutionToolResultError {
  error_code : TextEditorCodeExecutionToolResultErrorCode
  error_message : @sdkjson.Presence[String]
  type_ : String
}

///|
pub extend RequestTextEditorCodeExecutionToolResultError with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestTextEditorCodeExecutionToolResultError with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a RequestTextEditorCodeExecutionToolResultError with omitted optional fields absent.
pub fn RequestTextEditorCodeExecutionToolResultError::new(
  error_code~ : TextEditorCodeExecutionToolResultErrorCode,
  type_~ : String,
  error_message? : String,
) -> RequestTextEditorCodeExecutionToolResultError {
  {
    error_code,
    error_message: @sdkjson.Presence::from_option(error_message),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestTextEditorCodeExecutionToolResultError with ToJson::{to_json}

///|
pub impl ToJson for RequestTextEditorCodeExecutionToolResultError with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .presence("error_message", self.error_message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestTextEditorCodeExecutionToolResultError with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestTextEditorCodeExecutionToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    error_message: @sdkjson.presence_field(obj, "error_message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated string enum RequestTextEditorCodeExecutionViewResultBlockFileType.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestTextEditorCodeExecutionViewResultBlockFileType {
  Text
  Image
  Pdf
  Custom(String)
}

///|
pub extend RequestTextEditorCodeExecutionViewResultBlockFileType with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestTextEditorCodeExecutionViewResultBlockFileType with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this string enum as JSON.
pub extend RequestTextEditorCodeExecutionViewResultBlockFileType with ToJson::{
  to_json,
}

///|
pub impl ToJson for RequestTextEditorCodeExecutionViewResultBlockFileType with fn to_json(
  self,
) {
  let raw = match self {
    RequestTextEditorCodeExecutionViewResultBlockFileType::Text => "text"
    RequestTextEditorCodeExecutionViewResultBlockFileType::Image => "image"
    RequestTextEditorCodeExecutionViewResultBlockFileType::Pdf => "pdf"
    RequestTextEditorCodeExecutionViewResultBlockFileType::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend RequestTextEditorCodeExecutionViewResultBlockFileType with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestTextEditorCodeExecutionViewResultBlockFileType with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "text" =>
          Option::Some(
            RequestTextEditorCodeExecutionViewResultBlockFileType::Text,
          )
        "image" =>
          Option::Some(
            RequestTextEditorCodeExecutionViewResultBlockFileType::Image,
          )
        "pdf" =>
          Option::Some(
            RequestTextEditorCodeExecutionViewResultBlockFileType::Pdf,
          )
        _ => Option::None
      }
    },
    raw => RequestTextEditorCodeExecutionViewResultBlockFileType::Custom(raw),
  )
}

///|
///
/// Generated representation of RequestTextEditorCodeExecutionViewResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestTextEditorCodeExecutionViewResultBlock {
  content : String
  file_type : RequestTextEditorCodeExecutionViewResultBlockFileType
  num_lines : @sdkjson.Presence[Int32]
  start_line : @sdkjson.Presence[Int32]
  total_lines : @sdkjson.Presence[Int32]
  type_ : String
}

///|
pub extend RequestTextEditorCodeExecutionViewResultBlock with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestTextEditorCodeExecutionViewResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a RequestTextEditorCodeExecutionViewResultBlock with omitted optional fields absent.
pub fn RequestTextEditorCodeExecutionViewResultBlock::new(
  content~ : String,
  file_type~ : RequestTextEditorCodeExecutionViewResultBlockFileType,
  type_~ : String,
  num_lines? : Int32,
  start_line? : Int32,
  total_lines? : Int32,
) -> RequestTextEditorCodeExecutionViewResultBlock {
  {
    content,
    file_type,
    num_lines: @sdkjson.Presence::from_option(num_lines),
    start_line: @sdkjson.Presence::from_option(start_line),
    total_lines: @sdkjson.Presence::from_option(total_lines),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestTextEditorCodeExecutionViewResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestTextEditorCodeExecutionViewResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("file_type", self.file_type)
  .presence("num_lines", self.num_lines)
  .presence("start_line", self.start_line)
  .presence("total_lines", self.total_lines)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestTextEditorCodeExecutionViewResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestTextEditorCodeExecutionViewResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    file_type: required_field(obj, "file_type", path),
    num_lines: @sdkjson.presence_field(obj, "num_lines", path),
    start_line: @sdkjson.presence_field(obj, "start_line", path),
    total_lines: @sdkjson.presence_field(obj, "total_lines", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestTextEditorCodeExecutionCreateResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestTextEditorCodeExecutionCreateResultBlock {
  is_file_update : Bool
  type_ : String
}

///|
pub extend RequestTextEditorCodeExecutionCreateResultBlock with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestTextEditorCodeExecutionCreateResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a RequestTextEditorCodeExecutionCreateResultBlock with omitted optional fields absent.
pub fn RequestTextEditorCodeExecutionCreateResultBlock::new(
  is_file_update~ : Bool,
  type_~ : String,
) -> RequestTextEditorCodeExecutionCreateResultBlock {
  { is_file_update, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestTextEditorCodeExecutionCreateResultBlock with ToJson::{
  to_json,
}

///|
pub impl ToJson for RequestTextEditorCodeExecutionCreateResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("is_file_update", self.is_file_update)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestTextEditorCodeExecutionCreateResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestTextEditorCodeExecutionCreateResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    is_file_update: required_field(obj, "is_file_update", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestTextEditorCodeExecutionStrReplaceResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestTextEditorCodeExecutionStrReplaceResultBlock {
  lines : @sdkjson.Presence[Array[String]]
  new_lines : @sdkjson.Presence[Int32]
  new_start : @sdkjson.Presence[Int32]
  old_lines : @sdkjson.Presence[Int32]
  old_start : @sdkjson.Presence[Int32]
  type_ : String
}

///|
pub extend RequestTextEditorCodeExecutionStrReplaceResultBlock with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestTextEditorCodeExecutionStrReplaceResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a RequestTextEditorCodeExecutionStrReplaceResultBlock with omitted optional fields absent.
pub fn RequestTextEditorCodeExecutionStrReplaceResultBlock::new(
  type_~ : String,
  lines? : Array[String],
  new_lines? : Int32,
  new_start? : Int32,
  old_lines? : Int32,
  old_start? : Int32,
) -> RequestTextEditorCodeExecutionStrReplaceResultBlock {
  {
    lines: @sdkjson.Presence::from_option(lines),
    new_lines: @sdkjson.Presence::from_option(new_lines),
    new_start: @sdkjson.Presence::from_option(new_start),
    old_lines: @sdkjson.Presence::from_option(old_lines),
    old_start: @sdkjson.Presence::from_option(old_start),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestTextEditorCodeExecutionStrReplaceResultBlock with ToJson::{
  to_json,
}

///|
pub impl ToJson for RequestTextEditorCodeExecutionStrReplaceResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .presence("lines", self.lines)
  .presence("new_lines", self.new_lines)
  .presence("new_start", self.new_start)
  .presence("old_lines", self.old_lines)
  .presence("old_start", self.old_start)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestTextEditorCodeExecutionStrReplaceResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestTextEditorCodeExecutionStrReplaceResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    lines: @sdkjson.presence_field(obj, "lines", path),
    new_lines: @sdkjson.presence_field(obj, "new_lines", path),
    new_start: @sdkjson.presence_field(obj, "new_start", path),
    old_lines: @sdkjson.presence_field(obj, "old_lines", path),
    old_start: @sdkjson.presence_field(obj, "old_start", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union RequestTextEditorCodeExecutionToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestTextEditorCodeExecutionToolResultBlockContent {
  TextEditorCodeExecutionToolResultError(
    RequestTextEditorCodeExecutionToolResultError,
  )
  TextEditorCodeExecutionViewResult(
    RequestTextEditorCodeExecutionViewResultBlock,
  )
  TextEditorCodeExecutionCreateResult(
    RequestTextEditorCodeExecutionCreateResultBlock,
  )
  TextEditorCodeExecutionStrReplaceResult(
    RequestTextEditorCodeExecutionStrReplaceResultBlock,
  )
  Unknown(String, Json)
}

///|
pub extend RequestTextEditorCodeExecutionToolResultBlockContent with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestTextEditorCodeExecutionToolResultBlockContent with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestTextEditorCodeExecutionToolResultBlockContent with ToJson::{
  to_json,
}

///|
pub impl ToJson for RequestTextEditorCodeExecutionToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    RequestTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionToolResultError(
      value,
    ) => @json.Json::Json(value)
    RequestTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionViewResult(
      value,
    ) => @json.Json::Json(value)
    RequestTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionCreateResult(
      value,
    ) => @json.Json::Json(value)
    RequestTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionStrReplaceResult(
      value,
    ) => @json.Json::Json(value)
    RequestTextEditorCodeExecutionToolResultBlockContent::Unknown(_, value) =>
      value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestTextEditorCodeExecutionToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestTextEditorCodeExecutionToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "text_editor_code_execution_tool_result_error" =>
      RequestTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionToolResultError(
        @json.from_json(value, path~),
      )
    "text_editor_code_execution_view_result" =>
      RequestTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionViewResult(
        @json.from_json(value, path~),
      )
    "text_editor_code_execution_create_result" =>
      RequestTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionCreateResult(
        @json.from_json(value, path~),
      )
    "text_editor_code_execution_str_replace_result" =>
      RequestTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionStrReplaceResult(
        @json.from_json(value, path~),
      )
    other =>
      RequestTextEditorCodeExecutionToolResultBlockContent::Unknown(
        other, value,
      )
  }
}

///|
///
/// Generated representation of RequestTextEditorCodeExecutionToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestTextEditorCodeExecutionToolResultBlock {
  cache_control : @sdkjson.Presence[
    RequestTextEditorCodeExecutionToolResultBlockCacheControl,
  ]
  content : RequestTextEditorCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend RequestTextEditorCodeExecutionToolResultBlock with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestTextEditorCodeExecutionToolResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a RequestTextEditorCodeExecutionToolResultBlock with omitted optional fields absent.
pub fn RequestTextEditorCodeExecutionToolResultBlock::new(
  content~ : RequestTextEditorCodeExecutionToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
  cache_control? : RequestTextEditorCodeExecutionToolResultBlockCacheControl,
) -> RequestTextEditorCodeExecutionToolResultBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    content,
    tool_use_id,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestTextEditorCodeExecutionToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestTextEditorCodeExecutionToolResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestTextEditorCodeExecutionToolResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestTextEditorCodeExecutionToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestThinkingBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestThinkingBlock {
  signature : String
  thinking : String
  type_ : String
}

///|
pub extend RequestThinkingBlock with Eq::{equal, not_equal}

///|
pub extend RequestThinkingBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestThinkingBlock with omitted optional fields absent.
pub fn RequestThinkingBlock::new(
  signature~ : String,
  thinking~ : String,
  type_~ : String,
) -> RequestThinkingBlock {
  { signature, thinking, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestThinkingBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestThinkingBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("signature", self.signature)
  .field("thinking", self.thinking)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestThinkingBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestThinkingBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    signature: required_field(obj, "signature", path),
    thinking: required_field(obj, "thinking", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestToolResultBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestToolResultBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestToolResultBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestToolResultBlockCacheControl with fn to_json(self) {
  match self {
    RequestToolResultBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestToolResultBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestToolResultBlockCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolResultBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestToolResultBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestToolResultBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestBrowserStateBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestBrowserStateBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestBrowserStateBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestBrowserStateBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestBrowserStateBlockCacheControl with fn to_json(self) {
  match self {
    RequestBrowserStateBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestBrowserStateBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestBrowserStateBlockCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestBrowserStateBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestBrowserStateBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestBrowserStateBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// A file download that finished during this call, reported with the same `download_id` as its `download_started` — or without a prior `download_started`, when the download finished during the call that started it (at most one state change per `download_id` per result).
#derive(Eq, @debug.Debug)
pub(all) struct BrowserStateChangeDownloadCompleted {
  download_id : String
  path : @sdkjson.Presence[String]
  size_bytes : @sdkjson.Presence[Int32]
  type_ : String
  url : String
}

///|
pub extend BrowserStateChangeDownloadCompleted with Eq::{equal, not_equal}

///|
pub extend BrowserStateChangeDownloadCompleted with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserStateChangeDownloadCompleted with omitted optional fields absent.
pub fn BrowserStateChangeDownloadCompleted::new(
  download_id~ : String,
  type_~ : String,
  url~ : String,
  path? : String,
  size_bytes? : Int32,
) -> BrowserStateChangeDownloadCompleted {
  {
    download_id,
    path: @sdkjson.Presence::from_option(path),
    size_bytes: @sdkjson.Presence::from_option(size_bytes),
    type_,
    url,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserStateChangeDownloadCompleted with ToJson::{to_json}

///|
pub impl ToJson for BrowserStateChangeDownloadCompleted with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("download_id", self.download_id)
  .presence("path", self.path)
  .presence("size_bytes", self.size_bytes)
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserStateChangeDownloadCompleted with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserStateChangeDownloadCompleted with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    download_id: required_field(obj, "download_id", path),
    path: @sdkjson.presence_field(obj, "path", path),
    size_bytes: @sdkjson.presence_field(obj, "size_bytes", path),
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// A file download that failed — or was cancelled — during this call.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserStateChangeDownloadFailed {
  download_id : String
  error : @sdkjson.Presence[String]
  type_ : String
  url : String
}

///|
pub extend BrowserStateChangeDownloadFailed with Eq::{equal, not_equal}

///|
pub extend BrowserStateChangeDownloadFailed with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserStateChangeDownloadFailed with omitted optional fields absent.
pub fn BrowserStateChangeDownloadFailed::new(
  download_id~ : String,
  type_~ : String,
  url~ : String,
  error? : String,
) -> BrowserStateChangeDownloadFailed {
  { download_id, error: @sdkjson.Presence::from_option(error), type_, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserStateChangeDownloadFailed with ToJson::{to_json}

///|
pub impl ToJson for BrowserStateChangeDownloadFailed with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("download_id", self.download_id)
  .presence("error", self.error)
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserStateChangeDownloadFailed with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserStateChangeDownloadFailed with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    download_id: required_field(obj, "download_id", path),
    error: @sdkjson.presence_field(obj, "error", path),
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// A file download that started during this call.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserStateChangeDownloadStarted {
  download_id : String
  type_ : String
  url : String
}

///|
pub extend BrowserStateChangeDownloadStarted with Eq::{equal, not_equal}

///|
pub extend BrowserStateChangeDownloadStarted with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserStateChangeDownloadStarted with omitted optional fields absent.
pub fn BrowserStateChangeDownloadStarted::new(
  download_id~ : String,
  type_~ : String,
  url~ : String,
) -> BrowserStateChangeDownloadStarted {
  { download_id, type_, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserStateChangeDownloadStarted with ToJson::{to_json}

///|
pub impl ToJson for BrowserStateChangeDownloadStarted with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("download_id", self.download_id)
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserStateChangeDownloadStarted with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserStateChangeDownloadStarted with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    download_id: required_field(obj, "download_id", path),
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// A tab this call's execution opened that remains open at its end — the creation delta of the `tabs` inventory, not an event log. Carries only the `tab_id`; the tab's `title` and `url` live on its `tabs` entry, which must include the same `tab_id`. A tab opened during a failed call gets no deferred `tab_opened`; it simply appears in the next result's `tabs` inventory.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserStateChangeTabOpened {
  tab_id : String
  type_ : String
}

///|
pub extend BrowserStateChangeTabOpened with Eq::{equal, not_equal}

///|
pub extend BrowserStateChangeTabOpened with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserStateChangeTabOpened with omitted optional fields absent.
pub fn BrowserStateChangeTabOpened::new(
  tab_id~ : String,
  type_~ : String,
) -> BrowserStateChangeTabOpened {
  { tab_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserStateChangeTabOpened with ToJson::{to_json}

///|
pub impl ToJson for BrowserStateChangeTabOpened with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("tab_id", self.tab_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserStateChangeTabOpened with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserStateChangeTabOpened with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    tab_id: required_field(obj, "tab_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union RequestBrowserStateBlockStateChangesItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestBrowserStateBlockStateChangesItem {
  DownloadCompleted(BrowserStateChangeDownloadCompleted)
  DownloadFailed(BrowserStateChangeDownloadFailed)
  DownloadStarted(BrowserStateChangeDownloadStarted)
  TabOpened(BrowserStateChangeTabOpened)
  Unknown(String, Json)
}

///|
pub extend RequestBrowserStateBlockStateChangesItem with Eq::{equal, not_equal}

///|
pub extend RequestBrowserStateBlockStateChangesItem with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestBrowserStateBlockStateChangesItem with ToJson::{to_json}

///|
pub impl ToJson for RequestBrowserStateBlockStateChangesItem with fn to_json(
  self,
) {
  match self {
    RequestBrowserStateBlockStateChangesItem::DownloadCompleted(value) =>
      @json.Json::Json(value)
    RequestBrowserStateBlockStateChangesItem::DownloadFailed(value) =>
      @json.Json::Json(value)
    RequestBrowserStateBlockStateChangesItem::DownloadStarted(value) =>
      @json.Json::Json(value)
    RequestBrowserStateBlockStateChangesItem::TabOpened(value) =>
      @json.Json::Json(value)
    RequestBrowserStateBlockStateChangesItem::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestBrowserStateBlockStateChangesItem with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestBrowserStateBlockStateChangesItem with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "download_completed" =>
      RequestBrowserStateBlockStateChangesItem::DownloadCompleted(
        @json.from_json(value, path~),
      )
    "download_failed" =>
      RequestBrowserStateBlockStateChangesItem::DownloadFailed(
        @json.from_json(value, path~),
      )
    "download_started" =>
      RequestBrowserStateBlockStateChangesItem::DownloadStarted(
        @json.from_json(value, path~),
      )
    "tab_opened" =>
      RequestBrowserStateBlockStateChangesItem::TabOpened(
        @json.from_json(value, path~),
      )
    other => RequestBrowserStateBlockStateChangesItem::Unknown(other, value)
  }
}

///|
///
/// One open browser tab reported in a `browser_state` block's `tabs` inventory. `tab_id` is the caller-assigned identifier for the tab; `title` and `url` describe the page the tab is currently showing and may be empty strings (a blank tab legitimately has both empty). `active` marks the tab that is active after this call; whenever `tabs` is non-empty, exactly one entry is marked.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserStateTabEntry {
  active : Bool?
  tab_id : String
  title : String
  url : String
}

///|
pub extend BrowserStateTabEntry with Eq::{equal, not_equal}

///|
pub extend BrowserStateTabEntry with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserStateTabEntry with omitted optional fields absent.
pub fn BrowserStateTabEntry::new(
  tab_id~ : String,
  title~ : String,
  url~ : String,
  active? : Bool,
) -> BrowserStateTabEntry {
  { active, tab_id, title, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserStateTabEntry with ToJson::{to_json}

///|
pub impl ToJson for BrowserStateTabEntry with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("active", self.active)
  .field("tab_id", self.tab_id)
  .field("title", self.title)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserStateTabEntry with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserStateTabEntry with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    active: @sdkjson.opt_field(obj, "active", path),
    tab_id: required_field(obj, "tab_id", path),
    title: required_field(obj, "title", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// The caller's browser state after a browser toolset member call — the full inventory of open tabs, which tab is active, and any side effects (tabs opened, download state changes) the call produced. At most one per `tool_result`, only on a non-error result answering a browser toolset member `tool_use`. The server renders the model-visible text from it; the model never sees the raw fields.
#derive(Eq, @debug.Debug)
pub(all) struct RequestBrowserStateBlock {
  cache_control : @sdkjson.Presence[RequestBrowserStateBlockCacheControl]
  state_changes : @sdkjson.Presence[
    Array[RequestBrowserStateBlockStateChangesItem],
  ]
  tabs : Array[BrowserStateTabEntry]
  type_ : String
}

///|
pub extend RequestBrowserStateBlock with Eq::{equal, not_equal}

///|
pub extend RequestBrowserStateBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestBrowserStateBlock with omitted optional fields absent.
pub fn RequestBrowserStateBlock::new(
  tabs~ : Array[BrowserStateTabEntry],
  type_~ : String,
  cache_control? : RequestBrowserStateBlockCacheControl,
  state_changes? : Array[RequestBrowserStateBlockStateChangesItem],
) -> RequestBrowserStateBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    state_changes: @sdkjson.Presence::from_option(state_changes),
    tabs,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestBrowserStateBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestBrowserStateBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .presence("state_changes", self.state_changes)
  .field("tabs", self.tabs)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestBrowserStateBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestBrowserStateBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    state_changes: @sdkjson.presence_field(obj, "state_changes", path),
    tabs: required_field(obj, "tabs", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestToolReferenceBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestToolReferenceBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestToolReferenceBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestToolReferenceBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestToolReferenceBlockCacheControl with fn to_json(self) {
  match self {
    RequestToolReferenceBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestToolReferenceBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestToolReferenceBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestToolReferenceBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestToolReferenceBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestToolReferenceBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Tool reference block that can be included in tool_result content.
#derive(Eq, @debug.Debug)
pub(all) struct RequestToolReferenceBlock {
  cache_control : @sdkjson.Presence[RequestToolReferenceBlockCacheControl]
  tool_name : String
  type_ : String
}

///|
pub extend RequestToolReferenceBlock with Eq::{equal, not_equal}

///|
pub extend RequestToolReferenceBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestToolReferenceBlock with omitted optional fields absent.
pub fn RequestToolReferenceBlock::new(
  tool_name~ : String,
  type_~ : String,
  cache_control? : RequestToolReferenceBlockCacheControl,
) -> RequestToolReferenceBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    tool_name,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestToolReferenceBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestToolReferenceBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .field("tool_name", self.tool_name)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestToolReferenceBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolReferenceBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    tool_name: required_field(obj, "tool_name", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union RequestToolResultBlockContentValueArrayItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestToolResultBlockContentValueArrayItem {
  BrowserState(RequestBrowserStateBlock)
  Document(RequestDocumentBlock)
  Image(RequestImageBlock)
  SearchResult(RequestSearchResultBlock)
  Text(RequestTextBlock)
  ToolReference(RequestToolReferenceBlock)
  Unknown(String, Json)
}

///|
pub extend RequestToolResultBlockContentValueArrayItem with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestToolResultBlockContentValueArrayItem with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestToolResultBlockContentValueArrayItem with ToJson::{to_json}

///|
pub impl ToJson for RequestToolResultBlockContentValueArrayItem with fn to_json(
  self,
) {
  match self {
    RequestToolResultBlockContentValueArrayItem::BrowserState(value) =>
      @json.Json::Json(value)
    RequestToolResultBlockContentValueArrayItem::Document(value) =>
      @json.Json::Json(value)
    RequestToolResultBlockContentValueArrayItem::Image(value) =>
      @json.Json::Json(value)
    RequestToolResultBlockContentValueArrayItem::SearchResult(value) =>
      @json.Json::Json(value)
    RequestToolResultBlockContentValueArrayItem::Text(value) =>
      @json.Json::Json(value)
    RequestToolResultBlockContentValueArrayItem::ToolReference(value) =>
      @json.Json::Json(value)
    RequestToolResultBlockContentValueArrayItem::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestToolResultBlockContentValueArrayItem with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestToolResultBlockContentValueArrayItem with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "browser_state" =>
      RequestToolResultBlockContentValueArrayItem::BrowserState(
        @json.from_json(value, path~),
      )
    "document" =>
      RequestToolResultBlockContentValueArrayItem::Document(
        @json.from_json(value, path~),
      )
    "image" =>
      RequestToolResultBlockContentValueArrayItem::Image(
        @json.from_json(value, path~),
      )
    "search_result" =>
      RequestToolResultBlockContentValueArrayItem::SearchResult(
        @json.from_json(value, path~),
      )
    "text" =>
      RequestToolResultBlockContentValueArrayItem::Text(
        @json.from_json(value, path~),
      )
    "tool_reference" =>
      RequestToolResultBlockContentValueArrayItem::ToolReference(
        @json.from_json(value, path~),
      )
    other => RequestToolResultBlockContentValueArrayItem::Unknown(other, value)
  }
}

///|
///
/// Generated untagged union RequestToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestToolResultBlockContent {
  Text(String)
  ValueArray(Array[RequestToolResultBlockContentValueArrayItem])
}

///|
pub extend RequestToolResultBlockContent with Eq::{equal, not_equal}

///|
pub extend RequestToolResultBlockContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend RequestToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for RequestToolResultBlockContent with fn to_json(self) {
  match self {
    RequestToolResultBlockContent::Text(value) => @json.Json::Json(value)
    RequestToolResultBlockContent::ValueArray(value) => @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend RequestToolResultBlockContent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolResultBlockContent with fn from_json(
  value,
  path,
) {
  if value is @json.Json::String(_) {
    let decoded : String = @json.from_json(value, path~)
    return RequestToolResultBlockContent::Text(decoded)
  }
  if json_array_matches(value, item => item is @json.Json::Object(_)) {
    let decoded : Array[RequestToolResultBlockContentValueArrayItem] = @json.from_json(
      value,
      path~,
    )
    return RequestToolResultBlockContent::ValueArray(decoded)
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (
      path, "JSON shape does not match any RequestToolResultBlockContent variant",
    ),
  )
}

///|
///
/// Generated representation of RequestToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestToolResultBlock {
  cache_control : @sdkjson.Presence[RequestToolResultBlockCacheControl]
  content : RequestToolResultBlockContent?
  is_error : Bool?
  tool_use_id : String
  toolset_name : @sdkjson.Presence[String]
  type_ : String
}

///|
pub extend RequestToolResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestToolResultBlock with omitted optional fields absent.
pub fn RequestToolResultBlock::new(
  tool_use_id~ : String,
  type_~ : String,
  cache_control? : RequestToolResultBlockCacheControl,
  content? : RequestToolResultBlockContent,
  is_error? : Bool,
  toolset_name? : String,
) -> RequestToolResultBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    content,
    is_error,
    tool_use_id,
    toolset_name: @sdkjson.Presence::from_option(toolset_name),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .opt("content", self.content)
  .opt("is_error", self.is_error)
  .field("tool_use_id", self.tool_use_id)
  .presence("toolset_name", self.toolset_name)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    content: @sdkjson.opt_field(obj, "content", path),
    is_error: @sdkjson.opt_field(obj, "is_error", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    toolset_name: @sdkjson.presence_field(obj, "toolset_name", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestToolSearchToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestToolSearchToolResultBlockCacheControl with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestToolSearchToolResultBlockCacheControl with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestToolSearchToolResultBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestToolSearchToolResultBlockCacheControl with fn to_json(
  self,
) {
  match self {
    RequestToolSearchToolResultBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestToolSearchToolResultBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestToolSearchToolResultBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestToolSearchToolResultBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestToolSearchToolResultBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestToolSearchToolResultBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated string enum ToolSearchToolResultErrorCode.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolSearchToolResultErrorCode {
  InvalidToolInput
  Unavailable
  TooManyRequests
  ExecutionTimeExceeded
  Unknown(String)
}

///|
pub extend ToolSearchToolResultErrorCode with Eq::{equal, not_equal}

///|
pub extend ToolSearchToolResultErrorCode with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ToolSearchToolResultErrorCode with ToJson::{to_json}

///|
pub impl ToJson for ToolSearchToolResultErrorCode with fn to_json(self) {
  let raw = match self {
    ToolSearchToolResultErrorCode::InvalidToolInput => "invalid_tool_input"
    ToolSearchToolResultErrorCode::Unavailable => "unavailable"
    ToolSearchToolResultErrorCode::TooManyRequests => "too_many_requests"
    ToolSearchToolResultErrorCode::ExecutionTimeExceeded =>
      "execution_time_exceeded"
    ToolSearchToolResultErrorCode::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ToolSearchToolResultErrorCode with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolSearchToolResultErrorCode with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "invalid_tool_input" =>
          Option::Some(ToolSearchToolResultErrorCode::InvalidToolInput)
        "unavailable" =>
          Option::Some(ToolSearchToolResultErrorCode::Unavailable)
        "too_many_requests" =>
          Option::Some(ToolSearchToolResultErrorCode::TooManyRequests)
        "execution_time_exceeded" =>
          Option::Some(ToolSearchToolResultErrorCode::ExecutionTimeExceeded)
        _ => Option::None
      }
    },
    raw => ToolSearchToolResultErrorCode::Unknown(raw),
  )
}

///|
///
/// Generated representation of RequestToolSearchToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct RequestToolSearchToolResultError {
  error_code : ToolSearchToolResultErrorCode
  error_message : @sdkjson.Presence[String]
  type_ : String
}

///|
pub extend RequestToolSearchToolResultError with Eq::{equal, not_equal}

///|
pub extend RequestToolSearchToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestToolSearchToolResultError with omitted optional fields absent.
pub fn RequestToolSearchToolResultError::new(
  error_code~ : ToolSearchToolResultErrorCode,
  type_~ : String,
  error_message? : String,
) -> RequestToolSearchToolResultError {
  {
    error_code,
    error_message: @sdkjson.Presence::from_option(error_message),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestToolSearchToolResultError with ToJson::{to_json}

///|
pub impl ToJson for RequestToolSearchToolResultError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .presence("error_message", self.error_message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestToolSearchToolResultError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolSearchToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    error_message: @sdkjson.presence_field(obj, "error_message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestToolSearchToolSearchResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestToolSearchToolSearchResultBlock {
  tool_references : Array[RequestToolReferenceBlock]
  type_ : String
}

///|
pub extend RequestToolSearchToolSearchResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestToolSearchToolSearchResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestToolSearchToolSearchResultBlock with omitted optional fields absent.
pub fn RequestToolSearchToolSearchResultBlock::new(
  tool_references~ : Array[RequestToolReferenceBlock],
  type_~ : String,
) -> RequestToolSearchToolSearchResultBlock {
  { tool_references, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestToolSearchToolSearchResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestToolSearchToolSearchResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("tool_references", self.tool_references)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestToolSearchToolSearchResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestToolSearchToolSearchResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    tool_references: required_field(obj, "tool_references", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union RequestToolSearchToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestToolSearchToolResultBlockContent {
  ToolSearchToolResultError(RequestToolSearchToolResultError)
  ToolSearchToolSearchResult(RequestToolSearchToolSearchResultBlock)
  Unknown(String, Json)
}

///|
pub extend RequestToolSearchToolResultBlockContent with Eq::{equal, not_equal}

///|
pub extend RequestToolSearchToolResultBlockContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestToolSearchToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for RequestToolSearchToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    RequestToolSearchToolResultBlockContent::ToolSearchToolResultError(value) =>
      @json.Json::Json(value)
    RequestToolSearchToolResultBlockContent::ToolSearchToolSearchResult(value) =>
      @json.Json::Json(value)
    RequestToolSearchToolResultBlockContent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestToolSearchToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestToolSearchToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "tool_search_tool_result_error" =>
      RequestToolSearchToolResultBlockContent::ToolSearchToolResultError(
        @json.from_json(value, path~),
      )
    "tool_search_tool_search_result" =>
      RequestToolSearchToolResultBlockContent::ToolSearchToolSearchResult(
        @json.from_json(value, path~),
      )
    other => RequestToolSearchToolResultBlockContent::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestToolSearchToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestToolSearchToolResultBlock {
  cache_control : @sdkjson.Presence[
    RequestToolSearchToolResultBlockCacheControl,
  ]
  content : RequestToolSearchToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend RequestToolSearchToolResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestToolSearchToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestToolSearchToolResultBlock with omitted optional fields absent.
pub fn RequestToolSearchToolResultBlock::new(
  content~ : RequestToolSearchToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
  cache_control? : RequestToolSearchToolResultBlockCacheControl,
) -> RequestToolSearchToolResultBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    content,
    tool_use_id,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestToolSearchToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestToolSearchToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestToolSearchToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolSearchToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestToolUseBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestToolUseBlockCacheControl with Eq::{equal, not_equal}

///|
pub extend RequestToolUseBlockCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestToolUseBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestToolUseBlockCacheControl with fn to_json(self) {
  match self {
    RequestToolUseBlockCacheControl::Ephemeral(value) => @json.Json::Json(value)
    RequestToolUseBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestToolUseBlockCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolUseBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestToolUseBlockCacheControl::Ephemeral(@json.from_json(value, path~))
    other => RequestToolUseBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated tagged union RequestToolUseBlockCaller.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestToolUseBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
}

///|
pub extend RequestToolUseBlockCaller with Eq::{equal, not_equal}

///|
pub extend RequestToolUseBlockCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestToolUseBlockCaller with ToJson::{to_json}

///|
pub impl ToJson for RequestToolUseBlockCaller with fn to_json(self) {
  match self {
    RequestToolUseBlockCaller::CodeExecution20250825(value) =>
      @json.Json::Json(value)
    RequestToolUseBlockCaller::CodeExecution20260120(value) =>
      @json.Json::Json(value)
    RequestToolUseBlockCaller::Direct(value) => @json.Json::Json(value)
    RequestToolUseBlockCaller::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestToolUseBlockCaller with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolUseBlockCaller with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_20250825" =>
      RequestToolUseBlockCaller::CodeExecution20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      RequestToolUseBlockCaller::CodeExecution20260120(
        @json.from_json(value, path~),
      )
    "direct" => RequestToolUseBlockCaller::Direct(@json.from_json(value, path~))
    other => RequestToolUseBlockCaller::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestToolUseBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestToolUseBlock {
  cache_control : @sdkjson.Presence[RequestToolUseBlockCacheControl]
  caller : RequestToolUseBlockCaller?
  id : String
  input : Json
  name : String
  toolset_name : @sdkjson.Presence[String]
  type_ : String
}

///|
pub extend RequestToolUseBlock with Eq::{equal, not_equal}

///|
pub extend RequestToolUseBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestToolUseBlock with omitted optional fields absent.
pub fn RequestToolUseBlock::new(
  id~ : String,
  input~ : Json,
  name~ : String,
  type_~ : String,
  cache_control? : RequestToolUseBlockCacheControl,
  caller? : RequestToolUseBlockCaller,
  toolset_name? : String,
) -> RequestToolUseBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    caller,
    id,
    input,
    name,
    toolset_name: @sdkjson.Presence::from_option(toolset_name),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestToolUseBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestToolUseBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .opt("caller", self.caller)
  .field("id", self.id)
  .field("input", self.input)
  .field("name", self.name)
  .presence("toolset_name", self.toolset_name)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestToolUseBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestToolUseBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    caller: @sdkjson.opt_field(obj, "caller", path),
    id: required_field(obj, "id", path),
    input: required_field(obj, "input", path),
    name: required_field(obj, "name", path),
    toolset_name: @sdkjson.presence_field(obj, "toolset_name", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestWebFetchToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestWebFetchToolResultBlockCacheControl with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestWebFetchToolResultBlockCacheControl with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestWebFetchToolResultBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestWebFetchToolResultBlockCacheControl with fn to_json(
  self,
) {
  match self {
    RequestWebFetchToolResultBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestWebFetchToolResultBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestWebFetchToolResultBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestWebFetchToolResultBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestWebFetchToolResultBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestWebFetchToolResultBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated tagged union RequestWebFetchToolResultBlockCaller.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestWebFetchToolResultBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
}

///|
pub extend RequestWebFetchToolResultBlockCaller with Eq::{equal, not_equal}

///|
pub extend RequestWebFetchToolResultBlockCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestWebFetchToolResultBlockCaller with ToJson::{to_json}

///|
pub impl ToJson for RequestWebFetchToolResultBlockCaller with fn to_json(self) {
  match self {
    RequestWebFetchToolResultBlockCaller::CodeExecution20250825(value) =>
      @json.Json::Json(value)
    RequestWebFetchToolResultBlockCaller::CodeExecution20260120(value) =>
      @json.Json::Json(value)
    RequestWebFetchToolResultBlockCaller::Direct(value) =>
      @json.Json::Json(value)
    RequestWebFetchToolResultBlockCaller::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestWebFetchToolResultBlockCaller with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestWebFetchToolResultBlockCaller with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_20250825" =>
      RequestWebFetchToolResultBlockCaller::CodeExecution20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      RequestWebFetchToolResultBlockCaller::CodeExecution20260120(
        @json.from_json(value, path~),
      )
    "direct" =>
      RequestWebFetchToolResultBlockCaller::Direct(
        @json.from_json(value, path~),
      )
    other => RequestWebFetchToolResultBlockCaller::Unknown(other, value)
  }
}

///|
///
/// Generated string enum WebFetchToolResultErrorCode.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchToolResultErrorCode {
  InvalidToolInput
  UrlTooLong
  UrlNotAllowed
  UrlNotInPriorContext
  UrlNotAccessible
  UnsupportedContentType
  TooManyRequests
  MaxUsesExceeded
  Unavailable
  ContentTooLarge
  Unknown(String)
}

///|
pub extend WebFetchToolResultErrorCode with Eq::{equal, not_equal}

///|
pub extend WebFetchToolResultErrorCode with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend WebFetchToolResultErrorCode with ToJson::{to_json}

///|
pub impl ToJson for WebFetchToolResultErrorCode with fn to_json(self) {
  let raw = match self {
    WebFetchToolResultErrorCode::InvalidToolInput => "invalid_tool_input"
    WebFetchToolResultErrorCode::UrlTooLong => "url_too_long"
    WebFetchToolResultErrorCode::UrlNotAllowed => "url_not_allowed"
    WebFetchToolResultErrorCode::UrlNotInPriorContext =>
      "url_not_in_prior_context"
    WebFetchToolResultErrorCode::UrlNotAccessible => "url_not_accessible"
    WebFetchToolResultErrorCode::UnsupportedContentType =>
      "unsupported_content_type"
    WebFetchToolResultErrorCode::TooManyRequests => "too_many_requests"
    WebFetchToolResultErrorCode::MaxUsesExceeded => "max_uses_exceeded"
    WebFetchToolResultErrorCode::Unavailable => "unavailable"
    WebFetchToolResultErrorCode::ContentTooLarge => "content_too_large"
    WebFetchToolResultErrorCode::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend WebFetchToolResultErrorCode with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchToolResultErrorCode with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "invalid_tool_input" =>
          Option::Some(WebFetchToolResultErrorCode::InvalidToolInput)
        "url_too_long" => Option::Some(WebFetchToolResultErrorCode::UrlTooLong)
        "url_not_allowed" =>
          Option::Some(WebFetchToolResultErrorCode::UrlNotAllowed)
        "url_not_in_prior_context" =>
          Option::Some(WebFetchToolResultErrorCode::UrlNotInPriorContext)
        "url_not_accessible" =>
          Option::Some(WebFetchToolResultErrorCode::UrlNotAccessible)
        "unsupported_content_type" =>
          Option::Some(WebFetchToolResultErrorCode::UnsupportedContentType)
        "too_many_requests" =>
          Option::Some(WebFetchToolResultErrorCode::TooManyRequests)
        "max_uses_exceeded" =>
          Option::Some(WebFetchToolResultErrorCode::MaxUsesExceeded)
        "unavailable" => Option::Some(WebFetchToolResultErrorCode::Unavailable)
        "content_too_large" =>
          Option::Some(WebFetchToolResultErrorCode::ContentTooLarge)
        _ => Option::None
      }
    },
    raw => WebFetchToolResultErrorCode::Unknown(raw),
  )
}

///|
///
/// Generated representation of RequestWebFetchToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct RequestWebFetchToolResultError {
  error_code : WebFetchToolResultErrorCode
  type_ : String
}

///|
pub extend RequestWebFetchToolResultError with Eq::{equal, not_equal}

///|
pub extend RequestWebFetchToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestWebFetchToolResultError with omitted optional fields absent.
pub fn RequestWebFetchToolResultError::new(
  error_code~ : WebFetchToolResultErrorCode,
  type_~ : String,
) -> RequestWebFetchToolResultError {
  { error_code, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestWebFetchToolResultError with ToJson::{to_json}

///|
pub impl ToJson for RequestWebFetchToolResultError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestWebFetchToolResultError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestWebFetchToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RequestWebFetchResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestWebFetchResultBlock {
  content : RequestDocumentBlock
  retrieved_at : @sdkjson.Presence[String]
  type_ : String
  url : String
}

///|
pub extend RequestWebFetchResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestWebFetchResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestWebFetchResultBlock with omitted optional fields absent.
pub fn RequestWebFetchResultBlock::new(
  content~ : RequestDocumentBlock,
  type_~ : String,
  url~ : String,
  retrieved_at? : String,
) -> RequestWebFetchResultBlock {
  {
    content,
    retrieved_at: @sdkjson.Presence::from_option(retrieved_at),
    type_,
    url,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestWebFetchResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestWebFetchResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .presence("retrieved_at", self.retrieved_at)
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestWebFetchResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestWebFetchResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    retrieved_at: @sdkjson.presence_field(obj, "retrieved_at", path),
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// Generated tagged union RequestWebFetchToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestWebFetchToolResultBlockContent {
  WebFetchToolResultError(RequestWebFetchToolResultError)
  WebFetchResult(RequestWebFetchResultBlock)
  Unknown(String, Json)
}

///|
pub extend RequestWebFetchToolResultBlockContent with Eq::{equal, not_equal}

///|
pub extend RequestWebFetchToolResultBlockContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestWebFetchToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for RequestWebFetchToolResultBlockContent with fn to_json(self) {
  match self {
    RequestWebFetchToolResultBlockContent::WebFetchToolResultError(value) =>
      @json.Json::Json(value)
    RequestWebFetchToolResultBlockContent::WebFetchResult(value) =>
      @json.Json::Json(value)
    RequestWebFetchToolResultBlockContent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestWebFetchToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestWebFetchToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "web_fetch_tool_result_error" =>
      RequestWebFetchToolResultBlockContent::WebFetchToolResultError(
        @json.from_json(value, path~),
      )
    "web_fetch_result" =>
      RequestWebFetchToolResultBlockContent::WebFetchResult(
        @json.from_json(value, path~),
      )
    other => RequestWebFetchToolResultBlockContent::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestWebFetchToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestWebFetchToolResultBlock {
  cache_control : @sdkjson.Presence[RequestWebFetchToolResultBlockCacheControl]
  caller : RequestWebFetchToolResultBlockCaller?
  content : RequestWebFetchToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend RequestWebFetchToolResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestWebFetchToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestWebFetchToolResultBlock with omitted optional fields absent.
pub fn RequestWebFetchToolResultBlock::new(
  content~ : RequestWebFetchToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
  cache_control? : RequestWebFetchToolResultBlockCacheControl,
  caller? : RequestWebFetchToolResultBlockCaller,
) -> RequestWebFetchToolResultBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    caller,
    content,
    tool_use_id,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestWebFetchToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestWebFetchToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .opt("caller", self.caller)
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestWebFetchToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestWebFetchToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    caller: @sdkjson.opt_field(obj, "caller", path),
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestWebSearchToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend RequestWebSearchToolResultBlockCacheControl with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestWebSearchToolResultBlockCacheControl with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestWebSearchToolResultBlockCacheControl with ToJson::{to_json}

///|
pub impl ToJson for RequestWebSearchToolResultBlockCacheControl with fn to_json(
  self,
) {
  match self {
    RequestWebSearchToolResultBlockCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    RequestWebSearchToolResultBlockCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestWebSearchToolResultBlockCacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestWebSearchToolResultBlockCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      RequestWebSearchToolResultBlockCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => RequestWebSearchToolResultBlockCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated tagged union RequestWebSearchToolResultBlockCaller.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestWebSearchToolResultBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
}

///|
pub extend RequestWebSearchToolResultBlockCaller with Eq::{equal, not_equal}

///|
pub extend RequestWebSearchToolResultBlockCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend RequestWebSearchToolResultBlockCaller with ToJson::{to_json}

///|
pub impl ToJson for RequestWebSearchToolResultBlockCaller with fn to_json(self) {
  match self {
    RequestWebSearchToolResultBlockCaller::CodeExecution20250825(value) =>
      @json.Json::Json(value)
    RequestWebSearchToolResultBlockCaller::CodeExecution20260120(value) =>
      @json.Json::Json(value)
    RequestWebSearchToolResultBlockCaller::Direct(value) =>
      @json.Json::Json(value)
    RequestWebSearchToolResultBlockCaller::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend RequestWebSearchToolResultBlockCaller with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestWebSearchToolResultBlockCaller with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_20250825" =>
      RequestWebSearchToolResultBlockCaller::CodeExecution20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      RequestWebSearchToolResultBlockCaller::CodeExecution20260120(
        @json.from_json(value, path~),
      )
    "direct" =>
      RequestWebSearchToolResultBlockCaller::Direct(
        @json.from_json(value, path~),
      )
    other => RequestWebSearchToolResultBlockCaller::Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestWebSearchResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestWebSearchResultBlock {
  encrypted_content : String
  page_age : @sdkjson.Presence[String]
  title : String
  url : String
}

///|
pub extend RequestWebSearchResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestWebSearchResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestWebSearchResultBlock with omitted optional fields absent.
pub fn RequestWebSearchResultBlock::new(
  encrypted_content~ : String,
  title~ : String,
  url~ : String,
  page_age? : String,
) -> RequestWebSearchResultBlock {
  {
    encrypted_content,
    page_age: @sdkjson.Presence::from_option(page_age),
    title,
    url,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestWebSearchResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestWebSearchResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("encrypted_content", self.encrypted_content)
  .presence("page_age", self.page_age)
  .field("title", self.title)
  .field("type", "web_search_result")
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestWebSearchResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestWebSearchResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    encrypted_content: required_field(obj, "encrypted_content", path),
    page_age: @sdkjson.presence_field(obj, "page_age", path),
    title: required_field(obj, "title", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// Generated string enum WebSearchToolResultErrorCode.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebSearchToolResultErrorCode {
  InvalidToolInput
  Unavailable
  MaxUsesExceeded
  TooManyRequests
  QueryTooLong
  RequestTooLarge
  Unknown(String)
}

///|
pub extend WebSearchToolResultErrorCode with Eq::{equal, not_equal}

///|
pub extend WebSearchToolResultErrorCode with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend WebSearchToolResultErrorCode with ToJson::{to_json}

///|
pub impl ToJson for WebSearchToolResultErrorCode with fn to_json(self) {
  let raw = match self {
    WebSearchToolResultErrorCode::InvalidToolInput => "invalid_tool_input"
    WebSearchToolResultErrorCode::Unavailable => "unavailable"
    WebSearchToolResultErrorCode::MaxUsesExceeded => "max_uses_exceeded"
    WebSearchToolResultErrorCode::TooManyRequests => "too_many_requests"
    WebSearchToolResultErrorCode::QueryTooLong => "query_too_long"
    WebSearchToolResultErrorCode::RequestTooLarge => "request_too_large"
    WebSearchToolResultErrorCode::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend WebSearchToolResultErrorCode with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebSearchToolResultErrorCode with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "invalid_tool_input" =>
          Option::Some(WebSearchToolResultErrorCode::InvalidToolInput)
        "unavailable" => Option::Some(WebSearchToolResultErrorCode::Unavailable)
        "max_uses_exceeded" =>
          Option::Some(WebSearchToolResultErrorCode::MaxUsesExceeded)
        "too_many_requests" =>
          Option::Some(WebSearchToolResultErrorCode::TooManyRequests)
        "query_too_long" =>
          Option::Some(WebSearchToolResultErrorCode::QueryTooLong)
        "request_too_large" =>
          Option::Some(WebSearchToolResultErrorCode::RequestTooLarge)
        _ => Option::None
      }
    },
    raw => WebSearchToolResultErrorCode::Unknown(raw),
  )
}

///|
///
/// Generated representation of RequestWebSearchToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct RequestWebSearchToolResultError {
  error_code : WebSearchToolResultErrorCode
}

///|
pub extend RequestWebSearchToolResultError with Eq::{equal, not_equal}

///|
pub extend RequestWebSearchToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestWebSearchToolResultError with omitted optional fields absent.
pub fn RequestWebSearchToolResultError::new(
  error_code~ : WebSearchToolResultErrorCode,
) -> RequestWebSearchToolResultError {
  { error_code, }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestWebSearchToolResultError with ToJson::{to_json}

///|
pub impl ToJson for RequestWebSearchToolResultError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .field("type", "web_search_tool_result_error")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestWebSearchToolResultError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestWebSearchToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { error_code: required_field(obj, "error_code", path), }
}

///|
///
/// Generated untagged union RequestWebSearchToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RequestWebSearchToolResultBlockContent {
  RequestWebSearchResultBlockArray(Array[RequestWebSearchResultBlock])
  RequestWebSearchToolResultError(RequestWebSearchToolResultError)
}

///|
pub extend RequestWebSearchToolResultBlockContent with Eq::{equal, not_equal}

///|
pub extend RequestWebSearchToolResultBlockContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend RequestWebSearchToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for RequestWebSearchToolResultBlockContent with fn to_json(self) {
  match self {
    RequestWebSearchToolResultBlockContent::RequestWebSearchResultBlockArray(
      value,
    ) => @json.Json::Json(value)
    RequestWebSearchToolResultBlockContent::RequestWebSearchToolResultError(
      value,
    ) => @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend RequestWebSearchToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestWebSearchToolResultBlockContent with fn from_json(
  value,
  path,
) {
  if json_array_matches(value, item => item is @json.Json::Object(_)) {
    let decoded : Array[RequestWebSearchResultBlock] = @json.from_json(
      value,
      path~,
    )
    return RequestWebSearchToolResultBlockContent::RequestWebSearchResultBlockArray(
      decoded,
    )
  }
  if value is @json.Json::Object(_) {
    let decoded : RequestWebSearchToolResultError = @json.from_json(
      value,
      path~,
    )
    return RequestWebSearchToolResultBlockContent::RequestWebSearchToolResultError(
      decoded,
    )
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (
      path, "JSON shape does not match any RequestWebSearchToolResultBlockContent variant",
    ),
  )
}

///|
///
/// Generated representation of RequestWebSearchToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct RequestWebSearchToolResultBlock {
  cache_control : @sdkjson.Presence[RequestWebSearchToolResultBlockCacheControl]
  caller : RequestWebSearchToolResultBlockCaller?
  content : RequestWebSearchToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend RequestWebSearchToolResultBlock with Eq::{equal, not_equal}

///|
pub extend RequestWebSearchToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a RequestWebSearchToolResultBlock with omitted optional fields absent.
pub fn RequestWebSearchToolResultBlock::new(
  content~ : RequestWebSearchToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
  cache_control? : RequestWebSearchToolResultBlockCacheControl,
  caller? : RequestWebSearchToolResultBlockCaller,
) -> RequestWebSearchToolResultBlock {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    caller,
    content,
    tool_use_id,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend RequestWebSearchToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for RequestWebSearchToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .opt("caller", self.caller)
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestWebSearchToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RequestWebSearchToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    caller: @sdkjson.opt_field(obj, "caller", path),
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union InputContentBlock.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum InputContentBlock {
  BashCodeExecutionToolResult(RequestBashCodeExecutionToolResultBlock)
  CodeExecutionToolResult(RequestCodeExecutionToolResultBlock)
  ContainerUpload(RequestContainerUploadBlock)
  Document(RequestDocumentBlock)
  Image(RequestImageBlock)
  RedactedThinking(RequestRedactedThinkingBlock)
  SearchResult(RequestSearchResultBlock)
  ServerToolUse(RequestServerToolUseBlock)
  Text(RequestTextBlock)
  TextEditorCodeExecutionToolResult(
    RequestTextEditorCodeExecutionToolResultBlock,
  )
  Thinking(RequestThinkingBlock)
  ToolResult(RequestToolResultBlock)
  ToolSearchToolResult(RequestToolSearchToolResultBlock)
  ToolUse(RequestToolUseBlock)
  WebFetchToolResult(RequestWebFetchToolResultBlock)
  WebSearchToolResult(RequestWebSearchToolResultBlock)
  Unknown(String, Json)
}

///|
pub extend InputContentBlock with Eq::{equal, not_equal}

///|
pub extend InputContentBlock with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend InputContentBlock with ToJson::{to_json}

///|
pub impl ToJson for InputContentBlock with fn to_json(self) {
  match self {
    InputContentBlock::BashCodeExecutionToolResult(value) =>
      @json.Json::Json(value)
    InputContentBlock::CodeExecutionToolResult(value) => @json.Json::Json(value)
    InputContentBlock::ContainerUpload(value) => @json.Json::Json(value)
    InputContentBlock::Document(value) => @json.Json::Json(value)
    InputContentBlock::Image(value) => @json.Json::Json(value)
    InputContentBlock::RedactedThinking(value) => @json.Json::Json(value)
    InputContentBlock::SearchResult(value) => @json.Json::Json(value)
    InputContentBlock::ServerToolUse(value) => @json.Json::Json(value)
    InputContentBlock::Text(value) => @json.Json::Json(value)
    InputContentBlock::TextEditorCodeExecutionToolResult(value) =>
      @json.Json::Json(value)
    InputContentBlock::Thinking(value) => @json.Json::Json(value)
    InputContentBlock::ToolResult(value) => @json.Json::Json(value)
    InputContentBlock::ToolSearchToolResult(value) => @json.Json::Json(value)
    InputContentBlock::ToolUse(value) => @json.Json::Json(value)
    InputContentBlock::WebFetchToolResult(value) => @json.Json::Json(value)
    InputContentBlock::WebSearchToolResult(value) => @json.Json::Json(value)
    InputContentBlock::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend InputContentBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for InputContentBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "bash_code_execution_tool_result" =>
      InputContentBlock::BashCodeExecutionToolResult(
        @json.from_json(value, path~),
      )
    "code_execution_tool_result" =>
      InputContentBlock::CodeExecutionToolResult(@json.from_json(value, path~))
    "container_upload" =>
      InputContentBlock::ContainerUpload(@json.from_json(value, path~))
    "document" => InputContentBlock::Document(@json.from_json(value, path~))
    "image" => InputContentBlock::Image(@json.from_json(value, path~))
    "redacted_thinking" =>
      InputContentBlock::RedactedThinking(@json.from_json(value, path~))
    "search_result" =>
      InputContentBlock::SearchResult(@json.from_json(value, path~))
    "server_tool_use" =>
      InputContentBlock::ServerToolUse(@json.from_json(value, path~))
    "text" => InputContentBlock::Text(@json.from_json(value, path~))
    "text_editor_code_execution_tool_result" =>
      InputContentBlock::TextEditorCodeExecutionToolResult(
        @json.from_json(value, path~),
      )
    "thinking" => InputContentBlock::Thinking(@json.from_json(value, path~))
    "tool_result" =>
      InputContentBlock::ToolResult(@json.from_json(value, path~))
    "tool_search_tool_result" =>
      InputContentBlock::ToolSearchToolResult(@json.from_json(value, path~))
    "tool_use" => InputContentBlock::ToolUse(@json.from_json(value, path~))
    "web_fetch_tool_result" =>
      InputContentBlock::WebFetchToolResult(@json.from_json(value, path~))
    "web_search_tool_result" =>
      InputContentBlock::WebSearchToolResult(@json.from_json(value, path~))
    other => InputContentBlock::Unknown(other, value)
  }
}

///|
///
/// Generated untagged union InputMessageContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum InputMessageContent {
  Text(String)
  InputContentBlockArray(Array[InputContentBlock])
}

///|
pub extend InputMessageContent with Eq::{equal, not_equal}

///|
pub extend InputMessageContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend InputMessageContent with ToJson::{to_json}

///|
pub impl ToJson for InputMessageContent with fn to_json(self) {
  match self {
    InputMessageContent::Text(value) => @json.Json::Json(value)
    InputMessageContent::InputContentBlockArray(value) =>
      @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend InputMessageContent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for InputMessageContent with fn from_json(value, path) {
  if value is @json.Json::String(_) {
    let decoded : String = @json.from_json(value, path~)
    return InputMessageContent::Text(decoded)
  }
  if json_array_matches(value, item => item is @json.Json::Object(_)) {
    let decoded : Array[InputContentBlock] = @json.from_json(value, path~)
    return InputMessageContent::InputContentBlockArray(decoded)
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (path, "JSON shape does not match any InputMessageContent variant"),
  )
}

///|
///
/// Generated representation of AssistantInputMessage.
#derive(Eq, @debug.Debug)
pub(all) struct AssistantInputMessage {
  content : InputMessageContent
  role : String
}

///|
pub extend AssistantInputMessage with Eq::{equal, not_equal}

///|
pub extend AssistantInputMessage with @debug.Debug::{to_repr}

///|
///
/// Creates a AssistantInputMessage with omitted optional fields absent.
pub fn AssistantInputMessage::new(
  content~ : InputMessageContent,
  role~ : String,
) -> AssistantInputMessage {
  { content, role, }
}

///|
///
/// Encodes this value as JSON.
pub extend AssistantInputMessage with ToJson::{to_json}

///|
pub impl ToJson for AssistantInputMessage with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("role", self.role)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend AssistantInputMessage with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for AssistantInputMessage with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    role: required_field(obj, "role", path),
  }
}

///|
///
/// Generated representation of AuthenticationError.
#derive(Eq, @debug.Debug)
pub(all) struct AuthenticationError {
  message : String
  type_ : String
}

///|
pub extend AuthenticationError with Eq::{equal, not_equal}

///|
pub extend AuthenticationError with @debug.Debug::{to_repr}

///|
///
/// Creates a AuthenticationError with omitted optional fields absent.
pub fn AuthenticationError::new(
  message~ : String,
  type_~ : String,
) -> AuthenticationError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend AuthenticationError with ToJson::{to_json}

///|
pub impl ToJson for AuthenticationError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend AuthenticationError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for AuthenticationError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// The tools available after a message exceed a limit on their number or their size.
#derive(Eq, @debug.Debug)
pub(all) struct AvailableToolsLimitExceededErrorDetails {}

///|
pub extend AvailableToolsLimitExceededErrorDetails with Eq::{equal, not_equal}

///|
pub extend AvailableToolsLimitExceededErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend AvailableToolsLimitExceededErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for AvailableToolsLimitExceededErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "available_tools_limit_exceeded")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend AvailableToolsLimitExceededErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for AvailableToolsLimitExceededErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  AvailableToolsLimitExceededErrorDetails::{ }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum BashTool20250124CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend BashTool20250124CacheControl with Eq::{equal, not_equal}

///|
pub extend BashTool20250124CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend BashTool20250124CacheControl with ToJson::{to_json}

///|
pub impl ToJson for BashTool20250124CacheControl with fn to_json(self) {
  match self {
    BashTool20250124CacheControl::Ephemeral(value) => @json.Json::Json(value)
    BashTool20250124CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend BashTool20250124CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BashTool20250124CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      BashTool20250124CacheControl::Ephemeral(@json.from_json(value, path~))
    other => BashTool20250124CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of BashTool20250124.
#derive(Eq, @debug.Debug)
pub(all) struct BashTool20250124 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[BashTool20250124CacheControl]
  defer_loading : Bool?
  input_examples : Array[Map[String, Json]]?
  strict : Bool?
  type_ : String
}

///|
pub extend BashTool20250124 with Eq::{equal, not_equal}

///|
pub extend BashTool20250124 with @debug.Debug::{to_repr}

///|
///
/// Creates a BashTool20250124 with omitted optional fields absent.
pub fn BashTool20250124::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : BashTool20250124CacheControl,
  defer_loading? : Bool,
  input_examples? : Array[Map[String, Json]],
  strict? : Bool,
) -> BashTool20250124 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    input_examples,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BashTool20250124 with ToJson::{to_json}

///|
pub impl ToJson for BashTool20250124 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .opt("input_examples", self.input_examples)
  .field("name", "bash")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BashTool20250124 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BashTool20250124 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    input_examples: @sdkjson.opt_field(obj, "input_examples", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of BillingError.
#derive(Eq, @debug.Debug)
pub(all) struct BillingError {
  message : String
  type_ : String
}

///|
pub extend BillingError with Eq::{equal, not_equal}

///|
pub extend BillingError with @debug.Debug::{to_repr}

///|
///
/// Creates a BillingError with omitted optional fields absent.
pub fn BillingError::new(message~ : String, type_~ : String) -> BillingError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend BillingError with ToJson::{to_json}

///|
pub impl ToJson for BillingError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BillingError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BillingError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// ``close_tab``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserCloseTabConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserCloseTabConfig with Eq::{equal, not_equal}

///|
pub extend BrowserCloseTabConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserCloseTabConfig with omitted optional fields absent.
pub fn BrowserCloseTabConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserCloseTabConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserCloseTabConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserCloseTabConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserCloseTabConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserCloseTabConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``double_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserDoubleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserDoubleClickConfig with Eq::{equal, not_equal}

///|
pub extend BrowserDoubleClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserDoubleClickConfig with omitted optional fields absent.
pub fn BrowserDoubleClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserDoubleClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserDoubleClickConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserDoubleClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserDoubleClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserDoubleClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``file_upload``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserFileUploadConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserFileUploadConfig with Eq::{equal, not_equal}

///|
pub extend BrowserFileUploadConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserFileUploadConfig with omitted optional fields absent.
pub fn BrowserFileUploadConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserFileUploadConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserFileUploadConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserFileUploadConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserFileUploadConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserFileUploadConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``find``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserFindConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserFindConfig with Eq::{equal, not_equal}

///|
pub extend BrowserFindConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserFindConfig with omitted optional fields absent.
pub fn BrowserFindConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserFindConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserFindConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserFindConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserFindConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserFindConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``form_input``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserFormInputConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserFormInputConfig with Eq::{equal, not_equal}

///|
pub extend BrowserFormInputConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserFormInputConfig with omitted optional fields absent.
pub fn BrowserFormInputConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserFormInputConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserFormInputConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserFormInputConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserFormInputConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserFormInputConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``get_page_text``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserGetPageTextConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserGetPageTextConfig with Eq::{equal, not_equal}

///|
pub extend BrowserGetPageTextConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserGetPageTextConfig with omitted optional fields absent.
pub fn BrowserGetPageTextConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserGetPageTextConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserGetPageTextConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserGetPageTextConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserGetPageTextConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserGetPageTextConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``hold_key``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserHoldKeyConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserHoldKeyConfig with Eq::{equal, not_equal}

///|
pub extend BrowserHoldKeyConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserHoldKeyConfig with omitted optional fields absent.
pub fn BrowserHoldKeyConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserHoldKeyConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserHoldKeyConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserHoldKeyConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserHoldKeyConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserHoldKeyConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``hover``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserHoverConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserHoverConfig with Eq::{equal, not_equal}

///|
pub extend BrowserHoverConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserHoverConfig with omitted optional fields absent.
pub fn BrowserHoverConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserHoverConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserHoverConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserHoverConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserHoverConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserHoverConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``javascript_exec``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserJavascriptExecConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserJavascriptExecConfig with Eq::{equal, not_equal}

///|
pub extend BrowserJavascriptExecConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserJavascriptExecConfig with omitted optional fields absent.
pub fn BrowserJavascriptExecConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserJavascriptExecConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserJavascriptExecConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserJavascriptExecConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserJavascriptExecConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserJavascriptExecConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``key``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserKeyConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserKeyConfig with Eq::{equal, not_equal}

///|
pub extend BrowserKeyConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserKeyConfig with omitted optional fields absent.
pub fn BrowserKeyConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserKeyConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserKeyConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserKeyConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserKeyConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserKeyConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``left_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserLeftClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserLeftClickConfig with Eq::{equal, not_equal}

///|
pub extend BrowserLeftClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserLeftClickConfig with omitted optional fields absent.
pub fn BrowserLeftClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserLeftClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserLeftClickConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserLeftClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserLeftClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserLeftClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``left_click_drag``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserLeftClickDragConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserLeftClickDragConfig with Eq::{equal, not_equal}

///|
pub extend BrowserLeftClickDragConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserLeftClickDragConfig with omitted optional fields absent.
pub fn BrowserLeftClickDragConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserLeftClickDragConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserLeftClickDragConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserLeftClickDragConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserLeftClickDragConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserLeftClickDragConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``left_mouse_down``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserLeftMouseDownConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserLeftMouseDownConfig with Eq::{equal, not_equal}

///|
pub extend BrowserLeftMouseDownConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserLeftMouseDownConfig with omitted optional fields absent.
pub fn BrowserLeftMouseDownConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserLeftMouseDownConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserLeftMouseDownConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserLeftMouseDownConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserLeftMouseDownConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserLeftMouseDownConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``left_mouse_up``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserLeftMouseUpConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserLeftMouseUpConfig with Eq::{equal, not_equal}

///|
pub extend BrowserLeftMouseUpConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserLeftMouseUpConfig with omitted optional fields absent.
pub fn BrowserLeftMouseUpConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserLeftMouseUpConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserLeftMouseUpConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserLeftMouseUpConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserLeftMouseUpConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserLeftMouseUpConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``list_tabs``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserListTabsConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserListTabsConfig with Eq::{equal, not_equal}

///|
pub extend BrowserListTabsConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserListTabsConfig with omitted optional fields absent.
pub fn BrowserListTabsConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserListTabsConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserListTabsConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserListTabsConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserListTabsConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserListTabsConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``middle_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserMiddleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserMiddleClickConfig with Eq::{equal, not_equal}

///|
pub extend BrowserMiddleClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserMiddleClickConfig with omitted optional fields absent.
pub fn BrowserMiddleClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserMiddleClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserMiddleClickConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserMiddleClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserMiddleClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserMiddleClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``mouse_move``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserMouseMoveConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserMouseMoveConfig with Eq::{equal, not_equal}

///|
pub extend BrowserMouseMoveConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserMouseMoveConfig with omitted optional fields absent.
pub fn BrowserMouseMoveConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserMouseMoveConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserMouseMoveConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserMouseMoveConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserMouseMoveConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserMouseMoveConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``navigate``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserNavigateConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserNavigateConfig with Eq::{equal, not_equal}

///|
pub extend BrowserNavigateConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserNavigateConfig with omitted optional fields absent.
pub fn BrowserNavigateConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserNavigateConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserNavigateConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserNavigateConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserNavigateConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserNavigateConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``new_tab``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserNewTabConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserNewTabConfig with Eq::{equal, not_equal}

///|
pub extend BrowserNewTabConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserNewTabConfig with omitted optional fields absent.
pub fn BrowserNewTabConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserNewTabConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserNewTabConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserNewTabConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserNewTabConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserNewTabConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``read_console``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserReadConsoleConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserReadConsoleConfig with Eq::{equal, not_equal}

///|
pub extend BrowserReadConsoleConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserReadConsoleConfig with omitted optional fields absent.
pub fn BrowserReadConsoleConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserReadConsoleConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserReadConsoleConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserReadConsoleConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserReadConsoleConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserReadConsoleConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``read_network``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserReadNetworkConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserReadNetworkConfig with Eq::{equal, not_equal}

///|
pub extend BrowserReadNetworkConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserReadNetworkConfig with omitted optional fields absent.
pub fn BrowserReadNetworkConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserReadNetworkConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserReadNetworkConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserReadNetworkConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserReadNetworkConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserReadNetworkConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``read_page``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserReadPageConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserReadPageConfig with Eq::{equal, not_equal}

///|
pub extend BrowserReadPageConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserReadPageConfig with omitted optional fields absent.
pub fn BrowserReadPageConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserReadPageConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserReadPageConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserReadPageConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserReadPageConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserReadPageConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``right_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserRightClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserRightClickConfig with Eq::{equal, not_equal}

///|
pub extend BrowserRightClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserRightClickConfig with omitted optional fields absent.
pub fn BrowserRightClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserRightClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserRightClickConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserRightClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserRightClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserRightClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``screenshot``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserScreenshotConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserScreenshotConfig with Eq::{equal, not_equal}

///|
pub extend BrowserScreenshotConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserScreenshotConfig with omitted optional fields absent.
pub fn BrowserScreenshotConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserScreenshotConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserScreenshotConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserScreenshotConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserScreenshotConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserScreenshotConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``scroll``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserScrollConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserScrollConfig with Eq::{equal, not_equal}

///|
pub extend BrowserScrollConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserScrollConfig with omitted optional fields absent.
pub fn BrowserScrollConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserScrollConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserScrollConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserScrollConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserScrollConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserScrollConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``scroll_to``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserScrollToConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserScrollToConfig with Eq::{equal, not_equal}

///|
pub extend BrowserScrollToConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserScrollToConfig with omitted optional fields absent.
pub fn BrowserScrollToConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserScrollToConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserScrollToConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserScrollToConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserScrollToConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserScrollToConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``switch_tab``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserSwitchTabConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserSwitchTabConfig with Eq::{equal, not_equal}

///|
pub extend BrowserSwitchTabConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserSwitchTabConfig with omitted optional fields absent.
pub fn BrowserSwitchTabConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserSwitchTabConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserSwitchTabConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserSwitchTabConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserSwitchTabConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserSwitchTabConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``triple_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserTripleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserTripleClickConfig with Eq::{equal, not_equal}

///|
pub extend BrowserTripleClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserTripleClickConfig with omitted optional fields absent.
pub fn BrowserTripleClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserTripleClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserTripleClickConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserTripleClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserTripleClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserTripleClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``type``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserTypeConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserTypeConfig with Eq::{equal, not_equal}

///|
pub extend BrowserTypeConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserTypeConfig with omitted optional fields absent.
pub fn BrowserTypeConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserTypeConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserTypeConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserTypeConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserTypeConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserTypeConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``wait``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserWaitConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserWaitConfig with Eq::{equal, not_equal}

///|
pub extend BrowserWaitConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserWaitConfig with omitted optional fields absent.
pub fn BrowserWaitConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserWaitConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserWaitConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserWaitConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserWaitConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserWaitConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``zoom``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserZoomConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend BrowserZoomConfig with Eq::{equal, not_equal}

///|
pub extend BrowserZoomConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserZoomConfig with omitted optional fields absent.
pub fn BrowserZoomConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> BrowserZoomConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserZoomConfig with ToJson::{to_json}

///|
pub impl ToJson for BrowserZoomConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserZoomConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserZoomConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// Per-member configuration for ``browser_toolset_20260801``: one optional field per member tool, keyed by the member name — the same name the member's ``tool_use`` blocks carry. Every member is an accepted key, and a member's defaults apply wherever its key is absent. Unknown keys are rejected: the field set is this toolset version's complete member set.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserToolsetConfigs {
  close_tab : @sdkjson.Presence[BrowserCloseTabConfig]
  double_click : @sdkjson.Presence[BrowserDoubleClickConfig]
  file_upload : @sdkjson.Presence[BrowserFileUploadConfig]
  find : @sdkjson.Presence[BrowserFindConfig]
  form_input : @sdkjson.Presence[BrowserFormInputConfig]
  get_page_text : @sdkjson.Presence[BrowserGetPageTextConfig]
  hold_key : @sdkjson.Presence[BrowserHoldKeyConfig]
  hover : @sdkjson.Presence[BrowserHoverConfig]
  javascript_exec : @sdkjson.Presence[BrowserJavascriptExecConfig]
  key : @sdkjson.Presence[BrowserKeyConfig]
  left_click : @sdkjson.Presence[BrowserLeftClickConfig]
  left_click_drag : @sdkjson.Presence[BrowserLeftClickDragConfig]
  left_mouse_down : @sdkjson.Presence[BrowserLeftMouseDownConfig]
  left_mouse_up : @sdkjson.Presence[BrowserLeftMouseUpConfig]
  list_tabs : @sdkjson.Presence[BrowserListTabsConfig]
  middle_click : @sdkjson.Presence[BrowserMiddleClickConfig]
  mouse_move : @sdkjson.Presence[BrowserMouseMoveConfig]
  navigate : @sdkjson.Presence[BrowserNavigateConfig]
  new_tab : @sdkjson.Presence[BrowserNewTabConfig]
  read_console : @sdkjson.Presence[BrowserReadConsoleConfig]
  read_network : @sdkjson.Presence[BrowserReadNetworkConfig]
  read_page : @sdkjson.Presence[BrowserReadPageConfig]
  right_click : @sdkjson.Presence[BrowserRightClickConfig]
  screenshot : @sdkjson.Presence[BrowserScreenshotConfig]
  scroll : @sdkjson.Presence[BrowserScrollConfig]
  scroll_to : @sdkjson.Presence[BrowserScrollToConfig]
  switch_tab : @sdkjson.Presence[BrowserSwitchTabConfig]
  triple_click : @sdkjson.Presence[BrowserTripleClickConfig]
  type_ : @sdkjson.Presence[BrowserTypeConfig]
  wait : @sdkjson.Presence[BrowserWaitConfig]
  zoom : @sdkjson.Presence[BrowserZoomConfig]
}

///|
pub extend BrowserToolsetConfigs with Eq::{equal, not_equal}

///|
pub extend BrowserToolsetConfigs with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserToolsetConfigs with omitted optional fields absent.
pub fn BrowserToolsetConfigs::new(
  close_tab? : BrowserCloseTabConfig,
  double_click? : BrowserDoubleClickConfig,
  file_upload? : BrowserFileUploadConfig,
  find? : BrowserFindConfig,
  form_input? : BrowserFormInputConfig,
  get_page_text? : BrowserGetPageTextConfig,
  hold_key? : BrowserHoldKeyConfig,
  hover? : BrowserHoverConfig,
  javascript_exec? : BrowserJavascriptExecConfig,
  key? : BrowserKeyConfig,
  left_click? : BrowserLeftClickConfig,
  left_click_drag? : BrowserLeftClickDragConfig,
  left_mouse_down? : BrowserLeftMouseDownConfig,
  left_mouse_up? : BrowserLeftMouseUpConfig,
  list_tabs? : BrowserListTabsConfig,
  middle_click? : BrowserMiddleClickConfig,
  mouse_move? : BrowserMouseMoveConfig,
  navigate? : BrowserNavigateConfig,
  new_tab? : BrowserNewTabConfig,
  read_console? : BrowserReadConsoleConfig,
  read_network? : BrowserReadNetworkConfig,
  read_page? : BrowserReadPageConfig,
  right_click? : BrowserRightClickConfig,
  screenshot? : BrowserScreenshotConfig,
  scroll? : BrowserScrollConfig,
  scroll_to? : BrowserScrollToConfig,
  switch_tab? : BrowserSwitchTabConfig,
  triple_click? : BrowserTripleClickConfig,
  type_? : BrowserTypeConfig,
  wait? : BrowserWaitConfig,
  zoom? : BrowserZoomConfig,
) -> BrowserToolsetConfigs {
  {
    close_tab: @sdkjson.Presence::from_option(close_tab),
    double_click: @sdkjson.Presence::from_option(double_click),
    file_upload: @sdkjson.Presence::from_option(file_upload),
    find: @sdkjson.Presence::from_option(find),
    form_input: @sdkjson.Presence::from_option(form_input),
    get_page_text: @sdkjson.Presence::from_option(get_page_text),
    hold_key: @sdkjson.Presence::from_option(hold_key),
    hover: @sdkjson.Presence::from_option(hover),
    javascript_exec: @sdkjson.Presence::from_option(javascript_exec),
    key: @sdkjson.Presence::from_option(key),
    left_click: @sdkjson.Presence::from_option(left_click),
    left_click_drag: @sdkjson.Presence::from_option(left_click_drag),
    left_mouse_down: @sdkjson.Presence::from_option(left_mouse_down),
    left_mouse_up: @sdkjson.Presence::from_option(left_mouse_up),
    list_tabs: @sdkjson.Presence::from_option(list_tabs),
    middle_click: @sdkjson.Presence::from_option(middle_click),
    mouse_move: @sdkjson.Presence::from_option(mouse_move),
    navigate: @sdkjson.Presence::from_option(navigate),
    new_tab: @sdkjson.Presence::from_option(new_tab),
    read_console: @sdkjson.Presence::from_option(read_console),
    read_network: @sdkjson.Presence::from_option(read_network),
    read_page: @sdkjson.Presence::from_option(read_page),
    right_click: @sdkjson.Presence::from_option(right_click),
    screenshot: @sdkjson.Presence::from_option(screenshot),
    scroll: @sdkjson.Presence::from_option(scroll),
    scroll_to: @sdkjson.Presence::from_option(scroll_to),
    switch_tab: @sdkjson.Presence::from_option(switch_tab),
    triple_click: @sdkjson.Presence::from_option(triple_click),
    type_: @sdkjson.Presence::from_option(type_),
    wait: @sdkjson.Presence::from_option(wait),
    zoom: @sdkjson.Presence::from_option(zoom),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserToolsetConfigs with ToJson::{to_json}

///|
pub impl ToJson for BrowserToolsetConfigs with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("close_tab", self.close_tab)
  .presence("double_click", self.double_click)
  .presence("file_upload", self.file_upload)
  .presence("find", self.find)
  .presence("form_input", self.form_input)
  .presence("get_page_text", self.get_page_text)
  .presence("hold_key", self.hold_key)
  .presence("hover", self.hover)
  .presence("javascript_exec", self.javascript_exec)
  .presence("key", self.key)
  .presence("left_click", self.left_click)
  .presence("left_click_drag", self.left_click_drag)
  .presence("left_mouse_down", self.left_mouse_down)
  .presence("left_mouse_up", self.left_mouse_up)
  .presence("list_tabs", self.list_tabs)
  .presence("middle_click", self.middle_click)
  .presence("mouse_move", self.mouse_move)
  .presence("navigate", self.navigate)
  .presence("new_tab", self.new_tab)
  .presence("read_console", self.read_console)
  .presence("read_network", self.read_network)
  .presence("read_page", self.read_page)
  .presence("right_click", self.right_click)
  .presence("screenshot", self.screenshot)
  .presence("scroll", self.scroll)
  .presence("scroll_to", self.scroll_to)
  .presence("switch_tab", self.switch_tab)
  .presence("triple_click", self.triple_click)
  .presence("type", self.type_)
  .presence("wait", self.wait)
  .presence("zoom", self.zoom)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserToolsetConfigs with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserToolsetConfigs with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    close_tab: @sdkjson.presence_field(obj, "close_tab", path),
    double_click: @sdkjson.presence_field(obj, "double_click", path),
    file_upload: @sdkjson.presence_field(obj, "file_upload", path),
    find: @sdkjson.presence_field(obj, "find", path),
    form_input: @sdkjson.presence_field(obj, "form_input", path),
    get_page_text: @sdkjson.presence_field(obj, "get_page_text", path),
    hold_key: @sdkjson.presence_field(obj, "hold_key", path),
    hover: @sdkjson.presence_field(obj, "hover", path),
    javascript_exec: @sdkjson.presence_field(obj, "javascript_exec", path),
    key: @sdkjson.presence_field(obj, "key", path),
    left_click: @sdkjson.presence_field(obj, "left_click", path),
    left_click_drag: @sdkjson.presence_field(obj, "left_click_drag", path),
    left_mouse_down: @sdkjson.presence_field(obj, "left_mouse_down", path),
    left_mouse_up: @sdkjson.presence_field(obj, "left_mouse_up", path),
    list_tabs: @sdkjson.presence_field(obj, "list_tabs", path),
    middle_click: @sdkjson.presence_field(obj, "middle_click", path),
    mouse_move: @sdkjson.presence_field(obj, "mouse_move", path),
    navigate: @sdkjson.presence_field(obj, "navigate", path),
    new_tab: @sdkjson.presence_field(obj, "new_tab", path),
    read_console: @sdkjson.presence_field(obj, "read_console", path),
    read_network: @sdkjson.presence_field(obj, "read_network", path),
    read_page: @sdkjson.presence_field(obj, "read_page", path),
    right_click: @sdkjson.presence_field(obj, "right_click", path),
    screenshot: @sdkjson.presence_field(obj, "screenshot", path),
    scroll: @sdkjson.presence_field(obj, "scroll", path),
    scroll_to: @sdkjson.presence_field(obj, "scroll_to", path),
    switch_tab: @sdkjson.presence_field(obj, "switch_tab", path),
    triple_click: @sdkjson.presence_field(obj, "triple_click", path),
    type_: @sdkjson.presence_field(obj, "type", path),
    wait: @sdkjson.presence_field(obj, "wait", path),
    zoom: @sdkjson.presence_field(obj, "zoom", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum BrowserToolset20260801CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend BrowserToolset20260801CacheControl with Eq::{equal, not_equal}

///|
pub extend BrowserToolset20260801CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend BrowserToolset20260801CacheControl with ToJson::{to_json}

///|
pub impl ToJson for BrowserToolset20260801CacheControl with fn to_json(self) {
  match self {
    BrowserToolset20260801CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    BrowserToolset20260801CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend BrowserToolset20260801CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserToolset20260801CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      BrowserToolset20260801CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => BrowserToolset20260801CacheControl::Unknown(other, value)
  }
}

///|
///
/// The browser toolset: a single ``tools[]`` entry (carrying no ``name``) that declares the browser tool family. The model is served the family's tool with any members disabled via ``configs`` removed from its schema.
#derive(Eq, @debug.Debug)
pub(all) struct BrowserToolset20260801 {
  cache_control : @sdkjson.Presence[BrowserToolset20260801CacheControl]
  configs : @sdkjson.Presence[BrowserToolsetConfigs]
  type_ : String
}

///|
pub extend BrowserToolset20260801 with Eq::{equal, not_equal}

///|
pub extend BrowserToolset20260801 with @debug.Debug::{to_repr}

///|
///
/// Creates a BrowserToolset20260801 with omitted optional fields absent.
pub fn BrowserToolset20260801::new(
  type_~ : String,
  cache_control? : BrowserToolset20260801CacheControl,
  configs? : BrowserToolsetConfigs,
) -> BrowserToolset20260801 {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    configs: @sdkjson.Presence::from_option(configs),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend BrowserToolset20260801 with ToJson::{to_json}

///|
pub impl ToJson for BrowserToolset20260801 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .presence("configs", self.configs)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend BrowserToolset20260801 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for BrowserToolset20260801 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    configs: @sdkjson.presence_field(obj, "configs", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of CacheCreation.
#derive(Eq, @debug.Debug)
pub(all) struct CacheCreation {
  ephemeral_1h_input_tokens : Int32
  ephemeral_5m_input_tokens : Int32
}

///|
pub extend CacheCreation with Eq::{equal, not_equal}

///|
pub extend CacheCreation with @debug.Debug::{to_repr}

///|
///
/// Creates a CacheCreation with omitted optional fields absent.
pub fn CacheCreation::new(
  ephemeral_1h_input_tokens~ : Int32,
  ephemeral_5m_input_tokens~ : Int32,
) -> CacheCreation {
  { ephemeral_1h_input_tokens, ephemeral_5m_input_tokens, }
}

///|
///
/// Encodes this value as JSON.
pub extend CacheCreation with ToJson::{to_json}

///|
pub impl ToJson for CacheCreation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("ephemeral_1h_input_tokens", self.ephemeral_1h_input_tokens)
  .field("ephemeral_5m_input_tokens", self.ephemeral_5m_input_tokens)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CacheCreation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheCreation with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    ephemeral_1h_input_tokens: required_field(
      obj, "ephemeral_1h_input_tokens", path,
    ),
    ephemeral_5m_input_tokens: required_field(
      obj, "ephemeral_5m_input_tokens", path,
    ),
  }
}

///|
///
/// A `cache_miss_reason` for a request whose `messages` differ from the previous request's in an earlier entry, instead of only having entries appended. The `model`, `system`, and `tools` match. See the [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types) to learn what to change for each reason.
#derive(Eq, @debug.Debug)
pub(all) struct CacheMissMessagesChanged {
  cache_missed_input_tokens : Int32
  type_ : String
}

///|
pub extend CacheMissMessagesChanged with Eq::{equal, not_equal}

///|
pub extend CacheMissMessagesChanged with @debug.Debug::{to_repr}

///|
///
/// Creates a CacheMissMessagesChanged with omitted optional fields absent.
pub fn CacheMissMessagesChanged::new(
  cache_missed_input_tokens~ : Int32,
  type_~ : String,
) -> CacheMissMessagesChanged {
  { cache_missed_input_tokens, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend CacheMissMessagesChanged with ToJson::{to_json}

///|
pub impl ToJson for CacheMissMessagesChanged with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cache_missed_input_tokens", self.cache_missed_input_tokens)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CacheMissMessagesChanged with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheMissMessagesChanged with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_missed_input_tokens: required_field(
      obj, "cache_missed_input_tokens", path,
    ),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// A `cache_miss_reason` for a request whose `model` or `speed` differs from the previous request's. See the [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types) to learn what to change for each reason.
#derive(Eq, @debug.Debug)
pub(all) struct CacheMissModelChanged {
  cache_missed_input_tokens : Int32
  type_ : String
}

///|
pub extend CacheMissModelChanged with Eq::{equal, not_equal}

///|
pub extend CacheMissModelChanged with @debug.Debug::{to_repr}

///|
///
/// Creates a CacheMissModelChanged with omitted optional fields absent.
pub fn CacheMissModelChanged::new(
  cache_missed_input_tokens~ : Int32,
  type_~ : String,
) -> CacheMissModelChanged {
  { cache_missed_input_tokens, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend CacheMissModelChanged with ToJson::{to_json}

///|
pub impl ToJson for CacheMissModelChanged with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cache_missed_input_tokens", self.cache_missed_input_tokens)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CacheMissModelChanged with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheMissModelChanged with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_missed_input_tokens: required_field(
      obj, "cache_missed_input_tokens", path,
    ),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// A `cache_miss_reason` for when the API doesn't have a stored record of the request that `diagnostics.previous_message_id` references. This doesn't mean that this request changed. See the [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types) to learn what to change for each reason.
#derive(Eq, @debug.Debug)
pub(all) struct CacheMissPreviousMessageNotFound {
  type_ : String
}

///|
pub extend CacheMissPreviousMessageNotFound with Eq::{equal, not_equal}

///|
pub extend CacheMissPreviousMessageNotFound with @debug.Debug::{to_repr}

///|
///
/// Creates a CacheMissPreviousMessageNotFound with omitted optional fields absent.
pub fn CacheMissPreviousMessageNotFound::new(
  type_~ : String,
) -> CacheMissPreviousMessageNotFound {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend CacheMissPreviousMessageNotFound with ToJson::{to_json}

///|
pub impl ToJson for CacheMissPreviousMessageNotFound with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend CacheMissPreviousMessageNotFound with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheMissPreviousMessageNotFound with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// A `cache_miss_reason` for a request whose `system` differs from the previous request's. See the [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types) to learn what to change for each reason.
#derive(Eq, @debug.Debug)
pub(all) struct CacheMissSystemChanged {
  cache_missed_input_tokens : Int32
  type_ : String
}

///|
pub extend CacheMissSystemChanged with Eq::{equal, not_equal}

///|
pub extend CacheMissSystemChanged with @debug.Debug::{to_repr}

///|
///
/// Creates a CacheMissSystemChanged with omitted optional fields absent.
pub fn CacheMissSystemChanged::new(
  cache_missed_input_tokens~ : Int32,
  type_~ : String,
) -> CacheMissSystemChanged {
  { cache_missed_input_tokens, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend CacheMissSystemChanged with ToJson::{to_json}

///|
pub impl ToJson for CacheMissSystemChanged with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cache_missed_input_tokens", self.cache_missed_input_tokens)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CacheMissSystemChanged with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheMissSystemChanged with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_missed_input_tokens: required_field(
      obj, "cache_missed_input_tokens", path,
    ),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// A `cache_miss_reason` for a request whose `tools` differ from the previous request's, for example because tools were added, removed, or reordered. See the [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types) to learn what to change for each reason.
#derive(Eq, @debug.Debug)
pub(all) struct CacheMissToolsChanged {
  cache_missed_input_tokens : Int32
  type_ : String
}

///|
pub extend CacheMissToolsChanged with Eq::{equal, not_equal}

///|
pub extend CacheMissToolsChanged with @debug.Debug::{to_repr}

///|
///
/// Creates a CacheMissToolsChanged with omitted optional fields absent.
pub fn CacheMissToolsChanged::new(
  cache_missed_input_tokens~ : Int32,
  type_~ : String,
) -> CacheMissToolsChanged {
  { cache_missed_input_tokens, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend CacheMissToolsChanged with ToJson::{to_json}

///|
pub impl ToJson for CacheMissToolsChanged with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cache_missed_input_tokens", self.cache_missed_input_tokens)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CacheMissToolsChanged with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheMissToolsChanged with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_missed_input_tokens: required_field(
      obj, "cache_missed_input_tokens", path,
    ),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// A `cache_miss_reason` for when the API can't give a diagnosis. The request itself was processed normally. This includes a request whose `model`, `system`, and `tools` match the previous request's but whose other prompt-affecting parameters, such as `thinking` or `tool_choice`, differ. See the [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types) to learn what to change for each reason.
#derive(Eq, @debug.Debug)
pub(all) struct CacheMissUnavailable {
  type_ : String
}

///|
pub extend CacheMissUnavailable with Eq::{equal, not_equal}

///|
pub extend CacheMissUnavailable with @debug.Debug::{to_repr}

///|
///
/// Creates a CacheMissUnavailable with omitted optional fields absent.
pub fn CacheMissUnavailable::new(type_~ : String) -> CacheMissUnavailable {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend CacheMissUnavailable with ToJson::{to_json}

///|
pub impl ToJson for CacheMissUnavailable with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend CacheMissUnavailable with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheMissUnavailable with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// Generated tagged union CacheMissReason.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CacheMissReason {
  MessagesChanged(CacheMissMessagesChanged)
  ModelChanged(CacheMissModelChanged)
  PreviousMessageNotFound(CacheMissPreviousMessageNotFound)
  SystemChanged(CacheMissSystemChanged)
  ToolsChanged(CacheMissToolsChanged)
  Unavailable(CacheMissUnavailable)
  Unknown(String, Json)
}

///|
pub extend CacheMissReason with Eq::{equal, not_equal}

///|
pub extend CacheMissReason with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CacheMissReason with ToJson::{to_json}

///|
pub impl ToJson for CacheMissReason with fn to_json(self) {
  match self {
    CacheMissReason::MessagesChanged(value) => @json.Json::Json(value)
    CacheMissReason::ModelChanged(value) => @json.Json::Json(value)
    CacheMissReason::PreviousMessageNotFound(value) => @json.Json::Json(value)
    CacheMissReason::SystemChanged(value) => @json.Json::Json(value)
    CacheMissReason::ToolsChanged(value) => @json.Json::Json(value)
    CacheMissReason::Unavailable(value) => @json.Json::Json(value)
    CacheMissReason::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CacheMissReason with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CacheMissReason with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "messages_changed" =>
      CacheMissReason::MessagesChanged(@json.from_json(value, path~))
    "model_changed" =>
      CacheMissReason::ModelChanged(@json.from_json(value, path~))
    "previous_message_not_found" =>
      CacheMissReason::PreviousMessageNotFound(@json.from_json(value, path~))
    "system_changed" =>
      CacheMissReason::SystemChanged(@json.from_json(value, path~))
    "tools_changed" =>
      CacheMissReason::ToolsChanged(@json.from_json(value, path~))
    "unavailable" => CacheMissReason::Unavailable(@json.from_json(value, path~))
    other => CacheMissReason::Unknown(other, value)
  }
}

///|
///
/// Indicates whether a capability is supported.
#derive(Eq, @debug.Debug)
pub(all) struct CapabilitySupport {
  supported : Bool
}

///|
pub extend CapabilitySupport with Eq::{equal, not_equal}

///|
pub extend CapabilitySupport with @debug.Debug::{to_repr}

///|
///
/// Creates a CapabilitySupport with omitted optional fields absent.
pub fn CapabilitySupport::new(supported~ : Bool) -> CapabilitySupport {
  { supported, }
}

///|
///
/// Encodes this value as JSON.
pub extend CapabilitySupport with ToJson::{to_json}

///|
pub impl ToJson for CapabilitySupport with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("supported", self.supported).build()
}

///|
///
/// Decodes this value from JSON.
pub extend CapabilitySupport with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CapabilitySupport with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { supported: required_field(obj, "supported", path), }
}

///|
///
/// Generated representation of ResponseCharLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseCharLocationCitation {
  cited_text : String
  document_index : Int32
  document_title : String?
  end_char_index : Int32
  file_id : String?
  start_char_index : Int32
  type_ : String
}

///|
pub extend ResponseCharLocationCitation with Eq::{equal, not_equal}

///|
pub extend ResponseCharLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseCharLocationCitation with omitted optional fields absent.
pub fn ResponseCharLocationCitation::new(
  cited_text~ : String,
  document_index~ : Int32,
  end_char_index~ : Int32,
  start_char_index~ : Int32,
  type_~ : String,
  document_title? : String,
  file_id? : String,
) -> ResponseCharLocationCitation {
  {
    cited_text,
    document_index,
    document_title,
    end_char_index,
    file_id,
    start_char_index,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseCharLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for ResponseCharLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("document_index", self.document_index)
  .presence(
    "document_title",
    nullable_presence(self.document_title.map(value => value)),
  )
  .field("end_char_index", self.end_char_index)
  .presence("file_id", nullable_presence(self.file_id.map(value => value)))
  .field("start_char_index", self.start_char_index)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseCharLocationCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseCharLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    document_index: required_field(obj, "document_index", path),
    document_title: decode_nullable_field(obj, "document_title", path),
    end_char_index: required_field(obj, "end_char_index", path),
    file_id: decode_nullable_field(obj, "file_id", path),
    start_char_index: required_field(obj, "start_char_index", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseContentBlockLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseContentBlockLocationCitation {
  cited_text : String
  document_index : Int32
  document_title : String?
  end_block_index : Int32
  file_id : String?
  start_block_index : Int32
  type_ : String
}

///|
pub extend ResponseContentBlockLocationCitation with Eq::{equal, not_equal}

///|
pub extend ResponseContentBlockLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseContentBlockLocationCitation with omitted optional fields absent.
pub fn ResponseContentBlockLocationCitation::new(
  cited_text~ : String,
  document_index~ : Int32,
  end_block_index~ : Int32,
  start_block_index~ : Int32,
  type_~ : String,
  document_title? : String,
  file_id? : String,
) -> ResponseContentBlockLocationCitation {
  {
    cited_text,
    document_index,
    document_title,
    end_block_index,
    file_id,
    start_block_index,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseContentBlockLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for ResponseContentBlockLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("document_index", self.document_index)
  .presence(
    "document_title",
    nullable_presence(self.document_title.map(value => value)),
  )
  .field("end_block_index", self.end_block_index)
  .presence("file_id", nullable_presence(self.file_id.map(value => value)))
  .field("start_block_index", self.start_block_index)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseContentBlockLocationCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseContentBlockLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    document_index: required_field(obj, "document_index", path),
    document_title: decode_nullable_field(obj, "document_title", path),
    end_block_index: required_field(obj, "end_block_index", path),
    file_id: decode_nullable_field(obj, "file_id", path),
    start_block_index: required_field(obj, "start_block_index", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponsePageLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct ResponsePageLocationCitation {
  cited_text : String
  document_index : Int32
  document_title : String?
  end_page_number : Int32
  file_id : String?
  start_page_number : Int32
  type_ : String
}

///|
pub extend ResponsePageLocationCitation with Eq::{equal, not_equal}

///|
pub extend ResponsePageLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponsePageLocationCitation with omitted optional fields absent.
pub fn ResponsePageLocationCitation::new(
  cited_text~ : String,
  document_index~ : Int32,
  end_page_number~ : Int32,
  start_page_number~ : Int32,
  type_~ : String,
  document_title? : String,
  file_id? : String,
) -> ResponsePageLocationCitation {
  {
    cited_text,
    document_index,
    document_title,
    end_page_number,
    file_id,
    start_page_number,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponsePageLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for ResponsePageLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("document_index", self.document_index)
  .presence(
    "document_title",
    nullable_presence(self.document_title.map(value => value)),
  )
  .field("end_page_number", self.end_page_number)
  .presence("file_id", nullable_presence(self.file_id.map(value => value)))
  .field("start_page_number", self.start_page_number)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponsePageLocationCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponsePageLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    document_index: required_field(obj, "document_index", path),
    document_title: decode_nullable_field(obj, "document_title", path),
    end_page_number: required_field(obj, "end_page_number", path),
    file_id: decode_nullable_field(obj, "file_id", path),
    start_page_number: required_field(obj, "start_page_number", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseSearchResultLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseSearchResultLocationCitation {
  cited_text : String
  end_block_index : Int32
  search_result_index : Int32
  source : String
  start_block_index : Int32
  title : String?
  type_ : String
}

///|
pub extend ResponseSearchResultLocationCitation with Eq::{equal, not_equal}

///|
pub extend ResponseSearchResultLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseSearchResultLocationCitation with omitted optional fields absent.
pub fn ResponseSearchResultLocationCitation::new(
  cited_text~ : String,
  end_block_index~ : Int32,
  search_result_index~ : Int32,
  source~ : String,
  start_block_index~ : Int32,
  type_~ : String,
  title? : String,
) -> ResponseSearchResultLocationCitation {
  {
    cited_text,
    end_block_index,
    search_result_index,
    source,
    start_block_index,
    title,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseSearchResultLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for ResponseSearchResultLocationCitation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("end_block_index", self.end_block_index)
  .field("search_result_index", self.search_result_index)
  .field("source", self.source)
  .field("start_block_index", self.start_block_index)
  .presence("title", nullable_presence(self.title.map(value => value)))
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseSearchResultLocationCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseSearchResultLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    end_block_index: required_field(obj, "end_block_index", path),
    search_result_index: required_field(obj, "search_result_index", path),
    source: required_field(obj, "source", path),
    start_block_index: required_field(obj, "start_block_index", path),
    title: decode_nullable_field(obj, "title", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseWebSearchResultLocationCitation.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseWebSearchResultLocationCitation {
  cited_text : String
  encrypted_index : String
  title : String?
  type_ : String
  url : String
}

///|
pub extend ResponseWebSearchResultLocationCitation with Eq::{equal, not_equal}

///|
pub extend ResponseWebSearchResultLocationCitation with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseWebSearchResultLocationCitation with omitted optional fields absent.
pub fn ResponseWebSearchResultLocationCitation::new(
  cited_text~ : String,
  encrypted_index~ : String,
  type_~ : String,
  url~ : String,
  title? : String,
) -> ResponseWebSearchResultLocationCitation {
  { cited_text, encrypted_index, title, type_, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseWebSearchResultLocationCitation with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebSearchResultLocationCitation with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("cited_text", self.cited_text)
  .field("encrypted_index", self.encrypted_index)
  .presence("title", nullable_presence(self.title.map(value => value)))
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseWebSearchResultLocationCitation with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseWebSearchResultLocationCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cited_text: required_field(obj, "cited_text", path),
    encrypted_index: required_field(obj, "encrypted_index", path),
    title: decode_nullable_field(obj, "title", path),
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// Generated tagged union CitationsDeltaCitation.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CitationsDeltaCitation {
  CharLocation(ResponseCharLocationCitation)
  ContentBlockLocation(ResponseContentBlockLocationCitation)
  PageLocation(ResponsePageLocationCitation)
  SearchResultLocation(ResponseSearchResultLocationCitation)
  WebSearchResultLocation(ResponseWebSearchResultLocationCitation)
  Unknown(String, Json)
}

///|
pub extend CitationsDeltaCitation with Eq::{equal, not_equal}

///|
pub extend CitationsDeltaCitation with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CitationsDeltaCitation with ToJson::{to_json}

///|
pub impl ToJson for CitationsDeltaCitation with fn to_json(self) {
  match self {
    CitationsDeltaCitation::CharLocation(value) => @json.Json::Json(value)
    CitationsDeltaCitation::ContentBlockLocation(value) =>
      @json.Json::Json(value)
    CitationsDeltaCitation::PageLocation(value) => @json.Json::Json(value)
    CitationsDeltaCitation::SearchResultLocation(value) =>
      @json.Json::Json(value)
    CitationsDeltaCitation::WebSearchResultLocation(value) =>
      @json.Json::Json(value)
    CitationsDeltaCitation::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CitationsDeltaCitation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CitationsDeltaCitation with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "char_location" =>
      CitationsDeltaCitation::CharLocation(@json.from_json(value, path~))
    "content_block_location" =>
      CitationsDeltaCitation::ContentBlockLocation(
        @json.from_json(value, path~),
      )
    "page_location" =>
      CitationsDeltaCitation::PageLocation(@json.from_json(value, path~))
    "search_result_location" =>
      CitationsDeltaCitation::SearchResultLocation(
        @json.from_json(value, path~),
      )
    "web_search_result_location" =>
      CitationsDeltaCitation::WebSearchResultLocation(
        @json.from_json(value, path~),
      )
    other => CitationsDeltaCitation::Unknown(other, value)
  }
}

///|
///
/// Generated representation of CitationsDelta.
#derive(Eq, @debug.Debug)
pub(all) struct CitationsDelta {
  citation : CitationsDeltaCitation
  type_ : String
}

///|
pub extend CitationsDelta with Eq::{equal, not_equal}

///|
pub extend CitationsDelta with @debug.Debug::{to_repr}

///|
///
/// Creates a CitationsDelta with omitted optional fields absent.
pub fn CitationsDelta::new(
  citation~ : CitationsDeltaCitation,
  type_~ : String,
) -> CitationsDelta {
  { citation, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend CitationsDelta with ToJson::{to_json}

///|
pub impl ToJson for CitationsDelta with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("citation", self.citation)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CitationsDelta with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CitationsDelta with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    citation: required_field(obj, "citation", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// The API key belongs to the Claude Code workspace, and the user who created it is no longer a member of the organization or of that workspace.
#derive(Eq, @debug.Debug)
pub(all) struct ClaudeCodeKeyCreatorNotMemberErrorDetails {}

///|
pub extend ClaudeCodeKeyCreatorNotMemberErrorDetails with Eq::{equal, not_equal}

///|
pub extend ClaudeCodeKeyCreatorNotMemberErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend ClaudeCodeKeyCreatorNotMemberErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ClaudeCodeKeyCreatorNotMemberErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "claude_code_key_creator_not_member")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ClaudeCodeKeyCreatorNotMemberErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ClaudeCodeKeyCreatorNotMemberErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ClaudeCodeKeyCreatorNotMemberErrorDetails::{ }
}

///|
///
/// The request comes from a Claude Code version older than the minimum that the requested model or the organization requires. Update Claude Code, then retry.
#derive(Eq, @debug.Debug)
pub(all) struct ClaudeCodeVersionTooOldErrorDetails {}

///|
pub extend ClaudeCodeVersionTooOldErrorDetails with Eq::{equal, not_equal}

///|
pub extend ClaudeCodeVersionTooOldErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend ClaudeCodeVersionTooOldErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ClaudeCodeVersionTooOldErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "claude_code_version_too_old")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ClaudeCodeVersionTooOldErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ClaudeCodeVersionTooOldErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ClaudeCodeVersionTooOldErrorDetails::{ }
}

///|
///
/// The workspace's customer-managed encryption key is disabled or revoked. Re-enable the key, then retry.
#derive(Eq, @debug.Debug)
pub(all) struct CmekKeyDisabledErrorDetails {}

///|
pub extend CmekKeyDisabledErrorDetails with Eq::{equal, not_equal}

///|
pub extend CmekKeyDisabledErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CmekKeyDisabledErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CmekKeyDisabledErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new().field("error_code", "cmek_key_disabled").build()
}

///|
///
/// Decodes this value from JSON.
pub extend CmekKeyDisabledErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CmekKeyDisabledErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CmekKeyDisabledErrorDetails::{ }
}

///|
///
/// The key management service's network access controls blocked the request to the workspace's customer-managed encryption key. The key itself may be healthy.
#derive(Eq, @debug.Debug)
pub(all) struct CmekKeyNetworkBlockedErrorDetails {}

///|
pub extend CmekKeyNetworkBlockedErrorDetails with Eq::{equal, not_equal}

///|
pub extend CmekKeyNetworkBlockedErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CmekKeyNetworkBlockedErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CmekKeyNetworkBlockedErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "cmek_key_network_blocked")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CmekKeyNetworkBlockedErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CmekKeyNetworkBlockedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CmekKeyNetworkBlockedErrorDetails::{ }
}

///|
///
/// The workspace's customer-managed encryption key could not be reached. Retry the request; if this continues, check that the key is available in your key management service, or contact Anthropic support.
#derive(Eq, @debug.Debug)
pub(all) struct CmekKeyUnreachableErrorDetails {}

///|
pub extend CmekKeyUnreachableErrorDetails with Eq::{equal, not_equal}

///|
pub extend CmekKeyUnreachableErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CmekKeyUnreachableErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CmekKeyUnreachableErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new().field("error_code", "cmek_key_unreachable").build()
}

///|
///
/// Decodes this value from JSON.
pub extend CmekKeyUnreachableErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CmekKeyUnreachableErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CmekKeyUnreachableErrorDetails::{ }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CodeExecutionTool20250522CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend CodeExecutionTool20250522CacheControl with Eq::{equal, not_equal}

///|
pub extend CodeExecutionTool20250522CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CodeExecutionTool20250522CacheControl with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionTool20250522CacheControl with fn to_json(self) {
  match self {
    CodeExecutionTool20250522CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    CodeExecutionTool20250522CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CodeExecutionTool20250522CacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CodeExecutionTool20250522CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      CodeExecutionTool20250522CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => CodeExecutionTool20250522CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of CodeExecutionTool20250522.
#derive(Eq, @debug.Debug)
pub(all) struct CodeExecutionTool20250522 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[CodeExecutionTool20250522CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : String
}

///|
pub extend CodeExecutionTool20250522 with Eq::{equal, not_equal}

///|
pub extend CodeExecutionTool20250522 with @debug.Debug::{to_repr}

///|
///
/// Creates a CodeExecutionTool20250522 with omitted optional fields absent.
pub fn CodeExecutionTool20250522::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : CodeExecutionTool20250522CacheControl,
  defer_loading? : Bool,
  strict? : Bool,
) -> CodeExecutionTool20250522 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend CodeExecutionTool20250522 with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionTool20250522 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .field("name", "code_execution")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CodeExecutionTool20250522 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CodeExecutionTool20250522 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CodeExecutionTool20250825CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend CodeExecutionTool20250825CacheControl with Eq::{equal, not_equal}

///|
pub extend CodeExecutionTool20250825CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CodeExecutionTool20250825CacheControl with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionTool20250825CacheControl with fn to_json(self) {
  match self {
    CodeExecutionTool20250825CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    CodeExecutionTool20250825CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CodeExecutionTool20250825CacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CodeExecutionTool20250825CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      CodeExecutionTool20250825CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => CodeExecutionTool20250825CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of CodeExecutionTool20250825.
#derive(Eq, @debug.Debug)
pub(all) struct CodeExecutionTool20250825 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[CodeExecutionTool20250825CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : String
}

///|
pub extend CodeExecutionTool20250825 with Eq::{equal, not_equal}

///|
pub extend CodeExecutionTool20250825 with @debug.Debug::{to_repr}

///|
///
/// Creates a CodeExecutionTool20250825 with omitted optional fields absent.
pub fn CodeExecutionTool20250825::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : CodeExecutionTool20250825CacheControl,
  defer_loading? : Bool,
  strict? : Bool,
) -> CodeExecutionTool20250825 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend CodeExecutionTool20250825 with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionTool20250825 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .field("name", "code_execution")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CodeExecutionTool20250825 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CodeExecutionTool20250825 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CodeExecutionTool20260120CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend CodeExecutionTool20260120CacheControl with Eq::{equal, not_equal}

///|
pub extend CodeExecutionTool20260120CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CodeExecutionTool20260120CacheControl with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionTool20260120CacheControl with fn to_json(self) {
  match self {
    CodeExecutionTool20260120CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    CodeExecutionTool20260120CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CodeExecutionTool20260120CacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CodeExecutionTool20260120CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      CodeExecutionTool20260120CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => CodeExecutionTool20260120CacheControl::Unknown(other, value)
  }
}

///|
///
/// A `tools` entry for the code execution tool, version `code_execution_20260120`. It adds REPL state persistence to version `code_execution_20250825`. REPL state persistence applies with programmatic tool calling. With it, the Python interpreter state, such as variable bindings, persists across requests that reuse the container. See the [code execution tool guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool#tool-versions) to learn what each tool version adds.
#derive(Eq, @debug.Debug)
pub(all) struct CodeExecutionTool20260120 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[CodeExecutionTool20260120CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : String
}

///|
pub extend CodeExecutionTool20260120 with Eq::{equal, not_equal}

///|
pub extend CodeExecutionTool20260120 with @debug.Debug::{to_repr}

///|
///
/// Creates a CodeExecutionTool20260120 with omitted optional fields absent.
pub fn CodeExecutionTool20260120::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : CodeExecutionTool20260120CacheControl,
  defer_loading? : Bool,
  strict? : Bool,
) -> CodeExecutionTool20260120 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend CodeExecutionTool20260120 with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionTool20260120 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .field("name", "code_execution")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CodeExecutionTool20260120 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CodeExecutionTool20260120 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CodeExecutionTool20260521CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend CodeExecutionTool20260521CacheControl with Eq::{equal, not_equal}

///|
pub extend CodeExecutionTool20260521CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CodeExecutionTool20260521CacheControl with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionTool20260521CacheControl with fn to_json(self) {
  match self {
    CodeExecutionTool20260521CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    CodeExecutionTool20260521CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CodeExecutionTool20260521CacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CodeExecutionTool20260521CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      CodeExecutionTool20260521CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => CodeExecutionTool20260521CacheControl::Unknown(other, value)
  }
}

///|
///
/// Code execution tool with REPL state persistence.
#derive(Eq, @debug.Debug)
pub(all) struct CodeExecutionTool20260521 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[CodeExecutionTool20260521CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : String
}

///|
pub extend CodeExecutionTool20260521 with Eq::{equal, not_equal}

///|
pub extend CodeExecutionTool20260521 with @debug.Debug::{to_repr}

///|
///
/// Creates a CodeExecutionTool20260521 with omitted optional fields absent.
pub fn CodeExecutionTool20260521::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : CodeExecutionTool20260521CacheControl,
  defer_loading? : Bool,
  strict? : Bool,
) -> CodeExecutionTool20260521 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend CodeExecutionTool20260521 with ToJson::{to_json}

///|
pub impl ToJson for CodeExecutionTool20260521 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .field("name", "code_execution")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CodeExecutionTool20260521 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CodeExecutionTool20260521 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// `messages` holds more than one `compaction` block with content. Send only the block the conversation returned last.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionBlockAmbiguousErrorDetails {}

///|
pub extend CompactionBlockAmbiguousErrorDetails with Eq::{equal, not_equal}

///|
pub extend CompactionBlockAmbiguousErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CompactionBlockAmbiguousErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionBlockAmbiguousErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_block_ambiguous")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionBlockAmbiguousErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CompactionBlockAmbiguousErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionBlockAmbiguousErrorDetails::{ }
}

///|
///
/// The `compaction` block is not the first block of the conversation, or is in a `system` message.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionBlockMisplacedErrorDetails {}

///|
pub extend CompactionBlockMisplacedErrorDetails with Eq::{equal, not_equal}

///|
pub extend CompactionBlockMisplacedErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CompactionBlockMisplacedErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionBlockMisplacedErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_block_misplaced")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionBlockMisplacedErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CompactionBlockMisplacedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionBlockMisplacedErrorDetails::{ }
}

///|
///
/// The `compaction` block's `content` differs from the text its `signature` recorded.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionContentMismatchErrorDetails {}

///|
pub extend CompactionContentMismatchErrorDetails with Eq::{equal, not_equal}

///|
pub extend CompactionContentMismatchErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CompactionContentMismatchErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionContentMismatchErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_content_mismatch")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionContentMismatchErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CompactionContentMismatchErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionContentMismatchErrorDetails::{ }
}

///|
///
/// The compaction request ends on an `assistant` turn that is not finished.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionIncompleteTurnErrorDetails {}

///|
pub extend CompactionIncompleteTurnErrorDetails with Eq::{equal, not_equal}

///|
pub extend CompactionIncompleteTurnErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CompactionIncompleteTurnErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionIncompleteTurnErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_incomplete_turn")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionIncompleteTurnErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CompactionIncompleteTurnErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionIncompleteTurnErrorDetails::{ }
}

///|
///
/// `messages` holds no `user` or `assistant` content to summarize or adopt.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionNothingToSummarizeErrorDetails {}

///|
pub extend CompactionNothingToSummarizeErrorDetails with Eq::{equal, not_equal}

///|
pub extend CompactionNothingToSummarizeErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CompactionNothingToSummarizeErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionNothingToSummarizeErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_nothing_to_summarize")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionNothingToSummarizeErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CompactionNothingToSummarizeErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionNothingToSummarizeErrorDetails::{ }
}

///|
///
/// The `compaction` block's `signature` does not verify.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionSignatureInvalidErrorDetails {}

///|
pub extend CompactionSignatureInvalidErrorDetails with Eq::{equal, not_equal}

///|
pub extend CompactionSignatureInvalidErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CompactionSignatureInvalidErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionSignatureInvalidErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_signature_invalid")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionSignatureInvalidErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CompactionSignatureInvalidErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionSignatureInvalidErrorDetails::{ }
}

///|
///
/// The conversation references more distinct tools than a `compaction` block can record.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionTooManyToolReferencesErrorDetails {}

///|
pub extend CompactionTooManyToolReferencesErrorDetails with Eq::{
  equal,
  not_equal,
}

///|
pub extend CompactionTooManyToolReferencesErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend CompactionTooManyToolReferencesErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionTooManyToolReferencesErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_too_many_tool_references")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionTooManyToolReferencesErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CompactionTooManyToolReferencesErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionTooManyToolReferencesErrorDetails::{ }
}

///|
///
/// The `compaction` block's `tool_changes` differs from what was returned with the block.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionToolChangesMismatchErrorDetails {}

///|
pub extend CompactionToolChangesMismatchErrorDetails with Eq::{equal, not_equal}

///|
pub extend CompactionToolChangesMismatchErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend CompactionToolChangesMismatchErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionToolChangesMismatchErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_tool_changes_mismatch")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionToolChangesMismatchErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for CompactionToolChangesMismatchErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionToolChangesMismatchErrorDetails::{ }
}

///|
///
/// The compaction could not be completed for a transient server reason. Retry the request.
#derive(Eq, @debug.Debug)
pub(all) struct CompactionUnavailableErrorDetails {}

///|
pub extend CompactionUnavailableErrorDetails with Eq::{equal, not_equal}

///|
pub extend CompactionUnavailableErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend CompactionUnavailableErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for CompactionUnavailableErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "compaction_unavailable")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CompactionUnavailableErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CompactionUnavailableErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  CompactionUnavailableErrorDetails::{ }
}

///|
///
/// ``cursor_position``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerCursorPositionConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerCursorPositionConfig with Eq::{equal, not_equal}

///|
pub extend ComputerCursorPositionConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerCursorPositionConfig with omitted optional fields absent.
pub fn ComputerCursorPositionConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerCursorPositionConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerCursorPositionConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerCursorPositionConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerCursorPositionConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerCursorPositionConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``double_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerDoubleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerDoubleClickConfig with Eq::{equal, not_equal}

///|
pub extend ComputerDoubleClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerDoubleClickConfig with omitted optional fields absent.
pub fn ComputerDoubleClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerDoubleClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerDoubleClickConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerDoubleClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerDoubleClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerDoubleClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``hold_key``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerHoldKeyConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerHoldKeyConfig with Eq::{equal, not_equal}

///|
pub extend ComputerHoldKeyConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerHoldKeyConfig with omitted optional fields absent.
pub fn ComputerHoldKeyConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerHoldKeyConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerHoldKeyConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerHoldKeyConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerHoldKeyConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerHoldKeyConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``key``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerKeyConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerKeyConfig with Eq::{equal, not_equal}

///|
pub extend ComputerKeyConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerKeyConfig with omitted optional fields absent.
pub fn ComputerKeyConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerKeyConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerKeyConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerKeyConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerKeyConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerKeyConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``left_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerLeftClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerLeftClickConfig with Eq::{equal, not_equal}

///|
pub extend ComputerLeftClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerLeftClickConfig with omitted optional fields absent.
pub fn ComputerLeftClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerLeftClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerLeftClickConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerLeftClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerLeftClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerLeftClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``left_click_drag``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerLeftClickDragConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerLeftClickDragConfig with Eq::{equal, not_equal}

///|
pub extend ComputerLeftClickDragConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerLeftClickDragConfig with omitted optional fields absent.
pub fn ComputerLeftClickDragConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerLeftClickDragConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerLeftClickDragConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerLeftClickDragConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerLeftClickDragConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerLeftClickDragConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``left_mouse_down``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerLeftMouseDownConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerLeftMouseDownConfig with Eq::{equal, not_equal}

///|
pub extend ComputerLeftMouseDownConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerLeftMouseDownConfig with omitted optional fields absent.
pub fn ComputerLeftMouseDownConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerLeftMouseDownConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerLeftMouseDownConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerLeftMouseDownConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerLeftMouseDownConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerLeftMouseDownConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``left_mouse_up``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerLeftMouseUpConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerLeftMouseUpConfig with Eq::{equal, not_equal}

///|
pub extend ComputerLeftMouseUpConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerLeftMouseUpConfig with omitted optional fields absent.
pub fn ComputerLeftMouseUpConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerLeftMouseUpConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerLeftMouseUpConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerLeftMouseUpConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerLeftMouseUpConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerLeftMouseUpConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``middle_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerMiddleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerMiddleClickConfig with Eq::{equal, not_equal}

///|
pub extend ComputerMiddleClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerMiddleClickConfig with omitted optional fields absent.
pub fn ComputerMiddleClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerMiddleClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerMiddleClickConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerMiddleClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerMiddleClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerMiddleClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``mouse_move``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerMouseMoveConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerMouseMoveConfig with Eq::{equal, not_equal}

///|
pub extend ComputerMouseMoveConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerMouseMoveConfig with omitted optional fields absent.
pub fn ComputerMouseMoveConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerMouseMoveConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerMouseMoveConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerMouseMoveConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerMouseMoveConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerMouseMoveConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``right_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerRightClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerRightClickConfig with Eq::{equal, not_equal}

///|
pub extend ComputerRightClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerRightClickConfig with omitted optional fields absent.
pub fn ComputerRightClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerRightClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerRightClickConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerRightClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerRightClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerRightClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``screenshot``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerScreenshotConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerScreenshotConfig with Eq::{equal, not_equal}

///|
pub extend ComputerScreenshotConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerScreenshotConfig with omitted optional fields absent.
pub fn ComputerScreenshotConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerScreenshotConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerScreenshotConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerScreenshotConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerScreenshotConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerScreenshotConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``scroll``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerScrollConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerScrollConfig with Eq::{equal, not_equal}

///|
pub extend ComputerScrollConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerScrollConfig with omitted optional fields absent.
pub fn ComputerScrollConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerScrollConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerScrollConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerScrollConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerScrollConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerScrollConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``triple_click``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerTripleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerTripleClickConfig with Eq::{equal, not_equal}

///|
pub extend ComputerTripleClickConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerTripleClickConfig with omitted optional fields absent.
pub fn ComputerTripleClickConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerTripleClickConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerTripleClickConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerTripleClickConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerTripleClickConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerTripleClickConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``type``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerTypeConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerTypeConfig with Eq::{equal, not_equal}

///|
pub extend ComputerTypeConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerTypeConfig with omitted optional fields absent.
pub fn ComputerTypeConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerTypeConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerTypeConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerTypeConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerTypeConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerTypeConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``wait``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerWaitConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerWaitConfig with Eq::{equal, not_equal}

///|
pub extend ComputerWaitConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerWaitConfig with omitted optional fields absent.
pub fn ComputerWaitConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerWaitConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerWaitConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerWaitConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerWaitConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerWaitConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// ``zoom``'s config overrides.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerZoomConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
}

///|
pub extend ComputerZoomConfig with Eq::{equal, not_equal}

///|
pub extend ComputerZoomConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerZoomConfig with omitted optional fields absent.
pub fn ComputerZoomConfig::new(
  defer_loading? : Bool,
  enabled? : Bool,
) -> ComputerZoomConfig {
  {
    defer_loading: @sdkjson.Presence::from_option(defer_loading),
    enabled: @sdkjson.Presence::from_option(enabled),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerZoomConfig with ToJson::{to_json}

///|
pub impl ToJson for ComputerZoomConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("defer_loading", self.defer_loading)
  .presence("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerZoomConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerZoomConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    defer_loading: @sdkjson.presence_field(obj, "defer_loading", path),
    enabled: @sdkjson.presence_field(obj, "enabled", path),
  }
}

///|
///
/// Per-member configuration for ``computer_toolset_20260801``: one optional field per member tool, keyed by the member name — the same name the member's ``tool_use`` blocks carry. Every member is an accepted key, and a member's defaults apply wherever its key is absent. Unknown keys are rejected: the field set is this toolset version's complete member set.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerToolsetConfigs {
  cursor_position : @sdkjson.Presence[ComputerCursorPositionConfig]
  double_click : @sdkjson.Presence[ComputerDoubleClickConfig]
  hold_key : @sdkjson.Presence[ComputerHoldKeyConfig]
  key : @sdkjson.Presence[ComputerKeyConfig]
  left_click : @sdkjson.Presence[ComputerLeftClickConfig]
  left_click_drag : @sdkjson.Presence[ComputerLeftClickDragConfig]
  left_mouse_down : @sdkjson.Presence[ComputerLeftMouseDownConfig]
  left_mouse_up : @sdkjson.Presence[ComputerLeftMouseUpConfig]
  middle_click : @sdkjson.Presence[ComputerMiddleClickConfig]
  mouse_move : @sdkjson.Presence[ComputerMouseMoveConfig]
  right_click : @sdkjson.Presence[ComputerRightClickConfig]
  screenshot : @sdkjson.Presence[ComputerScreenshotConfig]
  scroll : @sdkjson.Presence[ComputerScrollConfig]
  triple_click : @sdkjson.Presence[ComputerTripleClickConfig]
  type_ : @sdkjson.Presence[ComputerTypeConfig]
  wait : @sdkjson.Presence[ComputerWaitConfig]
  zoom : @sdkjson.Presence[ComputerZoomConfig]
}

///|
pub extend ComputerToolsetConfigs with Eq::{equal, not_equal}

///|
pub extend ComputerToolsetConfigs with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerToolsetConfigs with omitted optional fields absent.
pub fn ComputerToolsetConfigs::new(
  cursor_position? : ComputerCursorPositionConfig,
  double_click? : ComputerDoubleClickConfig,
  hold_key? : ComputerHoldKeyConfig,
  key? : ComputerKeyConfig,
  left_click? : ComputerLeftClickConfig,
  left_click_drag? : ComputerLeftClickDragConfig,
  left_mouse_down? : ComputerLeftMouseDownConfig,
  left_mouse_up? : ComputerLeftMouseUpConfig,
  middle_click? : ComputerMiddleClickConfig,
  mouse_move? : ComputerMouseMoveConfig,
  right_click? : ComputerRightClickConfig,
  screenshot? : ComputerScreenshotConfig,
  scroll? : ComputerScrollConfig,
  triple_click? : ComputerTripleClickConfig,
  type_? : ComputerTypeConfig,
  wait? : ComputerWaitConfig,
  zoom? : ComputerZoomConfig,
) -> ComputerToolsetConfigs {
  {
    cursor_position: @sdkjson.Presence::from_option(cursor_position),
    double_click: @sdkjson.Presence::from_option(double_click),
    hold_key: @sdkjson.Presence::from_option(hold_key),
    key: @sdkjson.Presence::from_option(key),
    left_click: @sdkjson.Presence::from_option(left_click),
    left_click_drag: @sdkjson.Presence::from_option(left_click_drag),
    left_mouse_down: @sdkjson.Presence::from_option(left_mouse_down),
    left_mouse_up: @sdkjson.Presence::from_option(left_mouse_up),
    middle_click: @sdkjson.Presence::from_option(middle_click),
    mouse_move: @sdkjson.Presence::from_option(mouse_move),
    right_click: @sdkjson.Presence::from_option(right_click),
    screenshot: @sdkjson.Presence::from_option(screenshot),
    scroll: @sdkjson.Presence::from_option(scroll),
    triple_click: @sdkjson.Presence::from_option(triple_click),
    type_: @sdkjson.Presence::from_option(type_),
    wait: @sdkjson.Presence::from_option(wait),
    zoom: @sdkjson.Presence::from_option(zoom),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerToolsetConfigs with ToJson::{to_json}

///|
pub impl ToJson for ComputerToolsetConfigs with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cursor_position", self.cursor_position)
  .presence("double_click", self.double_click)
  .presence("hold_key", self.hold_key)
  .presence("key", self.key)
  .presence("left_click", self.left_click)
  .presence("left_click_drag", self.left_click_drag)
  .presence("left_mouse_down", self.left_mouse_down)
  .presence("left_mouse_up", self.left_mouse_up)
  .presence("middle_click", self.middle_click)
  .presence("mouse_move", self.mouse_move)
  .presence("right_click", self.right_click)
  .presence("screenshot", self.screenshot)
  .presence("scroll", self.scroll)
  .presence("triple_click", self.triple_click)
  .presence("type", self.type_)
  .presence("wait", self.wait)
  .presence("zoom", self.zoom)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerToolsetConfigs with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerToolsetConfigs with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cursor_position: @sdkjson.presence_field(obj, "cursor_position", path),
    double_click: @sdkjson.presence_field(obj, "double_click", path),
    hold_key: @sdkjson.presence_field(obj, "hold_key", path),
    key: @sdkjson.presence_field(obj, "key", path),
    left_click: @sdkjson.presence_field(obj, "left_click", path),
    left_click_drag: @sdkjson.presence_field(obj, "left_click_drag", path),
    left_mouse_down: @sdkjson.presence_field(obj, "left_mouse_down", path),
    left_mouse_up: @sdkjson.presence_field(obj, "left_mouse_up", path),
    middle_click: @sdkjson.presence_field(obj, "middle_click", path),
    mouse_move: @sdkjson.presence_field(obj, "mouse_move", path),
    right_click: @sdkjson.presence_field(obj, "right_click", path),
    screenshot: @sdkjson.presence_field(obj, "screenshot", path),
    scroll: @sdkjson.presence_field(obj, "scroll", path),
    triple_click: @sdkjson.presence_field(obj, "triple_click", path),
    type_: @sdkjson.presence_field(obj, "type", path),
    wait: @sdkjson.presence_field(obj, "wait", path),
    zoom: @sdkjson.presence_field(obj, "zoom", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ComputerToolset20260801CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend ComputerToolset20260801CacheControl with Eq::{equal, not_equal}

///|
pub extend ComputerToolset20260801CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ComputerToolset20260801CacheControl with ToJson::{to_json}

///|
pub impl ToJson for ComputerToolset20260801CacheControl with fn to_json(self) {
  match self {
    ComputerToolset20260801CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    ComputerToolset20260801CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ComputerToolset20260801CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerToolset20260801CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      ComputerToolset20260801CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => ComputerToolset20260801CacheControl::Unknown(other, value)
  }
}

///|
///
/// The computer toolset: a single ``tools[]`` entry (carrying no ``name``) that declares the computer tool family. The model is served the family's tool with any members disabled via ``configs`` removed from its schema. Every member is enabled by default, zoom included. The single-tool options ``display_number`` and ``enable_zoom`` are not fields of a toolset entry — it carries only ``type``, ``configs``, and ``cache_control``; zoom is controlled via ``configs.zoom.enabled``.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerToolset20260801 {
  cache_control : @sdkjson.Presence[ComputerToolset20260801CacheControl]
  configs : @sdkjson.Presence[ComputerToolsetConfigs]
  type_ : String
}

///|
pub extend ComputerToolset20260801 with Eq::{equal, not_equal}

///|
pub extend ComputerToolset20260801 with @debug.Debug::{to_repr}

///|
///
/// Creates a ComputerToolset20260801 with omitted optional fields absent.
pub fn ComputerToolset20260801::new(
  type_~ : String,
  cache_control? : ComputerToolset20260801CacheControl,
  configs? : ComputerToolsetConfigs,
) -> ComputerToolset20260801 {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    configs: @sdkjson.Presence::from_option(configs),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ComputerToolset20260801 with ToJson::{to_json}

///|
pub impl ToJson for ComputerToolset20260801 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .presence("configs", self.configs)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ComputerToolset20260801 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ComputerToolset20260801 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    configs: @sdkjson.presence_field(obj, "configs", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ContainerSkillType {
  Anthropic
  Custom
  Unknown(String)
}

///|
pub extend ContainerSkillType with Eq::{equal, not_equal}

///|
pub extend ContainerSkillType with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ContainerSkillType with ToJson::{to_json}

///|
pub impl ToJson for ContainerSkillType with fn to_json(self) {
  let raw = match self {
    ContainerSkillType::Anthropic => "anthropic"
    ContainerSkillType::Custom => "custom"
    ContainerSkillType::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ContainerSkillType with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContainerSkillType with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "anthropic" => Option::Some(ContainerSkillType::Anthropic)
        "custom" => Option::Some(ContainerSkillType::Custom)
        _ => Option::None
      }
    },
    raw => ContainerSkillType::Unknown(raw),
  )
}

///|
///
/// A skill that was loaded in a container (response model).
#derive(Eq, @debug.Debug)
pub(all) struct ContainerSkill {
  skill_id : String
  type_ : ContainerSkillType
  version : String
}

///|
pub extend ContainerSkill with Eq::{equal, not_equal}

///|
pub extend ContainerSkill with @debug.Debug::{to_repr}

///|
///
/// Creates a ContainerSkill with omitted optional fields absent.
pub fn ContainerSkill::new(
  skill_id~ : String,
  type_~ : ContainerSkillType,
  version~ : String,
) -> ContainerSkill {
  { skill_id, type_, version, }
}

///|
///
/// Encodes this value as JSON.
pub extend ContainerSkill with ToJson::{to_json}

///|
pub impl ToJson for ContainerSkill with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("skill_id", self.skill_id)
  .field("type", self.type_)
  .field("version", self.version)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ContainerSkill with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContainerSkill with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    skill_id: required_field(obj, "skill_id", path),
    type_: required_field(obj, "type", path),
    version: required_field(obj, "version", path),
  }
}

///|
///
/// Information about the container used in the request (for the code execution tool)
#derive(Eq, @debug.Debug)
pub(all) struct Container {
  expires_at : String
  id : String
  skills : Array[ContainerSkill]?
}

///|
pub extend Container with Eq::{equal, not_equal}

///|
pub extend Container with @debug.Debug::{to_repr}

///|
///
/// Creates a Container with omitted optional fields absent.
pub fn Container::new(
  expires_at~ : String,
  id~ : String,
  skills? : Array[ContainerSkill],
) -> Container {
  { expires_at, id, skills, }
}

///|
///
/// Encodes this value as JSON.
pub extend Container with ToJson::{to_json}

///|
pub impl ToJson for Container with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("expires_at", self.expires_at)
  .field("id", self.id)
  .presence("skills", nullable_presence(self.skills.map(value => value)))
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend Container with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Container with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    expires_at: required_field(obj, "expires_at", path),
    id: required_field(obj, "id", path),
    skills: decode_nullable_field(obj, "skills", path),
  }
}

///|
///
/// Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SkillParamsType {
  Anthropic
  CustomSkill
  Custom(String)
}

///|
pub extend SkillParamsType with Eq::{equal, not_equal}

///|
pub extend SkillParamsType with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend SkillParamsType with ToJson::{to_json}

///|
pub impl ToJson for SkillParamsType with fn to_json(self) {
  let raw = match self {
    SkillParamsType::Anthropic => "anthropic"
    SkillParamsType::CustomSkill => "custom"
    SkillParamsType::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend SkillParamsType with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for SkillParamsType with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "anthropic" => Option::Some(SkillParamsType::Anthropic)
        "custom" => Option::Some(SkillParamsType::CustomSkill)
        _ => Option::None
      }
    },
    raw => SkillParamsType::Custom(raw),
  )
}

///|
///
/// Specification for a skill to be loaded in a container.
#derive(Eq, @debug.Debug)
pub(all) struct SkillParams {
  skill_id : String
  type_ : SkillParamsType
  version : String?
}

///|
pub extend SkillParams with Eq::{equal, not_equal}

///|
pub extend SkillParams with @debug.Debug::{to_repr}

///|
///
/// Creates a SkillParams with omitted optional fields absent.
pub fn SkillParams::new(
  skill_id~ : String,
  type_~ : SkillParamsType,
  version? : String,
) -> SkillParams {
  { skill_id, type_, version, }
}

///|
///
/// Encodes this value as JSON.
pub extend SkillParams with ToJson::{to_json}

///|
pub impl ToJson for SkillParams with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("skill_id", self.skill_id)
  .field("type", self.type_)
  .opt("version", self.version)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend SkillParams with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for SkillParams with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    skill_id: required_field(obj, "skill_id", path),
    type_: required_field(obj, "type", path),
    version: @sdkjson.opt_field(obj, "version", path),
  }
}

///|
///
/// Container parameters with skills to be loaded.
#derive(Eq, @debug.Debug)
pub(all) struct ContainerParams {
  id : @sdkjson.Presence[String]
  skills : @sdkjson.Presence[Array[SkillParams]]
}

///|
pub extend ContainerParams with Eq::{equal, not_equal}

///|
pub extend ContainerParams with @debug.Debug::{to_repr}

///|
///
/// Creates a ContainerParams with omitted optional fields absent.
pub fn ContainerParams::new(
  id? : String,
  skills? : Array[SkillParams],
) -> ContainerParams {
  {
    id: @sdkjson.Presence::from_option(id),
    skills: @sdkjson.Presence::from_option(skills),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ContainerParams with ToJson::{to_json}

///|
pub impl ToJson for ContainerParams with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("id", self.id)
  .presence("skills", self.skills)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ContainerParams with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContainerParams with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    id: @sdkjson.presence_field(obj, "id", path),
    skills: @sdkjson.presence_field(obj, "skills", path),
  }
}

///|
///
/// Generated representation of ResponseBashCodeExecutionToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseBashCodeExecutionToolResultError {
  error_code : BashCodeExecutionToolResultErrorCode
  type_ : String
}

///|
pub extend ResponseBashCodeExecutionToolResultError with Eq::{equal, not_equal}

///|
pub extend ResponseBashCodeExecutionToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseBashCodeExecutionToolResultError with omitted optional fields absent.
pub fn ResponseBashCodeExecutionToolResultError::new(
  error_code~ : BashCodeExecutionToolResultErrorCode,
  type_~ : String,
) -> ResponseBashCodeExecutionToolResultError {
  { error_code, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseBashCodeExecutionToolResultError with ToJson::{to_json}

///|
pub impl ToJson for ResponseBashCodeExecutionToolResultError with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseBashCodeExecutionToolResultError with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseBashCodeExecutionToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseBashCodeExecutionOutputBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseBashCodeExecutionOutputBlock {
  file_id : String
}

///|
pub extend ResponseBashCodeExecutionOutputBlock with Eq::{equal, not_equal}

///|
pub extend ResponseBashCodeExecutionOutputBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseBashCodeExecutionOutputBlock with omitted optional fields absent.
pub fn ResponseBashCodeExecutionOutputBlock::new(
  file_id~ : String,
) -> ResponseBashCodeExecutionOutputBlock {
  { file_id, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseBashCodeExecutionOutputBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseBashCodeExecutionOutputBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("file_id", self.file_id)
  .field("type", "bash_code_execution_output")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseBashCodeExecutionOutputBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseBashCodeExecutionOutputBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { file_id: required_field(obj, "file_id", path), }
}

///|
///
/// Generated representation of ResponseBashCodeExecutionResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseBashCodeExecutionResultBlock {
  content : Array[ResponseBashCodeExecutionOutputBlock]
  return_code : Int32
  stderr : String
  stdout : String
  type_ : String
}

///|
pub extend ResponseBashCodeExecutionResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseBashCodeExecutionResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseBashCodeExecutionResultBlock with omitted optional fields absent.
pub fn ResponseBashCodeExecutionResultBlock::new(
  content~ : Array[ResponseBashCodeExecutionOutputBlock],
  return_code~ : Int32,
  stderr~ : String,
  stdout~ : String,
  type_~ : String,
) -> ResponseBashCodeExecutionResultBlock {
  { content, return_code, stderr, stdout, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseBashCodeExecutionResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseBashCodeExecutionResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("return_code", self.return_code)
  .field("stderr", self.stderr)
  .field("stdout", self.stdout)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseBashCodeExecutionResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseBashCodeExecutionResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    return_code: required_field(obj, "return_code", path),
    stderr: required_field(obj, "stderr", path),
    stdout: required_field(obj, "stdout", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseBashCodeExecutionToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseBashCodeExecutionToolResultBlockContent {
  BashCodeExecutionToolResultError(ResponseBashCodeExecutionToolResultError)
  BashCodeExecutionResult(ResponseBashCodeExecutionResultBlock)
  Unknown(String, Json)
}

///|
pub extend ResponseBashCodeExecutionToolResultBlockContent with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseBashCodeExecutionToolResultBlockContent with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseBashCodeExecutionToolResultBlockContent with ToJson::{
  to_json,
}

///|
pub impl ToJson for ResponseBashCodeExecutionToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    ResponseBashCodeExecutionToolResultBlockContent::BashCodeExecutionToolResultError(
      value,
    ) => @json.Json::Json(value)
    ResponseBashCodeExecutionToolResultBlockContent::BashCodeExecutionResult(
      value,
    ) => @json.Json::Json(value)
    ResponseBashCodeExecutionToolResultBlockContent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseBashCodeExecutionToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseBashCodeExecutionToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "bash_code_execution_tool_result_error" =>
      ResponseBashCodeExecutionToolResultBlockContent::BashCodeExecutionToolResultError(
        @json.from_json(value, path~),
      )
    "bash_code_execution_result" =>
      ResponseBashCodeExecutionToolResultBlockContent::BashCodeExecutionResult(
        @json.from_json(value, path~),
      )
    other =>
      ResponseBashCodeExecutionToolResultBlockContent::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseBashCodeExecutionToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseBashCodeExecutionToolResultBlock {
  content : ResponseBashCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend ResponseBashCodeExecutionToolResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseBashCodeExecutionToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseBashCodeExecutionToolResultBlock with omitted optional fields absent.
pub fn ResponseBashCodeExecutionToolResultBlock::new(
  content~ : ResponseBashCodeExecutionToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
) -> ResponseBashCodeExecutionToolResultBlock {
  { content, tool_use_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseBashCodeExecutionToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseBashCodeExecutionToolResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseBashCodeExecutionToolResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseBashCodeExecutionToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseCodeExecutionToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseCodeExecutionToolResultError {
  error_code : CodeExecutionToolResultErrorCode
  type_ : String
}

///|
pub extend ResponseCodeExecutionToolResultError with Eq::{equal, not_equal}

///|
pub extend ResponseCodeExecutionToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseCodeExecutionToolResultError with omitted optional fields absent.
pub fn ResponseCodeExecutionToolResultError::new(
  error_code~ : CodeExecutionToolResultErrorCode,
  type_~ : String,
) -> ResponseCodeExecutionToolResultError {
  { error_code, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseCodeExecutionToolResultError with ToJson::{to_json}

///|
pub impl ToJson for ResponseCodeExecutionToolResultError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseCodeExecutionToolResultError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseCodeExecutionToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseCodeExecutionOutputBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseCodeExecutionOutputBlock {
  file_id : String
}

///|
pub extend ResponseCodeExecutionOutputBlock with Eq::{equal, not_equal}

///|
pub extend ResponseCodeExecutionOutputBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseCodeExecutionOutputBlock with omitted optional fields absent.
pub fn ResponseCodeExecutionOutputBlock::new(
  file_id~ : String,
) -> ResponseCodeExecutionOutputBlock {
  { file_id, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseCodeExecutionOutputBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseCodeExecutionOutputBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("file_id", self.file_id)
  .field("type", "code_execution_output")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseCodeExecutionOutputBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseCodeExecutionOutputBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { file_id: required_field(obj, "file_id", path), }
}

///|
///
/// Generated representation of ResponseCodeExecutionResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseCodeExecutionResultBlock {
  content : Array[ResponseCodeExecutionOutputBlock]
  return_code : Int32
  stderr : String
  stdout : String
  type_ : String
}

///|
pub extend ResponseCodeExecutionResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseCodeExecutionResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseCodeExecutionResultBlock with omitted optional fields absent.
pub fn ResponseCodeExecutionResultBlock::new(
  content~ : Array[ResponseCodeExecutionOutputBlock],
  return_code~ : Int32,
  stderr~ : String,
  stdout~ : String,
  type_~ : String,
) -> ResponseCodeExecutionResultBlock {
  { content, return_code, stderr, stdout, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseCodeExecutionResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseCodeExecutionResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("return_code", self.return_code)
  .field("stderr", self.stderr)
  .field("stdout", self.stdout)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseCodeExecutionResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseCodeExecutionResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    return_code: required_field(obj, "return_code", path),
    stderr: required_field(obj, "stderr", path),
    stdout: required_field(obj, "stdout", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// The output and exit code of Python code that Claude ran with the code execution tool, with standard output in encrypted form. The API returns this block in place of `code_execution_result` when the code called the web search tool. See the [programmatic tool calling guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling) to learn more about programmatic tool calling.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseEncryptedCodeExecutionResultBlock {
  content : Array[ResponseCodeExecutionOutputBlock]
  encrypted_stdout : String
  return_code : Int32
  stderr : String
  type_ : String
}

///|
pub extend ResponseEncryptedCodeExecutionResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseEncryptedCodeExecutionResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a ResponseEncryptedCodeExecutionResultBlock with omitted optional fields absent.
pub fn ResponseEncryptedCodeExecutionResultBlock::new(
  content~ : Array[ResponseCodeExecutionOutputBlock],
  encrypted_stdout~ : String,
  return_code~ : Int32,
  stderr~ : String,
  type_~ : String,
) -> ResponseEncryptedCodeExecutionResultBlock {
  { content, encrypted_stdout, return_code, stderr, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseEncryptedCodeExecutionResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseEncryptedCodeExecutionResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("encrypted_stdout", self.encrypted_stdout)
  .field("return_code", self.return_code)
  .field("stderr", self.stderr)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseEncryptedCodeExecutionResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseEncryptedCodeExecutionResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    encrypted_stdout: required_field(obj, "encrypted_stdout", path),
    return_code: required_field(obj, "return_code", path),
    stderr: required_field(obj, "stderr", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseCodeExecutionToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseCodeExecutionToolResultBlockContent {
  CodeExecutionToolResultError(ResponseCodeExecutionToolResultError)
  CodeExecutionResult(ResponseCodeExecutionResultBlock)
  EncryptedCodeExecutionResult(ResponseEncryptedCodeExecutionResultBlock)
  Unknown(String, Json)
}

///|
pub extend ResponseCodeExecutionToolResultBlockContent with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseCodeExecutionToolResultBlockContent with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseCodeExecutionToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for ResponseCodeExecutionToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    ResponseCodeExecutionToolResultBlockContent::CodeExecutionToolResultError(
      value,
    ) => @json.Json::Json(value)
    ResponseCodeExecutionToolResultBlockContent::CodeExecutionResult(value) =>
      @json.Json::Json(value)
    ResponseCodeExecutionToolResultBlockContent::EncryptedCodeExecutionResult(
      value,
    ) => @json.Json::Json(value)
    ResponseCodeExecutionToolResultBlockContent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseCodeExecutionToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseCodeExecutionToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_tool_result_error" =>
      ResponseCodeExecutionToolResultBlockContent::CodeExecutionToolResultError(
        @json.from_json(value, path~),
      )
    "code_execution_result" =>
      ResponseCodeExecutionToolResultBlockContent::CodeExecutionResult(
        @json.from_json(value, path~),
      )
    "encrypted_code_execution_result" =>
      ResponseCodeExecutionToolResultBlockContent::EncryptedCodeExecutionResult(
        @json.from_json(value, path~),
      )
    other => ResponseCodeExecutionToolResultBlockContent::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseCodeExecutionToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseCodeExecutionToolResultBlock {
  content : ResponseCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend ResponseCodeExecutionToolResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseCodeExecutionToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseCodeExecutionToolResultBlock with omitted optional fields absent.
pub fn ResponseCodeExecutionToolResultBlock::new(
  content~ : ResponseCodeExecutionToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
) -> ResponseCodeExecutionToolResultBlock {
  { content, tool_use_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseCodeExecutionToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseCodeExecutionToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseCodeExecutionToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseCodeExecutionToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Response model for a file uploaded to the container.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseContainerUploadBlock {
  file_id : String
  type_ : String
}

///|
pub extend ResponseContainerUploadBlock with Eq::{equal, not_equal}

///|
pub extend ResponseContainerUploadBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseContainerUploadBlock with omitted optional fields absent.
pub fn ResponseContainerUploadBlock::new(
  file_id~ : String,
  type_~ : String,
) -> ResponseContainerUploadBlock {
  { file_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseContainerUploadBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseContainerUploadBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("file_id", self.file_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseContainerUploadBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseContainerUploadBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    file_id: required_field(obj, "file_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseRedactedThinkingBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseRedactedThinkingBlock {
  data : String
  type_ : String
}

///|
pub extend ResponseRedactedThinkingBlock with Eq::{equal, not_equal}

///|
pub extend ResponseRedactedThinkingBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseRedactedThinkingBlock with omitted optional fields absent.
pub fn ResponseRedactedThinkingBlock::new(
  data~ : String,
  type_~ : String,
) -> ResponseRedactedThinkingBlock {
  { data, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseRedactedThinkingBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseRedactedThinkingBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("data", self.data)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseRedactedThinkingBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseRedactedThinkingBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    data: required_field(obj, "data", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseServerToolUseBlockCaller.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseServerToolUseBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
}

///|
pub extend ResponseServerToolUseBlockCaller with Eq::{equal, not_equal}

///|
pub extend ResponseServerToolUseBlockCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseServerToolUseBlockCaller with ToJson::{to_json}

///|
pub impl ToJson for ResponseServerToolUseBlockCaller with fn to_json(self) {
  match self {
    ResponseServerToolUseBlockCaller::CodeExecution20250825(value) =>
      @json.Json::Json(value)
    ResponseServerToolUseBlockCaller::CodeExecution20260120(value) =>
      @json.Json::Json(value)
    ResponseServerToolUseBlockCaller::Direct(value) => @json.Json::Json(value)
    ResponseServerToolUseBlockCaller::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseServerToolUseBlockCaller with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseServerToolUseBlockCaller with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_20250825" =>
      ResponseServerToolUseBlockCaller::CodeExecution20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      ResponseServerToolUseBlockCaller::CodeExecution20260120(
        @json.from_json(value, path~),
      )
    "direct" =>
      ResponseServerToolUseBlockCaller::Direct(@json.from_json(value, path~))
    other => ResponseServerToolUseBlockCaller::Unknown(other, value)
  }
}

///|
///
/// Generated string enum ResponseServerToolUseBlockName.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseServerToolUseBlockName {
  WebSearch
  WebFetch
  CodeExecution
  BashCodeExecution
  TextEditorCodeExecution
  ToolSearchToolRegex
  ToolSearchToolBm25
  Unknown(String)
}

///|
pub extend ResponseServerToolUseBlockName with Eq::{equal, not_equal}

///|
pub extend ResponseServerToolUseBlockName with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ResponseServerToolUseBlockName with ToJson::{to_json}

///|
pub impl ToJson for ResponseServerToolUseBlockName with fn to_json(self) {
  let raw = match self {
    ResponseServerToolUseBlockName::WebSearch => "web_search"
    ResponseServerToolUseBlockName::WebFetch => "web_fetch"
    ResponseServerToolUseBlockName::CodeExecution => "code_execution"
    ResponseServerToolUseBlockName::BashCodeExecution => "bash_code_execution"
    ResponseServerToolUseBlockName::TextEditorCodeExecution =>
      "text_editor_code_execution"
    ResponseServerToolUseBlockName::ToolSearchToolRegex =>
      "tool_search_tool_regex"
    ResponseServerToolUseBlockName::ToolSearchToolBm25 =>
      "tool_search_tool_bm25"
    ResponseServerToolUseBlockName::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ResponseServerToolUseBlockName with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseServerToolUseBlockName with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "web_search" => Option::Some(ResponseServerToolUseBlockName::WebSearch)
        "web_fetch" => Option::Some(ResponseServerToolUseBlockName::WebFetch)
        "code_execution" =>
          Option::Some(ResponseServerToolUseBlockName::CodeExecution)
        "bash_code_execution" =>
          Option::Some(ResponseServerToolUseBlockName::BashCodeExecution)
        "text_editor_code_execution" =>
          Option::Some(ResponseServerToolUseBlockName::TextEditorCodeExecution)
        "tool_search_tool_regex" =>
          Option::Some(ResponseServerToolUseBlockName::ToolSearchToolRegex)
        "tool_search_tool_bm25" =>
          Option::Some(ResponseServerToolUseBlockName::ToolSearchToolBm25)
        _ => Option::None
      }
    },
    raw => ResponseServerToolUseBlockName::Unknown(raw),
  )
}

///|
///
/// Generated representation of ResponseServerToolUseBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseServerToolUseBlock {
  caller : ResponseServerToolUseBlockCaller
  id : String
  input : Json
  name : ResponseServerToolUseBlockName
  type_ : String
}

///|
pub extend ResponseServerToolUseBlock with Eq::{equal, not_equal}

///|
pub extend ResponseServerToolUseBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseServerToolUseBlock with omitted optional fields absent.
pub fn ResponseServerToolUseBlock::new(
  caller~ : ResponseServerToolUseBlockCaller,
  id~ : String,
  input~ : Json,
  name~ : ResponseServerToolUseBlockName,
  type_~ : String,
) -> ResponseServerToolUseBlock {
  { caller, id, input, name, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseServerToolUseBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseServerToolUseBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("caller", self.caller)
  .field("id", self.id)
  .field("input", self.input)
  .field("name", self.name)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseServerToolUseBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseServerToolUseBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    caller: decode_defaulted_field(obj, "caller", path, { "type": "direct" }),
    id: required_field(obj, "id", path),
    input: required_field(obj, "input", path),
    name: required_field(obj, "name", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseTextBlockCitationsItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseTextBlockCitationsItem {
  CharLocation(ResponseCharLocationCitation)
  ContentBlockLocation(ResponseContentBlockLocationCitation)
  PageLocation(ResponsePageLocationCitation)
  SearchResultLocation(ResponseSearchResultLocationCitation)
  WebSearchResultLocation(ResponseWebSearchResultLocationCitation)
  Unknown(String, Json)
}

///|
pub extend ResponseTextBlockCitationsItem with Eq::{equal, not_equal}

///|
pub extend ResponseTextBlockCitationsItem with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseTextBlockCitationsItem with ToJson::{to_json}

///|
pub impl ToJson for ResponseTextBlockCitationsItem with fn to_json(self) {
  match self {
    ResponseTextBlockCitationsItem::CharLocation(value) =>
      @json.Json::Json(value)
    ResponseTextBlockCitationsItem::ContentBlockLocation(value) =>
      @json.Json::Json(value)
    ResponseTextBlockCitationsItem::PageLocation(value) =>
      @json.Json::Json(value)
    ResponseTextBlockCitationsItem::SearchResultLocation(value) =>
      @json.Json::Json(value)
    ResponseTextBlockCitationsItem::WebSearchResultLocation(value) =>
      @json.Json::Json(value)
    ResponseTextBlockCitationsItem::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseTextBlockCitationsItem with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseTextBlockCitationsItem with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "char_location" =>
      ResponseTextBlockCitationsItem::CharLocation(
        @json.from_json(value, path~),
      )
    "content_block_location" =>
      ResponseTextBlockCitationsItem::ContentBlockLocation(
        @json.from_json(value, path~),
      )
    "page_location" =>
      ResponseTextBlockCitationsItem::PageLocation(
        @json.from_json(value, path~),
      )
    "search_result_location" =>
      ResponseTextBlockCitationsItem::SearchResultLocation(
        @json.from_json(value, path~),
      )
    "web_search_result_location" =>
      ResponseTextBlockCitationsItem::WebSearchResultLocation(
        @json.from_json(value, path~),
      )
    other => ResponseTextBlockCitationsItem::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseTextBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseTextBlock {
  citations : @sdkjson.Presence[Array[ResponseTextBlockCitationsItem]]
  text : String
  type_ : String
}

///|
pub extend ResponseTextBlock with Eq::{equal, not_equal}

///|
pub extend ResponseTextBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseTextBlock with omitted optional fields absent.
pub fn ResponseTextBlock::new(
  text~ : String,
  type_~ : String,
  citations? : Array[ResponseTextBlockCitationsItem],
) -> ResponseTextBlock {
  { citations: @sdkjson.Presence::from_option(citations), text, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseTextBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseTextBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("citations", self.citations)
  .field("text", self.text)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseTextBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseTextBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    citations: @sdkjson.presence_field(obj, "citations", path),
    text: required_field(obj, "text", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseTextEditorCodeExecutionToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseTextEditorCodeExecutionToolResultError {
  error_code : TextEditorCodeExecutionToolResultErrorCode
  error_message : String?
  type_ : String
}

///|
pub extend ResponseTextEditorCodeExecutionToolResultError with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseTextEditorCodeExecutionToolResultError with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a ResponseTextEditorCodeExecutionToolResultError with omitted optional fields absent.
pub fn ResponseTextEditorCodeExecutionToolResultError::new(
  error_code~ : TextEditorCodeExecutionToolResultErrorCode,
  type_~ : String,
  error_message? : String,
) -> ResponseTextEditorCodeExecutionToolResultError {
  { error_code, error_message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseTextEditorCodeExecutionToolResultError with ToJson::{to_json}

///|
pub impl ToJson for ResponseTextEditorCodeExecutionToolResultError with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .presence(
    "error_message",
    nullable_presence(self.error_message.map(value => value)),
  )
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseTextEditorCodeExecutionToolResultError with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseTextEditorCodeExecutionToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    error_message: decode_nullable_field(obj, "error_message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated string enum ResponseTextEditorCodeExecutionViewResultBlockFileType.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseTextEditorCodeExecutionViewResultBlockFileType {
  Text
  Image
  Pdf
  Unknown(String)
}

///|
pub extend ResponseTextEditorCodeExecutionViewResultBlockFileType with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseTextEditorCodeExecutionViewResultBlockFileType with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this string enum as JSON.
pub extend ResponseTextEditorCodeExecutionViewResultBlockFileType with ToJson::{
  to_json,
}

///|
pub impl ToJson for ResponseTextEditorCodeExecutionViewResultBlockFileType with fn to_json(
  self,
) {
  let raw = match self {
    ResponseTextEditorCodeExecutionViewResultBlockFileType::Text => "text"
    ResponseTextEditorCodeExecutionViewResultBlockFileType::Image => "image"
    ResponseTextEditorCodeExecutionViewResultBlockFileType::Pdf => "pdf"
    ResponseTextEditorCodeExecutionViewResultBlockFileType::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ResponseTextEditorCodeExecutionViewResultBlockFileType with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseTextEditorCodeExecutionViewResultBlockFileType with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "text" =>
          Option::Some(
            ResponseTextEditorCodeExecutionViewResultBlockFileType::Text,
          )
        "image" =>
          Option::Some(
            ResponseTextEditorCodeExecutionViewResultBlockFileType::Image,
          )
        "pdf" =>
          Option::Some(
            ResponseTextEditorCodeExecutionViewResultBlockFileType::Pdf,
          )
        _ => Option::None
      }
    },
    raw => ResponseTextEditorCodeExecutionViewResultBlockFileType::Unknown(raw),
  )
}

///|
///
/// Generated representation of ResponseTextEditorCodeExecutionViewResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseTextEditorCodeExecutionViewResultBlock {
  content : String
  file_type : ResponseTextEditorCodeExecutionViewResultBlockFileType
  num_lines : Int32?
  start_line : Int32?
  total_lines : Int32?
  type_ : String
}

///|
pub extend ResponseTextEditorCodeExecutionViewResultBlock with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseTextEditorCodeExecutionViewResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a ResponseTextEditorCodeExecutionViewResultBlock with omitted optional fields absent.
pub fn ResponseTextEditorCodeExecutionViewResultBlock::new(
  content~ : String,
  file_type~ : ResponseTextEditorCodeExecutionViewResultBlockFileType,
  type_~ : String,
  num_lines? : Int32,
  start_line? : Int32,
  total_lines? : Int32,
) -> ResponseTextEditorCodeExecutionViewResultBlock {
  { content, file_type, num_lines, start_line, total_lines, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseTextEditorCodeExecutionViewResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseTextEditorCodeExecutionViewResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("file_type", self.file_type)
  .presence("num_lines", nullable_presence(self.num_lines.map(value => value)))
  .presence(
    "start_line",
    nullable_presence(self.start_line.map(value => value)),
  )
  .presence(
    "total_lines",
    nullable_presence(self.total_lines.map(value => value)),
  )
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseTextEditorCodeExecutionViewResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseTextEditorCodeExecutionViewResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    file_type: required_field(obj, "file_type", path),
    num_lines: decode_nullable_field(obj, "num_lines", path),
    start_line: decode_nullable_field(obj, "start_line", path),
    total_lines: decode_nullable_field(obj, "total_lines", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseTextEditorCodeExecutionCreateResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseTextEditorCodeExecutionCreateResultBlock {
  is_file_update : Bool
  type_ : String
}

///|
pub extend ResponseTextEditorCodeExecutionCreateResultBlock with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseTextEditorCodeExecutionCreateResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a ResponseTextEditorCodeExecutionCreateResultBlock with omitted optional fields absent.
pub fn ResponseTextEditorCodeExecutionCreateResultBlock::new(
  is_file_update~ : Bool,
  type_~ : String,
) -> ResponseTextEditorCodeExecutionCreateResultBlock {
  { is_file_update, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseTextEditorCodeExecutionCreateResultBlock with ToJson::{
  to_json,
}

///|
pub impl ToJson for ResponseTextEditorCodeExecutionCreateResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("is_file_update", self.is_file_update)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseTextEditorCodeExecutionCreateResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseTextEditorCodeExecutionCreateResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    is_file_update: required_field(obj, "is_file_update", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseTextEditorCodeExecutionStrReplaceResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseTextEditorCodeExecutionStrReplaceResultBlock {
  lines : Array[String]?
  new_lines : Int32?
  new_start : Int32?
  old_lines : Int32?
  old_start : Int32?
  type_ : String
}

///|
pub extend ResponseTextEditorCodeExecutionStrReplaceResultBlock with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseTextEditorCodeExecutionStrReplaceResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a ResponseTextEditorCodeExecutionStrReplaceResultBlock with omitted optional fields absent.
pub fn ResponseTextEditorCodeExecutionStrReplaceResultBlock::new(
  type_~ : String,
  lines? : Array[String],
  new_lines? : Int32,
  new_start? : Int32,
  old_lines? : Int32,
  old_start? : Int32,
) -> ResponseTextEditorCodeExecutionStrReplaceResultBlock {
  { lines, new_lines, new_start, old_lines, old_start, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseTextEditorCodeExecutionStrReplaceResultBlock with ToJson::{
  to_json,
}

///|
pub impl ToJson for ResponseTextEditorCodeExecutionStrReplaceResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .presence("lines", nullable_presence(self.lines.map(value => value)))
  .presence("new_lines", nullable_presence(self.new_lines.map(value => value)))
  .presence("new_start", nullable_presence(self.new_start.map(value => value)))
  .presence("old_lines", nullable_presence(self.old_lines.map(value => value)))
  .presence("old_start", nullable_presence(self.old_start.map(value => value)))
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseTextEditorCodeExecutionStrReplaceResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseTextEditorCodeExecutionStrReplaceResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    lines: decode_nullable_field(obj, "lines", path),
    new_lines: decode_nullable_field(obj, "new_lines", path),
    new_start: decode_nullable_field(obj, "new_start", path),
    old_lines: decode_nullable_field(obj, "old_lines", path),
    old_start: decode_nullable_field(obj, "old_start", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseTextEditorCodeExecutionToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseTextEditorCodeExecutionToolResultBlockContent {
  TextEditorCodeExecutionToolResultError(
    ResponseTextEditorCodeExecutionToolResultError,
  )
  TextEditorCodeExecutionViewResult(
    ResponseTextEditorCodeExecutionViewResultBlock,
  )
  TextEditorCodeExecutionCreateResult(
    ResponseTextEditorCodeExecutionCreateResultBlock,
  )
  TextEditorCodeExecutionStrReplaceResult(
    ResponseTextEditorCodeExecutionStrReplaceResultBlock,
  )
  Unknown(String, Json)
}

///|
pub extend ResponseTextEditorCodeExecutionToolResultBlockContent with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseTextEditorCodeExecutionToolResultBlockContent with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseTextEditorCodeExecutionToolResultBlockContent with ToJson::{
  to_json,
}

///|
pub impl ToJson for ResponseTextEditorCodeExecutionToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    ResponseTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionToolResultError(
      value,
    ) => @json.Json::Json(value)
    ResponseTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionViewResult(
      value,
    ) => @json.Json::Json(value)
    ResponseTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionCreateResult(
      value,
    ) => @json.Json::Json(value)
    ResponseTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionStrReplaceResult(
      value,
    ) => @json.Json::Json(value)
    ResponseTextEditorCodeExecutionToolResultBlockContent::Unknown(_, value) =>
      value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseTextEditorCodeExecutionToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseTextEditorCodeExecutionToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "text_editor_code_execution_tool_result_error" =>
      ResponseTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionToolResultError(
        @json.from_json(value, path~),
      )
    "text_editor_code_execution_view_result" =>
      ResponseTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionViewResult(
        @json.from_json(value, path~),
      )
    "text_editor_code_execution_create_result" =>
      ResponseTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionCreateResult(
        @json.from_json(value, path~),
      )
    "text_editor_code_execution_str_replace_result" =>
      ResponseTextEditorCodeExecutionToolResultBlockContent::TextEditorCodeExecutionStrReplaceResult(
        @json.from_json(value, path~),
      )
    other =>
      ResponseTextEditorCodeExecutionToolResultBlockContent::Unknown(
        other, value,
      )
  }
}

///|
///
/// Generated representation of ResponseTextEditorCodeExecutionToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseTextEditorCodeExecutionToolResultBlock {
  content : ResponseTextEditorCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend ResponseTextEditorCodeExecutionToolResultBlock with Eq::{
  equal,
  not_equal,
}

///|
pub extend ResponseTextEditorCodeExecutionToolResultBlock with @debug.Debug::{
  to_repr,
}

///|
///
/// Creates a ResponseTextEditorCodeExecutionToolResultBlock with omitted optional fields absent.
pub fn ResponseTextEditorCodeExecutionToolResultBlock::new(
  content~ : ResponseTextEditorCodeExecutionToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
) -> ResponseTextEditorCodeExecutionToolResultBlock {
  { content, tool_use_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseTextEditorCodeExecutionToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseTextEditorCodeExecutionToolResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseTextEditorCodeExecutionToolResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseTextEditorCodeExecutionToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseThinkingBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseThinkingBlock {
  signature : String
  thinking : String
  type_ : String
}

///|
pub extend ResponseThinkingBlock with Eq::{equal, not_equal}

///|
pub extend ResponseThinkingBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseThinkingBlock with omitted optional fields absent.
pub fn ResponseThinkingBlock::new(
  signature~ : String,
  thinking~ : String,
  type_~ : String,
) -> ResponseThinkingBlock {
  { signature, thinking, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseThinkingBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseThinkingBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("signature", self.signature)
  .field("thinking", self.thinking)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseThinkingBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseThinkingBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    signature: required_field(obj, "signature", path),
    thinking: required_field(obj, "thinking", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseToolSearchToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseToolSearchToolResultError {
  error_code : ToolSearchToolResultErrorCode
  error_message : String?
  type_ : String
}

///|
pub extend ResponseToolSearchToolResultError with Eq::{equal, not_equal}

///|
pub extend ResponseToolSearchToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseToolSearchToolResultError with omitted optional fields absent.
pub fn ResponseToolSearchToolResultError::new(
  error_code~ : ToolSearchToolResultErrorCode,
  type_~ : String,
  error_message? : String,
) -> ResponseToolSearchToolResultError {
  { error_code, error_message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseToolSearchToolResultError with ToJson::{to_json}

///|
pub impl ToJson for ResponseToolSearchToolResultError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .presence(
    "error_message",
    nullable_presence(self.error_message.map(value => value)),
  )
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseToolSearchToolResultError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseToolSearchToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    error_message: decode_nullable_field(obj, "error_message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseToolReferenceBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseToolReferenceBlock {
  tool_name : String
}

///|
pub extend ResponseToolReferenceBlock with Eq::{equal, not_equal}

///|
pub extend ResponseToolReferenceBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseToolReferenceBlock with omitted optional fields absent.
pub fn ResponseToolReferenceBlock::new(
  tool_name~ : String,
) -> ResponseToolReferenceBlock {
  { tool_name, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseToolReferenceBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseToolReferenceBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("tool_name", self.tool_name)
  .field("type", "tool_reference")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseToolReferenceBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseToolReferenceBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { tool_name: required_field(obj, "tool_name", path), }
}

///|
///
/// Generated representation of ResponseToolSearchToolSearchResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseToolSearchToolSearchResultBlock {
  tool_references : Array[ResponseToolReferenceBlock]
  type_ : String
}

///|
pub extend ResponseToolSearchToolSearchResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseToolSearchToolSearchResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseToolSearchToolSearchResultBlock with omitted optional fields absent.
pub fn ResponseToolSearchToolSearchResultBlock::new(
  tool_references~ : Array[ResponseToolReferenceBlock],
  type_~ : String,
) -> ResponseToolSearchToolSearchResultBlock {
  { tool_references, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseToolSearchToolSearchResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseToolSearchToolSearchResultBlock with fn to_json(
  self,
) {
  @sdkjson.ObjBuilder::new()
  .field("tool_references", self.tool_references)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseToolSearchToolSearchResultBlock with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseToolSearchToolSearchResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    tool_references: required_field(obj, "tool_references", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseToolSearchToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseToolSearchToolResultBlockContent {
  ToolSearchToolResultError(ResponseToolSearchToolResultError)
  ToolSearchToolSearchResult(ResponseToolSearchToolSearchResultBlock)
  Unknown(String, Json)
}

///|
pub extend ResponseToolSearchToolResultBlockContent with Eq::{equal, not_equal}

///|
pub extend ResponseToolSearchToolResultBlockContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseToolSearchToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for ResponseToolSearchToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    ResponseToolSearchToolResultBlockContent::ToolSearchToolResultError(value) =>
      @json.Json::Json(value)
    ResponseToolSearchToolResultBlockContent::ToolSearchToolSearchResult(value) =>
      @json.Json::Json(value)
    ResponseToolSearchToolResultBlockContent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseToolSearchToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseToolSearchToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "tool_search_tool_result_error" =>
      ResponseToolSearchToolResultBlockContent::ToolSearchToolResultError(
        @json.from_json(value, path~),
      )
    "tool_search_tool_search_result" =>
      ResponseToolSearchToolResultBlockContent::ToolSearchToolSearchResult(
        @json.from_json(value, path~),
      )
    other => ResponseToolSearchToolResultBlockContent::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseToolSearchToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseToolSearchToolResultBlock {
  content : ResponseToolSearchToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend ResponseToolSearchToolResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseToolSearchToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseToolSearchToolResultBlock with omitted optional fields absent.
pub fn ResponseToolSearchToolResultBlock::new(
  content~ : ResponseToolSearchToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
) -> ResponseToolSearchToolResultBlock {
  { content, tool_use_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseToolSearchToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseToolSearchToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseToolSearchToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseToolSearchToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseToolUseBlockCaller.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseToolUseBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
}

///|
pub extend ResponseToolUseBlockCaller with Eq::{equal, not_equal}

///|
pub extend ResponseToolUseBlockCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseToolUseBlockCaller with ToJson::{to_json}

///|
pub impl ToJson for ResponseToolUseBlockCaller with fn to_json(self) {
  match self {
    ResponseToolUseBlockCaller::CodeExecution20250825(value) =>
      @json.Json::Json(value)
    ResponseToolUseBlockCaller::CodeExecution20260120(value) =>
      @json.Json::Json(value)
    ResponseToolUseBlockCaller::Direct(value) => @json.Json::Json(value)
    ResponseToolUseBlockCaller::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseToolUseBlockCaller with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseToolUseBlockCaller with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_20250825" =>
      ResponseToolUseBlockCaller::CodeExecution20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      ResponseToolUseBlockCaller::CodeExecution20260120(
        @json.from_json(value, path~),
      )
    "direct" =>
      ResponseToolUseBlockCaller::Direct(@json.from_json(value, path~))
    other => ResponseToolUseBlockCaller::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseToolUseBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseToolUseBlock {
  caller : ResponseToolUseBlockCaller
  id : String
  input : Json
  name : String
  toolset_name : @sdkjson.Presence[String]
  type_ : String
}

///|
pub extend ResponseToolUseBlock with Eq::{equal, not_equal}

///|
pub extend ResponseToolUseBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseToolUseBlock with omitted optional fields absent.
pub fn ResponseToolUseBlock::new(
  caller~ : ResponseToolUseBlockCaller,
  id~ : String,
  input~ : Json,
  name~ : String,
  type_~ : String,
  toolset_name? : String,
) -> ResponseToolUseBlock {
  {
    caller,
    id,
    input,
    name,
    toolset_name: @sdkjson.Presence::from_option(toolset_name),
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseToolUseBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseToolUseBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("caller", self.caller)
  .field("id", self.id)
  .field("input", self.input)
  .field("name", self.name)
  .presence("toolset_name", self.toolset_name)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseToolUseBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseToolUseBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    caller: decode_defaulted_field(obj, "caller", path, { "type": "direct" }),
    id: required_field(obj, "id", path),
    input: required_field(obj, "input", path),
    name: required_field(obj, "name", path),
    toolset_name: @sdkjson.presence_field(obj, "toolset_name", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseWebFetchToolResultBlockCaller.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseWebFetchToolResultBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
}

///|
pub extend ResponseWebFetchToolResultBlockCaller with Eq::{equal, not_equal}

///|
pub extend ResponseWebFetchToolResultBlockCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseWebFetchToolResultBlockCaller with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebFetchToolResultBlockCaller with fn to_json(self) {
  match self {
    ResponseWebFetchToolResultBlockCaller::CodeExecution20250825(value) =>
      @json.Json::Json(value)
    ResponseWebFetchToolResultBlockCaller::CodeExecution20260120(value) =>
      @json.Json::Json(value)
    ResponseWebFetchToolResultBlockCaller::Direct(value) =>
      @json.Json::Json(value)
    ResponseWebFetchToolResultBlockCaller::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseWebFetchToolResultBlockCaller with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseWebFetchToolResultBlockCaller with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_20250825" =>
      ResponseWebFetchToolResultBlockCaller::CodeExecution20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      ResponseWebFetchToolResultBlockCaller::CodeExecution20260120(
        @json.from_json(value, path~),
      )
    "direct" =>
      ResponseWebFetchToolResultBlockCaller::Direct(
        @json.from_json(value, path~),
      )
    other => ResponseWebFetchToolResultBlockCaller::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseWebFetchToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseWebFetchToolResultError {
  error_code : WebFetchToolResultErrorCode
  type_ : String
}

///|
pub extend ResponseWebFetchToolResultError with Eq::{equal, not_equal}

///|
pub extend ResponseWebFetchToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseWebFetchToolResultError with omitted optional fields absent.
pub fn ResponseWebFetchToolResultError::new(
  error_code~ : WebFetchToolResultErrorCode,
  type_~ : String,
) -> ResponseWebFetchToolResultError {
  { error_code, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseWebFetchToolResultError with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebFetchToolResultError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseWebFetchToolResultError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseWebFetchToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error_code: required_field(obj, "error_code", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ResponseCitationsConfig.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseCitationsConfig {
  enabled : Bool
}

///|
pub extend ResponseCitationsConfig with Eq::{equal, not_equal}

///|
pub extend ResponseCitationsConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseCitationsConfig with omitted optional fields absent.
pub fn ResponseCitationsConfig::new(enabled~ : Bool) -> ResponseCitationsConfig {
  { enabled, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseCitationsConfig with ToJson::{to_json}

///|
pub impl ToJson for ResponseCitationsConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("enabled", self.enabled).build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseCitationsConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseCitationsConfig with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { enabled: required_field(obj, "enabled", path), }
}

///|
///
/// Generated tagged union ResponseDocumentBlockSource.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseDocumentBlockSource {
  Base64(Base64PDFSource)
  Text(PlainTextSource)
  Unknown(String, Json)
}

///|
pub extend ResponseDocumentBlockSource with Eq::{equal, not_equal}

///|
pub extend ResponseDocumentBlockSource with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseDocumentBlockSource with ToJson::{to_json}

///|
pub impl ToJson for ResponseDocumentBlockSource with fn to_json(self) {
  match self {
    ResponseDocumentBlockSource::Base64(value) => @json.Json::Json(value)
    ResponseDocumentBlockSource::Text(value) => @json.Json::Json(value)
    ResponseDocumentBlockSource::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseDocumentBlockSource with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseDocumentBlockSource with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "base64" =>
      ResponseDocumentBlockSource::Base64(@json.from_json(value, path~))
    "text" => ResponseDocumentBlockSource::Text(@json.from_json(value, path~))
    other => ResponseDocumentBlockSource::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseDocumentBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseDocumentBlock {
  citations : ResponseCitationsConfig?
  source : ResponseDocumentBlockSource
  title : String?
}

///|
pub extend ResponseDocumentBlock with Eq::{equal, not_equal}

///|
pub extend ResponseDocumentBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseDocumentBlock with omitted optional fields absent.
pub fn ResponseDocumentBlock::new(
  source~ : ResponseDocumentBlockSource,
  citations? : ResponseCitationsConfig,
  title? : String,
) -> ResponseDocumentBlock {
  { citations, source, title, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseDocumentBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseDocumentBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("citations", nullable_presence(self.citations.map(value => value)))
  .field("source", self.source)
  .presence("title", nullable_presence(self.title.map(value => value)))
  .field("type", "document")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseDocumentBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseDocumentBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    citations: decode_nullable_field(obj, "citations", path),
    source: required_field(obj, "source", path),
    title: decode_nullable_field(obj, "title", path),
  }
}

///|
///
/// Generated representation of ResponseWebFetchResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseWebFetchResultBlock {
  content : ResponseDocumentBlock
  retrieved_at : String?
  type_ : String
  url : String
}

///|
pub extend ResponseWebFetchResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseWebFetchResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseWebFetchResultBlock with omitted optional fields absent.
pub fn ResponseWebFetchResultBlock::new(
  content~ : ResponseDocumentBlock,
  type_~ : String,
  url~ : String,
  retrieved_at? : String,
) -> ResponseWebFetchResultBlock {
  { content, retrieved_at, type_, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseWebFetchResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebFetchResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .presence(
    "retrieved_at",
    nullable_presence(self.retrieved_at.map(value => value)),
  )
  .field("type", self.type_)
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseWebFetchResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseWebFetchResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    retrieved_at: decode_nullable_field(obj, "retrieved_at", path),
    type_: required_field(obj, "type", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// Generated tagged union ResponseWebFetchToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseWebFetchToolResultBlockContent {
  WebFetchToolResultError(ResponseWebFetchToolResultError)
  WebFetchResult(ResponseWebFetchResultBlock)
  Unknown(String, Json)
}

///|
pub extend ResponseWebFetchToolResultBlockContent with Eq::{equal, not_equal}

///|
pub extend ResponseWebFetchToolResultBlockContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseWebFetchToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebFetchToolResultBlockContent with fn to_json(self) {
  match self {
    ResponseWebFetchToolResultBlockContent::WebFetchToolResultError(value) =>
      @json.Json::Json(value)
    ResponseWebFetchToolResultBlockContent::WebFetchResult(value) =>
      @json.Json::Json(value)
    ResponseWebFetchToolResultBlockContent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseWebFetchToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseWebFetchToolResultBlockContent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "web_fetch_tool_result_error" =>
      ResponseWebFetchToolResultBlockContent::WebFetchToolResultError(
        @json.from_json(value, path~),
      )
    "web_fetch_result" =>
      ResponseWebFetchToolResultBlockContent::WebFetchResult(
        @json.from_json(value, path~),
      )
    other => ResponseWebFetchToolResultBlockContent::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseWebFetchToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseWebFetchToolResultBlock {
  caller : ResponseWebFetchToolResultBlockCaller
  content : ResponseWebFetchToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend ResponseWebFetchToolResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseWebFetchToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseWebFetchToolResultBlock with omitted optional fields absent.
pub fn ResponseWebFetchToolResultBlock::new(
  caller~ : ResponseWebFetchToolResultBlockCaller,
  content~ : ResponseWebFetchToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
) -> ResponseWebFetchToolResultBlock {
  { caller, content, tool_use_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseWebFetchToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebFetchToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("caller", self.caller)
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseWebFetchToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseWebFetchToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    caller: required_field(obj, "caller", path),
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ResponseWebSearchToolResultBlockCaller.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseWebSearchToolResultBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
}

///|
pub extend ResponseWebSearchToolResultBlockCaller with Eq::{equal, not_equal}

///|
pub extend ResponseWebSearchToolResultBlockCaller with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ResponseWebSearchToolResultBlockCaller with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebSearchToolResultBlockCaller with fn to_json(self) {
  match self {
    ResponseWebSearchToolResultBlockCaller::CodeExecution20250825(value) =>
      @json.Json::Json(value)
    ResponseWebSearchToolResultBlockCaller::CodeExecution20260120(value) =>
      @json.Json::Json(value)
    ResponseWebSearchToolResultBlockCaller::Direct(value) =>
      @json.Json::Json(value)
    ResponseWebSearchToolResultBlockCaller::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ResponseWebSearchToolResultBlockCaller with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseWebSearchToolResultBlockCaller with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "code_execution_20250825" =>
      ResponseWebSearchToolResultBlockCaller::CodeExecution20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      ResponseWebSearchToolResultBlockCaller::CodeExecution20260120(
        @json.from_json(value, path~),
      )
    "direct" =>
      ResponseWebSearchToolResultBlockCaller::Direct(
        @json.from_json(value, path~),
      )
    other => ResponseWebSearchToolResultBlockCaller::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseWebSearchToolResultError.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseWebSearchToolResultError {
  error_code : WebSearchToolResultErrorCode
}

///|
pub extend ResponseWebSearchToolResultError with Eq::{equal, not_equal}

///|
pub extend ResponseWebSearchToolResultError with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseWebSearchToolResultError with omitted optional fields absent.
pub fn ResponseWebSearchToolResultError::new(
  error_code~ : WebSearchToolResultErrorCode,
) -> ResponseWebSearchToolResultError {
  { error_code, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseWebSearchToolResultError with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebSearchToolResultError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", self.error_code)
  .field("type", "web_search_tool_result_error")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseWebSearchToolResultError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseWebSearchToolResultError with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { error_code: required_field(obj, "error_code", path), }
}

///|
///
/// Generated representation of ResponseWebSearchResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseWebSearchResultBlock {
  encrypted_content : String
  page_age : String?
  title : String
  url : String
}

///|
pub extend ResponseWebSearchResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseWebSearchResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseWebSearchResultBlock with omitted optional fields absent.
pub fn ResponseWebSearchResultBlock::new(
  encrypted_content~ : String,
  title~ : String,
  url~ : String,
  page_age? : String,
) -> ResponseWebSearchResultBlock {
  { encrypted_content, page_age, title, url, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseWebSearchResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebSearchResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("encrypted_content", self.encrypted_content)
  .presence("page_age", nullable_presence(self.page_age.map(value => value)))
  .field("title", self.title)
  .field("type", "web_search_result")
  .field("url", self.url)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseWebSearchResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseWebSearchResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    encrypted_content: required_field(obj, "encrypted_content", path),
    page_age: decode_nullable_field(obj, "page_age", path),
    title: required_field(obj, "title", path),
    url: required_field(obj, "url", path),
  }
}

///|
///
/// Generated untagged union ResponseWebSearchToolResultBlockContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ResponseWebSearchToolResultBlockContent {
  ResponseWebSearchToolResultError(ResponseWebSearchToolResultError)
  ResponseWebSearchResultBlockArray(Array[ResponseWebSearchResultBlock])
}

///|
pub extend ResponseWebSearchToolResultBlockContent with Eq::{equal, not_equal}

///|
pub extend ResponseWebSearchToolResultBlockContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend ResponseWebSearchToolResultBlockContent with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebSearchToolResultBlockContent with fn to_json(
  self,
) {
  match self {
    ResponseWebSearchToolResultBlockContent::ResponseWebSearchToolResultError(
      value,
    ) => @json.Json::Json(value)
    ResponseWebSearchToolResultBlockContent::ResponseWebSearchResultBlockArray(
      value,
    ) => @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend ResponseWebSearchToolResultBlockContent with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ResponseWebSearchToolResultBlockContent with fn from_json(
  value,
  path,
) {
  if value is @json.Json::Object(_) {
    let decoded : ResponseWebSearchToolResultError = @json.from_json(
      value,
      path~,
    )
    return ResponseWebSearchToolResultBlockContent::ResponseWebSearchToolResultError(
      decoded,
    )
  }
  if json_array_matches(value, item => item is @json.Json::Object(_)) {
    let decoded : Array[ResponseWebSearchResultBlock] = @json.from_json(
      value,
      path~,
    )
    return ResponseWebSearchToolResultBlockContent::ResponseWebSearchResultBlockArray(
      decoded,
    )
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (
      path, "JSON shape does not match any ResponseWebSearchToolResultBlockContent variant",
    ),
  )
}

///|
///
/// Generated representation of ResponseWebSearchToolResultBlock.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseWebSearchToolResultBlock {
  caller : ResponseWebSearchToolResultBlockCaller
  content : ResponseWebSearchToolResultBlockContent
  tool_use_id : String
  type_ : String
}

///|
pub extend ResponseWebSearchToolResultBlock with Eq::{equal, not_equal}

///|
pub extend ResponseWebSearchToolResultBlock with @debug.Debug::{to_repr}

///|
///
/// Creates a ResponseWebSearchToolResultBlock with omitted optional fields absent.
pub fn ResponseWebSearchToolResultBlock::new(
  caller~ : ResponseWebSearchToolResultBlockCaller,
  content~ : ResponseWebSearchToolResultBlockContent,
  tool_use_id~ : String,
  type_~ : String,
) -> ResponseWebSearchToolResultBlock {
  { caller, content, tool_use_id, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ResponseWebSearchToolResultBlock with ToJson::{to_json}

///|
pub impl ToJson for ResponseWebSearchToolResultBlock with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("caller", self.caller)
  .field("content", self.content)
  .field("tool_use_id", self.tool_use_id)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ResponseWebSearchToolResultBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ResponseWebSearchToolResultBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    caller: required_field(obj, "caller", path),
    content: required_field(obj, "content", path),
    tool_use_id: required_field(obj, "tool_use_id", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ContentBlock.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ContentBlock {
  BashCodeExecutionToolResult(ResponseBashCodeExecutionToolResultBlock)
  CodeExecutionToolResult(ResponseCodeExecutionToolResultBlock)
  ContainerUpload(ResponseContainerUploadBlock)
  RedactedThinking(ResponseRedactedThinkingBlock)
  ServerToolUse(ResponseServerToolUseBlock)
  Text(ResponseTextBlock)
  TextEditorCodeExecutionToolResult(
    ResponseTextEditorCodeExecutionToolResultBlock,
  )
  Thinking(ResponseThinkingBlock)
  ToolSearchToolResult(ResponseToolSearchToolResultBlock)
  ToolUse(ResponseToolUseBlock)
  WebFetchToolResult(ResponseWebFetchToolResultBlock)
  WebSearchToolResult(ResponseWebSearchToolResultBlock)
  Unknown(String, Json)
}

///|
pub extend ContentBlock with Eq::{equal, not_equal}

///|
pub extend ContentBlock with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ContentBlock with ToJson::{to_json}

///|
pub impl ToJson for ContentBlock with fn to_json(self) {
  match self {
    ContentBlock::BashCodeExecutionToolResult(value) => @json.Json::Json(value)
    ContentBlock::CodeExecutionToolResult(value) => @json.Json::Json(value)
    ContentBlock::ContainerUpload(value) => @json.Json::Json(value)
    ContentBlock::RedactedThinking(value) => @json.Json::Json(value)
    ContentBlock::ServerToolUse(value) => @json.Json::Json(value)
    ContentBlock::Text(value) => @json.Json::Json(value)
    ContentBlock::TextEditorCodeExecutionToolResult(value) =>
      @json.Json::Json(value)
    ContentBlock::Thinking(value) => @json.Json::Json(value)
    ContentBlock::ToolSearchToolResult(value) => @json.Json::Json(value)
    ContentBlock::ToolUse(value) => @json.Json::Json(value)
    ContentBlock::WebFetchToolResult(value) => @json.Json::Json(value)
    ContentBlock::WebSearchToolResult(value) => @json.Json::Json(value)
    ContentBlock::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ContentBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContentBlock with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "bash_code_execution_tool_result" =>
      ContentBlock::BashCodeExecutionToolResult(@json.from_json(value, path~))
    "code_execution_tool_result" =>
      ContentBlock::CodeExecutionToolResult(@json.from_json(value, path~))
    "container_upload" =>
      ContentBlock::ContainerUpload(@json.from_json(value, path~))
    "redacted_thinking" =>
      ContentBlock::RedactedThinking(@json.from_json(value, path~))
    "server_tool_use" =>
      ContentBlock::ServerToolUse(@json.from_json(value, path~))
    "text" => ContentBlock::Text(@json.from_json(value, path~))
    "text_editor_code_execution_tool_result" =>
      ContentBlock::TextEditorCodeExecutionToolResult(
        @json.from_json(value, path~),
      )
    "thinking" => ContentBlock::Thinking(@json.from_json(value, path~))
    "tool_search_tool_result" =>
      ContentBlock::ToolSearchToolResult(@json.from_json(value, path~))
    "tool_use" => ContentBlock::ToolUse(@json.from_json(value, path~))
    "web_fetch_tool_result" =>
      ContentBlock::WebFetchToolResult(@json.from_json(value, path~))
    "web_search_tool_result" =>
      ContentBlock::WebSearchToolResult(@json.from_json(value, path~))
    other => ContentBlock::Unknown(other, value)
  }
}

///|
///
/// Generated representation of InputJsonContentBlockDelta.
#derive(Eq, @debug.Debug)
pub(all) struct InputJsonContentBlockDelta {
  partial_json : String
  type_ : String
}

///|
pub extend InputJsonContentBlockDelta with Eq::{equal, not_equal}

///|
pub extend InputJsonContentBlockDelta with @debug.Debug::{to_repr}

///|
///
/// Creates a InputJsonContentBlockDelta with omitted optional fields absent.
pub fn InputJsonContentBlockDelta::new(
  partial_json~ : String,
  type_~ : String,
) -> InputJsonContentBlockDelta {
  { partial_json, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend InputJsonContentBlockDelta with ToJson::{to_json}

///|
pub impl ToJson for InputJsonContentBlockDelta with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("partial_json", self.partial_json)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend InputJsonContentBlockDelta with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for InputJsonContentBlockDelta with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    partial_json: required_field(obj, "partial_json", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of SignatureContentBlockDelta.
#derive(Eq, @debug.Debug)
pub(all) struct SignatureContentBlockDelta {
  signature : String
  type_ : String
}

///|
pub extend SignatureContentBlockDelta with Eq::{equal, not_equal}

///|
pub extend SignatureContentBlockDelta with @debug.Debug::{to_repr}

///|
///
/// Creates a SignatureContentBlockDelta with omitted optional fields absent.
pub fn SignatureContentBlockDelta::new(
  signature~ : String,
  type_~ : String,
) -> SignatureContentBlockDelta {
  { signature, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend SignatureContentBlockDelta with ToJson::{to_json}

///|
pub impl ToJson for SignatureContentBlockDelta with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("signature", self.signature)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend SignatureContentBlockDelta with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for SignatureContentBlockDelta with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    signature: required_field(obj, "signature", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of TextContentBlockDelta.
#derive(Eq, @debug.Debug)
pub(all) struct TextContentBlockDelta {
  text : String
  type_ : String
}

///|
pub extend TextContentBlockDelta with Eq::{equal, not_equal}

///|
pub extend TextContentBlockDelta with @debug.Debug::{to_repr}

///|
///
/// Creates a TextContentBlockDelta with omitted optional fields absent.
pub fn TextContentBlockDelta::new(
  text~ : String,
  type_~ : String,
) -> TextContentBlockDelta {
  { text, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend TextContentBlockDelta with ToJson::{to_json}

///|
pub impl ToJson for TextContentBlockDelta with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("text", self.text)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend TextContentBlockDelta with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for TextContentBlockDelta with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    text: required_field(obj, "text", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ThinkingContentBlockDelta.
#derive(Eq, @debug.Debug)
pub(all) struct ThinkingContentBlockDelta {
  thinking : String
  type_ : String
}

///|
pub extend ThinkingContentBlockDelta with Eq::{equal, not_equal}

///|
pub extend ThinkingContentBlockDelta with @debug.Debug::{to_repr}

///|
///
/// Creates a ThinkingContentBlockDelta with omitted optional fields absent.
pub fn ThinkingContentBlockDelta::new(
  thinking~ : String,
  type_~ : String,
) -> ThinkingContentBlockDelta {
  { thinking, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ThinkingContentBlockDelta with ToJson::{to_json}

///|
pub impl ToJson for ThinkingContentBlockDelta with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("thinking", self.thinking)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThinkingContentBlockDelta with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingContentBlockDelta with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    thinking: required_field(obj, "thinking", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ContentBlockDeltaEventDelta.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ContentBlockDeltaEventDelta {
  CitationsDelta(CitationsDelta)
  InputJsonDelta(InputJsonContentBlockDelta)
  SignatureDelta(SignatureContentBlockDelta)
  TextDelta(TextContentBlockDelta)
  ThinkingDelta(ThinkingContentBlockDelta)
  Unknown(String, Json)
}

///|
pub extend ContentBlockDeltaEventDelta with Eq::{equal, not_equal}

///|
pub extend ContentBlockDeltaEventDelta with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ContentBlockDeltaEventDelta with ToJson::{to_json}

///|
pub impl ToJson for ContentBlockDeltaEventDelta with fn to_json(self) {
  match self {
    ContentBlockDeltaEventDelta::CitationsDelta(value) =>
      @json.Json::Json(value)
    ContentBlockDeltaEventDelta::InputJsonDelta(value) =>
      @json.Json::Json(value)
    ContentBlockDeltaEventDelta::SignatureDelta(value) =>
      @json.Json::Json(value)
    ContentBlockDeltaEventDelta::TextDelta(value) => @json.Json::Json(value)
    ContentBlockDeltaEventDelta::ThinkingDelta(value) => @json.Json::Json(value)
    ContentBlockDeltaEventDelta::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ContentBlockDeltaEventDelta with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContentBlockDeltaEventDelta with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "citations_delta" =>
      ContentBlockDeltaEventDelta::CitationsDelta(@json.from_json(value, path~))
    "input_json_delta" =>
      ContentBlockDeltaEventDelta::InputJsonDelta(@json.from_json(value, path~))
    "signature_delta" =>
      ContentBlockDeltaEventDelta::SignatureDelta(@json.from_json(value, path~))
    "text_delta" =>
      ContentBlockDeltaEventDelta::TextDelta(@json.from_json(value, path~))
    "thinking_delta" =>
      ContentBlockDeltaEventDelta::ThinkingDelta(@json.from_json(value, path~))
    other => ContentBlockDeltaEventDelta::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ContentBlockDeltaEvent.
#derive(Eq, @debug.Debug)
pub(all) struct ContentBlockDeltaEvent {
  delta : ContentBlockDeltaEventDelta
  index : Int32
  type_ : String
}

///|
pub extend ContentBlockDeltaEvent with Eq::{equal, not_equal}

///|
pub extend ContentBlockDeltaEvent with @debug.Debug::{to_repr}

///|
///
/// Creates a ContentBlockDeltaEvent with omitted optional fields absent.
pub fn ContentBlockDeltaEvent::new(
  delta~ : ContentBlockDeltaEventDelta,
  index~ : Int32,
  type_~ : String,
) -> ContentBlockDeltaEvent {
  { delta, index, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ContentBlockDeltaEvent with ToJson::{to_json}

///|
pub impl ToJson for ContentBlockDeltaEvent with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("delta", self.delta)
  .field("index", self.index)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ContentBlockDeltaEvent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContentBlockDeltaEvent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    delta: required_field(obj, "delta", path),
    index: required_field(obj, "index", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ContentBlockStartEventContentBlock.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ContentBlockStartEventContentBlock {
  BashCodeExecutionToolResult(ResponseBashCodeExecutionToolResultBlock)
  CodeExecutionToolResult(ResponseCodeExecutionToolResultBlock)
  ContainerUpload(ResponseContainerUploadBlock)
  RedactedThinking(ResponseRedactedThinkingBlock)
  ServerToolUse(ResponseServerToolUseBlock)
  Text(ResponseTextBlock)
  TextEditorCodeExecutionToolResult(
    ResponseTextEditorCodeExecutionToolResultBlock,
  )
  Thinking(ResponseThinkingBlock)
  ToolSearchToolResult(ResponseToolSearchToolResultBlock)
  ToolUse(ResponseToolUseBlock)
  WebFetchToolResult(ResponseWebFetchToolResultBlock)
  WebSearchToolResult(ResponseWebSearchToolResultBlock)
  Unknown(String, Json)
}

///|
pub extend ContentBlockStartEventContentBlock with Eq::{equal, not_equal}

///|
pub extend ContentBlockStartEventContentBlock with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ContentBlockStartEventContentBlock with ToJson::{to_json}

///|
pub impl ToJson for ContentBlockStartEventContentBlock with fn to_json(self) {
  match self {
    ContentBlockStartEventContentBlock::BashCodeExecutionToolResult(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::CodeExecutionToolResult(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::ContainerUpload(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::RedactedThinking(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::ServerToolUse(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::Text(value) => @json.Json::Json(value)
    ContentBlockStartEventContentBlock::TextEditorCodeExecutionToolResult(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::Thinking(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::ToolSearchToolResult(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::ToolUse(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::WebFetchToolResult(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::WebSearchToolResult(value) =>
      @json.Json::Json(value)
    ContentBlockStartEventContentBlock::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ContentBlockStartEventContentBlock with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContentBlockStartEventContentBlock with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "bash_code_execution_tool_result" =>
      ContentBlockStartEventContentBlock::BashCodeExecutionToolResult(
        @json.from_json(value, path~),
      )
    "code_execution_tool_result" =>
      ContentBlockStartEventContentBlock::CodeExecutionToolResult(
        @json.from_json(value, path~),
      )
    "container_upload" =>
      ContentBlockStartEventContentBlock::ContainerUpload(
        @json.from_json(value, path~),
      )
    "redacted_thinking" =>
      ContentBlockStartEventContentBlock::RedactedThinking(
        @json.from_json(value, path~),
      )
    "server_tool_use" =>
      ContentBlockStartEventContentBlock::ServerToolUse(
        @json.from_json(value, path~),
      )
    "text" =>
      ContentBlockStartEventContentBlock::Text(@json.from_json(value, path~))
    "text_editor_code_execution_tool_result" =>
      ContentBlockStartEventContentBlock::TextEditorCodeExecutionToolResult(
        @json.from_json(value, path~),
      )
    "thinking" =>
      ContentBlockStartEventContentBlock::Thinking(
        @json.from_json(value, path~),
      )
    "tool_search_tool_result" =>
      ContentBlockStartEventContentBlock::ToolSearchToolResult(
        @json.from_json(value, path~),
      )
    "tool_use" =>
      ContentBlockStartEventContentBlock::ToolUse(@json.from_json(value, path~))
    "web_fetch_tool_result" =>
      ContentBlockStartEventContentBlock::WebFetchToolResult(
        @json.from_json(value, path~),
      )
    "web_search_tool_result" =>
      ContentBlockStartEventContentBlock::WebSearchToolResult(
        @json.from_json(value, path~),
      )
    other => ContentBlockStartEventContentBlock::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ContentBlockStartEvent.
#derive(Eq, @debug.Debug)
pub(all) struct ContentBlockStartEvent {
  content_block : ContentBlockStartEventContentBlock
  index : Int32
  type_ : String
}

///|
pub extend ContentBlockStartEvent with Eq::{equal, not_equal}

///|
pub extend ContentBlockStartEvent with @debug.Debug::{to_repr}

///|
///
/// Creates a ContentBlockStartEvent with omitted optional fields absent.
pub fn ContentBlockStartEvent::new(
  content_block~ : ContentBlockStartEventContentBlock,
  index~ : Int32,
  type_~ : String,
) -> ContentBlockStartEvent {
  { content_block, index, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ContentBlockStartEvent with ToJson::{to_json}

///|
pub impl ToJson for ContentBlockStartEvent with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content_block", self.content_block)
  .field("index", self.index)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ContentBlockStartEvent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContentBlockStartEvent with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content_block: required_field(obj, "content_block", path),
    index: required_field(obj, "index", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ContentBlockStopEvent.
#derive(Eq, @debug.Debug)
pub(all) struct ContentBlockStopEvent {
  index : Int32
  type_ : String
}

///|
pub extend ContentBlockStopEvent with Eq::{equal, not_equal}

///|
pub extend ContentBlockStopEvent with @debug.Debug::{to_repr}

///|
///
/// Creates a ContentBlockStopEvent with omitted optional fields absent.
pub fn ContentBlockStopEvent::new(
  index~ : Int32,
  type_~ : String,
) -> ContentBlockStopEvent {
  { index, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ContentBlockStopEvent with ToJson::{to_json}

///|
pub impl ToJson for ContentBlockStopEvent with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("index", self.index)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ContentBlockStopEvent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContentBlockStopEvent with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    index: required_field(obj, "index", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Context management capability details.
#derive(Eq, @debug.Debug)
pub(all) struct ContextManagementCapability {
  clear_thinking_20251015 : CapabilitySupport?
  clear_tool_uses_20250919 : CapabilitySupport?
  compact_20260112 : CapabilitySupport?
  supported : Bool
}

///|
pub extend ContextManagementCapability with Eq::{equal, not_equal}

///|
pub extend ContextManagementCapability with @debug.Debug::{to_repr}

///|
///
/// Creates a ContextManagementCapability with omitted optional fields absent.
pub fn ContextManagementCapability::new(
  supported~ : Bool,
  clear_thinking_20251015? : CapabilitySupport,
  clear_tool_uses_20250919? : CapabilitySupport,
  compact_20260112? : CapabilitySupport,
) -> ContextManagementCapability {
  {
    clear_thinking_20251015,
    clear_tool_uses_20250919,
    compact_20260112,
    supported,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ContextManagementCapability with ToJson::{to_json}

///|
pub impl ToJson for ContextManagementCapability with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence(
    "clear_thinking_20251015",
    nullable_presence(self.clear_thinking_20251015.map(value => value)),
  )
  .presence(
    "clear_tool_uses_20250919",
    nullable_presence(self.clear_tool_uses_20250919.map(value => value)),
  )
  .presence(
    "compact_20260112",
    nullable_presence(self.compact_20260112.map(value => value)),
  )
  .field("supported", self.supported)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ContextManagementCapability with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ContextManagementCapability with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    clear_thinking_20251015: decode_nullable_field(
      obj, "clear_thinking_20251015", path,
    ),
    clear_tool_uses_20250919: decode_nullable_field(
      obj, "clear_tool_uses_20250919", path,
    ),
    compact_20260112: decode_nullable_field(obj, "compact_20260112", path),
    supported: required_field(obj, "supported", path),
  }
}

///|
///
/// The organization has reached the spend limit of its contract.
#derive(Eq, @debug.Debug)
pub(all) struct ContractSpendLimitReachedErrorDetails {}

///|
pub extend ContractSpendLimitReachedErrorDetails with Eq::{equal, not_equal}

///|
pub extend ContractSpendLimitReachedErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend ContractSpendLimitReachedErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ContractSpendLimitReachedErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "contract_spend_limit_reached")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ContractSpendLimitReachedErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ContractSpendLimitReachedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ContractSpendLimitReachedErrorDetails::{ }
}

///|
///
/// Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CountMessageTokensParamsCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend CountMessageTokensParamsCacheControl with Eq::{equal, not_equal}

///|
pub extend CountMessageTokensParamsCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CountMessageTokensParamsCacheControl with ToJson::{to_json}

///|
pub impl ToJson for CountMessageTokensParamsCacheControl with fn to_json(self) {
  match self {
    CountMessageTokensParamsCacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CountMessageTokensParamsCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CountMessageTokensParamsCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      CountMessageTokensParamsCacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => CountMessageTokensParamsCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated tagged union SystemInputMessageContentValueArrayItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SystemInputMessageContentValueArrayItem {
  Text(RequestTextBlock)
  Unknown(String, Json)
}

///|
pub extend SystemInputMessageContentValueArrayItem with Eq::{equal, not_equal}

///|
pub extend SystemInputMessageContentValueArrayItem with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend SystemInputMessageContentValueArrayItem with ToJson::{to_json}

///|
pub impl ToJson for SystemInputMessageContentValueArrayItem with fn to_json(
  self,
) {
  match self {
    SystemInputMessageContentValueArrayItem::Text(value) =>
      @json.Json::Json(value)
    SystemInputMessageContentValueArrayItem::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend SystemInputMessageContentValueArrayItem with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for SystemInputMessageContentValueArrayItem with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "text" =>
      SystemInputMessageContentValueArrayItem::Text(
        @json.from_json(value, path~),
      )
    other => SystemInputMessageContentValueArrayItem::Unknown(other, value)
  }
}

///|
///
/// Generated untagged union SystemInputMessageContent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SystemInputMessageContent {
  Text(String)
  ValueArray(Array[SystemInputMessageContentValueArrayItem])
}

///|
pub extend SystemInputMessageContent with Eq::{equal, not_equal}

///|
pub extend SystemInputMessageContent with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend SystemInputMessageContent with ToJson::{to_json}

///|
pub impl ToJson for SystemInputMessageContent with fn to_json(self) {
  match self {
    SystemInputMessageContent::Text(value) => @json.Json::Json(value)
    SystemInputMessageContent::ValueArray(value) => @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend SystemInputMessageContent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for SystemInputMessageContent with fn from_json(
  value,
  path,
) {
  if value is @json.Json::String(_) {
    let decoded : String = @json.from_json(value, path~)
    return SystemInputMessageContent::Text(decoded)
  }
  if json_array_matches(value, item => item is @json.Json::Object(_)) {
    let decoded : Array[SystemInputMessageContentValueArrayItem] = @json.from_json(
      value,
      path~,
    )
    return SystemInputMessageContent::ValueArray(decoded)
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (path, "JSON shape does not match any SystemInputMessageContent variant"),
  )
}

///|
///
/// Generated representation of SystemInputMessage.
#derive(Eq, @debug.Debug)
pub(all) struct SystemInputMessage {
  content : SystemInputMessageContent
  role : String
}

///|
pub extend SystemInputMessage with Eq::{equal, not_equal}

///|
pub extend SystemInputMessage with @debug.Debug::{to_repr}

///|
///
/// Creates a SystemInputMessage with omitted optional fields absent.
pub fn SystemInputMessage::new(
  content~ : SystemInputMessageContent,
  role~ : String,
) -> SystemInputMessage {
  { content, role, }
}

///|
///
/// Encodes this value as JSON.
pub extend SystemInputMessage with ToJson::{to_json}

///|
pub impl ToJson for SystemInputMessage with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("role", self.role)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend SystemInputMessage with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for SystemInputMessage with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    role: required_field(obj, "role", path),
  }
}

///|
///
/// Generated representation of UserInputMessage.
#derive(Eq, @debug.Debug)
pub(all) struct UserInputMessage {
  content : InputMessageContent
  role : String
}

///|
pub extend UserInputMessage with Eq::{equal, not_equal}

///|
pub extend UserInputMessage with @debug.Debug::{to_repr}

///|
///
/// Creates a UserInputMessage with omitted optional fields absent.
pub fn UserInputMessage::new(
  content~ : InputMessageContent,
  role~ : String,
) -> UserInputMessage {
  { content, role, }
}

///|
///
/// Encodes this value as JSON.
pub extend UserInputMessage with ToJson::{to_json}

///|
pub impl ToJson for UserInputMessage with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("content", self.content)
  .field("role", self.role)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend UserInputMessage with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for UserInputMessage with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    content: required_field(obj, "content", path),
    role: required_field(obj, "role", path),
  }
}

///|
///
/// Generated tagged union InputMessageUnion.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum InputMessageUnion {
  Assistant(AssistantInputMessage)
  System(SystemInputMessage)
  User(UserInputMessage)
  Unknown(String, Json)
}

///|
pub extend InputMessageUnion with Eq::{equal, not_equal}

///|
pub extend InputMessageUnion with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend InputMessageUnion with ToJson::{to_json}

///|
pub impl ToJson for InputMessageUnion with fn to_json(self) {
  match self {
    InputMessageUnion::Assistant(value) => @json.Json::Json(value)
    InputMessageUnion::System(value) => @json.Json::Json(value)
    InputMessageUnion::User(value) => @json.Json::Json(value)
    InputMessageUnion::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend InputMessageUnion with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for InputMessageUnion with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "role", path)
  match tag {
    "assistant" => InputMessageUnion::Assistant(@json.from_json(value, path~))
    "system" => InputMessageUnion::System(@json.from_json(value, path~))
    "user" => InputMessageUnion::User(@json.from_json(value, path~))
    other => InputMessageUnion::Unknown(other, value)
  }
}

///|
///
/// All possible effort levels.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum EffortLevel {
  Low
  Medium
  High
  Xhigh
  Max
  Custom(String)
}

///|
pub extend EffortLevel with Eq::{equal, not_equal}

///|
pub extend EffortLevel with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend EffortLevel with ToJson::{to_json}

///|
pub impl ToJson for EffortLevel with fn to_json(self) {
  let raw = match self {
    EffortLevel::Low => "low"
    EffortLevel::Medium => "medium"
    EffortLevel::High => "high"
    EffortLevel::Xhigh => "xhigh"
    EffortLevel::Max => "max"
    EffortLevel::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend EffortLevel with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for EffortLevel with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "low" => Option::Some(EffortLevel::Low)
        "medium" => Option::Some(EffortLevel::Medium)
        "high" => Option::Some(EffortLevel::High)
        "xhigh" => Option::Some(EffortLevel::Xhigh)
        "max" => Option::Some(EffortLevel::Max)
        _ => Option::None
      }
    },
    raw => EffortLevel::Custom(raw),
  )
}

///|
///
/// Generated representation of JsonOutputFormat.
#derive(Eq, @debug.Debug)
pub(all) struct JsonOutputFormat {
  schema : Json
}

///|
pub extend JsonOutputFormat with Eq::{equal, not_equal}

///|
pub extend JsonOutputFormat with @debug.Debug::{to_repr}

///|
///
/// Creates a JsonOutputFormat with omitted optional fields absent.
pub fn JsonOutputFormat::new(schema~ : Json) -> JsonOutputFormat {
  { schema, }
}

///|
///
/// Encodes this value as JSON.
pub extend JsonOutputFormat with ToJson::{to_json}

///|
pub impl ToJson for JsonOutputFormat with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("schema", self.schema)
  .field("type", "json_schema")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend JsonOutputFormat with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for JsonOutputFormat with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { schema: required_field(obj, "schema", path), }
}

///|
///
/// Generated representation of OutputConfig.
#derive(Eq, @debug.Debug)
pub(all) struct OutputConfig {
  effort : @sdkjson.Presence[EffortLevel]
  format : @sdkjson.Presence[JsonOutputFormat]
}

///|
pub extend OutputConfig with Eq::{equal, not_equal}

///|
pub extend OutputConfig with @debug.Debug::{to_repr}

///|
///
/// Creates a OutputConfig with omitted optional fields absent.
pub fn OutputConfig::new(
  effort? : EffortLevel,
  format? : JsonOutputFormat,
) -> OutputConfig {
  {
    effort: @sdkjson.Presence::from_option(effort),
    format: @sdkjson.Presence::from_option(format),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend OutputConfig with ToJson::{to_json}

///|
pub impl ToJson for OutputConfig with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("effort", self.effort)
  .presence("format", self.format)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend OutputConfig with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for OutputConfig with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    effort: @sdkjson.presence_field(obj, "effort", path),
    format: @sdkjson.presence_field(obj, "format", path),
  }
}

///|
///
/// Generated string enum Speed.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum Speed {
  Standard
  Fast
  Unknown(String)
}

///|
pub extend Speed with Eq::{equal, not_equal}

///|
pub extend Speed with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend Speed with ToJson::{to_json}

///|
pub impl ToJson for Speed with fn to_json(self) {
  let raw = match self {
    Speed::Standard => "standard"
    Speed::Fast => "fast"
    Speed::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend Speed with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Speed with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "standard" => Option::Some(Speed::Standard)
        "fast" => Option::Some(Speed::Fast)
        _ => Option::None
      }
    },
    raw => Speed::Unknown(raw),
  )
}

///|
///
/// System prompt. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CountMessageTokensParamsSystem {
  Text(String)
  RequestTextBlockArray(Array[RequestTextBlock])
}

///|
pub extend CountMessageTokensParamsSystem with Eq::{equal, not_equal}

///|
pub extend CountMessageTokensParamsSystem with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend CountMessageTokensParamsSystem with ToJson::{to_json}

///|
pub impl ToJson for CountMessageTokensParamsSystem with fn to_json(self) {
  match self {
    CountMessageTokensParamsSystem::Text(value) => @json.Json::Json(value)
    CountMessageTokensParamsSystem::RequestTextBlockArray(value) =>
      @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend CountMessageTokensParamsSystem with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CountMessageTokensParamsSystem with fn from_json(
  value,
  path,
) {
  if value is @json.Json::String(_) {
    let decoded : String = @json.from_json(value, path~)
    return CountMessageTokensParamsSystem::Text(decoded)
  }
  if json_array_matches(value, item => item is @json.Json::Object(_)) {
    let decoded : Array[RequestTextBlock] = @json.from_json(value, path~)
    return CountMessageTokensParamsSystem::RequestTextBlockArray(decoded)
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (
      path, "JSON shape does not match any CountMessageTokensParamsSystem variant",
    ),
  )
}

///|
///
/// Generated string enum ThinkingDisplayMode.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ThinkingDisplayMode {
  Summarized
  Omitted
  Custom(String)
}

///|
pub extend ThinkingDisplayMode with Eq::{equal, not_equal}

///|
pub extend ThinkingDisplayMode with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ThinkingDisplayMode with ToJson::{to_json}

///|
pub impl ToJson for ThinkingDisplayMode with fn to_json(self) {
  let raw = match self {
    ThinkingDisplayMode::Summarized => "summarized"
    ThinkingDisplayMode::Omitted => "omitted"
    ThinkingDisplayMode::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ThinkingDisplayMode with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingDisplayMode with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "summarized" => Option::Some(ThinkingDisplayMode::Summarized)
        "omitted" => Option::Some(ThinkingDisplayMode::Omitted)
        _ => Option::None
      }
    },
    raw => ThinkingDisplayMode::Custom(raw),
  )
}

///|
///
/// Generated representation of ThinkingConfigAdaptive.
#derive(Eq, @debug.Debug)
pub(all) struct ThinkingConfigAdaptive {
  display : @sdkjson.Presence[ThinkingDisplayMode]
  type_ : String
}

///|
pub extend ThinkingConfigAdaptive with Eq::{equal, not_equal}

///|
pub extend ThinkingConfigAdaptive with @debug.Debug::{to_repr}

///|
///
/// Creates a ThinkingConfigAdaptive with omitted optional fields absent.
pub fn ThinkingConfigAdaptive::new(
  type_~ : String,
  display? : ThinkingDisplayMode,
) -> ThinkingConfigAdaptive {
  { display: @sdkjson.Presence::from_option(display), type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ThinkingConfigAdaptive with ToJson::{to_json}

///|
pub impl ToJson for ThinkingConfigAdaptive with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("display", self.display)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThinkingConfigAdaptive with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingConfigAdaptive with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    display: @sdkjson.presence_field(obj, "display", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of ThinkingConfigBetweenTools.
#derive(Eq, @debug.Debug)
pub(all) struct ThinkingConfigBetweenTools {
  type_ : String
}

///|
pub extend ThinkingConfigBetweenTools with Eq::{equal, not_equal}

///|
pub extend ThinkingConfigBetweenTools with @debug.Debug::{to_repr}

///|
///
/// Creates a ThinkingConfigBetweenTools with omitted optional fields absent.
pub fn ThinkingConfigBetweenTools::new(
  type_~ : String,
) -> ThinkingConfigBetweenTools {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ThinkingConfigBetweenTools with ToJson::{to_json}

///|
pub impl ToJson for ThinkingConfigBetweenTools with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThinkingConfigBetweenTools with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingConfigBetweenTools with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// Generated representation of ThinkingConfigDisabled.
#derive(Eq, @debug.Debug)
pub(all) struct ThinkingConfigDisabled {
  type_ : String
}

///|
pub extend ThinkingConfigDisabled with Eq::{equal, not_equal}

///|
pub extend ThinkingConfigDisabled with @debug.Debug::{to_repr}

///|
///
/// Creates a ThinkingConfigDisabled with omitted optional fields absent.
pub fn ThinkingConfigDisabled::new(type_~ : String) -> ThinkingConfigDisabled {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ThinkingConfigDisabled with ToJson::{to_json}

///|
pub impl ToJson for ThinkingConfigDisabled with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThinkingConfigDisabled with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingConfigDisabled with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// Generated representation of ThinkingConfigEnabled.
#derive(Eq, @debug.Debug)
pub(all) struct ThinkingConfigEnabled {
  budget_tokens : Int32
  display : @sdkjson.Presence[ThinkingDisplayMode]
  type_ : String
}

///|
pub extend ThinkingConfigEnabled with Eq::{equal, not_equal}

///|
pub extend ThinkingConfigEnabled with @debug.Debug::{to_repr}

///|
///
/// Creates a ThinkingConfigEnabled with omitted optional fields absent.
pub fn ThinkingConfigEnabled::new(
  budget_tokens~ : Int32,
  type_~ : String,
  display? : ThinkingDisplayMode,
) -> ThinkingConfigEnabled {
  { budget_tokens, display: @sdkjson.Presence::from_option(display), type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ThinkingConfigEnabled with ToJson::{to_json}

///|
pub impl ToJson for ThinkingConfigEnabled with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("budget_tokens", self.budget_tokens)
  .presence("display", self.display)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThinkingConfigEnabled with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingConfigEnabled with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    budget_tokens: required_field(obj, "budget_tokens", path),
    display: @sdkjson.presence_field(obj, "display", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Configuration for Claude's thinking. With `{"type": "adaptive"}`, Claude decides when and how much to think. With `{"type": "enabled"}` (manual extended thinking), you set a `budget_tokens` of at least 1,024. Thinking tokens count toward your `max_tokens` limit. Which `type` values are accepted, and what happens when you omit `thinking`, depend on the model. See [thinking](https://platform.claude.com/docs/en/build-with-claude/thinking#configuring-thinking) for each model's behavior.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ThinkingConfigParam {
  Adaptive(ThinkingConfigAdaptive)
  BetweenTools(ThinkingConfigBetweenTools)
  Disabled(ThinkingConfigDisabled)
  Enabled(ThinkingConfigEnabled)
  Unknown(String, Json)
}

///|
pub extend ThinkingConfigParam with Eq::{equal, not_equal}

///|
pub extend ThinkingConfigParam with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ThinkingConfigParam with ToJson::{to_json}

///|
pub impl ToJson for ThinkingConfigParam with fn to_json(self) {
  match self {
    ThinkingConfigParam::Adaptive(value) => @json.Json::Json(value)
    ThinkingConfigParam::BetweenTools(value) => @json.Json::Json(value)
    ThinkingConfigParam::Disabled(value) => @json.Json::Json(value)
    ThinkingConfigParam::Enabled(value) => @json.Json::Json(value)
    ThinkingConfigParam::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ThinkingConfigParam with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingConfigParam with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "adaptive" => ThinkingConfigParam::Adaptive(@json.from_json(value, path~))
    "between_tools" =>
      ThinkingConfigParam::BetweenTools(@json.from_json(value, path~))
    "disabled" => ThinkingConfigParam::Disabled(@json.from_json(value, path~))
    "enabled" => ThinkingConfigParam::Enabled(@json.from_json(value, path~))
    other => ThinkingConfigParam::Unknown(other, value)
  }
}

///|
///
/// The model will use any available tools.
#derive(Eq, @debug.Debug)
pub(all) struct ToolChoiceAny {
  disable_parallel_tool_use : Bool?
  type_ : String
}

///|
pub extend ToolChoiceAny with Eq::{equal, not_equal}

///|
pub extend ToolChoiceAny with @debug.Debug::{to_repr}

///|
///
/// Creates a ToolChoiceAny with omitted optional fields absent.
pub fn ToolChoiceAny::new(
  type_~ : String,
  disable_parallel_tool_use? : Bool,
) -> ToolChoiceAny {
  { disable_parallel_tool_use, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ToolChoiceAny with ToJson::{to_json}

///|
pub impl ToJson for ToolChoiceAny with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("disable_parallel_tool_use", self.disable_parallel_tool_use)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ToolChoiceAny with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolChoiceAny with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    disable_parallel_tool_use: @sdkjson.opt_field(
      obj, "disable_parallel_tool_use", path,
    ),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// The model will automatically decide whether to use tools.
#derive(Eq, @debug.Debug)
pub(all) struct ToolChoiceAuto {
  disable_parallel_tool_use : Bool?
  type_ : String
}

///|
pub extend ToolChoiceAuto with Eq::{equal, not_equal}

///|
pub extend ToolChoiceAuto with @debug.Debug::{to_repr}

///|
///
/// Creates a ToolChoiceAuto with omitted optional fields absent.
pub fn ToolChoiceAuto::new(
  type_~ : String,
  disable_parallel_tool_use? : Bool,
) -> ToolChoiceAuto {
  { disable_parallel_tool_use, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ToolChoiceAuto with ToJson::{to_json}

///|
pub impl ToJson for ToolChoiceAuto with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("disable_parallel_tool_use", self.disable_parallel_tool_use)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ToolChoiceAuto with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolChoiceAuto with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    disable_parallel_tool_use: @sdkjson.opt_field(
      obj, "disable_parallel_tool_use", path,
    ),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// The model will not be allowed to use tools.
#derive(Eq, @debug.Debug)
pub(all) struct ToolChoiceNone {
  type_ : String
}

///|
pub extend ToolChoiceNone with Eq::{equal, not_equal}

///|
pub extend ToolChoiceNone with @debug.Debug::{to_repr}

///|
///
/// Creates a ToolChoiceNone with omitted optional fields absent.
pub fn ToolChoiceNone::new(type_~ : String) -> ToolChoiceNone {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ToolChoiceNone with ToJson::{to_json}

///|
pub impl ToJson for ToolChoiceNone with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend ToolChoiceNone with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolChoiceNone with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// The model will use the specified tool with `tool_choice.name`.
#derive(Eq, @debug.Debug)
pub(all) struct ToolChoiceTool {
  disable_parallel_tool_use : Bool?
  name : String
  type_ : String
}

///|
pub extend ToolChoiceTool with Eq::{equal, not_equal}

///|
pub extend ToolChoiceTool with @debug.Debug::{to_repr}

///|
///
/// Creates a ToolChoiceTool with omitted optional fields absent.
pub fn ToolChoiceTool::new(
  name~ : String,
  type_~ : String,
  disable_parallel_tool_use? : Bool,
) -> ToolChoiceTool {
  { disable_parallel_tool_use, name, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend ToolChoiceTool with ToJson::{to_json}

///|
pub impl ToJson for ToolChoiceTool with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("disable_parallel_tool_use", self.disable_parallel_tool_use)
  .field("name", self.name)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ToolChoiceTool with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolChoiceTool with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    disable_parallel_tool_use: @sdkjson.opt_field(
      obj, "disable_parallel_tool_use", path,
    ),
    name: required_field(obj, "name", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolChoice {
  Any(ToolChoiceAny)
  Auto(ToolChoiceAuto)
  None(ToolChoiceNone)
  Tool(ToolChoiceTool)
  Unknown(String, Json)
}

///|
pub extend ToolChoice with Eq::{equal, not_equal}

///|
pub extend ToolChoice with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ToolChoice with ToJson::{to_json}

///|
pub impl ToJson for ToolChoice with fn to_json(self) {
  match self {
    ToolChoice::Any(value) => @json.Json::Json(value)
    ToolChoice::Auto(value) => @json.Json::Json(value)
    ToolChoice::None(value) => @json.Json::Json(value)
    ToolChoice::Tool(value) => @json.Json::Json(value)
    ToolChoice::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ToolChoice with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolChoice with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "any" => ToolChoice::Any(@json.from_json(value, path~))
    "auto" => ToolChoice::Auto(@json.from_json(value, path~))
    "none" => ToolChoice::None(@json.from_json(value, path~))
    "tool" => ToolChoice::Tool(@json.from_json(value, path~))
    other => ToolChoice::Unknown(other, value)
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend ToolCacheControl with Eq::{equal, not_equal}

///|
pub extend ToolCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ToolCacheControl with ToJson::{to_json}

///|
pub impl ToJson for ToolCacheControl with fn to_json(self) {
  match self {
    ToolCacheControl::Ephemeral(value) => @json.Json::Json(value)
    ToolCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ToolCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolCacheControl with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" => ToolCacheControl::Ephemeral(@json.from_json(value, path~))
    other => ToolCacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of Tool.
#derive(Eq, @debug.Debug)
pub(all) struct Tool {
  type_ : @sdkjson.Presence[String]
  description : String?
  name : String
  input_schema : Json
  cache_control : @sdkjson.Presence[ToolCacheControl]
  strict : Bool?
  eager_input_streaming : @sdkjson.Presence[Bool]
  allowed_callers : Array[AllowedCaller]?
  defer_loading : Bool?
  input_examples : Array[Map[String, Json]]?
}

///|
pub extend Tool with Eq::{equal, not_equal}

///|
pub extend Tool with @debug.Debug::{to_repr}

///|
///
/// Creates a Tool with omitted optional fields absent.
pub fn Tool::new(
  name~ : String,
  input_schema~ : Json,
  type_? : String,
  description? : String,
  cache_control? : ToolCacheControl,
  strict? : Bool,
  eager_input_streaming? : Bool,
  allowed_callers? : Array[AllowedCaller],
  defer_loading? : Bool,
  input_examples? : Array[Map[String, Json]],
) -> Tool {
  {
    type_: @sdkjson.Presence::from_option(type_),
    description,
    name,
    input_schema,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    strict,
    eager_input_streaming: @sdkjson.Presence::from_option(eager_input_streaming),
    allowed_callers,
    defer_loading,
    input_examples,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend Tool with ToJson::{to_json}

///|
pub impl ToJson for Tool with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("type", self.type_)
  .opt("description", self.description)
  .field("name", self.name)
  .field("input_schema", self.input_schema)
  .presence("cache_control", self.cache_control)
  .opt("strict", self.strict)
  .presence("eager_input_streaming", self.eager_input_streaming)
  .opt("allowed_callers", self.allowed_callers)
  .opt("defer_loading", self.defer_loading)
  .opt("input_examples", self.input_examples)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend Tool with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Tool with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    type_: @sdkjson.presence_field(obj, "type", path),
    description: @sdkjson.opt_field(obj, "description", path),
    name: required_field(obj, "name", path),
    input_schema: required_field(obj, "input_schema", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    eager_input_streaming: @sdkjson.presence_field(
      obj, "eager_input_streaming", path,
    ),
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    input_examples: @sdkjson.opt_field(obj, "input_examples", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum MemoryTool20250818CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend MemoryTool20250818CacheControl with Eq::{equal, not_equal}

///|
pub extend MemoryTool20250818CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend MemoryTool20250818CacheControl with ToJson::{to_json}

///|
pub impl ToJson for MemoryTool20250818CacheControl with fn to_json(self) {
  match self {
    MemoryTool20250818CacheControl::Ephemeral(value) => @json.Json::Json(value)
    MemoryTool20250818CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend MemoryTool20250818CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for MemoryTool20250818CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      MemoryTool20250818CacheControl::Ephemeral(@json.from_json(value, path~))
    other => MemoryTool20250818CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of MemoryTool20250818.
#derive(Eq, @debug.Debug)
pub(all) struct MemoryTool20250818 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[MemoryTool20250818CacheControl]
  defer_loading : Bool?
  input_examples : Array[Map[String, Json]]?
  strict : Bool?
  type_ : String
}

///|
pub extend MemoryTool20250818 with Eq::{equal, not_equal}

///|
pub extend MemoryTool20250818 with @debug.Debug::{to_repr}

///|
///
/// Creates a MemoryTool20250818 with omitted optional fields absent.
pub fn MemoryTool20250818::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : MemoryTool20250818CacheControl,
  defer_loading? : Bool,
  input_examples? : Array[Map[String, Json]],
  strict? : Bool,
) -> MemoryTool20250818 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    input_examples,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend MemoryTool20250818 with ToJson::{to_json}

///|
pub impl ToJson for MemoryTool20250818 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .opt("input_examples", self.input_examples)
  .field("name", "memory")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend MemoryTool20250818 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for MemoryTool20250818 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    input_examples: @sdkjson.opt_field(obj, "input_examples", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum TextEditor20250124CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend TextEditor20250124CacheControl with Eq::{equal, not_equal}

///|
pub extend TextEditor20250124CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend TextEditor20250124CacheControl with ToJson::{to_json}

///|
pub impl ToJson for TextEditor20250124CacheControl with fn to_json(self) {
  match self {
    TextEditor20250124CacheControl::Ephemeral(value) => @json.Json::Json(value)
    TextEditor20250124CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend TextEditor20250124CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for TextEditor20250124CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      TextEditor20250124CacheControl::Ephemeral(@json.from_json(value, path~))
    other => TextEditor20250124CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of TextEditor20250124.
#derive(Eq, @debug.Debug)
pub(all) struct TextEditor20250124 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[TextEditor20250124CacheControl]
  defer_loading : Bool?
  input_examples : Array[Map[String, Json]]?
  strict : Bool?
  type_ : String
}

///|
pub extend TextEditor20250124 with Eq::{equal, not_equal}

///|
pub extend TextEditor20250124 with @debug.Debug::{to_repr}

///|
///
/// Creates a TextEditor20250124 with omitted optional fields absent.
pub fn TextEditor20250124::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : TextEditor20250124CacheControl,
  defer_loading? : Bool,
  input_examples? : Array[Map[String, Json]],
  strict? : Bool,
) -> TextEditor20250124 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    input_examples,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend TextEditor20250124 with ToJson::{to_json}

///|
pub impl ToJson for TextEditor20250124 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .opt("input_examples", self.input_examples)
  .field("name", "str_replace_editor")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend TextEditor20250124 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for TextEditor20250124 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    input_examples: @sdkjson.opt_field(obj, "input_examples", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum TextEditor20250429CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend TextEditor20250429CacheControl with Eq::{equal, not_equal}

///|
pub extend TextEditor20250429CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend TextEditor20250429CacheControl with ToJson::{to_json}

///|
pub impl ToJson for TextEditor20250429CacheControl with fn to_json(self) {
  match self {
    TextEditor20250429CacheControl::Ephemeral(value) => @json.Json::Json(value)
    TextEditor20250429CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend TextEditor20250429CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for TextEditor20250429CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      TextEditor20250429CacheControl::Ephemeral(@json.from_json(value, path~))
    other => TextEditor20250429CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of TextEditor20250429.
#derive(Eq, @debug.Debug)
pub(all) struct TextEditor20250429 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[TextEditor20250429CacheControl]
  defer_loading : Bool?
  input_examples : Array[Map[String, Json]]?
  strict : Bool?
  type_ : String
}

///|
pub extend TextEditor20250429 with Eq::{equal, not_equal}

///|
pub extend TextEditor20250429 with @debug.Debug::{to_repr}

///|
///
/// Creates a TextEditor20250429 with omitted optional fields absent.
pub fn TextEditor20250429::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : TextEditor20250429CacheControl,
  defer_loading? : Bool,
  input_examples? : Array[Map[String, Json]],
  strict? : Bool,
) -> TextEditor20250429 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    input_examples,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend TextEditor20250429 with ToJson::{to_json}

///|
pub impl ToJson for TextEditor20250429 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .opt("input_examples", self.input_examples)
  .field("name", "str_replace_based_edit_tool")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend TextEditor20250429 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for TextEditor20250429 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    input_examples: @sdkjson.opt_field(obj, "input_examples", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum TextEditor20250728CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend TextEditor20250728CacheControl with Eq::{equal, not_equal}

///|
pub extend TextEditor20250728CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend TextEditor20250728CacheControl with ToJson::{to_json}

///|
pub impl ToJson for TextEditor20250728CacheControl with fn to_json(self) {
  match self {
    TextEditor20250728CacheControl::Ephemeral(value) => @json.Json::Json(value)
    TextEditor20250728CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend TextEditor20250728CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for TextEditor20250728CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      TextEditor20250728CacheControl::Ephemeral(@json.from_json(value, path~))
    other => TextEditor20250728CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of TextEditor20250728.
#derive(Eq, @debug.Debug)
pub(all) struct TextEditor20250728 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[TextEditor20250728CacheControl]
  defer_loading : Bool?
  input_examples : Array[Map[String, Json]]?
  max_characters : @sdkjson.Presence[Int32]
  strict : Bool?
  type_ : String
}

///|
pub extend TextEditor20250728 with Eq::{equal, not_equal}

///|
pub extend TextEditor20250728 with @debug.Debug::{to_repr}

///|
///
/// Creates a TextEditor20250728 with omitted optional fields absent.
pub fn TextEditor20250728::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : TextEditor20250728CacheControl,
  defer_loading? : Bool,
  input_examples? : Array[Map[String, Json]],
  max_characters? : Int32,
  strict? : Bool,
) -> TextEditor20250728 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    input_examples,
    max_characters: @sdkjson.Presence::from_option(max_characters),
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend TextEditor20250728 with ToJson::{to_json}

///|
pub impl ToJson for TextEditor20250728 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .opt("input_examples", self.input_examples)
  .presence("max_characters", self.max_characters)
  .field("name", "str_replace_based_edit_tool")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend TextEditor20250728 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for TextEditor20250728 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    input_examples: @sdkjson.opt_field(obj, "input_examples", path),
    max_characters: @sdkjson.presence_field(obj, "max_characters", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebSearchTool20250305CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend WebSearchTool20250305CacheControl with Eq::{equal, not_equal}

///|
pub extend WebSearchTool20250305CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebSearchTool20250305CacheControl with ToJson::{to_json}

///|
pub impl ToJson for WebSearchTool20250305CacheControl with fn to_json(self) {
  match self {
    WebSearchTool20250305CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    WebSearchTool20250305CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebSearchTool20250305CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebSearchTool20250305CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      WebSearchTool20250305CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => WebSearchTool20250305CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of UserLocation.
#derive(Eq, @debug.Debug)
pub(all) struct UserLocation {
  city : @sdkjson.Presence[String]
  country : @sdkjson.Presence[String]
  region : @sdkjson.Presence[String]
  timezone : @sdkjson.Presence[String]
}

///|
pub extend UserLocation with Eq::{equal, not_equal}

///|
pub extend UserLocation with @debug.Debug::{to_repr}

///|
///
/// Creates a UserLocation with omitted optional fields absent.
pub fn UserLocation::new(
  city? : String,
  country? : String,
  region? : String,
  timezone? : String,
) -> UserLocation {
  {
    city: @sdkjson.Presence::from_option(city),
    country: @sdkjson.Presence::from_option(country),
    region: @sdkjson.Presence::from_option(region),
    timezone: @sdkjson.Presence::from_option(timezone),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend UserLocation with ToJson::{to_json}

///|
pub impl ToJson for UserLocation with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("city", self.city)
  .presence("country", self.country)
  .presence("region", self.region)
  .presence("timezone", self.timezone)
  .field("type", "approximate")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend UserLocation with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for UserLocation with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    city: @sdkjson.presence_field(obj, "city", path),
    country: @sdkjson.presence_field(obj, "country", path),
    region: @sdkjson.presence_field(obj, "region", path),
    timezone: @sdkjson.presence_field(obj, "timezone", path),
  }
}

///|
///
/// Generated representation of WebSearchTool20250305.
#derive(Eq, @debug.Debug)
pub(all) struct WebSearchTool20250305 {
  allowed_callers : Array[AllowedCaller]?
  allowed_domains : @sdkjson.Presence[Array[String]]
  blocked_domains : @sdkjson.Presence[Array[String]]
  cache_control : @sdkjson.Presence[WebSearchTool20250305CacheControl]
  defer_loading : Bool?
  max_uses : @sdkjson.Presence[Int32]
  strict : Bool?
  type_ : String
  user_location : @sdkjson.Presence[UserLocation]
}

///|
pub extend WebSearchTool20250305 with Eq::{equal, not_equal}

///|
pub extend WebSearchTool20250305 with @debug.Debug::{to_repr}

///|
///
/// Creates a WebSearchTool20250305 with omitted optional fields absent.
pub fn WebSearchTool20250305::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  allowed_domains? : Array[String],
  blocked_domains? : Array[String],
  cache_control? : WebSearchTool20250305CacheControl,
  defer_loading? : Bool,
  max_uses? : Int32,
  strict? : Bool,
  user_location? : UserLocation,
) -> WebSearchTool20250305 {
  {
    allowed_callers,
    allowed_domains: @sdkjson.Presence::from_option(allowed_domains),
    blocked_domains: @sdkjson.Presence::from_option(blocked_domains),
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    max_uses: @sdkjson.Presence::from_option(max_uses),
    strict,
    type_,
    user_location: @sdkjson.Presence::from_option(user_location),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend WebSearchTool20250305 with ToJson::{to_json}

///|
pub impl ToJson for WebSearchTool20250305 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("allowed_domains", self.allowed_domains)
  .presence("blocked_domains", self.blocked_domains)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .presence("max_uses", self.max_uses)
  .field("name", "web_search")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .presence("user_location", self.user_location)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebSearchTool20250305 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebSearchTool20250305 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    allowed_domains: @sdkjson.presence_field(obj, "allowed_domains", path),
    blocked_domains: @sdkjson.presence_field(obj, "blocked_domains", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    max_uses: @sdkjson.presence_field(obj, "max_uses", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
    user_location: @sdkjson.presence_field(obj, "user_location", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchTool20250910CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend WebFetchTool20250910CacheControl with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20250910CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebFetchTool20250910CacheControl with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20250910CacheControl with fn to_json(self) {
  match self {
    WebFetchTool20250910CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    WebFetchTool20250910CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebFetchTool20250910CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchTool20250910CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      WebFetchTool20250910CacheControl::Ephemeral(@json.from_json(value, path~))
    other => WebFetchTool20250910CacheControl::Unknown(other, value)
  }
}

///|
///
/// The ``url_sources`` variant under which a source contributes in full: every result of the tool filter's source, or all user input.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchUrlSourceAll {
  type_ : String
}

///|
pub extend WebFetchUrlSourceAll with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSourceAll with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchUrlSourceAll with omitted optional fields absent.
pub fn WebFetchUrlSourceAll::new(type_~ : String) -> WebFetchUrlSourceAll {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchUrlSourceAll with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSourceAll with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchUrlSourceAll with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSourceAll with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// One entry of a tool filter's ``tools``: it must name a tool declared in this request's ``tools[]``.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchUrlSourceToolReference {
  name : String
}

///|
pub extend WebFetchUrlSourceToolReference with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSourceToolReference with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchUrlSourceToolReference with omitted optional fields absent.
pub fn WebFetchUrlSourceToolReference::new(
  name~ : String,
) -> WebFetchUrlSourceToolReference {
  { name, }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchUrlSourceToolReference with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSourceToolReference with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("name", self.name)
  .field("type", "tool_reference")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchUrlSourceToolReference with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSourceToolReference with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { name: required_field(obj, "name", path), }
}

///|
///
/// The tool filter variant under which every result but the named tools' contributes.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchUrlSourceExcept {
  tools : Array[WebFetchUrlSourceToolReference]
  type_ : String
}

///|
pub extend WebFetchUrlSourceExcept with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSourceExcept with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchUrlSourceExcept with omitted optional fields absent.
pub fn WebFetchUrlSourceExcept::new(
  tools~ : Array[WebFetchUrlSourceToolReference],
  type_~ : String,
) -> WebFetchUrlSourceExcept {
  { tools, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchUrlSourceExcept with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSourceExcept with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("tools", self.tools)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchUrlSourceExcept with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSourceExcept with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    tools: required_field(obj, "tools", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// The ``url_sources`` variant under which a source contributes nothing: no result of the tool filter's source, or no user input.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchUrlSourceNone {
  type_ : String
}

///|
pub extend WebFetchUrlSourceNone with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSourceNone with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchUrlSourceNone with omitted optional fields absent.
pub fn WebFetchUrlSourceNone::new(type_~ : String) -> WebFetchUrlSourceNone {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchUrlSourceNone with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSourceNone with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchUrlSourceNone with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSourceNone with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// The tool filter variant under which only the named tools' results contribute.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchUrlSourceOnly {
  tools : Array[WebFetchUrlSourceToolReference]
  type_ : String
}

///|
pub extend WebFetchUrlSourceOnly with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSourceOnly with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchUrlSourceOnly with omitted optional fields absent.
pub fn WebFetchUrlSourceOnly::new(
  tools~ : Array[WebFetchUrlSourceToolReference],
  type_~ : String,
) -> WebFetchUrlSourceOnly {
  { tools, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchUrlSourceOnly with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSourceOnly with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("tools", self.tools)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchUrlSourceOnly with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSourceOnly with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    tools: required_field(obj, "tools", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Which client tools' results contribute fetchable URLs: "all", "none", or an only or except list of client tool names from tools[].
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchUrlSourcesClientToolResults {
  All(WebFetchUrlSourceAll)
  Except(WebFetchUrlSourceExcept)
  None(WebFetchUrlSourceNone)
  Only(WebFetchUrlSourceOnly)
  Unknown(String, Json)
}

///|
pub extend WebFetchUrlSourcesClientToolResults with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSourcesClientToolResults with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebFetchUrlSourcesClientToolResults with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSourcesClientToolResults with fn to_json(self) {
  match self {
    WebFetchUrlSourcesClientToolResults::All(value) => @json.Json::Json(value)
    WebFetchUrlSourcesClientToolResults::Except(value) =>
      @json.Json::Json(value)
    WebFetchUrlSourcesClientToolResults::None(value) => @json.Json::Json(value)
    WebFetchUrlSourcesClientToolResults::Only(value) => @json.Json::Json(value)
    WebFetchUrlSourcesClientToolResults::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebFetchUrlSourcesClientToolResults with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSourcesClientToolResults with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "all" =>
      WebFetchUrlSourcesClientToolResults::All(@json.from_json(value, path~))
    "except" =>
      WebFetchUrlSourcesClientToolResults::Except(@json.from_json(value, path~))
    "none" =>
      WebFetchUrlSourcesClientToolResults::None(@json.from_json(value, path~))
    "only" =>
      WebFetchUrlSourcesClientToolResults::Only(@json.from_json(value, path~))
    other => WebFetchUrlSourcesClientToolResults::Unknown(other, value)
  }
}

///|
///
/// Which server tools' results contribute fetchable URLs: "all", "none", or an only or except list of server tool names from tools[]; only web_search and web_fetch results ever contribute.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchUrlSourcesServerToolResults {
  All(WebFetchUrlSourceAll)
  Except(WebFetchUrlSourceExcept)
  None(WebFetchUrlSourceNone)
  Only(WebFetchUrlSourceOnly)
  Unknown(String, Json)
}

///|
pub extend WebFetchUrlSourcesServerToolResults with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSourcesServerToolResults with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebFetchUrlSourcesServerToolResults with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSourcesServerToolResults with fn to_json(self) {
  match self {
    WebFetchUrlSourcesServerToolResults::All(value) => @json.Json::Json(value)
    WebFetchUrlSourcesServerToolResults::Except(value) =>
      @json.Json::Json(value)
    WebFetchUrlSourcesServerToolResults::None(value) => @json.Json::Json(value)
    WebFetchUrlSourcesServerToolResults::Only(value) => @json.Json::Json(value)
    WebFetchUrlSourcesServerToolResults::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebFetchUrlSourcesServerToolResults with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSourcesServerToolResults with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "all" =>
      WebFetchUrlSourcesServerToolResults::All(@json.from_json(value, path~))
    "except" =>
      WebFetchUrlSourcesServerToolResults::Except(@json.from_json(value, path~))
    "none" =>
      WebFetchUrlSourcesServerToolResults::None(@json.from_json(value, path~))
    "only" =>
      WebFetchUrlSourcesServerToolResults::Only(@json.from_json(value, path~))
    other => WebFetchUrlSourcesServerToolResults::Unknown(other, value)
  }
}

///|
///
/// Whether URLs in user messages are fetchable: "all" or "none".
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchUrlSourcesUserInput {
  All(WebFetchUrlSourceAll)
  None(WebFetchUrlSourceNone)
  Unknown(String, Json)
}

///|
pub extend WebFetchUrlSourcesUserInput with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSourcesUserInput with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebFetchUrlSourcesUserInput with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSourcesUserInput with fn to_json(self) {
  match self {
    WebFetchUrlSourcesUserInput::All(value) => @json.Json::Json(value)
    WebFetchUrlSourcesUserInput::None(value) => @json.Json::Json(value)
    WebFetchUrlSourcesUserInput::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebFetchUrlSourcesUserInput with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSourcesUserInput with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "all" => WebFetchUrlSourcesUserInput::All(@json.from_json(value, path~))
    "none" => WebFetchUrlSourcesUserInput::None(@json.from_json(value, path~))
    other => WebFetchUrlSourcesUserInput::Unknown(other, value)
  }
}

///|
///
/// Which sources contribute to the set of URLs web fetch may fetch. Each key is a tagged variant: ``user_input`` is ``all`` or ``none``; the two tool filters are ``all``, ``none``, ``only`` (only the named tools' results) or ``except`` (every result but the named tools'). A named tool must be declared in this request's ``tools[]``.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchUrlSources {
  client_tool_results : WebFetchUrlSourcesClientToolResults?
  server_tool_results : WebFetchUrlSourcesServerToolResults?
  user_input : WebFetchUrlSourcesUserInput?
}

///|
pub extend WebFetchUrlSources with Eq::{equal, not_equal}

///|
pub extend WebFetchUrlSources with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchUrlSources with omitted optional fields absent.
pub fn WebFetchUrlSources::new(
  client_tool_results? : WebFetchUrlSourcesClientToolResults,
  server_tool_results? : WebFetchUrlSourcesServerToolResults,
  user_input? : WebFetchUrlSourcesUserInput,
) -> WebFetchUrlSources {
  { client_tool_results, server_tool_results, user_input, }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchUrlSources with ToJson::{to_json}

///|
pub impl ToJson for WebFetchUrlSources with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("client_tool_results", self.client_tool_results)
  .opt("server_tool_results", self.server_tool_results)
  .opt("user_input", self.user_input)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchUrlSources with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchUrlSources with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    client_tool_results: @sdkjson.opt_field(obj, "client_tool_results", path),
    server_tool_results: @sdkjson.opt_field(obj, "server_tool_results", path),
    user_input: @sdkjson.opt_field(obj, "user_input", path),
  }
}

///|
///
/// Generated representation of WebFetchTool20250910.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchTool20250910 {
  allowed_callers : Array[AllowedCaller]?
  allowed_domains : @sdkjson.Presence[Array[String]]
  blocked_domains : @sdkjson.Presence[Array[String]]
  cache_control : @sdkjson.Presence[WebFetchTool20250910CacheControl]
  citations : @sdkjson.Presence[RequestCitationsConfig]
  defer_loading : Bool?
  max_content_tokens : @sdkjson.Presence[Int32]
  max_uses : @sdkjson.Presence[Int32]
  strict : Bool?
  type_ : String
  url_sources : @sdkjson.Presence[WebFetchUrlSources]
}

///|
pub extend WebFetchTool20250910 with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20250910 with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchTool20250910 with omitted optional fields absent.
pub fn WebFetchTool20250910::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  allowed_domains? : Array[String],
  blocked_domains? : Array[String],
  cache_control? : WebFetchTool20250910CacheControl,
  citations? : RequestCitationsConfig,
  defer_loading? : Bool,
  max_content_tokens? : Int32,
  max_uses? : Int32,
  strict? : Bool,
  url_sources? : WebFetchUrlSources,
) -> WebFetchTool20250910 {
  {
    allowed_callers,
    allowed_domains: @sdkjson.Presence::from_option(allowed_domains),
    blocked_domains: @sdkjson.Presence::from_option(blocked_domains),
    cache_control: @sdkjson.Presence::from_option(cache_control),
    citations: @sdkjson.Presence::from_option(citations),
    defer_loading,
    max_content_tokens: @sdkjson.Presence::from_option(max_content_tokens),
    max_uses: @sdkjson.Presence::from_option(max_uses),
    strict,
    type_,
    url_sources: @sdkjson.Presence::from_option(url_sources),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchTool20250910 with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20250910 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("allowed_domains", self.allowed_domains)
  .presence("blocked_domains", self.blocked_domains)
  .presence("cache_control", self.cache_control)
  .presence("citations", self.citations)
  .opt("defer_loading", self.defer_loading)
  .presence("max_content_tokens", self.max_content_tokens)
  .presence("max_uses", self.max_uses)
  .field("name", "web_fetch")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .presence("url_sources", self.url_sources)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchTool20250910 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchTool20250910 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    allowed_domains: @sdkjson.presence_field(obj, "allowed_domains", path),
    blocked_domains: @sdkjson.presence_field(obj, "blocked_domains", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    citations: @sdkjson.presence_field(obj, "citations", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    max_content_tokens: @sdkjson.presence_field(obj, "max_content_tokens", path),
    max_uses: @sdkjson.presence_field(obj, "max_uses", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
    url_sources: @sdkjson.presence_field(obj, "url_sources", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebSearchTool20260209CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend WebSearchTool20260209CacheControl with Eq::{equal, not_equal}

///|
pub extend WebSearchTool20260209CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebSearchTool20260209CacheControl with ToJson::{to_json}

///|
pub impl ToJson for WebSearchTool20260209CacheControl with fn to_json(self) {
  match self {
    WebSearchTool20260209CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    WebSearchTool20260209CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebSearchTool20260209CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebSearchTool20260209CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      WebSearchTool20260209CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => WebSearchTool20260209CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of WebSearchTool20260209.
#derive(Eq, @debug.Debug)
pub(all) struct WebSearchTool20260209 {
  allowed_callers : Array[AllowedCaller]?
  allowed_domains : @sdkjson.Presence[Array[String]]
  blocked_domains : @sdkjson.Presence[Array[String]]
  cache_control : @sdkjson.Presence[WebSearchTool20260209CacheControl]
  defer_loading : Bool?
  max_uses : @sdkjson.Presence[Int32]
  strict : Bool?
  type_ : String
  user_location : @sdkjson.Presence[UserLocation]
}

///|
pub extend WebSearchTool20260209 with Eq::{equal, not_equal}

///|
pub extend WebSearchTool20260209 with @debug.Debug::{to_repr}

///|
///
/// Creates a WebSearchTool20260209 with omitted optional fields absent.
pub fn WebSearchTool20260209::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  allowed_domains? : Array[String],
  blocked_domains? : Array[String],
  cache_control? : WebSearchTool20260209CacheControl,
  defer_loading? : Bool,
  max_uses? : Int32,
  strict? : Bool,
  user_location? : UserLocation,
) -> WebSearchTool20260209 {
  {
    allowed_callers,
    allowed_domains: @sdkjson.Presence::from_option(allowed_domains),
    blocked_domains: @sdkjson.Presence::from_option(blocked_domains),
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    max_uses: @sdkjson.Presence::from_option(max_uses),
    strict,
    type_,
    user_location: @sdkjson.Presence::from_option(user_location),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend WebSearchTool20260209 with ToJson::{to_json}

///|
pub impl ToJson for WebSearchTool20260209 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("allowed_domains", self.allowed_domains)
  .presence("blocked_domains", self.blocked_domains)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .presence("max_uses", self.max_uses)
  .field("name", "web_search")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .presence("user_location", self.user_location)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebSearchTool20260209 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebSearchTool20260209 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    allowed_domains: @sdkjson.presence_field(obj, "allowed_domains", path),
    blocked_domains: @sdkjson.presence_field(obj, "blocked_domains", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    max_uses: @sdkjson.presence_field(obj, "max_uses", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
    user_location: @sdkjson.presence_field(obj, "user_location", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchTool20260209CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend WebFetchTool20260209CacheControl with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20260209CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebFetchTool20260209CacheControl with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20260209CacheControl with fn to_json(self) {
  match self {
    WebFetchTool20260209CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    WebFetchTool20260209CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebFetchTool20260209CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchTool20260209CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      WebFetchTool20260209CacheControl::Ephemeral(@json.from_json(value, path~))
    other => WebFetchTool20260209CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated representation of WebFetchTool20260209.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchTool20260209 {
  allowed_callers : Array[AllowedCaller]?
  allowed_domains : @sdkjson.Presence[Array[String]]
  blocked_domains : @sdkjson.Presence[Array[String]]
  cache_control : @sdkjson.Presence[WebFetchTool20260209CacheControl]
  citations : @sdkjson.Presence[RequestCitationsConfig]
  defer_loading : Bool?
  max_content_tokens : @sdkjson.Presence[Int32]
  max_uses : @sdkjson.Presence[Int32]
  strict : Bool?
  type_ : String
  url_sources : @sdkjson.Presence[WebFetchUrlSources]
}

///|
pub extend WebFetchTool20260209 with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20260209 with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchTool20260209 with omitted optional fields absent.
pub fn WebFetchTool20260209::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  allowed_domains? : Array[String],
  blocked_domains? : Array[String],
  cache_control? : WebFetchTool20260209CacheControl,
  citations? : RequestCitationsConfig,
  defer_loading? : Bool,
  max_content_tokens? : Int32,
  max_uses? : Int32,
  strict? : Bool,
  url_sources? : WebFetchUrlSources,
) -> WebFetchTool20260209 {
  {
    allowed_callers,
    allowed_domains: @sdkjson.Presence::from_option(allowed_domains),
    blocked_domains: @sdkjson.Presence::from_option(blocked_domains),
    cache_control: @sdkjson.Presence::from_option(cache_control),
    citations: @sdkjson.Presence::from_option(citations),
    defer_loading,
    max_content_tokens: @sdkjson.Presence::from_option(max_content_tokens),
    max_uses: @sdkjson.Presence::from_option(max_uses),
    strict,
    type_,
    url_sources: @sdkjson.Presence::from_option(url_sources),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchTool20260209 with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20260209 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("allowed_domains", self.allowed_domains)
  .presence("blocked_domains", self.blocked_domains)
  .presence("cache_control", self.cache_control)
  .presence("citations", self.citations)
  .opt("defer_loading", self.defer_loading)
  .presence("max_content_tokens", self.max_content_tokens)
  .presence("max_uses", self.max_uses)
  .field("name", "web_fetch")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .presence("url_sources", self.url_sources)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchTool20260209 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchTool20260209 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    allowed_domains: @sdkjson.presence_field(obj, "allowed_domains", path),
    blocked_domains: @sdkjson.presence_field(obj, "blocked_domains", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    citations: @sdkjson.presence_field(obj, "citations", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    max_content_tokens: @sdkjson.presence_field(obj, "max_content_tokens", path),
    max_uses: @sdkjson.presence_field(obj, "max_uses", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
    url_sources: @sdkjson.presence_field(obj, "url_sources", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchTool20260309CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend WebFetchTool20260309CacheControl with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20260309CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebFetchTool20260309CacheControl with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20260309CacheControl with fn to_json(self) {
  match self {
    WebFetchTool20260309CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    WebFetchTool20260309CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebFetchTool20260309CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchTool20260309CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      WebFetchTool20260309CacheControl::Ephemeral(@json.from_json(value, path~))
    other => WebFetchTool20260309CacheControl::Unknown(other, value)
  }
}

///|
///
/// Web fetch tool with use_cache parameter for bypassing cached content.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchTool20260309 {
  allowed_callers : Array[AllowedCaller]?
  allowed_domains : @sdkjson.Presence[Array[String]]
  blocked_domains : @sdkjson.Presence[Array[String]]
  cache_control : @sdkjson.Presence[WebFetchTool20260309CacheControl]
  citations : @sdkjson.Presence[RequestCitationsConfig]
  defer_loading : Bool?
  max_content_tokens : @sdkjson.Presence[Int32]
  max_uses : @sdkjson.Presence[Int32]
  strict : Bool?
  type_ : String
  url_sources : @sdkjson.Presence[WebFetchUrlSources]
  use_cache : Bool?
}

///|
pub extend WebFetchTool20260309 with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20260309 with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchTool20260309 with omitted optional fields absent.
pub fn WebFetchTool20260309::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  allowed_domains? : Array[String],
  blocked_domains? : Array[String],
  cache_control? : WebFetchTool20260309CacheControl,
  citations? : RequestCitationsConfig,
  defer_loading? : Bool,
  max_content_tokens? : Int32,
  max_uses? : Int32,
  strict? : Bool,
  url_sources? : WebFetchUrlSources,
  use_cache? : Bool,
) -> WebFetchTool20260309 {
  {
    allowed_callers,
    allowed_domains: @sdkjson.Presence::from_option(allowed_domains),
    blocked_domains: @sdkjson.Presence::from_option(blocked_domains),
    cache_control: @sdkjson.Presence::from_option(cache_control),
    citations: @sdkjson.Presence::from_option(citations),
    defer_loading,
    max_content_tokens: @sdkjson.Presence::from_option(max_content_tokens),
    max_uses: @sdkjson.Presence::from_option(max_uses),
    strict,
    type_,
    url_sources: @sdkjson.Presence::from_option(url_sources),
    use_cache,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchTool20260309 with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20260309 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("allowed_domains", self.allowed_domains)
  .presence("blocked_domains", self.blocked_domains)
  .presence("cache_control", self.cache_control)
  .presence("citations", self.citations)
  .opt("defer_loading", self.defer_loading)
  .presence("max_content_tokens", self.max_content_tokens)
  .presence("max_uses", self.max_uses)
  .field("name", "web_fetch")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .presence("url_sources", self.url_sources)
  .opt("use_cache", self.use_cache)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchTool20260309 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchTool20260309 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    allowed_domains: @sdkjson.presence_field(obj, "allowed_domains", path),
    blocked_domains: @sdkjson.presence_field(obj, "blocked_domains", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    citations: @sdkjson.presence_field(obj, "citations", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    max_content_tokens: @sdkjson.presence_field(obj, "max_content_tokens", path),
    max_uses: @sdkjson.presence_field(obj, "max_uses", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
    url_sources: @sdkjson.presence_field(obj, "url_sources", path),
    use_cache: @sdkjson.opt_field(obj, "use_cache", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebSearchTool20260318CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend WebSearchTool20260318CacheControl with Eq::{equal, not_equal}

///|
pub extend WebSearchTool20260318CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebSearchTool20260318CacheControl with ToJson::{to_json}

///|
pub impl ToJson for WebSearchTool20260318CacheControl with fn to_json(self) {
  match self {
    WebSearchTool20260318CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    WebSearchTool20260318CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebSearchTool20260318CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebSearchTool20260318CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      WebSearchTool20260318CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => WebSearchTool20260318CacheControl::Unknown(other, value)
  }
}

///|
///
/// How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebSearchTool20260318ResponseInclusion {
  Full
  Excluded
  Custom(String)
}

///|
pub extend WebSearchTool20260318ResponseInclusion with Eq::{equal, not_equal}

///|
pub extend WebSearchTool20260318ResponseInclusion with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend WebSearchTool20260318ResponseInclusion with ToJson::{to_json}

///|
pub impl ToJson for WebSearchTool20260318ResponseInclusion with fn to_json(self) {
  let raw = match self {
    WebSearchTool20260318ResponseInclusion::Full => "full"
    WebSearchTool20260318ResponseInclusion::Excluded => "excluded"
    WebSearchTool20260318ResponseInclusion::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend WebSearchTool20260318ResponseInclusion with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for WebSearchTool20260318ResponseInclusion with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "full" => Option::Some(WebSearchTool20260318ResponseInclusion::Full)
        "excluded" =>
          Option::Some(WebSearchTool20260318ResponseInclusion::Excluded)
        _ => Option::None
      }
    },
    raw => WebSearchTool20260318ResponseInclusion::Custom(raw),
  )
}

///|
///
/// Generated representation of WebSearchTool20260318.
#derive(Eq, @debug.Debug)
pub(all) struct WebSearchTool20260318 {
  allowed_callers : Array[AllowedCaller]?
  allowed_domains : @sdkjson.Presence[Array[String]]
  blocked_domains : @sdkjson.Presence[Array[String]]
  cache_control : @sdkjson.Presence[WebSearchTool20260318CacheControl]
  defer_loading : Bool?
  max_uses : @sdkjson.Presence[Int32]
  response_inclusion : WebSearchTool20260318ResponseInclusion?
  strict : Bool?
  type_ : String
  user_location : @sdkjson.Presence[UserLocation]
}

///|
pub extend WebSearchTool20260318 with Eq::{equal, not_equal}

///|
pub extend WebSearchTool20260318 with @debug.Debug::{to_repr}

///|
///
/// Creates a WebSearchTool20260318 with omitted optional fields absent.
pub fn WebSearchTool20260318::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  allowed_domains? : Array[String],
  blocked_domains? : Array[String],
  cache_control? : WebSearchTool20260318CacheControl,
  defer_loading? : Bool,
  max_uses? : Int32,
  response_inclusion? : WebSearchTool20260318ResponseInclusion,
  strict? : Bool,
  user_location? : UserLocation,
) -> WebSearchTool20260318 {
  {
    allowed_callers,
    allowed_domains: @sdkjson.Presence::from_option(allowed_domains),
    blocked_domains: @sdkjson.Presence::from_option(blocked_domains),
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    max_uses: @sdkjson.Presence::from_option(max_uses),
    response_inclusion,
    strict,
    type_,
    user_location: @sdkjson.Presence::from_option(user_location),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend WebSearchTool20260318 with ToJson::{to_json}

///|
pub impl ToJson for WebSearchTool20260318 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("allowed_domains", self.allowed_domains)
  .presence("blocked_domains", self.blocked_domains)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .presence("max_uses", self.max_uses)
  .field("name", "web_search")
  .opt("response_inclusion", self.response_inclusion)
  .opt("strict", self.strict)
  .field("type", self.type_)
  .presence("user_location", self.user_location)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebSearchTool20260318 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebSearchTool20260318 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    allowed_domains: @sdkjson.presence_field(obj, "allowed_domains", path),
    blocked_domains: @sdkjson.presence_field(obj, "blocked_domains", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    max_uses: @sdkjson.presence_field(obj, "max_uses", path),
    response_inclusion: @sdkjson.opt_field(obj, "response_inclusion", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
    user_location: @sdkjson.presence_field(obj, "user_location", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchTool20260318CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend WebFetchTool20260318CacheControl with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20260318CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend WebFetchTool20260318CacheControl with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20260318CacheControl with fn to_json(self) {
  match self {
    WebFetchTool20260318CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    WebFetchTool20260318CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend WebFetchTool20260318CacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchTool20260318CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      WebFetchTool20260318CacheControl::Ephemeral(@json.from_json(value, path~))
    other => WebFetchTool20260318CacheControl::Unknown(other, value)
  }
}

///|
///
/// How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum WebFetchTool20260318ResponseInclusion {
  Full
  Excluded
  Custom(String)
}

///|
pub extend WebFetchTool20260318ResponseInclusion with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20260318ResponseInclusion with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend WebFetchTool20260318ResponseInclusion with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20260318ResponseInclusion with fn to_json(self) {
  let raw = match self {
    WebFetchTool20260318ResponseInclusion::Full => "full"
    WebFetchTool20260318ResponseInclusion::Excluded => "excluded"
    WebFetchTool20260318ResponseInclusion::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend WebFetchTool20260318ResponseInclusion with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for WebFetchTool20260318ResponseInclusion with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "full" => Option::Some(WebFetchTool20260318ResponseInclusion::Full)
        "excluded" =>
          Option::Some(WebFetchTool20260318ResponseInclusion::Excluded)
        _ => Option::None
      }
    },
    raw => WebFetchTool20260318ResponseInclusion::Custom(raw),
  )
}

///|
///
/// Generated representation of WebFetchTool20260318.
#derive(Eq, @debug.Debug)
pub(all) struct WebFetchTool20260318 {
  allowed_callers : Array[AllowedCaller]?
  allowed_domains : @sdkjson.Presence[Array[String]]
  blocked_domains : @sdkjson.Presence[Array[String]]
  cache_control : @sdkjson.Presence[WebFetchTool20260318CacheControl]
  citations : @sdkjson.Presence[RequestCitationsConfig]
  defer_loading : Bool?
  max_content_tokens : @sdkjson.Presence[Int32]
  max_uses : @sdkjson.Presence[Int32]
  response_inclusion : WebFetchTool20260318ResponseInclusion?
  strict : Bool?
  type_ : String
  url_sources : @sdkjson.Presence[WebFetchUrlSources]
  use_cache : Bool?
}

///|
pub extend WebFetchTool20260318 with Eq::{equal, not_equal}

///|
pub extend WebFetchTool20260318 with @debug.Debug::{to_repr}

///|
///
/// Creates a WebFetchTool20260318 with omitted optional fields absent.
pub fn WebFetchTool20260318::new(
  type_~ : String,
  allowed_callers? : Array[AllowedCaller],
  allowed_domains? : Array[String],
  blocked_domains? : Array[String],
  cache_control? : WebFetchTool20260318CacheControl,
  citations? : RequestCitationsConfig,
  defer_loading? : Bool,
  max_content_tokens? : Int32,
  max_uses? : Int32,
  response_inclusion? : WebFetchTool20260318ResponseInclusion,
  strict? : Bool,
  url_sources? : WebFetchUrlSources,
  use_cache? : Bool,
) -> WebFetchTool20260318 {
  {
    allowed_callers,
    allowed_domains: @sdkjson.Presence::from_option(allowed_domains),
    blocked_domains: @sdkjson.Presence::from_option(blocked_domains),
    cache_control: @sdkjson.Presence::from_option(cache_control),
    citations: @sdkjson.Presence::from_option(citations),
    defer_loading,
    max_content_tokens: @sdkjson.Presence::from_option(max_content_tokens),
    max_uses: @sdkjson.Presence::from_option(max_uses),
    response_inclusion,
    strict,
    type_,
    url_sources: @sdkjson.Presence::from_option(url_sources),
    use_cache,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend WebFetchTool20260318 with ToJson::{to_json}

///|
pub impl ToJson for WebFetchTool20260318 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("allowed_domains", self.allowed_domains)
  .presence("blocked_domains", self.blocked_domains)
  .presence("cache_control", self.cache_control)
  .presence("citations", self.citations)
  .opt("defer_loading", self.defer_loading)
  .presence("max_content_tokens", self.max_content_tokens)
  .presence("max_uses", self.max_uses)
  .field("name", "web_fetch")
  .opt("response_inclusion", self.response_inclusion)
  .opt("strict", self.strict)
  .field("type", self.type_)
  .presence("url_sources", self.url_sources)
  .opt("use_cache", self.use_cache)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend WebFetchTool20260318 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for WebFetchTool20260318 with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    allowed_domains: @sdkjson.presence_field(obj, "allowed_domains", path),
    blocked_domains: @sdkjson.presence_field(obj, "blocked_domains", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    citations: @sdkjson.presence_field(obj, "citations", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    max_content_tokens: @sdkjson.presence_field(obj, "max_content_tokens", path),
    max_uses: @sdkjson.presence_field(obj, "max_uses", path),
    response_inclusion: @sdkjson.opt_field(obj, "response_inclusion", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
    url_sources: @sdkjson.presence_field(obj, "url_sources", path),
    use_cache: @sdkjson.opt_field(obj, "use_cache", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolSearchToolBM2520251119CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend ToolSearchToolBM2520251119CacheControl with Eq::{equal, not_equal}

///|
pub extend ToolSearchToolBM2520251119CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ToolSearchToolBM2520251119CacheControl with ToJson::{to_json}

///|
pub impl ToJson for ToolSearchToolBM2520251119CacheControl with fn to_json(self) {
  match self {
    ToolSearchToolBM2520251119CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    ToolSearchToolBM2520251119CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ToolSearchToolBM2520251119CacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ToolSearchToolBM2520251119CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      ToolSearchToolBM2520251119CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => ToolSearchToolBM2520251119CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated string enum ToolSearchToolBM2520251119Type.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolSearchToolBM2520251119Type {
  ToolSearchToolBm2520251119
  ToolSearchToolBm25
  Custom(String)
}

///|
pub extend ToolSearchToolBM2520251119Type with Eq::{equal, not_equal}

///|
pub extend ToolSearchToolBM2520251119Type with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ToolSearchToolBM2520251119Type with ToJson::{to_json}

///|
pub impl ToJson for ToolSearchToolBM2520251119Type with fn to_json(self) {
  let raw = match self {
    ToolSearchToolBM2520251119Type::ToolSearchToolBm2520251119 =>
      "tool_search_tool_bm25_20251119"
    ToolSearchToolBM2520251119Type::ToolSearchToolBm25 =>
      "tool_search_tool_bm25"
    ToolSearchToolBM2520251119Type::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ToolSearchToolBM2520251119Type with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolSearchToolBM2520251119Type with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "tool_search_tool_bm25_20251119" =>
          Option::Some(
            ToolSearchToolBM2520251119Type::ToolSearchToolBm2520251119,
          )
        "tool_search_tool_bm25" =>
          Option::Some(ToolSearchToolBM2520251119Type::ToolSearchToolBm25)
        _ => Option::None
      }
    },
    raw => ToolSearchToolBM2520251119Type::Custom(raw),
  )
}

///|
///
/// Generated representation of ToolSearchToolBM2520251119.
#derive(Eq, @debug.Debug)
pub(all) struct ToolSearchToolBM2520251119 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[ToolSearchToolBM2520251119CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : ToolSearchToolBM2520251119Type
}

///|
pub extend ToolSearchToolBM2520251119 with Eq::{equal, not_equal}

///|
pub extend ToolSearchToolBM2520251119 with @debug.Debug::{to_repr}

///|
///
/// Creates a ToolSearchToolBM2520251119 with omitted optional fields absent.
pub fn ToolSearchToolBM2520251119::new(
  type_~ : ToolSearchToolBM2520251119Type,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : ToolSearchToolBM2520251119CacheControl,
  defer_loading? : Bool,
  strict? : Bool,
) -> ToolSearchToolBM2520251119 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ToolSearchToolBM2520251119 with ToJson::{to_json}

///|
pub impl ToJson for ToolSearchToolBM2520251119 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .field("name", "tool_search_tool_bm25")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ToolSearchToolBM2520251119 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolSearchToolBM2520251119 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Create a cache control breakpoint at this content block.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolSearchToolRegex20251119CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend ToolSearchToolRegex20251119CacheControl with Eq::{equal, not_equal}

///|
pub extend ToolSearchToolRegex20251119CacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ToolSearchToolRegex20251119CacheControl with ToJson::{to_json}

///|
pub impl ToJson for ToolSearchToolRegex20251119CacheControl with fn to_json(
  self,
) {
  match self {
    ToolSearchToolRegex20251119CacheControl::Ephemeral(value) =>
      @json.Json::Json(value)
    ToolSearchToolRegex20251119CacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ToolSearchToolRegex20251119CacheControl with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ToolSearchToolRegex20251119CacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      ToolSearchToolRegex20251119CacheControl::Ephemeral(
        @json.from_json(value, path~),
      )
    other => ToolSearchToolRegex20251119CacheControl::Unknown(other, value)
  }
}

///|
///
/// Generated string enum ToolSearchToolRegex20251119Type.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolSearchToolRegex20251119Type {
  ToolSearchToolRegex20251119
  ToolSearchToolRegex
  Custom(String)
}

///|
pub extend ToolSearchToolRegex20251119Type with Eq::{equal, not_equal}

///|
pub extend ToolSearchToolRegex20251119Type with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ToolSearchToolRegex20251119Type with ToJson::{to_json}

///|
pub impl ToJson for ToolSearchToolRegex20251119Type with fn to_json(self) {
  let raw = match self {
    ToolSearchToolRegex20251119Type::ToolSearchToolRegex20251119 =>
      "tool_search_tool_regex_20251119"
    ToolSearchToolRegex20251119Type::ToolSearchToolRegex =>
      "tool_search_tool_regex"
    ToolSearchToolRegex20251119Type::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ToolSearchToolRegex20251119Type with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolSearchToolRegex20251119Type with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "tool_search_tool_regex_20251119" =>
          Option::Some(
            ToolSearchToolRegex20251119Type::ToolSearchToolRegex20251119,
          )
        "tool_search_tool_regex" =>
          Option::Some(ToolSearchToolRegex20251119Type::ToolSearchToolRegex)
        _ => Option::None
      }
    },
    raw => ToolSearchToolRegex20251119Type::Custom(raw),
  )
}

///|
///
/// Generated representation of ToolSearchToolRegex20251119.
#derive(Eq, @debug.Debug)
pub(all) struct ToolSearchToolRegex20251119 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[ToolSearchToolRegex20251119CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : ToolSearchToolRegex20251119Type
}

///|
pub extend ToolSearchToolRegex20251119 with Eq::{equal, not_equal}

///|
pub extend ToolSearchToolRegex20251119 with @debug.Debug::{to_repr}

///|
///
/// Creates a ToolSearchToolRegex20251119 with omitted optional fields absent.
pub fn ToolSearchToolRegex20251119::new(
  type_~ : ToolSearchToolRegex20251119Type,
  allowed_callers? : Array[AllowedCaller],
  cache_control? : ToolSearchToolRegex20251119CacheControl,
  defer_loading? : Bool,
  strict? : Bool,
) -> ToolSearchToolRegex20251119 {
  {
    allowed_callers,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    defer_loading,
    strict,
    type_,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ToolSearchToolRegex20251119 with ToJson::{to_json}

///|
pub impl ToJson for ToolSearchToolRegex20251119 with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .opt("allowed_callers", self.allowed_callers)
  .presence("cache_control", self.cache_control)
  .opt("defer_loading", self.defer_loading)
  .field("name", "tool_search_tool_regex")
  .opt("strict", self.strict)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ToolSearchToolRegex20251119 with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolSearchToolRegex20251119 with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    allowed_callers: @sdkjson.opt_field(obj, "allowed_callers", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    defer_loading: @sdkjson.opt_field(obj, "defer_loading", path),
    strict: @sdkjson.opt_field(obj, "strict", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union CountMessageTokensParamsToolsItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CountMessageTokensParamsToolsItem {
  Tool(Tool)
  BashTool20250124(BashTool20250124)
  CodeExecutionTool20250522(CodeExecutionTool20250522)
  CodeExecutionTool20250825(CodeExecutionTool20250825)
  CodeExecutionTool20260120(CodeExecutionTool20260120)
  CodeExecutionTool20260521(CodeExecutionTool20260521)
  BrowserToolset20260801(BrowserToolset20260801)
  MemoryTool20250818(MemoryTool20250818)
  ComputerToolset20260801(ComputerToolset20260801)
  TextEditor20250124(TextEditor20250124)
  TextEditor20250429(TextEditor20250429)
  TextEditor20250728(TextEditor20250728)
  WebSearchTool20250305(WebSearchTool20250305)
  WebFetchTool20250910(WebFetchTool20250910)
  WebSearchTool20260209(WebSearchTool20260209)
  WebFetchTool20260209(WebFetchTool20260209)
  WebFetchTool20260309(WebFetchTool20260309)
  WebSearchTool20260318(WebSearchTool20260318)
  WebFetchTool20260318(WebFetchTool20260318)
  ToolSearchToolBM2520251119(ToolSearchToolBM2520251119)
  ToolSearchToolRegex20251119(ToolSearchToolRegex20251119)
  Unknown(String, Json)
}

///|
pub extend CountMessageTokensParamsToolsItem with Eq::{equal, not_equal}

///|
pub extend CountMessageTokensParamsToolsItem with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CountMessageTokensParamsToolsItem with ToJson::{to_json}

///|
pub impl ToJson for CountMessageTokensParamsToolsItem with fn to_json(self) {
  match self {
    CountMessageTokensParamsToolsItem::Tool(value) => @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::BashTool20250124(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::CodeExecutionTool20250522(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::CodeExecutionTool20250825(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::CodeExecutionTool20260120(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::CodeExecutionTool20260521(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::BrowserToolset20260801(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::MemoryTool20250818(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::ComputerToolset20260801(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::TextEditor20250124(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::TextEditor20250429(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::TextEditor20250728(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::WebSearchTool20250305(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::WebFetchTool20250910(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::WebSearchTool20260209(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::WebFetchTool20260209(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::WebFetchTool20260309(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::WebSearchTool20260318(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::WebFetchTool20260318(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::ToolSearchToolBM2520251119(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::ToolSearchToolRegex20251119(value) =>
      @json.Json::Json(value)
    CountMessageTokensParamsToolsItem::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CountMessageTokensParamsToolsItem with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CountMessageTokensParamsToolsItem with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  // A missing or null "type" selects Tool, the one variant whose payload does not require it.
  let tag : String = match obj.get("type") {
    Option::None | Option::Some(@json.Json::Null) => "custom"
    Option::Some(raw) => @json.from_json(raw, path=path.add_key("type"))
  }
  match tag {
    "custom" =>
      CountMessageTokensParamsToolsItem::Tool(@json.from_json(value, path~))
    "bash_20250124" =>
      CountMessageTokensParamsToolsItem::BashTool20250124(
        @json.from_json(value, path~),
      )
    "code_execution_20250522" =>
      CountMessageTokensParamsToolsItem::CodeExecutionTool20250522(
        @json.from_json(value, path~),
      )
    "code_execution_20250825" =>
      CountMessageTokensParamsToolsItem::CodeExecutionTool20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      CountMessageTokensParamsToolsItem::CodeExecutionTool20260120(
        @json.from_json(value, path~),
      )
    "code_execution_20260521" =>
      CountMessageTokensParamsToolsItem::CodeExecutionTool20260521(
        @json.from_json(value, path~),
      )
    "browser_toolset_20260801" =>
      CountMessageTokensParamsToolsItem::BrowserToolset20260801(
        @json.from_json(value, path~),
      )
    "memory_20250818" =>
      CountMessageTokensParamsToolsItem::MemoryTool20250818(
        @json.from_json(value, path~),
      )
    "computer_toolset_20260801" =>
      CountMessageTokensParamsToolsItem::ComputerToolset20260801(
        @json.from_json(value, path~),
      )
    "text_editor_20250124" =>
      CountMessageTokensParamsToolsItem::TextEditor20250124(
        @json.from_json(value, path~),
      )
    "text_editor_20250429" =>
      CountMessageTokensParamsToolsItem::TextEditor20250429(
        @json.from_json(value, path~),
      )
    "text_editor_20250728" =>
      CountMessageTokensParamsToolsItem::TextEditor20250728(
        @json.from_json(value, path~),
      )
    "web_search_20250305" =>
      CountMessageTokensParamsToolsItem::WebSearchTool20250305(
        @json.from_json(value, path~),
      )
    "web_fetch_20250910" =>
      CountMessageTokensParamsToolsItem::WebFetchTool20250910(
        @json.from_json(value, path~),
      )
    "web_search_20260209" =>
      CountMessageTokensParamsToolsItem::WebSearchTool20260209(
        @json.from_json(value, path~),
      )
    "web_fetch_20260209" =>
      CountMessageTokensParamsToolsItem::WebFetchTool20260209(
        @json.from_json(value, path~),
      )
    "web_fetch_20260309" =>
      CountMessageTokensParamsToolsItem::WebFetchTool20260309(
        @json.from_json(value, path~),
      )
    "web_search_20260318" =>
      CountMessageTokensParamsToolsItem::WebSearchTool20260318(
        @json.from_json(value, path~),
      )
    "web_fetch_20260318" =>
      CountMessageTokensParamsToolsItem::WebFetchTool20260318(
        @json.from_json(value, path~),
      )
    "tool_search_tool_bm25_20251119" =>
      CountMessageTokensParamsToolsItem::ToolSearchToolBM2520251119(
        @json.from_json(value, path~),
      )
    "tool_search_tool_bm25" =>
      CountMessageTokensParamsToolsItem::ToolSearchToolBM2520251119(
        @json.from_json(value, path~),
      )
    "tool_search_tool_regex_20251119" =>
      CountMessageTokensParamsToolsItem::ToolSearchToolRegex20251119(
        @json.from_json(value, path~),
      )
    "tool_search_tool_regex" =>
      CountMessageTokensParamsToolsItem::ToolSearchToolRegex20251119(
        @json.from_json(value, path~),
      )
    other => CountMessageTokensParamsToolsItem::Unknown(other, value)
  }
}

///|
///
/// Generated representation of CountMessageTokensParams.
#derive(Eq, @debug.Debug)
pub(all) struct CountMessageTokensParams {
  cache_control : @sdkjson.Presence[CountMessageTokensParamsCacheControl]
  messages : Array[InputMessageUnion]
  model : String
  output_config : OutputConfig?
  speed : @sdkjson.Presence[Speed]
  system : CountMessageTokensParamsSystem?
  thinking : ThinkingConfigParam?
  tool_choice : ToolChoice?
  tools : Array[CountMessageTokensParamsToolsItem]?
}

///|
pub extend CountMessageTokensParams with Eq::{equal, not_equal}

///|
pub extend CountMessageTokensParams with @debug.Debug::{to_repr}

///|
///
/// Creates a CountMessageTokensParams with omitted optional fields absent.
pub fn CountMessageTokensParams::new(
  messages~ : Array[InputMessageUnion],
  model~ : String,
  cache_control? : CountMessageTokensParamsCacheControl,
  output_config? : OutputConfig,
  speed? : Speed,
  system? : CountMessageTokensParamsSystem,
  thinking? : ThinkingConfigParam,
  tool_choice? : ToolChoice,
  tools? : Array[CountMessageTokensParamsToolsItem],
) -> CountMessageTokensParams {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    messages,
    model,
    output_config,
    speed: @sdkjson.Presence::from_option(speed),
    system,
    thinking,
    tool_choice,
    tools,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend CountMessageTokensParams with ToJson::{to_json}

///|
pub impl ToJson for CountMessageTokensParams with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_control", self.cache_control)
  .field("messages", self.messages)
  .field("model", self.model)
  .opt("output_config", self.output_config)
  .presence("speed", self.speed)
  .opt("system", self.system)
  .opt("thinking", self.thinking)
  .opt("tool_choice", self.tool_choice)
  .opt("tools", self.tools)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CountMessageTokensParams with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CountMessageTokensParams with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    messages: required_field(obj, "messages", path),
    model: required_field(obj, "model", path),
    output_config: @sdkjson.opt_field(obj, "output_config", path),
    speed: @sdkjson.presence_field(obj, "speed", path),
    system: @sdkjson.opt_field(obj, "system", path),
    thinking: @sdkjson.opt_field(obj, "thinking", path),
    tool_choice: @sdkjson.opt_field(obj, "tool_choice", path),
    tools: @sdkjson.opt_field(obj, "tools", path),
  }
}

///|
///
/// Generated representation of CountMessageTokensResponse.
#derive(Eq, @debug.Debug)
pub(all) struct CountMessageTokensResponse {
  input_tokens : Int32
}

///|
pub extend CountMessageTokensResponse with Eq::{equal, not_equal}

///|
pub extend CountMessageTokensResponse with @debug.Debug::{to_repr}

///|
///
/// Creates a CountMessageTokensResponse with omitted optional fields absent.
pub fn CountMessageTokensResponse::new(
  input_tokens~ : Int32,
) -> CountMessageTokensResponse {
  { input_tokens, }
}

///|
///
/// Encodes this value as JSON.
pub extend CountMessageTokensResponse with ToJson::{to_json}

///|
pub impl ToJson for CountMessageTokensResponse with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("input_tokens", self.input_tokens).build()
}

///|
///
/// Decodes this value from JSON.
pub extend CountMessageTokensResponse with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CountMessageTokensResponse with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { input_tokens: required_field(obj, "input_tokens", path), }
}

///|
///
/// Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CreateMessageParamsCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
}

///|
pub extend CreateMessageParamsCacheControl with Eq::{equal, not_equal}

///|
pub extend CreateMessageParamsCacheControl with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CreateMessageParamsCacheControl with ToJson::{to_json}

///|
pub impl ToJson for CreateMessageParamsCacheControl with fn to_json(self) {
  match self {
    CreateMessageParamsCacheControl::Ephemeral(value) => @json.Json::Json(value)
    CreateMessageParamsCacheControl::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CreateMessageParamsCacheControl with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CreateMessageParamsCacheControl with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "ephemeral" =>
      CreateMessageParamsCacheControl::Ephemeral(@json.from_json(value, path~))
    other => CreateMessageParamsCacheControl::Unknown(other, value)
  }
}

///|
///
/// Container identifier for reuse across requests.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CreateMessageParamsContainer {
  ContainerParams(ContainerParams)
  Text(String)
}

///|
pub extend CreateMessageParamsContainer with Eq::{equal, not_equal}

///|
pub extend CreateMessageParamsContainer with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend CreateMessageParamsContainer with ToJson::{to_json}

///|
pub impl ToJson for CreateMessageParamsContainer with fn to_json(self) {
  match self {
    CreateMessageParamsContainer::ContainerParams(value) =>
      @json.Json::Json(value)
    CreateMessageParamsContainer::Text(value) => @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend CreateMessageParamsContainer with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CreateMessageParamsContainer with fn from_json(
  value,
  path,
) {
  if value is @json.Json::Object(_) {
    let decoded : ContainerParams = @json.from_json(value, path~)
    return CreateMessageParamsContainer::ContainerParams(decoded)
  }
  if value is @json.Json::String(_) {
    let decoded : String = @json.from_json(value, path~)
    return CreateMessageParamsContainer::Text(decoded)
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (path, "JSON shape does not match any CreateMessageParamsContainer variant"),
  )
}

///|
///
/// Request-level diagnostics. Currently carries the previous response id for prompt-cache divergence reporting.
#derive(Eq, @debug.Debug)
pub(all) struct DiagnosticsParam {
  previous_message_id : @sdkjson.Presence[String]
}

///|
pub extend DiagnosticsParam with Eq::{equal, not_equal}

///|
pub extend DiagnosticsParam with @debug.Debug::{to_repr}

///|
///
/// Creates a DiagnosticsParam with omitted optional fields absent.
pub fn DiagnosticsParam::new(previous_message_id? : String) -> DiagnosticsParam {
  { previous_message_id: @sdkjson.Presence::from_option(previous_message_id), }
}

///|
///
/// Encodes this value as JSON.
pub extend DiagnosticsParam with ToJson::{to_json}

///|
pub impl ToJson for DiagnosticsParam with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("previous_message_id", self.previous_message_id)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend DiagnosticsParam with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for DiagnosticsParam with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    previous_message_id: @sdkjson.presence_field(
      obj, "previous_message_id", path,
    ),
  }
}

///|
///
/// Generated representation of Metadata.
#derive(Eq, @debug.Debug)
pub(all) struct Metadata {
  user_id : @sdkjson.Presence[String]
}

///|
pub extend Metadata with Eq::{equal, not_equal}

///|
pub extend Metadata with @debug.Debug::{to_repr}

///|
///
/// Creates a Metadata with omitted optional fields absent.
pub fn Metadata::new(user_id? : String) -> Metadata {
  { user_id: @sdkjson.Presence::from_option(user_id), }
}

///|
///
/// Encodes this value as JSON.
pub extend Metadata with ToJson::{to_json}

///|
pub impl ToJson for Metadata with fn to_json(self) {
  @sdkjson.ObjBuilder::new().presence("user_id", self.user_id).build()
}

///|
///
/// Decodes this value from JSON.
pub extend Metadata with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Metadata with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { user_id: @sdkjson.presence_field(obj, "user_id", path), }
}

///|
///
/// Determines whether to use priority capacity (if available) or standard capacity for this request. Anthropic offers different levels of service for your API requests. See [service-tiers](https://platform.claude.com/docs/en/api/service-tiers) for details.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CreateMessageParamsServiceTier {
  Auto
  StandardOnly
  Custom(String)
}

///|
pub extend CreateMessageParamsServiceTier with Eq::{equal, not_equal}

///|
pub extend CreateMessageParamsServiceTier with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend CreateMessageParamsServiceTier with ToJson::{to_json}

///|
pub impl ToJson for CreateMessageParamsServiceTier with fn to_json(self) {
  let raw = match self {
    CreateMessageParamsServiceTier::Auto => "auto"
    CreateMessageParamsServiceTier::StandardOnly => "standard_only"
    CreateMessageParamsServiceTier::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend CreateMessageParamsServiceTier with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CreateMessageParamsServiceTier with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "auto" => Option::Some(CreateMessageParamsServiceTier::Auto)
        "standard_only" =>
          Option::Some(CreateMessageParamsServiceTier::StandardOnly)
        _ => Option::None
      }
    },
    raw => CreateMessageParamsServiceTier::Custom(raw),
  )
}

///|
///
/// System prompt. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CreateMessageParamsSystem {
  Text(String)
  RequestTextBlockArray(Array[RequestTextBlock])
}

///|
pub extend CreateMessageParamsSystem with Eq::{equal, not_equal}

///|
pub extend CreateMessageParamsSystem with @debug.Debug::{to_repr}

///|
///
/// Encodes this union as JSON.
pub extend CreateMessageParamsSystem with ToJson::{to_json}

///|
pub impl ToJson for CreateMessageParamsSystem with fn to_json(self) {
  match self {
    CreateMessageParamsSystem::Text(value) => @json.Json::Json(value)
    CreateMessageParamsSystem::RequestTextBlockArray(value) =>
      @json.Json::Json(value)
  }
}

///|
///
/// Decodes this union from JSON.
pub extend CreateMessageParamsSystem with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CreateMessageParamsSystem with fn from_json(
  value,
  path,
) {
  if value is @json.Json::String(_) {
    let decoded : String = @json.from_json(value, path~)
    return CreateMessageParamsSystem::Text(decoded)
  }
  if json_array_matches(value, item => item is @json.Json::Object(_)) {
    let decoded : Array[RequestTextBlock] = @json.from_json(value, path~)
    return CreateMessageParamsSystem::RequestTextBlockArray(decoded)
  }
  raise @json.JsonDecodeError::JsonDecodeError(
    (path, "JSON shape does not match any CreateMessageParamsSystem variant"),
  )
}

///|
///
/// Generated tagged union CreateMessageParamsToolsItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CreateMessageParamsToolsItem {
  Tool(Tool)
  BashTool20250124(BashTool20250124)
  CodeExecutionTool20250522(CodeExecutionTool20250522)
  CodeExecutionTool20250825(CodeExecutionTool20250825)
  CodeExecutionTool20260120(CodeExecutionTool20260120)
  CodeExecutionTool20260521(CodeExecutionTool20260521)
  BrowserToolset20260801(BrowserToolset20260801)
  MemoryTool20250818(MemoryTool20250818)
  ComputerToolset20260801(ComputerToolset20260801)
  TextEditor20250124(TextEditor20250124)
  TextEditor20250429(TextEditor20250429)
  TextEditor20250728(TextEditor20250728)
  WebSearchTool20250305(WebSearchTool20250305)
  WebFetchTool20250910(WebFetchTool20250910)
  WebSearchTool20260209(WebSearchTool20260209)
  WebFetchTool20260209(WebFetchTool20260209)
  WebFetchTool20260309(WebFetchTool20260309)
  WebSearchTool20260318(WebSearchTool20260318)
  WebFetchTool20260318(WebFetchTool20260318)
  ToolSearchToolBM2520251119(ToolSearchToolBM2520251119)
  ToolSearchToolRegex20251119(ToolSearchToolRegex20251119)
  Unknown(String, Json)
}

///|
pub extend CreateMessageParamsToolsItem with Eq::{equal, not_equal}

///|
pub extend CreateMessageParamsToolsItem with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend CreateMessageParamsToolsItem with ToJson::{to_json}

///|
pub impl ToJson for CreateMessageParamsToolsItem with fn to_json(self) {
  match self {
    CreateMessageParamsToolsItem::Tool(value) => @json.Json::Json(value)
    CreateMessageParamsToolsItem::BashTool20250124(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::CodeExecutionTool20250522(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::CodeExecutionTool20250825(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::CodeExecutionTool20260120(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::CodeExecutionTool20260521(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::BrowserToolset20260801(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::MemoryTool20250818(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::ComputerToolset20260801(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::TextEditor20250124(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::TextEditor20250429(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::TextEditor20250728(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::WebSearchTool20250305(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::WebFetchTool20250910(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::WebSearchTool20260209(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::WebFetchTool20260209(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::WebFetchTool20260309(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::WebSearchTool20260318(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::WebFetchTool20260318(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::ToolSearchToolBM2520251119(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::ToolSearchToolRegex20251119(value) =>
      @json.Json::Json(value)
    CreateMessageParamsToolsItem::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend CreateMessageParamsToolsItem with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CreateMessageParamsToolsItem with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  // A missing or null "type" selects Tool, the one variant whose payload does not require it.
  let tag : String = match obj.get("type") {
    Option::None | Option::Some(@json.Json::Null) => "custom"
    Option::Some(raw) => @json.from_json(raw, path=path.add_key("type"))
  }
  match tag {
    "custom" =>
      CreateMessageParamsToolsItem::Tool(@json.from_json(value, path~))
    "bash_20250124" =>
      CreateMessageParamsToolsItem::BashTool20250124(
        @json.from_json(value, path~),
      )
    "code_execution_20250522" =>
      CreateMessageParamsToolsItem::CodeExecutionTool20250522(
        @json.from_json(value, path~),
      )
    "code_execution_20250825" =>
      CreateMessageParamsToolsItem::CodeExecutionTool20250825(
        @json.from_json(value, path~),
      )
    "code_execution_20260120" =>
      CreateMessageParamsToolsItem::CodeExecutionTool20260120(
        @json.from_json(value, path~),
      )
    "code_execution_20260521" =>
      CreateMessageParamsToolsItem::CodeExecutionTool20260521(
        @json.from_json(value, path~),
      )
    "browser_toolset_20260801" =>
      CreateMessageParamsToolsItem::BrowserToolset20260801(
        @json.from_json(value, path~),
      )
    "memory_20250818" =>
      CreateMessageParamsToolsItem::MemoryTool20250818(
        @json.from_json(value, path~),
      )
    "computer_toolset_20260801" =>
      CreateMessageParamsToolsItem::ComputerToolset20260801(
        @json.from_json(value, path~),
      )
    "text_editor_20250124" =>
      CreateMessageParamsToolsItem::TextEditor20250124(
        @json.from_json(value, path~),
      )
    "text_editor_20250429" =>
      CreateMessageParamsToolsItem::TextEditor20250429(
        @json.from_json(value, path~),
      )
    "text_editor_20250728" =>
      CreateMessageParamsToolsItem::TextEditor20250728(
        @json.from_json(value, path~),
      )
    "web_search_20250305" =>
      CreateMessageParamsToolsItem::WebSearchTool20250305(
        @json.from_json(value, path~),
      )
    "web_fetch_20250910" =>
      CreateMessageParamsToolsItem::WebFetchTool20250910(
        @json.from_json(value, path~),
      )
    "web_search_20260209" =>
      CreateMessageParamsToolsItem::WebSearchTool20260209(
        @json.from_json(value, path~),
      )
    "web_fetch_20260209" =>
      CreateMessageParamsToolsItem::WebFetchTool20260209(
        @json.from_json(value, path~),
      )
    "web_fetch_20260309" =>
      CreateMessageParamsToolsItem::WebFetchTool20260309(
        @json.from_json(value, path~),
      )
    "web_search_20260318" =>
      CreateMessageParamsToolsItem::WebSearchTool20260318(
        @json.from_json(value, path~),
      )
    "web_fetch_20260318" =>
      CreateMessageParamsToolsItem::WebFetchTool20260318(
        @json.from_json(value, path~),
      )
    "tool_search_tool_bm25_20251119" =>
      CreateMessageParamsToolsItem::ToolSearchToolBM2520251119(
        @json.from_json(value, path~),
      )
    "tool_search_tool_bm25" =>
      CreateMessageParamsToolsItem::ToolSearchToolBM2520251119(
        @json.from_json(value, path~),
      )
    "tool_search_tool_regex_20251119" =>
      CreateMessageParamsToolsItem::ToolSearchToolRegex20251119(
        @json.from_json(value, path~),
      )
    "tool_search_tool_regex" =>
      CreateMessageParamsToolsItem::ToolSearchToolRegex20251119(
        @json.from_json(value, path~),
      )
    other => CreateMessageParamsToolsItem::Unknown(other, value)
  }
}

///|
///
/// The parameters of a request for the next message in a conversation. See the [Messages API guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages#basic-request-and-response) to learn more about requests and responses.
#derive(Eq, @debug.Debug)
pub(all) struct CreateMessageParams {
  model : String
  messages : Array[InputMessageUnion]
  cache_control : @sdkjson.Presence[CreateMessageParamsCacheControl]
  container : @sdkjson.Presence[CreateMessageParamsContainer]
  diagnostics : @sdkjson.Presence[DiagnosticsParam]
  inference_geo : @sdkjson.Presence[String]
  max_tokens : Int32
  metadata : Metadata?
  output_config : OutputConfig?
  service_tier : CreateMessageParamsServiceTier?
  speed : @sdkjson.Presence[Speed]
  stop_sequences : Array[String]?
  stream : Bool?
  system : CreateMessageParamsSystem?
  thinking : ThinkingConfigParam?
  tool_choice : ToolChoice?
  tools : Array[CreateMessageParamsToolsItem]?
}

///|
pub extend CreateMessageParams with Eq::{equal, not_equal}

///|
pub extend CreateMessageParams with @debug.Debug::{to_repr}

///|
///
/// Creates a CreateMessageParams with omitted optional fields absent.
pub fn CreateMessageParams::new(
  model~ : String,
  messages~ : Array[InputMessageUnion],
  max_tokens~ : Int32,
  cache_control? : CreateMessageParamsCacheControl,
  container? : CreateMessageParamsContainer,
  diagnostics? : DiagnosticsParam,
  inference_geo? : String,
  metadata? : Metadata,
  output_config? : OutputConfig,
  service_tier? : CreateMessageParamsServiceTier,
  speed? : Speed,
  stop_sequences? : Array[String],
  stream? : Bool,
  system? : CreateMessageParamsSystem,
  thinking? : ThinkingConfigParam,
  tool_choice? : ToolChoice,
  tools? : Array[CreateMessageParamsToolsItem],
) -> CreateMessageParams {
  {
    model,
    messages,
    cache_control: @sdkjson.Presence::from_option(cache_control),
    container: @sdkjson.Presence::from_option(container),
    diagnostics: @sdkjson.Presence::from_option(diagnostics),
    inference_geo: @sdkjson.Presence::from_option(inference_geo),
    max_tokens,
    metadata,
    output_config,
    service_tier,
    speed: @sdkjson.Presence::from_option(speed),
    stop_sequences,
    stream,
    system,
    thinking,
    tool_choice,
    tools,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend CreateMessageParams with ToJson::{to_json}

///|
pub impl ToJson for CreateMessageParams with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("model", self.model)
  .field("messages", self.messages)
  .presence("cache_control", self.cache_control)
  .presence("container", self.container)
  .presence("diagnostics", self.diagnostics)
  .presence("inference_geo", self.inference_geo)
  .field("max_tokens", self.max_tokens)
  .opt("metadata", self.metadata)
  .opt("output_config", self.output_config)
  .opt("service_tier", self.service_tier)
  .presence("speed", self.speed)
  .opt("stop_sequences", self.stop_sequences)
  .opt("stream", self.stream)
  .opt("system", self.system)
  .opt("thinking", self.thinking)
  .opt("tool_choice", self.tool_choice)
  .opt("tools", self.tools)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend CreateMessageParams with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for CreateMessageParams with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    model: required_field(obj, "model", path),
    messages: required_field(obj, "messages", path),
    cache_control: @sdkjson.presence_field(obj, "cache_control", path),
    container: @sdkjson.presence_field(obj, "container", path),
    diagnostics: @sdkjson.presence_field(obj, "diagnostics", path),
    inference_geo: @sdkjson.presence_field(obj, "inference_geo", path),
    max_tokens: required_field(obj, "max_tokens", path),
    metadata: @sdkjson.opt_field(obj, "metadata", path),
    output_config: @sdkjson.opt_field(obj, "output_config", path),
    service_tier: @sdkjson.opt_field(obj, "service_tier", path),
    speed: @sdkjson.presence_field(obj, "speed", path),
    stop_sequences: @sdkjson.opt_field(obj, "stop_sequences", path),
    stream: @sdkjson.opt_field(obj, "stream", path),
    system: @sdkjson.opt_field(obj, "system", path),
    thinking: @sdkjson.opt_field(obj, "thinking", path),
    tool_choice: @sdkjson.opt_field(obj, "tool_choice", path),
    tools: @sdkjson.opt_field(obj, "tools", path),
  }
}

///|
///
/// Request-level diagnostics: why the prompt cache could not fully reuse the prefix of the request named by `diagnostics.previous_message_id`.
#derive(Eq, @debug.Debug)
pub(all) struct Diagnostics {
  cache_miss_reason : CacheMissReason?
}

///|
pub extend Diagnostics with Eq::{equal, not_equal}

///|
pub extend Diagnostics with @debug.Debug::{to_repr}

///|
///
/// Creates a Diagnostics with omitted optional fields absent.
pub fn Diagnostics::new(cache_miss_reason? : CacheMissReason) -> Diagnostics {
  { cache_miss_reason, }
}

///|
///
/// Encodes this value as JSON.
pub extend Diagnostics with ToJson::{to_json}

///|
pub impl ToJson for Diagnostics with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence(
    "cache_miss_reason",
    nullable_presence(self.cache_miss_reason.map(value => value)),
  )
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend Diagnostics with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Diagnostics with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { cache_miss_reason: decode_nullable_field(obj, "cache_miss_reason", path), }
}

///|
///
/// Effort (reasoning_effort) capability details.
#derive(Eq, @debug.Debug)
pub(all) struct EffortCapability {
  high : CapabilitySupport
  low : CapabilitySupport
  max : CapabilitySupport
  medium : CapabilitySupport
  supported : Bool
  xhigh : CapabilitySupport?
}

///|
pub extend EffortCapability with Eq::{equal, not_equal}

///|
pub extend EffortCapability with @debug.Debug::{to_repr}

///|
///
/// Creates a EffortCapability with omitted optional fields absent.
pub fn EffortCapability::new(
  high~ : CapabilitySupport,
  low~ : CapabilitySupport,
  max~ : CapabilitySupport,
  medium~ : CapabilitySupport,
  supported~ : Bool,
  xhigh? : CapabilitySupport,
) -> EffortCapability {
  { high, low, max, medium, supported, xhigh, }
}

///|
///
/// Encodes this value as JSON.
pub extend EffortCapability with ToJson::{to_json}

///|
pub impl ToJson for EffortCapability with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("high", self.high)
  .field("low", self.low)
  .field("max", self.max)
  .field("medium", self.medium)
  .field("supported", self.supported)
  .presence("xhigh", nullable_presence(self.xhigh.map(value => value)))
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend EffortCapability with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for EffortCapability with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    high: required_field(obj, "high", path),
    low: required_field(obj, "low", path),
    max: required_field(obj, "max", path),
    medium: required_field(obj, "medium", path),
    supported: required_field(obj, "supported", path),
    xhigh: decode_nullable_field(obj, "xhigh", path),
  }
}

///|
///
/// The organization has crossed the monthly API usage threshold of its API tier.
#derive(Eq, @debug.Debug)
pub(all) struct EnforcedSpendLimitReachedErrorDetails {}

///|
pub extend EnforcedSpendLimitReachedErrorDetails with Eq::{equal, not_equal}

///|
pub extend EnforcedSpendLimitReachedErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend EnforcedSpendLimitReachedErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for EnforcedSpendLimitReachedErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "enforced_spend_limit_reached")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend EnforcedSpendLimitReachedErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for EnforcedSpendLimitReachedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  EnforcedSpendLimitReachedErrorDetails::{ }
}

///|
///
/// Generated representation of InvalidRequestError.
#derive(Eq, @debug.Debug)
pub(all) struct InvalidRequestError {
  message : String
  type_ : String
}

///|
pub extend InvalidRequestError with Eq::{equal, not_equal}

///|
pub extend InvalidRequestError with @debug.Debug::{to_repr}

///|
///
/// Creates a InvalidRequestError with omitted optional fields absent.
pub fn InvalidRequestError::new(
  message~ : String,
  type_~ : String,
) -> InvalidRequestError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend InvalidRequestError with ToJson::{to_json}

///|
pub impl ToJson for InvalidRequestError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend InvalidRequestError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for InvalidRequestError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of NotFoundError.
#derive(Eq, @debug.Debug)
pub(all) struct NotFoundError {
  message : String
  type_ : String
}

///|
pub extend NotFoundError with Eq::{equal, not_equal}

///|
pub extend NotFoundError with @debug.Debug::{to_repr}

///|
///
/// Creates a NotFoundError with omitted optional fields absent.
pub fn NotFoundError::new(message~ : String, type_~ : String) -> NotFoundError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend NotFoundError with ToJson::{to_json}

///|
pub impl ToJson for NotFoundError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend NotFoundError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for NotFoundError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of OverloadedError.
#derive(Eq, @debug.Debug)
pub(all) struct OverloadedError {
  message : String
  type_ : String
}

///|
pub extend OverloadedError with Eq::{equal, not_equal}

///|
pub extend OverloadedError with @debug.Debug::{to_repr}

///|
///
/// Creates a OverloadedError with omitted optional fields absent.
pub fn OverloadedError::new(
  message~ : String,
  type_~ : String,
) -> OverloadedError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend OverloadedError with ToJson::{to_json}

///|
pub impl ToJson for OverloadedError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend OverloadedError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for OverloadedError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of PermissionError.
#derive(Eq, @debug.Debug)
pub(all) struct PermissionError {
  message : String
  type_ : String
}

///|
pub extend PermissionError with Eq::{equal, not_equal}

///|
pub extend PermissionError with @debug.Debug::{to_repr}

///|
///
/// Creates a PermissionError with omitted optional fields absent.
pub fn PermissionError::new(
  message~ : String,
  type_~ : String,
) -> PermissionError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend PermissionError with ToJson::{to_json}

///|
pub impl ToJson for PermissionError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend PermissionError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for PermissionError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of RateLimitError.
#derive(Eq, @debug.Debug)
pub(all) struct RateLimitError {
  message : String
  type_ : String
}

///|
pub extend RateLimitError with Eq::{equal, not_equal}

///|
pub extend RateLimitError with @debug.Debug::{to_repr}

///|
///
/// Creates a RateLimitError with omitted optional fields absent.
pub fn RateLimitError::new(
  message~ : String,
  type_~ : String,
) -> RateLimitError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RateLimitError with ToJson::{to_json}

///|
pub impl ToJson for RateLimitError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RateLimitError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RateLimitError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of GatewayTimeoutError.
#derive(Eq, @debug.Debug)
pub(all) struct GatewayTimeoutError {
  message : String
  type_ : String
}

///|
pub extend GatewayTimeoutError with Eq::{equal, not_equal}

///|
pub extend GatewayTimeoutError with @debug.Debug::{to_repr}

///|
///
/// Creates a GatewayTimeoutError with omitted optional fields absent.
pub fn GatewayTimeoutError::new(
  message~ : String,
  type_~ : String,
) -> GatewayTimeoutError {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend GatewayTimeoutError with ToJson::{to_json}

///|
pub impl ToJson for GatewayTimeoutError with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend GatewayTimeoutError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for GatewayTimeoutError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union ErrorResponseError.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ErrorResponseError {
  ApiError(APIError)
  AuthenticationError(AuthenticationError)
  BillingError(BillingError)
  InvalidRequestError(InvalidRequestError)
  NotFoundError(NotFoundError)
  OverloadedError(OverloadedError)
  PermissionError(PermissionError)
  RateLimitError(RateLimitError)
  TimeoutError(GatewayTimeoutError)
  Unknown(String, Json)
}

///|
pub extend ErrorResponseError with Eq::{equal, not_equal}

///|
pub extend ErrorResponseError with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend ErrorResponseError with ToJson::{to_json}

///|
pub impl ToJson for ErrorResponseError with fn to_json(self) {
  match self {
    ErrorResponseError::ApiError(value) => @json.Json::Json(value)
    ErrorResponseError::AuthenticationError(value) => @json.Json::Json(value)
    ErrorResponseError::BillingError(value) => @json.Json::Json(value)
    ErrorResponseError::InvalidRequestError(value) => @json.Json::Json(value)
    ErrorResponseError::NotFoundError(value) => @json.Json::Json(value)
    ErrorResponseError::OverloadedError(value) => @json.Json::Json(value)
    ErrorResponseError::PermissionError(value) => @json.Json::Json(value)
    ErrorResponseError::RateLimitError(value) => @json.Json::Json(value)
    ErrorResponseError::TimeoutError(value) => @json.Json::Json(value)
    ErrorResponseError::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend ErrorResponseError with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ErrorResponseError with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "api_error" => ErrorResponseError::ApiError(@json.from_json(value, path~))
    "authentication_error" =>
      ErrorResponseError::AuthenticationError(@json.from_json(value, path~))
    "billing_error" =>
      ErrorResponseError::BillingError(@json.from_json(value, path~))
    "invalid_request_error" =>
      ErrorResponseError::InvalidRequestError(@json.from_json(value, path~))
    "not_found_error" =>
      ErrorResponseError::NotFoundError(@json.from_json(value, path~))
    "overloaded_error" =>
      ErrorResponseError::OverloadedError(@json.from_json(value, path~))
    "permission_error" =>
      ErrorResponseError::PermissionError(@json.from_json(value, path~))
    "rate_limit_error" =>
      ErrorResponseError::RateLimitError(@json.from_json(value, path~))
    "timeout_error" =>
      ErrorResponseError::TimeoutError(@json.from_json(value, path~))
    other => ErrorResponseError::Unknown(other, value)
  }
}

///|
///
/// Generated representation of ErrorResponse.
#derive(Eq, @debug.Debug)
pub(all) struct ErrorResponse {
  error : ErrorResponseError
  request_id : String?
}

///|
pub extend ErrorResponse with Eq::{equal, not_equal}

///|
pub extend ErrorResponse with @debug.Debug::{to_repr}

///|
///
/// Creates a ErrorResponse with omitted optional fields absent.
pub fn ErrorResponse::new(
  error~ : ErrorResponseError,
  request_id? : String,
) -> ErrorResponse {
  { error, request_id, }
}

///|
///
/// Encodes this value as JSON.
pub extend ErrorResponse with ToJson::{to_json}

///|
pub impl ToJson for ErrorResponse with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error", self.error)
  .presence(
    "request_id",
    nullable_presence(self.request_id.map(value => value)),
  )
  .field("type", "error")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ErrorResponse with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ErrorResponse with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    error: required_field(obj, "error", path),
    request_id: decode_nullable_field(obj, "request_id", path),
  }
}

///|
///
/// The longest side of one or more images in the request exceeds the image size limit. Scale each image in `paths` so that neither side exceeds `max_side_length_pixels`, or remove it, then retry.
#derive(Eq, @debug.Debug)
pub(all) struct ImageDimensionsTooLargeErrorDetails {
  max_side_length_pixels : Int32
  paths : Array[String]
}

///|
pub extend ImageDimensionsTooLargeErrorDetails with Eq::{equal, not_equal}

///|
pub extend ImageDimensionsTooLargeErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Creates a ImageDimensionsTooLargeErrorDetails with omitted optional fields absent.
pub fn ImageDimensionsTooLargeErrorDetails::new(
  max_side_length_pixels~ : Int32,
  paths~ : Array[String],
) -> ImageDimensionsTooLargeErrorDetails {
  { max_side_length_pixels, paths, }
}

///|
///
/// Encodes this value as JSON.
pub extend ImageDimensionsTooLargeErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ImageDimensionsTooLargeErrorDetails with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "image_dimensions_too_large")
  .field("max_side_length_pixels", self.max_side_length_pixels)
  .field("paths", self.paths)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ImageDimensionsTooLargeErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ImageDimensionsTooLargeErrorDetails with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  {
    max_side_length_pixels: required_field(obj, "max_side_length_pixels", path),
    paths: required_field(obj, "paths", path),
  }
}

///|
///
/// Anthropic cannot currently bill the organization linked to the request's user profile, for a reason that lies with that organization's own account. The response does not say what the reason is.
#derive(Eq, @debug.Debug)
pub(all) struct LinkedOrganizationBillingUnavailableErrorDetails {}

///|
pub extend LinkedOrganizationBillingUnavailableErrorDetails with Eq::{
  equal,
  not_equal,
}

///|
pub extend LinkedOrganizationBillingUnavailableErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend LinkedOrganizationBillingUnavailableErrorDetails with ToJson::{
  to_json,
}

///|
pub impl ToJson for LinkedOrganizationBillingUnavailableErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "linked_organization_billing_unavailable")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend LinkedOrganizationBillingUnavailableErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for LinkedOrganizationBillingUnavailableErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  LinkedOrganizationBillingUnavailableErrorDetails::{ }
}

///|
///
/// The organization linked to the request's user profile has reached a spend limit that it set, or lacks credit for the request. The response does not say which applies.
#derive(Eq, @debug.Debug)
pub(all) struct LinkedOrganizationSpendLimitReachedErrorDetails {}

///|
pub extend LinkedOrganizationSpendLimitReachedErrorDetails with Eq::{
  equal,
  not_equal,
}

///|
pub extend LinkedOrganizationSpendLimitReachedErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend LinkedOrganizationSpendLimitReachedErrorDetails with ToJson::{
  to_json,
}

///|
pub impl ToJson for LinkedOrganizationSpendLimitReachedErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "linked_organization_spend_limit_reached")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend LinkedOrganizationSpendLimitReachedErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for LinkedOrganizationSpendLimitReachedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  LinkedOrganizationSpendLimitReachedErrorDetails::{ }
}

///|
///
/// Web search and code execution tool support, with one entry per tool.
#derive(Eq, @debug.Debug)
pub(all) struct ServerToolsCapability {
  code_execution : CapabilitySupport
  supported : Bool
  web_search : CapabilitySupport
}

///|
pub extend ServerToolsCapability with Eq::{equal, not_equal}

///|
pub extend ServerToolsCapability with @debug.Debug::{to_repr}

///|
///
/// Creates a ServerToolsCapability with omitted optional fields absent.
pub fn ServerToolsCapability::new(
  code_execution~ : CapabilitySupport,
  supported~ : Bool,
  web_search~ : CapabilitySupport,
) -> ServerToolsCapability {
  { code_execution, supported, web_search, }
}

///|
///
/// Encodes this value as JSON.
pub extend ServerToolsCapability with ToJson::{to_json}

///|
pub impl ToJson for ServerToolsCapability with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("code_execution", self.code_execution)
  .field("supported", self.supported)
  .field("web_search", self.web_search)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ServerToolsCapability with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ServerToolsCapability with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    code_execution: required_field(obj, "code_execution", path),
    supported: required_field(obj, "supported", path),
    web_search: required_field(obj, "web_search", path),
  }
}

///|
///
/// Which `thinking.type` values the model accepts on requests. Read each key on its own: for example, `enabled` can be false while `disabled` is true.
#derive(Eq, @debug.Debug)
pub(all) struct ThinkingTypes {
  adaptive : CapabilitySupport
  between_tools : CapabilitySupport
  disabled : CapabilitySupport
  enabled : CapabilitySupport
}

///|
pub extend ThinkingTypes with Eq::{equal, not_equal}

///|
pub extend ThinkingTypes with @debug.Debug::{to_repr}

///|
///
/// Creates a ThinkingTypes with omitted optional fields absent.
pub fn ThinkingTypes::new(
  adaptive~ : CapabilitySupport,
  between_tools~ : CapabilitySupport,
  disabled~ : CapabilitySupport,
  enabled~ : CapabilitySupport,
) -> ThinkingTypes {
  { adaptive, between_tools, disabled, enabled, }
}

///|
///
/// Encodes this value as JSON.
pub extend ThinkingTypes with ToJson::{to_json}

///|
pub impl ToJson for ThinkingTypes with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("adaptive", self.adaptive)
  .field("between_tools", self.between_tools)
  .field("disabled", self.disabled)
  .field("enabled", self.enabled)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThinkingTypes with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingTypes with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    adaptive: required_field(obj, "adaptive", path),
    between_tools: required_field(obj, "between_tools", path),
    disabled: required_field(obj, "disabled", path),
    enabled: required_field(obj, "enabled", path),
  }
}

///|
///
/// Thinking capability details.
#derive(Eq, @debug.Debug)
pub(all) struct ThinkingCapability {
  supported : Bool
  types : ThinkingTypes
}

///|
pub extend ThinkingCapability with Eq::{equal, not_equal}

///|
pub extend ThinkingCapability with @debug.Debug::{to_repr}

///|
///
/// Creates a ThinkingCapability with omitted optional fields absent.
pub fn ThinkingCapability::new(
  supported~ : Bool,
  types~ : ThinkingTypes,
) -> ThinkingCapability {
  { supported, types, }
}

///|
///
/// Encodes this value as JSON.
pub extend ThinkingCapability with ToJson::{to_json}

///|
pub impl ToJson for ThinkingCapability with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("supported", self.supported)
  .field("types", self.types)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThinkingCapability with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThinkingCapability with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    supported: required_field(obj, "supported", path),
    types: required_field(obj, "types", path),
  }
}

///|
///
/// Model capability information.
#derive(Eq, @debug.Debug)
pub(all) struct ModelCapabilities {
  batch : CapabilitySupport
  citations : CapabilitySupport
  code_execution : CapabilitySupport
  context_management : ContextManagementCapability
  effort : EffortCapability
  image_input : CapabilitySupport
  pdf_input : CapabilitySupport
  server_tools : ServerToolsCapability
  structured_outputs : CapabilitySupport
  thinking : ThinkingCapability
}

///|
pub extend ModelCapabilities with Eq::{equal, not_equal}

///|
pub extend ModelCapabilities with @debug.Debug::{to_repr}

///|
///
/// Creates a ModelCapabilities with omitted optional fields absent.
pub fn ModelCapabilities::new(
  batch~ : CapabilitySupport,
  citations~ : CapabilitySupport,
  code_execution~ : CapabilitySupport,
  context_management~ : ContextManagementCapability,
  effort~ : EffortCapability,
  image_input~ : CapabilitySupport,
  pdf_input~ : CapabilitySupport,
  server_tools~ : ServerToolsCapability,
  structured_outputs~ : CapabilitySupport,
  thinking~ : ThinkingCapability,
) -> ModelCapabilities {
  {
    batch,
    citations,
    code_execution,
    context_management,
    effort,
    image_input,
    pdf_input,
    server_tools,
    structured_outputs,
    thinking,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ModelCapabilities with ToJson::{to_json}

///|
pub impl ToJson for ModelCapabilities with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("batch", self.batch)
  .field("citations", self.citations)
  .field("code_execution", self.code_execution)
  .field("context_management", self.context_management)
  .field("effort", self.effort)
  .field("image_input", self.image_input)
  .field("pdf_input", self.pdf_input)
  .field("server_tools", self.server_tools)
  .field("structured_outputs", self.structured_outputs)
  .field("thinking", self.thinking)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ModelCapabilities with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ModelCapabilities with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    batch: required_field(obj, "batch", path),
    citations: required_field(obj, "citations", path),
    code_execution: required_field(obj, "code_execution", path),
    context_management: required_field(obj, "context_management", path),
    effort: required_field(obj, "effort", path),
    image_input: required_field(obj, "image_input", path),
    pdf_input: required_field(obj, "pdf_input", path),
    server_tools: required_field(obj, "server_tools", path),
    structured_outputs: required_field(obj, "structured_outputs", path),
    thinking: required_field(obj, "thinking", path),
  }
}

///|
///
/// The model's current lifecycle stage. - `active`: The model is available for use, open to new adopters, and not scheduled for retirement. - `deprecated`: The model remains callable for organizations with existing access, but is headed for retirement and closed to new adopters. - `retired`: The model is no longer available for use; inference requests naming it fail. It remains in the catalogue as the historical record of its retirement.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ModelInfoLifecycle {
  Active
  Deprecated
  Retired
  Unknown(String)
}

///|
pub extend ModelInfoLifecycle with Eq::{equal, not_equal}

///|
pub extend ModelInfoLifecycle with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ModelInfoLifecycle with ToJson::{to_json}

///|
pub impl ToJson for ModelInfoLifecycle with fn to_json(self) {
  let raw = match self {
    ModelInfoLifecycle::Active => "active"
    ModelInfoLifecycle::Deprecated => "deprecated"
    ModelInfoLifecycle::Retired => "retired"
    ModelInfoLifecycle::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ModelInfoLifecycle with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ModelInfoLifecycle with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "active" => Option::Some(ModelInfoLifecycle::Active)
        "deprecated" => Option::Some(ModelInfoLifecycle::Deprecated)
        "retired" => Option::Some(ModelInfoLifecycle::Retired)
        _ => Option::None
      }
    },
    raw => ModelInfoLifecycle::Unknown(raw),
  )
}

///|
///
/// A Claude model line, such as `opus` or `sonnet`. More lines may be added as new values.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ModelLine {
  Haiku
  Sonnet
  Opus
  Fable
  Mythos
  Unknown(String)
}

///|
pub extend ModelLine with Eq::{equal, not_equal}

///|
pub extend ModelLine with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ModelLine with ToJson::{to_json}

///|
pub impl ToJson for ModelLine with fn to_json(self) {
  let raw = match self {
    ModelLine::Haiku => "haiku"
    ModelLine::Sonnet => "sonnet"
    ModelLine::Opus => "opus"
    ModelLine::Fable => "fable"
    ModelLine::Mythos => "mythos"
    ModelLine::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ModelLine with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ModelLine with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "haiku" => Option::Some(ModelLine::Haiku)
        "sonnet" => Option::Some(ModelLine::Sonnet)
        "opus" => Option::Some(ModelLine::Opus)
        "fable" => Option::Some(ModelLine::Fable)
        "mythos" => Option::Some(ModelLine::Mythos)
        _ => Option::None
      }
    },
    raw => ModelLine::Unknown(raw),
  )
}

///|
///
/// Generated representation of ModelInfo.
#derive(Eq, @debug.Debug)
pub(all) struct ModelInfo {
  capabilities : ModelCapabilities?
  created_at : String
  deprecated_at : String?
  display_name : String
  id : String
  lifecycle : ModelInfoLifecycle
  line : ModelLine?
  max_input_tokens : Int32?
  max_tokens : Int32?
  retires_at : String?
}

///|
pub extend ModelInfo with Eq::{equal, not_equal}

///|
pub extend ModelInfo with @debug.Debug::{to_repr}

///|
///
/// Creates a ModelInfo with omitted optional fields absent.
pub fn ModelInfo::new(
  created_at~ : String,
  display_name~ : String,
  id~ : String,
  lifecycle~ : ModelInfoLifecycle,
  capabilities? : ModelCapabilities,
  deprecated_at? : String,
  line? : ModelLine,
  max_input_tokens? : Int32,
  max_tokens? : Int32,
  retires_at? : String,
) -> ModelInfo {
  {
    capabilities,
    created_at,
    deprecated_at,
    display_name,
    id,
    lifecycle,
    line,
    max_input_tokens,
    max_tokens,
    retires_at,
  }
}

///|
///
/// Encodes this value as JSON.
pub extend ModelInfo with ToJson::{to_json}

///|
pub impl ToJson for ModelInfo with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence(
    "capabilities",
    nullable_presence(self.capabilities.map(value => value)),
  )
  .field("created_at", self.created_at)
  .presence(
    "deprecated_at",
    nullable_presence(self.deprecated_at.map(value => value)),
  )
  .field("display_name", self.display_name)
  .field("id", self.id)
  .field("lifecycle", self.lifecycle)
  .presence("line", nullable_presence(self.line.map(value => value)))
  .presence(
    "max_input_tokens",
    nullable_presence(self.max_input_tokens.map(value => value)),
  )
  .presence(
    "max_tokens",
    nullable_presence(self.max_tokens.map(value => value)),
  )
  .presence(
    "retires_at",
    nullable_presence(self.retires_at.map(value => value)),
  )
  .field("type", "model")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ModelInfo with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ModelInfo with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    capabilities: decode_nullable_field(obj, "capabilities", path),
    created_at: required_field(obj, "created_at", path),
    deprecated_at: decode_nullable_field(obj, "deprecated_at", path),
    display_name: required_field(obj, "display_name", path),
    id: required_field(obj, "id", path),
    lifecycle: required_field(obj, "lifecycle", path),
    line: decode_nullable_field(obj, "line", path),
    max_input_tokens: decode_nullable_field(obj, "max_input_tokens", path),
    max_tokens: decode_nullable_field(obj, "max_tokens", path),
    retires_at: decode_nullable_field(obj, "retires_at", path),
  }
}

///|
///
/// Generated representation of ListResponseModelInfo.
#derive(Eq, @debug.Debug)
pub(all) struct ListResponseModelInfo {
  data : Array[ModelInfo]
  first_id : String?
  has_more : Bool
  last_id : String?
}

///|
pub extend ListResponseModelInfo with Eq::{equal, not_equal}

///|
pub extend ListResponseModelInfo with @debug.Debug::{to_repr}

///|
///
/// Creates a ListResponseModelInfo with omitted optional fields absent.
pub fn ListResponseModelInfo::new(
  data~ : Array[ModelInfo],
  has_more~ : Bool,
  first_id? : String,
  last_id? : String,
) -> ListResponseModelInfo {
  { data, first_id, has_more, last_id, }
}

///|
///
/// Encodes this value as JSON.
pub extend ListResponseModelInfo with ToJson::{to_json}

///|
pub impl ToJson for ListResponseModelInfo with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("data", self.data)
  .presence("first_id", nullable_presence(self.first_id.map(value => value)))
  .field("has_more", self.has_more)
  .presence("last_id", nullable_presence(self.last_id.map(value => value)))
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ListResponseModelInfo with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ListResponseModelInfo with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    data: required_field(obj, "data", path),
    first_id: decode_nullable_field(obj, "first_id", path),
    has_more: required_field(obj, "has_more", path),
    last_id: decode_nullable_field(obj, "last_id", path),
  }
}

///|
///
/// Generated string enum StopReason.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum StopReason {
  EndTurn
  MaxTokens
  StopSequence
  ToolUse
  PauseTurn
  Refusal
  ModelContextWindowExceeded
  Unknown(String)
}

///|
pub extend StopReason with Eq::{equal, not_equal}

///|
pub extend StopReason with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend StopReason with ToJson::{to_json}

///|
pub impl ToJson for StopReason with fn to_json(self) {
  let raw = match self {
    StopReason::EndTurn => "end_turn"
    StopReason::MaxTokens => "max_tokens"
    StopReason::StopSequence => "stop_sequence"
    StopReason::ToolUse => "tool_use"
    StopReason::PauseTurn => "pause_turn"
    StopReason::Refusal => "refusal"
    StopReason::ModelContextWindowExceeded => "model_context_window_exceeded"
    StopReason::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend StopReason with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for StopReason with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "end_turn" => Option::Some(StopReason::EndTurn)
        "max_tokens" => Option::Some(StopReason::MaxTokens)
        "stop_sequence" => Option::Some(StopReason::StopSequence)
        "tool_use" => Option::Some(StopReason::ToolUse)
        "pause_turn" => Option::Some(StopReason::PauseTurn)
        "refusal" => Option::Some(StopReason::Refusal)
        "model_context_window_exceeded" =>
          Option::Some(StopReason::ModelContextWindowExceeded)
        _ => Option::None
      }
    },
    raw => StopReason::Unknown(raw),
  )
}

///|
///
/// The policy category that triggered a refusal.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum RefusalCategory {
  Cyber
  Bio
  FrontierLlm
  ReasoningExtraction
  GeneralHarms
  Unknown(String)
}

///|
pub extend RefusalCategory with Eq::{equal, not_equal}

///|
pub extend RefusalCategory with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend RefusalCategory with ToJson::{to_json}

///|
pub impl ToJson for RefusalCategory with fn to_json(self) {
  let raw = match self {
    RefusalCategory::Cyber => "cyber"
    RefusalCategory::Bio => "bio"
    RefusalCategory::FrontierLlm => "frontier_llm"
    RefusalCategory::ReasoningExtraction => "reasoning_extraction"
    RefusalCategory::GeneralHarms => "general_harms"
    RefusalCategory::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend RefusalCategory with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RefusalCategory with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "cyber" => Option::Some(RefusalCategory::Cyber)
        "bio" => Option::Some(RefusalCategory::Bio)
        "frontier_llm" => Option::Some(RefusalCategory::FrontierLlm)
        "reasoning_extraction" =>
          Option::Some(RefusalCategory::ReasoningExtraction)
        "general_harms" => Option::Some(RefusalCategory::GeneralHarms)
        _ => Option::None
      }
    },
    raw => RefusalCategory::Unknown(raw),
  )
}

///|
///
/// Structured information about a refusal.
#derive(Eq, @debug.Debug)
pub(all) struct RefusalStopDetails {
  category : RefusalCategory?
  explanation : String?
  type_ : String
}

///|
pub extend RefusalStopDetails with Eq::{equal, not_equal}

///|
pub extend RefusalStopDetails with @debug.Debug::{to_repr}

///|
///
/// Creates a RefusalStopDetails with omitted optional fields absent.
pub fn RefusalStopDetails::new(
  type_~ : String,
  category? : RefusalCategory,
  explanation? : String,
) -> RefusalStopDetails {
  { category, explanation, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend RefusalStopDetails with ToJson::{to_json}

///|
pub impl ToJson for RefusalStopDetails with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("category", nullable_presence(self.category.map(value => value)))
  .presence(
    "explanation",
    nullable_presence(self.explanation.map(value => value)),
  )
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RefusalStopDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RefusalStopDetails with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    category: decode_nullable_field(obj, "category", path),
    explanation: decode_nullable_field(obj, "explanation", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated tagged union StopDetails.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum StopDetails {
  Refusal(RefusalStopDetails)
  Unknown(String, Json)
}

///|
pub extend StopDetails with Eq::{equal, not_equal}

///|
pub extend StopDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend StopDetails with ToJson::{to_json}

///|
pub impl ToJson for StopDetails with fn to_json(self) {
  match self {
    StopDetails::Refusal(value) => @json.Json::Json(value)
    StopDetails::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend StopDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for StopDetails with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "refusal" => StopDetails::Refusal(@json.from_json(value, path~))
    other => StopDetails::Unknown(other, value)
  }
}

///|
///
/// Generated representation of OutputTokensDetails.
#derive(Eq, @debug.Debug)
pub(all) struct OutputTokensDetails {
  thinking_tokens : Int32
}

///|
pub extend OutputTokensDetails with Eq::{equal, not_equal}

///|
pub extend OutputTokensDetails with @debug.Debug::{to_repr}

///|
///
/// Creates a OutputTokensDetails with omitted optional fields absent.
pub fn OutputTokensDetails::new(
  thinking_tokens~ : Int32,
) -> OutputTokensDetails {
  { thinking_tokens, }
}

///|
///
/// Encodes this value as JSON.
pub extend OutputTokensDetails with ToJson::{to_json}

///|
pub impl ToJson for OutputTokensDetails with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("thinking_tokens", self.thinking_tokens)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend OutputTokensDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for OutputTokensDetails with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { thinking_tokens: required_field(obj, "thinking_tokens", path), }
}

///|
///
/// Generated representation of ServerToolUsage.
#derive(Eq, @debug.Debug)
pub(all) struct ServerToolUsage {
  web_fetch_requests : Int32
  web_search_requests : Int32
}

///|
pub extend ServerToolUsage with Eq::{equal, not_equal}

///|
pub extend ServerToolUsage with @debug.Debug::{to_repr}

///|
///
/// Creates a ServerToolUsage with omitted optional fields absent.
pub fn ServerToolUsage::new(
  web_fetch_requests~ : Int32,
  web_search_requests~ : Int32,
) -> ServerToolUsage {
  { web_fetch_requests, web_search_requests, }
}

///|
///
/// Encodes this value as JSON.
pub extend ServerToolUsage with ToJson::{to_json}

///|
pub impl ToJson for ServerToolUsage with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("web_fetch_requests", self.web_fetch_requests)
  .field("web_search_requests", self.web_search_requests)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ServerToolUsage with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ServerToolUsage with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    web_fetch_requests: required_field(obj, "web_fetch_requests", path),
    web_search_requests: required_field(obj, "web_search_requests", path),
  }
}

///|
///
/// If the request used the priority, standard, or batch tier.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum UsageServiceTier {
  Standard
  Priority
  Batch
  Unknown(String)
}

///|
pub extend UsageServiceTier with Eq::{equal, not_equal}

///|
pub extend UsageServiceTier with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend UsageServiceTier with ToJson::{to_json}

///|
pub impl ToJson for UsageServiceTier with fn to_json(self) {
  let raw = match self {
    UsageServiceTier::Standard => "standard"
    UsageServiceTier::Priority => "priority"
    UsageServiceTier::Batch => "batch"
    UsageServiceTier::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend UsageServiceTier with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for UsageServiceTier with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "standard" => Option::Some(UsageServiceTier::Standard)
        "priority" => Option::Some(UsageServiceTier::Priority)
        "batch" => Option::Some(UsageServiceTier::Batch)
        _ => Option::None
      }
    },
    raw => UsageServiceTier::Unknown(raw),
  )
}

///|
///
/// Generated representation of Usage.
#derive(Eq, @debug.Debug)
pub(all) struct Usage {
  cache_creation : @sdkjson.Presence[CacheCreation]
  cache_creation_input_tokens : @sdkjson.Presence[Int32]
  cache_read_input_tokens : @sdkjson.Presence[Int32]
  inference_geo : @sdkjson.Presence[String]
  input_tokens : Int32
  output_tokens : Int32
  output_tokens_details : @sdkjson.Presence[OutputTokensDetails]
  server_tool_use : @sdkjson.Presence[ServerToolUsage]
  service_tier : @sdkjson.Presence[UsageServiceTier]
  speed : @sdkjson.Presence[Speed]
}

///|
pub extend Usage with Eq::{equal, not_equal}

///|
pub extend Usage with @debug.Debug::{to_repr}

///|
///
/// Creates a Usage with omitted optional fields absent.
pub fn Usage::new(
  input_tokens~ : Int32,
  output_tokens~ : Int32,
  cache_creation? : CacheCreation,
  cache_creation_input_tokens? : Int32,
  cache_read_input_tokens? : Int32,
  inference_geo? : String,
  output_tokens_details? : OutputTokensDetails,
  server_tool_use? : ServerToolUsage,
  service_tier? : UsageServiceTier,
  speed? : Speed,
) -> Usage {
  {
    cache_creation: @sdkjson.Presence::from_option(cache_creation),
    cache_creation_input_tokens: @sdkjson.Presence::from_option(
      cache_creation_input_tokens,
    ),
    cache_read_input_tokens: @sdkjson.Presence::from_option(
      cache_read_input_tokens,
    ),
    inference_geo: @sdkjson.Presence::from_option(inference_geo),
    input_tokens,
    output_tokens,
    output_tokens_details: @sdkjson.Presence::from_option(output_tokens_details),
    server_tool_use: @sdkjson.Presence::from_option(server_tool_use),
    service_tier: @sdkjson.Presence::from_option(service_tier),
    speed: @sdkjson.Presence::from_option(speed),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend Usage with ToJson::{to_json}

///|
pub impl ToJson for Usage with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_creation", self.cache_creation)
  .presence("cache_creation_input_tokens", self.cache_creation_input_tokens)
  .presence("cache_read_input_tokens", self.cache_read_input_tokens)
  .presence("inference_geo", self.inference_geo)
  .field("input_tokens", self.input_tokens)
  .field("output_tokens", self.output_tokens)
  .presence("output_tokens_details", self.output_tokens_details)
  .presence("server_tool_use", self.server_tool_use)
  .presence("service_tier", self.service_tier)
  .presence("speed", self.speed)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend Usage with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Usage with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_creation: @sdkjson.presence_field(obj, "cache_creation", path),
    cache_creation_input_tokens: @sdkjson.presence_field(
      obj, "cache_creation_input_tokens", path,
    ),
    cache_read_input_tokens: @sdkjson.presence_field(
      obj, "cache_read_input_tokens", path,
    ),
    inference_geo: @sdkjson.presence_field(obj, "inference_geo", path),
    input_tokens: required_field(obj, "input_tokens", path),
    output_tokens: required_field(obj, "output_tokens", path),
    output_tokens_details: @sdkjson.presence_field(
      obj, "output_tokens_details", path,
    ),
    server_tool_use: @sdkjson.presence_field(obj, "server_tool_use", path),
    service_tier: @sdkjson.presence_field(obj, "service_tier", path),
    speed: @sdkjson.presence_field(obj, "speed", path),
  }
}

///|
///
/// Generated representation of Message.
#derive(Eq, @debug.Debug)
pub(all) struct Message {
  id : String
  content : Array[ContentBlock]
  model : String
  stop_reason : StopReason?
  stop_sequence : @sdkjson.Presence[String]
  stop_details : @sdkjson.Presence[StopDetails]
  usage : Usage
  diagnostics : @sdkjson.Presence[Diagnostics]
  container : @sdkjson.Presence[Container]
}

///|
pub extend Message with Eq::{equal, not_equal}

///|
pub extend Message with @debug.Debug::{to_repr}

///|
///
/// Creates a Message with omitted optional fields absent.
pub fn Message::new(
  id~ : String,
  content~ : Array[ContentBlock],
  model~ : String,
  usage~ : Usage,
  stop_reason? : StopReason,
  stop_sequence? : String,
  stop_details? : StopDetails,
  diagnostics? : Diagnostics,
  container? : Container,
) -> Message {
  {
    id,
    content,
    model,
    stop_reason,
    stop_sequence: @sdkjson.Presence::from_option(stop_sequence),
    stop_details: @sdkjson.Presence::from_option(stop_details),
    usage,
    diagnostics: @sdkjson.Presence::from_option(diagnostics),
    container: @sdkjson.Presence::from_option(container),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend Message with ToJson::{to_json}

///|
pub impl ToJson for Message with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("id", self.id)
  .field("type", "message")
  .field("role", "assistant")
  .field("content", self.content)
  .field("model", self.model)
  .presence(
    "stop_reason",
    nullable_presence(self.stop_reason.map(value => value)),
  )
  .presence("stop_sequence", self.stop_sequence)
  .presence("stop_details", self.stop_details)
  .field("usage", self.usage)
  .presence("diagnostics", self.diagnostics)
  .presence("container", self.container)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend Message with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for Message with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    id: required_field(obj, "id", path),
    content: required_field(obj, "content", path),
    model: required_field(obj, "model", path),
    stop_reason: decode_nullable_field(obj, "stop_reason", path),
    stop_sequence: @sdkjson.presence_field(obj, "stop_sequence", path),
    stop_details: @sdkjson.presence_field(obj, "stop_details", path),
    usage: required_field(obj, "usage", path),
    diagnostics: @sdkjson.presence_field(obj, "diagnostics", path),
    container: @sdkjson.presence_field(obj, "container", path),
  }
}

///|
///
/// Generated representation of MessageDelta.
#derive(Eq, @debug.Debug)
pub(all) struct MessageDelta {
  container : @sdkjson.Presence[Container]
  stop_details : @sdkjson.Presence[StopDetails]
  stop_reason : StopReason?
  stop_sequence : @sdkjson.Presence[String]
}

///|
pub extend MessageDelta with Eq::{equal, not_equal}

///|
pub extend MessageDelta with @debug.Debug::{to_repr}

///|
///
/// Creates a MessageDelta with omitted optional fields absent.
pub fn MessageDelta::new(
  container? : Container,
  stop_details? : StopDetails,
  stop_reason? : StopReason,
  stop_sequence? : String,
) -> MessageDelta {
  {
    container: @sdkjson.Presence::from_option(container),
    stop_details: @sdkjson.Presence::from_option(stop_details),
    stop_reason,
    stop_sequence: @sdkjson.Presence::from_option(stop_sequence),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend MessageDelta with ToJson::{to_json}

///|
pub impl ToJson for MessageDelta with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("container", self.container)
  .presence("stop_details", self.stop_details)
  .presence(
    "stop_reason",
    nullable_presence(self.stop_reason.map(value => value)),
  )
  .presence("stop_sequence", self.stop_sequence)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend MessageDelta with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for MessageDelta with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    container: @sdkjson.presence_field(obj, "container", path),
    stop_details: @sdkjson.presence_field(obj, "stop_details", path),
    stop_reason: decode_nullable_field(obj, "stop_reason", path),
    stop_sequence: @sdkjson.presence_field(obj, "stop_sequence", path),
  }
}

///|
///
/// Generated representation of MessageDeltaUsage.
#derive(Eq, @debug.Debug)
pub(all) struct MessageDeltaUsage {
  cache_creation_input_tokens : @sdkjson.Presence[Int32]
  cache_read_input_tokens : @sdkjson.Presence[Int32]
  input_tokens : @sdkjson.Presence[Int32]
  output_tokens : Int32
  output_tokens_details : @sdkjson.Presence[OutputTokensDetails]
  server_tool_use : @sdkjson.Presence[ServerToolUsage]
}

///|
pub extend MessageDeltaUsage with Eq::{equal, not_equal}

///|
pub extend MessageDeltaUsage with @debug.Debug::{to_repr}

///|
///
/// Creates a MessageDeltaUsage with omitted optional fields absent.
pub fn MessageDeltaUsage::new(
  output_tokens~ : Int32,
  cache_creation_input_tokens? : Int32,
  cache_read_input_tokens? : Int32,
  input_tokens? : Int32,
  output_tokens_details? : OutputTokensDetails,
  server_tool_use? : ServerToolUsage,
) -> MessageDeltaUsage {
  {
    cache_creation_input_tokens: @sdkjson.Presence::from_option(
      cache_creation_input_tokens,
    ),
    cache_read_input_tokens: @sdkjson.Presence::from_option(
      cache_read_input_tokens,
    ),
    input_tokens: @sdkjson.Presence::from_option(input_tokens),
    output_tokens,
    output_tokens_details: @sdkjson.Presence::from_option(output_tokens_details),
    server_tool_use: @sdkjson.Presence::from_option(server_tool_use),
  }
}

///|
///
/// Encodes this value as JSON.
pub extend MessageDeltaUsage with ToJson::{to_json}

///|
pub impl ToJson for MessageDeltaUsage with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("cache_creation_input_tokens", self.cache_creation_input_tokens)
  .presence("cache_read_input_tokens", self.cache_read_input_tokens)
  .presence("input_tokens", self.input_tokens)
  .field("output_tokens", self.output_tokens)
  .presence("output_tokens_details", self.output_tokens_details)
  .presence("server_tool_use", self.server_tool_use)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend MessageDeltaUsage with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for MessageDeltaUsage with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    cache_creation_input_tokens: @sdkjson.presence_field(
      obj, "cache_creation_input_tokens", path,
    ),
    cache_read_input_tokens: @sdkjson.presence_field(
      obj, "cache_read_input_tokens", path,
    ),
    input_tokens: @sdkjson.presence_field(obj, "input_tokens", path),
    output_tokens: required_field(obj, "output_tokens", path),
    output_tokens_details: @sdkjson.presence_field(
      obj, "output_tokens_details", path,
    ),
    server_tool_use: @sdkjson.presence_field(obj, "server_tool_use", path),
  }
}

///|
///
/// Generated representation of MessageDeltaEvent.
#derive(Eq, @debug.Debug)
pub(all) struct MessageDeltaEvent {
  delta : MessageDelta
  type_ : String
  usage : MessageDeltaUsage
}

///|
pub extend MessageDeltaEvent with Eq::{equal, not_equal}

///|
pub extend MessageDeltaEvent with @debug.Debug::{to_repr}

///|
///
/// Creates a MessageDeltaEvent with omitted optional fields absent.
pub fn MessageDeltaEvent::new(
  delta~ : MessageDelta,
  type_~ : String,
  usage~ : MessageDeltaUsage,
) -> MessageDeltaEvent {
  { delta, type_, usage, }
}

///|
///
/// Encodes this value as JSON.
pub extend MessageDeltaEvent with ToJson::{to_json}

///|
pub impl ToJson for MessageDeltaEvent with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("delta", self.delta)
  .field("type", self.type_)
  .field("usage", self.usage)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend MessageDeltaEvent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for MessageDeltaEvent with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    delta: required_field(obj, "delta", path),
    type_: required_field(obj, "type", path),
    usage: required_field(obj, "usage", path),
  }
}

///|
///
/// Generated representation of MessageStartEvent.
#derive(Eq, @debug.Debug)
pub(all) struct MessageStartEvent {
  message : Message
  type_ : String
}

///|
pub extend MessageStartEvent with Eq::{equal, not_equal}

///|
pub extend MessageStartEvent with @debug.Debug::{to_repr}

///|
///
/// Creates a MessageStartEvent with omitted optional fields absent.
pub fn MessageStartEvent::new(
  message~ : Message,
  type_~ : String,
) -> MessageStartEvent {
  { message, type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend MessageStartEvent with ToJson::{to_json}

///|
pub impl ToJson for MessageStartEvent with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("message", self.message)
  .field("type", self.type_)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend MessageStartEvent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for MessageStartEvent with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  {
    message: required_field(obj, "message", path),
    type_: required_field(obj, "type", path),
  }
}

///|
///
/// Generated representation of MessageStopEvent.
#derive(Eq, @debug.Debug)
pub(all) struct MessageStopEvent {
  type_ : String
}

///|
pub extend MessageStopEvent with Eq::{equal, not_equal}

///|
pub extend MessageStopEvent with @debug.Debug::{to_repr}

///|
///
/// Creates a MessageStopEvent with omitted optional fields absent.
pub fn MessageStopEvent::new(type_~ : String) -> MessageStopEvent {
  { type_, }
}

///|
///
/// Encodes this value as JSON.
pub extend MessageStopEvent with ToJson::{to_json}

///|
pub impl ToJson for MessageStopEvent with fn to_json(self) {
  @sdkjson.ObjBuilder::new().field("type", self.type_).build()
}

///|
///
/// Decodes this value from JSON.
pub extend MessageStopEvent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for MessageStopEvent with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  { type_: required_field(obj, "type", path), }
}

///|
///
/// Generated tagged union MessageStreamEvent.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum MessageStreamEvent {
  ContentBlockDelta(ContentBlockDeltaEvent)
  ContentBlockStart(ContentBlockStartEvent)
  ContentBlockStop(ContentBlockStopEvent)
  MessageDelta(MessageDeltaEvent)
  MessageStart(MessageStartEvent)
  MessageStop(MessageStopEvent)
  Unknown(String, Json)
}

///|
pub extend MessageStreamEvent with Eq::{equal, not_equal}

///|
pub extend MessageStreamEvent with @debug.Debug::{to_repr}

///|
///
/// Encodes this tagged union as JSON.
pub extend MessageStreamEvent with ToJson::{to_json}

///|
pub impl ToJson for MessageStreamEvent with fn to_json(self) {
  match self {
    MessageStreamEvent::ContentBlockDelta(value) => @json.Json::Json(value)
    MessageStreamEvent::ContentBlockStart(value) => @json.Json::Json(value)
    MessageStreamEvent::ContentBlockStop(value) => @json.Json::Json(value)
    MessageStreamEvent::MessageDelta(value) => @json.Json::Json(value)
    MessageStreamEvent::MessageStart(value) => @json.Json::Json(value)
    MessageStreamEvent::MessageStop(value) => @json.Json::Json(value)
    MessageStreamEvent::Unknown(_, value) => value
  }
}

///|
///
/// Decodes this tagged union from JSON.
pub extend MessageStreamEvent with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for MessageStreamEvent with fn from_json(value, path) {
  let obj = @sdkjson.expect_object(value, path)
  let tag : String = required_field(obj, "type", path)
  match tag {
    "content_block_delta" =>
      MessageStreamEvent::ContentBlockDelta(@json.from_json(value, path~))
    "content_block_start" =>
      MessageStreamEvent::ContentBlockStart(@json.from_json(value, path~))
    "content_block_stop" =>
      MessageStreamEvent::ContentBlockStop(@json.from_json(value, path~))
    "message_delta" =>
      MessageStreamEvent::MessageDelta(@json.from_json(value, path~))
    "message_start" =>
      MessageStreamEvent::MessageStart(@json.from_json(value, path~))
    "message_stop" =>
      MessageStreamEvent::MessageStop(@json.from_json(value, path~))
    other => MessageStreamEvent::Unknown(other, value)
  }
}

///|
///
/// Anthropic has disabled the organization for trust and safety reasons. An organization disabled for any other reason, such as billing, does not get this code. `appeal_url`, when present, is where the organization can appeal.
#derive(Eq, @debug.Debug)
pub(all) struct OrganizationOnHoldErrorDetails {
  appeal_url : @sdkjson.Presence[String]
}

///|
pub extend OrganizationOnHoldErrorDetails with Eq::{equal, not_equal}

///|
pub extend OrganizationOnHoldErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Creates a OrganizationOnHoldErrorDetails with omitted optional fields absent.
pub fn OrganizationOnHoldErrorDetails::new(
  appeal_url? : String,
) -> OrganizationOnHoldErrorDetails {
  { appeal_url: @sdkjson.Presence::from_option(appeal_url), }
}

///|
///
/// Encodes this value as JSON.
pub extend OrganizationOnHoldErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for OrganizationOnHoldErrorDetails with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .presence("appeal_url", self.appeal_url)
  .field("error_code", "organization_on_hold")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend OrganizationOnHoldErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for OrganizationOnHoldErrorDetails with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { appeal_url: @sdkjson.presence_field(obj, "appeal_url", path), }
}

///|
///
/// The request would exceed a ramp limit, which caps how fast usage can grow. Retry after the time in the `retry-after` header.
#derive(Eq, @debug.Debug)
pub(all) struct RampLimitExceededErrorDetails {}

///|
pub extend RampLimitExceededErrorDetails with Eq::{equal, not_equal}

///|
pub extend RampLimitExceededErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend RampLimitExceededErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for RampLimitExceededErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new().field("error_code", "ramp_limit_exceeded").build()
}

///|
///
/// Decodes this value from JSON.
pub extend RampLimitExceededErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for RampLimitExceededErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  RampLimitExceededErrorDetails::{ }
}

///|
///
/// The request body is not valid for its `Content-Encoding`.
#derive(Eq, @debug.Debug)
pub(all) struct RequestBodyEncodingInvalidErrorDetails {}

///|
pub extend RequestBodyEncodingInvalidErrorDetails with Eq::{equal, not_equal}

///|
pub extend RequestBodyEncodingInvalidErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend RequestBodyEncodingInvalidErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for RequestBodyEncodingInvalidErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "request_body_encoding_invalid")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestBodyEncodingInvalidErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestBodyEncodingInvalidErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  RequestBodyEncodingInvalidErrorDetails::{ }
}

///|
///
/// The request's `Content-Encoding` is not supported.
#derive(Eq, @debug.Debug)
pub(all) struct RequestBodyEncodingUnsupportedErrorDetails {}

///|
pub extend RequestBodyEncodingUnsupportedErrorDetails with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestBodyEncodingUnsupportedErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend RequestBodyEncodingUnsupportedErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for RequestBodyEncodingUnsupportedErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "request_body_encoding_unsupported")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestBodyEncodingUnsupportedErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestBodyEncodingUnsupportedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  RequestBodyEncodingUnsupportedErrorDetails::{ }
}

///|
///
/// The compressed request body exceeds the request size limit once decoded.
#derive(Eq, @debug.Debug)
pub(all) struct RequestBodyTooLargeAfterDecodingErrorDetails {}

///|
pub extend RequestBodyTooLargeAfterDecodingErrorDetails with Eq::{
  equal,
  not_equal,
}

///|
pub extend RequestBodyTooLargeAfterDecodingErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend RequestBodyTooLargeAfterDecodingErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for RequestBodyTooLargeAfterDecodingErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "request_body_too_large_after_decoding")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend RequestBodyTooLargeAfterDecodingErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for RequestBodyTooLargeAfterDecodingErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  RequestBodyTooLargeAfterDecodingErrorDetails::{ }
}

///|
///
/// A custom skill the request names is stored under an encryption key state the workspace cannot currently decrypt.
#derive(Eq, @debug.Debug)
pub(all) struct SkillReadBlockedUndecryptableErrorDetails {}

///|
pub extend SkillReadBlockedUndecryptableErrorDetails with Eq::{equal, not_equal}

///|
pub extend SkillReadBlockedUndecryptableErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend SkillReadBlockedUndecryptableErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for SkillReadBlockedUndecryptableErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "skill_read_blocked_undecryptable")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend SkillReadBlockedUndecryptableErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for SkillReadBlockedUndecryptableErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  SkillReadBlockedUndecryptableErrorDetails::{ }
}

///|
///
/// The response that `previous_message_id` names has already been continued, and each response can be continued only once. Continue from the Thread's most recent response `id`.
#derive(Eq, @debug.Debug)
pub(all) struct ThreadAlreadyContinuedErrorDetails {}

///|
pub extend ThreadAlreadyContinuedErrorDetails with Eq::{equal, not_equal}

///|
pub extend ThreadAlreadyContinuedErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend ThreadAlreadyContinuedErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ThreadAlreadyContinuedErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "thread_already_continued")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThreadAlreadyContinuedErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThreadAlreadyContinuedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ThreadAlreadyContinuedErrorDetails::{ }
}

///|
///
/// Another request is still continuing from the same `previous_message_id`. Wait for it to complete and continue from its response `id`, or replay the full conversation with `thread: {"type": "create"}`.
#derive(Eq, @debug.Debug)
pub(all) struct ThreadContinueInFlightErrorDetails {}

///|
pub extend ThreadContinueInFlightErrorDetails with Eq::{equal, not_equal}

///|
pub extend ThreadContinueInFlightErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend ThreadContinueInFlightErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ThreadContinueInFlightErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "thread_continue_in_flight")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThreadContinueInFlightErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThreadContinueInFlightErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ThreadContinueInFlightErrorDetails::{ }
}

///|
///
/// A field that must stay the same across a Thread's turns differs from the value stored with the Thread; the message names each such field. Send the stored values, or replay the full conversation with `thread: {"type": "create"}` to change them.
#derive(Eq, @debug.Debug)
pub(all) struct ThreadFingerprintMismatchErrorDetails {}

///|
pub extend ThreadFingerprintMismatchErrorDetails with Eq::{equal, not_equal}

///|
pub extend ThreadFingerprintMismatchErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend ThreadFingerprintMismatchErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ThreadFingerprintMismatchErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "thread_fingerprint_mismatch")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThreadFingerprintMismatchErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ThreadFingerprintMismatchErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ThreadFingerprintMismatchErrorDetails::{ }
}

///|
///
/// No usable Thread state was found for `previous_message_id`. Replay the full conversation with `thread: {"type": "create"}` to start a new Thread.
#derive(Eq, @debug.Debug)
pub(all) struct ThreadNotFoundErrorDetails {}

///|
pub extend ThreadNotFoundErrorDetails with Eq::{equal, not_equal}

///|
pub extend ThreadNotFoundErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend ThreadNotFoundErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ThreadNotFoundErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new().field("error_code", "thread_not_found").build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThreadNotFoundErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThreadNotFoundErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ThreadNotFoundErrorDetails::{ }
}

///|
///
/// Generated string enum ThreadUnsupportedRequestErrorDetailsUnsupportedItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ThreadUnsupportedRequestErrorDetailsUnsupportedItem {
  CacheControl
  ContextManagement
  Fallbacks
  Hipaa
  InferenceHooks
  Thinking
  Unknown(String)
}

///|
pub extend ThreadUnsupportedRequestErrorDetailsUnsupportedItem with Eq::{
  equal,
  not_equal,
}

///|
pub extend ThreadUnsupportedRequestErrorDetailsUnsupportedItem with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this string enum as JSON.
pub extend ThreadUnsupportedRequestErrorDetailsUnsupportedItem with ToJson::{
  to_json,
}

///|
pub impl ToJson for ThreadUnsupportedRequestErrorDetailsUnsupportedItem with fn to_json(
  self,
) {
  let raw = match self {
    ThreadUnsupportedRequestErrorDetailsUnsupportedItem::CacheControl =>
      "cache_control"
    ThreadUnsupportedRequestErrorDetailsUnsupportedItem::ContextManagement =>
      "context_management"
    ThreadUnsupportedRequestErrorDetailsUnsupportedItem::Fallbacks =>
      "fallbacks"
    ThreadUnsupportedRequestErrorDetailsUnsupportedItem::Hipaa => "hipaa"
    ThreadUnsupportedRequestErrorDetailsUnsupportedItem::InferenceHooks =>
      "inference_hooks"
    ThreadUnsupportedRequestErrorDetailsUnsupportedItem::Thinking => "thinking"
    ThreadUnsupportedRequestErrorDetailsUnsupportedItem::Unknown(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ThreadUnsupportedRequestErrorDetailsUnsupportedItem with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for ThreadUnsupportedRequestErrorDetailsUnsupportedItem with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "cache_control" =>
          Option::Some(
            ThreadUnsupportedRequestErrorDetailsUnsupportedItem::CacheControl,
          )
        "context_management" =>
          Option::Some(
            ThreadUnsupportedRequestErrorDetailsUnsupportedItem::ContextManagement,
          )
        "fallbacks" =>
          Option::Some(
            ThreadUnsupportedRequestErrorDetailsUnsupportedItem::Fallbacks,
          )
        "hipaa" =>
          Option::Some(
            ThreadUnsupportedRequestErrorDetailsUnsupportedItem::Hipaa,
          )
        "inference_hooks" =>
          Option::Some(
            ThreadUnsupportedRequestErrorDetailsUnsupportedItem::InferenceHooks,
          )
        "thinking" =>
          Option::Some(
            ThreadUnsupportedRequestErrorDetailsUnsupportedItem::Thinking,
          )
        _ => Option::None
      }
    },
    raw => ThreadUnsupportedRequestErrorDetailsUnsupportedItem::Unknown(raw),
  )
}

///|
///
/// The request combines `thread` with a request field or an organization setting that Threads do not support; `unsupported`, when present, names it. Send the full conversation without `thread`, or change that field.
#derive(Eq, @debug.Debug)
pub(all) struct ThreadUnsupportedRequestErrorDetails {
  unsupported : @sdkjson.Presence[
    Array[ThreadUnsupportedRequestErrorDetailsUnsupportedItem],
  ]
}

///|
pub extend ThreadUnsupportedRequestErrorDetails with Eq::{equal, not_equal}

///|
pub extend ThreadUnsupportedRequestErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Creates a ThreadUnsupportedRequestErrorDetails with omitted optional fields absent.
pub fn ThreadUnsupportedRequestErrorDetails::new(
  unsupported? : Array[ThreadUnsupportedRequestErrorDetailsUnsupportedItem],
) -> ThreadUnsupportedRequestErrorDetails {
  { unsupported: @sdkjson.Presence::from_option(unsupported), }
}

///|
///
/// Encodes this value as JSON.
pub extend ThreadUnsupportedRequestErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ThreadUnsupportedRequestErrorDetails with fn to_json(self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "thread_unsupported_request")
  .presence("unsupported", self.unsupported)
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ThreadUnsupportedRequestErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ThreadUnsupportedRequestErrorDetails with fn from_json(
  value,
  path,
) {
  let obj = @sdkjson.expect_object(value, path)
  { unsupported: @sdkjson.presence_field(obj, "unsupported", path), }
}

///|
///
/// A tool made available in `messages` takes a name that an available tool of another kind, or of another MCP server, already holds.
#derive(Eq, @debug.Debug)
pub(all) struct ToolNameConflictErrorDetails {}

///|
pub extend ToolNameConflictErrorDetails with Eq::{equal, not_equal}

///|
pub extend ToolNameConflictErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend ToolNameConflictErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ToolNameConflictErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new().field("error_code", "tool_name_conflict").build()
}

///|
///
/// Decodes this value from JSON.
pub extend ToolNameConflictErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolNameConflictErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ToolNameConflictErrorDetails::{ }
}

///|
///
/// A tool change or MCP tool listing references a tool or MCP server that is not defined at that position in the conversation.
#derive(Eq, @debug.Debug)
pub(all) struct ToolReferenceUnresolvedErrorDetails {}

///|
pub extend ToolReferenceUnresolvedErrorDetails with Eq::{equal, not_equal}

///|
pub extend ToolReferenceUnresolvedErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend ToolReferenceUnresolvedErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for ToolReferenceUnresolvedErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "tool_reference_unresolved")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend ToolReferenceUnresolvedErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ToolReferenceUnresolvedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  ToolReferenceUnresolvedErrorDetails::{ }
}

///|
///
/// The customer that the request's user profile represents has not authorized the caller to bill them, or the authorization that the request's credential uses has ended. The response does not say which applies.
#derive(Eq, @debug.Debug)
pub(all) struct UserProfileBillingNotAuthorizedErrorDetails {}

///|
pub extend UserProfileBillingNotAuthorizedErrorDetails with Eq::{
  equal,
  not_equal,
}

///|
pub extend UserProfileBillingNotAuthorizedErrorDetails with @debug.Debug::{
  to_repr,
}

///|
///
/// Encodes this value as JSON.
pub extend UserProfileBillingNotAuthorizedErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for UserProfileBillingNotAuthorizedErrorDetails with fn to_json(
  _self,
) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "user_profile_billing_not_authorized")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend UserProfileBillingNotAuthorizedErrorDetails with @json.FromJson::{
  from_json,
}

///|
pub impl @json.FromJson for UserProfileBillingNotAuthorizedErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  UserProfileBillingNotAuthorizedErrorDetails::{ }
}

///|
///
/// The request's user profile cannot be billed. The response gives no more specific error code and does not say what the reason is.
#derive(Eq, @debug.Debug)
pub(all) struct UserProfileNotBillableErrorDetails {}

///|
pub extend UserProfileNotBillableErrorDetails with Eq::{equal, not_equal}

///|
pub extend UserProfileNotBillableErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend UserProfileNotBillableErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for UserProfileNotBillableErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "user_profile_not_billable")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend UserProfileNotBillableErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for UserProfileNotBillableErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  UserProfileNotBillableErrorDetails::{ }
}

///|
///
/// The request sets `billing_policy.bill_to` to `"user_profile"` but names no user profile. Name the profile to bill in the `anthropic-user-profile-id` header.
#derive(Eq, @debug.Debug)
pub(all) struct UserProfileRequiredErrorDetails {}

///|
pub extend UserProfileRequiredErrorDetails with Eq::{equal, not_equal}

///|
pub extend UserProfileRequiredErrorDetails with @debug.Debug::{to_repr}

///|
///
/// Encodes this value as JSON.
pub extend UserProfileRequiredErrorDetails with ToJson::{to_json}

///|
pub impl ToJson for UserProfileRequiredErrorDetails with fn to_json(_self) {
  @sdkjson.ObjBuilder::new()
  .field("error_code", "user_profile_required")
  .build()
}

///|
///
/// Decodes this value from JSON.
pub extend UserProfileRequiredErrorDetails with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for UserProfileRequiredErrorDetails with fn from_json(
  value,
  path,
) {
  let _ = @sdkjson.expect_object(value, path)
  UserProfileRequiredErrorDetails::{ }
}

///|
///
/// Generated string enum ModelsListLifecycleItem.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ModelsListLifecycleItem {
  Active
  Deprecated
  Retired
  Custom(String)
}

///|
pub extend ModelsListLifecycleItem with Eq::{equal, not_equal}

///|
pub extend ModelsListLifecycleItem with @debug.Debug::{to_repr}

///|
///
/// Encodes this string enum as JSON.
pub extend ModelsListLifecycleItem with ToJson::{to_json}

///|
pub impl ToJson for ModelsListLifecycleItem with fn to_json(self) {
  let raw = match self {
    ModelsListLifecycleItem::Active => "active"
    ModelsListLifecycleItem::Deprecated => "deprecated"
    ModelsListLifecycleItem::Retired => "retired"
    ModelsListLifecycleItem::Custom(raw) => raw
  }
  @json.Json::Json(raw)
}

///|
///
/// Decodes this string enum from JSON.
pub extend ModelsListLifecycleItem with @json.FromJson::{from_json}

///|
pub impl @json.FromJson for ModelsListLifecycleItem with fn from_json(
  value,
  path,
) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "active" => Option::Some(ModelsListLifecycleItem::Active)
        "deprecated" => Option::Some(ModelsListLifecycleItem::Deprecated)
        "retired" => Option::Some(ModelsListLifecycleItem::Retired)
        _ => Option::None
      }
    },
    raw => ModelsListLifecycleItem::Custom(raw),
  )
}