claude-agent-sdk 0.37.0 → 1.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/README.md +6 -2
- data/UPGRADING-1.0.md +151 -0
- data/docs/client.md +11 -0
- data/docs/configuration.md +42 -0
- data/docs/errors.md +6 -0
- data/docs/sessions.md +20 -1
- data/docs/types.md +17 -14
- data/lib/claude_agent_sdk/cli_installer.rb +1 -1
- data/lib/claude_agent_sdk/deprecation.rb +1 -40
- data/lib/claude_agent_sdk/errors.rb +10 -0
- data/lib/claude_agent_sdk/query.rb +320 -56
- data/lib/claude_agent_sdk/session_resume.rb +11 -5
- data/lib/claude_agent_sdk/subprocess_cli_transport.rb +25 -0
- data/lib/claude_agent_sdk/types/attributes.rb +14 -49
- data/lib/claude_agent_sdk/types/base.rb +2 -0
- data/lib/claude_agent_sdk/types/messages.rb +7 -1
- data/lib/claude_agent_sdk/types/options.rb +69 -12
- data/lib/claude_agent_sdk/version.rb +1 -1
- data/lib/claude_agent_sdk.rb +28 -18
- data/sig/claude_agent_sdk/cancellation_signal.rbs +14 -0
- data/sig/claude_agent_sdk/configuration.rbs +14 -0
- data/sig/claude_agent_sdk/errors.rbs +86 -0
- data/sig/claude_agent_sdk/observer.rbs +42 -0
- data/sig/claude_agent_sdk/railtie.rbs +10 -0
- data/sig/claude_agent_sdk/sdk_mcp_server.rbs +76 -0
- data/sig/claude_agent_sdk/session_store.rbs +105 -0
- data/sig/claude_agent_sdk/streaming.rbs +15 -0
- data/sig/claude_agent_sdk/transport.rbs +98 -0
- data/sig/claude_agent_sdk/types/base.rbs +39 -0
- data/sig/claude_agent_sdk/types/content_blocks.rbs +79 -0
- data/sig/claude_agent_sdk/types/hooks.rbs +528 -0
- data/sig/claude_agent_sdk/types/mcp.rbs +216 -0
- data/sig/claude_agent_sdk/types/messages.rbs +586 -0
- data/sig/claude_agent_sdk/types/option_values.rbs +245 -0
- data/sig/claude_agent_sdk/types/options.rbs +297 -0
- data/sig/claude_agent_sdk/types/permissions.rbs +108 -0
- data/sig/claude_agent_sdk/types/sessions.rbs +66 -0
- data/sig/claude_agent_sdk.rbs +231 -0
- data/sig/manifest.yaml +5 -0
- metadata +23 -2
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
module ClaudeAgentSDK
|
|
2
|
+
# Valid `display` values of the thinking configs.
|
|
3
|
+
THINKING_DISPLAY_VALUES: Array[String]
|
|
4
|
+
|
|
5
|
+
# The value types below are built by the caller and passed IN (inside
|
|
6
|
+
# ClaudeAgentOptions). Each constructor takes the attributes as keywords;
|
|
7
|
+
# the Hash form (String or camelCase keys, e.g. `klass.new(value.to_h)`)
|
|
8
|
+
# is accepted too. An unknown key raises ArgumentError. Discriminators
|
|
9
|
+
# (`type`) are fixed by the class and read-only.
|
|
10
|
+
|
|
11
|
+
# Adaptive thinking: the model decides when and how much to think.
|
|
12
|
+
class ThinkingConfigAdaptive < Type
|
|
13
|
+
def initialize: (?display: String?) -> void
|
|
14
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
15
|
+
|
|
16
|
+
# "adaptive".
|
|
17
|
+
attr_reader type: String
|
|
18
|
+
|
|
19
|
+
attr_reader display: String?
|
|
20
|
+
|
|
21
|
+
# Raises ArgumentError unless nil or one of THINKING_DISPLAY_VALUES.
|
|
22
|
+
def display=: (String? value) -> String?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Thinking with an explicit token budget.
|
|
26
|
+
class ThinkingConfigEnabled < Type
|
|
27
|
+
def initialize: (?budget_tokens: Integer?, ?display: String?) -> void
|
|
28
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
29
|
+
|
|
30
|
+
attr_accessor budget_tokens: Integer?
|
|
31
|
+
|
|
32
|
+
# "enabled".
|
|
33
|
+
attr_reader type: String
|
|
34
|
+
|
|
35
|
+
attr_reader display: String?
|
|
36
|
+
|
|
37
|
+
# Raises ArgumentError unless nil or one of THINKING_DISPLAY_VALUES.
|
|
38
|
+
def display=: (String? value) -> String?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class ThinkingConfigDisabled < Type
|
|
42
|
+
def initialize: () -> void
|
|
43
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
44
|
+
|
|
45
|
+
# "disabled".
|
|
46
|
+
attr_reader type: String
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# A subagent definition (ClaudeAgentOptions#agents values).
|
|
50
|
+
class AgentDefinition < Type
|
|
51
|
+
def initialize: (?description: String?, ?prompt: String?, ?tools: Array[String]?, ?disallowed_tools: Array[String]?, ?model: String?, ?skills: Array[String]?, ?memory: String?, ?mcp_servers: Array[String | Hash[Symbol | String, untyped]]?, ?initial_prompt: String?, ?max_turns: Integer?, ?background: bool?, ?effort: (String | Integer)?, ?permission_mode: String?) -> void
|
|
52
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
53
|
+
|
|
54
|
+
attr_accessor description: String?
|
|
55
|
+
|
|
56
|
+
attr_accessor prompt: String?
|
|
57
|
+
|
|
58
|
+
attr_accessor tools: Array[String]?
|
|
59
|
+
|
|
60
|
+
attr_accessor disallowed_tools: Array[String]?
|
|
61
|
+
|
|
62
|
+
attr_accessor model: String?
|
|
63
|
+
|
|
64
|
+
attr_accessor skills: Array[String]?
|
|
65
|
+
|
|
66
|
+
attr_accessor memory: String?
|
|
67
|
+
|
|
68
|
+
# MCP server names, or inline server config Hashes.
|
|
69
|
+
attr_accessor mcp_servers: Array[String | Hash[Symbol | String, untyped]]?
|
|
70
|
+
|
|
71
|
+
attr_accessor initial_prompt: String?
|
|
72
|
+
|
|
73
|
+
attr_accessor max_turns: Integer?
|
|
74
|
+
|
|
75
|
+
attr_accessor background: bool?
|
|
76
|
+
|
|
77
|
+
attr_accessor effort: (String | Integer)?
|
|
78
|
+
|
|
79
|
+
attr_accessor permission_mode: String?
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# A local plugin directory (ClaudeAgentOptions#plugins entries).
|
|
83
|
+
class SdkPluginConfig < Type
|
|
84
|
+
def initialize: (?path: String?) -> void
|
|
85
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
86
|
+
|
|
87
|
+
attr_accessor path: String?
|
|
88
|
+
|
|
89
|
+
# "local".
|
|
90
|
+
attr_reader type: String
|
|
91
|
+
|
|
92
|
+
def to_h: () -> { type: String, path: String? }
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class SandboxNetworkConfig < Type
|
|
96
|
+
def initialize: (?allowed_domains: Array[String]?, ?denied_domains: Array[String]?, ?allow_managed_domains_only: bool?, ?allow_unix_sockets: (bool | Array[String])?, ?allow_all_unix_sockets: bool?, ?allow_local_binding: bool?, ?allow_mach_lookup: Array[String]?, ?http_proxy_port: Integer?, ?socks_proxy_port: Integer?) -> void
|
|
97
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
98
|
+
|
|
99
|
+
attr_accessor allowed_domains: Array[String]?
|
|
100
|
+
|
|
101
|
+
attr_accessor denied_domains: Array[String]?
|
|
102
|
+
|
|
103
|
+
attr_accessor allow_managed_domains_only: bool?
|
|
104
|
+
|
|
105
|
+
attr_accessor allow_unix_sockets: (bool | Array[String])?
|
|
106
|
+
|
|
107
|
+
attr_accessor allow_all_unix_sockets: bool?
|
|
108
|
+
|
|
109
|
+
attr_accessor allow_local_binding: bool?
|
|
110
|
+
|
|
111
|
+
attr_accessor allow_mach_lookup: Array[String]?
|
|
112
|
+
|
|
113
|
+
attr_accessor http_proxy_port: Integer?
|
|
114
|
+
|
|
115
|
+
attr_accessor socks_proxy_port: Integer?
|
|
116
|
+
|
|
117
|
+
# The camelCase settings form.
|
|
118
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
class SandboxFilesystemConfig < Type
|
|
122
|
+
def initialize: (?allow_write: Array[String]?, ?deny_write: Array[String]?, ?deny_read: Array[String]?, ?allow_read: Array[String]?, ?allow_managed_read_paths_only: bool?) -> void
|
|
123
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
124
|
+
|
|
125
|
+
attr_accessor allow_write: Array[String]?
|
|
126
|
+
|
|
127
|
+
attr_accessor deny_write: Array[String]?
|
|
128
|
+
|
|
129
|
+
attr_accessor deny_read: Array[String]?
|
|
130
|
+
|
|
131
|
+
attr_accessor allow_read: Array[String]?
|
|
132
|
+
|
|
133
|
+
attr_accessor allow_managed_read_paths_only: bool?
|
|
134
|
+
|
|
135
|
+
# The camelCase settings form.
|
|
136
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Sandbox settings for isolated command execution
|
|
140
|
+
# (ClaudeAgentOptions#sandbox).
|
|
141
|
+
class SandboxSettings < Type
|
|
142
|
+
def initialize: (?enabled: bool?, ?fail_if_unavailable: bool?, ?auto_allow_bash_if_sandboxed: bool?, ?excluded_commands: Array[String]?, ?allow_unsandboxed_commands: bool?, ?network: (SandboxNetworkConfig | Hash[Symbol | String, untyped])?, ?filesystem: (SandboxFilesystemConfig | Hash[Symbol | String, untyped])?, ?ignore_violations: Hash[Symbol | String, Array[String]]?, ?enable_weaker_nested_sandbox: bool?, ?enable_weaker_network_isolation: bool?, ?ripgrep: Hash[Symbol | String, untyped]?) -> void
|
|
143
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
144
|
+
|
|
145
|
+
attr_accessor enabled: bool?
|
|
146
|
+
|
|
147
|
+
attr_accessor fail_if_unavailable: bool?
|
|
148
|
+
|
|
149
|
+
attr_accessor auto_allow_bash_if_sandboxed: bool?
|
|
150
|
+
|
|
151
|
+
attr_accessor excluded_commands: Array[String]?
|
|
152
|
+
|
|
153
|
+
attr_accessor allow_unsandboxed_commands: bool?
|
|
154
|
+
|
|
155
|
+
attr_accessor network: (SandboxNetworkConfig | Hash[Symbol | String, untyped])?
|
|
156
|
+
|
|
157
|
+
attr_accessor filesystem: (SandboxFilesystemConfig | Hash[Symbol | String, untyped])?
|
|
158
|
+
|
|
159
|
+
# e.g. { file: [...paths], network: [...hosts] }.
|
|
160
|
+
attr_accessor ignore_violations: Hash[Symbol | String, Array[String]]?
|
|
161
|
+
|
|
162
|
+
attr_accessor enable_weaker_nested_sandbox: bool?
|
|
163
|
+
|
|
164
|
+
attr_accessor enable_weaker_network_isolation: bool?
|
|
165
|
+
|
|
166
|
+
attr_accessor ripgrep: Hash[Symbol | String, untyped]?
|
|
167
|
+
|
|
168
|
+
# The camelCase settings form.
|
|
169
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# API-side task budget in tokens (ClaudeAgentOptions#task_budget).
|
|
173
|
+
class TaskBudget < Type
|
|
174
|
+
def initialize: (?total: Integer?) -> void
|
|
175
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
176
|
+
|
|
177
|
+
attr_accessor total: Integer?
|
|
178
|
+
|
|
179
|
+
def to_h: () -> { total: Integer? }
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# A system prompt loaded from a file.
|
|
183
|
+
class SystemPromptFile < Type
|
|
184
|
+
def initialize: (?path: String?) -> void
|
|
185
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
186
|
+
|
|
187
|
+
attr_accessor path: String?
|
|
188
|
+
|
|
189
|
+
# "file".
|
|
190
|
+
attr_reader type: String
|
|
191
|
+
|
|
192
|
+
def to_h: () -> { type: String, path: String? }
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# The Claude Code preset system prompt, optionally extended.
|
|
196
|
+
class SystemPromptPreset < Type
|
|
197
|
+
def initialize: (?preset: String?, ?append: String?, ?exclude_dynamic_sections: bool?, ?snapshot: bool?) -> void
|
|
198
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
199
|
+
|
|
200
|
+
# "preset".
|
|
201
|
+
attr_reader type: String
|
|
202
|
+
|
|
203
|
+
# e.g. "claude_code".
|
|
204
|
+
attr_accessor preset: String?
|
|
205
|
+
|
|
206
|
+
attr_accessor append: String?
|
|
207
|
+
|
|
208
|
+
attr_accessor exclude_dynamic_sections: bool?
|
|
209
|
+
|
|
210
|
+
# Whether the session keeps the system prompt recorded on its first
|
|
211
|
+
# request (nil: the CLI default).
|
|
212
|
+
attr_accessor snapshot: bool?
|
|
213
|
+
|
|
214
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# The object form of a String system prompt, so snapshot can be set.
|
|
218
|
+
class SystemPromptCustom < Type
|
|
219
|
+
def initialize: (?prompt: String?, ?snapshot: bool?) -> void
|
|
220
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
221
|
+
|
|
222
|
+
# "custom".
|
|
223
|
+
attr_reader type: String
|
|
224
|
+
|
|
225
|
+
attr_accessor prompt: String?
|
|
226
|
+
|
|
227
|
+
attr_accessor snapshot: bool?
|
|
228
|
+
|
|
229
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# A tools preset (ClaudeAgentOptions#tools).
|
|
233
|
+
class ToolsPreset < Type
|
|
234
|
+
def initialize: (?preset: String?) -> void
|
|
235
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
236
|
+
|
|
237
|
+
# "preset".
|
|
238
|
+
attr_reader type: String
|
|
239
|
+
|
|
240
|
+
# e.g. "claude_code".
|
|
241
|
+
attr_accessor preset: String?
|
|
242
|
+
|
|
243
|
+
def to_h: () -> { type: String, preset: String? }
|
|
244
|
+
end
|
|
245
|
+
end
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
module ClaudeAgentSDK
|
|
2
|
+
SETTING_SOURCES: Array[String]
|
|
3
|
+
|
|
4
|
+
# Named ClaudeAgentOptions#effort levels (an Integer is accepted too).
|
|
5
|
+
EFFORT_LEVELS: Array[String]
|
|
6
|
+
|
|
7
|
+
SDK_BETAS: Array[String]
|
|
8
|
+
|
|
9
|
+
# ClaudeAgentOptions#system_prompt: a String, a typed config, or the
|
|
10
|
+
# equivalent Hash ({ type: 'preset' | 'custom' | 'file', ... }).
|
|
11
|
+
type system_prompt_config = String | SystemPromptPreset | SystemPromptCustom | SystemPromptFile | Hash[Symbol | String, untyped]
|
|
12
|
+
|
|
13
|
+
# ClaudeAgentOptions#thinking.
|
|
14
|
+
type thinking_config = ThinkingConfigAdaptive | ThinkingConfigEnabled | ThinkingConfigDisabled | Hash[Symbol | String, untyped]
|
|
15
|
+
|
|
16
|
+
# ClaudeAgentOptions#stderr: called with each stderr line of the CLI.
|
|
17
|
+
interface _StderrCallback
|
|
18
|
+
def call: (String line) -> void
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# ClaudeAgentOptions#debug_stderr as an IO-like object.
|
|
22
|
+
interface _Puts
|
|
23
|
+
def puts: (*untyped) -> untyped
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Configuration for query / Client. Unknown option names raise
|
|
27
|
+
# ArgumentError (in .new, #[]= and #dup_with). Values set with
|
|
28
|
+
# ClaudeAgentSDK.configure are merged in as defaults.
|
|
29
|
+
#
|
|
30
|
+
# The container options (allowed_tools, env, mcp_servers, ...) and
|
|
31
|
+
# session_store_flush / load_timeout_ms are filled with their defaults by
|
|
32
|
+
# the constructor, so they are nil only when set to nil afterwards.
|
|
33
|
+
class ClaudeAgentOptions < Type
|
|
34
|
+
CALLBACK_SCHEDULING_MODES: Array[Symbol]
|
|
35
|
+
|
|
36
|
+
def initialize: (
|
|
37
|
+
?allowed_tools: Array[String]?,
|
|
38
|
+
?system_prompt: system_prompt_config?,
|
|
39
|
+
?mcp_servers: (Hash[String | Symbol, mcp_server_config] | String)?,
|
|
40
|
+
?permission_mode: String?,
|
|
41
|
+
?resume: String?,
|
|
42
|
+
?resume_session_at: String?,
|
|
43
|
+
?resume_drops_turn: String?,
|
|
44
|
+
?session_id: String?,
|
|
45
|
+
?max_turns: Integer?,
|
|
46
|
+
?disallowed_tools: Array[String]?,
|
|
47
|
+
?model: String?,
|
|
48
|
+
?permission_prompt_tool_name: String?,
|
|
49
|
+
?cwd: (String | Pathname)?,
|
|
50
|
+
?cli_path: (String | Pathname)?,
|
|
51
|
+
?settings: (String | Hash[Symbol | String, untyped])?,
|
|
52
|
+
?add_dirs: Array[String | Pathname]?,
|
|
53
|
+
?env: Hash[String | Symbol, String?]?,
|
|
54
|
+
?extra_args: Hash[String | Symbol, untyped]?,
|
|
55
|
+
?max_buffer_size: Integer?,
|
|
56
|
+
?stderr: _StderrCallback?,
|
|
57
|
+
?can_use_tool: _CanUseTool?,
|
|
58
|
+
?hooks: Hash[String | Symbol, Array[HookMatcher]?]?,
|
|
59
|
+
?user: (String | Integer)?,
|
|
60
|
+
?agents: Hash[String | Symbol, AgentDefinition | Hash[Symbol | String, untyped]]?,
|
|
61
|
+
?setting_sources: Array[String]?,
|
|
62
|
+
?skills: (String | Array[String])?,
|
|
63
|
+
?output_format: (Hash[Symbol | String, untyped] | String)?,
|
|
64
|
+
?max_budget_usd: Numeric?,
|
|
65
|
+
?max_thinking_tokens: Integer?,
|
|
66
|
+
?fallback_model: String?,
|
|
67
|
+
?advisor_model: String?,
|
|
68
|
+
?plugins: Array[SdkPluginConfig | Hash[Symbol | String, untyped]]?,
|
|
69
|
+
?debug_stderr: (_Puts | String)?,
|
|
70
|
+
?betas: Array[String]?,
|
|
71
|
+
?tools: (Array[String] | ToolsPreset | Hash[Symbol | String, untyped])?,
|
|
72
|
+
?sandbox: (SandboxSettings | Hash[Symbol | String, untyped] | bool)?,
|
|
73
|
+
?thinking: thinking_config?,
|
|
74
|
+
?effort: (String | Symbol | Integer)?,
|
|
75
|
+
?observers: Array[untyped]?,
|
|
76
|
+
?task_budget: (TaskBudget | Hash[Symbol | String, untyped])?,
|
|
77
|
+
?session_store: _SessionStore?,
|
|
78
|
+
?session_store_flush: (String | Symbol)?,
|
|
79
|
+
?load_timeout_ms: Numeric?,
|
|
80
|
+
?bare: bool?,
|
|
81
|
+
?fork_session: bool?,
|
|
82
|
+
?enable_file_checkpointing: bool?,
|
|
83
|
+
?include_partial_messages: bool?,
|
|
84
|
+
?continue_conversation: bool?,
|
|
85
|
+
?include_hook_events: bool?,
|
|
86
|
+
?strict_mcp_config: bool?,
|
|
87
|
+
?forward_subagent_text: bool?,
|
|
88
|
+
?verbatim_prompts: bool?,
|
|
89
|
+
?agent_progress_summaries: bool?,
|
|
90
|
+
?callback_scheduling: (:thread | :inline | "thread" | "inline")?,
|
|
91
|
+
?callback_wrapper: _CallbackWrapper?
|
|
92
|
+
) -> void
|
|
93
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
94
|
+
|
|
95
|
+
# A deep copy with changes applied (unknown names raise ArgumentError).
|
|
96
|
+
# Containers and option value types are copied; callables, SDK MCP server
|
|
97
|
+
# instances and store adapters keep their identity.
|
|
98
|
+
def dup_with: (**untyped changes) -> ClaudeAgentOptions
|
|
99
|
+
|
|
100
|
+
# Tool names always allowed ([] by default).
|
|
101
|
+
attr_accessor allowed_tools: Array[String]?
|
|
102
|
+
|
|
103
|
+
attr_accessor system_prompt: system_prompt_config?
|
|
104
|
+
|
|
105
|
+
# Server name => config ({} by default), or a path / JSON String passed
|
|
106
|
+
# to --mcp-config.
|
|
107
|
+
attr_accessor mcp_servers: (Hash[String | Symbol, mcp_server_config] | String)?
|
|
108
|
+
|
|
109
|
+
# One of PERMISSION_MODES.
|
|
110
|
+
attr_accessor permission_mode: String?
|
|
111
|
+
|
|
112
|
+
# Session id to resume.
|
|
113
|
+
attr_accessor resume: String?
|
|
114
|
+
|
|
115
|
+
# With #resume: truncate the resumed session after this message UUID.
|
|
116
|
+
attr_accessor resume_session_at: String?
|
|
117
|
+
|
|
118
|
+
# With #resume_session_at: the prompt UUID of the turn being discarded.
|
|
119
|
+
attr_accessor resume_drops_turn: String?
|
|
120
|
+
|
|
121
|
+
attr_accessor session_id: String?
|
|
122
|
+
|
|
123
|
+
attr_accessor max_turns: Integer?
|
|
124
|
+
|
|
125
|
+
# Tool names always denied ([] by default).
|
|
126
|
+
attr_accessor disallowed_tools: Array[String]?
|
|
127
|
+
|
|
128
|
+
attr_accessor model: String?
|
|
129
|
+
|
|
130
|
+
attr_accessor permission_prompt_tool_name: String?
|
|
131
|
+
|
|
132
|
+
attr_accessor cwd: (String | Pathname)?
|
|
133
|
+
|
|
134
|
+
attr_accessor cli_path: (String | Pathname)?
|
|
135
|
+
|
|
136
|
+
# A settings JSON String, a path to a settings file, or a Hash.
|
|
137
|
+
attr_accessor settings: (String | Hash[Symbol | String, untyped])?
|
|
138
|
+
|
|
139
|
+
attr_accessor add_dirs: Array[String | Pathname]?
|
|
140
|
+
|
|
141
|
+
# Extra environment for the CLI process ({} by default).
|
|
142
|
+
attr_accessor env: Hash[String | Symbol, String?]?
|
|
143
|
+
|
|
144
|
+
# Extra CLI flags: flag name (kebab-case, no leading --) => value, nil
|
|
145
|
+
# for a boolean flag ({} by default).
|
|
146
|
+
attr_accessor extra_args: Hash[String | Symbol, untyped]?
|
|
147
|
+
|
|
148
|
+
attr_accessor max_buffer_size: Integer?
|
|
149
|
+
|
|
150
|
+
attr_accessor stderr: _StderrCallback?
|
|
151
|
+
|
|
152
|
+
attr_accessor can_use_tool: _CanUseTool?
|
|
153
|
+
|
|
154
|
+
# Hook event name (see HOOK_EVENTS) => matchers.
|
|
155
|
+
attr_accessor hooks: Hash[String | Symbol, Array[HookMatcher]?]?
|
|
156
|
+
|
|
157
|
+
# User (name or uid) to run the CLI process as.
|
|
158
|
+
attr_accessor user: (String | Integer)?
|
|
159
|
+
|
|
160
|
+
attr_accessor agents: Hash[String | Symbol, AgentDefinition | Hash[Symbol | String, untyped]]?
|
|
161
|
+
|
|
162
|
+
# Entries of SETTING_SOURCES.
|
|
163
|
+
attr_accessor setting_sources: Array[String]?
|
|
164
|
+
|
|
165
|
+
# 'all', or the names of the skills to enable.
|
|
166
|
+
attr_accessor skills: (String | Array[String])?
|
|
167
|
+
|
|
168
|
+
# { type: 'json_schema', schema: {...} }, a bare schema Hash, or a JSON
|
|
169
|
+
# String.
|
|
170
|
+
attr_accessor output_format: (Hash[Symbol | String, untyped] | String)?
|
|
171
|
+
|
|
172
|
+
attr_accessor max_budget_usd: Numeric?
|
|
173
|
+
|
|
174
|
+
attr_accessor max_thinking_tokens: Integer?
|
|
175
|
+
|
|
176
|
+
attr_accessor fallback_model: String?
|
|
177
|
+
|
|
178
|
+
attr_accessor advisor_model: String?
|
|
179
|
+
|
|
180
|
+
attr_accessor plugins: Array[SdkPluginConfig | Hash[Symbol | String, untyped]]?
|
|
181
|
+
|
|
182
|
+
# An IO-like object (#puts) or a file path to append CLI stderr to.
|
|
183
|
+
attr_accessor debug_stderr: (_Puts | String)?
|
|
184
|
+
|
|
185
|
+
# Entries of SDK_BETAS.
|
|
186
|
+
attr_accessor betas: Array[String]?
|
|
187
|
+
|
|
188
|
+
# The base tool set: tool names, or a preset.
|
|
189
|
+
attr_accessor tools: (Array[String] | ToolsPreset | Hash[Symbol | String, untyped])?
|
|
190
|
+
|
|
191
|
+
# true / false are forwarded as-is (a bare toggle).
|
|
192
|
+
attr_accessor sandbox: (SandboxSettings | Hash[Symbol | String, untyped] | bool)?
|
|
193
|
+
|
|
194
|
+
attr_accessor thinking: thinking_config?
|
|
195
|
+
|
|
196
|
+
# One of EFFORT_LEVELS, or an Integer.
|
|
197
|
+
attr_accessor effort: (String | Symbol | Integer)?
|
|
198
|
+
|
|
199
|
+
# Observer instances, or factories (callables returning a fresh observer
|
|
200
|
+
# per query/session). Anything implementing none of the Observer methods
|
|
201
|
+
# is warned about and skipped, so the element type is left open.
|
|
202
|
+
attr_accessor observers: Array[untyped]?
|
|
203
|
+
|
|
204
|
+
attr_accessor task_budget: (TaskBudget | Hash[Symbol | String, untyped])?
|
|
205
|
+
|
|
206
|
+
# Mirrors transcripts to this store and enables resume from it.
|
|
207
|
+
attr_accessor session_store: _SessionStore?
|
|
208
|
+
|
|
209
|
+
# One of SESSION_STORE_FLUSH_MODES ('batched' by default).
|
|
210
|
+
attr_accessor session_store_flush: (String | Symbol)?
|
|
211
|
+
|
|
212
|
+
# Resume-materialization timeout (60_000 by default; 0 = immediate).
|
|
213
|
+
attr_accessor load_timeout_ms: Numeric?
|
|
214
|
+
|
|
215
|
+
# The boolean flags coerce any assigned value (nil stays nil where
|
|
216
|
+
# noted; "false", "0", "off", ... read as false). The predicate form
|
|
217
|
+
# (#bare?, ...) is a strict Boolean.
|
|
218
|
+
|
|
219
|
+
attr_reader bare: bool?
|
|
220
|
+
|
|
221
|
+
def bare=: (untyped value) -> bool?
|
|
222
|
+
|
|
223
|
+
def bare?: () -> bool
|
|
224
|
+
|
|
225
|
+
attr_reader fork_session: bool?
|
|
226
|
+
|
|
227
|
+
def fork_session=: (untyped value) -> bool?
|
|
228
|
+
|
|
229
|
+
def fork_session?: () -> bool
|
|
230
|
+
|
|
231
|
+
attr_reader enable_file_checkpointing: bool?
|
|
232
|
+
|
|
233
|
+
def enable_file_checkpointing=: (untyped value) -> bool?
|
|
234
|
+
|
|
235
|
+
def enable_file_checkpointing?: () -> bool
|
|
236
|
+
|
|
237
|
+
attr_reader include_partial_messages: bool?
|
|
238
|
+
|
|
239
|
+
def include_partial_messages=: (untyped value) -> bool?
|
|
240
|
+
|
|
241
|
+
def include_partial_messages?: () -> bool
|
|
242
|
+
|
|
243
|
+
attr_reader continue_conversation: bool?
|
|
244
|
+
|
|
245
|
+
def continue_conversation=: (untyped value) -> bool?
|
|
246
|
+
|
|
247
|
+
def continue_conversation?: () -> bool
|
|
248
|
+
|
|
249
|
+
attr_reader include_hook_events: bool?
|
|
250
|
+
|
|
251
|
+
def include_hook_events=: (untyped value) -> bool?
|
|
252
|
+
|
|
253
|
+
def include_hook_events?: () -> bool
|
|
254
|
+
|
|
255
|
+
attr_reader strict_mcp_config: bool?
|
|
256
|
+
|
|
257
|
+
def strict_mcp_config=: (untyped value) -> bool?
|
|
258
|
+
|
|
259
|
+
def strict_mcp_config?: () -> bool
|
|
260
|
+
|
|
261
|
+
# Forward subagent text and thinking blocks (false by default).
|
|
262
|
+
attr_reader forward_subagent_text: bool?
|
|
263
|
+
|
|
264
|
+
def forward_subagent_text=: (untyped value) -> bool?
|
|
265
|
+
|
|
266
|
+
def forward_subagent_text?: () -> bool
|
|
267
|
+
|
|
268
|
+
# Mark every outgoing user message client_composed, so the CLI delivers
|
|
269
|
+
# it as written (false by default).
|
|
270
|
+
attr_reader verbatim_prompts: bool?
|
|
271
|
+
|
|
272
|
+
def verbatim_prompts=: (untyped value) -> bool?
|
|
273
|
+
|
|
274
|
+
def verbatim_prompts?: () -> bool
|
|
275
|
+
|
|
276
|
+
# Request model-generated progress summaries for subagent tasks (nil:
|
|
277
|
+
# unset, not sent).
|
|
278
|
+
attr_reader agent_progress_summaries: bool?
|
|
279
|
+
|
|
280
|
+
def agent_progress_summaries=: (untyped value) -> bool?
|
|
281
|
+
|
|
282
|
+
# Where user callbacks run (:thread by default). See the README's
|
|
283
|
+
# "Callback scheduling".
|
|
284
|
+
attr_reader callback_scheduling: (:thread | :inline)?
|
|
285
|
+
|
|
286
|
+
# A String is coerced to a Symbol; anything but :thread / :inline / nil
|
|
287
|
+
# raises ArgumentError.
|
|
288
|
+
def callback_scheduling=: ((:thread | :inline | "thread" | "inline")? value) -> (:thread | :inline | "thread" | "inline")?
|
|
289
|
+
|
|
290
|
+
# Middleware around every user-callback dispatch (nil: none). Rails:
|
|
291
|
+
# ClaudeAgentSDK::Railtie.callback_wrapper.
|
|
292
|
+
attr_reader callback_wrapper: _CallbackWrapper?
|
|
293
|
+
|
|
294
|
+
# Raises ArgumentError unless value is callable or nil.
|
|
295
|
+
def callback_wrapper=: (_CallbackWrapper? value) -> _CallbackWrapper?
|
|
296
|
+
end
|
|
297
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
module ClaudeAgentSDK
|
|
2
|
+
PERMISSION_MODES: Array[String]
|
|
3
|
+
|
|
4
|
+
PERMISSION_UPDATE_DESTINATIONS: Array[String]
|
|
5
|
+
|
|
6
|
+
PERMISSION_BEHAVIORS: Array[String]
|
|
7
|
+
|
|
8
|
+
# What a can_use_tool callback returns.
|
|
9
|
+
type permission_result = PermissionResultAllow | PermissionResultDeny
|
|
10
|
+
|
|
11
|
+
# ClaudeAgentOptions#can_use_tool: decides whether a tool call may run.
|
|
12
|
+
# input is the tool input (wire_hash).
|
|
13
|
+
interface _CanUseTool
|
|
14
|
+
def call: (String tool_name, wire_hash input, ToolPermissionContext context) -> permission_result
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class PermissionRuleValue < Type
|
|
18
|
+
def initialize: (?tool_name: String?, ?rule_content: String?) -> void
|
|
19
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
20
|
+
|
|
21
|
+
attr_accessor tool_name: String?
|
|
22
|
+
|
|
23
|
+
attr_accessor rule_content: String?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# A permission change: a suggestion in ToolPermissionContext#suggestions,
|
|
27
|
+
# or an entry of PermissionResultAllow#updated_permissions.
|
|
28
|
+
class PermissionUpdate < Type
|
|
29
|
+
def initialize: (?type: String?, ?behavior: String?, ?mode: String?, ?directories: Array[String]?, ?destination: String?, ?rules: Array[PermissionRuleValue | Hash[Symbol | String, untyped]]?) -> void
|
|
30
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
31
|
+
|
|
32
|
+
# "addRules", "replaceRules", "removeRules", "setMode",
|
|
33
|
+
# "addDirectories" or "removeDirectories".
|
|
34
|
+
attr_accessor type: String?
|
|
35
|
+
|
|
36
|
+
# One of PERMISSION_BEHAVIORS.
|
|
37
|
+
attr_accessor behavior: String?
|
|
38
|
+
|
|
39
|
+
# One of PERMISSION_MODES (for "setMode").
|
|
40
|
+
attr_accessor mode: String?
|
|
41
|
+
|
|
42
|
+
attr_accessor directories: Array[String]?
|
|
43
|
+
|
|
44
|
+
# One of PERMISSION_UPDATE_DESTINATIONS.
|
|
45
|
+
attr_accessor destination: String?
|
|
46
|
+
|
|
47
|
+
attr_reader rules: Array[PermissionRuleValue]?
|
|
48
|
+
|
|
49
|
+
# Hash entries (camelCase or snake_case keys) become PermissionRuleValue.
|
|
50
|
+
def rules=: (Array[PermissionRuleValue | Hash[Symbol | String, untyped]]? value) -> Array[PermissionRuleValue | Hash[Symbol | String, untyped]]?
|
|
51
|
+
|
|
52
|
+
# The wire form (camelCase keys).
|
|
53
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# The context passed to a can_use_tool callback.
|
|
57
|
+
class ToolPermissionContext < Type
|
|
58
|
+
attr_accessor signal: CancellationSignal?
|
|
59
|
+
|
|
60
|
+
# Identifies this permission request (not the tool invocation).
|
|
61
|
+
attr_accessor request_id: String?
|
|
62
|
+
|
|
63
|
+
# Never nil after construction ([] by default).
|
|
64
|
+
attr_accessor suggestions: Array[PermissionUpdate]?
|
|
65
|
+
|
|
66
|
+
attr_accessor tool_use_id: String?
|
|
67
|
+
|
|
68
|
+
attr_accessor agent_id: String?
|
|
69
|
+
|
|
70
|
+
attr_accessor title: String?
|
|
71
|
+
|
|
72
|
+
attr_accessor display_name: String?
|
|
73
|
+
|
|
74
|
+
attr_accessor description: String?
|
|
75
|
+
|
|
76
|
+
attr_accessor blocked_path: String?
|
|
77
|
+
|
|
78
|
+
attr_accessor decision_reason: String?
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
class PermissionResultAllow < Type
|
|
82
|
+
def initialize: (?updated_input: Hash[Symbol | String, untyped]?, ?updated_permissions: Array[PermissionUpdate | Hash[Symbol | String, untyped]]?) -> void
|
|
83
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
84
|
+
|
|
85
|
+
# Replaces the tool input when set.
|
|
86
|
+
attr_accessor updated_input: Hash[Symbol | String, untyped]?
|
|
87
|
+
|
|
88
|
+
# PermissionUpdates, or the equivalent wire Hashes (sent via #to_h).
|
|
89
|
+
attr_accessor updated_permissions: Array[PermissionUpdate | Hash[Symbol | String, untyped]]?
|
|
90
|
+
|
|
91
|
+
# "allow".
|
|
92
|
+
attr_reader behavior: String
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class PermissionResultDeny < Type
|
|
96
|
+
def initialize: (?message: String?, ?interrupt: bool?) -> void
|
|
97
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
98
|
+
|
|
99
|
+
# "" by default.
|
|
100
|
+
attr_accessor message: String?
|
|
101
|
+
|
|
102
|
+
# false by default; true also interrupts the turn.
|
|
103
|
+
attr_accessor interrupt: bool?
|
|
104
|
+
|
|
105
|
+
# "deny".
|
|
106
|
+
attr_reader behavior: String
|
|
107
|
+
end
|
|
108
|
+
end
|