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    /// Whether the sub-agent was torn down by cancellation - its own abort, or an ancestor being killed - instead of finishing its work. Cancellation is not a failure, so the run still reports completion; this distinguishes a torn-down sub-agent from one that ran to the end.
2864    #[serde(skip_serializing_if = "Option::is_none")]
2865    pub cancelled: Option<bool>,
2866    /// Wall-clock duration of the sub-agent execution in milliseconds
2867    #[serde(skip_serializing_if = "Option::is_none")]
2868    pub duration_ms: Option<i64>,
2869    /// Model used by the sub-agent
2870    #[serde(skip_serializing_if = "Option::is_none")]
2871    pub model: Option<String>,
2872    /// Tool call ID of the parent tool invocation that spawned this sub-agent
2873    pub tool_call_id: String,
2874    /// Total tokens (input + output) consumed by the sub-agent
2875    #[serde(skip_serializing_if = "Option::is_none")]
2876    pub total_tokens: Option<i64>,
2877    /// Total number of tool calls made by the sub-agent
2878    #[serde(skip_serializing_if = "Option::is_none")]
2879    pub total_tool_calls: Option<i64>,
2880}
2881
2882/// Session event "subagent.failed". Sub-agent failure details including error message and agent information
2883#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2884#[serde(rename_all = "camelCase")]
2885pub struct SubagentFailedData {
2886    /// Human-readable display name of the sub-agent
2887    pub agent_display_name: String,
2888    /// Internal name of the sub-agent
2889    pub agent_name: String,
2890    /// Wall-clock duration of the sub-agent execution in milliseconds
2891    #[serde(skip_serializing_if = "Option::is_none")]
2892    pub duration_ms: Option<i64>,
2893    /// Error message describing why the sub-agent failed
2894    pub error: String,
2895    /// Model selected for the sub-agent, when known
2896    #[serde(skip_serializing_if = "Option::is_none")]
2897    pub model: Option<String>,
2898    /// Tool call ID of the parent tool invocation that spawned this sub-agent
2899    pub tool_call_id: String,
2900    /// Total tokens (input + output) consumed before the sub-agent failed
2901    #[serde(skip_serializing_if = "Option::is_none")]
2902    pub total_tokens: Option<i64>,
2903    /// Total number of tool calls made before the sub-agent failed
2904    #[serde(skip_serializing_if = "Option::is_none")]
2905    pub total_tool_calls: Option<i64>,
2906}
2907
2908/// Session event "subagent.selected". Custom agent selection details including name and available tools
2909#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2910#[serde(rename_all = "camelCase")]
2911pub struct SubagentSelectedData {
2912    /// Human-readable display name of the selected custom agent
2913    pub agent_display_name: String,
2914    /// Internal name of the selected custom agent
2915    pub agent_name: String,
2916    /// List of tool names available to this agent, or null for all tools
2917    pub tools: Option<Vec<String>>,
2918}
2919
2920/// Session event "subagent.deselected". Empty payload; the event signals that the custom agent was deselected, returning to the default agent
2921#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2922#[serde(rename_all = "camelCase")]
2923pub struct SubagentDeselectedData {}
2924
2925/// Session event "hook.start". Hook invocation start details including type and input data
2926#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2927#[serde(rename_all = "camelCase")]
2928pub struct HookStartData {
2929    /// Unique identifier for this hook invocation
2930    pub hook_invocation_id: String,
2931    /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
2932    pub hook_type: String,
2933    /// Input data passed to the hook
2934    #[serde(skip_serializing_if = "Option::is_none")]
2935    pub input: Option<serde_json::Value>,
2936}
2937
2938/// Error details when the hook failed
2939#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2940#[serde(rename_all = "camelCase")]
2941pub struct HookEndError {
2942    /// Human-readable error message
2943    pub message: String,
2944    /// Source label of the hook that errored (e.g. the plugin it was loaded from), when known
2945    #[serde(skip_serializing_if = "Option::is_none")]
2946    pub source: Option<String>,
2947    /// Error stack trace, when available
2948    #[serde(skip_serializing_if = "Option::is_none")]
2949    pub stack: Option<String>,
2950}
2951
2952/// Session event "hook.end". Hook invocation completion details including output, success status, and error information
2953#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2954#[serde(rename_all = "camelCase")]
2955pub struct HookEndData {
2956    /// Error details when the hook failed
2957    #[serde(skip_serializing_if = "Option::is_none")]
2958    pub error: Option<HookEndError>,
2959    /// Identifier matching the corresponding hook.start event
2960    pub hook_invocation_id: String,
2961    /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
2962    pub hook_type: String,
2963    /// Output data produced by the hook
2964    #[serde(skip_serializing_if = "Option::is_none")]
2965    pub output: Option<serde_json::Value>,
2966    /// Whether the hook completed successfully
2967    pub success: bool,
2968}
2969
2970/// Session event "hook.progress". Ephemeral progress update from a running hook process
2971#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2972#[serde(rename_all = "camelCase")]
2973pub struct HookProgressData {
2974    /// Human-readable progress message from the hook process
2975    pub message: String,
2976    /// When true, this status message replaces the previous temporary one instead of accumulating
2977    #[serde(skip_serializing_if = "Option::is_none")]
2978    pub temporary: Option<bool>,
2979}
2980
2981/// Session event "session.binary_asset". Canonical bytes for a content-addressed binary asset shared by reference across events
2982#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2983#[serde(rename_all = "camelCase")]
2984pub struct SessionBinaryAssetData {
2985    /// Content-addressed id for this binary asset (e.g. "sha256:...").
2986    pub asset_id: String,
2987    /// Decoded byte length of the binary asset
2988    pub byte_length: i64,
2989    /// Base64-encoded binary data
2990    pub data: String,
2991    /// Human-readable description of the binary data
2992    #[serde(skip_serializing_if = "Option::is_none")]
2993    pub description: Option<String>,
2994    /// Optional metadata from the producing tool.
2995    #[serde(skip_serializing_if = "Option::is_none")]
2996    pub metadata: Option<HashMap<String, serde_json::Value>>,
2997    /// MIME type of the binary asset
2998    pub mime_type: String,
2999    /// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
3000    pub r#type: BinaryAssetType,
3001}
3002
3003/// Metadata about the prompt template and its construction
3004#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3005#[serde(rename_all = "camelCase")]
3006pub struct SystemMessageMetadata {
3007    /// Version identifier of the prompt template used
3008    #[serde(skip_serializing_if = "Option::is_none")]
3009    pub prompt_version: Option<String>,
3010    /// Template variables used when constructing the prompt
3011    #[serde(skip_serializing_if = "Option::is_none")]
3012    pub variables: Option<HashMap<String, serde_json::Value>>,
3013}
3014
3015/// Session event "system.message". System/developer instruction content with role and optional template metadata
3016#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3017#[serde(rename_all = "camelCase")]
3018pub struct SystemMessageData {
3019    /// The system or developer prompt text sent as model input
3020    pub content: String,
3021    /// Logical interaction identifier for the model run receiving this prompt
3022    #[serde(skip_serializing_if = "Option::is_none")]
3023    pub interaction_id: Option<String>,
3024    /// Metadata about the prompt template and its construction
3025    #[serde(skip_serializing_if = "Option::is_none")]
3026    pub metadata: Option<SystemMessageMetadata>,
3027    /// Optional name identifier for the message source
3028    #[serde(skip_serializing_if = "Option::is_none")]
3029    pub name: Option<String>,
3030    /// Message role: "system" for system prompts, "developer" for developer-injected instructions
3031    pub role: SystemMessageRole,
3032}
3033
3034/// Session event "system.notification". System-generated notification for runtime events like background task completion
3035#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3036#[serde(rename_all = "camelCase")]
3037pub struct SystemNotificationData {
3038    /// The notification text, typically wrapped in <system_notification> XML tags
3039    pub content: String,
3040    /// Structured metadata identifying what triggered this notification
3041    pub kind: serde_json::Value,
3042}
3043
3044/// A parsed command identifier in a shell permission request, including whether it is read-only.
3045#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3046#[serde(rename_all = "camelCase")]
3047pub struct PermissionRequestShellCommand {
3048    /// Command identifier (e.g., executable name)
3049    pub identifier: String,
3050    /// Whether this command is read-only (no side effects)
3051    pub read_only: bool,
3052}
3053
3054/// A parsed shell command segment used for argument-aware managed policy matching.
3055#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3056#[serde(rename_all = "camelCase")]
3057pub struct PermissionRequestShellCommandSegment {
3058    /// Full text of this command segment, including arguments
3059    pub full_command_text: String,
3060    /// Command identifier (e.g., executable name)
3061    pub identifier: String,
3062}
3063
3064/// A URL that may be accessed by a command in a shell permission request.
3065#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3066#[serde(rename_all = "camelCase")]
3067pub struct PermissionRequestShellPossibleUrl {
3068    /// URL that may be accessed by the command
3069    pub url: String,
3070}
3071
3072/// Shell command permission request
3073#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3074#[serde(rename_all = "camelCase")]
3075pub struct PermissionRequestShell {
3076    /// Whether the UI can offer session-wide approval for this command pattern
3077    pub can_offer_session_approval: bool,
3078    /// Parsed command identifiers found in the command text
3079    pub commands: Vec<PermissionRequestShellCommand>,
3080    /// Parsed command segments, including arguments, used for managed policy matching
3081    #[serde(skip_serializing_if = "Option::is_none")]
3082    pub command_segments: Option<Vec<PermissionRequestShellCommandSegment>>,
3083    /// The complete shell command text to be executed
3084    pub full_command_text: String,
3085    /// Whether the command includes a file write redirection (e.g., > or >>)
3086    pub has_write_file_redirection: bool,
3087    /// Human-readable description of what the command intends to do
3088    pub intention: String,
3089    /// Permission kind discriminator
3090    pub kind: PermissionRequestShellKind,
3091    /// Whether managed policy requires a human response and forbids host auto-approval
3092    #[serde(skip_serializing_if = "Option::is_none")]
3093    pub managed_approval_required: Option<bool>,
3094    /// File paths that may be read or written by the command
3095    pub possible_paths: Vec<String>,
3096    /// URLs that may be accessed by the command
3097    pub possible_urls: Vec<PermissionRequestShellPossibleUrl>,
3098    /// 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.
3099    #[serde(skip_serializing_if = "Option::is_none")]
3100    pub request_sandbox_bypass: Option<bool>,
3101    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3102    #[serde(skip_serializing_if = "Option::is_none")]
3103    pub request_sandbox_bypass_reason: Option<String>,
3104    /// Tool call ID that triggered this permission request
3105    #[serde(skip_serializing_if = "Option::is_none")]
3106    pub tool_call_id: Option<String>,
3107    /// Optional warning message about risks of running this command
3108    #[serde(skip_serializing_if = "Option::is_none")]
3109    pub warning: Option<String>,
3110}
3111
3112/// File write permission request
3113#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3114#[serde(rename_all = "camelCase")]
3115pub struct PermissionRequestWrite {
3116    /// Whether the UI can offer session-wide approval for file write operations
3117    pub can_offer_session_approval: bool,
3118    /// Unified diff showing the proposed changes
3119    pub diff: String,
3120    /// Path of the file being written to
3121    pub file_name: String,
3122    /// Human-readable description of the intended file change
3123    pub intention: String,
3124    /// Permission kind discriminator
3125    pub kind: PermissionRequestWriteKind,
3126    /// Whether managed policy requires a human response and forbids host auto-approval
3127    #[serde(skip_serializing_if = "Option::is_none")]
3128    pub managed_approval_required: Option<bool>,
3129    /// Complete new file contents for newly created files
3130    #[serde(skip_serializing_if = "Option::is_none")]
3131    pub new_file_contents: Option<String>,
3132    /// 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.
3133    #[serde(skip_serializing_if = "Option::is_none")]
3134    pub request_sandbox_bypass: Option<bool>,
3135    /// Justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3136    #[serde(skip_serializing_if = "Option::is_none")]
3137    pub request_sandbox_bypass_reason: Option<String>,
3138    /// Tool call ID that triggered this permission request
3139    #[serde(skip_serializing_if = "Option::is_none")]
3140    pub tool_call_id: Option<String>,
3141}
3142
3143/// File or directory read permission request
3144#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3145#[serde(rename_all = "camelCase")]
3146pub struct PermissionRequestRead {
3147    /// Human-readable description of why the file is being read
3148    pub intention: String,
3149    /// Permission kind discriminator
3150    pub kind: PermissionRequestReadKind,
3151    /// Whether managed policy requires a human response and forbids host auto-approval
3152    #[serde(skip_serializing_if = "Option::is_none")]
3153    pub managed_approval_required: Option<bool>,
3154    /// Path of the file or directory being read
3155    pub path: String,
3156    /// 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.
3157    #[serde(skip_serializing_if = "Option::is_none")]
3158    pub request_sandbox_bypass: Option<bool>,
3159    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3160    #[serde(skip_serializing_if = "Option::is_none")]
3161    pub request_sandbox_bypass_reason: Option<String>,
3162    /// Tool call ID that triggered this permission request
3163    #[serde(skip_serializing_if = "Option::is_none")]
3164    pub tool_call_id: Option<String>,
3165}
3166
3167/// MCP tool invocation permission request
3168#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3169#[serde(rename_all = "camelCase")]
3170pub struct PermissionRequestMcp {
3171    /// Arguments to pass to the MCP tool
3172    #[serde(skip_serializing_if = "Option::is_none")]
3173    pub args: Option<serde_json::Value>,
3174    /// Permission kind discriminator
3175    pub kind: PermissionRequestMcpKind,
3176    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3177    #[serde(skip_serializing_if = "Option::is_none")]
3178    pub managed_approval_required: Option<bool>,
3179    /// Whether this MCP tool is read-only (no side effects)
3180    pub read_only: bool,
3181    /// Name of the MCP server providing the tool
3182    pub server_name: String,
3183    /// Tool call ID that triggered this permission request
3184    #[serde(skip_serializing_if = "Option::is_none")]
3185    pub tool_call_id: Option<String>,
3186    /// Internal name of the MCP tool
3187    pub tool_name: String,
3188    /// Human-readable title of the MCP tool
3189    pub tool_title: String,
3190}
3191
3192/// URL access permission request
3193#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3194#[serde(rename_all = "camelCase")]
3195pub struct PermissionRequestUrl {
3196    /// Human-readable description of why the URL is being accessed
3197    pub intention: String,
3198    /// Permission kind discriminator
3199    pub kind: PermissionRequestUrlKind,
3200    /// Whether managed policy requires a human response and forbids host auto-approval
3201    #[serde(skip_serializing_if = "Option::is_none")]
3202    pub managed_approval_required: Option<bool>,
3203    /// Immediately preceding URL when this request is for a redirect target
3204    #[serde(skip_serializing_if = "Option::is_none")]
3205    pub redirected_from: Option<String>,
3206    /// 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.
3207    #[serde(skip_serializing_if = "Option::is_none")]
3208    pub request_sandbox_bypass: Option<bool>,
3209    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3210    #[serde(skip_serializing_if = "Option::is_none")]
3211    pub request_sandbox_bypass_reason: Option<String>,
3212    /// Tool call ID that triggered this permission request
3213    #[serde(skip_serializing_if = "Option::is_none")]
3214    pub tool_call_id: Option<String>,
3215    /// URL to be fetched
3216    pub url: String,
3217}
3218
3219/// Memory operation permission request
3220#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3221#[serde(rename_all = "camelCase")]
3222pub struct PermissionRequestMemory {
3223    /// Whether this is a store or vote memory operation
3224    #[serde(skip_serializing_if = "Option::is_none")]
3225    pub action: Option<PermissionRequestMemoryAction>,
3226    /// Source references for the stored fact (store only)
3227    #[serde(skip_serializing_if = "Option::is_none")]
3228    pub citations: Option<String>,
3229    /// Vote direction (vote only)
3230    #[serde(skip_serializing_if = "Option::is_none")]
3231    pub direction: Option<PermissionRequestMemoryDirection>,
3232    /// The fact being stored or voted on
3233    pub fact: String,
3234    /// Permission kind discriminator
3235    pub kind: PermissionRequestMemoryKind,
3236    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3237    #[serde(skip_serializing_if = "Option::is_none")]
3238    pub managed_approval_required: Option<bool>,
3239    /// Reason for the vote (vote only)
3240    #[serde(skip_serializing_if = "Option::is_none")]
3241    pub reason: Option<String>,
3242    /// Topic or subject of the memory (store only)
3243    #[serde(skip_serializing_if = "Option::is_none")]
3244    pub subject: Option<String>,
3245    /// Tool call ID that triggered this permission request
3246    #[serde(skip_serializing_if = "Option::is_none")]
3247    pub tool_call_id: Option<String>,
3248}
3249
3250/// Custom tool invocation permission request
3251#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3252#[serde(rename_all = "camelCase")]
3253pub struct PermissionRequestCustomTool {
3254    /// Arguments to pass to the custom tool
3255    #[serde(skip_serializing_if = "Option::is_none")]
3256    pub args: Option<serde_json::Value>,
3257    /// Permission kind discriminator
3258    pub kind: PermissionRequestCustomToolKind,
3259    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3260    #[serde(skip_serializing_if = "Option::is_none")]
3261    pub managed_approval_required: Option<bool>,
3262    /// Tool call ID that triggered this permission request
3263    #[serde(skip_serializing_if = "Option::is_none")]
3264    pub tool_call_id: Option<String>,
3265    /// Description of what the custom tool does
3266    pub tool_description: String,
3267    /// Name of the custom tool
3268    pub tool_name: String,
3269}
3270
3271/// Hook confirmation permission request
3272#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3273#[serde(rename_all = "camelCase")]
3274pub struct PermissionRequestHook {
3275    /// Optional message from the hook explaining why confirmation is needed
3276    #[serde(skip_serializing_if = "Option::is_none")]
3277    pub hook_message: Option<String>,
3278    /// Permission kind discriminator
3279    pub kind: PermissionRequestHookKind,
3280    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3281    #[serde(skip_serializing_if = "Option::is_none")]
3282    pub managed_approval_required: Option<bool>,
3283    /// Arguments of the tool call being gated
3284    #[serde(skip_serializing_if = "Option::is_none")]
3285    pub tool_args: Option<serde_json::Value>,
3286    /// Tool call ID that triggered this permission request
3287    #[serde(skip_serializing_if = "Option::is_none")]
3288    pub tool_call_id: Option<String>,
3289    /// Name of the tool the hook is gating
3290    pub tool_name: String,
3291}
3292
3293/// Extension management permission request
3294#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3295#[serde(rename_all = "camelCase")]
3296pub struct PermissionRequestExtensionManagement {
3297    /// Name of the extension being managed
3298    #[serde(skip_serializing_if = "Option::is_none")]
3299    pub extension_name: Option<String>,
3300    /// Permission kind discriminator
3301    pub kind: PermissionRequestExtensionManagementKind,
3302    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3303    #[serde(skip_serializing_if = "Option::is_none")]
3304    pub managed_approval_required: Option<bool>,
3305    /// The extension management operation (scaffold, reload)
3306    pub operation: String,
3307    /// Tool call ID that triggered this permission request
3308    #[serde(skip_serializing_if = "Option::is_none")]
3309    pub tool_call_id: Option<String>,
3310}
3311
3312/// A declared phase shown in a factory permission prompt.
3313#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3314#[serde(rename_all = "camelCase")]
3315pub struct FactoryPermissionPhase {
3316    /// Optional phase detail
3317    #[serde(skip_serializing_if = "Option::is_none")]
3318    pub detail: Option<String>,
3319    /// Phase title
3320    pub title: String,
3321}
3322
3323/// Factory run or authoring permission request
3324#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3325#[serde(rename_all = "camelCase")]
3326pub struct PermissionRequestFactory {
3327    /// Canonical key used for scoped factory approvals
3328    pub approval_key: String,
3329    /// Whether this factory is eligible for persistent approval
3330    pub can_persist_approval: bool,
3331    #[serde(skip_serializing_if = "Option::is_none")]
3332    pub declared_max_ai_credits: Option<f64>,
3333    #[serde(skip_serializing_if = "Option::is_none")]
3334    pub declared_max_concurrent_subagents: Option<i64>,
3335    #[serde(skip_serializing_if = "Option::is_none")]
3336    pub declared_max_total_subagents: Option<i64>,
3337    #[serde(skip_serializing_if = "Option::is_none")]
3338    pub declared_timeout_seconds: Option<f64>,
3339    /// Factory description
3340    pub description: String,
3341    /// Permission kind discriminator
3342    pub kind: PermissionRequestFactoryKind,
3343    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3344    #[serde(skip_serializing_if = "Option::is_none")]
3345    pub managed_approval_required: Option<bool>,
3346    /// Effective AI-credit limit; omitted means unlimited
3347    #[serde(skip_serializing_if = "Option::is_none")]
3348    pub max_ai_credits: Option<f64>,
3349    /// Effective concurrent-subagent limit; omitted means unlimited
3350    #[serde(skip_serializing_if = "Option::is_none")]
3351    pub max_concurrent_subagents: Option<i64>,
3352    /// Effective total-subagent limit; omitted means unlimited
3353    #[serde(skip_serializing_if = "Option::is_none")]
3354    pub max_total_subagents: Option<i64>,
3355    /// Factory name
3356    pub name: String,
3357    /// Factory operation, either run or author
3358    pub operation: FactoryPermissionOperation,
3359    /// Declared factory phases
3360    pub phases: Vec<FactoryPermissionPhase>,
3361    /// Effective active-time limit in seconds; omitted means unlimited
3362    #[serde(skip_serializing_if = "Option::is_none")]
3363    pub timeout_seconds: Option<f64>,
3364    /// Tool call ID that triggered this permission request
3365    #[serde(skip_serializing_if = "Option::is_none")]
3366    pub tool_call_id: Option<String>,
3367}
3368
3369/// Extension permission access request
3370#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3371#[serde(rename_all = "camelCase")]
3372pub struct PermissionRequestExtensionPermissionAccess {
3373    /// Capabilities the extension is requesting
3374    pub capabilities: Vec<String>,
3375    /// Name of the extension requesting permission access
3376    pub extension_name: String,
3377    /// Permission kind discriminator
3378    pub kind: PermissionRequestExtensionPermissionAccessKind,
3379    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
3380    #[serde(skip_serializing_if = "Option::is_none")]
3381    pub managed_approval_required: Option<bool>,
3382    /// Tool call ID that triggered this permission request
3383    #[serde(skip_serializing_if = "Option::is_none")]
3384    pub tool_call_id: Option<String>,
3385}
3386
3387/// 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.
3388///
3389/// <div class="warning">
3390///
3391/// **Experimental.** This type is part of an experimental wire-protocol surface
3392/// and may change or be removed in future SDK or CLI releases.
3393///
3394/// </div>
3395#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3396#[serde(rename_all = "camelCase")]
3397pub struct PermissionAutoApproval {
3398    /// Classified cause of an `error` recommendation. Absent for every other recommendation.
3399    #[serde(skip_serializing_if = "Option::is_none")]
3400    pub failure_reason: Option<AutoApprovalJudgeFailureReason>,
3401    /// 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.
3402    #[serde(skip_serializing_if = "Option::is_none")]
3403    pub model: Option<String>,
3404    /// Human-readable reason for the judge's recommendation, when available.
3405    #[serde(skip_serializing_if = "Option::is_none")]
3406    pub reason: Option<String>,
3407    /// The auto-approval safety judge's outcome for this request.
3408    pub recommendation: AutoApprovalRecommendation,
3409}
3410
3411/// Shell command permission prompt
3412#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3413#[serde(rename_all = "camelCase")]
3414pub struct PermissionPromptRequestCommands {
3415    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3416    ///
3417    /// <div class="warning">
3418    ///
3419    /// **Experimental.** This type is part of an experimental wire-protocol surface
3420    /// and may change or be removed in future SDK or CLI releases.
3421    ///
3422    /// </div>
3423    #[serde(skip_serializing_if = "Option::is_none")]
3424    pub auto_approval: Option<PermissionAutoApproval>,
3425    /// Whether the UI can offer session-wide approval for this command pattern
3426    pub can_offer_session_approval: bool,
3427    /// Command identifiers covered by this approval prompt
3428    pub command_identifiers: Vec<String>,
3429    /// The complete shell command text to be executed
3430    pub full_command_text: String,
3431    /// Human-readable description of what the command intends to do
3432    pub intention: String,
3433    /// Prompt kind discriminator
3434    pub kind: PermissionPromptRequestCommandsKind,
3435    /// Whether managed policy requires a human response and forbids host auto-approval
3436    #[serde(skip_serializing_if = "Option::is_none")]
3437    pub managed_approval_required: Option<bool>,
3438    /// Tool call ID that triggered this permission request
3439    #[serde(skip_serializing_if = "Option::is_none")]
3440    pub tool_call_id: Option<String>,
3441    /// Optional warning message about risks of running this command
3442    #[serde(skip_serializing_if = "Option::is_none")]
3443    pub warning: Option<String>,
3444}
3445
3446/// File write permission prompt
3447#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3448#[serde(rename_all = "camelCase")]
3449pub struct PermissionPromptRequestWrite {
3450    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3451    ///
3452    /// <div class="warning">
3453    ///
3454    /// **Experimental.** This type is part of an experimental wire-protocol surface
3455    /// and may change or be removed in future SDK or CLI releases.
3456    ///
3457    /// </div>
3458    #[serde(skip_serializing_if = "Option::is_none")]
3459    pub auto_approval: Option<PermissionAutoApproval>,
3460    /// Whether the UI can offer session-wide approval for file write operations
3461    pub can_offer_session_approval: bool,
3462    /// Unified diff showing the proposed changes
3463    pub diff: String,
3464    /// Path of the file being written to
3465    pub file_name: String,
3466    /// Human-readable description of the intended file change
3467    pub intention: String,
3468    /// Prompt kind discriminator
3469    pub kind: PermissionPromptRequestWriteKind,
3470    /// Whether managed policy requires a human response and forbids host auto-approval
3471    #[serde(skip_serializing_if = "Option::is_none")]
3472    pub managed_approval_required: Option<bool>,
3473    /// Complete new file contents for newly created files
3474    #[serde(skip_serializing_if = "Option::is_none")]
3475    pub new_file_contents: Option<String>,
3476    /// Tool call ID that triggered this permission request
3477    #[serde(skip_serializing_if = "Option::is_none")]
3478    pub tool_call_id: Option<String>,
3479}
3480
3481/// File read permission prompt
3482#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3483#[serde(rename_all = "camelCase")]
3484pub struct PermissionPromptRequestRead {
3485    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3486    ///
3487    /// <div class="warning">
3488    ///
3489    /// **Experimental.** This type is part of an experimental wire-protocol surface
3490    /// and may change or be removed in future SDK or CLI releases.
3491    ///
3492    /// </div>
3493    #[serde(skip_serializing_if = "Option::is_none")]
3494    pub auto_approval: Option<PermissionAutoApproval>,
3495    /// Human-readable description of why the file is being read
3496    pub intention: String,
3497    /// Prompt kind discriminator
3498    pub kind: PermissionPromptRequestReadKind,
3499    /// Whether managed policy requires a human response and forbids host auto-approval
3500    #[serde(skip_serializing_if = "Option::is_none")]
3501    pub managed_approval_required: Option<bool>,
3502    /// Path of the file or directory being read
3503    pub path: String,
3504    /// Tool call ID that triggered this permission request
3505    #[serde(skip_serializing_if = "Option::is_none")]
3506    pub tool_call_id: Option<String>,
3507}
3508
3509/// MCP tool invocation permission prompt
3510#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3511#[serde(rename_all = "camelCase")]
3512pub struct PermissionPromptRequestMcp {
3513    /// Arguments to pass to the MCP tool
3514    #[serde(skip_serializing_if = "Option::is_none")]
3515    pub args: Option<serde_json::Value>,
3516    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3517    ///
3518    /// <div class="warning">
3519    ///
3520    /// **Experimental.** This type is part of an experimental wire-protocol surface
3521    /// and may change or be removed in future SDK or CLI releases.
3522    ///
3523    /// </div>
3524    #[serde(skip_serializing_if = "Option::is_none")]
3525    pub auto_approval: Option<PermissionAutoApproval>,
3526    /// Prompt kind discriminator
3527    pub kind: PermissionPromptRequestMcpKind,
3528    /// Name of the MCP server providing the tool
3529    pub server_name: String,
3530    /// Tool call ID that triggered this permission request
3531    #[serde(skip_serializing_if = "Option::is_none")]
3532    pub tool_call_id: Option<String>,
3533    /// Internal name of the MCP tool
3534    pub tool_name: String,
3535    /// Human-readable title of the MCP tool
3536    pub tool_title: String,
3537}
3538
3539/// URL access permission prompt
3540#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3541#[serde(rename_all = "camelCase")]
3542pub struct PermissionPromptRequestUrl {
3543    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3544    ///
3545    /// <div class="warning">
3546    ///
3547    /// **Experimental.** This type is part of an experimental wire-protocol surface
3548    /// and may change or be removed in future SDK or CLI releases.
3549    ///
3550    /// </div>
3551    #[serde(skip_serializing_if = "Option::is_none")]
3552    pub auto_approval: Option<PermissionAutoApproval>,
3553    /// Human-readable description of why the URL is being accessed
3554    pub intention: String,
3555    /// Prompt kind discriminator
3556    pub kind: PermissionPromptRequestUrlKind,
3557    /// Whether managed policy requires a human response and forbids host auto-approval
3558    #[serde(skip_serializing_if = "Option::is_none")]
3559    pub managed_approval_required: Option<bool>,
3560    /// Immediately preceding URL when this prompt is for a redirect target
3561    #[serde(skip_serializing_if = "Option::is_none")]
3562    pub redirected_from: Option<String>,
3563    /// 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.
3564    #[serde(skip_serializing_if = "Option::is_none")]
3565    pub request_sandbox_bypass: Option<bool>,
3566    /// Model-provided justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
3567    #[serde(skip_serializing_if = "Option::is_none")]
3568    pub request_sandbox_bypass_reason: Option<String>,
3569    /// Tool call ID that triggered this permission request
3570    #[serde(skip_serializing_if = "Option::is_none")]
3571    pub tool_call_id: Option<String>,
3572    /// URL to be fetched
3573    pub url: String,
3574}
3575
3576/// Memory operation permission prompt
3577#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3578#[serde(rename_all = "camelCase")]
3579pub struct PermissionPromptRequestMemory {
3580    /// Whether this is a store or vote memory operation
3581    #[serde(skip_serializing_if = "Option::is_none")]
3582    pub action: Option<PermissionRequestMemoryAction>,
3583    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3584    ///
3585    /// <div class="warning">
3586    ///
3587    /// **Experimental.** This type is part of an experimental wire-protocol surface
3588    /// and may change or be removed in future SDK or CLI releases.
3589    ///
3590    /// </div>
3591    #[serde(skip_serializing_if = "Option::is_none")]
3592    pub auto_approval: Option<PermissionAutoApproval>,
3593    /// Source references for the stored fact (store only)
3594    #[serde(skip_serializing_if = "Option::is_none")]
3595    pub citations: Option<String>,
3596    /// Vote direction (vote only)
3597    #[serde(skip_serializing_if = "Option::is_none")]
3598    pub direction: Option<PermissionRequestMemoryDirection>,
3599    /// The fact being stored or voted on
3600    pub fact: String,
3601    /// Prompt kind discriminator
3602    pub kind: PermissionPromptRequestMemoryKind,
3603    /// Reason for the vote (vote only)
3604    #[serde(skip_serializing_if = "Option::is_none")]
3605    pub reason: Option<String>,
3606    /// Topic or subject of the memory (store only)
3607    #[serde(skip_serializing_if = "Option::is_none")]
3608    pub subject: Option<String>,
3609    /// Tool call ID that triggered this permission request
3610    #[serde(skip_serializing_if = "Option::is_none")]
3611    pub tool_call_id: Option<String>,
3612}
3613
3614/// Custom tool invocation permission prompt
3615#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3616#[serde(rename_all = "camelCase")]
3617pub struct PermissionPromptRequestCustomTool {
3618    /// Arguments to pass to the custom tool
3619    #[serde(skip_serializing_if = "Option::is_none")]
3620    pub args: Option<serde_json::Value>,
3621    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3622    ///
3623    /// <div class="warning">
3624    ///
3625    /// **Experimental.** This type is part of an experimental wire-protocol surface
3626    /// and may change or be removed in future SDK or CLI releases.
3627    ///
3628    /// </div>
3629    #[serde(skip_serializing_if = "Option::is_none")]
3630    pub auto_approval: Option<PermissionAutoApproval>,
3631    /// Prompt kind discriminator
3632    pub kind: PermissionPromptRequestCustomToolKind,
3633    /// Tool call ID that triggered this permission request
3634    #[serde(skip_serializing_if = "Option::is_none")]
3635    pub tool_call_id: Option<String>,
3636    /// Description of what the custom tool does
3637    pub tool_description: String,
3638    /// Name of the custom tool
3639    pub tool_name: String,
3640}
3641
3642/// Path access permission prompt
3643#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3644#[serde(rename_all = "camelCase")]
3645pub struct PermissionPromptRequestPath {
3646    /// Underlying permission kind that needs path approval
3647    pub access_kind: PermissionPromptRequestPathAccessKind,
3648    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3649    ///
3650    /// <div class="warning">
3651    ///
3652    /// **Experimental.** This type is part of an experimental wire-protocol surface
3653    /// and may change or be removed in future SDK or CLI releases.
3654    ///
3655    /// </div>
3656    #[serde(skip_serializing_if = "Option::is_none")]
3657    pub auto_approval: Option<PermissionAutoApproval>,
3658    /// Prompt kind discriminator
3659    pub kind: PermissionPromptRequestPathKind,
3660    /// File paths that require explicit approval
3661    pub paths: Vec<String>,
3662    /// Tool call ID that triggered this permission request
3663    #[serde(skip_serializing_if = "Option::is_none")]
3664    pub tool_call_id: Option<String>,
3665}
3666
3667/// Hook confirmation permission prompt
3668#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3669#[serde(rename_all = "camelCase")]
3670pub struct PermissionPromptRequestHook {
3671    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3672    ///
3673    /// <div class="warning">
3674    ///
3675    /// **Experimental.** This type is part of an experimental wire-protocol surface
3676    /// and may change or be removed in future SDK or CLI releases.
3677    ///
3678    /// </div>
3679    #[serde(skip_serializing_if = "Option::is_none")]
3680    pub auto_approval: Option<PermissionAutoApproval>,
3681    /// Optional message from the hook explaining why confirmation is needed
3682    #[serde(skip_serializing_if = "Option::is_none")]
3683    pub hook_message: Option<String>,
3684    /// Prompt kind discriminator
3685    pub kind: PermissionPromptRequestHookKind,
3686    /// Arguments of the tool call being gated
3687    #[serde(skip_serializing_if = "Option::is_none")]
3688    pub tool_args: Option<serde_json::Value>,
3689    /// Tool call ID that triggered this permission request
3690    #[serde(skip_serializing_if = "Option::is_none")]
3691    pub tool_call_id: Option<String>,
3692    /// Name of the tool the hook is gating
3693    pub tool_name: String,
3694}
3695
3696/// Extension management permission prompt
3697#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3698#[serde(rename_all = "camelCase")]
3699pub struct PermissionPromptRequestExtensionManagement {
3700    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3701    ///
3702    /// <div class="warning">
3703    ///
3704    /// **Experimental.** This type is part of an experimental wire-protocol surface
3705    /// and may change or be removed in future SDK or CLI releases.
3706    ///
3707    /// </div>
3708    #[serde(skip_serializing_if = "Option::is_none")]
3709    pub auto_approval: Option<PermissionAutoApproval>,
3710    /// Name of the extension being managed
3711    #[serde(skip_serializing_if = "Option::is_none")]
3712    pub extension_name: Option<String>,
3713    /// Prompt kind discriminator
3714    pub kind: PermissionPromptRequestExtensionManagementKind,
3715    /// The extension management operation (scaffold, reload)
3716    pub operation: String,
3717    /// Tool call ID that triggered this permission request
3718    #[serde(skip_serializing_if = "Option::is_none")]
3719    pub tool_call_id: Option<String>,
3720}
3721
3722/// Factory run or authoring permission prompt
3723#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3724#[serde(rename_all = "camelCase")]
3725pub struct PermissionPromptRequestFactory {
3726    /// Canonical key used for scoped factory approvals
3727    pub approval_key: String,
3728    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3729    ///
3730    /// <div class="warning">
3731    ///
3732    /// **Experimental.** This type is part of an experimental wire-protocol surface
3733    /// and may change or be removed in future SDK or CLI releases.
3734    ///
3735    /// </div>
3736    #[serde(skip_serializing_if = "Option::is_none")]
3737    pub auto_approval: Option<PermissionAutoApproval>,
3738    /// Whether this factory is eligible for persistent approval
3739    pub can_persist_approval: bool,
3740    #[serde(skip_serializing_if = "Option::is_none")]
3741    pub declared_max_ai_credits: Option<f64>,
3742    #[serde(skip_serializing_if = "Option::is_none")]
3743    pub declared_max_concurrent_subagents: Option<i64>,
3744    #[serde(skip_serializing_if = "Option::is_none")]
3745    pub declared_max_total_subagents: Option<i64>,
3746    #[serde(skip_serializing_if = "Option::is_none")]
3747    pub declared_timeout_seconds: Option<f64>,
3748    /// Factory description
3749    pub description: String,
3750    /// Prompt kind discriminator
3751    pub kind: PermissionPromptRequestFactoryKind,
3752    /// Whether managed policy requires a human response and forbids host auto-approval
3753    #[serde(skip_serializing_if = "Option::is_none")]
3754    pub managed_approval_required: Option<bool>,
3755    /// Effective AI-credit limit; omitted means unlimited
3756    #[serde(skip_serializing_if = "Option::is_none")]
3757    pub max_ai_credits: Option<f64>,
3758    /// Effective concurrent-subagent limit; omitted means unlimited
3759    #[serde(skip_serializing_if = "Option::is_none")]
3760    pub max_concurrent_subagents: Option<i64>,
3761    /// Effective total-subagent limit; omitted means unlimited
3762    #[serde(skip_serializing_if = "Option::is_none")]
3763    pub max_total_subagents: Option<i64>,
3764    /// Factory name
3765    pub name: String,
3766    /// Factory operation, either run or author
3767    pub operation: FactoryPermissionOperation,
3768    /// Declared factory phases
3769    pub phases: Vec<FactoryPermissionPhase>,
3770    /// Effective active-time limit in seconds; omitted means unlimited
3771    #[serde(skip_serializing_if = "Option::is_none")]
3772    pub timeout_seconds: Option<f64>,
3773    /// Tool call ID that triggered this permission request
3774    #[serde(skip_serializing_if = "Option::is_none")]
3775    pub tool_call_id: Option<String>,
3776}
3777
3778/// Extension permission access prompt
3779#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3780#[serde(rename_all = "camelCase")]
3781pub struct PermissionPromptRequestExtensionPermissionAccess {
3782    /// Auto-approval judge information for this request; present only when auto mode is enabled.
3783    ///
3784    /// <div class="warning">
3785    ///
3786    /// **Experimental.** This type is part of an experimental wire-protocol surface
3787    /// and may change or be removed in future SDK or CLI releases.
3788    ///
3789    /// </div>
3790    #[serde(skip_serializing_if = "Option::is_none")]
3791    pub auto_approval: Option<PermissionAutoApproval>,
3792    /// Capabilities the extension is requesting
3793    pub capabilities: Vec<String>,
3794    /// Name of the extension requesting permission access
3795    pub extension_name: String,
3796    /// Prompt kind discriminator
3797    pub kind: PermissionPromptRequestExtensionPermissionAccessKind,
3798    /// Tool call ID that triggered this permission request
3799    #[serde(skip_serializing_if = "Option::is_none")]
3800    pub tool_call_id: Option<String>,
3801}
3802
3803/// Session event "permission.requested". Permission request notification requiring client approval with request details
3804#[derive(Debug, Clone, Serialize, Deserialize)]
3805#[serde(rename_all = "camelCase")]
3806pub struct PermissionRequestedData {
3807    /// Details of the permission being requested
3808    pub permission_request: PermissionRequest,
3809    /// Derived user-facing permission prompt details for UI consumers
3810    #[serde(skip_serializing_if = "Option::is_none")]
3811    pub prompt_request: Option<PermissionPromptRequest>,
3812    /// Unique identifier for this permission request; used to respond via session.respondToPermission()
3813    pub request_id: RequestId,
3814    /// When true, this permission was already resolved by a permissionRequest hook and requires no client action
3815    #[serde(skip_serializing_if = "Option::is_none")]
3816    pub resolved_by_hook: Option<bool>,
3817    /// Neutral risk metadata supplied by the tool host. Consumers may display this value but must not use it to bypass the permission decision.
3818    #[serde(skip_serializing_if = "Option::is_none")]
3819    pub risk_assessment: Option<serde_json::Value>,
3820}
3821
3822/// Permission response variant indicating the request was approved without persisting an approval rule.
3823#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3824#[serde(rename_all = "camelCase")]
3825pub struct PermissionApproved {
3826    /// The permission request was approved
3827    pub kind: PermissionApprovedKind,
3828}
3829
3830/// Session-scoped tool-approval rule for specific shell command identifiers.
3831#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3832#[serde(rename_all = "camelCase")]
3833pub struct UserToolSessionApprovalCommands {
3834    /// Command identifiers approved by the user
3835    pub command_identifiers: Vec<String>,
3836    /// Command approval kind
3837    pub kind: UserToolSessionApprovalCommandsKind,
3838}
3839
3840/// Session-scoped tool-approval rule for read-only filesystem operations.
3841#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3842#[serde(rename_all = "camelCase")]
3843pub struct UserToolSessionApprovalRead {
3844    /// Read approval kind
3845    pub kind: UserToolSessionApprovalReadKind,
3846}
3847
3848/// Session-scoped tool-approval rule for filesystem write operations.
3849#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3850#[serde(rename_all = "camelCase")]
3851pub struct UserToolSessionApprovalWrite {
3852    /// Write approval kind
3853    pub kind: UserToolSessionApprovalWriteKind,
3854}
3855
3856/// Session-scoped tool-approval rule for an MCP server tool, or all tools on the server when `toolName` is null.
3857#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3858#[serde(rename_all = "camelCase")]
3859pub struct UserToolSessionApprovalMcp {
3860    /// MCP tool approval kind
3861    pub kind: UserToolSessionApprovalMcpKind,
3862    /// MCP server name
3863    pub server_name: String,
3864    /// Optional MCP tool name, or null for all tools on the server
3865    pub tool_name: Option<String>,
3866}
3867
3868/// Session-scoped tool-approval rule for writes to long-term memory.
3869#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3870#[serde(rename_all = "camelCase")]
3871pub struct UserToolSessionApprovalMemory {
3872    /// Memory approval kind
3873    pub kind: UserToolSessionApprovalMemoryKind,
3874}
3875
3876/// Session-scoped tool-approval rule for a custom tool, keyed by tool name.
3877#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3878#[serde(rename_all = "camelCase")]
3879pub struct UserToolSessionApprovalCustomTool {
3880    /// Custom tool approval kind
3881    pub kind: UserToolSessionApprovalCustomToolKind,
3882    /// Custom tool name
3883    pub tool_name: String,
3884}
3885
3886/// Session-scoped tool-approval rule for extension-management operations, optionally narrowed by operation.
3887#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3888#[serde(rename_all = "camelCase")]
3889pub struct UserToolSessionApprovalExtensionManagement {
3890    /// Extension management approval kind
3891    pub kind: UserToolSessionApprovalExtensionManagementKind,
3892    /// Optional operation identifier
3893    #[serde(skip_serializing_if = "Option::is_none")]
3894    pub operation: Option<String>,
3895}
3896
3897/// Session-scoped factory approval, optionally narrowed by approval key.
3898#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3899#[serde(rename_all = "camelCase")]
3900pub struct UserToolSessionApprovalFactory {
3901    /// Optional factory operation name or canonical approval key
3902    #[serde(skip_serializing_if = "Option::is_none")]
3903    pub approval_key: Option<String>,
3904    /// Factory approval kind
3905    pub kind: UserToolSessionApprovalFactoryKind,
3906}
3907
3908/// Session-scoped tool-approval rule for an extension's permission-gated capability access, keyed by extension name.
3909#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3910#[serde(rename_all = "camelCase")]
3911pub struct UserToolSessionApprovalExtensionPermissionAccess {
3912    /// Extension name
3913    pub extension_name: String,
3914    /// Extension permission access approval kind
3915    pub kind: UserToolSessionApprovalExtensionPermissionAccessKind,
3916}
3917
3918/// Permission response variant that approves a request and remembers the provided approval for the rest of the session.
3919#[derive(Debug, Clone, Serialize, Deserialize)]
3920#[serde(rename_all = "camelCase")]
3921pub struct PermissionApprovedForSession {
3922    /// The approval to add as a session-scoped rule
3923    pub approval: UserToolSessionApproval,
3924    /// Approved and remembered for the rest of the session
3925    pub kind: PermissionApprovedForSessionKind,
3926}
3927
3928/// Permission response variant that approves a request and persists the provided approval to a project location key.
3929#[derive(Debug, Clone, Serialize, Deserialize)]
3930#[serde(rename_all = "camelCase")]
3931pub struct PermissionApprovedForLocation {
3932    /// The approval to persist for this location
3933    pub approval: UserToolSessionApproval,
3934    /// Approved and persisted for this project location
3935    pub kind: PermissionApprovedForLocationKind,
3936    /// The location key (git root or cwd) to persist the approval to
3937    pub location_key: String,
3938}
3939
3940/// Permission response variant indicating the request was cancelled before use, with an optional reason.
3941#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3942#[serde(rename_all = "camelCase")]
3943pub struct PermissionCancelled {
3944    /// The permission request was cancelled before a response was used
3945    pub kind: PermissionCancelledKind,
3946    /// Optional explanation of why the request was cancelled
3947    #[serde(skip_serializing_if = "Option::is_none")]
3948    pub reason: Option<String>,
3949}
3950
3951/// A permission approval or denial rule matched against a tool request, identified by a rule kind with an optional argument value.
3952#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3953#[serde(rename_all = "camelCase")]
3954pub struct PermissionRule {
3955    /// Argument value matched against the request, or null when the rule kind has no argument (e.g. 'read', 'write', 'memory').
3956    pub argument: Option<String>,
3957    /// The rule kind, such as Shell or GitHubMCP
3958    pub kind: String,
3959}
3960
3961/// Permission response variant denied because matching approval rules explicitly blocked the request.
3962#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3963#[serde(rename_all = "camelCase")]
3964pub struct PermissionDeniedByRules {
3965    /// Denied because approval rules explicitly blocked it
3966    pub kind: PermissionDeniedByRulesKind,
3967    /// Rules that denied the request
3968    pub rules: Vec<PermissionRule>,
3969}
3970
3971/// Permission response variant denied because no approval rule matched and user confirmation was unavailable.
3972#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3973#[serde(rename_all = "camelCase")]
3974pub struct PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
3975    /// Denied because no approval rule matched and user confirmation was unavailable
3976    pub kind: PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind,
3977}
3978
3979/// Permission response variant denied in an interactive user prompt, with optional feedback and force-reject flag.
3980#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3981#[serde(rename_all = "camelCase")]
3982pub struct PermissionDeniedInteractivelyByUser {
3983    /// Optional feedback from the user explaining the denial
3984    #[serde(skip_serializing_if = "Option::is_none")]
3985    pub feedback: Option<String>,
3986    /// Whether to force-reject the current agent turn
3987    #[serde(skip_serializing_if = "Option::is_none")]
3988    pub force_reject: Option<bool>,
3989    /// Denied by the user during an interactive prompt
3990    pub kind: PermissionDeniedInteractivelyByUserKind,
3991}
3992
3993/// Permission response variant denying a path under content exclusion policy, with the path and message.
3994#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3995#[serde(rename_all = "camelCase")]
3996pub struct PermissionDeniedByContentExclusionPolicy {
3997    /// Denied by the organization's content exclusion policy
3998    pub kind: PermissionDeniedByContentExclusionPolicyKind,
3999    /// Human-readable explanation of why the path was excluded
4000    pub message: String,
4001    /// File path that triggered the exclusion
4002    pub path: String,
4003}
4004
4005/// Permission response variant denied by a permission-request hook, with optional message and interrupt flag.
4006#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4007#[serde(rename_all = "camelCase")]
4008pub struct PermissionDeniedByPermissionRequestHook {
4009    /// Whether to interrupt the current agent turn
4010    #[serde(skip_serializing_if = "Option::is_none")]
4011    pub interrupt: Option<bool>,
4012    /// Denied by a permission request hook registered by an extension or plugin
4013    pub kind: PermissionDeniedByPermissionRequestHookKind,
4014    /// Optional message from the hook explaining the denial
4015    #[serde(skip_serializing_if = "Option::is_none")]
4016    pub message: Option<String>,
4017}
4018
4019/// Session event "permission.completed". Permission request completion notification signaling UI dismissal
4020#[derive(Debug, Clone, Serialize, Deserialize)]
4021#[serde(rename_all = "camelCase")]
4022pub struct PermissionCompletedData {
4023    /// Request ID of the resolved permission request; clients should dismiss any UI for this request
4024    pub request_id: RequestId,
4025    /// The result of the permission request
4026    pub result: PermissionResult,
4027    /// Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
4028    #[serde(skip_serializing_if = "Option::is_none")]
4029    pub tool_call_id: Option<String>,
4030}
4031
4032/// Session event "user_input.requested". User input request notification with question and optional predefined choices
4033#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4034#[serde(rename_all = "camelCase")]
4035pub struct UserInputRequestedData {
4036    /// Whether the user can provide a free-form text response in addition to predefined choices
4037    #[serde(skip_serializing_if = "Option::is_none")]
4038    pub allow_freeform: Option<bool>,
4039    /// Predefined choices for the user to select from, if applicable
4040    #[serde(skip_serializing_if = "Option::is_none")]
4041    pub choices: Option<Vec<String>>,
4042    /// The question or prompt to present to the user
4043    pub question: String,
4044    /// Unique identifier for this input request; used to respond via session.respondToUserInput()
4045    pub request_id: RequestId,
4046    /// The LLM-assigned tool call ID that triggered this request; used by remote UIs to correlate responses
4047    #[serde(skip_serializing_if = "Option::is_none")]
4048    pub tool_call_id: Option<String>,
4049}
4050
4051/// Session event "user_input.completed". User input request completion with the user's response
4052#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4053#[serde(rename_all = "camelCase")]
4054pub struct UserInputCompletedData {
4055    /// The user's answer to the input request
4056    #[serde(skip_serializing_if = "Option::is_none")]
4057    pub answer: Option<String>,
4058    /// Request ID of the resolved user input request; clients should dismiss any UI for this request
4059    pub request_id: RequestId,
4060    /// Whether the answer was typed as free-form text rather than selected from choices
4061    #[serde(skip_serializing_if = "Option::is_none")]
4062    pub was_freeform: Option<bool>,
4063}
4064
4065/// JSON Schema describing the form fields to present to the user (form mode only)
4066#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4067#[serde(rename_all = "camelCase")]
4068pub struct ElicitationRequestedSchema {
4069    /// Form field definitions, keyed by field name
4070    pub properties: HashMap<String, serde_json::Value>,
4071    /// List of required field names
4072    #[serde(skip_serializing_if = "Option::is_none")]
4073    pub required: Option<Vec<String>>,
4074    /// Schema type indicator (always 'object')
4075    pub r#type: ElicitationRequestedSchemaType,
4076}
4077
4078/// Session event "elicitation.requested". Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
4079#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4080#[serde(rename_all = "camelCase")]
4081pub struct ElicitationRequestedData {
4082    /// The source that initiated the request (MCP server name, or absent for agent-initiated)
4083    #[serde(skip_serializing_if = "Option::is_none")]
4084    pub elicitation_source: Option<String>,
4085    /// Message describing what information is needed from the user
4086    pub message: String,
4087    /// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
4088    #[serde(skip_serializing_if = "Option::is_none")]
4089    pub mode: Option<ElicitationRequestedMode>,
4090    /// JSON Schema describing the form fields to present to the user (form mode only)
4091    #[serde(skip_serializing_if = "Option::is_none")]
4092    pub requested_schema: Option<ElicitationRequestedSchema>,
4093    /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation()
4094    pub request_id: RequestId,
4095    /// Tool call ID from the LLM completion; used to correlate with CompletionChunk.toolCall.id for remote UIs
4096    #[serde(skip_serializing_if = "Option::is_none")]
4097    pub tool_call_id: Option<String>,
4098    /// URL to open in the user's browser (url mode only)
4099    #[serde(skip_serializing_if = "Option::is_none")]
4100    pub url: Option<String>,
4101}
4102
4103/// Session event "elicitation.completed". Elicitation request completion with the user's response
4104#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4105#[serde(rename_all = "camelCase")]
4106pub struct ElicitationCompletedData {
4107    /// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
4108    #[serde(skip_serializing_if = "Option::is_none")]
4109    pub action: Option<ElicitationCompletedAction>,
4110    /// The submitted form data when action is 'accept'; keys match the requested schema fields
4111    #[serde(skip_serializing_if = "Option::is_none")]
4112    pub content: Option<HashMap<String, serde_json::Value>>,
4113    /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request
4114    pub request_id: RequestId,
4115}
4116
4117/// Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
4118#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4119#[serde(rename_all = "camelCase")]
4120pub struct SamplingRequestedData {
4121    /// The JSON-RPC request ID from the MCP protocol
4122    pub mcp_request_id: serde_json::Value,
4123    /// Unique identifier for this sampling request; used to respond via session.respondToSampling()
4124    pub request_id: RequestId,
4125    /// Name of the MCP server that initiated the sampling request
4126    pub server_name: String,
4127}
4128
4129/// Session event "sampling.completed". Sampling request completion notification signaling UI dismissal
4130#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4131#[serde(rename_all = "camelCase")]
4132pub struct SamplingCompletedData {
4133    /// Request ID of the resolved sampling request; clients should dismiss any UI for this request
4134    pub request_id: RequestId,
4135}
4136
4137/// Single HTTP header entry as a name/value pair.
4138#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4139#[serde(rename_all = "camelCase")]
4140pub struct HeaderEntry {
4141    /// HTTP response header name as observed by the runtime.
4142    pub name: String,
4143    /// HTTP response header value as observed by the runtime.
4144    pub value: String,
4145}
4146
4147/// Raw HTTP response details from the OAuth auth challenge, as observed by the runtime.
4148#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4149#[serde(rename_all = "camelCase")]
4150pub struct McpOauthHttpResponse {
4151    /// 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.
4152    #[serde(skip_serializing_if = "Option::is_none")]
4153    pub body: Option<String>,
4154    /// HTTP response headers as observed by the runtime. Order and casing are transport-dependent, and duplicate header names may appear multiple times.
4155    pub headers: Vec<HeaderEntry>,
4156    /// HTTP status code returned with the auth challenge.
4157    pub status_code: i32,
4158}
4159
4160/// Static OAuth client configuration, if the server specifies one
4161#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4162#[serde(rename_all = "camelCase")]
4163pub struct McpOauthRequiredStaticClientConfig {
4164    /// OAuth client ID for the server
4165    pub client_id: String,
4166    /// Optional OAuth client secret for confidential static clients, when the runtime can resolve one
4167    #[serde(skip_serializing_if = "Option::is_none")]
4168    pub client_secret: Option<String>,
4169    /// 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).
4170    #[serde(skip_serializing_if = "Option::is_none")]
4171    pub grant_type: Option<McpOauthRequiredStaticClientConfigGrantType>,
4172    /// Whether this is a public OAuth client
4173    #[serde(skip_serializing_if = "Option::is_none")]
4174    pub public_client: Option<bool>,
4175}
4176
4177/// OAuth WWW-Authenticate parameters parsed from an MCP auth challenge
4178#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4179#[serde(rename_all = "camelCase")]
4180pub struct McpOauthWWWAuthenticateParams {
4181    /// OAuth error from the WWW-Authenticate error parameter, if present
4182    #[serde(skip_serializing_if = "Option::is_none")]
4183    pub error: Option<String>,
4184    /// Protected resource metadata URL from the WWW-Authenticate resource_metadata parameter, if present
4185    #[serde(skip_serializing_if = "Option::is_none")]
4186    pub resource_metadata_url: Option<String>,
4187    /// Requested OAuth scopes from the WWW-Authenticate scope parameter, if present
4188    #[serde(skip_serializing_if = "Option::is_none")]
4189    pub scope: Option<String>,
4190}
4191
4192/// Session event "mcp.oauth_required". OAuth authentication request for an MCP server
4193#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4194#[serde(rename_all = "camelCase")]
4195pub struct McpOauthRequiredData {
4196    /// 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.
4197    #[serde(skip_serializing_if = "Option::is_none")]
4198    pub http_response: Option<McpOauthHttpResponse>,
4199    /// Why the runtime is requesting host-provided OAuth credentials.
4200    pub reason: McpOauthRequestReason,
4201    /// Unique identifier for this OAuth request; used to respond via session.mcp.oauth.handlePendingRequest
4202    pub request_id: RequestId,
4203    /// Raw OAuth protected-resource metadata document fetched for the MCP server, if available
4204    #[serde(skip_serializing_if = "Option::is_none")]
4205    pub resource_metadata: Option<String>,
4206    /// Display name of the MCP server that requires OAuth
4207    pub server_name: String,
4208    /// URL of the MCP server that requires OAuth
4209    pub server_url: String,
4210    /// Static OAuth client configuration, if the server specifies one
4211    #[serde(skip_serializing_if = "Option::is_none")]
4212    pub static_client_config: Option<McpOauthRequiredStaticClientConfig>,
4213    /// OAuth WWW-Authenticate parameters parsed from the auth challenge, if available
4214    #[serde(skip_serializing_if = "Option::is_none")]
4215    pub www_authenticate_params: Option<McpOauthWWWAuthenticateParams>,
4216}
4217
4218/// Session event "mcp.oauth_completed". MCP OAuth request completion notification
4219#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4220#[serde(rename_all = "camelCase")]
4221pub struct McpOauthCompletedData {
4222    /// How the pending OAuth request was completed
4223    pub outcome: McpOauthCompletionOutcome,
4224    /// Request ID of the resolved OAuth request
4225    pub request_id: RequestId,
4226}
4227
4228/// Session event "mcp.headers_refresh_required". Dynamic headers refresh request for a remote MCP server
4229#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4230#[serde(rename_all = "camelCase")]
4231pub struct McpHeadersRefreshRequiredData {
4232    /// Why dynamic headers are being requested.
4233    pub reason: McpHeadersRefreshRequiredReason,
4234    /// Unique identifier for this headers refresh request; used to respond via session.mcp.headers.handlePendingHeadersRefreshRequest()
4235    pub request_id: RequestId,
4236    /// Display name of the remote MCP server requesting headers
4237    pub server_name: String,
4238    /// URL of the remote MCP server requesting headers
4239    pub server_url: String,
4240}
4241
4242/// Session event "mcp.headers_refresh_completed". MCP headers refresh request completion notification
4243#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4244#[serde(rename_all = "camelCase")]
4245pub struct McpHeadersRefreshCompletedData {
4246    /// How the pending MCP headers refresh request resolved.
4247    pub outcome: McpHeadersRefreshCompletedOutcome,
4248    /// Request ID of the resolved headers refresh request
4249    pub request_id: RequestId,
4250}
4251
4252/// Session event "session.custom_notification". Opaque custom notification data. Consumers may branch on source and name, but payload semantics are source-defined.
4253#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4254#[serde(rename_all = "camelCase")]
4255pub struct SessionCustomNotificationData {
4256    /// Source-defined custom notification name
4257    pub name: String,
4258    /// Source-defined JSON payload for the custom notification
4259    pub payload: serde_json::Value,
4260    /// Namespace for the custom notification producer
4261    pub source: String,
4262    /// Optional source-defined string identifiers describing the payload subject
4263    #[serde(skip_serializing_if = "Option::is_none")]
4264    pub subject: Option<HashMap<String, String>>,
4265    /// Optional source-defined payload schema version
4266    #[serde(skip_serializing_if = "Option::is_none")]
4267    pub version: Option<i64>,
4268}
4269
4270/// Session event "external_tool.requested". External tool invocation request for client-side tool execution
4271#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4272#[serde(rename_all = "camelCase")]
4273pub struct ExternalToolRequestedData {
4274    /// Arguments to pass to the external tool
4275    #[serde(skip_serializing_if = "Option::is_none")]
4276    pub arguments: Option<serde_json::Value>,
4277    /// Unique identifier for this request; used to respond via session.respondToExternalTool()
4278    pub request_id: RequestId,
4279    /// Session ID that this external tool request belongs to
4280    pub session_id: SessionId,
4281    /// Tool call ID assigned to this external tool invocation
4282    pub tool_call_id: String,
4283    /// Name of the external tool to invoke
4284    pub tool_name: String,
4285    /// W3C Trace Context traceparent header for the execute_tool span
4286    #[serde(skip_serializing_if = "Option::is_none")]
4287    pub traceparent: Option<String>,
4288    /// W3C Trace Context tracestate header for the execute_tool span
4289    #[serde(skip_serializing_if = "Option::is_none")]
4290    pub tracestate: Option<String>,
4291    /// Active session working directory, when known.
4292    #[serde(skip_serializing_if = "Option::is_none")]
4293    pub working_directory: Option<String>,
4294}
4295
4296/// Session event "external_tool.completed". External tool completion notification signaling UI dismissal
4297#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4298#[serde(rename_all = "camelCase")]
4299pub struct ExternalToolCompletedData {
4300    /// Request ID of the resolved external tool request; clients should dismiss any UI for this request
4301    pub request_id: RequestId,
4302}
4303
4304/// Session event "command.queued". Queued slash command dispatch request for client execution
4305#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4306#[serde(rename_all = "camelCase")]
4307pub struct CommandQueuedData {
4308    /// The slash command text to be executed (e.g., /help, /clear)
4309    pub command: String,
4310    /// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
4311    pub request_id: RequestId,
4312}
4313
4314/// Session event "command.execute". Registered command dispatch request routed to the owning client
4315#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4316#[serde(rename_all = "camelCase")]
4317pub struct CommandExecuteData {
4318    /// Raw argument string after the command name
4319    pub args: String,
4320    /// The full command text (e.g., /deploy production)
4321    pub command: String,
4322    /// Command name without leading /
4323    pub command_name: String,
4324    /// Unique identifier; used to respond via session.commands.handlePendingCommand()
4325    pub request_id: RequestId,
4326}
4327
4328/// Session event "command.completed". Queued command completion notification signaling UI dismissal
4329#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4330#[serde(rename_all = "camelCase")]
4331pub struct CommandCompletedData {
4332    /// Request ID of the resolved command request; clients should dismiss any UI for this request
4333    pub request_id: RequestId,
4334}
4335
4336/// Session event "auto_mode_switch.requested". Auto mode switch request notification requiring user approval
4337#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4338#[serde(rename_all = "camelCase")]
4339pub struct AutoModeSwitchRequestedData {
4340    /// The rate limit error code that triggered this request
4341    #[serde(skip_serializing_if = "Option::is_none")]
4342    pub error_code: Option<String>,
4343    /// Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
4344    pub request_id: RequestId,
4345    /// Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
4346    #[serde(skip_serializing_if = "Option::is_none")]
4347    pub retry_after_seconds: Option<i64>,
4348}
4349
4350/// Session event "auto_mode_switch.completed". Auto mode switch completion notification
4351#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4352#[serde(rename_all = "camelCase")]
4353pub struct AutoModeSwitchCompletedData {
4354    /// Request ID of the resolved request; clients should dismiss any UI for this request
4355    pub request_id: RequestId,
4356    /// The user's auto-mode-switch choice
4357    pub response: AutoModeSwitchResponse,
4358}
4359
4360/// Session event "session_limits_exhausted.requested". Session limit exhaustion notification requiring user action.
4361#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4362#[serde(rename_all = "camelCase")]
4363pub struct SessionLimitsExhaustedRequestedData {
4364    /// Configured max AI Credits for the current accounting window.
4365    pub max_ai_credits: f64,
4366    /// Unique identifier for this request; used to respond via session.ui.handlePendingSessionLimitsExhausted().
4367    pub request_id: RequestId,
4368    /// AI Credits already consumed in the current accounting window.
4369    pub used_ai_credits: f64,
4370}
4371
4372/// The user's selected action for an exhausted session limit.
4373#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4374#[serde(rename_all = "camelCase")]
4375pub struct SessionLimitsExhaustedResponse {
4376    /// Action selected by the user.
4377    pub action: SessionLimitsExhaustedResponseAction,
4378    /// AI Credits to add to the current max when action is 'add'.
4379    #[serde(skip_serializing_if = "Option::is_none")]
4380    pub additional_ai_credits: Option<f64>,
4381    /// New absolute max AI Credits when action is 'set'.
4382    #[serde(skip_serializing_if = "Option::is_none")]
4383    pub max_ai_credits: Option<f64>,
4384}
4385
4386/// Session event "session_limits_exhausted.completed". Session limit exhaustion prompt completion notification.
4387#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4388#[serde(rename_all = "camelCase")]
4389pub struct SessionLimitsExhaustedCompletedData {
4390    /// Request ID of the resolved request; clients should dismiss any UI for this request.
4391    pub request_id: RequestId,
4392    /// The user's selected session-limit action.
4393    pub response: SessionLimitsExhaustedResponse,
4394}
4395
4396/// 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.
4397///
4398/// <div class="warning">
4399///
4400/// **Experimental.** This type is part of an experimental wire-protocol surface
4401/// and may change or be removed in future SDK or CLI releases.
4402///
4403/// </div>
4404#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4405#[serde(rename_all = "camelCase")]
4406pub struct SessionAutoModeResolvedData {
4407    /// Models offered to the router for this resolution
4408    #[serde(skip_serializing_if = "Option::is_none")]
4409    pub available_models: Option<Vec<String>>,
4410    /// Ordered candidate model list the router returned, when not a fallback
4411    #[serde(skip_serializing_if = "Option::is_none")]
4412    pub candidate_models: Option<Vec<String>>,
4413    /// 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.
4414    #[serde(skip_serializing_if = "Option::is_none")]
4415    pub category_scores: Option<HashMap<String, f64>>,
4416    /// The concrete model the session will use after any intent refinement
4417    pub chosen_model: String,
4418    /// The chosen model's score shortfall relative to the top candidate
4419    #[serde(skip_serializing_if = "Option::is_none")]
4420    pub chosen_shortfall: Option<f64>,
4421    /// Classifier confidence for the predicted label, when available
4422    #[serde(skip_serializing_if = "Option::is_none")]
4423    pub confidence: Option<f64>,
4424    /// End-to-end client wait time for the router request in milliseconds
4425    #[serde(skip_serializing_if = "Option::is_none")]
4426    pub end_to_end_latency_ms: Option<f64>,
4427    /// Whether the router fell back to the standard Auto selection
4428    #[serde(skip_serializing_if = "Option::is_none")]
4429    pub fallback: Option<bool>,
4430    /// Server-provided reason for falling back, when available
4431    #[serde(skip_serializing_if = "Option::is_none")]
4432    pub fallback_reason: Option<String>,
4433    /// Whether the routed prompt contained an image
4434    #[serde(skip_serializing_if = "Option::is_none")]
4435    pub has_image: Option<bool>,
4436    /// The predicted classifier label (e.g. `needs_reasoning`), when available
4437    #[serde(skip_serializing_if = "Option::is_none")]
4438    pub predicted_label: Option<String>,
4439    /// Coarse request-difficulty bucket, for explaining why a model was chosen ("picked X because this looks like high-reasoning work")
4440    #[serde(skip_serializing_if = "Option::is_none")]
4441    pub reasoning_bucket: Option<AutoModeResolvedReasoningBucket>,
4442    /// Server-reported router processing time in milliseconds
4443    #[serde(skip_serializing_if = "Option::is_none")]
4444    pub router_latency_ms: Option<f64>,
4445    /// The routing method the server applied, when Auto Intent ran
4446    #[serde(skip_serializing_if = "Option::is_none")]
4447    pub routing_method: Option<String>,
4448    /// Whether a sticky model choice overrode the router result
4449    #[serde(skip_serializing_if = "Option::is_none")]
4450    pub sticky_override: Option<bool>,
4451}
4452
4453/// 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.
4454///
4455/// <div class="warning">
4456///
4457/// **Experimental.** This type is part of an experimental wire-protocol surface
4458/// and may change or be removed in future SDK or CLI releases.
4459///
4460/// </div>
4461#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4462#[serde(rename_all = "camelCase")]
4463pub struct SessionManagedSettingsResolvedData {
4464    /// Whether enterprise policy disables bypass-permissions ("yolo") mode for this session. Deny-wins across layers, and forced on when `failClosed` is true.
4465    pub bypass_permissions_disabled: bool,
4466    /// Whether a session-local permissions layer injected by the SDK host was present
4467    #[serde(skip_serializing_if = "Option::is_none")]
4468    pub client_managed: Option<bool>,
4469    /// Whether an actual device MDM/plist/registry/file managed-settings layer was present
4470    pub device_managed: bool,
4471    /// 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.
4472    pub fail_closed: bool,
4473    /// The setting keys under enterprise management in the effective managed settings (e.g. `model`, `enabledPlugins`, `permissions`). Empty when no managed settings are in force.
4474    pub managed_keys: Vec<String>,
4475    /// Whether at least two managed sources supplied permission allowlists, so enforcement intersects them and the flattened settings payload omits `permissions.allow`.
4476    #[serde(skip_serializing_if = "Option::is_none")]
4477    pub permissions_allow_intersected: Option<bool>,
4478    /// Whether the server (account/org) managed-settings layer was present
4479    pub server_managed: bool,
4480    /// The effective (resolved) managed settings values, so clients can render exactly what is enforced. Absent when no managed policy is in force.
4481    #[serde(skip_serializing_if = "Option::is_none")]
4482    pub settings: Option<serde_json::Value>,
4483    /// 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.
4484    pub source: ManagedSettingsResolvedSource,
4485}
4486
4487/// 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.
4488///
4489/// <div class="warning">
4490///
4491/// **Experimental.** This type is part of an experimental wire-protocol surface
4492/// and may change or be removed in future SDK or CLI releases.
4493///
4494/// </div>
4495#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4496#[serde(rename_all = "camelCase")]
4497pub struct SessionManagedSettingsEnforcedData {
4498    /// The category of runtime action that managed policy governed.
4499    pub action: ManagedSettingsEnforcedAction,
4500    /// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused. Absent for actions without a specific escalation primitive.
4501    #[serde(skip_serializing_if = "Option::is_none")]
4502    pub escalation: Option<ManagedSettingsEnforcedEscalation>,
4503    /// 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.
4504    pub fail_closed: bool,
4505    /// A human-readable explanation of why the action was governed, suitable for surfacing to the user.
4506    pub message: String,
4507    /// The managed setting key responsible for the enforcement (e.g. `permissions.disableBypassPermissionsMode`).
4508    pub setting: String,
4509}
4510
4511/// A single slash command available in the session, as listed by the `commands.changed` event.
4512#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4513#[serde(rename_all = "camelCase")]
4514pub struct CommandsChangedCommand {
4515    /// Optional human-readable command description.
4516    #[serde(skip_serializing_if = "Option::is_none")]
4517    pub description: Option<String>,
4518    /// Slash command name without the leading slash.
4519    pub name: String,
4520}
4521
4522/// Session event "commands.changed". SDK command registration change notification
4523#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4524#[serde(rename_all = "camelCase")]
4525pub struct CommandsChangedData {
4526    /// Current list of registered SDK commands
4527    pub commands: Vec<CommandsChangedCommand>,
4528}
4529
4530/// UI capability changes
4531#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4532#[serde(rename_all = "camelCase")]
4533pub struct CapabilitiesChangedUI {
4534    /// Whether canvas rendering is now supported
4535    #[serde(skip_serializing_if = "Option::is_none")]
4536    pub canvases: Option<bool>,
4537    /// Whether elicitation is now supported
4538    #[serde(skip_serializing_if = "Option::is_none")]
4539    pub elicitation: Option<bool>,
4540    /// Whether MCP Apps (SEP-1865) UI passthrough is now supported
4541    #[serde(skip_serializing_if = "Option::is_none")]
4542    pub mcp_apps: Option<bool>,
4543}
4544
4545/// Session event "capabilities.changed". Session capability change notification
4546#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4547#[serde(rename_all = "camelCase")]
4548pub struct CapabilitiesChangedData {
4549    /// UI capability changes
4550    #[serde(skip_serializing_if = "Option::is_none")]
4551    pub ui: Option<CapabilitiesChangedUI>,
4552}
4553
4554/// Session event "exit_plan_mode.requested". Plan approval request with plan content and available user actions
4555#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4556#[serde(rename_all = "camelCase")]
4557pub struct ExitPlanModeRequestedData {
4558    /// Available actions the user can take
4559    pub actions: Vec<ExitPlanModeAction>,
4560    /// Full content of the plan file
4561    pub plan_content: String,
4562    /// Recommended action to preselect for the user
4563    pub recommended_action: ExitPlanModeAction,
4564    /// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
4565    pub request_id: RequestId,
4566    /// Summary of the plan that was created
4567    pub summary: String,
4568}
4569
4570/// Session event "exit_plan_mode.completed". Plan mode exit completion with the user's approval decision and optional feedback
4571#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4572#[serde(rename_all = "camelCase")]
4573pub struct ExitPlanModeCompletedData {
4574    /// Whether the plan was approved by the user
4575    #[serde(skip_serializing_if = "Option::is_none")]
4576    pub approved: Option<bool>,
4577    /// Whether edits should be auto-approved without confirmation
4578    #[serde(skip_serializing_if = "Option::is_none")]
4579    pub auto_approve_edits: Option<bool>,
4580    /// Free-form feedback from the user if they requested changes to the plan
4581    #[serde(skip_serializing_if = "Option::is_none")]
4582    pub feedback: Option<String>,
4583    /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
4584    pub request_id: RequestId,
4585    /// Action selected by the user
4586    #[serde(skip_serializing_if = "Option::is_none")]
4587    pub selected_action: Option<ExitPlanModeAction>,
4588}
4589
4590/// Session event "session.tools_updated". Payload of `session.tools_updated` identifying the model whose resolved tools were updated.
4591#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4592#[serde(rename_all = "camelCase")]
4593pub struct SessionToolsUpdatedData {
4594    /// Identifier of the model the resolved tools apply to.
4595    pub model: String,
4596}
4597
4598/// Session event "session.background_tasks_changed". Empty payload for `session.background_tasks_changed`, indicating background task state changed.
4599#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4600#[serde(rename_all = "camelCase")]
4601pub struct SessionBackgroundTasksChangedData {}
4602
4603/// Session event "factory.run_updated". Ephemeral invalidation signal for a changed factory run.
4604///
4605/// <div class="warning">
4606///
4607/// **Experimental.** This type is part of an experimental wire-protocol surface
4608/// and may change or be removed in future SDK or CLI releases.
4609///
4610/// </div>
4611#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4612#[serde(rename_all = "camelCase")]
4613pub struct FactoryRunUpdatedData {
4614    /// Monotonic revision now available for the run.
4615    pub revision: i64,
4616    pub run_id: String,
4617}
4618
4619/// A single resolved skill in `session.skills_loaded`, including source, invocability, enabled state, path, and argument hint.
4620#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4621#[serde(rename_all = "camelCase")]
4622pub struct SkillsLoadedSkill {
4623    /// Optional freeform hint describing the skill's expected arguments, from the `argument-hint` frontmatter field
4624    #[serde(skip_serializing_if = "Option::is_none")]
4625    pub argument_hint: Option<String>,
4626    /// Canonical slash command name used to invoke the skill, without the leading '/'
4627    #[serde(skip_serializing_if = "Option::is_none")]
4628    pub command_name: Option<String>,
4629    /// Description of what the skill does
4630    pub description: String,
4631    /// Whether the skill is currently enabled
4632    pub enabled: bool,
4633    /// Unique identifier for the skill
4634    pub name: String,
4635    /// Absolute path to the skill file, if available
4636    #[serde(skip_serializing_if = "Option::is_none")]
4637    pub path: Option<String>,
4638    /// Source location type (e.g., project, personal-copilot, plugin, builtin)
4639    pub source: SkillSource,
4640    /// Whether the skill can be invoked by the user as a slash command
4641    pub user_invocable: bool,
4642}
4643
4644/// Session event "session.skills_loaded". Payload of `session.skills_loaded` listing resolved skill metadata.
4645#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4646#[serde(rename_all = "camelCase")]
4647pub struct SessionSkillsLoadedData {
4648    /// Array of resolved skill metadata
4649    pub skills: Vec<SkillsLoadedSkill>,
4650}
4651
4652/// A single loaded custom agent in `session.custom_agents_updated`, with identity, source, tools, invocability, and model override.
4653#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4654#[serde(rename_all = "camelCase")]
4655pub struct CustomAgentsUpdatedAgent {
4656    /// Description of what the agent does
4657    pub description: String,
4658    /// Human-readable display name
4659    pub display_name: String,
4660    /// Unique identifier for the agent
4661    pub id: String,
4662    /// Model override for this agent, if set
4663    #[serde(skip_serializing_if = "Option::is_none")]
4664    pub model: Option<String>,
4665    /// Internal name of the agent
4666    pub name: String,
4667    /// Source location: user, project, inherited, remote, or plugin
4668    pub source: String,
4669    /// List of tool names available to this agent, or null when all tools are available
4670    pub tools: Option<Vec<String>>,
4671    /// Whether the agent can be selected by the user
4672    pub user_invocable: bool,
4673}
4674
4675/// Session event "session.custom_agents_updated". Payload of `session.custom_agents_updated` with loaded custom agents plus non-fatal warnings and fatal errors.
4676#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4677#[serde(rename_all = "camelCase")]
4678pub struct SessionCustomAgentsUpdatedData {
4679    /// Array of loaded custom agent metadata
4680    pub agents: Vec<CustomAgentsUpdatedAgent>,
4681    /// Fatal errors from agent loading
4682    pub errors: Vec<String>,
4683    /// Non-fatal warnings from agent loading
4684    pub warnings: Vec<String>,
4685}
4686
4687/// A single MCP server status summary in `session.mcp_servers_loaded`, including name, status, source, transport, and plugin metadata.
4688#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4689#[serde(rename_all = "camelCase")]
4690pub struct McpServersLoadedServer {
4691    /// Error message if the server failed to connect
4692    #[serde(skip_serializing_if = "Option::is_none")]
4693    pub error: Option<String>,
4694    /// Server name (config key)
4695    pub name: String,
4696    /// Name 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_name: Option<String>,
4699    /// Version of the plugin that supplied the effective MCP server config, only when source is plugin
4700    #[serde(skip_serializing_if = "Option::is_none")]
4701    pub plugin_version: Option<String>,
4702    /// Configuration source: user, workspace, plugin, or builtin
4703    #[serde(skip_serializing_if = "Option::is_none")]
4704    pub source: Option<McpServerSource>,
4705    /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
4706    pub status: McpServerStatus,
4707    /// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
4708    #[serde(skip_serializing_if = "Option::is_none")]
4709    pub transport: Option<McpServerTransport>,
4710}
4711
4712/// Session event "session.mcp_servers_loaded". Payload of `session.mcp_servers_loaded` listing MCP server status summaries.
4713#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4714#[serde(rename_all = "camelCase")]
4715pub struct SessionMcpServersLoadedData {
4716    /// Array of MCP server status summaries
4717    pub servers: Vec<McpServersLoadedServer>,
4718}
4719
4720/// Session event "session.mcp_server_status_changed". Payload of `session.mcp_server_status_changed` for one MCP server's status and optional failure error.
4721#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4722#[serde(rename_all = "camelCase")]
4723pub struct SessionMcpServerStatusChangedData {
4724    /// Error message if the server entered a failed state
4725    #[serde(skip_serializing_if = "Option::is_none")]
4726    pub error: Option<String>,
4727    /// Name of the MCP server whose status changed
4728    pub server_name: String,
4729    /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
4730    pub status: McpServerStatus,
4731}
4732
4733/// Session event "mcp.tools.list_changed". Payload identifying the MCP server associated with a list change.
4734#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4735#[serde(rename_all = "camelCase")]
4736pub struct McpToolsListChangedData {
4737    /// Name of the MCP server whose list changed
4738    pub server_name: String,
4739}
4740
4741/// Session event "mcp.resources.list_changed". Payload identifying the MCP server associated with a list change.
4742#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4743#[serde(rename_all = "camelCase")]
4744pub struct McpResourcesListChangedData {
4745    /// Name of the MCP server whose list changed
4746    pub server_name: String,
4747}
4748
4749/// Session event "mcp.prompts.list_changed". Payload identifying the MCP server associated with a list change.
4750#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4751#[serde(rename_all = "camelCase")]
4752pub struct McpPromptsListChangedData {
4753    /// Name of the MCP server whose list changed
4754    pub server_name: String,
4755}
4756
4757/// A single extension discovered by `session.extensions_loaded`, including qualified ID, source, and current status.
4758#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4759#[serde(rename_all = "camelCase")]
4760pub struct ExtensionsLoadedExtension {
4761    /// Source-qualified extension ID (e.g., 'project:my-ext', 'user:auth-helper', 'plugin:my-plugin:my-ext')
4762    pub id: String,
4763    /// Extension name (directory name)
4764    pub name: String,
4765    /// Discovery source
4766    pub source: ExtensionsLoadedExtensionSource,
4767    /// Current status: running, disabled, failed, or starting
4768    pub status: ExtensionsLoadedExtensionStatus,
4769}
4770
4771/// Session event "session.extensions_loaded". Payload of `session.extensions_loaded` listing discovered extensions and their statuses.
4772#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4773#[serde(rename_all = "camelCase")]
4774pub struct SessionExtensionsLoadedData {
4775    /// Array of discovered extensions and their status
4776    pub extensions: Vec<ExtensionsLoadedExtension>,
4777}
4778
4779/// Session event "session.canvas.opened". Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional icon, title, status, URL, and input.
4780///
4781/// <div class="warning">
4782///
4783/// **Experimental.** This type is part of an experimental wire-protocol surface
4784/// and may change or be removed in future SDK or CLI releases.
4785///
4786/// </div>
4787#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4788#[serde(rename_all = "camelCase")]
4789pub struct SessionCanvasOpenedData {
4790    /// Provider-local canvas identifier
4791    pub canvas_id: String,
4792    /// Owning provider identifier
4793    pub extension_id: String,
4794    /// Owning extension display name, when available
4795    #[serde(skip_serializing_if = "Option::is_none")]
4796    pub extension_name: Option<String>,
4797    /// Host-local PNG path for the canvas icon, when supplied
4798    #[serde(skip_serializing_if = "Option::is_none")]
4799    pub icon: Option<String>,
4800    /// Input supplied when the instance was opened
4801    #[serde(skip_serializing_if = "Option::is_none")]
4802    pub input: Option<serde_json::Value>,
4803    /// Stable caller-supplied canvas instance identifier
4804    pub instance_id: String,
4805    /// Provider-supplied status text
4806    #[serde(skip_serializing_if = "Option::is_none")]
4807    pub status: Option<String>,
4808    /// Rendered title
4809    #[serde(skip_serializing_if = "Option::is_none")]
4810    pub title: Option<String>,
4811    /// URL for web-rendered canvases
4812    #[serde(skip_serializing_if = "Option::is_none")]
4813    pub url: Option<String>,
4814}
4815
4816/// A single action within a canvas declaration, with its name, optional description, and optional input schema.
4817///
4818/// <div class="warning">
4819///
4820/// **Experimental.** This type is part of an experimental wire-protocol surface
4821/// and may change or be removed in future SDK or CLI releases.
4822///
4823/// </div>
4824#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4825#[serde(rename_all = "camelCase")]
4826pub struct CanvasRegistryChangedCanvasAction {
4827    /// Action description
4828    #[serde(skip_serializing_if = "Option::is_none")]
4829    pub description: Option<String>,
4830    /// JSON Schema for action input
4831    #[serde(skip_serializing_if = "Option::is_none")]
4832    pub input_schema: Option<serde_json::Value>,
4833    /// Action name
4834    pub name: String,
4835}
4836
4837/// A single canvas declaration in `session.canvas.registry_changed`, including provider IDs, display metadata, input schema, and actions.
4838///
4839/// <div class="warning">
4840///
4841/// **Experimental.** This type is part of an experimental wire-protocol surface
4842/// and may change or be removed in future SDK or CLI releases.
4843///
4844/// </div>
4845#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4846#[serde(rename_all = "camelCase")]
4847pub struct CanvasRegistryChangedCanvas {
4848    /// Actions the agent or host may invoke
4849    #[serde(skip_serializing_if = "Option::is_none")]
4850    pub actions: Option<Vec<CanvasRegistryChangedCanvasAction>>,
4851    /// Provider-local canvas identifier
4852    pub canvas_id: String,
4853    /// Short, single-sentence description shown to the agent in canvas catalogs.
4854    pub description: String,
4855    /// Human-readable canvas name
4856    pub display_name: String,
4857    /// Owning provider identifier
4858    pub extension_id: String,
4859    /// Owning extension display name, when available
4860    #[serde(skip_serializing_if = "Option::is_none")]
4861    pub extension_name: Option<String>,
4862    /// Host-local PNG path for the canvas icon, when supplied
4863    #[serde(skip_serializing_if = "Option::is_none")]
4864    pub icon: Option<String>,
4865    /// JSON Schema for canvas open input
4866    #[serde(skip_serializing_if = "Option::is_none")]
4867    pub input_schema: Option<serde_json::Value>,
4868}
4869
4870/// Session event "session.canvas.registry_changed". Payload of `session.canvas.registry_changed` listing the canvas declarations currently available.
4871///
4872/// <div class="warning">
4873///
4874/// **Experimental.** This type is part of an experimental wire-protocol surface
4875/// and may change or be removed in future SDK or CLI releases.
4876///
4877/// </div>
4878#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4879#[serde(rename_all = "camelCase")]
4880pub struct SessionCanvasRegistryChangedData {
4881    /// Canvas declarations currently available
4882    pub canvases: Vec<CanvasRegistryChangedCanvas>,
4883}
4884
4885/// Session event "session.canvas.closed". Payload of `session.canvas.closed` with the closed canvas instance ID, provider ID, and canvas ID.
4886///
4887/// <div class="warning">
4888///
4889/// **Experimental.** This type is part of an experimental wire-protocol surface
4890/// and may change or be removed in future SDK or CLI releases.
4891///
4892/// </div>
4893#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4894#[serde(rename_all = "camelCase")]
4895pub struct SessionCanvasClosedData {
4896    /// Provider-local canvas identifier
4897    pub canvas_id: String,
4898    /// Owning provider identifier
4899    pub extension_id: String,
4900    /// Stable caller-supplied identifier of the canvas instance that was closed
4901    pub instance_id: String,
4902}
4903
4904/// 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.
4905///
4906/// <div class="warning">
4907///
4908/// **Experimental.** This type is part of an experimental wire-protocol surface
4909/// and may change or be removed in future SDK or CLI releases.
4910///
4911/// </div>
4912#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4913#[serde(rename_all = "camelCase")]
4914pub struct SessionCanvasUnavailableData {
4915    /// Provider-local canvas identifier
4916    pub canvas_id: String,
4917    /// Owning provider identifier
4918    pub extension_id: String,
4919    /// Stable caller-supplied identifier of the canvas instance whose provider became unavailable
4920    pub instance_id: String,
4921}
4922
4923/// 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.
4924///
4925/// <div class="warning">
4926///
4927/// **Experimental.** This type is part of an experimental wire-protocol surface
4928/// and may change or be removed in future SDK or CLI releases.
4929///
4930/// </div>
4931#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4932#[serde(rename_all = "camelCase")]
4933pub struct SessionCanvasRecordedData {
4934    /// Provider-local canvas identifier
4935    pub canvas_id: String,
4936    /// Owning provider identifier
4937    pub extension_id: String,
4938    /// Input supplied when the instance was opened
4939    #[serde(skip_serializing_if = "Option::is_none")]
4940    pub input: Option<serde_json::Value>,
4941    /// Stable caller-supplied canvas instance identifier
4942    pub instance_id: String,
4943    /// Rendered title
4944    #[serde(skip_serializing_if = "Option::is_none")]
4945    pub title: Option<String>,
4946}
4947
4948/// Session event "session.canvas.removed". Durable record that a canvas instance was closed, superseding a prior instance_recorded during resume replay.
4949///
4950/// <div class="warning">
4951///
4952/// **Experimental.** This type is part of an experimental wire-protocol surface
4953/// and may change or be removed in future SDK or CLI releases.
4954///
4955/// </div>
4956#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4957#[serde(rename_all = "camelCase")]
4958pub struct SessionCanvasRemovedData {
4959    /// Provider-local canvas identifier
4960    pub canvas_id: String,
4961    /// Owning provider identifier
4962    pub extension_id: String,
4963    /// Stable caller-supplied identifier of the canvas instance that was closed
4964    pub instance_id: String,
4965}
4966
4967/// Session event "session.extensions.attachments_pushed". Payload of `session.extensions.attachments_pushed` with extension-contributed attachments for the next send.
4968#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4969#[serde(rename_all = "camelCase")]
4970pub struct SessionExtensionsAttachmentsPushedData {
4971    /// Attachments contributed by an extension; the host should surface these as composer pills and forward them via the next session.send call.
4972    pub attachments: Vec<serde_json::Value>,
4973}
4974
4975/// Set when the underlying tools/call threw an error before returning a CallToolResult
4976#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4977#[serde(rename_all = "camelCase")]
4978pub struct McpAppToolCallCompleteError {
4979    /// Human-readable error message
4980    pub message: String,
4981}
4982
4983/// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
4984#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4985#[serde(rename_all = "camelCase")]
4986pub struct McpAppToolCallCompleteToolMetaUI {
4987    /// `ui://` URI declared by the tool's `_meta.ui.resourceUri`
4988    #[serde(skip_serializing_if = "Option::is_none")]
4989    pub resource_uri: Option<String>,
4990    /// Tool visibility per SEP-1865 (typically a subset of `["model","app"]`)
4991    #[serde(skip_serializing_if = "Option::is_none")]
4992    pub visibility: Option<Vec<String>>,
4993}
4994
4995/// 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.
4996#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4997#[serde(rename_all = "camelCase")]
4998pub struct McpAppToolCallCompleteToolMeta {
4999    /// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
5000    #[serde(skip_serializing_if = "Option::is_none")]
5001    pub ui: Option<McpAppToolCallCompleteToolMetaUI>,
5002}
5003
5004/// Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
5005#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5006#[serde(rename_all = "camelCase")]
5007pub struct McpAppToolCallCompleteData {
5008    /// Arguments passed to the tool by the app view, if any
5009    #[serde(skip_serializing_if = "Option::is_none")]
5010    pub arguments: Option<HashMap<String, serde_json::Value>>,
5011    /// Wall-clock duration of the underlying tools/call in milliseconds
5012    pub duration_ms: f64,
5013    /// Set when the underlying tools/call threw an error before returning a CallToolResult
5014    #[serde(skip_serializing_if = "Option::is_none")]
5015    pub error: Option<McpAppToolCallCompleteError>,
5016    /// Standard MCP CallToolResult returned by the server. Present whether or not the call set isError.
5017    #[serde(skip_serializing_if = "Option::is_none")]
5018    pub result: Option<HashMap<String, serde_json::Value>>,
5019    /// Name of the MCP server hosting the tool
5020    pub server_name: String,
5021    /// True when the call completed without throwing AND the MCP CallToolResult did not set isError
5022    pub success: bool,
5023    /// 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.
5024    #[serde(skip_serializing_if = "Option::is_none")]
5025    pub tool_meta: Option<McpAppToolCallCompleteToolMeta>,
5026    /// MCP tool name that was invoked
5027    pub tool_name: String,
5028}
5029
5030/// Hosting platform type of the repository (github or ado)
5031#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5032pub enum WorkingDirectoryContextHostType {
5033    /// Repository is hosted on GitHub.
5034    #[serde(rename = "github")]
5035    GitHub,
5036    /// Repository is hosted on Azure DevOps.
5037    #[serde(rename = "ado")]
5038    Ado,
5039    /// Unknown variant for forward compatibility.
5040    #[default]
5041    #[serde(other)]
5042    Unknown,
5043}
5044
5045/// Allowed values for the `ContextTier` enumeration.
5046#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5047pub enum ContextTier {
5048    /// Default context tier with standard context window size.
5049    #[serde(rename = "default")]
5050    Default,
5051    /// Extended context tier with a larger context window.
5052    #[serde(rename = "long_context")]
5053    LongContext,
5054    /// Unknown variant for forward compatibility.
5055    #[default]
5056    #[serde(other)]
5057    Unknown,
5058}
5059
5060/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
5061#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5062pub enum ReasoningSummary {
5063    /// Do not request reasoning summaries from the model.
5064    #[serde(rename = "none")]
5065    None,
5066    /// Request a concise summary of the model's reasoning.
5067    #[serde(rename = "concise")]
5068    Concise,
5069    /// Request a detailed summary of the model's reasoning.
5070    #[serde(rename = "detailed")]
5071    Detailed,
5072    /// Unknown variant for forward compatibility.
5073    #[default]
5074    #[serde(other)]
5075    Unknown,
5076}
5077
5078/// Output verbosity level used for supported model calls (e.g. "low", "medium", "high")
5079#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5080pub enum Verbosity {
5081    /// A terse response was requested.
5082    #[serde(rename = "low")]
5083    Low,
5084    /// A medium amount of response detail was requested.
5085    #[serde(rename = "medium")]
5086    Medium,
5087    /// A more detailed response was requested.
5088    #[serde(rename = "high")]
5089    High,
5090    /// Unknown variant for forward compatibility.
5091    #[default]
5092    #[serde(other)]
5093    Unknown,
5094}
5095
5096/// 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.
5097#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5098pub enum ScheduleOrigin {
5099    /// The schedule was created by an explicit user action, such as `/every` or `/after`.
5100    #[serde(rename = "user")]
5101    User,
5102    /// The schedule was created by the agent via the `manage_schedule` tool.
5103    #[serde(rename = "model")]
5104    Model,
5105    /// Unknown variant for forward compatibility.
5106    #[default]
5107    #[serde(other)]
5108    Unknown,
5109}
5110
5111/// The type of operation performed on the autopilot objective state file
5112#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5113pub enum AutopilotObjectiveChangedOperation {
5114    /// Autopilot objective state file was created for a new objective.
5115    #[serde(rename = "create")]
5116    Create,
5117    /// Autopilot objective state file was updated for an existing objective.
5118    #[serde(rename = "update")]
5119    Update,
5120    /// Autopilot objective state file was deleted or cleared.
5121    #[serde(rename = "delete")]
5122    Delete,
5123    /// Unknown variant for forward compatibility.
5124    #[default]
5125    #[serde(other)]
5126    Unknown,
5127}
5128
5129/// Current autopilot objective status, if one exists
5130#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5131pub enum AutopilotObjectiveChangedStatus {
5132    /// Objective is active and can drive autopilot continuations.
5133    #[serde(rename = "active")]
5134    Active,
5135    /// Objective is paused and will not drive autopilot continuations.
5136    #[serde(rename = "paused")]
5137    Paused,
5138    /// Legacy objective state indicating the previous continuation cap was reached.
5139    #[serde(rename = "cap_reached")]
5140    CapReached,
5141    /// Objective was completed by the agent.
5142    #[serde(rename = "completed")]
5143    Completed,
5144    /// Unknown variant for forward compatibility.
5145    #[default]
5146    #[serde(other)]
5147    Unknown,
5148}
5149
5150/// The session mode the agent is operating in
5151#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5152pub enum SessionMode {
5153    /// The agent is responding interactively to the user.
5154    #[serde(rename = "interactive")]
5155    Interactive,
5156    /// The agent is preparing a plan before making changes.
5157    #[serde(rename = "plan")]
5158    Plan,
5159    /// The agent is working autonomously toward task completion.
5160    #[serde(rename = "autopilot")]
5161    Autopilot,
5162    /// Unknown variant for forward compatibility.
5163    #[default]
5164    #[serde(other)]
5165    Unknown,
5166}
5167
5168/// Allow-all mode for the session.
5169///
5170/// <div class="warning">
5171///
5172/// **Experimental.** This type is part of an experimental wire-protocol surface
5173/// and may change or be removed in future SDK or CLI releases.
5174///
5175/// </div>
5176#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5177pub enum PermissionAllowAllMode {
5178    /// Permission requests follow the normal approval flow.
5179    #[serde(rename = "off")]
5180    Off,
5181    /// Tool, path, and URL permission requests are automatically approved.
5182    #[serde(rename = "on")]
5183    On,
5184    /// 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.
5185    #[serde(rename = "auto")]
5186    Auto,
5187    /// Unknown variant for forward compatibility.
5188    #[default]
5189    #[serde(other)]
5190    Unknown,
5191}
5192
5193/// The type of operation performed on the plan file
5194#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5195pub enum PlanChangedOperation {
5196    /// The plan file was created.
5197    #[serde(rename = "create")]
5198    Create,
5199    /// The plan file was updated.
5200    #[serde(rename = "update")]
5201    Update,
5202    /// The plan file was deleted.
5203    #[serde(rename = "delete")]
5204    Delete,
5205    /// Unknown variant for forward compatibility.
5206    #[default]
5207    #[serde(other)]
5208    Unknown,
5209}
5210
5211/// Whether the file was newly created or updated
5212#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5213pub enum WorkspaceFileChangedOperation {
5214    /// The workspace file was created.
5215    #[serde(rename = "create")]
5216    Create,
5217    /// The workspace file was updated.
5218    #[serde(rename = "update")]
5219    Update,
5220    /// Unknown variant for forward compatibility.
5221    #[default]
5222    #[serde(other)]
5223    Unknown,
5224}
5225
5226/// Origin type of the session being handed off
5227#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5228pub enum HandoffSourceType {
5229    /// The handoff originated from a remote session.
5230    #[serde(rename = "remote")]
5231    Remote,
5232    /// The handoff originated from a local session.
5233    #[serde(rename = "local")]
5234    Local,
5235    /// Unknown variant for forward compatibility.
5236    #[default]
5237    #[serde(other)]
5238    Unknown,
5239}
5240
5241/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
5242#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5243pub enum ShutdownType {
5244    /// The session ended normally.
5245    #[serde(rename = "routine")]
5246    Routine,
5247    /// The session ended because of a crash or fatal error.
5248    #[serde(rename = "error")]
5249    Error,
5250    /// Unknown variant for forward compatibility.
5251    #[default]
5252    #[serde(other)]
5253    Unknown,
5254}
5255
5256/// What initiated a conversation compaction
5257#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5258pub enum CompactionTrigger {
5259    /// Background compaction started automatically because context utilization crossed the background threshold.
5260    #[serde(rename = "threshold")]
5261    Threshold,
5262    /// Compaction forced by a context-limit model response (e.g. HTTP 413) before retrying the request.
5263    #[serde(rename = "context_limit_retry")]
5264    ContextLimitRetry,
5265    /// User-requested compaction, e.g. the /compact command or the history.compact API.
5266    #[serde(rename = "manual")]
5267    Manual,
5268    /// Emergency compaction triggered by high process memory usage.
5269    #[serde(rename = "memory_pressure")]
5270    MemoryPressure,
5271    /// Compaction requested while switching to a model with a smaller context window.
5272    #[serde(rename = "model_switch")]
5273    ModelSwitch,
5274    /// Unknown variant for forward compatibility.
5275    #[default]
5276    #[serde(other)]
5277    Unknown,
5278}
5279
5280/// Semantic result of evaluating a task completion request
5281#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5282pub enum TaskCompletionOutcome {
5283    /// The completion request was accepted and the objective is complete.
5284    #[serde(rename = "completed")]
5285    Completed,
5286    /// The completion request was rejected because more work or validation remains.
5287    #[serde(rename = "continue")]
5288    Continue,
5289    /// Completion cannot proceed without intervention; the active objective is paused when one is identified.
5290    #[serde(rename = "blocked")]
5291    Blocked,
5292    /// Unknown variant for forward compatibility.
5293    #[default]
5294    #[serde(other)]
5295    Unknown,
5296}
5297
5298/// The agent mode that was active when this message was sent
5299#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5300pub enum UserMessageAgentMode {
5301    /// The agent is responding interactively to the user.
5302    #[serde(rename = "interactive")]
5303    Interactive,
5304    /// The agent is preparing a plan before making changes.
5305    #[serde(rename = "plan")]
5306    Plan,
5307    /// The agent is working autonomously toward task completion.
5308    #[serde(rename = "autopilot")]
5309    Autopilot,
5310    /// The agent is in shell-focused UI mode.
5311    #[serde(rename = "shell")]
5312    Shell,
5313    /// Unknown variant for forward compatibility.
5314    #[default]
5315    #[serde(other)]
5316    Unknown,
5317}
5318
5319/// 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.
5320#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5321pub enum UserMessageDelivery {
5322    /// Delivered while the loop was idle; starts its own run immediately (a human's fresh turn, or a system notification waking an idle agent).
5323    #[serde(rename = "idle")]
5324    Idle,
5325    /// Injected into the current in-flight run while the agent was busy (immediate mode).
5326    #[serde(rename = "steering")]
5327    Steering,
5328    /// Enqueued while the agent was busy; processed as its own run afterward.
5329    #[serde(rename = "queued")]
5330    Queued,
5331    /// Unknown variant for forward compatibility.
5332    #[default]
5333    #[serde(other)]
5334    Unknown,
5335}
5336
5337/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
5338#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5339pub enum AssistantMessageToolRequestType {
5340    /// Standard function-style tool call.
5341    #[serde(rename = "function")]
5342    Function,
5343    /// Custom grammar-based tool call.
5344    #[serde(rename = "custom")]
5345    Custom,
5346    /// Unknown variant for forward compatibility.
5347    #[default]
5348    #[serde(other)]
5349    Unknown,
5350}
5351
5352/// The system that produced a citation.
5353///
5354/// <div class="warning">
5355///
5356/// **Experimental.** This type is part of an experimental wire-protocol surface
5357/// and may change or be removed in future SDK or CLI releases.
5358///
5359/// </div>
5360#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5361pub enum CitationProvider {
5362    /// Citation produced by an Anthropic (Claude) model response.
5363    #[serde(rename = "anthropic")]
5364    Anthropic,
5365    /// Citation produced by an OpenAI model response.
5366    #[serde(rename = "openai")]
5367    Openai,
5368    /// Citation synthesized client-side by the runtime from tool output.
5369    #[serde(rename = "client")]
5370    Client,
5371    /// Unknown variant for forward compatibility.
5372    #[default]
5373    #[serde(other)]
5374    Unknown,
5375}
5376
5377/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
5378#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5379pub enum AssistantUsageApiEndpoint {
5380    /// Chat Completions API endpoint.
5381    #[serde(rename = "/chat/completions")]
5382    ChatCompletions,
5383    /// Anthropic Messages API endpoint.
5384    #[serde(rename = "/v1/messages")]
5385    V1Messages,
5386    /// Responses API endpoint.
5387    #[serde(rename = "/responses")]
5388    Responses,
5389    /// WebSocket Responses API endpoint.
5390    #[serde(rename = "ws:/responses")]
5391    WsResponses,
5392    /// Unknown variant for forward compatibility.
5393    #[default]
5394    #[serde(other)]
5395    Unknown,
5396}
5397
5398/// 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.
5399#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5400pub enum ModelCallFailureBadRequestKind {
5401    /// The 400 response carried no error body (transient gateway/proxy signature).
5402    #[serde(rename = "bodyless")]
5403    Bodyless,
5404    /// The 400 response carried a structured CAPI error envelope (deterministic validation failure).
5405    #[serde(rename = "structured_error")]
5406    StructuredError,
5407    /// Unknown variant for forward compatibility.
5408    #[default]
5409    #[serde(other)]
5410    Unknown,
5411}
5412
5413/// Boundary that produced a model call failure
5414#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5415pub enum ModelCallFailureKind {
5416    /// The provider returned an API error response.
5417    #[serde(rename = "api")]
5418    Api,
5419    /// The request transport failed before a usable API response completed.
5420    #[serde(rename = "transport")]
5421    Transport,
5422    /// Unknown variant for forward compatibility.
5423    #[default]
5424    #[serde(other)]
5425    Unknown,
5426}
5427
5428/// Where the failed model call originated
5429#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5430pub enum ModelCallFailureSource {
5431    /// Model call from the top-level agent.
5432    #[serde(rename = "top_level")]
5433    TopLevel,
5434    /// Model call from a sub-agent.
5435    #[serde(rename = "subagent")]
5436    Subagent,
5437    /// Model call from MCP sampling.
5438    #[serde(rename = "mcp_sampling")]
5439    McpSampling,
5440    /// Unknown variant for forward compatibility.
5441    #[default]
5442    #[serde(other)]
5443    Unknown,
5444}
5445
5446/// Transport used for a failed model call
5447#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5448pub enum ModelCallFailureTransport {
5449    /// HTTP transport, including SSE streams.
5450    #[serde(rename = "http")]
5451    Http,
5452    /// WebSocket transport.
5453    #[serde(rename = "websocket")]
5454    Websocket,
5455    /// Unknown variant for forward compatibility.
5456    #[default]
5457    #[serde(other)]
5458    Unknown,
5459}
5460
5461/// Finite reason code describing why the current turn was aborted
5462#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5463pub enum AbortReason {
5464    /// The local user requested the abort, for example by pressing Ctrl+C in the CLI.
5465    #[serde(rename = "user_initiated")]
5466    UserInitiated,
5467    /// A remote command requested the abort.
5468    #[serde(rename = "remote_command")]
5469    RemoteCommand,
5470    /// An MCP server delivered a user.abort notification.
5471    #[serde(rename = "user_abort")]
5472    UserAbort,
5473    /// Autopilot stopped the run because the active objective reached its user-set --max-ai-credits limit.
5474    #[serde(rename = "autopilot_credit_limit")]
5475    AutopilotCreditLimit,
5476    /// Unknown variant for forward compatibility.
5477    #[default]
5478    #[serde(other)]
5479    Unknown,
5480}
5481
5482/// Allowed values for the `ToolExecutionStartToolDescriptionMetaUIVisibility` enumeration.
5483#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5484pub enum ToolExecutionStartToolDescriptionMetaUIVisibility {
5485    /// Tool is callable by the model (LLM tool surface)
5486    #[serde(rename = "model")]
5487    Model,
5488    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
5489    #[serde(rename = "app")]
5490    App,
5491    /// Unknown variant for forward compatibility.
5492    #[default]
5493    #[serde(other)]
5494    Unknown,
5495}
5496
5497/// Content block type discriminator
5498#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5499pub enum ToolExecutionCompleteContentTextType {
5500    #[serde(rename = "text")]
5501    #[default]
5502    Text,
5503}
5504
5505/// Content block type discriminator
5506#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5507pub enum ToolExecutionCompleteContentTerminalType {
5508    #[serde(rename = "terminal")]
5509    #[default]
5510    Terminal,
5511}
5512
5513/// Content block type discriminator
5514#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5515pub enum ToolExecutionCompleteContentShellExitType {
5516    #[serde(rename = "shell_exit")]
5517    #[default]
5518    ShellExit,
5519}
5520
5521/// Content block type discriminator
5522#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5523pub enum ToolExecutionCompleteContentImageType {
5524    #[serde(rename = "image")]
5525    #[default]
5526    Image,
5527}
5528
5529/// Content block type discriminator
5530#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5531pub enum ToolExecutionCompleteContentAudioType {
5532    #[serde(rename = "audio")]
5533    #[default]
5534    Audio,
5535}
5536
5537/// Theme variant this icon is intended for
5538#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5539pub enum ToolExecutionCompleteContentResourceLinkIconTheme {
5540    /// Icon intended for light themes.
5541    #[serde(rename = "light")]
5542    Light,
5543    /// Icon intended for dark themes.
5544    #[serde(rename = "dark")]
5545    Dark,
5546    /// Unknown variant for forward compatibility.
5547    #[default]
5548    #[serde(other)]
5549    Unknown,
5550}
5551
5552/// Content block type discriminator
5553#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5554pub enum ToolExecutionCompleteContentResourceLinkType {
5555    #[serde(rename = "resource_link")]
5556    #[default]
5557    ResourceLink,
5558}
5559
5560/// The embedded resource contents, either text or base64-encoded binary
5561#[derive(Debug, Clone, Serialize, Deserialize)]
5562#[serde(untagged)]
5563pub enum ToolExecutionCompleteContentResourceDetails {
5564    EmbeddedTextResourceContents(EmbeddedTextResourceContents),
5565    EmbeddedBlobResourceContents(EmbeddedBlobResourceContents),
5566}
5567
5568/// Content block type discriminator
5569#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5570pub enum ToolExecutionCompleteContentResourceType {
5571    #[serde(rename = "resource")]
5572    #[default]
5573    Resource,
5574}
5575
5576/// A content block within a tool result, which may be text, terminal output, image, audio, or a resource
5577#[derive(Debug, Clone, Serialize, Deserialize)]
5578#[serde(untagged)]
5579pub enum ToolExecutionCompleteContent {
5580    Text(ToolExecutionCompleteContentText),
5581    Terminal(ToolExecutionCompleteContentTerminal),
5582    ShellExit(ToolExecutionCompleteContentShellExit),
5583    Image(ToolExecutionCompleteContentImage),
5584    Audio(ToolExecutionCompleteContentAudio),
5585    ResourceLink(ToolExecutionCompleteContentResourceLink),
5586    Resource(ToolExecutionCompleteContentResource),
5587}
5588
5589/// Allowed values for the `ToolExecutionCompleteToolDescriptionMetaUIVisibility` enumeration.
5590#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5591pub enum ToolExecutionCompleteToolDescriptionMetaUIVisibility {
5592    /// Tool is callable by the model (LLM tool surface)
5593    #[serde(rename = "model")]
5594    Model,
5595    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
5596    #[serde(rename = "app")]
5597    App,
5598    /// Unknown variant for forward compatibility.
5599    #[default]
5600    #[serde(other)]
5601    Unknown,
5602}
5603
5604/// 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)
5605#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5606pub enum SkillInvokedTrigger {
5607    /// Skill invocation requested explicitly by the user, such as via a slash command or UI affordance.
5608    #[serde(rename = "user-invoked")]
5609    UserInvoked,
5610    /// Skill invocation requested by the agent.
5611    #[serde(rename = "agent-invoked")]
5612    AgentInvoked,
5613    /// Skill content loaded as part of another context, such as a configured custom agent or subagent.
5614    #[serde(rename = "context-load")]
5615    ContextLoad,
5616    /// Unknown variant for forward compatibility.
5617    #[default]
5618    #[serde(other)]
5619    Unknown,
5620}
5621
5622/// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
5623#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5624pub enum BinaryAssetType {
5625    /// Binary image data.
5626    #[serde(rename = "image")]
5627    Image,
5628    /// Other binary resource data.
5629    #[serde(rename = "resource")]
5630    Resource,
5631    /// Unknown variant for forward compatibility.
5632    #[default]
5633    #[serde(other)]
5634    Unknown,
5635}
5636
5637/// Message role: "system" for system prompts, "developer" for developer-injected instructions
5638#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5639pub enum SystemMessageRole {
5640    /// System prompt message.
5641    #[serde(rename = "system")]
5642    System,
5643    /// Developer instruction message.
5644    #[serde(rename = "developer")]
5645    Developer,
5646    /// Unknown variant for forward compatibility.
5647    #[default]
5648    #[serde(other)]
5649    Unknown,
5650}
5651
5652/// Permission kind discriminator
5653#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5654pub enum PermissionRequestShellKind {
5655    #[serde(rename = "shell")]
5656    #[default]
5657    Shell,
5658}
5659
5660/// Permission kind discriminator
5661#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5662pub enum PermissionRequestWriteKind {
5663    #[serde(rename = "write")]
5664    #[default]
5665    Write,
5666}
5667
5668/// Permission kind discriminator
5669#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5670pub enum PermissionRequestReadKind {
5671    #[serde(rename = "read")]
5672    #[default]
5673    Read,
5674}
5675
5676/// Permission kind discriminator
5677#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5678pub enum PermissionRequestMcpKind {
5679    #[serde(rename = "mcp")]
5680    #[default]
5681    Mcp,
5682}
5683
5684/// Permission kind discriminator
5685#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5686pub enum PermissionRequestUrlKind {
5687    #[serde(rename = "url")]
5688    #[default]
5689    Url,
5690}
5691
5692/// Whether this is a store or vote memory operation
5693#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5694pub enum PermissionRequestMemoryAction {
5695    /// Store a new memory.
5696    #[serde(rename = "store")]
5697    Store,
5698    /// Vote on an existing memory.
5699    #[serde(rename = "vote")]
5700    Vote,
5701    /// Unknown variant for forward compatibility.
5702    #[default]
5703    #[serde(other)]
5704    Unknown,
5705}
5706
5707/// Vote direction (vote only)
5708#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5709pub enum PermissionRequestMemoryDirection {
5710    /// Vote that the memory is useful or accurate.
5711    #[serde(rename = "upvote")]
5712    Upvote,
5713    /// Vote that the memory is incorrect or outdated.
5714    #[serde(rename = "downvote")]
5715    Downvote,
5716    /// Unknown variant for forward compatibility.
5717    #[default]
5718    #[serde(other)]
5719    Unknown,
5720}
5721
5722/// Permission kind discriminator
5723#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5724pub enum PermissionRequestMemoryKind {
5725    #[serde(rename = "memory")]
5726    #[default]
5727    Memory,
5728}
5729
5730/// Permission kind discriminator
5731#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5732pub enum PermissionRequestCustomToolKind {
5733    #[serde(rename = "custom-tool")]
5734    #[default]
5735    CustomTool,
5736}
5737
5738/// Permission kind discriminator
5739#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5740pub enum PermissionRequestHookKind {
5741    #[serde(rename = "hook")]
5742    #[default]
5743    Hook,
5744}
5745
5746/// Permission kind discriminator
5747#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5748pub enum PermissionRequestExtensionManagementKind {
5749    #[serde(rename = "extension-management")]
5750    #[default]
5751    ExtensionManagement,
5752}
5753
5754/// Permission kind discriminator
5755#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5756pub enum PermissionRequestFactoryKind {
5757    #[serde(rename = "factory")]
5758    #[default]
5759    Factory,
5760}
5761
5762/// Operation gated by a factory permission request.
5763#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5764pub enum FactoryPermissionOperation {
5765    /// Running a registered factory, which spends subagents, active time, and AI credits under the approved limits.
5766    #[serde(rename = "run")]
5767    Run,
5768    /// Authoring a factory, which writes JavaScript into a session-scoped extension and loads it.
5769    #[serde(rename = "author")]
5770    Author,
5771    /// Unknown variant for forward compatibility.
5772    #[default]
5773    #[serde(other)]
5774    Unknown,
5775}
5776
5777/// Permission kind discriminator
5778#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5779pub enum PermissionRequestExtensionPermissionAccessKind {
5780    #[serde(rename = "extension-permission-access")]
5781    #[default]
5782    ExtensionPermissionAccess,
5783}
5784
5785/// Details of the permission being requested
5786#[derive(Debug, Clone, Serialize, Deserialize)]
5787#[serde(untagged)]
5788pub enum PermissionRequest {
5789    Shell(PermissionRequestShell),
5790    Write(PermissionRequestWrite),
5791    Read(PermissionRequestRead),
5792    Mcp(PermissionRequestMcp),
5793    Url(PermissionRequestUrl),
5794    Memory(PermissionRequestMemory),
5795    CustomTool(PermissionRequestCustomTool),
5796    Hook(PermissionRequestHook),
5797    ExtensionManagement(PermissionRequestExtensionManagement),
5798    Factory(PermissionRequestFactory),
5799    ExtensionPermissionAccess(PermissionRequestExtensionPermissionAccess),
5800}
5801
5802/// 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.
5803///
5804/// <div class="warning">
5805///
5806/// **Experimental.** This type is part of an experimental wire-protocol surface
5807/// and may change or be removed in future SDK or CLI releases.
5808///
5809/// </div>
5810#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5811pub enum AutoApprovalJudgeFailureReason {
5812    /// The judge model call exceeded its deadline.
5813    #[serde(rename = "timeout")]
5814    Timeout,
5815    /// The judge model call was cancelled before it returned.
5816    #[serde(rename = "abort")]
5817    Abort,
5818    /// The judge model call completed but returned no content.
5819    #[serde(rename = "empty_response")]
5820    EmptyResponse,
5821    /// The judge model call failed (for example a transport, authentication, or rate-limit error).
5822    #[serde(rename = "model_error")]
5823    ModelError,
5824    /// The judge model replied, but the reply carried no ALLOW/DENY verdict.
5825    #[serde(rename = "parse_error")]
5826    ParseError,
5827    /// Unknown variant for forward compatibility.
5828    #[default]
5829    #[serde(other)]
5830    Unknown,
5831}
5832
5833/// 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).
5834///
5835/// <div class="warning">
5836///
5837/// **Experimental.** This type is part of an experimental wire-protocol surface
5838/// and may change or be removed in future SDK or CLI releases.
5839///
5840/// </div>
5841#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5842pub enum AutoApprovalRecommendation {
5843    /// The judge evaluated the request and recommends automatically approving it.
5844    #[serde(rename = "approve")]
5845    Approve,
5846    /// 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.
5847    #[serde(rename = "requireApproval")]
5848    RequireApproval,
5849    /// Auto mode is enabled, but this request category is never auto-approvable (for example, sandbox-bypass requests), so the judge was not consulted.
5850    #[serde(rename = "excluded")]
5851    Excluded,
5852    /// The judge was consulted but did not return a usable recommendation, so the request requires explicit approval.
5853    #[serde(rename = "error")]
5854    Error,
5855    /// Unknown variant for forward compatibility.
5856    #[default]
5857    #[serde(other)]
5858    Unknown,
5859}
5860
5861/// Prompt kind discriminator
5862#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5863pub enum PermissionPromptRequestCommandsKind {
5864    #[serde(rename = "commands")]
5865    #[default]
5866    Commands,
5867}
5868
5869/// Prompt kind discriminator
5870#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5871pub enum PermissionPromptRequestWriteKind {
5872    #[serde(rename = "write")]
5873    #[default]
5874    Write,
5875}
5876
5877/// Prompt kind discriminator
5878#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5879pub enum PermissionPromptRequestReadKind {
5880    #[serde(rename = "read")]
5881    #[default]
5882    Read,
5883}
5884
5885/// Prompt kind discriminator
5886#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5887pub enum PermissionPromptRequestMcpKind {
5888    #[serde(rename = "mcp")]
5889    #[default]
5890    Mcp,
5891}
5892
5893/// Prompt kind discriminator
5894#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5895pub enum PermissionPromptRequestUrlKind {
5896    #[serde(rename = "url")]
5897    #[default]
5898    Url,
5899}
5900
5901/// Prompt kind discriminator
5902#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5903pub enum PermissionPromptRequestMemoryKind {
5904    #[serde(rename = "memory")]
5905    #[default]
5906    Memory,
5907}
5908
5909/// Prompt kind discriminator
5910#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5911pub enum PermissionPromptRequestCustomToolKind {
5912    #[serde(rename = "custom-tool")]
5913    #[default]
5914    CustomTool,
5915}
5916
5917/// Underlying permission kind that needs path approval
5918#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5919pub enum PermissionPromptRequestPathAccessKind {
5920    /// Read access to a filesystem path.
5921    #[serde(rename = "read")]
5922    Read,
5923    /// Shell command access involving a filesystem path.
5924    #[serde(rename = "shell")]
5925    Shell,
5926    /// Write access to a filesystem path.
5927    #[serde(rename = "write")]
5928    Write,
5929    /// Unknown variant for forward compatibility.
5930    #[default]
5931    #[serde(other)]
5932    Unknown,
5933}
5934
5935/// Prompt kind discriminator
5936#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5937pub enum PermissionPromptRequestPathKind {
5938    #[serde(rename = "path")]
5939    #[default]
5940    Path,
5941}
5942
5943/// Prompt kind discriminator
5944#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5945pub enum PermissionPromptRequestHookKind {
5946    #[serde(rename = "hook")]
5947    #[default]
5948    Hook,
5949}
5950
5951/// Prompt kind discriminator
5952#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5953pub enum PermissionPromptRequestExtensionManagementKind {
5954    #[serde(rename = "extension-management")]
5955    #[default]
5956    ExtensionManagement,
5957}
5958
5959/// Prompt kind discriminator
5960#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5961pub enum PermissionPromptRequestFactoryKind {
5962    #[serde(rename = "factory")]
5963    #[default]
5964    Factory,
5965}
5966
5967/// Prompt kind discriminator
5968#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5969pub enum PermissionPromptRequestExtensionPermissionAccessKind {
5970    #[serde(rename = "extension-permission-access")]
5971    #[default]
5972    ExtensionPermissionAccess,
5973}
5974
5975/// Derived user-facing permission prompt details for UI consumers
5976#[derive(Debug, Clone, Serialize, Deserialize)]
5977#[serde(untagged)]
5978pub enum PermissionPromptRequest {
5979    Commands(PermissionPromptRequestCommands),
5980    Write(PermissionPromptRequestWrite),
5981    Read(PermissionPromptRequestRead),
5982    Mcp(PermissionPromptRequestMcp),
5983    Url(PermissionPromptRequestUrl),
5984    Memory(PermissionPromptRequestMemory),
5985    CustomTool(PermissionPromptRequestCustomTool),
5986    Path(PermissionPromptRequestPath),
5987    Hook(PermissionPromptRequestHook),
5988    ExtensionManagement(PermissionPromptRequestExtensionManagement),
5989    Factory(PermissionPromptRequestFactory),
5990    ExtensionPermissionAccess(PermissionPromptRequestExtensionPermissionAccess),
5991}
5992
5993/// The permission request was approved
5994#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5995pub enum PermissionApprovedKind {
5996    #[serde(rename = "approved")]
5997    #[default]
5998    Approved,
5999}
6000
6001/// Command approval kind
6002#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6003pub enum UserToolSessionApprovalCommandsKind {
6004    #[serde(rename = "commands")]
6005    #[default]
6006    Commands,
6007}
6008
6009/// Read approval kind
6010#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6011pub enum UserToolSessionApprovalReadKind {
6012    #[serde(rename = "read")]
6013    #[default]
6014    Read,
6015}
6016
6017/// Write approval kind
6018#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6019pub enum UserToolSessionApprovalWriteKind {
6020    #[serde(rename = "write")]
6021    #[default]
6022    Write,
6023}
6024
6025/// MCP tool approval kind
6026#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6027pub enum UserToolSessionApprovalMcpKind {
6028    #[serde(rename = "mcp")]
6029    #[default]
6030    Mcp,
6031}
6032
6033/// Memory approval kind
6034#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6035pub enum UserToolSessionApprovalMemoryKind {
6036    #[serde(rename = "memory")]
6037    #[default]
6038    Memory,
6039}
6040
6041/// Custom tool approval kind
6042#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6043pub enum UserToolSessionApprovalCustomToolKind {
6044    #[serde(rename = "custom-tool")]
6045    #[default]
6046    CustomTool,
6047}
6048
6049/// Extension management approval kind
6050#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6051pub enum UserToolSessionApprovalExtensionManagementKind {
6052    #[serde(rename = "extension-management")]
6053    #[default]
6054    ExtensionManagement,
6055}
6056
6057/// Factory approval kind
6058#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6059pub enum UserToolSessionApprovalFactoryKind {
6060    #[serde(rename = "factory")]
6061    #[default]
6062    Factory,
6063}
6064
6065/// Extension permission access approval kind
6066#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6067pub enum UserToolSessionApprovalExtensionPermissionAccessKind {
6068    #[serde(rename = "extension-permission-access")]
6069    #[default]
6070    ExtensionPermissionAccess,
6071}
6072
6073/// The approval to add as a session-scoped rule
6074#[derive(Debug, Clone, Serialize, Deserialize)]
6075#[serde(untagged)]
6076pub enum UserToolSessionApproval {
6077    Commands(UserToolSessionApprovalCommands),
6078    Read(UserToolSessionApprovalRead),
6079    Write(UserToolSessionApprovalWrite),
6080    Mcp(UserToolSessionApprovalMcp),
6081    Memory(UserToolSessionApprovalMemory),
6082    CustomTool(UserToolSessionApprovalCustomTool),
6083    ExtensionManagement(UserToolSessionApprovalExtensionManagement),
6084    Factory(UserToolSessionApprovalFactory),
6085    ExtensionPermissionAccess(UserToolSessionApprovalExtensionPermissionAccess),
6086}
6087
6088/// Approved and remembered for the rest of the session
6089#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6090pub enum PermissionApprovedForSessionKind {
6091    #[serde(rename = "approved-for-session")]
6092    #[default]
6093    ApprovedForSession,
6094}
6095
6096/// Approved and persisted for this project location
6097#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6098pub enum PermissionApprovedForLocationKind {
6099    #[serde(rename = "approved-for-location")]
6100    #[default]
6101    ApprovedForLocation,
6102}
6103
6104/// The permission request was cancelled before a response was used
6105#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6106pub enum PermissionCancelledKind {
6107    #[serde(rename = "cancelled")]
6108    #[default]
6109    Cancelled,
6110}
6111
6112/// Denied because approval rules explicitly blocked it
6113#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6114pub enum PermissionDeniedByRulesKind {
6115    #[serde(rename = "denied-by-rules")]
6116    #[default]
6117    DeniedByRules,
6118}
6119
6120/// Denied because no approval rule matched and user confirmation was unavailable
6121#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6122pub enum PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind {
6123    #[serde(rename = "denied-no-approval-rule-and-could-not-request-from-user")]
6124    #[default]
6125    DeniedNoApprovalRuleAndCouldNotRequestFromUser,
6126}
6127
6128/// Denied by the user during an interactive prompt
6129#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6130pub enum PermissionDeniedInteractivelyByUserKind {
6131    #[serde(rename = "denied-interactively-by-user")]
6132    #[default]
6133    DeniedInteractivelyByUser,
6134}
6135
6136/// Denied by the organization's content exclusion policy
6137#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6138pub enum PermissionDeniedByContentExclusionPolicyKind {
6139    #[serde(rename = "denied-by-content-exclusion-policy")]
6140    #[default]
6141    DeniedByContentExclusionPolicy,
6142}
6143
6144/// Denied by a permission request hook registered by an extension or plugin
6145#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6146pub enum PermissionDeniedByPermissionRequestHookKind {
6147    #[serde(rename = "denied-by-permission-request-hook")]
6148    #[default]
6149    DeniedByPermissionRequestHook,
6150}
6151
6152/// The result of the permission request
6153#[derive(Debug, Clone, Serialize, Deserialize)]
6154#[serde(untagged)]
6155pub enum PermissionResult {
6156    Approved(PermissionApproved),
6157    ApprovedForSession(PermissionApprovedForSession),
6158    ApprovedForLocation(PermissionApprovedForLocation),
6159    Cancelled(PermissionCancelled),
6160    DeniedByRules(PermissionDeniedByRules),
6161    DeniedNoApprovalRuleAndCouldNotRequestFromUser(
6162        PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser,
6163    ),
6164    DeniedInteractivelyByUser(PermissionDeniedInteractivelyByUser),
6165    DeniedByContentExclusionPolicy(PermissionDeniedByContentExclusionPolicy),
6166    DeniedByPermissionRequestHook(PermissionDeniedByPermissionRequestHook),
6167}
6168
6169/// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
6170#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6171pub enum ElicitationRequestedMode {
6172    /// Structured form-based elicitation.
6173    #[serde(rename = "form")]
6174    Form,
6175    /// Browser URL-based elicitation.
6176    #[serde(rename = "url")]
6177    Url,
6178    /// Unknown variant for forward compatibility.
6179    #[default]
6180    #[serde(other)]
6181    Unknown,
6182}
6183
6184/// Schema type indicator (always 'object')
6185#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6186pub enum ElicitationRequestedSchemaType {
6187    #[serde(rename = "object")]
6188    #[default]
6189    Object,
6190}
6191
6192/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
6193#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6194pub enum ElicitationCompletedAction {
6195    /// The user submitted the requested form.
6196    #[serde(rename = "accept")]
6197    Accept,
6198    /// The user explicitly declined the request.
6199    #[serde(rename = "decline")]
6200    Decline,
6201    /// The user dismissed the request.
6202    #[serde(rename = "cancel")]
6203    Cancel,
6204    /// Unknown variant for forward compatibility.
6205    #[default]
6206    #[serde(other)]
6207    Unknown,
6208}
6209
6210/// Reason the runtime is requesting host-provided MCP OAuth credentials
6211#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6212pub enum McpOauthRequestReason {
6213    /// Initial credentials are required before connecting to the MCP server.
6214    #[serde(rename = "initial")]
6215    Initial,
6216    /// The current host-provided credential was rejected and a replacement is requested.
6217    #[serde(rename = "refresh")]
6218    Refresh,
6219    /// The server requires a new host authorization flow before continuing.
6220    #[serde(rename = "reauth")]
6221    Reauth,
6222    /// The server requires a credential with additional scope or audience.
6223    #[serde(rename = "upscope")]
6224    Upscope,
6225    /// Unknown variant for forward compatibility.
6226    #[default]
6227    #[serde(other)]
6228    Unknown,
6229}
6230
6231/// 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).
6232#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6233pub enum McpOauthRequiredStaticClientConfigGrantType {
6234    #[serde(rename = "client_credentials")]
6235    #[default]
6236    ClientCredentials,
6237}
6238
6239/// How the pending MCP OAuth request was completed
6240#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6241pub enum McpOauthCompletionOutcome {
6242    /// The request completed with a token-backed OAuth provider.
6243    #[serde(rename = "token")]
6244    Token,
6245    /// The request completed without an OAuth provider.
6246    #[serde(rename = "cancelled")]
6247    Cancelled,
6248    /// Unknown variant for forward compatibility.
6249    #[default]
6250    #[serde(other)]
6251    Unknown,
6252}
6253
6254/// Why dynamic headers are being requested.
6255#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6256pub enum McpHeadersRefreshRequiredReason {
6257    /// The transport is making its first dynamic header request for this server.
6258    #[serde(rename = "startup")]
6259    Startup,
6260    /// The previously cached dynamic headers expired.
6261    #[serde(rename = "ttl-expired")]
6262    TtlExpired,
6263    /// The server returned 401 and stale dynamic headers were invalidated.
6264    #[serde(rename = "auth-failed")]
6265    AuthFailed,
6266    /// Unknown variant for forward compatibility.
6267    #[default]
6268    #[serde(other)]
6269    Unknown,
6270}
6271
6272/// How the pending MCP headers refresh request resolved.
6273#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6274pub enum McpHeadersRefreshCompletedOutcome {
6275    /// The host supplied dynamic headers.
6276    #[serde(rename = "headers")]
6277    Headers,
6278    /// The host responded with no dynamic headers.
6279    #[serde(rename = "none")]
6280    None,
6281    /// No response arrived within the bounded window.
6282    #[serde(rename = "timeout")]
6283    Timeout,
6284    /// Unknown variant for forward compatibility.
6285    #[default]
6286    #[serde(other)]
6287    Unknown,
6288}
6289
6290/// The user's auto-mode-switch choice
6291#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6292pub enum AutoModeSwitchResponse {
6293    /// Switch models for this request.
6294    #[serde(rename = "yes")]
6295    Yes,
6296    /// Switch models now and keep using the replacement automatically.
6297    #[serde(rename = "yes_always")]
6298    YesAlways,
6299    /// Do not switch models.
6300    #[serde(rename = "no")]
6301    No,
6302    /// Unknown variant for forward compatibility.
6303    #[default]
6304    #[serde(other)]
6305    Unknown,
6306}
6307
6308/// User action selected for an exhausted session limit.
6309#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6310pub enum SessionLimitsExhaustedResponseAction {
6311    /// Increase the current max by an exact AI Credits amount.
6312    #[serde(rename = "add")]
6313    Add,
6314    /// Set a new absolute max AI Credits value.
6315    #[serde(rename = "set")]
6316    Set,
6317    /// Remove the current session limit.
6318    #[serde(rename = "unset")]
6319    Unset,
6320    /// Leave the limit unchanged and cancel the blocked model request.
6321    #[serde(rename = "cancel")]
6322    Cancel,
6323    /// Unknown variant for forward compatibility.
6324    #[default]
6325    #[serde(other)]
6326    Unknown,
6327}
6328
6329/// Coarse request-difficulty bucket for UX explainability
6330#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6331pub enum AutoModeResolvedReasoningBucket {
6332    /// The request looks low-reasoning; a lighter model is appropriate.
6333    #[serde(rename = "low")]
6334    Low,
6335    /// The request needs a moderate amount of reasoning.
6336    #[serde(rename = "medium")]
6337    Medium,
6338    /// The request looks high-reasoning; a stronger model is appropriate.
6339    #[serde(rename = "high")]
6340    High,
6341    /// Unknown variant for forward compatibility.
6342    #[default]
6343    #[serde(other)]
6344    Unknown,
6345}
6346
6347/// Summary of which managed-settings channels contributed to the effective session policy. Use the per-channel booleans for exact provenance.
6348#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6349pub enum ManagedSettingsResolvedSource {
6350    /// Only the server/account channel contributed.
6351    #[serde(rename = "server")]
6352    Server,
6353    /// Only the device MDM/plist/registry/file channel contributed.
6354    #[serde(rename = "device")]
6355    Device,
6356    /// Only session-local SDK-host injection contributed.
6357    #[serde(rename = "client")]
6358    Client,
6359    /// More than one channel contributed. Ordinary keys resolve device over server per key, while permissions compose restrictively across all present layers.
6360    #[serde(rename = "mixed")]
6361    Mixed,
6362    /// No managed policy is in force (no channel contributed).
6363    #[serde(rename = "none")]
6364    None,
6365    /// Unknown variant for forward compatibility.
6366    #[default]
6367    #[serde(other)]
6368    Unknown,
6369}
6370
6371/// The category of runtime action that enterprise managed settings governed (blocked or capped)
6372#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6373pub enum ManagedSettingsEnforcedAction {
6374    /// An attempt to turn on a bypass-permissions ("yolo") escalation was refused or capped because policy disables bypass-permissions mode.
6375    #[serde(rename = "bypass_permissions_blocked")]
6376    BypassPermissionsBlocked,
6377    /// Unknown variant for forward compatibility.
6378    #[default]
6379    #[serde(other)]
6380    Unknown,
6381}
6382
6383/// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused
6384#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6385pub enum ManagedSettingsEnforcedEscalation {
6386    /// Full allow-all ("/allow-all on") permissions — auto-approving tools, paths, and URLs.
6387    #[serde(rename = "allow_all")]
6388    AllowAll,
6389    /// Auto-approval of all tool permission requests.
6390    #[serde(rename = "approve_all")]
6391    ApproveAll,
6392    /// Advisory auto-approval ("/allow-all auto") mode — keeps normal prompt paths and adds LLM-advised approval, distinct from full allow-all.
6393    #[serde(rename = "auto_approval")]
6394    AutoApproval,
6395    /// Unrestricted filesystem access outside the session's allowed directories.
6396    #[serde(rename = "unrestricted_paths")]
6397    UnrestrictedPaths,
6398    /// Unrestricted URL fetch access.
6399    #[serde(rename = "unrestricted_urls")]
6400    UnrestrictedUrls,
6401    /// Unknown variant for forward compatibility.
6402    #[default]
6403    #[serde(other)]
6404    Unknown,
6405}
6406
6407/// Exit plan mode action
6408#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6409pub enum ExitPlanModeAction {
6410    /// Exit plan mode without starting implementation.
6411    #[serde(rename = "exit_only")]
6412    ExitOnly,
6413    /// Exit plan mode and continue in interactive mode.
6414    #[serde(rename = "interactive")]
6415    Interactive,
6416    /// Exit plan mode and continue autonomously.
6417    #[serde(rename = "autopilot")]
6418    Autopilot,
6419    /// Exit plan mode and continue with parallel autonomous workers.
6420    #[serde(rename = "autopilot_fleet")]
6421    AutopilotFleet,
6422    /// Unknown variant for forward compatibility.
6423    #[default]
6424    #[serde(other)]
6425    Unknown,
6426}
6427
6428/// Source location type (e.g., project, personal-copilot, plugin, builtin)
6429#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6430pub enum SkillSource {
6431    /// Skill defined in the current project's skill directories.
6432    #[serde(rename = "project")]
6433    Project,
6434    /// Skill discovered from a parent directory in the current workspace tree.
6435    #[serde(rename = "inherited")]
6436    Inherited,
6437    /// Skill defined in the user's Copilot skill directory.
6438    #[serde(rename = "personal-copilot")]
6439    PersonalCopilot,
6440    /// Skill defined in the user's personal agents skill directory.
6441    #[serde(rename = "personal-agents")]
6442    PersonalAgents,
6443    /// Skill provided by an installed plugin.
6444    #[serde(rename = "plugin")]
6445    Plugin,
6446    /// Skill loaded from a configured custom skill directory.
6447    #[serde(rename = "custom")]
6448    Custom,
6449    /// Skill bundled with the runtime.
6450    #[serde(rename = "builtin")]
6451    Builtin,
6452    /// Unknown variant for forward compatibility.
6453    #[default]
6454    #[serde(other)]
6455    Unknown,
6456}
6457
6458/// Configuration source: user, workspace, plugin, or builtin
6459#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6460pub enum McpServerSource {
6461    /// Server configured in the user's global MCP configuration.
6462    #[serde(rename = "user")]
6463    User,
6464    /// Server configured by the current workspace.
6465    #[serde(rename = "workspace")]
6466    Workspace,
6467    /// Server contributed by an installed plugin.
6468    #[serde(rename = "plugin")]
6469    Plugin,
6470    /// Server bundled with the runtime.
6471    #[serde(rename = "builtin")]
6472    Builtin,
6473    /// Unknown variant for forward compatibility.
6474    #[default]
6475    #[serde(other)]
6476    Unknown,
6477}
6478
6479/// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
6480#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6481pub enum McpServerStatus {
6482    /// The server is connected and available.
6483    #[serde(rename = "connected")]
6484    Connected,
6485    /// The server failed to connect or initialize.
6486    #[serde(rename = "failed")]
6487    Failed,
6488    /// The server requires authentication before it can connect.
6489    #[serde(rename = "needs-auth")]
6490    NeedsAuth,
6491    /// The server connection is still being established.
6492    #[serde(rename = "pending")]
6493    Pending,
6494    /// The server is configured but disabled.
6495    #[serde(rename = "disabled")]
6496    Disabled,
6497    /// 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.
6498    #[serde(rename = "stopped")]
6499    Stopped,
6500    /// The server is not configured for this session.
6501    #[serde(rename = "not_configured")]
6502    NotConfigured,
6503    /// Unknown variant for forward compatibility.
6504    #[default]
6505    #[serde(other)]
6506    Unknown,
6507}
6508
6509/// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
6510#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6511pub enum McpServerTransport {
6512    /// Server communicates over stdio with a local child process.
6513    #[serde(rename = "stdio")]
6514    Stdio,
6515    /// Server communicates over streamable HTTP.
6516    #[serde(rename = "http")]
6517    Http,
6518    /// Server communicates over Server-Sent Events (deprecated).
6519    #[serde(rename = "sse")]
6520    Sse,
6521    /// Server is backed by an in-memory runtime implementation.
6522    #[serde(rename = "memory")]
6523    Memory,
6524    /// Unknown variant for forward compatibility.
6525    #[default]
6526    #[serde(other)]
6527    Unknown,
6528}
6529
6530/// Discovery source
6531#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6532pub enum ExtensionsLoadedExtensionSource {
6533    /// Extension discovered from the current project.
6534    #[serde(rename = "project")]
6535    Project,
6536    /// Extension discovered from the user's extension directory.
6537    #[serde(rename = "user")]
6538    User,
6539    /// Extension contributed by an installed plugin.
6540    #[serde(rename = "plugin")]
6541    Plugin,
6542    /// Extension discovered from the current session's state directory.
6543    #[serde(rename = "session")]
6544    Session,
6545    /// Unknown variant for forward compatibility.
6546    #[default]
6547    #[serde(other)]
6548    Unknown,
6549}
6550
6551/// Current status: running, disabled, failed, or starting
6552#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
6553pub enum ExtensionsLoadedExtensionStatus {
6554    /// The extension process is running.
6555    #[serde(rename = "running")]
6556    Running,
6557    /// The extension is installed but disabled.
6558    #[serde(rename = "disabled")]
6559    Disabled,
6560    /// The extension failed to start or crashed.
6561    #[serde(rename = "failed")]
6562    Failed,
6563    /// The extension process is starting.
6564    #[serde(rename = "starting")]
6565    Starting,
6566    /// Unknown variant for forward compatibility.
6567    #[default]
6568    #[serde(other)]
6569    Unknown,
6570}