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