@gaburieuru/claudio 0.24.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,2385 @@
1
+ // AUTO-GENERATED — do not edit manually.
2
+ // Regenerate with: bun scripts/generate-sdk-types.ts
3
+ //
4
+ // Generated from Zod schemas in coreSchemas.ts
5
+
6
+ export type ModelUsage = {
7
+ inputTokens: number
8
+ outputTokens: number
9
+ cacheReadInputTokens: number
10
+ cacheCreationInputTokens: number
11
+ webSearchRequests: number
12
+ costUSD: number
13
+ contextWindow: number
14
+ maxOutputTokens: number
15
+ }
16
+
17
+ export type OutputFormatType = "json_schema"
18
+
19
+ export type BaseOutputFormat = {
20
+ type: "json_schema"
21
+ }
22
+
23
+ export type JsonSchemaOutputFormat = {
24
+ type: "json_schema"
25
+ schema: Record<string, unknown>
26
+ }
27
+
28
+ export type OutputFormat = {
29
+ type: "json_schema"
30
+ schema: Record<string, unknown>
31
+ }
32
+
33
+ export type ApiKeySource = "user" | "project" | "org" | "temporary" | "oauth" | "none"
34
+
35
+ /** Config scope for settings. */
36
+ export type ConfigScope = "local" | "user" | "project"
37
+
38
+ export type SdkBeta = "context-1m-2025-08-07"
39
+
40
+ /** Claude decides when and how much to think (Opus 4.6+). */
41
+ export type ThinkingAdaptive = {
42
+ type: "adaptive"
43
+ }
44
+
45
+ /** Fixed thinking token budget (older models) */
46
+ export type ThinkingEnabled = {
47
+ type: "enabled"
48
+ budgetTokens?: number
49
+ }
50
+
51
+ /** No extended thinking */
52
+ export type ThinkingDisabled = {
53
+ type: "disabled"
54
+ }
55
+
56
+ /** Controls Claude's thinking/reasoning behavior. When set, takes precedence over the deprecated maxThinkingTokens. */
57
+ export type ThinkingConfig = ({
58
+ type: "adaptive"
59
+ }) | ({
60
+ type: "enabled"
61
+ budgetTokens?: number
62
+ }) | ({
63
+ type: "disabled"
64
+ })
65
+
66
+ export type McpStdioServerConfig = {
67
+ type?: "stdio"
68
+ command: string
69
+ args?: string[]
70
+ env?: Record<string, string>
71
+ }
72
+
73
+ export type McpSSEServerConfig = {
74
+ type: "sse"
75
+ url: string
76
+ headers?: Record<string, string>
77
+ }
78
+
79
+ export type McpHttpServerConfig = {
80
+ type: "http"
81
+ url: string
82
+ headers?: Record<string, string>
83
+ }
84
+
85
+ export type McpSdkServerConfig = {
86
+ type: "sdk"
87
+ name: string
88
+ }
89
+
90
+ export type McpServerConfigForProcessTransport = ({
91
+ type?: "stdio"
92
+ command: string
93
+ args?: string[]
94
+ env?: Record<string, string>
95
+ }) | ({
96
+ type: "sse"
97
+ url: string
98
+ headers?: Record<string, string>
99
+ }) | ({
100
+ type: "http"
101
+ url: string
102
+ headers?: Record<string, string>
103
+ }) | ({
104
+ type: "sdk"
105
+ name: string
106
+ })
107
+
108
+ export type McpClaudeAIProxyServerConfig = {
109
+ type: "claudeai-proxy"
110
+ url: string
111
+ id: string
112
+ }
113
+
114
+ export type McpServerStatusConfig = (({
115
+ type?: "stdio"
116
+ command: string
117
+ args?: string[]
118
+ env?: Record<string, string>
119
+ }) | ({
120
+ type: "sse"
121
+ url: string
122
+ headers?: Record<string, string>
123
+ }) | ({
124
+ type: "http"
125
+ url: string
126
+ headers?: Record<string, string>
127
+ }) | ({
128
+ type: "sdk"
129
+ name: string
130
+ })) | ({
131
+ type: "claudeai-proxy"
132
+ url: string
133
+ id: string
134
+ })
135
+
136
+ /** Status information for an MCP server connection. */
137
+ export type McpServerStatus = {
138
+ name: string
139
+ status: "connected" | "failed" | "needs-auth" | "pending" | "disabled"
140
+ serverInfo?: {
141
+ name: string
142
+ version: string
143
+ }
144
+ error?: string
145
+ config?: (({
146
+ type?: "stdio"
147
+ command: string
148
+ args?: string[]
149
+ env?: Record<string, string>
150
+ }) | ({
151
+ type: "sse"
152
+ url: string
153
+ headers?: Record<string, string>
154
+ }) | ({
155
+ type: "http"
156
+ url: string
157
+ headers?: Record<string, string>
158
+ }) | ({
159
+ type: "sdk"
160
+ name: string
161
+ })) | ({
162
+ type: "claudeai-proxy"
163
+ url: string
164
+ id: string
165
+ })
166
+ scope?: string
167
+ tools?: {
168
+ name: string
169
+ description?: string
170
+ annotations?: {
171
+ readOnly?: boolean
172
+ destructive?: boolean
173
+ openWorld?: boolean
174
+ }
175
+ }[]
176
+ capabilities?: {
177
+ experimental?: Record<string, unknown>
178
+ }
179
+ }
180
+
181
+ /** Result of a setMcpServers operation. */
182
+ export type McpSetServersResult = {
183
+ added: string[]
184
+ removed: string[]
185
+ errors: Record<string, string>
186
+ }
187
+
188
+ export type PermissionUpdateDestination = "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
189
+
190
+ export type PermissionBehavior = "allow" | "deny" | "ask"
191
+
192
+ export type PermissionRuleValue = {
193
+ toolName: string
194
+ ruleContent?: string
195
+ }
196
+
197
+ export type PermissionUpdate = ({
198
+ type: "addRules"
199
+ rules: {
200
+ toolName: string
201
+ ruleContent?: string
202
+ }[]
203
+ behavior: "allow" | "deny" | "ask"
204
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
205
+ }) | ({
206
+ type: "replaceRules"
207
+ rules: {
208
+ toolName: string
209
+ ruleContent?: string
210
+ }[]
211
+ behavior: "allow" | "deny" | "ask"
212
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
213
+ }) | ({
214
+ type: "removeRules"
215
+ rules: {
216
+ toolName: string
217
+ ruleContent?: string
218
+ }[]
219
+ behavior: "allow" | "deny" | "ask"
220
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
221
+ }) | ({
222
+ type: "setMode"
223
+ mode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
224
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
225
+ }) | ({
226
+ type: "addDirectories"
227
+ directories: string[]
228
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
229
+ }) | ({
230
+ type: "removeDirectories"
231
+ directories: string[]
232
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
233
+ })
234
+
235
+ /** Classification of this permission decision for telemetry. SDK hosts that prompt users (desktop apps, IDEs) should set this to reflect what actually happened: user_temporary for allow-once, user_permanent for always-allow (both the click and later cache hits), user_reject for deny. If unset, the CLI infers conservatively (temporary for allow, reject for deny). The vocabulary matches tool_decision OTel events (monitoring-usage docs). */
236
+ export type PermissionDecisionClassification = "user_temporary" | "user_permanent" | "user_reject"
237
+
238
+ export type PermissionResult = ({
239
+ behavior: "allow"
240
+ updatedInput?: Record<string, unknown>
241
+ updatedPermissions?: (({
242
+ type: "addRules"
243
+ rules: {
244
+ toolName: string
245
+ ruleContent?: string
246
+ }[]
247
+ behavior: "allow" | "deny" | "ask"
248
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
249
+ }) | ({
250
+ type: "replaceRules"
251
+ rules: {
252
+ toolName: string
253
+ ruleContent?: string
254
+ }[]
255
+ behavior: "allow" | "deny" | "ask"
256
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
257
+ }) | ({
258
+ type: "removeRules"
259
+ rules: {
260
+ toolName: string
261
+ ruleContent?: string
262
+ }[]
263
+ behavior: "allow" | "deny" | "ask"
264
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
265
+ }) | ({
266
+ type: "setMode"
267
+ mode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
268
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
269
+ }) | ({
270
+ type: "addDirectories"
271
+ directories: string[]
272
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
273
+ }) | ({
274
+ type: "removeDirectories"
275
+ directories: string[]
276
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
277
+ }))[]
278
+ toolUseID?: string
279
+ decisionClassification?: "user_temporary" | "user_permanent" | "user_reject"
280
+ }) | ({
281
+ behavior: "deny"
282
+ message: string
283
+ interrupt?: boolean
284
+ toolUseID?: string
285
+ decisionClassification?: "user_temporary" | "user_permanent" | "user_reject"
286
+ })
287
+
288
+ /** Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass normal permission prompts while preserving hard safety checks (requires allowDangerouslySkipPermissions). 'fullAccess' - Bypass normal permission prompts and hard safety-check prompts (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved. */
289
+ export type PermissionMode = "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
290
+
291
+ export type HookEvent = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "Notification" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop" | "PreCompact" | "PostCompact" | "PermissionRequest" | "PermissionDenied" | "Setup" | "TeammateIdle" | "TaskCreated" | "TaskCompleted" | "Elicitation" | "ElicitationResult" | "ConfigChange" | "WorktreeCreate" | "WorktreeRemove" | "InstructionsLoaded" | "CwdChanged" | "FileChanged"
292
+
293
+ export type BaseHookInput = {
294
+ session_id: string
295
+ transcript_path: string
296
+ cwd: string
297
+ permission_mode?: string
298
+ agent_id?: string
299
+ agent_type?: string
300
+ }
301
+
302
+ export type PreToolUseHookInput = {
303
+ session_id: string
304
+ transcript_path: string
305
+ cwd: string
306
+ permission_mode?: string
307
+ agent_id?: string
308
+ agent_type?: string
309
+ } & {
310
+ hook_event_name: "PreToolUse"
311
+ tool_name: string
312
+ tool_input: unknown
313
+ tool_use_id: string
314
+ }
315
+
316
+ export type PostToolUseHookInput = {
317
+ session_id: string
318
+ transcript_path: string
319
+ cwd: string
320
+ permission_mode?: string
321
+ agent_id?: string
322
+ agent_type?: string
323
+ } & {
324
+ hook_event_name: "PostToolUse"
325
+ tool_name: string
326
+ tool_input: unknown
327
+ tool_response: unknown
328
+ tool_use_id: string
329
+ }
330
+
331
+ export type PostToolUseFailureHookInput = {
332
+ session_id: string
333
+ transcript_path: string
334
+ cwd: string
335
+ permission_mode?: string
336
+ agent_id?: string
337
+ agent_type?: string
338
+ } & {
339
+ hook_event_name: "PostToolUseFailure"
340
+ tool_name: string
341
+ tool_input: unknown
342
+ tool_use_id: string
343
+ error: string
344
+ is_interrupt?: boolean
345
+ }
346
+
347
+ export type PermissionDeniedHookInput = {
348
+ session_id: string
349
+ transcript_path: string
350
+ cwd: string
351
+ permission_mode?: string
352
+ agent_id?: string
353
+ agent_type?: string
354
+ } & {
355
+ hook_event_name: "PermissionDenied"
356
+ tool_name: string
357
+ tool_input: unknown
358
+ tool_use_id: string
359
+ reason: string
360
+ }
361
+
362
+ export type NotificationHookInput = {
363
+ session_id: string
364
+ transcript_path: string
365
+ cwd: string
366
+ permission_mode?: string
367
+ agent_id?: string
368
+ agent_type?: string
369
+ } & {
370
+ hook_event_name: "Notification"
371
+ message: string
372
+ title?: string
373
+ notification_type: string
374
+ }
375
+
376
+ export type UserPromptSubmitHookInput = {
377
+ session_id: string
378
+ transcript_path: string
379
+ cwd: string
380
+ permission_mode?: string
381
+ agent_id?: string
382
+ agent_type?: string
383
+ } & {
384
+ hook_event_name: "UserPromptSubmit"
385
+ prompt: string
386
+ }
387
+
388
+ export type SessionStartHookInput = {
389
+ session_id: string
390
+ transcript_path: string
391
+ cwd: string
392
+ permission_mode?: string
393
+ agent_id?: string
394
+ agent_type?: string
395
+ } & {
396
+ hook_event_name: "SessionStart"
397
+ source: "startup" | "resume" | "clear" | "compact"
398
+ agent_type?: string
399
+ model?: string
400
+ }
401
+
402
+ export type SessionEndHookInput = {
403
+ session_id: string
404
+ transcript_path: string
405
+ cwd: string
406
+ permission_mode?: string
407
+ agent_id?: string
408
+ agent_type?: string
409
+ } & {
410
+ hook_event_name: "SessionEnd"
411
+ reason: "clear" | "resume" | "logout" | "prompt_input_exit" | "other" | "bypass_permissions_disabled"
412
+ }
413
+
414
+ export type StopHookInput = {
415
+ session_id: string
416
+ transcript_path: string
417
+ cwd: string
418
+ permission_mode?: string
419
+ agent_id?: string
420
+ agent_type?: string
421
+ } & {
422
+ hook_event_name: "Stop"
423
+ stop_hook_active: boolean
424
+ last_assistant_message?: string
425
+ }
426
+
427
+ export type StopFailureHookInput = {
428
+ session_id: string
429
+ transcript_path: string
430
+ cwd: string
431
+ permission_mode?: string
432
+ agent_id?: string
433
+ agent_type?: string
434
+ } & {
435
+ hook_event_name: "StopFailure"
436
+ error: "authentication_failed" | "billing_error" | "rate_limit" | "invalid_request" | "server_error" | "unknown" | "max_output_tokens"
437
+ error_details?: string
438
+ last_assistant_message?: string
439
+ }
440
+
441
+ export type SubagentStartHookInput = {
442
+ session_id: string
443
+ transcript_path: string
444
+ cwd: string
445
+ permission_mode?: string
446
+ agent_id?: string
447
+ agent_type?: string
448
+ } & {
449
+ hook_event_name: "SubagentStart"
450
+ agent_id: string
451
+ agent_type: string
452
+ }
453
+
454
+ export type SubagentStopHookInput = {
455
+ session_id: string
456
+ transcript_path: string
457
+ cwd: string
458
+ permission_mode?: string
459
+ agent_id?: string
460
+ agent_type?: string
461
+ } & {
462
+ hook_event_name: "SubagentStop"
463
+ stop_hook_active: boolean
464
+ agent_id: string
465
+ agent_transcript_path: string
466
+ agent_type: string
467
+ last_assistant_message?: string
468
+ }
469
+
470
+ export type PreCompactHookInput = {
471
+ session_id: string
472
+ transcript_path: string
473
+ cwd: string
474
+ permission_mode?: string
475
+ agent_id?: string
476
+ agent_type?: string
477
+ } & {
478
+ hook_event_name: "PreCompact"
479
+ trigger: "manual" | "auto"
480
+ custom_instructions: string | null
481
+ }
482
+
483
+ export type PostCompactHookInput = {
484
+ session_id: string
485
+ transcript_path: string
486
+ cwd: string
487
+ permission_mode?: string
488
+ agent_id?: string
489
+ agent_type?: string
490
+ } & {
491
+ hook_event_name: "PostCompact"
492
+ trigger: "manual" | "auto"
493
+ compact_summary: string
494
+ }
495
+
496
+ export type PermissionRequestHookInput = {
497
+ session_id: string
498
+ transcript_path: string
499
+ cwd: string
500
+ permission_mode?: string
501
+ agent_id?: string
502
+ agent_type?: string
503
+ } & {
504
+ hook_event_name: "PermissionRequest"
505
+ tool_name: string
506
+ tool_input: unknown
507
+ permission_suggestions?: (({
508
+ type: "addRules"
509
+ rules: {
510
+ toolName: string
511
+ ruleContent?: string
512
+ }[]
513
+ behavior: "allow" | "deny" | "ask"
514
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
515
+ }) | ({
516
+ type: "replaceRules"
517
+ rules: {
518
+ toolName: string
519
+ ruleContent?: string
520
+ }[]
521
+ behavior: "allow" | "deny" | "ask"
522
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
523
+ }) | ({
524
+ type: "removeRules"
525
+ rules: {
526
+ toolName: string
527
+ ruleContent?: string
528
+ }[]
529
+ behavior: "allow" | "deny" | "ask"
530
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
531
+ }) | ({
532
+ type: "setMode"
533
+ mode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
534
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
535
+ }) | ({
536
+ type: "addDirectories"
537
+ directories: string[]
538
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
539
+ }) | ({
540
+ type: "removeDirectories"
541
+ directories: string[]
542
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
543
+ }))[]
544
+ }
545
+
546
+ export type SetupHookInput = {
547
+ session_id: string
548
+ transcript_path: string
549
+ cwd: string
550
+ permission_mode?: string
551
+ agent_id?: string
552
+ agent_type?: string
553
+ } & {
554
+ hook_event_name: "Setup"
555
+ trigger: "init" | "maintenance"
556
+ }
557
+
558
+ export type TeammateIdleHookInput = {
559
+ session_id: string
560
+ transcript_path: string
561
+ cwd: string
562
+ permission_mode?: string
563
+ agent_id?: string
564
+ agent_type?: string
565
+ } & {
566
+ hook_event_name: "TeammateIdle"
567
+ teammate_name: string
568
+ team_name: string
569
+ }
570
+
571
+ export type TaskCreatedHookInput = {
572
+ session_id: string
573
+ transcript_path: string
574
+ cwd: string
575
+ permission_mode?: string
576
+ agent_id?: string
577
+ agent_type?: string
578
+ } & {
579
+ hook_event_name: "TaskCreated"
580
+ task_id: string
581
+ task_subject: string
582
+ task_description?: string
583
+ teammate_name?: string
584
+ team_name?: string
585
+ }
586
+
587
+ export type TaskCompletedHookInput = {
588
+ session_id: string
589
+ transcript_path: string
590
+ cwd: string
591
+ permission_mode?: string
592
+ agent_id?: string
593
+ agent_type?: string
594
+ } & {
595
+ hook_event_name: "TaskCompleted"
596
+ task_id: string
597
+ task_subject: string
598
+ task_description?: string
599
+ teammate_name?: string
600
+ team_name?: string
601
+ }
602
+
603
+ /** Hook input for the Elicitation event. Fired when an MCP server requests user input. Hooks can auto-respond (accept/decline) instead of showing the dialog. */
604
+ export type ElicitationHookInput = {
605
+ session_id: string
606
+ transcript_path: string
607
+ cwd: string
608
+ permission_mode?: string
609
+ agent_id?: string
610
+ agent_type?: string
611
+ } & {
612
+ hook_event_name: "Elicitation"
613
+ mcp_server_name: string
614
+ message: string
615
+ mode?: "form" | "url"
616
+ url?: string
617
+ elicitation_id?: string
618
+ requested_schema?: Record<string, unknown>
619
+ }
620
+
621
+ /** Hook input for the ElicitationResult event. Fired after the user responds to an MCP elicitation. Hooks can observe or override the response before it is sent to the server. */
622
+ export type ElicitationResultHookInput = {
623
+ session_id: string
624
+ transcript_path: string
625
+ cwd: string
626
+ permission_mode?: string
627
+ agent_id?: string
628
+ agent_type?: string
629
+ } & {
630
+ hook_event_name: "ElicitationResult"
631
+ mcp_server_name: string
632
+ elicitation_id?: string
633
+ mode?: "form" | "url"
634
+ action: "accept" | "decline" | "cancel"
635
+ content?: Record<string, unknown>
636
+ }
637
+
638
+ export type ConfigChangeHookInput = {
639
+ session_id: string
640
+ transcript_path: string
641
+ cwd: string
642
+ permission_mode?: string
643
+ agent_id?: string
644
+ agent_type?: string
645
+ } & {
646
+ hook_event_name: "ConfigChange"
647
+ source: "user_settings" | "project_settings" | "local_settings" | "policy_settings" | "skills"
648
+ file_path?: string
649
+ }
650
+
651
+ export type InstructionsLoadedHookInput = {
652
+ session_id: string
653
+ transcript_path: string
654
+ cwd: string
655
+ permission_mode?: string
656
+ agent_id?: string
657
+ agent_type?: string
658
+ } & {
659
+ hook_event_name: "InstructionsLoaded"
660
+ file_path: string
661
+ memory_type: "User" | "Project" | "Local" | "Managed"
662
+ load_reason: "session_start" | "nested_traversal" | "path_glob_match" | "include" | "compact"
663
+ globs?: string[]
664
+ trigger_file_path?: string
665
+ parent_file_path?: string
666
+ }
667
+
668
+ export type WorktreeCreateHookInput = {
669
+ session_id: string
670
+ transcript_path: string
671
+ cwd: string
672
+ permission_mode?: string
673
+ agent_id?: string
674
+ agent_type?: string
675
+ } & {
676
+ hook_event_name: "WorktreeCreate"
677
+ name: string
678
+ }
679
+
680
+ export type WorktreeRemoveHookInput = {
681
+ session_id: string
682
+ transcript_path: string
683
+ cwd: string
684
+ permission_mode?: string
685
+ agent_id?: string
686
+ agent_type?: string
687
+ } & {
688
+ hook_event_name: "WorktreeRemove"
689
+ worktree_path: string
690
+ }
691
+
692
+ export type CwdChangedHookInput = {
693
+ session_id: string
694
+ transcript_path: string
695
+ cwd: string
696
+ permission_mode?: string
697
+ agent_id?: string
698
+ agent_type?: string
699
+ } & {
700
+ hook_event_name: "CwdChanged"
701
+ old_cwd: string
702
+ new_cwd: string
703
+ }
704
+
705
+ export type FileChangedHookInput = {
706
+ session_id: string
707
+ transcript_path: string
708
+ cwd: string
709
+ permission_mode?: string
710
+ agent_id?: string
711
+ agent_type?: string
712
+ } & {
713
+ hook_event_name: "FileChanged"
714
+ file_path: string
715
+ event: "change" | "add" | "unlink"
716
+ }
717
+
718
+ export type HookInput = ({
719
+ session_id: string
720
+ transcript_path: string
721
+ cwd: string
722
+ permission_mode?: string
723
+ agent_id?: string
724
+ agent_type?: string
725
+ } & {
726
+ hook_event_name: "PreToolUse"
727
+ tool_name: string
728
+ tool_input: unknown
729
+ tool_use_id: string
730
+ }) | ({
731
+ session_id: string
732
+ transcript_path: string
733
+ cwd: string
734
+ permission_mode?: string
735
+ agent_id?: string
736
+ agent_type?: string
737
+ } & {
738
+ hook_event_name: "PostToolUse"
739
+ tool_name: string
740
+ tool_input: unknown
741
+ tool_response: unknown
742
+ tool_use_id: string
743
+ }) | ({
744
+ session_id: string
745
+ transcript_path: string
746
+ cwd: string
747
+ permission_mode?: string
748
+ agent_id?: string
749
+ agent_type?: string
750
+ } & {
751
+ hook_event_name: "PostToolUseFailure"
752
+ tool_name: string
753
+ tool_input: unknown
754
+ tool_use_id: string
755
+ error: string
756
+ is_interrupt?: boolean
757
+ }) | ({
758
+ session_id: string
759
+ transcript_path: string
760
+ cwd: string
761
+ permission_mode?: string
762
+ agent_id?: string
763
+ agent_type?: string
764
+ } & {
765
+ hook_event_name: "PermissionDenied"
766
+ tool_name: string
767
+ tool_input: unknown
768
+ tool_use_id: string
769
+ reason: string
770
+ }) | ({
771
+ session_id: string
772
+ transcript_path: string
773
+ cwd: string
774
+ permission_mode?: string
775
+ agent_id?: string
776
+ agent_type?: string
777
+ } & {
778
+ hook_event_name: "Notification"
779
+ message: string
780
+ title?: string
781
+ notification_type: string
782
+ }) | ({
783
+ session_id: string
784
+ transcript_path: string
785
+ cwd: string
786
+ permission_mode?: string
787
+ agent_id?: string
788
+ agent_type?: string
789
+ } & {
790
+ hook_event_name: "UserPromptSubmit"
791
+ prompt: string
792
+ }) | ({
793
+ session_id: string
794
+ transcript_path: string
795
+ cwd: string
796
+ permission_mode?: string
797
+ agent_id?: string
798
+ agent_type?: string
799
+ } & {
800
+ hook_event_name: "SessionStart"
801
+ source: "startup" | "resume" | "clear" | "compact"
802
+ agent_type?: string
803
+ model?: string
804
+ }) | ({
805
+ session_id: string
806
+ transcript_path: string
807
+ cwd: string
808
+ permission_mode?: string
809
+ agent_id?: string
810
+ agent_type?: string
811
+ } & {
812
+ hook_event_name: "SessionEnd"
813
+ reason: "clear" | "resume" | "logout" | "prompt_input_exit" | "other" | "bypass_permissions_disabled"
814
+ }) | ({
815
+ session_id: string
816
+ transcript_path: string
817
+ cwd: string
818
+ permission_mode?: string
819
+ agent_id?: string
820
+ agent_type?: string
821
+ } & {
822
+ hook_event_name: "Stop"
823
+ stop_hook_active: boolean
824
+ last_assistant_message?: string
825
+ }) | ({
826
+ session_id: string
827
+ transcript_path: string
828
+ cwd: string
829
+ permission_mode?: string
830
+ agent_id?: string
831
+ agent_type?: string
832
+ } & {
833
+ hook_event_name: "StopFailure"
834
+ error: "authentication_failed" | "billing_error" | "rate_limit" | "invalid_request" | "server_error" | "unknown" | "max_output_tokens"
835
+ error_details?: string
836
+ last_assistant_message?: string
837
+ }) | ({
838
+ session_id: string
839
+ transcript_path: string
840
+ cwd: string
841
+ permission_mode?: string
842
+ agent_id?: string
843
+ agent_type?: string
844
+ } & {
845
+ hook_event_name: "SubagentStart"
846
+ agent_id: string
847
+ agent_type: string
848
+ }) | ({
849
+ session_id: string
850
+ transcript_path: string
851
+ cwd: string
852
+ permission_mode?: string
853
+ agent_id?: string
854
+ agent_type?: string
855
+ } & {
856
+ hook_event_name: "SubagentStop"
857
+ stop_hook_active: boolean
858
+ agent_id: string
859
+ agent_transcript_path: string
860
+ agent_type: string
861
+ last_assistant_message?: string
862
+ }) | ({
863
+ session_id: string
864
+ transcript_path: string
865
+ cwd: string
866
+ permission_mode?: string
867
+ agent_id?: string
868
+ agent_type?: string
869
+ } & {
870
+ hook_event_name: "PreCompact"
871
+ trigger: "manual" | "auto"
872
+ custom_instructions: string | null
873
+ }) | ({
874
+ session_id: string
875
+ transcript_path: string
876
+ cwd: string
877
+ permission_mode?: string
878
+ agent_id?: string
879
+ agent_type?: string
880
+ } & {
881
+ hook_event_name: "PostCompact"
882
+ trigger: "manual" | "auto"
883
+ compact_summary: string
884
+ }) | ({
885
+ session_id: string
886
+ transcript_path: string
887
+ cwd: string
888
+ permission_mode?: string
889
+ agent_id?: string
890
+ agent_type?: string
891
+ } & {
892
+ hook_event_name: "PermissionRequest"
893
+ tool_name: string
894
+ tool_input: unknown
895
+ permission_suggestions?: (({
896
+ type: "addRules"
897
+ rules: {
898
+ toolName: string
899
+ ruleContent?: string
900
+ }[]
901
+ behavior: "allow" | "deny" | "ask"
902
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
903
+ }) | ({
904
+ type: "replaceRules"
905
+ rules: {
906
+ toolName: string
907
+ ruleContent?: string
908
+ }[]
909
+ behavior: "allow" | "deny" | "ask"
910
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
911
+ }) | ({
912
+ type: "removeRules"
913
+ rules: {
914
+ toolName: string
915
+ ruleContent?: string
916
+ }[]
917
+ behavior: "allow" | "deny" | "ask"
918
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
919
+ }) | ({
920
+ type: "setMode"
921
+ mode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
922
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
923
+ }) | ({
924
+ type: "addDirectories"
925
+ directories: string[]
926
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
927
+ }) | ({
928
+ type: "removeDirectories"
929
+ directories: string[]
930
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
931
+ }))[]
932
+ }) | ({
933
+ session_id: string
934
+ transcript_path: string
935
+ cwd: string
936
+ permission_mode?: string
937
+ agent_id?: string
938
+ agent_type?: string
939
+ } & {
940
+ hook_event_name: "Setup"
941
+ trigger: "init" | "maintenance"
942
+ }) | ({
943
+ session_id: string
944
+ transcript_path: string
945
+ cwd: string
946
+ permission_mode?: string
947
+ agent_id?: string
948
+ agent_type?: string
949
+ } & {
950
+ hook_event_name: "TeammateIdle"
951
+ teammate_name: string
952
+ team_name: string
953
+ }) | ({
954
+ session_id: string
955
+ transcript_path: string
956
+ cwd: string
957
+ permission_mode?: string
958
+ agent_id?: string
959
+ agent_type?: string
960
+ } & {
961
+ hook_event_name: "TaskCreated"
962
+ task_id: string
963
+ task_subject: string
964
+ task_description?: string
965
+ teammate_name?: string
966
+ team_name?: string
967
+ }) | ({
968
+ session_id: string
969
+ transcript_path: string
970
+ cwd: string
971
+ permission_mode?: string
972
+ agent_id?: string
973
+ agent_type?: string
974
+ } & {
975
+ hook_event_name: "TaskCompleted"
976
+ task_id: string
977
+ task_subject: string
978
+ task_description?: string
979
+ teammate_name?: string
980
+ team_name?: string
981
+ }) | ({
982
+ session_id: string
983
+ transcript_path: string
984
+ cwd: string
985
+ permission_mode?: string
986
+ agent_id?: string
987
+ agent_type?: string
988
+ } & {
989
+ hook_event_name: "Elicitation"
990
+ mcp_server_name: string
991
+ message: string
992
+ mode?: "form" | "url"
993
+ url?: string
994
+ elicitation_id?: string
995
+ requested_schema?: Record<string, unknown>
996
+ }) | ({
997
+ session_id: string
998
+ transcript_path: string
999
+ cwd: string
1000
+ permission_mode?: string
1001
+ agent_id?: string
1002
+ agent_type?: string
1003
+ } & {
1004
+ hook_event_name: "ElicitationResult"
1005
+ mcp_server_name: string
1006
+ elicitation_id?: string
1007
+ mode?: "form" | "url"
1008
+ action: "accept" | "decline" | "cancel"
1009
+ content?: Record<string, unknown>
1010
+ }) | ({
1011
+ session_id: string
1012
+ transcript_path: string
1013
+ cwd: string
1014
+ permission_mode?: string
1015
+ agent_id?: string
1016
+ agent_type?: string
1017
+ } & {
1018
+ hook_event_name: "ConfigChange"
1019
+ source: "user_settings" | "project_settings" | "local_settings" | "policy_settings" | "skills"
1020
+ file_path?: string
1021
+ }) | ({
1022
+ session_id: string
1023
+ transcript_path: string
1024
+ cwd: string
1025
+ permission_mode?: string
1026
+ agent_id?: string
1027
+ agent_type?: string
1028
+ } & {
1029
+ hook_event_name: "InstructionsLoaded"
1030
+ file_path: string
1031
+ memory_type: "User" | "Project" | "Local" | "Managed"
1032
+ load_reason: "session_start" | "nested_traversal" | "path_glob_match" | "include" | "compact"
1033
+ globs?: string[]
1034
+ trigger_file_path?: string
1035
+ parent_file_path?: string
1036
+ }) | ({
1037
+ session_id: string
1038
+ transcript_path: string
1039
+ cwd: string
1040
+ permission_mode?: string
1041
+ agent_id?: string
1042
+ agent_type?: string
1043
+ } & {
1044
+ hook_event_name: "WorktreeCreate"
1045
+ name: string
1046
+ }) | ({
1047
+ session_id: string
1048
+ transcript_path: string
1049
+ cwd: string
1050
+ permission_mode?: string
1051
+ agent_id?: string
1052
+ agent_type?: string
1053
+ } & {
1054
+ hook_event_name: "WorktreeRemove"
1055
+ worktree_path: string
1056
+ }) | ({
1057
+ session_id: string
1058
+ transcript_path: string
1059
+ cwd: string
1060
+ permission_mode?: string
1061
+ agent_id?: string
1062
+ agent_type?: string
1063
+ } & {
1064
+ hook_event_name: "CwdChanged"
1065
+ old_cwd: string
1066
+ new_cwd: string
1067
+ }) | ({
1068
+ session_id: string
1069
+ transcript_path: string
1070
+ cwd: string
1071
+ permission_mode?: string
1072
+ agent_id?: string
1073
+ agent_type?: string
1074
+ } & {
1075
+ hook_event_name: "FileChanged"
1076
+ file_path: string
1077
+ event: "change" | "add" | "unlink"
1078
+ })
1079
+
1080
+ export type AsyncHookJSONOutput = {
1081
+ async: true
1082
+ asyncTimeout?: number
1083
+ }
1084
+
1085
+ export type PreToolUseHookSpecificOutput = {
1086
+ hookEventName: "PreToolUse"
1087
+ permissionDecision?: "allow" | "deny" | "ask"
1088
+ permissionDecisionReason?: string
1089
+ updatedInput?: Record<string, unknown>
1090
+ additionalContext?: string
1091
+ }
1092
+
1093
+ export type UserPromptSubmitHookSpecificOutput = {
1094
+ hookEventName: "UserPromptSubmit"
1095
+ additionalContext?: string
1096
+ }
1097
+
1098
+ export type SessionStartHookSpecificOutput = {
1099
+ hookEventName: "SessionStart"
1100
+ additionalContext?: string
1101
+ initialUserMessage?: string
1102
+ watchPaths?: string[]
1103
+ }
1104
+
1105
+ export type SetupHookSpecificOutput = {
1106
+ hookEventName: "Setup"
1107
+ additionalContext?: string
1108
+ }
1109
+
1110
+ export type SubagentStartHookSpecificOutput = {
1111
+ hookEventName: "SubagentStart"
1112
+ additionalContext?: string
1113
+ }
1114
+
1115
+ export type PostToolUseHookSpecificOutput = {
1116
+ hookEventName: "PostToolUse"
1117
+ additionalContext?: string
1118
+ updatedMCPToolOutput?: unknown
1119
+ }
1120
+
1121
+ export type PostToolUseFailureHookSpecificOutput = {
1122
+ hookEventName: "PostToolUseFailure"
1123
+ additionalContext?: string
1124
+ }
1125
+
1126
+ export type PermissionDeniedHookSpecificOutput = {
1127
+ hookEventName: "PermissionDenied"
1128
+ retry?: boolean
1129
+ }
1130
+
1131
+ export type NotificationHookSpecificOutput = {
1132
+ hookEventName: "Notification"
1133
+ additionalContext?: string
1134
+ }
1135
+
1136
+ export type PermissionRequestHookSpecificOutput = {
1137
+ hookEventName: "PermissionRequest"
1138
+ decision: ({
1139
+ behavior: "allow"
1140
+ updatedInput?: Record<string, unknown>
1141
+ updatedPermissions?: (({
1142
+ type: "addRules"
1143
+ rules: {
1144
+ toolName: string
1145
+ ruleContent?: string
1146
+ }[]
1147
+ behavior: "allow" | "deny" | "ask"
1148
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1149
+ }) | ({
1150
+ type: "replaceRules"
1151
+ rules: {
1152
+ toolName: string
1153
+ ruleContent?: string
1154
+ }[]
1155
+ behavior: "allow" | "deny" | "ask"
1156
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1157
+ }) | ({
1158
+ type: "removeRules"
1159
+ rules: {
1160
+ toolName: string
1161
+ ruleContent?: string
1162
+ }[]
1163
+ behavior: "allow" | "deny" | "ask"
1164
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1165
+ }) | ({
1166
+ type: "setMode"
1167
+ mode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
1168
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1169
+ }) | ({
1170
+ type: "addDirectories"
1171
+ directories: string[]
1172
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1173
+ }) | ({
1174
+ type: "removeDirectories"
1175
+ directories: string[]
1176
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1177
+ }))[]
1178
+ }) | ({
1179
+ behavior: "deny"
1180
+ message?: string
1181
+ interrupt?: boolean
1182
+ })
1183
+ }
1184
+
1185
+ export type CwdChangedHookSpecificOutput = {
1186
+ hookEventName: "CwdChanged"
1187
+ watchPaths?: string[]
1188
+ }
1189
+
1190
+ export type FileChangedHookSpecificOutput = {
1191
+ hookEventName: "FileChanged"
1192
+ watchPaths?: string[]
1193
+ }
1194
+
1195
+ /** Hook-specific output for the Elicitation event. Return this to programmatically accept or decline an MCP elicitation request. */
1196
+ export type ElicitationHookSpecificOutput = {
1197
+ hookEventName: "Elicitation"
1198
+ action?: "accept" | "decline" | "cancel"
1199
+ content?: Record<string, unknown>
1200
+ }
1201
+
1202
+ /** Hook-specific output for the ElicitationResult event. Return this to override the action or content before the response is sent to the MCP server. */
1203
+ export type ElicitationResultHookSpecificOutput = {
1204
+ hookEventName: "ElicitationResult"
1205
+ action?: "accept" | "decline" | "cancel"
1206
+ content?: Record<string, unknown>
1207
+ }
1208
+
1209
+ /** Hook-specific output for the WorktreeCreate event. Provides the absolute path to the created worktree directory. Command hooks print the path on stdout instead. */
1210
+ export type WorktreeCreateHookSpecificOutput = {
1211
+ hookEventName: "WorktreeCreate"
1212
+ worktreePath: string
1213
+ }
1214
+
1215
+ export type SyncHookJSONOutput = {
1216
+ continue?: boolean
1217
+ suppressOutput?: boolean
1218
+ stopReason?: string
1219
+ decision?: "approve" | "block"
1220
+ systemMessage?: string
1221
+ reason?: string
1222
+ hookSpecificOutput?: ({
1223
+ hookEventName: "PreToolUse"
1224
+ permissionDecision?: "allow" | "deny" | "ask"
1225
+ permissionDecisionReason?: string
1226
+ updatedInput?: Record<string, unknown>
1227
+ additionalContext?: string
1228
+ }) | ({
1229
+ hookEventName: "UserPromptSubmit"
1230
+ additionalContext?: string
1231
+ }) | ({
1232
+ hookEventName: "SessionStart"
1233
+ additionalContext?: string
1234
+ initialUserMessage?: string
1235
+ watchPaths?: string[]
1236
+ }) | ({
1237
+ hookEventName: "Setup"
1238
+ additionalContext?: string
1239
+ }) | ({
1240
+ hookEventName: "SubagentStart"
1241
+ additionalContext?: string
1242
+ }) | ({
1243
+ hookEventName: "PostToolUse"
1244
+ additionalContext?: string
1245
+ updatedMCPToolOutput?: unknown
1246
+ }) | ({
1247
+ hookEventName: "PostToolUseFailure"
1248
+ additionalContext?: string
1249
+ }) | ({
1250
+ hookEventName: "PermissionDenied"
1251
+ retry?: boolean
1252
+ }) | ({
1253
+ hookEventName: "Notification"
1254
+ additionalContext?: string
1255
+ }) | ({
1256
+ hookEventName: "PermissionRequest"
1257
+ decision: ({
1258
+ behavior: "allow"
1259
+ updatedInput?: Record<string, unknown>
1260
+ updatedPermissions?: (({
1261
+ type: "addRules"
1262
+ rules: {
1263
+ toolName: string
1264
+ ruleContent?: string
1265
+ }[]
1266
+ behavior: "allow" | "deny" | "ask"
1267
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1268
+ }) | ({
1269
+ type: "replaceRules"
1270
+ rules: {
1271
+ toolName: string
1272
+ ruleContent?: string
1273
+ }[]
1274
+ behavior: "allow" | "deny" | "ask"
1275
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1276
+ }) | ({
1277
+ type: "removeRules"
1278
+ rules: {
1279
+ toolName: string
1280
+ ruleContent?: string
1281
+ }[]
1282
+ behavior: "allow" | "deny" | "ask"
1283
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1284
+ }) | ({
1285
+ type: "setMode"
1286
+ mode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
1287
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1288
+ }) | ({
1289
+ type: "addDirectories"
1290
+ directories: string[]
1291
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1292
+ }) | ({
1293
+ type: "removeDirectories"
1294
+ directories: string[]
1295
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1296
+ }))[]
1297
+ }) | ({
1298
+ behavior: "deny"
1299
+ message?: string
1300
+ interrupt?: boolean
1301
+ })
1302
+ }) | ({
1303
+ hookEventName: "Elicitation"
1304
+ action?: "accept" | "decline" | "cancel"
1305
+ content?: Record<string, unknown>
1306
+ }) | ({
1307
+ hookEventName: "ElicitationResult"
1308
+ action?: "accept" | "decline" | "cancel"
1309
+ content?: Record<string, unknown>
1310
+ }) | ({
1311
+ hookEventName: "CwdChanged"
1312
+ watchPaths?: string[]
1313
+ }) | ({
1314
+ hookEventName: "FileChanged"
1315
+ watchPaths?: string[]
1316
+ }) | ({
1317
+ hookEventName: "WorktreeCreate"
1318
+ worktreePath: string
1319
+ })
1320
+ }
1321
+
1322
+ export type HookJSONOutput = ({
1323
+ async: true
1324
+ asyncTimeout?: number
1325
+ }) | ({
1326
+ continue?: boolean
1327
+ suppressOutput?: boolean
1328
+ stopReason?: string
1329
+ decision?: "approve" | "block"
1330
+ systemMessage?: string
1331
+ reason?: string
1332
+ hookSpecificOutput?: ({
1333
+ hookEventName: "PreToolUse"
1334
+ permissionDecision?: "allow" | "deny" | "ask"
1335
+ permissionDecisionReason?: string
1336
+ updatedInput?: Record<string, unknown>
1337
+ additionalContext?: string
1338
+ }) | ({
1339
+ hookEventName: "UserPromptSubmit"
1340
+ additionalContext?: string
1341
+ }) | ({
1342
+ hookEventName: "SessionStart"
1343
+ additionalContext?: string
1344
+ initialUserMessage?: string
1345
+ watchPaths?: string[]
1346
+ }) | ({
1347
+ hookEventName: "Setup"
1348
+ additionalContext?: string
1349
+ }) | ({
1350
+ hookEventName: "SubagentStart"
1351
+ additionalContext?: string
1352
+ }) | ({
1353
+ hookEventName: "PostToolUse"
1354
+ additionalContext?: string
1355
+ updatedMCPToolOutput?: unknown
1356
+ }) | ({
1357
+ hookEventName: "PostToolUseFailure"
1358
+ additionalContext?: string
1359
+ }) | ({
1360
+ hookEventName: "PermissionDenied"
1361
+ retry?: boolean
1362
+ }) | ({
1363
+ hookEventName: "Notification"
1364
+ additionalContext?: string
1365
+ }) | ({
1366
+ hookEventName: "PermissionRequest"
1367
+ decision: ({
1368
+ behavior: "allow"
1369
+ updatedInput?: Record<string, unknown>
1370
+ updatedPermissions?: (({
1371
+ type: "addRules"
1372
+ rules: {
1373
+ toolName: string
1374
+ ruleContent?: string
1375
+ }[]
1376
+ behavior: "allow" | "deny" | "ask"
1377
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1378
+ }) | ({
1379
+ type: "replaceRules"
1380
+ rules: {
1381
+ toolName: string
1382
+ ruleContent?: string
1383
+ }[]
1384
+ behavior: "allow" | "deny" | "ask"
1385
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1386
+ }) | ({
1387
+ type: "removeRules"
1388
+ rules: {
1389
+ toolName: string
1390
+ ruleContent?: string
1391
+ }[]
1392
+ behavior: "allow" | "deny" | "ask"
1393
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1394
+ }) | ({
1395
+ type: "setMode"
1396
+ mode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
1397
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1398
+ }) | ({
1399
+ type: "addDirectories"
1400
+ directories: string[]
1401
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1402
+ }) | ({
1403
+ type: "removeDirectories"
1404
+ directories: string[]
1405
+ destination: "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg"
1406
+ }))[]
1407
+ }) | ({
1408
+ behavior: "deny"
1409
+ message?: string
1410
+ interrupt?: boolean
1411
+ })
1412
+ }) | ({
1413
+ hookEventName: "Elicitation"
1414
+ action?: "accept" | "decline" | "cancel"
1415
+ content?: Record<string, unknown>
1416
+ }) | ({
1417
+ hookEventName: "ElicitationResult"
1418
+ action?: "accept" | "decline" | "cancel"
1419
+ content?: Record<string, unknown>
1420
+ }) | ({
1421
+ hookEventName: "CwdChanged"
1422
+ watchPaths?: string[]
1423
+ }) | ({
1424
+ hookEventName: "FileChanged"
1425
+ watchPaths?: string[]
1426
+ }) | ({
1427
+ hookEventName: "WorktreeCreate"
1428
+ worktreePath: string
1429
+ })
1430
+ })
1431
+
1432
+ export type PromptRequestOption = {
1433
+ key: string
1434
+ label: string
1435
+ description?: string
1436
+ }
1437
+
1438
+ export type PromptRequest = {
1439
+ prompt: string
1440
+ message: string
1441
+ options: {
1442
+ key: string
1443
+ label: string
1444
+ description?: string
1445
+ }[]
1446
+ }
1447
+
1448
+ export type PromptResponse = {
1449
+ prompt_response: string
1450
+ selected: string
1451
+ }
1452
+
1453
+ /** Information about an available skill (invoked via /command syntax). */
1454
+ export type SlashCommand = {
1455
+ name: string
1456
+ description: string
1457
+ argumentHint: string
1458
+ }
1459
+
1460
+ /** Information about an available subagent that can be invoked via the Task tool. */
1461
+ export type AgentInfo = {
1462
+ name: string
1463
+ description: string
1464
+ model?: string
1465
+ }
1466
+
1467
+ /** Information about an available model. */
1468
+ export type ModelInfo = {
1469
+ value: string
1470
+ displayName: string
1471
+ description: string
1472
+ supportsEffort?: boolean
1473
+ supportedEffortLevels?: ("low" | "medium" | "high" | "xhigh" | "max" | "ultracode")[]
1474
+ supportsAdaptiveThinking?: boolean
1475
+ supportsFastMode?: boolean
1476
+ supportsAutoMode?: boolean
1477
+ }
1478
+
1479
+ /** Information about the logged in user's account. */
1480
+ export type AccountInfo = {
1481
+ email?: string
1482
+ organization?: string
1483
+ subscriptionType?: string
1484
+ tokenSource?: string
1485
+ apiKeySource?: string
1486
+ apiProvider?: "firstParty" | "bedrock" | "vertex" | "foundry" | "openai" | "gemini" | "github" | "codex" | "nvidia-nim" | "minimax" | "mistral" | "xai" | "xiaomi-mimo"
1487
+ }
1488
+
1489
+ export type AgentMcpServerSpec = string | (Record<string, ({
1490
+ type?: "stdio"
1491
+ command: string
1492
+ args?: string[]
1493
+ env?: Record<string, string>
1494
+ }) | ({
1495
+ type: "sse"
1496
+ url: string
1497
+ headers?: Record<string, string>
1498
+ }) | ({
1499
+ type: "http"
1500
+ url: string
1501
+ headers?: Record<string, string>
1502
+ }) | ({
1503
+ type: "sdk"
1504
+ name: string
1505
+ })>)
1506
+
1507
+ /** Definition for a custom subagent that can be invoked via the Agent tool. */
1508
+ export type AgentDefinition = {
1509
+ description: string
1510
+ tools?: string[]
1511
+ disallowedTools?: string[]
1512
+ prompt: string
1513
+ model?: string
1514
+ mcpServers?: (string | (Record<string, ({
1515
+ type?: "stdio"
1516
+ command: string
1517
+ args?: string[]
1518
+ env?: Record<string, string>
1519
+ }) | ({
1520
+ type: "sse"
1521
+ url: string
1522
+ headers?: Record<string, string>
1523
+ }) | ({
1524
+ type: "http"
1525
+ url: string
1526
+ headers?: Record<string, string>
1527
+ }) | ({
1528
+ type: "sdk"
1529
+ name: string
1530
+ })>))[]
1531
+ criticalSystemReminder_EXPERIMENTAL?: string
1532
+ skills?: string[]
1533
+ initialPrompt?: string
1534
+ maxTurns?: number
1535
+ maxSteps?: number
1536
+ background?: boolean
1537
+ memory?: "user" | "project" | "local"
1538
+ effort?: "low" | "medium" | "high" | "xhigh" | "max" | number
1539
+ permissionMode?: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
1540
+ }
1541
+
1542
+ /** Source for loading filesystem-based settings. 'user' - Global user settings (~/.openclaude/settings.json). 'project' - Project settings (.openclaude/settings.json). 'local' - Local settings (.openclaude/settings.local.json). */
1543
+ export type SettingSource = "user" | "project" | "local"
1544
+
1545
+ /** Configuration for loading a plugin. */
1546
+ export type SdkPluginConfig = {
1547
+ type: "local"
1548
+ path: string
1549
+ }
1550
+
1551
+ /** Result of a rewindFiles operation. */
1552
+ export type RewindFilesResult = {
1553
+ canRewind: boolean
1554
+ error?: string
1555
+ filesChanged?: string[]
1556
+ insertions?: number
1557
+ deletions?: number
1558
+ }
1559
+
1560
+ export type SDKAssistantMessageError = "authentication_failed" | "billing_error" | "rate_limit" | "invalid_request" | "server_error" | "unknown" | "max_output_tokens"
1561
+
1562
+ export type SDKStatus = "compacting" | null
1563
+
1564
+ export type SDKUserMessage = {
1565
+ type: "user"
1566
+ message: Record<string, unknown> & { role: "user", content: string | Array<unknown> }
1567
+ parent_tool_use_id: string | null
1568
+ isSynthetic?: boolean
1569
+ tool_use_result?: unknown
1570
+ priority?: "now" | "next" | "later"
1571
+ timestamp?: string
1572
+ uuid?: string
1573
+ session_id?: string
1574
+ }
1575
+
1576
+ export type SDKUserMessageReplay = {
1577
+ type: "user"
1578
+ message: Record<string, unknown> & { role: "user", content: string | Array<unknown> }
1579
+ parent_tool_use_id: string | null
1580
+ isSynthetic?: boolean
1581
+ tool_use_result?: unknown
1582
+ priority?: "now" | "next" | "later"
1583
+ timestamp?: string
1584
+ uuid: string
1585
+ session_id: string
1586
+ isReplay: true
1587
+ }
1588
+
1589
+ /** Rate limit information for claude.ai subscription users. */
1590
+ export type SDKRateLimitInfo = {
1591
+ status: "allowed" | "allowed_warning" | "rejected"
1592
+ resetsAt?: number
1593
+ rateLimitType?: "five_hour" | "seven_day" | "seven_day_opus" | "seven_day_sonnet" | "overage"
1594
+ utilization?: number
1595
+ overageStatus?: "allowed" | "allowed_warning" | "rejected"
1596
+ overageResetsAt?: number
1597
+ overageDisabledReason?: "overage_not_provisioned" | "org_level_disabled" | "org_level_disabled_until" | "out_of_credits" | "seat_tier_level_disabled" | "member_level_disabled" | "seat_tier_zero_credit_limit" | "group_zero_credit_limit" | "member_zero_credit_limit" | "org_service_level_disabled" | "org_service_zero_credit_limit" | "no_limits_configured" | "unknown"
1598
+ isUsingOverage?: boolean
1599
+ surpassedThreshold?: number
1600
+ }
1601
+
1602
+ export type SDKAssistantMessage = {
1603
+ type: "assistant"
1604
+ message: Record<string, unknown> & { role: "assistant", content: Array<unknown> }
1605
+ parent_tool_use_id: string | null
1606
+ error?: "authentication_failed" | "billing_error" | "rate_limit" | "invalid_request" | "server_error" | "unknown" | "max_output_tokens"
1607
+ uuid: string
1608
+ session_id: string
1609
+ }
1610
+
1611
+ /** Rate limit event emitted when rate limit info changes. */
1612
+ export type SDKRateLimitEvent = {
1613
+ type: "rate_limit_event"
1614
+ rate_limit_info: {
1615
+ status: "allowed" | "allowed_warning" | "rejected"
1616
+ resetsAt?: number
1617
+ rateLimitType?: "five_hour" | "seven_day" | "seven_day_opus" | "seven_day_sonnet" | "overage"
1618
+ utilization?: number
1619
+ overageStatus?: "allowed" | "allowed_warning" | "rejected"
1620
+ overageResetsAt?: number
1621
+ overageDisabledReason?: "overage_not_provisioned" | "org_level_disabled" | "org_level_disabled_until" | "out_of_credits" | "seat_tier_level_disabled" | "member_level_disabled" | "seat_tier_zero_credit_limit" | "group_zero_credit_limit" | "member_zero_credit_limit" | "org_service_level_disabled" | "org_service_zero_credit_limit" | "no_limits_configured" | "unknown"
1622
+ isUsingOverage?: boolean
1623
+ surpassedThreshold?: number
1624
+ }
1625
+ uuid: string
1626
+ session_id: string
1627
+ }
1628
+
1629
+ /** @internal Streamlined text message - replaces SDKAssistantMessage in streamlined output. Text content preserved, thinking and tool_use blocks removed. */
1630
+ export type SDKStreamlinedTextMessage = {
1631
+ type: "streamlined_text"
1632
+ text: string
1633
+ session_id: string
1634
+ uuid: string
1635
+ }
1636
+
1637
+ /** @internal Streamlined tool use summary - replaces tool_use blocks in streamlined output with a cumulative summary string. */
1638
+ export type SDKStreamlinedToolUseSummaryMessage = {
1639
+ type: "streamlined_tool_use_summary"
1640
+ tool_summary: string
1641
+ session_id: string
1642
+ uuid: string
1643
+ }
1644
+
1645
+ export type SDKPermissionDenial = {
1646
+ tool_name: string
1647
+ tool_use_id: string
1648
+ tool_input: Record<string, unknown>
1649
+ }
1650
+
1651
+ export type SDKResultSuccess = {
1652
+ type: "result"
1653
+ subtype: "success"
1654
+ duration_ms: number
1655
+ duration_api_ms: number
1656
+ is_error: boolean
1657
+ num_turns: number
1658
+ result: string
1659
+ stop_reason: string | null
1660
+ total_cost_usd: number
1661
+ usage: { input_tokens: number; output_tokens: number; cache_creation_input_tokens: number; cache_read_input_tokens: number; cache_creation?: { ephemeral_1h_input_tokens?: number; ephemeral_5m_input_tokens?: number }; server_tool_use?: { web_search_requests?: number; web_fetch_requests?: number }; service_tier?: string; [key: string]: unknown }
1662
+ modelUsage: Record<string, {
1663
+ inputTokens: number
1664
+ outputTokens: number
1665
+ cacheReadInputTokens: number
1666
+ cacheCreationInputTokens: number
1667
+ webSearchRequests: number
1668
+ costUSD: number
1669
+ contextWindow: number
1670
+ maxOutputTokens: number
1671
+ }>
1672
+ permission_denials: {
1673
+ tool_name: string
1674
+ tool_use_id: string
1675
+ tool_input: Record<string, unknown>
1676
+ }[]
1677
+ structured_output?: unknown
1678
+ fast_mode_state?: "off" | "cooldown" | "on"
1679
+ uuid: string
1680
+ session_id: string
1681
+ }
1682
+
1683
+ export type SDKResultError = {
1684
+ type: "result"
1685
+ subtype: "error_during_execution" | "error_max_turns" | "error_max_budget_usd" | "error_max_structured_output_retries"
1686
+ duration_ms: number
1687
+ duration_api_ms: number
1688
+ is_error: boolean
1689
+ num_turns: number
1690
+ stop_reason: string | null
1691
+ total_cost_usd: number
1692
+ usage: { input_tokens: number; output_tokens: number; cache_creation_input_tokens: number; cache_read_input_tokens: number; cache_creation?: { ephemeral_1h_input_tokens?: number; ephemeral_5m_input_tokens?: number }; server_tool_use?: { web_search_requests?: number; web_fetch_requests?: number }; service_tier?: string; [key: string]: unknown }
1693
+ modelUsage: Record<string, {
1694
+ inputTokens: number
1695
+ outputTokens: number
1696
+ cacheReadInputTokens: number
1697
+ cacheCreationInputTokens: number
1698
+ webSearchRequests: number
1699
+ costUSD: number
1700
+ contextWindow: number
1701
+ maxOutputTokens: number
1702
+ }>
1703
+ permission_denials: {
1704
+ tool_name: string
1705
+ tool_use_id: string
1706
+ tool_input: Record<string, unknown>
1707
+ }[]
1708
+ errors: string[]
1709
+ fast_mode_state?: "off" | "cooldown" | "on"
1710
+ uuid: string
1711
+ session_id: string
1712
+ }
1713
+
1714
+ export type SDKResultMessage = ({
1715
+ type: "result"
1716
+ subtype: "success"
1717
+ duration_ms: number
1718
+ duration_api_ms: number
1719
+ is_error: boolean
1720
+ num_turns: number
1721
+ result: string
1722
+ stop_reason: string | null
1723
+ total_cost_usd: number
1724
+ usage: { input_tokens: number; output_tokens: number; cache_creation_input_tokens: number; cache_read_input_tokens: number; cache_creation?: { ephemeral_1h_input_tokens?: number; ephemeral_5m_input_tokens?: number }; server_tool_use?: { web_search_requests?: number; web_fetch_requests?: number }; service_tier?: string; [key: string]: unknown }
1725
+ modelUsage: Record<string, {
1726
+ inputTokens: number
1727
+ outputTokens: number
1728
+ cacheReadInputTokens: number
1729
+ cacheCreationInputTokens: number
1730
+ webSearchRequests: number
1731
+ costUSD: number
1732
+ contextWindow: number
1733
+ maxOutputTokens: number
1734
+ }>
1735
+ permission_denials: {
1736
+ tool_name: string
1737
+ tool_use_id: string
1738
+ tool_input: Record<string, unknown>
1739
+ }[]
1740
+ structured_output?: unknown
1741
+ fast_mode_state?: "off" | "cooldown" | "on"
1742
+ uuid: string
1743
+ session_id: string
1744
+ }) | ({
1745
+ type: "result"
1746
+ subtype: "error_during_execution" | "error_max_turns" | "error_max_budget_usd" | "error_max_structured_output_retries"
1747
+ duration_ms: number
1748
+ duration_api_ms: number
1749
+ is_error: boolean
1750
+ num_turns: number
1751
+ stop_reason: string | null
1752
+ total_cost_usd: number
1753
+ usage: { input_tokens: number; output_tokens: number; cache_creation_input_tokens: number; cache_read_input_tokens: number; cache_creation?: { ephemeral_1h_input_tokens?: number; ephemeral_5m_input_tokens?: number }; server_tool_use?: { web_search_requests?: number; web_fetch_requests?: number }; service_tier?: string; [key: string]: unknown }
1754
+ modelUsage: Record<string, {
1755
+ inputTokens: number
1756
+ outputTokens: number
1757
+ cacheReadInputTokens: number
1758
+ cacheCreationInputTokens: number
1759
+ webSearchRequests: number
1760
+ costUSD: number
1761
+ contextWindow: number
1762
+ maxOutputTokens: number
1763
+ }>
1764
+ permission_denials: {
1765
+ tool_name: string
1766
+ tool_use_id: string
1767
+ tool_input: Record<string, unknown>
1768
+ }[]
1769
+ errors: string[]
1770
+ fast_mode_state?: "off" | "cooldown" | "on"
1771
+ uuid: string
1772
+ session_id: string
1773
+ })
1774
+
1775
+ export type SDKSystemMessage = {
1776
+ type: "system"
1777
+ subtype: "init"
1778
+ agents?: string[]
1779
+ apiKeySource: "user" | "project" | "org" | "temporary" | "oauth" | "none"
1780
+ betas?: string[]
1781
+ claude_code_version: string
1782
+ cwd: string
1783
+ tools: string[]
1784
+ mcp_servers: {
1785
+ name: string
1786
+ status: string
1787
+ }[]
1788
+ model: string
1789
+ permissionMode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
1790
+ slash_commands: string[]
1791
+ output_style: string
1792
+ skills: string[]
1793
+ plugins: {
1794
+ name: string
1795
+ path: string
1796
+ source?: string
1797
+ }[]
1798
+ fast_mode_state?: "off" | "cooldown" | "on"
1799
+ uuid: string
1800
+ session_id: string
1801
+ }
1802
+
1803
+ export type SDKPartialAssistantMessage = {
1804
+ type: "stream_event"
1805
+ event: Record<string, unknown>
1806
+ parent_tool_use_id: string | null
1807
+ uuid: string
1808
+ session_id: string
1809
+ }
1810
+
1811
+ export type SDKCompactBoundaryMessage = {
1812
+ type: "system"
1813
+ subtype: "compact_boundary"
1814
+ compact_metadata: {
1815
+ trigger: "manual" | "auto"
1816
+ pre_tokens: number
1817
+ preserved_segment?: {
1818
+ head_uuid: string
1819
+ anchor_uuid: string
1820
+ tail_uuid: string
1821
+ }
1822
+ }
1823
+ uuid: string
1824
+ session_id: string
1825
+ }
1826
+
1827
+ export type SDKStatusMessage = {
1828
+ type: "system"
1829
+ subtype: "status"
1830
+ status: "compacting" | null
1831
+ permissionMode?: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
1832
+ uuid: string
1833
+ session_id: string
1834
+ }
1835
+
1836
+ /** @internal Background post-turn summary emitted after each assistant turn. summarizes_uuid points to the assistant message this summarizes. */
1837
+ export type SDKPostTurnSummaryMessage = {
1838
+ type: "system"
1839
+ subtype: "post_turn_summary"
1840
+ summarizes_uuid: string
1841
+ status_category: "blocked" | "waiting" | "completed" | "review_ready" | "failed"
1842
+ status_detail: string
1843
+ is_noteworthy: boolean
1844
+ title: string
1845
+ description: string
1846
+ recent_action: string
1847
+ needs_action: string
1848
+ artifact_urls: string[]
1849
+ uuid: string
1850
+ session_id: string
1851
+ }
1852
+
1853
+ /** Emitted when an API request fails with a retryable error and will be retried after a delay. error_status is null for connection errors (e.g. timeouts) that had no HTTP response. */
1854
+ export type SDKAPIRetryMessage = {
1855
+ type: "system"
1856
+ subtype: "api_retry"
1857
+ attempt: number
1858
+ max_retries: number
1859
+ retry_delay_ms: number
1860
+ error_status: number | null
1861
+ error: "authentication_failed" | "billing_error" | "rate_limit" | "invalid_request" | "server_error" | "unknown" | "max_output_tokens"
1862
+ uuid: string
1863
+ session_id: string
1864
+ }
1865
+
1866
+ /** Output from a local slash command (e.g. /voice, /cost). Displayed as assistant-style text in the transcript. */
1867
+ export type SDKLocalCommandOutputMessage = {
1868
+ type: "system"
1869
+ subtype: "local_command_output"
1870
+ content: string
1871
+ uuid: string
1872
+ session_id: string
1873
+ }
1874
+
1875
+ export type SDKHookStartedMessage = {
1876
+ type: "system"
1877
+ subtype: "hook_started"
1878
+ hook_id: string
1879
+ hook_name: string
1880
+ hook_event: string
1881
+ uuid: string
1882
+ session_id: string
1883
+ }
1884
+
1885
+ export type SDKHookProgressMessage = {
1886
+ type: "system"
1887
+ subtype: "hook_progress"
1888
+ hook_id: string
1889
+ hook_name: string
1890
+ hook_event: string
1891
+ stdout: string
1892
+ stderr: string
1893
+ output: string
1894
+ uuid: string
1895
+ session_id: string
1896
+ }
1897
+
1898
+ export type SDKHookResponseMessage = {
1899
+ type: "system"
1900
+ subtype: "hook_response"
1901
+ hook_id: string
1902
+ hook_name: string
1903
+ hook_event: string
1904
+ output: string
1905
+ stdout: string
1906
+ stderr: string
1907
+ exit_code?: number
1908
+ outcome: "success" | "error" | "cancelled"
1909
+ uuid: string
1910
+ session_id: string
1911
+ }
1912
+
1913
+ export type SDKToolProgressMessage = {
1914
+ type: "tool_progress"
1915
+ tool_use_id: string
1916
+ tool_name: string
1917
+ parent_tool_use_id: string | null
1918
+ elapsed_time_seconds: number
1919
+ task_id?: string
1920
+ uuid: string
1921
+ session_id: string
1922
+ }
1923
+
1924
+ export type SDKAuthStatusMessage = {
1925
+ type: "auth_status"
1926
+ isAuthenticating: boolean
1927
+ output: string[]
1928
+ error?: string
1929
+ uuid: string
1930
+ session_id: string
1931
+ }
1932
+
1933
+ export type SDKFilesPersistedEvent = {
1934
+ type: "system"
1935
+ subtype: "files_persisted"
1936
+ files: {
1937
+ filename: string
1938
+ file_id: string
1939
+ }[]
1940
+ failed: {
1941
+ filename: string
1942
+ error: string
1943
+ }[]
1944
+ processed_at: string
1945
+ uuid: string
1946
+ session_id: string
1947
+ }
1948
+
1949
+ export type SDKTaskNotificationMessage = {
1950
+ type: "system"
1951
+ subtype: "task_notification"
1952
+ task_id: string
1953
+ tool_use_id?: string
1954
+ status: "completed" | "failed" | "stopped"
1955
+ output_file: string
1956
+ summary: string
1957
+ usage?: {
1958
+ total_tokens: number
1959
+ tool_uses: number
1960
+ duration_ms: number
1961
+ }
1962
+ uuid: string
1963
+ session_id: string
1964
+ }
1965
+
1966
+ export type SDKTaskStartedMessage = {
1967
+ type: "system"
1968
+ subtype: "task_started"
1969
+ task_id: string
1970
+ tool_use_id?: string
1971
+ description: string
1972
+ task_type?: string
1973
+ workflow_name?: string
1974
+ prompt?: string
1975
+ uuid: string
1976
+ session_id: string
1977
+ }
1978
+
1979
+ export type SDKTaskProgressMessage = {
1980
+ type: "system"
1981
+ subtype: "task_progress"
1982
+ task_id: string
1983
+ tool_use_id?: string
1984
+ description: string
1985
+ usage: {
1986
+ total_tokens: number
1987
+ tool_uses: number
1988
+ duration_ms: number
1989
+ }
1990
+ last_tool_name?: string
1991
+ summary?: string
1992
+ uuid: string
1993
+ session_id: string
1994
+ }
1995
+
1996
+ /** Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal. */
1997
+ export type SDKSessionStateChangedMessage = {
1998
+ type: "system"
1999
+ subtype: "session_state_changed"
2000
+ state: "idle" | "running" | "requires_action"
2001
+ uuid: string
2002
+ session_id: string
2003
+ }
2004
+
2005
+ /** Opt-in headless liveness signal emitted while --print output is quiet. */
2006
+ export type SDKHeartbeatMessage = {
2007
+ type: "system"
2008
+ subtype: "heartbeat"
2009
+ timestamp: string
2010
+ elapsed_ms: number
2011
+ since_last_activity_ms: number
2012
+ state: "starting" | "running" | "requires_action" | "idle" | "shutting_down"
2013
+ phase: "startup" | "loading_session" | "connecting_mcp" | "draining_commands" | "in_turn" | "waiting_for_permission" | "waiting_for_agents" | "flushing" | "shutting_down"
2014
+ heartbeat_index: number
2015
+ pending_permission_requests: number
2016
+ background_tasks: Record<string, number>
2017
+ uuid: string
2018
+ session_id: string
2019
+ }
2020
+
2021
+ export type SDKToolUseSummaryMessage = {
2022
+ type: "tool_use_summary"
2023
+ summary: string
2024
+ preceding_tool_use_ids: string[]
2025
+ uuid: string
2026
+ session_id: string
2027
+ }
2028
+
2029
+ /** Emitted when an MCP server confirms that a URL-mode elicitation is complete. */
2030
+ export type SDKElicitationCompleteMessage = {
2031
+ type: "system"
2032
+ subtype: "elicitation_complete"
2033
+ mcp_server_name: string
2034
+ elicitation_id: string
2035
+ uuid: string
2036
+ session_id: string
2037
+ }
2038
+
2039
+ /** Predicted next user prompt, emitted after each turn when promptSuggestions is enabled. */
2040
+ export type SDKPromptSuggestionMessage = {
2041
+ type: "prompt_suggestion"
2042
+ suggestion: string
2043
+ uuid: string
2044
+ session_id: string
2045
+ }
2046
+
2047
+ /** Session metadata returned by listSessions and getSessionInfo. */
2048
+ export type SDKSessionInfo = {
2049
+ sessionId: string
2050
+ summary: string
2051
+ lastModified: number
2052
+ fileSize?: number
2053
+ customTitle?: string
2054
+ firstPrompt?: string
2055
+ gitBranch?: string
2056
+ cwd?: string
2057
+ tag?: string
2058
+ createdAt?: number
2059
+ }
2060
+
2061
+ export type SDKMessage = ({
2062
+ type: "assistant"
2063
+ message: Record<string, unknown> & { role: "assistant", content: Array<unknown> }
2064
+ parent_tool_use_id: string | null
2065
+ error?: "authentication_failed" | "billing_error" | "rate_limit" | "invalid_request" | "server_error" | "unknown" | "max_output_tokens"
2066
+ uuid: string
2067
+ session_id: string
2068
+ }) | ({
2069
+ type: "user"
2070
+ message: Record<string, unknown> & { role: "user", content: string | Array<unknown> }
2071
+ parent_tool_use_id: string | null
2072
+ isSynthetic?: boolean
2073
+ tool_use_result?: unknown
2074
+ priority?: "now" | "next" | "later"
2075
+ timestamp?: string
2076
+ uuid?: string
2077
+ session_id?: string
2078
+ }) | ({
2079
+ type: "user"
2080
+ message: Record<string, unknown> & { role: "user", content: string | Array<unknown> }
2081
+ parent_tool_use_id: string | null
2082
+ isSynthetic?: boolean
2083
+ tool_use_result?: unknown
2084
+ priority?: "now" | "next" | "later"
2085
+ timestamp?: string
2086
+ uuid: string
2087
+ session_id: string
2088
+ isReplay: true
2089
+ }) | (({
2090
+ type: "result"
2091
+ subtype: "success"
2092
+ duration_ms: number
2093
+ duration_api_ms: number
2094
+ is_error: boolean
2095
+ num_turns: number
2096
+ result: string
2097
+ stop_reason: string | null
2098
+ total_cost_usd: number
2099
+ usage: { input_tokens: number; output_tokens: number; cache_creation_input_tokens: number; cache_read_input_tokens: number; cache_creation?: { ephemeral_1h_input_tokens?: number; ephemeral_5m_input_tokens?: number }; server_tool_use?: { web_search_requests?: number; web_fetch_requests?: number }; service_tier?: string; [key: string]: unknown }
2100
+ modelUsage: Record<string, {
2101
+ inputTokens: number
2102
+ outputTokens: number
2103
+ cacheReadInputTokens: number
2104
+ cacheCreationInputTokens: number
2105
+ webSearchRequests: number
2106
+ costUSD: number
2107
+ contextWindow: number
2108
+ maxOutputTokens: number
2109
+ }>
2110
+ permission_denials: {
2111
+ tool_name: string
2112
+ tool_use_id: string
2113
+ tool_input: Record<string, unknown>
2114
+ }[]
2115
+ structured_output?: unknown
2116
+ fast_mode_state?: "off" | "cooldown" | "on"
2117
+ uuid: string
2118
+ session_id: string
2119
+ }) | ({
2120
+ type: "result"
2121
+ subtype: "error_during_execution" | "error_max_turns" | "error_max_budget_usd" | "error_max_structured_output_retries"
2122
+ duration_ms: number
2123
+ duration_api_ms: number
2124
+ is_error: boolean
2125
+ num_turns: number
2126
+ stop_reason: string | null
2127
+ total_cost_usd: number
2128
+ usage: { input_tokens: number; output_tokens: number; cache_creation_input_tokens: number; cache_read_input_tokens: number; cache_creation?: { ephemeral_1h_input_tokens?: number; ephemeral_5m_input_tokens?: number }; server_tool_use?: { web_search_requests?: number; web_fetch_requests?: number }; service_tier?: string; [key: string]: unknown }
2129
+ modelUsage: Record<string, {
2130
+ inputTokens: number
2131
+ outputTokens: number
2132
+ cacheReadInputTokens: number
2133
+ cacheCreationInputTokens: number
2134
+ webSearchRequests: number
2135
+ costUSD: number
2136
+ contextWindow: number
2137
+ maxOutputTokens: number
2138
+ }>
2139
+ permission_denials: {
2140
+ tool_name: string
2141
+ tool_use_id: string
2142
+ tool_input: Record<string, unknown>
2143
+ }[]
2144
+ errors: string[]
2145
+ fast_mode_state?: "off" | "cooldown" | "on"
2146
+ uuid: string
2147
+ session_id: string
2148
+ })) | ({
2149
+ type: "system"
2150
+ subtype: "init"
2151
+ agents?: string[]
2152
+ apiKeySource: "user" | "project" | "org" | "temporary" | "oauth" | "none"
2153
+ betas?: string[]
2154
+ claude_code_version: string
2155
+ cwd: string
2156
+ tools: string[]
2157
+ mcp_servers: {
2158
+ name: string
2159
+ status: string
2160
+ }[]
2161
+ model: string
2162
+ permissionMode: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
2163
+ slash_commands: string[]
2164
+ output_style: string
2165
+ skills: string[]
2166
+ plugins: {
2167
+ name: string
2168
+ path: string
2169
+ source?: string
2170
+ }[]
2171
+ fast_mode_state?: "off" | "cooldown" | "on"
2172
+ uuid: string
2173
+ session_id: string
2174
+ }) | ({
2175
+ type: "stream_event"
2176
+ event: Record<string, unknown>
2177
+ parent_tool_use_id: string | null
2178
+ uuid: string
2179
+ session_id: string
2180
+ }) | ({
2181
+ type: "system"
2182
+ subtype: "compact_boundary"
2183
+ compact_metadata: {
2184
+ trigger: "manual" | "auto"
2185
+ pre_tokens: number
2186
+ preserved_segment?: {
2187
+ head_uuid: string
2188
+ anchor_uuid: string
2189
+ tail_uuid: string
2190
+ }
2191
+ }
2192
+ uuid: string
2193
+ session_id: string
2194
+ }) | ({
2195
+ type: "system"
2196
+ subtype: "status"
2197
+ status: "compacting" | null
2198
+ permissionMode?: "default" | "acceptEdits" | "bypassPermissions" | "fullAccess" | "plan" | "dontAsk"
2199
+ uuid: string
2200
+ session_id: string
2201
+ }) | ({
2202
+ type: "system"
2203
+ subtype: "api_retry"
2204
+ attempt: number
2205
+ max_retries: number
2206
+ retry_delay_ms: number
2207
+ error_status: number | null
2208
+ error: "authentication_failed" | "billing_error" | "rate_limit" | "invalid_request" | "server_error" | "unknown" | "max_output_tokens"
2209
+ uuid: string
2210
+ session_id: string
2211
+ }) | ({
2212
+ type: "system"
2213
+ subtype: "local_command_output"
2214
+ content: string
2215
+ uuid: string
2216
+ session_id: string
2217
+ }) | ({
2218
+ type: "system"
2219
+ subtype: "hook_started"
2220
+ hook_id: string
2221
+ hook_name: string
2222
+ hook_event: string
2223
+ uuid: string
2224
+ session_id: string
2225
+ }) | ({
2226
+ type: "system"
2227
+ subtype: "hook_progress"
2228
+ hook_id: string
2229
+ hook_name: string
2230
+ hook_event: string
2231
+ stdout: string
2232
+ stderr: string
2233
+ output: string
2234
+ uuid: string
2235
+ session_id: string
2236
+ }) | ({
2237
+ type: "system"
2238
+ subtype: "hook_response"
2239
+ hook_id: string
2240
+ hook_name: string
2241
+ hook_event: string
2242
+ output: string
2243
+ stdout: string
2244
+ stderr: string
2245
+ exit_code?: number
2246
+ outcome: "success" | "error" | "cancelled"
2247
+ uuid: string
2248
+ session_id: string
2249
+ }) | ({
2250
+ type: "tool_progress"
2251
+ tool_use_id: string
2252
+ tool_name: string
2253
+ parent_tool_use_id: string | null
2254
+ elapsed_time_seconds: number
2255
+ task_id?: string
2256
+ uuid: string
2257
+ session_id: string
2258
+ }) | ({
2259
+ type: "auth_status"
2260
+ isAuthenticating: boolean
2261
+ output: string[]
2262
+ error?: string
2263
+ uuid: string
2264
+ session_id: string
2265
+ }) | ({
2266
+ type: "system"
2267
+ subtype: "task_notification"
2268
+ task_id: string
2269
+ tool_use_id?: string
2270
+ status: "completed" | "failed" | "stopped"
2271
+ output_file: string
2272
+ summary: string
2273
+ usage?: {
2274
+ total_tokens: number
2275
+ tool_uses: number
2276
+ duration_ms: number
2277
+ }
2278
+ uuid: string
2279
+ session_id: string
2280
+ }) | ({
2281
+ type: "system"
2282
+ subtype: "task_started"
2283
+ task_id: string
2284
+ tool_use_id?: string
2285
+ description: string
2286
+ task_type?: string
2287
+ workflow_name?: string
2288
+ prompt?: string
2289
+ uuid: string
2290
+ session_id: string
2291
+ }) | ({
2292
+ type: "system"
2293
+ subtype: "task_progress"
2294
+ task_id: string
2295
+ tool_use_id?: string
2296
+ description: string
2297
+ usage: {
2298
+ total_tokens: number
2299
+ tool_uses: number
2300
+ duration_ms: number
2301
+ }
2302
+ last_tool_name?: string
2303
+ summary?: string
2304
+ uuid: string
2305
+ session_id: string
2306
+ }) | ({
2307
+ type: "system"
2308
+ subtype: "session_state_changed"
2309
+ state: "idle" | "running" | "requires_action"
2310
+ uuid: string
2311
+ session_id: string
2312
+ }) | ({
2313
+ type: "system"
2314
+ subtype: "heartbeat"
2315
+ timestamp: string
2316
+ elapsed_ms: number
2317
+ since_last_activity_ms: number
2318
+ state: "starting" | "running" | "requires_action" | "idle" | "shutting_down"
2319
+ phase: "startup" | "loading_session" | "connecting_mcp" | "draining_commands" | "in_turn" | "waiting_for_permission" | "waiting_for_agents" | "flushing" | "shutting_down"
2320
+ heartbeat_index: number
2321
+ pending_permission_requests: number
2322
+ background_tasks: Record<string, number>
2323
+ uuid: string
2324
+ session_id: string
2325
+ }) | ({
2326
+ type: "system"
2327
+ subtype: "files_persisted"
2328
+ files: {
2329
+ filename: string
2330
+ file_id: string
2331
+ }[]
2332
+ failed: {
2333
+ filename: string
2334
+ error: string
2335
+ }[]
2336
+ processed_at: string
2337
+ uuid: string
2338
+ session_id: string
2339
+ }) | ({
2340
+ type: "tool_use_summary"
2341
+ summary: string
2342
+ preceding_tool_use_ids: string[]
2343
+ uuid: string
2344
+ session_id: string
2345
+ }) | ({
2346
+ type: "rate_limit_event"
2347
+ rate_limit_info: {
2348
+ status: "allowed" | "allowed_warning" | "rejected"
2349
+ resetsAt?: number
2350
+ rateLimitType?: "five_hour" | "seven_day" | "seven_day_opus" | "seven_day_sonnet" | "overage"
2351
+ utilization?: number
2352
+ overageStatus?: "allowed" | "allowed_warning" | "rejected"
2353
+ overageResetsAt?: number
2354
+ overageDisabledReason?: "overage_not_provisioned" | "org_level_disabled" | "org_level_disabled_until" | "out_of_credits" | "seat_tier_level_disabled" | "member_level_disabled" | "seat_tier_zero_credit_limit" | "group_zero_credit_limit" | "member_zero_credit_limit" | "org_service_level_disabled" | "org_service_zero_credit_limit" | "no_limits_configured" | "unknown"
2355
+ isUsingOverage?: boolean
2356
+ surpassedThreshold?: number
2357
+ }
2358
+ uuid: string
2359
+ session_id: string
2360
+ }) | ({
2361
+ type: "system"
2362
+ subtype: "elicitation_complete"
2363
+ mcp_server_name: string
2364
+ elicitation_id: string
2365
+ uuid: string
2366
+ session_id: string
2367
+ }) | ({
2368
+ type: "prompt_suggestion"
2369
+ suggestion: string
2370
+ uuid: string
2371
+ session_id: string
2372
+ }) | ({
2373
+ type: "permission_request"
2374
+ request_id: string
2375
+ tool_name: string
2376
+ tool_use_id: string
2377
+ input: Record<string, unknown>
2378
+ uuid: string
2379
+ session_id: string
2380
+ })
2381
+
2382
+ /** Fast mode state: off, in cooldown after rate limit, or actively enabled. */
2383
+ export type FastModeState = "off" | "cooldown" | "on"
2384
+
2385
+ export type ExitReason = "clear" | "resume" | "logout" | "prompt_input_exit" | "other" | "bypass_permissions_disabled"