lib/anthropic/models/beta/beta_tool_use_block.rb



# frozen_string_literal: true

module Anthropic
  module Models
    module Beta
      class BetaToolUseBlock < Anthropic::Internal::Type::BaseModel
        # @!attribute id
        #
        #   @return [String]
        required :id, String

        # @!attribute input
        #
        #   @return [Object]
        required :input, Anthropic::Internal::Type::Unknown

        # @!attribute name
        #
        #   @return [String]
        required :name, String

        # @!attribute type
        #
        #   @return [Symbol, :tool_use]
        required :type, const: :tool_use

        # @!attribute caller_
        #   Tool invocation directly from the model.
        #
        #   @return [Anthropic::Models::Beta::BetaDirectCaller, Anthropic::Models::Beta::BetaServerToolCaller, Anthropic::Models::Beta::BetaServerToolCaller20260120, nil]
        optional :caller_, union: -> { Anthropic::Beta::BetaToolUseBlock::Caller }, api_name: :caller

        response_only do
          # @api public
          #
          # Parsed input data coerced to the tool's input schema model.
          # Only present when tools are defined using the InputSchema DSL.
          required :parsed, Anthropic::Internal::Type::Unknown

          # @api private
          #
          # Internal buffer for accumulating partial JSON during streaming.
          # Used by streaming helpers to reconstruct complete JSON input from deltas.
          optional :_json_buf, String
        end

        # @!method initialize(id:, input:, name:, caller_: nil, type: :tool_use)
        #   @param id [String]
        #
        #   @param input [Object]
        #
        #   @param name [String]
        #
        #   @param caller_ [Anthropic::Models::Beta::BetaDirectCaller, Anthropic::Models::Beta::BetaServerToolCaller, Anthropic::Models::Beta::BetaServerToolCaller20260120] Tool invocation directly from the model.
        #
        #   @param type [Symbol, :tool_use]

        # Tool invocation directly from the model.
        #
        # @see Anthropic::Models::Beta::BetaToolUseBlock#caller_
        module Caller
          extend Anthropic::Internal::Type::Union

          discriminator :type

          # Tool invocation directly from the model.
          variant :direct, -> { Anthropic::Beta::BetaDirectCaller }

          # Tool invocation generated by a server-side tool.
          variant :code_execution_20250825, -> { Anthropic::Beta::BetaServerToolCaller }

          variant :code_execution_20260120, -> { Anthropic::Beta::BetaServerToolCaller20260120 }

          # @!method self.variants
          #   @return [Array(Anthropic::Models::Beta::BetaDirectCaller, Anthropic::Models::Beta::BetaServerToolCaller, Anthropic::Models::Beta::BetaServerToolCaller20260120)]
        end
      end
    end

    BetaToolUseBlock = Beta::BetaToolUseBlock
  end
end