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