anthropic 1.1.1 → 1.6.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 (197) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +123 -0
  3. data/README.md +32 -16
  4. data/lib/anthropic/client.rb +5 -2
  5. data/lib/anthropic/errors.rb +22 -0
  6. data/lib/anthropic/helpers/bedrock/client.rb +34 -4
  7. data/lib/anthropic/helpers/streaming/events.rb +141 -0
  8. data/lib/anthropic/helpers/streaming/message_stream.rb +238 -0
  9. data/lib/anthropic/helpers/streaming.rb +37 -0
  10. data/lib/anthropic/helpers/vertex/client.rb +4 -1
  11. data/lib/anthropic/internal/stream.rb +4 -2
  12. data/lib/anthropic/internal/transport/base_client.rb +29 -3
  13. data/lib/anthropic/internal/type/array_of.rb +7 -1
  14. data/lib/anthropic/internal/type/base_model.rb +80 -24
  15. data/lib/anthropic/internal/type/base_stream.rb +3 -1
  16. data/lib/anthropic/internal/type/boolean.rb +7 -1
  17. data/lib/anthropic/internal/type/converter.rb +69 -34
  18. data/lib/anthropic/internal/type/enum.rb +16 -5
  19. data/lib/anthropic/internal/type/file_input.rb +6 -1
  20. data/lib/anthropic/internal/type/hash_of.rb +7 -1
  21. data/lib/anthropic/internal/type/union.rb +26 -16
  22. data/lib/anthropic/internal/type/unknown.rb +7 -1
  23. data/lib/anthropic/internal/util.rb +8 -9
  24. data/lib/anthropic/models/anthropic_beta.rb +3 -0
  25. data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +1 -65
  26. data/lib/anthropic/models/beta/beta_citation_char_location.rb +7 -1
  27. data/lib/anthropic/models/beta/beta_citation_content_block_location.rb +7 -1
  28. data/lib/anthropic/models/beta/beta_citation_page_location.rb +7 -1
  29. data/lib/anthropic/models/beta/beta_citation_search_result_location.rb +55 -0
  30. data/lib/anthropic/models/beta/beta_citation_search_result_location_param.rb +55 -0
  31. data/lib/anthropic/models/beta/beta_citations_delta.rb +5 -3
  32. data/lib/anthropic/models/beta/beta_content_block.rb +5 -5
  33. data/lib/anthropic/models/beta/beta_content_block_param.rb +20 -17
  34. data/lib/anthropic/models/beta/beta_message.rb +6 -2
  35. data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
  36. data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +7 -7
  37. data/lib/anthropic/models/beta/beta_request_document_block.rb +75 -0
  38. data/lib/anthropic/models/beta/beta_search_result_block_param.rb +55 -0
  39. data/lib/anthropic/models/beta/beta_text_block.rb +2 -2
  40. data/lib/anthropic/models/beta/beta_text_block_param.rb +2 -2
  41. data/lib/anthropic/models/beta/beta_text_citation.rb +3 -1
  42. data/lib/anthropic/models/beta/beta_text_citation_param.rb +3 -1
  43. data/lib/anthropic/models/beta/beta_tool.rb +7 -1
  44. data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +6 -4
  45. data/lib/anthropic/models/beta/beta_tool_text_editor_20250728.rb +49 -0
  46. data/lib/anthropic/models/beta/beta_tool_union.rb +9 -7
  47. data/lib/anthropic/models/beta/message_count_tokens_params.rb +18 -10
  48. data/lib/anthropic/models/beta/message_create_params.rb +9 -3
  49. data/lib/anthropic/models/beta/messages/batch_create_params.rb +9 -3
  50. data/lib/anthropic/models/citation_char_location.rb +7 -1
  51. data/lib/anthropic/models/citation_content_block_location.rb +7 -1
  52. data/lib/anthropic/models/citation_page_location.rb +7 -1
  53. data/lib/anthropic/models/citation_search_result_location_param.rb +51 -0
  54. data/lib/anthropic/models/citations_delta.rb +5 -3
  55. data/lib/anthropic/models/citations_search_result_location.rb +51 -0
  56. data/lib/anthropic/models/content_block.rb +5 -5
  57. data/lib/anthropic/models/content_block_param.rb +14 -11
  58. data/lib/anthropic/models/message.rb +6 -2
  59. data/lib/anthropic/models/message_count_tokens_params.rb +9 -3
  60. data/lib/anthropic/models/message_count_tokens_tool.rb +5 -1
  61. data/lib/anthropic/models/message_create_params.rb +9 -3
  62. data/lib/anthropic/models/message_param.rb +3 -3
  63. data/lib/anthropic/models/messages/batch_create_params.rb +9 -3
  64. data/lib/anthropic/models/model.rb +10 -21
  65. data/lib/anthropic/models/raw_content_block_start_event.rb +7 -7
  66. data/lib/anthropic/models/search_result_block_param.rb +51 -0
  67. data/lib/anthropic/models/text_block.rb +2 -2
  68. data/lib/anthropic/models/text_block_param.rb +2 -2
  69. data/lib/anthropic/models/text_citation.rb +3 -1
  70. data/lib/anthropic/models/text_citation_param.rb +3 -1
  71. data/lib/anthropic/models/tool.rb +7 -1
  72. data/lib/anthropic/models/tool_result_block_param.rb +6 -4
  73. data/lib/anthropic/models/tool_text_editor_20250429.rb +36 -0
  74. data/lib/anthropic/models/tool_text_editor_20250728.rb +45 -0
  75. data/lib/anthropic/models/tool_union.rb +5 -1
  76. data/lib/anthropic/models/tool_use_block.rb +6 -0
  77. data/lib/anthropic/models.rb +14 -4
  78. data/lib/anthropic/resources/beta/messages.rb +73 -6
  79. data/lib/anthropic/resources/messages.rb +68 -7
  80. data/lib/anthropic/streaming.rb +5 -0
  81. data/lib/anthropic/version.rb +1 -1
  82. data/lib/anthropic.rb +14 -0
  83. data/rbi/anthropic/errors.rbi +16 -0
  84. data/rbi/anthropic/helpers/bedrock/client.rbi +17 -6
  85. data/rbi/anthropic/helpers/streaming/events.rbi +95 -0
  86. data/rbi/anthropic/helpers/streaming/message_stream.rbi +73 -0
  87. data/rbi/anthropic/helpers/vertex/client.rbi +17 -6
  88. data/rbi/anthropic/internal/transport/base_client.rbi +1 -1
  89. data/rbi/anthropic/internal/type/base_stream.rbi +8 -1
  90. data/rbi/anthropic/internal/type/boolean.rbi +2 -0
  91. data/rbi/anthropic/internal/type/converter.rbi +69 -15
  92. data/rbi/anthropic/internal/type/union.rbi +14 -2
  93. data/rbi/anthropic/internal/type/unknown.rbi +2 -0
  94. data/rbi/anthropic/internal/util.rbi +2 -0
  95. data/rbi/anthropic/models/anthropic_beta.rbi +2 -0
  96. data/rbi/anthropic/models/beta/beta_base64_pdf_block.rbi +1 -128
  97. data/rbi/anthropic/models/beta/beta_citation_char_location.rbi +6 -0
  98. data/rbi/anthropic/models/beta/beta_citation_content_block_location.rbi +6 -0
  99. data/rbi/anthropic/models/beta/beta_citation_page_location.rbi +6 -0
  100. data/rbi/anthropic/models/beta/beta_citation_search_result_location.rbi +78 -0
  101. data/rbi/anthropic/models/beta/beta_citation_search_result_location_param.rbi +79 -0
  102. data/rbi/anthropic/models/beta/beta_citations_delta.rbi +4 -2
  103. data/rbi/anthropic/models/beta/beta_content_block.rbi +3 -3
  104. data/rbi/anthropic/models/beta/beta_content_block_param.rbi +8 -7
  105. data/rbi/anthropic/models/beta/beta_message.rbi +11 -3
  106. data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +6 -6
  107. data/rbi/anthropic/models/beta/beta_request_document_block.rbi +140 -0
  108. data/rbi/anthropic/models/beta/beta_search_result_block_param.rbi +91 -0
  109. data/rbi/anthropic/models/beta/beta_text_block.rbi +2 -1
  110. data/rbi/anthropic/models/beta/beta_text_block_param.rbi +6 -3
  111. data/rbi/anthropic/models/beta/beta_text_citation.rbi +2 -1
  112. data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +2 -1
  113. data/rbi/anthropic/models/beta/beta_tool.rbi +14 -5
  114. data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +2 -1
  115. data/rbi/anthropic/models/beta/beta_tool_text_editor_20250728.rbi +82 -0
  116. data/rbi/anthropic/models/beta/beta_tool_union.rbi +6 -5
  117. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +44 -27
  118. data/rbi/anthropic/models/beta/message_create_params.rbi +38 -22
  119. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +38 -22
  120. data/rbi/anthropic/models/citation_char_location.rbi +6 -0
  121. data/rbi/anthropic/models/citation_content_block_location.rbi +6 -0
  122. data/rbi/anthropic/models/citation_page_location.rbi +6 -0
  123. data/rbi/anthropic/models/citation_search_result_location_param.rbi +74 -0
  124. data/rbi/anthropic/models/citations_delta.rbi +4 -2
  125. data/rbi/anthropic/models/citations_search_result_location.rbi +74 -0
  126. data/rbi/anthropic/models/content_block.rbi +3 -3
  127. data/rbi/anthropic/models/content_block_param.rbi +6 -5
  128. data/rbi/anthropic/models/message.rbi +11 -3
  129. data/rbi/anthropic/models/message_count_tokens_params.rbi +22 -2
  130. data/rbi/anthropic/models/message_count_tokens_tool.rbi +2 -0
  131. data/rbi/anthropic/models/message_create_params.rbi +22 -2
  132. data/rbi/anthropic/models/messages/batch_create_params.rbi +22 -2
  133. data/rbi/anthropic/models/model.rbi +4 -8
  134. data/rbi/anthropic/models/raw_content_block_start_event.rbi +6 -6
  135. data/rbi/anthropic/models/search_result_block_param.rbi +77 -0
  136. data/rbi/anthropic/models/text_block.rbi +2 -1
  137. data/rbi/anthropic/models/text_block_param.rbi +6 -3
  138. data/rbi/anthropic/models/text_citation.rbi +2 -1
  139. data/rbi/anthropic/models/text_citation_param.rbi +2 -1
  140. data/rbi/anthropic/models/tool.rbi +16 -5
  141. data/rbi/anthropic/models/tool_result_block_param.rbi +5 -1
  142. data/rbi/anthropic/models/tool_text_editor_20250429.rbi +62 -0
  143. data/rbi/anthropic/models/tool_text_editor_20250728.rbi +72 -0
  144. data/rbi/anthropic/models/tool_union.rbi +2 -0
  145. data/rbi/anthropic/models.rbi +12 -0
  146. data/rbi/anthropic/resources/beta/messages.rbi +39 -18
  147. data/rbi/anthropic/resources/messages.rbi +318 -3
  148. data/rbi/anthropic/streaming.rbi +5 -0
  149. data/sig/anthropic/errors.rbs +9 -0
  150. data/sig/anthropic/helpers/streaming/events.rbs +117 -0
  151. data/sig/anthropic/helpers/streaming/message_stream.rbs +57 -0
  152. data/sig/anthropic/internal/transport/base_client.rbs +1 -1
  153. data/sig/anthropic/internal/type/base_stream.rbs +4 -0
  154. data/sig/anthropic/internal/type/converter.rbs +24 -1
  155. data/sig/anthropic/internal/type/union.rbs +2 -2
  156. data/sig/anthropic/models/anthropic_beta.rbs +2 -0
  157. data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +1 -58
  158. data/sig/anthropic/models/beta/beta_citation_char_location.rbs +5 -0
  159. data/sig/anthropic/models/beta/beta_citation_content_block_location.rbs +5 -0
  160. data/sig/anthropic/models/beta/beta_citation_page_location.rbs +5 -0
  161. data/sig/anthropic/models/beta/beta_citation_search_result_location.rbs +54 -0
  162. data/sig/anthropic/models/beta/beta_citation_search_result_location_param.rbs +54 -0
  163. data/sig/anthropic/models/beta/beta_citations_delta.rbs +1 -0
  164. data/sig/anthropic/models/beta/beta_content_block.rbs +2 -2
  165. data/sig/anthropic/models/beta/beta_content_block_param.rbs +9 -8
  166. data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +2 -2
  167. data/sig/anthropic/models/beta/beta_request_document_block.rbs +66 -0
  168. data/sig/anthropic/models/beta/beta_search_result_block_param.rbs +53 -0
  169. data/sig/anthropic/models/beta/beta_text_citation.rbs +1 -0
  170. data/sig/anthropic/models/beta/beta_text_citation_param.rbs +1 -0
  171. data/sig/anthropic/models/beta/beta_tool.rbs +14 -3
  172. data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +1 -0
  173. data/sig/anthropic/models/beta/beta_tool_text_editor_20250728.rbs +39 -0
  174. data/sig/anthropic/models/beta/beta_tool_union.rbs +5 -4
  175. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +5 -4
  176. data/sig/anthropic/models/citation_char_location.rbs +5 -0
  177. data/sig/anthropic/models/citation_content_block_location.rbs +5 -0
  178. data/sig/anthropic/models/citation_page_location.rbs +5 -0
  179. data/sig/anthropic/models/citation_search_result_location_param.rbs +50 -0
  180. data/sig/anthropic/models/citations_delta.rbs +1 -0
  181. data/sig/anthropic/models/citations_search_result_location.rbs +50 -0
  182. data/sig/anthropic/models/content_block.rbs +2 -2
  183. data/sig/anthropic/models/content_block_param.rbs +6 -5
  184. data/sig/anthropic/models/message_count_tokens_tool.rbs +2 -0
  185. data/sig/anthropic/models/model.rbs +4 -10
  186. data/sig/anthropic/models/raw_content_block_start_event.rbs +2 -2
  187. data/sig/anthropic/models/search_result_block_param.rbs +49 -0
  188. data/sig/anthropic/models/text_citation.rbs +1 -0
  189. data/sig/anthropic/models/text_citation_param.rbs +1 -0
  190. data/sig/anthropic/models/tool.rbs +14 -3
  191. data/sig/anthropic/models/tool_result_block_param.rbs +4 -1
  192. data/sig/anthropic/models/tool_text_editor_20250429.rbs +30 -0
  193. data/sig/anthropic/models/tool_text_editor_20250728.rbs +35 -0
  194. data/sig/anthropic/models/tool_union.rbs +2 -0
  195. data/sig/anthropic/models.rbs +10 -0
  196. data/sig/anthropic/streaming.rbs +3 -0
  197. metadata +44 -3
