anthropic 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/README.md +12 -12
  4. data/lib/anthropic/errors.rb +25 -11
  5. data/lib/anthropic/internal/page.rb +1 -1
  6. data/lib/anthropic/internal/stream.rb +1 -0
  7. data/lib/anthropic/internal/transport/base_client.rb +11 -7
  8. data/lib/anthropic/internal/type/base_page.rb +1 -1
  9. data/lib/anthropic/internal/type/base_stream.rb +9 -1
  10. data/lib/anthropic/internal/util.rb +2 -1
  11. data/lib/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rb +98 -0
  12. data/lib/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rb +38 -0
  13. data/lib/anthropic/models/beta/beta_context_management_config.rb +22 -0
  14. data/lib/anthropic/models/beta/beta_context_management_response.rb +23 -0
  15. data/lib/anthropic/models/beta/beta_count_tokens_context_management_response.rb +20 -0
  16. data/lib/anthropic/models/beta/beta_input_tokens_clear_at_least.rb +25 -0
  17. data/lib/anthropic/models/beta/beta_input_tokens_trigger.rb +25 -0
  18. data/lib/anthropic/models/beta/beta_memory_tool_20250818.rb +40 -0
  19. data/lib/anthropic/models/beta/beta_memory_tool_20250818_command.rb +30 -0
  20. data/lib/anthropic/models/beta/beta_memory_tool_20250818_create_command.rb +36 -0
  21. data/lib/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rb +28 -0
  22. data/lib/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rb +44 -0
  23. data/lib/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rb +36 -0
  24. data/lib/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rb +44 -0
  25. data/lib/anthropic/models/beta/beta_memory_tool_20250818_view_command.rb +36 -0
  26. data/lib/anthropic/models/beta/beta_message.rb +9 -1
  27. data/lib/anthropic/models/beta/beta_message_tokens_count.rb +13 -1
  28. data/lib/anthropic/models/beta/beta_raw_message_delta_event.rb +9 -1
  29. data/lib/anthropic/models/beta/beta_stop_reason.rb +1 -0
  30. data/lib/anthropic/models/beta/beta_tool_union.rb +3 -1
  31. data/lib/anthropic/models/beta/beta_tool_uses_keep.rb +25 -0
  32. data/lib/anthropic/models/beta/beta_tool_uses_trigger.rb +25 -0
  33. data/lib/anthropic/models/beta/message_count_tokens_params.rb +14 -4
  34. data/lib/anthropic/models/beta/message_create_params.rb +11 -3
  35. data/lib/anthropic/models/beta/messages/batch_create_params.rb +11 -3
  36. data/lib/anthropic/models/model.rb +10 -0
  37. data/lib/anthropic/models/stop_reason.rb +1 -0
  38. data/lib/anthropic/resources/beta/messages.rb +12 -6
  39. data/lib/anthropic/version.rb +1 -1
  40. data/lib/anthropic.rb +17 -0
  41. data/rbi/anthropic/errors.rbi +29 -2
  42. data/rbi/anthropic/internal/transport/base_client.rbi +4 -5
  43. data/rbi/anthropic/internal/type/base_page.rbi +1 -1
  44. data/rbi/anthropic/internal/type/base_stream.rbi +16 -1
  45. data/rbi/anthropic/internal/util.rbi +1 -1
  46. data/rbi/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rbi +183 -0
  47. data/rbi/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rbi +62 -0
  48. data/rbi/anthropic/models/beta/beta_context_management_config.rbi +56 -0
  49. data/rbi/anthropic/models/beta/beta_context_management_response.rbi +53 -0
  50. data/rbi/anthropic/models/beta/beta_count_tokens_context_management_response.rbi +35 -0
  51. data/rbi/anthropic/models/beta/beta_input_tokens_clear_at_least.rbi +33 -0
  52. data/rbi/anthropic/models/beta/beta_input_tokens_trigger.rbi +33 -0
  53. data/rbi/anthropic/models/beta/beta_memory_tool_20250818.rbi +72 -0
  54. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_command.rbi +33 -0
  55. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_create_command.rbi +53 -0
  56. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rbi +41 -0
  57. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rbi +69 -0
  58. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rbi +55 -0
  59. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rbi +64 -0
  60. data/rbi/anthropic/models/beta/beta_memory_tool_20250818_view_command.rbi +59 -0
  61. data/rbi/anthropic/models/beta/beta_message.rbi +20 -0
  62. data/rbi/anthropic/models/beta/beta_message_tokens_count.rbi +40 -2
  63. data/rbi/anthropic/models/beta/beta_raw_message_delta_event.rbi +20 -0
  64. data/rbi/anthropic/models/beta/beta_stop_reason.rbi +5 -0
  65. data/rbi/anthropic/models/beta/beta_tool_union.rbi +1 -0
  66. data/rbi/anthropic/models/beta/beta_tool_uses_keep.rbi +33 -0
  67. data/rbi/anthropic/models/beta/beta_tool_uses_trigger.rbi +33 -0
  68. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +23 -0
  69. data/rbi/anthropic/models/beta/message_create_params.rbi +22 -0
  70. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +28 -0
  71. data/rbi/anthropic/models/model.rbi +8 -0
  72. data/rbi/anthropic/models/stop_reason.rbi +5 -0
  73. data/rbi/anthropic/resources/beta/messages.rbi +15 -0
  74. data/sig/anthropic/errors.rbs +7 -0
  75. data/sig/anthropic/internal/type/base_stream.rbs +5 -0
  76. data/sig/anthropic/models/beta/beta_clear_tool_uses_20250919_edit.rbs +77 -0
  77. data/sig/anthropic/models/beta/beta_clear_tool_uses_20250919_edit_response.rbs +34 -0
  78. data/sig/anthropic/models/beta/beta_context_management_config.rbs +26 -0
  79. data/sig/anthropic/models/beta/beta_context_management_response.rbs +24 -0
  80. data/sig/anthropic/models/beta/beta_count_tokens_context_management_response.rbs +18 -0
  81. data/sig/anthropic/models/beta/beta_input_tokens_clear_at_least.rbs +20 -0
  82. data/sig/anthropic/models/beta/beta_input_tokens_trigger.rbs +19 -0
  83. data/sig/anthropic/models/beta/beta_memory_tool_20250818.rbs +34 -0
  84. data/sig/anthropic/models/beta/beta_memory_tool_20250818_command.rbs +21 -0
  85. data/sig/anthropic/models/beta/beta_memory_tool_20250818_create_command.rbs +26 -0
  86. data/sig/anthropic/models/beta/beta_memory_tool_20250818_delete_command.rbs +20 -0
  87. data/sig/anthropic/models/beta/beta_memory_tool_20250818_insert_command.rbs +39 -0
  88. data/sig/anthropic/models/beta/beta_memory_tool_20250818_rename_command.rbs +26 -0
  89. data/sig/anthropic/models/beta/beta_memory_tool_20250818_str_replace_command.rbs +39 -0
  90. data/sig/anthropic/models/beta/beta_memory_tool_20250818_view_command.rbs +32 -0
  91. data/sig/anthropic/models/beta/beta_message.rbs +5 -0
  92. data/sig/anthropic/models/beta/beta_message_tokens_count.rbs +15 -3
  93. data/sig/anthropic/models/beta/beta_raw_message_delta_event.rbs +5 -0
  94. data/sig/anthropic/models/beta/beta_stop_reason.rbs +2 -0
  95. data/sig/anthropic/models/beta/beta_tool_union.rbs +1 -0
  96. data/sig/anthropic/models/beta/beta_tool_uses_keep.rbs +19 -0
  97. data/sig/anthropic/models/beta/beta_tool_uses_trigger.rbs +19 -0
  98. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +6 -0
  99. data/sig/anthropic/models/beta/message_create_params.rbs +5 -0
  100. data/sig/anthropic/models/beta/messages/batch_create_params.rbs +5 -0
  101. data/sig/anthropic/models/model.rbs +8 -0
  102. data/sig/anthropic/models/stop_reason.rbs +2 -0
  103. data/sig/anthropic/resources/beta/messages.rbs +3 -0
  104. metadata +53 -2
