claude-agent-sdk 0.37.0 → 1.0.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 +17 -0
- data/README.md +6 -2
- data/UPGRADING-1.0.md +151 -0
- data/docs/errors.md +6 -0
- data/docs/sessions.md +20 -1
- data/docs/types.md +17 -14
- data/lib/claude_agent_sdk/deprecation.rb +1 -40
- data/lib/claude_agent_sdk/errors.rb +10 -0
- data/lib/claude_agent_sdk/session_resume.rb +11 -5
- 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/version.rb +1 -1
- data/lib/claude_agent_sdk.rb +11 -11
- 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 +288 -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 +22 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
module ClaudeAgentSDK
|
|
2
|
+
# McpServerStatus#status values.
|
|
3
|
+
MCP_SERVER_CONNECTION_STATUSES: Array[String]
|
|
4
|
+
|
|
5
|
+
# A ClaudeAgentOptions#mcp_servers value: a typed config, the Hash
|
|
6
|
+
# ClaudeAgentSDK.create_sdk_mcp_server returns, or any config Hash
|
|
7
|
+
# (Symbol or String keys).
|
|
8
|
+
type mcp_server_config = McpStdioServerConfig
|
|
9
|
+
| McpSSEServerConfig
|
|
10
|
+
| McpHttpServerConfig
|
|
11
|
+
| McpSdkServerConfig
|
|
12
|
+
| Hash[Symbol | String, untyped]
|
|
13
|
+
|
|
14
|
+
# ---- Typed view of Client#mcp_status (McpStatusResponse.parse) ----
|
|
15
|
+
|
|
16
|
+
class McpServerInfo < Type
|
|
17
|
+
attr_accessor name: String?
|
|
18
|
+
|
|
19
|
+
attr_accessor version: String?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class McpToolAnnotations < Type
|
|
23
|
+
attr_accessor read_only: bool?
|
|
24
|
+
|
|
25
|
+
attr_accessor destructive: bool?
|
|
26
|
+
|
|
27
|
+
attr_accessor open_world: bool?
|
|
28
|
+
|
|
29
|
+
def self.parse: (untyped data) -> McpToolAnnotations?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class McpToolInfo < Type
|
|
33
|
+
attr_accessor name: String?
|
|
34
|
+
|
|
35
|
+
attr_accessor description: String?
|
|
36
|
+
|
|
37
|
+
attr_reader annotations: McpToolAnnotations?
|
|
38
|
+
|
|
39
|
+
# A Hash is converted to McpToolAnnotations.
|
|
40
|
+
def annotations=: (McpToolAnnotations | Hash[Symbol | String, untyped] | nil value) -> (McpToolAnnotations | Hash[Symbol | String, untyped] | nil)
|
|
41
|
+
|
|
42
|
+
def self.parse: (untyped data) -> McpToolInfo?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# McpServerStatus#config for an SDK server.
|
|
46
|
+
class McpSdkServerConfigStatus < Type
|
|
47
|
+
attr_accessor name: String?
|
|
48
|
+
|
|
49
|
+
# "sdk".
|
|
50
|
+
attr_reader type: String
|
|
51
|
+
|
|
52
|
+
def to_h: () -> { type: String, name: String? }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# McpServerStatus#config for a claude.ai proxy server.
|
|
56
|
+
class McpClaudeAIProxyServerConfig < Type
|
|
57
|
+
attr_accessor url: String?
|
|
58
|
+
|
|
59
|
+
attr_accessor id: String?
|
|
60
|
+
|
|
61
|
+
# "claudeai-proxy".
|
|
62
|
+
attr_reader type: String
|
|
63
|
+
|
|
64
|
+
def to_h: () -> { type: String, url: String?, id: String? }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class McpServerStatus < Type
|
|
68
|
+
attr_accessor name: String?
|
|
69
|
+
|
|
70
|
+
# One of MCP_SERVER_CONNECTION_STATUSES.
|
|
71
|
+
attr_accessor status: String?
|
|
72
|
+
|
|
73
|
+
attr_accessor error: String?
|
|
74
|
+
|
|
75
|
+
attr_accessor scope: String?
|
|
76
|
+
|
|
77
|
+
attr_reader server_info: McpServerInfo?
|
|
78
|
+
|
|
79
|
+
# A typed config for SDK / claude.ai proxy servers; the raw wire_hash
|
|
80
|
+
# for any other type.
|
|
81
|
+
attr_reader config: (McpSdkServerConfigStatus | McpClaudeAIProxyServerConfig | wire_hash)?
|
|
82
|
+
|
|
83
|
+
attr_reader tools: Array[McpToolInfo]?
|
|
84
|
+
|
|
85
|
+
# A Hash is converted to McpServerInfo.
|
|
86
|
+
def server_info=: (McpServerInfo | Hash[Symbol | String, untyped] | nil value) -> (McpServerInfo | Hash[Symbol | String, untyped] | nil)
|
|
87
|
+
|
|
88
|
+
# Hash entries are converted to McpToolInfo.
|
|
89
|
+
def tools=: (Array[McpToolInfo | Hash[Symbol | String, untyped]]? value) -> Array[McpToolInfo | Hash[Symbol | String, untyped]]?
|
|
90
|
+
|
|
91
|
+
def config=: (McpSdkServerConfigStatus | McpClaudeAIProxyServerConfig | wire_hash | nil value) -> (McpSdkServerConfigStatus | McpClaudeAIProxyServerConfig | wire_hash | nil)
|
|
92
|
+
|
|
93
|
+
def self.parse: (untyped data) -> McpServerStatus?
|
|
94
|
+
|
|
95
|
+
# The typed config for a config wire_hash (nil for anything else).
|
|
96
|
+
def self.parse_config: (untyped config) -> (McpSdkServerConfigStatus | McpClaudeAIProxyServerConfig | wire_hash)?
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Typed view of the Client#mcp_status Hash:
|
|
100
|
+
# `McpStatusResponse.parse(client.mcp_status).mcp_servers`.
|
|
101
|
+
class McpStatusResponse < Type
|
|
102
|
+
attr_reader mcp_servers: Array[McpServerStatus]?
|
|
103
|
+
|
|
104
|
+
# Hash entries are converted to McpServerStatus.
|
|
105
|
+
def mcp_servers=: (Array[McpServerStatus | Hash[Symbol | String, untyped]]? value) -> Array[McpServerStatus | Hash[Symbol | String, untyped]]?
|
|
106
|
+
|
|
107
|
+
def self.parse: (untyped data) -> McpStatusResponse?
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# ---- Server configs (ClaudeAgentOptions#mcp_servers values) ----
|
|
111
|
+
#
|
|
112
|
+
# Built by the caller: keyword constructors (the Hash form is accepted
|
|
113
|
+
# too), an unknown key raises ArgumentError, and `type` is fixed by the
|
|
114
|
+
# class.
|
|
115
|
+
|
|
116
|
+
class McpStdioServerConfig < Type
|
|
117
|
+
def initialize: (?command: String?, ?args: Array[String]?, ?env: Hash[String | Symbol, String]?) -> void
|
|
118
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
119
|
+
|
|
120
|
+
attr_accessor command: String?
|
|
121
|
+
|
|
122
|
+
attr_accessor args: Array[String]?
|
|
123
|
+
|
|
124
|
+
attr_accessor env: Hash[String | Symbol, String]?
|
|
125
|
+
|
|
126
|
+
# "stdio".
|
|
127
|
+
attr_reader type: String
|
|
128
|
+
|
|
129
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
class McpSSEServerConfig < Type
|
|
133
|
+
def initialize: (?url: String?, ?headers: Hash[String | Symbol, String]?) -> void
|
|
134
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
135
|
+
|
|
136
|
+
attr_accessor url: String?
|
|
137
|
+
|
|
138
|
+
attr_accessor headers: Hash[String | Symbol, String]?
|
|
139
|
+
|
|
140
|
+
# "sse".
|
|
141
|
+
attr_reader type: String
|
|
142
|
+
|
|
143
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
class McpHttpServerConfig < Type
|
|
147
|
+
def initialize: (?url: String?, ?headers: Hash[String | Symbol, String]?) -> void
|
|
148
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
149
|
+
|
|
150
|
+
attr_accessor url: String?
|
|
151
|
+
|
|
152
|
+
attr_accessor headers: Hash[String | Symbol, String]?
|
|
153
|
+
|
|
154
|
+
# "http".
|
|
155
|
+
attr_reader type: String
|
|
156
|
+
|
|
157
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# The typed form of the create_sdk_mcp_server Hash.
|
|
161
|
+
class McpSdkServerConfig < Type
|
|
162
|
+
def initialize: (?name: String?, ?instance: SdkMcpServer?) -> void
|
|
163
|
+
| (Hash[Symbol | String, untyped]? attributes) -> void
|
|
164
|
+
|
|
165
|
+
attr_accessor name: String?
|
|
166
|
+
|
|
167
|
+
attr_accessor instance: SdkMcpServer?
|
|
168
|
+
|
|
169
|
+
# "sdk".
|
|
170
|
+
attr_reader type: String
|
|
171
|
+
|
|
172
|
+
def to_h: () -> { type: String, name: String?, instance: SdkMcpServer? }
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# ---- SDK MCP definitions (ClaudeAgentSDK.create_tool / _resource / _prompt) ----
|
|
176
|
+
|
|
177
|
+
class SdkMcpTool < Type
|
|
178
|
+
attr_accessor name: String?
|
|
179
|
+
|
|
180
|
+
attr_accessor description: String?
|
|
181
|
+
|
|
182
|
+
# A JSON Schema Hash, or the shorthand `{ param: :string, ... }`.
|
|
183
|
+
attr_accessor input_schema: Hash[untyped, untyped]?
|
|
184
|
+
|
|
185
|
+
attr_accessor handler: _ToolHandler?
|
|
186
|
+
|
|
187
|
+
# MCP tool annotations (readOnlyHint, ..., maxResultSizeChars).
|
|
188
|
+
attr_accessor annotations: Hash[Symbol | String, untyped]?
|
|
189
|
+
|
|
190
|
+
# The tool's _meta.
|
|
191
|
+
attr_accessor meta: Hash[String | Symbol, untyped]?
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
class SdkMcpResource < Type
|
|
195
|
+
attr_accessor uri: String?
|
|
196
|
+
|
|
197
|
+
attr_accessor name: String?
|
|
198
|
+
|
|
199
|
+
attr_accessor description: String?
|
|
200
|
+
|
|
201
|
+
attr_accessor mime_type: String?
|
|
202
|
+
|
|
203
|
+
attr_accessor reader: _ResourceReader?
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
class SdkMcpPrompt < Type
|
|
207
|
+
attr_accessor name: String?
|
|
208
|
+
|
|
209
|
+
attr_accessor description: String?
|
|
210
|
+
|
|
211
|
+
# { name:, description:, required: } Hashes.
|
|
212
|
+
attr_accessor arguments: Array[Hash[Symbol | String, untyped]]?
|
|
213
|
+
|
|
214
|
+
attr_accessor generator: _PromptGenerator?
|
|
215
|
+
end
|
|
216
|
+
end
|