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.indexed_search")]
37    SessionIndexedSearch,
38    #[serde(rename = "session.warning")]
39    SessionWarning,
40    #[serde(rename = "session.model_change")]
41    SessionModelChange,
42    #[serde(rename = "session.model_deselected")]
43    SessionModelDeselected,
44    ///
45    /// <div class="warning">
46    ///
47    /// **Experimental.** This type is part of an experimental wire-protocol surface
48    /// and may change or be removed in future SDK or CLI releases.
49    ///
50    /// </div>
51    #[serde(rename = "session.auto_tier_recommendation")]
52    SessionAutoTierRecommendation,
53    #[serde(rename = "session.auto_tier_switch_failed")]
54    SessionAutoTierSwitchFailed,
55    #[serde(rename = "session.mode_changed")]
56    SessionModeChanged,
57    #[serde(rename = "session.mode_notice_delivered")]
58    SessionModeNoticeDelivered,
59    #[serde(rename = "session.session_limits_changed")]
60    SessionSessionLimitsChanged,
61    ///
62    /// <div class="warning">
63    ///
64    /// **Experimental.** This type is part of an experimental wire-protocol surface
65    /// and may change or be removed in future SDK or CLI releases.
66    ///
67    /// </div>
68    #[serde(rename = "session.permissions_changed")]
69    SessionPermissionsChanged,
70    #[serde(rename = "session.plan_changed")]
71    SessionPlanChanged,
72    #[serde(rename = "session.todos_changed")]
73    SessionTodosChanged,
74    #[serde(rename = "session.workspace_file_changed")]
75    SessionWorkspaceFileChanged,
76    #[serde(rename = "session.handoff")]
77    SessionHandoff,
78    #[serde(rename = "session.truncation")]
79    SessionTruncation,
80    #[serde(rename = "session.snapshot_rewind")]
81    SessionSnapshotRewind,
82    #[serde(rename = "session.shutdown")]
83    SessionShutdown,
84    #[serde(rename = "session.usage_checkpoint")]
85    SessionUsageCheckpoint,
86    #[serde(rename = "session.context_changed")]
87    SessionContextChanged,
88    #[serde(rename = "session.usage_info")]
89    SessionUsageInfo,
90    #[serde(rename = "session.context_cleared")]
91    SessionContextCleared,
92    #[serde(rename = "session.compaction_start")]
93    SessionCompactionStart,
94    #[serde(rename = "session.compaction_complete")]
95    SessionCompactionComplete,
96    #[serde(rename = "session.task_complete")]
97    SessionTaskComplete,
98    ///
99    /// <div class="warning">
100    ///
101    /// **Experimental.** This type is part of an experimental wire-protocol surface
102    /// and may change or be removed in future SDK or CLI releases.
103    ///
104    /// </div>
105    #[serde(rename = "session.completion_receipt")]
106    SessionCompletionReceipt,
107    ///
108    /// <div class="warning">
109    ///
110    /// **Experimental.** This type is part of an experimental wire-protocol surface
111    /// and may change or be removed in future SDK or CLI releases.
112    ///
113    /// </div>
114    #[serde(rename = "session.fusion_route_started")]
115    SessionFusionRouteStarted,
116    ///
117    /// <div class="warning">
118    ///
119    /// **Experimental.** This type is part of an experimental wire-protocol surface
120    /// and may change or be removed in future SDK or CLI releases.
121    ///
122    /// </div>
123    #[serde(rename = "session.fusion_route_failed")]
124    SessionFusionRouteFailed,
125    ///
126    /// <div class="warning">
127    ///
128    /// **Experimental.** This type is part of an experimental wire-protocol surface
129    /// and may change or be removed in future SDK or CLI releases.
130    ///
131    /// </div>
132    #[serde(rename = "session.fusion_resolved")]
133    SessionFusionResolved,
134    ///
135    /// <div class="warning">
136    ///
137    /// **Experimental.** This type is part of an experimental wire-protocol surface
138    /// and may change or be removed in future SDK or CLI releases.
139    ///
140    /// </div>
141    #[serde(rename = "session.fusion_completed")]
142    SessionFusionCompleted,
143    #[serde(rename = "session.permission_recovery")]
144    SessionPermissionRecovery,
145    #[serde(rename = "user.message")]
146    UserMessage,
147    #[serde(rename = "pending_messages.modified")]
148    PendingMessagesModified,
149    #[serde(rename = "assistant.turn_start")]
150    AssistantTurnStart,
151    #[serde(rename = "assistant.turn_retry")]
152    AssistantTurnRetry,
153    #[serde(rename = "agent.interrupted")]
154    AgentInterrupted,
155    #[serde(rename = "assistant.intent")]
156    AssistantIntent,
157    ///
158    /// <div class="warning">
159    ///
160    /// **Experimental.** This type is part of an experimental wire-protocol surface
161    /// and may change or be removed in future SDK or CLI releases.
162    ///
163    /// </div>
164    #[serde(rename = "assistant.fusion_phase_started")]
165    AssistantFusionPhaseStarted,
166    ///
167    /// <div class="warning">
168    ///
169    /// **Experimental.** This type is part of an experimental wire-protocol surface
170    /// and may change or be removed in future SDK or CLI releases.
171    ///
172    /// </div>
173    #[serde(rename = "assistant.fusion_phase_activity")]
174    AssistantFusionPhaseActivity,
175    ///
176    /// <div class="warning">
177    ///
178    /// **Experimental.** This type is part of an experimental wire-protocol surface
179    /// and may change or be removed in future SDK or CLI releases.
180    ///
181    /// </div>
182    #[serde(rename = "assistant.fusion_phase_completed")]
183    AssistantFusionPhaseCompleted,
184    ///
185    /// <div class="warning">
186    ///
187    /// **Experimental.** This type is part of an experimental wire-protocol surface
188    /// and may change or be removed in future SDK or CLI releases.
189    ///
190    /// </div>
191    #[serde(rename = "assistant.fusion_phase_failed")]
192    AssistantFusionPhaseFailed,
193    #[serde(rename = "assistant.server_tool_progress")]
194    AssistantServerToolProgress,
195    #[serde(rename = "assistant.reasoning")]
196    AssistantReasoning,
197    #[serde(rename = "assistant.reasoning_delta")]
198    AssistantReasoningDelta,
199    #[serde(rename = "assistant.tool_call_delta")]
200    AssistantToolCallDelta,
201    #[serde(rename = "assistant.streaming_delta")]
202    AssistantStreamingDelta,
203    #[serde(rename = "assistant.message")]
204    AssistantMessage,
205    #[serde(rename = "assistant.message_start")]
206    AssistantMessageStart,
207    #[serde(rename = "assistant.message_delta")]
208    AssistantMessageDelta,
209    #[serde(rename = "assistant.turn_end")]
210    AssistantTurnEnd,
211    #[serde(rename = "assistant.idle")]
212    AssistantIdle,
213    #[serde(rename = "assistant.usage")]
214    AssistantUsage,
215    #[serde(rename = "prompt_cache_break")]
216    PromptCacheBreak,
217    #[serde(rename = "model.call_failure")]
218    ModelCallFailure,
219    #[serde(rename = "model.call_finished")]
220    ModelCallFinished,
221    #[serde(rename = "model.call_start")]
222    ModelCallStart,
223    #[serde(rename = "abort")]
224    Abort,
225    #[serde(rename = "tool.user_requested")]
226    ToolUserRequested,
227    #[serde(rename = "tool.execution_start")]
228    ToolExecutionStart,
229    #[serde(rename = "tool.execution_partial_result")]
230    ToolExecutionPartialResult,
231    #[serde(rename = "tool.execution_progress")]
232    ToolExecutionProgress,
233    #[serde(rename = "tool.execution_complete")]
234    ToolExecutionComplete,
235    #[serde(rename = "tool_search.activated")]
236    ToolSearchActivated,
237    #[serde(rename = "skill.invoked")]
238    SkillInvoked,
239    ///
240    /// <div class="warning">
241    ///
242    /// **Experimental.** This type is part of an experimental wire-protocol surface
243    /// and may change or be removed in future SDK or CLI releases.
244    ///
245    /// </div>
246    #[serde(rename = "skill.invoked_ref")]
247    SkillInvokedRef,
248    ///
249    /// <div class="warning">
250    ///
251    /// **Experimental.** This type is part of an experimental wire-protocol surface
252    /// and may change or be removed in future SDK or CLI releases.
253    ///
254    /// </div>
255    #[serde(rename = "skill.context_delivered")]
256    SkillContextDelivered,
257    ///
258    /// <div class="warning">
259    ///
260    /// **Experimental.** This type is part of an experimental wire-protocol surface
261    /// and may change or be removed in future SDK or CLI releases.
262    ///
263    /// </div>
264    #[serde(rename = "skill.context_delivered_ref")]
265    SkillContextDeliveredRef,
266    #[serde(rename = "sandbox.decision")]
267    SandboxDecision,
268    #[serde(rename = "subagent.started")]
269    SubagentStarted,
270    #[serde(rename = "subagent.configured")]
271    SubagentConfigured,
272    #[serde(rename = "subagent.completed")]
273    SubagentCompleted,
274    #[serde(rename = "subagent.failed")]
275    SubagentFailed,
276    #[serde(rename = "subagent.selected")]
277    SubagentSelected,
278    #[serde(rename = "subagent.deselected")]
279    SubagentDeselected,
280    #[serde(rename = "hook.start")]
281    HookStart,
282    #[serde(rename = "hook.end")]
283    HookEnd,
284    #[serde(rename = "hook.progress")]
285    HookProgress,
286    ///
287    /// <div class="warning">
288    ///
289    /// **Experimental.** This type is part of an experimental wire-protocol surface
290    /// and may change or be removed in future SDK or CLI releases.
291    ///
292    /// </div>
293    #[serde(rename = "session.binary_asset")]
294    SessionBinaryAsset,
295    #[serde(rename = "system.message")]
296    SystemMessage,
297    #[serde(rename = "system.notification")]
298    SystemNotification,
299    #[serde(rename = "permission.requested")]
300    PermissionRequested,
301    #[serde(rename = "permission.completed")]
302    PermissionCompleted,
303    ///
304    /// <div class="warning">
305    ///
306    /// **Experimental.** This type is part of an experimental wire-protocol surface
307    /// and may change or be removed in future SDK or CLI releases.
308    ///
309    /// </div>
310    #[serde(rename = "permission.carriedForward")]
311    PermissionCarriedForward,
312    ///
313    /// <div class="warning">
314    ///
315    /// **Experimental.** This type is part of an experimental wire-protocol surface
316    /// and may change or be removed in future SDK or CLI releases.
317    ///
318    /// </div>
319    #[serde(rename = "permission.messageAuthorization")]
320    PermissionMessageAuthorization,
321    ///
322    /// <div class="warning">
323    ///
324    /// **Experimental.** This type is part of an experimental wire-protocol surface
325    /// and may change or be removed in future SDK or CLI releases.
326    ///
327    /// </div>
328    #[serde(rename = "permission.messageAuthorizationRead")]
329    PermissionMessageAuthorizationRead,
330    ///
331    /// <div class="warning">
332    ///
333    /// **Experimental.** This type is part of an experimental wire-protocol surface
334    /// and may change or be removed in future SDK or CLI releases.
335    ///
336    /// </div>
337    #[serde(rename = "permission.messageAuthorizationDegraded")]
338    PermissionMessageAuthorizationDegraded,
339    ///
340    /// <div class="warning">
341    ///
342    /// **Experimental.** This type is part of an experimental wire-protocol surface
343    /// and may change or be removed in future SDK or CLI releases.
344    ///
345    /// </div>
346    #[serde(rename = "permission.assentDetected")]
347    PermissionAssentDetected,
348    ///
349    /// <div class="warning">
350    ///
351    /// **Experimental.** This type is part of an experimental wire-protocol surface
352    /// and may change or be removed in future SDK or CLI releases.
353    ///
354    /// </div>
355    #[serde(rename = "permission.contextualAuthorization")]
356    PermissionContextualAuthorization,
357    #[serde(rename = "user_input.requested")]
358    UserInputRequested,
359    #[serde(rename = "user_input.completed")]
360    UserInputCompleted,
361    #[serde(rename = "elicitation.requested")]
362    ElicitationRequested,
363    #[serde(rename = "elicitation.completed")]
364    ElicitationCompleted,
365    #[serde(rename = "sampling.requested")]
366    SamplingRequested,
367    #[serde(rename = "sampling.completed")]
368    SamplingCompleted,
369    #[serde(rename = "mcp.oauth_required")]
370    McpOauthRequired,
371    #[serde(rename = "mcp.oauth_completed")]
372    McpOauthCompleted,
373    #[serde(rename = "mcp.headers_refresh_required")]
374    McpHeadersRefreshRequired,
375    #[serde(rename = "mcp.headers_refresh_completed")]
376    McpHeadersRefreshCompleted,
377    #[serde(rename = "session.custom_notification")]
378    SessionCustomNotification,
379    ///
380    /// <div class="warning">
381    ///
382    /// **Experimental.** This type is part of an experimental wire-protocol surface
383    /// and may change or be removed in future SDK or CLI releases.
384    ///
385    /// </div>
386    #[serde(rename = "ui.ephemeral_query")]
387    UiEphemeralQuery,
388    #[serde(rename = "external_tool.requested")]
389    ExternalToolRequested,
390    #[serde(rename = "external_tool.completed")]
391    ExternalToolCompleted,
392    #[serde(rename = "command.queued")]
393    CommandQueued,
394    #[serde(rename = "command.execute")]
395    CommandExecute,
396    #[serde(rename = "command.completed")]
397    CommandCompleted,
398    #[serde(rename = "auto_mode_switch.requested")]
399    AutoModeSwitchRequested,
400    #[serde(rename = "auto_mode_switch.completed")]
401    AutoModeSwitchCompleted,
402    #[serde(rename = "session_limits_exhausted.requested")]
403    SessionLimitsExhaustedRequested,
404    #[serde(rename = "session_limits_exhausted.completed")]
405    SessionLimitsExhaustedCompleted,
406    ///
407    /// <div class="warning">
408    ///
409    /// **Experimental.** This type is part of an experimental wire-protocol surface
410    /// and may change or be removed in future SDK or CLI releases.
411    ///
412    /// </div>
413    #[serde(rename = "session.auto_mode_resolved")]
414    SessionAutoModeResolved,
415    ///
416    /// <div class="warning">
417    ///
418    /// **Experimental.** This type is part of an experimental wire-protocol surface
419    /// and may change or be removed in future SDK or CLI releases.
420    ///
421    /// </div>
422    #[serde(rename = "session.managed_settings_resolved")]
423    SessionManagedSettingsResolved,
424    ///
425    /// <div class="warning">
426    ///
427    /// **Experimental.** This type is part of an experimental wire-protocol surface
428    /// and may change or be removed in future SDK or CLI releases.
429    ///
430    /// </div>
431    #[serde(rename = "session.managed_settings_enforced")]
432    SessionManagedSettingsEnforced,
433    #[serde(rename = "commands.changed")]
434    CommandsChanged,
435    #[serde(rename = "capabilities.changed")]
436    CapabilitiesChanged,
437    #[serde(rename = "exit_plan_mode.requested")]
438    ExitPlanModeRequested,
439    #[serde(rename = "exit_plan_mode.completed")]
440    ExitPlanModeCompleted,
441    #[serde(rename = "session.tools_updated")]
442    SessionToolsUpdated,
443    #[serde(rename = "session.background_tasks_changed")]
444    SessionBackgroundTasksChanged,
445    ///
446    /// <div class="warning">
447    ///
448    /// **Experimental.** This type is part of an experimental wire-protocol surface
449    /// and may change or be removed in future SDK or CLI releases.
450    ///
451    /// </div>
452    #[serde(rename = "factory.run_updated")]
453    FactoryRunUpdated,
454    ///
455    /// <div class="warning">
456    ///
457    /// **Experimental.** This type is part of an experimental wire-protocol surface
458    /// and may change or be removed in future SDK or CLI releases.
459    ///
460    /// </div>
461    #[serde(rename = "factory.run_started")]
462    FactoryRunStarted,
463    ///
464    /// <div class="warning">
465    ///
466    /// **Experimental.** This type is part of an experimental wire-protocol surface
467    /// and may change or be removed in future SDK or CLI releases.
468    ///
469    /// </div>
470    #[serde(rename = "factory.run_settled")]
471    FactoryRunSettled,
472    #[serde(rename = "session.skills_loaded")]
473    SessionSkillsLoaded,
474    #[serde(rename = "session.custom_agents_updated")]
475    SessionCustomAgentsUpdated,
476    #[serde(rename = "session.mcp_servers_loaded")]
477    SessionMcpServersLoaded,
478    #[serde(rename = "session.mcp_server_status_changed")]
479    SessionMcpServerStatusChanged,
480    #[serde(rename = "session.mcp_server_removed")]
481    SessionMcpServerRemoved,
482    #[serde(rename = "session.mcp_server_needs_reconnect")]
483    SessionMcpServerNeedsReconnect,
484    #[serde(rename = "mcp.tools.list_changed")]
485    McpToolsListChanged,
486    #[serde(rename = "mcp.resources.list_changed")]
487    McpResourcesListChanged,
488    #[serde(rename = "mcp.prompts.list_changed")]
489    McpPromptsListChanged,
490    #[serde(rename = "session.extensions_loaded")]
491    SessionExtensionsLoaded,
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.canvas.opened")]
500    SessionCanvasOpened,
501    ///
502    /// <div class="warning">
503    ///
504    /// **Experimental.** This type is part of an experimental wire-protocol surface
505    /// and may change or be removed in future SDK or CLI releases.
506    ///
507    /// </div>
508    #[serde(rename = "session.canvas.registry_changed")]
509    SessionCanvasRegistryChanged,
510    ///
511    /// <div class="warning">
512    ///
513    /// **Experimental.** This type is part of an experimental wire-protocol surface
514    /// and may change or be removed in future SDK or CLI releases.
515    ///
516    /// </div>
517    #[serde(rename = "session.canvas.closed")]
518    SessionCanvasClosed,
519    ///
520    /// <div class="warning">
521    ///
522    /// **Experimental.** This type is part of an experimental wire-protocol surface
523    /// and may change or be removed in future SDK or CLI releases.
524    ///
525    /// </div>
526    #[serde(rename = "session.canvas.unavailable")]
527    SessionCanvasUnavailable,
528    ///
529    /// <div class="warning">
530    ///
531    /// **Experimental.** This type is part of an experimental wire-protocol surface
532    /// and may change or be removed in future SDK or CLI releases.
533    ///
534    /// </div>
535    #[serde(rename = "session.canvas.recorded")]
536    SessionCanvasRecorded,
537    ///
538    /// <div class="warning">
539    ///
540    /// **Experimental.** This type is part of an experimental wire-protocol surface
541    /// and may change or be removed in future SDK or CLI releases.
542    ///
543    /// </div>
544    #[serde(rename = "session.canvas.removed")]
545    SessionCanvasRemoved,
546    #[serde(rename = "session.extensions.attachments_pushed")]
547    SessionExtensionsAttachmentsPushed,
548    #[serde(rename = "mcp_app.tool_call_complete")]
549    McpAppToolCallComplete,
550    /// Unknown event type for forward compatibility.
551    #[default]
552    #[serde(other)]
553    Unknown,
554}
555
556/// Typed session event data, discriminated by the event `type` field.
557///
558/// Use with [`TypedSessionEvent`] for fully typed event handling.
559#[derive(Debug, Clone, Serialize, Deserialize)]
560#[serde(tag = "type", content = "data")]
561pub enum SessionEventData {
562    #[serde(rename = "session.start")]
563    SessionStart(SessionStartData),
564    #[serde(rename = "session.resume")]
565    SessionResume(SessionResumeData),
566    #[serde(rename = "session.remote_steerable_changed")]
567    SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
568    #[serde(rename = "session.error")]
569    SessionError(SessionErrorData),
570    #[serde(rename = "session.idle")]
571    SessionIdle(SessionIdleData),
572    #[serde(rename = "session.title_changed")]
573    SessionTitleChanged(SessionTitleChangedData),
574    #[serde(rename = "session.schedule_created")]
575    SessionScheduleCreated(SessionScheduleCreatedData),
576    #[serde(rename = "session.schedule_cancelled")]
577    SessionScheduleCancelled(SessionScheduleCancelledData),
578    #[serde(rename = "session.schedule_rearmed")]
579    SessionScheduleRearmed(SessionScheduleRearmedData),
580    #[serde(rename = "session.autopilot_objective_changed")]
581    SessionAutopilotObjectiveChanged(SessionAutopilotObjectiveChangedData),
582    #[serde(rename = "session.info")]
583    SessionInfo(SessionInfoData),
584    #[serde(rename = "session.indexed_search")]
585    SessionIndexedSearch(SessionIndexedSearchData),
586    #[serde(rename = "session.warning")]
587    SessionWarning(SessionWarningData),
588    #[serde(rename = "session.model_change")]
589    SessionModelChange(SessionModelChangeData),
590    #[serde(rename = "session.model_deselected")]
591    SessionModelDeselected(SessionModelDeselectedData),
592    ///
593    /// <div class="warning">
594    ///
595    /// **Experimental.** This type is part of an experimental wire-protocol surface
596    /// and may change or be removed in future SDK or CLI releases.
597    ///
598    /// </div>
599    #[serde(rename = "session.auto_tier_recommendation")]
600    SessionAutoTierRecommendation(SessionAutoTierRecommendationData),
601    #[serde(rename = "session.auto_tier_switch_failed")]
602    SessionAutoTierSwitchFailed(SessionAutoTierSwitchFailedData),
603    #[serde(rename = "session.mode_changed")]
604    SessionModeChanged(SessionModeChangedData),
605    #[serde(rename = "session.mode_notice_delivered")]
606    SessionModeNoticeDelivered(SessionModeNoticeDeliveredData),
607    #[serde(rename = "session.session_limits_changed")]
608    SessionSessionLimitsChanged(SessionSessionLimitsChangedData),
609    ///
610    /// <div class="warning">
611    ///
612    /// **Experimental.** This type is part of an experimental wire-protocol surface
613    /// and may change or be removed in future SDK or CLI releases.
614    ///
615    /// </div>
616    #[serde(rename = "session.permissions_changed")]
617    SessionPermissionsChanged(SessionPermissionsChangedData),
618    #[serde(rename = "session.plan_changed")]
619    SessionPlanChanged(SessionPlanChangedData),
620    #[serde(rename = "session.todos_changed")]
621    SessionTodosChanged(SessionTodosChangedData),
622    #[serde(rename = "session.workspace_file_changed")]
623    SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
624    #[serde(rename = "session.handoff")]
625    SessionHandoff(SessionHandoffData),
626    #[serde(rename = "session.truncation")]
627    SessionTruncation(SessionTruncationData),
628    #[serde(rename = "session.snapshot_rewind")]
629    SessionSnapshotRewind(SessionSnapshotRewindData),
630    #[serde(rename = "session.shutdown")]
631    SessionShutdown(SessionShutdownData),
632    #[serde(rename = "session.usage_checkpoint")]
633    SessionUsageCheckpoint(SessionUsageCheckpointData),
634    #[serde(rename = "session.context_changed")]
635    SessionContextChanged(SessionContextChangedData),
636    #[serde(rename = "session.usage_info")]
637    SessionUsageInfo(SessionUsageInfoData),
638    #[serde(rename = "session.context_cleared")]
639    SessionContextCleared(SessionContextClearedData),
640    #[serde(rename = "session.compaction_start")]
641    SessionCompactionStart(SessionCompactionStartData),
642    #[serde(rename = "session.compaction_complete")]
643    SessionCompactionComplete(SessionCompactionCompleteData),
644    #[serde(rename = "session.task_complete")]
645    SessionTaskComplete(SessionTaskCompleteData),
646    ///
647    /// <div class="warning">
648    ///
649    /// **Experimental.** This type is part of an experimental wire-protocol surface
650    /// and may change or be removed in future SDK or CLI releases.
651    ///
652    /// </div>
653    #[serde(rename = "session.completion_receipt")]
654    SessionCompletionReceipt(SessionCompletionReceiptData),
655    ///
656    /// <div class="warning">
657    ///
658    /// **Experimental.** This type is part of an experimental wire-protocol surface
659    /// and may change or be removed in future SDK or CLI releases.
660    ///
661    /// </div>
662    #[serde(rename = "session.fusion_route_started")]
663    SessionFusionRouteStarted(SessionFusionRouteStartedData),
664    ///
665    /// <div class="warning">
666    ///
667    /// **Experimental.** This type is part of an experimental wire-protocol surface
668    /// and may change or be removed in future SDK or CLI releases.
669    ///
670    /// </div>
671    #[serde(rename = "session.fusion_route_failed")]
672    SessionFusionRouteFailed(SessionFusionRouteFailedData),
673    ///
674    /// <div class="warning">
675    ///
676    /// **Experimental.** This type is part of an experimental wire-protocol surface
677    /// and may change or be removed in future SDK or CLI releases.
678    ///
679    /// </div>
680    #[serde(rename = "session.fusion_resolved")]
681    SessionFusionResolved(SessionFusionResolvedData),
682    ///
683    /// <div class="warning">
684    ///
685    /// **Experimental.** This type is part of an experimental wire-protocol surface
686    /// and may change or be removed in future SDK or CLI releases.
687    ///
688    /// </div>
689    #[serde(rename = "session.fusion_completed")]
690    SessionFusionCompleted(SessionFusionCompletedData),
691    #[serde(rename = "session.permission_recovery")]
692    SessionPermissionRecovery(SessionPermissionRecoveryData),
693    #[serde(rename = "user.message")]
694    UserMessage(UserMessageData),
695    #[serde(rename = "pending_messages.modified")]
696    PendingMessagesModified(PendingMessagesModifiedData),
697    #[serde(rename = "assistant.turn_start")]
698    AssistantTurnStart(AssistantTurnStartData),
699    #[serde(rename = "assistant.turn_retry")]
700    AssistantTurnRetry(AssistantTurnRetryData),
701    #[serde(rename = "agent.interrupted")]
702    AgentInterrupted(AgentInterruptedData),
703    #[serde(rename = "assistant.intent")]
704    AssistantIntent(AssistantIntentData),
705    ///
706    /// <div class="warning">
707    ///
708    /// **Experimental.** This type is part of an experimental wire-protocol surface
709    /// and may change or be removed in future SDK or CLI releases.
710    ///
711    /// </div>
712    #[serde(rename = "assistant.fusion_phase_started")]
713    AssistantFusionPhaseStarted(AssistantFusionPhaseStartedData),
714    ///
715    /// <div class="warning">
716    ///
717    /// **Experimental.** This type is part of an experimental wire-protocol surface
718    /// and may change or be removed in future SDK or CLI releases.
719    ///
720    /// </div>
721    #[serde(rename = "assistant.fusion_phase_activity")]
722    AssistantFusionPhaseActivity(AssistantFusionPhaseActivityData),
723    ///
724    /// <div class="warning">
725    ///
726    /// **Experimental.** This type is part of an experimental wire-protocol surface
727    /// and may change or be removed in future SDK or CLI releases.
728    ///
729    /// </div>
730    #[serde(rename = "assistant.fusion_phase_completed")]
731    AssistantFusionPhaseCompleted(AssistantFusionPhaseCompletedData),
732    ///
733    /// <div class="warning">
734    ///
735    /// **Experimental.** This type is part of an experimental wire-protocol surface
736    /// and may change or be removed in future SDK or CLI releases.
737    ///
738    /// </div>
739    #[serde(rename = "assistant.fusion_phase_failed")]
740    AssistantFusionPhaseFailed(AssistantFusionPhaseFailedData),
741    #[serde(rename = "assistant.server_tool_progress")]
742    AssistantServerToolProgress(AssistantServerToolProgressData),
743    #[serde(rename = "assistant.reasoning")]
744    AssistantReasoning(AssistantReasoningData),
745    #[serde(rename = "assistant.reasoning_delta")]
746    AssistantReasoningDelta(AssistantReasoningDeltaData),
747    #[serde(rename = "assistant.tool_call_delta")]
748    AssistantToolCallDelta(AssistantToolCallDeltaData),
749    #[serde(rename = "assistant.streaming_delta")]
750    AssistantStreamingDelta(AssistantStreamingDeltaData),
751    #[serde(rename = "assistant.message")]
752    AssistantMessage(AssistantMessageData),
753    #[serde(rename = "assistant.message_start")]
754    AssistantMessageStart(AssistantMessageStartData),
755    #[serde(rename = "assistant.message_delta")]
756    AssistantMessageDelta(AssistantMessageDeltaData),
757    #[serde(rename = "assistant.turn_end")]
758    AssistantTurnEnd(AssistantTurnEndData),
759    #[serde(rename = "assistant.idle")]
760    AssistantIdle(AssistantIdleData),
761    #[serde(rename = "assistant.usage")]
762    AssistantUsage(AssistantUsageData),
763    #[serde(rename = "prompt_cache_break")]
764    PromptCacheBreak(PromptCacheBreakData),
765    #[serde(rename = "model.call_failure")]
766    ModelCallFailure(ModelCallFailureData),
767    #[serde(rename = "model.call_finished")]
768    ModelCallFinished(ModelCallFinishedData),
769    #[serde(rename = "model.call_start")]
770    ModelCallStart(ModelCallStartData),
771    #[serde(rename = "abort")]
772    Abort(AbortData),
773    #[serde(rename = "tool.user_requested")]
774    ToolUserRequested(ToolUserRequestedData),
775    #[serde(rename = "tool.execution_start")]
776    ToolExecutionStart(ToolExecutionStartData),
777    #[serde(rename = "tool.execution_partial_result")]
778    ToolExecutionPartialResult(ToolExecutionPartialResultData),
779    #[serde(rename = "tool.execution_progress")]
780    ToolExecutionProgress(ToolExecutionProgressData),
781    #[serde(rename = "tool.execution_complete")]
782    ToolExecutionComplete(ToolExecutionCompleteData),
783    #[serde(rename = "tool_search.activated")]
784    ToolSearchActivated(ToolSearchActivatedData),
785    #[serde(rename = "skill.invoked")]
786    SkillInvoked(SkillInvokedData),
787    #[serde(rename = "skill.invoked_ref")]
788    SkillInvokedRef(SkillInvokedRefData),
789    #[serde(rename = "skill.context_delivered")]
790    SkillContextDelivered(SkillContextDeliveredData),
791    #[serde(rename = "skill.context_delivered_ref")]
792    SkillContextDeliveredRef(SkillContextDeliveredRefData),
793    #[serde(rename = "sandbox.decision")]
794    SandboxDecision(SandboxDecisionData),
795    #[serde(rename = "subagent.started")]
796    SubagentStarted(SubagentStartedData),
797    #[serde(rename = "subagent.configured")]
798    SubagentConfigured(SubagentConfiguredData),
799    #[serde(rename = "subagent.completed")]
800    SubagentCompleted(SubagentCompletedData),
801    #[serde(rename = "subagent.failed")]
802    SubagentFailed(SubagentFailedData),
803    #[serde(rename = "subagent.selected")]
804    SubagentSelected(SubagentSelectedData),
805    #[serde(rename = "subagent.deselected")]
806    SubagentDeselected(SubagentDeselectedData),
807    #[serde(rename = "hook.start")]
808    HookStart(HookStartData),
809    #[serde(rename = "hook.end")]
810    HookEnd(HookEndData),
811    #[serde(rename = "hook.progress")]
812    HookProgress(HookProgressData),
813    #[serde(rename = "session.binary_asset")]
814    SessionBinaryAsset(SessionBinaryAssetData),
815    #[serde(rename = "system.message")]
816    SystemMessage(SystemMessageData),
817    #[serde(rename = "system.notification")]
818    SystemNotification(SystemNotificationData),
819    #[serde(rename = "permission.requested")]
820    PermissionRequested(PermissionRequestedData),
821    #[serde(rename = "permission.completed")]
822    PermissionCompleted(PermissionCompletedData),
823    ///
824    /// <div class="warning">
825    ///
826    /// **Experimental.** This type is part of an experimental wire-protocol surface
827    /// and may change or be removed in future SDK or CLI releases.
828    ///
829    /// </div>
830    #[serde(rename = "permission.carriedForward")]
831    PermissionCarriedForward(PermissionCarriedForwardData),
832    ///
833    /// <div class="warning">
834    ///
835    /// **Experimental.** This type is part of an experimental wire-protocol surface
836    /// and may change or be removed in future SDK or CLI releases.
837    ///
838    /// </div>
839    #[serde(rename = "permission.messageAuthorization")]
840    PermissionMessageAuthorization(PermissionMessageAuthorizationData),
841    ///
842    /// <div class="warning">
843    ///
844    /// **Experimental.** This type is part of an experimental wire-protocol surface
845    /// and may change or be removed in future SDK or CLI releases.
846    ///
847    /// </div>
848    #[serde(rename = "permission.messageAuthorizationRead")]
849    PermissionMessageAuthorizationRead(PermissionMessageAuthorizationReadData),
850    ///
851    /// <div class="warning">
852    ///
853    /// **Experimental.** This type is part of an experimental wire-protocol surface
854    /// and may change or be removed in future SDK or CLI releases.
855    ///
856    /// </div>
857    #[serde(rename = "permission.messageAuthorizationDegraded")]
858    PermissionMessageAuthorizationDegraded(PermissionMessageAuthorizationDegradedData),
859    ///
860    /// <div class="warning">
861    ///
862    /// **Experimental.** This type is part of an experimental wire-protocol surface
863    /// and may change or be removed in future SDK or CLI releases.
864    ///
865    /// </div>
866    #[serde(rename = "permission.assentDetected")]
867    PermissionAssentDetected(PermissionAssentDetectedData),
868    ///
869    /// <div class="warning">
870    ///
871    /// **Experimental.** This type is part of an experimental wire-protocol surface
872    /// and may change or be removed in future SDK or CLI releases.
873    ///
874    /// </div>
875    #[serde(rename = "permission.contextualAuthorization")]
876    PermissionContextualAuthorization(PermissionContextualAuthorizationData),
877    #[serde(rename = "user_input.requested")]
878    UserInputRequested(UserInputRequestedData),
879    #[serde(rename = "user_input.completed")]
880    UserInputCompleted(UserInputCompletedData),
881    #[serde(rename = "elicitation.requested")]
882    ElicitationRequested(ElicitationRequestedData),
883    #[serde(rename = "elicitation.completed")]
884    ElicitationCompleted(ElicitationCompletedData),
885    #[serde(rename = "sampling.requested")]
886    SamplingRequested(SamplingRequestedData),
887    #[serde(rename = "sampling.completed")]
888    SamplingCompleted(SamplingCompletedData),
889    #[serde(rename = "mcp.oauth_required")]
890    McpOauthRequired(McpOauthRequiredData),
891    #[serde(rename = "mcp.oauth_completed")]
892    McpOauthCompleted(McpOauthCompletedData),
893    #[serde(rename = "mcp.headers_refresh_required")]
894    McpHeadersRefreshRequired(McpHeadersRefreshRequiredData),
895    #[serde(rename = "mcp.headers_refresh_completed")]
896    McpHeadersRefreshCompleted(McpHeadersRefreshCompletedData),
897    #[serde(rename = "session.custom_notification")]
898    SessionCustomNotification(SessionCustomNotificationData),
899    ///
900    /// <div class="warning">
901    ///
902    /// **Experimental.** This type is part of an experimental wire-protocol surface
903    /// and may change or be removed in future SDK or CLI releases.
904    ///
905    /// </div>
906    #[serde(rename = "ui.ephemeral_query")]
907    UiEphemeralQuery(UiEphemeralQueryData),
908    #[serde(rename = "external_tool.requested")]
909    ExternalToolRequested(ExternalToolRequestedData),
910    #[serde(rename = "external_tool.completed")]
911    ExternalToolCompleted(ExternalToolCompletedData),
912    #[serde(rename = "command.queued")]
913    CommandQueued(CommandQueuedData),
914    #[serde(rename = "command.execute")]
915    CommandExecute(CommandExecuteData),
916    #[serde(rename = "command.completed")]
917    CommandCompleted(CommandCompletedData),
918    #[serde(rename = "auto_mode_switch.requested")]
919    AutoModeSwitchRequested(AutoModeSwitchRequestedData),
920    #[serde(rename = "auto_mode_switch.completed")]
921    AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
922    #[serde(rename = "session_limits_exhausted.requested")]
923    SessionLimitsExhaustedRequested(SessionLimitsExhaustedRequestedData),
924    #[serde(rename = "session_limits_exhausted.completed")]
925    SessionLimitsExhaustedCompleted(SessionLimitsExhaustedCompletedData),
926    ///
927    /// <div class="warning">
928    ///
929    /// **Experimental.** This type is part of an experimental wire-protocol surface
930    /// and may change or be removed in future SDK or CLI releases.
931    ///
932    /// </div>
933    #[serde(rename = "session.auto_mode_resolved")]
934    SessionAutoModeResolved(SessionAutoModeResolvedData),
935    ///
936    /// <div class="warning">
937    ///
938    /// **Experimental.** This type is part of an experimental wire-protocol surface
939    /// and may change or be removed in future SDK or CLI releases.
940    ///
941    /// </div>
942    #[serde(rename = "session.managed_settings_resolved")]
943    SessionManagedSettingsResolved(SessionManagedSettingsResolvedData),
944    ///
945    /// <div class="warning">
946    ///
947    /// **Experimental.** This type is part of an experimental wire-protocol surface
948    /// and may change or be removed in future SDK or CLI releases.
949    ///
950    /// </div>
951    #[serde(rename = "session.managed_settings_enforced")]
952    SessionManagedSettingsEnforced(SessionManagedSettingsEnforcedData),
953    #[serde(rename = "commands.changed")]
954    CommandsChanged(CommandsChangedData),
955    #[serde(rename = "capabilities.changed")]
956    CapabilitiesChanged(CapabilitiesChangedData),
957    #[serde(rename = "exit_plan_mode.requested")]
958    ExitPlanModeRequested(ExitPlanModeRequestedData),
959    #[serde(rename = "exit_plan_mode.completed")]
960    ExitPlanModeCompleted(ExitPlanModeCompletedData),
961    #[serde(rename = "session.tools_updated")]
962    SessionToolsUpdated(SessionToolsUpdatedData),
963    #[serde(rename = "session.background_tasks_changed")]
964    SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
965    ///
966    /// <div class="warning">
967    ///
968    /// **Experimental.** This type is part of an experimental wire-protocol surface
969    /// and may change or be removed in future SDK or CLI releases.
970    ///
971    /// </div>
972    #[serde(rename = "factory.run_updated")]
973    FactoryRunUpdated(FactoryRunUpdatedData),
974    ///
975    /// <div class="warning">
976    ///
977    /// **Experimental.** This type is part of an experimental wire-protocol surface
978    /// and may change or be removed in future SDK or CLI releases.
979    ///
980    /// </div>
981    #[serde(rename = "factory.run_started")]
982    FactoryRunStarted(FactoryRunStartedData),
983    ///
984    /// <div class="warning">
985    ///
986    /// **Experimental.** This type is part of an experimental wire-protocol surface
987    /// and may change or be removed in future SDK or CLI releases.
988    ///
989    /// </div>
990    #[serde(rename = "factory.run_settled")]
991    FactoryRunSettled(FactoryRunSettledData),
992    #[serde(rename = "session.skills_loaded")]
993    SessionSkillsLoaded(SessionSkillsLoadedData),
994    #[serde(rename = "session.custom_agents_updated")]
995    SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
996    #[serde(rename = "session.mcp_servers_loaded")]
997    SessionMcpServersLoaded(SessionMcpServersLoadedData),
998    #[serde(rename = "session.mcp_server_status_changed")]
999    SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
1000    #[serde(rename = "session.mcp_server_removed")]
1001    SessionMcpServerRemoved(SessionMcpServerRemovedData),
1002    #[serde(rename = "session.mcp_server_needs_reconnect")]
1003    SessionMcpServerNeedsReconnect(SessionMcpServerNeedsReconnectData),
1004    #[serde(rename = "mcp.tools.list_changed")]
1005    McpToolsListChanged(McpToolsListChangedData),
1006    #[serde(rename = "mcp.resources.list_changed")]
1007    McpResourcesListChanged(McpResourcesListChangedData),
1008    #[serde(rename = "mcp.prompts.list_changed")]
1009    McpPromptsListChanged(McpPromptsListChangedData),
1010    #[serde(rename = "session.extensions_loaded")]
1011    SessionExtensionsLoaded(SessionExtensionsLoadedData),
1012    ///
1013    /// <div class="warning">
1014    ///
1015    /// **Experimental.** This type is part of an experimental wire-protocol surface
1016    /// and may change or be removed in future SDK or CLI releases.
1017    ///
1018    /// </div>
1019    #[serde(rename = "session.canvas.opened")]
1020    SessionCanvasOpened(SessionCanvasOpenedData),
1021    ///
1022    /// <div class="warning">
1023    ///
1024    /// **Experimental.** This type is part of an experimental wire-protocol surface
1025    /// and may change or be removed in future SDK or CLI releases.
1026    ///
1027    /// </div>
1028    #[serde(rename = "session.canvas.registry_changed")]
1029    SessionCanvasRegistryChanged(SessionCanvasRegistryChangedData),
1030    ///
1031    /// <div class="warning">
1032    ///
1033    /// **Experimental.** This type is part of an experimental wire-protocol surface
1034    /// and may change or be removed in future SDK or CLI releases.
1035    ///
1036    /// </div>
1037    #[serde(rename = "session.canvas.closed")]
1038    SessionCanvasClosed(SessionCanvasClosedData),
1039    ///
1040    /// <div class="warning">
1041    ///
1042    /// **Experimental.** This type is part of an experimental wire-protocol surface
1043    /// and may change or be removed in future SDK or CLI releases.
1044    ///
1045    /// </div>
1046    #[serde(rename = "session.canvas.unavailable")]
1047    SessionCanvasUnavailable(SessionCanvasUnavailableData),
1048    ///
1049    /// <div class="warning">
1050    ///
1051    /// **Experimental.** This type is part of an experimental wire-protocol surface
1052    /// and may change or be removed in future SDK or CLI releases.
1053    ///
1054    /// </div>
1055    #[serde(rename = "session.canvas.recorded")]
1056    SessionCanvasRecorded(SessionCanvasRecordedData),
1057    ///
1058    /// <div class="warning">
1059    ///
1060    /// **Experimental.** This type is part of an experimental wire-protocol surface
1061    /// and may change or be removed in future SDK or CLI releases.
1062    ///
1063    /// </div>
1064    #[serde(rename = "session.canvas.removed")]
1065    SessionCanvasRemoved(SessionCanvasRemovedData),
1066    #[serde(rename = "session.extensions.attachments_pushed")]
1067    SessionExtensionsAttachmentsPushed(SessionExtensionsAttachmentsPushedData),
1068    #[serde(rename = "mcp_app.tool_call_complete")]
1069    McpAppToolCallComplete(McpAppToolCallCompleteData),
1070}
1071
1072/// A session event with typed data payload.
1073///
1074/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
1075/// are available directly. The event-specific data is in the `payload`
1076/// field as a [`SessionEventData`] enum.
1077#[derive(Debug, Clone, Serialize, Deserialize)]
1078#[serde(rename_all = "camelCase")]
1079pub struct TypedSessionEvent {
1080    /// Unique event identifier (UUID v4).
1081    pub id: String,
1082    /// ISO 8601 timestamp when the event was created.
1083    pub timestamp: String,
1084    /// ID of the preceding event in the chain.
1085    #[serde(skip_serializing_if = "Option::is_none")]
1086    pub parent_id: Option<String>,
1087    /// When true, the event is transient and not persisted.
1088    #[serde(skip_serializing_if = "Option::is_none")]
1089    pub ephemeral: Option<bool>,
1090    /// Sub-agent instance identifier. Absent for events from the root /
1091    /// main agent and session-level events.
1092    #[serde(skip_serializing_if = "Option::is_none")]
1093    pub agent_id: Option<String>,
1094    /// The typed event payload (discriminated by event type).
1095    #[serde(flatten)]
1096    pub payload: SessionEventData,
1097}
1098
1099/// Working directory and git context at session start
1100#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1101#[serde(rename_all = "camelCase")]
1102pub struct WorkingDirectoryContext {
1103    /// Base commit of current git branch at session start time
1104    #[serde(skip_serializing_if = "Option::is_none")]
1105    pub base_commit: Option<String>,
1106    /// Current git branch name
1107    #[serde(skip_serializing_if = "Option::is_none")]
1108    pub branch: Option<String>,
1109    /// Current working directory path
1110    pub cwd: String,
1111    /// Root directory of the git repository, resolved via git rev-parse
1112    #[serde(skip_serializing_if = "Option::is_none")]
1113    pub git_root: Option<String>,
1114    /// Head commit of current git branch at session start time
1115    #[serde(skip_serializing_if = "Option::is_none")]
1116    pub head_commit: Option<String>,
1117    /// Hosting platform type of the repository (github or ado)
1118    #[serde(skip_serializing_if = "Option::is_none")]
1119    pub host_type: Option<WorkingDirectoryContextHostType>,
1120    /// 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).
1121    #[serde(skip_serializing_if = "Option::is_none")]
1122    pub pending_git_context: Option<bool>,
1123    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
1124    #[serde(skip_serializing_if = "Option::is_none")]
1125    pub repository: Option<String>,
1126    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
1127    #[serde(skip_serializing_if = "Option::is_none")]
1128    pub repository_host: Option<String>,
1129}
1130
1131/// Per-session configuration for the built-in GitHub MCP server
1132#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1133#[serde(rename_all = "camelCase")]
1134pub struct GitHubMcpToolConfig {
1135    /// Additional GitHub MCP tools requested by the session
1136    #[serde(skip_serializing_if = "Option::is_none")]
1137    pub additional_tools: Option<Vec<String>>,
1138    /// Additional GitHub MCP toolsets requested by the session
1139    #[serde(skip_serializing_if = "Option::is_none")]
1140    pub additional_toolsets: Option<Vec<String>>,
1141    /// Whether to use the read-write endpoint and request all toolsets
1142    #[serde(skip_serializing_if = "Option::is_none")]
1143    pub enable_all_tools: Option<bool>,
1144    /// Whether to request the GitHub MCP insiders build
1145    #[serde(skip_serializing_if = "Option::is_none")]
1146    pub enable_insiders_mode: Option<bool>,
1147}
1148
1149/// Optional session limits.
1150#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1151#[serde(rename_all = "camelCase")]
1152pub struct SessionLimitsConfig {
1153    /// Maximum AI Credits allowed across the session's current accounting window.
1154    #[serde(skip_serializing_if = "Option::is_none")]
1155    pub max_ai_credits: Option<f64>,
1156}
1157
1158/// Session event "session.start". Session initialization metadata including context and configuration
1159#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1160#[serde(rename_all = "camelCase")]
1161pub struct SessionStartData {
1162    /// Whether the session was already in use by another client at start time
1163    #[serde(skip_serializing_if = "Option::is_none")]
1164    pub already_in_use: Option<bool>,
1165    /// Auto routing preference selected at session creation time
1166    #[serde(skip_serializing_if = "Option::is_none")]
1167    pub auto_tier: Option<AutoTier>,
1168    /// Working directory and git context at session start
1169    #[serde(skip_serializing_if = "Option::is_none")]
1170    pub context: Option<WorkingDirectoryContext>,
1171    /// Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
1172    #[serde(skip_serializing_if = "Option::is_none")]
1173    pub context_tier: Option<ContextTier>,
1174    /// Version string of the Copilot application
1175    pub copilot_version: String,
1176    /// 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.
1177    #[serde(skip_serializing_if = "Option::is_none")]
1178    pub detached_from_spawning_parent_session_id: Option<String>,
1179    /// Per-session GitHub MCP override persisted for cold resume
1180    #[serde(skip_serializing_if = "Option::is_none")]
1181    pub github_mcp_tool_config: Option<GitHubMcpToolConfig>,
1182    /// Identifier of the software producing the events (e.g., "copilot-agent")
1183    pub producer: String,
1184    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
1185    #[serde(skip_serializing_if = "Option::is_none")]
1186    pub reasoning_effort: Option<String>,
1187    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
1188    #[serde(skip_serializing_if = "Option::is_none")]
1189    pub reasoning_summary: Option<ReasoningSummary>,
1190    /// Whether this session supports remote steering via GitHub
1191    #[serde(skip_serializing_if = "Option::is_none")]
1192    pub remote_steerable: Option<bool>,
1193    /// Model selected at session creation time, if any
1194    #[serde(skip_serializing_if = "Option::is_none")]
1195    pub selected_model: Option<String>,
1196    /// Unique identifier for the session
1197    pub session_id: SessionId,
1198    /// Session limits configured at session creation time, if any
1199    #[serde(skip_serializing_if = "Option::is_none")]
1200    pub session_limits: Option<SessionLimitsConfig>,
1201    /// ISO 8601 timestamp when the session was created
1202    pub start_time: String,
1203    /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
1204    #[serde(skip_serializing_if = "Option::is_none")]
1205    pub verbosity: Option<Verbosity>,
1206    /// Schema version number for the session event format
1207    pub version: i64,
1208}
1209
1210/// Session event "session.resume". Session resume metadata including current context and event count
1211#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1212#[serde(rename_all = "camelCase")]
1213pub struct SessionResumeData {
1214    /// Whether the session was already in use by another client at resume time
1215    #[serde(skip_serializing_if = "Option::is_none")]
1216    pub already_in_use: Option<bool>,
1217    /// Auto routing preference active at resume time
1218    #[serde(skip_serializing_if = "Option::is_none")]
1219    pub auto_tier: Option<AutoTier>,
1220    /// Updated working directory and git context at resume time
1221    #[serde(skip_serializing_if = "Option::is_none")]
1222    pub context: Option<WorkingDirectoryContext>,
1223    /// Context tier currently selected at resume time; null when no tier is active
1224    #[serde(skip_serializing_if = "Option::is_none")]
1225    pub context_tier: Option<ContextTier>,
1226    /// 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.
1227    #[serde(skip_serializing_if = "Option::is_none")]
1228    pub continue_pending_work: Option<bool>,
1229    /// Total number of persisted events in the session at the time of resume
1230    pub event_count: i64,
1231    /// 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
1232    #[serde(skip_serializing_if = "Option::is_none")]
1233    pub events_file_size_bytes: Option<i64>,
1234    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
1235    #[serde(skip_serializing_if = "Option::is_none")]
1236    pub reasoning_effort: Option<String>,
1237    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
1238    #[serde(skip_serializing_if = "Option::is_none")]
1239    pub reasoning_summary: Option<ReasoningSummary>,
1240    /// Whether this session supports remote steering via GitHub
1241    #[serde(skip_serializing_if = "Option::is_none")]
1242    pub remote_steerable: Option<bool>,
1243    /// ISO 8601 timestamp when the session was resumed
1244    pub resume_time: String,
1245    /// Model currently selected at resume time
1246    #[serde(skip_serializing_if = "Option::is_none")]
1247    pub selected_model: Option<String>,
1248    /// Session limits currently configured at resume time; null when no limits are active
1249    #[serde(skip_serializing_if = "Option::is_none")]
1250    pub session_limits: Option<SessionLimitsConfig>,
1251    /// 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.
1252    #[serde(skip_serializing_if = "Option::is_none")]
1253    pub session_was_active: Option<bool>,
1254    /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
1255    #[serde(skip_serializing_if = "Option::is_none")]
1256    pub verbosity: Option<Verbosity>,
1257}
1258
1259/// Session event "session.remote_steerable_changed". Notifies that the session's remote steering capability has changed
1260#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1261#[serde(rename_all = "camelCase")]
1262pub struct SessionRemoteSteerableChangedData {
1263    /// Whether this session now supports remote steering via GitHub
1264    pub remote_steerable: bool,
1265}
1266
1267/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
1268#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1269#[serde(rename_all = "camelCase")]
1270pub struct SessionErrorData {
1271    /// 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.
1272    #[serde(skip_serializing_if = "Option::is_none")]
1273    pub eligible_for_auto_switch: Option<bool>,
1274    /// 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"`).
1275    #[serde(skip_serializing_if = "Option::is_none")]
1276    pub error_code: Option<String>,
1277    /// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
1278    pub error_type: String,
1279    /// Human-readable error message
1280    pub message: String,
1281    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
1282    #[serde(skip_serializing_if = "Option::is_none")]
1283    pub provider_call_id: Option<String>,
1284    /// What the user must do to recover, when the runtime knows of an action. The `message` never names a client affordance, so a client that offers one — a slash command, a settings pane, a link — renders it from this value.
1285    #[serde(skip_serializing_if = "Option::is_none")]
1286    pub remediation: Option<RemediationAction>,
1287    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
1288    #[serde(skip_serializing_if = "Option::is_none")]
1289    pub service_request_id: Option<String>,
1290    /// Error stack trace, when available
1291    #[serde(skip_serializing_if = "Option::is_none")]
1292    pub stack: Option<String>,
1293    /// HTTP status code from the upstream request, if applicable
1294    #[serde(skip_serializing_if = "Option::is_none")]
1295    pub status_code: Option<i32>,
1296    /// Optional URL associated with this error that the user can open in a browser
1297    #[serde(skip_serializing_if = "Option::is_none")]
1298    pub url: Option<String>,
1299}
1300
1301/// Session event "session.idle". Payload indicating the session is idle with no background agents or attached shell commands in flight
1302#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1303#[serde(rename_all = "camelCase")]
1304pub struct SessionIdleData {
1305    /// True when the preceding agentic loop was cancelled via abort signal
1306    #[serde(skip_serializing_if = "Option::is_none")]
1307    pub aborted: Option<bool>,
1308    /// 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.
1309    #[serde(skip_serializing_if = "Option::is_none")]
1310    pub mode: Option<SessionMode>,
1311}
1312
1313/// Session event "session.title_changed". Session title change payload containing the new display title
1314#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1315#[serde(rename_all = "camelCase")]
1316pub struct SessionTitleChangedData {
1317    /// The new display title for the session
1318    pub title: String,
1319}
1320
1321/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
1322#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1323#[serde(rename_all = "camelCase")]
1324pub struct SessionScheduleCreatedData {
1325    /// Absolute fire time (epoch milliseconds) for a one-shot calendar schedule
1326    #[serde(skip_serializing_if = "Option::is_none")]
1327    pub at: Option<i64>,
1328    /// 5-field cron expression for a recurring calendar schedule, evaluated in `tz`
1329    #[serde(skip_serializing_if = "Option::is_none")]
1330    pub cron: Option<String>,
1331    /// 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)
1332    #[serde(skip_serializing_if = "Option::is_none")]
1333    pub display_prompt: Option<String>,
1334    /// Sequential id assigned to the scheduled prompt within the session
1335    pub id: i64,
1336    /// Interval between ticks in milliseconds (relative-interval schedules)
1337    #[serde(skip_serializing_if = "Option::is_none")]
1338    pub interval_ms: Option<i64>,
1339    /// 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.
1340    #[serde(skip_serializing_if = "Option::is_none")]
1341    pub origin: Option<ScheduleOrigin>,
1342    /// Prompt text that gets enqueued on every tick
1343    pub prompt: String,
1344    /// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
1345    #[serde(skip_serializing_if = "Option::is_none")]
1346    pub recurring: Option<bool>,
1347    /// 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.
1348    #[serde(skip_serializing_if = "Option::is_none")]
1349    pub self_paced: Option<bool>,
1350    /// IANA timezone the `cron` expression is evaluated in
1351    #[serde(skip_serializing_if = "Option::is_none")]
1352    pub tz: Option<String>,
1353}
1354
1355/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
1356#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1357#[serde(rename_all = "camelCase")]
1358pub struct SessionScheduleCancelledData {
1359    /// Id of the scheduled prompt that was cancelled
1360    pub id: i64,
1361}
1362
1363/// Session event "session.schedule_rearmed". Self-paced schedule re-armed for its next run
1364#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1365#[serde(rename_all = "camelCase")]
1366pub struct SessionScheduleRearmedData {
1367    /// Id of the self-paced schedule that was re-armed
1368    pub id: i64,
1369    /// Absolute time (epoch milliseconds) the model armed the next run to fire
1370    pub next_run_at: i64,
1371}
1372
1373/// Session event "session.autopilot_objective_changed". Autopilot objective state file operation details indicating what changed
1374#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1375#[serde(rename_all = "camelCase")]
1376pub struct SessionAutopilotObjectiveChangedData {
1377    /// Current autopilot objective id, if one exists
1378    #[serde(skip_serializing_if = "Option::is_none")]
1379    pub id: Option<i64>,
1380    /// The type of operation performed on the autopilot objective state file
1381    pub operation: AutopilotObjectiveChangedOperation,
1382    /// Current autopilot objective status, if one exists
1383    #[serde(skip_serializing_if = "Option::is_none")]
1384    pub status: Option<AutopilotObjectiveChangedStatus>,
1385}
1386
1387/// Session event "session.info". Informational message for timeline display with categorization
1388#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1389#[serde(rename_all = "camelCase")]
1390pub struct SessionInfoData {
1391    /// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
1392    pub info_type: String,
1393    /// Human-readable informational message for display in the timeline
1394    pub message: String,
1395    /// Optional actionable tip displayed with this message
1396    #[serde(skip_serializing_if = "Option::is_none")]
1397    pub tip: Option<String>,
1398    /// Optional URL associated with this message that the user can open in a browser
1399    #[serde(skip_serializing_if = "Option::is_none")]
1400    pub url: Option<String>,
1401}
1402
1403#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1404#[serde(rename_all = "camelCase")]
1405pub struct IndexedSearchDataStatus {
1406    /// Indexed-search event variant discriminator.
1407    pub kind: IndexedSearchDataStatusKind,
1408    /// Current indexed-search state for this session activation.
1409    pub state: IndexedSearchState,
1410}
1411
1412#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1413#[serde(rename_all = "camelCase")]
1414pub struct IndexedSearchDataStartup {
1415    /// Why indexed search was disabled, when applicable.
1416    #[serde(skip_serializing_if = "Option::is_none")]
1417    pub disabled_reason: Option<IndexedSearchDisabledReason>,
1418    /// Whether the repository meets the automatic indexing file-count threshold, when known.
1419    #[serde(skip_serializing_if = "Option::is_none")]
1420    pub eligible: Option<bool>,
1421    /// Startup failure details. May contain sensitive user data; restricted telemetry only.
1422    #[serde(skip_serializing_if = "Option::is_none")]
1423    pub error_message: Option<String>,
1424    /// Number of text files counted in the repository.
1425    #[serde(skip_serializing_if = "Option::is_none")]
1426    pub file_count: Option<f64>,
1427    /// Whether indexed search was explicitly enabled through the environment.
1428    pub forced_by_env: bool,
1429    /// Indexed-search event variant discriminator.
1430    pub kind: IndexedSearchDataStartupKind,
1431    /// Outcome of this startup attempt.
1432    pub outcome: IndexedSearchOutcome,
1433    /// Wall-clock duration of startup in milliseconds.
1434    pub startup_duration_ms: f64,
1435    /// Whether waiting for index readiness was requested, including skipped attempts.
1436    pub warm_start: bool,
1437}
1438
1439#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1440#[serde(rename_all = "camelCase")]
1441pub struct IndexedSearchDataServerError {
1442    /// Server failure details. May contain sensitive user data; restricted telemetry only.
1443    #[serde(skip_serializing_if = "Option::is_none")]
1444    pub error_message: Option<String>,
1445    /// Category of the server failure.
1446    pub error_type: IndexedSearchErrorType,
1447    /// Process exit code, when available.
1448    #[serde(skip_serializing_if = "Option::is_none")]
1449    pub exit_code: Option<f64>,
1450    /// Indexed-search event variant discriminator.
1451    pub kind: IndexedSearchDataServerErrorKind,
1452}
1453
1454#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1455#[serde(rename_all = "camelCase")]
1456pub struct IndexedSearchDataIncremental {
1457    /// Number of added files.
1458    #[serde(skip_serializing_if = "Option::is_none")]
1459    pub added_file_count: Option<f64>,
1460    /// Number of modified files.
1461    #[serde(skip_serializing_if = "Option::is_none")]
1462    pub changed_file_count: Option<f64>,
1463    /// Number of deleted files.
1464    #[serde(skip_serializing_if = "Option::is_none")]
1465    pub deleted_file_count: Option<f64>,
1466    /// Indexed-search event variant discriminator.
1467    pub kind: IndexedSearchDataIncrementalKind,
1468    /// Phase of the incremental index update.
1469    pub phase: IndexedSearchIncrementalPhase,
1470    /// Total number of detected changes.
1471    #[serde(skip_serializing_if = "Option::is_none")]
1472    pub total_change_count: Option<f64>,
1473    /// Total incremental indexing duration in milliseconds.
1474    #[serde(skip_serializing_if = "Option::is_none")]
1475    pub total_duration_ms: Option<f64>,
1476    /// Index update duration in milliseconds.
1477    #[serde(skip_serializing_if = "Option::is_none")]
1478    pub update_duration_ms: Option<f64>,
1479    /// Workspace scan duration in milliseconds.
1480    #[serde(skip_serializing_if = "Option::is_none")]
1481    pub walk_duration_ms: Option<f64>,
1482}
1483
1484/// Session event "session.warning". Warning message for timeline display with categorization
1485#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1486#[serde(rename_all = "camelCase")]
1487pub struct SessionWarningData {
1488    /// Human-readable warning message for display in the timeline
1489    pub message: String,
1490    /// What the user must do to recover, when the runtime knows of an action. The `message` never names a client affordance, so a client that offers one — a slash command, a settings pane, a link — renders it from this value.
1491    #[serde(skip_serializing_if = "Option::is_none")]
1492    pub remediation: Option<RemediationAction>,
1493    /// Optional URL associated with this warning that the user can open in a browser
1494    #[serde(skip_serializing_if = "Option::is_none")]
1495    pub url: Option<String>,
1496    /// Category of warning (e.g., "subscription", "policy", "mcp")
1497    pub warning_type: String,
1498}
1499
1500/// Session event "session.model_change". Model change details including previous and new model identifiers
1501#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1502#[serde(rename_all = "camelCase")]
1503pub struct SessionModelChangeData {
1504    /// Committed Auto preference after the model configuration change, when applicable.
1505    #[serde(skip_serializing_if = "Option::is_none")]
1506    pub auto_tier: Option<AutoTier>,
1507    /// 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.
1508    #[serde(skip_serializing_if = "Option::is_none")]
1509    pub cause: Option<String>,
1510    /// Context tier after the model change; null explicitly clears a previously selected tier
1511    #[serde(skip_serializing_if = "Option::is_none")]
1512    pub context_tier: Option<ContextTier>,
1513    /// Newly selected model identifier
1514    pub new_model: String,
1515    /// Previously committed Auto preference, when one was explicitly selected.
1516    #[serde(skip_serializing_if = "Option::is_none")]
1517    pub previous_auto_tier: Option<AutoTier>,
1518    /// Model that was previously selected, if any
1519    #[serde(skip_serializing_if = "Option::is_none")]
1520    pub previous_model: Option<String>,
1521    /// Reasoning effort level before the model change, if applicable
1522    #[serde(skip_serializing_if = "Option::is_none")]
1523    pub previous_reasoning_effort: Option<String>,
1524    /// Reasoning summary mode before the model change, if applicable
1525    #[serde(skip_serializing_if = "Option::is_none")]
1526    pub previous_reasoning_summary: Option<ReasoningSummary>,
1527    /// Output verbosity level before the model change, if applicable
1528    #[serde(skip_serializing_if = "Option::is_none")]
1529    pub previous_verbosity: Option<Verbosity>,
1530    /// Reasoning effort level after the model change, if applicable
1531    #[serde(skip_serializing_if = "Option::is_none")]
1532    pub reasoning_effort: Option<String>,
1533    /// Reasoning summary mode after the model change, if applicable
1534    #[serde(skip_serializing_if = "Option::is_none")]
1535    pub reasoning_summary: Option<ReasoningSummary>,
1536    /// Origin of the effective model change, when known.
1537    #[serde(skip_serializing_if = "Option::is_none")]
1538    pub source: Option<ModelChangeSource>,
1539    /// Output verbosity level after the model change, if applicable
1540    #[serde(skip_serializing_if = "Option::is_none")]
1541    pub verbosity: Option<Verbosity>,
1542}
1543
1544/// Session event "session.model_deselected". The model the user had explicitly selected is no longer available, because the host that published it withdrew it, so the session no longer has an explicit selection. The next turn resolves a default as though the user had never chosen a model. Clients should stop presenting the previous model as selected. This event is durable because resume rebuilds the selected model from the event log; without it a resumed session would restore a model its provider no longer serves. Reasoning effort, verbosity, and other session-level preferences are deliberately unchanged, because they belong to the session rather than to the model.
1545#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1546#[serde(rename_all = "camelCase")]
1547pub struct SessionModelDeselectedData {
1548    /// Model that was selected before the host withdrew it.
1549    pub previous_model: String,
1550    /// Low-cardinality reason the selection was cleared.
1551    pub reason: ModelDeselectedReason,
1552}
1553
1554/// Session event "session.auto_tier_recommendation". Live-only Auto preference recommendation from Copilot API after a successful Auto model call.
1555///
1556/// <div class="warning">
1557///
1558/// **Experimental.** This type is part of an experimental wire-protocol surface
1559/// and may change or be removed in future SDK or CLI releases.
1560///
1561/// </div>
1562#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1563#[serde(rename_all = "camelCase")]
1564pub struct SessionAutoTierRecommendationData {
1565    /// Recommended Auto preference.
1566    pub recommended_auto_tier: RecommendedAutoTier,
1567}
1568
1569/// Session event "session.auto_tier_switch_failed". A transient Auto preference failure emitted when the runtime cannot mint or accept a usable model and token pair. The previously effective preference remains active, so SDK clients can surface a non-blocking failure without changing their committed-tier state. This event is ephemeral and is not persisted or replayed on resume.
1570#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1571#[serde(rename_all = "camelCase")]
1572pub struct SessionAutoTierSwitchFailedData {
1573    /// Auto preference that remains effective after the failed request.
1574    #[serde(skip_serializing_if = "Option::is_none")]
1575    pub effective_auto_tier: Option<AutoTier>,
1576    /// Low-cardinality failure outcome reported by Auto resolution.
1577    pub reason: AutoTierSwitchFailureReason,
1578    /// Auto preference that failed to activate, or null when returning to provider-default routing failed.
1579    pub requested_auto_tier: Option<AutoTier>,
1580}
1581
1582/// Session event "session.mode_changed". Agent mode change details including previous and new modes
1583#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1584#[serde(rename_all = "camelCase")]
1585pub struct SessionModeChangedData {
1586    /// The session mode the agent is operating in
1587    pub new_mode: SessionMode,
1588    /// The session mode the agent is operating in
1589    pub previous_mode: SessionMode,
1590}
1591
1592/// 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.
1593#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1594#[serde(rename_all = "camelCase")]
1595pub struct SessionModeNoticeDeliveredData {
1596    /// Model-visible transition notice persisted for a mid-turn delivery
1597    #[serde(skip_serializing_if = "Option::is_none")]
1598    pub content: Option<String>,
1599    /// Mode established by the delivered transition notice
1600    pub mode: SessionMode,
1601}
1602
1603/// Session event "session.session_limits_changed". Session limits update details. Null clears the limits.
1604#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1605#[serde(rename_all = "camelCase")]
1606pub struct SessionSessionLimitsChangedData {
1607    /// Current session limits, or null when no limits are active
1608    pub session_limits: Option<SessionLimitsConfig>,
1609}
1610
1611/// Session event "session.permissions_changed". Permission-mode transition details.
1612///
1613/// <div class="warning">
1614///
1615/// **Experimental.** This type is part of an experimental wire-protocol surface
1616/// and may change or be removed in future SDK or CLI releases.
1617///
1618/// </div>
1619#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1620#[serde(rename_all = "camelCase")]
1621pub struct SessionPermissionsChangedData {
1622    /// Explicit LLM judge model override used by assisted mode; omitted when the provider default applies
1623    ///
1624    /// <div class="warning">
1625    ///
1626    /// **Experimental.** This type is part of an experimental wire-protocol surface
1627    /// and may change or be removed in future SDK or CLI releases.
1628    ///
1629    /// </div>
1630    #[serde(skip_serializing_if = "Option::is_none")]
1631    pub assisted_approval_model: Option<String>,
1632    /// Permission mode after the change
1633    ///
1634    /// <div class="warning">
1635    ///
1636    /// **Experimental.** This type is part of an experimental wire-protocol surface
1637    /// and may change or be removed in future SDK or CLI releases.
1638    ///
1639    /// </div>
1640    #[serde(skip_serializing_if = "Option::is_none")]
1641    pub mode: Option<PermissionMode>,
1642    /// Permission mode before the change
1643    ///
1644    /// <div class="warning">
1645    ///
1646    /// **Experimental.** This type is part of an experimental wire-protocol surface
1647    /// and may change or be removed in future SDK or CLI releases.
1648    ///
1649    /// </div>
1650    #[serde(skip_serializing_if = "Option::is_none")]
1651    pub previous_mode: Option<PermissionMode>,
1652}
1653
1654/// Session event "session.plan_changed". Plan file operation details indicating what changed
1655#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1656#[serde(rename_all = "camelCase")]
1657pub struct SessionPlanChangedData {
1658    /// The type of operation performed on the plan file
1659    pub operation: PlanChangedOperation,
1660}
1661
1662/// 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.
1663#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1664#[serde(rename_all = "camelCase")]
1665pub struct SessionTodosChangedData {}
1666
1667/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
1668#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1669#[serde(rename_all = "camelCase")]
1670pub struct SessionWorkspaceFileChangedData {
1671    /// Whether the file was newly created or updated
1672    pub operation: WorkspaceFileChangedOperation,
1673    /// Relative path within the session workspace files directory
1674    pub path: String,
1675}
1676
1677/// Repository context for the handed-off session
1678#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1679#[serde(rename_all = "camelCase")]
1680pub struct HandoffRepository {
1681    /// Git branch name, if applicable
1682    #[serde(skip_serializing_if = "Option::is_none")]
1683    pub branch: Option<String>,
1684    /// Repository name
1685    pub name: String,
1686    /// Repository owner (user or organization)
1687    pub owner: String,
1688}
1689
1690/// Session event "session.handoff". Session handoff metadata including source, context, and repository information
1691#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1692#[serde(rename_all = "camelCase")]
1693pub struct SessionHandoffData {
1694    /// Additional context information for the handoff
1695    #[serde(skip_serializing_if = "Option::is_none")]
1696    pub context: Option<String>,
1697    /// ISO 8601 timestamp when the handoff occurred
1698    pub handoff_time: String,
1699    /// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
1700    #[serde(skip_serializing_if = "Option::is_none")]
1701    pub host: Option<String>,
1702    /// Session ID of the remote session being handed off
1703    #[serde(skip_serializing_if = "Option::is_none")]
1704    pub remote_session_id: Option<SessionId>,
1705    /// Repository context for the handed-off session
1706    #[serde(skip_serializing_if = "Option::is_none")]
1707    pub repository: Option<HandoffRepository>,
1708    /// Origin type of the session being handed off
1709    pub source_type: HandoffSourceType,
1710    /// Summary of the work done in the source session
1711    #[serde(skip_serializing_if = "Option::is_none")]
1712    pub summary: Option<String>,
1713}
1714
1715/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
1716#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1717#[serde(rename_all = "camelCase")]
1718pub struct SessionTruncationData {
1719    /// Number of messages removed by truncation
1720    pub messages_removed_during_truncation: i64,
1721    /// Identifier of the component that performed truncation (e.g., "BasicTruncator")
1722    pub performed_by: String,
1723    /// Number of conversation messages after truncation
1724    pub post_truncation_messages_length: i64,
1725    /// Total tokens in conversation messages after truncation
1726    pub post_truncation_tokens_in_messages: i64,
1727    /// Number of conversation messages before truncation
1728    pub pre_truncation_messages_length: i64,
1729    /// Total tokens in conversation messages before truncation
1730    pub pre_truncation_tokens_in_messages: i64,
1731    /// Maximum token count for the model's context window
1732    pub token_limit: i64,
1733    /// Number of tokens removed by truncation
1734    pub tokens_removed_during_truncation: i64,
1735}
1736
1737/// Session event "session.snapshot_rewind". Session rewind details including target event and count of removed events
1738#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1739#[serde(rename_all = "camelCase")]
1740pub struct SessionSnapshotRewindData {
1741    /// Number of events that were removed by the rewind
1742    pub events_removed: i64,
1743    /// Event ID that was rewound to; this event and all after it were removed
1744    pub up_to_event_id: String,
1745}
1746
1747/// Request count and cost metrics
1748#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1749#[serde(rename_all = "camelCase")]
1750pub struct ShutdownModelMetricRequests {
1751    /// Cumulative cost multiplier for requests to this model
1752    ///
1753    /// <div class="warning">
1754    ///
1755    /// **Experimental.** This type is part of an experimental wire-protocol surface
1756    /// and may change or be removed in future SDK or CLI releases.
1757    ///
1758    /// </div>
1759    #[serde(skip_serializing_if = "Option::is_none")]
1760    pub cost: Option<f64>,
1761    /// Total number of API requests made to this model
1762    ///
1763    /// <div class="warning">
1764    ///
1765    /// **Experimental.** This type is part of an experimental wire-protocol surface
1766    /// and may change or be removed in future SDK or CLI releases.
1767    ///
1768    /// </div>
1769    #[serde(skip_serializing_if = "Option::is_none")]
1770    pub count: Option<i64>,
1771}
1772
1773/// A token-type entry in a shutdown model metric, storing the accumulated token count.
1774#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1775#[serde(rename_all = "camelCase")]
1776pub struct ShutdownModelMetricTokenDetail {
1777    /// Accumulated token count for this token type
1778    pub token_count: i64,
1779}
1780
1781/// Token usage breakdown
1782#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1783#[serde(rename_all = "camelCase")]
1784pub struct ShutdownModelMetricUsage {
1785    /// Total tokens read from prompt cache across all requests
1786    pub cache_read_tokens: i64,
1787    /// Total tokens written to prompt cache across all requests
1788    pub cache_write_tokens: i64,
1789    /// Total input tokens consumed across all requests to this model
1790    pub input_tokens: i64,
1791    /// Total output tokens produced across all requests to this model
1792    pub output_tokens: i64,
1793    /// Total reasoning tokens produced across all requests to this model
1794    #[serde(skip_serializing_if = "Option::is_none")]
1795    pub reasoning_tokens: Option<i64>,
1796}
1797
1798/// Per-model shutdown metrics with request counts, token usage, nano-AI units, and token details.
1799#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1800#[serde(rename_all = "camelCase")]
1801pub struct ShutdownModelMetric {
1802    /// Request count and cost metrics
1803    pub requests: ShutdownModelMetricRequests,
1804    /// Token count details per type
1805    #[serde(skip_serializing_if = "Option::is_none")]
1806    pub token_details: Option<HashMap<String, ShutdownModelMetricTokenDetail>>,
1807    /// Accumulated nano-AI units cost for this model
1808    ///
1809    /// <div class="warning">
1810    ///
1811    /// **Experimental.** This type is part of an experimental wire-protocol surface
1812    /// and may change or be removed in future SDK or CLI releases.
1813    ///
1814    /// </div>
1815    #[serde(skip_serializing_if = "Option::is_none")]
1816    pub total_nano_aiu: Option<f64>,
1817    /// Token usage breakdown
1818    pub usage: ShutdownModelMetricUsage,
1819}
1820
1821/// Usage attributed to one agent instance at session shutdown.
1822#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1823#[serde(rename_all = "camelCase")]
1824pub struct ShutdownAgentMetric {
1825    /// 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.
1826    #[serde(skip_serializing_if = "Option::is_none")]
1827    pub agent_display_name: Option<String>,
1828    /// Configured agent name, when this is a subagent
1829    #[serde(skip_serializing_if = "Option::is_none")]
1830    pub agent_name: Option<String>,
1831    /// Per-model usage for this agent, keyed by model identifier
1832    pub model_metrics: HashMap<String, ShutdownModelMetric>,
1833    /// Time spent in model API calls by this agent, in milliseconds
1834    pub total_api_duration_ms: i64,
1835    /// Accumulated nano-AI units cost for this agent
1836    pub total_nano_aiu: f64,
1837}
1838
1839/// Aggregate code change metrics for the session
1840#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1841#[serde(rename_all = "camelCase")]
1842pub struct ShutdownCodeChanges {
1843    /// List of file paths that were modified during the session
1844    pub files_modified: Vec<String>,
1845    /// Total number of lines added during the session
1846    pub lines_added: i64,
1847    /// Total number of lines removed during the session
1848    pub lines_removed: i64,
1849}
1850
1851/// A session-wide shutdown token-type entry storing the accumulated token count.
1852#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1853#[serde(rename_all = "camelCase")]
1854pub struct ShutdownTokenDetail {
1855    /// Accumulated token count for this token type
1856    pub token_count: i64,
1857}
1858
1859/// Session event "session.shutdown". Session termination metrics including usage statistics, code changes, and shutdown reason
1860#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1861#[serde(rename_all = "camelCase")]
1862pub struct SessionShutdownData {
1863    /// Per-agent usage breakdown, keyed by agent instance identifier. The main conversation uses the stable key `main`.
1864    #[serde(skip_serializing_if = "Option::is_none")]
1865    pub agent_metrics: Option<HashMap<String, ShutdownAgentMetric>>,
1866    /// Aggregate code change metrics for the session
1867    pub code_changes: ShutdownCodeChanges,
1868    /// Non-system message token count at shutdown
1869    #[serde(skip_serializing_if = "Option::is_none")]
1870    pub conversation_tokens: Option<i64>,
1871    /// Model that was selected at the time of shutdown
1872    #[serde(skip_serializing_if = "Option::is_none")]
1873    pub current_model: Option<String>,
1874    /// Total tokens in context window at shutdown
1875    #[serde(skip_serializing_if = "Option::is_none")]
1876    pub current_tokens: Option<i64>,
1877    /// Error description when shutdownType is "error"
1878    #[serde(skip_serializing_if = "Option::is_none")]
1879    pub error_reason: Option<String>,
1880    /// 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
1881    #[serde(skip_serializing_if = "Option::is_none")]
1882    pub events_file_size_bytes: Option<i64>,
1883    /// Per-model usage breakdown, keyed by model identifier
1884    pub model_metrics: HashMap<String, ShutdownModelMetric>,
1885    /// Unix timestamp (milliseconds) when the session started
1886    pub session_start_time: i64,
1887    /// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
1888    pub shutdown_type: ShutdownType,
1889    /// System message token count at shutdown
1890    #[serde(skip_serializing_if = "Option::is_none")]
1891    pub system_tokens: Option<i64>,
1892    /// Session-wide per-token-type accumulated token counts
1893    #[serde(skip_serializing_if = "Option::is_none")]
1894    pub token_details: Option<HashMap<String, ShutdownTokenDetail>>,
1895    /// Tool definitions token count at shutdown
1896    #[serde(skip_serializing_if = "Option::is_none")]
1897    pub tool_definitions_tokens: Option<i64>,
1898    /// Cumulative time spent in API calls during the session, in milliseconds
1899    pub total_api_duration_ms: i64,
1900    /// Session-wide accumulated nano-AI units cost
1901    ///
1902    /// <div class="warning">
1903    ///
1904    /// **Experimental.** This type is part of an experimental wire-protocol surface
1905    /// and may change or be removed in future SDK or CLI releases.
1906    ///
1907    /// </div>
1908    #[serde(skip_serializing_if = "Option::is_none")]
1909    pub total_nano_aiu: Option<f64>,
1910    /// Total number of premium API requests used during the session
1911    #[doc(hidden)]
1912    #[serde(skip_serializing_if = "Option::is_none")]
1913    pub(crate) total_premium_requests: Option<f64>,
1914}
1915
1916/// Internal prompt-cache expiration state for one model
1917#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1918#[serde(rename_all = "camelCase")]
1919pub(crate) struct UsageCheckpointModelCacheState {
1920    /// Latest known prompt-cache expiration
1921    pub cache_expires_at: String,
1922    /// Retained cache lifetime in seconds, used to refresh expiration after a cache read
1923    #[doc(hidden)]
1924    pub(crate) cache_ttl_seconds: i64,
1925    /// Model identifier associated with this cache state
1926    pub model_id: String,
1927}
1928
1929/// Session event "session.usage_checkpoint". Durable session usage checkpoint for reconstructing aggregate accounting on resume
1930#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1931#[serde(rename_all = "camelCase")]
1932pub struct SessionUsageCheckpointData {
1933    /// Internal per-model prompt-cache state used to restore expiration tracking on resume
1934    #[doc(hidden)]
1935    #[serde(skip_serializing_if = "Option::is_none")]
1936    pub(crate) model_cache_state: Option<Vec<UsageCheckpointModelCacheState>>,
1937    /// Internal per-conversation prompt-cache-break detector baselines restored on resume
1938    #[doc(hidden)]
1939    #[serde(skip_serializing_if = "Option::is_none")]
1940    pub(crate) prompt_cache_break_state: Option<Vec<serde_json::Value>>,
1941    /// Session-wide accumulated nano-AI units cost at checkpoint time
1942    pub total_nano_aiu: f64,
1943    /// Total number of premium API requests used at checkpoint time
1944    #[doc(hidden)]
1945    #[serde(skip_serializing_if = "Option::is_none")]
1946    pub(crate) total_premium_requests: Option<f64>,
1947}
1948
1949/// Session event "session.context_changed". Updated working directory and git context after the change
1950#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1951#[serde(rename_all = "camelCase")]
1952pub struct SessionContextChangedData {
1953    /// Base commit of current git branch at session start time
1954    #[serde(skip_serializing_if = "Option::is_none")]
1955    pub base_commit: Option<String>,
1956    /// Current git branch name
1957    #[serde(skip_serializing_if = "Option::is_none")]
1958    pub branch: Option<String>,
1959    /// Current working directory path
1960    pub cwd: String,
1961    /// Root directory of the git repository, resolved via git rev-parse
1962    #[serde(skip_serializing_if = "Option::is_none")]
1963    pub git_root: Option<String>,
1964    /// Head commit of current git branch at session start time
1965    #[serde(skip_serializing_if = "Option::is_none")]
1966    pub head_commit: Option<String>,
1967    /// Hosting platform type of the repository (github or ado)
1968    #[serde(skip_serializing_if = "Option::is_none")]
1969    pub host_type: Option<WorkingDirectoryContextHostType>,
1970    /// 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).
1971    #[serde(skip_serializing_if = "Option::is_none")]
1972    pub pending_git_context: Option<bool>,
1973    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
1974    #[serde(skip_serializing_if = "Option::is_none")]
1975    pub repository: Option<String>,
1976    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
1977    #[serde(skip_serializing_if = "Option::is_none")]
1978    pub repository_host: Option<String>,
1979}
1980
1981/// Session event "session.usage_info". Current context window usage statistics including token and message counts
1982#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1983#[serde(rename_all = "camelCase")]
1984pub struct SessionUsageInfoData {
1985    /// Token count from non-system messages (user, assistant, tool)
1986    #[serde(skip_serializing_if = "Option::is_none")]
1987    pub conversation_tokens: Option<i64>,
1988    /// Current number of tokens in the context window
1989    pub current_tokens: i64,
1990    /// Whether this is the first usage_info event emitted in this session
1991    #[serde(skip_serializing_if = "Option::is_none")]
1992    pub is_initial: Option<bool>,
1993    /// Current number of messages in the conversation
1994    pub messages_length: i64,
1995    /// Token count from system message(s)
1996    #[serde(skip_serializing_if = "Option::is_none")]
1997    pub system_tokens: Option<i64>,
1998    /// Maximum token count for the model's context window
1999    pub token_limit: i64,
2000    /// Token count from tool definitions
2001    #[serde(skip_serializing_if = "Option::is_none")]
2002    pub tool_definitions_tokens: Option<i64>,
2003}
2004
2005/// Session event "session.context_cleared". Context-cleared details emitted when the host clears the conversation (the session.history.clearContext RPC / Session.clearContextMessages)
2006#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2007#[serde(rename_all = "camelCase")]
2008pub struct SessionContextClearedData {
2009    /// Optional initial message set after clearing
2010    #[serde(skip_serializing_if = "Option::is_none")]
2011    pub initial_message: Option<String>,
2012    /// Number of conversation messages that were cleared
2013    pub messages_cleared: i64,
2014}
2015
2016/// Session event "session.compaction_start". Context window breakdown at the start of LLM-powered conversation compaction
2017#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2018#[serde(rename_all = "camelCase")]
2019pub struct SessionCompactionStartData {
2020    /// Token count from non-system messages (user, assistant, tool) at compaction start
2021    #[serde(skip_serializing_if = "Option::is_none")]
2022    pub conversation_tokens: Option<i64>,
2023    /// Total context tokens (system + conversation + tool definitions) at compaction start, when known
2024    #[serde(skip_serializing_if = "Option::is_none")]
2025    pub current_tokens: Option<i64>,
2026    /// Model identifier used for compaction, when known
2027    #[serde(skip_serializing_if = "Option::is_none")]
2028    pub model: Option<String>,
2029    /// Token count from system message(s) at compaction start
2030    #[serde(skip_serializing_if = "Option::is_none")]
2031    pub system_tokens: Option<i64>,
2032    /// Model context window token limit the compaction is targeting, when known
2033    #[serde(skip_serializing_if = "Option::is_none")]
2034    pub token_limit: Option<i64>,
2035    /// Token count from tool definitions at compaction start
2036    #[serde(skip_serializing_if = "Option::is_none")]
2037    pub tool_definitions_tokens: Option<i64>,
2038    /// What initiated this compaction, when known
2039    #[serde(skip_serializing_if = "Option::is_none")]
2040    pub trigger: Option<CompactionTrigger>,
2041}
2042
2043/// Token usage detail for a single billing category
2044#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2045#[serde(rename_all = "camelCase")]
2046pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
2047    /// Number of tokens in this billing batch
2048    pub batch_size: i64,
2049    /// Cost per batch of tokens
2050    pub cost_per_batch: i64,
2051    /// Model responsible for this billing entry
2052    #[serde(skip_serializing_if = "Option::is_none")]
2053    pub model: Option<String>,
2054    /// Total token count for this entry
2055    pub token_count: i64,
2056    /// Token category (e.g., "input", "output")
2057    pub token_type: String,
2058}
2059
2060/// Per-request cost and usage data from the CAPI copilot_usage response field
2061#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2062#[serde(rename_all = "camelCase")]
2063pub(crate) struct CompactionCompleteCompactionTokensUsedCopilotUsage {
2064    /// Default billing model for token details that do not identify their own model
2065    #[doc(hidden)]
2066    #[serde(skip_serializing_if = "Option::is_none")]
2067    pub(crate) model: Option<String>,
2068    /// Itemized token usage breakdown
2069    #[doc(hidden)]
2070    #[serde(skip_serializing_if = "Option::is_none")]
2071    pub(crate) token_details:
2072        Option<Vec<CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail>>,
2073    /// Total cost in nano-AI units for this request
2074    pub total_nano_aiu: f64,
2075}
2076
2077/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
2078#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2079#[serde(rename_all = "camelCase")]
2080pub struct CompactionCompleteCompactionTokensUsed {
2081    /// Cached input tokens reused in the compaction LLM call
2082    #[serde(skip_serializing_if = "Option::is_none")]
2083    pub cache_read_tokens: Option<i64>,
2084    /// Tokens written to prompt cache in the compaction LLM call
2085    #[serde(skip_serializing_if = "Option::is_none")]
2086    pub cache_write_tokens: Option<i64>,
2087    /// Per-request cost and usage data from the CAPI copilot_usage response field
2088    #[doc(hidden)]
2089    #[serde(skip_serializing_if = "Option::is_none")]
2090    pub(crate) copilot_usage: Option<CompactionCompleteCompactionTokensUsedCopilotUsage>,
2091    /// Duration of the compaction LLM call in milliseconds
2092    #[serde(skip_serializing_if = "Option::is_none")]
2093    pub duration: Option<i64>,
2094    /// Input tokens consumed by the compaction LLM call
2095    #[serde(skip_serializing_if = "Option::is_none")]
2096    pub input_tokens: Option<i64>,
2097    /// Model identifier used for the compaction LLM call
2098    #[serde(skip_serializing_if = "Option::is_none")]
2099    pub model: Option<String>,
2100    /// Output tokens produced by the compaction LLM call
2101    #[serde(skip_serializing_if = "Option::is_none")]
2102    pub output_tokens: Option<i64>,
2103}
2104
2105/// Original request-level and effective conversation reasoning effort for a Responses history boundary
2106#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2107#[serde(rename_all = "camelCase")]
2108pub struct ResponsesReasoning {
2109    /// Effective effort selected before this message, independent of the response-level reasoning field
2110    pub effort: String,
2111    /// Original request-level effort, retained while replaying this conversation prefix
2112    pub initial_effort: String,
2113    /// Provider model whose reasoning settings this boundary records
2114    pub model: String,
2115}
2116
2117/// Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
2118#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2119#[serde(rename_all = "camelCase")]
2120pub struct SessionCompactionCompleteData {
2121    /// Authoritative active-factory reminder appended to the compacted context
2122    #[doc(hidden)]
2123    #[serde(skip_serializing_if = "Option::is_none")]
2124    pub(crate) active_factory_summary: Option<String>,
2125    /// Canonical model identifier used for model-specific behavior when replaying compaction
2126    #[serde(skip_serializing_if = "Option::is_none")]
2127    pub behavior_model_id: Option<String>,
2128    /// Checkpoint snapshot number created for recovery
2129    #[serde(skip_serializing_if = "Option::is_none")]
2130    pub checkpoint_number: Option<i64>,
2131    /// File path where the checkpoint was stored
2132    #[serde(skip_serializing_if = "Option::is_none")]
2133    pub checkpoint_path: Option<String>,
2134    /// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
2135    #[serde(skip_serializing_if = "Option::is_none")]
2136    pub compaction_tokens_used: Option<CompactionCompleteCompactionTokensUsed>,
2137    /// Token count from non-system messages (user, assistant, tool) after compaction
2138    #[serde(skip_serializing_if = "Option::is_none")]
2139    pub conversation_tokens: Option<i64>,
2140    /// User-supplied focus instructions provided to a manual `/compact` invocation. Omitted for automatic compaction and for manual compaction with no focus text.
2141    #[serde(skip_serializing_if = "Option::is_none")]
2142    pub custom_instructions: Option<String>,
2143    /// Error message if compaction failed
2144    #[serde(skip_serializing_if = "Option::is_none")]
2145    pub error: Option<String>,
2146    /// Number of messages removed during compaction
2147    #[serde(skip_serializing_if = "Option::is_none")]
2148    pub messages_removed: Option<i64>,
2149    /// Total tokens in conversation after compaction
2150    #[serde(skip_serializing_if = "Option::is_none")]
2151    pub post_compaction_tokens: Option<i64>,
2152    /// Number of messages before compaction
2153    #[serde(skip_serializing_if = "Option::is_none")]
2154    pub pre_compaction_messages_length: Option<i64>,
2155    /// Total tokens in conversation before compaction
2156    #[serde(skip_serializing_if = "Option::is_none")]
2157    pub pre_compaction_tokens: Option<i64>,
2158    /// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
2159    #[serde(skip_serializing_if = "Option::is_none")]
2160    pub request_id: Option<RequestId>,
2161    /// Reasoning baseline on the replacement summary, preserved when replay skips the compacted history
2162    #[serde(skip_serializing_if = "Option::is_none")]
2163    pub responses_reasoning: Option<ResponsesReasoning>,
2164    /// Copilot service request ID (x-copilot-service-request-id header) for the compaction LLM call
2165    #[serde(skip_serializing_if = "Option::is_none")]
2166    pub service_request_id: Option<String>,
2167    /// 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).
2168    #[serde(skip_serializing_if = "Option::is_none")]
2169    pub status_code: Option<i64>,
2170    /// Whether compaction completed successfully
2171    pub success: bool,
2172    /// LLM-generated summary of the compacted conversation history
2173    #[serde(skip_serializing_if = "Option::is_none")]
2174    pub summary_content: Option<String>,
2175    /// Token count from system message(s) after compaction
2176    #[serde(skip_serializing_if = "Option::is_none")]
2177    pub system_tokens: Option<i64>,
2178    /// Model context window token limit the compaction was targeting, when known
2179    #[serde(skip_serializing_if = "Option::is_none")]
2180    pub token_limit: Option<i64>,
2181    /// Number of tokens removed during compaction
2182    #[serde(skip_serializing_if = "Option::is_none")]
2183    pub tokens_removed: Option<i64>,
2184    /// Token count from tool definitions after compaction
2185    #[serde(skip_serializing_if = "Option::is_none")]
2186    pub tool_definitions_tokens: Option<i64>,
2187    /// What initiated this compaction, when known
2188    #[serde(skip_serializing_if = "Option::is_none")]
2189    pub trigger: Option<CompactionTrigger>,
2190}
2191
2192#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2193#[serde(rename_all = "camelCase")]
2194pub struct PermissionRecoveryAttempt {
2195    /// Unique identifier for this attempt record
2196    pub attempt_id: String,
2197    /// How the runtime handled this attempt
2198    pub disposition: PermissionRecoveryAttemptDisposition,
2199    /// One-based position of this attempt in the episode
2200    pub ordinal: i64,
2201    /// Controlled permission request kind, such as shell, path, URL, or tool
2202    pub permission_kind: String,
2203    /// Controlled reason for the attempt disposition
2204    pub reason: PermissionRecoveryAttemptReason,
2205    /// Relationship between this attempt and earlier attempts in the episode
2206    pub relation: PermissionRecoveryAttemptRelation,
2207    /// SHA-256 fingerprint of normalized request data; raw permission arguments are not included
2208    pub request_fingerprint: String,
2209    /// Tool-call identifier associated with this attempt, when available
2210    #[serde(skip_serializing_if = "Option::is_none")]
2211    pub tool_call_id: Option<String>,
2212}
2213
2214/// Authoritative snapshot of an Autopilot permission-recovery episode
2215#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2216#[serde(rename_all = "camelCase")]
2217pub struct PermissionRecoveryData {
2218    /// Ordered privacy-safe record of permission attempts and the successful alternative, when any
2219    pub attempts: Vec<PermissionRecoveryAttempt>,
2220    /// Stable identifier shared by every transition in this recovery episode
2221    pub episode_id: String,
2222    /// Maximum number of distinct autonomous permission attempts allowed before escalation
2223    pub max_attempts: i64,
2224    /// Policy selected from the current client's response capability; mode or client changes may update it during recovery
2225    pub on_blocked: PermissionRecoveryOnBlocked,
2226    /// Controlled reason for the latest episode transition
2227    pub reason: PermissionRecoveryReason,
2228    /// Current lifecycle state of the recovery episode
2229    pub status: PermissionRecoveryStatus,
2230}
2231
2232/// Structured reason that the task cannot continue without intervention
2233///
2234/// <div class="warning">
2235///
2236/// **Experimental.** This type is part of an experimental wire-protocol surface
2237/// and may change or be removed in future SDK or CLI releases.
2238///
2239/// </div>
2240#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2241#[serde(rename_all = "camelCase")]
2242pub struct TaskBlocker {
2243    /// Category of intervention that blocked the task
2244    pub kind: TaskBlockerKind,
2245    /// Permission-recovery episode that produced this blocker
2246    pub permission_recovery: PermissionRecoveryData,
2247    /// Controlled reason for the current blocked state
2248    pub reason: PermissionRecoveryReason,
2249    /// Whether a later user response or steering message can resume the task
2250    pub resumable: bool,
2251}
2252
2253/// Session event "session.task_complete". Task completion notification with summary from the agent
2254#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2255#[serde(rename_all = "camelCase")]
2256pub struct SessionTaskCompleteData {
2257    /// Structured blocker details when outcome is blocked
2258    #[serde(skip_serializing_if = "Option::is_none")]
2259    pub blocker: Option<TaskBlocker>,
2260    /// Active autopilot objective ID evaluated by the completion reviewer
2261    #[serde(skip_serializing_if = "Option::is_none")]
2262    pub objective_id: Option<i64>,
2263    /// Semantic completion decision. Absent on legacy events and invalid tool calls
2264    #[serde(skip_serializing_if = "Option::is_none")]
2265    pub outcome: Option<TaskCompletionOutcome>,
2266    /// 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
2267    #[serde(skip_serializing_if = "Option::is_none")]
2268    pub reason: Option<String>,
2269    /// Whether the task was accepted as complete. False when validation failed or completion was rejected or blocked by the reviewer
2270    #[serde(skip_serializing_if = "Option::is_none")]
2271    pub success: Option<bool>,
2272    /// Summary of the completed task, provided by the agent
2273    #[serde(skip_serializing_if = "Option::is_none")]
2274    pub summary: Option<String>,
2275}
2276
2277/// Inclusive durable event range summarized by a completion receipt.
2278#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2279#[serde(rename_all = "camelCase")]
2280pub struct CompletionReceiptEventRange {
2281    /// 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.
2282    pub end_event_id: String,
2283    /// Identifier of the user message that starts the covered exchange.
2284    pub start_event_id: String,
2285}
2286
2287/// Final structured tool completion in the covered event range.
2288#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2289#[serde(rename_all = "camelCase")]
2290pub struct CompletionReceiptFinalTool {
2291    /// Process exit code from a structured shell result, when available.
2292    #[serde(skip_serializing_if = "Option::is_none")]
2293    pub exit_code: Option<i64>,
2294    /// Structured success or failure status from the tool completion event.
2295    pub status: CompletionReceiptToolStatus,
2296    /// Unique identifier of the completed tool call.
2297    pub tool_call_id: String,
2298    /// Tool name from the matching tool execution start event, when available.
2299    #[serde(skip_serializing_if = "Option::is_none")]
2300    pub tool_name: Option<String>,
2301}
2302
2303/// Session event "session.completion_receipt". Behavior-neutral record of structured runtime facts present when an agent completion decision is accepted.
2304///
2305/// <div class="warning">
2306///
2307/// **Experimental.** This type is part of an experimental wire-protocol surface
2308/// and may change or be removed in future SDK or CLI releases.
2309///
2310/// </div>
2311#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2312#[serde(rename_all = "camelCase")]
2313pub struct SessionCompletionReceiptData {
2314    /// One-based accepted completion receipt ordinal in the durable session history.
2315    pub attempt: i64,
2316    /// Inclusive durable event range summarized by this receipt.
2317    pub event_range: CompletionReceiptEventRange,
2318    /// Number of failed structured tool completions in the covered range.
2319    pub failed_tool_count: i64,
2320    /// Final structured tool completion in the covered range, when one exists.
2321    #[serde(skip_serializing_if = "Option::is_none")]
2322    pub final_tool: Option<CompletionReceiptFinalTool>,
2323    /// Version of the completion receipt payload.
2324    pub schema_version: i64,
2325    /// 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.
2326    pub source_event_id: String,
2327    /// Runtime reason the completion decision was accepted.
2328    pub stop_reason: CompletionReceiptStopReason,
2329    /// Number of successful structured tool completions in the covered range.
2330    pub successful_tool_count: i64,
2331}
2332
2333/// Session event "session.fusion_route_started". Experimental transient signal that HydraFusion routing has started for an eligible turn.
2334///
2335/// <div class="warning">
2336///
2337/// **Experimental.** This type is part of an experimental wire-protocol surface
2338/// and may change or be removed in future SDK or CLI releases.
2339///
2340/// </div>
2341#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2342#[serde(rename_all = "camelCase")]
2343pub struct SessionFusionRouteStartedData {
2344    /// Identifier for this routing attempt before a durable Fusion turn exists.
2345    pub attempt_id: String,
2346    /// HydraFusion routing policy requested for the turn.
2347    #[serde(skip_serializing_if = "Option::is_none")]
2348    pub policy: Option<String>,
2349    /// Synthetic HydraFusion model selected for the session.
2350    #[serde(skip_serializing_if = "Option::is_none")]
2351    pub synthetic_model: Option<String>,
2352    /// Kind of turn being routed.
2353    pub turn_kind: FusionTurnKind,
2354}
2355
2356/// Session event "session.fusion_route_failed". Experimental durable HydraFusion routing failure and the deterministic concrete fallback selected for the turn.
2357///
2358/// <div class="warning">
2359///
2360/// **Experimental.** This type is part of an experimental wire-protocol surface
2361/// and may change or be removed in future SDK or CLI releases.
2362///
2363/// </div>
2364#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2365#[serde(rename_all = "camelCase")]
2366pub struct SessionFusionRouteFailedData {
2367    /// Identifier of the routing attempt that failed.
2368    pub attempt_id: String,
2369    /// Provider or validation error detail, when available.
2370    #[serde(skip_serializing_if = "Option::is_none")]
2371    pub error_message: Option<String>,
2372    /// Concrete model selected as the deterministic fallback.
2373    pub fallback_model: String,
2374    /// HydraFusion routing policy requested for the turn.
2375    pub policy: String,
2376    /// Stable machine-readable reason for the routing failure.
2377    pub reason: String,
2378    /// Elapsed routing time in milliseconds before the failure.
2379    #[serde(skip_serializing_if = "Option::is_none")]
2380    pub routing_latency_ms: Option<f64>,
2381    /// Synthetic HydraFusion model selected for the session.
2382    pub synthetic_model: String,
2383}
2384
2385/// Durable server recommendation for subsequent HydraFusion turns.
2386///
2387/// <div class="warning">
2388///
2389/// **Experimental.** This type is part of an experimental wire-protocol surface
2390/// and may change or be removed in future SDK or CLI releases.
2391///
2392/// </div>
2393#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2394#[serde(rename_all = "camelCase")]
2395pub struct FusionFollowUpRecommendation {
2396    /// Recommended routing action for the next compaction turn.
2397    pub compaction_turn: FusionFollowUpAction,
2398    /// Recommended routing action for the next user-message turn.
2399    pub user_turn: FusionFollowUpAction,
2400}
2401
2402/// Presentation-neutral phase planned for a HydraFusion turn.
2403///
2404/// <div class="warning">
2405///
2406/// **Experimental.** This type is part of an experimental wire-protocol surface
2407/// and may change or be removed in future SDK or CLI releases.
2408///
2409/// </div>
2410#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2411#[serde(rename_all = "camelCase")]
2412pub struct FusionPhasePlanStep {
2413    /// Whether the phase executes only when an earlier phase requests it.
2414    pub conditional: bool,
2415    /// Kind of phase that may execute.
2416    pub kind: FusionPhaseKind,
2417    /// Semantic role assigned to the phase.
2418    pub role: String,
2419    /// Conversation scope in which the phase executes.
2420    pub scope: FusionConversationScope,
2421}
2422
2423/// Validated HydraFusion routing capability scores.
2424///
2425/// <div class="warning">
2426///
2427/// **Experimental.** This type is part of an experimental wire-protocol surface
2428/// and may change or be removed in future SDK or CLI releases.
2429///
2430/// </div>
2431#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2432#[serde(rename_all = "camelCase")]
2433pub struct FusionScores {
2434    /// Code-generation capability score returned by the authenticated router.
2435    pub code_gen: f64,
2436    /// Debugging capability score returned by the authenticated router.
2437    pub debugging: f64,
2438    /// Reasoning capability score returned by the authenticated router.
2439    pub reasoning: f64,
2440    /// Tool-use capability score returned by the authenticated router.
2441    pub tool_use: f64,
2442}
2443
2444/// Session event "session.fusion_resolved". Experimental durable validated HydraFusion route and turn policy.
2445///
2446/// <div class="warning">
2447///
2448/// **Experimental.** This type is part of an experimental wire-protocol surface
2449/// and may change or be removed in future SDK or CLI releases.
2450///
2451/// </div>
2452#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2453#[serde(rename_all = "camelCase")]
2454pub struct SessionFusionResolvedData {
2455    /// Version of the validated HydraFusion event contract.
2456    pub contract_version: i64,
2457    /// Concrete model used when the planned primary model cannot execute.
2458    pub fallback_model: String,
2459    /// Router recommendation controlling reuse or rerouting on later turns.
2460    #[serde(skip_serializing_if = "Option::is_none")]
2461    pub follow_up: Option<FusionFollowUpRecommendation>,
2462    /// Concrete model recommended for eligible follow-up turns.
2463    pub follow_up_model: String,
2464    /// Stable identifier for the resolved HydraFusion turn.
2465    pub fusion_id: String,
2466    /// Version of the executable model universe used for selection.
2467    #[serde(skip_serializing_if = "Option::is_none")]
2468    pub model_universe_version: Option<String>,
2469    /// Validated orchestration pattern selected for the turn.
2470    pub pattern: FusionPattern,
2471    /// Presentation-neutral phase plan for clients that render workflow progress.
2472    ///
2473    /// <div class="warning">
2474    ///
2475    /// **Experimental.** This type is part of an experimental wire-protocol surface
2476    /// and may change or be removed in future SDK or CLI releases.
2477    ///
2478    /// </div>
2479    #[serde(skip_serializing_if = "Option::is_none")]
2480    pub phase_plan: Option<Vec<FusionPhasePlanStep>>,
2481    /// Version of the validated execution-plan format.
2482    #[serde(skip_serializing_if = "Option::is_none")]
2483    pub plan_version: Option<String>,
2484    /// HydraFusion routing policy used to resolve the plan.
2485    pub policy: String,
2486    /// Version of the local routing policy.
2487    #[serde(skip_serializing_if = "Option::is_none")]
2488    pub policy_version: Option<String>,
2489    /// Concrete model selected for the primary solver phase.
2490    pub primary_model: String,
2491    /// Router implementation that supplied the plan.
2492    #[serde(skip_serializing_if = "Option::is_none")]
2493    pub route_source: Option<String>,
2494    /// Elapsed time in milliseconds required to resolve and validate the route.
2495    #[serde(skip_serializing_if = "Option::is_none")]
2496    pub routing_latency_ms: Option<f64>,
2497    /// Identifier of the local policy rule that matched.
2498    #[serde(skip_serializing_if = "Option::is_none")]
2499    pub rule_id: Option<String>,
2500    /// Zero-based index of the local policy rule that matched.
2501    #[serde(skip_serializing_if = "Option::is_none")]
2502    pub rule_index: Option<i64>,
2503    /// Human-readable name of the local policy rule that matched.
2504    #[serde(skip_serializing_if = "Option::is_none")]
2505    pub rule_name: Option<String>,
2506    /// Validated capability scores used to select the route.
2507    #[serde(skip_serializing_if = "Option::is_none")]
2508    pub scores: Option<FusionScores>,
2509    /// Concrete model selected for the review or judge phase, when required.
2510    pub secondary_model: Option<String>,
2511    /// Synthetic HydraFusion model selected for the session.
2512    pub synthetic_model: String,
2513    /// Identifier of the session turn associated with the route.
2514    pub turn_id: String,
2515}
2516
2517/// Session event "session.fusion_completed". Experimental durable aggregate outcome of a HydraFusion turn.
2518///
2519/// <div class="warning">
2520///
2521/// **Experimental.** This type is part of an experimental wire-protocol surface
2522/// and may change or be removed in future SDK or CLI releases.
2523///
2524/// </div>
2525#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2526#[serde(rename_all = "camelCase")]
2527pub struct SessionFusionCompletedData {
2528    /// Total cached input tokens reported across all phases.
2529    pub cached_tokens: i64,
2530    /// Total tokens written to prompt cache across all phases.
2531    #[serde(skip_serializing_if = "Option::is_none")]
2532    pub cache_write_tokens: Option<i64>,
2533    /// Idempotency identifier for the authoritative final commit.
2534    pub commit_id: String,
2535    /// Reason the turn used a degraded route, when applicable.
2536    pub degraded_reason: Option<String>,
2537    /// Total elapsed execution time for the HydraFusion turn in milliseconds.
2538    pub duration_ms: f64,
2539    /// Concrete model that supplied the authoritative final content.
2540    pub final_source_model: Option<String>,
2541    /// Phase whose output supplied the authoritative final content.
2542    pub final_source_phase_id: Option<String>,
2543    /// Concrete model recommended for eligible follow-up turns.
2544    pub follow_up_model: String,
2545    /// Stable identifier for the completed HydraFusion turn.
2546    pub fusion_id: String,
2547    /// Total input tokens consumed across all phases.
2548    pub input_tokens: i64,
2549    /// Stable aggregate outcome of the HydraFusion turn.
2550    pub outcome: String,
2551    /// Total output tokens produced across all phases.
2552    pub output_tokens: i64,
2553    /// HydraFusion orchestration pattern executed for the turn.
2554    pub pattern: FusionPattern,
2555    /// Number of concrete phases attempted by the turn.
2556    pub phase_count: i64,
2557    /// Total concrete model requests made across all phases.
2558    pub request_count: i64,
2559    /// Synthetic HydraFusion model selected for the session.
2560    pub synthetic_model: String,
2561    /// Total normalized AI-unit cost reported across all phases, in nano-AIU.
2562    pub total_nano_aiu: f64,
2563    /// Identifier of the session turn associated with the completion.
2564    pub turn_id: String,
2565}
2566
2567/// Session event "session.permission_recovery". Authoritative snapshot of an Autopilot permission-recovery episode
2568#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2569#[serde(rename_all = "camelCase")]
2570pub struct SessionPermissionRecoveryData {
2571    /// Ordered privacy-safe record of permission attempts and the successful alternative, when any
2572    pub attempts: Vec<PermissionRecoveryAttempt>,
2573    /// Stable identifier shared by every transition in this recovery episode
2574    pub episode_id: String,
2575    /// Maximum number of distinct autonomous permission attempts allowed before escalation
2576    pub max_attempts: i64,
2577    /// Policy selected from the current client's response capability; mode or client changes may update it during recovery
2578    pub on_blocked: PermissionRecoveryOnBlocked,
2579    /// Controlled reason for the latest episode transition
2580    pub reason: PermissionRecoveryReason,
2581    /// Current lifecycle state of the recovery episode
2582    pub status: PermissionRecoveryStatus,
2583}
2584
2585/// Session event "user.message". Payload of `user.message` with displayed and model-transformed content, attachments, source/delivery metadata, mode, and telemetry IDs.
2586#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2587#[serde(rename_all = "camelCase")]
2588pub struct UserMessageData {
2589    /// The agent mode that was active when this message was sent
2590    #[serde(skip_serializing_if = "Option::is_none")]
2591    pub agent_mode: Option<UserMessageAgentMode>,
2592    /// Files, selections, or GitHub references attached to the message
2593    #[serde(skip_serializing_if = "Option::is_none")]
2594    pub attachments: Option<Vec<serde_json::Value>>,
2595    /// The user's message text as displayed in the timeline
2596    pub content: String,
2597    /// 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.
2598    #[serde(skip_serializing_if = "Option::is_none")]
2599    pub delivery: Option<UserMessageDelivery>,
2600    /// CAPI interaction ID for correlating this user message with its turn
2601    #[serde(skip_serializing_if = "Option::is_none")]
2602    pub interaction_id: Option<String>,
2603    /// 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.
2604    #[serde(skip_serializing_if = "Option::is_none")]
2605    pub is_autopilot_continuation: Option<bool>,
2606    /// Stable identity of the logical user message, matching the ID returned by send and retained by pending queue snapshots
2607    #[serde(skip_serializing_if = "Option::is_none")]
2608    pub message_id: Option<String>,
2609    /// 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
2610    #[serde(skip_serializing_if = "Option::is_none")]
2611    pub native_document_path_fallback_paths: Option<Vec<String>>,
2612    /// Parent agent task ID for background telemetry correlated to this user turn
2613    #[serde(skip_serializing_if = "Option::is_none")]
2614    pub parent_agent_task_id: Option<String>,
2615    /// Responses reasoning settings anchored before this model-facing message, for cache-stable history replay
2616    #[serde(skip_serializing_if = "Option::is_none")]
2617    pub responses_reasoning: Option<ResponsesReasoning>,
2618    /// 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)
2619    #[serde(skip_serializing_if = "Option::is_none")]
2620    pub source: Option<String>,
2621    /// Normalized document MIME types that were sent natively instead of through tagged_files XML
2622    #[serde(skip_serializing_if = "Option::is_none")]
2623    pub supported_native_document_mime_types: Option<Vec<String>>,
2624    /// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching
2625    #[serde(skip_serializing_if = "Option::is_none")]
2626    pub transformed_content: Option<String>,
2627    /// The agent-loop turn ID that consumed this message; absent when no agent-loop turn consumed it
2628    #[serde(skip_serializing_if = "Option::is_none")]
2629    pub turn_id: Option<String>,
2630}
2631
2632/// Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
2633#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2634#[serde(rename_all = "camelCase")]
2635pub struct PendingMessagesModifiedData {}
2636
2637/// Session event "assistant.turn_start". Turn initialization metadata including identifier and interaction tracking
2638#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2639#[serde(rename_all = "camelCase")]
2640pub struct AssistantTurnStartData {
2641    /// CAPI interaction ID for correlating this turn with upstream telemetry
2642    #[serde(skip_serializing_if = "Option::is_none")]
2643    pub interaction_id: Option<String>,
2644    /// Model identifier used for this turn, when known
2645    #[serde(skip_serializing_if = "Option::is_none")]
2646    pub model: Option<String>,
2647    /// Identifier for this turn within the agentic loop, typically a stringified turn number
2648    pub turn_id: String,
2649}
2650
2651/// Session event "assistant.turn_retry". Metadata for an additional model inference attempt within an existing assistant turn
2652#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2653#[serde(rename_all = "camelCase")]
2654pub struct AssistantTurnRetryData {
2655    /// Model identifier used for this retry, when known
2656    #[serde(skip_serializing_if = "Option::is_none")]
2657    pub model: Option<String>,
2658    /// Provider or runtime classification that caused the retry, when known
2659    #[serde(skip_serializing_if = "Option::is_none")]
2660    pub reason: Option<String>,
2661    /// Identifier of the turn whose model inference is being retried
2662    pub turn_id: String,
2663}
2664
2665/// Session event "agent.interrupted". Metadata for work the user interrupted while the agent was running
2666#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2667#[serde(rename_all = "camelCase")]
2668pub struct AgentInterruptedData {
2669    /// What the agent was doing when the user interrupted it
2670    pub activity: AgentInterruptedActivity,
2671    /// For an interrupted model call: the provider endpoint the request targeted
2672    #[serde(skip_serializing_if = "Option::is_none")]
2673    pub api_endpoint: Option<String>,
2674    /// For an interrupted model call: whether the user interrupted before any token arrived or while the response was streaming
2675    #[serde(skip_serializing_if = "Option::is_none")]
2676    pub cancel_phase: Option<AgentInterruptedCancelPhase>,
2677    /// How long the interrupted work had been running, in milliseconds
2678    pub elapsed_ms: f64,
2679    /// 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.
2680    #[serde(skip_serializing_if = "Option::is_none")]
2681    pub interrupted_agent_count: Option<i64>,
2682    /// For an interrupted model call: the model the request targeted
2683    #[serde(skip_serializing_if = "Option::is_none")]
2684    pub model: Option<String>,
2685    /// 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.
2686    #[serde(skip_serializing_if = "Option::is_none")]
2687    pub output_ttft_ms: Option<f64>,
2688    /// For an interrupted model call: the reasoning effort the request asked for
2689    #[serde(skip_serializing_if = "Option::is_none")]
2690    pub reasoning_effort: Option<String>,
2691    /// Subset of `toolNames` whose tool metadata marks the tool name as safe to record unhashed in telemetry.
2692    #[serde(skip_serializing_if = "Option::is_none")]
2693    pub safe_tool_names: Option<Vec<String>>,
2694    /// Tool call identifiers that were still running
2695    #[serde(skip_serializing_if = "Option::is_none")]
2696    pub tool_call_ids: Option<Vec<String>>,
2697    /// Names of the tools that were still running. More than one when the model requested a parallel fan-out.
2698    #[serde(skip_serializing_if = "Option::is_none")]
2699    pub tool_names: Option<Vec<String>>,
2700    /// For an interrupted model call: the transport the request used
2701    #[serde(skip_serializing_if = "Option::is_none")]
2702    pub transport: Option<ModelCallFailureTransport>,
2703    /// Zero-based agentic-loop iteration the interrupt landed in
2704    pub turn: i64,
2705}
2706
2707/// Session event "assistant.intent". Agent intent description for current activity or plan
2708#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2709#[serde(rename_all = "camelCase")]
2710pub struct AssistantIntentData {
2711    /// Short description of what the agent is currently doing or planning to do
2712    pub intent: String,
2713}
2714
2715/// Session event "assistant.fusion_phase_started". Experimental transient HydraFusion phase/model/role signal.
2716///
2717/// <div class="warning">
2718///
2719/// **Experimental.** This type is part of an experimental wire-protocol surface
2720/// and may change or be removed in future SDK or CLI releases.
2721///
2722/// </div>
2723#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2724#[serde(rename_all = "camelCase")]
2725pub struct AssistantFusionPhaseStartedData {
2726    /// Conversation scope in which the phase executes.
2727    pub conversation_scope: FusionConversationScope,
2728    /// Identifier of the HydraFusion turn containing the phase.
2729    pub fusion_id: String,
2730    /// Concrete model executing the phase.
2731    pub model: String,
2732    /// HydraFusion orchestration pattern containing the phase.
2733    pub pattern: FusionPattern,
2734    /// Stable identifier for the concrete phase.
2735    pub phase_id: String,
2736    /// Kind of phase being executed.
2737    pub phase_kind: FusionPhaseKind,
2738    /// Semantic role assigned to the phase.
2739    pub role: String,
2740}
2741
2742/// Session event "assistant.fusion_phase_activity". Experimental content-safe activity signal for a running HydraFusion phase.
2743///
2744/// <div class="warning">
2745///
2746/// **Experimental.** This type is part of an experimental wire-protocol surface
2747/// and may change or be removed in future SDK or CLI releases.
2748///
2749/// </div>
2750#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2751#[serde(rename_all = "camelCase")]
2752pub struct AssistantFusionPhaseActivityData {
2753    /// Kind of real activity observed.
2754    pub activity: FusionPhaseActivityKind,
2755    /// Conversation scope in which the phase executes.
2756    pub conversation_scope: FusionConversationScope,
2757    /// Identifier of the HydraFusion turn containing the phase.
2758    pub fusion_id: String,
2759    /// HydraFusion orchestration pattern containing the phase.
2760    pub pattern: FusionPattern,
2761    /// Stable identifier for the concrete phase.
2762    pub phase_id: String,
2763    /// Kind of phase currently executing.
2764    pub phase_kind: FusionPhaseKind,
2765    /// Semantic role assigned to the phase.
2766    pub role: String,
2767    /// 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.
2768    #[serde(skip_serializing_if = "Option::is_none")]
2769    pub tool_call_id: Option<String>,
2770    /// Cumulative private response bytes observed for this model call. The event never includes response text.
2771    #[serde(skip_serializing_if = "Option::is_none")]
2772    pub total_response_size_bytes: Option<i64>,
2773}
2774
2775/// Internal durable terminal request staged by a HydraFusion phase until an idempotent final commit selects it.
2776///
2777/// <div class="warning">
2778///
2779/// **Experimental.** This type is part of an experimental wire-protocol surface
2780/// and may change or be removed in future SDK or CLI releases.
2781///
2782/// </div>
2783#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2784#[serde(rename_all = "camelCase")]
2785pub(crate) struct FusionStagedTerminal {
2786    pub arguments: String,
2787    pub assistant_message: serde_json::Value,
2788    pub phase_id: String,
2789    pub tool_call_id: String,
2790    pub tool_name: String,
2791}
2792
2793/// Aggregate concrete-model usage for one HydraFusion phase.
2794///
2795/// <div class="warning">
2796///
2797/// **Experimental.** This type is part of an experimental wire-protocol surface
2798/// and may change or be removed in future SDK or CLI releases.
2799///
2800/// </div>
2801#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2802#[serde(rename_all = "camelCase")]
2803pub struct FusionPhaseUsage {
2804    /// Total cached input tokens reported for the phase.
2805    pub cached_tokens: i64,
2806    /// Total tokens written to prompt cache during the phase.
2807    #[serde(skip_serializing_if = "Option::is_none")]
2808    pub cache_write_tokens: Option<i64>,
2809    /// Total input tokens consumed by the phase.
2810    pub input_tokens: i64,
2811    /// Total output tokens produced by the phase.
2812    pub output_tokens: i64,
2813    /// Number of concrete model requests made by the phase.
2814    pub request_count: i64,
2815    /// Total normalized AI-unit cost reported for the phase, in nano-AIU.
2816    pub total_nano_aiu: f64,
2817}
2818
2819/// Session event "assistant.fusion_phase_completed". Experimental durable HydraFusion phase output and lossless replay checkpoint.
2820///
2821/// <div class="warning">
2822///
2823/// **Experimental.** This type is part of an experimental wire-protocol surface
2824/// and may change or be removed in future SDK or CLI releases.
2825///
2826/// </div>
2827#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2828#[serde(rename_all = "camelCase")]
2829pub struct AssistantFusionPhaseCompletedData {
2830    /// Provider-normalized textual output produced by the phase.
2831    pub content: String,
2832    /// Conversation scope in which the phase executed.
2833    pub conversation_scope: FusionConversationScope,
2834    /// Elapsed execution time for the phase in milliseconds.
2835    pub duration_ms: f64,
2836    /// Identifier of the HydraFusion turn containing the phase.
2837    pub fusion_id: String,
2838    /// Concrete model that executed the phase.
2839    pub model: String,
2840    /// Stable identifier for the completed phase.
2841    pub phase_id: String,
2842    /// Kind of phase that completed.
2843    pub phase_kind: FusionPhaseKind,
2844    /// Exact provider-normalized message used to reconstruct canonical model history.
2845    #[doc(hidden)]
2846    #[serde(skip_serializing_if = "Option::is_none")]
2847    pub(crate) projection_message: Option<serde_json::Value>,
2848    /// Projection action for the exact internal message.
2849    #[doc(hidden)]
2850    #[serde(skip_serializing_if = "Option::is_none")]
2851    pub(crate) projection_mode: Option<FusionProjectionMode>,
2852    /// Semantic role assigned to the completed phase.
2853    pub role: String,
2854    /// Terminal request held outside canonical state until selected by the final commit.
2855    #[doc(hidden)]
2856    #[serde(skip_serializing_if = "Option::is_none")]
2857    pub(crate) staged_terminal: Option<FusionStagedTerminal>,
2858    /// Durable outcome status of the phase.
2859    pub status: FusionPhaseStatus,
2860    /// Aggregate concrete-model usage consumed by the phase.
2861    pub usage: FusionPhaseUsage,
2862    /// Structured judge or critic verdict, when the phase produces one.
2863    pub verdict: Option<String>,
2864}
2865
2866/// Session event "assistant.fusion_phase_failed". Experimental durable typed HydraFusion phase failure and degradation transition.
2867///
2868/// <div class="warning">
2869///
2870/// **Experimental.** This type is part of an experimental wire-protocol surface
2871/// and may change or be removed in future SDK or CLI releases.
2872///
2873/// </div>
2874#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2875#[serde(rename_all = "camelCase")]
2876pub struct AssistantFusionPhaseFailedData {
2877    /// Conversation scope in which the phase executed.
2878    pub conversation_scope: FusionConversationScope,
2879    /// Identifier of the fallback phase used to continue the turn after degradation.
2880    #[serde(skip_serializing_if = "Option::is_none")]
2881    pub degraded_to_phase_id: Option<String>,
2882    /// Elapsed execution time before the phase failed, in milliseconds.
2883    pub duration_ms: f64,
2884    /// Provider or execution error detail, when available.
2885    #[serde(skip_serializing_if = "Option::is_none")]
2886    pub error_message: Option<String>,
2887    /// Identifier of the HydraFusion turn containing the phase.
2888    pub fusion_id: String,
2889    /// Concrete model that attempted the phase.
2890    pub model: String,
2891    /// Stable identifier for the failed phase.
2892    pub phase_id: String,
2893    /// Kind of phase that failed.
2894    pub phase_kind: FusionPhaseKind,
2895    /// Stable machine-readable reason for the phase failure.
2896    pub reason: String,
2897    /// Semantic role assigned to the failed phase.
2898    pub role: String,
2899    /// Durable outcome status of the phase.
2900    pub status: FusionPhaseStatus,
2901    /// Aggregate concrete-model usage consumed before the failure.
2902    pub usage: FusionPhaseUsage,
2903}
2904
2905/// 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
2906#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2907#[serde(rename_all = "camelCase")]
2908pub struct AssistantServerToolProgressData {
2909    /// Kind of hosted server tool that is running. Only `web_search` is emitted today.
2910    pub kind: String,
2911    /// 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.
2912    pub output_index: i64,
2913    /// Lifecycle status of the hosted call: `in_progress`, `searching`, or `completed`.
2914    pub status: String,
2915}
2916
2917/// Session event "assistant.reasoning". Assistant reasoning content for timeline display with complete thinking text
2918#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2919#[serde(rename_all = "camelCase")]
2920pub struct AssistantReasoningData {
2921    /// The complete extended thinking text from the model
2922    pub content: String,
2923    /// Unique identifier for this reasoning block
2924    pub reasoning_id: String,
2925    /// 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.
2926    #[serde(skip_serializing_if = "Option::is_none")]
2927    pub rte: Option<bool>,
2928}
2929
2930/// Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
2931#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2932#[serde(rename_all = "camelCase")]
2933pub struct AssistantReasoningDeltaData {
2934    /// Incremental text chunk to append to the reasoning content
2935    pub delta_content: String,
2936    /// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event
2937    pub reasoning_id: String,
2938}
2939
2940/// Session event "assistant.tool_call_delta". Streaming tool-call input delta for incremental tool-call updates
2941#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2942#[serde(rename_all = "camelCase")]
2943pub struct AssistantToolCallDeltaData {
2944    /// 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.
2945    pub input_delta: String,
2946    /// Tool call ID this delta belongs to, matching the corresponding assistant.message tool request
2947    pub tool_call_id: String,
2948    /// Name of the tool being invoked, when known from the stream
2949    #[serde(skip_serializing_if = "Option::is_none")]
2950    pub tool_name: Option<String>,
2951    /// Tool call type, when known from the stream
2952    #[serde(skip_serializing_if = "Option::is_none")]
2953    pub tool_type: Option<AssistantMessageToolRequestType>,
2954}
2955
2956/// Session event "assistant.streaming_delta". Streaming response progress with cumulative byte count
2957#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2958#[serde(rename_all = "camelCase")]
2959pub struct AssistantStreamingDeltaData {
2960    /// Cumulative total bytes received from the streaming response so far
2961    pub total_response_size_bytes: i64,
2962}
2963
2964/// A source that backs one or more cited spans in the assistant's response.
2965///
2966/// <div class="warning">
2967///
2968/// **Experimental.** This type is part of an experimental wire-protocol surface
2969/// and may change or be removed in future SDK or CLI releases.
2970///
2971/// </div>
2972#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2973#[serde(rename_all = "camelCase")]
2974pub struct CitationSource {
2975    /// Stable, turn-scoped identifier for this source, referenced by CitationReference.sourceId.
2976    pub id: String,
2977    /// File path relative to the agent's workspace root, when the source is a file.
2978    #[serde(skip_serializing_if = "Option::is_none")]
2979    pub path: Option<String>,
2980    /// The system that produced this citation.
2981    pub provider: CitationProvider,
2982    /// Human-readable title of the source.
2983    #[serde(skip_serializing_if = "Option::is_none")]
2984    pub title: Option<String>,
2985    /// URL of the source, when it is a web resource.
2986    #[serde(skip_serializing_if = "Option::is_none")]
2987    pub url: Option<String>,
2988}
2989
2990/// A single citation occurrence linking a span of generated text to a supporting source.
2991///
2992/// <div class="warning">
2993///
2994/// **Experimental.** This type is part of an experimental wire-protocol surface
2995/// and may change or be removed in future SDK or CLI releases.
2996///
2997/// </div>
2998#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2999#[serde(rename_all = "camelCase")]
3000pub struct CitationReference {
3001    /// The exact text from the source that supports the cited span, when provided by the model.
3002    #[serde(skip_serializing_if = "Option::is_none")]
3003    pub cited_text: Option<String>,
3004    /// Location within the source that supports the cited span, when the provider reports one.
3005    #[serde(skip_serializing_if = "Option::is_none")]
3006    pub location: Option<serde_json::Value>,
3007    /// Provider-native citation correlation data (e.g. Anthropic search_result_index / document_index), passed through opaquely for debugging and forward compatibility.
3008    #[serde(skip_serializing_if = "Option::is_none")]
3009    pub provider_metadata: Option<serde_json::Value>,
3010    /// Identifier of the CitationSource this reference points to (CitationSource.id).
3011    pub source_id: String,
3012}
3013
3014/// A contiguous span of generated assistant text and the source references that support it.
3015///
3016/// <div class="warning">
3017///
3018/// **Experimental.** This type is part of an experimental wire-protocol surface
3019/// and may change or be removed in future SDK or CLI releases.
3020///
3021/// </div>
3022#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3023#[serde(rename_all = "camelCase")]
3024pub struct CitationSpan {
3025    /// End offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, exclusive).
3026    pub end_index: i64,
3027    /// The sources that support this span of generated text.
3028    pub references: Vec<CitationReference>,
3029    /// Start offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, inclusive).
3030    pub start_index: i64,
3031}
3032
3033/// Provider-agnostic citations linking spans of the assistant's response to their supporting sources.
3034///
3035/// <div class="warning">
3036///
3037/// **Experimental.** This type is part of an experimental wire-protocol surface
3038/// and may change or be removed in future SDK or CLI releases.
3039///
3040/// </div>
3041#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3042#[serde(rename_all = "camelCase")]
3043pub struct Citations {
3044    /// Deduplicated set of sources referenced by the citation spans.
3045    pub sources: Vec<CitationSource>,
3046    /// Spans of generated text annotated with the sources that support them.
3047    pub spans: Vec<CitationSpan>,
3048}
3049
3050/// Experimental attribution linking an ordinary event to the HydraFusion turn, phase, and concrete source that produced it.
3051///
3052/// <div class="warning">
3053///
3054/// **Experimental.** This type is part of an experimental wire-protocol surface
3055/// and may change or be removed in future SDK or CLI releases.
3056///
3057/// </div>
3058#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3059#[serde(rename_all = "camelCase")]
3060pub struct FusionAttribution {
3061    /// Idempotency identifier for the authoritative commit, when the event belongs to the selected output.
3062    #[serde(skip_serializing_if = "Option::is_none")]
3063    pub commit_id: Option<String>,
3064    /// Conversation scope in which the concrete phase executed.
3065    #[serde(skip_serializing_if = "Option::is_none")]
3066    pub conversation_scope: Option<String>,
3067    /// Stable identifier for the HydraFusion turn that produced the event.
3068    pub fusion_id: String,
3069    /// HydraFusion orchestration pattern selected for the turn.
3070    pub pattern: String,
3071    /// Identifier of the concrete phase that produced the event.
3072    #[serde(skip_serializing_if = "Option::is_none")]
3073    pub phase_id: Option<String>,
3074    /// Kind of concrete phase that produced the event.
3075    #[serde(skip_serializing_if = "Option::is_none")]
3076    pub phase_kind: Option<String>,
3077    /// HydraFusion routing policy used for the turn.
3078    pub policy: String,
3079    /// Semantic role assigned to the concrete phase.
3080    #[serde(skip_serializing_if = "Option::is_none")]
3081    pub role: Option<String>,
3082    /// Concrete model that produced the attributed event.
3083    #[serde(skip_serializing_if = "Option::is_none")]
3084    pub source_model: Option<String>,
3085    /// Phase whose output supplied the authoritative content, when different from the executing phase.
3086    #[serde(skip_serializing_if = "Option::is_none")]
3087    pub source_phase_id: Option<String>,
3088    /// Synthetic HydraFusion model selected for the session.
3089    pub synthetic_model: String,
3090}
3091
3092/// Neutral provider-tagged reasoning content blocks preserved verbatim for round-tripping
3093///
3094/// <div class="warning">
3095///
3096/// **Experimental.** This type is part of an experimental wire-protocol surface
3097/// and may change or be removed in future SDK or CLI releases.
3098///
3099/// </div>
3100#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3101#[serde(rename_all = "camelCase")]
3102pub struct AssistantMessageReasoningBlocks {
3103    /// 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.
3104    #[serde(skip_serializing_if = "Option::is_none")]
3105    pub blocks: Option<Vec<serde_json::Value>>,
3106    /// Model provider that produced these reasoning blocks.
3107    pub provider: String,
3108}
3109
3110/// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
3111///
3112/// <div class="warning">
3113///
3114/// **Experimental.** This type is part of an experimental wire-protocol surface
3115/// and may change or be removed in future SDK or CLI releases.
3116///
3117/// </div>
3118#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3119#[serde(rename_all = "camelCase")]
3120pub struct AssistantMessageServerTools {
3121    /// Advisor model identifier associated with the server-tool payload.
3122    #[serde(skip_serializing_if = "Option::is_none")]
3123    pub advisor_model: Option<String>,
3124    /// Provider function-call namespaces keyed by function-call identifier.
3125    #[serde(skip_serializing_if = "Option::is_none")]
3126    pub function_call_namespaces: Option<HashMap<String, String>>,
3127    /// Provider-native server-tool call and output items preserved verbatim for replay.
3128    #[serde(skip_serializing_if = "Option::is_none")]
3129    pub items: Option<Vec<serde_json::Value>>,
3130    /// Model provider that produced this server-tool payload.
3131    pub provider: String,
3132    /// Raw provider content blocks retained for verbatim round-tripping.
3133    #[serde(skip_serializing_if = "Option::is_none")]
3134    pub raw_content_blocks: Option<Vec<serde_json::Value>>,
3135}
3136
3137/// Hosted program that requested this client tool call
3138#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3139#[serde(rename_all = "camelCase")]
3140pub struct AssistantMessageToolRequestCaller {
3141    /// Provider-assigned identifier for the hosted caller.
3142    pub caller_id: String,
3143    /// Kind of hosted caller that requested the client tool call.
3144    pub r#type: AssistantMessageToolRequestCallerType,
3145}
3146
3147/// A tool invocation request from the assistant
3148#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3149#[serde(rename_all = "camelCase")]
3150pub struct AssistantMessageToolRequest {
3151    /// Arguments to pass to the tool, format depends on the tool
3152    #[serde(skip_serializing_if = "Option::is_none")]
3153    pub arguments: Option<serde_json::Value>,
3154    /// Hosted program that requested this client tool call
3155    #[serde(skip_serializing_if = "Option::is_none")]
3156    pub caller: Option<AssistantMessageToolRequestCaller>,
3157    /// Resolved intention summary describing what this specific call does
3158    #[serde(skip_serializing_if = "Option::is_none")]
3159    pub intention_summary: Option<String>,
3160    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
3161    #[serde(skip_serializing_if = "Option::is_none")]
3162    pub mcp_server_name: Option<String>,
3163    /// Original tool name on the MCP server, when the tool is an MCP tool
3164    #[serde(skip_serializing_if = "Option::is_none")]
3165    pub mcp_tool_name: Option<String>,
3166    /// Name of the tool being invoked
3167    pub name: String,
3168    /// Unique identifier for this tool call
3169    pub tool_call_id: String,
3170    /// Human-readable display title for the tool
3171    #[serde(skip_serializing_if = "Option::is_none")]
3172    pub tool_title: Option<String>,
3173    /// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
3174    #[serde(skip_serializing_if = "Option::is_none")]
3175    pub r#type: Option<AssistantMessageToolRequestType>,
3176}
3177
3178/// Session event "assistant.message". Assistant response containing text content, optional tool requests, and interaction metadata
3179#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3180#[serde(rename_all = "camelCase")]
3181pub struct AssistantMessageData {
3182    /// Provider's completion / response identifier; shared across all chunks of a single API call. Used to group multi-chunk assistant utterances.
3183    #[serde(skip_serializing_if = "Option::is_none")]
3184    pub api_call_id: Option<String>,
3185    /// 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.
3186    #[serde(skip_serializing_if = "Option::is_none")]
3187    pub chunk_count: Option<i64>,
3188    /// Zero-based position of this message within its model call's response. Absent when the response was not split into chunks.
3189    #[serde(skip_serializing_if = "Option::is_none")]
3190    pub chunk_index: Option<i64>,
3191    /// Provider-agnostic citations linking spans of this message's content to the sources that support them. Experimental; only populated when citation emission is enabled.
3192    ///
3193    /// <div class="warning">
3194    ///
3195    /// **Experimental.** This type is part of an experimental wire-protocol surface
3196    /// and may change or be removed in future SDK or CLI releases.
3197    ///
3198    /// </div>
3199    #[serde(skip_serializing_if = "Option::is_none")]
3200    pub citations: Option<Citations>,
3201    /// 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).
3202    #[serde(skip_serializing_if = "Option::is_none")]
3203    pub client_request_id: Option<String>,
3204    /// The assistant's text response content
3205    pub content: String,
3206    /// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
3207    #[serde(skip_serializing_if = "Option::is_none")]
3208    pub encrypted_content: Option<String>,
3209    /// Experimental HydraFusion source attribution for this ordinary authoritative assistant message.
3210    ///
3211    /// <div class="warning">
3212    ///
3213    /// **Experimental.** This type is part of an experimental wire-protocol surface
3214    /// and may change or be removed in future SDK or CLI releases.
3215    ///
3216    /// </div>
3217    #[serde(skip_serializing_if = "Option::is_none")]
3218    pub fusion: Option<FusionAttribution>,
3219    /// CAPI interaction ID for correlating this message with upstream telemetry
3220    #[serde(skip_serializing_if = "Option::is_none")]
3221    pub interaction_id: Option<String>,
3222    /// Unique identifier for this assistant message
3223    pub message_id: String,
3224    /// Model that produced this assistant message, if known
3225    #[serde(skip_serializing_if = "Option::is_none")]
3226    pub model: Option<String>,
3227    /// Logical ID of the primary user message that initiated this run, matching the messageId returned by session.send (or the last messageId of session.sendMessages). Stable across model/tool iterations, steering messages, and stop-hook corrections. Subagent runs use their own initiating message ID, not the parent's. Absent for runs without an associated initiating message, such as empty batches.
3228    #[serde(skip_serializing_if = "Option::is_none")]
3229    pub originating_message_id: Option<String>,
3230    /// Actual output token count from the API response (completion_tokens), used for accurate token accounting
3231    #[serde(skip_serializing_if = "Option::is_none")]
3232    pub output_tokens: Option<i64>,
3233    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3234    #[doc(hidden)]
3235    #[deprecated]
3236    #[serde(skip_serializing_if = "Option::is_none")]
3237    pub parent_tool_call_id: Option<String>,
3238    /// Generation phase for phased-output models (e.g., thinking vs. response phases)
3239    #[serde(skip_serializing_if = "Option::is_none")]
3240    pub phase: Option<String>,
3241    /// 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.
3242    #[serde(skip_serializing_if = "Option::is_none")]
3243    pub reasoning_blocks: Option<AssistantMessageReasoningBlocks>,
3244    /// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
3245    #[serde(skip_serializing_if = "Option::is_none")]
3246    pub reasoning_opaque: Option<String>,
3247    /// Readable reasoning text from the model's extended thinking
3248    #[serde(skip_serializing_if = "Option::is_none")]
3249    pub reasoning_text: Option<String>,
3250    /// 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.
3251    #[serde(skip_serializing_if = "Option::is_none")]
3252    pub reasoning_wire_field: Option<String>,
3253    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
3254    #[serde(skip_serializing_if = "Option::is_none")]
3255    pub request_id: Option<RequestId>,
3256    /// 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.
3257    #[serde(skip_serializing_if = "Option::is_none")]
3258    pub rte: Option<bool>,
3259    /// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
3260    #[serde(skip_serializing_if = "Option::is_none")]
3261    pub server_tools: Option<AssistantMessageServerTools>,
3262    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3263    #[serde(skip_serializing_if = "Option::is_none")]
3264    pub service_request_id: Option<String>,
3265    /// Tool invocations requested by the assistant in this message
3266    #[serde(skip_serializing_if = "Option::is_none")]
3267    pub tool_requests: Option<Vec<AssistantMessageToolRequest>>,
3268    /// Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
3269    #[serde(skip_serializing_if = "Option::is_none")]
3270    pub turn_id: Option<String>,
3271}
3272
3273/// Session event "assistant.message_start". Streaming assistant message start metadata
3274#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3275#[serde(rename_all = "camelCase")]
3276pub struct AssistantMessageStartData {
3277    /// Message ID this start event belongs to, matching subsequent deltas and assistant.message
3278    pub message_id: String,
3279    /// Generation phase this message belongs to for phased-output models
3280    #[serde(skip_serializing_if = "Option::is_none")]
3281    pub phase: Option<String>,
3282}
3283
3284/// Session event "assistant.message_delta". Streaming assistant message delta for incremental response updates
3285#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3286#[serde(rename_all = "camelCase")]
3287pub struct AssistantMessageDeltaData {
3288    /// Incremental text chunk to append to the message content
3289    pub delta_content: String,
3290    /// Message ID this delta belongs to, matching the corresponding assistant.message event
3291    pub message_id: String,
3292    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3293    #[doc(hidden)]
3294    #[deprecated]
3295    #[serde(skip_serializing_if = "Option::is_none")]
3296    pub parent_tool_call_id: Option<String>,
3297}
3298
3299/// Session event "assistant.turn_end". Turn completion metadata including the turn identifier
3300#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3301#[serde(rename_all = "camelCase")]
3302pub struct AssistantTurnEndData {
3303    /// Model identifier used for this turn, when known
3304    #[serde(skip_serializing_if = "Option::is_none")]
3305    pub model: Option<String>,
3306    /// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event
3307    pub turn_id: String,
3308}
3309
3310/// 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
3311#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3312#[serde(rename_all = "camelCase")]
3313pub struct AssistantIdleData {
3314    /// True when the preceding agentic loop was cancelled via abort signal
3315    #[serde(skip_serializing_if = "Option::is_none")]
3316    pub aborted: Option<bool>,
3317}
3318
3319/// Token usage detail for a single billing category
3320#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3321#[serde(rename_all = "camelCase")]
3322pub struct AssistantUsageCopilotUsageTokenDetail {
3323    /// Number of tokens in this billing batch
3324    pub batch_size: i64,
3325    /// Cost per batch of tokens
3326    pub cost_per_batch: i64,
3327    /// Model responsible for this billing entry
3328    #[serde(skip_serializing_if = "Option::is_none")]
3329    pub model: Option<String>,
3330    /// Total token count for this entry
3331    pub token_count: i64,
3332    /// Token category (e.g., "input", "output")
3333    pub token_type: String,
3334}
3335
3336/// Per-request cost and usage data from the CAPI copilot_usage response field
3337#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3338#[serde(rename_all = "camelCase")]
3339pub struct AssistantUsageCopilotUsage {
3340    /// Default billing model for token details that do not identify their own model
3341    #[serde(skip_serializing_if = "Option::is_none")]
3342    pub model: Option<String>,
3343    /// Itemized token usage breakdown
3344    #[doc(hidden)]
3345    #[serde(skip_serializing_if = "Option::is_none")]
3346    pub(crate) token_details: Option<Vec<AssistantUsageCopilotUsageTokenDetail>>,
3347    /// Total cost in nano-AI units for this request
3348    pub total_nano_aiu: f64,
3349}
3350
3351/// Internal per-quota snapshot for assistant usage, including entitlement, consumed requests, overage, reset date, and remaining quota.
3352#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3353#[serde(rename_all = "camelCase")]
3354pub(crate) struct AssistantUsageQuotaSnapshot {
3355    /// Total requests allowed by the entitlement
3356    #[doc(hidden)]
3357    pub(crate) entitlement_requests: i64,
3358    /// Whether the user currently has quota available for use
3359    #[doc(hidden)]
3360    #[serde(skip_serializing_if = "Option::is_none")]
3361    pub(crate) has_quota: Option<bool>,
3362    /// Whether the user has an unlimited usage entitlement
3363    #[doc(hidden)]
3364    pub(crate) is_unlimited_entitlement: bool,
3365    /// Number of additional usage requests made this period
3366    #[doc(hidden)]
3367    pub(crate) overage: f64,
3368    /// Whether additional usage is allowed when quota is exhausted
3369    #[doc(hidden)]
3370    pub(crate) overage_allowed_with_exhausted_quota: bool,
3371    /// Pay-as-you-go additional-usage budget cap in AI credits (1 credit = $0.01); present only when CAPI emits a finite value
3372    #[doc(hidden)]
3373    #[serde(skip_serializing_if = "Option::is_none")]
3374    pub(crate) overage_entitlement: Option<f64>,
3375    /// Percentage of quota remaining (0 to 100)
3376    #[doc(hidden)]
3377    pub(crate) remaining_percentage: f64,
3378    /// Date when the quota resets
3379    #[doc(hidden)]
3380    #[serde(skip_serializing_if = "Option::is_none")]
3381    pub(crate) reset_date: Option<String>,
3382    /// Whether this snapshot uses token-based billing (AI-credits allocation)
3383    #[doc(hidden)]
3384    #[serde(skip_serializing_if = "Option::is_none")]
3385    pub(crate) token_based_billing: Option<bool>,
3386    /// Whether usage is still permitted after quota exhaustion
3387    #[doc(hidden)]
3388    pub(crate) usage_allowed_with_exhausted_quota: bool,
3389    /// Number of requests already consumed
3390    #[doc(hidden)]
3391    pub(crate) used_requests: i64,
3392}
3393
3394/// Session event "assistant.usage". LLM API call usage metrics including tokens, costs, quotas, and billing information
3395#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3396#[serde(rename_all = "camelCase")]
3397pub struct AssistantUsageData {
3398    /// Number of accepted speculative prediction tokens
3399    #[serde(skip_serializing_if = "Option::is_none")]
3400    pub accepted_prediction_tokens: Option<i64>,
3401    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
3402    #[serde(skip_serializing_if = "Option::is_none")]
3403    pub api_call_id: Option<String>,
3404    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
3405    #[serde(skip_serializing_if = "Option::is_none")]
3406    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
3407    /// Number of tools available to the model for this call
3408    #[doc(hidden)]
3409    #[serde(skip_serializing_if = "Option::is_none")]
3410    pub(crate) available_tool_count: Option<i64>,
3411    /// Whether the provider reported prompt-cache usage details for this call
3412    #[doc(hidden)]
3413    #[serde(skip_serializing_if = "Option::is_none")]
3414    pub(crate) cache_details_reported: Option<bool>,
3415    /// Updated prompt-cache expiration for this model call. Present only when the call establishes or refreshes known cache state.
3416    #[serde(skip_serializing_if = "Option::is_none")]
3417    pub cache_expires_at: Option<String>,
3418    /// Number of tokens read from prompt cache
3419    #[serde(skip_serializing_if = "Option::is_none")]
3420    pub cache_read_tokens: Option<i64>,
3421    /// Effective prompt-cache lifetime in seconds for this call
3422    #[doc(hidden)]
3423    #[serde(skip_serializing_if = "Option::is_none")]
3424    pub(crate) cache_ttl_seconds: Option<i64>,
3425    /// Number of tokens written to prompt cache
3426    #[serde(skip_serializing_if = "Option::is_none")]
3427    pub cache_write_tokens: Option<i64>,
3428    /// 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.
3429    #[serde(skip_serializing_if = "Option::is_none")]
3430    pub content_filter_triggered: Option<bool>,
3431    /// Per-request cost and usage data from the CAPI copilot_usage response field
3432    #[serde(skip_serializing_if = "Option::is_none")]
3433    pub copilot_usage: Option<AssistantUsageCopilotUsage>,
3434    /// Model multiplier cost for billing purposes
3435    ///
3436    /// <div class="warning">
3437    ///
3438    /// **Experimental.** This type is part of an experimental wire-protocol surface
3439    /// and may change or be removed in future SDK or CLI releases.
3440    ///
3441    /// </div>
3442    #[serde(skip_serializing_if = "Option::is_none")]
3443    pub cost: Option<f64>,
3444    /// Duration of the API call in milliseconds
3445    #[serde(skip_serializing_if = "Option::is_none")]
3446    pub duration: Option<i64>,
3447    /// 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".
3448    #[serde(skip_serializing_if = "Option::is_none")]
3449    pub finish_reason: Option<String>,
3450    /// How the prompt-cache frontier was determined for this call
3451    #[doc(hidden)]
3452    #[serde(skip_serializing_if = "Option::is_none")]
3453    pub(crate) frontier_source: Option<String>,
3454    /// Experimental HydraFusion attribution for this concrete model call's usage.
3455    ///
3456    /// <div class="warning">
3457    ///
3458    /// **Experimental.** This type is part of an experimental wire-protocol surface
3459    /// and may change or be removed in future SDK or CLI releases.
3460    ///
3461    /// </div>
3462    #[serde(skip_serializing_if = "Option::is_none")]
3463    pub fusion: Option<FusionAttribution>,
3464    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
3465    #[serde(skip_serializing_if = "Option::is_none")]
3466    pub initiator: Option<String>,
3467    /// Number of input tokens consumed
3468    #[serde(skip_serializing_if = "Option::is_none")]
3469    pub input_tokens: Option<i64>,
3470    /// 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.
3471    #[serde(skip_serializing_if = "Option::is_none")]
3472    pub interaction_type: Option<String>,
3473    /// Average inter-token latency in milliseconds. Only available for streaming requests
3474    #[serde(skip_serializing_if = "Option::is_none")]
3475    pub inter_token_latency_ms: Option<f64>,
3476    /// Whether Auto mode was selected for this model call
3477    #[serde(skip_serializing_if = "Option::is_none")]
3478    pub is_auto: Option<bool>,
3479    /// Whether this model call used a bring-your-own-key provider
3480    #[serde(skip_serializing_if = "Option::is_none")]
3481    pub is_byok: Option<bool>,
3482    /// Requested maximum output tokens used for this model call
3483    #[serde(skip_serializing_if = "Option::is_none")]
3484    pub max_output_tokens: Option<i64>,
3485    /// Effective maximum prompt-token limit used for this model call
3486    #[serde(skip_serializing_if = "Option::is_none")]
3487    pub max_prompt_tokens: Option<i64>,
3488    /// Model identifier used for this API call
3489    pub model: String,
3490    /// Number of tool calls returned by the model
3491    #[doc(hidden)]
3492    #[serde(skip_serializing_if = "Option::is_none")]
3493    pub(crate) num_tool_calls: Option<i64>,
3494    /// Number of output tokens produced
3495    #[serde(skip_serializing_if = "Option::is_none")]
3496    pub output_tokens: Option<i64>,
3497    /// Time to first observable model output in milliseconds. Includes text, reasoning, and tool-call output; only available for streaming requests that produce observable output.
3498    #[serde(skip_serializing_if = "Option::is_none")]
3499    pub output_ttft_ms: Option<f64>,
3500    /// Parent tool call ID when this usage originates from a sub-agent
3501    #[doc(hidden)]
3502    #[deprecated]
3503    #[serde(skip_serializing_if = "Option::is_none")]
3504    pub parent_tool_call_id: Option<String>,
3505    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
3506    #[serde(skip_serializing_if = "Option::is_none")]
3507    pub provider_call_id: Option<String>,
3508    /// Per-quota resource usage snapshots, keyed by quota identifier
3509    #[doc(hidden)]
3510    #[serde(skip_serializing_if = "Option::is_none")]
3511    pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
3512    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
3513    #[serde(skip_serializing_if = "Option::is_none")]
3514    pub reasoning_effort: Option<String>,
3515    /// Reasoning summary mode used for this model call, if applicable
3516    #[serde(skip_serializing_if = "Option::is_none")]
3517    pub reasoning_summary: Option<ReasoningSummary>,
3518    /// Number of output tokens used for reasoning (e.g., chain-of-thought)
3519    #[serde(skip_serializing_if = "Option::is_none")]
3520    pub reasoning_tokens: Option<i64>,
3521    /// Number of rejected speculative prediction tokens
3522    #[serde(skip_serializing_if = "Option::is_none")]
3523    pub rejected_prediction_tokens: Option<i64>,
3524    /// 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.
3525    #[serde(skip_serializing_if = "Option::is_none")]
3526    pub rte: Option<bool>,
3527    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3528    #[serde(skip_serializing_if = "Option::is_none")]
3529    pub service_request_id: Option<String>,
3530    /// Number of prior thinking blocks the provider dropped while transforming the request
3531    #[doc(hidden)]
3532    #[serde(skip_serializing_if = "Option::is_none")]
3533    pub(crate) thinking_dropped_blocks: Option<i64>,
3534    /// Recognized provider-reported reasons for dropped thinking blocks, in response order
3535    #[doc(hidden)]
3536    #[serde(skip_serializing_if = "Option::is_none")]
3537    pub(crate) thinking_dropped_reasons: Option<Vec<String>>,
3538    /// Time to first token in milliseconds. Only available for streaming requests
3539    #[serde(skip_serializing_if = "Option::is_none")]
3540    pub time_to_first_token_ms: Option<f64>,
3541    /// Tool-call counts keyed by tool name
3542    #[doc(hidden)]
3543    #[serde(skip_serializing_if = "Option::is_none")]
3544    pub(crate) tool_counts: Option<HashMap<String, i64>>,
3545    /// Number of tokens used by tool definitions for this call
3546    #[doc(hidden)]
3547    #[serde(skip_serializing_if = "Option::is_none")]
3548    pub(crate) tool_token_count: Option<i64>,
3549    /// Transport used for this model call (http or websocket)
3550    #[serde(skip_serializing_if = "Option::is_none")]
3551    pub transport: Option<AssistantUsageTransport>,
3552}
3553
3554/// Session event "prompt_cache_break". A detected loss of a previously cached prompt prefix
3555#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3556#[serde(rename_all = "camelCase")]
3557pub struct PromptCacheBreakData {
3558    /// Request state whose cached prefix fell short
3559    #[doc(hidden)]
3560    #[serde(skip_serializing_if = "Option::is_none")]
3561    pub(crate) after_request: Option<serde_json::Value>,
3562    /// Name of the sub-agent whose conversation broke, stamped by the parent bridge
3563    #[doc(hidden)]
3564    #[serde(skip_serializing_if = "Option::is_none")]
3565    pub(crate) agent_name: Option<String>,
3566    /// Request state that established the prior cache frontier
3567    #[doc(hidden)]
3568    #[serde(skip_serializing_if = "Option::is_none")]
3569    pub(crate) before_request: Option<serde_json::Value>,
3570    /// Names of the cache-configuration fields that changed
3571    #[doc(hidden)]
3572    #[serde(skip_serializing_if = "Option::is_none")]
3573    pub(crate) cache_config_changed_fields: Option<Vec<String>>,
3574    /// All reasons that contributed to the cache break, ordered by precedence
3575    pub contributing_reasons: Vec<String>,
3576    /// Prior cached prompt frontier in tokens
3577    pub frontier_tokens: i64,
3578    /// Model that held the prior cache frontier, when the call changed models
3579    #[doc(hidden)]
3580    #[serde(skip_serializing_if = "Option::is_none")]
3581    pub(crate) model_from: Option<String>,
3582    /// Model this call targeted, when the call changed models
3583    #[doc(hidden)]
3584    #[serde(skip_serializing_if = "Option::is_none")]
3585    pub(crate) model_to: Option<String>,
3586    /// The highest-precedence reason for the cache break
3587    pub primary_reason: String,
3588    /// Fraction of the prior cache frontier that survived
3589    pub retention_ratio: f64,
3590    /// Index of the first conversation message whose content changed
3591    #[doc(hidden)]
3592    #[serde(skip_serializing_if = "Option::is_none")]
3593    pub(crate) rewrite_message_index: Option<i64>,
3594    /// Shape of the history rewrite, for example whether the history grew or shrank
3595    #[doc(hidden)]
3596    #[serde(skip_serializing_if = "Option::is_none")]
3597    pub(crate) rewrite_shape: Option<String>,
3598    /// Subsystems that announced a history rewrite before this call, for example compaction or truncation
3599    #[doc(hidden)]
3600    #[serde(skip_serializing_if = "Option::is_none")]
3601    pub(crate) rewrite_source: Option<Vec<String>>,
3602    /// Cached prefix tokens lost since the prior call
3603    pub shortfall_tokens: i64,
3604    /// Number of cached prefix tokens that survived
3605    pub survived_tokens: i64,
3606    /// Names of the system-prompt segments whose content changed
3607    #[doc(hidden)]
3608    #[serde(skip_serializing_if = "Option::is_none")]
3609    pub(crate) system_segments_changed: Option<Vec<String>>,
3610    /// Telemetry-safe names of tools added since the prior call
3611    #[doc(hidden)]
3612    #[serde(skip_serializing_if = "Option::is_none")]
3613    pub(crate) tools_added: Option<Vec<String>>,
3614    /// Raw names of tools added since the prior call, restricted because a tool name can be user-authored
3615    #[doc(hidden)]
3616    #[serde(skip_serializing_if = "Option::is_none")]
3617    pub(crate) tools_added_raw: Option<Vec<String>>,
3618    /// Telemetry-safe names of tools whose definition changed since the prior call
3619    #[doc(hidden)]
3620    #[serde(skip_serializing_if = "Option::is_none")]
3621    pub(crate) tools_redefined: Option<Vec<String>>,
3622    /// Raw names of tools redefined since the prior call, restricted because a tool name can be user-authored
3623    #[doc(hidden)]
3624    #[serde(skip_serializing_if = "Option::is_none")]
3625    pub(crate) tools_redefined_raw: Option<Vec<String>>,
3626    /// Telemetry-safe names of tools removed since the prior call
3627    #[doc(hidden)]
3628    #[serde(skip_serializing_if = "Option::is_none")]
3629    pub(crate) tools_removed: Option<Vec<String>>,
3630    /// Raw names of tools removed since the prior call, restricted because a tool name can be user-authored
3631    #[doc(hidden)]
3632    #[serde(skip_serializing_if = "Option::is_none")]
3633    pub(crate) tools_removed_raw: Option<Vec<String>>,
3634    /// Whether the tool list kept its members but changed their order
3635    #[doc(hidden)]
3636    #[serde(skip_serializing_if = "Option::is_none")]
3637    pub(crate) tools_reordered: Option<bool>,
3638}
3639
3640/// Content-free structural summary of the failing request for diagnosing malformed 4xx calls
3641#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3642#[serde(rename_all = "camelCase")]
3643pub struct ModelCallFailureRequestFingerprint {
3644    /// Total number of image content parts
3645    pub image_part_count: i64,
3646    /// Image parts whose media type cannot be determined (rejected by strict providers)
3647    pub image_parts_missing_media_type: i64,
3648    /// Role of the final message in the request
3649    #[serde(skip_serializing_if = "Option::is_none")]
3650    pub last_message_role: Option<String>,
3651    /// Total number of messages in the request
3652    pub message_count: i64,
3653    /// Tool calls whose name is missing or empty (rejected by strict providers)
3654    pub nameless_tool_call_count: i64,
3655    /// Total number of tool calls across assistant messages
3656    pub tool_call_count: i64,
3657    /// Number of "tool" result messages in the request
3658    pub tool_result_message_count: i64,
3659}
3660
3661/// Session event "model.call_failure". Failed LLM API call metadata for telemetry
3662#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3663#[serde(rename_all = "camelCase")]
3664pub struct ModelCallFailureData {
3665    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
3666    #[serde(skip_serializing_if = "Option::is_none")]
3667    pub api_call_id: Option<String>,
3668    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
3669    #[serde(skip_serializing_if = "Option::is_none")]
3670    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
3671    /// 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.
3672    #[serde(skip_serializing_if = "Option::is_none")]
3673    pub bad_request_kind: Option<ModelCallFailureBadRequestKind>,
3674    /// Duration of the failed API call in milliseconds
3675    #[serde(skip_serializing_if = "Option::is_none")]
3676    pub duration_ms: Option<i64>,
3677    /// 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.
3678    #[serde(skip_serializing_if = "Option::is_none")]
3679    pub error_code: Option<String>,
3680    /// Raw provider/runtime error message for restricted telemetry
3681    #[serde(skip_serializing_if = "Option::is_none")]
3682    pub error_message: Option<String>,
3683    /// 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.
3684    #[serde(skip_serializing_if = "Option::is_none")]
3685    pub error_type: Option<String>,
3686    /// Whether the failure originated from an API response or the request transport
3687    #[serde(skip_serializing_if = "Option::is_none")]
3688    pub failure_kind: Option<ModelCallFailureKind>,
3689    /// Experimental HydraFusion attribution for this failed concrete model call.
3690    ///
3691    /// <div class="warning">
3692    ///
3693    /// **Experimental.** This type is part of an experimental wire-protocol surface
3694    /// and may change or be removed in future SDK or CLI releases.
3695    ///
3696    /// </div>
3697    #[serde(skip_serializing_if = "Option::is_none")]
3698    pub fusion: Option<FusionAttribution>,
3699    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
3700    #[serde(skip_serializing_if = "Option::is_none")]
3701    pub initiator: Option<String>,
3702    /// 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.
3703    #[serde(skip_serializing_if = "Option::is_none")]
3704    pub interaction_type: Option<String>,
3705    /// Whether the session selected Auto mode for the failed call
3706    #[serde(skip_serializing_if = "Option::is_none")]
3707    pub is_auto: Option<bool>,
3708    /// Whether the failed call used a bring-your-own-key provider
3709    #[serde(skip_serializing_if = "Option::is_none")]
3710    pub is_byok: Option<bool>,
3711    /// Effective maximum output-token limit for the failed call
3712    #[serde(skip_serializing_if = "Option::is_none")]
3713    pub max_output_tokens: Option<i64>,
3714    /// Effective maximum prompt-token limit for the failed call
3715    #[serde(skip_serializing_if = "Option::is_none")]
3716    pub max_prompt_tokens: Option<i64>,
3717    /// Model identifier used for the failed API call
3718    #[serde(skip_serializing_if = "Option::is_none")]
3719    pub model: Option<String>,
3720    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
3721    #[serde(skip_serializing_if = "Option::is_none")]
3722    pub provider_call_id: Option<String>,
3723    /// 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.
3724    #[doc(hidden)]
3725    #[serde(skip_serializing_if = "Option::is_none")]
3726    pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
3727    /// Reasoning effort level used for the failed model call, if applicable
3728    #[serde(skip_serializing_if = "Option::is_none")]
3729    pub reasoning_effort: Option<String>,
3730    /// 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.
3731    #[serde(skip_serializing_if = "Option::is_none")]
3732    pub request_fingerprint: Option<ModelCallFailureRequestFingerprint>,
3733    /// 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.
3734    #[serde(skip_serializing_if = "Option::is_none")]
3735    pub rte: Option<bool>,
3736    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3737    #[serde(skip_serializing_if = "Option::is_none")]
3738    pub service_request_id: Option<String>,
3739    /// Where the failed model call originated
3740    pub source: ModelCallFailureSource,
3741    /// HTTP status code from the failed request
3742    #[serde(skip_serializing_if = "Option::is_none")]
3743    pub status_code: Option<i32>,
3744    /// Transport used for the failed model call (http or websocket)
3745    #[serde(skip_serializing_if = "Option::is_none")]
3746    pub transport: Option<ModelCallFailureTransport>,
3747}
3748
3749/// 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.
3750#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3751#[serde(rename_all = "camelCase")]
3752pub struct ModelCallFinishedData {
3753    /// 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.
3754    #[serde(skip_serializing_if = "Option::is_none")]
3755    pub contains_built_in_file_edit_request: Option<bool>,
3756    /// 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
3757    pub dispatch_duration_ms: f64,
3758    /// Version of the built-in file-edit semantic classifier used for this event
3759    pub edit_classifier_version: i64,
3760    /// Identifier of the user interaction that owns the model dispatch, matching assistant.turn_start.interactionId when available
3761    #[serde(skip_serializing_if = "Option::is_none")]
3762    pub interaction_id: Option<String>,
3763    /// Final outcome after post-response acceptance processing
3764    pub outcome: ModelCallFinishedOutcome,
3765    /// Agent-loop iteration within the interaction that initiated the model dispatch
3766    pub turn_id: String,
3767}
3768
3769/// Session event "model.call_start". Model API dispatch metadata for internal telemetry
3770#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3771#[serde(rename_all = "camelCase")]
3772pub struct ModelCallStartData {
3773    /// Experimental HydraFusion attribution for this concrete model call.
3774    ///
3775    /// <div class="warning">
3776    ///
3777    /// **Experimental.** This type is part of an experimental wire-protocol surface
3778    /// and may change or be removed in future SDK or CLI releases.
3779    ///
3780    /// </div>
3781    #[serde(skip_serializing_if = "Option::is_none")]
3782    pub fusion: Option<FusionAttribution>,
3783    /// Model identifier used for this API call, when known
3784    #[serde(skip_serializing_if = "Option::is_none")]
3785    pub model: Option<String>,
3786    /// Previous response or interaction identifier included in the model request, when present
3787    #[doc(hidden)]
3788    #[serde(skip_serializing_if = "Option::is_none")]
3789    pub(crate) previous_response_id: Option<String>,
3790    /// Identifier of the assistant turn that initiated the model call
3791    pub turn_id: String,
3792}
3793
3794/// Session event "abort". Turn abort information including the reason for termination
3795#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3796#[serde(rename_all = "camelCase")]
3797pub struct AbortData {
3798    /// Finite reason code describing why the current turn was aborted
3799    pub reason: AbortReason,
3800}
3801
3802/// Session event "tool.user_requested". User-initiated tool invocation request with tool name and arguments
3803#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3804#[serde(rename_all = "camelCase")]
3805pub struct ToolUserRequestedData {
3806    /// Arguments for the tool invocation
3807    #[serde(skip_serializing_if = "Option::is_none")]
3808    pub arguments: Option<serde_json::Value>,
3809    /// Unique identifier for this tool call
3810    pub tool_call_id: String,
3811    /// Name of the tool the user wants to invoke
3812    pub tool_name: String,
3813}
3814
3815/// 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.
3816#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3817#[serde(rename_all = "camelCase")]
3818pub struct ToolExecutionStartShellToolInfo {
3819    /// 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.
3820    ///
3821    /// <div class="warning">
3822    ///
3823    /// **Experimental.** This type is part of an experimental wire-protocol surface
3824    /// and may change or be removed in future SDK or CLI releases.
3825    ///
3826    /// </div>
3827    #[serde(skip_serializing_if = "Option::is_none")]
3828    pub display_command: Option<String>,
3829    /// Whether the command includes a file write redirection (e.g., > or >>).
3830    pub has_write_file_redirection: bool,
3831    /// 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.
3832    pub possible_paths: Vec<String>,
3833}
3834
3835/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
3836#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3837#[serde(rename_all = "camelCase")]
3838pub struct ToolExecutionStartToolDescriptionMetaUI {
3839    /// URI of the UI resource
3840    #[serde(skip_serializing_if = "Option::is_none")]
3841    pub resource_uri: Option<String>,
3842    /// Who can access this tool
3843    #[serde(skip_serializing_if = "Option::is_none")]
3844    pub visibility: Option<Vec<ToolExecutionStartToolDescriptionMetaUIVisibility>>,
3845}
3846
3847/// MCP Apps metadata for UI resource association
3848#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3849#[serde(rename_all = "camelCase")]
3850pub struct ToolExecutionStartToolDescriptionMeta {
3851    /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
3852    #[serde(skip_serializing_if = "Option::is_none")]
3853    pub ui: Option<ToolExecutionStartToolDescriptionMetaUI>,
3854}
3855
3856/// Tool definition metadata, present for MCP tools with MCP Apps support
3857#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3858#[serde(rename_all = "camelCase")]
3859pub struct ToolExecutionStartToolDescription {
3860    /// MCP Apps metadata for UI resource association
3861    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
3862    pub meta: Option<ToolExecutionStartToolDescriptionMeta>,
3863    /// Tool description
3864    #[serde(skip_serializing_if = "Option::is_none")]
3865    pub description: Option<String>,
3866    /// Tool name
3867    pub name: String,
3868}
3869
3870/// Session event "tool.execution_start". Tool execution startup details including MCP server information when applicable
3871#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3872#[serde(rename_all = "camelCase")]
3873pub struct ToolExecutionStartData {
3874    /// Arguments passed to the tool
3875    #[serde(skip_serializing_if = "Option::is_none")]
3876    pub arguments: Option<serde_json::Value>,
3877    /// When true, the tool output should be displayed expanded (verbatim) in the CLI timeline
3878    #[serde(skip_serializing_if = "Option::is_none")]
3879    pub display_verbatim: Option<bool>,
3880    /// Experimental HydraFusion attribution for this tool execution.
3881    ///
3882    /// <div class="warning">
3883    ///
3884    /// **Experimental.** This type is part of an experimental wire-protocol surface
3885    /// and may change or be removed in future SDK or CLI releases.
3886    ///
3887    /// </div>
3888    #[serde(skip_serializing_if = "Option::is_none")]
3889    pub fusion: Option<FusionAttribution>,
3890    /// Preferred lookup name for the MCP server hosting this tool: the configured (namespaced) config-map key when the tool carries one, otherwise the display name from `mcpServerName`. Present when the tool is an MCP tool; this is the name unrestricted provenance telemetry hashes so it joins with `mcp_server_setup`, which keys off the configured name too.
3891    #[serde(skip_serializing_if = "Option::is_none")]
3892    pub mcp_config_server_name: Option<String>,
3893    /// Where the MCP server's configuration came from (`user`, `workspace`, `plugin`, or `builtin`), when the tool is an MCP tool and the server is configured
3894    #[serde(skip_serializing_if = "Option::is_none")]
3895    pub mcp_config_source: Option<McpServerSource>,
3896    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
3897    #[serde(skip_serializing_if = "Option::is_none")]
3898    pub mcp_server_name: Option<String>,
3899    /// Original tool name on the MCP server, when the tool is an MCP tool
3900    #[serde(skip_serializing_if = "Option::is_none")]
3901    pub mcp_tool_name: Option<String>,
3902    /// Transport the MCP server hosting this tool is connected over, when the tool is an MCP tool and the server is configured
3903    #[serde(skip_serializing_if = "Option::is_none")]
3904    pub mcp_transport: Option<McpServerTransport>,
3905    /// Model identifier that generated this tool call
3906    #[serde(skip_serializing_if = "Option::is_none")]
3907    pub model: Option<String>,
3908    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3909    #[doc(hidden)]
3910    #[deprecated]
3911    #[serde(skip_serializing_if = "Option::is_none")]
3912    pub parent_tool_call_id: Option<String>,
3913    /// 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.
3914    #[serde(skip_serializing_if = "Option::is_none")]
3915    pub rte: Option<bool>,
3916    /// 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.
3917    #[serde(skip_serializing_if = "Option::is_none")]
3918    pub shell_tool_info: Option<ToolExecutionStartShellToolInfo>,
3919    /// Unique identifier for this tool call
3920    pub tool_call_id: String,
3921    /// Tool definition metadata, present for MCP tools with MCP Apps support
3922    #[serde(skip_serializing_if = "Option::is_none")]
3923    pub tool_description: Option<ToolExecutionStartToolDescription>,
3924    /// Name of the tool being executed
3925    pub tool_name: String,
3926    /// Human-readable display title for the tool, when the selected tool descriptor has a non-empty title.
3927    #[serde(skip_serializing_if = "Option::is_none")]
3928    pub tool_title: Option<String>,
3929    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
3930    #[serde(skip_serializing_if = "Option::is_none")]
3931    pub turn_id: Option<String>,
3932}
3933
3934/// Session event "tool.execution_partial_result". Streaming tool execution output for incremental result display
3935#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3936#[serde(rename_all = "camelCase")]
3937pub struct ToolExecutionPartialResultData {
3938    /// Incremental output chunk from the running tool
3939    pub partial_output: String,
3940    /// Tool call ID this partial result belongs to
3941    pub tool_call_id: String,
3942}
3943
3944/// Session event "tool.execution_progress". Tool execution progress notification with status message
3945#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3946#[serde(rename_all = "camelCase")]
3947pub struct ToolExecutionProgressData {
3948    /// Human-readable progress status message (e.g., from an MCP server)
3949    pub progress_message: String,
3950    /// Tool call ID this progress notification belongs to
3951    pub tool_call_id: String,
3952}
3953
3954/// Error details when the tool execution failed
3955#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3956#[serde(rename_all = "camelCase")]
3957pub struct ToolExecutionCompleteError {
3958    /// Machine-readable error code
3959    #[serde(skip_serializing_if = "Option::is_none")]
3960    pub code: Option<String>,
3961    /// Human-readable error message
3962    pub message: String,
3963    /// What the user must do to recover, when the runtime knows of an action. Set on sandbox policy denials, where `message` names the rule that blocked the call but never the client affordance that relaxes it.
3964    #[serde(skip_serializing_if = "Option::is_none")]
3965    pub remediation: Option<RemediationAction>,
3966}
3967
3968/// Binary result returned by a tool for the model
3969#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3970#[serde(rename_all = "camelCase")]
3971pub struct PersistedBinaryImage {
3972    /// Base64-encoded binary data
3973    pub data: String,
3974    /// Human-readable description of the binary data
3975    #[serde(skip_serializing_if = "Option::is_none")]
3976    pub description: Option<String>,
3977    /// Optional metadata from the producing tool.
3978    #[serde(skip_serializing_if = "Option::is_none")]
3979    pub metadata: Option<HashMap<String, serde_json::Value>>,
3980    /// MIME type of the binary data
3981    pub mime_type: String,
3982    /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
3983    pub r#type: PersistedBinaryImageType,
3984}
3985
3986/// A binary result whose data was omitted from persistence due to the inline size limit
3987///
3988/// <div class="warning">
3989///
3990/// **Experimental.** This type is part of an experimental wire-protocol surface
3991/// and may change or be removed in future SDK or CLI releases.
3992///
3993/// </div>
3994#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3995#[serde(rename_all = "camelCase")]
3996pub struct OmittedBinaryResult {
3997    /// Decoded byte length of the omitted binary data
3998    pub byte_length: i64,
3999    /// Human-readable description of the binary data
4000    #[serde(skip_serializing_if = "Option::is_none")]
4001    pub description: Option<String>,
4002    /// Optional metadata from the producing tool.
4003    #[serde(skip_serializing_if = "Option::is_none")]
4004    pub metadata: Option<HashMap<String, serde_json::Value>>,
4005    /// MIME type of the omitted binary data
4006    pub mime_type: String,
4007    /// Why the binary data is absent: it exceeded the inline size limit, or its asset was unavailable
4008    pub omitted_reason: OmittedBinaryOmittedReason,
4009    /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
4010    pub r#type: OmittedBinaryType,
4011}
4012
4013/// A reference to binary data persisted once on a session.binary_asset event and shared by id
4014///
4015/// <div class="warning">
4016///
4017/// **Experimental.** This type is part of an experimental wire-protocol surface
4018/// and may change or be removed in future SDK or CLI releases.
4019///
4020/// </div>
4021#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4022#[serde(rename_all = "camelCase")]
4023pub struct BinaryAssetReference {
4024    /// Content-addressed id of the session.binary_asset event that holds this binary's bytes (e.g. "sha256:...").
4025    pub asset_id: String,
4026    /// Decoded byte length of the referenced binary data
4027    pub byte_length: i64,
4028    /// Human-readable description of the binary data
4029    #[serde(skip_serializing_if = "Option::is_none")]
4030    pub description: Option<String>,
4031    /// Optional metadata from the producing tool.
4032    #[serde(skip_serializing_if = "Option::is_none")]
4033    pub metadata: Option<HashMap<String, serde_json::Value>>,
4034    /// MIME type of the referenced binary data
4035    pub mime_type: String,
4036    /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
4037    pub r#type: BinaryAssetReferenceType,
4038}
4039
4040/// A source supplied by a tool that should be made available to the model as citable content.
4041///
4042/// <div class="warning">
4043///
4044/// **Experimental.** This type is part of an experimental wire-protocol surface
4045/// and may change or be removed in future SDK or CLI releases.
4046///
4047/// </div>
4048#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4049#[serde(rename_all = "camelCase")]
4050pub struct CitableSource {
4051    /// The source text made available to the model as citable content.
4052    pub content: String,
4053    /// 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.
4054    pub id: String,
4055    /// File path relative to the agent's workspace root, when the source is a file.
4056    #[serde(skip_serializing_if = "Option::is_none")]
4057    pub path: Option<String>,
4058    /// Human-readable title of the source.
4059    #[serde(skip_serializing_if = "Option::is_none")]
4060    pub title: Option<String>,
4061    /// URL of the source, when it is a web resource.
4062    #[serde(skip_serializing_if = "Option::is_none")]
4063    pub url: Option<String>,
4064}
4065
4066/// Plain text content block
4067#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4068#[serde(rename_all = "camelCase")]
4069pub struct ToolExecutionCompleteContentText {
4070    /// The text content
4071    pub text: String,
4072    /// Content block type discriminator
4073    pub r#type: ToolExecutionCompleteContentTextType,
4074}
4075
4076/// Deprecated for shell command exit metadata. Use ToolExecutionCompleteContentShellExit instead.
4077#[doc(hidden)]
4078#[deprecated]
4079#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4080#[serde(rename_all = "camelCase")]
4081pub struct ToolExecutionCompleteContentTerminal {
4082    /// Working directory where the command was executed
4083    #[serde(skip_serializing_if = "Option::is_none")]
4084    pub cwd: Option<String>,
4085    /// Process exit code, if the command has completed
4086    #[serde(skip_serializing_if = "Option::is_none")]
4087    pub exit_code: Option<i64>,
4088    /// Terminal/shell output text
4089    pub text: String,
4090    /// Content block type discriminator
4091    pub r#type: ToolExecutionCompleteContentTerminalType,
4092}
4093
4094/// Shell command exit metadata with optional output preview
4095#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4096#[serde(rename_all = "camelCase")]
4097pub struct ToolExecutionCompleteContentShellExit {
4098    /// Working directory where the shell command was executed
4099    #[serde(skip_serializing_if = "Option::is_none")]
4100    pub cwd: Option<String>,
4101    /// Exit code from the completed shell command
4102    pub exit_code: i64,
4103    /// Path reported in the shell session's filesystem namespace when shell output exceeded the configured large-output threshold.
4104    #[serde(skip_serializing_if = "Option::is_none")]
4105    pub output_file_path: Option<String>,
4106    /// Output associated with this shell command, if available. May be partial, truncated, or a preview; not guaranteed to be full output.
4107    #[serde(skip_serializing_if = "Option::is_none")]
4108    pub output_preview: Option<String>,
4109    /// Whether outputPreview is known to be incomplete or truncated
4110    #[serde(skip_serializing_if = "Option::is_none")]
4111    pub output_truncated: Option<bool>,
4112    /// Shell id, as assigned by Copilot runtime
4113    pub shell_id: String,
4114    /// Content block type discriminator
4115    pub r#type: ToolExecutionCompleteContentShellExitType,
4116}
4117
4118/// Image content block with base64-encoded data
4119#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4120#[serde(rename_all = "camelCase")]
4121pub struct ToolExecutionCompleteContentImage {
4122    /// Base64-encoded image data
4123    pub data: String,
4124    /// MIME type of the image (e.g., image/png, image/jpeg)
4125    pub mime_type: String,
4126    /// Content block type discriminator
4127    pub r#type: ToolExecutionCompleteContentImageType,
4128}
4129
4130/// Audio content block with base64-encoded data
4131#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4132#[serde(rename_all = "camelCase")]
4133pub struct ToolExecutionCompleteContentAudio {
4134    /// Base64-encoded audio data
4135    pub data: String,
4136    /// MIME type of the audio (e.g., audio/wav, audio/mpeg)
4137    pub mime_type: String,
4138    /// Content block type discriminator
4139    pub r#type: ToolExecutionCompleteContentAudioType,
4140}
4141
4142/// Icon image for a resource
4143#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4144#[serde(rename_all = "camelCase")]
4145pub struct ToolExecutionCompleteContentResourceLinkIcon {
4146    /// MIME type of the icon image
4147    #[serde(skip_serializing_if = "Option::is_none")]
4148    pub mime_type: Option<String>,
4149    /// Available icon sizes (e.g., ['16x16', '32x32'])
4150    #[serde(skip_serializing_if = "Option::is_none")]
4151    pub sizes: Option<Vec<String>>,
4152    /// URL or path to the icon image
4153    pub src: String,
4154    /// Theme variant this icon is intended for
4155    #[serde(skip_serializing_if = "Option::is_none")]
4156    pub theme: Option<ToolExecutionCompleteContentResourceLinkIconTheme>,
4157}
4158
4159/// Resource link content block referencing an external resource
4160#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4161#[serde(rename_all = "camelCase")]
4162pub struct ToolExecutionCompleteContentResourceLink {
4163    /// Human-readable description of the resource
4164    #[serde(skip_serializing_if = "Option::is_none")]
4165    pub description: Option<String>,
4166    /// Icons associated with this resource
4167    #[serde(skip_serializing_if = "Option::is_none")]
4168    pub icons: Option<Vec<ToolExecutionCompleteContentResourceLinkIcon>>,
4169    /// MIME type of the resource content
4170    #[serde(skip_serializing_if = "Option::is_none")]
4171    pub mime_type: Option<String>,
4172    /// Resource name identifier
4173    pub name: String,
4174    /// Size of the resource in bytes
4175    #[serde(skip_serializing_if = "Option::is_none")]
4176    pub size: Option<i64>,
4177    /// Human-readable display title for the resource
4178    #[serde(skip_serializing_if = "Option::is_none")]
4179    pub title: Option<String>,
4180    /// Content block type discriminator
4181    pub r#type: ToolExecutionCompleteContentResourceLinkType,
4182    /// URI identifying the resource
4183    pub uri: String,
4184}
4185
4186/// Embedded text resource contents identified by a URI, with an optional MIME type and a text payload.
4187#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4188#[serde(rename_all = "camelCase")]
4189pub struct EmbeddedTextResourceContents {
4190    /// MIME type of the text content
4191    #[serde(skip_serializing_if = "Option::is_none")]
4192    pub mime_type: Option<String>,
4193    /// Text content of the resource
4194    pub text: String,
4195    /// URI identifying the resource
4196    pub uri: String,
4197}
4198
4199/// Embedded binary resource contents identified by a URI, with an optional MIME type and a base64-encoded blob.
4200#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4201#[serde(rename_all = "camelCase")]
4202pub struct EmbeddedBlobResourceContents {
4203    /// Base64-encoded binary content of the resource
4204    pub blob: String,
4205    /// MIME type of the blob content
4206    #[serde(skip_serializing_if = "Option::is_none")]
4207    pub mime_type: Option<String>,
4208    /// URI identifying the resource
4209    pub uri: String,
4210}
4211
4212/// Embedded resource content block with inline text or binary data
4213#[derive(Debug, Clone, Serialize, Deserialize)]
4214#[serde(rename_all = "camelCase")]
4215pub struct ToolExecutionCompleteContentResource {
4216    /// The embedded resource contents, either text or base64-encoded binary
4217    pub resource: ToolExecutionCompleteContentResourceDetails,
4218    /// Content block type discriminator
4219    pub r#type: ToolExecutionCompleteContentResourceType,
4220}
4221
4222/// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
4223#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4224#[serde(rename_all = "camelCase")]
4225pub struct ToolExecutionCompleteUIResourceMetaUICsp {
4226    /// Domains the UI resource may use as document base URIs.
4227    #[serde(skip_serializing_if = "Option::is_none")]
4228    pub base_uri_domains: Option<Vec<String>>,
4229    /// Domains the UI resource may connect to.
4230    #[serde(skip_serializing_if = "Option::is_none")]
4231    pub connect_domains: Option<Vec<String>>,
4232    /// Domains the UI resource may embed as nested frames.
4233    #[serde(skip_serializing_if = "Option::is_none")]
4234    pub frame_domains: Option<Vec<String>>,
4235    /// Domains from which the UI resource may load scripts, styles, images, and other resources.
4236    #[serde(skip_serializing_if = "Option::is_none")]
4237    pub resource_domains: Option<Vec<String>>,
4238}
4239
4240/// Marker object for camera permission on an MCP Apps UI resource.
4241#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4242#[serde(rename_all = "camelCase")]
4243pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsCamera {}
4244
4245/// Marker object for clipboard-write permission on an MCP Apps UI resource.
4246#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4247#[serde(rename_all = "camelCase")]
4248pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite {}
4249
4250/// Marker object for geolocation permission on an MCP Apps UI resource.
4251#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4252#[serde(rename_all = "camelCase")]
4253pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation {}
4254
4255/// Marker object for microphone permission on an MCP Apps UI resource.
4256#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4257#[serde(rename_all = "camelCase")]
4258pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone {}
4259
4260/// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
4261#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4262#[serde(rename_all = "camelCase")]
4263pub struct ToolExecutionCompleteUIResourceMetaUIPermissions {
4264    /// Marker object for camera permission on an MCP Apps UI resource.
4265    #[serde(skip_serializing_if = "Option::is_none")]
4266    pub camera: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsCamera>,
4267    /// Marker object for clipboard-write permission on an MCP Apps UI resource.
4268    #[serde(skip_serializing_if = "Option::is_none")]
4269    pub clipboard_write: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite>,
4270    /// Marker object for geolocation permission on an MCP Apps UI resource.
4271    #[serde(skip_serializing_if = "Option::is_none")]
4272    pub geolocation: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation>,
4273    /// Marker object for microphone permission on an MCP Apps UI resource.
4274    #[serde(skip_serializing_if = "Option::is_none")]
4275    pub microphone: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone>,
4276}
4277
4278/// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
4279#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4280#[serde(rename_all = "camelCase")]
4281pub struct ToolExecutionCompleteUIResourceMetaUI {
4282    /// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
4283    #[serde(skip_serializing_if = "Option::is_none")]
4284    pub csp: Option<ToolExecutionCompleteUIResourceMetaUICsp>,
4285    /// Optional dedicated origin for the rendered MCP Apps UI resource.
4286    #[serde(skip_serializing_if = "Option::is_none")]
4287    pub domain: Option<String>,
4288    /// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
4289    #[serde(skip_serializing_if = "Option::is_none")]
4290    pub permissions: Option<ToolExecutionCompleteUIResourceMetaUIPermissions>,
4291    /// Whether the host should render a border around the MCP Apps UI resource.
4292    #[serde(skip_serializing_if = "Option::is_none")]
4293    pub prefers_border: Option<bool>,
4294}
4295
4296/// Resource-level UI metadata (CSP, permissions, visual preferences)
4297#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4298#[serde(rename_all = "camelCase")]
4299pub struct ToolExecutionCompleteUIResourceMeta {
4300    /// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
4301    #[serde(skip_serializing_if = "Option::is_none")]
4302    pub ui: Option<ToolExecutionCompleteUIResourceMetaUI>,
4303}
4304
4305/// MCP Apps UI resource content for rendering in a sandboxed iframe
4306#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4307#[serde(rename_all = "camelCase")]
4308pub struct ToolExecutionCompleteUIResource {
4309    /// Resource-level UI metadata (CSP, permissions, visual preferences)
4310    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
4311    pub meta: Option<ToolExecutionCompleteUIResourceMeta>,
4312    /// Base64-encoded HTML content
4313    #[serde(skip_serializing_if = "Option::is_none")]
4314    pub blob: Option<String>,
4315    /// MIME type of the content
4316    pub mime_type: String,
4317    /// HTML content as a string
4318    #[serde(skip_serializing_if = "Option::is_none")]
4319    pub text: Option<String>,
4320    /// The ui:// URI of the resource
4321    pub uri: String,
4322}
4323
4324/// Tool execution result on success
4325#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4326#[serde(rename_all = "camelCase")]
4327pub struct ToolExecutionCompleteResult {
4328    /// Model-facing binary results (base64 inline or size-omitted markers) sent to the LLM for this tool call
4329    ///
4330    /// <div class="warning">
4331    ///
4332    /// **Experimental.** This type is part of an experimental wire-protocol surface
4333    /// and may change or be removed in future SDK or CLI releases.
4334    ///
4335    /// </div>
4336    #[serde(skip_serializing_if = "Option::is_none")]
4337    pub binary_results_for_llm: Option<Vec<PersistedBinaryResult>>,
4338    /// Provider-neutral source material this tool makes available to the model as citable content. Persisted so it survives session resume. Experimental.
4339    ///
4340    /// <div class="warning">
4341    ///
4342    /// **Experimental.** This type is part of an experimental wire-protocol surface
4343    /// and may change or be removed in future SDK or CLI releases.
4344    ///
4345    /// </div>
4346    #[serde(skip_serializing_if = "Option::is_none")]
4347    pub citable_sources: Option<Vec<CitableSource>>,
4348    /// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency
4349    pub content: String,
4350    /// Structured content blocks (text, images, audio, resources) returned by the tool in their native format
4351    #[serde(skip_serializing_if = "Option::is_none")]
4352    pub contents: Option<Vec<ToolExecutionCompleteContent>>,
4353    /// Detailed tool result for UI/timeline display, preserving complete content such as diffs for most tools. Successful skill invocations intentionally use the concise model-facing content here; the authoritative skill body is carried by the corresponding skill invocation event. Falls back to content when absent.
4354    #[serde(skip_serializing_if = "Option::is_none")]
4355    pub detailed_content: Option<String>,
4356    /// 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.
4357    ///
4358    /// <div class="warning">
4359    ///
4360    /// **Experimental.** This type is part of an experimental wire-protocol surface
4361    /// and may change or be removed in future SDK or CLI releases.
4362    ///
4363    /// </div>
4364    #[serde(skip_serializing_if = "Option::is_none")]
4365    pub mcp_meta: Option<serde_json::Value>,
4366    /// Structured content (arbitrary JSON) returned verbatim by the MCP tool
4367    #[serde(skip_serializing_if = "Option::is_none")]
4368    pub structured_content: Option<serde_json::Value>,
4369    /// MCP Apps UI resource content for rendering in a sandboxed iframe
4370    #[serde(skip_serializing_if = "Option::is_none")]
4371    pub ui_resource: Option<ToolExecutionCompleteUIResource>,
4372}
4373
4374/// Experimental shell completion facts retained independently of the full tool result.
4375///
4376/// <div class="warning">
4377///
4378/// **Experimental.** This type is part of an experimental wire-protocol surface
4379/// and may change or be removed in future SDK or CLI releases.
4380///
4381/// </div>
4382#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4383#[serde(rename_all = "camelCase")]
4384pub struct ToolExecutionCompleteShellExecution {
4385    /// Process exit code reported by the shell driver.
4386    pub exit_code: i64,
4387}
4388
4389/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
4390#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4391#[serde(rename_all = "camelCase")]
4392pub struct ToolExecutionCompleteToolDescriptionMetaUI {
4393    /// URI of the UI resource
4394    #[serde(skip_serializing_if = "Option::is_none")]
4395    pub resource_uri: Option<String>,
4396    /// Who can access this tool
4397    #[serde(skip_serializing_if = "Option::is_none")]
4398    pub visibility: Option<Vec<ToolExecutionCompleteToolDescriptionMetaUIVisibility>>,
4399}
4400
4401/// MCP Apps metadata for UI resource association
4402#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4403#[serde(rename_all = "camelCase")]
4404pub struct ToolExecutionCompleteToolDescriptionMeta {
4405    /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
4406    #[serde(skip_serializing_if = "Option::is_none")]
4407    pub ui: Option<ToolExecutionCompleteToolDescriptionMetaUI>,
4408}
4409
4410/// Tool definition metadata, present for MCP tools with MCP Apps support
4411#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4412#[serde(rename_all = "camelCase")]
4413pub struct ToolExecutionCompleteToolDescription {
4414    /// MCP Apps metadata for UI resource association
4415    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
4416    pub meta: Option<ToolExecutionCompleteToolDescriptionMeta>,
4417    /// Tool description
4418    #[serde(skip_serializing_if = "Option::is_none")]
4419    pub description: Option<String>,
4420    /// Tool name
4421    pub name: String,
4422}
4423
4424/// Session event "tool.execution_complete". Tool execution completion results including success status, detailed output, and error information
4425#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4426#[serde(rename_all = "camelCase")]
4427pub struct ToolExecutionCompleteData {
4428    /// Error details when the tool execution failed
4429    #[serde(skip_serializing_if = "Option::is_none")]
4430    pub error: Option<ToolExecutionCompleteError>,
4431    /// Experimental HydraFusion attribution for this tool completion.
4432    ///
4433    /// <div class="warning">
4434    ///
4435    /// **Experimental.** This type is part of an experimental wire-protocol surface
4436    /// and may change or be removed in future SDK or CLI releases.
4437    ///
4438    /// </div>
4439    #[serde(skip_serializing_if = "Option::is_none")]
4440    pub fusion: Option<FusionAttribution>,
4441    /// CAPI interaction ID for correlating this tool execution with upstream telemetry
4442    #[serde(skip_serializing_if = "Option::is_none")]
4443    pub interaction_id: Option<String>,
4444    /// Whether this tool call was explicitly requested by the user rather than the assistant
4445    #[serde(skip_serializing_if = "Option::is_none")]
4446    pub is_user_requested: Option<bool>,
4447    /// 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.
4448    ///
4449    /// <div class="warning">
4450    ///
4451    /// **Experimental.** This type is part of an experimental wire-protocol surface
4452    /// and may change or be removed in future SDK or CLI releases.
4453    ///
4454    /// </div>
4455    #[serde(skip_serializing_if = "Option::is_none")]
4456    pub mcp_meta: Option<serde_json::Value>,
4457    /// Model identifier that generated this tool call
4458    #[serde(skip_serializing_if = "Option::is_none")]
4459    pub model: Option<String>,
4460    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
4461    #[doc(hidden)]
4462    #[deprecated]
4463    #[serde(skip_serializing_if = "Option::is_none")]
4464    pub parent_tool_call_id: Option<String>,
4465    /// Tool execution result on success
4466    #[serde(skip_serializing_if = "Option::is_none")]
4467    pub result: Option<ToolExecutionCompleteResult>,
4468    /// 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.
4469    #[serde(skip_serializing_if = "Option::is_none")]
4470    pub rte: Option<bool>,
4471    /// Whether this tool execution ran inside a sandbox container
4472    #[serde(skip_serializing_if = "Option::is_none")]
4473    pub sandboxed: Option<bool>,
4474    /// Experimental shell completion facts captured before the persisted result contents are stripped.
4475    ///
4476    /// <div class="warning">
4477    ///
4478    /// **Experimental.** This type is part of an experimental wire-protocol surface
4479    /// and may change or be removed in future SDK or CLI releases.
4480    ///
4481    /// </div>
4482    #[serde(skip_serializing_if = "Option::is_none")]
4483    pub shell_execution: Option<ToolExecutionCompleteShellExecution>,
4484    /// Whether the tool execution completed successfully
4485    pub success: bool,
4486    /// Unique identifier for the completed tool call
4487    pub tool_call_id: String,
4488    /// Tool definition metadata, present for MCP tools with MCP Apps support
4489    #[serde(skip_serializing_if = "Option::is_none")]
4490    pub tool_description: Option<ToolExecutionCompleteToolDescription>,
4491    /// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
4492    #[serde(skip_serializing_if = "Option::is_none")]
4493    pub tool_telemetry: Option<HashMap<String, serde_json::Value>>,
4494    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
4495    #[serde(skip_serializing_if = "Option::is_none")]
4496    pub turn_id: Option<String>,
4497}
4498
4499/// Session event "tool_search.activated". Persisted generic client-side tool activations restored when a session resumes.
4500#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4501#[serde(rename_all = "camelCase")]
4502pub struct ToolSearchActivatedData {
4503    /// Tool-search strategy that activated the definitions.
4504    pub strategy: String,
4505    /// Names of tool definitions activated by this search invocation.
4506    pub tool_names: Vec<String>,
4507}
4508
4509/// Session event "skill.invoked". Skill invocation details including content, allowed tools, and plugin metadata
4510#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4511#[serde(rename_all = "camelCase")]
4512pub struct SkillInvokedData {
4513    /// Tool names that should be auto-approved when this skill is active
4514    #[serde(skip_serializing_if = "Option::is_none")]
4515    pub allowed_tools: Option<Vec<String>>,
4516    /// Full content of the skill file, injected into the conversation for the model
4517    pub content: String,
4518    /// Description of the skill from its SKILL.md frontmatter
4519    #[serde(skip_serializing_if = "Option::is_none")]
4520    pub description: Option<String>,
4521    /// Whether model invocation is disabled for this skill
4522    #[serde(skip_serializing_if = "Option::is_none")]
4523    pub disable_model_invocation: Option<bool>,
4524    /// Projected chat-message count when the skill was invoked. New writers persist this so replay does not need to reconstruct superseded history; readers derive it for legacy events when absent.
4525    #[serde(skip_serializing_if = "Option::is_none")]
4526    pub invoked_at_turn: Option<i64>,
4527    /// Model identifier active when the skill was invoked, when known
4528    #[serde(skip_serializing_if = "Option::is_none")]
4529    pub model: Option<String>,
4530    /// Name of the invoked skill
4531    pub name: String,
4532    /// File path to the SKILL.md definition, or an empty string for an SDK-provided skill without a filesystem identity
4533    pub path: String,
4534    /// Name of the plugin this skill originated from, when applicable
4535    #[serde(skip_serializing_if = "Option::is_none")]
4536    pub plugin_name: Option<String>,
4537    /// Version of the plugin this skill originated from, when applicable
4538    #[serde(skip_serializing_if = "Option::is_none")]
4539    pub plugin_version: Option<String>,
4540    /// 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)
4541    #[serde(skip_serializing_if = "Option::is_none")]
4542    pub source: Option<String>,
4543    /// 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)
4544    #[serde(skip_serializing_if = "Option::is_none")]
4545    pub trigger: Option<SkillInvokedTrigger>,
4546}
4547
4548/// Session event "skill.invoked_ref". Internal durable skill invocation receipt whose content resolves from an earlier inline skill event in the same session.
4549#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4550#[serde(rename_all = "camelCase")]
4551pub struct SkillInvokedRefData {
4552    /// Tool names that should be auto-approved when this skill is active
4553    #[serde(skip_serializing_if = "Option::is_none")]
4554    pub allowed_tools: Option<Vec<String>>,
4555    /// Content identifier of an earlier inline skill event in this session, in the prefixed form `sha256:<lowercase hex digest>` over the UTF-8 bytes of that event's `content`
4556    pub content_id: String,
4557    /// UTF-16 code unit length of the referenced skill content. Derived from the referenced body and validated against it when the reference is expanded; a reference whose length disagrees with the body it names is rejected instead of expanded
4558    pub content_length: i64,
4559    /// Description of the skill from its SKILL.md frontmatter
4560    #[serde(skip_serializing_if = "Option::is_none")]
4561    pub description: Option<String>,
4562    /// Whether model invocation is disabled for this skill
4563    #[serde(skip_serializing_if = "Option::is_none")]
4564    pub disable_model_invocation: Option<bool>,
4565    /// Projected chat-message count when the skill was invoked. Preserved from the inline event data when the authored body is deduplicated.
4566    #[serde(skip_serializing_if = "Option::is_none")]
4567    pub invoked_at_turn: Option<i64>,
4568    /// Model identifier active when the skill was invoked, when known
4569    #[serde(skip_serializing_if = "Option::is_none")]
4570    pub model: Option<String>,
4571    /// Name of the invoked skill
4572    pub name: String,
4573    /// File path to the SKILL.md definition, or an empty string for an SDK-provided skill without a filesystem identity
4574    pub path: String,
4575    /// Name of the plugin this skill originated from, when applicable
4576    #[serde(skip_serializing_if = "Option::is_none")]
4577    pub plugin_name: Option<String>,
4578    /// Version of the plugin this skill originated from, when applicable
4579    #[serde(skip_serializing_if = "Option::is_none")]
4580    pub plugin_version: Option<String>,
4581    /// Source identifier for where the skill was discovered
4582    #[serde(skip_serializing_if = "Option::is_none")]
4583    pub source: Option<String>,
4584    /// What triggered the skill invocation
4585    #[serde(skip_serializing_if = "Option::is_none")]
4586    pub trigger: Option<SkillInvokedTrigger>,
4587}
4588
4589/// Session event "skill.context_delivered". Exact skill context delivered to the model during a tool phase. This is not a user submission or another skill invocation.
4590#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4591#[serde(rename_all = "camelCase")]
4592pub struct SkillContextDeliveredData {
4593    /// Exact model-facing skill wrapper, including its invocation-time file context
4594    pub content: String,
4595    /// Interaction that delivered this context, when known
4596    #[serde(skip_serializing_if = "Option::is_none")]
4597    pub interaction_id: Option<String>,
4598    /// Unmodified injection provenance, in the form skill-`<invocation-name>`
4599    pub source: String,
4600}
4601
4602/// Session event "skill.context_delivered_ref". Internal durable receipt that reconstructs exact model-visible skill context from earlier session content.
4603#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4604#[serde(rename_all = "camelCase")]
4605pub struct SkillContextDeliveredRefData {
4606    /// Content identifier of an earlier inline skill event in this session, in the prefixed form `sha256:<lowercase hex digest>` over the UTF-8 bytes of that event's `content`
4607    pub content_id: String,
4608    /// Interaction that delivered this context, when known
4609    #[serde(skip_serializing_if = "Option::is_none")]
4610    pub interaction_id: Option<String>,
4611    /// Exact text preceding the referenced content in the delivered wrapper
4612    #[serde(skip_serializing_if = "Option::is_none")]
4613    pub prefix: Option<String>,
4614    /// Unmodified injection provenance, in the form skill-`<invocation-name>`
4615    pub source: String,
4616    /// Exact text following the referenced content in the delivered wrapper
4617    #[serde(skip_serializing_if = "Option::is_none")]
4618    pub suffix: Option<String>,
4619}
4620
4621/// Effective sandbox filesystem rules, in policy order. Only populated when content capture is enabled, since these are real host paths.
4622#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4623#[serde(rename_all = "camelCase")]
4624pub struct SandboxFilesystemPolicyDetails {
4625    /// Paths the sandboxed process may not access at all
4626    pub denied_paths: Vec<String>,
4627    /// Paths the sandboxed process may read but not write
4628    pub readonly_paths: Vec<String>,
4629    /// Paths the sandboxed process may read and write
4630    pub readwrite_paths: Vec<String>,
4631}
4632
4633#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4634#[serde(rename_all = "camelCase")]
4635pub struct SandboxDecisionDataPolicyResolved {
4636    /// Whether the current working directory was granted automatically
4637    pub add_current_working_directory: bool,
4638    /// Whether callers may opt an individual command out of the sandbox
4639    pub allow_bypass: bool,
4640    /// Whether the sandboxed process may reach loopback and private-range addresses
4641    pub allow_local_network: bool,
4642    /// Whether the sandboxed process may open outbound network connections
4643    pub allow_outbound: bool,
4644    /// Process-containment implementation backing the sandbox
4645    pub backend: SandboxBackend,
4646    /// Enforcement mechanism this decision describes
4647    pub control: SandboxControl,
4648    /// Why enforcement is weaker than configured, when it is
4649    #[serde(skip_serializing_if = "Option::is_none")]
4650    pub degradation_reason: Option<SandboxDegradationReason>,
4651    /// Number of denied path rules in the effective policy
4652    pub denied_paths_count: i64,
4653    /// Effective filesystem rules. Populated only when content capture is enabled; the counts above are always present.
4654    #[serde(skip_serializing_if = "Option::is_none")]
4655    pub effective_filesystem_policy: Option<SandboxFilesystemPolicyDetails>,
4656    /// Runtime subsystem that applied the policy
4657    pub enforcement_point: SandboxEnforcementPoint,
4658    /// Whether the sandbox policy permits GitHub CLI credentials inside the sandbox. A policy capability, not proof that a credential was injected into this spawn: injection is per-command
4659    pub gh_auth: bool,
4660    /// Whether the sandbox policy permits git credentials inside the sandbox. A policy capability, not proof that a credential was injected into this spawn: injection is per-command
4661    pub git_auth: bool,
4662    /// Whether the macOS keychain was reachable from inside the sandbox. Always false on other platforms.
4663    pub keychain_access: bool,
4664    /// Sandbox decision variant discriminator.
4665    pub kind: SandboxDecisionDataPolicyResolvedKind,
4666    /// Whether the resolved policy is fully active or degraded
4667    pub outcome: SandboxOutcome,
4668    /// Host platform the sandbox is running on
4669    pub platform: SandboxPlatform,
4670    /// Whether the policy came from built-in defaults or user configuration
4671    pub policy_source: SandboxPolicySource,
4672    /// Whether outbound traffic is unproxied, routed through a loopback proxy, or routed through an external proxy
4673    pub proxy_mode: SandboxProxyMode,
4674    /// Number of read-only path rules in the effective policy
4675    pub readonly_paths_count: i64,
4676    /// Number of read-write path rules in the effective policy
4677    pub readwrite_paths_count: i64,
4678    /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4679    #[serde(skip_serializing_if = "Option::is_none")]
4680    pub tool_call_id: Option<String>,
4681}
4682
4683#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4684#[serde(rename_all = "camelCase")]
4685pub struct SandboxDecisionDataSpawnCompleted {
4686    /// Process-containment implementation backing the sandbox
4687    pub backend: SandboxBackend,
4688    /// Enforcement mechanism this decision describes
4689    pub control: SandboxControl,
4690    /// Why enforcement is weaker than configured, when it is
4691    #[serde(skip_serializing_if = "Option::is_none")]
4692    pub degradation_reason: Option<SandboxDegradationReason>,
4693    /// Wall-clock time spent spawning the sandboxed process, in milliseconds
4694    pub duration_ms: f64,
4695    /// Runtime subsystem that applied the policy
4696    pub enforcement_point: SandboxEnforcementPoint,
4697    /// Sandbox decision variant discriminator.
4698    pub kind: SandboxDecisionDataSpawnCompletedKind,
4699    /// Whether the sandboxed process launched under the named backend. Not the exit status of the command that ran inside it.
4700    pub outcome: SandboxOutcome,
4701    /// Host platform the sandbox is running on
4702    pub platform: SandboxPlatform,
4703    /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4704    #[serde(skip_serializing_if = "Option::is_none")]
4705    pub tool_call_id: Option<String>,
4706}
4707
4708#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4709#[serde(rename_all = "camelCase")]
4710pub struct SandboxDecisionDataEnforcementState {
4711    /// Runtime observation backing the state. Omitted for `inactive`, which has nothing to attest.
4712    #[serde(skip_serializing_if = "Option::is_none")]
4713    pub attestation: Option<SandboxAttestation>,
4714    /// Containment backend that engaged. `unsupported` for any state other than `engaged`, since no backend is known to have run.
4715    pub backend: SandboxBackend,
4716    /// Command the enforcement governed. Populated only when content capture is enabled, and only for shell commands; MCP, LSP, and search command lines are runtime plumbing.
4717    #[serde(skip_serializing_if = "Option::is_none")]
4718    pub command: Option<String>,
4719    /// Enforcement mechanism this decision describes
4720    pub control: SandboxControl,
4721    /// Runtime subsystem whose enforcement this describes
4722    pub enforcement_point: SandboxEnforcementPoint,
4723    /// Sandbox decision variant discriminator.
4724    pub kind: SandboxDecisionDataEnforcementStateKind,
4725    /// Observed enforcement state: `engaged`, `inactive`, or `failed`. Derived from runtime evidence, never from the configured posture or the compile-time target platform.
4726    pub outcome: SandboxOutcome,
4727    /// Host platform the sandbox is running on
4728    pub platform: SandboxPlatform,
4729    /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4730    #[serde(skip_serializing_if = "Option::is_none")]
4731    pub tool_call_id: Option<String>,
4732}
4733
4734/// An enforcement check refused a specific access. Emitted per refusal with no deduplication, including when policy permits the caller to bypass the denial. Carries no backend: the built-in checks that produce this run in-process against the effective policy.
4735#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4736#[serde(rename_all = "camelCase")]
4737pub struct SandboxDecisionDataAccessDenied {
4738    /// Runtime observation backing the denial.
4739    pub attestation: SandboxAttestation,
4740    /// Command whose execution the denial arose from. Populated only when content capture is enabled.
4741    #[serde(skip_serializing_if = "Option::is_none")]
4742    pub command: Option<String>,
4743    /// How strong the evidence behind this denial is. Lets an analysis separate denials the sandbox recorded from ones inferred from output text, which otherwise look identical.
4744    #[serde(skip_serializing_if = "Option::is_none")]
4745    pub confidence: Option<SandboxDenialConfidence>,
4746    /// Sandbox control the denial belongs to. Follows from `denialClass`.
4747    pub control: SandboxControl,
4748    /// Bounded class of the refused access.
4749    pub denial_class: SandboxDenialClass,
4750    /// Resource the check refused, when identified and content capture is enabled.
4751    #[serde(skip_serializing_if = "Option::is_none")]
4752    pub denied_resource: Option<String>,
4753    /// Runtime subsystem that performed the check
4754    pub enforcement_point: SandboxEnforcementPoint,
4755    /// Sandbox decision variant discriminator.
4756    pub kind: SandboxDecisionDataAccessDeniedKind,
4757    /// Always `denied`.
4758    pub outcome: SandboxOutcome,
4759    /// Host operating-system family
4760    pub platform: SandboxPlatform,
4761    /// Executable image associated with the captured denial, normalized to a basename. Populated only when content capture is enabled.
4762    #[serde(skip_serializing_if = "Option::is_none")]
4763    pub process_name: Option<String>,
4764    /// Tool call the denial belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4765    #[serde(skip_serializing_if = "Option::is_none")]
4766    pub tool_call_id: Option<String>,
4767}
4768
4769/// A request to run outside the process sandbox was resolved. This is what makes an `inactive` `enforcement_state` readable: without it, a command that ran unsandboxed because a person approved a bypass looks identical to one that ran unsandboxed because the session never had a sandbox. Reported only when a sandbox was in force, since bypassing a disabled sandbox bypasses nothing. Carries neither backend nor attestation: the verdict comes from the runtime's own permission flow or the local escalation prompt, not from a containment backend and not from the built-in policy check, so `source` is what records where it came from.
4770#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4771#[serde(rename_all = "camelCase")]
4772pub struct SandboxDecisionDataBypassDecided {
4773    /// Command the verdict governs. Populated only when content capture is enabled.
4774    #[serde(skip_serializing_if = "Option::is_none")]
4775    pub command: Option<String>,
4776    /// How strong the evidence behind `denialClass` was. Present exactly when `denialClass` is, so a verdict that relaxed the sandbox on a guess is distinguishable from one that relaxed it on a recorded refusal. Named to match `access_denied`, which reports the same pair.
4777    #[serde(skip_serializing_if = "Option::is_none")]
4778    pub confidence: Option<SandboxDenialConfidence>,
4779    /// Always `bypass`.
4780    pub control: SandboxControl,
4781    /// Bounded class of the access whose refusal raised this escalation. Omitted for a pre-execution bypass, such as a detached command that cannot be sandboxed and therefore resolves no denial.
4782    #[serde(skip_serializing_if = "Option::is_none")]
4783    pub denial_class: Option<SandboxDenialClass>,
4784    /// Resource whose refusal raised this escalation. Populated only when content capture is enabled.
4785    #[serde(skip_serializing_if = "Option::is_none")]
4786    pub denied_resource: Option<String>,
4787    /// Runtime subsystem the bypass applies to
4788    pub enforcement_point: SandboxEnforcementPoint,
4789    /// Sandbox decision variant discriminator.
4790    pub kind: SandboxDecisionDataBypassDecidedKind,
4791    /// Whether the bypass was granted: `approved` or `declined`. `declined` also covers the cases where nobody answered, since the sandboxed denial stands either way.
4792    pub outcome: SandboxOutcome,
4793    /// Host operating-system family
4794    pub platform: SandboxPlatform,
4795    /// Executable image associated with the denial that raised this escalation, normalized to a basename. Populated only when content capture is enabled.
4796    #[serde(skip_serializing_if = "Option::is_none")]
4797    pub process_name: Option<String>,
4798    /// Where the request originated. Orthogonal to `outcome`.
4799    pub source: SandboxBypassSource,
4800    /// Tool call the decision belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4801    #[serde(skip_serializing_if = "Option::is_none")]
4802    pub tool_call_id: Option<String>,
4803}
4804
4805/// A permissive retry was resolved. Distinct from `bypass_decided` because this rung never requests a run outside the process sandbox: it relaxes the process container for one run while the sandbox, and with it the network policy, stays attached. Reported for both outcomes, so an escalation the user declined still leaves evidence that the runtime asked and that the sandboxed denial stood.
4806#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4807#[serde(rename_all = "camelCase")]
4808pub struct SandboxDecisionDataPermissiveRetryDecided {
4809    /// Command the verdict governs. Populated only when content capture is enabled.
4810    #[serde(skip_serializing_if = "Option::is_none")]
4811    pub command: Option<String>,
4812    /// How strong the evidence behind `denialClass` was. Present exactly when `denialClass` is.
4813    #[serde(skip_serializing_if = "Option::is_none")]
4814    pub confidence: Option<SandboxDenialConfidence>,
4815    /// Always `process`: the process container is what this rung relaxes, and the network control is deliberately untouched.
4816    pub control: SandboxControl,
4817    /// Bounded class of the access whose refusal raised this escalation.
4818    #[serde(skip_serializing_if = "Option::is_none")]
4819    pub denial_class: Option<SandboxDenialClass>,
4820    /// Resource whose refusal raised this escalation. Populated only when content capture is enabled.
4821    #[serde(skip_serializing_if = "Option::is_none")]
4822    pub denied_resource: Option<String>,
4823    /// Runtime subsystem the retry applies to
4824    pub enforcement_point: SandboxEnforcementPoint,
4825    /// Sandbox decision variant discriminator.
4826    pub kind: SandboxDecisionDataPermissiveRetryDecidedKind,
4827    /// Whether the permissive retry was granted: `approved` or `declined`. `declined` also covers the cases where nobody answered, since the sandboxed denial stands either way.
4828    pub outcome: SandboxOutcome,
4829    /// Host operating-system family
4830    pub platform: SandboxPlatform,
4831    /// Executable image associated with the denial that raised this escalation, normalized to a basename. Populated only when content capture is enabled.
4832    #[serde(skip_serializing_if = "Option::is_none")]
4833    pub process_name: Option<String>,
4834    /// Where the request originated. Orthogonal to `outcome`.
4835    pub source: SandboxBypassSource,
4836    /// Tool call the decision belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4837    #[serde(skip_serializing_if = "Option::is_none")]
4838    pub tool_call_id: Option<String>,
4839}
4840
4841/// An approved permissive retry finished. `succeeded` means the retry exited successfully without another correlated sandbox denial; `failed` means it failed or remained blocked and may therefore be followed by a full bypass.
4842#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4843#[serde(rename_all = "camelCase")]
4844pub struct SandboxDecisionDataPermissiveRetryCompleted {
4845    /// Command the retry executed. Populated only when content capture is enabled.
4846    #[serde(skip_serializing_if = "Option::is_none")]
4847    pub command: Option<String>,
4848    /// How strong the evidence behind `denialClass` was.
4849    #[serde(skip_serializing_if = "Option::is_none")]
4850    pub confidence: Option<SandboxDenialConfidence>,
4851    /// Always `process`: the retry changes process-container enforcement while leaving network policy attached.
4852    pub control: SandboxControl,
4853    /// Bounded class of the access whose refusal raised the permissive retry.
4854    #[serde(skip_serializing_if = "Option::is_none")]
4855    pub denial_class: Option<SandboxDenialClass>,
4856    /// Resource whose refusal raised the retry. Populated only when content capture is enabled.
4857    #[serde(skip_serializing_if = "Option::is_none")]
4858    pub denied_resource: Option<String>,
4859    /// Runtime subsystem that ran the retry
4860    pub enforcement_point: SandboxEnforcementPoint,
4861    /// Sandbox decision variant discriminator.
4862    pub kind: SandboxDecisionDataPermissiveRetryCompletedKind,
4863    /// Whether the permissive retry completed successfully: `succeeded` or `failed`.
4864    pub outcome: SandboxOutcome,
4865    /// Host operating-system family
4866    pub platform: SandboxPlatform,
4867    /// Executable image associated with the denial that raised the retry, normalized to a basename. Populated only when content capture is enabled.
4868    #[serde(skip_serializing_if = "Option::is_none")]
4869    pub process_name: Option<String>,
4870    /// Tool call the completion belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4871    #[serde(skip_serializing_if = "Option::is_none")]
4872    pub tool_call_id: Option<String>,
4873}
4874
4875/// Session event "subagent.started". Sub-agent startup details including parent tool call and agent information
4876#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4877#[serde(rename_all = "camelCase")]
4878pub struct SubagentStartedData {
4879    /// Description of what the sub-agent does
4880    pub agent_description: String,
4881    /// Human-readable display name of the sub-agent
4882    pub agent_display_name: String,
4883    /// Internal name of the sub-agent
4884    pub agent_name: String,
4885    /// Type of the sub-agent selected at spawn time.
4886    #[serde(skip_serializing_if = "Option::is_none")]
4887    pub agent_type: Option<String>,
4888    /// Whether the sub-agent runs synchronously or in the background.
4889    #[serde(skip_serializing_if = "Option::is_none")]
4890    pub execution_mode: Option<String>,
4891    /// Root id of the factory run that spawned this sub-agent, when it was spawned by one.
4892    #[serde(skip_serializing_if = "Option::is_none")]
4893    pub factory_run_id: Option<String>,
4894    /// Model the sub-agent will run with, when known at start.
4895    #[serde(skip_serializing_if = "Option::is_none")]
4896    pub model: Option<String>,
4897    /// Authority or runtime mechanism responsible for sub-agent model selection, when known at start.
4898    #[serde(skip_serializing_if = "Option::is_none")]
4899    pub model_selection_source: Option<SubagentModelSelectionSource>,
4900    /// Task-registry ID of the spawning sub-agent. Absent when the root session spawned this child.
4901    #[serde(skip_serializing_if = "Option::is_none")]
4902    pub parent_id: Option<String>,
4903    /// Whether this sub-agent can be resumed. Currently always false.
4904    #[serde(skip_serializing_if = "Option::is_none")]
4905    pub resumable: Option<bool>,
4906    /// Where the model input for this sub-agent came from. Present when the task planner resolved the launch (the task tool and factory agents); absent for sub-agents created through other runtime paths.
4907    #[serde(skip_serializing_if = "Option::is_none")]
4908    pub task_model_source: Option<SubagentTaskModelSource>,
4909    /// Tool call ID of the parent tool invocation that spawned this sub-agent
4910    pub tool_call_id: String,
4911}
4912
4913/// Session event "subagent.configured". Resolved runtime configuration for a configured sub-agent
4914#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4915#[serde(rename_all = "camelCase")]
4916pub struct SubagentConfiguredData {
4917    /// Resolved context tier, when configured for the model
4918    #[serde(skip_serializing_if = "Option::is_none")]
4919    pub context_tier: Option<String>,
4920    /// Resolved model the sub-agent will run with
4921    pub model: String,
4922    /// Whether the sub-agent accepts follow-up turns
4923    pub multi_turn: bool,
4924    /// Resolved reasoning effort, when configured for the model
4925    #[serde(skip_serializing_if = "Option::is_none")]
4926    pub reasoning_effort: Option<String>,
4927}
4928
4929/// Session event "subagent.completed". Sub-agent completion details for successful execution
4930#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4931#[serde(rename_all = "camelCase")]
4932pub struct SubagentCompletedData {
4933    /// Human-readable display name of the sub-agent
4934    pub agent_display_name: String,
4935    /// Internal name of the sub-agent
4936    pub agent_name: String,
4937    /// 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.
4938    #[serde(skip_serializing_if = "Option::is_none")]
4939    pub cancelled: Option<bool>,
4940    /// Whether the first model actually dispatched matched the user's configured preference
4941    #[serde(skip_serializing_if = "Option::is_none")]
4942    pub configured_model_matches_actual: Option<bool>,
4943    /// Concrete model the user configured for this sub-agent via `/subagents`, when present
4944    #[serde(skip_serializing_if = "Option::is_none")]
4945    pub configured_model_preference: Option<String>,
4946    /// Wall-clock duration of the sub-agent execution in milliseconds
4947    #[serde(skip_serializing_if = "Option::is_none")]
4948    pub duration_ms: Option<i64>,
4949    /// Whether the explicit task-call model matched the user's configured preference
4950    #[serde(skip_serializing_if = "Option::is_none")]
4951    pub explicit_model_matches_preference: Option<bool>,
4952    /// Explicit model supplied by the parent agent on the task call, when present
4953    #[serde(skip_serializing_if = "Option::is_none")]
4954    pub explicit_model_override: Option<String>,
4955    /// First model for which the sub-agent started an inference request, when one was dispatched
4956    #[serde(skip_serializing_if = "Option::is_none")]
4957    pub first_dispatched_model: Option<String>,
4958    /// Model used by the sub-agent
4959    #[serde(skip_serializing_if = "Option::is_none")]
4960    pub model: Option<String>,
4961    /// Why an explicit task-call model did not become the effective model
4962    #[serde(skip_serializing_if = "Option::is_none")]
4963    pub model_override_reason: Option<String>,
4964    /// Authority or runtime mechanism responsible for sub-agent model selection
4965    #[serde(skip_serializing_if = "Option::is_none")]
4966    pub model_selection_source: Option<SubagentModelSelectionSource>,
4967    /// Tool call ID of the parent tool invocation that spawned this sub-agent
4968    pub tool_call_id: String,
4969    /// Total tokens (input + output) consumed by the sub-agent
4970    #[serde(skip_serializing_if = "Option::is_none")]
4971    pub total_tokens: Option<i64>,
4972    /// Total number of tool calls made by the sub-agent
4973    #[serde(skip_serializing_if = "Option::is_none")]
4974    pub total_tool_calls: Option<i64>,
4975}
4976
4977/// Session event "subagent.failed". Sub-agent failure details including error message and agent information
4978#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4979#[serde(rename_all = "camelCase")]
4980pub struct SubagentFailedData {
4981    /// Human-readable display name of the sub-agent
4982    pub agent_display_name: String,
4983    /// Internal name of the sub-agent
4984    pub agent_name: String,
4985    /// Whether the first model actually dispatched matched the user's configured preference
4986    #[serde(skip_serializing_if = "Option::is_none")]
4987    pub configured_model_matches_actual: Option<bool>,
4988    /// Concrete model the user configured for this sub-agent via `/subagents`, when present
4989    #[serde(skip_serializing_if = "Option::is_none")]
4990    pub configured_model_preference: Option<String>,
4991    /// Wall-clock duration of the sub-agent execution in milliseconds
4992    #[serde(skip_serializing_if = "Option::is_none")]
4993    pub duration_ms: Option<i64>,
4994    /// Error message describing why the sub-agent failed
4995    pub error: String,
4996    /// Whether the explicit task-call model matched the user's configured preference
4997    #[serde(skip_serializing_if = "Option::is_none")]
4998    pub explicit_model_matches_preference: Option<bool>,
4999    /// Explicit model supplied by the parent agent on the task call, when present
5000    #[serde(skip_serializing_if = "Option::is_none")]
5001    pub explicit_model_override: Option<String>,
5002    /// First model for which the sub-agent started an inference request, when one was dispatched
5003    #[serde(skip_serializing_if = "Option::is_none")]
5004    pub first_dispatched_model: Option<String>,
5005    /// Model selected for the sub-agent, when known
5006    #[serde(skip_serializing_if = "Option::is_none")]
5007    pub model: Option<String>,
5008    /// Why an explicit task-call model did not become the effective model
5009    #[serde(skip_serializing_if = "Option::is_none")]
5010    pub model_override_reason: Option<String>,
5011    /// Authority or runtime mechanism responsible for sub-agent model selection
5012    #[serde(skip_serializing_if = "Option::is_none")]
5013    pub model_selection_source: Option<SubagentModelSelectionSource>,
5014    /// Tool call ID of the parent tool invocation that spawned this sub-agent
5015    pub tool_call_id: String,
5016    /// Total tokens (input + output) consumed before the sub-agent failed
5017    #[serde(skip_serializing_if = "Option::is_none")]
5018    pub total_tokens: Option<i64>,
5019    /// Total number of tool calls made before the sub-agent failed
5020    #[serde(skip_serializing_if = "Option::is_none")]
5021    pub total_tool_calls: Option<i64>,
5022}
5023
5024/// Session event "subagent.selected". Custom agent selection details including name and available tools
5025#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5026#[serde(rename_all = "camelCase")]
5027pub struct SubagentSelectedData {
5028    /// Human-readable display name of the selected custom agent
5029    pub agent_display_name: String,
5030    /// Internal name of the selected custom agent
5031    pub agent_name: String,
5032    /// List of tool names available to this agent, or null for all tools
5033    pub tools: Option<Vec<String>>,
5034}
5035
5036/// Session event "subagent.deselected". Empty payload; the event signals that the custom agent was deselected, returning to the default agent
5037#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5038#[serde(rename_all = "camelCase")]
5039pub struct SubagentDeselectedData {}
5040
5041/// Session event "hook.start". Hook invocation start details including type and input data
5042#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5043#[serde(rename_all = "camelCase")]
5044pub struct HookStartData {
5045    /// Unique identifier for this hook invocation
5046    pub hook_invocation_id: String,
5047    /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
5048    pub hook_type: String,
5049    /// Input data passed to the hook. For postToolUse hooks the retained copy served by session.eventLog.read (and by a resumed session) drops the tool result's inline `contents`/`uiResource`/`skillInvocation` and replaces duplicated text result fields with a `[copilot:elided ...]` marker; the live subscription stream still delivers the full value. Canonical tool output remains in the adjacent tool.execution_complete event, while an invoked skill's authoritative body remains in its skill invocation event.
5050    #[serde(skip_serializing_if = "Option::is_none")]
5051    pub input: Option<serde_json::Value>,
5052    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
5053    #[serde(skip_serializing_if = "Option::is_none")]
5054    pub parent_tool_call_id: Option<String>,
5055}
5056
5057/// Error details when the hook failed
5058#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5059#[serde(rename_all = "camelCase")]
5060pub struct HookEndError {
5061    /// Human-readable error message
5062    pub message: String,
5063    /// Source label of the hook that errored (e.g. the plugin it was loaded from), when known
5064    #[serde(skip_serializing_if = "Option::is_none")]
5065    pub source: Option<String>,
5066    /// Error stack trace, when available
5067    #[serde(skip_serializing_if = "Option::is_none")]
5068    pub stack: Option<String>,
5069}
5070
5071/// Session event "hook.end". Hook invocation completion details including output, success status, and error information
5072#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5073#[serde(rename_all = "camelCase")]
5074pub struct HookEndData {
5075    /// Error details when the hook failed
5076    #[serde(skip_serializing_if = "Option::is_none")]
5077    pub error: Option<HookEndError>,
5078    /// Identifier matching the corresponding hook.start event
5079    pub hook_invocation_id: String,
5080    /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
5081    pub hook_type: String,
5082    /// Output data produced by the hook. Durable and resumed postToolUse receipts may omit messages owned by a successful skill invocation and replace an unchanged skill sessionLog copy with an elision marker; hook-modified or re-sourced values are preserved, and the authoritative body remains in the skill invocation event.
5083    #[serde(skip_serializing_if = "Option::is_none")]
5084    pub output: Option<serde_json::Value>,
5085    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
5086    #[serde(skip_serializing_if = "Option::is_none")]
5087    pub parent_tool_call_id: Option<String>,
5088    /// Whether the hook completed successfully
5089    pub success: bool,
5090}
5091
5092/// Session event "hook.progress". Ephemeral progress update from a running hook process
5093#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5094#[serde(rename_all = "camelCase")]
5095pub struct HookProgressData {
5096    /// Human-readable progress message from the hook process
5097    pub message: String,
5098    /// When true, this status message replaces the previous temporary one instead of accumulating
5099    #[serde(skip_serializing_if = "Option::is_none")]
5100    pub temporary: Option<bool>,
5101}
5102
5103/// Session event "session.binary_asset". Canonical bytes for a content-addressed binary asset shared by reference across events
5104#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5105#[serde(rename_all = "camelCase")]
5106pub struct SessionBinaryAssetData {
5107    /// Content-addressed id for this binary asset (e.g. "sha256:...").
5108    pub asset_id: String,
5109    /// Decoded byte length of the binary asset
5110    pub byte_length: i64,
5111    /// Base64-encoded binary data
5112    pub data: String,
5113    /// Human-readable description of the binary data
5114    #[serde(skip_serializing_if = "Option::is_none")]
5115    pub description: Option<String>,
5116    /// Optional metadata from the producing tool.
5117    #[serde(skip_serializing_if = "Option::is_none")]
5118    pub metadata: Option<HashMap<String, serde_json::Value>>,
5119    /// MIME type of the binary asset
5120    pub mime_type: String,
5121    /// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
5122    pub r#type: BinaryAssetType,
5123}
5124
5125/// One persisted structured system-message block and its cache intent
5126#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5127#[serde(rename_all = "camelCase")]
5128pub struct SystemMessageContentBlock {
5129    /// Explicit prompt-cache intent. True places a breakpoint after this block, false suppresses one, and absence preserves the provider's legacy default.
5130    #[serde(skip_serializing_if = "Option::is_none")]
5131    pub cache_breakpoint: Option<bool>,
5132    /// Text content for this system-message block.
5133    pub content: String,
5134    /// Diagnostic classification indicating whether the block is stable across equivalent sessions.
5135    #[serde(skip_serializing_if = "Option::is_none")]
5136    pub is_static: Option<bool>,
5137}
5138
5139/// Metadata about the prompt template and its construction
5140#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5141#[serde(rename_all = "camelCase")]
5142pub struct SystemMessageMetadata {
5143    /// Version identifier of the prompt template or structured prompt layout used
5144    #[serde(skip_serializing_if = "Option::is_none")]
5145    pub prompt_version: Option<String>,
5146    /// Template variables used when constructing the prompt
5147    #[serde(skip_serializing_if = "Option::is_none")]
5148    pub variables: Option<HashMap<String, serde_json::Value>>,
5149}
5150
5151/// Session event "system.message". System/developer instruction content with role and optional template metadata
5152#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5153#[serde(rename_all = "camelCase")]
5154pub struct SystemMessageData {
5155    /// The system or developer prompt text sent as model input
5156    pub content: String,
5157    /// Optional ordered structured blocks corresponding to content, retained for prompt-cache layout restoration.
5158    #[serde(skip_serializing_if = "Option::is_none")]
5159    pub content_blocks: Option<Vec<SystemMessageContentBlock>>,
5160    /// Logical interaction identifier for the model run receiving this prompt
5161    #[serde(skip_serializing_if = "Option::is_none")]
5162    pub interaction_id: Option<String>,
5163    /// Metadata about the prompt template and its construction
5164    #[serde(skip_serializing_if = "Option::is_none")]
5165    pub metadata: Option<SystemMessageMetadata>,
5166    /// Optional name identifier for the message source
5167    #[serde(skip_serializing_if = "Option::is_none")]
5168    pub name: Option<String>,
5169    /// Message role: "system" for system prompts, "developer" for developer-injected instructions
5170    pub role: SystemMessageRole,
5171}
5172
5173/// Session event "system.notification". System-generated notification for runtime events like background task completion
5174#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5175#[serde(rename_all = "camelCase")]
5176pub struct SystemNotificationData {
5177    /// The notification text, typically wrapped in `<system_notification>` XML tags
5178    pub content: String,
5179    /// Structured metadata identifying what triggered this notification
5180    pub kind: serde_json::Value,
5181    /// Responses reasoning settings anchored before this model-facing message, for cache-stable history replay
5182    #[serde(skip_serializing_if = "Option::is_none")]
5183    pub responses_reasoning: Option<ResponsesReasoning>,
5184}
5185
5186/// A parsed command identifier in a shell permission request, including whether it is read-only.
5187#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5188#[serde(rename_all = "camelCase")]
5189pub struct PermissionRequestShellCommand {
5190    /// Command identifier (e.g., executable name)
5191    pub identifier: String,
5192    /// Whether this command is read-only (no side effects)
5193    pub read_only: bool,
5194}
5195
5196/// A parsed shell command segment used for argument-aware managed policy matching.
5197#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5198#[serde(rename_all = "camelCase")]
5199pub struct PermissionRequestShellCommandSegment {
5200    /// Full text of this command segment, including arguments
5201    pub full_command_text: String,
5202    /// Command identifier (e.g., executable name)
5203    pub identifier: String,
5204}
5205
5206/// A URL that may be accessed by a command in a shell permission request.
5207#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5208#[serde(rename_all = "camelCase")]
5209pub struct PermissionRequestShellPossibleUrl {
5210    /// URL that may be accessed by the command
5211    pub url: String,
5212}
5213
5214/// Shell command permission request
5215#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5216#[serde(rename_all = "camelCase")]
5217pub struct PermissionRequestShell {
5218    /// Whether the UI can offer session-wide approval for this command pattern
5219    pub can_offer_session_approval: bool,
5220    /// Parsed command identifiers found in the command text
5221    pub commands: Vec<PermissionRequestShellCommand>,
5222    /// Parsed command segments, including arguments, used for managed policy matching
5223    #[serde(skip_serializing_if = "Option::is_none")]
5224    pub command_segments: Option<Vec<PermissionRequestShellCommandSegment>>,
5225    /// The complete shell command text to be executed
5226    pub full_command_text: String,
5227    /// Whether the command includes a file write redirection (e.g., > or >>)
5228    pub has_write_file_redirection: bool,
5229    /// Human-readable description of what the command intends to do
5230    pub intention: String,
5231    /// Permission kind discriminator
5232    pub kind: PermissionRequestShellKind,
5233    /// Whether managed policy requires a human response and forbids host auto-approval
5234    #[serde(skip_serializing_if = "Option::is_none")]
5235    pub managed_approval_required: Option<bool>,
5236    /// File paths that may be read or written by the command
5237    pub possible_paths: Vec<String>,
5238    /// URLs that may be accessed by the command
5239    pub possible_urls: Vec<PermissionRequestShellPossibleUrl>,
5240    /// True when the tool is asking to run this command outside the sandbox, either because the command detaches and cannot be sandboxed at all, or because a sandboxed run looked blocked (host opted in via sandbox.allowBypass). The model cannot ask for this; only the tool raises it. 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.
5241    #[serde(skip_serializing_if = "Option::is_none")]
5242    pub request_sandbox_bypass: Option<bool>,
5243    /// What the tool tells the user about the bypass on offer: which policy rule blocked the call, or why it cannot be sandboxed. Only meaningful when requestSandboxBypass is true.
5244    #[serde(skip_serializing_if = "Option::is_none")]
5245    pub request_sandbox_bypass_reason: Option<String>,
5246    /// True when the requested escalation is a permissive retry rather than a full bypass: the command re-runs inside the sandbox with its file and process restrictions recording instead of blocking, while the network policy stays enforced. Always accompanied by requestSandboxBypass, so hosts that do not recognize this field still treat the request as the escalation it is. Hosts that do recognize it must not describe the command as running outside the sandbox, which would overstate the privilege being granted.
5247    #[serde(skip_serializing_if = "Option::is_none")]
5248    pub request_sandbox_permissive: Option<bool>,
5249    /// Runtime-resolved canonical object each possiblePaths entry names, keyed by the requested spelling, used for authorization identity checks. Internal and experimental; clients should continue to display possiblePaths.
5250    ///
5251    /// <div class="warning">
5252    ///
5253    /// **Experimental.** This type is part of an experimental wire-protocol surface
5254    /// and may change or be removed in future SDK or CLI releases.
5255    ///
5256    /// </div>
5257    #[serde(skip_serializing_if = "Option::is_none")]
5258    pub resolved_paths: Option<HashMap<String, String>>,
5259    /// Runtime-resolved canonical working directory the command runs in, used for authorization identity checks. Internal and experimental; clients should not display it.
5260    ///
5261    /// <div class="warning">
5262    ///
5263    /// **Experimental.** This type is part of an experimental wire-protocol surface
5264    /// and may change or be removed in future SDK or CLI releases.
5265    ///
5266    /// </div>
5267    #[serde(skip_serializing_if = "Option::is_none")]
5268    pub resolved_working_directory: Option<String>,
5269    /// Tool call ID that triggered this permission request
5270    #[serde(skip_serializing_if = "Option::is_none")]
5271    pub tool_call_id: Option<String>,
5272    /// Optional warning message about risks of running this command
5273    #[serde(skip_serializing_if = "Option::is_none")]
5274    pub warning: Option<String>,
5275}
5276
5277/// File write permission request
5278#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5279#[serde(rename_all = "camelCase")]
5280pub struct PermissionRequestWrite {
5281    /// Whether the UI can offer session-wide approval for file write operations
5282    pub can_offer_session_approval: bool,
5283    /// Unified diff showing the proposed changes
5284    pub diff: String,
5285    /// Path of the file being written to
5286    pub file_name: String,
5287    /// Human-readable description of the intended file change
5288    pub intention: String,
5289    /// Permission kind discriminator
5290    pub kind: PermissionRequestWriteKind,
5291    /// Whether managed policy requires a human response and forbids host auto-approval
5292    #[serde(skip_serializing_if = "Option::is_none")]
5293    pub managed_approval_required: Option<bool>,
5294    /// Complete new file contents for newly created files
5295    #[serde(skip_serializing_if = "Option::is_none")]
5296    pub new_file_contents: Option<String>,
5297    /// 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.
5298    #[serde(skip_serializing_if = "Option::is_none")]
5299    pub request_sandbox_bypass: Option<bool>,
5300    /// Justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
5301    #[serde(skip_serializing_if = "Option::is_none")]
5302    pub request_sandbox_bypass_reason: Option<String>,
5303    /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display fileName.
5304    ///
5305    /// <div class="warning">
5306    ///
5307    /// **Experimental.** This type is part of an experimental wire-protocol surface
5308    /// and may change or be removed in future SDK or CLI releases.
5309    ///
5310    /// </div>
5311    #[serde(skip_serializing_if = "Option::is_none")]
5312    pub resolved_path: Option<String>,
5313    /// Tool call ID that triggered this permission request
5314    #[serde(skip_serializing_if = "Option::is_none")]
5315    pub tool_call_id: Option<String>,
5316}
5317
5318/// File or directory read permission request
5319#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5320#[serde(rename_all = "camelCase")]
5321pub struct PermissionRequestRead {
5322    /// Human-readable description of why the file is being read
5323    pub intention: String,
5324    /// Permission kind discriminator
5325    pub kind: PermissionRequestReadKind,
5326    /// Whether managed policy requires a human response and forbids host auto-approval
5327    #[serde(skip_serializing_if = "Option::is_none")]
5328    pub managed_approval_required: Option<bool>,
5329    /// Path of the file or directory being read
5330    pub path: String,
5331    /// True when the tool is asking to re-run this search outside the sandbox, after a sandboxed run looked blocked (host opted in via sandbox.allowBypass). The model cannot ask for this; only the tool raises it. 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.
5332    #[serde(skip_serializing_if = "Option::is_none")]
5333    pub request_sandbox_bypass: Option<bool>,
5334    /// What the tool tells the user about the bypass on offer: which policy rule blocked the call, or why it cannot be sandboxed. Only meaningful when requestSandboxBypass is true.
5335    #[serde(skip_serializing_if = "Option::is_none")]
5336    pub request_sandbox_bypass_reason: Option<String>,
5337    /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display path.
5338    ///
5339    /// <div class="warning">
5340    ///
5341    /// **Experimental.** This type is part of an experimental wire-protocol surface
5342    /// and may change or be removed in future SDK or CLI releases.
5343    ///
5344    /// </div>
5345    #[serde(skip_serializing_if = "Option::is_none")]
5346    pub resolved_path: Option<String>,
5347    /// Tool call ID that triggered this permission request
5348    #[serde(skip_serializing_if = "Option::is_none")]
5349    pub tool_call_id: Option<String>,
5350}
5351
5352/// MCP tool invocation permission request
5353#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5354#[serde(rename_all = "camelCase")]
5355pub struct PermissionRequestMcp {
5356    /// Arguments to pass to the MCP tool
5357    #[serde(skip_serializing_if = "Option::is_none")]
5358    pub args: Option<serde_json::Value>,
5359    /// Permission kind discriminator
5360    pub kind: PermissionRequestMcpKind,
5361    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5362    #[serde(skip_serializing_if = "Option::is_none")]
5363    pub managed_approval_required: Option<bool>,
5364    /// Advisory runtime permission recommendation. The SDK host remains responsible for deciding the request and may reject it.
5365    ///
5366    /// <div class="warning">
5367    ///
5368    /// **Experimental.** This type is part of an experimental wire-protocol surface
5369    /// and may change or be removed in future SDK or CLI releases.
5370    ///
5371    /// </div>
5372    #[serde(skip_serializing_if = "Option::is_none")]
5373    pub permission_recommendation: Option<PermissionRecommendation>,
5374    /// Whether this MCP tool is read-only (no side effects)
5375    pub read_only: bool,
5376    /// Name of the MCP server providing the tool
5377    pub server_name: String,
5378    /// Tool call ID that triggered this permission request
5379    #[serde(skip_serializing_if = "Option::is_none")]
5380    pub tool_call_id: Option<String>,
5381    /// Internal name of the MCP tool
5382    pub tool_name: String,
5383    /// Human-readable title of the MCP tool
5384    pub tool_title: String,
5385}
5386
5387/// URL access permission request
5388#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5389#[serde(rename_all = "camelCase")]
5390pub struct PermissionRequestUrl {
5391    /// Human-readable description of why the URL is being accessed
5392    pub intention: String,
5393    /// Permission kind discriminator
5394    pub kind: PermissionRequestUrlKind,
5395    /// Whether managed policy requires a human response and forbids host auto-approval
5396    #[serde(skip_serializing_if = "Option::is_none")]
5397    pub managed_approval_required: Option<bool>,
5398    /// Immediately preceding URL when this request is for a redirect target
5399    #[serde(skip_serializing_if = "Option::is_none")]
5400    pub redirected_from: Option<String>,
5401    /// True when the tool is asking to run this URL fetch outside the sandbox, after the network policy denied the approved URL or the sandbox proxy could not reach it (host opted in via sandbox.allowBypass). The model cannot ask for this; only the tool raises it. 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.
5402    #[serde(skip_serializing_if = "Option::is_none")]
5403    pub request_sandbox_bypass: Option<bool>,
5404    /// What the tool tells the user about the bypass on offer: which policy rule blocked the call, or why it cannot be sandboxed. Only meaningful when requestSandboxBypass is true.
5405    #[serde(skip_serializing_if = "Option::is_none")]
5406    pub request_sandbox_bypass_reason: Option<String>,
5407    /// Tool call ID that triggered this permission request
5408    #[serde(skip_serializing_if = "Option::is_none")]
5409    pub tool_call_id: Option<String>,
5410    /// URL to be fetched
5411    pub url: String,
5412}
5413
5414/// Bounded runtime attribution, independent of free-text rationale. Telemetry revalidates this vocabulary before standard collection.
5415#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5416#[serde(rename_all = "camelCase")]
5417pub struct PermissionApprovalEvaluation {
5418    /// Stage that produced this attribution.
5419    pub evaluation_stage: PermissionApprovalEvaluationEvaluationStage,
5420    /// Whether the request invoked the judge interface. A cached recommendation retains the original attempt fact. Omitted means unknown, including inherited outcomes.
5421    #[serde(skip_serializing_if = "Option::is_none")]
5422    pub judge_attempted: Option<bool>,
5423    /// Status of the local judge interface, not proof of a model network call.
5424    pub judge_status: PermissionApprovalEvaluationJudgeStatus,
5425    /// Machine-readable runtime gate reason, never a command, path or human rationale.
5426    pub reason_code: PermissionApprovalEvaluationReasonCode,
5427}
5428
5429/// 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.
5430///
5431/// <div class="warning">
5432///
5433/// **Experimental.** This type is part of an experimental wire-protocol surface
5434/// and may change or be removed in future SDK or CLI releases.
5435///
5436/// </div>
5437#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5438#[serde(rename_all = "camelCase")]
5439pub struct PermissionAssistedApproval {
5440    /// Runtime reason and judge-call metadata. Absent on older events; missing metadata means unknown, not that the judge was skipped.
5441    #[serde(skip_serializing_if = "Option::is_none")]
5442    pub evaluation: Option<PermissionApprovalEvaluation>,
5443    /// Classified cause of an `error` recommendation. Absent for every other recommendation.
5444    #[serde(skip_serializing_if = "Option::is_none")]
5445    pub failure_reason: Option<AssistedApprovalJudgeFailureReason>,
5446    /// 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.
5447    #[serde(skip_serializing_if = "Option::is_none")]
5448    pub model: Option<String>,
5449    /// Human-readable reason for the judge's recommendation, when available.
5450    #[serde(skip_serializing_if = "Option::is_none")]
5451    pub reason: Option<String>,
5452    /// The assisted-approval safety judge's outcome for this request.
5453    pub recommendation: AssistedApprovalRecommendation,
5454}
5455
5456/// Memory operation permission request
5457#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5458#[serde(rename_all = "camelCase")]
5459pub struct PermissionRequestMemory {
5460    /// Whether this is a store or vote memory operation
5461    #[serde(skip_serializing_if = "Option::is_none")]
5462    pub action: Option<PermissionRequestMemoryAction>,
5463    /// Assisted-approval judge information for this request; present only in assisted mode.
5464    ///
5465    /// <div class="warning">
5466    ///
5467    /// **Experimental.** This type is part of an experimental wire-protocol surface
5468    /// and may change or be removed in future SDK or CLI releases.
5469    ///
5470    /// </div>
5471    #[serde(skip_serializing_if = "Option::is_none")]
5472    pub assisted_approval: Option<PermissionAssistedApproval>,
5473    /// Source references for the stored fact (store only)
5474    #[serde(skip_serializing_if = "Option::is_none")]
5475    pub citations: Option<String>,
5476    /// Vote direction (vote only)
5477    #[serde(skip_serializing_if = "Option::is_none")]
5478    pub direction: Option<PermissionRequestMemoryDirection>,
5479    /// The fact being stored or voted on
5480    pub fact: String,
5481    /// Permission kind discriminator
5482    pub kind: PermissionRequestMemoryKind,
5483    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5484    #[serde(skip_serializing_if = "Option::is_none")]
5485    pub managed_approval_required: Option<bool>,
5486    /// Reason for the vote (vote only)
5487    #[serde(skip_serializing_if = "Option::is_none")]
5488    pub reason: Option<String>,
5489    /// Repository name with owner associated with the stored memory (store only)
5490    #[serde(skip_serializing_if = "Option::is_none")]
5491    pub repo_nwo: Option<String>,
5492    /// Scope of the stored memory (store only)
5493    #[serde(skip_serializing_if = "Option::is_none")]
5494    pub scope: Option<PermissionRequestMemoryScope>,
5495    /// Topic or subject of the memory (store only)
5496    #[serde(skip_serializing_if = "Option::is_none")]
5497    pub subject: Option<String>,
5498    /// Tool call ID that triggered this permission request
5499    #[serde(skip_serializing_if = "Option::is_none")]
5500    pub tool_call_id: Option<String>,
5501}
5502
5503/// Custom tool invocation permission request
5504#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5505#[serde(rename_all = "camelCase")]
5506pub struct PermissionRequestCustomTool {
5507    /// Arguments to pass to the custom tool
5508    #[serde(skip_serializing_if = "Option::is_none")]
5509    pub args: Option<serde_json::Value>,
5510    /// Permission kind discriminator
5511    pub kind: PermissionRequestCustomToolKind,
5512    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5513    #[serde(skip_serializing_if = "Option::is_none")]
5514    pub managed_approval_required: Option<bool>,
5515    /// Whether the tool declared that permission may be skipped unless a deny rule matches
5516    #[serde(skip_serializing_if = "Option::is_none")]
5517    pub skip_permission: Option<bool>,
5518    /// Tool call ID that triggered this permission request
5519    #[serde(skip_serializing_if = "Option::is_none")]
5520    pub tool_call_id: Option<String>,
5521    /// Description of what the custom tool does
5522    pub tool_description: String,
5523    /// Name of the custom tool
5524    pub tool_name: String,
5525}
5526
5527/// Hook confirmation permission request
5528#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5529#[serde(rename_all = "camelCase")]
5530pub struct PermissionRequestHook {
5531    /// Optional message from the hook explaining why confirmation is needed
5532    #[serde(skip_serializing_if = "Option::is_none")]
5533    pub hook_message: Option<String>,
5534    /// Permission kind discriminator
5535    pub kind: PermissionRequestHookKind,
5536    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5537    #[serde(skip_serializing_if = "Option::is_none")]
5538    pub managed_approval_required: Option<bool>,
5539    /// Arguments of the tool call being gated
5540    #[serde(skip_serializing_if = "Option::is_none")]
5541    pub tool_args: Option<serde_json::Value>,
5542    /// Tool call ID that triggered this permission request
5543    #[serde(skip_serializing_if = "Option::is_none")]
5544    pub tool_call_id: Option<String>,
5545    /// Name of the tool the hook is gating
5546    pub tool_name: String,
5547}
5548
5549/// Extension management permission request
5550#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5551#[serde(rename_all = "camelCase")]
5552pub struct PermissionRequestExtensionManagement {
5553    /// Name of the extension being managed
5554    #[serde(skip_serializing_if = "Option::is_none")]
5555    pub extension_name: Option<String>,
5556    /// Permission kind discriminator
5557    pub kind: PermissionRequestExtensionManagementKind,
5558    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5559    #[serde(skip_serializing_if = "Option::is_none")]
5560    pub managed_approval_required: Option<bool>,
5561    /// The extension management operation (scaffold, reload)
5562    pub operation: String,
5563    /// Tool call ID that triggered this permission request
5564    #[serde(skip_serializing_if = "Option::is_none")]
5565    pub tool_call_id: Option<String>,
5566}
5567
5568/// A declared phase shown in a factory permission prompt.
5569#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5570#[serde(rename_all = "camelCase")]
5571pub struct FactoryPermissionPhase {
5572    /// Optional phase detail
5573    #[serde(skip_serializing_if = "Option::is_none")]
5574    pub detail: Option<String>,
5575    /// Phase title
5576    pub title: String,
5577}
5578
5579/// Factory run or authoring permission request
5580#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5581#[serde(rename_all = "camelCase")]
5582pub struct PermissionRequestFactory {
5583    /// Canonical key used for scoped factory approvals
5584    pub approval_key: String,
5585    /// Whether this factory is eligible for persistent approval
5586    pub can_persist_approval: bool,
5587    /// Factory-declared AI-credit limit before any run/resume caller override is applied.
5588    #[serde(skip_serializing_if = "Option::is_none")]
5589    pub declared_max_ai_credits: Option<f64>,
5590    /// Factory-declared concurrent-subagent limit before any run/resume caller override is applied.
5591    #[serde(skip_serializing_if = "Option::is_none")]
5592    pub declared_max_concurrent_subagents: Option<i64>,
5593    /// Factory-declared total-subagent limit before any run/resume caller override is applied.
5594    #[serde(skip_serializing_if = "Option::is_none")]
5595    pub declared_max_total_subagents: Option<i64>,
5596    /// Factory-declared active-time limit in seconds before any run/resume caller override is applied.
5597    #[serde(skip_serializing_if = "Option::is_none")]
5598    pub declared_timeout_seconds: Option<f64>,
5599    /// Factory description
5600    pub description: String,
5601    /// Permission kind discriminator
5602    pub kind: PermissionRequestFactoryKind,
5603    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5604    #[serde(skip_serializing_if = "Option::is_none")]
5605    pub managed_approval_required: Option<bool>,
5606    /// Effective AI-credit limit; omitted means unlimited
5607    #[serde(skip_serializing_if = "Option::is_none")]
5608    pub max_ai_credits: Option<f64>,
5609    /// Effective concurrent-subagent limit; omitted means unlimited
5610    #[serde(skip_serializing_if = "Option::is_none")]
5611    pub max_concurrent_subagents: Option<i64>,
5612    /// Effective total-subagent limit; omitted means unlimited
5613    #[serde(skip_serializing_if = "Option::is_none")]
5614    pub max_total_subagents: Option<i64>,
5615    /// Factory name
5616    pub name: String,
5617    /// Factory operation, either run or author
5618    pub operation: FactoryPermissionOperation,
5619    /// Declared factory phases
5620    pub phases: Vec<FactoryPermissionPhase>,
5621    /// Effective active-time limit in seconds; omitted means unlimited
5622    #[serde(skip_serializing_if = "Option::is_none")]
5623    pub timeout_seconds: Option<f64>,
5624    /// Tool call ID that triggered this permission request
5625    #[serde(skip_serializing_if = "Option::is_none")]
5626    pub tool_call_id: Option<String>,
5627}
5628
5629/// Extension permission access request
5630#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5631#[serde(rename_all = "camelCase")]
5632pub struct PermissionRequestExtensionPermissionAccess {
5633    /// Capabilities the extension is requesting
5634    pub capabilities: Vec<String>,
5635    /// Name of the extension requesting permission access
5636    pub extension_name: String,
5637    /// Permission kind discriminator
5638    pub kind: PermissionRequestExtensionPermissionAccessKind,
5639    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5640    #[serde(skip_serializing_if = "Option::is_none")]
5641    pub managed_approval_required: Option<bool>,
5642    /// Tool call ID that triggered this permission request
5643    #[serde(skip_serializing_if = "Option::is_none")]
5644    pub tool_call_id: Option<String>,
5645}
5646
5647/// Extension sensitive environment variable access request
5648#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5649#[serde(rename_all = "camelCase")]
5650pub struct PermissionRequestExtensionEnvAccess {
5651    /// Names of the sensitive environment variables the extension is requesting. Values never appear here.
5652    pub environment_variables: Vec<String>,
5653    /// Name of the extension requesting environment variable access
5654    pub extension_name: String,
5655    /// Permission kind discriminator
5656    pub kind: PermissionRequestExtensionEnvAccessKind,
5657    /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5658    #[serde(skip_serializing_if = "Option::is_none")]
5659    pub managed_approval_required: Option<bool>,
5660    /// Tool call ID that triggered this permission request
5661    #[serde(skip_serializing_if = "Option::is_none")]
5662    pub tool_call_id: Option<String>,
5663}
5664
5665/// Shell command permission prompt
5666#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5667#[serde(rename_all = "camelCase")]
5668pub struct PermissionPromptRequestCommands {
5669    /// Assisted-approval judge information for this request; present only in assisted mode.
5670    ///
5671    /// <div class="warning">
5672    ///
5673    /// **Experimental.** This type is part of an experimental wire-protocol surface
5674    /// and may change or be removed in future SDK or CLI releases.
5675    ///
5676    /// </div>
5677    #[serde(skip_serializing_if = "Option::is_none")]
5678    pub assisted_approval: Option<PermissionAssistedApproval>,
5679    /// Whether the UI can offer session-wide approval for this command pattern
5680    pub can_offer_session_approval: bool,
5681    /// Command identifiers covered by this approval prompt
5682    pub command_identifiers: Vec<String>,
5683    /// The complete shell command text to be executed
5684    pub full_command_text: String,
5685    /// Human-readable description of what the command intends to do
5686    pub intention: String,
5687    /// Prompt kind discriminator
5688    pub kind: PermissionPromptRequestCommandsKind,
5689    /// Whether managed policy requires a human response and forbids host auto-approval
5690    #[serde(skip_serializing_if = "Option::is_none")]
5691    pub managed_approval_required: Option<bool>,
5692    /// True when the shell command is requesting sandbox escalation. This is a request, not a grant.
5693    #[serde(skip_serializing_if = "Option::is_none")]
5694    pub request_sandbox_bypass: Option<bool>,
5695    /// Reason for the sandbox escalation request.
5696    #[serde(skip_serializing_if = "Option::is_none")]
5697    pub request_sandbox_bypass_reason: Option<String>,
5698    /// True when the escalation is a permissive retry that keeps the sandbox and network policy attached while recording file and process accesses instead of blocking them.
5699    #[serde(skip_serializing_if = "Option::is_none")]
5700    pub request_sandbox_permissive: Option<bool>,
5701    /// Tool call ID that triggered this permission request
5702    #[serde(skip_serializing_if = "Option::is_none")]
5703    pub tool_call_id: Option<String>,
5704    /// Optional warning message about risks of running this command
5705    #[serde(skip_serializing_if = "Option::is_none")]
5706    pub warning: Option<String>,
5707}
5708
5709/// File write permission prompt
5710#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5711#[serde(rename_all = "camelCase")]
5712pub struct PermissionPromptRequestWrite {
5713    /// Assisted-approval judge information for this request; present only in assisted mode.
5714    ///
5715    /// <div class="warning">
5716    ///
5717    /// **Experimental.** This type is part of an experimental wire-protocol surface
5718    /// and may change or be removed in future SDK or CLI releases.
5719    ///
5720    /// </div>
5721    #[serde(skip_serializing_if = "Option::is_none")]
5722    pub assisted_approval: Option<PermissionAssistedApproval>,
5723    /// Whether the UI can offer session-wide approval for file write operations
5724    pub can_offer_session_approval: bool,
5725    /// Unified diff showing the proposed changes
5726    pub diff: String,
5727    /// Path of the file being written to
5728    pub file_name: String,
5729    /// Human-readable description of the intended file change
5730    pub intention: String,
5731    /// Prompt kind discriminator
5732    pub kind: PermissionPromptRequestWriteKind,
5733    /// Whether managed policy requires a human response and forbids host auto-approval
5734    #[serde(skip_serializing_if = "Option::is_none")]
5735    pub managed_approval_required: Option<bool>,
5736    /// Complete new file contents for newly created files
5737    #[serde(skip_serializing_if = "Option::is_none")]
5738    pub new_file_contents: Option<String>,
5739    /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display fileName.
5740    ///
5741    /// <div class="warning">
5742    ///
5743    /// **Experimental.** This type is part of an experimental wire-protocol surface
5744    /// and may change or be removed in future SDK or CLI releases.
5745    ///
5746    /// </div>
5747    #[serde(skip_serializing_if = "Option::is_none")]
5748    pub resolved_path: Option<String>,
5749    /// Tool call ID that triggered this permission request
5750    #[serde(skip_serializing_if = "Option::is_none")]
5751    pub tool_call_id: Option<String>,
5752}
5753
5754/// File read permission prompt
5755#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5756#[serde(rename_all = "camelCase")]
5757pub struct PermissionPromptRequestRead {
5758    /// Assisted-approval judge information for this request; present only in assisted mode.
5759    ///
5760    /// <div class="warning">
5761    ///
5762    /// **Experimental.** This type is part of an experimental wire-protocol surface
5763    /// and may change or be removed in future SDK or CLI releases.
5764    ///
5765    /// </div>
5766    #[serde(skip_serializing_if = "Option::is_none")]
5767    pub assisted_approval: Option<PermissionAssistedApproval>,
5768    /// Human-readable description of why the file is being read
5769    pub intention: String,
5770    /// Prompt kind discriminator
5771    pub kind: PermissionPromptRequestReadKind,
5772    /// Whether managed policy requires a human response and forbids host auto-approval
5773    #[serde(skip_serializing_if = "Option::is_none")]
5774    pub managed_approval_required: Option<bool>,
5775    /// Path of the file or directory being read
5776    pub path: String,
5777    /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display path.
5778    ///
5779    /// <div class="warning">
5780    ///
5781    /// **Experimental.** This type is part of an experimental wire-protocol surface
5782    /// and may change or be removed in future SDK or CLI releases.
5783    ///
5784    /// </div>
5785    #[serde(skip_serializing_if = "Option::is_none")]
5786    pub resolved_path: Option<String>,
5787    /// Tool call ID that triggered this permission request
5788    #[serde(skip_serializing_if = "Option::is_none")]
5789    pub tool_call_id: Option<String>,
5790}
5791
5792/// MCP tool invocation permission prompt
5793#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5794#[serde(rename_all = "camelCase")]
5795pub struct PermissionPromptRequestMcp {
5796    /// Arguments to pass to the MCP tool
5797    #[serde(skip_serializing_if = "Option::is_none")]
5798    pub args: Option<serde_json::Value>,
5799    /// Assisted-approval judge information for this request; present only in assisted mode.
5800    ///
5801    /// <div class="warning">
5802    ///
5803    /// **Experimental.** This type is part of an experimental wire-protocol surface
5804    /// and may change or be removed in future SDK or CLI releases.
5805    ///
5806    /// </div>
5807    #[serde(skip_serializing_if = "Option::is_none")]
5808    pub assisted_approval: Option<PermissionAssistedApproval>,
5809    /// 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.
5810    #[serde(skip_serializing_if = "Option::is_none")]
5811    pub can_offer_server_wide_approval: Option<bool>,
5812    /// Prompt kind discriminator
5813    pub kind: PermissionPromptRequestMcpKind,
5814    /// Advisory runtime permission recommendation. The host remains responsible for deciding the request and may reject it.
5815    ///
5816    /// <div class="warning">
5817    ///
5818    /// **Experimental.** This type is part of an experimental wire-protocol surface
5819    /// and may change or be removed in future SDK or CLI releases.
5820    ///
5821    /// </div>
5822    #[serde(skip_serializing_if = "Option::is_none")]
5823    pub permission_recommendation: Option<PermissionRecommendation>,
5824    /// Name of the MCP server providing the tool
5825    pub server_name: String,
5826    /// Tool call ID that triggered this permission request
5827    #[serde(skip_serializing_if = "Option::is_none")]
5828    pub tool_call_id: Option<String>,
5829    /// Internal name of the MCP tool
5830    pub tool_name: String,
5831    /// Human-readable title of the MCP tool
5832    pub tool_title: String,
5833}
5834
5835/// URL access permission prompt
5836#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5837#[serde(rename_all = "camelCase")]
5838pub struct PermissionPromptRequestUrl {
5839    /// Assisted-approval judge information for this request; present only in assisted mode.
5840    ///
5841    /// <div class="warning">
5842    ///
5843    /// **Experimental.** This type is part of an experimental wire-protocol surface
5844    /// and may change or be removed in future SDK or CLI releases.
5845    ///
5846    /// </div>
5847    #[serde(skip_serializing_if = "Option::is_none")]
5848    pub assisted_approval: Option<PermissionAssistedApproval>,
5849    /// Human-readable description of why the URL is being accessed
5850    pub intention: String,
5851    /// Prompt kind discriminator
5852    pub kind: PermissionPromptRequestUrlKind,
5853    /// Whether managed policy requires a human response and forbids host auto-approval
5854    #[serde(skip_serializing_if = "Option::is_none")]
5855    pub managed_approval_required: Option<bool>,
5856    /// Immediately preceding URL when this prompt is for a redirect target
5857    #[serde(skip_serializing_if = "Option::is_none")]
5858    pub redirected_from: Option<String>,
5859    /// True when the tool is asking to run this URL fetch outside the sandbox, after the network policy denied the approved URL or the sandbox proxy could not reach it (host opted in via sandbox.allowBypass). The model cannot ask for this; only the tool raises it. 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.
5860    #[serde(skip_serializing_if = "Option::is_none")]
5861    pub request_sandbox_bypass: Option<bool>,
5862    /// What the tool tells the user about the bypass on offer: which policy rule blocked the call, or why it cannot be sandboxed. Only meaningful when requestSandboxBypass is true.
5863    #[serde(skip_serializing_if = "Option::is_none")]
5864    pub request_sandbox_bypass_reason: Option<String>,
5865    /// Tool call ID that triggered this permission request
5866    #[serde(skip_serializing_if = "Option::is_none")]
5867    pub tool_call_id: Option<String>,
5868    /// URL to be fetched
5869    pub url: String,
5870}
5871
5872/// Memory operation permission prompt
5873#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5874#[serde(rename_all = "camelCase")]
5875pub struct PermissionPromptRequestMemory {
5876    /// Whether this is a store or vote memory operation
5877    #[serde(skip_serializing_if = "Option::is_none")]
5878    pub action: Option<PermissionRequestMemoryAction>,
5879    /// Assisted-approval judge information for this request; present only in assisted mode.
5880    ///
5881    /// <div class="warning">
5882    ///
5883    /// **Experimental.** This type is part of an experimental wire-protocol surface
5884    /// and may change or be removed in future SDK or CLI releases.
5885    ///
5886    /// </div>
5887    #[serde(skip_serializing_if = "Option::is_none")]
5888    pub assisted_approval: Option<PermissionAssistedApproval>,
5889    /// Source references for the stored fact (store only)
5890    #[serde(skip_serializing_if = "Option::is_none")]
5891    pub citations: Option<String>,
5892    /// Vote direction (vote only)
5893    #[serde(skip_serializing_if = "Option::is_none")]
5894    pub direction: Option<PermissionRequestMemoryDirection>,
5895    /// The fact being stored or voted on
5896    pub fact: String,
5897    /// Prompt kind discriminator
5898    pub kind: PermissionPromptRequestMemoryKind,
5899    /// Reason for the vote (vote only)
5900    #[serde(skip_serializing_if = "Option::is_none")]
5901    pub reason: Option<String>,
5902    /// Topic or subject of the memory (store only)
5903    #[serde(skip_serializing_if = "Option::is_none")]
5904    pub subject: Option<String>,
5905    /// Tool call ID that triggered this permission request
5906    #[serde(skip_serializing_if = "Option::is_none")]
5907    pub tool_call_id: Option<String>,
5908}
5909
5910/// Custom tool invocation permission prompt
5911#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5912#[serde(rename_all = "camelCase")]
5913pub struct PermissionPromptRequestCustomTool {
5914    /// Arguments to pass to the custom tool
5915    #[serde(skip_serializing_if = "Option::is_none")]
5916    pub args: Option<serde_json::Value>,
5917    /// Assisted-approval judge information for this request; present only in assisted mode.
5918    ///
5919    /// <div class="warning">
5920    ///
5921    /// **Experimental.** This type is part of an experimental wire-protocol surface
5922    /// and may change or be removed in future SDK or CLI releases.
5923    ///
5924    /// </div>
5925    #[serde(skip_serializing_if = "Option::is_none")]
5926    pub assisted_approval: Option<PermissionAssistedApproval>,
5927    /// Prompt kind discriminator
5928    pub kind: PermissionPromptRequestCustomToolKind,
5929    /// Tool call ID that triggered this permission request
5930    #[serde(skip_serializing_if = "Option::is_none")]
5931    pub tool_call_id: Option<String>,
5932    /// Description of what the custom tool does
5933    pub tool_description: String,
5934    /// Name of the custom tool
5935    pub tool_name: String,
5936}
5937
5938/// Path access permission prompt
5939#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5940#[serde(rename_all = "camelCase")]
5941pub struct PermissionPromptRequestPath {
5942    /// Underlying permission kind that needs path approval
5943    pub access_kind: PermissionPromptRequestPathAccessKind,
5944    /// Assisted-approval judge information for this request; present only in assisted mode.
5945    ///
5946    /// <div class="warning">
5947    ///
5948    /// **Experimental.** This type is part of an experimental wire-protocol surface
5949    /// and may change or be removed in future SDK or CLI releases.
5950    ///
5951    /// </div>
5952    #[serde(skip_serializing_if = "Option::is_none")]
5953    pub assisted_approval: Option<PermissionAssistedApproval>,
5954    /// Prompt kind discriminator
5955    pub kind: PermissionPromptRequestPathKind,
5956    /// File paths that require explicit approval
5957    pub paths: Vec<String>,
5958    /// Tool call ID that triggered this permission request
5959    #[serde(skip_serializing_if = "Option::is_none")]
5960    pub tool_call_id: Option<String>,
5961}
5962
5963/// Hook confirmation permission prompt
5964#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5965#[serde(rename_all = "camelCase")]
5966pub struct PermissionPromptRequestHook {
5967    /// Assisted-approval judge information for this request; present only in assisted mode.
5968    ///
5969    /// <div class="warning">
5970    ///
5971    /// **Experimental.** This type is part of an experimental wire-protocol surface
5972    /// and may change or be removed in future SDK or CLI releases.
5973    ///
5974    /// </div>
5975    #[serde(skip_serializing_if = "Option::is_none")]
5976    pub assisted_approval: Option<PermissionAssistedApproval>,
5977    /// Optional message from the hook explaining why confirmation is needed
5978    #[serde(skip_serializing_if = "Option::is_none")]
5979    pub hook_message: Option<String>,
5980    /// Prompt kind discriminator
5981    pub kind: PermissionPromptRequestHookKind,
5982    /// Arguments of the tool call being gated
5983    #[serde(skip_serializing_if = "Option::is_none")]
5984    pub tool_args: Option<serde_json::Value>,
5985    /// Tool call ID that triggered this permission request
5986    #[serde(skip_serializing_if = "Option::is_none")]
5987    pub tool_call_id: Option<String>,
5988    /// Name of the tool the hook is gating
5989    pub tool_name: String,
5990}
5991
5992/// Extension management permission prompt
5993#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5994#[serde(rename_all = "camelCase")]
5995pub struct PermissionPromptRequestExtensionManagement {
5996    /// Assisted-approval judge information for this request; present only in assisted mode.
5997    ///
5998    /// <div class="warning">
5999    ///
6000    /// **Experimental.** This type is part of an experimental wire-protocol surface
6001    /// and may change or be removed in future SDK or CLI releases.
6002    ///
6003    /// </div>
6004    #[serde(skip_serializing_if = "Option::is_none")]
6005    pub assisted_approval: Option<PermissionAssistedApproval>,
6006    /// Name of the extension being managed
6007    #[serde(skip_serializing_if = "Option::is_none")]
6008    pub extension_name: Option<String>,
6009    /// Prompt kind discriminator
6010    pub kind: PermissionPromptRequestExtensionManagementKind,
6011    /// The extension management operation (scaffold, reload)
6012    pub operation: String,
6013    /// Tool call ID that triggered this permission request
6014    #[serde(skip_serializing_if = "Option::is_none")]
6015    pub tool_call_id: Option<String>,
6016}
6017
6018/// Factory run or authoring permission prompt
6019#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6020#[serde(rename_all = "camelCase")]
6021pub struct PermissionPromptRequestFactory {
6022    /// Canonical key used for scoped factory approvals
6023    pub approval_key: String,
6024    /// Assisted-approval judge information for this request; present only in assisted mode.
6025    ///
6026    /// <div class="warning">
6027    ///
6028    /// **Experimental.** This type is part of an experimental wire-protocol surface
6029    /// and may change or be removed in future SDK or CLI releases.
6030    ///
6031    /// </div>
6032    #[serde(skip_serializing_if = "Option::is_none")]
6033    pub assisted_approval: Option<PermissionAssistedApproval>,
6034    /// Whether this factory is eligible for persistent approval
6035    pub can_persist_approval: bool,
6036    /// Factory-declared AI-credit limit before any run/resume caller override is applied.
6037    #[serde(skip_serializing_if = "Option::is_none")]
6038    pub declared_max_ai_credits: Option<f64>,
6039    /// Factory-declared concurrent-subagent limit before any run/resume caller override is applied.
6040    #[serde(skip_serializing_if = "Option::is_none")]
6041    pub declared_max_concurrent_subagents: Option<i64>,
6042    /// Factory-declared total-subagent limit before any run/resume caller override is applied.
6043    #[serde(skip_serializing_if = "Option::is_none")]
6044    pub declared_max_total_subagents: Option<i64>,
6045    /// Factory-declared active-time limit in seconds before any run/resume caller override is applied.
6046    #[serde(skip_serializing_if = "Option::is_none")]
6047    pub declared_timeout_seconds: Option<f64>,
6048    /// Factory description
6049    pub description: String,
6050    /// Prompt kind discriminator
6051    pub kind: PermissionPromptRequestFactoryKind,
6052    /// Whether managed policy requires a human response and forbids host auto-approval
6053    #[serde(skip_serializing_if = "Option::is_none")]
6054    pub managed_approval_required: Option<bool>,
6055    /// Effective AI-credit limit; omitted means unlimited
6056    #[serde(skip_serializing_if = "Option::is_none")]
6057    pub max_ai_credits: Option<f64>,
6058    /// Effective concurrent-subagent limit; omitted means unlimited
6059    #[serde(skip_serializing_if = "Option::is_none")]
6060    pub max_concurrent_subagents: Option<i64>,
6061    /// Effective total-subagent limit; omitted means unlimited
6062    #[serde(skip_serializing_if = "Option::is_none")]
6063    pub max_total_subagents: Option<i64>,
6064    /// Factory name
6065    pub name: String,
6066    /// Factory operation, either run or author
6067    pub operation: FactoryPermissionOperation,
6068    /// Declared factory phases
6069    pub phases: Vec<FactoryPermissionPhase>,
6070    /// Effective active-time limit in seconds; omitted means unlimited
6071    #[serde(skip_serializing_if = "Option::is_none")]
6072    pub timeout_seconds: Option<f64>,
6073    /// Tool call ID that triggered this permission request
6074    #[serde(skip_serializing_if = "Option::is_none")]
6075    pub tool_call_id: Option<String>,
6076}
6077
6078/// Extension permission access prompt
6079#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6080#[serde(rename_all = "camelCase")]
6081pub struct PermissionPromptRequestExtensionPermissionAccess {
6082    /// Assisted-approval judge information for this request; present only in assisted mode.
6083    ///
6084    /// <div class="warning">
6085    ///
6086    /// **Experimental.** This type is part of an experimental wire-protocol surface
6087    /// and may change or be removed in future SDK or CLI releases.
6088    ///
6089    /// </div>
6090    #[serde(skip_serializing_if = "Option::is_none")]
6091    pub assisted_approval: Option<PermissionAssistedApproval>,
6092    /// Capabilities the extension is requesting
6093    pub capabilities: Vec<String>,
6094    /// Name of the extension requesting permission access
6095    pub extension_name: String,
6096    /// Prompt kind discriminator
6097    pub kind: PermissionPromptRequestExtensionPermissionAccessKind,
6098    /// Tool call ID that triggered this permission request
6099    #[serde(skip_serializing_if = "Option::is_none")]
6100    pub tool_call_id: Option<String>,
6101}
6102
6103/// Extension sensitive environment variable access prompt
6104#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6105#[serde(rename_all = "camelCase")]
6106pub struct PermissionPromptRequestExtensionEnvAccess {
6107    /// Assisted-approval judge information for this request; present only in assisted mode.
6108    ///
6109    /// <div class="warning">
6110    ///
6111    /// **Experimental.** This type is part of an experimental wire-protocol surface
6112    /// and may change or be removed in future SDK or CLI releases.
6113    ///
6114    /// </div>
6115    #[serde(skip_serializing_if = "Option::is_none")]
6116    pub assisted_approval: Option<PermissionAssistedApproval>,
6117    /// Names of the sensitive environment variables the extension is requesting. Values never appear here.
6118    pub environment_variables: Vec<String>,
6119    /// Name of the extension requesting environment variable access
6120    pub extension_name: String,
6121    /// Prompt kind discriminator
6122    pub kind: PermissionPromptRequestExtensionEnvAccessKind,
6123    /// Tool call ID that triggered this permission request
6124    #[serde(skip_serializing_if = "Option::is_none")]
6125    pub tool_call_id: Option<String>,
6126}
6127
6128/// Session event "permission.requested". Permission request notification requiring client approval with request details
6129#[derive(Debug, Clone, Serialize, Deserialize)]
6130#[serde(rename_all = "camelCase")]
6131pub struct PermissionRequestedData {
6132    /// Agent mode captured from the owning turn when permission evaluation began.
6133    #[serde(skip_serializing_if = "Option::is_none")]
6134    pub agent_mode: Option<SessionMode>,
6135    /// Permission mode captured when evaluation began. Absent on historical events.
6136    #[serde(skip_serializing_if = "Option::is_none")]
6137    pub permission_mode: Option<PermissionMode>,
6138    /// Details of the permission being requested
6139    pub permission_request: PermissionRequest,
6140    /// Derived user-facing permission prompt details for UI consumers
6141    #[serde(skip_serializing_if = "Option::is_none")]
6142    pub prompt_request: Option<PermissionPromptRequest>,
6143    /// Permission-recovery episode that authorized this request to surface for interactive attention
6144    #[serde(skip_serializing_if = "Option::is_none")]
6145    pub recovery_episode_id: Option<String>,
6146    /// Unique identifier for this permission request; used to respond via session.respondToPermission()
6147    pub request_id: RequestId,
6148    /// When true, this permission was already resolved by a permissionRequest hook and requires no client action
6149    #[serde(skip_serializing_if = "Option::is_none")]
6150    pub resolved_by_hook: Option<bool>,
6151    /// Neutral risk metadata supplied by the tool host. Consumers may display this value but must not use it to bypass the permission decision.
6152    #[serde(skip_serializing_if = "Option::is_none")]
6153    pub risk_assessment: Option<serde_json::Value>,
6154}
6155
6156/// Permission response variant indicating the request was approved without persisting an approval rule.
6157#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6158#[serde(rename_all = "camelCase")]
6159pub struct PermissionApproved {
6160    /// The permission request was approved
6161    pub kind: PermissionApprovedKind,
6162    /// Whether a managed approval policy already handled this request
6163    #[serde(skip_serializing_if = "Option::is_none")]
6164    pub managed_approval_handled: Option<bool>,
6165}
6166
6167/// Session-scoped tool-approval rule for specific shell command identifiers.
6168#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6169#[serde(rename_all = "camelCase")]
6170pub struct UserToolSessionApprovalCommands {
6171    /// Command identifiers approved by the user
6172    pub command_identifiers: Vec<String>,
6173    /// Command approval kind
6174    pub kind: UserToolSessionApprovalCommandsKind,
6175}
6176
6177/// Session-scoped tool-approval rule for read-only filesystem operations.
6178#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6179#[serde(rename_all = "camelCase")]
6180pub struct UserToolSessionApprovalRead {
6181    /// Read approval kind
6182    pub kind: UserToolSessionApprovalReadKind,
6183}
6184
6185/// Session-scoped tool-approval rule for filesystem write operations.
6186#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6187#[serde(rename_all = "camelCase")]
6188pub struct UserToolSessionApprovalWrite {
6189    /// Write approval kind
6190    pub kind: UserToolSessionApprovalWriteKind,
6191}
6192
6193/// Session-scoped tool-approval rule for an MCP server tool, or all tools on the server when `toolName` is null.
6194#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6195#[serde(rename_all = "camelCase")]
6196pub struct UserToolSessionApprovalMcp {
6197    /// MCP tool approval kind
6198    pub kind: UserToolSessionApprovalMcpKind,
6199    /// MCP server name
6200    pub server_name: String,
6201    /// Optional MCP tool name, or null for all tools on the server
6202    pub tool_name: Option<String>,
6203}
6204
6205/// Session-scoped tool-approval rule for writes to long-term memory.
6206#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6207#[serde(rename_all = "camelCase")]
6208pub struct UserToolSessionApprovalMemory {
6209    /// Memory approval kind
6210    pub kind: UserToolSessionApprovalMemoryKind,
6211}
6212
6213/// Session-scoped tool-approval rule for a custom tool, keyed by tool name.
6214#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6215#[serde(rename_all = "camelCase")]
6216pub struct UserToolSessionApprovalCustomTool {
6217    /// Custom tool approval kind
6218    pub kind: UserToolSessionApprovalCustomToolKind,
6219    /// Custom tool name
6220    pub tool_name: String,
6221}
6222
6223/// Session-scoped tool-approval rule for extension-management operations, optionally narrowed by operation.
6224#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6225#[serde(rename_all = "camelCase")]
6226pub struct UserToolSessionApprovalExtensionManagement {
6227    /// Extension management approval kind
6228    pub kind: UserToolSessionApprovalExtensionManagementKind,
6229    /// Optional operation identifier
6230    #[serde(skip_serializing_if = "Option::is_none")]
6231    pub operation: Option<String>,
6232}
6233
6234/// Session-scoped factory approval, optionally narrowed by approval key.
6235#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6236#[serde(rename_all = "camelCase")]
6237pub struct UserToolSessionApprovalFactory {
6238    /// Optional factory operation name or canonical approval key
6239    #[serde(skip_serializing_if = "Option::is_none")]
6240    pub approval_key: Option<String>,
6241    /// Factory approval kind
6242    pub kind: UserToolSessionApprovalFactoryKind,
6243}
6244
6245/// Session-scoped tool-approval rule for an extension's permission-gated capability access, keyed by extension name.
6246#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6247#[serde(rename_all = "camelCase")]
6248pub struct UserToolSessionApprovalExtensionPermissionAccess {
6249    /// Extension name
6250    pub extension_name: String,
6251    /// Extension permission access approval kind
6252    pub kind: UserToolSessionApprovalExtensionPermissionAccessKind,
6253}
6254
6255/// 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.
6256#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6257#[serde(rename_all = "camelCase")]
6258pub struct UserToolSessionApprovalExtensionEnvAccess {
6259    /// Names of the sensitive environment variables this approval covers. Values are never persisted.
6260    pub environment_variables: Vec<String>,
6261    /// Extension name
6262    pub extension_name: String,
6263    /// Extension environment access approval kind
6264    pub kind: UserToolSessionApprovalExtensionEnvAccessKind,
6265}
6266
6267/// Permission response variant that approves a request and remembers the provided approval for the rest of the session.
6268#[derive(Debug, Clone, Serialize, Deserialize)]
6269#[serde(rename_all = "camelCase")]
6270pub struct PermissionApprovedForSession {
6271    /// The approval to add as a session-scoped rule
6272    pub approval: UserToolSessionApproval,
6273    /// Approved and remembered for the rest of the session
6274    pub kind: PermissionApprovedForSessionKind,
6275    /// Whether a managed approval policy already handled this request
6276    #[serde(skip_serializing_if = "Option::is_none")]
6277    pub managed_approval_handled: Option<bool>,
6278}
6279
6280/// Permission response variant that approves a request and persists the provided approval to a project location key.
6281#[derive(Debug, Clone, Serialize, Deserialize)]
6282#[serde(rename_all = "camelCase")]
6283pub struct PermissionApprovedForLocation {
6284    /// The approval to persist for this location
6285    pub approval: UserToolSessionApproval,
6286    /// Approved and persisted for this project location
6287    pub kind: PermissionApprovedForLocationKind,
6288    /// The location key (git root or cwd) to persist the approval to
6289    pub location_key: String,
6290    /// Whether a managed approval policy already handled this request
6291    #[serde(skip_serializing_if = "Option::is_none")]
6292    pub managed_approval_handled: Option<bool>,
6293}
6294
6295/// Permission response variant indicating the request was cancelled before use, with an optional reason.
6296#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6297#[serde(rename_all = "camelCase")]
6298pub struct PermissionCancelled {
6299    /// The permission request was cancelled before a response was used
6300    pub kind: PermissionCancelledKind,
6301    /// Optional explanation of why the request was cancelled
6302    #[serde(skip_serializing_if = "Option::is_none")]
6303    pub reason: Option<String>,
6304}
6305
6306/// A permission approval or denial rule matched against a tool request, identified by a rule kind with an optional argument value.
6307#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6308#[serde(rename_all = "camelCase")]
6309pub struct PermissionRule {
6310    /// Argument value matched against the request, or null when the rule kind has no argument (e.g. 'read', 'write', 'memory').
6311    pub argument: Option<String>,
6312    /// The rule kind, such as Shell or GitHubMCP
6313    pub kind: String,
6314}
6315
6316/// Permission response variant denied because matching approval rules explicitly blocked the request.
6317#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6318#[serde(rename_all = "camelCase")]
6319pub struct PermissionDeniedByRules {
6320    /// Denied because approval rules explicitly blocked it
6321    pub kind: PermissionDeniedByRulesKind,
6322    /// Rules that denied the request
6323    pub rules: Vec<PermissionRule>,
6324}
6325
6326/// Permission response variant denied because no approval rule matched and user confirmation was unavailable.
6327#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6328#[serde(rename_all = "camelCase")]
6329pub struct PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
6330    /// Denied because no approval rule matched and user confirmation was unavailable
6331    pub kind: PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind,
6332}
6333
6334/// Permission response variant denied in an interactive user prompt, with optional feedback and force-reject flag.
6335#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6336#[serde(rename_all = "camelCase")]
6337pub struct PermissionDeniedInteractivelyByUser {
6338    /// Optional feedback from the user explaining the denial
6339    #[serde(skip_serializing_if = "Option::is_none")]
6340    pub feedback: Option<String>,
6341    /// Whether to force-reject the current agent turn
6342    #[serde(skip_serializing_if = "Option::is_none")]
6343    pub force_reject: Option<bool>,
6344    /// Denied by the user during an interactive prompt
6345    pub kind: PermissionDeniedInteractivelyByUserKind,
6346}
6347
6348/// Permission response variant denying a path under content exclusion policy, with the path and message.
6349#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6350#[serde(rename_all = "camelCase")]
6351pub struct PermissionDeniedByContentExclusionPolicy {
6352    /// Denied by the organization's content exclusion policy
6353    pub kind: PermissionDeniedByContentExclusionPolicyKind,
6354    /// Human-readable explanation of why the path was excluded
6355    pub message: String,
6356    /// File path that triggered the exclusion
6357    pub path: String,
6358}
6359
6360/// Permission response variant denied by a permission-request hook, with optional message and interrupt flag.
6361#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6362#[serde(rename_all = "camelCase")]
6363pub struct PermissionDeniedByPermissionRequestHook {
6364    /// Whether to interrupt the current agent turn
6365    #[serde(skip_serializing_if = "Option::is_none")]
6366    pub interrupt: Option<bool>,
6367    /// Denied by a permission request hook registered by an extension or plugin
6368    pub kind: PermissionDeniedByPermissionRequestHookKind,
6369    /// Optional message from the hook explaining the denial
6370    #[serde(skip_serializing_if = "Option::is_none")]
6371    pub message: Option<String>,
6372}
6373
6374/// Session event "permission.completed". Permission request completion notification signaling UI dismissal
6375#[derive(Debug, Clone, Serialize, Deserialize)]
6376#[serde(rename_all = "camelCase")]
6377pub struct PermissionCompletedData {
6378    /// Atomic structured blocked outcome when this permission response ended an Autopilot recovery episode unsuccessfully
6379    #[serde(skip_serializing_if = "Option::is_none")]
6380    pub blocker: Option<TaskBlocker>,
6381    /// Who decided this permission request. Absent on completions recorded before this field existed, which consumers must treat as "not a human decision" rather than assuming one. Authorization records are minted only for `human_response`; an assisted-approval verdict, a host policy, an unattended fallback, and a hook resolution all produce the same `result` a person does, so this is the only field that distinguishes them.
6382    ///
6383    /// <div class="warning">
6384    ///
6385    /// **Experimental.** This type is part of an experimental wire-protocol surface
6386    /// and may change or be removed in future SDK or CLI releases.
6387    ///
6388    /// </div>
6389    #[serde(skip_serializing_if = "Option::is_none")]
6390    pub decision_source: Option<PermissionDecisionSource>,
6391    /// Permission-recovery episode settled by this response, when the request was escalated by Autopilot
6392    #[serde(skip_serializing_if = "Option::is_none")]
6393    pub recovery_episode_id: Option<String>,
6394    /// Request ID of the resolved permission request; clients should dismiss any UI for this request
6395    pub request_id: RequestId,
6396    /// The result of the permission request
6397    pub result: PermissionResult,
6398    /// Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
6399    #[serde(skip_serializing_if = "Option::is_none")]
6400    pub tool_call_id: Option<String>,
6401}
6402
6403/// Session event "permission.carriedForward". Records that a live authorization record from an earlier human decision in this session contained a permission proposal, so it ran without another prompt. This mints no authority: it accounts for one more effect against the prior grant, which is what lets a replayed session agree with the live one about how much of that grant is left.
6404///
6405/// <div class="warning">
6406///
6407/// **Experimental.** This type is part of an experimental wire-protocol surface
6408/// and may change or be removed in future SDK or CLI releases.
6409///
6410/// </div>
6411#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6412#[serde(rename_all = "camelCase")]
6413pub struct PermissionCarriedForwardData {
6414    /// Always `authorization_carry_forward`. Stated explicitly so a consumer reading this event cannot mistake it for a human, host-policy, or assisted-approval decision.
6415    ///
6416    /// <div class="warning">
6417    ///
6418    /// **Experimental.** This type is part of an experimental wire-protocol surface
6419    /// and may change or be removed in future SDK or CLI releases.
6420    ///
6421    /// </div>
6422    pub decision_source: PermissionDecisionSource,
6423    /// Identity of the prior authorization record that contained the proposal.
6424    ///
6425    /// <div class="warning">
6426    ///
6427    /// **Experimental.** This type is part of an experimental wire-protocol surface
6428    /// and may change or be removed in future SDK or CLI releases.
6429    ///
6430    /// </div>
6431    pub record_id: String,
6432    /// Authorization edge minted for this admission. Not a prompt id: no prompt was raised, so no client should expect a request with this id.
6433    ///
6434    /// <div class="warning">
6435    ///
6436    /// **Experimental.** This type is part of an experimental wire-protocol surface
6437    /// and may change or be removed in future SDK or CLI releases.
6438    ///
6439    /// </div>
6440    pub request_id: RequestId,
6441    /// Tool call this admission authorizes. Its execution receipts the prior grant, which is how a single-effect approval is spent rather than carried forward again.
6442    ///
6443    /// <div class="warning">
6444    ///
6445    /// **Experimental.** This type is part of an experimental wire-protocol surface
6446    /// and may change or be removed in future SDK or CLI releases.
6447    ///
6448    /// </div>
6449    pub tool_call_id: String,
6450}
6451
6452/// Session event "permission.messageAuthorization". Freezes one blinded, verbatim-verified authorization claim the runtime minted from a human user message, so a resumed session re-establishes the same grant deterministically instead of re-running the extraction model. This mints no authority on its own: it records what a blinded proposer pointed at and the trusted discriminator the runtime established, and deterministic establishment runs on replay. Persisted so recorded authority survives compaction and process resume.
6453///
6454/// <div class="warning">
6455///
6456/// **Experimental.** This type is part of an experimental wire-protocol surface
6457/// and may change or be removed in future SDK or CLI releases.
6458///
6459/// </div>
6460#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6461#[serde(rename_all = "camelCase")]
6462pub struct PermissionMessageAuthorizationData {
6463    /// The kind of effect authorized, as an action-class identifier.
6464    ///
6465    /// <div class="warning">
6466    ///
6467    /// **Experimental.** This type is part of an experimental wire-protocol surface
6468    /// and may change or be removed in future SDK or CLI releases.
6469    ///
6470    /// </div>
6471    pub action_class: String,
6472    /// Whether the claim granted or denied authority.
6473    ///
6474    /// <div class="warning">
6475    ///
6476    /// **Experimental.** This type is part of an experimental wire-protocol surface
6477    /// and may change or be removed in future SDK or CLI releases.
6478    ///
6479    /// </div>
6480    pub polarity: PermissionMessageAuthorizationPolarity,
6481    /// Deterministic identity of the record, derived from the turn and span offsets so re-extracting the same span mints nothing new.
6482    ///
6483    /// <div class="warning">
6484    ///
6485    /// **Experimental.** This type is part of an experimental wire-protocol surface
6486    /// and may change or be removed in future SDK or CLI releases.
6487    ///
6488    /// </div>
6489    pub record_id: String,
6490    /// End byte offset of the authorizing span within the turn.
6491    ///
6492    /// <div class="warning">
6493    ///
6494    /// **Experimental.** This type is part of an experimental wire-protocol surface
6495    /// and may change or be removed in future SDK or CLI releases.
6496    ///
6497    /// </div>
6498    pub span_end: i64,
6499    /// Start byte offset of the authorizing span within the turn.
6500    ///
6501    /// <div class="warning">
6502    ///
6503    /// **Experimental.** This type is part of an experimental wire-protocol surface
6504    /// and may change or be removed in future SDK or CLI releases.
6505    ///
6506    /// </div>
6507    pub span_start: i64,
6508    /// Concrete named targets that appear verbatim inside the span.
6509    ///
6510    /// <div class="warning">
6511    ///
6512    /// **Experimental.** This type is part of an experimental wire-protocol surface
6513    /// and may change or be removed in future SDK or CLI releases.
6514    ///
6515    /// </div>
6516    #[serde(skip_serializing_if = "Option::is_none")]
6517    pub target_members: Option<Vec<String>>,
6518    /// The task the permission is scoped to, when the human named one.
6519    ///
6520    /// <div class="warning">
6521    ///
6522    /// **Experimental.** This type is part of an experimental wire-protocol surface
6523    /// and may change or be removed in future SDK or CLI releases.
6524    ///
6525    /// </div>
6526    #[serde(skip_serializing_if = "Option::is_none")]
6527    pub task: Option<String>,
6528    /// The human turn the quoted span was read from.
6529    ///
6530    /// <div class="warning">
6531    ///
6532    /// **Experimental.** This type is part of an experimental wire-protocol surface
6533    /// and may change or be removed in future SDK or CLI releases.
6534    ///
6535    /// </div>
6536    pub turn_index: i64,
6537    /// The trusted version discriminator, when one exists. Exact shell-command grants carry the byte-identical commands grounded in the human span; world-derived classes carry a file object, remote tip, or runner only when that state was captured safely. An opaque object mirroring the runtime's adjacently-tagged resolution.
6538    ///
6539    /// <div class="warning">
6540    ///
6541    /// **Experimental.** This type is part of an experimental wire-protocol surface
6542    /// and may change or be removed in future SDK or CLI releases.
6543    ///
6544    /// </div>
6545    #[serde(skip_serializing_if = "Option::is_none")]
6546    pub world: Option<serde_json::Value>,
6547}
6548
6549/// Session event "permission.messageAuthorizationRead". Records that one human turn has been read by the blinded authorization proposer, whether or not it minted anything, so a resumed session does not re-run the extraction model on a turn the live session already read. Also records whether that pass activates ongoing extraction; contextual-assent-only passes do not, so unrelated future messages remain outside extraction.
6550///
6551/// <div class="warning">
6552///
6553/// **Experimental.** This type is part of an experimental wire-protocol surface
6554/// and may change or be removed in future SDK or CLI releases.
6555///
6556/// </div>
6557#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6558#[serde(rename_all = "camelCase")]
6559pub struct PermissionMessageAuthorizationReadData {
6560    /// Whether this read activates ongoing message-backed extraction. False for a contextual-assent-only pass while auto-approval is off, so unrelated future messages remain outside extraction.
6561    ///
6562    /// <div class="warning">
6563    ///
6564    /// **Experimental.** This type is part of an experimental wire-protocol surface
6565    /// and may change or be removed in future SDK or CLI releases.
6566    ///
6567    /// </div>
6568    #[serde(skip_serializing_if = "Option::is_none")]
6569    pub activates_extraction: Option<bool>,
6570    /// The human turn that was read by the proposer.
6571    ///
6572    /// <div class="warning">
6573    ///
6574    /// **Experimental.** This type is part of an experimental wire-protocol surface
6575    /// and may change or be removed in future SDK or CLI releases.
6576    ///
6577    /// </div>
6578    pub turn_index: i64,
6579}
6580
6581/// Session event "permission.messageAuthorizationDegraded". Records that message-backed authorization could not safely represent one human turn before compaction. The runtime may compact the original message after this marker is durable, but message-derived carry-forward and assisted auto-approval remain disabled for the rest of the session so subsequent commands continue through the ordinary permission prompt.
6582///
6583/// <div class="warning">
6584///
6585/// **Experimental.** This type is part of an experimental wire-protocol surface
6586/// and may change or be removed in future SDK or CLI releases.
6587///
6588/// </div>
6589#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6590#[serde(rename_all = "camelCase")]
6591pub struct PermissionMessageAuthorizationDegradedData {
6592    /// The human turn that could not be represented safely.
6593    ///
6594    /// <div class="warning">
6595    ///
6596    /// **Experimental.** This type is part of an experimental wire-protocol surface
6597    /// and may change or be removed in future SDK or CLI releases.
6598    ///
6599    /// </div>
6600    pub turn_index: i64,
6601}
6602
6603/// Session event "permission.assentDetected". Records that deterministic text recognition found likely assent in the human turn immediately following a root Autopilot permission request that was blocked because no interactive response was available. This event grants no authority; its model-facing projection only suggests retrying the unchanged operation.
6604///
6605/// <div class="warning">
6606///
6607/// **Experimental.** This type is part of an experimental wire-protocol surface
6608/// and may change or be removed in future SDK or CLI releases.
6609///
6610/// </div>
6611#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6612#[serde(rename_all = "camelCase")]
6613pub struct PermissionAssentDetectedData {
6614    /// Permission request the likely assent may refer to. The runtime derives this from the preceding durable blocker; the human message and extraction model do not choose it.
6615    ///
6616    /// <div class="warning">
6617    ///
6618    /// **Experimental.** This type is part of an experimental wire-protocol surface
6619    /// and may change or be removed in future SDK or CLI releases.
6620    ///
6621    /// </div>
6622    pub request_id: RequestId,
6623    /// Human turn whose text triggered the deterministic assent recognizer.
6624    ///
6625    /// <div class="warning">
6626    ///
6627    /// **Experimental.** This type is part of an experimental wire-protocol surface
6628    /// and may change or be removed in future SDK or CLI releases.
6629    ///
6630    /// </div>
6631    pub turn_index: i64,
6632}
6633
6634/// Session event "permission.contextualAuthorization". Freezes a blinded contextual authorization proposal whose verbatim human span was deterministically bound to the immediately preceding blocked permission request. The event carries no action fields; replay re-derives the exact action from the earlier permission request and mints a one-shot message grant only when the binding and span still verify.
6635///
6636/// <div class="warning">
6637///
6638/// **Experimental.** This type is part of an experimental wire-protocol surface
6639/// and may change or be removed in future SDK or CLI releases.
6640///
6641/// </div>
6642#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6643#[serde(rename_all = "camelCase")]
6644pub struct PermissionContextualAuthorizationData {
6645    /// Whether the contextual human span granted or denied authority.
6646    ///
6647    /// <div class="warning">
6648    ///
6649    /// **Experimental.** This type is part of an experimental wire-protocol surface
6650    /// and may change or be removed in future SDK or CLI releases.
6651    ///
6652    /// </div>
6653    pub polarity: PermissionMessageAuthorizationPolarity,
6654    /// Deterministic identity of the contextual message grant.
6655    ///
6656    /// <div class="warning">
6657    ///
6658    /// **Experimental.** This type is part of an experimental wire-protocol surface
6659    /// and may change or be removed in future SDK or CLI releases.
6660    ///
6661    /// </div>
6662    pub record_id: String,
6663    /// Original blocked permission request selected by deterministic event ordering, never by the extraction model.
6664    ///
6665    /// <div class="warning">
6666    ///
6667    /// **Experimental.** This type is part of an experimental wire-protocol surface
6668    /// and may change or be removed in future SDK or CLI releases.
6669    ///
6670    /// </div>
6671    pub request_id: RequestId,
6672    /// End byte offset of the contextual decision span within the turn.
6673    ///
6674    /// <div class="warning">
6675    ///
6676    /// **Experimental.** This type is part of an experimental wire-protocol surface
6677    /// and may change or be removed in future SDK or CLI releases.
6678    ///
6679    /// </div>
6680    pub span_end: i64,
6681    /// Start byte offset of the contextual decision span within the turn.
6682    ///
6683    /// <div class="warning">
6684    ///
6685    /// **Experimental.** This type is part of an experimental wire-protocol surface
6686    /// and may change or be removed in future SDK or CLI releases.
6687    ///
6688    /// </div>
6689    pub span_start: i64,
6690    /// Human turn containing the contextual decision.
6691    ///
6692    /// <div class="warning">
6693    ///
6694    /// **Experimental.** This type is part of an experimental wire-protocol surface
6695    /// and may change or be removed in future SDK or CLI releases.
6696    ///
6697    /// </div>
6698    pub turn_index: i64,
6699}
6700
6701/// Session event "user_input.requested". User input request notification with question and optional predefined choices
6702#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6703#[serde(rename_all = "camelCase")]
6704pub struct UserInputRequestedData {
6705    /// Whether the user can provide a free-form text response in addition to predefined choices
6706    #[serde(skip_serializing_if = "Option::is_none")]
6707    pub allow_freeform: Option<bool>,
6708    /// Predefined choices for the user to select from, if applicable
6709    #[serde(skip_serializing_if = "Option::is_none")]
6710    pub choices: Option<Vec<String>>,
6711    /// The question or prompt to present to the user
6712    pub question: String,
6713    /// Unique identifier for this input request; used to respond via session.respondToUserInput()
6714    pub request_id: RequestId,
6715    /// The LLM-assigned tool call ID that triggered this request; used by remote UIs to correlate responses
6716    #[serde(skip_serializing_if = "Option::is_none")]
6717    pub tool_call_id: Option<String>,
6718}
6719
6720/// Session event "user_input.completed". User input request completion with the user's response
6721#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6722#[serde(rename_all = "camelCase")]
6723pub struct UserInputCompletedData {
6724    /// The user's answer to the input request
6725    #[serde(skip_serializing_if = "Option::is_none")]
6726    pub answer: Option<String>,
6727    /// Request ID of the resolved user input request; clients should dismiss any UI for this request
6728    pub request_id: RequestId,
6729    /// Whether the answer was typed as free-form text rather than selected from choices
6730    #[serde(skip_serializing_if = "Option::is_none")]
6731    pub was_freeform: Option<bool>,
6732}
6733
6734/// JSON Schema describing the form fields to present to the user (form mode only)
6735#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6736#[serde(rename_all = "camelCase")]
6737pub struct ElicitationRequestedSchema {
6738    /// Form field definitions, keyed by field name
6739    pub properties: HashMap<String, serde_json::Value>,
6740    /// List of required field names
6741    #[serde(skip_serializing_if = "Option::is_none")]
6742    pub required: Option<Vec<String>>,
6743    /// Schema type indicator (always 'object')
6744    pub r#type: ElicitationRequestedSchemaType,
6745}
6746
6747/// Session event "elicitation.requested". Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
6748#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6749#[serde(rename_all = "camelCase")]
6750pub struct ElicitationRequestedData {
6751    /// The source that initiated the request (MCP server name, or absent for agent-initiated)
6752    #[serde(skip_serializing_if = "Option::is_none")]
6753    pub elicitation_source: Option<String>,
6754    /// Message describing what information is needed from the user
6755    pub message: String,
6756    /// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
6757    #[serde(skip_serializing_if = "Option::is_none")]
6758    pub mode: Option<ElicitationRequestedMode>,
6759    /// JSON Schema describing the form fields to present to the user (form mode only)
6760    #[serde(skip_serializing_if = "Option::is_none")]
6761    pub requested_schema: Option<ElicitationRequestedSchema>,
6762    /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation()
6763    pub request_id: RequestId,
6764    /// Tool call ID from the LLM completion; used to correlate with CompletionChunk.toolCall.id for remote UIs
6765    #[serde(skip_serializing_if = "Option::is_none")]
6766    pub tool_call_id: Option<String>,
6767    /// URL to open in the user's browser (url mode only)
6768    #[serde(skip_serializing_if = "Option::is_none")]
6769    pub url: Option<String>,
6770}
6771
6772/// Session event "elicitation.completed". Elicitation request completion with the user's response
6773#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6774#[serde(rename_all = "camelCase")]
6775pub struct ElicitationCompletedData {
6776    /// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
6777    #[serde(skip_serializing_if = "Option::is_none")]
6778    pub action: Option<ElicitationCompletedAction>,
6779    /// The submitted form data when action is 'accept'; keys match the requested schema fields
6780    #[serde(skip_serializing_if = "Option::is_none")]
6781    pub content: Option<HashMap<String, serde_json::Value>>,
6782    /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request
6783    pub request_id: RequestId,
6784}
6785
6786/// Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
6787#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6788#[serde(rename_all = "camelCase")]
6789pub struct SamplingRequestedData {
6790    /// The JSON-RPC request ID from the MCP protocol
6791    pub mcp_request_id: serde_json::Value,
6792    /// Unique identifier for this sampling request; used to respond via session.respondToSampling()
6793    pub request_id: RequestId,
6794    /// Name of the MCP server that initiated the sampling request
6795    pub server_name: String,
6796}
6797
6798/// Session event "sampling.completed". Sampling request completion notification signaling UI dismissal
6799#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6800#[serde(rename_all = "camelCase")]
6801pub struct SamplingCompletedData {
6802    /// Request ID of the resolved sampling request; clients should dismiss any UI for this request
6803    pub request_id: RequestId,
6804}
6805
6806/// Single HTTP header entry as a name/value pair.
6807#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6808#[serde(rename_all = "camelCase")]
6809pub struct HeaderEntry {
6810    /// HTTP response header name as observed by the runtime.
6811    pub name: String,
6812    /// HTTP response header value as observed by the runtime.
6813    pub value: String,
6814}
6815
6816/// Raw HTTP response details from the OAuth auth challenge, as observed by the runtime.
6817#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6818#[serde(rename_all = "camelCase")]
6819pub struct McpOauthHttpResponse {
6820    /// 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.
6821    #[serde(skip_serializing_if = "Option::is_none")]
6822    pub body: Option<String>,
6823    /// HTTP response headers as observed by the runtime. Order and casing are transport-dependent, and duplicate header names may appear multiple times.
6824    pub headers: Vec<HeaderEntry>,
6825    /// HTTP status code returned with the auth challenge.
6826    pub status_code: i32,
6827}
6828
6829/// Static OAuth client configuration, if the server specifies one
6830#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6831#[serde(rename_all = "camelCase")]
6832pub struct McpOauthRequiredStaticClientConfig {
6833    /// OAuth client ID for the server
6834    pub client_id: String,
6835    /// Optional OAuth client secret for confidential static clients, when the runtime can resolve one
6836    #[serde(skip_serializing_if = "Option::is_none")]
6837    pub client_secret: Option<String>,
6838    /// 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).
6839    #[serde(skip_serializing_if = "Option::is_none")]
6840    pub grant_type: Option<McpOauthRequiredStaticClientConfigGrantType>,
6841    /// Whether this is a public OAuth client
6842    #[serde(skip_serializing_if = "Option::is_none")]
6843    pub public_client: Option<bool>,
6844}
6845
6846/// OAuth WWW-Authenticate parameters parsed from an MCP auth challenge
6847#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6848#[serde(rename_all = "camelCase")]
6849pub struct McpOauthWWWAuthenticateParams {
6850    /// OAuth error from the WWW-Authenticate error parameter, if present
6851    #[serde(skip_serializing_if = "Option::is_none")]
6852    pub error: Option<String>,
6853    /// Protected resource metadata URL from the WWW-Authenticate resource_metadata parameter, if present
6854    #[serde(skip_serializing_if = "Option::is_none")]
6855    pub resource_metadata_url: Option<String>,
6856    /// Requested OAuth scopes from the WWW-Authenticate scope parameter, if present
6857    #[serde(skip_serializing_if = "Option::is_none")]
6858    pub scope: Option<String>,
6859}
6860
6861/// Session event "mcp.oauth_required". OAuth authentication request for an MCP server
6862#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6863#[serde(rename_all = "camelCase")]
6864pub struct McpOauthRequiredData {
6865    /// 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.
6866    #[serde(skip_serializing_if = "Option::is_none")]
6867    pub http_response: Option<McpOauthHttpResponse>,
6868    /// Why the runtime is requesting host-provided OAuth credentials.
6869    pub reason: McpOauthRequestReason,
6870    /// Unique identifier for this OAuth request; used to respond via session.mcp.oauth.handlePendingRequest
6871    pub request_id: RequestId,
6872    /// Raw OAuth protected-resource metadata document fetched for the MCP server, if available
6873    #[serde(skip_serializing_if = "Option::is_none")]
6874    pub resource_metadata: Option<String>,
6875    /// Display name of the MCP server that requires OAuth
6876    pub server_name: String,
6877    /// URL of the MCP server that requires OAuth
6878    pub server_url: String,
6879    /// Static OAuth client configuration, if the server specifies one
6880    #[serde(skip_serializing_if = "Option::is_none")]
6881    pub static_client_config: Option<McpOauthRequiredStaticClientConfig>,
6882    /// OAuth WWW-Authenticate parameters parsed from the auth challenge, if available
6883    #[serde(skip_serializing_if = "Option::is_none")]
6884    pub www_authenticate_params: Option<McpOauthWWWAuthenticateParams>,
6885}
6886
6887/// Session event "mcp.oauth_completed". MCP OAuth request completion notification
6888#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6889#[serde(rename_all = "camelCase")]
6890pub struct McpOauthCompletedData {
6891    /// How the pending OAuth request was completed
6892    pub outcome: McpOauthCompletionOutcome,
6893    /// Request ID of the resolved OAuth request
6894    pub request_id: RequestId,
6895}
6896
6897/// Session event "mcp.headers_refresh_required". Dynamic headers refresh request for a remote MCP server
6898#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6899#[serde(rename_all = "camelCase")]
6900pub struct McpHeadersRefreshRequiredData {
6901    /// Why dynamic headers are being requested.
6902    pub reason: McpHeadersRefreshRequiredReason,
6903    /// Unique identifier for this headers refresh request; used to respond via session.mcp.headers.handlePendingHeadersRefreshRequest()
6904    pub request_id: RequestId,
6905    /// Display name of the remote MCP server requesting headers
6906    pub server_name: String,
6907    /// URL of the remote MCP server requesting headers
6908    pub server_url: String,
6909}
6910
6911/// Session event "mcp.headers_refresh_completed". MCP headers refresh request completion notification
6912#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6913#[serde(rename_all = "camelCase")]
6914pub struct McpHeadersRefreshCompletedData {
6915    /// How the pending MCP headers refresh request resolved.
6916    pub outcome: McpHeadersRefreshCompletedOutcome,
6917    /// Request ID of the resolved headers refresh request
6918    pub request_id: RequestId,
6919}
6920
6921/// Session event "session.custom_notification". Opaque custom notification data. Consumers may branch on source and name, but payload semantics are source-defined.
6922#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6923#[serde(rename_all = "camelCase")]
6924pub struct SessionCustomNotificationData {
6925    /// Source-defined custom notification name
6926    pub name: String,
6927    /// Source-defined JSON payload for the custom notification
6928    pub payload: serde_json::Value,
6929    /// Namespace for the custom notification producer
6930    pub source: String,
6931    /// Optional source-defined string identifiers describing the payload subject
6932    #[serde(skip_serializing_if = "Option::is_none")]
6933    pub subject: Option<HashMap<String, String>>,
6934    /// Optional source-defined payload schema version
6935    #[serde(skip_serializing_if = "Option::is_none")]
6936    pub version: Option<i64>,
6937}
6938
6939/// Session event "ui.ephemeral_query". Ordered output and terminal state for a transient query that does not modify conversation history.
6940///
6941/// <div class="warning">
6942///
6943/// **Experimental.** This type is part of an experimental wire-protocol surface
6944/// and may change or be removed in future SDK or CLI releases.
6945///
6946/// </div>
6947#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6948#[serde(rename_all = "camelCase")]
6949pub struct UiEphemeralQueryData {
6950    /// Full response text, present for the `completed` phase.
6951    #[serde(skip_serializing_if = "Option::is_none")]
6952    pub answer: Option<String>,
6953    /// Ordered text delta, present for the `chunk` phase.
6954    #[serde(skip_serializing_if = "Option::is_none")]
6955    pub chunk: Option<String>,
6956    /// Model or transport failure message, present for the `failed` phase.
6957    #[serde(skip_serializing_if = "Option::is_none")]
6958    pub error: Option<String>,
6959    /// Current query lifecycle phase.
6960    pub phase: UIEphemeralQueryPhase,
6961    /// Runtime-minted query identifier.
6962    pub request_id: RequestId,
6963}
6964
6965/// Session event "external_tool.requested". External tool invocation request for client-side tool execution
6966#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6967#[serde(rename_all = "camelCase")]
6968pub struct ExternalToolRequestedData {
6969    /// Arguments to pass to the external tool
6970    #[serde(skip_serializing_if = "Option::is_none")]
6971    pub arguments: Option<serde_json::Value>,
6972    /// 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
6973    #[serde(skip_serializing_if = "Option::is_none")]
6974    pub provider_id: Option<String>,
6975    /// Unique identifier for this request; used to respond via session.respondToExternalTool()
6976    pub request_id: RequestId,
6977    /// Session ID that this external tool request belongs to
6978    pub session_id: SessionId,
6979    /// Tool call ID assigned to this external tool invocation
6980    pub tool_call_id: String,
6981    /// Name of the external tool to invoke
6982    pub tool_name: String,
6983    /// W3C Trace Context traceparent header for the execute_tool span
6984    #[serde(skip_serializing_if = "Option::is_none")]
6985    pub traceparent: Option<String>,
6986    /// W3C Trace Context tracestate header for the execute_tool span
6987    #[serde(skip_serializing_if = "Option::is_none")]
6988    pub tracestate: Option<String>,
6989    /// Active session working directory, when known.
6990    #[serde(skip_serializing_if = "Option::is_none")]
6991    pub working_directory: Option<String>,
6992}
6993
6994/// Session event "external_tool.completed". External tool completion notification signaling UI dismissal
6995#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6996#[serde(rename_all = "camelCase")]
6997pub struct ExternalToolCompletedData {
6998    /// Request ID of the resolved external tool request; clients should dismiss any UI for this request
6999    pub request_id: RequestId,
7000}
7001
7002/// Session event "command.queued". Queued slash command dispatch request for client execution
7003#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7004#[serde(rename_all = "camelCase")]
7005pub struct CommandQueuedData {
7006    /// The slash command text to be executed (e.g., /help, /clear)
7007    pub command: String,
7008    /// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
7009    pub request_id: RequestId,
7010}
7011
7012/// Session event "command.execute". Registered command dispatch request routed to the owning client
7013#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7014#[serde(rename_all = "camelCase")]
7015pub struct CommandExecuteData {
7016    /// Raw argument string after the command name
7017    pub args: String,
7018    /// The full command text (e.g., /deploy production)
7019    pub command: String,
7020    /// Command name without leading /
7021    pub command_name: String,
7022    /// Unique identifier; used to respond via session.commands.handlePendingCommand()
7023    pub request_id: RequestId,
7024}
7025
7026/// Session event "command.completed". Queued command completion notification signaling UI dismissal
7027#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7028#[serde(rename_all = "camelCase")]
7029pub struct CommandCompletedData {
7030    /// Request ID of the resolved command request; clients should dismiss any UI for this request
7031    pub request_id: RequestId,
7032}
7033
7034/// Session event "auto_mode_switch.requested". Auto mode switch request notification requiring user approval
7035#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7036#[serde(rename_all = "camelCase")]
7037pub struct AutoModeSwitchRequestedData {
7038    /// The rate limit error code that triggered this request
7039    #[serde(skip_serializing_if = "Option::is_none")]
7040    pub error_code: Option<String>,
7041    /// Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
7042    pub request_id: RequestId,
7043    /// Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
7044    #[serde(skip_serializing_if = "Option::is_none")]
7045    pub retry_after_seconds: Option<i64>,
7046}
7047
7048/// Session event "auto_mode_switch.completed". Auto mode switch completion notification
7049#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7050#[serde(rename_all = "camelCase")]
7051pub struct AutoModeSwitchCompletedData {
7052    /// Request ID of the resolved request; clients should dismiss any UI for this request
7053    pub request_id: RequestId,
7054    /// The user's auto-mode-switch choice
7055    pub response: AutoModeSwitchResponse,
7056}
7057
7058/// Session event "session_limits_exhausted.requested". Session limit exhaustion notification requiring user action.
7059#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7060#[serde(rename_all = "camelCase")]
7061pub struct SessionLimitsExhaustedRequestedData {
7062    /// Configured max AI Credits for the current accounting window.
7063    pub max_ai_credits: f64,
7064    /// Unique identifier for this request; used to respond via session.ui.handlePendingSessionLimitsExhausted().
7065    pub request_id: RequestId,
7066    /// AI Credits already consumed in the current accounting window.
7067    pub used_ai_credits: f64,
7068}
7069
7070/// The user's selected action for an exhausted session limit.
7071#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7072#[serde(rename_all = "camelCase")]
7073pub struct SessionLimitsExhaustedResponse {
7074    /// Action selected by the user.
7075    pub action: SessionLimitsExhaustedResponseAction,
7076    /// AI Credits to add to the current max when action is 'add'.
7077    #[serde(skip_serializing_if = "Option::is_none")]
7078    pub additional_ai_credits: Option<f64>,
7079    /// New absolute max AI Credits when action is 'set'.
7080    #[serde(skip_serializing_if = "Option::is_none")]
7081    pub max_ai_credits: Option<f64>,
7082}
7083
7084/// Session event "session_limits_exhausted.completed". Session limit exhaustion prompt completion notification.
7085#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7086#[serde(rename_all = "camelCase")]
7087pub struct SessionLimitsExhaustedCompletedData {
7088    /// Request ID of the resolved request; clients should dismiss any UI for this request.
7089    pub request_id: RequestId,
7090    /// The user's selected session-limit action.
7091    pub response: SessionLimitsExhaustedResponse,
7092}
7093
7094/// 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.
7095///
7096/// <div class="warning">
7097///
7098/// **Experimental.** This type is part of an experimental wire-protocol surface
7099/// and may change or be removed in future SDK or CLI releases.
7100///
7101/// </div>
7102#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7103#[serde(rename_all = "camelCase")]
7104pub struct SessionAutoModeResolvedData {
7105    /// Models offered to the router for this resolution
7106    #[serde(skip_serializing_if = "Option::is_none")]
7107    pub available_models: Option<Vec<String>>,
7108    /// Ordered candidate model list the router returned, when not a fallback
7109    #[serde(skip_serializing_if = "Option::is_none")]
7110    pub candidate_models: Option<Vec<String>>,
7111    /// 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.
7112    #[serde(skip_serializing_if = "Option::is_none")]
7113    pub category_scores: Option<HashMap<String, f64>>,
7114    /// The concrete model the session will use after any intent refinement
7115    pub chosen_model: String,
7116    /// The chosen model's score shortfall relative to the top candidate
7117    #[serde(skip_serializing_if = "Option::is_none")]
7118    pub chosen_shortfall: Option<f64>,
7119    /// Classifier confidence for the predicted label, when available
7120    #[serde(skip_serializing_if = "Option::is_none")]
7121    pub confidence: Option<f64>,
7122    /// End-to-end client wait time for the router request in milliseconds
7123    #[serde(skip_serializing_if = "Option::is_none")]
7124    pub end_to_end_latency_ms: Option<f64>,
7125    /// Whether the router fell back to the standard Auto selection
7126    #[serde(skip_serializing_if = "Option::is_none")]
7127    pub fallback: Option<bool>,
7128    /// Server-provided reason for falling back, when available
7129    #[serde(skip_serializing_if = "Option::is_none")]
7130    pub fallback_reason: Option<String>,
7131    /// Whether the routed prompt contained an image
7132    #[serde(skip_serializing_if = "Option::is_none")]
7133    pub has_image: Option<bool>,
7134    /// The predicted classifier label (e.g. `needs_reasoning`), when available
7135    #[serde(skip_serializing_if = "Option::is_none")]
7136    pub predicted_label: Option<String>,
7137    /// Coarse request-difficulty bucket, for explaining why a model was chosen ("picked X because this looks like high-reasoning work")
7138    #[serde(skip_serializing_if = "Option::is_none")]
7139    pub reasoning_bucket: Option<AutoModeResolvedReasoningBucket>,
7140    /// Server-reported router processing time in milliseconds
7141    #[serde(skip_serializing_if = "Option::is_none")]
7142    pub router_latency_ms: Option<f64>,
7143    /// The routing method the server applied, when Auto Intent ran
7144    #[serde(skip_serializing_if = "Option::is_none")]
7145    pub routing_method: Option<String>,
7146    /// Whether a sticky model choice overrode the router result
7147    #[serde(skip_serializing_if = "Option::is_none")]
7148    pub sticky_override: Option<bool>,
7149}
7150
7151/// 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.
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, Serialize, Deserialize)]
7160#[serde(rename_all = "camelCase")]
7161pub struct SessionManagedSettingsResolvedData {
7162    /// Whether enterprise policy disables bypass-permissions ("yolo") mode for this session. Deny-wins across layers, and forced on when `failClosed` is true.
7163    pub bypass_permissions_disabled: bool,
7164    /// Whether a session-local permissions layer injected by the SDK host was present
7165    #[serde(skip_serializing_if = "Option::is_none")]
7166    pub client_managed: Option<bool>,
7167    /// Whether an actual device MDM/plist/registry/file managed-settings layer was present
7168    pub device_managed: bool,
7169    /// 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.
7170    pub fail_closed: bool,
7171    /// The setting keys under enterprise management in the effective managed settings (e.g. `model`, `enabledPlugins`, `permissions`). Empty when no managed settings are in force.
7172    pub managed_keys: Vec<String>,
7173    /// Whether at least two managed sources supplied permission allowlists, so enforcement intersects them and the flattened settings payload omits `permissions.allow`.
7174    #[serde(skip_serializing_if = "Option::is_none")]
7175    pub permissions_allow_intersected: Option<bool>,
7176    /// 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.
7177    #[serde(skip_serializing_if = "Option::is_none")]
7178    pub policy_helper_managed: Option<bool>,
7179    /// 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.
7180    #[serde(skip_serializing_if = "Option::is_none")]
7181    pub sandbox_enabled_by_undetermined_policy: Option<bool>,
7182    /// Whether the server (account/org) managed-settings layer was present
7183    pub server_managed: bool,
7184    /// The effective (resolved) managed settings values, so clients can render exactly what is enforced. Absent when no managed policy is in force.
7185    #[serde(skip_serializing_if = "Option::is_none")]
7186    pub settings: Option<serde_json::Value>,
7187    /// 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.
7188    pub source: ManagedSettingsResolvedSource,
7189}
7190
7191/// 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.
7192///
7193/// <div class="warning">
7194///
7195/// **Experimental.** This type is part of an experimental wire-protocol surface
7196/// and may change or be removed in future SDK or CLI releases.
7197///
7198/// </div>
7199#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7200#[serde(rename_all = "camelCase")]
7201pub struct SessionManagedSettingsEnforcedData {
7202    /// The category of runtime action that managed policy governed.
7203    pub action: ManagedSettingsEnforcedAction,
7204    /// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused. Absent for actions without a specific escalation primitive.
7205    #[serde(skip_serializing_if = "Option::is_none")]
7206    pub escalation: Option<ManagedSettingsEnforcedEscalation>,
7207    /// 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.
7208    pub fail_closed: bool,
7209    /// A human-readable explanation of why the action was governed, suitable for surfacing to the user.
7210    pub message: String,
7211    /// The managed setting key responsible for the enforcement (e.g. `permissions.disableBypassPermissionsMode`).
7212    pub setting: String,
7213}
7214
7215/// A single slash command available in the session, as listed by the `commands.changed` event.
7216#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7217#[serde(rename_all = "camelCase")]
7218pub struct CommandsChangedCommand {
7219    /// Optional human-readable command description.
7220    #[serde(skip_serializing_if = "Option::is_none")]
7221    pub description: Option<String>,
7222    /// Slash command name without the leading slash.
7223    pub name: String,
7224}
7225
7226/// Session event "commands.changed". SDK command registration change notification
7227#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7228#[serde(rename_all = "camelCase")]
7229pub struct CommandsChangedData {
7230    /// Current list of registered SDK commands
7231    pub commands: Vec<CommandsChangedCommand>,
7232}
7233
7234/// UI capability changes
7235#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7236#[serde(rename_all = "camelCase")]
7237pub struct CapabilitiesChangedUI {
7238    /// Whether canvas rendering is now supported
7239    #[serde(skip_serializing_if = "Option::is_none")]
7240    pub canvases: Option<bool>,
7241    /// Whether elicitation is now supported
7242    #[serde(skip_serializing_if = "Option::is_none")]
7243    pub elicitation: Option<bool>,
7244    /// Whether MCP Apps (SEP-1865) UI passthrough is now supported
7245    #[serde(skip_serializing_if = "Option::is_none")]
7246    pub mcp_apps: Option<bool>,
7247}
7248
7249/// Session event "capabilities.changed". Session capability change notification
7250#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7251#[serde(rename_all = "camelCase")]
7252pub struct CapabilitiesChangedData {
7253    /// UI capability changes
7254    #[serde(skip_serializing_if = "Option::is_none")]
7255    pub ui: Option<CapabilitiesChangedUI>,
7256}
7257
7258/// Session event "exit_plan_mode.requested". Plan approval request with plan content and available user actions
7259#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7260#[serde(rename_all = "camelCase")]
7261pub struct ExitPlanModeRequestedData {
7262    /// Available actions the user can take
7263    pub actions: Vec<ExitPlanModeAction>,
7264    /// Model the session had selected when the plan was authored, when one is known
7265    #[serde(skip_serializing_if = "Option::is_none")]
7266    pub model: Option<String>,
7267    /// Full content of the plan file
7268    pub plan_content: String,
7269    /// Recommended action to preselect for the user
7270    pub recommended_action: ExitPlanModeAction,
7271    /// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
7272    pub request_id: RequestId,
7273    /// Summary of the plan that was created
7274    pub summary: String,
7275}
7276
7277/// Session event "exit_plan_mode.completed". Plan mode exit completion with the user's approval decision and optional feedback
7278#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7279#[serde(rename_all = "camelCase")]
7280pub struct ExitPlanModeCompletedData {
7281    /// Whether the plan was approved by the user
7282    #[serde(skip_serializing_if = "Option::is_none")]
7283    pub approved: Option<bool>,
7284    /// Whether edits should be auto-approved without confirmation
7285    #[serde(skip_serializing_if = "Option::is_none")]
7286    pub auto_approve_edits: Option<bool>,
7287    /// Free-form feedback from the user if they requested changes to the plan
7288    #[serde(skip_serializing_if = "Option::is_none")]
7289    pub feedback: Option<String>,
7290    /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
7291    pub request_id: RequestId,
7292    /// Action selected by the user
7293    #[serde(skip_serializing_if = "Option::is_none")]
7294    pub selected_action: Option<ExitPlanModeAction>,
7295}
7296
7297/// Session event "session.tools_updated". Payload of `session.tools_updated` identifying the model whose resolved tools were updated.
7298#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7299#[serde(rename_all = "camelCase")]
7300pub struct SessionToolsUpdatedData {
7301    /// Identifier of the model the resolved tools apply to.
7302    pub model: String,
7303}
7304
7305/// Session event "session.background_tasks_changed". Empty payload for `session.background_tasks_changed`, indicating background task state changed.
7306#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7307#[serde(rename_all = "camelCase")]
7308pub struct SessionBackgroundTasksChangedData {}
7309
7310/// Session event "factory.run_updated". Ephemeral invalidation signal for a changed factory run.
7311///
7312/// <div class="warning">
7313///
7314/// **Experimental.** This type is part of an experimental wire-protocol surface
7315/// and may change or be removed in future SDK or CLI releases.
7316///
7317/// </div>
7318#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7319#[serde(rename_all = "camelCase")]
7320pub struct FactoryRunUpdatedData {
7321    /// Monotonic revision now available for the run.
7322    pub revision: i64,
7323    /// Factory run identifier.
7324    pub run_id: String,
7325}
7326
7327/// Session event "factory.run_started". Ephemeral signal that a factory run attempt began executing.
7328///
7329/// <div class="warning">
7330///
7331/// **Experimental.** This type is part of an experimental wire-protocol surface
7332/// and may change or be removed in future SDK or CLI releases.
7333///
7334/// </div>
7335#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7336#[serde(rename_all = "camelCase")]
7337pub struct FactoryRunStartedData {
7338    /// Attempt number this start committed; a resumed run increments it.
7339    pub attempt: i64,
7340    /// Name of the factory this run executes. Low cardinality by construction.
7341    pub factory_name: String,
7342    /// Identifier of the factory run that started.
7343    pub run_id: String,
7344}
7345
7346/// Session event "factory.run_settled". Ephemeral signal that a factory run reached a terminal status.
7347///
7348/// <div class="warning">
7349///
7350/// **Experimental.** This type is part of an experimental wire-protocol surface
7351/// and may change or be removed in future SDK or CLI releases.
7352///
7353/// </div>
7354#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7355#[serde(rename_all = "camelCase")]
7356pub struct FactoryRunSettledData {
7357    /// AI credits this run consumed, in nano-AIU.
7358    pub consumed_nano_aiu: i64,
7359    /// Subagents this run consumed against its limits.
7360    pub consumed_subagents: i64,
7361    /// Active milliseconds accumulated across every attempt of this run.
7362    pub elapsed_ms: i64,
7363    /// Typed failure class recorded on the run, when it failed with one (e.g. `factory_limit_reached`).
7364    #[serde(skip_serializing_if = "Option::is_none")]
7365    pub failure_type: Option<String>,
7366    /// Identifier of the factory run that settled.
7367    pub run_id: String,
7368    /// Terminal status the run committed.
7369    pub status: FactoryRunSettledStatus,
7370}
7371
7372/// A single resolved skill in `session.skills_loaded`, including source, invocability, enabled state, path, and argument hint.
7373#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7374#[serde(rename_all = "camelCase")]
7375pub struct SkillsLoadedSkill {
7376    /// Optional freeform hint describing the skill's expected arguments, from the `argument-hint` frontmatter field
7377    #[serde(skip_serializing_if = "Option::is_none")]
7378    pub argument_hint: Option<String>,
7379    /// Canonical slash command name used to invoke the skill, without the leading '/'
7380    #[serde(skip_serializing_if = "Option::is_none")]
7381    pub command_name: Option<String>,
7382    /// Description of what the skill does
7383    pub description: String,
7384    /// Whether the skill is currently enabled
7385    pub enabled: bool,
7386    /// Unique identifier for the skill
7387    pub name: String,
7388    /// Absolute path to the skill file, if available
7389    #[serde(skip_serializing_if = "Option::is_none")]
7390    pub path: Option<String>,
7391    /// Source location type (e.g., project, personal-copilot, plugin, builtin, remote, sdk)
7392    pub source: SkillSource,
7393    /// Whether the skill can be invoked by the user as a slash command
7394    pub user_invocable: bool,
7395}
7396
7397/// Session event "session.skills_loaded". Payload of `session.skills_loaded` listing resolved skill metadata.
7398#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7399#[serde(rename_all = "camelCase")]
7400pub struct SessionSkillsLoadedData {
7401    /// Array of resolved skill metadata
7402    pub skills: Vec<SkillsLoadedSkill>,
7403}
7404
7405/// A single loaded custom agent in `session.custom_agents_updated`, with identity, source, tools, invocability, and authored model configuration.
7406#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7407#[serde(rename_all = "camelCase")]
7408pub struct CustomAgentsUpdatedAgent {
7409    /// Description of what the agent does
7410    pub description: String,
7411    /// Whether model-driven invocation is disabled for this agent.
7412    #[serde(skip_serializing_if = "Option::is_none")]
7413    pub disable_model_invocation: Option<bool>,
7414    /// Human-readable display name
7415    pub display_name: String,
7416    /// Unique identifier for the agent
7417    pub id: String,
7418    /// Model override for this agent, if set
7419    #[serde(skip_serializing_if = "Option::is_none")]
7420    pub model: Option<String>,
7421    /// Whether authored models are preferences or required constraints
7422    #[serde(skip_serializing_if = "Option::is_none")]
7423    pub model_policy: Option<AgentModelPolicy>,
7424    /// Authored model ids in priority order, if configured
7425    #[serde(skip_serializing_if = "Option::is_none")]
7426    pub models: Option<Vec<String>>,
7427    /// Internal name of the agent
7428    pub name: String,
7429    /// Source location: user, project, inherited, remote, or plugin
7430    pub source: String,
7431    /// List of tool names available to this agent, or null when all tools are available
7432    pub tools: Option<Vec<String>>,
7433    /// Whether the agent can be selected by the user
7434    pub user_invocable: bool,
7435}
7436
7437/// Session event "session.custom_agents_updated". Payload of `session.custom_agents_updated` with loaded custom agents plus non-fatal warnings and fatal errors.
7438#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7439#[serde(rename_all = "camelCase")]
7440pub struct SessionCustomAgentsUpdatedData {
7441    /// Array of loaded custom agent metadata
7442    pub agents: Vec<CustomAgentsUpdatedAgent>,
7443    /// Fatal errors from agent loading
7444    pub errors: Vec<String>,
7445    /// Non-fatal warnings from agent loading
7446    pub warnings: Vec<String>,
7447}
7448
7449/// Server-advertised metadata learned through modern discovery or legacy initialization.
7450#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7451#[serde(rename_all = "camelCase")]
7452pub struct McpServerMetadata {
7453    /// Non-empty natural-language guidance for using the server, or null when the server omitted instructions or advertised an empty string.
7454    pub instructions: Option<String>,
7455}
7456
7457/// A single MCP server status summary in `session.mcp_servers_loaded`, including name, status, source, transport, and plugin metadata.
7458#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7459#[serde(rename_all = "camelCase")]
7460pub struct McpServersLoadedServer {
7461    /// Human-readable display name supplied by a managed server catalog.
7462    #[serde(skip_serializing_if = "Option::is_none")]
7463    pub display_name: Option<String>,
7464    /// Error message if the server failed to connect
7465    #[serde(skip_serializing_if = "Option::is_none")]
7466    pub error: Option<String>,
7467    /// Server name (config key)
7468    pub name: String,
7469    /// Name of the plugin that supplied the effective MCP server config, only when source is plugin
7470    #[serde(skip_serializing_if = "Option::is_none")]
7471    pub plugin_name: Option<String>,
7472    /// Version of the plugin that supplied the effective MCP server config, only when source is plugin
7473    #[serde(skip_serializing_if = "Option::is_none")]
7474    pub plugin_version: Option<String>,
7475    /// Server-advertised metadata for a connected server. Omitted when no live connection metadata is available, including while pending or when failed, disabled, stopped, or not configured.
7476    #[serde(skip_serializing_if = "Option::is_none")]
7477    pub server_metadata: Option<McpServerMetadata>,
7478    /// Configuration source: user, workspace, plugin, builtin, or managed
7479    #[serde(skip_serializing_if = "Option::is_none")]
7480    pub source: Option<McpServerSource>,
7481    /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
7482    pub status: McpServerStatus,
7483    /// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
7484    #[serde(skip_serializing_if = "Option::is_none")]
7485    pub transport: Option<McpServerTransport>,
7486}
7487
7488/// Session event "session.mcp_servers_loaded". Payload of `session.mcp_servers_loaded` listing MCP server status summaries.
7489#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7490#[serde(rename_all = "camelCase")]
7491pub struct SessionMcpServersLoadedData {
7492    /// Array of MCP server status summaries
7493    pub servers: Vec<McpServersLoadedServer>,
7494}
7495
7496/// Session event "session.mcp_server_status_changed". Payload of `session.mcp_server_status_changed` for one MCP server's status and optional failure error.
7497#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7498#[serde(rename_all = "camelCase")]
7499pub struct SessionMcpServerStatusChangedData {
7500    /// Error message if the server entered a failed state
7501    #[serde(skip_serializing_if = "Option::is_none")]
7502    pub error: Option<String>,
7503    /// Name of the MCP server whose status changed
7504    pub server_name: String,
7505    /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
7506    pub status: McpServerStatus,
7507}
7508
7509/// Session event "session.mcp_server_removed". Payload of `session.mcp_server_removed` identifying an MCP server the graph no longer runs.
7510#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7511#[serde(rename_all = "camelCase")]
7512pub struct SessionMcpServerRemovedData {
7513    /// Name of the MCP server that was removed from the graph
7514    pub server_name: String,
7515}
7516
7517/// Session event "session.mcp_server_needs_reconnect". Payload of `session.mcp_server_needs_reconnect` identifying an MCP server whose connection must be re-established.
7518#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7519#[serde(rename_all = "camelCase")]
7520pub struct SessionMcpServerNeedsReconnectData {
7521    /// Name of the MCP server that needs to reconnect
7522    pub server_name: String,
7523}
7524
7525/// Session event "mcp.tools.list_changed". Payload identifying the MCP server associated with a list change.
7526#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7527#[serde(rename_all = "camelCase")]
7528pub struct McpToolsListChangedData {
7529    /// Name of the MCP server whose list changed
7530    pub server_name: String,
7531}
7532
7533/// Session event "mcp.resources.list_changed". Payload identifying the MCP server associated with a list change.
7534#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7535#[serde(rename_all = "camelCase")]
7536pub struct McpResourcesListChangedData {
7537    /// Name of the MCP server whose list changed
7538    pub server_name: String,
7539}
7540
7541/// Session event "mcp.prompts.list_changed". Payload identifying the MCP server associated with a list change.
7542#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7543#[serde(rename_all = "camelCase")]
7544pub struct McpPromptsListChangedData {
7545    /// Name of the MCP server whose list changed
7546    pub server_name: String,
7547}
7548
7549/// A single extension discovered by `session.extensions_loaded`, including qualified ID, source, and current status.
7550#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7551#[serde(rename_all = "camelCase")]
7552pub struct ExtensionsLoadedExtension {
7553    /// Source-qualified extension ID (e.g., 'project:my-ext', 'user:auth-helper', 'plugin:my-plugin:my-ext')
7554    pub id: String,
7555    /// Extension name (directory name)
7556    pub name: String,
7557    /// Discovery source
7558    pub source: ExtensionsLoadedExtensionSource,
7559    /// Current status: running, disabled, failed, or starting
7560    pub status: ExtensionsLoadedExtensionStatus,
7561}
7562
7563/// Session event "session.extensions_loaded". Payload of `session.extensions_loaded` listing discovered extensions and their statuses.
7564#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7565#[serde(rename_all = "camelCase")]
7566pub struct SessionExtensionsLoadedData {
7567    /// Array of discovered extensions and their status
7568    pub extensions: Vec<ExtensionsLoadedExtension>,
7569}
7570
7571/// Session event "session.canvas.opened". Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional icon, title, status, URL, and input.
7572///
7573/// <div class="warning">
7574///
7575/// **Experimental.** This type is part of an experimental wire-protocol surface
7576/// and may change or be removed in future SDK or CLI releases.
7577///
7578/// </div>
7579#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7580#[serde(rename_all = "camelCase")]
7581pub struct SessionCanvasOpenedData {
7582    /// Provider-local canvas identifier
7583    pub canvas_id: String,
7584    /// Owning provider identifier
7585    pub extension_id: String,
7586    /// Owning extension display name, when available
7587    #[serde(skip_serializing_if = "Option::is_none")]
7588    pub extension_name: Option<String>,
7589    /// Host-local PNG path for the canvas icon, when supplied
7590    #[serde(skip_serializing_if = "Option::is_none")]
7591    pub icon: Option<String>,
7592    /// Input supplied when the instance was opened
7593    #[serde(skip_serializing_if = "Option::is_none")]
7594    pub input: Option<serde_json::Value>,
7595    /// Stable caller-supplied canvas instance identifier
7596    pub instance_id: String,
7597    /// Provider-supplied status text
7598    #[serde(skip_serializing_if = "Option::is_none")]
7599    pub status: Option<String>,
7600    /// Rendered title
7601    #[serde(skip_serializing_if = "Option::is_none")]
7602    pub title: Option<String>,
7603    /// URL for web-rendered canvases
7604    #[serde(skip_serializing_if = "Option::is_none")]
7605    pub url: Option<String>,
7606}
7607
7608/// A single action within a canvas declaration, with its name, optional description, and optional input schema.
7609///
7610/// <div class="warning">
7611///
7612/// **Experimental.** This type is part of an experimental wire-protocol surface
7613/// and may change or be removed in future SDK or CLI releases.
7614///
7615/// </div>
7616#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7617#[serde(rename_all = "camelCase")]
7618pub struct CanvasRegistryChangedCanvasAction {
7619    /// Action description
7620    #[serde(skip_serializing_if = "Option::is_none")]
7621    pub description: Option<String>,
7622    /// JSON Schema for action input
7623    #[serde(skip_serializing_if = "Option::is_none")]
7624    pub input_schema: Option<serde_json::Value>,
7625    /// Action name
7626    pub name: String,
7627}
7628
7629/// A single canvas declaration in `session.canvas.registry_changed`, including provider IDs, display metadata, input schema, and actions.
7630///
7631/// <div class="warning">
7632///
7633/// **Experimental.** This type is part of an experimental wire-protocol surface
7634/// and may change or be removed in future SDK or CLI releases.
7635///
7636/// </div>
7637#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7638#[serde(rename_all = "camelCase")]
7639pub struct CanvasRegistryChangedCanvas {
7640    /// Actions the agent or host may invoke
7641    #[serde(skip_serializing_if = "Option::is_none")]
7642    pub actions: Option<Vec<CanvasRegistryChangedCanvasAction>>,
7643    /// Provider-local canvas identifier
7644    pub canvas_id: String,
7645    /// Short, single-sentence description shown to the agent in canvas catalogs.
7646    pub description: String,
7647    /// Human-readable canvas name
7648    pub display_name: String,
7649    /// Owning provider identifier
7650    pub extension_id: String,
7651    /// Owning extension display name, when available
7652    #[serde(skip_serializing_if = "Option::is_none")]
7653    pub extension_name: Option<String>,
7654    /// Host-local PNG path for the canvas icon, when supplied
7655    #[serde(skip_serializing_if = "Option::is_none")]
7656    pub icon: Option<String>,
7657    /// JSON Schema for canvas open input
7658    #[serde(skip_serializing_if = "Option::is_none")]
7659    pub input_schema: Option<serde_json::Value>,
7660}
7661
7662/// Session event "session.canvas.registry_changed". Payload of `session.canvas.registry_changed` listing the canvas declarations currently available.
7663///
7664/// <div class="warning">
7665///
7666/// **Experimental.** This type is part of an experimental wire-protocol surface
7667/// and may change or be removed in future SDK or CLI releases.
7668///
7669/// </div>
7670#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7671#[serde(rename_all = "camelCase")]
7672pub struct SessionCanvasRegistryChangedData {
7673    /// Canvas declarations currently available
7674    pub canvases: Vec<CanvasRegistryChangedCanvas>,
7675}
7676
7677/// Session event "session.canvas.closed". Payload of `session.canvas.closed` with the closed canvas instance ID, provider ID, and canvas ID.
7678///
7679/// <div class="warning">
7680///
7681/// **Experimental.** This type is part of an experimental wire-protocol surface
7682/// and may change or be removed in future SDK or CLI releases.
7683///
7684/// </div>
7685#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7686#[serde(rename_all = "camelCase")]
7687pub struct SessionCanvasClosedData {
7688    /// Provider-local canvas identifier
7689    pub canvas_id: String,
7690    /// Owning provider identifier
7691    pub extension_id: String,
7692    /// Stable caller-supplied identifier of the canvas instance that was closed
7693    pub instance_id: String,
7694}
7695
7696/// 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.
7697///
7698/// <div class="warning">
7699///
7700/// **Experimental.** This type is part of an experimental wire-protocol surface
7701/// and may change or be removed in future SDK or CLI releases.
7702///
7703/// </div>
7704#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7705#[serde(rename_all = "camelCase")]
7706pub struct SessionCanvasUnavailableData {
7707    /// Provider-local canvas identifier
7708    pub canvas_id: String,
7709    /// Owning provider identifier
7710    pub extension_id: String,
7711    /// Stable caller-supplied identifier of the canvas instance whose provider became unavailable
7712    pub instance_id: String,
7713}
7714
7715/// 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.
7716///
7717/// <div class="warning">
7718///
7719/// **Experimental.** This type is part of an experimental wire-protocol surface
7720/// and may change or be removed in future SDK or CLI releases.
7721///
7722/// </div>
7723#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7724#[serde(rename_all = "camelCase")]
7725pub struct SessionCanvasRecordedData {
7726    /// Provider-local canvas identifier
7727    pub canvas_id: String,
7728    /// Owning provider identifier
7729    pub extension_id: String,
7730    /// Input supplied when the instance was opened
7731    #[serde(skip_serializing_if = "Option::is_none")]
7732    pub input: Option<serde_json::Value>,
7733    /// Stable caller-supplied canvas instance identifier
7734    pub instance_id: String,
7735    /// Rendered title
7736    #[serde(skip_serializing_if = "Option::is_none")]
7737    pub title: Option<String>,
7738}
7739
7740/// Session event "session.canvas.removed". Durable record that a canvas instance was closed, superseding a prior instance_recorded during resume replay.
7741///
7742/// <div class="warning">
7743///
7744/// **Experimental.** This type is part of an experimental wire-protocol surface
7745/// and may change or be removed in future SDK or CLI releases.
7746///
7747/// </div>
7748#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7749#[serde(rename_all = "camelCase")]
7750pub struct SessionCanvasRemovedData {
7751    /// Provider-local canvas identifier
7752    pub canvas_id: String,
7753    /// Owning provider identifier
7754    pub extension_id: String,
7755    /// Stable caller-supplied identifier of the canvas instance that was closed
7756    pub instance_id: String,
7757}
7758
7759/// Session event "session.extensions.attachments_pushed". Payload of `session.extensions.attachments_pushed` with extension-contributed attachments for the next send.
7760#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7761#[serde(rename_all = "camelCase")]
7762pub struct SessionExtensionsAttachmentsPushedData {
7763    /// Attachments contributed by an extension; the host should surface these as composer pills and forward them via the next session.send call.
7764    pub attachments: Vec<serde_json::Value>,
7765}
7766
7767/// Set when the underlying tools/call threw an error before returning a CallToolResult
7768#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7769#[serde(rename_all = "camelCase")]
7770pub struct McpAppToolCallCompleteError {
7771    /// Human-readable error message
7772    pub message: String,
7773}
7774
7775/// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
7776#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7777#[serde(rename_all = "camelCase")]
7778pub struct McpAppToolCallCompleteToolMetaUI {
7779    /// `ui://` URI declared by the tool's `_meta.ui.resourceUri`
7780    #[serde(skip_serializing_if = "Option::is_none")]
7781    pub resource_uri: Option<String>,
7782    /// Tool visibility per SEP-1865 (typically a subset of `["model","app"]`)
7783    #[serde(skip_serializing_if = "Option::is_none")]
7784    pub visibility: Option<Vec<String>>,
7785}
7786
7787/// 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.
7788#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7789#[serde(rename_all = "camelCase")]
7790pub struct McpAppToolCallCompleteToolMeta {
7791    /// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
7792    #[serde(skip_serializing_if = "Option::is_none")]
7793    pub ui: Option<McpAppToolCallCompleteToolMetaUI>,
7794}
7795
7796/// Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
7797#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7798#[serde(rename_all = "camelCase")]
7799pub struct McpAppToolCallCompleteData {
7800    /// Arguments passed to the tool by the app view, if any
7801    #[serde(skip_serializing_if = "Option::is_none")]
7802    pub arguments: Option<HashMap<String, serde_json::Value>>,
7803    /// Wall-clock duration of the underlying tools/call in milliseconds
7804    pub duration_ms: f64,
7805    /// Set when the underlying tools/call threw an error before returning a CallToolResult
7806    #[serde(skip_serializing_if = "Option::is_none")]
7807    pub error: Option<McpAppToolCallCompleteError>,
7808    /// Standard MCP CallToolResult returned by the server. Present whether or not the call set isError.
7809    #[serde(skip_serializing_if = "Option::is_none")]
7810    pub result: Option<HashMap<String, serde_json::Value>>,
7811    /// Name of the MCP server hosting the tool
7812    pub server_name: String,
7813    /// True when the call completed without throwing AND the MCP CallToolResult did not set isError
7814    pub success: bool,
7815    /// 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.
7816    #[serde(skip_serializing_if = "Option::is_none")]
7817    pub tool_meta: Option<McpAppToolCallCompleteToolMeta>,
7818    /// MCP tool name that was invoked
7819    pub tool_name: String,
7820}
7821
7822/// Session event "session.indexed_search". Transient indexed-search status and diagnostics from the live runtime service. Never persisted or used to infer activation from session history.
7823pub type SessionIndexedSearchData = IndexedSearchData;
7824
7825/// Routing preference used when the session model is `auto`. `fast` is an integrator-only latency preset and is not a first-party GitHub Copilot product preference.
7826#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7827pub enum AutoTier {
7828    /// Optimize for efficiency.
7829    #[serde(rename = "efficiency")]
7830    Efficiency,
7831    /// Balance efficiency and intelligence.
7832    #[serde(rename = "balance")]
7833    Balance,
7834    /// Optimize for intelligence.
7835    #[serde(rename = "intelligence")]
7836    Intelligence,
7837    /// Integrator-only preset that optimizes for latency.
7838    #[serde(rename = "fast")]
7839    Fast,
7840    /// Unknown variant for forward compatibility.
7841    #[default]
7842    #[serde(other)]
7843    Unknown,
7844}
7845
7846/// Hosting platform type of the repository (github or ado)
7847#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7848pub enum WorkingDirectoryContextHostType {
7849    /// Repository is hosted on GitHub.
7850    #[serde(rename = "github")]
7851    GitHub,
7852    /// Repository is hosted on Azure DevOps.
7853    #[serde(rename = "ado")]
7854    Ado,
7855    /// Unknown variant for forward compatibility.
7856    #[default]
7857    #[serde(other)]
7858    Unknown,
7859}
7860
7861/// Allowed values for the `ContextTier` enumeration.
7862#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7863pub enum ContextTier {
7864    /// Default context tier with standard context window size.
7865    #[serde(rename = "default")]
7866    Default,
7867    /// Extended context tier with a larger context window.
7868    #[serde(rename = "long_context")]
7869    LongContext,
7870    /// Unknown variant for forward compatibility.
7871    #[default]
7872    #[serde(other)]
7873    Unknown,
7874}
7875
7876/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
7877#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7878pub enum ReasoningSummary {
7879    /// Do not request reasoning summaries from the model.
7880    #[serde(rename = "none")]
7881    None,
7882    /// Request a concise summary of the model's reasoning.
7883    #[serde(rename = "concise")]
7884    Concise,
7885    /// Request a detailed summary of the model's reasoning.
7886    #[serde(rename = "detailed")]
7887    Detailed,
7888    /// Unknown variant for forward compatibility.
7889    #[default]
7890    #[serde(other)]
7891    Unknown,
7892}
7893
7894/// Output verbosity level used for supported model calls (e.g. "low", "medium", "high")
7895#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7896pub enum Verbosity {
7897    /// A terse response was requested.
7898    #[serde(rename = "low")]
7899    Low,
7900    /// A medium amount of response detail was requested.
7901    #[serde(rename = "medium")]
7902    Medium,
7903    /// A more detailed response was requested.
7904    #[serde(rename = "high")]
7905    High,
7906    /// Unknown variant for forward compatibility.
7907    #[default]
7908    #[serde(other)]
7909    Unknown,
7910}
7911
7912/// What the user must do to recover from a failure, named as an action rather than as one client's affordance. The runtime cannot know which affordance a client offers — a slash command, a settings pane, a link — so the accompanying message stays host-agnostic and each client renders its own copy from this value. Absent when the runtime knows of no action the user can take.
7913#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7914pub enum RemediationAction {
7915    /// Authenticate again with the Copilot backend. The current credential is absent, expired, or rejected.
7916    #[serde(rename = "sign_in")]
7917    SignIn,
7918    /// Authenticate as a different account. The current account exists but lacks access to the requested resource.
7919    #[serde(rename = "switch_account")]
7920    SwitchAccount,
7921    /// Inspect which account is currently authenticated before deciding what to change.
7922    #[serde(rename = "show_account")]
7923    ShowAccount,
7924    /// Review or widen the sandbox policy. The blocked path or host is named by the accompanying message or by the tool result the action arrived with.
7925    #[serde(rename = "review_sandbox_policy")]
7926    ReviewSandboxPolicy,
7927    /// Permit outbound network access in the sandbox policy.
7928    #[serde(rename = "allow_sandbox_outbound")]
7929    AllowSandboxOutbound,
7930    /// Unknown variant for forward compatibility.
7931    #[default]
7932    #[serde(other)]
7933    Unknown,
7934}
7935
7936/// The session mode the agent is operating in
7937#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7938pub enum SessionMode {
7939    /// The agent is responding interactively to the user.
7940    #[serde(rename = "interactive")]
7941    Interactive,
7942    /// The agent is preparing a plan before making changes.
7943    #[serde(rename = "plan")]
7944    Plan,
7945    /// The agent is working autonomously toward task completion.
7946    #[serde(rename = "autopilot")]
7947    Autopilot,
7948    /// Unknown variant for forward compatibility.
7949    #[default]
7950    #[serde(other)]
7951    Unknown,
7952}
7953
7954/// 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.
7955#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7956pub enum ScheduleOrigin {
7957    /// The schedule was created by an explicit user action, such as `/every` or `/after`.
7958    #[serde(rename = "user")]
7959    User,
7960    /// The schedule was created by the agent via the `manage_schedule` tool.
7961    #[serde(rename = "model")]
7962    Model,
7963    /// Unknown variant for forward compatibility.
7964    #[default]
7965    #[serde(other)]
7966    Unknown,
7967}
7968
7969/// The type of operation performed on the autopilot objective state file
7970#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7971pub enum AutopilotObjectiveChangedOperation {
7972    /// Autopilot objective state file was created for a new objective.
7973    #[serde(rename = "create")]
7974    Create,
7975    /// Autopilot objective state file was updated for an existing objective.
7976    #[serde(rename = "update")]
7977    Update,
7978    /// Autopilot objective state file was deleted or cleared.
7979    #[serde(rename = "delete")]
7980    Delete,
7981    /// Unknown variant for forward compatibility.
7982    #[default]
7983    #[serde(other)]
7984    Unknown,
7985}
7986
7987/// Current autopilot objective status, if one exists
7988#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7989pub enum AutopilotObjectiveChangedStatus {
7990    /// Objective is active and can drive autopilot continuations.
7991    #[serde(rename = "active")]
7992    Active,
7993    /// Objective is paused and will not drive autopilot continuations.
7994    #[serde(rename = "paused")]
7995    Paused,
7996    /// Legacy objective state indicating the previous continuation cap was reached.
7997    #[serde(rename = "cap_reached")]
7998    CapReached,
7999    /// Objective was completed by the agent.
8000    #[serde(rename = "completed")]
8001    Completed,
8002    /// Unknown variant for forward compatibility.
8003    #[default]
8004    #[serde(other)]
8005    Unknown,
8006}
8007
8008/// Indexed-search event variant discriminator.
8009#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8010pub enum IndexedSearchDataStatusKind {
8011    #[serde(rename = "status")]
8012    #[default]
8013    Status,
8014}
8015
8016/// Live indexed-search state for this session activation, never inferred from persisted history.
8017#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8018pub enum IndexedSearchState {
8019    /// Indexed search is not active for this session.
8020    #[serde(rename = "disabled")]
8021    Disabled,
8022    /// Indexed-search startup is in progress.
8023    #[serde(rename = "starting")]
8024    Starting,
8025    /// The indexed-search server started successfully; its index may still be warming.
8026    #[serde(rename = "enabled")]
8027    Enabled,
8028    /// The indexed-search server and its index are ready.
8029    #[serde(rename = "ready")]
8030    Ready,
8031    /// Indexed-search startup or the active server failed.
8032    #[serde(rename = "failed")]
8033    Failed,
8034    /// Unknown variant for forward compatibility.
8035    #[default]
8036    #[serde(other)]
8037    Unknown,
8038}
8039
8040/// Configuration, policy, or workspace condition that disabled indexed search.
8041#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8042pub enum IndexedSearchDisabledReason {
8043    /// Indexed search was explicitly disabled by the environment.
8044    #[serde(rename = "use_tgrep_false")]
8045    UseTgrepFalse,
8046    /// Search uses the external ripgrep binary instead of bundled search.
8047    #[serde(rename = "use_builtin_ripgrep_false")]
8048    UseBuiltinRipgrepFalse,
8049    /// Organization policy disables indexed search.
8050    #[serde(rename = "organization")]
8051    Organization,
8052    /// Authentication has not resolved organization policy.
8053    #[serde(rename = "organization_policy_auth_pending")]
8054    OrganizationPolicyAuthPending,
8055    /// Organization policy could not be determined.
8056    #[serde(rename = "organization_policy_unknown")]
8057    OrganizationPolicyUnknown,
8058    /// The workspace uses a virtualized or network filesystem.
8059    #[serde(rename = "virtual_filesystem")]
8060    VirtualFilesystem,
8061    /// The workspace is inside a Windows cloud-sync root.
8062    #[serde(rename = "cloud_sync_root")]
8063    CloudSyncRoot,
8064    /// The Windows cloud-sync safety check failed.
8065    #[serde(rename = "cloud_sync_detection_failed")]
8066    CloudSyncDetectionFailed,
8067    /// The workspace is not available on the runtime's local filesystem.
8068    #[serde(rename = "workspace_not_local")]
8069    WorkspaceNotLocal,
8070    /// Unknown variant for forward compatibility.
8071    #[default]
8072    #[serde(other)]
8073    Unknown,
8074}
8075
8076/// Indexed-search event variant discriminator.
8077#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8078pub enum IndexedSearchDataStartupKind {
8079    #[serde(rename = "startup")]
8080    #[default]
8081    Startup,
8082}
8083
8084/// Result of an indexed-search startup attempt.
8085#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8086pub enum IndexedSearchOutcome {
8087    /// A new indexed-search server was started.
8088    #[serde(rename = "started")]
8089    Started,
8090    /// The repository has too few files for automatic indexing.
8091    #[serde(rename = "skipped_below_threshold")]
8092    SkippedBelowThreshold,
8093    /// No Git repository was found and indexing was not forced.
8094    #[serde(rename = "skipped_no_gitroot")]
8095    SkippedNoGitroot,
8096    /// Configuration, policy, or workspace safety disabled indexing.
8097    #[serde(rename = "skipped_disabled")]
8098    SkippedDisabled,
8099    /// An existing indexed-search server was reused.
8100    #[serde(rename = "reused_existing")]
8101    ReusedExisting,
8102    /// The startup attempt failed.
8103    #[serde(rename = "failed")]
8104    Failed,
8105    /// Unknown variant for forward compatibility.
8106    #[default]
8107    #[serde(other)]
8108    Unknown,
8109}
8110
8111/// Category of an indexed-search server failure.
8112#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8113pub enum IndexedSearchErrorType {
8114    /// The indexed-search server could not be spawned.
8115    #[serde(rename = "spawn_error")]
8116    SpawnError,
8117    /// The indexed-search server exited unexpectedly.
8118    #[serde(rename = "unexpected_exit")]
8119    UnexpectedExit,
8120    /// The indexed-search server was terminated by a signal.
8121    #[serde(rename = "killed_by_signal")]
8122    KilledBySignal,
8123    /// Unknown variant for forward compatibility.
8124    #[default]
8125    #[serde(other)]
8126    Unknown,
8127}
8128
8129/// Indexed-search event variant discriminator.
8130#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8131pub enum IndexedSearchDataServerErrorKind {
8132    #[serde(rename = "server_error")]
8133    #[default]
8134    ServerError,
8135}
8136
8137/// Indexed-search event variant discriminator.
8138#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8139pub enum IndexedSearchDataIncrementalKind {
8140    #[serde(rename = "incremental")]
8141    #[default]
8142    Incremental,
8143}
8144
8145/// Phase of an incremental indexed-search update.
8146#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8147pub enum IndexedSearchIncrementalPhase {
8148    /// A workspace scan found changes to index.
8149    #[serde(rename = "changes_detected")]
8150    ChangesDetected,
8151    /// The incremental index update completed.
8152    #[serde(rename = "updated")]
8153    Updated,
8154    /// Unknown variant for forward compatibility.
8155    #[default]
8156    #[serde(other)]
8157    Unknown,
8158}
8159
8160/// Transient indexed-search status and diagnostics from the live runtime service. Never persisted or used to infer activation from session history.
8161#[derive(Debug, Clone, Serialize, Deserialize)]
8162#[serde(untagged)]
8163pub enum IndexedSearchData {
8164    Status(IndexedSearchDataStatus),
8165    Startup(IndexedSearchDataStartup),
8166    ServerError(IndexedSearchDataServerError),
8167    Incremental(IndexedSearchDataIncremental),
8168}
8169
8170/// Origin of an effective session model change.
8171#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8172pub enum ModelChangeSource {
8173    /// The user selected a model directly with `/model <id>`.
8174    #[serde(rename = "model_command")]
8175    ModelCommand,
8176    /// The user selected the model with `/settings`.
8177    #[serde(rename = "settings_command")]
8178    SettingsCommand,
8179    /// The user selected the model with the `/config` alias.
8180    #[serde(rename = "config_command")]
8181    ConfigCommand,
8182    /// The user selected the model in the model picker, including the picker opened by bare `/model`.
8183    #[serde(rename = "model_picker")]
8184    ModelPicker,
8185    /// Organization-managed settings selected the model.
8186    #[serde(rename = "managed_settings")]
8187    ManagedSettings,
8188    /// Repository settings selected the model.
8189    #[serde(rename = "repo_settings")]
8190    RepoSettings,
8191    /// Startup model resolution selected the model.
8192    #[serde(rename = "startup")]
8193    Startup,
8194    /// Selecting an agent selected its configured model.
8195    #[serde(rename = "agent")]
8196    Agent,
8197    /// Entering, leaving, or reconfiguring plan mode selected the model.
8198    #[serde(rename = "plan_mode")]
8199    PlanMode,
8200    /// The runtime selected the model automatically, such as rate-limit recovery or refusal fallback.
8201    #[serde(rename = "automatic")]
8202    Automatic,
8203    /// The user selected the promoted model from the changeboarding card or its keyboard shortcut.
8204    #[serde(rename = "changeboarding_shortcut")]
8205    ChangeboardingShortcut,
8206    /// An SDK or RPC caller selected the model.
8207    #[serde(rename = "sdk")]
8208    Sdk,
8209    /// Unknown variant for forward compatibility.
8210    #[default]
8211    #[serde(other)]
8212    Unknown,
8213}
8214
8215/// Why the session no longer has an explicitly selected model.
8216#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8217pub enum ModelDeselectedReason {
8218    /// A host-managed provider snapshot no longer publishes the selected model.
8219    #[serde(rename = "provider_withdrawn")]
8220    ProviderWithdrawn,
8221    /// Unknown variant for forward compatibility.
8222    #[default]
8223    #[serde(other)]
8224    Unknown,
8225}
8226
8227/// Auto preferences that Copilot API can recommend.
8228#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8229pub enum RecommendedAutoTier {
8230    /// Optimize for efficiency.
8231    #[serde(rename = "efficiency")]
8232    Efficiency,
8233    /// Balance efficiency and intelligence.
8234    #[serde(rename = "balance")]
8235    Balance,
8236    /// Optimize for intelligence.
8237    #[serde(rename = "intelligence")]
8238    Intelligence,
8239    /// Unknown variant for forward compatibility.
8240    #[default]
8241    #[serde(other)]
8242    Unknown,
8243}
8244
8245/// Terminal reason an Auto preference activation failed.
8246#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8247pub enum AutoTierSwitchFailureReason {
8248    /// The candidate model was rejected by model policy.
8249    #[serde(rename = "policy_rejected")]
8250    PolicyRejected,
8251    /// The Auto routing request failed or returned an unusable response.
8252    #[serde(rename = "request_failed")]
8253    RequestFailed,
8254    /// The runtime could not prepare the Auto routing request.
8255    #[serde(rename = "setup_failed")]
8256    SetupFailed,
8257    /// The provider does not support Auto routing.
8258    #[serde(rename = "unsupported")]
8259    Unsupported,
8260    /// Unknown variant for forward compatibility.
8261    #[default]
8262    #[serde(other)]
8263    Unknown,
8264}
8265
8266/// Permission mode for the session.
8267///
8268/// <div class="warning">
8269///
8270/// **Experimental.** This type is part of an experimental wire-protocol surface
8271/// and may change or be removed in future SDK or CLI releases.
8272///
8273/// </div>
8274#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8275pub enum PermissionMode {
8276    /// Permission requests follow the normal approval flow.
8277    #[serde(rename = "manual")]
8278    Manual,
8279    /// Permission requests include an LLM safety recommendation; clients may automatically approve requests judged acceptable.
8280    #[serde(rename = "assisted")]
8281    Assisted,
8282    /// Tool, path, and URL permission requests are automatically approved.
8283    #[serde(rename = "allow-all")]
8284    AllowAll,
8285    /// Unknown variant for forward compatibility.
8286    #[default]
8287    #[serde(other)]
8288    Unknown,
8289}
8290
8291/// The type of operation performed on the plan file
8292#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8293pub enum PlanChangedOperation {
8294    /// The plan file was created.
8295    #[serde(rename = "create")]
8296    Create,
8297    /// The plan file was updated.
8298    #[serde(rename = "update")]
8299    Update,
8300    /// The plan file was deleted.
8301    #[serde(rename = "delete")]
8302    Delete,
8303    /// Unknown variant for forward compatibility.
8304    #[default]
8305    #[serde(other)]
8306    Unknown,
8307}
8308
8309/// Whether the file was newly created or updated
8310#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8311pub enum WorkspaceFileChangedOperation {
8312    /// The workspace file was created.
8313    #[serde(rename = "create")]
8314    Create,
8315    /// The workspace file was updated.
8316    #[serde(rename = "update")]
8317    Update,
8318    /// Unknown variant for forward compatibility.
8319    #[default]
8320    #[serde(other)]
8321    Unknown,
8322}
8323
8324/// Origin type of the session being handed off
8325#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8326pub enum HandoffSourceType {
8327    /// The handoff originated from a remote session.
8328    #[serde(rename = "remote")]
8329    Remote,
8330    /// The handoff originated from a local session.
8331    #[serde(rename = "local")]
8332    Local,
8333    /// Unknown variant for forward compatibility.
8334    #[default]
8335    #[serde(other)]
8336    Unknown,
8337}
8338
8339/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
8340#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8341pub enum ShutdownType {
8342    /// The session ended normally.
8343    #[serde(rename = "routine")]
8344    Routine,
8345    /// The session ended because of a crash or fatal error.
8346    #[serde(rename = "error")]
8347    Error,
8348    /// Unknown variant for forward compatibility.
8349    #[default]
8350    #[serde(other)]
8351    Unknown,
8352}
8353
8354/// What initiated a conversation compaction
8355#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8356pub enum CompactionTrigger {
8357    /// Background compaction started automatically because context utilization crossed the background threshold.
8358    #[serde(rename = "threshold")]
8359    Threshold,
8360    /// Compaction forced by a context-limit model response (e.g. HTTP 413) before retrying the request.
8361    #[serde(rename = "context_limit_retry")]
8362    ContextLimitRetry,
8363    /// User-requested compaction, e.g. the /compact command or the history.compact API.
8364    #[serde(rename = "manual")]
8365    Manual,
8366    /// Emergency compaction triggered by high process memory usage.
8367    #[serde(rename = "memory_pressure")]
8368    MemoryPressure,
8369    /// Compaction requested while switching to a model with a smaller context window.
8370    #[serde(rename = "model_switch")]
8371    ModelSwitch,
8372    /// Unknown variant for forward compatibility.
8373    #[default]
8374    #[serde(other)]
8375    Unknown,
8376}
8377
8378/// Category of structured task blocker
8379#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8380pub enum TaskBlockerKind {
8381    /// Autopilot permission recovery requires intervention or has no safe autonomous path.
8382    #[serde(rename = "permission_recovery")]
8383    PermissionRecovery,
8384    /// Unknown variant for forward compatibility.
8385    #[default]
8386    #[serde(other)]
8387    Unknown,
8388}
8389
8390/// Runtime handling applied to a recovery attempt
8391#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8392pub enum PermissionRecoveryAttemptDisposition {
8393    /// The request was denied without prompting so the agent could try an alternative.
8394    #[serde(rename = "deferred")]
8395    Deferred,
8396    /// The request was surfaced to an interactive responder.
8397    #[serde(rename = "prompted")]
8398    Prompted,
8399    /// The interactive responder approved the request.
8400    #[serde(rename = "approved")]
8401    Approved,
8402    /// The interactive responder denied the request or became unavailable.
8403    #[serde(rename = "denied")]
8404    Denied,
8405    /// The request exhausted unattended recovery and produced a blocked outcome.
8406    #[serde(rename = "blocked")]
8407    Blocked,
8408    /// A tool call succeeded as an equivalent alternative.
8409    #[serde(rename = "succeeded")]
8410    Succeeded,
8411    /// Unknown variant for forward compatibility.
8412    #[default]
8413    #[serde(other)]
8414    Unknown,
8415}
8416
8417/// Controlled reason for an individual attempt disposition
8418#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8419pub enum PermissionRecoveryAttemptReason {
8420    /// The attempt required permission that Assisted Permissions could not grant.
8421    #[serde(rename = "permission_required")]
8422    PermissionRequired,
8423    /// The request repeated an earlier attempt.
8424    #[serde(rename = "repeated_attempt")]
8425    RepeatedAttempt,
8426    /// The request exceeded the bounded number of distinct attempts.
8427    #[serde(rename = "attempts_exhausted")]
8428    AttemptsExhausted,
8429    /// The interactive responder approved the request.
8430    #[serde(rename = "permission_approved")]
8431    PermissionApproved,
8432    /// The interactive responder denied the request.
8433    #[serde(rename = "permission_denied")]
8434    PermissionDenied,
8435    /// The interactive responder became unavailable.
8436    #[serde(rename = "responder_unavailable")]
8437    ResponderUnavailable,
8438    /// The tool call succeeded without the blocked permission.
8439    #[serde(rename = "equivalent_alternative_succeeded")]
8440    EquivalentAlternativeSucceeded,
8441    /// Unknown variant for forward compatibility.
8442    #[default]
8443    #[serde(other)]
8444    Unknown,
8445}
8446
8447/// Relationship of an attempt to earlier permission requests
8448#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8449pub enum PermissionRecoveryAttemptRelation {
8450    /// The first denied permission request in the episode.
8451    #[serde(rename = "initial")]
8452    Initial,
8453    /// A request equivalent to an earlier attempt.
8454    #[serde(rename = "retry")]
8455    Retry,
8456    /// A distinct request or a successful alternative tool call.
8457    #[serde(rename = "alternative")]
8458    Alternative,
8459    /// Unknown variant for forward compatibility.
8460    #[default]
8461    #[serde(other)]
8462    Unknown,
8463}
8464
8465/// Action selected when autonomous recovery cannot continue
8466#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8467pub enum PermissionRecoveryOnBlocked {
8468    /// Surface the existing permission prompt to a response-capable client.
8469    #[serde(rename = "ask")]
8470    Ask,
8471    /// Return a structured unsuccessful blocked outcome because no responder is available.
8472    #[serde(rename = "fail")]
8473    Fail,
8474    /// Unknown variant for forward compatibility.
8475    #[default]
8476    #[serde(other)]
8477    Unknown,
8478}
8479
8480/// Controlled reason for a permission-recovery episode transition
8481#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8482pub enum PermissionRecoveryReason {
8483    /// An action required permission that Assisted Permissions could not grant.
8484    #[serde(rename = "permission_required")]
8485    PermissionRequired,
8486    /// The agent repeated an equivalent permission request instead of making progress.
8487    #[serde(rename = "repeated_attempt")]
8488    RepeatedAttempt,
8489    /// The bounded number of distinct permission attempts was exhausted.
8490    #[serde(rename = "attempts_exhausted")]
8491    AttemptsExhausted,
8492    /// A responder approved the escalated permission request.
8493    #[serde(rename = "permission_approved")]
8494    PermissionApproved,
8495    /// A responder denied the escalated permission request.
8496    #[serde(rename = "permission_denied")]
8497    PermissionDenied,
8498    /// The response-capable client became unavailable while escalation was pending.
8499    #[serde(rename = "responder_unavailable")]
8500    ResponderUnavailable,
8501    /// A later tool call succeeded without requiring the blocked permission.
8502    #[serde(rename = "equivalent_alternative_succeeded")]
8503    EquivalentAlternativeSucceeded,
8504    /// Unknown variant for forward compatibility.
8505    #[default]
8506    #[serde(other)]
8507    Unknown,
8508}
8509
8510/// Lifecycle state of a permission-recovery episode
8511#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8512pub enum PermissionRecoveryStatus {
8513    /// Autopilot may try a bounded equivalent alternative.
8514    #[serde(rename = "recovering")]
8515    Recovering,
8516    /// An interactive permission response is required.
8517    #[serde(rename = "awaiting_approval")]
8518    AwaitingApproval,
8519    /// The episode ended through approval or a successful equivalent alternative.
8520    #[serde(rename = "resolved")]
8521    Resolved,
8522    /// No autonomous path remains and the task requires intervention.
8523    #[serde(rename = "blocked")]
8524    Blocked,
8525    /// Unknown variant for forward compatibility.
8526    #[default]
8527    #[serde(other)]
8528    Unknown,
8529}
8530
8531/// Semantic result of evaluating a task completion request
8532#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8533pub enum TaskCompletionOutcome {
8534    /// The completion request was accepted and the objective is complete.
8535    #[serde(rename = "completed")]
8536    Completed,
8537    /// The completion request was rejected because more work or validation remains.
8538    #[serde(rename = "continue")]
8539    Continue,
8540    /// Completion cannot proceed without intervention; the active objective is paused when one is identified.
8541    #[serde(rename = "blocked")]
8542    Blocked,
8543    /// Unknown variant for forward compatibility.
8544    #[default]
8545    #[serde(other)]
8546    Unknown,
8547}
8548
8549/// Structured terminal status from a tool completion event.
8550#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8551pub enum CompletionReceiptToolStatus {
8552    /// The tool completed successfully.
8553    #[serde(rename = "success")]
8554    Success,
8555    /// The tool failed without a more specific structured status.
8556    #[serde(rename = "failure")]
8557    Failure,
8558    /// The tool exceeded its time budget.
8559    #[serde(rename = "timeout")]
8560    Timeout,
8561    /// The user rejected the tool call.
8562    #[serde(rename = "rejected")]
8563    Rejected,
8564    /// The permissions service denied the tool call.
8565    #[serde(rename = "denied")]
8566    Denied,
8567    /// Unknown variant for forward compatibility.
8568    #[default]
8569    #[serde(other)]
8570    Unknown,
8571}
8572
8573/// Runtime reason the completion decision was accepted.
8574#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8575pub enum CompletionReceiptStopReason {
8576    /// The model reached a natural terminal response.
8577    #[serde(rename = "natural")]
8578    Natural,
8579    /// A terminal tool ended the interaction.
8580    #[serde(rename = "terminal_tool")]
8581    TerminalTool,
8582    /// The configured agentStop continuation limit was reached.
8583    #[serde(rename = "agent_stop_block_limit")]
8584    AgentStopBlockLimit,
8585    /// Unknown variant for forward compatibility.
8586    #[default]
8587    #[serde(other)]
8588    Unknown,
8589}
8590
8591/// Kind of turn for which HydraFusion routing is running.
8592///
8593/// <div class="warning">
8594///
8595/// **Experimental.** This type is part of an experimental wire-protocol surface
8596/// and may change or be removed in future SDK or CLI releases.
8597///
8598/// </div>
8599#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8600pub enum FusionTurnKind {
8601    /// A user-message turn.
8602    #[serde(rename = "user")]
8603    User,
8604    /// A conversation-compaction turn.
8605    #[serde(rename = "compaction")]
8606    Compaction,
8607    /// Unknown variant for forward compatibility.
8608    #[default]
8609    #[serde(other)]
8610    Unknown,
8611}
8612
8613/// Server-recommended routing behavior for a later HydraFusion turn.
8614///
8615/// <div class="warning">
8616///
8617/// **Experimental.** This type is part of an experimental wire-protocol surface
8618/// and may change or be removed in future SDK or CLI releases.
8619///
8620/// </div>
8621#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8622pub enum FusionFollowUpAction {
8623    /// Reuse the durable primary model without routing.
8624    #[serde(rename = "reuse_primary")]
8625    ReusePrimary,
8626    /// Request a new routing decision.
8627    #[serde(rename = "reroute")]
8628    Reroute,
8629    /// Unknown variant for forward compatibility.
8630    #[default]
8631    #[serde(other)]
8632    Unknown,
8633}
8634
8635/// Validated HydraFusion execution pattern.
8636///
8637/// <div class="warning">
8638///
8639/// **Experimental.** This type is part of an experimental wire-protocol surface
8640/// and may change or be removed in future SDK or CLI releases.
8641///
8642/// </div>
8643#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8644pub enum FusionPattern {
8645    /// Run one primary solver phase.
8646    #[serde(rename = "single")]
8647    Single,
8648    /// Run a primary phase, a judge, and an optional repair.
8649    #[serde(rename = "cascade")]
8650    Cascade,
8651    /// Run a primary draft, a read-only critique, and a revision.
8652    #[serde(rename = "critique")]
8653    Critique,
8654    /// Unknown variant for forward compatibility.
8655    #[default]
8656    #[serde(other)]
8657    Unknown,
8658}
8659
8660/// HydraFusion phase kind.
8661///
8662/// <div class="warning">
8663///
8664/// **Experimental.** This type is part of an experimental wire-protocol surface
8665/// and may change or be removed in future SDK or CLI releases.
8666///
8667/// </div>
8668#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8669pub enum FusionPhaseKind {
8670    /// Primary solver phase.
8671    #[serde(rename = "primary")]
8672    Primary,
8673    /// Read-only cascade judge phase.
8674    #[serde(rename = "judge")]
8675    Judge,
8676    /// Cascade repair phase.
8677    #[serde(rename = "repair")]
8678    Repair,
8679    /// Initial critique-pattern draft phase.
8680    #[serde(rename = "draft")]
8681    Draft,
8682    /// Read-only critique phase.
8683    #[serde(rename = "critic")]
8684    Critic,
8685    /// Critique-pattern revision phase.
8686    #[serde(rename = "revision")]
8687    Revision,
8688    /// Follow-up phase continuing from the resolved model.
8689    #[serde(rename = "follow_up")]
8690    FollowUp,
8691    /// Unknown variant for forward compatibility.
8692    #[default]
8693    #[serde(other)]
8694    Unknown,
8695}
8696
8697/// Conversation scope in which a HydraFusion phase executes.
8698///
8699/// <div class="warning">
8700///
8701/// **Experimental.** This type is part of an experimental wire-protocol surface
8702/// and may change or be removed in future SDK or CLI releases.
8703///
8704/// </div>
8705#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8706pub enum FusionConversationScope {
8707    /// Canonical root conversation history.
8708    #[serde(rename = "root")]
8709    Root,
8710    /// Isolated read-only review history that does not enter the root conversation.
8711    #[serde(rename = "review")]
8712    Review,
8713    /// Unknown variant for forward compatibility.
8714    #[default]
8715    #[serde(other)]
8716    Unknown,
8717}
8718
8719/// The agent mode that was active when this message was sent
8720#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8721pub enum UserMessageAgentMode {
8722    /// The agent is responding interactively to the user.
8723    #[serde(rename = "interactive")]
8724    Interactive,
8725    /// The agent is preparing a plan before making changes.
8726    #[serde(rename = "plan")]
8727    Plan,
8728    /// The agent is working autonomously toward task completion.
8729    #[serde(rename = "autopilot")]
8730    Autopilot,
8731    /// The agent is in shell-focused UI mode.
8732    #[serde(rename = "shell")]
8733    Shell,
8734    /// Unknown variant for forward compatibility.
8735    #[default]
8736    #[serde(other)]
8737    Unknown,
8738}
8739
8740/// 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.
8741#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8742pub enum UserMessageDelivery {
8743    /// Delivered while the loop was idle; starts its own run immediately (a human's fresh turn, or a system notification waking an idle agent).
8744    #[serde(rename = "idle")]
8745    Idle,
8746    /// Injected into the current in-flight run while the agent was busy (immediate mode).
8747    #[serde(rename = "steering")]
8748    Steering,
8749    /// Enqueued while the agent was busy; processed as its own run afterward.
8750    #[serde(rename = "queued")]
8751    Queued,
8752    /// Unknown variant for forward compatibility.
8753    #[default]
8754    #[serde(other)]
8755    Unknown,
8756}
8757
8758/// What the agent was doing when the user interrupted it.
8759#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8760pub enum AgentInterruptedActivity {
8761    /// A request to the model was open.
8762    #[serde(rename = "model_call")]
8763    ModelCall,
8764    /// The turn was sleeping between retry attempts.
8765    #[serde(rename = "retry_backoff")]
8766    RetryBackoff,
8767    /// One or more tools were executing.
8768    #[serde(rename = "tool_call")]
8769    ToolCall,
8770    /// Background sub-agents were running while the main loop was idle.
8771    #[serde(rename = "background_agent")]
8772    BackgroundAgent,
8773    /// Unknown variant for forward compatibility.
8774    #[default]
8775    #[serde(other)]
8776    Unknown,
8777}
8778
8779/// Where the interruption landed relative to the first streamed token.
8780#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8781pub enum AgentInterruptedCancelPhase {
8782    /// No output had been produced when the request was cancelled.
8783    #[serde(rename = "pre_first_token")]
8784    PreFirstToken,
8785    /// The response was already streaming when the request was cancelled.
8786    #[serde(rename = "mid_stream")]
8787    MidStream,
8788    /// Unknown variant for forward compatibility.
8789    #[default]
8790    #[serde(other)]
8791    Unknown,
8792}
8793
8794/// Transport used for a failed model call
8795#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8796pub enum ModelCallFailureTransport {
8797    /// HTTP transport, including SSE streams.
8798    #[serde(rename = "http")]
8799    Http,
8800    /// WebSocket transport.
8801    #[serde(rename = "websocket")]
8802    Websocket,
8803    /// Unknown variant for forward compatibility.
8804    #[default]
8805    #[serde(other)]
8806    Unknown,
8807}
8808
8809/// Content-safe activity observed while a HydraFusion phase is running.
8810///
8811/// <div class="warning">
8812///
8813/// **Experimental.** This type is part of an experimental wire-protocol surface
8814/// and may change or be removed in future SDK or CLI releases.
8815///
8816/// </div>
8817#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8818pub enum FusionPhaseActivityKind {
8819    /// The provider produced additional private output bytes.
8820    #[serde(rename = "model_output")]
8821    ModelOutput,
8822    /// A tool began executing inside the phase.
8823    #[serde(rename = "tool_started")]
8824    ToolStarted,
8825    /// A tool finished executing inside the phase.
8826    #[serde(rename = "tool_completed")]
8827    ToolCompleted,
8828    /// Unknown variant for forward compatibility.
8829    #[default]
8830    #[serde(other)]
8831    Unknown,
8832}
8833
8834/// How a durable phase checkpoint contributes its exact message to canonical root history.
8835///
8836/// <div class="warning">
8837///
8838/// **Experimental.** This type is part of an experimental wire-protocol surface
8839/// and may change or be removed in future SDK or CLI releases.
8840///
8841/// </div>
8842#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8843pub enum FusionProjectionMode {
8844    /// Append the exact root message immediately.
8845    #[serde(rename = "append")]
8846    Append,
8847    /// Hold a terminal message outside canonical history until the final commit selects it.
8848    #[serde(rename = "staged")]
8849    Staged,
8850    /// Do not project the checkpoint into root history.
8851    #[serde(rename = "none")]
8852    None,
8853    /// Unknown variant for forward compatibility.
8854    #[default]
8855    #[serde(other)]
8856    Unknown,
8857}
8858
8859/// Durable outcome status of a HydraFusion phase.
8860///
8861/// <div class="warning">
8862///
8863/// **Experimental.** This type is part of an experimental wire-protocol surface
8864/// and may change or be removed in future SDK or CLI releases.
8865///
8866/// </div>
8867#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8868pub enum FusionPhaseStatus {
8869    /// The phase completed successfully.
8870    #[serde(rename = "succeeded")]
8871    Succeeded,
8872    /// The phase failed.
8873    #[serde(rename = "failed")]
8874    Failed,
8875    /// The phase was cancelled.
8876    #[serde(rename = "cancelled")]
8877    Cancelled,
8878    /// Unknown variant for forward compatibility.
8879    #[default]
8880    #[serde(other)]
8881    Unknown,
8882}
8883
8884/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
8885#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8886pub enum AssistantMessageToolRequestType {
8887    /// Standard function-style tool call.
8888    #[serde(rename = "function")]
8889    Function,
8890    /// Custom grammar-based tool call.
8891    #[serde(rename = "custom")]
8892    Custom,
8893    /// Unknown variant for forward compatibility.
8894    #[default]
8895    #[serde(other)]
8896    Unknown,
8897}
8898
8899/// The system that produced a citation.
8900///
8901/// <div class="warning">
8902///
8903/// **Experimental.** This type is part of an experimental wire-protocol surface
8904/// and may change or be removed in future SDK or CLI releases.
8905///
8906/// </div>
8907#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8908pub enum CitationProvider {
8909    /// Citation produced by an Anthropic (Claude) model response.
8910    #[serde(rename = "anthropic")]
8911    Anthropic,
8912    /// Citation produced by an OpenAI model response.
8913    #[serde(rename = "openai")]
8914    Openai,
8915    /// Citation synthesized client-side by the runtime from tool output.
8916    #[serde(rename = "client")]
8917    Client,
8918    /// Unknown variant for forward compatibility.
8919    #[default]
8920    #[serde(other)]
8921    Unknown,
8922}
8923
8924/// Hosted program caller type
8925#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8926pub enum AssistantMessageToolRequestCallerType {
8927    #[serde(rename = "program")]
8928    Program,
8929    /// Unknown variant for forward compatibility.
8930    #[default]
8931    #[serde(other)]
8932    Unknown,
8933}
8934
8935/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
8936#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8937pub enum AssistantUsageApiEndpoint {
8938    /// Chat Completions API endpoint.
8939    #[serde(rename = "/chat/completions")]
8940    ChatCompletions,
8941    /// Anthropic Messages API endpoint.
8942    #[serde(rename = "/v1/messages")]
8943    V1Messages,
8944    /// Responses API endpoint.
8945    #[serde(rename = "/responses")]
8946    Responses,
8947    /// WebSocket Responses API endpoint.
8948    #[serde(rename = "ws:/responses")]
8949    WsResponses,
8950    /// Unknown variant for forward compatibility.
8951    #[default]
8952    #[serde(other)]
8953    Unknown,
8954}
8955
8956/// Transport used for a successful model call
8957#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8958pub enum AssistantUsageTransport {
8959    /// HTTP transport, including SSE streams.
8960    #[serde(rename = "http")]
8961    Http,
8962    /// WebSocket transport.
8963    #[serde(rename = "websocket")]
8964    Websocket,
8965    /// Unknown variant for forward compatibility.
8966    #[default]
8967    #[serde(other)]
8968    Unknown,
8969}
8970
8971/// 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.
8972#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8973pub enum ModelCallFailureBadRequestKind {
8974    /// The 400 response carried no error body (transient gateway/proxy signature).
8975    #[serde(rename = "bodyless")]
8976    Bodyless,
8977    /// The 400 response carried a structured CAPI error envelope (deterministic validation failure).
8978    #[serde(rename = "structured_error")]
8979    StructuredError,
8980    /// Unknown variant for forward compatibility.
8981    #[default]
8982    #[serde(other)]
8983    Unknown,
8984}
8985
8986/// Boundary that produced a model call failure
8987#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8988pub enum ModelCallFailureKind {
8989    /// The provider returned an API error response.
8990    #[serde(rename = "api")]
8991    Api,
8992    /// The request transport failed before a usable API response completed.
8993    #[serde(rename = "transport")]
8994    Transport,
8995    /// Unknown variant for forward compatibility.
8996    #[default]
8997    #[serde(other)]
8998    Unknown,
8999}
9000
9001/// Where the failed model call originated
9002#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9003pub enum ModelCallFailureSource {
9004    /// Model call from the top-level agent.
9005    #[serde(rename = "top_level")]
9006    TopLevel,
9007    /// Model call from a sub-agent.
9008    #[serde(rename = "subagent")]
9009    Subagent,
9010    /// Model call from MCP sampling.
9011    #[serde(rename = "mcp_sampling")]
9012    McpSampling,
9013    /// Unknown variant for forward compatibility.
9014    #[default]
9015    #[serde(other)]
9016    Unknown,
9017}
9018
9019/// Final outcome of one logical model dispatch after response acceptance processing
9020#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9021pub enum ModelCallFinishedOutcome {
9022    /// The provider response was accepted for continued agent processing.
9023    #[serde(rename = "success")]
9024    Success,
9025    /// The dispatch ended with a provider or transport error.
9026    #[serde(rename = "error")]
9027    Error,
9028    /// The dispatch was cancelled before an accepted response was produced.
9029    #[serde(rename = "cancelled")]
9030    Cancelled,
9031    /// The provider response was rejected during post-response acceptance processing.
9032    #[serde(rename = "rejected")]
9033    Rejected,
9034    /// Unknown variant for forward compatibility.
9035    #[default]
9036    #[serde(other)]
9037    Unknown,
9038}
9039
9040/// Finite reason code describing why the current turn was aborted
9041#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9042pub enum AbortReason {
9043    /// The local user requested the abort, for example by pressing Ctrl+C in the CLI.
9044    #[serde(rename = "user_initiated")]
9045    UserInitiated,
9046    /// A remote command requested the abort.
9047    #[serde(rename = "remote_command")]
9048    RemoteCommand,
9049    /// An MCP server delivered a user.abort notification.
9050    #[serde(rename = "user_abort")]
9051    UserAbort,
9052    /// Autopilot stopped the run because the active objective reached its user-set --max-ai-credits limit.
9053    #[serde(rename = "autopilot_credit_limit")]
9054    AutopilotCreditLimit,
9055    /// Unknown variant for forward compatibility.
9056    #[default]
9057    #[serde(other)]
9058    Unknown,
9059}
9060
9061/// Configuration source: user, workspace, plugin, builtin, or managed
9062#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9063pub enum McpServerSource {
9064    /// Server configured in the user's global MCP configuration.
9065    #[serde(rename = "user")]
9066    User,
9067    /// Server configured by the current workspace.
9068    #[serde(rename = "workspace")]
9069    Workspace,
9070    /// Server contributed by an installed plugin.
9071    #[serde(rename = "plugin")]
9072    Plugin,
9073    /// Server bundled with the runtime.
9074    #[serde(rename = "builtin")]
9075    Builtin,
9076    /// Server supplied by a trusted host-managed catalog.
9077    #[serde(rename = "managed")]
9078    Managed,
9079    /// Unknown variant for forward compatibility.
9080    #[default]
9081    #[serde(other)]
9082    Unknown,
9083}
9084
9085/// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
9086#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9087pub enum McpServerTransport {
9088    /// Server communicates over stdio with a local child process.
9089    #[serde(rename = "stdio")]
9090    Stdio,
9091    /// Server communicates over streamable HTTP.
9092    #[serde(rename = "http")]
9093    Http,
9094    /// Server communicates over Server-Sent Events (deprecated).
9095    #[serde(rename = "sse")]
9096    Sse,
9097    /// Server is backed by an in-memory runtime implementation.
9098    #[serde(rename = "memory")]
9099    Memory,
9100    /// Unknown variant for forward compatibility.
9101    #[default]
9102    #[serde(other)]
9103    Unknown,
9104}
9105
9106/// Allowed values for the `ToolExecutionStartToolDescriptionMetaUIVisibility` enumeration.
9107#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9108pub enum ToolExecutionStartToolDescriptionMetaUIVisibility {
9109    /// Tool is callable by the model (LLM tool surface)
9110    #[serde(rename = "model")]
9111    Model,
9112    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
9113    #[serde(rename = "app")]
9114    App,
9115    /// Unknown variant for forward compatibility.
9116    #[default]
9117    #[serde(other)]
9118    Unknown,
9119}
9120
9121/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9122#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9123pub enum PersistedBinaryImageType {
9124    /// Binary image data.
9125    #[serde(rename = "image")]
9126    Image,
9127    /// Other binary resource data.
9128    #[serde(rename = "resource")]
9129    Resource,
9130    /// Unknown variant for forward compatibility.
9131    #[default]
9132    #[serde(other)]
9133    Unknown,
9134}
9135
9136/// Why the binary data is absent: it exceeded the inline size limit, or its asset was unavailable
9137#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9138pub enum OmittedBinaryOmittedReason {
9139    /// Bytes exceeded the session's inline size limit.
9140    #[serde(rename = "too_large")]
9141    TooLarge,
9142    /// The referenced binary asset could not be found (e.g. a truncated log).
9143    #[serde(rename = "asset_unavailable")]
9144    AssetUnavailable,
9145    /// Unknown variant for forward compatibility.
9146    #[default]
9147    #[serde(other)]
9148    Unknown,
9149}
9150
9151/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9152#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9153pub enum OmittedBinaryType {
9154    /// Binary image data.
9155    #[serde(rename = "image")]
9156    Image,
9157    /// Other binary resource data.
9158    #[serde(rename = "resource")]
9159    Resource,
9160    /// Unknown variant for forward compatibility.
9161    #[default]
9162    #[serde(other)]
9163    Unknown,
9164}
9165
9166/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9167#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9168pub enum BinaryAssetReferenceType {
9169    /// Binary image data.
9170    #[serde(rename = "image")]
9171    Image,
9172    /// Other binary resource data.
9173    #[serde(rename = "resource")]
9174    Resource,
9175    /// Unknown variant for forward compatibility.
9176    #[default]
9177    #[serde(other)]
9178    Unknown,
9179}
9180
9181/// A model-facing binary result as persisted: full inline data, a size-omitted marker, or a deduplicated asset reference
9182///
9183/// <div class="warning">
9184///
9185/// **Experimental.** This type is part of an experimental wire-protocol surface
9186/// and may change or be removed in future SDK or CLI releases.
9187///
9188/// </div>
9189#[derive(Debug, Clone, Serialize, Deserialize)]
9190#[serde(untagged)]
9191pub enum PersistedBinaryResult {
9192    PersistedBinaryImage(PersistedBinaryImage),
9193    OmittedBinaryResult(OmittedBinaryResult),
9194    BinaryAssetReference(BinaryAssetReference),
9195}
9196
9197/// Content block type discriminator
9198#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9199pub enum ToolExecutionCompleteContentTextType {
9200    #[serde(rename = "text")]
9201    #[default]
9202    Text,
9203}
9204
9205/// Content block type discriminator
9206#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9207pub enum ToolExecutionCompleteContentTerminalType {
9208    #[serde(rename = "terminal")]
9209    #[default]
9210    Terminal,
9211}
9212
9213/// Content block type discriminator
9214#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9215pub enum ToolExecutionCompleteContentShellExitType {
9216    #[serde(rename = "shell_exit")]
9217    #[default]
9218    ShellExit,
9219}
9220
9221/// Content block type discriminator
9222#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9223pub enum ToolExecutionCompleteContentImageType {
9224    #[serde(rename = "image")]
9225    #[default]
9226    Image,
9227}
9228
9229/// Content block type discriminator
9230#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9231pub enum ToolExecutionCompleteContentAudioType {
9232    #[serde(rename = "audio")]
9233    #[default]
9234    Audio,
9235}
9236
9237/// Theme variant this icon is intended for
9238#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9239pub enum ToolExecutionCompleteContentResourceLinkIconTheme {
9240    /// Icon intended for light themes.
9241    #[serde(rename = "light")]
9242    Light,
9243    /// Icon intended for dark themes.
9244    #[serde(rename = "dark")]
9245    Dark,
9246    /// Unknown variant for forward compatibility.
9247    #[default]
9248    #[serde(other)]
9249    Unknown,
9250}
9251
9252/// Content block type discriminator
9253#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9254pub enum ToolExecutionCompleteContentResourceLinkType {
9255    #[serde(rename = "resource_link")]
9256    #[default]
9257    ResourceLink,
9258}
9259
9260/// The embedded resource contents, either text or base64-encoded binary
9261#[derive(Debug, Clone, Serialize, Deserialize)]
9262#[serde(untagged)]
9263pub enum ToolExecutionCompleteContentResourceDetails {
9264    EmbeddedTextResourceContents(EmbeddedTextResourceContents),
9265    EmbeddedBlobResourceContents(EmbeddedBlobResourceContents),
9266}
9267
9268/// Content block type discriminator
9269#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9270pub enum ToolExecutionCompleteContentResourceType {
9271    #[serde(rename = "resource")]
9272    #[default]
9273    Resource,
9274}
9275
9276/// A content block within a tool result, which may be text, terminal output, image, audio, or a resource
9277#[derive(Debug, Clone, Serialize, Deserialize)]
9278#[serde(untagged)]
9279pub enum ToolExecutionCompleteContent {
9280    Text(ToolExecutionCompleteContentText),
9281    Terminal(ToolExecutionCompleteContentTerminal),
9282    ShellExit(ToolExecutionCompleteContentShellExit),
9283    Image(ToolExecutionCompleteContentImage),
9284    Audio(ToolExecutionCompleteContentAudio),
9285    ResourceLink(ToolExecutionCompleteContentResourceLink),
9286    Resource(ToolExecutionCompleteContentResource),
9287}
9288
9289/// Allowed values for the `ToolExecutionCompleteToolDescriptionMetaUIVisibility` enumeration.
9290#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9291pub enum ToolExecutionCompleteToolDescriptionMetaUIVisibility {
9292    /// Tool is callable by the model (LLM tool surface)
9293    #[serde(rename = "model")]
9294    Model,
9295    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
9296    #[serde(rename = "app")]
9297    App,
9298    /// Unknown variant for forward compatibility.
9299    #[default]
9300    #[serde(other)]
9301    Unknown,
9302}
9303
9304/// 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)
9305#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9306pub enum SkillInvokedTrigger {
9307    /// Skill invocation requested explicitly by the user, such as via a slash command or UI affordance.
9308    #[serde(rename = "user-invoked")]
9309    UserInvoked,
9310    /// Skill invocation requested by the agent.
9311    #[serde(rename = "agent-invoked")]
9312    AgentInvoked,
9313    /// Skill content loaded as part of another context, such as a configured custom agent or subagent.
9314    #[serde(rename = "context-load")]
9315    ContextLoad,
9316    /// Unknown variant for forward compatibility.
9317    #[default]
9318    #[serde(other)]
9319    Unknown,
9320}
9321
9322/// Process-containment backend selected for the host platform
9323#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9324pub enum SandboxBackend {
9325    /// Apple Seatbelt process sandbox.
9326    #[serde(rename = "seatbelt")]
9327    Seatbelt,
9328    /// Linux Bubblewrap process sandbox.
9329    #[serde(rename = "bubblewrap")]
9330    Bubblewrap,
9331    /// Windows ProcessContainer sandbox.
9332    #[serde(rename = "process_container")]
9333    ProcessContainer,
9334    /// No supported process-containment backend is available.
9335    #[serde(rename = "unsupported")]
9336    Unsupported,
9337    /// Unknown variant for forward compatibility.
9338    #[default]
9339    #[serde(other)]
9340    Unknown,
9341}
9342
9343/// Customer-controllable sandbox governance area
9344#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9345pub enum SandboxControl {
9346    /// Process containment and sandbox spawn behavior.
9347    #[serde(rename = "process")]
9348    Process,
9349    /// Filesystem read, write, and deny policy.
9350    #[serde(rename = "filesystem")]
9351    Filesystem,
9352    /// Outbound and local-network access policy.
9353    #[serde(rename = "network")]
9354    Network,
9355    /// Selection of the sandbox or built-in enforcement route.
9356    #[serde(rename = "routing")]
9357    Routing,
9358    /// Decisions to run outside the process sandbox, whether requested by the model or resolved by a person.
9359    #[serde(rename = "bypass")]
9360    Bypass,
9361    /// Credential and keychain capability injection.
9362    #[serde(rename = "credentials")]
9363    Credentials,
9364    /// Host-platform and backend support behavior.
9365    #[serde(rename = "platform")]
9366    Platform,
9367    /// Unknown variant for forward compatibility.
9368    #[default]
9369    #[serde(other)]
9370    Unknown,
9371}
9372
9373/// Finite reason why sandbox enforcement is weaker than configured
9374#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9375pub enum SandboxDegradationReason {
9376    /// The selected backend cannot enforce per-path deny rules.
9377    #[serde(rename = "denied_paths_unsupported")]
9378    DeniedPathsUnsupported,
9379    /// The host platform has no supported process-containment backend.
9380    #[serde(rename = "unsupported_platform")]
9381    UnsupportedPlatform,
9382    /// Unknown variant for forward compatibility.
9383    #[default]
9384    #[serde(other)]
9385    Unknown,
9386}
9387
9388/// Runtime boundary that enforced or routed a sandbox decision
9389#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9390pub enum SandboxEnforcementPoint {
9391    /// Shell command process containment.
9392    #[serde(rename = "shell")]
9393    Shell,
9394    /// Built-in filesystem policy enforcement.
9395    #[serde(rename = "builtin_filesystem")]
9396    BuiltinFilesystem,
9397    /// Search-tool sandbox or policy enforcement.
9398    #[serde(rename = "search")]
9399    Search,
9400    /// Web-fetch network policy enforcement.
9401    #[serde(rename = "web_fetch")]
9402    WebFetch,
9403    /// Model Context Protocol server routing.
9404    #[serde(rename = "mcp")]
9405    Mcp,
9406    /// Language server process routing.
9407    #[serde(rename = "lsp")]
9408    Lsp,
9409    /// Unknown variant for forward compatibility.
9410    #[default]
9411    #[serde(other)]
9412    Unknown,
9413}
9414
9415/// Sandbox decision variant discriminator.
9416#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9417pub enum SandboxDecisionDataPolicyResolvedKind {
9418    #[serde(rename = "policy_resolved")]
9419    #[default]
9420    PolicyResolved,
9421}
9422
9423/// Finite result of a sandbox decision. Each `SandboxDecisionData` variant uses a disjoint subset: `policy_resolved` is `resolved | degraded`, `spawn_completed` and `permissive_retry_completed` are `succeeded | failed`, `enforcement_state` is `engaged | inactive | failed`, `access_denied` is `denied`, and escalation decisions are `approved | declined`.
9424#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9425pub enum SandboxOutcome {
9426    /// The sandbox policy resolved successfully. Describes configuration only and makes no claim that a backend engaged.
9427    #[serde(rename = "resolved")]
9428    Resolved,
9429    /// No sandbox governed the workload.
9430    #[serde(rename = "inactive")]
9431    Inactive,
9432    /// A runtime-owned containment backend accepted the workload. Evidence of engagement, not of verified containment for the workload's lifetime.
9433    #[serde(rename = "engaged")]
9434    Engaged,
9435    /// The sandbox operation completed successfully.
9436    #[serde(rename = "succeeded")]
9437    Succeeded,
9438    /// The sandbox operation failed.
9439    #[serde(rename = "failed")]
9440    Failed,
9441    /// The sandbox is active with one or more controls weakened by platform limitations or an explicitly selected relaxed mode.
9442    #[serde(rename = "degraded")]
9443    Degraded,
9444    /// An enforcement check refused the requested access.
9445    #[serde(rename = "denied")]
9446    Denied,
9447    /// A request to run outside the process sandbox was granted.
9448    #[serde(rename = "approved")]
9449    Approved,
9450    /// A request to run outside the process sandbox was not granted.
9451    #[serde(rename = "declined")]
9452    Declined,
9453    /// Unknown variant for forward compatibility.
9454    #[default]
9455    #[serde(other)]
9456    Unknown,
9457}
9458
9459/// Host operating-system family used for sandbox enforcement
9460#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9461pub enum SandboxPlatform {
9462    /// Apple macOS host.
9463    #[serde(rename = "macos")]
9464    Macos,
9465    /// Linux host.
9466    #[serde(rename = "linux")]
9467    Linux,
9468    /// Microsoft Windows host.
9469    #[serde(rename = "windows")]
9470    Windows,
9471    /// Host platform outside the explicitly supported families.
9472    #[serde(rename = "other")]
9473    Other,
9474    /// Unknown variant for forward compatibility.
9475    #[default]
9476    #[serde(other)]
9477    Unknown,
9478}
9479
9480/// Origin of the effective sandbox policy
9481#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9482pub enum SandboxPolicySource {
9483    /// Runtime default sandbox policy.
9484    #[serde(rename = "default_policy")]
9485    DefaultPolicy,
9486    /// User-configured sandbox policy merged with runtime-required grants.
9487    #[serde(rename = "user_policy")]
9488    UserPolicy,
9489    /// Unknown variant for forward compatibility.
9490    #[default]
9491    #[serde(other)]
9492    Unknown,
9493}
9494
9495/// Bounded classification of effective sandbox proxy routing
9496#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9497pub enum SandboxProxyMode {
9498    /// No sandbox proxy is configured.
9499    #[serde(rename = "none")]
9500    None,
9501    /// Traffic routes through a loopback proxy.
9502    #[serde(rename = "loopback")]
9503    Loopback,
9504    /// Traffic routes through a non-loopback proxy endpoint.
9505    #[serde(rename = "external")]
9506    External,
9507    /// Unknown variant for forward compatibility.
9508    #[default]
9509    #[serde(other)]
9510    Unknown,
9511}
9512
9513/// Sandbox decision variant discriminator.
9514#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9515pub enum SandboxDecisionDataSpawnCompletedKind {
9516    #[serde(rename = "spawn_completed")]
9517    #[default]
9518    SpawnCompleted,
9519}
9520
9521/// Runtime observation backing an enforcement-state or denial claim. Absent on `enforcement_state` when no observation backs the state.
9522#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9523pub enum SandboxAttestation {
9524    /// A containment backend accepted and applied the spawn request.
9525    #[serde(rename = "spawn_succeeded")]
9526    SpawnSucceeded,
9527    /// The spawn was refused for lack of a usable containment backend.
9528    #[serde(rename = "unsupported")]
9529    Unsupported,
9530    /// A runtime-owned policy check ran and returned a verdict. Attests the check, not that the caller honoured it.
9531    #[serde(rename = "builtin_policy_checked")]
9532    BuiltinPolicyChecked,
9533    /// Unknown variant for forward compatibility.
9534    #[default]
9535    #[serde(other)]
9536    Unknown,
9537}
9538
9539/// Sandbox decision variant discriminator.
9540#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9541pub enum SandboxDecisionDataEnforcementStateKind {
9542    #[serde(rename = "enforcement_state")]
9543    #[default]
9544    EnforcementState,
9545}
9546
9547/// How strong the evidence behind a denial is. A denial the sandbox itself recorded is a fact; one inferred from a command's output text is a judgement, and an analysis that cannot tell them apart will treat a false positive as enforcement.
9548#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9549pub enum SandboxDenialConfidence {
9550    /// The sandbox's own denial capture recorded the refused access. The strongest evidence available: the kernel observed it, not the runtime.
9551    #[serde(rename = "captured")]
9552    Captured,
9553    /// The command named a path that the effective policy independently denies. No capture confirmed it, but the policy did.
9554    #[serde(rename = "policy_corroborated")]
9555    PolicyCorroborated,
9556    /// The failure carried a fingerprint the sandbox itself emits, so the sandbox is known to have refused something even though the resource was not confirmed.
9557    #[serde(rename = "sandbox_reported")]
9558    SandboxReported,
9559    /// Classified from the command's own output text alone. The weakest evidence: a command that merely prints sandbox-like wording reaches this level.
9560    #[serde(rename = "output_classified")]
9561    OutputClassified,
9562    /// Unknown variant for forward compatibility.
9563    #[default]
9564    #[serde(other)]
9565    Unknown,
9566}
9567
9568/// Bounded class of access an enforcement check refused. Raw resources, commands, and process names accompany it only when content capture is enabled; diagnostic text and matched rules are never exported.
9569#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9570pub enum SandboxDenialClass {
9571    /// A read was refused because the effective policy does not grant it.
9572    #[serde(rename = "filesystem_read")]
9573    FilesystemRead,
9574    /// A write was refused. Distinct from `filesystem_read` because a read-only grant denies writes to a path it otherwise permits.
9575    #[serde(rename = "filesystem_write")]
9576    FilesystemWrite,
9577    /// A process could not start because the sandbox refused a required process-scoped resource. Currently emitted for the Windows MSYS `BaseNamedObjects` fork failure confirmed by learning-mode capture.
9578    #[serde(rename = "process_startup")]
9579    ProcessStartup,
9580    /// Windows registry access was refused and correlated with capture evidence.
9581    #[serde(rename = "registry_access")]
9582    RegistryAccess,
9583    /// Windows ALPC or RPC access was refused and correlated with capture evidence.
9584    #[serde(rename = "ipc_access")]
9585    IpcAccess,
9586    /// Access to another Windows process was refused and correlated with capture evidence.
9587    #[serde(rename = "process_access")]
9588    ProcessAccess,
9589    /// Windows job-object access was refused and correlated with capture evidence.
9590    #[serde(rename = "job_access")]
9591    JobAccess,
9592    /// Windows UI-handle access was refused and correlated with capture evidence.
9593    #[serde(rename = "ui_access")]
9594    UiAccess,
9595    /// Windows service-control-manager access was refused and correlated with capture evidence.
9596    #[serde(rename = "service_access")]
9597    ServiceAccess,
9598    /// An outbound connection was refused by `network.allowOutbound`.
9599    #[serde(rename = "network_outbound")]
9600    NetworkOutbound,
9601    /// A connection to a local or loopback destination was refused by `network.allowLocalNetwork`.
9602    #[serde(rename = "network_local")]
9603    NetworkLocal,
9604    /// A destination was refused by the sandbox host allow/deny rules.
9605    #[serde(rename = "network_host")]
9606    NetworkHost,
9607    /// The sandbox's denial capture recorded a refusal its record does not attribute to a more specific control: an unclassified resource (registry, COM, section object) or an AppContainer capability with no network meaning. Deliberately generic — the capture proves the denial happened, and naming a narrower class than the record supports would be a guess.
9608    #[serde(rename = "other_access")]
9609    OtherAccess,
9610    /// Unknown variant for forward compatibility.
9611    #[default]
9612    #[serde(other)]
9613    Unknown,
9614}
9615
9616/// Sandbox decision variant discriminator.
9617#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9618pub enum SandboxDecisionDataAccessDeniedKind {
9619    #[serde(rename = "access_denied")]
9620    #[default]
9621    AccessDenied,
9622}
9623
9624/// Sandbox decision variant discriminator.
9625#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9626pub enum SandboxDecisionDataBypassDecidedKind {
9627    #[serde(rename = "bypass_decided")]
9628    #[default]
9629    BypassDecided,
9630}
9631
9632/// Where a request to run outside the process sandbox originated. Orthogonal to the outcome: the same verdict means a different thing depending on where the request came from.
9633#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9634pub enum SandboxBypassSource {
9635    /// No longer produced. The model could once ask for a bypass in the tool call itself; no tool exposes that parameter now. Retained so historical events still deserialize.
9636    #[serde(rename = "model_requested")]
9637    ModelRequested,
9638    /// The runtime raised the prompt itself — either after a sandboxed attempt looked blocked, or before a run the sandbox cannot enforce at all, such as a detached command — and a person answered it. In the second case nothing had executed when the decision was made.
9639    #[serde(rename = "user_prompted")]
9640    UserPrompted,
9641    /// The runtime raised the prompt itself — after a sandboxed attempt looked blocked, or before a run it cannot enforce — but the permission flow produced no confirmed human answer. This includes unavailable or unreadable prompts, cancellation, and automated rule, hook, or content-exclusion denials.
9642    #[serde(rename = "prompt_unavailable")]
9643    PromptUnavailable,
9644    /// Unknown variant for forward compatibility.
9645    #[default]
9646    #[serde(other)]
9647    Unknown,
9648}
9649
9650/// Sandbox decision variant discriminator.
9651#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9652pub enum SandboxDecisionDataPermissiveRetryDecidedKind {
9653    #[serde(rename = "permissive_retry_decided")]
9654    #[default]
9655    PermissiveRetryDecided,
9656}
9657
9658/// Sandbox decision variant discriminator.
9659#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9660pub enum SandboxDecisionDataPermissiveRetryCompletedKind {
9661    #[serde(rename = "permissive_retry_completed")]
9662    #[default]
9663    PermissiveRetryCompleted,
9664}
9665
9666/// 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`.
9667#[derive(Debug, Clone, Serialize, Deserialize)]
9668#[serde(untagged)]
9669pub enum SandboxDecisionData {
9670    PolicyResolved(SandboxDecisionDataPolicyResolved),
9671    SpawnCompleted(SandboxDecisionDataSpawnCompleted),
9672    EnforcementState(SandboxDecisionDataEnforcementState),
9673    AccessDenied(SandboxDecisionDataAccessDenied),
9674    BypassDecided(SandboxDecisionDataBypassDecided),
9675    PermissiveRetryDecided(SandboxDecisionDataPermissiveRetryDecided),
9676    PermissiveRetryCompleted(SandboxDecisionDataPermissiveRetryCompleted),
9677}
9678
9679/// Authority or runtime mechanism responsible for sub-agent model selection.
9680#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9681pub enum SubagentModelSelectionSource {
9682    /// Explicit model supplied by the parent agent on the task call and selected for dispatch.
9683    #[serde(rename = "explicit_override")]
9684    ExplicitOverride,
9685    /// Required model policy configured for the sub-agent.
9686    #[serde(rename = "configured_required")]
9687    ConfiguredRequired,
9688    /// Non-required model preference configured for the sub-agent.
9689    #[serde(rename = "configured_preference")]
9690    ConfiguredPreference,
9691    /// Complementary-model default selected for the sub-agent.
9692    #[serde(rename = "complementary_default")]
9693    ComplementaryDefault,
9694    /// Model inherited from the parent session.
9695    #[serde(rename = "session_inheritance")]
9696    SessionInheritance,
9697    /// Default model declared by the agent definition.
9698    #[serde(rename = "agent_definition_default")]
9699    AgentDefinitionDefault,
9700    /// Runtime policy, Auto mode, or an experiment selected the model.
9701    #[serde(rename = "runtime_policy")]
9702    RuntimePolicy,
9703    /// Unknown variant for forward compatibility.
9704    #[default]
9705    #[serde(other)]
9706    Unknown,
9707}
9708
9709/// Where the model input for a task-tool sub-agent came from.
9710#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9711pub enum SubagentTaskModelSource {
9712    /// The spawning agent supplied the task tool's model argument.
9713    #[serde(rename = "task_argument")]
9714    TaskArgument,
9715    /// The task omitted a model and the per-sub-agent settings entry supplied a concrete one.
9716    #[serde(rename = "subagent_configuration")]
9717    SubagentConfiguration,
9718    /// The task omitted a model and the user-defined custom agent's definition supplied one.
9719    #[serde(rename = "custom_agent_definition")]
9720    CustomAgentDefinition,
9721    /// Neither the task call, the per-sub-agent settings entry, nor a custom agent definition supplied a model.
9722    #[serde(rename = "unset")]
9723    Unset,
9724    /// Unknown variant for forward compatibility.
9725    #[default]
9726    #[serde(other)]
9727    Unknown,
9728}
9729
9730/// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
9731#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9732pub enum BinaryAssetType {
9733    /// Binary image data.
9734    #[serde(rename = "image")]
9735    Image,
9736    /// Other binary resource data.
9737    #[serde(rename = "resource")]
9738    Resource,
9739    /// Unknown variant for forward compatibility.
9740    #[default]
9741    #[serde(other)]
9742    Unknown,
9743}
9744
9745/// Message role: "system" for system prompts, "developer" for developer-injected instructions
9746#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9747pub enum SystemMessageRole {
9748    /// System prompt message.
9749    #[serde(rename = "system")]
9750    System,
9751    /// Developer instruction message.
9752    #[serde(rename = "developer")]
9753    Developer,
9754    /// Unknown variant for forward compatibility.
9755    #[default]
9756    #[serde(other)]
9757    Unknown,
9758}
9759
9760/// Permission kind discriminator
9761#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9762pub enum PermissionRequestShellKind {
9763    #[serde(rename = "shell")]
9764    #[default]
9765    Shell,
9766}
9767
9768/// Permission kind discriminator
9769#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9770pub enum PermissionRequestWriteKind {
9771    #[serde(rename = "write")]
9772    #[default]
9773    Write,
9774}
9775
9776/// Permission kind discriminator
9777#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9778pub enum PermissionRequestReadKind {
9779    #[serde(rename = "read")]
9780    #[default]
9781    Read,
9782}
9783
9784/// Permission kind discriminator
9785#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9786pub enum PermissionRequestMcpKind {
9787    #[serde(rename = "mcp")]
9788    #[default]
9789    Mcp,
9790}
9791
9792/// 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.
9793///
9794/// <div class="warning">
9795///
9796/// **Experimental.** This type is part of an experimental wire-protocol surface
9797/// and may change or be removed in future SDK or CLI releases.
9798///
9799/// </div>
9800#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9801pub enum PermissionRecommendation {
9802    /// 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.
9803    #[serde(rename = "approve")]
9804    Approve,
9805    /// Unknown variant for forward compatibility.
9806    #[default]
9807    #[serde(other)]
9808    Unknown,
9809}
9810
9811/// Permission kind discriminator
9812#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9813pub enum PermissionRequestUrlKind {
9814    #[serde(rename = "url")]
9815    #[default]
9816    Url,
9817}
9818
9819/// Whether this is a store or vote memory operation
9820#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9821pub enum PermissionRequestMemoryAction {
9822    /// Store a new memory.
9823    #[serde(rename = "store")]
9824    Store,
9825    /// Vote on an existing memory.
9826    #[serde(rename = "vote")]
9827    Vote,
9828    /// Unknown variant for forward compatibility.
9829    #[default]
9830    #[serde(other)]
9831    Unknown,
9832}
9833
9834/// Stage that produced this attribution.
9835#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9836pub enum PermissionApprovalEvaluationEvaluationStage {
9837    /// The attribution stage is unknown.
9838    #[serde(rename = "unknown")]
9839    UnknownValue,
9840    /// The request resolved before assisted-approval evaluation.
9841    #[serde(rename = "not_reached")]
9842    NotReached,
9843    /// A runtime gate skipped the judge.
9844    #[serde(rename = "pre_judge")]
9845    PreJudge,
9846    /// The judge interface produced the evaluation.
9847    #[serde(rename = "judge")]
9848    Judge,
9849    /// A cached recommendation or another request's outcome was reused.
9850    #[serde(rename = "reuse")]
9851    Reuse,
9852    /// Unknown variant for forward compatibility.
9853    #[default]
9854    #[serde(other)]
9855    Unknown,
9856}
9857
9858/// Status of the local judge interface, not proof of a model network call.
9859#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9860pub enum PermissionApprovalEvaluationJudgeStatus {
9861    /// No authoritative attribution is available.
9862    #[serde(rename = "unknown")]
9863    UnknownValue,
9864    /// This evaluation did not invoke the judge interface.
9865    #[serde(rename = "not_called")]
9866    NotCalled,
9867    /// The judge interface returned a usable verdict.
9868    #[serde(rename = "completed")]
9869    Completed,
9870    /// The judge interface returned an error.
9871    #[serde(rename = "failed")]
9872    Failed,
9873    /// This evaluation reused a cached recommendation.
9874    #[serde(rename = "cached")]
9875    Cached,
9876    /// This request inherited another decision without local judge attribution.
9877    #[serde(rename = "inherited")]
9878    Inherited,
9879    /// Unknown variant for forward compatibility.
9880    #[default]
9881    #[serde(other)]
9882    Unknown,
9883}
9884
9885/// Machine-readable runtime gate reason, never a command, path or human rationale.
9886#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9887pub enum PermissionApprovalEvaluationReasonCode {
9888    /// Attribution is missing or outside the supported vocabulary.
9889    #[serde(rename = "unknown")]
9890    UnknownValue,
9891    /// The request resolved before assisted-approval evaluation.
9892    #[serde(rename = "not-reached")]
9893    NotReached,
9894    /// Assisted approval was inactive for this request.
9895    #[serde(rename = "inactive")]
9896    Inactive,
9897    /// The judge was skipped because authorization extraction could not safely establish a complete recent history.
9898    #[serde(rename = "authorization-history-incomplete")]
9899    AuthorizationHistoryIncomplete,
9900    /// Managed policy required a human decision.
9901    #[serde(rename = "managed-approval-required")]
9902    ManagedApprovalRequired,
9903    /// The request asked to bypass sandbox restrictions.
9904    #[serde(rename = "sandbox-bypass")]
9905    SandboxBypass,
9906    /// An action field exceeded the judge input limit.
9907    #[serde(rename = "action-too-long")]
9908    ActionTooLong,
9909    /// The script path was not authorized for inspection.
9910    #[serde(rename = "path-not-authorized")]
9911    PathNotAuthorized,
9912    /// The script working directory was invalid.
9913    #[serde(rename = "invalid-working-directory")]
9914    InvalidWorkingDirectory,
9915    /// The script snapshot could not be read.
9916    #[serde(rename = "unreadable")]
9917    Unreadable,
9918    /// The script path was not a regular file.
9919    #[serde(rename = "not-regular-file")]
9920    NotRegularFile,
9921    /// The script snapshot exceeded the size limit.
9922    #[serde(rename = "too-large")]
9923    TooLarge,
9924    /// The script snapshot was not UTF-8.
9925    #[serde(rename = "non-utf8")]
9926    NonUtf8,
9927    /// The script interpreter could not be inspected.
9928    #[serde(rename = "interpreter-unavailable")]
9929    InterpreterUnavailable,
9930    /// The interpreter snapshot exceeded the size limit.
9931    #[serde(rename = "interpreter-too-large")]
9932    InterpreterTooLarge,
9933    /// The shell environment could not be reviewed.
9934    #[serde(rename = "shell-environment-unreviewable")]
9935    ShellEnvironmentUnreviewable,
9936    /// A script path could not be represented for review.
9937    #[serde(rename = "unrepresentable-path")]
9938    UnrepresentablePath,
9939    /// An interpreter wrapped a script that could not be reviewed.
9940    #[serde(rename = "interpreter-wrapped-script")]
9941    InterpreterWrappedScript,
9942    /// The script invocation could not be reviewed.
9943    #[serde(rename = "unreviewable-script-invocation")]
9944    UnreviewableScriptInvocation,
9945    /// The script argument binding could not be reviewed.
9946    #[serde(rename = "argument-binding-unreviewable")]
9947    ArgumentBindingUnreviewable,
9948    /// The script review metadata was malformed.
9949    #[serde(rename = "malformed-script-action-review")]
9950    MalformedScriptActionReview,
9951    /// The script snapshot manifest was malformed.
9952    #[serde(rename = "malformed-script-action-manifest")]
9953    MalformedScriptActionManifest,
9954    /// Script review was unavailable.
9955    #[serde(rename = "unavailable")]
9956    Unavailable,
9957    /// The judge interface returned a usable verdict.
9958    #[serde(rename = "judge-verdict")]
9959    JudgeVerdict,
9960    /// The judge interface returned an error.
9961    #[serde(rename = "judge-error")]
9962    JudgeError,
9963    /// The request inherited an outcome from another decision.
9964    #[serde(rename = "inherited")]
9965    Inherited,
9966    /// Unknown variant for forward compatibility.
9967    #[default]
9968    #[serde(other)]
9969    Unknown,
9970}
9971
9972/// 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.
9973///
9974/// <div class="warning">
9975///
9976/// **Experimental.** This type is part of an experimental wire-protocol surface
9977/// and may change or be removed in future SDK or CLI releases.
9978///
9979/// </div>
9980#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9981pub enum AssistedApprovalJudgeFailureReason {
9982    /// The judge model call exceeded its deadline.
9983    #[serde(rename = "timeout")]
9984    Timeout,
9985    /// The judge model call was cancelled before it returned.
9986    #[serde(rename = "abort")]
9987    Abort,
9988    /// The judge model call completed but returned no content.
9989    #[serde(rename = "empty_response")]
9990    EmptyResponse,
9991    /// The judge model call failed (for example a transport, authentication, or rate-limit error).
9992    #[serde(rename = "model_error")]
9993    ModelError,
9994    /// The judge model replied, but the reply carried no ALLOW/DENY verdict.
9995    #[serde(rename = "parse_error")]
9996    ParseError,
9997    /// Unknown variant for forward compatibility.
9998    #[default]
9999    #[serde(other)]
10000    Unknown,
10001}
10002
10003/// 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.
10004///
10005/// <div class="warning">
10006///
10007/// **Experimental.** This type is part of an experimental wire-protocol surface
10008/// and may change or be removed in future SDK or CLI releases.
10009///
10010/// </div>
10011#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10012pub enum AssistedApprovalRecommendation {
10013    /// The judge evaluated the request and recommends automatically approving it.
10014    #[serde(rename = "approve")]
10015    Approve,
10016    /// 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.
10017    #[serde(rename = "requireApproval")]
10018    RequireApproval,
10019    /// Assisted mode is enabled, but this request category is never automatically approvable (for example, sandbox-bypass requests), so the judge was not consulted.
10020    #[serde(rename = "excluded")]
10021    Excluded,
10022    /// The judge was consulted but did not return a usable recommendation, so the request requires explicit approval.
10023    #[serde(rename = "error")]
10024    Error,
10025    /// Unknown variant for forward compatibility.
10026    #[default]
10027    #[serde(other)]
10028    Unknown,
10029}
10030
10031/// Vote direction (vote only)
10032#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10033pub enum PermissionRequestMemoryDirection {
10034    /// Vote that the memory is useful or accurate.
10035    #[serde(rename = "upvote")]
10036    Upvote,
10037    /// Vote that the memory is incorrect or outdated.
10038    #[serde(rename = "downvote")]
10039    Downvote,
10040    /// Unknown variant for forward compatibility.
10041    #[default]
10042    #[serde(other)]
10043    Unknown,
10044}
10045
10046/// Permission kind discriminator
10047#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10048pub enum PermissionRequestMemoryKind {
10049    #[serde(rename = "memory")]
10050    #[default]
10051    Memory,
10052}
10053
10054/// Scope of a stored memory.
10055#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10056pub enum PermissionRequestMemoryScope {
10057    /// Store the memory for the current repository.
10058    #[serde(rename = "repository")]
10059    Repository,
10060    /// Store the memory for the current user.
10061    #[serde(rename = "user")]
10062    User,
10063    /// Unknown variant for forward compatibility.
10064    #[default]
10065    #[serde(other)]
10066    Unknown,
10067}
10068
10069/// Permission kind discriminator
10070#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10071pub enum PermissionRequestCustomToolKind {
10072    #[serde(rename = "custom-tool")]
10073    #[default]
10074    CustomTool,
10075}
10076
10077/// Permission kind discriminator
10078#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10079pub enum PermissionRequestHookKind {
10080    #[serde(rename = "hook")]
10081    #[default]
10082    Hook,
10083}
10084
10085/// Permission kind discriminator
10086#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10087pub enum PermissionRequestExtensionManagementKind {
10088    #[serde(rename = "extension-management")]
10089    #[default]
10090    ExtensionManagement,
10091}
10092
10093/// Permission kind discriminator
10094#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10095pub enum PermissionRequestFactoryKind {
10096    #[serde(rename = "factory")]
10097    #[default]
10098    Factory,
10099}
10100
10101/// Operation gated by a factory permission request.
10102#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10103pub enum FactoryPermissionOperation {
10104    /// Running a registered factory, which spends subagents, active time, and AI credits under the approved limits.
10105    #[serde(rename = "run")]
10106    Run,
10107    /// Authoring a factory, which writes JavaScript into a session-scoped extension and loads it.
10108    #[serde(rename = "author")]
10109    Author,
10110    /// Unknown variant for forward compatibility.
10111    #[default]
10112    #[serde(other)]
10113    Unknown,
10114}
10115
10116/// Permission kind discriminator
10117#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10118pub enum PermissionRequestExtensionPermissionAccessKind {
10119    #[serde(rename = "extension-permission-access")]
10120    #[default]
10121    ExtensionPermissionAccess,
10122}
10123
10124/// Permission kind discriminator
10125#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10126pub enum PermissionRequestExtensionEnvAccessKind {
10127    #[serde(rename = "extension-env-access")]
10128    #[default]
10129    ExtensionEnvAccess,
10130}
10131
10132/// Details of the permission being requested
10133#[derive(Debug, Clone, Serialize, Deserialize)]
10134#[serde(untagged)]
10135pub enum PermissionRequest {
10136    Shell(PermissionRequestShell),
10137    Write(PermissionRequestWrite),
10138    Read(PermissionRequestRead),
10139    Mcp(PermissionRequestMcp),
10140    Url(PermissionRequestUrl),
10141    Memory(PermissionRequestMemory),
10142    CustomTool(PermissionRequestCustomTool),
10143    Hook(PermissionRequestHook),
10144    ExtensionManagement(PermissionRequestExtensionManagement),
10145    Factory(PermissionRequestFactory),
10146    ExtensionPermissionAccess(PermissionRequestExtensionPermissionAccess),
10147    ExtensionEnvAccess(PermissionRequestExtensionEnvAccess),
10148}
10149
10150/// Prompt kind discriminator
10151#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10152pub enum PermissionPromptRequestCommandsKind {
10153    #[serde(rename = "commands")]
10154    #[default]
10155    Commands,
10156}
10157
10158/// Prompt kind discriminator
10159#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10160pub enum PermissionPromptRequestWriteKind {
10161    #[serde(rename = "write")]
10162    #[default]
10163    Write,
10164}
10165
10166/// Prompt kind discriminator
10167#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10168pub enum PermissionPromptRequestReadKind {
10169    #[serde(rename = "read")]
10170    #[default]
10171    Read,
10172}
10173
10174/// Prompt kind discriminator
10175#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10176pub enum PermissionPromptRequestMcpKind {
10177    #[serde(rename = "mcp")]
10178    #[default]
10179    Mcp,
10180}
10181
10182/// Prompt kind discriminator
10183#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10184pub enum PermissionPromptRequestUrlKind {
10185    #[serde(rename = "url")]
10186    #[default]
10187    Url,
10188}
10189
10190/// Prompt kind discriminator
10191#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10192pub enum PermissionPromptRequestMemoryKind {
10193    #[serde(rename = "memory")]
10194    #[default]
10195    Memory,
10196}
10197
10198/// Prompt kind discriminator
10199#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10200pub enum PermissionPromptRequestCustomToolKind {
10201    #[serde(rename = "custom-tool")]
10202    #[default]
10203    CustomTool,
10204}
10205
10206/// Underlying permission kind that needs path approval
10207#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10208pub enum PermissionPromptRequestPathAccessKind {
10209    /// Read access to a filesystem path.
10210    #[serde(rename = "read")]
10211    Read,
10212    /// Shell command access involving a filesystem path.
10213    #[serde(rename = "shell")]
10214    Shell,
10215    /// Write access to a filesystem path.
10216    #[serde(rename = "write")]
10217    Write,
10218    /// Unknown variant for forward compatibility.
10219    #[default]
10220    #[serde(other)]
10221    Unknown,
10222}
10223
10224/// Prompt kind discriminator
10225#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10226pub enum PermissionPromptRequestPathKind {
10227    #[serde(rename = "path")]
10228    #[default]
10229    Path,
10230}
10231
10232/// Prompt kind discriminator
10233#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10234pub enum PermissionPromptRequestHookKind {
10235    #[serde(rename = "hook")]
10236    #[default]
10237    Hook,
10238}
10239
10240/// Prompt kind discriminator
10241#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10242pub enum PermissionPromptRequestExtensionManagementKind {
10243    #[serde(rename = "extension-management")]
10244    #[default]
10245    ExtensionManagement,
10246}
10247
10248/// Prompt kind discriminator
10249#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10250pub enum PermissionPromptRequestFactoryKind {
10251    #[serde(rename = "factory")]
10252    #[default]
10253    Factory,
10254}
10255
10256/// Prompt kind discriminator
10257#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10258pub enum PermissionPromptRequestExtensionPermissionAccessKind {
10259    #[serde(rename = "extension-permission-access")]
10260    #[default]
10261    ExtensionPermissionAccess,
10262}
10263
10264/// Prompt kind discriminator
10265#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10266pub enum PermissionPromptRequestExtensionEnvAccessKind {
10267    #[serde(rename = "extension-env-access")]
10268    #[default]
10269    ExtensionEnvAccess,
10270}
10271
10272/// Derived user-facing permission prompt details for UI consumers
10273#[derive(Debug, Clone, Serialize, Deserialize)]
10274#[serde(untagged)]
10275pub enum PermissionPromptRequest {
10276    Commands(PermissionPromptRequestCommands),
10277    Write(PermissionPromptRequestWrite),
10278    Read(PermissionPromptRequestRead),
10279    Mcp(PermissionPromptRequestMcp),
10280    Url(PermissionPromptRequestUrl),
10281    Memory(PermissionPromptRequestMemory),
10282    CustomTool(PermissionPromptRequestCustomTool),
10283    Path(PermissionPromptRequestPath),
10284    Hook(PermissionPromptRequestHook),
10285    ExtensionManagement(PermissionPromptRequestExtensionManagement),
10286    Factory(PermissionPromptRequestFactory),
10287    ExtensionPermissionAccess(PermissionPromptRequestExtensionPermissionAccess),
10288    ExtensionEnvAccess(PermissionPromptRequestExtensionEnvAccess),
10289}
10290
10291/// Controlled reason or actor responsible for a permission response.
10292#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10293pub enum PermissionDecisionSource {
10294    /// The response followed the assisted-approval judge recommendation.
10295    #[serde(rename = "assisted_approval")]
10296    AssistedApproval,
10297    /// A human supplied the response through an interactive prompt.
10298    #[serde(rename = "human_response")]
10299    HumanResponse,
10300    /// The host applied a standing policy or override rather than a judge recommendation or human decision.
10301    #[serde(rename = "host_policy")]
10302    HostPolicy,
10303    /// The host denied the request because no interactive user response was available.
10304    #[serde(rename = "unattended_fallback")]
10305    UnattendedFallback,
10306    /// A live authorization record from an earlier human decision in this session contained the proposal, so it ran without another prompt. This is not a new human decision and never mints authority of its own.
10307    #[serde(rename = "authorization_carry_forward")]
10308    AuthorizationCarryForward,
10309    /// Unknown variant for forward compatibility.
10310    #[default]
10311    #[serde(other)]
10312    Unknown,
10313}
10314
10315/// The permission request was approved
10316#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10317pub enum PermissionApprovedKind {
10318    #[serde(rename = "approved")]
10319    #[default]
10320    Approved,
10321}
10322
10323/// Command approval kind
10324#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10325pub enum UserToolSessionApprovalCommandsKind {
10326    #[serde(rename = "commands")]
10327    #[default]
10328    Commands,
10329}
10330
10331/// Read approval kind
10332#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10333pub enum UserToolSessionApprovalReadKind {
10334    #[serde(rename = "read")]
10335    #[default]
10336    Read,
10337}
10338
10339/// Write approval kind
10340#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10341pub enum UserToolSessionApprovalWriteKind {
10342    #[serde(rename = "write")]
10343    #[default]
10344    Write,
10345}
10346
10347/// MCP tool approval kind
10348#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10349pub enum UserToolSessionApprovalMcpKind {
10350    #[serde(rename = "mcp")]
10351    #[default]
10352    Mcp,
10353}
10354
10355/// Memory approval kind
10356#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10357pub enum UserToolSessionApprovalMemoryKind {
10358    #[serde(rename = "memory")]
10359    #[default]
10360    Memory,
10361}
10362
10363/// Custom tool approval kind
10364#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10365pub enum UserToolSessionApprovalCustomToolKind {
10366    #[serde(rename = "custom-tool")]
10367    #[default]
10368    CustomTool,
10369}
10370
10371/// Extension management approval kind
10372#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10373pub enum UserToolSessionApprovalExtensionManagementKind {
10374    #[serde(rename = "extension-management")]
10375    #[default]
10376    ExtensionManagement,
10377}
10378
10379/// Factory approval kind
10380#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10381pub enum UserToolSessionApprovalFactoryKind {
10382    #[serde(rename = "factory")]
10383    #[default]
10384    Factory,
10385}
10386
10387/// Extension permission access approval kind
10388#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10389pub enum UserToolSessionApprovalExtensionPermissionAccessKind {
10390    #[serde(rename = "extension-permission-access")]
10391    #[default]
10392    ExtensionPermissionAccess,
10393}
10394
10395/// Extension environment access approval kind
10396#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10397pub enum UserToolSessionApprovalExtensionEnvAccessKind {
10398    #[serde(rename = "extension-env-access")]
10399    #[default]
10400    ExtensionEnvAccess,
10401}
10402
10403/// The approval to add as a session-scoped rule
10404#[derive(Debug, Clone, Serialize, Deserialize)]
10405#[serde(untagged)]
10406pub enum UserToolSessionApproval {
10407    Commands(UserToolSessionApprovalCommands),
10408    Read(UserToolSessionApprovalRead),
10409    Write(UserToolSessionApprovalWrite),
10410    Mcp(UserToolSessionApprovalMcp),
10411    Memory(UserToolSessionApprovalMemory),
10412    CustomTool(UserToolSessionApprovalCustomTool),
10413    ExtensionManagement(UserToolSessionApprovalExtensionManagement),
10414    Factory(UserToolSessionApprovalFactory),
10415    ExtensionPermissionAccess(UserToolSessionApprovalExtensionPermissionAccess),
10416    ExtensionEnvAccess(UserToolSessionApprovalExtensionEnvAccess),
10417}
10418
10419/// Approved and remembered for the rest of the session
10420#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10421pub enum PermissionApprovedForSessionKind {
10422    #[serde(rename = "approved-for-session")]
10423    #[default]
10424    ApprovedForSession,
10425}
10426
10427/// Approved and persisted for this project location
10428#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10429pub enum PermissionApprovedForLocationKind {
10430    #[serde(rename = "approved-for-location")]
10431    #[default]
10432    ApprovedForLocation,
10433}
10434
10435/// The permission request was cancelled before a response was used
10436#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10437pub enum PermissionCancelledKind {
10438    #[serde(rename = "cancelled")]
10439    #[default]
10440    Cancelled,
10441}
10442
10443/// Denied because approval rules explicitly blocked it
10444#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10445pub enum PermissionDeniedByRulesKind {
10446    #[serde(rename = "denied-by-rules")]
10447    #[default]
10448    DeniedByRules,
10449}
10450
10451/// Denied because no approval rule matched and user confirmation was unavailable
10452#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10453pub enum PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind {
10454    #[serde(rename = "denied-no-approval-rule-and-could-not-request-from-user")]
10455    #[default]
10456    DeniedNoApprovalRuleAndCouldNotRequestFromUser,
10457}
10458
10459/// Denied by the user during an interactive prompt
10460#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10461pub enum PermissionDeniedInteractivelyByUserKind {
10462    #[serde(rename = "denied-interactively-by-user")]
10463    #[default]
10464    DeniedInteractivelyByUser,
10465}
10466
10467/// Denied by the organization's content exclusion policy
10468#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10469pub enum PermissionDeniedByContentExclusionPolicyKind {
10470    #[serde(rename = "denied-by-content-exclusion-policy")]
10471    #[default]
10472    DeniedByContentExclusionPolicy,
10473}
10474
10475/// Denied by a permission request hook registered by an extension or plugin
10476#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10477pub enum PermissionDeniedByPermissionRequestHookKind {
10478    #[serde(rename = "denied-by-permission-request-hook")]
10479    #[default]
10480    DeniedByPermissionRequestHook,
10481}
10482
10483/// The result of the permission request
10484#[derive(Debug, Clone, Serialize, Deserialize)]
10485#[serde(untagged)]
10486pub enum PermissionResult {
10487    Approved(PermissionApproved),
10488    ApprovedForSession(PermissionApprovedForSession),
10489    ApprovedForLocation(PermissionApprovedForLocation),
10490    Cancelled(PermissionCancelled),
10491    DeniedByRules(PermissionDeniedByRules),
10492    DeniedNoApprovalRuleAndCouldNotRequestFromUser(
10493        PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser,
10494    ),
10495    DeniedInteractivelyByUser(PermissionDeniedInteractivelyByUser),
10496    DeniedByContentExclusionPolicy(PermissionDeniedByContentExclusionPolicy),
10497    DeniedByPermissionRequestHook(PermissionDeniedByPermissionRequestHook),
10498}
10499
10500/// Which direction a message-backed authorization claim moves authority in.
10501///
10502/// <div class="warning">
10503///
10504/// **Experimental.** This type is part of an experimental wire-protocol surface
10505/// and may change or be removed in future SDK or CLI releases.
10506///
10507/// </div>
10508#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10509pub enum PermissionMessageAuthorizationPolarity {
10510    /// The human's words authorized an effect.
10511    #[serde(rename = "grant")]
10512    Grant,
10513    /// The human's words refused an effect.
10514    #[serde(rename = "denial")]
10515    Denial,
10516    /// Unknown variant for forward compatibility.
10517    #[default]
10518    #[serde(other)]
10519    Unknown,
10520}
10521
10522/// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
10523#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10524pub enum ElicitationRequestedMode {
10525    /// Structured form-based elicitation.
10526    #[serde(rename = "form")]
10527    Form,
10528    /// Browser URL-based elicitation.
10529    #[serde(rename = "url")]
10530    Url,
10531    /// Unknown variant for forward compatibility.
10532    #[default]
10533    #[serde(other)]
10534    Unknown,
10535}
10536
10537/// Schema type indicator (always 'object')
10538#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10539pub enum ElicitationRequestedSchemaType {
10540    #[serde(rename = "object")]
10541    #[default]
10542    Object,
10543}
10544
10545/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
10546#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10547pub enum ElicitationCompletedAction {
10548    /// The user submitted the requested form.
10549    #[serde(rename = "accept")]
10550    Accept,
10551    /// The user explicitly declined the request.
10552    #[serde(rename = "decline")]
10553    Decline,
10554    /// The user dismissed the request.
10555    #[serde(rename = "cancel")]
10556    Cancel,
10557    /// Unknown variant for forward compatibility.
10558    #[default]
10559    #[serde(other)]
10560    Unknown,
10561}
10562
10563/// Reason the runtime is requesting host-provided MCP OAuth credentials
10564#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10565pub enum McpOauthRequestReason {
10566    /// Initial credentials are required before connecting to the MCP server.
10567    #[serde(rename = "initial")]
10568    Initial,
10569    /// The current host-provided credential was rejected and a replacement is requested.
10570    #[serde(rename = "refresh")]
10571    Refresh,
10572    /// The server requires a new host authorization flow before continuing.
10573    #[serde(rename = "reauth")]
10574    Reauth,
10575    /// The server requires a credential with additional scope or audience.
10576    #[serde(rename = "upscope")]
10577    Upscope,
10578    /// Unknown variant for forward compatibility.
10579    #[default]
10580    #[serde(other)]
10581    Unknown,
10582}
10583
10584/// 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).
10585#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10586pub enum McpOauthRequiredStaticClientConfigGrantType {
10587    #[serde(rename = "client_credentials")]
10588    #[default]
10589    ClientCredentials,
10590}
10591
10592/// How the pending MCP OAuth request was completed
10593#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10594pub enum McpOauthCompletionOutcome {
10595    /// The request completed with a token-backed OAuth provider.
10596    #[serde(rename = "token")]
10597    Token,
10598    /// The request completed without an OAuth provider.
10599    #[serde(rename = "cancelled")]
10600    Cancelled,
10601    /// Unknown variant for forward compatibility.
10602    #[default]
10603    #[serde(other)]
10604    Unknown,
10605}
10606
10607/// Why dynamic headers are being requested.
10608#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10609pub enum McpHeadersRefreshRequiredReason {
10610    /// The transport is making its first dynamic header request for this server.
10611    #[serde(rename = "startup")]
10612    Startup,
10613    /// The previously cached dynamic headers expired.
10614    #[serde(rename = "ttl-expired")]
10615    TtlExpired,
10616    /// The server returned 401 and stale dynamic headers were invalidated.
10617    #[serde(rename = "auth-failed")]
10618    AuthFailed,
10619    /// Unknown variant for forward compatibility.
10620    #[default]
10621    #[serde(other)]
10622    Unknown,
10623}
10624
10625/// How the pending MCP headers refresh request resolved.
10626#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10627pub enum McpHeadersRefreshCompletedOutcome {
10628    /// The host supplied dynamic headers.
10629    #[serde(rename = "headers")]
10630    Headers,
10631    /// The host responded with no dynamic headers.
10632    #[serde(rename = "none")]
10633    None,
10634    /// The host credential broker rejected or failed the refresh.
10635    #[serde(rename = "error")]
10636    Error,
10637    /// No response arrived within the bounded window.
10638    #[serde(rename = "timeout")]
10639    Timeout,
10640    /// Unknown variant for forward compatibility.
10641    #[default]
10642    #[serde(other)]
10643    Unknown,
10644}
10645
10646/// Lifecycle phase for a Rust-owned ephemeral query stream.
10647///
10648/// <div class="warning">
10649///
10650/// **Experimental.** This type is part of an experimental wire-protocol surface
10651/// and may change or be removed in future SDK or CLI releases.
10652///
10653/// </div>
10654#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10655pub enum UIEphemeralQueryPhase {
10656    /// The ephemeral query stream has begun.
10657    #[serde(rename = "started")]
10658    Started,
10659    /// A partial result chunk was produced by the stream.
10660    #[serde(rename = "chunk")]
10661    Chunk,
10662    /// The ephemeral query stream finished successfully.
10663    #[serde(rename = "completed")]
10664    Completed,
10665    /// The ephemeral query stream ended with an error.
10666    #[serde(rename = "failed")]
10667    Failed,
10668    /// The ephemeral query stream was cancelled before completing.
10669    #[serde(rename = "aborted")]
10670    Aborted,
10671    /// Unknown variant for forward compatibility.
10672    #[default]
10673    #[serde(other)]
10674    Unknown,
10675}
10676
10677/// The user's auto-mode-switch choice
10678#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10679pub enum AutoModeSwitchResponse {
10680    /// Switch models for this request.
10681    #[serde(rename = "yes")]
10682    Yes,
10683    /// Switch models now and keep using the replacement automatically.
10684    #[serde(rename = "yes_always")]
10685    YesAlways,
10686    /// Do not switch models.
10687    #[serde(rename = "no")]
10688    No,
10689    /// Unknown variant for forward compatibility.
10690    #[default]
10691    #[serde(other)]
10692    Unknown,
10693}
10694
10695/// User action selected for an exhausted session limit.
10696#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10697pub enum SessionLimitsExhaustedResponseAction {
10698    /// Increase the current max by an exact AI Credits amount.
10699    #[serde(rename = "add")]
10700    Add,
10701    /// Set a new absolute max AI Credits value.
10702    #[serde(rename = "set")]
10703    Set,
10704    /// Remove the current session limit.
10705    #[serde(rename = "unset")]
10706    Unset,
10707    /// Leave the limit unchanged and cancel the blocked model request.
10708    #[serde(rename = "cancel")]
10709    Cancel,
10710    /// Unknown variant for forward compatibility.
10711    #[default]
10712    #[serde(other)]
10713    Unknown,
10714}
10715
10716/// Coarse request-difficulty bucket for UX explainability
10717#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10718pub enum AutoModeResolvedReasoningBucket {
10719    /// The request looks low-reasoning; a lighter model is appropriate.
10720    #[serde(rename = "low")]
10721    Low,
10722    /// The request needs a moderate amount of reasoning.
10723    #[serde(rename = "medium")]
10724    Medium,
10725    /// The request looks high-reasoning; a stronger model is appropriate.
10726    #[serde(rename = "high")]
10727    High,
10728    /// Unknown variant for forward compatibility.
10729    #[default]
10730    #[serde(other)]
10731    Unknown,
10732}
10733
10734/// Summary of which managed-settings channels contributed to the effective session policy. Use the per-channel booleans for exact provenance.
10735#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10736pub enum ManagedSettingsResolvedSource {
10737    /// Only the server/account channel contributed.
10738    #[serde(rename = "server")]
10739    Server,
10740    /// Only the device MDM/plist/registry/file channel contributed.
10741    #[serde(rename = "device")]
10742    Device,
10743    /// Only session-local SDK-host injection contributed.
10744    #[serde(rename = "client")]
10745    Client,
10746    /// A policy helper registered by device or server policy contributed. Device registration takes priority when present.
10747    #[serde(rename = "policyHelper")]
10748    PolicyHelper,
10749    /// More than one channel contributed. Ordinary keys resolve device over server over policy helper per key, while permissions compose restrictively across all present layers.
10750    #[serde(rename = "mixed")]
10751    Mixed,
10752    /// No managed policy is in force (no channel contributed).
10753    #[serde(rename = "none")]
10754    None,
10755    /// Unknown variant for forward compatibility.
10756    #[default]
10757    #[serde(other)]
10758    Unknown,
10759}
10760
10761/// The category of runtime action that enterprise managed settings governed (blocked or capped)
10762#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10763pub enum ManagedSettingsEnforcedAction {
10764    /// An attempt to turn on a bypass-permissions ("yolo") escalation was refused or capped because policy disables bypass-permissions mode.
10765    #[serde(rename = "bypass_permissions_blocked")]
10766    BypassPermissionsBlocked,
10767    /// Unknown variant for forward compatibility.
10768    #[default]
10769    #[serde(other)]
10770    Unknown,
10771}
10772
10773/// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused
10774#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10775pub enum ManagedSettingsEnforcedEscalation {
10776    /// Full allow-all permissions — automatically approving tools, paths, and URLs.
10777    #[serde(rename = "allow_all")]
10778    AllowAll,
10779    /// Automatic approval of all tool permission requests.
10780    #[serde(rename = "approve_all")]
10781    ApproveAll,
10782    /// Assisted mode — keeps normal prompt paths and adds an LLM recommendation, distinct from allow-all.
10783    #[serde(rename = "assisted_approval")]
10784    AssistedApproval,
10785    /// Unrestricted filesystem access outside the session's allowed directories.
10786    #[serde(rename = "unrestricted_paths")]
10787    UnrestrictedPaths,
10788    /// Unrestricted URL fetch access.
10789    #[serde(rename = "unrestricted_urls")]
10790    UnrestrictedUrls,
10791    /// 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.
10792    #[serde(rename = "server_wide_mcp_approval")]
10793    ServerWideMcpApproval,
10794    /// Unknown variant for forward compatibility.
10795    #[default]
10796    #[serde(other)]
10797    Unknown,
10798}
10799
10800/// Exit plan mode action
10801#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10802pub enum ExitPlanModeAction {
10803    /// Exit plan mode without starting implementation.
10804    #[serde(rename = "exit_only")]
10805    ExitOnly,
10806    /// Exit plan mode and continue in interactive mode.
10807    #[serde(rename = "interactive")]
10808    Interactive,
10809    /// Exit plan mode and continue autonomously.
10810    #[serde(rename = "autopilot")]
10811    Autopilot,
10812    /// Exit plan mode and continue with parallel autonomous workers.
10813    #[serde(rename = "autopilot_fleet")]
10814    AutopilotFleet,
10815    /// Unknown variant for forward compatibility.
10816    #[default]
10817    #[serde(other)]
10818    Unknown,
10819}
10820
10821/// 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.
10822#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10823pub enum FactoryRunSettledStatus {
10824    /// The factory body resolved and its result was committed.
10825    #[serde(rename = "completed")]
10826    Completed,
10827    /// The run was stopped by a limit, an approval refusal or another policy decision.
10828    #[serde(rename = "halted")]
10829    Halted,
10830    /// The attempt paused intentionally while preserving resumable run state.
10831    #[serde(rename = "paused")]
10832    Paused,
10833    /// The run was cancelled by its caller or by session disposal.
10834    #[serde(rename = "cancelled")]
10835    Cancelled,
10836    /// The run failed, with `failureType` carrying the class when it has one.
10837    #[serde(rename = "error")]
10838    Error,
10839    /// Unknown variant for forward compatibility.
10840    #[default]
10841    #[serde(other)]
10842    Unknown,
10843}
10844
10845/// Source location type (e.g., project, personal-copilot, plugin, builtin, sdk)
10846#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10847pub enum SkillSource {
10848    /// Skill defined in the current project's skill directories.
10849    #[serde(rename = "project")]
10850    Project,
10851    /// Skill discovered from a parent directory in the current workspace tree.
10852    #[serde(rename = "inherited")]
10853    Inherited,
10854    /// Skill defined in the user's Copilot skill directory.
10855    #[serde(rename = "personal-copilot")]
10856    PersonalCopilot,
10857    /// Skill defined in the user's personal agents skill directory.
10858    #[serde(rename = "personal-agents")]
10859    PersonalAgents,
10860    /// Skill provided by an installed plugin.
10861    #[serde(rename = "plugin")]
10862    Plugin,
10863    /// Skill loaded from a configured custom skill directory.
10864    #[serde(rename = "custom")]
10865    Custom,
10866    /// Skill bundled with the runtime.
10867    #[serde(rename = "builtin")]
10868    Builtin,
10869    /// Pathless skill supplied lazily by an SDK skill provider.
10870    #[serde(rename = "sdk")]
10871    Sdk,
10872    /// Unknown variant for forward compatibility.
10873    #[default]
10874    #[serde(other)]
10875    Unknown,
10876}
10877
10878/// Whether configured models are advisory preferences or required constraints
10879#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10880pub enum AgentModelPolicy {
10881    /// Treat the authored models as advisory preferences that callers may override.
10882    #[serde(rename = "preferred")]
10883    Preferred,
10884    /// Require subagent execution to use one of the authored models.
10885    #[serde(rename = "required")]
10886    Required,
10887    /// Unknown variant for forward compatibility.
10888    #[default]
10889    #[serde(other)]
10890    Unknown,
10891}
10892
10893/// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
10894#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10895pub enum McpServerStatus {
10896    /// The server is connected and available.
10897    #[serde(rename = "connected")]
10898    Connected,
10899    /// The server failed to connect or initialize.
10900    #[serde(rename = "failed")]
10901    Failed,
10902    /// The server requires authentication before it can connect.
10903    #[serde(rename = "needs-auth")]
10904    NeedsAuth,
10905    /// The server connection is still being established.
10906    #[serde(rename = "pending")]
10907    Pending,
10908    /// The server is configured but disabled.
10909    #[serde(rename = "disabled")]
10910    Disabled,
10911    /// 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.
10912    #[serde(rename = "stopped")]
10913    Stopped,
10914    /// The server is not configured for this session.
10915    #[serde(rename = "not_configured")]
10916    NotConfigured,
10917    /// Unknown variant for forward compatibility.
10918    #[default]
10919    #[serde(other)]
10920    Unknown,
10921}
10922
10923/// Discovery source
10924#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10925pub enum ExtensionsLoadedExtensionSource {
10926    /// Extension discovered from the current project.
10927    #[serde(rename = "project")]
10928    Project,
10929    /// Extension discovered from the user's extension directory.
10930    #[serde(rename = "user")]
10931    User,
10932    /// Extension contributed by an installed plugin.
10933    #[serde(rename = "plugin")]
10934    Plugin,
10935    /// Extension discovered from the current session's state directory.
10936    #[serde(rename = "session")]
10937    Session,
10938    /// Unknown variant for forward compatibility.
10939    #[default]
10940    #[serde(other)]
10941    Unknown,
10942}
10943
10944/// Current status: running, disabled, failed, or starting
10945#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10946pub enum ExtensionsLoadedExtensionStatus {
10947    /// The extension process is running.
10948    #[serde(rename = "running")]
10949    Running,
10950    /// The extension is installed but disabled.
10951    #[serde(rename = "disabled")]
10952    Disabled,
10953    /// The extension failed to start or crashed.
10954    #[serde(rename = "failed")]
10955    Failed,
10956    /// The extension process is starting.
10957    #[serde(rename = "starting")]
10958    Starting,
10959    /// Unknown variant for forward compatibility.
10960    #[default]
10961    #[serde(other)]
10962    Unknown,
10963}