Skip to main content

github_copilot_sdk/generated/
session_events.rs

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