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