Skip to main content

github_copilot_sdk/generated/
session_events.rs

1//! Auto-generated from session-events.schema.json — do not edit manually.
2
3#![allow(deprecated)]
4
5use std::collections::HashMap;
6
7use serde::{Deserialize, Serialize};
8
9use crate::types::{RequestId, SessionId};
10
11/// Identifies the kind of session event.
12#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
13pub enum SessionEventType {
14    #[serde(rename = "session.start")]
15    SessionStart,
16    #[serde(rename = "session.resume")]
17    SessionResume,
18    #[serde(rename = "session.remote_steerable_changed")]
19    SessionRemoteSteerableChanged,
20    #[serde(rename = "session.error")]
21    SessionError,
22    #[serde(rename = "session.idle")]
23    SessionIdle,
24    #[serde(rename = "session.title_changed")]
25    SessionTitleChanged,
26    #[serde(rename = "session.schedule_created")]
27    SessionScheduleCreated,
28    #[serde(rename = "session.schedule_cancelled")]
29    SessionScheduleCancelled,
30    #[serde(rename = "session.schedule_rearmed")]
31    SessionScheduleRearmed,
32    #[serde(rename = "session.autopilot_objective_changed")]
33    SessionAutopilotObjectiveChanged,
34    #[serde(rename = "session.info")]
35    SessionInfo,
36    #[serde(rename = "session.warning")]
37    SessionWarning,
38    #[serde(rename = "session.model_change")]
39    SessionModelChange,
40    #[serde(rename = "session.mode_changed")]
41    SessionModeChanged,
42    #[serde(rename = "session.session_limits_changed")]
43    SessionSessionLimitsChanged,
44    #[serde(rename = "session.permissions_changed")]
45    SessionPermissionsChanged,
46    #[serde(rename = "session.plan_changed")]
47    SessionPlanChanged,
48    #[serde(rename = "session.todos_changed")]
49    SessionTodosChanged,
50    #[serde(rename = "session.workspace_file_changed")]
51    SessionWorkspaceFileChanged,
52    #[serde(rename = "session.handoff")]
53    SessionHandoff,
54    #[serde(rename = "session.truncation")]
55    SessionTruncation,
56    #[serde(rename = "session.snapshot_rewind")]
57    SessionSnapshotRewind,
58    #[serde(rename = "session.shutdown")]
59    SessionShutdown,
60    #[serde(rename = "session.usage_checkpoint")]
61    SessionUsageCheckpoint,
62    #[serde(rename = "session.context_changed")]
63    SessionContextChanged,
64    #[serde(rename = "session.usage_info")]
65    SessionUsageInfo,
66    #[serde(rename = "session.context_cleared")]
67    SessionContextCleared,
68    #[serde(rename = "session.compaction_start")]
69    SessionCompactionStart,
70    #[serde(rename = "session.compaction_complete")]
71    SessionCompactionComplete,
72    #[serde(rename = "session.task_complete")]
73    SessionTaskComplete,
74    #[serde(rename = "user.message")]
75    UserMessage,
76    #[serde(rename = "pending_messages.modified")]
77    PendingMessagesModified,
78    #[serde(rename = "assistant.turn_start")]
79    AssistantTurnStart,
80    #[serde(rename = "assistant.turn_retry")]
81    AssistantTurnRetry,
82    #[serde(rename = "assistant.intent")]
83    AssistantIntent,
84    #[serde(rename = "assistant.server_tool_progress")]
85    AssistantServerToolProgress,
86    #[serde(rename = "assistant.reasoning")]
87    AssistantReasoning,
88    #[serde(rename = "assistant.reasoning_delta")]
89    AssistantReasoningDelta,
90    #[serde(rename = "assistant.tool_call_delta")]
91    AssistantToolCallDelta,
92    #[serde(rename = "assistant.streaming_delta")]
93    AssistantStreamingDelta,
94    #[serde(rename = "assistant.message")]
95    AssistantMessage,
96    #[serde(rename = "assistant.message_start")]
97    AssistantMessageStart,
98    #[serde(rename = "assistant.message_delta")]
99    AssistantMessageDelta,
100    #[serde(rename = "assistant.turn_end")]
101    AssistantTurnEnd,
102    #[serde(rename = "assistant.idle")]
103    AssistantIdle,
104    #[serde(rename = "assistant.usage")]
105    AssistantUsage,
106    #[serde(rename = "model.call_failure")]
107    ModelCallFailure,
108    #[serde(rename = "model.call_start")]
109    ModelCallStart,
110    #[serde(rename = "abort")]
111    Abort,
112    #[serde(rename = "tool.user_requested")]
113    ToolUserRequested,
114    #[serde(rename = "tool.execution_start")]
115    ToolExecutionStart,
116    #[serde(rename = "tool.execution_partial_result")]
117    ToolExecutionPartialResult,
118    #[serde(rename = "tool.execution_progress")]
119    ToolExecutionProgress,
120    #[serde(rename = "tool.execution_complete")]
121    ToolExecutionComplete,
122    #[serde(rename = "tool_search.activated")]
123    ToolSearchActivated,
124    #[serde(rename = "skill.invoked")]
125    SkillInvoked,
126    #[serde(rename = "subagent.started")]
127    SubagentStarted,
128    #[serde(rename = "subagent.completed")]
129    SubagentCompleted,
130    #[serde(rename = "subagent.failed")]
131    SubagentFailed,
132    #[serde(rename = "subagent.selected")]
133    SubagentSelected,
134    #[serde(rename = "subagent.deselected")]
135    SubagentDeselected,
136    #[serde(rename = "hook.start")]
137    HookStart,
138    #[serde(rename = "hook.end")]
139    HookEnd,
140    #[serde(rename = "hook.progress")]
141    HookProgress,
142    ///
143    /// <div class="warning">
144    ///
145    /// **Experimental.** This type is part of an experimental wire-protocol surface
146    /// and may change or be removed in future SDK or CLI releases.
147    ///
148    /// </div>
149    #[serde(rename = "session.binary_asset")]
150    SessionBinaryAsset,
151    #[serde(rename = "system.message")]
152    SystemMessage,
153    #[serde(rename = "system.notification")]
154    SystemNotification,
155    #[serde(rename = "permission.requested")]
156    PermissionRequested,
157    #[serde(rename = "permission.completed")]
158    PermissionCompleted,
159    #[serde(rename = "user_input.requested")]
160    UserInputRequested,
161    #[serde(rename = "user_input.completed")]
162    UserInputCompleted,
163    #[serde(rename = "elicitation.requested")]
164    ElicitationRequested,
165    #[serde(rename = "elicitation.completed")]
166    ElicitationCompleted,
167    #[serde(rename = "sampling.requested")]
168    SamplingRequested,
169    #[serde(rename = "sampling.completed")]
170    SamplingCompleted,
171    #[serde(rename = "mcp.oauth_required")]
172    McpOauthRequired,
173    #[serde(rename = "mcp.oauth_completed")]
174    McpOauthCompleted,
175    #[serde(rename = "mcp.headers_refresh_required")]
176    McpHeadersRefreshRequired,
177    #[serde(rename = "mcp.headers_refresh_completed")]
178    McpHeadersRefreshCompleted,
179    #[serde(rename = "session.custom_notification")]
180    SessionCustomNotification,
181    #[serde(rename = "external_tool.requested")]
182    ExternalToolRequested,
183    #[serde(rename = "external_tool.completed")]
184    ExternalToolCompleted,
185    #[serde(rename = "command.queued")]
186    CommandQueued,
187    #[serde(rename = "command.execute")]
188    CommandExecute,
189    #[serde(rename = "command.completed")]
190    CommandCompleted,
191    #[serde(rename = "auto_mode_switch.requested")]
192    AutoModeSwitchRequested,
193    #[serde(rename = "auto_mode_switch.completed")]
194    AutoModeSwitchCompleted,
195    #[serde(rename = "session_limits_exhausted.requested")]
196    SessionLimitsExhaustedRequested,
197    #[serde(rename = "session_limits_exhausted.completed")]
198    SessionLimitsExhaustedCompleted,
199    ///
200    /// <div class="warning">
201    ///
202    /// **Experimental.** This type is part of an experimental wire-protocol surface
203    /// and may change or be removed in future SDK or CLI releases.
204    ///
205    /// </div>
206    #[serde(rename = "session.auto_mode_resolved")]
207    SessionAutoModeResolved,
208    ///
209    /// <div class="warning">
210    ///
211    /// **Experimental.** This type is part of an experimental wire-protocol surface
212    /// and may change or be removed in future SDK or CLI releases.
213    ///
214    /// </div>
215    #[serde(rename = "session.managed_settings_resolved")]
216    SessionManagedSettingsResolved,
217    ///
218    /// <div class="warning">
219    ///
220    /// **Experimental.** This type is part of an experimental wire-protocol surface
221    /// and may change or be removed in future SDK or CLI releases.
222    ///
223    /// </div>
224    #[serde(rename = "session.managed_settings_enforced")]
225    SessionManagedSettingsEnforced,
226    #[serde(rename = "commands.changed")]
227    CommandsChanged,
228    #[serde(rename = "capabilities.changed")]
229    CapabilitiesChanged,
230    #[serde(rename = "exit_plan_mode.requested")]
231    ExitPlanModeRequested,
232    #[serde(rename = "exit_plan_mode.completed")]
233    ExitPlanModeCompleted,
234    #[serde(rename = "session.tools_updated")]
235    SessionToolsUpdated,
236    #[serde(rename = "session.background_tasks_changed")]
237    SessionBackgroundTasksChanged,
238    ///
239    /// <div class="warning">
240    ///
241    /// **Experimental.** This type is part of an experimental wire-protocol surface
242    /// and may change or be removed in future SDK or CLI releases.
243    ///
244    /// </div>
245    #[serde(rename = "factory.run_updated")]
246    FactoryRunUpdated,
247    #[serde(rename = "session.skills_loaded")]
248    SessionSkillsLoaded,
249    #[serde(rename = "session.custom_agents_updated")]
250    SessionCustomAgentsUpdated,
251    #[serde(rename = "session.mcp_servers_loaded")]
252    SessionMcpServersLoaded,
253    #[serde(rename = "session.mcp_server_status_changed")]
254    SessionMcpServerStatusChanged,
255    #[serde(rename = "mcp.tools.list_changed")]
256    McpToolsListChanged,
257    #[serde(rename = "mcp.resources.list_changed")]
258    McpResourcesListChanged,
259    #[serde(rename = "mcp.prompts.list_changed")]
260    McpPromptsListChanged,
261    #[serde(rename = "session.extensions_loaded")]
262    SessionExtensionsLoaded,
263    ///
264    /// <div class="warning">
265    ///
266    /// **Experimental.** This type is part of an experimental wire-protocol surface
267    /// and may change or be removed in future SDK or CLI releases.
268    ///
269    /// </div>
270    #[serde(rename = "session.canvas.opened")]
271    SessionCanvasOpened,
272    ///
273    /// <div class="warning">
274    ///
275    /// **Experimental.** This type is part of an experimental wire-protocol surface
276    /// and may change or be removed in future SDK or CLI releases.
277    ///
278    /// </div>
279    #[serde(rename = "session.canvas.registry_changed")]
280    SessionCanvasRegistryChanged,
281    ///
282    /// <div class="warning">
283    ///
284    /// **Experimental.** This type is part of an experimental wire-protocol surface
285    /// and may change or be removed in future SDK or CLI releases.
286    ///
287    /// </div>
288    #[serde(rename = "session.canvas.closed")]
289    SessionCanvasClosed,
290    ///
291    /// <div class="warning">
292    ///
293    /// **Experimental.** This type is part of an experimental wire-protocol surface
294    /// and may change or be removed in future SDK or CLI releases.
295    ///
296    /// </div>
297    #[serde(rename = "session.canvas.unavailable")]
298    SessionCanvasUnavailable,
299    ///
300    /// <div class="warning">
301    ///
302    /// **Experimental.** This type is part of an experimental wire-protocol surface
303    /// and may change or be removed in future SDK or CLI releases.
304    ///
305    /// </div>
306    #[serde(rename = "session.canvas.recorded")]
307    SessionCanvasRecorded,
308    ///
309    /// <div class="warning">
310    ///
311    /// **Experimental.** This type is part of an experimental wire-protocol surface
312    /// and may change or be removed in future SDK or CLI releases.
313    ///
314    /// </div>
315    #[serde(rename = "session.canvas.removed")]
316    SessionCanvasRemoved,
317    #[serde(rename = "session.extensions.attachments_pushed")]
318    SessionExtensionsAttachmentsPushed,
319    #[serde(rename = "mcp_app.tool_call_complete")]
320    McpAppToolCallComplete,
321    /// Unknown event type for forward compatibility.
322    #[default]
323    #[serde(other)]
324    Unknown,
325}
326
327/// Typed session event data, discriminated by the event `type` field.
328///
329/// Use with [`TypedSessionEvent`] for fully typed event handling.
330#[derive(Debug, Clone, Serialize, Deserialize)]
331#[serde(tag = "type", content = "data")]
332pub enum SessionEventData {
333    #[serde(rename = "session.start")]
334    SessionStart(SessionStartData),
335    #[serde(rename = "session.resume")]
336    SessionResume(SessionResumeData),
337    #[serde(rename = "session.remote_steerable_changed")]
338    SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
339    #[serde(rename = "session.error")]
340    SessionError(SessionErrorData),
341    #[serde(rename = "session.idle")]
342    SessionIdle(SessionIdleData),
343    #[serde(rename = "session.title_changed")]
344    SessionTitleChanged(SessionTitleChangedData),
345    #[serde(rename = "session.schedule_created")]
346    SessionScheduleCreated(SessionScheduleCreatedData),
347    #[serde(rename = "session.schedule_cancelled")]
348    SessionScheduleCancelled(SessionScheduleCancelledData),
349    #[serde(rename = "session.schedule_rearmed")]
350    SessionScheduleRearmed(SessionScheduleRearmedData),
351    #[serde(rename = "session.autopilot_objective_changed")]
352    SessionAutopilotObjectiveChanged(SessionAutopilotObjectiveChangedData),
353    #[serde(rename = "session.info")]
354    SessionInfo(SessionInfoData),
355    #[serde(rename = "session.warning")]
356    SessionWarning(SessionWarningData),
357    #[serde(rename = "session.model_change")]
358    SessionModelChange(SessionModelChangeData),
359    #[serde(rename = "session.mode_changed")]
360    SessionModeChanged(SessionModeChangedData),
361    #[serde(rename = "session.session_limits_changed")]
362    SessionSessionLimitsChanged(SessionSessionLimitsChangedData),
363    #[serde(rename = "session.permissions_changed")]
364    SessionPermissionsChanged(SessionPermissionsChangedData),
365    #[serde(rename = "session.plan_changed")]
366    SessionPlanChanged(SessionPlanChangedData),
367    #[serde(rename = "session.todos_changed")]
368    SessionTodosChanged(SessionTodosChangedData),
369    #[serde(rename = "session.workspace_file_changed")]
370    SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
371    #[serde(rename = "session.handoff")]
372    SessionHandoff(SessionHandoffData),
373    #[serde(rename = "session.truncation")]
374    SessionTruncation(SessionTruncationData),
375    #[serde(rename = "session.snapshot_rewind")]
376    SessionSnapshotRewind(SessionSnapshotRewindData),
377    #[serde(rename = "session.shutdown")]
378    SessionShutdown(SessionShutdownData),
379    #[serde(rename = "session.usage_checkpoint")]
380    SessionUsageCheckpoint(SessionUsageCheckpointData),
381    #[serde(rename = "session.context_changed")]
382    SessionContextChanged(SessionContextChangedData),
383    #[serde(rename = "session.usage_info")]
384    SessionUsageInfo(SessionUsageInfoData),
385    #[serde(rename = "session.context_cleared")]
386    SessionContextCleared(SessionContextClearedData),
387    #[serde(rename = "session.compaction_start")]
388    SessionCompactionStart(SessionCompactionStartData),
389    #[serde(rename = "session.compaction_complete")]
390    SessionCompactionComplete(SessionCompactionCompleteData),
391    #[serde(rename = "session.task_complete")]
392    SessionTaskComplete(SessionTaskCompleteData),
393    #[serde(rename = "user.message")]
394    UserMessage(UserMessageData),
395    #[serde(rename = "pending_messages.modified")]
396    PendingMessagesModified(PendingMessagesModifiedData),
397    #[serde(rename = "assistant.turn_start")]
398    AssistantTurnStart(AssistantTurnStartData),
399    #[serde(rename = "assistant.turn_retry")]
400    AssistantTurnRetry(AssistantTurnRetryData),
401    #[serde(rename = "assistant.intent")]
402    AssistantIntent(AssistantIntentData),
403    #[serde(rename = "assistant.server_tool_progress")]
404    AssistantServerToolProgress(AssistantServerToolProgressData),
405    #[serde(rename = "assistant.reasoning")]
406    AssistantReasoning(AssistantReasoningData),
407    #[serde(rename = "assistant.reasoning_delta")]
408    AssistantReasoningDelta(AssistantReasoningDeltaData),
409    #[serde(rename = "assistant.tool_call_delta")]
410    AssistantToolCallDelta(AssistantToolCallDeltaData),
411    #[serde(rename = "assistant.streaming_delta")]
412    AssistantStreamingDelta(AssistantStreamingDeltaData),
413    #[serde(rename = "assistant.message")]
414    AssistantMessage(AssistantMessageData),
415    #[serde(rename = "assistant.message_start")]
416    AssistantMessageStart(AssistantMessageStartData),
417    #[serde(rename = "assistant.message_delta")]
418    AssistantMessageDelta(AssistantMessageDeltaData),
419    #[serde(rename = "assistant.turn_end")]
420    AssistantTurnEnd(AssistantTurnEndData),
421    #[serde(rename = "assistant.idle")]
422    AssistantIdle(AssistantIdleData),
423    #[serde(rename = "assistant.usage")]
424    AssistantUsage(AssistantUsageData),
425    #[serde(rename = "model.call_failure")]
426    ModelCallFailure(ModelCallFailureData),
427    #[serde(rename = "model.call_start")]
428    ModelCallStart(ModelCallStartData),
429    #[serde(rename = "abort")]
430    Abort(AbortData),
431    #[serde(rename = "tool.user_requested")]
432    ToolUserRequested(ToolUserRequestedData),
433    #[serde(rename = "tool.execution_start")]
434    ToolExecutionStart(ToolExecutionStartData),
435    #[serde(rename = "tool.execution_partial_result")]
436    ToolExecutionPartialResult(ToolExecutionPartialResultData),
437    #[serde(rename = "tool.execution_progress")]
438    ToolExecutionProgress(ToolExecutionProgressData),
439    #[serde(rename = "tool.execution_complete")]
440    ToolExecutionComplete(ToolExecutionCompleteData),
441    #[serde(rename = "tool_search.activated")]
442    ToolSearchActivated(ToolSearchActivatedData),
443    #[serde(rename = "skill.invoked")]
444    SkillInvoked(SkillInvokedData),
445    #[serde(rename = "subagent.started")]
446    SubagentStarted(SubagentStartedData),
447    #[serde(rename = "subagent.completed")]
448    SubagentCompleted(SubagentCompletedData),
449    #[serde(rename = "subagent.failed")]
450    SubagentFailed(SubagentFailedData),
451    #[serde(rename = "subagent.selected")]
452    SubagentSelected(SubagentSelectedData),
453    #[serde(rename = "subagent.deselected")]
454    SubagentDeselected(SubagentDeselectedData),
455    #[serde(rename = "hook.start")]
456    HookStart(HookStartData),
457    #[serde(rename = "hook.end")]
458    HookEnd(HookEndData),
459    #[serde(rename = "hook.progress")]
460    HookProgress(HookProgressData),
461    #[serde(rename = "session.binary_asset")]
462    SessionBinaryAsset(SessionBinaryAssetData),
463    #[serde(rename = "system.message")]
464    SystemMessage(SystemMessageData),
465    #[serde(rename = "system.notification")]
466    SystemNotification(SystemNotificationData),
467    #[serde(rename = "permission.requested")]
468    PermissionRequested(PermissionRequestedData),
469    #[serde(rename = "permission.completed")]
470    PermissionCompleted(PermissionCompletedData),
471    #[serde(rename = "user_input.requested")]
472    UserInputRequested(UserInputRequestedData),
473    #[serde(rename = "user_input.completed")]
474    UserInputCompleted(UserInputCompletedData),
475    #[serde(rename = "elicitation.requested")]
476    ElicitationRequested(ElicitationRequestedData),
477    #[serde(rename = "elicitation.completed")]
478    ElicitationCompleted(ElicitationCompletedData),
479    #[serde(rename = "sampling.requested")]
480    SamplingRequested(SamplingRequestedData),
481    #[serde(rename = "sampling.completed")]
482    SamplingCompleted(SamplingCompletedData),
483    #[serde(rename = "mcp.oauth_required")]
484    McpOauthRequired(McpOauthRequiredData),
485    #[serde(rename = "mcp.oauth_completed")]
486    McpOauthCompleted(McpOauthCompletedData),
487    #[serde(rename = "mcp.headers_refresh_required")]
488    McpHeadersRefreshRequired(McpHeadersRefreshRequiredData),
489    #[serde(rename = "mcp.headers_refresh_completed")]
490    McpHeadersRefreshCompleted(McpHeadersRefreshCompletedData),
491    #[serde(rename = "session.custom_notification")]
492    SessionCustomNotification(SessionCustomNotificationData),
493    #[serde(rename = "external_tool.requested")]
494    ExternalToolRequested(ExternalToolRequestedData),
495    #[serde(rename = "external_tool.completed")]
496    ExternalToolCompleted(ExternalToolCompletedData),
497    #[serde(rename = "command.queued")]
498    CommandQueued(CommandQueuedData),
499    #[serde(rename = "command.execute")]
500    CommandExecute(CommandExecuteData),
501    #[serde(rename = "command.completed")]
502    CommandCompleted(CommandCompletedData),
503    #[serde(rename = "auto_mode_switch.requested")]
504    AutoModeSwitchRequested(AutoModeSwitchRequestedData),
505    #[serde(rename = "auto_mode_switch.completed")]
506    AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
507    #[serde(rename = "session_limits_exhausted.requested")]
508    SessionLimitsExhaustedRequested(SessionLimitsExhaustedRequestedData),
509    #[serde(rename = "session_limits_exhausted.completed")]
510    SessionLimitsExhaustedCompleted(SessionLimitsExhaustedCompletedData),
511    ///
512    /// <div class="warning">
513    ///
514    /// **Experimental.** This type is part of an experimental wire-protocol surface
515    /// and may change or be removed in future SDK or CLI releases.
516    ///
517    /// </div>
518    #[serde(rename = "session.auto_mode_resolved")]
519    SessionAutoModeResolved(SessionAutoModeResolvedData),
520    ///
521    /// <div class="warning">
522    ///
523    /// **Experimental.** This type is part of an experimental wire-protocol surface
524    /// and may change or be removed in future SDK or CLI releases.
525    ///
526    /// </div>
527    #[serde(rename = "session.managed_settings_resolved")]
528    SessionManagedSettingsResolved(SessionManagedSettingsResolvedData),
529    ///
530    /// <div class="warning">
531    ///
532    /// **Experimental.** This type is part of an experimental wire-protocol surface
533    /// and may change or be removed in future SDK or CLI releases.
534    ///
535    /// </div>
536    #[serde(rename = "session.managed_settings_enforced")]
537    SessionManagedSettingsEnforced(SessionManagedSettingsEnforcedData),
538    #[serde(rename = "commands.changed")]
539    CommandsChanged(CommandsChangedData),
540    #[serde(rename = "capabilities.changed")]
541    CapabilitiesChanged(CapabilitiesChangedData),
542    #[serde(rename = "exit_plan_mode.requested")]
543    ExitPlanModeRequested(ExitPlanModeRequestedData),
544    #[serde(rename = "exit_plan_mode.completed")]
545    ExitPlanModeCompleted(ExitPlanModeCompletedData),
546    #[serde(rename = "session.tools_updated")]
547    SessionToolsUpdated(SessionToolsUpdatedData),
548    #[serde(rename = "session.background_tasks_changed")]
549    SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
550    ///
551    /// <div class="warning">
552    ///
553    /// **Experimental.** This type is part of an experimental wire-protocol surface
554    /// and may change or be removed in future SDK or CLI releases.
555    ///
556    /// </div>
557    #[serde(rename = "factory.run_updated")]
558    FactoryRunUpdated(FactoryRunUpdatedData),
559    #[serde(rename = "session.skills_loaded")]
560    SessionSkillsLoaded(SessionSkillsLoadedData),
561    #[serde(rename = "session.custom_agents_updated")]
562    SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
563    #[serde(rename = "session.mcp_servers_loaded")]
564    SessionMcpServersLoaded(SessionMcpServersLoadedData),
565    #[serde(rename = "session.mcp_server_status_changed")]
566    SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
567    #[serde(rename = "mcp.tools.list_changed")]
568    McpToolsListChanged(McpToolsListChangedData),
569    #[serde(rename = "mcp.resources.list_changed")]
570    McpResourcesListChanged(McpResourcesListChangedData),
571    #[serde(rename = "mcp.prompts.list_changed")]
572    McpPromptsListChanged(McpPromptsListChangedData),
573    #[serde(rename = "session.extensions_loaded")]
574    SessionExtensionsLoaded(SessionExtensionsLoadedData),
575    ///
576    /// <div class="warning">
577    ///
578    /// **Experimental.** This type is part of an experimental wire-protocol surface
579    /// and may change or be removed in future SDK or CLI releases.
580    ///
581    /// </div>
582    #[serde(rename = "session.canvas.opened")]
583    SessionCanvasOpened(SessionCanvasOpenedData),
584    ///
585    /// <div class="warning">
586    ///
587    /// **Experimental.** This type is part of an experimental wire-protocol surface
588    /// and may change or be removed in future SDK or CLI releases.
589    ///
590    /// </div>
591    #[serde(rename = "session.canvas.registry_changed")]
592    SessionCanvasRegistryChanged(SessionCanvasRegistryChangedData),
593    ///
594    /// <div class="warning">
595    ///
596    /// **Experimental.** This type is part of an experimental wire-protocol surface
597    /// and may change or be removed in future SDK or CLI releases.
598    ///
599    /// </div>
600    #[serde(rename = "session.canvas.closed")]
601    SessionCanvasClosed(SessionCanvasClosedData),
602    ///
603    /// <div class="warning">
604    ///
605    /// **Experimental.** This type is part of an experimental wire-protocol surface
606    /// and may change or be removed in future SDK or CLI releases.
607    ///
608    /// </div>
609    #[serde(rename = "session.canvas.unavailable")]
610    SessionCanvasUnavailable(SessionCanvasUnavailableData),
611    ///
612    /// <div class="warning">
613    ///
614    /// **Experimental.** This type is part of an experimental wire-protocol surface
615    /// and may change or be removed in future SDK or CLI releases.
616    ///
617    /// </div>
618    #[serde(rename = "session.canvas.recorded")]
619    SessionCanvasRecorded(SessionCanvasRecordedData),
620    ///
621    /// <div class="warning">
622    ///
623    /// **Experimental.** This type is part of an experimental wire-protocol surface
624    /// and may change or be removed in future SDK or CLI releases.
625    ///
626    /// </div>
627    #[serde(rename = "session.canvas.removed")]
628    SessionCanvasRemoved(SessionCanvasRemovedData),
629    #[serde(rename = "session.extensions.attachments_pushed")]
630    SessionExtensionsAttachmentsPushed(SessionExtensionsAttachmentsPushedData),
631    #[serde(rename = "mcp_app.tool_call_complete")]
632    McpAppToolCallComplete(McpAppToolCallCompleteData),
633}
634
635/// A session event with typed data payload.
636///
637/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
638/// are available directly. The event-specific data is in the `payload`
639/// field as a [`SessionEventData`] enum.
640#[derive(Debug, Clone, Serialize, Deserialize)]
641#[serde(rename_all = "camelCase")]
642pub struct TypedSessionEvent {
643    /// Unique event identifier (UUID v4).
644    pub id: String,
645    /// ISO 8601 timestamp when the event was created.
646    pub timestamp: String,
647    /// ID of the preceding event in the chain.
648    #[serde(skip_serializing_if = "Option::is_none")]
649    pub parent_id: Option<String>,
650    /// When true, the event is transient and not persisted.
651    #[serde(skip_serializing_if = "Option::is_none")]
652    pub ephemeral: Option<bool>,
653    /// Sub-agent instance identifier. Absent for events from the root /
654    /// main agent and session-level events.
655    #[serde(skip_serializing_if = "Option::is_none")]
656    pub agent_id: Option<String>,
657    /// The typed event payload (discriminated by event type).
658    #[serde(flatten)]
659    pub payload: SessionEventData,
660}
661
662/// Working directory and git context at session start
663#[derive(Debug, Clone, Default, Serialize, Deserialize)]
664#[serde(rename_all = "camelCase")]
665pub struct WorkingDirectoryContext {
666    /// Base commit of current git branch at session start time
667    #[serde(skip_serializing_if = "Option::is_none")]
668    pub base_commit: Option<String>,
669    /// Current git branch name
670    #[serde(skip_serializing_if = "Option::is_none")]
671    pub branch: Option<String>,
672    /// Current working directory path
673    pub cwd: String,
674    /// Root directory of the git repository, resolved via git rev-parse
675    #[serde(skip_serializing_if = "Option::is_none")]
676    pub git_root: Option<String>,
677    /// Head commit of current git branch at session start time
678    #[serde(skip_serializing_if = "Option::is_none")]
679    pub head_commit: Option<String>,
680    /// Hosting platform type of the repository (github or ado)
681    #[serde(skip_serializing_if = "Option::is_none")]
682    pub host_type: Option<WorkingDirectoryContextHostType>,
683    /// Set on the immediate preliminary event of a working-directory change, before the git context is resolved. A settled follow-up event (enriched with git context, or cwd-only for a non-repository) is always emitted afterward, so observers may defer to it. Absent on standalone/final events (e.g. relay context changes).
684    #[serde(skip_serializing_if = "Option::is_none")]
685    pub pending_git_context: Option<bool>,
686    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
687    #[serde(skip_serializing_if = "Option::is_none")]
688    pub repository: Option<String>,
689    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
690    #[serde(skip_serializing_if = "Option::is_none")]
691    pub repository_host: Option<String>,
692}
693
694/// Per-session configuration for the built-in GitHub MCP server
695#[derive(Debug, Clone, Default, Serialize, Deserialize)]
696#[serde(rename_all = "camelCase")]
697pub struct GitHubMcpToolConfig {
698    /// Additional GitHub MCP tools requested by the session
699    #[serde(skip_serializing_if = "Option::is_none")]
700    pub additional_tools: Option<Vec<String>>,
701    /// Additional GitHub MCP toolsets requested by the session
702    #[serde(skip_serializing_if = "Option::is_none")]
703    pub additional_toolsets: Option<Vec<String>>,
704    /// Whether to use the read-write endpoint and request all toolsets
705    #[serde(skip_serializing_if = "Option::is_none")]
706    pub enable_all_tools: Option<bool>,
707    /// Whether to request the GitHub MCP insiders build
708    #[serde(skip_serializing_if = "Option::is_none")]
709    pub enable_insiders_mode: Option<bool>,
710}
711
712/// Optional session limits.
713#[derive(Debug, Clone, Default, Serialize, Deserialize)]
714#[serde(rename_all = "camelCase")]
715pub struct SessionLimitsConfig {
716    /// Maximum AI Credits allowed across the session's current accounting window.
717    #[serde(skip_serializing_if = "Option::is_none")]
718    pub max_ai_credits: Option<f64>,
719}
720
721/// Session event "session.start". Session initialization metadata including context and configuration
722#[derive(Debug, Clone, Default, Serialize, Deserialize)]
723#[serde(rename_all = "camelCase")]
724pub struct SessionStartData {
725    /// Whether the session was already in use by another client at start time
726    #[serde(skip_serializing_if = "Option::is_none")]
727    pub already_in_use: Option<bool>,
728    /// Working directory and git context at session start
729    #[serde(skip_serializing_if = "Option::is_none")]
730    pub context: Option<WorkingDirectoryContext>,
731    /// Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
732    #[serde(skip_serializing_if = "Option::is_none")]
733    pub context_tier: Option<ContextTier>,
734    /// Version string of the Copilot application
735    pub copilot_version: String,
736    /// 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.
737    #[serde(skip_serializing_if = "Option::is_none")]
738    pub detached_from_spawning_parent_session_id: Option<String>,
739    /// Per-session GitHub MCP override persisted for cold resume
740    #[serde(skip_serializing_if = "Option::is_none")]
741    pub github_mcp_tool_config: Option<GitHubMcpToolConfig>,
742    /// Identifier of the software producing the events (e.g., "copilot-agent")
743    pub producer: String,
744    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
745    #[serde(skip_serializing_if = "Option::is_none")]
746    pub reasoning_effort: Option<String>,
747    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
748    #[serde(skip_serializing_if = "Option::is_none")]
749    pub reasoning_summary: Option<ReasoningSummary>,
750    /// Whether this session supports remote steering via GitHub
751    #[serde(skip_serializing_if = "Option::is_none")]
752    pub remote_steerable: Option<bool>,
753    /// Model selected at session creation time, if any
754    #[serde(skip_serializing_if = "Option::is_none")]
755    pub selected_model: Option<String>,
756    /// Unique identifier for the session
757    pub session_id: SessionId,
758    /// Session limits configured at session creation time, if any
759    #[serde(skip_serializing_if = "Option::is_none")]
760    pub session_limits: Option<SessionLimitsConfig>,
761    /// ISO 8601 timestamp when the session was created
762    pub start_time: String,
763    /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
764    #[serde(skip_serializing_if = "Option::is_none")]
765    pub verbosity: Option<Verbosity>,
766    /// Schema version number for the session event format
767    pub version: i64,
768}
769
770/// Session event "session.resume". Session resume metadata including current context and event count
771#[derive(Debug, Clone, Default, Serialize, Deserialize)]
772#[serde(rename_all = "camelCase")]
773pub struct SessionResumeData {
774    /// Whether the session was already in use by another client at resume time
775    #[serde(skip_serializing_if = "Option::is_none")]
776    pub already_in_use: Option<bool>,
777    /// Updated working directory and git context at resume time
778    #[serde(skip_serializing_if = "Option::is_none")]
779    pub context: Option<WorkingDirectoryContext>,
780    /// Context tier currently selected at resume time; null when no tier is active
781    #[serde(skip_serializing_if = "Option::is_none")]
782    pub context_tier: Option<ContextTier>,
783    /// 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 or omitted, pending work is normally marked as interrupted unless the resume passively joined live work owned by another client; sessionWasActive distinguishes that case.
784    #[serde(skip_serializing_if = "Option::is_none")]
785    pub continue_pending_work: Option<bool>,
786    /// Total number of persisted events in the session at the time of resume
787    pub event_count: i64,
788    /// On-disk byte size of the session's persisted events.jsonl file at resume time; omitted when the file does not exist or cannot be stat'd
789    #[serde(skip_serializing_if = "Option::is_none")]
790    pub events_file_size_bytes: Option<i64>,
791    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
792    #[serde(skip_serializing_if = "Option::is_none")]
793    pub reasoning_effort: Option<String>,
794    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
795    #[serde(skip_serializing_if = "Option::is_none")]
796    pub reasoning_summary: Option<ReasoningSummary>,
797    /// Whether this session supports remote steering via GitHub
798    #[serde(skip_serializing_if = "Option::is_none")]
799    pub remote_steerable: Option<bool>,
800    /// ISO 8601 timestamp when the session was resumed
801    pub resume_time: String,
802    /// Model currently selected at resume time
803    #[serde(skip_serializing_if = "Option::is_none")]
804    pub selected_model: Option<String>,
805    /// Session limits currently configured at resume time; null when no limits are active
806    #[serde(skip_serializing_if = "Option::is_none")]
807    pub session_limits: Option<SessionLimitsConfig>,
808    /// True when this resume passively joined a session that already had live work running in the runtime - an agent turn, a native queue run, a queued resume continuation, or an in-flight send (for example, an extension joining a session another client was actively driving). False (or omitted) when the session had no live work or when the resume explicitly abandoned pending work, including cold resumes and suspended sessions that remain resident in memory.
809    #[serde(skip_serializing_if = "Option::is_none")]
810    pub session_was_active: Option<bool>,
811    /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
812    #[serde(skip_serializing_if = "Option::is_none")]
813    pub verbosity: Option<Verbosity>,
814}
815
816/// Session event "session.remote_steerable_changed". Notifies that the session's remote steering capability has changed
817#[derive(Debug, Clone, Default, Serialize, Deserialize)]
818#[serde(rename_all = "camelCase")]
819pub struct SessionRemoteSteerableChangedData {
820    /// Whether this session now supports remote steering via GitHub
821    pub remote_steerable: bool,
822}
823
824/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
825#[derive(Debug, Clone, Default, Serialize, Deserialize)]
826#[serde(rename_all = "camelCase")]
827pub struct SessionErrorData {
828    /// 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.
829    #[serde(skip_serializing_if = "Option::is_none")]
830    pub eligible_for_auto_switch: Option<bool>,
831    /// Fine-grained error code from the upstream provider, when available. For `errorType: "rate_limit"`, this is one of the `RateLimitErrorCode` values (e.g., `"user_weekly_rate_limited"`, `"user_global_rate_limited"`, `"rate_limited"`, `"user_model_rate_limited"`, `"integration_rate_limited"`). For `errorType: "quota"`, this is the CAPI quota error code (e.g., `"quota_exceeded"`, `"session_quota_exceeded"`, `"billing_not_configured"`).
832    #[serde(skip_serializing_if = "Option::is_none")]
833    pub error_code: Option<String>,
834    /// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
835    pub error_type: String,
836    /// Human-readable error message
837    pub message: String,
838    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
839    #[serde(skip_serializing_if = "Option::is_none")]
840    pub provider_call_id: Option<String>,
841    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
842    #[serde(skip_serializing_if = "Option::is_none")]
843    pub service_request_id: Option<String>,
844    /// Error stack trace, when available
845    #[serde(skip_serializing_if = "Option::is_none")]
846    pub stack: Option<String>,
847    /// HTTP status code from the upstream request, if applicable
848    #[serde(skip_serializing_if = "Option::is_none")]
849    pub status_code: Option<i32>,
850    /// Optional URL associated with this error that the user can open in a browser
851    #[serde(skip_serializing_if = "Option::is_none")]
852    pub url: Option<String>,
853}
854
855/// Session event "session.idle". Payload indicating the session is idle with no background agents or attached shell commands in flight
856#[derive(Debug, Clone, Default, Serialize, Deserialize)]
857#[serde(rename_all = "camelCase")]
858pub struct SessionIdleData {
859    /// True when the preceding agentic loop was cancelled via abort signal
860    #[serde(skip_serializing_if = "Option::is_none")]
861    pub aborted: Option<bool>,
862}
863
864/// Session event "session.title_changed". Session title change payload containing the new display title
865#[derive(Debug, Clone, Default, Serialize, Deserialize)]
866#[serde(rename_all = "camelCase")]
867pub struct SessionTitleChangedData {
868    /// The new display title for the session
869    pub title: String,
870}
871
872/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
873#[derive(Debug, Clone, Default, Serialize, Deserialize)]
874#[serde(rename_all = "camelCase")]
875pub struct SessionScheduleCreatedData {
876    /// Absolute fire time (epoch milliseconds) for a one-shot calendar schedule
877    #[serde(skip_serializing_if = "Option::is_none")]
878    pub at: Option<i64>,
879    /// 5-field cron expression for a recurring calendar schedule, evaluated in `tz`
880    #[serde(skip_serializing_if = "Option::is_none")]
881    pub cron: Option<String>,
882    /// Optional user-facing label shown in the timeline instead of the actual prompt (e.g. `/skill-name args` when the prompt is a skill invocation expansion)
883    #[serde(skip_serializing_if = "Option::is_none")]
884    pub display_prompt: Option<String>,
885    /// Sequential id assigned to the scheduled prompt within the session
886    pub id: i64,
887    /// Interval between ticks in milliseconds (relative-interval schedules)
888    #[serde(skip_serializing_if = "Option::is_none")]
889    pub interval_ms: Option<i64>,
890    /// Who created the schedule (`user` or `model`). Persisted so a resumed session keeps gating non-user schedules from firing skills that opted out of model invocation. Absent on entries created before this field existed; a missing origin fails closed (treated the same as a non-user origin), so such a schedule may not resolve a `disable-model-invocation` skill.
891    #[serde(skip_serializing_if = "Option::is_none")]
892    pub origin: Option<ScheduleOrigin>,
893    /// Prompt text that gets enqueued on every tick
894    pub prompt: String,
895    /// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
896    #[serde(skip_serializing_if = "Option::is_none")]
897    pub recurring: Option<bool>,
898    /// True for a self-paced (`dynamic`) schedule: no fixed cadence; the model arms each next run via the `manage_schedule` `wakeup` action. `nextRunAt` is model-controlled rather than auto-computed.
899    #[serde(skip_serializing_if = "Option::is_none")]
900    pub self_paced: Option<bool>,
901    /// IANA timezone the `cron` expression is evaluated in
902    #[serde(skip_serializing_if = "Option::is_none")]
903    pub tz: Option<String>,
904}
905
906/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
907#[derive(Debug, Clone, Default, Serialize, Deserialize)]
908#[serde(rename_all = "camelCase")]
909pub struct SessionScheduleCancelledData {
910    /// Id of the scheduled prompt that was cancelled
911    pub id: i64,
912}
913
914/// Session event "session.schedule_rearmed". Self-paced schedule re-armed for its next run
915#[derive(Debug, Clone, Default, Serialize, Deserialize)]
916#[serde(rename_all = "camelCase")]
917pub struct SessionScheduleRearmedData {
918    /// Id of the self-paced schedule that was re-armed
919    pub id: i64,
920    /// Absolute time (epoch milliseconds) the model armed the next run to fire
921    pub next_run_at: i64,
922}
923
924/// Session event "session.autopilot_objective_changed". Autopilot objective state file operation details indicating what changed
925#[derive(Debug, Clone, Default, Serialize, Deserialize)]
926#[serde(rename_all = "camelCase")]
927pub struct SessionAutopilotObjectiveChangedData {
928    /// Current autopilot objective id, if one exists
929    #[serde(skip_serializing_if = "Option::is_none")]
930    pub id: Option<i64>,
931    /// The type of operation performed on the autopilot objective state file
932    pub operation: AutopilotObjectiveChangedOperation,
933    /// Current autopilot objective status, if one exists
934    #[serde(skip_serializing_if = "Option::is_none")]
935    pub status: Option<AutopilotObjectiveChangedStatus>,
936}
937
938/// Session event "session.info". Informational message for timeline display with categorization
939#[derive(Debug, Clone, Default, Serialize, Deserialize)]
940#[serde(rename_all = "camelCase")]
941pub struct SessionInfoData {
942    /// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
943    pub info_type: String,
944    /// Human-readable informational message for display in the timeline
945    pub message: String,
946    /// Optional actionable tip displayed with this message
947    #[serde(skip_serializing_if = "Option::is_none")]
948    pub tip: Option<String>,
949    /// Optional URL associated with this message that the user can open in a browser
950    #[serde(skip_serializing_if = "Option::is_none")]
951    pub url: Option<String>,
952}
953
954/// Session event "session.warning". Warning message for timeline display with categorization
955#[derive(Debug, Clone, Default, Serialize, Deserialize)]
956#[serde(rename_all = "camelCase")]
957pub struct SessionWarningData {
958    /// Human-readable warning message for display in the timeline
959    pub message: String,
960    /// Optional URL associated with this warning that the user can open in a browser
961    #[serde(skip_serializing_if = "Option::is_none")]
962    pub url: Option<String>,
963    /// Category of warning (e.g., "subscription", "policy", "mcp")
964    pub warning_type: String,
965}
966
967/// Session event "session.model_change". Model change details including previous and new model identifiers
968#[derive(Debug, Clone, Default, Serialize, Deserialize)]
969#[serde(rename_all = "camelCase")]
970pub struct SessionModelChangeData {
971    /// Reason the change happened, when not user-initiated. `"rate_limit_auto_switch"` for changes triggered by the auto-mode-switch rate-limit recovery path, or `"refusal_fallback"` when the active model declined a request (content refusal) and the runtime switched to the configured refusal-fallback model. UI clients can use this to render contextual copy.
972    #[serde(skip_serializing_if = "Option::is_none")]
973    pub cause: Option<String>,
974    /// Context tier after the model change; null explicitly clears a previously selected tier
975    #[serde(skip_serializing_if = "Option::is_none")]
976    pub context_tier: Option<ContextTier>,
977    /// Newly selected model identifier
978    pub new_model: String,
979    /// Model that was previously selected, if any
980    #[serde(skip_serializing_if = "Option::is_none")]
981    pub previous_model: Option<String>,
982    /// Reasoning effort level before the model change, if applicable
983    #[serde(skip_serializing_if = "Option::is_none")]
984    pub previous_reasoning_effort: Option<String>,
985    /// Reasoning summary mode before the model change, if applicable
986    #[serde(skip_serializing_if = "Option::is_none")]
987    pub previous_reasoning_summary: Option<ReasoningSummary>,
988    /// Output verbosity level before the model change, if applicable
989    #[serde(skip_serializing_if = "Option::is_none")]
990    pub previous_verbosity: Option<Verbosity>,
991    /// Reasoning effort level after the model change, if applicable
992    #[serde(skip_serializing_if = "Option::is_none")]
993    pub reasoning_effort: Option<String>,
994    /// Reasoning summary mode after the model change, if applicable
995    #[serde(skip_serializing_if = "Option::is_none")]
996    pub reasoning_summary: Option<ReasoningSummary>,
997    /// Output verbosity level after the model change, if applicable
998    #[serde(skip_serializing_if = "Option::is_none")]
999    pub verbosity: Option<Verbosity>,
1000}
1001
1002/// Session event "session.mode_changed". Agent mode change details including previous and new modes
1003#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1004#[serde(rename_all = "camelCase")]
1005pub struct SessionModeChangedData {
1006    /// The session mode the agent is operating in
1007    pub new_mode: SessionMode,
1008    /// The session mode the agent is operating in
1009    pub previous_mode: SessionMode,
1010}
1011
1012/// Session event "session.session_limits_changed". Session limits update details. Null clears the limits.
1013#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1014#[serde(rename_all = "camelCase")]
1015pub struct SessionSessionLimitsChangedData {
1016    /// Current session limits, or null when no limits are active
1017    pub session_limits: Option<SessionLimitsConfig>,
1018}
1019
1020/// Session event "session.permissions_changed". Permissions change details carrying the aggregate allow-all transition.
1021#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1022#[serde(rename_all = "camelCase")]
1023pub struct SessionPermissionsChangedData {
1024    /// Allow-all mode after the change
1025    ///
1026    /// <div class="warning">
1027    ///
1028    /// **Experimental.** This type is part of an experimental wire-protocol surface
1029    /// and may change or be removed in future SDK or CLI releases.
1030    ///
1031    /// </div>
1032    #[serde(skip_serializing_if = "Option::is_none")]
1033    pub allow_all_permission_mode: Option<PermissionAllowAllMode>,
1034    /// Aggregate allow-all flag after the change
1035    pub allow_all_permissions: bool,
1036    /// Allow-all mode before the change
1037    ///
1038    /// <div class="warning">
1039    ///
1040    /// **Experimental.** This type is part of an experimental wire-protocol surface
1041    /// and may change or be removed in future SDK or CLI releases.
1042    ///
1043    /// </div>
1044    #[serde(skip_serializing_if = "Option::is_none")]
1045    pub previous_allow_all_permission_mode: Option<PermissionAllowAllMode>,
1046    /// Aggregate allow-all flag before the change
1047    pub previous_allow_all_permissions: bool,
1048}
1049
1050/// Session event "session.plan_changed". Plan file operation details indicating what changed
1051#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1052#[serde(rename_all = "camelCase")]
1053pub struct SessionPlanChangedData {
1054    /// The type of operation performed on the plan file
1055    pub operation: PlanChangedOperation,
1056}
1057
1058/// Session event "session.todos_changed". Signal-only event: the agent's todos or todo_deps table was written to. No payload — clients should call session.plan.readSqlTodosWithDependencies() to fetch the current state. Events arrive in order; clients can debounce on arrival if needed.
1059#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1060#[serde(rename_all = "camelCase")]
1061pub struct SessionTodosChangedData {}
1062
1063/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
1064#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1065#[serde(rename_all = "camelCase")]
1066pub struct SessionWorkspaceFileChangedData {
1067    /// Whether the file was newly created or updated
1068    pub operation: WorkspaceFileChangedOperation,
1069    /// Relative path within the session workspace files directory
1070    pub path: String,
1071}
1072
1073/// Repository context for the handed-off session
1074#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1075#[serde(rename_all = "camelCase")]
1076pub struct HandoffRepository {
1077    /// Git branch name, if applicable
1078    #[serde(skip_serializing_if = "Option::is_none")]
1079    pub branch: Option<String>,
1080    /// Repository name
1081    pub name: String,
1082    /// Repository owner (user or organization)
1083    pub owner: String,
1084}
1085
1086/// Session event "session.handoff". Session handoff metadata including source, context, and repository information
1087#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1088#[serde(rename_all = "camelCase")]
1089pub struct SessionHandoffData {
1090    /// Additional context information for the handoff
1091    #[serde(skip_serializing_if = "Option::is_none")]
1092    pub context: Option<String>,
1093    /// ISO 8601 timestamp when the handoff occurred
1094    pub handoff_time: String,
1095    /// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
1096    #[serde(skip_serializing_if = "Option::is_none")]
1097    pub host: Option<String>,
1098    /// Session ID of the remote session being handed off
1099    #[serde(skip_serializing_if = "Option::is_none")]
1100    pub remote_session_id: Option<SessionId>,
1101    /// Repository context for the handed-off session
1102    #[serde(skip_serializing_if = "Option::is_none")]
1103    pub repository: Option<HandoffRepository>,
1104    /// Origin type of the session being handed off
1105    pub source_type: HandoffSourceType,
1106    /// Summary of the work done in the source session
1107    #[serde(skip_serializing_if = "Option::is_none")]
1108    pub summary: Option<String>,
1109}
1110
1111/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
1112#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1113#[serde(rename_all = "camelCase")]
1114pub struct SessionTruncationData {
1115    /// Number of messages removed by truncation
1116    pub messages_removed_during_truncation: i64,
1117    /// Identifier of the component that performed truncation (e.g., "BasicTruncator")
1118    pub performed_by: String,
1119    /// Number of conversation messages after truncation
1120    pub post_truncation_messages_length: i64,
1121    /// Total tokens in conversation messages after truncation
1122    pub post_truncation_tokens_in_messages: i64,
1123    /// Number of conversation messages before truncation
1124    pub pre_truncation_messages_length: i64,
1125    /// Total tokens in conversation messages before truncation
1126    pub pre_truncation_tokens_in_messages: i64,
1127    /// Maximum token count for the model's context window
1128    pub token_limit: i64,
1129    /// Number of tokens removed by truncation
1130    pub tokens_removed_during_truncation: i64,
1131}
1132
1133/// Session event "session.snapshot_rewind". Session rewind details including target event and count of removed events
1134#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1135#[serde(rename_all = "camelCase")]
1136pub struct SessionSnapshotRewindData {
1137    /// Number of events that were removed by the rewind
1138    pub events_removed: i64,
1139    /// Event ID that was rewound to; this event and all after it were removed
1140    pub up_to_event_id: String,
1141}
1142
1143/// Aggregate code change metrics for the session
1144#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1145#[serde(rename_all = "camelCase")]
1146pub struct ShutdownCodeChanges {
1147    /// List of file paths that were modified during the session
1148    pub files_modified: Vec<String>,
1149    /// Total number of lines added during the session
1150    pub lines_added: i64,
1151    /// Total number of lines removed during the session
1152    pub lines_removed: i64,
1153}
1154
1155/// Request count and cost metrics
1156#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1157#[serde(rename_all = "camelCase")]
1158pub struct ShutdownModelMetricRequests {
1159    /// Cumulative cost multiplier for requests to this model
1160    ///
1161    /// <div class="warning">
1162    ///
1163    /// **Experimental.** This type is part of an experimental wire-protocol surface
1164    /// and may change or be removed in future SDK or CLI releases.
1165    ///
1166    /// </div>
1167    #[serde(skip_serializing_if = "Option::is_none")]
1168    pub cost: Option<f64>,
1169    /// Total number of API requests made to this model
1170    ///
1171    /// <div class="warning">
1172    ///
1173    /// **Experimental.** This type is part of an experimental wire-protocol surface
1174    /// and may change or be removed in future SDK or CLI releases.
1175    ///
1176    /// </div>
1177    #[serde(skip_serializing_if = "Option::is_none")]
1178    pub count: Option<i64>,
1179}
1180
1181/// A token-type entry in a shutdown model metric, storing the accumulated token count.
1182#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1183#[serde(rename_all = "camelCase")]
1184pub struct ShutdownModelMetricTokenDetail {
1185    /// Accumulated token count for this token type
1186    pub token_count: i64,
1187}
1188
1189/// Token usage breakdown
1190#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1191#[serde(rename_all = "camelCase")]
1192pub struct ShutdownModelMetricUsage {
1193    /// Total tokens read from prompt cache across all requests
1194    pub cache_read_tokens: i64,
1195    /// Total tokens written to prompt cache across all requests
1196    pub cache_write_tokens: i64,
1197    /// Total input tokens consumed across all requests to this model
1198    pub input_tokens: i64,
1199    /// Total output tokens produced across all requests to this model
1200    pub output_tokens: i64,
1201    /// Total reasoning tokens produced across all requests to this model
1202    #[serde(skip_serializing_if = "Option::is_none")]
1203    pub reasoning_tokens: Option<i64>,
1204}
1205
1206/// Per-model shutdown metrics with request counts, token usage, nano-AI units, and token details.
1207#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1208#[serde(rename_all = "camelCase")]
1209pub struct ShutdownModelMetric {
1210    /// Request count and cost metrics
1211    pub requests: ShutdownModelMetricRequests,
1212    /// Token count details per type
1213    #[serde(skip_serializing_if = "Option::is_none")]
1214    pub token_details: Option<HashMap<String, ShutdownModelMetricTokenDetail>>,
1215    /// Accumulated nano-AI units cost for this model
1216    ///
1217    /// <div class="warning">
1218    ///
1219    /// **Experimental.** This type is part of an experimental wire-protocol surface
1220    /// and may change or be removed in future SDK or CLI releases.
1221    ///
1222    /// </div>
1223    #[serde(skip_serializing_if = "Option::is_none")]
1224    pub total_nano_aiu: Option<f64>,
1225    /// Token usage breakdown
1226    pub usage: ShutdownModelMetricUsage,
1227}
1228
1229/// A session-wide shutdown token-type entry storing the accumulated token count.
1230#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1231#[serde(rename_all = "camelCase")]
1232pub struct ShutdownTokenDetail {
1233    /// Accumulated token count for this token type
1234    pub token_count: i64,
1235}
1236
1237/// Session event "session.shutdown". Session termination metrics including usage statistics, code changes, and shutdown reason
1238#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1239#[serde(rename_all = "camelCase")]
1240pub struct SessionShutdownData {
1241    /// Aggregate code change metrics for the session
1242    pub code_changes: ShutdownCodeChanges,
1243    /// Non-system message token count at shutdown
1244    #[serde(skip_serializing_if = "Option::is_none")]
1245    pub conversation_tokens: Option<i64>,
1246    /// Model that was selected at the time of shutdown
1247    #[serde(skip_serializing_if = "Option::is_none")]
1248    pub current_model: Option<String>,
1249    /// Total tokens in context window at shutdown
1250    #[serde(skip_serializing_if = "Option::is_none")]
1251    pub current_tokens: Option<i64>,
1252    /// Error description when shutdownType is "error"
1253    #[serde(skip_serializing_if = "Option::is_none")]
1254    pub error_reason: Option<String>,
1255    /// On-disk byte size of the session's persisted events.jsonl file at shutdown time; omitted when the file does not exist or cannot be stat'd
1256    #[serde(skip_serializing_if = "Option::is_none")]
1257    pub events_file_size_bytes: Option<i64>,
1258    /// Per-model usage breakdown, keyed by model identifier
1259    pub model_metrics: HashMap<String, ShutdownModelMetric>,
1260    /// Unix timestamp (milliseconds) when the session started
1261    pub session_start_time: i64,
1262    /// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
1263    pub shutdown_type: ShutdownType,
1264    /// System message token count at shutdown
1265    #[serde(skip_serializing_if = "Option::is_none")]
1266    pub system_tokens: Option<i64>,
1267    /// Session-wide per-token-type accumulated token counts
1268    #[serde(skip_serializing_if = "Option::is_none")]
1269    pub token_details: Option<HashMap<String, ShutdownTokenDetail>>,
1270    /// Tool definitions token count at shutdown
1271    #[serde(skip_serializing_if = "Option::is_none")]
1272    pub tool_definitions_tokens: Option<i64>,
1273    /// Cumulative time spent in API calls during the session, in milliseconds
1274    pub total_api_duration_ms: i64,
1275    /// Session-wide accumulated nano-AI units cost
1276    ///
1277    /// <div class="warning">
1278    ///
1279    /// **Experimental.** This type is part of an experimental wire-protocol surface
1280    /// and may change or be removed in future SDK or CLI releases.
1281    ///
1282    /// </div>
1283    #[serde(skip_serializing_if = "Option::is_none")]
1284    pub total_nano_aiu: Option<f64>,
1285    /// Total number of premium API requests used during the session
1286    #[doc(hidden)]
1287    #[serde(skip_serializing_if = "Option::is_none")]
1288    pub(crate) total_premium_requests: Option<f64>,
1289}
1290
1291/// Internal prompt-cache expiration state for one model
1292#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1293#[serde(rename_all = "camelCase")]
1294pub(crate) struct UsageCheckpointModelCacheState {
1295    /// Latest known prompt-cache expiration
1296    pub cache_expires_at: String,
1297    /// Retained cache lifetime in seconds, used to refresh expiration after a cache read
1298    #[doc(hidden)]
1299    pub(crate) cache_ttl_seconds: i64,
1300    /// Model identifier associated with this cache state
1301    pub model_id: String,
1302}
1303
1304/// Session event "session.usage_checkpoint". Durable session usage checkpoint for reconstructing aggregate accounting on resume
1305#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1306#[serde(rename_all = "camelCase")]
1307pub struct SessionUsageCheckpointData {
1308    /// Internal per-model prompt-cache state used to restore expiration tracking on resume
1309    #[doc(hidden)]
1310    #[serde(skip_serializing_if = "Option::is_none")]
1311    pub(crate) model_cache_state: Option<Vec<UsageCheckpointModelCacheState>>,
1312    /// Session-wide accumulated nano-AI units cost at checkpoint time
1313    pub total_nano_aiu: f64,
1314    /// Total number of premium API requests used at checkpoint time
1315    #[doc(hidden)]
1316    #[serde(skip_serializing_if = "Option::is_none")]
1317    pub(crate) total_premium_requests: Option<f64>,
1318}
1319
1320/// Session event "session.context_changed". Updated working directory and git context after the change
1321#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1322#[serde(rename_all = "camelCase")]
1323pub struct SessionContextChangedData {
1324    /// Base commit of current git branch at session start time
1325    #[serde(skip_serializing_if = "Option::is_none")]
1326    pub base_commit: Option<String>,
1327    /// Current git branch name
1328    #[serde(skip_serializing_if = "Option::is_none")]
1329    pub branch: Option<String>,
1330    /// Current working directory path
1331    pub cwd: String,
1332    /// Root directory of the git repository, resolved via git rev-parse
1333    #[serde(skip_serializing_if = "Option::is_none")]
1334    pub git_root: Option<String>,
1335    /// Head commit of current git branch at session start time
1336    #[serde(skip_serializing_if = "Option::is_none")]
1337    pub head_commit: Option<String>,
1338    /// Hosting platform type of the repository (github or ado)
1339    #[serde(skip_serializing_if = "Option::is_none")]
1340    pub host_type: Option<WorkingDirectoryContextHostType>,
1341    /// Set on the immediate preliminary event of a working-directory change, before the git context is resolved. A settled follow-up event (enriched with git context, or cwd-only for a non-repository) is always emitted afterward, so observers may defer to it. Absent on standalone/final events (e.g. relay context changes).
1342    #[serde(skip_serializing_if = "Option::is_none")]
1343    pub pending_git_context: Option<bool>,
1344    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
1345    #[serde(skip_serializing_if = "Option::is_none")]
1346    pub repository: Option<String>,
1347    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
1348    #[serde(skip_serializing_if = "Option::is_none")]
1349    pub repository_host: Option<String>,
1350}
1351
1352/// Session event "session.usage_info". Current context window usage statistics including token and message counts
1353#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1354#[serde(rename_all = "camelCase")]
1355pub struct SessionUsageInfoData {
1356    /// Token count from non-system messages (user, assistant, tool)
1357    #[serde(skip_serializing_if = "Option::is_none")]
1358    pub conversation_tokens: Option<i64>,
1359    /// Current number of tokens in the context window
1360    pub current_tokens: i64,
1361    /// Whether this is the first usage_info event emitted in this session
1362    #[serde(skip_serializing_if = "Option::is_none")]
1363    pub is_initial: Option<bool>,
1364    /// Current number of messages in the conversation
1365    pub messages_length: i64,
1366    /// Token count from system message(s)
1367    #[serde(skip_serializing_if = "Option::is_none")]
1368    pub system_tokens: Option<i64>,
1369    /// Maximum token count for the model's context window
1370    pub token_limit: i64,
1371    /// Token count from tool definitions
1372    #[serde(skip_serializing_if = "Option::is_none")]
1373    pub tool_definitions_tokens: Option<i64>,
1374}
1375
1376/// Session event "session.context_cleared". Context-cleared details emitted when the host clears the conversation (the session.history.clearContext RPC / Session.clearContextMessages)
1377#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1378#[serde(rename_all = "camelCase")]
1379pub struct SessionContextClearedData {
1380    /// Optional initial message set after clearing
1381    #[serde(skip_serializing_if = "Option::is_none")]
1382    pub initial_message: Option<String>,
1383    /// Number of conversation messages that were cleared
1384    pub messages_cleared: i64,
1385}
1386
1387/// Session event "session.compaction_start". Context window breakdown at the start of LLM-powered conversation compaction
1388#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1389#[serde(rename_all = "camelCase")]
1390pub struct SessionCompactionStartData {
1391    /// Token count from non-system messages (user, assistant, tool) at compaction start
1392    #[serde(skip_serializing_if = "Option::is_none")]
1393    pub conversation_tokens: Option<i64>,
1394    /// Total context tokens (system + conversation + tool definitions) at compaction start, when known
1395    #[serde(skip_serializing_if = "Option::is_none")]
1396    pub current_tokens: Option<i64>,
1397    /// Model identifier used for compaction, when known
1398    #[serde(skip_serializing_if = "Option::is_none")]
1399    pub model: Option<String>,
1400    /// Token count from system message(s) at compaction start
1401    #[serde(skip_serializing_if = "Option::is_none")]
1402    pub system_tokens: Option<i64>,
1403    /// Model context window token limit the compaction is targeting, when known
1404    #[serde(skip_serializing_if = "Option::is_none")]
1405    pub token_limit: Option<i64>,
1406    /// Token count from tool definitions at compaction start
1407    #[serde(skip_serializing_if = "Option::is_none")]
1408    pub tool_definitions_tokens: Option<i64>,
1409    /// What initiated this compaction, when known
1410    #[serde(skip_serializing_if = "Option::is_none")]
1411    pub trigger: Option<CompactionTrigger>,
1412}
1413
1414/// Token usage detail for a single billing category
1415#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1416#[serde(rename_all = "camelCase")]
1417pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
1418    /// Number of tokens in this billing batch
1419    pub batch_size: i64,
1420    /// Cost per batch of tokens
1421    pub cost_per_batch: i64,
1422    /// Total token count for this entry
1423    pub token_count: i64,
1424    /// Token category (e.g., "input", "output")
1425    pub token_type: String,
1426}
1427
1428/// Per-request cost and usage data from the CAPI copilot_usage response field
1429#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1430#[serde(rename_all = "camelCase")]
1431pub(crate) struct CompactionCompleteCompactionTokensUsedCopilotUsage {
1432    /// Itemized token usage breakdown
1433    #[doc(hidden)]
1434    #[serde(skip_serializing_if = "Option::is_none")]
1435    pub(crate) token_details:
1436        Option<Vec<CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail>>,
1437    /// Total cost in nano-AI units for this request
1438    pub total_nano_aiu: f64,
1439}
1440
1441/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
1442#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1443#[serde(rename_all = "camelCase")]
1444pub struct CompactionCompleteCompactionTokensUsed {
1445    /// Cached input tokens reused in the compaction LLM call
1446    #[serde(skip_serializing_if = "Option::is_none")]
1447    pub cache_read_tokens: Option<i64>,
1448    /// Tokens written to prompt cache in the compaction LLM call
1449    #[serde(skip_serializing_if = "Option::is_none")]
1450    pub cache_write_tokens: Option<i64>,
1451    /// Per-request cost and usage data from the CAPI copilot_usage response field
1452    #[doc(hidden)]
1453    #[serde(skip_serializing_if = "Option::is_none")]
1454    pub(crate) copilot_usage: Option<CompactionCompleteCompactionTokensUsedCopilotUsage>,
1455    /// Duration of the compaction LLM call in milliseconds
1456    #[serde(skip_serializing_if = "Option::is_none")]
1457    pub duration: Option<i64>,
1458    /// Input tokens consumed by the compaction LLM call
1459    #[serde(skip_serializing_if = "Option::is_none")]
1460    pub input_tokens: Option<i64>,
1461    /// Model identifier used for the compaction LLM call
1462    #[serde(skip_serializing_if = "Option::is_none")]
1463    pub model: Option<String>,
1464    /// Output tokens produced by the compaction LLM call
1465    #[serde(skip_serializing_if = "Option::is_none")]
1466    pub output_tokens: Option<i64>,
1467}
1468
1469/// Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
1470#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1471#[serde(rename_all = "camelCase")]
1472pub struct SessionCompactionCompleteData {
1473    /// Checkpoint snapshot number created for recovery
1474    #[serde(skip_serializing_if = "Option::is_none")]
1475    pub checkpoint_number: Option<i64>,
1476    /// File path where the checkpoint was stored
1477    #[serde(skip_serializing_if = "Option::is_none")]
1478    pub checkpoint_path: Option<String>,
1479    /// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
1480    #[serde(skip_serializing_if = "Option::is_none")]
1481    pub compaction_tokens_used: Option<CompactionCompleteCompactionTokensUsed>,
1482    /// Token count from non-system messages (user, assistant, tool) after compaction
1483    #[serde(skip_serializing_if = "Option::is_none")]
1484    pub conversation_tokens: Option<i64>,
1485    /// User-supplied focus instructions provided to a manual `/compact` invocation. Omitted for automatic compaction and for manual compaction with no focus text.
1486    #[serde(skip_serializing_if = "Option::is_none")]
1487    pub custom_instructions: Option<String>,
1488    /// Error message if compaction failed
1489    #[serde(skip_serializing_if = "Option::is_none")]
1490    pub error: Option<String>,
1491    /// Number of messages removed during compaction
1492    #[serde(skip_serializing_if = "Option::is_none")]
1493    pub messages_removed: Option<i64>,
1494    /// Total tokens in conversation after compaction
1495    #[serde(skip_serializing_if = "Option::is_none")]
1496    pub post_compaction_tokens: Option<i64>,
1497    /// Number of messages before compaction
1498    #[serde(skip_serializing_if = "Option::is_none")]
1499    pub pre_compaction_messages_length: Option<i64>,
1500    /// Total tokens in conversation before compaction
1501    #[serde(skip_serializing_if = "Option::is_none")]
1502    pub pre_compaction_tokens: Option<i64>,
1503    /// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
1504    #[serde(skip_serializing_if = "Option::is_none")]
1505    pub request_id: Option<RequestId>,
1506    /// Copilot service request ID (x-copilot-service-request-id header) for the compaction LLM call
1507    #[serde(skip_serializing_if = "Option::is_none")]
1508    pub service_request_id: Option<String>,
1509    /// For failed compaction only: the HTTP status code of the compaction LLM call failure, when it carried one. Absent for successful compaction and for failures without an HTTP status (e.g. an empty model response or a transport error).
1510    #[serde(skip_serializing_if = "Option::is_none")]
1511    pub status_code: Option<i64>,
1512    /// Whether compaction completed successfully
1513    pub success: bool,
1514    /// LLM-generated summary of the compacted conversation history
1515    #[serde(skip_serializing_if = "Option::is_none")]
1516    pub summary_content: Option<String>,
1517    /// Token count from system message(s) after compaction
1518    #[serde(skip_serializing_if = "Option::is_none")]
1519    pub system_tokens: Option<i64>,
1520    /// Model context window token limit the compaction was targeting, when known
1521    #[serde(skip_serializing_if = "Option::is_none")]
1522    pub token_limit: Option<i64>,
1523    /// Number of tokens removed during compaction
1524    #[serde(skip_serializing_if = "Option::is_none")]
1525    pub tokens_removed: Option<i64>,
1526    /// Token count from tool definitions after compaction
1527    #[serde(skip_serializing_if = "Option::is_none")]
1528    pub tool_definitions_tokens: Option<i64>,
1529    /// What initiated this compaction, when known
1530    #[serde(skip_serializing_if = "Option::is_none")]
1531    pub trigger: Option<CompactionTrigger>,
1532}
1533
1534/// Session event "session.task_complete". Task completion notification with summary from the agent
1535#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1536#[serde(rename_all = "camelCase")]
1537pub struct SessionTaskCompleteData {
1538    /// Active autopilot objective ID evaluated by the completion reviewer
1539    #[serde(skip_serializing_if = "Option::is_none")]
1540    pub objective_id: Option<i64>,
1541    /// Semantic completion decision. Absent on legacy events and invalid tool calls
1542    #[serde(skip_serializing_if = "Option::is_none")]
1543    pub outcome: Option<TaskCompletionOutcome>,
1544    /// Label-safe runtime rationale for the completion decision (e.g. a cancellation or pause/resume downgrade), when one applies. Reviewer-authored rationale is intentionally omitted here because this event has no IFC label channel; the reviewer's findings remain available through its own labeled sub-agent events
1545    #[serde(skip_serializing_if = "Option::is_none")]
1546    pub reason: Option<String>,
1547    /// Whether the task was accepted as complete. False when validation failed or completion was rejected or blocked by the reviewer
1548    #[serde(skip_serializing_if = "Option::is_none")]
1549    pub success: Option<bool>,
1550    /// Summary of the completed task, provided by the agent
1551    #[serde(skip_serializing_if = "Option::is_none")]
1552    pub summary: Option<String>,
1553}
1554
1555/// Session event "user.message". Payload of `user.message` with displayed and model-transformed content, attachments, source/delivery metadata, mode, and telemetry IDs.
1556#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1557#[serde(rename_all = "camelCase")]
1558pub struct UserMessageData {
1559    /// The agent mode that was active when this message was sent
1560    #[serde(skip_serializing_if = "Option::is_none")]
1561    pub agent_mode: Option<UserMessageAgentMode>,
1562    /// Files, selections, or GitHub references attached to the message
1563    #[serde(skip_serializing_if = "Option::is_none")]
1564    pub attachments: Option<Vec<serde_json::Value>>,
1565    /// The user's message text as displayed in the timeline
1566    pub content: String,
1567    /// How this message was delivered to the agentic loop relative to loop state (idle-start vs. steering/queued while busy). The timing axis; combine with `source` (origin) for the full picture. Used for telemetry attribution.
1568    #[serde(skip_serializing_if = "Option::is_none")]
1569    pub delivery: Option<UserMessageDelivery>,
1570    /// CAPI interaction ID for correlating this user message with its turn
1571    #[serde(skip_serializing_if = "Option::is_none")]
1572    pub interaction_id: Option<String>,
1573    /// True when this user message was auto-injected by autopilot's continuation loop rather than typed by the user; used to distinguish autopilot-driven turns in telemetry.
1574    #[serde(skip_serializing_if = "Option::is_none")]
1575    pub is_autopilot_continuation: Option<bool>,
1576    /// Path-backed native document attachments that stayed on the tagged_files path flow because native upload could not read them or would exceed the request size limit
1577    #[serde(skip_serializing_if = "Option::is_none")]
1578    pub native_document_path_fallback_paths: Option<Vec<String>>,
1579    /// Parent agent task ID for background telemetry correlated to this user turn
1580    #[serde(skip_serializing_if = "Option::is_none")]
1581    pub parent_agent_task_id: Option<String>,
1582    /// Origin of this message, used for timeline filtering and attribution (e.g., `skill-pdf` for hidden skill injection or `agent-<agent-id>` for an inter-agent prompt)
1583    #[serde(skip_serializing_if = "Option::is_none")]
1584    pub source: Option<String>,
1585    /// Normalized document MIME types that were sent natively instead of through tagged_files XML
1586    #[serde(skip_serializing_if = "Option::is_none")]
1587    pub supported_native_document_mime_types: Option<Vec<String>>,
1588    /// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching
1589    #[serde(skip_serializing_if = "Option::is_none")]
1590    pub transformed_content: Option<String>,
1591}
1592
1593/// Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
1594#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1595#[serde(rename_all = "camelCase")]
1596pub struct PendingMessagesModifiedData {}
1597
1598/// Session event "assistant.turn_start". Turn initialization metadata including identifier and interaction tracking
1599#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1600#[serde(rename_all = "camelCase")]
1601pub struct AssistantTurnStartData {
1602    /// CAPI interaction ID for correlating this turn with upstream telemetry
1603    #[serde(skip_serializing_if = "Option::is_none")]
1604    pub interaction_id: Option<String>,
1605    /// Model identifier used for this turn, when known
1606    #[serde(skip_serializing_if = "Option::is_none")]
1607    pub model: Option<String>,
1608    /// Identifier for this turn within the agentic loop, typically a stringified turn number
1609    pub turn_id: String,
1610}
1611
1612/// Session event "assistant.turn_retry". Metadata for an additional model inference attempt within an existing assistant turn
1613#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1614#[serde(rename_all = "camelCase")]
1615pub struct AssistantTurnRetryData {
1616    /// Model identifier used for this retry, when known
1617    #[serde(skip_serializing_if = "Option::is_none")]
1618    pub model: Option<String>,
1619    /// Provider or runtime classification that caused the retry, when known
1620    #[serde(skip_serializing_if = "Option::is_none")]
1621    pub reason: Option<String>,
1622    /// Identifier of the turn whose model inference is being retried
1623    pub turn_id: String,
1624}
1625
1626/// Session event "assistant.intent". Agent intent description for current activity or plan
1627#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1628#[serde(rename_all = "camelCase")]
1629pub struct AssistantIntentData {
1630    /// Short description of what the agent is currently doing or planning to do
1631    pub intent: String,
1632}
1633
1634/// Session event "assistant.server_tool_progress". Live progress signal for a provider-hosted server tool (e.g. hosted web search) while it runs, before the finalized serverTools envelope lands on the terminal assistant.message
1635#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1636#[serde(rename_all = "camelCase")]
1637pub struct AssistantServerToolProgressData {
1638    /// Kind of hosted server tool that is running. Only `web_search` is emitted today.
1639    pub kind: String,
1640    /// Position of the hosted tool call in the response output. Stable across the call's lifecycle events (unlike the provider's per-event item id, which CAPI rotates), so the host keys the live in-progress row on it.
1641    pub output_index: i64,
1642    /// Lifecycle status of the hosted call: `in_progress`, `searching`, or `completed`.
1643    pub status: String,
1644}
1645
1646/// Session event "assistant.reasoning". Assistant reasoning content for timeline display with complete thinking text
1647#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1648#[serde(rename_all = "camelCase")]
1649pub struct AssistantReasoningData {
1650    /// The complete extended thinking text from the model
1651    pub content: String,
1652    /// Unique identifier for this reasoning block
1653    pub reasoning_id: String,
1654    #[serde(skip_serializing_if = "Option::is_none")]
1655    pub rte: Option<bool>,
1656}
1657
1658/// Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
1659#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1660#[serde(rename_all = "camelCase")]
1661pub struct AssistantReasoningDeltaData {
1662    /// Incremental text chunk to append to the reasoning content
1663    pub delta_content: String,
1664    /// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event
1665    pub reasoning_id: String,
1666}
1667
1668/// Session event "assistant.tool_call_delta". Streaming tool-call input delta for incremental tool-call updates
1669#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1670#[serde(rename_all = "camelCase")]
1671pub struct AssistantToolCallDeltaData {
1672    /// Raw provider tool input fragment to append for this tool call. Function/tool-use providers stream serialized JSON argument text (so newlines inside JSON string values may appear as escaped `\n` until the accumulated JSON is parsed); custom tool calls stream raw custom input.
1673    pub input_delta: String,
1674    /// Tool call ID this delta belongs to, matching the corresponding assistant.message tool request
1675    pub tool_call_id: String,
1676    /// Name of the tool being invoked, when known from the stream
1677    #[serde(skip_serializing_if = "Option::is_none")]
1678    pub tool_name: Option<String>,
1679    /// Tool call type, when known from the stream
1680    #[serde(skip_serializing_if = "Option::is_none")]
1681    pub tool_type: Option<AssistantMessageToolRequestType>,
1682}
1683
1684/// Session event "assistant.streaming_delta". Streaming response progress with cumulative byte count
1685#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1686#[serde(rename_all = "camelCase")]
1687pub struct AssistantStreamingDeltaData {
1688    /// Cumulative total bytes received from the streaming response so far
1689    pub total_response_size_bytes: i64,
1690}
1691
1692/// A source that backs one or more cited spans in the assistant's response.
1693///
1694/// <div class="warning">
1695///
1696/// **Experimental.** This type is part of an experimental wire-protocol surface
1697/// and may change or be removed in future SDK or CLI releases.
1698///
1699/// </div>
1700#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1701#[serde(rename_all = "camelCase")]
1702pub struct CitationSource {
1703    /// Stable, turn-scoped identifier for this source, referenced by CitationReference.sourceId.
1704    pub id: String,
1705    /// File path relative to the agent's workspace root, when the source is a file.
1706    #[serde(skip_serializing_if = "Option::is_none")]
1707    pub path: Option<String>,
1708    /// The system that produced this citation.
1709    pub provider: CitationProvider,
1710    /// Human-readable title of the source.
1711    #[serde(skip_serializing_if = "Option::is_none")]
1712    pub title: Option<String>,
1713    /// URL of the source, when it is a web resource.
1714    #[serde(skip_serializing_if = "Option::is_none")]
1715    pub url: Option<String>,
1716}
1717
1718/// A single citation occurrence linking a span of generated text to a supporting source.
1719///
1720/// <div class="warning">
1721///
1722/// **Experimental.** This type is part of an experimental wire-protocol surface
1723/// and may change or be removed in future SDK or CLI releases.
1724///
1725/// </div>
1726#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1727#[serde(rename_all = "camelCase")]
1728pub struct CitationReference {
1729    /// The exact text from the source that supports the cited span, when provided by the model.
1730    #[serde(skip_serializing_if = "Option::is_none")]
1731    pub cited_text: Option<String>,
1732    /// Location within the source that supports the cited span, when the provider reports one.
1733    #[serde(skip_serializing_if = "Option::is_none")]
1734    pub location: Option<serde_json::Value>,
1735    /// Provider-native citation correlation data (e.g. Anthropic search_result_index / document_index), passed through opaquely for debugging and forward compatibility.
1736    #[serde(skip_serializing_if = "Option::is_none")]
1737    pub provider_metadata: Option<serde_json::Value>,
1738    /// Identifier of the CitationSource this reference points to (CitationSource.id).
1739    pub source_id: String,
1740}
1741
1742/// A contiguous span of generated assistant text and the source references that support it.
1743///
1744/// <div class="warning">
1745///
1746/// **Experimental.** This type is part of an experimental wire-protocol surface
1747/// and may change or be removed in future SDK or CLI releases.
1748///
1749/// </div>
1750#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1751#[serde(rename_all = "camelCase")]
1752pub struct CitationSpan {
1753    /// End offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, exclusive).
1754    pub end_index: i64,
1755    /// The sources that support this span of generated text.
1756    pub references: Vec<CitationReference>,
1757    /// Start offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, inclusive).
1758    pub start_index: i64,
1759}
1760
1761/// Provider-agnostic citations linking spans of the assistant's response to their supporting sources.
1762///
1763/// <div class="warning">
1764///
1765/// **Experimental.** This type is part of an experimental wire-protocol surface
1766/// and may change or be removed in future SDK or CLI releases.
1767///
1768/// </div>
1769#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1770#[serde(rename_all = "camelCase")]
1771pub struct Citations {
1772    /// Deduplicated set of sources referenced by the citation spans.
1773    pub sources: Vec<CitationSource>,
1774    /// Spans of generated text annotated with the sources that support them.
1775    pub spans: Vec<CitationSpan>,
1776}
1777
1778/// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
1779///
1780/// <div class="warning">
1781///
1782/// **Experimental.** This type is part of an experimental wire-protocol surface
1783/// and may change or be removed in future SDK or CLI releases.
1784///
1785/// </div>
1786#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1787#[serde(rename_all = "camelCase")]
1788pub struct AssistantMessageServerTools {
1789    #[serde(skip_serializing_if = "Option::is_none")]
1790    pub advisor_model: Option<String>,
1791    #[serde(skip_serializing_if = "Option::is_none")]
1792    pub function_call_namespaces: Option<HashMap<String, String>>,
1793    #[serde(skip_serializing_if = "Option::is_none")]
1794    pub items: Option<Vec<serde_json::Value>>,
1795    pub provider: String,
1796    #[serde(skip_serializing_if = "Option::is_none")]
1797    pub raw_content_blocks: Option<Vec<serde_json::Value>>,
1798}
1799
1800/// A tool invocation request from the assistant
1801#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1802#[serde(rename_all = "camelCase")]
1803pub struct AssistantMessageToolRequest {
1804    /// Arguments to pass to the tool, format depends on the tool
1805    #[serde(skip_serializing_if = "Option::is_none")]
1806    pub arguments: Option<serde_json::Value>,
1807    /// Resolved intention summary describing what this specific call does
1808    #[serde(skip_serializing_if = "Option::is_none")]
1809    pub intention_summary: Option<String>,
1810    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
1811    #[serde(skip_serializing_if = "Option::is_none")]
1812    pub mcp_server_name: Option<String>,
1813    /// Original tool name on the MCP server, when the tool is an MCP tool
1814    #[serde(skip_serializing_if = "Option::is_none")]
1815    pub mcp_tool_name: Option<String>,
1816    /// Name of the tool being invoked
1817    pub name: String,
1818    /// Unique identifier for this tool call
1819    pub tool_call_id: String,
1820    /// Human-readable display title for the tool
1821    #[serde(skip_serializing_if = "Option::is_none")]
1822    pub tool_title: Option<String>,
1823    /// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
1824    #[serde(skip_serializing_if = "Option::is_none")]
1825    pub r#type: Option<AssistantMessageToolRequestType>,
1826}
1827
1828/// Session event "assistant.message". Assistant response containing text content, optional tool requests, and interaction metadata
1829#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1830#[serde(rename_all = "camelCase")]
1831pub struct AssistantMessageData {
1832    /// Provider's completion / response identifier; shared across all chunks of a single API call. Used to group multi-chunk assistant utterances.
1833    #[serde(skip_serializing_if = "Option::is_none")]
1834    pub api_call_id: Option<String>,
1835    /// Total messages the model call's response was split into, one per reasoning boundary. Absent for a single-message response; the last chunk is the one where chunkIndex is chunkCount - 1.
1836    #[serde(skip_serializing_if = "Option::is_none")]
1837    pub chunk_count: Option<i64>,
1838    /// Zero-based position of this message within its model call's response. Absent when the response was not split into chunks.
1839    #[serde(skip_serializing_if = "Option::is_none")]
1840    pub chunk_index: Option<i64>,
1841    /// Provider-agnostic citations linking spans of this message's content to the sources that support them. Experimental; only populated when citation emission is enabled.
1842    ///
1843    /// <div class="warning">
1844    ///
1845    /// **Experimental.** This type is part of an experimental wire-protocol surface
1846    /// and may change or be removed in future SDK or CLI releases.
1847    ///
1848    /// </div>
1849    #[serde(skip_serializing_if = "Option::is_none")]
1850    pub citations: Option<Citations>,
1851    /// Client-minted request id (x-request-id header) echoed by the server. Distinct from requestId (x-github-request-id) and serviceRequestId (x-copilot-service-request-id).
1852    #[serde(skip_serializing_if = "Option::is_none")]
1853    pub client_request_id: Option<String>,
1854    /// The assistant's text response content
1855    pub content: String,
1856    /// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
1857    #[serde(skip_serializing_if = "Option::is_none")]
1858    pub encrypted_content: Option<String>,
1859    /// CAPI interaction ID for correlating this message with upstream telemetry
1860    #[serde(skip_serializing_if = "Option::is_none")]
1861    pub interaction_id: Option<String>,
1862    /// Unique identifier for this assistant message
1863    pub message_id: String,
1864    /// Model that produced this assistant message, if known
1865    #[serde(skip_serializing_if = "Option::is_none")]
1866    pub model: Option<String>,
1867    /// Actual output token count from the API response (completion_tokens), used for accurate token accounting
1868    #[serde(skip_serializing_if = "Option::is_none")]
1869    pub output_tokens: Option<i64>,
1870    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
1871    #[doc(hidden)]
1872    #[deprecated]
1873    #[serde(skip_serializing_if = "Option::is_none")]
1874    pub parent_tool_call_id: Option<String>,
1875    /// Generation phase for phased-output models (e.g., thinking vs. response phases)
1876    #[serde(skip_serializing_if = "Option::is_none")]
1877    pub phase: Option<String>,
1878    /// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
1879    #[serde(skip_serializing_if = "Option::is_none")]
1880    pub reasoning_opaque: Option<String>,
1881    /// Readable reasoning text from the model's extended thinking
1882    #[serde(skip_serializing_if = "Option::is_none")]
1883    pub reasoning_text: Option<String>,
1884    /// OpenAI-compatible wire field the provider used for reasoning (e.g. reasoning_content/reasoning). Populated only when non-canonical, so the dialect round-trips across turns.
1885    #[serde(skip_serializing_if = "Option::is_none")]
1886    pub reasoning_wire_field: Option<String>,
1887    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
1888    #[serde(skip_serializing_if = "Option::is_none")]
1889    pub request_id: Option<RequestId>,
1890    #[serde(skip_serializing_if = "Option::is_none")]
1891    pub rte: Option<bool>,
1892    /// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
1893    #[serde(skip_serializing_if = "Option::is_none")]
1894    pub server_tools: Option<AssistantMessageServerTools>,
1895    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
1896    #[serde(skip_serializing_if = "Option::is_none")]
1897    pub service_request_id: Option<String>,
1898    /// Tool invocations requested by the assistant in this message
1899    #[serde(skip_serializing_if = "Option::is_none")]
1900    pub tool_requests: Option<Vec<AssistantMessageToolRequest>>,
1901    /// Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
1902    #[serde(skip_serializing_if = "Option::is_none")]
1903    pub turn_id: Option<String>,
1904}
1905
1906/// Session event "assistant.message_start". Streaming assistant message start metadata
1907#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1908#[serde(rename_all = "camelCase")]
1909pub struct AssistantMessageStartData {
1910    /// Message ID this start event belongs to, matching subsequent deltas and assistant.message
1911    pub message_id: String,
1912    /// Generation phase this message belongs to for phased-output models
1913    #[serde(skip_serializing_if = "Option::is_none")]
1914    pub phase: Option<String>,
1915}
1916
1917/// Session event "assistant.message_delta". Streaming assistant message delta for incremental response updates
1918#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1919#[serde(rename_all = "camelCase")]
1920pub struct AssistantMessageDeltaData {
1921    /// Incremental text chunk to append to the message content
1922    pub delta_content: String,
1923    /// Message ID this delta belongs to, matching the corresponding assistant.message event
1924    pub message_id: String,
1925    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
1926    #[doc(hidden)]
1927    #[deprecated]
1928    #[serde(skip_serializing_if = "Option::is_none")]
1929    pub parent_tool_call_id: Option<String>,
1930}
1931
1932/// Session event "assistant.turn_end". Turn completion metadata including the turn identifier
1933#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1934#[serde(rename_all = "camelCase")]
1935pub struct AssistantTurnEndData {
1936    /// Model identifier used for this turn, when known
1937    #[serde(skip_serializing_if = "Option::is_none")]
1938    pub model: Option<String>,
1939    /// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event
1940    pub turn_id: String,
1941}
1942
1943/// Session event "assistant.idle". Payload emitted whenever the main agent's processing loop goes idle, including while related background work (running agents or in-flight attached shell commands) is still pending and the session-level idle event is therefore deferred
1944#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1945#[serde(rename_all = "camelCase")]
1946pub struct AssistantIdleData {
1947    /// True when the preceding agentic loop was cancelled via abort signal
1948    #[serde(skip_serializing_if = "Option::is_none")]
1949    pub aborted: Option<bool>,
1950}
1951
1952/// Token usage detail for a single billing category
1953#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1954#[serde(rename_all = "camelCase")]
1955pub struct AssistantUsageCopilotUsageTokenDetail {
1956    /// Number of tokens in this billing batch
1957    pub batch_size: i64,
1958    /// Cost per batch of tokens
1959    pub cost_per_batch: i64,
1960    /// Total token count for this entry
1961    pub token_count: i64,
1962    /// Token category (e.g., "input", "output")
1963    pub token_type: String,
1964}
1965
1966/// Per-request cost and usage data from the CAPI copilot_usage response field
1967#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1968#[serde(rename_all = "camelCase")]
1969pub struct AssistantUsageCopilotUsage {
1970    /// Itemized token usage breakdown
1971    #[doc(hidden)]
1972    #[serde(skip_serializing_if = "Option::is_none")]
1973    pub(crate) token_details: Option<Vec<AssistantUsageCopilotUsageTokenDetail>>,
1974    /// Total cost in nano-AI units for this request
1975    pub total_nano_aiu: f64,
1976}
1977
1978/// Internal per-quota snapshot for assistant usage, including entitlement, consumed requests, overage, reset date, and remaining quota.
1979#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1980#[serde(rename_all = "camelCase")]
1981pub(crate) struct AssistantUsageQuotaSnapshot {
1982    /// Total requests allowed by the entitlement
1983    #[doc(hidden)]
1984    pub(crate) entitlement_requests: i64,
1985    /// Whether the user currently has quota available for use
1986    #[doc(hidden)]
1987    #[serde(skip_serializing_if = "Option::is_none")]
1988    pub(crate) has_quota: Option<bool>,
1989    /// Whether the user has an unlimited usage entitlement
1990    #[doc(hidden)]
1991    pub(crate) is_unlimited_entitlement: bool,
1992    /// Number of additional usage requests made this period
1993    #[doc(hidden)]
1994    pub(crate) overage: f64,
1995    /// Whether additional usage is allowed when quota is exhausted
1996    #[doc(hidden)]
1997    pub(crate) overage_allowed_with_exhausted_quota: bool,
1998    /// Pay-as-you-go additional-usage budget cap in AI credits (1 credit = $0.01); present only when CAPI emits a finite value
1999    #[doc(hidden)]
2000    #[serde(skip_serializing_if = "Option::is_none")]
2001    pub(crate) overage_entitlement: Option<f64>,
2002    /// Percentage of quota remaining (0 to 100)
2003    #[doc(hidden)]
2004    pub(crate) remaining_percentage: f64,
2005    /// Date when the quota resets
2006    #[doc(hidden)]
2007    #[serde(skip_serializing_if = "Option::is_none")]
2008    pub(crate) reset_date: Option<String>,
2009    /// Whether this snapshot uses token-based billing (AI-credits allocation)
2010    #[doc(hidden)]
2011    #[serde(skip_serializing_if = "Option::is_none")]
2012    pub(crate) token_based_billing: Option<bool>,
2013    /// Whether usage is still permitted after quota exhaustion
2014    #[doc(hidden)]
2015    pub(crate) usage_allowed_with_exhausted_quota: bool,
2016    /// Number of requests already consumed
2017    #[doc(hidden)]
2018    pub(crate) used_requests: i64,
2019}
2020
2021/// Session event "assistant.usage". LLM API call usage metrics including tokens, costs, quotas, and billing information
2022#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2023#[serde(rename_all = "camelCase")]
2024pub struct AssistantUsageData {
2025    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
2026    #[serde(skip_serializing_if = "Option::is_none")]
2027    pub api_call_id: Option<String>,
2028    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
2029    #[serde(skip_serializing_if = "Option::is_none")]
2030    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
2031    /// Number of tools available to the model for this call
2032    #[doc(hidden)]
2033    #[serde(skip_serializing_if = "Option::is_none")]
2034    pub(crate) available_tool_count: Option<i64>,
2035    /// Updated prompt-cache expiration for this model call. Present only when the call establishes or refreshes known cache state.
2036    #[serde(skip_serializing_if = "Option::is_none")]
2037    pub cache_expires_at: Option<String>,
2038    /// Number of tokens read from prompt cache
2039    #[serde(skip_serializing_if = "Option::is_none")]
2040    pub cache_read_tokens: Option<i64>,
2041    /// Number of tokens written to prompt cache
2042    #[serde(skip_serializing_if = "Option::is_none")]
2043    pub cache_write_tokens: Option<i64>,
2044    /// Whether the model response was blocked or truncated by content filtering (finish_reason === 'content_filter'). For Anthropic models this corresponds to a 'refusal' stop reason.
2045    #[serde(skip_serializing_if = "Option::is_none")]
2046    pub content_filter_triggered: Option<bool>,
2047    /// Per-request cost and usage data from the CAPI copilot_usage response field
2048    #[serde(skip_serializing_if = "Option::is_none")]
2049    pub copilot_usage: Option<AssistantUsageCopilotUsage>,
2050    /// Model multiplier cost for billing purposes
2051    ///
2052    /// <div class="warning">
2053    ///
2054    /// **Experimental.** This type is part of an experimental wire-protocol surface
2055    /// and may change or be removed in future SDK or CLI releases.
2056    ///
2057    /// </div>
2058    #[serde(skip_serializing_if = "Option::is_none")]
2059    pub cost: Option<f64>,
2060    /// Duration of the API call in milliseconds
2061    #[serde(skip_serializing_if = "Option::is_none")]
2062    pub duration: Option<i64>,
2063    /// Finish reason reported by the model for this API call (e.g. "stop", "length", "tool_calls", "content_filter"). Normalized to OpenAI vocabulary; for Anthropic models a "refusal" stop reason maps to "content_filter".
2064    #[serde(skip_serializing_if = "Option::is_none")]
2065    pub finish_reason: Option<String>,
2066    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
2067    #[serde(skip_serializing_if = "Option::is_none")]
2068    pub initiator: Option<String>,
2069    /// Number of input tokens consumed
2070    #[serde(skip_serializing_if = "Option::is_none")]
2071    pub input_tokens: Option<i64>,
2072    /// Coarse classification of the interaction that produced this call, mirroring the session's per-request agent context (e.g. `conversation-agent`, `conversation-subagent`, `conversation-sampling`, `conversation-background`, `conversation-compaction`, `conversation-user`). Non-billing; lets consumers attribute a model call to a call class (e.g. sub-agent/sidekick) independently of the billing initiator. Absent when the runtime did not classify the request.
2073    #[serde(skip_serializing_if = "Option::is_none")]
2074    pub interaction_type: Option<String>,
2075    /// Average inter-token latency in milliseconds. Only available for streaming requests
2076    #[serde(skip_serializing_if = "Option::is_none")]
2077    pub inter_token_latency_ms: Option<f64>,
2078    /// Model identifier used for this API call
2079    pub model: String,
2080    /// Number of tool calls returned by the model
2081    #[doc(hidden)]
2082    #[serde(skip_serializing_if = "Option::is_none")]
2083    pub(crate) num_tool_calls: Option<i64>,
2084    /// Number of output tokens produced
2085    #[serde(skip_serializing_if = "Option::is_none")]
2086    pub output_tokens: Option<i64>,
2087    /// Parent tool call ID when this usage originates from a sub-agent
2088    #[doc(hidden)]
2089    #[deprecated]
2090    #[serde(skip_serializing_if = "Option::is_none")]
2091    pub parent_tool_call_id: Option<String>,
2092    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
2093    #[serde(skip_serializing_if = "Option::is_none")]
2094    pub provider_call_id: Option<String>,
2095    /// Per-quota resource usage snapshots, keyed by quota identifier
2096    #[doc(hidden)]
2097    #[serde(skip_serializing_if = "Option::is_none")]
2098    pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
2099    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
2100    #[serde(skip_serializing_if = "Option::is_none")]
2101    pub reasoning_effort: Option<String>,
2102    /// Number of output tokens used for reasoning (e.g., chain-of-thought)
2103    #[serde(skip_serializing_if = "Option::is_none")]
2104    pub reasoning_tokens: Option<i64>,
2105    #[serde(skip_serializing_if = "Option::is_none")]
2106    pub rte: Option<bool>,
2107    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
2108    #[serde(skip_serializing_if = "Option::is_none")]
2109    pub service_request_id: Option<String>,
2110    /// Time to first token in milliseconds. Only available for streaming requests
2111    #[serde(skip_serializing_if = "Option::is_none")]
2112    pub time_to_first_token_ms: Option<f64>,
2113    /// Tool-call counts keyed by tool name
2114    #[doc(hidden)]
2115    #[serde(skip_serializing_if = "Option::is_none")]
2116    pub(crate) tool_counts: Option<HashMap<String, i64>>,
2117    /// Number of tokens used by tool definitions for this call
2118    #[doc(hidden)]
2119    #[serde(skip_serializing_if = "Option::is_none")]
2120    pub(crate) tool_token_count: Option<i64>,
2121}
2122
2123/// Content-free structural summary of the failing request for diagnosing malformed 4xx calls
2124#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2125#[serde(rename_all = "camelCase")]
2126pub struct ModelCallFailureRequestFingerprint {
2127    /// Total number of image content parts
2128    pub image_part_count: i64,
2129    /// Image parts whose media type cannot be determined (rejected by strict providers)
2130    pub image_parts_missing_media_type: i64,
2131    /// Role of the final message in the request
2132    #[serde(skip_serializing_if = "Option::is_none")]
2133    pub last_message_role: Option<String>,
2134    /// Total number of messages in the request
2135    pub message_count: i64,
2136    /// Tool calls whose name is missing or empty (rejected by strict providers)
2137    pub nameless_tool_call_count: i64,
2138    /// Total number of tool calls across assistant messages
2139    pub tool_call_count: i64,
2140    /// Number of "tool" result messages in the request
2141    pub tool_result_message_count: i64,
2142}
2143
2144/// Session event "model.call_failure". Failed LLM API call metadata for telemetry
2145#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2146#[serde(rename_all = "camelCase")]
2147pub struct ModelCallFailureData {
2148    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
2149    #[serde(skip_serializing_if = "Option::is_none")]
2150    pub api_call_id: Option<String>,
2151    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
2152    #[serde(skip_serializing_if = "Option::is_none")]
2153    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
2154    /// For HTTP 400 failures only: whether the response carried a structured CAPI error envelope (structured_error, a deterministic validation failure) or no error body (bodyless, the transient gateway/proxy signature). Absent for non-400 failures.
2155    #[serde(skip_serializing_if = "Option::is_none")]
2156    pub bad_request_kind: Option<ModelCallFailureBadRequestKind>,
2157    /// Duration of the failed API call in milliseconds
2158    #[serde(skip_serializing_if = "Option::is_none")]
2159    pub duration_ms: Option<i64>,
2160    /// For HTTP 400 failures only: the `code` from the CAPI error envelope (e.g. 'model_max_prompt_tokens_exceeded') identifying which deterministic validation failure occurred. Raw server-controlled string, emitted only through restricted telemetry. Absent for bodyless or non-400 failures.
2161    #[serde(skip_serializing_if = "Option::is_none")]
2162    pub error_code: Option<String>,
2163    /// Raw provider/runtime error message for restricted telemetry
2164    #[serde(skip_serializing_if = "Option::is_none")]
2165    pub error_message: Option<String>,
2166    /// For HTTP 400 failures only: the `type` from the CAPI error envelope (e.g. 'websocket_error'), a coarser companion to errorCode for envelopes that carry no code. Raw server-controlled string, emitted only through restricted telemetry. Absent for bodyless or non-400 failures.
2167    #[serde(skip_serializing_if = "Option::is_none")]
2168    pub error_type: Option<String>,
2169    /// Whether the failure originated from an API response or the request transport
2170    #[serde(skip_serializing_if = "Option::is_none")]
2171    pub failure_kind: Option<ModelCallFailureKind>,
2172    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
2173    #[serde(skip_serializing_if = "Option::is_none")]
2174    pub initiator: Option<String>,
2175    /// Whether the session selected Auto mode for the failed call
2176    #[serde(skip_serializing_if = "Option::is_none")]
2177    pub is_auto: Option<bool>,
2178    /// Whether the failed call used a bring-your-own-key provider
2179    #[serde(skip_serializing_if = "Option::is_none")]
2180    pub is_byok: Option<bool>,
2181    /// Effective maximum output-token limit for the failed call
2182    #[serde(skip_serializing_if = "Option::is_none")]
2183    pub max_output_tokens: Option<i64>,
2184    /// Effective maximum prompt-token limit for the failed call
2185    #[serde(skip_serializing_if = "Option::is_none")]
2186    pub max_prompt_tokens: Option<i64>,
2187    /// Model identifier used for the failed API call
2188    #[serde(skip_serializing_if = "Option::is_none")]
2189    pub model: Option<String>,
2190    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
2191    #[serde(skip_serializing_if = "Option::is_none")]
2192    pub provider_call_id: Option<String>,
2193    /// Per-quota usage snapshots parsed from the failed response's quota headers, keyed by quota identifier. Present when the error response carried quota headers (e.g. a 402 once the additional spend limit is reached) so the UI can refresh the quota display on failure.
2194    #[doc(hidden)]
2195    #[serde(skip_serializing_if = "Option::is_none")]
2196    pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
2197    /// Reasoning effort level used for the failed model call, if applicable
2198    #[serde(skip_serializing_if = "Option::is_none")]
2199    pub reasoning_effort: Option<String>,
2200    /// Content-free structural summary of the failing request. Contains only counts and shape flags (no prompt content), so it is safe for unrestricted telemetry. Populated only for client-error (4xx) failures.
2201    #[serde(skip_serializing_if = "Option::is_none")]
2202    pub request_fingerprint: Option<ModelCallFailureRequestFingerprint>,
2203    #[serde(skip_serializing_if = "Option::is_none")]
2204    pub rte: Option<bool>,
2205    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
2206    #[serde(skip_serializing_if = "Option::is_none")]
2207    pub service_request_id: Option<String>,
2208    /// Where the failed model call originated
2209    pub source: ModelCallFailureSource,
2210    /// HTTP status code from the failed request
2211    #[serde(skip_serializing_if = "Option::is_none")]
2212    pub status_code: Option<i32>,
2213    /// Transport used for the failed model call (http or websocket)
2214    #[serde(skip_serializing_if = "Option::is_none")]
2215    pub transport: Option<ModelCallFailureTransport>,
2216}
2217
2218/// Session event "model.call_start". Model API dispatch metadata for internal telemetry
2219#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2220#[serde(rename_all = "camelCase")]
2221pub struct ModelCallStartData {
2222    /// Model identifier used for this API call, when known
2223    #[serde(skip_serializing_if = "Option::is_none")]
2224    pub model: Option<String>,
2225    /// Previous response or interaction identifier included in the model request, when present
2226    #[doc(hidden)]
2227    #[serde(skip_serializing_if = "Option::is_none")]
2228    pub(crate) previous_response_id: Option<String>,
2229    /// Identifier of the assistant turn that initiated the model call
2230    pub turn_id: String,
2231}
2232
2233/// Session event "abort". Turn abort information including the reason for termination
2234#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2235#[serde(rename_all = "camelCase")]
2236pub struct AbortData {
2237    /// Finite reason code describing why the current turn was aborted
2238    pub reason: AbortReason,
2239}
2240
2241/// Session event "tool.user_requested". User-initiated tool invocation request with tool name and arguments
2242#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2243#[serde(rename_all = "camelCase")]
2244pub struct ToolUserRequestedData {
2245    /// Arguments for the tool invocation
2246    #[serde(skip_serializing_if = "Option::is_none")]
2247    pub arguments: Option<serde_json::Value>,
2248    /// Unique identifier for this tool call
2249    pub tool_call_id: String,
2250    /// Name of the tool the user wants to invoke
2251    pub tool_name: String,
2252}
2253
2254/// Shell-aware path hints for a shell tool's command, captured at start time so consumers can snapshot a file's pre-image before the tool runs.
2255#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2256#[serde(rename_all = "camelCase")]
2257pub struct ToolExecutionStartShellToolInfo {
2258    /// The command with a redundant leading `cd` into the working directory removed, present only when there was one to remove. Computed with the same routine the shell driver applies before spawning, so a surface that renders this shows the text that actually runs. Consumers that display it should keep the original tool arguments available on demand.
2259    ///
2260    /// <div class="warning">
2261    ///
2262    /// **Experimental.** This type is part of an experimental wire-protocol surface
2263    /// and may change or be removed in future SDK or CLI releases.
2264    ///
2265    /// </div>
2266    #[serde(skip_serializing_if = "Option::is_none")]
2267    pub display_command: Option<String>,
2268    /// Whether the command includes a file write redirection (e.g., > or >>).
2269    pub has_write_file_redirection: bool,
2270    /// File paths the command may read or write, derived from the command at start time. Produced by the same shell-aware extractor as PermissionRequestShell.possiblePaths, so it is present even when the command is auto-approved and no permission request fires.
2271    pub possible_paths: Vec<String>,
2272}
2273
2274/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
2275#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2276#[serde(rename_all = "camelCase")]
2277pub struct ToolExecutionStartToolDescriptionMetaUI {
2278    /// URI of the UI resource
2279    #[serde(skip_serializing_if = "Option::is_none")]
2280    pub resource_uri: Option<String>,
2281    /// Who can access this tool
2282    #[serde(skip_serializing_if = "Option::is_none")]
2283    pub visibility: Option<Vec<ToolExecutionStartToolDescriptionMetaUIVisibility>>,
2284}
2285
2286/// MCP Apps metadata for UI resource association
2287#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2288#[serde(rename_all = "camelCase")]
2289pub struct ToolExecutionStartToolDescriptionMeta {
2290    /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
2291    #[serde(skip_serializing_if = "Option::is_none")]
2292    pub ui: Option<ToolExecutionStartToolDescriptionMetaUI>,
2293}
2294
2295/// Tool definition metadata, present for MCP tools with MCP Apps support
2296#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2297#[serde(rename_all = "camelCase")]
2298pub struct ToolExecutionStartToolDescription {
2299    /// MCP Apps metadata for UI resource association
2300    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
2301    pub meta: Option<ToolExecutionStartToolDescriptionMeta>,
2302    /// Tool description
2303    #[serde(skip_serializing_if = "Option::is_none")]
2304    pub description: Option<String>,
2305    /// Tool name
2306    pub name: String,
2307}
2308
2309/// Session event "tool.execution_start". Tool execution startup details including MCP server information when applicable
2310#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2311#[serde(rename_all = "camelCase")]
2312pub struct ToolExecutionStartData {
2313    /// Arguments passed to the tool
2314    #[serde(skip_serializing_if = "Option::is_none")]
2315    pub arguments: Option<serde_json::Value>,
2316    /// When true, the tool output should be displayed expanded (verbatim) in the CLI timeline
2317    #[serde(skip_serializing_if = "Option::is_none")]
2318    pub display_verbatim: Option<bool>,
2319    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
2320    #[serde(skip_serializing_if = "Option::is_none")]
2321    pub mcp_server_name: Option<String>,
2322    /// Original tool name on the MCP server, when the tool is an MCP tool
2323    #[serde(skip_serializing_if = "Option::is_none")]
2324    pub mcp_tool_name: Option<String>,
2325    /// Model identifier that generated this tool call
2326    #[serde(skip_serializing_if = "Option::is_none")]
2327    pub model: Option<String>,
2328    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
2329    #[doc(hidden)]
2330    #[deprecated]
2331    #[serde(skip_serializing_if = "Option::is_none")]
2332    pub parent_tool_call_id: Option<String>,
2333    #[serde(skip_serializing_if = "Option::is_none")]
2334    pub rte: Option<bool>,
2335    /// Shell-tool path hints derived from the command at start time for shell tools (bash/powershell/local_shell). Produced by the same shell-aware extractor as PermissionRequestShell.possiblePaths, so it is present even when the command is auto-approved and no permission request fires. Absent for non-shell tools.
2336    #[serde(skip_serializing_if = "Option::is_none")]
2337    pub shell_tool_info: Option<ToolExecutionStartShellToolInfo>,
2338    /// Unique identifier for this tool call
2339    pub tool_call_id: String,
2340    /// Tool definition metadata, present for MCP tools with MCP Apps support
2341    #[serde(skip_serializing_if = "Option::is_none")]
2342    pub tool_description: Option<ToolExecutionStartToolDescription>,
2343    /// Name of the tool being executed
2344    pub tool_name: String,
2345    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
2346    #[serde(skip_serializing_if = "Option::is_none")]
2347    pub turn_id: Option<String>,
2348}
2349
2350/// Session event "tool.execution_partial_result". Streaming tool execution output for incremental result display
2351#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2352#[serde(rename_all = "camelCase")]
2353pub struct ToolExecutionPartialResultData {
2354    /// Incremental output chunk from the running tool
2355    pub partial_output: String,
2356    /// Tool call ID this partial result belongs to
2357    pub tool_call_id: String,
2358}
2359
2360/// Session event "tool.execution_progress". Tool execution progress notification with status message
2361#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2362#[serde(rename_all = "camelCase")]
2363pub struct ToolExecutionProgressData {
2364    /// Human-readable progress status message (e.g., from an MCP server)
2365    pub progress_message: String,
2366    /// Tool call ID this progress notification belongs to
2367    pub tool_call_id: String,
2368}
2369
2370/// Error details when the tool execution failed
2371#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2372#[serde(rename_all = "camelCase")]
2373pub struct ToolExecutionCompleteError {
2374    /// Machine-readable error code
2375    #[serde(skip_serializing_if = "Option::is_none")]
2376    pub code: Option<String>,
2377    /// Human-readable error message
2378    pub message: String,
2379}
2380
2381/// A source supplied by a tool that should be made available to the model as citable content.
2382///
2383/// <div class="warning">
2384///
2385/// **Experimental.** This type is part of an experimental wire-protocol surface
2386/// and may change or be removed in future SDK or CLI releases.
2387///
2388/// </div>
2389#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2390#[serde(rename_all = "camelCase")]
2391pub struct CitableSource {
2392    /// The source text made available to the model as citable content.
2393    pub content: String,
2394    /// Stable identifier for this source within the tool result. Used for deduplication and may be used by future provider integrations to correlate response citations back to the originating source.
2395    pub id: String,
2396    /// File path relative to the agent's workspace root, when the source is a file.
2397    #[serde(skip_serializing_if = "Option::is_none")]
2398    pub path: Option<String>,
2399    /// Human-readable title of the source.
2400    #[serde(skip_serializing_if = "Option::is_none")]
2401    pub title: Option<String>,
2402    /// URL of the source, when it is a web resource.
2403    #[serde(skip_serializing_if = "Option::is_none")]
2404    pub url: Option<String>,
2405}
2406
2407/// Plain text content block
2408#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2409#[serde(rename_all = "camelCase")]
2410pub struct ToolExecutionCompleteContentText {
2411    /// The text content
2412    pub text: String,
2413    /// Content block type discriminator
2414    pub r#type: ToolExecutionCompleteContentTextType,
2415}
2416
2417/// Deprecated for shell command exit metadata. Use ToolExecutionCompleteContentShellExit instead.
2418#[doc(hidden)]
2419#[deprecated]
2420#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2421#[serde(rename_all = "camelCase")]
2422pub struct ToolExecutionCompleteContentTerminal {
2423    /// Working directory where the command was executed
2424    #[serde(skip_serializing_if = "Option::is_none")]
2425    pub cwd: Option<String>,
2426    /// Process exit code, if the command has completed
2427    #[serde(skip_serializing_if = "Option::is_none")]
2428    pub exit_code: Option<i64>,
2429    /// Terminal/shell output text
2430    pub text: String,
2431    /// Content block type discriminator
2432    pub r#type: ToolExecutionCompleteContentTerminalType,
2433}
2434
2435/// Shell command exit metadata with optional output preview
2436#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2437#[serde(rename_all = "camelCase")]
2438pub struct ToolExecutionCompleteContentShellExit {
2439    /// Working directory where the shell command was executed
2440    #[serde(skip_serializing_if = "Option::is_none")]
2441    pub cwd: Option<String>,
2442    /// Exit code from the completed shell command
2443    pub exit_code: i64,
2444    /// Output associated with this shell command, if available. May be partial, truncated, or a preview; not guaranteed to be full output.
2445    #[serde(skip_serializing_if = "Option::is_none")]
2446    pub output_preview: Option<String>,
2447    /// Whether outputPreview is known to be incomplete or truncated
2448    #[serde(skip_serializing_if = "Option::is_none")]
2449    pub output_truncated: Option<bool>,
2450    /// Shell id, as assigned by Copilot runtime
2451    pub shell_id: String,
2452    /// Content block type discriminator
2453    pub r#type: ToolExecutionCompleteContentShellExitType,
2454}
2455
2456/// Image content block with base64-encoded data
2457#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2458#[serde(rename_all = "camelCase")]
2459pub struct ToolExecutionCompleteContentImage {
2460    /// Base64-encoded image data
2461    pub data: String,
2462    /// MIME type of the image (e.g., image/png, image/jpeg)
2463    pub mime_type: String,
2464    /// Content block type discriminator
2465    pub r#type: ToolExecutionCompleteContentImageType,
2466}
2467
2468/// Audio content block with base64-encoded data
2469#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2470#[serde(rename_all = "camelCase")]
2471pub struct ToolExecutionCompleteContentAudio {
2472    /// Base64-encoded audio data
2473    pub data: String,
2474    /// MIME type of the audio (e.g., audio/wav, audio/mpeg)
2475    pub mime_type: String,
2476    /// Content block type discriminator
2477    pub r#type: ToolExecutionCompleteContentAudioType,
2478}
2479
2480/// Icon image for a resource
2481#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2482#[serde(rename_all = "camelCase")]
2483pub struct ToolExecutionCompleteContentResourceLinkIcon {
2484    /// MIME type of the icon image
2485    #[serde(skip_serializing_if = "Option::is_none")]
2486    pub mime_type: Option<String>,
2487    /// Available icon sizes (e.g., ['16x16', '32x32'])
2488    #[serde(skip_serializing_if = "Option::is_none")]
2489    pub sizes: Option<Vec<String>>,
2490    /// URL or path to the icon image
2491    pub src: String,
2492    /// Theme variant this icon is intended for
2493    #[serde(skip_serializing_if = "Option::is_none")]
2494    pub theme: Option<ToolExecutionCompleteContentResourceLinkIconTheme>,
2495}
2496
2497/// Resource link content block referencing an external resource
2498#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2499#[serde(rename_all = "camelCase")]
2500pub struct ToolExecutionCompleteContentResourceLink {
2501    /// Human-readable description of the resource
2502    #[serde(skip_serializing_if = "Option::is_none")]
2503    pub description: Option<String>,
2504    /// Icons associated with this resource
2505    #[serde(skip_serializing_if = "Option::is_none")]
2506    pub icons: Option<Vec<ToolExecutionCompleteContentResourceLinkIcon>>,
2507    /// MIME type of the resource content
2508    #[serde(skip_serializing_if = "Option::is_none")]
2509    pub mime_type: Option<String>,
2510    /// Resource name identifier
2511    pub name: String,
2512    /// Size of the resource in bytes
2513    #[serde(skip_serializing_if = "Option::is_none")]
2514    pub size: Option<i64>,
2515    /// Human-readable display title for the resource
2516    #[serde(skip_serializing_if = "Option::is_none")]
2517    pub title: Option<String>,
2518    /// Content block type discriminator
2519    pub r#type: ToolExecutionCompleteContentResourceLinkType,
2520    /// URI identifying the resource
2521    pub uri: String,
2522}
2523
2524/// Embedded text resource contents identified by a URI, with an optional MIME type and a text payload.
2525#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2526#[serde(rename_all = "camelCase")]
2527pub struct EmbeddedTextResourceContents {
2528    /// MIME type of the text content
2529    #[serde(skip_serializing_if = "Option::is_none")]
2530    pub mime_type: Option<String>,
2531    /// Text content of the resource
2532    pub text: String,
2533    /// URI identifying the resource
2534    pub uri: String,
2535}
2536
2537/// Embedded binary resource contents identified by a URI, with an optional MIME type and a base64-encoded blob.
2538#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2539#[serde(rename_all = "camelCase")]
2540pub struct EmbeddedBlobResourceContents {
2541    /// Base64-encoded binary content of the resource
2542    pub blob: String,
2543    /// MIME type of the blob content
2544    #[serde(skip_serializing_if = "Option::is_none")]
2545    pub mime_type: Option<String>,
2546    /// URI identifying the resource
2547    pub uri: String,
2548}
2549
2550/// Embedded resource content block with inline text or binary data
2551#[derive(Debug, Clone, Serialize, Deserialize)]
2552#[serde(rename_all = "camelCase")]
2553pub struct ToolExecutionCompleteContentResource {
2554    /// The embedded resource contents, either text or base64-encoded binary
2555    pub resource: ToolExecutionCompleteContentResourceDetails,
2556    /// Content block type discriminator
2557    pub r#type: ToolExecutionCompleteContentResourceType,
2558}
2559
2560/// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
2561#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2562#[serde(rename_all = "camelCase")]
2563pub struct ToolExecutionCompleteUIResourceMetaUICsp {
2564    #[serde(skip_serializing_if = "Option::is_none")]
2565    pub base_uri_domains: Option<Vec<String>>,
2566    #[serde(skip_serializing_if = "Option::is_none")]
2567    pub connect_domains: Option<Vec<String>>,
2568    #[serde(skip_serializing_if = "Option::is_none")]
2569    pub frame_domains: Option<Vec<String>>,
2570    #[serde(skip_serializing_if = "Option::is_none")]
2571    pub resource_domains: Option<Vec<String>>,
2572}
2573
2574/// Marker object for camera permission on an MCP Apps UI resource.
2575#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2576#[serde(rename_all = "camelCase")]
2577pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsCamera {}
2578
2579/// Marker object for clipboard-write permission on an MCP Apps UI resource.
2580#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2581#[serde(rename_all = "camelCase")]
2582pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite {}
2583
2584/// Marker object for geolocation permission on an MCP Apps UI resource.
2585#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2586#[serde(rename_all = "camelCase")]
2587pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation {}
2588
2589/// Marker object for microphone permission on an MCP Apps UI resource.
2590#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2591#[serde(rename_all = "camelCase")]
2592pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone {}
2593
2594/// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
2595#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2596#[serde(rename_all = "camelCase")]
2597pub struct ToolExecutionCompleteUIResourceMetaUIPermissions {
2598    /// Marker object for camera permission on an MCP Apps UI resource.
2599    #[serde(skip_serializing_if = "Option::is_none")]
2600    pub camera: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsCamera>,
2601    /// Marker object for clipboard-write permission on an MCP Apps UI resource.
2602    #[serde(skip_serializing_if = "Option::is_none")]
2603    pub clipboard_write: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite>,
2604    /// Marker object for geolocation permission on an MCP Apps UI resource.
2605    #[serde(skip_serializing_if = "Option::is_none")]
2606    pub geolocation: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation>,
2607    /// Marker object for microphone permission on an MCP Apps UI resource.
2608    #[serde(skip_serializing_if = "Option::is_none")]
2609    pub microphone: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone>,
2610}
2611
2612/// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
2613#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2614#[serde(rename_all = "camelCase")]
2615pub struct ToolExecutionCompleteUIResourceMetaUI {
2616    /// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
2617    #[serde(skip_serializing_if = "Option::is_none")]
2618    pub csp: Option<ToolExecutionCompleteUIResourceMetaUICsp>,
2619    #[serde(skip_serializing_if = "Option::is_none")]
2620    pub domain: Option<String>,
2621    /// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
2622    #[serde(skip_serializing_if = "Option::is_none")]
2623    pub permissions: Option<ToolExecutionCompleteUIResourceMetaUIPermissions>,
2624    #[serde(skip_serializing_if = "Option::is_none")]
2625    pub prefers_border: Option<bool>,
2626}
2627
2628/// Resource-level UI metadata (CSP, permissions, visual preferences)
2629#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2630#[serde(rename_all = "camelCase")]
2631pub struct ToolExecutionCompleteUIResourceMeta {
2632    /// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
2633    #[serde(skip_serializing_if = "Option::is_none")]
2634    pub ui: Option<ToolExecutionCompleteUIResourceMetaUI>,
2635}
2636
2637/// MCP Apps UI resource content for rendering in a sandboxed iframe
2638#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2639#[serde(rename_all = "camelCase")]
2640pub struct ToolExecutionCompleteUIResource {
2641    /// Resource-level UI metadata (CSP, permissions, visual preferences)
2642    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
2643    pub meta: Option<ToolExecutionCompleteUIResourceMeta>,
2644    /// Base64-encoded HTML content
2645    #[serde(skip_serializing_if = "Option::is_none")]
2646    pub blob: Option<String>,
2647    /// MIME type of the content
2648    pub mime_type: String,
2649    /// HTML content as a string
2650    #[serde(skip_serializing_if = "Option::is_none")]
2651    pub text: Option<String>,
2652    /// The ui:// URI of the resource
2653    pub uri: String,
2654}
2655
2656/// Tool execution result on success
2657#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2658#[serde(rename_all = "camelCase")]
2659pub struct ToolExecutionCompleteResult {
2660    /// Model-facing binary results (base64 inline or size-omitted markers) sent to the LLM for this tool call
2661    ///
2662    /// <div class="warning">
2663    ///
2664    /// **Experimental.** This type is part of an experimental wire-protocol surface
2665    /// and may change or be removed in future SDK or CLI releases.
2666    ///
2667    /// </div>
2668    #[serde(skip_serializing_if = "Option::is_none")]
2669    pub binary_results_for_llm: Option<Vec<serde_json::Value>>,
2670    /// Provider-neutral source material this tool makes available to the model as citable content. Persisted so it survives session resume. Experimental.
2671    ///
2672    /// <div class="warning">
2673    ///
2674    /// **Experimental.** This type is part of an experimental wire-protocol surface
2675    /// and may change or be removed in future SDK or CLI releases.
2676    ///
2677    /// </div>
2678    #[serde(skip_serializing_if = "Option::is_none")]
2679    pub citable_sources: Option<Vec<CitableSource>>,
2680    /// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency
2681    pub content: String,
2682    /// Structured content blocks (text, images, audio, resources) returned by the tool in their native format
2683    #[serde(skip_serializing_if = "Option::is_none")]
2684    pub contents: Option<Vec<ToolExecutionCompleteContent>>,
2685    /// Full detailed tool result for UI/timeline display, preserving complete content such as diffs. Falls back to content when absent.
2686    #[serde(skip_serializing_if = "Option::is_none")]
2687    pub detailed_content: Option<String>,
2688    /// FIDES IFC label projected from tool ingress metadata (MCP `CallToolResult._meta` or synthesized built-in ingress labels) — persisted as `{ ifc: ... }` (only the `ifc` key, not the whole `_meta`). Persisted so the FIDES IFC label survives session resume: the engine rehydrates accumulated taint by replaying these on load. Populated for ingress sources when FIDES IFC is on. Experimental.
2689    ///
2690    /// <div class="warning">
2691    ///
2692    /// **Experimental.** This type is part of an experimental wire-protocol surface
2693    /// and may change or be removed in future SDK or CLI releases.
2694    ///
2695    /// </div>
2696    #[serde(skip_serializing_if = "Option::is_none")]
2697    pub mcp_meta: Option<serde_json::Value>,
2698    /// Structured content (arbitrary JSON) returned verbatim by the MCP tool
2699    #[serde(skip_serializing_if = "Option::is_none")]
2700    pub structured_content: Option<serde_json::Value>,
2701    /// MCP Apps UI resource content for rendering in a sandboxed iframe
2702    #[serde(skip_serializing_if = "Option::is_none")]
2703    pub ui_resource: Option<ToolExecutionCompleteUIResource>,
2704}
2705
2706/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
2707#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2708#[serde(rename_all = "camelCase")]
2709pub struct ToolExecutionCompleteToolDescriptionMetaUI {
2710    /// URI of the UI resource
2711    #[serde(skip_serializing_if = "Option::is_none")]
2712    pub resource_uri: Option<String>,
2713    /// Who can access this tool
2714    #[serde(skip_serializing_if = "Option::is_none")]
2715    pub visibility: Option<Vec<ToolExecutionCompleteToolDescriptionMetaUIVisibility>>,
2716}
2717
2718/// MCP Apps metadata for UI resource association
2719#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2720#[serde(rename_all = "camelCase")]
2721pub struct ToolExecutionCompleteToolDescriptionMeta {
2722    /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
2723    #[serde(skip_serializing_if = "Option::is_none")]
2724    pub ui: Option<ToolExecutionCompleteToolDescriptionMetaUI>,
2725}
2726
2727/// Tool definition metadata, present for MCP tools with MCP Apps support
2728#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2729#[serde(rename_all = "camelCase")]
2730pub struct ToolExecutionCompleteToolDescription {
2731    /// MCP Apps metadata for UI resource association
2732    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
2733    pub meta: Option<ToolExecutionCompleteToolDescriptionMeta>,
2734    /// Tool description
2735    #[serde(skip_serializing_if = "Option::is_none")]
2736    pub description: Option<String>,
2737    /// Tool name
2738    pub name: String,
2739}
2740
2741/// Session event "tool.execution_complete". Tool execution completion results including success status, detailed output, and error information
2742#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2743#[serde(rename_all = "camelCase")]
2744pub struct ToolExecutionCompleteData {
2745    /// Error details when the tool execution failed
2746    #[serde(skip_serializing_if = "Option::is_none")]
2747    pub error: Option<ToolExecutionCompleteError>,
2748    /// CAPI interaction ID for correlating this tool execution with upstream telemetry
2749    #[serde(skip_serializing_if = "Option::is_none")]
2750    pub interaction_id: Option<String>,
2751    /// Whether this tool call was explicitly requested by the user rather than the assistant
2752    #[serde(skip_serializing_if = "Option::is_none")]
2753    pub is_user_requested: Option<bool>,
2754    /// FIDES IFC label projected from tool ingress metadata (MCP `CallToolResult._meta` or synthesized built-in ingress labels). Persisted as `{ ifc: ... }` so the label survives session resume, including model-visible failure results. Experimental.
2755    ///
2756    /// <div class="warning">
2757    ///
2758    /// **Experimental.** This type is part of an experimental wire-protocol surface
2759    /// and may change or be removed in future SDK or CLI releases.
2760    ///
2761    /// </div>
2762    #[serde(skip_serializing_if = "Option::is_none")]
2763    pub mcp_meta: Option<serde_json::Value>,
2764    /// Model identifier that generated this tool call
2765    #[serde(skip_serializing_if = "Option::is_none")]
2766    pub model: Option<String>,
2767    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
2768    #[doc(hidden)]
2769    #[deprecated]
2770    #[serde(skip_serializing_if = "Option::is_none")]
2771    pub parent_tool_call_id: Option<String>,
2772    /// Tool execution result on success
2773    #[serde(skip_serializing_if = "Option::is_none")]
2774    pub result: Option<ToolExecutionCompleteResult>,
2775    #[serde(skip_serializing_if = "Option::is_none")]
2776    pub rte: Option<bool>,
2777    /// Whether this tool execution ran inside a sandbox container
2778    #[serde(skip_serializing_if = "Option::is_none")]
2779    pub sandboxed: Option<bool>,
2780    /// Whether the tool execution completed successfully
2781    pub success: bool,
2782    /// Unique identifier for the completed tool call
2783    pub tool_call_id: String,
2784    /// Tool definition metadata, present for MCP tools with MCP Apps support
2785    #[serde(skip_serializing_if = "Option::is_none")]
2786    pub tool_description: Option<ToolExecutionCompleteToolDescription>,
2787    /// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
2788    #[serde(skip_serializing_if = "Option::is_none")]
2789    pub tool_telemetry: Option<HashMap<String, serde_json::Value>>,
2790    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
2791    #[serde(skip_serializing_if = "Option::is_none")]
2792    pub turn_id: Option<String>,
2793}
2794
2795/// Session event "tool_search.activated". Persisted generic client-side tool activations restored when a session resumes.
2796#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2797#[serde(rename_all = "camelCase")]
2798pub struct ToolSearchActivatedData {
2799    /// Tool-search strategy that activated the definitions.
2800    pub strategy: String,
2801    /// Names of tool definitions activated by this search invocation.
2802    pub tool_names: Vec<String>,
2803}
2804
2805/// Session event "skill.invoked". Skill invocation details including content, allowed tools, and plugin metadata
2806#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2807#[serde(rename_all = "camelCase")]
2808pub struct SkillInvokedData {
2809    /// Tool names that should be auto-approved when this skill is active
2810    #[serde(skip_serializing_if = "Option::is_none")]
2811    pub allowed_tools: Option<Vec<String>>,
2812    /// Full content of the skill file, injected into the conversation for the model
2813    pub content: String,
2814    /// Description of the skill from its SKILL.md frontmatter
2815    #[serde(skip_serializing_if = "Option::is_none")]
2816    pub description: Option<String>,
2817    /// Model identifier active when the skill was invoked, when known
2818    #[serde(skip_serializing_if = "Option::is_none")]
2819    pub model: Option<String>,
2820    /// Name of the invoked skill
2821    pub name: String,
2822    /// File path to the SKILL.md definition
2823    pub path: String,
2824    /// Name of the plugin this skill originated from, when applicable
2825    #[serde(skip_serializing_if = "Option::is_none")]
2826    pub plugin_name: Option<String>,
2827    /// Version of the plugin this skill originated from, when applicable
2828    #[serde(skip_serializing_if = "Option::is_none")]
2829    pub plugin_version: Option<String>,
2830    /// Source identifier for where the skill was discovered. Known values include: project (workspace skill), inherited (parent-directory skill), personal-copilot (~/.copilot/skills), personal-agents (~/.agents/skills), custom (configured directory), plugin (installed plugin), builtin (bundled runtime skill), and remote (org/enterprise skill)
2831    #[serde(skip_serializing_if = "Option::is_none")]
2832    pub source: Option<String>,
2833    /// What triggered the skill invocation: `user-invoked` (explicit user action, such as via a slash command or UI affordance), `agent-invoked` (agent requested the skill), or `context-load` (loaded as part of another context, such as preloading skills configured on a custom agent or subagent)
2834    #[serde(skip_serializing_if = "Option::is_none")]
2835    pub trigger: Option<SkillInvokedTrigger>,
2836}
2837
2838/// Session event "subagent.started". Sub-agent startup details including parent tool call and agent information
2839#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2840#[serde(rename_all = "camelCase")]
2841pub struct SubagentStartedData {
2842    /// Description of what the sub-agent does
2843    pub agent_description: String,
2844    /// Human-readable display name of the sub-agent
2845    pub agent_display_name: String,
2846    /// Internal name of the sub-agent
2847    pub agent_name: String,
2848    /// Model the sub-agent will run with, when known at start.
2849    #[serde(skip_serializing_if = "Option::is_none")]
2850    pub model: Option<String>,
2851    /// Tool call ID of the parent tool invocation that spawned this sub-agent
2852    pub tool_call_id: String,
2853}
2854
2855/// Session event "subagent.completed". Sub-agent completion details for successful execution
2856#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2857#[serde(rename_all = "camelCase")]
2858pub struct SubagentCompletedData {
2859    /// Human-readable display name of the sub-agent
2860    pub agent_display_name: String,
2861    /// Internal name of the sub-agent
2862    pub agent_name: String,
2863    /// Wall-clock duration of the sub-agent execution in milliseconds
2864    #[serde(skip_serializing_if = "Option::is_none")]
2865    pub duration_ms: Option<i64>,
2866    /// Model used by the sub-agent
2867    #[serde(skip_serializing_if = "Option::is_none")]
2868    pub model: Option<String>,
2869    /// Tool call ID of the parent tool invocation that spawned this sub-agent
2870    pub tool_call_id: String,
2871    /// Total tokens (input + output) consumed by the sub-agent
2872    #[serde(skip_serializing_if = "Option::is_none")]
2873    pub total_tokens: Option<i64>,
2874    /// Total number of tool calls made by the sub-agent
2875    #[serde(skip_serializing_if = "Option::is_none")]
2876    pub total_tool_calls: Option<i64>,
2877}
2878
2879/// Session event "subagent.failed". Sub-agent failure details including error message and agent information
2880#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2881#[serde(rename_all = "camelCase")]
2882pub struct SubagentFailedData {
2883    /// Human-readable display name of the sub-agent
2884    pub agent_display_name: String,
2885    /// Internal name of the sub-agent
2886    pub agent_name: String,
2887    /// Wall-clock duration of the sub-agent execution in milliseconds
2888    #[serde(skip_serializing_if = "Option::is_none")]
2889    pub duration_ms: Option<i64>,
2890    /// Error message describing why the sub-agent failed
2891    pub error: String,
2892    /// Model selected for the sub-agent, when known
2893    #[serde(skip_serializing_if = "Option::is_none")]
2894    pub model: Option<String>,
2895    /// Tool call ID of the parent tool invocation that spawned this sub-agent
2896    pub tool_call_id: String,
2897    /// Total tokens (input + output) consumed before the sub-agent failed
2898    #[serde(skip_serializing_if = "Option::is_none")]
2899    pub total_tokens: Option<i64>,
2900    /// Total number of tool calls made before the sub-agent failed
2901    #[serde(skip_serializing_if = "Option::is_none")]
2902    pub total_tool_calls: Option<i64>,
2903}
2904
2905/// Session event "subagent.selected". Custom agent selection details including name and available tools
2906#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2907#[serde(rename_all = "camelCase")]
2908pub struct SubagentSelectedData {
2909    /// Human-readable display name of the selected custom agent
2910    pub agent_display_name: String,
2911    /// Internal name of the selected custom agent
2912    pub agent_name: String,
2913    /// List of tool names available to this agent, or null for all tools
2914    pub tools: Option<Vec<String>>,
2915}
2916
2917/// Session event "subagent.deselected". Empty payload; the event signals that the custom agent was deselected, returning to the default agent
2918#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2919#[serde(rename_all = "camelCase")]
2920pub struct SubagentDeselectedData {}
2921
2922/// Session event "hook.start". Hook invocation start details including type and input data
2923#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2924#[serde(rename_all = "camelCase")]
2925pub struct HookStartData {
2926    /// Unique identifier for this hook invocation
2927    pub hook_invocation_id: String,
2928    /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
2929    pub hook_type: String,
2930    /// Input data passed to the hook
2931    #[serde(skip_serializing_if = "Option::is_none")]
2932    pub input: Option<serde_json::Value>,
2933}
2934
2935/// Error details when the hook failed
2936#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2937#[serde(rename_all = "camelCase")]
2938pub struct HookEndError {
2939    /// Human-readable error message
2940    pub message: String,
2941    /// Source label of the hook that errored (e.g. the plugin it was loaded from), when known
2942    #[serde(skip_serializing_if = "Option::is_none")]
2943    pub source: Option<String>,
2944    /// Error stack trace, when available
2945    #[serde(skip_serializing_if = "Option::is_none")]
2946    pub stack: Option<String>,
2947}
2948
2949/// Session event "hook.end". Hook invocation completion details including output, success status, and error information
2950#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2951#[serde(rename_all = "camelCase")]
2952pub struct HookEndData {
2953    /// Error details when the hook failed
2954    #[serde(skip_serializing_if = "Option::is_none")]
2955    pub error: Option<HookEndError>,
2956    /// Identifier matching the corresponding hook.start event
2957    pub hook_invocation_id: String,
2958    /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
2959    pub hook_type: String,
2960    /// Output data produced by the hook
2961    #[serde(skip_serializing_if = "Option::is_none")]
2962    pub output: Option<serde_json::Value>,
2963    /// Whether the hook completed successfully
2964    pub success: bool,
2965}
2966
2967/// Session event "hook.progress". Ephemeral progress update from a running hook process
2968#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2969#[serde(rename_all = "camelCase")]
2970pub struct HookProgressData {
2971    /// Human-readable progress message from the hook process
2972    pub message: String,
2973    /// When true, this status message replaces the previous temporary one instead of accumulating
2974    #[serde(skip_serializing_if = "Option::is_none")]
2975    pub temporary: Option<bool>,
2976}
2977
2978/// Session event "session.binary_asset". Canonical bytes for a content-addressed binary asset shared by reference across events
2979#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2980#[serde(rename_all = "camelCase")]
2981pub struct SessionBinaryAssetData {
2982    /// Content-addressed id for this binary asset (e.g. "sha256:...").
2983    pub asset_id: String,
2984    /// Decoded byte length of the binary asset
2985    pub byte_length: i64,
2986    /// Base64-encoded binary data
2987    pub data: String,
2988    /// Human-readable description of the binary data
2989    #[serde(skip_serializing_if = "Option::is_none")]
2990    pub description: Option<String>,
2991    /// Optional metadata from the producing tool.
2992    #[serde(skip_serializing_if = "Option::is_none")]
2993    pub metadata: Option<HashMap<String, serde_json::Value>>,
2994    /// MIME type of the binary asset
2995    pub mime_type: String,
2996    /// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
2997    pub r#type: BinaryAssetType,
2998}
2999
3000/// Metadata about the prompt template and its construction
3001#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3002#[serde(rename_all = "camelCase")]
3003pub struct SystemMessageMetadata {
3004    /// Version identifier of the prompt template used
3005    #[serde(skip_serializing_if = "Option::is_none")]
3006    pub prompt_version: Option<String>,
3007    /// Template variables used when constructing the prompt
3008    #[serde(skip_serializing_if = "Option::is_none")]
3009    pub variables: Option<HashMap<String, serde_json::Value>>,
3010}
3011
3012/// Session event "system.message". System/developer instruction content with role and optional template metadata
3013#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3014#[serde(rename_all = "camelCase")]
3015pub struct SystemMessageData {
3016    /// The system or developer prompt text sent as model input
3017    pub content: String,
3018    /// Logical interaction identifier for the model run receiving this prompt
3019    #[serde(skip_serializing_if = "Option::is_none")]
3020    pub interaction_id: Option<String>,
3021    /// Metadata about the prompt template and its construction
3022    #[serde(skip_serializing_if = "Option::is_none")]
3023    pub metadata: Option<SystemMessageMetadata>,
3024    /// Optional name identifier for the message source
3025    #[serde(skip_serializing_if = "Option::is_none")]
3026    pub name: Option<String>,
3027    /// Message role: "system" for system prompts, "developer" for developer-injected instructions
3028    pub role: SystemMessageRole,
3029}
3030
3031/// Session event "system.notification". System-generated notification for runtime events like background task completion
3032#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3033#[serde(rename_all = "camelCase")]
3034pub struct SystemNotificationData {
3035    /// The notification text, typically wrapped in <system_notification> XML tags
3036    pub content: String,
3037    /// Structured metadata identifying what triggered this notification
3038    pub kind: serde_json::Value,
3039}
3040
3041/// A parsed command identifier in a shell permission request, including whether it is read-only.
3042#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3043#[serde(rename_all = "camelCase")]
3044pub struct PermissionRequestShellCommand {
3045    /// Command identifier (e.g., executable name)
3046    pub identifier: String,
3047    /// Whether this command is read-only (no side effects)
3048    pub read_only: bool,
3049}
3050
3051/// A parsed shell command segment used for argument-aware managed policy matching.
3052#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3053#[serde(rename_all = "camelCase")]
3054pub struct PermissionRequestShellCommandSegment {
3055    /// Full text of this command segment, including arguments
3056    pub full_command_text: String,
3057    /// Command identifier (e.g., executable name)
3058    pub identifier: String,
3059}
3060
3061/// A URL that may be accessed by a command in a shell permission request.
3062#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3063#[serde(rename_all = "camelCase")]
3064pub struct PermissionRequestShellPossibleUrl {
3065    /// URL that may be accessed by the command
3066    pub url: String,
3067}
3068
3069/// Shell command permission request
3070#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3071#[serde(rename_all = "camelCase")]
3072pub struct PermissionRequestShell {
3073    /// Whether the UI can offer session-wide approval for this command pattern
3074    pub can_offer_session_approval: bool,
3075    /// Parsed command identifiers found in the command text
3076    pub commands: Vec<PermissionRequestShellCommand>,
3077    /// Parsed command segments, including arguments, used for managed policy matching
3078    #[serde(skip_serializing_if = "Option::is_none")]
3079    pub command_segments: Option<Vec<PermissionRequestShellCommandSegment>>,
3080    /// The complete shell command text to be executed
3081    pub full_command_text: String,
3082    /// Whether the command includes a file write redirection (e.g., > or >>)
3083    pub has_write_file_redirection: bool,
3084    /// Human-readable description of what the command intends to do
3085    pub intention: String,
3086    /// Permission kind discriminator
3087    pub kind: PermissionRequestShellKind,
3088    /// Whether managed policy requires a human response and forbids host auto-approval
3089    #[serde(skip_serializing_if = "Option::is_none")]
3090    pub managed_approval_required: Option<bool>,
3091    /// File paths that may be read or written by the command
3092    pub possible_paths: Vec<String>,
3093    /// URLs that may be accessed by the command
3094    pub possible_urls: Vec<PermissionRequestShellPossibleUrl>,
3095    /// True when the model has requested to run this command outside the sandbox (it set requestSandboxBypass: true and the host opted in via sandbox.allowBypass). This is a request, not a grant: the command runs unsandboxed only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
3096    #[serde(skip_serializing_if = "Option::is_none")]
3097    pub request_sandbox_bypass: Option<bool>,
3098    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3099    #[serde(skip_serializing_if = "Option::is_none")]
3100    pub request_sandbox_bypass_reason: Option<String>,
3101    /// Tool call ID that triggered this permission request
3102    #[serde(skip_serializing_if = "Option::is_none")]
3103    pub tool_call_id: Option<String>,
3104    /// Optional warning message about risks of running this command
3105    #[serde(skip_serializing_if = "Option::is_none")]
3106    pub warning: Option<String>,
3107}
3108
3109/// File write permission request
3110#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3111#[serde(rename_all = "camelCase")]
3112pub struct PermissionRequestWrite {
3113    /// Whether the UI can offer session-wide approval for file write operations
3114    pub can_offer_session_approval: bool,
3115    /// Unified diff showing the proposed changes
3116    pub diff: String,
3117    /// Path of the file being written to
3118    pub file_name: String,
3119    /// Human-readable description of the intended file change
3120    pub intention: String,
3121    /// Permission kind discriminator
3122    pub kind: PermissionRequestWriteKind,
3123    /// Whether managed policy requires a human response and forbids host auto-approval
3124    #[serde(skip_serializing_if = "Option::is_none")]
3125    pub managed_approval_required: Option<bool>,
3126    /// Complete new file contents for newly created files
3127    #[serde(skip_serializing_if = "Option::is_none")]
3128    pub new_file_contents: Option<String>,
3129    /// True when a built-in file tool (apply_patch / str_replace_editor) asked to write a path the sandbox filesystem policy would block, and the host opted in via sandbox.allowBypass. This is a request, not a grant: the write happens unsandboxed only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
3130    #[serde(skip_serializing_if = "Option::is_none")]
3131    pub request_sandbox_bypass: Option<bool>,
3132    /// Justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3133    #[serde(skip_serializing_if = "Option::is_none")]
3134    pub request_sandbox_bypass_reason: Option<String>,
3135    /// Tool call ID that triggered this permission request
3136    #[serde(skip_serializing_if = "Option::is_none")]
3137    pub tool_call_id: Option<String>,
3138}
3139
3140/// File or directory read permission request
3141#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3142#[serde(rename_all = "camelCase")]
3143pub struct PermissionRequestRead {
3144    /// Human-readable description of why the file is being read
3145    pub intention: String,
3146    /// Permission kind discriminator
3147    pub kind: PermissionRequestReadKind,
3148    /// Whether managed policy requires a human response and forbids host auto-approval
3149    #[serde(skip_serializing_if = "Option::is_none")]
3150    pub managed_approval_required: Option<bool>,
3151    /// Path of the file or directory being read
3152    pub path: String,
3153    /// True when the model has requested to run this search outside the sandbox (it set requestSandboxBypass: true and the host opted in via sandbox.allowBypass). This is a request, not a grant: the search runs unsandboxed only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
3154    #[serde(skip_serializing_if = "Option::is_none")]
3155    pub request_sandbox_bypass: Option<bool>,
3156    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3157    #[serde(skip_serializing_if = "Option::is_none")]
3158    pub request_sandbox_bypass_reason: Option<String>,
3159    /// Tool call ID that triggered this permission request
3160    #[serde(skip_serializing_if = "Option::is_none")]
3161    pub tool_call_id: Option<String>,
3162}
3163
3164/// MCP tool invocation permission request
3165#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3166#[serde(rename_all = "camelCase")]
3167pub struct PermissionRequestMcp {
3168    /// Arguments to pass to the MCP tool
3169    #[serde(skip_serializing_if = "Option::is_none")]
3170    pub args: Option<serde_json::Value>,
3171    /// Permission kind discriminator
3172    pub kind: PermissionRequestMcpKind,
3173    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3174    #[serde(skip_serializing_if = "Option::is_none")]
3175    pub managed_approval_required: Option<bool>,
3176    /// Whether this MCP tool is read-only (no side effects)
3177    pub read_only: bool,
3178    /// Name of the MCP server providing the tool
3179    pub server_name: String,
3180    /// Tool call ID that triggered this permission request
3181    #[serde(skip_serializing_if = "Option::is_none")]
3182    pub tool_call_id: Option<String>,
3183    /// Internal name of the MCP tool
3184    pub tool_name: String,
3185    /// Human-readable title of the MCP tool
3186    pub tool_title: String,
3187}
3188
3189/// URL access permission request
3190#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3191#[serde(rename_all = "camelCase")]
3192pub struct PermissionRequestUrl {
3193    /// Human-readable description of why the URL is being accessed
3194    pub intention: String,
3195    /// Permission kind discriminator
3196    pub kind: PermissionRequestUrlKind,
3197    /// Whether managed policy requires a human response and forbids host auto-approval
3198    #[serde(skip_serializing_if = "Option::is_none")]
3199    pub managed_approval_required: Option<bool>,
3200    /// Immediately preceding URL when this request is for a redirect target
3201    #[serde(skip_serializing_if = "Option::is_none")]
3202    pub redirected_from: Option<String>,
3203    /// True when this URL fetch is requesting to bypass the sandbox network policy: either the model set requestSandboxBypass: true, or the tool re-issued the request as an interactive bypass after the network policy denied the approved URL (host opted in via sandbox.allowBypass). This is a request, not a grant: the fetch runs only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
3204    #[serde(skip_serializing_if = "Option::is_none")]
3205    pub request_sandbox_bypass: Option<bool>,
3206    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3207    #[serde(skip_serializing_if = "Option::is_none")]
3208    pub request_sandbox_bypass_reason: Option<String>,
3209    /// Tool call ID that triggered this permission request
3210    #[serde(skip_serializing_if = "Option::is_none")]
3211    pub tool_call_id: Option<String>,
3212    /// URL to be fetched
3213    pub url: String,
3214}
3215
3216/// Memory operation permission request
3217#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3218#[serde(rename_all = "camelCase")]
3219pub struct PermissionRequestMemory {
3220    /// Whether this is a store or vote memory operation
3221    #[serde(skip_serializing_if = "Option::is_none")]
3222    pub action: Option<PermissionRequestMemoryAction>,
3223    /// Source references for the stored fact (store only)
3224    #[serde(skip_serializing_if = "Option::is_none")]
3225    pub citations: Option<String>,
3226    /// Vote direction (vote only)
3227    #[serde(skip_serializing_if = "Option::is_none")]
3228    pub direction: Option<PermissionRequestMemoryDirection>,
3229    /// The fact being stored or voted on
3230    pub fact: String,
3231    /// Permission kind discriminator
3232    pub kind: PermissionRequestMemoryKind,
3233    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3234    #[serde(skip_serializing_if = "Option::is_none")]
3235    pub managed_approval_required: Option<bool>,
3236    /// Reason for the vote (vote only)
3237    #[serde(skip_serializing_if = "Option::is_none")]
3238    pub reason: Option<String>,
3239    /// Topic or subject of the memory (store only)
3240    #[serde(skip_serializing_if = "Option::is_none")]
3241    pub subject: Option<String>,
3242    /// Tool call ID that triggered this permission request
3243    #[serde(skip_serializing_if = "Option::is_none")]
3244    pub tool_call_id: Option<String>,
3245}
3246
3247/// Custom tool invocation permission request
3248#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3249#[serde(rename_all = "camelCase")]
3250pub struct PermissionRequestCustomTool {
3251    /// Arguments to pass to the custom tool
3252    #[serde(skip_serializing_if = "Option::is_none")]
3253    pub args: Option<serde_json::Value>,
3254    /// Permission kind discriminator
3255    pub kind: PermissionRequestCustomToolKind,
3256    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3257    #[serde(skip_serializing_if = "Option::is_none")]
3258    pub managed_approval_required: Option<bool>,
3259    /// Tool call ID that triggered this permission request
3260    #[serde(skip_serializing_if = "Option::is_none")]
3261    pub tool_call_id: Option<String>,
3262    /// Description of what the custom tool does
3263    pub tool_description: String,
3264    /// Name of the custom tool
3265    pub tool_name: String,
3266}
3267
3268/// Hook confirmation permission request
3269#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3270#[serde(rename_all = "camelCase")]
3271pub struct PermissionRequestHook {
3272    /// Optional message from the hook explaining why confirmation is needed
3273    #[serde(skip_serializing_if = "Option::is_none")]
3274    pub hook_message: Option<String>,
3275    /// Permission kind discriminator
3276    pub kind: PermissionRequestHookKind,
3277    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3278    #[serde(skip_serializing_if = "Option::is_none")]
3279    pub managed_approval_required: Option<bool>,
3280    /// Arguments of the tool call being gated
3281    #[serde(skip_serializing_if = "Option::is_none")]
3282    pub tool_args: Option<serde_json::Value>,
3283    /// Tool call ID that triggered this permission request
3284    #[serde(skip_serializing_if = "Option::is_none")]
3285    pub tool_call_id: Option<String>,
3286    /// Name of the tool the hook is gating
3287    pub tool_name: String,
3288}
3289
3290/// Extension management permission request
3291#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3292#[serde(rename_all = "camelCase")]
3293pub struct PermissionRequestExtensionManagement {
3294    /// Name of the extension being managed
3295    #[serde(skip_serializing_if = "Option::is_none")]
3296    pub extension_name: Option<String>,
3297    /// Permission kind discriminator
3298    pub kind: PermissionRequestExtensionManagementKind,
3299    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3300    #[serde(skip_serializing_if = "Option::is_none")]
3301    pub managed_approval_required: Option<bool>,
3302    /// The extension management operation (scaffold, reload)
3303    pub operation: String,
3304    /// Tool call ID that triggered this permission request
3305    #[serde(skip_serializing_if = "Option::is_none")]
3306    pub tool_call_id: Option<String>,
3307}
3308
3309/// A declared phase shown in a factory permission prompt.
3310#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3311#[serde(rename_all = "camelCase")]
3312pub struct FactoryPermissionPhase {
3313    /// Optional phase detail
3314    #[serde(skip_serializing_if = "Option::is_none")]
3315    pub detail: Option<String>,
3316    /// Phase title
3317    pub title: String,
3318}
3319
3320/// Factory run or authoring permission request
3321#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3322#[serde(rename_all = "camelCase")]
3323pub struct PermissionRequestFactory {
3324    /// Canonical key used for scoped factory approvals
3325    pub approval_key: String,
3326    /// Whether this factory is eligible for persistent approval
3327    pub can_persist_approval: bool,
3328    #[serde(skip_serializing_if = "Option::is_none")]
3329    pub declared_max_ai_credits: Option<f64>,
3330    #[serde(skip_serializing_if = "Option::is_none")]
3331    pub declared_max_concurrent_subagents: Option<i64>,
3332    #[serde(skip_serializing_if = "Option::is_none")]
3333    pub declared_max_total_subagents: Option<i64>,
3334    #[serde(skip_serializing_if = "Option::is_none")]
3335    pub declared_timeout_seconds: Option<f64>,
3336    /// Factory description
3337    pub description: String,
3338    /// Permission kind discriminator
3339    pub kind: PermissionRequestFactoryKind,
3340    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3341    #[serde(skip_serializing_if = "Option::is_none")]
3342    pub managed_approval_required: Option<bool>,
3343    /// Effective AI-credit limit; omitted means unlimited
3344    #[serde(skip_serializing_if = "Option::is_none")]
3345    pub max_ai_credits: Option<f64>,
3346    /// Effective concurrent-subagent limit; omitted means unlimited
3347    #[serde(skip_serializing_if = "Option::is_none")]
3348    pub max_concurrent_subagents: Option<i64>,
3349    /// Effective total-subagent limit; omitted means unlimited
3350    #[serde(skip_serializing_if = "Option::is_none")]
3351    pub max_total_subagents: Option<i64>,
3352    /// Factory name
3353    pub name: String,
3354    /// Factory operation, either run or author
3355    pub operation: FactoryPermissionOperation,
3356    /// Declared factory phases
3357    pub phases: Vec<FactoryPermissionPhase>,
3358    /// Effective active-time limit in seconds; omitted means unlimited
3359    #[serde(skip_serializing_if = "Option::is_none")]
3360    pub timeout_seconds: Option<f64>,
3361    /// Tool call ID that triggered this permission request
3362    #[serde(skip_serializing_if = "Option::is_none")]
3363    pub tool_call_id: Option<String>,
3364}
3365
3366/// Extension permission access request
3367#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3368#[serde(rename_all = "camelCase")]
3369pub struct PermissionRequestExtensionPermissionAccess {
3370    /// Capabilities the extension is requesting
3371    pub capabilities: Vec<String>,
3372    /// Name of the extension requesting permission access
3373    pub extension_name: String,
3374    /// Permission kind discriminator
3375    pub kind: PermissionRequestExtensionPermissionAccessKind,
3376    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3377    #[serde(skip_serializing_if = "Option::is_none")]
3378    pub managed_approval_required: Option<bool>,
3379    /// Tool call ID that triggered this permission request
3380    #[serde(skip_serializing_if = "Option::is_none")]
3381    pub tool_call_id: Option<String>,
3382}
3383
3384/// Auto-approval judge information attached to a permission request. Present (non-null) only when the session's allow-all mode is "auto"; its absence means auto mode was off and the judge did not evaluate the request. The `recommendation` conveys the judge's disposition for this request.
3385///
3386/// <div class="warning">
3387///
3388/// **Experimental.** This type is part of an experimental wire-protocol surface
3389/// and may change or be removed in future SDK or CLI releases.
3390///
3391/// </div>
3392#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3393#[serde(rename_all = "camelCase")]
3394pub struct PermissionAutoApproval {
3395    /// Classified cause of an `error` recommendation. Absent for every other recommendation.
3396    #[serde(skip_serializing_if = "Option::is_none")]
3397    pub failure_reason: Option<AutoApprovalJudgeFailureReason>,
3398    /// Model id that produced the recommendation, when the judge was consulted and reported one. Absent for `excluded` (the judge was not consulted) and for failures that occurred before a model was selected.
3399    #[serde(skip_serializing_if = "Option::is_none")]
3400    pub model: Option<String>,
3401    /// Human-readable reason for the judge's recommendation, when available.
3402    #[serde(skip_serializing_if = "Option::is_none")]
3403    pub reason: Option<String>,
3404    /// The auto-approval safety judge's outcome for this request.
3405    pub recommendation: AutoApprovalRecommendation,
3406}
3407
3408/// Shell command permission prompt
3409#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3410#[serde(rename_all = "camelCase")]
3411pub struct PermissionPromptRequestCommands {
3412    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3413    ///
3414    /// <div class="warning">
3415    ///
3416    /// **Experimental.** This type is part of an experimental wire-protocol surface
3417    /// and may change or be removed in future SDK or CLI releases.
3418    ///
3419    /// </div>
3420    #[serde(skip_serializing_if = "Option::is_none")]
3421    pub auto_approval: Option<PermissionAutoApproval>,
3422    /// Whether the UI can offer session-wide approval for this command pattern
3423    pub can_offer_session_approval: bool,
3424    /// Command identifiers covered by this approval prompt
3425    pub command_identifiers: Vec<String>,
3426    /// The complete shell command text to be executed
3427    pub full_command_text: String,
3428    /// Human-readable description of what the command intends to do
3429    pub intention: String,
3430    /// Prompt kind discriminator
3431    pub kind: PermissionPromptRequestCommandsKind,
3432    /// Whether managed policy requires a human response and forbids host auto-approval
3433    #[serde(skip_serializing_if = "Option::is_none")]
3434    pub managed_approval_required: Option<bool>,
3435    /// Tool call ID that triggered this permission request
3436    #[serde(skip_serializing_if = "Option::is_none")]
3437    pub tool_call_id: Option<String>,
3438    /// Optional warning message about risks of running this command
3439    #[serde(skip_serializing_if = "Option::is_none")]
3440    pub warning: Option<String>,
3441}
3442
3443/// File write permission prompt
3444#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3445#[serde(rename_all = "camelCase")]
3446pub struct PermissionPromptRequestWrite {
3447    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3448    ///
3449    /// <div class="warning">
3450    ///
3451    /// **Experimental.** This type is part of an experimental wire-protocol surface
3452    /// and may change or be removed in future SDK or CLI releases.
3453    ///
3454    /// </div>
3455    #[serde(skip_serializing_if = "Option::is_none")]
3456    pub auto_approval: Option<PermissionAutoApproval>,
3457    /// Whether the UI can offer session-wide approval for file write operations
3458    pub can_offer_session_approval: bool,
3459    /// Unified diff showing the proposed changes
3460    pub diff: String,
3461    /// Path of the file being written to
3462    pub file_name: String,
3463    /// Human-readable description of the intended file change
3464    pub intention: String,
3465    /// Prompt kind discriminator
3466    pub kind: PermissionPromptRequestWriteKind,
3467    /// Whether managed policy requires a human response and forbids host auto-approval
3468    #[serde(skip_serializing_if = "Option::is_none")]
3469    pub managed_approval_required: Option<bool>,
3470    /// Complete new file contents for newly created files
3471    #[serde(skip_serializing_if = "Option::is_none")]
3472    pub new_file_contents: Option<String>,
3473    /// Tool call ID that triggered this permission request
3474    #[serde(skip_serializing_if = "Option::is_none")]
3475    pub tool_call_id: Option<String>,
3476}
3477
3478/// File read permission prompt
3479#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3480#[serde(rename_all = "camelCase")]
3481pub struct PermissionPromptRequestRead {
3482    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3483    ///
3484    /// <div class="warning">
3485    ///
3486    /// **Experimental.** This type is part of an experimental wire-protocol surface
3487    /// and may change or be removed in future SDK or CLI releases.
3488    ///
3489    /// </div>
3490    #[serde(skip_serializing_if = "Option::is_none")]
3491    pub auto_approval: Option<PermissionAutoApproval>,
3492    /// Human-readable description of why the file is being read
3493    pub intention: String,
3494    /// Prompt kind discriminator
3495    pub kind: PermissionPromptRequestReadKind,
3496    /// Whether managed policy requires a human response and forbids host auto-approval
3497    #[serde(skip_serializing_if = "Option::is_none")]
3498    pub managed_approval_required: Option<bool>,
3499    /// Path of the file or directory being read
3500    pub path: String,
3501    /// Tool call ID that triggered this permission request
3502    #[serde(skip_serializing_if = "Option::is_none")]
3503    pub tool_call_id: Option<String>,
3504}
3505
3506/// MCP tool invocation permission prompt
3507#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3508#[serde(rename_all = "camelCase")]
3509pub struct PermissionPromptRequestMcp {
3510    /// Arguments to pass to the MCP tool
3511    #[serde(skip_serializing_if = "Option::is_none")]
3512    pub args: Option<serde_json::Value>,
3513    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3514    ///
3515    /// <div class="warning">
3516    ///
3517    /// **Experimental.** This type is part of an experimental wire-protocol surface
3518    /// and may change or be removed in future SDK or CLI releases.
3519    ///
3520    /// </div>
3521    #[serde(skip_serializing_if = "Option::is_none")]
3522    pub auto_approval: Option<PermissionAutoApproval>,
3523    /// Prompt kind discriminator
3524    pub kind: PermissionPromptRequestMcpKind,
3525    /// Name of the MCP server providing the tool
3526    pub server_name: String,
3527    /// Tool call ID that triggered this permission request
3528    #[serde(skip_serializing_if = "Option::is_none")]
3529    pub tool_call_id: Option<String>,
3530    /// Internal name of the MCP tool
3531    pub tool_name: String,
3532    /// Human-readable title of the MCP tool
3533    pub tool_title: String,
3534}
3535
3536/// URL access permission prompt
3537#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3538#[serde(rename_all = "camelCase")]
3539pub struct PermissionPromptRequestUrl {
3540    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3541    ///
3542    /// <div class="warning">
3543    ///
3544    /// **Experimental.** This type is part of an experimental wire-protocol surface
3545    /// and may change or be removed in future SDK or CLI releases.
3546    ///
3547    /// </div>
3548    #[serde(skip_serializing_if = "Option::is_none")]
3549    pub auto_approval: Option<PermissionAutoApproval>,
3550    /// Human-readable description of why the URL is being accessed
3551    pub intention: String,
3552    /// Prompt kind discriminator
3553    pub kind: PermissionPromptRequestUrlKind,
3554    /// Whether managed policy requires a human response and forbids host auto-approval
3555    #[serde(skip_serializing_if = "Option::is_none")]
3556    pub managed_approval_required: Option<bool>,
3557    /// Immediately preceding URL when this prompt is for a redirect target
3558    #[serde(skip_serializing_if = "Option::is_none")]
3559    pub redirected_from: Option<String>,
3560    /// True when this URL fetch is requesting to bypass the sandbox network policy: either the model set requestSandboxBypass: true, or the tool re-issued the request as an interactive bypass after the network policy denied the approved URL (host opted in via sandbox.allowBypass). This is a request, not a grant: the fetch runs only if the user approves this permission request. Hosts should highlight the elevated risk in the approval UI.
3561    #[serde(skip_serializing_if = "Option::is_none")]
3562    pub request_sandbox_bypass: Option<bool>,
3563    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3564    #[serde(skip_serializing_if = "Option::is_none")]
3565    pub request_sandbox_bypass_reason: Option<String>,
3566    /// Tool call ID that triggered this permission request
3567    #[serde(skip_serializing_if = "Option::is_none")]
3568    pub tool_call_id: Option<String>,
3569    /// URL to be fetched
3570    pub url: String,
3571}
3572
3573/// Memory operation permission prompt
3574#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3575#[serde(rename_all = "camelCase")]
3576pub struct PermissionPromptRequestMemory {
3577    /// Whether this is a store or vote memory operation
3578    #[serde(skip_serializing_if = "Option::is_none")]
3579    pub action: Option<PermissionRequestMemoryAction>,
3580    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3581    ///
3582    /// <div class="warning">
3583    ///
3584    /// **Experimental.** This type is part of an experimental wire-protocol surface
3585    /// and may change or be removed in future SDK or CLI releases.
3586    ///
3587    /// </div>
3588    #[serde(skip_serializing_if = "Option::is_none")]
3589    pub auto_approval: Option<PermissionAutoApproval>,
3590    /// Source references for the stored fact (store only)
3591    #[serde(skip_serializing_if = "Option::is_none")]
3592    pub citations: Option<String>,
3593    /// Vote direction (vote only)
3594    #[serde(skip_serializing_if = "Option::is_none")]
3595    pub direction: Option<PermissionRequestMemoryDirection>,
3596    /// The fact being stored or voted on
3597    pub fact: String,
3598    /// Prompt kind discriminator
3599    pub kind: PermissionPromptRequestMemoryKind,
3600    /// Reason for the vote (vote only)
3601    #[serde(skip_serializing_if = "Option::is_none")]
3602    pub reason: Option<String>,
3603    /// Topic or subject of the memory (store only)
3604    #[serde(skip_serializing_if = "Option::is_none")]
3605    pub subject: Option<String>,
3606    /// Tool call ID that triggered this permission request
3607    #[serde(skip_serializing_if = "Option::is_none")]
3608    pub tool_call_id: Option<String>,
3609}
3610
3611/// Custom tool invocation permission prompt
3612#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3613#[serde(rename_all = "camelCase")]
3614pub struct PermissionPromptRequestCustomTool {
3615    /// Arguments to pass to the custom tool
3616    #[serde(skip_serializing_if = "Option::is_none")]
3617    pub args: Option<serde_json::Value>,
3618    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3619    ///
3620    /// <div class="warning">
3621    ///
3622    /// **Experimental.** This type is part of an experimental wire-protocol surface
3623    /// and may change or be removed in future SDK or CLI releases.
3624    ///
3625    /// </div>
3626    #[serde(skip_serializing_if = "Option::is_none")]
3627    pub auto_approval: Option<PermissionAutoApproval>,
3628    /// Prompt kind discriminator
3629    pub kind: PermissionPromptRequestCustomToolKind,
3630    /// Tool call ID that triggered this permission request
3631    #[serde(skip_serializing_if = "Option::is_none")]
3632    pub tool_call_id: Option<String>,
3633    /// Description of what the custom tool does
3634    pub tool_description: String,
3635    /// Name of the custom tool
3636    pub tool_name: String,
3637}
3638
3639/// Path access permission prompt
3640#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3641#[serde(rename_all = "camelCase")]
3642pub struct PermissionPromptRequestPath {
3643    /// Underlying permission kind that needs path approval
3644    pub access_kind: PermissionPromptRequestPathAccessKind,
3645    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3646    ///
3647    /// <div class="warning">
3648    ///
3649    /// **Experimental.** This type is part of an experimental wire-protocol surface
3650    /// and may change or be removed in future SDK or CLI releases.
3651    ///
3652    /// </div>
3653    #[serde(skip_serializing_if = "Option::is_none")]
3654    pub auto_approval: Option<PermissionAutoApproval>,
3655    /// Prompt kind discriminator
3656    pub kind: PermissionPromptRequestPathKind,
3657    /// File paths that require explicit approval
3658    pub paths: Vec<String>,
3659    /// Tool call ID that triggered this permission request
3660    #[serde(skip_serializing_if = "Option::is_none")]
3661    pub tool_call_id: Option<String>,
3662}
3663
3664/// Hook confirmation permission prompt
3665#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3666#[serde(rename_all = "camelCase")]
3667pub struct PermissionPromptRequestHook {
3668    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3669    ///
3670    /// <div class="warning">
3671    ///
3672    /// **Experimental.** This type is part of an experimental wire-protocol surface
3673    /// and may change or be removed in future SDK or CLI releases.
3674    ///
3675    /// </div>
3676    #[serde(skip_serializing_if = "Option::is_none")]
3677    pub auto_approval: Option<PermissionAutoApproval>,
3678    /// Optional message from the hook explaining why confirmation is needed
3679    #[serde(skip_serializing_if = "Option::is_none")]
3680    pub hook_message: Option<String>,
3681    /// Prompt kind discriminator
3682    pub kind: PermissionPromptRequestHookKind,
3683    /// Arguments of the tool call being gated
3684    #[serde(skip_serializing_if = "Option::is_none")]
3685    pub tool_args: Option<serde_json::Value>,
3686    /// Tool call ID that triggered this permission request
3687    #[serde(skip_serializing_if = "Option::is_none")]
3688    pub tool_call_id: Option<String>,
3689    /// Name of the tool the hook is gating
3690    pub tool_name: String,
3691}
3692
3693/// Extension management permission prompt
3694#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3695#[serde(rename_all = "camelCase")]
3696pub struct PermissionPromptRequestExtensionManagement {
3697    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3698    ///
3699    /// <div class="warning">
3700    ///
3701    /// **Experimental.** This type is part of an experimental wire-protocol surface
3702    /// and may change or be removed in future SDK or CLI releases.
3703    ///
3704    /// </div>
3705    #[serde(skip_serializing_if = "Option::is_none")]
3706    pub auto_approval: Option<PermissionAutoApproval>,
3707    /// Name of the extension being managed
3708    #[serde(skip_serializing_if = "Option::is_none")]
3709    pub extension_name: Option<String>,
3710    /// Prompt kind discriminator
3711    pub kind: PermissionPromptRequestExtensionManagementKind,
3712    /// The extension management operation (scaffold, reload)
3713    pub operation: String,
3714    /// Tool call ID that triggered this permission request
3715    #[serde(skip_serializing_if = "Option::is_none")]
3716    pub tool_call_id: Option<String>,
3717}
3718
3719/// Factory run or authoring permission prompt
3720#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3721#[serde(rename_all = "camelCase")]
3722pub struct PermissionPromptRequestFactory {
3723    /// Canonical key used for scoped factory approvals
3724    pub approval_key: String,
3725    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3726    ///
3727    /// <div class="warning">
3728    ///
3729    /// **Experimental.** This type is part of an experimental wire-protocol surface
3730    /// and may change or be removed in future SDK or CLI releases.
3731    ///
3732    /// </div>
3733    #[serde(skip_serializing_if = "Option::is_none")]
3734    pub auto_approval: Option<PermissionAutoApproval>,
3735    /// Whether this factory is eligible for persistent approval
3736    pub can_persist_approval: bool,
3737    #[serde(skip_serializing_if = "Option::is_none")]
3738    pub declared_max_ai_credits: Option<f64>,
3739    #[serde(skip_serializing_if = "Option::is_none")]
3740    pub declared_max_concurrent_subagents: Option<i64>,
3741    #[serde(skip_serializing_if = "Option::is_none")]
3742    pub declared_max_total_subagents: Option<i64>,
3743    #[serde(skip_serializing_if = "Option::is_none")]
3744    pub declared_timeout_seconds: Option<f64>,
3745    /// Factory description
3746    pub description: String,
3747    /// Prompt kind discriminator
3748    pub kind: PermissionPromptRequestFactoryKind,
3749    /// Whether managed policy requires a human response and forbids host auto-approval
3750    #[serde(skip_serializing_if = "Option::is_none")]
3751    pub managed_approval_required: Option<bool>,
3752    /// Effective AI-credit limit; omitted means unlimited
3753    #[serde(skip_serializing_if = "Option::is_none")]
3754    pub max_ai_credits: Option<f64>,
3755    /// Effective concurrent-subagent limit; omitted means unlimited
3756    #[serde(skip_serializing_if = "Option::is_none")]
3757    pub max_concurrent_subagents: Option<i64>,
3758    /// Effective total-subagent limit; omitted means unlimited
3759    #[serde(skip_serializing_if = "Option::is_none")]
3760    pub max_total_subagents: Option<i64>,
3761    /// Factory name
3762    pub name: String,
3763    /// Factory operation, either run or author
3764    pub operation: FactoryPermissionOperation,
3765    /// Declared factory phases
3766    pub phases: Vec<FactoryPermissionPhase>,
3767    /// Effective active-time limit in seconds; omitted means unlimited
3768    #[serde(skip_serializing_if = "Option::is_none")]
3769    pub timeout_seconds: Option<f64>,
3770    /// Tool call ID that triggered this permission request
3771    #[serde(skip_serializing_if = "Option::is_none")]
3772    pub tool_call_id: Option<String>,
3773}
3774
3775/// Extension permission access prompt
3776#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3777#[serde(rename_all = "camelCase")]
3778pub struct PermissionPromptRequestExtensionPermissionAccess {
3779    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3780    ///
3781    /// <div class="warning">
3782    ///
3783    /// **Experimental.** This type is part of an experimental wire-protocol surface
3784    /// and may change or be removed in future SDK or CLI releases.
3785    ///
3786    /// </div>
3787    #[serde(skip_serializing_if = "Option::is_none")]
3788    pub auto_approval: Option<PermissionAutoApproval>,
3789    /// Capabilities the extension is requesting
3790    pub capabilities: Vec<String>,
3791    /// Name of the extension requesting permission access
3792    pub extension_name: String,
3793    /// Prompt kind discriminator
3794    pub kind: PermissionPromptRequestExtensionPermissionAccessKind,
3795    /// Tool call ID that triggered this permission request
3796    #[serde(skip_serializing_if = "Option::is_none")]
3797    pub tool_call_id: Option<String>,
3798}
3799
3800/// Session event "permission.requested". Permission request notification requiring client approval with request details
3801#[derive(Debug, Clone, Serialize, Deserialize)]
3802#[serde(rename_all = "camelCase")]
3803pub struct PermissionRequestedData {
3804    /// Details of the permission being requested
3805    pub permission_request: PermissionRequest,
3806    /// Derived user-facing permission prompt details for UI consumers
3807    #[serde(skip_serializing_if = "Option::is_none")]
3808    pub prompt_request: Option<PermissionPromptRequest>,
3809    /// Unique identifier for this permission request; used to respond via session.respondToPermission()
3810    pub request_id: RequestId,
3811    /// When true, this permission was already resolved by a permissionRequest hook and requires no client action
3812    #[serde(skip_serializing_if = "Option::is_none")]
3813    pub resolved_by_hook: Option<bool>,
3814    /// Neutral risk metadata supplied by the tool host. Consumers may display this value but must not use it to bypass the permission decision.
3815    #[serde(skip_serializing_if = "Option::is_none")]
3816    pub risk_assessment: Option<serde_json::Value>,
3817}
3818
3819/// Permission response variant indicating the request was approved without persisting an approval rule.
3820#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3821#[serde(rename_all = "camelCase")]
3822pub struct PermissionApproved {
3823    /// The permission request was approved
3824    pub kind: PermissionApprovedKind,
3825}
3826
3827/// Session-scoped tool-approval rule for specific shell command identifiers.
3828#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3829#[serde(rename_all = "camelCase")]
3830pub struct UserToolSessionApprovalCommands {
3831    /// Command identifiers approved by the user
3832    pub command_identifiers: Vec<String>,
3833    /// Command approval kind
3834    pub kind: UserToolSessionApprovalCommandsKind,
3835}
3836
3837/// Session-scoped tool-approval rule for read-only filesystem operations.
3838#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3839#[serde(rename_all = "camelCase")]
3840pub struct UserToolSessionApprovalRead {
3841    /// Read approval kind
3842    pub kind: UserToolSessionApprovalReadKind,
3843}
3844
3845/// Session-scoped tool-approval rule for filesystem write operations.
3846#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3847#[serde(rename_all = "camelCase")]
3848pub struct UserToolSessionApprovalWrite {
3849    /// Write approval kind
3850    pub kind: UserToolSessionApprovalWriteKind,
3851}
3852
3853/// Session-scoped tool-approval rule for an MCP server tool, or all tools on the server when `toolName` is null.
3854#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3855#[serde(rename_all = "camelCase")]
3856pub struct UserToolSessionApprovalMcp {
3857    /// MCP tool approval kind
3858    pub kind: UserToolSessionApprovalMcpKind,
3859    /// MCP server name
3860    pub server_name: String,
3861    /// Optional MCP tool name, or null for all tools on the server
3862    pub tool_name: Option<String>,
3863}
3864
3865/// Session-scoped tool-approval rule for writes to long-term memory.
3866#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3867#[serde(rename_all = "camelCase")]
3868pub struct UserToolSessionApprovalMemory {
3869    /// Memory approval kind
3870    pub kind: UserToolSessionApprovalMemoryKind,
3871}
3872
3873/// Session-scoped tool-approval rule for a custom tool, keyed by tool name.
3874#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3875#[serde(rename_all = "camelCase")]
3876pub struct UserToolSessionApprovalCustomTool {
3877    /// Custom tool approval kind
3878    pub kind: UserToolSessionApprovalCustomToolKind,
3879    /// Custom tool name
3880    pub tool_name: String,
3881}
3882
3883/// Session-scoped tool-approval rule for extension-management operations, optionally narrowed by operation.
3884#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3885#[serde(rename_all = "camelCase")]
3886pub struct UserToolSessionApprovalExtensionManagement {
3887    /// Extension management approval kind
3888    pub kind: UserToolSessionApprovalExtensionManagementKind,
3889    /// Optional operation identifier
3890    #[serde(skip_serializing_if = "Option::is_none")]
3891    pub operation: Option<String>,
3892}
3893
3894/// Session-scoped factory approval, optionally narrowed by approval key.
3895#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3896#[serde(rename_all = "camelCase")]
3897pub struct UserToolSessionApprovalFactory {
3898    /// Optional factory operation name or canonical approval key
3899    #[serde(skip_serializing_if = "Option::is_none")]
3900    pub approval_key: Option<String>,
3901    /// Factory approval kind
3902    pub kind: UserToolSessionApprovalFactoryKind,
3903}
3904
3905/// Session-scoped tool-approval rule for an extension's permission-gated capability access, keyed by extension name.
3906#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3907#[serde(rename_all = "camelCase")]
3908pub struct UserToolSessionApprovalExtensionPermissionAccess {
3909    /// Extension name
3910    pub extension_name: String,
3911    /// Extension permission access approval kind
3912    pub kind: UserToolSessionApprovalExtensionPermissionAccessKind,
3913}
3914
3915/// Permission response variant that approves a request and remembers the provided approval for the rest of the session.
3916#[derive(Debug, Clone, Serialize, Deserialize)]
3917#[serde(rename_all = "camelCase")]
3918pub struct PermissionApprovedForSession {
3919    /// The approval to add as a session-scoped rule
3920    pub approval: UserToolSessionApproval,
3921    /// Approved and remembered for the rest of the session
3922    pub kind: PermissionApprovedForSessionKind,
3923}
3924
3925/// Permission response variant that approves a request and persists the provided approval to a project location key.
3926#[derive(Debug, Clone, Serialize, Deserialize)]
3927#[serde(rename_all = "camelCase")]
3928pub struct PermissionApprovedForLocation {
3929    /// The approval to persist for this location
3930    pub approval: UserToolSessionApproval,
3931    /// Approved and persisted for this project location
3932    pub kind: PermissionApprovedForLocationKind,
3933    /// The location key (git root or cwd) to persist the approval to
3934    pub location_key: String,
3935}
3936
3937/// Permission response variant indicating the request was cancelled before use, with an optional reason.
3938#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3939#[serde(rename_all = "camelCase")]
3940pub struct PermissionCancelled {
3941    /// The permission request was cancelled before a response was used
3942    pub kind: PermissionCancelledKind,
3943    /// Optional explanation of why the request was cancelled
3944    #[serde(skip_serializing_if = "Option::is_none")]
3945    pub reason: Option<String>,
3946}
3947
3948/// A permission approval or denial rule matched against a tool request, identified by a rule kind with an optional argument value.
3949#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3950#[serde(rename_all = "camelCase")]
3951pub struct PermissionRule {
3952    /// Argument value matched against the request, or null when the rule kind has no argument (e.g. 'read', 'write', 'memory').
3953    pub argument: Option<String>,
3954    /// The rule kind, such as Shell or GitHubMCP
3955    pub kind: String,
3956}
3957
3958/// Permission response variant denied because matching approval rules explicitly blocked the request.
3959#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3960#[serde(rename_all = "camelCase")]
3961pub struct PermissionDeniedByRules {
3962    /// Denied because approval rules explicitly blocked it
3963    pub kind: PermissionDeniedByRulesKind,
3964    /// Rules that denied the request
3965    pub rules: Vec<PermissionRule>,
3966}
3967
3968/// Permission response variant denied because no approval rule matched and user confirmation was unavailable.
3969#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3970#[serde(rename_all = "camelCase")]
3971pub struct PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
3972    /// Denied because no approval rule matched and user confirmation was unavailable
3973    pub kind: PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind,
3974}
3975
3976/// Permission response variant denied in an interactive user prompt, with optional feedback and force-reject flag.
3977#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3978#[serde(rename_all = "camelCase")]
3979pub struct PermissionDeniedInteractivelyByUser {
3980    /// Optional feedback from the user explaining the denial
3981    #[serde(skip_serializing_if = "Option::is_none")]
3982    pub feedback: Option<String>,
3983    /// Whether to force-reject the current agent turn
3984    #[serde(skip_serializing_if = "Option::is_none")]
3985    pub force_reject: Option<bool>,
3986    /// Denied by the user during an interactive prompt
3987    pub kind: PermissionDeniedInteractivelyByUserKind,
3988}
3989
3990/// Permission response variant denying a path under content exclusion policy, with the path and message.
3991#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3992#[serde(rename_all = "camelCase")]
3993pub struct PermissionDeniedByContentExclusionPolicy {
3994    /// Denied by the organization's content exclusion policy
3995    pub kind: PermissionDeniedByContentExclusionPolicyKind,
3996    /// Human-readable explanation of why the path was excluded
3997    pub message: String,
3998    /// File path that triggered the exclusion
3999    pub path: String,
4000}
4001
4002/// Permission response variant denied by a permission-request hook, with optional message and interrupt flag.
4003#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4004#[serde(rename_all = "camelCase")]
4005pub struct PermissionDeniedByPermissionRequestHook {
4006    /// Whether to interrupt the current agent turn
4007    #[serde(skip_serializing_if = "Option::is_none")]
4008    pub interrupt: Option<bool>,
4009    /// Denied by a permission request hook registered by an extension or plugin
4010    pub kind: PermissionDeniedByPermissionRequestHookKind,
4011    /// Optional message from the hook explaining the denial
4012    #[serde(skip_serializing_if = "Option::is_none")]
4013    pub message: Option<String>,
4014}
4015
4016/// Session event "permission.completed". Permission request completion notification signaling UI dismissal
4017#[derive(Debug, Clone, Serialize, Deserialize)]
4018#[serde(rename_all = "camelCase")]
4019pub struct PermissionCompletedData {
4020    /// Request ID of the resolved permission request; clients should dismiss any UI for this request
4021    pub request_id: RequestId,
4022    /// The result of the permission request
4023    pub result: PermissionResult,
4024    /// Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
4025    #[serde(skip_serializing_if = "Option::is_none")]
4026    pub tool_call_id: Option<String>,
4027}
4028
4029/// Session event "user_input.requested". User input request notification with question and optional predefined choices
4030#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4031#[serde(rename_all = "camelCase")]
4032pub struct UserInputRequestedData {
4033    /// Whether the user can provide a free-form text response in addition to predefined choices
4034    #[serde(skip_serializing_if = "Option::is_none")]
4035    pub allow_freeform: Option<bool>,
4036    /// Predefined choices for the user to select from, if applicable
4037    #[serde(skip_serializing_if = "Option::is_none")]
4038    pub choices: Option<Vec<String>>,
4039    /// The question or prompt to present to the user
4040    pub question: String,
4041    /// Unique identifier for this input request; used to respond via session.respondToUserInput()
4042    pub request_id: RequestId,
4043    /// The LLM-assigned tool call ID that triggered this request; used by remote UIs to correlate responses
4044    #[serde(skip_serializing_if = "Option::is_none")]
4045    pub tool_call_id: Option<String>,
4046}
4047
4048/// Session event "user_input.completed". User input request completion with the user's response
4049#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4050#[serde(rename_all = "camelCase")]
4051pub struct UserInputCompletedData {
4052    /// The user's answer to the input request
4053    #[serde(skip_serializing_if = "Option::is_none")]
4054    pub answer: Option<String>,
4055    /// Request ID of the resolved user input request; clients should dismiss any UI for this request
4056    pub request_id: RequestId,
4057    /// Whether the answer was typed as free-form text rather than selected from choices
4058    #[serde(skip_serializing_if = "Option::is_none")]
4059    pub was_freeform: Option<bool>,
4060}
4061
4062/// JSON Schema describing the form fields to present to the user (form mode only)
4063#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4064#[serde(rename_all = "camelCase")]
4065pub struct ElicitationRequestedSchema {
4066    /// Form field definitions, keyed by field name
4067    pub properties: HashMap<String, serde_json::Value>,
4068    /// List of required field names
4069    #[serde(skip_serializing_if = "Option::is_none")]
4070    pub required: Option<Vec<String>>,
4071    /// Schema type indicator (always 'object')
4072    pub r#type: ElicitationRequestedSchemaType,
4073}
4074
4075/// Session event "elicitation.requested". Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
4076#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4077#[serde(rename_all = "camelCase")]
4078pub struct ElicitationRequestedData {
4079    /// The source that initiated the request (MCP server name, or absent for agent-initiated)
4080    #[serde(skip_serializing_if = "Option::is_none")]
4081    pub elicitation_source: Option<String>,
4082    /// Message describing what information is needed from the user
4083    pub message: String,
4084    /// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
4085    #[serde(skip_serializing_if = "Option::is_none")]
4086    pub mode: Option<ElicitationRequestedMode>,
4087    /// JSON Schema describing the form fields to present to the user (form mode only)
4088    #[serde(skip_serializing_if = "Option::is_none")]
4089    pub requested_schema: Option<ElicitationRequestedSchema>,
4090    /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation()
4091    pub request_id: RequestId,
4092    /// Tool call ID from the LLM completion; used to correlate with CompletionChunk.toolCall.id for remote UIs
4093    #[serde(skip_serializing_if = "Option::is_none")]
4094    pub tool_call_id: Option<String>,
4095    /// URL to open in the user's browser (url mode only)
4096    #[serde(skip_serializing_if = "Option::is_none")]
4097    pub url: Option<String>,
4098}
4099
4100/// Session event "elicitation.completed". Elicitation request completion with the user's response
4101#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4102#[serde(rename_all = "camelCase")]
4103pub struct ElicitationCompletedData {
4104    /// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
4105    #[serde(skip_serializing_if = "Option::is_none")]
4106    pub action: Option<ElicitationCompletedAction>,
4107    /// The submitted form data when action is 'accept'; keys match the requested schema fields
4108    #[serde(skip_serializing_if = "Option::is_none")]
4109    pub content: Option<HashMap<String, serde_json::Value>>,
4110    /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request
4111    pub request_id: RequestId,
4112}
4113
4114/// Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
4115#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4116#[serde(rename_all = "camelCase")]
4117pub struct SamplingRequestedData {
4118    /// The JSON-RPC request ID from the MCP protocol
4119    pub mcp_request_id: serde_json::Value,
4120    /// Unique identifier for this sampling request; used to respond via session.respondToSampling()
4121    pub request_id: RequestId,
4122    /// Name of the MCP server that initiated the sampling request
4123    pub server_name: String,
4124}
4125
4126/// Session event "sampling.completed". Sampling request completion notification signaling UI dismissal
4127#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4128#[serde(rename_all = "camelCase")]
4129pub struct SamplingCompletedData {
4130    /// Request ID of the resolved sampling request; clients should dismiss any UI for this request
4131    pub request_id: RequestId,
4132}
4133
4134/// Single HTTP header entry as a name/value pair.
4135#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4136#[serde(rename_all = "camelCase")]
4137pub struct HeaderEntry {
4138    /// HTTP response header name as observed by the runtime.
4139    pub name: String,
4140    /// HTTP response header value as observed by the runtime.
4141    pub value: String,
4142}
4143
4144/// Raw HTTP response details from the OAuth auth challenge, as observed by the runtime.
4145#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4146#[serde(rename_all = "camelCase")]
4147pub struct McpOauthHttpResponse {
4148    /// Complete UTF-8 response body for host-specific challenge handling, including an empty string for an empty body. Omitted when the complete body is not valid UTF-8; body read failures fail the HTTP operation rather than exposing a partial response.
4149    #[serde(skip_serializing_if = "Option::is_none")]
4150    pub body: Option<String>,
4151    /// HTTP response headers as observed by the runtime. Order and casing are transport-dependent, and duplicate header names may appear multiple times.
4152    pub headers: Vec<HeaderEntry>,
4153    /// HTTP status code returned with the auth challenge.
4154    pub status_code: i32,
4155}
4156
4157/// Static OAuth client configuration, if the server specifies one
4158#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4159#[serde(rename_all = "camelCase")]
4160pub struct McpOauthRequiredStaticClientConfig {
4161    /// OAuth client ID for the server
4162    pub client_id: String,
4163    /// Optional OAuth client secret for confidential static clients, when the runtime can resolve one
4164    #[serde(skip_serializing_if = "Option::is_none")]
4165    pub client_secret: Option<String>,
4166    /// 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).
4167    #[serde(skip_serializing_if = "Option::is_none")]
4168    pub grant_type: Option<McpOauthRequiredStaticClientConfigGrantType>,
4169    /// Whether this is a public OAuth client
4170    #[serde(skip_serializing_if = "Option::is_none")]
4171    pub public_client: Option<bool>,
4172}
4173
4174/// OAuth WWW-Authenticate parameters parsed from an MCP auth challenge
4175#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4176#[serde(rename_all = "camelCase")]
4177pub struct McpOauthWWWAuthenticateParams {
4178    /// OAuth error from the WWW-Authenticate error parameter, if present
4179    #[serde(skip_serializing_if = "Option::is_none")]
4180    pub error: Option<String>,
4181    /// Protected resource metadata URL from the WWW-Authenticate resource_metadata parameter, if present
4182    #[serde(skip_serializing_if = "Option::is_none")]
4183    pub resource_metadata_url: Option<String>,
4184    /// Requested OAuth scopes from the WWW-Authenticate scope parameter, if present
4185    #[serde(skip_serializing_if = "Option::is_none")]
4186    pub scope: Option<String>,
4187}
4188
4189/// Session event "mcp.oauth_required". OAuth authentication request for an MCP server
4190#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4191#[serde(rename_all = "camelCase")]
4192pub struct McpOauthRequiredData {
4193    /// Raw HTTP response details from the OAuth auth challenge, as observed by the runtime. Header order and casing are transport-dependent, and duplicate header names may appear multiple times.
4194    #[serde(skip_serializing_if = "Option::is_none")]
4195    pub http_response: Option<McpOauthHttpResponse>,
4196    /// Why the runtime is requesting host-provided OAuth credentials.
4197    pub reason: McpOauthRequestReason,
4198    /// Unique identifier for this OAuth request; used to respond via session.mcp.oauth.handlePendingRequest
4199    pub request_id: RequestId,
4200    /// Raw OAuth protected-resource metadata document fetched for the MCP server, if available
4201    #[serde(skip_serializing_if = "Option::is_none")]
4202    pub resource_metadata: Option<String>,
4203    /// Display name of the MCP server that requires OAuth
4204    pub server_name: String,
4205    /// URL of the MCP server that requires OAuth
4206    pub server_url: String,
4207    /// Static OAuth client configuration, if the server specifies one
4208    #[serde(skip_serializing_if = "Option::is_none")]
4209    pub static_client_config: Option<McpOauthRequiredStaticClientConfig>,
4210    /// OAuth WWW-Authenticate parameters parsed from the auth challenge, if available
4211    #[serde(skip_serializing_if = "Option::is_none")]
4212    pub www_authenticate_params: Option<McpOauthWWWAuthenticateParams>,
4213}
4214
4215/// Session event "mcp.oauth_completed". MCP OAuth request completion notification
4216#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4217#[serde(rename_all = "camelCase")]
4218pub struct McpOauthCompletedData {
4219    /// How the pending OAuth request was completed
4220    pub outcome: McpOauthCompletionOutcome,
4221    /// Request ID of the resolved OAuth request
4222    pub request_id: RequestId,
4223}
4224
4225/// Session event "mcp.headers_refresh_required". Dynamic headers refresh request for a remote MCP server
4226#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4227#[serde(rename_all = "camelCase")]
4228pub struct McpHeadersRefreshRequiredData {
4229    /// Why dynamic headers are being requested.
4230    pub reason: McpHeadersRefreshRequiredReason,
4231    /// Unique identifier for this headers refresh request; used to respond via session.mcp.headers.handlePendingHeadersRefreshRequest()
4232    pub request_id: RequestId,
4233    /// Display name of the remote MCP server requesting headers
4234    pub server_name: String,
4235    /// URL of the remote MCP server requesting headers
4236    pub server_url: String,
4237}
4238
4239/// Session event "mcp.headers_refresh_completed". MCP headers refresh request completion notification
4240#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4241#[serde(rename_all = "camelCase")]
4242pub struct McpHeadersRefreshCompletedData {
4243    /// How the pending MCP headers refresh request resolved.
4244    pub outcome: McpHeadersRefreshCompletedOutcome,
4245    /// Request ID of the resolved headers refresh request
4246    pub request_id: RequestId,
4247}
4248
4249/// Session event "session.custom_notification". Opaque custom notification data. Consumers may branch on source and name, but payload semantics are source-defined.
4250#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4251#[serde(rename_all = "camelCase")]
4252pub struct SessionCustomNotificationData {
4253    /// Source-defined custom notification name
4254    pub name: String,
4255    /// Source-defined JSON payload for the custom notification
4256    pub payload: serde_json::Value,
4257    /// Namespace for the custom notification producer
4258    pub source: String,
4259    /// Optional source-defined string identifiers describing the payload subject
4260    #[serde(skip_serializing_if = "Option::is_none")]
4261    pub subject: Option<HashMap<String, String>>,
4262    /// Optional source-defined payload schema version
4263    #[serde(skip_serializing_if = "Option::is_none")]
4264    pub version: Option<i64>,
4265}
4266
4267/// Session event "external_tool.requested". External tool invocation request for client-side tool execution
4268#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4269#[serde(rename_all = "camelCase")]
4270pub struct ExternalToolRequestedData {
4271    /// Arguments to pass to the external tool
4272    #[serde(skip_serializing_if = "Option::is_none")]
4273    pub arguments: Option<serde_json::Value>,
4274    /// Unique identifier for this request; used to respond via session.respondToExternalTool()
4275    pub request_id: RequestId,
4276    /// Session ID that this external tool request belongs to
4277    pub session_id: SessionId,
4278    /// Tool call ID assigned to this external tool invocation
4279    pub tool_call_id: String,
4280    /// Name of the external tool to invoke
4281    pub tool_name: String,
4282    /// W3C Trace Context traceparent header for the execute_tool span
4283    #[serde(skip_serializing_if = "Option::is_none")]
4284    pub traceparent: Option<String>,
4285    /// W3C Trace Context tracestate header for the execute_tool span
4286    #[serde(skip_serializing_if = "Option::is_none")]
4287    pub tracestate: Option<String>,
4288    /// Active session working directory, when known.
4289    #[serde(skip_serializing_if = "Option::is_none")]
4290    pub working_directory: Option<String>,
4291}
4292
4293/// Session event "external_tool.completed". External tool completion notification signaling UI dismissal
4294#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4295#[serde(rename_all = "camelCase")]
4296pub struct ExternalToolCompletedData {
4297    /// Request ID of the resolved external tool request; clients should dismiss any UI for this request
4298    pub request_id: RequestId,
4299}
4300
4301/// Session event "command.queued". Queued slash command dispatch request for client execution
4302#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4303#[serde(rename_all = "camelCase")]
4304pub struct CommandQueuedData {
4305    /// The slash command text to be executed (e.g., /help, /clear)
4306    pub command: String,
4307    /// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
4308    pub request_id: RequestId,
4309}
4310
4311/// Session event "command.execute". Registered command dispatch request routed to the owning client
4312#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4313#[serde(rename_all = "camelCase")]
4314pub struct CommandExecuteData {
4315    /// Raw argument string after the command name
4316    pub args: String,
4317    /// The full command text (e.g., /deploy production)
4318    pub command: String,
4319    /// Command name without leading /
4320    pub command_name: String,
4321    /// Unique identifier; used to respond via session.commands.handlePendingCommand()
4322    pub request_id: RequestId,
4323}
4324
4325/// Session event "command.completed". Queued command completion notification signaling UI dismissal
4326#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4327#[serde(rename_all = "camelCase")]
4328pub struct CommandCompletedData {
4329    /// Request ID of the resolved command request; clients should dismiss any UI for this request
4330    pub request_id: RequestId,
4331}
4332
4333/// Session event "auto_mode_switch.requested". Auto mode switch request notification requiring user approval
4334#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4335#[serde(rename_all = "camelCase")]
4336pub struct AutoModeSwitchRequestedData {
4337    /// The rate limit error code that triggered this request
4338    #[serde(skip_serializing_if = "Option::is_none")]
4339    pub error_code: Option<String>,
4340    /// Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
4341    pub request_id: RequestId,
4342    /// Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
4343    #[serde(skip_serializing_if = "Option::is_none")]
4344    pub retry_after_seconds: Option<i64>,
4345}
4346
4347/// Session event "auto_mode_switch.completed". Auto mode switch completion notification
4348#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4349#[serde(rename_all = "camelCase")]
4350pub struct AutoModeSwitchCompletedData {
4351    /// Request ID of the resolved request; clients should dismiss any UI for this request
4352    pub request_id: RequestId,
4353    /// The user's auto-mode-switch choice
4354    pub response: AutoModeSwitchResponse,
4355}
4356
4357/// Session event "session_limits_exhausted.requested". Session limit exhaustion notification requiring user action.
4358#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4359#[serde(rename_all = "camelCase")]
4360pub struct SessionLimitsExhaustedRequestedData {
4361    /// Configured max AI Credits for the current accounting window.
4362    pub max_ai_credits: f64,
4363    /// Unique identifier for this request; used to respond via session.ui.handlePendingSessionLimitsExhausted().
4364    pub request_id: RequestId,
4365    /// AI Credits already consumed in the current accounting window.
4366    pub used_ai_credits: f64,
4367}
4368
4369/// The user's selected action for an exhausted session limit.
4370#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4371#[serde(rename_all = "camelCase")]
4372pub struct SessionLimitsExhaustedResponse {
4373    /// Action selected by the user.
4374    pub action: SessionLimitsExhaustedResponseAction,
4375    /// AI Credits to add to the current max when action is 'add'.
4376    #[serde(skip_serializing_if = "Option::is_none")]
4377    pub additional_ai_credits: Option<f64>,
4378    /// New absolute max AI Credits when action is 'set'.
4379    #[serde(skip_serializing_if = "Option::is_none")]
4380    pub max_ai_credits: Option<f64>,
4381}
4382
4383/// Session event "session_limits_exhausted.completed". Session limit exhaustion prompt completion notification.
4384#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4385#[serde(rename_all = "camelCase")]
4386pub struct SessionLimitsExhaustedCompletedData {
4387    /// Request ID of the resolved request; clients should dismiss any UI for this request.
4388    pub request_id: RequestId,
4389    /// The user's selected session-limit action.
4390    pub response: SessionLimitsExhaustedResponse,
4391}
4392
4393/// Session event "session.auto_mode_resolved". Auto Intent resolution: the concrete model the session settled on for the first prompt of an auto-mode session, and why. Lets SDK clients render the chosen model and the full reason it was picked. The core selection fields (chosenModel/reasoningBucket/categoryScores) are stable; the routing-analytics fields (predictedLabel/confidence/candidateModels) mirror the upstream intent service and may evolve, hence the event's experimental stability.
4394///
4395/// <div class="warning">
4396///
4397/// **Experimental.** This type is part of an experimental wire-protocol surface
4398/// and may change or be removed in future SDK or CLI releases.
4399///
4400/// </div>
4401#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4402#[serde(rename_all = "camelCase")]
4403pub struct SessionAutoModeResolvedData {
4404    /// Models offered to the router for this resolution
4405    #[serde(skip_serializing_if = "Option::is_none")]
4406    pub available_models: Option<Vec<String>>,
4407    /// Ordered candidate model list the router returned, when not a fallback
4408    #[serde(skip_serializing_if = "Option::is_none")]
4409    pub candidate_models: Option<Vec<String>>,
4410    /// Per-category classifier scores (0-1) behind the bucket: the granular HYDRA capability scores (reasoning, code_gen, debugging, tool_use), or the binary needs_reasoning/no_reasoning scores when HYDRA didn't run. Lets clients show a breakdown rather than just the bucket.
4411    #[serde(skip_serializing_if = "Option::is_none")]
4412    pub category_scores: Option<HashMap<String, f64>>,
4413    /// The concrete model the session will use after any intent refinement
4414    pub chosen_model: String,
4415    /// The chosen model's score shortfall relative to the top candidate
4416    #[serde(skip_serializing_if = "Option::is_none")]
4417    pub chosen_shortfall: Option<f64>,
4418    /// Classifier confidence for the predicted label, when available
4419    #[serde(skip_serializing_if = "Option::is_none")]
4420    pub confidence: Option<f64>,
4421    /// End-to-end client wait time for the router request in milliseconds
4422    #[serde(skip_serializing_if = "Option::is_none")]
4423    pub end_to_end_latency_ms: Option<f64>,
4424    /// Whether the router fell back to the standard Auto selection
4425    #[serde(skip_serializing_if = "Option::is_none")]
4426    pub fallback: Option<bool>,
4427    /// Server-provided reason for falling back, when available
4428    #[serde(skip_serializing_if = "Option::is_none")]
4429    pub fallback_reason: Option<String>,
4430    /// Whether the routed prompt contained an image
4431    #[serde(skip_serializing_if = "Option::is_none")]
4432    pub has_image: Option<bool>,
4433    /// The predicted classifier label (e.g. `needs_reasoning`), when available
4434    #[serde(skip_serializing_if = "Option::is_none")]
4435    pub predicted_label: Option<String>,
4436    /// Coarse request-difficulty bucket, for explaining why a model was chosen ("picked X because this looks like high-reasoning work")
4437    #[serde(skip_serializing_if = "Option::is_none")]
4438    pub reasoning_bucket: Option<AutoModeResolvedReasoningBucket>,
4439    /// Server-reported router processing time in milliseconds
4440    #[serde(skip_serializing_if = "Option::is_none")]
4441    pub router_latency_ms: Option<f64>,
4442    /// The routing method the server applied, when Auto Intent ran
4443    #[serde(skip_serializing_if = "Option::is_none")]
4444    pub routing_method: Option<String>,
4445    /// Whether a sticky model choice overrode the router result
4446    #[serde(skip_serializing_if = "Option::is_none")]
4447    pub sticky_override: Option<bool>,
4448}
4449
4450/// Session event "session.managed_settings_resolved". Enterprise managed-settings resolution: the effective managed settings the session applied and which channels contributed, so SDK clients can show users what is enterprise-managed. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted. Device values take precedence over server values per ordinary key, while permissions compose restrictively across device, server, and SDK-client layers. The account-scoped `getManagedSettings()` API does not include session-local client injection. Marked experimental while the managed-settings surface stabilizes.
4451///
4452/// <div class="warning">
4453///
4454/// **Experimental.** This type is part of an experimental wire-protocol surface
4455/// and may change or be removed in future SDK or CLI releases.
4456///
4457/// </div>
4458#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4459#[serde(rename_all = "camelCase")]
4460pub struct SessionManagedSettingsResolvedData {
4461    /// Whether enterprise policy disables bypass-permissions ("yolo") mode for this session. Deny-wins across layers, and forced on when `failClosed` is true.
4462    pub bypass_permissions_disabled: bool,
4463    /// Whether a session-local permissions layer injected by the SDK host was present
4464    #[serde(skip_serializing_if = "Option::is_none")]
4465    pub client_managed: Option<bool>,
4466    /// Whether an actual device MDM/plist/registry/file managed-settings layer was present
4467    pub device_managed: bool,
4468    /// Whether managed policy could not be determined (e.g. a failed server fetch) and the session fell back to the fail-closed restriction. When true, restrictions such as disabling bypass-permissions are enforced even though `settings` may be absent.
4469    pub fail_closed: bool,
4470    /// The setting keys under enterprise management in the effective managed settings (e.g. `model`, `enabledPlugins`, `permissions`). Empty when no managed settings are in force.
4471    pub managed_keys: Vec<String>,
4472    /// Whether at least two managed sources supplied permission allowlists, so enforcement intersects them and the flattened settings payload omits `permissions.allow`.
4473    #[serde(skip_serializing_if = "Option::is_none")]
4474    pub permissions_allow_intersected: Option<bool>,
4475    /// Whether the server (account/org) managed-settings layer was present
4476    pub server_managed: bool,
4477    /// The effective (resolved) managed settings values, so clients can render exactly what is enforced. Absent when no managed policy is in force.
4478    #[serde(skip_serializing_if = "Option::is_none")]
4479    pub settings: Option<serde_json::Value>,
4480    /// Channel summary: `server`, `device`, or `client` when exactly one channel contributed; `mixed` when multiple channels contributed; otherwise `none`. Consult the per-channel booleans for exact provenance.
4481    pub source: ManagedSettingsResolvedSource,
4482}
4483
4484/// Session event "session.managed_settings_enforced". Runtime enforcement of enterprise managed settings: fires when the session blocks or caps a runtime action because enterprise policy governs it, so SDK clients can explain *why* an action was governed. Unlike `session.managed_settings_resolved` (which reports *what* is managed), this reports a concrete governed action — e.g. a user or host tried to turn on a bypass-permissions escalation while policy disables it. Emitted live (not persisted to the session event log) on user/host-initiated attempts only, never for silent policy application. Marked experimental while the managed-settings surface stabilizes.
4485///
4486/// <div class="warning">
4487///
4488/// **Experimental.** This type is part of an experimental wire-protocol surface
4489/// and may change or be removed in future SDK or CLI releases.
4490///
4491/// </div>
4492#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4493#[serde(rename_all = "camelCase")]
4494pub struct SessionManagedSettingsEnforcedData {
4495    /// The category of runtime action that managed policy governed.
4496    pub action: ManagedSettingsEnforcedAction,
4497    /// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused. Absent for actions without a specific escalation primitive.
4498    #[serde(skip_serializing_if = "Option::is_none")]
4499    pub escalation: Option<ManagedSettingsEnforcedEscalation>,
4500    /// Whether the enforcement was forced by fail-closed handling (managed policy could not be determined) rather than an explicit managed setting. When true, `setting` still names the restriction that was applied.
4501    pub fail_closed: bool,
4502    /// A human-readable explanation of why the action was governed, suitable for surfacing to the user.
4503    pub message: String,
4504    /// The managed setting key responsible for the enforcement (e.g. `permissions.disableBypassPermissionsMode`).
4505    pub setting: String,
4506}
4507
4508/// A single slash command available in the session, as listed by the `commands.changed` event.
4509#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4510#[serde(rename_all = "camelCase")]
4511pub struct CommandsChangedCommand {
4512    /// Optional human-readable command description.
4513    #[serde(skip_serializing_if = "Option::is_none")]
4514    pub description: Option<String>,
4515    /// Slash command name without the leading slash.
4516    pub name: String,
4517}
4518
4519/// Session event "commands.changed". SDK command registration change notification
4520#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4521#[serde(rename_all = "camelCase")]
4522pub struct CommandsChangedData {
4523    /// Current list of registered SDK commands
4524    pub commands: Vec<CommandsChangedCommand>,
4525}
4526
4527/// UI capability changes
4528#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4529#[serde(rename_all = "camelCase")]
4530pub struct CapabilitiesChangedUI {
4531    /// Whether canvas rendering is now supported
4532    #[serde(skip_serializing_if = "Option::is_none")]
4533    pub canvases: Option<bool>,
4534    /// Whether elicitation is now supported
4535    #[serde(skip_serializing_if = "Option::is_none")]
4536    pub elicitation: Option<bool>,
4537    /// Whether MCP Apps (SEP-1865) UI passthrough is now supported
4538    #[serde(skip_serializing_if = "Option::is_none")]
4539    pub mcp_apps: Option<bool>,
4540}
4541
4542/// Session event "capabilities.changed". Session capability change notification
4543#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4544#[serde(rename_all = "camelCase")]
4545pub struct CapabilitiesChangedData {
4546    /// UI capability changes
4547    #[serde(skip_serializing_if = "Option::is_none")]
4548    pub ui: Option<CapabilitiesChangedUI>,
4549}
4550
4551/// Session event "exit_plan_mode.requested". Plan approval request with plan content and available user actions
4552#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4553#[serde(rename_all = "camelCase")]
4554pub struct ExitPlanModeRequestedData {
4555    /// Available actions the user can take
4556    pub actions: Vec<ExitPlanModeAction>,
4557    /// Full content of the plan file
4558    pub plan_content: String,
4559    /// Recommended action to preselect for the user
4560    pub recommended_action: ExitPlanModeAction,
4561    /// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
4562    pub request_id: RequestId,
4563    /// Summary of the plan that was created
4564    pub summary: String,
4565}
4566
4567/// Session event "exit_plan_mode.completed". Plan mode exit completion with the user's approval decision and optional feedback
4568#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4569#[serde(rename_all = "camelCase")]
4570pub struct ExitPlanModeCompletedData {
4571    /// Whether the plan was approved by the user
4572    #[serde(skip_serializing_if = "Option::is_none")]
4573    pub approved: Option<bool>,
4574    /// Whether edits should be auto-approved without confirmation
4575    #[serde(skip_serializing_if = "Option::is_none")]
4576    pub auto_approve_edits: Option<bool>,
4577    /// Free-form feedback from the user if they requested changes to the plan
4578    #[serde(skip_serializing_if = "Option::is_none")]
4579    pub feedback: Option<String>,
4580    /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
4581    pub request_id: RequestId,
4582    /// Action selected by the user
4583    #[serde(skip_serializing_if = "Option::is_none")]
4584    pub selected_action: Option<ExitPlanModeAction>,
4585}
4586
4587/// Session event "session.tools_updated". Payload of `session.tools_updated` identifying the model whose resolved tools were updated.
4588#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4589#[serde(rename_all = "camelCase")]
4590pub struct SessionToolsUpdatedData {
4591    /// Identifier of the model the resolved tools apply to.
4592    pub model: String,
4593}
4594
4595/// Session event "session.background_tasks_changed". Empty payload for `session.background_tasks_changed`, indicating background task state changed.
4596#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4597#[serde(rename_all = "camelCase")]
4598pub struct SessionBackgroundTasksChangedData {}
4599
4600/// Session event "factory.run_updated". Ephemeral invalidation signal for a changed factory run.
4601///
4602/// <div class="warning">
4603///
4604/// **Experimental.** This type is part of an experimental wire-protocol surface
4605/// and may change or be removed in future SDK or CLI releases.
4606///
4607/// </div>
4608#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4609#[serde(rename_all = "camelCase")]
4610pub struct FactoryRunUpdatedData {
4611    /// Monotonic revision now available for the run.
4612    pub revision: i64,
4613    pub run_id: String,
4614}
4615
4616/// A single resolved skill in `session.skills_loaded`, including source, invocability, enabled state, path, and argument hint.
4617#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4618#[serde(rename_all = "camelCase")]
4619pub struct SkillsLoadedSkill {
4620    /// Optional freeform hint describing the skill's expected arguments, from the `argument-hint` frontmatter field
4621    #[serde(skip_serializing_if = "Option::is_none")]
4622    pub argument_hint: Option<String>,
4623    /// Canonical slash command name used to invoke the skill, without the leading '/'
4624    #[serde(skip_serializing_if = "Option::is_none")]
4625    pub command_name: Option<String>,
4626    /// Description of what the skill does
4627    pub description: String,
4628    /// Whether the skill is currently enabled
4629    pub enabled: bool,
4630    /// Unique identifier for the skill
4631    pub name: String,
4632    /// Absolute path to the skill file, if available
4633    #[serde(skip_serializing_if = "Option::is_none")]
4634    pub path: Option<String>,
4635    /// Source location type (e.g., project, personal-copilot, plugin, builtin)
4636    pub source: SkillSource,
4637    /// Whether the skill can be invoked by the user as a slash command
4638    pub user_invocable: bool,
4639}
4640
4641/// Session event "session.skills_loaded". Payload of `session.skills_loaded` listing resolved skill metadata.
4642#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4643#[serde(rename_all = "camelCase")]
4644pub struct SessionSkillsLoadedData {
4645    /// Array of resolved skill metadata
4646    pub skills: Vec<SkillsLoadedSkill>,
4647}
4648
4649/// A single loaded custom agent in `session.custom_agents_updated`, with identity, source, tools, invocability, and model override.
4650#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4651#[serde(rename_all = "camelCase")]
4652pub struct CustomAgentsUpdatedAgent {
4653    /// Description of what the agent does
4654    pub description: String,
4655    /// Human-readable display name
4656    pub display_name: String,
4657    /// Unique identifier for the agent
4658    pub id: String,
4659    /// Model override for this agent, if set
4660    #[serde(skip_serializing_if = "Option::is_none")]
4661    pub model: Option<String>,
4662    /// Internal name of the agent
4663    pub name: String,
4664    /// Source location: user, project, inherited, remote, or plugin
4665    pub source: String,
4666    /// List of tool names available to this agent, or null when all tools are available
4667    pub tools: Option<Vec<String>>,
4668    /// Whether the agent can be selected by the user
4669    pub user_invocable: bool,
4670}
4671
4672/// Session event "session.custom_agents_updated". Payload of `session.custom_agents_updated` with loaded custom agents plus non-fatal warnings and fatal errors.
4673#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4674#[serde(rename_all = "camelCase")]
4675pub struct SessionCustomAgentsUpdatedData {
4676    /// Array of loaded custom agent metadata
4677    pub agents: Vec<CustomAgentsUpdatedAgent>,
4678    /// Fatal errors from agent loading
4679    pub errors: Vec<String>,
4680    /// Non-fatal warnings from agent loading
4681    pub warnings: Vec<String>,
4682}
4683
4684/// A single MCP server status summary in `session.mcp_servers_loaded`, including name, status, source, transport, and plugin metadata.
4685#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4686#[serde(rename_all = "camelCase")]
4687pub struct McpServersLoadedServer {
4688    /// Error message if the server failed to connect
4689    #[serde(skip_serializing_if = "Option::is_none")]
4690    pub error: Option<String>,
4691    /// Server name (config key)
4692    pub name: String,
4693    /// Name of the plugin that supplied the effective MCP server config, only when source is plugin
4694    #[serde(skip_serializing_if = "Option::is_none")]
4695    pub plugin_name: Option<String>,
4696    /// Version of the plugin that supplied the effective MCP server config, only when source is plugin
4697    #[serde(skip_serializing_if = "Option::is_none")]
4698    pub plugin_version: Option<String>,
4699    /// Configuration source: user, workspace, plugin, or builtin
4700    #[serde(skip_serializing_if = "Option::is_none")]
4701    pub source: Option<McpServerSource>,
4702    /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
4703    pub status: McpServerStatus,
4704    /// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
4705    #[serde(skip_serializing_if = "Option::is_none")]
4706    pub transport: Option<McpServerTransport>,
4707}
4708
4709/// Session event "session.mcp_servers_loaded". Payload of `session.mcp_servers_loaded` listing MCP server status summaries.
4710#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4711#[serde(rename_all = "camelCase")]
4712pub struct SessionMcpServersLoadedData {
4713    /// Array of MCP server status summaries
4714    pub servers: Vec<McpServersLoadedServer>,
4715}
4716
4717/// Session event "session.mcp_server_status_changed". Payload of `session.mcp_server_status_changed` for one MCP server's status and optional failure error.
4718#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4719#[serde(rename_all = "camelCase")]
4720pub struct SessionMcpServerStatusChangedData {
4721    /// Error message if the server entered a failed state
4722    #[serde(skip_serializing_if = "Option::is_none")]
4723    pub error: Option<String>,
4724    /// Name of the MCP server whose status changed
4725    pub server_name: String,
4726    /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
4727    pub status: McpServerStatus,
4728}
4729
4730/// Session event "mcp.tools.list_changed". Payload identifying the MCP server associated with a list change.
4731#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4732#[serde(rename_all = "camelCase")]
4733pub struct McpToolsListChangedData {
4734    /// Name of the MCP server whose list changed
4735    pub server_name: String,
4736}
4737
4738/// Session event "mcp.resources.list_changed". Payload identifying the MCP server associated with a list change.
4739#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4740#[serde(rename_all = "camelCase")]
4741pub struct McpResourcesListChangedData {
4742    /// Name of the MCP server whose list changed
4743    pub server_name: String,
4744}
4745
4746/// Session event "mcp.prompts.list_changed". Payload identifying the MCP server associated with a list change.
4747#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4748#[serde(rename_all = "camelCase")]
4749pub struct McpPromptsListChangedData {
4750    /// Name of the MCP server whose list changed
4751    pub server_name: String,
4752}
4753
4754/// A single extension discovered by `session.extensions_loaded`, including qualified ID, source, and current status.
4755#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4756#[serde(rename_all = "camelCase")]
4757pub struct ExtensionsLoadedExtension {
4758    /// Source-qualified extension ID (e.g., 'project:my-ext', 'user:auth-helper', 'plugin:my-plugin:my-ext')
4759    pub id: String,
4760    /// Extension name (directory name)
4761    pub name: String,
4762    /// Discovery source
4763    pub source: ExtensionsLoadedExtensionSource,
4764    /// Current status: running, disabled, failed, or starting
4765    pub status: ExtensionsLoadedExtensionStatus,
4766}
4767
4768/// Session event "session.extensions_loaded". Payload of `session.extensions_loaded` listing discovered extensions and their statuses.
4769#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4770#[serde(rename_all = "camelCase")]
4771pub struct SessionExtensionsLoadedData {
4772    /// Array of discovered extensions and their status
4773    pub extensions: Vec<ExtensionsLoadedExtension>,
4774}
4775
4776/// Session event "session.canvas.opened". Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional icon, title, status, URL, and input.
4777///
4778/// <div class="warning">
4779///
4780/// **Experimental.** This type is part of an experimental wire-protocol surface
4781/// and may change or be removed in future SDK or CLI releases.
4782///
4783/// </div>
4784#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4785#[serde(rename_all = "camelCase")]
4786pub struct SessionCanvasOpenedData {
4787    /// Provider-local canvas identifier
4788    pub canvas_id: String,
4789    /// Owning provider identifier
4790    pub extension_id: String,
4791    /// Owning extension display name, when available
4792    #[serde(skip_serializing_if = "Option::is_none")]
4793    pub extension_name: Option<String>,
4794    /// Host-local PNG path for the canvas icon, when supplied
4795    #[serde(skip_serializing_if = "Option::is_none")]
4796    pub icon: Option<String>,
4797    /// Input supplied when the instance was opened
4798    #[serde(skip_serializing_if = "Option::is_none")]
4799    pub input: Option<serde_json::Value>,
4800    /// Stable caller-supplied canvas instance identifier
4801    pub instance_id: String,
4802    /// Provider-supplied status text
4803    #[serde(skip_serializing_if = "Option::is_none")]
4804    pub status: Option<String>,
4805    /// Rendered title
4806    #[serde(skip_serializing_if = "Option::is_none")]
4807    pub title: Option<String>,
4808    /// URL for web-rendered canvases
4809    #[serde(skip_serializing_if = "Option::is_none")]
4810    pub url: Option<String>,
4811}
4812
4813/// A single action within a canvas declaration, with its name, optional description, and optional input schema.
4814///
4815/// <div class="warning">
4816///
4817/// **Experimental.** This type is part of an experimental wire-protocol surface
4818/// and may change or be removed in future SDK or CLI releases.
4819///
4820/// </div>
4821#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4822#[serde(rename_all = "camelCase")]
4823pub struct CanvasRegistryChangedCanvasAction {
4824    /// Action description
4825    #[serde(skip_serializing_if = "Option::is_none")]
4826    pub description: Option<String>,
4827    /// JSON Schema for action input
4828    #[serde(skip_serializing_if = "Option::is_none")]
4829    pub input_schema: Option<serde_json::Value>,
4830    /// Action name
4831    pub name: String,
4832}
4833
4834/// A single canvas declaration in `session.canvas.registry_changed`, including provider IDs, display metadata, input schema, and actions.
4835///
4836/// <div class="warning">
4837///
4838/// **Experimental.** This type is part of an experimental wire-protocol surface
4839/// and may change or be removed in future SDK or CLI releases.
4840///
4841/// </div>
4842#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4843#[serde(rename_all = "camelCase")]
4844pub struct CanvasRegistryChangedCanvas {
4845    /// Actions the agent or host may invoke
4846    #[serde(skip_serializing_if = "Option::is_none")]
4847    pub actions: Option<Vec<CanvasRegistryChangedCanvasAction>>,
4848    /// Provider-local canvas identifier
4849    pub canvas_id: String,
4850    /// Short, single-sentence description shown to the agent in canvas catalogs.
4851    pub description: String,
4852    /// Human-readable canvas name
4853    pub display_name: String,
4854    /// Owning provider identifier
4855    pub extension_id: String,
4856    /// Owning extension display name, when available
4857    #[serde(skip_serializing_if = "Option::is_none")]
4858    pub extension_name: Option<String>,
4859    /// Host-local PNG path for the canvas icon, when supplied
4860    #[serde(skip_serializing_if = "Option::is_none")]
4861    pub icon: Option<String>,
4862    /// JSON Schema for canvas open input
4863    #[serde(skip_serializing_if = "Option::is_none")]
4864    pub input_schema: Option<serde_json::Value>,
4865}
4866
4867/// Session event "session.canvas.registry_changed". Payload of `session.canvas.registry_changed` listing the canvas declarations currently available.
4868///
4869/// <div class="warning">
4870///
4871/// **Experimental.** This type is part of an experimental wire-protocol surface
4872/// and may change or be removed in future SDK or CLI releases.
4873///
4874/// </div>
4875#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4876#[serde(rename_all = "camelCase")]
4877pub struct SessionCanvasRegistryChangedData {
4878    /// Canvas declarations currently available
4879    pub canvases: Vec<CanvasRegistryChangedCanvas>,
4880}
4881
4882/// Session event "session.canvas.closed". Payload of `session.canvas.closed` with the closed canvas instance ID, provider ID, and canvas ID.
4883///
4884/// <div class="warning">
4885///
4886/// **Experimental.** This type is part of an experimental wire-protocol surface
4887/// and may change or be removed in future SDK or CLI releases.
4888///
4889/// </div>
4890#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4891#[serde(rename_all = "camelCase")]
4892pub struct SessionCanvasClosedData {
4893    /// Provider-local canvas identifier
4894    pub canvas_id: String,
4895    /// Owning provider identifier
4896    pub extension_id: String,
4897    /// Stable caller-supplied identifier of the canvas instance that was closed
4898    pub instance_id: String,
4899}
4900
4901/// Session event "session.canvas.unavailable". Transient signal that an open canvas instance's provider has dropped (for example the extension is reloading mid-session). The host should keep the panel mounted and surface a reconnecting affordance rather than tearing it down; a subsequent `session.canvas.opened` for the same instanceId clears the affordance once the provider reconnects with a fresh url. Ephemeral and never persisted, so it is never replayed on cold resume.
4902///
4903/// <div class="warning">
4904///
4905/// **Experimental.** This type is part of an experimental wire-protocol surface
4906/// and may change or be removed in future SDK or CLI releases.
4907///
4908/// </div>
4909#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4910#[serde(rename_all = "camelCase")]
4911pub struct SessionCanvasUnavailableData {
4912    /// Provider-local canvas identifier
4913    pub canvas_id: String,
4914    /// Owning provider identifier
4915    pub extension_id: String,
4916    /// Stable caller-supplied identifier of the canvas instance whose provider became unavailable
4917    pub instance_id: String,
4918}
4919
4920/// Session event "session.canvas.recorded". Durable record that a canvas instance is open, used to restore open canvases on cold session resume. Intentionally omits the transient url and availability.
4921///
4922/// <div class="warning">
4923///
4924/// **Experimental.** This type is part of an experimental wire-protocol surface
4925/// and may change or be removed in future SDK or CLI releases.
4926///
4927/// </div>
4928#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4929#[serde(rename_all = "camelCase")]
4930pub struct SessionCanvasRecordedData {
4931    /// Provider-local canvas identifier
4932    pub canvas_id: String,
4933    /// Owning provider identifier
4934    pub extension_id: String,
4935    /// Input supplied when the instance was opened
4936    #[serde(skip_serializing_if = "Option::is_none")]
4937    pub input: Option<serde_json::Value>,
4938    /// Stable caller-supplied canvas instance identifier
4939    pub instance_id: String,
4940    /// Rendered title
4941    #[serde(skip_serializing_if = "Option::is_none")]
4942    pub title: Option<String>,
4943}
4944
4945/// Session event "session.canvas.removed". Durable record that a canvas instance was closed, superseding a prior instance_recorded during resume replay.
4946///
4947/// <div class="warning">
4948///
4949/// **Experimental.** This type is part of an experimental wire-protocol surface
4950/// and may change or be removed in future SDK or CLI releases.
4951///
4952/// </div>
4953#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4954#[serde(rename_all = "camelCase")]
4955pub struct SessionCanvasRemovedData {
4956    /// Provider-local canvas identifier
4957    pub canvas_id: String,
4958    /// Owning provider identifier
4959    pub extension_id: String,
4960    /// Stable caller-supplied identifier of the canvas instance that was closed
4961    pub instance_id: String,
4962}
4963
4964/// Session event "session.extensions.attachments_pushed". Payload of `session.extensions.attachments_pushed` with extension-contributed attachments for the next send.
4965#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4966#[serde(rename_all = "camelCase")]
4967pub struct SessionExtensionsAttachmentsPushedData {
4968    /// Attachments contributed by an extension; the host should surface these as composer pills and forward them via the next session.send call.
4969    pub attachments: Vec<serde_json::Value>,
4970}
4971
4972/// Set when the underlying tools/call threw an error before returning a CallToolResult
4973#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4974#[serde(rename_all = "camelCase")]
4975pub struct McpAppToolCallCompleteError {
4976    /// Human-readable error message
4977    pub message: String,
4978}
4979
4980/// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
4981#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4982#[serde(rename_all = "camelCase")]
4983pub struct McpAppToolCallCompleteToolMetaUI {
4984    /// `ui://` URI declared by the tool's `_meta.ui.resourceUri`
4985    #[serde(skip_serializing_if = "Option::is_none")]
4986    pub resource_uri: Option<String>,
4987    /// Tool visibility per SEP-1865 (typically a subset of `["model","app"]`)
4988    #[serde(skip_serializing_if = "Option::is_none")]
4989    pub visibility: Option<Vec<String>>,
4990}
4991
4992/// The tool's `_meta.ui` block at the time of the call, so consumers can decide whether to forward the result to the model without re-listing tools.
4993#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4994#[serde(rename_all = "camelCase")]
4995pub struct McpAppToolCallCompleteToolMeta {
4996    /// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
4997    #[serde(skip_serializing_if = "Option::is_none")]
4998    pub ui: Option<McpAppToolCallCompleteToolMetaUI>,
4999}
5000
5001/// Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
5002#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5003#[serde(rename_all = "camelCase")]
5004pub struct McpAppToolCallCompleteData {
5005    /// Arguments passed to the tool by the app view, if any
5006    #[serde(skip_serializing_if = "Option::is_none")]
5007    pub arguments: Option<HashMap<String, serde_json::Value>>,
5008    /// Wall-clock duration of the underlying tools/call in milliseconds
5009    pub duration_ms: f64,
5010    /// Set when the underlying tools/call threw an error before returning a CallToolResult
5011    #[serde(skip_serializing_if = "Option::is_none")]
5012    pub error: Option<McpAppToolCallCompleteError>,
5013    /// Standard MCP CallToolResult returned by the server. Present whether or not the call set isError.
5014    #[serde(skip_serializing_if = "Option::is_none")]
5015    pub result: Option<HashMap<String, serde_json::Value>>,
5016    /// Name of the MCP server hosting the tool
5017    pub server_name: String,
5018    /// True when the call completed without throwing AND the MCP CallToolResult did not set isError
5019    pub success: bool,
5020    /// The tool's `_meta.ui` block at the time of the call, so consumers can decide whether to forward the result to the model without re-listing tools.
5021    #[serde(skip_serializing_if = "Option::is_none")]
5022    pub tool_meta: Option<McpAppToolCallCompleteToolMeta>,
5023    /// MCP tool name that was invoked
5024    pub tool_name: String,
5025}
5026
5027/// Hosting platform type of the repository (github or ado)
5028#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5029pub enum WorkingDirectoryContextHostType {
5030    /// Repository is hosted on GitHub.
5031    #[serde(rename = "github")]
5032    GitHub,
5033    /// Repository is hosted on Azure DevOps.
5034    #[serde(rename = "ado")]
5035    Ado,
5036    /// Unknown variant for forward compatibility.
5037    #[default]
5038    #[serde(other)]
5039    Unknown,
5040}
5041
5042/// Allowed values for the `ContextTier` enumeration.
5043#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5044pub enum ContextTier {
5045    /// Default context tier with standard context window size.
5046    #[serde(rename = "default")]
5047    Default,
5048    /// Extended context tier with a larger context window.
5049    #[serde(rename = "long_context")]
5050    LongContext,
5051    /// Unknown variant for forward compatibility.
5052    #[default]
5053    #[serde(other)]
5054    Unknown,
5055}
5056
5057/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
5058#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5059pub enum ReasoningSummary {
5060    /// Do not request reasoning summaries from the model.
5061    #[serde(rename = "none")]
5062    None,
5063    /// Request a concise summary of the model's reasoning.
5064    #[serde(rename = "concise")]
5065    Concise,
5066    /// Request a detailed summary of the model's reasoning.
5067    #[serde(rename = "detailed")]
5068    Detailed,
5069    /// Unknown variant for forward compatibility.
5070    #[default]
5071    #[serde(other)]
5072    Unknown,
5073}
5074
5075/// Output verbosity level used for supported model calls (e.g. "low", "medium", "high")
5076#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5077pub enum Verbosity {
5078    /// A terse response was requested.
5079    #[serde(rename = "low")]
5080    Low,
5081    /// A medium amount of response detail was requested.
5082    #[serde(rename = "medium")]
5083    Medium,
5084    /// A more detailed response was requested.
5085    #[serde(rename = "high")]
5086    High,
5087    /// Unknown variant for forward compatibility.
5088    #[default]
5089    #[serde(other)]
5090    Unknown,
5091}
5092
5093/// Who created the schedule: `user` (an explicit user action such as `/every` or `/after`) or `model` (the agent via the `manage_schedule` tool). Gates whether a scheduled skill that opted out of model invocation may fire: only user-created schedules may.
5094#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5095pub enum ScheduleOrigin {
5096    /// The schedule was created by an explicit user action, such as `/every` or `/after`.
5097    #[serde(rename = "user")]
5098    User,
5099    /// The schedule was created by the agent via the `manage_schedule` tool.
5100    #[serde(rename = "model")]
5101    Model,
5102    /// Unknown variant for forward compatibility.
5103    #[default]
5104    #[serde(other)]
5105    Unknown,
5106}
5107
5108/// The type of operation performed on the autopilot objective state file
5109#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5110pub enum AutopilotObjectiveChangedOperation {
5111    /// Autopilot objective state file was created for a new objective.
5112    #[serde(rename = "create")]
5113    Create,
5114    /// Autopilot objective state file was updated for an existing objective.
5115    #[serde(rename = "update")]
5116    Update,
5117    /// Autopilot objective state file was deleted or cleared.
5118    #[serde(rename = "delete")]
5119    Delete,
5120    /// Unknown variant for forward compatibility.
5121    #[default]
5122    #[serde(other)]
5123    Unknown,
5124}
5125
5126/// Current autopilot objective status, if one exists
5127#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5128pub enum AutopilotObjectiveChangedStatus {
5129    /// Objective is active and can drive autopilot continuations.
5130    #[serde(rename = "active")]
5131    Active,
5132    /// Objective is paused and will not drive autopilot continuations.
5133    #[serde(rename = "paused")]
5134    Paused,
5135    /// Legacy objective state indicating the previous continuation cap was reached.
5136    #[serde(rename = "cap_reached")]
5137    CapReached,
5138    /// Objective was completed by the agent.
5139    #[serde(rename = "completed")]
5140    Completed,
5141    /// Unknown variant for forward compatibility.
5142    #[default]
5143    #[serde(other)]
5144    Unknown,
5145}
5146
5147/// The session mode the agent is operating in
5148#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5149pub enum SessionMode {
5150    /// The agent is responding interactively to the user.
5151    #[serde(rename = "interactive")]
5152    Interactive,
5153    /// The agent is preparing a plan before making changes.
5154    #[serde(rename = "plan")]
5155    Plan,
5156    /// The agent is working autonomously toward task completion.
5157    #[serde(rename = "autopilot")]
5158    Autopilot,
5159    /// Unknown variant for forward compatibility.
5160    #[default]
5161    #[serde(other)]
5162    Unknown,
5163}
5164
5165/// Allow-all mode for the session.
5166///
5167/// <div class="warning">
5168///
5169/// **Experimental.** This type is part of an experimental wire-protocol surface
5170/// and may change or be removed in future SDK or CLI releases.
5171///
5172/// </div>
5173#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5174pub enum PermissionAllowAllMode {
5175    /// Permission requests follow the normal approval flow.
5176    #[serde(rename = "off")]
5177    Off,
5178    /// Tool, path, and URL permission requests are automatically approved.
5179    #[serde(rename = "on")]
5180    On,
5181    /// Permission requests follow the normal approval flow with an LLM advisory recommendation attached; clients may choose to auto-approve requests the judge evaluated as acceptable.
5182    #[serde(rename = "auto")]
5183    Auto,
5184    /// Unknown variant for forward compatibility.
5185    #[default]
5186    #[serde(other)]
5187    Unknown,
5188}
5189
5190/// The type of operation performed on the plan file
5191#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5192pub enum PlanChangedOperation {
5193    /// The plan file was created.
5194    #[serde(rename = "create")]
5195    Create,
5196    /// The plan file was updated.
5197    #[serde(rename = "update")]
5198    Update,
5199    /// The plan file was deleted.
5200    #[serde(rename = "delete")]
5201    Delete,
5202    /// Unknown variant for forward compatibility.
5203    #[default]
5204    #[serde(other)]
5205    Unknown,
5206}
5207
5208/// Whether the file was newly created or updated
5209#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5210pub enum WorkspaceFileChangedOperation {
5211    /// The workspace file was created.
5212    #[serde(rename = "create")]
5213    Create,
5214    /// The workspace file was updated.
5215    #[serde(rename = "update")]
5216    Update,
5217    /// Unknown variant for forward compatibility.
5218    #[default]
5219    #[serde(other)]
5220    Unknown,
5221}
5222
5223/// Origin type of the session being handed off
5224#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5225pub enum HandoffSourceType {
5226    /// The handoff originated from a remote session.
5227    #[serde(rename = "remote")]
5228    Remote,
5229    /// The handoff originated from a local session.
5230    #[serde(rename = "local")]
5231    Local,
5232    /// Unknown variant for forward compatibility.
5233    #[default]
5234    #[serde(other)]
5235    Unknown,
5236}
5237
5238/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
5239#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5240pub enum ShutdownType {
5241    /// The session ended normally.
5242    #[serde(rename = "routine")]
5243    Routine,
5244    /// The session ended because of a crash or fatal error.
5245    #[serde(rename = "error")]
5246    Error,
5247    /// Unknown variant for forward compatibility.
5248    #[default]
5249    #[serde(other)]
5250    Unknown,
5251}
5252
5253/// What initiated a conversation compaction
5254#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5255pub enum CompactionTrigger {
5256    /// Background compaction started automatically because context utilization crossed the background threshold.
5257    #[serde(rename = "threshold")]
5258    Threshold,
5259    /// Compaction forced by a context-limit model response (e.g. HTTP 413) before retrying the request.
5260    #[serde(rename = "context_limit_retry")]
5261    ContextLimitRetry,
5262    /// User-requested compaction, e.g. the /compact command or the history.compact API.
5263    #[serde(rename = "manual")]
5264    Manual,
5265    /// Emergency compaction triggered by high process memory usage.
5266    #[serde(rename = "memory_pressure")]
5267    MemoryPressure,
5268    /// Compaction requested while switching to a model with a smaller context window.
5269    #[serde(rename = "model_switch")]
5270    ModelSwitch,
5271    /// Unknown variant for forward compatibility.
5272    #[default]
5273    #[serde(other)]
5274    Unknown,
5275}
5276
5277/// Semantic result of evaluating a task completion request
5278#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5279pub enum TaskCompletionOutcome {
5280    /// The completion request was accepted and the objective is complete.
5281    #[serde(rename = "completed")]
5282    Completed,
5283    /// The completion request was rejected because more work or validation remains.
5284    #[serde(rename = "continue")]
5285    Continue,
5286    /// Completion cannot proceed without intervention; the active objective is paused when one is identified.
5287    #[serde(rename = "blocked")]
5288    Blocked,
5289    /// Unknown variant for forward compatibility.
5290    #[default]
5291    #[serde(other)]
5292    Unknown,
5293}
5294
5295/// The agent mode that was active when this message was sent
5296#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5297pub enum UserMessageAgentMode {
5298    /// The agent is responding interactively to the user.
5299    #[serde(rename = "interactive")]
5300    Interactive,
5301    /// The agent is preparing a plan before making changes.
5302    #[serde(rename = "plan")]
5303    Plan,
5304    /// The agent is working autonomously toward task completion.
5305    #[serde(rename = "autopilot")]
5306    Autopilot,
5307    /// The agent is in shell-focused UI mode.
5308    #[serde(rename = "shell")]
5309    Shell,
5310    /// Unknown variant for forward compatibility.
5311    #[default]
5312    #[serde(other)]
5313    Unknown,
5314}
5315
5316/// How this user message was delivered to the agentic loop, relative to whether the loop was already running. This is the timing axis only; the message's origin (human vs. system/command/schedule/skill/etc.) is carried separately by `source`. A system-injected message has a delivery too — e.g. a background-task notification waking an idle agent is `idle`, the same mechanism as a human starting a fresh turn.
5317#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5318pub enum UserMessageDelivery {
5319    /// Delivered while the loop was idle; starts its own run immediately (a human's fresh turn, or a system notification waking an idle agent).
5320    #[serde(rename = "idle")]
5321    Idle,
5322    /// Injected into the current in-flight run while the agent was busy (immediate mode).
5323    #[serde(rename = "steering")]
5324    Steering,
5325    /// Enqueued while the agent was busy; processed as its own run afterward.
5326    #[serde(rename = "queued")]
5327    Queued,
5328    /// Unknown variant for forward compatibility.
5329    #[default]
5330    #[serde(other)]
5331    Unknown,
5332}
5333
5334/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
5335#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5336pub enum AssistantMessageToolRequestType {
5337    /// Standard function-style tool call.
5338    #[serde(rename = "function")]
5339    Function,
5340    /// Custom grammar-based tool call.
5341    #[serde(rename = "custom")]
5342    Custom,
5343    /// Unknown variant for forward compatibility.
5344    #[default]
5345    #[serde(other)]
5346    Unknown,
5347}
5348
5349/// The system that produced a citation.
5350///
5351/// <div class="warning">
5352///
5353/// **Experimental.** This type is part of an experimental wire-protocol surface
5354/// and may change or be removed in future SDK or CLI releases.
5355///
5356/// </div>
5357#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5358pub enum CitationProvider {
5359    /// Citation produced by an Anthropic (Claude) model response.
5360    #[serde(rename = "anthropic")]
5361    Anthropic,
5362    /// Citation produced by an OpenAI model response.
5363    #[serde(rename = "openai")]
5364    Openai,
5365    /// Citation synthesized client-side by the runtime from tool output.
5366    #[serde(rename = "client")]
5367    Client,
5368    /// Unknown variant for forward compatibility.
5369    #[default]
5370    #[serde(other)]
5371    Unknown,
5372}
5373
5374/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
5375#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5376pub enum AssistantUsageApiEndpoint {
5377    /// Chat Completions API endpoint.
5378    #[serde(rename = "/chat/completions")]
5379    ChatCompletions,
5380    /// Anthropic Messages API endpoint.
5381    #[serde(rename = "/v1/messages")]
5382    V1Messages,
5383    /// Responses API endpoint.
5384    #[serde(rename = "/responses")]
5385    Responses,
5386    /// WebSocket Responses API endpoint.
5387    #[serde(rename = "ws:/responses")]
5388    WsResponses,
5389    /// Unknown variant for forward compatibility.
5390    #[default]
5391    #[serde(other)]
5392    Unknown,
5393}
5394
5395/// For HTTP 400 failures only: whether the response carried a structured CAPI error envelope (structured_error, a deterministic validation failure) or no error body (bodyless, the transient gateway/proxy signature). Absent for non-400 failures.
5396#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5397pub enum ModelCallFailureBadRequestKind {
5398    /// The 400 response carried no error body (transient gateway/proxy signature).
5399    #[serde(rename = "bodyless")]
5400    Bodyless,
5401    /// The 400 response carried a structured CAPI error envelope (deterministic validation failure).
5402    #[serde(rename = "structured_error")]
5403    StructuredError,
5404    /// Unknown variant for forward compatibility.
5405    #[default]
5406    #[serde(other)]
5407    Unknown,
5408}
5409
5410/// Boundary that produced a model call failure
5411#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5412pub enum ModelCallFailureKind {
5413    /// The provider returned an API error response.
5414    #[serde(rename = "api")]
5415    Api,
5416    /// The request transport failed before a usable API response completed.
5417    #[serde(rename = "transport")]
5418    Transport,
5419    /// Unknown variant for forward compatibility.
5420    #[default]
5421    #[serde(other)]
5422    Unknown,
5423}
5424
5425/// Where the failed model call originated
5426#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5427pub enum ModelCallFailureSource {
5428    /// Model call from the top-level agent.
5429    #[serde(rename = "top_level")]
5430    TopLevel,
5431    /// Model call from a sub-agent.
5432    #[serde(rename = "subagent")]
5433    Subagent,
5434    /// Model call from MCP sampling.
5435    #[serde(rename = "mcp_sampling")]
5436    McpSampling,
5437    /// Unknown variant for forward compatibility.
5438    #[default]
5439    #[serde(other)]
5440    Unknown,
5441}
5442
5443/// Transport used for a failed model call
5444#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5445pub enum ModelCallFailureTransport {
5446    /// HTTP transport, including SSE streams.
5447    #[serde(rename = "http")]
5448    Http,
5449    /// WebSocket transport.
5450    #[serde(rename = "websocket")]
5451    Websocket,
5452    /// Unknown variant for forward compatibility.
5453    #[default]
5454    #[serde(other)]
5455    Unknown,
5456}
5457
5458/// Finite reason code describing why the current turn was aborted
5459#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5460pub enum AbortReason {
5461    /// The local user requested the abort, for example by pressing Ctrl+C in the CLI.
5462    #[serde(rename = "user_initiated")]
5463    UserInitiated,
5464    /// A remote command requested the abort.
5465    #[serde(rename = "remote_command")]
5466    RemoteCommand,
5467    /// An MCP server delivered a user.abort notification.
5468    #[serde(rename = "user_abort")]
5469    UserAbort,
5470    /// Autopilot stopped the run because the active objective reached its user-set --max-ai-credits limit.
5471    #[serde(rename = "autopilot_credit_limit")]
5472    AutopilotCreditLimit,
5473    /// Unknown variant for forward compatibility.
5474    #[default]
5475    #[serde(other)]
5476    Unknown,
5477}
5478
5479/// Allowed values for the `ToolExecutionStartToolDescriptionMetaUIVisibility` enumeration.
5480#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5481pub enum ToolExecutionStartToolDescriptionMetaUIVisibility {
5482    /// Tool is callable by the model (LLM tool surface)
5483    #[serde(rename = "model")]
5484    Model,
5485    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
5486    #[serde(rename = "app")]
5487    App,
5488    /// Unknown variant for forward compatibility.
5489    #[default]
5490    #[serde(other)]
5491    Unknown,
5492}
5493
5494/// Content block type discriminator
5495#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5496pub enum ToolExecutionCompleteContentTextType {
5497    #[serde(rename = "text")]
5498    #[default]
5499    Text,
5500}
5501
5502/// Content block type discriminator
5503#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5504pub enum ToolExecutionCompleteContentTerminalType {
5505    #[serde(rename = "terminal")]
5506    #[default]
5507    Terminal,
5508}
5509
5510/// Content block type discriminator
5511#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5512pub enum ToolExecutionCompleteContentShellExitType {
5513    #[serde(rename = "shell_exit")]
5514    #[default]
5515    ShellExit,
5516}
5517
5518/// Content block type discriminator
5519#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5520pub enum ToolExecutionCompleteContentImageType {
5521    #[serde(rename = "image")]
5522    #[default]
5523    Image,
5524}
5525
5526/// Content block type discriminator
5527#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5528pub enum ToolExecutionCompleteContentAudioType {
5529    #[serde(rename = "audio")]
5530    #[default]
5531    Audio,
5532}
5533
5534/// Theme variant this icon is intended for
5535#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5536pub enum ToolExecutionCompleteContentResourceLinkIconTheme {
5537    /// Icon intended for light themes.
5538    #[serde(rename = "light")]
5539    Light,
5540    /// Icon intended for dark themes.
5541    #[serde(rename = "dark")]
5542    Dark,
5543    /// Unknown variant for forward compatibility.
5544    #[default]
5545    #[serde(other)]
5546    Unknown,
5547}
5548
5549/// Content block type discriminator
5550#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5551pub enum ToolExecutionCompleteContentResourceLinkType {
5552    #[serde(rename = "resource_link")]
5553    #[default]
5554    ResourceLink,
5555}
5556
5557/// The embedded resource contents, either text or base64-encoded binary
5558#[derive(Debug, Clone, Serialize, Deserialize)]
5559#[serde(untagged)]
5560pub enum ToolExecutionCompleteContentResourceDetails {
5561    EmbeddedTextResourceContents(EmbeddedTextResourceContents),
5562    EmbeddedBlobResourceContents(EmbeddedBlobResourceContents),
5563}
5564
5565/// Content block type discriminator
5566#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5567pub enum ToolExecutionCompleteContentResourceType {
5568    #[serde(rename = "resource")]
5569    #[default]
5570    Resource,
5571}
5572
5573/// A content block within a tool result, which may be text, terminal output, image, audio, or a resource
5574#[derive(Debug, Clone, Serialize, Deserialize)]
5575#[serde(untagged)]
5576pub enum ToolExecutionCompleteContent {
5577    Text(ToolExecutionCompleteContentText),
5578    Terminal(ToolExecutionCompleteContentTerminal),
5579    ShellExit(ToolExecutionCompleteContentShellExit),
5580    Image(ToolExecutionCompleteContentImage),
5581    Audio(ToolExecutionCompleteContentAudio),
5582    ResourceLink(ToolExecutionCompleteContentResourceLink),
5583    Resource(ToolExecutionCompleteContentResource),
5584}
5585
5586/// Allowed values for the `ToolExecutionCompleteToolDescriptionMetaUIVisibility` enumeration.
5587#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5588pub enum ToolExecutionCompleteToolDescriptionMetaUIVisibility {
5589    /// Tool is callable by the model (LLM tool surface)
5590    #[serde(rename = "model")]
5591    Model,
5592    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
5593    #[serde(rename = "app")]
5594    App,
5595    /// Unknown variant for forward compatibility.
5596    #[default]
5597    #[serde(other)]
5598    Unknown,
5599}
5600
5601/// What triggered the skill invocation: `user-invoked` (explicit user action, such as via a slash command or UI affordance), `agent-invoked` (agent requested the skill), or `context-load` (loaded as part of another context, such as preloading skills configured on a custom agent or subagent)
5602#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5603pub enum SkillInvokedTrigger {
5604    /// Skill invocation requested explicitly by the user, such as via a slash command or UI affordance.
5605    #[serde(rename = "user-invoked")]
5606    UserInvoked,
5607    /// Skill invocation requested by the agent.
5608    #[serde(rename = "agent-invoked")]
5609    AgentInvoked,
5610    /// Skill content loaded as part of another context, such as a configured custom agent or subagent.
5611    #[serde(rename = "context-load")]
5612    ContextLoad,
5613    /// Unknown variant for forward compatibility.
5614    #[default]
5615    #[serde(other)]
5616    Unknown,
5617}
5618
5619/// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
5620#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5621pub enum BinaryAssetType {
5622    /// Binary image data.
5623    #[serde(rename = "image")]
5624    Image,
5625    /// Other binary resource data.
5626    #[serde(rename = "resource")]
5627    Resource,
5628    /// Unknown variant for forward compatibility.
5629    #[default]
5630    #[serde(other)]
5631    Unknown,
5632}
5633
5634/// Message role: "system" for system prompts, "developer" for developer-injected instructions
5635#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5636pub enum SystemMessageRole {
5637    /// System prompt message.
5638    #[serde(rename = "system")]
5639    System,
5640    /// Developer instruction message.
5641    #[serde(rename = "developer")]
5642    Developer,
5643    /// Unknown variant for forward compatibility.
5644    #[default]
5645    #[serde(other)]
5646    Unknown,
5647}
5648
5649/// Permission kind discriminator
5650#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5651pub enum PermissionRequestShellKind {
5652    #[serde(rename = "shell")]
5653    #[default]
5654    Shell,
5655}
5656
5657/// Permission kind discriminator
5658#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5659pub enum PermissionRequestWriteKind {
5660    #[serde(rename = "write")]
5661    #[default]
5662    Write,
5663}
5664
5665/// Permission kind discriminator
5666#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5667pub enum PermissionRequestReadKind {
5668    #[serde(rename = "read")]
5669    #[default]
5670    Read,
5671}
5672
5673/// Permission kind discriminator
5674#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5675pub enum PermissionRequestMcpKind {
5676    #[serde(rename = "mcp")]
5677    #[default]
5678    Mcp,
5679}
5680
5681/// Permission kind discriminator
5682#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5683pub enum PermissionRequestUrlKind {
5684    #[serde(rename = "url")]
5685    #[default]
5686    Url,
5687}
5688
5689/// Whether this is a store or vote memory operation
5690#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5691pub enum PermissionRequestMemoryAction {
5692    /// Store a new memory.
5693    #[serde(rename = "store")]
5694    Store,
5695    /// Vote on an existing memory.
5696    #[serde(rename = "vote")]
5697    Vote,
5698    /// Unknown variant for forward compatibility.
5699    #[default]
5700    #[serde(other)]
5701    Unknown,
5702}
5703
5704/// Vote direction (vote only)
5705#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5706pub enum PermissionRequestMemoryDirection {
5707    /// Vote that the memory is useful or accurate.
5708    #[serde(rename = "upvote")]
5709    Upvote,
5710    /// Vote that the memory is incorrect or outdated.
5711    #[serde(rename = "downvote")]
5712    Downvote,
5713    /// Unknown variant for forward compatibility.
5714    #[default]
5715    #[serde(other)]
5716    Unknown,
5717}
5718
5719/// Permission kind discriminator
5720#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5721pub enum PermissionRequestMemoryKind {
5722    #[serde(rename = "memory")]
5723    #[default]
5724    Memory,
5725}
5726
5727/// Permission kind discriminator
5728#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5729pub enum PermissionRequestCustomToolKind {
5730    #[serde(rename = "custom-tool")]
5731    #[default]
5732    CustomTool,
5733}
5734
5735/// Permission kind discriminator
5736#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5737pub enum PermissionRequestHookKind {
5738    #[serde(rename = "hook")]
5739    #[default]
5740    Hook,
5741}
5742
5743/// Permission kind discriminator
5744#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5745pub enum PermissionRequestExtensionManagementKind {
5746    #[serde(rename = "extension-management")]
5747    #[default]
5748    ExtensionManagement,
5749}
5750
5751/// Permission kind discriminator
5752#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5753pub enum PermissionRequestFactoryKind {
5754    #[serde(rename = "factory")]
5755    #[default]
5756    Factory,
5757}
5758
5759/// Operation gated by a factory permission request.
5760#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5761pub enum FactoryPermissionOperation {
5762    /// Running a registered factory, which spends subagents, active time, and AI credits under the approved limits.
5763    #[serde(rename = "run")]
5764    Run,
5765    /// Authoring a factory, which writes JavaScript into a session-scoped extension and loads it.
5766    #[serde(rename = "author")]
5767    Author,
5768    /// Unknown variant for forward compatibility.
5769    #[default]
5770    #[serde(other)]
5771    Unknown,
5772}
5773
5774/// Permission kind discriminator
5775#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5776pub enum PermissionRequestExtensionPermissionAccessKind {
5777    #[serde(rename = "extension-permission-access")]
5778    #[default]
5779    ExtensionPermissionAccess,
5780}
5781
5782/// Details of the permission being requested
5783#[derive(Debug, Clone, Serialize, Deserialize)]
5784#[serde(untagged)]
5785pub enum PermissionRequest {
5786    Shell(PermissionRequestShell),
5787    Write(PermissionRequestWrite),
5788    Read(PermissionRequestRead),
5789    Mcp(PermissionRequestMcp),
5790    Url(PermissionRequestUrl),
5791    Memory(PermissionRequestMemory),
5792    CustomTool(PermissionRequestCustomTool),
5793    Hook(PermissionRequestHook),
5794    ExtensionManagement(PermissionRequestExtensionManagement),
5795    Factory(PermissionRequestFactory),
5796    ExtensionPermissionAccess(PermissionRequestExtensionPermissionAccess),
5797}
5798
5799/// Why the auto-approval judge produced no usable recommendation. Present only alongside an `error` recommendation, where the human-readable reason is a fixed string and therefore cannot distinguish these cases. Intended to make a judge failure reportable by a consumer that has no access to the host's logs.
5800///
5801/// <div class="warning">
5802///
5803/// **Experimental.** This type is part of an experimental wire-protocol surface
5804/// and may change or be removed in future SDK or CLI releases.
5805///
5806/// </div>
5807#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5808pub enum AutoApprovalJudgeFailureReason {
5809    /// The judge model call exceeded its deadline.
5810    #[serde(rename = "timeout")]
5811    Timeout,
5812    /// The judge model call was cancelled before it returned.
5813    #[serde(rename = "abort")]
5814    Abort,
5815    /// The judge model call completed but returned no content.
5816    #[serde(rename = "empty_response")]
5817    EmptyResponse,
5818    /// The judge model call failed (for example a transport, authentication, or rate-limit error).
5819    #[serde(rename = "model_error")]
5820    ModelError,
5821    /// The judge model replied, but the reply carried no ALLOW/DENY verdict.
5822    #[serde(rename = "parse_error")]
5823    ParseError,
5824    /// Unknown variant for forward compatibility.
5825    #[default]
5826    #[serde(other)]
5827    Unknown,
5828}
5829
5830/// Outcome of the auto-approval safety judge for a permission request. Present only when auto mode is enabled; its absence means the judge did not evaluate the request (auto mode was off).
5831///
5832/// <div class="warning">
5833///
5834/// **Experimental.** This type is part of an experimental wire-protocol surface
5835/// and may change or be removed in future SDK or CLI releases.
5836///
5837/// </div>
5838#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5839pub enum AutoApprovalRecommendation {
5840    /// The judge evaluated the request and recommends automatically approving it.
5841    #[serde(rename = "approve")]
5842    Approve,
5843    /// The judge evaluated the request and does not recommend auto-approving it; explicit approval is required. Whether that means prompting, denying, or something else is the consumer's decision.
5844    #[serde(rename = "requireApproval")]
5845    RequireApproval,
5846    /// Auto mode is enabled, but this request category is never auto-approvable (for example, sandbox-bypass requests), so the judge was not consulted.
5847    #[serde(rename = "excluded")]
5848    Excluded,
5849    /// The judge was consulted but did not return a usable recommendation, so the request requires explicit approval.
5850    #[serde(rename = "error")]
5851    Error,
5852    /// Unknown variant for forward compatibility.
5853    #[default]
5854    #[serde(other)]
5855    Unknown,
5856}
5857
5858/// Prompt kind discriminator
5859#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5860pub enum PermissionPromptRequestCommandsKind {
5861    #[serde(rename = "commands")]
5862    #[default]
5863    Commands,
5864}
5865
5866/// Prompt kind discriminator
5867#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5868pub enum PermissionPromptRequestWriteKind {
5869    #[serde(rename = "write")]
5870    #[default]
5871    Write,
5872}
5873
5874/// Prompt kind discriminator
5875#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5876pub enum PermissionPromptRequestReadKind {
5877    #[serde(rename = "read")]
5878    #[default]
5879    Read,
5880}
5881
5882/// Prompt kind discriminator
5883#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5884pub enum PermissionPromptRequestMcpKind {
5885    #[serde(rename = "mcp")]
5886    #[default]
5887    Mcp,
5888}
5889
5890/// Prompt kind discriminator
5891#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5892pub enum PermissionPromptRequestUrlKind {
5893    #[serde(rename = "url")]
5894    #[default]
5895    Url,
5896}
5897
5898/// Prompt kind discriminator
5899#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5900pub enum PermissionPromptRequestMemoryKind {
5901    #[serde(rename = "memory")]
5902    #[default]
5903    Memory,
5904}
5905
5906/// Prompt kind discriminator
5907#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5908pub enum PermissionPromptRequestCustomToolKind {
5909    #[serde(rename = "custom-tool")]
5910    #[default]
5911    CustomTool,
5912}
5913
5914/// Underlying permission kind that needs path approval
5915#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5916pub enum PermissionPromptRequestPathAccessKind {
5917    /// Read access to a filesystem path.
5918    #[serde(rename = "read")]
5919    Read,
5920    /// Shell command access involving a filesystem path.
5921    #[serde(rename = "shell")]
5922    Shell,
5923    /// Write access to a filesystem path.
5924    #[serde(rename = "write")]
5925    Write,
5926    /// Unknown variant for forward compatibility.
5927    #[default]
5928    #[serde(other)]
5929    Unknown,
5930}
5931
5932/// Prompt kind discriminator
5933#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5934pub enum PermissionPromptRequestPathKind {
5935    #[serde(rename = "path")]
5936    #[default]
5937    Path,
5938}
5939
5940/// Prompt kind discriminator
5941#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5942pub enum PermissionPromptRequestHookKind {
5943    #[serde(rename = "hook")]
5944    #[default]
5945    Hook,
5946}
5947
5948/// Prompt kind discriminator
5949#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5950pub enum PermissionPromptRequestExtensionManagementKind {
5951    #[serde(rename = "extension-management")]
5952    #[default]
5953    ExtensionManagement,
5954}
5955
5956/// Prompt kind discriminator
5957#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5958pub enum PermissionPromptRequestFactoryKind {
5959    #[serde(rename = "factory")]
5960    #[default]
5961    Factory,
5962}
5963
5964/// Prompt kind discriminator
5965#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5966pub enum PermissionPromptRequestExtensionPermissionAccessKind {
5967    #[serde(rename = "extension-permission-access")]
5968    #[default]
5969    ExtensionPermissionAccess,
5970}
5971
5972/// Derived user-facing permission prompt details for UI consumers
5973#[derive(Debug, Clone, Serialize, Deserialize)]
5974#[serde(untagged)]
5975pub enum PermissionPromptRequest {
5976    Commands(PermissionPromptRequestCommands),
5977    Write(PermissionPromptRequestWrite),
5978    Read(PermissionPromptRequestRead),
5979    Mcp(PermissionPromptRequestMcp),
5980    Url(PermissionPromptRequestUrl),
5981    Memory(PermissionPromptRequestMemory),
5982    CustomTool(PermissionPromptRequestCustomTool),
5983    Path(PermissionPromptRequestPath),
5984    Hook(PermissionPromptRequestHook),
5985    ExtensionManagement(PermissionPromptRequestExtensionManagement),
5986    Factory(PermissionPromptRequestFactory),
5987    ExtensionPermissionAccess(PermissionPromptRequestExtensionPermissionAccess),
5988}
5989
5990/// The permission request was approved
5991#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5992pub enum PermissionApprovedKind {
5993    #[serde(rename = "approved")]
5994    #[default]
5995    Approved,
5996}
5997
5998/// Command approval kind
5999#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6000pub enum UserToolSessionApprovalCommandsKind {
6001    #[serde(rename = "commands")]
6002    #[default]
6003    Commands,
6004}
6005
6006/// Read approval kind
6007#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6008pub enum UserToolSessionApprovalReadKind {
6009    #[serde(rename = "read")]
6010    #[default]
6011    Read,
6012}
6013
6014/// Write approval kind
6015#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6016pub enum UserToolSessionApprovalWriteKind {
6017    #[serde(rename = "write")]
6018    #[default]
6019    Write,
6020}
6021
6022/// MCP tool approval kind
6023#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6024pub enum UserToolSessionApprovalMcpKind {
6025    #[serde(rename = "mcp")]
6026    #[default]
6027    Mcp,
6028}
6029
6030/// Memory approval kind
6031#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6032pub enum UserToolSessionApprovalMemoryKind {
6033    #[serde(rename = "memory")]
6034    #[default]
6035    Memory,
6036}
6037
6038/// Custom tool approval kind
6039#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6040pub enum UserToolSessionApprovalCustomToolKind {
6041    #[serde(rename = "custom-tool")]
6042    #[default]
6043    CustomTool,
6044}
6045
6046/// Extension management approval kind
6047#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6048pub enum UserToolSessionApprovalExtensionManagementKind {
6049    #[serde(rename = "extension-management")]
6050    #[default]
6051    ExtensionManagement,
6052}
6053
6054/// Factory approval kind
6055#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6056pub enum UserToolSessionApprovalFactoryKind {
6057    #[serde(rename = "factory")]
6058    #[default]
6059    Factory,
6060}
6061
6062/// Extension permission access approval kind
6063#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6064pub enum UserToolSessionApprovalExtensionPermissionAccessKind {
6065    #[serde(rename = "extension-permission-access")]
6066    #[default]
6067    ExtensionPermissionAccess,
6068}
6069
6070/// The approval to add as a session-scoped rule
6071#[derive(Debug, Clone, Serialize, Deserialize)]
6072#[serde(untagged)]
6073pub enum UserToolSessionApproval {
6074    Commands(UserToolSessionApprovalCommands),
6075    Read(UserToolSessionApprovalRead),
6076    Write(UserToolSessionApprovalWrite),
6077    Mcp(UserToolSessionApprovalMcp),
6078    Memory(UserToolSessionApprovalMemory),
6079    CustomTool(UserToolSessionApprovalCustomTool),
6080    ExtensionManagement(UserToolSessionApprovalExtensionManagement),
6081    Factory(UserToolSessionApprovalFactory),
6082    ExtensionPermissionAccess(UserToolSessionApprovalExtensionPermissionAccess),
6083}
6084
6085/// Approved and remembered for the rest of the session
6086#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6087pub enum PermissionApprovedForSessionKind {
6088    #[serde(rename = "approved-for-session")]
6089    #[default]
6090    ApprovedForSession,
6091}
6092
6093/// Approved and persisted for this project location
6094#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6095pub enum PermissionApprovedForLocationKind {
6096    #[serde(rename = "approved-for-location")]
6097    #[default]
6098    ApprovedForLocation,
6099}
6100
6101/// The permission request was cancelled before a response was used
6102#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6103pub enum PermissionCancelledKind {
6104    #[serde(rename = "cancelled")]
6105    #[default]
6106    Cancelled,
6107}
6108
6109/// Denied because approval rules explicitly blocked it
6110#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6111pub enum PermissionDeniedByRulesKind {
6112    #[serde(rename = "denied-by-rules")]
6113    #[default]
6114    DeniedByRules,
6115}
6116
6117/// Denied because no approval rule matched and user confirmation was unavailable
6118#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6119pub enum PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind {
6120    #[serde(rename = "denied-no-approval-rule-and-could-not-request-from-user")]
6121    #[default]
6122    DeniedNoApprovalRuleAndCouldNotRequestFromUser,
6123}
6124
6125/// Denied by the user during an interactive prompt
6126#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6127pub enum PermissionDeniedInteractivelyByUserKind {
6128    #[serde(rename = "denied-interactively-by-user")]
6129    #[default]
6130    DeniedInteractivelyByUser,
6131}
6132
6133/// Denied by the organization's content exclusion policy
6134#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6135pub enum PermissionDeniedByContentExclusionPolicyKind {
6136    #[serde(rename = "denied-by-content-exclusion-policy")]
6137    #[default]
6138    DeniedByContentExclusionPolicy,
6139}
6140
6141/// Denied by a permission request hook registered by an extension or plugin
6142#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6143pub enum PermissionDeniedByPermissionRequestHookKind {
6144    #[serde(rename = "denied-by-permission-request-hook")]
6145    #[default]
6146    DeniedByPermissionRequestHook,
6147}
6148
6149/// The result of the permission request
6150#[derive(Debug, Clone, Serialize, Deserialize)]
6151#[serde(untagged)]
6152pub enum PermissionResult {
6153    Approved(PermissionApproved),
6154    ApprovedForSession(PermissionApprovedForSession),
6155    ApprovedForLocation(PermissionApprovedForLocation),
6156    Cancelled(PermissionCancelled),
6157    DeniedByRules(PermissionDeniedByRules),
6158    DeniedNoApprovalRuleAndCouldNotRequestFromUser(
6159        PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser,
6160    ),
6161    DeniedInteractivelyByUser(PermissionDeniedInteractivelyByUser),
6162    DeniedByContentExclusionPolicy(PermissionDeniedByContentExclusionPolicy),
6163    DeniedByPermissionRequestHook(PermissionDeniedByPermissionRequestHook),
6164}
6165
6166/// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
6167#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6168pub enum ElicitationRequestedMode {
6169    /// Structured form-based elicitation.
6170    #[serde(rename = "form")]
6171    Form,
6172    /// Browser URL-based elicitation.
6173    #[serde(rename = "url")]
6174    Url,
6175    /// Unknown variant for forward compatibility.
6176    #[default]
6177    #[serde(other)]
6178    Unknown,
6179}
6180
6181/// Schema type indicator (always 'object')
6182#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6183pub enum ElicitationRequestedSchemaType {
6184    #[serde(rename = "object")]
6185    #[default]
6186    Object,
6187}
6188
6189/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
6190#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6191pub enum ElicitationCompletedAction {
6192    /// The user submitted the requested form.
6193    #[serde(rename = "accept")]
6194    Accept,
6195    /// The user explicitly declined the request.
6196    #[serde(rename = "decline")]
6197    Decline,
6198    /// The user dismissed the request.
6199    #[serde(rename = "cancel")]
6200    Cancel,
6201    /// Unknown variant for forward compatibility.
6202    #[default]
6203    #[serde(other)]
6204    Unknown,
6205}
6206
6207/// Reason the runtime is requesting host-provided MCP OAuth credentials
6208#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6209pub enum McpOauthRequestReason {
6210    /// Initial credentials are required before connecting to the MCP server.
6211    #[serde(rename = "initial")]
6212    Initial,
6213    /// The current host-provided credential was rejected and a replacement is requested.
6214    #[serde(rename = "refresh")]
6215    Refresh,
6216    /// The server requires a new host authorization flow before continuing.
6217    #[serde(rename = "reauth")]
6218    Reauth,
6219    /// The server requires a credential with additional scope or audience.
6220    #[serde(rename = "upscope")]
6221    Upscope,
6222    /// Unknown variant for forward compatibility.
6223    #[default]
6224    #[serde(other)]
6225    Unknown,
6226}
6227
6228/// 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).
6229#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6230pub enum McpOauthRequiredStaticClientConfigGrantType {
6231    #[serde(rename = "client_credentials")]
6232    #[default]
6233    ClientCredentials,
6234}
6235
6236/// How the pending MCP OAuth request was completed
6237#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6238pub enum McpOauthCompletionOutcome {
6239    /// The request completed with a token-backed OAuth provider.
6240    #[serde(rename = "token")]
6241    Token,
6242    /// The request completed without an OAuth provider.
6243    #[serde(rename = "cancelled")]
6244    Cancelled,
6245    /// Unknown variant for forward compatibility.
6246    #[default]
6247    #[serde(other)]
6248    Unknown,
6249}
6250
6251/// Why dynamic headers are being requested.
6252#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6253pub enum McpHeadersRefreshRequiredReason {
6254    /// The transport is making its first dynamic header request for this server.
6255    #[serde(rename = "startup")]
6256    Startup,
6257    /// The previously cached dynamic headers expired.
6258    #[serde(rename = "ttl-expired")]
6259    TtlExpired,
6260    /// The server returned 401 and stale dynamic headers were invalidated.
6261    #[serde(rename = "auth-failed")]
6262    AuthFailed,
6263    /// Unknown variant for forward compatibility.
6264    #[default]
6265    #[serde(other)]
6266    Unknown,
6267}
6268
6269/// How the pending MCP headers refresh request resolved.
6270#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6271pub enum McpHeadersRefreshCompletedOutcome {
6272    /// The host supplied dynamic headers.
6273    #[serde(rename = "headers")]
6274    Headers,
6275    /// The host responded with no dynamic headers.
6276    #[serde(rename = "none")]
6277    None,
6278    /// No response arrived within the bounded window.
6279    #[serde(rename = "timeout")]
6280    Timeout,
6281    /// Unknown variant for forward compatibility.
6282    #[default]
6283    #[serde(other)]
6284    Unknown,
6285}
6286
6287/// The user's auto-mode-switch choice
6288#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6289pub enum AutoModeSwitchResponse {
6290    /// Switch models for this request.
6291    #[serde(rename = "yes")]
6292    Yes,
6293    /// Switch models now and keep using the replacement automatically.
6294    #[serde(rename = "yes_always")]
6295    YesAlways,
6296    /// Do not switch models.
6297    #[serde(rename = "no")]
6298    No,
6299    /// Unknown variant for forward compatibility.
6300    #[default]
6301    #[serde(other)]
6302    Unknown,
6303}
6304
6305/// User action selected for an exhausted session limit.
6306#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6307pub enum SessionLimitsExhaustedResponseAction {
6308    /// Increase the current max by an exact AI Credits amount.
6309    #[serde(rename = "add")]
6310    Add,
6311    /// Set a new absolute max AI Credits value.
6312    #[serde(rename = "set")]
6313    Set,
6314    /// Remove the current session limit.
6315    #[serde(rename = "unset")]
6316    Unset,
6317    /// Leave the limit unchanged and cancel the blocked model request.
6318    #[serde(rename = "cancel")]
6319    Cancel,
6320    /// Unknown variant for forward compatibility.
6321    #[default]
6322    #[serde(other)]
6323    Unknown,
6324}
6325
6326/// Coarse request-difficulty bucket for UX explainability
6327#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6328pub enum AutoModeResolvedReasoningBucket {
6329    /// The request looks low-reasoning; a lighter model is appropriate.
6330    #[serde(rename = "low")]
6331    Low,
6332    /// The request needs a moderate amount of reasoning.
6333    #[serde(rename = "medium")]
6334    Medium,
6335    /// The request looks high-reasoning; a stronger model is appropriate.
6336    #[serde(rename = "high")]
6337    High,
6338    /// Unknown variant for forward compatibility.
6339    #[default]
6340    #[serde(other)]
6341    Unknown,
6342}
6343
6344/// Summary of which managed-settings channels contributed to the effective session policy. Use the per-channel booleans for exact provenance.
6345#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6346pub enum ManagedSettingsResolvedSource {
6347    /// Only the server/account channel contributed.
6348    #[serde(rename = "server")]
6349    Server,
6350    /// Only the device MDM/plist/registry/file channel contributed.
6351    #[serde(rename = "device")]
6352    Device,
6353    /// Only session-local SDK-host injection contributed.
6354    #[serde(rename = "client")]
6355    Client,
6356    /// More than one channel contributed. Ordinary keys resolve device over server per key, while permissions compose restrictively across all present layers.
6357    #[serde(rename = "mixed")]
6358    Mixed,
6359    /// No managed policy is in force (no channel contributed).
6360    #[serde(rename = "none")]
6361    None,
6362    /// Unknown variant for forward compatibility.
6363    #[default]
6364    #[serde(other)]
6365    Unknown,
6366}
6367
6368/// The category of runtime action that enterprise managed settings governed (blocked or capped)
6369#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6370pub enum ManagedSettingsEnforcedAction {
6371    /// An attempt to turn on a bypass-permissions ("yolo") escalation was refused or capped because policy disables bypass-permissions mode.
6372    #[serde(rename = "bypass_permissions_blocked")]
6373    BypassPermissionsBlocked,
6374    /// Unknown variant for forward compatibility.
6375    #[default]
6376    #[serde(other)]
6377    Unknown,
6378}
6379
6380/// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused
6381#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6382pub enum ManagedSettingsEnforcedEscalation {
6383    /// Full allow-all ("/allow-all on") permissions — auto-approving tools, paths, and URLs.
6384    #[serde(rename = "allow_all")]
6385    AllowAll,
6386    /// Auto-approval of all tool permission requests.
6387    #[serde(rename = "approve_all")]
6388    ApproveAll,
6389    /// Advisory auto-approval ("/allow-all auto") mode — keeps normal prompt paths and adds LLM-advised approval, distinct from full allow-all.
6390    #[serde(rename = "auto_approval")]
6391    AutoApproval,
6392    /// Unrestricted filesystem access outside the session's allowed directories.
6393    #[serde(rename = "unrestricted_paths")]
6394    UnrestrictedPaths,
6395    /// Unrestricted URL fetch access.
6396    #[serde(rename = "unrestricted_urls")]
6397    UnrestrictedUrls,
6398    /// Unknown variant for forward compatibility.
6399    #[default]
6400    #[serde(other)]
6401    Unknown,
6402}
6403
6404/// Exit plan mode action
6405#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6406pub enum ExitPlanModeAction {
6407    /// Exit plan mode without starting implementation.
6408    #[serde(rename = "exit_only")]
6409    ExitOnly,
6410    /// Exit plan mode and continue in interactive mode.
6411    #[serde(rename = "interactive")]
6412    Interactive,
6413    /// Exit plan mode and continue autonomously.
6414    #[serde(rename = "autopilot")]
6415    Autopilot,
6416    /// Exit plan mode and continue with parallel autonomous workers.
6417    #[serde(rename = "autopilot_fleet")]
6418    AutopilotFleet,
6419    /// Unknown variant for forward compatibility.
6420    #[default]
6421    #[serde(other)]
6422    Unknown,
6423}
6424
6425/// Source location type (e.g., project, personal-copilot, plugin, builtin)
6426#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6427pub enum SkillSource {
6428    /// Skill defined in the current project's skill directories.
6429    #[serde(rename = "project")]
6430    Project,
6431    /// Skill discovered from a parent directory in the current workspace tree.
6432    #[serde(rename = "inherited")]
6433    Inherited,
6434    /// Skill defined in the user's Copilot skill directory.
6435    #[serde(rename = "personal-copilot")]
6436    PersonalCopilot,
6437    /// Skill defined in the user's personal agents skill directory.
6438    #[serde(rename = "personal-agents")]
6439    PersonalAgents,
6440    /// Skill provided by an installed plugin.
6441    #[serde(rename = "plugin")]
6442    Plugin,
6443    /// Skill loaded from a configured custom skill directory.
6444    #[serde(rename = "custom")]
6445    Custom,
6446    /// Skill bundled with the runtime.
6447    #[serde(rename = "builtin")]
6448    Builtin,
6449    /// Unknown variant for forward compatibility.
6450    #[default]
6451    #[serde(other)]
6452    Unknown,
6453}
6454
6455/// Configuration source: user, workspace, plugin, or builtin
6456#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6457pub enum McpServerSource {
6458    /// Server configured in the user's global MCP configuration.
6459    #[serde(rename = "user")]
6460    User,
6461    /// Server configured by the current workspace.
6462    #[serde(rename = "workspace")]
6463    Workspace,
6464    /// Server contributed by an installed plugin.
6465    #[serde(rename = "plugin")]
6466    Plugin,
6467    /// Server bundled with the runtime.
6468    #[serde(rename = "builtin")]
6469    Builtin,
6470    /// Unknown variant for forward compatibility.
6471    #[default]
6472    #[serde(other)]
6473    Unknown,
6474}
6475
6476/// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
6477#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6478pub enum McpServerStatus {
6479    /// The server is connected and available.
6480    #[serde(rename = "connected")]
6481    Connected,
6482    /// The server failed to connect or initialize.
6483    #[serde(rename = "failed")]
6484    Failed,
6485    /// The server requires authentication before it can connect.
6486    #[serde(rename = "needs-auth")]
6487    NeedsAuth,
6488    /// The server connection is still being established.
6489    #[serde(rename = "pending")]
6490    Pending,
6491    /// The server is configured but disabled.
6492    #[serde(rename = "disabled")]
6493    Disabled,
6494    /// The server was intentionally stopped and can be restarted on demand when policy permits; a server quarantined by restrictive managed policy stays stopped and cannot be restarted until the policy allows it.
6495    #[serde(rename = "stopped")]
6496    Stopped,
6497    /// The server is not configured for this session.
6498    #[serde(rename = "not_configured")]
6499    NotConfigured,
6500    /// Unknown variant for forward compatibility.
6501    #[default]
6502    #[serde(other)]
6503    Unknown,
6504}
6505
6506/// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
6507#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6508pub enum McpServerTransport {
6509    /// Server communicates over stdio with a local child process.
6510    #[serde(rename = "stdio")]
6511    Stdio,
6512    /// Server communicates over streamable HTTP.
6513    #[serde(rename = "http")]
6514    Http,
6515    /// Server communicates over Server-Sent Events (deprecated).
6516    #[serde(rename = "sse")]
6517    Sse,
6518    /// Server is backed by an in-memory runtime implementation.
6519    #[serde(rename = "memory")]
6520    Memory,
6521    /// Unknown variant for forward compatibility.
6522    #[default]
6523    #[serde(other)]
6524    Unknown,
6525}
6526
6527/// Discovery source
6528#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6529pub enum ExtensionsLoadedExtensionSource {
6530    /// Extension discovered from the current project.
6531    #[serde(rename = "project")]
6532    Project,
6533    /// Extension discovered from the user's extension directory.
6534    #[serde(rename = "user")]
6535    User,
6536    /// Extension contributed by an installed plugin.
6537    #[serde(rename = "plugin")]
6538    Plugin,
6539    /// Extension discovered from the current session's state directory.
6540    #[serde(rename = "session")]
6541    Session,
6542    /// Unknown variant for forward compatibility.
6543    #[default]
6544    #[serde(other)]
6545    Unknown,
6546}
6547
6548/// Current status: running, disabled, failed, or starting
6549#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6550pub enum ExtensionsLoadedExtensionStatus {
6551    /// The extension process is running.
6552    #[serde(rename = "running")]
6553    Running,
6554    /// The extension is installed but disabled.
6555    #[serde(rename = "disabled")]
6556    Disabled,
6557    /// The extension failed to start or crashed.
6558    #[serde(rename = "failed")]
6559    Failed,
6560    /// The extension process is starting.
6561    #[serde(rename = "starting")]
6562    Starting,
6563    /// Unknown variant for forward compatibility.
6564    #[default]
6565    #[serde(other)]
6566    Unknown,
6567}