claude-agent-sdk 1.1.0 → 1.2.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.
- checksums.yaml +4 -4
- data/.yardopts +10 -0
- data/CHANGELOG.md +99 -0
- data/README.md +43 -31
- data/docs/cli-installer.md +26 -4
- data/docs/client.md +29 -11
- data/docs/configuration.md +164 -1
- data/docs/errors.md +32 -2
- data/docs/hooks-and-permissions.md +30 -10
- data/docs/mcp-servers.md +30 -9
- data/docs/observability.md +61 -10
- data/docs/options.md +232 -0
- data/docs/rails.md +263 -18
- data/docs/sessions.md +40 -12
- data/docs/subagents.md +1 -1
- data/docs/types.md +100 -11
- data/lib/claude_agent_sdk/cli_installer.rb +140 -19
- data/lib/claude_agent_sdk/command_builder.rb +83 -108
- data/lib/claude_agent_sdk/fiber_boundary.rb +45 -2
- data/lib/claude_agent_sdk/instrumentation/otel.rb +90 -28
- data/lib/claude_agent_sdk/option_forms.rb +379 -0
- data/lib/claude_agent_sdk/query/run_lifecycle.rb +373 -0
- data/lib/claude_agent_sdk/query.rb +266 -364
- data/lib/claude_agent_sdk/railtie.rb +27 -2
- data/lib/claude_agent_sdk/sdk_mcp_server.rb +78 -26
- data/lib/claude_agent_sdk/session_assembly.rb +311 -0
- data/lib/claude_agent_sdk/session_mutations.rb +112 -92
- data/lib/claude_agent_sdk/session_resume.rb +360 -43
- data/lib/claude_agent_sdk/session_store.rb +31 -2
- data/lib/claude_agent_sdk/sessions.rb +720 -138
- data/lib/claude_agent_sdk/subprocess_cli_transport.rb +228 -29
- data/lib/claude_agent_sdk/testing/session_store_conformance.rb +18 -7
- data/lib/claude_agent_sdk/transcript_mirror_batcher.rb +45 -37
- data/lib/claude_agent_sdk/transport.rb +28 -12
- data/lib/claude_agent_sdk/types/attributes.rb +9 -0
- data/lib/claude_agent_sdk/types/base.rb +85 -15
- data/lib/claude_agent_sdk/types/hooks.rb +73 -0
- data/lib/claude_agent_sdk/types/mcp.rb +37 -1
- data/lib/claude_agent_sdk/types/option_values.rb +186 -4
- data/lib/claude_agent_sdk/types/options.rb +35 -5
- data/lib/claude_agent_sdk/types/permissions.rb +18 -9
- data/lib/claude_agent_sdk/version.rb +1 -1
- data/lib/claude_agent_sdk.rb +223 -418
- data/lib/generators/claude_agent_sdk/install/templates/claude_agent_sdk.rb.tt +6 -0
- data/sig/claude_agent_sdk/types/hooks.rbs +6 -3
- data/sig/claude_agent_sdk/types/option_values.rbs +23 -6
- data/sig/claude_agent_sdk/types/options.rbs +11 -7
- data/sig/claude_agent_sdk/types/permissions.rbs +4 -2
- metadata +9 -4
|
@@ -22,6 +22,12 @@ ClaudeAgentSDK.configure do |config|
|
|
|
22
22
|
# whatever the process cwd. To run a binary from somewhere else instead:
|
|
23
23
|
# cli_path: '/usr/local/bin/claude',
|
|
24
24
|
|
|
25
|
+
# Multi-user apps: turn off the CLI's auto-memory — kept per project
|
|
26
|
+
# directory, read by every session and written by claude_code-preset
|
|
27
|
+
# sessions, so one user's "remember ..." reaches all others (the value
|
|
28
|
+
# must stay '1'; '0' forces it on). See docs/rails.md ("Per-user isolation").
|
|
29
|
+
# env: { 'CLAUDE_CODE_DISABLE_AUTO_MEMORY' => '1' },
|
|
30
|
+
|
|
25
31
|
# OpenTelemetry tracing (Langfuse, Honeycomb, ...). A factory lambda gives
|
|
26
32
|
# every query/session its own observer — safe under Puma and job threads.
|
|
27
33
|
# observers: [-> { ClaudeAgentSDK::Instrumentation::OTelObserver.new }],
|
|
@@ -47,8 +47,9 @@ module ClaudeAgentSDK
|
|
|
47
47
|
| CwdChangedHookSpecificOutput
|
|
48
48
|
| FileChangedHookSpecificOutput
|
|
49
49
|
|
|
50
|
-
# What a hook callback returns: a Hash (
|
|
51
|
-
# typed output, or nil
|
|
50
|
+
# What a hook callback returns: a Hash (Symbol or String keys, snake_case
|
|
51
|
+
# or camelCase, also inside hook_specific_output), a typed output, or nil
|
|
52
|
+
# (treated as {}).
|
|
52
53
|
type hook_output = Hash[Symbol | String, untyped] | SyncHookJSONOutput | AsyncHookJSONOutput | nil
|
|
53
54
|
|
|
54
55
|
# A hook callback (HookMatcher#hooks entries). tool_use_id is nil for
|
|
@@ -520,7 +521,9 @@ module ClaudeAgentSDK
|
|
|
520
521
|
|
|
521
522
|
attr_accessor reason: String?
|
|
522
523
|
|
|
523
|
-
# A typed output, or the equivalent Hash (camelCase
|
|
524
|
+
# A typed output, or the equivalent Hash (snake_case or camelCase keys).
|
|
525
|
+
# #to_h returns a Hash as written; the SDK puts its keys in wire spelling
|
|
526
|
+
# when it sends the output.
|
|
524
527
|
attr_accessor hook_specific_output: (hook_specific_output | Hash[Symbol | String, untyped])?
|
|
525
528
|
|
|
526
529
|
def to_h: () -> Hash[Symbol, untyped]
|
|
@@ -7,6 +7,16 @@ module ClaudeAgentSDK
|
|
|
7
7
|
# the Hash form (String or camelCase keys, e.g. `klass.new(value.to_h)`)
|
|
8
8
|
# is accepted too. An unknown key raises ArgumentError. Discriminators
|
|
9
9
|
# (`type`) are fixed by the class and read-only.
|
|
10
|
+
#
|
|
11
|
+
# The keyword overload documents the accepted keys and their types; no
|
|
12
|
+
# type checker enforces it. `klass.new(typo: 1)` is also a Symbol-keyed
|
|
13
|
+
# Hash, which the second overload accepts whatever its keys and values, so
|
|
14
|
+
# Steep reports neither a misspelled keyword nor a wrong value type, and
|
|
15
|
+
# the runtime checker behind `rake rbs:test` never reports a constructor
|
|
16
|
+
# mismatch (it only checks the attribute setters the constructor calls).
|
|
17
|
+
# The enforcement is the ArgumentError the constructor raises at runtime
|
|
18
|
+
# for an unknown key. This holds for every constructor in sig/ that has
|
|
19
|
+
# both overloads.
|
|
10
20
|
|
|
11
21
|
# Adaptive thinking: the model decides when and how much to think.
|
|
12
22
|
class ThinkingConfigAdaptive < Type
|
|
@@ -81,15 +91,15 @@ module ClaudeAgentSDK
|
|
|
81
91
|
|
|
82
92
|
# A local plugin directory (ClaudeAgentOptions#plugins entries).
|
|
83
93
|
class SdkPluginConfig < Type
|
|
84
|
-
def initialize: (?path: String?) -> void
|
|
94
|
+
def initialize: (?path: (String | Pathname)?) -> void
|
|
85
95
|
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
86
96
|
|
|
87
|
-
attr_accessor path: String?
|
|
97
|
+
attr_accessor path: (String | Pathname)?
|
|
88
98
|
|
|
89
99
|
# "local".
|
|
90
100
|
attr_reader type: String
|
|
91
101
|
|
|
92
|
-
def to_h: () -> { type: String, path: String? }
|
|
102
|
+
def to_h: () -> { type: String, path: (String | Pathname)? }
|
|
93
103
|
end
|
|
94
104
|
|
|
95
105
|
class SandboxNetworkConfig < Type
|
|
@@ -138,6 +148,13 @@ module ClaudeAgentSDK
|
|
|
138
148
|
|
|
139
149
|
# Sandbox settings for isolated command execution
|
|
140
150
|
# (ClaudeAgentOptions#sandbox).
|
|
151
|
+
#
|
|
152
|
+
# network / filesystem take the typed config or a Hash. A Hash may spell
|
|
153
|
+
# the fields of the typed class in snake_case or in the CLI's camelCase,
|
|
154
|
+
# with Symbol or String keys; other keys are sent as written. A snake_case
|
|
155
|
+
# key is sent under the CLI's name only when its value has the shape the
|
|
156
|
+
# CLI accepts for it; otherwise it is sent as written, which the CLI
|
|
157
|
+
# ignores.
|
|
141
158
|
class SandboxSettings < Type
|
|
142
159
|
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
160
|
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
@@ -181,15 +198,15 @@ module ClaudeAgentSDK
|
|
|
181
198
|
|
|
182
199
|
# A system prompt loaded from a file.
|
|
183
200
|
class SystemPromptFile < Type
|
|
184
|
-
def initialize: (?path: String?) -> void
|
|
201
|
+
def initialize: (?path: (String | Pathname)?) -> void
|
|
185
202
|
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
186
203
|
|
|
187
|
-
attr_accessor path: String?
|
|
204
|
+
attr_accessor path: (String | Pathname)?
|
|
188
205
|
|
|
189
206
|
# "file".
|
|
190
207
|
attr_reader type: String
|
|
191
208
|
|
|
192
|
-
def to_h: () -> { type: String, path: String? }
|
|
209
|
+
def to_h: () -> { type: String, path: (String | Pathname)? }
|
|
193
210
|
end
|
|
194
211
|
|
|
195
212
|
# The Claude Code preset system prompt, optionally extended.
|
|
@@ -48,7 +48,7 @@ module ClaudeAgentSDK
|
|
|
48
48
|
?permission_prompt_tool_name: String?,
|
|
49
49
|
?cwd: (String | Pathname)?,
|
|
50
50
|
?cli_path: (String | Pathname)?,
|
|
51
|
-
?settings: (String | Hash[Symbol | String, untyped])?,
|
|
51
|
+
?settings: (String | Pathname | Hash[Symbol | String, untyped])?,
|
|
52
52
|
?add_dirs: Array[String | Pathname]?,
|
|
53
53
|
?env: Hash[String | Symbol, String?]?,
|
|
54
54
|
?extra_args: Hash[String | Symbol, untyped]?,
|
|
@@ -68,7 +68,7 @@ module ClaudeAgentSDK
|
|
|
68
68
|
?plugins: Array[SdkPluginConfig | Hash[Symbol | String, untyped]]?,
|
|
69
69
|
?debug_stderr: (_Puts | String)?,
|
|
70
70
|
?betas: Array[String]?,
|
|
71
|
-
?tools: (Array[String] | ToolsPreset | Hash[Symbol | String, untyped])?,
|
|
71
|
+
?tools: (Array[String] | ToolsPreset | Hash[Symbol | String, untyped] | String)?,
|
|
72
72
|
?sandbox: (SandboxSettings | Hash[Symbol | String, untyped] | bool)?,
|
|
73
73
|
?thinking: thinking_config?,
|
|
74
74
|
?effort: (String | Symbol | Integer)?,
|
|
@@ -133,8 +133,9 @@ module ClaudeAgentSDK
|
|
|
133
133
|
|
|
134
134
|
attr_accessor cli_path: (String | Pathname)?
|
|
135
135
|
|
|
136
|
-
# A settings JSON String, a path to a settings file
|
|
137
|
-
|
|
136
|
+
# A settings JSON String, a path to a settings file (a String or a
|
|
137
|
+
# Pathname), or a Hash.
|
|
138
|
+
attr_accessor settings: (String | Pathname | Hash[Symbol | String, untyped])?
|
|
138
139
|
|
|
139
140
|
attr_accessor add_dirs: Array[String | Pathname]?
|
|
140
141
|
|
|
@@ -185,10 +186,13 @@ module ClaudeAgentSDK
|
|
|
185
186
|
# Entries of SDK_BETAS.
|
|
186
187
|
attr_accessor betas: Array[String]?
|
|
187
188
|
|
|
188
|
-
# The base tool set: tool names, or
|
|
189
|
-
|
|
189
|
+
# The base tool set: tool names (an Array, or the CLI's comma-separated
|
|
190
|
+
# String such as "Read,Grep"), or a preset.
|
|
191
|
+
attr_accessor tools: (Array[String] | ToolsPreset | Hash[Symbol | String, untyped] | String)?
|
|
190
192
|
|
|
191
|
-
# true / false are forwarded as-is (a bare toggle).
|
|
193
|
+
# true / false are forwarded as-is (a bare toggle). A Hash may spell the
|
|
194
|
+
# fields of SandboxSettings, and of its network / filesystem, in
|
|
195
|
+
# snake_case or in the CLI's camelCase (see SandboxSettings).
|
|
192
196
|
attr_accessor sandbox: (SandboxSettings | Hash[Symbol | String, untyped] | bool)?
|
|
193
197
|
|
|
194
198
|
attr_accessor thinking: thinking_config?
|
|
@@ -41,7 +41,8 @@ module ClaudeAgentSDK
|
|
|
41
41
|
|
|
42
42
|
attr_accessor directories: Array[String]?
|
|
43
43
|
|
|
44
|
-
# One of PERMISSION_UPDATE_DESTINATIONS.
|
|
44
|
+
# One of PERMISSION_UPDATE_DESTINATIONS. When nil, #to_h sends "session"
|
|
45
|
+
# (unless type is nil too).
|
|
45
46
|
attr_accessor destination: String?
|
|
46
47
|
|
|
47
48
|
attr_reader rules: Array[PermissionRuleValue]?
|
|
@@ -49,7 +50,8 @@ module ClaudeAgentSDK
|
|
|
49
50
|
# Hash entries (camelCase or snake_case keys) become PermissionRuleValue.
|
|
50
51
|
def rules=: (Array[PermissionRuleValue | Hash[Symbol | String, untyped]]? value) -> Array[PermissionRuleValue | Hash[Symbol | String, untyped]]?
|
|
51
52
|
|
|
52
|
-
# The wire form (camelCase keys).
|
|
53
|
+
# The wire form (camelCase keys). A rule without content has no
|
|
54
|
+
# ruleContent key.
|
|
53
55
|
def to_h: () -> Hash[Symbol, untyped]
|
|
54
56
|
end
|
|
55
57
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: claude-agent-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ya-luotao
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: async
|
|
@@ -54,14 +54,14 @@ dependencies:
|
|
|
54
54
|
name: bundler
|
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
|
-
- - "
|
|
57
|
+
- - ">="
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: '2.0'
|
|
60
60
|
type: :development
|
|
61
61
|
prerelease: false
|
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
|
64
|
-
- - "
|
|
64
|
+
- - ">="
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
66
|
version: '2.0'
|
|
67
67
|
- !ruby/object:Gem::Dependency
|
|
@@ -118,6 +118,7 @@ executables: []
|
|
|
118
118
|
extensions: []
|
|
119
119
|
extra_rdoc_files: []
|
|
120
120
|
files:
|
|
121
|
+
- ".yardopts"
|
|
121
122
|
- CHANGELOG.md
|
|
122
123
|
- LICENSE
|
|
123
124
|
- README.md
|
|
@@ -129,6 +130,7 @@ files:
|
|
|
129
130
|
- docs/hooks-and-permissions.md
|
|
130
131
|
- docs/mcp-servers.md
|
|
131
132
|
- docs/observability.md
|
|
133
|
+
- docs/options.md
|
|
132
134
|
- docs/rails.md
|
|
133
135
|
- docs/sessions.md
|
|
134
136
|
- docs/subagents.md
|
|
@@ -146,10 +148,13 @@ files:
|
|
|
146
148
|
- lib/claude_agent_sdk/instrumentation/otel.rb
|
|
147
149
|
- lib/claude_agent_sdk/message_parser.rb
|
|
148
150
|
- lib/claude_agent_sdk/observer.rb
|
|
151
|
+
- lib/claude_agent_sdk/option_forms.rb
|
|
149
152
|
- lib/claude_agent_sdk/option_warnings.rb
|
|
150
153
|
- lib/claude_agent_sdk/query.rb
|
|
154
|
+
- lib/claude_agent_sdk/query/run_lifecycle.rb
|
|
151
155
|
- lib/claude_agent_sdk/railtie.rb
|
|
152
156
|
- lib/claude_agent_sdk/sdk_mcp_server.rb
|
|
157
|
+
- lib/claude_agent_sdk/session_assembly.rb
|
|
153
158
|
- lib/claude_agent_sdk/session_mutations.rb
|
|
154
159
|
- lib/claude_agent_sdk/session_resume.rb
|
|
155
160
|
- lib/claude_agent_sdk/session_store.rb
|