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