anthropic 1.11.0 → 1.13.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 (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +1 -1
  4. data/lib/anthropic/helpers/streaming/message_stream.rb +3 -0
  5. data/lib/anthropic/internal/page_cursor.rb +92 -0
  6. data/lib/anthropic/internal/token_page.rb +92 -0
  7. data/lib/anthropic/internal/transport/pooled_net_requester.rb +30 -24
  8. data/lib/anthropic/models/anthropic_beta.rb +3 -0
  9. data/lib/anthropic/models/beta/beta_all_thinking_turns.rb +19 -0
  10. data/lib/anthropic/models/beta/beta_clear_thinking_20251015_edit.rb +48 -0
  11. data/lib/anthropic/models/beta/beta_clear_thinking_20251015_edit_response.rb +36 -0
  12. data/lib/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rb +0 -2
  13. data/lib/anthropic/models/beta/beta_container.rb +9 -1
  14. data/lib/anthropic/models/beta/beta_container_params.rb +34 -0
  15. data/lib/anthropic/models/beta/beta_context_management_config.rb +17 -5
  16. data/lib/anthropic/models/beta/beta_context_management_response.rb +16 -5
  17. data/lib/anthropic/models/beta/beta_mcp_tool_use_block_param.rb +3 -3
  18. data/lib/anthropic/models/beta/beta_message.rb +4 -2
  19. data/lib/anthropic/models/beta/beta_raw_message_delta_event.rb +2 -2
  20. data/lib/anthropic/models/beta/beta_server_tool_use_block_param.rb +3 -3
  21. data/lib/anthropic/models/beta/beta_skill.rb +51 -0
  22. data/lib/anthropic/models/beta/beta_skill_params.rb +51 -0
  23. data/lib/anthropic/models/beta/beta_thinking_config_enabled.rb +1 -1
  24. data/lib/anthropic/models/beta/beta_thinking_config_param.rb +1 -1
  25. data/lib/anthropic/models/beta/beta_thinking_turns.rb +25 -0
  26. data/lib/anthropic/models/beta/beta_tool.rb +5 -3
  27. data/lib/anthropic/models/beta/beta_tool_use_block_param.rb +3 -3
  28. data/lib/anthropic/models/beta/message_count_tokens_params.rb +15 -12
  29. data/lib/anthropic/models/beta/message_create_params.rb +34 -18
  30. data/lib/anthropic/models/beta/messages/batch_create_params.rb +39 -20
  31. data/lib/anthropic/models/beta/skill_create_params.rb +49 -0
  32. data/lib/anthropic/models/beta/skill_create_response.rb +84 -0
  33. data/lib/anthropic/models/beta/skill_delete_params.rb +24 -0
  34. data/lib/anthropic/models/beta/skill_delete_response.rb +34 -0
  35. data/lib/anthropic/models/beta/skill_list_params.rb +61 -0
  36. data/lib/anthropic/models/beta/skill_list_response.rb +84 -0
  37. data/lib/anthropic/models/beta/skill_retrieve_params.rb +24 -0
  38. data/lib/anthropic/models/beta/skill_retrieve_response.rb +84 -0
  39. data/lib/anthropic/models/beta/skills/version_create_params.rb +42 -0
  40. data/lib/anthropic/models/beta/skills/version_create_response.rb +92 -0
  41. data/lib/anthropic/models/beta/skills/version_delete_params.rb +39 -0
  42. data/lib/anthropic/models/beta/skills/version_delete_response.rb +36 -0
  43. data/lib/anthropic/models/beta/skills/version_list_params.rb +47 -0
  44. data/lib/anthropic/models/beta/skills/version_list_response.rb +92 -0
  45. data/lib/anthropic/models/beta/skills/version_retrieve_params.rb +39 -0
  46. data/lib/anthropic/models/beta/skills/version_retrieve_response.rb +92 -0
  47. data/lib/anthropic/models/completion_create_params.rb +3 -4
  48. data/lib/anthropic/models/message_count_tokens_params.rb +10 -10
  49. data/lib/anthropic/models/message_create_params.rb +13 -13
  50. data/lib/anthropic/models/messages/batch_create_params.rb +14 -15
  51. data/lib/anthropic/models/model.rb +6 -20
  52. data/lib/anthropic/models/server_tool_use_block_param.rb +3 -3
  53. data/lib/anthropic/models/stop_reason.rb +0 -1
  54. data/lib/anthropic/models/thinking_config_enabled.rb +1 -1
  55. data/lib/anthropic/models/thinking_config_param.rb +1 -1
  56. data/lib/anthropic/models/tool.rb +5 -3
  57. data/lib/anthropic/models/tool_use_block_param.rb +3 -3
  58. data/lib/anthropic/resources/beta/messages.rb +5 -5
  59. data/lib/anthropic/resources/beta/skills/versions.rb +154 -0
  60. data/lib/anthropic/resources/beta/skills.rb +144 -0
  61. data/lib/anthropic/resources/beta.rb +4 -0
  62. data/lib/anthropic/resources/completions.rb +4 -4
  63. data/lib/anthropic/version.rb +1 -1
  64. data/lib/anthropic.rb +27 -0
  65. data/rbi/anthropic/internal/page_cursor.rbi +25 -0
  66. data/rbi/anthropic/internal/token_page.rbi +25 -0
  67. data/rbi/anthropic/models/anthropic_beta.rbi +2 -0
  68. data/rbi/anthropic/models/beta/beta_all_thinking_turns.rbi +30 -0
  69. data/rbi/anthropic/models/beta/beta_clear_thinking_20251015_edit.rbi +109 -0
  70. data/rbi/anthropic/models/beta/beta_clear_thinking_20251015_edit_response.rbi +61 -0
  71. data/rbi/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rbi +0 -1
  72. data/rbi/anthropic/models/beta/beta_container.rbi +23 -3
  73. data/rbi/anthropic/models/beta/beta_container_params.rbi +54 -0
  74. data/rbi/anthropic/models/beta/beta_context_management_config.rbi +51 -5
  75. data/rbi/anthropic/models/beta/beta_context_management_response.rbi +32 -4
  76. data/rbi/anthropic/models/beta/beta_mcp_tool_use_block.rbi +3 -3
  77. data/rbi/anthropic/models/beta/beta_mcp_tool_use_block_param.rbi +3 -3
  78. data/rbi/anthropic/models/beta/beta_message.rbi +6 -2
  79. data/rbi/anthropic/models/beta/beta_raw_message_delta_event.rbi +2 -2
  80. data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +3 -3
  81. data/rbi/anthropic/models/beta/beta_server_tool_use_block_param.rbi +3 -3
  82. data/rbi/anthropic/models/beta/beta_skill.rbi +80 -0
  83. data/rbi/anthropic/models/beta/beta_skill_params.rbi +91 -0
  84. data/rbi/anthropic/models/beta/beta_thinking_config_enabled.rbi +2 -2
  85. data/rbi/anthropic/models/beta/beta_thinking_config_param.rbi +1 -1
  86. data/rbi/anthropic/models/beta/beta_thinking_turns.rbi +33 -0
  87. data/rbi/anthropic/models/beta/beta_tool.rbi +3 -3
  88. data/rbi/anthropic/models/beta/beta_tool_use_block.rbi +8 -3
  89. data/rbi/anthropic/models/beta/beta_tool_use_block_param.rbi +3 -3
  90. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +27 -21
  91. data/rbi/anthropic/models/beta/message_create_params.rbi +61 -29
  92. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +70 -33
  93. data/rbi/anthropic/models/beta/skill_create_params.rbi +90 -0
  94. data/rbi/anthropic/models/beta/skill_create_response.rbi +118 -0
  95. data/rbi/anthropic/models/beta/skill_delete_params.rbi +62 -0
  96. data/rbi/anthropic/models/beta/skill_delete_response.rbi +46 -0
  97. data/rbi/anthropic/models/beta/skill_list_params.rbi +109 -0
  98. data/rbi/anthropic/models/beta/skill_list_response.rbi +118 -0
  99. data/rbi/anthropic/models/beta/skill_retrieve_params.rbi +62 -0
  100. data/rbi/anthropic/models/beta/skill_retrieve_response.rbi +118 -0
  101. data/rbi/anthropic/models/beta/skills/version_create_params.rbi +79 -0
  102. data/rbi/anthropic/models/beta/skills/version_create_response.rbi +124 -0
  103. data/rbi/anthropic/models/beta/skills/version_delete_params.rbi +77 -0
  104. data/rbi/anthropic/models/beta/skills/version_delete_response.rbi +48 -0
  105. data/rbi/anthropic/models/beta/skills/version_list_params.rbi +85 -0
  106. data/rbi/anthropic/models/beta/skills/version_list_response.rbi +124 -0
  107. data/rbi/anthropic/models/beta/skills/version_retrieve_params.rbi +77 -0
  108. data/rbi/anthropic/models/beta/skills/version_retrieve_response.rbi +124 -0
  109. data/rbi/anthropic/models/completion_create_params.rbi +6 -8
  110. data/rbi/anthropic/models/message_count_tokens_params.rbi +19 -19
  111. data/rbi/anthropic/models/message_create_params.rbi +24 -24
  112. data/rbi/anthropic/models/messages/batch_create_params.rbi +26 -28
  113. data/rbi/anthropic/models/model.rbi +0 -11
  114. data/rbi/anthropic/models/server_tool_use_block.rbi +8 -3
  115. data/rbi/anthropic/models/server_tool_use_block_param.rbi +3 -3
  116. data/rbi/anthropic/models/stop_reason.rbi +0 -5
  117. data/rbi/anthropic/models/thinking_config_enabled.rbi +2 -2
  118. data/rbi/anthropic/models/thinking_config_param.rbi +1 -1
  119. data/rbi/anthropic/models/tool.rbi +3 -3
  120. data/rbi/anthropic/models/tool_use_block.rbi +8 -3
  121. data/rbi/anthropic/models/tool_use_block_param.rbi +3 -3
  122. data/rbi/anthropic/resources/beta/messages.rbi +51 -36
  123. data/rbi/anthropic/resources/beta/skills/versions.rbi +124 -0
  124. data/rbi/anthropic/resources/beta/skills.rbi +118 -0
  125. data/rbi/anthropic/resources/beta.rbi +3 -0
  126. data/rbi/anthropic/resources/completions.rbi +10 -12
  127. data/rbi/anthropic/resources/messages.rbi +31 -31
  128. data/sig/anthropic/internal/page_cursor.rbs +15 -0
  129. data/sig/anthropic/internal/token_page.rbs +15 -0
  130. data/sig/anthropic/models/anthropic_beta.rbs +2 -0
  131. data/sig/anthropic/models/beta/beta_all_thinking_turns.rbs +17 -0
  132. data/sig/anthropic/models/beta/beta_clear_thinking_20251015_edit.rbs +44 -0
  133. data/sig/anthropic/models/beta/beta_clear_thinking_20251015_edit_response.rbs +34 -0
  134. data/sig/anthropic/models/beta/beta_container.rbs +18 -3
  135. data/sig/anthropic/models/beta/beta_container_params.rbs +26 -0
  136. data/sig/anthropic/models/beta/beta_context_management_config.rbs +18 -6
  137. data/sig/anthropic/models/beta/beta_context_management_response.rbs +14 -4
  138. data/sig/anthropic/models/beta/beta_mcp_tool_use_block.rbs +4 -4
  139. data/sig/anthropic/models/beta/beta_mcp_tool_use_block_param.rbs +4 -4
  140. data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +4 -4
  141. data/sig/anthropic/models/beta/beta_server_tool_use_block_param.rbs +4 -4
  142. data/sig/anthropic/models/beta/beta_skill.rbs +45 -0
  143. data/sig/anthropic/models/beta/beta_skill_params.rbs +47 -0
  144. data/sig/anthropic/models/beta/beta_thinking_turns.rbs +19 -0
  145. data/sig/anthropic/models/beta/beta_tool.rbs +8 -4
  146. data/sig/anthropic/models/beta/beta_tool_use_block.rbs +9 -4
  147. data/sig/anthropic/models/beta/beta_tool_use_block_param.rbs +4 -4
  148. data/sig/anthropic/models/beta/message_create_params.rbs +12 -4
  149. data/sig/anthropic/models/beta/messages/batch_create_params.rbs +12 -4
  150. data/sig/anthropic/models/beta/skill_create_params.rbs +42 -0
  151. data/sig/anthropic/models/beta/skill_create_response.rbs +52 -0
  152. data/sig/anthropic/models/beta/skill_delete_params.rbs +30 -0
  153. data/sig/anthropic/models/beta/skill_delete_response.rbs +17 -0
  154. data/sig/anthropic/models/beta/skill_list_params.rbs +49 -0
  155. data/sig/anthropic/models/beta/skill_list_response.rbs +52 -0
  156. data/sig/anthropic/models/beta/skill_retrieve_params.rbs +30 -0
  157. data/sig/anthropic/models/beta/skill_retrieve_response.rbs +52 -0
  158. data/sig/anthropic/models/beta/skills/version_create_params.rbs +39 -0
  159. data/sig/anthropic/models/beta/skills/version_create_response.rbs +59 -0
  160. data/sig/anthropic/models/beta/skills/version_delete_params.rbs +39 -0
  161. data/sig/anthropic/models/beta/skills/version_delete_response.rbs +19 -0
  162. data/sig/anthropic/models/beta/skills/version_list_params.rbs +44 -0
  163. data/sig/anthropic/models/beta/skills/version_list_response.rbs +59 -0
  164. data/sig/anthropic/models/beta/skills/version_retrieve_params.rbs +39 -0
  165. data/sig/anthropic/models/beta/skills/version_retrieve_response.rbs +59 -0
  166. data/sig/anthropic/models/model.rbs +0 -11
  167. data/sig/anthropic/models/server_tool_use_block.rbs +9 -4
  168. data/sig/anthropic/models/server_tool_use_block_param.rbs +4 -4
  169. data/sig/anthropic/models/stop_reason.rbs +0 -2
  170. data/sig/anthropic/models/tool.rbs +8 -4
  171. data/sig/anthropic/models/tool_use_block.rbs +9 -4
  172. data/sig/anthropic/models/tool_use_block_param.rbs +4 -4
  173. data/sig/anthropic/resources/beta/messages.rbs +2 -2
  174. data/sig/anthropic/resources/beta/skills/versions.rbs +40 -0
  175. data/sig/anthropic/resources/beta/skills.rbs +38 -0
  176. data/sig/anthropic/resources/beta.rbs +2 -0
  177. metadata +83 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12b3f9d861ff7a7496bf881459f0e91f5abd06dd600f39334bc001efdc2e25c6
4
- data.tar.gz: 3b38352e42254caddb6751cd4a3eff5b585c565dca670fe9a9437d59968a99d7
3
+ metadata.gz: 402cad94c15427670184c0922d15aa743631c9cf0178a2bd7d1a54fd515e138a
4
+ data.tar.gz: 89e7ff9f5a7072a3380a749286be91d0da71eb0067310ab558086496cd9264f3
5
5
  SHA512:
6
- metadata.gz: a55256f9935f4ffb75fa94b347ecc174c9c4a143e539c8de619c0cc55239a17d2d7779f0416188b4d0cb4736ee53960992231eac699585c5b788677bb76e4b07
7
- data.tar.gz: 557d3cfdc2af02f2b4642613f3bc3c9ad566fb40b1564848e7c8832abb89afd7bb1378e6f7f135da7b72c0abf0abc9cd4e3d6fa6d39e637621f5c2b2dd61b0b2
6
+ metadata.gz: 9439dd79ab1f200590ea63e60e27f444a51566fb75988b8b6a32cde0d20d404dd7e85b5bd77d94c21ec0ff77684df53f59d610063bb834e222ec1d267490d0f1
7
+ data.tar.gz: 998aca515a29223d30c4bd7f3c240e99c476a354eb40a3b2131feb62404893e3428ecf47d72bb188ff847af5f56125b87ec27bce90b03f69fb2cc8dc5d6d0ac5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.13.0 (2025-10-29)
4
+
5
+ Full Changelog: [v1.12.0...v1.13.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.12.0...v1.13.0)
6
+
7
+ ### Features
8
+
9
+ * add headers and status method to MessageStream ([#727](https://github.com/anthropics/anthropic-sdk-ruby/issues/727)) ([71fe5d0](https://github.com/anthropics/anthropic-sdk-ruby/commit/71fe5d072d3ba174383b7469c94375273d454ed3))
10
+ * **api:** add ability to clear thinking in context management ([c597009](https://github.com/anthropics/anthropic-sdk-ruby/commit/c5970096e8e35cc4cf04db328dd7a0f36f10de2a))
11
+ * handle thread interrupts in the core HTTP client ([ed4243d](https://github.com/anthropics/anthropic-sdk-ruby/commit/ed4243de16f67db3aa1cf2a01e671a481a96074e))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **client:** remove duplicate model ([3652886](https://github.com/anthropics/anthropic-sdk-ruby/commit/36528863de526228434352fab00d28bdc365ade8))
17
+
18
+
19
+ ### Chores
20
+
21
+ * **api:** mark older sonnet models as deprecated ([071c146](https://github.com/anthropics/anthropic-sdk-ruby/commit/071c14698878c7d4bccac73f91ea48d6ffcf8c55))
22
+ * **internal:** refactor message stream header and status retrieval ([#731](https://github.com/anthropics/anthropic-sdk-ruby/issues/731)) ([f763a1d](https://github.com/anthropics/anthropic-sdk-ruby/commit/f763a1df50369391ec235890d24ef01181f493df))
23
+
24
+ ## 1.12.0 (2025-10-16)
25
+
26
+ Full Changelog: [v1.11.0...v1.12.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.11.0...v1.12.0)
27
+
28
+ ### Features
29
+
30
+ * **api:** adding support for agent skills ([0e6b431](https://github.com/anthropics/anthropic-sdk-ruby/commit/0e6b431be2767a9674f80e3764955d8a5531cfec))
31
+
3
32
  ## 1.11.0 (2025-10-15)
4
33
 
5
34
  Full Changelog: [v1.10.1...v1.11.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.10.1...v1.11.0)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "anthropic", "~> 1.11.0"
18
+ gem "anthropic", "~> 1.13.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -271,6 +271,9 @@ module Anthropic
271
271
  @tool_models = tool_models
272
272
  # Lazy enumerable that transforms raw events into consumable events.
273
273
  @iterator = iterator
274
+ @status = raw_stream.status
275
+ @headers = raw_stream.headers
276
+ @model = raw_stream.instance_variable_get(:@model)
274
277
  end
275
278
  end
276
279
  end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Internal
5
+ # @generic Elem
6
+ #
7
+ # @example
8
+ # if page_cursor.has_next?
9
+ # page_cursor = page_cursor.next_page
10
+ # end
11
+ #
12
+ # @example
13
+ # page_cursor.auto_paging_each do |skill|
14
+ # puts(skill)
15
+ # end
16
+ class PageCursor
17
+ include Anthropic::Internal::Type::BasePage
18
+
19
+ # @return [Array<generic<Elem>>, nil]
20
+ attr_accessor :data
21
+
22
+ # @return [Boolean]
23
+ attr_accessor :has_more
24
+
25
+ # @return [String, nil]
26
+ attr_accessor :next_page_
27
+
28
+ # @return [Boolean]
29
+ def next_page?
30
+ has_more
31
+ end
32
+
33
+ # @raise [Anthropic::HTTP::Error]
34
+ # @return [self]
35
+ def next_page
36
+ unless next_page?
37
+ message = "No more pages available. Please check #next_page? before calling ##{__method__}"
38
+ raise RuntimeError.new(message)
39
+ end
40
+
41
+ req = Anthropic::Internal::Util.deep_merge(@req, {query: {page: next_page_}})
42
+ @client.request(req)
43
+ end
44
+
45
+ # @param blk [Proc]
46
+ #
47
+ # @yieldparam [generic<Elem>]
48
+ def auto_paging_each(&blk)
49
+ unless block_given?
50
+ raise ArgumentError.new("A block must be given to ##{__method__}")
51
+ end
52
+
53
+ page = self
54
+ loop do
55
+ page.data&.each(&blk)
56
+
57
+ break unless page.next_page?
58
+ page = page.next_page
59
+ end
60
+ end
61
+
62
+ # @api private
63
+ #
64
+ # @param client [Anthropic::Internal::Transport::BaseClient]
65
+ # @param req [Hash{Symbol=>Object}]
66
+ # @param headers [Hash{String=>String}]
67
+ # @param page_data [Hash{Symbol=>Object}]
68
+ def initialize(client:, req:, headers:, page_data:)
69
+ super
70
+
71
+ case page_data
72
+ in {data: Array => data}
73
+ @data = data.map { Anthropic::Internal::Type::Converter.coerce(@model, _1) }
74
+ else
75
+ end
76
+ @has_more = page_data[:has_more]
77
+ @next_page_ = page_data[:next_page]
78
+ end
79
+
80
+ # @api private
81
+ #
82
+ # @return [String]
83
+ def inspect
84
+ # rubocop:disable Layout/LineLength
85
+ model = Anthropic::Internal::Type::Converter.inspect(@model, depth: 1)
86
+
87
+ "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)} has_more=#{has_more.inspect} next_page_=#{next_page_.inspect}>"
88
+ # rubocop:enable Layout/LineLength
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Internal
5
+ # @generic Elem
6
+ #
7
+ # @example
8
+ # if token_page.has_next?
9
+ # token_page = token_page.next_page
10
+ # end
11
+ #
12
+ # @example
13
+ # token_page.auto_paging_each do |item|
14
+ # puts(item)
15
+ # end
16
+ class TokenPage
17
+ include Anthropic::Internal::Type::BasePage
18
+
19
+ # @return [Array<generic<Elem>>, nil]
20
+ attr_accessor :data
21
+
22
+ # @return [Boolean]
23
+ attr_accessor :has_more
24
+
25
+ # @return [String, nil]
26
+ attr_accessor :next_page_
27
+
28
+ # @return [Boolean]
29
+ def next_page?
30
+ has_more
31
+ end
32
+
33
+ # @raise [Anthropic::HTTP::Error]
34
+ # @return [self]
35
+ def next_page
36
+ unless next_page?
37
+ message = "No more pages available. Please check #next_page? before calling ##{__method__}"
38
+ raise RuntimeError.new(message)
39
+ end
40
+
41
+ req = Anthropic::Internal::Util.deep_merge(@req, {query: {page_token: next_page_}})
42
+ @client.request(req)
43
+ end
44
+
45
+ # @param blk [Proc]
46
+ #
47
+ # @yieldparam [generic<Elem>]
48
+ def auto_paging_each(&blk)
49
+ unless block_given?
50
+ raise ArgumentError.new("A block must be given to ##{__method__}")
51
+ end
52
+
53
+ page = self
54
+ loop do
55
+ page.data&.each(&blk)
56
+
57
+ break unless page.next_page?
58
+ page = page.next_page
59
+ end
60
+ end
61
+
62
+ # @api private
63
+ #
64
+ # @param client [Anthropic::Internal::Transport::BaseClient]
65
+ # @param req [Hash{Symbol=>Object}]
66
+ # @param headers [Hash{String=>String}]
67
+ # @param page_data [Hash{Symbol=>Object}]
68
+ def initialize(client:, req:, headers:, page_data:)
69
+ super
70
+
71
+ case page_data
72
+ in {data: Array => data}
73
+ @data = data.map { Anthropic::Internal::Type::Converter.coerce(@model, _1) }
74
+ else
75
+ end
76
+ @has_more = page_data[:has_more]
77
+ @next_page_ = page_data[:next_page]
78
+ end
79
+
80
+ # @api private
81
+ #
82
+ # @return [String]
83
+ def inspect
84
+ # rubocop:disable Layout/LineLength
85
+ model = Anthropic::Internal::Type::Converter.inspect(@model, depth: 1)
86
+
87
+ "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)} has_more=#{has_more.inspect} next_page_=#{next_page_.inspect}>"
88
+ # rubocop:enable Layout/LineLength
89
+ end
90
+ end
91
+ end
92
+ end
@@ -128,40 +128,48 @@ module Anthropic
128
128
  url, deadline = request.fetch_values(:url, :deadline)
129
129
 
130
130
  req = nil
131
- eof = false
132
131
  finished = false
133
- closing = nil
134
132
 
135
133
  # rubocop:disable Metrics/BlockLength
136
134
  enum = Enumerator.new do |y|
137
135
  next if finished
138
136
 
139
137
  with_pool(url, deadline: deadline) do |conn|
140
- req, closing = self.class.build_request(request) do
141
- self.class.calibrate_socket_timeout(conn, deadline)
142
- end
143
-
144
- self.class.calibrate_socket_timeout(conn, deadline)
145
- unless conn.started?
146
- conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
147
- conn.start
148
- end
138
+ eof = false
139
+ closing = nil
140
+ ::Thread.handle_interrupt(Object => :never) do
141
+ ::Thread.handle_interrupt(Object => :immediate) do
142
+ req, closing = self.class.build_request(request) do
143
+ self.class.calibrate_socket_timeout(conn, deadline)
144
+ end
149
145
 
150
- self.class.calibrate_socket_timeout(conn, deadline)
151
- conn.request(req) do |rsp|
152
- y << [req, rsp]
153
- break if finished
154
-
155
- rsp.read_body do |bytes|
156
- y << bytes.force_encoding(Encoding::BINARY)
157
- break if finished
146
+ self.class.calibrate_socket_timeout(conn, deadline)
147
+ unless conn.started?
148
+ conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
149
+ conn.start
150
+ end
158
151
 
159
152
  self.class.calibrate_socket_timeout(conn, deadline)
153
+ conn.request(req) do |rsp|
154
+ y << [req, rsp]
155
+ break if finished
156
+
157
+ rsp.read_body do |bytes|
158
+ y << bytes.force_encoding(Encoding::BINARY)
159
+ break if finished
160
+
161
+ self.class.calibrate_socket_timeout(conn, deadline)
162
+ end
163
+ eof = true
164
+ end
165
+ end
166
+ ensure
167
+ begin
168
+ conn.finish if !eof && conn&.started?
169
+ ensure
170
+ closing&.call
160
171
  end
161
- eof = true
162
172
  end
163
- ensure
164
- conn.finish if !eof && conn&.started?
165
173
  end
166
174
  rescue Timeout::Error
167
175
  raise Anthropic::Errors::APITimeoutError.new(url: url, request: req)
@@ -174,8 +182,6 @@ module Anthropic
174
182
  body = Anthropic::Internal::Util.fused_enum(enum, external: true) do
175
183
  finished = true
176
184
  loop { enum.next }
177
- ensure
178
- closing&.call
179
185
  end
180
186
  [Integer(response.code), response, body]
181
187
  end
@@ -41,6 +41,8 @@ module Anthropic
41
41
 
42
42
  variant const: -> { Anthropic::Models::AnthropicBeta::MODEL_CONTEXT_WINDOW_EXCEEDED_2025_08_26 }
43
43
 
44
+ variant const: -> { Anthropic::Models::AnthropicBeta::SKILLS_2025_10_02 }
45
+
44
46
  # @!method self.variants
45
47
  # @return [Array(String, Symbol)]
46
48
 
@@ -67,6 +69,7 @@ module Anthropic
67
69
  CONTEXT_1M_2025_08_07 = :"context-1m-2025-08-07"
68
70
  CONTEXT_MANAGEMENT_2025_06_27 = :"context-management-2025-06-27"
69
71
  MODEL_CONTEXT_WINDOW_EXCEEDED_2025_08_26 = :"model-context-window-exceeded-2025-08-26"
72
+ SKILLS_2025_10_02 = :"skills-2025-10-02"
70
73
 
71
74
  # @!endgroup
72
75
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaAllThinkingTurns < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute type
8
+ #
9
+ # @return [Symbol, :all]
10
+ required :type, const: :all
11
+
12
+ # @!method initialize(type: :all)
13
+ # @param type [Symbol, :all]
14
+ end
15
+ end
16
+
17
+ BetaAllThinkingTurns = Beta::BetaAllThinkingTurns
18
+ end
19
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaClearThinking20251015Edit < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute type
8
+ #
9
+ # @return [Symbol, :clear_thinking_20251015]
10
+ required :type, const: :clear_thinking_20251015
11
+
12
+ # @!attribute keep
13
+ # Number of most recent assistant turns to keep thinking blocks for. Older turns
14
+ # will have their thinking blocks removed.
15
+ #
16
+ # @return [Anthropic::Models::Beta::BetaThinkingTurns, Anthropic::Models::Beta::BetaAllThinkingTurns, Symbol, :all, nil]
17
+ optional :keep, union: -> { Anthropic::Beta::BetaClearThinking20251015Edit::Keep }
18
+
19
+ # @!method initialize(keep: nil, type: :clear_thinking_20251015)
20
+ # Some parameter documentations has been truncated, see
21
+ # {Anthropic::Models::Beta::BetaClearThinking20251015Edit} for more details.
22
+ #
23
+ # @param keep [Anthropic::Models::Beta::BetaThinkingTurns, Anthropic::Models::Beta::BetaAllThinkingTurns, Symbol, :all] Number of most recent assistant turns to keep thinking blocks for. Older turns w
24
+ #
25
+ # @param type [Symbol, :clear_thinking_20251015]
26
+
27
+ # Number of most recent assistant turns to keep thinking blocks for. Older turns
28
+ # will have their thinking blocks removed.
29
+ #
30
+ # @see Anthropic::Models::Beta::BetaClearThinking20251015Edit#keep
31
+ module Keep
32
+ extend Anthropic::Internal::Type::Union
33
+
34
+ variant -> { Anthropic::Beta::BetaThinkingTurns }
35
+
36
+ variant -> { Anthropic::Beta::BetaAllThinkingTurns }
37
+
38
+ variant const: :all
39
+
40
+ # @!method self.variants
41
+ # @return [Array(Anthropic::Models::Beta::BetaThinkingTurns, Anthropic::Models::Beta::BetaAllThinkingTurns, Symbol, :all)]
42
+ end
43
+ end
44
+ end
45
+
46
+ BetaClearThinking20251015Edit = Beta::BetaClearThinking20251015Edit
47
+ end
48
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaClearThinking20251015EditResponse < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute cleared_input_tokens
8
+ # Number of input tokens cleared by this edit.
9
+ #
10
+ # @return [Integer]
11
+ required :cleared_input_tokens, Integer
12
+
13
+ # @!attribute cleared_thinking_turns
14
+ # Number of thinking turns that were cleared.
15
+ #
16
+ # @return [Integer]
17
+ required :cleared_thinking_turns, Integer
18
+
19
+ # @!attribute type
20
+ # The type of context management edit applied.
21
+ #
22
+ # @return [Symbol, :clear_thinking_20251015]
23
+ required :type, const: :clear_thinking_20251015
24
+
25
+ # @!method initialize(cleared_input_tokens:, cleared_thinking_turns:, type: :clear_thinking_20251015)
26
+ # @param cleared_input_tokens [Integer] Number of input tokens cleared by this edit.
27
+ #
28
+ # @param cleared_thinking_turns [Integer] Number of thinking turns that were cleared.
29
+ #
30
+ # @param type [Symbol, :clear_thinking_20251015] The type of context management edit applied.
31
+ end
32
+ end
33
+
34
+ BetaClearThinking20251015EditResponse = Beta::BetaClearThinking20251015EditResponse
35
+ end
36
+ end
@@ -23,8 +23,6 @@ module Anthropic
23
23
  required :type, const: :clear_tool_uses_20250919
24
24
 
25
25
  # @!method initialize(cleared_input_tokens:, cleared_tool_uses:, type: :clear_tool_uses_20250919)
26
- # Results for clear_tool_uses_20250919 edit.
27
- #
28
26
  # @param cleared_input_tokens [Integer] Number of input tokens cleared by this edit.
29
27
  #
30
28
  # @param cleared_tool_uses [Integer] Number of tool uses that were cleared.
@@ -16,13 +16,21 @@ module Anthropic
16
16
  # @return [Time]
17
17
  required :expires_at, Time
18
18
 
19
- # @!method initialize(id:, expires_at:)
19
+ # @!attribute skills
20
+ # Skills loaded in the container
21
+ #
22
+ # @return [Array<Anthropic::Models::Beta::BetaSkill>, nil]
23
+ required :skills, -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaSkill] }, nil?: true
24
+
25
+ # @!method initialize(id:, expires_at:, skills:)
20
26
  # Information about the container used in the request (for the code execution
21
27
  # tool)
22
28
  #
23
29
  # @param id [String] Identifier for the container used in this request
24
30
  #
25
31
  # @param expires_at [Time] The time at which the container will expire.
32
+ #
33
+ # @param skills [Array<Anthropic::Models::Beta::BetaSkill>, nil] Skills loaded in the container
26
34
  end
27
35
  end
28
36
 
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaContainerParams < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute id
8
+ # Container id
9
+ #
10
+ # @return [String, nil]
11
+ optional :id, String, nil?: true
12
+
13
+ # @!attribute skills
14
+ # List of skills to load in the container
15
+ #
16
+ # @return [Array<Anthropic::Models::Beta::BetaSkillParams>, nil]
17
+ optional :skills,
18
+ -> {
19
+ Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaSkillParams]
20
+ },
21
+ nil?: true
22
+
23
+ # @!method initialize(id: nil, skills: nil)
24
+ # Container parameters with skills to be loaded.
25
+ #
26
+ # @param id [String, nil] Container id
27
+ #
28
+ # @param skills [Array<Anthropic::Models::Beta::BetaSkillParams>, nil] List of skills to load in the container
29
+ end
30
+ end
31
+
32
+ BetaContainerParams = Beta::BetaContainerParams
33
+ end
34
+ end
@@ -7,13 +7,25 @@ module Anthropic
7
7
  # @!attribute edits
8
8
  # List of context management edits to apply
9
9
  #
10
- # @return [Array<Anthropic::Models::Beta::BetaClearToolUses20250919Edit>, nil]
11
- optional :edits, -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaClearToolUses20250919Edit] }
10
+ # @return [Array<Anthropic::Models::Beta::BetaClearToolUses20250919Edit, Anthropic::Models::Beta::BetaClearThinking20251015Edit>, nil]
11
+ optional :edits,
12
+ -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaContextManagementConfig::Edit] }
12
13
 
13
14
  # @!method initialize(edits: nil)
14
- # Configuration for context management operations.
15
- #
16
- # @param edits [Array<Anthropic::Models::Beta::BetaClearToolUses20250919Edit>] List of context management edits to apply
15
+ # @param edits [Array<Anthropic::Models::Beta::BetaClearToolUses20250919Edit, Anthropic::Models::Beta::BetaClearThinking20251015Edit>] List of context management edits to apply
16
+
17
+ module Edit
18
+ extend Anthropic::Internal::Type::Union
19
+
20
+ discriminator :type
21
+
22
+ variant :clear_tool_uses_20250919, -> { Anthropic::Beta::BetaClearToolUses20250919Edit }
23
+
24
+ variant :clear_thinking_20251015, -> { Anthropic::Beta::BetaClearThinking20251015Edit }
25
+
26
+ # @!method self.variants
27
+ # @return [Array(Anthropic::Models::Beta::BetaClearToolUses20250919Edit, Anthropic::Models::Beta::BetaClearThinking20251015Edit)]
28
+ end
17
29
  end
18
30
  end
19
31
 
@@ -7,14 +7,25 @@ module Anthropic
7
7
  # @!attribute applied_edits
8
8
  # List of context management edits that were applied.
9
9
  #
10
- # @return [Array<Anthropic::Models::Beta::BetaClearToolUses20250919EditResponse>]
10
+ # @return [Array<Anthropic::Models::Beta::BetaClearToolUses20250919EditResponse, Anthropic::Models::Beta::BetaClearThinking20251015EditResponse>]
11
11
  required :applied_edits,
12
- -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaClearToolUses20250919EditResponse] }
12
+ -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaContextManagementResponse::AppliedEdit] }
13
13
 
14
14
  # @!method initialize(applied_edits:)
15
- # Information about context management operations applied during the request.
16
- #
17
- # @param applied_edits [Array<Anthropic::Models::Beta::BetaClearToolUses20250919EditResponse>] List of context management edits that were applied.
15
+ # @param applied_edits [Array<Anthropic::Models::Beta::BetaClearToolUses20250919EditResponse, Anthropic::Models::Beta::BetaClearThinking20251015EditResponse>] List of context management edits that were applied.
16
+
17
+ module AppliedEdit
18
+ extend Anthropic::Internal::Type::Union
19
+
20
+ discriminator :type
21
+
22
+ variant :clear_tool_uses_20250919, -> { Anthropic::Beta::BetaClearToolUses20250919EditResponse }
23
+
24
+ variant :clear_thinking_20251015, -> { Anthropic::Beta::BetaClearThinking20251015EditResponse }
25
+
26
+ # @!method self.variants
27
+ # @return [Array(Anthropic::Models::Beta::BetaClearToolUses20250919EditResponse, Anthropic::Models::Beta::BetaClearThinking20251015EditResponse)]
28
+ end
18
29
  end
19
30
  end
20
31
 
@@ -11,8 +11,8 @@ module Anthropic
11
11
 
12
12
  # @!attribute input
13
13
  #
14
- # @return [Object]
15
- required :input, Anthropic::Internal::Type::Unknown
14
+ # @return [Hash{Symbol=>Object}]
15
+ required :input, Anthropic::Internal::Type::HashOf[Anthropic::Internal::Type::Unknown]
16
16
 
17
17
  # @!attribute name
18
18
  #
@@ -39,7 +39,7 @@ module Anthropic
39
39
  # @!method initialize(id:, input:, name:, server_name:, cache_control: nil, type: :mcp_tool_use)
40
40
  # @param id [String]
41
41
  #
42
- # @param input [Object]
42
+ # @param input [Hash{Symbol=>Object}]
43
43
  #
44
44
  # @param name [String]
45
45
  #
@@ -60,7 +60,9 @@ module Anthropic
60
60
  required :content, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaContentBlock] }
