Skip to main content

github_copilot_sdk/generated/
session_events.rs

1//! Auto-generated from session-events.schema.json — do not edit manually.
2
3#![allow(deprecated)]
4
5use std::collections::HashMap;
6
7use serde::{Deserialize, Serialize};
8
9use crate::types::{RequestId, SessionId};
10
11/// Identifies the kind of session event.
12#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
13pub enum SessionEventType {
14    #[serde(rename = "session.start")]
15    SessionStart,
16    #[serde(rename = "session.resume")]
17    SessionResume,
18    #[serde(rename = "session.remote_steerable_changed")]
19    SessionRemoteSteerableChanged,
20    #[serde(rename = "session.error")]
21    SessionError,
22    #[serde(rename = "session.idle")]
23    SessionIdle,
24    #[serde(rename = "session.title_changed")]
25    SessionTitleChanged,
26    #[serde(rename = "session.schedule_created")]
27    SessionScheduleCreated,
28    #[serde(rename = "session.schedule_cancelled")]
29    SessionScheduleCancelled,
30    #[serde(rename = "session.schedule_rearmed")]
31    SessionScheduleRearmed,
32    #[serde(rename = "session.autopilot_objective_changed")]
33    SessionAutopilotObjectiveChanged,
34    #[serde(rename = "session.info")]
35    SessionInfo,
36    #[serde(rename = "session.indexed_search")]
37    SessionIndexedSearch,
38    #[serde(rename = "session.warning")]
39    SessionWarning,
40    #[serde(rename = "session.model_change")]
41    SessionModelChange,
42    #[serde(rename = "session.model_deselected")]
43    SessionModelDeselected,
44    ///
45    /// <div class="warning">
46    ///
47    /// **Experimental.** This type is part of an experimental wire-protocol surface
48    /// and may change or be removed in future SDK or CLI releases.
49    ///
50    /// </div>
51    #[serde(rename = "session.auto_tier_recommendation")]
52    SessionAutoTierRecommendation,
53    #[serde(rename = "session.auto_tier_switch_failed")]
54    SessionAutoTierSwitchFailed,
55    #[serde(rename = "session.mode_changed")]
56    SessionModeChanged,
57    #[serde(rename = "session.mode_notice_delivered")]
58    SessionModeNoticeDelivered,
59    #[serde(rename = "session.session_limits_changed")]
60    SessionSessionLimitsChanged,
61    ///
62    /// <div class="warning">
63    ///
64    /// **Experimental.** This type is part of an experimental wire-protocol surface
65    /// and may change or be removed in future SDK or CLI releases.
66    ///
67    /// </div>
68    #[serde(rename = "session.permissions_changed")]
69    SessionPermissionsChanged,
70    #[serde(rename = "session.plan_changed")]
71    SessionPlanChanged,
72    #[serde(rename = "session.todos_changed")]
73    SessionTodosChanged,
74    #[serde(rename = "session.workspace_file_changed")]
75    SessionWorkspaceFileChanged,
76    #[serde(rename = "session.handoff")]
77    SessionHandoff,
78    #[serde(rename = "session.truncation")]
79    SessionTruncation,
80    #[serde(rename = "session.snapshot_rewind")]
81    SessionSnapshotRewind,
82    #[serde(rename = "session.shutdown")]
83    SessionShutdown,
84    #[serde(rename = "session.usage_checkpoint")]
85    SessionUsageCheckpoint,
86    #[serde(rename = "session.context_changed")]
87    SessionContextChanged,
88    #[serde(rename = "session.usage_info")]
89    SessionUsageInfo,
90    #[serde(rename = "session.context_cleared")]
91    SessionContextCleared,
92    #[serde(rename = "session.compaction_start")]
93    SessionCompactionStart,
94    #[serde(rename = "session.compaction_complete")]
95    SessionCompactionComplete,
96    #[serde(rename = "session.task_complete")]
97    SessionTaskComplete,
98    ///
99    /// <div class="warning">
100    ///
101    /// **Experimental.** This type is part of an experimental wire-protocol surface
102    /// and may change or be removed in future SDK or CLI releases.
103    ///
104    /// </div>
105    #[serde(rename = "session.completion_receipt")]
106    SessionCompletionReceipt,
107    ///
108    /// <div class="warning">
109    ///
110    /// **Experimental.** This type is part of an experimental wire-protocol surface
111    /// and may change or be removed in future SDK or CLI releases.
112    ///
113    /// </div>
114    #[serde(rename = "session.fusion_route_started")]
115    SessionFusionRouteStarted,
116    ///
117    /// <div class="warning">
118    ///
119    /// **Experimental.** This type is part of an experimental wire-protocol surface
120    /// and may change or be removed in future SDK or CLI releases.
121    ///
122    /// </div>
123    #[serde(rename = "session.fusion_route_failed")]
124    SessionFusionRouteFailed,
125    ///
126    /// <div class="warning">
127    ///
128    /// **Experimental.** This type is part of an experimental wire-protocol surface
129    /// and may change or be removed in future SDK or CLI releases.
130    ///
131    /// </div>
132    #[serde(rename = "session.fusion_resolved")]
133    SessionFusionResolved,
134    ///
135    /// <div class="warning">
136    ///
137    /// **Experimental.** This type is part of an experimental wire-protocol surface
138    /// and may change or be removed in future SDK or CLI releases.
139    ///
140    /// </div>
141    #[serde(rename = "session.fusion_completed")]
142    SessionFusionCompleted,
143    #[serde(rename = "session.permission_recovery")]
144    SessionPermissionRecovery,
145    #[serde(rename = "user.message")]
146    UserMessage,
147    #[serde(rename = "pending_messages.modified")]
148    PendingMessagesModified,
149    #[serde(rename = "assistant.turn_start")]
150    AssistantTurnStart,
151    #[serde(rename = "assistant.turn_retry")]
152    AssistantTurnRetry,
153    #[serde(rename = "agent.interrupted")]
154    AgentInterrupted,
155    #[serde(rename = "assistant.intent")]
156    AssistantIntent,
157    ///
158    /// <div class="warning">
159    ///
160    /// **Experimental.** This type is part of an experimental wire-protocol surface
161    /// and may change or be removed in future SDK or CLI releases.
162    ///
163    /// </div>
164    #[serde(rename = "assistant.fusion_phase_started")]
165    AssistantFusionPhaseStarted,
166    ///
167    /// <div class="warning">
168    ///
169    /// **Experimental.** This type is part of an experimental wire-protocol surface
170    /// and may change or be removed in future SDK or CLI releases.
171    ///
172    /// </div>
173    #[serde(rename = "assistant.fusion_phase_activity")]
174    AssistantFusionPhaseActivity,
175    ///
176    /// <div class="warning">
177    ///
178    /// **Experimental.** This type is part of an experimental wire-protocol surface
179    /// and may change or be removed in future SDK or CLI releases.
180    ///
181    /// </div>
182    #[serde(rename = "assistant.fusion_phase_completed")]
183    AssistantFusionPhaseCompleted,
184    ///
185    /// <div class="warning">
186    ///
187    /// **Experimental.** This type is part of an experimental wire-protocol surface
188    /// and may change or be removed in future SDK or CLI releases.
189    ///
190    /// </div>
191    #[serde(rename = "assistant.fusion_phase_failed")]
192    AssistantFusionPhaseFailed,
193    #[serde(rename = "assistant.server_tool_progress")]
194    AssistantServerToolProgress,
195    #[serde(rename = "assistant.reasoning")]
196    AssistantReasoning,
197    #[serde(rename = "assistant.reasoning_delta")]
198    AssistantReasoningDelta,
199    #[serde(rename = "assistant.tool_call_delta")]
200    AssistantToolCallDelta,
201    #[serde(rename = "assistant.streaming_delta")]
202    AssistantStreamingDelta,
203    #[serde(rename = "assistant.message")]
204    AssistantMessage,
205    #[serde(rename = "assistant.message_start")]
206    AssistantMessageStart,
207    #[serde(rename = "assistant.message_delta")]
208    AssistantMessageDelta,
209    #[serde(rename = "assistant.turn_end")]
210    AssistantTurnEnd,
211    #[serde(rename = "assistant.idle")]
212    AssistantIdle,
213    #[serde(rename = "assistant.usage")]
214    AssistantUsage,
215    #[serde(rename = "prompt_cache_break")]
216    PromptCacheBreak,
217    #[serde(rename = "model.call_failure")]
218    ModelCallFailure,
219    #[serde(rename = "model.call_finished")]
220    ModelCallFinished,
221    #[serde(rename = "model.call_start")]
222    ModelCallStart,
223    #[serde(rename = "abort")]
224    Abort,
225    #[serde(rename = "tool.user_requested")]
226    ToolUserRequested,
227    #[serde(rename = "tool.execution_start")]
228    ToolExecutionStart,
229    #[serde(rename = "tool.execution_partial_result")]
230    ToolExecutionPartialResult,
231    #[serde(rename = "tool.execution_progress")]
232    ToolExecutionProgress,
233    #[serde(rename = "tool.execution_complete")]
234    ToolExecutionComplete,
235    #[serde(rename = "tool_search.activated")]
236    ToolSearchActivated,
237    #[serde(rename = "skill.invoked")]
238    SkillInvoked,
239    ///
240    /// <div class="warning">
241    ///
242    /// **Experimental.** This type is part of an experimental wire-protocol surface
243    /// and may change or be removed in future SDK or CLI releases.
244    ///
245    /// </div>
246    #[serde(rename = "skill.invoked_ref")]
247    SkillInvokedRef,
248    ///
249    /// <div class="warning">
250    ///
251    /// **Experimental.** This type is part of an experimental wire-protocol surface
252    /// and may change or be removed in future SDK or CLI releases.
253    ///
254    /// </div>
255    #[serde(rename = "skill.context_delivered")]
256    SkillContextDelivered,
257    ///
258    /// <div class="warning">
259    ///
260    /// **Experimental.** This type is part of an experimental wire-protocol surface
261    /// and may change or be removed in future SDK or CLI releases.
262    ///
263    /// </div>
264    #[serde(rename = "skill.context_delivered_ref")]
265    SkillContextDeliveredRef,
266    #[serde(rename = "sandbox.decision")]
267    SandboxDecision,
268    #[serde(rename = "subagent.started")]
269    SubagentStarted,
270    #[serde(rename = "subagent.configured")]
271    SubagentConfigured,
272    #[serde(rename = "subagent.completed")]
273    SubagentCompleted,
274    #[serde(rename = "subagent.failed")]
275    SubagentFailed,
276    #[serde(rename = "subagent.selected")]
277    SubagentSelected,
278    #[serde(rename = "subagent.deselected")]
279    SubagentDeselected,
280    #[serde(rename = "hook.start")]
281    HookStart,
282    #[serde(rename = "hook.end")]
283    HookEnd,
284    #[serde(rename = "hook.progress")]
285    HookProgress,
286    ///
287    /// <div class="warning">
288    ///
289    /// **Experimental.** This type is part of an experimental wire-protocol surface
290    /// and may change or be removed in future SDK or CLI releases.
291    ///
292    /// </div>
293    #[serde(rename = "session.binary_asset")]
294    SessionBinaryAsset,
295    #[serde(rename = "system.message")]
296    SystemMessage,
297    #[serde(rename = "system.notification")]
298    SystemNotification,
299    #[serde(rename = "permission.requested")]
300    PermissionRequested,
301    #[serde(rename = "permission.completed")]
302    PermissionCompleted,
303    ///
304    /// <div class="warning">
305    ///
306    /// **Experimental.** This type is part of an experimental wire-protocol surface
307    /// and may change or be removed in future SDK or CLI releases.
308    ///
309    /// </div>
310    #[serde(rename = "permission.carriedForward")]
311    PermissionCarriedForward,
312    ///
313    /// <div class="warning">
314    ///
315    /// **Experimental.** This type is part of an experimental wire-protocol surface
316    /// and may change or be removed in future SDK or CLI releases.
317    ///
318    /// </div>
319    #[serde(rename = "permission.messageAuthorization")]
320    PermissionMessageAuthorization,
321    ///
322    /// <div class="warning">
323    ///
324    /// **Experimental.** This type is part of an experimental wire-protocol surface
325    /// and may change or be removed in future SDK or CLI releases.
326    ///
327    /// </div>
328    #[serde(rename = "permission.messageAuthorizationRead")]
329    PermissionMessageAuthorizationRead,
330    ///
331    /// <div class="warning">
332    ///
333    /// **Experimental.** This type is part of an experimental wire-protocol surface
334    /// and may change or be removed in future SDK or CLI releases.
335    ///
336    /// </div>
337    #[serde(rename = "permission.messageAuthorizationDegraded")]
338    PermissionMessageAuthorizationDegraded,
339    ///
340    /// <div class="warning">
341    ///
342    /// **Experimental.** This type is part of an experimental wire-protocol surface
343    /// and may change or be removed in future SDK or CLI releases.
344    ///
345    /// </div>
346    #[serde(rename = "permission.assentDetected")]
347    PermissionAssentDetected,
348    ///
349    /// <div class="warning">
350    ///
351    /// **Experimental.** This type is part of an experimental wire-protocol surface
352    /// and may change or be removed in future SDK or CLI releases.
353    ///
354    /// </div>
355    #[serde(rename = "permission.contextualAuthorization")]
356    PermissionContextualAuthorization,
357    #[serde(rename = "user_input.requested")]
358    UserInputRequested,
359    #[serde(rename = "user_input.completed")]
360    UserInputCompleted,
361    #[serde(rename = "elicitation.requested")]
362    ElicitationRequested,
363    #[serde(rename = "elicitation.completed")]
364    ElicitationCompleted,
365    #[serde(rename = "sampling.requested")]
366    SamplingRequested,
367    #[serde(rename = "sampling.completed")]
368    SamplingCompleted,
369    #[serde(rename = "mcp.oauth_required")]
370    McpOauthRequired,
371    #[serde(rename = "mcp.oauth_completed")]
372    McpOauthCompleted,
373    #[serde(rename = "mcp.headers_refresh_required")]
374    McpHeadersRefreshRequired,
375    #[serde(rename = "mcp.headers_refresh_completed")]
376    McpHeadersRefreshCompleted,
377    #[serde(rename = "session.custom_notification")]
378    SessionCustomNotification,
379    ///
380    /// <div class="warning">
381    ///
382    /// **Experimental.** This type is part of an experimental wire-protocol surface
383    /// and may change or be removed in future SDK or CLI releases.
384    ///
385    /// </div>
386    #[serde(rename = "ui.ephemeral_query")]
387    UiEphemeralQuery,
388    #[serde(rename = "external_tool.requested")]
389    ExternalToolRequested,
390    #[serde(rename = "external_tool.completed")]
391    ExternalToolCompleted,
392    #[serde(rename = "command.queued")]
393    CommandQueued,
394    #[serde(rename = "command.execute")]
395    CommandExecute,
396    #[serde(rename = "command.completed")]
397    CommandCompleted,
398    #[serde(rename = "auto_mode_switch.requested")]
399    AutoModeSwitchRequested,
400    #[serde(rename = "auto_mode_switch.completed")]
401    AutoModeSwitchCompleted,
402    #[serde(rename = "session_limits_exhausted.requested")]
403    SessionLimitsExhaustedRequested,
404    #[serde(rename = "session_limits_exhausted.completed")]
405    SessionLimitsExhaustedCompleted,
406    ///
407    /// <div class="warning">
408    ///
409    /// **Experimental.** This type is part of an experimental wire-protocol surface
410    /// and may change or be removed in future SDK or CLI releases.
411    ///
412    /// </div>
413    #[serde(rename = "session.auto_mode_resolved")]
414    SessionAutoModeResolved,
415    ///
416    /// <div class="warning">
417    ///
418    /// **Experimental.** This type is part of an experimental wire-protocol surface
419    /// and may change or be removed in future SDK or CLI releases.
420    ///
421    /// </div>
422    #[serde(rename = "session.managed_settings_resolved")]
423    SessionManagedSettingsResolved,
424    ///
425    /// <div class="warning">
426    ///
427    /// **Experimental.** This type is part of an experimental wire-protocol surface
428    /// and may change or be removed in future SDK or CLI releases.
429    ///
430    /// </div>
431    #[serde(rename = "session.managed_settings_enforced")]
432    SessionManagedSettingsEnforced,
433    #[serde(rename = "commands.changed")]
434    CommandsChanged,
435    #[serde(rename = "capabilities.changed")]
436    CapabilitiesChanged,
437    #[serde(rename = "exit_plan_mode.requested")]
438    ExitPlanModeRequested,
439    #[serde(rename = "exit_plan_mode.completed")]
440    ExitPlanModeCompleted,
441    #[serde(rename = "session.tools_updated")]
442    SessionToolsUpdated,
443    #[serde(rename = "session.background_tasks_changed")]
444    SessionBackgroundTasksChanged,
445    ///
446    /// <div class="warning">
447    ///
448    /// **Experimental.** This type is part of an experimental wire-protocol surface
449    /// and may change or be removed in future SDK or CLI releases.
450    ///
451    /// </div>
452    #[serde(rename = "factory.run_updated")]
453    FactoryRunUpdated,
454    ///
455    /// <div class="warning">
456    ///
457    /// **Experimental.** This type is part of an experimental wire-protocol surface
458    /// and may change or be removed in future SDK or CLI releases.
459    ///
460    /// </div>
461    #[serde(rename = "factory.run_started")]
462    FactoryRunStarted,
463    ///
464    /// <div class="warning">
465    ///
466    /// **Experimental.** This type is part of an experimental wire-protocol surface
467    /// and may change or be removed in future SDK or CLI releases.
468    ///
469    /// </div>
470    #[serde(rename = "factory.run_settled")]
471    FactoryRunSettled,
472    #[serde(rename = "session.skills_loaded")]
473    SessionSkillsLoaded,
474    #[serde(rename = "session.custom_agents_updated")]
475    SessionCustomAgentsUpdated,
476    #[serde(rename = "session.mcp_servers_loaded")]
477    SessionMcpServersLoaded,
478    #[serde(rename = "session.mcp_server_status_changed")]
479    SessionMcpServerStatusChanged,
480    #[serde(rename = "session.mcp_server_removed")]
481    SessionMcpServerRemoved,
482    #[serde(rename = "session.mcp_server_needs_reconnect")]
483    SessionMcpServerNeedsReconnect,
484    #[serde(rename = "mcp.tools.list_changed")]
485    McpToolsListChanged,
486    #[serde(rename = "mcp.resources.list_changed")]
487    McpResourcesListChanged,
488    #[serde(rename = "mcp.prompts.list_changed")]
489    McpPromptsListChanged,
490    #[serde(rename = "session.extensions_loaded")]
491    SessionExtensionsLoaded,
492    ///
493    /// <div class="warning">
494    ///
495    /// **Experimental.** This type is part of an experimental wire-protocol surface
496    /// and may change or be removed in future SDK or CLI releases.
497    ///
498    /// </div>
499    #[serde(rename = "session.canvas.opened")]
500    SessionCanvasOpened,
501    ///
502    /// <div class="warning">
503    ///
504    /// **Experimental.** This type is part of an experimental wire-protocol surface
505    /// and may change or be removed in future SDK or CLI releases.
506    ///
507    /// </div>
508    #[serde(rename = "session.canvas.registry_changed")]
509    SessionCanvasRegistryChanged,
510    ///
511    /// <div class="warning">
512    ///
513    /// **Experimental.** This type is part of an experimental wire-protocol surface
514    /// and may change or be removed in future SDK or CLI releases.
515    ///
516    /// </div>
517    #[serde(rename = "session.canvas.closed")]
518    SessionCanvasClosed,
519    ///
520    /// <div class="warning">
521    ///
522    /// **Experimental.** This type is part of an experimental wire-protocol surface
523    /// and may change or be removed in future SDK or CLI releases.
524    ///
525    /// </div>
526    #[serde(rename = "session.canvas.unavailable")]
527    SessionCanvasUnavailable,
528    ///
529    /// <div class="warning">
530    ///
531    /// **Experimental.** This type is part of an experimental wire-protocol surface
532    /// and may change or be removed in future SDK or CLI releases.
533    ///
534    /// </div>
535    #[serde(rename = "session.canvas.recorded")]
536    SessionCanvasRecorded,
537    ///
538    /// <div class="warning">
539    ///
540    /// **Experimental.** This type is part of an experimental wire-protocol surface
541    /// and may change or be removed in future SDK or CLI releases.
542    ///
543    /// </div>
544    #[serde(rename = "session.canvas.removed")]
545    SessionCanvasRemoved,
546    #[serde(rename = "session.extensions.attachments_pushed")]
547    SessionExtensionsAttachmentsPushed,
548    #[serde(rename = "mcp_app.tool_call_complete")]
549    McpAppToolCallComplete,
550    /// Unknown event type for forward compatibility.
551    #[default]
552    #[serde(other)]
553    Unknown,
554}
555
556/// Typed session event data, discriminated by the event `type` field.
557///
558/// Use with [`TypedSessionEvent`] for fully typed event handling.
559#[derive(Debug, Clone, Serialize, Deserialize)]
560#[serde(tag = "type", content = "data")]
561pub enum SessionEventData {
562    #[serde(rename = "session.start")]
563    SessionStart(SessionStartData),
564    #[serde(rename = "session.resume")]
565    SessionResume(SessionResumeData),
566    #[serde(rename = "session.remote_steerable_changed")]
567    SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
568    #[serde(rename = "session.error")]
569    SessionError(SessionErrorData),
570    #[serde(rename = "session.idle")]
571    SessionIdle(SessionIdleData),
572    #[serde(rename = "session.title_changed")]
573    SessionTitleChanged(SessionTitleChangedData),
574    #[serde(rename = "session.schedule_created")]
575    SessionScheduleCreated(SessionScheduleCreatedData),
576    #[serde(rename = "session.schedule_cancelled")]
577    SessionScheduleCancelled(SessionScheduleCancelledData),
578    #[serde(rename = "session.schedule_rearmed")]
579    SessionScheduleRearmed(SessionScheduleRearmedData),
580    #[serde(rename = "session.autopilot_objective_changed")]
581    SessionAutopilotObjectiveChanged(SessionAutopilotObjectiveChangedData),
582    #[serde(rename = "session.info")]
583    SessionInfo(SessionInfoData),
584    #[serde(rename = "session.indexed_search")]
585    SessionIndexedSearch(SessionIndexedSearchData),
586    #[serde(rename = "session.warning")]
587    SessionWarning(SessionWarningData),
588    #[serde(rename = "session.model_change")]
589    SessionModelChange(SessionModelChangeData),
590    #[serde(rename = "session.model_deselected")]
591    SessionModelDeselected(SessionModelDeselectedData),
592    ///
593    /// <div class="warning">
594    ///
595    /// **Experimental.** This type is part of an experimental wire-protocol surface
596    /// and may change or be removed in future SDK or CLI releases.
597    ///
598    /// </div>
599    #[serde(rename = "session.auto_tier_recommendation")]
600    SessionAutoTierRecommendation(SessionAutoTierRecommendationData),
601    #[serde(rename = "session.auto_tier_switch_failed")]
602    SessionAutoTierSwitchFailed(SessionAutoTierSwitchFailedData),
603    #[serde(rename = "session.mode_changed")]
604    SessionModeChanged(SessionModeChangedData),
605    #[serde(rename = "session.mode_notice_delivered")]
606    SessionModeNoticeDelivered(SessionModeNoticeDeliveredData),
607    #[serde(rename = "session.session_limits_changed")]
608    SessionSessionLimitsChanged(SessionSessionLimitsChangedData),
609    ///
610    /// <div class="warning">
611    ///
612    /// **Experimental.** This type is part of an experimental wire-protocol surface
613    /// and may change or be removed in future SDK or CLI releases.
614    ///
615    /// </div>
616    #[serde(rename = "session.permissions_changed")]
617    SessionPermissionsChanged(SessionPermissionsChangedData),
618    #[serde(rename = "session.plan_changed")]
619    SessionPlanChanged(SessionPlanChangedData),
620    #[serde(rename = "session.todos_changed")]
621    SessionTodosChanged(SessionTodosChangedData),
622    #[serde(rename = "session.workspace_file_changed")]
623    SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
624    #[serde(rename = "session.handoff")]
625    SessionHandoff(SessionHandoffData),
626    #[serde(rename = "session.truncation")]
627    SessionTruncation(SessionTruncationData),
628    #[serde(rename = "session.snapshot_rewind")]
629    SessionSnapshotRewind(SessionSnapshotRewindData),
630    #[serde(rename = "session.shutdown")]
631    SessionShutdown(SessionShutdownData),
632    #[serde(rename = "session.usage_checkpoint")]
633    SessionUsageCheckpoint(SessionUsageCheckpointData),
634    #[serde(rename = "session.context_changed")]
635    SessionContextChanged(SessionContextChangedData),
636    #[serde(rename = "session.usage_info")]
637    SessionUsageInfo(SessionUsageInfoData),
638    #[serde(rename = "session.context_cleared")]
639    SessionContextCleared(SessionContextClearedData),
640    #[serde(rename = "session.compaction_start")]
641    SessionCompactionStart(SessionCompactionStartData),
642    #[serde(rename = "session.compaction_complete")]
643    SessionCompactionComplete(SessionCompactionCompleteData),
644    #[serde(rename = "session.task_complete")]
645    SessionTaskComplete(SessionTaskCompleteData),
646    ///
647    /// <div class="warning">
648    ///
649    /// **Experimental.** This type is part of an experimental wire-protocol surface
650    /// and may change or be removed in future SDK or CLI releases.
651    ///
652    /// </div>
653    #[serde(rename = "session.completion_receipt")]
654    SessionCompletionReceipt(SessionCompletionReceiptData),
655    ///
656    /// <div class="warning">
657    ///
658    /// **Experimental.** This type is part of an experimental wire-protocol surface
659    /// and may change or be removed in future SDK or CLI releases.
660    ///
661    /// </div>
662    #[serde(rename = "session.fusion_route_started")]
663    SessionFusionRouteStarted(SessionFusionRouteStartedData),
664    ///
665    /// <div class="warning">
666    ///
667    /// **Experimental.** This type is part of an experimental wire-protocol surface
668    /// and may change or be removed in future SDK or CLI releases.
669    ///
670    /// </div>
671    #[serde(rename = "session.fusion_route_failed")]
672    SessionFusionRouteFailed(SessionFusionRouteFailedData),
673    ///
674    /// <div class="warning">
675    ///
676    /// **Experimental.** This type is part of an experimental wire-protocol surface
677    /// and may change or be removed in future SDK or CLI releases.
678    ///
679    /// </div>
680    #[serde(rename = "session.fusion_resolved")]
681    SessionFusionResolved(SessionFusionResolvedData),
682    ///
683    /// <div class="warning">
684    ///
685    /// **Experimental.** This type is part of an experimental wire-protocol surface
686    /// and may change or be removed in future SDK or CLI releases.
687    ///
688    /// </div>
689    #[serde(rename = "session.fusion_completed")]
690    SessionFusionCompleted(SessionFusionCompletedData),
691    #[serde(rename = "session.permission_recovery")]
692    SessionPermissionRecovery(SessionPermissionRecoveryData),
693    #[serde(rename = "user.message")]
694    UserMessage(UserMessageData),
695    #[serde(rename = "pending_messages.modified")]
696    PendingMessagesModified(PendingMessagesModifiedData),
697    #[serde(rename = "assistant.turn_start")]
698    AssistantTurnStart(AssistantTurnStartData),
699    #[serde(rename = "assistant.turn_retry")]
700    AssistantTurnRetry(AssistantTurnRetryData),
701    #[serde(rename = "agent.interrupted")]
702    AgentInterrupted(AgentInterruptedData),
703    #[serde(rename = "assistant.intent")]
704    AssistantIntent(AssistantIntentData),
705    ///
706    /// <div class="warning">
707    ///
708    /// **Experimental.** This type is part of an experimental wire-protocol surface
709    /// and may change or be removed in future SDK or CLI releases.
710    ///
711    /// </div>
712    #[serde(rename = "assistant.fusion_phase_started")]
713    AssistantFusionPhaseStarted(AssistantFusionPhaseStartedData),
714    ///
715    /// <div class="warning">
716    ///
717    /// **Experimental.** This type is part of an experimental wire-protocol surface
718    /// and may change or be removed in future SDK or CLI releases.
719    ///
720    /// </div>
721    #[serde(rename = "assistant.fusion_phase_activity")]
722    AssistantFusionPhaseActivity(AssistantFusionPhaseActivityData),
723    ///
724    /// <div class="warning">
725    ///
726    /// **Experimental.** This type is part of an experimental wire-protocol surface
727    /// and may change or be removed in future SDK or CLI releases.
728    ///
729    /// </div>
730    #[serde(rename = "assistant.fusion_phase_completed")]
731    AssistantFusionPhaseCompleted(AssistantFusionPhaseCompletedData),
732    ///
733    /// <div class="warning">
734    ///
735    /// **Experimental.** This type is part of an experimental wire-protocol surface
736    /// and may change or be removed in future SDK or CLI releases.
737    ///
738    /// </div>
739    #[serde(rename = "assistant.fusion_phase_failed")]
740    AssistantFusionPhaseFailed(AssistantFusionPhaseFailedData),
741    #[serde(rename = "assistant.server_tool_progress")]
742    AssistantServerToolProgress(AssistantServerToolProgressData),
743    #[serde(rename = "assistant.reasoning")]
744    AssistantReasoning(AssistantReasoningData),
745    #[serde(rename = "assistant.reasoning_delta")]
746    AssistantReasoningDelta(AssistantReasoningDeltaData),
747    #[serde(rename = "assistant.tool_call_delta")]
748    AssistantToolCallDelta(AssistantToolCallDeltaData),
749    #[serde(rename = "assistant.streaming_delta")]
750    AssistantStreamingDelta(AssistantStreamingDeltaData),
751    #[serde(rename = "assistant.message")]
752    AssistantMessage(AssistantMessageData),
753    #[serde(rename = "assistant.message_start")]
754    AssistantMessageStart(AssistantMessageStartData),
755    #[serde(rename = "assistant.message_delta")]
756    AssistantMessageDelta(AssistantMessageDeltaData),
757    #[serde(rename = "assistant.turn_end")]
758    AssistantTurnEnd(AssistantTurnEndData),
759    #[serde(rename = "assistant.idle")]
760    AssistantIdle(AssistantIdleData),
761    #[serde(rename = "assistant.usage")]
762    AssistantUsage(AssistantUsageData),
763    #[serde(rename = "prompt_cache_break")]
764    PromptCacheBreak(PromptCacheBreakData),
765    #[serde(rename = "model.call_failure")]
766    ModelCallFailure(ModelCallFailureData),
767    #[serde(rename = "model.call_finished")]
768    ModelCallFinished(ModelCallFinishedData),
769    #[serde(rename = "model.call_start")]
770    ModelCallStart(ModelCallStartData),
771    #[serde(rename = "abort")]
772    Abort(AbortData),
773    #[serde(rename = "tool.user_requested")]
774    ToolUserRequested(ToolUserRequestedData),
775    #[serde(rename = "tool.execution_start")]
776    ToolExecutionStart(ToolExecutionStartData),
777    #[serde(rename = "tool.execution_partial_result")]
778    ToolExecutionPartialResult(ToolExecutionPartialResultData),
779    #[serde(rename = "tool.execution_progress")]
780    ToolExecutionProgress(ToolExecutionProgressData),
781    #[serde(rename = "tool.execution_complete")]
782    ToolExecutionComplete(ToolExecutionCompleteData),
783    #[serde(rename = "tool_search.activated")]
784    ToolSearchActivated(ToolSearchActivatedData),
785    #[serde(rename = "skill.invoked")]
786    SkillInvoked(SkillInvokedData),
787    #[serde(rename = "skill.invoked_ref")]
788    SkillInvokedRef(SkillInvokedRefData),
789    #[serde(rename = "skill.context_delivered")]
790    SkillContextDelivered(SkillContextDeliveredData),
791    #[serde(rename = "skill.context_delivered_ref")]
792    SkillContextDeliveredRef(SkillContextDeliveredRefData),
793    #[serde(rename = "sandbox.decision")]
794    SandboxDecision(SandboxDecisionData),
795    #[serde(rename = "subagent.started")]
796    SubagentStarted(SubagentStartedData),
797    #[serde(rename = "subagent.configured")]
798    SubagentConfigured(SubagentConfiguredData),
799    #[serde(rename = "subagent.completed")]
800    SubagentCompleted(SubagentCompletedData),
801    #[serde(rename = "subagent.failed")]
802    SubagentFailed(SubagentFailedData),
803    #[serde(rename = "subagent.selected")]
804    SubagentSelected(SubagentSelectedData),
805    #[serde(rename = "subagent.deselected")]
806    SubagentDeselected(SubagentDeselectedData),
807    #[serde(rename = "hook.start")]
808    HookStart(HookStartData),
809    #[serde(rename = "hook.end")]
810    HookEnd(HookEndData),
811    #[serde(rename = "hook.progress")]
812    HookProgress(HookProgressData),
813    #[serde(rename = "session.binary_asset")]
814    SessionBinaryAsset(SessionBinaryAssetData),
815    #[serde(rename = "system.message")]
816    SystemMessage(SystemMessageData),
817    #[serde(rename = "system.notification")]
818    SystemNotification(SystemNotificationData),
819    #[serde(rename = "permission.requested")]
820    PermissionRequested(PermissionRequestedData),
821    #[serde(rename = "permission.completed")]
822    PermissionCompleted(PermissionCompletedData),
823    ///
824    /// <div class="warning">
825    ///
826    /// **Experimental.** This type is part of an experimental wire-protocol surface
827    /// and may change or be removed in future SDK or CLI releases.
828    ///
829    /// </div>
830    #[serde(rename = "permission.carriedForward")]
831    PermissionCarriedForward(PermissionCarriedForwardData),
832    ///
833    /// <div class="warning">
834    ///
835    /// **Experimental.** This type is part of an experimental wire-protocol surface
836    /// and may change or be removed in future SDK or CLI releases.
837    ///
838    /// </div>
839    #[serde(rename = "permission.messageAuthorization")]
840    PermissionMessageAuthorization(PermissionMessageAuthorizationData),
841    ///
842    /// <div class="warning">
843    ///
844    /// **Experimental.** This type is part of an experimental wire-protocol surface
845    /// and may change or be removed in future SDK or CLI releases.
846    ///
847    /// </div>
848    #[serde(rename = "permission.messageAuthorizationRead")]
849    PermissionMessageAuthorizationRead(PermissionMessageAuthorizationReadData),
850    ///
851    /// <div class="warning">
852    ///
853    /// **Experimental.** This type is part of an experimental wire-protocol surface
854    /// and may change or be removed in future SDK or CLI releases.
855    ///
856    /// </div>
857    #[serde(rename = "permission.messageAuthorizationDegraded")]
858    PermissionMessageAuthorizationDegraded(PermissionMessageAuthorizationDegradedData),
859    ///
860    /// <div class="warning">
861    ///
862    /// **Experimental.** This type is part of an experimental wire-protocol surface
863    /// and may change or be removed in future SDK or CLI releases.
864    ///
865    /// </div>
866    #[serde(rename = "permission.assentDetected")]
867    PermissionAssentDetected(PermissionAssentDetectedData),
868    ///
869    /// <div class="warning">
870    ///
871    /// **Experimental.** This type is part of an experimental wire-protocol surface
872    /// and may change or be removed in future SDK or CLI releases.
873    ///
874    /// </div>
875    #[serde(rename = "permission.contextualAuthorization")]
876    PermissionContextualAuthorization(PermissionContextualAuthorizationData),
877    #[serde(rename = "user_input.requested")]
878    UserInputRequested(UserInputRequestedData),
879    #[serde(rename = "user_input.completed")]
880    UserInputCompleted(UserInputCompletedData),
881    #[serde(rename = "elicitation.requested")]
882    ElicitationRequested(ElicitationRequestedData),
883    #[serde(rename = "elicitation.completed")]
884    ElicitationCompleted(ElicitationCompletedData),
885    #[serde(rename = "sampling.requested")]
886    SamplingRequested(SamplingRequestedData),
887    #[serde(rename = "sampling.completed")]
888    SamplingCompleted(SamplingCompletedData),
889    #[serde(rename = "mcp.oauth_required")]
890    McpOauthRequired(McpOauthRequiredData),
891    #[serde(rename = "mcp.oauth_completed")]
892    McpOauthCompleted(McpOauthCompletedData),
893    #[serde(rename = "mcp.headers_refresh_required")]
894    McpHeadersRefreshRequired(McpHeadersRefreshRequiredData),
895    #[serde(rename = "mcp.headers_refresh_completed")]
896    McpHeadersRefreshCompleted(McpHeadersRefreshCompletedData),
897    #[serde(rename = "session.custom_notification")]
898    SessionCustomNotification(SessionCustomNotificationData),
899    ///
900    /// <div class="warning">
901    ///
902    /// **Experimental.** This type is part of an experimental wire-protocol surface
903    /// and may change or be removed in future SDK or CLI releases.
904    ///
905    /// </div>
906    #[serde(rename = "ui.ephemeral_query")]
907    UiEphemeralQuery(UiEphemeralQueryData),
908    #[serde(rename = "external_tool.requested")]
909    ExternalToolRequested(ExternalToolRequestedData),
910    #[serde(rename = "external_tool.completed")]
911    ExternalToolCompleted(ExternalToolCompletedData),
912    #[serde(rename = "command.queued")]
913    CommandQueued(CommandQueuedData),
914    #[serde(rename = "command.execute")]
915    CommandExecute(CommandExecuteData),
916    #[serde(rename = "command.completed")]
917    CommandCompleted(CommandCompletedData),
918    #[serde(rename = "auto_mode_switch.requested")]
919    AutoModeSwitchRequested(AutoModeSwitchRequestedData),
920    #[serde(rename = "auto_mode_switch.completed")]
921    AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
922    #[serde(rename = "session_limits_exhausted.requested")]
923    SessionLimitsExhaustedRequested(SessionLimitsExhaustedRequestedData),
924    #[serde(rename = "session_limits_exhausted.completed")]
925    SessionLimitsExhaustedCompleted(SessionLimitsExhaustedCompletedData),
926    ///
927    /// <div class="warning">
928    ///
929    /// **Experimental.** This type is part of an experimental wire-protocol surface
930    /// and may change or be removed in future SDK or CLI releases.
931    ///
932    /// </div>
933    #[serde(rename = "session.auto_mode_resolved")]
934    SessionAutoModeResolved(SessionAutoModeResolvedData),
935    ///
936    /// <div class="warning">
937    ///
938    /// **Experimental.** This type is part of an experimental wire-protocol surface
939    /// and may change or be removed in future SDK or CLI releases.
940    ///
941    /// </div>
942    #[serde(rename = "session.managed_settings_resolved")]
943    SessionManagedSettingsResolved(SessionManagedSettingsResolvedData),
944    ///
945    /// <div class="warning">
946    ///
947    /// **Experimental.** This type is part of an experimental wire-protocol surface
948    /// and may change or be removed in future SDK or CLI releases.
949    ///
950    /// </div>
951    #[serde(rename = "session.managed_settings_enforced")]
952    SessionManagedSettingsEnforced(SessionManagedSettingsEnforcedData),
953    #[serde(rename = "commands.changed")]
954    CommandsChanged(CommandsChangedData),
955    #[serde(rename = "capabilities.changed")]
956    CapabilitiesChanged(CapabilitiesChangedData),
957    #[serde(rename = "exit_plan_mode.requested")]
958    ExitPlanModeRequested(ExitPlanModeRequestedData),
959    #[serde(rename = "exit_plan_mode.completed")]
960    ExitPlanModeCompleted(ExitPlanModeCompletedData),
961    #[serde(rename = "session.tools_updated")]
962    SessionToolsUpdated(SessionToolsUpdatedData),
963    #[serde(rename = "session.background_tasks_changed")]
964    SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
965    ///
966    /// <div class="warning">
967    ///
968    /// **Experimental.** This type is part of an experimental wire-protocol surface
969    /// and may change or be removed in future SDK or CLI releases.
970    ///
971    /// </div>
972    #[serde(rename = "factory.run_updated")]
973    FactoryRunUpdated(FactoryRunUpdatedData),
974    ///
975    /// <div class="warning">
976    ///
977    /// **Experimental.** This type is part of an experimental wire-protocol surface
978    /// and may change or be removed in future SDK or CLI releases.
979    ///
980    /// </div>
981    #[serde(rename = "factory.run_started")]
982    FactoryRunStarted(FactoryRunStartedData),
983    ///
984    /// <div class="warning">
985    ///
986    /// **Experimental.** This type is part of an experimental wire-protocol surface
987    /// and may change or be removed in future SDK or CLI releases.
988    ///
989    /// </div>
990    #[serde(rename = "factory.run_settled")]
991    FactoryRunSettled(FactoryRunSettledData),
992    #[serde(rename = "session.skills_loaded")]
993    SessionSkillsLoaded(SessionSkillsLoadedData),
994    #[serde(rename = "session.custom_agents_updated")]
995    SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
996    #[serde(rename = "session.mcp_servers_loaded")]
997    SessionMcpServersLoaded(SessionMcpServersLoadedData),
998    #[serde(rename = "session.mcp_server_status_changed")]
999    SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
1000    #[serde(rename = "session.mcp_server_removed")]
1001    SessionMcpServerRemoved(SessionMcpServerRemovedData),
1002    #[serde(rename = "session.mcp_server_needs_reconnect")]
1003    SessionMcpServerNeedsReconnect(SessionMcpServerNeedsReconnectData),
1004    #[serde(rename = "mcp.tools.list_changed")]
1005    McpToolsListChanged(McpToolsListChangedData),
1006    #[serde(rename = "mcp.resources.list_changed")]
1007    McpResourcesListChanged(McpResourcesListChangedData),
1008    #[serde(rename = "mcp.prompts.list_changed")]
1009    McpPromptsListChanged(McpPromptsListChangedData),
1010    #[serde(rename = "session.extensions_loaded")]
1011    SessionExtensionsLoaded(SessionExtensionsLoadedData),
1012    ///
1013    /// <div class="warning">
1014    ///
1015    /// **Experimental.** This type is part of an experimental wire-protocol surface
1016    /// and may change or be removed in future SDK or CLI releases.
1017    ///
1018    /// </div>
1019    #[serde(rename = "session.canvas.opened")]
1020    SessionCanvasOpened(SessionCanvasOpenedData),
1021    ///
1022    /// <div class="warning">
1023    ///
1024    /// **Experimental.** This type is part of an experimental wire-protocol surface
1025    /// and may change or be removed in future SDK or CLI releases.
1026    ///
1027    /// </div>
1028    #[serde(rename = "session.canvas.registry_changed")]
1029    SessionCanvasRegistryChanged(SessionCanvasRegistryChangedData),
1030    ///
1031    /// <div class="warning">
1032    ///
1033    /// **Experimental.** This type is part of an experimental wire-protocol surface
1034    /// and may change or be removed in future SDK or CLI releases.
1035    ///
1036    /// </div>
1037    #[serde(rename = "session.canvas.closed")]
1038    SessionCanvasClosed(SessionCanvasClosedData),
1039    ///
1040    /// <div class="warning">
1041    ///
1042    /// **Experimental.** This type is part of an experimental wire-protocol surface
1043    /// and may change or be removed in future SDK or CLI releases.
1044    ///
1045    /// </div>
1046    #[serde(rename = "session.canvas.unavailable")]
1047    SessionCanvasUnavailable(SessionCanvasUnavailableData),
1048    ///
1049    /// <div class="warning">
1050    ///
1051    /// **Experimental.** This type is part of an experimental wire-protocol surface
1052    /// and may change or be removed in future SDK or CLI releases.
1053    ///
1054    /// </div>
1055    #[serde(rename = "session.canvas.recorded")]
1056    SessionCanvasRecorded(SessionCanvasRecordedData),
1057    ///
1058    /// <div class="warning">
1059    ///
1060    /// **Experimental.** This type is part of an experimental wire-protocol surface
1061    /// and may change or be removed in future SDK or CLI releases.
1062    ///
1063    /// </div>
1064    #[serde(rename = "session.canvas.removed")]
1065    SessionCanvasRemoved(SessionCanvasRemovedData),
1066    #[serde(rename = "session.extensions.attachments_pushed")]
1067    SessionExtensionsAttachmentsPushed(SessionExtensionsAttachmentsPushedData),
1068    #[serde(rename = "mcp_app.tool_call_complete")]
1069    McpAppToolCallComplete(McpAppToolCallCompleteData),
1070}
1071
1072/// A session event with typed data payload.
1073///
1074/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
1075/// are available directly. The event-specific data is in the `payload`
1076/// field as a [`SessionEventData`] enum.
1077#[derive(Debug, Clone, Serialize, Deserialize)]
1078#[serde(rename_all = "camelCase")]
1079pub struct TypedSessionEvent {
1080    /// Unique event identifier (UUID v4).
1081    pub id: String,
1082    /// ISO 8601 timestamp when the event was created.
1083    pub timestamp: String,
1084    /// ID of the preceding event in the chain.
1085    #[serde(skip_serializing_if = "Option::is_none")]
1086    pub parent_id: Option<String>,
1087    /// When true, the event is transient and not persisted.
1088    #[serde(skip_serializing_if = "Option::is_none")]
1089    pub ephemeral: Option<bool>,
1090    /// Sub-agent instance identifier. Absent for events from the root /
1091    /// main agent and session-level events.
1092    #[serde(skip_serializing_if = "Option::is_none")]
1093    pub agent_id: Option<String>,
1094    /// The typed event payload (discriminated by event type).
1095    #[serde(flatten)]
1096    pub payload: SessionEventData,
1097}
1098
1099/// Working directory and git context at session start
1100#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1101#[serde(rename_all = "camelCase")]
1102pub struct WorkingDirectoryContext {
1103    /// Base commit of current git branch at session start time
1104    #[serde(skip_serializing_if = "Option::is_none")]
1105    pub base_commit: Option<String>,
1106    /// Current git branch name
1107    #[serde(skip_serializing_if = "Option::is_none")]
1108    pub branch: Option<String>,
1109    /// Current working directory path
1110    pub cwd: String,
1111    /// Root directory of the git repository, resolved via git rev-parse
1112    #[serde(skip_serializing_if = "Option::is_none")]
1113    pub git_root: Option<String>,
1114    /// Head commit of current git branch at session start time
1115    #[serde(skip_serializing_if = "Option::is_none")]
1116    pub head_commit: Option<String>,
1117    /// Hosting platform type of the repository (github or ado)
1118    #[serde(skip_serializing_if = "Option::is_none")]
1119    pub host_type: Option<WorkingDirectoryContextHostType>,
1120    /// Set on the immediate preliminary event of a working-directory change, before the git context is resolved. A settled follow-up event (enriched with git context, or cwd-only for a non-repository) is always emitted afterward, so observers may defer to it. Absent on standalone/final events (e.g. relay context changes).
1121    #[serde(skip_serializing_if = "Option::is_none")]
1122    pub pending_git_context: Option<bool>,
1123    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
1124    #[serde(skip_serializing_if = "Option::is_none")]
1125    pub repository: Option<String>,
1126    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
1127    #[serde(skip_serializing_if = "Option::is_none")]
1128    pub repository_host: Option<String>,
1129}
1130
1131/// Per-session configuration for the built-in GitHub MCP server
1132#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1133#[serde(rename_all = "camelCase")]
1134pub struct GitHubMcpToolConfig {
1135    /// Additional GitHub MCP tools requested by the session
1136    #[serde(skip_serializing_if = "Option::is_none")]
1137    pub additional_tools: Option<Vec<String>>,
1138    /// Additional GitHub MCP toolsets requested by the session
1139    #[serde(skip_serializing_if = "Option::is_none")]
1140    pub additional_toolsets: Option<Vec<String>>,
1141    /// Whether to use the read-write endpoint and request all toolsets
1142    #[serde(skip_serializing_if = "Option::is_none")]
1143    pub enable_all_tools: Option<bool>,
1144    /// Whether to request the GitHub MCP insiders build
1145    #[serde(skip_serializing_if = "Option::is_none")]
1146    pub enable_insiders_mode: Option<bool>,
1147}
1148
1149/// Optional session limits.
1150#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1151#[serde(rename_all = "camelCase")]
1152pub struct SessionLimitsConfig {
1153    /// Maximum AI Credits allowed across the session's current accounting window.
1154    #[serde(skip_serializing_if = "Option::is_none")]
1155    pub max_ai_credits: Option<f64>,
1156}
1157
1158/// Session event "session.start". Session initialization metadata including context and configuration
1159#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1160#[serde(rename_all = "camelCase")]
1161pub struct SessionStartData {
1162    /// Whether the session was already in use by another client at start time
1163    #[serde(skip_serializing_if = "Option::is_none")]
1164    pub already_in_use: Option<bool>,
1165    /// Auto routing preference selected at session creation time
1166    #[serde(skip_serializing_if = "Option::is_none")]
1167    pub auto_tier: Option<AutoTier>,
1168    /// Working directory and git context at session start
1169    #[serde(skip_serializing_if = "Option::is_none")]
1170    pub context: Option<WorkingDirectoryContext>,
1171    /// Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
1172    #[serde(skip_serializing_if = "Option::is_none")]
1173    pub context_tier: Option<ContextTier>,
1174    /// Version string of the Copilot application
1175    pub copilot_version: String,
1176    /// When set, identifies a parent session whose context this session continues — e.g., a detached headless rem-agent run launched on the parent's interactive shutdown. Telemetry from this session is reported under the parent's session_id.
1177    #[serde(skip_serializing_if = "Option::is_none")]
1178    pub detached_from_spawning_parent_session_id: Option<String>,
1179    /// Per-session GitHub MCP override persisted for cold resume
1180    #[serde(skip_serializing_if = "Option::is_none")]
1181    pub github_mcp_tool_config: Option<GitHubMcpToolConfig>,
1182    /// Identifier of the software producing the events (e.g., "copilot-agent")
1183    pub producer: String,
1184    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
1185    #[serde(skip_serializing_if = "Option::is_none")]
1186    pub reasoning_effort: Option<String>,
1187    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
1188    #[serde(skip_serializing_if = "Option::is_none")]
1189    pub reasoning_summary: Option<ReasoningSummary>,
1190    /// Whether this session supports remote steering via GitHub
1191    #[serde(skip_serializing_if = "Option::is_none")]
1192    pub remote_steerable: Option<bool>,
1193    /// Model selected at session creation time, if any
1194    #[serde(skip_serializing_if = "Option::is_none")]
1195    pub selected_model: Option<String>,
1196    /// Unique identifier for the session
1197    pub session_id: SessionId,
1198    /// Session limits configured at session creation time, if any
1199    #[serde(skip_serializing_if = "Option::is_none")]
1200    pub session_limits: Option<SessionLimitsConfig>,
1201    /// ISO 8601 timestamp when the session was created
1202    pub start_time: String,
1203    /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
1204    #[serde(skip_serializing_if = "Option::is_none")]
1205    pub verbosity: Option<Verbosity>,
1206    /// Schema version number for the session event format
1207    pub version: i64,
1208}
1209
1210/// Session event "session.resume". Session resume metadata including current context and event count
1211#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1212#[serde(rename_all = "camelCase")]
1213pub struct SessionResumeData {
1214    /// Whether the session was already in use by another client at resume time
1215    #[serde(skip_serializing_if = "Option::is_none")]
1216    pub already_in_use: Option<bool>,
1217    /// Auto routing preference active at resume time
1218    #[serde(skip_serializing_if = "Option::is_none")]
1219    pub auto_tier: Option<AutoTier>,
1220    /// Updated working directory and git context at resume time
1221    #[serde(skip_serializing_if = "Option::is_none")]
1222    pub context: Option<WorkingDirectoryContext>,
1223    /// Context tier currently selected at resume time; null when no tier is active
1224    #[serde(skip_serializing_if = "Option::is_none")]
1225    pub context_tier: Option<ContextTier>,
1226    /// When true, tool calls and permission requests left in flight by the previous session lifetime remain pending after resume and the agentic loop awaits their results. User sends are queued behind the pending work until all such requests reach a terminal state. When false or omitted, pending work is normally marked as interrupted unless the resume passively joined live work owned by another client; sessionWasActive distinguishes that case.
1227    #[serde(skip_serializing_if = "Option::is_none")]
1228    pub continue_pending_work: Option<bool>,
1229    /// Total number of persisted events in the session at the time of resume
1230    pub event_count: i64,
1231    /// On-disk byte size of the session's persisted events.jsonl file at resume time; omitted when the file does not exist or cannot be stat'd
1232    #[serde(skip_serializing_if = "Option::is_none")]
1233    pub events_file_size_bytes: Option<i64>,
1234    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
1235    #[serde(skip_serializing_if = "Option::is_none")]
1236    pub reasoning_effort: Option<String>,
1237    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
1238    #[serde(skip_serializing_if = "Option::is_none")]
1239    pub reasoning_summary: Option<ReasoningSummary>,
1240    /// Whether this session supports remote steering via GitHub
1241    #[serde(skip_serializing_if = "Option::is_none")]
1242    pub remote_steerable: Option<bool>,
1243    /// ISO 8601 timestamp when the session was resumed
1244    pub resume_time: String,
1245    /// Model currently selected at resume time
1246    #[serde(skip_serializing_if = "Option::is_none")]
1247    pub selected_model: Option<String>,
1248    /// Session limits currently configured at resume time; null when no limits are active
1249    #[serde(skip_serializing_if = "Option::is_none")]
1250    pub session_limits: Option<SessionLimitsConfig>,
1251    /// True when this resume passively joined a session that already had live work running in the runtime - an agent turn, a native queue run, a queued resume continuation, or an in-flight send (for example, an extension joining a session another client was actively driving). False (or omitted) when the session had no live work or when the resume explicitly abandoned pending work, including cold resumes and suspended sessions that remain resident in memory.
1252    #[serde(skip_serializing_if = "Option::is_none")]
1253    pub session_was_active: Option<bool>,
1254    /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
1255    #[serde(skip_serializing_if = "Option::is_none")]
1256    pub verbosity: Option<Verbosity>,
1257}
1258
1259/// Session event "session.remote_steerable_changed". Notifies that the session's remote steering capability has changed
1260#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1261#[serde(rename_all = "camelCase")]
1262pub struct SessionRemoteSteerableChangedData {
1263    /// Whether this session now supports remote steering via GitHub
1264    pub remote_steerable: bool,
1265}
1266
1267/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
1268#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1269#[serde(rename_all = "camelCase")]
1270pub struct SessionErrorData {
1271    /// Only set on `errorType: "rate_limit"`. When `true`, the runtime will follow this error with an `auto_mode_switch.requested` event (or silently switch if `continueOnAutoMode` is enabled). UI clients can use this flag to suppress duplicate rendering of the rate-limit error when they show their own auto-mode-switch prompt.
1272    #[serde(skip_serializing_if = "Option::is_none")]
1273    pub eligible_for_auto_switch: Option<bool>,
1274    /// Fine-grained error code from the upstream provider, when available. For `errorType: "rate_limit"`, this is one of the `RateLimitErrorCode` values (e.g., `"user_weekly_rate_limited"`, `"user_global_rate_limited"`, `"rate_limited"`, `"user_model_rate_limited"`, `"integration_rate_limited"`). For `errorType: "quota"`, this is the CAPI quota error code (e.g., `"quota_exceeded"`, `"session_quota_exceeded"`, `"billing_not_configured"`).
1275    #[serde(skip_serializing_if = "Option::is_none")]
1276    pub error_code: Option<String>,
1277    /// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
1278    pub error_type: String,
1279    /// Human-readable error message
1280    pub message: String,
1281    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
1282    #[serde(skip_serializing_if = "Option::is_none")]
1283    pub provider_call_id: Option<String>,
1284    /// What the user must do to recover, when the runtime knows of an action. The `message` never names a client affordance, so a client that offers one — a slash command, a settings pane, a link — renders it from this value.
1285    #[serde(skip_serializing_if = "Option::is_none")]
1286    pub remediation: Option<RemediationAction>,
1287    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
1288    #[serde(skip_serializing_if = "Option::is_none")]
1289    pub service_request_id: Option<String>,
1290    /// Error stack trace, when available
1291    #[serde(skip_serializing_if = "Option::is_none")]
1292    pub stack: Option<String>,
1293    /// HTTP status code from the upstream request, if applicable
1294    #[serde(skip_serializing_if = "Option::is_none")]
1295    pub status_code: Option<i32>,
1296    /// Optional URL associated with this error that the user can open in a browser
1297    #[serde(skip_serializing_if = "Option::is_none")]
1298    pub url: Option<String>,
1299}
1300
1301/// Session event "session.idle". Payload indicating the session is idle with no background agents or attached shell commands in flight
1302#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1303#[serde(rename_all = "camelCase")]
1304pub struct SessionIdleData {
1305    /// True when the preceding agentic loop was cancelled via abort signal
1306    #[serde(skip_serializing_if = "Option::is_none")]
1307    pub aborted: Option<bool>,
1308    /// The session mode the agent was operating in when it went idle, when the mode is known. Lets turn-scoped consumers distinguish an autopilot continuation boundary (where the agent keeps working after this idle) from a genuine turn completion.
1309    #[serde(skip_serializing_if = "Option::is_none")]
1310    pub mode: Option<SessionMode>,
1311}
1312
1313/// Session event "session.title_changed". Session title change payload containing the new display title
1314#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1315#[serde(rename_all = "camelCase")]
1316pub struct SessionTitleChangedData {
1317    /// The new display title for the session
1318    pub title: String,
1319}
1320
1321/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
1322#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1323#[serde(rename_all = "camelCase")]
1324pub struct SessionScheduleCreatedData {
1325    /// Absolute fire time (epoch milliseconds) for a one-shot calendar schedule
1326    #[serde(skip_serializing_if = "Option::is_none")]
1327    pub at: Option<i64>,
1328    /// 5-field cron expression for a recurring calendar schedule, evaluated in `tz`
1329    #[serde(skip_serializing_if = "Option::is_none")]
1330    pub cron: Option<String>,
1331    /// Optional user-facing label shown in the timeline instead of the actual prompt (e.g. `/skill-name args` when the prompt is a skill invocation expansion)
1332    #[serde(skip_serializing_if = "Option::is_none")]
1333    pub display_prompt: Option<String>,
1334    /// Sequential id assigned to the scheduled prompt within the session
1335    pub id: i64,
1336    /// Interval between ticks in milliseconds (relative-interval schedules)
1337    #[serde(skip_serializing_if = "Option::is_none")]
1338    pub interval_ms: Option<i64>,
1339    /// Who created the schedule (`user` or `model`). Persisted so a resumed session keeps gating non-user schedules from firing skills that opted out of model invocation. Absent on entries created before this field existed; a missing origin fails closed (treated the same as a non-user origin), so such a schedule may not resolve a `disable-model-invocation` skill.
1340    #[serde(skip_serializing_if = "Option::is_none")]
1341    pub origin: Option<ScheduleOrigin>,
1342    /// Prompt text that gets enqueued on every tick
1343    pub prompt: String,
1344    /// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
1345    #[serde(skip_serializing_if = "Option::is_none")]
1346    pub recurring: Option<bool>,
1347    /// True for a self-paced (`dynamic`) schedule: no fixed cadence; the model arms each next run via the `manage_schedule` `wakeup` action. `nextRunAt` is model-controlled rather than auto-computed.
1348    #[serde(skip_serializing_if = "Option::is_none")]
1349    pub self_paced: Option<bool>,
1350    /// IANA timezone the `cron` expression is evaluated in
1351    #[serde(skip_serializing_if = "Option::is_none")]
1352    pub tz: Option<String>,
1353}
1354
1355/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
1356#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1357#[serde(rename_all = "camelCase")]
1358pub struct SessionScheduleCancelledData {
1359    /// Id of the scheduled prompt that was cancelled
1360    pub id: i64,
1361}
1362
1363/// Session event "session.schedule_rearmed". Self-paced schedule re-armed for its next run
1364#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1365#[serde(rename_all = "camelCase")]
1366pub struct SessionScheduleRearmedData {
1367    /// Id of the self-paced schedule that was re-armed
1368    pub id: i64,
1369    /// Absolute time (epoch milliseconds) the model armed the next run to fire
1370    pub next_run_at: i64,
1371}
1372
1373/// Session event "session.autopilot_objective_changed". Autopilot objective state file operation details indicating what changed
1374#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1375#[serde(rename_all = "camelCase")]
1376pub struct SessionAutopilotObjectiveChangedData {
1377    /// Current autopilot objective id, if one exists
1378    #[serde(skip_serializing_if = "Option::is_none")]
1379    pub id: Option<i64>,
1380    /// The type of operation performed on the autopilot objective state file
1381    pub operation: AutopilotObjectiveChangedOperation,
1382    /// Current autopilot objective status, if one exists
1383    #[serde(skip_serializing_if = "Option::is_none")]
1384    pub status: Option<AutopilotObjectiveChangedStatus>,
1385}
1386
1387/// Session event "session.info". Informational message for timeline display with categorization
1388#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1389#[serde(rename_all = "camelCase")]
1390pub struct SessionInfoData {
1391    /// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
1392    pub info_type: String,
1393    /// Human-readable informational message for display in the timeline
1394    pub message: String,
1395    /// Optional actionable tip displayed with this message
1396    #[serde(skip_serializing_if = "Option::is_none")]
1397    pub tip: Option<String>,
1398    /// Optional URL associated with this message that the user can open in a browser
1399    #[serde(skip_serializing_if = "Option::is_none")]
1400    pub url: Option<String>,
1401}
1402
1403#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1404#[serde(rename_all = "camelCase")]
1405pub struct IndexedSearchDataStatus {
1406    /// Indexed-search event variant discriminator.
1407    pub kind: IndexedSearchDataStatusKind,
1408    /// Current indexed-search state for this session activation.
1409    pub state: IndexedSearchState,
1410}
1411
1412#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1413#[serde(rename_all = "camelCase")]
1414pub struct IndexedSearchDataStartup {
1415    /// Why indexed search was disabled, when applicable.
1416    #[serde(skip_serializing_if = "Option::is_none")]
1417    pub disabled_reason: Option<IndexedSearchDisabledReason>,
1418    /// Whether the repository meets the automatic indexing file-count threshold, when known.
1419    #[serde(skip_serializing_if = "Option::is_none")]
1420    pub eligible: Option<bool>,
1421    /// Startup failure details. May contain sensitive user data; restricted telemetry only.
1422    #[serde(skip_serializing_if = "Option::is_none")]
1423    pub error_message: Option<String>,
1424    /// Number of text files counted in the repository.
1425    #[serde(skip_serializing_if = "Option::is_none")]
1426    pub file_count: Option<f64>,
1427    /// Whether indexed search was explicitly enabled through the environment.
1428    pub forced_by_env: bool,
1429    /// Indexed-search event variant discriminator.
1430    pub kind: IndexedSearchDataStartupKind,
1431    /// Outcome of this startup attempt.
1432    pub outcome: IndexedSearchOutcome,
1433    /// Wall-clock duration of startup in milliseconds.
1434    pub startup_duration_ms: f64,
1435    /// Whether waiting for index readiness was requested, including skipped attempts.
1436    pub warm_start: bool,
1437}
1438
1439#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1440#[serde(rename_all = "camelCase")]
1441pub struct IndexedSearchDataServerError {
1442    /// Server failure details. May contain sensitive user data; restricted telemetry only.
1443    #[serde(skip_serializing_if = "Option::is_none")]
1444    pub error_message: Option<String>,
1445    /// Category of the server failure.
1446    pub error_type: IndexedSearchErrorType,
1447    /// Process exit code, when available.
1448    #[serde(skip_serializing_if = "Option::is_none")]
1449    pub exit_code: Option<f64>,
1450    /// Indexed-search event variant discriminator.
1451    pub kind: IndexedSearchDataServerErrorKind,
1452}
1453
1454#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1455#[serde(rename_all = "camelCase")]
1456pub struct IndexedSearchDataIncremental {
1457    /// Number of added files.
1458    #[serde(skip_serializing_if = "Option::is_none")]
1459    pub added_file_count: Option<f64>,
1460    /// Number of modified files.
1461    #[serde(skip_serializing_if = "Option::is_none")]
1462    pub changed_file_count: Option<f64>,
1463    /// Number of deleted files.
1464    #[serde(skip_serializing_if = "Option::is_none")]
1465    pub deleted_file_count: Option<f64>,
1466    /// Indexed-search event variant discriminator.
1467    pub kind: IndexedSearchDataIncrementalKind,
1468    /// Phase of the incremental index update.
1469    pub phase: IndexedSearchIncrementalPhase,
1470    /// Total number of detected changes.
1471    #[serde(skip_serializing_if = "Option::is_none")]
1472    pub total_change_count: Option<f64>,
1473    /// Total incremental indexing duration in milliseconds.
1474    #[serde(skip_serializing_if = "Option::is_none")]
1475    pub total_duration_ms: Option<f64>,
1476    /// Index update duration in milliseconds.
1477    #[serde(skip_serializing_if = "Option::is_none")]
1478    pub update_duration_ms: Option<f64>,
1479    /// Workspace scan duration in milliseconds.
1480    #[serde(skip_serializing_if = "Option::is_none")]
1481    pub walk_duration_ms: Option<f64>,
1482}
1483
1484/// Session event "session.warning". Warning message for timeline display with categorization
1485#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1486#[serde(rename_all = "camelCase")]
1487pub struct SessionWarningData {
1488    /// Human-readable warning message for display in the timeline
1489    pub message: String,
1490    /// What the user must do to recover, when the runtime knows of an action. The `message` never names a client affordance, so a client that offers one — a slash command, a settings pane, a link — renders it from this value.
1491    #[serde(skip_serializing_if = "Option::is_none")]
1492    pub remediation: Option<RemediationAction>,
1493    /// Optional URL associated with this warning that the user can open in a browser
1494    #[serde(skip_serializing_if = "Option::is_none")]
1495    pub url: Option<String>,
1496    /// Category of warning (e.g., "subscription", "policy", "mcp")
1497    pub warning_type: String,
1498}
1499
1500/// Session event "session.model_change". Model change details including previous and new model identifiers
1501#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1502#[serde(rename_all = "camelCase")]
1503pub struct SessionModelChangeData {
1504    /// Committed Auto preference after the model configuration change, when applicable.
1505    #[serde(skip_serializing_if = "Option::is_none")]
1506    pub auto_tier: Option<AutoTier>,
1507    /// Reason the change happened, when not user-initiated. `"rate_limit_auto_switch"` for changes triggered by the auto-mode-switch rate-limit recovery path, or `"refusal_fallback"` when the active model declined a request (content refusal) and the runtime switched to the configured refusal-fallback model. UI clients can use this to render contextual copy.
1508    #[serde(skip_serializing_if = "Option::is_none")]
1509    pub cause: Option<String>,
1510    /// Context tier after the model change; null explicitly clears a previously selected tier
1511    #[serde(skip_serializing_if = "Option::is_none")]
1512    pub context_tier: Option<ContextTier>,
1513    /// Newly selected model identifier
1514    pub new_model: String,
1515    /// Previously committed Auto preference, when one was explicitly selected.
1516    #[serde(skip_serializing_if = "Option::is_none")]
1517    pub previous_auto_tier: Option<AutoTier>,
1518    /// Model that was previously selected, if any
1519    #[serde(skip_serializing_if = "Option::is_none")]
1520    pub previous_model: Option<String>,
1521    /// Reasoning effort level before the model change, if applicable
1522    #[serde(skip_serializing_if = "Option::is_none")]
1523    pub previous_reasoning_effort: Option<String>,
1524    /// Reasoning summary mode before the model change, if applicable
1525    #[serde(skip_serializing_if = "Option::is_none")]
1526    pub previous_reasoning_summary: Option<ReasoningSummary>,
1527    /// Output verbosity level before the model change, if applicable
1528    #[serde(skip_serializing_if = "Option::is_none")]
1529    pub previous_verbosity: Option<Verbosity>,
1530    /// Reasoning effort level after the model change, if applicable
1531    #[serde(skip_serializing_if = "Option::is_none")]
1532    pub reasoning_effort: Option<String>,
1533    /// Reasoning summary mode after the model change, if applicable
1534    #[serde(skip_serializing_if = "Option::is_none")]
1535    pub reasoning_summary: Option<ReasoningSummary>,
1536    /// Origin of the effective model change, when known.
1537    #[serde(skip_serializing_if = "Option::is_none")]
1538    pub source: Option<ModelChangeSource>,
1539    /// Output verbosity level after the model change, if applicable
1540    #[serde(skip_serializing_if = "Option::is_none")]
1541    pub verbosity: Option<Verbosity>,
1542}
1543
1544/// Session event "session.model_deselected". The model the user had explicitly selected is no longer available, because the host that published it withdrew it, so the session no longer has an explicit selection. The next turn resolves a default as though the user had never chosen a model. Clients should stop presenting the previous model as selected. This event is durable because resume rebuilds the selected model from the event log; without it a resumed session would restore a model its provider no longer serves. Reasoning effort, verbosity, and other session-level preferences are deliberately unchanged, because they belong to the session rather than to the model.
1545#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1546#[serde(rename_all = "camelCase")]
1547pub struct SessionModelDeselectedData {
1548    /// Model that was selected before the host withdrew it.
1549    pub previous_model: String,
1550    /// Low-cardinality reason the selection was cleared.
1551    pub reason: ModelDeselectedReason,
1552}
1553
1554/// Session event "session.auto_tier_recommendation". Live-only Auto preference recommendation from Copilot API after a successful Auto model call.
1555///
1556/// <div class="warning">
1557///
1558/// **Experimental.** This type is part of an experimental wire-protocol surface
1559/// and may change or be removed in future SDK or CLI releases.
1560///
1561/// </div>
1562#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1563#[serde(rename_all = "camelCase")]
1564pub struct SessionAutoTierRecommendationData {
1565    /// Recommended Auto preference.
1566    pub recommended_auto_tier: RecommendedAutoTier,
1567}
1568
1569/// Session event "session.auto_tier_switch_failed". A transient Auto preference failure emitted when the runtime cannot mint or accept a usable model and token pair. The previously effective preference remains active, so SDK clients can surface a non-blocking failure without changing their committed-tier state. This event is ephemeral and is not persisted or replayed on resume.
1570#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1571#[serde(rename_all = "camelCase")]
1572pub struct SessionAutoTierSwitchFailedData {
1573    /// Auto preference that remains effective after the failed request.
1574    #[serde(skip_serializing_if = "Option::is_none")]
1575    pub effective_auto_tier: Option<AutoTier>,
1576    /// Low-cardinality failure outcome reported by Auto resolution.
1577    pub reason: AutoTierSwitchFailureReason,
1578    /// Auto preference that failed to activate, or null when returning to provider-default routing failed.
1579    pub requested_auto_tier: Option<AutoTier>,
1580}
1581
1582/// Session event "session.mode_changed". Agent mode change details including previous and new modes
1583#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1584#[serde(rename_all = "camelCase")]
1585pub struct SessionModeChangedData {
1586    /// The session mode the agent is operating in
1587    pub new_mode: SessionMode,
1588    /// The session mode the agent is operating in
1589    pub previous_mode: SessionMode,
1590}
1591
1592/// Session event "session.mode_notice_delivered". Records that a mode transition notice reached the model so cache-stable mode tools can remain offered across resume.
1593#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1594#[serde(rename_all = "camelCase")]
1595pub struct SessionModeNoticeDeliveredData {
1596    /// Model-visible transition notice persisted for a mid-turn delivery
1597    #[serde(skip_serializing_if = "Option::is_none")]
1598    pub content: Option<String>,
1599    /// Mode established by the delivered transition notice
1600    pub mode: SessionMode,
1601}
1602
1603/// Session event "session.session_limits_changed". Session limits update details. Null clears the limits.
1604#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1605#[serde(rename_all = "camelCase")]
1606pub struct SessionSessionLimitsChangedData {
1607    /// Current session limits, or null when no limits are active
1608    pub session_limits: Option<SessionLimitsConfig>,
1609}
1610
1611/// Session event "session.permissions_changed". Permission-mode transition details.
1612///
1613/// <div class="warning">
1614///
1615/// **Experimental.** This type is part of an experimental wire-protocol surface
1616/// and may change or be removed in future SDK or CLI releases.
1617///
1618/// </div>
1619#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1620#[serde(rename_all = "camelCase")]
1621pub struct SessionPermissionsChangedData {
1622    /// Explicit LLM judge model override used by assisted mode; omitted when the provider default applies
1623    ///
1624    /// <div class="warning">
1625    ///
1626    /// **Experimental.** This type is part of an experimental wire-protocol surface
1627    /// and may change or be removed in future SDK or CLI releases.
1628    ///
1629    /// </div>
1630    #[serde(skip_serializing_if = "Option::is_none")]
1631    pub assisted_approval_model: Option<String>,
1632    /// Permission mode after the change
1633    ///
1634    /// <div class="warning">
1635    ///
1636    /// **Experimental.** This type is part of an experimental wire-protocol surface
1637    /// and may change or be removed in future SDK or CLI releases.
1638    ///
1639    /// </div>
1640    #[serde(skip_serializing_if = "Option::is_none")]
1641    pub mode: Option<PermissionMode>,
1642    /// Permission mode before the change
1643    ///
1644    /// <div class="warning">
1645    ///
1646    /// **Experimental.** This type is part of an experimental wire-protocol surface
1647    /// and may change or be removed in future SDK or CLI releases.
1648    ///
1649    /// </div>
1650    #[serde(skip_serializing_if = "Option::is_none")]
1651    pub previous_mode: Option<PermissionMode>,
1652}
1653
1654/// Session event "session.plan_changed". Plan file operation details indicating what changed
1655#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1656#[serde(rename_all = "camelCase")]
1657pub struct SessionPlanChangedData {
1658    /// The type of operation performed on the plan file
1659    pub operation: PlanChangedOperation,
1660}
1661
1662/// Session event "session.todos_changed". Signal-only event: the agent's todos or todo_deps table was written to. No payload — clients should call session.plan.readSqlTodosWithDependencies() to fetch the current state. Events arrive in order; clients can debounce on arrival if needed.
1663#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1664#[serde(rename_all = "camelCase")]
1665pub struct SessionTodosChangedData {}
1666
1667/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
1668#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1669#[serde(rename_all = "camelCase")]
1670pub struct SessionWorkspaceFileChangedData {
1671    /// Whether the file was newly created or updated
1672    pub operation: WorkspaceFileChangedOperation,
1673    /// Relative path within the session workspace files directory
1674    pub path: String,
1675}
1676
1677/// Repository context for the handed-off session
1678#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1679#[serde(rename_all = "camelCase")]
1680pub struct HandoffRepository {
1681    /// Git branch name, if applicable
1682    #[serde(skip_serializing_if = "Option::is_none")]
1683    pub branch: Option<String>,
1684    /// Repository name
1685    pub name: String,
1686    /// Repository owner (user or organization)
1687    pub owner: String,
1688}
1689
1690/// Session event "session.handoff". Session handoff metadata including source, context, and repository information
1691#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1692#[serde(rename_all = "camelCase")]
1693pub struct SessionHandoffData {
1694    /// Additional context information for the handoff
1695    #[serde(skip_serializing_if = "Option::is_none")]
1696    pub context: Option<String>,
1697    /// ISO 8601 timestamp when the handoff occurred
1698    pub handoff_time: String,
1699    /// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
1700    #[serde(skip_serializing_if = "Option::is_none")]
1701    pub host: Option<String>,
1702    /// Session ID of the remote session being handed off
1703    #[serde(skip_serializing_if = "Option::is_none")]
1704    pub remote_session_id: Option<SessionId>,
1705    /// Repository context for the handed-off session
1706    #[serde(skip_serializing_if = "Option::is_none")]
1707    pub repository: Option<HandoffRepository>,
1708    /// Origin type of the session being handed off
1709    pub source_type: HandoffSourceType,
1710    /// Summary of the work done in the source session
1711    #[serde(skip_serializing_if = "Option::is_none")]
1712    pub summary: Option<String>,
1713}
1714
1715/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
1716#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1717#[serde(rename_all = "camelCase")]
1718pub struct SessionTruncationData {
1719    /// Number of messages removed by truncation
1720    pub messages_removed_during_truncation: i64,
1721    /// Identifier of the component that performed truncation (e.g., "BasicTruncator")
1722    pub performed_by: String,
1723    /// Number of conversation messages after truncation
1724    pub post_truncation_messages_length: i64,
1725    /// Total tokens in conversation messages after truncation
1726    pub post_truncation_tokens_in_messages: i64,
1727    /// Number of conversation messages before truncation
1728    pub pre_truncation_messages_length: i64,
1729    /// Total tokens in conversation messages before truncation
1730    pub pre_truncation_tokens_in_messages: i64,
1731    /// Maximum token count for the model's context window
1732    pub token_limit: i64,
1733    /// Number of tokens removed by truncation
1734    pub tokens_removed_during_truncation: i64,
1735}
1736
1737/// Session event "session.snapshot_rewind". Session rewind details including target event and count of removed events
1738#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1739#[serde(rename_all = "camelCase")]
1740pub struct SessionSnapshotRewindData {
1741    /// The removed events, starting with `upToEventId`. Later events not listed were kept, such as a background agent's events that interleaved with a withdrawn turn
1742    #[serde(skip_serializing_if = "Option::is_none")]
1743    pub event_ids: Option<Vec<String>>,
1744    /// Number of events that were removed by the rewind
1745    pub events_removed: i64,
1746    /// First removed event. Without `eventIds`, it and every event after it were removed
1747    pub up_to_event_id: String,
1748}
1749
1750/// Request count and cost metrics
1751#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1752#[serde(rename_all = "camelCase")]
1753pub struct ShutdownModelMetricRequests {
1754    /// Cumulative cost multiplier for requests to this model
1755    ///
1756    /// <div class="warning">
1757    ///
1758    /// **Experimental.** This type is part of an experimental wire-protocol surface
1759    /// and may change or be removed in future SDK or CLI releases.
1760    ///
1761    /// </div>
1762    #[serde(skip_serializing_if = "Option::is_none")]
1763    pub cost: Option<f64>,
1764    /// Total number of API requests made to this model
1765    ///
1766    /// <div class="warning">
1767    ///
1768    /// **Experimental.** This type is part of an experimental wire-protocol surface
1769    /// and may change or be removed in future SDK or CLI releases.
1770    ///
1771    /// </div>
1772    #[serde(skip_serializing_if = "Option::is_none")]
1773    pub count: Option<i64>,
1774}
1775
1776/// A token-type entry in a shutdown model metric, storing the accumulated token count.
1777#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1778#[serde(rename_all = "camelCase")]
1779pub struct ShutdownModelMetricTokenDetail {
1780    /// Accumulated token count for this token type
1781    pub token_count: i64,
1782}
1783
1784/// Token usage breakdown
1785#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1786#[serde(rename_all = "camelCase")]
1787pub struct ShutdownModelMetricUsage {
1788    /// Total tokens read from prompt cache across all requests
1789    pub cache_read_tokens: i64,
1790    /// Total tokens written to prompt cache across all requests
1791    pub cache_write_tokens: i64,
1792    /// Total input tokens consumed across all requests to this model
1793    pub input_tokens: i64,
1794    /// Total output tokens produced across all requests to this model
1795    pub output_tokens: i64,
1796    /// Total reasoning tokens produced across all requests to this model
1797    #[serde(skip_serializing_if = "Option::is_none")]
1798    pub reasoning_tokens: Option<i64>,
1799}
1800
1801/// Per-model shutdown metrics with request counts, token usage, nano-AI units, and token details.
1802#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1803#[serde(rename_all = "camelCase")]
1804pub struct ShutdownModelMetric {
1805    /// Request count and cost metrics
1806    pub requests: ShutdownModelMetricRequests,
1807    /// Token count details per type
1808    #[serde(skip_serializing_if = "Option::is_none")]
1809    pub token_details: Option<HashMap<String, ShutdownModelMetricTokenDetail>>,
1810    /// Accumulated nano-AI units cost for this model
1811    ///
1812    /// <div class="warning">
1813    ///
1814    /// **Experimental.** This type is part of an experimental wire-protocol surface
1815    /// and may change or be removed in future SDK or CLI releases.
1816    ///
1817    /// </div>
1818    #[serde(skip_serializing_if = "Option::is_none")]
1819    pub total_nano_aiu: Option<f64>,
1820    /// Token usage breakdown
1821    pub usage: ShutdownModelMetricUsage,
1822}
1823
1824/// Usage attributed to one agent instance at session shutdown.
1825#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1826#[serde(rename_all = "camelCase")]
1827pub struct ShutdownAgentMetric {
1828    /// Human-readable label for this subagent invocation, copied from the originating `subagent.started` event. For task-tool subagents this is the invocation's task description rather than the agent's configured display name, so group by `agentName` for stable per-agent labels.
1829    #[serde(skip_serializing_if = "Option::is_none")]
1830    pub agent_display_name: Option<String>,
1831    /// Configured agent name, when this is a subagent
1832    #[serde(skip_serializing_if = "Option::is_none")]
1833    pub agent_name: Option<String>,
1834    /// Per-model usage for this agent, keyed by model identifier
1835    pub model_metrics: HashMap<String, ShutdownModelMetric>,
1836    /// Time spent in model API calls by this agent, in milliseconds
1837    pub total_api_duration_ms: i64,
1838    /// Accumulated nano-AI units cost for this agent
1839    pub total_nano_aiu: f64,
1840}
1841
1842/// Aggregate code change metrics for the session
1843#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1844#[serde(rename_all = "camelCase")]
1845pub struct ShutdownCodeChanges {
1846    /// List of file paths that were modified during the session
1847    pub files_modified: Vec<String>,
1848    /// Total number of lines added during the session
1849    pub lines_added: i64,
1850    /// Total number of lines removed during the session
1851    pub lines_removed: i64,
1852}
1853
1854/// A session-wide shutdown token-type entry storing the accumulated token count.
1855#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1856#[serde(rename_all = "camelCase")]
1857pub struct ShutdownTokenDetail {
1858    /// Accumulated token count for this token type
1859    pub token_count: i64,
1860}
1861
1862/// Session event "session.shutdown". Session termination metrics including usage statistics, code changes, and shutdown reason
1863#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1864#[serde(rename_all = "camelCase")]
1865pub struct SessionShutdownData {
1866    /// Per-agent usage breakdown, keyed by agent instance identifier. The main conversation uses the stable key `main`.
1867    #[serde(skip_serializing_if = "Option::is_none")]
1868    pub agent_metrics: Option<HashMap<String, ShutdownAgentMetric>>,
1869    /// Aggregate code change metrics for the session
1870    pub code_changes: ShutdownCodeChanges,
1871    /// Non-system message token count at shutdown
1872    #[serde(skip_serializing_if = "Option::is_none")]
1873    pub conversation_tokens: Option<i64>,
1874    /// Model that was selected at the time of shutdown
1875    #[serde(skip_serializing_if = "Option::is_none")]
1876    pub current_model: Option<String>,
1877    /// Total tokens in context window at shutdown
1878    #[serde(skip_serializing_if = "Option::is_none")]
1879    pub current_tokens: Option<i64>,
1880    /// Error description when shutdownType is "error"
1881    #[serde(skip_serializing_if = "Option::is_none")]
1882    pub error_reason: Option<String>,
1883    /// On-disk byte size of the session's persisted events.jsonl file at shutdown time; omitted when the file does not exist or cannot be stat'd
1884    #[serde(skip_serializing_if = "Option::is_none")]
1885    pub events_file_size_bytes: Option<i64>,
1886    /// Per-model usage breakdown, keyed by model identifier
1887    pub model_metrics: HashMap<String, ShutdownModelMetric>,
1888    /// Unix timestamp (milliseconds) when the session started
1889    pub session_start_time: i64,
1890    /// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
1891    pub shutdown_type: ShutdownType,
1892    /// System message token count at shutdown
1893    #[serde(skip_serializing_if = "Option::is_none")]
1894    pub system_tokens: Option<i64>,
1895    /// Session-wide per-token-type accumulated token counts
1896    #[serde(skip_serializing_if = "Option::is_none")]
1897    pub token_details: Option<HashMap<String, ShutdownTokenDetail>>,
1898    /// Tool definitions token count at shutdown
1899    #[serde(skip_serializing_if = "Option::is_none")]
1900    pub tool_definitions_tokens: Option<i64>,
1901    /// Cumulative time spent in API calls during the session, in milliseconds
1902    pub total_api_duration_ms: i64,
1903    /// Session-wide accumulated nano-AI units cost
1904    ///
1905    /// <div class="warning">
1906    ///
1907    /// **Experimental.** This type is part of an experimental wire-protocol surface
1908    /// and may change or be removed in future SDK or CLI releases.
1909    ///
1910    /// </div>
1911    #[serde(skip_serializing_if = "Option::is_none")]
1912    pub total_nano_aiu: Option<f64>,
1913    /// Total number of premium API requests used during the session
1914    #[doc(hidden)]
1915    #[serde(skip_serializing_if = "Option::is_none")]
1916    pub(crate) total_premium_requests: Option<f64>,
1917}
1918
1919/// Internal prompt-cache expiration state for one model
1920#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1921#[serde(rename_all = "camelCase")]
1922pub(crate) struct UsageCheckpointModelCacheState {
1923    /// Latest known prompt-cache expiration
1924    pub cache_expires_at: String,
1925    /// Retained cache lifetime in seconds, used to refresh expiration after a cache read
1926    #[doc(hidden)]
1927    pub(crate) cache_ttl_seconds: i64,
1928    /// Model identifier associated with this cache state
1929    pub model_id: String,
1930}
1931
1932/// Session event "session.usage_checkpoint". Durable session usage checkpoint for reconstructing aggregate accounting on resume
1933#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1934#[serde(rename_all = "camelCase")]
1935pub struct SessionUsageCheckpointData {
1936    /// Internal per-model prompt-cache state used to restore expiration tracking on resume
1937    #[doc(hidden)]
1938    #[serde(skip_serializing_if = "Option::is_none")]
1939    pub(crate) model_cache_state: Option<Vec<UsageCheckpointModelCacheState>>,
1940    /// Internal per-conversation prompt-cache-break detector baselines restored on resume
1941    #[doc(hidden)]
1942    #[serde(skip_serializing_if = "Option::is_none")]
1943    pub(crate) prompt_cache_break_state: Option<Vec<serde_json::Value>>,
1944    /// Session-wide accumulated nano-AI units cost at checkpoint time
1945    pub total_nano_aiu: f64,
1946    /// Total number of premium API requests used at checkpoint time
1947    #[doc(hidden)]
1948    #[serde(skip_serializing_if = "Option::is_none")]
1949    pub(crate) total_premium_requests: Option<f64>,
1950}
1951
1952/// Session event "session.context_changed". Updated working directory and git context after the change
1953#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1954#[serde(rename_all = "camelCase")]
1955pub struct SessionContextChangedData {
1956    /// Base commit of current git branch at session start time
1957    #[serde(skip_serializing_if = "Option::is_none")]
1958    pub base_commit: Option<String>,
1959    /// Current git branch name
1960    #[serde(skip_serializing_if = "Option::is_none")]
1961    pub branch: Option<String>,
1962    /// Current working directory path
1963    pub cwd: String,
1964    /// Root directory of the git repository, resolved via git rev-parse
1965    #[serde(skip_serializing_if = "Option::is_none")]
1966    pub git_root: Option<String>,
1967    /// Head commit of current git branch at session start time
1968    #[serde(skip_serializing_if = "Option::is_none")]
1969    pub head_commit: Option<String>,
1970    /// Hosting platform type of the repository (github or ado)
1971    #[serde(skip_serializing_if = "Option::is_none")]
1972    pub host_type: Option<WorkingDirectoryContextHostType>,
1973    /// Set on the immediate preliminary event of a working-directory change, before the git context is resolved. A settled follow-up event (enriched with git context, or cwd-only for a non-repository) is always emitted afterward, so observers may defer to it. Absent on standalone/final events (e.g. relay context changes).
1974    #[serde(skip_serializing_if = "Option::is_none")]
1975    pub pending_git_context: Option<bool>,
1976    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
1977    #[serde(skip_serializing_if = "Option::is_none")]
1978    pub repository: Option<String>,
1979    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
1980    #[serde(skip_serializing_if = "Option::is_none")]
1981    pub repository_host: Option<String>,
1982}
1983
1984/// Session event "session.usage_info". Current context window usage statistics including token and message counts
1985#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1986#[serde(rename_all = "camelCase")]
1987pub struct SessionUsageInfoData {
1988    /// Token count from non-system messages (user, assistant, tool)
1989    #[serde(skip_serializing_if = "Option::is_none")]
1990    pub conversation_tokens: Option<i64>,
1991    /// Current number of tokens in the context window
1992    pub current_tokens: i64,
1993    /// Whether this is the first usage_info event emitted in this session
1994    #[serde(skip_serializing_if = "Option::is_none")]
1995    pub is_initial: Option<bool>,
1996    /// Current number of messages in the conversation
1997    pub messages_length: i64,
1998    /// Token count from system message(s)
1999    #[serde(skip_serializing_if = "Option::is_none")]
2000    pub system_tokens: Option<i64>,
2001    /// Maximum token count for the model's context window
2002    pub token_limit: i64,
2003    /// Token count from tool definitions
2004    #[serde(skip_serializing_if = "Option::is_none")]
2005    pub tool_definitions_tokens: Option<i64>,
2006}
2007
2008/// Session event "session.context_cleared". Context-cleared details emitted when the host clears the conversation (the session.history.clearContext RPC / Session.clearContextMessages)
2009#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2010#[serde(rename_all = "camelCase")]
2011pub struct SessionContextClearedData {
2012    /// Optional initial message set after clearing
2013    #[serde(skip_serializing_if = "Option::is_none")]
2014    pub initial_message: Option<String>,
2015    /// Number of conversation messages that were cleared
2016    pub messages_cleared: i64,
2017}
2018
2019/// Session event "session.compaction_start". Context window breakdown at the start of LLM-powered conversation compaction
2020#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2021#[serde(rename_all = "camelCase")]
2022pub struct SessionCompactionStartData {
2023    /// Token count from non-system messages (user, assistant, tool) at compaction start
2024    #[serde(skip_serializing_if = "Option::is_none")]
2025    pub conversation_tokens: Option<i64>,
2026    /// Total context tokens (system + conversation + tool definitions) at compaction start, when known
2027    #[serde(skip_serializing_if = "Option::is_none")]
2028    pub current_tokens: Option<i64>,
2029    /// Model identifier used for compaction, when known
2030    #[serde(skip_serializing_if = "Option::is_none")]
2031    pub model: Option<String>,
2032    /// Token count from system message(s) at compaction start
2033    #[serde(skip_serializing_if = "Option::is_none")]
2034    pub system_tokens: Option<i64>,
2035    /// Model context window token limit the compaction is targeting, when known
2036    #[serde(skip_serializing_if = "Option::is_none")]
2037    pub token_limit: Option<i64>,
2038    /// Token count from tool definitions at compaction start
2039    #[serde(skip_serializing_if = "Option::is_none")]
2040    pub tool_definitions_tokens: Option<i64>,
2041    /// What initiated this compaction, when known
2042    #[serde(skip_serializing_if = "Option::is_none")]
2043    pub trigger: Option<CompactionTrigger>,
2044}
2045
2046/// Token usage detail for a single billing category
2047#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2048#[serde(rename_all = "camelCase")]
2049pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
2050    /// Number of tokens in this billing batch
2051    pub batch_size: i64,
2052    /// Cost per batch of tokens
2053    pub cost_per_batch: i64,
2054    /// Model responsible for this billing entry
2055    #[serde(skip_serializing_if = "Option::is_none")]
2056    pub model: Option<String>,
2057    /// Total token count for this entry
2058    pub token_count: i64,
2059    /// Token category (e.g., "input", "output")
2060    pub token_type: String,
2061}
2062
2063/// Per-request cost and usage data from the CAPI copilot_usage response field
2064#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2065#[serde(rename_all = "camelCase")]
2066pub(crate) struct CompactionCompleteCompactionTokensUsedCopilotUsage {
2067    /// Default billing model for token details that do not identify their own model
2068    #[doc(hidden)]
2069    #[serde(skip_serializing_if = "Option::is_none")]
2070    pub(crate) model: Option<String>,
2071    /// Itemized token usage breakdown
2072    #[doc(hidden)]
2073    #[serde(skip_serializing_if = "Option::is_none")]
2074    pub(crate) token_details:
2075        Option<Vec<CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail>>,
2076    /// Total cost in nano-AI units for this request
2077    pub total_nano_aiu: f64,
2078}
2079
2080/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
2081#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2082#[serde(rename_all = "camelCase")]
2083pub struct CompactionCompleteCompactionTokensUsed {
2084    /// Cached input tokens reused in the compaction LLM call
2085    #[serde(skip_serializing_if = "Option::is_none")]
2086    pub cache_read_tokens: Option<i64>,
2087    /// Tokens written to prompt cache in the compaction LLM call
2088    #[serde(skip_serializing_if = "Option::is_none")]
2089    pub cache_write_tokens: Option<i64>,
2090    /// Per-request cost and usage data from the CAPI copilot_usage response field
2091    #[doc(hidden)]
2092    #[serde(skip_serializing_if = "Option::is_none")]
2093    pub(crate) copilot_usage: Option<CompactionCompleteCompactionTokensUsedCopilotUsage>,
2094    /// Duration of the compaction LLM call in milliseconds
2095    #[serde(skip_serializing_if = "Option::is_none")]
2096    pub duration: Option<i64>,
2097    /// Input tokens consumed by the compaction LLM call
2098    #[serde(skip_serializing_if = "Option::is_none")]
2099    pub input_tokens: Option<i64>,
2100    /// Model identifier used for the compaction LLM call
2101    #[serde(skip_serializing_if = "Option::is_none")]
2102    pub model: Option<String>,
2103    /// Output tokens produced by the compaction LLM call
2104    #[serde(skip_serializing_if = "Option::is_none")]
2105    pub output_tokens: Option<i64>,
2106}
2107
2108/// Original request-level and effective conversation reasoning effort for a provider history boundary; the historical type name is retained for compatibility
2109#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2110#[serde(rename_all = "camelCase")]
2111pub struct ResponsesReasoning {
2112    /// Effective effort selected before this message, independent of the response-level reasoning field
2113    pub effort: String,
2114    /// Original request-level effort, retained while replaying this conversation prefix
2115    pub initial_effort: String,
2116    /// Provider model whose reasoning settings this boundary records
2117    pub model: String,
2118}
2119
2120/// Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
2121#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2122#[serde(rename_all = "camelCase")]
2123pub struct SessionCompactionCompleteData {
2124    /// Authoritative active-factory reminder appended to the compacted context
2125    #[doc(hidden)]
2126    #[serde(skip_serializing_if = "Option::is_none")]
2127    pub(crate) active_factory_summary: Option<String>,
2128    /// Canonical model identifier used for model-specific behavior when replaying compaction
2129    #[serde(skip_serializing_if = "Option::is_none")]
2130    pub behavior_model_id: Option<String>,
2131    /// Checkpoint snapshot number created for recovery
2132    #[serde(skip_serializing_if = "Option::is_none")]
2133    pub checkpoint_number: Option<i64>,
2134    /// File path where the checkpoint was stored
2135    #[serde(skip_serializing_if = "Option::is_none")]
2136    pub checkpoint_path: Option<String>,
2137    /// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
2138    #[serde(skip_serializing_if = "Option::is_none")]
2139    pub compaction_tokens_used: Option<CompactionCompleteCompactionTokensUsed>,
2140    /// Token count from non-system messages (user, assistant, tool) after compaction
2141    #[serde(skip_serializing_if = "Option::is_none")]
2142    pub conversation_tokens: Option<i64>,
2143    /// User-supplied focus instructions provided to a manual `/compact` invocation. Omitted for automatic compaction and for manual compaction with no focus text.
2144    #[serde(skip_serializing_if = "Option::is_none")]
2145    pub custom_instructions: Option<String>,
2146    /// Error message if compaction failed
2147    #[serde(skip_serializing_if = "Option::is_none")]
2148    pub error: Option<String>,
2149    /// Number of messages removed during compaction
2150    #[serde(skip_serializing_if = "Option::is_none")]
2151    pub messages_removed: Option<i64>,
2152    /// Total tokens in conversation after compaction
2153    #[serde(skip_serializing_if = "Option::is_none")]
2154    pub post_compaction_tokens: Option<i64>,
2155    /// Number of messages before compaction
2156    #[serde(skip_serializing_if = "Option::is_none")]
2157    pub pre_compaction_messages_length: Option<i64>,
2158    /// Total tokens in conversation before compaction
2159    #[serde(skip_serializing_if = "Option::is_none")]
2160    pub pre_compaction_tokens: Option<i64>,
2161    /// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
2162    #[serde(skip_serializing_if = "Option::is_none")]
2163    pub request_id: Option<RequestId>,
2164    /// Reasoning baseline on the replacement summary, preserved when replay skips the compacted history
2165    #[serde(skip_serializing_if = "Option::is_none")]
2166    pub responses_reasoning: Option<ResponsesReasoning>,
2167    /// Copilot service request ID (x-copilot-service-request-id header) for the compaction LLM call
2168    #[serde(skip_serializing_if = "Option::is_none")]
2169    pub service_request_id: Option<String>,
2170    /// For failed compaction only: the HTTP status code of the compaction LLM call failure, when it carried one. Absent for successful compaction and for failures without an HTTP status (e.g. an empty model response or a transport error).
2171    #[serde(skip_serializing_if = "Option::is_none")]
2172    pub status_code: Option<i64>,
2173    /// Whether compaction completed successfully
2174    pub success: bool,
2175    /// LLM-generated summary of the compacted conversation history
2176    #[serde(skip_serializing_if = "Option::is_none")]
2177    pub summary_content: Option<String>,
2178    /// Token count from system message(s) after compaction
2179    #[serde(skip_serializing_if = "Option::is_none")]
2180    pub system_tokens: Option<i64>,
2181    /// Model context window token limit the compaction was targeting, when known
2182    #[serde(skip_serializing_if = "Option::is_none")]
2183    pub token_limit: Option<i64>,
2184    /// Number of tokens removed during compaction
2185    #[serde(skip_serializing_if = "Option::is_none")]
2186    pub tokens_removed: Option<i64>,
2187    /// Token count from tool definitions after compaction
2188    #[serde(skip_serializing_if = "Option::is_none")]
2189    pub tool_definitions_tokens: Option<i64>,
2190    /// What initiated this compaction, when known
2191    #[serde(skip_serializing_if = "Option::is_none")]
2192    pub trigger: Option<CompactionTrigger>,
2193}
2194
2195#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2196#[serde(rename_all = "camelCase")]
2197pub struct PermissionRecoveryAttempt {
2198    /// Unique identifier for this attempt record
2199    pub attempt_id: String,
2200    /// How the runtime handled this attempt
2201    pub disposition: PermissionRecoveryAttemptDisposition,
2202    /// One-based position of this attempt in the episode
2203    pub ordinal: i64,
2204    /// Controlled permission request kind, such as shell, path, URL, or tool
2205    pub permission_kind: String,
2206    /// Controlled reason for the attempt disposition
2207    pub reason: PermissionRecoveryAttemptReason,
2208    /// Relationship between this attempt and earlier attempts in the episode
2209    pub relation: PermissionRecoveryAttemptRelation,
2210    /// SHA-256 fingerprint of normalized request data; raw permission arguments are not included
2211    pub request_fingerprint: String,
2212    /// Tool-call identifier associated with this attempt, when available
2213    #[serde(skip_serializing_if = "Option::is_none")]
2214    pub tool_call_id: Option<String>,
2215}
2216
2217/// Authoritative snapshot of an Autopilot permission-recovery episode
2218#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2219#[serde(rename_all = "camelCase")]
2220pub struct PermissionRecoveryData {
2221    /// Ordered privacy-safe record of permission attempts and the successful alternative, when any
2222    pub attempts: Vec<PermissionRecoveryAttempt>,
2223    /// Stable identifier shared by every transition in this recovery episode
2224    pub episode_id: String,
2225    /// Maximum number of distinct autonomous permission attempts allowed before escalation
2226    pub max_attempts: i64,
2227    /// Policy selected from the current client's response capability; mode or client changes may update it during recovery
2228    pub on_blocked: PermissionRecoveryOnBlocked,
2229    /// Controlled reason for the latest episode transition
2230    pub reason: PermissionRecoveryReason,
2231    /// Current lifecycle state of the recovery episode
2232    pub status: PermissionRecoveryStatus,
2233}
2234
2235/// Structured reason that the task cannot continue without intervention
2236///
2237/// <div class="warning">
2238///
2239/// **Experimental.** This type is part of an experimental wire-protocol surface
2240/// and may change or be removed in future SDK or CLI releases.
2241///
2242/// </div>
2243#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2244#[serde(rename_all = "camelCase")]
2245pub struct TaskBlocker {
2246    /// Category of intervention that blocked the task
2247    pub kind: TaskBlockerKind,
2248    /// Permission-recovery episode that produced this blocker
2249    pub permission_recovery: PermissionRecoveryData,
2250    /// Controlled reason for the current blocked state
2251    pub reason: PermissionRecoveryReason,
2252    /// Whether a later user response or steering message can resume the task
2253    pub resumable: bool,
2254}
2255
2256/// Session event "session.task_complete". Task completion notification with summary from the agent
2257#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2258#[serde(rename_all = "camelCase")]
2259pub struct SessionTaskCompleteData {
2260    /// Structured blocker details when outcome is blocked
2261    #[serde(skip_serializing_if = "Option::is_none")]
2262    pub blocker: Option<TaskBlocker>,
2263    /// Active autopilot objective ID evaluated by the completion reviewer
2264    #[serde(skip_serializing_if = "Option::is_none")]
2265    pub objective_id: Option<i64>,
2266    /// Semantic completion decision. Absent on legacy events and invalid tool calls
2267    #[serde(skip_serializing_if = "Option::is_none")]
2268    pub outcome: Option<TaskCompletionOutcome>,
2269    /// Label-safe runtime rationale for the completion decision (e.g. a cancellation or pause/resume downgrade), when one applies. Reviewer-authored rationale is intentionally omitted here because this event has no IFC label channel; the reviewer's findings remain available through its own labeled sub-agent events
2270    #[serde(skip_serializing_if = "Option::is_none")]
2271    pub reason: Option<String>,
2272    /// Whether the task was accepted as complete. False when validation failed or completion was rejected or blocked by the reviewer
2273    #[serde(skip_serializing_if = "Option::is_none")]
2274    pub success: Option<bool>,
2275    /// Summary of the completed task, provided by the agent
2276    #[serde(skip_serializing_if = "Option::is_none")]
2277    pub summary: Option<String>,
2278}
2279
2280/// Inclusive durable event range summarized by a completion receipt.
2281#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2282#[serde(rename_all = "camelCase")]
2283pub struct CompletionReceiptEventRange {
2284    /// Identifier of the assistant turn-end event that ends the covered exchange. Always equals the receipt's sourceEventId, so either field is a valid join key.
2285    pub end_event_id: String,
2286    /// Identifier of the user message that starts the covered exchange.
2287    pub start_event_id: String,
2288}
2289
2290/// Final structured tool completion in the covered event range.
2291#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2292#[serde(rename_all = "camelCase")]
2293pub struct CompletionReceiptFinalTool {
2294    /// Process exit code from a structured shell result, when available.
2295    #[serde(skip_serializing_if = "Option::is_none")]
2296    pub exit_code: Option<i64>,
2297    /// Structured success or failure status from the tool completion event.
2298    pub status: CompletionReceiptToolStatus,
2299    /// Unique identifier of the completed tool call.
2300    pub tool_call_id: String,
2301    /// Tool name from the matching tool execution start event, when available.
2302    #[serde(skip_serializing_if = "Option::is_none")]
2303    pub tool_name: Option<String>,
2304}
2305
2306/// Session event "session.completion_receipt". Behavior-neutral record of structured runtime facts present when an agent completion decision is accepted.
2307///
2308/// <div class="warning">
2309///
2310/// **Experimental.** This type is part of an experimental wire-protocol surface
2311/// and may change or be removed in future SDK or CLI releases.
2312///
2313/// </div>
2314#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2315#[serde(rename_all = "camelCase")]
2316pub struct SessionCompletionReceiptData {
2317    /// One-based accepted completion receipt ordinal in the durable session history.
2318    pub attempt: i64,
2319    /// Inclusive durable event range summarized by this receipt.
2320    pub event_range: CompletionReceiptEventRange,
2321    /// Number of failed structured tool completions in the covered range.
2322    pub failed_tool_count: i64,
2323    /// Final structured tool completion in the covered range, when one exists.
2324    #[serde(skip_serializing_if = "Option::is_none")]
2325    pub final_tool: Option<CompletionReceiptFinalTool>,
2326    /// Version of the completion receipt payload.
2327    pub schema_version: i64,
2328    /// Identifier of the assistant turn-end event that supplied the accepted completion boundary. This is the receipt's idempotency key, and always equals eventRange.endEventId.
2329    pub source_event_id: String,
2330    /// Runtime reason the completion decision was accepted.
2331    pub stop_reason: CompletionReceiptStopReason,
2332    /// Number of successful structured tool completions in the covered range.
2333    pub successful_tool_count: i64,
2334}
2335
2336/// Session event "session.fusion_route_started". Experimental transient signal that HydraFusion routing has started for an eligible turn.
2337///
2338/// <div class="warning">
2339///
2340/// **Experimental.** This type is part of an experimental wire-protocol surface
2341/// and may change or be removed in future SDK or CLI releases.
2342///
2343/// </div>
2344#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2345#[serde(rename_all = "camelCase")]
2346pub struct SessionFusionRouteStartedData {
2347    /// Identifier for this routing attempt before a durable Fusion turn exists.
2348    pub attempt_id: String,
2349    /// HydraFusion routing policy requested for the turn.
2350    #[serde(skip_serializing_if = "Option::is_none")]
2351    pub policy: Option<String>,
2352    /// Synthetic HydraFusion model selected for the session.
2353    #[serde(skip_serializing_if = "Option::is_none")]
2354    pub synthetic_model: Option<String>,
2355    /// Kind of turn being routed.
2356    pub turn_kind: FusionTurnKind,
2357}
2358
2359/// Session event "session.fusion_route_failed". Experimental durable HydraFusion routing failure and the deterministic concrete fallback selected for the turn.
2360///
2361/// <div class="warning">
2362///
2363/// **Experimental.** This type is part of an experimental wire-protocol surface
2364/// and may change or be removed in future SDK or CLI releases.
2365///
2366/// </div>
2367#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2368#[serde(rename_all = "camelCase")]
2369pub struct SessionFusionRouteFailedData {
2370    /// Identifier of the routing attempt that failed.
2371    pub attempt_id: String,
2372    /// Provider or validation error detail, when available.
2373    #[serde(skip_serializing_if = "Option::is_none")]
2374    pub error_message: Option<String>,
2375    /// Concrete model selected as the deterministic fallback.
2376    pub fallback_model: String,
2377    /// HydraFusion routing policy requested for the turn.
2378    pub policy: String,
2379    /// Stable machine-readable reason for the routing failure.
2380    pub reason: String,
2381    /// Elapsed routing time in milliseconds before the failure.
2382    #[serde(skip_serializing_if = "Option::is_none")]
2383    pub routing_latency_ms: Option<f64>,
2384    /// Synthetic HydraFusion model selected for the session.
2385    pub synthetic_model: String,
2386}
2387
2388/// Durable server recommendation for subsequent HydraFusion turns.
2389///
2390/// <div class="warning">
2391///
2392/// **Experimental.** This type is part of an experimental wire-protocol surface
2393/// and may change or be removed in future SDK or CLI releases.
2394///
2395/// </div>
2396#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2397#[serde(rename_all = "camelCase")]
2398pub struct FusionFollowUpRecommendation {
2399    /// Recommended routing action for the next compaction turn.
2400    pub compaction_turn: FusionFollowUpAction,
2401    /// Recommended routing action for the next user-message turn.
2402    pub user_turn: FusionFollowUpAction,
2403}
2404
2405/// Presentation-neutral phase planned for a HydraFusion turn.
2406///
2407/// <div class="warning">
2408///
2409/// **Experimental.** This type is part of an experimental wire-protocol surface
2410/// and may change or be removed in future SDK or CLI releases.
2411///
2412/// </div>
2413#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2414#[serde(rename_all = "camelCase")]
2415pub struct FusionPhasePlanStep {
2416    /// Whether the phase executes only when an earlier phase requests it.
2417    pub conditional: bool,
2418    /// Kind of phase that may execute.
2419    pub kind: FusionPhaseKind,
2420    /// Semantic role assigned to the phase.
2421    pub role: String,
2422    /// Conversation scope in which the phase executes.
2423    pub scope: FusionConversationScope,
2424}
2425
2426/// Validated HydraFusion routing capability scores.
2427///
2428/// <div class="warning">
2429///
2430/// **Experimental.** This type is part of an experimental wire-protocol surface
2431/// and may change or be removed in future SDK or CLI releases.
2432///
2433/// </div>
2434#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2435#[serde(rename_all = "camelCase")]
2436pub struct FusionScores {
2437    /// Code-generation capability score returned by the authenticated router.
2438    pub code_gen: f64,
2439    /// Debugging capability score returned by the authenticated router.
2440    pub debugging: f64,
2441    /// Reasoning capability score returned by the authenticated router.
2442    pub reasoning: f64,
2443    /// Tool-use capability score returned by the authenticated router.
2444    pub tool_use: f64,
2445}
2446
2447/// Session event "session.fusion_resolved". Experimental durable validated HydraFusion route and turn policy.
2448///
2449/// <div class="warning">
2450///
2451/// **Experimental.** This type is part of an experimental wire-protocol surface
2452/// and may change or be removed in future SDK or CLI releases.
2453///
2454/// </div>
2455#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2456#[serde(rename_all = "camelCase")]
2457pub struct SessionFusionResolvedData {
2458    /// Version of the validated HydraFusion event contract.
2459    pub contract_version: i64,
2460    /// Concrete model used when the planned primary model cannot execute.
2461    pub fallback_model: String,
2462    /// Router recommendation controlling reuse or rerouting on later turns.
2463    #[serde(skip_serializing_if = "Option::is_none")]
2464    pub follow_up: Option<FusionFollowUpRecommendation>,
2465    /// Concrete model recommended for eligible follow-up turns.
2466    pub follow_up_model: String,
2467    /// Stable identifier for the resolved HydraFusion turn.
2468    pub fusion_id: String,
2469    /// Short human-readable summary of the selected workflow, suitable for immediate client display after routing. May be absent in older durable events; omit the explanation or derive one from pattern and phasePlan. Display text, not a stable machine-readable value.
2470    ///
2471    /// <div class="warning">
2472    ///
2473    /// **Experimental.** This type is part of an experimental wire-protocol surface
2474    /// and may change or be removed in future SDK or CLI releases.
2475    ///
2476    /// </div>
2477    #[serde(skip_serializing_if = "Option::is_none")]
2478    pub hint: Option<String>,
2479    /// Version of the executable model universe used for selection.
2480    #[serde(skip_serializing_if = "Option::is_none")]
2481    pub model_universe_version: Option<String>,
2482    /// Validated orchestration pattern selected for the turn.
2483    pub pattern: FusionPattern,
2484    /// Presentation-neutral phase plan for clients that render workflow progress.
2485    ///
2486    /// <div class="warning">
2487    ///
2488    /// **Experimental.** This type is part of an experimental wire-protocol surface
2489    /// and may change or be removed in future SDK or CLI releases.
2490    ///
2491    /// </div>
2492    #[serde(skip_serializing_if = "Option::is_none")]
2493    pub phase_plan: Option<Vec<FusionPhasePlanStep>>,
2494    /// Version of the validated execution-plan format.
2495    #[serde(skip_serializing_if = "Option::is_none")]
2496    pub plan_version: Option<String>,
2497    /// HydraFusion routing policy used to resolve the plan.
2498    pub policy: String,
2499    /// Version of the local routing policy.
2500    #[serde(skip_serializing_if = "Option::is_none")]
2501    pub policy_version: Option<String>,
2502    /// Concrete model selected for the primary solver phase.
2503    pub primary_model: String,
2504    /// Router implementation that supplied the plan.
2505    #[serde(skip_serializing_if = "Option::is_none")]
2506    pub route_source: Option<String>,
2507    /// Elapsed time in milliseconds required to resolve and validate the route.
2508    #[serde(skip_serializing_if = "Option::is_none")]
2509    pub routing_latency_ms: Option<f64>,
2510    /// Identifier of the local policy rule that matched.
2511    #[serde(skip_serializing_if = "Option::is_none")]
2512    pub rule_id: Option<String>,
2513    /// Zero-based index of the local policy rule that matched.
2514    #[serde(skip_serializing_if = "Option::is_none")]
2515    pub rule_index: Option<i64>,
2516    /// Human-readable name of the local policy rule that matched.
2517    #[serde(skip_serializing_if = "Option::is_none")]
2518    pub rule_name: Option<String>,
2519    /// Validated capability scores used to select the route.
2520    #[serde(skip_serializing_if = "Option::is_none")]
2521    pub scores: Option<FusionScores>,
2522    /// Concrete model selected for the review or judge phase, when required.
2523    pub secondary_model: Option<String>,
2524    /// Synthetic HydraFusion model selected for the session.
2525    pub synthetic_model: String,
2526    /// Identifier of the session turn associated with the route.
2527    pub turn_id: String,
2528}
2529
2530/// Session event "session.fusion_completed". Experimental durable aggregate outcome of a HydraFusion turn.
2531///
2532/// <div class="warning">
2533///
2534/// **Experimental.** This type is part of an experimental wire-protocol surface
2535/// and may change or be removed in future SDK or CLI releases.
2536///
2537/// </div>
2538#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2539#[serde(rename_all = "camelCase")]
2540pub struct SessionFusionCompletedData {
2541    /// Total cached input tokens reported across all phases.
2542    pub cached_tokens: i64,
2543    /// Total tokens written to prompt cache across all phases.
2544    #[serde(skip_serializing_if = "Option::is_none")]
2545    pub cache_write_tokens: Option<i64>,
2546    /// Idempotency identifier for the authoritative final commit.
2547    pub commit_id: String,
2548    /// Reason the turn used a degraded route, when applicable.
2549    pub degraded_reason: Option<String>,
2550    /// Total elapsed execution time for the HydraFusion turn in milliseconds.
2551    pub duration_ms: f64,
2552    /// Concrete model that supplied the authoritative final content.
2553    pub final_source_model: Option<String>,
2554    /// Phase whose output supplied the authoritative final content.
2555    pub final_source_phase_id: Option<String>,
2556    /// Concrete model recommended for eligible follow-up turns.
2557    pub follow_up_model: String,
2558    /// Stable identifier for the completed HydraFusion turn.
2559    pub fusion_id: String,
2560    /// Total input tokens consumed across all phases.
2561    pub input_tokens: i64,
2562    /// Stable aggregate outcome of the HydraFusion turn.
2563    pub outcome: String,
2564    /// Total output tokens produced across all phases.
2565    pub output_tokens: i64,
2566    /// HydraFusion orchestration pattern executed for the turn.
2567    pub pattern: FusionPattern,
2568    /// Number of concrete phases attempted by the turn.
2569    pub phase_count: i64,
2570    /// Total concrete model requests made across all phases.
2571    pub request_count: i64,
2572    /// Synthetic HydraFusion model selected for the session.
2573    pub synthetic_model: String,
2574    /// Total normalized AI-unit cost reported across all phases, in nano-AIU.
2575    pub total_nano_aiu: f64,
2576    /// Identifier of the session turn associated with the completion.
2577    pub turn_id: String,
2578}
2579
2580/// Session event "session.permission_recovery". Authoritative snapshot of an Autopilot permission-recovery episode
2581#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2582#[serde(rename_all = "camelCase")]
2583pub struct SessionPermissionRecoveryData {
2584    /// Ordered privacy-safe record of permission attempts and the successful alternative, when any
2585    pub attempts: Vec<PermissionRecoveryAttempt>,
2586    /// Stable identifier shared by every transition in this recovery episode
2587    pub episode_id: String,
2588    /// Maximum number of distinct autonomous permission attempts allowed before escalation
2589    pub max_attempts: i64,
2590    /// Policy selected from the current client's response capability; mode or client changes may update it during recovery
2591    pub on_blocked: PermissionRecoveryOnBlocked,
2592    /// Controlled reason for the latest episode transition
2593    pub reason: PermissionRecoveryReason,
2594    /// Current lifecycle state of the recovery episode
2595    pub status: PermissionRecoveryStatus,
2596}
2597
2598/// Session event "user.message". Payload of `user.message` with displayed and model-transformed content, attachments, source/delivery metadata, mode, and telemetry IDs.
2599#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2600#[serde(rename_all = "camelCase")]
2601pub struct UserMessageData {
2602    /// The agent mode that was active when this message was sent
2603    #[serde(skip_serializing_if = "Option::is_none")]
2604    pub agent_mode: Option<UserMessageAgentMode>,
2605    /// Files, selections, or GitHub references attached to the message
2606    #[serde(skip_serializing_if = "Option::is_none")]
2607    pub attachments: Option<Vec<serde_json::Value>>,
2608    /// The user's message text as displayed in the timeline
2609    pub content: String,
2610    /// How this message was delivered to the agentic loop relative to loop state (idle-start vs. steering/queued while busy). The timing axis; combine with `source` (origin) for the full picture. Used for telemetry attribution.
2611    #[serde(skip_serializing_if = "Option::is_none")]
2612    pub delivery: Option<UserMessageDelivery>,
2613    /// CAPI interaction ID for correlating this user message with its turn
2614    #[serde(skip_serializing_if = "Option::is_none")]
2615    pub interaction_id: Option<String>,
2616    /// True when this user message was auto-injected by autopilot's continuation loop rather than typed by the user; used to distinguish autopilot-driven turns in telemetry.
2617    #[serde(skip_serializing_if = "Option::is_none")]
2618    pub is_autopilot_continuation: Option<bool>,
2619    /// Stable identity of the logical user message, matching the ID returned by send and retained by pending queue snapshots
2620    #[serde(skip_serializing_if = "Option::is_none")]
2621    pub message_id: Option<String>,
2622    /// Path-backed native document attachments that stayed on the tagged_files path flow because native upload could not read them or would exceed the request size limit
2623    #[serde(skip_serializing_if = "Option::is_none")]
2624    pub native_document_path_fallback_paths: Option<Vec<String>>,
2625    /// Parent agent task ID for background telemetry correlated to this user turn
2626    #[serde(skip_serializing_if = "Option::is_none")]
2627    pub parent_agent_task_id: Option<String>,
2628    /// Provider reasoning settings anchored before this model-facing message for cache-stable replay; the historical responsesReasoning name is retained for compatibility
2629    #[serde(skip_serializing_if = "Option::is_none")]
2630    pub responses_reasoning: Option<ResponsesReasoning>,
2631    /// Origin of this message, used for timeline filtering and attribution (e.g., `skill-pdf` for hidden skill injection or `agent-<agent-id>` for an inter-agent prompt)
2632    #[serde(skip_serializing_if = "Option::is_none")]
2633    pub source: Option<String>,
2634    /// Normalized document MIME types that were sent natively instead of through tagged_files XML
2635    #[serde(skip_serializing_if = "Option::is_none")]
2636    pub supported_native_document_mime_types: Option<Vec<String>>,
2637    /// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching
2638    #[serde(skip_serializing_if = "Option::is_none")]
2639    pub transformed_content: Option<String>,
2640    /// The agent-loop turn ID that consumed this message; absent when no agent-loop turn consumed it
2641    #[serde(skip_serializing_if = "Option::is_none")]
2642    pub turn_id: Option<String>,
2643}
2644
2645/// Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
2646#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2647#[serde(rename_all = "camelCase")]
2648pub struct PendingMessagesModifiedData {}
2649
2650/// Session event "assistant.turn_start". Turn initialization metadata including identifier and interaction tracking
2651#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2652#[serde(rename_all = "camelCase")]
2653pub struct AssistantTurnStartData {
2654    /// CAPI interaction ID for correlating this turn with upstream telemetry
2655    #[serde(skip_serializing_if = "Option::is_none")]
2656    pub interaction_id: Option<String>,
2657    /// Model identifier used for this turn, when known
2658    #[serde(skip_serializing_if = "Option::is_none")]
2659    pub model: Option<String>,
2660    /// Identifier for this turn within the agentic loop, typically a stringified turn number
2661    pub turn_id: String,
2662}
2663
2664/// Session event "assistant.turn_retry". Metadata for an additional model inference attempt within an existing assistant turn
2665#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2666#[serde(rename_all = "camelCase")]
2667pub struct AssistantTurnRetryData {
2668    /// Model identifier used for this retry, when known
2669    #[serde(skip_serializing_if = "Option::is_none")]
2670    pub model: Option<String>,
2671    /// Provider or runtime classification that caused the retry, when known
2672    #[serde(skip_serializing_if = "Option::is_none")]
2673    pub reason: Option<String>,
2674    /// Identifier of the turn whose model inference is being retried
2675    pub turn_id: String,
2676}
2677
2678/// Session event "agent.interrupted". Metadata for work the user interrupted while the agent was running
2679#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2680#[serde(rename_all = "camelCase")]
2681pub struct AgentInterruptedData {
2682    /// What the agent was doing when the user interrupted it
2683    pub activity: AgentInterruptedActivity,
2684    /// For an interrupted model call: the provider endpoint the request targeted
2685    #[serde(skip_serializing_if = "Option::is_none")]
2686    pub api_endpoint: Option<String>,
2687    /// For an interrupted model call: whether the user interrupted before any token arrived or while the response was streaming
2688    #[serde(skip_serializing_if = "Option::is_none")]
2689    pub cancel_phase: Option<AgentInterruptedCancelPhase>,
2690    /// How long the interrupted work had been running, in milliseconds
2691    pub elapsed_ms: f64,
2692    /// For an interrupted background-agent batch: how many background sub-agents the stop swept. Counts accepted cancellations, so an agent cancelled as a cascade of its interrupted parent is covered by that parent rather than counted again.
2693    #[serde(skip_serializing_if = "Option::is_none")]
2694    pub interrupted_agent_count: Option<i64>,
2695    /// For an interrupted model call: the model the request targeted
2696    #[serde(skip_serializing_if = "Option::is_none")]
2697    pub model: Option<String>,
2698    /// For a mid-stream interrupt: the observed time to first observable output, in milliseconds. Deliberately distinct from the `ttftMs` reported on a successful model call, which measures time to first stream event.
2699    #[serde(skip_serializing_if = "Option::is_none")]
2700    pub output_ttft_ms: Option<f64>,
2701    /// For an interrupted model call: the reasoning effort the request asked for
2702    #[serde(skip_serializing_if = "Option::is_none")]
2703    pub reasoning_effort: Option<String>,
2704    /// Subset of `toolNames` whose tool metadata marks the tool name as safe to record unhashed in telemetry.
2705    #[serde(skip_serializing_if = "Option::is_none")]
2706    pub safe_tool_names: Option<Vec<String>>,
2707    /// Tool call identifiers that were still running
2708    #[serde(skip_serializing_if = "Option::is_none")]
2709    pub tool_call_ids: Option<Vec<String>>,
2710    /// Names of the tools that were still running. More than one when the model requested a parallel fan-out.
2711    #[serde(skip_serializing_if = "Option::is_none")]
2712    pub tool_names: Option<Vec<String>>,
2713    /// For an interrupted model call: the transport the request used
2714    #[serde(skip_serializing_if = "Option::is_none")]
2715    pub transport: Option<ModelCallFailureTransport>,
2716    /// Zero-based agentic-loop iteration the interrupt landed in
2717    pub turn: i64,
2718}
2719
2720/// Session event "assistant.intent". Agent intent description for current activity or plan
2721#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2722#[serde(rename_all = "camelCase")]
2723pub struct AssistantIntentData {
2724    /// Short description of what the agent is currently doing or planning to do
2725    pub intent: String,
2726}
2727
2728/// Session event "assistant.fusion_phase_started". Experimental transient HydraFusion phase/model/role signal.
2729///
2730/// <div class="warning">
2731///
2732/// **Experimental.** This type is part of an experimental wire-protocol surface
2733/// and may change or be removed in future SDK or CLI releases.
2734///
2735/// </div>
2736#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2737#[serde(rename_all = "camelCase")]
2738pub struct AssistantFusionPhaseStartedData {
2739    /// Conversation scope in which the phase executes.
2740    pub conversation_scope: FusionConversationScope,
2741    /// Identifier of the HydraFusion turn containing the phase.
2742    pub fusion_id: String,
2743    /// Concrete model executing the phase.
2744    pub model: String,
2745    /// HydraFusion orchestration pattern containing the phase.
2746    pub pattern: FusionPattern,
2747    /// Stable identifier for the concrete phase.
2748    pub phase_id: String,
2749    /// Kind of phase being executed.
2750    pub phase_kind: FusionPhaseKind,
2751    /// Semantic role assigned to the phase.
2752    pub role: String,
2753}
2754
2755/// Session event "assistant.fusion_phase_activity". Experimental content-safe activity signal for a running HydraFusion phase.
2756///
2757/// <div class="warning">
2758///
2759/// **Experimental.** This type is part of an experimental wire-protocol surface
2760/// and may change or be removed in future SDK or CLI releases.
2761///
2762/// </div>
2763#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2764#[serde(rename_all = "camelCase")]
2765pub struct AssistantFusionPhaseActivityData {
2766    /// Kind of real activity observed.
2767    pub activity: FusionPhaseActivityKind,
2768    /// Conversation scope in which the phase executes.
2769    pub conversation_scope: FusionConversationScope,
2770    /// Identifier of the HydraFusion turn containing the phase.
2771    pub fusion_id: String,
2772    /// HydraFusion orchestration pattern containing the phase.
2773    pub pattern: FusionPattern,
2774    /// Stable identifier for the concrete phase.
2775    pub phase_id: String,
2776    /// Kind of phase currently executing.
2777    pub phase_kind: FusionPhaseKind,
2778    /// Semantic role assigned to the phase.
2779    pub role: String,
2780    /// Opaque hashed correlation token for matching tool-started and tool-completed activity within this Fusion activity stream. It is not the tool call identifier exposed by tool lifecycle events.
2781    #[serde(skip_serializing_if = "Option::is_none")]
2782    pub tool_call_id: Option<String>,
2783    /// Cumulative private response bytes observed for this model call. The event never includes response text.
2784    #[serde(skip_serializing_if = "Option::is_none")]
2785    pub total_response_size_bytes: Option<i64>,
2786}
2787
2788/// Internal durable terminal request staged by a HydraFusion phase until an idempotent final commit selects it.
2789///
2790/// <div class="warning">
2791///
2792/// **Experimental.** This type is part of an experimental wire-protocol surface
2793/// and may change or be removed in future SDK or CLI releases.
2794///
2795/// </div>
2796#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2797#[serde(rename_all = "camelCase")]
2798pub(crate) struct FusionStagedTerminal {
2799    pub arguments: String,
2800    pub assistant_message: serde_json::Value,
2801    pub phase_id: String,
2802    pub tool_call_id: String,
2803    pub tool_name: String,
2804}
2805
2806/// Aggregate concrete-model usage for one HydraFusion phase.
2807///
2808/// <div class="warning">
2809///
2810/// **Experimental.** This type is part of an experimental wire-protocol surface
2811/// and may change or be removed in future SDK or CLI releases.
2812///
2813/// </div>
2814#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2815#[serde(rename_all = "camelCase")]
2816pub struct FusionPhaseUsage {
2817    /// Total cached input tokens reported for the phase.
2818    pub cached_tokens: i64,
2819    /// Total tokens written to prompt cache during the phase.
2820    #[serde(skip_serializing_if = "Option::is_none")]
2821    pub cache_write_tokens: Option<i64>,
2822    /// Total input tokens consumed by the phase.
2823    pub input_tokens: i64,
2824    /// Total output tokens produced by the phase.
2825    pub output_tokens: i64,
2826    /// Number of concrete model requests made by the phase.
2827    pub request_count: i64,
2828    /// Total normalized AI-unit cost reported for the phase, in nano-AIU.
2829    pub total_nano_aiu: f64,
2830}
2831
2832/// Session event "assistant.fusion_phase_completed". Experimental durable HydraFusion phase output and lossless replay checkpoint.
2833///
2834/// <div class="warning">
2835///
2836/// **Experimental.** This type is part of an experimental wire-protocol surface
2837/// and may change or be removed in future SDK or CLI releases.
2838///
2839/// </div>
2840#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2841#[serde(rename_all = "camelCase")]
2842pub struct AssistantFusionPhaseCompletedData {
2843    /// Provider-normalized textual output produced by the phase.
2844    pub content: String,
2845    /// Conversation scope in which the phase executed.
2846    pub conversation_scope: FusionConversationScope,
2847    /// Elapsed execution time for the phase in milliseconds.
2848    pub duration_ms: f64,
2849    /// Identifier of the HydraFusion turn containing the phase.
2850    pub fusion_id: String,
2851    /// Concrete model that executed the phase.
2852    pub model: String,
2853    /// Stable identifier for the completed phase.
2854    pub phase_id: String,
2855    /// Kind of phase that completed.
2856    pub phase_kind: FusionPhaseKind,
2857    /// Exact provider-normalized message used to reconstruct canonical model history.
2858    #[doc(hidden)]
2859    #[serde(skip_serializing_if = "Option::is_none")]
2860    pub(crate) projection_message: Option<serde_json::Value>,
2861    /// Projection action for the exact internal message.
2862    #[doc(hidden)]
2863    #[serde(skip_serializing_if = "Option::is_none")]
2864    pub(crate) projection_mode: Option<FusionProjectionMode>,
2865    /// Semantic role assigned to the completed phase.
2866    pub role: String,
2867    /// Terminal request held outside canonical state until selected by the final commit.
2868    #[doc(hidden)]
2869    #[serde(skip_serializing_if = "Option::is_none")]
2870    pub(crate) staged_terminal: Option<FusionStagedTerminal>,
2871    /// Durable outcome status of the phase.
2872    pub status: FusionPhaseStatus,
2873    /// Aggregate concrete-model usage consumed by the phase.
2874    pub usage: FusionPhaseUsage,
2875    /// Structured judge or critic verdict, when the phase produces one.
2876    pub verdict: Option<String>,
2877}
2878
2879/// Session event "assistant.fusion_phase_failed". Experimental durable typed HydraFusion phase failure and degradation transition.
2880///
2881/// <div class="warning">
2882///
2883/// **Experimental.** This type is part of an experimental wire-protocol surface
2884/// and may change or be removed in future SDK or CLI releases.
2885///
2886/// </div>
2887#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2888#[serde(rename_all = "camelCase")]
2889pub struct AssistantFusionPhaseFailedData {
2890    /// Conversation scope in which the phase executed.
2891    pub conversation_scope: FusionConversationScope,
2892    /// Identifier of the fallback phase used to continue the turn after degradation.
2893    #[serde(skip_serializing_if = "Option::is_none")]
2894    pub degraded_to_phase_id: Option<String>,
2895    /// Elapsed execution time before the phase failed, in milliseconds.
2896    pub duration_ms: f64,
2897    /// Provider or execution error detail, when available.
2898    #[serde(skip_serializing_if = "Option::is_none")]
2899    pub error_message: Option<String>,
2900    /// Identifier of the HydraFusion turn containing the phase.
2901    pub fusion_id: String,
2902    /// Concrete model that attempted the phase.
2903    pub model: String,
2904    /// Stable identifier for the failed phase.
2905    pub phase_id: String,
2906    /// Kind of phase that failed.
2907    pub phase_kind: FusionPhaseKind,
2908    /// Stable machine-readable reason for the phase failure.
2909    pub reason: String,
2910    /// Semantic role assigned to the failed phase.
2911    pub role: String,
2912    /// Durable outcome status of the phase.
2913    pub status: FusionPhaseStatus,
2914    /// Aggregate concrete-model usage consumed before the failure.
2915    pub usage: FusionPhaseUsage,
2916}
2917
2918/// Session event "assistant.server_tool_progress". Live progress signal for a provider-hosted server tool (e.g. hosted web search) while it runs, before the finalized serverTools envelope lands on the terminal assistant.message
2919#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2920#[serde(rename_all = "camelCase")]
2921pub struct AssistantServerToolProgressData {
2922    /// Kind of hosted server tool that is running. Only `web_search` is emitted today.
2923    pub kind: String,
2924    /// Position of the hosted tool call in the response output. Stable across the call's lifecycle events (unlike the provider's per-event item id, which CAPI rotates), so the host keys the live in-progress row on it.
2925    pub output_index: i64,
2926    /// Lifecycle status of the hosted call: `in_progress`, `searching`, or `completed`.
2927    pub status: String,
2928}
2929
2930/// Session event "assistant.reasoning". Assistant reasoning content for timeline display with complete thinking text
2931#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2932#[serde(rename_all = "camelCase")]
2933pub struct AssistantReasoningData {
2934    /// The complete extended thinking text from the model
2935    pub content: String,
2936    /// Unique identifier for this reasoning block
2937    pub reasoning_id: String,
2938    /// Per-request treatment/eligibility signal returned by the Copilot API in the `X-GitHub-Copilot-Request-TE` response header for the associated model call; `false` when the header was absent or unparseable.
2939    #[serde(skip_serializing_if = "Option::is_none")]
2940    pub rte: Option<bool>,
2941}
2942
2943/// Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
2944#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2945#[serde(rename_all = "camelCase")]
2946pub struct AssistantReasoningDeltaData {
2947    /// Incremental text chunk to append to the reasoning content
2948    pub delta_content: String,
2949    /// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event
2950    pub reasoning_id: String,
2951}
2952
2953/// Session event "assistant.tool_call_delta". Streaming tool-call input delta for incremental tool-call updates
2954#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2955#[serde(rename_all = "camelCase")]
2956pub struct AssistantToolCallDeltaData {
2957    /// Raw provider tool input fragment to append for this tool call. Function/tool-use providers stream serialized JSON argument text (so newlines inside JSON string values may appear as escaped `\n` until the accumulated JSON is parsed); custom tool calls stream raw custom input.
2958    pub input_delta: String,
2959    /// Tool call ID this delta belongs to, matching the corresponding assistant.message tool request
2960    pub tool_call_id: String,
2961    /// Name of the tool being invoked, when known from the stream
2962    #[serde(skip_serializing_if = "Option::is_none")]
2963    pub tool_name: Option<String>,
2964    /// Tool call type, when known from the stream
2965    #[serde(skip_serializing_if = "Option::is_none")]
2966    pub tool_type: Option<AssistantMessageToolRequestType>,
2967}
2968
2969/// Session event "assistant.streaming_delta". Streaming response progress with cumulative byte count
2970#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2971#[serde(rename_all = "camelCase")]
2972pub struct AssistantStreamingDeltaData {
2973    /// Cumulative total bytes received from the streaming response so far
2974    pub total_response_size_bytes: i64,
2975}
2976
2977/// A source that backs one or more cited spans in the assistant's response.
2978///
2979/// <div class="warning">
2980///
2981/// **Experimental.** This type is part of an experimental wire-protocol surface
2982/// and may change or be removed in future SDK or CLI releases.
2983///
2984/// </div>
2985#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2986#[serde(rename_all = "camelCase")]
2987pub struct CitationSource {
2988    /// Stable, turn-scoped identifier for this source, referenced by CitationReference.sourceId.
2989    pub id: String,
2990    /// File path relative to the agent's workspace root, when the source is a file.
2991    #[serde(skip_serializing_if = "Option::is_none")]
2992    pub path: Option<String>,
2993    /// The system that produced this citation.
2994    pub provider: CitationProvider,
2995    /// Human-readable title of the source.
2996    #[serde(skip_serializing_if = "Option::is_none")]
2997    pub title: Option<String>,
2998    /// URL of the source, when it is a web resource.
2999    #[serde(skip_serializing_if = "Option::is_none")]
3000    pub url: Option<String>,
3001}
3002
3003/// A single citation occurrence linking a span of generated text to a supporting source.
3004///
3005/// <div class="warning">
3006///
3007/// **Experimental.** This type is part of an experimental wire-protocol surface
3008/// and may change or be removed in future SDK or CLI releases.
3009///
3010/// </div>
3011#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3012#[serde(rename_all = "camelCase")]
3013pub struct CitationReference {
3014    /// The exact text from the source that supports the cited span, when provided by the model.
3015    #[serde(skip_serializing_if = "Option::is_none")]
3016    pub cited_text: Option<String>,
3017    /// Location within the source that supports the cited span, when the provider reports one.
3018    #[serde(skip_serializing_if = "Option::is_none")]
3019    pub location: Option<serde_json::Value>,
3020    /// Provider-native citation correlation data (e.g. Anthropic search_result_index / document_index), passed through opaquely for debugging and forward compatibility.
3021    #[serde(skip_serializing_if = "Option::is_none")]
3022    pub provider_metadata: Option<serde_json::Value>,
3023    /// Identifier of the CitationSource this reference points to (CitationSource.id).
3024    pub source_id: String,
3025}
3026
3027/// A contiguous span of generated assistant text and the source references that support it.
3028///
3029/// <div class="warning">
3030///
3031/// **Experimental.** This type is part of an experimental wire-protocol surface
3032/// and may change or be removed in future SDK or CLI releases.
3033///
3034/// </div>
3035#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3036#[serde(rename_all = "camelCase")]
3037pub struct CitationSpan {
3038    /// End offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, exclusive).
3039    pub end_index: i64,
3040    /// The sources that support this span of generated text.
3041    pub references: Vec<CitationReference>,
3042    /// Start offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, inclusive).
3043    pub start_index: i64,
3044}
3045
3046/// Provider-agnostic citations linking spans of the assistant's response to their supporting sources.
3047///
3048/// <div class="warning">
3049///
3050/// **Experimental.** This type is part of an experimental wire-protocol surface
3051/// and may change or be removed in future SDK or CLI releases.
3052///
3053/// </div>
3054#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3055#[serde(rename_all = "camelCase")]
3056pub struct Citations {
3057    /// Deduplicated set of sources referenced by the citation spans.
3058    pub sources: Vec<CitationSource>,
3059    /// Spans of generated text annotated with the sources that support them.
3060    pub spans: Vec<CitationSpan>,
3061}
3062
3063/// Experimental attribution linking an ordinary event to the HydraFusion turn, phase, and concrete source that produced it.
3064///
3065/// <div class="warning">
3066///
3067/// **Experimental.** This type is part of an experimental wire-protocol surface
3068/// and may change or be removed in future SDK or CLI releases.
3069///
3070/// </div>
3071#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3072#[serde(rename_all = "camelCase")]
3073pub struct FusionAttribution {
3074    /// Idempotency identifier for the authoritative commit, when the event belongs to the selected output.
3075    #[serde(skip_serializing_if = "Option::is_none")]
3076    pub commit_id: Option<String>,
3077    /// Conversation scope in which the concrete phase executed.
3078    #[serde(skip_serializing_if = "Option::is_none")]
3079    pub conversation_scope: Option<String>,
3080    /// Stable identifier for the HydraFusion turn that produced the event.
3081    pub fusion_id: String,
3082    /// Whether this model request consumed a user steering message rather than only internal Fusion work.
3083    #[serde(skip_serializing_if = "Option::is_none")]
3084    pub has_user_steering: Option<bool>,
3085    /// HydraFusion orchestration pattern selected for the turn.
3086    pub pattern: String,
3087    /// Identifier of the concrete phase that produced the event.
3088    #[serde(skip_serializing_if = "Option::is_none")]
3089    pub phase_id: Option<String>,
3090    /// Kind of concrete phase that produced the event.
3091    #[serde(skip_serializing_if = "Option::is_none")]
3092    pub phase_kind: Option<String>,
3093    /// HydraFusion routing policy used for the turn.
3094    pub policy: String,
3095    /// Semantic role assigned to the concrete phase.
3096    #[serde(skip_serializing_if = "Option::is_none")]
3097    pub role: Option<String>,
3098    /// Concrete model that produced the attributed event.
3099    #[serde(skip_serializing_if = "Option::is_none")]
3100    pub source_model: Option<String>,
3101    /// Phase whose output supplied the authoritative content, when different from the executing phase.
3102    #[serde(skip_serializing_if = "Option::is_none")]
3103    pub source_phase_id: Option<String>,
3104    /// Synthetic HydraFusion model selected for the session.
3105    pub synthetic_model: String,
3106}
3107
3108/// Neutral provider-tagged reasoning content blocks preserved verbatim for round-tripping
3109///
3110/// <div class="warning">
3111///
3112/// **Experimental.** This type is part of an experimental wire-protocol surface
3113/// and may change or be removed in future SDK or CLI releases.
3114///
3115/// </div>
3116#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3117#[serde(rename_all = "camelCase")]
3118pub struct AssistantMessageReasoningBlocks {
3119    /// Provider-native reasoning items or content blocks preserved verbatim, in order. A single response can carry several, and provider signatures or identifiers may depend on their exact content and ordering.
3120    #[serde(skip_serializing_if = "Option::is_none")]
3121    pub blocks: Option<Vec<serde_json::Value>>,
3122    /// Model provider that produced these reasoning blocks.
3123    pub provider: String,
3124}
3125
3126/// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
3127///
3128/// <div class="warning">
3129///
3130/// **Experimental.** This type is part of an experimental wire-protocol surface
3131/// and may change or be removed in future SDK or CLI releases.
3132///
3133/// </div>
3134#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3135#[serde(rename_all = "camelCase")]
3136pub struct AssistantMessageServerTools {
3137    /// Advisor model identifier associated with the server-tool payload.
3138    #[serde(skip_serializing_if = "Option::is_none")]
3139    pub advisor_model: Option<String>,
3140    /// Provider function-call namespaces keyed by function-call identifier.
3141    #[serde(skip_serializing_if = "Option::is_none")]
3142    pub function_call_namespaces: Option<HashMap<String, String>>,
3143    /// Provider-native server-tool call and output items preserved verbatim for replay.
3144    #[serde(skip_serializing_if = "Option::is_none")]
3145    pub items: Option<Vec<serde_json::Value>>,
3146    /// Model provider that produced this server-tool payload.
3147    pub provider: String,
3148    /// Raw provider content blocks retained for verbatim round-tripping.
3149    #[serde(skip_serializing_if = "Option::is_none")]
3150    pub raw_content_blocks: Option<Vec<serde_json::Value>>,
3151}
3152
3153/// Hosted program that requested this client tool call
3154#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3155#[serde(rename_all = "camelCase")]
3156pub struct AssistantMessageToolRequestCaller {
3157    /// Provider-assigned identifier for the hosted caller.
3158    pub caller_id: String,
3159    /// Kind of hosted caller that requested the client tool call.
3160    pub r#type: AssistantMessageToolRequestCallerType,
3161}
3162
3163/// A tool invocation request from the assistant
3164#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3165#[serde(rename_all = "camelCase")]
3166pub struct AssistantMessageToolRequest {
3167    /// Arguments to pass to the tool, format depends on the tool
3168    #[serde(skip_serializing_if = "Option::is_none")]
3169    pub arguments: Option<serde_json::Value>,
3170    /// Hosted program that requested this client tool call
3171    #[serde(skip_serializing_if = "Option::is_none")]
3172    pub caller: Option<AssistantMessageToolRequestCaller>,
3173    /// Resolved intention summary describing what this specific call does
3174    #[serde(skip_serializing_if = "Option::is_none")]
3175    pub intention_summary: Option<String>,
3176    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
3177    #[serde(skip_serializing_if = "Option::is_none")]
3178    pub mcp_server_name: Option<String>,
3179    /// Original tool name on the MCP server, when the tool is an MCP tool
3180    #[serde(skip_serializing_if = "Option::is_none")]
3181    pub mcp_tool_name: Option<String>,
3182    /// Name of the tool being invoked
3183    pub name: String,
3184    /// Unique identifier for this tool call
3185    pub tool_call_id: String,
3186    /// Human-readable display title for the tool
3187    #[serde(skip_serializing_if = "Option::is_none")]
3188    pub tool_title: Option<String>,
3189    /// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
3190    #[serde(skip_serializing_if = "Option::is_none")]
3191    pub r#type: Option<AssistantMessageToolRequestType>,
3192}
3193
3194/// Session event "assistant.message". Assistant response containing text content, optional tool requests, and interaction metadata
3195#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3196#[serde(rename_all = "camelCase")]
3197pub struct AssistantMessageData {
3198    /// Provider's completion / response identifier; shared across all chunks of a single API call. Used to group multi-chunk assistant utterances.
3199    #[serde(skip_serializing_if = "Option::is_none")]
3200    pub api_call_id: Option<String>,
3201    /// Total messages the model call's response was split into, one per reasoning boundary. Absent for a single-message response; the last chunk is the one where chunkIndex is chunkCount - 1.
3202    #[serde(skip_serializing_if = "Option::is_none")]
3203    pub chunk_count: Option<i64>,
3204    /// Zero-based position of this message within its model call's response. Absent when the response was not split into chunks.
3205    #[serde(skip_serializing_if = "Option::is_none")]
3206    pub chunk_index: Option<i64>,
3207    /// Provider-agnostic citations linking spans of this message's content to the sources that support them. Experimental; only populated when citation emission is enabled.
3208    ///
3209    /// <div class="warning">
3210    ///
3211    /// **Experimental.** This type is part of an experimental wire-protocol surface
3212    /// and may change or be removed in future SDK or CLI releases.
3213    ///
3214    /// </div>
3215    #[serde(skip_serializing_if = "Option::is_none")]
3216    pub citations: Option<Citations>,
3217    /// Client-minted request id (x-request-id header) echoed by the server. Distinct from requestId (x-github-request-id) and serviceRequestId (x-copilot-service-request-id).
3218    #[serde(skip_serializing_if = "Option::is_none")]
3219    pub client_request_id: Option<String>,
3220    /// The assistant's text response content
3221    pub content: String,
3222    /// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
3223    #[serde(skip_serializing_if = "Option::is_none")]
3224    pub encrypted_content: Option<String>,
3225    /// Experimental HydraFusion source attribution for this ordinary authoritative assistant message.
3226    ///
3227    /// <div class="warning">
3228    ///
3229    /// **Experimental.** This type is part of an experimental wire-protocol surface
3230    /// and may change or be removed in future SDK or CLI releases.
3231    ///
3232    /// </div>
3233    #[serde(skip_serializing_if = "Option::is_none")]
3234    pub fusion: Option<FusionAttribution>,
3235    /// CAPI interaction ID for correlating this message with upstream telemetry
3236    #[serde(skip_serializing_if = "Option::is_none")]
3237    pub interaction_id: Option<String>,
3238    /// Unique identifier for this assistant message
3239    pub message_id: String,
3240    /// Model that produced this assistant message, if known
3241    #[serde(skip_serializing_if = "Option::is_none")]
3242    pub model: Option<String>,
3243    /// Logical ID of the primary user message that initiated this run, matching the messageId returned by session.send (or the last messageId of session.sendMessages). Stable across model/tool iterations, steering messages, and stop-hook corrections. Subagent runs use their own initiating message ID, not the parent's. Absent for runs without an associated initiating message, such as empty batches.
3244    #[serde(skip_serializing_if = "Option::is_none")]
3245    pub originating_message_id: Option<String>,
3246    /// Actual output token count from the API response (completion_tokens), used for accurate token accounting
3247    #[serde(skip_serializing_if = "Option::is_none")]
3248    pub output_tokens: Option<i64>,
3249    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3250    #[doc(hidden)]
3251    #[deprecated]
3252    #[serde(skip_serializing_if = "Option::is_none")]
3253    pub parent_tool_call_id: Option<String>,
3254    /// Generation phase for phased-output models (e.g., thinking vs. response phases)
3255    #[serde(skip_serializing_if = "Option::is_none")]
3256    pub phase: Option<String>,
3257    /// Neutral provider-tagged reasoning content blocks preserved verbatim for round-tripping. `reasoningText` and `reasoningOpaque` are a lossy derived view of these blocks, retained for display.
3258    #[serde(skip_serializing_if = "Option::is_none")]
3259    pub reasoning_blocks: Option<AssistantMessageReasoningBlocks>,
3260    /// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
3261    #[serde(skip_serializing_if = "Option::is_none")]
3262    pub reasoning_opaque: Option<String>,
3263    /// Readable reasoning text from the model's extended thinking
3264    #[serde(skip_serializing_if = "Option::is_none")]
3265    pub reasoning_text: Option<String>,
3266    /// OpenAI-compatible wire field the provider used for reasoning (e.g. reasoning_content/reasoning). Populated only when non-canonical, so the dialect round-trips across turns.
3267    #[serde(skip_serializing_if = "Option::is_none")]
3268    pub reasoning_wire_field: Option<String>,
3269    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
3270    #[serde(skip_serializing_if = "Option::is_none")]
3271    pub request_id: Option<RequestId>,
3272    /// Per-request treatment/eligibility signal returned by the Copilot API in the `X-GitHub-Copilot-Request-TE` response header for the associated model call; `false` when the header was absent or unparseable.
3273    #[serde(skip_serializing_if = "Option::is_none")]
3274    pub rte: Option<bool>,
3275    /// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
3276    #[serde(skip_serializing_if = "Option::is_none")]
3277    pub server_tools: Option<AssistantMessageServerTools>,
3278    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3279    #[serde(skip_serializing_if = "Option::is_none")]
3280    pub service_request_id: Option<String>,
3281    /// Tool invocations requested by the assistant in this message
3282    #[serde(skip_serializing_if = "Option::is_none")]
3283    pub tool_requests: Option<Vec<AssistantMessageToolRequest>>,
3284    /// Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
3285    #[serde(skip_serializing_if = "Option::is_none")]
3286    pub turn_id: Option<String>,
3287}
3288
3289/// Session event "assistant.message_start". Streaming assistant message start metadata
3290#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3291#[serde(rename_all = "camelCase")]
3292pub struct AssistantMessageStartData {
3293    /// Message ID this start event belongs to, matching subsequent deltas and assistant.message
3294    pub message_id: String,
3295    /// Generation phase this message belongs to for phased-output models
3296    #[serde(skip_serializing_if = "Option::is_none")]
3297    pub phase: Option<String>,
3298}
3299
3300/// Session event "assistant.message_delta". Streaming assistant message delta for incremental response updates
3301#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3302#[serde(rename_all = "camelCase")]
3303pub struct AssistantMessageDeltaData {
3304    /// Incremental text chunk to append to the message content
3305    pub delta_content: String,
3306    /// Message ID this delta belongs to, matching the corresponding assistant.message event
3307    pub message_id: String,
3308    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3309    #[doc(hidden)]
3310    #[deprecated]
3311    #[serde(skip_serializing_if = "Option::is_none")]
3312    pub parent_tool_call_id: Option<String>,
3313}
3314
3315/// Session event "assistant.turn_end". Turn completion metadata including the turn identifier
3316#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3317#[serde(rename_all = "camelCase")]
3318pub struct AssistantTurnEndData {
3319    /// Model identifier used for this turn, when known
3320    #[serde(skip_serializing_if = "Option::is_none")]
3321    pub model: Option<String>,
3322    /// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event
3323    pub turn_id: String,
3324}
3325
3326/// Session event "assistant.idle". Payload emitted whenever the main agent's processing loop goes idle, including while related background work (running agents or in-flight attached shell commands) is still pending and the session-level idle event is therefore deferred
3327#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3328#[serde(rename_all = "camelCase")]
3329pub struct AssistantIdleData {
3330    /// True when the preceding agentic loop was cancelled via abort signal
3331    #[serde(skip_serializing_if = "Option::is_none")]
3332    pub aborted: Option<bool>,
3333}
3334
3335/// Token usage detail for a single billing category
3336#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3337#[serde(rename_all = "camelCase")]
3338pub struct AssistantUsageCopilotUsageTokenDetail {
3339    /// Number of tokens in this billing batch
3340    pub batch_size: i64,
3341    /// Cost per batch of tokens
3342    pub cost_per_batch: i64,
3343    /// Model responsible for this billing entry
3344    #[serde(skip_serializing_if = "Option::is_none")]
3345    pub model: Option<String>,
3346    /// Total token count for this entry
3347    pub token_count: i64,
3348    /// Token category (e.g., "input", "output")
3349    pub token_type: String,
3350}
3351
3352/// Per-request cost and usage data from the CAPI copilot_usage response field
3353#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3354#[serde(rename_all = "camelCase")]
3355pub struct AssistantUsageCopilotUsage {
3356    /// Default billing model for token details that do not identify their own model
3357    #[serde(skip_serializing_if = "Option::is_none")]
3358    pub model: Option<String>,
3359    /// Itemized token usage breakdown
3360    #[doc(hidden)]
3361    #[serde(skip_serializing_if = "Option::is_none")]
3362    pub(crate) token_details: Option<Vec<AssistantUsageCopilotUsageTokenDetail>>,
3363    /// Total cost in nano-AI units for this request
3364    pub total_nano_aiu: f64,
3365}
3366
3367/// Internal per-quota snapshot for assistant usage, including entitlement, consumed requests, overage, reset date, and remaining quota.
3368#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3369#[serde(rename_all = "camelCase")]
3370pub(crate) struct AssistantUsageQuotaSnapshot {
3371    /// Total requests allowed by the entitlement
3372    #[doc(hidden)]
3373    pub(crate) entitlement_requests: i64,
3374    /// Whether the user currently has quota available for use
3375    #[doc(hidden)]
3376    #[serde(skip_serializing_if = "Option::is_none")]
3377    pub(crate) has_quota: Option<bool>,
3378    /// Whether the user has an unlimited usage entitlement
3379    #[doc(hidden)]
3380    pub(crate) is_unlimited_entitlement: bool,
3381    /// Number of additional usage requests made this period
3382    #[doc(hidden)]
3383    pub(crate) overage: f64,
3384    /// Whether additional usage is allowed when quota is exhausted
3385    #[doc(hidden)]
3386    pub(crate) overage_allowed_with_exhausted_quota: bool,
3387    /// Pay-as-you-go additional-usage budget cap in AI credits (1 credit = $0.01); present only when CAPI emits a finite value
3388    #[doc(hidden)]
3389    #[serde(skip_serializing_if = "Option::is_none")]
3390    pub(crate) overage_entitlement: Option<f64>,
3391    /// Percentage of quota remaining (0 to 100)
3392    #[doc(hidden)]
3393    pub(crate) remaining_percentage: f64,
3394    /// Date when the quota resets
3395    #[doc(hidden)]
3396    #[serde(skip_serializing_if = "Option::is_none")]
3397    pub(crate) reset_date: Option<String>,
3398    /// Whether this snapshot uses token-based billing (AI-credits allocation)
3399    #[doc(hidden)]
3400    #[serde(skip_serializing_if = "Option::is_none")]
3401    pub(crate) token_based_billing: Option<bool>,
3402    /// Whether usage is still permitted after quota exhaustion
3403    #[doc(hidden)]
3404    pub(crate) usage_allowed_with_exhausted_quota: bool,
3405    /// Number of requests already consumed
3406    #[doc(hidden)]
3407    pub(crate) used_requests: i64,
3408}
3409
3410/// Session event "assistant.usage". LLM API call usage metrics including tokens, costs, quotas, and billing information
3411#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3412#[serde(rename_all = "camelCase")]
3413pub struct AssistantUsageData {
3414    /// Number of accepted speculative prediction tokens
3415    #[serde(skip_serializing_if = "Option::is_none")]
3416    pub accepted_prediction_tokens: Option<i64>,
3417    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
3418    #[serde(skip_serializing_if = "Option::is_none")]
3419    pub api_call_id: Option<String>,
3420    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
3421    #[serde(skip_serializing_if = "Option::is_none")]
3422    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
3423    /// Number of tools available to the model for this call
3424    #[doc(hidden)]
3425    #[serde(skip_serializing_if = "Option::is_none")]
3426    pub(crate) available_tool_count: Option<i64>,
3427    /// Whether the provider reported prompt-cache usage details for this call
3428    #[doc(hidden)]
3429    #[serde(skip_serializing_if = "Option::is_none")]
3430    pub(crate) cache_details_reported: Option<bool>,
3431    /// Updated prompt-cache expiration for this model call. Present only when the call establishes or refreshes known cache state.
3432    #[serde(skip_serializing_if = "Option::is_none")]
3433    pub cache_expires_at: Option<String>,
3434    /// Number of tokens read from prompt cache
3435    #[serde(skip_serializing_if = "Option::is_none")]
3436    pub cache_read_tokens: Option<i64>,
3437    /// Effective prompt-cache lifetime in seconds for this call
3438    #[doc(hidden)]
3439    #[serde(skip_serializing_if = "Option::is_none")]
3440    pub(crate) cache_ttl_seconds: Option<i64>,
3441    /// Number of tokens written to prompt cache
3442    #[serde(skip_serializing_if = "Option::is_none")]
3443    pub cache_write_tokens: Option<i64>,
3444    /// Whether the model response was blocked or truncated by content filtering (finish_reason === 'content_filter'). For Anthropic models this corresponds to a 'refusal' stop reason.
3445    #[serde(skip_serializing_if = "Option::is_none")]
3446    pub content_filter_triggered: Option<bool>,
3447    /// Per-request cost and usage data from the CAPI copilot_usage response field
3448    #[serde(skip_serializing_if = "Option::is_none")]
3449    pub copilot_usage: Option<AssistantUsageCopilotUsage>,
3450    /// Model multiplier cost for billing purposes
3451    ///
3452    /// <div class="warning">
3453    ///
3454    /// **Experimental.** This type is part of an experimental wire-protocol surface
3455    /// and may change or be removed in future SDK or CLI releases.
3456    ///
3457    /// </div>
3458    #[serde(skip_serializing_if = "Option::is_none")]
3459    pub cost: Option<f64>,
3460    /// Duration of the API call in milliseconds
3461    #[serde(skip_serializing_if = "Option::is_none")]
3462    pub duration: Option<i64>,
3463    /// Finish reason reported by the model for this API call (e.g. "stop", "length", "tool_calls", "content_filter"). Normalized to OpenAI vocabulary; for Anthropic models a "refusal" stop reason maps to "content_filter".
3464    #[serde(skip_serializing_if = "Option::is_none")]
3465    pub finish_reason: Option<String>,
3466    /// How the prompt-cache frontier was determined for this call
3467    #[doc(hidden)]
3468    #[serde(skip_serializing_if = "Option::is_none")]
3469    pub(crate) frontier_source: Option<String>,
3470    /// Experimental HydraFusion attribution for this concrete model call's usage.
3471    ///
3472    /// <div class="warning">
3473    ///
3474    /// **Experimental.** This type is part of an experimental wire-protocol surface
3475    /// and may change or be removed in future SDK or CLI releases.
3476    ///
3477    /// </div>
3478    #[serde(skip_serializing_if = "Option::is_none")]
3479    pub fusion: Option<FusionAttribution>,
3480    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
3481    #[serde(skip_serializing_if = "Option::is_none")]
3482    pub initiator: Option<String>,
3483    /// Number of input tokens consumed
3484    #[serde(skip_serializing_if = "Option::is_none")]
3485    pub input_tokens: Option<i64>,
3486    /// Coarse classification of the interaction that produced this call, mirroring the session's per-request agent context (e.g. `conversation-agent`, `conversation-subagent`, `conversation-sampling`, `conversation-background`, `conversation-compaction`, `conversation-user`). Non-billing; lets consumers attribute a model call to a call class (e.g. sub-agent/sidekick) independently of the billing initiator. Absent when the runtime did not classify the request.
3487    #[serde(skip_serializing_if = "Option::is_none")]
3488    pub interaction_type: Option<String>,
3489    /// Average inter-token latency in milliseconds. Only available for streaming requests
3490    #[serde(skip_serializing_if = "Option::is_none")]
3491    pub inter_token_latency_ms: Option<f64>,
3492    /// Whether Auto mode was selected for this model call
3493    #[serde(skip_serializing_if = "Option::is_none")]
3494    pub is_auto: Option<bool>,
3495    /// Whether this model call used a bring-your-own-key provider
3496    #[serde(skip_serializing_if = "Option::is_none")]
3497    pub is_byok: Option<bool>,
3498    /// Requested maximum output tokens used for this model call
3499    #[serde(skip_serializing_if = "Option::is_none")]
3500    pub max_output_tokens: Option<i64>,
3501    /// Effective maximum prompt-token limit used for this model call
3502    #[serde(skip_serializing_if = "Option::is_none")]
3503    pub max_prompt_tokens: Option<i64>,
3504    /// Model identifier used for this API call
3505    pub model: String,
3506    /// Number of tool calls returned by the model
3507    #[doc(hidden)]
3508    #[serde(skip_serializing_if = "Option::is_none")]
3509    pub(crate) num_tool_calls: Option<i64>,
3510    /// Number of output tokens produced
3511    #[serde(skip_serializing_if = "Option::is_none")]
3512    pub output_tokens: Option<i64>,
3513    /// Time to first observable model output in milliseconds. Includes text, reasoning, and tool-call output; only available for streaming requests that produce observable output.
3514    #[serde(skip_serializing_if = "Option::is_none")]
3515    pub output_ttft_ms: Option<f64>,
3516    /// Parent tool call ID when this usage originates from a sub-agent
3517    #[doc(hidden)]
3518    #[deprecated]
3519    #[serde(skip_serializing_if = "Option::is_none")]
3520    pub parent_tool_call_id: Option<String>,
3521    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
3522    #[serde(skip_serializing_if = "Option::is_none")]
3523    pub provider_call_id: Option<String>,
3524    /// Per-quota resource usage snapshots, keyed by quota identifier
3525    #[doc(hidden)]
3526    #[serde(skip_serializing_if = "Option::is_none")]
3527    pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
3528    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
3529    #[serde(skip_serializing_if = "Option::is_none")]
3530    pub reasoning_effort: Option<String>,
3531    /// Reasoning summary mode used for this model call, if applicable
3532    #[serde(skip_serializing_if = "Option::is_none")]
3533    pub reasoning_summary: Option<ReasoningSummary>,
3534    /// Number of output tokens used for reasoning (e.g., chain-of-thought)
3535    #[serde(skip_serializing_if = "Option::is_none")]
3536    pub reasoning_tokens: Option<i64>,
3537    /// Number of rejected speculative prediction tokens
3538    #[serde(skip_serializing_if = "Option::is_none")]
3539    pub rejected_prediction_tokens: Option<i64>,
3540    /// Per-request treatment/eligibility signal returned by the Copilot API in the `X-GitHub-Copilot-Request-TE` response header for the associated model call; `false` when the header was absent or unparseable.
3541    #[serde(skip_serializing_if = "Option::is_none")]
3542    pub rte: Option<bool>,
3543    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3544    #[serde(skip_serializing_if = "Option::is_none")]
3545    pub service_request_id: Option<String>,
3546    /// Number of prior thinking blocks the provider dropped while transforming the request
3547    #[doc(hidden)]
3548    #[serde(skip_serializing_if = "Option::is_none")]
3549    pub(crate) thinking_dropped_blocks: Option<i64>,
3550    /// Recognized provider-reported reasons for dropped thinking blocks, in response order
3551    #[doc(hidden)]
3552    #[serde(skip_serializing_if = "Option::is_none")]
3553    pub(crate) thinking_dropped_reasons: Option<Vec<String>>,
3554    /// Time to first token in milliseconds. Only available for streaming requests
3555    #[serde(skip_serializing_if = "Option::is_none")]
3556    pub time_to_first_token_ms: Option<f64>,
3557    /// Tool-call counts keyed by tool name
3558    #[doc(hidden)]
3559    #[serde(skip_serializing_if = "Option::is_none")]
3560    pub(crate) tool_counts: Option<HashMap<String, i64>>,
3561    /// Number of tokens used by tool definitions for this call
3562    #[doc(hidden)]
3563    #[serde(skip_serializing_if = "Option::is_none")]
3564    pub(crate) tool_token_count: Option<i64>,
3565    /// Transport used for this model call (http or websocket)
3566    #[serde(skip_serializing_if = "Option::is_none")]
3567    pub transport: Option<AssistantUsageTransport>,
3568}
3569
3570/// Session event "prompt_cache_break". A detected loss of a previously cached prompt prefix
3571#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3572#[serde(rename_all = "camelCase")]
3573pub struct PromptCacheBreakData {
3574    /// Request state whose cached prefix fell short
3575    #[doc(hidden)]
3576    #[serde(skip_serializing_if = "Option::is_none")]
3577    pub(crate) after_request: Option<serde_json::Value>,
3578    /// Name of the sub-agent whose conversation broke, stamped by the parent bridge
3579    #[doc(hidden)]
3580    #[serde(skip_serializing_if = "Option::is_none")]
3581    pub(crate) agent_name: Option<String>,
3582    /// Request state that established the prior cache frontier
3583    #[doc(hidden)]
3584    #[serde(skip_serializing_if = "Option::is_none")]
3585    pub(crate) before_request: Option<serde_json::Value>,
3586    /// Names of the cache-configuration fields that changed
3587    #[doc(hidden)]
3588    #[serde(skip_serializing_if = "Option::is_none")]
3589    pub(crate) cache_config_changed_fields: Option<Vec<String>>,
3590    /// All reasons that contributed to the cache break, ordered by precedence
3591    pub contributing_reasons: Vec<String>,
3592    /// Prior cached prompt frontier in tokens
3593    pub frontier_tokens: i64,
3594    /// Model that held the prior cache frontier, when the call changed models
3595    #[doc(hidden)]
3596    #[serde(skip_serializing_if = "Option::is_none")]
3597    pub(crate) model_from: Option<String>,
3598    /// Model this call targeted, when the call changed models
3599    #[doc(hidden)]
3600    #[serde(skip_serializing_if = "Option::is_none")]
3601    pub(crate) model_to: Option<String>,
3602    /// The highest-precedence reason for the cache break
3603    pub primary_reason: String,
3604    /// Fraction of the prior cache frontier that survived
3605    pub retention_ratio: f64,
3606    /// Index of the first conversation message whose content changed
3607    #[doc(hidden)]
3608    #[serde(skip_serializing_if = "Option::is_none")]
3609    pub(crate) rewrite_message_index: Option<i64>,
3610    /// Shape of the history rewrite, for example whether the history grew or shrank
3611    #[doc(hidden)]
3612    #[serde(skip_serializing_if = "Option::is_none")]
3613    pub(crate) rewrite_shape: Option<String>,
3614    /// Subsystems that announced a history rewrite before this call, for example compaction or truncation
3615    #[doc(hidden)]
3616    #[serde(skip_serializing_if = "Option::is_none")]
3617    pub(crate) rewrite_source: Option<Vec<String>>,
3618    /// Cached prefix tokens lost since the prior call
3619    pub shortfall_tokens: i64,
3620    /// Number of cached prefix tokens that survived
3621    pub survived_tokens: i64,
3622    /// Names of the system-prompt segments whose content changed
3623    #[doc(hidden)]
3624    #[serde(skip_serializing_if = "Option::is_none")]
3625    pub(crate) system_segments_changed: Option<Vec<String>>,
3626    /// Telemetry-safe names of tools added since the prior call
3627    #[doc(hidden)]
3628    #[serde(skip_serializing_if = "Option::is_none")]
3629    pub(crate) tools_added: Option<Vec<String>>,
3630    /// Raw names of tools added since the prior call, restricted because a tool name can be user-authored
3631    #[doc(hidden)]
3632    #[serde(skip_serializing_if = "Option::is_none")]
3633    pub(crate) tools_added_raw: Option<Vec<String>>,
3634    /// Telemetry-safe names of tools whose definition changed since the prior call
3635    #[doc(hidden)]
3636    #[serde(skip_serializing_if = "Option::is_none")]
3637    pub(crate) tools_redefined: Option<Vec<String>>,
3638    /// Raw names of tools redefined since the prior call, restricted because a tool name can be user-authored
3639    #[doc(hidden)]
3640    #[serde(skip_serializing_if = "Option::is_none")]
3641    pub(crate) tools_redefined_raw: Option<Vec<String>>,
3642    /// Telemetry-safe names of tools removed since the prior call
3643    #[doc(hidden)]
3644    #[serde(skip_serializing_if = "Option::is_none")]
3645    pub(crate) tools_removed: Option<Vec<String>>,
3646    /// Raw names of tools removed since the prior call, restricted because a tool name can be user-authored
3647    #[doc(hidden)]
3648    #[serde(skip_serializing_if = "Option::is_none")]
3649    pub(crate) tools_removed_raw: Option<Vec<String>>,
3650    /// Whether the tool list kept its members but changed their order
3651    #[doc(hidden)]
3652    #[serde(skip_serializing_if = "Option::is_none")]
3653    pub(crate) tools_reordered: Option<bool>,
3654}
3655
3656/// Content-free structural summary of the failing request for diagnosing malformed 4xx calls
3657#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3658#[serde(rename_all = "camelCase")]
3659pub struct ModelCallFailureRequestFingerprint {
3660    /// Total number of image content parts
3661    pub image_part_count: i64,
3662    /// Image parts whose media type cannot be determined (rejected by strict providers)
3663    pub image_parts_missing_media_type: i64,
3664    /// Role of the final message in the request
3665    #[serde(skip_serializing_if = "Option::is_none")]
3666    pub last_message_role: Option<String>,
3667    /// Total number of messages in the request
3668    pub message_count: i64,
3669    /// Tool calls whose name is missing or empty (rejected by strict providers)
3670    pub nameless_tool_call_count: i64,
3671    /// Total number of tool calls across assistant messages
3672    pub tool_call_count: i64,
3673    /// Number of "tool" result messages in the request
3674    pub tool_result_message_count: i64,
3675}
3676
3677/// Session event "model.call_failure". Failed LLM API call metadata for telemetry
3678#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3679#[serde(rename_all = "camelCase")]
3680pub struct ModelCallFailureData {
3681    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
3682    #[serde(skip_serializing_if = "Option::is_none")]
3683    pub api_call_id: Option<String>,
3684    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
3685    #[serde(skip_serializing_if = "Option::is_none")]
3686    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
3687    /// For HTTP 400 failures only: whether the response carried a structured CAPI error envelope (structured_error, a deterministic validation failure) or no error body (bodyless, the transient gateway/proxy signature). Absent for non-400 failures.
3688    #[serde(skip_serializing_if = "Option::is_none")]
3689    pub bad_request_kind: Option<ModelCallFailureBadRequestKind>,
3690    /// Duration of the failed API call in milliseconds
3691    #[serde(skip_serializing_if = "Option::is_none")]
3692    pub duration_ms: Option<i64>,
3693    /// For HTTP 400 failures only: the `code` from the CAPI error envelope (e.g. 'model_max_prompt_tokens_exceeded') identifying which deterministic validation failure occurred. Raw server-controlled string, emitted only through restricted telemetry. Absent for bodyless or non-400 failures.
3694    #[serde(skip_serializing_if = "Option::is_none")]
3695    pub error_code: Option<String>,
3696    /// Raw provider/runtime error message for restricted telemetry
3697    #[serde(skip_serializing_if = "Option::is_none")]
3698    pub error_message: Option<String>,
3699    /// For HTTP 400 failures only: the `type` from the CAPI error envelope (e.g. 'websocket_error'), a coarser companion to errorCode for envelopes that carry no code. Raw server-controlled string, emitted only through restricted telemetry. Absent for bodyless or non-400 failures.
3700    #[serde(skip_serializing_if = "Option::is_none")]
3701    pub error_type: Option<String>,
3702    /// Whether the failure originated from an API response or the request transport
3703    #[serde(skip_serializing_if = "Option::is_none")]
3704    pub failure_kind: Option<ModelCallFailureKind>,
3705    /// Experimental HydraFusion attribution for this failed concrete model call.
3706    ///
3707    /// <div class="warning">
3708    ///
3709    /// **Experimental.** This type is part of an experimental wire-protocol surface
3710    /// and may change or be removed in future SDK or CLI releases.
3711    ///
3712    /// </div>
3713    #[serde(skip_serializing_if = "Option::is_none")]
3714    pub fusion: Option<FusionAttribution>,
3715    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
3716    #[serde(skip_serializing_if = "Option::is_none")]
3717    pub initiator: Option<String>,
3718    /// Authoritative interaction classification for the failed call, matching `assistant.usage.interactionType` (for example `conversation-agent`, `conversation-subagent`, or `conversation-sampling`). Absent when the producer cannot classify the interaction.
3719    #[serde(skip_serializing_if = "Option::is_none")]
3720    pub interaction_type: Option<String>,
3721    /// Whether the session selected Auto mode for the failed call
3722    #[serde(skip_serializing_if = "Option::is_none")]
3723    pub is_auto: Option<bool>,
3724    /// Whether the failed call used a bring-your-own-key provider
3725    #[serde(skip_serializing_if = "Option::is_none")]
3726    pub is_byok: Option<bool>,
3727    /// Effective maximum output-token limit for the failed call
3728    #[serde(skip_serializing_if = "Option::is_none")]
3729    pub max_output_tokens: Option<i64>,
3730    /// Effective maximum prompt-token limit for the failed call
3731    #[serde(skip_serializing_if = "Option::is_none")]
3732    pub max_prompt_tokens: Option<i64>,
3733    /// Model identifier used for the failed API call
3734    #[serde(skip_serializing_if = "Option::is_none")]
3735    pub model: Option<String>,
3736    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
3737    #[serde(skip_serializing_if = "Option::is_none")]
3738    pub provider_call_id: Option<String>,
3739    /// Per-quota usage snapshots parsed from the failed response's quota headers, keyed by quota identifier. Present when the error response carried quota headers (e.g. a 402 once the additional spend limit is reached) so the UI can refresh the quota display on failure.
3740    #[doc(hidden)]
3741    #[serde(skip_serializing_if = "Option::is_none")]
3742    pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
3743    /// Reasoning effort level used for the failed model call, if applicable
3744    #[serde(skip_serializing_if = "Option::is_none")]
3745    pub reasoning_effort: Option<String>,
3746    /// Content-free structural summary of the failing request. Contains only counts and shape flags (no prompt content), so it is safe for unrestricted telemetry. Populated only for client-error (4xx) failures.
3747    #[serde(skip_serializing_if = "Option::is_none")]
3748    pub request_fingerprint: Option<ModelCallFailureRequestFingerprint>,
3749    /// Per-request treatment/eligibility signal returned by the Copilot API in the `X-GitHub-Copilot-Request-TE` response header for the associated model call; `false` when the header was absent or unparseable.
3750    #[serde(skip_serializing_if = "Option::is_none")]
3751    pub rte: Option<bool>,
3752    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3753    #[serde(skip_serializing_if = "Option::is_none")]
3754    pub service_request_id: Option<String>,
3755    /// Where the failed model call originated
3756    pub source: ModelCallFailureSource,
3757    /// HTTP status code from the failed request
3758    #[serde(skip_serializing_if = "Option::is_none")]
3759    pub status_code: Option<i32>,
3760    /// Transport used for the failed model call (http or websocket)
3761    #[serde(skip_serializing_if = "Option::is_none")]
3762    pub transport: Option<ModelCallFailureTransport>,
3763}
3764
3765/// Session event "model.call_finished". Final lifecycle outcome for one logical model dispatch. A logical dispatch may include internal reconnect or fallback work, so event count is not provider HTTP-request count.
3766#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3767#[serde(rename_all = "camelCase")]
3768pub struct ModelCallFinishedData {
3769    /// Whether an accepted successful response requested the exact name and command semantics of a built-in file edit tool, including an external tool explicitly replacing that built-in name. Absent when the logical dispatch did not produce an accepted response.
3770    #[serde(skip_serializing_if = "Option::is_none")]
3771    pub contains_built_in_file_edit_request: Option<bool>,
3772    /// Monotonic elapsed time spent in the logical model dispatch, including any internal transport reconnect or fallback and excluding orchestrator retry backoff, tool execution, confirmations, and post-response processing
3773    pub dispatch_duration_ms: f64,
3774    /// Version of the built-in file-edit semantic classifier used for this event
3775    pub edit_classifier_version: i64,
3776    /// Identifier of the user interaction that owns the model dispatch, matching assistant.turn_start.interactionId when available
3777    #[serde(skip_serializing_if = "Option::is_none")]
3778    pub interaction_id: Option<String>,
3779    /// Final outcome after post-response acceptance processing
3780    pub outcome: ModelCallFinishedOutcome,
3781    /// Agent-loop iteration within the interaction that initiated the model dispatch
3782    pub turn_id: String,
3783}
3784
3785/// Session event "model.call_start". Model API dispatch metadata for internal telemetry
3786#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3787#[serde(rename_all = "camelCase")]
3788pub struct ModelCallStartData {
3789    /// Experimental HydraFusion attribution for this concrete model call.
3790    ///
3791    /// <div class="warning">
3792    ///
3793    /// **Experimental.** This type is part of an experimental wire-protocol surface
3794    /// and may change or be removed in future SDK or CLI releases.
3795    ///
3796    /// </div>
3797    #[serde(skip_serializing_if = "Option::is_none")]
3798    pub fusion: Option<FusionAttribution>,
3799    /// Model identifier used for this API call, when known
3800    #[serde(skip_serializing_if = "Option::is_none")]
3801    pub model: Option<String>,
3802    /// Previous response or interaction identifier included in the model request, when present
3803    #[doc(hidden)]
3804    #[serde(skip_serializing_if = "Option::is_none")]
3805    pub(crate) previous_response_id: Option<String>,
3806    /// Identifier of the assistant turn that initiated the model call
3807    pub turn_id: String,
3808}
3809
3810/// Session event "abort". Turn abort information including the reason for termination
3811#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3812#[serde(rename_all = "camelCase")]
3813pub struct AbortData {
3814    /// Finite reason code describing why the current turn was aborted
3815    pub reason: AbortReason,
3816}
3817
3818/// Session event "tool.user_requested". User-initiated tool invocation request with tool name and arguments
3819#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3820#[serde(rename_all = "camelCase")]
3821pub struct ToolUserRequestedData {
3822    /// Arguments for the tool invocation
3823    #[serde(skip_serializing_if = "Option::is_none")]
3824    pub arguments: Option<serde_json::Value>,
3825    /// Unique identifier for this tool call
3826    pub tool_call_id: String,
3827    /// Name of the tool the user wants to invoke
3828    pub tool_name: String,
3829}
3830
3831/// Shell-aware path hints for a shell tool's command, captured at start time so consumers can snapshot a file's pre-image before the tool runs.
3832#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3833#[serde(rename_all = "camelCase")]
3834pub struct ToolExecutionStartShellToolInfo {
3835    /// The command with a redundant leading `cd` into the working directory removed, present only when there was one to remove. Computed with the same routine the shell driver applies before spawning, so a surface that renders this shows the text that actually runs. Consumers that display it should keep the original tool arguments available on demand.
3836    ///
3837    /// <div class="warning">
3838    ///
3839    /// **Experimental.** This type is part of an experimental wire-protocol surface
3840    /// and may change or be removed in future SDK or CLI releases.
3841    ///
3842    /// </div>
3843    #[serde(skip_serializing_if = "Option::is_none")]
3844    pub display_command: Option<String>,
3845    /// Whether the command includes a file write redirection (e.g., > or >>).
3846    pub has_write_file_redirection: bool,
3847    /// File paths the command may read or write, derived from the command at start time. Produced by the same shell-aware extractor as PermissionRequestShell.possiblePaths, so it is present even when the command is auto-approved and no permission request fires.
3848    pub possible_paths: Vec<String>,
3849}
3850
3851/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
3852#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3853#[serde(rename_all = "camelCase")]
3854pub struct ToolExecutionStartToolDescriptionMetaUI {
3855    /// URI of the UI resource
3856    #[serde(skip_serializing_if = "Option::is_none")]
3857    pub resource_uri: Option<String>,
3858    /// Who can access this tool
3859    #[serde(skip_serializing_if = "Option::is_none")]
3860    pub visibility: Option<Vec<ToolExecutionStartToolDescriptionMetaUIVisibility>>,
3861}
3862
3863/// MCP Apps metadata for UI resource association
3864#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3865#[serde(rename_all = "camelCase")]
3866pub struct ToolExecutionStartToolDescriptionMeta {
3867    /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
3868    #[serde(skip_serializing_if = "Option::is_none")]
3869    pub ui: Option<ToolExecutionStartToolDescriptionMetaUI>,
3870}
3871
3872/// Tool definition metadata, present for MCP tools with MCP Apps support
3873#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3874#[serde(rename_all = "camelCase")]
3875pub struct ToolExecutionStartToolDescription {
3876    /// MCP Apps metadata for UI resource association
3877    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
3878    pub meta: Option<ToolExecutionStartToolDescriptionMeta>,
3879    /// Tool description
3880    #[serde(skip_serializing_if = "Option::is_none")]
3881    pub description: Option<String>,
3882    /// Tool name
3883    pub name: String,
3884}
3885
3886/// Session event "tool.execution_start". Tool execution startup details including MCP server information when applicable
3887#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3888#[serde(rename_all = "camelCase")]
3889pub struct ToolExecutionStartData {
3890    /// Arguments passed to the tool
3891    #[serde(skip_serializing_if = "Option::is_none")]
3892    pub arguments: Option<serde_json::Value>,
3893    /// When true, the tool output should be displayed expanded (verbatim) in the CLI timeline
3894    #[serde(skip_serializing_if = "Option::is_none")]
3895    pub display_verbatim: Option<bool>,
3896    /// Experimental HydraFusion attribution for this tool execution.
3897    ///
3898    /// <div class="warning">
3899    ///
3900    /// **Experimental.** This type is part of an experimental wire-protocol surface
3901    /// and may change or be removed in future SDK or CLI releases.
3902    ///
3903    /// </div>
3904    #[serde(skip_serializing_if = "Option::is_none")]
3905    pub fusion: Option<FusionAttribution>,
3906    /// Preferred lookup name for the MCP server hosting this tool: the configured (namespaced) config-map key when the tool carries one, otherwise the display name from `mcpServerName`. Present when the tool is an MCP tool; this is the name unrestricted provenance telemetry hashes so it joins with `mcp_server_setup`, which keys off the configured name too.
3907    #[serde(skip_serializing_if = "Option::is_none")]
3908    pub mcp_config_server_name: Option<String>,
3909    /// Where the MCP server's configuration came from (`user`, `workspace`, `plugin`, or `builtin`), when the tool is an MCP tool and the server is configured
3910    #[serde(skip_serializing_if = "Option::is_none")]
3911    pub mcp_config_source: Option<McpServerSource>,
3912    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
3913    #[serde(skip_serializing_if = "Option::is_none")]
3914    pub mcp_server_name: Option<String>,
3915    /// Original tool name on the MCP server, when the tool is an MCP tool
3916    #[serde(skip_serializing_if = "Option::is_none")]
3917    pub mcp_tool_name: Option<String>,
3918    /// Transport the MCP server hosting this tool is connected over, when the tool is an MCP tool and the server is configured
3919    #[serde(skip_serializing_if = "Option::is_none")]
3920    pub mcp_transport: Option<McpServerTransport>,
3921    /// Model identifier that generated this tool call
3922    #[serde(skip_serializing_if = "Option::is_none")]
3923    pub model: Option<String>,
3924    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3925    #[doc(hidden)]
3926    #[deprecated]
3927    #[serde(skip_serializing_if = "Option::is_none")]
3928    pub parent_tool_call_id: Option<String>,
3929    /// Per-request treatment/eligibility signal returned by the Copilot API in the `X-GitHub-Copilot-Request-TE` response header for the associated model call; `false` when the header was absent or unparseable.
3930    #[serde(skip_serializing_if = "Option::is_none")]
3931    pub rte: Option<bool>,
3932    /// Shell-tool path hints derived from the command at start time for shell tools (bash/powershell/local_shell). Produced by the same shell-aware extractor as PermissionRequestShell.possiblePaths, so it is present even when the command is auto-approved and no permission request fires. Absent for non-shell tools.
3933    #[serde(skip_serializing_if = "Option::is_none")]
3934    pub shell_tool_info: Option<ToolExecutionStartShellToolInfo>,
3935    /// Unique identifier for this tool call
3936    pub tool_call_id: String,
3937    /// Tool definition metadata, present for MCP tools with MCP Apps support
3938    #[serde(skip_serializing_if = "Option::is_none")]
3939    pub tool_description: Option<ToolExecutionStartToolDescription>,
3940    /// Name of the tool being executed
3941    pub tool_name: String,
3942    /// Human-readable display title for the tool, when the selected tool descriptor has a non-empty title.
3943    #[serde(skip_serializing_if = "Option::is_none")]
3944    pub tool_title: Option<String>,
3945    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
3946    #[serde(skip_serializing_if = "Option::is_none")]
3947    pub turn_id: Option<String>,
3948}
3949
3950/// Session event "tool.execution_partial_result". Streaming tool execution output for incremental result display
3951#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3952#[serde(rename_all = "camelCase")]
3953pub struct ToolExecutionPartialResultData {
3954    /// Incremental output chunk from the running tool
3955    pub partial_output: String,
3956    /// Tool call ID this partial result belongs to
3957    pub tool_call_id: String,
3958}
3959
3960/// Session event "tool.execution_progress". Tool execution progress notification with status message
3961#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3962#[serde(rename_all = "camelCase")]
3963pub struct ToolExecutionProgressData {
3964    /// Human-readable progress status message (e.g., from an MCP server)
3965    pub progress_message: String,
3966    /// Tool call ID this progress notification belongs to
3967    pub tool_call_id: String,
3968}
3969
3970/// Error details when the tool execution failed
3971#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3972#[serde(rename_all = "camelCase")]
3973pub struct ToolExecutionCompleteError {
3974    /// Machine-readable error code
3975    #[serde(skip_serializing_if = "Option::is_none")]
3976    pub code: Option<String>,
3977    /// Human-readable error message
3978    pub message: String,
3979    /// What the user must do to recover, when the runtime knows of an action. Set on sandbox policy denials, where `message` names the rule that blocked the call but never the client affordance that relaxes it.
3980    #[serde(skip_serializing_if = "Option::is_none")]
3981    pub remediation: Option<RemediationAction>,
3982}
3983
3984/// Binary result returned by a tool for the model
3985#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3986#[serde(rename_all = "camelCase")]
3987pub struct PersistedBinaryImage {
3988    /// Base64-encoded binary data
3989    pub data: String,
3990    /// Human-readable description of the binary data
3991    #[serde(skip_serializing_if = "Option::is_none")]
3992    pub description: Option<String>,
3993    /// Optional metadata from the producing tool.
3994    #[serde(skip_serializing_if = "Option::is_none")]
3995    pub metadata: Option<HashMap<String, serde_json::Value>>,
3996    /// MIME type of the binary data
3997    pub mime_type: String,
3998    /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
3999    pub r#type: PersistedBinaryImageType,
4000}
4001
4002/// A binary result whose data was omitted from persistence due to the inline size limit
4003///
4004/// <div class="warning">
4005///
4006/// **Experimental.** This type is part of an experimental wire-protocol surface
4007/// and may change or be removed in future SDK or CLI releases.
4008///
4009/// </div>
4010#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4011#[serde(rename_all = "camelCase")]
4012pub struct OmittedBinaryResult {
4013    /// Decoded byte length of the omitted binary data
4014    pub byte_length: i64,
4015    /// Human-readable description of the binary data
4016    #[serde(skip_serializing_if = "Option::is_none")]
4017    pub description: Option<String>,
4018    /// Optional metadata from the producing tool.
4019    #[serde(skip_serializing_if = "Option::is_none")]
4020    pub metadata: Option<HashMap<String, serde_json::Value>>,
4021    /// MIME type of the omitted binary data
4022    pub mime_type: String,
4023    /// Why the binary data is absent: it exceeded the inline size limit, or its asset was unavailable
4024    pub omitted_reason: OmittedBinaryOmittedReason,
4025    /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
4026    pub r#type: OmittedBinaryType,
4027}
4028
4029/// A reference to binary data persisted once on a session.binary_asset event and shared by id
4030///
4031/// <div class="warning">
4032///
4033/// **Experimental.** This type is part of an experimental wire-protocol surface
4034/// and may change or be removed in future SDK or CLI releases.
4035///
4036/// </div>
4037#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4038#[serde(rename_all = "camelCase")]
4039pub struct BinaryAssetReference {
4040    /// Content-addressed id of the session.binary_asset event that holds this binary's bytes (e.g. "sha256:...").
4041    pub asset_id: String,
4042    /// Decoded byte length of the referenced binary data
4043    pub byte_length: i64,
4044    /// Human-readable description of the binary data
4045    #[serde(skip_serializing_if = "Option::is_none")]
4046    pub description: Option<String>,
4047    /// Optional metadata from the producing tool.
4048    #[serde(skip_serializing_if = "Option::is_none")]
4049    pub metadata: Option<HashMap<String, serde_json::Value>>,
4050    /// MIME type of the referenced binary data
4051    pub mime_type: String,
4052    /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
4053    pub r#type: BinaryAssetReferenceType,
4054}
4055
4056/// A source supplied by a tool that should be made available to the model as citable content.
4057///
4058/// <div class="warning">
4059///
4060/// **Experimental.** This type is part of an experimental wire-protocol surface
4061/// and may change or be removed in future SDK or CLI releases.
4062///
4063/// </div>
4064#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4065#[serde(rename_all = "camelCase")]
4066pub struct CitableSource {
4067    /// The source text made available to the model as citable content.
4068    pub content: String,
4069    /// Stable identifier for this source within the tool result. Used for deduplication and may be used by future provider integrations to correlate response citations back to the originating source.
4070    pub id: String,
4071    /// File path relative to the agent's workspace root, when the source is a file.
4072    #[serde(skip_serializing_if = "Option::is_none")]
4073    pub path: Option<String>,
4074    /// Human-readable title of the source.
4075    #[serde(skip_serializing_if = "Option::is_none")]
4076    pub title: Option<String>,
4077    /// URL of the source, when it is a web resource.
4078    #[serde(skip_serializing_if = "Option::is_none")]
4079    pub url: Option<String>,
4080}
4081
4082/// Plain text content block
4083#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4084#[serde(rename_all = "camelCase")]
4085pub struct ToolExecutionCompleteContentText {
4086    /// The text content
4087    pub text: String,
4088    /// Content block type discriminator
4089    pub r#type: ToolExecutionCompleteContentTextType,
4090}
4091
4092/// Deprecated for shell command exit metadata. Use ToolExecutionCompleteContentShellExit instead.
4093#[doc(hidden)]
4094#[deprecated]
4095#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4096#[serde(rename_all = "camelCase")]
4097pub struct ToolExecutionCompleteContentTerminal {
4098    /// Working directory where the command was executed
4099    #[serde(skip_serializing_if = "Option::is_none")]
4100    pub cwd: Option<String>,
4101    /// Process exit code, if the command has completed
4102    #[serde(skip_serializing_if = "Option::is_none")]
4103    pub exit_code: Option<i64>,
4104    /// Terminal/shell output text
4105    pub text: String,
4106    /// Content block type discriminator
4107    pub r#type: ToolExecutionCompleteContentTerminalType,
4108}
4109
4110/// Shell command exit metadata with optional output preview
4111#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4112#[serde(rename_all = "camelCase")]
4113pub struct ToolExecutionCompleteContentShellExit {
4114    /// Working directory where the shell command was executed
4115    #[serde(skip_serializing_if = "Option::is_none")]
4116    pub cwd: Option<String>,
4117    /// Exit code from the completed shell command
4118    pub exit_code: i64,
4119    /// Path reported in the shell session's filesystem namespace when shell output exceeded the configured large-output threshold.
4120    #[serde(skip_serializing_if = "Option::is_none")]
4121    pub output_file_path: Option<String>,
4122    /// Output associated with this shell command, if available. May be partial, truncated, or a preview; not guaranteed to be full output.
4123    #[serde(skip_serializing_if = "Option::is_none")]
4124    pub output_preview: Option<String>,
4125    /// Whether outputPreview is known to be incomplete or truncated
4126    #[serde(skip_serializing_if = "Option::is_none")]
4127    pub output_truncated: Option<bool>,
4128    /// Shell id, as assigned by Copilot runtime
4129    pub shell_id: String,
4130    /// Content block type discriminator
4131    pub r#type: ToolExecutionCompleteContentShellExitType,
4132}
4133
4134/// Image content block with base64-encoded data
4135#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4136#[serde(rename_all = "camelCase")]
4137pub struct ToolExecutionCompleteContentImage {
4138    /// Base64-encoded image data
4139    pub data: String,
4140    /// MIME type of the image (e.g., image/png, image/jpeg)
4141    pub mime_type: String,
4142    /// Content block type discriminator
4143    pub r#type: ToolExecutionCompleteContentImageType,
4144}
4145
4146/// Audio content block with base64-encoded data
4147#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4148#[serde(rename_all = "camelCase")]
4149pub struct ToolExecutionCompleteContentAudio {
4150    /// Base64-encoded audio data
4151    pub data: String,
4152    /// MIME type of the audio (e.g., audio/wav, audio/mpeg)
4153    pub mime_type: String,
4154    /// Content block type discriminator
4155    pub r#type: ToolExecutionCompleteContentAudioType,
4156}
4157
4158/// Icon image for a resource
4159#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4160#[serde(rename_all = "camelCase")]
4161pub struct ToolExecutionCompleteContentResourceLinkIcon {
4162    /// MIME type of the icon image
4163    #[serde(skip_serializing_if = "Option::is_none")]
4164    pub mime_type: Option<String>,
4165    /// Available icon sizes (e.g., ['16x16', '32x32'])
4166    #[serde(skip_serializing_if = "Option::is_none")]
4167    pub sizes: Option<Vec<String>>,
4168    /// URL or path to the icon image
4169    pub src: String,
4170    /// Theme variant this icon is intended for
4171    #[serde(skip_serializing_if = "Option::is_none")]
4172    pub theme: Option<ToolExecutionCompleteContentResourceLinkIconTheme>,
4173}
4174
4175/// Resource link content block referencing an external resource
4176#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4177#[serde(rename_all = "camelCase")]
4178pub struct ToolExecutionCompleteContentResourceLink {
4179    /// Human-readable description of the resource
4180    #[serde(skip_serializing_if = "Option::is_none")]
4181    pub description: Option<String>,
4182    /// Icons associated with this resource
4183    #[serde(skip_serializing_if = "Option::is_none")]
4184    pub icons: Option<Vec<ToolExecutionCompleteContentResourceLinkIcon>>,
4185    /// MIME type of the resource content
4186    #[serde(skip_serializing_if = "Option::is_none")]
4187    pub mime_type: Option<String>,
4188    /// Resource name identifier
4189    pub name: String,
4190    /// Size of the resource in bytes
4191    #[serde(skip_serializing_if = "Option::is_none")]
4192    pub size: Option<i64>,
4193    /// Human-readable display title for the resource
4194    #[serde(skip_serializing_if = "Option::is_none")]
4195    pub title: Option<String>,
4196    /// Content block type discriminator
4197    pub r#type: ToolExecutionCompleteContentResourceLinkType,
4198    /// URI identifying the resource
4199    pub uri: String,
4200}
4201
4202/// Embedded text resource contents identified by a URI, with an optional MIME type and a text payload.
4203#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4204#[serde(rename_all = "camelCase")]
4205pub struct EmbeddedTextResourceContents {
4206    /// MIME type of the text content
4207    #[serde(skip_serializing_if = "Option::is_none")]
4208    pub mime_type: Option<String>,
4209    /// Text content of the resource
4210    pub text: String,
4211    /// URI identifying the resource
4212    pub uri: String,
4213}
4214
4215/// Embedded binary resource contents identified by a URI, with an optional MIME type and a base64-encoded blob.
4216#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4217#[serde(rename_all = "camelCase")]
4218pub struct EmbeddedBlobResourceContents {
4219    /// Base64-encoded binary content of the resource
4220    pub blob: String,
4221    /// MIME type of the blob content
4222    #[serde(skip_serializing_if = "Option::is_none")]
4223    pub mime_type: Option<String>,
4224    /// URI identifying the resource
4225    pub uri: String,
4226}
4227
4228/// Embedded resource content block with inline text or binary data
4229#[derive(Debug, Clone, Serialize, Deserialize)]
4230#[serde(rename_all = "camelCase")]
4231pub struct ToolExecutionCompleteContentResource {
4232    /// The embedded resource contents, either text or base64-encoded binary
4233    pub resource: ToolExecutionCompleteContentResourceDetails,
4234    /// Content block type discriminator
4235    pub r#type: ToolExecutionCompleteContentResourceType,
4236}
4237
4238/// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
4239#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4240#[serde(rename_all = "camelCase")]
4241pub struct ToolExecutionCompleteUIResourceMetaUICsp {
4242    /// Domains the UI resource may use as document base URIs.
4243    #[serde(skip_serializing_if = "Option::is_none")]
4244    pub base_uri_domains: Option<Vec<String>>,
4245    /// Domains the UI resource may connect to.
4246    #[serde(skip_serializing_if = "Option::is_none")]
4247    pub connect_domains: Option<Vec<String>>,
4248    /// Domains the UI resource may embed as nested frames.
4249    #[serde(skip_serializing_if = "Option::is_none")]
4250    pub frame_domains: Option<Vec<String>>,
4251    /// Domains from which the UI resource may load scripts, styles, images, and other resources.
4252    #[serde(skip_serializing_if = "Option::is_none")]
4253    pub resource_domains: Option<Vec<String>>,
4254}
4255
4256/// Marker object for camera permission on an MCP Apps UI resource.
4257#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4258#[serde(rename_all = "camelCase")]
4259pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsCamera {}
4260
4261/// Marker object for clipboard-write permission on an MCP Apps UI resource.
4262#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4263#[serde(rename_all = "camelCase")]
4264pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite {}
4265
4266/// Marker object for geolocation permission on an MCP Apps UI resource.
4267#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4268#[serde(rename_all = "camelCase")]
4269pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation {}
4270
4271/// Marker object for microphone permission on an MCP Apps UI resource.
4272#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4273#[serde(rename_all = "camelCase")]
4274pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone {}
4275
4276/// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
4277#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4278#[serde(rename_all = "camelCase")]
4279pub struct ToolExecutionCompleteUIResourceMetaUIPermissions {
4280    /// Marker object for camera permission on an MCP Apps UI resource.
4281    #[serde(skip_serializing_if = "Option::is_none")]
4282    pub camera: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsCamera>,
4283    /// Marker object for clipboard-write permission on an MCP Apps UI resource.
4284    #[serde(skip_serializing_if = "Option::is_none")]
4285    pub clipboard_write: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite>,
4286    /// Marker object for geolocation permission on an MCP Apps UI resource.
4287    #[serde(skip_serializing_if = "Option::is_none")]
4288    pub geolocation: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation>,
4289    /// Marker object for microphone permission on an MCP Apps UI resource.
4290    #[serde(skip_serializing_if = "Option::is_none")]
4291    pub microphone: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone>,
4292}
4293
4294/// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
4295#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4296#[serde(rename_all = "camelCase")]
4297pub struct ToolExecutionCompleteUIResourceMetaUI {
4298    /// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
4299    #[serde(skip_serializing_if = "Option::is_none")]
4300    pub csp: Option<ToolExecutionCompleteUIResourceMetaUICsp>,
4301    /// Optional dedicated origin for the rendered MCP Apps UI resource.
4302    #[serde(skip_serializing_if = "Option::is_none")]
4303    pub domain: Option<String>,
4304    /// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
4305    #[serde(skip_serializing_if = "Option::is_none")]
4306    pub permissions: Option<ToolExecutionCompleteUIResourceMetaUIPermissions>,
4307    /// Whether the host should render a border around the MCP Apps UI resource.
4308    #[serde(skip_serializing_if = "Option::is_none")]
4309    pub prefers_border: Option<bool>,
4310}
4311
4312/// Resource-level UI metadata (CSP, permissions, visual preferences)
4313#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4314#[serde(rename_all = "camelCase")]
4315pub struct ToolExecutionCompleteUIResourceMeta {
4316    /// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
4317    #[serde(skip_serializing_if = "Option::is_none")]
4318    pub ui: Option<ToolExecutionCompleteUIResourceMetaUI>,
4319}
4320
4321/// MCP Apps UI resource content for rendering in a sandboxed iframe
4322#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4323#[serde(rename_all = "camelCase")]
4324pub struct ToolExecutionCompleteUIResource {
4325    /// Resource-level UI metadata (CSP, permissions, visual preferences)
4326    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
4327    pub meta: Option<ToolExecutionCompleteUIResourceMeta>,
4328    /// Base64-encoded HTML content
4329    #[serde(skip_serializing_if = "Option::is_none")]
4330    pub blob: Option<String>,
4331    /// MIME type of the content
4332    pub mime_type: String,
4333    /// HTML content as a string
4334    #[serde(skip_serializing_if = "Option::is_none")]
4335    pub text: Option<String>,
4336    /// The ui:// URI of the resource
4337    pub uri: String,
4338}
4339
4340/// Tool execution result on success
4341#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4342#[serde(rename_all = "camelCase")]
4343pub struct ToolExecutionCompleteResult {
4344    /// Model-facing binary results (base64 inline or size-omitted markers) sent to the LLM for this tool call
4345    ///
4346    /// <div class="warning">
4347    ///
4348    /// **Experimental.** This type is part of an experimental wire-protocol surface
4349    /// and may change or be removed in future SDK or CLI releases.
4350    ///
4351    /// </div>
4352    #[serde(skip_serializing_if = "Option::is_none")]
4353    pub binary_results_for_llm: Option<Vec<PersistedBinaryResult>>,
4354    /// Provider-neutral source material this tool makes available to the model as citable content. Persisted so it survives session resume. Experimental.
4355    ///
4356    /// <div class="warning">
4357    ///
4358    /// **Experimental.** This type is part of an experimental wire-protocol surface
4359    /// and may change or be removed in future SDK or CLI releases.
4360    ///
4361    /// </div>
4362    #[serde(skip_serializing_if = "Option::is_none")]
4363    pub citable_sources: Option<Vec<CitableSource>>,
4364    /// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency
4365    pub content: String,
4366    /// Structured content blocks (text, images, audio, resources) returned by the tool in their native format
4367    #[serde(skip_serializing_if = "Option::is_none")]
4368    pub contents: Option<Vec<ToolExecutionCompleteContent>>,
4369    /// Detailed tool result for UI/timeline display, preserving complete content such as diffs for most tools. Successful skill invocations intentionally use the concise model-facing content here; the authoritative skill body is carried by the corresponding skill invocation event. Falls back to content when absent.
4370    #[serde(skip_serializing_if = "Option::is_none")]
4371    pub detailed_content: Option<String>,
4372    /// FIDES IFC label projected from tool ingress metadata (MCP `CallToolResult._meta` or synthesized built-in ingress labels) — persisted as `{ ifc: ... }` (only the `ifc` key, not the whole `_meta`). Persisted so the FIDES IFC label survives session resume: the engine rehydrates accumulated taint by replaying these on load. Populated for ingress sources when FIDES IFC is on. Experimental.
4373    ///
4374    /// <div class="warning">
4375    ///
4376    /// **Experimental.** This type is part of an experimental wire-protocol surface
4377    /// and may change or be removed in future SDK or CLI releases.
4378    ///
4379    /// </div>
4380    #[serde(skip_serializing_if = "Option::is_none")]
4381    pub mcp_meta: Option<serde_json::Value>,
4382    /// Structured content (arbitrary JSON) returned verbatim by the MCP tool
4383    #[serde(skip_serializing_if = "Option::is_none")]
4384    pub structured_content: Option<serde_json::Value>,
4385    /// MCP Apps UI resource content for rendering in a sandboxed iframe
4386    #[serde(skip_serializing_if = "Option::is_none")]
4387    pub ui_resource: Option<ToolExecutionCompleteUIResource>,
4388}
4389
4390/// Experimental shell completion facts retained independently of the full tool result.
4391///
4392/// <div class="warning">
4393///
4394/// **Experimental.** This type is part of an experimental wire-protocol surface
4395/// and may change or be removed in future SDK or CLI releases.
4396///
4397/// </div>
4398#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4399#[serde(rename_all = "camelCase")]
4400pub struct ToolExecutionCompleteShellExecution {
4401    /// Process exit code reported by the shell driver.
4402    pub exit_code: i64,
4403}
4404
4405/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
4406#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4407#[serde(rename_all = "camelCase")]
4408pub struct ToolExecutionCompleteToolDescriptionMetaUI {
4409    /// URI of the UI resource
4410    #[serde(skip_serializing_if = "Option::is_none")]
4411    pub resource_uri: Option<String>,
4412    /// Who can access this tool
4413    #[serde(skip_serializing_if = "Option::is_none")]
4414    pub visibility: Option<Vec<ToolExecutionCompleteToolDescriptionMetaUIVisibility>>,
4415}
4416
4417/// MCP Apps metadata for UI resource association
4418#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4419#[serde(rename_all = "camelCase")]
4420pub struct ToolExecutionCompleteToolDescriptionMeta {
4421    /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
4422    #[serde(skip_serializing_if = "Option::is_none")]
4423    pub ui: Option<ToolExecutionCompleteToolDescriptionMetaUI>,
4424}
4425
4426/// Tool definition metadata, present for MCP tools with MCP Apps support
4427#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4428#[serde(rename_all = "camelCase")]
4429pub struct ToolExecutionCompleteToolDescription {
4430    /// MCP Apps metadata for UI resource association
4431    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
4432    pub meta: Option<ToolExecutionCompleteToolDescriptionMeta>,
4433    /// Tool description
4434    #[serde(skip_serializing_if = "Option::is_none")]
4435    pub description: Option<String>,
4436    /// Tool name
4437    pub name: String,
4438}
4439
4440/// Session event "tool.execution_complete". Tool execution completion results including success status, detailed output, and error information
4441#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4442#[serde(rename_all = "camelCase")]
4443pub struct ToolExecutionCompleteData {
4444    /// Error details when the tool execution failed
4445    #[serde(skip_serializing_if = "Option::is_none")]
4446    pub error: Option<ToolExecutionCompleteError>,
4447    /// Experimental HydraFusion attribution for this tool completion.
4448    ///
4449    /// <div class="warning">
4450    ///
4451    /// **Experimental.** This type is part of an experimental wire-protocol surface
4452    /// and may change or be removed in future SDK or CLI releases.
4453    ///
4454    /// </div>
4455    #[serde(skip_serializing_if = "Option::is_none")]
4456    pub fusion: Option<FusionAttribution>,
4457    /// CAPI interaction ID for correlating this tool execution with upstream telemetry
4458    #[serde(skip_serializing_if = "Option::is_none")]
4459    pub interaction_id: Option<String>,
4460    /// Whether this tool call was explicitly requested by the user rather than the assistant
4461    #[serde(skip_serializing_if = "Option::is_none")]
4462    pub is_user_requested: Option<bool>,
4463    /// FIDES IFC label projected from tool ingress metadata (MCP `CallToolResult._meta` or synthesized built-in ingress labels). Persisted as `{ ifc: ... }` so the label survives session resume, including model-visible failure results. Experimental.
4464    ///
4465    /// <div class="warning">
4466    ///
4467    /// **Experimental.** This type is part of an experimental wire-protocol surface
4468    /// and may change or be removed in future SDK or CLI releases.
4469    ///
4470    /// </div>
4471    #[serde(skip_serializing_if = "Option::is_none")]
4472    pub mcp_meta: Option<serde_json::Value>,
4473    /// Model identifier that generated this tool call
4474    #[serde(skip_serializing_if = "Option::is_none")]
4475    pub model: Option<String>,
4476    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
4477    #[doc(hidden)]
4478    #[deprecated]
4479    #[serde(skip_serializing_if = "Option::is_none")]
4480    pub parent_tool_call_id: Option<String>,
4481    /// Tool execution result on success
4482    #[serde(skip_serializing_if = "Option::is_none")]
4483    pub result: Option<ToolExecutionCompleteResult>,
4484    /// Per-request treatment/eligibility signal returned by the Copilot API in the `X-GitHub-Copilot-Request-TE` response header for the associated model call; `false` when the header was absent or unparseable.
4485    #[serde(skip_serializing_if = "Option::is_none")]
4486    pub rte: Option<bool>,
4487    /// Whether this tool execution ran inside a sandbox container
4488    #[serde(skip_serializing_if = "Option::is_none")]
4489    pub sandboxed: Option<bool>,
4490    /// Experimental shell completion facts captured before the persisted result contents are stripped.
4491    ///
4492    /// <div class="warning">
4493    ///
4494    /// **Experimental.** This type is part of an experimental wire-protocol surface
4495    /// and may change or be removed in future SDK or CLI releases.
4496    ///
4497    /// </div>
4498    #[serde(skip_serializing_if = "Option::is_none")]
4499    pub shell_execution: Option<ToolExecutionCompleteShellExecution>,
4500    /// Whether the tool execution completed successfully
4501    pub success: bool,
4502    /// Unique identifier for the completed tool call
4503    pub tool_call_id: String,
4504    /// Tool definition metadata, present for MCP tools with MCP Apps support
4505    #[serde(skip_serializing_if = "Option::is_none")]
4506    pub tool_description: Option<ToolExecutionCompleteToolDescription>,
4507    /// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
4508    #[serde(skip_serializing_if = "Option::is_none")]
4509    pub tool_telemetry: Option<HashMap<String, serde_json::Value>>,
4510    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
4511    #[serde(skip_serializing_if = "Option::is_none")]
4512    pub turn_id: Option<String>,
4513}
4514
4515/// Session event "tool_search.activated". Persisted generic client-side tool activations restored when a session resumes.
4516#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4517#[serde(rename_all = "camelCase")]
4518pub struct ToolSearchActivatedData {
4519    /// Tool-search strategy that activated the definitions.
4520    pub strategy: String,
4521    /// Names of tool definitions activated by this search invocation.
4522    pub tool_names: Vec<String>,
4523}
4524
4525/// Session event "skill.invoked". Skill invocation details including content, allowed tools, and plugin metadata
4526#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4527#[serde(rename_all = "camelCase")]
4528pub struct SkillInvokedData {
4529    /// Tool names that should be auto-approved when this skill is active
4530    #[serde(skip_serializing_if = "Option::is_none")]
4531    pub allowed_tools: Option<Vec<String>>,
4532    /// Full content of the skill file, injected into the conversation for the model
4533    pub content: String,
4534    /// Description of the skill from its SKILL.md frontmatter
4535    #[serde(skip_serializing_if = "Option::is_none")]
4536    pub description: Option<String>,
4537    /// Whether model invocation is disabled for this skill
4538    #[serde(skip_serializing_if = "Option::is_none")]
4539    pub disable_model_invocation: Option<bool>,
4540    /// Projected chat-message count when the skill was invoked. New writers persist this so replay does not need to reconstruct superseded history; readers derive it for legacy events when absent.
4541    #[serde(skip_serializing_if = "Option::is_none")]
4542    pub invoked_at_turn: Option<i64>,
4543    /// Model identifier active when the skill was invoked, when known
4544    #[serde(skip_serializing_if = "Option::is_none")]
4545    pub model: Option<String>,
4546    /// Name of the invoked skill
4547    pub name: String,
4548    /// File path to the SKILL.md definition, or an empty string for an SDK-provided skill without a filesystem identity
4549    pub path: String,
4550    /// Name of the plugin this skill originated from, when applicable
4551    #[serde(skip_serializing_if = "Option::is_none")]
4552    pub plugin_name: Option<String>,
4553    /// Version of the plugin this skill originated from, when applicable
4554    #[serde(skip_serializing_if = "Option::is_none")]
4555    pub plugin_version: Option<String>,
4556    /// Source identifier for where the skill was discovered. Known values include: project (workspace skill), inherited (parent-directory skill), personal-copilot (~/.copilot/skills), personal-agents (~/.agents/skills), custom (configured directory), plugin (installed plugin), builtin (bundled runtime skill), remote (org/enterprise skill), and sdk (SDK-provided skill)
4557    #[serde(skip_serializing_if = "Option::is_none")]
4558    pub source: Option<String>,
4559    /// What triggered the skill invocation: `user-invoked` (explicit user action, such as via a slash command or UI affordance), `agent-invoked` (agent requested the skill), or `context-load` (loaded as part of another context, such as preloading skills configured on a custom agent or subagent)
4560    #[serde(skip_serializing_if = "Option::is_none")]
4561    pub trigger: Option<SkillInvokedTrigger>,
4562}
4563
4564/// Session event "skill.invoked_ref". Internal durable skill invocation receipt whose content resolves from an earlier inline skill event in the same session.
4565#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4566#[serde(rename_all = "camelCase")]
4567pub struct SkillInvokedRefData {
4568    /// Tool names that should be auto-approved when this skill is active
4569    #[serde(skip_serializing_if = "Option::is_none")]
4570    pub allowed_tools: Option<Vec<String>>,
4571    /// Content identifier of an earlier inline skill event in this session, in the prefixed form `sha256:<lowercase hex digest>` over the UTF-8 bytes of that event's `content`
4572    pub content_id: String,
4573    /// UTF-16 code unit length of the referenced skill content. Derived from the referenced body and validated against it when the reference is expanded; a reference whose length disagrees with the body it names is rejected instead of expanded
4574    pub content_length: i64,
4575    /// Description of the skill from its SKILL.md frontmatter
4576    #[serde(skip_serializing_if = "Option::is_none")]
4577    pub description: Option<String>,
4578    /// Whether model invocation is disabled for this skill
4579    #[serde(skip_serializing_if = "Option::is_none")]
4580    pub disable_model_invocation: Option<bool>,
4581    /// Projected chat-message count when the skill was invoked. Preserved from the inline event data when the authored body is deduplicated.
4582    #[serde(skip_serializing_if = "Option::is_none")]
4583    pub invoked_at_turn: Option<i64>,
4584    /// Model identifier active when the skill was invoked, when known
4585    #[serde(skip_serializing_if = "Option::is_none")]
4586    pub model: Option<String>,
4587    /// Name of the invoked skill
4588    pub name: String,
4589    /// File path to the SKILL.md definition, or an empty string for an SDK-provided skill without a filesystem identity
4590    pub path: String,
4591    /// Name of the plugin this skill originated from, when applicable
4592    #[serde(skip_serializing_if = "Option::is_none")]
4593    pub plugin_name: Option<String>,
4594    /// Version of the plugin this skill originated from, when applicable
4595    #[serde(skip_serializing_if = "Option::is_none")]
4596    pub plugin_version: Option<String>,
4597    /// Source identifier for where the skill was discovered
4598    #[serde(skip_serializing_if = "Option::is_none")]
4599    pub source: Option<String>,
4600    /// What triggered the skill invocation
4601    #[serde(skip_serializing_if = "Option::is_none")]
4602    pub trigger: Option<SkillInvokedTrigger>,
4603}
4604
4605/// Session event "skill.context_delivered". Exact skill context delivered to the model during a tool phase. This is not a user submission or another skill invocation.
4606#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4607#[serde(rename_all = "camelCase")]
4608pub struct SkillContextDeliveredData {
4609    /// Exact model-facing skill wrapper, including its invocation-time file context
4610    pub content: String,
4611    /// Interaction that delivered this context, when known
4612    #[serde(skip_serializing_if = "Option::is_none")]
4613    pub interaction_id: Option<String>,
4614    /// Unmodified injection provenance, in the form skill-`<invocation-name>`
4615    pub source: String,
4616}
4617
4618/// Session event "skill.context_delivered_ref". Internal durable receipt that reconstructs exact model-visible skill context from earlier session content.
4619#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4620#[serde(rename_all = "camelCase")]
4621pub struct SkillContextDeliveredRefData {
4622    /// Content identifier of an earlier inline skill event in this session, in the prefixed form `sha256:<lowercase hex digest>` over the UTF-8 bytes of that event's `content`
4623    pub content_id: String,
4624    /// Interaction that delivered this context, when known
4625    #[serde(skip_serializing_if = "Option::is_none")]
4626    pub interaction_id: Option<String>,
4627    /// Exact text preceding the referenced content in the delivered wrapper
4628    #[serde(skip_serializing_if = "Option::is_none")]
4629    pub prefix: Option<String>,
4630    /// Unmodified injection provenance, in the form skill-`<invocation-name>`
4631    pub source: String,
4632    /// Exact text following the referenced content in the delivered wrapper
4633    #[serde(skip_serializing_if = "Option::is_none")]
4634    pub suffix: Option<String>,
4635}
4636
4637/// Effective sandbox filesystem rules, in policy order. Only populated when content capture is enabled, since these are real host paths.
4638#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4639#[serde(rename_all = "camelCase")]
4640pub struct SandboxFilesystemPolicyDetails {
4641    /// Paths the sandboxed process may not access at all
4642    pub denied_paths: Vec<String>,
4643    /// Paths the sandboxed process may read but not write
4644    pub readonly_paths: Vec<String>,
4645    /// Paths the sandboxed process may read and write
4646    pub readwrite_paths: Vec<String>,
4647}
4648
4649#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4650#[serde(rename_all = "camelCase")]
4651pub struct SandboxDecisionDataPolicyResolved {
4652    /// Whether the current working directory was granted automatically
4653    pub add_current_working_directory: bool,
4654    /// Whether callers may opt an individual command out of the sandbox
4655    pub allow_bypass: bool,
4656    /// Whether the sandboxed process may reach loopback and private-range addresses
4657    pub allow_local_network: bool,
4658    /// Whether the sandboxed process may open outbound network connections
4659    pub allow_outbound: bool,
4660    /// Process-containment implementation backing the sandbox
4661    pub backend: SandboxBackend,
4662    /// Enforcement mechanism this decision describes
4663    pub control: SandboxControl,
4664    /// Why enforcement is weaker than configured, when it is
4665    #[serde(skip_serializing_if = "Option::is_none")]
4666    pub degradation_reason: Option<SandboxDegradationReason>,
4667    /// Number of denied path rules in the effective policy
4668    pub denied_paths_count: i64,
4669    /// Effective filesystem rules. Populated only when content capture is enabled; the counts above are always present.
4670    #[serde(skip_serializing_if = "Option::is_none")]
4671    pub effective_filesystem_policy: Option<SandboxFilesystemPolicyDetails>,
4672    /// Runtime subsystem that applied the policy
4673    pub enforcement_point: SandboxEnforcementPoint,
4674    /// Whether the sandbox policy permits GitHub CLI credentials inside the sandbox. A policy capability, not proof that a credential was injected into this spawn: injection is per-command
4675    pub gh_auth: bool,
4676    /// Whether the sandbox policy permits git credentials inside the sandbox. A policy capability, not proof that a credential was injected into this spawn: injection is per-command
4677    pub git_auth: bool,
4678    /// Whether the macOS keychain was reachable from inside the sandbox. Always false on other platforms.
4679    pub keychain_access: bool,
4680    /// Sandbox decision variant discriminator.
4681    pub kind: SandboxDecisionDataPolicyResolvedKind,
4682    /// Whether the resolved policy is fully active or degraded
4683    pub outcome: SandboxOutcome,
4684    /// Host platform the sandbox is running on
4685    pub platform: SandboxPlatform,
4686    /// Whether the policy came from built-in defaults or user configuration
4687    pub policy_source: SandboxPolicySource,
4688    /// Whether outbound traffic is unproxied, routed through a loopback proxy, or routed through an external proxy
4689    pub proxy_mode: SandboxProxyMode,
4690    /// Number of read-only path rules in the effective policy
4691    pub readonly_paths_count: i64,
4692    /// Number of read-write path rules in the effective policy
4693    pub readwrite_paths_count: i64,
4694    /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4695    #[serde(skip_serializing_if = "Option::is_none")]
4696    pub tool_call_id: Option<String>,
4697}
4698
4699#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4700#[serde(rename_all = "camelCase")]
4701pub struct SandboxDecisionDataSpawnCompleted {
4702    /// Process-containment implementation backing the sandbox
4703    pub backend: SandboxBackend,
4704    /// Enforcement mechanism this decision describes
4705    pub control: SandboxControl,
4706    /// Why enforcement is weaker than configured, when it is
4707    #[serde(skip_serializing_if = "Option::is_none")]
4708    pub degradation_reason: Option<SandboxDegradationReason>,
4709    /// Wall-clock time spent spawning the sandboxed process, in milliseconds
4710    pub duration_ms: f64,
4711    /// Runtime subsystem that applied the policy
4712    pub enforcement_point: SandboxEnforcementPoint,
4713    /// Sandbox decision variant discriminator.
4714    pub kind: SandboxDecisionDataSpawnCompletedKind,
4715    /// Whether the sandboxed process launched under the named backend. Not the exit status of the command that ran inside it.
4716    pub outcome: SandboxOutcome,
4717    /// Host platform the sandbox is running on
4718    pub platform: SandboxPlatform,
4719    /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4720    #[serde(skip_serializing_if = "Option::is_none")]
4721    pub tool_call_id: Option<String>,
4722}
4723
4724#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4725#[serde(rename_all = "camelCase")]
4726pub struct SandboxDecisionDataEnforcementState {
4727    /// Runtime observation backing the state. Omitted for `inactive`, which has nothing to attest.
4728    #[serde(skip_serializing_if = "Option::is_none")]
4729    pub attestation: Option<SandboxAttestation>,
4730    /// Containment backend that engaged. `unsupported` for any state other than `engaged`, since no backend is known to have run.
4731    pub backend: SandboxBackend,
4732    /// Command the enforcement governed. Populated only when content capture is enabled, and only for shell commands; MCP, LSP, and search command lines are runtime plumbing.
4733    #[serde(skip_serializing_if = "Option::is_none")]
4734    pub command: Option<String>,
4735    /// Enforcement mechanism this decision describes
4736    pub control: SandboxControl,
4737    /// Runtime subsystem whose enforcement this describes
4738    pub enforcement_point: SandboxEnforcementPoint,
4739    /// Sandbox decision variant discriminator.
4740    pub kind: SandboxDecisionDataEnforcementStateKind,
4741    /// Observed enforcement state: `engaged`, `inactive`, or `failed`. Derived from runtime evidence, never from the configured posture or the compile-time target platform.
4742    pub outcome: SandboxOutcome,
4743    /// Host platform the sandbox is running on
4744    pub platform: SandboxPlatform,
4745    /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4746    #[serde(skip_serializing_if = "Option::is_none")]
4747    pub tool_call_id: Option<String>,
4748}
4749
4750/// An enforcement check refused a specific access. Emitted per refusal with no deduplication, including when policy permits the caller to bypass the denial. Carries no backend: the built-in checks that produce this run in-process against the effective policy.
4751#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4752#[serde(rename_all = "camelCase")]
4753pub struct SandboxDecisionDataAccessDenied {
4754    /// Runtime observation backing the denial.
4755    pub attestation: SandboxAttestation,
4756    /// Command whose execution the denial arose from. Populated only when content capture is enabled.
4757    #[serde(skip_serializing_if = "Option::is_none")]
4758    pub command: Option<String>,
4759    /// How strong the evidence behind this denial is. Lets an analysis separate denials the sandbox recorded from ones inferred from output text, which otherwise look identical.
4760    #[serde(skip_serializing_if = "Option::is_none")]
4761    pub confidence: Option<SandboxDenialConfidence>,
4762    /// Sandbox control the denial belongs to. Follows from `denialClass`.
4763    pub control: SandboxControl,
4764    /// Bounded class of the refused access.
4765    pub denial_class: SandboxDenialClass,
4766    /// Resource the check refused, when identified and content capture is enabled.
4767    #[serde(skip_serializing_if = "Option::is_none")]
4768    pub denied_resource: Option<String>,
4769    /// Runtime subsystem that performed the check
4770    pub enforcement_point: SandboxEnforcementPoint,
4771    /// Sandbox decision variant discriminator.
4772    pub kind: SandboxDecisionDataAccessDeniedKind,
4773    /// Always `denied`.
4774    pub outcome: SandboxOutcome,
4775    /// Host operating-system family
4776    pub platform: SandboxPlatform,
4777    /// Executable image associated with the captured denial, normalized to a basename. Populated only when content capture is enabled.
4778    #[serde(skip_serializing_if = "Option::is_none")]
4779    pub process_name: Option<String>,
4780    /// Tool call the denial belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4781    #[serde(skip_serializing_if = "Option::is_none")]
4782    pub tool_call_id: Option<String>,
4783}
4784
4785/// A request to run outside the process sandbox was resolved. This is what makes an `inactive` `enforcement_state` readable: without it, a command that ran unsandboxed because a person approved a bypass looks identical to one that ran unsandboxed because the session never had a sandbox. Reported only when a sandbox was in force, since bypassing a disabled sandbox bypasses nothing. Carries neither backend nor attestation: the verdict comes from the runtime's own permission flow or the local escalation prompt, not from a containment backend and not from the built-in policy check, so `source` is what records where it came from.
4786#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4787#[serde(rename_all = "camelCase")]
4788pub struct SandboxDecisionDataBypassDecided {
4789    /// Command the verdict governs. Populated only when content capture is enabled.
4790    #[serde(skip_serializing_if = "Option::is_none")]
4791    pub command: Option<String>,
4792    /// How strong the evidence behind `denialClass` was. Present exactly when `denialClass` is, so a verdict that relaxed the sandbox on a guess is distinguishable from one that relaxed it on a recorded refusal. Named to match `access_denied`, which reports the same pair.
4793    #[serde(skip_serializing_if = "Option::is_none")]
4794    pub confidence: Option<SandboxDenialConfidence>,
4795    /// Always `bypass`.
4796    pub control: SandboxControl,
4797    /// Bounded class of the access whose refusal raised this escalation. Omitted for a pre-execution bypass, such as a detached command that cannot be sandboxed and therefore resolves no denial.
4798    #[serde(skip_serializing_if = "Option::is_none")]
4799    pub denial_class: Option<SandboxDenialClass>,
4800    /// Resource whose refusal raised this escalation. Populated only when content capture is enabled.
4801    #[serde(skip_serializing_if = "Option::is_none")]
4802    pub denied_resource: Option<String>,
4803    /// Runtime subsystem the bypass applies to
4804    pub enforcement_point: SandboxEnforcementPoint,
4805    /// Sandbox decision variant discriminator.
4806    pub kind: SandboxDecisionDataBypassDecidedKind,
4807    /// Whether the bypass was granted: `approved` or `declined`. `declined` also covers the cases where nobody answered, since the sandboxed denial stands either way.
4808    pub outcome: SandboxOutcome,
4809    /// Host operating-system family
4810    pub platform: SandboxPlatform,
4811    /// Executable image associated with the denial that raised this escalation, normalized to a basename. Populated only when content capture is enabled.
4812    #[serde(skip_serializing_if = "Option::is_none")]
4813    pub process_name: Option<String>,
4814    /// Where the request originated. Orthogonal to `outcome`.
4815    pub source: SandboxBypassSource,
4816    /// Tool call the decision belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4817    #[serde(skip_serializing_if = "Option::is_none")]
4818    pub tool_call_id: Option<String>,
4819}
4820
4821/// A permissive retry was resolved. Distinct from `bypass_decided` because this rung never requests a run outside the process sandbox: it relaxes the process container for one run while the sandbox, and with it the network policy, stays attached. Reported for both outcomes, so an escalation the user declined still leaves evidence that the runtime asked and that the sandboxed denial stood.
4822#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4823#[serde(rename_all = "camelCase")]
4824pub struct SandboxDecisionDataPermissiveRetryDecided {
4825    /// Command the verdict governs. Populated only when content capture is enabled.
4826    #[serde(skip_serializing_if = "Option::is_none")]
4827    pub command: Option<String>,
4828    /// How strong the evidence behind `denialClass` was. Present exactly when `denialClass` is.
4829    #[serde(skip_serializing_if = "Option::is_none")]
4830    pub confidence: Option<SandboxDenialConfidence>,
4831    /// Always `process`: the process container is what this rung relaxes, and the network control is deliberately untouched.
4832    pub control: SandboxControl,
4833    /// Bounded class of the access whose refusal raised this escalation.
4834    #[serde(skip_serializing_if = "Option::is_none")]
4835    pub denial_class: Option<SandboxDenialClass>,
4836    /// Resource whose refusal raised this escalation. Populated only when content capture is enabled.
4837    #[serde(skip_serializing_if = "Option::is_none")]
4838    pub denied_resource: Option<String>,
4839    /// Runtime subsystem the retry applies to
4840    pub enforcement_point: SandboxEnforcementPoint,
4841    /// Sandbox decision variant discriminator.
4842    pub kind: SandboxDecisionDataPermissiveRetryDecidedKind,
4843    /// Whether the permissive retry was granted: `approved` or `declined`. `declined` also covers the cases where nobody answered, since the sandboxed denial stands either way.
4844    pub outcome: SandboxOutcome,
4845    /// Host operating-system family
4846    pub platform: SandboxPlatform,
4847    /// Executable image associated with the denial that raised this escalation, normalized to a basename. Populated only when content capture is enabled.
4848    #[serde(skip_serializing_if = "Option::is_none")]
4849    pub process_name: Option<String>,
4850    /// Where the request originated. Orthogonal to `outcome`.
4851    pub source: SandboxBypassSource,
4852    /// Tool call the decision belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4853    #[serde(skip_serializing_if = "Option::is_none")]
4854    pub tool_call_id: Option<String>,
4855}
4856
4857/// An approved permissive retry finished. `succeeded` means the retry exited successfully without another correlated sandbox denial; `failed` means it failed or remained blocked and may therefore be followed by a full bypass.
4858#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4859#[serde(rename_all = "camelCase")]
4860pub struct SandboxDecisionDataPermissiveRetryCompleted {
4861    /// Command the retry executed. Populated only when content capture is enabled.
4862    #[serde(skip_serializing_if = "Option::is_none")]
4863    pub command: Option<String>,
4864    /// How strong the evidence behind `denialClass` was.
4865    #[serde(skip_serializing_if = "Option::is_none")]
4866    pub confidence: Option<SandboxDenialConfidence>,
4867    /// Always `process`: the retry changes process-container enforcement while leaving network policy attached.
4868    pub control: SandboxControl,
4869    /// Bounded class of the access whose refusal raised the permissive retry.
4870    #[serde(skip_serializing_if = "Option::is_none")]
4871    pub denial_class: Option<SandboxDenialClass>,
4872    /// Resource whose refusal raised the retry. Populated only when content capture is enabled.
4873    #[serde(skip_serializing_if = "Option::is_none")]
4874    pub denied_resource: Option<String>,
4875    /// Runtime subsystem that ran the retry
4876    pub enforcement_point: SandboxEnforcementPoint,
4877    /// Sandbox decision variant discriminator.
4878    pub kind: SandboxDecisionDataPermissiveRetryCompletedKind,
4879    /// Whether the permissive retry completed successfully: `succeeded` or `failed`.
4880    pub outcome: SandboxOutcome,
4881    /// Host operating-system family
4882    pub platform: SandboxPlatform,
4883    /// Executable image associated with the denial that raised the retry, normalized to a basename. Populated only when content capture is enabled.
4884    #[serde(skip_serializing_if = "Option::is_none")]
4885    pub process_name: Option<String>,
4886    /// Tool call the completion belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4887    #[serde(skip_serializing_if = "Option::is_none")]
4888    pub tool_call_id: Option<String>,
4889}
4890
4891/// Session event "subagent.started". Sub-agent startup details including parent tool call and agent information
4892#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4893#[serde(rename_all = "camelCase")]
4894pub struct SubagentStartedData {
4895    /// Description of what the sub-agent does
4896    pub agent_description: String,
4897    /// Human-readable display name of the sub-agent
4898    pub agent_display_name: String,
4899    /// Internal name of the sub-agent
4900    pub agent_name: String,
4901    /// Type of the sub-agent selected at spawn time.
4902    #[serde(skip_serializing_if = "Option::is_none")]
4903    pub agent_type: Option<String>,
4904    /// Whether the sub-agent runs synchronously or in the background.
4905    #[serde(skip_serializing_if = "Option::is_none")]
4906    pub execution_mode: Option<String>,
4907    /// Root id of the factory run that spawned this sub-agent, when it was spawned by one.
4908    #[serde(skip_serializing_if = "Option::is_none")]
4909    pub factory_run_id: Option<String>,
4910    /// Model the sub-agent will run with, when known at start.
4911    #[serde(skip_serializing_if = "Option::is_none")]
4912    pub model: Option<String>,
4913    /// Authority or runtime mechanism responsible for sub-agent model selection, when known at start.
4914    #[serde(skip_serializing_if = "Option::is_none")]
4915    pub model_selection_source: Option<SubagentModelSelectionSource>,
4916    /// Task-registry ID of the spawning sub-agent. Absent when the root session spawned this child.
4917    #[serde(skip_serializing_if = "Option::is_none")]
4918    pub parent_id: Option<String>,
4919    /// Whether this sub-agent can be resumed. Currently always false.
4920    #[serde(skip_serializing_if = "Option::is_none")]
4921    pub resumable: Option<bool>,
4922    /// Where the model input for this sub-agent came from. Present when the task planner resolved the launch (the task tool and factory agents); absent for sub-agents created through other runtime paths.
4923    #[serde(skip_serializing_if = "Option::is_none")]
4924    pub task_model_source: Option<SubagentTaskModelSource>,
4925    /// Tool call ID of the parent tool invocation that spawned this sub-agent
4926    pub tool_call_id: String,
4927}
4928
4929/// Session event "subagent.configured". Resolved runtime configuration for a configured sub-agent
4930#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4931#[serde(rename_all = "camelCase")]
4932pub struct SubagentConfiguredData {
4933    /// Resolved context tier, when configured for the model
4934    #[serde(skip_serializing_if = "Option::is_none")]
4935    pub context_tier: Option<String>,
4936    /// Resolved model the sub-agent will run with
4937    pub model: String,
4938    /// Whether the sub-agent accepts follow-up turns
4939    pub multi_turn: bool,
4940    /// Resolved reasoning effort, when configured for the model
4941    #[serde(skip_serializing_if = "Option::is_none")]
4942    pub reasoning_effort: Option<String>,
4943}
4944
4945/// Session event "subagent.completed". Sub-agent completion details for successful execution
4946#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4947#[serde(rename_all = "camelCase")]
4948pub struct SubagentCompletedData {
4949    /// Human-readable display name of the sub-agent
4950    pub agent_display_name: String,
4951    /// Internal name of the sub-agent
4952    pub agent_name: String,
4953    /// Whether the sub-agent was torn down by cancellation - its own abort, or an ancestor being killed - instead of finishing its work. Cancellation is not a failure, so the run still reports completion; this distinguishes a torn-down sub-agent from one that ran to the end.
4954    #[serde(skip_serializing_if = "Option::is_none")]
4955    pub cancelled: Option<bool>,
4956    /// Whether the first model actually dispatched matched the user's configured preference
4957    #[serde(skip_serializing_if = "Option::is_none")]
4958    pub configured_model_matches_actual: Option<bool>,
4959    /// Concrete model the user configured for this sub-agent via `/subagents`, when present
4960    #[serde(skip_serializing_if = "Option::is_none")]
4961    pub configured_model_preference: Option<String>,
4962    /// Wall-clock duration of the sub-agent execution in milliseconds
4963    #[serde(skip_serializing_if = "Option::is_none")]
4964    pub duration_ms: Option<i64>,
4965    /// Whether the explicit task-call model matched the user's configured preference
4966    #[serde(skip_serializing_if = "Option::is_none")]
4967    pub explicit_model_matches_preference: Option<bool>,
4968    /// Explicit model supplied by the parent agent on the task call, when present
4969    #[serde(skip_serializing_if = "Option::is_none")]
4970    pub explicit_model_override: Option<String>,
4971    /// First model for which the sub-agent started an inference request, when one was dispatched
4972    #[serde(skip_serializing_if = "Option::is_none")]
4973    pub first_dispatched_model: Option<String>,
4974    /// Model used by the sub-agent
4975    #[serde(skip_serializing_if = "Option::is_none")]
4976    pub model: Option<String>,
4977    /// Why an explicit task-call model did not become the effective model
4978    #[serde(skip_serializing_if = "Option::is_none")]
4979    pub model_override_reason: Option<String>,
4980    /// Authority or runtime mechanism responsible for sub-agent model selection
4981    #[serde(skip_serializing_if = "Option::is_none")]
4982    pub model_selection_source: Option<SubagentModelSelectionSource>,
4983    /// Tool call ID of the parent tool invocation that spawned this sub-agent
4984    pub tool_call_id: String,
4985    /// Total tokens (input + output) consumed by the sub-agent
4986    #[serde(skip_serializing_if = "Option::is_none")]
4987    pub total_tokens: Option<i64>,
4988    /// Total number of tool calls made by the sub-agent
4989    #[serde(skip_serializing_if = "Option::is_none")]
4990    pub total_tool_calls: Option<i64>,
4991}
4992
4993/// Session event "subagent.failed". Sub-agent failure details including error message and agent information
4994#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4995#[serde(rename_all = "camelCase")]
4996pub struct SubagentFailedData {
4997    /// Human-readable display name of the sub-agent
4998    pub agent_display_name: String,
4999    /// Internal name of the sub-agent
5000    pub agent_name: String,
5001    /// Whether the first model actually dispatched matched the user's configured preference
5002    #[serde(skip_serializing_if = "Option::is_none")]
5003    pub configured_model_matches_actual: Option<bool>,
5004    /// Concrete model the user configured for this sub-agent via `/subagents`, when present
5005    #[serde(skip_serializing_if = "Option::is_none")]
5006    pub configured_model_preference: Option<String>,
5007    /// Wall-clock duration of the sub-agent execution in milliseconds
5008    #[serde(skip_serializing_if = "Option::is_none")]
5009    pub duration_ms: Option<i64>,
5010    /// Error message describing why the sub-agent failed
5011    pub error: String,
5012    /// Whether the explicit task-call model matched the user's configured preference
5013    #[serde(skip_serializing_if = "Option::is_none")]
5014    pub explicit_model_matches_preference: Option<bool>,
5015    /// Explicit model supplied by the parent agent on the task call, when present
5016    #[serde(skip_serializing_if = "Option::is_none")]
5017    pub explicit_model_override: Option<String>,
5018    /// First model for which the sub-agent started an inference request, when one was dispatched
5019    #[serde(skip_serializing_if = "Option::is_none")]
5020    pub first_dispatched_model: Option<String>,
5021    /// Model selected for the sub-agent, when known
5022    #[serde(skip_serializing_if = "Option::is_none")]
5023    pub model: Option<String>,
5024    /// Why an explicit task-call model did not become the effective model
5025    #[serde(skip_serializing_if = "Option::is_none")]
5026    pub model_override_reason: Option<String>,
5027    /// Authority or runtime mechanism responsible for sub-agent model selection
5028    #[serde(skip_serializing_if = "Option::is_none")]
5029    pub model_selection_source: Option<SubagentModelSelectionSource>,
5030    /// Tool call ID of the parent tool invocation that spawned this sub-agent
5031    pub tool_call_id: String,
5032    /// Total tokens (input + output) consumed before the sub-agent failed
5033    #[serde(skip_serializing_if = "Option::is_none")]
5034    pub total_tokens: Option<i64>,
5035    /// Total number of tool calls made before the sub-agent failed
5036    #[serde(skip_serializing_if = "Option::is_none")]
5037    pub total_tool_calls: Option<i64>,
5038}
5039
5040/// Session event "subagent.selected". Custom agent selection details including name and available tools
5041#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5042#[serde(rename_all = "camelCase")]
5043pub struct SubagentSelectedData {
5044    /// Human-readable display name of the selected custom agent
5045    pub agent_display_name: String,
5046    /// Internal name of the selected custom agent
5047    pub agent_name: String,
5048    /// List of tool names available to this agent, or null for all tools
5049    pub tools: Option<Vec<String>>,
5050}
5051
5052/// Session event "subagent.deselected". Empty payload; the event signals that the custom agent was deselected, returning to the default agent
5053#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5054#[serde(rename_all = "camelCase")]
5055pub struct SubagentDeselectedData {}
5056
5057/// Session event "hook.start". Hook invocation start details including type and input data
5058#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5059#[serde(rename_all = "camelCase")]
5060pub struct HookStartData {
5061    /// Unique identifier for this hook invocation
5062    pub hook_invocation_id: String,
5063    /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
5064    pub hook_type: String,
5065    /// Input data passed to the hook. For postToolUse hooks the retained copy served by session.eventLog.read (and by a resumed session) drops the tool result's inline `contents`/`uiResource`/`skillInvocation` and replaces duplicated text result fields with a `[copilot:elided ...]` marker; the live subscription stream still delivers the full value. Canonical tool output remains in the adjacent tool.execution_complete event, while an invoked skill's authoritative body remains in its skill invocation event.
5066    #[serde(skip_serializing_if = "Option::is_none")]
5067    pub input: Option<serde_json::Value>,
5068    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
5069    #[serde(skip_serializing_if = "Option::is_none")]
5070    pub parent_tool_call_id: Option<String>,
5071}
5072
5073/// Error details when the hook failed
5074#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5075#[serde(rename_all = "camelCase")]
5076pub struct HookEndError {
5077    /// Human-readable error message
5078    pub message: String,
5079    /// Source label of the hook that errored (e.g. the plugin it was loaded from), when known
5080    #[serde(skip_serializing_if = "Option::is_none")]
5081    pub source: Option<String>,
5082    /// Error stack trace, when available
5083    #[serde(skip_serializing_if = "Option::is_none")]
5084    pub stack: Option<String>,
5085}
5086
5087/// Session event "hook.end". Hook invocation completion details including output, success status, and error information
5088#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5089#[serde(rename_all = "camelCase")]
5090pub struct HookEndData {
5091    /// Error details when the hook failed
5092    #[serde(skip_serializing_if = "Option::is_none")]
5093    pub error: Option<HookEndError>,
5094    /// Identifier matching the corresponding hook.start event
5095    pub hook_invocation_id: String,
5096    /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
5097    pub hook_type: String,
5098    /// Output data produced by the hook. Durable and resumed postToolUse receipts may omit messages owned by a successful skill invocation and replace an unchanged skill sessionLog copy with an elision marker; hook-modified or re-sourced values are preserved, and the authoritative body remains in the skill invocation event.
5099    #[serde(skip_serializing_if = "Option::is_none")]
5100    pub output: Option<serde_json::Value>,
5101    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
5102    #[serde(skip_serializing_if = "Option::is_none")]
5103    pub parent_tool_call_id: Option<String>,
5104    /// Whether the hook completed successfully
5105    pub success: bool,
5106}
5107
5108/// Session event "hook.progress". Ephemeral progress update from a running hook process
5109#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5110#[serde(rename_all = "camelCase")]
5111pub struct HookProgressData {
5112    /// Human-readable progress message from the hook process
5113    pub message: String,
5114    /// When true, this status message replaces the previous temporary one instead of accumulating
5115    #[serde(skip_serializing_if = "Option::is_none")]
5116    pub temporary: Option<bool>,
5117}
5118
5119/// Session event "session.binary_asset". Canonical bytes for a content-addressed binary asset shared by reference across events
5120#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5121#[serde(rename_all = "camelCase")]
5122pub struct SessionBinaryAssetData {
5123    /// Content-addressed id for this binary asset (e.g. "sha256:...").
5124    pub asset_id: String,
5125    /// Decoded byte length of the binary asset
5126    pub byte_length: i64,
5127    /// Base64-encoded binary data
5128    pub data: String,
5129    /// Human-readable description of the binary data
5130    #[serde(skip_serializing_if = "Option::is_none")]
5131    pub description: Option<String>,
5132    /// Optional metadata from the producing tool.
5133    #[serde(skip_serializing_if = "Option::is_none")]
5134    pub metadata: Option<HashMap<String, serde_json::Value>>,
5135    /// MIME type of the binary asset
5136    pub mime_type: String,
5137    /// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
5138    pub r#type: BinaryAssetType,
5139}
5140
5141/// One persisted structured system-message block and its cache intent
5142#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5143#[serde(rename_all = "camelCase")]
5144pub struct SystemMessageContentBlock {
5145    /// Explicit prompt-cache intent. True places a breakpoint after this block, false suppresses one, and absence preserves the provider's legacy default.
5146    #[serde(skip_serializing_if = "Option::is_none")]
5147    pub cache_breakpoint: Option<bool>,
5148    /// Text content for this system-message block.
5149    pub content: String,
5150    /// Diagnostic classification indicating whether the block is stable across equivalent sessions.
5151    #[serde(skip_serializing_if = "Option::is_none")]
5152    pub is_static: Option<bool>,
5153}
5154
5155/// Metadata about the prompt template and its construction
5156#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5157#[serde(rename_all = "camelCase")]
5158pub struct SystemMessageMetadata {
5159    /// Version identifier of the prompt template or structured prompt layout used
5160    #[serde(skip_serializing_if = "Option::is_none")]
5161    pub prompt_version: Option<String>,
5162    /// Template variables used when constructing the prompt
5163    #[serde(skip_serializing_if = "Option::is_none")]
5164    pub variables: Option<HashMap<String, serde_json::Value>>,
5165}
5166
5167/// Session event "system.message". System/developer instruction content with role and optional template metadata
5168#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5169#[serde(rename_all = "camelCase")]
5170pub struct SystemMessageData {
5171    /// The system or developer prompt text sent as model input
5172    pub content: String,
5173    /// Optional ordered structured blocks corresponding to content, retained for prompt-cache layout restoration.
5174    #[serde(skip_serializing_if = "Option::is_none")]
5175    pub content_blocks: Option<Vec<SystemMessageContentBlock>>,
5176    /// Logical interaction identifier for the model run receiving this prompt
5177    #[serde(skip_serializing_if = "Option::is_none")]
5178    pub interaction_id: Option<String>,
5179    /// Metadata about the prompt template and its construction
5180    #[serde(skip_serializing_if = "Option::is_none")]
5181    pub metadata: Option<SystemMessageMetadata>,
5182    /// Optional name identifier for the message source
5183    #[serde(skip_serializing_if = "Option::is_none")]
5184    pub name: Option<String>,
5185    /// Message role: "system" for system prompts, "developer" for developer-injected instructions
5186    pub role: SystemMessageRole,
5187}
5188
5189/// Session event "system.notification". System-generated notification for runtime events like background task completion
5190#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5191#[serde(rename_all = "camelCase")]
5192pub struct SystemNotificationData {
5193    /// The notification text, typically wrapped in `<system_notification>` XML tags
5194    pub content: String,
5195    /// Structured metadata identifying what triggered this notification
5196    pub kind: serde_json::Value,
5197    /// Provider reasoning settings anchored before this model-facing message for cache-stable replay; the historical responsesReasoning name is retained for compatibility
5198    #[serde(skip_serializing_if = "Option::is_none")]
5199    pub responses_reasoning: Option<ResponsesReasoning>,
5200}
5201
5202/// A parsed command identifier in a shell permission request, including whether it is read-only.
5203#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5204#[serde(rename_all = "camelCase")]
5205pub struct PermissionRequestShellCommand {
5206    /// Command identifier (e.g., executable name)
5207    pub identifier: String,
5208    /// Whether this command is read-only (no side effects)
5209    pub read_only: bool,
5210}
5211
5212/// A parsed shell command segment used for argument-aware managed policy matching.
5213#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5214#[serde(rename_all = "camelCase")]
5215pub struct PermissionRequestShellCommandSegment {
5216    /// Full text of this command segment, including arguments
5217    pub full_command_text: String,
5218    /// Command identifier (e.g., executable name)
5219    pub identifier: String,
5220}
5221
5222/// A URL that may be accessed by a command in a shell permission request.
5223#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5224#[serde(rename_all = "camelCase")]
5225pub struct PermissionRequestShellPossibleUrl {
5226    /// URL that may be accessed by the command
5227    pub url: String,
5228}
5229
5230/// Shell command permission request
5231#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5232#[serde(rename_all = "camelCase")]
5233pub struct PermissionRequestShell {
5234    /// Whether the UI can offer session-wide approval for this command pattern
5235    pub can_offer_session_approval: bool,
5236    /// Parsed command identifiers found in the command text
5237    pub commands: Vec<PermissionRequestShellCommand>,
5238    /// Parsed command segments, including arguments, used for managed policy matching
5239    #[serde(skip_serializing_if = "Option::is_none")]
5240    pub command_segments: Option<Vec<PermissionRequestShellCommandSegment>>,
5241    /// The complete shell command text to be executed
5242    pub full_command_text: String,
5243    /// Whether the command includes a file write redirection (e.g., > or >>)
5244    pub has_write_file_redirection: bool,
5245    /// Human-readable description of what the command intends to do
5246    pub intention: String,
5247    /// Permission kind discriminator
5248    pub kind: PermissionRequestShellKind,
5249    /// Whether managed policy requires a human response and forbids host auto-approval
5250    #[serde(skip_serializing_if = "Option::is_none")]
5251    pub managed_approval_required: Option<bool>,
5252    /// File paths that may be read or written by the command
5253    pub possible_paths: Vec<String>,
5254    /// URLs that may be accessed by the command
5255    pub possible_urls: Vec<PermissionRequestShellPossibleUrl>,
5256    /// True when the tool is asking to run this command outside the sandbox, either because the command detaches and cannot be sandboxed at all, or because a sandboxed run looked blocked (host opted in via sandbox.allowBypass). The model cannot ask for this; only the tool raises it. This is a request, not a grant: the command runs unsandboxed only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
5257    #[serde(skip_serializing_if = "Option::is_none")]
5258    pub request_sandbox_bypass: Option<bool>,
5259    /// What the tool tells the user about the bypass on offer: which policy rule blocked the call, or why it cannot be sandboxed. Only meaningful when requestSandboxBypass is true.
5260    #[serde(skip_serializing_if = "Option::is_none")]
5261    pub request_sandbox_bypass_reason: Option<String>,
5262    /// True when the requested escalation is a permissive retry rather than a full bypass: the command re-runs inside the sandbox with its file and process restrictions recording instead of blocking, while the network policy stays enforced. Always accompanied by requestSandboxBypass, so hosts that do not recognize this field still treat the request as the escalation it is. Hosts that do recognize it must not describe the command as running outside the sandbox, which would overstate the privilege being granted.
5263    #[serde(skip_serializing_if = "Option::is_none")]
5264    pub request_sandbox_permissive: Option<bool>,
5265    /// Runtime-resolved canonical object each possiblePaths entry names, keyed by the requested spelling, used for authorization identity checks. Internal and experimental; clients should continue to display possiblePaths.
5266    ///
5267    /// <div class="warning">
5268    ///
5269    /// **Experimental.** This type is part of an experimental wire-protocol surface
5270    /// and may change or be removed in future SDK or CLI releases.
5271    ///
5272    /// </div>
5273    #[serde(skip_serializing_if = "Option::is_none")]
5274    pub resolved_paths: Option<HashMap<String, String>>,
5275    /// Runtime-resolved canonical working directory the command runs in, used for authorization identity checks. Internal and experimental; clients should not display it.
5276    ///
5277    /// <div class="warning">
5278    ///
5279    /// **Experimental.** This type is part of an experimental wire-protocol surface
5280    /// and may change or be removed in future SDK or CLI releases.
5281    ///
5282    /// </div>
5283    #[serde(skip_serializing_if = "Option::is_none")]
5284    pub resolved_working_directory: Option<String>,
5285    /// Tool call ID that triggered this permission request
5286    #[serde(skip_serializing_if = "Option::is_none")]
5287    pub tool_call_id: Option<String>,
5288    /// Optional warning message about risks of running this command
5289    #[serde(skip_serializing_if = "Option::is_none")]
5290    pub warning: Option<String>,
5291}
5292
5293/// File write permission request
5294#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5295#[serde(rename_all = "camelCase")]
5296pub struct PermissionRequestWrite {
5297    /// Whether the UI can offer session-wide approval for file write operations
5298    pub can_offer_session_approval: bool,
5299    /// Unified diff showing the proposed changes
5300    pub diff: String,
5301    /// Path of the file being written to
5302    pub file_name: String,
5303    /// Human-readable description of the intended file change
5304    pub intention: String,
5305    /// Permission kind discriminator
5306    pub kind: PermissionRequestWriteKind,
5307    /// Whether managed policy requires a human response and forbids host auto-approval
5308    #[serde(skip_serializing_if = "Option::is_none")]
5309    pub managed_approval_required: Option<bool>,
5310    /// Complete new file contents for newly created files
5311    #[serde(skip_serializing_if = "Option::is_none")]
5312    pub new_file_contents: Option<String>,
5313    /// True when a built-in file tool (apply_patch / str_replace_editor) asked to write a path the sandbox filesystem policy would block, and the host opted in via sandbox.allowBypass. This is a request, not a grant: the write happens unsandboxed only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
5314    #[serde(skip_serializing_if = "Option::is_none")]
5315    pub request_sandbox_bypass: Option<bool>,
5316    /// Justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
5317    #[serde(skip_serializing_if = "Option::is_none")]
5318    pub request_sandbox_bypass_reason: Option<String>,
5319    /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display fileName.
5320    ///
5321    /// <div class="warning">
5322    ///
5323    /// **Experimental.** This type is part of an experimental wire-protocol surface
5324    /// and may change or be removed in future SDK or CLI releases.
5325    ///
5326    /// </div>
5327    #[serde(skip_serializing_if = "Option::is_none")]
5328    pub resolved_path: Option<String>,
5329    /// Tool call ID that triggered this permission request
5330    #[serde(skip_serializing_if = "Option::is_none")]
5331    pub tool_call_id: Option<String>,
5332}
5333
5334/// File or directory read permission request
5335#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5336#[serde(rename_all = "camelCase")]
5337pub struct PermissionRequestRead {
5338    /// Human-readable description of why the file is being read
5339    pub intention: String,
5340    /// Permission kind discriminator
5341    pub kind: PermissionRequestReadKind,
5342    /// Whether managed policy requires a human response and forbids host auto-approval
5343    #[serde(skip_serializing_if = "Option::is_none")]
5344    pub managed_approval_required: Option<bool>,
5345    /// Path of the file or directory being read
5346    pub path: String,
5347    /// True when the tool is asking to re-run this search outside the sandbox, after a sandboxed run looked blocked (host opted in via sandbox.allowBypass). The model cannot ask for this; only the tool raises it. This is a request, not a grant: the search runs unsandboxed only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
5348    #[serde(skip_serializing_if = "Option::is_none")]
5349    pub request_sandbox_bypass: Option<bool>,
5350    /// What the tool tells the user about the bypass on offer: which policy rule blocked the call, or why it cannot be sandboxed. Only meaningful when requestSandboxBypass is true.
5351    #[serde(skip_serializing_if = "Option::is_none")]
5352    pub request_sandbox_bypass_reason: Option<String>,
5353    /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display path.
5354    ///
5355    /// <div class="warning">
5356    ///
5357    /// **Experimental.** This type is part of an experimental wire-protocol surface
5358    /// and may change or be removed in future SDK or CLI releases.
5359    ///
5360    /// </div>
5361    #[serde(skip_serializing_if = "Option::is_none")]
5362    pub resolved_path: Option<String>,
5363    /// Tool call ID that triggered this permission request
5364    #[serde(skip_serializing_if = "Option::is_none")]
5365    pub tool_call_id: Option<String>,
5366}
5367
5368/// MCP tool invocation permission request
5369#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5370#[serde(rename_all = "camelCase")]
5371pub struct PermissionRequestMcp {
5372    /// Arguments to pass to the MCP tool
5373    #[serde(skip_serializing_if = "Option::is_none")]
5374    pub args: Option<serde_json::Value>,
5375    /// Permission kind discriminator
5376    pub kind: PermissionRequestMcpKind,
5377    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5378    #[serde(skip_serializing_if = "Option::is_none")]
5379    pub managed_approval_required: Option<bool>,
5380    /// Advisory runtime permission recommendation. The SDK host remains responsible for deciding the request and may reject it.
5381    ///
5382    /// <div class="warning">
5383    ///
5384    /// **Experimental.** This type is part of an experimental wire-protocol surface
5385    /// and may change or be removed in future SDK or CLI releases.
5386    ///
5387    /// </div>
5388    #[serde(skip_serializing_if = "Option::is_none")]
5389    pub permission_recommendation: Option<PermissionRecommendation>,
5390    /// Whether this MCP tool is read-only (no side effects)
5391    pub read_only: bool,
5392    /// Name of the MCP server providing the tool
5393    pub server_name: String,
5394    /// Tool call ID that triggered this permission request
5395    #[serde(skip_serializing_if = "Option::is_none")]
5396    pub tool_call_id: Option<String>,
5397    /// Internal name of the MCP tool
5398    pub tool_name: String,
5399    /// Human-readable title of the MCP tool
5400    pub tool_title: String,
5401}
5402
5403/// URL access permission request
5404#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5405#[serde(rename_all = "camelCase")]
5406pub struct PermissionRequestUrl {
5407    /// Human-readable description of why the URL is being accessed
5408    pub intention: String,
5409    /// Permission kind discriminator
5410    pub kind: PermissionRequestUrlKind,
5411    /// Whether managed policy requires a human response and forbids host auto-approval
5412    #[serde(skip_serializing_if = "Option::is_none")]
5413    pub managed_approval_required: Option<bool>,
5414    /// Immediately preceding URL when this request is for a redirect target
5415    #[serde(skip_serializing_if = "Option::is_none")]
5416    pub redirected_from: Option<String>,
5417    /// True when the tool is asking to run this URL fetch outside the sandbox, after the network policy denied the approved URL or the sandbox proxy could not reach it (host opted in via sandbox.allowBypass). The model cannot ask for this; only the tool raises it. This is a request, not a grant: the fetch runs only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
5418    #[serde(skip_serializing_if = "Option::is_none")]
5419    pub request_sandbox_bypass: Option<bool>,
5420    /// What the tool tells the user about the bypass on offer: which policy rule blocked the call, or why it cannot be sandboxed. Only meaningful when requestSandboxBypass is true.
5421    #[serde(skip_serializing_if = "Option::is_none")]
5422    pub request_sandbox_bypass_reason: Option<String>,
5423    /// Tool call ID that triggered this permission request
5424    #[serde(skip_serializing_if = "Option::is_none")]
5425    pub tool_call_id: Option<String>,
5426    /// URL to be fetched
5427    pub url: String,
5428}
5429
5430/// Bounded runtime attribution, independent of free-text rationale. Telemetry revalidates this vocabulary before standard collection.
5431#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5432#[serde(rename_all = "camelCase")]
5433pub struct PermissionApprovalEvaluation {
5434    /// Stage that produced this attribution.
5435    pub evaluation_stage: PermissionApprovalEvaluationEvaluationStage,
5436    /// Whether the request invoked the judge interface. A cached recommendation retains the original attempt fact. Omitted means unknown, including inherited outcomes.
5437    #[serde(skip_serializing_if = "Option::is_none")]
5438    pub judge_attempted: Option<bool>,
5439    /// Status of the local judge interface, not proof of a model network call.
5440    pub judge_status: PermissionApprovalEvaluationJudgeStatus,
5441    /// Machine-readable runtime gate reason, never a command, path or human rationale.
5442    pub reason_code: PermissionApprovalEvaluationReasonCode,
5443}
5444
5445/// Assisted-approval judge information attached to a permission request. Present only in assisted mode; its absence means the judge did not evaluate the request. The `recommendation` conveys the judge's disposition for this request.
5446///
5447/// <div class="warning">
5448///
5449/// **Experimental.** This type is part of an experimental wire-protocol surface
5450/// and may change or be removed in future SDK or CLI releases.
5451///
5452/// </div>
5453#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5454#[serde(rename_all = "camelCase")]
5455pub struct PermissionAssistedApproval {
5456    /// Runtime reason and judge-call metadata. Absent on older events; missing metadata means unknown, not that the judge was skipped.
5457    #[serde(skip_serializing_if = "Option::is_none")]
5458    pub evaluation: Option<PermissionApprovalEvaluation>,
5459    /// Classified cause of an `error` recommendation. Absent for every other recommendation.
5460    #[serde(skip_serializing_if = "Option::is_none")]
5461    pub failure_reason: Option<AssistedApprovalJudgeFailureReason>,
5462    /// Model id that produced the recommendation, when the judge was consulted and reported one. Absent for `excluded` (the judge was not consulted) and for failures that occurred before a model was selected.
5463    #[serde(skip_serializing_if = "Option::is_none")]
5464    pub model: Option<String>,
5465    /// Human-readable reason for the judge's recommendation, when available.
5466    #[serde(skip_serializing_if = "Option::is_none")]
5467    pub reason: Option<String>,
5468    /// The assisted-approval safety judge's outcome for this request.
5469    pub recommendation: AssistedApprovalRecommendation,
5470}
5471
5472/// Memory operation permission request
5473#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5474#[serde(rename_all = "camelCase")]
5475pub struct PermissionRequestMemory {
5476    /// Whether this is a store or vote memory operation
5477    #[serde(skip_serializing_if = "Option::is_none")]
5478    pub action: Option<PermissionRequestMemoryAction>,
5479    /// Assisted-approval judge information for this request; present only in assisted mode.
5480    ///
5481    /// <div class="warning">
5482    ///
5483    /// **Experimental.** This type is part of an experimental wire-protocol surface
5484    /// and may change or be removed in future SDK or CLI releases.
5485    ///
5486    /// </div>
5487    #[serde(skip_serializing_if = "Option::is_none")]
5488    pub assisted_approval: Option<PermissionAssistedApproval>,
5489    /// Source references for the stored fact (store only)
5490    #[serde(skip_serializing_if = "Option::is_none")]
5491    pub citations: Option<String>,
5492    /// Vote direction (vote only)
5493    #[serde(skip_serializing_if = "Option::is_none")]
5494    pub direction: Option<PermissionRequestMemoryDirection>,
5495    /// The fact being stored or voted on
5496    pub fact: String,
5497    /// Permission kind discriminator
5498    pub kind: PermissionRequestMemoryKind,
5499    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5500    #[serde(skip_serializing_if = "Option::is_none")]
5501    pub managed_approval_required: Option<bool>,
5502    /// Reason for the vote (vote only)
5503    #[serde(skip_serializing_if = "Option::is_none")]
5504    pub reason: Option<String>,
5505    /// Repository name with owner associated with the stored memory (store only)
5506    #[serde(skip_serializing_if = "Option::is_none")]
5507    pub repo_nwo: Option<String>,
5508    /// Scope of the stored memory (store only)
5509    #[serde(skip_serializing_if = "Option::is_none")]
5510    pub scope: Option<PermissionRequestMemoryScope>,
5511    /// Topic or subject of the memory (store only)
5512    #[serde(skip_serializing_if = "Option::is_none")]
5513    pub subject: Option<String>,
5514    /// Tool call ID that triggered this permission request
5515    #[serde(skip_serializing_if = "Option::is_none")]
5516    pub tool_call_id: Option<String>,
5517}
5518
5519/// Custom tool invocation permission request
5520#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5521#[serde(rename_all = "camelCase")]
5522pub struct PermissionRequestCustomTool {
5523    /// Arguments to pass to the custom tool
5524    #[serde(skip_serializing_if = "Option::is_none")]
5525    pub args: Option<serde_json::Value>,
5526    /// Permission kind discriminator
5527    pub kind: PermissionRequestCustomToolKind,
5528    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5529    #[serde(skip_serializing_if = "Option::is_none")]
5530    pub managed_approval_required: Option<bool>,
5531    /// Whether the tool declared that permission may be skipped unless a deny rule matches
5532    #[serde(skip_serializing_if = "Option::is_none")]
5533    pub skip_permission: Option<bool>,
5534    /// Tool call ID that triggered this permission request
5535    #[serde(skip_serializing_if = "Option::is_none")]
5536    pub tool_call_id: Option<String>,
5537    /// Description of what the custom tool does
5538    pub tool_description: String,
5539    /// Name of the custom tool
5540    pub tool_name: String,
5541}
5542
5543/// Hook confirmation permission request
5544#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5545#[serde(rename_all = "camelCase")]
5546pub struct PermissionRequestHook {
5547    /// Optional message from the hook explaining why confirmation is needed
5548    #[serde(skip_serializing_if = "Option::is_none")]
5549    pub hook_message: Option<String>,
5550    /// Permission kind discriminator
5551    pub kind: PermissionRequestHookKind,
5552    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5553    #[serde(skip_serializing_if = "Option::is_none")]
5554    pub managed_approval_required: Option<bool>,
5555    /// Arguments of the tool call being gated
5556    #[serde(skip_serializing_if = "Option::is_none")]
5557    pub tool_args: Option<serde_json::Value>,
5558    /// Tool call ID that triggered this permission request
5559    #[serde(skip_serializing_if = "Option::is_none")]
5560    pub tool_call_id: Option<String>,
5561    /// Name of the tool the hook is gating
5562    pub tool_name: String,
5563}
5564
5565/// Extension management permission request
5566#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5567#[serde(rename_all = "camelCase")]
5568pub struct PermissionRequestExtensionManagement {
5569    /// Name of the extension being managed
5570    #[serde(skip_serializing_if = "Option::is_none")]
5571    pub extension_name: Option<String>,
5572    /// Permission kind discriminator
5573    pub kind: PermissionRequestExtensionManagementKind,
5574    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5575    #[serde(skip_serializing_if = "Option::is_none")]
5576    pub managed_approval_required: Option<bool>,
5577    /// The extension management operation (scaffold, reload)
5578    pub operation: String,
5579    /// Tool call ID that triggered this permission request
5580    #[serde(skip_serializing_if = "Option::is_none")]
5581    pub tool_call_id: Option<String>,
5582}
5583
5584/// A declared phase shown in a factory permission prompt.
5585#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5586#[serde(rename_all = "camelCase")]
5587pub struct FactoryPermissionPhase {
5588    /// Optional phase detail
5589    #[serde(skip_serializing_if = "Option::is_none")]
5590    pub detail: Option<String>,
5591    /// Phase title
5592    pub title: String,
5593}
5594
5595/// Factory run or authoring permission request
5596#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5597#[serde(rename_all = "camelCase")]
5598pub struct PermissionRequestFactory {
5599    /// Canonical key used for scoped factory approvals
5600    pub approval_key: String,
5601    /// Whether this factory is eligible for persistent approval
5602    pub can_persist_approval: bool,
5603    /// Factory-declared AI-credit limit before any run/resume caller override is applied.
5604    #[serde(skip_serializing_if = "Option::is_none")]
5605    pub declared_max_ai_credits: Option<f64>,
5606    /// Factory-declared concurrent-subagent limit before any run/resume caller override is applied.
5607    #[serde(skip_serializing_if = "Option::is_none")]
5608    pub declared_max_concurrent_subagents: Option<i64>,
5609    /// Factory-declared total-subagent limit before any run/resume caller override is applied.
5610    #[serde(skip_serializing_if = "Option::is_none")]
5611    pub declared_max_total_subagents: Option<i64>,
5612    /// Factory-declared active-time limit in seconds before any run/resume caller override is applied.
5613    #[serde(skip_serializing_if = "Option::is_none")]
5614    pub declared_timeout_seconds: Option<f64>,
5615    /// Factory description
5616    pub description: String,
5617    /// Permission kind discriminator
5618    pub kind: PermissionRequestFactoryKind,
5619    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5620    #[serde(skip_serializing_if = "Option::is_none")]
5621    pub managed_approval_required: Option<bool>,
5622    /// Effective AI-credit limit; omitted means unlimited
5623    #[serde(skip_serializing_if = "Option::is_none")]
5624    pub max_ai_credits: Option<f64>,
5625    /// Effective concurrent-subagent limit; omitted means unlimited
5626    #[serde(skip_serializing_if = "Option::is_none")]
5627    pub max_concurrent_subagents: Option<i64>,
5628    /// Effective total-subagent limit; omitted means unlimited
5629    #[serde(skip_serializing_if = "Option::is_none")]
5630    pub max_total_subagents: Option<i64>,
5631    /// Factory name
5632    pub name: String,
5633    /// Factory operation, either run or author
5634    pub operation: FactoryPermissionOperation,
5635    /// Declared factory phases
5636    pub phases: Vec<FactoryPermissionPhase>,
5637    /// Effective active-time limit in seconds; omitted means unlimited
5638    #[serde(skip_serializing_if = "Option::is_none")]
5639    pub timeout_seconds: Option<f64>,
5640    /// Tool call ID that triggered this permission request
5641    #[serde(skip_serializing_if = "Option::is_none")]
5642    pub tool_call_id: Option<String>,
5643}
5644
5645/// Extension permission access request
5646#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5647#[serde(rename_all = "camelCase")]
5648pub struct PermissionRequestExtensionPermissionAccess {
5649    /// Capabilities the extension is requesting
5650    pub capabilities: Vec<String>,
5651    /// Name of the extension requesting permission access
5652    pub extension_name: String,
5653    /// Permission kind discriminator
5654    pub kind: PermissionRequestExtensionPermissionAccessKind,
5655    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5656    #[serde(skip_serializing_if = "Option::is_none")]
5657    pub managed_approval_required: Option<bool>,
5658    /// Tool call ID that triggered this permission request
5659    #[serde(skip_serializing_if = "Option::is_none")]
5660    pub tool_call_id: Option<String>,
5661}
5662
5663/// Extension sensitive environment variable access request
5664#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5665#[serde(rename_all = "camelCase")]
5666pub struct PermissionRequestExtensionEnvAccess {
5667    /// Names of the sensitive environment variables the extension is requesting. Values never appear here.
5668    pub environment_variables: Vec<String>,
5669    /// Name of the extension requesting environment variable access
5670    pub extension_name: String,
5671    /// Permission kind discriminator
5672    pub kind: PermissionRequestExtensionEnvAccessKind,
5673    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5674    #[serde(skip_serializing_if = "Option::is_none")]
5675    pub managed_approval_required: Option<bool>,
5676    /// Tool call ID that triggered this permission request
5677    #[serde(skip_serializing_if = "Option::is_none")]
5678    pub tool_call_id: Option<String>,
5679}
5680
5681/// Shell command permission prompt
5682#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5683#[serde(rename_all = "camelCase")]
5684pub struct PermissionPromptRequestCommands {
5685    /// Assisted-approval judge information for this request; present only in assisted mode.
5686    ///
5687    /// <div class="warning">
5688    ///
5689    /// **Experimental.** This type is part of an experimental wire-protocol surface
5690    /// and may change or be removed in future SDK or CLI releases.
5691    ///
5692    /// </div>
5693    #[serde(skip_serializing_if = "Option::is_none")]
5694    pub assisted_approval: Option<PermissionAssistedApproval>,
5695    /// Whether the UI can offer session-wide approval for this command pattern
5696    pub can_offer_session_approval: bool,
5697    /// Command identifiers covered by this approval prompt
5698    pub command_identifiers: Vec<String>,
5699    /// The complete shell command text to be executed
5700    pub full_command_text: String,
5701    /// Human-readable description of what the command intends to do
5702    pub intention: String,
5703    /// Prompt kind discriminator
5704    pub kind: PermissionPromptRequestCommandsKind,
5705    /// Whether managed policy requires a human response and forbids host auto-approval
5706    #[serde(skip_serializing_if = "Option::is_none")]
5707    pub managed_approval_required: Option<bool>,
5708    /// True when the shell command is requesting sandbox escalation. This is a request, not a grant.
5709    #[serde(skip_serializing_if = "Option::is_none")]
5710    pub request_sandbox_bypass: Option<bool>,
5711    /// Reason for the sandbox escalation request.
5712    #[serde(skip_serializing_if = "Option::is_none")]
5713    pub request_sandbox_bypass_reason: Option<String>,
5714    /// True when the escalation is a permissive retry that keeps the sandbox and network policy attached while recording file and process accesses instead of blocking them.
5715    #[serde(skip_serializing_if = "Option::is_none")]
5716    pub request_sandbox_permissive: Option<bool>,
5717    /// Tool call ID that triggered this permission request
5718    #[serde(skip_serializing_if = "Option::is_none")]
5719    pub tool_call_id: Option<String>,
5720    /// Optional warning message about risks of running this command
5721    #[serde(skip_serializing_if = "Option::is_none")]
5722    pub warning: Option<String>,
5723}
5724
5725/// File write permission prompt
5726#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5727#[serde(rename_all = "camelCase")]
5728pub struct PermissionPromptRequestWrite {
5729    /// Assisted-approval judge information for this request; present only in assisted mode.
5730    ///
5731    /// <div class="warning">
5732    ///
5733    /// **Experimental.** This type is part of an experimental wire-protocol surface
5734    /// and may change or be removed in future SDK or CLI releases.
5735    ///
5736    /// </div>
5737    #[serde(skip_serializing_if = "Option::is_none")]
5738    pub assisted_approval: Option<PermissionAssistedApproval>,
5739    /// Whether the UI can offer session-wide approval for file write operations
5740    pub can_offer_session_approval: bool,
5741    /// Unified diff showing the proposed changes
5742    pub diff: String,
5743    /// Path of the file being written to
5744    pub file_name: String,
5745    /// Human-readable description of the intended file change
5746    pub intention: String,
5747    /// Prompt kind discriminator
5748    pub kind: PermissionPromptRequestWriteKind,
5749    /// Whether managed policy requires a human response and forbids host auto-approval
5750    #[serde(skip_serializing_if = "Option::is_none")]
5751    pub managed_approval_required: Option<bool>,
5752    /// Complete new file contents for newly created files
5753    #[serde(skip_serializing_if = "Option::is_none")]
5754    pub new_file_contents: Option<String>,
5755    /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display fileName.
5756    ///
5757    /// <div class="warning">
5758    ///
5759    /// **Experimental.** This type is part of an experimental wire-protocol surface
5760    /// and may change or be removed in future SDK or CLI releases.
5761    ///
5762    /// </div>
5763    #[serde(skip_serializing_if = "Option::is_none")]
5764    pub resolved_path: Option<String>,
5765    /// Tool call ID that triggered this permission request
5766    #[serde(skip_serializing_if = "Option::is_none")]
5767    pub tool_call_id: Option<String>,
5768}
5769
5770/// File read permission prompt
5771#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5772#[serde(rename_all = "camelCase")]
5773pub struct PermissionPromptRequestRead {
5774    /// Assisted-approval judge information for this request; present only in assisted mode.
5775    ///
5776    /// <div class="warning">
5777    ///
5778    /// **Experimental.** This type is part of an experimental wire-protocol surface
5779    /// and may change or be removed in future SDK or CLI releases.
5780    ///
5781    /// </div>
5782    #[serde(skip_serializing_if = "Option::is_none")]
5783    pub assisted_approval: Option<PermissionAssistedApproval>,
5784    /// Human-readable description of why the file is being read
5785    pub intention: String,
5786    /// Prompt kind discriminator
5787    pub kind: PermissionPromptRequestReadKind,
5788    /// Whether managed policy requires a human response and forbids host auto-approval
5789    #[serde(skip_serializing_if = "Option::is_none")]
5790    pub managed_approval_required: Option<bool>,
5791    /// Path of the file or directory being read
5792    pub path: String,
5793    /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display path.
5794    ///
5795    /// <div class="warning">
5796    ///
5797    /// **Experimental.** This type is part of an experimental wire-protocol surface
5798    /// and may change or be removed in future SDK or CLI releases.
5799    ///
5800    /// </div>
5801    #[serde(skip_serializing_if = "Option::is_none")]
5802    pub resolved_path: Option<String>,
5803    /// Tool call ID that triggered this permission request
5804    #[serde(skip_serializing_if = "Option::is_none")]
5805    pub tool_call_id: Option<String>,
5806}
5807
5808/// MCP tool invocation permission prompt
5809#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5810#[serde(rename_all = "camelCase")]
5811pub struct PermissionPromptRequestMcp {
5812    /// Arguments to pass to the MCP tool
5813    #[serde(skip_serializing_if = "Option::is_none")]
5814    pub args: Option<serde_json::Value>,
5815    /// Assisted-approval judge information for this request; present only in assisted mode.
5816    ///
5817    /// <div class="warning">
5818    ///
5819    /// **Experimental.** This type is part of an experimental wire-protocol surface
5820    /// and may change or be removed in future SDK or CLI releases.
5821    ///
5822    /// </div>
5823    #[serde(skip_serializing_if = "Option::is_none")]
5824    pub assisted_approval: Option<PermissionAssistedApproval>,
5825    /// Whether the host may offer a server-wide "approve all tools from this server" blanket. Absent is treated as true; the runtime sends false when managed policy disables bypass-permissions mode, which forbids the server-wide escalation while still allowing per-tool approval.
5826    #[serde(skip_serializing_if = "Option::is_none")]
5827    pub can_offer_server_wide_approval: Option<bool>,
5828    /// Prompt kind discriminator
5829    pub kind: PermissionPromptRequestMcpKind,
5830    /// Advisory runtime permission recommendation. The host remains responsible for deciding the request and may reject it.
5831    ///
5832    /// <div class="warning">
5833    ///
5834    /// **Experimental.** This type is part of an experimental wire-protocol surface
5835    /// and may change or be removed in future SDK or CLI releases.
5836    ///
5837    /// </div>
5838    #[serde(skip_serializing_if = "Option::is_none")]
5839    pub permission_recommendation: Option<PermissionRecommendation>,
5840    /// Name of the MCP server providing the tool
5841    pub server_name: String,
5842    /// Tool call ID that triggered this permission request
5843    #[serde(skip_serializing_if = "Option::is_none")]
5844    pub tool_call_id: Option<String>,
5845    /// Internal name of the MCP tool
5846    pub tool_name: String,
5847    /// Human-readable title of the MCP tool
5848    pub tool_title: String,
5849}
5850
5851/// URL access permission prompt
5852#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5853#[serde(rename_all = "camelCase")]
5854pub struct PermissionPromptRequestUrl {
5855    /// Assisted-approval judge information for this request; present only in assisted mode.
5856    ///
5857    /// <div class="warning">
5858    ///
5859    /// **Experimental.** This type is part of an experimental wire-protocol surface
5860    /// and may change or be removed in future SDK or CLI releases.
5861    ///
5862    /// </div>
5863    #[serde(skip_serializing_if = "Option::is_none")]
5864    pub assisted_approval: Option<PermissionAssistedApproval>,
5865    /// Human-readable description of why the URL is being accessed
5866    pub intention: String,
5867    /// Prompt kind discriminator
5868    pub kind: PermissionPromptRequestUrlKind,
5869    /// Whether managed policy requires a human response and forbids host auto-approval
5870    #[serde(skip_serializing_if = "Option::is_none")]
5871    pub managed_approval_required: Option<bool>,
5872    /// Immediately preceding URL when this prompt is for a redirect target
5873    #[serde(skip_serializing_if = "Option::is_none")]
5874    pub redirected_from: Option<String>,
5875    /// True when the tool is asking to run this URL fetch outside the sandbox, after the network policy denied the approved URL or the sandbox proxy could not reach it (host opted in via sandbox.allowBypass). The model cannot ask for this; only the tool raises it. This is a request, not a grant: the fetch runs only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
5876    #[serde(skip_serializing_if = "Option::is_none")]
5877    pub request_sandbox_bypass: Option<bool>,
5878    /// What the tool tells the user about the bypass on offer: which policy rule blocked the call, or why it cannot be sandboxed. Only meaningful when requestSandboxBypass is true.
5879    #[serde(skip_serializing_if = "Option::is_none")]
5880    pub request_sandbox_bypass_reason: Option<String>,
5881    /// Tool call ID that triggered this permission request
5882    #[serde(skip_serializing_if = "Option::is_none")]
5883    pub tool_call_id: Option<String>,
5884    /// URL to be fetched
5885    pub url: String,
5886}
5887
5888/// Memory operation permission prompt
5889#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5890#[serde(rename_all = "camelCase")]
5891pub struct PermissionPromptRequestMemory {
5892    /// Whether this is a store or vote memory operation
5893    #[serde(skip_serializing_if = "Option::is_none")]
5894    pub action: Option<PermissionRequestMemoryAction>,
5895    /// Assisted-approval judge information for this request; present only in assisted mode.
5896    ///
5897    /// <div class="warning">
5898    ///
5899    /// **Experimental.** This type is part of an experimental wire-protocol surface
5900    /// and may change or be removed in future SDK or CLI releases.
5901    ///
5902    /// </div>
5903    #[serde(skip_serializing_if = "Option::is_none")]
5904    pub assisted_approval: Option<PermissionAssistedApproval>,
5905    /// Source references for the stored fact (store only)
5906    #[serde(skip_serializing_if = "Option::is_none")]
5907    pub citations: Option<String>,
5908    /// Vote direction (vote only)
5909    #[serde(skip_serializing_if = "Option::is_none")]
5910    pub direction: Option<PermissionRequestMemoryDirection>,
5911    /// The fact being stored or voted on
5912    pub fact: String,
5913    /// Prompt kind discriminator
5914    pub kind: PermissionPromptRequestMemoryKind,
5915    /// Reason for the vote (vote only)
5916    #[serde(skip_serializing_if = "Option::is_none")]
5917    pub reason: Option<String>,
5918    /// Topic or subject of the memory (store only)
5919    #[serde(skip_serializing_if = "Option::is_none")]
5920    pub subject: Option<String>,
5921    /// Tool call ID that triggered this permission request
5922    #[serde(skip_serializing_if = "Option::is_none")]
5923    pub tool_call_id: Option<String>,
5924}
5925
5926/// Custom tool invocation permission prompt
5927#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5928#[serde(rename_all = "camelCase")]
5929pub struct PermissionPromptRequestCustomTool {
5930    /// Arguments to pass to the custom tool
5931    #[serde(skip_serializing_if = "Option::is_none")]
5932    pub args: Option<serde_json::Value>,
5933    /// Assisted-approval judge information for this request; present only in assisted mode.
5934    ///
5935    /// <div class="warning">
5936    ///
5937    /// **Experimental.** This type is part of an experimental wire-protocol surface
5938    /// and may change or be removed in future SDK or CLI releases.
5939    ///
5940    /// </div>
5941    #[serde(skip_serializing_if = "Option::is_none")]
5942    pub assisted_approval: Option<PermissionAssistedApproval>,
5943    /// Prompt kind discriminator
5944    pub kind: PermissionPromptRequestCustomToolKind,
5945    /// Tool call ID that triggered this permission request
5946    #[serde(skip_serializing_if = "Option::is_none")]
5947    pub tool_call_id: Option<String>,
5948    /// Description of what the custom tool does
5949    pub tool_description: String,
5950    /// Name of the custom tool
5951    pub tool_name: String,
5952}
5953
5954/// Path access permission prompt
5955#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5956#[serde(rename_all = "camelCase")]
5957pub struct PermissionPromptRequestPath {
5958    /// Underlying permission kind that needs path approval
5959    pub access_kind: PermissionPromptRequestPathAccessKind,
5960    /// Assisted-approval judge information for this request; present only in assisted mode.
5961    ///
5962    /// <div class="warning">
5963    ///
5964    /// **Experimental.** This type is part of an experimental wire-protocol surface
5965    /// and may change or be removed in future SDK or CLI releases.
5966    ///
5967    /// </div>
5968    #[serde(skip_serializing_if = "Option::is_none")]
5969    pub assisted_approval: Option<PermissionAssistedApproval>,
5970    /// Prompt kind discriminator
5971    pub kind: PermissionPromptRequestPathKind,
5972    /// File paths that require explicit approval
5973    pub paths: Vec<String>,
5974    /// Tool call ID that triggered this permission request
5975    #[serde(skip_serializing_if = "Option::is_none")]
5976    pub tool_call_id: Option<String>,
5977}
5978
5979/// Hook confirmation permission prompt
5980#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5981#[serde(rename_all = "camelCase")]
5982pub struct PermissionPromptRequestHook {
5983    /// Assisted-approval judge information for this request; present only in assisted mode.
5984    ///
5985    /// <div class="warning">
5986    ///
5987    /// **Experimental.** This type is part of an experimental wire-protocol surface
5988    /// and may change or be removed in future SDK or CLI releases.
5989    ///
5990    /// </div>
5991    #[serde(skip_serializing_if = "Option::is_none")]
5992    pub assisted_approval: Option<PermissionAssistedApproval>,
5993    /// Optional message from the hook explaining why confirmation is needed
5994    #[serde(skip_serializing_if = "Option::is_none")]
5995    pub hook_message: Option<String>,
5996    /// Prompt kind discriminator
5997    pub kind: PermissionPromptRequestHookKind,
5998    /// Arguments of the tool call being gated
5999    #[serde(skip_serializing_if = "Option::is_none")]
6000    pub tool_args: Option<serde_json::Value>,
6001    /// Tool call ID that triggered this permission request
6002    #[serde(skip_serializing_if = "Option::is_none")]
6003    pub tool_call_id: Option<String>,
6004    /// Name of the tool the hook is gating
6005    pub tool_name: String,
6006}
6007
6008/// Extension management permission prompt
6009#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6010#[serde(rename_all = "camelCase")]
6011pub struct PermissionPromptRequestExtensionManagement {
6012    /// Assisted-approval judge information for this request; present only in assisted mode.
6013    ///
6014    /// <div class="warning">
6015    ///
6016    /// **Experimental.** This type is part of an experimental wire-protocol surface
6017    /// and may change or be removed in future SDK or CLI releases.
6018    ///
6019    /// </div>
6020    #[serde(skip_serializing_if = "Option::is_none")]
6021    pub assisted_approval: Option<PermissionAssistedApproval>,
6022    /// Name of the extension being managed
6023    #[serde(skip_serializing_if = "Option::is_none")]
6024    pub extension_name: Option<String>,
6025    /// Prompt kind discriminator
6026    pub kind: PermissionPromptRequestExtensionManagementKind,
6027    /// The extension management operation (scaffold, reload)
6028    pub operation: String,
6029    /// Tool call ID that triggered this permission request
6030    #[serde(skip_serializing_if = "Option::is_none")]
6031    pub tool_call_id: Option<String>,
6032}
6033
6034/// Factory run or authoring permission prompt
6035#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6036#[serde(rename_all = "camelCase")]
6037pub struct PermissionPromptRequestFactory {
6038    /// Canonical key used for scoped factory approvals
6039    pub approval_key: String,
6040    /// Assisted-approval judge information for this request; present only in assisted mode.
6041    ///
6042    /// <div class="warning">
6043    ///
6044    /// **Experimental.** This type is part of an experimental wire-protocol surface
6045    /// and may change or be removed in future SDK or CLI releases.
6046    ///
6047    /// </div>
6048    #[serde(skip_serializing_if = "Option::is_none")]
6049    pub assisted_approval: Option<PermissionAssistedApproval>,
6050    /// Whether this factory is eligible for persistent approval
6051    pub can_persist_approval: bool,
6052    /// Factory-declared AI-credit limit before any run/resume caller override is applied.
6053    #[serde(skip_serializing_if = "Option::is_none")]
6054    pub declared_max_ai_credits: Option<f64>,
6055    /// Factory-declared concurrent-subagent limit before any run/resume caller override is applied.
6056    #[serde(skip_serializing_if = "Option::is_none")]
6057    pub declared_max_concurrent_subagents: Option<i64>,
6058    /// Factory-declared total-subagent limit before any run/resume caller override is applied.
6059    #[serde(skip_serializing_if = "Option::is_none")]
6060    pub declared_max_total_subagents: Option<i64>,
6061    /// Factory-declared active-time limit in seconds before any run/resume caller override is applied.
6062    #[serde(skip_serializing_if = "Option::is_none")]
6063    pub declared_timeout_seconds: Option<f64>,
6064    /// Factory description
6065    pub description: String,
6066    /// Prompt kind discriminator
6067    pub kind: PermissionPromptRequestFactoryKind,
6068    /// Whether managed policy requires a human response and forbids host auto-approval
6069    #[serde(skip_serializing_if = "Option::is_none")]
6070    pub managed_approval_required: Option<bool>,
6071    /// Effective AI-credit limit; omitted means unlimited
6072    #[serde(skip_serializing_if = "Option::is_none")]
6073    pub max_ai_credits: Option<f64>,
6074    /// Effective concurrent-subagent limit; omitted means unlimited
6075    #[serde(skip_serializing_if = "Option::is_none")]
6076    pub max_concurrent_subagents: Option<i64>,
6077    /// Effective total-subagent limit; omitted means unlimited
6078    #[serde(skip_serializing_if = "Option::is_none")]
6079    pub max_total_subagents: Option<i64>,
6080    /// Factory name
6081    pub name: String,
6082    /// Factory operation, either run or author
6083    pub operation: FactoryPermissionOperation,
6084    /// Declared factory phases
6085    pub phases: Vec<FactoryPermissionPhase>,
6086    /// Effective active-time limit in seconds; omitted means unlimited
6087    #[serde(skip_serializing_if = "Option::is_none")]
6088    pub timeout_seconds: Option<f64>,
6089    /// Tool call ID that triggered this permission request
6090    #[serde(skip_serializing_if = "Option::is_none")]
6091    pub tool_call_id: Option<String>,
6092}
6093
6094/// Extension permission access prompt
6095#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6096#[serde(rename_all = "camelCase")]
6097pub struct PermissionPromptRequestExtensionPermissionAccess {
6098    /// Assisted-approval judge information for this request; present only in assisted mode.
6099    ///
6100    /// <div class="warning">
6101    ///
6102    /// **Experimental.** This type is part of an experimental wire-protocol surface
6103    /// and may change or be removed in future SDK or CLI releases.
6104    ///
6105    /// </div>
6106    #[serde(skip_serializing_if = "Option::is_none")]
6107    pub assisted_approval: Option<PermissionAssistedApproval>,
6108    /// Capabilities the extension is requesting
6109    pub capabilities: Vec<String>,
6110    /// Name of the extension requesting permission access
6111    pub extension_name: String,
6112    /// Prompt kind discriminator
6113    pub kind: PermissionPromptRequestExtensionPermissionAccessKind,
6114    /// Tool call ID that triggered this permission request
6115    #[serde(skip_serializing_if = "Option::is_none")]
6116    pub tool_call_id: Option<String>,
6117}
6118
6119/// Extension sensitive environment variable access prompt
6120#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6121#[serde(rename_all = "camelCase")]
6122pub struct PermissionPromptRequestExtensionEnvAccess {
6123    /// Assisted-approval judge information for this request; present only in assisted mode.
6124    ///
6125    /// <div class="warning">
6126    ///
6127    /// **Experimental.** This type is part of an experimental wire-protocol surface
6128    /// and may change or be removed in future SDK or CLI releases.
6129    ///
6130    /// </div>
6131    #[serde(skip_serializing_if = "Option::is_none")]
6132    pub assisted_approval: Option<PermissionAssistedApproval>,
6133    /// Names of the sensitive environment variables the extension is requesting. Values never appear here.
6134    pub environment_variables: Vec<String>,
6135    /// Name of the extension requesting environment variable access
6136    pub extension_name: String,
6137    /// Prompt kind discriminator
6138    pub kind: PermissionPromptRequestExtensionEnvAccessKind,
6139    /// Tool call ID that triggered this permission request
6140    #[serde(skip_serializing_if = "Option::is_none")]
6141    pub tool_call_id: Option<String>,
6142}
6143
6144/// Session event "permission.requested". Permission request notification requiring client approval with request details
6145#[derive(Debug, Clone, Serialize, Deserialize)]
6146#[serde(rename_all = "camelCase")]
6147pub struct PermissionRequestedData {
6148    /// Agent mode captured from the owning turn when permission evaluation began.
6149    #[serde(skip_serializing_if = "Option::is_none")]
6150    pub agent_mode: Option<SessionMode>,
6151    /// Permission mode captured when evaluation began. Absent on historical events.
6152    #[serde(skip_serializing_if = "Option::is_none")]
6153    pub permission_mode: Option<PermissionMode>,
6154    /// Details of the permission being requested
6155    pub permission_request: PermissionRequest,
6156    /// Derived user-facing permission prompt details for UI consumers
6157    #[serde(skip_serializing_if = "Option::is_none")]
6158    pub prompt_request: Option<PermissionPromptRequest>,
6159    /// Permission-recovery episode that authorized this request to surface for interactive attention
6160    #[serde(skip_serializing_if = "Option::is_none")]
6161    pub recovery_episode_id: Option<String>,
6162    /// Unique identifier for this permission request; used to respond via session.respondToPermission()
6163    pub request_id: RequestId,
6164    /// When true, this permission was already resolved by a permissionRequest hook and requires no client action
6165    #[serde(skip_serializing_if = "Option::is_none")]
6166    pub resolved_by_hook: Option<bool>,
6167    /// Neutral risk metadata supplied by the tool host. Consumers may display this value but must not use it to bypass the permission decision.
6168    #[serde(skip_serializing_if = "Option::is_none")]
6169    pub risk_assessment: Option<serde_json::Value>,
6170}
6171
6172/// Permission response variant indicating the request was approved without persisting an approval rule.
6173#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6174#[serde(rename_all = "camelCase")]
6175pub struct PermissionApproved {
6176    /// The permission request was approved
6177    pub kind: PermissionApprovedKind,
6178    /// Whether a managed approval policy already handled this request
6179    #[serde(skip_serializing_if = "Option::is_none")]
6180    pub managed_approval_handled: Option<bool>,
6181}
6182
6183/// Session-scoped tool-approval rule for specific shell command identifiers.
6184#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6185#[serde(rename_all = "camelCase")]
6186pub struct UserToolSessionApprovalCommands {
6187    /// Command identifiers approved by the user
6188    pub command_identifiers: Vec<String>,
6189    /// Command approval kind
6190    pub kind: UserToolSessionApprovalCommandsKind,
6191}
6192
6193/// Session-scoped tool-approval rule for read-only filesystem operations.
6194#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6195#[serde(rename_all = "camelCase")]
6196pub struct UserToolSessionApprovalRead {
6197    /// Read approval kind
6198    pub kind: UserToolSessionApprovalReadKind,
6199}
6200
6201/// Session-scoped tool-approval rule for filesystem write operations.
6202#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6203#[serde(rename_all = "camelCase")]
6204pub struct UserToolSessionApprovalWrite {
6205    /// Write approval kind
6206    pub kind: UserToolSessionApprovalWriteKind,
6207}
6208
6209/// Session-scoped tool-approval rule for an MCP server tool, or all tools on the server when `toolName` is null.
6210#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6211#[serde(rename_all = "camelCase")]
6212pub struct UserToolSessionApprovalMcp {
6213    /// MCP tool approval kind
6214    pub kind: UserToolSessionApprovalMcpKind,
6215    /// MCP server name
6216    pub server_name: String,
6217    /// Optional MCP tool name, or null for all tools on the server
6218    pub tool_name: Option<String>,
6219}
6220
6221/// Session-scoped tool-approval rule for writes to long-term memory.
6222#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6223#[serde(rename_all = "camelCase")]
6224pub struct UserToolSessionApprovalMemory {
6225    /// Memory approval kind
6226    pub kind: UserToolSessionApprovalMemoryKind,
6227}
6228
6229/// Session-scoped tool-approval rule for a custom tool, keyed by tool name.
6230#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6231#[serde(rename_all = "camelCase")]
6232pub struct UserToolSessionApprovalCustomTool {
6233    /// Custom tool approval kind
6234    pub kind: UserToolSessionApprovalCustomToolKind,
6235    /// Custom tool name
6236    pub tool_name: String,
6237}
6238
6239/// Session-scoped tool-approval rule for extension-management operations, optionally narrowed by operation.
6240#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6241#[serde(rename_all = "camelCase")]
6242pub struct UserToolSessionApprovalExtensionManagement {
6243    /// Extension management approval kind
6244    pub kind: UserToolSessionApprovalExtensionManagementKind,
6245    /// Optional operation identifier
6246    #[serde(skip_serializing_if = "Option::is_none")]
6247    pub operation: Option<String>,
6248}
6249
6250/// Session-scoped factory approval, optionally narrowed by approval key.
6251#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6252#[serde(rename_all = "camelCase")]
6253pub struct UserToolSessionApprovalFactory {
6254    /// Optional factory operation name or canonical approval key
6255    #[serde(skip_serializing_if = "Option::is_none")]
6256    pub approval_key: Option<String>,
6257    /// Factory approval kind
6258    pub kind: UserToolSessionApprovalFactoryKind,
6259}
6260
6261/// Session-scoped tool-approval rule for an extension's permission-gated capability access, keyed by extension name.
6262#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6263#[serde(rename_all = "camelCase")]
6264pub struct UserToolSessionApprovalExtensionPermissionAccess {
6265    /// Extension name
6266    pub extension_name: String,
6267    /// Extension permission access approval kind
6268    pub kind: UserToolSessionApprovalExtensionPermissionAccessKind,
6269}
6270
6271/// Session-scoped tool-approval rule for an extension's access to sensitive environment variables, keyed by extension name and the exact set of variable names.
6272#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6273#[serde(rename_all = "camelCase")]
6274pub struct UserToolSessionApprovalExtensionEnvAccess {
6275    /// Names of the sensitive environment variables this approval covers. Values are never persisted.
6276    pub environment_variables: Vec<String>,
6277    /// Extension name
6278    pub extension_name: String,
6279    /// Extension environment access approval kind
6280    pub kind: UserToolSessionApprovalExtensionEnvAccessKind,
6281}
6282
6283/// Permission response variant that approves a request and remembers the provided approval for the rest of the session.
6284#[derive(Debug, Clone, Serialize, Deserialize)]
6285#[serde(rename_all = "camelCase")]
6286pub struct PermissionApprovedForSession {
6287    /// The approval to add as a session-scoped rule
6288    pub approval: UserToolSessionApproval,
6289    /// Approved and remembered for the rest of the session
6290    pub kind: PermissionApprovedForSessionKind,
6291    /// Whether a managed approval policy already handled this request
6292    #[serde(skip_serializing_if = "Option::is_none")]
6293    pub managed_approval_handled: Option<bool>,
6294}
6295
6296/// Permission response variant that approves a request and persists the provided approval to a project location key.
6297#[derive(Debug, Clone, Serialize, Deserialize)]
6298#[serde(rename_all = "camelCase")]
6299pub struct PermissionApprovedForLocation {
6300    /// The approval to persist for this location
6301    pub approval: UserToolSessionApproval,
6302    /// Approved and persisted for this project location
6303    pub kind: PermissionApprovedForLocationKind,
6304    /// The location key (git root or cwd) to persist the approval to
6305    pub location_key: String,
6306    /// Whether a managed approval policy already handled this request
6307    #[serde(skip_serializing_if = "Option::is_none")]
6308    pub managed_approval_handled: Option<bool>,
6309}
6310
6311/// Permission response variant indicating the request was cancelled before use, with an optional reason.
6312#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6313#[serde(rename_all = "camelCase")]
6314pub struct PermissionCancelled {
6315    /// The permission request was cancelled before a response was used
6316    pub kind: PermissionCancelledKind,
6317    /// Optional explanation of why the request was cancelled
6318    #[serde(skip_serializing_if = "Option::is_none")]
6319    pub reason: Option<String>,
6320}
6321
6322/// A permission approval or denial rule matched against a tool request, identified by a rule kind with an optional argument value.
6323#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6324#[serde(rename_all = "camelCase")]
6325pub struct PermissionRule {
6326    /// Argument value matched against the request, or null when the rule kind has no argument (e.g. 'read', 'write', 'memory').
6327    pub argument: Option<String>,
6328    /// The rule kind, such as Shell or GitHubMCP
6329    pub kind: String,
6330}
6331
6332/// Permission response variant denied because matching approval rules explicitly blocked the request.
6333#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6334#[serde(rename_all = "camelCase")]
6335pub struct PermissionDeniedByRules {
6336    /// Denied because approval rules explicitly blocked it
6337    pub kind: PermissionDeniedByRulesKind,
6338    /// Rules that denied the request
6339    pub rules: Vec<PermissionRule>,
6340}
6341
6342/// Permission response variant denied because no approval rule matched and user confirmation was unavailable.
6343#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6344#[serde(rename_all = "camelCase")]
6345pub struct PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
6346    /// Denied because no approval rule matched and user confirmation was unavailable
6347    pub kind: PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind,
6348}
6349
6350/// Permission response variant denied in an interactive user prompt, with optional feedback and force-reject flag.
6351#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6352#[serde(rename_all = "camelCase")]
6353pub struct PermissionDeniedInteractivelyByUser {
6354    /// Optional feedback from the user explaining the denial
6355    #[serde(skip_serializing_if = "Option::is_none")]
6356    pub feedback: Option<String>,
6357    /// Whether to force-reject the current agent turn
6358    #[serde(skip_serializing_if = "Option::is_none")]
6359    pub force_reject: Option<bool>,
6360    /// Denied by the user during an interactive prompt
6361    pub kind: PermissionDeniedInteractivelyByUserKind,
6362}
6363
6364/// Permission response variant denying a path under content exclusion policy, with the path and message.
6365#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6366#[serde(rename_all = "camelCase")]
6367pub struct PermissionDeniedByContentExclusionPolicy {
6368    /// Denied by the organization's content exclusion policy
6369    pub kind: PermissionDeniedByContentExclusionPolicyKind,
6370    /// Human-readable explanation of why the path was excluded
6371    pub message: String,
6372    /// File path that triggered the exclusion
6373    pub path: String,
6374}
6375
6376/// Permission response variant denied by a permission-request hook, with optional message and interrupt flag.
6377#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6378#[serde(rename_all = "camelCase")]
6379pub struct PermissionDeniedByPermissionRequestHook {
6380    /// Whether to interrupt the current agent turn
6381    #[serde(skip_serializing_if = "Option::is_none")]
6382    pub interrupt: Option<bool>,
6383    /// Denied by a permission request hook registered by an extension or plugin
6384    pub kind: PermissionDeniedByPermissionRequestHookKind,
6385    /// Optional message from the hook explaining the denial
6386    #[serde(skip_serializing_if = "Option::is_none")]
6387    pub message: Option<String>,
6388}
6389
6390/// Session event "permission.completed". Permission request completion notification signaling UI dismissal
6391#[derive(Debug, Clone, Serialize, Deserialize)]
6392#[serde(rename_all = "camelCase")]
6393pub struct PermissionCompletedData {
6394    /// Atomic structured blocked outcome when this permission response ended an Autopilot recovery episode unsuccessfully
6395    #[serde(skip_serializing_if = "Option::is_none")]
6396    pub blocker: Option<TaskBlocker>,
6397    /// Who decided this permission request. Absent on completions recorded before this field existed, which consumers must treat as "not a human decision" rather than assuming one. Authorization records are minted only for `human_response`; an assisted-approval verdict, a host policy, an unattended fallback, and a hook resolution all produce the same `result` a person does, so this is the only field that distinguishes them.
6398    ///
6399    /// <div class="warning">
6400    ///
6401    /// **Experimental.** This type is part of an experimental wire-protocol surface
6402    /// and may change or be removed in future SDK or CLI releases.
6403    ///
6404    /// </div>
6405    #[serde(skip_serializing_if = "Option::is_none")]
6406    pub decision_source: Option<PermissionDecisionSource>,
6407    /// Permission-recovery episode settled by this response, when the request was escalated by Autopilot
6408    #[serde(skip_serializing_if = "Option::is_none")]
6409    pub recovery_episode_id: Option<String>,
6410    /// Request ID of the resolved permission request; clients should dismiss any UI for this request
6411    pub request_id: RequestId,
6412    /// The result of the permission request
6413    pub result: PermissionResult,
6414    /// Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
6415    #[serde(skip_serializing_if = "Option::is_none")]
6416    pub tool_call_id: Option<String>,
6417}
6418
6419/// Session event "permission.carriedForward". Records that a live authorization record from an earlier human decision in this session contained a permission proposal, so it ran without another prompt. This mints no authority: it accounts for one more effect against the prior grant, which is what lets a replayed session agree with the live one about how much of that grant is left.
6420///
6421/// <div class="warning">
6422///
6423/// **Experimental.** This type is part of an experimental wire-protocol surface
6424/// and may change or be removed in future SDK or CLI releases.
6425///
6426/// </div>
6427#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6428#[serde(rename_all = "camelCase")]
6429pub struct PermissionCarriedForwardData {
6430    /// Always `authorization_carry_forward`. Stated explicitly so a consumer reading this event cannot mistake it for a human, host-policy, or assisted-approval decision.
6431    ///
6432    /// <div class="warning">
6433    ///
6434    /// **Experimental.** This type is part of an experimental wire-protocol surface
6435    /// and may change or be removed in future SDK or CLI releases.
6436    ///
6437    /// </div>
6438    pub decision_source: PermissionDecisionSource,
6439    /// Identity of the prior authorization record that contained the proposal.
6440    ///
6441    /// <div class="warning">
6442    ///
6443    /// **Experimental.** This type is part of an experimental wire-protocol surface
6444    /// and may change or be removed in future SDK or CLI releases.
6445    ///
6446    /// </div>
6447    pub record_id: String,
6448    /// Authorization edge minted for this admission. Not a prompt id: no prompt was raised, so no client should expect a request with this id.
6449    ///
6450    /// <div class="warning">
6451    ///
6452    /// **Experimental.** This type is part of an experimental wire-protocol surface
6453    /// and may change or be removed in future SDK or CLI releases.
6454    ///
6455    /// </div>
6456    pub request_id: RequestId,
6457    /// Tool call this admission authorizes. Its execution receipts the prior grant, which is how a single-effect approval is spent rather than carried forward again.
6458    ///
6459    /// <div class="warning">
6460    ///
6461    /// **Experimental.** This type is part of an experimental wire-protocol surface
6462    /// and may change or be removed in future SDK or CLI releases.
6463    ///
6464    /// </div>
6465    pub tool_call_id: String,
6466}
6467
6468/// Session event "permission.messageAuthorization". Freezes one blinded, verbatim-verified authorization claim the runtime minted from a human user message, so a resumed session re-establishes the same grant deterministically instead of re-running the extraction model. This mints no authority on its own: it records what a blinded proposer pointed at and the trusted discriminator the runtime established, and deterministic establishment runs on replay. Persisted so recorded authority survives compaction and process resume.
6469///
6470/// <div class="warning">
6471///
6472/// **Experimental.** This type is part of an experimental wire-protocol surface
6473/// and may change or be removed in future SDK or CLI releases.
6474///
6475/// </div>
6476#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6477#[serde(rename_all = "camelCase")]
6478pub struct PermissionMessageAuthorizationData {
6479    /// The kind of effect authorized, as an action-class identifier.
6480    ///
6481    /// <div class="warning">
6482    ///
6483    /// **Experimental.** This type is part of an experimental wire-protocol surface
6484    /// and may change or be removed in future SDK or CLI releases.
6485    ///
6486    /// </div>
6487    pub action_class: String,
6488    /// Whether the claim granted or denied authority.
6489    ///
6490    /// <div class="warning">
6491    ///
6492    /// **Experimental.** This type is part of an experimental wire-protocol surface
6493    /// and may change or be removed in future SDK or CLI releases.
6494    ///
6495    /// </div>
6496    pub polarity: PermissionMessageAuthorizationPolarity,
6497    /// Deterministic identity of the record, derived from the turn and span offsets so re-extracting the same span mints nothing new.
6498    ///
6499    /// <div class="warning">
6500    ///
6501    /// **Experimental.** This type is part of an experimental wire-protocol surface
6502    /// and may change or be removed in future SDK or CLI releases.
6503    ///
6504    /// </div>
6505    pub record_id: String,
6506    /// End byte offset of the authorizing span within the turn.
6507    ///
6508    /// <div class="warning">
6509    ///
6510    /// **Experimental.** This type is part of an experimental wire-protocol surface
6511    /// and may change or be removed in future SDK or CLI releases.
6512    ///
6513    /// </div>
6514    pub span_end: i64,
6515    /// Start byte offset of the authorizing span within the turn.
6516    ///
6517    /// <div class="warning">
6518    ///
6519    /// **Experimental.** This type is part of an experimental wire-protocol surface
6520    /// and may change or be removed in future SDK or CLI releases.
6521    ///
6522    /// </div>
6523    pub span_start: i64,
6524    /// Concrete named targets that appear verbatim inside the span.
6525    ///
6526    /// <div class="warning">
6527    ///
6528    /// **Experimental.** This type is part of an experimental wire-protocol surface
6529    /// and may change or be removed in future SDK or CLI releases.
6530    ///
6531    /// </div>
6532    #[serde(skip_serializing_if = "Option::is_none")]
6533    pub target_members: Option<Vec<String>>,
6534    /// The task the permission is scoped to, when the human named one.
6535    ///
6536    /// <div class="warning">
6537    ///
6538    /// **Experimental.** This type is part of an experimental wire-protocol surface
6539    /// and may change or be removed in future SDK or CLI releases.
6540    ///
6541    /// </div>
6542    #[serde(skip_serializing_if = "Option::is_none")]
6543    pub task: Option<String>,
6544    /// The human turn the quoted span was read from.
6545    ///
6546    /// <div class="warning">
6547    ///
6548    /// **Experimental.** This type is part of an experimental wire-protocol surface
6549    /// and may change or be removed in future SDK or CLI releases.
6550    ///
6551    /// </div>
6552    pub turn_index: i64,
6553    /// The trusted version discriminator, when one exists. Exact shell-command grants carry the byte-identical commands grounded in the human span; world-derived classes carry a file object, remote tip, or runner only when that state was captured safely. An opaque object mirroring the runtime's adjacently-tagged resolution.
6554    ///
6555    /// <div class="warning">
6556    ///
6557    /// **Experimental.** This type is part of an experimental wire-protocol surface
6558    /// and may change or be removed in future SDK or CLI releases.
6559    ///
6560    /// </div>
6561    #[serde(skip_serializing_if = "Option::is_none")]
6562    pub world: Option<serde_json::Value>,
6563}
6564
6565/// Session event "permission.messageAuthorizationRead". Records that one human turn has been read by the blinded authorization proposer, whether or not it minted anything, so a resumed session does not re-run the extraction model on a turn the live session already read. Also records whether that pass activates ongoing extraction; contextual-assent-only passes do not, so unrelated future messages remain outside extraction.
6566///
6567/// <div class="warning">
6568///
6569/// **Experimental.** This type is part of an experimental wire-protocol surface
6570/// and may change or be removed in future SDK or CLI releases.
6571///
6572/// </div>
6573#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6574#[serde(rename_all = "camelCase")]
6575pub struct PermissionMessageAuthorizationReadData {
6576    /// Whether this read activates ongoing message-backed extraction. False for a contextual-assent-only pass while auto-approval is off, so unrelated future messages remain outside extraction.
6577    ///
6578    /// <div class="warning">
6579    ///
6580    /// **Experimental.** This type is part of an experimental wire-protocol surface
6581    /// and may change or be removed in future SDK or CLI releases.
6582    ///
6583    /// </div>
6584    #[serde(skip_serializing_if = "Option::is_none")]
6585    pub activates_extraction: Option<bool>,
6586    /// The human turn that was read by the proposer.
6587    ///
6588    /// <div class="warning">
6589    ///
6590    /// **Experimental.** This type is part of an experimental wire-protocol surface
6591    /// and may change or be removed in future SDK or CLI releases.
6592    ///
6593    /// </div>
6594    pub turn_index: i64,
6595}
6596
6597/// Session event "permission.messageAuthorizationDegraded". Records that message-backed authorization could not safely represent one human turn before compaction. The runtime may compact the original message after this marker is durable, but message-derived carry-forward and assisted auto-approval remain disabled for the rest of the session so subsequent commands continue through the ordinary permission prompt.
6598///
6599/// <div class="warning">
6600///
6601/// **Experimental.** This type is part of an experimental wire-protocol surface
6602/// and may change or be removed in future SDK or CLI releases.
6603///
6604/// </div>
6605#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6606#[serde(rename_all = "camelCase")]
6607pub struct PermissionMessageAuthorizationDegradedData {
6608    /// The human turn that could not be represented safely.
6609    ///
6610    /// <div class="warning">
6611    ///
6612    /// **Experimental.** This type is part of an experimental wire-protocol surface
6613    /// and may change or be removed in future SDK or CLI releases.
6614    ///
6615    /// </div>
6616    pub turn_index: i64,
6617}
6618
6619/// Session event "permission.assentDetected". Records that deterministic text recognition found likely assent in the human turn immediately following a root Autopilot permission request that was blocked because no interactive response was available. This event grants no authority; its model-facing projection only suggests retrying the unchanged operation.
6620///
6621/// <div class="warning">
6622///
6623/// **Experimental.** This type is part of an experimental wire-protocol surface
6624/// and may change or be removed in future SDK or CLI releases.
6625///
6626/// </div>
6627#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6628#[serde(rename_all = "camelCase")]
6629pub struct PermissionAssentDetectedData {
6630    /// Permission request the likely assent may refer to. The runtime derives this from the preceding durable blocker; the human message and extraction model do not choose it.
6631    ///
6632    /// <div class="warning">
6633    ///
6634    /// **Experimental.** This type is part of an experimental wire-protocol surface
6635    /// and may change or be removed in future SDK or CLI releases.
6636    ///
6637    /// </div>
6638    pub request_id: RequestId,
6639    /// Human turn whose text triggered the deterministic assent recognizer.
6640    ///
6641    /// <div class="warning">
6642    ///
6643    /// **Experimental.** This type is part of an experimental wire-protocol surface
6644    /// and may change or be removed in future SDK or CLI releases.
6645    ///
6646    /// </div>
6647    pub turn_index: i64,
6648}
6649
6650/// Session event "permission.contextualAuthorization". Freezes a blinded contextual authorization proposal whose verbatim human span was deterministically bound to the immediately preceding blocked permission request. The event carries no action fields; replay re-derives the exact action from the earlier permission request and mints a one-shot message grant only when the binding and span still verify.
6651///
6652/// <div class="warning">
6653///
6654/// **Experimental.** This type is part of an experimental wire-protocol surface
6655/// and may change or be removed in future SDK or CLI releases.
6656///
6657/// </div>
6658#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6659#[serde(rename_all = "camelCase")]
6660pub struct PermissionContextualAuthorizationData {
6661    /// Whether the contextual human span granted or denied authority.
6662    ///
6663    /// <div class="warning">
6664    ///
6665    /// **Experimental.** This type is part of an experimental wire-protocol surface
6666    /// and may change or be removed in future SDK or CLI releases.
6667    ///
6668    /// </div>
6669    pub polarity: PermissionMessageAuthorizationPolarity,
6670    /// Deterministic identity of the contextual message grant.
6671    ///
6672    /// <div class="warning">
6673    ///
6674    /// **Experimental.** This type is part of an experimental wire-protocol surface
6675    /// and may change or be removed in future SDK or CLI releases.
6676    ///
6677    /// </div>
6678    pub record_id: String,
6679    /// Original blocked permission request selected by deterministic event ordering, never by the extraction model.
6680    ///
6681    /// <div class="warning">
6682    ///
6683    /// **Experimental.** This type is part of an experimental wire-protocol surface
6684    /// and may change or be removed in future SDK or CLI releases.
6685    ///
6686    /// </div>
6687    pub request_id: RequestId,
6688    /// End byte offset of the contextual decision span within the turn.
6689    ///
6690    /// <div class="warning">
6691    ///
6692    /// **Experimental.** This type is part of an experimental wire-protocol surface
6693    /// and may change or be removed in future SDK or CLI releases.
6694    ///
6695    /// </div>
6696    pub span_end: i64,
6697    /// Start byte offset of the contextual decision span within the turn.
6698    ///
6699    /// <div class="warning">
6700    ///
6701    /// **Experimental.** This type is part of an experimental wire-protocol surface
6702    /// and may change or be removed in future SDK or CLI releases.
6703    ///
6704    /// </div>
6705    pub span_start: i64,
6706    /// Human turn containing the contextual decision.
6707    ///
6708    /// <div class="warning">
6709    ///
6710    /// **Experimental.** This type is part of an experimental wire-protocol surface
6711    /// and may change or be removed in future SDK or CLI releases.
6712    ///
6713    /// </div>
6714    pub turn_index: i64,
6715}
6716
6717/// Session event "user_input.requested". User input request notification with question and optional predefined choices
6718#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6719#[serde(rename_all = "camelCase")]
6720pub struct UserInputRequestedData {
6721    /// Whether the user can provide a free-form text response in addition to predefined choices
6722    #[serde(skip_serializing_if = "Option::is_none")]
6723    pub allow_freeform: Option<bool>,
6724    /// Predefined choices for the user to select from, if applicable
6725    #[serde(skip_serializing_if = "Option::is_none")]
6726    pub choices: Option<Vec<String>>,
6727    /// The question or prompt to present to the user
6728    pub question: String,
6729    /// Unique identifier for this input request; used to respond via session.respondToUserInput()
6730    pub request_id: RequestId,
6731    /// The LLM-assigned tool call ID that triggered this request; used by remote UIs to correlate responses
6732    #[serde(skip_serializing_if = "Option::is_none")]
6733    pub tool_call_id: Option<String>,
6734}
6735
6736/// Session event "user_input.completed". User input request completion with the user's response
6737#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6738#[serde(rename_all = "camelCase")]
6739pub struct UserInputCompletedData {
6740    /// The user's answer to the input request
6741    #[serde(skip_serializing_if = "Option::is_none")]
6742    pub answer: Option<String>,
6743    /// Request ID of the resolved user input request; clients should dismiss any UI for this request
6744    pub request_id: RequestId,
6745    /// Whether the answer was typed as free-form text rather than selected from choices
6746    #[serde(skip_serializing_if = "Option::is_none")]
6747    pub was_freeform: Option<bool>,
6748}
6749
6750/// JSON Schema describing the form fields to present to the user (form mode only)
6751#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6752#[serde(rename_all = "camelCase")]
6753pub struct ElicitationRequestedSchema {
6754    /// Form field definitions, keyed by field name
6755    pub properties: HashMap<String, serde_json::Value>,
6756    /// List of required field names
6757    #[serde(skip_serializing_if = "Option::is_none")]
6758    pub required: Option<Vec<String>>,
6759    /// Schema type indicator (always 'object')
6760    pub r#type: ElicitationRequestedSchemaType,
6761}
6762
6763/// Session event "elicitation.requested". Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
6764#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6765#[serde(rename_all = "camelCase")]
6766pub struct ElicitationRequestedData {
6767    /// The source that initiated the request (MCP server name, or absent for agent-initiated)
6768    #[serde(skip_serializing_if = "Option::is_none")]
6769    pub elicitation_source: Option<String>,
6770    /// Message describing what information is needed from the user
6771    pub message: String,
6772    /// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
6773    #[serde(skip_serializing_if = "Option::is_none")]
6774    pub mode: Option<ElicitationRequestedMode>,
6775    /// JSON Schema describing the form fields to present to the user (form mode only)
6776    #[serde(skip_serializing_if = "Option::is_none")]
6777    pub requested_schema: Option<ElicitationRequestedSchema>,
6778    /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation()
6779    pub request_id: RequestId,
6780    /// Tool call ID from the LLM completion; used to correlate with CompletionChunk.toolCall.id for remote UIs
6781    #[serde(skip_serializing_if = "Option::is_none")]
6782    pub tool_call_id: Option<String>,
6783    /// URL to open in the user's browser (url mode only)
6784    #[serde(skip_serializing_if = "Option::is_none")]
6785    pub url: Option<String>,
6786}
6787
6788/// Session event "elicitation.completed". Elicitation request completion with the user's response
6789#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6790#[serde(rename_all = "camelCase")]
6791pub struct ElicitationCompletedData {
6792    /// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
6793    #[serde(skip_serializing_if = "Option::is_none")]
6794    pub action: Option<ElicitationCompletedAction>,
6795    /// The submitted form data when action is 'accept'; keys match the requested schema fields
6796    #[serde(skip_serializing_if = "Option::is_none")]
6797    pub content: Option<HashMap<String, serde_json::Value>>,
6798    /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request
6799    pub request_id: RequestId,
6800}
6801
6802/// Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
6803#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6804#[serde(rename_all = "camelCase")]
6805pub struct SamplingRequestedData {
6806    /// The JSON-RPC request ID from the MCP protocol
6807    pub mcp_request_id: serde_json::Value,
6808    /// Unique identifier for this sampling request; used to respond via session.respondToSampling()
6809    pub request_id: RequestId,
6810    /// Name of the MCP server that initiated the sampling request
6811    pub server_name: String,
6812}
6813
6814/// Session event "sampling.completed". Sampling request completion notification signaling UI dismissal
6815#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6816#[serde(rename_all = "camelCase")]
6817pub struct SamplingCompletedData {
6818    /// Request ID of the resolved sampling request; clients should dismiss any UI for this request
6819    pub request_id: RequestId,
6820}
6821
6822/// Single HTTP header entry as a name/value pair.
6823#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6824#[serde(rename_all = "camelCase")]
6825pub struct HeaderEntry {
6826    /// HTTP response header name as observed by the runtime.
6827    pub name: String,
6828    /// HTTP response header value as observed by the runtime.
6829    pub value: String,
6830}
6831
6832/// Raw HTTP response details from the OAuth auth challenge, as observed by the runtime.
6833#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6834#[serde(rename_all = "camelCase")]
6835pub struct McpOauthHttpResponse {
6836    /// Complete UTF-8 response body for host-specific challenge handling, including an empty string for an empty body. Omitted when the complete body is not valid UTF-8; body read failures fail the HTTP operation rather than exposing a partial response.
6837    #[serde(skip_serializing_if = "Option::is_none")]
6838    pub body: Option<String>,
6839    /// HTTP response headers as observed by the runtime. Order and casing are transport-dependent, and duplicate header names may appear multiple times.
6840    pub headers: Vec<HeaderEntry>,
6841    /// HTTP status code returned with the auth challenge.
6842    pub status_code: i32,
6843}
6844
6845/// Static OAuth client configuration, if the server specifies one
6846#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6847#[serde(rename_all = "camelCase")]
6848pub struct McpOauthRequiredStaticClientConfig {
6849    /// OAuth client ID for the server
6850    pub client_id: String,
6851    /// Optional OAuth client secret for confidential static clients, when the runtime can resolve one
6852    #[serde(skip_serializing_if = "Option::is_none")]
6853    pub client_secret: Option<String>,
6854    /// Optional non-default OAuth grant type. When set to 'client_credentials', the OAuth flow runs headlessly using the client_id + keychain-stored secret (no browser, no callback server).
6855    #[serde(skip_serializing_if = "Option::is_none")]
6856    pub grant_type: Option<McpOauthRequiredStaticClientConfigGrantType>,
6857    /// Whether this is a public OAuth client
6858    #[serde(skip_serializing_if = "Option::is_none")]
6859    pub public_client: Option<bool>,
6860    /// Configured OAuth scope string used when the server challenge omits scope or provides an empty scope
6861    #[serde(skip_serializing_if = "Option::is_none")]
6862    pub scope: Option<String>,
6863}
6864
6865/// OAuth WWW-Authenticate parameters parsed from an MCP auth challenge
6866#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6867#[serde(rename_all = "camelCase")]
6868pub struct McpOauthWWWAuthenticateParams {
6869    /// OAuth error from the WWW-Authenticate error parameter, if present
6870    #[serde(skip_serializing_if = "Option::is_none")]
6871    pub error: Option<String>,
6872    /// Protected resource metadata URL from the WWW-Authenticate resource_metadata parameter, if present
6873    #[serde(skip_serializing_if = "Option::is_none")]
6874    pub resource_metadata_url: Option<String>,
6875    /// Requested OAuth scopes from the WWW-Authenticate scope parameter, if present
6876    #[serde(skip_serializing_if = "Option::is_none")]
6877    pub scope: Option<String>,
6878}
6879
6880/// Session event "mcp.oauth_required". OAuth authentication request for an MCP server
6881#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6882#[serde(rename_all = "camelCase")]
6883pub struct McpOauthRequiredData {
6884    /// Raw HTTP response details from the OAuth auth challenge, as observed by the runtime. Header order and casing are transport-dependent, and duplicate header names may appear multiple times.
6885    #[serde(skip_serializing_if = "Option::is_none")]
6886    pub http_response: Option<McpOauthHttpResponse>,
6887    /// Why the runtime is requesting host-provided OAuth credentials.
6888    pub reason: McpOauthRequestReason,
6889    /// Unique identifier for this OAuth request; used to respond via session.mcp.oauth.handlePendingRequest
6890    pub request_id: RequestId,
6891    /// Raw OAuth protected-resource metadata document fetched for the MCP server, if available
6892    #[serde(skip_serializing_if = "Option::is_none")]
6893    pub resource_metadata: Option<String>,
6894    /// Display name of the MCP server that requires OAuth
6895    pub server_name: String,
6896    /// URL of the MCP server that requires OAuth
6897    pub server_url: String,
6898    /// Static OAuth client configuration, if the server specifies one
6899    #[serde(skip_serializing_if = "Option::is_none")]
6900    pub static_client_config: Option<McpOauthRequiredStaticClientConfig>,
6901    /// OAuth WWW-Authenticate parameters parsed from the auth challenge, if available
6902    #[serde(skip_serializing_if = "Option::is_none")]
6903    pub www_authenticate_params: Option<McpOauthWWWAuthenticateParams>,
6904}
6905
6906/// Session event "mcp.oauth_completed". MCP OAuth request completion notification
6907#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6908#[serde(rename_all = "camelCase")]
6909pub struct McpOauthCompletedData {
6910    /// How the pending OAuth request was completed
6911    pub outcome: McpOauthCompletionOutcome,
6912    /// Request ID of the resolved OAuth request
6913    pub request_id: RequestId,
6914}
6915
6916/// Session event "mcp.headers_refresh_required". Dynamic headers refresh request for a remote MCP server
6917#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6918#[serde(rename_all = "camelCase")]
6919pub struct McpHeadersRefreshRequiredData {
6920    /// Why dynamic headers are being requested.
6921    pub reason: McpHeadersRefreshRequiredReason,
6922    /// Unique identifier for this headers refresh request; used to respond via session.mcp.headers.handlePendingHeadersRefreshRequest()
6923    pub request_id: RequestId,
6924    /// Display name of the remote MCP server requesting headers
6925    pub server_name: String,
6926    /// URL of the remote MCP server requesting headers
6927    pub server_url: String,
6928}
6929
6930/// Session event "mcp.headers_refresh_completed". MCP headers refresh request completion notification
6931#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6932#[serde(rename_all = "camelCase")]
6933pub struct McpHeadersRefreshCompletedData {
6934    /// How the pending MCP headers refresh request resolved.
6935    pub outcome: McpHeadersRefreshCompletedOutcome,
6936    /// Request ID of the resolved headers refresh request
6937    pub request_id: RequestId,
6938}
6939
6940/// Session event "session.custom_notification". Opaque custom notification data. Consumers may branch on source and name, but payload semantics are source-defined.
6941#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6942#[serde(rename_all = "camelCase")]
6943pub struct SessionCustomNotificationData {
6944    /// Source-defined custom notification name
6945    pub name: String,
6946    /// Source-defined JSON payload for the custom notification
6947    pub payload: serde_json::Value,
6948    /// Namespace for the custom notification producer
6949    pub source: String,
6950    /// Optional source-defined string identifiers describing the payload subject
6951    #[serde(skip_serializing_if = "Option::is_none")]
6952    pub subject: Option<HashMap<String, String>>,
6953    /// Optional source-defined payload schema version
6954    #[serde(skip_serializing_if = "Option::is_none")]
6955    pub version: Option<i64>,
6956}
6957
6958/// Session event "ui.ephemeral_query". Ordered output and terminal state for a transient query that does not modify conversation history.
6959///
6960/// <div class="warning">
6961///
6962/// **Experimental.** This type is part of an experimental wire-protocol surface
6963/// and may change or be removed in future SDK or CLI releases.
6964///
6965/// </div>
6966#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6967#[serde(rename_all = "camelCase")]
6968pub struct UiEphemeralQueryData {
6969    /// Full response text, present for the `completed` phase.
6970    #[serde(skip_serializing_if = "Option::is_none")]
6971    pub answer: Option<String>,
6972    /// Ordered text delta, present for the `chunk` phase.
6973    #[serde(skip_serializing_if = "Option::is_none")]
6974    pub chunk: Option<String>,
6975    /// Model or transport failure message, present for the `failed` phase.
6976    #[serde(skip_serializing_if = "Option::is_none")]
6977    pub error: Option<String>,
6978    /// Current query lifecycle phase.
6979    pub phase: UIEphemeralQueryPhase,
6980    /// Runtime-minted query identifier.
6981    pub request_id: RequestId,
6982}
6983
6984/// Session event "external_tool.requested". External tool invocation request for client-side tool execution
6985#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6986#[serde(rename_all = "camelCase")]
6987pub struct ExternalToolRequestedData {
6988    /// Arguments to pass to the external tool
6989    #[serde(skip_serializing_if = "Option::is_none")]
6990    pub arguments: Option<serde_json::Value>,
6991    /// Stable provider identity captured with an extension-owned tool definition; hosts use it to route the request to the same provider that was offered to the model
6992    #[serde(skip_serializing_if = "Option::is_none")]
6993    pub provider_id: Option<String>,
6994    /// Unique identifier for this request; used to respond via session.respondToExternalTool()
6995    pub request_id: RequestId,
6996    /// Session ID that this external tool request belongs to
6997    pub session_id: SessionId,
6998    /// Tool call ID assigned to this external tool invocation
6999    pub tool_call_id: String,
7000    /// Name of the external tool to invoke
7001    pub tool_name: String,
7002    /// W3C Trace Context traceparent header for the execute_tool span
7003    #[serde(skip_serializing_if = "Option::is_none")]
7004    pub traceparent: Option<String>,
7005    /// W3C Trace Context tracestate header for the execute_tool span
7006    #[serde(skip_serializing_if = "Option::is_none")]
7007    pub tracestate: Option<String>,
7008    /// Active session working directory, when known.
7009    #[serde(skip_serializing_if = "Option::is_none")]
7010    pub working_directory: Option<String>,
7011}
7012
7013/// Session event "external_tool.completed". External tool completion notification signaling UI dismissal
7014#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7015#[serde(rename_all = "camelCase")]
7016pub struct ExternalToolCompletedData {
7017    /// Request ID of the resolved external tool request; clients should dismiss any UI for this request
7018    pub request_id: RequestId,
7019}
7020
7021/// Session event "command.queued". Queued slash command dispatch request for client execution
7022#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7023#[serde(rename_all = "camelCase")]
7024pub struct CommandQueuedData {
7025    /// The slash command text to be executed (e.g., /help, /clear)
7026    pub command: String,
7027    /// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
7028    pub request_id: RequestId,
7029}
7030
7031/// Session event "command.execute". Registered command dispatch request routed to the owning client
7032#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7033#[serde(rename_all = "camelCase")]
7034pub struct CommandExecuteData {
7035    /// Raw argument string after the command name
7036    pub args: String,
7037    /// The full command text (e.g., /deploy production)
7038    pub command: String,
7039    /// Command name without leading /
7040    pub command_name: String,
7041    /// Unique identifier; used to respond via session.commands.handlePendingCommand()
7042    pub request_id: RequestId,
7043}
7044
7045/// Session event "command.completed". Queued command completion notification signaling UI dismissal
7046#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7047#[serde(rename_all = "camelCase")]
7048pub struct CommandCompletedData {
7049    /// Request ID of the resolved command request; clients should dismiss any UI for this request
7050    pub request_id: RequestId,
7051}
7052
7053/// Session event "auto_mode_switch.requested". Auto mode switch request notification requiring user approval
7054#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7055#[serde(rename_all = "camelCase")]
7056pub struct AutoModeSwitchRequestedData {
7057    /// The rate limit error code that triggered this request
7058    #[serde(skip_serializing_if = "Option::is_none")]
7059    pub error_code: Option<String>,
7060    /// Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
7061    pub request_id: RequestId,
7062    /// Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
7063    #[serde(skip_serializing_if = "Option::is_none")]
7064    pub retry_after_seconds: Option<i64>,
7065}
7066
7067/// Session event "auto_mode_switch.completed". Auto mode switch completion notification
7068#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7069#[serde(rename_all = "camelCase")]
7070pub struct AutoModeSwitchCompletedData {
7071    /// Request ID of the resolved request; clients should dismiss any UI for this request
7072    pub request_id: RequestId,
7073    /// The user's auto-mode-switch choice
7074    pub response: AutoModeSwitchResponse,
7075}
7076
7077/// Session event "session_limits_exhausted.requested". Session limit exhaustion notification requiring user action.
7078#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7079#[serde(rename_all = "camelCase")]
7080pub struct SessionLimitsExhaustedRequestedData {
7081    /// Configured max AI Credits for the current accounting window.
7082    pub max_ai_credits: f64,
7083    /// Unique identifier for this request; used to respond via session.ui.handlePendingSessionLimitsExhausted().
7084    pub request_id: RequestId,
7085    /// AI Credits already consumed in the current accounting window.
7086    pub used_ai_credits: f64,
7087}
7088
7089/// The user's selected action for an exhausted session limit.
7090#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7091#[serde(rename_all = "camelCase")]
7092pub struct SessionLimitsExhaustedResponse {
7093    /// Action selected by the user.
7094    pub action: SessionLimitsExhaustedResponseAction,
7095    /// AI Credits to add to the current max when action is 'add'.
7096    #[serde(skip_serializing_if = "Option::is_none")]
7097    pub additional_ai_credits: Option<f64>,
7098    /// New absolute max AI Credits when action is 'set'.
7099    #[serde(skip_serializing_if = "Option::is_none")]
7100    pub max_ai_credits: Option<f64>,
7101}
7102
7103/// Session event "session_limits_exhausted.completed". Session limit exhaustion prompt completion notification.
7104#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7105#[serde(rename_all = "camelCase")]
7106pub struct SessionLimitsExhaustedCompletedData {
7107    /// Request ID of the resolved request; clients should dismiss any UI for this request.
7108    pub request_id: RequestId,
7109    /// The user's selected session-limit action.
7110    pub response: SessionLimitsExhaustedResponse,
7111}
7112
7113/// Session event "session.auto_mode_resolved". Auto Intent resolution: the concrete model the session settled on for the first prompt of an auto-mode session, and why. Lets SDK clients render the chosen model and the full reason it was picked. The core selection fields (chosenModel/reasoningBucket/categoryScores) are stable; the routing-analytics fields (predictedLabel/confidence/candidateModels) mirror the upstream intent service and may evolve, hence the event's experimental stability.
7114///
7115/// <div class="warning">
7116///
7117/// **Experimental.** This type is part of an experimental wire-protocol surface
7118/// and may change or be removed in future SDK or CLI releases.
7119///
7120/// </div>
7121#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7122#[serde(rename_all = "camelCase")]
7123pub struct SessionAutoModeResolvedData {
7124    /// Models offered to the router for this resolution
7125    #[serde(skip_serializing_if = "Option::is_none")]
7126    pub available_models: Option<Vec<String>>,
7127    /// Ordered candidate model list the router returned, when not a fallback
7128    #[serde(skip_serializing_if = "Option::is_none")]
7129    pub candidate_models: Option<Vec<String>>,
7130    /// Per-category classifier scores (0-1) behind the bucket: the granular HYDRA capability scores (reasoning, code_gen, debugging, tool_use), or the binary needs_reasoning/no_reasoning scores when HYDRA didn't run. Lets clients show a breakdown rather than just the bucket.
7131    #[serde(skip_serializing_if = "Option::is_none")]
7132    pub category_scores: Option<HashMap<String, f64>>,
7133    /// The concrete model the session will use after any intent refinement
7134    pub chosen_model: String,
7135    /// The chosen model's score shortfall relative to the top candidate
7136    #[serde(skip_serializing_if = "Option::is_none")]
7137    pub chosen_shortfall: Option<f64>,
7138    /// Classifier confidence for the predicted label, when available
7139    #[serde(skip_serializing_if = "Option::is_none")]
7140    pub confidence: Option<f64>,
7141    /// End-to-end client wait time for the router request in milliseconds
7142    #[serde(skip_serializing_if = "Option::is_none")]
7143    pub end_to_end_latency_ms: Option<f64>,
7144    /// Whether the router fell back to the standard Auto selection
7145    #[serde(skip_serializing_if = "Option::is_none")]
7146    pub fallback: Option<bool>,
7147    /// Server-provided reason for falling back, when available
7148    #[serde(skip_serializing_if = "Option::is_none")]
7149    pub fallback_reason: Option<String>,
7150    /// Whether the routed prompt contained an image
7151    #[serde(skip_serializing_if = "Option::is_none")]
7152    pub has_image: Option<bool>,
7153    /// The predicted classifier label (e.g. `needs_reasoning`), when available
7154    #[serde(skip_serializing_if = "Option::is_none")]
7155    pub predicted_label: Option<String>,
7156    /// Coarse request-difficulty bucket, for explaining why a model was chosen ("picked X because this looks like high-reasoning work")
7157    #[serde(skip_serializing_if = "Option::is_none")]
7158    pub reasoning_bucket: Option<AutoModeResolvedReasoningBucket>,
7159    /// Server-reported router processing time in milliseconds
7160    #[serde(skip_serializing_if = "Option::is_none")]
7161    pub router_latency_ms: Option<f64>,
7162    /// The routing method the server applied, when Auto Intent ran
7163    #[serde(skip_serializing_if = "Option::is_none")]
7164    pub routing_method: Option<String>,
7165    /// Whether a sticky model choice overrode the router result
7166    #[serde(skip_serializing_if = "Option::is_none")]
7167    pub sticky_override: Option<bool>,
7168}
7169
7170/// Session event "session.managed_settings_resolved". Enterprise managed-settings resolution: the effective managed settings the session applied and which channels contributed, so SDK clients can show users what is enterprise-managed. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted. Device values take precedence over server values, then the policy helper, per ordinary key, while permissions compose restrictively across device, server, policy-helper, and SDK-client layers. The account-scoped `getManagedSettings()` API does not include session-local client injection. Marked experimental while the managed-settings surface stabilizes.
7171///
7172/// <div class="warning">
7173///
7174/// **Experimental.** This type is part of an experimental wire-protocol surface
7175/// and may change or be removed in future SDK or CLI releases.
7176///
7177/// </div>
7178#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7179#[serde(rename_all = "camelCase")]
7180pub struct SessionManagedSettingsResolvedData {
7181    /// Whether enterprise policy disables bypass-permissions ("yolo") mode for this session. Deny-wins across layers, and forced on when `failClosed` is true.
7182    pub bypass_permissions_disabled: bool,
7183    /// Whether a session-local permissions layer injected by the SDK host was present
7184    #[serde(skip_serializing_if = "Option::is_none")]
7185    pub client_managed: Option<bool>,
7186    /// Whether an actual device MDM/plist/registry/file managed-settings layer was present
7187    pub device_managed: bool,
7188    /// Whether managed policy could not be determined (e.g. a failed server fetch) and the session fell back to the fail-closed restriction. When true, restrictions such as disabling bypass-permissions are enforced even though `settings` may be absent.
7189    pub fail_closed: bool,
7190    /// The setting keys under enterprise management in the effective managed settings (e.g. `model`, `enabledPlugins`, `permissions`). Empty when no managed settings are in force.
7191    pub managed_keys: Vec<String>,
7192    /// Whether at least two managed sources supplied permission allowlists, so enforcement intersects them and the flattened settings payload omits `permissions.allow`.
7193    #[serde(skip_serializing_if = "Option::is_none")]
7194    pub permissions_allow_intersected: Option<bool>,
7195    /// Whether the policy-helper managed-settings layer was present. The policy helper is the weakest channel: it fills keys no enterprise source set and can never replace one.
7196    #[serde(skip_serializing_if = "Option::is_none")]
7197    pub policy_helper_managed: Option<bool>,
7198    /// Whether the effective sandbox policy forces the sandbox on *only* because managed policy could not be determined, rather than because the policy requires it. Lets clients tell a user whose `--no-sandbox` was overridden that the sandbox stayed on as a fail-closed fallback, instead of attributing it to an administrator who set no such policy.
7199    #[serde(skip_serializing_if = "Option::is_none")]
7200    pub sandbox_enabled_by_undetermined_policy: Option<bool>,
7201    /// Whether the server (account/org) managed-settings layer was present
7202    pub server_managed: bool,
7203    /// The effective (resolved) managed settings values, so clients can render exactly what is enforced. Absent when no managed policy is in force.
7204    #[serde(skip_serializing_if = "Option::is_none")]
7205    pub settings: Option<serde_json::Value>,
7206    /// Channel summary: `server`, `device`, `client`, or `policyHelper` when exactly one channel contributed; `mixed` when multiple channels contributed; otherwise `none`. Consult the per-channel booleans for exact provenance.
7207    pub source: ManagedSettingsResolvedSource,
7208}
7209
7210/// Session event "session.managed_settings_enforced". Runtime enforcement of enterprise managed settings: fires when the session blocks or caps a runtime action because enterprise policy governs it, so SDK clients can explain *why* an action was governed. Unlike `session.managed_settings_resolved` (which reports *what* is managed), this reports a concrete governed action — e.g. a user or host tried to turn on a bypass-permissions escalation while policy disables it. Emitted live (not persisted to the session event log) on user/host-initiated attempts only, never for silent policy application. Marked experimental while the managed-settings surface stabilizes.
7211///
7212/// <div class="warning">
7213///
7214/// **Experimental.** This type is part of an experimental wire-protocol surface
7215/// and may change or be removed in future SDK or CLI releases.
7216///
7217/// </div>
7218#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7219#[serde(rename_all = "camelCase")]
7220pub struct SessionManagedSettingsEnforcedData {
7221    /// The category of runtime action that managed policy governed.
7222    pub action: ManagedSettingsEnforcedAction,
7223    /// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused. Absent for actions without a specific escalation primitive.
7224    #[serde(skip_serializing_if = "Option::is_none")]
7225    pub escalation: Option<ManagedSettingsEnforcedEscalation>,
7226    /// Whether the enforcement was forced by fail-closed handling (managed policy could not be determined) rather than an explicit managed setting. When true, `setting` still names the restriction that was applied.
7227    pub fail_closed: bool,
7228    /// A human-readable explanation of why the action was governed, suitable for surfacing to the user.
7229    pub message: String,
7230    /// The managed setting key responsible for the enforcement (e.g. `permissions.disableBypassPermissionsMode`).
7231    pub setting: String,
7232}
7233
7234/// A single slash command available in the session, as listed by the `commands.changed` event.
7235#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7236#[serde(rename_all = "camelCase")]
7237pub struct CommandsChangedCommand {
7238    /// Optional human-readable command description.
7239    #[serde(skip_serializing_if = "Option::is_none")]
7240    pub description: Option<String>,
7241    /// Slash command name without the leading slash.
7242    pub name: String,
7243}
7244
7245/// Session event "commands.changed". SDK command registration change notification
7246#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7247#[serde(rename_all = "camelCase")]
7248pub struct CommandsChangedData {
7249    /// Current list of registered SDK commands
7250    pub commands: Vec<CommandsChangedCommand>,
7251}
7252
7253/// UI capability changes
7254#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7255#[serde(rename_all = "camelCase")]
7256pub struct CapabilitiesChangedUI {
7257    /// Whether canvas rendering is now supported
7258    #[serde(skip_serializing_if = "Option::is_none")]
7259    pub canvases: Option<bool>,
7260    /// Whether elicitation is now supported
7261    #[serde(skip_serializing_if = "Option::is_none")]
7262    pub elicitation: Option<bool>,
7263    /// Whether MCP Apps (SEP-1865) UI passthrough is now supported
7264    #[serde(skip_serializing_if = "Option::is_none")]
7265    pub mcp_apps: Option<bool>,
7266}
7267
7268/// Session event "capabilities.changed". Session capability change notification
7269#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7270#[serde(rename_all = "camelCase")]
7271pub struct CapabilitiesChangedData {
7272    /// UI capability changes
7273    #[serde(skip_serializing_if = "Option::is_none")]
7274    pub ui: Option<CapabilitiesChangedUI>,
7275}
7276
7277/// Session event "exit_plan_mode.requested". Plan approval request with plan content and available user actions
7278#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7279#[serde(rename_all = "camelCase")]
7280pub struct ExitPlanModeRequestedData {
7281    /// Available actions the user can take
7282    pub actions: Vec<ExitPlanModeAction>,
7283    /// Model the session had selected when the plan was authored, when one is known
7284    #[serde(skip_serializing_if = "Option::is_none")]
7285    pub model: Option<String>,
7286    /// Full content of the plan file
7287    pub plan_content: String,
7288    /// Recommended action to preselect for the user
7289    pub recommended_action: ExitPlanModeAction,
7290    /// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
7291    pub request_id: RequestId,
7292    /// Summary of the plan that was created
7293    pub summary: String,
7294}
7295
7296/// Session event "exit_plan_mode.completed". Plan mode exit completion with the user's approval decision and optional feedback
7297#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7298#[serde(rename_all = "camelCase")]
7299pub struct ExitPlanModeCompletedData {
7300    /// Whether the plan was approved by the user
7301    #[serde(skip_serializing_if = "Option::is_none")]
7302    pub approved: Option<bool>,
7303    /// Whether edits should be auto-approved without confirmation
7304    #[serde(skip_serializing_if = "Option::is_none")]
7305    pub auto_approve_edits: Option<bool>,
7306    /// Free-form feedback from the user if they requested changes to the plan
7307    #[serde(skip_serializing_if = "Option::is_none")]
7308    pub feedback: Option<String>,
7309    /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
7310    pub request_id: RequestId,
7311    /// Action selected by the user
7312    #[serde(skip_serializing_if = "Option::is_none")]
7313    pub selected_action: Option<ExitPlanModeAction>,
7314}
7315
7316/// Session event "session.tools_updated". Payload of `session.tools_updated` identifying the model whose resolved tools were updated.
7317#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7318#[serde(rename_all = "camelCase")]
7319pub struct SessionToolsUpdatedData {
7320    /// Identifier of the model the resolved tools apply to.
7321    pub model: String,
7322}
7323
7324/// Session event "session.background_tasks_changed". Empty payload for `session.background_tasks_changed`, indicating background task state changed.
7325#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7326#[serde(rename_all = "camelCase")]
7327pub struct SessionBackgroundTasksChangedData {}
7328
7329/// Session event "factory.run_updated". Ephemeral invalidation signal for a changed factory run.
7330///
7331/// <div class="warning">
7332///
7333/// **Experimental.** This type is part of an experimental wire-protocol surface
7334/// and may change or be removed in future SDK or CLI releases.
7335///
7336/// </div>
7337#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7338#[serde(rename_all = "camelCase")]
7339pub struct FactoryRunUpdatedData {
7340    /// Monotonic revision now available for the run.
7341    pub revision: i64,
7342    /// Factory run identifier.
7343    pub run_id: String,
7344}
7345
7346/// Session event "factory.run_started". Ephemeral signal that a factory run attempt began executing.
7347///
7348/// <div class="warning">
7349///
7350/// **Experimental.** This type is part of an experimental wire-protocol surface
7351/// and may change or be removed in future SDK or CLI releases.
7352///
7353/// </div>
7354#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7355#[serde(rename_all = "camelCase")]
7356pub struct FactoryRunStartedData {
7357    /// Attempt number this start committed; a resumed run increments it.
7358    pub attempt: i64,
7359    /// Name of the factory this run executes. Low cardinality by construction.
7360    pub factory_name: String,
7361    /// Identifier of the factory run that started.
7362    pub run_id: String,
7363}
7364
7365/// Session event "factory.run_settled". Ephemeral signal that a factory run reached a terminal status.
7366///
7367/// <div class="warning">
7368///
7369/// **Experimental.** This type is part of an experimental wire-protocol surface
7370/// and may change or be removed in future SDK or CLI releases.
7371///
7372/// </div>
7373#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7374#[serde(rename_all = "camelCase")]
7375pub struct FactoryRunSettledData {
7376    /// AI credits this run consumed, in nano-AIU.
7377    pub consumed_nano_aiu: i64,
7378    /// Subagents this run consumed against its limits.
7379    pub consumed_subagents: i64,
7380    /// Active milliseconds accumulated across every attempt of this run.
7381    pub elapsed_ms: i64,
7382    /// Typed failure class recorded on the run, when it failed with one (e.g. `factory_limit_reached`).
7383    #[serde(skip_serializing_if = "Option::is_none")]
7384    pub failure_type: Option<String>,
7385    /// Identifier of the factory run that settled.
7386    pub run_id: String,
7387    /// Terminal status the run committed.
7388    pub status: FactoryRunSettledStatus,
7389}
7390
7391/// A single resolved skill in `session.skills_loaded`, including source, invocability, enabled state, path, and argument hint.
7392#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7393#[serde(rename_all = "camelCase")]
7394pub struct SkillsLoadedSkill {
7395    /// Optional freeform hint describing the skill's expected arguments, from the `argument-hint` frontmatter field
7396    #[serde(skip_serializing_if = "Option::is_none")]
7397    pub argument_hint: Option<String>,
7398    /// Canonical slash command name used to invoke the skill, without the leading '/'
7399    #[serde(skip_serializing_if = "Option::is_none")]
7400    pub command_name: Option<String>,
7401    /// Description of what the skill does
7402    pub description: String,
7403    /// Whether the skill is currently enabled
7404    pub enabled: bool,
7405    /// Unique identifier for the skill
7406    pub name: String,
7407    /// Absolute path to the skill file, if available
7408    #[serde(skip_serializing_if = "Option::is_none")]
7409    pub path: Option<String>,
7410    /// Source location type (e.g., project, personal-copilot, plugin, builtin, remote, sdk)
7411    pub source: SkillSource,
7412    /// Whether the skill can be invoked by the user as a slash command
7413    pub user_invocable: bool,
7414}
7415
7416/// Session event "session.skills_loaded". Payload of `session.skills_loaded` listing resolved skill metadata.
7417#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7418#[serde(rename_all = "camelCase")]
7419pub struct SessionSkillsLoadedData {
7420    /// Array of resolved skill metadata
7421    pub skills: Vec<SkillsLoadedSkill>,
7422}
7423
7424/// A single loaded custom agent in `session.custom_agents_updated`, with identity, source, tools, invocability, and authored model configuration.
7425#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7426#[serde(rename_all = "camelCase")]
7427pub struct CustomAgentsUpdatedAgent {
7428    /// Description of what the agent does
7429    pub description: String,
7430    /// Whether model-driven invocation is disabled for this agent.
7431    #[serde(skip_serializing_if = "Option::is_none")]
7432    pub disable_model_invocation: Option<bool>,
7433    /// Human-readable display name
7434    pub display_name: String,
7435    /// Unique identifier for the agent
7436    pub id: String,
7437    /// Model override for this agent, if set
7438    #[serde(skip_serializing_if = "Option::is_none")]
7439    pub model: Option<String>,
7440    /// Whether authored models are preferences or required constraints
7441    #[serde(skip_serializing_if = "Option::is_none")]
7442    pub model_policy: Option<AgentModelPolicy>,
7443    /// Authored model ids in priority order, if configured
7444    #[serde(skip_serializing_if = "Option::is_none")]
7445    pub models: Option<Vec<String>>,
7446    /// Internal name of the agent
7447    pub name: String,
7448    /// Source location: user, project, inherited, remote, or plugin
7449    pub source: String,
7450    /// List of tool names available to this agent, or null when all tools are available
7451    pub tools: Option<Vec<String>>,
7452    /// Whether the agent can be selected by the user
7453    pub user_invocable: bool,
7454}
7455
7456/// Session event "session.custom_agents_updated". Payload of `session.custom_agents_updated` with loaded custom agents plus non-fatal warnings and fatal errors.
7457#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7458#[serde(rename_all = "camelCase")]
7459pub struct SessionCustomAgentsUpdatedData {
7460    /// Array of loaded custom agent metadata
7461    pub agents: Vec<CustomAgentsUpdatedAgent>,
7462    /// Fatal errors from agent loading
7463    pub errors: Vec<String>,
7464    /// Non-fatal warnings from agent loading
7465    pub warnings: Vec<String>,
7466}
7467
7468/// Server-advertised metadata learned through modern discovery or legacy initialization.
7469#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7470#[serde(rename_all = "camelCase")]
7471pub struct McpServerMetadata {
7472    /// Non-empty natural-language guidance for using the server, or null when the server omitted instructions or advertised an empty string.
7473    pub instructions: Option<String>,
7474}
7475
7476/// A single MCP server status summary in `session.mcp_servers_loaded`, including name, status, source, transport, and plugin metadata.
7477#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7478#[serde(rename_all = "camelCase")]
7479pub struct McpServersLoadedServer {
7480    /// Human-readable display name supplied by a managed server catalog.
7481    #[serde(skip_serializing_if = "Option::is_none")]
7482    pub display_name: Option<String>,
7483    /// Error message if the server failed to connect
7484    #[serde(skip_serializing_if = "Option::is_none")]
7485    pub error: Option<String>,
7486    /// Server name (config key)
7487    pub name: String,
7488    /// Name of the plugin that supplied the effective MCP server config, only when source is plugin
7489    #[serde(skip_serializing_if = "Option::is_none")]
7490    pub plugin_name: Option<String>,
7491    /// Version of the plugin that supplied the effective MCP server config, only when source is plugin
7492    #[serde(skip_serializing_if = "Option::is_none")]
7493    pub plugin_version: Option<String>,
7494    /// Server-advertised metadata for a connected server. Omitted when no live connection metadata is available, including while pending or when failed, disabled, stopped, or not configured.
7495    #[serde(skip_serializing_if = "Option::is_none")]
7496    pub server_metadata: Option<McpServerMetadata>,
7497    /// Configuration source: user, workspace, plugin, builtin, or managed
7498    #[serde(skip_serializing_if = "Option::is_none")]
7499    pub source: Option<McpServerSource>,
7500    /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
7501    pub status: McpServerStatus,
7502    /// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
7503    #[serde(skip_serializing_if = "Option::is_none")]
7504    pub transport: Option<McpServerTransport>,
7505}
7506
7507/// Session event "session.mcp_servers_loaded". Payload of `session.mcp_servers_loaded` listing MCP server status summaries.
7508#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7509#[serde(rename_all = "camelCase")]
7510pub struct SessionMcpServersLoadedData {
7511    /// Array of MCP server status summaries
7512    pub servers: Vec<McpServersLoadedServer>,
7513}
7514
7515/// Session event "session.mcp_server_status_changed". Payload of `session.mcp_server_status_changed` for one MCP server's status and optional failure error.
7516#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7517#[serde(rename_all = "camelCase")]
7518pub struct SessionMcpServerStatusChangedData {
7519    /// Error message if the server entered a failed state
7520    #[serde(skip_serializing_if = "Option::is_none")]
7521    pub error: Option<String>,
7522    /// Name of the MCP server whose status changed
7523    pub server_name: String,
7524    /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
7525    pub status: McpServerStatus,
7526}
7527
7528/// Session event "session.mcp_server_removed". Payload of `session.mcp_server_removed` identifying an MCP server the graph no longer runs.
7529#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7530#[serde(rename_all = "camelCase")]
7531pub struct SessionMcpServerRemovedData {
7532    /// Name of the MCP server that was removed from the graph
7533    pub server_name: String,
7534}
7535
7536/// Session event "session.mcp_server_needs_reconnect". Payload of `session.mcp_server_needs_reconnect` identifying an MCP server whose connection must be re-established.
7537#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7538#[serde(rename_all = "camelCase")]
7539pub struct SessionMcpServerNeedsReconnectData {
7540    /// Name of the MCP server that needs to reconnect
7541    pub server_name: String,
7542}
7543
7544/// Session event "mcp.tools.list_changed". Payload identifying the MCP server associated with a list change.
7545#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7546#[serde(rename_all = "camelCase")]
7547pub struct McpToolsListChangedData {
7548    /// Name of the MCP server whose list changed
7549    pub server_name: String,
7550}
7551
7552/// Session event "mcp.resources.list_changed". Payload identifying the MCP server associated with a list change.
7553#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7554#[serde(rename_all = "camelCase")]
7555pub struct McpResourcesListChangedData {
7556    /// Name of the MCP server whose list changed
7557    pub server_name: String,
7558}
7559
7560/// Session event "mcp.prompts.list_changed". Payload identifying the MCP server associated with a list change.
7561#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7562#[serde(rename_all = "camelCase")]
7563pub struct McpPromptsListChangedData {
7564    /// Name of the MCP server whose list changed
7565    pub server_name: String,
7566}
7567
7568/// A single extension discovered by `session.extensions_loaded`, including qualified ID, source, and current status.
7569#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7570#[serde(rename_all = "camelCase")]
7571pub struct ExtensionsLoadedExtension {
7572    /// Source-qualified extension ID (e.g., 'project:my-ext', 'user:auth-helper', 'plugin:my-plugin:my-ext')
7573    pub id: String,
7574    /// Extension name (directory name)
7575    pub name: String,
7576    /// Discovery source
7577    pub source: ExtensionsLoadedExtensionSource,
7578    /// Current status: running, disabled, failed, or starting
7579    pub status: ExtensionsLoadedExtensionStatus,
7580}
7581
7582/// Session event "session.extensions_loaded". Payload of `session.extensions_loaded` listing discovered extensions and their statuses.
7583#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7584#[serde(rename_all = "camelCase")]
7585pub struct SessionExtensionsLoadedData {
7586    /// Array of discovered extensions and their status
7587    pub extensions: Vec<ExtensionsLoadedExtension>,
7588}
7589
7590/// Session event "session.canvas.opened". Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional icon, title, status, URL, and input.
7591///
7592/// <div class="warning">
7593///
7594/// **Experimental.** This type is part of an experimental wire-protocol surface
7595/// and may change or be removed in future SDK or CLI releases.
7596///
7597/// </div>
7598#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7599#[serde(rename_all = "camelCase")]
7600pub struct SessionCanvasOpenedData {
7601    /// Provider-local canvas identifier
7602    pub canvas_id: String,
7603    /// Owning provider identifier
7604    pub extension_id: String,
7605    /// Owning extension display name, when available
7606    #[serde(skip_serializing_if = "Option::is_none")]
7607    pub extension_name: Option<String>,
7608    /// Host-local PNG path for the canvas icon, when supplied
7609    #[serde(skip_serializing_if = "Option::is_none")]
7610    pub icon: Option<String>,
7611    /// Input supplied when the instance was opened
7612    #[serde(skip_serializing_if = "Option::is_none")]
7613    pub input: Option<serde_json::Value>,
7614    /// Stable caller-supplied canvas instance identifier
7615    pub instance_id: String,
7616    /// Provider-supplied status text
7617    #[serde(skip_serializing_if = "Option::is_none")]
7618    pub status: Option<String>,
7619    /// Rendered title
7620    #[serde(skip_serializing_if = "Option::is_none")]
7621    pub title: Option<String>,
7622    /// URL for web-rendered canvases
7623    #[serde(skip_serializing_if = "Option::is_none")]
7624    pub url: Option<String>,
7625}
7626
7627/// A single action within a canvas declaration, with its name, optional description, and optional input schema.
7628///
7629/// <div class="warning">
7630///
7631/// **Experimental.** This type is part of an experimental wire-protocol surface
7632/// and may change or be removed in future SDK or CLI releases.
7633///
7634/// </div>
7635#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7636#[serde(rename_all = "camelCase")]
7637pub struct CanvasRegistryChangedCanvasAction {
7638    /// Action description
7639    #[serde(skip_serializing_if = "Option::is_none")]
7640    pub description: Option<String>,
7641    /// JSON Schema for action input
7642    #[serde(skip_serializing_if = "Option::is_none")]
7643    pub input_schema: Option<serde_json::Value>,
7644    /// Action name
7645    pub name: String,
7646}
7647
7648/// A single canvas declaration in `session.canvas.registry_changed`, including provider IDs, display metadata, input schema, and actions.
7649///
7650/// <div class="warning">
7651///
7652/// **Experimental.** This type is part of an experimental wire-protocol surface
7653/// and may change or be removed in future SDK or CLI releases.
7654///
7655/// </div>
7656#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7657#[serde(rename_all = "camelCase")]
7658pub struct CanvasRegistryChangedCanvas {
7659    /// Actions the agent or host may invoke
7660    #[serde(skip_serializing_if = "Option::is_none")]
7661    pub actions: Option<Vec<CanvasRegistryChangedCanvasAction>>,
7662    /// Provider-local canvas identifier
7663    pub canvas_id: String,
7664    /// Short, single-sentence description shown to the agent in canvas catalogs.
7665    pub description: String,
7666    /// Human-readable canvas name
7667    pub display_name: String,
7668    /// Owning provider identifier
7669    pub extension_id: String,
7670    /// Owning extension display name, when available
7671    #[serde(skip_serializing_if = "Option::is_none")]
7672    pub extension_name: Option<String>,
7673    /// Host-local PNG path for the canvas icon, when supplied
7674    #[serde(skip_serializing_if = "Option::is_none")]
7675    pub icon: Option<String>,
7676    /// JSON Schema for canvas open input
7677    #[serde(skip_serializing_if = "Option::is_none")]
7678    pub input_schema: Option<serde_json::Value>,
7679}
7680
7681/// Session event "session.canvas.registry_changed". Payload of `session.canvas.registry_changed` listing the canvas declarations currently available.
7682///
7683/// <div class="warning">
7684///
7685/// **Experimental.** This type is part of an experimental wire-protocol surface
7686/// and may change or be removed in future SDK or CLI releases.
7687///
7688/// </div>
7689#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7690#[serde(rename_all = "camelCase")]
7691pub struct SessionCanvasRegistryChangedData {
7692    /// Canvas declarations currently available
7693    pub canvases: Vec<CanvasRegistryChangedCanvas>,
7694}
7695
7696/// Session event "session.canvas.closed". Payload of `session.canvas.closed` with the closed canvas instance ID, provider ID, and canvas ID.
7697///
7698/// <div class="warning">
7699///
7700/// **Experimental.** This type is part of an experimental wire-protocol surface
7701/// and may change or be removed in future SDK or CLI releases.
7702///
7703/// </div>
7704#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7705#[serde(rename_all = "camelCase")]
7706pub struct SessionCanvasClosedData {
7707    /// Provider-local canvas identifier
7708    pub canvas_id: String,
7709    /// Owning provider identifier
7710    pub extension_id: String,
7711    /// Stable caller-supplied identifier of the canvas instance that was closed
7712    pub instance_id: String,
7713}
7714
7715/// Session event "session.canvas.unavailable". Transient signal that an open canvas instance's provider has dropped (for example the extension is reloading mid-session). The host should keep the panel mounted and surface a reconnecting affordance rather than tearing it down; a subsequent `session.canvas.opened` for the same instanceId clears the affordance once the provider reconnects with a fresh url. Ephemeral and never persisted, so it is never replayed on cold resume.
7716///
7717/// <div class="warning">
7718///
7719/// **Experimental.** This type is part of an experimental wire-protocol surface
7720/// and may change or be removed in future SDK or CLI releases.
7721///
7722/// </div>
7723#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7724#[serde(rename_all = "camelCase")]
7725pub struct SessionCanvasUnavailableData {
7726    /// Provider-local canvas identifier
7727    pub canvas_id: String,
7728    /// Owning provider identifier
7729    pub extension_id: String,
7730    /// Stable caller-supplied identifier of the canvas instance whose provider became unavailable
7731    pub instance_id: String,
7732}
7733
7734/// Session event "session.canvas.recorded". Durable record that a canvas instance is open, used to restore open canvases on cold session resume. Intentionally omits the transient url and availability.
7735///
7736/// <div class="warning">
7737///
7738/// **Experimental.** This type is part of an experimental wire-protocol surface
7739/// and may change or be removed in future SDK or CLI releases.
7740///
7741/// </div>
7742#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7743#[serde(rename_all = "camelCase")]
7744pub struct SessionCanvasRecordedData {
7745    /// Provider-local canvas identifier
7746    pub canvas_id: String,
7747    /// Owning provider identifier
7748    pub extension_id: String,
7749    /// Input supplied when the instance was opened
7750    #[serde(skip_serializing_if = "Option::is_none")]
7751    pub input: Option<serde_json::Value>,
7752    /// Stable caller-supplied canvas instance identifier
7753    pub instance_id: String,
7754    /// Rendered title
7755    #[serde(skip_serializing_if = "Option::is_none")]
7756    pub title: Option<String>,
7757}
7758
7759/// Session event "session.canvas.removed". Durable record that a canvas instance was closed, superseding a prior instance_recorded during resume replay.
7760///
7761/// <div class="warning">
7762///
7763/// **Experimental.** This type is part of an experimental wire-protocol surface
7764/// and may change or be removed in future SDK or CLI releases.
7765///
7766/// </div>
7767#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7768#[serde(rename_all = "camelCase")]
7769pub struct SessionCanvasRemovedData {
7770    /// Provider-local canvas identifier
7771    pub canvas_id: String,
7772    /// Owning provider identifier
7773    pub extension_id: String,
7774    /// Stable caller-supplied identifier of the canvas instance that was closed
7775    pub instance_id: String,
7776}
7777
7778/// Session event "session.extensions.attachments_pushed". Payload of `session.extensions.attachments_pushed` with extension-contributed attachments for the next send.
7779#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7780#[serde(rename_all = "camelCase")]
7781pub struct SessionExtensionsAttachmentsPushedData {
7782    /// Attachments contributed by an extension; the host should surface these as composer pills and forward them via the next session.send call.
7783    pub attachments: Vec<serde_json::Value>,
7784}
7785
7786/// Set when the underlying tools/call threw an error before returning a CallToolResult
7787#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7788#[serde(rename_all = "camelCase")]
7789pub struct McpAppToolCallCompleteError {
7790    /// Human-readable error message
7791    pub message: String,
7792}
7793
7794/// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
7795#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7796#[serde(rename_all = "camelCase")]
7797pub struct McpAppToolCallCompleteToolMetaUI {
7798    /// `ui://` URI declared by the tool's `_meta.ui.resourceUri`
7799    #[serde(skip_serializing_if = "Option::is_none")]
7800    pub resource_uri: Option<String>,
7801    /// Tool visibility per SEP-1865 (typically a subset of `["model","app"]`)
7802    #[serde(skip_serializing_if = "Option::is_none")]
7803    pub visibility: Option<Vec<String>>,
7804}
7805
7806/// The tool's `_meta.ui` block at the time of the call, so consumers can decide whether to forward the result to the model without re-listing tools.
7807#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7808#[serde(rename_all = "camelCase")]
7809pub struct McpAppToolCallCompleteToolMeta {
7810    /// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
7811    #[serde(skip_serializing_if = "Option::is_none")]
7812    pub ui: Option<McpAppToolCallCompleteToolMetaUI>,
7813}
7814
7815/// Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
7816#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7817#[serde(rename_all = "camelCase")]
7818pub struct McpAppToolCallCompleteData {
7819    /// Arguments passed to the tool by the app view, if any
7820    #[serde(skip_serializing_if = "Option::is_none")]
7821    pub arguments: Option<HashMap<String, serde_json::Value>>,
7822    /// Wall-clock duration of the underlying tools/call in milliseconds
7823    pub duration_ms: f64,
7824    /// Set when the underlying tools/call threw an error before returning a CallToolResult
7825    #[serde(skip_serializing_if = "Option::is_none")]
7826    pub error: Option<McpAppToolCallCompleteError>,
7827    /// Standard MCP CallToolResult returned by the server. Present whether or not the call set isError.
7828    #[serde(skip_serializing_if = "Option::is_none")]
7829    pub result: Option<HashMap<String, serde_json::Value>>,
7830    /// Name of the MCP server hosting the tool
7831    pub server_name: String,
7832    /// True when the call completed without throwing AND the MCP CallToolResult did not set isError
7833    pub success: bool,
7834    /// The tool's `_meta.ui` block at the time of the call, so consumers can decide whether to forward the result to the model without re-listing tools.
7835    #[serde(skip_serializing_if = "Option::is_none")]
7836    pub tool_meta: Option<McpAppToolCallCompleteToolMeta>,
7837    /// MCP tool name that was invoked
7838    pub tool_name: String,
7839}
7840
7841/// Session event "session.indexed_search". Transient indexed-search status and diagnostics from the live runtime service. Never persisted or used to infer activation from session history.
7842pub type SessionIndexedSearchData = IndexedSearchData;
7843
7844/// Routing preference used when the session model is `auto`. `fast` is an integrator-only latency preset and is not a first-party GitHub Copilot product preference.
7845#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7846pub enum AutoTier {
7847    /// Optimize for efficiency.
7848    #[serde(rename = "efficiency")]
7849    Efficiency,
7850    /// Balance efficiency and intelligence.
7851    #[serde(rename = "balance")]
7852    Balance,
7853    /// Optimize for intelligence.
7854    #[serde(rename = "intelligence")]
7855    Intelligence,
7856    /// Integrator-only preset that optimizes for latency.
7857    #[serde(rename = "fast")]
7858    Fast,
7859    /// Unknown variant for forward compatibility.
7860    #[default]
7861    #[serde(other)]
7862    Unknown,
7863}
7864
7865/// Hosting platform type of the repository (github or ado)
7866#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7867pub enum WorkingDirectoryContextHostType {
7868    /// Repository is hosted on GitHub.
7869    #[serde(rename = "github")]
7870    GitHub,
7871    /// Repository is hosted on Azure DevOps.
7872    #[serde(rename = "ado")]
7873    Ado,
7874    /// Unknown variant for forward compatibility.
7875    #[default]
7876    #[serde(other)]
7877    Unknown,
7878}
7879
7880/// Allowed values for the `ContextTier` enumeration.
7881#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7882pub enum ContextTier {
7883    /// Default context tier with standard context window size.
7884    #[serde(rename = "default")]
7885    Default,
7886    /// Extended context tier with a larger context window.
7887    #[serde(rename = "long_context")]
7888    LongContext,
7889    /// Unknown variant for forward compatibility.
7890    #[default]
7891    #[serde(other)]
7892    Unknown,
7893}
7894
7895/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
7896#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7897pub enum ReasoningSummary {
7898    /// Do not request reasoning summaries from the model.
7899    #[serde(rename = "none")]
7900    None,
7901    /// Request a concise summary of the model's reasoning.
7902    #[serde(rename = "concise")]
7903    Concise,
7904    /// Request a detailed summary of the model's reasoning.
7905    #[serde(rename = "detailed")]
7906    Detailed,
7907    /// Unknown variant for forward compatibility.
7908    #[default]
7909    #[serde(other)]
7910    Unknown,
7911}
7912
7913/// Output verbosity level used for supported model calls (e.g. "low", "medium", "high")
7914#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7915pub enum Verbosity {
7916    /// A terse response was requested.
7917    #[serde(rename = "low")]
7918    Low,
7919    /// A medium amount of response detail was requested.
7920    #[serde(rename = "medium")]
7921    Medium,
7922    /// A more detailed response was requested.
7923    #[serde(rename = "high")]
7924    High,
7925    /// Unknown variant for forward compatibility.
7926    #[default]
7927    #[serde(other)]
7928    Unknown,
7929}
7930
7931/// What the user must do to recover from a failure, named as an action rather than as one client's affordance. The runtime cannot know which affordance a client offers — a slash command, a settings pane, a link — so the accompanying message stays host-agnostic and each client renders its own copy from this value. Absent when the runtime knows of no action the user can take.
7932#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7933pub enum RemediationAction {
7934    /// Authenticate again with the Copilot backend. The current credential is absent, expired, or rejected.
7935    #[serde(rename = "sign_in")]
7936    SignIn,
7937    /// Authenticate as a different account. The current account exists but lacks access to the requested resource.
7938    #[serde(rename = "switch_account")]
7939    SwitchAccount,
7940    /// Inspect which account is currently authenticated before deciding what to change.
7941    #[serde(rename = "show_account")]
7942    ShowAccount,
7943    /// Review or widen the sandbox policy. The blocked path or host is named by the accompanying message or by the tool result the action arrived with.
7944    #[serde(rename = "review_sandbox_policy")]
7945    ReviewSandboxPolicy,
7946    /// Permit outbound network access in the sandbox policy.
7947    #[serde(rename = "allow_sandbox_outbound")]
7948    AllowSandboxOutbound,
7949    /// Unknown variant for forward compatibility.
7950    #[default]
7951    #[serde(other)]
7952    Unknown,
7953}
7954
7955/// The session mode the agent is operating in
7956#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7957pub enum SessionMode {
7958    /// The agent is responding interactively to the user.
7959    #[serde(rename = "interactive")]
7960    Interactive,
7961    /// The agent is preparing a plan before making changes.
7962    #[serde(rename = "plan")]
7963    Plan,
7964    /// The agent is working autonomously toward task completion.
7965    #[serde(rename = "autopilot")]
7966    Autopilot,
7967    /// Unknown variant for forward compatibility.
7968    #[default]
7969    #[serde(other)]
7970    Unknown,
7971}
7972
7973/// Who created the schedule: `user` (an explicit user action such as `/every` or `/after`) or `model` (the agent via the `manage_schedule` tool). Gates whether a scheduled skill that opted out of model invocation may fire: only user-created schedules may.
7974#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7975pub enum ScheduleOrigin {
7976    /// The schedule was created by an explicit user action, such as `/every` or `/after`.
7977    #[serde(rename = "user")]
7978    User,
7979    /// The schedule was created by the agent via the `manage_schedule` tool.
7980    #[serde(rename = "model")]
7981    Model,
7982    /// Unknown variant for forward compatibility.
7983    #[default]
7984    #[serde(other)]
7985    Unknown,
7986}
7987
7988/// The type of operation performed on the autopilot objective state file
7989#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7990pub enum AutopilotObjectiveChangedOperation {
7991    /// Autopilot objective state file was created for a new objective.
7992    #[serde(rename = "create")]
7993    Create,
7994    /// Autopilot objective state file was updated for an existing objective.
7995    #[serde(rename = "update")]
7996    Update,
7997    /// Autopilot objective state file was deleted or cleared.
7998    #[serde(rename = "delete")]
7999    Delete,
8000    /// Unknown variant for forward compatibility.
8001    #[default]
8002    #[serde(other)]
8003    Unknown,
8004}
8005
8006/// Current autopilot objective status, if one exists
8007#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8008pub enum AutopilotObjectiveChangedStatus {
8009    /// Objective is active and can drive autopilot continuations.
8010    #[serde(rename = "active")]
8011    Active,
8012    /// Objective is paused and will not drive autopilot continuations.
8013    #[serde(rename = "paused")]
8014    Paused,
8015    /// Legacy objective state indicating the previous continuation cap was reached.
8016    #[serde(rename = "cap_reached")]
8017    CapReached,
8018    /// Objective was completed by the agent.
8019    #[serde(rename = "completed")]
8020    Completed,
8021    /// Unknown variant for forward compatibility.
8022    #[default]
8023    #[serde(other)]
8024    Unknown,
8025}
8026
8027/// Indexed-search event variant discriminator.
8028#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8029pub enum IndexedSearchDataStatusKind {
8030    #[serde(rename = "status")]
8031    #[default]
8032    Status,
8033}
8034
8035/// Live indexed-search state for this session activation, never inferred from persisted history.
8036#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8037pub enum IndexedSearchState {
8038    /// Indexed search is not active for this session.
8039    #[serde(rename = "disabled")]
8040    Disabled,
8041    /// Indexed-search startup is in progress.
8042    #[serde(rename = "starting")]
8043    Starting,
8044    /// The indexed-search server started successfully; its index may still be warming.
8045    #[serde(rename = "enabled")]
8046    Enabled,
8047    /// The indexed-search server and its index are ready.
8048    #[serde(rename = "ready")]
8049    Ready,
8050    /// Indexed-search startup or the active server failed.
8051    #[serde(rename = "failed")]
8052    Failed,
8053    /// Unknown variant for forward compatibility.
8054    #[default]
8055    #[serde(other)]
8056    Unknown,
8057}
8058
8059/// Configuration, policy, or workspace condition that disabled indexed search.
8060#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8061pub enum IndexedSearchDisabledReason {
8062    /// Indexed search was explicitly disabled by the environment.
8063    #[serde(rename = "use_tgrep_false")]
8064    UseTgrepFalse,
8065    /// Search uses the external ripgrep binary instead of bundled search.
8066    #[serde(rename = "use_builtin_ripgrep_false")]
8067    UseBuiltinRipgrepFalse,
8068    /// Organization policy disables indexed search.
8069    #[serde(rename = "organization")]
8070    Organization,
8071    /// Authentication has not resolved organization policy.
8072    #[serde(rename = "organization_policy_auth_pending")]
8073    OrganizationPolicyAuthPending,
8074    /// Organization policy could not be determined.
8075    #[serde(rename = "organization_policy_unknown")]
8076    OrganizationPolicyUnknown,
8077    /// The workspace uses a virtualized or network filesystem.
8078    #[serde(rename = "virtual_filesystem")]
8079    VirtualFilesystem,
8080    /// The workspace is inside a Windows cloud-sync root.
8081    #[serde(rename = "cloud_sync_root")]
8082    CloudSyncRoot,
8083    /// The Windows cloud-sync safety check failed.
8084    #[serde(rename = "cloud_sync_detection_failed")]
8085    CloudSyncDetectionFailed,
8086    /// The workspace is not available on the runtime's local filesystem.
8087    #[serde(rename = "workspace_not_local")]
8088    WorkspaceNotLocal,
8089    /// Unknown variant for forward compatibility.
8090    #[default]
8091    #[serde(other)]
8092    Unknown,
8093}
8094
8095/// Indexed-search event variant discriminator.
8096#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8097pub enum IndexedSearchDataStartupKind {
8098    #[serde(rename = "startup")]
8099    #[default]
8100    Startup,
8101}
8102
8103/// Result of an indexed-search startup attempt.
8104#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8105pub enum IndexedSearchOutcome {
8106    /// A new indexed-search server was started.
8107    #[serde(rename = "started")]
8108    Started,
8109    /// The repository has too few files for automatic indexing.
8110    #[serde(rename = "skipped_below_threshold")]
8111    SkippedBelowThreshold,
8112    /// No Git repository was found and indexing was not forced.
8113    #[serde(rename = "skipped_no_gitroot")]
8114    SkippedNoGitroot,
8115    /// Configuration, policy, or workspace safety disabled indexing.
8116    #[serde(rename = "skipped_disabled")]
8117    SkippedDisabled,
8118    /// An existing indexed-search server was reused.
8119    #[serde(rename = "reused_existing")]
8120    ReusedExisting,
8121    /// The startup attempt failed.
8122    #[serde(rename = "failed")]
8123    Failed,
8124    /// Unknown variant for forward compatibility.
8125    #[default]
8126    #[serde(other)]
8127    Unknown,
8128}
8129
8130/// Category of an indexed-search server failure.
8131#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8132pub enum IndexedSearchErrorType {
8133    /// The indexed-search server could not be spawned.
8134    #[serde(rename = "spawn_error")]
8135    SpawnError,
8136    /// The indexed-search server exited unexpectedly.
8137    #[serde(rename = "unexpected_exit")]
8138    UnexpectedExit,
8139    /// The indexed-search server was terminated by a signal.
8140    #[serde(rename = "killed_by_signal")]
8141    KilledBySignal,
8142    /// Unknown variant for forward compatibility.
8143    #[default]
8144    #[serde(other)]
8145    Unknown,
8146}
8147
8148/// Indexed-search event variant discriminator.
8149#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8150pub enum IndexedSearchDataServerErrorKind {
8151    #[serde(rename = "server_error")]
8152    #[default]
8153    ServerError,
8154}
8155
8156/// Indexed-search event variant discriminator.
8157#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8158pub enum IndexedSearchDataIncrementalKind {
8159    #[serde(rename = "incremental")]
8160    #[default]
8161    Incremental,
8162}
8163
8164/// Phase of an incremental indexed-search update.
8165#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8166pub enum IndexedSearchIncrementalPhase {
8167    /// A workspace scan found changes to index.
8168    #[serde(rename = "changes_detected")]
8169    ChangesDetected,
8170    /// The incremental index update completed.
8171    #[serde(rename = "updated")]
8172    Updated,
8173    /// Unknown variant for forward compatibility.
8174    #[default]
8175    #[serde(other)]
8176    Unknown,
8177}
8178
8179/// Transient indexed-search status and diagnostics from the live runtime service. Never persisted or used to infer activation from session history.
8180#[derive(Debug, Clone, Serialize, Deserialize)]
8181#[serde(untagged)]
8182pub enum IndexedSearchData {
8183    Status(IndexedSearchDataStatus),
8184    Startup(IndexedSearchDataStartup),
8185    ServerError(IndexedSearchDataServerError),
8186    Incremental(IndexedSearchDataIncremental),
8187}
8188
8189/// Origin of an effective session model change.
8190#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8191pub enum ModelChangeSource {
8192    /// The user selected a model directly with `/model <id>`.
8193    #[serde(rename = "model_command")]
8194    ModelCommand,
8195    /// The user selected the model with `/settings`.
8196    #[serde(rename = "settings_command")]
8197    SettingsCommand,
8198    /// The user selected the model with the `/config` alias.
8199    #[serde(rename = "config_command")]
8200    ConfigCommand,
8201    /// The user selected the model in the model picker, including the picker opened by bare `/model`.
8202    #[serde(rename = "model_picker")]
8203    ModelPicker,
8204    /// Organization-managed settings selected the model.
8205    #[serde(rename = "managed_settings")]
8206    ManagedSettings,
8207    /// Repository settings selected the model.
8208    #[serde(rename = "repo_settings")]
8209    RepoSettings,
8210    /// Startup model resolution selected the model.
8211    #[serde(rename = "startup")]
8212    Startup,
8213    /// Selecting an agent selected its configured model.
8214    #[serde(rename = "agent")]
8215    Agent,
8216    /// Entering, leaving, or reconfiguring plan mode selected the model.
8217    #[serde(rename = "plan_mode")]
8218    PlanMode,
8219    /// The runtime selected the model automatically, such as rate-limit recovery or refusal fallback.
8220    #[serde(rename = "automatic")]
8221    Automatic,
8222    /// The user selected the promoted model from the changeboarding card or its keyboard shortcut.
8223    #[serde(rename = "changeboarding_shortcut")]
8224    ChangeboardingShortcut,
8225    /// An SDK or RPC caller selected the model.
8226    #[serde(rename = "sdk")]
8227    Sdk,
8228    /// Unknown variant for forward compatibility.
8229    #[default]
8230    #[serde(other)]
8231    Unknown,
8232}
8233
8234/// Why the session no longer has an explicitly selected model.
8235#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8236pub enum ModelDeselectedReason {
8237    /// A host-managed provider snapshot no longer publishes the selected model.
8238    #[serde(rename = "provider_withdrawn")]
8239    ProviderWithdrawn,
8240    /// Unknown variant for forward compatibility.
8241    #[default]
8242    #[serde(other)]
8243    Unknown,
8244}
8245
8246/// Auto preferences that Copilot API can recommend.
8247#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8248pub enum RecommendedAutoTier {
8249    /// Optimize for efficiency.
8250    #[serde(rename = "efficiency")]
8251    Efficiency,
8252    /// Balance efficiency and intelligence.
8253    #[serde(rename = "balance")]
8254    Balance,
8255    /// Optimize for intelligence.
8256    #[serde(rename = "intelligence")]
8257    Intelligence,
8258    /// Unknown variant for forward compatibility.
8259    #[default]
8260    #[serde(other)]
8261    Unknown,
8262}
8263
8264/// Terminal reason an Auto preference activation failed.
8265#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8266pub enum AutoTierSwitchFailureReason {
8267    /// The candidate model was rejected by model policy.
8268    #[serde(rename = "policy_rejected")]
8269    PolicyRejected,
8270    /// The Auto routing request failed or returned an unusable response.
8271    #[serde(rename = "request_failed")]
8272    RequestFailed,
8273    /// The runtime could not prepare the Auto routing request.
8274    #[serde(rename = "setup_failed")]
8275    SetupFailed,
8276    /// The provider does not support Auto routing.
8277    #[serde(rename = "unsupported")]
8278    Unsupported,
8279    /// Unknown variant for forward compatibility.
8280    #[default]
8281    #[serde(other)]
8282    Unknown,
8283}
8284
8285/// Permission mode for the session.
8286///
8287/// <div class="warning">
8288///
8289/// **Experimental.** This type is part of an experimental wire-protocol surface
8290/// and may change or be removed in future SDK or CLI releases.
8291///
8292/// </div>
8293#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8294pub enum PermissionMode {
8295    /// Permission requests follow the normal approval flow.
8296    #[serde(rename = "manual")]
8297    Manual,
8298    /// Permission requests include an LLM safety recommendation; clients may automatically approve requests judged acceptable.
8299    #[serde(rename = "assisted")]
8300    Assisted,
8301    /// Tool, path, and URL permission requests are automatically approved.
8302    #[serde(rename = "allow-all")]
8303    AllowAll,
8304    /// Unknown variant for forward compatibility.
8305    #[default]
8306    #[serde(other)]
8307    Unknown,
8308}
8309
8310/// The type of operation performed on the plan file
8311#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8312pub enum PlanChangedOperation {
8313    /// The plan file was created.
8314    #[serde(rename = "create")]
8315    Create,
8316    /// The plan file was updated.
8317    #[serde(rename = "update")]
8318    Update,
8319    /// The plan file was deleted.
8320    #[serde(rename = "delete")]
8321    Delete,
8322    /// Unknown variant for forward compatibility.
8323    #[default]
8324    #[serde(other)]
8325    Unknown,
8326}
8327
8328/// Whether the file was newly created or updated
8329#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8330pub enum WorkspaceFileChangedOperation {
8331    /// The workspace file was created.
8332    #[serde(rename = "create")]
8333    Create,
8334    /// The workspace file was updated.
8335    #[serde(rename = "update")]
8336    Update,
8337    /// Unknown variant for forward compatibility.
8338    #[default]
8339    #[serde(other)]
8340    Unknown,
8341}
8342
8343/// Origin type of the session being handed off
8344#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8345pub enum HandoffSourceType {
8346    /// The handoff originated from a remote session.
8347    #[serde(rename = "remote")]
8348    Remote,
8349    /// The handoff originated from a local session.
8350    #[serde(rename = "local")]
8351    Local,
8352    /// Unknown variant for forward compatibility.
8353    #[default]
8354    #[serde(other)]
8355    Unknown,
8356}
8357
8358/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
8359#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8360pub enum ShutdownType {
8361    /// The session ended normally.
8362    #[serde(rename = "routine")]
8363    Routine,
8364    /// The session ended because of a crash or fatal error.
8365    #[serde(rename = "error")]
8366    Error,
8367    /// Unknown variant for forward compatibility.
8368    #[default]
8369    #[serde(other)]
8370    Unknown,
8371}
8372
8373/// What initiated a conversation compaction
8374#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8375pub enum CompactionTrigger {
8376    /// Background compaction started automatically because context utilization crossed the background threshold.
8377    #[serde(rename = "threshold")]
8378    Threshold,
8379    /// Compaction forced by a context-limit model response (e.g. HTTP 413) before retrying the request.
8380    #[serde(rename = "context_limit_retry")]
8381    ContextLimitRetry,
8382    /// User-requested compaction, e.g. the /compact command or the history.compact API.
8383    #[serde(rename = "manual")]
8384    Manual,
8385    /// Emergency compaction triggered by high process memory usage.
8386    #[serde(rename = "memory_pressure")]
8387    MemoryPressure,
8388    /// Compaction requested while switching to a model with a smaller context window.
8389    #[serde(rename = "model_switch")]
8390    ModelSwitch,
8391    /// Unknown variant for forward compatibility.
8392    #[default]
8393    #[serde(other)]
8394    Unknown,
8395}
8396
8397/// Category of structured task blocker
8398#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8399pub enum TaskBlockerKind {
8400    /// Autopilot permission recovery requires intervention or has no safe autonomous path.
8401    #[serde(rename = "permission_recovery")]
8402    PermissionRecovery,
8403    /// Unknown variant for forward compatibility.
8404    #[default]
8405    #[serde(other)]
8406    Unknown,
8407}
8408
8409/// Runtime handling applied to a recovery attempt
8410#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8411pub enum PermissionRecoveryAttemptDisposition {
8412    /// The request was denied without prompting so the agent could try an alternative.
8413    #[serde(rename = "deferred")]
8414    Deferred,
8415    /// The request was surfaced to an interactive responder.
8416    #[serde(rename = "prompted")]
8417    Prompted,
8418    /// The interactive responder approved the request.
8419    #[serde(rename = "approved")]
8420    Approved,
8421    /// The interactive responder denied the request or became unavailable.
8422    #[serde(rename = "denied")]
8423    Denied,
8424    /// The request exhausted unattended recovery and produced a blocked outcome.
8425    #[serde(rename = "blocked")]
8426    Blocked,
8427    /// A tool call succeeded as an equivalent alternative.
8428    #[serde(rename = "succeeded")]
8429    Succeeded,
8430    /// Unknown variant for forward compatibility.
8431    #[default]
8432    #[serde(other)]
8433    Unknown,
8434}
8435
8436/// Controlled reason for an individual attempt disposition
8437#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8438pub enum PermissionRecoveryAttemptReason {
8439    /// The attempt required permission that Assisted Permissions could not grant.
8440    #[serde(rename = "permission_required")]
8441    PermissionRequired,
8442    /// The request repeated an earlier attempt.
8443    #[serde(rename = "repeated_attempt")]
8444    RepeatedAttempt,
8445    /// The request exceeded the bounded number of distinct attempts.
8446    #[serde(rename = "attempts_exhausted")]
8447    AttemptsExhausted,
8448    /// The interactive responder approved the request.
8449    #[serde(rename = "permission_approved")]
8450    PermissionApproved,
8451    /// The interactive responder denied the request.
8452    #[serde(rename = "permission_denied")]
8453    PermissionDenied,
8454    /// The interactive responder became unavailable.
8455    #[serde(rename = "responder_unavailable")]
8456    ResponderUnavailable,
8457    /// The tool call succeeded without the blocked permission.
8458    #[serde(rename = "equivalent_alternative_succeeded")]
8459    EquivalentAlternativeSucceeded,
8460    /// Unknown variant for forward compatibility.
8461    #[default]
8462    #[serde(other)]
8463    Unknown,
8464}
8465
8466/// Relationship of an attempt to earlier permission requests
8467#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8468pub enum PermissionRecoveryAttemptRelation {
8469    /// The first denied permission request in the episode.
8470    #[serde(rename = "initial")]
8471    Initial,
8472    /// A request equivalent to an earlier attempt.
8473    #[serde(rename = "retry")]
8474    Retry,
8475    /// A distinct request or a successful alternative tool call.
8476    #[serde(rename = "alternative")]
8477    Alternative,
8478    /// Unknown variant for forward compatibility.
8479    #[default]
8480    #[serde(other)]
8481    Unknown,
8482}
8483
8484/// Action selected when autonomous recovery cannot continue
8485#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8486pub enum PermissionRecoveryOnBlocked {
8487    /// Surface the existing permission prompt to a response-capable client.
8488    #[serde(rename = "ask")]
8489    Ask,
8490    /// Return a structured unsuccessful blocked outcome because no responder is available.
8491    #[serde(rename = "fail")]
8492    Fail,
8493    /// Unknown variant for forward compatibility.
8494    #[default]
8495    #[serde(other)]
8496    Unknown,
8497}
8498
8499/// Controlled reason for a permission-recovery episode transition
8500#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8501pub enum PermissionRecoveryReason {
8502    /// An action required permission that Assisted Permissions could not grant.
8503    #[serde(rename = "permission_required")]
8504    PermissionRequired,
8505    /// The agent repeated an equivalent permission request instead of making progress.
8506    #[serde(rename = "repeated_attempt")]
8507    RepeatedAttempt,
8508    /// The bounded number of distinct permission attempts was exhausted.
8509    #[serde(rename = "attempts_exhausted")]
8510    AttemptsExhausted,
8511    /// A responder approved the escalated permission request.
8512    #[serde(rename = "permission_approved")]
8513    PermissionApproved,
8514    /// A responder denied the escalated permission request.
8515    #[serde(rename = "permission_denied")]
8516    PermissionDenied,
8517    /// The response-capable client became unavailable while escalation was pending.
8518    #[serde(rename = "responder_unavailable")]
8519    ResponderUnavailable,
8520    /// A later tool call succeeded without requiring the blocked permission.
8521    #[serde(rename = "equivalent_alternative_succeeded")]
8522    EquivalentAlternativeSucceeded,
8523    /// Unknown variant for forward compatibility.
8524    #[default]
8525    #[serde(other)]
8526    Unknown,
8527}
8528
8529/// Lifecycle state of a permission-recovery episode
8530#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8531pub enum PermissionRecoveryStatus {
8532    /// Autopilot may try a bounded equivalent alternative.
8533    #[serde(rename = "recovering")]
8534    Recovering,
8535    /// An interactive permission response is required.
8536    #[serde(rename = "awaiting_approval")]
8537    AwaitingApproval,
8538    /// The episode ended through approval or a successful equivalent alternative.
8539    #[serde(rename = "resolved")]
8540    Resolved,
8541    /// No autonomous path remains and the task requires intervention.
8542    #[serde(rename = "blocked")]
8543    Blocked,
8544    /// Unknown variant for forward compatibility.
8545    #[default]
8546    #[serde(other)]
8547    Unknown,
8548}
8549
8550/// Semantic result of evaluating a task completion request
8551#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8552pub enum TaskCompletionOutcome {
8553    /// The completion request was accepted and the objective is complete.
8554    #[serde(rename = "completed")]
8555    Completed,
8556    /// The completion request was rejected because more work or validation remains.
8557    #[serde(rename = "continue")]
8558    Continue,
8559    /// Completion cannot proceed without intervention; the active objective is paused when one is identified.
8560    #[serde(rename = "blocked")]
8561    Blocked,
8562    /// Unknown variant for forward compatibility.
8563    #[default]
8564    #[serde(other)]
8565    Unknown,
8566}
8567
8568/// Structured terminal status from a tool completion event.
8569#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8570pub enum CompletionReceiptToolStatus {
8571    /// The tool completed successfully.
8572    #[serde(rename = "success")]
8573    Success,
8574    /// The tool failed without a more specific structured status.
8575    #[serde(rename = "failure")]
8576    Failure,
8577    /// The tool exceeded its time budget.
8578    #[serde(rename = "timeout")]
8579    Timeout,
8580    /// The user rejected the tool call.
8581    #[serde(rename = "rejected")]
8582    Rejected,
8583    /// The permissions service denied the tool call.
8584    #[serde(rename = "denied")]
8585    Denied,
8586    /// Unknown variant for forward compatibility.
8587    #[default]
8588    #[serde(other)]
8589    Unknown,
8590}
8591
8592/// Runtime reason the completion decision was accepted.
8593#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8594pub enum CompletionReceiptStopReason {
8595    /// The model reached a natural terminal response.
8596    #[serde(rename = "natural")]
8597    Natural,
8598    /// A terminal tool ended the interaction.
8599    #[serde(rename = "terminal_tool")]
8600    TerminalTool,
8601    /// The configured agentStop continuation limit was reached.
8602    #[serde(rename = "agent_stop_block_limit")]
8603    AgentStopBlockLimit,
8604    /// Unknown variant for forward compatibility.
8605    #[default]
8606    #[serde(other)]
8607    Unknown,
8608}
8609
8610/// Kind of turn for which HydraFusion routing is running.
8611///
8612/// <div class="warning">
8613///
8614/// **Experimental.** This type is part of an experimental wire-protocol surface
8615/// and may change or be removed in future SDK or CLI releases.
8616///
8617/// </div>
8618#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8619pub enum FusionTurnKind {
8620    /// A user-message turn.
8621    #[serde(rename = "user")]
8622    User,
8623    /// A conversation-compaction turn.
8624    #[serde(rename = "compaction")]
8625    Compaction,
8626    /// Unknown variant for forward compatibility.
8627    #[default]
8628    #[serde(other)]
8629    Unknown,
8630}
8631
8632/// Server-recommended routing behavior for a later HydraFusion turn.
8633///
8634/// <div class="warning">
8635///
8636/// **Experimental.** This type is part of an experimental wire-protocol surface
8637/// and may change or be removed in future SDK or CLI releases.
8638///
8639/// </div>
8640#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8641pub enum FusionFollowUpAction {
8642    /// Reuse the durable primary model without routing.
8643    #[serde(rename = "reuse_primary")]
8644    ReusePrimary,
8645    /// Request a new routing decision.
8646    #[serde(rename = "reroute")]
8647    Reroute,
8648    /// Unknown variant for forward compatibility.
8649    #[default]
8650    #[serde(other)]
8651    Unknown,
8652}
8653
8654/// Validated HydraFusion execution pattern.
8655///
8656/// <div class="warning">
8657///
8658/// **Experimental.** This type is part of an experimental wire-protocol surface
8659/// and may change or be removed in future SDK or CLI releases.
8660///
8661/// </div>
8662#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8663pub enum FusionPattern {
8664    /// Run one primary solver phase.
8665    #[serde(rename = "single")]
8666    Single,
8667    /// Run a primary phase, a judge, and an optional repair.
8668    #[serde(rename = "cascade")]
8669    Cascade,
8670    /// Run a primary draft, a read-only critique, and a revision.
8671    #[serde(rename = "critique")]
8672    Critique,
8673    /// Unknown variant for forward compatibility.
8674    #[default]
8675    #[serde(other)]
8676    Unknown,
8677}
8678
8679/// HydraFusion phase kind.
8680///
8681/// <div class="warning">
8682///
8683/// **Experimental.** This type is part of an experimental wire-protocol surface
8684/// and may change or be removed in future SDK or CLI releases.
8685///
8686/// </div>
8687#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8688pub enum FusionPhaseKind {
8689    /// Primary solver phase.
8690    #[serde(rename = "primary")]
8691    Primary,
8692    /// Read-only cascade judge phase.
8693    #[serde(rename = "judge")]
8694    Judge,
8695    /// Cascade repair phase.
8696    #[serde(rename = "repair")]
8697    Repair,
8698    /// Initial critique-pattern draft phase.
8699    #[serde(rename = "draft")]
8700    Draft,
8701    /// Read-only critique phase.
8702    #[serde(rename = "critic")]
8703    Critic,
8704    /// Critique-pattern revision phase.
8705    #[serde(rename = "revision")]
8706    Revision,
8707    /// Follow-up phase continuing from the resolved model.
8708    #[serde(rename = "follow_up")]
8709    FollowUp,
8710    /// Unknown variant for forward compatibility.
8711    #[default]
8712    #[serde(other)]
8713    Unknown,
8714}
8715
8716/// Conversation scope in which a HydraFusion phase executes.
8717///
8718/// <div class="warning">
8719///
8720/// **Experimental.** This type is part of an experimental wire-protocol surface
8721/// and may change or be removed in future SDK or CLI releases.
8722///
8723/// </div>
8724#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8725pub enum FusionConversationScope {
8726    /// Canonical root conversation history.
8727    #[serde(rename = "root")]
8728    Root,
8729    /// Isolated read-only review history that does not enter the root conversation.
8730    #[serde(rename = "review")]
8731    Review,
8732    /// Unknown variant for forward compatibility.
8733    #[default]
8734    #[serde(other)]
8735    Unknown,
8736}
8737
8738/// The agent mode that was active when this message was sent
8739#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8740pub enum UserMessageAgentMode {
8741    /// The agent is responding interactively to the user.
8742    #[serde(rename = "interactive")]
8743    Interactive,
8744    /// The agent is preparing a plan before making changes.
8745    #[serde(rename = "plan")]
8746    Plan,
8747    /// The agent is working autonomously toward task completion.
8748    #[serde(rename = "autopilot")]
8749    Autopilot,
8750    /// The agent is in shell-focused UI mode.
8751    #[serde(rename = "shell")]
8752    Shell,
8753    /// Unknown variant for forward compatibility.
8754    #[default]
8755    #[serde(other)]
8756    Unknown,
8757}
8758
8759/// How this user message was delivered to the agentic loop, relative to whether the loop was already running. This is the timing axis only; the message's origin (human vs. system/command/schedule/skill/etc.) is carried separately by `source`. A system-injected message has a delivery too — e.g. a background-task notification waking an idle agent is `idle`, the same mechanism as a human starting a fresh turn.
8760#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8761pub enum UserMessageDelivery {
8762    /// Delivered while the loop was idle; starts its own run immediately (a human's fresh turn, or a system notification waking an idle agent).
8763    #[serde(rename = "idle")]
8764    Idle,
8765    /// Injected into the current in-flight run while the agent was busy (immediate mode).
8766    #[serde(rename = "steering")]
8767    Steering,
8768    /// Enqueued while the agent was busy; processed as its own run afterward.
8769    #[serde(rename = "queued")]
8770    Queued,
8771    /// Unknown variant for forward compatibility.
8772    #[default]
8773    #[serde(other)]
8774    Unknown,
8775}
8776
8777/// What the agent was doing when the user interrupted it.
8778#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8779pub enum AgentInterruptedActivity {
8780    /// A request to the model was open.
8781    #[serde(rename = "model_call")]
8782    ModelCall,
8783    /// The turn was sleeping between retry attempts.
8784    #[serde(rename = "retry_backoff")]
8785    RetryBackoff,
8786    /// One or more tools were executing.
8787    #[serde(rename = "tool_call")]
8788    ToolCall,
8789    /// Background sub-agents were running while the main loop was idle.
8790    #[serde(rename = "background_agent")]
8791    BackgroundAgent,
8792    /// Unknown variant for forward compatibility.
8793    #[default]
8794    #[serde(other)]
8795    Unknown,
8796}
8797
8798/// Where the interruption landed relative to the first streamed token.
8799#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8800pub enum AgentInterruptedCancelPhase {
8801    /// No output had been produced when the request was cancelled.
8802    #[serde(rename = "pre_first_token")]
8803    PreFirstToken,
8804    /// The response was already streaming when the request was cancelled.
8805    #[serde(rename = "mid_stream")]
8806    MidStream,
8807    /// Unknown variant for forward compatibility.
8808    #[default]
8809    #[serde(other)]
8810    Unknown,
8811}
8812
8813/// Transport used for a failed model call
8814#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8815pub enum ModelCallFailureTransport {
8816    /// HTTP transport, including SSE streams.
8817    #[serde(rename = "http")]
8818    Http,
8819    /// WebSocket transport.
8820    #[serde(rename = "websocket")]
8821    Websocket,
8822    /// Unknown variant for forward compatibility.
8823    #[default]
8824    #[serde(other)]
8825    Unknown,
8826}
8827
8828/// Content-safe activity observed while a HydraFusion phase is running.
8829///
8830/// <div class="warning">
8831///
8832/// **Experimental.** This type is part of an experimental wire-protocol surface
8833/// and may change or be removed in future SDK or CLI releases.
8834///
8835/// </div>
8836#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8837pub enum FusionPhaseActivityKind {
8838    /// The provider produced additional private output bytes.
8839    #[serde(rename = "model_output")]
8840    ModelOutput,
8841    /// A tool began executing inside the phase.
8842    #[serde(rename = "tool_started")]
8843    ToolStarted,
8844    /// A tool finished executing inside the phase.
8845    #[serde(rename = "tool_completed")]
8846    ToolCompleted,
8847    /// Unknown variant for forward compatibility.
8848    #[default]
8849    #[serde(other)]
8850    Unknown,
8851}
8852
8853/// How a durable phase checkpoint contributes its exact message to canonical root history.
8854///
8855/// <div class="warning">
8856///
8857/// **Experimental.** This type is part of an experimental wire-protocol surface
8858/// and may change or be removed in future SDK or CLI releases.
8859///
8860/// </div>
8861#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8862pub enum FusionProjectionMode {
8863    /// Append the exact root message immediately.
8864    #[serde(rename = "append")]
8865    Append,
8866    /// Hold a terminal message outside canonical history until the final commit selects it.
8867    #[serde(rename = "staged")]
8868    Staged,
8869    /// Do not project the checkpoint into root history.
8870    #[serde(rename = "none")]
8871    None,
8872    /// Unknown variant for forward compatibility.
8873    #[default]
8874    #[serde(other)]
8875    Unknown,
8876}
8877
8878/// Durable outcome status of a HydraFusion phase.
8879///
8880/// <div class="warning">
8881///
8882/// **Experimental.** This type is part of an experimental wire-protocol surface
8883/// and may change or be removed in future SDK or CLI releases.
8884///
8885/// </div>
8886#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8887pub enum FusionPhaseStatus {
8888    /// The phase completed successfully.
8889    #[serde(rename = "succeeded")]
8890    Succeeded,
8891    /// The phase failed.
8892    #[serde(rename = "failed")]
8893    Failed,
8894    /// The phase was cancelled.
8895    #[serde(rename = "cancelled")]
8896    Cancelled,
8897    /// Unknown variant for forward compatibility.
8898    #[default]
8899    #[serde(other)]
8900    Unknown,
8901}
8902
8903/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
8904#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8905pub enum AssistantMessageToolRequestType {
8906    /// Standard function-style tool call.
8907    #[serde(rename = "function")]
8908    Function,
8909    /// Custom grammar-based tool call.
8910    #[serde(rename = "custom")]
8911    Custom,
8912    /// Unknown variant for forward compatibility.
8913    #[default]
8914    #[serde(other)]
8915    Unknown,
8916}
8917
8918/// The system that produced a citation.
8919///
8920/// <div class="warning">
8921///
8922/// **Experimental.** This type is part of an experimental wire-protocol surface
8923/// and may change or be removed in future SDK or CLI releases.
8924///
8925/// </div>
8926#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8927pub enum CitationProvider {
8928    /// Citation produced by an Anthropic (Claude) model response.
8929    #[serde(rename = "anthropic")]
8930    Anthropic,
8931    /// Citation produced by an OpenAI model response.
8932    #[serde(rename = "openai")]
8933    Openai,
8934    /// Citation synthesized client-side by the runtime from tool output.
8935    #[serde(rename = "client")]
8936    Client,
8937    /// Unknown variant for forward compatibility.
8938    #[default]
8939    #[serde(other)]
8940    Unknown,
8941}
8942
8943/// Hosted program caller type
8944#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8945pub enum AssistantMessageToolRequestCallerType {
8946    #[serde(rename = "program")]
8947    Program,
8948    /// Unknown variant for forward compatibility.
8949    #[default]
8950    #[serde(other)]
8951    Unknown,
8952}
8953
8954/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
8955#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8956pub enum AssistantUsageApiEndpoint {
8957    /// Chat Completions API endpoint.
8958    #[serde(rename = "/chat/completions")]
8959    ChatCompletions,
8960    /// Anthropic Messages API endpoint.
8961    #[serde(rename = "/v1/messages")]
8962    V1Messages,
8963    /// Responses API endpoint.
8964    #[serde(rename = "/responses")]
8965    Responses,
8966    /// WebSocket Responses API endpoint.
8967    #[serde(rename = "ws:/responses")]
8968    WsResponses,
8969    /// Unknown variant for forward compatibility.
8970    #[default]
8971    #[serde(other)]
8972    Unknown,
8973}
8974
8975/// Transport used for a successful model call
8976#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8977pub enum AssistantUsageTransport {
8978    /// HTTP transport, including SSE streams.
8979    #[serde(rename = "http")]
8980    Http,
8981    /// WebSocket transport.
8982    #[serde(rename = "websocket")]
8983    Websocket,
8984    /// Unknown variant for forward compatibility.
8985    #[default]
8986    #[serde(other)]
8987    Unknown,
8988}
8989
8990/// For HTTP 400 failures only: whether the response carried a structured CAPI error envelope (structured_error, a deterministic validation failure) or no error body (bodyless, the transient gateway/proxy signature). Absent for non-400 failures.
8991#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8992pub enum ModelCallFailureBadRequestKind {
8993    /// The 400 response carried no error body (transient gateway/proxy signature).
8994    #[serde(rename = "bodyless")]
8995    Bodyless,
8996    /// The 400 response carried a structured CAPI error envelope (deterministic validation failure).
8997    #[serde(rename = "structured_error")]
8998    StructuredError,
8999    /// Unknown variant for forward compatibility.
9000    #[default]
9001    #[serde(other)]
9002    Unknown,
9003}
9004
9005/// Boundary that produced a model call failure
9006#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9007pub enum ModelCallFailureKind {
9008    /// The provider returned an API error response.
9009    #[serde(rename = "api")]
9010    Api,
9011    /// The request transport failed before a usable API response completed.
9012    #[serde(rename = "transport")]
9013    Transport,
9014    /// Unknown variant for forward compatibility.
9015    #[default]
9016    #[serde(other)]
9017    Unknown,
9018}
9019
9020/// Where the failed model call originated
9021#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9022pub enum ModelCallFailureSource {
9023    /// Model call from the top-level agent.
9024    #[serde(rename = "top_level")]
9025    TopLevel,
9026    /// Model call from a sub-agent.
9027    #[serde(rename = "subagent")]
9028    Subagent,
9029    /// Model call from MCP sampling.
9030    #[serde(rename = "mcp_sampling")]
9031    McpSampling,
9032    /// Unknown variant for forward compatibility.
9033    #[default]
9034    #[serde(other)]
9035    Unknown,
9036}
9037
9038/// Final outcome of one logical model dispatch after response acceptance processing
9039#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9040pub enum ModelCallFinishedOutcome {
9041    /// The provider response was accepted for continued agent processing.
9042    #[serde(rename = "success")]
9043    Success,
9044    /// The dispatch ended with a provider or transport error.
9045    #[serde(rename = "error")]
9046    Error,
9047    /// The dispatch was cancelled before an accepted response was produced.
9048    #[serde(rename = "cancelled")]
9049    Cancelled,
9050    /// The provider response was rejected during post-response acceptance processing.
9051    #[serde(rename = "rejected")]
9052    Rejected,
9053    /// Unknown variant for forward compatibility.
9054    #[default]
9055    #[serde(other)]
9056    Unknown,
9057}
9058
9059/// Finite reason code describing why the current turn was aborted
9060#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9061pub enum AbortReason {
9062    /// The local user requested the abort, for example by pressing Ctrl+C in the CLI.
9063    #[serde(rename = "user_initiated")]
9064    UserInitiated,
9065    /// A remote command requested the abort.
9066    #[serde(rename = "remote_command")]
9067    RemoteCommand,
9068    /// An MCP server delivered a user.abort notification.
9069    #[serde(rename = "user_abort")]
9070    UserAbort,
9071    /// Autopilot stopped the run because the active objective reached its user-set --max-ai-credits limit.
9072    #[serde(rename = "autopilot_credit_limit")]
9073    AutopilotCreditLimit,
9074    /// Unknown variant for forward compatibility.
9075    #[default]
9076    #[serde(other)]
9077    Unknown,
9078}
9079
9080/// Configuration source: user, workspace, plugin, builtin, or managed
9081#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9082pub enum McpServerSource {
9083    /// Server configured in the user's global MCP configuration.
9084    #[serde(rename = "user")]
9085    User,
9086    /// Server configured by the current workspace.
9087    #[serde(rename = "workspace")]
9088    Workspace,
9089    /// Server contributed by an installed plugin.
9090    #[serde(rename = "plugin")]
9091    Plugin,
9092    /// Server bundled with the runtime.
9093    #[serde(rename = "builtin")]
9094    Builtin,
9095    /// Server supplied by a trusted host-managed catalog.
9096    #[serde(rename = "managed")]
9097    Managed,
9098    /// Unknown variant for forward compatibility.
9099    #[default]
9100    #[serde(other)]
9101    Unknown,
9102}
9103
9104/// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
9105#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9106pub enum McpServerTransport {
9107    /// Server communicates over stdio with a local child process.
9108    #[serde(rename = "stdio")]
9109    Stdio,
9110    /// Server communicates over streamable HTTP.
9111    #[serde(rename = "http")]
9112    Http,
9113    /// Server communicates over Server-Sent Events (deprecated).
9114    #[serde(rename = "sse")]
9115    Sse,
9116    /// Server is backed by an in-memory runtime implementation.
9117    #[serde(rename = "memory")]
9118    Memory,
9119    /// Unknown variant for forward compatibility.
9120    #[default]
9121    #[serde(other)]
9122    Unknown,
9123}
9124
9125/// Allowed values for the `ToolExecutionStartToolDescriptionMetaUIVisibility` enumeration.
9126#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9127pub enum ToolExecutionStartToolDescriptionMetaUIVisibility {
9128    /// Tool is callable by the model (LLM tool surface)
9129    #[serde(rename = "model")]
9130    Model,
9131    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
9132    #[serde(rename = "app")]
9133    App,
9134    /// Unknown variant for forward compatibility.
9135    #[default]
9136    #[serde(other)]
9137    Unknown,
9138}
9139
9140/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9141#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9142pub enum PersistedBinaryImageType {
9143    /// Binary image data.
9144    #[serde(rename = "image")]
9145    Image,
9146    /// Other binary resource data.
9147    #[serde(rename = "resource")]
9148    Resource,
9149    /// Unknown variant for forward compatibility.
9150    #[default]
9151    #[serde(other)]
9152    Unknown,
9153}
9154
9155/// Why the binary data is absent: it exceeded the inline size limit, or its asset was unavailable
9156#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9157pub enum OmittedBinaryOmittedReason {
9158    /// Bytes exceeded the session's inline size limit.
9159    #[serde(rename = "too_large")]
9160    TooLarge,
9161    /// The referenced binary asset could not be found (e.g. a truncated log).
9162    #[serde(rename = "asset_unavailable")]
9163    AssetUnavailable,
9164    /// Unknown variant for forward compatibility.
9165    #[default]
9166    #[serde(other)]
9167    Unknown,
9168}
9169
9170/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9171#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9172pub enum OmittedBinaryType {
9173    /// Binary image data.
9174    #[serde(rename = "image")]
9175    Image,
9176    /// Other binary resource data.
9177    #[serde(rename = "resource")]
9178    Resource,
9179    /// Unknown variant for forward compatibility.
9180    #[default]
9181    #[serde(other)]
9182    Unknown,
9183}
9184
9185/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9186#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9187pub enum BinaryAssetReferenceType {
9188    /// Binary image data.
9189    #[serde(rename = "image")]
9190    Image,
9191    /// Other binary resource data.
9192    #[serde(rename = "resource")]
9193    Resource,
9194    /// Unknown variant for forward compatibility.
9195    #[default]
9196    #[serde(other)]
9197    Unknown,
9198}
9199
9200/// A model-facing binary result as persisted: full inline data, a size-omitted marker, or a deduplicated asset reference
9201///
9202/// <div class="warning">
9203///
9204/// **Experimental.** This type is part of an experimental wire-protocol surface
9205/// and may change or be removed in future SDK or CLI releases.
9206///
9207/// </div>
9208#[derive(Debug, Clone, Serialize, Deserialize)]
9209#[serde(untagged)]
9210pub enum PersistedBinaryResult {
9211    PersistedBinaryImage(PersistedBinaryImage),
9212    OmittedBinaryResult(OmittedBinaryResult),
9213    BinaryAssetReference(BinaryAssetReference),
9214}
9215
9216/// Content block type discriminator
9217#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9218pub enum ToolExecutionCompleteContentTextType {
9219    #[serde(rename = "text")]
9220    #[default]
9221    Text,
9222}
9223
9224/// Content block type discriminator
9225#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9226pub enum ToolExecutionCompleteContentTerminalType {
9227    #[serde(rename = "terminal")]
9228    #[default]
9229    Terminal,
9230}
9231
9232/// Content block type discriminator
9233#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9234pub enum ToolExecutionCompleteContentShellExitType {
9235    #[serde(rename = "shell_exit")]
9236    #[default]
9237    ShellExit,
9238}
9239
9240/// Content block type discriminator
9241#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9242pub enum ToolExecutionCompleteContentImageType {
9243    #[serde(rename = "image")]
9244    #[default]
9245    Image,
9246}
9247
9248/// Content block type discriminator
9249#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9250pub enum ToolExecutionCompleteContentAudioType {
9251    #[serde(rename = "audio")]
9252    #[default]
9253    Audio,
9254}
9255
9256/// Theme variant this icon is intended for
9257#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9258pub enum ToolExecutionCompleteContentResourceLinkIconTheme {
9259    /// Icon intended for light themes.
9260    #[serde(rename = "light")]
9261    Light,
9262    /// Icon intended for dark themes.
9263    #[serde(rename = "dark")]
9264    Dark,
9265    /// Unknown variant for forward compatibility.
9266    #[default]
9267    #[serde(other)]
9268    Unknown,
9269}
9270
9271/// Content block type discriminator
9272#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9273pub enum ToolExecutionCompleteContentResourceLinkType {
9274    #[serde(rename = "resource_link")]
9275    #[default]
9276    ResourceLink,
9277}
9278
9279/// The embedded resource contents, either text or base64-encoded binary
9280#[derive(Debug, Clone, Serialize, Deserialize)]
9281#[serde(untagged)]
9282pub enum ToolExecutionCompleteContentResourceDetails {
9283    EmbeddedTextResourceContents(EmbeddedTextResourceContents),
9284    EmbeddedBlobResourceContents(EmbeddedBlobResourceContents),
9285}
9286
9287/// Content block type discriminator
9288#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9289pub enum ToolExecutionCompleteContentResourceType {
9290    #[serde(rename = "resource")]
9291    #[default]
9292    Resource,
9293}
9294
9295/// A content block within a tool result, which may be text, terminal output, image, audio, or a resource
9296#[derive(Debug, Clone, Serialize, Deserialize)]
9297#[serde(untagged)]
9298pub enum ToolExecutionCompleteContent {
9299    Text(ToolExecutionCompleteContentText),
9300    Terminal(ToolExecutionCompleteContentTerminal),
9301    ShellExit(ToolExecutionCompleteContentShellExit),
9302    Image(ToolExecutionCompleteContentImage),
9303    Audio(ToolExecutionCompleteContentAudio),
9304    ResourceLink(ToolExecutionCompleteContentResourceLink),
9305    Resource(ToolExecutionCompleteContentResource),
9306}
9307
9308/// Allowed values for the `ToolExecutionCompleteToolDescriptionMetaUIVisibility` enumeration.
9309#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9310pub enum ToolExecutionCompleteToolDescriptionMetaUIVisibility {
9311    /// Tool is callable by the model (LLM tool surface)
9312    #[serde(rename = "model")]
9313    Model,
9314    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
9315    #[serde(rename = "app")]
9316    App,
9317    /// Unknown variant for forward compatibility.
9318    #[default]
9319    #[serde(other)]
9320    Unknown,
9321}
9322
9323/// What triggered the skill invocation: `user-invoked` (explicit user action, such as via a slash command or UI affordance), `agent-invoked` (agent requested the skill), or `context-load` (loaded as part of another context, such as preloading skills configured on a custom agent or subagent)
9324#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9325pub enum SkillInvokedTrigger {
9326    /// Skill invocation requested explicitly by the user, such as via a slash command or UI affordance.
9327    #[serde(rename = "user-invoked")]
9328    UserInvoked,
9329    /// Skill invocation requested by the agent.
9330    #[serde(rename = "agent-invoked")]
9331    AgentInvoked,
9332    /// Skill content loaded as part of another context, such as a configured custom agent or subagent.
9333    #[serde(rename = "context-load")]
9334    ContextLoad,
9335    /// Unknown variant for forward compatibility.
9336    #[default]
9337    #[serde(other)]
9338    Unknown,
9339}
9340
9341/// Process-containment backend selected for the host platform
9342#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9343pub enum SandboxBackend {
9344    /// Apple Seatbelt process sandbox.
9345    #[serde(rename = "seatbelt")]
9346    Seatbelt,
9347    /// Linux Bubblewrap process sandbox.
9348    #[serde(rename = "bubblewrap")]
9349    Bubblewrap,
9350    /// Windows ProcessContainer sandbox.
9351    #[serde(rename = "process_container")]
9352    ProcessContainer,
9353    /// No supported process-containment backend is available.
9354    #[serde(rename = "unsupported")]
9355    Unsupported,
9356    /// Unknown variant for forward compatibility.
9357    #[default]
9358    #[serde(other)]
9359    Unknown,
9360}
9361
9362/// Customer-controllable sandbox governance area
9363#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9364pub enum SandboxControl {
9365    /// Process containment and sandbox spawn behavior.
9366    #[serde(rename = "process")]
9367    Process,
9368    /// Filesystem read, write, and deny policy.
9369    #[serde(rename = "filesystem")]
9370    Filesystem,
9371    /// Outbound and local-network access policy.
9372    #[serde(rename = "network")]
9373    Network,
9374    /// Selection of the sandbox or built-in enforcement route.
9375    #[serde(rename = "routing")]
9376    Routing,
9377    /// Decisions to run outside the process sandbox, whether requested by the model or resolved by a person.
9378    #[serde(rename = "bypass")]
9379    Bypass,
9380    /// Credential and keychain capability injection.
9381    #[serde(rename = "credentials")]
9382    Credentials,
9383    /// Host-platform and backend support behavior.
9384    #[serde(rename = "platform")]
9385    Platform,
9386    /// Unknown variant for forward compatibility.
9387    #[default]
9388    #[serde(other)]
9389    Unknown,
9390}
9391
9392/// Finite reason why sandbox enforcement is weaker than configured
9393#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9394pub enum SandboxDegradationReason {
9395    /// The selected backend cannot enforce per-path deny rules.
9396    #[serde(rename = "denied_paths_unsupported")]
9397    DeniedPathsUnsupported,
9398    /// The host platform has no supported process-containment backend.
9399    #[serde(rename = "unsupported_platform")]
9400    UnsupportedPlatform,
9401    /// Unknown variant for forward compatibility.
9402    #[default]
9403    #[serde(other)]
9404    Unknown,
9405}
9406
9407/// Runtime boundary that enforced or routed a sandbox decision
9408#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9409pub enum SandboxEnforcementPoint {
9410    /// Shell command process containment.
9411    #[serde(rename = "shell")]
9412    Shell,
9413    /// Built-in filesystem policy enforcement.
9414    #[serde(rename = "builtin_filesystem")]
9415    BuiltinFilesystem,
9416    /// Search-tool sandbox or policy enforcement.
9417    #[serde(rename = "search")]
9418    Search,
9419    /// Web-fetch network policy enforcement.
9420    #[serde(rename = "web_fetch")]
9421    WebFetch,
9422    /// Model Context Protocol server routing.
9423    #[serde(rename = "mcp")]
9424    Mcp,
9425    /// Language server process routing.
9426    #[serde(rename = "lsp")]
9427    Lsp,
9428    /// Unknown variant for forward compatibility.
9429    #[default]
9430    #[serde(other)]
9431    Unknown,
9432}
9433
9434/// Sandbox decision variant discriminator.
9435#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9436pub enum SandboxDecisionDataPolicyResolvedKind {
9437    #[serde(rename = "policy_resolved")]
9438    #[default]
9439    PolicyResolved,
9440}
9441
9442/// Finite result of a sandbox decision. Each `SandboxDecisionData` variant uses a disjoint subset: `policy_resolved` is `resolved | degraded`, `spawn_completed` and `permissive_retry_completed` are `succeeded | failed`, `enforcement_state` is `engaged | inactive | failed`, `access_denied` is `denied`, and escalation decisions are `approved | declined`.
9443#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9444pub enum SandboxOutcome {
9445    /// The sandbox policy resolved successfully. Describes configuration only and makes no claim that a backend engaged.
9446    #[serde(rename = "resolved")]
9447    Resolved,
9448    /// No sandbox governed the workload.
9449    #[serde(rename = "inactive")]
9450    Inactive,
9451    /// A runtime-owned containment backend accepted the workload. Evidence of engagement, not of verified containment for the workload's lifetime.
9452    #[serde(rename = "engaged")]
9453    Engaged,
9454    /// The sandbox operation completed successfully.
9455    #[serde(rename = "succeeded")]
9456    Succeeded,
9457    /// The sandbox operation failed.
9458    #[serde(rename = "failed")]
9459    Failed,
9460    /// The sandbox is active with one or more controls weakened by platform limitations or an explicitly selected relaxed mode.
9461    #[serde(rename = "degraded")]
9462    Degraded,
9463    /// An enforcement check refused the requested access.
9464    #[serde(rename = "denied")]
9465    Denied,
9466    /// A request to run outside the process sandbox was granted.
9467    #[serde(rename = "approved")]
9468    Approved,
9469    /// A request to run outside the process sandbox was not granted.
9470    #[serde(rename = "declined")]
9471    Declined,
9472    /// Unknown variant for forward compatibility.
9473    #[default]
9474    #[serde(other)]
9475    Unknown,
9476}
9477
9478/// Host operating-system family used for sandbox enforcement
9479#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9480pub enum SandboxPlatform {
9481    /// Apple macOS host.
9482    #[serde(rename = "macos")]
9483    Macos,
9484    /// Linux host.
9485    #[serde(rename = "linux")]
9486    Linux,
9487    /// Microsoft Windows host.
9488    #[serde(rename = "windows")]
9489    Windows,
9490    /// Host platform outside the explicitly supported families.
9491    #[serde(rename = "other")]
9492    Other,
9493    /// Unknown variant for forward compatibility.
9494    #[default]
9495    #[serde(other)]
9496    Unknown,
9497}
9498
9499/// Origin of the effective sandbox policy
9500#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9501pub enum SandboxPolicySource {
9502    /// Runtime default sandbox policy.
9503    #[serde(rename = "default_policy")]
9504    DefaultPolicy,
9505    /// User-configured sandbox policy merged with runtime-required grants.
9506    #[serde(rename = "user_policy")]
9507    UserPolicy,
9508    /// Unknown variant for forward compatibility.
9509    #[default]
9510    #[serde(other)]
9511    Unknown,
9512}
9513
9514/// Bounded classification of effective sandbox proxy routing
9515#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9516pub enum SandboxProxyMode {
9517    /// No sandbox proxy is configured.
9518    #[serde(rename = "none")]
9519    None,
9520    /// Traffic routes through a loopback proxy.
9521    #[serde(rename = "loopback")]
9522    Loopback,
9523    /// Traffic routes through a non-loopback proxy endpoint.
9524    #[serde(rename = "external")]
9525    External,
9526    /// Unknown variant for forward compatibility.
9527    #[default]
9528    #[serde(other)]
9529    Unknown,
9530}
9531
9532/// Sandbox decision variant discriminator.
9533#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9534pub enum SandboxDecisionDataSpawnCompletedKind {
9535    #[serde(rename = "spawn_completed")]
9536    #[default]
9537    SpawnCompleted,
9538}
9539
9540/// Runtime observation backing an enforcement-state or denial claim. Absent on `enforcement_state` when no observation backs the state.
9541#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9542pub enum SandboxAttestation {
9543    /// A containment backend accepted and applied the spawn request.
9544    #[serde(rename = "spawn_succeeded")]
9545    SpawnSucceeded,
9546    /// The spawn was refused for lack of a usable containment backend.
9547    #[serde(rename = "unsupported")]
9548    Unsupported,
9549    /// A runtime-owned policy check ran and returned a verdict. Attests the check, not that the caller honoured it.
9550    #[serde(rename = "builtin_policy_checked")]
9551    BuiltinPolicyChecked,
9552    /// Unknown variant for forward compatibility.
9553    #[default]
9554    #[serde(other)]
9555    Unknown,
9556}
9557
9558/// Sandbox decision variant discriminator.
9559#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9560pub enum SandboxDecisionDataEnforcementStateKind {
9561    #[serde(rename = "enforcement_state")]
9562    #[default]
9563    EnforcementState,
9564}
9565
9566/// How strong the evidence behind a denial is. A denial the sandbox itself recorded is a fact; one inferred from a command's output text is a judgement, and an analysis that cannot tell them apart will treat a false positive as enforcement.
9567#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9568pub enum SandboxDenialConfidence {
9569    /// The sandbox's own denial capture recorded the refused access. The strongest evidence available: the kernel observed it, not the runtime.
9570    #[serde(rename = "captured")]
9571    Captured,
9572    /// The command named a path that the effective policy independently denies. No capture confirmed it, but the policy did.
9573    #[serde(rename = "policy_corroborated")]
9574    PolicyCorroborated,
9575    /// The failure carried a fingerprint the sandbox itself emits, so the sandbox is known to have refused something even though the resource was not confirmed.
9576    #[serde(rename = "sandbox_reported")]
9577    SandboxReported,
9578    /// Classified from the command's own output text alone. The weakest evidence: a command that merely prints sandbox-like wording reaches this level.
9579    #[serde(rename = "output_classified")]
9580    OutputClassified,
9581    /// Unknown variant for forward compatibility.
9582    #[default]
9583    #[serde(other)]
9584    Unknown,
9585}
9586
9587/// Bounded class of access an enforcement check refused. Raw resources, commands, and process names accompany it only when content capture is enabled; diagnostic text and matched rules are never exported.
9588#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9589pub enum SandboxDenialClass {
9590    /// A read was refused because the effective policy does not grant it.
9591    #[serde(rename = "filesystem_read")]
9592    FilesystemRead,
9593    /// A write was refused. Distinct from `filesystem_read` because a read-only grant denies writes to a path it otherwise permits.
9594    #[serde(rename = "filesystem_write")]
9595    FilesystemWrite,
9596    /// A process could not start because the sandbox refused a required process-scoped resource. Currently emitted for the Windows MSYS `BaseNamedObjects` fork failure confirmed by learning-mode capture.
9597    #[serde(rename = "process_startup")]
9598    ProcessStartup,
9599    /// Windows registry access was refused and correlated with capture evidence.
9600    #[serde(rename = "registry_access")]
9601    RegistryAccess,
9602    /// Windows ALPC or RPC access was refused and correlated with capture evidence.
9603    #[serde(rename = "ipc_access")]
9604    IpcAccess,
9605    /// Access to another Windows process was refused and correlated with capture evidence.
9606    #[serde(rename = "process_access")]
9607    ProcessAccess,
9608    /// Windows job-object access was refused and correlated with capture evidence.
9609    #[serde(rename = "job_access")]
9610    JobAccess,
9611    /// Windows UI-handle access was refused and correlated with capture evidence.
9612    #[serde(rename = "ui_access")]
9613    UiAccess,
9614    /// Windows service-control-manager access was refused and correlated with capture evidence.
9615    #[serde(rename = "service_access")]
9616    ServiceAccess,
9617    /// An outbound connection was refused by `network.allowOutbound`.
9618    #[serde(rename = "network_outbound")]
9619    NetworkOutbound,
9620    /// A connection to a local or loopback destination was refused by `network.allowLocalNetwork`.
9621    #[serde(rename = "network_local")]
9622    NetworkLocal,
9623    /// A destination was refused by the sandbox host allow/deny rules.
9624    #[serde(rename = "network_host")]
9625    NetworkHost,
9626    /// The sandbox's denial capture recorded a refusal its record does not attribute to a more specific control: an unclassified resource (registry, COM, section object) or an AppContainer capability with no network meaning. Deliberately generic — the capture proves the denial happened, and naming a narrower class than the record supports would be a guess.
9627    #[serde(rename = "other_access")]
9628    OtherAccess,
9629    /// Unknown variant for forward compatibility.
9630    #[default]
9631    #[serde(other)]
9632    Unknown,
9633}
9634
9635/// Sandbox decision variant discriminator.
9636#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9637pub enum SandboxDecisionDataAccessDeniedKind {
9638    #[serde(rename = "access_denied")]
9639    #[default]
9640    AccessDenied,
9641}
9642
9643/// Sandbox decision variant discriminator.
9644#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9645pub enum SandboxDecisionDataBypassDecidedKind {
9646    #[serde(rename = "bypass_decided")]
9647    #[default]
9648    BypassDecided,
9649}
9650
9651/// Where a request to run outside the process sandbox originated. Orthogonal to the outcome: the same verdict means a different thing depending on where the request came from.
9652#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9653pub enum SandboxBypassSource {
9654    /// No longer produced. The model could once ask for a bypass in the tool call itself; no tool exposes that parameter now. Retained so historical events still deserialize.
9655    #[serde(rename = "model_requested")]
9656    ModelRequested,
9657    /// The runtime raised the prompt itself — either after a sandboxed attempt looked blocked, or before a run the sandbox cannot enforce at all, such as a detached command — and a person answered it. In the second case nothing had executed when the decision was made.
9658    #[serde(rename = "user_prompted")]
9659    UserPrompted,
9660    /// The runtime raised the prompt itself — after a sandboxed attempt looked blocked, or before a run it cannot enforce — but the permission flow produced no confirmed human answer. This includes unavailable or unreadable prompts, cancellation, and automated rule, hook, or content-exclusion denials.
9661    #[serde(rename = "prompt_unavailable")]
9662    PromptUnavailable,
9663    /// Unknown variant for forward compatibility.
9664    #[default]
9665    #[serde(other)]
9666    Unknown,
9667}
9668
9669/// Sandbox decision variant discriminator.
9670#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9671pub enum SandboxDecisionDataPermissiveRetryDecidedKind {
9672    #[serde(rename = "permissive_retry_decided")]
9673    #[default]
9674    PermissiveRetryDecided,
9675}
9676
9677/// Sandbox decision variant discriminator.
9678#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9679pub enum SandboxDecisionDataPermissiveRetryCompletedKind {
9680    #[serde(rename = "permissive_retry_completed")]
9681    #[default]
9682    PermissiveRetryCompleted,
9683}
9684
9685/// Payload of `sandbox.decision`, a bounded governance record of what the process sandbox was configured to do and whether it took effect. Discriminated by `kind`.
9686#[derive(Debug, Clone, Serialize, Deserialize)]
9687#[serde(untagged)]
9688pub enum SandboxDecisionData {
9689    PolicyResolved(SandboxDecisionDataPolicyResolved),
9690    SpawnCompleted(SandboxDecisionDataSpawnCompleted),
9691    EnforcementState(SandboxDecisionDataEnforcementState),
9692    AccessDenied(SandboxDecisionDataAccessDenied),
9693    BypassDecided(SandboxDecisionDataBypassDecided),
9694    PermissiveRetryDecided(SandboxDecisionDataPermissiveRetryDecided),
9695    PermissiveRetryCompleted(SandboxDecisionDataPermissiveRetryCompleted),
9696}
9697
9698/// Authority or runtime mechanism responsible for sub-agent model selection.
9699#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9700pub enum SubagentModelSelectionSource {
9701    /// Explicit model supplied by the parent agent on the task call and selected for dispatch.
9702    #[serde(rename = "explicit_override")]
9703    ExplicitOverride,
9704    /// Required model policy configured for the sub-agent.
9705    #[serde(rename = "configured_required")]
9706    ConfiguredRequired,
9707    /// Non-required model preference configured for the sub-agent.
9708    #[serde(rename = "configured_preference")]
9709    ConfiguredPreference,
9710    /// Complementary-model default selected for the sub-agent.
9711    #[serde(rename = "complementary_default")]
9712    ComplementaryDefault,
9713    /// Model inherited from the parent session.
9714    #[serde(rename = "session_inheritance")]
9715    SessionInheritance,
9716    /// Default model declared by the agent definition.
9717    #[serde(rename = "agent_definition_default")]
9718    AgentDefinitionDefault,
9719    /// Runtime policy, Auto mode, or an experiment selected the model.
9720    #[serde(rename = "runtime_policy")]
9721    RuntimePolicy,
9722    /// Unknown variant for forward compatibility.
9723    #[default]
9724    #[serde(other)]
9725    Unknown,
9726}
9727
9728/// Where the model input for a task-tool sub-agent came from.
9729#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9730pub enum SubagentTaskModelSource {
9731    /// The spawning agent supplied the task tool's model argument.
9732    #[serde(rename = "task_argument")]
9733    TaskArgument,
9734    /// The task omitted a model and the per-sub-agent settings entry supplied a concrete one.
9735    #[serde(rename = "subagent_configuration")]
9736    SubagentConfiguration,
9737    /// The task omitted a model and the user-defined custom agent's definition supplied one.
9738    #[serde(rename = "custom_agent_definition")]
9739    CustomAgentDefinition,
9740    /// Neither the task call, the per-sub-agent settings entry, nor a custom agent definition supplied a model.
9741    #[serde(rename = "unset")]
9742    Unset,
9743    /// Unknown variant for forward compatibility.
9744    #[default]
9745    #[serde(other)]
9746    Unknown,
9747}
9748
9749/// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
9750#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9751pub enum BinaryAssetType {
9752    /// Binary image data.
9753    #[serde(rename = "image")]
9754    Image,
9755    /// Other binary resource data.
9756    #[serde(rename = "resource")]
9757    Resource,
9758    /// Unknown variant for forward compatibility.
9759    #[default]
9760    #[serde(other)]
9761    Unknown,
9762}
9763
9764/// Message role: "system" for system prompts, "developer" for developer-injected instructions
9765#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9766pub enum SystemMessageRole {
9767    /// System prompt message.
9768    #[serde(rename = "system")]
9769    System,
9770    /// Developer instruction message.
9771    #[serde(rename = "developer")]
9772    Developer,
9773    /// Unknown variant for forward compatibility.
9774    #[default]
9775    #[serde(other)]
9776    Unknown,
9777}
9778
9779/// Permission kind discriminator
9780#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9781pub enum PermissionRequestShellKind {
9782    #[serde(rename = "shell")]
9783    #[default]
9784    Shell,
9785}
9786
9787/// Permission kind discriminator
9788#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9789pub enum PermissionRequestWriteKind {
9790    #[serde(rename = "write")]
9791    #[default]
9792    Write,
9793}
9794
9795/// Permission kind discriminator
9796#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9797pub enum PermissionRequestReadKind {
9798    #[serde(rename = "read")]
9799    #[default]
9800    Read,
9801}
9802
9803/// Permission kind discriminator
9804#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9805pub enum PermissionRequestMcpKind {
9806    #[serde(rename = "mcp")]
9807    #[default]
9808    Mcp,
9809}
9810
9811/// Advisory recommendation the runtime attaches to a permission request whose origin it can vouch for by construction. Unlike the auto-approval judge this does not depend on auto mode and does not evaluate what the tool call does; its absence simply means the runtime has no opinion and the request follows the host's normal approval flow.
9812///
9813/// <div class="warning">
9814///
9815/// **Experimental.** This type is part of an experimental wire-protocol surface
9816/// and may change or be removed in future SDK or CLI releases.
9817///
9818/// </div>
9819#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9820pub enum PermissionRecommendation {
9821    /// The runtime vouches for the request's origin and recommends approving it without prompting. The host still owns the decision and may deny it; deny rules, managed policy, and the auto-approval safety judge all outrank this recommendation.
9822    #[serde(rename = "approve")]
9823    Approve,
9824    /// Unknown variant for forward compatibility.
9825    #[default]
9826    #[serde(other)]
9827    Unknown,
9828}
9829
9830/// Permission kind discriminator
9831#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9832pub enum PermissionRequestUrlKind {
9833    #[serde(rename = "url")]
9834    #[default]
9835    Url,
9836}
9837
9838/// Whether this is a store or vote memory operation
9839#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9840pub enum PermissionRequestMemoryAction {
9841    /// Store a new memory.
9842    #[serde(rename = "store")]
9843    Store,
9844    /// Vote on an existing memory.
9845    #[serde(rename = "vote")]
9846    Vote,
9847    /// Unknown variant for forward compatibility.
9848    #[default]
9849    #[serde(other)]
9850    Unknown,
9851}
9852
9853/// Stage that produced this attribution.
9854#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9855pub enum PermissionApprovalEvaluationEvaluationStage {
9856    /// The attribution stage is unknown.
9857    #[serde(rename = "unknown")]
9858    UnknownValue,
9859    /// The request resolved before assisted-approval evaluation.
9860    #[serde(rename = "not_reached")]
9861    NotReached,
9862    /// A runtime gate skipped the judge.
9863    #[serde(rename = "pre_judge")]
9864    PreJudge,
9865    /// The judge interface produced the evaluation.
9866    #[serde(rename = "judge")]
9867    Judge,
9868    /// A cached recommendation or another request's outcome was reused.
9869    #[serde(rename = "reuse")]
9870    Reuse,
9871    /// Unknown variant for forward compatibility.
9872    #[default]
9873    #[serde(other)]
9874    Unknown,
9875}
9876
9877/// Status of the local judge interface, not proof of a model network call.
9878#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9879pub enum PermissionApprovalEvaluationJudgeStatus {
9880    /// No authoritative attribution is available.
9881    #[serde(rename = "unknown")]
9882    UnknownValue,
9883    /// This evaluation did not invoke the judge interface.
9884    #[serde(rename = "not_called")]
9885    NotCalled,
9886    /// The judge interface returned a usable verdict.
9887    #[serde(rename = "completed")]
9888    Completed,
9889    /// The judge interface returned an error.
9890    #[serde(rename = "failed")]
9891    Failed,
9892    /// This evaluation reused a cached recommendation.
9893    #[serde(rename = "cached")]
9894    Cached,
9895    /// This request inherited another decision without local judge attribution.
9896    #[serde(rename = "inherited")]
9897    Inherited,
9898    /// Unknown variant for forward compatibility.
9899    #[default]
9900    #[serde(other)]
9901    Unknown,
9902}
9903
9904/// Machine-readable runtime gate reason, never a command, path or human rationale.
9905#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9906pub enum PermissionApprovalEvaluationReasonCode {
9907    /// Attribution is missing or outside the supported vocabulary.
9908    #[serde(rename = "unknown")]
9909    UnknownValue,
9910    /// The request resolved before assisted-approval evaluation.
9911    #[serde(rename = "not-reached")]
9912    NotReached,
9913    /// Assisted approval was inactive for this request.
9914    #[serde(rename = "inactive")]
9915    Inactive,
9916    /// The judge was skipped because authorization extraction could not safely establish a complete recent history.
9917    #[serde(rename = "authorization-history-incomplete")]
9918    AuthorizationHistoryIncomplete,
9919    /// Managed policy required a human decision.
9920    #[serde(rename = "managed-approval-required")]
9921    ManagedApprovalRequired,
9922    /// The request asked to bypass sandbox restrictions.
9923    #[serde(rename = "sandbox-bypass")]
9924    SandboxBypass,
9925    /// An action field exceeded the judge input limit.
9926    #[serde(rename = "action-too-long")]
9927    ActionTooLong,
9928    /// The script path was not authorized for inspection.
9929    #[serde(rename = "path-not-authorized")]
9930    PathNotAuthorized,
9931    /// The script working directory was invalid.
9932    #[serde(rename = "invalid-working-directory")]
9933    InvalidWorkingDirectory,
9934    /// The script snapshot could not be read.
9935    #[serde(rename = "unreadable")]
9936    Unreadable,
9937    /// The script path was not a regular file.
9938    #[serde(rename = "not-regular-file")]
9939    NotRegularFile,
9940    /// The script snapshot exceeded the size limit.
9941    #[serde(rename = "too-large")]
9942    TooLarge,
9943    /// The script snapshot was not UTF-8.
9944    #[serde(rename = "non-utf8")]
9945    NonUtf8,
9946    /// The script interpreter could not be inspected.
9947    #[serde(rename = "interpreter-unavailable")]
9948    InterpreterUnavailable,
9949    /// The interpreter snapshot exceeded the size limit.
9950    #[serde(rename = "interpreter-too-large")]
9951    InterpreterTooLarge,
9952    /// The shell environment could not be reviewed.
9953    #[serde(rename = "shell-environment-unreviewable")]
9954    ShellEnvironmentUnreviewable,
9955    /// A script path could not be represented for review.
9956    #[serde(rename = "unrepresentable-path")]
9957    UnrepresentablePath,
9958    /// An interpreter wrapped a script that could not be reviewed.
9959    #[serde(rename = "interpreter-wrapped-script")]
9960    InterpreterWrappedScript,
9961    /// The script invocation could not be reviewed.
9962    #[serde(rename = "unreviewable-script-invocation")]
9963    UnreviewableScriptInvocation,
9964    /// The script argument binding could not be reviewed.
9965    #[serde(rename = "argument-binding-unreviewable")]
9966    ArgumentBindingUnreviewable,
9967    /// The script review metadata was malformed.
9968    #[serde(rename = "malformed-script-action-review")]
9969    MalformedScriptActionReview,
9970    /// The script snapshot manifest was malformed.
9971    #[serde(rename = "malformed-script-action-manifest")]
9972    MalformedScriptActionManifest,
9973    /// Script review was unavailable.
9974    #[serde(rename = "unavailable")]
9975    Unavailable,
9976    /// The judge interface returned a usable verdict.
9977    #[serde(rename = "judge-verdict")]
9978    JudgeVerdict,
9979    /// The judge interface returned an error.
9980    #[serde(rename = "judge-error")]
9981    JudgeError,
9982    /// The request inherited an outcome from another decision.
9983    #[serde(rename = "inherited")]
9984    Inherited,
9985    /// Unknown variant for forward compatibility.
9986    #[default]
9987    #[serde(other)]
9988    Unknown,
9989}
9990
9991/// Why the assisted-approval judge produced no usable recommendation. Present only alongside an `error` recommendation, where the human-readable reason is a fixed string and therefore cannot distinguish these cases. Intended to make a judge failure reportable by a consumer that has no access to the host's logs.
9992///
9993/// <div class="warning">
9994///
9995/// **Experimental.** This type is part of an experimental wire-protocol surface
9996/// and may change or be removed in future SDK or CLI releases.
9997///
9998/// </div>
9999#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10000pub enum AssistedApprovalJudgeFailureReason {
10001    /// The judge model call exceeded its deadline.
10002    #[serde(rename = "timeout")]
10003    Timeout,
10004    /// The judge model call was cancelled before it returned.
10005    #[serde(rename = "abort")]
10006    Abort,
10007    /// The judge model call completed but returned no content.
10008    #[serde(rename = "empty_response")]
10009    EmptyResponse,
10010    /// The judge model call failed (for example a transport, authentication, or rate-limit error).
10011    #[serde(rename = "model_error")]
10012    ModelError,
10013    /// The judge model replied, but the reply carried no ALLOW/DENY verdict.
10014    #[serde(rename = "parse_error")]
10015    ParseError,
10016    /// Unknown variant for forward compatibility.
10017    #[default]
10018    #[serde(other)]
10019    Unknown,
10020}
10021
10022/// Outcome of the assisted-approval safety judge for a permission request. Present only in assisted mode; its absence means the judge did not evaluate the request.
10023///
10024/// <div class="warning">
10025///
10026/// **Experimental.** This type is part of an experimental wire-protocol surface
10027/// and may change or be removed in future SDK or CLI releases.
10028///
10029/// </div>
10030#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10031pub enum AssistedApprovalRecommendation {
10032    /// The judge evaluated the request and recommends automatically approving it.
10033    #[serde(rename = "approve")]
10034    Approve,
10035    /// The judge evaluated the request and does not recommend automatically approving it; explicit approval is required. Whether that means prompting, denying, or something else is the consumer's decision.
10036    #[serde(rename = "requireApproval")]
10037    RequireApproval,
10038    /// Assisted mode is enabled, but this request category is never automatically approvable (for example, sandbox-bypass requests), so the judge was not consulted.
10039    #[serde(rename = "excluded")]
10040    Excluded,
10041    /// The judge was consulted but did not return a usable recommendation, so the request requires explicit approval.
10042    #[serde(rename = "error")]
10043    Error,
10044    /// Unknown variant for forward compatibility.
10045    #[default]
10046    #[serde(other)]
10047    Unknown,
10048}
10049
10050/// Vote direction (vote only)
10051#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10052pub enum PermissionRequestMemoryDirection {
10053    /// Vote that the memory is useful or accurate.
10054    #[serde(rename = "upvote")]
10055    Upvote,
10056    /// Vote that the memory is incorrect or outdated.
10057    #[serde(rename = "downvote")]
10058    Downvote,
10059    /// Unknown variant for forward compatibility.
10060    #[default]
10061    #[serde(other)]
10062    Unknown,
10063}
10064
10065/// Permission kind discriminator
10066#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10067pub enum PermissionRequestMemoryKind {
10068    #[serde(rename = "memory")]
10069    #[default]
10070    Memory,
10071}
10072
10073/// Scope of a stored memory.
10074#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10075pub enum PermissionRequestMemoryScope {
10076    /// Store the memory for the current repository.
10077    #[serde(rename = "repository")]
10078    Repository,
10079    /// Store the memory for the current user.
10080    #[serde(rename = "user")]
10081    User,
10082    /// Unknown variant for forward compatibility.
10083    #[default]
10084    #[serde(other)]
10085    Unknown,
10086}
10087
10088/// Permission kind discriminator
10089#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10090pub enum PermissionRequestCustomToolKind {
10091    #[serde(rename = "custom-tool")]
10092    #[default]
10093    CustomTool,
10094}
10095
10096/// Permission kind discriminator
10097#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10098pub enum PermissionRequestHookKind {
10099    #[serde(rename = "hook")]
10100    #[default]
10101    Hook,
10102}
10103
10104/// Permission kind discriminator
10105#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10106pub enum PermissionRequestExtensionManagementKind {
10107    #[serde(rename = "extension-management")]
10108    #[default]
10109    ExtensionManagement,
10110}
10111
10112/// Permission kind discriminator
10113#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10114pub enum PermissionRequestFactoryKind {
10115    #[serde(rename = "factory")]
10116    #[default]
10117    Factory,
10118}
10119
10120/// Operation gated by a factory permission request.
10121#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10122pub enum FactoryPermissionOperation {
10123    /// Running a registered factory, which spends subagents, active time, and AI credits under the approved limits.
10124    #[serde(rename = "run")]
10125    Run,
10126    /// Authoring a factory, which writes JavaScript into a session-scoped extension and loads it.
10127    #[serde(rename = "author")]
10128    Author,
10129    /// Unknown variant for forward compatibility.
10130    #[default]
10131    #[serde(other)]
10132    Unknown,
10133}
10134
10135/// Permission kind discriminator
10136#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10137pub enum PermissionRequestExtensionPermissionAccessKind {
10138    #[serde(rename = "extension-permission-access")]
10139    #[default]
10140    ExtensionPermissionAccess,
10141}
10142
10143/// Permission kind discriminator
10144#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10145pub enum PermissionRequestExtensionEnvAccessKind {
10146    #[serde(rename = "extension-env-access")]
10147    #[default]
10148    ExtensionEnvAccess,
10149}
10150
10151/// Details of the permission being requested
10152#[derive(Debug, Clone, Serialize, Deserialize)]
10153#[serde(untagged)]
10154pub enum PermissionRequest {
10155    Shell(PermissionRequestShell),
10156    Write(PermissionRequestWrite),
10157    Read(PermissionRequestRead),
10158    Mcp(PermissionRequestMcp),
10159    Url(PermissionRequestUrl),
10160    Memory(PermissionRequestMemory),
10161    CustomTool(PermissionRequestCustomTool),
10162    Hook(PermissionRequestHook),
10163    ExtensionManagement(PermissionRequestExtensionManagement),
10164    Factory(PermissionRequestFactory),
10165    ExtensionPermissionAccess(PermissionRequestExtensionPermissionAccess),
10166    ExtensionEnvAccess(PermissionRequestExtensionEnvAccess),
10167}
10168
10169/// Prompt kind discriminator
10170#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10171pub enum PermissionPromptRequestCommandsKind {
10172    #[serde(rename = "commands")]
10173    #[default]
10174    Commands,
10175}
10176
10177/// Prompt kind discriminator
10178#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10179pub enum PermissionPromptRequestWriteKind {
10180    #[serde(rename = "write")]
10181    #[default]
10182    Write,
10183}
10184
10185/// Prompt kind discriminator
10186#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10187pub enum PermissionPromptRequestReadKind {
10188    #[serde(rename = "read")]
10189    #[default]
10190    Read,
10191}
10192
10193/// Prompt kind discriminator
10194#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10195pub enum PermissionPromptRequestMcpKind {
10196    #[serde(rename = "mcp")]
10197    #[default]
10198    Mcp,
10199}
10200
10201/// Prompt kind discriminator
10202#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10203pub enum PermissionPromptRequestUrlKind {
10204    #[serde(rename = "url")]
10205    #[default]
10206    Url,
10207}
10208
10209/// Prompt kind discriminator
10210#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10211pub enum PermissionPromptRequestMemoryKind {
10212    #[serde(rename = "memory")]
10213    #[default]
10214    Memory,
10215}
10216
10217/// Prompt kind discriminator
10218#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10219pub enum PermissionPromptRequestCustomToolKind {
10220    #[serde(rename = "custom-tool")]
10221    #[default]
10222    CustomTool,
10223}
10224
10225/// Underlying permission kind that needs path approval
10226#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10227pub enum PermissionPromptRequestPathAccessKind {
10228    /// Read access to a filesystem path.
10229    #[serde(rename = "read")]
10230    Read,
10231    /// Shell command access involving a filesystem path.
10232    #[serde(rename = "shell")]
10233    Shell,
10234    /// Write access to a filesystem path.
10235    #[serde(rename = "write")]
10236    Write,
10237    /// Unknown variant for forward compatibility.
10238    #[default]
10239    #[serde(other)]
10240    Unknown,
10241}
10242
10243/// Prompt kind discriminator
10244#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10245pub enum PermissionPromptRequestPathKind {
10246    #[serde(rename = "path")]
10247    #[default]
10248    Path,
10249}
10250
10251/// Prompt kind discriminator
10252#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10253pub enum PermissionPromptRequestHookKind {
10254    #[serde(rename = "hook")]
10255    #[default]
10256    Hook,
10257}
10258
10259/// Prompt kind discriminator
10260#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10261pub enum PermissionPromptRequestExtensionManagementKind {
10262    #[serde(rename = "extension-management")]
10263    #[default]
10264    ExtensionManagement,
10265}
10266
10267/// Prompt kind discriminator
10268#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10269pub enum PermissionPromptRequestFactoryKind {
10270    #[serde(rename = "factory")]
10271    #[default]
10272    Factory,
10273}
10274
10275/// Prompt kind discriminator
10276#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10277pub enum PermissionPromptRequestExtensionPermissionAccessKind {
10278    #[serde(rename = "extension-permission-access")]
10279    #[default]
10280    ExtensionPermissionAccess,
10281}
10282
10283/// Prompt kind discriminator
10284#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10285pub enum PermissionPromptRequestExtensionEnvAccessKind {
10286    #[serde(rename = "extension-env-access")]
10287    #[default]
10288    ExtensionEnvAccess,
10289}
10290
10291/// Derived user-facing permission prompt details for UI consumers
10292#[derive(Debug, Clone, Serialize, Deserialize)]
10293#[serde(untagged)]
10294pub enum PermissionPromptRequest {
10295    Commands(PermissionPromptRequestCommands),
10296    Write(PermissionPromptRequestWrite),
10297    Read(PermissionPromptRequestRead),
10298    Mcp(PermissionPromptRequestMcp),
10299    Url(PermissionPromptRequestUrl),
10300    Memory(PermissionPromptRequestMemory),
10301    CustomTool(PermissionPromptRequestCustomTool),
10302    Path(PermissionPromptRequestPath),
10303    Hook(PermissionPromptRequestHook),
10304    ExtensionManagement(PermissionPromptRequestExtensionManagement),
10305    Factory(PermissionPromptRequestFactory),
10306    ExtensionPermissionAccess(PermissionPromptRequestExtensionPermissionAccess),
10307    ExtensionEnvAccess(PermissionPromptRequestExtensionEnvAccess),
10308}
10309
10310/// Controlled reason or actor responsible for a permission response.
10311#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10312pub enum PermissionDecisionSource {
10313    /// The response followed the assisted-approval judge recommendation.
10314    #[serde(rename = "assisted_approval")]
10315    AssistedApproval,
10316    /// A human supplied the response through an interactive prompt.
10317    #[serde(rename = "human_response")]
10318    HumanResponse,
10319    /// The host applied a standing policy or override rather than a judge recommendation or human decision.
10320    #[serde(rename = "host_policy")]
10321    HostPolicy,
10322    /// The host denied the request because no interactive user response was available.
10323    #[serde(rename = "unattended_fallback")]
10324    UnattendedFallback,
10325    /// A live authorization record from an earlier human decision in this session contained the proposal, so it ran without another prompt. This is not a new human decision and never mints authority of its own.
10326    #[serde(rename = "authorization_carry_forward")]
10327    AuthorizationCarryForward,
10328    /// Unknown variant for forward compatibility.
10329    #[default]
10330    #[serde(other)]
10331    Unknown,
10332}
10333
10334/// The permission request was approved
10335#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10336pub enum PermissionApprovedKind {
10337    #[serde(rename = "approved")]
10338    #[default]
10339    Approved,
10340}
10341
10342/// Command approval kind
10343#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10344pub enum UserToolSessionApprovalCommandsKind {
10345    #[serde(rename = "commands")]
10346    #[default]
10347    Commands,
10348}
10349
10350/// Read approval kind
10351#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10352pub enum UserToolSessionApprovalReadKind {
10353    #[serde(rename = "read")]
10354    #[default]
10355    Read,
10356}
10357
10358/// Write approval kind
10359#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10360pub enum UserToolSessionApprovalWriteKind {
10361    #[serde(rename = "write")]
10362    #[default]
10363    Write,
10364}
10365
10366/// MCP tool approval kind
10367#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10368pub enum UserToolSessionApprovalMcpKind {
10369    #[serde(rename = "mcp")]
10370    #[default]
10371    Mcp,
10372}
10373
10374/// Memory approval kind
10375#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10376pub enum UserToolSessionApprovalMemoryKind {
10377    #[serde(rename = "memory")]
10378    #[default]
10379    Memory,
10380}
10381
10382/// Custom tool approval kind
10383#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10384pub enum UserToolSessionApprovalCustomToolKind {
10385    #[serde(rename = "custom-tool")]
10386    #[default]
10387    CustomTool,
10388}
10389
10390/// Extension management approval kind
10391#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10392pub enum UserToolSessionApprovalExtensionManagementKind {
10393    #[serde(rename = "extension-management")]
10394    #[default]
10395    ExtensionManagement,
10396}
10397
10398/// Factory approval kind
10399#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10400pub enum UserToolSessionApprovalFactoryKind {
10401    #[serde(rename = "factory")]
10402    #[default]
10403    Factory,
10404}
10405
10406/// Extension permission access approval kind
10407#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10408pub enum UserToolSessionApprovalExtensionPermissionAccessKind {
10409    #[serde(rename = "extension-permission-access")]
10410    #[default]
10411    ExtensionPermissionAccess,
10412}
10413
10414/// Extension environment access approval kind
10415#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10416pub enum UserToolSessionApprovalExtensionEnvAccessKind {
10417    #[serde(rename = "extension-env-access")]
10418    #[default]
10419    ExtensionEnvAccess,
10420}
10421
10422/// The approval to add as a session-scoped rule
10423#[derive(Debug, Clone, Serialize, Deserialize)]
10424#[serde(untagged)]
10425pub enum UserToolSessionApproval {
10426    Commands(UserToolSessionApprovalCommands),
10427    Read(UserToolSessionApprovalRead),
10428    Write(UserToolSessionApprovalWrite),
10429    Mcp(UserToolSessionApprovalMcp),
10430    Memory(UserToolSessionApprovalMemory),
10431    CustomTool(UserToolSessionApprovalCustomTool),
10432    ExtensionManagement(UserToolSessionApprovalExtensionManagement),
10433    Factory(UserToolSessionApprovalFactory),
10434    ExtensionPermissionAccess(UserToolSessionApprovalExtensionPermissionAccess),
10435    ExtensionEnvAccess(UserToolSessionApprovalExtensionEnvAccess),
10436}
10437
10438/// Approved and remembered for the rest of the session
10439#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10440pub enum PermissionApprovedForSessionKind {
10441    #[serde(rename = "approved-for-session")]
10442    #[default]
10443    ApprovedForSession,
10444}
10445
10446/// Approved and persisted for this project location
10447#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10448pub enum PermissionApprovedForLocationKind {
10449    #[serde(rename = "approved-for-location")]
10450    #[default]
10451    ApprovedForLocation,
10452}
10453
10454/// The permission request was cancelled before a response was used
10455#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10456pub enum PermissionCancelledKind {
10457    #[serde(rename = "cancelled")]
10458    #[default]
10459    Cancelled,
10460}
10461
10462/// Denied because approval rules explicitly blocked it
10463#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10464pub enum PermissionDeniedByRulesKind {
10465    #[serde(rename = "denied-by-rules")]
10466    #[default]
10467    DeniedByRules,
10468}
10469
10470/// Denied because no approval rule matched and user confirmation was unavailable
10471#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10472pub enum PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind {
10473    #[serde(rename = "denied-no-approval-rule-and-could-not-request-from-user")]
10474    #[default]
10475    DeniedNoApprovalRuleAndCouldNotRequestFromUser,
10476}
10477
10478/// Denied by the user during an interactive prompt
10479#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10480pub enum PermissionDeniedInteractivelyByUserKind {
10481    #[serde(rename = "denied-interactively-by-user")]
10482    #[default]
10483    DeniedInteractivelyByUser,
10484}
10485
10486/// Denied by the organization's content exclusion policy
10487#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10488pub enum PermissionDeniedByContentExclusionPolicyKind {
10489    #[serde(rename = "denied-by-content-exclusion-policy")]
10490    #[default]
10491    DeniedByContentExclusionPolicy,
10492}
10493
10494/// Denied by a permission request hook registered by an extension or plugin
10495#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10496pub enum PermissionDeniedByPermissionRequestHookKind {
10497    #[serde(rename = "denied-by-permission-request-hook")]
10498    #[default]
10499    DeniedByPermissionRequestHook,
10500}
10501
10502/// The result of the permission request
10503#[derive(Debug, Clone, Serialize, Deserialize)]
10504#[serde(untagged)]
10505pub enum PermissionResult {
10506    Approved(PermissionApproved),
10507    ApprovedForSession(PermissionApprovedForSession),
10508    ApprovedForLocation(PermissionApprovedForLocation),
10509    Cancelled(PermissionCancelled),
10510    DeniedByRules(PermissionDeniedByRules),
10511    DeniedNoApprovalRuleAndCouldNotRequestFromUser(
10512        PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser,
10513    ),
10514    DeniedInteractivelyByUser(PermissionDeniedInteractivelyByUser),
10515    DeniedByContentExclusionPolicy(PermissionDeniedByContentExclusionPolicy),
10516    DeniedByPermissionRequestHook(PermissionDeniedByPermissionRequestHook),
10517}
10518
10519/// Which direction a message-backed authorization claim moves authority in.
10520///
10521/// <div class="warning">
10522///
10523/// **Experimental.** This type is part of an experimental wire-protocol surface
10524/// and may change or be removed in future SDK or CLI releases.
10525///
10526/// </div>
10527#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10528pub enum PermissionMessageAuthorizationPolarity {
10529    /// The human's words authorized an effect.
10530    #[serde(rename = "grant")]
10531    Grant,
10532    /// The human's words refused an effect.
10533    #[serde(rename = "denial")]
10534    Denial,
10535    /// Unknown variant for forward compatibility.
10536    #[default]
10537    #[serde(other)]
10538    Unknown,
10539}
10540
10541/// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
10542#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10543pub enum ElicitationRequestedMode {
10544    /// Structured form-based elicitation.
10545    #[serde(rename = "form")]
10546    Form,
10547    /// Browser URL-based elicitation.
10548    #[serde(rename = "url")]
10549    Url,
10550    /// Unknown variant for forward compatibility.
10551    #[default]
10552    #[serde(other)]
10553    Unknown,
10554}
10555
10556/// Schema type indicator (always 'object')
10557#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10558pub enum ElicitationRequestedSchemaType {
10559    #[serde(rename = "object")]
10560    #[default]
10561    Object,
10562}
10563
10564/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
10565#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10566pub enum ElicitationCompletedAction {
10567    /// The user submitted the requested form.
10568    #[serde(rename = "accept")]
10569    Accept,
10570    /// The user explicitly declined the request.
10571    #[serde(rename = "decline")]
10572    Decline,
10573    /// The user dismissed the request.
10574    #[serde(rename = "cancel")]
10575    Cancel,
10576    /// Unknown variant for forward compatibility.
10577    #[default]
10578    #[serde(other)]
10579    Unknown,
10580}
10581
10582/// Reason the runtime is requesting host-provided MCP OAuth credentials
10583#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10584pub enum McpOauthRequestReason {
10585    /// Initial credentials are required before connecting to the MCP server.
10586    #[serde(rename = "initial")]
10587    Initial,
10588    /// The current host-provided credential was rejected and a replacement is requested.
10589    #[serde(rename = "refresh")]
10590    Refresh,
10591    /// The server requires a new host authorization flow before continuing.
10592    #[serde(rename = "reauth")]
10593    Reauth,
10594    /// The server requires a credential with additional scope or audience.
10595    #[serde(rename = "upscope")]
10596    Upscope,
10597    /// Unknown variant for forward compatibility.
10598    #[default]
10599    #[serde(other)]
10600    Unknown,
10601}
10602
10603/// Optional non-default OAuth grant type. When set to 'client_credentials', the OAuth flow runs headlessly using the client_id + keychain-stored secret (no browser, no callback server).
10604#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10605pub enum McpOauthRequiredStaticClientConfigGrantType {
10606    #[serde(rename = "client_credentials")]
10607    #[default]
10608    ClientCredentials,
10609}
10610
10611/// How the pending MCP OAuth request was completed
10612#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10613pub enum McpOauthCompletionOutcome {
10614    /// The request completed with a token-backed OAuth provider.
10615    #[serde(rename = "token")]
10616    Token,
10617    /// The request completed without an OAuth provider.
10618    #[serde(rename = "cancelled")]
10619    Cancelled,
10620    /// Unknown variant for forward compatibility.
10621    #[default]
10622    #[serde(other)]
10623    Unknown,
10624}
10625
10626/// Why dynamic headers are being requested.
10627#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10628pub enum McpHeadersRefreshRequiredReason {
10629    /// The transport is making its first dynamic header request for this server.
10630    #[serde(rename = "startup")]
10631    Startup,
10632    /// The previously cached dynamic headers expired.
10633    #[serde(rename = "ttl-expired")]
10634    TtlExpired,
10635    /// The server returned 401 and stale dynamic headers were invalidated.
10636    #[serde(rename = "auth-failed")]
10637    AuthFailed,
10638    /// Unknown variant for forward compatibility.
10639    #[default]
10640    #[serde(other)]
10641    Unknown,
10642}
10643
10644/// How the pending MCP headers refresh request resolved.
10645#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10646pub enum McpHeadersRefreshCompletedOutcome {
10647    /// The host supplied dynamic headers.
10648    #[serde(rename = "headers")]
10649    Headers,
10650    /// The host responded with no dynamic headers.
10651    #[serde(rename = "none")]
10652    None,
10653    /// The host credential broker rejected or failed the refresh.
10654    #[serde(rename = "error")]
10655    Error,
10656    /// No response arrived within the bounded window.
10657    #[serde(rename = "timeout")]
10658    Timeout,
10659    /// Unknown variant for forward compatibility.
10660    #[default]
10661    #[serde(other)]
10662    Unknown,
10663}
10664
10665/// Lifecycle phase for a Rust-owned ephemeral query stream.
10666///
10667/// <div class="warning">
10668///
10669/// **Experimental.** This type is part of an experimental wire-protocol surface
10670/// and may change or be removed in future SDK or CLI releases.
10671///
10672/// </div>
10673#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10674pub enum UIEphemeralQueryPhase {
10675    /// The ephemeral query stream has begun.
10676    #[serde(rename = "started")]
10677    Started,
10678    /// A partial result chunk was produced by the stream.
10679    #[serde(rename = "chunk")]
10680    Chunk,
10681    /// The ephemeral query stream finished successfully.
10682    #[serde(rename = "completed")]
10683    Completed,
10684    /// The ephemeral query stream ended with an error.
10685    #[serde(rename = "failed")]
10686    Failed,
10687    /// The ephemeral query stream was cancelled before completing.
10688    #[serde(rename = "aborted")]
10689    Aborted,
10690    /// Unknown variant for forward compatibility.
10691    #[default]
10692    #[serde(other)]
10693    Unknown,
10694}
10695
10696/// The user's auto-mode-switch choice
10697#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10698pub enum AutoModeSwitchResponse {
10699    /// Switch models for this request.
10700    #[serde(rename = "yes")]
10701    Yes,
10702    /// Switch models now and keep using the replacement automatically.
10703    #[serde(rename = "yes_always")]
10704    YesAlways,
10705    /// Do not switch models.
10706    #[serde(rename = "no")]
10707    No,
10708    /// Unknown variant for forward compatibility.
10709    #[default]
10710    #[serde(other)]
10711    Unknown,
10712}
10713
10714/// User action selected for an exhausted session limit.
10715#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10716pub enum SessionLimitsExhaustedResponseAction {
10717    /// Increase the current max by an exact AI Credits amount.
10718    #[serde(rename = "add")]
10719    Add,
10720    /// Set a new absolute max AI Credits value.
10721    #[serde(rename = "set")]
10722    Set,
10723    /// Remove the current session limit.
10724    #[serde(rename = "unset")]
10725    Unset,
10726    /// Leave the limit unchanged and cancel the blocked model request.
10727    #[serde(rename = "cancel")]
10728    Cancel,
10729    /// Unknown variant for forward compatibility.
10730    #[default]
10731    #[serde(other)]
10732    Unknown,
10733}
10734
10735/// Coarse request-difficulty bucket for UX explainability
10736#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10737pub enum AutoModeResolvedReasoningBucket {
10738    /// The request looks low-reasoning; a lighter model is appropriate.
10739    #[serde(rename = "low")]
10740    Low,
10741    /// The request needs a moderate amount of reasoning.
10742    #[serde(rename = "medium")]
10743    Medium,
10744    /// The request looks high-reasoning; a stronger model is appropriate.
10745    #[serde(rename = "high")]
10746    High,
10747    /// Unknown variant for forward compatibility.
10748    #[default]
10749    #[serde(other)]
10750    Unknown,
10751}
10752
10753/// Summary of which managed-settings channels contributed to the effective session policy. Use the per-channel booleans for exact provenance.
10754#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10755pub enum ManagedSettingsResolvedSource {
10756    /// Only the server/account channel contributed.
10757    #[serde(rename = "server")]
10758    Server,
10759    /// Only the device MDM/plist/registry/file channel contributed.
10760    #[serde(rename = "device")]
10761    Device,
10762    /// Only session-local SDK-host injection contributed.
10763    #[serde(rename = "client")]
10764    Client,
10765    /// A policy helper registered by device or server policy contributed. Device registration takes priority when present.
10766    #[serde(rename = "policyHelper")]
10767    PolicyHelper,
10768    /// More than one channel contributed. Ordinary keys resolve device over server over policy helper per key, while permissions compose restrictively across all present layers.
10769    #[serde(rename = "mixed")]
10770    Mixed,
10771    /// No managed policy is in force (no channel contributed).
10772    #[serde(rename = "none")]
10773    None,
10774    /// Unknown variant for forward compatibility.
10775    #[default]
10776    #[serde(other)]
10777    Unknown,
10778}
10779
10780/// The category of runtime action that enterprise managed settings governed (blocked or capped)
10781#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10782pub enum ManagedSettingsEnforcedAction {
10783    /// An attempt to turn on a bypass-permissions ("yolo") escalation was refused or capped because policy disables bypass-permissions mode.
10784    #[serde(rename = "bypass_permissions_blocked")]
10785    BypassPermissionsBlocked,
10786    /// Unknown variant for forward compatibility.
10787    #[default]
10788    #[serde(other)]
10789    Unknown,
10790}
10791
10792/// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused
10793#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10794pub enum ManagedSettingsEnforcedEscalation {
10795    /// Full allow-all permissions — automatically approving tools, paths, and URLs.
10796    #[serde(rename = "allow_all")]
10797    AllowAll,
10798    /// Automatic approval of all tool permission requests.
10799    #[serde(rename = "approve_all")]
10800    ApproveAll,
10801    /// Assisted mode — keeps normal prompt paths and adds an LLM recommendation, distinct from allow-all.
10802    #[serde(rename = "assisted_approval")]
10803    AssistedApproval,
10804    /// Unrestricted filesystem access outside the session's allowed directories.
10805    #[serde(rename = "unrestricted_paths")]
10806    UnrestrictedPaths,
10807    /// Unrestricted URL fetch access.
10808    #[serde(rename = "unrestricted_urls")]
10809    UnrestrictedUrls,
10810    /// A server-wide MCP "Always Allow" (or `--allow-tool <server>`) blanket that would auto-approve every tool from an MCP server. Capped to per-tool approval; each tool still prompts.
10811    #[serde(rename = "server_wide_mcp_approval")]
10812    ServerWideMcpApproval,
10813    /// Unknown variant for forward compatibility.
10814    #[default]
10815    #[serde(other)]
10816    Unknown,
10817}
10818
10819/// Exit plan mode action
10820#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10821pub enum ExitPlanModeAction {
10822    /// Exit plan mode without starting implementation.
10823    #[serde(rename = "exit_only")]
10824    ExitOnly,
10825    /// Exit plan mode and continue in interactive mode.
10826    #[serde(rename = "interactive")]
10827    Interactive,
10828    /// Exit plan mode and continue autonomously.
10829    #[serde(rename = "autopilot")]
10830    Autopilot,
10831    /// Exit plan mode and continue with parallel autonomous workers.
10832    #[serde(rename = "autopilot_fleet")]
10833    AutopilotFleet,
10834    /// Unknown variant for forward compatibility.
10835    #[default]
10836    #[serde(other)]
10837    Unknown,
10838}
10839
10840/// Terminal status a factory run committed. A settled run is never `pending` or `running`, so those two members of the run-status domain are deliberately absent.
10841#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10842pub enum FactoryRunSettledStatus {
10843    /// The factory body resolved and its result was committed.
10844    #[serde(rename = "completed")]
10845    Completed,
10846    /// The run was stopped by a limit, an approval refusal or another policy decision.
10847    #[serde(rename = "halted")]
10848    Halted,
10849    /// The attempt paused intentionally while preserving resumable run state.
10850    #[serde(rename = "paused")]
10851    Paused,
10852    /// The run was cancelled by its caller or by session disposal.
10853    #[serde(rename = "cancelled")]
10854    Cancelled,
10855    /// The run failed, with `failureType` carrying the class when it has one.
10856    #[serde(rename = "error")]
10857    Error,
10858    /// Unknown variant for forward compatibility.
10859    #[default]
10860    #[serde(other)]
10861    Unknown,
10862}
10863
10864/// Source location type (e.g., project, personal-copilot, plugin, builtin, sdk)
10865#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10866pub enum SkillSource {
10867    /// Skill defined in the current project's skill directories.
10868    #[serde(rename = "project")]
10869    Project,
10870    /// Skill discovered from a parent directory in the current workspace tree.
10871    #[serde(rename = "inherited")]
10872    Inherited,
10873    /// Skill defined in the user's Copilot skill directory.
10874    #[serde(rename = "personal-copilot")]
10875    PersonalCopilot,
10876    /// Skill defined in the user's personal agents skill directory.
10877    #[serde(rename = "personal-agents")]
10878    PersonalAgents,
10879    /// Skill provided by an installed plugin.
10880    #[serde(rename = "plugin")]
10881    Plugin,
10882    /// Skill loaded from a configured custom skill directory.
10883    #[serde(rename = "custom")]
10884    Custom,
10885    /// Skill bundled with the runtime.
10886    #[serde(rename = "builtin")]
10887    Builtin,
10888    /// Pathless skill supplied lazily by an SDK skill provider.
10889    #[serde(rename = "sdk")]
10890    Sdk,
10891    /// Unknown variant for forward compatibility.
10892    #[default]
10893    #[serde(other)]
10894    Unknown,
10895}
10896
10897/// Whether configured models are advisory preferences or required constraints
10898#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10899pub enum AgentModelPolicy {
10900    /// Treat the authored models as advisory preferences that callers may override.
10901    #[serde(rename = "preferred")]
10902    Preferred,
10903    /// Require subagent execution to use one of the authored models.
10904    #[serde(rename = "required")]
10905    Required,
10906    /// Unknown variant for forward compatibility.
10907    #[default]
10908    #[serde(other)]
10909    Unknown,
10910}
10911
10912/// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
10913#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10914pub enum McpServerStatus {
10915    /// The server is connected and available.
10916    #[serde(rename = "connected")]
10917    Connected,
10918    /// The server failed to connect or initialize.
10919    #[serde(rename = "failed")]
10920    Failed,
10921    /// The server requires authentication before it can connect.
10922    #[serde(rename = "needs-auth")]
10923    NeedsAuth,
10924    /// The server connection is still being established.
10925    #[serde(rename = "pending")]
10926    Pending,
10927    /// The server is configured but disabled.
10928    #[serde(rename = "disabled")]
10929    Disabled,
10930    /// The server was intentionally stopped and can be restarted on demand when policy permits; a server quarantined by restrictive managed policy stays stopped and cannot be restarted until the policy allows it.
10931    #[serde(rename = "stopped")]
10932    Stopped,
10933    /// The server is not configured for this session.
10934    #[serde(rename = "not_configured")]
10935    NotConfigured,
10936    /// Unknown variant for forward compatibility.
10937    #[default]
10938    #[serde(other)]
10939    Unknown,
10940}
10941
10942/// Discovery source
10943#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10944pub enum ExtensionsLoadedExtensionSource {
10945    /// Extension discovered from the current project.
10946    #[serde(rename = "project")]
10947    Project,
10948    /// Extension discovered from the user's extension directory.
10949    #[serde(rename = "user")]
10950    User,
10951    /// Extension contributed by an installed plugin.
10952    #[serde(rename = "plugin")]
10953    Plugin,
10954    /// Extension discovered from the current session's state directory.
10955    #[serde(rename = "session")]
10956    Session,
10957    /// Unknown variant for forward compatibility.
10958    #[default]
10959    #[serde(other)]
10960    Unknown,
10961}
10962
10963/// Current status: running, disabled, failed, or starting
10964#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10965pub enum ExtensionsLoadedExtensionStatus {
10966    /// The extension process is running.
10967    #[serde(rename = "running")]
10968    Running,
10969    /// The extension is installed but disabled.
10970    #[serde(rename = "disabled")]
10971    Disabled,
10972    /// The extension failed to start or crashed.
10973    #[serde(rename = "failed")]
10974    Failed,
10975    /// The extension process is starting.
10976    #[serde(rename = "starting")]
10977    Starting,
10978    /// Unknown variant for forward compatibility.
10979    #[default]
10980    #[serde(other)]
10981    Unknown,
10982}