anthropic 1.12.0 → 1.14.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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +31 -1
  4. data/lib/anthropic/helpers/input_schema/base_model.rb +6 -3
  5. data/lib/anthropic/helpers/input_schema/json_schema_converter.rb +9 -3
  6. data/lib/anthropic/helpers/input_schema/supported_schemas.rb +106 -0
  7. data/lib/anthropic/helpers/input_schema/union_of.rb +3 -1
  8. data/lib/anthropic/helpers/messages.rb +107 -0
  9. data/lib/anthropic/helpers/streaming/message_stream.rb +57 -43
  10. data/lib/anthropic/helpers/tools/base_tool.rb +82 -0
  11. data/lib/anthropic/helpers/tools/runner.rb +156 -0
  12. data/lib/anthropic/helpers/tools.rb +5 -0
  13. data/lib/anthropic/internal/transport/base_client.rb +7 -1
  14. data/lib/anthropic/internal/transport/pooled_net_requester.rb +36 -26
  15. data/lib/anthropic/models/beta/beta_all_thinking_turns.rb +19 -0
  16. data/lib/anthropic/models/beta/beta_clear_thinking_20251015_edit.rb +48 -0
  17. data/lib/anthropic/models/beta/beta_clear_thinking_20251015_edit_response.rb +36 -0
  18. data/lib/anthropic/models/beta/beta_context_management_config.rb +17 -3
  19. data/lib/anthropic/models/beta/beta_context_management_response.rb +16 -3
  20. data/lib/anthropic/models/beta/beta_mcp_tool_use_block_param.rb +3 -3
  21. data/lib/anthropic/models/beta/beta_server_tool_use_block_param.rb +3 -3
  22. data/lib/anthropic/models/beta/beta_thinking_turns.rb +25 -0
  23. data/lib/anthropic/models/beta/beta_tool.rb +5 -3
  24. data/lib/anthropic/models/beta/beta_tool_use_block.rb +14 -0
  25. data/lib/anthropic/models/beta/beta_tool_use_block_param.rb +3 -3
  26. data/lib/anthropic/models/model.rb +6 -20
  27. data/lib/anthropic/models/server_tool_use_block_param.rb +3 -3
  28. data/lib/anthropic/models/tool.rb +5 -3
  29. data/lib/anthropic/models/tool_use_block.rb +6 -6
  30. data/lib/anthropic/models/tool_use_block_param.rb +3 -3
  31. data/lib/anthropic/resources/beta/messages.rb +23 -5
  32. data/lib/anthropic/resources/messages.rb +7 -81
  33. data/lib/anthropic/version.rb +1 -1
  34. data/lib/anthropic.rb +19 -10
  35. data/manifest.yaml +1 -0
  36. data/rbi/anthropic/helpers/input_schema/base_model.rbi +7 -2
  37. data/rbi/anthropic/helpers/tools/base_tool.rbi +51 -0
  38. data/rbi/anthropic/helpers/tools/runner.rbi +40 -0
  39. data/rbi/anthropic/helpers/tools.rbi +5 -0
  40. data/rbi/anthropic/internal/transport/base_client.rbi +5 -0
  41. data/rbi/anthropic/internal/transport/pooled_net_requester.rbi +6 -2
  42. data/rbi/anthropic/internal/type/base_model.rbi +8 -4
  43. data/rbi/anthropic/models/beta/beta_all_thinking_turns.rbi +30 -0
  44. data/rbi/anthropic/models/beta/beta_clear_thinking_20251015_edit.rbi +109 -0
  45. data/rbi/anthropic/models/beta/beta_clear_thinking_20251015_edit_response.rbi +61 -0
  46. data/rbi/anthropic/models/beta/beta_context_management_config.rbi +51 -4
  47. data/rbi/anthropic/models/beta/beta_context_management_response.rbi +32 -3
  48. data/rbi/anthropic/models/beta/beta_mcp_tool_use_block.rbi +3 -3
  49. data/rbi/anthropic/models/beta/beta_mcp_tool_use_block_param.rbi +3 -3
  50. data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +3 -3
  51. data/rbi/anthropic/models/beta/beta_server_tool_use_block_param.rbi +3 -3
  52. data/rbi/anthropic/models/beta/beta_thinking_turns.rbi +33 -0
  53. data/rbi/anthropic/models/beta/beta_tool.rbi +3 -3
  54. data/rbi/anthropic/models/beta/beta_tool_use_block.rbi +8 -3
  55. data/rbi/anthropic/models/beta/beta_tool_use_block_param.rbi +3 -3
  56. data/rbi/anthropic/models/model.rbi +0 -11
  57. data/rbi/anthropic/models/server_tool_use_block.rbi +8 -3
  58. data/rbi/anthropic/models/server_tool_use_block_param.rbi +3 -3
  59. data/rbi/anthropic/models/tool.rbi +3 -3
  60. data/rbi/anthropic/models/tool_use_block.rbi +11 -3
  61. data/rbi/anthropic/models/tool_use_block_param.rbi +3 -3
  62. data/rbi/anthropic/resources/beta/messages.rbi +296 -0
  63. data/sig/anthropic/internal/transport/base_client.rbs +2 -0
  64. data/sig/anthropic/internal/transport/pooled_net_requester.rbs +4 -1
  65. data/sig/anthropic/models/beta/beta_all_thinking_turns.rbs +17 -0
  66. data/sig/anthropic/models/beta/beta_clear_thinking_20251015_edit.rbs +44 -0
  67. data/sig/anthropic/models/beta/beta_clear_thinking_20251015_edit_response.rbs +34 -0
  68. data/sig/anthropic/models/beta/beta_context_management_config.rbs +18 -6
  69. data/sig/anthropic/models/beta/beta_context_management_response.rbs +14 -4
  70. data/sig/anthropic/models/beta/beta_mcp_tool_use_block.rbs +4 -4
  71. data/sig/anthropic/models/beta/beta_mcp_tool_use_block_param.rbs +4 -4
  72. data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +4 -4
  73. data/sig/anthropic/models/beta/beta_server_tool_use_block_param.rbs +4 -4
  74. data/sig/anthropic/models/beta/beta_thinking_turns.rbs +19 -0
  75. data/sig/anthropic/models/beta/beta_tool.rbs +8 -4
  76. data/sig/anthropic/models/beta/beta_tool_use_block.rbs +9 -4
  77. data/sig/anthropic/models/beta/beta_tool_use_block_param.rbs +4 -4
  78. data/sig/anthropic/models/model.rbs +0 -11
  79. data/sig/anthropic/models/server_tool_use_block.rbs +9 -4
  80. data/sig/anthropic/models/server_tool_use_block_param.rbs +4 -4
  81. data/sig/anthropic/models/tool.rbs +8 -4
  82. data/sig/anthropic/models/tool_use_block.rbs +9 -4
  83. data/sig/anthropic/models/tool_use_block_param.rbs +4 -4
  84. metadata +23 -4
  85. data/lib/anthropic/helpers/input_schema/property_mapping.rb +0 -47
  86. /data/rbi/anthropic/helpers/{structured_output.rbi → input_schema.rbi} +0 -0
