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