@@ -33,15 +33,15 @@ module Anthropic
33
33
  content_block:
34
34
  T.any(
35
35
  Anthropic::Beta::BetaTextBlock::OrHash,
36
+ Anthropic::Beta::BetaThinkingBlock::OrHash,
37
+ Anthropic::Beta::BetaRedactedThinkingBlock::OrHash,
36
38
  Anthropic::Beta::BetaToolUseBlock::OrHash,
37
39
  Anthropic::Beta::BetaServerToolUseBlock::OrHash,
38
40
  Anthropic::Beta::BetaWebSearchToolResultBlock::OrHash,
39
41
  Anthropic::Beta::BetaCodeExecutionToolResultBlock::OrHash,
40
42
  Anthropic::Beta::BetaMCPToolUseBlock::OrHash,
41
43
  Anthropic::Beta::BetaMCPToolResultBlock::OrHash,
42
- Anthropic::Beta::BetaContainerUploadBlock::OrHash,
43
- Anthropic::Beta::BetaThinkingBlock::OrHash,
44
- Anthropic::Beta::BetaRedactedThinkingBlock::OrHash
44
+ Anthropic::Beta::BetaContainerUploadBlock::OrHash
45
45
  ),
46
46
  index: Integer,
47
47
  type: Symbol
@@ -76,15 +76,15 @@ module Anthropic
76
76
  T.type_alias do