@@ -11,7 +11,7 @@ module Anthropic
11
11
  sig { returns(String) }
12
12
  attr_accessor :id
13
13
 
14
- sig { returns(T.anything) }
14
+ sig { returns(T::Hash[Symbol, T.anything]) }
15
15
  attr_accessor :input
16
16
 
17
17
  sig { returns(String) }
@@ -34,7 +34,7 @@ module Anthropic
34
34
  sig do
35
35
  params(
36
36
  id: String,
37
- input: T.anything,
37
+ input: T::Hash[Symbol, T.anything],
38
38
  name: String,
39
39
  cache_control: T.nilable(Anthropic::CacheControlEphemeral::OrHash),
40
40
  type: Symbol
@@ -54,7 +54,7 @@ module Anthropic
54
54
  override.returns(
55
55
  {
56
56
  id: String,
57
- input: T.anything,
57
+ input: T::Hash[Symbol, T.anything],
58
58
  name: String,
59
59
  type: Symbol,
60
60
  cache_control: T.nilable(Anthropic::CacheControlEphemeral)
@@ -7,6 +7,302 @@ module Anthropic
7
7
  sig { returns(Anthropic::Resources::Beta::Messages::Batches) }
8
8
  attr_reader :batches
9
9
 
10
+ sig do
11
+ params(
12
+ max_tokens: Integer,
13
+ messages: T::Array[Anthropic::Beta::BetaMessageParam::OrHash],
14
+ model: T.any(Anthropic::Model::OrSymbol, String),
15
+ container:
16
+ T.nilable(
17
+ T.any(Anthropic::Beta::BetaContainerParams::OrHash, String)
18
+ ),
19
+ context_management:
20
+ T.nilable(Anthropic::Beta::BetaContextManagementConfig::OrHash),
21
+ mcp_servers:
22
+ T::Array[
23
+ Anthropic::Beta::BetaRequestMCPServerURLDefinition::OrHash
24
+ ],
25
+ metadata: Anthropic::Beta::BetaMetadata::OrHash,
26
+ service_tier:
27
+ Anthropic::Beta::MessageCreateParams::ServiceTier::OrSymbol,
28
+ stop_sequences: T::Array[String],
29
+ system_: Anthropic::Beta::MessageCreateParams::System::Variants,
30
+ temperature: Float,
31
+ thinking:
32
+ T.any(
33
+ Anthropic::Beta::BetaThinkingConfigEnabled::OrHash,
34
+ Anthropic::Beta::BetaThinkingConfigDisabled::OrHash
35
+ ),
36
+ tool_choice:
37
+ T.any(
38
+ Anthropic::Beta::BetaToolChoiceAuto::OrHash,
39
+ Anthropic::Beta::BetaToolChoiceAny::OrHash,
40
+ Anthropic::Beta::BetaToolChoiceTool::OrHash,
41
+ Anthropic::Beta::BetaToolChoiceNone::OrHash
42
+ ),
43
+ tools:
44
+ T::Array[
45
+ T.any(
46
+ Anthropic::Beta::BetaTool::OrHash,
47
+ Anthropic::Beta::BetaToolBash20241022::OrHash,
48
+ Anthropic::Beta::BetaToolBash20250124::OrHash,
49
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
50
+ Anthropic::Beta::BetaCodeExecutionTool20250825::OrHash,
51
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
52
+ Anthropic::Beta::BetaMemoryTool20250818::OrHash,
53
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
54
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
55
+ Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
56
+ Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
57
+ Anthropic::Beta::BetaToolTextEditor20250728::OrHash,
58
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
59
+ Anthropic::Beta::BetaWebFetchTool20250910::OrHash
60
+ )
61
+ ],
62
+ top_k: Integer,
63
+ top_p: Float,
64
+ betas: T::Array[T.any(String, Anthropic::AnthropicBeta::OrSymbol)],
65
+ stream: T.noreturn,
66
+ request_options: Anthropic::RequestOptions::OrHash
67
+ ).returns(Anthropic::Helpers::Tools::Runner)
68
+ end
69
+ def tool_runner(
70
+ # Body param: The maximum number of tokens to generate before stopping.
71
+ #
72
+ # Note that our models may stop _before_ reaching this maximum. This parameter
73
+ # only specifies the absolute maximum number of tokens to generate.
74
+ #
75
+ # Different models have different maximum values for this parameter. See
76
+ # [models](https://docs.claude.com/en/docs/models-overview) for details.
77
+ max_tokens:,
78
+ # Body param: Input messages.
79
+ #
80
+ # Our models are trained to operate on alternating `user` and `assistant`
81
+ # conversational turns. When creating a new `Message`, you specify the prior
82
+ # conversational turns with the `messages` parameter, and the model then generates
83
+ # the next `Message` in the conversation. Consecutive `user` or `assistant` turns
84
+ # in your request will be combined into a single turn.
85
+ #
86
+ # Each input message must be an object with a `role` and `content`. You can
87
+ # specify a single `user`-role message, or you can include multiple `user` and
88
+ # `assistant` messages.
89
+ #
90
+ # If the final message uses the `assistant` role, the response content will
91
+ # continue immediately from the content in that message. This can be used to
92
+ # constrain part of the model's response.
93
+ #
94
+ # Example with a single `user` message:
95
+ #
96
+ # ```json
97
+ # [{ "role": "user", "content": "Hello, Claude" }]
98
+ # ```
99
+ #
100
+ # Example with multiple conversational turns:
101
+ #
102
+ # ```json
103
+ # [
104
+ # { "role": "user", "content": "Hello there." },
105
+ # { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
106
+ # { "role": "user", "content": "Can you explain LLMs in plain English?" }
107
+ # ]
108
+ # ```
109
+ #
110
+ # Example with a partially-filled response from Claude:
111
+ #
112
+ # ```json
113
+ # [
114
+ # {
115
+ # "role": "user",
116
+ # "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
117
+ # },
118
+ # { "role": "assistant", "content": "The best answer is (" }
119
+ # ]
120
+ # ```
121
+ #
122
+ # Each input message `content` may be either a single `string` or an array of
123
+ # content blocks, where each block has a specific `type`. Using a `string` for
124
+ # `content` is shorthand for an array of one content block of type `"text"`. The
125
+ # following input messages are equivalent:
126
+ #
127
+ # ```json
128
+ # { "role": "user", "content": "Hello, Claude" }
129
+ # ```
130
+ #
131
+ # ```json
132
+ # { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
133
+ # ```
134
+ #
135
+ # See [input examples](https://docs.claude.com/en/api/messages-examples).
136
+ #
137
+ # Note that if you want to include a
138
+ # [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the
139
+ # top-level `system` parameter — there is no `"system"` role for input messages in
140
+ # the Messages API.
141
+ #
142
+ # There is a limit of 100,000 messages in a single request.
143
+ messages:,
144
+ # Body param: The model that will complete your prompt.\n\nSee
145
+ # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
146
+ # details and options.
147
+ model:,
148
+ # Body param: Container identifier for reuse across requests.
149
+ container: nil,
150
+ # Body param: Context management configuration.
151
+ #
152
+ # This allows you to control how Claude manages context across multiple requests,
153
+ # such as whether to clear function results or not.
154
+ context_management: nil,
155
+ # Body param: MCP servers to be utilized in this request
156
+ mcp_servers: nil,
157
+ # Body param: An object describing metadata about the request.
158
+ metadata: nil,
159
+ # Body param: Determines whether to use priority capacity (if available) or
160
+ # standard capacity for this request.
161
+ #
162
+ # Anthropic offers different levels of service for your API requests. See
163
+ # [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
164
+ service_tier: nil,
165
+ # Body param: Custom text sequences that will cause the model to stop generating.
166
+ #
167
+ # Our models will normally stop when they have naturally completed their turn,
168
+ # which will result in a response `stop_reason` of `"end_turn"`.
169
+ #
170
+ # If you want the model to stop generating when it encounters custom strings of
171
+ # text, you can use the `stop_sequences` parameter. If the model encounters one of
172
+ # the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
173
+ # and the response `stop_sequence` value will contain the matched stop sequence.
174
+ stop_sequences: nil,
175
+ # Body param: System prompt.
176
+ #
177
+ # A system prompt is a way of providing context and instructions to Claude, such
178
+ # as specifying a particular goal or role. See our
179
+ # [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).
180
+ system_: nil,
181
+ # Body param: Amount of randomness injected into the response.
182
+ #
183
+ # Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
184
+ # for analytical / multiple choice, and closer to `1.0` for creative and
185
+ # generative tasks.
186
+ #
187
+ # Note that even with `temperature` of `0.0`, the results will not be fully
188
+ # deterministic.
189
+ temperature: nil,
190
+ # Body param: Configuration for enabling Claude's extended thinking.
191
+ #
192
+ # When enabled, responses include `thinking` content blocks showing Claude's
193
+ # thinking process before the final answer. Requires a minimum budget of 1,024
194
+ # tokens and counts towards your `max_tokens` limit.
195
+ #
196
+ # See
197
+ # [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
198
+ # for details.
199
+ thinking: nil,
200
+ # Body param: How the model should use the provided tools. The model can use a
201
+ # specific tool, any available tool, decide by itself, or not use tools at all.
202
+ tool_choice: nil,
203
+ # Body param: Definitions of tools that the model may use.
204
+ #
205
+ # If you include `tools` in your API request, the model may return `tool_use`
206
+ # content blocks that represent the model's use of those tools. You can then run
207
+ # those tools using the tool input generated by the model and then optionally
208
+ # return results back to the model using `tool_result` content blocks.
209
+ #
210
+ # There are two types of tools: **client tools** and **server tools**. The
211
+ # behavior described below applies to client tools. For
212
+ # [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
213
+ # see their individual documentation as each has its own behavior (e.g., the
214
+ # [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
215
+ #
216
+ # Each tool definition includes:
217
+ #
218
+ # - `name`: Name of the tool.
219
+ # - `description`: Optional, but strongly-recommended description of the tool.
220
+ # - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
221
+ # tool `input` shape that the model will produce in `tool_use` output content
222
+ # blocks.
223
+ #
224
+ # For example, if you defined `tools` as:
225
+ #
226
+ # ```json
227
+ # [
228
+ # {
229
+ # "name": "get_stock_price",
230
+ # "description": "Get the current stock price for a given ticker symbol.",
231
+ # "input_schema": {
232
+ # "type": "object",
233
+ # "properties": {
234
+ # "ticker": {
235
+ # "type": "string",
236
+ # "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
237
+ # }
238
+ # },
239
+ # "required": ["ticker"]
240
+ # }
241
+ # }
242
+ # ]
243
+ # ```
244
+ #
245
+ # And then asked the model "What's the S&P 500 at today?", the model might produce
246
+ # `tool_use` content blocks in the response like this:
247
+ #
248
+ # ```json
249
+ # [
250
+ # {
251
+ # "type": "tool_use",
252
+ # "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
253
+ # "name": "get_stock_price",
254
+ # "input": { "ticker": "^GSPC" }
255
+ # }
256
+ # ]
257
+ # ```
258
+ #
259
+ # You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
260
+ # input, and return the following back to the model in a subsequent `user`
261
+ # message:
262
+ #
263
+ # ```json
264
+ # [
265
+ # {
266
+ # "type": "tool_result",
267
+ # "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
268
+ # "content": "259.75 USD"
269
+ # }
270
+ # ]
271
+ # ```
272
+ #
273
+ # Tools can be used for workflows that include running client-side tools and
274
+ # functions, or more generally whenever you want the model to produce a particular
275
+ # JSON structure of output.
276
+ #
277
+ # See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.
278
+ tools: nil,
279
+ # Body param: Only sample from the top K options for each subsequent token.
280
+ #
281
+ # Used to remove "long tail" low probability responses.
282
+ # [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
283
+ #
284
+ # Recommended for advanced use cases only. You usually only need to use
285
+ # `temperature`.
286
+ top_k: nil,
287
+ # Body param: Use nucleus sampling.
288
+ #
289
+ # In nucleus sampling, we compute the cumulative distribution over all the options
290
+ # for each subsequent token in decreasing probability order and cut it off once it
291
+ # reaches a particular probability specified by `top_p`. You should either alter
292
+ # `temperature` or `top_p`, but not both.
293
+ #
294
+ # Recommended for advanced use cases only. You usually only need to use
295
+ # `temperature`.
296
+ top_p: nil,
297
+ # Header param: Optional header to specify the beta version(s) you want to use.
298
+ betas: nil,
299
+ # There is no need to provide `stream:`. Instead, use `#stream_raw` or `#create`
300
+ # for streaming and non-streaming use cases, respectively.
301
+ stream: false,
302
+ request_options: {}
303
+ )
304
+ end
305
+
10
306
  # See {Anthropic::Resources::Beta::Messages#stream_raw} for streaming counterpart.
11
307
  #
12
308
  # Send a structured list of input messages with text and/or image content, and the
@@ -87,6 +87,8 @@ module Anthropic
87
87
 
88
88
  private def auth_headers: -> ::Hash[String, String]
89
89
 
90
+ private def user_agent: -> String
91
+
90
92
  private def generate_idempotency_key: -> String
91
93
 
92
94
  private def build_request: (
@@ -17,7 +17,10 @@ module Anthropic
17
17
 
18
18
  DEFAULT_MAX_CONNECTIONS: Integer
19
19
 
20
- def self.connect: (URI::Generic url) -> top
20
+ def self.connect: (
21
+ cert_store: OpenSSL::X509::Store,
22
+ url: URI::Generic
23
+ ) -> top
21
24
 
22
25
  def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
23
26
 
@@ -0,0 +1,17 @@
1
+ module Anthropic
2
+ module Models
3
+ class BetaAllThinkingTurns = Beta::BetaAllThinkingTurns
4
+
5
+ module Beta
6
+ type beta_all_thinking_turns = { type: :all }
7
+
8
+ class BetaAllThinkingTurns < Anthropic::Internal::Type::BaseModel
9
+ attr_accessor type: :all
10
+
11
+ def initialize: (?type: :all) -> void
12
+
13
+ def to_hash: -> { type: :all }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,44 @@
1
+ module Anthropic
2
+ module Models
3
+ class BetaClearThinking20251015Edit = Beta::BetaClearThinking20251015Edit
4
+
5
+ module Beta
6
+ type beta_clear_thinking20251015_edit =
7
+ {
8
+ type: :clear_thinking_20251015,
9
+ keep: Anthropic::Models::Beta::BetaClearThinking20251015Edit::keep
10
+ }
11
+
12
+ class BetaClearThinking20251015Edit < Anthropic::Internal::Type::BaseModel
13
+ attr_accessor type: :clear_thinking_20251015
14
+
15
+ attr_reader keep: Anthropic::Models::Beta::BetaClearThinking20251015Edit::keep?
16
+
17
+ def keep=: (
18
+ Anthropic::Models::Beta::BetaClearThinking20251015Edit::keep
19
+ ) -> Anthropic::Models::Beta::BetaClearThinking20251015Edit::keep
20
+
21
+ def initialize: (
22
+ ?keep: Anthropic::Models::Beta::BetaClearThinking20251015Edit::keep,
23
+ ?type: :clear_thinking_20251015
24
+ ) -> void
25
+
26
+ def to_hash: -> {
27
+ type: :clear_thinking_20251015,
28
+ keep: Anthropic::Models::Beta::BetaClearThinking20251015Edit::keep
29
+ }
30
+
31
+ type keep =
32
+ Anthropic::Beta::BetaThinkingTurns
33
+ | Anthropic::Beta::BetaAllThinkingTurns
34
+ | :all
35
+
36
+ module Keep
37
+ extend Anthropic::Internal::Type::Union
38
+
39
+ def self?.variants: -> ::Array[Anthropic::Models::Beta::BetaClearThinking20251015Edit::keep]
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,34 @@
1
+ module Anthropic
2
+ module Models
3
+ class BetaClearThinking20251015EditResponse = Beta::BetaClearThinking20251015EditResponse
4
+
5
+ module Beta
6
+ type beta_clear_thinking20251015_edit_response =
7
+ {
8
+ cleared_input_tokens: Integer,
9
+ cleared_thinking_turns: Integer,
10
+ type: :clear_thinking_20251015
11
+ }
12
+
13
+ class BetaClearThinking20251015EditResponse < Anthropic::Internal::Type::BaseModel
14
+ attr_accessor cleared_input_tokens: Integer
15
+
16
+ attr_accessor cleared_thinking_turns: Integer
17
+
18
+ attr_accessor type: :clear_thinking_20251015
19
+
20
+ def initialize: (
21
+ cleared_input_tokens: Integer,
22
+ cleared_thinking_turns: Integer,
23
+ ?type: :clear_thinking_20251015
24
+ ) -> void
25
+
26
+ def to_hash: -> {
27
+ cleared_input_tokens: Integer,
28
+ cleared_thinking_turns: Integer,
29
+ type: :clear_thinking_20251015
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -4,22 +4,34 @@ module Anthropic
4
4
 
5
5
  module Beta
6
6
  type beta_context_management_config =
7
- { edits: ::Array[Anthropic::Beta::BetaClearToolUses20250919Edit] }
7
+ {
8
+ edits: ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]
9
+ }
8
10
 
9
11
  class BetaContextManagementConfig < Anthropic::Internal::Type::BaseModel
10
- attr_reader edits: ::Array[Anthropic::Beta::BetaClearToolUses20250919Edit]?
12
+ attr_reader edits: ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]?
11
13
 
12
14
  def edits=: (
13
- ::Array[Anthropic::Beta::BetaClearToolUses20250919Edit]
14
- ) -> ::Array[Anthropic::Beta::BetaClearToolUses20250919Edit]
15
+ ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]
16
+ ) -> ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]
15
17
 