@@ -0,0 +1,53 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaContextManagementResponse = Beta::BetaContextManagementResponse
6
+
7
+ module Beta
8
+ class BetaContextManagementResponse < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaContextManagementResponse,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ # List of context management edits that were applied.
18
+ sig do
19
+ returns(
20
+ T::Array[Anthropic::Beta::BetaClearToolUses20250919EditResponse]
21
+ )
22
+ end
23
+ attr_accessor :applied_edits
24
+
25
+ # Information about context management operations applied during the request.
26
+ sig do
27
+ params(
28
+ applied_edits:
29
+ T::Array[
30
+ Anthropic::Beta::BetaClearToolUses20250919EditResponse::OrHash
31
+ ]
32
+ ).returns(T.attached_class)
33
+ end
34
+ def self.new(
35
+ # List of context management edits that were applied.
36
+ applied_edits:
37
+ )
38
+ end
39
+
40
+ sig do
41
+ override.returns(
42
+ {
43
+ applied_edits:
44
+ T::Array[Anthropic::Beta::BetaClearToolUses20250919EditResponse]
45
+ }
46
+ )
47
+ end
48
+ def to_hash
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,35 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaCountTokensContextManagementResponse =
6
+ Beta::BetaCountTokensContextManagementResponse
7
+
8
+ module Beta
9
+ class BetaCountTokensContextManagementResponse < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaCountTokensContextManagementResponse,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ # The original token count before context management was applied
19
+ sig { returns(Integer) }
20
+ attr_accessor :original_input_tokens
21
+
22
+ sig { params(original_input_tokens: Integer).returns(T.attached_class) }
23
+ def self.new(
24
+ # The original token count before context management was applied
25
+ original_input_tokens:
26
+ )
27
+ end
28
+
29
+ sig { override.returns({ original_input_tokens: Integer }) }
30
+ def to_hash
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaInputTokensClearAtLeast = Beta::BetaInputTokensClearAtLeast
6
+
7
+ module Beta
8
+ class BetaInputTokensClearAtLeast < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaInputTokensClearAtLeast,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(Symbol) }
18
+ attr_accessor :type
19
+
20
+ sig { returns(Integer) }
21
+ attr_accessor :value
22
+
23
+ sig { params(value: Integer, type: Symbol).returns(T.attached_class) }
24
+ def self.new(value:, type: :input_tokens)
25
+ end
26
+
27
+ sig { override.returns({ type: Symbol, value: Integer }) }
28
+ def to_hash
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaInputTokensTrigger = Beta::BetaInputTokensTrigger
6
+
7
+ module Beta
8
+ class BetaInputTokensTrigger < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaInputTokensTrigger,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(Symbol) }
18
+ attr_accessor :type
19
+
20
+ sig { returns(Integer) }
21
+ attr_accessor :value
22
+
23
+ sig { params(value: Integer, type: Symbol).returns(T.attached_class) }
24
+ def self.new(value:, type: :input_tokens)
25
+ end
26
+
27
+ sig { override.returns({ type: Symbol, value: Integer }) }
28
+ def to_hash
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,72 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaMemoryTool20250818 = Beta::BetaMemoryTool20250818
6
+
7
+ module Beta
8
+ class BetaMemoryTool20250818 < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaMemoryTool20250818,
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
+ sig do
39
+ params(
40
+ cache_control:
41
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral::OrHash),
42
+ name: Symbol,
43
+ type: Symbol
44
+ ).returns(T.attached_class)
45
+ end
46
+ def self.new(
47
+ # Create a cache control breakpoint at this content block.
48
+ cache_control: nil,
49
+ # Name of the tool.
50
+ #
51
+ # This is how the tool will be called by the model and in `tool_use` blocks.
52
+ name: :memory,
53
+ type: :memory_20250818
54
+ )
55
+ end
56
+
57
+ sig do
58
+ override.returns(
59
+ {
60
+ name: Symbol,
61
+ type: Symbol,
62
+ cache_control:
63
+ T.nilable(Anthropic::Beta::BetaCacheControlEphemeral)
64
+ }
65
+ )
66
+ end
67
+ def to_hash
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,33 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaMemoryTool20250818Command = Beta::BetaMemoryTool20250818Command
6
+
7
+ module Beta
8
+ module BetaMemoryTool20250818Command
9
+ extend Anthropic::Internal::Type::Union
10
+
11
+ Variants =
12
+ T.type_alias do
13
+ T.any(
14
+ Anthropic::Beta::BetaMemoryTool20250818ViewCommand,
15
+ Anthropic::Beta::BetaMemoryTool20250818CreateCommand,
16
+ Anthropic::Beta::BetaMemoryTool20250818StrReplaceCommand,
17
+ Anthropic::Beta::BetaMemoryTool20250818InsertCommand,
18
+ Anthropic::Beta::BetaMemoryTool20250818DeleteCommand,
19
+ Anthropic::Beta::BetaMemoryTool20250818RenameCommand
20
+ )
21
+ end
22
+
23
+ sig do
24
+ override.returns(
25
+ T::Array[Anthropic::Beta::BetaMemoryTool20250818Command::Variants]
26
+ )
27
+ end
28
+ def self.variants
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,53 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaMemoryTool20250818CreateCommand =
6
+ Beta::BetaMemoryTool20250818CreateCommand
7
+
8
+ module Beta
9
+ class BetaMemoryTool20250818CreateCommand < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaMemoryTool20250818CreateCommand,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ # Command type identifier
19
+ sig { returns(Symbol) }
20
+ attr_accessor :command
21
+
22
+ # Content to write to the file
23
+ sig { returns(String) }
24
+ attr_accessor :file_text
25
+
26
+ # Path where the file should be created
27
+ sig { returns(String) }
28
+ attr_accessor :path
29
+
30
+ sig do
31
+ params(file_text: String, path: String, command: Symbol).returns(
32
+ T.attached_class
33
+ )
34
+ end
35
+ def self.new(
36
+ # Content to write to the file
37
+ file_text:,
38
+ # Path where the file should be created
39
+ path:,
40
+ # Command type identifier
41
+ command: :create
42
+ )
43
+ end
44
+
45
+ sig do
46
+ override.returns({ command: Symbol, file_text: String, path: String })
47
+ end
48
+ def to_hash
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,41 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaMemoryTool20250818DeleteCommand =
6
+ Beta::BetaMemoryTool20250818DeleteCommand
7
+
8
+ module Beta
9
+ class BetaMemoryTool20250818DeleteCommand < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaMemoryTool20250818DeleteCommand,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ # Command type identifier
19
+ sig { returns(Symbol) }
20
+ attr_accessor :command
21
+
22
+ # Path to the file or directory to delete
23
+ sig { returns(String) }
24
+ attr_accessor :path
25
+
26
+ sig { params(path: String, command: Symbol).returns(T.attached_class) }
27
+ def self.new(
28
+ # Path to the file or directory to delete
29
+ path:,
30
+ # Command type identifier
31
+ command: :delete
32
+ )
33
+ end
34
+
35
+ sig { override.returns({ command: Symbol, path: String }) }
36
+ def to_hash
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,69 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaMemoryTool20250818InsertCommand =
6
+ Beta::BetaMemoryTool20250818InsertCommand
7
+
8
+ module Beta
9
+ class BetaMemoryTool20250818InsertCommand < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaMemoryTool20250818InsertCommand,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ # Command type identifier
19
+ sig { returns(Symbol) }
20
+ attr_accessor :command
21
+
22
+ # Line number where text should be inserted
23
+ sig { returns(Integer) }
24
+ attr_accessor :insert_line
25
+
26
+ # Text to insert at the specified line
27
+ sig { returns(String) }
28
+ attr_accessor :insert_text
29
+
30
+ # Path to the file where text should be inserted
31
+ sig { returns(String) }
32
+ attr_accessor :path
33
+
34
+ sig do
35
+ params(
36
+ insert_line: Integer,
37
+ insert_text: String,
38
+ path: String,
39
+ command: Symbol
40
+ ).returns(T.attached_class)
41
+ end
42
+ def self.new(
43
+ # Line number where text should be inserted
44
+ insert_line:,
45
+ # Text to insert at the specified line
46
+ insert_text:,
47
+ # Path to the file where text should be inserted
48
+ path:,
49
+ # Command type identifier
50
+ command: :insert
51
+ )
52
+ end
53
+
54
+ sig do
55
+ override.returns(
56
+ {
57
+ command: Symbol,
58
+ insert_line: Integer,
59
+ insert_text: String,
60
+ path: String
61
+ }
62
+ )
63
+ end
64
+ def to_hash
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,55 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaMemoryTool20250818RenameCommand =
6
+ Beta::BetaMemoryTool20250818RenameCommand
7
+
8
+ module Beta
9
+ class BetaMemoryTool20250818RenameCommand < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaMemoryTool20250818RenameCommand,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ # Command type identifier
19
+ sig { returns(Symbol) }
20
+ attr_accessor :command
21
+
22
+ # New path for the file or directory
23
+ sig { returns(String) }
24
+ attr_accessor :new_path
25
+
26
+ # Current path of the file or directory
27
+ sig { returns(String) }
28
+ attr_accessor :old_path
29
+
30
+ sig do
31
+ params(new_path: String, old_path: String, command: Symbol).returns(
32
+ T.attached_class
33
+ )
34
+ end
35
+ def self.new(
36
+ # New path for the file or directory
37
+ new_path:,
38
+ # Current path of the file or directory
39
+ old_path:,
40
+ # Command type identifier
41
+ command: :rename
42
+ )
43
+ end
44
+
45
+ sig do
46
+ override.returns(
47
+ { command: Symbol, new_path: String, old_path: String }
48
+ )
49
+ end
50
+ def to_hash
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,64 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaMemoryTool20250818StrReplaceCommand =
6
+ Beta::BetaMemoryTool20250818StrReplaceCommand
7
+
8
+ module Beta
9
+ class BetaMemoryTool20250818StrReplaceCommand < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaMemoryTool20250818StrReplaceCommand,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ # Command type identifier
19
+ sig { returns(Symbol) }
20
+ attr_accessor :command
21
+
22
+ # Text to replace with
23
+ sig { returns(String) }
24
+ attr_accessor :new_str
25
+
26
+ # Text to search for and replace
27
+ sig { returns(String) }
28
+ attr_accessor :old_str
29
+
30
+ # Path to the file where text should be replaced
31
+ sig { returns(String) }
32
+ attr_accessor :path
33
+
34
+ sig do
35
+ params(
36
+ new_str: String,
37
+ old_str: String,
38
+ path: String,
39
+ command: Symbol
40
+ ).returns(T.attached_class)
41
+ end
42
+ def self.new(
43
+ # Text to replace with
44
+ new_str:,
45
+ # Text to search for and replace
46
+ old_str:,
47
+ # Path to the file where text should be replaced
48
+ path:,
49
+ # Command type identifier
50
+ command: :str_replace
51
+ )
52
+ end
53
+
54
+ sig do
55
+ override.returns(
56
+ { command: Symbol, new_str: String, old_str: String, path: String }
57
+ )
58
+ end
59
+ def to_hash
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,59 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaMemoryTool20250818ViewCommand = Beta::BetaMemoryTool20250818ViewCommand
6
+
7
+ module Beta
8
+ class BetaMemoryTool20250818ViewCommand < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaMemoryTool20250818ViewCommand,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ # Command type identifier
18
+ sig { returns(Symbol) }
19
+ attr_accessor :command
20
+
21
+ # Path to directory or file to view
22
+ sig { returns(String) }
23
+ attr_accessor :path
24
+
25
+ # Optional line range for viewing specific lines
26
+ sig { returns(T.nilable(T::Array[Integer])) }
27
+ attr_reader :view_range
28
+
29
+ sig { params(view_range: T::Array[Integer]).void }
30
+ attr_writer :view_range
31
+
32
+ sig do
33
+ params(
34
+ path: String,
35
+ view_range: T::Array[Integer],
36
+ command: Symbol
37
+ ).returns(T.attached_class)
38
+ end
39
+ def self.new(
40
+ # Path to directory or file to view
41
+ path:,
42
+ # Optional line range for viewing specific lines
43
+ view_range: nil,
44
+ # Command type identifier
45
+ command: :view
46
+ )
47
+ end
48
+
49
+ sig do
50
+ override.returns(
51
+ { command: Symbol, path: String, view_range: T::Array[Integer] }
52
+ )
53
+ end
54
+ def to_hash
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -64,6 +64,20 @@ module Anthropic
64
64
  sig { returns(T::Array[Anthropic::Beta::BetaContentBlock::Variants]) }
