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