claude_agent 0.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.
@@ -0,0 +1,912 @@
1
+ module ClaudeAgent
2
+ VERSION: String
3
+
4
+ # One-shot query to Claude Code CLI
5
+ def self.query: (
6
+ prompt: String,
7
+ ?options: Options?,
8
+ ?transport: Transport::Base?
9
+ ) -> Enumerator[message, void]
10
+
11
+ # Error classes
12
+ class Error < StandardError
13
+ end
14
+
15
+ class CLINotFoundError < Error
16
+ end
17
+
18
+ class CLIVersionError < Error
19
+ attr_reader required_version: String
20
+ attr_reader actual_version: String?
21
+
22
+ def initialize: (String message, ?required_version: String, ?actual_version: String?) -> void
23
+ end
24
+
25
+ class CLIConnectionError < Error
26
+ end
27
+
28
+ class ProcessError < Error
29
+ attr_reader exit_code: Integer?
30
+ attr_reader stderr: String?
31
+
32
+ def initialize: (String message, ?exit_code: Integer?, ?stderr: String?) -> void
33
+ end
34
+
35
+ class TimeoutError < Error
36
+ attr_reader request_id: String?
37
+ attr_reader timeout_seconds: Integer?
38
+
39
+ def initialize: (String message, ?request_id: String?, ?timeout_seconds: Integer?) -> void
40
+ end
41
+
42
+ class ConfigurationError < Error
43
+ end
44
+
45
+ class JSONDecodeError < Error
46
+ attr_reader raw_data: String?
47
+
48
+ def initialize: (String message, ?raw_data: String?) -> void
49
+ end
50
+
51
+ class MessageParseError < Error
52
+ attr_reader raw_message: Hash[String, untyped]?
53
+
54
+ def initialize: (String message, ?raw_message: Hash[String, untyped]?) -> void
55
+ end
56
+
57
+ class AbortError < Error
58
+ def initialize: (?String message) -> void
59
+ end
60
+
61
+ # Abort controller for cancelling operations (TypeScript SDK parity)
62
+ class AbortController
63
+ attr_reader signal: AbortSignal
64
+
65
+ def initialize: () -> void
66
+ def abort: (?String? reason) -> void
67
+ end
68
+
69
+ # Abort signal for tracking abort state (TypeScript SDK parity)
70
+ class AbortSignal
71
+ def initialize: () -> void
72
+ def aborted?: () -> bool
73
+ def reason: () -> String?
74
+ def on_abort: () { (String?) -> void } -> void
75
+ def wait: (?timeout: Numeric?) -> bool
76
+ def check!: () -> void
77
+ def abort!: (?String? reason) -> void
78
+ end
79
+
80
+ # TypeScript SDK parity types
81
+ ASSISTANT_MESSAGE_ERROR_TYPES: Array[String]
82
+ API_KEY_SOURCES: Array[String]
83
+ class SlashCommand
84
+ attr_reader name: String
85
+ attr_reader description: String?
86
+ attr_reader argument_hint: String?
87
+
88
+ def initialize: (name: String, ?description: String?, ?argument_hint: String?) -> void
89
+ end
90
+
91
+ class ModelInfo
92
+ attr_reader value: String
93
+ attr_reader display_name: String?
94
+ attr_reader description: String?
95
+
96
+ def initialize: (value: String, ?display_name: String?, ?description: String?) -> void
97
+ end
98
+
99
+ class McpServerStatus
100
+ attr_reader name: String
101
+ attr_reader status: String
102
+ attr_reader server_info: Hash[String, untyped]?
103
+
104
+ def initialize: (name: String, status: String, ?server_info: Hash[String, untyped]?) -> void
105
+ end
106
+
107
+ class AccountInfo
108
+ attr_reader email: String?
109
+ attr_reader organization: String?
110
+ attr_reader subscription_type: String?
111
+ attr_reader token_source: String?
112
+ attr_reader api_key_source: String?
113
+
114
+ def initialize: (?email: String?, ?organization: String?, ?subscription_type: String?, ?token_source: String?, ?api_key_source: String?) -> void
115
+ end
116
+
117
+ class ModelUsage
118
+ attr_reader input_tokens: Integer
119
+ attr_reader output_tokens: Integer
120
+ attr_reader cache_read_input_tokens: Integer
121
+ attr_reader cache_creation_input_tokens: Integer
122
+ attr_reader web_search_requests: Integer
123
+ attr_reader cost_usd: Float
124
+ attr_reader context_window: Integer?
125
+
126
+ def initialize: (?input_tokens: Integer, ?output_tokens: Integer, ?cache_read_input_tokens: Integer, ?cache_creation_input_tokens: Integer, ?web_search_requests: Integer, ?cost_usd: Float, ?context_window: Integer?) -> void
127
+ end
128
+
129
+ class SDKPermissionDenial
130
+ attr_reader tool_name: String
131
+ attr_reader tool_use_id: String
132
+ attr_reader tool_input: Hash[String, untyped]
133
+
134
+ def initialize: (tool_name: String, tool_use_id: String, tool_input: Hash[String, untyped]) -> void
135
+ end
136
+
137
+ # Result of set_mcp_servers() control method (TypeScript SDK parity)
138
+ class McpSetServersResult
139
+ attr_reader added: Array[String]
140
+ attr_reader removed: Array[String]
141
+ attr_reader errors: Hash[String, String]
142
+
143
+ def initialize: (?added: Array[String], ?removed: Array[String], ?errors: Hash[String, String]) -> void
144
+ end
145
+
146
+ # Result of rewind_files() control method (TypeScript SDK parity)
147
+ class RewindFilesResult
148
+ attr_reader can_rewind: bool
149
+ attr_reader error: String?
150
+ attr_reader files_changed: Array[String]?
151
+ attr_reader insertions: Integer?
152
+ attr_reader deletions: Integer?
153
+
154
+ def initialize: (can_rewind: bool, ?error: String?, ?files_changed: Array[String]?, ?insertions: Integer?, ?deletions: Integer?) -> void
155
+ end
156
+
157
+ # Agent definition for custom subagents (TypeScript SDK parity)
158
+ class AgentDefinition
159
+ attr_reader description: String
160
+ attr_reader prompt: String
161
+ attr_reader tools: Array[String]?
162
+ attr_reader disallowed_tools: Array[String]?
163
+ attr_reader model: String?
164
+ attr_reader mcp_servers: Hash[String, untyped]?
165
+ attr_reader critical_system_reminder: String?
166
+
167
+ def initialize: (description: String, prompt: String, ?tools: Array[String]?, ?disallowed_tools: Array[String]?, ?model: String?, ?mcp_servers: Hash[String, untyped]?, ?critical_system_reminder: String?) -> void
168
+ def to_h: () -> Hash[Symbol, untyped]
169
+ end
170
+
171
+ # Sandbox configuration types
172
+ class SandboxNetworkConfig
173
+ attr_reader allowed_domains: Array[String]
174
+ attr_reader allow_local_binding: bool
175
+ attr_reader allow_unix_sockets: Array[String]
176
+ attr_reader allow_all_unix_sockets: bool
177
+ attr_reader http_proxy_port: Integer?
178
+ attr_reader socks_proxy_port: Integer?
179
+
180
+ def initialize: (?allowed_domains: Array[String], ?allow_local_binding: bool, ?allow_unix_sockets: Array[String], ?allow_all_unix_sockets: bool, ?http_proxy_port: Integer?, ?socks_proxy_port: Integer?) -> void
181
+ def to_h: () -> Hash[Symbol, untyped]
182
+ end
183
+
184
+ class SandboxRipgrepConfig
185
+ attr_reader command: String
186
+ attr_reader args: Array[String]?
187
+
188
+ def initialize: (command: String, ?args: Array[String]?) -> void
189
+ def to_h: () -> Hash[Symbol, untyped]
190
+ end
191
+
192
+ class SandboxIgnoreViolations
193
+ attr_reader file: Array[String]
194
+ attr_reader network: Array[String]
195
+
196
+ def initialize: (?file: Array[String], ?network: Array[String]) -> void
197
+ def to_h: () -> Hash[Symbol, untyped]
198
+ end
199
+
200
+ class SandboxSettings
201
+ attr_reader enabled: bool
202
+ attr_reader auto_allow_bash_if_sandboxed: bool
203
+ attr_reader excluded_commands: Array[String]
204
+ attr_reader allow_unsandboxed_commands: bool
205
+ attr_reader network: SandboxNetworkConfig?
206
+ attr_reader ignore_violations: SandboxIgnoreViolations?
207
+ attr_reader enable_weaker_nested_sandbox: bool
208
+ attr_reader ripgrep: SandboxRipgrepConfig?
209
+
210
+ def initialize: (?enabled: bool, ?auto_allow_bash_if_sandboxed: bool, ?excluded_commands: Array[String], ?allow_unsandboxed_commands: bool, ?network: SandboxNetworkConfig?, ?ignore_violations: SandboxIgnoreViolations?, ?enable_weaker_nested_sandbox: bool, ?ripgrep: SandboxRipgrepConfig?) -> void
211
+ def to_h: () -> Hash[Symbol, untyped]
212
+ end
213
+
214
+ # Tools preset configuration
215
+ class ToolsPreset
216
+ attr_reader type: String
217
+ attr_reader preset: String
218
+
219
+ def initialize: (?type: String, ?preset: String) -> void
220
+ def to_h: () -> Hash[Symbol, untyped]
221
+ end
222
+
223
+ # Permission modes
224
+ PERMISSION_MODES: Array[String]
225
+
226
+ # Options for configuring Claude Code CLI
227
+ class Options
228
+ # Constants
229
+ DEFAULTS: Hash[Symbol, untyped]
230
+ ATTRIBUTES: Array[Symbol]
231
+
232
+ # Tool configuration
233
+ attr_accessor tools: (Array[String] | String)?
234
+ attr_accessor allowed_tools: Array[String]
235
+ attr_accessor disallowed_tools: Array[String]
236
+
237
+ # System prompt
238
+ attr_accessor system_prompt: (String | Hash[Symbol, untyped])?
239
+ attr_accessor append_system_prompt: String?
240
+
241
+ # Model selection
242
+ attr_accessor model: String?
243
+ attr_accessor fallback_model: String?
244
+
245
+ # Permission control
246
+ attr_accessor permission_mode: String?
247
+ attr_accessor permission_prompt_tool_name: String?
248
+ attr_accessor can_use_tool: (^(String, Hash[String, untyped], untyped) -> permission_result)?
249
+ attr_accessor allow_dangerously_skip_permissions: bool
250
+
251
+ # Conversation flow
252
+ attr_accessor continue_conversation: bool
253
+ attr_accessor resume: String?
254
+ attr_accessor fork_session: bool
255
+ attr_accessor resume_session_at: String?
256
+ attr_accessor persist_session: bool
257
+
258
+ # Limits & budget
259
+ attr_accessor max_turns: Integer?
260
+ attr_accessor max_budget_usd: Float?
261
+ attr_accessor max_thinking_tokens: Integer?
262
+
263
+ # Strict validation
264
+ attr_accessor strict_mcp_config: bool
265
+
266
+ # MCP servers
267
+ attr_accessor mcp_servers: Hash[String, Hash[Symbol, untyped]]
268
+
269
+ # Hooks
270
+ attr_accessor hooks: Hash[String, Array[HookMatcher]]?
271
+
272
+ # Settings & sandbox
273
+ attr_accessor settings: String?
274
+ attr_accessor sandbox: SandboxSettings?
275
+
276
+ # Environment
277
+ attr_accessor cwd: String?
278
+ attr_accessor add_dirs: Array[String]
279
+ attr_accessor env: Hash[String, String]
280
+ attr_accessor user: String?
281
+
282
+ # CLI configuration
283
+ attr_accessor cli_path: String?
284
+ attr_accessor extra_args: Hash[String | Symbol, String?]
285
+
286
+ # Advanced features
287
+ attr_accessor agents: Hash[String, untyped]?
288
+ attr_accessor setting_sources: Array[String]?
289
+ attr_accessor plugins: Array[String | Hash[Symbol, String]]
290
+
291
+ # Output & streaming
292
+ attr_accessor include_partial_messages: bool
293
+ attr_accessor output_format: Hash[String, untyped]?
294
+ attr_accessor enable_file_checkpointing: bool
295
+
296
+ # Beta features
297
+ attr_accessor betas: Array[String]
298
+
299
+ # Buffering & debugging
300
+ attr_accessor max_buffer_size: Integer?
301
+ attr_accessor stderr_callback: (^(String) -> void)?
302
+
303
+ # Abort control (TypeScript SDK parity)
304
+ attr_accessor abort_controller: AbortController?
305
+
306
+ # Custom spawn function (TypeScript SDK parity)
307
+ attr_accessor spawn_claude_code_process: (^(Array[String], Hash[Symbol, untyped]) -> untyped)?
308
+
309
+ def initialize: (**untyped kwargs) -> void
310
+ def to_cli_args: () -> Array[String]
311
+ def to_env: () -> Hash[String, String]
312
+ def has_hooks?: () -> bool
313
+ def has_sdk_mcp_servers?: () -> bool
314
+ def abort_signal: () -> AbortSignal?
315
+ end
316
+
317
+ # Content block types
318
+ class TextBlock
319
+ attr_reader text: String
320
+
321
+ def initialize: (text: String) -> void
322
+ def type: () -> :text
323
+ def to_h: () -> Hash[Symbol, untyped]
324
+ end
325
+
326
+ class ThinkingBlock
327
+ attr_reader thinking: String
328
+ attr_reader signature: String?
329
+
330
+ def initialize: (thinking: String, ?signature: String?) -> void
331
+ def type: () -> :thinking
332
+ def to_h: () -> Hash[Symbol, untyped]
333
+ end
334
+
335
+ class ToolUseBlock
336
+ attr_reader id: String
337
+ attr_reader name: String
338
+ attr_reader input: Hash[String, untyped]
339
+
340
+ def initialize: (id: String, name: String, input: Hash[String, untyped]) -> void
341
+ def type: () -> :tool_use
342
+ def to_h: () -> Hash[Symbol, untyped]
343
+ end
344
+
345
+ class ToolResultBlock
346
+ attr_reader tool_use_id: String
347
+ attr_reader content: String?
348
+ attr_reader is_error: bool?
349
+
350
+ def initialize: (tool_use_id: String, ?content: String?, ?is_error: bool?) -> void
351
+ def type: () -> :tool_result
352
+ def to_h: () -> Hash[Symbol, untyped]
353
+ end
354
+
355
+ class ServerToolUseBlock
356
+ attr_reader id: String
357
+ attr_reader name: String
358
+ attr_reader input: Hash[String, untyped]
359
+ attr_reader server_name: String
360
+
361
+ def initialize: (id: String, name: String, input: Hash[String, untyped], server_name: String) -> void
362
+ def type: () -> :server_tool_use
363
+ def to_h: () -> Hash[Symbol, untyped]
364
+ end
365
+
366
+ class ServerToolResultBlock
367
+ attr_reader tool_use_id: String
368
+ attr_reader server_name: String
369
+ attr_reader content: String?
370
+ attr_reader is_error: bool?
371
+
372
+ def initialize: (tool_use_id: String, server_name: String, ?content: String?, ?is_error: bool?) -> void
373
+ def type: () -> :server_tool_result
374
+ def to_h: () -> Hash[Symbol, untyped]
375
+ end
376
+
377
+ class ImageContentBlock
378
+ attr_reader source: Hash[String | Symbol, untyped]
379
+
380
+ def initialize: (source: Hash[String | Symbol, untyped]) -> void
381
+ def type: () -> :image
382
+ def source_type: () -> String?
383
+ def media_type: () -> String?
384
+ def data: () -> String?
385
+ def url: () -> String?
386
+ def to_h: () -> Hash[Symbol, untyped]
387
+ end
388
+
389
+ type content_block = TextBlock | ThinkingBlock | ToolUseBlock | ToolResultBlock | ServerToolUseBlock | ServerToolResultBlock | ImageContentBlock
390
+
391
+ CONTENT_BLOCK_TYPES: Array[Class]
392
+
393
+ # Message types
394
+ type message = UserMessage | UserMessageReplay | AssistantMessage | SystemMessage | ResultMessage | StreamEvent | CompactBoundaryMessage | StatusMessage | ToolProgressMessage | HookResponseMessage | AuthStatusMessage
395
+
396
+ MESSAGE_TYPES: Array[Class]
397
+
398
+ class UserMessage
399
+ attr_reader content: String | Array[content_block]
400
+ attr_reader uuid: String?
401
+ attr_reader session_id: String?
402
+ attr_reader parent_tool_use_id: String?
403
+
404
+ def initialize: (content: String | Array[content_block], ?uuid: String?, ?session_id: String?, ?parent_tool_use_id: String?) -> void
405
+ def type: () -> :user
406
+ def text: () -> String?
407
+ def replay?: () -> bool
408
+ end
409
+
410
+ class UserMessageReplay
411
+ attr_reader content: String | Array[content_block]
412
+ attr_reader uuid: String?
413
+ attr_reader session_id: String?
414
+ attr_reader parent_tool_use_id: String?
415
+ attr_reader is_replay: bool
416
+ attr_reader is_synthetic: bool?
417
+ attr_reader tool_use_result: untyped
418
+
419
+ def initialize: (content: String | Array[content_block], ?uuid: String?, ?session_id: String?, ?parent_tool_use_id: String?, ?is_replay: bool, ?is_synthetic: bool?, ?tool_use_result: untyped) -> void
420
+ def type: () -> :user
421
+ def text: () -> String?
422
+ def replay?: () -> bool
423
+ def synthetic?: () -> bool
424
+ end
425
+
426
+ class AssistantMessage
427
+ attr_reader content: Array[content_block]
428
+ attr_reader model: String
429
+ attr_reader uuid: String?
430
+ attr_reader session_id: String?
431
+ attr_reader error: String?
432
+ attr_reader parent_tool_use_id: String?
433
+
434
+ def initialize: (content: Array[content_block], model: String, ?uuid: String?, ?session_id: String?, ?error: String?, ?parent_tool_use_id: String?) -> void
435
+ def type: () -> :assistant
436
+ def text: () -> String
437
+ def thinking: () -> String
438
+ def tool_uses: () -> Array[ToolUseBlock]
439
+ def has_tool_use?: () -> bool
440
+ end
441
+
442
+ class SystemMessage
443
+ attr_reader subtype: String
444
+ attr_reader data: Hash[String, untyped]
445
+
446
+ def initialize: (subtype: String, data: Hash[String, untyped]) -> void
447
+ def type: () -> :system
448
+ end
449
+
450
+ class ResultMessage
451
+ attr_reader subtype: String
452
+ attr_reader duration_ms: Integer
453
+ attr_reader duration_api_ms: Integer
454
+ attr_reader is_error: bool
455
+ attr_reader num_turns: Integer
456
+ attr_reader session_id: String
457
+ attr_reader total_cost_usd: Float?
458
+ attr_reader usage: Hash[String, untyped]?
459
+ attr_reader result: String?
460
+ attr_reader structured_output: untyped
461
+ attr_reader errors: Array[String]?
462
+ attr_reader permission_denials: Array[SDKPermissionDenial]?
463
+ attr_reader model_usage: Hash[String, untyped]?
464
+
465
+ def initialize: (
466
+ subtype: String,
467
+ duration_ms: Integer,
468
+ duration_api_ms: Integer,
469
+ is_error: bool,
470
+ num_turns: Integer,
471
+ session_id: String,
472
+ ?total_cost_usd: Float?,
473
+ ?usage: Hash[String, untyped]?,
474
+ ?result: String?,
475
+ ?structured_output: untyped,
476
+ ?errors: Array[String]?,
477
+ ?permission_denials: Array[SDKPermissionDenial]?,
478
+ ?model_usage: Hash[String, untyped]?
479
+ ) -> void
480
+
481
+ def type: () -> :result
482
+ def success?: () -> bool
483
+ def error?: () -> bool
484
+ end
485
+
486
+ class StreamEvent
487
+ attr_reader uuid: String
488
+ attr_reader session_id: String
489
+ attr_reader event: Hash[String, untyped]
490
+ attr_reader parent_tool_use_id: String?
491
+
492
+ def initialize: (uuid: String, session_id: String, event: Hash[String, untyped], ?parent_tool_use_id: String?) -> void
493
+ def type: () -> :stream_event
494
+ def event_type: () -> String?
495
+ end
496
+
497
+ class CompactBoundaryMessage
498
+ attr_reader uuid: String
499
+ attr_reader session_id: String
500
+ attr_reader compact_metadata: Hash[String | Symbol, untyped]
501
+
502
+ def initialize: (uuid: String, session_id: String, compact_metadata: Hash[String | Symbol, untyped]) -> void
503
+ def type: () -> :compact_boundary
504
+ def trigger: () -> String?
505
+ def pre_tokens: () -> Integer?
506
+ end
507
+
508
+ # Status message (TypeScript SDK parity)
509
+ class StatusMessage
510
+ attr_reader uuid: String
511
+ attr_reader session_id: String
512
+ attr_reader status: String
513
+
514
+ def initialize: (uuid: String, session_id: String, status: String) -> void
515
+ def type: () -> :status
516
+ end
517
+
518
+ # Tool progress message (TypeScript SDK parity)
519
+ class ToolProgressMessage
520
+ attr_reader uuid: String
521
+ attr_reader session_id: String
522
+ attr_reader tool_use_id: String
523
+ attr_reader tool_name: String
524
+ attr_reader parent_tool_use_id: String?
525
+ attr_reader elapsed_time_seconds: Float
526
+
527
+ def initialize: (uuid: String, session_id: String, tool_use_id: String, tool_name: String, elapsed_time_seconds: Float, ?parent_tool_use_id: String?) -> void
528
+ def type: () -> :tool_progress
529
+ end
530
+
531
+ # Hook response message (TypeScript SDK parity)
532
+ class HookResponseMessage
533
+ attr_reader uuid: String
534
+ attr_reader session_id: String
535
+ attr_reader hook_name: String
536
+ attr_reader hook_event: String
537
+ attr_reader stdout: String
538
+ attr_reader stderr: String
539
+ attr_reader exit_code: Integer?
540
+
541
+ def initialize: (uuid: String, session_id: String, hook_name: String, hook_event: String, ?stdout: String, ?stderr: String, ?exit_code: Integer?) -> void
542
+ def type: () -> :hook_response
543
+ end
544
+
545
+ # Auth status message (TypeScript SDK parity)
546
+ class AuthStatusMessage
547
+ attr_reader uuid: String
548
+ attr_reader session_id: String
549
+ attr_reader is_authenticating: bool
550
+ attr_reader output: Array[String]
551
+ attr_reader error: String?
552
+
553
+ def initialize: (uuid: String, session_id: String, is_authenticating: bool, ?output: Array[String], ?error: String?) -> void
554
+ def type: () -> :auth_status
555
+ end
556
+
557
+ # Message parser
558
+ class MessageParser
559
+ def initialize: () -> void
560
+ def parse: (Hash[String, untyped] raw) -> message
561
+ end
562
+
563
+ # Hook types
564
+ HOOK_EVENTS: Array[String]
565
+
566
+ class HookMatcher
567
+ attr_reader matcher: String | Regexp
568
+ attr_reader callbacks: Array[^(BaseHookInput, HookContext) -> Hash[Symbol, untyped]]
569
+ attr_reader timeout: Integer?
570
+
571
+ def initialize: (matcher: String | Regexp, callbacks: Array[^(BaseHookInput, HookContext) -> Hash[Symbol, untyped]], ?timeout: Integer?) -> void
572
+ def matches?: (String tool_name) -> bool
573
+ end
574
+
575
+ class HookContext
576
+ attr_reader tool_use_id: String?
577
+
578
+ def initialize: (?tool_use_id: String?) -> void
579
+ end
580
+
581
+ class BaseHookInput
582
+ attr_reader hook_event_name: String
583
+ attr_reader session_id: String?
584
+ attr_reader transcript_path: String?
585
+ attr_reader cwd: String?
586
+ attr_reader permission_mode: String?
587
+
588
+ def initialize: (hook_event_name: String, ?session_id: String?, ?transcript_path: String?, ?cwd: String?, ?permission_mode: String?, **untyped) -> void
589
+ end
590
+
591
+ class PreToolUseInput < BaseHookInput
592
+ attr_reader tool_name: String
593
+ attr_reader tool_input: Hash[String, untyped]
594
+ attr_reader tool_use_id: String?
595
+
596
+ def initialize: (tool_name: String, tool_input: Hash[String, untyped], ?tool_use_id: String?, **untyped) -> void
597
+ end
598
+
599
+ class PostToolUseInput < BaseHookInput
600
+ attr_reader tool_name: String
601
+ attr_reader tool_input: Hash[String, untyped]
602
+ attr_reader tool_response: untyped
603
+ attr_reader tool_use_id: String?
604
+
605
+ def initialize: (tool_name: String, tool_input: Hash[String, untyped], tool_response: untyped, ?tool_use_id: String?, **untyped) -> void
606
+ end
607
+
608
+ class PostToolUseFailureInput < BaseHookInput
609
+ attr_reader tool_name: String
610
+ attr_reader tool_input: Hash[String, untyped]
611
+ attr_reader tool_use_id: String?
612
+ attr_reader error: String
613
+ attr_reader is_interrupt: bool?
614
+
615
+ def initialize: (tool_name: String, tool_input: Hash[String, untyped], error: String, ?tool_use_id: String?, ?is_interrupt: bool?, **untyped) -> void
616
+ end
617
+
618
+ class NotificationInput < BaseHookInput
619
+ attr_reader message: String
620
+ attr_reader title: String?
621
+ attr_reader notification_type: String?
622
+
623
+ def initialize: (message: String, ?title: String?, ?notification_type: String?, **untyped) -> void
624
+ end
625
+
626
+ class UserPromptSubmitInput < BaseHookInput
627
+ attr_reader prompt: String
628
+
629
+ def initialize: (prompt: String, **untyped) -> void
630
+ end
631
+
632
+ class SessionStartInput < BaseHookInput
633
+ attr_reader source: String
634
+ attr_reader agent_type: String?
635
+
636
+ def initialize: (source: String, ?agent_type: String?, **untyped) -> void
637
+ end
638
+
639
+ class SessionEndInput < BaseHookInput
640
+ attr_reader reason: String
641
+
642
+ def initialize: (reason: String, **untyped) -> void
643
+ end
644
+
645
+ class StopInput < BaseHookInput
646
+ attr_reader stop_hook_active: bool
647
+
648
+ def initialize: (?stop_hook_active: bool, **untyped) -> void
649
+ end
650
+
651
+ class SubagentStartInput < BaseHookInput
652
+ attr_reader agent_id: String
653
+ attr_reader agent_type: String
654
+
655
+ def initialize: (agent_id: String, agent_type: String, **untyped) -> void
656
+ end
657
+
658
+ class SubagentStopInput < BaseHookInput
659
+ attr_reader stop_hook_active: bool
660
+ attr_reader agent_id: String?
661
+ attr_reader agent_transcript_path: String?
662
+
663
+ def initialize: (?stop_hook_active: bool, ?agent_id: String?, ?agent_transcript_path: String?, **untyped) -> void
664
+ end
665
+
666
+ class PreCompactInput < BaseHookInput
667
+ attr_reader trigger: String
668
+ attr_reader custom_instructions: String?
669
+
670
+ def initialize: (trigger: String, ?custom_instructions: String?, **untyped) -> void
671
+ end
672
+
673
+ class PermissionRequestInput < BaseHookInput
674
+ attr_reader tool_name: String
675
+ attr_reader tool_input: Hash[String, untyped]
676
+ attr_reader permission_suggestions: untyped
677
+
678
+ def initialize: (tool_name: String, tool_input: Hash[String, untyped], ?permission_suggestions: untyped, **untyped) -> void
679
+ end
680
+
681
+ # Permission types
682
+ type permission_result = PermissionResultAllow | PermissionResultDeny
683
+
684
+ PERMISSION_UPDATE_TYPES: Array[String]
685
+ PERMISSION_UPDATE_DESTINATIONS: Array[String]
686
+
687
+ class PermissionResultAllow
688
+ attr_reader updated_input: Hash[String, untyped]?
689
+ attr_reader updated_permissions: Array[PermissionUpdate]?
690
+
691
+ def initialize: (?updated_input: Hash[String, untyped]?, ?updated_permissions: Array[PermissionUpdate]?) -> void
692
+ def behavior: () -> "allow"
693
+ def to_h: () -> Hash[Symbol, untyped]
694
+ end
695
+
696
+ class PermissionResultDeny
697
+ attr_reader message: String
698
+ attr_reader interrupt: bool
699
+
700
+ def initialize: (?message: String, ?interrupt: bool) -> void
701
+ def behavior: () -> "deny"
702
+ def to_h: () -> Hash[Symbol, untyped]
703
+ end
704
+
705
+ class PermissionUpdate
706
+ attr_reader type: String
707
+ attr_reader rules: Array[PermissionRuleValue]?
708
+ attr_reader behavior: String?
709
+ attr_reader mode: String?
710
+ attr_reader directories: Array[String]?
711
+ attr_reader destination: String?
712
+
713
+ def initialize: (type: String, ?rules: Array[PermissionRuleValue]?, ?behavior: String?, ?mode: String?, ?directories: Array[String]?, ?destination: String?) -> void
714
+ def to_h: () -> Hash[Symbol, untyped]
715
+ end
716
+
717
+ class PermissionRuleValue
718
+ attr_reader tool_name: String?
719
+ attr_reader rule_content: String?
720
+
721
+ def initialize: (?tool_name: String?, ?rule_content: String?) -> void
722
+ def to_h: () -> Hash[Symbol, untyped]
723
+ end
724
+
725
+ class ToolPermissionContext
726
+ attr_reader permission_suggestions: untyped
727
+ attr_reader blocked_path: String?
728
+ attr_reader decision_reason: String?
729
+ attr_reader tool_use_id: String?
730
+ attr_reader agent_id: String?
731
+
732
+ def initialize: (?permission_suggestions: untyped, ?blocked_path: String?, ?decision_reason: String?, ?tool_use_id: String?, ?agent_id: String?) -> void
733
+ end
734
+
735
+ # Client
736
+ class Client
737
+ attr_reader options: Options
738
+ attr_reader transport: Transport::Base
739
+ attr_reader server_info: Hash[String, untyped]?
740
+
741
+ def self.open: (?options: Options?, ?transport: Transport::Base?, ?prompt: String?) { (Client) -> void } -> void
742
+
743
+ def initialize: (?options: Options?, ?transport: Transport::Base?) -> void
744
+ def connect: (?prompt: String?) -> void
745
+ def disconnect: () -> void
746
+ def connected?: () -> bool
747
+ def send_message: (String | Array[content_block] content, ?session_id: String, ?uuid: String?) -> void
748
+ alias query send_message
749
+ def receive_messages: () { (message) -> void } -> void
750
+ | () -> Enumerator[message, void]
751
+ def receive_response: () { (message) -> void } -> void
752
+ | () -> Enumerator[message, void]
753
+ def stream_input: (Enumerable[String | Hash[String, untyped] | UserMessage] stream, ?session_id: String) -> void
754
+ | (Enumerable[String | Hash[String, untyped] | UserMessage] stream, ?session_id: String) { (message) -> void } -> void
755
+ def interrupt: () -> void
756
+ def abort!: (?String? reason) -> void
757
+ def set_permission_mode: (String mode) -> Hash[String, untyped]
758
+ def set_model: (String? model) -> Hash[String, untyped]
759
+ def rewind_files: (String user_message_id, ?dry_run: bool) -> RewindFilesResult
760
+ def set_max_thinking_tokens: (Integer? tokens) -> Hash[String, untyped]
761
+ def set_mcp_servers: (Hash[String, untyped] servers) -> McpSetServersResult
762
+ def supported_commands: () -> Array[SlashCommand]
763
+ def supported_models: () -> Array[ModelInfo]
764
+ def mcp_server_status: () -> Array[McpServerStatus]
765
+ def account_info: () -> AccountInfo
766
+ end
767
+
768
+ # Control protocol
769
+ class ControlProtocol
770
+ DEFAULT_TIMEOUT: Integer
771
+ REQUEST_ID_PREFIX: String
772
+ HOOK_RESPONSE_KEYS: Hash[Symbol, String]
773
+
774
+ attr_reader transport: Transport::Base
775
+ attr_reader options: Options
776
+ attr_reader server_info: Hash[String, untyped]?
777
+
778
+ def initialize: (transport: Transport::Base, ?options: Options?) -> void
779
+ def start: (?streaming: bool, ?prompt: String?) -> Hash[String, untyped]?
780
+ def stop: () -> void
781
+ def abort!: () -> void
782
+ def send_user_message: (String | Array[content_block] content, ?session_id: String, ?uuid: String?) -> void
783
+ def each_message: () { (message) -> void } -> void
784
+ | () -> Enumerator[message, void]
785
+ def receive_response: () { (message) -> void } -> void
786
+ | () -> Enumerator[message, void]
787
+ def stream_input: (Enumerable[String | Hash[String, untyped] | UserMessage] stream, ?session_id: String) -> void
788
+ def stream_conversation: (Enumerable[String | Hash[String, untyped] | UserMessage] stream, ?session_id: String) { (message) -> void } -> void
789
+ def interrupt: () -> void
790
+ def set_permission_mode: (String mode) -> Hash[String, untyped]
791
+ def set_model: (String? model) -> Hash[String, untyped]
792
+ def rewind_files: (String user_message_id, ?dry_run: bool) -> RewindFilesResult
793
+ def set_max_thinking_tokens: (Integer? tokens) -> Hash[String, untyped]
794
+ def set_mcp_servers: (Hash[String, untyped] servers) -> McpSetServersResult
795
+ def supported_commands: () -> Array[SlashCommand]
796
+ def supported_models: () -> Array[ModelInfo]
797
+ def mcp_server_status: () -> Array[McpServerStatus]
798
+ def account_info: () -> AccountInfo
799
+ end
800
+
801
+ # Transport layer
802
+ module Transport
803
+ class Base
804
+ def connect: (?streaming: bool, ?prompt: String?) -> void
805
+ def close: () -> void
806
+ def connected?: () -> bool
807
+ def ready?: () -> bool
808
+ def write: (String data) -> void
809
+ def read_messages: () { (Hash[String, untyped]) -> void } -> void
810
+ | () -> Enumerator[Hash[String, untyped], void]
811
+ def end_input: () -> void
812
+ end
813
+
814
+ class Subprocess < Base
815
+ attr_reader cli_path: String
816
+ attr_reader options: Options
817
+
818
+ def initialize: (?options: Options?, ?cli_path: String?) -> void
819
+ def connect: (?streaming: bool, ?prompt: String?) -> void
820
+ def close: () -> void
821
+ def connected?: () -> bool
822
+ def ready?: () -> bool
823
+ def write: (String data) -> void
824
+ def read_messages: () { (Hash[String, untyped]) -> void } -> void
825
+ | () -> Enumerator[Hash[String, untyped], void]
826
+ def end_input: () -> void
827
+ end
828
+ end
829
+
830
+ # Spawn options for custom process creation (TypeScript SDK parity)
831
+ class SpawnOptions
832
+ attr_reader command: String
833
+ attr_reader args: Array[String]
834
+ attr_reader cwd: String?
835
+ attr_reader env: Hash[String, String]
836
+ attr_reader abort_signal: AbortSignal?
837
+
838
+ def initialize: (command: String, ?args: Array[String], ?cwd: String?, ?env: Hash[String, String], ?abort_signal: AbortSignal?) -> void
839
+ def to_command_array: () -> Array[String]
840
+ end
841
+
842
+ # Interface for spawned processes (TypeScript SDK parity)
843
+ module SpawnedProcess
844
+ def write: (String data) -> void
845
+ def read_stdout: () { (String) -> void } -> void
846
+ | () -> Enumerator[String, void]
847
+ def read_stderr: () { (String) -> void } -> void
848
+ | () -> Enumerator[String, void]
849
+ def close_stdin: () -> void
850
+ def terminate: (?timeout: Numeric) -> void
851
+ def kill: () -> void
852
+ def running?: () -> bool
853
+ def exit_status: () -> Integer?
854
+ def close: () -> void
855
+ end
856
+
857
+ # Local spawned process using Open3.popen3 (TypeScript SDK parity)
858
+ class LocalSpawnedProcess
859
+ include SpawnedProcess
860
+
861
+ attr_reader pid: Integer?
862
+ attr_reader stdin: IO
863
+ attr_reader stdout: IO
864
+ attr_reader stderr: IO
865
+ attr_reader wait_thread: Thread
866
+
867
+ def self.spawn: (SpawnOptions spawn_options) -> LocalSpawnedProcess
868
+ def initialize: (stdin: IO, stdout: IO, stderr: IO, wait_thread: Thread) -> void
869
+ def write: (String data) -> void
870
+ def read_stdout: () { (String) -> void } -> void
871
+ | () -> Enumerator[String, void]
872
+ def read_stderr: () { (String) -> void } -> void
873
+ | () -> Enumerator[String, void]
874
+ def close_stdin: () -> void
875
+ def terminate: (?timeout: Numeric) -> void
876
+ def kill: () -> void
877
+ def running?: () -> bool
878
+ def exit_status: () -> Integer?
879
+ def killed?: () -> bool
880
+ def close: () -> void
881
+ end
882
+
883
+ # Default spawn function
884
+ DEFAULT_SPAWN: ^(SpawnOptions) -> LocalSpawnedProcess
885
+
886
+ # MCP module
887
+ module MCP
888
+ def self.tool: (String name, String description, ?Hash[Symbol, untyped] schema) { (Hash[String, untyped]) -> untyped } -> Tool
889
+ def self.create_server: (name: String, ?tools: Array[Tool]) -> Server
890
+
891
+ class Tool
892
+ attr_reader name: String
893
+ attr_reader description: String
894
+ attr_reader schema: Hash[Symbol, untyped]
895
+
896
+ def initialize: (name: String, description: String, ?schema: Hash[Symbol, untyped]) { (Hash[String, untyped]) -> untyped } -> void
897
+ def call: (Hash[String, untyped] arguments) -> Hash[Symbol, untyped]
898
+ def to_mcp_definition: () -> Hash[Symbol, untyped]
899
+ end
900
+
901
+ class Server
902
+ attr_reader name: String
903
+ attr_reader tools: Hash[String, Tool]
904
+
905
+ def initialize: (name: String, ?tools: Array[Tool]) -> void
906
+ def add_tool: (Tool tool) -> void
907
+ def remove_tool: (String name) -> Tool?
908
+ def handle_message: (Hash[String, untyped] message) -> Hash[Symbol, untyped]?
909
+ def to_config: () -> Hash[Symbol, untyped]
910
+ end
911
+ end
912
+ end