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