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.warning")]
37    SessionWarning,
38    #[serde(rename = "session.model_change")]
39    SessionModelChange,
40    #[serde(rename = "session.mode_changed")]
41    SessionModeChanged,
42    #[serde(rename = "session.session_limits_changed")]
43    SessionSessionLimitsChanged,
44    #[serde(rename = "session.permissions_changed")]
45    SessionPermissionsChanged,
46    #[serde(rename = "session.plan_changed")]
47    SessionPlanChanged,
48    #[serde(rename = "session.todos_changed")]
49    SessionTodosChanged,
50    #[serde(rename = "session.workspace_file_changed")]
51    SessionWorkspaceFileChanged,
52    #[serde(rename = "session.handoff")]
53    SessionHandoff,
54    #[serde(rename = "session.truncation")]
55    SessionTruncation,
56    #[serde(rename = "session.snapshot_rewind")]
57    SessionSnapshotRewind,
58    #[serde(rename = "session.shutdown")]
59    SessionShutdown,
60    #[serde(rename = "session.usage_checkpoint")]
61    SessionUsageCheckpoint,
62    #[serde(rename = "session.context_changed")]
63    SessionContextChanged,
64    #[serde(rename = "session.usage_info")]
65    SessionUsageInfo,
66    #[serde(rename = "session.compaction_start")]
67    SessionCompactionStart,
68    #[serde(rename = "session.compaction_complete")]
69    SessionCompactionComplete,
70    #[serde(rename = "session.task_complete")]
71    SessionTaskComplete,
72    #[serde(rename = "user.message")]
73    UserMessage,
74    #[serde(rename = "pending_messages.modified")]
75    PendingMessagesModified,
76    #[serde(rename = "assistant.turn_start")]
77    AssistantTurnStart,
78    #[serde(rename = "assistant.turn_retry")]
79    AssistantTurnRetry,
80    #[serde(rename = "assistant.intent")]
81    AssistantIntent,
82    #[serde(rename = "assistant.server_tool_progress")]
83    AssistantServerToolProgress,
84    #[serde(rename = "assistant.reasoning")]
85    AssistantReasoning,
86    #[serde(rename = "assistant.reasoning_delta")]
87    AssistantReasoningDelta,
88    #[serde(rename = "assistant.tool_call_delta")]
89    AssistantToolCallDelta,
90    #[serde(rename = "assistant.streaming_delta")]
91    AssistantStreamingDelta,
92    #[serde(rename = "assistant.message")]
93    AssistantMessage,
94    #[serde(rename = "assistant.message_start")]
95    AssistantMessageStart,
96    #[serde(rename = "assistant.message_delta")]
97    AssistantMessageDelta,
98    #[serde(rename = "assistant.turn_end")]
99    AssistantTurnEnd,
100    #[serde(rename = "assistant.idle")]
101    AssistantIdle,
102    #[serde(rename = "assistant.usage")]
103    AssistantUsage,
104    #[serde(rename = "model.call_failure")]
105    ModelCallFailure,
106    #[serde(rename = "model.call_start")]
107    ModelCallStart,
108    #[serde(rename = "abort")]
109    Abort,
110    #[serde(rename = "tool.user_requested")]
111    ToolUserRequested,
112    #[serde(rename = "tool.execution_start")]
113    ToolExecutionStart,
114    #[serde(rename = "tool.execution_partial_result")]
115    ToolExecutionPartialResult,
116    #[serde(rename = "tool.execution_progress")]
117    ToolExecutionProgress,
118    #[serde(rename = "tool.execution_complete")]
119    ToolExecutionComplete,
120    #[serde(rename = "tool_search.activated")]
121    ToolSearchActivated,
122    #[serde(rename = "skill.invoked")]
123    SkillInvoked,
124    #[serde(rename = "subagent.started")]
125    SubagentStarted,
126    #[serde(rename = "subagent.completed")]
127    SubagentCompleted,
128    #[serde(rename = "subagent.failed")]
129    SubagentFailed,
130    #[serde(rename = "subagent.selected")]
131    SubagentSelected,
132    #[serde(rename = "subagent.deselected")]
133    SubagentDeselected,
134    #[serde(rename = "hook.start")]
135    HookStart,
136    #[serde(rename = "hook.end")]
137    HookEnd,
138    #[serde(rename = "hook.progress")]
139    HookProgress,
140    ///
141    /// <div class="warning">
142    ///
143    /// **Experimental.** This type is part of an experimental wire-protocol surface
144    /// and may change or be removed in future SDK or CLI releases.
145    ///
146    /// </div>
147    #[serde(rename = "session.binary_asset")]
148    SessionBinaryAsset,
149    #[serde(rename = "system.message")]
150    SystemMessage,
151    #[serde(rename = "system.notification")]
152    SystemNotification,
153    #[serde(rename = "permission.requested")]
154    PermissionRequested,
155    #[serde(rename = "permission.completed")]
156    PermissionCompleted,
157    #[serde(rename = "user_input.requested")]
158    UserInputRequested,
159    #[serde(rename = "user_input.completed")]
160    UserInputCompleted,
161    #[serde(rename = "elicitation.requested")]
162    ElicitationRequested,
163    #[serde(rename = "elicitation.completed")]
164    ElicitationCompleted,
165    #[serde(rename = "sampling.requested")]
166    SamplingRequested,
167    #[serde(rename = "sampling.completed")]
168    SamplingCompleted,
169    #[serde(rename = "mcp.oauth_required")]
170    McpOauthRequired,
171    #[serde(rename = "mcp.oauth_completed")]
172    McpOauthCompleted,
173    #[serde(rename = "mcp.headers_refresh_required")]
174    McpHeadersRefreshRequired,
175    #[serde(rename = "mcp.headers_refresh_completed")]
176    McpHeadersRefreshCompleted,
177    #[serde(rename = "session.custom_notification")]
178    SessionCustomNotification,
179    #[serde(rename = "external_tool.requested")]
180    ExternalToolRequested,
181    #[serde(rename = "external_tool.completed")]
182    ExternalToolCompleted,
183    #[serde(rename = "command.queued")]
184    CommandQueued,
185    #[serde(rename = "command.execute")]
186    CommandExecute,
187    #[serde(rename = "command.completed")]
188    CommandCompleted,
189    #[serde(rename = "auto_mode_switch.requested")]
190    AutoModeSwitchRequested,
191    #[serde(rename = "auto_mode_switch.completed")]
192    AutoModeSwitchCompleted,
193    #[serde(rename = "session_limits_exhausted.requested")]
194    SessionLimitsExhaustedRequested,
195    #[serde(rename = "session_limits_exhausted.completed")]
196    SessionLimitsExhaustedCompleted,
197    ///
198    /// <div class="warning">
199    ///
200    /// **Experimental.** This type is part of an experimental wire-protocol surface
201    /// and may change or be removed in future SDK or CLI releases.
202    ///
203    /// </div>
204    #[serde(rename = "session.auto_mode_resolved")]
205    SessionAutoModeResolved,
206    ///
207    /// <div class="warning">
208    ///
209    /// **Experimental.** This type is part of an experimental wire-protocol surface
210    /// and may change or be removed in future SDK or CLI releases.
211    ///
212    /// </div>
213    #[serde(rename = "session.managed_settings_resolved")]
214    SessionManagedSettingsResolved,
215    ///
216    /// <div class="warning">
217    ///
218    /// **Experimental.** This type is part of an experimental wire-protocol surface
219    /// and may change or be removed in future SDK or CLI releases.
220    ///
221    /// </div>
222    #[serde(rename = "session.managed_settings_enforced")]
223    SessionManagedSettingsEnforced,
224    #[serde(rename = "commands.changed")]
225    CommandsChanged,
226    #[serde(rename = "capabilities.changed")]
227    CapabilitiesChanged,
228    #[serde(rename = "exit_plan_mode.requested")]
229    ExitPlanModeRequested,
230    #[serde(rename = "exit_plan_mode.completed")]
231    ExitPlanModeCompleted,
232    #[serde(rename = "session.tools_updated")]
233    SessionToolsUpdated,
234    #[serde(rename = "session.background_tasks_changed")]
235    SessionBackgroundTasksChanged,
236    #[serde(rename = "session.skills_loaded")]
237    SessionSkillsLoaded,
238    #[serde(rename = "session.custom_agents_updated")]
239    SessionCustomAgentsUpdated,
240    #[serde(rename = "session.mcp_servers_loaded")]
241    SessionMcpServersLoaded,
242    #[serde(rename = "session.mcp_server_status_changed")]
243    SessionMcpServerStatusChanged,
244    #[serde(rename = "mcp.tools.list_changed")]
245    McpToolsListChanged,
246    #[serde(rename = "mcp.resources.list_changed")]
247    McpResourcesListChanged,
248    #[serde(rename = "mcp.prompts.list_changed")]
249    McpPromptsListChanged,
250    #[serde(rename = "session.extensions_loaded")]
251    SessionExtensionsLoaded,
252    ///
253    /// <div class="warning">
254    ///
255    /// **Experimental.** This type is part of an experimental wire-protocol surface
256    /// and may change or be removed in future SDK or CLI releases.
257    ///
258    /// </div>
259    #[serde(rename = "session.canvas.opened")]
260    SessionCanvasOpened,
261    ///
262    /// <div class="warning">
263    ///
264    /// **Experimental.** This type is part of an experimental wire-protocol surface
265    /// and may change or be removed in future SDK or CLI releases.
266    ///
267    /// </div>
268    #[serde(rename = "session.canvas.registry_changed")]
269    SessionCanvasRegistryChanged,
270    ///
271    /// <div class="warning">
272    ///
273    /// **Experimental.** This type is part of an experimental wire-protocol surface
274    /// and may change or be removed in future SDK or CLI releases.
275    ///
276    /// </div>
277    #[serde(rename = "session.canvas.closed")]
278    SessionCanvasClosed,
279    ///
280    /// <div class="warning">
281    ///
282    /// **Experimental.** This type is part of an experimental wire-protocol surface
283    /// and may change or be removed in future SDK or CLI releases.
284    ///
285    /// </div>
286    #[serde(rename = "session.canvas.unavailable")]
287    SessionCanvasUnavailable,
288    ///
289    /// <div class="warning">
290    ///
291    /// **Experimental.** This type is part of an experimental wire-protocol surface
292    /// and may change or be removed in future SDK or CLI releases.
293    ///
294    /// </div>
295    #[serde(rename = "session.canvas.recorded")]
296    SessionCanvasRecorded,
297    ///
298    /// <div class="warning">
299    ///
300    /// **Experimental.** This type is part of an experimental wire-protocol surface
301    /// and may change or be removed in future SDK or CLI releases.
302    ///
303    /// </div>
304    #[serde(rename = "session.canvas.removed")]
305    SessionCanvasRemoved,
306    #[serde(rename = "session.extensions.attachments_pushed")]
307    SessionExtensionsAttachmentsPushed,
308    #[serde(rename = "mcp_app.tool_call_complete")]
309    McpAppToolCallComplete,
310    /// Unknown event type for forward compatibility.
311    #[default]
312    #[serde(other)]
313    Unknown,
314}
315
316/// Typed session event data, discriminated by the event `type` field.
317///
318/// Use with [`TypedSessionEvent`] for fully typed event handling.
319#[derive(Debug, Clone, Serialize, Deserialize)]
320#[serde(tag = "type", content = "data")]
321pub enum SessionEventData {
322    #[serde(rename = "session.start")]
323    SessionStart(SessionStartData),
324    #[serde(rename = "session.resume")]
325    SessionResume(SessionResumeData),
326    #[serde(rename = "session.remote_steerable_changed")]
327    SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
328    #[serde(rename = "session.error")]
329    SessionError(SessionErrorData),
330    #[serde(rename = "session.idle")]
331    SessionIdle(SessionIdleData),
332    #[serde(rename = "session.title_changed")]
333    SessionTitleChanged(SessionTitleChangedData),
334    #[serde(rename = "session.schedule_created")]
335    SessionScheduleCreated(SessionScheduleCreatedData),
336    #[serde(rename = "session.schedule_cancelled")]
337    SessionScheduleCancelled(SessionScheduleCancelledData),
338    #[serde(rename = "session.schedule_rearmed")]
339    SessionScheduleRearmed(SessionScheduleRearmedData),
340    #[serde(rename = "session.autopilot_objective_changed")]
341    SessionAutopilotObjectiveChanged(SessionAutopilotObjectiveChangedData),
342    #[serde(rename = "session.info")]
343    SessionInfo(SessionInfoData),
344    #[serde(rename = "session.warning")]
345    SessionWarning(SessionWarningData),
346    #[serde(rename = "session.model_change")]
347    SessionModelChange(SessionModelChangeData),
348    #[serde(rename = "session.mode_changed")]
349    SessionModeChanged(SessionModeChangedData),
350    #[serde(rename = "session.session_limits_changed")]
351    SessionSessionLimitsChanged(SessionSessionLimitsChangedData),
352    #[serde(rename = "session.permissions_changed")]
353    SessionPermissionsChanged(SessionPermissionsChangedData),
354    #[serde(rename = "session.plan_changed")]
355    SessionPlanChanged(SessionPlanChangedData),
356    #[serde(rename = "session.todos_changed")]
357    SessionTodosChanged(SessionTodosChangedData),
358    #[serde(rename = "session.workspace_file_changed")]
359    SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
360    #[serde(rename = "session.handoff")]
361    SessionHandoff(SessionHandoffData),
362    #[serde(rename = "session.truncation")]
363    SessionTruncation(SessionTruncationData),
364    #[serde(rename = "session.snapshot_rewind")]
365    SessionSnapshotRewind(SessionSnapshotRewindData),
366    #[serde(rename = "session.shutdown")]
367    SessionShutdown(SessionShutdownData),
368    #[serde(rename = "session.usage_checkpoint")]
369    SessionUsageCheckpoint(SessionUsageCheckpointData),
370    #[serde(rename = "session.context_changed")]
371    SessionContextChanged(SessionContextChangedData),
372    #[serde(rename = "session.usage_info")]
373    SessionUsageInfo(SessionUsageInfoData),
374    #[serde(rename = "session.compaction_start")]
375    SessionCompactionStart(SessionCompactionStartData),
376    #[serde(rename = "session.compaction_complete")]
377    SessionCompactionComplete(SessionCompactionCompleteData),
378    #[serde(rename = "session.task_complete")]
379    SessionTaskComplete(SessionTaskCompleteData),
380    #[serde(rename = "user.message")]
381    UserMessage(UserMessageData),
382    #[serde(rename = "pending_messages.modified")]
383    PendingMessagesModified(PendingMessagesModifiedData),
384    #[serde(rename = "assistant.turn_start")]
385    AssistantTurnStart(AssistantTurnStartData),
386    #[serde(rename = "assistant.turn_retry")]
387    AssistantTurnRetry(AssistantTurnRetryData),
388    #[serde(rename = "assistant.intent")]
389    AssistantIntent(AssistantIntentData),
390    #[serde(rename = "assistant.server_tool_progress")]
391    AssistantServerToolProgress(AssistantServerToolProgressData),
392    #[serde(rename = "assistant.reasoning")]
393    AssistantReasoning(AssistantReasoningData),
394    #[serde(rename = "assistant.reasoning_delta")]
395    AssistantReasoningDelta(AssistantReasoningDeltaData),
396    #[serde(rename = "assistant.tool_call_delta")]
397    AssistantToolCallDelta(AssistantToolCallDeltaData),
398    #[serde(rename = "assistant.streaming_delta")]
399    AssistantStreamingDelta(AssistantStreamingDeltaData),
400    #[serde(rename = "assistant.message")]
401    AssistantMessage(AssistantMessageData),
402    #[serde(rename = "assistant.message_start")]
403    AssistantMessageStart(AssistantMessageStartData),
404    #[serde(rename = "assistant.message_delta")]
405    AssistantMessageDelta(AssistantMessageDeltaData),
406    #[serde(rename = "assistant.turn_end")]
407    AssistantTurnEnd(AssistantTurnEndData),
408    #[serde(rename = "assistant.idle")]
409    AssistantIdle(AssistantIdleData),
410    #[serde(rename = "assistant.usage")]
411    AssistantUsage(AssistantUsageData),
412    #[serde(rename = "model.call_failure")]
413    ModelCallFailure(ModelCallFailureData),
414    #[serde(rename = "model.call_start")]
415    ModelCallStart(ModelCallStartData),
416    #[serde(rename = "abort")]
417    Abort(AbortData),
418    #[serde(rename = "tool.user_requested")]
419    ToolUserRequested(ToolUserRequestedData),
420    #[serde(rename = "tool.execution_start")]
421    ToolExecutionStart(ToolExecutionStartData),
422    #[serde(rename = "tool.execution_partial_result")]
423    ToolExecutionPartialResult(ToolExecutionPartialResultData),
424    #[serde(rename = "tool.execution_progress")]
425    ToolExecutionProgress(ToolExecutionProgressData),
426    #[serde(rename = "tool.execution_complete")]
427    ToolExecutionComplete(ToolExecutionCompleteData),
428    #[serde(rename = "tool_search.activated")]
429    ToolSearchActivated(ToolSearchActivatedData),
430    #[serde(rename = "skill.invoked")]
431    SkillInvoked(SkillInvokedData),
432    #[serde(rename = "subagent.started")]
433    SubagentStarted(SubagentStartedData),
434    #[serde(rename = "subagent.completed")]
435    SubagentCompleted(SubagentCompletedData),
436    #[serde(rename = "subagent.failed")]
437    SubagentFailed(SubagentFailedData),
438    #[serde(rename = "subagent.selected")]
439    SubagentSelected(SubagentSelectedData),
440    #[serde(rename = "subagent.deselected")]
441    SubagentDeselected(SubagentDeselectedData),
442    #[serde(rename = "hook.start")]
443    HookStart(HookStartData),
444    #[serde(rename = "hook.end")]
445    HookEnd(HookEndData),
446    #[serde(rename = "hook.progress")]
447    HookProgress(HookProgressData),
448    #[serde(rename = "session.binary_asset")]
449    SessionBinaryAsset(SessionBinaryAssetData),
450    #[serde(rename = "system.message")]
451    SystemMessage(SystemMessageData),
452    #[serde(rename = "system.notification")]
453    SystemNotification(SystemNotificationData),
454    #[serde(rename = "permission.requested")]
455    PermissionRequested(PermissionRequestedData),
456    #[serde(rename = "permission.completed")]
457    PermissionCompleted(PermissionCompletedData),
458    #[serde(rename = "user_input.requested")]
459    UserInputRequested(UserInputRequestedData),
460    #[serde(rename = "user_input.completed")]
461    UserInputCompleted(UserInputCompletedData),
462    #[serde(rename = "elicitation.requested")]
463    ElicitationRequested(ElicitationRequestedData),
464    #[serde(rename = "elicitation.completed")]
465    ElicitationCompleted(ElicitationCompletedData),
466    #[serde(rename = "sampling.requested")]
467    SamplingRequested(SamplingRequestedData),
468    #[serde(rename = "sampling.completed")]
469    SamplingCompleted(SamplingCompletedData),
470    #[serde(rename = "mcp.oauth_required")]
471    McpOauthRequired(McpOauthRequiredData),
472    #[serde(rename = "mcp.oauth_completed")]
473    McpOauthCompleted(McpOauthCompletedData),
474    #[serde(rename = "mcp.headers_refresh_required")]
475    McpHeadersRefreshRequired(McpHeadersRefreshRequiredData),
476    #[serde(rename = "mcp.headers_refresh_completed")]
477    McpHeadersRefreshCompleted(McpHeadersRefreshCompletedData),
478    #[serde(rename = "session.custom_notification")]
479    SessionCustomNotification(SessionCustomNotificationData),
480    #[serde(rename = "external_tool.requested")]
481    ExternalToolRequested(ExternalToolRequestedData),
482    #[serde(rename = "external_tool.completed")]
483    ExternalToolCompleted(ExternalToolCompletedData),
484    #[serde(rename = "command.queued")]
485    CommandQueued(CommandQueuedData),
486    #[serde(rename = "command.execute")]
487    CommandExecute(CommandExecuteData),
488    #[serde(rename = "command.completed")]
489    CommandCompleted(CommandCompletedData),
490    #[serde(rename = "auto_mode_switch.requested")]
491    AutoModeSwitchRequested(AutoModeSwitchRequestedData),
492    #[serde(rename = "auto_mode_switch.completed")]
493    AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
494    #[serde(rename = "session_limits_exhausted.requested")]
495    SessionLimitsExhaustedRequested(SessionLimitsExhaustedRequestedData),
496    #[serde(rename = "session_limits_exhausted.completed")]
497    SessionLimitsExhaustedCompleted(SessionLimitsExhaustedCompletedData),
498    ///
499    /// <div class="warning">
500    ///
501    /// **Experimental.** This type is part of an experimental wire-protocol surface
502    /// and may change or be removed in future SDK or CLI releases.
503    ///
504    /// </div>
505    #[serde(rename = "session.auto_mode_resolved")]
506    SessionAutoModeResolved(SessionAutoModeResolvedData),
507    ///
508    /// <div class="warning">
509    ///
510    /// **Experimental.** This type is part of an experimental wire-protocol surface
511    /// and may change or be removed in future SDK or CLI releases.
512    ///
513    /// </div>
514    #[serde(rename = "session.managed_settings_resolved")]
515    SessionManagedSettingsResolved(SessionManagedSettingsResolvedData),
516    ///
517    /// <div class="warning">
518    ///
519    /// **Experimental.** This type is part of an experimental wire-protocol surface
520    /// and may change or be removed in future SDK or CLI releases.
521    ///
522    /// </div>
523    #[serde(rename = "session.managed_settings_enforced")]
524    SessionManagedSettingsEnforced(SessionManagedSettingsEnforcedData),
525    #[serde(rename = "commands.changed")]
526    CommandsChanged(CommandsChangedData),
527    #[serde(rename = "capabilities.changed")]
528    CapabilitiesChanged(CapabilitiesChangedData),
529    #[serde(rename = "exit_plan_mode.requested")]
530    ExitPlanModeRequested(ExitPlanModeRequestedData),
531    #[serde(rename = "exit_plan_mode.completed")]
532    ExitPlanModeCompleted(ExitPlanModeCompletedData),
533    #[serde(rename = "session.tools_updated")]
534    SessionToolsUpdated(SessionToolsUpdatedData),
535    #[serde(rename = "session.background_tasks_changed")]
536    SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
537    #[serde(rename = "session.skills_loaded")]
538    SessionSkillsLoaded(SessionSkillsLoadedData),
539    #[serde(rename = "session.custom_agents_updated")]
540    SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
541    #[serde(rename = "session.mcp_servers_loaded")]
542    SessionMcpServersLoaded(SessionMcpServersLoadedData),
543    #[serde(rename = "session.mcp_server_status_changed")]
544    SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
545    #[serde(rename = "mcp.tools.list_changed")]
546    McpToolsListChanged(McpToolsListChangedData),
547    #[serde(rename = "mcp.resources.list_changed")]
548    McpResourcesListChanged(McpResourcesListChangedData),
549    #[serde(rename = "mcp.prompts.list_changed")]
550    McpPromptsListChanged(McpPromptsListChangedData),
551    #[serde(rename = "session.extensions_loaded")]
552    SessionExtensionsLoaded(SessionExtensionsLoadedData),
553    ///
554    /// <div class="warning">
555    ///
556    /// **Experimental.** This type is part of an experimental wire-protocol surface
557    /// and may change or be removed in future SDK or CLI releases.
558    ///
559    /// </div>
560    #[serde(rename = "session.canvas.opened")]
561    SessionCanvasOpened(SessionCanvasOpenedData),
562    ///
563    /// <div class="warning">
564    ///
565    /// **Experimental.** This type is part of an experimental wire-protocol surface
566    /// and may change or be removed in future SDK or CLI releases.
567    ///
568    /// </div>
569    #[serde(rename = "session.canvas.registry_changed")]
570    SessionCanvasRegistryChanged(SessionCanvasRegistryChangedData),
571    ///
572    /// <div class="warning">
573    ///
574    /// **Experimental.** This type is part of an experimental wire-protocol surface
575    /// and may change or be removed in future SDK or CLI releases.
576    ///
577    /// </div>
578    #[serde(rename = "session.canvas.closed")]
579    SessionCanvasClosed(SessionCanvasClosedData),
580    ///
581    /// <div class="warning">
582    ///
583    /// **Experimental.** This type is part of an experimental wire-protocol surface
584    /// and may change or be removed in future SDK or CLI releases.
585    ///
586    /// </div>
587    #[serde(rename = "session.canvas.unavailable")]
588    SessionCanvasUnavailable(SessionCanvasUnavailableData),
589    ///
590    /// <div class="warning">
591    ///
592    /// **Experimental.** This type is part of an experimental wire-protocol surface
593    /// and may change or be removed in future SDK or CLI releases.
594    ///
595    /// </div>
596    #[serde(rename = "session.canvas.recorded")]
597    SessionCanvasRecorded(SessionCanvasRecordedData),
598    ///
599    /// <div class="warning">
600    ///
601    /// **Experimental.** This type is part of an experimental wire-protocol surface
602    /// and may change or be removed in future SDK or CLI releases.
603    ///
604    /// </div>
605    #[serde(rename = "session.canvas.removed")]
606    SessionCanvasRemoved(SessionCanvasRemovedData),
607    #[serde(rename = "session.extensions.attachments_pushed")]
608    SessionExtensionsAttachmentsPushed(SessionExtensionsAttachmentsPushedData),
609    #[serde(rename = "mcp_app.tool_call_complete")]
610    McpAppToolCallComplete(McpAppToolCallCompleteData),
611}
612
613/// A session event with typed data payload.
614///
615/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
616/// are available directly. The event-specific data is in the `payload`
617/// field as a [`SessionEventData`] enum.
618#[derive(Debug, Clone, Serialize, Deserialize)]
619#[serde(rename_all = "camelCase")]
620pub struct TypedSessionEvent {
621    /// Unique event identifier (UUID v4).
622    pub id: String,
623    /// ISO 8601 timestamp when the event was created.
624    pub timestamp: String,
625    /// ID of the preceding event in the chain.
626    #[serde(skip_serializing_if = "Option::is_none")]
627    pub parent_id: Option<String>,
628    /// When true, the event is transient and not persisted.
629    #[serde(skip_serializing_if = "Option::is_none")]
630    pub ephemeral: Option<bool>,
631    /// Sub-agent instance identifier. Absent for events from the root /
632    /// main agent and session-level events.
633    #[serde(skip_serializing_if = "Option::is_none")]
634    pub agent_id: Option<String>,
635    /// The typed event payload (discriminated by event type).
636    #[serde(flatten)]
637    pub payload: SessionEventData,
638}
639
640/// Working directory and git context at session start
641#[derive(Debug, Clone, Default, Serialize, Deserialize)]
642#[serde(rename_all = "camelCase")]
643pub struct WorkingDirectoryContext {
644    /// Base commit of current git branch at session start time
645    #[serde(skip_serializing_if = "Option::is_none")]
646    pub base_commit: Option<String>,
647    /// Current git branch name
648    #[serde(skip_serializing_if = "Option::is_none")]
649    pub branch: Option<String>,
650    /// Current working directory path
651    pub cwd: String,
652    /// Root directory of the git repository, resolved via git rev-parse
653    #[serde(skip_serializing_if = "Option::is_none")]
654    pub git_root: Option<String>,
655    /// Head commit of current git branch at session start time
656    #[serde(skip_serializing_if = "Option::is_none")]
657    pub head_commit: Option<String>,
658    /// Hosting platform type of the repository (github or ado)
659    #[serde(skip_serializing_if = "Option::is_none")]
660    pub host_type: Option<WorkingDirectoryContextHostType>,
661    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
662    #[serde(skip_serializing_if = "Option::is_none")]
663    pub repository: Option<String>,
664    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
665    #[serde(skip_serializing_if = "Option::is_none")]
666    pub repository_host: Option<String>,
667}
668
669/// Optional session limits.
670#[derive(Debug, Clone, Default, Serialize, Deserialize)]
671#[serde(rename_all = "camelCase")]
672pub struct SessionLimitsConfig {
673    /// Maximum AI Credits allowed across the session's current accounting window.
674    #[serde(skip_serializing_if = "Option::is_none")]
675    pub max_ai_credits: Option<f64>,
676}
677
678/// Session event "session.start". Session initialization metadata including context and configuration
679#[derive(Debug, Clone, Default, Serialize, Deserialize)]
680#[serde(rename_all = "camelCase")]
681pub struct SessionStartData {
682    /// Whether the session was already in use by another client at start time
683    #[serde(skip_serializing_if = "Option::is_none")]
684    pub already_in_use: Option<bool>,
685    /// Working directory and git context at session start
686    #[serde(skip_serializing_if = "Option::is_none")]
687    pub context: Option<WorkingDirectoryContext>,
688    /// Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
689    #[serde(skip_serializing_if = "Option::is_none")]
690    pub context_tier: Option<ContextTier>,
691    /// Version string of the Copilot application
692    pub copilot_version: String,
693    /// 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.
694    #[serde(skip_serializing_if = "Option::is_none")]
695    pub detached_from_spawning_parent_session_id: Option<String>,
696    /// Identifier of the software producing the events (e.g., "copilot-agent")
697    pub producer: String,
698    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
699    #[serde(skip_serializing_if = "Option::is_none")]
700    pub reasoning_effort: Option<String>,
701    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
702    #[serde(skip_serializing_if = "Option::is_none")]
703    pub reasoning_summary: Option<ReasoningSummary>,
704    /// Whether this session supports remote steering via GitHub
705    #[serde(skip_serializing_if = "Option::is_none")]
706    pub remote_steerable: Option<bool>,
707    /// Model selected at session creation time, if any
708    #[serde(skip_serializing_if = "Option::is_none")]
709    pub selected_model: Option<String>,
710    /// Unique identifier for the session
711    pub session_id: SessionId,
712    /// Session limits configured at session creation time, if any
713    #[serde(skip_serializing_if = "Option::is_none")]
714    pub session_limits: Option<SessionLimitsConfig>,
715    /// ISO 8601 timestamp when the session was created
716    pub start_time: String,
717    /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
718    #[serde(skip_serializing_if = "Option::is_none")]
719    pub verbosity: Option<Verbosity>,
720    /// Schema version number for the session event format
721    pub version: i64,
722}
723
724/// Session event "session.resume". Session resume metadata including current context and event count
725#[derive(Debug, Clone, Default, Serialize, Deserialize)]
726#[serde(rename_all = "camelCase")]
727pub struct SessionResumeData {
728    /// Whether the session was already in use by another client at resume time
729    #[serde(skip_serializing_if = "Option::is_none")]
730    pub already_in_use: Option<bool>,
731    /// Updated working directory and git context at resume time
732    #[serde(skip_serializing_if = "Option::is_none")]
733    pub context: Option<WorkingDirectoryContext>,
734    /// Context tier currently selected at resume time; null when no tier is active
735    #[serde(skip_serializing_if = "Option::is_none")]
736    pub context_tier: Option<ContextTier>,
737    /// 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 (the default), any such tool calls and permission requests are immediately marked as interrupted on resume.
738    #[serde(skip_serializing_if = "Option::is_none")]
739    pub continue_pending_work: Option<bool>,
740    /// Total number of persisted events in the session at the time of resume
741    pub event_count: i64,
742    /// 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
743    #[serde(skip_serializing_if = "Option::is_none")]
744    pub events_file_size_bytes: Option<i64>,
745    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
746    #[serde(skip_serializing_if = "Option::is_none")]
747    pub reasoning_effort: Option<String>,
748    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
749    #[serde(skip_serializing_if = "Option::is_none")]
750    pub reasoning_summary: Option<ReasoningSummary>,
751    /// Whether this session supports remote steering via GitHub
752    #[serde(skip_serializing_if = "Option::is_none")]
753    pub remote_steerable: Option<bool>,
754    /// ISO 8601 timestamp when the session was resumed
755    pub resume_time: String,
756    /// Model currently selected at resume time
757    #[serde(skip_serializing_if = "Option::is_none")]
758    pub selected_model: Option<String>,
759    /// Session limits currently configured at resume time; null when no limits are active
760    #[serde(skip_serializing_if = "Option::is_none")]
761    pub session_limits: Option<SessionLimitsConfig>,
762    /// True when this resume attached to a session that the runtime already had running in-memory (for example, an extension joining a session another client was actively driving). False (or omitted) for cold resumes — the runtime had to reconstitute the session from its persisted event log.
763    #[serde(skip_serializing_if = "Option::is_none")]
764    pub session_was_active: Option<bool>,
765    /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
766    #[serde(skip_serializing_if = "Option::is_none")]
767    pub verbosity: Option<Verbosity>,
768}
769
770/// Session event "session.remote_steerable_changed". Notifies that the session's remote steering capability has changed
771#[derive(Debug, Clone, Default, Serialize, Deserialize)]
772#[serde(rename_all = "camelCase")]
773pub struct SessionRemoteSteerableChangedData {
774    /// Whether this session now supports remote steering via GitHub
775    pub remote_steerable: bool,
776}
777
778/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
779#[derive(Debug, Clone, Default, Serialize, Deserialize)]
780#[serde(rename_all = "camelCase")]
781pub struct SessionErrorData {
782    /// 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.
783    #[serde(skip_serializing_if = "Option::is_none")]
784    pub eligible_for_auto_switch: Option<bool>,
785    /// 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"`).
786    #[serde(skip_serializing_if = "Option::is_none")]
787    pub error_code: Option<String>,
788    /// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
789    pub error_type: String,
790    /// Human-readable error message
791    pub message: String,
792    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
793    #[serde(skip_serializing_if = "Option::is_none")]
794    pub provider_call_id: Option<String>,
795    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
796    #[serde(skip_serializing_if = "Option::is_none")]
797    pub service_request_id: Option<String>,
798    /// Error stack trace, when available
799    #[serde(skip_serializing_if = "Option::is_none")]
800    pub stack: Option<String>,
801    /// HTTP status code from the upstream request, if applicable
802    #[serde(skip_serializing_if = "Option::is_none")]
803    pub status_code: Option<i32>,
804    /// Optional URL associated with this error that the user can open in a browser
805    #[serde(skip_serializing_if = "Option::is_none")]
806    pub url: Option<String>,
807}
808
809/// Session event "session.idle". Payload indicating the session is idle with no background agents or attached shell commands in flight
810#[derive(Debug, Clone, Default, Serialize, Deserialize)]
811#[serde(rename_all = "camelCase")]
812pub struct SessionIdleData {
813    /// True when the preceding agentic loop was cancelled via abort signal
814    #[serde(skip_serializing_if = "Option::is_none")]
815    pub aborted: Option<bool>,
816}
817
818/// Session event "session.title_changed". Session title change payload containing the new display title
819#[derive(Debug, Clone, Default, Serialize, Deserialize)]
820#[serde(rename_all = "camelCase")]
821pub struct SessionTitleChangedData {
822    /// The new display title for the session
823    pub title: String,
824}
825
826/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
827#[derive(Debug, Clone, Default, Serialize, Deserialize)]
828#[serde(rename_all = "camelCase")]
829pub struct SessionScheduleCreatedData {
830    /// Absolute fire time (epoch milliseconds) for a one-shot calendar schedule
831    #[serde(skip_serializing_if = "Option::is_none")]
832    pub at: Option<i64>,
833    /// 5-field cron expression for a recurring calendar schedule, evaluated in `tz`
834    #[serde(skip_serializing_if = "Option::is_none")]
835    pub cron: Option<String>,
836    /// 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)
837    #[serde(skip_serializing_if = "Option::is_none")]
838    pub display_prompt: Option<String>,
839    /// Sequential id assigned to the scheduled prompt within the session
840    pub id: i64,
841    /// Interval between ticks in milliseconds (relative-interval schedules)
842    #[serde(skip_serializing_if = "Option::is_none")]
843    pub interval_ms: Option<i64>,
844    /// Prompt text that gets enqueued on every tick
845    pub prompt: String,
846    /// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
847    #[serde(skip_serializing_if = "Option::is_none")]
848    pub recurring: Option<bool>,
849    /// 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.
850    #[serde(skip_serializing_if = "Option::is_none")]
851    pub self_paced: Option<bool>,
852    /// IANA timezone the `cron` expression is evaluated in
853    #[serde(skip_serializing_if = "Option::is_none")]
854    pub tz: Option<String>,
855}
856
857/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
858#[derive(Debug, Clone, Default, Serialize, Deserialize)]
859#[serde(rename_all = "camelCase")]
860pub struct SessionScheduleCancelledData {
861    /// Id of the scheduled prompt that was cancelled
862    pub id: i64,
863}
864
865/// Session event "session.schedule_rearmed". Self-paced schedule re-armed for its next run
866#[derive(Debug, Clone, Default, Serialize, Deserialize)]
867#[serde(rename_all = "camelCase")]
868pub struct SessionScheduleRearmedData {
869    /// Id of the self-paced schedule that was re-armed
870    pub id: i64,
871    /// Absolute time (epoch milliseconds) the model armed the next run to fire
872    pub next_run_at: i64,
873}
874
875/// Session event "session.autopilot_objective_changed". Autopilot objective state file operation details indicating what changed
876#[derive(Debug, Clone, Default, Serialize, Deserialize)]
877#[serde(rename_all = "camelCase")]
878pub struct SessionAutopilotObjectiveChangedData {
879    /// Current autopilot objective id, if one exists
880    #[serde(skip_serializing_if = "Option::is_none")]
881    pub id: Option<i64>,
882    /// The type of operation performed on the autopilot objective state file
883    pub operation: AutopilotObjectiveChangedOperation,
884    /// Current autopilot objective status, if one exists
885    #[serde(skip_serializing_if = "Option::is_none")]
886    pub status: Option<AutopilotObjectiveChangedStatus>,
887}
888
889/// Session event "session.info". Informational message for timeline display with categorization
890#[derive(Debug, Clone, Default, Serialize, Deserialize)]
891#[serde(rename_all = "camelCase")]
892pub struct SessionInfoData {
893    /// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
894    pub info_type: String,
895    /// Human-readable informational message for display in the timeline
896    pub message: String,
897    /// Optional actionable tip displayed with this message
898    #[serde(skip_serializing_if = "Option::is_none")]
899    pub tip: Option<String>,
900    /// Optional URL associated with this message that the user can open in a browser
901    #[serde(skip_serializing_if = "Option::is_none")]
902    pub url: Option<String>,
903}
904
905/// Session event "session.warning". Warning message for timeline display with categorization
906#[derive(Debug, Clone, Default, Serialize, Deserialize)]
907#[serde(rename_all = "camelCase")]
908pub struct SessionWarningData {
909    /// Human-readable warning message for display in the timeline
910    pub message: String,
911    /// Optional URL associated with this warning that the user can open in a browser
912    #[serde(skip_serializing_if = "Option::is_none")]
913    pub url: Option<String>,
914    /// Category of warning (e.g., "subscription", "policy", "mcp")
915    pub warning_type: String,
916}
917
918/// Session event "session.model_change". Model change details including previous and new model identifiers
919#[derive(Debug, Clone, Default, Serialize, Deserialize)]
920#[serde(rename_all = "camelCase")]
921pub struct SessionModelChangeData {
922    /// Reason the change happened, when not user-initiated. Currently `"rate_limit_auto_switch"` for changes triggered by the auto-mode-switch rate-limit recovery path. UI clients can use this to render contextual copy.
923    #[serde(skip_serializing_if = "Option::is_none")]
924    pub cause: Option<String>,
925    /// Context tier after the model change; null explicitly clears a previously selected tier
926    #[serde(skip_serializing_if = "Option::is_none")]
927    pub context_tier: Option<ContextTier>,
928    /// Newly selected model identifier
929    pub new_model: String,
930    /// Model that was previously selected, if any
931    #[serde(skip_serializing_if = "Option::is_none")]
932    pub previous_model: Option<String>,
933    /// Reasoning effort level before the model change, if applicable
934    #[serde(skip_serializing_if = "Option::is_none")]
935    pub previous_reasoning_effort: Option<String>,
936    /// Reasoning summary mode before the model change, if applicable
937    #[serde(skip_serializing_if = "Option::is_none")]
938    pub previous_reasoning_summary: Option<ReasoningSummary>,
939    /// Output verbosity level before the model change, if applicable
940    #[serde(skip_serializing_if = "Option::is_none")]
941    pub previous_verbosity: Option<Verbosity>,
942    /// Reasoning effort level after the model change, if applicable
943    #[serde(skip_serializing_if = "Option::is_none")]
944    pub reasoning_effort: Option<String>,
945    /// Reasoning summary mode after the model change, if applicable
946    #[serde(skip_serializing_if = "Option::is_none")]
947    pub reasoning_summary: Option<ReasoningSummary>,
948    /// Output verbosity level after the model change, if applicable
949    #[serde(skip_serializing_if = "Option::is_none")]
950    pub verbosity: Option<Verbosity>,
951}
952
953/// Session event "session.mode_changed". Agent mode change details including previous and new modes
954#[derive(Debug, Clone, Default, Serialize, Deserialize)]
955#[serde(rename_all = "camelCase")]
956pub struct SessionModeChangedData {
957    /// The session mode the agent is operating in
958    pub new_mode: SessionMode,
959    /// The session mode the agent is operating in
960    pub previous_mode: SessionMode,
961}
962
963/// Session event "session.session_limits_changed". Session limits update details. Null clears the limits.
964#[derive(Debug, Clone, Default, Serialize, Deserialize)]
965#[serde(rename_all = "camelCase")]
966pub struct SessionSessionLimitsChangedData {
967    /// Current session limits, or null when no limits are active
968    pub session_limits: Option<SessionLimitsConfig>,
969}
970
971/// Session event "session.permissions_changed". Permissions change details carrying the aggregate allow-all transition.
972#[derive(Debug, Clone, Default, Serialize, Deserialize)]
973#[serde(rename_all = "camelCase")]
974pub struct SessionPermissionsChangedData {
975    /// Allow-all mode after the change
976    ///
977    /// <div class="warning">
978    ///
979    /// **Experimental.** This type is part of an experimental wire-protocol surface
980    /// and may change or be removed in future SDK or CLI releases.
981    ///
982    /// </div>
983    #[serde(skip_serializing_if = "Option::is_none")]
984    pub allow_all_permission_mode: Option<PermissionAllowAllMode>,
985    /// Aggregate allow-all flag after the change
986    pub allow_all_permissions: bool,
987    /// Allow-all mode before the change
988    ///
989    /// <div class="warning">
990    ///
991    /// **Experimental.** This type is part of an experimental wire-protocol surface
992    /// and may change or be removed in future SDK or CLI releases.
993    ///
994    /// </div>
995    #[serde(skip_serializing_if = "Option::is_none")]
996    pub previous_allow_all_permission_mode: Option<PermissionAllowAllMode>,
997    /// Aggregate allow-all flag before the change
998    pub previous_allow_all_permissions: bool,
999}
1000
1001/// Session event "session.plan_changed". Plan file operation details indicating what changed
1002#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1003#[serde(rename_all = "camelCase")]
1004pub struct SessionPlanChangedData {
1005    /// The type of operation performed on the plan file
1006    pub operation: PlanChangedOperation,
1007}
1008
1009/// 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.
1010#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1011#[serde(rename_all = "camelCase")]
1012pub struct SessionTodosChangedData {}
1013
1014/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
1015#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1016#[serde(rename_all = "camelCase")]
1017pub struct SessionWorkspaceFileChangedData {
1018    /// Whether the file was newly created or updated
1019    pub operation: WorkspaceFileChangedOperation,
1020    /// Relative path within the session workspace files directory
1021    pub path: String,
1022}
1023
1024/// Repository context for the handed-off session
1025#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1026#[serde(rename_all = "camelCase")]
1027pub struct HandoffRepository {
1028    /// Git branch name, if applicable
1029    #[serde(skip_serializing_if = "Option::is_none")]
1030    pub branch: Option<String>,
1031    /// Repository name
1032    pub name: String,
1033    /// Repository owner (user or organization)
1034    pub owner: String,
1035}
1036
1037/// Session event "session.handoff". Session handoff metadata including source, context, and repository information
1038#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1039#[serde(rename_all = "camelCase")]
1040pub struct SessionHandoffData {
1041    /// Additional context information for the handoff
1042    #[serde(skip_serializing_if = "Option::is_none")]
1043    pub context: Option<String>,
1044    /// ISO 8601 timestamp when the handoff occurred
1045    pub handoff_time: String,
1046    /// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
1047    #[serde(skip_serializing_if = "Option::is_none")]
1048    pub host: Option<String>,
1049    /// Session ID of the remote session being handed off
1050    #[serde(skip_serializing_if = "Option::is_none")]
1051    pub remote_session_id: Option<SessionId>,
1052    /// Repository context for the handed-off session
1053    #[serde(skip_serializing_if = "Option::is_none")]
1054    pub repository: Option<HandoffRepository>,
1055    /// Origin type of the session being handed off
1056    pub source_type: HandoffSourceType,
1057    /// Summary of the work done in the source session
1058    #[serde(skip_serializing_if = "Option::is_none")]
1059    pub summary: Option<String>,
1060}
1061
1062/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
1063#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1064#[serde(rename_all = "camelCase")]
1065pub struct SessionTruncationData {
1066    /// Number of messages removed by truncation
1067    pub messages_removed_during_truncation: i64,
1068    /// Identifier of the component that performed truncation (e.g., "BasicTruncator")
1069    pub performed_by: String,
1070    /// Number of conversation messages after truncation
1071    pub post_truncation_messages_length: i64,
1072    /// Total tokens in conversation messages after truncation
1073    pub post_truncation_tokens_in_messages: i64,
1074    /// Number of conversation messages before truncation
1075    pub pre_truncation_messages_length: i64,
1076    /// Total tokens in conversation messages before truncation
1077    pub pre_truncation_tokens_in_messages: i64,
1078    /// Maximum token count for the model's context window
1079    pub token_limit: i64,
1080    /// Number of tokens removed by truncation
1081    pub tokens_removed_during_truncation: i64,
1082}
1083
1084/// Session event "session.snapshot_rewind". Session rewind details including target event and count of removed events
1085#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1086#[serde(rename_all = "camelCase")]
1087pub struct SessionSnapshotRewindData {
1088    /// Number of events that were removed by the rewind
1089    pub events_removed: i64,
1090    /// Event ID that was rewound to; this event and all after it were removed
1091    pub up_to_event_id: String,
1092}
1093
1094/// Aggregate code change metrics for the session
1095#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1096#[serde(rename_all = "camelCase")]
1097pub struct ShutdownCodeChanges {
1098    /// List of file paths that were modified during the session
1099    pub files_modified: Vec<String>,
1100    /// Total number of lines added during the session
1101    pub lines_added: i64,
1102    /// Total number of lines removed during the session
1103    pub lines_removed: i64,
1104}
1105
1106/// Request count and cost metrics
1107#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1108#[serde(rename_all = "camelCase")]
1109pub struct ShutdownModelMetricRequests {
1110    /// Cumulative cost multiplier for requests to this model
1111    ///
1112    /// <div class="warning">
1113    ///
1114    /// **Experimental.** This type is part of an experimental wire-protocol surface
1115    /// and may change or be removed in future SDK or CLI releases.
1116    ///
1117    /// </div>
1118    #[serde(skip_serializing_if = "Option::is_none")]
1119    pub cost: Option<f64>,
1120    /// Total number of API requests made to this model
1121    ///
1122    /// <div class="warning">
1123    ///
1124    /// **Experimental.** This type is part of an experimental wire-protocol surface
1125    /// and may change or be removed in future SDK or CLI releases.
1126    ///
1127    /// </div>
1128    #[serde(skip_serializing_if = "Option::is_none")]
1129    pub count: Option<i64>,
1130}
1131
1132/// A token-type entry in a shutdown model metric, storing the accumulated token count.
1133#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1134#[serde(rename_all = "camelCase")]
1135pub struct ShutdownModelMetricTokenDetail {
1136    /// Accumulated token count for this token type
1137    pub token_count: i64,
1138}
1139
1140/// Token usage breakdown
1141#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1142#[serde(rename_all = "camelCase")]
1143pub struct ShutdownModelMetricUsage {
1144    /// Total tokens read from prompt cache across all requests
1145    pub cache_read_tokens: i64,
1146    /// Total tokens written to prompt cache across all requests
1147    pub cache_write_tokens: i64,
1148    /// Total input tokens consumed across all requests to this model
1149    pub input_tokens: i64,
1150    /// Total output tokens produced across all requests to this model
1151    pub output_tokens: i64,
1152    /// Total reasoning tokens produced across all requests to this model
1153    #[serde(skip_serializing_if = "Option::is_none")]
1154    pub reasoning_tokens: Option<i64>,
1155}
1156
1157/// Per-model shutdown metrics with request counts, token usage, nano-AI units, and token details.
1158#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1159#[serde(rename_all = "camelCase")]
1160pub struct ShutdownModelMetric {
1161    /// Request count and cost metrics
1162    pub requests: ShutdownModelMetricRequests,
1163    /// Token count details per type
1164    #[serde(skip_serializing_if = "Option::is_none")]
1165    pub token_details: Option<HashMap<String, ShutdownModelMetricTokenDetail>>,
1166    /// Accumulated nano-AI units cost for this model
1167    ///
1168    /// <div class="warning">
1169    ///
1170    /// **Experimental.** This type is part of an experimental wire-protocol surface
1171    /// and may change or be removed in future SDK or CLI releases.
1172    ///
1173    /// </div>
1174    #[serde(skip_serializing_if = "Option::is_none")]
1175    pub total_nano_aiu: Option<f64>,
1176    /// Token usage breakdown
1177    pub usage: ShutdownModelMetricUsage,
1178}
1179
1180/// A session-wide shutdown token-type entry storing the accumulated token count.
1181#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1182#[serde(rename_all = "camelCase")]
1183pub struct ShutdownTokenDetail {
1184    /// Accumulated token count for this token type
1185    pub token_count: i64,
1186}
1187
1188/// Session event "session.shutdown". Session termination metrics including usage statistics, code changes, and shutdown reason
1189#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1190#[serde(rename_all = "camelCase")]
1191pub struct SessionShutdownData {
1192    /// Aggregate code change metrics for the session
1193    pub code_changes: ShutdownCodeChanges,
1194    /// Non-system message token count at shutdown
1195    #[serde(skip_serializing_if = "Option::is_none")]
1196    pub conversation_tokens: Option<i64>,
1197    /// Model that was selected at the time of shutdown
1198    #[serde(skip_serializing_if = "Option::is_none")]
1199    pub current_model: Option<String>,
1200    /// Total tokens in context window at shutdown
1201    #[serde(skip_serializing_if = "Option::is_none")]
1202    pub current_tokens: Option<i64>,
1203    /// Error description when shutdownType is "error"
1204    #[serde(skip_serializing_if = "Option::is_none")]
1205    pub error_reason: Option<String>,
1206    /// 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
1207    #[serde(skip_serializing_if = "Option::is_none")]
1208    pub events_file_size_bytes: Option<i64>,
1209    /// Per-model usage breakdown, keyed by model identifier
1210    pub model_metrics: HashMap<String, ShutdownModelMetric>,
1211    /// Unix timestamp (milliseconds) when the session started
1212    pub session_start_time: i64,
1213    /// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
1214    pub shutdown_type: ShutdownType,
1215    /// System message token count at shutdown
1216    #[serde(skip_serializing_if = "Option::is_none")]
1217    pub system_tokens: Option<i64>,
1218    /// Session-wide per-token-type accumulated token counts
1219    #[serde(skip_serializing_if = "Option::is_none")]
1220    pub token_details: Option<HashMap<String, ShutdownTokenDetail>>,
1221    /// Tool definitions token count at shutdown
1222    #[serde(skip_serializing_if = "Option::is_none")]
1223    pub tool_definitions_tokens: Option<i64>,
1224    /// Cumulative time spent in API calls during the session, in milliseconds
1225    pub total_api_duration_ms: i64,
1226    /// Session-wide accumulated nano-AI units cost
1227    ///
1228    /// <div class="warning">
1229    ///
1230    /// **Experimental.** This type is part of an experimental wire-protocol surface
1231    /// and may change or be removed in future SDK or CLI releases.
1232    ///
1233    /// </div>
1234    #[serde(skip_serializing_if = "Option::is_none")]
1235    pub total_nano_aiu: Option<f64>,
1236    /// Total number of premium API requests used during the session
1237    #[doc(hidden)]
1238    #[serde(skip_serializing_if = "Option::is_none")]
1239    pub(crate) total_premium_requests: Option<f64>,
1240}
1241
1242/// Internal prompt-cache expiration state for one model
1243#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1244#[serde(rename_all = "camelCase")]
1245pub(crate) struct UsageCheckpointModelCacheState {
1246    /// Latest known prompt-cache expiration
1247    pub cache_expires_at: String,
1248    /// Retained cache lifetime in seconds, used to refresh expiration after a cache read
1249    #[doc(hidden)]
1250    pub(crate) cache_ttl_seconds: i64,
1251    /// Model identifier associated with this cache state
1252    pub model_id: String,
1253}
1254
1255/// Session event "session.usage_checkpoint". Durable session usage checkpoint for reconstructing aggregate accounting on resume
1256#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1257#[serde(rename_all = "camelCase")]
1258pub struct SessionUsageCheckpointData {
1259    /// Internal per-model prompt-cache state used to restore expiration tracking on resume
1260    #[doc(hidden)]
1261    #[serde(skip_serializing_if = "Option::is_none")]
1262    pub(crate) model_cache_state: Option<Vec<UsageCheckpointModelCacheState>>,
1263    /// Session-wide accumulated nano-AI units cost at checkpoint time
1264    pub total_nano_aiu: f64,
1265    /// Total number of premium API requests used at checkpoint time
1266    #[doc(hidden)]
1267    #[serde(skip_serializing_if = "Option::is_none")]
1268    pub(crate) total_premium_requests: Option<f64>,
1269}
1270
1271/// Session event "session.context_changed". Updated working directory and git context after the change
1272#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1273#[serde(rename_all = "camelCase")]
1274pub struct SessionContextChangedData {
1275    /// Base commit of current git branch at session start time
1276    #[serde(skip_serializing_if = "Option::is_none")]
1277    pub base_commit: Option<String>,
1278    /// Current git branch name
1279    #[serde(skip_serializing_if = "Option::is_none")]
1280    pub branch: Option<String>,
1281    /// Current working directory path
1282    pub cwd: String,
1283    /// Root directory of the git repository, resolved via git rev-parse
1284    #[serde(skip_serializing_if = "Option::is_none")]
1285    pub git_root: Option<String>,
1286    /// Head commit of current git branch at session start time
1287    #[serde(skip_serializing_if = "Option::is_none")]
1288    pub head_commit: Option<String>,
1289    /// Hosting platform type of the repository (github or ado)
1290    #[serde(skip_serializing_if = "Option::is_none")]
1291    pub host_type: Option<WorkingDirectoryContextHostType>,
1292    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
1293    #[serde(skip_serializing_if = "Option::is_none")]
1294    pub repository: Option<String>,
1295    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
1296    #[serde(skip_serializing_if = "Option::is_none")]
1297    pub repository_host: Option<String>,
1298}
1299
1300/// Session event "session.usage_info". Current context window usage statistics including token and message counts
1301#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1302#[serde(rename_all = "camelCase")]
1303pub struct SessionUsageInfoData {
1304    /// Token count from non-system messages (user, assistant, tool)
1305    #[serde(skip_serializing_if = "Option::is_none")]
1306    pub conversation_tokens: Option<i64>,
1307    /// Current number of tokens in the context window
1308    pub current_tokens: i64,
1309    /// Whether this is the first usage_info event emitted in this session
1310    #[serde(skip_serializing_if = "Option::is_none")]
1311    pub is_initial: Option<bool>,
1312    /// Current number of messages in the conversation
1313    pub messages_length: i64,
1314    /// Token count from system message(s)
1315    #[serde(skip_serializing_if = "Option::is_none")]
1316    pub system_tokens: Option<i64>,
1317    /// Maximum token count for the model's context window
1318    pub token_limit: i64,
1319    /// Token count from tool definitions
1320    #[serde(skip_serializing_if = "Option::is_none")]
1321    pub tool_definitions_tokens: Option<i64>,
1322}
1323
1324/// Session event "session.compaction_start". Context window breakdown at the start of LLM-powered conversation compaction
1325#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1326#[serde(rename_all = "camelCase")]
1327pub struct SessionCompactionStartData {
1328    /// Token count from non-system messages (user, assistant, tool) at compaction start
1329    #[serde(skip_serializing_if = "Option::is_none")]
1330    pub conversation_tokens: Option<i64>,
1331    /// Model identifier used for compaction, when known
1332    #[serde(skip_serializing_if = "Option::is_none")]
1333    pub model: Option<String>,
1334    /// Token count from system message(s) at compaction start
1335    #[serde(skip_serializing_if = "Option::is_none")]
1336    pub system_tokens: Option<i64>,
1337    /// Token count from tool definitions at compaction start
1338    #[serde(skip_serializing_if = "Option::is_none")]
1339    pub tool_definitions_tokens: Option<i64>,
1340}
1341
1342/// Token usage detail for a single billing category
1343#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1344#[serde(rename_all = "camelCase")]
1345pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
1346    /// Number of tokens in this billing batch
1347    pub batch_size: i64,
1348    /// Cost per batch of tokens
1349    pub cost_per_batch: i64,
1350    /// Total token count for this entry
1351    pub token_count: i64,
1352    /// Token category (e.g., "input", "output")
1353    pub token_type: String,
1354}
1355
1356/// Per-request cost and usage data from the CAPI copilot_usage response field
1357#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1358#[serde(rename_all = "camelCase")]
1359pub(crate) struct CompactionCompleteCompactionTokensUsedCopilotUsage {
1360    /// Itemized token usage breakdown
1361    #[doc(hidden)]
1362    #[serde(skip_serializing_if = "Option::is_none")]
1363    pub(crate) token_details:
1364        Option<Vec<CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail>>,
1365    /// Total cost in nano-AI units for this request
1366    pub total_nano_aiu: f64,
1367}
1368
1369/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
1370#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1371#[serde(rename_all = "camelCase")]
1372pub struct CompactionCompleteCompactionTokensUsed {
1373    /// Cached input tokens reused in the compaction LLM call
1374    #[serde(skip_serializing_if = "Option::is_none")]
1375    pub cache_read_tokens: Option<i64>,
1376    /// Tokens written to prompt cache in the compaction LLM call
1377    #[serde(skip_serializing_if = "Option::is_none")]
1378    pub cache_write_tokens: Option<i64>,
1379    /// Per-request cost and usage data from the CAPI copilot_usage response field
1380    #[doc(hidden)]
1381    #[serde(skip_serializing_if = "Option::is_none")]
1382    pub(crate) copilot_usage: Option<CompactionCompleteCompactionTokensUsedCopilotUsage>,
1383    /// Duration of the compaction LLM call in milliseconds
1384    #[serde(skip_serializing_if = "Option::is_none")]
1385    pub duration: Option<i64>,
1386    /// Input tokens consumed by the compaction LLM call
1387    #[serde(skip_serializing_if = "Option::is_none")]
1388    pub input_tokens: Option<i64>,
1389    /// Model identifier used for the compaction LLM call
1390    #[serde(skip_serializing_if = "Option::is_none")]
1391    pub model: Option<String>,
1392    /// Output tokens produced by the compaction LLM call
1393    #[serde(skip_serializing_if = "Option::is_none")]
1394    pub output_tokens: Option<i64>,
1395}
1396
1397/// Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
1398#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1399#[serde(rename_all = "camelCase")]
1400pub struct SessionCompactionCompleteData {
1401    /// Checkpoint snapshot number created for recovery
1402    #[serde(skip_serializing_if = "Option::is_none")]
1403    pub checkpoint_number: Option<i64>,
1404    /// File path where the checkpoint was stored
1405    #[serde(skip_serializing_if = "Option::is_none")]
1406    pub checkpoint_path: Option<String>,
1407    /// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
1408    #[serde(skip_serializing_if = "Option::is_none")]
1409    pub compaction_tokens_used: Option<CompactionCompleteCompactionTokensUsed>,
1410    /// Token count from non-system messages (user, assistant, tool) after compaction
1411    #[serde(skip_serializing_if = "Option::is_none")]
1412    pub conversation_tokens: Option<i64>,
1413    /// User-supplied focus instructions provided to a manual `/compact` invocation. Omitted for automatic compaction and for manual compaction with no focus text.
1414    #[serde(skip_serializing_if = "Option::is_none")]
1415    pub custom_instructions: Option<String>,
1416    /// Error message if compaction failed
1417    #[serde(skip_serializing_if = "Option::is_none")]
1418    pub error: Option<String>,
1419    /// Number of messages removed during compaction
1420    #[serde(skip_serializing_if = "Option::is_none")]
1421    pub messages_removed: Option<i64>,
1422    /// Total tokens in conversation after compaction
1423    #[serde(skip_serializing_if = "Option::is_none")]
1424    pub post_compaction_tokens: Option<i64>,
1425    /// Number of messages before compaction
1426    #[serde(skip_serializing_if = "Option::is_none")]
1427    pub pre_compaction_messages_length: Option<i64>,
1428    /// Total tokens in conversation before compaction
1429    #[serde(skip_serializing_if = "Option::is_none")]
1430    pub pre_compaction_tokens: Option<i64>,
1431    /// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
1432    #[serde(skip_serializing_if = "Option::is_none")]
1433    pub request_id: Option<RequestId>,
1434    /// Copilot service request ID (x-copilot-service-request-id header) for the compaction LLM call
1435    #[serde(skip_serializing_if = "Option::is_none")]
1436    pub service_request_id: Option<String>,
1437    /// 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).
1438    #[serde(skip_serializing_if = "Option::is_none")]
1439    pub status_code: Option<i64>,
1440    /// Whether compaction completed successfully
1441    pub success: bool,
1442    /// LLM-generated summary of the compacted conversation history
1443    #[serde(skip_serializing_if = "Option::is_none")]
1444    pub summary_content: Option<String>,
1445    /// Token count from system message(s) after compaction
1446    #[serde(skip_serializing_if = "Option::is_none")]
1447    pub system_tokens: Option<i64>,
1448    /// Number of tokens removed during compaction
1449    #[serde(skip_serializing_if = "Option::is_none")]
1450    pub tokens_removed: Option<i64>,
1451    /// Token count from tool definitions after compaction
1452    #[serde(skip_serializing_if = "Option::is_none")]
1453    pub tool_definitions_tokens: Option<i64>,
1454}
1455
1456/// Session event "session.task_complete". Task completion notification with summary from the agent
1457#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1458#[serde(rename_all = "camelCase")]
1459pub struct SessionTaskCompleteData {
1460    /// Whether the tool call succeeded. False when validation failed (e.g., invalid arguments)
1461    #[serde(skip_serializing_if = "Option::is_none")]
1462    pub success: Option<bool>,
1463    /// Summary of the completed task, provided by the agent
1464    #[serde(skip_serializing_if = "Option::is_none")]
1465    pub summary: Option<String>,
1466}
1467
1468/// Session event "user.message". Payload of `user.message` with displayed and model-transformed content, attachments, source/delivery metadata, mode, and telemetry IDs.
1469#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1470#[serde(rename_all = "camelCase")]
1471pub struct UserMessageData {
1472    /// The agent mode that was active when this message was sent
1473    #[serde(skip_serializing_if = "Option::is_none")]
1474    pub agent_mode: Option<UserMessageAgentMode>,
1475    /// Files, selections, or GitHub references attached to the message
1476    #[serde(skip_serializing_if = "Option::is_none")]
1477    pub attachments: Option<Vec<serde_json::Value>>,
1478    /// The user's message text as displayed in the timeline
1479    pub content: String,
1480    /// 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.
1481    #[serde(skip_serializing_if = "Option::is_none")]
1482    pub delivery: Option<UserMessageDelivery>,
1483    /// CAPI interaction ID for correlating this user message with its turn
1484    #[serde(skip_serializing_if = "Option::is_none")]
1485    pub interaction_id: Option<String>,
1486    /// 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.
1487    #[serde(skip_serializing_if = "Option::is_none")]
1488    pub is_autopilot_continuation: Option<bool>,
1489    /// 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
1490    #[serde(skip_serializing_if = "Option::is_none")]
1491    pub native_document_path_fallback_paths: Option<Vec<String>>,
1492    /// Parent agent task ID for background telemetry correlated to this user turn
1493    #[serde(skip_serializing_if = "Option::is_none")]
1494    pub parent_agent_task_id: Option<String>,
1495    /// Origin of this message, used for timeline filtering (e.g., "skill-pdf" for skill-injected messages that should be hidden from the user)
1496    #[serde(skip_serializing_if = "Option::is_none")]
1497    pub source: Option<String>,
1498    /// Normalized document MIME types that were sent natively instead of through tagged_files XML
1499    #[serde(skip_serializing_if = "Option::is_none")]
1500    pub supported_native_document_mime_types: Option<Vec<String>>,
1501    /// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching
1502    #[serde(skip_serializing_if = "Option::is_none")]
1503    pub transformed_content: Option<String>,
1504}
1505
1506/// Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
1507#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1508#[serde(rename_all = "camelCase")]
1509pub struct PendingMessagesModifiedData {}
1510
1511/// Session event "assistant.turn_start". Turn initialization metadata including identifier and interaction tracking
1512#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1513#[serde(rename_all = "camelCase")]
1514pub struct AssistantTurnStartData {
1515    /// CAPI interaction ID for correlating this turn with upstream telemetry
1516    #[serde(skip_serializing_if = "Option::is_none")]
1517    pub interaction_id: Option<String>,
1518    /// Model identifier used for this turn, when known
1519    #[serde(skip_serializing_if = "Option::is_none")]
1520    pub model: Option<String>,
1521    /// Identifier for this turn within the agentic loop, typically a stringified turn number
1522    pub turn_id: String,
1523}
1524
1525/// Session event "assistant.turn_retry". Metadata for an additional model inference attempt within an existing assistant turn
1526#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1527#[serde(rename_all = "camelCase")]
1528pub struct AssistantTurnRetryData {
1529    /// Model identifier used for this retry, when known
1530    #[serde(skip_serializing_if = "Option::is_none")]
1531    pub model: Option<String>,
1532    /// Provider or runtime classification that caused the retry, when known
1533    #[serde(skip_serializing_if = "Option::is_none")]
1534    pub reason: Option<String>,
1535    /// Identifier of the turn whose model inference is being retried
1536    pub turn_id: String,
1537}
1538
1539/// Session event "assistant.intent". Agent intent description for current activity or plan
1540#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1541#[serde(rename_all = "camelCase")]
1542pub struct AssistantIntentData {
1543    /// Short description of what the agent is currently doing or planning to do
1544    pub intent: String,
1545}
1546
1547/// 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
1548#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1549#[serde(rename_all = "camelCase")]
1550pub struct AssistantServerToolProgressData {
1551    /// Kind of hosted server tool that is running. Only `web_search` is emitted today.
1552    pub kind: String,
1553    /// 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.
1554    pub output_index: i64,
1555    /// Lifecycle status of the hosted call: `in_progress`, `searching`, or `completed`.
1556    pub status: String,
1557}
1558
1559/// Session event "assistant.reasoning". Assistant reasoning content for timeline display with complete thinking text
1560#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1561#[serde(rename_all = "camelCase")]
1562pub struct AssistantReasoningData {
1563    /// The complete extended thinking text from the model
1564    pub content: String,
1565    /// Unique identifier for this reasoning block
1566    pub reasoning_id: String,
1567}
1568
1569/// Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
1570#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1571#[serde(rename_all = "camelCase")]
1572pub struct AssistantReasoningDeltaData {
1573    /// Incremental text chunk to append to the reasoning content
1574    pub delta_content: String,
1575    /// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event
1576    pub reasoning_id: String,
1577}
1578
1579/// Session event "assistant.tool_call_delta". Streaming tool-call input delta for incremental tool-call updates
1580#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1581#[serde(rename_all = "camelCase")]
1582pub struct AssistantToolCallDeltaData {
1583    /// 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.
1584    pub input_delta: String,
1585    /// Tool call ID this delta belongs to, matching the corresponding assistant.message tool request
1586    pub tool_call_id: String,
1587    /// Name of the tool being invoked, when known from the stream
1588    #[serde(skip_serializing_if = "Option::is_none")]
1589    pub tool_name: Option<String>,
1590    /// Tool call type, when known from the stream
1591    #[serde(skip_serializing_if = "Option::is_none")]
1592    pub tool_type: Option<AssistantMessageToolRequestType>,
1593}
1594
1595/// Session event "assistant.streaming_delta". Streaming response progress with cumulative byte count
1596#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1597#[serde(rename_all = "camelCase")]
1598pub struct AssistantStreamingDeltaData {
1599    /// Cumulative total bytes received from the streaming response so far
1600    pub total_response_size_bytes: i64,
1601}
1602
1603/// A source that backs one or more cited spans in the assistant's response.
1604///
1605/// <div class="warning">
1606///
1607/// **Experimental.** This type is part of an experimental wire-protocol surface
1608/// and may change or be removed in future SDK or CLI releases.
1609///
1610/// </div>
1611#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1612#[serde(rename_all = "camelCase")]
1613pub struct CitationSource {
1614    /// Stable, turn-scoped identifier for this source, referenced by CitationReference.sourceId.
1615    pub id: String,
1616    /// File path relative to the agent's workspace root, when the source is a file.
1617    #[serde(skip_serializing_if = "Option::is_none")]
1618    pub path: Option<String>,
1619    /// The system that produced this citation.
1620    pub provider: CitationProvider,
1621    /// Human-readable title of the source.
1622    #[serde(skip_serializing_if = "Option::is_none")]
1623    pub title: Option<String>,
1624    /// URL of the source, when it is a web resource.
1625    #[serde(skip_serializing_if = "Option::is_none")]
1626    pub url: Option<String>,
1627}
1628
1629/// A single citation occurrence linking a span of generated text to a supporting source.
1630///
1631/// <div class="warning">
1632///
1633/// **Experimental.** This type is part of an experimental wire-protocol surface
1634/// and may change or be removed in future SDK or CLI releases.
1635///
1636/// </div>
1637#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1638#[serde(rename_all = "camelCase")]
1639pub struct CitationReference {
1640    /// The exact text from the source that supports the cited span, when provided by the model.
1641    #[serde(skip_serializing_if = "Option::is_none")]
1642    pub cited_text: Option<String>,
1643    /// Location within the source that supports the cited span, when the provider reports one.
1644    #[serde(skip_serializing_if = "Option::is_none")]
1645    pub location: Option<serde_json::Value>,
1646    /// Provider-native citation correlation data (e.g. Anthropic search_result_index / document_index), passed through opaquely for debugging and forward compatibility.
1647    #[serde(skip_serializing_if = "Option::is_none")]
1648    pub provider_metadata: Option<serde_json::Value>,
1649    /// Identifier of the CitationSource this reference points to (CitationSource.id).
1650    pub source_id: String,
1651}
1652
1653/// A contiguous span of generated assistant text and the source references that support it.
1654///
1655/// <div class="warning">
1656///
1657/// **Experimental.** This type is part of an experimental wire-protocol surface
1658/// and may change or be removed in future SDK or CLI releases.
1659///
1660/// </div>
1661#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1662#[serde(rename_all = "camelCase")]
1663pub struct CitationSpan {
1664    /// End offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, exclusive).
1665    pub end_index: i64,
1666    /// The sources that support this span of generated text.
1667    pub references: Vec<CitationReference>,
1668    /// Start offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, inclusive).
1669    pub start_index: i64,
1670}
1671
1672/// Provider-agnostic citations linking spans of the assistant's response to their supporting sources.
1673///
1674/// <div class="warning">
1675///
1676/// **Experimental.** This type is part of an experimental wire-protocol surface
1677/// and may change or be removed in future SDK or CLI releases.
1678///
1679/// </div>
1680#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1681#[serde(rename_all = "camelCase")]
1682pub struct Citations {
1683    /// Deduplicated set of sources referenced by the citation spans.
1684    pub sources: Vec<CitationSource>,
1685    /// Spans of generated text annotated with the sources that support them.
1686    pub spans: Vec<CitationSpan>,
1687}
1688
1689/// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
1690///
1691/// <div class="warning">
1692///
1693/// **Experimental.** This type is part of an experimental wire-protocol surface
1694/// and may change or be removed in future SDK or CLI releases.
1695///
1696/// </div>
1697#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1698#[serde(rename_all = "camelCase")]
1699pub struct AssistantMessageServerTools {
1700    #[serde(skip_serializing_if = "Option::is_none")]
1701    pub advisor_model: Option<String>,
1702    #[serde(skip_serializing_if = "Option::is_none")]
1703    pub function_call_namespaces: Option<HashMap<String, String>>,
1704    #[serde(skip_serializing_if = "Option::is_none")]
1705    pub items: Option<Vec<serde_json::Value>>,
1706    pub provider: String,
1707    #[serde(skip_serializing_if = "Option::is_none")]
1708    pub raw_content_blocks: Option<Vec<serde_json::Value>>,
1709}
1710
1711/// A tool invocation request from the assistant
1712#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1713#[serde(rename_all = "camelCase")]
1714pub struct AssistantMessageToolRequest {
1715    /// Arguments to pass to the tool, format depends on the tool
1716    #[serde(skip_serializing_if = "Option::is_none")]
1717    pub arguments: Option<serde_json::Value>,
1718    /// Resolved intention summary describing what this specific call does
1719    #[serde(skip_serializing_if = "Option::is_none")]
1720    pub intention_summary: Option<String>,
1721    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
1722    #[serde(skip_serializing_if = "Option::is_none")]
1723    pub mcp_server_name: Option<String>,
1724    /// Original tool name on the MCP server, when the tool is an MCP tool
1725    #[serde(skip_serializing_if = "Option::is_none")]
1726    pub mcp_tool_name: Option<String>,
1727    /// Name of the tool being invoked
1728    pub name: String,
1729    /// Unique identifier for this tool call
1730    pub tool_call_id: String,
1731    /// Human-readable display title for the tool
1732    #[serde(skip_serializing_if = "Option::is_none")]
1733    pub tool_title: Option<String>,
1734    /// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
1735    #[serde(skip_serializing_if = "Option::is_none")]
1736    pub r#type: Option<AssistantMessageToolRequestType>,
1737}
1738
1739/// Session event "assistant.message". Assistant response containing text content, optional tool requests, and interaction metadata
1740#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1741#[serde(rename_all = "camelCase")]
1742pub struct AssistantMessageData {
1743    /// Provider's completion / response identifier; shared across all chunks of a single API call. Used to group multi-chunk assistant utterances.
1744    #[serde(skip_serializing_if = "Option::is_none")]
1745    pub api_call_id: Option<String>,
1746    /// Provider-agnostic citations linking spans of this message's content to the sources that support them. Experimental; only populated when citation emission is enabled.
1747    ///
1748    /// <div class="warning">
1749    ///
1750    /// **Experimental.** This type is part of an experimental wire-protocol surface
1751    /// and may change or be removed in future SDK or CLI releases.
1752    ///
1753    /// </div>
1754    #[serde(skip_serializing_if = "Option::is_none")]
1755    pub citations: Option<Citations>,
1756    /// 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).
1757    #[serde(skip_serializing_if = "Option::is_none")]
1758    pub client_request_id: Option<String>,
1759    /// The assistant's text response content
1760    pub content: String,
1761    /// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
1762    #[serde(skip_serializing_if = "Option::is_none")]
1763    pub encrypted_content: Option<String>,
1764    /// CAPI interaction ID for correlating this message with upstream telemetry
1765    #[serde(skip_serializing_if = "Option::is_none")]
1766    pub interaction_id: Option<String>,
1767    /// Unique identifier for this assistant message
1768    pub message_id: String,
1769    /// Model that produced this assistant message, if known
1770    #[serde(skip_serializing_if = "Option::is_none")]
1771    pub model: Option<String>,
1772    /// Actual output token count from the API response (completion_tokens), used for accurate token accounting
1773    #[serde(skip_serializing_if = "Option::is_none")]
1774    pub output_tokens: Option<i64>,
1775    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
1776    #[doc(hidden)]
1777    #[deprecated]
1778    #[serde(skip_serializing_if = "Option::is_none")]
1779    pub parent_tool_call_id: Option<String>,
1780    /// Generation phase for phased-output models (e.g., thinking vs. response phases)
1781    #[serde(skip_serializing_if = "Option::is_none")]
1782    pub phase: Option<String>,
1783    /// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
1784    #[serde(skip_serializing_if = "Option::is_none")]
1785    pub reasoning_opaque: Option<String>,
1786    /// Readable reasoning text from the model's extended thinking
1787    #[serde(skip_serializing_if = "Option::is_none")]
1788    pub reasoning_text: Option<String>,
1789    /// 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.
1790    #[serde(skip_serializing_if = "Option::is_none")]
1791    pub reasoning_wire_field: Option<String>,
1792    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
1793    #[serde(skip_serializing_if = "Option::is_none")]
1794    pub request_id: Option<RequestId>,
1795    /// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
1796    #[serde(skip_serializing_if = "Option::is_none")]
1797    pub server_tools: Option<AssistantMessageServerTools>,
1798    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
1799    #[serde(skip_serializing_if = "Option::is_none")]
1800    pub service_request_id: Option<String>,
1801    /// Tool invocations requested by the assistant in this message
1802    #[serde(skip_serializing_if = "Option::is_none")]
1803    pub tool_requests: Option<Vec<AssistantMessageToolRequest>>,
1804    /// Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
1805    #[serde(skip_serializing_if = "Option::is_none")]
1806    pub turn_id: Option<String>,
1807}
1808
1809/// Session event "assistant.message_start". Streaming assistant message start metadata
1810#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1811#[serde(rename_all = "camelCase")]
1812pub struct AssistantMessageStartData {
1813    /// Message ID this start event belongs to, matching subsequent deltas and assistant.message
1814    pub message_id: String,
1815    /// Generation phase this message belongs to for phased-output models
1816    #[serde(skip_serializing_if = "Option::is_none")]
1817    pub phase: Option<String>,
1818}
1819
1820/// Session event "assistant.message_delta". Streaming assistant message delta for incremental response updates
1821#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1822#[serde(rename_all = "camelCase")]
1823pub struct AssistantMessageDeltaData {
1824    /// Incremental text chunk to append to the message content
1825    pub delta_content: String,
1826    /// Message ID this delta belongs to, matching the corresponding assistant.message event
1827    pub message_id: String,
1828    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
1829    #[doc(hidden)]
1830    #[deprecated]
1831    #[serde(skip_serializing_if = "Option::is_none")]
1832    pub parent_tool_call_id: Option<String>,
1833}
1834
1835/// Session event "assistant.turn_end". Turn completion metadata including the turn identifier
1836#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1837#[serde(rename_all = "camelCase")]
1838pub struct AssistantTurnEndData {
1839    /// Model identifier used for this turn, when known
1840    #[serde(skip_serializing_if = "Option::is_none")]
1841    pub model: Option<String>,
1842    /// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event
1843    pub turn_id: String,
1844}
1845
1846/// 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
1847#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1848#[serde(rename_all = "camelCase")]
1849pub struct AssistantIdleData {
1850    /// True when the preceding agentic loop was cancelled via abort signal
1851    #[serde(skip_serializing_if = "Option::is_none")]
1852    pub aborted: Option<bool>,
1853}
1854
1855/// Token usage detail for a single billing category
1856#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1857#[serde(rename_all = "camelCase")]
1858pub struct AssistantUsageCopilotUsageTokenDetail {
1859    /// Number of tokens in this billing batch
1860    pub batch_size: i64,
1861    /// Cost per batch of tokens
1862    pub cost_per_batch: i64,
1863    /// Total token count for this entry
1864    pub token_count: i64,
1865    /// Token category (e.g., "input", "output")
1866    pub token_type: String,
1867}
1868
1869/// Per-request cost and usage data from the CAPI copilot_usage response field
1870#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1871#[serde(rename_all = "camelCase")]
1872pub struct AssistantUsageCopilotUsage {
1873    /// Itemized token usage breakdown
1874    #[doc(hidden)]
1875    #[serde(skip_serializing_if = "Option::is_none")]
1876    pub(crate) token_details: Option<Vec<AssistantUsageCopilotUsageTokenDetail>>,
1877    /// Total cost in nano-AI units for this request
1878    pub total_nano_aiu: f64,
1879}
1880
1881/// Internal per-quota snapshot for assistant usage, including entitlement, consumed requests, overage, reset date, and remaining quota.
1882#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1883#[serde(rename_all = "camelCase")]
1884pub(crate) struct AssistantUsageQuotaSnapshot {
1885    /// Total requests allowed by the entitlement
1886    #[doc(hidden)]
1887    pub(crate) entitlement_requests: i64,
1888    /// Whether the user currently has quota available for use
1889    #[doc(hidden)]
1890    #[serde(skip_serializing_if = "Option::is_none")]
1891    pub(crate) has_quota: Option<bool>,
1892    /// Whether the user has an unlimited usage entitlement
1893    #[doc(hidden)]
1894    pub(crate) is_unlimited_entitlement: bool,
1895    /// Number of additional usage requests made this period
1896    #[doc(hidden)]
1897    pub(crate) overage: f64,
1898    /// Whether additional usage is allowed when quota is exhausted
1899    #[doc(hidden)]
1900    pub(crate) overage_allowed_with_exhausted_quota: bool,
1901    /// Pay-as-you-go additional-usage budget cap in AI credits (1 credit = $0.01); present only when CAPI emits a finite value
1902    #[doc(hidden)]
1903    #[serde(skip_serializing_if = "Option::is_none")]
1904    pub(crate) overage_entitlement: Option<f64>,
1905    /// Percentage of quota remaining (0 to 100)
1906    #[doc(hidden)]
1907    pub(crate) remaining_percentage: f64,
1908    /// Date when the quota resets
1909    #[doc(hidden)]
1910    #[serde(skip_serializing_if = "Option::is_none")]
1911    pub(crate) reset_date: Option<String>,
1912    /// Whether this snapshot uses token-based billing (AI-credits allocation)
1913    #[doc(hidden)]
1914    #[serde(skip_serializing_if = "Option::is_none")]
1915    pub(crate) token_based_billing: Option<bool>,
1916    /// Whether usage is still permitted after quota exhaustion
1917    #[doc(hidden)]
1918    pub(crate) usage_allowed_with_exhausted_quota: bool,
1919    /// Number of requests already consumed
1920    #[doc(hidden)]
1921    pub(crate) used_requests: i64,
1922}
1923
1924/// Session event "assistant.usage". LLM API call usage metrics including tokens, costs, quotas, and billing information
1925#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1926#[serde(rename_all = "camelCase")]
1927pub struct AssistantUsageData {
1928    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
1929    #[serde(skip_serializing_if = "Option::is_none")]
1930    pub api_call_id: Option<String>,
1931    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
1932    #[serde(skip_serializing_if = "Option::is_none")]
1933    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
1934    /// Updated prompt-cache expiration for this model call. Present only when the call establishes or refreshes known cache state.
1935    #[serde(skip_serializing_if = "Option::is_none")]
1936    pub cache_expires_at: Option<String>,
1937    /// Number of tokens read from prompt cache
1938    #[serde(skip_serializing_if = "Option::is_none")]
1939    pub cache_read_tokens: Option<i64>,
1940    /// Number of tokens written to prompt cache
1941    #[serde(skip_serializing_if = "Option::is_none")]
1942    pub cache_write_tokens: Option<i64>,
1943    /// 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.
1944    #[serde(skip_serializing_if = "Option::is_none")]
1945    pub content_filter_triggered: Option<bool>,
1946    /// Per-request cost and usage data from the CAPI copilot_usage response field
1947    #[serde(skip_serializing_if = "Option::is_none")]
1948    pub copilot_usage: Option<AssistantUsageCopilotUsage>,
1949    /// Model multiplier cost for billing purposes
1950    ///
1951    /// <div class="warning">
1952    ///
1953    /// **Experimental.** This type is part of an experimental wire-protocol surface
1954    /// and may change or be removed in future SDK or CLI releases.
1955    ///
1956    /// </div>
1957    #[serde(skip_serializing_if = "Option::is_none")]
1958    pub cost: Option<f64>,
1959    /// Duration of the API call in milliseconds
1960    #[serde(skip_serializing_if = "Option::is_none")]
1961    pub duration: Option<i64>,
1962    /// 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".
1963    #[serde(skip_serializing_if = "Option::is_none")]
1964    pub finish_reason: Option<String>,
1965    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
1966    #[serde(skip_serializing_if = "Option::is_none")]
1967    pub initiator: Option<String>,
1968    /// Number of input tokens consumed
1969    #[serde(skip_serializing_if = "Option::is_none")]
1970    pub input_tokens: Option<i64>,
1971    /// Average inter-token latency in milliseconds. Only available for streaming requests
1972    #[serde(skip_serializing_if = "Option::is_none")]
1973    pub inter_token_latency_ms: Option<f64>,
1974    /// Model identifier used for this API call
1975    pub model: String,
1976    /// Number of output tokens produced
1977    #[serde(skip_serializing_if = "Option::is_none")]
1978    pub output_tokens: Option<i64>,
1979    /// Parent tool call ID when this usage originates from a sub-agent
1980    #[doc(hidden)]
1981    #[deprecated]
1982    #[serde(skip_serializing_if = "Option::is_none")]
1983    pub parent_tool_call_id: Option<String>,
1984    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
1985    #[serde(skip_serializing_if = "Option::is_none")]
1986    pub provider_call_id: Option<String>,
1987    /// Per-quota resource usage snapshots, keyed by quota identifier
1988    #[doc(hidden)]
1989    #[serde(skip_serializing_if = "Option::is_none")]
1990    pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
1991    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
1992    #[serde(skip_serializing_if = "Option::is_none")]
1993    pub reasoning_effort: Option<String>,
1994    /// Number of output tokens used for reasoning (e.g., chain-of-thought)
1995    #[serde(skip_serializing_if = "Option::is_none")]
1996    pub reasoning_tokens: Option<i64>,
1997    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
1998    #[serde(skip_serializing_if = "Option::is_none")]
1999    pub service_request_id: Option<String>,
2000    /// Time to first token in milliseconds. Only available for streaming requests
2001    #[serde(skip_serializing_if = "Option::is_none")]
2002    pub time_to_first_token_ms: Option<f64>,
2003}
2004
2005/// Content-free structural summary of the failing request for diagnosing malformed 4xx calls
2006#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2007#[serde(rename_all = "camelCase")]
2008pub struct ModelCallFailureRequestFingerprint {
2009    /// Total number of image content parts
2010    pub image_part_count: i64,
2011    /// Image parts whose media type cannot be determined (rejected by strict providers)
2012    pub image_parts_missing_media_type: i64,
2013    /// Role of the final message in the request
2014    #[serde(skip_serializing_if = "Option::is_none")]
2015    pub last_message_role: Option<String>,
2016    /// Total number of messages in the request
2017    pub message_count: i64,
2018    /// Tool calls whose name is missing or empty (rejected by strict providers)
2019    pub nameless_tool_call_count: i64,
2020    /// Total number of tool calls across assistant messages
2021    pub tool_call_count: i64,
2022    /// Number of "tool" result messages in the request
2023    pub tool_result_message_count: i64,
2024}
2025
2026/// Session event "model.call_failure". Failed LLM API call metadata for telemetry
2027#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2028#[serde(rename_all = "camelCase")]
2029pub struct ModelCallFailureData {
2030    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
2031    #[serde(skip_serializing_if = "Option::is_none")]
2032    pub api_call_id: Option<String>,
2033    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
2034    #[serde(skip_serializing_if = "Option::is_none")]
2035    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
2036    /// 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.
2037    #[serde(skip_serializing_if = "Option::is_none")]
2038    pub bad_request_kind: Option<ModelCallFailureBadRequestKind>,
2039    /// Duration of the failed API call in milliseconds
2040    #[serde(skip_serializing_if = "Option::is_none")]
2041    pub duration_ms: Option<i64>,
2042    /// 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.
2043    #[serde(skip_serializing_if = "Option::is_none")]
2044    pub error_code: Option<String>,
2045    /// Raw provider/runtime error message for restricted telemetry
2046    #[serde(skip_serializing_if = "Option::is_none")]
2047    pub error_message: Option<String>,
2048    /// 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.
2049    #[serde(skip_serializing_if = "Option::is_none")]
2050    pub error_type: Option<String>,
2051    /// Whether the failure originated from an API response or the request transport
2052    #[serde(skip_serializing_if = "Option::is_none")]
2053    pub failure_kind: Option<ModelCallFailureKind>,
2054    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
2055    #[serde(skip_serializing_if = "Option::is_none")]
2056    pub initiator: Option<String>,
2057    /// Whether the session selected Auto mode for the failed call
2058    #[serde(skip_serializing_if = "Option::is_none")]
2059    pub is_auto: Option<bool>,
2060    /// Whether the failed call used a bring-your-own-key provider
2061    #[serde(skip_serializing_if = "Option::is_none")]
2062    pub is_byok: Option<bool>,
2063    /// Effective maximum output-token limit for the failed call
2064    #[serde(skip_serializing_if = "Option::is_none")]
2065    pub max_output_tokens: Option<i64>,
2066    /// Effective maximum prompt-token limit for the failed call
2067    #[serde(skip_serializing_if = "Option::is_none")]
2068    pub max_prompt_tokens: Option<i64>,
2069    /// Model identifier used for the failed API call
2070    #[serde(skip_serializing_if = "Option::is_none")]
2071    pub model: Option<String>,
2072    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
2073    #[serde(skip_serializing_if = "Option::is_none")]
2074    pub provider_call_id: Option<String>,
2075    /// 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.
2076    #[doc(hidden)]
2077    #[serde(skip_serializing_if = "Option::is_none")]
2078    pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
2079    /// Reasoning effort level used for the failed model call, if applicable
2080    #[serde(skip_serializing_if = "Option::is_none")]
2081    pub reasoning_effort: Option<String>,
2082    /// 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.
2083    #[serde(skip_serializing_if = "Option::is_none")]
2084    pub request_fingerprint: Option<ModelCallFailureRequestFingerprint>,
2085    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
2086    #[serde(skip_serializing_if = "Option::is_none")]
2087    pub service_request_id: Option<String>,
2088    /// Where the failed model call originated
2089    pub source: ModelCallFailureSource,
2090    /// HTTP status code from the failed request
2091    #[serde(skip_serializing_if = "Option::is_none")]
2092    pub status_code: Option<i32>,
2093    /// Transport used for the failed model call (http or websocket)
2094    #[serde(skip_serializing_if = "Option::is_none")]
2095    pub transport: Option<ModelCallFailureTransport>,
2096}
2097
2098/// Session event "model.call_start". Model API dispatch metadata for internal telemetry
2099#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2100#[serde(rename_all = "camelCase")]
2101pub struct ModelCallStartData {
2102    /// Model identifier used for this API call, when known
2103    #[serde(skip_serializing_if = "Option::is_none")]
2104    pub model: Option<String>,
2105    /// Identifier of the assistant turn that initiated the model call
2106    pub turn_id: String,
2107}
2108
2109/// Session event "abort". Turn abort information including the reason for termination
2110#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2111#[serde(rename_all = "camelCase")]
2112pub struct AbortData {
2113    /// Finite reason code describing why the current turn was aborted
2114    pub reason: AbortReason,
2115}
2116
2117/// Session event "tool.user_requested". User-initiated tool invocation request with tool name and arguments
2118#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2119#[serde(rename_all = "camelCase")]
2120pub struct ToolUserRequestedData {
2121    /// Arguments for the tool invocation
2122    #[serde(skip_serializing_if = "Option::is_none")]
2123    pub arguments: Option<serde_json::Value>,
2124    /// Unique identifier for this tool call
2125    pub tool_call_id: String,
2126    /// Name of the tool the user wants to invoke
2127    pub tool_name: String,
2128}
2129
2130/// 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.
2131#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2132#[serde(rename_all = "camelCase")]
2133pub struct ToolExecutionStartShellToolInfo {
2134    /// Whether the command includes a file write redirection (e.g., > or >>).
2135    pub has_write_file_redirection: bool,
2136    /// 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.
2137    pub possible_paths: Vec<String>,
2138}
2139
2140/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
2141#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2142#[serde(rename_all = "camelCase")]
2143pub struct ToolExecutionStartToolDescriptionMetaUI {
2144    /// URI of the UI resource
2145    #[serde(skip_serializing_if = "Option::is_none")]
2146    pub resource_uri: Option<String>,
2147    /// Who can access this tool
2148    #[serde(skip_serializing_if = "Option::is_none")]
2149    pub visibility: Option<Vec<ToolExecutionStartToolDescriptionMetaUIVisibility>>,
2150}
2151
2152/// MCP Apps metadata for UI resource association
2153#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2154#[serde(rename_all = "camelCase")]
2155pub struct ToolExecutionStartToolDescriptionMeta {
2156    /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
2157    #[serde(skip_serializing_if = "Option::is_none")]
2158    pub ui: Option<ToolExecutionStartToolDescriptionMetaUI>,
2159}
2160
2161/// Tool definition metadata, present for MCP tools with MCP Apps support
2162#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2163#[serde(rename_all = "camelCase")]
2164pub struct ToolExecutionStartToolDescription {
2165    /// MCP Apps metadata for UI resource association
2166    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
2167    pub meta: Option<ToolExecutionStartToolDescriptionMeta>,
2168    /// Tool description
2169    #[serde(skip_serializing_if = "Option::is_none")]
2170    pub description: Option<String>,
2171    /// Tool name
2172    pub name: String,
2173}
2174
2175/// Session event "tool.execution_start". Tool execution startup details including MCP server information when applicable
2176#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2177#[serde(rename_all = "camelCase")]
2178pub struct ToolExecutionStartData {
2179    /// Arguments passed to the tool
2180    #[serde(skip_serializing_if = "Option::is_none")]
2181    pub arguments: Option<serde_json::Value>,
2182    /// When true, the tool output should be displayed expanded (verbatim) in the CLI timeline
2183    #[serde(skip_serializing_if = "Option::is_none")]
2184    pub display_verbatim: Option<bool>,
2185    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
2186    #[serde(skip_serializing_if = "Option::is_none")]
2187    pub mcp_server_name: Option<String>,
2188    /// Original tool name on the MCP server, when the tool is an MCP tool
2189    #[serde(skip_serializing_if = "Option::is_none")]
2190    pub mcp_tool_name: Option<String>,
2191    /// Model identifier that generated this tool call
2192    #[serde(skip_serializing_if = "Option::is_none")]
2193    pub model: Option<String>,
2194    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
2195    #[doc(hidden)]
2196    #[deprecated]
2197    #[serde(skip_serializing_if = "Option::is_none")]
2198    pub parent_tool_call_id: Option<String>,
2199    /// 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.
2200    #[serde(skip_serializing_if = "Option::is_none")]
2201    pub shell_tool_info: Option<ToolExecutionStartShellToolInfo>,
2202    /// Unique identifier for this tool call
2203    pub tool_call_id: String,
2204    /// Tool definition metadata, present for MCP tools with MCP Apps support
2205    #[serde(skip_serializing_if = "Option::is_none")]
2206    pub tool_description: Option<ToolExecutionStartToolDescription>,
2207    /// Name of the tool being executed
2208    pub tool_name: String,
2209    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
2210    #[serde(skip_serializing_if = "Option::is_none")]
2211    pub turn_id: Option<String>,
2212}
2213
2214/// Session event "tool.execution_partial_result". Streaming tool execution output for incremental result display
2215#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2216#[serde(rename_all = "camelCase")]
2217pub struct ToolExecutionPartialResultData {
2218    /// Incremental output chunk from the running tool
2219    pub partial_output: String,
2220    /// Tool call ID this partial result belongs to
2221    pub tool_call_id: String,
2222}
2223
2224/// Session event "tool.execution_progress". Tool execution progress notification with status message
2225#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2226#[serde(rename_all = "camelCase")]
2227pub struct ToolExecutionProgressData {
2228    /// Human-readable progress status message (e.g., from an MCP server)
2229    pub progress_message: String,
2230    /// Tool call ID this progress notification belongs to
2231    pub tool_call_id: String,
2232}
2233
2234/// Error details when the tool execution failed
2235#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2236#[serde(rename_all = "camelCase")]
2237pub struct ToolExecutionCompleteError {
2238    /// Machine-readable error code
2239    #[serde(skip_serializing_if = "Option::is_none")]
2240    pub code: Option<String>,
2241    /// Human-readable error message
2242    pub message: String,
2243}
2244
2245/// A source supplied by a tool that should be made available to the model as citable content.
2246///
2247/// <div class="warning">
2248///
2249/// **Experimental.** This type is part of an experimental wire-protocol surface
2250/// and may change or be removed in future SDK or CLI releases.
2251///
2252/// </div>
2253#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2254#[serde(rename_all = "camelCase")]
2255pub struct CitableSource {
2256    /// The source text made available to the model as citable content.
2257    pub content: String,
2258    /// 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.
2259    pub id: String,
2260    /// File path relative to the agent's workspace root, when the source is a file.
2261    #[serde(skip_serializing_if = "Option::is_none")]
2262    pub path: Option<String>,
2263    /// Human-readable title of the source.
2264    #[serde(skip_serializing_if = "Option::is_none")]
2265    pub title: Option<String>,
2266    /// URL of the source, when it is a web resource.
2267    #[serde(skip_serializing_if = "Option::is_none")]
2268    pub url: Option<String>,
2269}
2270
2271/// Plain text content block
2272#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2273#[serde(rename_all = "camelCase")]
2274pub struct ToolExecutionCompleteContentText {
2275    /// The text content
2276    pub text: String,
2277    /// Content block type discriminator
2278    pub r#type: ToolExecutionCompleteContentTextType,
2279}
2280
2281/// Deprecated for shell command exit metadata. Use ToolExecutionCompleteContentShellExit instead.
2282#[doc(hidden)]
2283#[deprecated]
2284#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2285#[serde(rename_all = "camelCase")]
2286pub struct ToolExecutionCompleteContentTerminal {
2287    /// Working directory where the command was executed
2288    #[serde(skip_serializing_if = "Option::is_none")]
2289    pub cwd: Option<String>,
2290    /// Process exit code, if the command has completed
2291    #[serde(skip_serializing_if = "Option::is_none")]
2292    pub exit_code: Option<i64>,
2293    /// Terminal/shell output text
2294    pub text: String,
2295    /// Content block type discriminator
2296    pub r#type: ToolExecutionCompleteContentTerminalType,
2297}
2298
2299/// Shell command exit metadata with optional output preview
2300#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2301#[serde(rename_all = "camelCase")]
2302pub struct ToolExecutionCompleteContentShellExit {
2303    /// Working directory where the shell command was executed
2304    #[serde(skip_serializing_if = "Option::is_none")]
2305    pub cwd: Option<String>,
2306    /// Exit code from the completed shell command
2307    pub exit_code: i64,
2308    /// Output associated with this shell command, if available. May be partial, truncated, or a preview; not guaranteed to be full output.
2309    #[serde(skip_serializing_if = "Option::is_none")]
2310    pub output_preview: Option<String>,
2311    /// Whether outputPreview is known to be incomplete or truncated
2312    #[serde(skip_serializing_if = "Option::is_none")]
2313    pub output_truncated: Option<bool>,
2314    /// Shell id, as assigned by Copilot runtime
2315    pub shell_id: String,
2316    /// Content block type discriminator
2317    pub r#type: ToolExecutionCompleteContentShellExitType,
2318}
2319
2320/// Image content block with base64-encoded data
2321#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2322#[serde(rename_all = "camelCase")]
2323pub struct ToolExecutionCompleteContentImage {
2324    /// Base64-encoded image data
2325    pub data: String,
2326    /// MIME type of the image (e.g., image/png, image/jpeg)
2327    pub mime_type: String,
2328    /// Content block type discriminator
2329    pub r#type: ToolExecutionCompleteContentImageType,
2330}
2331
2332/// Audio content block with base64-encoded data
2333#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2334#[serde(rename_all = "camelCase")]
2335pub struct ToolExecutionCompleteContentAudio {
2336    /// Base64-encoded audio data
2337    pub data: String,
2338    /// MIME type of the audio (e.g., audio/wav, audio/mpeg)
2339    pub mime_type: String,
2340    /// Content block type discriminator
2341    pub r#type: ToolExecutionCompleteContentAudioType,
2342}
2343
2344/// Icon image for a resource
2345#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2346#[serde(rename_all = "camelCase")]
2347pub struct ToolExecutionCompleteContentResourceLinkIcon {
2348    /// MIME type of the icon image
2349    #[serde(skip_serializing_if = "Option::is_none")]
2350    pub mime_type: Option<String>,
2351    /// Available icon sizes (e.g., ['16x16', '32x32'])
2352    #[serde(skip_serializing_if = "Option::is_none")]
2353    pub sizes: Option<Vec<String>>,
2354    /// URL or path to the icon image
2355    pub src: String,
2356    /// Theme variant this icon is intended for
2357    #[serde(skip_serializing_if = "Option::is_none")]
2358    pub theme: Option<ToolExecutionCompleteContentResourceLinkIconTheme>,
2359}
2360
2361/// Resource link content block referencing an external resource
2362#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2363#[serde(rename_all = "camelCase")]
2364pub struct ToolExecutionCompleteContentResourceLink {
2365    /// Human-readable description of the resource
2366    #[serde(skip_serializing_if = "Option::is_none")]
2367    pub description: Option<String>,
2368    /// Icons associated with this resource
2369    #[serde(skip_serializing_if = "Option::is_none")]
2370    pub icons: Option<Vec<ToolExecutionCompleteContentResourceLinkIcon>>,
2371    /// MIME type of the resource content
2372    #[serde(skip_serializing_if = "Option::is_none")]
2373    pub mime_type: Option<String>,
2374    /// Resource name identifier
2375    pub name: String,
2376    /// Size of the resource in bytes
2377    #[serde(skip_serializing_if = "Option::is_none")]
2378    pub size: Option<i64>,
2379    /// Human-readable display title for the resource
2380    #[serde(skip_serializing_if = "Option::is_none")]
2381    pub title: Option<String>,
2382    /// Content block type discriminator
2383    pub r#type: ToolExecutionCompleteContentResourceLinkType,
2384    /// URI identifying the resource
2385    pub uri: String,
2386}
2387
2388/// Embedded text resource contents identified by a URI, with an optional MIME type and a text payload.
2389#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2390#[serde(rename_all = "camelCase")]
2391pub struct EmbeddedTextResourceContents {
2392    /// MIME type of the text content
2393    #[serde(skip_serializing_if = "Option::is_none")]
2394    pub mime_type: Option<String>,
2395    /// Text content of the resource
2396    pub text: String,
2397    /// URI identifying the resource
2398    pub uri: String,
2399}
2400
2401/// Embedded binary resource contents identified by a URI, with an optional MIME type and a base64-encoded blob.
2402#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2403#[serde(rename_all = "camelCase")]
2404pub struct EmbeddedBlobResourceContents {
2405    /// Base64-encoded binary content of the resource
2406    pub blob: String,
2407    /// MIME type of the blob content
2408    #[serde(skip_serializing_if = "Option::is_none")]
2409    pub mime_type: Option<String>,
2410    /// URI identifying the resource
2411    pub uri: String,
2412}
2413
2414/// Embedded resource content block with inline text or binary data
2415#[derive(Debug, Clone, Serialize, Deserialize)]
2416#[serde(rename_all = "camelCase")]
2417pub struct ToolExecutionCompleteContentResource {
2418    /// The embedded resource contents, either text or base64-encoded binary
2419    pub resource: ToolExecutionCompleteContentResourceDetails,
2420    /// Content block type discriminator
2421    pub r#type: ToolExecutionCompleteContentResourceType,
2422}
2423
2424/// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
2425#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2426#[serde(rename_all = "camelCase")]
2427pub struct ToolExecutionCompleteUIResourceMetaUICsp {
2428    #[serde(skip_serializing_if = "Option::is_none")]
2429    pub base_uri_domains: Option<Vec<String>>,
2430    #[serde(skip_serializing_if = "Option::is_none")]
2431    pub connect_domains: Option<Vec<String>>,
2432    #[serde(skip_serializing_if = "Option::is_none")]
2433    pub frame_domains: Option<Vec<String>>,
2434    #[serde(skip_serializing_if = "Option::is_none")]
2435    pub resource_domains: Option<Vec<String>>,
2436}
2437
2438/// Marker object for camera permission on an MCP Apps UI resource.
2439#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2440#[serde(rename_all = "camelCase")]
2441pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsCamera {}
2442
2443/// Marker object for clipboard-write permission on an MCP Apps UI resource.
2444#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2445#[serde(rename_all = "camelCase")]
2446pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite {}
2447
2448/// Marker object for geolocation permission on an MCP Apps UI resource.
2449#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2450#[serde(rename_all = "camelCase")]
2451pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation {}
2452
2453/// Marker object for microphone permission on an MCP Apps UI resource.
2454#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2455#[serde(rename_all = "camelCase")]
2456pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone {}
2457
2458/// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
2459#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2460#[serde(rename_all = "camelCase")]
2461pub struct ToolExecutionCompleteUIResourceMetaUIPermissions {
2462    /// Marker object for camera permission on an MCP Apps UI resource.
2463    #[serde(skip_serializing_if = "Option::is_none")]
2464    pub camera: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsCamera>,
2465    /// Marker object for clipboard-write permission on an MCP Apps UI resource.
2466    #[serde(skip_serializing_if = "Option::is_none")]
2467    pub clipboard_write: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite>,
2468    /// Marker object for geolocation permission on an MCP Apps UI resource.
2469    #[serde(skip_serializing_if = "Option::is_none")]
2470    pub geolocation: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation>,
2471    /// Marker object for microphone permission on an MCP Apps UI resource.
2472    #[serde(skip_serializing_if = "Option::is_none")]
2473    pub microphone: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone>,
2474}
2475
2476/// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
2477#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2478#[serde(rename_all = "camelCase")]
2479pub struct ToolExecutionCompleteUIResourceMetaUI {
2480    /// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
2481    #[serde(skip_serializing_if = "Option::is_none")]
2482    pub csp: Option<ToolExecutionCompleteUIResourceMetaUICsp>,
2483    #[serde(skip_serializing_if = "Option::is_none")]
2484    pub domain: Option<String>,
2485    /// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
2486    #[serde(skip_serializing_if = "Option::is_none")]
2487    pub permissions: Option<ToolExecutionCompleteUIResourceMetaUIPermissions>,
2488    #[serde(skip_serializing_if = "Option::is_none")]
2489    pub prefers_border: Option<bool>,
2490}
2491
2492/// Resource-level UI metadata (CSP, permissions, visual preferences)
2493#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2494#[serde(rename_all = "camelCase")]
2495pub struct ToolExecutionCompleteUIResourceMeta {
2496    /// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
2497    #[serde(skip_serializing_if = "Option::is_none")]
2498    pub ui: Option<ToolExecutionCompleteUIResourceMetaUI>,
2499}
2500
2501/// MCP Apps UI resource content for rendering in a sandboxed iframe
2502#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2503#[serde(rename_all = "camelCase")]
2504pub struct ToolExecutionCompleteUIResource {
2505    /// Resource-level UI metadata (CSP, permissions, visual preferences)
2506    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
2507    pub meta: Option<ToolExecutionCompleteUIResourceMeta>,
2508    /// Base64-encoded HTML content
2509    #[serde(skip_serializing_if = "Option::is_none")]
2510    pub blob: Option<String>,
2511    /// MIME type of the content
2512    pub mime_type: String,
2513    /// HTML content as a string
2514    #[serde(skip_serializing_if = "Option::is_none")]
2515    pub text: Option<String>,
2516    /// The ui:// URI of the resource
2517    pub uri: String,
2518}
2519
2520/// Tool execution result on success
2521#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2522#[serde(rename_all = "camelCase")]
2523pub struct ToolExecutionCompleteResult {
2524    /// Model-facing binary results (base64 inline or size-omitted markers) sent to the LLM for this tool call
2525    ///
2526    /// <div class="warning">
2527    ///
2528    /// **Experimental.** This type is part of an experimental wire-protocol surface
2529    /// and may change or be removed in future SDK or CLI releases.
2530    ///
2531    /// </div>
2532    #[serde(skip_serializing_if = "Option::is_none")]
2533    pub binary_results_for_llm: Option<Vec<serde_json::Value>>,
2534    /// Provider-neutral source material this tool makes available to the model as citable content. Persisted so it survives session resume. Experimental.
2535    ///
2536    /// <div class="warning">
2537    ///
2538    /// **Experimental.** This type is part of an experimental wire-protocol surface
2539    /// and may change or be removed in future SDK or CLI releases.
2540    ///
2541    /// </div>
2542    #[serde(skip_serializing_if = "Option::is_none")]
2543    pub citable_sources: Option<Vec<CitableSource>>,
2544    /// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency
2545    pub content: String,
2546    /// Structured content blocks (text, images, audio, resources) returned by the tool in their native format
2547    #[serde(skip_serializing_if = "Option::is_none")]
2548    pub contents: Option<Vec<ToolExecutionCompleteContent>>,
2549    /// Full detailed tool result for UI/timeline display, preserving complete content such as diffs. Falls back to content when absent.
2550    #[serde(skip_serializing_if = "Option::is_none")]
2551    pub detailed_content: Option<String>,
2552    /// 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.
2553    ///
2554    /// <div class="warning">
2555    ///
2556    /// **Experimental.** This type is part of an experimental wire-protocol surface
2557    /// and may change or be removed in future SDK or CLI releases.
2558    ///
2559    /// </div>
2560    #[serde(skip_serializing_if = "Option::is_none")]
2561    pub mcp_meta: Option<serde_json::Value>,
2562    /// Structured content (arbitrary JSON) returned verbatim by the MCP tool
2563    #[serde(skip_serializing_if = "Option::is_none")]
2564    pub structured_content: Option<serde_json::Value>,
2565    /// MCP Apps UI resource content for rendering in a sandboxed iframe
2566    #[serde(skip_serializing_if = "Option::is_none")]
2567    pub ui_resource: Option<ToolExecutionCompleteUIResource>,
2568}
2569
2570/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
2571#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2572#[serde(rename_all = "camelCase")]
2573pub struct ToolExecutionCompleteToolDescriptionMetaUI {
2574    /// URI of the UI resource
2575    #[serde(skip_serializing_if = "Option::is_none")]
2576    pub resource_uri: Option<String>,
2577    /// Who can access this tool
2578    #[serde(skip_serializing_if = "Option::is_none")]
2579    pub visibility: Option<Vec<ToolExecutionCompleteToolDescriptionMetaUIVisibility>>,
2580}
2581
2582/// MCP Apps metadata for UI resource association
2583#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2584#[serde(rename_all = "camelCase")]
2585pub struct ToolExecutionCompleteToolDescriptionMeta {
2586    /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
2587    #[serde(skip_serializing_if = "Option::is_none")]
2588    pub ui: Option<ToolExecutionCompleteToolDescriptionMetaUI>,
2589}
2590
2591/// Tool definition metadata, present for MCP tools with MCP Apps support
2592#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2593#[serde(rename_all = "camelCase")]
2594pub struct ToolExecutionCompleteToolDescription {
2595    /// MCP Apps metadata for UI resource association
2596    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
2597    pub meta: Option<ToolExecutionCompleteToolDescriptionMeta>,
2598    /// Tool description
2599    #[serde(skip_serializing_if = "Option::is_none")]
2600    pub description: Option<String>,
2601    /// Tool name
2602    pub name: String,
2603}
2604
2605/// Session event "tool.execution_complete". Tool execution completion results including success status, detailed output, and error information
2606#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2607#[serde(rename_all = "camelCase")]
2608pub struct ToolExecutionCompleteData {
2609    /// Error details when the tool execution failed
2610    #[serde(skip_serializing_if = "Option::is_none")]
2611    pub error: Option<ToolExecutionCompleteError>,
2612    /// CAPI interaction ID for correlating this tool execution with upstream telemetry
2613    #[serde(skip_serializing_if = "Option::is_none")]
2614    pub interaction_id: Option<String>,
2615    /// Whether this tool call was explicitly requested by the user rather than the assistant
2616    #[serde(skip_serializing_if = "Option::is_none")]
2617    pub is_user_requested: Option<bool>,
2618    /// 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.
2619    ///
2620    /// <div class="warning">
2621    ///
2622    /// **Experimental.** This type is part of an experimental wire-protocol surface
2623    /// and may change or be removed in future SDK or CLI releases.
2624    ///
2625    /// </div>
2626    #[serde(skip_serializing_if = "Option::is_none")]
2627    pub mcp_meta: Option<serde_json::Value>,
2628    /// Model identifier that generated this tool call
2629    #[serde(skip_serializing_if = "Option::is_none")]
2630    pub model: Option<String>,
2631    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
2632    #[doc(hidden)]
2633    #[deprecated]
2634    #[serde(skip_serializing_if = "Option::is_none")]
2635    pub parent_tool_call_id: Option<String>,
2636    /// Tool execution result on success
2637    #[serde(skip_serializing_if = "Option::is_none")]
2638    pub result: Option<ToolExecutionCompleteResult>,
2639    /// Whether this tool execution ran inside a sandbox container
2640    #[serde(skip_serializing_if = "Option::is_none")]
2641    pub sandboxed: Option<bool>,
2642    /// Whether the tool execution completed successfully
2643    pub success: bool,
2644    /// Unique identifier for the completed tool call
2645    pub tool_call_id: String,
2646    /// Tool definition metadata, present for MCP tools with MCP Apps support
2647    #[serde(skip_serializing_if = "Option::is_none")]
2648    pub tool_description: Option<ToolExecutionCompleteToolDescription>,
2649    /// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
2650    #[serde(skip_serializing_if = "Option::is_none")]
2651    pub tool_telemetry: Option<HashMap<String, serde_json::Value>>,
2652    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
2653    #[serde(skip_serializing_if = "Option::is_none")]
2654    pub turn_id: Option<String>,
2655}
2656
2657/// Session event "tool_search.activated". Persisted generic client-side tool activations restored when a session resumes.
2658#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2659#[serde(rename_all = "camelCase")]
2660pub struct ToolSearchActivatedData {
2661    /// Tool-search strategy that activated the definitions.
2662    pub strategy: String,
2663    /// Names of tool definitions activated by this search invocation.
2664    pub tool_names: Vec<String>,
2665}
2666
2667/// Session event "skill.invoked". Skill invocation details including content, allowed tools, and plugin metadata
2668#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2669#[serde(rename_all = "camelCase")]
2670pub struct SkillInvokedData {
2671    /// Tool names that should be auto-approved when this skill is active
2672    #[serde(skip_serializing_if = "Option::is_none")]
2673    pub allowed_tools: Option<Vec<String>>,
2674    /// Full content of the skill file, injected into the conversation for the model
2675    pub content: String,
2676    /// Description of the skill from its SKILL.md frontmatter
2677    #[serde(skip_serializing_if = "Option::is_none")]
2678    pub description: Option<String>,
2679    /// Model identifier active when the skill was invoked, when known
2680    #[serde(skip_serializing_if = "Option::is_none")]
2681    pub model: Option<String>,
2682    /// Name of the invoked skill
2683    pub name: String,
2684    /// File path to the SKILL.md definition
2685    pub path: String,
2686    /// Name of the plugin this skill originated from, when applicable
2687    #[serde(skip_serializing_if = "Option::is_none")]
2688    pub plugin_name: Option<String>,
2689    /// Version of the plugin this skill originated from, when applicable
2690    #[serde(skip_serializing_if = "Option::is_none")]
2691    pub plugin_version: Option<String>,
2692    /// 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), and remote (org/enterprise skill)
2693    #[serde(skip_serializing_if = "Option::is_none")]
2694    pub source: Option<String>,
2695    /// 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)
2696    #[serde(skip_serializing_if = "Option::is_none")]
2697    pub trigger: Option<SkillInvokedTrigger>,
2698}
2699
2700/// Session event "subagent.started". Sub-agent startup details including parent tool call and agent information
2701#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2702#[serde(rename_all = "camelCase")]
2703pub struct SubagentStartedData {
2704    /// Description of what the sub-agent does
2705    pub agent_description: String,
2706    /// Human-readable display name of the sub-agent
2707    pub agent_display_name: String,
2708    /// Internal name of the sub-agent
2709    pub agent_name: String,
2710    /// Model the sub-agent will run with, when known at start.
2711    #[serde(skip_serializing_if = "Option::is_none")]
2712    pub model: Option<String>,
2713    /// Tool call ID of the parent tool invocation that spawned this sub-agent
2714    pub tool_call_id: String,
2715}
2716
2717/// Session event "subagent.completed". Sub-agent completion details for successful execution
2718#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2719#[serde(rename_all = "camelCase")]
2720pub struct SubagentCompletedData {
2721    /// Human-readable display name of the sub-agent
2722    pub agent_display_name: String,
2723    /// Internal name of the sub-agent
2724    pub agent_name: String,
2725    /// Wall-clock duration of the sub-agent execution in milliseconds
2726    #[serde(skip_serializing_if = "Option::is_none")]
2727    pub duration_ms: Option<i64>,
2728    /// Model used by the sub-agent
2729    #[serde(skip_serializing_if = "Option::is_none")]
2730    pub model: Option<String>,
2731    /// Tool call ID of the parent tool invocation that spawned this sub-agent
2732    pub tool_call_id: String,
2733    /// Total tokens (input + output) consumed by the sub-agent
2734    #[serde(skip_serializing_if = "Option::is_none")]
2735    pub total_tokens: Option<i64>,
2736    /// Total number of tool calls made by the sub-agent
2737    #[serde(skip_serializing_if = "Option::is_none")]
2738    pub total_tool_calls: Option<i64>,
2739}
2740
2741/// Session event "subagent.failed". Sub-agent failure details including error message and agent information
2742#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2743#[serde(rename_all = "camelCase")]
2744pub struct SubagentFailedData {
2745    /// Human-readable display name of the sub-agent
2746    pub agent_display_name: String,
2747    /// Internal name of the sub-agent
2748    pub agent_name: String,
2749    /// Wall-clock duration of the sub-agent execution in milliseconds
2750    #[serde(skip_serializing_if = "Option::is_none")]
2751    pub duration_ms: Option<i64>,
2752    /// Error message describing why the sub-agent failed
2753    pub error: String,
2754    /// Model selected for the sub-agent, when known
2755    #[serde(skip_serializing_if = "Option::is_none")]
2756    pub model: Option<String>,
2757    /// Tool call ID of the parent tool invocation that spawned this sub-agent
2758    pub tool_call_id: String,
2759    /// Total tokens (input + output) consumed before the sub-agent failed
2760    #[serde(skip_serializing_if = "Option::is_none")]
2761    pub total_tokens: Option<i64>,
2762    /// Total number of tool calls made before the sub-agent failed
2763    #[serde(skip_serializing_if = "Option::is_none")]
2764    pub total_tool_calls: Option<i64>,
2765}
2766
2767/// Session event "subagent.selected". Custom agent selection details including name and available tools
2768#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2769#[serde(rename_all = "camelCase")]
2770pub struct SubagentSelectedData {
2771    /// Human-readable display name of the selected custom agent
2772    pub agent_display_name: String,
2773    /// Internal name of the selected custom agent
2774    pub agent_name: String,
2775    /// List of tool names available to this agent, or null for all tools
2776    pub tools: Option<Vec<String>>,
2777}
2778
2779/// Session event "subagent.deselected". Empty payload; the event signals that the custom agent was deselected, returning to the default agent
2780#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2781#[serde(rename_all = "camelCase")]
2782pub struct SubagentDeselectedData {}
2783
2784/// Session event "hook.start". Hook invocation start details including type and input data
2785#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2786#[serde(rename_all = "camelCase")]
2787pub struct HookStartData {
2788    /// Unique identifier for this hook invocation
2789    pub hook_invocation_id: String,
2790    /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
2791    pub hook_type: String,
2792    /// Input data passed to the hook
2793    #[serde(skip_serializing_if = "Option::is_none")]
2794    pub input: Option<serde_json::Value>,
2795}
2796
2797/// Error details when the hook failed
2798#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2799#[serde(rename_all = "camelCase")]
2800pub struct HookEndError {
2801    /// Human-readable error message
2802    pub message: String,
2803    /// Source label of the hook that errored (e.g. the plugin it was loaded from), when known
2804    #[serde(skip_serializing_if = "Option::is_none")]
2805    pub source: Option<String>,
2806    /// Error stack trace, when available
2807    #[serde(skip_serializing_if = "Option::is_none")]
2808    pub stack: Option<String>,
2809}
2810
2811/// Session event "hook.end". Hook invocation completion details including output, success status, and error information
2812#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2813#[serde(rename_all = "camelCase")]
2814pub struct HookEndData {
2815    /// Error details when the hook failed
2816    #[serde(skip_serializing_if = "Option::is_none")]
2817    pub error: Option<HookEndError>,
2818    /// Identifier matching the corresponding hook.start event
2819    pub hook_invocation_id: String,
2820    /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
2821    pub hook_type: String,
2822    /// Output data produced by the hook
2823    #[serde(skip_serializing_if = "Option::is_none")]
2824    pub output: Option<serde_json::Value>,
2825    /// Whether the hook completed successfully
2826    pub success: bool,
2827}
2828
2829/// Session event "hook.progress". Ephemeral progress update from a running hook process
2830#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2831#[serde(rename_all = "camelCase")]
2832pub struct HookProgressData {
2833    /// Human-readable progress message from the hook process
2834    pub message: String,
2835    /// When true, this status message replaces the previous temporary one instead of accumulating
2836    #[serde(skip_serializing_if = "Option::is_none")]
2837    pub temporary: Option<bool>,
2838}
2839
2840/// Session event "session.binary_asset". Canonical bytes for a content-addressed binary asset shared by reference across events
2841#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2842#[serde(rename_all = "camelCase")]
2843pub struct SessionBinaryAssetData {
2844    /// Content-addressed id for this binary asset (e.g. "sha256:...").
2845    pub asset_id: String,
2846    /// Decoded byte length of the binary asset
2847    pub byte_length: i64,
2848    /// Base64-encoded binary data
2849    pub data: String,
2850    /// Human-readable description of the binary data
2851    #[serde(skip_serializing_if = "Option::is_none")]
2852    pub description: Option<String>,
2853    /// Optional metadata from the producing tool.
2854    #[serde(skip_serializing_if = "Option::is_none")]
2855    pub metadata: Option<HashMap<String, serde_json::Value>>,
2856    /// MIME type of the binary asset
2857    pub mime_type: String,
2858    /// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
2859    pub r#type: BinaryAssetType,
2860}
2861
2862/// Metadata about the prompt template and its construction
2863#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2864#[serde(rename_all = "camelCase")]
2865pub struct SystemMessageMetadata {
2866    /// Version identifier of the prompt template used
2867    #[serde(skip_serializing_if = "Option::is_none")]
2868    pub prompt_version: Option<String>,
2869    /// Template variables used when constructing the prompt
2870    #[serde(skip_serializing_if = "Option::is_none")]
2871    pub variables: Option<HashMap<String, serde_json::Value>>,
2872}
2873
2874/// Session event "system.message". System/developer instruction content with role and optional template metadata
2875#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2876#[serde(rename_all = "camelCase")]
2877pub struct SystemMessageData {
2878    /// The system or developer prompt text sent as model input
2879    pub content: String,
2880    /// Metadata about the prompt template and its construction
2881    #[serde(skip_serializing_if = "Option::is_none")]
2882    pub metadata: Option<SystemMessageMetadata>,
2883    /// Optional name identifier for the message source
2884    #[serde(skip_serializing_if = "Option::is_none")]
2885    pub name: Option<String>,
2886    /// Message role: "system" for system prompts, "developer" for developer-injected instructions
2887    pub role: SystemMessageRole,
2888}
2889
2890/// Session event "system.notification". System-generated notification for runtime events like background task completion
2891#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2892#[serde(rename_all = "camelCase")]
2893pub struct SystemNotificationData {
2894    /// The notification text, typically wrapped in <system_notification> XML tags
2895    pub content: String,
2896    /// Structured metadata identifying what triggered this notification
2897    pub kind: serde_json::Value,
2898}
2899
2900/// A parsed command identifier in a shell permission request, including whether it is read-only.
2901#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2902#[serde(rename_all = "camelCase")]
2903pub struct PermissionRequestShellCommand {
2904    /// Command identifier (e.g., executable name)
2905    pub identifier: String,
2906    /// Whether this command is read-only (no side effects)
2907    pub read_only: bool,
2908}
2909
2910/// A URL that may be accessed by a command in a shell permission request.
2911#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2912#[serde(rename_all = "camelCase")]
2913pub struct PermissionRequestShellPossibleUrl {
2914    /// URL that may be accessed by the command
2915    pub url: String,
2916}
2917
2918/// Shell command permission request
2919#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2920#[serde(rename_all = "camelCase")]
2921pub struct PermissionRequestShell {
2922    /// Whether the UI can offer session-wide approval for this command pattern
2923    pub can_offer_session_approval: bool,
2924    /// Parsed command identifiers found in the command text
2925    pub commands: Vec<PermissionRequestShellCommand>,
2926    /// The complete shell command text to be executed
2927    pub full_command_text: String,
2928    /// Whether the command includes a file write redirection (e.g., > or >>)
2929    pub has_write_file_redirection: bool,
2930    /// Human-readable description of what the command intends to do
2931    pub intention: String,
2932    /// Permission kind discriminator
2933    pub kind: PermissionRequestShellKind,
2934    /// File paths that may be read or written by the command
2935    pub possible_paths: Vec<String>,
2936    /// URLs that may be accessed by the command
2937    pub possible_urls: Vec<PermissionRequestShellPossibleUrl>,
2938    /// True when the model has requested to run this command outside the sandbox (it set requestSandboxBypass: true and the host opted in via sandbox.allowBypass). 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.
2939    #[serde(skip_serializing_if = "Option::is_none")]
2940    pub request_sandbox_bypass: Option<bool>,
2941    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
2942    #[serde(skip_serializing_if = "Option::is_none")]
2943    pub request_sandbox_bypass_reason: Option<String>,
2944    /// Tool call ID that triggered this permission request
2945    #[serde(skip_serializing_if = "Option::is_none")]
2946    pub tool_call_id: Option<String>,
2947    /// Optional warning message about risks of running this command
2948    #[serde(skip_serializing_if = "Option::is_none")]
2949    pub warning: Option<String>,
2950}
2951
2952/// File write permission request
2953#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2954#[serde(rename_all = "camelCase")]
2955pub struct PermissionRequestWrite {
2956    /// Whether the UI can offer session-wide approval for file write operations
2957    pub can_offer_session_approval: bool,
2958    /// Unified diff showing the proposed changes
2959    pub diff: String,
2960    /// Path of the file being written to
2961    pub file_name: String,
2962    /// Human-readable description of the intended file change
2963    pub intention: String,
2964    /// Permission kind discriminator
2965    pub kind: PermissionRequestWriteKind,
2966    /// Complete new file contents for newly created files
2967    #[serde(skip_serializing_if = "Option::is_none")]
2968    pub new_file_contents: Option<String>,
2969    /// 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.
2970    #[serde(skip_serializing_if = "Option::is_none")]
2971    pub request_sandbox_bypass: Option<bool>,
2972    /// Justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
2973    #[serde(skip_serializing_if = "Option::is_none")]
2974    pub request_sandbox_bypass_reason: Option<String>,
2975    /// Tool call ID that triggered this permission request
2976    #[serde(skip_serializing_if = "Option::is_none")]
2977    pub tool_call_id: Option<String>,
2978}
2979
2980/// File or directory read permission request
2981#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2982#[serde(rename_all = "camelCase")]
2983pub struct PermissionRequestRead {
2984    /// Human-readable description of why the file is being read
2985    pub intention: String,
2986    /// Permission kind discriminator
2987    pub kind: PermissionRequestReadKind,
2988    /// Path of the file or directory being read
2989    pub path: String,
2990    /// True when the model has requested to run this search outside the sandbox (it set requestSandboxBypass: true and the host opted in via sandbox.allowBypass). 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.
2991    #[serde(skip_serializing_if = "Option::is_none")]
2992    pub request_sandbox_bypass: Option<bool>,
2993    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
2994    #[serde(skip_serializing_if = "Option::is_none")]
2995    pub request_sandbox_bypass_reason: Option<String>,
2996    /// Tool call ID that triggered this permission request
2997    #[serde(skip_serializing_if = "Option::is_none")]
2998    pub tool_call_id: Option<String>,
2999}
3000
3001/// MCP tool invocation permission request
3002#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3003#[serde(rename_all = "camelCase")]
3004pub struct PermissionRequestMcp {
3005    /// Arguments to pass to the MCP tool
3006    #[serde(skip_serializing_if = "Option::is_none")]
3007    pub args: Option<serde_json::Value>,
3008    /// Permission kind discriminator
3009    pub kind: PermissionRequestMcpKind,
3010    /// Whether this MCP tool is read-only (no side effects)
3011    pub read_only: bool,
3012    /// Name of the MCP server providing the tool
3013    pub server_name: String,
3014    /// Tool call ID that triggered this permission request
3015    #[serde(skip_serializing_if = "Option::is_none")]
3016    pub tool_call_id: Option<String>,
3017    /// Internal name of the MCP tool
3018    pub tool_name: String,
3019    /// Human-readable title of the MCP tool
3020    pub tool_title: String,
3021}
3022
3023/// URL access permission request
3024#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3025#[serde(rename_all = "camelCase")]
3026pub struct PermissionRequestUrl {
3027    /// Human-readable description of why the URL is being accessed
3028    pub intention: String,
3029    /// Permission kind discriminator
3030    pub kind: PermissionRequestUrlKind,
3031    /// True when this URL fetch is requesting to bypass the sandbox network policy: either the model set requestSandboxBypass: true, or the tool re-issued the request as an interactive bypass after the network policy denied the approved URL (host opted in via sandbox.allowBypass). 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.
3032    #[serde(skip_serializing_if = "Option::is_none")]
3033    pub request_sandbox_bypass: Option<bool>,
3034    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3035    #[serde(skip_serializing_if = "Option::is_none")]
3036    pub request_sandbox_bypass_reason: Option<String>,
3037    /// Tool call ID that triggered this permission request
3038    #[serde(skip_serializing_if = "Option::is_none")]
3039    pub tool_call_id: Option<String>,
3040    /// URL to be fetched
3041    pub url: String,
3042}
3043
3044/// Memory operation permission request
3045#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3046#[serde(rename_all = "camelCase")]
3047pub struct PermissionRequestMemory {
3048    /// Whether this is a store or vote memory operation
3049    #[serde(skip_serializing_if = "Option::is_none")]
3050    pub action: Option<PermissionRequestMemoryAction>,
3051    /// Source references for the stored fact (store only)
3052    #[serde(skip_serializing_if = "Option::is_none")]
3053    pub citations: Option<String>,
3054    /// Vote direction (vote only)
3055    #[serde(skip_serializing_if = "Option::is_none")]
3056    pub direction: Option<PermissionRequestMemoryDirection>,
3057    /// The fact being stored or voted on
3058    pub fact: String,
3059    /// Permission kind discriminator
3060    pub kind: PermissionRequestMemoryKind,
3061    /// Reason for the vote (vote only)
3062    #[serde(skip_serializing_if = "Option::is_none")]
3063    pub reason: Option<String>,
3064    /// Topic or subject of the memory (store only)
3065    #[serde(skip_serializing_if = "Option::is_none")]
3066    pub subject: Option<String>,
3067    /// Tool call ID that triggered this permission request
3068    #[serde(skip_serializing_if = "Option::is_none")]
3069    pub tool_call_id: Option<String>,
3070}
3071
3072/// Custom tool invocation permission request
3073#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3074#[serde(rename_all = "camelCase")]
3075pub struct PermissionRequestCustomTool {
3076    /// Arguments to pass to the custom tool
3077    #[serde(skip_serializing_if = "Option::is_none")]
3078    pub args: Option<serde_json::Value>,
3079    /// Permission kind discriminator
3080    pub kind: PermissionRequestCustomToolKind,
3081    /// Tool call ID that triggered this permission request
3082    #[serde(skip_serializing_if = "Option::is_none")]
3083    pub tool_call_id: Option<String>,
3084    /// Description of what the custom tool does
3085    pub tool_description: String,
3086    /// Name of the custom tool
3087    pub tool_name: String,
3088}
3089
3090/// Hook confirmation permission request
3091#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3092#[serde(rename_all = "camelCase")]
3093pub struct PermissionRequestHook {
3094    /// Optional message from the hook explaining why confirmation is needed
3095    #[serde(skip_serializing_if = "Option::is_none")]
3096    pub hook_message: Option<String>,
3097    /// Permission kind discriminator
3098    pub kind: PermissionRequestHookKind,
3099    /// Arguments of the tool call being gated
3100    #[serde(skip_serializing_if = "Option::is_none")]
3101    pub tool_args: Option<serde_json::Value>,
3102    /// Tool call ID that triggered this permission request
3103    #[serde(skip_serializing_if = "Option::is_none")]
3104    pub tool_call_id: Option<String>,
3105    /// Name of the tool the hook is gating
3106    pub tool_name: String,
3107}
3108
3109/// Extension management permission request
3110#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3111#[serde(rename_all = "camelCase")]
3112pub struct PermissionRequestExtensionManagement {
3113    /// Name of the extension being managed
3114    #[serde(skip_serializing_if = "Option::is_none")]
3115    pub extension_name: Option<String>,
3116    /// Permission kind discriminator
3117    pub kind: PermissionRequestExtensionManagementKind,
3118    /// The extension management operation (scaffold, reload)
3119    pub operation: String,
3120    /// Tool call ID that triggered this permission request
3121    #[serde(skip_serializing_if = "Option::is_none")]
3122    pub tool_call_id: Option<String>,
3123}
3124
3125/// Extension permission access request
3126#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3127#[serde(rename_all = "camelCase")]
3128pub struct PermissionRequestExtensionPermissionAccess {
3129    /// Capabilities the extension is requesting
3130    pub capabilities: Vec<String>,
3131    /// Name of the extension requesting permission access
3132    pub extension_name: String,
3133    /// Permission kind discriminator
3134    pub kind: PermissionRequestExtensionPermissionAccessKind,
3135    /// Tool call ID that triggered this permission request
3136    #[serde(skip_serializing_if = "Option::is_none")]
3137    pub tool_call_id: Option<String>,
3138}
3139
3140/// Auto-approval judge information attached to a permission request. Present (non-null) only when the session's allow-all mode is "auto"; its absence means auto mode was off and the judge did not evaluate the request. The `recommendation` conveys the judge's disposition for this request.
3141///
3142/// <div class="warning">
3143///
3144/// **Experimental.** This type is part of an experimental wire-protocol surface
3145/// and may change or be removed in future SDK or CLI releases.
3146///
3147/// </div>
3148#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3149#[serde(rename_all = "camelCase")]
3150pub struct PermissionAutoApproval {
3151    /// Human-readable reason for the judge's recommendation, when available.
3152    #[serde(skip_serializing_if = "Option::is_none")]
3153    pub reason: Option<String>,
3154    /// The auto-approval safety judge's outcome for this request.
3155    pub recommendation: AutoApprovalRecommendation,
3156}
3157
3158/// Shell command permission prompt
3159#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3160#[serde(rename_all = "camelCase")]
3161pub struct PermissionPromptRequestCommands {
3162    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3163    ///
3164    /// <div class="warning">
3165    ///
3166    /// **Experimental.** This type is part of an experimental wire-protocol surface
3167    /// and may change or be removed in future SDK or CLI releases.
3168    ///
3169    /// </div>
3170    #[serde(skip_serializing_if = "Option::is_none")]
3171    pub auto_approval: Option<PermissionAutoApproval>,
3172    /// Whether the UI can offer session-wide approval for this command pattern
3173    pub can_offer_session_approval: bool,
3174    /// Command identifiers covered by this approval prompt
3175    pub command_identifiers: Vec<String>,
3176    /// The complete shell command text to be executed
3177    pub full_command_text: String,
3178    /// Human-readable description of what the command intends to do
3179    pub intention: String,
3180    /// Prompt kind discriminator
3181    pub kind: PermissionPromptRequestCommandsKind,
3182    /// Tool call ID that triggered this permission request
3183    #[serde(skip_serializing_if = "Option::is_none")]
3184    pub tool_call_id: Option<String>,
3185    /// Optional warning message about risks of running this command
3186    #[serde(skip_serializing_if = "Option::is_none")]
3187    pub warning: Option<String>,
3188}
3189
3190/// File write permission prompt
3191#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3192#[serde(rename_all = "camelCase")]
3193pub struct PermissionPromptRequestWrite {
3194    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3195    ///
3196    /// <div class="warning">
3197    ///
3198    /// **Experimental.** This type is part of an experimental wire-protocol surface
3199    /// and may change or be removed in future SDK or CLI releases.
3200    ///
3201    /// </div>
3202    #[serde(skip_serializing_if = "Option::is_none")]
3203    pub auto_approval: Option<PermissionAutoApproval>,
3204    /// Whether the UI can offer session-wide approval for file write operations
3205    pub can_offer_session_approval: bool,
3206    /// Unified diff showing the proposed changes
3207    pub diff: String,
3208    /// Path of the file being written to
3209    pub file_name: String,
3210    /// Human-readable description of the intended file change
3211    pub intention: String,
3212    /// Prompt kind discriminator
3213    pub kind: PermissionPromptRequestWriteKind,
3214    /// Complete new file contents for newly created files
3215    #[serde(skip_serializing_if = "Option::is_none")]
3216    pub new_file_contents: Option<String>,
3217    /// Tool call ID that triggered this permission request
3218    #[serde(skip_serializing_if = "Option::is_none")]
3219    pub tool_call_id: Option<String>,
3220}
3221
3222/// File read permission prompt
3223#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3224#[serde(rename_all = "camelCase")]
3225pub struct PermissionPromptRequestRead {
3226    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3227    ///
3228    /// <div class="warning">
3229    ///
3230    /// **Experimental.** This type is part of an experimental wire-protocol surface
3231    /// and may change or be removed in future SDK or CLI releases.
3232    ///
3233    /// </div>
3234    #[serde(skip_serializing_if = "Option::is_none")]
3235    pub auto_approval: Option<PermissionAutoApproval>,
3236    /// Human-readable description of why the file is being read
3237    pub intention: String,
3238    /// Prompt kind discriminator
3239    pub kind: PermissionPromptRequestReadKind,
3240    /// Path of the file or directory being read
3241    pub path: String,
3242    /// Tool call ID that triggered this permission request
3243    #[serde(skip_serializing_if = "Option::is_none")]
3244    pub tool_call_id: Option<String>,
3245}
3246
3247/// MCP tool invocation permission prompt
3248#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3249#[serde(rename_all = "camelCase")]
3250pub struct PermissionPromptRequestMcp {
3251    /// Arguments to pass to the MCP tool
3252    #[serde(skip_serializing_if = "Option::is_none")]
3253    pub args: Option<serde_json::Value>,
3254    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3255    ///
3256    /// <div class="warning">
3257    ///
3258    /// **Experimental.** This type is part of an experimental wire-protocol surface
3259    /// and may change or be removed in future SDK or CLI releases.
3260    ///
3261    /// </div>
3262    #[serde(skip_serializing_if = "Option::is_none")]
3263    pub auto_approval: Option<PermissionAutoApproval>,
3264    /// Prompt kind discriminator
3265    pub kind: PermissionPromptRequestMcpKind,
3266    /// Name of the MCP server providing the tool
3267    pub server_name: String,
3268    /// Tool call ID that triggered this permission request
3269    #[serde(skip_serializing_if = "Option::is_none")]
3270    pub tool_call_id: Option<String>,
3271    /// Internal name of the MCP tool
3272    pub tool_name: String,
3273    /// Human-readable title of the MCP tool
3274    pub tool_title: String,
3275}
3276
3277/// URL access permission prompt
3278#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3279#[serde(rename_all = "camelCase")]
3280pub struct PermissionPromptRequestUrl {
3281    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3282    ///
3283    /// <div class="warning">
3284    ///
3285    /// **Experimental.** This type is part of an experimental wire-protocol surface
3286    /// and may change or be removed in future SDK or CLI releases.
3287    ///
3288    /// </div>
3289    #[serde(skip_serializing_if = "Option::is_none")]
3290    pub auto_approval: Option<PermissionAutoApproval>,
3291    /// Human-readable description of why the URL is being accessed
3292    pub intention: String,
3293    /// Prompt kind discriminator
3294    pub kind: PermissionPromptRequestUrlKind,
3295    /// True when this URL fetch is requesting to bypass the sandbox network policy: either the model set requestSandboxBypass: true, or the tool re-issued the request as an interactive bypass after the network policy denied the approved URL (host opted in via sandbox.allowBypass). 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.
3296    #[serde(skip_serializing_if = "Option::is_none")]
3297    pub request_sandbox_bypass: Option<bool>,
3298    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3299    #[serde(skip_serializing_if = "Option::is_none")]
3300    pub request_sandbox_bypass_reason: Option<String>,
3301    /// Tool call ID that triggered this permission request
3302    #[serde(skip_serializing_if = "Option::is_none")]
3303    pub tool_call_id: Option<String>,
3304    /// URL to be fetched
3305    pub url: String,
3306}
3307
3308/// Memory operation permission prompt
3309#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3310#[serde(rename_all = "camelCase")]
3311pub struct PermissionPromptRequestMemory {
3312    /// Whether this is a store or vote memory operation
3313    #[serde(skip_serializing_if = "Option::is_none")]
3314    pub action: Option<PermissionRequestMemoryAction>,
3315    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3316    ///
3317    /// <div class="warning">
3318    ///
3319    /// **Experimental.** This type is part of an experimental wire-protocol surface
3320    /// and may change or be removed in future SDK or CLI releases.
3321    ///
3322    /// </div>
3323    #[serde(skip_serializing_if = "Option::is_none")]
3324    pub auto_approval: Option<PermissionAutoApproval>,
3325    /// Source references for the stored fact (store only)
3326    #[serde(skip_serializing_if = "Option::is_none")]
3327    pub citations: Option<String>,
3328    /// Vote direction (vote only)
3329    #[serde(skip_serializing_if = "Option::is_none")]
3330    pub direction: Option<PermissionRequestMemoryDirection>,
3331    /// The fact being stored or voted on
3332    pub fact: String,
3333    /// Prompt kind discriminator
3334    pub kind: PermissionPromptRequestMemoryKind,
3335    /// Reason for the vote (vote only)
3336    #[serde(skip_serializing_if = "Option::is_none")]
3337    pub reason: Option<String>,
3338    /// Topic or subject of the memory (store only)
3339    #[serde(skip_serializing_if = "Option::is_none")]
3340    pub subject: Option<String>,
3341    /// Tool call ID that triggered this permission request
3342    #[serde(skip_serializing_if = "Option::is_none")]
3343    pub tool_call_id: Option<String>,
3344}
3345
3346/// Custom tool invocation permission prompt
3347#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3348#[serde(rename_all = "camelCase")]
3349pub struct PermissionPromptRequestCustomTool {
3350    /// Arguments to pass to the custom tool
3351    #[serde(skip_serializing_if = "Option::is_none")]
3352    pub args: Option<serde_json::Value>,
3353    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3354    ///
3355    /// <div class="warning">
3356    ///
3357    /// **Experimental.** This type is part of an experimental wire-protocol surface
3358    /// and may change or be removed in future SDK or CLI releases.
3359    ///
3360    /// </div>
3361    #[serde(skip_serializing_if = "Option::is_none")]
3362    pub auto_approval: Option<PermissionAutoApproval>,
3363    /// Prompt kind discriminator
3364    pub kind: PermissionPromptRequestCustomToolKind,
3365    /// Tool call ID that triggered this permission request
3366    #[serde(skip_serializing_if = "Option::is_none")]
3367    pub tool_call_id: Option<String>,
3368    /// Description of what the custom tool does
3369    pub tool_description: String,
3370    /// Name of the custom tool
3371    pub tool_name: String,
3372}
3373
3374/// Path access permission prompt
3375#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3376#[serde(rename_all = "camelCase")]
3377pub struct PermissionPromptRequestPath {
3378    /// Underlying permission kind that needs path approval
3379    pub access_kind: PermissionPromptRequestPathAccessKind,
3380    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3381    ///
3382    /// <div class="warning">
3383    ///
3384    /// **Experimental.** This type is part of an experimental wire-protocol surface
3385    /// and may change or be removed in future SDK or CLI releases.
3386    ///
3387    /// </div>
3388    #[serde(skip_serializing_if = "Option::is_none")]
3389    pub auto_approval: Option<PermissionAutoApproval>,
3390    /// Prompt kind discriminator
3391    pub kind: PermissionPromptRequestPathKind,
3392    /// File paths that require explicit approval
3393    pub paths: Vec<String>,
3394    /// Tool call ID that triggered this permission request
3395    #[serde(skip_serializing_if = "Option::is_none")]
3396    pub tool_call_id: Option<String>,
3397}
3398
3399/// Hook confirmation permission prompt
3400#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3401#[serde(rename_all = "camelCase")]
3402pub struct PermissionPromptRequestHook {
3403    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3404    ///
3405    /// <div class="warning">
3406    ///
3407    /// **Experimental.** This type is part of an experimental wire-protocol surface
3408    /// and may change or be removed in future SDK or CLI releases.
3409    ///
3410    /// </div>
3411    #[serde(skip_serializing_if = "Option::is_none")]
3412    pub auto_approval: Option<PermissionAutoApproval>,
3413    /// Optional message from the hook explaining why confirmation is needed
3414    #[serde(skip_serializing_if = "Option::is_none")]
3415    pub hook_message: Option<String>,
3416    /// Prompt kind discriminator
3417    pub kind: PermissionPromptRequestHookKind,
3418    /// Arguments of the tool call being gated
3419    #[serde(skip_serializing_if = "Option::is_none")]
3420    pub tool_args: Option<serde_json::Value>,
3421    /// Tool call ID that triggered this permission request
3422    #[serde(skip_serializing_if = "Option::is_none")]
3423    pub tool_call_id: Option<String>,
3424    /// Name of the tool the hook is gating
3425    pub tool_name: String,
3426}
3427
3428/// Extension management permission prompt
3429#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3430#[serde(rename_all = "camelCase")]
3431pub struct PermissionPromptRequestExtensionManagement {
3432    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3433    ///
3434    /// <div class="warning">
3435    ///
3436    /// **Experimental.** This type is part of an experimental wire-protocol surface
3437    /// and may change or be removed in future SDK or CLI releases.
3438    ///
3439    /// </div>
3440    #[serde(skip_serializing_if = "Option::is_none")]
3441    pub auto_approval: Option<PermissionAutoApproval>,
3442    /// Name of the extension being managed
3443    #[serde(skip_serializing_if = "Option::is_none")]
3444    pub extension_name: Option<String>,
3445    /// Prompt kind discriminator
3446    pub kind: PermissionPromptRequestExtensionManagementKind,
3447    /// The extension management operation (scaffold, reload)
3448    pub operation: String,
3449    /// Tool call ID that triggered this permission request
3450    #[serde(skip_serializing_if = "Option::is_none")]
3451    pub tool_call_id: Option<String>,
3452}
3453
3454/// Extension permission access prompt
3455#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3456#[serde(rename_all = "camelCase")]
3457pub struct PermissionPromptRequestExtensionPermissionAccess {
3458    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3459    ///
3460    /// <div class="warning">
3461    ///
3462    /// **Experimental.** This type is part of an experimental wire-protocol surface
3463    /// and may change or be removed in future SDK or CLI releases.
3464    ///
3465    /// </div>
3466    #[serde(skip_serializing_if = "Option::is_none")]
3467    pub auto_approval: Option<PermissionAutoApproval>,
3468    /// Capabilities the extension is requesting
3469    pub capabilities: Vec<String>,
3470    /// Name of the extension requesting permission access
3471    pub extension_name: String,
3472    /// Prompt kind discriminator
3473    pub kind: PermissionPromptRequestExtensionPermissionAccessKind,
3474    /// Tool call ID that triggered this permission request
3475    #[serde(skip_serializing_if = "Option::is_none")]
3476    pub tool_call_id: Option<String>,
3477}
3478
3479/// Session event "permission.requested". Permission request notification requiring client approval with request details
3480#[derive(Debug, Clone, Serialize, Deserialize)]
3481#[serde(rename_all = "camelCase")]
3482pub struct PermissionRequestedData {
3483    /// Details of the permission being requested
3484    pub permission_request: PermissionRequest,
3485    /// Derived user-facing permission prompt details for UI consumers
3486    #[serde(skip_serializing_if = "Option::is_none")]
3487    pub prompt_request: Option<PermissionPromptRequest>,
3488    /// Unique identifier for this permission request; used to respond via session.respondToPermission()
3489    pub request_id: RequestId,
3490    /// When true, this permission was already resolved by a permissionRequest hook and requires no client action
3491    #[serde(skip_serializing_if = "Option::is_none")]
3492    pub resolved_by_hook: Option<bool>,
3493}
3494
3495/// Permission response variant indicating the request was approved without persisting an approval rule.
3496#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3497#[serde(rename_all = "camelCase")]
3498pub struct PermissionApproved {
3499    /// The permission request was approved
3500    pub kind: PermissionApprovedKind,
3501}
3502
3503/// Session-scoped tool-approval rule for specific shell command identifiers.
3504#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3505#[serde(rename_all = "camelCase")]
3506pub struct UserToolSessionApprovalCommands {
3507    /// Command identifiers approved by the user
3508    pub command_identifiers: Vec<String>,
3509    /// Command approval kind
3510    pub kind: UserToolSessionApprovalCommandsKind,
3511}
3512
3513/// Session-scoped tool-approval rule for read-only filesystem operations.
3514#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3515#[serde(rename_all = "camelCase")]
3516pub struct UserToolSessionApprovalRead {
3517    /// Read approval kind
3518    pub kind: UserToolSessionApprovalReadKind,
3519}
3520
3521/// Session-scoped tool-approval rule for filesystem write operations.
3522#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3523#[serde(rename_all = "camelCase")]
3524pub struct UserToolSessionApprovalWrite {
3525    /// Write approval kind
3526    pub kind: UserToolSessionApprovalWriteKind,
3527}
3528
3529/// Session-scoped tool-approval rule for an MCP server tool, or all tools on the server when `toolName` is null.
3530#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3531#[serde(rename_all = "camelCase")]
3532pub struct UserToolSessionApprovalMcp {
3533    /// MCP tool approval kind
3534    pub kind: UserToolSessionApprovalMcpKind,
3535    /// MCP server name
3536    pub server_name: String,
3537    /// Optional MCP tool name, or null for all tools on the server
3538    pub tool_name: Option<String>,
3539}
3540
3541/// Session-scoped tool-approval rule for writes to long-term memory.
3542#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3543#[serde(rename_all = "camelCase")]
3544pub struct UserToolSessionApprovalMemory {
3545    /// Memory approval kind
3546    pub kind: UserToolSessionApprovalMemoryKind,
3547}
3548
3549/// Session-scoped tool-approval rule for a custom tool, keyed by tool name.
3550#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3551#[serde(rename_all = "camelCase")]
3552pub struct UserToolSessionApprovalCustomTool {
3553    /// Custom tool approval kind
3554    pub kind: UserToolSessionApprovalCustomToolKind,
3555    /// Custom tool name
3556    pub tool_name: String,
3557}
3558
3559/// Session-scoped tool-approval rule for extension-management operations, optionally narrowed by operation.
3560#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3561#[serde(rename_all = "camelCase")]
3562pub struct UserToolSessionApprovalExtensionManagement {
3563    /// Extension management approval kind
3564    pub kind: UserToolSessionApprovalExtensionManagementKind,
3565    /// Optional operation identifier
3566    #[serde(skip_serializing_if = "Option::is_none")]
3567    pub operation: Option<String>,
3568}
3569
3570/// Session-scoped tool-approval rule for an extension's permission-gated capability access, keyed by extension name.
3571#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3572#[serde(rename_all = "camelCase")]
3573pub struct UserToolSessionApprovalExtensionPermissionAccess {
3574    /// Extension name
3575    pub extension_name: String,
3576    /// Extension permission access approval kind
3577    pub kind: UserToolSessionApprovalExtensionPermissionAccessKind,
3578}
3579
3580/// Permission response variant that approves a request and remembers the provided approval for the rest of the session.
3581#[derive(Debug, Clone, Serialize, Deserialize)]
3582#[serde(rename_all = "camelCase")]
3583pub struct PermissionApprovedForSession {
3584    /// The approval to add as a session-scoped rule
3585    pub approval: UserToolSessionApproval,
3586    /// Approved and remembered for the rest of the session
3587    pub kind: PermissionApprovedForSessionKind,
3588}
3589
3590/// Permission response variant that approves a request and persists the provided approval to a project location key.
3591#[derive(Debug, Clone, Serialize, Deserialize)]
3592#[serde(rename_all = "camelCase")]
3593pub struct PermissionApprovedForLocation {
3594    /// The approval to persist for this location
3595    pub approval: UserToolSessionApproval,
3596    /// Approved and persisted for this project location
3597    pub kind: PermissionApprovedForLocationKind,
3598    /// The location key (git root or cwd) to persist the approval to
3599    pub location_key: String,
3600}
3601
3602/// Permission response variant indicating the request was cancelled before use, with an optional reason.
3603#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3604#[serde(rename_all = "camelCase")]
3605pub struct PermissionCancelled {
3606    /// The permission request was cancelled before a response was used
3607    pub kind: PermissionCancelledKind,
3608    /// Optional explanation of why the request was cancelled
3609    #[serde(skip_serializing_if = "Option::is_none")]
3610    pub reason: Option<String>,
3611}
3612
3613/// A permission approval or denial rule matched against a tool request, identified by a rule kind with an optional argument value.
3614#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3615#[serde(rename_all = "camelCase")]
3616pub struct PermissionRule {
3617    /// Argument value matched against the request, or null when the rule kind has no argument (e.g. 'read', 'write', 'memory').
3618    pub argument: Option<String>,
3619    /// The rule kind, such as Shell or GitHubMCP
3620    pub kind: String,
3621}
3622
3623/// Permission response variant denied because matching approval rules explicitly blocked the request.
3624#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3625#[serde(rename_all = "camelCase")]
3626pub struct PermissionDeniedByRules {
3627    /// Denied because approval rules explicitly blocked it
3628    pub kind: PermissionDeniedByRulesKind,
3629    /// Rules that denied the request
3630    pub rules: Vec<PermissionRule>,
3631}
3632
3633/// Permission response variant denied because no approval rule matched and user confirmation was unavailable.
3634#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3635#[serde(rename_all = "camelCase")]
3636pub struct PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
3637    /// Denied because no approval rule matched and user confirmation was unavailable
3638    pub kind: PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind,
3639}
3640
3641/// Permission response variant denied in an interactive user prompt, with optional feedback and force-reject flag.
3642#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3643#[serde(rename_all = "camelCase")]
3644pub struct PermissionDeniedInteractivelyByUser {
3645    /// Optional feedback from the user explaining the denial
3646    #[serde(skip_serializing_if = "Option::is_none")]
3647    pub feedback: Option<String>,
3648    /// Whether to force-reject the current agent turn
3649    #[serde(skip_serializing_if = "Option::is_none")]
3650    pub force_reject: Option<bool>,
3651    /// Denied by the user during an interactive prompt
3652    pub kind: PermissionDeniedInteractivelyByUserKind,
3653}
3654
3655/// Permission response variant denying a path under content exclusion policy, with the path and message.
3656#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3657#[serde(rename_all = "camelCase")]
3658pub struct PermissionDeniedByContentExclusionPolicy {
3659    /// Denied by the organization's content exclusion policy
3660    pub kind: PermissionDeniedByContentExclusionPolicyKind,
3661    /// Human-readable explanation of why the path was excluded
3662    pub message: String,
3663    /// File path that triggered the exclusion
3664    pub path: String,
3665}
3666
3667/// Permission response variant denied by a permission-request hook, with optional message and interrupt flag.
3668#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3669#[serde(rename_all = "camelCase")]
3670pub struct PermissionDeniedByPermissionRequestHook {
3671    /// Whether to interrupt the current agent turn
3672    #[serde(skip_serializing_if = "Option::is_none")]
3673    pub interrupt: Option<bool>,
3674    /// Denied by a permission request hook registered by an extension or plugin
3675    pub kind: PermissionDeniedByPermissionRequestHookKind,
3676    /// Optional message from the hook explaining the denial
3677    #[serde(skip_serializing_if = "Option::is_none")]
3678    pub message: Option<String>,
3679}
3680
3681/// Session event "permission.completed". Permission request completion notification signaling UI dismissal
3682#[derive(Debug, Clone, Serialize, Deserialize)]
3683#[serde(rename_all = "camelCase")]
3684pub struct PermissionCompletedData {
3685    /// Request ID of the resolved permission request; clients should dismiss any UI for this request
3686    pub request_id: RequestId,
3687    /// The result of the permission request
3688    pub result: PermissionResult,
3689    /// Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
3690    #[serde(skip_serializing_if = "Option::is_none")]
3691    pub tool_call_id: Option<String>,
3692}
3693
3694/// Session event "user_input.requested". User input request notification with question and optional predefined choices
3695#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3696#[serde(rename_all = "camelCase")]
3697pub struct UserInputRequestedData {
3698    /// Whether the user can provide a free-form text response in addition to predefined choices
3699    #[serde(skip_serializing_if = "Option::is_none")]
3700    pub allow_freeform: Option<bool>,
3701    /// Predefined choices for the user to select from, if applicable
3702    #[serde(skip_serializing_if = "Option::is_none")]
3703    pub choices: Option<Vec<String>>,
3704    /// The question or prompt to present to the user
3705    pub question: String,
3706    /// Unique identifier for this input request; used to respond via session.respondToUserInput()
3707    pub request_id: RequestId,
3708    /// The LLM-assigned tool call ID that triggered this request; used by remote UIs to correlate responses
3709    #[serde(skip_serializing_if = "Option::is_none")]
3710    pub tool_call_id: Option<String>,
3711}
3712
3713/// Session event "user_input.completed". User input request completion with the user's response
3714#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3715#[serde(rename_all = "camelCase")]
3716pub struct UserInputCompletedData {
3717    /// The user's answer to the input request
3718    #[serde(skip_serializing_if = "Option::is_none")]
3719    pub answer: Option<String>,
3720    /// Request ID of the resolved user input request; clients should dismiss any UI for this request
3721    pub request_id: RequestId,
3722    /// Whether the answer was typed as free-form text rather than selected from choices
3723    #[serde(skip_serializing_if = "Option::is_none")]
3724    pub was_freeform: Option<bool>,
3725}
3726
3727/// JSON Schema describing the form fields to present to the user (form mode only)
3728#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3729#[serde(rename_all = "camelCase")]
3730pub struct ElicitationRequestedSchema {
3731    /// Form field definitions, keyed by field name
3732    pub properties: HashMap<String, serde_json::Value>,
3733    /// List of required field names
3734    #[serde(skip_serializing_if = "Option::is_none")]
3735    pub required: Option<Vec<String>>,
3736    /// Schema type indicator (always 'object')
3737    pub r#type: ElicitationRequestedSchemaType,
3738}
3739
3740/// Session event "elicitation.requested". Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
3741#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3742#[serde(rename_all = "camelCase")]
3743pub struct ElicitationRequestedData {
3744    /// The source that initiated the request (MCP server name, or absent for agent-initiated)
3745    #[serde(skip_serializing_if = "Option::is_none")]
3746    pub elicitation_source: Option<String>,
3747    /// Message describing what information is needed from the user
3748    pub message: String,
3749    /// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
3750    #[serde(skip_serializing_if = "Option::is_none")]
3751    pub mode: Option<ElicitationRequestedMode>,
3752    /// JSON Schema describing the form fields to present to the user (form mode only)
3753    #[serde(skip_serializing_if = "Option::is_none")]
3754    pub requested_schema: Option<ElicitationRequestedSchema>,
3755    /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation()
3756    pub request_id: RequestId,
3757    /// Tool call ID from the LLM completion; used to correlate with CompletionChunk.toolCall.id for remote UIs
3758    #[serde(skip_serializing_if = "Option::is_none")]
3759    pub tool_call_id: Option<String>,
3760    /// URL to open in the user's browser (url mode only)
3761    #[serde(skip_serializing_if = "Option::is_none")]
3762    pub url: Option<String>,
3763}
3764
3765/// Session event "elicitation.completed". Elicitation request completion with the user's response
3766#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3767#[serde(rename_all = "camelCase")]
3768pub struct ElicitationCompletedData {
3769    /// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
3770    #[serde(skip_serializing_if = "Option::is_none")]
3771    pub action: Option<ElicitationCompletedAction>,
3772    /// The submitted form data when action is 'accept'; keys match the requested schema fields
3773    #[serde(skip_serializing_if = "Option::is_none")]
3774    pub content: Option<HashMap<String, serde_json::Value>>,
3775    /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request
3776    pub request_id: RequestId,
3777}
3778
3779/// Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
3780#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3781#[serde(rename_all = "camelCase")]
3782pub struct SamplingRequestedData {
3783    /// The JSON-RPC request ID from the MCP protocol
3784    pub mcp_request_id: serde_json::Value,
3785    /// Unique identifier for this sampling request; used to respond via session.respondToSampling()
3786    pub request_id: RequestId,
3787    /// Name of the MCP server that initiated the sampling request
3788    pub server_name: String,
3789}
3790
3791/// Session event "sampling.completed". Sampling request completion notification signaling UI dismissal
3792#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3793#[serde(rename_all = "camelCase")]
3794pub struct SamplingCompletedData {
3795    /// Request ID of the resolved sampling request; clients should dismiss any UI for this request
3796    pub request_id: RequestId,
3797}
3798
3799/// Single HTTP header entry as a name/value pair.
3800#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3801#[serde(rename_all = "camelCase")]
3802pub struct HeaderEntry {
3803    /// HTTP response header name as observed by the runtime.
3804    pub name: String,
3805    /// HTTP response header value as observed by the runtime.
3806    pub value: String,
3807}
3808
3809/// Raw HTTP response details from the OAuth auth challenge, as observed by the runtime.
3810#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3811#[serde(rename_all = "camelCase")]
3812pub struct McpOauthHttpResponse {
3813    /// 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.
3814    #[serde(skip_serializing_if = "Option::is_none")]
3815    pub body: Option<String>,
3816    /// HTTP response headers as observed by the runtime. Order and casing are transport-dependent, and duplicate header names may appear multiple times.
3817    pub headers: Vec<HeaderEntry>,
3818    /// HTTP status code returned with the auth challenge.
3819    pub status_code: i32,
3820}
3821
3822/// Static OAuth client configuration, if the server specifies one
3823#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3824#[serde(rename_all = "camelCase")]
3825pub struct McpOauthRequiredStaticClientConfig {
3826    /// OAuth client ID for the server
3827    pub client_id: String,
3828    /// Optional OAuth client secret for confidential static clients, when the runtime can resolve one
3829    #[serde(skip_serializing_if = "Option::is_none")]
3830    pub client_secret: Option<String>,
3831    /// 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).
3832    #[serde(skip_serializing_if = "Option::is_none")]
3833    pub grant_type: Option<McpOauthRequiredStaticClientConfigGrantType>,
3834    /// Whether this is a public OAuth client
3835    #[serde(skip_serializing_if = "Option::is_none")]
3836    pub public_client: Option<bool>,
3837}
3838
3839/// OAuth WWW-Authenticate parameters parsed from an MCP auth challenge
3840#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3841#[serde(rename_all = "camelCase")]
3842pub struct McpOauthWWWAuthenticateParams {
3843    /// OAuth error from the WWW-Authenticate error parameter, if present
3844    #[serde(skip_serializing_if = "Option::is_none")]
3845    pub error: Option<String>,
3846    /// Protected resource metadata URL from the WWW-Authenticate resource_metadata parameter, if present
3847    #[serde(skip_serializing_if = "Option::is_none")]
3848    pub resource_metadata_url: Option<String>,
3849    /// Requested OAuth scopes from the WWW-Authenticate scope parameter, if present
3850    #[serde(skip_serializing_if = "Option::is_none")]
3851    pub scope: Option<String>,
3852}
3853
3854/// Session event "mcp.oauth_required". OAuth authentication request for an MCP server
3855#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3856#[serde(rename_all = "camelCase")]
3857pub struct McpOauthRequiredData {
3858    /// 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.
3859    #[serde(skip_serializing_if = "Option::is_none")]
3860    pub http_response: Option<McpOauthHttpResponse>,
3861    /// Why the runtime is requesting host-provided OAuth credentials.
3862    pub reason: McpOauthRequestReason,
3863    /// Unique identifier for this OAuth request; used to respond via session.mcp.oauth.handlePendingRequest
3864    pub request_id: RequestId,
3865    /// Raw OAuth protected-resource metadata document fetched for the MCP server, if available
3866    #[serde(skip_serializing_if = "Option::is_none")]
3867    pub resource_metadata: Option<String>,
3868    /// Display name of the MCP server that requires OAuth
3869    pub server_name: String,
3870    /// URL of the MCP server that requires OAuth
3871    pub server_url: String,
3872    /// Static OAuth client configuration, if the server specifies one
3873    #[serde(skip_serializing_if = "Option::is_none")]
3874    pub static_client_config: Option<McpOauthRequiredStaticClientConfig>,
3875    /// OAuth WWW-Authenticate parameters parsed from the auth challenge, if available
3876    #[serde(skip_serializing_if = "Option::is_none")]
3877    pub www_authenticate_params: Option<McpOauthWWWAuthenticateParams>,
3878}
3879
3880/// Session event "mcp.oauth_completed". MCP OAuth request completion notification
3881#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3882#[serde(rename_all = "camelCase")]
3883pub struct McpOauthCompletedData {
3884    /// How the pending OAuth request was completed
3885    pub outcome: McpOauthCompletionOutcome,
3886    /// Request ID of the resolved OAuth request
3887    pub request_id: RequestId,
3888}
3889
3890/// Session event "mcp.headers_refresh_required". Dynamic headers refresh request for a remote MCP server
3891#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3892#[serde(rename_all = "camelCase")]
3893pub struct McpHeadersRefreshRequiredData {
3894    /// Why dynamic headers are being requested.
3895    pub reason: McpHeadersRefreshRequiredReason,
3896    /// Unique identifier for this headers refresh request; used to respond via session.mcp.headers.handlePendingHeadersRefreshRequest()
3897    pub request_id: RequestId,
3898    /// Display name of the remote MCP server requesting headers
3899    pub server_name: String,
3900    /// URL of the remote MCP server requesting headers
3901    pub server_url: String,
3902}
3903
3904/// Session event "mcp.headers_refresh_completed". MCP headers refresh request completion notification
3905#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3906#[serde(rename_all = "camelCase")]
3907pub struct McpHeadersRefreshCompletedData {
3908    /// How the pending MCP headers refresh request resolved.
3909    pub outcome: McpHeadersRefreshCompletedOutcome,
3910    /// Request ID of the resolved headers refresh request
3911    pub request_id: RequestId,
3912}
3913
3914/// Session event "session.custom_notification". Opaque custom notification data. Consumers may branch on source and name, but payload semantics are source-defined.
3915#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3916#[serde(rename_all = "camelCase")]
3917pub struct SessionCustomNotificationData {
3918    /// Source-defined custom notification name
3919    pub name: String,
3920    /// Source-defined JSON payload for the custom notification
3921    pub payload: serde_json::Value,
3922    /// Namespace for the custom notification producer
3923    pub source: String,
3924    /// Optional source-defined string identifiers describing the payload subject
3925    #[serde(skip_serializing_if = "Option::is_none")]
3926    pub subject: Option<HashMap<String, String>>,
3927    /// Optional source-defined payload schema version
3928    #[serde(skip_serializing_if = "Option::is_none")]
3929    pub version: Option<i64>,
3930}
3931
3932/// Session event "external_tool.requested". External tool invocation request for client-side tool execution
3933#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3934#[serde(rename_all = "camelCase")]
3935pub struct ExternalToolRequestedData {
3936    /// Arguments to pass to the external tool
3937    #[serde(skip_serializing_if = "Option::is_none")]
3938    pub arguments: Option<serde_json::Value>,
3939    /// Unique identifier for this request; used to respond via session.respondToExternalTool()
3940    pub request_id: RequestId,
3941    /// Session ID that this external tool request belongs to
3942    pub session_id: SessionId,
3943    /// Tool call ID assigned to this external tool invocation
3944    pub tool_call_id: String,
3945    /// Name of the external tool to invoke
3946    pub tool_name: String,
3947    /// W3C Trace Context traceparent header for the execute_tool span
3948    #[serde(skip_serializing_if = "Option::is_none")]
3949    pub traceparent: Option<String>,
3950    /// W3C Trace Context tracestate header for the execute_tool span
3951    #[serde(skip_serializing_if = "Option::is_none")]
3952    pub tracestate: Option<String>,
3953    /// Active session working directory, when known.
3954    #[serde(skip_serializing_if = "Option::is_none")]
3955    pub working_directory: Option<String>,
3956}
3957
3958/// Session event "external_tool.completed". External tool completion notification signaling UI dismissal
3959#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3960#[serde(rename_all = "camelCase")]
3961pub struct ExternalToolCompletedData {
3962    /// Request ID of the resolved external tool request; clients should dismiss any UI for this request
3963    pub request_id: RequestId,
3964}
3965
3966/// Session event "command.queued". Queued slash command dispatch request for client execution
3967#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3968#[serde(rename_all = "camelCase")]
3969pub struct CommandQueuedData {
3970    /// The slash command text to be executed (e.g., /help, /clear)
3971    pub command: String,
3972    /// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
3973    pub request_id: RequestId,
3974}
3975
3976/// Session event "command.execute". Registered command dispatch request routed to the owning client
3977#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3978#[serde(rename_all = "camelCase")]
3979pub struct CommandExecuteData {
3980    /// Raw argument string after the command name
3981    pub args: String,
3982    /// The full command text (e.g., /deploy production)
3983    pub command: String,
3984    /// Command name without leading /
3985    pub command_name: String,
3986    /// Unique identifier; used to respond via session.commands.handlePendingCommand()
3987    pub request_id: RequestId,
3988}
3989
3990/// Session event "command.completed". Queued command completion notification signaling UI dismissal
3991#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3992#[serde(rename_all = "camelCase")]
3993pub struct CommandCompletedData {
3994    /// Request ID of the resolved command request; clients should dismiss any UI for this request
3995    pub request_id: RequestId,
3996}
3997
3998/// Session event "auto_mode_switch.requested". Auto mode switch request notification requiring user approval
3999#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4000#[serde(rename_all = "camelCase")]
4001pub struct AutoModeSwitchRequestedData {
4002    /// The rate limit error code that triggered this request
4003    #[serde(skip_serializing_if = "Option::is_none")]
4004    pub error_code: Option<String>,
4005    /// Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
4006    pub request_id: RequestId,
4007    /// Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
4008    #[serde(skip_serializing_if = "Option::is_none")]
4009    pub retry_after_seconds: Option<i64>,
4010}
4011
4012/// Session event "auto_mode_switch.completed". Auto mode switch completion notification
4013#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4014#[serde(rename_all = "camelCase")]
4015pub struct AutoModeSwitchCompletedData {
4016    /// Request ID of the resolved request; clients should dismiss any UI for this request
4017    pub request_id: RequestId,
4018    /// The user's auto-mode-switch choice
4019    pub response: AutoModeSwitchResponse,
4020}
4021
4022/// Session event "session_limits_exhausted.requested". Session limit exhaustion notification requiring user action.
4023#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4024#[serde(rename_all = "camelCase")]
4025pub struct SessionLimitsExhaustedRequestedData {
4026    /// Configured max AI Credits for the current accounting window.
4027    pub max_ai_credits: f64,
4028    /// Unique identifier for this request; used to respond via session.ui.handlePendingSessionLimitsExhausted().
4029    pub request_id: RequestId,
4030    /// AI Credits already consumed in the current accounting window.
4031    pub used_ai_credits: f64,
4032}
4033
4034/// The user's selected action for an exhausted session limit.
4035#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4036#[serde(rename_all = "camelCase")]
4037pub struct SessionLimitsExhaustedResponse {
4038    /// Action selected by the user.
4039    pub action: SessionLimitsExhaustedResponseAction,
4040    /// AI Credits to add to the current max when action is 'add'.
4041    #[serde(skip_serializing_if = "Option::is_none")]
4042    pub additional_ai_credits: Option<f64>,
4043    /// New absolute max AI Credits when action is 'set'.
4044    #[serde(skip_serializing_if = "Option::is_none")]
4045    pub max_ai_credits: Option<f64>,
4046}
4047
4048/// Session event "session_limits_exhausted.completed". Session limit exhaustion prompt completion notification.
4049#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4050#[serde(rename_all = "camelCase")]
4051pub struct SessionLimitsExhaustedCompletedData {
4052    /// Request ID of the resolved request; clients should dismiss any UI for this request.
4053    pub request_id: RequestId,
4054    /// The user's selected session-limit action.
4055    pub response: SessionLimitsExhaustedResponse,
4056}
4057
4058/// 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.
4059///
4060/// <div class="warning">
4061///
4062/// **Experimental.** This type is part of an experimental wire-protocol surface
4063/// and may change or be removed in future SDK or CLI releases.
4064///
4065/// </div>
4066#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4067#[serde(rename_all = "camelCase")]
4068pub struct SessionAutoModeResolvedData {
4069    /// Ordered candidate model list the router returned, when not a fallback
4070    #[serde(skip_serializing_if = "Option::is_none")]
4071    pub candidate_models: Option<Vec<String>>,
4072    /// 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.
4073    #[serde(skip_serializing_if = "Option::is_none")]
4074    pub category_scores: Option<HashMap<String, f64>>,
4075    /// The concrete model the session will use after any intent refinement
4076    pub chosen_model: String,
4077    /// Classifier confidence for the predicted label, when available
4078    #[serde(skip_serializing_if = "Option::is_none")]
4079    pub confidence: Option<f64>,
4080    /// The predicted classifier label (e.g. `needs_reasoning`), when available
4081    #[serde(skip_serializing_if = "Option::is_none")]
4082    pub predicted_label: Option<String>,
4083    /// Coarse request-difficulty bucket, for explaining why a model was chosen ("picked X because this looks like high-reasoning work")
4084    #[serde(skip_serializing_if = "Option::is_none")]
4085    pub reasoning_bucket: Option<AutoModeResolvedReasoningBucket>,
4086}
4087
4088/// Session event "session.managed_settings_resolved". Enterprise managed-settings resolution: the effective managed settings the session applied and where they came from, so SDK clients can show users what is enterprise-managed and by which authority. 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; for a session-independent pull, use the SDK `getManagedSettings()` API, which returns the identical payload. Managed settings have a single authoritative source, so the highest-authority present layer (server > device) wins wholesale; `bypassPermissionsDisabled` is deny-wins across layers. Marked experimental while the managed-settings surface stabilizes.
4089///
4090/// <div class="warning">
4091///
4092/// **Experimental.** This type is part of an experimental wire-protocol surface
4093/// and may change or be removed in future SDK or CLI releases.
4094///
4095/// </div>
4096#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4097#[serde(rename_all = "camelCase")]
4098pub struct SessionManagedSettingsResolvedData {
4099    /// Whether enterprise policy disables bypass-permissions ("yolo") mode for this session. Deny-wins across layers, and forced on when `failClosed` is true.
4100    pub bypass_permissions_disabled: bool,
4101    /// Whether the device (MDM/plist/registry/file) managed-settings layer was present
4102    pub device_managed: bool,
4103    /// 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.
4104    pub fail_closed: bool,
4105    /// The setting keys under enterprise management in the effective managed settings (e.g. `model`, `enabledPlugins`, `permissions`). Empty when no managed settings are in force.
4106    pub managed_keys: Vec<String>,
4107    /// Whether the server (account/org) managed-settings layer was present
4108    pub server_managed: bool,
4109    /// The effective (resolved) managed settings values, so clients can render exactly what is enforced. Absent when no managed policy is in force.
4110    #[serde(skip_serializing_if = "Option::is_none")]
4111    pub settings: Option<serde_json::Value>,
4112    /// Which channel supplied the effective managed settings (the winning layer), or `none` when no policy is in force
4113    pub source: ManagedSettingsResolvedSource,
4114}
4115
4116/// 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.
4117///
4118/// <div class="warning">
4119///
4120/// **Experimental.** This type is part of an experimental wire-protocol surface
4121/// and may change or be removed in future SDK or CLI releases.
4122///
4123/// </div>
4124#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4125#[serde(rename_all = "camelCase")]
4126pub struct SessionManagedSettingsEnforcedData {
4127    /// The category of runtime action that managed policy governed.
4128    pub action: ManagedSettingsEnforcedAction,
4129    /// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused. Absent for actions without a specific escalation primitive.
4130    #[serde(skip_serializing_if = "Option::is_none")]
4131    pub escalation: Option<ManagedSettingsEnforcedEscalation>,
4132    /// 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.
4133    pub fail_closed: bool,
4134    /// A human-readable explanation of why the action was governed, suitable for surfacing to the user.
4135    pub message: String,
4136    /// The managed setting key responsible for the enforcement (e.g. `permissions.disableBypassPermissionsMode`).
4137    pub setting: String,
4138}
4139
4140/// A single slash command available in the session, as listed by the `commands.changed` event.
4141#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4142#[serde(rename_all = "camelCase")]
4143pub struct CommandsChangedCommand {
4144    /// Optional human-readable command description.
4145    #[serde(skip_serializing_if = "Option::is_none")]
4146    pub description: Option<String>,
4147    /// Slash command name without the leading slash.
4148    pub name: String,
4149}
4150
4151/// Session event "commands.changed". SDK command registration change notification
4152#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4153#[serde(rename_all = "camelCase")]
4154pub struct CommandsChangedData {
4155    /// Current list of registered SDK commands
4156    pub commands: Vec<CommandsChangedCommand>,
4157}
4158
4159/// UI capability changes
4160#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4161#[serde(rename_all = "camelCase")]
4162pub struct CapabilitiesChangedUI {
4163    /// Whether canvas rendering is now supported
4164    #[serde(skip_serializing_if = "Option::is_none")]
4165    pub canvases: Option<bool>,
4166    /// Whether elicitation is now supported
4167    #[serde(skip_serializing_if = "Option::is_none")]
4168    pub elicitation: Option<bool>,
4169    /// Whether MCP Apps (SEP-1865) UI passthrough is now supported
4170    #[serde(skip_serializing_if = "Option::is_none")]
4171    pub mcp_apps: Option<bool>,
4172}
4173
4174/// Session event "capabilities.changed". Session capability change notification
4175#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4176#[serde(rename_all = "camelCase")]
4177pub struct CapabilitiesChangedData {
4178    /// UI capability changes
4179    #[serde(skip_serializing_if = "Option::is_none")]
4180    pub ui: Option<CapabilitiesChangedUI>,
4181}
4182
4183/// Session event "exit_plan_mode.requested". Plan approval request with plan content and available user actions
4184#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4185#[serde(rename_all = "camelCase")]
4186pub struct ExitPlanModeRequestedData {
4187    /// Available actions the user can take
4188    pub actions: Vec<ExitPlanModeAction>,
4189    /// Full content of the plan file
4190    pub plan_content: String,
4191    /// Recommended action to preselect for the user
4192    pub recommended_action: ExitPlanModeAction,
4193    /// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
4194    pub request_id: RequestId,
4195    /// Summary of the plan that was created
4196    pub summary: String,
4197}
4198
4199/// Session event "exit_plan_mode.completed". Plan mode exit completion with the user's approval decision and optional feedback
4200#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4201#[serde(rename_all = "camelCase")]
4202pub struct ExitPlanModeCompletedData {
4203    /// Whether the plan was approved by the user
4204    #[serde(skip_serializing_if = "Option::is_none")]
4205    pub approved: Option<bool>,
4206    /// Whether edits should be auto-approved without confirmation
4207    #[serde(skip_serializing_if = "Option::is_none")]
4208    pub auto_approve_edits: Option<bool>,
4209    /// Free-form feedback from the user if they requested changes to the plan
4210    #[serde(skip_serializing_if = "Option::is_none")]
4211    pub feedback: Option<String>,
4212    /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
4213    pub request_id: RequestId,
4214    /// Action selected by the user
4215    #[serde(skip_serializing_if = "Option::is_none")]
4216    pub selected_action: Option<ExitPlanModeAction>,
4217}
4218
4219/// Session event "session.tools_updated". Payload of `session.tools_updated` identifying the model whose resolved tools were updated.
4220#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4221#[serde(rename_all = "camelCase")]
4222pub struct SessionToolsUpdatedData {
4223    /// Identifier of the model the resolved tools apply to.
4224    pub model: String,
4225}
4226
4227/// Session event "session.background_tasks_changed". Empty payload for `session.background_tasks_changed`, indicating background task state changed.
4228#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4229#[serde(rename_all = "camelCase")]
4230pub struct SessionBackgroundTasksChangedData {}
4231
4232/// A single resolved skill in `session.skills_loaded`, including source, invocability, enabled state, path, and argument hint.
4233#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4234#[serde(rename_all = "camelCase")]
4235pub struct SkillsLoadedSkill {
4236    /// Optional freeform hint describing the skill's expected arguments, from the `argument-hint` frontmatter field
4237    #[serde(skip_serializing_if = "Option::is_none")]
4238    pub argument_hint: Option<String>,
4239    /// Description of what the skill does
4240    pub description: String,
4241    /// Whether the skill is currently enabled
4242    pub enabled: bool,
4243    /// Unique identifier for the skill
4244    pub name: String,
4245    /// Absolute path to the skill file, if available
4246    #[serde(skip_serializing_if = "Option::is_none")]
4247    pub path: Option<String>,
4248    /// Source location type (e.g., project, personal-copilot, plugin, builtin)
4249    pub source: SkillSource,
4250    /// Whether the skill can be invoked by the user as a slash command
4251    pub user_invocable: bool,
4252}
4253
4254/// Session event "session.skills_loaded". Payload of `session.skills_loaded` listing resolved skill metadata.
4255#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4256#[serde(rename_all = "camelCase")]
4257pub struct SessionSkillsLoadedData {
4258    /// Array of resolved skill metadata
4259    pub skills: Vec<SkillsLoadedSkill>,
4260}
4261
4262/// A single loaded custom agent in `session.custom_agents_updated`, with identity, source, tools, invocability, and model override.
4263#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4264#[serde(rename_all = "camelCase")]
4265pub struct CustomAgentsUpdatedAgent {
4266    /// Description of what the agent does
4267    pub description: String,
4268    /// Human-readable display name
4269    pub display_name: String,
4270    /// Unique identifier for the agent
4271    pub id: String,
4272    /// Model override for this agent, if set
4273    #[serde(skip_serializing_if = "Option::is_none")]
4274    pub model: Option<String>,
4275    /// Internal name of the agent
4276    pub name: String,
4277    /// Source location: user, project, inherited, remote, or plugin
4278    pub source: String,
4279    /// List of tool names available to this agent, or null when all tools are available
4280    pub tools: Option<Vec<String>>,
4281    /// Whether the agent can be selected by the user
4282    pub user_invocable: bool,
4283}
4284
4285/// Session event "session.custom_agents_updated". Payload of `session.custom_agents_updated` with loaded custom agents plus non-fatal warnings and fatal errors.
4286#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4287#[serde(rename_all = "camelCase")]
4288pub struct SessionCustomAgentsUpdatedData {
4289    /// Array of loaded custom agent metadata
4290    pub agents: Vec<CustomAgentsUpdatedAgent>,
4291    /// Fatal errors from agent loading
4292    pub errors: Vec<String>,
4293    /// Non-fatal warnings from agent loading
4294    pub warnings: Vec<String>,
4295}
4296
4297/// A single MCP server status summary in `session.mcp_servers_loaded`, including name, status, source, transport, and plugin metadata.
4298#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4299#[serde(rename_all = "camelCase")]
4300pub struct McpServersLoadedServer {
4301    /// Error message if the server failed to connect
4302    #[serde(skip_serializing_if = "Option::is_none")]
4303    pub error: Option<String>,
4304    /// Server name (config key)
4305    pub name: String,
4306    /// Name of the plugin that supplied the effective MCP server config, only when source is plugin
4307    #[serde(skip_serializing_if = "Option::is_none")]
4308    pub plugin_name: Option<String>,
4309    /// Version of the plugin that supplied the effective MCP server config, only when source is plugin
4310    #[serde(skip_serializing_if = "Option::is_none")]
4311    pub plugin_version: Option<String>,
4312    /// Configuration source: user, workspace, plugin, or builtin
4313    #[serde(skip_serializing_if = "Option::is_none")]
4314    pub source: Option<McpServerSource>,
4315    /// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
4316    pub status: McpServerStatus,
4317    /// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
4318    #[serde(skip_serializing_if = "Option::is_none")]
4319    pub transport: Option<McpServerTransport>,
4320}
4321
4322/// Session event "session.mcp_servers_loaded". Payload of `session.mcp_servers_loaded` listing MCP server status summaries.
4323#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4324#[serde(rename_all = "camelCase")]
4325pub struct SessionMcpServersLoadedData {
4326    /// Array of MCP server status summaries
4327    pub servers: Vec<McpServersLoadedServer>,
4328}
4329
4330/// Session event "session.mcp_server_status_changed". Payload of `session.mcp_server_status_changed` for one MCP server's status and optional failure error.
4331#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4332#[serde(rename_all = "camelCase")]
4333pub struct SessionMcpServerStatusChangedData {
4334    /// Error message if the server entered a failed state
4335    #[serde(skip_serializing_if = "Option::is_none")]
4336    pub error: Option<String>,
4337    /// Name of the MCP server whose status changed
4338    pub server_name: String,
4339    /// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
4340    pub status: McpServerStatus,
4341}
4342
4343/// Session event "mcp.tools.list_changed". Payload identifying the MCP server associated with a list change.
4344#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4345#[serde(rename_all = "camelCase")]
4346pub struct McpToolsListChangedData {
4347    /// Name of the MCP server whose list changed
4348    pub server_name: String,
4349}
4350
4351/// Session event "mcp.resources.list_changed". Payload identifying the MCP server associated with a list change.
4352#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4353#[serde(rename_all = "camelCase")]
4354pub struct McpResourcesListChangedData {
4355    /// Name of the MCP server whose list changed
4356    pub server_name: String,
4357}
4358
4359/// Session event "mcp.prompts.list_changed". Payload identifying the MCP server associated with a list change.
4360#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4361#[serde(rename_all = "camelCase")]
4362pub struct McpPromptsListChangedData {
4363    /// Name of the MCP server whose list changed
4364    pub server_name: String,
4365}
4366
4367/// A single extension discovered by `session.extensions_loaded`, including qualified ID, source, and current status.
4368#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4369#[serde(rename_all = "camelCase")]
4370pub struct ExtensionsLoadedExtension {
4371    /// Source-qualified extension ID (e.g., 'project:my-ext', 'user:auth-helper', 'plugin:my-plugin:my-ext')
4372    pub id: String,
4373    /// Extension name (directory name)
4374    pub name: String,
4375    /// Discovery source
4376    pub source: ExtensionsLoadedExtensionSource,
4377    /// Current status: running, disabled, failed, or starting
4378    pub status: ExtensionsLoadedExtensionStatus,
4379}
4380
4381/// Session event "session.extensions_loaded". Payload of `session.extensions_loaded` listing discovered extensions and their statuses.
4382#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4383#[serde(rename_all = "camelCase")]
4384pub struct SessionExtensionsLoadedData {
4385    /// Array of discovered extensions and their status
4386    pub extensions: Vec<ExtensionsLoadedExtension>,
4387}
4388
4389/// Session event "session.canvas.opened". Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional icon, title, status, URL, and input.
4390///
4391/// <div class="warning">
4392///
4393/// **Experimental.** This type is part of an experimental wire-protocol surface
4394/// and may change or be removed in future SDK or CLI releases.
4395///
4396/// </div>
4397#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4398#[serde(rename_all = "camelCase")]
4399pub struct SessionCanvasOpenedData {
4400    /// Provider-local canvas identifier
4401    pub canvas_id: String,
4402    /// Owning provider identifier
4403    pub extension_id: String,
4404    /// Owning extension display name, when available
4405    #[serde(skip_serializing_if = "Option::is_none")]
4406    pub extension_name: Option<String>,
4407    /// Host-local PNG path for the canvas icon, when supplied
4408    #[serde(skip_serializing_if = "Option::is_none")]
4409    pub icon: Option<String>,
4410    /// Input supplied when the instance was opened
4411    #[serde(skip_serializing_if = "Option::is_none")]
4412    pub input: Option<serde_json::Value>,
4413    /// Stable caller-supplied canvas instance identifier
4414    pub instance_id: String,
4415    /// Provider-supplied status text
4416    #[serde(skip_serializing_if = "Option::is_none")]
4417    pub status: Option<String>,
4418    /// Rendered title
4419    #[serde(skip_serializing_if = "Option::is_none")]
4420    pub title: Option<String>,
4421    /// URL for web-rendered canvases
4422    #[serde(skip_serializing_if = "Option::is_none")]
4423    pub url: Option<String>,
4424}
4425
4426/// A single action within a canvas declaration, with its name, optional description, and optional input schema.
4427///
4428/// <div class="warning">
4429///
4430/// **Experimental.** This type is part of an experimental wire-protocol surface
4431/// and may change or be removed in future SDK or CLI releases.
4432///
4433/// </div>
4434#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4435#[serde(rename_all = "camelCase")]
4436pub struct CanvasRegistryChangedCanvasAction {
4437    /// Action description
4438    #[serde(skip_serializing_if = "Option::is_none")]
4439    pub description: Option<String>,
4440    /// JSON Schema for action input
4441    #[serde(skip_serializing_if = "Option::is_none")]
4442    pub input_schema: Option<serde_json::Value>,
4443    /// Action name
4444    pub name: String,
4445}
4446
4447/// A single canvas declaration in `session.canvas.registry_changed`, including provider IDs, display metadata, input schema, and actions.
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#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4456#[serde(rename_all = "camelCase")]
4457pub struct CanvasRegistryChangedCanvas {
4458    /// Actions the agent or host may invoke
4459    #[serde(skip_serializing_if = "Option::is_none")]
4460    pub actions: Option<Vec<CanvasRegistryChangedCanvasAction>>,
4461    /// Provider-local canvas identifier
4462    pub canvas_id: String,
4463    /// Short, single-sentence description shown to the agent in canvas catalogs.
4464    pub description: String,
4465    /// Human-readable canvas name
4466    pub display_name: String,
4467    /// Owning provider identifier
4468    pub extension_id: String,
4469    /// Owning extension display name, when available
4470    #[serde(skip_serializing_if = "Option::is_none")]
4471    pub extension_name: Option<String>,
4472    /// Host-local PNG path for the canvas icon, when supplied
4473    #[serde(skip_serializing_if = "Option::is_none")]
4474    pub icon: Option<String>,
4475    /// JSON Schema for canvas open input
4476    #[serde(skip_serializing_if = "Option::is_none")]
4477    pub input_schema: Option<serde_json::Value>,
4478}
4479
4480/// Session event "session.canvas.registry_changed". Payload of `session.canvas.registry_changed` listing the canvas declarations currently available.
4481///
4482/// <div class="warning">
4483///
4484/// **Experimental.** This type is part of an experimental wire-protocol surface
4485/// and may change or be removed in future SDK or CLI releases.
4486///
4487/// </div>
4488#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4489#[serde(rename_all = "camelCase")]
4490pub struct SessionCanvasRegistryChangedData {
4491    /// Canvas declarations currently available
4492    pub canvases: Vec<CanvasRegistryChangedCanvas>,
4493}
4494
4495/// Session event "session.canvas.closed". Payload of `session.canvas.closed` with the closed canvas instance ID, provider ID, and canvas ID.
4496///
4497/// <div class="warning">
4498///
4499/// **Experimental.** This type is part of an experimental wire-protocol surface
4500/// and may change or be removed in future SDK or CLI releases.
4501///
4502/// </div>
4503#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4504#[serde(rename_all = "camelCase")]
4505pub struct SessionCanvasClosedData {
4506    /// Provider-local canvas identifier
4507    pub canvas_id: String,
4508    /// Owning provider identifier
4509    pub extension_id: String,
4510    /// Stable caller-supplied identifier of the canvas instance that was closed
4511    pub instance_id: String,
4512}
4513
4514/// 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.
4515///
4516/// <div class="warning">
4517///
4518/// **Experimental.** This type is part of an experimental wire-protocol surface
4519/// and may change or be removed in future SDK or CLI releases.
4520///
4521/// </div>
4522#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4523#[serde(rename_all = "camelCase")]
4524pub struct SessionCanvasUnavailableData {
4525    /// Provider-local canvas identifier
4526    pub canvas_id: String,
4527    /// Owning provider identifier
4528    pub extension_id: String,
4529    /// Stable caller-supplied identifier of the canvas instance whose provider became unavailable
4530    pub instance_id: String,
4531}
4532
4533/// 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.
4534///
4535/// <div class="warning">
4536///
4537/// **Experimental.** This type is part of an experimental wire-protocol surface
4538/// and may change or be removed in future SDK or CLI releases.
4539///
4540/// </div>
4541#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4542#[serde(rename_all = "camelCase")]
4543pub struct SessionCanvasRecordedData {
4544    /// Provider-local canvas identifier
4545    pub canvas_id: String,
4546    /// Owning provider identifier
4547    pub extension_id: String,
4548    /// Input supplied when the instance was opened
4549    #[serde(skip_serializing_if = "Option::is_none")]
4550    pub input: Option<serde_json::Value>,
4551    /// Stable caller-supplied canvas instance identifier
4552    pub instance_id: String,
4553    /// Rendered title
4554    #[serde(skip_serializing_if = "Option::is_none")]
4555    pub title: Option<String>,
4556}
4557
4558/// Session event "session.canvas.removed". Durable record that a canvas instance was closed, superseding a prior instance_recorded during resume replay.
4559///
4560/// <div class="warning">
4561///
4562/// **Experimental.** This type is part of an experimental wire-protocol surface
4563/// and may change or be removed in future SDK or CLI releases.
4564///
4565/// </div>
4566#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4567#[serde(rename_all = "camelCase")]
4568pub struct SessionCanvasRemovedData {
4569    /// Provider-local canvas identifier
4570    pub canvas_id: String,
4571    /// Owning provider identifier
4572    pub extension_id: String,
4573    /// Stable caller-supplied identifier of the canvas instance that was closed
4574    pub instance_id: String,
4575}
4576
4577/// Session event "session.extensions.attachments_pushed". Payload of `session.extensions.attachments_pushed` with extension-contributed attachments for the next send.
4578#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4579#[serde(rename_all = "camelCase")]
4580pub struct SessionExtensionsAttachmentsPushedData {
4581    /// Attachments contributed by an extension; the host should surface these as composer pills and forward them via the next session.send call.
4582    pub attachments: Vec<serde_json::Value>,
4583}
4584
4585/// Set when the underlying tools/call threw an error before returning a CallToolResult
4586#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4587#[serde(rename_all = "camelCase")]
4588pub struct McpAppToolCallCompleteError {
4589    /// Human-readable error message
4590    pub message: String,
4591}
4592
4593/// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
4594#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4595#[serde(rename_all = "camelCase")]
4596pub struct McpAppToolCallCompleteToolMetaUI {
4597    /// `ui://` URI declared by the tool's `_meta.ui.resourceUri`
4598    #[serde(skip_serializing_if = "Option::is_none")]
4599    pub resource_uri: Option<String>,
4600    /// Tool visibility per SEP-1865 (typically a subset of `["model","app"]`)
4601    #[serde(skip_serializing_if = "Option::is_none")]
4602    pub visibility: Option<Vec<String>>,
4603}
4604
4605/// 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.
4606#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4607#[serde(rename_all = "camelCase")]
4608pub struct McpAppToolCallCompleteToolMeta {
4609    /// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
4610    #[serde(skip_serializing_if = "Option::is_none")]
4611    pub ui: Option<McpAppToolCallCompleteToolMetaUI>,
4612}
4613
4614/// Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
4615#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4616#[serde(rename_all = "camelCase")]
4617pub struct McpAppToolCallCompleteData {
4618    /// Arguments passed to the tool by the app view, if any
4619    #[serde(skip_serializing_if = "Option::is_none")]
4620    pub arguments: Option<HashMap<String, serde_json::Value>>,
4621    /// Wall-clock duration of the underlying tools/call in milliseconds
4622    pub duration_ms: f64,
4623    /// Set when the underlying tools/call threw an error before returning a CallToolResult
4624    #[serde(skip_serializing_if = "Option::is_none")]
4625    pub error: Option<McpAppToolCallCompleteError>,
4626    /// Standard MCP CallToolResult returned by the server. Present whether or not the call set isError.
4627    #[serde(skip_serializing_if = "Option::is_none")]
4628    pub result: Option<HashMap<String, serde_json::Value>>,
4629    /// Name of the MCP server hosting the tool
4630    pub server_name: String,
4631    /// True when the call completed without throwing AND the MCP CallToolResult did not set isError
4632    pub success: bool,
4633    /// 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.
4634    #[serde(skip_serializing_if = "Option::is_none")]
4635    pub tool_meta: Option<McpAppToolCallCompleteToolMeta>,
4636    /// MCP tool name that was invoked
4637    pub tool_name: String,
4638}
4639
4640/// Hosting platform type of the repository (github or ado)
4641#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4642pub enum WorkingDirectoryContextHostType {
4643    /// Repository is hosted on GitHub.
4644    #[serde(rename = "github")]
4645    GitHub,
4646    /// Repository is hosted on Azure DevOps.
4647    #[serde(rename = "ado")]
4648    Ado,
4649    /// Unknown variant for forward compatibility.
4650    #[default]
4651    #[serde(other)]
4652    Unknown,
4653}
4654
4655/// Allowed values for the `ContextTier` enumeration.
4656#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4657pub enum ContextTier {
4658    /// Default context tier with standard context window size.
4659    #[serde(rename = "default")]
4660    Default,
4661    /// Extended context tier with a larger context window.
4662    #[serde(rename = "long_context")]
4663    LongContext,
4664    /// Unknown variant for forward compatibility.
4665    #[default]
4666    #[serde(other)]
4667    Unknown,
4668}
4669
4670/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
4671#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4672pub enum ReasoningSummary {
4673    /// Do not request reasoning summaries from the model.
4674    #[serde(rename = "none")]
4675    None,
4676    /// Request a concise summary of the model's reasoning.
4677    #[serde(rename = "concise")]
4678    Concise,
4679    /// Request a detailed summary of the model's reasoning.
4680    #[serde(rename = "detailed")]
4681    Detailed,
4682    /// Unknown variant for forward compatibility.
4683    #[default]
4684    #[serde(other)]
4685    Unknown,
4686}
4687
4688/// Output verbosity level used for supported model calls (e.g. "low", "medium", "high")
4689#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4690pub enum Verbosity {
4691    /// A terse response was requested.
4692    #[serde(rename = "low")]
4693    Low,
4694    /// A medium amount of response detail was requested.
4695    #[serde(rename = "medium")]
4696    Medium,
4697    /// A more detailed response was requested.
4698    #[serde(rename = "high")]
4699    High,
4700    /// Unknown variant for forward compatibility.
4701    #[default]
4702    #[serde(other)]
4703    Unknown,
4704}
4705
4706/// The type of operation performed on the autopilot objective state file
4707#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4708pub enum AutopilotObjectiveChangedOperation {
4709    /// Autopilot objective state file was created for a new objective.
4710    #[serde(rename = "create")]
4711    Create,
4712    /// Autopilot objective state file was updated for an existing objective.
4713    #[serde(rename = "update")]
4714    Update,
4715    /// Autopilot objective state file was deleted or cleared.
4716    #[serde(rename = "delete")]
4717    Delete,
4718    /// Unknown variant for forward compatibility.
4719    #[default]
4720    #[serde(other)]
4721    Unknown,
4722}
4723
4724/// Current autopilot objective status, if one exists
4725#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4726pub enum AutopilotObjectiveChangedStatus {
4727    /// Objective is active and can drive autopilot continuations.
4728    #[serde(rename = "active")]
4729    Active,
4730    /// Objective is paused and will not drive autopilot continuations.
4731    #[serde(rename = "paused")]
4732    Paused,
4733    /// Legacy objective state indicating the previous continuation cap was reached.
4734    #[serde(rename = "cap_reached")]
4735    CapReached,
4736    /// Objective was completed by the agent.
4737    #[serde(rename = "completed")]
4738    Completed,
4739    /// Unknown variant for forward compatibility.
4740    #[default]
4741    #[serde(other)]
4742    Unknown,
4743}
4744
4745/// The session mode the agent is operating in
4746#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4747pub enum SessionMode {
4748    /// The agent is responding interactively to the user.
4749    #[serde(rename = "interactive")]
4750    Interactive,
4751    /// The agent is preparing a plan before making changes.
4752    #[serde(rename = "plan")]
4753    Plan,
4754    /// The agent is working autonomously toward task completion.
4755    #[serde(rename = "autopilot")]
4756    Autopilot,
4757    /// Unknown variant for forward compatibility.
4758    #[default]
4759    #[serde(other)]
4760    Unknown,
4761}
4762
4763/// Allow-all mode for the session.
4764///
4765/// <div class="warning">
4766///
4767/// **Experimental.** This type is part of an experimental wire-protocol surface
4768/// and may change or be removed in future SDK or CLI releases.
4769///
4770/// </div>
4771#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4772pub enum PermissionAllowAllMode {
4773    /// Permission requests follow the normal approval flow.
4774    #[serde(rename = "off")]
4775    Off,
4776    /// Tool, path, and URL permission requests are automatically approved.
4777    #[serde(rename = "on")]
4778    On,
4779    /// Permission requests follow the normal approval flow with an LLM advisory recommendation attached; clients may choose to auto-approve requests the judge evaluated as acceptable.
4780    #[serde(rename = "auto")]
4781    Auto,
4782    /// Unknown variant for forward compatibility.
4783    #[default]
4784    #[serde(other)]
4785    Unknown,
4786}
4787
4788/// The type of operation performed on the plan file
4789#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4790pub enum PlanChangedOperation {
4791    /// The plan file was created.
4792    #[serde(rename = "create")]
4793    Create,
4794    /// The plan file was updated.
4795    #[serde(rename = "update")]
4796    Update,
4797    /// The plan file was deleted.
4798    #[serde(rename = "delete")]
4799    Delete,
4800    /// Unknown variant for forward compatibility.
4801    #[default]
4802    #[serde(other)]
4803    Unknown,
4804}
4805
4806/// Whether the file was newly created or updated
4807#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4808pub enum WorkspaceFileChangedOperation {
4809    /// The workspace file was created.
4810    #[serde(rename = "create")]
4811    Create,
4812    /// The workspace file was updated.
4813    #[serde(rename = "update")]
4814    Update,
4815    /// Unknown variant for forward compatibility.
4816    #[default]
4817    #[serde(other)]
4818    Unknown,
4819}
4820
4821/// Origin type of the session being handed off
4822#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4823pub enum HandoffSourceType {
4824    /// The handoff originated from a remote session.
4825    #[serde(rename = "remote")]
4826    Remote,
4827    /// The handoff originated from a local session.
4828    #[serde(rename = "local")]
4829    Local,
4830    /// Unknown variant for forward compatibility.
4831    #[default]
4832    #[serde(other)]
4833    Unknown,
4834}
4835
4836/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
4837#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4838pub enum ShutdownType {
4839    /// The session ended normally.
4840    #[serde(rename = "routine")]
4841    Routine,
4842    /// The session ended because of a crash or fatal error.
4843    #[serde(rename = "error")]
4844    Error,
4845    /// Unknown variant for forward compatibility.
4846    #[default]
4847    #[serde(other)]
4848    Unknown,
4849}
4850
4851/// The agent mode that was active when this message was sent
4852#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4853pub enum UserMessageAgentMode {
4854    /// The agent is responding interactively to the user.
4855    #[serde(rename = "interactive")]
4856    Interactive,
4857    /// The agent is preparing a plan before making changes.
4858    #[serde(rename = "plan")]
4859    Plan,
4860    /// The agent is working autonomously toward task completion.
4861    #[serde(rename = "autopilot")]
4862    Autopilot,
4863    /// The agent is in shell-focused UI mode.
4864    #[serde(rename = "shell")]
4865    Shell,
4866    /// Unknown variant for forward compatibility.
4867    #[default]
4868    #[serde(other)]
4869    Unknown,
4870}
4871
4872/// 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.
4873#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4874pub enum UserMessageDelivery {
4875    /// Delivered while the loop was idle; starts its own run immediately (a human's fresh turn, or a system notification waking an idle agent).
4876    #[serde(rename = "idle")]
4877    Idle,
4878    /// Injected into the current in-flight run while the agent was busy (immediate mode).
4879    #[serde(rename = "steering")]
4880    Steering,
4881    /// Enqueued while the agent was busy; processed as its own run afterward.
4882    #[serde(rename = "queued")]
4883    Queued,
4884    /// Unknown variant for forward compatibility.
4885    #[default]
4886    #[serde(other)]
4887    Unknown,
4888}
4889
4890/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
4891#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4892pub enum AssistantMessageToolRequestType {
4893    /// Standard function-style tool call.
4894    #[serde(rename = "function")]
4895    Function,
4896    /// Custom grammar-based tool call.
4897    #[serde(rename = "custom")]
4898    Custom,
4899    /// Unknown variant for forward compatibility.
4900    #[default]
4901    #[serde(other)]
4902    Unknown,
4903}
4904
4905/// The system that produced a citation.
4906///
4907/// <div class="warning">
4908///
4909/// **Experimental.** This type is part of an experimental wire-protocol surface
4910/// and may change or be removed in future SDK or CLI releases.
4911///
4912/// </div>
4913#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4914pub enum CitationProvider {
4915    /// Citation produced by an Anthropic (Claude) model response.
4916    #[serde(rename = "anthropic")]
4917    Anthropic,
4918    /// Citation produced by an OpenAI model response.
4919    #[serde(rename = "openai")]
4920    Openai,
4921    /// Citation synthesized client-side by the runtime from tool output.
4922    #[serde(rename = "client")]
4923    Client,
4924    /// Unknown variant for forward compatibility.
4925    #[default]
4926    #[serde(other)]
4927    Unknown,
4928}
4929
4930/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
4931#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4932pub enum AssistantUsageApiEndpoint {
4933    /// Chat Completions API endpoint.
4934    #[serde(rename = "/chat/completions")]
4935    ChatCompletions,
4936    /// Anthropic Messages API endpoint.
4937    #[serde(rename = "/v1/messages")]
4938    V1Messages,
4939    /// Responses API endpoint.
4940    #[serde(rename = "/responses")]
4941    Responses,
4942    /// WebSocket Responses API endpoint.
4943    #[serde(rename = "ws:/responses")]
4944    WsResponses,
4945    /// Unknown variant for forward compatibility.
4946    #[default]
4947    #[serde(other)]
4948    Unknown,
4949}
4950
4951/// 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.
4952#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4953pub enum ModelCallFailureBadRequestKind {
4954    /// The 400 response carried no error body (transient gateway/proxy signature).
4955    #[serde(rename = "bodyless")]
4956    Bodyless,
4957    /// The 400 response carried a structured CAPI error envelope (deterministic validation failure).
4958    #[serde(rename = "structured_error")]
4959    StructuredError,
4960    /// Unknown variant for forward compatibility.
4961    #[default]
4962    #[serde(other)]
4963    Unknown,
4964}
4965
4966/// Boundary that produced a model call failure
4967#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4968pub enum ModelCallFailureKind {
4969    /// The provider returned an API error response.
4970    #[serde(rename = "api")]
4971    Api,
4972    /// The request transport failed before a usable API response completed.
4973    #[serde(rename = "transport")]
4974    Transport,
4975    /// Unknown variant for forward compatibility.
4976    #[default]
4977    #[serde(other)]
4978    Unknown,
4979}
4980
4981/// Where the failed model call originated
4982#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
4983pub enum ModelCallFailureSource {
4984    /// Model call from the top-level agent.
4985    #[serde(rename = "top_level")]
4986    TopLevel,
4987    /// Model call from a sub-agent.
4988    #[serde(rename = "subagent")]
4989    Subagent,
4990    /// Model call from MCP sampling.
4991    #[serde(rename = "mcp_sampling")]
4992    McpSampling,
4993    /// Unknown variant for forward compatibility.
4994    #[default]
4995    #[serde(other)]
4996    Unknown,
4997}
4998
4999/// Transport used for a failed model call
5000#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5001pub enum ModelCallFailureTransport {
5002    /// HTTP transport, including SSE streams.
5003    #[serde(rename = "http")]
5004    Http,
5005    /// WebSocket transport.
5006    #[serde(rename = "websocket")]
5007    Websocket,
5008    /// Unknown variant for forward compatibility.
5009    #[default]
5010    #[serde(other)]
5011    Unknown,
5012}
5013
5014/// Finite reason code describing why the current turn was aborted
5015#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5016pub enum AbortReason {
5017    /// The local user requested the abort, for example by pressing Ctrl+C in the CLI.
5018    #[serde(rename = "user_initiated")]
5019    UserInitiated,
5020    /// A remote command requested the abort.
5021    #[serde(rename = "remote_command")]
5022    RemoteCommand,
5023    /// An MCP server delivered a user.abort notification.
5024    #[serde(rename = "user_abort")]
5025    UserAbort,
5026    /// Unknown variant for forward compatibility.
5027    #[default]
5028    #[serde(other)]
5029    Unknown,
5030}
5031
5032/// Allowed values for the `ToolExecutionStartToolDescriptionMetaUIVisibility` enumeration.
5033#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5034pub enum ToolExecutionStartToolDescriptionMetaUIVisibility {
5035    /// Tool is callable by the model (LLM tool surface)
5036    #[serde(rename = "model")]
5037    Model,
5038    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
5039    #[serde(rename = "app")]
5040    App,
5041    /// Unknown variant for forward compatibility.
5042    #[default]
5043    #[serde(other)]
5044    Unknown,
5045}
5046
5047/// Content block type discriminator
5048#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5049pub enum ToolExecutionCompleteContentTextType {
5050    #[serde(rename = "text")]
5051    #[default]
5052    Text,
5053}
5054
5055/// Content block type discriminator
5056#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5057pub enum ToolExecutionCompleteContentTerminalType {
5058    #[serde(rename = "terminal")]
5059    #[default]
5060    Terminal,
5061}
5062
5063/// Content block type discriminator
5064#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5065pub enum ToolExecutionCompleteContentShellExitType {
5066    #[serde(rename = "shell_exit")]
5067    #[default]
5068    ShellExit,
5069}
5070
5071/// Content block type discriminator
5072#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5073pub enum ToolExecutionCompleteContentImageType {
5074    #[serde(rename = "image")]
5075    #[default]
5076    Image,
5077}
5078
5079/// Content block type discriminator
5080#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5081pub enum ToolExecutionCompleteContentAudioType {
5082    #[serde(rename = "audio")]
5083    #[default]
5084    Audio,
5085}
5086
5087/// Theme variant this icon is intended for
5088#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5089pub enum ToolExecutionCompleteContentResourceLinkIconTheme {
5090    /// Icon intended for light themes.
5091    #[serde(rename = "light")]
5092    Light,
5093    /// Icon intended for dark themes.
5094    #[serde(rename = "dark")]
5095    Dark,
5096    /// Unknown variant for forward compatibility.
5097    #[default]
5098    #[serde(other)]
5099    Unknown,
5100}
5101
5102/// Content block type discriminator
5103#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5104pub enum ToolExecutionCompleteContentResourceLinkType {
5105    #[serde(rename = "resource_link")]
5106    #[default]
5107    ResourceLink,
5108}
5109
5110/// The embedded resource contents, either text or base64-encoded binary
5111#[derive(Debug, Clone, Serialize, Deserialize)]
5112#[serde(untagged)]
5113pub enum ToolExecutionCompleteContentResourceDetails {
5114    EmbeddedTextResourceContents(EmbeddedTextResourceContents),
5115    EmbeddedBlobResourceContents(EmbeddedBlobResourceContents),
5116}
5117
5118/// Content block type discriminator
5119#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5120pub enum ToolExecutionCompleteContentResourceType {
5121    #[serde(rename = "resource")]
5122    #[default]
5123    Resource,
5124}
5125
5126/// A content block within a tool result, which may be text, terminal output, image, audio, or a resource
5127#[derive(Debug, Clone, Serialize, Deserialize)]
5128#[serde(untagged)]
5129pub enum ToolExecutionCompleteContent {
5130    Text(ToolExecutionCompleteContentText),
5131    Terminal(ToolExecutionCompleteContentTerminal),
5132    ShellExit(ToolExecutionCompleteContentShellExit),
5133    Image(ToolExecutionCompleteContentImage),
5134    Audio(ToolExecutionCompleteContentAudio),
5135    ResourceLink(ToolExecutionCompleteContentResourceLink),
5136    Resource(ToolExecutionCompleteContentResource),
5137}
5138
5139/// Allowed values for the `ToolExecutionCompleteToolDescriptionMetaUIVisibility` enumeration.
5140#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5141pub enum ToolExecutionCompleteToolDescriptionMetaUIVisibility {
5142    /// Tool is callable by the model (LLM tool surface)
5143    #[serde(rename = "model")]
5144    Model,
5145    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
5146    #[serde(rename = "app")]
5147    App,
5148    /// Unknown variant for forward compatibility.
5149    #[default]
5150    #[serde(other)]
5151    Unknown,
5152}
5153
5154/// 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)
5155#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5156pub enum SkillInvokedTrigger {
5157    /// Skill invocation requested explicitly by the user, such as via a slash command or UI affordance.
5158    #[serde(rename = "user-invoked")]
5159    UserInvoked,
5160    /// Skill invocation requested by the agent.
5161    #[serde(rename = "agent-invoked")]
5162    AgentInvoked,
5163    /// Skill content loaded as part of another context, such as a configured custom agent or subagent.
5164    #[serde(rename = "context-load")]
5165    ContextLoad,
5166    /// Unknown variant for forward compatibility.
5167    #[default]
5168    #[serde(other)]
5169    Unknown,
5170}
5171
5172/// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
5173#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5174pub enum BinaryAssetType {
5175    /// Binary image data.
5176    #[serde(rename = "image")]
5177    Image,
5178    /// Other binary resource data.
5179    #[serde(rename = "resource")]
5180    Resource,
5181    /// Unknown variant for forward compatibility.
5182    #[default]
5183    #[serde(other)]
5184    Unknown,
5185}
5186
5187/// Message role: "system" for system prompts, "developer" for developer-injected instructions
5188#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5189pub enum SystemMessageRole {
5190    /// System prompt message.
5191    #[serde(rename = "system")]
5192    System,
5193    /// Developer instruction message.
5194    #[serde(rename = "developer")]
5195    Developer,
5196    /// Unknown variant for forward compatibility.
5197    #[default]
5198    #[serde(other)]
5199    Unknown,
5200}
5201
5202/// Permission kind discriminator
5203#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5204pub enum PermissionRequestShellKind {
5205    #[serde(rename = "shell")]
5206    #[default]
5207    Shell,
5208}
5209
5210/// Permission kind discriminator
5211#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5212pub enum PermissionRequestWriteKind {
5213    #[serde(rename = "write")]
5214    #[default]
5215    Write,
5216}
5217
5218/// Permission kind discriminator
5219#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5220pub enum PermissionRequestReadKind {
5221    #[serde(rename = "read")]
5222    #[default]
5223    Read,
5224}
5225
5226/// Permission kind discriminator
5227#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5228pub enum PermissionRequestMcpKind {
5229    #[serde(rename = "mcp")]
5230    #[default]
5231    Mcp,
5232}
5233
5234/// Permission kind discriminator
5235#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5236pub enum PermissionRequestUrlKind {
5237    #[serde(rename = "url")]
5238    #[default]
5239    Url,
5240}
5241
5242/// Whether this is a store or vote memory operation
5243#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5244pub enum PermissionRequestMemoryAction {
5245    /// Store a new memory.
5246    #[serde(rename = "store")]
5247    Store,
5248    /// Vote on an existing memory.
5249    #[serde(rename = "vote")]
5250    Vote,
5251    /// Unknown variant for forward compatibility.
5252    #[default]
5253    #[serde(other)]
5254    Unknown,
5255}
5256
5257/// Vote direction (vote only)
5258#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5259pub enum PermissionRequestMemoryDirection {
5260    /// Vote that the memory is useful or accurate.
5261    #[serde(rename = "upvote")]
5262    Upvote,
5263    /// Vote that the memory is incorrect or outdated.
5264    #[serde(rename = "downvote")]
5265    Downvote,
5266    /// Unknown variant for forward compatibility.
5267    #[default]
5268    #[serde(other)]
5269    Unknown,
5270}
5271
5272/// Permission kind discriminator
5273#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5274pub enum PermissionRequestMemoryKind {
5275    #[serde(rename = "memory")]
5276    #[default]
5277    Memory,
5278}
5279
5280/// Permission kind discriminator
5281#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5282pub enum PermissionRequestCustomToolKind {
5283    #[serde(rename = "custom-tool")]
5284    #[default]
5285    CustomTool,
5286}
5287
5288/// Permission kind discriminator
5289#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5290pub enum PermissionRequestHookKind {
5291    #[serde(rename = "hook")]
5292    #[default]
5293    Hook,
5294}
5295
5296/// Permission kind discriminator
5297#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5298pub enum PermissionRequestExtensionManagementKind {
5299    #[serde(rename = "extension-management")]
5300    #[default]
5301    ExtensionManagement,
5302}
5303
5304/// Permission kind discriminator
5305#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5306pub enum PermissionRequestExtensionPermissionAccessKind {
5307    #[serde(rename = "extension-permission-access")]
5308    #[default]
5309    ExtensionPermissionAccess,
5310}
5311
5312/// Details of the permission being requested
5313#[derive(Debug, Clone, Serialize, Deserialize)]
5314#[serde(untagged)]
5315pub enum PermissionRequest {
5316    Shell(PermissionRequestShell),
5317    Write(PermissionRequestWrite),
5318    Read(PermissionRequestRead),
5319    Mcp(PermissionRequestMcp),
5320    Url(PermissionRequestUrl),
5321    Memory(PermissionRequestMemory),
5322    CustomTool(PermissionRequestCustomTool),
5323    Hook(PermissionRequestHook),
5324    ExtensionManagement(PermissionRequestExtensionManagement),
5325    ExtensionPermissionAccess(PermissionRequestExtensionPermissionAccess),
5326}
5327
5328/// Outcome of the auto-approval safety judge for a permission request. Present only when auto mode is enabled; its absence means the judge did not evaluate the request (auto mode was off).
5329///
5330/// <div class="warning">
5331///
5332/// **Experimental.** This type is part of an experimental wire-protocol surface
5333/// and may change or be removed in future SDK or CLI releases.
5334///
5335/// </div>
5336#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5337pub enum AutoApprovalRecommendation {
5338    /// The judge evaluated the request and recommends automatically approving it.
5339    #[serde(rename = "approve")]
5340    Approve,
5341    /// The judge evaluated the request and does not recommend auto-approving it; explicit approval is required. Whether that means prompting, denying, or something else is the consumer's decision.
5342    #[serde(rename = "requireApproval")]
5343    RequireApproval,
5344    /// Auto mode is enabled, but this request category is never auto-approvable (for example, sandbox-bypass requests), so the judge was not consulted.
5345    #[serde(rename = "excluded")]
5346    Excluded,
5347    /// The judge was consulted but did not return a usable recommendation, so the request requires explicit approval.
5348    #[serde(rename = "error")]
5349    Error,
5350    /// Unknown variant for forward compatibility.
5351    #[default]
5352    #[serde(other)]
5353    Unknown,
5354}
5355
5356/// Prompt kind discriminator
5357#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5358pub enum PermissionPromptRequestCommandsKind {
5359    #[serde(rename = "commands")]
5360    #[default]
5361    Commands,
5362}
5363
5364/// Prompt kind discriminator
5365#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5366pub enum PermissionPromptRequestWriteKind {
5367    #[serde(rename = "write")]
5368    #[default]
5369    Write,
5370}
5371
5372/// Prompt kind discriminator
5373#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5374pub enum PermissionPromptRequestReadKind {
5375    #[serde(rename = "read")]
5376    #[default]
5377    Read,
5378}
5379
5380/// Prompt kind discriminator
5381#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5382pub enum PermissionPromptRequestMcpKind {
5383    #[serde(rename = "mcp")]
5384    #[default]
5385    Mcp,
5386}
5387
5388/// Prompt kind discriminator
5389#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5390pub enum PermissionPromptRequestUrlKind {
5391    #[serde(rename = "url")]
5392    #[default]
5393    Url,
5394}
5395
5396/// Prompt kind discriminator
5397#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5398pub enum PermissionPromptRequestMemoryKind {
5399    #[serde(rename = "memory")]
5400    #[default]
5401    Memory,
5402}
5403
5404/// Prompt kind discriminator
5405#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5406pub enum PermissionPromptRequestCustomToolKind {
5407    #[serde(rename = "custom-tool")]
5408    #[default]
5409    CustomTool,
5410}
5411
5412/// Underlying permission kind that needs path approval
5413#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5414pub enum PermissionPromptRequestPathAccessKind {
5415    /// Read access to a filesystem path.
5416    #[serde(rename = "read")]
5417    Read,
5418    /// Shell command access involving a filesystem path.
5419    #[serde(rename = "shell")]
5420    Shell,
5421    /// Write access to a filesystem path.
5422    #[serde(rename = "write")]
5423    Write,
5424    /// Unknown variant for forward compatibility.
5425    #[default]
5426    #[serde(other)]
5427    Unknown,
5428}
5429
5430/// Prompt kind discriminator
5431#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5432pub enum PermissionPromptRequestPathKind {
5433    #[serde(rename = "path")]
5434    #[default]
5435    Path,
5436}
5437
5438/// Prompt kind discriminator
5439#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5440pub enum PermissionPromptRequestHookKind {
5441    #[serde(rename = "hook")]
5442    #[default]
5443    Hook,
5444}
5445
5446/// Prompt kind discriminator
5447#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5448pub enum PermissionPromptRequestExtensionManagementKind {
5449    #[serde(rename = "extension-management")]
5450    #[default]
5451    ExtensionManagement,
5452}
5453
5454/// Prompt kind discriminator
5455#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5456pub enum PermissionPromptRequestExtensionPermissionAccessKind {
5457    #[serde(rename = "extension-permission-access")]
5458    #[default]
5459    ExtensionPermissionAccess,
5460}
5461
5462/// Derived user-facing permission prompt details for UI consumers
5463#[derive(Debug, Clone, Serialize, Deserialize)]
5464#[serde(untagged)]
5465pub enum PermissionPromptRequest {
5466    Commands(PermissionPromptRequestCommands),
5467    Write(PermissionPromptRequestWrite),
5468    Read(PermissionPromptRequestRead),
5469    Mcp(PermissionPromptRequestMcp),
5470    Url(PermissionPromptRequestUrl),
5471    Memory(PermissionPromptRequestMemory),
5472    CustomTool(PermissionPromptRequestCustomTool),
5473    Path(PermissionPromptRequestPath),
5474    Hook(PermissionPromptRequestHook),
5475    ExtensionManagement(PermissionPromptRequestExtensionManagement),
5476    ExtensionPermissionAccess(PermissionPromptRequestExtensionPermissionAccess),
5477}
5478
5479/// The permission request was approved
5480#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5481pub enum PermissionApprovedKind {
5482    #[serde(rename = "approved")]
5483    #[default]
5484    Approved,
5485}
5486
5487/// Command approval kind
5488#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5489pub enum UserToolSessionApprovalCommandsKind {
5490    #[serde(rename = "commands")]
5491    #[default]
5492    Commands,
5493}
5494
5495/// Read approval kind
5496#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5497pub enum UserToolSessionApprovalReadKind {
5498    #[serde(rename = "read")]
5499    #[default]
5500    Read,
5501}
5502
5503/// Write approval kind
5504#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5505pub enum UserToolSessionApprovalWriteKind {
5506    #[serde(rename = "write")]
5507    #[default]
5508    Write,
5509}
5510
5511/// MCP tool approval kind
5512#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5513pub enum UserToolSessionApprovalMcpKind {
5514    #[serde(rename = "mcp")]
5515    #[default]
5516    Mcp,
5517}
5518
5519/// Memory approval kind
5520#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5521pub enum UserToolSessionApprovalMemoryKind {
5522    #[serde(rename = "memory")]
5523    #[default]
5524    Memory,
5525}
5526
5527/// Custom tool approval kind
5528#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5529pub enum UserToolSessionApprovalCustomToolKind {
5530    #[serde(rename = "custom-tool")]
5531    #[default]
5532    CustomTool,
5533}
5534
5535/// Extension management approval kind
5536#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5537pub enum UserToolSessionApprovalExtensionManagementKind {
5538    #[serde(rename = "extension-management")]
5539    #[default]
5540    ExtensionManagement,
5541}
5542
5543/// Extension permission access approval kind
5544#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5545pub enum UserToolSessionApprovalExtensionPermissionAccessKind {
5546    #[serde(rename = "extension-permission-access")]
5547    #[default]
5548    ExtensionPermissionAccess,
5549}
5550
5551/// The approval to add as a session-scoped rule
5552#[derive(Debug, Clone, Serialize, Deserialize)]
5553#[serde(untagged)]
5554pub enum UserToolSessionApproval {
5555    Commands(UserToolSessionApprovalCommands),
5556    Read(UserToolSessionApprovalRead),
5557    Write(UserToolSessionApprovalWrite),
5558    Mcp(UserToolSessionApprovalMcp),
5559    Memory(UserToolSessionApprovalMemory),
5560    CustomTool(UserToolSessionApprovalCustomTool),
5561    ExtensionManagement(UserToolSessionApprovalExtensionManagement),
5562    ExtensionPermissionAccess(UserToolSessionApprovalExtensionPermissionAccess),
5563}
5564
5565/// Approved and remembered for the rest of the session
5566#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5567pub enum PermissionApprovedForSessionKind {
5568    #[serde(rename = "approved-for-session")]
5569    #[default]
5570    ApprovedForSession,
5571}
5572
5573/// Approved and persisted for this project location
5574#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5575pub enum PermissionApprovedForLocationKind {
5576    #[serde(rename = "approved-for-location")]
5577    #[default]
5578    ApprovedForLocation,
5579}
5580
5581/// The permission request was cancelled before a response was used
5582#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5583pub enum PermissionCancelledKind {
5584    #[serde(rename = "cancelled")]
5585    #[default]
5586    Cancelled,
5587}
5588
5589/// Denied because approval rules explicitly blocked it
5590#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5591pub enum PermissionDeniedByRulesKind {
5592    #[serde(rename = "denied-by-rules")]
5593    #[default]
5594    DeniedByRules,
5595}
5596
5597/// Denied because no approval rule matched and user confirmation was unavailable
5598#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5599pub enum PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind {
5600    #[serde(rename = "denied-no-approval-rule-and-could-not-request-from-user")]
5601    #[default]
5602    DeniedNoApprovalRuleAndCouldNotRequestFromUser,
5603}
5604
5605/// Denied by the user during an interactive prompt
5606#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5607pub enum PermissionDeniedInteractivelyByUserKind {
5608    #[serde(rename = "denied-interactively-by-user")]
5609    #[default]
5610    DeniedInteractivelyByUser,
5611}
5612
5613/// Denied by the organization's content exclusion policy
5614#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5615pub enum PermissionDeniedByContentExclusionPolicyKind {
5616    #[serde(rename = "denied-by-content-exclusion-policy")]
5617    #[default]
5618    DeniedByContentExclusionPolicy,
5619}
5620
5621/// Denied by a permission request hook registered by an extension or plugin
5622#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5623pub enum PermissionDeniedByPermissionRequestHookKind {
5624    #[serde(rename = "denied-by-permission-request-hook")]
5625    #[default]
5626    DeniedByPermissionRequestHook,
5627}
5628
5629/// The result of the permission request
5630#[derive(Debug, Clone, Serialize, Deserialize)]
5631#[serde(untagged)]
5632pub enum PermissionResult {
5633    Approved(PermissionApproved),
5634    ApprovedForSession(PermissionApprovedForSession),
5635    ApprovedForLocation(PermissionApprovedForLocation),
5636    Cancelled(PermissionCancelled),
5637    DeniedByRules(PermissionDeniedByRules),
5638    DeniedNoApprovalRuleAndCouldNotRequestFromUser(
5639        PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser,
5640    ),
5641    DeniedInteractivelyByUser(PermissionDeniedInteractivelyByUser),
5642    DeniedByContentExclusionPolicy(PermissionDeniedByContentExclusionPolicy),
5643    DeniedByPermissionRequestHook(PermissionDeniedByPermissionRequestHook),
5644}
5645
5646/// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
5647#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5648pub enum ElicitationRequestedMode {
5649    /// Structured form-based elicitation.
5650    #[serde(rename = "form")]
5651    Form,
5652    /// Browser URL-based elicitation.
5653    #[serde(rename = "url")]
5654    Url,
5655    /// Unknown variant for forward compatibility.
5656    #[default]
5657    #[serde(other)]
5658    Unknown,
5659}
5660
5661/// Schema type indicator (always 'object')
5662#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5663pub enum ElicitationRequestedSchemaType {
5664    #[serde(rename = "object")]
5665    #[default]
5666    Object,
5667}
5668
5669/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
5670#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5671pub enum ElicitationCompletedAction {
5672    /// The user submitted the requested form.
5673    #[serde(rename = "accept")]
5674    Accept,
5675    /// The user explicitly declined the request.
5676    #[serde(rename = "decline")]
5677    Decline,
5678    /// The user dismissed the request.
5679    #[serde(rename = "cancel")]
5680    Cancel,
5681    /// Unknown variant for forward compatibility.
5682    #[default]
5683    #[serde(other)]
5684    Unknown,
5685}
5686
5687/// Reason the runtime is requesting host-provided MCP OAuth credentials
5688#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5689pub enum McpOauthRequestReason {
5690    /// Initial credentials are required before connecting to the MCP server.
5691    #[serde(rename = "initial")]
5692    Initial,
5693    /// The current host-provided credential was rejected and a replacement is requested.
5694    #[serde(rename = "refresh")]
5695    Refresh,
5696    /// The server requires a new host authorization flow before continuing.
5697    #[serde(rename = "reauth")]
5698    Reauth,
5699    /// The server requires a credential with additional scope or audience.
5700    #[serde(rename = "upscope")]
5701    Upscope,
5702    /// Unknown variant for forward compatibility.
5703    #[default]
5704    #[serde(other)]
5705    Unknown,
5706}
5707
5708/// 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).
5709#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5710pub enum McpOauthRequiredStaticClientConfigGrantType {
5711    #[serde(rename = "client_credentials")]
5712    #[default]
5713    ClientCredentials,
5714}
5715
5716/// How the pending MCP OAuth request was completed
5717#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5718pub enum McpOauthCompletionOutcome {
5719    /// The request completed with a token-backed OAuth provider.
5720    #[serde(rename = "token")]
5721    Token,
5722    /// The request completed without an OAuth provider.
5723    #[serde(rename = "cancelled")]
5724    Cancelled,
5725    /// Unknown variant for forward compatibility.
5726    #[default]
5727    #[serde(other)]
5728    Unknown,
5729}
5730
5731/// Why dynamic headers are being requested.
5732#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5733pub enum McpHeadersRefreshRequiredReason {
5734    /// The transport is making its first dynamic header request for this server.
5735    #[serde(rename = "startup")]
5736    Startup,
5737    /// The previously cached dynamic headers expired.
5738    #[serde(rename = "ttl-expired")]
5739    TtlExpired,
5740    /// The server returned 401 and stale dynamic headers were invalidated.
5741    #[serde(rename = "auth-failed")]
5742    AuthFailed,
5743    /// Unknown variant for forward compatibility.
5744    #[default]
5745    #[serde(other)]
5746    Unknown,
5747}
5748
5749/// How the pending MCP headers refresh request resolved.
5750#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5751pub enum McpHeadersRefreshCompletedOutcome {
5752    /// The host supplied dynamic headers.
5753    #[serde(rename = "headers")]
5754    Headers,
5755    /// The host responded with no dynamic headers.
5756    #[serde(rename = "none")]
5757    None,
5758    /// No response arrived within the bounded window.
5759    #[serde(rename = "timeout")]
5760    Timeout,
5761    /// Unknown variant for forward compatibility.
5762    #[default]
5763    #[serde(other)]
5764    Unknown,
5765}
5766
5767/// The user's auto-mode-switch choice
5768#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5769pub enum AutoModeSwitchResponse {
5770    /// Switch models for this request.
5771    #[serde(rename = "yes")]
5772    Yes,
5773    /// Switch models now and keep using the replacement automatically.
5774    #[serde(rename = "yes_always")]
5775    YesAlways,
5776    /// Do not switch models.
5777    #[serde(rename = "no")]
5778    No,
5779    /// Unknown variant for forward compatibility.
5780    #[default]
5781    #[serde(other)]
5782    Unknown,
5783}
5784
5785/// User action selected for an exhausted session limit.
5786#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5787pub enum SessionLimitsExhaustedResponseAction {
5788    /// Increase the current max by an exact AI Credits amount.
5789    #[serde(rename = "add")]
5790    Add,
5791    /// Set a new absolute max AI Credits value.
5792    #[serde(rename = "set")]
5793    Set,
5794    /// Remove the current session limit.
5795    #[serde(rename = "unset")]
5796    Unset,
5797    /// Leave the limit unchanged and cancel the blocked model request.
5798    #[serde(rename = "cancel")]
5799    Cancel,
5800    /// Unknown variant for forward compatibility.
5801    #[default]
5802    #[serde(other)]
5803    Unknown,
5804}
5805
5806/// Coarse request-difficulty bucket for UX explainability
5807#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5808pub enum AutoModeResolvedReasoningBucket {
5809    /// The request looks low-reasoning; a lighter model is appropriate.
5810    #[serde(rename = "low")]
5811    Low,
5812    /// The request needs a moderate amount of reasoning.
5813    #[serde(rename = "medium")]
5814    Medium,
5815    /// The request looks high-reasoning; a stronger model is appropriate.
5816    #[serde(rename = "high")]
5817    High,
5818    /// Unknown variant for forward compatibility.
5819    #[default]
5820    #[serde(other)]
5821    Unknown,
5822}
5823
5824/// Which channel supplied the effective enterprise managed settings (highest-authority present layer wins wholesale)
5825#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5826pub enum ManagedSettingsResolvedSource {
5827    /// Account/org policy self-fetched from the GitHub managed-settings endpoint (higher authority).
5828    #[serde(rename = "server")]
5829    Server,
5830    /// Device-level MDM policy discovered from plist/registry/file (lower authority).
5831    #[serde(rename = "device")]
5832    Device,
5833    /// No managed policy is in force (no layer contributed).
5834    #[serde(rename = "none")]
5835    None,
5836    /// Unknown variant for forward compatibility.
5837    #[default]
5838    #[serde(other)]
5839    Unknown,
5840}
5841
5842/// The category of runtime action that enterprise managed settings governed (blocked or capped)
5843#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5844pub enum ManagedSettingsEnforcedAction {
5845    /// An attempt to turn on a bypass-permissions ("yolo") escalation was refused or capped because policy disables bypass-permissions mode.
5846    #[serde(rename = "bypass_permissions_blocked")]
5847    BypassPermissionsBlocked,
5848    /// Unknown variant for forward compatibility.
5849    #[default]
5850    #[serde(other)]
5851    Unknown,
5852}
5853
5854/// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused
5855#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5856pub enum ManagedSettingsEnforcedEscalation {
5857    /// Full allow-all ("/allow-all on") permissions — auto-approving tools, paths, and URLs.
5858    #[serde(rename = "allow_all")]
5859    AllowAll,
5860    /// Auto-approval of all tool permission requests.
5861    #[serde(rename = "approve_all")]
5862    ApproveAll,
5863    /// Advisory auto-approval ("/allow-all auto") mode — keeps normal prompt paths and adds LLM-advised approval, distinct from full allow-all.
5864    #[serde(rename = "auto_approval")]
5865    AutoApproval,
5866    /// Unrestricted filesystem access outside the session's allowed directories.
5867    #[serde(rename = "unrestricted_paths")]
5868    UnrestrictedPaths,
5869    /// Unrestricted URL fetch access.
5870    #[serde(rename = "unrestricted_urls")]
5871    UnrestrictedUrls,
5872    /// Unknown variant for forward compatibility.
5873    #[default]
5874    #[serde(other)]
5875    Unknown,
5876}
5877
5878/// Exit plan mode action
5879#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5880pub enum ExitPlanModeAction {
5881    /// Exit plan mode without starting implementation.
5882    #[serde(rename = "exit_only")]
5883    ExitOnly,
5884    /// Exit plan mode and continue in interactive mode.
5885    #[serde(rename = "interactive")]
5886    Interactive,
5887    /// Exit plan mode and continue autonomously.
5888    #[serde(rename = "autopilot")]
5889    Autopilot,
5890    /// Exit plan mode and continue with parallel autonomous workers.
5891    #[serde(rename = "autopilot_fleet")]
5892    AutopilotFleet,
5893    /// Unknown variant for forward compatibility.
5894    #[default]
5895    #[serde(other)]
5896    Unknown,
5897}
5898
5899/// Source location type (e.g., project, personal-copilot, plugin, builtin)
5900#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5901pub enum SkillSource {
5902    /// Skill defined in the current project's skill directories.
5903    #[serde(rename = "project")]
5904    Project,
5905    /// Skill discovered from a parent directory in the current workspace tree.
5906    #[serde(rename = "inherited")]
5907    Inherited,
5908    /// Skill defined in the user's Copilot skill directory.
5909    #[serde(rename = "personal-copilot")]
5910    PersonalCopilot,
5911    /// Skill defined in the user's personal agents skill directory.
5912    #[serde(rename = "personal-agents")]
5913    PersonalAgents,
5914    /// Skill provided by an installed plugin.
5915    #[serde(rename = "plugin")]
5916    Plugin,
5917    /// Skill loaded from a configured custom skill directory.
5918    #[serde(rename = "custom")]
5919    Custom,
5920    /// Skill bundled with the runtime.
5921    #[serde(rename = "builtin")]
5922    Builtin,
5923    /// Unknown variant for forward compatibility.
5924    #[default]
5925    #[serde(other)]
5926    Unknown,
5927}
5928
5929/// Configuration source: user, workspace, plugin, or builtin
5930#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5931pub enum McpServerSource {
5932    /// Server configured in the user's global MCP configuration.
5933    #[serde(rename = "user")]
5934    User,
5935    /// Server configured by the current workspace.
5936    #[serde(rename = "workspace")]
5937    Workspace,
5938    /// Server contributed by an installed plugin.
5939    #[serde(rename = "plugin")]
5940    Plugin,
5941    /// Server bundled with the runtime.
5942    #[serde(rename = "builtin")]
5943    Builtin,
5944    /// Unknown variant for forward compatibility.
5945    #[default]
5946    #[serde(other)]
5947    Unknown,
5948}
5949
5950/// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
5951#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5952pub enum McpServerStatus {
5953    /// The server is connected and available.
5954    #[serde(rename = "connected")]
5955    Connected,
5956    /// The server failed to connect or initialize.
5957    #[serde(rename = "failed")]
5958    Failed,
5959    /// The server requires authentication before it can connect.
5960    #[serde(rename = "needs-auth")]
5961    NeedsAuth,
5962    /// The server connection is still being established.
5963    #[serde(rename = "pending")]
5964    Pending,
5965    /// The server is configured but disabled.
5966    #[serde(rename = "disabled")]
5967    Disabled,
5968    /// The server is not configured for this session.
5969    #[serde(rename = "not_configured")]
5970    NotConfigured,
5971    /// Unknown variant for forward compatibility.
5972    #[default]
5973    #[serde(other)]
5974    Unknown,
5975}
5976
5977/// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
5978#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5979pub enum McpServerTransport {
5980    /// Server communicates over stdio with a local child process.
5981    #[serde(rename = "stdio")]
5982    Stdio,
5983    /// Server communicates over streamable HTTP.
5984    #[serde(rename = "http")]
5985    Http,
5986    /// Server communicates over Server-Sent Events (deprecated).
5987    #[serde(rename = "sse")]
5988    Sse,
5989    /// Server is backed by an in-memory runtime implementation.
5990    #[serde(rename = "memory")]
5991    Memory,
5992    /// Unknown variant for forward compatibility.
5993    #[default]
5994    #[serde(other)]
5995    Unknown,
5996}
5997
5998/// Discovery source
5999#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6000pub enum ExtensionsLoadedExtensionSource {
6001    /// Extension discovered from the current project.
6002    #[serde(rename = "project")]
6003    Project,
6004    /// Extension discovered from the user's extension directory.
6005    #[serde(rename = "user")]
6006    User,
6007    /// Extension contributed by an installed plugin.
6008    #[serde(rename = "plugin")]
6009    Plugin,
6010    /// Extension discovered from the current session's state directory.
6011    #[serde(rename = "session")]
6012    Session,
6013    /// Unknown variant for forward compatibility.
6014    #[default]
6015    #[serde(other)]
6016    Unknown,
6017}
6018
6019/// Current status: running, disabled, failed, or starting
6020#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6021pub enum ExtensionsLoadedExtensionStatus {
6022    /// The extension process is running.
6023    #[serde(rename = "running")]
6024    Running,
6025    /// The extension is installed but disabled.
6026    #[serde(rename = "disabled")]
6027    Disabled,
6028    /// The extension failed to start or crashed.
6029    #[serde(rename = "failed")]
6030    Failed,
6031    /// The extension process is starting.
6032    #[serde(rename = "starting")]
6033    Starting,
6034    /// Unknown variant for forward compatibility.
6035    #[default]
6036    #[serde(other)]
6037    Unknown,
6038}