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

///|
fn json_array_matches(value : Json, predicate : (Json) -> Bool) -> Bool {
  match value {
    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) {
    None =>
      raise @json.JsonDecodeError(
        (field_path, "required だが欠落: " + field_path.to_string()),
      )
    Some(value) => @json.from_json(value, path=field_path)
  }
}

///|
fn[T] nullable_presence(value : T?) -> @sdkjson.Presence[T] {
  match value {
    Some(value) => @sdkjson.Value(value)
    None => @sdkjson.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 {
    Null => None
    value => 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) {
    Some(value) => @json.from_json(value, path=path.add_key(key))
    None => @json.from_json(default, path=path.add_key(key))
  }
}

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

///|
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).
pub(all) enum AllowedCaller {
  Direct
  CodeExecution20250825
  CodeExecution20260120
  CodeExecution20260521
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Direct => "direct"
    CodeExecution20250825 => "code_execution_20250825"
    CodeExecution20260120 => "code_execution_20260120"
    CodeExecution20260521 => "code_execution_20260521"
    Custom(raw) => raw
  }
  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" => Some(Direct)
        "code_execution_20250825" => Some(CodeExecution20250825)
        "code_execution_20260120" => Some(CodeExecution20260120)
        "code_execution_20260521" => Some(CodeExecution20260521)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

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

///|
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),
  }
}

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

///|
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 {
    ImageJpeg => "image/jpeg"
    ImagePng => "image/png"
    ImageGif => "image/gif"
    ImageWebp => "image/webp"
    Custom(raw) => raw
  }
  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" => Some(ImageJpeg)
        "image/png" => Some(ImagePng)
        "image/gif" => Some(ImageGif)
        "image/webp" => Some(ImageWebp)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

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

///|
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 Base64PDFSource.
pub(all) struct Base64PDFSource {
  data : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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),
  }
}

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

///|
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 {
    InvalidToolInput => "invalid_tool_input"
    Unavailable => "unavailable"
    TooManyRequests => "too_many_requests"
    ExecutionTimeExceeded => "execution_time_exceeded"
    OutputFileTooLarge => "output_file_too_large"
    Unknown(raw) => raw
  }
  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" => Some(InvalidToolInput)
        "unavailable" => Some(Unavailable)
        "too_many_requests" => Some(TooManyRequests)
        "execution_time_exceeded" => Some(ExecutionTimeExceeded)
        "output_file_too_large" => Some(OutputFileTooLarge)
        _ => None
      }
    },
    raw => Unknown(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.
pub(all) enum CacheControlEphemeralTtl {
  Value5m
  Value1h
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Value5m => "5m"
    Value1h => "1h"
    Custom(raw) => raw
  }
  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" => Some(Value5m)
        "1h" => Some(Value1h)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

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

///|
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.
pub(all) enum BashTool20250124CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of BashTool20250124.
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
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BillingError {
  message : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserCloseTabConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserDoubleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserFileUploadConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserFindConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserFormInputConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserGetPageTextConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserHoldKeyConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserHoverConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserJavascriptExecConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserKeyConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserLeftClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserLeftClickDragConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserLeftMouseDownConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserLeftMouseUpConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserListTabsConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserMiddleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserMouseMoveConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserNavigateConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserNewTabConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserReadConsoleConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserReadNetworkConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserReadPageConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserRightClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserScreenshotConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserScrollConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserScrollToConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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),
  }
}

///|
///
/// 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).
pub(all) struct BrowserStateChangeDownloadCompleted {
  download_id : String
  path : @sdkjson.Presence[String]
  size_bytes : @sdkjson.Presence[Int]
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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? : Int,
) -> 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.
pub(all) struct BrowserStateChangeDownloadFailed {
  download_id : String
  error : @sdkjson.Presence[String]
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserStateChangeDownloadStarted {
  download_id : String
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserStateChangeTabOpened {
  tab_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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),
  }
}

///|
///
/// 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.
pub(all) struct BrowserStateTabEntry {
  active : Bool?
  tab_id : String
  title : String
  url : String
} derive(Eq, @debug.Debug)

///|
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),
  }
}

///|
///
/// ``switch_tab``'s config overrides.
pub(all) struct BrowserSwitchTabConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserTripleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserTypeConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserWaitConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct BrowserZoomConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
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]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum BrowserToolset20260801CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => 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.
pub(all) struct BrowserToolset20260801 {
  cache_control : @sdkjson.Presence[BrowserToolset20260801CacheControl]
  configs : @sdkjson.Presence[BrowserToolsetConfigs]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct CacheCreation {
  ephemeral_1h_input_tokens : Int
  ephemeral_5m_input_tokens : Int
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  ephemeral_5m_input_tokens~ : Int,
) -> 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,
    ),
  }
}

///|
///
/// Generated representation of CacheMissMessagesChanged.
pub(all) struct CacheMissMessagesChanged {
  cache_missed_input_tokens : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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),
  }
}

///|
///
/// Generated representation of CacheMissModelChanged.
pub(all) struct CacheMissModelChanged {
  cache_missed_input_tokens : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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),
  }
}

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

///|
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), }
}

///|
///
/// Generated representation of CacheMissSystemChanged.
pub(all) struct CacheMissSystemChanged {
  cache_missed_input_tokens : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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),
  }
}

///|
///
/// Generated representation of CacheMissToolsChanged.
pub(all) struct CacheMissToolsChanged {
  cache_missed_input_tokens : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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),
  }
}

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