77
77
  T.any(
78
78
  Anthropic::Beta::BetaTextBlock,
79
+ Anthropic::Beta::BetaThinkingBlock,
80
+ Anthropic::Beta::BetaRedactedThinkingBlock,
79
81
  Anthropic::Beta::BetaToolUseBlock,
80
82
  Anthropic::Beta::BetaServerToolUseBlock,
81
83
  Anthropic::Beta::BetaWebSearchToolResultBlock,
82
84
  Anthropic::Beta::BetaCodeExecutionToolResultBlock,
83
85
  Anthropic::Beta::BetaMCPToolUseBlock,
84
86
  Anthropic::Beta::BetaMCPToolResultBlock,
85
- Anthropic::Beta::BetaContainerUploadBlock,
86
- Anthropic::Beta::BetaThinkingBlock,
87
- Anthropic::Beta::BetaRedactedThinkingBlock
87
+ Anthropic::Beta::BetaContainerUploadBlock
88
88
  )
89
89
  end
90
90
 
@@ -0,0 +1,140 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaRequestDocumentBlock = Beta::BetaRequestDocumentBlock
6
+
7
+ module Beta
8
+ class BetaRequestDocumentBlock < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaRequestDocumentBlock,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig do
18
+ returns(
19
+ T.any(
20
+ Anthropic::Beta::BetaBase64PDFSource,
21
+ Anthropic::Beta::BetaPlainTextSource,
22
+ Anthropic::Beta::BetaContentBlockSource,
23
+ Anthropic::Beta::BetaURLPDFSource,
24
+ Anthropic::Beta::BetaFileDocumentSource
25
+ )
26
+ )
27
+ end
28
+ attr_accessor :source
29
+
30
+ sig { returns(Symbol) }
31
+ attr_accessor :type
32
+
33
+ # Create a cache control breakpoint at this content block.
34
+ sig { returns(T.nilable(Anthropic::Beta::BetaCacheControlEphemeral)) }
35
+ attr_reader :cache_control
36
+
37
+ sig do
38
+ params(
39
+ cache_control:
40
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral::OrHash)
41
+ ).void
42
+ end
43
+ attr_writer :cache_control
44
+
45
+ sig { returns(T.nilable(Anthropic::Beta::BetaCitationsConfigParam)) }
46
+ attr_reader :citations
47
+
48
+ sig do
49
+ params(
50
+ citations: Anthropic::Beta::BetaCitationsConfigParam::OrHash
51
+ ).void
52
+ end
53
+ attr_writer :citations
54
+
55
+ sig { returns(T.nilable(String)) }
56
+ attr_accessor :context
57
+
58
+ sig { returns(T.nilable(String)) }
59
+ attr_accessor :title
60
+
61
+ sig do
62
+ params(
63
+ source:
64
+ T.any(
65
+ Anthropic::Beta::BetaBase64PDFSource::OrHash,
66
+ Anthropic::Beta::BetaPlainTextSource::OrHash,
67
+ Anthropic::Beta::BetaContentBlockSource::OrHash,
68
+ Anthropic::Beta::BetaURLPDFSource::OrHash,
69
+ Anthropic::Beta::BetaFileDocumentSource::OrHash
70
+ ),
71
+ cache_control:
72
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral::OrHash),
73
+ citations: Anthropic::Beta::BetaCitationsConfigParam::OrHash,
74
+ context: T.nilable(String),
75
+ title: T.nilable(String),
76
+ type: Symbol
77
+ ).returns(T.attached_class)
78
+ end
79
+ def self.new(
80
+ source:,
81
+ # Create a cache control breakpoint at this content block.
82
+ cache_control: nil,
83
+ citations: nil,
84
+ context: nil,
85
+ title: nil,
86
+ type: :document
87
+ )
88
+ end
89
+
90
+ sig do
91
+ override.returns(
92
+ {
93
+ source:
94
+ T.any(
95
+ Anthropic::Beta::BetaBase64PDFSource,
96
+ Anthropic::Beta::BetaPlainTextSource,
97
+ Anthropic::Beta::BetaContentBlockSource,
98
+ Anthropic::Beta::BetaURLPDFSource,
99
+ Anthropic::Beta::BetaFileDocumentSource
100
+ ),
101
+ type: Symbol,
102
+ cache_control:
103
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral),
104
+ citations: Anthropic::Beta::BetaCitationsConfigParam,
105
+ context: T.nilable(String),
106
+ title: T.nilable(String)
107
+ }
108
+ )
109
+ end
110
+ def to_hash
111
+ end
112
+
113
+ module Source
114
+ extend Anthropic::Internal::Type::Union
115
+
116
+ Variants =
117
+ T.type_alias do
118
+ T.any(
119
+ Anthropic::Beta::BetaBase64PDFSource,
120
+ Anthropic::Beta::BetaPlainTextSource,
121
+ Anthropic::Beta::BetaContentBlockSource,
122
+ Anthropic::Beta::BetaURLPDFSource,
123
+ Anthropic::Beta::BetaFileDocumentSource
124
+ )
125
+ end
126
+
127
+ sig do
128
+ override.returns(
129
+ T::Array[
130
+ Anthropic::Beta::BetaRequestDocumentBlock::Source::Variants
131
+ ]
132
+ )
133
+ end
134
+ def self.variants
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,91 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaSearchResultBlockParam = Beta::BetaSearchResultBlockParam
6
+
7
+ module Beta
8
+ class BetaSearchResultBlockParam < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaSearchResultBlockParam,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(T::Array[Anthropic::Beta::BetaTextBlockParam]) }
18
+ attr_accessor :content
19
+
20
+ sig { returns(String) }
21
+ attr_accessor :source
22
+
23
+ sig { returns(String) }
24
+ attr_accessor :title
25
+
26
+ sig { returns(Symbol) }
27
+ attr_accessor :type
28
+
29
+ # Create a cache control breakpoint at this content block.
30
+ sig { returns(T.nilable(Anthropic::Beta::BetaCacheControlEphemeral)) }
31
+ attr_reader :cache_control
32
+
33
+ sig do
34
+ params(
35
+ cache_control:
36
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral::OrHash)
37
+ ).void
38
+ end
39
+ attr_writer :cache_control
40
+
41
+ sig { returns(T.nilable(Anthropic::Beta::BetaCitationsConfigParam)) }
42
+ attr_reader :citations
43
+
44
+ sig do
45
+ params(
46
+ citations: Anthropic::Beta::BetaCitationsConfigParam::OrHash
47
+ ).void
48
+ end
49
+ attr_writer :citations
50
+
51
+ sig do
52
+ params(
53
+ content: T::Array[Anthropic::Beta::BetaTextBlockParam::OrHash],
54
+ source: String,
55
+ title: String,
56
+ cache_control:
57
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral::OrHash),
58
+ citations: Anthropic::Beta::BetaCitationsConfigParam::OrHash,
59
+ type: Symbol
60
+ ).returns(T.attached_class)
61
+ end
62
+ def self.new(
63
+ content:,
64
+ source:,
65
+ title:,
66
+ # Create a cache control breakpoint at this content block.
67
+ cache_control: nil,
68
+ citations: nil,
69
+ type: :search_result
70
+ )
71
+ end
72
+
73
+ sig do
74
+ override.returns(
75
+ {
76
+ content: T::Array[Anthropic::Beta::BetaTextBlockParam],
77
+ source: String,
78
+ title: String,
79
+ type: Symbol,
80
+ cache_control:
81
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral),
82
+ citations: Anthropic::Beta::BetaCitationsConfigParam
83
+ }
84
+ )
85
+ end
86
+ def to_hash
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -38,7 +38,8 @@ module Anthropic
38
38
  Anthropic::Beta::BetaCitationCharLocation::OrHash,