16
18
  def initialize: (
17
- ?edits: ::Array[Anthropic::Beta::BetaClearToolUses20250919Edit]
19
+ ?edits: ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]
18
20
  ) -> void
19
21
 
20
22
  def to_hash: -> {
21
- edits: ::Array[Anthropic::Beta::BetaClearToolUses20250919Edit]
23
+ edits: ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]
22
24
  }
25
+
26
+ type edit =
27
+ Anthropic::Beta::BetaClearToolUses20250919Edit
28
+ | Anthropic::Beta::BetaClearThinking20251015Edit
29
+
30
+ module Edit
31
+ extend Anthropic::Internal::Type::Union
32
+
33
+ def self?.variants: -> ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]
34
+ end
23
35
  end
24
36
  end
25
37
  end
@@ -5,19 +5,29 @@ module Anthropic
5
5
  module Beta
6
6
  type beta_context_management_response =
7
7
  {
8
- applied_edits: ::Array[Anthropic::Beta::BetaClearToolUses20250919EditResponse]
8
+ applied_edits: ::Array[Anthropic::Models::Beta::BetaContextManagementResponse::applied_edit]
9
9
  }
10
10
 
11
11
  class BetaContextManagementResponse < Anthropic::Internal::Type::BaseModel
12
- attr_accessor applied_edits: ::Array[Anthropic::Beta::BetaClearToolUses20250919EditResponse]
12
+ attr_accessor applied_edits: ::Array[Anthropic::Models::Beta::BetaContextManagementResponse::applied_edit]
13
13
 