///|
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.
pub(all) enum CacheMissReason {
  MessagesChanged(CacheMissMessagesChanged)
  ModelChanged(CacheMissModelChanged)
  PreviousMessageNotFound(CacheMissPreviousMessageNotFound)
  SystemChanged(CacheMissSystemChanged)
  ToolsChanged(CacheMissToolsChanged)
  Unavailable(CacheMissUnavailable)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    MessagesChanged(value) => Json(value)
    ModelChanged(value) => Json(value)
    PreviousMessageNotFound(value) => Json(value)
    SystemChanged(value) => Json(value)
    ToolsChanged(value) => Json(value)
    Unavailable(value) => Json(value)
    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" => MessagesChanged(@json.from_json(value, path~))
    "model_changed" => ModelChanged(@json.from_json(value, path~))
    "previous_message_not_found" =>
      PreviousMessageNotFound(@json.from_json(value, path~))
    "system_changed" => SystemChanged(@json.from_json(value, path~))
    "tools_changed" => ToolsChanged(@json.from_json(value, path~))
    "unavailable" => Unavailable(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Indicates whether a capability is supported.
pub(all) struct CapabilitySupport {
  supported : Bool
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseCharLocationCitation {
  cited_text : String
  document_index : Int
  document_title : String?
  end_char_index : Int
  file_id : String?
  start_char_index : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  end_char_index~ : Int,
  start_char_index~ : Int,
  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.
pub(all) struct ResponseContentBlockLocationCitation {
  cited_text : String
  document_index : Int
  document_title : String?
  end_block_index : Int
  file_id : String?
  start_block_index : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  end_block_index~ : Int,
  start_block_index~ : Int,
  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.
pub(all) struct ResponsePageLocationCitation {
  cited_text : String
  document_index : Int
  document_title : String?
  end_page_number : Int
  file_id : String?
  start_page_number : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  end_page_number~ : Int,
  start_page_number~ : Int,
  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.
pub(all) struct ResponseSearchResultLocationCitation {
  cited_text : String
  end_block_index : Int
  search_result_index : Int
  source : String
  start_block_index : Int
  title : String?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  search_result_index~ : Int,
  source~ : String,
  start_block_index~ : Int,
  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.
pub(all) struct ResponseWebSearchResultLocationCitation {
  cited_text : String
  encrypted_index : String
  title : String?
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum CitationsDeltaCitation {
  CharLocation(ResponseCharLocationCitation)
  ContentBlockLocation(ResponseContentBlockLocationCitation)
  PageLocation(ResponsePageLocationCitation)
  SearchResultLocation(ResponseSearchResultLocationCitation)
  WebSearchResultLocation(ResponseWebSearchResultLocationCitation)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CharLocation(value) => Json(value)
    ContentBlockLocation(value) => Json(value)
    PageLocation(value) => Json(value)
    SearchResultLocation(value) => Json(value)
    WebSearchResultLocation(value) => Json(value)
    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" => CharLocation(@json.from_json(value, path~))
    "content_block_location" =>
      ContentBlockLocation(@json.from_json(value, path~))
    "page_location" => PageLocation(@json.from_json(value, path~))
    "search_result_location" =>
      SearchResultLocation(@json.from_json(value, path~))
    "web_search_result_location" =>
      WebSearchResultLocation(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of CitationsDelta.
pub(all) struct CitationsDelta {
  citation : CitationsDeltaCitation
  type_ : String
} derive(Eq, @debug.Debug)

///|
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),
  }
}

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

///|
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 {
    InvalidToolInput => "invalid_tool_input"
    Unavailable => "unavailable"
    TooManyRequests => "too_many_requests"
    ExecutionTimeExceeded => "execution_time_exceeded"
    Unknown(raw) => raw
  }
  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" => Some(InvalidToolInput)
        "unavailable" => Some(Unavailable)
        "too_many_requests" => Some(TooManyRequests)
        "execution_time_exceeded" => Some(ExecutionTimeExceeded)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

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

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of CodeExecutionTool20250522.
pub(all) struct CodeExecutionTool20250522 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[CodeExecutionTool20250522CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum CodeExecutionTool20250825CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of CodeExecutionTool20250825.
pub(all) struct CodeExecutionTool20250825 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[CodeExecutionTool20250825CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum CodeExecutionTool20260120CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).
pub(all) struct CodeExecutionTool20260120 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[CodeExecutionTool20260120CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum CodeExecutionTool20260521CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Code execution tool with REPL state persistence.
pub(all) struct CodeExecutionTool20260521 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[CodeExecutionTool20260521CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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),
  }
}

///|
///
/// ``cursor_position``'s config overrides.
pub(all) struct ComputerCursorPositionConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerDoubleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerHoldKeyConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerKeyConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerLeftClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerLeftClickDragConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerLeftMouseDownConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerLeftMouseUpConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerMiddleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerMouseMoveConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerRightClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerScreenshotConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerScrollConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerTripleClickConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerTypeConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerWaitConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ComputerZoomConfig {
  defer_loading : @sdkjson.Presence[Bool]
  enabled : @sdkjson.Presence[Bool]
} derive(Eq, @debug.Debug)

///|
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.
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]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ComputerToolset20260801CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => 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``.
pub(all) struct ComputerToolset20260801 {
  cache_control : @sdkjson.Presence[ComputerToolset20260801CacheControl]
  configs : @sdkjson.Presence[ComputerToolsetConfigs]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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)
pub(all) enum ContainerSkillType {
  Anthropic
  Custom
  Unknown(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Anthropic => "anthropic"
    Custom => "custom"
    Unknown(raw) => raw
  }
  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" => Some(Anthropic)
        "custom" => Some(Custom)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

///|
///
/// A skill that was loaded in a container (response model).
pub(all) struct ContainerSkill {
  skill_id : String
  type_ : ContainerSkillType
  version : String
} derive(Eq, @debug.Debug)

///|
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)
pub(all) struct Container {
  expires_at : String
  id : String
  skills : Array[ContainerSkill]?
} derive(Eq, @debug.Debug)

///|
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)
pub(all) enum SkillParamsType {
  Anthropic
  CustomSkill
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Anthropic => "anthropic"
    CustomSkill => "custom"
    Custom(raw) => raw
  }
  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" => Some(Anthropic)
        "custom" => Some(CustomSkill)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

///|
///
/// Specification for a skill to be loaded in a container (request model).
pub(all) struct SkillParams {
  skill_id : String
  type_ : SkillParamsType
  version : String?
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ContainerParams {
  id : @sdkjson.Presence[String]
  skills : @sdkjson.Presence[Array[SkillParams]]
} derive(Eq, @debug.Debug)

///|
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 InputJsonContentBlockDelta.
pub(all) struct InputJsonContentBlockDelta {
  partial_json : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct SignatureContentBlockDelta {
  signature : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct TextContentBlockDelta {
  text : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ThinkingContentBlockDelta {
  thinking : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ContentBlockDeltaEventDelta {
  CitationsDelta(CitationsDelta)
  InputJsonDelta(InputJsonContentBlockDelta)
  SignatureDelta(SignatureContentBlockDelta)
  TextDelta(TextContentBlockDelta)
  ThinkingDelta(ThinkingContentBlockDelta)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CitationsDelta(value) => Json(value)
    InputJsonDelta(value) => Json(value)
    SignatureDelta(value) => Json(value)
    TextDelta(value) => Json(value)
    ThinkingDelta(value) => Json(value)
    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" => CitationsDelta(@json.from_json(value, path~))
    "input_json_delta" => InputJsonDelta(@json.from_json(value, path~))
    "signature_delta" => SignatureDelta(@json.from_json(value, path~))
    "text_delta" => TextDelta(@json.from_json(value, path~))
    "thinking_delta" => ThinkingDelta(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ContentBlockDeltaEvent.
pub(all) struct ContentBlockDeltaEvent {
  delta : ContentBlockDeltaEventDelta
  index : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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),
  }
}

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

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) struct URLImageSource {
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestImageBlockSource {
  Base64(Base64ImageSource)
  File(FileImageSource)
  Url(URLImageSource)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Base64(value) => Json(value)
    File(value) => Json(value)
    Url(value) => Json(value)
    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" => Base64(@json.from_json(value, path~))
    "file" => File(@json.from_json(value, path~))
    "url" => Url(@json.from_json(value, path~))
    other => 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.
pub(all) enum RequestImageTransformationsOversizedImage {
  Downsize
  Error
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Downsize => "downsize"
    Error => "error"
    Custom(raw) => raw
  }
  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" => Some(Downsize)
        "error" => Some(Error)
        _ => None
      }
    },
    raw => 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.
pub(all) struct RequestImageTransformations {
  oversized_image : RequestImageTransformationsOversizedImage?
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct RequestImageBlock {
  cache_control : @sdkjson.Presence[RequestImageBlockCacheControl]
  source : RequestImageBlockSource
  transformations : @sdkjson.Presence[RequestImageTransformations]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestTextBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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~ : Int,
  end_char_index~ : Int,
  start_char_index~ : Int,
  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.
pub(all) struct RequestContentBlockLocationCitation {
  cited_text : String
  document_index : Int
  document_title : String?
  end_block_index : Int
  start_block_index : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  end_block_index~ : Int,
  start_block_index~ : Int,
  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.
pub(all) struct RequestPageLocationCitation {
  cited_text : String
  document_index : Int
  document_title : String?
  end_page_number : Int
  start_page_number : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  end_page_number~ : Int,
  start_page_number~ : Int,
  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.
pub(all) struct RequestSearchResultLocationCitation {
  cited_text : String
  end_block_index : Int
  search_result_index : Int
  source : String
  start_block_index : Int
  title : String?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  search_result_index~ : Int,
  source~ : String,
  start_block_index~ : Int,
  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.
pub(all) struct RequestWebSearchResultLocationCitation {
  cited_text : String
  encrypted_index : String
  title : String?
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestTextBlockCitationsItem {
  CharLocation(RequestCharLocationCitation)
  ContentBlockLocation(RequestContentBlockLocationCitation)
  PageLocation(RequestPageLocationCitation)
  SearchResultLocation(RequestSearchResultLocationCitation)
  WebSearchResultLocation(RequestWebSearchResultLocationCitation)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CharLocation(value) => Json(value)
    ContentBlockLocation(value) => Json(value)
    PageLocation(value) => Json(value)
    SearchResultLocation(value) => Json(value)
    WebSearchResultLocation(value) => Json(value)
    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" => CharLocation(@json.from_json(value, path~))
    "content_block_location" =>
      ContentBlockLocation(@json.from_json(value, path~))
    "page_location" => PageLocation(@json.from_json(value, path~))
    "search_result_location" =>
      SearchResultLocation(@json.from_json(value, path~))
    "web_search_result_location" =>
      WebSearchResultLocation(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum ContentBlockSourceContentValueArrayItem {
  Image(RequestImageBlock)
  Text(RequestTextBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Image(value) => Json(value)
    Text(value) => Json(value)
    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" => Image(@json.from_json(value, path~))
    "text" => Text(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    Text(value) => Json(value)
    ValueArray(value) => 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 String(_) {
    let decoded : String = @json.from_json(value, path~)
    return Text(decoded)
  }
  if json_array_matches(value, item => item is Object(_)) {
    let decoded : Array[ContentBlockSourceContentValueArrayItem] = @json.from_json(
      value,
      path~,
    )
    return ValueArray(decoded)
  }
  raise @json.JsonDecodeError(
    (path, "JSON shape does not match any ContentBlockSourceContent variant"),
  )
}

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

///|
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 ResponseBashCodeExecutionToolResultError.
pub(all) struct ResponseBashCodeExecutionToolResultError {
  error_code : BashCodeExecutionToolResultErrorCode
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseBashCodeExecutionOutputBlock {
  file_id : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseBashCodeExecutionResultBlock {
  content : Array[ResponseBashCodeExecutionOutputBlock]
  return_code : Int
  stderr : String
  stdout : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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.
pub(all) enum ResponseBashCodeExecutionToolResultBlockContent {
  BashCodeExecutionToolResultError(ResponseBashCodeExecutionToolResultError)
  BashCodeExecutionResult(ResponseBashCodeExecutionResultBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    BashCodeExecutionToolResultError(value) => Json(value)
    BashCodeExecutionResult(value) => Json(value)
    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" =>
      BashCodeExecutionToolResultError(@json.from_json(value, path~))
    "bash_code_execution_result" =>
      BashCodeExecutionResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseBashCodeExecutionToolResultBlock.
pub(all) struct ResponseBashCodeExecutionToolResultBlock {
  content : ResponseBashCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseCodeExecutionToolResultError {
  error_code : CodeExecutionToolResultErrorCode
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseCodeExecutionOutputBlock {
  file_id : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseCodeExecutionResultBlock {
  content : Array[ResponseCodeExecutionOutputBlock]
  return_code : Int
  stderr : String
  stdout : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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),
  }
}

///|
///
/// Code execution result with encrypted stdout for PFC + web_search results.
pub(all) struct ResponseEncryptedCodeExecutionResultBlock {
  content : Array[ResponseCodeExecutionOutputBlock]
  encrypted_stdout : String
  return_code : Int
  stderr : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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.
pub(all) enum ResponseCodeExecutionToolResultBlockContent {
  CodeExecutionToolResultError(ResponseCodeExecutionToolResultError)
  CodeExecutionResult(ResponseCodeExecutionResultBlock)
  EncryptedCodeExecutionResult(ResponseEncryptedCodeExecutionResultBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CodeExecutionToolResultError(value) => Json(value)
    CodeExecutionResult(value) => Json(value)
    EncryptedCodeExecutionResult(value) => Json(value)
    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" =>
      CodeExecutionToolResultError(@json.from_json(value, path~))
    "code_execution_result" =>
      CodeExecutionResult(@json.from_json(value, path~))
    "encrypted_code_execution_result" =>
      EncryptedCodeExecutionResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseCodeExecutionToolResultBlock.
pub(all) struct ResponseCodeExecutionToolResultBlock {
  content : ResponseCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseContainerUploadBlock {
  file_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseRedactedThinkingBlock {
  data : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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),
  }
}

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

///|
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.
pub(all) struct ServerToolCaller20260120 {
  tool_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct DirectCaller {
  type_ : String
} derive(Eq, @debug.Debug)

///|
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 ResponseServerToolUseBlockCaller.
pub(all) enum ResponseServerToolUseBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CodeExecution20250825(value) => Json(value)
    CodeExecution20260120(value) => Json(value)
    Direct(value) => Json(value)
    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" =>
      CodeExecution20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecution20260120(@json.from_json(value, path~))
    "direct" => Direct(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    WebSearch => "web_search"
    WebFetch => "web_fetch"
    CodeExecution => "code_execution"
    BashCodeExecution => "bash_code_execution"
    TextEditorCodeExecution => "text_editor_code_execution"
    ToolSearchToolRegex => "tool_search_tool_regex"
    ToolSearchToolBm25 => "tool_search_tool_bm25"
    Unknown(raw) => raw
  }
  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" => Some(WebSearch)
        "web_fetch" => Some(WebFetch)
        "code_execution" => Some(CodeExecution)
        "bash_code_execution" => Some(BashCodeExecution)
        "text_editor_code_execution" => Some(TextEditorCodeExecution)
        "tool_search_tool_regex" => Some(ToolSearchToolRegex)
        "tool_search_tool_bm25" => Some(ToolSearchToolBm25)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

///|
///
/// Generated representation of ResponseServerToolUseBlock.
pub(all) struct ResponseServerToolUseBlock {
  caller : ResponseServerToolUseBlockCaller
  id : String
  input : Json
  name : ResponseServerToolUseBlockName
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ResponseTextBlockCitationsItem {
  CharLocation(ResponseCharLocationCitation)
  ContentBlockLocation(ResponseContentBlockLocationCitation)
  PageLocation(ResponsePageLocationCitation)
  SearchResultLocation(ResponseSearchResultLocationCitation)
  WebSearchResultLocation(ResponseWebSearchResultLocationCitation)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CharLocation(value) => Json(value)
    ContentBlockLocation(value) => Json(value)
    PageLocation(value) => Json(value)
    SearchResultLocation(value) => Json(value)
    WebSearchResultLocation(value) => Json(value)
    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" => CharLocation(@json.from_json(value, path~))
    "content_block_location" =>
      ContentBlockLocation(@json.from_json(value, path~))
    "page_location" => PageLocation(@json.from_json(value, path~))
    "search_result_location" =>
      SearchResultLocation(@json.from_json(value, path~))
    "web_search_result_location" =>
      WebSearchResultLocation(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 string enum TextEditorCodeExecutionToolResultErrorCode.
pub(all) enum TextEditorCodeExecutionToolResultErrorCode {
  InvalidToolInput
  Unavailable
  TooManyRequests
  ExecutionTimeExceeded
  FileNotFound
  Unknown(String)
} derive(Eq, @debug.Debug)

///|
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 {
    InvalidToolInput => "invalid_tool_input"
    Unavailable => "unavailable"
    TooManyRequests => "too_many_requests"
    ExecutionTimeExceeded => "execution_time_exceeded"
    FileNotFound => "file_not_found"
    Unknown(raw) => raw
  }
  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" => Some(InvalidToolInput)
        "unavailable" => Some(Unavailable)
        "too_many_requests" => Some(TooManyRequests)
        "execution_time_exceeded" => Some(ExecutionTimeExceeded)
        "file_not_found" => Some(FileNotFound)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

///|
///
/// Generated representation of ResponseTextEditorCodeExecutionToolResultError.
pub(all) struct ResponseTextEditorCodeExecutionToolResultError {
  error_code : TextEditorCodeExecutionToolResultErrorCode
  error_message : String?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ResponseTextEditorCodeExecutionViewResultBlockFileType {
  Text
  Image
  Pdf
  Unknown(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Text => "text"
    Image => "image"
    Pdf => "pdf"
    Unknown(raw) => raw
  }
  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" => Some(Text)
        "image" => Some(Image)
        "pdf" => Some(Pdf)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

///|
///
/// Generated representation of ResponseTextEditorCodeExecutionViewResultBlock.
pub(all) struct ResponseTextEditorCodeExecutionViewResultBlock {
  content : String
  file_type : ResponseTextEditorCodeExecutionViewResultBlockFileType
  num_lines : Int?
  start_line : Int?
  total_lines : Int?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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? : Int,
  start_line? : Int,
  total_lines? : Int,
) -> 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.
pub(all) struct ResponseTextEditorCodeExecutionCreateResultBlock {
  is_file_update : Bool
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseTextEditorCodeExecutionStrReplaceResultBlock {
  lines : Array[String]?
  new_lines : Int?
  new_start : Int?
  old_lines : Int?
  old_start : Int?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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? : Int,
  new_start? : Int,
  old_lines? : Int,
  old_start? : Int,
) -> 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.
pub(all) enum ResponseTextEditorCodeExecutionToolResultBlockContent {
  TextEditorCodeExecutionToolResultError(
    ResponseTextEditorCodeExecutionToolResultError
  )
  TextEditorCodeExecutionViewResult(
    ResponseTextEditorCodeExecutionViewResultBlock
  )
  TextEditorCodeExecutionCreateResult(
    ResponseTextEditorCodeExecutionCreateResultBlock
  )
  TextEditorCodeExecutionStrReplaceResult(
    ResponseTextEditorCodeExecutionStrReplaceResultBlock
  )
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    TextEditorCodeExecutionToolResultError(value) => Json(value)
    TextEditorCodeExecutionViewResult(value) => Json(value)
    TextEditorCodeExecutionCreateResult(value) => Json(value)
    TextEditorCodeExecutionStrReplaceResult(value) => Json(value)
    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" =>
      TextEditorCodeExecutionToolResultError(@json.from_json(value, path~))
    "text_editor_code_execution_view_result" =>
      TextEditorCodeExecutionViewResult(@json.from_json(value, path~))
    "text_editor_code_execution_create_result" =>
      TextEditorCodeExecutionCreateResult(@json.from_json(value, path~))
    "text_editor_code_execution_str_replace_result" =>
      TextEditorCodeExecutionStrReplaceResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseTextEditorCodeExecutionToolResultBlock.
pub(all) struct ResponseTextEditorCodeExecutionToolResultBlock {
  content : ResponseTextEditorCodeExecutionToolResultBlockContent
  tool_use_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseThinkingBlock {
  signature : String
  thinking : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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 string enum ToolSearchToolResultErrorCode.
pub(all) enum ToolSearchToolResultErrorCode {
  InvalidToolInput
  Unavailable
  TooManyRequests
  ExecutionTimeExceeded
  Unknown(String)
} derive(Eq, @debug.Debug)

///|
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 {
    InvalidToolInput => "invalid_tool_input"
    Unavailable => "unavailable"
    TooManyRequests => "too_many_requests"
    ExecutionTimeExceeded => "execution_time_exceeded"
    Unknown(raw) => raw
  }
  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" => Some(InvalidToolInput)
        "unavailable" => Some(Unavailable)
        "too_many_requests" => Some(TooManyRequests)
        "execution_time_exceeded" => Some(ExecutionTimeExceeded)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

///|
///
/// Generated representation of ResponseToolSearchToolResultError.
pub(all) struct ResponseToolSearchToolResultError {
  error_code : ToolSearchToolResultErrorCode
  error_message : String?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseToolReferenceBlock {
  tool_name : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseToolSearchToolSearchResultBlock {
  tool_references : Array[ResponseToolReferenceBlock]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ResponseToolSearchToolResultBlockContent {
  ToolSearchToolResultError(ResponseToolSearchToolResultError)
  ToolSearchToolSearchResult(ResponseToolSearchToolSearchResultBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    ToolSearchToolResultError(value) => Json(value)
    ToolSearchToolSearchResult(value) => Json(value)
    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" =>
      ToolSearchToolResultError(@json.from_json(value, path~))
    "tool_search_tool_search_result" =>
      ToolSearchToolSearchResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseToolSearchToolResultBlock.
pub(all) struct ResponseToolSearchToolResultBlock {
  content : ResponseToolSearchToolResultBlockContent
  tool_use_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ResponseToolUseBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CodeExecution20250825(value) => Json(value)
    CodeExecution20260120(value) => Json(value)
    Direct(value) => Json(value)
    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" =>
      CodeExecution20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecution20260120(@json.from_json(value, path~))
    "direct" => Direct(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum ResponseWebFetchToolResultBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CodeExecution20250825(value) => Json(value)
    CodeExecution20260120(value) => Json(value)
    Direct(value) => Json(value)
    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" =>
      CodeExecution20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecution20260120(@json.from_json(value, path~))
    "direct" => Direct(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    InvalidToolInput => "invalid_tool_input"
    UrlTooLong => "url_too_long"
    UrlNotAllowed => "url_not_allowed"
    UrlNotInPriorContext => "url_not_in_prior_context"
    UrlNotAccessible => "url_not_accessible"
    UnsupportedContentType => "unsupported_content_type"
    TooManyRequests => "too_many_requests"
    MaxUsesExceeded => "max_uses_exceeded"
    Unavailable => "unavailable"
    ContentTooLarge => "content_too_large"
    Unknown(raw) => raw
  }
  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" => Some(InvalidToolInput)
        "url_too_long" => Some(UrlTooLong)
        "url_not_allowed" => Some(UrlNotAllowed)
        "url_not_in_prior_context" => Some(UrlNotInPriorContext)
        "url_not_accessible" => Some(UrlNotAccessible)
        "unsupported_content_type" => Some(UnsupportedContentType)
        "too_many_requests" => Some(TooManyRequests)
        "max_uses_exceeded" => Some(MaxUsesExceeded)
        "unavailable" => Some(Unavailable)
        "content_too_large" => Some(ContentTooLarge)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

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

///|
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.
pub(all) struct ResponseCitationsConfig {
  enabled : Bool
} derive(Eq, @debug.Debug)

///|
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 representation of PlainTextSource.
pub(all) struct PlainTextSource {
  data : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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 tagged union ResponseDocumentBlockSource.
pub(all) enum ResponseDocumentBlockSource {
  Base64(Base64PDFSource)
  Text(PlainTextSource)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Base64(value) => Json(value)
    Text(value) => Json(value)
    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" => Base64(@json.from_json(value, path~))
    "text" => Text(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseDocumentBlock.
pub(all) struct ResponseDocumentBlock {
  citations : ResponseCitationsConfig?
  source : ResponseDocumentBlockSource
  title : String?
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ResponseWebFetchResultBlock {
  content : ResponseDocumentBlock
  retrieved_at : String?
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ResponseWebFetchToolResultBlockContent {
  WebFetchToolResultError(ResponseWebFetchToolResultError)
  WebFetchResult(ResponseWebFetchResultBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    WebFetchToolResultError(value) => Json(value)
    WebFetchResult(value) => Json(value)
    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" =>
      WebFetchToolResultError(@json.from_json(value, path~))
    "web_fetch_result" => WebFetchResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ResponseWebFetchToolResultBlock.
pub(all) struct ResponseWebFetchToolResultBlock {
  caller : ResponseWebFetchToolResultBlockCaller
  content : ResponseWebFetchToolResultBlockContent
  tool_use_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ResponseWebSearchToolResultBlockCaller {
  CodeExecution20250825(ServerToolCaller)
  CodeExecution20260120(ServerToolCaller20260120)
  Direct(DirectCaller)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CodeExecution20250825(value) => Json(value)
    CodeExecution20260120(value) => Json(value)
    Direct(value) => Json(value)
    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" =>
      CodeExecution20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecution20260120(@json.from_json(value, path~))
    "direct" => Direct(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    InvalidToolInput => "invalid_tool_input"
    Unavailable => "unavailable"
    MaxUsesExceeded => "max_uses_exceeded"
    TooManyRequests => "too_many_requests"
    QueryTooLong => "query_too_long"
    RequestTooLarge => "request_too_large"
    Unknown(raw) => raw
  }
  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" => Some(InvalidToolInput)
        "unavailable" => Some(Unavailable)
        "max_uses_exceeded" => Some(MaxUsesExceeded)
        "too_many_requests" => Some(TooManyRequests)
        "query_too_long" => Some(QueryTooLong)
        "request_too_large" => Some(RequestTooLarge)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

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

///|
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.
pub(all) struct ResponseWebSearchResultBlock {
  encrypted_content : String
  page_age : String?
  title : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ResponseWebSearchToolResultBlockContent {
  ResponseWebSearchToolResultError(ResponseWebSearchToolResultError)
  ResponseWebSearchResultBlockArray(Array[ResponseWebSearchResultBlock])
} derive(Eq, @debug.Debug)

///|
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 {
    ResponseWebSearchToolResultError(value) => Json(value)
    ResponseWebSearchResultBlockArray(value) => 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 Object(_) {
    let decoded : ResponseWebSearchToolResultError = @json.from_json(
      value,
      path~,
    )
    return ResponseWebSearchToolResultError(decoded)
  }
  if json_array_matches(value, item => item is Object(_)) {
    let decoded : Array[ResponseWebSearchResultBlock] = @json.from_json(
      value,
      path~,
    )
    return ResponseWebSearchResultBlockArray(decoded)
  }
  raise @json.JsonDecodeError(
    (
      path, "JSON shape does not match any ResponseWebSearchToolResultBlockContent variant",
    ),
  )
}

///|
///
/// Generated representation of ResponseWebSearchToolResultBlock.
pub(all) struct ResponseWebSearchToolResultBlock {
  caller : ResponseWebSearchToolResultBlockCaller
  content : ResponseWebSearchToolResultBlockContent
  tool_use_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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 ContentBlockStartEventContentBlock.
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)
} derive(Eq, @debug.Debug)

///|
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 {
    BashCodeExecutionToolResult(value) => Json(value)
    CodeExecutionToolResult(value) => Json(value)
    ContainerUpload(value) => Json(value)
    RedactedThinking(value) => Json(value)
    ServerToolUse(value) => Json(value)
    Text(value) => Json(value)
    TextEditorCodeExecutionToolResult(value) => Json(value)
    Thinking(value) => Json(value)
    ToolSearchToolResult(value) => Json(value)
    ToolUse(value) => Json(value)
    WebFetchToolResult(value) => Json(value)
    WebSearchToolResult(value) => Json(value)
    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" =>
      BashCodeExecutionToolResult(@json.from_json(value, path~))
    "code_execution_tool_result" =>
      CodeExecutionToolResult(@json.from_json(value, path~))
    "container_upload" => ContainerUpload(@json.from_json(value, path~))
    "redacted_thinking" => RedactedThinking(@json.from_json(value, path~))
    "server_tool_use" => ServerToolUse(@json.from_json(value, path~))
    "text" => Text(@json.from_json(value, path~))
    "text_editor_code_execution_tool_result" =>
      TextEditorCodeExecutionToolResult(@json.from_json(value, path~))
    "thinking" => Thinking(@json.from_json(value, path~))
    "tool_search_tool_result" =>
      ToolSearchToolResult(@json.from_json(value, path~))
    "tool_use" => ToolUse(@json.from_json(value, path~))
    "web_fetch_tool_result" => WebFetchToolResult(@json.from_json(value, path~))
    "web_search_tool_result" =>
      WebSearchToolResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ContentBlockStartEvent.
pub(all) struct ContentBlockStartEvent {
  content_block : ContentBlockStartEventContentBlock
  index : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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.
pub(all) struct ContentBlockStopEvent {
  index : Int
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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.
pub(all) struct ContextManagementCapability {
  clear_thinking_20251015 : CapabilitySupport?
  clear_tool_uses_20250919 : CapabilitySupport?
  compact_20260112 : CapabilitySupport?
  supported : Bool
} derive(Eq, @debug.Debug)

///|
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),
  }
}

///|
///
/// Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.
pub(all) enum CountMessageTokensParamsCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) struct RequestBashCodeExecutionOutputBlock {
  file_id : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct RequestBashCodeExecutionResultBlock {
  content : Array[RequestBashCodeExecutionOutputBlock]
  return_code : Int
  stderr : String
  stdout : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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.
pub(all) enum RequestBashCodeExecutionToolResultBlockContent {
  BashCodeExecutionToolResultError(RequestBashCodeExecutionToolResultError)
  BashCodeExecutionResult(RequestBashCodeExecutionResultBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    BashCodeExecutionToolResultError(value) => Json(value)
    BashCodeExecutionResult(value) => Json(value)
    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" =>
      BashCodeExecutionToolResultError(@json.from_json(value, path~))
    "bash_code_execution_result" =>
      BashCodeExecutionResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum RequestCodeExecutionToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) struct RequestCodeExecutionOutputBlock {
  file_id : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct RequestCodeExecutionResultBlock {
  content : Array[RequestCodeExecutionOutputBlock]
  return_code : Int
  stderr : String
  stdout : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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),
  }
}

///|
///
/// Code execution result with encrypted stdout for PFC + web_search results.
pub(all) struct RequestEncryptedCodeExecutionResultBlock {
  content : Array[RequestCodeExecutionOutputBlock]
  encrypted_stdout : String
  return_code : Int
  stderr : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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.
pub(all) enum RequestCodeExecutionToolResultBlockContent {
  CodeExecutionToolResultError(RequestCodeExecutionToolResultError)
  CodeExecutionResult(RequestCodeExecutionResultBlock)
  EncryptedCodeExecutionResult(RequestEncryptedCodeExecutionResultBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    CodeExecutionToolResultError(value) => Json(value)
    CodeExecutionResult(value) => Json(value)
    EncryptedCodeExecutionResult(value) => Json(value)
    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" =>
      CodeExecutionToolResultError(@json.from_json(value, path~))
    "code_execution_result" =>
      CodeExecutionResult(@json.from_json(value, path~))
    "encrypted_code_execution_result" =>
      EncryptedCodeExecutionResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum RequestContainerUploadBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => 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.
pub(all) struct RequestContainerUploadBlock {
  cache_control : @sdkjson.Presence[RequestContainerUploadBlockCacheControl]
  file_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestDocumentBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 FileDocumentSource.
pub(all) struct FileDocumentSource {
  file_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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 URLPDFSource.
pub(all) struct URLPDFSource {
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestDocumentBlockSource {
  Base64(Base64PDFSource)
  Content(ContentBlockSource)
  File(FileDocumentSource)
  Text(PlainTextSource)
  Url(URLPDFSource)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Base64(value) => Json(value)
    Content(value) => Json(value)
    File(value) => Json(value)
    Text(value) => Json(value)
    Url(value) => Json(value)
    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" => Base64(@json.from_json(value, path~))
    "content" => Content(@json.from_json(value, path~))
    "file" => File(@json.from_json(value, path~))
    "text" => Text(@json.from_json(value, path~))
    "url" => Url(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of RequestDocumentBlock.
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
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct RequestRedactedThinkingBlock {
  data : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestSearchResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum RequestServerToolUseBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    CodeExecution20250825(value) => Json(value)
    CodeExecution20260120(value) => Json(value)
    Direct(value) => Json(value)
    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" =>
      CodeExecution20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecution20260120(@json.from_json(value, path~))
    "direct" => Direct(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    WebSearch => "web_search"
    WebFetch => "web_fetch"
    CodeExecution => "code_execution"
    BashCodeExecution => "bash_code_execution"
    TextEditorCodeExecution => "text_editor_code_execution"
    ToolSearchToolRegex => "tool_search_tool_regex"
    ToolSearchToolBm25 => "tool_search_tool_bm25"
    Custom(raw) => raw
  }
  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" => Some(WebSearch)
        "web_fetch" => Some(WebFetch)
        "code_execution" => Some(CodeExecution)
        "bash_code_execution" => Some(BashCodeExecution)
        "text_editor_code_execution" => Some(TextEditorCodeExecution)
        "tool_search_tool_regex" => Some(ToolSearchToolRegex)
        "tool_search_tool_bm25" => Some(ToolSearchToolBm25)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

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

///|
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.
pub(all) enum RequestTextEditorCodeExecutionToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum RequestTextEditorCodeExecutionViewResultBlockFileType {
  Text
  Image
  Pdf
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Text => "text"
    Image => "image"
    Pdf => "pdf"
    Custom(raw) => raw
  }
  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" => Some(Text)
        "image" => Some(Image)
        "pdf" => Some(Pdf)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

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

///|
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? : Int,
  start_line? : Int,
  total_lines? : Int,
) -> 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.
pub(all) struct RequestTextEditorCodeExecutionCreateResultBlock {
  is_file_update : Bool
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct RequestTextEditorCodeExecutionStrReplaceResultBlock {
  lines : @sdkjson.Presence[Array[String]]
  new_lines : @sdkjson.Presence[Int]
  new_start : @sdkjson.Presence[Int]
  old_lines : @sdkjson.Presence[Int]
  old_start : @sdkjson.Presence[Int]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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? : Int,
  new_start? : Int,
  old_lines? : Int,
  old_start? : Int,
) -> 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.
pub(all) enum RequestTextEditorCodeExecutionToolResultBlockContent {
  TextEditorCodeExecutionToolResultError(
    RequestTextEditorCodeExecutionToolResultError
  )
  TextEditorCodeExecutionViewResult(
    RequestTextEditorCodeExecutionViewResultBlock
  )
  TextEditorCodeExecutionCreateResult(
    RequestTextEditorCodeExecutionCreateResultBlock
  )
  TextEditorCodeExecutionStrReplaceResult(
    RequestTextEditorCodeExecutionStrReplaceResultBlock
  )
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    TextEditorCodeExecutionToolResultError(value) => Json(value)
    TextEditorCodeExecutionViewResult(value) => Json(value)
    TextEditorCodeExecutionCreateResult(value) => Json(value)
    TextEditorCodeExecutionStrReplaceResult(value) => Json(value)
    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" =>
      TextEditorCodeExecutionToolResultError(@json.from_json(value, path~))
    "text_editor_code_execution_view_result" =>
      TextEditorCodeExecutionViewResult(@json.from_json(value, path~))
    "text_editor_code_execution_create_result" =>
      TextEditorCodeExecutionCreateResult(@json.from_json(value, path~))
    "text_editor_code_execution_str_replace_result" =>
      TextEditorCodeExecutionStrReplaceResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) struct RequestThinkingBlock {
  signature : String
  thinking : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    DownloadCompleted(value) => Json(value)
    DownloadFailed(value) => Json(value)
    DownloadStarted(value) => Json(value)
    TabOpened(value) => Json(value)
    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" => DownloadCompleted(@json.from_json(value, path~))
    "download_failed" => DownloadFailed(@json.from_json(value, path~))
    "download_started" => DownloadStarted(@json.from_json(value, path~))
    "tab_opened" => TabOpened(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// 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.
pub(all) struct RequestBrowserStateBlock {
  cache_control : @sdkjson.Presence[RequestBrowserStateBlockCacheControl]
  state_changes : @sdkjson.Presence[
    Array[RequestBrowserStateBlockStateChangesItem],
  ]
  tabs : Array[BrowserStateTabEntry]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestToolReferenceBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum RequestToolResultBlockContentValueArrayItem {
  BrowserState(RequestBrowserStateBlock)
  Document(RequestDocumentBlock)
  Image(RequestImageBlock)
  SearchResult(RequestSearchResultBlock)
  Text(RequestTextBlock)
  ToolReference(RequestToolReferenceBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    BrowserState(value) => Json(value)
    Document(value) => Json(value)
    Image(value) => Json(value)
    SearchResult(value) => Json(value)
    Text(value) => Json(value)
    ToolReference(value) => Json(value)
    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" => BrowserState(@json.from_json(value, path~))
    "document" => Document(@json.from_json(value, path~))
    "image" => Image(@json.from_json(value, path~))
    "search_result" => SearchResult(@json.from_json(value, path~))
    "text" => Text(@json.from_json(value, path~))
    "tool_reference" => ToolReference(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    Text(value) => Json(value)
    ValueArray(value) => 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 String(_) {
    let decoded : String = @json.from_json(value, path~)
    return Text(decoded)
  }
  if json_array_matches(value, item => item is Object(_)) {
    let decoded : Array[RequestToolResultBlockContentValueArrayItem] = @json.from_json(
      value,
      path~,
    )
    return ValueArray(decoded)
  }
  raise @json.JsonDecodeError(
    (
      path, "JSON shape does not match any RequestToolResultBlockContent variant",
    ),
  )
}

///|
///
/// Generated representation of RequestToolResultBlock.
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
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestToolSearchToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) struct RequestToolSearchToolSearchResultBlock {
  tool_references : Array[RequestToolReferenceBlock]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestToolSearchToolResultBlockContent {
  ToolSearchToolResultError(RequestToolSearchToolResultError)
  ToolSearchToolSearchResult(RequestToolSearchToolSearchResultBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    ToolSearchToolResultError(value) => Json(value)
    ToolSearchToolSearchResult(value) => Json(value)
    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" =>
      ToolSearchToolResultError(@json.from_json(value, path~))
    "tool_search_tool_search_result" =>
      ToolSearchToolSearchResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum RequestToolUseBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    CodeExecution20250825(value) => Json(value)
    CodeExecution20260120(value) => Json(value)
    Direct(value) => Json(value)
    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" =>
      CodeExecution20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecution20260120(@json.from_json(value, path~))
    "direct" => Direct(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum RequestWebFetchToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    CodeExecution20250825(value) => Json(value)
    CodeExecution20260120(value) => Json(value)
    Direct(value) => Json(value)
    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" =>
      CodeExecution20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecution20260120(@json.from_json(value, path~))
    "direct" => Direct(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) struct RequestWebFetchResultBlock {
  content : RequestDocumentBlock
  retrieved_at : @sdkjson.Presence[String]
  type_ : String
  url : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestWebFetchToolResultBlockContent {
  WebFetchToolResultError(RequestWebFetchToolResultError)
  WebFetchResult(RequestWebFetchResultBlock)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    WebFetchToolResultError(value) => Json(value)
    WebFetchResult(value) => Json(value)
    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" =>
      WebFetchToolResultError(@json.from_json(value, path~))
    "web_fetch_result" => WebFetchResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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.
pub(all) enum RequestWebSearchToolResultBlockCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    CodeExecution20250825(value) => Json(value)
    CodeExecution20260120(value) => Json(value)
    Direct(value) => Json(value)
    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" =>
      CodeExecution20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecution20260120(@json.from_json(value, path~))
    "direct" => Direct(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 representation of RequestWebSearchToolResultError.
pub(all) struct RequestWebSearchToolResultError {
  error_code : WebSearchToolResultErrorCode
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum RequestWebSearchToolResultBlockContent {
  RequestWebSearchResultBlockArray(Array[RequestWebSearchResultBlock])
  RequestWebSearchToolResultError(RequestWebSearchToolResultError)
} derive(Eq, @debug.Debug)

///|
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 {
    RequestWebSearchResultBlockArray(value) => Json(value)
    RequestWebSearchToolResultError(value) => 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 Object(_)) {
    let decoded : Array[RequestWebSearchResultBlock] = @json.from_json(
      value,
      path~,
    )
    return RequestWebSearchResultBlockArray(decoded)
  }
  if value is Object(_) {
    let decoded : RequestWebSearchToolResultError = @json.from_json(
      value,
      path~,
    )
    return RequestWebSearchToolResultError(decoded)
  }
  raise @json.JsonDecodeError(
    (
      path, "JSON shape does not match any RequestWebSearchToolResultBlockContent variant",
    ),
  )
}

///|
///
/// Generated representation of RequestWebSearchToolResultBlock.
pub(all) struct RequestWebSearchToolResultBlock {
  cache_control : @sdkjson.Presence[RequestWebSearchToolResultBlockCacheControl]
  caller : RequestWebSearchToolResultBlockCaller?
  content : RequestWebSearchToolResultBlockContent
  tool_use_id : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
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)
} derive(Eq, @debug.Debug)

///|
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 {
    BashCodeExecutionToolResult(value) => Json(value)
    CodeExecutionToolResult(value) => Json(value)
    ContainerUpload(value) => Json(value)
    Document(value) => Json(value)
    Image(value) => Json(value)
    RedactedThinking(value) => Json(value)
    SearchResult(value) => Json(value)
    ServerToolUse(value) => Json(value)
    Text(value) => Json(value)
    TextEditorCodeExecutionToolResult(value) => Json(value)
    Thinking(value) => Json(value)
    ToolResult(value) => Json(value)
    ToolSearchToolResult(value) => Json(value)
    ToolUse(value) => Json(value)
    WebFetchToolResult(value) => Json(value)
    WebSearchToolResult(value) => Json(value)
    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" =>
      BashCodeExecutionToolResult(@json.from_json(value, path~))
    "code_execution_tool_result" =>
      CodeExecutionToolResult(@json.from_json(value, path~))
    "container_upload" => ContainerUpload(@json.from_json(value, path~))
    "document" => Document(@json.from_json(value, path~))
    "image" => Image(@json.from_json(value, path~))
    "redacted_thinking" => RedactedThinking(@json.from_json(value, path~))
    "search_result" => SearchResult(@json.from_json(value, path~))
    "server_tool_use" => ServerToolUse(@json.from_json(value, path~))
    "text" => Text(@json.from_json(value, path~))
    "text_editor_code_execution_tool_result" =>
      TextEditorCodeExecutionToolResult(@json.from_json(value, path~))
    "thinking" => Thinking(@json.from_json(value, path~))
    "tool_result" => ToolResult(@json.from_json(value, path~))
    "tool_search_tool_result" =>
      ToolSearchToolResult(@json.from_json(value, path~))
    "tool_use" => ToolUse(@json.from_json(value, path~))
    "web_fetch_tool_result" => WebFetchToolResult(@json.from_json(value, path~))
    "web_search_tool_result" =>
      WebSearchToolResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated untagged union InputMessageContent.
pub(all) enum InputMessageContent {
  Text(String)
  InputContentBlockArray(Array[InputContentBlock])
} derive(Eq, @debug.Debug)

///|
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 {
    Text(value) => Json(value)
    InputContentBlockArray(value) => 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 String(_) {
    let decoded : String = @json.from_json(value, path~)
    return Text(decoded)
  }
  if json_array_matches(value, item => item is Object(_)) {
    let decoded : Array[InputContentBlock] = @json.from_json(value, path~)
    return InputContentBlockArray(decoded)
  }
  raise @json.JsonDecodeError(
    (path, "JSON shape does not match any InputMessageContent variant"),
  )
}

///|
///
/// Generated string enum InputMessageRole.
pub(all) enum InputMessageRole {
  User
  Assistant
  System
  Custom(String)
} derive(Eq, @debug.Debug)

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

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

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

///|
pub impl ToJson for InputMessageRole with fn to_json(self) {
  let raw = match self {
    User => "user"
    Assistant => "assistant"
    System => "system"
    Custom(raw) => raw
  }
  Json(raw)
}

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

///|
pub impl @json.FromJson for InputMessageRole with fn from_json(value, path) {
  @sdkjson.open_string(
    value,
    path,
    raw => {
      match raw {
        "user" => Some(User)
        "assistant" => Some(Assistant)
        "system" => Some(System)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

///|
///
/// Generated representation of InputMessage.
pub(all) struct InputMessage {
  content : InputMessageContent
  role : InputMessageRole
} derive(Eq, @debug.Debug)

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

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

///|
///
/// Creates a InputMessage with omitted optional fields absent.
pub fn InputMessage::new(
  content~ : InputMessageContent,
  role~ : InputMessageRole,
) -> InputMessage {
  { content, role, }
}

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

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

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

///|
pub impl @json.FromJson for InputMessage 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),
  }
}

///|
///
/// All possible effort levels.
pub(all) enum EffortLevel {
  Low
  Medium
  High
  Xhigh
  Max
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Low => "low"
    Medium => "medium"
    High => "high"
    Xhigh => "xhigh"
    Max => "max"
    Custom(raw) => raw
  }
  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" => Some(Low)
        "medium" => Some(Medium)
        "high" => Some(High)
        "xhigh" => Some(Xhigh)
        "max" => Some(Max)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

///|
///
/// Generated representation of JsonOutputFormat.
pub(all) struct JsonOutputFormat {
  schema : Json
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct OutputConfig {
  effort : @sdkjson.Presence[EffortLevel]
  format : @sdkjson.Presence[JsonOutputFormat]
} derive(Eq, @debug.Debug)

///|
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),
  }
}

///|
///
/// 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).
pub(all) enum CountMessageTokensParamsSystem {
  Text(String)
  RequestTextBlockArray(Array[RequestTextBlock])
} derive(Eq, @debug.Debug)

///|
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 {
    Text(value) => Json(value)
    RequestTextBlockArray(value) => 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 String(_) {
    let decoded : String = @json.from_json(value, path~)
    return Text(decoded)
  }
  if json_array_matches(value, item => item is Object(_)) {
    let decoded : Array[RequestTextBlock] = @json.from_json(value, path~)
    return RequestTextBlockArray(decoded)
  }
  raise @json.JsonDecodeError(
    (
      path, "JSON shape does not match any CountMessageTokensParamsSystem variant",
    ),
  )
}

///|
///
/// Generated string enum ThinkingDisplayMode.
pub(all) enum ThinkingDisplayMode {
  Summarized
  Omitted
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Summarized => "summarized"
    Omitted => "omitted"
    Custom(raw) => raw
  }
  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" => Some(Summarized)
        "omitted" => Some(Omitted)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

///|
///
/// Generated representation of ThinkingConfigAdaptive.
pub(all) struct ThinkingConfigAdaptive {
  display : @sdkjson.Presence[ThinkingDisplayMode]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ThinkingConfigBetweenTools {
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ThinkingConfigDisabled {
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ThinkingConfigEnabled {
  budget_tokens : Int
  display : @sdkjson.Presence[ThinkingDisplayMode]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  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 enabling Claude's extended thinking. When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.
pub(all) enum ThinkingConfigParam {
  Adaptive(ThinkingConfigAdaptive)
  BetweenTools(ThinkingConfigBetweenTools)
  Disabled(ThinkingConfigDisabled)
  Enabled(ThinkingConfigEnabled)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Adaptive(value) => Json(value)
    BetweenTools(value) => Json(value)
    Disabled(value) => Json(value)
    Enabled(value) => Json(value)
    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" => Adaptive(@json.from_json(value, path~))
    "between_tools" => BetweenTools(@json.from_json(value, path~))
    "disabled" => Disabled(@json.from_json(value, path~))
    "enabled" => Enabled(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// The model will use any available tools.
pub(all) struct ToolChoiceAny {
  disable_parallel_tool_use : Bool?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ToolChoiceAuto {
  disable_parallel_tool_use : Bool?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ToolChoiceNone {
  type_ : String
} derive(Eq, @debug.Debug)

///|
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`.
pub(all) struct ToolChoiceTool {
  disable_parallel_tool_use : Bool?
  name : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ToolChoice {
  Any(ToolChoiceAny)
  Auto(ToolChoiceAuto)
  None(ToolChoiceNone)
  Tool(ToolChoiceTool)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Any(value) => Json(value)
    Auto(value) => Json(value)
    None(value) => Json(value)
    Tool(value) => Json(value)
    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" => Any(@json.from_json(value, path~))
    "auto" => Auto(@json.from_json(value, path~))
    "none" => None(@json.from_json(value, path~))
    "tool" => Tool(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

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

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of Tool.
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]]?
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum MemoryTool20250818CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of MemoryTool20250818.
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
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum TextEditor20250124CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of TextEditor20250124.
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
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum TextEditor20250429CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of TextEditor20250429.
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
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum TextEditor20250728CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of TextEditor20250728.
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[Int]
  strict : Bool?
  type_ : String
} derive(Eq, @debug.Debug)

///|
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? : Int,
  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.
pub(all) enum WebSearchTool20250305CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of UserLocation.
pub(all) struct UserLocation {
  city : @sdkjson.Presence[String]
  country : @sdkjson.Presence[String]
  region : @sdkjson.Presence[String]
  timezone : @sdkjson.Presence[String]
} derive(Eq, @debug.Debug)

///|
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.
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[Int]
  strict : Bool?
  type_ : String
  user_location : @sdkjson.Presence[UserLocation]
} derive(Eq, @debug.Debug)

///|
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? : Int,
  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.
pub(all) enum WebFetchTool20250910CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => 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.
pub(all) struct WebFetchUrlSourceAll {
  type_ : String
} derive(Eq, @debug.Debug)

///|
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[]``.
pub(all) struct WebFetchUrlSourceToolReference {
  name : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct WebFetchUrlSourceExcept {
  tools : Array[WebFetchUrlSourceToolReference]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct WebFetchUrlSourceNone {
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct WebFetchUrlSourceOnly {
  tools : Array[WebFetchUrlSourceToolReference]
  type_ : String
} derive(Eq, @debug.Debug)

///|
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[].
pub(all) enum WebFetchUrlSourcesClientToolResults {
  All(WebFetchUrlSourceAll)
  Except(WebFetchUrlSourceExcept)
  None(WebFetchUrlSourceNone)
  Only(WebFetchUrlSourceOnly)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    All(value) => Json(value)
    Except(value) => Json(value)
    None(value) => Json(value)
    Only(value) => Json(value)
    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" => All(@json.from_json(value, path~))
    "except" => Except(@json.from_json(value, path~))
    "none" => None(@json.from_json(value, path~))
    "only" => Only(@json.from_json(value, path~))
    other => 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.
pub(all) enum WebFetchUrlSourcesServerToolResults {
  All(WebFetchUrlSourceAll)
  Except(WebFetchUrlSourceExcept)
  None(WebFetchUrlSourceNone)
  Only(WebFetchUrlSourceOnly)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    All(value) => Json(value)
    Except(value) => Json(value)
    None(value) => Json(value)
    Only(value) => Json(value)
    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" => All(@json.from_json(value, path~))
    "except" => Except(@json.from_json(value, path~))
    "none" => None(@json.from_json(value, path~))
    "only" => Only(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Whether URLs in user messages are fetchable: "all" or "none".
pub(all) enum WebFetchUrlSourcesUserInput {
  All(WebFetchUrlSourceAll)
  None(WebFetchUrlSourceNone)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    All(value) => Json(value)
    None(value) => Json(value)
    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" => All(@json.from_json(value, path~))
    "none" => None(@json.from_json(value, path~))
    other => 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[]``.
pub(all) struct WebFetchUrlSources {
  client_tool_results : WebFetchUrlSourcesClientToolResults?
  server_tool_results : WebFetchUrlSourcesServerToolResults?
  user_input : WebFetchUrlSourcesUserInput?
} derive(Eq, @debug.Debug)

///|
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.
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[Int]
  max_uses : @sdkjson.Presence[Int]
  strict : Bool?
  type_ : String
  url_sources : @sdkjson.Presence[WebFetchUrlSources]
} derive(Eq, @debug.Debug)

///|
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? : Int,
  max_uses? : Int,
  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.
pub(all) enum WebSearchTool20260209CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of WebSearchTool20260209.
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[Int]
  strict : Bool?
  type_ : String
  user_location : @sdkjson.Presence[UserLocation]
} derive(Eq, @debug.Debug)

///|
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? : Int,
  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.
pub(all) enum WebFetchTool20260209CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of WebFetchTool20260209.
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[Int]
  max_uses : @sdkjson.Presence[Int]
  strict : Bool?
  type_ : String
  url_sources : @sdkjson.Presence[WebFetchUrlSources]
} derive(Eq, @debug.Debug)

///|
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? : Int,
  max_uses? : Int,
  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.
pub(all) enum WebFetchTool20260309CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Web fetch tool with use_cache parameter for bypassing cached content.
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[Int]
  max_uses : @sdkjson.Presence[Int]
  strict : Bool?
  type_ : String
  url_sources : @sdkjson.Presence[WebFetchUrlSources]
  use_cache : Bool?
} derive(Eq, @debug.Debug)

///|
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? : Int,
  max_uses? : Int,
  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.
pub(all) enum WebSearchTool20260318CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => 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.
pub(all) enum WebSearchTool20260318ResponseInclusion {
  Full
  Excluded
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Full => "full"
    Excluded => "excluded"
    Custom(raw) => raw
  }
  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" => Some(Full)
        "excluded" => Some(Excluded)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

///|
///
/// Generated representation of WebSearchTool20260318.
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[Int]
  response_inclusion : WebSearchTool20260318ResponseInclusion?
  strict : Bool?
  type_ : String
  user_location : @sdkjson.Presence[UserLocation]
} derive(Eq, @debug.Debug)

///|
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? : Int,
  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.
pub(all) enum WebFetchTool20260318CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => 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.
pub(all) enum WebFetchTool20260318ResponseInclusion {
  Full
  Excluded
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Full => "full"
    Excluded => "excluded"
    Custom(raw) => raw
  }
  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" => Some(Full)
        "excluded" => Some(Excluded)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

///|
///
/// Generated representation of WebFetchTool20260318.
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[Int]
  max_uses : @sdkjson.Presence[Int]
  response_inclusion : WebFetchTool20260318ResponseInclusion?
  strict : Bool?
  type_ : String
  url_sources : @sdkjson.Presence[WebFetchUrlSources]
  use_cache : Bool?
} derive(Eq, @debug.Debug)

///|
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? : Int,
  max_uses? : Int,
  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.
pub(all) enum ToolSearchToolBM2520251119CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated string enum ToolSearchToolBM2520251119Type.
pub(all) enum ToolSearchToolBM2520251119Type {
  ToolSearchToolBm2520251119
  ToolSearchToolBm25
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    ToolSearchToolBm2520251119 => "tool_search_tool_bm25_20251119"
    ToolSearchToolBm25 => "tool_search_tool_bm25"
    Custom(raw) => raw
  }
  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" => Some(ToolSearchToolBm2520251119)
        "tool_search_tool_bm25" => Some(ToolSearchToolBm25)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

///|
///
/// Generated representation of ToolSearchToolBM2520251119.
pub(all) struct ToolSearchToolBM2520251119 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[ToolSearchToolBM2520251119CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : ToolSearchToolBM2520251119Type
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum ToolSearchToolRegex20251119CacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated string enum ToolSearchToolRegex20251119Type.
pub(all) enum ToolSearchToolRegex20251119Type {
  ToolSearchToolRegex20251119
  ToolSearchToolRegex
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    ToolSearchToolRegex20251119 => "tool_search_tool_regex_20251119"
    ToolSearchToolRegex => "tool_search_tool_regex"
    Custom(raw) => raw
  }
  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" => Some(ToolSearchToolRegex20251119)
        "tool_search_tool_regex" => Some(ToolSearchToolRegex)
        _ => None
      }
    },
    raw => Custom(raw),
  )
}

///|
///
/// Generated representation of ToolSearchToolRegex20251119.
pub(all) struct ToolSearchToolRegex20251119 {
  allowed_callers : Array[AllowedCaller]?
  cache_control : @sdkjson.Presence[ToolSearchToolRegex20251119CacheControl]
  defer_loading : Bool?
  strict : Bool?
  type_ : ToolSearchToolRegex20251119Type
} derive(Eq, @debug.Debug)

///|
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.
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)
} derive(Eq, @debug.Debug)

///|
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 {
    Tool(value) => Json(value)
    BashTool20250124(value) => Json(value)
    CodeExecutionTool20250522(value) => Json(value)
    CodeExecutionTool20250825(value) => Json(value)
    CodeExecutionTool20260120(value) => Json(value)
    CodeExecutionTool20260521(value) => Json(value)
    BrowserToolset20260801(value) => Json(value)
    MemoryTool20250818(value) => Json(value)
    ComputerToolset20260801(value) => Json(value)
    TextEditor20250124(value) => Json(value)
    TextEditor20250429(value) => Json(value)
    TextEditor20250728(value) => Json(value)
    WebSearchTool20250305(value) => Json(value)
    WebFetchTool20250910(value) => Json(value)
    WebSearchTool20260209(value) => Json(value)
    WebFetchTool20260209(value) => Json(value)
    WebFetchTool20260309(value) => Json(value)
    WebSearchTool20260318(value) => Json(value)
    WebFetchTool20260318(value) => Json(value)
    ToolSearchToolBM2520251119(value) => Json(value)
    ToolSearchToolRegex20251119(value) => Json(value)
    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") {
    None | Some(Null) => "custom"
    Some(raw) => @json.from_json(raw, path=path.add_key("type"))
  }
  match tag {
    "custom" => Tool(@json.from_json(value, path~))
    "bash_20250124" => BashTool20250124(@json.from_json(value, path~))
    "code_execution_20250522" =>
      CodeExecutionTool20250522(@json.from_json(value, path~))
    "code_execution_20250825" =>
      CodeExecutionTool20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecutionTool20260120(@json.from_json(value, path~))
    "code_execution_20260521" =>
      CodeExecutionTool20260521(@json.from_json(value, path~))
    "browser_toolset_20260801" =>
      BrowserToolset20260801(@json.from_json(value, path~))
    "memory_20250818" => MemoryTool20250818(@json.from_json(value, path~))
    "computer_toolset_20260801" =>
      ComputerToolset20260801(@json.from_json(value, path~))
    "text_editor_20250124" => TextEditor20250124(@json.from_json(value, path~))
    "text_editor_20250429" => TextEditor20250429(@json.from_json(value, path~))
    "text_editor_20250728" => TextEditor20250728(@json.from_json(value, path~))
    "web_search_20250305" =>
      WebSearchTool20250305(@json.from_json(value, path~))
    "web_fetch_20250910" => WebFetchTool20250910(@json.from_json(value, path~))
    "web_search_20260209" =>
      WebSearchTool20260209(@json.from_json(value, path~))
    "web_fetch_20260209" => WebFetchTool20260209(@json.from_json(value, path~))
    "web_fetch_20260309" => WebFetchTool20260309(@json.from_json(value, path~))
    "web_search_20260318" =>
      WebSearchTool20260318(@json.from_json(value, path~))
    "web_fetch_20260318" => WebFetchTool20260318(@json.from_json(value, path~))
    "tool_search_tool_bm25_20251119" =>
      ToolSearchToolBM2520251119(@json.from_json(value, path~))
    "tool_search_tool_bm25" =>
      ToolSearchToolBM2520251119(@json.from_json(value, path~))
    "tool_search_tool_regex_20251119" =>
      ToolSearchToolRegex20251119(@json.from_json(value, path~))
    "tool_search_tool_regex" =>
      ToolSearchToolRegex20251119(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of CountMessageTokensParams.
pub(all) struct CountMessageTokensParams {
  cache_control : @sdkjson.Presence[CountMessageTokensParamsCacheControl]
  messages : Array[InputMessage]
  model : String
  output_config : OutputConfig?
  system : CountMessageTokensParamsSystem?
  thinking : ThinkingConfigParam?
  tool_choice : ToolChoice?
  tools : Array[CountMessageTokensParamsToolsItem]?
} derive(Eq, @debug.Debug)

///|
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[InputMessage],
  model~ : String,
  cache_control? : CountMessageTokensParamsCacheControl,
  output_config? : OutputConfig,
  system? : CountMessageTokensParamsSystem,
  thinking? : ThinkingConfigParam,
  tool_choice? : ToolChoice,
  tools? : Array[CountMessageTokensParamsToolsItem],
) -> CountMessageTokensParams {
  {
    cache_control: @sdkjson.Presence::from_option(cache_control),
    messages,
    model,
    output_config,
    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)
  .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),
    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.
pub(all) struct CountMessageTokensResponse {
  input_tokens : Int
} derive(Eq, @debug.Debug)

///|
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~ : Int,
) -> 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.
pub(all) enum CreateMessageParamsCacheControl {
  Ephemeral(CacheControlEphemeral)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    Ephemeral(value) => Json(value)
    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" => Ephemeral(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Container identifier for reuse across requests.
pub(all) enum CreateMessageParamsContainer {
  ContainerParams(ContainerParams)
  Text(String)
} derive(Eq, @debug.Debug)

///|
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 {
    ContainerParams(value) => Json(value)
    Text(value) => 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 Object(_) {
    let decoded : ContainerParams = @json.from_json(value, path~)
    return ContainerParams(decoded)
  }
  if value is String(_) {
    let decoded : String = @json.from_json(value, path~)
    return Text(decoded)
  }
  raise @json.JsonDecodeError(
    (path, "JSON shape does not match any CreateMessageParamsContainer variant"),
  )
}

///|
///
/// Request-level diagnostics. Currently carries the previous response id for prompt-cache divergence reporting.
pub(all) struct DiagnosticsParam {
  previous_message_id : @sdkjson.Presence[String]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct Metadata {
  user_id : @sdkjson.Presence[String]
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum CreateMessageParamsServiceTier {
  Auto
  StandardOnly
  Custom(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Auto => "auto"
    StandardOnly => "standard_only"
    Custom(raw) => raw
  }
  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" => Some(Auto)
        "standard_only" => Some(StandardOnly)
        _ => None
      }
    },
    raw => 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).
pub(all) enum CreateMessageParamsSystem {
  Text(String)
  RequestTextBlockArray(Array[RequestTextBlock])
} derive(Eq, @debug.Debug)

///|
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 {
    Text(value) => Json(value)
    RequestTextBlockArray(value) => 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 String(_) {
    let decoded : String = @json.from_json(value, path~)
    return Text(decoded)
  }
  if json_array_matches(value, item => item is Object(_)) {
    let decoded : Array[RequestTextBlock] = @json.from_json(value, path~)
    return RequestTextBlockArray(decoded)
  }
  raise @json.JsonDecodeError(
    (path, "JSON shape does not match any CreateMessageParamsSystem variant"),
  )
}

///|
///
/// Generated tagged union CreateMessageParamsToolsItem.
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)
} derive(Eq, @debug.Debug)

///|
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 {
    Tool(value) => Json(value)
    BashTool20250124(value) => Json(value)
    CodeExecutionTool20250522(value) => Json(value)
    CodeExecutionTool20250825(value) => Json(value)
    CodeExecutionTool20260120(value) => Json(value)
    CodeExecutionTool20260521(value) => Json(value)
    BrowserToolset20260801(value) => Json(value)
    MemoryTool20250818(value) => Json(value)
    ComputerToolset20260801(value) => Json(value)
    TextEditor20250124(value) => Json(value)
    TextEditor20250429(value) => Json(value)
    TextEditor20250728(value) => Json(value)
    WebSearchTool20250305(value) => Json(value)
    WebFetchTool20250910(value) => Json(value)
    WebSearchTool20260209(value) => Json(value)
    WebFetchTool20260209(value) => Json(value)
    WebFetchTool20260309(value) => Json(value)
    WebSearchTool20260318(value) => Json(value)
    WebFetchTool20260318(value) => Json(value)
    ToolSearchToolBM2520251119(value) => Json(value)
    ToolSearchToolRegex20251119(value) => Json(value)
    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") {
    None | Some(Null) => "custom"
    Some(raw) => @json.from_json(raw, path=path.add_key("type"))
  }
  match tag {
    "custom" => Tool(@json.from_json(value, path~))
    "bash_20250124" => BashTool20250124(@json.from_json(value, path~))
    "code_execution_20250522" =>
      CodeExecutionTool20250522(@json.from_json(value, path~))
    "code_execution_20250825" =>
      CodeExecutionTool20250825(@json.from_json(value, path~))
    "code_execution_20260120" =>
      CodeExecutionTool20260120(@json.from_json(value, path~))
    "code_execution_20260521" =>
      CodeExecutionTool20260521(@json.from_json(value, path~))
    "browser_toolset_20260801" =>
      BrowserToolset20260801(@json.from_json(value, path~))
    "memory_20250818" => MemoryTool20250818(@json.from_json(value, path~))
    "computer_toolset_20260801" =>
      ComputerToolset20260801(@json.from_json(value, path~))
    "text_editor_20250124" => TextEditor20250124(@json.from_json(value, path~))
    "text_editor_20250429" => TextEditor20250429(@json.from_json(value, path~))
    "text_editor_20250728" => TextEditor20250728(@json.from_json(value, path~))
    "web_search_20250305" =>
      WebSearchTool20250305(@json.from_json(value, path~))
    "web_fetch_20250910" => WebFetchTool20250910(@json.from_json(value, path~))
    "web_search_20260209" =>
      WebSearchTool20260209(@json.from_json(value, path~))
    "web_fetch_20260209" => WebFetchTool20260209(@json.from_json(value, path~))
    "web_fetch_20260309" => WebFetchTool20260309(@json.from_json(value, path~))
    "web_search_20260318" =>
      WebSearchTool20260318(@json.from_json(value, path~))
    "web_fetch_20260318" => WebFetchTool20260318(@json.from_json(value, path~))
    "tool_search_tool_bm25_20251119" =>
      ToolSearchToolBM2520251119(@json.from_json(value, path~))
    "tool_search_tool_bm25" =>
      ToolSearchToolBM2520251119(@json.from_json(value, path~))
    "tool_search_tool_regex_20251119" =>
      ToolSearchToolRegex20251119(@json.from_json(value, path~))
    "tool_search_tool_regex" =>
      ToolSearchToolRegex20251119(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of CreateMessageParams.
pub(all) struct CreateMessageParams {
  model : String
  messages : Array[InputMessage]
  cache_control : @sdkjson.Presence[CreateMessageParamsCacheControl]
  container : @sdkjson.Presence[CreateMessageParamsContainer]
  diagnostics : @sdkjson.Presence[DiagnosticsParam]
  inference_geo : @sdkjson.Presence[String]
  max_tokens : Int
  metadata : Metadata?
  output_config : OutputConfig?
  service_tier : CreateMessageParamsServiceTier?
  stop_sequences : Array[String]?
  stream : Bool?
  system : CreateMessageParamsSystem?
  temperature : Double?
  thinking : ThinkingConfigParam?
  tool_choice : ToolChoice?
  tools : Array[CreateMessageParamsToolsItem]?
  top_k : Int?
  top_p : Double?
} derive(Eq, @debug.Debug)

///|
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[InputMessage],
  max_tokens~ : Int,
  cache_control? : CreateMessageParamsCacheControl,
  container? : CreateMessageParamsContainer,
  diagnostics? : DiagnosticsParam,
  inference_geo? : String,
  metadata? : Metadata,
  output_config? : OutputConfig,
  service_tier? : CreateMessageParamsServiceTier,
  stop_sequences? : Array[String],
  stream? : Bool,
  system? : CreateMessageParamsSystem,
  temperature? : Double,
  thinking? : ThinkingConfigParam,
  tool_choice? : ToolChoice,
  tools? : Array[CreateMessageParamsToolsItem],
  top_k? : Int,
  top_p? : Double,
) -> 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,
    stop_sequences,
    stream,
    system,
    temperature,
    thinking,
    tool_choice,
    tools,
    top_k,
    top_p,
  }
}

///|
///
/// 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)
  .opt("stop_sequences", self.stop_sequences)
  .opt("stream", self.stream)
  .opt("system", self.system)
  .opt("temperature", self.temperature)
  .opt("thinking", self.thinking)
  .opt("tool_choice", self.tool_choice)
  .opt("tools", self.tools)
  .opt("top_k", self.top_k)
  .opt("top_p", self.top_p)
  .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),
    stop_sequences: @sdkjson.opt_field(obj, "stop_sequences", path),
    stream: @sdkjson.opt_field(obj, "stream", path),
    system: @sdkjson.opt_field(obj, "system", path),
    temperature: @sdkjson.opt_field(obj, "temperature", path),
    thinking: @sdkjson.opt_field(obj, "thinking", path),
    tool_choice: @sdkjson.opt_field(obj, "tool_choice", path),
    tools: @sdkjson.opt_field(obj, "tools", path),
    top_k: @sdkjson.opt_field(obj, "top_k", path),
    top_p: @sdkjson.opt_field(obj, "top_p", path),
  }
}

///|
///
/// Request-level diagnostics: why the prompt cache could not fully reuse the prefix of the request named by `diagnostics.previous_message_id`.
pub(all) struct Diagnostics {
  cache_miss_reason : CacheMissReason?
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct EffortCapability {
  high : CapabilitySupport
  low : CapabilitySupport
  max : CapabilitySupport
  medium : CapabilitySupport
  supported : Bool
  xhigh : CapabilitySupport?
} derive(Eq, @debug.Debug)

///|
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),
  }
}

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

///|
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.
pub(all) struct NotFoundError {
  message : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct OverloadedError {
  message : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct PermissionError {
  message : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct RateLimitError {
  message : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct GatewayTimeoutError {
  message : String
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
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)
} derive(Eq, @debug.Debug)

///|
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 {
    ApiError(value) => Json(value)
    AuthenticationError(value) => Json(value)
    BillingError(value) => Json(value)
    InvalidRequestError(value) => Json(value)
    NotFoundError(value) => Json(value)
    OverloadedError(value) => Json(value)
    PermissionError(value) => Json(value)
    RateLimitError(value) => Json(value)
    TimeoutError(value) => Json(value)
    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" => ApiError(@json.from_json(value, path~))
    "authentication_error" => AuthenticationError(@json.from_json(value, path~))
    "billing_error" => BillingError(@json.from_json(value, path~))
    "invalid_request_error" =>
      InvalidRequestError(@json.from_json(value, path~))
    "not_found_error" => NotFoundError(@json.from_json(value, path~))
    "overloaded_error" => OverloadedError(@json.from_json(value, path~))
    "permission_error" => PermissionError(@json.from_json(value, path~))
    "rate_limit_error" => RateLimitError(@json.from_json(value, path~))
    "timeout_error" => TimeoutError(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated representation of ErrorResponse.
pub(all) struct ErrorResponse {
  error : ErrorResponseError
  request_id : String?
} derive(Eq, @debug.Debug)

///|
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),
  }
}

///|
///
/// Supported thinking type configurations.
pub(all) struct ThinkingTypes {
  adaptive : CapabilitySupport
  enabled : CapabilitySupport
} derive(Eq, @debug.Debug)

///|
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,
  enabled~ : CapabilitySupport,
) -> ThinkingTypes {
  { adaptive, 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("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),
    enabled: required_field(obj, "enabled", path),
  }
}

///|
///
/// Thinking capability details.
pub(all) struct ThinkingCapability {
  supported : Bool
  types : ThinkingTypes
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct ModelCapabilities {
  batch : CapabilitySupport
  citations : CapabilitySupport
  code_execution : CapabilitySupport
  context_management : ContextManagementCapability
  effort : EffortCapability
  image_input : CapabilitySupport
  pdf_input : CapabilitySupport
  structured_outputs : CapabilitySupport
  thinking : ThinkingCapability
} derive(Eq, @debug.Debug)

///|
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,
  structured_outputs~ : CapabilitySupport,
  thinking~ : ThinkingCapability,
) -> ModelCapabilities {
  {
    batch,
    citations,
    code_execution,
    context_management,
    effort,
    image_input,
    pdf_input,
    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("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),
    structured_outputs: required_field(obj, "structured_outputs", path),
    thinking: required_field(obj, "thinking", path),
  }
}

///|
///
/// Generated representation of ModelInfo.
pub(all) struct ModelInfo {
  capabilities : ModelCapabilities?
  created_at : String
  display_name : String
  id : String
  max_input_tokens : Int?
  max_tokens : Int?
} derive(Eq, @debug.Debug)

///|
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,
  capabilities? : ModelCapabilities,
  max_input_tokens? : Int,
  max_tokens? : Int,
) -> ModelInfo {
  { capabilities, created_at, display_name, id, max_input_tokens, max_tokens, }
}

///|
///
/// 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)
  .field("display_name", self.display_name)
  .field("id", self.id)
  .presence(
    "max_input_tokens",
    nullable_presence(self.max_input_tokens.map(value => value)),
  )
  .presence(
    "max_tokens",
    nullable_presence(self.max_tokens.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),
    display_name: required_field(obj, "display_name", path),
    id: required_field(obj, "id", path),
    max_input_tokens: decode_nullable_field(obj, "max_input_tokens", path),
    max_tokens: decode_nullable_field(obj, "max_tokens", path),
  }
}

///|
///
/// Generated representation of ListResponseModelInfo.
pub(all) struct ListResponseModelInfo {
  data : Array[ModelInfo]
  first_id : String?
  has_more : Bool
  last_id : String?
} derive(Eq, @debug.Debug)

///|
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 tagged union ContentBlock.
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)
} derive(Eq, @debug.Debug)

///|
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 {
    BashCodeExecutionToolResult(value) => Json(value)
    CodeExecutionToolResult(value) => Json(value)
    ContainerUpload(value) => Json(value)
    RedactedThinking(value) => Json(value)
    ServerToolUse(value) => Json(value)
    Text(value) => Json(value)
    TextEditorCodeExecutionToolResult(value) => Json(value)
    Thinking(value) => Json(value)
    ToolSearchToolResult(value) => Json(value)
    ToolUse(value) => Json(value)
    WebFetchToolResult(value) => Json(value)
    WebSearchToolResult(value) => Json(value)
    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" =>
      BashCodeExecutionToolResult(@json.from_json(value, path~))
    "code_execution_tool_result" =>
      CodeExecutionToolResult(@json.from_json(value, path~))
    "container_upload" => ContainerUpload(@json.from_json(value, path~))
    "redacted_thinking" => RedactedThinking(@json.from_json(value, path~))
    "server_tool_use" => ServerToolUse(@json.from_json(value, path~))
    "text" => Text(@json.from_json(value, path~))
    "text_editor_code_execution_tool_result" =>
      TextEditorCodeExecutionToolResult(@json.from_json(value, path~))
    "thinking" => Thinking(@json.from_json(value, path~))
    "tool_search_tool_result" =>
      ToolSearchToolResult(@json.from_json(value, path~))
    "tool_use" => ToolUse(@json.from_json(value, path~))
    "web_fetch_tool_result" => WebFetchToolResult(@json.from_json(value, path~))
    "web_search_tool_result" =>
      WebSearchToolResult(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}

///|
///
/// Generated string enum StopReason.
pub(all) enum StopReason {
  EndTurn
  MaxTokens
  StopSequence
  ToolUse
  PauseTurn
  Refusal
  ModelContextWindowExceeded
  Unknown(String)
} derive(Eq, @debug.Debug)

///|
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 {
    EndTurn => "end_turn"
    MaxTokens => "max_tokens"
    StopSequence => "stop_sequence"
    ToolUse => "tool_use"
    PauseTurn => "pause_turn"
    Refusal => "refusal"
    ModelContextWindowExceeded => "model_context_window_exceeded"
    Unknown(raw) => raw
  }
  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" => Some(EndTurn)
        "max_tokens" => Some(MaxTokens)
        "stop_sequence" => Some(StopSequence)
        "tool_use" => Some(ToolUse)
        "pause_turn" => Some(PauseTurn)
        "refusal" => Some(Refusal)
        "model_context_window_exceeded" => Some(ModelContextWindowExceeded)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

///|
///
/// The policy category that triggered a refusal.
pub(all) enum RefusalCategory {
  Cyber
  Bio
  FrontierLlm
  ReasoningExtraction
  GeneralHarms
  Unknown(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Cyber => "cyber"
    Bio => "bio"
    FrontierLlm => "frontier_llm"
    ReasoningExtraction => "reasoning_extraction"
    GeneralHarms => "general_harms"
    Unknown(raw) => raw
  }
  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" => Some(Cyber)
        "bio" => Some(Bio)
        "frontier_llm" => Some(FrontierLlm)
        "reasoning_extraction" => Some(ReasoningExtraction)
        "general_harms" => Some(GeneralHarms)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

///|
///
/// Structured information about a refusal.
pub(all) struct RefusalStopDetails {
  category : RefusalCategory?
  explanation : String?
} derive(Eq, @debug.Debug)

///|
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(
  category? : RefusalCategory,
  explanation? : String,
) -> RefusalStopDetails {
  { category, explanation, }
}

///|
///
/// 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", "refusal")
  .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),
  }
}

///|
///
/// Generated representation of OutputTokensDetails.
pub(all) struct OutputTokensDetails {
  thinking_tokens : Int
} derive(Eq, @debug.Debug)

///|
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~ : Int) -> 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.
pub(all) struct ServerToolUsage {
  web_fetch_requests : Int
  web_search_requests : Int
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  web_search_requests~ : Int,
) -> 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.
pub(all) enum UsageServiceTier {
  Standard
  Priority
  Batch
  Unknown(String)
} derive(Eq, @debug.Debug)

///|
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 {
    Standard => "standard"
    Priority => "priority"
    Batch => "batch"
    Unknown(raw) => raw
  }
  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" => Some(Standard)
        "priority" => Some(Priority)
        "batch" => Some(Batch)
        _ => None
      }
    },
    raw => Unknown(raw),
  )
}

///|
///
/// Generated representation of Usage.
pub(all) struct Usage {
  cache_creation : @sdkjson.Presence[CacheCreation]
  cache_creation_input_tokens : @sdkjson.Presence[Int]
  cache_read_input_tokens : @sdkjson.Presence[Int]
  inference_geo : @sdkjson.Presence[String]
  input_tokens : Int
  output_tokens : Int
  output_tokens_details : @sdkjson.Presence[OutputTokensDetails]
  server_tool_use : @sdkjson.Presence[ServerToolUsage]
  service_tier : @sdkjson.Presence[UsageServiceTier]
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  output_tokens~ : Int,
  cache_creation? : CacheCreation,
  cache_creation_input_tokens? : Int,
  cache_read_input_tokens? : Int,
  inference_geo? : String,
  output_tokens_details? : OutputTokensDetails,
  server_tool_use? : ServerToolUsage,
  service_tier? : UsageServiceTier,
) -> 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),
  }
}

///|
///
/// 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)
  .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),
  }
}

///|
///
/// Generated representation of Message.
pub(all) struct Message {
  id : String
  content : Array[ContentBlock]
  model : String
  stop_reason : StopReason?
  stop_sequence : @sdkjson.Presence[String]
  stop_details : @sdkjson.Presence[RefusalStopDetails]
  usage : Usage
  diagnostics : @sdkjson.Presence[Diagnostics]
  container : @sdkjson.Presence[Container]
} derive(Eq, @debug.Debug)

///|
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? : RefusalStopDetails,
  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.
pub(all) struct MessageDelta {
  container : @sdkjson.Presence[Container]
  stop_details : @sdkjson.Presence[RefusalStopDetails]
  stop_reason : StopReason?
  stop_sequence : @sdkjson.Presence[String]
} derive(Eq, @debug.Debug)

///|
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? : RefusalStopDetails,
  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.
pub(all) struct MessageDeltaUsage {
  cache_creation_input_tokens : @sdkjson.Presence[Int]
  cache_read_input_tokens : @sdkjson.Presence[Int]
  input_tokens : @sdkjson.Presence[Int]
  output_tokens : Int
  output_tokens_details : @sdkjson.Presence[OutputTokensDetails]
  server_tool_use : @sdkjson.Presence[ServerToolUsage]
} derive(Eq, @debug.Debug)

///|
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~ : Int,
  cache_creation_input_tokens? : Int,
  cache_read_input_tokens? : Int,
  input_tokens? : Int,
  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.
pub(all) struct MessageDeltaEvent {
  delta : MessageDelta
  type_ : String
  usage : MessageDeltaUsage
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct MessageStartEvent {
  message : Message
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) struct MessageStopEvent {
  type_ : String
} derive(Eq, @debug.Debug)

///|
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.
pub(all) enum MessageStreamEvent {
  ContentBlockDelta(ContentBlockDeltaEvent)
  ContentBlockStart(ContentBlockStartEvent)
  ContentBlockStop(ContentBlockStopEvent)
  MessageDelta(MessageDeltaEvent)
  MessageStart(MessageStartEvent)
  MessageStop(MessageStopEvent)
  Unknown(String, Json)
} derive(Eq, @debug.Debug)

///|
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 {
    ContentBlockDelta(value) => Json(value)
    ContentBlockStart(value) => Json(value)
    ContentBlockStop(value) => Json(value)
    MessageDelta(value) => Json(value)
    MessageStart(value) => Json(value)
    MessageStop(value) => Json(value)
    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" => ContentBlockDelta(@json.from_json(value, path~))
    "content_block_start" => ContentBlockStart(@json.from_json(value, path~))
    "content_block_stop" => ContentBlockStop(@json.from_json(value, path~))
    "message_delta" => MessageDelta(@json.from_json(value, path~))
    "message_start" => MessageStart(@json.from_json(value, path~))
    "message_stop" => MessageStop(@json.from_json(value, path~))
    other => Unknown(other, value)
  }
}