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