Skip to main content

github_copilot_sdk/generated/
session_events.rs

1//! Auto-generated from session-events.schema.json — do not edit manually.
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7use crate::types::{RequestId, SessionId};
8
9/// Identifies the kind of session event.
10#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
11pub enum SessionEventType {
12    #[serde(rename = "session.start")]
13    SessionStart,
14    #[serde(rename = "session.resume")]
15    SessionResume,
16    #[serde(rename = "session.remote_steerable_changed")]
17    SessionRemoteSteerableChanged,
18    #[serde(rename = "session.error")]
19    SessionError,
20    #[serde(rename = "session.idle")]
21    SessionIdle,
22    #[serde(rename = "session.title_changed")]
23    SessionTitleChanged,
24    #[serde(rename = "session.schedule_created")]
25    SessionScheduleCreated,
26    #[serde(rename = "session.schedule_cancelled")]
27    SessionScheduleCancelled,
28    #[serde(rename = "session.info")]
29    SessionInfo,
30    #[serde(rename = "session.warning")]
31    SessionWarning,
32    #[serde(rename = "session.model_change")]
33    SessionModelChange,
34    #[serde(rename = "session.mode_changed")]
35    SessionModeChanged,
36    #[serde(rename = "session.plan_changed")]
37    SessionPlanChanged,
38    #[serde(rename = "session.workspace_file_changed")]
39    SessionWorkspaceFileChanged,
40    #[serde(rename = "session.handoff")]
41    SessionHandoff,
42    #[serde(rename = "session.truncation")]
43    SessionTruncation,
44    #[serde(rename = "session.snapshot_rewind")]
45    SessionSnapshotRewind,
46    #[serde(rename = "session.shutdown")]
47    SessionShutdown,
48    #[serde(rename = "session.context_changed")]
49    SessionContextChanged,
50    #[serde(rename = "session.usage_info")]
51    SessionUsageInfo,
52    #[serde(rename = "session.compaction_start")]
53    SessionCompactionStart,
54    #[serde(rename = "session.compaction_complete")]
55    SessionCompactionComplete,
56    #[serde(rename = "session.task_complete")]
57    SessionTaskComplete,
58    #[serde(rename = "user.message")]
59    UserMessage,
60    #[serde(rename = "pending_messages.modified")]
61    PendingMessagesModified,
62    #[serde(rename = "assistant.turn_start")]
63    AssistantTurnStart,
64    #[serde(rename = "assistant.intent")]
65    AssistantIntent,
66    #[serde(rename = "assistant.reasoning")]
67    AssistantReasoning,
68    #[serde(rename = "assistant.reasoning_delta")]
69    AssistantReasoningDelta,
70    #[serde(rename = "assistant.streaming_delta")]
71    AssistantStreamingDelta,
72    #[serde(rename = "assistant.message")]
73    AssistantMessage,
74    #[serde(rename = "assistant.message_start")]
75    AssistantMessageStart,
76    #[serde(rename = "assistant.message_delta")]
77    AssistantMessageDelta,
78    #[serde(rename = "assistant.turn_end")]
79    AssistantTurnEnd,
80    #[serde(rename = "assistant.usage")]
81    AssistantUsage,
82    #[serde(rename = "model.call_failure")]
83    ModelCallFailure,
84    #[serde(rename = "abort")]
85    Abort,
86    #[serde(rename = "tool.user_requested")]
87    ToolUserRequested,
88    #[serde(rename = "tool.execution_start")]
89    ToolExecutionStart,
90    #[serde(rename = "tool.execution_partial_result")]
91    ToolExecutionPartialResult,
92    #[serde(rename = "tool.execution_progress")]
93    ToolExecutionProgress,
94    #[serde(rename = "tool.execution_complete")]
95    ToolExecutionComplete,
96    #[serde(rename = "skill.invoked")]
97    SkillInvoked,
98    #[serde(rename = "subagent.started")]
99    SubagentStarted,
100    #[serde(rename = "subagent.completed")]
101    SubagentCompleted,
102    #[serde(rename = "subagent.failed")]
103    SubagentFailed,
104    #[serde(rename = "subagent.selected")]
105    SubagentSelected,
106    #[serde(rename = "subagent.deselected")]
107    SubagentDeselected,
108    #[serde(rename = "hook.start")]
109    HookStart,
110    #[serde(rename = "hook.end")]
111    HookEnd,
112    #[serde(rename = "system.message")]
113    SystemMessage,
114    #[serde(rename = "system.notification")]
115    SystemNotification,
116    #[serde(rename = "permission.requested")]
117    PermissionRequested,
118    #[serde(rename = "permission.completed")]
119    PermissionCompleted,
120    #[serde(rename = "user_input.requested")]
121    UserInputRequested,
122    #[serde(rename = "user_input.completed")]
123    UserInputCompleted,
124    #[serde(rename = "elicitation.requested")]
125    ElicitationRequested,
126    #[serde(rename = "elicitation.completed")]
127    ElicitationCompleted,
128    #[serde(rename = "sampling.requested")]
129    SamplingRequested,
130    #[serde(rename = "sampling.completed")]
131    SamplingCompleted,
132    #[serde(rename = "mcp.oauth_required")]
133    McpOauthRequired,
134    #[serde(rename = "mcp.oauth_completed")]
135    McpOauthCompleted,
136    #[serde(rename = "session.custom_notification")]
137    SessionCustomNotification,
138    #[serde(rename = "external_tool.requested")]
139    ExternalToolRequested,
140    #[serde(rename = "external_tool.completed")]
141    ExternalToolCompleted,
142    #[serde(rename = "command.queued")]
143    CommandQueued,
144    #[serde(rename = "command.execute")]
145    CommandExecute,
146    #[serde(rename = "command.completed")]
147    CommandCompleted,
148    #[serde(rename = "auto_mode_switch.requested")]
149    AutoModeSwitchRequested,
150    #[serde(rename = "auto_mode_switch.completed")]
151    AutoModeSwitchCompleted,
152    #[serde(rename = "commands.changed")]
153    CommandsChanged,
154    #[serde(rename = "capabilities.changed")]
155    CapabilitiesChanged,
156    #[serde(rename = "exit_plan_mode.requested")]
157    ExitPlanModeRequested,
158    #[serde(rename = "exit_plan_mode.completed")]
159    ExitPlanModeCompleted,
160    #[serde(rename = "session.tools_updated")]
161    SessionToolsUpdated,
162    #[serde(rename = "session.background_tasks_changed")]
163    SessionBackgroundTasksChanged,
164    #[serde(rename = "session.skills_loaded")]
165    SessionSkillsLoaded,
166    #[serde(rename = "session.custom_agents_updated")]
167    SessionCustomAgentsUpdated,
168    #[serde(rename = "session.mcp_servers_loaded")]
169    SessionMcpServersLoaded,
170    #[serde(rename = "session.mcp_server_status_changed")]
171    SessionMcpServerStatusChanged,
172    #[serde(rename = "session.extensions_loaded")]
173    SessionExtensionsLoaded,
174    /// Unknown event type for forward compatibility.
175    #[default]
176    #[serde(other)]
177    Unknown,
178}
179
180/// Typed session event data, discriminated by the event `type` field.
181///
182/// Use with [`TypedSessionEvent`] for fully typed event handling.
183#[derive(Debug, Clone, Serialize, Deserialize)]
184#[serde(tag = "type", content = "data")]
185pub enum SessionEventData {
186    #[serde(rename = "session.start")]
187    SessionStart(SessionStartData),
188    #[serde(rename = "session.resume")]
189    SessionResume(SessionResumeData),
190    #[serde(rename = "session.remote_steerable_changed")]
191    SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
192    #[serde(rename = "session.error")]
193    SessionError(SessionErrorData),
194    #[serde(rename = "session.idle")]
195    SessionIdle(SessionIdleData),
196    #[serde(rename = "session.title_changed")]
197    SessionTitleChanged(SessionTitleChangedData),
198    #[serde(rename = "session.schedule_created")]
199    SessionScheduleCreated(SessionScheduleCreatedData),
200    #[serde(rename = "session.schedule_cancelled")]
201    SessionScheduleCancelled(SessionScheduleCancelledData),
202    #[serde(rename = "session.info")]
203    SessionInfo(SessionInfoData),
204    #[serde(rename = "session.warning")]
205    SessionWarning(SessionWarningData),
206    #[serde(rename = "session.model_change")]
207    SessionModelChange(SessionModelChangeData),
208    #[serde(rename = "session.mode_changed")]
209    SessionModeChanged(SessionModeChangedData),
210    #[serde(rename = "session.plan_changed")]
211    SessionPlanChanged(SessionPlanChangedData),
212    #[serde(rename = "session.workspace_file_changed")]
213    SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
214    #[serde(rename = "session.handoff")]
215    SessionHandoff(SessionHandoffData),
216    #[serde(rename = "session.truncation")]
217    SessionTruncation(SessionTruncationData),
218    #[serde(rename = "session.snapshot_rewind")]
219    SessionSnapshotRewind(SessionSnapshotRewindData),
220    #[serde(rename = "session.shutdown")]
221    SessionShutdown(SessionShutdownData),
222    #[serde(rename = "session.context_changed")]
223    SessionContextChanged(SessionContextChangedData),
224    #[serde(rename = "session.usage_info")]
225    SessionUsageInfo(SessionUsageInfoData),
226    #[serde(rename = "session.compaction_start")]
227    SessionCompactionStart(SessionCompactionStartData),
228    #[serde(rename = "session.compaction_complete")]
229    SessionCompactionComplete(SessionCompactionCompleteData),
230    #[serde(rename = "session.task_complete")]
231    SessionTaskComplete(SessionTaskCompleteData),
232    #[serde(rename = "user.message")]
233    UserMessage(UserMessageData),
234    #[serde(rename = "pending_messages.modified")]
235    PendingMessagesModified(PendingMessagesModifiedData),
236    #[serde(rename = "assistant.turn_start")]
237    AssistantTurnStart(AssistantTurnStartData),
238    #[serde(rename = "assistant.intent")]
239    AssistantIntent(AssistantIntentData),
240    #[serde(rename = "assistant.reasoning")]
241    AssistantReasoning(AssistantReasoningData),
242    #[serde(rename = "assistant.reasoning_delta")]
243    AssistantReasoningDelta(AssistantReasoningDeltaData),
244    #[serde(rename = "assistant.streaming_delta")]
245    AssistantStreamingDelta(AssistantStreamingDeltaData),
246    #[serde(rename = "assistant.message")]
247    AssistantMessage(AssistantMessageData),
248    #[serde(rename = "assistant.message_start")]
249    AssistantMessageStart(AssistantMessageStartData),
250    #[serde(rename = "assistant.message_delta")]
251    AssistantMessageDelta(AssistantMessageDeltaData),
252    #[serde(rename = "assistant.turn_end")]
253    AssistantTurnEnd(AssistantTurnEndData),
254    #[serde(rename = "assistant.usage")]
255    AssistantUsage(AssistantUsageData),
256    #[serde(rename = "model.call_failure")]
257    ModelCallFailure(ModelCallFailureData),
258    #[serde(rename = "abort")]
259    Abort(AbortData),
260    #[serde(rename = "tool.user_requested")]
261    ToolUserRequested(ToolUserRequestedData),
262    #[serde(rename = "tool.execution_start")]
263    ToolExecutionStart(ToolExecutionStartData),
264    #[serde(rename = "tool.execution_partial_result")]
265    ToolExecutionPartialResult(ToolExecutionPartialResultData),
266    #[serde(rename = "tool.execution_progress")]
267    ToolExecutionProgress(ToolExecutionProgressData),
268    #[serde(rename = "tool.execution_complete")]
269    ToolExecutionComplete(ToolExecutionCompleteData),
270    #[serde(rename = "skill.invoked")]
271    SkillInvoked(SkillInvokedData),
272    #[serde(rename = "subagent.started")]
273    SubagentStarted(SubagentStartedData),
274    #[serde(rename = "subagent.completed")]
275    SubagentCompleted(SubagentCompletedData),
276    #[serde(rename = "subagent.failed")]
277    SubagentFailed(SubagentFailedData),
278    #[serde(rename = "subagent.selected")]
279    SubagentSelected(SubagentSelectedData),
280    #[serde(rename = "subagent.deselected")]
281    SubagentDeselected(SubagentDeselectedData),
282    #[serde(rename = "hook.start")]
283    HookStart(HookStartData),
284    #[serde(rename = "hook.end")]
285    HookEnd(HookEndData),
286    #[serde(rename = "system.message")]
287    SystemMessage(SystemMessageData),
288    #[serde(rename = "system.notification")]
289    SystemNotification(SystemNotificationData),
290    #[serde(rename = "permission.requested")]
291    PermissionRequested(PermissionRequestedData),
292    #[serde(rename = "permission.completed")]
293    PermissionCompleted(PermissionCompletedData),
294    #[serde(rename = "user_input.requested")]
295    UserInputRequested(UserInputRequestedData),
296    #[serde(rename = "user_input.completed")]
297    UserInputCompleted(UserInputCompletedData),
298    #[serde(rename = "elicitation.requested")]
299    ElicitationRequested(ElicitationRequestedData),
300    #[serde(rename = "elicitation.completed")]
301    ElicitationCompleted(ElicitationCompletedData),
302    #[serde(rename = "sampling.requested")]
303    SamplingRequested(SamplingRequestedData),
304    #[serde(rename = "sampling.completed")]
305    SamplingCompleted(SamplingCompletedData),
306    #[serde(rename = "mcp.oauth_required")]
307    McpOauthRequired(McpOauthRequiredData),
308    #[serde(rename = "mcp.oauth_completed")]
309    McpOauthCompleted(McpOauthCompletedData),
310    #[serde(rename = "session.custom_notification")]
311    SessionCustomNotification(SessionCustomNotificationData),
312    #[serde(rename = "external_tool.requested")]
313    ExternalToolRequested(ExternalToolRequestedData),
314    #[serde(rename = "external_tool.completed")]
315    ExternalToolCompleted(ExternalToolCompletedData),
316    #[serde(rename = "command.queued")]
317    CommandQueued(CommandQueuedData),
318    #[serde(rename = "command.execute")]
319    CommandExecute(CommandExecuteData),
320    #[serde(rename = "command.completed")]
321    CommandCompleted(CommandCompletedData),
322    #[serde(rename = "auto_mode_switch.requested")]
323    AutoModeSwitchRequested(AutoModeSwitchRequestedData),
324    #[serde(rename = "auto_mode_switch.completed")]
325    AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
326    #[serde(rename = "commands.changed")]
327    CommandsChanged(CommandsChangedData),
328    #[serde(rename = "capabilities.changed")]
329    CapabilitiesChanged(CapabilitiesChangedData),
330    #[serde(rename = "exit_plan_mode.requested")]
331    ExitPlanModeRequested(ExitPlanModeRequestedData),
332    #[serde(rename = "exit_plan_mode.completed")]
333    ExitPlanModeCompleted(ExitPlanModeCompletedData),
334    #[serde(rename = "session.tools_updated")]
335    SessionToolsUpdated(SessionToolsUpdatedData),
336    #[serde(rename = "session.background_tasks_changed")]
337    SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
338    #[serde(rename = "session.skills_loaded")]
339    SessionSkillsLoaded(SessionSkillsLoadedData),
340    #[serde(rename = "session.custom_agents_updated")]
341    SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
342    #[serde(rename = "session.mcp_servers_loaded")]
343    SessionMcpServersLoaded(SessionMcpServersLoadedData),
344    #[serde(rename = "session.mcp_server_status_changed")]
345    SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
346    #[serde(rename = "session.extensions_loaded")]
347    SessionExtensionsLoaded(SessionExtensionsLoadedData),
348}
349
350/// A session event with typed data payload.
351///
352/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
353/// are available directly. The event-specific data is in the `payload`
354/// field as a [`SessionEventData`] enum.
355#[derive(Debug, Clone, Serialize, Deserialize)]
356#[serde(rename_all = "camelCase")]
357pub struct TypedSessionEvent {
358    /// Unique event identifier (UUID v4).
359    pub id: String,
360    /// ISO 8601 timestamp when the event was created.
361    pub timestamp: String,
362    /// ID of the preceding event in the chain.
363    #[serde(skip_serializing_if = "Option::is_none")]
364    pub parent_id: Option<String>,
365    /// When true, the event is transient and not persisted.
366    #[serde(skip_serializing_if = "Option::is_none")]
367    pub ephemeral: Option<bool>,
368    /// Sub-agent instance identifier. Absent for events from the root /
369    /// main agent and session-level events.
370    #[serde(skip_serializing_if = "Option::is_none")]
371    pub agent_id: Option<String>,
372    /// The typed event payload (discriminated by event type).
373    #[serde(flatten)]
374    pub payload: SessionEventData,
375}
376
377/// Working directory and git context at session start
378#[derive(Debug, Clone, Default, Serialize, Deserialize)]
379#[serde(rename_all = "camelCase")]
380pub struct WorkingDirectoryContext {
381    /// Base commit of current git branch at session start time
382    #[serde(skip_serializing_if = "Option::is_none")]
383    pub base_commit: Option<String>,
384    /// Current git branch name
385    #[serde(skip_serializing_if = "Option::is_none")]
386    pub branch: Option<String>,
387    /// Current working directory path
388    pub cwd: String,
389    /// Root directory of the git repository, resolved via git rev-parse
390    #[serde(skip_serializing_if = "Option::is_none")]
391    pub git_root: Option<String>,
392    /// Head commit of current git branch at session start time
393    #[serde(skip_serializing_if = "Option::is_none")]
394    pub head_commit: Option<String>,
395    /// Hosting platform type of the repository (github or ado)
396    #[serde(skip_serializing_if = "Option::is_none")]
397    pub host_type: Option<WorkingDirectoryContextHostType>,
398    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
399    #[serde(skip_serializing_if = "Option::is_none")]
400    pub repository: Option<String>,
401    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
402    #[serde(skip_serializing_if = "Option::is_none")]
403    pub repository_host: Option<String>,
404}
405
406/// Session event "session.start". Session initialization metadata including context and configuration
407#[derive(Debug, Clone, Default, Serialize, Deserialize)]
408#[serde(rename_all = "camelCase")]
409pub struct SessionStartData {
410    /// Whether the session was already in use by another client at start time
411    #[serde(skip_serializing_if = "Option::is_none")]
412    pub already_in_use: Option<bool>,
413    /// Working directory and git context at session start
414    #[serde(skip_serializing_if = "Option::is_none")]
415    pub context: Option<WorkingDirectoryContext>,
416    /// Version string of the Copilot application
417    pub copilot_version: String,
418    /// 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.
419    #[serde(skip_serializing_if = "Option::is_none")]
420    pub detached_from_spawning_parent_session_id: Option<String>,
421    /// Identifier of the software producing the events (e.g., "copilot-agent")
422    pub producer: String,
423    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
424    #[serde(skip_serializing_if = "Option::is_none")]
425    pub reasoning_effort: Option<String>,
426    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
427    #[serde(skip_serializing_if = "Option::is_none")]
428    pub reasoning_summary: Option<ReasoningSummary>,
429    /// Whether this session supports remote steering via GitHub
430    #[serde(skip_serializing_if = "Option::is_none")]
431    pub remote_steerable: Option<bool>,
432    /// Model selected at session creation time, if any
433    #[serde(skip_serializing_if = "Option::is_none")]
434    pub selected_model: Option<String>,
435    /// Unique identifier for the session
436    pub session_id: SessionId,
437    /// ISO 8601 timestamp when the session was created
438    pub start_time: String,
439    /// Schema version number for the session event format
440    pub version: i64,
441}
442
443/// Session event "session.resume". Session resume metadata including current context and event count
444#[derive(Debug, Clone, Default, Serialize, Deserialize)]
445#[serde(rename_all = "camelCase")]
446pub struct SessionResumeData {
447    /// Whether the session was already in use by another client at resume time
448    #[serde(skip_serializing_if = "Option::is_none")]
449    pub already_in_use: Option<bool>,
450    /// Updated working directory and git context at resume time
451    #[serde(skip_serializing_if = "Option::is_none")]
452    pub context: Option<WorkingDirectoryContext>,
453    /// 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.
454    #[serde(skip_serializing_if = "Option::is_none")]
455    pub continue_pending_work: Option<bool>,
456    /// Total number of persisted events in the session at the time of resume
457    pub event_count: i64,
458    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
459    #[serde(skip_serializing_if = "Option::is_none")]
460    pub reasoning_effort: Option<String>,
461    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
462    #[serde(skip_serializing_if = "Option::is_none")]
463    pub reasoning_summary: Option<ReasoningSummary>,
464    /// Whether this session supports remote steering via GitHub
465    #[serde(skip_serializing_if = "Option::is_none")]
466    pub remote_steerable: Option<bool>,
467    /// ISO 8601 timestamp when the session was resumed
468    pub resume_time: String,
469    /// Model currently selected at resume time
470    #[serde(skip_serializing_if = "Option::is_none")]
471    pub selected_model: Option<String>,
472    /// 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.
473    #[serde(skip_serializing_if = "Option::is_none")]
474    pub session_was_active: Option<bool>,
475}
476
477/// Session event "session.remote_steerable_changed". Notifies that the session's remote steering capability has changed
478#[derive(Debug, Clone, Default, Serialize, Deserialize)]
479#[serde(rename_all = "camelCase")]
480pub struct SessionRemoteSteerableChangedData {
481    /// Whether this session now supports remote steering via GitHub
482    pub remote_steerable: bool,
483}
484
485/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
486#[derive(Debug, Clone, Default, Serialize, Deserialize)]
487#[serde(rename_all = "camelCase")]
488pub struct SessionErrorData {
489    /// 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.
490    #[serde(skip_serializing_if = "Option::is_none")]
491    pub eligible_for_auto_switch: Option<bool>,
492    /// 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"`).
493    #[serde(skip_serializing_if = "Option::is_none")]
494    pub error_code: Option<String>,
495    /// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
496    pub error_type: String,
497    /// Human-readable error message
498    pub message: String,
499    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
500    #[serde(skip_serializing_if = "Option::is_none")]
501    pub provider_call_id: Option<String>,
502    /// Error stack trace, when available
503    #[serde(skip_serializing_if = "Option::is_none")]
504    pub stack: Option<String>,
505    /// HTTP status code from the upstream request, if applicable
506    #[serde(skip_serializing_if = "Option::is_none")]
507    pub status_code: Option<i32>,
508    /// Optional URL associated with this error that the user can open in a browser
509    #[serde(skip_serializing_if = "Option::is_none")]
510    pub url: Option<String>,
511}
512
513/// Session event "session.idle". Payload indicating the session is idle with no background agents in flight
514#[derive(Debug, Clone, Default, Serialize, Deserialize)]
515#[serde(rename_all = "camelCase")]
516pub struct SessionIdleData {
517    /// True when the preceding agentic loop was cancelled via abort signal
518    #[serde(skip_serializing_if = "Option::is_none")]
519    pub aborted: Option<bool>,
520}
521
522/// Session event "session.title_changed". Session title change payload containing the new display title
523#[derive(Debug, Clone, Default, Serialize, Deserialize)]
524#[serde(rename_all = "camelCase")]
525pub struct SessionTitleChangedData {
526    /// The new display title for the session
527    pub title: String,
528}
529
530/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
531#[derive(Debug, Clone, Default, Serialize, Deserialize)]
532#[serde(rename_all = "camelCase")]
533pub struct SessionScheduleCreatedData {
534    /// 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)
535    #[serde(skip_serializing_if = "Option::is_none")]
536    pub display_prompt: Option<String>,
537    /// Sequential id assigned to the scheduled prompt within the session
538    pub id: i64,
539    /// Interval between ticks in milliseconds
540    pub interval_ms: i64,
541    /// Prompt text that gets enqueued on every tick
542    pub prompt: String,
543    /// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
544    #[serde(skip_serializing_if = "Option::is_none")]
545    pub recurring: Option<bool>,
546}
547
548/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
549#[derive(Debug, Clone, Default, Serialize, Deserialize)]
550#[serde(rename_all = "camelCase")]
551pub struct SessionScheduleCancelledData {
552    /// Id of the scheduled prompt that was cancelled
553    pub id: i64,
554}
555
556/// Session event "session.info". Informational message for timeline display with categorization
557#[derive(Debug, Clone, Default, Serialize, Deserialize)]
558#[serde(rename_all = "camelCase")]
559pub struct SessionInfoData {
560    /// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
561    pub info_type: String,
562    /// Human-readable informational message for display in the timeline
563    pub message: String,
564    /// Optional actionable tip displayed with this message
565    #[serde(skip_serializing_if = "Option::is_none")]
566    pub tip: Option<String>,
567    /// Optional URL associated with this message that the user can open in a browser
568    #[serde(skip_serializing_if = "Option::is_none")]
569    pub url: Option<String>,
570}
571
572/// Session event "session.warning". Warning message for timeline display with categorization
573#[derive(Debug, Clone, Default, Serialize, Deserialize)]
574#[serde(rename_all = "camelCase")]
575pub struct SessionWarningData {
576    /// Human-readable warning message for display in the timeline
577    pub message: String,
578    /// Optional URL associated with this warning that the user can open in a browser
579    #[serde(skip_serializing_if = "Option::is_none")]
580    pub url: Option<String>,
581    /// Category of warning (e.g., "subscription", "policy", "mcp")
582    pub warning_type: String,
583}
584
585/// Session event "session.model_change". Model change details including previous and new model identifiers
586#[derive(Debug, Clone, Default, Serialize, Deserialize)]
587#[serde(rename_all = "camelCase")]
588pub struct SessionModelChangeData {
589    /// 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.
590    #[serde(skip_serializing_if = "Option::is_none")]
591    pub cause: Option<String>,
592    /// Newly selected model identifier
593    pub new_model: String,
594    /// Model that was previously selected, if any
595    #[serde(skip_serializing_if = "Option::is_none")]
596    pub previous_model: Option<String>,
597    /// Reasoning effort level before the model change, if applicable
598    #[serde(skip_serializing_if = "Option::is_none")]
599    pub previous_reasoning_effort: Option<String>,
600    /// Reasoning summary mode before the model change, if applicable
601    #[serde(skip_serializing_if = "Option::is_none")]
602    pub previous_reasoning_summary: Option<ReasoningSummary>,
603    /// Reasoning effort level after the model change, if applicable
604    #[serde(skip_serializing_if = "Option::is_none")]
605    pub reasoning_effort: Option<String>,
606    /// Reasoning summary mode after the model change, if applicable
607    #[serde(skip_serializing_if = "Option::is_none")]
608    pub reasoning_summary: Option<ReasoningSummary>,
609}
610
611/// Session event "session.mode_changed". Agent mode change details including previous and new modes
612#[derive(Debug, Clone, Default, Serialize, Deserialize)]
613#[serde(rename_all = "camelCase")]
614pub struct SessionModeChangedData {
615    /// The session mode the agent is operating in
616    pub new_mode: SessionMode,
617    /// The session mode the agent is operating in
618    pub previous_mode: SessionMode,
619}
620
621/// Session event "session.plan_changed". Plan file operation details indicating what changed
622#[derive(Debug, Clone, Default, Serialize, Deserialize)]
623#[serde(rename_all = "camelCase")]
624pub struct SessionPlanChangedData {
625    /// The type of operation performed on the plan file
626    pub operation: PlanChangedOperation,
627}
628
629/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
630#[derive(Debug, Clone, Default, Serialize, Deserialize)]
631#[serde(rename_all = "camelCase")]
632pub struct SessionWorkspaceFileChangedData {
633    /// Whether the file was newly created or updated
634    pub operation: WorkspaceFileChangedOperation,
635    /// Relative path within the session workspace files directory
636    pub path: String,
637}
638
639/// Repository context for the handed-off session
640#[derive(Debug, Clone, Default, Serialize, Deserialize)]
641#[serde(rename_all = "camelCase")]
642pub struct HandoffRepository {
643    /// Git branch name, if applicable
644    #[serde(skip_serializing_if = "Option::is_none")]
645    pub branch: Option<String>,
646    /// Repository name
647    pub name: String,
648    /// Repository owner (user or organization)
649    pub owner: String,
650}
651
652/// Session event "session.handoff". Session handoff metadata including source, context, and repository information
653#[derive(Debug, Clone, Default, Serialize, Deserialize)]
654#[serde(rename_all = "camelCase")]
655pub struct SessionHandoffData {
656    /// Additional context information for the handoff
657    #[serde(skip_serializing_if = "Option::is_none")]
658    pub context: Option<String>,
659    /// ISO 8601 timestamp when the handoff occurred
660    pub handoff_time: String,
661    /// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
662    #[serde(skip_serializing_if = "Option::is_none")]
663    pub host: Option<String>,
664    /// Session ID of the remote session being handed off
665    #[serde(skip_serializing_if = "Option::is_none")]
666    pub remote_session_id: Option<SessionId>,
667    /// Repository context for the handed-off session
668    #[serde(skip_serializing_if = "Option::is_none")]
669    pub repository: Option<HandoffRepository>,
670    /// Origin type of the session being handed off
671    pub source_type: HandoffSourceType,
672    /// Summary of the work done in the source session
673    #[serde(skip_serializing_if = "Option::is_none")]
674    pub summary: Option<String>,
675}
676
677/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
678#[derive(Debug, Clone, Default, Serialize, Deserialize)]
679#[serde(rename_all = "camelCase")]
680pub struct SessionTruncationData {
681    /// Number of messages removed by truncation
682    pub messages_removed_during_truncation: i64,
683    /// Identifier of the component that performed truncation (e.g., "BasicTruncator")
684    pub performed_by: String,
685    /// Number of conversation messages after truncation
686    pub post_truncation_messages_length: i64,
687    /// Total tokens in conversation messages after truncation
688    pub post_truncation_tokens_in_messages: i64,
689    /// Number of conversation messages before truncation
690    pub pre_truncation_messages_length: i64,
691    /// Total tokens in conversation messages before truncation
692    pub pre_truncation_tokens_in_messages: i64,
693    /// Maximum token count for the model's context window
694    pub token_limit: i64,
695    /// Number of tokens removed by truncation
696    pub tokens_removed_during_truncation: i64,
697}
698
699/// Session event "session.snapshot_rewind". Session rewind details including target event and count of removed events
700#[derive(Debug, Clone, Default, Serialize, Deserialize)]
701#[serde(rename_all = "camelCase")]
702pub struct SessionSnapshotRewindData {
703    /// Number of events that were removed by the rewind
704    pub events_removed: i64,
705    /// Event ID that was rewound to; this event and all after it were removed
706    pub up_to_event_id: String,
707}
708
709/// Aggregate code change metrics for the session
710#[derive(Debug, Clone, Default, Serialize, Deserialize)]
711#[serde(rename_all = "camelCase")]
712pub struct ShutdownCodeChanges {
713    /// List of file paths that were modified during the session
714    pub files_modified: Vec<String>,
715    /// Total number of lines added during the session
716    pub lines_added: i64,
717    /// Total number of lines removed during the session
718    pub lines_removed: i64,
719}
720
721/// Request count and cost metrics
722#[derive(Debug, Clone, Default, Serialize, Deserialize)]
723#[serde(rename_all = "camelCase")]
724pub struct ShutdownModelMetricRequests {
725    /// Cumulative cost multiplier for requests to this model
726    pub cost: f64,
727    /// Total number of API requests made to this model
728    pub count: i64,
729}
730
731/// Schema for the `ShutdownModelMetricTokenDetail` type.
732#[derive(Debug, Clone, Default, Serialize, Deserialize)]
733#[serde(rename_all = "camelCase")]
734pub struct ShutdownModelMetricTokenDetail {
735    /// Accumulated token count for this token type
736    pub token_count: i64,
737}
738
739/// Token usage breakdown
740#[derive(Debug, Clone, Default, Serialize, Deserialize)]
741#[serde(rename_all = "camelCase")]
742pub struct ShutdownModelMetricUsage {
743    /// Total tokens read from prompt cache across all requests
744    pub cache_read_tokens: i64,
745    /// Total tokens written to prompt cache across all requests
746    pub cache_write_tokens: i64,
747    /// Total input tokens consumed across all requests to this model
748    pub input_tokens: i64,
749    /// Total output tokens produced across all requests to this model
750    pub output_tokens: i64,
751    /// Total reasoning tokens produced across all requests to this model
752    #[serde(skip_serializing_if = "Option::is_none")]
753    pub reasoning_tokens: Option<i64>,
754}
755
756/// Schema for the `ShutdownModelMetric` type.
757#[derive(Debug, Clone, Default, Serialize, Deserialize)]
758#[serde(rename_all = "camelCase")]
759pub struct ShutdownModelMetric {
760    /// Request count and cost metrics
761    pub requests: ShutdownModelMetricRequests,
762    /// Token count details per type
763    #[serde(default)]
764    pub token_details: HashMap<String, ShutdownModelMetricTokenDetail>,
765    /// Accumulated nano-AI units cost for this model
766    #[serde(skip_serializing_if = "Option::is_none")]
767    pub total_nano_aiu: Option<f64>,
768    /// Token usage breakdown
769    pub usage: ShutdownModelMetricUsage,
770}
771
772/// Schema for the `ShutdownTokenDetail` type.
773#[derive(Debug, Clone, Default, Serialize, Deserialize)]
774#[serde(rename_all = "camelCase")]
775pub struct ShutdownTokenDetail {
776    /// Accumulated token count for this token type
777    pub token_count: i64,
778}
779
780/// Session event "session.shutdown". Session termination metrics including usage statistics, code changes, and shutdown reason
781#[derive(Debug, Clone, Default, Serialize, Deserialize)]
782#[serde(rename_all = "camelCase")]
783pub struct SessionShutdownData {
784    /// Aggregate code change metrics for the session
785    pub code_changes: ShutdownCodeChanges,
786    /// Non-system message token count at shutdown
787    #[serde(skip_serializing_if = "Option::is_none")]
788    pub conversation_tokens: Option<i64>,
789    /// Model that was selected at the time of shutdown
790    #[serde(skip_serializing_if = "Option::is_none")]
791    pub current_model: Option<String>,
792    /// Total tokens in context window at shutdown
793    #[serde(skip_serializing_if = "Option::is_none")]
794    pub current_tokens: Option<i64>,
795    /// Error description when shutdownType is "error"
796    #[serde(skip_serializing_if = "Option::is_none")]
797    pub error_reason: Option<String>,
798    /// Per-model usage breakdown, keyed by model identifier
799    pub model_metrics: HashMap<String, ShutdownModelMetric>,
800    /// Unix timestamp (milliseconds) when the session started
801    pub session_start_time: i64,
802    /// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
803    pub shutdown_type: ShutdownType,
804    /// System message token count at shutdown
805    #[serde(skip_serializing_if = "Option::is_none")]
806    pub system_tokens: Option<i64>,
807    /// Session-wide per-token-type accumulated token counts
808    #[serde(default)]
809    pub token_details: HashMap<String, ShutdownTokenDetail>,
810    /// Tool definitions token count at shutdown
811    #[serde(skip_serializing_if = "Option::is_none")]
812    pub tool_definitions_tokens: Option<i64>,
813    /// Cumulative time spent in API calls during the session, in milliseconds
814    pub total_api_duration_ms: i64,
815    /// Session-wide accumulated nano-AI units cost
816    #[serde(skip_serializing_if = "Option::is_none")]
817    pub total_nano_aiu: Option<f64>,
818    /// Total number of premium API requests used during the session
819    pub total_premium_requests: f64,
820}
821
822/// Session event "session.context_changed". Updated working directory and git context after the change
823#[derive(Debug, Clone, Default, Serialize, Deserialize)]
824#[serde(rename_all = "camelCase")]
825pub struct SessionContextChangedData {
826    /// Base commit of current git branch at session start time
827    #[serde(skip_serializing_if = "Option::is_none")]
828    pub base_commit: Option<String>,
829    /// Current git branch name
830    #[serde(skip_serializing_if = "Option::is_none")]
831    pub branch: Option<String>,
832    /// Current working directory path
833    pub cwd: String,
834    /// Root directory of the git repository, resolved via git rev-parse
835    #[serde(skip_serializing_if = "Option::is_none")]
836    pub git_root: Option<String>,
837    /// Head commit of current git branch at session start time
838    #[serde(skip_serializing_if = "Option::is_none")]
839    pub head_commit: Option<String>,
840    /// Hosting platform type of the repository (github or ado)
841    #[serde(skip_serializing_if = "Option::is_none")]
842    pub host_type: Option<WorkingDirectoryContextHostType>,
843    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
844    #[serde(skip_serializing_if = "Option::is_none")]
845    pub repository: Option<String>,
846    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
847    #[serde(skip_serializing_if = "Option::is_none")]
848    pub repository_host: Option<String>,
849}
850
851/// Session event "session.usage_info". Current context window usage statistics including token and message counts
852#[derive(Debug, Clone, Default, Serialize, Deserialize)]
853#[serde(rename_all = "camelCase")]
854pub struct SessionUsageInfoData {
855    /// Token count from non-system messages (user, assistant, tool)
856    #[serde(skip_serializing_if = "Option::is_none")]
857    pub conversation_tokens: Option<i64>,
858    /// Current number of tokens in the context window
859    pub current_tokens: i64,
860    /// Whether this is the first usage_info event emitted in this session
861    #[serde(skip_serializing_if = "Option::is_none")]
862    pub is_initial: Option<bool>,
863    /// Current number of messages in the conversation
864    pub messages_length: i64,
865    /// Token count from system message(s)
866    #[serde(skip_serializing_if = "Option::is_none")]
867    pub system_tokens: Option<i64>,
868    /// Maximum token count for the model's context window
869    pub token_limit: i64,
870    /// Token count from tool definitions
871    #[serde(skip_serializing_if = "Option::is_none")]
872    pub tool_definitions_tokens: Option<i64>,
873}
874
875/// Session event "session.compaction_start". Context window breakdown at the start of LLM-powered conversation compaction
876#[derive(Debug, Clone, Default, Serialize, Deserialize)]
877#[serde(rename_all = "camelCase")]
878pub struct SessionCompactionStartData {
879    /// Token count from non-system messages (user, assistant, tool) at compaction start
880    #[serde(skip_serializing_if = "Option::is_none")]
881    pub conversation_tokens: Option<i64>,
882    /// Token count from system message(s) at compaction start
883    #[serde(skip_serializing_if = "Option::is_none")]
884    pub system_tokens: Option<i64>,
885    /// Token count from tool definitions at compaction start
886    #[serde(skip_serializing_if = "Option::is_none")]
887    pub tool_definitions_tokens: Option<i64>,
888}
889
890/// Token usage detail for a single billing category
891#[derive(Debug, Clone, Default, Serialize, Deserialize)]
892#[serde(rename_all = "camelCase")]
893pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
894    /// Number of tokens in this billing batch
895    pub batch_size: i64,
896    /// Cost per batch of tokens
897    pub cost_per_batch: i64,
898    /// Total token count for this entry
899    pub token_count: i64,
900    /// Token category (e.g., "input", "output")
901    pub token_type: String,
902}
903
904/// Per-request cost and usage data from the CAPI copilot_usage response field
905#[derive(Debug, Clone, Default, Serialize, Deserialize)]
906#[serde(rename_all = "camelCase")]
907pub struct CompactionCompleteCompactionTokensUsedCopilotUsage {
908    /// Itemized token usage breakdown
909    pub token_details: Vec<CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail>,
910    /// Total cost in nano-AI units for this request
911    pub total_nano_aiu: f64,
912}
913
914/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
915#[derive(Debug, Clone, Default, Serialize, Deserialize)]
916#[serde(rename_all = "camelCase")]
917pub struct CompactionCompleteCompactionTokensUsed {
918    /// Cached input tokens reused in the compaction LLM call
919    #[serde(skip_serializing_if = "Option::is_none")]
920    pub cache_read_tokens: Option<i64>,
921    /// Tokens written to prompt cache in the compaction LLM call
922    #[serde(skip_serializing_if = "Option::is_none")]
923    pub cache_write_tokens: Option<i64>,
924    /// Per-request cost and usage data from the CAPI copilot_usage response field
925    #[serde(skip_serializing_if = "Option::is_none")]
926    pub copilot_usage: Option<CompactionCompleteCompactionTokensUsedCopilotUsage>,
927    /// Duration of the compaction LLM call in milliseconds
928    #[serde(skip_serializing_if = "Option::is_none")]
929    pub duration: Option<i64>,
930    /// Input tokens consumed by the compaction LLM call
931    #[serde(skip_serializing_if = "Option::is_none")]
932    pub input_tokens: Option<i64>,
933    /// Model identifier used for the compaction LLM call
934    #[serde(skip_serializing_if = "Option::is_none")]
935    pub model: Option<String>,
936    /// Output tokens produced by the compaction LLM call
937    #[serde(skip_serializing_if = "Option::is_none")]
938    pub output_tokens: Option<i64>,
939}
940
941/// Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
942#[derive(Debug, Clone, Default, Serialize, Deserialize)]
943#[serde(rename_all = "camelCase")]
944pub struct SessionCompactionCompleteData {
945    /// Checkpoint snapshot number created for recovery
946    #[serde(skip_serializing_if = "Option::is_none")]
947    pub checkpoint_number: Option<i64>,
948    /// File path where the checkpoint was stored
949    #[serde(skip_serializing_if = "Option::is_none")]
950    pub checkpoint_path: Option<String>,
951    /// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
952    #[serde(skip_serializing_if = "Option::is_none")]
953    pub compaction_tokens_used: Option<CompactionCompleteCompactionTokensUsed>,
954    /// Token count from non-system messages (user, assistant, tool) after compaction
955    #[serde(skip_serializing_if = "Option::is_none")]
956    pub conversation_tokens: Option<i64>,
957    /// Error message if compaction failed
958    #[serde(skip_serializing_if = "Option::is_none")]
959    pub error: Option<String>,
960    /// Number of messages removed during compaction
961    #[serde(skip_serializing_if = "Option::is_none")]
962    pub messages_removed: Option<i64>,
963    /// Total tokens in conversation after compaction
964    #[serde(skip_serializing_if = "Option::is_none")]
965    pub post_compaction_tokens: Option<i64>,
966    /// Number of messages before compaction
967    #[serde(skip_serializing_if = "Option::is_none")]
968    pub pre_compaction_messages_length: Option<i64>,
969    /// Total tokens in conversation before compaction
970    #[serde(skip_serializing_if = "Option::is_none")]
971    pub pre_compaction_tokens: Option<i64>,
972    /// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
973    #[serde(skip_serializing_if = "Option::is_none")]
974    pub request_id: Option<RequestId>,
975    /// Whether compaction completed successfully
976    pub success: bool,
977    /// LLM-generated summary of the compacted conversation history
978    #[serde(skip_serializing_if = "Option::is_none")]
979    pub summary_content: Option<String>,
980    /// Token count from system message(s) after compaction
981    #[serde(skip_serializing_if = "Option::is_none")]
982    pub system_tokens: Option<i64>,
983    /// Number of tokens removed during compaction
984    #[serde(skip_serializing_if = "Option::is_none")]
985    pub tokens_removed: Option<i64>,
986    /// Token count from tool definitions after compaction
987    #[serde(skip_serializing_if = "Option::is_none")]
988    pub tool_definitions_tokens: Option<i64>,
989}
990
991/// Session event "session.task_complete". Task completion notification with summary from the agent
992#[derive(Debug, Clone, Default, Serialize, Deserialize)]
993#[serde(rename_all = "camelCase")]
994pub struct SessionTaskCompleteData {
995    /// Whether the tool call succeeded. False when validation failed (e.g., invalid arguments)
996    #[serde(skip_serializing_if = "Option::is_none")]
997    pub success: Option<bool>,
998    /// Summary of the completed task, provided by the agent
999    #[serde(skip_serializing_if = "Option::is_none")]
1000    pub summary: Option<String>,
1001}
1002
1003/// Session event "user.message".
1004#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1005#[serde(rename_all = "camelCase")]
1006pub struct UserMessageData {
1007    /// The agent mode that was active when this message was sent
1008    #[serde(skip_serializing_if = "Option::is_none")]
1009    pub agent_mode: Option<UserMessageAgentMode>,
1010    /// Files, selections, or GitHub references attached to the message
1011    #[serde(default)]
1012    pub attachments: Vec<serde_json::Value>,
1013    /// The user's message text as displayed in the timeline
1014    pub content: String,
1015    /// CAPI interaction ID for correlating this user message with its turn
1016    #[serde(skip_serializing_if = "Option::is_none")]
1017    pub interaction_id: Option<String>,
1018    /// 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.
1019    #[serde(skip_serializing_if = "Option::is_none")]
1020    pub is_autopilot_continuation: Option<bool>,
1021    /// 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
1022    #[serde(default)]
1023    pub native_document_path_fallback_paths: Vec<String>,
1024    /// Parent agent task ID for background telemetry correlated to this user turn
1025    #[serde(skip_serializing_if = "Option::is_none")]
1026    pub parent_agent_task_id: Option<String>,
1027    /// Origin of this message, used for timeline filtering (e.g., "skill-pdf" for skill-injected messages that should be hidden from the user)
1028    #[serde(skip_serializing_if = "Option::is_none")]
1029    pub source: Option<String>,
1030    /// Normalized document MIME types that were sent natively instead of through tagged_files XML
1031    #[serde(default)]
1032    pub supported_native_document_mime_types: Vec<String>,
1033    /// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching
1034    #[serde(skip_serializing_if = "Option::is_none")]
1035    pub transformed_content: Option<String>,
1036}
1037
1038/// Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
1039#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1040#[serde(rename_all = "camelCase")]
1041pub struct PendingMessagesModifiedData {}
1042
1043/// Session event "assistant.turn_start". Turn initialization metadata including identifier and interaction tracking
1044#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1045#[serde(rename_all = "camelCase")]
1046pub struct AssistantTurnStartData {
1047    /// CAPI interaction ID for correlating this turn with upstream telemetry
1048    #[serde(skip_serializing_if = "Option::is_none")]
1049    pub interaction_id: Option<String>,
1050    /// Identifier for this turn within the agentic loop, typically a stringified turn number
1051    pub turn_id: String,
1052}
1053
1054/// Session event "assistant.intent". Agent intent description for current activity or plan
1055#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1056#[serde(rename_all = "camelCase")]
1057pub struct AssistantIntentData {
1058    /// Short description of what the agent is currently doing or planning to do
1059    pub intent: String,
1060}
1061
1062/// Session event "assistant.reasoning". Assistant reasoning content for timeline display with complete thinking text
1063#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1064#[serde(rename_all = "camelCase")]
1065pub struct AssistantReasoningData {
1066    /// The complete extended thinking text from the model
1067    pub content: String,
1068    /// Unique identifier for this reasoning block
1069    pub reasoning_id: String,
1070}
1071
1072/// Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
1073#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1074#[serde(rename_all = "camelCase")]
1075pub struct AssistantReasoningDeltaData {
1076    /// Incremental text chunk to append to the reasoning content
1077    pub delta_content: String,
1078    /// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event
1079    pub reasoning_id: String,
1080}
1081
1082/// Session event "assistant.streaming_delta". Streaming response progress with cumulative byte count
1083#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1084#[serde(rename_all = "camelCase")]
1085pub struct AssistantStreamingDeltaData {
1086    /// Cumulative total bytes received from the streaming response so far
1087    pub total_response_size_bytes: i64,
1088}
1089
1090/// A tool invocation request from the assistant
1091#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1092#[serde(rename_all = "camelCase")]
1093pub struct AssistantMessageToolRequest {
1094    /// Arguments to pass to the tool, format depends on the tool
1095    #[serde(skip_serializing_if = "Option::is_none")]
1096    pub arguments: Option<serde_json::Value>,
1097    /// Resolved intention summary describing what this specific call does
1098    #[serde(skip_serializing_if = "Option::is_none")]
1099    pub intention_summary: Option<String>,
1100    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
1101    #[serde(skip_serializing_if = "Option::is_none")]
1102    pub mcp_server_name: Option<String>,
1103    /// Original tool name on the MCP server, when the tool is an MCP tool
1104    #[serde(skip_serializing_if = "Option::is_none")]
1105    pub mcp_tool_name: Option<String>,
1106    /// Name of the tool being invoked
1107    pub name: String,
1108    /// Unique identifier for this tool call
1109    pub tool_call_id: String,
1110    /// Human-readable display title for the tool
1111    #[serde(skip_serializing_if = "Option::is_none")]
1112    pub tool_title: Option<String>,
1113    /// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
1114    #[serde(skip_serializing_if = "Option::is_none")]
1115    pub r#type: Option<AssistantMessageToolRequestType>,
1116}
1117
1118/// Session event "assistant.message". Assistant response containing text content, optional tool requests, and interaction metadata
1119#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1120#[serde(rename_all = "camelCase")]
1121pub struct AssistantMessageData {
1122    /// Raw Anthropic content array with advisor blocks (server_tool_use, advisor_tool_result) for verbatim round-tripping
1123    #[serde(default)]
1124    pub anthropic_advisor_blocks: Vec<serde_json::Value>,
1125    /// Anthropic advisor model ID used for this response, for timeline display on replay
1126    #[serde(skip_serializing_if = "Option::is_none")]
1127    pub anthropic_advisor_model: Option<String>,
1128    /// The assistant's text response content
1129    pub content: String,
1130    /// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
1131    #[serde(skip_serializing_if = "Option::is_none")]
1132    pub encrypted_content: Option<String>,
1133    /// CAPI interaction ID for correlating this message with upstream telemetry
1134    #[serde(skip_serializing_if = "Option::is_none")]
1135    pub interaction_id: Option<String>,
1136    /// Unique identifier for this assistant message
1137    pub message_id: String,
1138    /// Model that produced this assistant message, if known
1139    #[serde(skip_serializing_if = "Option::is_none")]
1140    pub model: Option<String>,
1141    /// Actual output token count from the API response (completion_tokens), used for accurate token accounting
1142    #[serde(skip_serializing_if = "Option::is_none")]
1143    pub output_tokens: Option<i64>,
1144    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
1145    #[doc(hidden)]
1146    #[deprecated]
1147    #[serde(skip_serializing_if = "Option::is_none")]
1148    pub parent_tool_call_id: Option<String>,
1149    /// Generation phase for phased-output models (e.g., thinking vs. response phases)
1150    #[serde(skip_serializing_if = "Option::is_none")]
1151    pub phase: Option<String>,
1152    /// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
1153    #[serde(skip_serializing_if = "Option::is_none")]
1154    pub reasoning_opaque: Option<String>,
1155    /// Readable reasoning text from the model's extended thinking
1156    #[serde(skip_serializing_if = "Option::is_none")]
1157    pub reasoning_text: Option<String>,
1158    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
1159    #[serde(skip_serializing_if = "Option::is_none")]
1160    pub request_id: Option<RequestId>,
1161    /// Tool invocations requested by the assistant in this message
1162    #[serde(default)]
1163    pub tool_requests: Vec<AssistantMessageToolRequest>,
1164    /// Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
1165    #[serde(skip_serializing_if = "Option::is_none")]
1166    pub turn_id: Option<String>,
1167}
1168
1169/// Session event "assistant.message_start". Streaming assistant message start metadata
1170#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1171#[serde(rename_all = "camelCase")]
1172pub struct AssistantMessageStartData {
1173    /// Message ID this start event belongs to, matching subsequent deltas and assistant.message
1174    pub message_id: String,
1175    /// Generation phase this message belongs to for phased-output models
1176    #[serde(skip_serializing_if = "Option::is_none")]
1177    pub phase: Option<String>,
1178}
1179
1180/// Session event "assistant.message_delta". Streaming assistant message delta for incremental response updates
1181#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1182#[serde(rename_all = "camelCase")]
1183pub struct AssistantMessageDeltaData {
1184    /// Incremental text chunk to append to the message content
1185    pub delta_content: String,
1186    /// Message ID this delta belongs to, matching the corresponding assistant.message event
1187    pub message_id: String,
1188    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
1189    #[doc(hidden)]
1190    #[deprecated]
1191    #[serde(skip_serializing_if = "Option::is_none")]
1192    pub parent_tool_call_id: Option<String>,
1193}
1194
1195/// Session event "assistant.turn_end". Turn completion metadata including the turn identifier
1196#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1197#[serde(rename_all = "camelCase")]
1198pub struct AssistantTurnEndData {
1199    /// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event
1200    pub turn_id: String,
1201}
1202
1203/// Token usage detail for a single billing category
1204#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1205#[serde(rename_all = "camelCase")]
1206pub struct AssistantUsageCopilotUsageTokenDetail {
1207    /// Number of tokens in this billing batch
1208    pub batch_size: i64,
1209    /// Cost per batch of tokens
1210    pub cost_per_batch: i64,
1211    /// Total token count for this entry
1212    pub token_count: i64,
1213    /// Token category (e.g., "input", "output")
1214    pub token_type: String,
1215}
1216
1217/// Per-request cost and usage data from the CAPI copilot_usage response field
1218#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1219#[serde(rename_all = "camelCase")]
1220pub struct AssistantUsageCopilotUsage {
1221    /// Itemized token usage breakdown
1222    pub token_details: Vec<AssistantUsageCopilotUsageTokenDetail>,
1223    /// Total cost in nano-AI units for this request
1224    pub total_nano_aiu: f64,
1225}
1226
1227/// Schema for the `AssistantUsageQuotaSnapshot` type.
1228#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1229#[serde(rename_all = "camelCase")]
1230pub struct AssistantUsageQuotaSnapshot {
1231    /// Total requests allowed by the entitlement
1232    pub entitlement_requests: i64,
1233    /// Whether the user has an unlimited usage entitlement
1234    pub is_unlimited_entitlement: bool,
1235    /// Number of requests over the entitlement limit
1236    pub overage: f64,
1237    /// Whether overage is allowed when quota is exhausted
1238    pub overage_allowed_with_exhausted_quota: bool,
1239    /// Percentage of quota remaining (0 to 100)
1240    pub remaining_percentage: f64,
1241    /// Date when the quota resets
1242    #[serde(skip_serializing_if = "Option::is_none")]
1243    pub reset_date: Option<String>,
1244    /// Whether usage is still permitted after quota exhaustion
1245    pub usage_allowed_with_exhausted_quota: bool,
1246    /// Number of requests already consumed
1247    pub used_requests: i64,
1248}
1249
1250/// Session event "assistant.usage". LLM API call usage metrics including tokens, costs, quotas, and billing information
1251#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1252#[serde(rename_all = "camelCase")]
1253pub struct AssistantUsageData {
1254    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
1255    #[serde(skip_serializing_if = "Option::is_none")]
1256    pub api_call_id: Option<String>,
1257    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
1258    #[serde(skip_serializing_if = "Option::is_none")]
1259    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
1260    /// Number of tokens read from prompt cache
1261    #[serde(skip_serializing_if = "Option::is_none")]
1262    pub cache_read_tokens: Option<i64>,
1263    /// Number of tokens written to prompt cache
1264    #[serde(skip_serializing_if = "Option::is_none")]
1265    pub cache_write_tokens: Option<i64>,
1266    /// Per-request cost and usage data from the CAPI copilot_usage response field
1267    #[serde(skip_serializing_if = "Option::is_none")]
1268    pub copilot_usage: Option<AssistantUsageCopilotUsage>,
1269    /// Model multiplier cost for billing purposes
1270    #[serde(skip_serializing_if = "Option::is_none")]
1271    pub cost: Option<f64>,
1272    /// Duration of the API call in milliseconds
1273    #[serde(skip_serializing_if = "Option::is_none")]
1274    pub duration: Option<i64>,
1275    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
1276    #[serde(skip_serializing_if = "Option::is_none")]
1277    pub initiator: Option<String>,
1278    /// Number of input tokens consumed
1279    #[serde(skip_serializing_if = "Option::is_none")]
1280    pub input_tokens: Option<i64>,
1281    /// Average inter-token latency in milliseconds. Only available for streaming requests
1282    #[serde(skip_serializing_if = "Option::is_none")]
1283    pub inter_token_latency_ms: Option<f64>,
1284    /// Model identifier used for this API call
1285    pub model: String,
1286    /// Number of output tokens produced
1287    #[serde(skip_serializing_if = "Option::is_none")]
1288    pub output_tokens: Option<i64>,
1289    /// Parent tool call ID when this usage originates from a sub-agent
1290    #[doc(hidden)]
1291    #[deprecated]
1292    #[serde(skip_serializing_if = "Option::is_none")]
1293    pub parent_tool_call_id: Option<String>,
1294    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
1295    #[serde(skip_serializing_if = "Option::is_none")]
1296    pub provider_call_id: Option<String>,
1297    /// Per-quota resource usage snapshots, keyed by quota identifier
1298    #[serde(default)]
1299    pub quota_snapshots: HashMap<String, AssistantUsageQuotaSnapshot>,
1300    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
1301    #[serde(skip_serializing_if = "Option::is_none")]
1302    pub reasoning_effort: Option<String>,
1303    /// Number of output tokens used for reasoning (e.g., chain-of-thought)
1304    #[serde(skip_serializing_if = "Option::is_none")]
1305    pub reasoning_tokens: Option<i64>,
1306    /// Time to first token in milliseconds. Only available for streaming requests
1307    #[serde(skip_serializing_if = "Option::is_none")]
1308    pub time_to_first_token_ms: Option<i64>,
1309}
1310
1311/// Session event "model.call_failure". Failed LLM API call metadata for telemetry
1312#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1313#[serde(rename_all = "camelCase")]
1314pub struct ModelCallFailureData {
1315    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
1316    #[serde(skip_serializing_if = "Option::is_none")]
1317    pub api_call_id: Option<String>,
1318    /// Duration of the failed API call in milliseconds
1319    #[serde(skip_serializing_if = "Option::is_none")]
1320    pub duration_ms: Option<i64>,
1321    /// Raw provider/runtime error message for restricted telemetry
1322    #[serde(skip_serializing_if = "Option::is_none")]
1323    pub error_message: Option<String>,
1324    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
1325    #[serde(skip_serializing_if = "Option::is_none")]
1326    pub initiator: Option<String>,
1327    /// Model identifier used for the failed API call
1328    #[serde(skip_serializing_if = "Option::is_none")]
1329    pub model: Option<String>,
1330    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
1331    #[serde(skip_serializing_if = "Option::is_none")]
1332    pub provider_call_id: Option<String>,
1333    /// Where the failed model call originated
1334    pub source: ModelCallFailureSource,
1335    /// HTTP status code from the failed request
1336    #[serde(skip_serializing_if = "Option::is_none")]
1337    pub status_code: Option<i32>,
1338}
1339
1340/// Session event "abort". Turn abort information including the reason for termination
1341#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1342#[serde(rename_all = "camelCase")]
1343pub struct AbortData {
1344    /// Finite reason code describing why the current turn was aborted
1345    pub reason: AbortReason,
1346}
1347
1348/// Session event "tool.user_requested". User-initiated tool invocation request with tool name and arguments
1349#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1350#[serde(rename_all = "camelCase")]
1351pub struct ToolUserRequestedData {
1352    /// Arguments for the tool invocation
1353    #[serde(skip_serializing_if = "Option::is_none")]
1354    pub arguments: Option<serde_json::Value>,
1355    /// Unique identifier for this tool call
1356    pub tool_call_id: String,
1357    /// Name of the tool the user wants to invoke
1358    pub tool_name: String,
1359}
1360
1361/// Session event "tool.execution_start". Tool execution startup details including MCP server information when applicable
1362#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1363#[serde(rename_all = "camelCase")]
1364pub struct ToolExecutionStartData {
1365    /// Arguments passed to the tool
1366    #[serde(skip_serializing_if = "Option::is_none")]
1367    pub arguments: Option<serde_json::Value>,
1368    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
1369    #[serde(skip_serializing_if = "Option::is_none")]
1370    pub mcp_server_name: Option<String>,
1371    /// Original tool name on the MCP server, when the tool is an MCP tool
1372    #[serde(skip_serializing_if = "Option::is_none")]
1373    pub mcp_tool_name: Option<String>,
1374    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
1375    #[doc(hidden)]
1376    #[deprecated]
1377    #[serde(skip_serializing_if = "Option::is_none")]
1378    pub parent_tool_call_id: Option<String>,
1379    /// Unique identifier for this tool call
1380    pub tool_call_id: String,
1381    /// Name of the tool being executed
1382    pub tool_name: String,
1383    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
1384    #[serde(skip_serializing_if = "Option::is_none")]
1385    pub turn_id: Option<String>,
1386}
1387
1388/// Session event "tool.execution_partial_result". Streaming tool execution output for incremental result display
1389#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1390#[serde(rename_all = "camelCase")]
1391pub struct ToolExecutionPartialResultData {
1392    /// Incremental output chunk from the running tool
1393    pub partial_output: String,
1394    /// Tool call ID this partial result belongs to
1395    pub tool_call_id: String,
1396}
1397
1398/// Session event "tool.execution_progress". Tool execution progress notification with status message
1399#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1400#[serde(rename_all = "camelCase")]
1401pub struct ToolExecutionProgressData {
1402    /// Human-readable progress status message (e.g., from an MCP server)
1403    pub progress_message: String,
1404    /// Tool call ID this progress notification belongs to
1405    pub tool_call_id: String,
1406}
1407
1408/// Error details when the tool execution failed
1409#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1410#[serde(rename_all = "camelCase")]
1411pub struct ToolExecutionCompleteError {
1412    /// Machine-readable error code
1413    #[serde(skip_serializing_if = "Option::is_none")]
1414    pub code: Option<String>,
1415    /// Human-readable error message
1416    pub message: String,
1417}
1418
1419/// Plain text content block
1420#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1421#[serde(rename_all = "camelCase")]
1422pub struct ToolExecutionCompleteContentText {
1423    /// The text content
1424    pub text: String,
1425    /// Content block type discriminator
1426    pub r#type: ToolExecutionCompleteContentTextType,
1427}
1428
1429/// Terminal/shell output content block with optional exit code and working directory
1430#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1431#[serde(rename_all = "camelCase")]
1432pub struct ToolExecutionCompleteContentTerminal {
1433    /// Working directory where the command was executed
1434    #[serde(skip_serializing_if = "Option::is_none")]
1435    pub cwd: Option<String>,
1436    /// Process exit code, if the command has completed
1437    #[serde(skip_serializing_if = "Option::is_none")]
1438    pub exit_code: Option<i64>,
1439    /// Terminal/shell output text
1440    pub text: String,
1441    /// Content block type discriminator
1442    pub r#type: ToolExecutionCompleteContentTerminalType,
1443}
1444
1445/// Image content block with base64-encoded data
1446#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1447#[serde(rename_all = "camelCase")]
1448pub struct ToolExecutionCompleteContentImage {
1449    /// Base64-encoded image data
1450    pub data: String,
1451    /// MIME type of the image (e.g., image/png, image/jpeg)
1452    pub mime_type: String,
1453    /// Content block type discriminator
1454    pub r#type: ToolExecutionCompleteContentImageType,
1455}
1456
1457/// Audio content block with base64-encoded data
1458#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1459#[serde(rename_all = "camelCase")]
1460pub struct ToolExecutionCompleteContentAudio {
1461    /// Base64-encoded audio data
1462    pub data: String,
1463    /// MIME type of the audio (e.g., audio/wav, audio/mpeg)
1464    pub mime_type: String,
1465    /// Content block type discriminator
1466    pub r#type: ToolExecutionCompleteContentAudioType,
1467}
1468
1469/// Icon image for a resource
1470#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1471#[serde(rename_all = "camelCase")]
1472pub struct ToolExecutionCompleteContentResourceLinkIcon {
1473    /// MIME type of the icon image
1474    #[serde(skip_serializing_if = "Option::is_none")]
1475    pub mime_type: Option<String>,
1476    /// Available icon sizes (e.g., ['16x16', '32x32'])
1477    #[serde(default)]
1478    pub sizes: Vec<String>,
1479    /// URL or path to the icon image
1480    pub src: String,
1481    /// Theme variant this icon is intended for
1482    #[serde(skip_serializing_if = "Option::is_none")]
1483    pub theme: Option<ToolExecutionCompleteContentResourceLinkIconTheme>,
1484}
1485
1486/// Resource link content block referencing an external resource
1487#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1488#[serde(rename_all = "camelCase")]
1489pub struct ToolExecutionCompleteContentResourceLink {
1490    /// Human-readable description of the resource
1491    #[serde(skip_serializing_if = "Option::is_none")]
1492    pub description: Option<String>,
1493    /// Icons associated with this resource
1494    #[serde(default)]
1495    pub icons: Vec<ToolExecutionCompleteContentResourceLinkIcon>,
1496    /// MIME type of the resource content
1497    #[serde(skip_serializing_if = "Option::is_none")]
1498    pub mime_type: Option<String>,
1499    /// Resource name identifier
1500    pub name: String,
1501    /// Size of the resource in bytes
1502    #[serde(skip_serializing_if = "Option::is_none")]
1503    pub size: Option<i64>,
1504    /// Human-readable display title for the resource
1505    #[serde(skip_serializing_if = "Option::is_none")]
1506    pub title: Option<String>,
1507    /// Content block type discriminator
1508    pub r#type: ToolExecutionCompleteContentResourceLinkType,
1509    /// URI identifying the resource
1510    pub uri: String,
1511}
1512
1513/// Schema for the `EmbeddedTextResourceContents` type.
1514#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1515#[serde(rename_all = "camelCase")]
1516pub struct EmbeddedTextResourceContents {
1517    /// MIME type of the text content
1518    #[serde(skip_serializing_if = "Option::is_none")]
1519    pub mime_type: Option<String>,
1520    /// Text content of the resource
1521    pub text: String,
1522    /// URI identifying the resource
1523    pub uri: String,
1524}
1525
1526/// Schema for the `EmbeddedBlobResourceContents` type.
1527#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1528#[serde(rename_all = "camelCase")]
1529pub struct EmbeddedBlobResourceContents {
1530    /// Base64-encoded binary content of the resource
1531    pub blob: String,
1532    /// MIME type of the blob content
1533    #[serde(skip_serializing_if = "Option::is_none")]
1534    pub mime_type: Option<String>,
1535    /// URI identifying the resource
1536    pub uri: String,
1537}
1538
1539/// Embedded resource content block with inline text or binary data
1540#[derive(Debug, Clone, Serialize, Deserialize)]
1541#[serde(rename_all = "camelCase")]
1542pub struct ToolExecutionCompleteContentResource {
1543    /// The embedded resource contents, either text or base64-encoded binary
1544    pub resource: ToolExecutionCompleteContentResourceDetails,
1545    /// Content block type discriminator
1546    pub r#type: ToolExecutionCompleteContentResourceType,
1547}
1548
1549/// Tool execution result on success
1550#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1551#[serde(rename_all = "camelCase")]
1552pub struct ToolExecutionCompleteResult {
1553    /// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency
1554    pub content: String,
1555    /// Structured content blocks (text, images, audio, resources) returned by the tool in their native format
1556    #[serde(default)]
1557    pub contents: Vec<ToolExecutionCompleteContent>,
1558    /// Full detailed tool result for UI/timeline display, preserving complete content such as diffs. Falls back to content when absent.
1559    #[serde(skip_serializing_if = "Option::is_none")]
1560    pub detailed_content: Option<String>,
1561}
1562
1563/// Session event "tool.execution_complete". Tool execution completion results including success status, detailed output, and error information
1564#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1565#[serde(rename_all = "camelCase")]
1566pub struct ToolExecutionCompleteData {
1567    /// Error details when the tool execution failed
1568    #[serde(skip_serializing_if = "Option::is_none")]
1569    pub error: Option<ToolExecutionCompleteError>,
1570    /// CAPI interaction ID for correlating this tool execution with upstream telemetry
1571    #[serde(skip_serializing_if = "Option::is_none")]
1572    pub interaction_id: Option<String>,
1573    /// Whether this tool call was explicitly requested by the user rather than the assistant
1574    #[serde(skip_serializing_if = "Option::is_none")]
1575    pub is_user_requested: Option<bool>,
1576    /// Model identifier that generated this tool call
1577    #[serde(skip_serializing_if = "Option::is_none")]
1578    pub model: Option<String>,
1579    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
1580    #[doc(hidden)]
1581    #[deprecated]
1582    #[serde(skip_serializing_if = "Option::is_none")]
1583    pub parent_tool_call_id: Option<String>,
1584    /// Tool execution result on success
1585    #[serde(skip_serializing_if = "Option::is_none")]
1586    pub result: Option<ToolExecutionCompleteResult>,
1587    /// Whether the tool execution completed successfully
1588    pub success: bool,
1589    /// Unique identifier for the completed tool call
1590    pub tool_call_id: String,
1591    /// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
1592    #[serde(default)]
1593    pub tool_telemetry: HashMap<String, serde_json::Value>,
1594    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
1595    #[serde(skip_serializing_if = "Option::is_none")]
1596    pub turn_id: Option<String>,
1597}
1598
1599/// Session event "skill.invoked". Skill invocation details including content, allowed tools, and plugin metadata
1600#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1601#[serde(rename_all = "camelCase")]
1602pub struct SkillInvokedData {
1603    /// Tool names that should be auto-approved when this skill is active
1604    #[serde(default)]
1605    pub allowed_tools: Vec<String>,
1606    /// Full content of the skill file, injected into the conversation for the model
1607    pub content: String,
1608    /// Description of the skill from its SKILL.md frontmatter
1609    #[serde(skip_serializing_if = "Option::is_none")]
1610    pub description: Option<String>,
1611    /// Name of the invoked skill
1612    pub name: String,
1613    /// File path to the SKILL.md definition
1614    pub path: String,
1615    /// Name of the plugin this skill originated from, when applicable
1616    #[serde(skip_serializing_if = "Option::is_none")]
1617    pub plugin_name: Option<String>,
1618    /// Version of the plugin this skill originated from, when applicable
1619    #[serde(skip_serializing_if = "Option::is_none")]
1620    pub plugin_version: Option<String>,
1621}
1622
1623/// Session event "subagent.started". Sub-agent startup details including parent tool call and agent information
1624#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1625#[serde(rename_all = "camelCase")]
1626pub struct SubagentStartedData {
1627    /// Description of what the sub-agent does
1628    pub agent_description: String,
1629    /// Human-readable display name of the sub-agent
1630    pub agent_display_name: String,
1631    /// Internal name of the sub-agent
1632    pub agent_name: String,
1633    /// Model the sub-agent will run with, when known at start. Surfaced in the timeline for auto-selected sub-agents (e.g. rubber-duck).
1634    #[serde(skip_serializing_if = "Option::is_none")]
1635    pub model: Option<String>,
1636    /// Tool call ID of the parent tool invocation that spawned this sub-agent
1637    pub tool_call_id: String,
1638}
1639
1640/// Session event "subagent.completed". Sub-agent completion details for successful execution
1641#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1642#[serde(rename_all = "camelCase")]
1643pub struct SubagentCompletedData {
1644    /// Human-readable display name of the sub-agent
1645    pub agent_display_name: String,
1646    /// Internal name of the sub-agent
1647    pub agent_name: String,
1648    /// Wall-clock duration of the sub-agent execution in milliseconds
1649    #[serde(skip_serializing_if = "Option::is_none")]
1650    pub duration_ms: Option<i64>,
1651    /// Model used by the sub-agent
1652    #[serde(skip_serializing_if = "Option::is_none")]
1653    pub model: Option<String>,
1654    /// Tool call ID of the parent tool invocation that spawned this sub-agent
1655    pub tool_call_id: String,
1656    /// Total tokens (input + output) consumed by the sub-agent
1657    #[serde(skip_serializing_if = "Option::is_none")]
1658    pub total_tokens: Option<i64>,
1659    /// Total number of tool calls made by the sub-agent
1660    #[serde(skip_serializing_if = "Option::is_none")]
1661    pub total_tool_calls: Option<i64>,
1662}
1663
1664/// Session event "subagent.failed". Sub-agent failure details including error message and agent information
1665#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1666#[serde(rename_all = "camelCase")]
1667pub struct SubagentFailedData {
1668    /// Human-readable display name of the sub-agent
1669    pub agent_display_name: String,
1670    /// Internal name of the sub-agent
1671    pub agent_name: String,
1672    /// Wall-clock duration of the sub-agent execution in milliseconds
1673    #[serde(skip_serializing_if = "Option::is_none")]
1674    pub duration_ms: Option<i64>,
1675    /// Error message describing why the sub-agent failed
1676    pub error: String,
1677    /// Model used by the sub-agent (if any model calls succeeded before failure)
1678    #[serde(skip_serializing_if = "Option::is_none")]
1679    pub model: Option<String>,
1680    /// Tool call ID of the parent tool invocation that spawned this sub-agent
1681    pub tool_call_id: String,
1682    /// Total tokens (input + output) consumed before the sub-agent failed
1683    #[serde(skip_serializing_if = "Option::is_none")]
1684    pub total_tokens: Option<i64>,
1685    /// Total number of tool calls made before the sub-agent failed
1686    #[serde(skip_serializing_if = "Option::is_none")]
1687    pub total_tool_calls: Option<i64>,
1688}
1689
1690/// Session event "subagent.selected". Custom agent selection details including name and available tools
1691#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1692#[serde(rename_all = "camelCase")]
1693pub struct SubagentSelectedData {
1694    /// Human-readable display name of the selected custom agent
1695    pub agent_display_name: String,
1696    /// Internal name of the selected custom agent
1697    pub agent_name: String,
1698    /// List of tool names available to this agent, or null for all tools
1699    pub tools: Vec<String>,
1700}
1701
1702/// Session event "subagent.deselected". Empty payload; the event signals that the custom agent was deselected, returning to the default agent
1703#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1704#[serde(rename_all = "camelCase")]
1705pub struct SubagentDeselectedData {}
1706
1707/// Session event "hook.start". Hook invocation start details including type and input data
1708#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1709#[serde(rename_all = "camelCase")]
1710pub struct HookStartData {
1711    /// Unique identifier for this hook invocation
1712    pub hook_invocation_id: String,
1713    /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
1714    pub hook_type: String,
1715    /// Input data passed to the hook
1716    #[serde(skip_serializing_if = "Option::is_none")]
1717    pub input: Option<serde_json::Value>,
1718}
1719
1720/// Error details when the hook failed
1721#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1722#[serde(rename_all = "camelCase")]
1723pub struct HookEndError {
1724    /// Human-readable error message
1725    pub message: String,
1726    /// Error stack trace, when available
1727    #[serde(skip_serializing_if = "Option::is_none")]
1728    pub stack: Option<String>,
1729}
1730
1731/// Session event "hook.end". Hook invocation completion details including output, success status, and error information
1732#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1733#[serde(rename_all = "camelCase")]
1734pub struct HookEndData {
1735    /// Error details when the hook failed
1736    #[serde(skip_serializing_if = "Option::is_none")]
1737    pub error: Option<HookEndError>,
1738    /// Identifier matching the corresponding hook.start event
1739    pub hook_invocation_id: String,
1740    /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
1741    pub hook_type: String,
1742    /// Output data produced by the hook
1743    #[serde(skip_serializing_if = "Option::is_none")]
1744    pub output: Option<serde_json::Value>,
1745    /// Whether the hook completed successfully
1746    pub success: bool,
1747}
1748
1749/// Metadata about the prompt template and its construction
1750#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1751#[serde(rename_all = "camelCase")]
1752pub struct SystemMessageMetadata {
1753    /// Version identifier of the prompt template used
1754    #[serde(skip_serializing_if = "Option::is_none")]
1755    pub prompt_version: Option<String>,
1756    /// Template variables used when constructing the prompt
1757    #[serde(default)]
1758    pub variables: HashMap<String, serde_json::Value>,
1759}
1760
1761/// Session event "system.message". System/developer instruction content with role and optional template metadata
1762#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1763#[serde(rename_all = "camelCase")]
1764pub struct SystemMessageData {
1765    /// The system or developer prompt text sent as model input
1766    pub content: String,
1767    /// Metadata about the prompt template and its construction
1768    #[serde(skip_serializing_if = "Option::is_none")]
1769    pub metadata: Option<SystemMessageMetadata>,
1770    /// Optional name identifier for the message source
1771    #[serde(skip_serializing_if = "Option::is_none")]
1772    pub name: Option<String>,
1773    /// Message role: "system" for system prompts, "developer" for developer-injected instructions
1774    pub role: SystemMessageRole,
1775}
1776
1777/// Session event "system.notification". System-generated notification for runtime events like background task completion
1778#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1779#[serde(rename_all = "camelCase")]
1780pub struct SystemNotificationData {
1781    /// The notification text, typically wrapped in <system_notification> XML tags
1782    pub content: String,
1783    /// Structured metadata identifying what triggered this notification
1784    pub kind: serde_json::Value,
1785}
1786
1787/// Schema for the `PermissionRequestShellCommand` type.
1788#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1789#[serde(rename_all = "camelCase")]
1790pub struct PermissionRequestShellCommand {
1791    /// Command identifier (e.g., executable name)
1792    pub identifier: String,
1793    /// Whether this command is read-only (no side effects)
1794    pub read_only: bool,
1795}
1796
1797/// Schema for the `PermissionRequestShellPossibleUrl` type.
1798#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1799#[serde(rename_all = "camelCase")]
1800pub struct PermissionRequestShellPossibleUrl {
1801    /// URL that may be accessed by the command
1802    pub url: String,
1803}
1804
1805/// Shell command permission request
1806#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1807#[serde(rename_all = "camelCase")]
1808pub struct PermissionRequestShell {
1809    /// Whether the UI can offer session-wide approval for this command pattern
1810    pub can_offer_session_approval: bool,
1811    /// Parsed command identifiers found in the command text
1812    pub commands: Vec<PermissionRequestShellCommand>,
1813    /// The complete shell command text to be executed
1814    pub full_command_text: String,
1815    /// Whether the command includes a file write redirection (e.g., > or >>)
1816    pub has_write_file_redirection: bool,
1817    /// Human-readable description of what the command intends to do
1818    pub intention: String,
1819    /// Permission kind discriminator
1820    pub kind: PermissionRequestShellKind,
1821    /// File paths that may be read or written by the command
1822    pub possible_paths: Vec<String>,
1823    /// URLs that may be accessed by the command
1824    pub possible_urls: Vec<PermissionRequestShellPossibleUrl>,
1825    /// Tool call ID that triggered this permission request
1826    #[serde(skip_serializing_if = "Option::is_none")]
1827    pub tool_call_id: Option<String>,
1828    /// Optional warning message about risks of running this command
1829    #[serde(skip_serializing_if = "Option::is_none")]
1830    pub warning: Option<String>,
1831}
1832
1833/// File write permission request
1834#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1835#[serde(rename_all = "camelCase")]
1836pub struct PermissionRequestWrite {
1837    /// Whether the UI can offer session-wide approval for file write operations
1838    pub can_offer_session_approval: bool,
1839    /// Unified diff showing the proposed changes
1840    pub diff: String,
1841    /// Path of the file being written to
1842    pub file_name: String,
1843    /// Human-readable description of the intended file change
1844    pub intention: String,
1845    /// Permission kind discriminator
1846    pub kind: PermissionRequestWriteKind,
1847    /// Complete new file contents for newly created files
1848    #[serde(skip_serializing_if = "Option::is_none")]
1849    pub new_file_contents: Option<String>,
1850    /// Tool call ID that triggered this permission request
1851    #[serde(skip_serializing_if = "Option::is_none")]
1852    pub tool_call_id: Option<String>,
1853}
1854
1855/// File or directory read permission request
1856#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1857#[serde(rename_all = "camelCase")]
1858pub struct PermissionRequestRead {
1859    /// Human-readable description of why the file is being read
1860    pub intention: String,
1861    /// Permission kind discriminator
1862    pub kind: PermissionRequestReadKind,
1863    /// Path of the file or directory being read
1864    pub path: String,
1865    /// Tool call ID that triggered this permission request
1866    #[serde(skip_serializing_if = "Option::is_none")]
1867    pub tool_call_id: Option<String>,
1868}
1869
1870/// MCP tool invocation permission request
1871#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1872#[serde(rename_all = "camelCase")]
1873pub struct PermissionRequestMcp {
1874    /// Arguments to pass to the MCP tool
1875    #[serde(skip_serializing_if = "Option::is_none")]
1876    pub args: Option<serde_json::Value>,
1877    /// Permission kind discriminator
1878    pub kind: PermissionRequestMcpKind,
1879    /// Whether this MCP tool is read-only (no side effects)
1880    pub read_only: bool,
1881    /// Name of the MCP server providing the tool
1882    pub server_name: String,
1883    /// Tool call ID that triggered this permission request
1884    #[serde(skip_serializing_if = "Option::is_none")]
1885    pub tool_call_id: Option<String>,
1886    /// Internal name of the MCP tool
1887    pub tool_name: String,
1888    /// Human-readable title of the MCP tool
1889    pub tool_title: String,
1890}
1891
1892/// URL access permission request
1893#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1894#[serde(rename_all = "camelCase")]
1895pub struct PermissionRequestUrl {
1896    /// Human-readable description of why the URL is being accessed
1897    pub intention: String,
1898    /// Permission kind discriminator
1899    pub kind: PermissionRequestUrlKind,
1900    /// Tool call ID that triggered this permission request
1901    #[serde(skip_serializing_if = "Option::is_none")]
1902    pub tool_call_id: Option<String>,
1903    /// URL to be fetched
1904    pub url: String,
1905}
1906
1907/// Memory operation permission request
1908#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1909#[serde(rename_all = "camelCase")]
1910pub struct PermissionRequestMemory {
1911    /// Whether this is a store or vote memory operation
1912    #[serde(skip_serializing_if = "Option::is_none")]
1913    pub action: Option<PermissionRequestMemoryAction>,
1914    /// Source references for the stored fact (store only)
1915    #[serde(skip_serializing_if = "Option::is_none")]
1916    pub citations: Option<String>,
1917    /// Vote direction (vote only)
1918    #[serde(skip_serializing_if = "Option::is_none")]
1919    pub direction: Option<PermissionRequestMemoryDirection>,
1920    /// The fact being stored or voted on
1921    pub fact: String,
1922    /// Permission kind discriminator
1923    pub kind: PermissionRequestMemoryKind,
1924    /// Reason for the vote (vote only)
1925    #[serde(skip_serializing_if = "Option::is_none")]
1926    pub reason: Option<String>,
1927    /// Topic or subject of the memory (store only)
1928    #[serde(skip_serializing_if = "Option::is_none")]
1929    pub subject: Option<String>,
1930    /// Tool call ID that triggered this permission request
1931    #[serde(skip_serializing_if = "Option::is_none")]
1932    pub tool_call_id: Option<String>,
1933}
1934
1935/// Custom tool invocation permission request
1936#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1937#[serde(rename_all = "camelCase")]
1938pub struct PermissionRequestCustomTool {
1939    /// Arguments to pass to the custom tool
1940    #[serde(skip_serializing_if = "Option::is_none")]
1941    pub args: Option<serde_json::Value>,
1942    /// Permission kind discriminator
1943    pub kind: PermissionRequestCustomToolKind,
1944    /// Tool call ID that triggered this permission request
1945    #[serde(skip_serializing_if = "Option::is_none")]
1946    pub tool_call_id: Option<String>,
1947    /// Description of what the custom tool does
1948    pub tool_description: String,
1949    /// Name of the custom tool
1950    pub tool_name: String,
1951}
1952
1953/// Hook confirmation permission request
1954#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1955#[serde(rename_all = "camelCase")]
1956pub struct PermissionRequestHook {
1957    /// Optional message from the hook explaining why confirmation is needed
1958    #[serde(skip_serializing_if = "Option::is_none")]
1959    pub hook_message: Option<String>,
1960    /// Permission kind discriminator
1961    pub kind: PermissionRequestHookKind,
1962    /// Arguments of the tool call being gated
1963    #[serde(skip_serializing_if = "Option::is_none")]
1964    pub tool_args: Option<serde_json::Value>,
1965    /// Tool call ID that triggered this permission request
1966    #[serde(skip_serializing_if = "Option::is_none")]
1967    pub tool_call_id: Option<String>,
1968    /// Name of the tool the hook is gating
1969    pub tool_name: String,
1970}
1971
1972/// Extension management permission request
1973#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1974#[serde(rename_all = "camelCase")]
1975pub struct PermissionRequestExtensionManagement {
1976    /// Name of the extension being managed
1977    #[serde(skip_serializing_if = "Option::is_none")]
1978    pub extension_name: Option<String>,
1979    /// Permission kind discriminator
1980    pub kind: PermissionRequestExtensionManagementKind,
1981    /// The extension management operation (scaffold, reload)
1982    pub operation: String,
1983    /// Tool call ID that triggered this permission request
1984    #[serde(skip_serializing_if = "Option::is_none")]
1985    pub tool_call_id: Option<String>,
1986}
1987
1988/// Extension permission access request
1989#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1990#[serde(rename_all = "camelCase")]
1991pub struct PermissionRequestExtensionPermissionAccess {
1992    /// Capabilities the extension is requesting
1993    pub capabilities: Vec<String>,
1994    /// Name of the extension requesting permission access
1995    pub extension_name: String,
1996    /// Permission kind discriminator
1997    pub kind: PermissionRequestExtensionPermissionAccessKind,
1998    /// Tool call ID that triggered this permission request
1999    #[serde(skip_serializing_if = "Option::is_none")]
2000    pub tool_call_id: Option<String>,
2001}
2002
2003/// Shell command permission prompt
2004#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2005#[serde(rename_all = "camelCase")]
2006pub struct PermissionPromptRequestCommands {
2007    /// Whether the UI can offer session-wide approval for this command pattern
2008    pub can_offer_session_approval: bool,
2009    /// Command identifiers covered by this approval prompt
2010    pub command_identifiers: Vec<String>,
2011    /// The complete shell command text to be executed
2012    pub full_command_text: String,
2013    /// Human-readable description of what the command intends to do
2014    pub intention: String,
2015    /// Prompt kind discriminator
2016    pub kind: PermissionPromptRequestCommandsKind,
2017    /// Tool call ID that triggered this permission request
2018    #[serde(skip_serializing_if = "Option::is_none")]
2019    pub tool_call_id: Option<String>,
2020    /// Optional warning message about risks of running this command
2021    #[serde(skip_serializing_if = "Option::is_none")]
2022    pub warning: Option<String>,
2023}
2024
2025/// File write permission prompt
2026#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2027#[serde(rename_all = "camelCase")]
2028pub struct PermissionPromptRequestWrite {
2029    /// Whether the UI can offer session-wide approval for file write operations
2030    pub can_offer_session_approval: bool,
2031    /// Unified diff showing the proposed changes
2032    pub diff: String,
2033    /// Path of the file being written to
2034    pub file_name: String,
2035    /// Human-readable description of the intended file change
2036    pub intention: String,
2037    /// Prompt kind discriminator
2038    pub kind: PermissionPromptRequestWriteKind,
2039    /// Complete new file contents for newly created files
2040    #[serde(skip_serializing_if = "Option::is_none")]
2041    pub new_file_contents: Option<String>,
2042    /// Tool call ID that triggered this permission request
2043    #[serde(skip_serializing_if = "Option::is_none")]
2044    pub tool_call_id: Option<String>,
2045}
2046
2047/// File read permission prompt
2048#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2049#[serde(rename_all = "camelCase")]
2050pub struct PermissionPromptRequestRead {
2051    /// Human-readable description of why the file is being read
2052    pub intention: String,
2053    /// Prompt kind discriminator
2054    pub kind: PermissionPromptRequestReadKind,
2055    /// Path of the file or directory being read
2056    pub path: String,
2057    /// Tool call ID that triggered this permission request
2058    #[serde(skip_serializing_if = "Option::is_none")]
2059    pub tool_call_id: Option<String>,
2060}
2061
2062/// MCP tool invocation permission prompt
2063#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2064#[serde(rename_all = "camelCase")]
2065pub struct PermissionPromptRequestMcp {
2066    /// Arguments to pass to the MCP tool
2067    #[serde(skip_serializing_if = "Option::is_none")]
2068    pub args: Option<serde_json::Value>,
2069    /// Prompt kind discriminator
2070    pub kind: PermissionPromptRequestMcpKind,
2071    /// Name of the MCP server providing the tool
2072    pub server_name: String,
2073    /// Tool call ID that triggered this permission request
2074    #[serde(skip_serializing_if = "Option::is_none")]
2075    pub tool_call_id: Option<String>,
2076    /// Internal name of the MCP tool
2077    pub tool_name: String,
2078    /// Human-readable title of the MCP tool
2079    pub tool_title: String,
2080}
2081
2082/// URL access permission prompt
2083#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2084#[serde(rename_all = "camelCase")]
2085pub struct PermissionPromptRequestUrl {
2086    /// Human-readable description of why the URL is being accessed
2087    pub intention: String,
2088    /// Prompt kind discriminator
2089    pub kind: PermissionPromptRequestUrlKind,
2090    /// Tool call ID that triggered this permission request
2091    #[serde(skip_serializing_if = "Option::is_none")]
2092    pub tool_call_id: Option<String>,
2093    /// URL to be fetched
2094    pub url: String,
2095}
2096
2097/// Memory operation permission prompt
2098#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2099#[serde(rename_all = "camelCase")]
2100pub struct PermissionPromptRequestMemory {
2101    /// Whether this is a store or vote memory operation
2102    #[serde(skip_serializing_if = "Option::is_none")]
2103    pub action: Option<PermissionRequestMemoryAction>,
2104    /// Source references for the stored fact (store only)
2105    #[serde(skip_serializing_if = "Option::is_none")]
2106    pub citations: Option<String>,
2107    /// Vote direction (vote only)
2108    #[serde(skip_serializing_if = "Option::is_none")]
2109    pub direction: Option<PermissionRequestMemoryDirection>,
2110    /// The fact being stored or voted on
2111    pub fact: String,
2112    /// Prompt kind discriminator
2113    pub kind: PermissionPromptRequestMemoryKind,
2114    /// Reason for the vote (vote only)
2115    #[serde(skip_serializing_if = "Option::is_none")]
2116    pub reason: Option<String>,
2117    /// Topic or subject of the memory (store only)
2118    #[serde(skip_serializing_if = "Option::is_none")]
2119    pub subject: Option<String>,
2120    /// Tool call ID that triggered this permission request
2121    #[serde(skip_serializing_if = "Option::is_none")]
2122    pub tool_call_id: Option<String>,
2123}
2124
2125/// Custom tool invocation permission prompt
2126#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2127#[serde(rename_all = "camelCase")]
2128pub struct PermissionPromptRequestCustomTool {
2129    /// Arguments to pass to the custom tool
2130    #[serde(skip_serializing_if = "Option::is_none")]
2131    pub args: Option<serde_json::Value>,
2132    /// Prompt kind discriminator
2133    pub kind: PermissionPromptRequestCustomToolKind,
2134    /// Tool call ID that triggered this permission request
2135    #[serde(skip_serializing_if = "Option::is_none")]
2136    pub tool_call_id: Option<String>,
2137    /// Description of what the custom tool does
2138    pub tool_description: String,
2139    /// Name of the custom tool
2140    pub tool_name: String,
2141}
2142
2143/// Path access permission prompt
2144#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2145#[serde(rename_all = "camelCase")]
2146pub struct PermissionPromptRequestPath {
2147    /// Underlying permission kind that needs path approval
2148    pub access_kind: PermissionPromptRequestPathAccessKind,
2149    /// Prompt kind discriminator
2150    pub kind: PermissionPromptRequestPathKind,
2151    /// File paths that require explicit approval
2152    pub paths: Vec<String>,
2153    /// Tool call ID that triggered this permission request
2154    #[serde(skip_serializing_if = "Option::is_none")]
2155    pub tool_call_id: Option<String>,
2156}
2157
2158/// Hook confirmation permission prompt
2159#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2160#[serde(rename_all = "camelCase")]
2161pub struct PermissionPromptRequestHook {
2162    /// Optional message from the hook explaining why confirmation is needed
2163    #[serde(skip_serializing_if = "Option::is_none")]
2164    pub hook_message: Option<String>,
2165    /// Prompt kind discriminator
2166    pub kind: PermissionPromptRequestHookKind,
2167    /// Arguments of the tool call being gated
2168    #[serde(skip_serializing_if = "Option::is_none")]
2169    pub tool_args: Option<serde_json::Value>,
2170    /// Tool call ID that triggered this permission request
2171    #[serde(skip_serializing_if = "Option::is_none")]
2172    pub tool_call_id: Option<String>,
2173    /// Name of the tool the hook is gating
2174    pub tool_name: String,
2175}
2176
2177/// Extension management permission prompt
2178#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2179#[serde(rename_all = "camelCase")]
2180pub struct PermissionPromptRequestExtensionManagement {
2181    /// Name of the extension being managed
2182    #[serde(skip_serializing_if = "Option::is_none")]
2183    pub extension_name: Option<String>,
2184    /// Prompt kind discriminator
2185    pub kind: PermissionPromptRequestExtensionManagementKind,
2186    /// The extension management operation (scaffold, reload)
2187    pub operation: String,
2188    /// Tool call ID that triggered this permission request
2189    #[serde(skip_serializing_if = "Option::is_none")]
2190    pub tool_call_id: Option<String>,
2191}
2192
2193/// Extension permission access prompt
2194#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2195#[serde(rename_all = "camelCase")]
2196pub struct PermissionPromptRequestExtensionPermissionAccess {
2197    /// Capabilities the extension is requesting
2198    pub capabilities: Vec<String>,
2199    /// Name of the extension requesting permission access
2200    pub extension_name: String,
2201    /// Prompt kind discriminator
2202    pub kind: PermissionPromptRequestExtensionPermissionAccessKind,
2203    /// Tool call ID that triggered this permission request
2204    #[serde(skip_serializing_if = "Option::is_none")]
2205    pub tool_call_id: Option<String>,
2206}
2207
2208/// Session event "permission.requested". Permission request notification requiring client approval with request details
2209#[derive(Debug, Clone, Serialize, Deserialize)]
2210#[serde(rename_all = "camelCase")]
2211pub struct PermissionRequestedData {
2212    /// Details of the permission being requested
2213    pub permission_request: PermissionRequest,
2214    /// Derived user-facing permission prompt details for UI consumers
2215    #[serde(skip_serializing_if = "Option::is_none")]
2216    pub prompt_request: Option<PermissionPromptRequest>,
2217    /// Unique identifier for this permission request; used to respond via session.respondToPermission()
2218    pub request_id: RequestId,
2219    /// When true, this permission was already resolved by a permissionRequest hook and requires no client action
2220    #[serde(skip_serializing_if = "Option::is_none")]
2221    pub resolved_by_hook: Option<bool>,
2222}
2223
2224/// Schema for the `PermissionApproved` type.
2225#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2226#[serde(rename_all = "camelCase")]
2227pub struct PermissionApproved {
2228    /// The permission request was approved
2229    pub kind: PermissionApprovedKind,
2230}
2231
2232/// Schema for the `UserToolSessionApprovalCommands` type.
2233#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2234#[serde(rename_all = "camelCase")]
2235pub struct UserToolSessionApprovalCommands {
2236    /// Command identifiers approved by the user
2237    pub command_identifiers: Vec<String>,
2238    /// Command approval kind
2239    pub kind: UserToolSessionApprovalCommandsKind,
2240}
2241
2242/// Schema for the `UserToolSessionApprovalRead` type.
2243#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2244#[serde(rename_all = "camelCase")]
2245pub struct UserToolSessionApprovalRead {
2246    /// Read approval kind
2247    pub kind: UserToolSessionApprovalReadKind,
2248}
2249
2250/// Schema for the `UserToolSessionApprovalWrite` type.
2251#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2252#[serde(rename_all = "camelCase")]
2253pub struct UserToolSessionApprovalWrite {
2254    /// Write approval kind
2255    pub kind: UserToolSessionApprovalWriteKind,
2256}
2257
2258/// Schema for the `UserToolSessionApprovalMcp` type.
2259#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2260#[serde(rename_all = "camelCase")]
2261pub struct UserToolSessionApprovalMcp {
2262    /// MCP tool approval kind
2263    pub kind: UserToolSessionApprovalMcpKind,
2264    /// MCP server name
2265    pub server_name: String,
2266    /// Optional MCP tool name, or null for all tools on the server
2267    pub tool_name: Option<String>,
2268}
2269
2270/// Schema for the `UserToolSessionApprovalMemory` type.
2271#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2272#[serde(rename_all = "camelCase")]
2273pub struct UserToolSessionApprovalMemory {
2274    /// Memory approval kind
2275    pub kind: UserToolSessionApprovalMemoryKind,
2276}
2277
2278/// Schema for the `UserToolSessionApprovalCustomTool` type.
2279#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2280#[serde(rename_all = "camelCase")]
2281pub struct UserToolSessionApprovalCustomTool {
2282    /// Custom tool approval kind
2283    pub kind: UserToolSessionApprovalCustomToolKind,
2284    /// Custom tool name
2285    pub tool_name: String,
2286}
2287
2288/// Schema for the `UserToolSessionApprovalExtensionManagement` type.
2289#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2290#[serde(rename_all = "camelCase")]
2291pub struct UserToolSessionApprovalExtensionManagement {
2292    /// Extension management approval kind
2293    pub kind: UserToolSessionApprovalExtensionManagementKind,
2294    /// Optional operation identifier
2295    #[serde(skip_serializing_if = "Option::is_none")]
2296    pub operation: Option<String>,
2297}
2298
2299/// Schema for the `UserToolSessionApprovalExtensionPermissionAccess` type.
2300#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2301#[serde(rename_all = "camelCase")]
2302pub struct UserToolSessionApprovalExtensionPermissionAccess {
2303    /// Extension name
2304    pub extension_name: String,
2305    /// Extension permission access approval kind
2306    pub kind: UserToolSessionApprovalExtensionPermissionAccessKind,
2307}
2308
2309/// Schema for the `PermissionApprovedForSession` type.
2310#[derive(Debug, Clone, Serialize, Deserialize)]
2311#[serde(rename_all = "camelCase")]
2312pub struct PermissionApprovedForSession {
2313    /// The approval to add as a session-scoped rule
2314    pub approval: UserToolSessionApproval,
2315    /// Approved and remembered for the rest of the session
2316    pub kind: PermissionApprovedForSessionKind,
2317}
2318
2319/// Schema for the `PermissionApprovedForLocation` type.
2320#[derive(Debug, Clone, Serialize, Deserialize)]
2321#[serde(rename_all = "camelCase")]
2322pub struct PermissionApprovedForLocation {
2323    /// The approval to persist for this location
2324    pub approval: UserToolSessionApproval,
2325    /// Approved and persisted for this project location
2326    pub kind: PermissionApprovedForLocationKind,
2327    /// The location key (git root or cwd) to persist the approval to
2328    pub location_key: String,
2329}
2330
2331/// Schema for the `PermissionCancelled` type.
2332#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2333#[serde(rename_all = "camelCase")]
2334pub struct PermissionCancelled {
2335    /// The permission request was cancelled before a response was used
2336    pub kind: PermissionCancelledKind,
2337    /// Optional explanation of why the request was cancelled
2338    #[serde(skip_serializing_if = "Option::is_none")]
2339    pub reason: Option<String>,
2340}
2341
2342/// Schema for the `PermissionRule` type.
2343#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2344#[serde(rename_all = "camelCase")]
2345pub struct PermissionRule {
2346    /// Argument value matched against the request, or null when the rule kind has no argument (e.g. 'read', 'write', 'memory').
2347    pub argument: Option<String>,
2348    /// The rule kind, such as Shell or GitHubMCP
2349    pub kind: String,
2350}
2351
2352/// Schema for the `PermissionDeniedByRules` type.
2353#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2354#[serde(rename_all = "camelCase")]
2355pub struct PermissionDeniedByRules {
2356    /// Denied because approval rules explicitly blocked it
2357    pub kind: PermissionDeniedByRulesKind,
2358    /// Rules that denied the request
2359    pub rules: Vec<PermissionRule>,
2360}
2361
2362/// Schema for the `PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser` type.
2363#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2364#[serde(rename_all = "camelCase")]
2365pub struct PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
2366    /// Denied because no approval rule matched and user confirmation was unavailable
2367    pub kind: PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind,
2368}
2369
2370/// Schema for the `PermissionDeniedInteractivelyByUser` type.
2371#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2372#[serde(rename_all = "camelCase")]
2373pub struct PermissionDeniedInteractivelyByUser {
2374    /// Optional feedback from the user explaining the denial
2375    #[serde(skip_serializing_if = "Option::is_none")]
2376    pub feedback: Option<String>,
2377    /// Whether to force-reject the current agent turn
2378    #[serde(skip_serializing_if = "Option::is_none")]
2379    pub force_reject: Option<bool>,
2380    /// Denied by the user during an interactive prompt
2381    pub kind: PermissionDeniedInteractivelyByUserKind,
2382}
2383
2384/// Schema for the `PermissionDeniedByContentExclusionPolicy` type.
2385#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2386#[serde(rename_all = "camelCase")]
2387pub struct PermissionDeniedByContentExclusionPolicy {
2388    /// Denied by the organization's content exclusion policy
2389    pub kind: PermissionDeniedByContentExclusionPolicyKind,
2390    /// Human-readable explanation of why the path was excluded
2391    pub message: String,
2392    /// File path that triggered the exclusion
2393    pub path: String,
2394}
2395
2396/// Schema for the `PermissionDeniedByPermissionRequestHook` type.
2397#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2398#[serde(rename_all = "camelCase")]
2399pub struct PermissionDeniedByPermissionRequestHook {
2400    /// Whether to interrupt the current agent turn
2401    #[serde(skip_serializing_if = "Option::is_none")]
2402    pub interrupt: Option<bool>,
2403    /// Denied by a permission request hook registered by an extension or plugin
2404    pub kind: PermissionDeniedByPermissionRequestHookKind,
2405    /// Optional message from the hook explaining the denial
2406    #[serde(skip_serializing_if = "Option::is_none")]
2407    pub message: Option<String>,
2408}
2409
2410/// Session event "permission.completed". Permission request completion notification signaling UI dismissal
2411#[derive(Debug, Clone, Serialize, Deserialize)]
2412#[serde(rename_all = "camelCase")]
2413pub struct PermissionCompletedData {
2414    /// Request ID of the resolved permission request; clients should dismiss any UI for this request
2415    pub request_id: RequestId,
2416    /// The result of the permission request
2417    pub result: PermissionResult,
2418    /// Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
2419    #[serde(skip_serializing_if = "Option::is_none")]
2420    pub tool_call_id: Option<String>,
2421}
2422
2423/// Session event "user_input.requested". User input request notification with question and optional predefined choices
2424#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2425#[serde(rename_all = "camelCase")]
2426pub struct UserInputRequestedData {
2427    /// Whether the user can provide a free-form text response in addition to predefined choices
2428    #[serde(skip_serializing_if = "Option::is_none")]
2429    pub allow_freeform: Option<bool>,
2430    /// Predefined choices for the user to select from, if applicable
2431    #[serde(default)]
2432    pub choices: Vec<String>,
2433    /// The question or prompt to present to the user
2434    pub question: String,
2435    /// Unique identifier for this input request; used to respond via session.respondToUserInput()
2436    pub request_id: RequestId,
2437    /// The LLM-assigned tool call ID that triggered this request; used by remote UIs to correlate responses
2438    #[serde(skip_serializing_if = "Option::is_none")]
2439    pub tool_call_id: Option<String>,
2440}
2441
2442/// Session event "user_input.completed". User input request completion with the user's response
2443#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2444#[serde(rename_all = "camelCase")]
2445pub struct UserInputCompletedData {
2446    /// The user's answer to the input request
2447    #[serde(skip_serializing_if = "Option::is_none")]
2448    pub answer: Option<String>,
2449    /// Request ID of the resolved user input request; clients should dismiss any UI for this request
2450    pub request_id: RequestId,
2451    /// Whether the answer was typed as free-form text rather than selected from choices
2452    #[serde(skip_serializing_if = "Option::is_none")]
2453    pub was_freeform: Option<bool>,
2454}
2455
2456/// JSON Schema describing the form fields to present to the user (form mode only)
2457#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2458#[serde(rename_all = "camelCase")]
2459pub struct ElicitationRequestedSchema {
2460    /// Form field definitions, keyed by field name
2461    pub properties: HashMap<String, serde_json::Value>,
2462    /// List of required field names
2463    #[serde(default)]
2464    pub required: Vec<String>,
2465    /// Schema type indicator (always 'object')
2466    pub r#type: ElicitationRequestedSchemaType,
2467}
2468
2469/// Session event "elicitation.requested". Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
2470#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2471#[serde(rename_all = "camelCase")]
2472pub struct ElicitationRequestedData {
2473    /// The source that initiated the request (MCP server name, or absent for agent-initiated)
2474    #[serde(skip_serializing_if = "Option::is_none")]
2475    pub elicitation_source: Option<String>,
2476    /// Message describing what information is needed from the user
2477    pub message: String,
2478    /// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
2479    #[serde(skip_serializing_if = "Option::is_none")]
2480    pub mode: Option<ElicitationRequestedMode>,
2481    /// JSON Schema describing the form fields to present to the user (form mode only)
2482    #[serde(skip_serializing_if = "Option::is_none")]
2483    pub requested_schema: Option<ElicitationRequestedSchema>,
2484    /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation()
2485    pub request_id: RequestId,
2486    /// Tool call ID from the LLM completion; used to correlate with CompletionChunk.toolCall.id for remote UIs
2487    #[serde(skip_serializing_if = "Option::is_none")]
2488    pub tool_call_id: Option<String>,
2489    /// URL to open in the user's browser (url mode only)
2490    #[serde(skip_serializing_if = "Option::is_none")]
2491    pub url: Option<String>,
2492}
2493
2494/// Session event "elicitation.completed". Elicitation request completion with the user's response
2495#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2496#[serde(rename_all = "camelCase")]
2497pub struct ElicitationCompletedData {
2498    /// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
2499    #[serde(skip_serializing_if = "Option::is_none")]
2500    pub action: Option<ElicitationCompletedAction>,
2501    /// The submitted form data when action is 'accept'; keys match the requested schema fields
2502    #[serde(default)]
2503    pub content: HashMap<String, serde_json::Value>,
2504    /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request
2505    pub request_id: RequestId,
2506}
2507
2508/// Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
2509#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2510#[serde(rename_all = "camelCase")]
2511pub struct SamplingRequestedData {
2512    /// The JSON-RPC request ID from the MCP protocol
2513    pub mcp_request_id: serde_json::Value,
2514    /// Unique identifier for this sampling request; used to respond via session.respondToSampling()
2515    pub request_id: RequestId,
2516    /// Name of the MCP server that initiated the sampling request
2517    pub server_name: String,
2518}
2519
2520/// Session event "sampling.completed". Sampling request completion notification signaling UI dismissal
2521#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2522#[serde(rename_all = "camelCase")]
2523pub struct SamplingCompletedData {
2524    /// Request ID of the resolved sampling request; clients should dismiss any UI for this request
2525    pub request_id: RequestId,
2526}
2527
2528/// Static OAuth client configuration, if the server specifies one
2529#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2530#[serde(rename_all = "camelCase")]
2531pub struct McpOauthRequiredStaticClientConfig {
2532    /// OAuth client ID for the server
2533    pub client_id: String,
2534    /// 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).
2535    #[serde(skip_serializing_if = "Option::is_none")]
2536    pub grant_type: Option<McpOauthRequiredStaticClientConfigGrantType>,
2537    /// Whether this is a public OAuth client
2538    #[serde(skip_serializing_if = "Option::is_none")]
2539    pub public_client: Option<bool>,
2540}
2541
2542/// Session event "mcp.oauth_required". OAuth authentication request for an MCP server
2543#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2544#[serde(rename_all = "camelCase")]
2545pub struct McpOauthRequiredData {
2546    /// Unique identifier for this OAuth request; used to respond via session.respondToMcpOAuth()
2547    pub request_id: RequestId,
2548    /// Display name of the MCP server that requires OAuth
2549    pub server_name: String,
2550    /// URL of the MCP server that requires OAuth
2551    pub server_url: String,
2552    /// Static OAuth client configuration, if the server specifies one
2553    #[serde(skip_serializing_if = "Option::is_none")]
2554    pub static_client_config: Option<McpOauthRequiredStaticClientConfig>,
2555}
2556
2557/// Session event "mcp.oauth_completed". MCP OAuth request completion notification
2558#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2559#[serde(rename_all = "camelCase")]
2560pub struct McpOauthCompletedData {
2561    /// Request ID of the resolved OAuth request
2562    pub request_id: RequestId,
2563}
2564
2565/// Session event "session.custom_notification". Opaque custom notification data. Consumers may branch on source and name, but payload semantics are source-defined.
2566#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2567#[serde(rename_all = "camelCase")]
2568pub struct SessionCustomNotificationData {
2569    /// Source-defined custom notification name
2570    pub name: String,
2571    /// Source-defined JSON payload for the custom notification
2572    pub payload: serde_json::Value,
2573    /// Namespace for the custom notification producer
2574    pub source: String,
2575    /// Optional source-defined string identifiers describing the payload subject
2576    #[serde(default)]
2577    pub subject: HashMap<String, String>,
2578    /// Optional source-defined payload schema version
2579    #[serde(skip_serializing_if = "Option::is_none")]
2580    pub version: Option<i64>,
2581}
2582
2583/// Session event "external_tool.requested". External tool invocation request for client-side tool execution
2584#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2585#[serde(rename_all = "camelCase")]
2586pub struct ExternalToolRequestedData {
2587    /// Arguments to pass to the external tool
2588    #[serde(skip_serializing_if = "Option::is_none")]
2589    pub arguments: Option<serde_json::Value>,
2590    /// Unique identifier for this request; used to respond via session.respondToExternalTool()
2591    pub request_id: RequestId,
2592    /// Session ID that this external tool request belongs to
2593    pub session_id: SessionId,
2594    /// Tool call ID assigned to this external tool invocation
2595    pub tool_call_id: String,
2596    /// Name of the external tool to invoke
2597    pub tool_name: String,
2598    /// W3C Trace Context traceparent header for the execute_tool span
2599    #[serde(skip_serializing_if = "Option::is_none")]
2600    pub traceparent: Option<String>,
2601    /// W3C Trace Context tracestate header for the execute_tool span
2602    #[serde(skip_serializing_if = "Option::is_none")]
2603    pub tracestate: Option<String>,
2604}
2605
2606/// Session event "external_tool.completed". External tool completion notification signaling UI dismissal
2607#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2608#[serde(rename_all = "camelCase")]
2609pub struct ExternalToolCompletedData {
2610    /// Request ID of the resolved external tool request; clients should dismiss any UI for this request
2611    pub request_id: RequestId,
2612}
2613
2614/// Session event "command.queued". Queued slash command dispatch request for client execution
2615#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2616#[serde(rename_all = "camelCase")]
2617pub struct CommandQueuedData {
2618    /// The slash command text to be executed (e.g., /help, /clear)
2619    pub command: String,
2620    /// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
2621    pub request_id: RequestId,
2622}
2623
2624/// Session event "command.execute". Registered command dispatch request routed to the owning client
2625#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2626#[serde(rename_all = "camelCase")]
2627pub struct CommandExecuteData {
2628    /// Raw argument string after the command name
2629    pub args: String,
2630    /// The full command text (e.g., /deploy production)
2631    pub command: String,
2632    /// Command name without leading /
2633    pub command_name: String,
2634    /// Unique identifier; used to respond via session.commands.handlePendingCommand()
2635    pub request_id: RequestId,
2636}
2637
2638/// Session event "command.completed". Queued command completion notification signaling UI dismissal
2639#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2640#[serde(rename_all = "camelCase")]
2641pub struct CommandCompletedData {
2642    /// Request ID of the resolved command request; clients should dismiss any UI for this request
2643    pub request_id: RequestId,
2644}
2645
2646/// Session event "auto_mode_switch.requested". Auto mode switch request notification requiring user approval
2647#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2648#[serde(rename_all = "camelCase")]
2649pub struct AutoModeSwitchRequestedData {
2650    /// The rate limit error code that triggered this request
2651    #[serde(skip_serializing_if = "Option::is_none")]
2652    pub error_code: Option<String>,
2653    /// Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
2654    pub request_id: RequestId,
2655    /// Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
2656    #[serde(skip_serializing_if = "Option::is_none")]
2657    pub retry_after_seconds: Option<i64>,
2658}
2659
2660/// Session event "auto_mode_switch.completed". Auto mode switch completion notification
2661#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2662#[serde(rename_all = "camelCase")]
2663pub struct AutoModeSwitchCompletedData {
2664    /// Request ID of the resolved request; clients should dismiss any UI for this request
2665    pub request_id: RequestId,
2666    /// The user's auto-mode-switch choice
2667    pub response: AutoModeSwitchResponse,
2668}
2669
2670/// Schema for the `CommandsChangedCommand` type.
2671#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2672#[serde(rename_all = "camelCase")]
2673pub struct CommandsChangedCommand {
2674    /// Optional human-readable command description.
2675    #[serde(skip_serializing_if = "Option::is_none")]
2676    pub description: Option<String>,
2677    /// Slash command name without the leading slash.
2678    pub name: String,
2679}
2680
2681/// Session event "commands.changed". SDK command registration change notification
2682#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2683#[serde(rename_all = "camelCase")]
2684pub struct CommandsChangedData {
2685    /// Current list of registered SDK commands
2686    pub commands: Vec<CommandsChangedCommand>,
2687}
2688
2689/// UI capability changes
2690#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2691#[serde(rename_all = "camelCase")]
2692pub struct CapabilitiesChangedUI {
2693    /// Whether elicitation is now supported
2694    #[serde(skip_serializing_if = "Option::is_none")]
2695    pub elicitation: Option<bool>,
2696}
2697
2698/// Session event "capabilities.changed". Session capability change notification
2699#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2700#[serde(rename_all = "camelCase")]
2701pub struct CapabilitiesChangedData {
2702    /// UI capability changes
2703    #[serde(skip_serializing_if = "Option::is_none")]
2704    pub ui: Option<CapabilitiesChangedUI>,
2705}
2706
2707/// Session event "exit_plan_mode.requested". Plan approval request with plan content and available user actions
2708#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2709#[serde(rename_all = "camelCase")]
2710pub struct ExitPlanModeRequestedData {
2711    /// Available actions the user can take
2712    pub actions: Vec<ExitPlanModeAction>,
2713    /// Full content of the plan file
2714    pub plan_content: String,
2715    /// Recommended action to preselect for the user
2716    pub recommended_action: ExitPlanModeAction,
2717    /// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
2718    pub request_id: RequestId,
2719    /// Summary of the plan that was created
2720    pub summary: String,
2721}
2722
2723/// Session event "exit_plan_mode.completed". Plan mode exit completion with the user's approval decision and optional feedback
2724#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2725#[serde(rename_all = "camelCase")]
2726pub struct ExitPlanModeCompletedData {
2727    /// Whether the plan was approved by the user
2728    #[serde(skip_serializing_if = "Option::is_none")]
2729    pub approved: Option<bool>,
2730    /// Whether edits should be auto-approved without confirmation
2731    #[serde(skip_serializing_if = "Option::is_none")]
2732    pub auto_approve_edits: Option<bool>,
2733    /// Free-form feedback from the user if they requested changes to the plan
2734    #[serde(skip_serializing_if = "Option::is_none")]
2735    pub feedback: Option<String>,
2736    /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
2737    pub request_id: RequestId,
2738    /// Action selected by the user
2739    #[serde(skip_serializing_if = "Option::is_none")]
2740    pub selected_action: Option<ExitPlanModeAction>,
2741}
2742
2743/// Session event "session.tools_updated".
2744#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2745#[serde(rename_all = "camelCase")]
2746pub struct SessionToolsUpdatedData {
2747    /// Identifier of the model the resolved tools apply to.
2748    pub model: String,
2749}
2750
2751/// Session event "session.background_tasks_changed".
2752#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2753#[serde(rename_all = "camelCase")]
2754pub struct SessionBackgroundTasksChangedData {}
2755
2756/// Schema for the `SkillsLoadedSkill` type.
2757#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2758#[serde(rename_all = "camelCase")]
2759pub struct SkillsLoadedSkill {
2760    /// Description of what the skill does
2761    pub description: String,
2762    /// Whether the skill is currently enabled
2763    pub enabled: bool,
2764    /// Unique identifier for the skill
2765    pub name: String,
2766    /// Absolute path to the skill file, if available
2767    #[serde(skip_serializing_if = "Option::is_none")]
2768    pub path: Option<String>,
2769    /// Source location type (e.g., project, personal-copilot, plugin, builtin)
2770    pub source: SkillSource,
2771    /// Whether the skill can be invoked by the user as a slash command
2772    pub user_invocable: bool,
2773}
2774
2775/// Session event "session.skills_loaded".
2776#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2777#[serde(rename_all = "camelCase")]
2778pub struct SessionSkillsLoadedData {
2779    /// Array of resolved skill metadata
2780    pub skills: Vec<SkillsLoadedSkill>,
2781}
2782
2783/// Schema for the `CustomAgentsUpdatedAgent` type.
2784#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2785#[serde(rename_all = "camelCase")]
2786pub struct CustomAgentsUpdatedAgent {
2787    /// Description of what the agent does
2788    pub description: String,
2789    /// Human-readable display name
2790    pub display_name: String,
2791    /// Unique identifier for the agent
2792    pub id: String,
2793    /// Model override for this agent, if set
2794    #[serde(skip_serializing_if = "Option::is_none")]
2795    pub model: Option<String>,
2796    /// Internal name of the agent
2797    pub name: String,
2798    /// Source location: user, project, inherited, remote, or plugin
2799    pub source: String,
2800    /// List of tool names available to this agent, or null when all tools are available
2801    pub tools: Vec<String>,
2802    /// Whether the agent can be selected by the user
2803    pub user_invocable: bool,
2804}
2805
2806/// Session event "session.custom_agents_updated".
2807#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2808#[serde(rename_all = "camelCase")]
2809pub struct SessionCustomAgentsUpdatedData {
2810    /// Array of loaded custom agent metadata
2811    pub agents: Vec<CustomAgentsUpdatedAgent>,
2812    /// Fatal errors from agent loading
2813    pub errors: Vec<String>,
2814    /// Non-fatal warnings from agent loading
2815    pub warnings: Vec<String>,
2816}
2817
2818/// Schema for the `McpServersLoadedServer` type.
2819#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2820#[serde(rename_all = "camelCase")]
2821pub struct McpServersLoadedServer {
2822    /// Error message if the server failed to connect
2823    #[serde(skip_serializing_if = "Option::is_none")]
2824    pub error: Option<String>,
2825    /// Server name (config key)
2826    pub name: String,
2827    /// Configuration source: user, workspace, plugin, or builtin
2828    #[serde(skip_serializing_if = "Option::is_none")]
2829    pub source: Option<McpServerSource>,
2830    /// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
2831    pub status: McpServerStatus,
2832}
2833
2834/// Session event "session.mcp_servers_loaded".
2835#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2836#[serde(rename_all = "camelCase")]
2837pub struct SessionMcpServersLoadedData {
2838    /// Array of MCP server status summaries
2839    pub servers: Vec<McpServersLoadedServer>,
2840}
2841
2842/// Session event "session.mcp_server_status_changed".
2843#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2844#[serde(rename_all = "camelCase")]
2845pub struct SessionMcpServerStatusChangedData {
2846    /// Name of the MCP server whose status changed
2847    pub server_name: String,
2848    /// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
2849    pub status: McpServerStatus,
2850}
2851
2852/// Schema for the `ExtensionsLoadedExtension` type.
2853#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2854#[serde(rename_all = "camelCase")]
2855pub struct ExtensionsLoadedExtension {
2856    /// Source-qualified extension ID (e.g., 'project:my-ext', 'user:auth-helper')
2857    pub id: String,
2858    /// Extension name (directory name)
2859    pub name: String,
2860    /// Discovery source
2861    pub source: ExtensionsLoadedExtensionSource,
2862    /// Current status: running, disabled, failed, or starting
2863    pub status: ExtensionsLoadedExtensionStatus,
2864}
2865
2866/// Session event "session.extensions_loaded".
2867#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2868#[serde(rename_all = "camelCase")]
2869pub struct SessionExtensionsLoadedData {
2870    /// Array of discovered extensions and their status
2871    pub extensions: Vec<ExtensionsLoadedExtension>,
2872}
2873
2874/// Hosting platform type of the repository (github or ado)
2875#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
2876pub enum WorkingDirectoryContextHostType {
2877    /// Repository is hosted on GitHub.
2878    #[serde(rename = "github")]
2879    Github,
2880    /// Repository is hosted on Azure DevOps.
2881    #[serde(rename = "ado")]
2882    Ado,
2883    /// Unknown variant for forward compatibility.
2884    #[default]
2885    #[serde(other)]
2886    Unknown,
2887}
2888
2889/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
2890#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
2891pub enum ReasoningSummary {
2892    /// Do not request reasoning summaries from the model.
2893    #[serde(rename = "none")]
2894    None,
2895    /// Request a concise summary of the model's reasoning.
2896    #[serde(rename = "concise")]
2897    Concise,
2898    /// Request a detailed summary of the model's reasoning.
2899    #[serde(rename = "detailed")]
2900    Detailed,
2901    /// Unknown variant for forward compatibility.
2902    #[default]
2903    #[serde(other)]
2904    Unknown,
2905}
2906
2907/// The session mode the agent is operating in
2908#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
2909pub enum SessionMode {
2910    /// The agent is responding interactively to the user.
2911    #[serde(rename = "interactive")]
2912    Interactive,
2913    /// The agent is preparing a plan before making changes.
2914    #[serde(rename = "plan")]
2915    Plan,
2916    /// The agent is working autonomously toward task completion.
2917    #[serde(rename = "autopilot")]
2918    Autopilot,
2919    /// Unknown variant for forward compatibility.
2920    #[default]
2921    #[serde(other)]
2922    Unknown,
2923}
2924
2925/// The type of operation performed on the plan file
2926#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
2927pub enum PlanChangedOperation {
2928    /// The plan file was created.
2929    #[serde(rename = "create")]
2930    Create,
2931    /// The plan file was updated.
2932    #[serde(rename = "update")]
2933    Update,
2934    /// The plan file was deleted.
2935    #[serde(rename = "delete")]
2936    Delete,
2937    /// Unknown variant for forward compatibility.
2938    #[default]
2939    #[serde(other)]
2940    Unknown,
2941}
2942
2943/// Whether the file was newly created or updated
2944#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
2945pub enum WorkspaceFileChangedOperation {
2946    /// The workspace file was created.
2947    #[serde(rename = "create")]
2948    Create,
2949    /// The workspace file was updated.
2950    #[serde(rename = "update")]
2951    Update,
2952    /// Unknown variant for forward compatibility.
2953    #[default]
2954    #[serde(other)]
2955    Unknown,
2956}
2957
2958/// Origin type of the session being handed off
2959#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
2960pub enum HandoffSourceType {
2961    /// The handoff originated from a remote session.
2962    #[serde(rename = "remote")]
2963    Remote,
2964    /// The handoff originated from a local session.
2965    #[serde(rename = "local")]
2966    Local,
2967    /// Unknown variant for forward compatibility.
2968    #[default]
2969    #[serde(other)]
2970    Unknown,
2971}
2972
2973/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
2974#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
2975pub enum ShutdownType {
2976    /// The session ended normally.
2977    #[serde(rename = "routine")]
2978    Routine,
2979    /// The session ended because of a crash or fatal error.
2980    #[serde(rename = "error")]
2981    Error,
2982    /// Unknown variant for forward compatibility.
2983    #[default]
2984    #[serde(other)]
2985    Unknown,
2986}
2987
2988/// The agent mode that was active when this message was sent
2989#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
2990pub enum UserMessageAgentMode {
2991    /// The agent is responding interactively to the user.
2992    #[serde(rename = "interactive")]
2993    Interactive,
2994    /// The agent is preparing a plan before making changes.
2995    #[serde(rename = "plan")]
2996    Plan,
2997    /// The agent is working autonomously toward task completion.
2998    #[serde(rename = "autopilot")]
2999    Autopilot,
3000    /// The agent is in shell-focused UI mode.
3001    #[serde(rename = "shell")]
3002    Shell,
3003    /// Unknown variant for forward compatibility.
3004    #[default]
3005    #[serde(other)]
3006    Unknown,
3007}
3008
3009/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
3010#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3011pub enum AssistantMessageToolRequestType {
3012    /// Standard function-style tool call.
3013    #[serde(rename = "function")]
3014    Function,
3015    /// Custom grammar-based tool call.
3016    #[serde(rename = "custom")]
3017    Custom,
3018    /// Unknown variant for forward compatibility.
3019    #[default]
3020    #[serde(other)]
3021    Unknown,
3022}
3023
3024/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
3025#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3026pub enum AssistantUsageApiEndpoint {
3027    /// Chat Completions API endpoint.
3028    #[serde(rename = "/chat/completions")]
3029    ChatCompletions,
3030    /// Anthropic Messages API endpoint.
3031    #[serde(rename = "/v1/messages")]
3032    V1Messages,
3033    /// Responses API endpoint.
3034    #[serde(rename = "/responses")]
3035    Responses,
3036    /// WebSocket Responses API endpoint.
3037    #[serde(rename = "ws:/responses")]
3038    WsResponses,
3039    /// Unknown variant for forward compatibility.
3040    #[default]
3041    #[serde(other)]
3042    Unknown,
3043}
3044
3045/// Where the failed model call originated
3046#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3047pub enum ModelCallFailureSource {
3048    /// Model call from the top-level agent.
3049    #[serde(rename = "top_level")]
3050    TopLevel,
3051    /// Model call from a sub-agent.
3052    #[serde(rename = "subagent")]
3053    Subagent,
3054    /// Model call from MCP sampling.
3055    #[serde(rename = "mcp_sampling")]
3056    McpSampling,
3057    /// Unknown variant for forward compatibility.
3058    #[default]
3059    #[serde(other)]
3060    Unknown,
3061}
3062
3063/// Finite reason code describing why the current turn was aborted
3064#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3065pub enum AbortReason {
3066    /// The local user requested the abort, for example by pressing Ctrl+C in the CLI.
3067    #[serde(rename = "user_initiated")]
3068    UserInitiated,
3069    /// A remote command requested the abort.
3070    #[serde(rename = "remote_command")]
3071    RemoteCommand,
3072    /// An MCP server delivered a user.abort notification.
3073    #[serde(rename = "user_abort")]
3074    UserAbort,
3075    /// Unknown variant for forward compatibility.
3076    #[default]
3077    #[serde(other)]
3078    Unknown,
3079}
3080
3081/// Content block type discriminator
3082#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3083pub enum ToolExecutionCompleteContentTextType {
3084    #[serde(rename = "text")]
3085    #[default]
3086    Text,
3087}
3088
3089/// Content block type discriminator
3090#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3091pub enum ToolExecutionCompleteContentTerminalType {
3092    #[serde(rename = "terminal")]
3093    #[default]
3094    Terminal,
3095}
3096
3097/// Content block type discriminator
3098#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3099pub enum ToolExecutionCompleteContentImageType {
3100    #[serde(rename = "image")]
3101    #[default]
3102    Image,
3103}
3104
3105/// Content block type discriminator
3106#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3107pub enum ToolExecutionCompleteContentAudioType {
3108    #[serde(rename = "audio")]
3109    #[default]
3110    Audio,
3111}
3112
3113/// Theme variant this icon is intended for
3114#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3115pub enum ToolExecutionCompleteContentResourceLinkIconTheme {
3116    /// Icon intended for light themes.
3117    #[serde(rename = "light")]
3118    Light,
3119    /// Icon intended for dark themes.
3120    #[serde(rename = "dark")]
3121    Dark,
3122    /// Unknown variant for forward compatibility.
3123    #[default]
3124    #[serde(other)]
3125    Unknown,
3126}
3127
3128/// Content block type discriminator
3129#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3130pub enum ToolExecutionCompleteContentResourceLinkType {
3131    #[serde(rename = "resource_link")]
3132    #[default]
3133    ResourceLink,
3134}
3135
3136/// The embedded resource contents, either text or base64-encoded binary
3137#[derive(Debug, Clone, Serialize, Deserialize)]
3138#[serde(untagged)]
3139pub enum ToolExecutionCompleteContentResourceDetails {
3140    EmbeddedTextResourceContents(EmbeddedTextResourceContents),
3141    EmbeddedBlobResourceContents(EmbeddedBlobResourceContents),
3142}
3143
3144/// Content block type discriminator
3145#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3146pub enum ToolExecutionCompleteContentResourceType {
3147    #[serde(rename = "resource")]
3148    #[default]
3149    Resource,
3150}
3151
3152/// A content block within a tool result, which may be text, terminal output, image, audio, or a resource
3153#[derive(Debug, Clone, Serialize, Deserialize)]
3154#[serde(untagged)]
3155pub enum ToolExecutionCompleteContent {
3156    Text(ToolExecutionCompleteContentText),
3157    Terminal(ToolExecutionCompleteContentTerminal),
3158    Image(ToolExecutionCompleteContentImage),
3159    Audio(ToolExecutionCompleteContentAudio),
3160    ResourceLink(ToolExecutionCompleteContentResourceLink),
3161    Resource(ToolExecutionCompleteContentResource),
3162}
3163
3164/// Message role: "system" for system prompts, "developer" for developer-injected instructions
3165#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3166pub enum SystemMessageRole {
3167    /// System prompt message.
3168    #[serde(rename = "system")]
3169    System,
3170    /// Developer instruction message.
3171    #[serde(rename = "developer")]
3172    Developer,
3173    /// Unknown variant for forward compatibility.
3174    #[default]
3175    #[serde(other)]
3176    Unknown,
3177}
3178
3179/// Permission kind discriminator
3180#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3181pub enum PermissionRequestShellKind {
3182    #[serde(rename = "shell")]
3183    #[default]
3184    Shell,
3185}
3186
3187/// Permission kind discriminator
3188#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3189pub enum PermissionRequestWriteKind {
3190    #[serde(rename = "write")]
3191    #[default]
3192    Write,
3193}
3194
3195/// Permission kind discriminator
3196#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3197pub enum PermissionRequestReadKind {
3198    #[serde(rename = "read")]
3199    #[default]
3200    Read,
3201}
3202
3203/// Permission kind discriminator
3204#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3205pub enum PermissionRequestMcpKind {
3206    #[serde(rename = "mcp")]
3207    #[default]
3208    Mcp,
3209}
3210
3211/// Permission kind discriminator
3212#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3213pub enum PermissionRequestUrlKind {
3214    #[serde(rename = "url")]
3215    #[default]
3216    Url,
3217}
3218
3219/// Whether this is a store or vote memory operation
3220#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3221pub enum PermissionRequestMemoryAction {
3222    /// Store a new memory.
3223    #[serde(rename = "store")]
3224    Store,
3225    /// Vote on an existing memory.
3226    #[serde(rename = "vote")]
3227    Vote,
3228    /// Unknown variant for forward compatibility.
3229    #[default]
3230    #[serde(other)]
3231    Unknown,
3232}
3233
3234/// Vote direction (vote only)
3235#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3236pub enum PermissionRequestMemoryDirection {
3237    /// Vote that the memory is useful or accurate.
3238    #[serde(rename = "upvote")]
3239    Upvote,
3240    /// Vote that the memory is incorrect or outdated.
3241    #[serde(rename = "downvote")]
3242    Downvote,
3243    /// Unknown variant for forward compatibility.
3244    #[default]
3245    #[serde(other)]
3246    Unknown,
3247}
3248
3249/// Permission kind discriminator
3250#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3251pub enum PermissionRequestMemoryKind {
3252    #[serde(rename = "memory")]
3253    #[default]
3254    Memory,
3255}
3256
3257/// Permission kind discriminator
3258#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3259pub enum PermissionRequestCustomToolKind {
3260    #[serde(rename = "custom-tool")]
3261    #[default]
3262    CustomTool,
3263}
3264
3265/// Permission kind discriminator
3266#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3267pub enum PermissionRequestHookKind {
3268    #[serde(rename = "hook")]
3269    #[default]
3270    Hook,
3271}
3272
3273/// Permission kind discriminator
3274#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3275pub enum PermissionRequestExtensionManagementKind {
3276    #[serde(rename = "extension-management")]
3277    #[default]
3278    ExtensionManagement,
3279}
3280
3281/// Permission kind discriminator
3282#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3283pub enum PermissionRequestExtensionPermissionAccessKind {
3284    #[serde(rename = "extension-permission-access")]
3285    #[default]
3286    ExtensionPermissionAccess,
3287}
3288
3289/// Details of the permission being requested
3290#[derive(Debug, Clone, Serialize, Deserialize)]
3291#[serde(untagged)]
3292pub enum PermissionRequest {
3293    Shell(PermissionRequestShell),
3294    Write(PermissionRequestWrite),
3295    Read(PermissionRequestRead),
3296    Mcp(PermissionRequestMcp),
3297    Url(PermissionRequestUrl),
3298    Memory(PermissionRequestMemory),
3299    CustomTool(PermissionRequestCustomTool),
3300    Hook(PermissionRequestHook),
3301    ExtensionManagement(PermissionRequestExtensionManagement),
3302    ExtensionPermissionAccess(PermissionRequestExtensionPermissionAccess),
3303}
3304
3305/// Prompt kind discriminator
3306#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3307pub enum PermissionPromptRequestCommandsKind {
3308    #[serde(rename = "commands")]
3309    #[default]
3310    Commands,
3311}
3312
3313/// Prompt kind discriminator
3314#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3315pub enum PermissionPromptRequestWriteKind {
3316    #[serde(rename = "write")]
3317    #[default]
3318    Write,
3319}
3320
3321/// Prompt kind discriminator
3322#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3323pub enum PermissionPromptRequestReadKind {
3324    #[serde(rename = "read")]
3325    #[default]
3326    Read,
3327}
3328
3329/// Prompt kind discriminator
3330#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3331pub enum PermissionPromptRequestMcpKind {
3332    #[serde(rename = "mcp")]
3333    #[default]
3334    Mcp,
3335}
3336
3337/// Prompt kind discriminator
3338#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3339pub enum PermissionPromptRequestUrlKind {
3340    #[serde(rename = "url")]
3341    #[default]
3342    Url,
3343}
3344
3345/// Prompt kind discriminator
3346#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3347pub enum PermissionPromptRequestMemoryKind {
3348    #[serde(rename = "memory")]
3349    #[default]
3350    Memory,
3351}
3352
3353/// Prompt kind discriminator
3354#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3355pub enum PermissionPromptRequestCustomToolKind {
3356    #[serde(rename = "custom-tool")]
3357    #[default]
3358    CustomTool,
3359}
3360
3361/// Underlying permission kind that needs path approval
3362#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3363pub enum PermissionPromptRequestPathAccessKind {
3364    /// Read access to a filesystem path.
3365    #[serde(rename = "read")]
3366    Read,
3367    /// Shell command access involving a filesystem path.
3368    #[serde(rename = "shell")]
3369    Shell,
3370    /// Write access to a filesystem path.
3371    #[serde(rename = "write")]
3372    Write,
3373    /// Unknown variant for forward compatibility.
3374    #[default]
3375    #[serde(other)]
3376    Unknown,
3377}
3378
3379/// Prompt kind discriminator
3380#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3381pub enum PermissionPromptRequestPathKind {
3382    #[serde(rename = "path")]
3383    #[default]
3384    Path,
3385}
3386
3387/// Prompt kind discriminator
3388#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3389pub enum PermissionPromptRequestHookKind {
3390    #[serde(rename = "hook")]
3391    #[default]
3392    Hook,
3393}
3394
3395/// Prompt kind discriminator
3396#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3397pub enum PermissionPromptRequestExtensionManagementKind {
3398    #[serde(rename = "extension-management")]
3399    #[default]
3400    ExtensionManagement,
3401}
3402
3403/// Prompt kind discriminator
3404#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3405pub enum PermissionPromptRequestExtensionPermissionAccessKind {
3406    #[serde(rename = "extension-permission-access")]
3407    #[default]
3408    ExtensionPermissionAccess,
3409}
3410
3411/// Derived user-facing permission prompt details for UI consumers
3412#[derive(Debug, Clone, Serialize, Deserialize)]
3413#[serde(untagged)]
3414pub enum PermissionPromptRequest {
3415    Commands(PermissionPromptRequestCommands),
3416    Write(PermissionPromptRequestWrite),
3417    Read(PermissionPromptRequestRead),
3418    Mcp(PermissionPromptRequestMcp),
3419    Url(PermissionPromptRequestUrl),
3420    Memory(PermissionPromptRequestMemory),
3421    CustomTool(PermissionPromptRequestCustomTool),
3422    Path(PermissionPromptRequestPath),
3423    Hook(PermissionPromptRequestHook),
3424    ExtensionManagement(PermissionPromptRequestExtensionManagement),
3425    ExtensionPermissionAccess(PermissionPromptRequestExtensionPermissionAccess),
3426}
3427
3428/// The permission request was approved
3429#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3430pub enum PermissionApprovedKind {
3431    #[serde(rename = "approved")]
3432    #[default]
3433    Approved,
3434}
3435
3436/// Command approval kind
3437#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3438pub enum UserToolSessionApprovalCommandsKind {
3439    #[serde(rename = "commands")]
3440    #[default]
3441    Commands,
3442}
3443
3444/// Read approval kind
3445#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3446pub enum UserToolSessionApprovalReadKind {
3447    #[serde(rename = "read")]
3448    #[default]
3449    Read,
3450}
3451
3452/// Write approval kind
3453#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3454pub enum UserToolSessionApprovalWriteKind {
3455    #[serde(rename = "write")]
3456    #[default]
3457    Write,
3458}
3459
3460/// MCP tool approval kind
3461#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3462pub enum UserToolSessionApprovalMcpKind {
3463    #[serde(rename = "mcp")]
3464    #[default]
3465    Mcp,
3466}
3467
3468/// Memory approval kind
3469#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3470pub enum UserToolSessionApprovalMemoryKind {
3471    #[serde(rename = "memory")]
3472    #[default]
3473    Memory,
3474}
3475
3476/// Custom tool approval kind
3477#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3478pub enum UserToolSessionApprovalCustomToolKind {
3479    #[serde(rename = "custom-tool")]
3480    #[default]
3481    CustomTool,
3482}
3483
3484/// Extension management approval kind
3485#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3486pub enum UserToolSessionApprovalExtensionManagementKind {
3487    #[serde(rename = "extension-management")]
3488    #[default]
3489    ExtensionManagement,
3490}
3491
3492/// Extension permission access approval kind
3493#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3494pub enum UserToolSessionApprovalExtensionPermissionAccessKind {
3495    #[serde(rename = "extension-permission-access")]
3496    #[default]
3497    ExtensionPermissionAccess,
3498}
3499
3500/// The approval to add as a session-scoped rule
3501#[derive(Debug, Clone, Serialize, Deserialize)]
3502#[serde(untagged)]
3503pub enum UserToolSessionApproval {
3504    Commands(UserToolSessionApprovalCommands),
3505    Read(UserToolSessionApprovalRead),
3506    Write(UserToolSessionApprovalWrite),
3507    Mcp(UserToolSessionApprovalMcp),
3508    Memory(UserToolSessionApprovalMemory),
3509    CustomTool(UserToolSessionApprovalCustomTool),
3510    ExtensionManagement(UserToolSessionApprovalExtensionManagement),
3511    ExtensionPermissionAccess(UserToolSessionApprovalExtensionPermissionAccess),
3512}
3513
3514/// Approved and remembered for the rest of the session
3515#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3516pub enum PermissionApprovedForSessionKind {
3517    #[serde(rename = "approved-for-session")]
3518    #[default]
3519    ApprovedForSession,
3520}
3521
3522/// Approved and persisted for this project location
3523#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3524pub enum PermissionApprovedForLocationKind {
3525    #[serde(rename = "approved-for-location")]
3526    #[default]
3527    ApprovedForLocation,
3528}
3529
3530/// The permission request was cancelled before a response was used
3531#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3532pub enum PermissionCancelledKind {
3533    #[serde(rename = "cancelled")]
3534    #[default]
3535    Cancelled,
3536}
3537
3538/// Denied because approval rules explicitly blocked it
3539#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3540pub enum PermissionDeniedByRulesKind {
3541    #[serde(rename = "denied-by-rules")]
3542    #[default]
3543    DeniedByRules,
3544}
3545
3546/// Denied because no approval rule matched and user confirmation was unavailable
3547#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3548pub enum PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind {
3549    #[serde(rename = "denied-no-approval-rule-and-could-not-request-from-user")]
3550    #[default]
3551    DeniedNoApprovalRuleAndCouldNotRequestFromUser,
3552}
3553
3554/// Denied by the user during an interactive prompt
3555#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3556pub enum PermissionDeniedInteractivelyByUserKind {
3557    #[serde(rename = "denied-interactively-by-user")]
3558    #[default]
3559    DeniedInteractivelyByUser,
3560}
3561
3562/// Denied by the organization's content exclusion policy
3563#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3564pub enum PermissionDeniedByContentExclusionPolicyKind {
3565    #[serde(rename = "denied-by-content-exclusion-policy")]
3566    #[default]
3567    DeniedByContentExclusionPolicy,
3568}
3569
3570/// Denied by a permission request hook registered by an extension or plugin
3571#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3572pub enum PermissionDeniedByPermissionRequestHookKind {
3573    #[serde(rename = "denied-by-permission-request-hook")]
3574    #[default]
3575    DeniedByPermissionRequestHook,
3576}
3577
3578/// The result of the permission request
3579#[derive(Debug, Clone, Serialize, Deserialize)]
3580#[serde(untagged)]
3581pub enum PermissionResult {
3582    Approved(PermissionApproved),
3583    ApprovedForSession(PermissionApprovedForSession),
3584    ApprovedForLocation(PermissionApprovedForLocation),
3585    Cancelled(PermissionCancelled),
3586    DeniedByRules(PermissionDeniedByRules),
3587    DeniedNoApprovalRuleAndCouldNotRequestFromUser(
3588        PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser,
3589    ),
3590    DeniedInteractivelyByUser(PermissionDeniedInteractivelyByUser),
3591    DeniedByContentExclusionPolicy(PermissionDeniedByContentExclusionPolicy),
3592    DeniedByPermissionRequestHook(PermissionDeniedByPermissionRequestHook),
3593}
3594
3595/// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
3596#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3597pub enum ElicitationRequestedMode {
3598    /// Structured form-based elicitation.
3599    #[serde(rename = "form")]
3600    Form,
3601    /// Browser URL-based elicitation.
3602    #[serde(rename = "url")]
3603    Url,
3604    /// Unknown variant for forward compatibility.
3605    #[default]
3606    #[serde(other)]
3607    Unknown,
3608}
3609
3610/// Schema type indicator (always 'object')
3611#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3612pub enum ElicitationRequestedSchemaType {
3613    #[serde(rename = "object")]
3614    #[default]
3615    Object,
3616}
3617
3618/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
3619#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3620pub enum ElicitationCompletedAction {
3621    /// The user submitted the requested form.
3622    #[serde(rename = "accept")]
3623    Accept,
3624    /// The user explicitly declined the request.
3625    #[serde(rename = "decline")]
3626    Decline,
3627    /// The user dismissed the request.
3628    #[serde(rename = "cancel")]
3629    Cancel,
3630    /// Unknown variant for forward compatibility.
3631    #[default]
3632    #[serde(other)]
3633    Unknown,
3634}
3635
3636/// 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).
3637#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3638pub enum McpOauthRequiredStaticClientConfigGrantType {
3639    #[serde(rename = "client_credentials")]
3640    #[default]
3641    ClientCredentials,
3642}
3643
3644/// The user's auto-mode-switch choice
3645#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3646pub enum AutoModeSwitchResponse {
3647    /// Switch models for this request.
3648    #[serde(rename = "yes")]
3649    Yes,
3650    /// Switch models now and keep using the replacement automatically.
3651    #[serde(rename = "yes_always")]
3652    YesAlways,
3653    /// Do not switch models.
3654    #[serde(rename = "no")]
3655    No,
3656    /// Unknown variant for forward compatibility.
3657    #[default]
3658    #[serde(other)]
3659    Unknown,
3660}
3661
3662/// Exit plan mode action
3663#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3664pub enum ExitPlanModeAction {
3665    /// Exit plan mode without starting implementation.
3666    #[serde(rename = "exit_only")]
3667    ExitOnly,
3668    /// Exit plan mode and continue in interactive mode.
3669    #[serde(rename = "interactive")]
3670    Interactive,
3671    /// Exit plan mode and continue autonomously.
3672    #[serde(rename = "autopilot")]
3673    Autopilot,
3674    /// Exit plan mode and continue with parallel autonomous workers.
3675    #[serde(rename = "autopilot_fleet")]
3676    AutopilotFleet,
3677    /// Unknown variant for forward compatibility.
3678    #[default]
3679    #[serde(other)]
3680    Unknown,
3681}
3682
3683/// Source location type (e.g., project, personal-copilot, plugin, builtin)
3684#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3685pub enum SkillSource {
3686    /// Skill defined in the current project's skill directories.
3687    #[serde(rename = "project")]
3688    Project,
3689    /// Skill discovered from a parent directory in the current workspace tree.
3690    #[serde(rename = "inherited")]
3691    Inherited,
3692    /// Skill defined in the user's Copilot skill directory.
3693    #[serde(rename = "personal-copilot")]
3694    PersonalCopilot,
3695    /// Skill defined in the user's personal agents skill directory.
3696    #[serde(rename = "personal-agents")]
3697    PersonalAgents,
3698    /// Skill provided by an installed plugin.
3699    #[serde(rename = "plugin")]
3700    Plugin,
3701    /// Skill loaded from a configured custom skill directory.
3702    #[serde(rename = "custom")]
3703    Custom,
3704    /// Skill bundled with the runtime.
3705    #[serde(rename = "builtin")]
3706    Builtin,
3707    /// Unknown variant for forward compatibility.
3708    #[default]
3709    #[serde(other)]
3710    Unknown,
3711}
3712
3713/// Configuration source: user, workspace, plugin, or builtin
3714#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3715pub enum McpServerSource {
3716    /// Server configured in the user's global MCP configuration.
3717    #[serde(rename = "user")]
3718    User,
3719    /// Server configured by the current workspace.
3720    #[serde(rename = "workspace")]
3721    Workspace,
3722    /// Server contributed by an installed plugin.
3723    #[serde(rename = "plugin")]
3724    Plugin,
3725    /// Server bundled with the runtime.
3726    #[serde(rename = "builtin")]
3727    Builtin,
3728    /// Unknown variant for forward compatibility.
3729    #[default]
3730    #[serde(other)]
3731    Unknown,
3732}
3733
3734/// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
3735#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3736pub enum McpServerStatus {
3737    /// The server is connected and available.
3738    #[serde(rename = "connected")]
3739    Connected,
3740    /// The server failed to connect or initialize.
3741    #[serde(rename = "failed")]
3742    Failed,
3743    /// The server requires authentication before it can connect.
3744    #[serde(rename = "needs-auth")]
3745    NeedsAuth,
3746    /// The server connection is still being established.
3747    #[serde(rename = "pending")]
3748    Pending,
3749    /// The server is configured but disabled.
3750    #[serde(rename = "disabled")]
3751    Disabled,
3752    /// The server is not configured for this session.
3753    #[serde(rename = "not_configured")]
3754    NotConfigured,
3755    /// Unknown variant for forward compatibility.
3756    #[default]
3757    #[serde(other)]
3758    Unknown,
3759}
3760
3761/// Discovery source
3762#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3763pub enum ExtensionsLoadedExtensionSource {
3764    /// Extension discovered from the current project.
3765    #[serde(rename = "project")]
3766    Project,
3767    /// Extension discovered from the user's extension directory.
3768    #[serde(rename = "user")]
3769    User,
3770    /// Unknown variant for forward compatibility.
3771    #[default]
3772    #[serde(other)]
3773    Unknown,
3774}
3775
3776/// Current status: running, disabled, failed, or starting
3777#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
3778pub enum ExtensionsLoadedExtensionStatus {
3779    /// The extension process is running.
3780    #[serde(rename = "running")]
3781    Running,
3782    /// The extension is installed but disabled.
3783    #[serde(rename = "disabled")]
3784    Disabled,
3785    /// The extension failed to start or crashed.
3786    #[serde(rename = "failed")]
3787    Failed,
3788    /// The extension process is starting.
3789    #[serde(rename = "starting")]
3790    Starting,
3791    /// Unknown variant for forward compatibility.
3792    #[default]
3793    #[serde(other)]
3794    Unknown,
3795}