14
14
  def initialize: (
15
- applied_edits: ::Array[Anthropic::Beta::BetaClearToolUses20250919EditResponse]
15
+ applied_edits: ::Array[Anthropic::Models::Beta::BetaContextManagementResponse::applied_edit]
16
16
  ) -> void
17
17
 
18
18
  def to_hash: -> {
19
- applied_edits: ::Array[Anthropic::Beta::BetaClearToolUses20250919EditResponse]
19
+ applied_edits: ::Array[Anthropic::Models::Beta::BetaContextManagementResponse::applied_edit]
20
20
  }
21
+
22
+ type applied_edit =
23
+ Anthropic::Beta::BetaClearToolUses20250919EditResponse
24
+ | Anthropic::Beta::BetaClearThinking20251015EditResponse
25
+
26
+ module AppliedEdit
27
+ extend Anthropic::Internal::Type::Union
28
+
29
+ def self?.variants: -> ::Array[Anthropic::Models::Beta::BetaContextManagementResponse::applied_edit]
30
+ end
21
31
  end
22
32
  end
23
33
  end
@@ -6,7 +6,7 @@ module Anthropic
6
6
  type beta_mcp_tool_use_block =
7
7
  {
8
8
  id: String,
9
- input: top,
9
+ input: ::Hash[Symbol, top],
10
10
  name: String,
11
11
  server_name: String,
12
12
  type: :mcp_tool_use
@@ -15,7 +15,7 @@ module Anthropic
15
15
  class BetaMCPToolUseBlock < Anthropic::Internal::Type::BaseModel
16
16
  attr_accessor id: String
17
17
 
18
- attr_accessor input: top
18
+ attr_accessor input: ::Hash[Symbol, top]
19
19
 
20
20
  attr_accessor name: String
21
21
 
@@ -25,7 +25,7 @@ module Anthropic
25
25
 
26
26
  def initialize: (
27
27
  id: String,
28
- input: top,
28
+ input: ::Hash[Symbol, top],
29
29
  name: String,
30
30
  server_name: String,
31
31
  ?type: :mcp_tool_use
@@ -33,7 +33,7 @@ module Anthropic
33
33
 
34
34
  def to_hash: -> {
35
35
  id: String,
36
- input: top,
36
+ input: ::Hash[Symbol, top],
37
37
  name: String,
38
38
  server_name: String,
39
39
  type: :mcp_tool_use
@@ -6,7 +6,7 @@ module Anthropic
6
6
  type beta_mcp_tool_use_block_param =
7
7
  {
8
8
  id: String,
9
- input: top,
9
+ input: ::Hash[Symbol, top],
10
10
  name: String,
11
11
  server_name: String,
12
12
  type: :mcp_tool_use,
@@ -16,7 +16,7 @@ module Anthropic
16
16
  class BetaMCPToolUseBlockParam < Anthropic::Internal::Type::BaseModel
17
17
  attr_accessor id: String
18
18
 
19
- attr_accessor input: top
19
+ attr_accessor input: ::Hash[Symbol, top]
20
20
 
21
21
  attr_accessor name: String
22
22
 
@@ -28,7 +28,7 @@ module Anthropic
28
28
 
29
29
  def initialize: (
30
30
  id: String,
31
- input: top,
31
+ input: ::Hash[Symbol, top],
32
32
  name: String,
33
33
  server_name: String,
34
34
  ?cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
@@ -37,7 +37,7 @@ module Anthropic
37
37
 
38
38
  def to_hash: -> {
39
39
  id: String,
40
- input: top,
40
+ input: ::Hash[Symbol, top],
41
41
  name: String,
42
42
  server_name: String,
43
43
  type: :mcp_tool_use,
@@ -6,7 +6,7 @@ module Anthropic
6
6
  type beta_server_tool_use_block =
7
7
  {
8
8
  id: String,
9
- input: top,
9
+ input: ::Hash[Symbol, top],
10
10
  name: Anthropic::Models::Beta::BetaServerToolUseBlock::name_,
11
11
  type: :server_tool_use
12
12
  }
@@ -14,7 +14,7 @@ module Anthropic
14
14
  class BetaServerToolUseBlock < Anthropic::Internal::Type::BaseModel
15
15
  attr_accessor id: String
16
16
 
17
- attr_accessor input: top
17
+ attr_accessor input: ::Hash[Symbol, top]
18
18
 
19
19
  attr_accessor name: Anthropic::Models::Beta::BetaServerToolUseBlock::name_
20
20
 
@@ -22,14 +22,14 @@ module Anthropic
22
22
 
23
23
  def initialize: (
24
24
  id: String,
25
- input: top,
25
+ input: ::Hash[Symbol, top],
26
26
  name: Anthropic::Models::Beta::BetaServerToolUseBlock::name_,
27
27
  ?type: :server_tool_use
28
28
  ) -> void
29
29
 
30
30
  def to_hash: -> {
31
31
  id: String,
32
- input: top,
32
+ input: ::Hash[Symbol, top],
33
33
  name: Anthropic::Models::Beta::BetaServerToolUseBlock::name_,
34
34
  type: :server_tool_use
35
35
  }
@@ -6,7 +6,7 @@ module Anthropic
6
6
  type beta_server_tool_use_block_param =
7
7
  {
8
8
  id: String,
9
- input: top,
9
+ input: ::Hash[Symbol, top],
10
10
  name: Anthropic::Models::Beta::BetaServerToolUseBlockParam::name_,
11
11
  type: :server_tool_use,
12
12
  cache_control: Anthropic::Beta::BetaCacheControlEphemeral?
@@ -15,7 +15,7 @@ module Anthropic
15
15
  class BetaServerToolUseBlockParam < Anthropic::Internal::Type::BaseModel
16
16
  attr_accessor id: String
17
17
 
18
- attr_accessor input: top
18
+ attr_accessor input: ::Hash[Symbol, top]
19
19
 
20
20
  attr_accessor name: Anthropic::Models::Beta::BetaServerToolUseBlockParam::name_
21
21
 
@@ -25,7 +25,7 @@ module Anthropic
25
25
 
26
26
  def initialize: (
27
27
  id: String,
28
- input: top,
28
+ input: ::Hash[Symbol, top],
29
29
  name: Anthropic::Models::Beta::BetaServerToolUseBlockParam::name_,
30
30
  ?cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
31
31
  ?type: :server_tool_use
@@ -33,7 +33,7 @@ module Anthropic
33
33
 
34
34
  def to_hash: -> {
35
35
  id: String,
36
- input: top,
36
+ input: ::Hash[Symbol, top],
37
37
  name: Anthropic::Models::Beta::BetaServerToolUseBlockParam::name_,
38
38
  type: :server_tool_use,
39
39
  cache_control: Anthropic::Beta::BetaCacheControlEphemeral?