anthropic 1.9.0 → 1.10.1

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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/README.md +12 -12
  4. data/lib/anthropic/errors.rb +25 -11
  5. data/lib/anthropic/file_part.rb +10 -7
  6. data/lib/anthropic/helpers/bedrock/client.rb +8 -24
  7. data/lib/anthropic/internal/page.rb +1 -1
  8. data/lib/anthropic/internal/stream.rb +1 -0
  9. data/lib/anthropic/internal/transport/base_client.rb +16 -12
  10. data/lib/anthropic/internal/transport/pooled_net_requester.rb +7 -10
  11. data/lib/anthropic/internal/type/base_page.rb +1 -1
  12. data/lib/anthropic/internal/type/base_stream.rb +8 -17
  13. data/lib/anthropic/internal/type/file_input.rb +7 -4
  14. data/lib/anthropic/internal/util.rb +2 -1
  15. data/lib/anthropic/models/anthropic_beta.rb +6 -0
  16. data/lib/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rb +98 -0
  17. data/lib/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rb +38 -0
  18. data/lib/anthropic/models/beta/beta_context_management_config.rb +22 -0
  19. data/lib/anthropic/models/beta/beta_context_management_response.rb +23 -0
  20. data/lib/anthropic/models/beta/beta_count_tokens_context_management_response.rb +20 -0
  21. data/lib/anthropic/models/beta/beta_input_tokens_clear_at_least.rb +25 -0
  22. data/lib/anthropic/models/beta/beta_input_tokens_trigger.rb +25 -0
  23. data/lib/anthropic/models/beta/beta_memory_tool_20250818.rb +40 -0
  24. data/lib/anthropic/models/beta/beta_memory_tool_20250818_command.rb +30 -0
  25. data/lib/anthropic/models/beta/beta_memory_tool_20250818_create_command.rb +36 -0
  26. data/lib/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rb +28 -0
  27. data/lib/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rb +44 -0
  28. data/lib/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rb +36 -0
  29. data/lib/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rb +44 -0
  30. data/lib/anthropic/models/beta/beta_memory_tool_20250818_view_command.rb +36 -0
  31. data/lib/anthropic/models/beta/beta_message.rb +9 -1
  32. data/lib/anthropic/models/beta/beta_message_tokens_count.rb +13 -1
  33. data/lib/anthropic/models/beta/beta_raw_message_delta_event.rb +9 -1
  34. data/lib/anthropic/models/beta/beta_stop_reason.rb +1 -0
  35. data/lib/anthropic/models/beta/beta_tool_union.rb +3 -1
  36. data/lib/anthropic/models/beta/beta_tool_uses_keep.rb +25 -0
  37. data/lib/anthropic/models/beta/beta_tool_uses_trigger.rb +25 -0
  38. data/lib/anthropic/models/beta/message_count_tokens_params.rb +14 -4
  39. data/lib/anthropic/models/beta/message_create_params.rb +11 -3
  40. data/lib/anthropic/models/beta/messages/batch_create_params.rb +11 -3
  41. data/lib/anthropic/models/model.rb +10 -0
  42. data/lib/anthropic/models/stop_reason.rb +1 -0
  43. data/lib/anthropic/resources/beta/messages.rb +12 -6
  44. data/lib/anthropic/version.rb +1 -1
  45. data/lib/anthropic.rb +17 -0
  46. data/rbi/anthropic/errors.rbi +29 -2
  47. data/rbi/anthropic/file_part.rbi +1 -1
  48. data/rbi/anthropic/internal/transport/base_client.rbi +4 -5
  49. data/rbi/anthropic/internal/type/base_page.rbi +1 -1
  50. data/rbi/anthropic/internal/type/base_stream.rbi +15 -15
  51. data/rbi/anthropic/internal/util.rbi +1 -1
  52. data/rbi/anthropic/models/anthropic_beta.rbi +10 -0
  53. data/rbi/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rbi +183 -0
  54. data/rbi/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rbi +62 -0
  55. data/rbi/anthropic/models/beta/beta_context_management_config.rbi +56 -0
  56. data/rbi/anthropic/models/beta/beta_context_management_response.rbi +53 -0
  57. data/rbi/anthropic/models/beta/beta_count_tokens_context_management_response.rbi +35 -0
  58. data/rbi/anthropic/models/beta/beta_input_tokens_clear_at_least.rbi +33 -0
  59. data/rbi/anthropic/models/beta/beta_input_tokens_trigger.rbi +33 -0
  60. data/rbi/anthropic/models/beta/beta_memory_tool_20250818.rbi +72 -0
  61. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_command.rbi +33 -0
  62. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_create_command.rbi +53 -0
  63. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rbi +41 -0
  64. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rbi +69 -0
  65. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rbi +55 -0
  66. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rbi +64 -0
  67. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_view_command.rbi +59 -0
  68. data/rbi/anthropic/models/beta/beta_message.rbi +20 -0
  69. data/rbi/anthropic/models/beta/beta_message_tokens_count.rbi +40 -2
  70. data/rbi/anthropic/models/beta/beta_raw_message_delta_event.rbi +20 -0
  71. data/rbi/anthropic/models/beta/beta_stop_reason.rbi +5 -0
  72. data/rbi/anthropic/models/beta/beta_tool_union.rbi +1 -0
  73. data/rbi/anthropic/models/beta/beta_tool_uses_keep.rbi +33 -0
  74. data/rbi/anthropic/models/beta/beta_tool_uses_trigger.rbi +33 -0
  75. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +23 -0
  76. data/rbi/anthropic/models/beta/message_create_params.rbi +22 -0
  77. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +28 -0
  78. data/rbi/anthropic/models/model.rbi +8 -0
  79. data/rbi/anthropic/models/stop_reason.rbi +5 -0
  80. data/rbi/anthropic/resources/beta/messages.rbi +15 -0
  81. data/sig/anthropic/errors.rbs +7 -0
  82. data/sig/anthropic/file_part.rbs +1 -1
  83. data/sig/anthropic/internal/type/base_stream.rbs +4 -3
  84. data/sig/anthropic/models/anthropic_beta.rbs +4 -0
  85. data/sig/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rbs +77 -0
  86. data/sig/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rbs +34 -0
  87. data/sig/anthropic/models/beta/beta_context_management_config.rbs +26 -0
  88. data/sig/anthropic/models/beta/beta_context_management_response.rbs +24 -0
  89. data/sig/anthropic/models/beta/beta_count_tokens_context_management_response.rbs +18 -0
  90. data/sig/anthropic/models/beta/beta_input_tokens_clear_at_least.rbs +20 -0
  91. data/sig/anthropic/models/beta/beta_input_tokens_trigger.rbs +19 -0
  92. data/sig/anthropic/models/beta/beta_memory_tool_20250818.rbs +34 -0
  93. data/sig/anthropic/models/beta/beta_memory_tool_20250818_command.rbs +21 -0
  94. data/sig/anthropic/models/beta/beta_memory_tool_20250818_create_command.rbs +26 -0
  95. data/sig/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rbs +20 -0
  96. data/sig/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rbs +39 -0
  97. data/sig/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rbs +26 -0
  98. data/sig/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rbs +39 -0
  99. data/sig/anthropic/models/beta/beta_memory_tool_20250818_view_command.rbs +32 -0
  100. data/sig/anthropic/models/beta/beta_message.rbs +5 -0
  101. data/sig/anthropic/models/beta/beta_message_tokens_count.rbs +15 -3
  102. data/sig/anthropic/models/beta/beta_raw_message_delta_event.rbs +5 -0
  103. data/sig/anthropic/models/beta/beta_stop_reason.rbs +2 -0
  104. data/sig/anthropic/models/beta/beta_tool_union.rbs +1 -0
  105. data/sig/anthropic/models/beta/beta_tool_uses_keep.rbs +19 -0
  106. data/sig/anthropic/models/beta/beta_tool_uses_trigger.rbs +19 -0
  107. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +6 -0
  108. data/sig/anthropic/models/beta/message_create_params.rbs +5 -0
  109. data/sig/anthropic/models/beta/messages/batch_create_params.rbs +5 -0
  110. data/sig/anthropic/models/model.rbs +8 -0
  111. data/sig/anthropic/models/stop_reason.rbs +2 -0
  112. data/sig/anthropic/resources/beta/messages.rbs +3 -0
  113. metadata +53 -2
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaClearToolUses20250919Edit < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute type
8
+ #
9
+ # @return [Symbol, :clear_tool_uses_20250919]
10
+ required :type, const: :clear_tool_uses_20250919
11
+
12
+ # @!attribute clear_at_least
13
+ # Minimum number of tokens that must be cleared when triggered. Context will only
14
+ # be modified if at least this many tokens can be removed.
15
+ #
16
+ # @return [Anthropic::Models::Beta::BetaInputTokensClearAtLeast, nil]
17
+ optional :clear_at_least, -> { Anthropic::Beta::BetaInputTokensClearAtLeast }, nil?: true
18
+
19
+ # @!attribute clear_tool_inputs
20
+ # Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
21
+ #
22
+ # @return [Boolean, Array<String>, nil]
23
+ optional :clear_tool_inputs,
24
+ union: -> { Anthropic::Beta::BetaClearToolUses20250919Edit::ClearToolInputs },
25
+ nil?: true
26
+
27
+ # @!attribute exclude_tools
28
+ # Tool names whose uses are preserved from clearing
29
+ #
30
+ # @return [Array<String>, nil]
31
+ optional :exclude_tools, Anthropic::Internal::Type::ArrayOf[String], nil?: true
32
+
33
+ # @!attribute keep
34
+ # Number of tool uses to retain in the conversation
35
+ #
36
+ # @return [Anthropic::Models::Beta::BetaToolUsesKeep, nil]
37
+ optional :keep, -> { Anthropic::Beta::BetaToolUsesKeep }
38
+
39
+ # @!attribute trigger
40
+ # Condition that triggers the context management strategy
41
+ #
42
+ # @return [Anthropic::Models::Beta::BetaInputTokensTrigger, Anthropic::Models::Beta::BetaToolUsesTrigger, nil]
43
+ optional :trigger, union: -> { Anthropic::Beta::BetaClearToolUses20250919Edit::Trigger }
44
+
45
+ # @!method initialize(clear_at_least: nil, clear_tool_inputs: nil, exclude_tools: nil, keep: nil, trigger: nil, type: :clear_tool_uses_20250919)
46
+ # Some parameter documentations has been truncated, see
47
+ # {Anthropic::Models::Beta::BetaClearToolUses20250919Edit} for more details.
48
+ #
49
+ # @param clear_at_least [Anthropic::Models::Beta::BetaInputTokensClearAtLeast, nil] Minimum number of tokens that must be cleared when triggered. Context will only
50
+ #
51
+ # @param clear_tool_inputs [Boolean, Array<String>, nil] Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
52
+ #
53
+ # @param exclude_tools [Array<String>, nil] Tool names whose uses are preserved from clearing
54
+ #
55
+ # @param keep [Anthropic::Models::Beta::BetaToolUsesKeep] Number of tool uses to retain in the conversation
56
+ #
57
+ # @param trigger [Anthropic::Models::Beta::BetaInputTokensTrigger, Anthropic::Models::Beta::BetaToolUsesTrigger] Condition that triggers the context management strategy
58
+ #
59
+ # @param type [Symbol, :clear_tool_uses_20250919]
60
+
61
+ # Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
62
+ #
63
+ # @see Anthropic::Models::Beta::BetaClearToolUses20250919Edit#clear_tool_inputs
64
+ module ClearToolInputs
65
+ extend Anthropic::Internal::Type::Union
66
+
67
+ variant Anthropic::Internal::Type::Boolean
68
+
69
+ variant -> { Anthropic::Models::Beta::BetaClearToolUses20250919Edit::ClearToolInputs::StringArray }
70
+
71
+ # @!method self.variants
72
+ # @return [Array(Boolean, Array<String>)]
73
+
74
+ # @type [Anthropic::Internal::Type::Converter]
75
+ StringArray = Anthropic::Internal::Type::ArrayOf[String]
76
+ end
77
+
78
+ # Condition that triggers the context management strategy
79
+ #
80
+ # @see Anthropic::Models::Beta::BetaClearToolUses20250919Edit#trigger
81
+ module Trigger
82
+ extend Anthropic::Internal::Type::Union
83
+
84
+ discriminator :type
85
+
86
+ variant :input_tokens, -> { Anthropic::Beta::BetaInputTokensTrigger }
87
+
88
+ variant :tool_uses, -> { Anthropic::Beta::BetaToolUsesTrigger }
89
+
90
+ # @!method self.variants
91
+ # @return [Array(Anthropic::Models::Beta::BetaInputTokensTrigger, Anthropic::Models::Beta::BetaToolUsesTrigger)]
92
+ end
93
+ end
94
+ end
95
+
96
+ BetaClearToolUses20250919Edit = Beta::BetaClearToolUses20250919Edit
97
+ end
98
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaClearToolUses20250919EditResponse < 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_tool_uses
14
+ # Number of tool uses that were cleared.
15
+ #
16
+ # @return [Integer]
17
+ required :cleared_tool_uses, Integer
18
+
19
+ # @!attribute type
20
+ # The type of context management edit applied.
21
+ #
22
+ # @return [Symbol, :clear_tool_uses_20250919]
23
+ required :type, const: :clear_tool_uses_20250919
24
+
25
+ # @!method initialize(cleared_input_tokens:, cleared_tool_uses:, type: :clear_tool_uses_20250919)
26
+ # Results for clear_tool_uses_20250919 edit.
27
+ #
28
+ # @param cleared_input_tokens [Integer] Number of input tokens cleared by this edit.
29
+ #
30
+ # @param cleared_tool_uses [Integer] Number of tool uses that were cleared.
31
+ #
32
+ # @param type [Symbol, :clear_tool_uses_20250919] The type of context management edit applied.
33
+ end
34
+ end
35
+
36
+ BetaClearToolUses20250919EditResponse = Beta::BetaClearToolUses20250919EditResponse
37
+ end
38
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaContextManagementConfig < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute edits
8
+ # List of context management edits to apply
9
+ #
10
+ # @return [Array<Anthropic::Models::Beta::BetaClearToolUses20250919Edit>, nil]
11
+ optional :edits, -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaClearToolUses20250919Edit] }
12
+
13
+ # @!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
17
+ end
18
+ end
19
+
20
+ BetaContextManagementConfig = Beta::BetaContextManagementConfig
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaContextManagementResponse < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute applied_edits
8
+ # List of context management edits that were applied.
9
+ #
10
+ # @return [Array<Anthropic::Models::Beta::BetaClearToolUses20250919EditResponse>]
11
+ required :applied_edits,
12
+ -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaClearToolUses20250919EditResponse] }
13
+
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.
18
+ end
19
+ end
20
+
21
+ BetaContextManagementResponse = Beta::BetaContextManagementResponse
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaCountTokensContextManagementResponse < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute original_input_tokens
8
+ # The original token count before context management was applied
9
+ #
10
+ # @return [Integer]
11
+ required :original_input_tokens, Integer
12
+
13
+ # @!method initialize(original_input_tokens:)
14
+ # @param original_input_tokens [Integer] The original token count before context management was applied
15
+ end
16
+ end
17
+
18
+ BetaCountTokensContextManagementResponse = Beta::BetaCountTokensContextManagementResponse
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaInputTokensClearAtLeast < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute type
8
+ #
9
+ # @return [Symbol, :input_tokens]
10
+ required :type, const: :input_tokens
11
+
12
+ # @!attribute value
13
+ #
14
+ # @return [Integer]
15
+ required :value, Integer
16
+
17
+ # @!method initialize(value:, type: :input_tokens)
18
+ # @param value [Integer]
19
+ # @param type [Symbol, :input_tokens]
20
+ end
21
+ end
22
+
23
+ BetaInputTokensClearAtLeast = Beta::BetaInputTokensClearAtLeast
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaInputTokensTrigger < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute type
8
+ #
9
+ # @return [Symbol, :input_tokens]
10
+ required :type, const: :input_tokens
11
+
12
+ # @!attribute value
13
+ #
14
+ # @return [Integer]
15
+ required :value, Integer
16
+
17
+ # @!method initialize(value:, type: :input_tokens)
18
+ # @param value [Integer]
19
+ # @param type [Symbol, :input_tokens]
20
+ end
21
+ end
22
+
23
+ BetaInputTokensTrigger = Beta::BetaInputTokensTrigger
24
+ end
25
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaMemoryTool20250818 < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute name
8
+ # Name of the tool.
9
+ #
10
+ # This is how the tool will be called by the model and in `tool_use` blocks.
11
+ #
12
+ # @return [Symbol, :memory]
13
+ required :name, const: :memory
14
+
15
+ # @!attribute type
16
+ #
17
+ # @return [Symbol, :memory_20250818]
18
+ required :type, const: :memory_20250818
19
+
20
+ # @!attribute cache_control
21
+ # Create a cache control breakpoint at this content block.
22
+ #
23
+ # @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
24
+ optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
25
+
26
+ # @!method initialize(cache_control: nil, name: :memory, type: :memory_20250818)
27
+ # Some parameter documentations has been truncated, see
28
+ # {Anthropic::Models::Beta::BetaMemoryTool20250818} for more details.
29
+ #
30
+ # @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
31
+ #
32
+ # @param name [Symbol, :memory] Name of the tool.
33
+ #
34
+ # @param type [Symbol, :memory_20250818]
35
+ end
36
+ end
37
+
38
+ BetaMemoryTool20250818 = Beta::BetaMemoryTool20250818
39
+ end
40
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ module BetaMemoryTool20250818Command
7
+ extend Anthropic::Internal::Type::Union
8
+
9
+ discriminator :command
10
+
11
+ variant :view, -> { Anthropic::Beta::BetaMemoryTool20250818ViewCommand }
12
+
13
+ variant :create, -> { Anthropic::Beta::BetaMemoryTool20250818CreateCommand }
14
+
15
+ variant :str_replace, -> { Anthropic::Beta::BetaMemoryTool20250818StrReplaceCommand }
16
+
17
+ variant :insert, -> { Anthropic::Beta::BetaMemoryTool20250818InsertCommand }
18
+
19
+ variant :delete, -> { Anthropic::Beta::BetaMemoryTool20250818DeleteCommand }
20
+
21
+ variant :rename, -> { Anthropic::Beta::BetaMemoryTool20250818RenameCommand }
22
+
23
+ # @!method self.variants
24
+ # @return [Array(Anthropic::Models::Beta::BetaMemoryTool20250818ViewCommand, Anthropic::Models::Beta::BetaMemoryTool20250818CreateCommand, Anthropic::Models::Beta::BetaMemoryTool20250818StrReplaceCommand, Anthropic::Models::Beta::BetaMemoryTool20250818InsertCommand, Anthropic::Models::Beta::BetaMemoryTool20250818DeleteCommand, Anthropic::Models::Beta::BetaMemoryTool20250818RenameCommand)]
25
+ end
26
+ end
27
+
28
+ BetaMemoryTool20250818Command = Beta::BetaMemoryTool20250818Command
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaMemoryTool20250818CreateCommand < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute command
8
+ # Command type identifier
9
+ #
10
+ # @return [Symbol, :create]
11
+ required :command, const: :create
12
+
13
+ # @!attribute file_text
14
+ # Content to write to the file
15
+ #
16
+ # @return [String]
17
+ required :file_text, String
18
+
19
+ # @!attribute path
20
+ # Path where the file should be created
21
+ #
22
+ # @return [String]
23
+ required :path, String
24
+
25
+ # @!method initialize(file_text:, path:, command: :create)
26
+ # @param file_text [String] Content to write to the file
27
+ #
28
+ # @param path [String] Path where the file should be created
29
+ #
30
+ # @param command [Symbol, :create] Command type identifier
31
+ end
32
+ end
33
+
34
+ BetaMemoryTool20250818CreateCommand = Beta::BetaMemoryTool20250818CreateCommand
35
+ end
36
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaMemoryTool20250818DeleteCommand < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute command
8
+ # Command type identifier
9
+ #
10
+ # @return [Symbol, :delete]
11
+ required :command, const: :delete
12
+
13
+ # @!attribute path
14
+ # Path to the file or directory to delete
15
+ #
16
+ # @return [String]
17
+ required :path, String
18
+
19
+ # @!method initialize(path:, command: :delete)
20
+ # @param path [String] Path to the file or directory to delete
21
+ #
22
+ # @param command [Symbol, :delete] Command type identifier
23
+ end
24
+ end
25
+
26
+ BetaMemoryTool20250818DeleteCommand = Beta::BetaMemoryTool20250818DeleteCommand
27
+ end
28
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaMemoryTool20250818InsertCommand < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute command
8
+ # Command type identifier
9
+ #
10
+ # @return [Symbol, :insert]
11
+ required :command, const: :insert
12
+
13
+ # @!attribute insert_line
14
+ # Line number where text should be inserted
15
+ #
16
+ # @return [Integer]
17
+ required :insert_line, Integer
18
+
19
+ # @!attribute insert_text
20
+ # Text to insert at the specified line
21
+ #
22
+ # @return [String]
23
+ required :insert_text, String
24
+
25
+ # @!attribute path
26
+ # Path to the file where text should be inserted
27
+ #
28
+ # @return [String]
29
+ required :path, String
30
+
31
+ # @!method initialize(insert_line:, insert_text:, path:, command: :insert)
32
+ # @param insert_line [Integer] Line number where text should be inserted
33
+ #
34
+ # @param insert_text [String] Text to insert at the specified line
35
+ #
36
+ # @param path [String] Path to the file where text should be inserted
37
+ #
38
+ # @param command [Symbol, :insert] Command type identifier
39
+ end
40
+ end
41
+
42
+ BetaMemoryTool20250818InsertCommand = Beta::BetaMemoryTool20250818InsertCommand
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaMemoryTool20250818RenameCommand < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute command
8
+ # Command type identifier
9
+ #
10
+ # @return [Symbol, :rename]
11
+ required :command, const: :rename
12
+
13
+ # @!attribute new_path
14
+ # New path for the file or directory
15
+ #
16
+ # @return [String]
17
+ required :new_path, String
18
+
19
+ # @!attribute old_path
20
+ # Current path of the file or directory
21
+ #
22
+ # @return [String]
23
+ required :old_path, String
24
+
25
+ # @!method initialize(new_path:, old_path:, command: :rename)
26
+ # @param new_path [String] New path for the file or directory
27
+ #
28
+ # @param old_path [String] Current path of the file or directory
29
+ #
30
+ # @param command [Symbol, :rename] Command type identifier
31
+ end
32
+ end
33
+
34
+ BetaMemoryTool20250818RenameCommand = Beta::BetaMemoryTool20250818RenameCommand
35
+ end
36
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaMemoryTool20250818StrReplaceCommand < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute command
8
+ # Command type identifier
9
+ #
10
+ # @return [Symbol, :str_replace]
11
+ required :command, const: :str_replace
12
+
13
+ # @!attribute new_str
14
+ # Text to replace with
15
+ #
16
+ # @return [String]
17
+ required :new_str, String
18
+
19
+ # @!attribute old_str
20
+ # Text to search for and replace
21
+ #
22
+ # @return [String]
23
+ required :old_str, String
24
+
25
+ # @!attribute path
26
+ # Path to the file where text should be replaced
27
+ #
28
+ # @return [String]
29
+ required :path, String
30
+
31
+ # @!method initialize(new_str:, old_str:, path:, command: :str_replace)
32
+ # @param new_str [String] Text to replace with
33
+ #
34
+ # @param old_str [String] Text to search for and replace
35
+ #
36
+ # @param path [String] Path to the file where text should be replaced
37
+ #
38
+ # @param command [Symbol, :str_replace] Command type identifier
39
+ end
40
+ end
41
+
42
+ BetaMemoryTool20250818StrReplaceCommand = Beta::BetaMemoryTool20250818StrReplaceCommand
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaMemoryTool20250818ViewCommand < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute command
8
+ # Command type identifier
9
+ #
10
+ # @return [Symbol, :view]
11
+ required :command, const: :view
12
+
13
+ # @!attribute path
14
+ # Path to directory or file to view
15
+ #
16
+ # @return [String]
17
+ required :path, String
18
+
19
+ # @!attribute view_range
20
+ # Optional line range for viewing specific lines
21
+ #
22
+ # @return [Array<Integer>, nil]
23
+ optional :view_range, Anthropic::Internal::Type::ArrayOf[Integer]
24
+
25
+ # @!method initialize(path:, view_range: nil, command: :view)
26
+ # @param path [String] Path to directory or file to view
27
+ #
28
+ # @param view_range [Array<Integer>] Optional line range for viewing specific lines
29
+ #
30
+ # @param command [Symbol, :view] Command type identifier
31
+ end
32
+ end
33
+
34
+ BetaMemoryTool20250818ViewCommand = Beta::BetaMemoryTool20250818ViewCommand
35
+ end
36
+ end
@@ -59,6 +59,12 @@ module Anthropic
59
59
  # @return [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>]
