Skip to main content

github_copilot_sdk/generated/
session_events.rs

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