39
39
  Anthropic::Beta::BetaCitationPageLocation::OrHash,
40
40
  Anthropic::Beta::BetaCitationContentBlockLocation::OrHash,
41
- Anthropic::Beta::BetaCitationsWebSearchResultLocation::OrHash
41
+ Anthropic::Beta::BetaCitationsWebSearchResultLocation::OrHash,
42
+ Anthropic::Beta::BetaCitationSearchResultLocation::OrHash
42
43
  )
43
44
  ]
44
45
  ),
@@ -40,7 +40,8 @@ module Anthropic
40
40
  Anthropic::Beta::BetaCitationCharLocationParam,
41
41
  Anthropic::Beta::BetaCitationPageLocationParam,
42
42
  Anthropic::Beta::BetaCitationContentBlockLocationParam,
43
- Anthropic::Beta::BetaCitationWebSearchResultLocationParam
43
+ Anthropic::Beta::BetaCitationWebSearchResultLocationParam,
44
+ Anthropic::Beta::BetaCitationSearchResultLocationParam
44
45
  )
45
46
  ]
46
47
  )
@@ -60,7 +61,8 @@ module Anthropic
60
61
  Anthropic::Beta::BetaCitationCharLocationParam::OrHash,
61
62
  Anthropic::Beta::BetaCitationPageLocationParam::OrHash,
