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