60
60
  required :content, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaContentBlock] }
61
61
 
62
+ # @!attribute context_management
63
+ # Information about context management operations applied during the request.
64
+ #
65
+ # @return [Anthropic::Models::Beta::BetaContextManagementResponse, nil]
66
+ required :context_management, -> { Anthropic::Beta::BetaContextManagementResponse }, nil?: true
67
+
62
68
  # @!attribute model
63
69
  # The model that will complete your prompt.\n\nSee
64
70
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -132,7 +138,7 @@ module Anthropic
132
138
  # @return [Anthropic::Models::Beta::BetaUsage]
133
139
  required :usage, -> { Anthropic::Beta::BetaUsage }
134
140
 
135
- # @!method initialize(id:, container:, content:, model:, stop_reason:, stop_sequence:, usage:, role: :assistant, type: :message)
141
+ # @!method initialize(id:, container:, content:, context_management:, model:, stop_reason:, stop_sequence:, usage:, role: :assistant, type: :message)
136
142
  # Some parameter documentations has been truncated, see
137
143
  # {Anthropic::Models::Beta::BetaMessage} for more details.
138
144
  #
@@ -142,6 +148,8 @@ module Anthropic
142
148
  #
143
149
  # @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.
144
150
  #
151
+ # @param context_management [Anthropic::Models::Beta::BetaContextManagementResponse, nil] Information about context management operations applied during the request.
152
+ #
145
153
  # @param model [Symbol, String, Anthropic::Models::Model] The model that will complete your prompt.\n\nSee [models](https://docs.anthropic