62
63
  Anthropic::Beta::BetaCitationContentBlockLocationParam::OrHash,
63
- Anthropic::Beta::BetaCitationWebSearchResultLocationParam::OrHash
64
+ Anthropic::Beta::BetaCitationWebSearchResultLocationParam::OrHash,
65
+ Anthropic::Beta::BetaCitationSearchResultLocationParam::OrHash
64
66
  )
65
67
  ]
66
68
  ),
@@ -90,7 +92,8 @@ module Anthropic
90
92
  Anthropic::Beta::BetaCitationCharLocationParam,
91
93
  Anthropic::Beta::BetaCitationPageLocationParam,
92
94
  Anthropic::Beta::BetaCitationContentBlockLocationParam,
93
- Anthropic::Beta::BetaCitationWebSearchResultLocationParam
95
+ Anthropic::Beta::BetaCitationWebSearchResultLocationParam,
96
+ Anthropic::Beta::BetaCitationSearchResultLocationParam
94
97
  )
95
98
  ]
96
99
  )
@@ -14,7 +14,8 @@ module Anthropic
14
14
  Anthropic::Beta::BetaCitationCharLocation,
15
15
  Anthropic::Beta::BetaCitationPageLocation,
16
16
  Anthropic::Beta::BetaCitationContentBlockLocation,
