claude-agent-sdk 0.36.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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/README.md +7 -3
  4. data/UPGRADING-1.0.md +151 -0
  5. data/docs/client.md +26 -1
  6. data/docs/errors.md +6 -0
  7. data/docs/hooks-and-permissions.md +5 -3
  8. data/docs/mcp-servers.md +1 -2
  9. data/docs/sessions.md +101 -3
  10. data/docs/types.md +109 -4
  11. data/lib/claude_agent_sdk/cli_installer.rb +30 -3
  12. data/lib/claude_agent_sdk/command_builder.rb +109 -98
  13. data/lib/claude_agent_sdk/deprecation.rb +1 -1
  14. data/lib/claude_agent_sdk/errors.rb +10 -0
  15. data/lib/claude_agent_sdk/fiber_boundary.rb +2 -0
  16. data/lib/claude_agent_sdk/instrumentation/otel.rb +15 -7
  17. data/lib/claude_agent_sdk/message_parser.rb +23 -9
  18. data/lib/claude_agent_sdk/observer.rb +2 -1
  19. data/lib/claude_agent_sdk/option_warnings.rb +2 -0
  20. data/lib/claude_agent_sdk/query.rb +50 -43
  21. data/lib/claude_agent_sdk/sdk_mcp_server.rb +22 -13
  22. data/lib/claude_agent_sdk/session_mutations.rb +20 -8
  23. data/lib/claude_agent_sdk/session_resume.rb +31 -16
  24. data/lib/claude_agent_sdk/session_store.rb +7 -3
  25. data/lib/claude_agent_sdk/session_summary.rb +4 -2
  26. data/lib/claude_agent_sdk/sessions.rb +8 -6
  27. data/lib/claude_agent_sdk/streaming.rb +1 -1
  28. data/lib/claude_agent_sdk/subprocess_cli_transport.rb +72 -40
  29. data/lib/claude_agent_sdk/testing/session_store_conformance.rb +14 -10
  30. data/lib/claude_agent_sdk/transcript_mirror_batcher.rb +2 -0
  31. data/lib/claude_agent_sdk/types/attributes.rb +236 -0
  32. data/lib/claude_agent_sdk/types/base.rb +322 -0
  33. data/lib/claude_agent_sdk/types/content_blocks.rb +57 -0
  34. data/lib/claude_agent_sdk/types/hooks.rb +640 -0
  35. data/lib/claude_agent_sdk/types/mcp.rb +232 -0
  36. data/lib/claude_agent_sdk/types/messages.rb +614 -0
  37. data/lib/claude_agent_sdk/types/option_values.rb +302 -0
  38. data/lib/claude_agent_sdk/types/options.rb +352 -0
  39. data/lib/claude_agent_sdk/types/permissions.rb +107 -0
  40. data/lib/claude_agent_sdk/types/sessions.rb +10 -0
  41. data/lib/claude_agent_sdk/types.rb +13 -2534
  42. data/lib/claude_agent_sdk/version.rb +1 -1
  43. data/lib/claude_agent_sdk.rb +62 -28
  44. data/sig/claude_agent_sdk/cancellation_signal.rbs +14 -0
  45. data/sig/claude_agent_sdk/configuration.rbs +14 -0
  46. data/sig/claude_agent_sdk/errors.rbs +86 -0
  47. data/sig/claude_agent_sdk/observer.rbs +42 -0
  48. data/sig/claude_agent_sdk/railtie.rbs +10 -0
  49. data/sig/claude_agent_sdk/sdk_mcp_server.rbs +76 -0
  50. data/sig/claude_agent_sdk/session_store.rbs +105 -0
  51. data/sig/claude_agent_sdk/streaming.rbs +15 -0
  52. data/sig/claude_agent_sdk/transport.rbs +98 -0
  53. data/sig/claude_agent_sdk/types/base.rbs +39 -0
  54. data/sig/claude_agent_sdk/types/content_blocks.rbs +79 -0
  55. data/sig/claude_agent_sdk/types/hooks.rbs +528 -0
  56. data/sig/claude_agent_sdk/types/mcp.rbs +216 -0
  57. data/sig/claude_agent_sdk/types/messages.rbs +586 -0
  58. data/sig/claude_agent_sdk/types/option_values.rbs +245 -0
  59. data/sig/claude_agent_sdk/types/options.rbs +288 -0
  60. data/sig/claude_agent_sdk/types/permissions.rbs +108 -0
  61. data/sig/claude_agent_sdk/types/sessions.rbs +66 -0
  62. data/sig/claude_agent_sdk.rbs +231 -0
  63. data/sig/manifest.yaml +5 -0
  64. metadata +32 -1
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module ClaudeAgentSDK
6
+ # Content Blocks
7
+
8
+ # Text content block
9
+ class TextBlock < Type
10
+ attr_accessor :text
11
+
12
+ def to_s
13
+ text.to_s
14
+ end
15
+ end
16
+
17
+ # Thinking content block
18
+ class ThinkingBlock < Type
19
+ attr_accessor :thinking, :signature
20
+ end
21
+
22
+ # Tool use content block
23
+ class ToolUseBlock < Type
24
+ attr_accessor :id, :name, :input
25
+ end
26
+
27
+ # Tool result content block
28
+ class ToolResultBlock < Type
29
+ attr_accessor :tool_use_id, :content, :is_error
30
+ end
31
+
32
+ # Server-side tool use (CLI's built-in tools that execute server-side
33
+ # rather than as MCP tools — advisor, web_search, code_execution, etc.).
34
+ # Mirrors Python's `ServerToolUseBlock`.
35
+ class ServerToolUseBlock < Type
36
+ attr_accessor :id, :name, :input
37
+ end
38
+
39
+ # Result of a server-side tool execution. Mirrors Python's
40
+ # `ServerToolResultBlock`.
41
+ class ServerToolResultBlock < Type
42
+ attr_accessor :tool_use_id, :content, :is_error
43
+ end
44
+
45
+ # Generic content block for types the SDK doesn't explicitly handle (e.g., "document", "image").
46
+ # Preserves the raw hash data for forward compatibility with newer CLI versions.
47
+ class UnknownBlock < Type
48
+ attr_accessor :type, :data
49
+ end
50
+
51
+ # Deferred tool use, emitted on `ResultMessage` when a PreToolUse hook
52
+ # returned `permissionDecision: "defer"`. The session can be resumed later
53
+ # to execute the deferred call. Mirrors Python's `DeferredToolUse`.
54
+ class DeferredToolUse < Type
55
+ attr_accessor :id, :name, :input
56
+ end
57
+ end
@@ -0,0 +1,640 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module ClaudeAgentSDK
6
+ # Type constants for hook events
7
+ HOOK_EVENTS = %w[
8
+ PreToolUse
9
+ PostToolUse
10
+ PostToolUseFailure
11
+ Notification
12
+ UserPromptSubmit
13
+ SessionStart
14
+ SessionEnd
15
+ Stop
16
+ StopFailure
17
+ SubagentStart
18
+ SubagentStop
19
+ PreCompact
20
+ PostCompact
21
+ PermissionRequest
22
+ PermissionDenied
23
+ Setup
24
+ TeammateIdle
25
+ TaskCreated
26
+ TaskCompleted
27
+ Elicitation
28
+ ElicitationResult
29
+ ConfigChange
30
+ WorktreeCreate
31
+ WorktreeRemove
32
+ InstructionsLoaded
33
+ CwdChanged
34
+ FileChanged
35
+ ].freeze
36
+
37
+ # Hook matcher configuration
38
+ class HookMatcher < Type
39
+ include Type::OptionValue
40
+
41
+ strict_attributes
42
+
43
+ attr_accessor :matcher, :hooks, :timeout
44
+
45
+ def initialize(attributes = {})
46
+ super
47
+ @hooks ||= []
48
+ end
49
+ end
50
+
51
+ # Hook context passed to hook callbacks. Dispatched hooks receive the control
52
+ # request ID and a CancellationSignal (including on HookMatcher timeout).
53
+ class HookContext < Type
54
+ attr_accessor :signal, :request_id
55
+ end
56
+
57
+ # Base hook input with common fields
58
+ class BaseHookInput < Type
59
+ attr_accessor :session_id, :transcript_path, :cwd, :permission_mode
60
+ attr_reader :hook_event_name
61
+ end
62
+
63
+ # PreToolUse hook input
64
+ class PreToolUseHookInput < BaseHookInput
65
+ attr_accessor :tool_name, :tool_input, :tool_use_id, :agent_id, :agent_type
66
+
67
+ def initialize(attributes = {})
68
+ super
69
+ @hook_event_name = 'PreToolUse'
70
+ end
71
+ end
72
+
73
+ # PostToolUse hook input
74
+ class PostToolUseHookInput < BaseHookInput
75
+ attr_accessor :tool_name, :tool_input, :tool_response, :tool_use_id, :agent_id, :agent_type
76
+
77
+ def initialize(attributes = {})
78
+ super
79
+ @hook_event_name = 'PostToolUse'
80
+ end
81
+ end
82
+
83
+ # UserPromptSubmit hook input
84
+ class UserPromptSubmitHookInput < BaseHookInput
85
+ attr_accessor :prompt
86
+
87
+ def initialize(attributes = {})
88
+ super
89
+ @hook_event_name = 'UserPromptSubmit'
90
+ end
91
+ end
92
+
93
+ # Stop hook input
94
+ # Snapshot arrays are passed through unchanged. nil means unavailable;
95
+ # [] means the CLI provided an empty snapshot. They cover the parent
96
+ # session's background work, NOT all foreground and background agents.
97
+ class StopHookInput < BaseHookInput
98
+ attr_accessor :stop_hook_active, :last_assistant_message, :background_tasks, :session_crons
99
+
100
+ def initialize(attributes = {})
101
+ super
102
+ @hook_event_name = 'Stop'
103
+ @stop_hook_active = false if @stop_hook_active.nil?
104
+ end
105
+ end
106
+
107
+ # SubagentStop hook input
108
+ class SubagentStopHookInput < BaseHookInput
109
+ attr_accessor :stop_hook_active, :agent_id, :agent_transcript_path, :agent_type,
110
+ :last_assistant_message, :background_tasks, :session_crons
111
+
112
+ def initialize(attributes = {})
113
+ super
114
+ @hook_event_name = 'SubagentStop'
115
+ @stop_hook_active = false if @stop_hook_active.nil?
116
+ end
117
+ end
118
+
119
+ # PostToolUseFailure hook input
120
+ class PostToolUseFailureHookInput < BaseHookInput
121
+ attr_accessor :tool_name, :tool_input, :tool_use_id, :error, :is_interrupt,
122
+ :agent_id, :agent_type
123
+
124
+ def initialize(attributes = {})
125
+ super
126
+ @hook_event_name = 'PostToolUseFailure'
127
+ end
128
+ end
129
+
130
+ # Notification hook input
131
+ class NotificationHookInput < BaseHookInput
132
+ attr_accessor :message, :title, :notification_type
133
+
134
+ def initialize(attributes = {})
135
+ super
136
+ @hook_event_name = 'Notification'
137
+ end
138
+ end
139
+
140
+ # SubagentStart hook input
141
+ class SubagentStartHookInput < BaseHookInput
142
+ attr_accessor :agent_id, :agent_type
143
+
144
+ def initialize(attributes = {})
145
+ super
146
+ @hook_event_name = 'SubagentStart'
147
+ end
148
+ end
149
+
150
+ # PermissionRequest hook input
151
+ class PermissionRequestHookInput < BaseHookInput
152
+ attr_accessor :tool_name, :tool_input, :permission_suggestions, :agent_id, :agent_type
153
+
154
+ def initialize(attributes = {})
155
+ super
156
+ @hook_event_name = 'PermissionRequest'
157
+ end
158
+ end
159
+
160
+ # PreCompact hook input
161
+ class PreCompactHookInput < BaseHookInput
162
+ attr_accessor :trigger, :custom_instructions
163
+
164
+ def initialize(attributes = {})
165
+ super
166
+ @hook_event_name = 'PreCompact'
167
+ end
168
+ end
169
+
170
+ # SessionStart hook input
171
+ class SessionStartHookInput < BaseHookInput
172
+ attr_accessor :source, :agent_type, :model
173
+
174
+ def initialize(attributes = {})
175
+ super
176
+ @hook_event_name = 'SessionStart'
177
+ end
178
+ end
179
+
180
+ # SessionEnd hook input
181
+ class SessionEndHookInput < BaseHookInput
182
+ attr_accessor :reason
183
+
184
+ def initialize(attributes = {})
185
+ super
186
+ @hook_event_name = 'SessionEnd'
187
+ end
188
+ end
189
+
190
+ # Setup hook input
191
+ class SetupHookInput < BaseHookInput
192
+ attr_accessor :trigger
193
+
194
+ def initialize(attributes = {})
195
+ super
196
+ @hook_event_name = 'Setup'
197
+ end
198
+ end
199
+
200
+ # TeammateIdle hook input
201
+ class TeammateIdleHookInput < BaseHookInput
202
+ attr_accessor :teammate_name, :team_name
203
+
204
+ def initialize(attributes = {})
205
+ super
206
+ @hook_event_name = 'TeammateIdle'
207
+ end
208
+ end
209
+
210
+ # TaskCompleted hook input
211
+ class TaskCompletedHookInput < BaseHookInput
212
+ attr_accessor :task_id, :task_subject, :task_description, :teammate_name, :team_name
213
+
214
+ def initialize(attributes = {})
215
+ super
216
+ @hook_event_name = 'TaskCompleted'
217
+ end
218
+ end
219
+
220
+ # ConfigChange hook input
221
+ class ConfigChangeHookInput < BaseHookInput
222
+ attr_accessor :source, :file_path
223
+
224
+ def initialize(attributes = {})
225
+ super
226
+ @hook_event_name = 'ConfigChange'
227
+ end
228
+ end
229
+
230
+ # WorktreeCreate hook input
231
+ class WorktreeCreateHookInput < BaseHookInput
232
+ attr_accessor :name
233
+
234
+ def initialize(attributes = {})
235
+ super
236
+ @hook_event_name = 'WorktreeCreate'
237
+ end
238
+ end
239
+
240
+ # WorktreeRemove hook input
241
+ class WorktreeRemoveHookInput < BaseHookInput
242
+ attr_accessor :worktree_path
243
+
244
+ def initialize(attributes = {})
245
+ super
246
+ @hook_event_name = 'WorktreeRemove'
247
+ end
248
+ end
249
+
250
+ # StopFailure hook input
251
+ class StopFailureHookInput < BaseHookInput
252
+ attr_accessor :error, :error_details, :last_assistant_message
253
+
254
+ def initialize(attributes = {})
255
+ super
256
+ @hook_event_name = 'StopFailure'
257
+ end
258
+ end
259
+
260
+ # PostCompact hook input
261
+ class PostCompactHookInput < BaseHookInput
262
+ attr_accessor :trigger, :compact_summary
263
+
264
+ def initialize(attributes = {})
265
+ super
266
+ @hook_event_name = 'PostCompact'
267
+ end
268
+ end
269
+
270
+ # PermissionDenied hook input
271
+ class PermissionDeniedHookInput < BaseHookInput
272
+ attr_accessor :tool_name, :tool_input, :tool_use_id, :reason, :agent_id, :agent_type
273
+
274
+ def initialize(attributes = {})
275
+ super
276
+ @hook_event_name = 'PermissionDenied'
277
+ end
278
+ end
279
+
280
+ # TaskCreated hook input
281
+ class TaskCreatedHookInput < BaseHookInput
282
+ attr_accessor :task_id, :task_subject, :task_description, :teammate_name, :team_name
283
+
284
+ def initialize(attributes = {})
285
+ super
286
+ @hook_event_name = 'TaskCreated'
287
+ end
288
+ end
289
+
290
+ # Elicitation hook input
291
+ class ElicitationHookInput < BaseHookInput
292
+ attr_accessor :mcp_server_name, :message, :mode, :url,
293
+ :elicitation_id, :requested_schema
294
+
295
+ def initialize(attributes = {})
296
+ super
297
+ @hook_event_name = 'Elicitation'
298
+ end
299
+ end
300
+
301
+ # ElicitationResult hook input
302
+ class ElicitationResultHookInput < BaseHookInput
303
+ attr_accessor :mcp_server_name, :elicitation_id, :mode, :action, :content
304
+
305
+ def initialize(attributes = {})
306
+ super
307
+ @hook_event_name = 'ElicitationResult'
308
+ end
309
+ end
310
+
311
+ # InstructionsLoaded hook input
312
+ class InstructionsLoadedHookInput < BaseHookInput
313
+ attr_accessor :file_path, :memory_type, :load_reason, :globs, :trigger_file_path
314
+
315
+ def initialize(attributes = {})
316
+ super
317
+ @hook_event_name = 'InstructionsLoaded'
318
+ end
319
+ end
320
+
321
+ # CwdChanged hook input
322
+ class CwdChangedHookInput < BaseHookInput
323
+ attr_accessor :old_cwd, :new_cwd
324
+
325
+ def initialize(attributes = {})
326
+ super
327
+ @hook_event_name = 'CwdChanged'
328
+ end
329
+ end
330
+
331
+ # FileChanged hook input
332
+ class FileChangedHookInput < BaseHookInput
333
+ attr_accessor :file_path, :event
334
+
335
+ def initialize(attributes = {})
336
+ super
337
+ @hook_event_name = 'FileChanged'
338
+ end
339
+ end
340
+
341
+ # Fallback for hook events the SDK does not yet model. Carries the wire
342
+ # event name and the complete raw payload so no fields are lost (Python
343
+ # passes hook input through as a raw dict, so unknown events lose
344
+ # nothing there).
345
+ class UnknownHookInput < BaseHookInput
346
+ attr_accessor :raw_input
347
+
348
+ def initialize(attributes = {})
349
+ super
350
+ # Direct assignment: BaseHookInput exposes hook_event_name as
351
+ # attr_reader only, and Type#assign_attribute silently drops keys
352
+ # without public setters.
353
+ @hook_event_name = attributes[:hook_event_name] || attributes['hook_event_name']
354
+ end
355
+ end
356
+
357
+ # Setup hook specific output
358
+ class SetupHookSpecificOutput < Type
359
+ strict_attributes
360
+
361
+ attr_accessor :additional_context
362
+ attr_reader :hook_event_name
363
+
364
+ def initialize(attributes = {})
365
+ super
366
+ @hook_event_name = 'Setup'
367
+ end
368
+
369
+ def to_h
370
+ result = { hookEventName: @hook_event_name }
371
+ result[:additionalContext] = @additional_context if @additional_context
372
+ result
373
+ end
374
+ end
375
+
376
+ # PreToolUse hook specific output
377
+ class PreToolUseHookSpecificOutput < Type
378
+ strict_attributes
379
+
380
+ attr_accessor :permission_decision, :permission_decision_reason,
381
+ :updated_input, :additional_context
382
+ attr_reader :hook_event_name
383
+
384
+ def initialize(attributes = {})
385
+ super
386
+ @hook_event_name = 'PreToolUse'
387
+ end
388
+
389
+ def to_h
390
+ result = { hookEventName: @hook_event_name }
391
+ result[:permissionDecision] = @permission_decision if @permission_decision
392
+ result[:permissionDecisionReason] = @permission_decision_reason if @permission_decision_reason
393
+ result[:updatedInput] = @updated_input if @updated_input
394
+ result[:additionalContext] = @additional_context if @additional_context
395
+ result
396
+ end
397
+ end
398
+
399
+ # PostToolUse hook specific output.
400
+ #
401
+ # `updated_tool_output` (CLI 2.1.110+) replaces the tool's output entirely
402
+ # — works for any tool, MCP or built-in. `updated_mcp_tool_output` is the
403
+ # legacy MCP-only field that pre-dates the unified one; the CLI still
404
+ # honors it, so both are emitted when set. Mirrors Python's
405
+ # `PostToolUseHookSpecificOutput`.
406
+ class PostToolUseHookSpecificOutput < Type
407
+ strict_attributes
408
+
409
+ attr_accessor :additional_context, :updated_mcp_tool_output, :updated_tool_output
410
+ attr_reader :hook_event_name
411
+
412
+ def initialize(attributes = {})
413
+ super
414
+ @hook_event_name = 'PostToolUse'
415
+ end
416
+
417
+ def to_h
418
+ result = { hookEventName: @hook_event_name }
419
+ result[:additionalContext] = @additional_context if @additional_context
420
+ result[:updatedToolOutput] = @updated_tool_output unless @updated_tool_output.nil?
421
+ result[:updatedMCPToolOutput] = @updated_mcp_tool_output if @updated_mcp_tool_output
422
+ result
423
+ end
424
+ end
425
+
426
+ # PostToolUseFailure hook specific output
427
+ class PostToolUseFailureHookSpecificOutput < Type
428
+ strict_attributes
429
+
430
+ attr_accessor :additional_context
431
+ attr_reader :hook_event_name
432
+
433
+ def initialize(attributes = {})
434
+ super
435
+ @hook_event_name = 'PostToolUseFailure'
436
+ end
437
+
438
+ def to_h
439
+ result = { hookEventName: @hook_event_name }
440
+ result[:additionalContext] = @additional_context if @additional_context
441
+ result
442
+ end
443
+ end
444
+
445
+ # UserPromptSubmit hook specific output
446
+ class UserPromptSubmitHookSpecificOutput < Type
447
+ strict_attributes
448
+
449
+ attr_accessor :additional_context
450
+ attr_reader :hook_event_name
451
+
452
+ def initialize(attributes = {})
453
+ super
454
+ @hook_event_name = 'UserPromptSubmit'
455
+ end
456
+
457
+ def to_h
458
+ result = { hookEventName: @hook_event_name }
459
+ result[:additionalContext] = @additional_context if @additional_context
460
+ result
461
+ end
462
+ end
463
+
464
+ # Notification hook specific output
465
+ class NotificationHookSpecificOutput < Type
466
+ strict_attributes
467
+
468
+ attr_accessor :additional_context
469
+ attr_reader :hook_event_name
470
+
471
+ def initialize(attributes = {})
472
+ super
473
+ @hook_event_name = 'Notification'
474
+ end
475
+
476
+ def to_h
477
+ result = { hookEventName: @hook_event_name }
478
+ result[:additionalContext] = @additional_context if @additional_context
479
+ result
480
+ end
481
+ end
482
+
483
+ # SubagentStart hook specific output
484
+ class SubagentStartHookSpecificOutput < Type
485
+ strict_attributes
486
+
487
+ attr_accessor :additional_context
488
+ attr_reader :hook_event_name
489
+
490
+ def initialize(attributes = {})
491
+ super
492
+ @hook_event_name = 'SubagentStart'
493
+ end
494
+
495
+ def to_h
496
+ result = { hookEventName: @hook_event_name }
497
+ result[:additionalContext] = @additional_context if @additional_context
498
+ result
499
+ end
500
+ end
501
+
502
+ # PermissionRequest hook specific output
503
+ class PermissionRequestHookSpecificOutput < Type
504
+ strict_attributes
505
+
506
+ attr_accessor :decision
507
+ attr_reader :hook_event_name
508
+
509
+ def initialize(attributes = {})
510
+ super
511
+ @hook_event_name = 'PermissionRequest'
512
+ end
513
+
514
+ def to_h
515
+ result = { hookEventName: @hook_event_name }
516
+ result[:decision] = @decision if @decision
517
+ result
518
+ end
519
+ end
520
+
521
+ # SessionStart hook specific output
522
+ class SessionStartHookSpecificOutput < Type
523
+ strict_attributes
524
+
525
+ attr_accessor :additional_context
526
+ attr_reader :hook_event_name
527
+
528
+ def initialize(attributes = {})
529
+ super
530
+ @hook_event_name = 'SessionStart'
531
+ end
532
+
533
+ def to_h
534
+ result = { hookEventName: @hook_event_name }
535
+ result[:additionalContext] = @additional_context if @additional_context
536
+ result
537
+ end
538
+ end
539
+
540
+ # PermissionDenied hook specific output
541
+ class PermissionDeniedHookSpecificOutput < Type
542
+ strict_attributes
543
+
544
+ attr_accessor :retry
545
+ attr_reader :hook_event_name
546
+
547
+ def initialize(attributes = {})
548
+ super
549
+ @hook_event_name = 'PermissionDenied'
550
+ @retry = false if @retry.nil?
551
+ end
552
+
553
+ def to_h
554
+ result = { hookEventName: @hook_event_name }
555
+ result[:retry] = @retry unless @retry.nil?
556
+ result
557
+ end
558
+ end
559
+
560
+ # CwdChanged hook specific output
561
+ class CwdChangedHookSpecificOutput < Type
562
+ strict_attributes
563
+
564
+ attr_accessor :watch_paths
565
+ attr_reader :hook_event_name
566
+
567
+ def initialize(attributes = {})
568
+ super
569
+ @hook_event_name = 'CwdChanged'
570
+ end
571
+
572
+ def to_h
573
+ result = { hookEventName: @hook_event_name }
574
+ result[:watchPaths] = @watch_paths if @watch_paths
575
+ result
576
+ end
577
+ end
578
+
579
+ # FileChanged hook specific output
580
+ class FileChangedHookSpecificOutput < Type
581
+ strict_attributes
582
+
583
+ attr_accessor :watch_paths
584
+ attr_reader :hook_event_name
585
+
586
+ def initialize(attributes = {})
587
+ super
588
+ @hook_event_name = 'FileChanged'
589
+ end
590
+
591
+ def to_h
592
+ result = { hookEventName: @hook_event_name }
593
+ result[:watchPaths] = @watch_paths if @watch_paths
594
+ result
595
+ end
596
+ end
597
+
598
+ # Async hook JSON output
599
+ class AsyncHookJSONOutput < Type
600
+ strict_attributes
601
+
602
+ attr_accessor :async, :async_timeout
603
+
604
+ def initialize(attributes = {})
605
+ super
606
+ @async = true if @async.nil?
607
+ end
608
+
609
+ def to_h
610
+ result = { async: @async }
611
+ result[:asyncTimeout] = @async_timeout if @async_timeout
612
+ result
613
+ end
614
+ end
615
+
616
+ # Sync hook JSON output
617
+ class SyncHookJSONOutput < Type
618
+ strict_attributes
619
+
620
+ attr_accessor :continue, :suppress_output, :stop_reason, :decision,
621
+ :system_message, :reason, :hook_specific_output
622
+
623
+ def initialize(attributes = {})
624
+ super
625
+ @continue = true if @continue.nil?
626
+ @suppress_output = false if @suppress_output.nil?
627
+ end
628
+
629
+ def to_h
630
+ result = { continue: @continue }
631
+ result[:suppressOutput] = @suppress_output if @suppress_output
632
+ result[:stopReason] = @stop_reason if @stop_reason
633
+ result[:decision] = @decision if @decision
634
+ result[:systemMessage] = @system_message if @system_message
635
+ result[:reason] = @reason if @reason
636
+ result[:hookSpecificOutput] = @hook_specific_output.to_h if @hook_specific_output
637
+ result
638
+ end
639
+ end
640
+ end