146
154
  #
147
155
  # @param stop_reason [Symbol, Anthropic::Models::Beta::BetaStopReason, nil] The reason that we stopped.
@@ -5,6 +5,16 @@ module Anthropic
5
5
  module Beta
6
6
  # @see Anthropic::Resources::Beta::Messages#count_tokens
7
7
  class BetaMessageTokensCount < Anthropic::Internal::Type::BaseModel
8
+ # @!attribute context_management
9
+ # Information about context management applied to the message.
10
+ #
11
+ # @return [Anthropic::Models::Beta::BetaCountTokensContextManagementResponse, nil]
12
+ required :context_management,
13
+ -> {
14
+ Anthropic::Beta::BetaCountTokensContextManagementResponse
15
+ },
16
+ nil?: true
17
+
8
18
  # @!attribute input_tokens
9
19
  # The total number of tokens across the provided list of messages, system prompt,
10
20
  # and tools.
@@ -12,10 +22,12 @@ module Anthropic
12
22
  # @return [Integer]
13
23
  required :input_tokens, Integer
14
24
 
15
- # @!method initialize(input_tokens:)
25
+ # @!method initialize(context_management:, input_tokens:)
16
26
  # Some parameter documentations has been truncated, see
17
27
  # {Anthropic::Models::Beta::BetaMessageTokensCount} for more details.