17
- Anthropic::Beta::BetaCitationsWebSearchResultLocation
17
+ Anthropic::Beta::BetaCitationsWebSearchResultLocation,
18
+ Anthropic::Beta::BetaCitationSearchResultLocation
18
19
  )
19
20
  end
20
21
 
@@ -14,7 +14,8 @@ module Anthropic
14
14
  Anthropic::Beta::BetaCitationCharLocationParam,
15
15
  Anthropic::Beta::BetaCitationPageLocationParam,
16
16
  Anthropic::Beta::BetaCitationContentBlockLocationParam,
17
- Anthropic::Beta::BetaCitationWebSearchResultLocationParam
17
+ Anthropic::Beta::BetaCitationWebSearchResultLocationParam,
18
+ Anthropic::Beta::BetaCitationSearchResultLocationParam
18
19
  )
19
20
  end
20
21
 
@@ -121,21 +121,30 @@ module Anthropic
121
121
  sig { returns(T.nilable(T.anything)) }
122
122
  attr_accessor :properties
123
123
 
124
+ sig { returns(T.nilable(T::Array[String])) }
125
+ attr_accessor :required
126
+
124
127
  # [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
125
128
  #
126
129
  # This defines the shape of the `input` that your tool accepts and that the model
127
130
  # will produce.
128
131
  sig do
129
- params(properties: T.nilable(T.anything), type: Symbol).returns(
130
- T.attached_class
131
- )
132
+ params(
133
+ properties: T.nilable(T.anything),
134
+ required: T.nilable(T::Array[String]),
135
+ type: Symbol
136
+ ).returns(T.attached_class)
132
137
  end
133
- def self.new(properties: nil, type: :object)
138
+ def self.new(properties: nil, required: nil, type: :object)
134
139
  end
135
140
 
136
141
  sig do
137
142
  override.returns(
138
- { type: Symbol, properties: T.nilable(T.anything) }
143
+ {
144
+ type: Symbol,
145
+ properties: T.nilable(T.anything),
146
+ required: T.nilable(T::Array[String])
147
+ }
139
148
  )
140
149
  end
141
150
  def to_hash
@@ -112,7 +112,8 @@ module Anthropic
112
112
  T.type_alias do
113
113
  T.any(
114
114
  Anthropic::Beta::BetaTextBlockParam,
115
- Anthropic::Beta::BetaImageBlockParam
115
+ Anthropic::Beta::BetaImageBlockParam,
116
+ Anthropic::Beta::BetaSearchResultBlockParam
116
117
  )
117
118
  end
118
119
 
