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