anthropic 1.61.0 → 1.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -0
- data/README.md +1 -1
- data/lib/anthropic/client.rb +29 -5
- data/lib/anthropic/errors.rb +6 -0
- data/lib/anthropic/helpers/aws/client.rb +9 -17
- data/lib/anthropic/helpers/aws_auth.rb +13 -2
- data/lib/anthropic/helpers/bedrock/client.rb +19 -17
- data/lib/anthropic/helpers/google_cloud/client.rb +16 -27
- data/lib/anthropic/helpers/messages.rb +21 -15
- data/lib/anthropic/helpers/streaming/message_stream.rb +37 -8
- data/lib/anthropic/helpers/tools/base_tool.rb +69 -10
- data/lib/anthropic/helpers/tools/mcp.rb +2 -2
- data/lib/anthropic/helpers/tools/runner.rb +33 -19
- data/lib/anthropic/helpers/vertex/client.rb +24 -13
- data/lib/anthropic/internal/type/base_model.rb +5 -1
- data/lib/anthropic/internal/type/base_stream.rb +10 -0
- data/lib/anthropic/models/anthropic_beta.rb +3 -0
- data/lib/anthropic/models/beta/agent_create_params.rb +39 -2
- data/lib/anthropic/models/beta/agent_update_params.rb +39 -2
- data/lib/anthropic/models/beta/beta_advisor_message_iteration_usage.rb +2 -2
- data/lib/anthropic/models/beta/beta_citations_delta.rb +59 -0
- data/lib/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rb +22 -0
- data/lib/anthropic/models/beta/beta_cloud_config.rb +29 -0
- data/lib/anthropic/models/beta/beta_cloud_config_params.rb +32 -3
- data/lib/anthropic/models/beta/beta_code_execution_tool_20260120.rb +3 -3
- data/lib/anthropic/models/beta/beta_code_execution_tool_20260521.rb +2 -2
- data/lib/anthropic/models/beta/beta_content_block.rb +89 -0
- data/lib/anthropic/models/beta/beta_content_block_param.rb +112 -7
- data/lib/anthropic/models/beta/beta_content_block_source_content.rb +28 -0
- data/lib/anthropic/models/beta/beta_context_management_config.rb +39 -0
- data/lib/anthropic/models/beta/beta_context_management_response.rb +26 -0
- data/lib/anthropic/models/beta/beta_diagnostics.rb +36 -3
- data/lib/anthropic/models/beta/beta_diagnostics_param.rb +3 -3
- data/lib/anthropic/models/beta/beta_document_block.rb +24 -0
- data/lib/anthropic/models/beta/beta_dream.rb +18 -7
- data/lib/anthropic/models/beta/beta_dream_input.rb +28 -2
- data/lib/anthropic/models/beta/beta_dream_memory_store_input.rb +3 -1
- data/lib/anthropic/models/beta/beta_dream_model_config.rb +5 -5
- data/lib/anthropic/models/beta/beta_dream_model_config_param.rb +4 -4
- data/lib/anthropic/models/beta/beta_environment.rb +30 -6
- data/lib/anthropic/models/beta/beta_fallback_block.rb +3 -3
- data/lib/anthropic/models/beta/beta_fallback_block_param.rb +3 -3
- data/lib/anthropic/models/beta/beta_fallback_credit_not_applied.rb +2 -2
- data/lib/anthropic/models/beta/beta_fallback_credit_token_param.rb +3 -3
- data/lib/anthropic/models/beta/beta_fallback_credit_usage.rb +29 -2
- data/lib/anthropic/models/beta/beta_fallback_info.rb +2 -2
- data/lib/anthropic/models/beta/beta_fallback_info_param.rb +2 -2
- data/lib/anthropic/models/beta/beta_fallback_message_iteration_usage.rb +3 -3
- data/lib/anthropic/models/beta/beta_fallback_param.rb +32 -3
- data/lib/anthropic/models/beta/beta_image_block_param.rb +30 -0
- data/lib/anthropic/models/beta/beta_iterations_usage.rb +39 -0
- data/lib/anthropic/models/beta/beta_limited_network.rb +2 -2
- data/lib/anthropic/models/beta/beta_limited_network_params.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_advisor_params.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_agent.rb +60 -2
- data/lib/anthropic/models/beta/beta_managed_agents_agent_params.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_agent_tool_config.rb +20 -0
- data/lib/anthropic/models/beta/beta_managed_agents_agent_tool_config_params.rb +22 -2
- data/lib/anthropic/models/beta/beta_managed_agents_agent_toolset20260401_bash_input.rb +4 -4
- data/lib/anthropic/models/beta/beta_managed_agents_agent_toolset20260401_edit_input.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_agent_toolset20260401_glob_input.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_agent_toolset20260401_grep_input.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_agent_toolset20260401_read_input.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_agent_toolset_default_config.rb +20 -0
- data/lib/anthropic/models/beta/beta_managed_agents_agent_toolset_default_config_params.rb +22 -2
- data/lib/anthropic/models/beta/beta_managed_agents_agent_with_overrides_params.rb +45 -7
- data/lib/anthropic/models/beta/beta_managed_agents_cron_schedule.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_cron_schedule_params.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_custom_tool_params.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_deleted_memory_store.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_delta_event.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_deployment.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_deployment_initial_event.rb +30 -0
- data/lib/anthropic/models/beta/beta_managed_agents_deployment_initial_event_params.rb +30 -0
- data/lib/anthropic/models/beta/beta_managed_agents_deployment_paused_reason.rb +22 -0
- data/lib/anthropic/models/beta/beta_managed_agents_deployment_paused_reason_error.rb +44 -0
- data/lib/anthropic/models/beta/beta_managed_agents_deployment_run.rb +53 -3
- data/lib/anthropic/models/beta/beta_managed_agents_deployment_user_define_outcome_event.rb +24 -0
- data/lib/anthropic/models/beta/beta_managed_agents_deployment_user_message_event.rb +32 -0
- data/lib/anthropic/models/beta/beta_managed_agents_github_repository_resource_config.rb +24 -0
- data/lib/anthropic/models/beta/beta_managed_agents_github_repository_resource_params.rb +24 -0
- data/lib/anthropic/models/beta/beta_managed_agents_mcp_tool_config.rb +20 -0
- data/lib/anthropic/models/beta/beta_managed_agents_mcp_tool_config_params.rb +20 -0
- data/lib/anthropic/models/beta/beta_managed_agents_mcp_toolset_default_config.rb +20 -0
- data/lib/anthropic/models/beta/beta_managed_agents_mcp_toolset_default_config_params.rb +20 -0
- data/lib/anthropic/models/beta/beta_managed_agents_mcp_toolset_params.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_memory_store.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_memory_store_resource_config.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_memory_store_resource_param.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_model_config.rb +28 -2
- data/lib/anthropic/models/beta/beta_managed_agents_model_config_params.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_multiagent.rb +28 -2
- data/lib/anthropic/models/beta/beta_managed_agents_multiagent_coordinator.rb +28 -2
- data/lib/anthropic/models/beta/beta_managed_agents_multiagent_coordinator_params.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_multiagent_params.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_outcome_evaluation_resource.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_schedule.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_schedule_params.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_session.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_session_agent.rb +61 -3
- data/lib/anthropic/models/beta/beta_managed_agents_session_agent_update.rb +41 -3
- data/lib/anthropic/models/beta/beta_managed_agents_session_multiagent_coordinator.rb +38 -0
- data/lib/anthropic/models/beta/beta_managed_agents_session_resource_config.rb +41 -0
- data/lib/anthropic/models/beta/beta_managed_agents_session_stats.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_session_thread_agent.rb +58 -0
- data/lib/anthropic/models/beta/beta_managed_agents_session_updated_event.rb +4 -4
- data/lib/anthropic/models/beta/beta_managed_agents_session_usage.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_session_usage_event.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_skill_params.rb +24 -0
- data/lib/anthropic/models/beta/beta_managed_agents_start_event.rb +3 -3
- data/lib/anthropic/models/beta/beta_managed_agents_start_event_preview.rb +25 -0
- data/lib/anthropic/models/beta/beta_managed_agents_trigger_context.rb +22 -0
- data/lib/anthropic/models/beta/beta_managed_agents_url_mcp_server_params.rb +2 -2
- data/lib/anthropic/models/beta/beta_managed_agents_user_tool_result_event.rb +40 -4
- data/lib/anthropic/models/beta/beta_memory_tool_20250818_command.rb +46 -0
- data/lib/anthropic/models/beta/beta_message_iteration_usage.rb +2 -2
- data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
- data/lib/anthropic/models/beta/beta_output_behavior.rb +49 -0
- data/lib/anthropic/models/beta/beta_output_behavior_create_new.rb +33 -0
- data/lib/anthropic/models/beta/beta_output_behavior_update_existing.rb +39 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_delta.rb +47 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +90 -0
- data/lib/anthropic/models/beta/beta_raw_message_stream_event.rb +43 -0
- data/lib/anthropic/models/beta/beta_refusal_stop_details.rb +2 -2
- data/lib/anthropic/models/beta/beta_request_document_block.rb +36 -0
- data/lib/anthropic/models/beta/beta_request_tool_addition_block.rb +29 -3
- data/lib/anthropic/models/beta/beta_request_tool_removal_block.rb +29 -3
- data/lib/anthropic/models/beta/beta_server_tool_use_block.rb +24 -0
- data/lib/anthropic/models/beta/beta_server_tool_use_block_param.rb +24 -0
- data/lib/anthropic/models/beta/beta_text_citation.rb +59 -0
- data/lib/anthropic/models/beta/beta_text_citation_param.rb +57 -0
- data/lib/anthropic/models/beta/beta_thinking_config_param.rb +29 -0
- data/lib/anthropic/models/beta/beta_token_task_budget.rb +2 -2
- data/lib/anthropic/models/beta/beta_tool_choice.rb +31 -0
- data/lib/anthropic/models/beta/beta_tool_choice_any.rb +2 -2
- data/lib/anthropic/models/beta/beta_tool_choice_auto.rb +2 -2
- data/lib/anthropic/models/beta/beta_tool_choice_tool.rb +2 -2
- data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +42 -0
- data/lib/anthropic/models/beta/beta_tool_use_block.rb +24 -0
- data/lib/anthropic/models/beta/beta_tool_use_block_param.rb +24 -0
- data/lib/anthropic/models/beta/beta_tunnel.rb +2 -2
- data/lib/anthropic/models/beta/beta_tunnel_token.rb +2 -2
- data/lib/anthropic/models/beta/beta_user_profile.rb +56 -26
- data/lib/anthropic/models/beta/beta_web_fetch_tool_20260309.rb +2 -2
- data/lib/anthropic/models/beta/beta_web_fetch_tool_result_block.rb +24 -0
- data/lib/anthropic/models/beta/beta_web_fetch_tool_result_block_param.rb +24 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_result_block.rb +24 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_result_block_param.rb +24 -0
- data/lib/anthropic/models/beta/beta_webhook_event_data.rb +114 -0
- data/lib/anthropic/models/beta/deployment_create_params.rb +42 -0
- data/lib/anthropic/models/beta/deployment_update_params.rb +42 -0
- data/lib/anthropic/models/beta/dream_create_params.rb +14 -1
- data/lib/anthropic/models/beta/environment_create_params.rb +27 -0
- data/lib/anthropic/models/beta/environment_update_params.rb +30 -2
- data/lib/anthropic/models/beta/environments/beta_self_hosted_work.rb +3 -3
- data/lib/anthropic/models/beta/environments/beta_self_hosted_work_queue_stats.rb +4 -4
- data/lib/anthropic/models/beta/environments/beta_self_hosted_work_update_request.rb +2 -2
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_actor.rb +40 -1
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_api_actor.rb +3 -3
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_content_sha256_precondition.rb +4 -4
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_error.rb +46 -0
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory.rb +4 -4
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_list_item.rb +42 -0
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_prefix.rb +4 -4
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_version.rb +8 -8
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_precondition.rb +4 -4
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_service_account_actor.rb +30 -0
- data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_session_actor.rb +3 -3
- data/lib/anthropic/models/beta/memory_stores/memory_version_list_params.rb +9 -1
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +4 -4
- data/lib/anthropic/models/beta/messages/beta_message_batch_individual_response.rb +3 -3
- data/lib/anthropic/models/beta/messages/beta_message_batch_result.rb +28 -0
- data/lib/anthropic/models/beta/session_create_params.rb +70 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_agent_custom_tool_use_event.rb +3 -3
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_agent_mcp_tool_result_event.rb +36 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_agent_mcp_tool_use_event.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_agent_message_event.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_agent_thread_message_received_event.rb +35 -3
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_agent_thread_message_sent_event.rb +35 -3
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_agent_tool_result_event.rb +36 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_agent_tool_use_event.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_base64_image_source.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_billing_error.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_credential_host_unreachable_error.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_document_block.rb +32 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_event_params.rb +54 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_github_repository_resource.rb +24 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_image_block.rb +34 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_mcp_authentication_failed_error.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_mcp_connection_failed_error.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_memory_store_resource.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_model_overloaded_error.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_model_rate_limited_error.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_model_request_failed_error.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_send_session_events.rb +60 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_error_event.rb +44 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_event.rb +160 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_requires_action.rb +4 -4
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_resource.rb +51 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_status_idle_event.rb +30 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_thread.rb +38 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_thread_stats.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_thread_status_idle_event.rb +30 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_thread_usage.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_session_usage_snapshot.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_span_model_usage.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_span_outcome_evaluation_end_event.rb +4 -4
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_span_outcome_evaluation_ongoing_event.rb +4 -4
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_span_outcome_evaluation_start_event.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_stream_session_events.rb +170 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_stream_session_thread_events.rb +170 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_text_rubric_params.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_unknown_error.rb +22 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_custom_tool_result_event.rb +38 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_custom_tool_result_event_params.rb +38 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_define_outcome_event.rb +27 -3
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_define_outcome_event_params.rb +28 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_interrupt_event.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_interrupt_event_params.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_message_event.rb +32 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_message_event_params.rb +32 -0
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_tool_confirmation_event.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_tool_confirmation_event_params.rb +2 -2
- data/lib/anthropic/models/beta/sessions/beta_managed_agents_user_tool_result_event_params.rb +40 -4
- data/lib/anthropic/models/beta/sessions/resource_retrieve_response.rb +50 -0
- data/lib/anthropic/models/beta/sessions/resource_update_response.rb +50 -0
- data/lib/anthropic/models/beta/user_profile_create_params.rb +32 -4
- data/lib/anthropic/models/beta/user_profile_update_params.rb +28 -1
- data/lib/anthropic/models/beta/vaults/beta_managed_agents_credential.rb +34 -0
- data/lib/anthropic/models/beta/vaults/beta_managed_agents_credential_networking_params.rb +26 -0
- data/lib/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_auth_response.rb +26 -0
- data/lib/anthropic/models/beta/vaults/beta_managed_agents_limited_credential_networking_params.rb +2 -2
- data/lib/anthropic/models/beta/vaults/beta_managed_agents_limited_credential_networking_response.rb +2 -2
- data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_params.rb +24 -0
- data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_response.rb +22 -0
- data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_update_params.rb +22 -0
- data/lib/anthropic/models/beta/vaults/credential_create_params.rb +40 -0
- data/lib/anthropic/models/beta/vaults/credential_update_params.rb +36 -0
- data/lib/anthropic/models/beta_error.rb +36 -0
- data/lib/anthropic/models/beta_monetary_amount.rb +2 -2
- data/lib/anthropic/models/citations_delta.rb +59 -0
- data/lib/anthropic/models/code_execution_tool_20260120.rb +3 -3
- data/lib/anthropic/models/code_execution_tool_20260521.rb +2 -2
- data/lib/anthropic/models/content_block.rb +67 -0
- data/lib/anthropic/models/content_block_param.rb +86 -7
- data/lib/anthropic/models/content_block_source_content.rb +28 -0
- data/lib/anthropic/models/document_block.rb +24 -0
- data/lib/anthropic/models/document_block_param.rb +32 -0
- data/lib/anthropic/models/error_object.rb +36 -0
- data/lib/anthropic/models/image_block_param.rb +26 -0
- data/lib/anthropic/models/message_param.rb +3 -3
- data/lib/anthropic/models/messages/batch_create_params.rb +4 -4
- data/lib/anthropic/models/messages/message_batch_individual_response.rb +3 -3
- data/lib/anthropic/models/messages/message_batch_result.rb +28 -0
- data/lib/anthropic/models/raw_content_block_delta.rb +39 -0
- data/lib/anthropic/models/raw_content_block_start_event.rb +67 -0
- data/lib/anthropic/models/raw_message_stream_event.rb +41 -0
- data/lib/anthropic/models/refusal_stop_details.rb +2 -2
- data/lib/anthropic/models/server_tool_use_block.rb +24 -0
- data/lib/anthropic/models/server_tool_use_block_param.rb +24 -0
- data/lib/anthropic/models/text_citation.rb +59 -0
- data/lib/anthropic/models/text_citation_param.rb +57 -0
- data/lib/anthropic/models/thinking_config_param.rb +29 -0
- data/lib/anthropic/models/tool_choice.rb +31 -0
- data/lib/anthropic/models/tool_choice_any.rb +2 -2
- data/lib/anthropic/models/tool_choice_auto.rb +2 -2
- data/lib/anthropic/models/tool_choice_tool.rb +2 -2
- data/lib/anthropic/models/tool_result_block_param.rb +42 -0
- data/lib/anthropic/models/tool_use_block.rb +24 -0
- data/lib/anthropic/models/tool_use_block_param.rb +24 -0
- data/lib/anthropic/models/web_fetch_tool_20260309.rb +2 -2
- data/lib/anthropic/models/web_fetch_tool_result_block.rb +24 -0
- data/lib/anthropic/models/web_fetch_tool_result_block_param.rb +24 -0
- data/lib/anthropic/models/web_search_tool_result_block.rb +24 -0
- data/lib/anthropic/models/web_search_tool_result_block_param.rb +24 -0
- data/lib/anthropic/models.rb +0 -2
- data/lib/anthropic/resources/beta/agents.rb +6 -6
- data/lib/anthropic/resources/beta/deployment_runs.rb +2 -2
- data/lib/anthropic/resources/beta/deployments.rb +6 -6
- data/lib/anthropic/resources/beta/dreams.rb +8 -3
- data/lib/anthropic/resources/beta/environments/work.rb +9 -9
- data/lib/anthropic/resources/beta/environments.rb +7 -7
- data/lib/anthropic/resources/beta/files.rb +2 -2
- data/lib/anthropic/resources/beta/memory_stores/memories.rb +6 -6
- data/lib/anthropic/resources/beta/memory_stores/memory_versions.rb +4 -1
- data/lib/anthropic/resources/beta/memory_stores.rb +6 -6
- data/lib/anthropic/resources/beta/messages/batches.rb +6 -6
- data/lib/anthropic/resources/beta/messages.rb +9 -9
- data/lib/anthropic/resources/beta/models.rb +3 -3
- data/lib/anthropic/resources/beta/sessions/events.rb +4 -4
- data/lib/anthropic/resources/beta/sessions/resources.rb +6 -6
- data/lib/anthropic/resources/beta/sessions/threads/events.rb +2 -2
- data/lib/anthropic/resources/beta/sessions/threads.rb +2 -2
- data/lib/anthropic/resources/beta/sessions.rb +6 -6
- data/lib/anthropic/resources/beta/skills/versions.rb +10 -10
- data/lib/anthropic/resources/beta/skills.rb +8 -8
- data/lib/anthropic/resources/beta/tunnels/certificates.rb +6 -6
- data/lib/anthropic/resources/beta/tunnels.rb +3 -3
- data/lib/anthropic/resources/beta/user_profiles.rb +15 -11
- data/lib/anthropic/resources/beta/vaults/credentials.rb +6 -6
- data/lib/anthropic/resources/beta/vaults.rb +6 -6
- data/lib/anthropic/resources/completions.rb +6 -6
- data/lib/anthropic/resources/messages/batches.rb +6 -6
- data/lib/anthropic/resources/messages.rb +9 -9
- data/lib/anthropic/resources/models.rb +3 -3
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +4 -2
- data/rbi/anthropic/client.rbi +5 -0
- data/rbi/anthropic/errors.rbi +8 -0
- data/rbi/anthropic/helpers/bedrock/client.rbi +4 -0
- data/rbi/anthropic/helpers/google_cloud/client.rbi +5 -9
- data/rbi/anthropic/helpers/tools/base_tool.rbi +17 -0
- data/rbi/anthropic/helpers/vertex/client.rbi +5 -0
- data/rbi/anthropic/internal/type/base_stream.rbi +8 -0
- data/rbi/anthropic/models/anthropic_beta.rbi +5 -0
- data/rbi/anthropic/models/beta/agent_create_params.rbi +53 -3
- data/rbi/anthropic/models/beta/agent_update_params.rbi +53 -3
- data/rbi/anthropic/models/beta/beta_citations_delta.rbi +60 -0
- data/rbi/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_cloud_config.rbi +23 -0
- data/rbi/anthropic/models/beta/beta_cloud_config_params.rbi +25 -0
- data/rbi/anthropic/models/beta/beta_content_block.rbi +142 -0
- data/rbi/anthropic/models/beta/beta_content_block_param.rbi +163 -1
- data/rbi/anthropic/models/beta/beta_content_block_source_content.rbi +38 -0
- data/rbi/anthropic/models/beta/beta_context_management_config.rbi +55 -0
- data/rbi/anthropic/models/beta/beta_context_management_response.rbi +23 -0
- data/rbi/anthropic/models/beta/beta_diagnostics.rbi +18 -0
- data/rbi/anthropic/models/beta/beta_document_block.rbi +12 -0
- data/rbi/anthropic/models/beta/beta_dream.rbi +20 -3
- data/rbi/anthropic/models/beta/beta_dream_input.rbi +15 -1
- data/rbi/anthropic/models/beta/beta_dream_memory_store_input.rbi +3 -1
- data/rbi/anthropic/models/beta/beta_dream_model_config.rbi +2 -2
- data/rbi/anthropic/models/beta/beta_dream_model_config_param.rbi +2 -2
- data/rbi/anthropic/models/beta/beta_environment.rbi +27 -5
- data/rbi/anthropic/models/beta/beta_fallback_credit_usage.rbi +30 -0
- data/rbi/anthropic/models/beta/beta_fallback_param.rbi +37 -0
- data/rbi/anthropic/models/beta/beta_image_block_param.rbi +21 -0
- data/rbi/anthropic/models/beta/beta_iterations_usage.rbi +34 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_agent.rbi +51 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_agent_tool_config.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_agent_tool_config_params.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_agent_toolset_default_config.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_agent_toolset_default_config_params.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_agent_with_overrides_params.rbi +55 -3
- data/rbi/anthropic/models/beta/beta_managed_agents_deployment_initial_event.rbi +43 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_deployment_initial_event_params.rbi +43 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_deployment_paused_reason.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_deployment_paused_reason_error.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_deployment_run.rbi +14 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_deployment_user_define_outcome_event.rbi +20 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_deployment_user_message_event.rbi +39 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_github_repository_resource_config.rbi +20 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_github_repository_resource_params.rbi +20 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_mcp_tool_config.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_mcp_tool_config_params.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_mcp_toolset_default_config.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_mcp_toolset_default_config_params.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_model_config.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_multiagent.rbi +21 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_multiagent_coordinator.rbi +21 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_session_agent.rbi +55 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_session_agent_update.rbi +52 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_session_multiagent_coordinator.rbi +53 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_session_resource_config.rbi +46 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_session_thread_agent.rbi +55 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_skill_params.rbi +18 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_start_event_preview.rbi +15 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_trigger_context.rbi +14 -0
- data/rbi/anthropic/models/beta/beta_managed_agents_user_tool_result_event.rbi +50 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818_command.rbi +39 -0
- data/rbi/anthropic/models/beta/beta_output_behavior.rbi +42 -0
- data/rbi/anthropic/models/beta/beta_output_behavior_create_new.rbi +71 -0
- data/rbi/anthropic/models/beta/beta_output_behavior_update_existing.rbi +83 -0
- data/rbi/anthropic/models/beta/beta_raw_content_block_delta.rbi +50 -0
- data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +144 -0
- data/rbi/anthropic/models/beta/beta_raw_message_stream_event.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_request_document_block.rbi +25 -0
- data/rbi/anthropic/models/beta/beta_request_tool_addition_block.rbi +14 -0
- data/rbi/anthropic/models/beta/beta_request_tool_removal_block.rbi +14 -0
- data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_server_tool_use_block_param.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_text_citation.rbi +60 -0
- data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +58 -0
- data/rbi/anthropic/models/beta/beta_thinking_config_param.rbi +37 -0
- data/rbi/anthropic/models/beta/beta_tool_choice.rbi +21 -0
- data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +62 -0
- data/rbi/anthropic/models/beta/beta_tool_use_block.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_tool_use_block_param.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_user_profile.rbi +125 -45
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_result_block.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_result_block_param.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_result_block.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_result_block_param.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_webhook_event_data.rbi +25 -0
- data/rbi/anthropic/models/beta/deployment_create_params.rbi +49 -0
- data/rbi/anthropic/models/beta/deployment_update_params.rbi +49 -0
- data/rbi/anthropic/models/beta/dream_create_params.rbi +40 -0
- data/rbi/anthropic/models/beta/environment_create_params.rbi +30 -0
- data/rbi/anthropic/models/beta/environment_update_params.rbi +34 -2
- data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_actor.rbi +31 -1
- data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_error.rbi +20 -0
- data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory_list_item.rbi +53 -0
- data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory_version.rbi +8 -4
- data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_service_account_actor.rbi +44 -0
- data/rbi/anthropic/models/beta/memory_stores/memory_version_list_params.rbi +11 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch_result.rbi +14 -0
- data/rbi/anthropic/models/beta/session_create_params.rbi +85 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_agent_mcp_tool_result_event.rbi +50 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_agent_message_event.rbi +14 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_agent_thread_message_received_event.rbi +39 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_agent_thread_message_sent_event.rbi +39 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_agent_tool_result_event.rbi +50 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_billing_error.rbi +10 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_credential_host_unreachable_error.rbi +10 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_document_block.rbi +30 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_event_params.rbi +79 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_github_repository_resource.rbi +20 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_image_block.rbi +27 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_mcp_authentication_failed_error.rbi +10 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_mcp_connection_failed_error.rbi +10 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_model_overloaded_error.rbi +10 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_model_rate_limited_error.rbi +10 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_model_request_failed_error.rbi +10 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_send_session_events.rbi +89 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_session_error_event.rbi +34 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_session_event.rbi +203 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_session_resource.rbi +60 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_session_status_idle_event.rbi +18 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_session_thread.rbi +53 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_session_thread_status_idle_event.rbi +18 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_stream_session_events.rbi +222 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_stream_session_thread_events.rbi +222 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_unknown_error.rbi +10 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_user_custom_tool_result_event.rbi +50 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_user_custom_tool_result_event_params.rbi +50 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_user_define_outcome_event.rbi +20 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_user_define_outcome_event_params.rbi +21 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_user_message_event.rbi +39 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_user_message_event_params.rbi +39 -0
- data/rbi/anthropic/models/beta/sessions/beta_managed_agents_user_tool_result_event_params.rbi +50 -0
- data/rbi/anthropic/models/beta/sessions/resource_retrieve_response.rbi +60 -0
- data/rbi/anthropic/models/beta/sessions/resource_update_response.rbi +60 -0
- data/rbi/anthropic/models/beta/user_profile_create_params.rbi +77 -4
- data/rbi/anthropic/models/beta/user_profile_update_params.rbi +67 -0
- data/rbi/anthropic/models/beta/vaults/beta_managed_agents_credential.rbi +40 -0
- data/rbi/anthropic/models/beta/vaults/beta_managed_agents_credential_networking_params.rbi +20 -0
- data/rbi/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_auth_response.rbi +19 -0
- data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_params.rbi +17 -0
- data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_response.rbi +10 -0
- data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_update_params.rbi +17 -0
- data/rbi/anthropic/models/beta/vaults/credential_create_params.rbi +49 -0
- data/rbi/anthropic/models/beta/vaults/credential_update_params.rbi +45 -0
- data/rbi/anthropic/models/beta_error.rbi +10 -0
- data/rbi/anthropic/models/citations_delta.rbi +60 -0
- data/rbi/anthropic/models/content_block.rbi +109 -0
- data/rbi/anthropic/models/content_block_param.rbi +123 -2
- data/rbi/anthropic/models/content_block_source_content.rbi +36 -0
- data/rbi/anthropic/models/document_block.rbi +12 -0
- data/rbi/anthropic/models/document_block_param.rbi +14 -0
- data/rbi/anthropic/models/error_object.rbi +10 -0
- data/rbi/anthropic/models/image_block_param.rbi +13 -0
- data/rbi/anthropic/models/messages/message_batch_result.rbi +12 -0
- data/rbi/anthropic/models/raw_content_block_delta.rbi +35 -0
- data/rbi/anthropic/models/raw_content_block_start_event.rbi +111 -0
- data/rbi/anthropic/models/raw_message_stream_event.rbi +62 -0
- data/rbi/anthropic/models/server_tool_use_block.rbi +10 -0
- data/rbi/anthropic/models/server_tool_use_block_param.rbi +10 -0
- data/rbi/anthropic/models/text_citation.rbi +60 -0
- data/rbi/anthropic/models/text_citation_param.rbi +58 -0
- data/rbi/anthropic/models/thinking_config_param.rbi +33 -0
- data/rbi/anthropic/models/tool_choice.rbi +21 -0
- data/rbi/anthropic/models/tool_result_block_param.rbi +60 -0
- data/rbi/anthropic/models/tool_use_block.rbi +10 -0
- data/rbi/anthropic/models/tool_use_block_param.rbi +10 -0
- data/rbi/anthropic/models/web_fetch_tool_result_block.rbi +10 -0
- data/rbi/anthropic/models/web_fetch_tool_result_block_param.rbi +10 -0
- data/rbi/anthropic/models/web_search_tool_result_block.rbi +10 -0
- data/rbi/anthropic/models/web_search_tool_result_block_param.rbi +10 -0
- data/rbi/anthropic/models.rbi +0 -3
- data/rbi/anthropic/resources/beta/agents.rbi +2 -2
- data/rbi/anthropic/resources/beta/dreams.rbi +9 -0
- data/rbi/anthropic/resources/beta/environments.rbi +2 -1
- data/rbi/anthropic/resources/beta/memory_stores/memory_versions.rbi +3 -0
- data/rbi/anthropic/resources/beta/user_profiles.rbi +22 -3
- data/sig/anthropic/client.rbs +1 -0
- data/sig/anthropic/errors.rbs +4 -0
- data/sig/anthropic/helpers/bedrock/client.rbs +2 -0
- data/sig/anthropic/helpers/google_cloud/client.rbs +2 -6
- data/sig/anthropic/helpers/vertex/client.rbs +2 -0
- data/sig/anthropic/internal/type/base_stream.rbs +4 -0
- data/sig/anthropic/models/anthropic_beta.rbs +2 -0
- data/sig/anthropic/models/beta/agent_create_params.rbs +30 -0
- data/sig/anthropic/models/beta/agent_update_params.rbs +30 -0
- data/sig/anthropic/models/beta/beta_citations_delta.rbs +63 -0
- data/sig/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rbs +14 -0
- data/sig/anthropic/models/beta/beta_cloud_config.rbs +17 -0
- data/sig/anthropic/models/beta/beta_cloud_config_params.rbs +17 -0
- data/sig/anthropic/models/beta/beta_content_block.rbs +130 -0
- data/sig/anthropic/models/beta/beta_content_block_param.rbs +194 -1
- data/sig/anthropic/models/beta/beta_content_block_source_content.rbs +20 -0
- data/sig/anthropic/models/beta/beta_context_management_config.rbs +32 -0
- data/sig/anthropic/models/beta/beta_context_management_response.rbs +18 -0
- data/sig/anthropic/models/beta/beta_diagnostics.rbs +28 -0
- data/sig/anthropic/models/beta/beta_document_block.rbs +17 -0
- data/sig/anthropic/models/beta/beta_dream.rbs +5 -0
- data/sig/anthropic/models/beta/beta_dream_input.rbs +15 -0
- data/sig/anthropic/models/beta/beta_environment.rbs +19 -4
- data/sig/anthropic/models/beta/beta_fallback_credit_usage.rbs +15 -0
- data/sig/anthropic/models/beta/beta_fallback_param.rbs +20 -0
- data/sig/anthropic/models/beta/beta_image_block_param.rbs +22 -0
- data/sig/anthropic/models/beta/beta_iterations_usage.rbs +46 -0
- data/sig/anthropic/models/beta/beta_managed_agents_agent.rbs +47 -0
- data/sig/anthropic/models/beta/beta_managed_agents_agent_tool_config.rbs +11 -0
- data/sig/anthropic/models/beta/beta_managed_agents_agent_tool_config_params.rbs +11 -0
- data/sig/anthropic/models/beta/beta_managed_agents_agent_toolset_default_config.rbs +11 -0
- data/sig/anthropic/models/beta/beta_managed_agents_agent_toolset_default_config_params.rbs +11 -0
- data/sig/anthropic/models/beta/beta_managed_agents_agent_with_overrides_params.rbs +30 -0
- data/sig/anthropic/models/beta/beta_managed_agents_deployment_initial_event.rbs +24 -0
- data/sig/anthropic/models/beta/beta_managed_agents_deployment_initial_event_params.rbs +24 -0
- data/sig/anthropic/models/beta/beta_managed_agents_deployment_paused_reason.rbs +13 -0
- data/sig/anthropic/models/beta/beta_managed_agents_deployment_paused_reason_error.rbs +49 -0
- data/sig/anthropic/models/beta/beta_managed_agents_deployment_run.rbs +76 -0
- data/sig/anthropic/models/beta/beta_managed_agents_deployment_user_define_outcome_event.rbs +15 -0
- data/sig/anthropic/models/beta/beta_managed_agents_deployment_user_message_event.rbs +27 -0
- data/sig/anthropic/models/beta/beta_managed_agents_github_repository_resource_config.rbs +15 -0
- data/sig/anthropic/models/beta/beta_managed_agents_github_repository_resource_params.rbs +15 -0
- data/sig/anthropic/models/beta/beta_managed_agents_mcp_tool_config.rbs +11 -0
- data/sig/anthropic/models/beta/beta_managed_agents_mcp_tool_config_params.rbs +11 -0
- data/sig/anthropic/models/beta/beta_managed_agents_mcp_toolset_default_config.rbs +11 -0
- data/sig/anthropic/models/beta/beta_managed_agents_mcp_toolset_default_config_params.rbs +11 -0
- data/sig/anthropic/models/beta/beta_managed_agents_model_config.rbs +18 -0
- data/sig/anthropic/models/beta/beta_managed_agents_multiagent.rbs +17 -0
- data/sig/anthropic/models/beta/beta_managed_agents_multiagent_coordinator.rbs +17 -0
- data/sig/anthropic/models/beta/beta_managed_agents_session_agent.rbs +47 -0
- data/sig/anthropic/models/beta/beta_managed_agents_session_agent_update.rbs +30 -0
- data/sig/anthropic/models/beta/beta_managed_agents_session_multiagent_coordinator.rbs +30 -0
- data/sig/anthropic/models/beta/beta_managed_agents_session_resource_config.rbs +29 -0
- data/sig/anthropic/models/beta/beta_managed_agents_session_thread_agent.rbs +47 -0
- data/sig/anthropic/models/beta/beta_managed_agents_skill_params.rbs +17 -0
- data/sig/anthropic/models/beta/beta_managed_agents_start_event_preview.rbs +14 -0
- data/sig/anthropic/models/beta/beta_managed_agents_trigger_context.rbs +13 -0
- data/sig/anthropic/models/beta/beta_managed_agents_user_tool_result_event.rbs +34 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818_command.rbs +45 -0
- data/sig/anthropic/models/beta/beta_output_behavior.rbs +30 -0
- data/sig/anthropic/models/beta/beta_output_behavior_create_new.rbs +32 -0
- data/sig/anthropic/models/beta/beta_output_behavior_update_existing.rbs +39 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_delta.rbs +39 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +130 -0
- data/sig/anthropic/models/beta/beta_raw_message_stream_event.rbs +39 -0
- data/sig/anthropic/models/beta/beta_request_document_block.rbs +32 -0
- data/sig/anthropic/models/beta/beta_request_tool_addition_block.rbs +20 -0
- data/sig/anthropic/models/beta/beta_request_tool_removal_block.rbs +20 -0
- data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +15 -0
- data/sig/anthropic/models/beta/beta_server_tool_use_block_param.rbs +15 -0
- data/sig/anthropic/models/beta/beta_text_citation.rbs +63 -0
- data/sig/anthropic/models/beta/beta_text_citation_param.rbs +59 -0
- data/sig/anthropic/models/beta/beta_thinking_config_param.rbs +20 -0
- data/sig/anthropic/models/beta/beta_tool_choice.rbs +21 -0
- data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +49 -0
- data/sig/anthropic/models/beta/beta_tool_use_block.rbs +15 -0
- data/sig/anthropic/models/beta/beta_tool_use_block_param.rbs +15 -0
- data/sig/anthropic/models/beta/beta_user_profile.rbs +42 -18
- data/sig/anthropic/models/beta/beta_web_fetch_tool_result_block.rbs +15 -0
- data/sig/anthropic/models/beta/beta_web_fetch_tool_result_block_param.rbs +15 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_result_block.rbs +15 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_result_block_param.rbs +15 -0
- data/sig/anthropic/models/beta/beta_webhook_event_data.rbs +283 -0
- data/sig/anthropic/models/beta/deployment_create_params.rbs +31 -0
- data/sig/anthropic/models/beta/deployment_update_params.rbs +31 -0
- data/sig/anthropic/models/beta/dream_create_params.rbs +9 -0
- data/sig/anthropic/models/beta/environment_create_params.rbs +15 -0
- data/sig/anthropic/models/beta/environment_update_params.rbs +15 -0
- data/sig/anthropic/models/beta/memory_stores/beta_managed_agents_actor.rbs +26 -0
- data/sig/anthropic/models/beta/memory_stores/beta_managed_agents_error.rbs +59 -0
- data/sig/anthropic/models/beta/memory_stores/beta_managed_agents_memory_list_item.rbs +30 -0
- data/sig/anthropic/models/beta/memory_stores/beta_managed_agents_service_account_actor.rbs +26 -0
- data/sig/anthropic/models/beta/memory_stores/memory_version_list_params.rbs +7 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_result.rbs +21 -0
- data/sig/anthropic/models/beta/session_create_params.rbs +50 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_agent_mcp_tool_result_event.rbs +34 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_agent_message_event.rbs +13 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_agent_thread_message_received_event.rbs +27 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_agent_thread_message_sent_event.rbs +27 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_agent_tool_result_event.rbs +34 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_billing_error.rbs +14 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_credential_host_unreachable_error.rbs +14 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_document_block.rbs +28 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_event_params.rbs +54 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_github_repository_resource.rbs +15 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_image_block.rbs +22 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_mcp_authentication_failed_error.rbs +14 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_mcp_connection_failed_error.rbs +14 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_model_overloaded_error.rbs +14 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_model_rate_limited_error.rbs +14 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_model_request_failed_error.rbs +14 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_send_session_events.rbs +75 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_session_error_event.rbs +65 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_session_event.rbs +313 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_session_resource.rbs +43 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_session_status_idle_event.rbs +19 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_session_thread.rbs +30 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_session_thread_status_idle_event.rbs +19 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_stream_session_events.rbs +325 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_stream_session_thread_events.rbs +325 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_unknown_error.rbs +14 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_user_custom_tool_result_event.rbs +34 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_user_custom_tool_result_event_params.rbs +34 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_user_define_outcome_event.rbs +15 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_user_define_outcome_event_params.rbs +15 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_user_message_event.rbs +27 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_user_message_event_params.rbs +27 -0
- data/sig/anthropic/models/beta/sessions/beta_managed_agents_user_tool_result_event_params.rbs +34 -0
- data/sig/anthropic/models/beta/sessions/resource_retrieve_response.rbs +43 -0
- data/sig/anthropic/models/beta/sessions/resource_update_response.rbs +43 -0
- data/sig/anthropic/models/beta/user_profile_create_params.rbs +20 -0
- data/sig/anthropic/models/beta/user_profile_update_params.rbs +16 -0
- data/sig/anthropic/models/beta/vaults/beta_managed_agents_credential.rbs +27 -0
- data/sig/anthropic/models/beta/vaults/beta_managed_agents_credential_networking_params.rbs +13 -0
- data/sig/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_auth_response.rbs +13 -0
- data/sig/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_params.rbs +17 -0
- data/sig/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_response.rbs +14 -0
- data/sig/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_update_params.rbs +14 -0
- data/sig/anthropic/models/beta/vaults/credential_create_params.rbs +33 -0
- data/sig/anthropic/models/beta/vaults/credential_update_params.rbs +28 -0
- data/sig/anthropic/models/beta_error.rbs +42 -0
- data/sig/anthropic/models/citations_delta.rbs +63 -0
- data/sig/anthropic/models/content_block.rbs +91 -0
- data/sig/anthropic/models/content_block_param.rbs +140 -1
- data/sig/anthropic/models/content_block_source_content.rbs +20 -0
- data/sig/anthropic/models/document_block.rbs +17 -0
- data/sig/anthropic/models/document_block_param.rbs +24 -0
- data/sig/anthropic/models/error_object.rbs +42 -0
- data/sig/anthropic/models/image_block_param.rbs +14 -0
- data/sig/anthropic/models/messages/message_batch_result.rbs +21 -0
- data/sig/anthropic/models/raw_content_block_delta.rbs +27 -0
- data/sig/anthropic/models/raw_content_block_start_event.rbs +91 -0
- data/sig/anthropic/models/raw_message_stream_event.rbs +37 -0
- data/sig/anthropic/models/server_tool_use_block.rbs +15 -0
- data/sig/anthropic/models/server_tool_use_block_param.rbs +15 -0
- data/sig/anthropic/models/text_citation.rbs +63 -0
- data/sig/anthropic/models/text_citation_param.rbs +59 -0
- data/sig/anthropic/models/thinking_config_param.rbs +18 -0
- data/sig/anthropic/models/tool_choice.rbs +21 -0
- data/sig/anthropic/models/tool_result_block_param.rbs +49 -0
- data/sig/anthropic/models/tool_use_block.rbs +15 -0
- data/sig/anthropic/models/tool_use_block_param.rbs +15 -0
- data/sig/anthropic/models/web_fetch_tool_result_block.rbs +15 -0
- data/sig/anthropic/models/web_fetch_tool_result_block_param.rbs +15 -0
- data/sig/anthropic/models/web_search_tool_result_block.rbs +15 -0
- data/sig/anthropic/models/web_search_tool_result_block_param.rbs +15 -0
- data/sig/anthropic/models.rbs +0 -2
- data/sig/anthropic/resources/beta/dreams.rbs +1 -0
- data/sig/anthropic/resources/beta/memory_stores/memory_versions.rbs +1 -0
- data/sig/anthropic/resources/beta/user_profiles.rbs +2 -0
- metadata +14 -8
- data/lib/anthropic/models/beta/beta_mid_conversation_system_block_param.rb +0 -71
- data/lib/anthropic/models/mid_conversation_system_block_param.rb +0 -37
- data/rbi/anthropic/models/beta/beta_mid_conversation_system_block_param.rbi +0 -125
- data/rbi/anthropic/models/mid_conversation_system_block_param.rbi +0 -66
- data/sig/anthropic/models/beta/beta_mid_conversation_system_block_param.rbs +0 -45
- data/sig/anthropic/models/mid_conversation_system_block_param.rbs +0 -30
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9a5ec69ebe4f2fe1d743013098cb879401a601825c244fdb587b36c055ebfc5
|
|
4
|
+
data.tar.gz: de874bbfc686b83f328bccdc1a95f8a4e5211ad6f73895d4f117ffd9e6faf260
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79022be4b042788f7586f77a3ab32f3036bd82733505afbe387aae2f709e3db1de135ab2de906f561915a417aa73c19576c8564c7ba1632e746b620ec358b8e4
|
|
7
|
+
data.tar.gz: cd8af8f0f3577f4558b8126607b2de05bd994584fe549792af7434eb7b791f25eda4ead4ea583b233b3bf73c2f07ed4f03ebf21338dd55af1a33bee77dd150e5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.63.0 (2026-08-18)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.62.0...v1.63.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.62.0...v1.63.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** additions to files and memory stores ([f4baf57](https://github.com/anthropics/anthropic-sdk-ruby/commit/f4baf57eaf96b098ec63c895c84c701294583240))
|
|
10
|
+
* **api:** updates to skill, files, and user profiles ([ba0844b](https://github.com/anthropics/anthropic-sdk-ruby/commit/ba0844b290a2036cba7c0a79e500497d48096c5f))
|
|
11
|
+
* **tools:** add `tool_options` to `BaseTool` (strict, cache_control, …) ([#161](https://github.com/anthropics/anthropic-sdk-ruby/issues/161)) ([df278f9](https://github.com/anthropics/anthropic-sdk-ruby/commit/df278f9170ce5ff130433602b18470248dcfa3f4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **api:** remove unsupported mid_conv_system content block ([687a6da](https://github.com/anthropics/anthropic-sdk-ruby/commit/687a6da56fe9cb85753f6a819d7978580bed61c9))
|
|
17
|
+
* **aws,google_cloud:** adopt the default-credentials hook in the AWS and Google Cloud clients ([#170](https://github.com/anthropics/anthropic-sdk-ruby/issues/170)) ([169fea9](https://github.com/anthropics/anthropic-sdk-ruby/commit/169fea9f5ef8d0798bc0e795e0579eae367939e2))
|
|
18
|
+
* **client:** never fall back to the first-party base URL when default credentials are disabled ([#193](https://github.com/anthropics/anthropic-sdk-ruby/issues/193)) ([b6e9f56](https://github.com/anthropics/anthropic-sdk-ruby/commit/b6e9f562c2872dc5f3ca3a4d6c4025e0e75397d1))
|
|
19
|
+
* **tool-runner:** forward the server-assigned container on follow-up requests ([#189](https://github.com/anthropics/anthropic-sdk-ruby/issues/189)) ([891ac9b](https://github.com/anthropics/anthropic-sdk-ruby/commit/891ac9b8f12234bfe6938086937505e27175df46))
|
|
20
|
+
* **tool-runner:** replay unknown tool_use input verbatim ([#173](https://github.com/anthropics/anthropic-sdk-ruby/issues/173)) ([566a881](https://github.com/anthropics/anthropic-sdk-ruby/commit/566a8817fbe8aad5a25b4111021e39d20451ef03))
|
|
21
|
+
* **tool-runner:** stop on refusal instead of executing tools ([#174](https://github.com/anthropics/anthropic-sdk-ruby/issues/174)) ([4b8d2e4](https://github.com/anthropics/anthropic-sdk-ruby/commit/4b8d2e43265d31b55eb9a6f0d3241b62fa510b2d))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Chores
|
|
25
|
+
|
|
26
|
+
* **internal:** remove leftover prism references ([5a416d3](https://github.com/anthropics/anthropic-sdk-ruby/commit/5a416d3f2c784d697a8f9fbc99f5620102ea0c84))
|
|
27
|
+
|
|
28
|
+
## 1.62.0 (2026-08-13)
|
|
29
|
+
|
|
30
|
+
Full Changelog: [v1.61.0...v1.62.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.61.0...v1.62.0)
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* **api:** add output_behavior to dream creation (create a new memory store or update the input store in place) ([836125f](https://github.com/anthropics/anthropic-sdk-ruby/commit/836125f10cee42677d814fa7bb85f693914c6af9))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* **bedrock:** adopt the default-credentials hook in place of the direct base-client bind ([#145](https://github.com/anthropics/anthropic-sdk-ruby/issues/145)) ([e082f28](https://github.com/anthropics/anthropic-sdk-ruby/commit/e082f280846cd00bda4f89b9fb6ad50b4a4a5feb))
|
|
40
|
+
* **client:** accumulate streamed input for server tool use blocks ([#162](https://github.com/anthropics/anthropic-sdk-ruby/issues/162)) ([75382d8](https://github.com/anthropics/anthropic-sdk-ruby/commit/75382d81ebb6b3bedad92749f26e4625d8203097))
|
|
41
|
+
* **client:** add models ([055b440](https://github.com/anthropics/anthropic-sdk-ruby/commit/055b440aa315cf644b08ede51a19f448fab00cbf))
|
|
42
|
+
* **internal:** don't resolve lazy field types when hashing a model class ([#155](https://github.com/anthropics/anthropic-sdk-ruby/issues/155)) ([0a2c06f](https://github.com/anthropics/anthropic-sdk-ruby/commit/0a2c06fcbdb345d751ae0850cac70177cb232d53))
|
|
43
|
+
* **streaming:** apply all message_delta fields when accumulating streamed messages ([#160](https://github.com/anthropics/anthropic-sdk-ruby/issues/160)) ([e537ae2](https://github.com/anthropics/anthropic-sdk-ruby/commit/e537ae23ac5c5701b47812e9062db9c3bd9f29da))
|
|
44
|
+
* **vertex:** don't resolve the shared config store during client init ([#142](https://github.com/anthropics/anthropic-sdk-ruby/issues/142)) ([4108bd4](https://github.com/anthropics/anthropic-sdk-ruby/commit/4108bd4aa3fd3517b51971fdd25f15351bd8f5be))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Documentation
|
|
48
|
+
|
|
49
|
+
* **api:** clarify that user profile name is optional for resold profiles ([e68fd57](https://github.com/anthropics/anthropic-sdk-ruby/commit/e68fd57357fed4964666d84d011b38873abff02d))
|
|
50
|
+
* **client:** move truncated-docs note below the description in YARD doc blocks ([3db8b94](https://github.com/anthropics/anthropic-sdk-ruby/commit/3db8b9489cd2adb207edbb0165ea11fbacc19db4))
|
|
51
|
+
* fix Symbol typo in RDoc comments ([#163](https://github.com/anthropics/anthropic-sdk-ruby/issues/163)) ([1102732](https://github.com/anthropics/anthropic-sdk-ruby/commit/1102732847ffc02eef9d2c69e233f5e6f56787d8))
|
|
52
|
+
|
|
3
53
|
## 1.61.0 (2026-08-07)
|
|
4
54
|
|
|
5
55
|
Full Changelog: [v1.60.0...v1.61.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.60.0...v1.61.0)
|
data/README.md
CHANGED
data/lib/anthropic/client.rb
CHANGED
|
@@ -197,7 +197,7 @@ module Anthropic
|
|
|
197
197
|
|
|
198
198
|
has_explicit_credential = api_key || auth_token || credentials || config
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
if !has_explicit_credential && resolve_default_credentials?
|
|
201
201
|
api_key = ENV["ANTHROPIC_API_KEY"]
|
|
202
202
|
auth_token = ENV["ANTHROPIC_AUTH_TOKEN"]
|
|
203
203
|
end
|
|
@@ -208,7 +208,7 @@ module Anthropic
|
|
|
208
208
|
@token_cache = nil
|
|
209
209
|
|
|
210
210
|
base_url_is_explicit = base_url && !base_url.empty?
|
|
211
|
-
base_url ||= ENV["ANTHROPIC_BASE_URL"]
|
|
211
|
+
base_url ||= ENV["ANTHROPIC_BASE_URL"] if resolve_default_credentials?
|
|
212
212
|
|
|
213
213
|
credential_headers = {}
|
|
214
214
|
|
|
@@ -223,7 +223,7 @@ module Anthropic
|
|
|
223
223
|
@credentials = credentials
|
|
224
224
|
end
|
|
225
225
|
|
|
226
|
-
if @credentials.nil? && @api_key.nil? && @auth_token.nil?
|
|
226
|
+
if @credentials.nil? && @api_key.nil? && @auth_token.nil? && resolve_default_credentials?
|
|
227
227
|
default_base_url = base_url || "https://api.anthropic.com"
|
|
228
228
|
result = Anthropic::Credentials.default_credentials(base_url: default_base_url)
|
|
229
229
|
if result
|
|
@@ -234,13 +234,20 @@ module Anthropic
|
|
|
234
234
|
end
|
|
235
235
|
|
|
236
236
|
warn_explicit_shadow(api_key: api_key, auth_token: auth_token, credentials: credentials || config)
|
|
237
|
-
warn_env_shadow(api_key: api_key, auth_token: auth_token)
|
|
237
|
+
warn_env_shadow(api_key: api_key, auth_token: auth_token) if resolve_default_credentials?
|
|
238
238
|
|
|
239
239
|
if @credentials
|
|
240
240
|
@token_cache = Anthropic::Credentials::TokenCache.new(@credentials)
|
|
241
241
|
end
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
if resolve_default_credentials?
|
|
244
|
+
base_url ||= "https://api.anthropic.com"
|
|
245
|
+
elsif base_url.to_s.empty?
|
|
246
|
+
raise ArgumentError.new(
|
|
247
|
+
"No base_url was resolved for #{self.class.name}; " \
|
|
248
|
+
"platform clients must supply their own endpoint."
|
|
249
|
+
)
|
|
250
|
+
end
|
|
244
251
|
|
|
245
252
|
if @credentials.respond_to?(:bind_base_url)
|
|
246
253
|
@credentials.bind_base_url(base_url)
|
|
@@ -295,6 +302,23 @@ module Anthropic
|
|
|
295
302
|
|
|
296
303
|
private
|
|
297
304
|
|
|
305
|
+
# @api private
|
|
306
|
+
#
|
|
307
|
+
# Whether to resolve credentials from the default chain (the static
|
|
308
|
+
# +ANTHROPIC_API_KEY+ / +ANTHROPIC_AUTH_TOKEN+ env vars and the shared
|
|
309
|
+
# config store / federation auto-discovery, precedence steps 2–5 above)
|
|
310
|
+
# when no explicit credential argument is passed. Called once from
|
|
311
|
+
# {#initialize}, so overrides must not depend on subclass instance state.
|
|
312
|
+
# Subclasses that bring their own auth scheme override this to +false+ so
|
|
313
|
+
# ambient first-party credentials are never resolved or folded into
|
|
314
|
+
# requests bound for another platform's endpoint. Returning +false+ also
|
|
315
|
+
# withholds the +ANTHROPIC_BASE_URL+ / +https://api.anthropic.com+
|
|
316
|
+
# base-URL fallback, so such a subclass must pass its own +base_url+ or
|
|
317
|
+
# {#initialize} raises +ArgumentError+.
|
|
318
|
+
#
|
|
319
|
+
# @return [Boolean]
|
|
320
|
+
def resolve_default_credentials? = true
|
|
321
|
+
|
|
298
322
|
def warn_explicit_shadow(api_key:, auth_token:, credentials:)
|
|
299
323
|
return if credentials.nil?
|
|
300
324
|
|
data/lib/anthropic/errors.rb
CHANGED
|
@@ -60,6 +60,12 @@ module Anthropic
|
|
|
60
60
|
# @return [Object, nil]
|
|
61
61
|
attr_accessor :body
|
|
62
62
|
|
|
63
|
+
# @return [String, nil]
|
|
64
|
+
def request_id = headers&.[]("request-id")
|
|
65
|
+
|
|
66
|
+
# @return [String, nil]
|
|
67
|
+
def workspace_id = headers&.[]("anthropic-workspace-id")
|
|
68
|
+
|
|
63
69
|
# @api private
|
|
64
70
|
#
|
|
65
71
|
# @param url [URI::Generic]
|
|
@@ -53,7 +53,7 @@ module Anthropic
|
|
|
53
53
|
#
|
|
54
54
|
# @param max_retry_delay [Float]
|
|
55
55
|
#
|
|
56
|
-
def initialize(
|
|
56
|
+
def initialize(
|
|
57
57
|
api_key: nil,
|
|
58
58
|
aws_access_key: nil,
|
|
59
59
|
aws_secret_access_key: nil,
|
|
@@ -84,27 +84,19 @@ module Anthropic
|
|
|
84
84
|
derive_base_url: ->(region) { "https://aws-external-anthropic.#{region}.api.aws" }
|
|
85
85
|
)
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# not apply here.
|
|
95
|
-
Anthropic::Internal::Transport::BaseClient.instance_method(:initialize).bind(self).call(
|
|
87
|
+
# In API-key mode the gateway key rides the base client's `api_key`
|
|
88
|
+
# slot; {#resolve_default_credentials?} keeps first-party credential
|
|
89
|
+
# auto-discovery out of the picture when it is absent. The gateway
|
|
90
|
+
# serves the full first-party API, so every resource the parent wires
|
|
91
|
+
# up stays available.
|
|
92
|
+
super(
|
|
93
|
+
api_key: effective_api_key,
|
|
96
94
|
base_url: resolved_base_url,
|
|
97
95
|
timeout: timeout,
|
|
98
96
|
max_retries: max_retries,
|
|
99
97
|
initial_retry_delay: initial_retry_delay,
|
|
100
|
-
max_retry_delay: max_retry_delay
|
|
101
|
-
headers: {"anthropic-version" => "2023-06-01"}
|
|
98
|
+
max_retry_delay: max_retry_delay
|
|
102
99
|
)
|
|
103
|
-
|
|
104
|
-
@completions = Anthropic::Resources::Completions.new(client: self)
|
|
105
|
-
@messages = Anthropic::Resources::Messages.new(client: self)
|
|
106
|
-
@models = Anthropic::Resources::Models.new(client: self)
|
|
107
|
-
@beta = Anthropic::Resources::Beta.new(client: self)
|
|
108
100
|
end
|
|
109
101
|
|
|
110
102
|
# @api private
|
|
@@ -44,6 +44,7 @@ module Anthropic
|
|
|
44
44
|
use_bearer_auth: false
|
|
45
45
|
)
|
|
46
46
|
@use_bearer_auth = use_bearer_auth
|
|
47
|
+
base_url = nil if base_url.to_s.empty?
|
|
47
48
|
begin
|
|
48
49
|
require("aws-sdk-core")
|
|
49
50
|
rescue LoadError
|
|
@@ -119,12 +120,12 @@ module Anthropic
|
|
|
119
120
|
end
|
|
120
121
|
end
|
|
121
122
|
|
|
122
|
-
if base_url
|
|
123
|
+
if !base_url && !aws_region.to_s.empty?
|
|
123
124
|
@aws_region ||= aws_region
|
|
124
125
|
base_url = derive_base_url.call(aws_region)
|
|
125
126
|
end
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
unless base_url
|
|
128
129
|
# rubocop:disable Layout/LineLength
|
|
129
130
|
raise ArgumentError.new("No base_url was given and no aws_region is available to derive one. Set the `base_url` argument or provide an `aws_region`.")
|
|
130
131
|
# rubocop:enable Layout/LineLength
|
|
@@ -147,6 +148,16 @@ module Anthropic
|
|
|
147
148
|
super
|
|
148
149
|
end
|
|
149
150
|
|
|
151
|
+
# @api private
|
|
152
|
+
#
|
|
153
|
+
# AWS-authenticated clients never resolve ambient first-party
|
|
154
|
+
# credentials, which would fold the shared config store's headers and
|
|
155
|
+
# bearer into requests bound for a third-party endpoint.
|
|
156
|
+
#
|
|
157
|
+
# @return [Boolean]
|
|
158
|
+
# @see Anthropic::Client#resolve_default_credentials?
|
|
159
|
+
private def resolve_default_credentials? = false
|
|
160
|
+
|
|
150
161
|
# The AWS provider middleware entry: applies the workspace-id header and
|
|
151
162
|
# SigV4 signing per attempt. Return from the including class's
|
|
152
163
|
# `provider_middleware`. Pure — requests are reused across retry
|
|
@@ -60,7 +60,7 @@ module Anthropic
|
|
|
60
60
|
# the Bedrock URL rewrite and SigV4 signing happen inside the continuation, per
|
|
61
61
|
# attempt.
|
|
62
62
|
#
|
|
63
|
-
def initialize(
|
|
63
|
+
def initialize(
|
|
64
64
|
aws_region: nil,
|
|
65
65
|
base_url: nil,
|
|
66
66
|
max_retries: self.class::DEFAULT_MAX_RETRIES,
|
|
@@ -121,36 +121,38 @@ module Anthropic
|
|
|
121
121
|
@aws_region = aws_region
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
base_url
|
|
125
|
-
|
|
126
|
-
"https://bedrock-runtime.#{@aws_region}.amazonaws.com"
|
|
127
|
-
)
|
|
124
|
+
base_url = ENV["ANTHROPIC_BEDROCK_BASE_URL"] if base_url.to_s.empty?
|
|
125
|
+
base_url = "https://bedrock-runtime.#{@aws_region}.amazonaws.com" if base_url.to_s.empty?
|
|
128
126
|
|
|
129
|
-
@api_key = nil
|
|
130
|
-
@auth_token = @signer ? nil : api_key
|
|
131
|
-
@credentials = nil
|
|
132
|
-
@token_cache = nil
|
|
133
127
|
# For AWSAuth#auth_headers: suppress key headers in SigV4 mode; in
|
|
134
128
|
# API-key mode fall through to the base bearer-token handling.
|
|
135
129
|
@use_sig_v4 = !@signer.nil?
|
|
136
130
|
@use_bearer_auth = false
|
|
137
131
|
|
|
138
|
-
#
|
|
139
|
-
#
|
|
140
|
-
#
|
|
141
|
-
|
|
132
|
+
# The Bedrock bearer rides the base client's `auth_token` slot;
|
|
133
|
+
# {#resolve_default_credentials?} keeps first-party credential
|
|
134
|
+
# auto-discovery out of the picture when it is absent.
|
|
135
|
+
super(
|
|
136
|
+
auth_token: @signer ? nil : api_key,
|
|
142
137
|
base_url: base_url,
|
|
143
138
|
timeout: timeout,
|
|
144
139
|
max_retries: max_retries,
|
|
145
140
|
initial_retry_delay: initial_retry_delay,
|
|
146
141
|
max_retry_delay: max_retry_delay,
|
|
147
|
-
headers: {"anthropic-version" => "2023-06-01"},
|
|
148
142
|
middleware: middleware
|
|
149
143
|
)
|
|
144
|
+
end
|
|
150
145
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
# The Models API is not available on Bedrock, so the resource the
|
|
147
|
+
# parent wires up would target routes the Bedrock host does not serve
|
|
148
|
+
# — keep it unavailable, matching the SDK's other Bedrock clients.
|
|
149
|
+
#
|
|
150
|
+
# @raise [NotImplementedError]
|
|
151
|
+
def models
|
|
152
|
+
# rubocop:disable Layout/LineLength
|
|
153
|
+
message = "Please instead use https://docs.anthropic.com/en/api/claude-on-amazon-bedrock#list-available-models to list available models on Bedrock."
|
|
154
|
+
# rubocop:enable Layout/LineLength
|
|
155
|
+
raise NotImplementedError.new(message)
|
|
154
156
|
end
|
|
155
157
|
|
|
156
158
|
# @api private
|
|
@@ -31,15 +31,6 @@ module Anthropic
|
|
|
31
31
|
# @return [String, nil]
|
|
32
32
|
attr_reader :workspace_id
|
|
33
33
|
|
|
34
|
-
# @return [Anthropic::Resources::Messages]
|
|
35
|
-
attr_reader :messages
|
|
36
|
-
|
|
37
|
-
# @return [Anthropic::Resources::Models]
|
|
38
|
-
attr_reader :models
|
|
39
|
-
|
|
40
|
-
# @return [Anthropic::Resources::Beta]
|
|
41
|
-
attr_reader :beta
|
|
42
|
-
|
|
43
34
|
# Creates a new client for the Anthropic API on the Google Cloud gateway.
|
|
44
35
|
#
|
|
45
36
|
# Authentication uses Google credentials by precedence (unless
|
|
@@ -95,7 +86,7 @@ module Anthropic
|
|
|
95
86
|
# is applied per attempt, after user middleware.
|
|
96
87
|
#
|
|
97
88
|
# @raise [ArgumentError]
|
|
98
|
-
def initialize(
|
|
89
|
+
def initialize(
|
|
99
90
|
project: ENV["ANTHROPIC_GOOGLE_CLOUD_PROJECT"] || ENV["GOOGLE_CLOUD_PROJECT"],
|
|
100
91
|
location: ENV["ANTHROPIC_GOOGLE_CLOUD_LOCATION"] || "global",
|
|
101
92
|
workspace_id: ENV["ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID"],
|
|
@@ -144,33 +135,31 @@ module Anthropic
|
|
|
144
135
|
end
|
|
145
136
|
@workspace_id = workspace_id
|
|
146
137
|
|
|
147
|
-
base_url =
|
|
148
|
-
|
|
149
|
-
# Never inherit first-party Anthropic credentials from the
|
|
150
|
-
# environment: clear the ivars `Anthropic::Client#auth_headers` reads,
|
|
151
|
-
# and bind `BaseClient#initialize` directly so the parent's
|
|
152
|
-
# credential-provider / `ANTHROPIC_BASE_URL` resolution is skipped
|
|
153
|
-
# entirely.
|
|
154
|
-
@api_key = nil
|
|
155
|
-
@auth_token = nil
|
|
156
|
-
@credentials = nil
|
|
157
|
-
@token_cache = nil
|
|
138
|
+
base_url = nil if base_url.to_s.empty?
|
|
139
|
+
base_url ||= derive_base_url
|
|
158
140
|
|
|
159
|
-
|
|
141
|
+
# No first-party credential is ever passed up, and
|
|
142
|
+
# {#resolve_default_credentials?} keeps the parent from discovering
|
|
143
|
+
# one; `base_url` is always resolved by this point, so the parent's
|
|
144
|
+
# `ANTHROPIC_BASE_URL` fallback never applies. The parent wires up
|
|
145
|
+
# every resource; {#completions} withholds the one the gateway does
|
|
146
|
+
# not serve.
|
|
147
|
+
super(
|
|
160
148
|
base_url: base_url,
|
|
161
149
|
timeout: timeout,
|
|
162
150
|
max_retries: max_retries,
|
|
163
151
|
initial_retry_delay: initial_retry_delay,
|
|
164
152
|
max_retry_delay: max_retry_delay,
|
|
165
|
-
headers: {"anthropic-version" => "2023-06-01"},
|
|
166
153
|
middleware: middleware
|
|
167
154
|
)
|
|
168
|
-
|
|
169
|
-
@messages = Anthropic::Resources::Messages.new(client: self)
|
|
170
|
-
@models = Anthropic::Resources::Models.new(client: self)
|
|
171
|
-
@beta = Anthropic::Resources::Beta.new(client: self)
|
|
172
155
|
end
|
|
173
156
|
|
|
157
|
+
# @api private
|
|
158
|
+
#
|
|
159
|
+
# @return [Boolean]
|
|
160
|
+
# @see Anthropic::Client#resolve_default_credentials?
|
|
161
|
+
private def resolve_default_credentials? = false
|
|
162
|
+
|
|
174
163
|
# The deprecated text Completions endpoint is not supported on the
|
|
175
164
|
# Google Cloud gateway.
|
|
176
165
|
#
|
|
@@ -9,7 +9,7 @@ module Anthropic
|
|
|
9
9
|
# Extract tool models from the request and convert them to JSON Schema
|
|
10
10
|
# Returns a hash mapping tool name to Ruby model.
|
|
11
11
|
#
|
|
12
|
-
# @param data [Hash{
|
|
12
|
+
# @param data [Hash{Symbol=>Object}]
|
|
13
13
|
#
|
|
14
14
|
# @param strict [Boolean, nil]
|
|
15
15
|
#
|
|
@@ -38,26 +38,27 @@ module Anthropic
|
|
|
38
38
|
# rubocop:disable Metrics/BlockLength
|
|
39
39
|
mapped = tool_array.map do |tool|
|
|
40
40
|
case tool
|
|
41
|
-
#
|
|
42
|
-
in Anthropic::Helpers::Tools::BaseTool
|
|
41
|
+
# Runnable tool instance (an `Anthropic::BaseTool` subclass, hand-written or helper-built):
|
|
42
|
+
in Anthropic::Helpers::Tools::BaseTool
|
|
43
43
|
name = tool_api_name(tool)
|
|
44
|
+
# Helper-built tools (e.g. MCP) declare an explicit `tool_name` and only send the
|
|
45
|
+
# description they were given; hand-written tools fall back to their name.
|
|
44
46
|
description = tool.class.doc_string
|
|
47
|
+
description ||= name unless tool.class.tool_name
|
|
45
48
|
tools.store(name, tool)
|
|
46
49
|
input_schema = Anthropic::Helpers::InputSchema::JsonSchemaConverter.to_json_schema(tool)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
# On a clash the derived keys win, so nothing in `tool_options` can shadow them.
|
|
51
|
+
definition =
|
|
52
|
+
{name:, description:, input_schema:}
|
|
53
|
+
.merge(tool.class.tool_options) { |_key, derived, _option| derived }
|
|
54
|
+
.compact
|
|
55
|
+
definition.tap { _1.update(strict:) if strict }
|
|
56
|
+
# Input schema class used directly as a tool:
|
|
53
57
|
in Anthropic::Helpers::InputSchema::JsonSchemaConverter
|
|
54
|
-
name =
|
|
55
|
-
tool.is_a?(Anthropic::Helpers::Tools::BaseTool) ? tool_api_name(tool) : model_name(tool.name)
|
|
58
|
+
name = model_name(tool.name)
|
|
56
59
|
|
|
57
60
|
description =
|
|
58
61
|
case tool
|
|
59
|
-
in Anthropic::Helpers::Tools::BaseTool
|
|
60
|
-
tool.class.doc_string || name
|
|
61
62
|
in Class if tool <= Anthropic::Helpers::InputSchema::BaseModel
|
|
62
63
|
tool.doc_string || name
|
|
63
64
|
else
|
|
@@ -82,6 +83,11 @@ module Anthropic
|
|
|
82
83
|
end
|
|
83
84
|
# rubocop:enable Metrics/BlockLength
|
|
84
85
|
tool_array.replace(mapped)
|
|
86
|
+
else
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Matched separately from `tools:` so a request can carry both tools and a structured output format.
|
|
90
|
+
case data
|
|
85
91
|
# GA: output_config with BaseModel class as format
|
|
86
92
|
in {output_config: {format: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model} => output_config}
|
|
87
93
|
name = model_name(model.name)
|
|
@@ -128,13 +134,13 @@ module Anthropic
|
|
|
128
134
|
|
|
129
135
|
# @api private
|
|
130
136
|
#
|
|
131
|
-
# @param raw [Hash{
|
|
137
|
+
# @param raw [Hash{Symbol=>Object}]
|
|
132
138
|
#
|
|
133
139
|
# @param tools [Hash{String=>Class}]
|
|
134
140
|
#
|
|
135
141
|
# @param models [Hash{String=>Class}]
|
|
136
142
|
#
|
|
137
|
-
# @return [Hash{
|
|
143
|
+
# @return [Hash{Symbol=>Object}]
|
|
138
144
|
def parse_input_schemas!(raw, tools:, models:)
|
|
139
145
|
raw[:content]&.each do |content|
|
|
140
146
|
case content
|
|
@@ -123,12 +123,14 @@ module Anthropic
|
|
|
123
123
|
case (delta = event.delta)
|
|
124
124
|
in Anthropic::Models::TextDelta | Anthropic::Models::BetaTextDelta if content.type == :text
|
|
125
125
|
content.text += delta.text
|
|
126
|
-
in Anthropic::Models::InputJSONDelta | Anthropic::Models::BetaInputJSONDelta if content
|
|
127
|
-
|
|
126
|
+
in Anthropic::Models::InputJSONDelta | Anthropic::Models::BetaInputJSONDelta if tracks_tool_input?(content)
|
|
127
|
+
# `input` itself is the partial-JSON buffer mid-stream: it starts as the
|
|
128
|
+
# `{}` placeholder from content_block_start and holds the raw String once
|
|
129
|
+
# the first delta lands (server/MCP tool blocks have no `_json_buf`).
|
|
130
|
+
json_buf = content.input.is_a?(String) ? content.input : ""
|
|
128
131
|
json_buf += delta.partial_json
|
|
129
132
|
|
|
130
133
|
content.input = json_buf
|
|
131
|
-
content._json_buf = json_buf
|
|
132
134
|
in Anthropic::Models::CitationsDelta | Anthropic::Models::BetaCitationsDelta if content.type == :text
|
|
133
135
|
content.citations ||= []
|
|
134
136
|
content.citations << delta.citation
|
|
@@ -147,7 +149,7 @@ module Anthropic
|
|
|
147
149
|
# finished block must carry the decoded object, as in the non-streaming
|
|
148
150
|
# message and the other SDKs' accumulators.
|
|
149
151
|
case current_snapshot.content[event.index]
|
|
150
|
-
in {
|
|
152
|
+
in {input: String => raw} => content if tracks_tool_input?(content)
|
|
151
153
|
begin
|
|
152
154
|
content.input = decode_tool_use_input(raw)
|
|
153
155
|
rescue JSON::ParserError
|
|
@@ -156,9 +158,15 @@ module Anthropic
|
|
|
156
158
|
else
|
|
157
159
|
end
|
|
158
160
|
in Anthropic::Models::RawMessageDeltaEvent | Anthropic::Models::BetaRawMessageDeltaEvent
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
# message_start already seeds the null placeholders for these, and the
|
|
162
|
+
# generated setters cannot take a nil, so skip the ones the event omits.
|
|
163
|
+
current_snapshot.stop_reason = event.delta.stop_reason unless event.delta.stop_reason.nil?
|
|
164
|
+
current_snapshot.stop_sequence = event.delta.stop_sequence unless event.delta.stop_sequence.nil?
|
|
161
165
|
current_snapshot.stop_details = event.delta.stop_details unless event.delta.stop_details.nil?
|
|
166
|
+
|
|
167
|
+
# Only reported once a container actually ran, and never on message_start.
|
|
168
|
+
current_snapshot.container = event.delta.container unless event.delta.container.nil?
|
|
169
|
+
|
|
162
170
|
current_snapshot.usage.output_tokens = event.usage.output_tokens
|
|
163
171
|
|
|
164
172
|
# The message_delta usage is authoritative for the final counts; carry every
|
|
@@ -176,6 +184,9 @@ module Anthropic
|
|
|
176
184
|
unless event.usage.server_tool_use.nil?
|
|
177
185
|
current_snapshot.usage.server_tool_use = event.usage.server_tool_use
|
|
178
186
|
end
|
|
187
|
+
unless event.usage.output_tokens_details.nil?
|
|
188
|
+
current_snapshot.usage.output_tokens_details = event.usage.output_tokens_details
|
|
189
|
+
end
|
|
179
190
|
|
|
180
191
|
if event.is_a?(Anthropic::Models::BetaRawMessageDeltaEvent)
|
|
181
192
|
unless event.usage.iterations.nil?
|
|
@@ -184,6 +195,10 @@ module Anthropic
|
|
|
184
195
|
unless event.usage.fallback_credit.nil?
|
|
185
196
|
current_snapshot.usage.fallback_credit = event.usage.fallback_credit
|
|
186
197
|
end
|
|
198
|
+
# Applied context-management edits ride on the event, not on `delta`.
|
|
199
|
+
unless event.context_management.nil?
|
|
200
|
+
current_snapshot.context_management = event.context_management
|
|
201
|
+
end
|
|
187
202
|
end
|
|
188
203
|
else
|
|
189
204
|
end
|
|
@@ -222,7 +237,7 @@ module Anthropic
|
|
|
222
237
|
text: delta.text,
|
|
223
238
|
snapshot: content_block.text
|
|
224
239
|
)
|
|
225
|
-
in Anthropic::Models::InputJSONDelta | Anthropic::Models::BetaInputJSONDelta if content_block
|
|
240
|
+
in Anthropic::Models::InputJSONDelta | Anthropic::Models::BetaInputJSONDelta if tracks_tool_input?(content_block)
|
|
226
241
|
events_to_yield << Anthropic::Streaming::InputJsonEvent.new(
|
|
227
242
|
type: :input_json,
|
|
228
243
|
partial_json: delta.partial_json,
|
|
@@ -269,7 +284,21 @@ module Anthropic
|
|
|
269
284
|
|
|
270
285
|
# @api private
|
|
271
286
|
#
|
|
272
|
-
#
|
|
287
|
+
# Content block types whose `input` streams in as input_json_delta events.
|
|
288
|
+
TOOL_INPUT_BLOCK_TYPES = [:tool_use, :server_tool_use, :mcp_tool_use].freeze
|
|
289
|
+
|
|
290
|
+
# @api private
|
|
291
|
+
#
|
|
292
|
+
# @param content_block [Object]
|
|
293
|
+
#
|
|
294
|
+
# @return [Boolean]
|
|
295
|
+
private def tracks_tool_input?(content_block)
|
|
296
|
+
TOOL_INPUT_BLOCK_TYPES.include?(content_block.type)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# @api private
|
|
300
|
+
#
|
|
301
|
+
# Decodes a tool-use block's buffered partial-JSON input. An empty buffer
|
|
273
302
|
# means a no-argument tool call, which the wire encodes as an empty object.
|
|
274
303
|
#
|
|
275
304
|
# @param raw [String]
|
|
@@ -25,15 +25,6 @@ module Anthropic
|
|
|
25
25
|
# @return [String, nil]
|
|
26
26
|
attr_accessor :tool_name
|
|
27
27
|
|
|
28
|
-
# @api private
|
|
29
|
-
#
|
|
30
|
-
# Extra tool-definition properties merged into the API payload (e.g.
|
|
31
|
-
# `cache_control`, `defer_loading`, `allowed_callers`, `eager_input_streaming`,
|
|
32
|
-
# `input_examples`, `strict`).
|
|
33
|
-
#
|
|
34
|
-
# @return [Hash{Symbol=>Object}, nil]
|
|
35
|
-
attr_accessor :tool_extra_props
|
|
36
|
-
|
|
37
28
|
# @api public
|
|
38
29
|
#
|
|
39
30
|
# @param description [String]
|
|
@@ -46,10 +37,78 @@ module Anthropic
|
|
|
46
37
|
# @model [Class<Anthropic::Helpers::InputSchema::BaseModel>]
|
|
47
38
|
def input_schema(model) = (@model = model)
|
|
48
39
|
|
|
40
|
+
# @api public
|
|
41
|
+
#
|
|
42
|
+
# Declares additional properties for this tool's API definition, sent alongside the
|
|
43
|
+
# `name`, `description` and `input_schema` — e.g. `strict`, `cache_control`,
|
|
44
|
+
# `defer_loading`, `allowed_callers`, `eager_input_streaming` or `input_examples`.
|
|
45
|
+
#
|
|
46
|
+
# Options accumulate: each call merges into what was already declared, and a subclass
|
|
47
|
+
# starts from its superclass's options. Called without an argument, returns the declared
|
|
48
|
+
# options as a frozen hash.
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# class GetWeather < Anthropic::BaseTool
|
|
52
|
+
# doc "Get the current weather in a given location"
|
|
53
|
+
# input_schema GetWeatherInput
|
|
54
|
+
# tool_options strict: true, cache_control: {type: :ephemeral}
|
|
55
|
+
# end
|
|
56
|
+
#
|
|
57
|
+
# @param options [Hash{Symbol=>Object}, nil]
|
|
58
|
+
#
|
|
59
|
+
# @return [Hash{Symbol=>Object}]
|
|
60
|
+
def tool_options(options = nil)
|
|
61
|
+
if options.nil?
|
|
62
|
+
return @tool_options if @tool_options
|
|
63
|
+
|
|
64
|
+
# Nothing declared on this class: read through to the superclass (`BaseTool` has none).
|
|
65
|
+
return superclass.respond_to?(:tool_options) ? superclass.tool_options : {}.freeze
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
options = Anthropic::Internal::Util.coerce_hash!(options).to_h.transform_keys(&:to_sym)
|
|
69
|
+
# These either have their own declaration or are derived from the class; letting them
|
|
70
|
+
# through would desync the definition sent to the API from how responses are parsed.
|
|
71
|
+
reserved = options.keys & [:name, :description, :input_schema]
|
|
72
|
+
unless reserved.empty?
|
|
73
|
+
message =
|
|
74
|
+
"#{reserved.map { "`#{_1}`" }.join(', ')} cannot be set through `tool_options`; " \
|
|
75
|
+
"use `doc` and `input_schema` instead (the tool name is derived from the class name)."
|
|
76
|
+
raise ArgumentError.new(message)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Frozen so the stored declaration can't drift from what was validated above.
|
|
80
|
+
@tool_options = Anthropic::Internal::Util.deep_frozen_copy(tool_options.merge(options))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @api private
|
|
84
|
+
#
|
|
85
|
+
# @deprecated Use {.tool_options}.
|
|
86
|
+
#
|
|
87
|
+
# @return [Hash{Symbol=>Object}]
|
|
88
|
+
def tool_extra_props = tool_options
|
|
89
|
+
|
|
90
|
+
# @api private
|
|
91
|
+
#
|
|
92
|
+
# @deprecated Use {.tool_options}.
|
|
93
|
+
#
|
|
94
|
+
# @param props [Hash{Symbol=>Object}, nil]
|
|
95
|
+
def tool_extra_props=(props)
|
|
96
|
+
warn(
|
|
97
|
+
"[DEPRECATION] `tool_extra_props=` is deprecated. Use `tool_options` instead.",
|
|
98
|
+
category: :deprecated
|
|
99
|
+
)
|
|
100
|
+
tool_options(props.to_h)
|
|
101
|
+
end
|
|
102
|
+
|
|
49
103
|
# @api private
|
|
50
104
|
#
|
|
51
105
|
# @param depth [Integer]
|
|
52
|
-
def inspect(depth: 0)
|
|
106
|
+
def inspect(depth: 0)
|
|
107
|
+
# Only hand-written tools carry an input schema class here; helper-built tools (e.g. MCP)
|
|
108
|
+
# hold a plain class and an undeclared schema is nil, neither of which takes `depth:`.
|
|
109
|
+
schema = model.is_a?(Anthropic::Internal::Type::Converter) ? model.inspect(depth:) : model.inspect
|
|
110
|
+
"#{name || tool_name}[#{schema}]"
|
|
111
|
+
end
|
|
53
112
|
end
|
|
54
113
|
|
|
55
114
|
# @api private
|