@@ -0,0 +1,82 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaToolTextEditor20250728 = Beta::BetaToolTextEditor20250728
6
+
7
+ module Beta
8
+ class BetaToolTextEditor20250728 < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaToolTextEditor20250728,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ # Name of the tool.
18
+ #
19
+ # This is how the tool will be called by the model and in `tool_use` blocks.
20
+ sig { returns(Symbol) }
21
+ attr_accessor :name
22
+
23
+ sig { returns(Symbol) }
24
+ attr_accessor :type
25
+
26
+ # Create a cache control breakpoint at this content block.
27
+ sig { returns(T.nilable(Anthropic::Beta::BetaCacheControlEphemeral)) }
28
+ attr_reader :cache_control
29
+
30
+ sig do
31
+ params(
32
+ cache_control:
33
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral::OrHash)
34
+ ).void
35
+ end
36
+ attr_writer :cache_control
37
+
38
+ # Maximum number of characters to display when viewing a file. If not specified,
39
+ # defaults to displaying the full file.
40
+ sig { returns(T.nilable(Integer)) }
41
+ attr_accessor :max_characters
42
+
43
+ sig do
44
+ params(
45
+ cache_control:
46
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral::OrHash),
47
+ max_characters: T.nilable(Integer),
48
+ name: Symbol,
49
+ type: Symbol
50
+ ).returns(T.attached_class)
51
+ end
52
+ def self.new(
53
+ # Create a cache control breakpoint at this content block.
54
+ cache_control: nil,
55
+ # Maximum number of characters to display when viewing a file. If not specified,
56
+ # defaults to displaying the full file.
57
+ max_characters: nil,
58
+ # Name of the tool.
59
+ #
60
+ # This is how the tool will be called by the model and in `tool_use` blocks.
61
+ name: :str_replace_based_edit_tool,
62
+ type: :text_editor_20250728
63
+ )
64
+ end
65
+
66
+ sig do
67
+ override.returns(
68
+ {
69
+ name: Symbol,
70
+ type: Symbol,
71
+ cache_control:
72
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral),
73
+ max_characters: T.nilable(Integer)
74
+ }
75
+ )
76
+ end
77
+ def to_hash
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -12,15 +12,16 @@ module Anthropic
12
12
  T.type_alias do
13
13
  T.any(
14
14
  Anthropic::Beta::BetaTool,
15
- Anthropic::Beta::BetaToolComputerUse20241022,
16
15
  Anthropic::Beta::BetaToolBash20241022,
17
- Anthropic::Beta::BetaToolTextEditor20241022,
18
- Anthropic::Beta::BetaToolComputerUse20250124,
19
16
  Anthropic::Beta::BetaToolBash20250124,
17
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
18
+ Anthropic::Beta::BetaToolComputerUse20241022,
19
+ Anthropic::Beta::BetaToolComputerUse20250124,
20
+ Anthropic::Beta::BetaToolTextEditor20241022,
20
21
  Anthropic::Beta::BetaToolTextEditor20250124,
21
22
  Anthropic::Beta::BetaToolTextEditor20250429,
22
- Anthropic::Beta::BetaWebSearchTool20250305,
23
- Anthropic::Beta::BetaCodeExecutionTool20250522
23
+ Anthropic::Beta::BetaToolTextEditor20250728,
24
+ Anthropic::Beta::BetaWebSearchTool20250305
24
25
  )
25
26
  end
26
27
 
@@ -102,7 +102,7 @@ module Anthropic
102
102
  # the top-level `system` parameter — there is no `"system"` role for input
103
103
  # messages in the Messages API.
104
104
  #
105
- # There is a limit of 100000 messages in a single request.
105
+ # There is a limit of 100,000 messages in a single request.
106
106
  sig { returns(T::Array[Anthropic::Beta::BetaMessageParam]) }
107
107
  attr_accessor :messages
108
108
 
@@ -221,6 +221,12 @@ module Anthropic
221
221
  # those tools using the tool input generated by the model and then optionally
222
222
  # return results back to the model using `tool_result` content blocks.
223
223
  #
224
+ # There are two types of tools: **client tools** and **server tools**. The
225
+ # behavior described below applies to client tools. For
226
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
227
+ # see their individual documentation as each has its own behavior (e.g., the
228
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
229
+ #
224
230
  # Each tool definition includes:
225
231
  #
226
232
  # - `name`: Name of the tool.
@@ -289,15 +295,16 @@ module Anthropic
289
295
  T::Array[
290
296
  T.any(
291
297
  Anthropic::Beta::BetaTool,
292
- Anthropic::Beta::BetaToolComputerUse20241022,
293
298
  Anthropic::Beta::BetaToolBash20241022,
294
- Anthropic::Beta::BetaToolTextEditor20241022,
295
- Anthropic::Beta::BetaToolComputerUse20250124,
296
299
  Anthropic::Beta::BetaToolBash20250124,
300
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
301
+ Anthropic::Beta::BetaToolComputerUse20241022,
302
+ Anthropic::Beta::BetaToolComputerUse20250124,
303
+ Anthropic::Beta::BetaToolTextEditor20241022,
297
304
  Anthropic::Beta::BetaToolTextEditor20250124,
298
305
  Anthropic::Beta::BetaToolTextEditor20250429,
299
- Anthropic::Beta::BetaWebSearchTool20250305,
300
- Anthropic::Beta::BetaCodeExecutionTool20250522
306
+ Anthropic::Beta::BetaToolTextEditor20250728,
307
+ Anthropic::Beta::BetaWebSearchTool20250305
301
308
  )
302
309
  ]
303
310
  )
@@ -311,15 +318,16 @@ module Anthropic
311
318
  T::Array[
312
319
  T.any(
313
320
  Anthropic::Beta::BetaTool::OrHash,
314
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
315
321
  Anthropic::Beta::BetaToolBash20241022::OrHash,
316
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
317
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
318
322
  Anthropic::Beta::BetaToolBash20250124::OrHash,
323
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
324
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
325
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
326
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
319
327
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
320
328
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
321
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
322
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
329
+ Anthropic::Beta::BetaToolTextEditor20250728::OrHash,
330
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
323
331
  )
324
332
  ]
