anthropic 1.9.0 → 1.10.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 +28 -0
- data/README.md +12 -12
- data/lib/anthropic/errors.rb +25 -11
- data/lib/anthropic/internal/page.rb +1 -1
- data/lib/anthropic/internal/stream.rb +1 -0
- data/lib/anthropic/internal/transport/base_client.rb +11 -7
- data/lib/anthropic/internal/type/base_page.rb +1 -1
- data/lib/anthropic/internal/type/base_stream.rb +9 -1
- data/lib/anthropic/internal/util.rb +2 -1
- data/lib/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rb +98 -0
- data/lib/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rb +38 -0
- data/lib/anthropic/models/beta/beta_context_management_config.rb +22 -0
- data/lib/anthropic/models/beta/beta_context_management_response.rb +23 -0
- data/lib/anthropic/models/beta/beta_count_tokens_context_management_response.rb +20 -0
- data/lib/anthropic/models/beta/beta_input_tokens_clear_at_least.rb +25 -0
- data/lib/anthropic/models/beta/beta_input_tokens_trigger.rb +25 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818.rb +40 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818_command.rb +30 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818_create_command.rb +36 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rb +28 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rb +44 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rb +36 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rb +44 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818_view_command.rb +36 -0
- data/lib/anthropic/models/beta/beta_message.rb +9 -1
- data/lib/anthropic/models/beta/beta_message_tokens_count.rb +13 -1
- data/lib/anthropic/models/beta/beta_raw_message_delta_event.rb +9 -1
- data/lib/anthropic/models/beta/beta_stop_reason.rb +1 -0
- data/lib/anthropic/models/beta/beta_tool_union.rb +3 -1
- data/lib/anthropic/models/beta/beta_tool_uses_keep.rb +25 -0
- data/lib/anthropic/models/beta/beta_tool_uses_trigger.rb +25 -0
- data/lib/anthropic/models/beta/message_count_tokens_params.rb +14 -4
- data/lib/anthropic/models/beta/message_create_params.rb +11 -3
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +11 -3
- data/lib/anthropic/models/model.rb +10 -0
- data/lib/anthropic/models/stop_reason.rb +1 -0
- data/lib/anthropic/resources/beta/messages.rb +12 -6
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +17 -0
- data/rbi/anthropic/errors.rbi +29 -2
- data/rbi/anthropic/internal/transport/base_client.rbi +4 -5
- data/rbi/anthropic/internal/type/base_page.rbi +1 -1
- data/rbi/anthropic/internal/type/base_stream.rbi +16 -1
- data/rbi/anthropic/internal/util.rbi +1 -1
- data/rbi/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rbi +183 -0
- data/rbi/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rbi +62 -0
- data/rbi/anthropic/models/beta/beta_context_management_config.rbi +56 -0
- data/rbi/anthropic/models/beta/beta_context_management_response.rbi +53 -0
- data/rbi/anthropic/models/beta/beta_count_tokens_context_management_response.rbi +35 -0
- data/rbi/anthropic/models/beta/beta_input_tokens_clear_at_least.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_input_tokens_trigger.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818_command.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818_create_command.rbi +53 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rbi +41 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rbi +69 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rbi +55 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rbi +64 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818_view_command.rbi +59 -0
- data/rbi/anthropic/models/beta/beta_message.rbi +20 -0
- data/rbi/anthropic/models/beta/beta_message_tokens_count.rbi +40 -2
- data/rbi/anthropic/models/beta/beta_raw_message_delta_event.rbi +20 -0
- data/rbi/anthropic/models/beta/beta_stop_reason.rbi +5 -0
- data/rbi/anthropic/models/beta/beta_tool_union.rbi +1 -0
- data/rbi/anthropic/models/beta/beta_tool_uses_keep.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_tool_uses_trigger.rbi +33 -0
- data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +23 -0
- data/rbi/anthropic/models/beta/message_create_params.rbi +22 -0
- data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +28 -0
- data/rbi/anthropic/models/model.rbi +8 -0
- data/rbi/anthropic/models/stop_reason.rbi +5 -0
- data/rbi/anthropic/resources/beta/messages.rbi +15 -0
- data/sig/anthropic/errors.rbs +7 -0
- data/sig/anthropic/internal/type/base_stream.rbs +5 -0
- data/sig/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rbs +77 -0
- data/sig/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rbs +34 -0
- data/sig/anthropic/models/beta/beta_context_management_config.rbs +26 -0
- data/sig/anthropic/models/beta/beta_context_management_response.rbs +24 -0
- data/sig/anthropic/models/beta/beta_count_tokens_context_management_response.rbs +18 -0
- data/sig/anthropic/models/beta/beta_input_tokens_clear_at_least.rbs +20 -0
- data/sig/anthropic/models/beta/beta_input_tokens_trigger.rbs +19 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818.rbs +34 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818_command.rbs +21 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818_create_command.rbs +26 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rbs +20 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rbs +39 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rbs +26 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rbs +39 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818_view_command.rbs +32 -0
- data/sig/anthropic/models/beta/beta_message.rbs +5 -0
- data/sig/anthropic/models/beta/beta_message_tokens_count.rbs +15 -3
- data/sig/anthropic/models/beta/beta_raw_message_delta_event.rbs +5 -0
- data/sig/anthropic/models/beta/beta_stop_reason.rbs +2 -0
- data/sig/anthropic/models/beta/beta_tool_union.rbs +1 -0
- data/sig/anthropic/models/beta/beta_tool_uses_keep.rbs +19 -0
- data/sig/anthropic/models/beta/beta_tool_uses_trigger.rbs +19 -0
- data/sig/anthropic/models/beta/message_count_tokens_params.rbs +6 -0
- data/sig/anthropic/models/beta/message_create_params.rbs +5 -0
- data/sig/anthropic/models/beta/messages/batch_create_params.rbs +5 -0
- data/sig/anthropic/models/model.rbs +8 -0
- data/sig/anthropic/models/stop_reason.rbs +2 -0
- data/sig/anthropic/resources/beta/messages.rbs +3 -0
- metadata +53 -2
@@ -22,6 +22,10 @@ module Anthropic
|
|
22
22
|
|
23
23
|
variant const: -> { Anthropic::Models::Model::CLAUDE_4_SONNET_20250514 }
|
24
24
|
|
25
|
+
variant const: -> { Anthropic::Models::Model::CLAUDE_SONNET_4_5 }
|
26
|
+
|
27
|
+
variant const: -> { Anthropic::Models::Model::CLAUDE_SONNET_4_5_20250929 }
|
28
|
+
|
25
29
|
variant const: -> { Anthropic::Models::Model::CLAUDE_3_5_SONNET_LATEST }
|
26
30
|
|
27
31
|
variant const: -> { Anthropic::Models::Model::CLAUDE_3_5_SONNET_20241022 }
|
@@ -74,6 +78,12 @@ module Anthropic
|
|
74
78
|
# High-performance model with extended thinking
|
75
79
|
CLAUDE_4_SONNET_20250514 = :"claude-4-sonnet-20250514"
|
76
80
|
|
81
|
+
# Our best model for real-world agents and coding
|
82
|
+
CLAUDE_SONNET_4_5 = :"claude-sonnet-4-5"
|
83
|
+
|
84
|
+
# Our best model for real-world agents and coding
|
85
|
+
CLAUDE_SONNET_4_5_20250929 = :"claude-sonnet-4-5-20250929"
|
86
|
+
|
77
87
|
# Our previous most intelligent model
|
78
88
|
CLAUDE_3_5_SONNET_LATEST = :"claude-3-5-sonnet-latest"
|
79
89
|
|
@@ -20,7 +20,7 @@ module Anthropic
|
|
20
20
|
#
|
21
21
|
# Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
|
22
22
|
#
|
23
|
-
# @overload create(max_tokens:, messages:, model:, container: nil, mcp_servers: nil, metadata: nil, service_tier: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, betas: nil, request_options: {})
|
23
|
+
# @overload create(max_tokens:, messages:, model:, container: nil, context_management: nil, mcp_servers: nil, metadata: nil, service_tier: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, betas: nil, request_options: {})
|
24
24
|
#
|
25
25
|
# @param max_tokens [Integer] Body param: The maximum number of tokens to generate before stopping.
|
26
26
|
#
|
@@ -30,6 +30,8 @@ module Anthropic
|
|
30
30
|
#
|
31
31
|
# @param container [String, nil] Body param: Container identifier for reuse across requests.
|
32
32
|
#
|
33
|
+
# @param context_management [Anthropic::Models::Beta::BetaContextManagementConfig, nil] Body param: Configuration for context management operations.
|
34
|
+
#
|
33
35
|
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] Body param: MCP servers to be utilized in this request
|
34
36
|
#
|
35
37
|
# @param metadata [Anthropic::Models::Beta::BetaMetadata] Body param: An object describing metadata about the request.
|
@@ -46,7 +48,7 @@ module Anthropic
|
|
46
48
|
#
|
47
49
|
# @param tool_choice [Anthropic::Models::Beta::BetaToolChoiceAuto, Anthropic::Models::Beta::BetaToolChoiceAny, Anthropic::Models::Beta::BetaToolChoiceTool, Anthropic::Models::Beta::BetaToolChoiceNone] Body param: How the model should use the provided tools. The model can use a spe
|
48
50
|
#
|
49
|
-
# @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305, Anthropic::Models::Beta::BetaWebFetchTool20250910>] Body param: Definitions of tools that the model may use.
|
51
|
+
# @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaMemoryTool20250818, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305, Anthropic::Models::Beta::BetaWebFetchTool20250910>] Body param: Definitions of tools that the model may use.
|
50
52
|
#
|
51
53
|
# @param top_k [Integer] Body param: Only sample from the top K options for each subsequent token.
|
52
54
|
#
|
@@ -102,7 +104,7 @@ module Anthropic
|
|
102
104
|
#
|
103
105
|
# Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
|
104
106
|
#
|
105
|
-
# @overload stream_raw(max_tokens:, messages:, model:, container: nil, mcp_servers: nil, metadata: nil, service_tier: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, betas: nil, request_options: {})
|
107
|
+
# @overload stream_raw(max_tokens:, messages:, model:, container: nil, context_management: nil, mcp_servers: nil, metadata: nil, service_tier: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, betas: nil, request_options: {})
|
106
108
|
#
|
107
109
|
# @param max_tokens [Integer] Body param: The maximum number of tokens to generate before stopping.
|
108
110
|
#
|
@@ -112,6 +114,8 @@ module Anthropic
|
|
112
114
|
#
|
113
115
|
# @param container [String, nil] Body param: Container identifier for reuse across requests.
|
114
116
|
#
|
117
|
+
# @param context_management [Anthropic::Models::Beta::BetaContextManagementConfig, nil] Body param: Configuration for context management operations.
|
118
|
+
#
|
115
119
|
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] Body param: MCP servers to be utilized in this request
|
116
120
|
#
|
117
121
|
# @param metadata [Anthropic::Models::Beta::BetaMetadata] Body param: An object describing metadata about the request.
|
@@ -128,7 +132,7 @@ module Anthropic
|
|
128
132
|
#
|
129
133
|
# @param tool_choice [Anthropic::Models::Beta::BetaToolChoiceAuto, Anthropic::Models::Beta::BetaToolChoiceAny, Anthropic::Models::Beta::BetaToolChoiceTool, Anthropic::Models::Beta::BetaToolChoiceNone] Body param: How the model should use the provided tools. The model can use a spe
|
130
134
|
#
|
131
|
-
# @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305, Anthropic::Models::Beta::BetaWebFetchTool20250910>] Body param: Definitions of tools that the model may use.
|
135
|
+
# @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaMemoryTool20250818, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305, Anthropic::Models::Beta::BetaWebFetchTool20250910>] Body param: Definitions of tools that the model may use.
|
132
136
|
#
|
133
137
|
# @param top_k [Integer] Body param: Only sample from the top K options for each subsequent token.
|
134
138
|
#
|
@@ -245,12 +249,14 @@ module Anthropic
|
|
245
249
|
# Learn more about token counting in our
|
246
250
|
# [user guide](/en/docs/build-with-claude/token-counting)
|
247
251
|
#
|
248
|
-
# @overload count_tokens(messages:, model:, mcp_servers: nil, system_: nil, thinking: nil, tool_choice: nil, tools: nil, betas: nil, request_options: {})
|
252
|
+
# @overload count_tokens(messages:, model:, context_management: nil, mcp_servers: nil, system_: nil, thinking: nil, tool_choice: nil, tools: nil, betas: nil, request_options: {})
|
249
253
|
#
|
250
254
|
# @param messages [Array<Anthropic::Models::Beta::BetaMessageParam>] Body param: Input messages.
|
251
255
|
#
|
252
256
|
# @param model [Symbol, String, Anthropic::Models::Model] Body param: The model that will complete your prompt.\n\nSee [models](https://do
|
253
257
|
#
|
258
|
+
# @param context_management [Anthropic::Models::Beta::BetaContextManagementConfig, nil] Body param: Configuration for context management operations.
|
259
|
+
#
|
254
260
|
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] Body param: MCP servers to be utilized in this request
|
255
261
|
#
|
256
262
|
# @param system_ [String, Array<Anthropic::Models::Beta::BetaTextBlockParam>] Body param: System prompt.
|
@@ -259,7 +265,7 @@ module Anthropic
|
|
259
265
|
#
|
260
266
|
# @param tool_choice [Anthropic::Models::Beta::BetaToolChoiceAuto, Anthropic::Models::Beta::BetaToolChoiceAny, Anthropic::Models::Beta::BetaToolChoiceTool, Anthropic::Models::Beta::BetaToolChoiceNone] Body param: How the model should use the provided tools. The model can use a spe
|
261
267
|
#
|
262
|
-
# @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305, Anthropic::Models::Beta::BetaWebFetchTool20250910>] Body param: Definitions of tools that the model may use.
|
268
|
+
# @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaMemoryTool20250818, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305, Anthropic::Models::Beta::BetaWebFetchTool20250910>] Body param: Definitions of tools that the model may use.
|
263
269
|
#
|
264
270
|
# @param betas [Array<String, Symbol, Anthropic::Models::AnthropicBeta>] Header param: Optional header to specify the beta version(s) you want to use.
|
265
271
|
#
|
data/lib/anthropic/version.rb
CHANGED
data/lib/anthropic.rb
CHANGED
@@ -90,6 +90,8 @@ require_relative "anthropic/models/beta/beta_citation_search_result_location"
|
|
90
90
|
require_relative "anthropic/models/beta/beta_citation_search_result_location_param"
|
91
91
|
require_relative "anthropic/models/beta/beta_citations_web_search_result_location"
|
92
92
|
require_relative "anthropic/models/beta/beta_citation_web_search_result_location_param"
|
93
|
+
require_relative "anthropic/models/beta/beta_clear_tool_uses_20250919_edit"
|
94
|
+
require_relative "anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response"
|
93
95
|
require_relative "anthropic/models/beta/beta_code_execution_output_block"
|
94
96
|
require_relative "anthropic/models/beta/beta_code_execution_output_block_param"
|
95
97
|
require_relative "anthropic/models/beta/beta_code_execution_result_block"
|
@@ -110,14 +112,27 @@ require_relative "anthropic/models/beta/beta_content_block"
|
|
110
112
|
require_relative "anthropic/models/beta/beta_content_block_param"
|
111
113
|
require_relative "anthropic/models/beta/beta_content_block_source"
|
112
114
|
require_relative "anthropic/models/beta/beta_content_block_source_content"
|
115
|
+
require_relative "anthropic/models/beta/beta_context_management_config"
|
116
|
+
require_relative "anthropic/models/beta/beta_context_management_response"
|
117
|
+
require_relative "anthropic/models/beta/beta_count_tokens_context_management_response"
|
113
118
|
require_relative "anthropic/models/beta/beta_document_block"
|
114
119
|
require_relative "anthropic/models/beta/beta_file_document_source"
|
115
120
|
require_relative "anthropic/models/beta/beta_file_image_source"
|
116
121
|
require_relative "anthropic/models/beta/beta_image_block_param"
|
117
122
|
require_relative "anthropic/models/beta/beta_input_json_delta"
|
123
|
+
require_relative "anthropic/models/beta/beta_input_tokens_clear_at_least"
|
124
|
+
require_relative "anthropic/models/beta/beta_input_tokens_trigger"
|
118
125
|
require_relative "anthropic/models/beta/beta_mcp_tool_result_block"
|
119
126
|
require_relative "anthropic/models/beta/beta_mcp_tool_use_block"
|
120
127
|
require_relative "anthropic/models/beta/beta_mcp_tool_use_block_param"
|
128
|
+
require_relative "anthropic/models/beta/beta_memory_tool_20250818"
|
129
|
+
require_relative "anthropic/models/beta/beta_memory_tool_20250818_command"
|
130
|
+
require_relative "anthropic/models/beta/beta_memory_tool_20250818_create_command"
|
131
|
+
require_relative "anthropic/models/beta/beta_memory_tool_20250818_delete_command"
|
132
|
+
require_relative "anthropic/models/beta/beta_memory_tool_20250818_insert_command"
|
133
|
+
require_relative "anthropic/models/beta/beta_memory_tool_20250818_rename_command"
|
134
|
+
require_relative "anthropic/models/beta/beta_memory_tool_20250818_str_replace_command"
|
135
|
+
require_relative "anthropic/models/beta/beta_memory_tool_20250818_view_command"
|
121
136
|
require_relative "anthropic/models/beta/beta_message"
|
122
137
|
require_relative "anthropic/models/beta/beta_message_delta_usage"
|
123
138
|
require_relative "anthropic/models/beta/beta_message_param"
|
@@ -183,6 +198,8 @@ require_relative "anthropic/models/beta/beta_tool_text_editor_20250728"
|
|
183
198
|
require_relative "anthropic/models/beta/beta_tool_union"
|
184
199
|
require_relative "anthropic/models/beta/beta_tool_use_block"
|
185
200
|
require_relative "anthropic/models/beta/beta_tool_use_block_param"
|
201
|
+
require_relative "anthropic/models/beta/beta_tool_uses_keep"
|
202
|
+
require_relative "anthropic/models/beta/beta_tool_uses_trigger"
|
186
203
|
require_relative "anthropic/models/beta/beta_url_image_source"
|
187
204
|
require_relative "anthropic/models/beta/beta_url_pdf_source"
|
188
205
|
require_relative "anthropic/models/beta/beta_usage"
|
data/rbi/anthropic/errors.rbi
CHANGED
@@ -33,6 +33,9 @@ module Anthropic
|
|
33
33
|
sig { returns(T.nilable(Integer)) }
|
34
34
|
attr_accessor :status
|
35
35
|
|
36
|
+
sig { returns(T.nilable(T::Hash[String, String])) }
|
37
|
+
attr_accessor :headers
|
38
|
+
|
36
39
|
sig { returns(T.nilable(T.anything)) }
|
37
40
|
attr_accessor :body
|
38
41
|
|
@@ -41,6 +44,7 @@ module Anthropic
|
|
41
44
|
params(
|
42
45
|
url: URI::Generic,
|
43
46
|
status: T.nilable(Integer),
|
47
|
+
headers: T.nilable(T::Hash[String, String]),
|
44
48
|
body: T.nilable(Object),
|
45
49
|
request: NilClass,
|
46
50
|
response: NilClass,
|
@@ -50,6 +54,7 @@ module Anthropic
|
|
50
54
|
def self.new(
|
51
55
|
url:,
|
52
56
|
status: nil,
|
57
|
+
headers: nil,
|
53
58
|
body: nil,
|
54
59
|
request: nil,
|
55
60
|
response: nil,
|
@@ -70,6 +75,7 @@ module Anthropic
|
|
70
75
|
params(
|
71
76
|
url: URI::Generic,
|
72
77
|
status: NilClass,
|
78
|
+
headers: T.nilable(T::Hash[String, String]),
|
73
79
|
body: NilClass,
|
74
80
|
request: NilClass,
|
75
81
|
response: NilClass,
|
@@ -79,6 +85,7 @@ module Anthropic
|
|
79
85
|
def self.new(
|
80
86
|
url:,
|
81
87
|
status: nil,
|
88
|
+
headers: nil,
|
82
89
|
body: nil,
|
83
90
|
request: nil,
|
84
91
|
response: nil,
|
@@ -93,6 +100,7 @@ module Anthropic
|
|
93
100
|
params(
|
94
101
|
url: URI::Generic,
|
95
102
|
status: NilClass,
|
103
|
+
headers: T.nilable(T::Hash[String, String]),
|
96
104
|
body: NilClass,
|
97
105
|
request: NilClass,
|
98
106
|
response: NilClass,
|
@@ -102,6 +110,7 @@ module Anthropic
|
|
102
110
|
def self.new(
|
103
111
|
url:,
|
104
112
|
status: nil,
|
113
|
+
headers: nil,
|
105
114
|
body: nil,
|
106
115
|
request: nil,
|
107
116
|
response: nil,
|
@@ -116,13 +125,22 @@ module Anthropic
|
|
116
125
|
params(
|
117
126
|
url: URI::Generic,
|
118
127
|
status: Integer,
|
128
|
+
headers: T.nilable(T::Hash[String, String]),
|
119
129
|
body: T.nilable(Object),
|
120
130
|
request: NilClass,
|
121
131
|
response: NilClass,
|
122
132
|
message: T.nilable(String)
|
123
133
|
).returns(T.attached_class)
|
124
134
|
end
|
125
|
-
def self.for(
|
135
|
+
def self.for(
|
136
|
+
url:,
|
137
|
+
status:,
|
138
|
+
headers:,
|
139
|
+
body:,
|
140
|
+
request:,
|
141
|
+
response:,
|
142
|
+
message: nil
|
143
|
+
)
|
126
144
|
end
|
127
145
|
|
128
146
|
sig { returns(Integer) }
|
@@ -133,13 +151,22 @@ module Anthropic
|
|
133
151
|
params(
|
134
152
|
url: URI::Generic,
|
135
153
|
status: Integer,
|
154
|
+
headers: T.nilable(T::Hash[String, String]),
|
136
155
|
body: T.nilable(Object),
|
137
156
|
request: NilClass,
|
138
157
|
response: NilClass,
|
139
158
|
message: T.nilable(String)
|
140
159
|
).returns(T.attached_class)
|
141
160
|
end
|
142
|
-
def self.new(
|
161
|
+
def self.new(
|
162
|
+
url:,
|
163
|
+
status:,
|
164
|
+
headers:,
|
165
|
+
body:,
|
166
|
+
request:,
|
167
|
+
response:,
|
168
|
+
message: nil
|
169
|
+
)
|
143
170
|
end
|
144
171
|
end
|
145
172
|
|
@@ -92,10 +92,9 @@ module Anthropic
|
|
92
92
|
|
93
93
|
# @api private
|
94
94
|
sig do
|
95
|
-
params(
|
96
|
-
|
97
|
-
|
98
|
-
).returns(T::Boolean)
|
95
|
+
params(status: Integer, headers: T::Hash[String, String]).returns(
|
96
|
+
T::Boolean
|
97
|
+
)
|
99
98
|
end
|
100
99
|
def should_retry?(status, headers:)
|
101
100
|
end
|
@@ -105,7 +104,7 @@ module Anthropic
|
|
105
104
|
params(
|
106
105
|
request: Anthropic::Internal::Transport::BaseClient::RequestInput,
|
107
106
|
status: Integer,
|
108
|
-
response_headers: T
|
107
|
+
response_headers: T::Hash[String, String]
|
109
108
|
).returns(Anthropic::Internal::Transport::BaseClient::RequestInput)
|
110
109
|
end
|
111
110
|
def follow_redirect(request, status:, response_headers:)
|
@@ -30,7 +30,7 @@ module Anthropic
|
|
30
30
|
params(
|
31
31
|
client: Anthropic::Internal::Transport::BaseClient,
|
32
32
|
req: Anthropic::Internal::Transport::BaseClient::RequestComponents,
|
33
|
-
headers: T
|
33
|
+
headers: T::Hash[String, String],
|
34
34
|
page_data: T.anything
|
35
35
|
).void
|
36
36
|
end
|
@@ -27,6 +27,12 @@ module Anthropic
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
sig { returns(Integer) }
|
31
|
+
attr_reader :status
|
32
|
+
|
33
|
+
sig { returns(T::Hash[String, String]) }
|
34
|
+
attr_reader :headers
|
35
|
+
|
30
36
|
sig { void }
|
31
37
|
def close
|
32
38
|
end
|
@@ -51,6 +57,7 @@ module Anthropic
|
|
51
57
|
T.any(T::Class[T.anything], Anthropic::Internal::Type::Converter),
|
52
58
|
url: URI::Generic,
|
53
59
|
status: Integer,
|
60
|
+
headers: T::Hash[String, String],
|
54
61
|
response: Net::HTTPResponse,
|
55
62
|
unwrap:
|
56
63
|
T.any(
|
@@ -62,7 +69,15 @@ module Anthropic
|
|
62
69
|
stream: T::Enumerable[Message]
|
63
70
|
).void
|
64
71
|
end
|
65
|
-
def initialize(
|
72
|
+
def initialize(
|
73
|
+
model:,
|
74
|
+
url:,
|
75
|
+
status:,
|
76
|
+
headers:,
|
77
|
+
response:,
|
78
|
+
unwrap:,
|
79
|
+
stream:
|
80
|
+
)
|
66
81
|
end
|
67
82
|
|
68
83
|
# @api private
|
@@ -361,7 +361,7 @@ module Anthropic
|
|
361
361
|
# Assumes each chunk in stream has `Encoding::BINARY`.
|
362
362
|
sig do
|
363
363
|
params(
|
364
|
-
headers: T
|
364
|
+
headers: T::Hash[String, String],
|
365
365
|
stream: T::Enumerable[String],
|
366
366
|
suppress_error: T::Boolean
|
367
367
|
).returns(T.anything)
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Models
|
5
|
+
BetaClearToolUses20250919Edit = Beta::BetaClearToolUses20250919Edit
|
6
|
+
|
7
|
+
module Beta
|
8
|
+
class BetaClearToolUses20250919Edit < Anthropic::Internal::Type::BaseModel
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(
|
12
|
+
Anthropic::Beta::BetaClearToolUses20250919Edit,
|
13
|
+
Anthropic::Internal::AnyHash
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { returns(Symbol) }
|
18
|
+
attr_accessor :type
|
19
|
+
|
20
|
+
# Minimum number of tokens that must be cleared when triggered. Context will only
|
21
|
+
# be modified if at least this many tokens can be removed.
|
22
|
+
sig { returns(T.nilable(Anthropic::Beta::BetaInputTokensClearAtLeast)) }
|
23
|
+
attr_reader :clear_at_least
|
24
|
+
|
25
|
+
sig do
|
26
|
+
params(
|
27
|
+
clear_at_least:
|
28
|
+
T.nilable(Anthropic::Beta::BetaInputTokensClearAtLeast::OrHash)
|
29
|
+
).void
|
30
|
+
end
|
31
|
+
attr_writer :clear_at_least
|
32
|
+
|
33
|
+
# Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
|
34
|
+
sig do
|
35
|
+
returns(
|
36
|
+
T.nilable(
|
37
|
+
Anthropic::Beta::BetaClearToolUses20250919Edit::ClearToolInputs::Variants
|
38
|
+
)
|
39
|
+
)
|
40
|
+
end
|
41
|
+
attr_accessor :clear_tool_inputs
|
42
|
+
|
43
|
+
# Tool names whose uses are preserved from clearing
|
44
|
+
sig { returns(T.nilable(T::Array[String])) }
|
45
|
+
attr_accessor :exclude_tools
|
46
|
+
|
47
|
+
# Number of tool uses to retain in the conversation
|
48
|
+
sig { returns(T.nilable(Anthropic::Beta::BetaToolUsesKeep)) }
|
49
|
+
attr_reader :keep
|
50
|
+
|
51
|
+
sig { params(keep: Anthropic::Beta::BetaToolUsesKeep::OrHash).void }
|
52
|
+
attr_writer :keep
|
53
|
+
|
54
|
+
# Condition that triggers the context management strategy
|
55
|
+
sig do
|
56
|
+
returns(
|
57
|
+
T.nilable(
|
58
|
+
T.any(
|
59
|
+
Anthropic::Beta::BetaInputTokensTrigger,
|
60
|
+
Anthropic::Beta::BetaToolUsesTrigger
|
61
|
+
)
|
62
|
+
)
|
63
|
+
)
|
64
|
+
end
|
65
|
+
attr_reader :trigger
|
66
|
+
|
67
|
+
sig do
|
68
|
+
params(
|
69
|
+
trigger:
|
70
|
+
T.any(
|
71
|
+
Anthropic::Beta::BetaInputTokensTrigger::OrHash,
|
72
|
+
Anthropic::Beta::BetaToolUsesTrigger::OrHash
|
73
|
+
)
|
74
|
+
).void
|
75
|
+
end
|
76
|
+
attr_writer :trigger
|
77
|
+
|
78
|
+
sig do
|
79
|
+
params(
|
80
|
+
clear_at_least:
|
81
|
+
T.nilable(Anthropic::Beta::BetaInputTokensClearAtLeast::OrHash),
|
82
|
+
clear_tool_inputs:
|
83
|
+
T.nilable(
|
84
|
+
Anthropic::Beta::BetaClearToolUses20250919Edit::ClearToolInputs::Variants
|
85
|
+
),
|
86
|
+
exclude_tools: T.nilable(T::Array[String]),
|
87
|
+
keep: Anthropic::Beta::BetaToolUsesKeep::OrHash,
|
88
|
+
trigger:
|
89
|
+
T.any(
|
90
|
+
Anthropic::Beta::BetaInputTokensTrigger::OrHash,
|
91
|
+
Anthropic::Beta::BetaToolUsesTrigger::OrHash
|
92
|
+
),
|
93
|
+
type: Symbol
|
94
|
+
).returns(T.attached_class)
|
95
|
+
end
|
96
|
+
def self.new(
|
97
|
+
# Minimum number of tokens that must be cleared when triggered. Context will only
|
98
|
+
# be modified if at least this many tokens can be removed.
|
99
|
+
clear_at_least: nil,
|
100
|
+
# Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
|
101
|
+
clear_tool_inputs: nil,
|
102
|
+
# Tool names whose uses are preserved from clearing
|
103
|
+
exclude_tools: nil,
|
104
|
+
# Number of tool uses to retain in the conversation
|
105
|
+
keep: nil,
|
106
|
+
# Condition that triggers the context management strategy
|
107
|
+
trigger: nil,
|
108
|
+
type: :clear_tool_uses_20250919
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
sig do
|
113
|
+
override.returns(
|
114
|
+
{
|
115
|
+
type: Symbol,
|
116
|
+
clear_at_least:
|
117
|
+
T.nilable(Anthropic::Beta::BetaInputTokensClearAtLeast),
|
118
|
+
clear_tool_inputs:
|
119
|
+
T.nilable(
|
120
|
+
Anthropic::Beta::BetaClearToolUses20250919Edit::ClearToolInputs::Variants
|
121
|
+
),
|
122
|
+
exclude_tools: T.nilable(T::Array[String]),
|
123
|
+
keep: Anthropic::Beta::BetaToolUsesKeep,
|
124
|
+
trigger:
|
125
|
+
T.any(
|
126
|
+
Anthropic::Beta::BetaInputTokensTrigger,
|
127
|
+
Anthropic::Beta::BetaToolUsesTrigger
|
128
|
+
)
|
129
|
+
}
|
130
|
+
)
|
131
|
+
end
|
132
|
+
def to_hash
|
133
|
+
end
|
134
|
+
|
135
|
+
# Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
|
136
|
+
module ClearToolInputs
|
137
|
+
extend Anthropic::Internal::Type::Union
|
138
|
+
|
139
|
+
Variants = T.type_alias { T.any(T::Boolean, T::Array[String]) }
|
140
|
+
|
141
|
+
sig do
|
142
|
+
override.returns(
|
143
|
+
T::Array[
|
144
|
+
Anthropic::Beta::BetaClearToolUses20250919Edit::ClearToolInputs::Variants
|
145
|
+
]
|
146
|
+
)
|
147
|
+
end
|
148
|
+
def self.variants
|
149
|
+
end
|
150
|
+
|
151
|
+
StringArray =
|
152
|
+
T.let(
|
153
|
+
Anthropic::Internal::Type::ArrayOf[String],
|
154
|
+
Anthropic::Internal::Type::Converter
|
155
|
+
)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Condition that triggers the context management strategy
|
159
|
+
module Trigger
|
160
|
+
extend Anthropic::Internal::Type::Union
|
161
|
+
|
162
|
+
Variants =
|
163
|
+
T.type_alias do
|
164
|
+
T.any(
|
165
|
+
Anthropic::Beta::BetaInputTokensTrigger,
|
166
|
+
Anthropic::Beta::BetaToolUsesTrigger
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
sig do
|
171
|
+
override.returns(
|
172
|
+
T::Array[
|
173
|
+
Anthropic::Beta::BetaClearToolUses20250919Edit::Trigger::Variants
|
174
|
+
]
|
175
|
+
)
|
176
|
+
end
|
177
|
+
def self.variants
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Models
|
5
|
+
BetaClearToolUses20250919EditResponse =
|
6
|
+
Beta::BetaClearToolUses20250919EditResponse
|
7
|
+
|
8
|
+
module Beta
|
9
|
+
class BetaClearToolUses20250919EditResponse < Anthropic::Internal::Type::BaseModel
|
10
|
+
OrHash =
|
11
|
+
T.type_alias do
|
12
|
+
T.any(
|
13
|
+
Anthropic::Beta::BetaClearToolUses20250919EditResponse,
|
14
|
+
Anthropic::Internal::AnyHash
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Number of input tokens cleared by this edit.
|
19
|
+
sig { returns(Integer) }
|
20
|
+
attr_accessor :cleared_input_tokens
|
21
|
+
|
22
|
+
# Number of tool uses that were cleared.
|
23
|
+
sig { returns(Integer) }
|
24
|
+
attr_accessor :cleared_tool_uses
|
25
|
+
|
26
|
+
# The type of context management edit applied.
|
27
|
+
sig { returns(Symbol) }
|
28
|
+
attr_accessor :type
|
29
|
+
|
30
|
+
# Results for clear_tool_uses_20250919 edit.
|
31
|
+
sig do
|
32
|
+
params(
|
33
|
+
cleared_input_tokens: Integer,
|
34
|
+
cleared_tool_uses: Integer,
|
35
|
+
type: Symbol
|
36
|
+
).returns(T.attached_class)
|
37
|
+
end
|
38
|
+
def self.new(
|
39
|
+
# Number of input tokens cleared by this edit.
|
40
|
+
cleared_input_tokens:,
|
41
|
+
# Number of tool uses that were cleared.
|
42
|
+
cleared_tool_uses:,
|
43
|
+
# The type of context management edit applied.
|
44
|
+
type: :clear_tool_uses_20250919
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
sig do
|
49
|
+
override.returns(
|
50
|
+
{
|
51
|
+
cleared_input_tokens: Integer,
|
52
|
+
cleared_tool_uses: Integer,
|
53
|
+
type: Symbol
|
54
|
+
}
|
55
|
+
)
|
56
|
+
end
|
57
|
+
def to_hash
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Models
|
5
|
+
BetaContextManagementConfig = Beta::BetaContextManagementConfig
|
6
|
+
|
7
|
+
module Beta
|
8
|
+
class BetaContextManagementConfig < Anthropic::Internal::Type::BaseModel
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(
|
12
|
+
Anthropic::Beta::BetaContextManagementConfig,
|
13
|
+
Anthropic::Internal::AnyHash
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
# List of context management edits to apply
|
18
|
+
sig do
|
19
|
+
returns(
|
20
|
+
T.nilable(T::Array[Anthropic::Beta::BetaClearToolUses20250919Edit])
|
21
|
+
)
|
22
|
+
end
|
23
|
+
attr_reader :edits
|
24
|
+
|
25
|
+
sig do
|
26
|
+
params(
|
27
|
+
edits:
|
28
|
+
T::Array[Anthropic::Beta::BetaClearToolUses20250919Edit::OrHash]
|
29
|
+
).void
|
30
|
+
end
|
31
|
+
attr_writer :edits
|
32
|
+
|
33
|
+
# Configuration for context management operations.
|
34
|
+
sig do
|
35
|
+
params(
|
36
|
+
edits:
|
37
|
+
T::Array[Anthropic::Beta::BetaClearToolUses20250919Edit::OrHash]
|
38
|
+
).returns(T.attached_class)
|
39
|
+
end
|
40
|
+
def self.new(
|
41
|
+
# List of context management edits to apply
|
42
|
+
edits: nil
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
sig do
|
47
|
+
override.returns(
|
48
|
+
{ edits: T::Array[Anthropic::Beta::BetaClearToolUses20250919Edit] }
|
49
|
+
)
|
50
|
+
end
|
51
|
+
def to_hash
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|