61
61
 
62
62
  # @!attribute context_management
63
- # Information about context management operations applied during the request.
63
+ # Context management response.
64
+ #
65
+ # Information about context management strategies applied during the request.
64
66
  #
65
67
  # @return [Anthropic::Models::Beta::BetaContextManagementResponse, nil]
66
68
  required :context_management, -> { Anthropic::Beta::BetaContextManagementResponse }, nil?: true
@@ -148,7 +150,7 @@ module Anthropic
148
150
  #
149
151
  # @param content [Array<Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock>] Content generated by the model.
150
152
  #
151
- # @param context_management [Anthropic::Models::Beta::BetaContextManagementResponse, nil] Information about context management operations applied during the request.
153
+ # @param context_management [Anthropic::Models::Beta::BetaContextManagementResponse, nil] Context management response.
152
154
  #
153
155
  # @param model [Symbol, String, Anthropic::Models::Model] The model that will complete your prompt.\n\nSee [models](https://docs.anthropic
154
156
  #
@@ -5,7 +5,7 @@ module Anthropic
5
5
  module Beta
6
6
  class BetaRawMessageDeltaEvent < Anthropic::Internal::Type::BaseModel
7
7
  # @!attribute context_management
8
- # Information about context management operations applied during the request.
8
+ # Information about context management strategies applied during the request
9
9
  #
10
10
  # @return [Anthropic::Models::Beta::BetaContextManagementResponse, nil]
11
11
  required :context_management, -> { Anthropic::Beta::BetaContextManagementResponse }, nil?: true
@@ -44,7 +44,7 @@ module Anthropic
44
44
  # Some parameter documentations has been truncated, see
45
45
  # {Anthropic::Models::Beta::BetaRawMessageDeltaEvent} for more details.
46
46
  #
47
- # @param context_management [Anthropic::Models::Beta::BetaContextManagementResponse, nil] Information about context management operations applied during the request.
47
+ # @param context_management [Anthropic::Models::Beta::BetaContextManagementResponse, nil] Information about context management strategies applied during the request
48
48
  #
49
49
  # @param delta [Anthropic::Models::Beta::BetaRawMessageDeltaEvent::Delta]
50
50
  #