Skip to main content

github_copilot_sdk/generated/
session_events.rs

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