18
28
  #
29
+ # @param context_management [Anthropic::Models::Beta::BetaCountTokensContextManagementResponse, nil] Information about context management applied to the message.
30
+ #
19
31
  # @param input_tokens [Integer] The total number of tokens across the provided list of messages, system prompt,
20
32
  end
21
33
  end
@@ -4,6 +4,12 @@ module Anthropic
4
4
  module Models
5
5
  module Beta
6
6
  class BetaRawMessageDeltaEvent < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute context_management
8
+ # Information about context management operations applied during the request.
9
+ #
10
+ # @return [Anthropic::Models::Beta::BetaContextManagementResponse, nil]
11
+ required :context_management, -> { Anthropic::Beta::BetaContextManagementResponse }, nil?: true
12
+
7
13
  # @!attribute delta
8
14
  #
9
15
  # @return [Anthropic::Models::Beta::BetaRawMessageDeltaEvent::Delta]
@@ -34,10 +40,12 @@ module Anthropic
34
40
  # @return [Anthropic::Models::Beta::BetaMessageDeltaUsage]
35
41
  required :usage, -> { Anthropic::Beta::BetaMessageDeltaUsage }
36
42
 
37
- # @!method initialize(delta:, usage:, type: :message_delta)
43
+ # @!method initialize(context_management:, delta:, usage:, type: :message_delta)
38
44
  # Some parameter documentations has been truncated, see
39
45
  # {Anthropic::Models::Beta::BetaRawMessageDeltaEvent} for more details.
40
46
  #
47
+ # @param context_management [Anthropic::Models::Beta::BetaContextManagementResponse, nil] Information about context management operations applied during the request.
48
+ #
41
49
  # @param delta [Anthropic::Models::Beta::BetaRawMessageDeltaEvent::Delta]
42
50
  #
43
51
  # @param usage [Anthropic::Models::Beta::BetaMessageDeltaUsage] Billing and rate-limit usage.
@@ -12,6 +12,7 @@ module Anthropic
12
12
  TOOL_USE = :tool_use
13
13
  PAUSE_TURN = :pause_turn
14
14
  REFUSAL = :refusal
15
+ MODEL_CONTEXT_WINDOW_EXCEEDED = :model_context_window_exceeded
15
16
 
16
17
  # @!method self.values
17
18
  # @return [Array<Symbol>]