325
333
  ).void
@@ -369,15 +377,16 @@ module Anthropic
369
377
  T::Array[
370
378
  T.any(
371
379
  Anthropic::Beta::BetaTool::OrHash,
372
- Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
373
380
  Anthropic::Beta::BetaToolBash20241022::OrHash,
374
- Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
375
- Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
376
381
  Anthropic::Beta::BetaToolBash20250124::OrHash,
382
+ Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash,
383
+ Anthropic::Beta::BetaToolComputerUse20241022::OrHash,
384
+ Anthropic::Beta::BetaToolComputerUse20250124::OrHash,
385
+ Anthropic::Beta::BetaToolTextEditor20241022::OrHash,
377
386
  Anthropic::Beta::BetaToolTextEditor20250124::OrHash,
378
387
  Anthropic::Beta::BetaToolTextEditor20250429::OrHash,
379
- Anthropic::Beta::BetaWebSearchTool20250305::OrHash,
380
- Anthropic::Beta::BetaCodeExecutionTool20250522::OrHash
388
+ Anthropic::Beta::BetaToolTextEditor20250728::OrHash,
389
+ Anthropic::Beta::BetaWebSearchTool20250305::OrHash
381
390
  )
382
391
  ],
383
392
  betas: T::Array[T.any(String, Anthropic::AnthropicBeta::OrSymbol)],
@@ -472,7 +481,7 @@ module Anthropic
472
481
  # the top-level `system` parameter — there is no `"system"` role for input
473
482
  # messages in the Messages API.
474
483
  #
475
- # There is a limit of 100000 messages in a single request.
484
+ # There is a limit of 100,000 messages in a single request.
476
485
  messages:,
477
486
  # The model that will complete your prompt.\n\nSee
478
487
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -506,6 +515,12 @@ module Anthropic
506
515
  # those tools using the tool input generated by the model and then optionally
507
516
  # return results back to the model using `tool_result` content blocks.
508
517
  #
518
+ # There are two types of tools: **client tools** and **server tools**. The
519
+ # behavior described below applies to client tools. For
520
+ # [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
521
+ # see their individual documentation as each has its own behavior (e.g., the
522
+ # [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
523
+ #
509
524
  # Each tool definition includes:
510
525
  #
511
526
  # - `name`: Name of the tool.
@@ -600,15 +615,16 @@ module Anthropic
600
615
  T::Array[
601
616
  T.any(
602
617
  Anthropic::Beta::BetaTool,
603
- Anthropic::Beta::BetaToolComputerUse20241022,
604
618
  Anthropic::Beta::BetaToolBash20241022,
605
- Anthropic::Beta::BetaToolTextEditor20241022,
606
- Anthropic::Beta::BetaToolComputerUse20250124,
607
619
  Anthropic::Beta::BetaToolBash20250124,
620
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
621
+ Anthropic::Beta::BetaToolComputerUse20241022,
622
+ Anthropic::Beta::BetaToolComputerUse20250124,
623
+ Anthropic::Beta::BetaToolTextEditor20241022,
608
624
  Anthropic::Beta::BetaToolTextEditor20250124,
609
625
  Anthropic::Beta::BetaToolTextEditor20250429,
610
- Anthropic::Beta::BetaWebSearchTool20250305,
611
- Anthropic::Beta::BetaCodeExecutionTool20250522
626
+ Anthropic::Beta::BetaToolTextEditor20250728,
627
+ Anthropic::Beta::BetaWebSearchTool20250305
612
628
  )
613
629
  ],
614
630
  betas:
@@ -659,15 +675,16 @@ module Anthropic
659
675
  T.type_alias do
660
676
  T.any(
661
677
  Anthropic::Beta::BetaTool,
662
- Anthropic::Beta::BetaToolComputerUse20241022,
663
678
  Anthropic::Beta::BetaToolBash20241022,
664
- Anthropic::Beta::BetaToolTextEditor20241022,
665
- Anthropic::Beta::BetaToolComputerUse20250124,
666
679
  Anthropic::Beta::BetaToolBash20250124,
680
+ Anthropic::Beta::BetaCodeExecutionTool20250522,
681
+ Anthropic::Beta::BetaToolComputerUse20241022,
682
+ Anthropic::Beta::BetaToolComputerUse20250124,
683
+ Anthropic::Beta::BetaToolTextEditor20241022,
667
684
  Anthropic::Beta::BetaToolTextEditor20250124,
668
685
  Anthropic::Beta::BetaToolTextEditor20250429,
669
- Anthropic::Beta::BetaWebSearchTool20250305,
670
- Anthropic::Beta::BetaCodeExecutionTool20250522
686
+ Anthropic::Beta::BetaToolTextEditor20250728,
687
+ Anthropic::Beta::BetaWebSearchTool20250305
671
688
  )
672
689
  end
673
690