65
65
  attr_accessor :content
66
66
 
67
+ # Information about context management operations applied during the request.
68
+ sig do
69
+ returns(T.nilable(Anthropic::Beta::BetaContextManagementResponse))
70
+ end
71
+ attr_reader :context_management
72
+
73
+ sig do
74
+ params(
75
+ context_management:
76
+ T.nilable(Anthropic::Beta::BetaContextManagementResponse::OrHash)
77
+ ).void
78
+ end
79
+ attr_writer :context_management
80
+
67
81
  # The model that will complete your prompt.\n\nSee
68
82
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
69
83
  # details and options.
@@ -152,6 +166,8 @@ module Anthropic
152
166
  Anthropic::Beta::BetaContainerUploadBlock::OrHash
153
167
  )
154
168
  ],
169
+ context_management:
170
+ T.nilable(Anthropic::Beta::BetaContextManagementResponse::OrHash),
155
171
  model: T.any(Anthropic::Model::OrSymbol, String),
156
172
  stop_reason: T.nilable(Anthropic::Beta::BetaStopReason::OrSymbol),
157
173
  stop_sequence: T.nilable(String),
@@ -201,6 +217,8 @@ module Anthropic
201
217
  # [{ "type": "text", "text": "B)" }]
202
218
  # ```
203
219
  content:,
220
+ # Information about context management operations applied during the request.
221
+ context_management:,
204
222
  # The model that will complete your prompt.\n\nSee
205
223
  # [models](https://docs.anthropic.com/en/docs/models-overview) for additional
206
224
  # details and options.
@@ -259,6 +277,8 @@ module Anthropic
259
277
  id: String,
260
278
  container: T.nilable(Anthropic::Beta::BetaContainer),
261
279
  content: T::Array[Anthropic::Beta::BetaContentBlock::Variants],
280
+ context_management:
281
+ T.nilable(Anthropic::Beta::BetaContextManagementResponse),
262
282
  model: Anthropic::Model::Variants,
263
283
  role: Symbol,
264
284
  stop_reason: