github_copilot_sdk/generated/session_events.rs
1//! Auto-generated from session-events.schema.json — do not edit manually.
2
3#![allow(deprecated)]
4
5use std::collections::HashMap;
6
7use serde::{Deserialize, Serialize};
8
9use crate::types::{RequestId, SessionId};
10
11/// Identifies the kind of session event.
12#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
13pub enum SessionEventType {
14 #[serde(rename = "session.start")]
15 SessionStart,
16 #[serde(rename = "session.resume")]
17 SessionResume,
18 #[serde(rename = "session.remote_steerable_changed")]
19 SessionRemoteSteerableChanged,
20 #[serde(rename = "session.error")]
21 SessionError,
22 #[serde(rename = "session.idle")]
23 SessionIdle,
24 #[serde(rename = "session.title_changed")]
25 SessionTitleChanged,
26 #[serde(rename = "session.schedule_created")]
27 SessionScheduleCreated,
28 #[serde(rename = "session.schedule_cancelled")]
29 SessionScheduleCancelled,
30 #[serde(rename = "session.schedule_rearmed")]
31 SessionScheduleRearmed,
32 #[serde(rename = "session.autopilot_objective_changed")]
33 SessionAutopilotObjectiveChanged,
34 #[serde(rename = "session.info")]
35 SessionInfo,
36 #[serde(rename = "session.indexed_search")]
37 SessionIndexedSearch,
38 #[serde(rename = "session.warning")]
39 SessionWarning,
40 #[serde(rename = "session.model_change")]
41 SessionModelChange,
42 #[serde(rename = "session.model_deselected")]
43 SessionModelDeselected,
44 ///
45 /// <div class="warning">
46 ///
47 /// **Experimental.** This type is part of an experimental wire-protocol surface
48 /// and may change or be removed in future SDK or CLI releases.
49 ///
50 /// </div>
51 #[serde(rename = "session.auto_tier_recommendation")]
52 SessionAutoTierRecommendation,
53 #[serde(rename = "session.auto_tier_switch_failed")]
54 SessionAutoTierSwitchFailed,
55 #[serde(rename = "session.mode_changed")]
56 SessionModeChanged,
57 #[serde(rename = "session.mode_notice_delivered")]
58 SessionModeNoticeDelivered,
59 #[serde(rename = "session.session_limits_changed")]
60 SessionSessionLimitsChanged,
61 ///
62 /// <div class="warning">
63 ///
64 /// **Experimental.** This type is part of an experimental wire-protocol surface
65 /// and may change or be removed in future SDK or CLI releases.
66 ///
67 /// </div>
68 #[serde(rename = "session.permissions_changed")]
69 SessionPermissionsChanged,
70 #[serde(rename = "session.plan_changed")]
71 SessionPlanChanged,
72 #[serde(rename = "session.todos_changed")]
73 SessionTodosChanged,
74 #[serde(rename = "session.workspace_file_changed")]
75 SessionWorkspaceFileChanged,
76 #[serde(rename = "session.handoff")]
77 SessionHandoff,
78 #[serde(rename = "session.truncation")]
79 SessionTruncation,
80 #[serde(rename = "session.snapshot_rewind")]
81 SessionSnapshotRewind,
82 #[serde(rename = "session.shutdown")]
83 SessionShutdown,
84 #[serde(rename = "session.usage_checkpoint")]
85 SessionUsageCheckpoint,
86 #[serde(rename = "session.context_changed")]
87 SessionContextChanged,
88 #[serde(rename = "session.usage_info")]
89 SessionUsageInfo,
90 #[serde(rename = "session.context_cleared")]
91 SessionContextCleared,
92 #[serde(rename = "session.compaction_start")]
93 SessionCompactionStart,
94 #[serde(rename = "session.compaction_complete")]
95 SessionCompactionComplete,
96 #[serde(rename = "session.task_complete")]
97 SessionTaskComplete,
98 ///
99 /// <div class="warning">
100 ///
101 /// **Experimental.** This type is part of an experimental wire-protocol surface
102 /// and may change or be removed in future SDK or CLI releases.
103 ///
104 /// </div>
105 #[serde(rename = "session.completion_receipt")]
106 SessionCompletionReceipt,
107 ///
108 /// <div class="warning">
109 ///
110 /// **Experimental.** This type is part of an experimental wire-protocol surface
111 /// and may change or be removed in future SDK or CLI releases.
112 ///
113 /// </div>
114 #[serde(rename = "session.fusion_route_started")]
115 SessionFusionRouteStarted,
116 ///
117 /// <div class="warning">
118 ///
119 /// **Experimental.** This type is part of an experimental wire-protocol surface
120 /// and may change or be removed in future SDK or CLI releases.
121 ///
122 /// </div>
123 #[serde(rename = "session.fusion_route_failed")]
124 SessionFusionRouteFailed,
125 ///
126 /// <div class="warning">
127 ///
128 /// **Experimental.** This type is part of an experimental wire-protocol surface
129 /// and may change or be removed in future SDK or CLI releases.
130 ///
131 /// </div>
132 #[serde(rename = "session.fusion_resolved")]
133 SessionFusionResolved,
134 ///
135 /// <div class="warning">
136 ///
137 /// **Experimental.** This type is part of an experimental wire-protocol surface
138 /// and may change or be removed in future SDK or CLI releases.
139 ///
140 /// </div>
141 #[serde(rename = "session.fusion_completed")]
142 SessionFusionCompleted,
143 #[serde(rename = "session.permission_recovery")]
144 SessionPermissionRecovery,
145 #[serde(rename = "user.message")]
146 UserMessage,
147 #[serde(rename = "pending_messages.modified")]
148 PendingMessagesModified,
149 #[serde(rename = "assistant.turn_start")]
150 AssistantTurnStart,
151 #[serde(rename = "assistant.turn_retry")]
152 AssistantTurnRetry,
153 #[serde(rename = "agent.interrupted")]
154 AgentInterrupted,
155 #[serde(rename = "assistant.intent")]
156 AssistantIntent,
157 ///
158 /// <div class="warning">
159 ///
160 /// **Experimental.** This type is part of an experimental wire-protocol surface
161 /// and may change or be removed in future SDK or CLI releases.
162 ///
163 /// </div>
164 #[serde(rename = "assistant.fusion_phase_started")]
165 AssistantFusionPhaseStarted,
166 ///
167 /// <div class="warning">
168 ///
169 /// **Experimental.** This type is part of an experimental wire-protocol surface
170 /// and may change or be removed in future SDK or CLI releases.
171 ///
172 /// </div>
173 #[serde(rename = "assistant.fusion_phase_activity")]
174 AssistantFusionPhaseActivity,
175 ///
176 /// <div class="warning">
177 ///
178 /// **Experimental.** This type is part of an experimental wire-protocol surface
179 /// and may change or be removed in future SDK or CLI releases.
180 ///
181 /// </div>
182 #[serde(rename = "assistant.fusion_phase_completed")]
183 AssistantFusionPhaseCompleted,
184 ///
185 /// <div class="warning">
186 ///
187 /// **Experimental.** This type is part of an experimental wire-protocol surface
188 /// and may change or be removed in future SDK or CLI releases.
189 ///
190 /// </div>
191 #[serde(rename = "assistant.fusion_phase_failed")]
192 AssistantFusionPhaseFailed,
193 #[serde(rename = "assistant.server_tool_progress")]
194 AssistantServerToolProgress,
195 #[serde(rename = "assistant.reasoning")]
196 AssistantReasoning,
197 #[serde(rename = "assistant.reasoning_delta")]
198 AssistantReasoningDelta,
199 #[serde(rename = "assistant.tool_call_delta")]
200 AssistantToolCallDelta,
201 #[serde(rename = "assistant.streaming_delta")]
202 AssistantStreamingDelta,
203 #[serde(rename = "assistant.message")]
204 AssistantMessage,
205 #[serde(rename = "assistant.message_start")]
206 AssistantMessageStart,
207 #[serde(rename = "assistant.message_delta")]
208 AssistantMessageDelta,
209 #[serde(rename = "assistant.turn_end")]
210 AssistantTurnEnd,
211 #[serde(rename = "assistant.idle")]
212 AssistantIdle,
213 #[serde(rename = "assistant.usage")]
214 AssistantUsage,
215 #[serde(rename = "prompt_cache_break")]
216 PromptCacheBreak,
217 #[serde(rename = "model.call_failure")]
218 ModelCallFailure,
219 #[serde(rename = "model.call_finished")]
220 ModelCallFinished,
221 #[serde(rename = "model.call_start")]
222 ModelCallStart,
223 #[serde(rename = "abort")]
224 Abort,
225 #[serde(rename = "tool.user_requested")]
226 ToolUserRequested,
227 #[serde(rename = "tool.execution_start")]
228 ToolExecutionStart,
229 #[serde(rename = "tool.execution_partial_result")]
230 ToolExecutionPartialResult,
231 #[serde(rename = "tool.execution_progress")]
232 ToolExecutionProgress,
233 #[serde(rename = "tool.execution_complete")]
234 ToolExecutionComplete,
235 #[serde(rename = "tool_search.activated")]
236 ToolSearchActivated,
237 #[serde(rename = "skill.invoked")]
238 SkillInvoked,
239 ///
240 /// <div class="warning">
241 ///
242 /// **Experimental.** This type is part of an experimental wire-protocol surface
243 /// and may change or be removed in future SDK or CLI releases.
244 ///
245 /// </div>
246 #[serde(rename = "skill.invoked_ref")]
247 SkillInvokedRef,
248 ///
249 /// <div class="warning">
250 ///
251 /// **Experimental.** This type is part of an experimental wire-protocol surface
252 /// and may change or be removed in future SDK or CLI releases.
253 ///
254 /// </div>
255 #[serde(rename = "skill.context_delivered")]
256 SkillContextDelivered,
257 ///
258 /// <div class="warning">
259 ///
260 /// **Experimental.** This type is part of an experimental wire-protocol surface
261 /// and may change or be removed in future SDK or CLI releases.
262 ///
263 /// </div>
264 #[serde(rename = "skill.context_delivered_ref")]
265 SkillContextDeliveredRef,
266 #[serde(rename = "sandbox.decision")]
267 SandboxDecision,
268 #[serde(rename = "subagent.started")]
269 SubagentStarted,
270 #[serde(rename = "subagent.configured")]
271 SubagentConfigured,
272 #[serde(rename = "subagent.completed")]
273 SubagentCompleted,
274 #[serde(rename = "subagent.failed")]
275 SubagentFailed,
276 #[serde(rename = "subagent.selected")]
277 SubagentSelected,
278 #[serde(rename = "subagent.deselected")]
279 SubagentDeselected,
280 #[serde(rename = "hook.start")]
281 HookStart,
282 #[serde(rename = "hook.end")]
283 HookEnd,
284 #[serde(rename = "hook.progress")]
285 HookProgress,
286 ///
287 /// <div class="warning">
288 ///
289 /// **Experimental.** This type is part of an experimental wire-protocol surface
290 /// and may change or be removed in future SDK or CLI releases.
291 ///
292 /// </div>
293 #[serde(rename = "session.binary_asset")]
294 SessionBinaryAsset,
295 #[serde(rename = "system.message")]
296 SystemMessage,
297 #[serde(rename = "system.notification")]
298 SystemNotification,
299 #[serde(rename = "permission.requested")]
300 PermissionRequested,
301 #[serde(rename = "permission.completed")]
302 PermissionCompleted,
303 ///
304 /// <div class="warning">
305 ///
306 /// **Experimental.** This type is part of an experimental wire-protocol surface
307 /// and may change or be removed in future SDK or CLI releases.
308 ///
309 /// </div>
310 #[serde(rename = "permission.carriedForward")]
311 PermissionCarriedForward,
312 ///
313 /// <div class="warning">
314 ///
315 /// **Experimental.** This type is part of an experimental wire-protocol surface
316 /// and may change or be removed in future SDK or CLI releases.
317 ///
318 /// </div>
319 #[serde(rename = "permission.messageAuthorization")]
320 PermissionMessageAuthorization,
321 ///
322 /// <div class="warning">
323 ///
324 /// **Experimental.** This type is part of an experimental wire-protocol surface
325 /// and may change or be removed in future SDK or CLI releases.
326 ///
327 /// </div>
328 #[serde(rename = "permission.messageAuthorizationRead")]
329 PermissionMessageAuthorizationRead,
330 ///
331 /// <div class="warning">
332 ///
333 /// **Experimental.** This type is part of an experimental wire-protocol surface
334 /// and may change or be removed in future SDK or CLI releases.
335 ///
336 /// </div>
337 #[serde(rename = "permission.messageAuthorizationDegraded")]
338 PermissionMessageAuthorizationDegraded,
339 ///
340 /// <div class="warning">
341 ///
342 /// **Experimental.** This type is part of an experimental wire-protocol surface
343 /// and may change or be removed in future SDK or CLI releases.
344 ///
345 /// </div>
346 #[serde(rename = "permission.assentDetected")]
347 PermissionAssentDetected,
348 ///
349 /// <div class="warning">
350 ///
351 /// **Experimental.** This type is part of an experimental wire-protocol surface
352 /// and may change or be removed in future SDK or CLI releases.
353 ///
354 /// </div>
355 #[serde(rename = "permission.contextualAuthorization")]
356 PermissionContextualAuthorization,
357 #[serde(rename = "user_input.requested")]
358 UserInputRequested,
359 #[serde(rename = "user_input.completed")]
360 UserInputCompleted,
361 #[serde(rename = "elicitation.requested")]
362 ElicitationRequested,
363 #[serde(rename = "elicitation.completed")]
364 ElicitationCompleted,
365 #[serde(rename = "sampling.requested")]
366 SamplingRequested,
367 #[serde(rename = "sampling.completed")]
368 SamplingCompleted,
369 #[serde(rename = "mcp.oauth_required")]
370 McpOauthRequired,
371 #[serde(rename = "mcp.oauth_completed")]
372 McpOauthCompleted,
373 #[serde(rename = "mcp.headers_refresh_required")]
374 McpHeadersRefreshRequired,
375 #[serde(rename = "mcp.headers_refresh_completed")]
376 McpHeadersRefreshCompleted,
377 #[serde(rename = "session.custom_notification")]
378 SessionCustomNotification,
379 ///
380 /// <div class="warning">
381 ///
382 /// **Experimental.** This type is part of an experimental wire-protocol surface
383 /// and may change or be removed in future SDK or CLI releases.
384 ///
385 /// </div>
386 #[serde(rename = "ui.ephemeral_query")]
387 UiEphemeralQuery,
388 #[serde(rename = "external_tool.requested")]
389 ExternalToolRequested,
390 #[serde(rename = "external_tool.completed")]
391 ExternalToolCompleted,
392 #[serde(rename = "command.queued")]
393 CommandQueued,
394 #[serde(rename = "command.execute")]
395 CommandExecute,
396 #[serde(rename = "command.completed")]
397 CommandCompleted,
398 #[serde(rename = "auto_mode_switch.requested")]
399 AutoModeSwitchRequested,
400 #[serde(rename = "auto_mode_switch.completed")]
401 AutoModeSwitchCompleted,
402 #[serde(rename = "session_limits_exhausted.requested")]
403 SessionLimitsExhaustedRequested,
404 #[serde(rename = "session_limits_exhausted.completed")]
405 SessionLimitsExhaustedCompleted,
406 ///
407 /// <div class="warning">
408 ///
409 /// **Experimental.** This type is part of an experimental wire-protocol surface
410 /// and may change or be removed in future SDK or CLI releases.
411 ///
412 /// </div>
413 #[serde(rename = "session.auto_mode_resolved")]
414 SessionAutoModeResolved,
415 ///
416 /// <div class="warning">
417 ///
418 /// **Experimental.** This type is part of an experimental wire-protocol surface
419 /// and may change or be removed in future SDK or CLI releases.
420 ///
421 /// </div>
422 #[serde(rename = "session.managed_settings_resolved")]
423 SessionManagedSettingsResolved,
424 ///
425 /// <div class="warning">
426 ///
427 /// **Experimental.** This type is part of an experimental wire-protocol surface
428 /// and may change or be removed in future SDK or CLI releases.
429 ///
430 /// </div>
431 #[serde(rename = "session.managed_settings_enforced")]
432 SessionManagedSettingsEnforced,
433 #[serde(rename = "commands.changed")]
434 CommandsChanged,
435 #[serde(rename = "capabilities.changed")]
436 CapabilitiesChanged,
437 #[serde(rename = "exit_plan_mode.requested")]
438 ExitPlanModeRequested,
439 #[serde(rename = "exit_plan_mode.completed")]
440 ExitPlanModeCompleted,
441 #[serde(rename = "session.tools_updated")]
442 SessionToolsUpdated,
443 #[serde(rename = "session.background_tasks_changed")]
444 SessionBackgroundTasksChanged,
445 ///
446 /// <div class="warning">
447 ///
448 /// **Experimental.** This type is part of an experimental wire-protocol surface
449 /// and may change or be removed in future SDK or CLI releases.
450 ///
451 /// </div>
452 #[serde(rename = "factory.run_updated")]
453 FactoryRunUpdated,
454 ///
455 /// <div class="warning">
456 ///
457 /// **Experimental.** This type is part of an experimental wire-protocol surface
458 /// and may change or be removed in future SDK or CLI releases.
459 ///
460 /// </div>
461 #[serde(rename = "factory.run_started")]
462 FactoryRunStarted,
463 ///
464 /// <div class="warning">
465 ///
466 /// **Experimental.** This type is part of an experimental wire-protocol surface
467 /// and may change or be removed in future SDK or CLI releases.
468 ///
469 /// </div>
470 #[serde(rename = "factory.run_settled")]
471 FactoryRunSettled,
472 #[serde(rename = "session.skills_loaded")]
473 SessionSkillsLoaded,
474 #[serde(rename = "session.custom_agents_updated")]
475 SessionCustomAgentsUpdated,
476 #[serde(rename = "session.mcp_servers_loaded")]
477 SessionMcpServersLoaded,
478 #[serde(rename = "session.mcp_server_status_changed")]
479 SessionMcpServerStatusChanged,
480 #[serde(rename = "session.mcp_server_removed")]
481 SessionMcpServerRemoved,
482 #[serde(rename = "session.mcp_server_needs_reconnect")]
483 SessionMcpServerNeedsReconnect,
484 #[serde(rename = "mcp.tools.list_changed")]
485 McpToolsListChanged,
486 #[serde(rename = "mcp.resources.list_changed")]
487 McpResourcesListChanged,
488 #[serde(rename = "mcp.prompts.list_changed")]
489 McpPromptsListChanged,
490 #[serde(rename = "session.extensions_loaded")]
491 SessionExtensionsLoaded,
492 ///
493 /// <div class="warning">
494 ///
495 /// **Experimental.** This type is part of an experimental wire-protocol surface
496 /// and may change or be removed in future SDK or CLI releases.
497 ///
498 /// </div>
499 #[serde(rename = "session.canvas.opened")]
500 SessionCanvasOpened,
501 ///
502 /// <div class="warning">
503 ///
504 /// **Experimental.** This type is part of an experimental wire-protocol surface
505 /// and may change or be removed in future SDK or CLI releases.
506 ///
507 /// </div>
508 #[serde(rename = "session.canvas.registry_changed")]
509 SessionCanvasRegistryChanged,
510 ///
511 /// <div class="warning">
512 ///
513 /// **Experimental.** This type is part of an experimental wire-protocol surface
514 /// and may change or be removed in future SDK or CLI releases.
515 ///
516 /// </div>
517 #[serde(rename = "session.canvas.closed")]
518 SessionCanvasClosed,
519 ///
520 /// <div class="warning">
521 ///
522 /// **Experimental.** This type is part of an experimental wire-protocol surface
523 /// and may change or be removed in future SDK or CLI releases.
524 ///
525 /// </div>
526 #[serde(rename = "session.canvas.unavailable")]
527 SessionCanvasUnavailable,
528 ///
529 /// <div class="warning">
530 ///
531 /// **Experimental.** This type is part of an experimental wire-protocol surface
532 /// and may change or be removed in future SDK or CLI releases.
533 ///
534 /// </div>
535 #[serde(rename = "session.canvas.recorded")]
536 SessionCanvasRecorded,
537 ///
538 /// <div class="warning">
539 ///
540 /// **Experimental.** This type is part of an experimental wire-protocol surface
541 /// and may change or be removed in future SDK or CLI releases.
542 ///
543 /// </div>
544 #[serde(rename = "session.canvas.removed")]
545 SessionCanvasRemoved,
546 #[serde(rename = "session.extensions.attachments_pushed")]
547 SessionExtensionsAttachmentsPushed,
548 #[serde(rename = "mcp_app.tool_call_complete")]
549 McpAppToolCallComplete,
550 /// Unknown event type for forward compatibility.
551 #[default]
552 #[serde(other)]
553 Unknown,
554}
555
556/// Typed session event data, discriminated by the event `type` field.
557///
558/// Use with [`TypedSessionEvent`] for fully typed event handling.
559#[derive(Debug, Clone, Serialize, Deserialize)]
560#[serde(tag = "type", content = "data")]
561pub enum SessionEventData {
562 #[serde(rename = "session.start")]
563 SessionStart(SessionStartData),
564 #[serde(rename = "session.resume")]
565 SessionResume(SessionResumeData),
566 #[serde(rename = "session.remote_steerable_changed")]
567 SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
568 #[serde(rename = "session.error")]
569 SessionError(SessionErrorData),
570 #[serde(rename = "session.idle")]
571 SessionIdle(SessionIdleData),
572 #[serde(rename = "session.title_changed")]
573 SessionTitleChanged(SessionTitleChangedData),
574 #[serde(rename = "session.schedule_created")]
575 SessionScheduleCreated(SessionScheduleCreatedData),
576 #[serde(rename = "session.schedule_cancelled")]
577 SessionScheduleCancelled(SessionScheduleCancelledData),
578 #[serde(rename = "session.schedule_rearmed")]
579 SessionScheduleRearmed(SessionScheduleRearmedData),
580 #[serde(rename = "session.autopilot_objective_changed")]
581 SessionAutopilotObjectiveChanged(SessionAutopilotObjectiveChangedData),
582 #[serde(rename = "session.info")]
583 SessionInfo(SessionInfoData),
584 #[serde(rename = "session.indexed_search")]
585 SessionIndexedSearch(SessionIndexedSearchData),
586 #[serde(rename = "session.warning")]
587 SessionWarning(SessionWarningData),
588 #[serde(rename = "session.model_change")]
589 SessionModelChange(SessionModelChangeData),
590 #[serde(rename = "session.model_deselected")]
591 SessionModelDeselected(SessionModelDeselectedData),
592 ///
593 /// <div class="warning">
594 ///
595 /// **Experimental.** This type is part of an experimental wire-protocol surface
596 /// and may change or be removed in future SDK or CLI releases.
597 ///
598 /// </div>
599 #[serde(rename = "session.auto_tier_recommendation")]
600 SessionAutoTierRecommendation(SessionAutoTierRecommendationData),
601 #[serde(rename = "session.auto_tier_switch_failed")]
602 SessionAutoTierSwitchFailed(SessionAutoTierSwitchFailedData),
603 #[serde(rename = "session.mode_changed")]
604 SessionModeChanged(SessionModeChangedData),
605 #[serde(rename = "session.mode_notice_delivered")]
606 SessionModeNoticeDelivered(SessionModeNoticeDeliveredData),
607 #[serde(rename = "session.session_limits_changed")]
608 SessionSessionLimitsChanged(SessionSessionLimitsChangedData),
609 ///
610 /// <div class="warning">
611 ///
612 /// **Experimental.** This type is part of an experimental wire-protocol surface
613 /// and may change or be removed in future SDK or CLI releases.
614 ///
615 /// </div>
616 #[serde(rename = "session.permissions_changed")]
617 SessionPermissionsChanged(SessionPermissionsChangedData),
618 #[serde(rename = "session.plan_changed")]
619 SessionPlanChanged(SessionPlanChangedData),
620 #[serde(rename = "session.todos_changed")]
621 SessionTodosChanged(SessionTodosChangedData),
622 #[serde(rename = "session.workspace_file_changed")]
623 SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
624 #[serde(rename = "session.handoff")]
625 SessionHandoff(SessionHandoffData),
626 #[serde(rename = "session.truncation")]
627 SessionTruncation(SessionTruncationData),
628 #[serde(rename = "session.snapshot_rewind")]
629 SessionSnapshotRewind(SessionSnapshotRewindData),
630 #[serde(rename = "session.shutdown")]
631 SessionShutdown(SessionShutdownData),
632 #[serde(rename = "session.usage_checkpoint")]
633 SessionUsageCheckpoint(SessionUsageCheckpointData),
634 #[serde(rename = "session.context_changed")]
635 SessionContextChanged(SessionContextChangedData),
636 #[serde(rename = "session.usage_info")]
637 SessionUsageInfo(SessionUsageInfoData),
638 #[serde(rename = "session.context_cleared")]
639 SessionContextCleared(SessionContextClearedData),
640 #[serde(rename = "session.compaction_start")]
641 SessionCompactionStart(SessionCompactionStartData),
642 #[serde(rename = "session.compaction_complete")]
643 SessionCompactionComplete(SessionCompactionCompleteData),
644 #[serde(rename = "session.task_complete")]
645 SessionTaskComplete(SessionTaskCompleteData),
646 ///
647 /// <div class="warning">
648 ///
649 /// **Experimental.** This type is part of an experimental wire-protocol surface
650 /// and may change or be removed in future SDK or CLI releases.
651 ///
652 /// </div>
653 #[serde(rename = "session.completion_receipt")]
654 SessionCompletionReceipt(SessionCompletionReceiptData),
655 ///
656 /// <div class="warning">
657 ///
658 /// **Experimental.** This type is part of an experimental wire-protocol surface
659 /// and may change or be removed in future SDK or CLI releases.
660 ///
661 /// </div>
662 #[serde(rename = "session.fusion_route_started")]
663 SessionFusionRouteStarted(SessionFusionRouteStartedData),
664 ///
665 /// <div class="warning">
666 ///
667 /// **Experimental.** This type is part of an experimental wire-protocol surface
668 /// and may change or be removed in future SDK or CLI releases.
669 ///
670 /// </div>
671 #[serde(rename = "session.fusion_route_failed")]
672 SessionFusionRouteFailed(SessionFusionRouteFailedData),
673 ///
674 /// <div class="warning">
675 ///
676 /// **Experimental.** This type is part of an experimental wire-protocol surface
677 /// and may change or be removed in future SDK or CLI releases.
678 ///
679 /// </div>
680 #[serde(rename = "session.fusion_resolved")]
681 SessionFusionResolved(SessionFusionResolvedData),
682 ///
683 /// <div class="warning">
684 ///
685 /// **Experimental.** This type is part of an experimental wire-protocol surface
686 /// and may change or be removed in future SDK or CLI releases.
687 ///
688 /// </div>
689 #[serde(rename = "session.fusion_completed")]
690 SessionFusionCompleted(SessionFusionCompletedData),
691 #[serde(rename = "session.permission_recovery")]
692 SessionPermissionRecovery(SessionPermissionRecoveryData),
693 #[serde(rename = "user.message")]
694 UserMessage(UserMessageData),
695 #[serde(rename = "pending_messages.modified")]
696 PendingMessagesModified(PendingMessagesModifiedData),
697 #[serde(rename = "assistant.turn_start")]
698 AssistantTurnStart(AssistantTurnStartData),
699 #[serde(rename = "assistant.turn_retry")]
700 AssistantTurnRetry(AssistantTurnRetryData),
701 #[serde(rename = "agent.interrupted")]
702 AgentInterrupted(AgentInterruptedData),
703 #[serde(rename = "assistant.intent")]
704 AssistantIntent(AssistantIntentData),
705 ///
706 /// <div class="warning">
707 ///
708 /// **Experimental.** This type is part of an experimental wire-protocol surface
709 /// and may change or be removed in future SDK or CLI releases.
710 ///
711 /// </div>
712 #[serde(rename = "assistant.fusion_phase_started")]
713 AssistantFusionPhaseStarted(AssistantFusionPhaseStartedData),
714 ///
715 /// <div class="warning">
716 ///
717 /// **Experimental.** This type is part of an experimental wire-protocol surface
718 /// and may change or be removed in future SDK or CLI releases.
719 ///
720 /// </div>
721 #[serde(rename = "assistant.fusion_phase_activity")]
722 AssistantFusionPhaseActivity(AssistantFusionPhaseActivityData),
723 ///
724 /// <div class="warning">
725 ///
726 /// **Experimental.** This type is part of an experimental wire-protocol surface
727 /// and may change or be removed in future SDK or CLI releases.
728 ///
729 /// </div>
730 #[serde(rename = "assistant.fusion_phase_completed")]
731 AssistantFusionPhaseCompleted(AssistantFusionPhaseCompletedData),
732 ///
733 /// <div class="warning">
734 ///
735 /// **Experimental.** This type is part of an experimental wire-protocol surface
736 /// and may change or be removed in future SDK or CLI releases.
737 ///
738 /// </div>
739 #[serde(rename = "assistant.fusion_phase_failed")]
740 AssistantFusionPhaseFailed(AssistantFusionPhaseFailedData),
741 #[serde(rename = "assistant.server_tool_progress")]
742 AssistantServerToolProgress(AssistantServerToolProgressData),
743 #[serde(rename = "assistant.reasoning")]
744 AssistantReasoning(AssistantReasoningData),
745 #[serde(rename = "assistant.reasoning_delta")]
746 AssistantReasoningDelta(AssistantReasoningDeltaData),
747 #[serde(rename = "assistant.tool_call_delta")]
748 AssistantToolCallDelta(AssistantToolCallDeltaData),
749 #[serde(rename = "assistant.streaming_delta")]
750 AssistantStreamingDelta(AssistantStreamingDeltaData),
751 #[serde(rename = "assistant.message")]
752 AssistantMessage(AssistantMessageData),
753 #[serde(rename = "assistant.message_start")]
754 AssistantMessageStart(AssistantMessageStartData),
755 #[serde(rename = "assistant.message_delta")]
756 AssistantMessageDelta(AssistantMessageDeltaData),
757 #[serde(rename = "assistant.turn_end")]
758 AssistantTurnEnd(AssistantTurnEndData),
759 #[serde(rename = "assistant.idle")]
760 AssistantIdle(AssistantIdleData),
761 #[serde(rename = "assistant.usage")]
762 AssistantUsage(AssistantUsageData),
763 #[serde(rename = "prompt_cache_break")]
764 PromptCacheBreak(PromptCacheBreakData),
765 #[serde(rename = "model.call_failure")]
766 ModelCallFailure(ModelCallFailureData),
767 #[serde(rename = "model.call_finished")]
768 ModelCallFinished(ModelCallFinishedData),
769 #[serde(rename = "model.call_start")]
770 ModelCallStart(ModelCallStartData),
771 #[serde(rename = "abort")]
772 Abort(AbortData),
773 #[serde(rename = "tool.user_requested")]
774 ToolUserRequested(ToolUserRequestedData),
775 #[serde(rename = "tool.execution_start")]
776 ToolExecutionStart(ToolExecutionStartData),
777 #[serde(rename = "tool.execution_partial_result")]
778 ToolExecutionPartialResult(ToolExecutionPartialResultData),
779 #[serde(rename = "tool.execution_progress")]
780 ToolExecutionProgress(ToolExecutionProgressData),
781 #[serde(rename = "tool.execution_complete")]
782 ToolExecutionComplete(ToolExecutionCompleteData),
783 #[serde(rename = "tool_search.activated")]
784 ToolSearchActivated(ToolSearchActivatedData),
785 #[serde(rename = "skill.invoked")]
786 SkillInvoked(SkillInvokedData),
787 #[serde(rename = "skill.invoked_ref")]
788 SkillInvokedRef(SkillInvokedRefData),
789 #[serde(rename = "skill.context_delivered")]
790 SkillContextDelivered(SkillContextDeliveredData),
791 #[serde(rename = "skill.context_delivered_ref")]
792 SkillContextDeliveredRef(SkillContextDeliveredRefData),
793 #[serde(rename = "sandbox.decision")]
794 SandboxDecision(SandboxDecisionData),
795 #[serde(rename = "subagent.started")]
796 SubagentStarted(SubagentStartedData),
797 #[serde(rename = "subagent.configured")]
798 SubagentConfigured(SubagentConfiguredData),
799 #[serde(rename = "subagent.completed")]
800 SubagentCompleted(SubagentCompletedData),
801 #[serde(rename = "subagent.failed")]
802 SubagentFailed(SubagentFailedData),
803 #[serde(rename = "subagent.selected")]
804 SubagentSelected(SubagentSelectedData),
805 #[serde(rename = "subagent.deselected")]
806 SubagentDeselected(SubagentDeselectedData),
807 #[serde(rename = "hook.start")]
808 HookStart(HookStartData),
809 #[serde(rename = "hook.end")]
810 HookEnd(HookEndData),
811 #[serde(rename = "hook.progress")]
812 HookProgress(HookProgressData),
813 #[serde(rename = "session.binary_asset")]
814 SessionBinaryAsset(SessionBinaryAssetData),
815 #[serde(rename = "system.message")]
816 SystemMessage(SystemMessageData),
817 #[serde(rename = "system.notification")]
818 SystemNotification(SystemNotificationData),
819 #[serde(rename = "permission.requested")]
820 PermissionRequested(PermissionRequestedData),
821 #[serde(rename = "permission.completed")]
822 PermissionCompleted(PermissionCompletedData),
823 ///
824 /// <div class="warning">
825 ///
826 /// **Experimental.** This type is part of an experimental wire-protocol surface
827 /// and may change or be removed in future SDK or CLI releases.
828 ///
829 /// </div>
830 #[serde(rename = "permission.carriedForward")]
831 PermissionCarriedForward(PermissionCarriedForwardData),
832 ///
833 /// <div class="warning">
834 ///
835 /// **Experimental.** This type is part of an experimental wire-protocol surface
836 /// and may change or be removed in future SDK or CLI releases.
837 ///
838 /// </div>
839 #[serde(rename = "permission.messageAuthorization")]
840 PermissionMessageAuthorization(PermissionMessageAuthorizationData),
841 ///
842 /// <div class="warning">
843 ///
844 /// **Experimental.** This type is part of an experimental wire-protocol surface
845 /// and may change or be removed in future SDK or CLI releases.
846 ///
847 /// </div>
848 #[serde(rename = "permission.messageAuthorizationRead")]
849 PermissionMessageAuthorizationRead(PermissionMessageAuthorizationReadData),
850 ///
851 /// <div class="warning">
852 ///
853 /// **Experimental.** This type is part of an experimental wire-protocol surface
854 /// and may change or be removed in future SDK or CLI releases.
855 ///
856 /// </div>
857 #[serde(rename = "permission.messageAuthorizationDegraded")]
858 PermissionMessageAuthorizationDegraded(PermissionMessageAuthorizationDegradedData),
859 ///
860 /// <div class="warning">
861 ///
862 /// **Experimental.** This type is part of an experimental wire-protocol surface
863 /// and may change or be removed in future SDK or CLI releases.
864 ///
865 /// </div>
866 #[serde(rename = "permission.assentDetected")]
867 PermissionAssentDetected(PermissionAssentDetectedData),
868 ///
869 /// <div class="warning">
870 ///
871 /// **Experimental.** This type is part of an experimental wire-protocol surface
872 /// and may change or be removed in future SDK or CLI releases.
873 ///
874 /// </div>
875 #[serde(rename = "permission.contextualAuthorization")]
876 PermissionContextualAuthorization(PermissionContextualAuthorizationData),
877 #[serde(rename = "user_input.requested")]
878 UserInputRequested(UserInputRequestedData),
879 #[serde(rename = "user_input.completed")]
880 UserInputCompleted(UserInputCompletedData),
881 #[serde(rename = "elicitation.requested")]
882 ElicitationRequested(ElicitationRequestedData),
883 #[serde(rename = "elicitation.completed")]
884 ElicitationCompleted(ElicitationCompletedData),
885 #[serde(rename = "sampling.requested")]
886 SamplingRequested(SamplingRequestedData),
887 #[serde(rename = "sampling.completed")]
888 SamplingCompleted(SamplingCompletedData),
889 #[serde(rename = "mcp.oauth_required")]
890 McpOauthRequired(McpOauthRequiredData),
891 #[serde(rename = "mcp.oauth_completed")]
892 McpOauthCompleted(McpOauthCompletedData),
893 #[serde(rename = "mcp.headers_refresh_required")]
894 McpHeadersRefreshRequired(McpHeadersRefreshRequiredData),
895 #[serde(rename = "mcp.headers_refresh_completed")]
896 McpHeadersRefreshCompleted(McpHeadersRefreshCompletedData),
897 #[serde(rename = "session.custom_notification")]
898 SessionCustomNotification(SessionCustomNotificationData),
899 ///
900 /// <div class="warning">
901 ///
902 /// **Experimental.** This type is part of an experimental wire-protocol surface
903 /// and may change or be removed in future SDK or CLI releases.
904 ///
905 /// </div>
906 #[serde(rename = "ui.ephemeral_query")]
907 UiEphemeralQuery(UiEphemeralQueryData),
908 #[serde(rename = "external_tool.requested")]
909 ExternalToolRequested(ExternalToolRequestedData),
910 #[serde(rename = "external_tool.completed")]
911 ExternalToolCompleted(ExternalToolCompletedData),
912 #[serde(rename = "command.queued")]
913 CommandQueued(CommandQueuedData),
914 #[serde(rename = "command.execute")]
915 CommandExecute(CommandExecuteData),
916 #[serde(rename = "command.completed")]
917 CommandCompleted(CommandCompletedData),
918 #[serde(rename = "auto_mode_switch.requested")]
919 AutoModeSwitchRequested(AutoModeSwitchRequestedData),
920 #[serde(rename = "auto_mode_switch.completed")]
921 AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
922 #[serde(rename = "session_limits_exhausted.requested")]
923 SessionLimitsExhaustedRequested(SessionLimitsExhaustedRequestedData),
924 #[serde(rename = "session_limits_exhausted.completed")]
925 SessionLimitsExhaustedCompleted(SessionLimitsExhaustedCompletedData),
926 ///
927 /// <div class="warning">
928 ///
929 /// **Experimental.** This type is part of an experimental wire-protocol surface
930 /// and may change or be removed in future SDK or CLI releases.
931 ///
932 /// </div>
933 #[serde(rename = "session.auto_mode_resolved")]
934 SessionAutoModeResolved(SessionAutoModeResolvedData),
935 ///
936 /// <div class="warning">
937 ///
938 /// **Experimental.** This type is part of an experimental wire-protocol surface
939 /// and may change or be removed in future SDK or CLI releases.
940 ///
941 /// </div>
942 #[serde(rename = "session.managed_settings_resolved")]
943 SessionManagedSettingsResolved(SessionManagedSettingsResolvedData),
944 ///
945 /// <div class="warning">
946 ///
947 /// **Experimental.** This type is part of an experimental wire-protocol surface
948 /// and may change or be removed in future SDK or CLI releases.
949 ///
950 /// </div>
951 #[serde(rename = "session.managed_settings_enforced")]
952 SessionManagedSettingsEnforced(SessionManagedSettingsEnforcedData),
953 #[serde(rename = "commands.changed")]
954 CommandsChanged(CommandsChangedData),
955 #[serde(rename = "capabilities.changed")]
956 CapabilitiesChanged(CapabilitiesChangedData),
957 #[serde(rename = "exit_plan_mode.requested")]
958 ExitPlanModeRequested(ExitPlanModeRequestedData),
959 #[serde(rename = "exit_plan_mode.completed")]
960 ExitPlanModeCompleted(ExitPlanModeCompletedData),
961 #[serde(rename = "session.tools_updated")]
962 SessionToolsUpdated(SessionToolsUpdatedData),
963 #[serde(rename = "session.background_tasks_changed")]
964 SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
965 ///
966 /// <div class="warning">
967 ///
968 /// **Experimental.** This type is part of an experimental wire-protocol surface
969 /// and may change or be removed in future SDK or CLI releases.
970 ///
971 /// </div>
972 #[serde(rename = "factory.run_updated")]
973 FactoryRunUpdated(FactoryRunUpdatedData),
974 ///
975 /// <div class="warning">
976 ///
977 /// **Experimental.** This type is part of an experimental wire-protocol surface
978 /// and may change or be removed in future SDK or CLI releases.
979 ///
980 /// </div>
981 #[serde(rename = "factory.run_started")]
982 FactoryRunStarted(FactoryRunStartedData),
983 ///
984 /// <div class="warning">
985 ///
986 /// **Experimental.** This type is part of an experimental wire-protocol surface
987 /// and may change or be removed in future SDK or CLI releases.
988 ///
989 /// </div>
990 #[serde(rename = "factory.run_settled")]
991 FactoryRunSettled(FactoryRunSettledData),
992 #[serde(rename = "session.skills_loaded")]
993 SessionSkillsLoaded(SessionSkillsLoadedData),
994 #[serde(rename = "session.custom_agents_updated")]
995 SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
996 #[serde(rename = "session.mcp_servers_loaded")]
997 SessionMcpServersLoaded(SessionMcpServersLoadedData),
998 #[serde(rename = "session.mcp_server_status_changed")]
999 SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
1000 #[serde(rename = "session.mcp_server_removed")]
1001 SessionMcpServerRemoved(SessionMcpServerRemovedData),
1002 #[serde(rename = "session.mcp_server_needs_reconnect")]
1003 SessionMcpServerNeedsReconnect(SessionMcpServerNeedsReconnectData),
1004 #[serde(rename = "mcp.tools.list_changed")]
1005 McpToolsListChanged(McpToolsListChangedData),
1006 #[serde(rename = "mcp.resources.list_changed")]
1007 McpResourcesListChanged(McpResourcesListChangedData),
1008 #[serde(rename = "mcp.prompts.list_changed")]
1009 McpPromptsListChanged(McpPromptsListChangedData),
1010 #[serde(rename = "session.extensions_loaded")]
1011 SessionExtensionsLoaded(SessionExtensionsLoadedData),
1012 ///
1013 /// <div class="warning">
1014 ///
1015 /// **Experimental.** This type is part of an experimental wire-protocol surface
1016 /// and may change or be removed in future SDK or CLI releases.
1017 ///
1018 /// </div>
1019 #[serde(rename = "session.canvas.opened")]
1020 SessionCanvasOpened(SessionCanvasOpenedData),
1021 ///
1022 /// <div class="warning">
1023 ///
1024 /// **Experimental.** This type is part of an experimental wire-protocol surface
1025 /// and may change or be removed in future SDK or CLI releases.
1026 ///
1027 /// </div>
1028 #[serde(rename = "session.canvas.registry_changed")]
1029 SessionCanvasRegistryChanged(SessionCanvasRegistryChangedData),
1030 ///
1031 /// <div class="warning">
1032 ///
1033 /// **Experimental.** This type is part of an experimental wire-protocol surface
1034 /// and may change or be removed in future SDK or CLI releases.
1035 ///
1036 /// </div>
1037 #[serde(rename = "session.canvas.closed")]
1038 SessionCanvasClosed(SessionCanvasClosedData),
1039 ///
1040 /// <div class="warning">
1041 ///
1042 /// **Experimental.** This type is part of an experimental wire-protocol surface
1043 /// and may change or be removed in future SDK or CLI releases.
1044 ///
1045 /// </div>
1046 #[serde(rename = "session.canvas.unavailable")]
1047 SessionCanvasUnavailable(SessionCanvasUnavailableData),
1048 ///
1049 /// <div class="warning">
1050 ///
1051 /// **Experimental.** This type is part of an experimental wire-protocol surface
1052 /// and may change or be removed in future SDK or CLI releases.
1053 ///
1054 /// </div>
1055 #[serde(rename = "session.canvas.recorded")]
1056 SessionCanvasRecorded(SessionCanvasRecordedData),
1057 ///
1058 /// <div class="warning">
1059 ///
1060 /// **Experimental.** This type is part of an experimental wire-protocol surface
1061 /// and may change or be removed in future SDK or CLI releases.
1062 ///
1063 /// </div>
1064 #[serde(rename = "session.canvas.removed")]
1065 SessionCanvasRemoved(SessionCanvasRemovedData),
1066 #[serde(rename = "session.extensions.attachments_pushed")]
1067 SessionExtensionsAttachmentsPushed(SessionExtensionsAttachmentsPushedData),
1068 #[serde(rename = "mcp_app.tool_call_complete")]
1069 McpAppToolCallComplete(McpAppToolCallCompleteData),
1070}
1071
1072/// A session event with typed data payload.
1073///
1074/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
1075/// are available directly. The event-specific data is in the `payload`
1076/// field as a [`SessionEventData`] enum.
1077#[derive(Debug, Clone, Serialize, Deserialize)]
1078#[serde(rename_all = "camelCase")]
1079pub struct TypedSessionEvent {
1080 /// Unique event identifier (UUID v4).
1081 pub id: String,
1082 /// ISO 8601 timestamp when the event was created.
1083 pub timestamp: String,
1084 /// ID of the preceding event in the chain.
1085 #[serde(skip_serializing_if = "Option::is_none")]
1086 pub parent_id: Option<String>,
1087 /// When true, the event is transient and not persisted.
1088 #[serde(skip_serializing_if = "Option::is_none")]
1089 pub ephemeral: Option<bool>,
1090 /// Sub-agent instance identifier. Absent for events from the root /
1091 /// main agent and session-level events.
1092 #[serde(skip_serializing_if = "Option::is_none")]
1093 pub agent_id: Option<String>,
1094 /// The typed event payload (discriminated by event type).
1095 #[serde(flatten)]
1096 pub payload: SessionEventData,
1097}
1098
1099/// Working directory and git context at session start
1100#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1101#[serde(rename_all = "camelCase")]
1102pub struct WorkingDirectoryContext {
1103 /// Base commit of current git branch at session start time
1104 #[serde(skip_serializing_if = "Option::is_none")]
1105 pub base_commit: Option<String>,
1106 /// Current git branch name
1107 #[serde(skip_serializing_if = "Option::is_none")]
1108 pub branch: Option<String>,
1109 /// Current working directory path
1110 pub cwd: String,
1111 /// Root directory of the git repository, resolved via git rev-parse
1112 #[serde(skip_serializing_if = "Option::is_none")]
1113 pub git_root: Option<String>,
1114 /// Head commit of current git branch at session start time
1115 #[serde(skip_serializing_if = "Option::is_none")]
1116 pub head_commit: Option<String>,
1117 /// Hosting platform type of the repository (github or ado)
1118 #[serde(skip_serializing_if = "Option::is_none")]
1119 pub host_type: Option<WorkingDirectoryContextHostType>,
1120 /// Set on the immediate preliminary event of a working-directory change, before the git context is resolved. A settled follow-up event (enriched with git context, or cwd-only for a non-repository) is always emitted afterward, so observers may defer to it. Absent on standalone/final events (e.g. relay context changes).
1121 #[serde(skip_serializing_if = "Option::is_none")]
1122 pub pending_git_context: Option<bool>,
1123 /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
1124 #[serde(skip_serializing_if = "Option::is_none")]
1125 pub repository: Option<String>,
1126 /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
1127 #[serde(skip_serializing_if = "Option::is_none")]
1128 pub repository_host: Option<String>,
1129}
1130
1131/// Per-session configuration for the built-in GitHub MCP server
1132#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1133#[serde(rename_all = "camelCase")]
1134pub struct GitHubMcpToolConfig {
1135 /// Additional GitHub MCP tools requested by the session
1136 #[serde(skip_serializing_if = "Option::is_none")]
1137 pub additional_tools: Option<Vec<String>>,
1138 /// Additional GitHub MCP toolsets requested by the session
1139 #[serde(skip_serializing_if = "Option::is_none")]
1140 pub additional_toolsets: Option<Vec<String>>,
1141 /// Whether to use the read-write endpoint and request all toolsets
1142 #[serde(skip_serializing_if = "Option::is_none")]
1143 pub enable_all_tools: Option<bool>,
1144 /// Whether to request the GitHub MCP insiders build
1145 #[serde(skip_serializing_if = "Option::is_none")]
1146 pub enable_insiders_mode: Option<bool>,
1147}
1148
1149/// Optional session limits.
1150#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1151#[serde(rename_all = "camelCase")]
1152pub struct SessionLimitsConfig {
1153 /// Maximum AI Credits allowed across the session's current accounting window.
1154 #[serde(skip_serializing_if = "Option::is_none")]
1155 pub max_ai_credits: Option<f64>,
1156}
1157
1158/// Session event "session.start". Session initialization metadata including context and configuration
1159#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1160#[serde(rename_all = "camelCase")]
1161pub struct SessionStartData {
1162 /// Whether the session was already in use by another client at start time
1163 #[serde(skip_serializing_if = "Option::is_none")]
1164 pub already_in_use: Option<bool>,
1165 /// Auto routing preference selected at session creation time
1166 #[serde(skip_serializing_if = "Option::is_none")]
1167 pub auto_tier: Option<AutoTier>,
1168 /// Working directory and git context at session start
1169 #[serde(skip_serializing_if = "Option::is_none")]
1170 pub context: Option<WorkingDirectoryContext>,
1171 /// Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
1172 #[serde(skip_serializing_if = "Option::is_none")]
1173 pub context_tier: Option<ContextTier>,
1174 /// Version string of the Copilot application
1175 pub copilot_version: String,
1176 /// When set, identifies a parent session whose context this session continues — e.g., a detached headless rem-agent run launched on the parent's interactive shutdown. Telemetry from this session is reported under the parent's session_id.
1177 #[serde(skip_serializing_if = "Option::is_none")]
1178 pub detached_from_spawning_parent_session_id: Option<String>,
1179 /// Per-session GitHub MCP override persisted for cold resume
1180 #[serde(skip_serializing_if = "Option::is_none")]
1181 pub github_mcp_tool_config: Option<GitHubMcpToolConfig>,
1182 /// Identifier of the software producing the events (e.g., "copilot-agent")
1183 pub producer: String,
1184 /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
1185 #[serde(skip_serializing_if = "Option::is_none")]
1186 pub reasoning_effort: Option<String>,
1187 /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
1188 #[serde(skip_serializing_if = "Option::is_none")]
1189 pub reasoning_summary: Option<ReasoningSummary>,
1190 /// Whether this session supports remote steering via GitHub
1191 #[serde(skip_serializing_if = "Option::is_none")]
1192 pub remote_steerable: Option<bool>,
1193 /// Model selected at session creation time, if any
1194 #[serde(skip_serializing_if = "Option::is_none")]
1195 pub selected_model: Option<String>,
1196 /// Unique identifier for the session
1197 pub session_id: SessionId,
1198 /// Session limits configured at session creation time, if any
1199 #[serde(skip_serializing_if = "Option::is_none")]
1200 pub session_limits: Option<SessionLimitsConfig>,
1201 /// ISO 8601 timestamp when the session was created
1202 pub start_time: String,
1203 /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
1204 #[serde(skip_serializing_if = "Option::is_none")]
1205 pub verbosity: Option<Verbosity>,
1206 /// Schema version number for the session event format
1207 pub version: i64,
1208}
1209
1210/// Session event "session.resume". Session resume metadata including current context and event count
1211#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1212#[serde(rename_all = "camelCase")]
1213pub struct SessionResumeData {
1214 /// Whether the session was already in use by another client at resume time
1215 #[serde(skip_serializing_if = "Option::is_none")]
1216 pub already_in_use: Option<bool>,
1217 /// Auto routing preference active at resume time
1218 #[serde(skip_serializing_if = "Option::is_none")]
1219 pub auto_tier: Option<AutoTier>,
1220 /// Updated working directory and git context at resume time
1221 #[serde(skip_serializing_if = "Option::is_none")]
1222 pub context: Option<WorkingDirectoryContext>,
1223 /// Context tier currently selected at resume time; null when no tier is active
1224 #[serde(skip_serializing_if = "Option::is_none")]
1225 pub context_tier: Option<ContextTier>,
1226 /// When true, tool calls and permission requests left in flight by the previous session lifetime remain pending after resume and the agentic loop awaits their results. User sends are queued behind the pending work until all such requests reach a terminal state. When false or omitted, pending work is normally marked as interrupted unless the resume passively joined live work owned by another client; sessionWasActive distinguishes that case.
1227 #[serde(skip_serializing_if = "Option::is_none")]
1228 pub continue_pending_work: Option<bool>,
1229 /// Total number of persisted events in the session at the time of resume
1230 pub event_count: i64,
1231 /// On-disk byte size of the session's persisted events.jsonl file at resume time; omitted when the file does not exist or cannot be stat'd
1232 #[serde(skip_serializing_if = "Option::is_none")]
1233 pub events_file_size_bytes: Option<i64>,
1234 /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
1235 #[serde(skip_serializing_if = "Option::is_none")]
1236 pub reasoning_effort: Option<String>,
1237 /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
1238 #[serde(skip_serializing_if = "Option::is_none")]
1239 pub reasoning_summary: Option<ReasoningSummary>,
1240 /// Whether this session supports remote steering via GitHub
1241 #[serde(skip_serializing_if = "Option::is_none")]
1242 pub remote_steerable: Option<bool>,
1243 /// ISO 8601 timestamp when the session was resumed
1244 pub resume_time: String,
1245 /// Model currently selected at resume time
1246 #[serde(skip_serializing_if = "Option::is_none")]
1247 pub selected_model: Option<String>,
1248 /// Session limits currently configured at resume time; null when no limits are active
1249 #[serde(skip_serializing_if = "Option::is_none")]
1250 pub session_limits: Option<SessionLimitsConfig>,
1251 /// True when this resume passively joined a session that already had live work running in the runtime - an agent turn, a native queue run, a queued resume continuation, or an in-flight send (for example, an extension joining a session another client was actively driving). False (or omitted) when the session had no live work or when the resume explicitly abandoned pending work, including cold resumes and suspended sessions that remain resident in memory.
1252 #[serde(skip_serializing_if = "Option::is_none")]
1253 pub session_was_active: Option<bool>,
1254 /// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
1255 #[serde(skip_serializing_if = "Option::is_none")]
1256 pub verbosity: Option<Verbosity>,
1257}
1258
1259/// Session event "session.remote_steerable_changed". Notifies that the session's remote steering capability has changed
1260#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1261#[serde(rename_all = "camelCase")]
1262pub struct SessionRemoteSteerableChangedData {
1263 /// Whether this session now supports remote steering via GitHub
1264 pub remote_steerable: bool,
1265}
1266
1267/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
1268#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1269#[serde(rename_all = "camelCase")]
1270pub struct SessionErrorData {
1271 /// Only set on `errorType: "rate_limit"`. When `true`, the runtime will follow this error with an `auto_mode_switch.requested` event (or silently switch if `continueOnAutoMode` is enabled). UI clients can use this flag to suppress duplicate rendering of the rate-limit error when they show their own auto-mode-switch prompt.
1272 #[serde(skip_serializing_if = "Option::is_none")]
1273 pub eligible_for_auto_switch: Option<bool>,
1274 /// Fine-grained error code from the upstream provider, when available. For `errorType: "rate_limit"`, this is one of the `RateLimitErrorCode` values (e.g., `"user_weekly_rate_limited"`, `"user_global_rate_limited"`, `"rate_limited"`, `"user_model_rate_limited"`, `"integration_rate_limited"`). For `errorType: "quota"`, this is the CAPI quota error code (e.g., `"quota_exceeded"`, `"session_quota_exceeded"`, `"billing_not_configured"`).
1275 #[serde(skip_serializing_if = "Option::is_none")]
1276 pub error_code: Option<String>,
1277 /// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
1278 pub error_type: String,
1279 /// Human-readable error message
1280 pub message: String,
1281 /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
1282 #[serde(skip_serializing_if = "Option::is_none")]
1283 pub provider_call_id: Option<String>,
1284 /// What the user must do to recover, when the runtime knows of an action. The `message` never names a client affordance, so a client that offers one — a slash command, a settings pane, a link — renders it from this value.
1285 #[serde(skip_serializing_if = "Option::is_none")]
1286 pub remediation: Option<RemediationAction>,
1287 /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
1288 #[serde(skip_serializing_if = "Option::is_none")]
1289 pub service_request_id: Option<String>,
1290 /// Error stack trace, when available
1291 #[serde(skip_serializing_if = "Option::is_none")]
1292 pub stack: Option<String>,
1293 /// HTTP status code from the upstream request, if applicable
1294 #[serde(skip_serializing_if = "Option::is_none")]
1295 pub status_code: Option<i32>,
1296 /// Optional URL associated with this error that the user can open in a browser
1297 #[serde(skip_serializing_if = "Option::is_none")]
1298 pub url: Option<String>,
1299}
1300
1301/// Session event "session.idle". Payload indicating the session is idle with no background agents or attached shell commands in flight
1302#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1303#[serde(rename_all = "camelCase")]
1304pub struct SessionIdleData {
1305 /// True when the preceding agentic loop was cancelled via abort signal
1306 #[serde(skip_serializing_if = "Option::is_none")]
1307 pub aborted: Option<bool>,
1308 /// The session mode the agent was operating in when it went idle, when the mode is known. Lets turn-scoped consumers distinguish an autopilot continuation boundary (where the agent keeps working after this idle) from a genuine turn completion.
1309 #[serde(skip_serializing_if = "Option::is_none")]
1310 pub mode: Option<SessionMode>,
1311}
1312
1313/// Session event "session.title_changed". Session title change payload containing the new display title
1314#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1315#[serde(rename_all = "camelCase")]
1316pub struct SessionTitleChangedData {
1317 /// The new display title for the session
1318 pub title: String,
1319}
1320
1321/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
1322#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1323#[serde(rename_all = "camelCase")]
1324pub struct SessionScheduleCreatedData {
1325 /// Absolute fire time (epoch milliseconds) for a one-shot calendar schedule
1326 #[serde(skip_serializing_if = "Option::is_none")]
1327 pub at: Option<i64>,
1328 /// 5-field cron expression for a recurring calendar schedule, evaluated in `tz`
1329 #[serde(skip_serializing_if = "Option::is_none")]
1330 pub cron: Option<String>,
1331 /// Optional user-facing label shown in the timeline instead of the actual prompt (e.g. `/skill-name args` when the prompt is a skill invocation expansion)
1332 #[serde(skip_serializing_if = "Option::is_none")]
1333 pub display_prompt: Option<String>,
1334 /// Sequential id assigned to the scheduled prompt within the session
1335 pub id: i64,
1336 /// Interval between ticks in milliseconds (relative-interval schedules)
1337 #[serde(skip_serializing_if = "Option::is_none")]
1338 pub interval_ms: Option<i64>,
1339 /// Who created the schedule (`user` or `model`). Persisted so a resumed session keeps gating non-user schedules from firing skills that opted out of model invocation. Absent on entries created before this field existed; a missing origin fails closed (treated the same as a non-user origin), so such a schedule may not resolve a `disable-model-invocation` skill.
1340 #[serde(skip_serializing_if = "Option::is_none")]
1341 pub origin: Option<ScheduleOrigin>,
1342 /// Prompt text that gets enqueued on every tick
1343 pub prompt: String,
1344 /// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
1345 #[serde(skip_serializing_if = "Option::is_none")]
1346 pub recurring: Option<bool>,
1347 /// True for a self-paced (`dynamic`) schedule: no fixed cadence; the model arms each next run via the `manage_schedule` `wakeup` action. `nextRunAt` is model-controlled rather than auto-computed.
1348 #[serde(skip_serializing_if = "Option::is_none")]
1349 pub self_paced: Option<bool>,
1350 /// IANA timezone the `cron` expression is evaluated in
1351 #[serde(skip_serializing_if = "Option::is_none")]
1352 pub tz: Option<String>,
1353}
1354
1355/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
1356#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1357#[serde(rename_all = "camelCase")]
1358pub struct SessionScheduleCancelledData {
1359 /// Id of the scheduled prompt that was cancelled
1360 pub id: i64,
1361}
1362
1363/// Session event "session.schedule_rearmed". Self-paced schedule re-armed for its next run
1364#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1365#[serde(rename_all = "camelCase")]
1366pub struct SessionScheduleRearmedData {
1367 /// Id of the self-paced schedule that was re-armed
1368 pub id: i64,
1369 /// Absolute time (epoch milliseconds) the model armed the next run to fire
1370 pub next_run_at: i64,
1371}
1372
1373/// Session event "session.autopilot_objective_changed". Autopilot objective state file operation details indicating what changed
1374#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1375#[serde(rename_all = "camelCase")]
1376pub struct SessionAutopilotObjectiveChangedData {
1377 /// Current autopilot objective id, if one exists
1378 #[serde(skip_serializing_if = "Option::is_none")]
1379 pub id: Option<i64>,
1380 /// The type of operation performed on the autopilot objective state file
1381 pub operation: AutopilotObjectiveChangedOperation,
1382 /// Current autopilot objective status, if one exists
1383 #[serde(skip_serializing_if = "Option::is_none")]
1384 pub status: Option<AutopilotObjectiveChangedStatus>,
1385}
1386
1387/// Session event "session.info". Informational message for timeline display with categorization
1388#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1389#[serde(rename_all = "camelCase")]
1390pub struct SessionInfoData {
1391 /// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
1392 pub info_type: String,
1393 /// Human-readable informational message for display in the timeline
1394 pub message: String,
1395 /// Optional actionable tip displayed with this message
1396 #[serde(skip_serializing_if = "Option::is_none")]
1397 pub tip: Option<String>,
1398 /// Optional URL associated with this message that the user can open in a browser
1399 #[serde(skip_serializing_if = "Option::is_none")]
1400 pub url: Option<String>,
1401}
1402
1403#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1404#[serde(rename_all = "camelCase")]
1405pub struct IndexedSearchDataStatus {
1406 /// Indexed-search event variant discriminator.
1407 pub kind: IndexedSearchDataStatusKind,
1408 /// Current indexed-search state for this session activation.
1409 pub state: IndexedSearchState,
1410}
1411
1412#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1413#[serde(rename_all = "camelCase")]
1414pub struct IndexedSearchDataStartup {
1415 /// Why indexed search was disabled, when applicable.
1416 #[serde(skip_serializing_if = "Option::is_none")]
1417 pub disabled_reason: Option<IndexedSearchDisabledReason>,
1418 /// Whether the repository meets the automatic indexing file-count threshold, when known.
1419 #[serde(skip_serializing_if = "Option::is_none")]
1420 pub eligible: Option<bool>,
1421 /// Startup failure details. May contain sensitive user data; restricted telemetry only.
1422 #[serde(skip_serializing_if = "Option::is_none")]
1423 pub error_message: Option<String>,
1424 /// Number of text files counted in the repository.
1425 #[serde(skip_serializing_if = "Option::is_none")]
1426 pub file_count: Option<f64>,
1427 /// Whether indexed search was explicitly enabled through the environment.
1428 pub forced_by_env: bool,
1429 /// Indexed-search event variant discriminator.
1430 pub kind: IndexedSearchDataStartupKind,
1431 /// Outcome of this startup attempt.
1432 pub outcome: IndexedSearchOutcome,
1433 /// Wall-clock duration of startup in milliseconds.
1434 pub startup_duration_ms: f64,
1435 /// Whether waiting for index readiness was requested, including skipped attempts.
1436 pub warm_start: bool,
1437}
1438
1439#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1440#[serde(rename_all = "camelCase")]
1441pub struct IndexedSearchDataServerError {
1442 /// Server failure details. May contain sensitive user data; restricted telemetry only.
1443 #[serde(skip_serializing_if = "Option::is_none")]
1444 pub error_message: Option<String>,
1445 /// Category of the server failure.
1446 pub error_type: IndexedSearchErrorType,
1447 /// Process exit code, when available.
1448 #[serde(skip_serializing_if = "Option::is_none")]
1449 pub exit_code: Option<f64>,
1450 /// Indexed-search event variant discriminator.
1451 pub kind: IndexedSearchDataServerErrorKind,
1452}
1453
1454#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1455#[serde(rename_all = "camelCase")]
1456pub struct IndexedSearchDataIncremental {
1457 /// Number of added files.
1458 #[serde(skip_serializing_if = "Option::is_none")]
1459 pub added_file_count: Option<f64>,
1460 /// Number of modified files.
1461 #[serde(skip_serializing_if = "Option::is_none")]
1462 pub changed_file_count: Option<f64>,
1463 /// Number of deleted files.
1464 #[serde(skip_serializing_if = "Option::is_none")]
1465 pub deleted_file_count: Option<f64>,
1466 /// Indexed-search event variant discriminator.
1467 pub kind: IndexedSearchDataIncrementalKind,
1468 /// Phase of the incremental index update.
1469 pub phase: IndexedSearchIncrementalPhase,
1470 /// Total number of detected changes.
1471 #[serde(skip_serializing_if = "Option::is_none")]
1472 pub total_change_count: Option<f64>,
1473 /// Total incremental indexing duration in milliseconds.
1474 #[serde(skip_serializing_if = "Option::is_none")]
1475 pub total_duration_ms: Option<f64>,
1476 /// Index update duration in milliseconds.
1477 #[serde(skip_serializing_if = "Option::is_none")]
1478 pub update_duration_ms: Option<f64>,
1479 /// Workspace scan duration in milliseconds.
1480 #[serde(skip_serializing_if = "Option::is_none")]
1481 pub walk_duration_ms: Option<f64>,
1482}
1483
1484/// Session event "session.warning". Warning message for timeline display with categorization
1485#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1486#[serde(rename_all = "camelCase")]
1487pub struct SessionWarningData {
1488 /// Human-readable warning message for display in the timeline
1489 pub message: String,
1490 /// What the user must do to recover, when the runtime knows of an action. The `message` never names a client affordance, so a client that offers one — a slash command, a settings pane, a link — renders it from this value.
1491 #[serde(skip_serializing_if = "Option::is_none")]
1492 pub remediation: Option<RemediationAction>,
1493 /// Optional URL associated with this warning that the user can open in a browser
1494 #[serde(skip_serializing_if = "Option::is_none")]
1495 pub url: Option<String>,
1496 /// Category of warning (e.g., "subscription", "policy", "mcp")
1497 pub warning_type: String,
1498}
1499
1500/// Session event "session.model_change". Model change details including previous and new model identifiers
1501#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1502#[serde(rename_all = "camelCase")]
1503pub struct SessionModelChangeData {
1504 /// Committed Auto preference after the model configuration change, when applicable.
1505 #[serde(skip_serializing_if = "Option::is_none")]
1506 pub auto_tier: Option<AutoTier>,
1507 /// Reason the change happened, when not user-initiated. `"rate_limit_auto_switch"` for changes triggered by the auto-mode-switch rate-limit recovery path, or `"refusal_fallback"` when the active model declined a request (content refusal) and the runtime switched to the configured refusal-fallback model. UI clients can use this to render contextual copy.
1508 #[serde(skip_serializing_if = "Option::is_none")]
1509 pub cause: Option<String>,
1510 /// Context tier after the model change; null explicitly clears a previously selected tier
1511 #[serde(skip_serializing_if = "Option::is_none")]
1512 pub context_tier: Option<ContextTier>,
1513 /// Newly selected model identifier
1514 pub new_model: String,
1515 /// Previously committed Auto preference, when one was explicitly selected.
1516 #[serde(skip_serializing_if = "Option::is_none")]
1517 pub previous_auto_tier: Option<AutoTier>,
1518 /// Model that was previously selected, if any
1519 #[serde(skip_serializing_if = "Option::is_none")]
1520 pub previous_model: Option<String>,
1521 /// Reasoning effort level before the model change, if applicable
1522 #[serde(skip_serializing_if = "Option::is_none")]
1523 pub previous_reasoning_effort: Option<String>,
1524 /// Reasoning summary mode before the model change, if applicable
1525 #[serde(skip_serializing_if = "Option::is_none")]
1526 pub previous_reasoning_summary: Option<ReasoningSummary>,
1527 /// Output verbosity level before the model change, if applicable
1528 #[serde(skip_serializing_if = "Option::is_none")]
1529 pub previous_verbosity: Option<Verbosity>,
1530 /// Reasoning effort level after the model change, if applicable
1531 #[serde(skip_serializing_if = "Option::is_none")]
1532 pub reasoning_effort: Option<String>,
1533 /// Reasoning summary mode after the model change, if applicable
1534 #[serde(skip_serializing_if = "Option::is_none")]
1535 pub reasoning_summary: Option<ReasoningSummary>,
1536 /// Origin of the effective model change, when known.
1537 #[serde(skip_serializing_if = "Option::is_none")]
1538 pub source: Option<ModelChangeSource>,
1539 /// Output verbosity level after the model change, if applicable
1540 #[serde(skip_serializing_if = "Option::is_none")]
1541 pub verbosity: Option<Verbosity>,
1542}
1543
1544/// Session event "session.model_deselected". The model the user had explicitly selected is no longer available, because the host that published it withdrew it, so the session no longer has an explicit selection. The next turn resolves a default as though the user had never chosen a model. Clients should stop presenting the previous model as selected. This event is durable because resume rebuilds the selected model from the event log; without it a resumed session would restore a model its provider no longer serves. Reasoning effort, verbosity, and other session-level preferences are deliberately unchanged, because they belong to the session rather than to the model.
1545#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1546#[serde(rename_all = "camelCase")]
1547pub struct SessionModelDeselectedData {
1548 /// Model that was selected before the host withdrew it.
1549 pub previous_model: String,
1550 /// Low-cardinality reason the selection was cleared.
1551 pub reason: ModelDeselectedReason,
1552}
1553
1554/// Session event "session.auto_tier_recommendation". Live-only Auto preference recommendation from Copilot API after a successful Auto model call.
1555///
1556/// <div class="warning">
1557///
1558/// **Experimental.** This type is part of an experimental wire-protocol surface
1559/// and may change or be removed in future SDK or CLI releases.
1560///
1561/// </div>
1562#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1563#[serde(rename_all = "camelCase")]
1564pub struct SessionAutoTierRecommendationData {
1565 /// Recommended Auto preference.
1566 pub recommended_auto_tier: RecommendedAutoTier,
1567}
1568
1569/// Session event "session.auto_tier_switch_failed". A transient Auto preference failure emitted when the runtime cannot mint or accept a usable model and token pair. The previously effective preference remains active, so SDK clients can surface a non-blocking failure without changing their committed-tier state. This event is ephemeral and is not persisted or replayed on resume.
1570#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1571#[serde(rename_all = "camelCase")]
1572pub struct SessionAutoTierSwitchFailedData {
1573 /// Auto preference that remains effective after the failed request.
1574 #[serde(skip_serializing_if = "Option::is_none")]
1575 pub effective_auto_tier: Option<AutoTier>,
1576 /// Low-cardinality failure outcome reported by Auto resolution.
1577 pub reason: AutoTierSwitchFailureReason,
1578 /// Auto preference that failed to activate, or null when returning to provider-default routing failed.
1579 pub requested_auto_tier: Option<AutoTier>,
1580}
1581
1582/// Session event "session.mode_changed". Agent mode change details including previous and new modes
1583#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1584#[serde(rename_all = "camelCase")]
1585pub struct SessionModeChangedData {
1586 /// The session mode the agent is operating in
1587 pub new_mode: SessionMode,
1588 /// The session mode the agent is operating in
1589 pub previous_mode: SessionMode,
1590}
1591
1592/// Session event "session.mode_notice_delivered". Records that a mode transition notice reached the model so cache-stable mode tools can remain offered across resume.
1593#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1594#[serde(rename_all = "camelCase")]
1595pub struct SessionModeNoticeDeliveredData {
1596 /// Model-visible transition notice persisted for a mid-turn delivery
1597 #[serde(skip_serializing_if = "Option::is_none")]
1598 pub content: Option<String>,
1599 /// Mode established by the delivered transition notice
1600 pub mode: SessionMode,
1601}
1602
1603/// Session event "session.session_limits_changed". Session limits update details. Null clears the limits.
1604#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1605#[serde(rename_all = "camelCase")]
1606pub struct SessionSessionLimitsChangedData {
1607 /// Current session limits, or null when no limits are active
1608 pub session_limits: Option<SessionLimitsConfig>,
1609}
1610
1611/// Session event "session.permissions_changed". Permission-mode transition details.
1612///
1613/// <div class="warning">
1614///
1615/// **Experimental.** This type is part of an experimental wire-protocol surface
1616/// and may change or be removed in future SDK or CLI releases.
1617///
1618/// </div>
1619#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1620#[serde(rename_all = "camelCase")]
1621pub struct SessionPermissionsChangedData {
1622 /// Explicit LLM judge model override used by assisted mode; omitted when the provider default applies
1623 ///
1624 /// <div class="warning">
1625 ///
1626 /// **Experimental.** This type is part of an experimental wire-protocol surface
1627 /// and may change or be removed in future SDK or CLI releases.
1628 ///
1629 /// </div>
1630 #[serde(skip_serializing_if = "Option::is_none")]
1631 pub assisted_approval_model: Option<String>,
1632 /// Permission mode after the change
1633 ///
1634 /// <div class="warning">
1635 ///
1636 /// **Experimental.** This type is part of an experimental wire-protocol surface
1637 /// and may change or be removed in future SDK or CLI releases.
1638 ///
1639 /// </div>
1640 #[serde(skip_serializing_if = "Option::is_none")]
1641 pub mode: Option<PermissionMode>,
1642 /// Permission mode before the change
1643 ///
1644 /// <div class="warning">
1645 ///
1646 /// **Experimental.** This type is part of an experimental wire-protocol surface
1647 /// and may change or be removed in future SDK or CLI releases.
1648 ///
1649 /// </div>
1650 #[serde(skip_serializing_if = "Option::is_none")]
1651 pub previous_mode: Option<PermissionMode>,
1652}
1653
1654/// Session event "session.plan_changed". Plan file operation details indicating what changed
1655#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1656#[serde(rename_all = "camelCase")]
1657pub struct SessionPlanChangedData {
1658 /// The type of operation performed on the plan file
1659 pub operation: PlanChangedOperation,
1660}
1661
1662/// Session event "session.todos_changed". Signal-only event: the agent's todos or todo_deps table was written to. No payload — clients should call session.plan.readSqlTodosWithDependencies() to fetch the current state. Events arrive in order; clients can debounce on arrival if needed.
1663#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1664#[serde(rename_all = "camelCase")]
1665pub struct SessionTodosChangedData {}
1666
1667/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
1668#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1669#[serde(rename_all = "camelCase")]
1670pub struct SessionWorkspaceFileChangedData {
1671 /// Whether the file was newly created or updated
1672 pub operation: WorkspaceFileChangedOperation,
1673 /// Relative path within the session workspace files directory
1674 pub path: String,
1675}
1676
1677/// Repository context for the handed-off session
1678#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1679#[serde(rename_all = "camelCase")]
1680pub struct HandoffRepository {
1681 /// Git branch name, if applicable
1682 #[serde(skip_serializing_if = "Option::is_none")]
1683 pub branch: Option<String>,
1684 /// Repository name
1685 pub name: String,
1686 /// Repository owner (user or organization)
1687 pub owner: String,
1688}
1689
1690/// Session event "session.handoff". Session handoff metadata including source, context, and repository information
1691#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1692#[serde(rename_all = "camelCase")]
1693pub struct SessionHandoffData {
1694 /// Additional context information for the handoff
1695 #[serde(skip_serializing_if = "Option::is_none")]
1696 pub context: Option<String>,
1697 /// ISO 8601 timestamp when the handoff occurred
1698 pub handoff_time: String,
1699 /// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
1700 #[serde(skip_serializing_if = "Option::is_none")]
1701 pub host: Option<String>,
1702 /// Session ID of the remote session being handed off
1703 #[serde(skip_serializing_if = "Option::is_none")]
1704 pub remote_session_id: Option<SessionId>,
1705 /// Repository context for the handed-off session
1706 #[serde(skip_serializing_if = "Option::is_none")]
1707 pub repository: Option<HandoffRepository>,
1708 /// Origin type of the session being handed off
1709 pub source_type: HandoffSourceType,
1710 /// Summary of the work done in the source session
1711 #[serde(skip_serializing_if = "Option::is_none")]
1712 pub summary: Option<String>,
1713}
1714
1715/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
1716#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1717#[serde(rename_all = "camelCase")]
1718pub struct SessionTruncationData {
1719 /// Number of messages removed by truncation
1720 pub messages_removed_during_truncation: i64,
1721 /// Identifier of the component that performed truncation (e.g., "BasicTruncator")
1722 pub performed_by: String,
1723 /// Number of conversation messages after truncation
1724 pub post_truncation_messages_length: i64,
1725 /// Total tokens in conversation messages after truncation
1726 pub post_truncation_tokens_in_messages: i64,
1727 /// Number of conversation messages before truncation
1728 pub pre_truncation_messages_length: i64,
1729 /// Total tokens in conversation messages before truncation
1730 pub pre_truncation_tokens_in_messages: i64,
1731 /// Maximum token count for the model's context window
1732 pub token_limit: i64,
1733 /// Number of tokens removed by truncation
1734 pub tokens_removed_during_truncation: i64,
1735}
1736
1737/// Session event "session.snapshot_rewind". Session rewind details including target event and count of removed events
1738#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1739#[serde(rename_all = "camelCase")]
1740pub struct SessionSnapshotRewindData {
1741 /// Number of events that were removed by the rewind
1742 pub events_removed: i64,
1743 /// Event ID that was rewound to; this event and all after it were removed
1744 pub up_to_event_id: String,
1745}
1746
1747/// Request count and cost metrics
1748#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1749#[serde(rename_all = "camelCase")]
1750pub struct ShutdownModelMetricRequests {
1751 /// Cumulative cost multiplier for requests to this model
1752 ///
1753 /// <div class="warning">
1754 ///
1755 /// **Experimental.** This type is part of an experimental wire-protocol surface
1756 /// and may change or be removed in future SDK or CLI releases.
1757 ///
1758 /// </div>
1759 #[serde(skip_serializing_if = "Option::is_none")]
1760 pub cost: Option<f64>,
1761 /// Total number of API requests made to this model
1762 ///
1763 /// <div class="warning">
1764 ///
1765 /// **Experimental.** This type is part of an experimental wire-protocol surface
1766 /// and may change or be removed in future SDK or CLI releases.
1767 ///
1768 /// </div>
1769 #[serde(skip_serializing_if = "Option::is_none")]
1770 pub count: Option<i64>,
1771}
1772
1773/// A token-type entry in a shutdown model metric, storing the accumulated token count.
1774#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1775#[serde(rename_all = "camelCase")]
1776pub struct ShutdownModelMetricTokenDetail {
1777 /// Accumulated token count for this token type
1778 pub token_count: i64,
1779}
1780
1781/// Token usage breakdown
1782#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1783#[serde(rename_all = "camelCase")]
1784pub struct ShutdownModelMetricUsage {
1785 /// Total tokens read from prompt cache across all requests
1786 pub cache_read_tokens: i64,
1787 /// Total tokens written to prompt cache across all requests
1788 pub cache_write_tokens: i64,
1789 /// Total input tokens consumed across all requests to this model
1790 pub input_tokens: i64,
1791 /// Total output tokens produced across all requests to this model
1792 pub output_tokens: i64,
1793 /// Total reasoning tokens produced across all requests to this model
1794 #[serde(skip_serializing_if = "Option::is_none")]
1795 pub reasoning_tokens: Option<i64>,
1796}
1797
1798/// Per-model shutdown metrics with request counts, token usage, nano-AI units, and token details.
1799#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1800#[serde(rename_all = "camelCase")]
1801pub struct ShutdownModelMetric {
1802 /// Request count and cost metrics
1803 pub requests: ShutdownModelMetricRequests,
1804 /// Token count details per type
1805 #[serde(skip_serializing_if = "Option::is_none")]
1806 pub token_details: Option<HashMap<String, ShutdownModelMetricTokenDetail>>,
1807 /// Accumulated nano-AI units cost for this model
1808 ///
1809 /// <div class="warning">
1810 ///
1811 /// **Experimental.** This type is part of an experimental wire-protocol surface
1812 /// and may change or be removed in future SDK or CLI releases.
1813 ///
1814 /// </div>
1815 #[serde(skip_serializing_if = "Option::is_none")]
1816 pub total_nano_aiu: Option<f64>,
1817 /// Token usage breakdown
1818 pub usage: ShutdownModelMetricUsage,
1819}
1820
1821/// Usage attributed to one agent instance at session shutdown.
1822#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1823#[serde(rename_all = "camelCase")]
1824pub struct ShutdownAgentMetric {
1825 /// Human-readable label for this subagent invocation, copied from the originating `subagent.started` event. For task-tool subagents this is the invocation's task description rather than the agent's configured display name, so group by `agentName` for stable per-agent labels.
1826 #[serde(skip_serializing_if = "Option::is_none")]
1827 pub agent_display_name: Option<String>,
1828 /// Configured agent name, when this is a subagent
1829 #[serde(skip_serializing_if = "Option::is_none")]
1830 pub agent_name: Option<String>,
1831 /// Per-model usage for this agent, keyed by model identifier
1832 pub model_metrics: HashMap<String, ShutdownModelMetric>,
1833 /// Time spent in model API calls by this agent, in milliseconds
1834 pub total_api_duration_ms: i64,
1835 /// Accumulated nano-AI units cost for this agent
1836 pub total_nano_aiu: f64,
1837}
1838
1839/// Aggregate code change metrics for the session
1840#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1841#[serde(rename_all = "camelCase")]
1842pub struct ShutdownCodeChanges {
1843 /// List of file paths that were modified during the session
1844 pub files_modified: Vec<String>,
1845 /// Total number of lines added during the session
1846 pub lines_added: i64,
1847 /// Total number of lines removed during the session
1848 pub lines_removed: i64,
1849}
1850
1851/// A session-wide shutdown token-type entry storing the accumulated token count.
1852#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1853#[serde(rename_all = "camelCase")]
1854pub struct ShutdownTokenDetail {
1855 /// Accumulated token count for this token type
1856 pub token_count: i64,
1857}
1858
1859/// Session event "session.shutdown". Session termination metrics including usage statistics, code changes, and shutdown reason
1860#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1861#[serde(rename_all = "camelCase")]
1862pub struct SessionShutdownData {
1863 /// Per-agent usage breakdown, keyed by agent instance identifier. The main conversation uses the stable key `main`.
1864 #[serde(skip_serializing_if = "Option::is_none")]
1865 pub agent_metrics: Option<HashMap<String, ShutdownAgentMetric>>,
1866 /// Aggregate code change metrics for the session
1867 pub code_changes: ShutdownCodeChanges,
1868 /// Non-system message token count at shutdown
1869 #[serde(skip_serializing_if = "Option::is_none")]
1870 pub conversation_tokens: Option<i64>,
1871 /// Model that was selected at the time of shutdown
1872 #[serde(skip_serializing_if = "Option::is_none")]
1873 pub current_model: Option<String>,
1874 /// Total tokens in context window at shutdown
1875 #[serde(skip_serializing_if = "Option::is_none")]
1876 pub current_tokens: Option<i64>,
1877 /// Error description when shutdownType is "error"
1878 #[serde(skip_serializing_if = "Option::is_none")]
1879 pub error_reason: Option<String>,
1880 /// On-disk byte size of the session's persisted events.jsonl file at shutdown time; omitted when the file does not exist or cannot be stat'd
1881 #[serde(skip_serializing_if = "Option::is_none")]
1882 pub events_file_size_bytes: Option<i64>,
1883 /// Per-model usage breakdown, keyed by model identifier
1884 pub model_metrics: HashMap<String, ShutdownModelMetric>,
1885 /// Unix timestamp (milliseconds) when the session started
1886 pub session_start_time: i64,
1887 /// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
1888 pub shutdown_type: ShutdownType,
1889 /// System message token count at shutdown
1890 #[serde(skip_serializing_if = "Option::is_none")]
1891 pub system_tokens: Option<i64>,
1892 /// Session-wide per-token-type accumulated token counts
1893 #[serde(skip_serializing_if = "Option::is_none")]
1894 pub token_details: Option<HashMap<String, ShutdownTokenDetail>>,
1895 /// Tool definitions token count at shutdown
1896 #[serde(skip_serializing_if = "Option::is_none")]
1897 pub tool_definitions_tokens: Option<i64>,
1898 /// Cumulative time spent in API calls during the session, in milliseconds
1899 pub total_api_duration_ms: i64,
1900 /// Session-wide accumulated nano-AI units cost
1901 ///
1902 /// <div class="warning">
1903 ///
1904 /// **Experimental.** This type is part of an experimental wire-protocol surface
1905 /// and may change or be removed in future SDK or CLI releases.
1906 ///
1907 /// </div>
1908 #[serde(skip_serializing_if = "Option::is_none")]
1909 pub total_nano_aiu: Option<f64>,
1910 /// Total number of premium API requests used during the session
1911 #[doc(hidden)]
1912 #[serde(skip_serializing_if = "Option::is_none")]
1913 pub(crate) total_premium_requests: Option<f64>,
1914}
1915
1916/// Internal prompt-cache expiration state for one model
1917#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1918#[serde(rename_all = "camelCase")]
1919pub(crate) struct UsageCheckpointModelCacheState {
1920 /// Latest known prompt-cache expiration
1921 pub cache_expires_at: String,
1922 /// Retained cache lifetime in seconds, used to refresh expiration after a cache read
1923 #[doc(hidden)]
1924 pub(crate) cache_ttl_seconds: i64,
1925 /// Model identifier associated with this cache state
1926 pub model_id: String,
1927}
1928
1929/// Session event "session.usage_checkpoint". Durable session usage checkpoint for reconstructing aggregate accounting on resume
1930#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1931#[serde(rename_all = "camelCase")]
1932pub struct SessionUsageCheckpointData {
1933 /// Internal per-model prompt-cache state used to restore expiration tracking on resume
1934 #[doc(hidden)]
1935 #[serde(skip_serializing_if = "Option::is_none")]
1936 pub(crate) model_cache_state: Option<Vec<UsageCheckpointModelCacheState>>,
1937 /// Internal per-conversation prompt-cache-break detector baselines restored on resume
1938 #[doc(hidden)]
1939 #[serde(skip_serializing_if = "Option::is_none")]
1940 pub(crate) prompt_cache_break_state: Option<Vec<serde_json::Value>>,
1941 /// Session-wide accumulated nano-AI units cost at checkpoint time
1942 pub total_nano_aiu: f64,
1943 /// Total number of premium API requests used at checkpoint time
1944 #[doc(hidden)]
1945 #[serde(skip_serializing_if = "Option::is_none")]
1946 pub(crate) total_premium_requests: Option<f64>,
1947}
1948
1949/// Session event "session.context_changed". Updated working directory and git context after the change
1950#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1951#[serde(rename_all = "camelCase")]
1952pub struct SessionContextChangedData {
1953 /// Base commit of current git branch at session start time
1954 #[serde(skip_serializing_if = "Option::is_none")]
1955 pub base_commit: Option<String>,
1956 /// Current git branch name
1957 #[serde(skip_serializing_if = "Option::is_none")]
1958 pub branch: Option<String>,
1959 /// Current working directory path
1960 pub cwd: String,
1961 /// Root directory of the git repository, resolved via git rev-parse
1962 #[serde(skip_serializing_if = "Option::is_none")]
1963 pub git_root: Option<String>,
1964 /// Head commit of current git branch at session start time
1965 #[serde(skip_serializing_if = "Option::is_none")]
1966 pub head_commit: Option<String>,
1967 /// Hosting platform type of the repository (github or ado)
1968 #[serde(skip_serializing_if = "Option::is_none")]
1969 pub host_type: Option<WorkingDirectoryContextHostType>,
1970 /// Set on the immediate preliminary event of a working-directory change, before the git context is resolved. A settled follow-up event (enriched with git context, or cwd-only for a non-repository) is always emitted afterward, so observers may defer to it. Absent on standalone/final events (e.g. relay context changes).
1971 #[serde(skip_serializing_if = "Option::is_none")]
1972 pub pending_git_context: Option<bool>,
1973 /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
1974 #[serde(skip_serializing_if = "Option::is_none")]
1975 pub repository: Option<String>,
1976 /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
1977 #[serde(skip_serializing_if = "Option::is_none")]
1978 pub repository_host: Option<String>,
1979}
1980
1981/// Session event "session.usage_info". Current context window usage statistics including token and message counts
1982#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1983#[serde(rename_all = "camelCase")]
1984pub struct SessionUsageInfoData {
1985 /// Token count from non-system messages (user, assistant, tool)
1986 #[serde(skip_serializing_if = "Option::is_none")]
1987 pub conversation_tokens: Option<i64>,
1988 /// Current number of tokens in the context window
1989 pub current_tokens: i64,
1990 /// Whether this is the first usage_info event emitted in this session
1991 #[serde(skip_serializing_if = "Option::is_none")]
1992 pub is_initial: Option<bool>,
1993 /// Current number of messages in the conversation
1994 pub messages_length: i64,
1995 /// Token count from system message(s)
1996 #[serde(skip_serializing_if = "Option::is_none")]
1997 pub system_tokens: Option<i64>,
1998 /// Maximum token count for the model's context window
1999 pub token_limit: i64,
2000 /// Token count from tool definitions
2001 #[serde(skip_serializing_if = "Option::is_none")]
2002 pub tool_definitions_tokens: Option<i64>,
2003}
2004
2005/// Session event "session.context_cleared". Context-cleared details emitted when the host clears the conversation (the session.history.clearContext RPC / Session.clearContextMessages)
2006#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2007#[serde(rename_all = "camelCase")]
2008pub struct SessionContextClearedData {
2009 /// Optional initial message set after clearing
2010 #[serde(skip_serializing_if = "Option::is_none")]
2011 pub initial_message: Option<String>,
2012 /// Number of conversation messages that were cleared
2013 pub messages_cleared: i64,
2014}
2015
2016/// Session event "session.compaction_start". Context window breakdown at the start of LLM-powered conversation compaction
2017#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2018#[serde(rename_all = "camelCase")]
2019pub struct SessionCompactionStartData {
2020 /// Token count from non-system messages (user, assistant, tool) at compaction start
2021 #[serde(skip_serializing_if = "Option::is_none")]
2022 pub conversation_tokens: Option<i64>,
2023 /// Total context tokens (system + conversation + tool definitions) at compaction start, when known
2024 #[serde(skip_serializing_if = "Option::is_none")]
2025 pub current_tokens: Option<i64>,
2026 /// Model identifier used for compaction, when known
2027 #[serde(skip_serializing_if = "Option::is_none")]
2028 pub model: Option<String>,
2029 /// Token count from system message(s) at compaction start
2030 #[serde(skip_serializing_if = "Option::is_none")]
2031 pub system_tokens: Option<i64>,
2032 /// Model context window token limit the compaction is targeting, when known
2033 #[serde(skip_serializing_if = "Option::is_none")]
2034 pub token_limit: Option<i64>,
2035 /// Token count from tool definitions at compaction start
2036 #[serde(skip_serializing_if = "Option::is_none")]
2037 pub tool_definitions_tokens: Option<i64>,
2038 /// What initiated this compaction, when known
2039 #[serde(skip_serializing_if = "Option::is_none")]
2040 pub trigger: Option<CompactionTrigger>,
2041}
2042
2043/// Token usage detail for a single billing category
2044#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2045#[serde(rename_all = "camelCase")]
2046pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
2047 /// Number of tokens in this billing batch
2048 pub batch_size: i64,
2049 /// Cost per batch of tokens
2050 pub cost_per_batch: i64,
2051 /// Model responsible for this billing entry
2052 #[serde(skip_serializing_if = "Option::is_none")]
2053 pub model: Option<String>,
2054 /// Total token count for this entry
2055 pub token_count: i64,
2056 /// Token category (e.g., "input", "output")
2057 pub token_type: String,
2058}
2059
2060/// Per-request cost and usage data from the CAPI copilot_usage response field
2061#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2062#[serde(rename_all = "camelCase")]
2063pub(crate) struct CompactionCompleteCompactionTokensUsedCopilotUsage {
2064 /// Default billing model for token details that do not identify their own model
2065 #[doc(hidden)]
2066 #[serde(skip_serializing_if = "Option::is_none")]
2067 pub(crate) model: Option<String>,
2068 /// Itemized token usage breakdown
2069 #[doc(hidden)]
2070 #[serde(skip_serializing_if = "Option::is_none")]
2071 pub(crate) token_details:
2072 Option<Vec<CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail>>,
2073 /// Total cost in nano-AI units for this request
2074 pub total_nano_aiu: f64,
2075}
2076
2077/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
2078#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2079#[serde(rename_all = "camelCase")]
2080pub struct CompactionCompleteCompactionTokensUsed {
2081 /// Cached input tokens reused in the compaction LLM call
2082 #[serde(skip_serializing_if = "Option::is_none")]
2083 pub cache_read_tokens: Option<i64>,
2084 /// Tokens written to prompt cache in the compaction LLM call
2085 #[serde(skip_serializing_if = "Option::is_none")]
2086 pub cache_write_tokens: Option<i64>,
2087 /// Per-request cost and usage data from the CAPI copilot_usage response field
2088 #[doc(hidden)]
2089 #[serde(skip_serializing_if = "Option::is_none")]
2090 pub(crate) copilot_usage: Option<CompactionCompleteCompactionTokensUsedCopilotUsage>,
2091 /// Duration of the compaction LLM call in milliseconds
2092 #[serde(skip_serializing_if = "Option::is_none")]
2093 pub duration: Option<i64>,
2094 /// Input tokens consumed by the compaction LLM call
2095 #[serde(skip_serializing_if = "Option::is_none")]
2096 pub input_tokens: Option<i64>,
2097 /// Model identifier used for the compaction LLM call
2098 #[serde(skip_serializing_if = "Option::is_none")]
2099 pub model: Option<String>,
2100 /// Output tokens produced by the compaction LLM call
2101 #[serde(skip_serializing_if = "Option::is_none")]
2102 pub output_tokens: Option<i64>,
2103}
2104
2105/// Original request-level and effective conversation reasoning effort for a Responses history boundary
2106#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2107#[serde(rename_all = "camelCase")]
2108pub struct ResponsesReasoning {
2109 /// Effective effort selected before this message, independent of the response-level reasoning field
2110 pub effort: String,
2111 /// Original request-level effort, retained while replaying this conversation prefix
2112 pub initial_effort: String,
2113 /// Provider model whose reasoning settings this boundary records
2114 pub model: String,
2115}
2116
2117/// Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
2118#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2119#[serde(rename_all = "camelCase")]
2120pub struct SessionCompactionCompleteData {
2121 /// Authoritative active-factory reminder appended to the compacted context
2122 #[doc(hidden)]
2123 #[serde(skip_serializing_if = "Option::is_none")]
2124 pub(crate) active_factory_summary: Option<String>,
2125 /// Canonical model identifier used for model-specific behavior when replaying compaction
2126 #[serde(skip_serializing_if = "Option::is_none")]
2127 pub behavior_model_id: Option<String>,
2128 /// Checkpoint snapshot number created for recovery
2129 #[serde(skip_serializing_if = "Option::is_none")]
2130 pub checkpoint_number: Option<i64>,
2131 /// File path where the checkpoint was stored
2132 #[serde(skip_serializing_if = "Option::is_none")]
2133 pub checkpoint_path: Option<String>,
2134 /// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
2135 #[serde(skip_serializing_if = "Option::is_none")]
2136 pub compaction_tokens_used: Option<CompactionCompleteCompactionTokensUsed>,
2137 /// Token count from non-system messages (user, assistant, tool) after compaction
2138 #[serde(skip_serializing_if = "Option::is_none")]
2139 pub conversation_tokens: Option<i64>,
2140 /// User-supplied focus instructions provided to a manual `/compact` invocation. Omitted for automatic compaction and for manual compaction with no focus text.
2141 #[serde(skip_serializing_if = "Option::is_none")]
2142 pub custom_instructions: Option<String>,
2143 /// Error message if compaction failed
2144 #[serde(skip_serializing_if = "Option::is_none")]
2145 pub error: Option<String>,
2146 /// Number of messages removed during compaction
2147 #[serde(skip_serializing_if = "Option::is_none")]
2148 pub messages_removed: Option<i64>,
2149 /// Total tokens in conversation after compaction
2150 #[serde(skip_serializing_if = "Option::is_none")]
2151 pub post_compaction_tokens: Option<i64>,
2152 /// Number of messages before compaction
2153 #[serde(skip_serializing_if = "Option::is_none")]
2154 pub pre_compaction_messages_length: Option<i64>,
2155 /// Total tokens in conversation before compaction
2156 #[serde(skip_serializing_if = "Option::is_none")]
2157 pub pre_compaction_tokens: Option<i64>,
2158 /// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
2159 #[serde(skip_serializing_if = "Option::is_none")]
2160 pub request_id: Option<RequestId>,
2161 /// Reasoning baseline on the replacement summary, preserved when replay skips the compacted history
2162 #[serde(skip_serializing_if = "Option::is_none")]
2163 pub responses_reasoning: Option<ResponsesReasoning>,
2164 /// Copilot service request ID (x-copilot-service-request-id header) for the compaction LLM call
2165 #[serde(skip_serializing_if = "Option::is_none")]
2166 pub service_request_id: Option<String>,
2167 /// For failed compaction only: the HTTP status code of the compaction LLM call failure, when it carried one. Absent for successful compaction and for failures without an HTTP status (e.g. an empty model response or a transport error).
2168 #[serde(skip_serializing_if = "Option::is_none")]
2169 pub status_code: Option<i64>,
2170 /// Whether compaction completed successfully
2171 pub success: bool,
2172 /// LLM-generated summary of the compacted conversation history
2173 #[serde(skip_serializing_if = "Option::is_none")]
2174 pub summary_content: Option<String>,
2175 /// Token count from system message(s) after compaction
2176 #[serde(skip_serializing_if = "Option::is_none")]
2177 pub system_tokens: Option<i64>,
2178 /// Model context window token limit the compaction was targeting, when known
2179 #[serde(skip_serializing_if = "Option::is_none")]
2180 pub token_limit: Option<i64>,
2181 /// Number of tokens removed during compaction
2182 #[serde(skip_serializing_if = "Option::is_none")]
2183 pub tokens_removed: Option<i64>,
2184 /// Token count from tool definitions after compaction
2185 #[serde(skip_serializing_if = "Option::is_none")]
2186 pub tool_definitions_tokens: Option<i64>,
2187 /// What initiated this compaction, when known
2188 #[serde(skip_serializing_if = "Option::is_none")]
2189 pub trigger: Option<CompactionTrigger>,
2190}
2191
2192#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2193#[serde(rename_all = "camelCase")]
2194pub struct PermissionRecoveryAttempt {
2195 /// Unique identifier for this attempt record
2196 pub attempt_id: String,
2197 /// How the runtime handled this attempt
2198 pub disposition: PermissionRecoveryAttemptDisposition,
2199 /// One-based position of this attempt in the episode
2200 pub ordinal: i64,
2201 /// Controlled permission request kind, such as shell, path, URL, or tool
2202 pub permission_kind: String,
2203 /// Controlled reason for the attempt disposition
2204 pub reason: PermissionRecoveryAttemptReason,
2205 /// Relationship between this attempt and earlier attempts in the episode
2206 pub relation: PermissionRecoveryAttemptRelation,
2207 /// SHA-256 fingerprint of normalized request data; raw permission arguments are not included
2208 pub request_fingerprint: String,
2209 /// Tool-call identifier associated with this attempt, when available
2210 #[serde(skip_serializing_if = "Option::is_none")]
2211 pub tool_call_id: Option<String>,
2212}
2213
2214/// Authoritative snapshot of an Autopilot permission-recovery episode
2215#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2216#[serde(rename_all = "camelCase")]
2217pub struct PermissionRecoveryData {
2218 /// Ordered privacy-safe record of permission attempts and the successful alternative, when any
2219 pub attempts: Vec<PermissionRecoveryAttempt>,
2220 /// Stable identifier shared by every transition in this recovery episode
2221 pub episode_id: String,
2222 /// Maximum number of distinct autonomous permission attempts allowed before escalation
2223 pub max_attempts: i64,
2224 /// Policy selected from the current client's response capability; mode or client changes may update it during recovery
2225 pub on_blocked: PermissionRecoveryOnBlocked,
2226 /// Controlled reason for the latest episode transition
2227 pub reason: PermissionRecoveryReason,
2228 /// Current lifecycle state of the recovery episode
2229 pub status: PermissionRecoveryStatus,
2230}
2231
2232/// Structured reason that the task cannot continue without intervention
2233///
2234/// <div class="warning">
2235///
2236/// **Experimental.** This type is part of an experimental wire-protocol surface
2237/// and may change or be removed in future SDK or CLI releases.
2238///
2239/// </div>
2240#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2241#[serde(rename_all = "camelCase")]
2242pub struct TaskBlocker {
2243 /// Category of intervention that blocked the task
2244 pub kind: TaskBlockerKind,
2245 /// Permission-recovery episode that produced this blocker
2246 pub permission_recovery: PermissionRecoveryData,
2247 /// Controlled reason for the current blocked state
2248 pub reason: PermissionRecoveryReason,
2249 /// Whether a later user response or steering message can resume the task
2250 pub resumable: bool,
2251}
2252
2253/// Session event "session.task_complete". Task completion notification with summary from the agent
2254#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2255#[serde(rename_all = "camelCase")]
2256pub struct SessionTaskCompleteData {
2257 /// Structured blocker details when outcome is blocked
2258 #[serde(skip_serializing_if = "Option::is_none")]
2259 pub blocker: Option<TaskBlocker>,
2260 /// Active autopilot objective ID evaluated by the completion reviewer
2261 #[serde(skip_serializing_if = "Option::is_none")]
2262 pub objective_id: Option<i64>,
2263 /// Semantic completion decision. Absent on legacy events and invalid tool calls
2264 #[serde(skip_serializing_if = "Option::is_none")]
2265 pub outcome: Option<TaskCompletionOutcome>,
2266 /// Label-safe runtime rationale for the completion decision (e.g. a cancellation or pause/resume downgrade), when one applies. Reviewer-authored rationale is intentionally omitted here because this event has no IFC label channel; the reviewer's findings remain available through its own labeled sub-agent events
2267 #[serde(skip_serializing_if = "Option::is_none")]
2268 pub reason: Option<String>,
2269 /// Whether the task was accepted as complete. False when validation failed or completion was rejected or blocked by the reviewer
2270 #[serde(skip_serializing_if = "Option::is_none")]
2271 pub success: Option<bool>,
2272 /// Summary of the completed task, provided by the agent
2273 #[serde(skip_serializing_if = "Option::is_none")]
2274 pub summary: Option<String>,
2275}
2276
2277/// Inclusive durable event range summarized by a completion receipt.
2278#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2279#[serde(rename_all = "camelCase")]
2280pub struct CompletionReceiptEventRange {
2281 /// Identifier of the assistant turn-end event that ends the covered exchange. Always equals the receipt's sourceEventId, so either field is a valid join key.
2282 pub end_event_id: String,
2283 /// Identifier of the user message that starts the covered exchange.
2284 pub start_event_id: String,
2285}
2286
2287/// Final structured tool completion in the covered event range.
2288#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2289#[serde(rename_all = "camelCase")]
2290pub struct CompletionReceiptFinalTool {
2291 /// Process exit code from a structured shell result, when available.
2292 #[serde(skip_serializing_if = "Option::is_none")]
2293 pub exit_code: Option<i64>,
2294 /// Structured success or failure status from the tool completion event.
2295 pub status: CompletionReceiptToolStatus,
2296 /// Unique identifier of the completed tool call.
2297 pub tool_call_id: String,
2298 /// Tool name from the matching tool execution start event, when available.
2299 #[serde(skip_serializing_if = "Option::is_none")]
2300 pub tool_name: Option<String>,
2301}
2302
2303/// Session event "session.completion_receipt". Behavior-neutral record of structured runtime facts present when an agent completion decision is accepted.
2304///
2305/// <div class="warning">
2306///
2307/// **Experimental.** This type is part of an experimental wire-protocol surface
2308/// and may change or be removed in future SDK or CLI releases.
2309///
2310/// </div>
2311#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2312#[serde(rename_all = "camelCase")]
2313pub struct SessionCompletionReceiptData {
2314 /// One-based accepted completion receipt ordinal in the durable session history.
2315 pub attempt: i64,
2316 /// Inclusive durable event range summarized by this receipt.
2317 pub event_range: CompletionReceiptEventRange,
2318 /// Number of failed structured tool completions in the covered range.
2319 pub failed_tool_count: i64,
2320 /// Final structured tool completion in the covered range, when one exists.
2321 #[serde(skip_serializing_if = "Option::is_none")]
2322 pub final_tool: Option<CompletionReceiptFinalTool>,
2323 /// Version of the completion receipt payload.
2324 pub schema_version: i64,
2325 /// Identifier of the assistant turn-end event that supplied the accepted completion boundary. This is the receipt's idempotency key, and always equals eventRange.endEventId.
2326 pub source_event_id: String,
2327 /// Runtime reason the completion decision was accepted.
2328 pub stop_reason: CompletionReceiptStopReason,
2329 /// Number of successful structured tool completions in the covered range.
2330 pub successful_tool_count: i64,
2331}
2332
2333/// Session event "session.fusion_route_started". Experimental transient signal that HydraFusion routing has started for an eligible turn.
2334///
2335/// <div class="warning">
2336///
2337/// **Experimental.** This type is part of an experimental wire-protocol surface
2338/// and may change or be removed in future SDK or CLI releases.
2339///
2340/// </div>
2341#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2342#[serde(rename_all = "camelCase")]
2343pub struct SessionFusionRouteStartedData {
2344 /// Identifier for this routing attempt before a durable Fusion turn exists.
2345 pub attempt_id: String,
2346 /// HydraFusion routing policy requested for the turn.
2347 #[serde(skip_serializing_if = "Option::is_none")]
2348 pub policy: Option<String>,
2349 /// Synthetic HydraFusion model selected for the session.
2350 #[serde(skip_serializing_if = "Option::is_none")]
2351 pub synthetic_model: Option<String>,
2352 /// Kind of turn being routed.
2353 pub turn_kind: FusionTurnKind,
2354}
2355
2356/// Session event "session.fusion_route_failed". Experimental durable HydraFusion routing failure and the deterministic concrete fallback selected for the turn.
2357///
2358/// <div class="warning">
2359///
2360/// **Experimental.** This type is part of an experimental wire-protocol surface
2361/// and may change or be removed in future SDK or CLI releases.
2362///
2363/// </div>
2364#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2365#[serde(rename_all = "camelCase")]
2366pub struct SessionFusionRouteFailedData {
2367 /// Identifier of the routing attempt that failed.
2368 pub attempt_id: String,
2369 /// Provider or validation error detail, when available.
2370 #[serde(skip_serializing_if = "Option::is_none")]
2371 pub error_message: Option<String>,
2372 /// Concrete model selected as the deterministic fallback.
2373 pub fallback_model: String,
2374 /// HydraFusion routing policy requested for the turn.
2375 pub policy: String,
2376 /// Stable machine-readable reason for the routing failure.
2377 pub reason: String,
2378 /// Elapsed routing time in milliseconds before the failure.
2379 #[serde(skip_serializing_if = "Option::is_none")]
2380 pub routing_latency_ms: Option<f64>,
2381 /// Synthetic HydraFusion model selected for the session.
2382 pub synthetic_model: String,
2383}
2384
2385/// Durable server recommendation for subsequent HydraFusion turns.
2386///
2387/// <div class="warning">
2388///
2389/// **Experimental.** This type is part of an experimental wire-protocol surface
2390/// and may change or be removed in future SDK or CLI releases.
2391///
2392/// </div>
2393#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2394#[serde(rename_all = "camelCase")]
2395pub struct FusionFollowUpRecommendation {
2396 /// Recommended routing action for the next compaction turn.
2397 pub compaction_turn: FusionFollowUpAction,
2398 /// Recommended routing action for the next user-message turn.
2399 pub user_turn: FusionFollowUpAction,
2400}
2401
2402/// Presentation-neutral phase planned for a HydraFusion turn.
2403///
2404/// <div class="warning">
2405///
2406/// **Experimental.** This type is part of an experimental wire-protocol surface
2407/// and may change or be removed in future SDK or CLI releases.
2408///
2409/// </div>
2410#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2411#[serde(rename_all = "camelCase")]
2412pub struct FusionPhasePlanStep {
2413 /// Whether the phase executes only when an earlier phase requests it.
2414 pub conditional: bool,
2415 /// Kind of phase that may execute.
2416 pub kind: FusionPhaseKind,
2417 /// Semantic role assigned to the phase.
2418 pub role: String,
2419 /// Conversation scope in which the phase executes.
2420 pub scope: FusionConversationScope,
2421}
2422
2423/// Validated HydraFusion routing capability scores.
2424///
2425/// <div class="warning">
2426///
2427/// **Experimental.** This type is part of an experimental wire-protocol surface
2428/// and may change or be removed in future SDK or CLI releases.
2429///
2430/// </div>
2431#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2432#[serde(rename_all = "camelCase")]
2433pub struct FusionScores {
2434 /// Code-generation capability score returned by the authenticated router.
2435 pub code_gen: f64,
2436 /// Debugging capability score returned by the authenticated router.
2437 pub debugging: f64,
2438 /// Reasoning capability score returned by the authenticated router.
2439 pub reasoning: f64,
2440 /// Tool-use capability score returned by the authenticated router.
2441 pub tool_use: f64,
2442}
2443
2444/// Session event "session.fusion_resolved". Experimental durable validated HydraFusion route and turn policy.
2445///
2446/// <div class="warning">
2447///
2448/// **Experimental.** This type is part of an experimental wire-protocol surface
2449/// and may change or be removed in future SDK or CLI releases.
2450///
2451/// </div>
2452#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2453#[serde(rename_all = "camelCase")]
2454pub struct SessionFusionResolvedData {
2455 /// Version of the validated HydraFusion event contract.
2456 pub contract_version: i64,
2457 /// Concrete model used when the planned primary model cannot execute.
2458 pub fallback_model: String,
2459 /// Router recommendation controlling reuse or rerouting on later turns.
2460 #[serde(skip_serializing_if = "Option::is_none")]
2461 pub follow_up: Option<FusionFollowUpRecommendation>,
2462 /// Concrete model recommended for eligible follow-up turns.
2463 pub follow_up_model: String,
2464 /// Stable identifier for the resolved HydraFusion turn.
2465 pub fusion_id: String,
2466 /// Short human-readable summary of the selected workflow, suitable for immediate client display after routing. May be absent in older durable events; omit the explanation or derive one from pattern and phasePlan. Display text, not a stable machine-readable value.
2467 ///
2468 /// <div class="warning">
2469 ///
2470 /// **Experimental.** This type is part of an experimental wire-protocol surface
2471 /// and may change or be removed in future SDK or CLI releases.
2472 ///
2473 /// </div>
2474 #[serde(skip_serializing_if = "Option::is_none")]
2475 pub hint: Option<String>,
2476 /// Version of the executable model universe used for selection.
2477 #[serde(skip_serializing_if = "Option::is_none")]
2478 pub model_universe_version: Option<String>,
2479 /// Validated orchestration pattern selected for the turn.
2480 pub pattern: FusionPattern,
2481 /// Presentation-neutral phase plan for clients that render workflow progress.
2482 ///
2483 /// <div class="warning">
2484 ///
2485 /// **Experimental.** This type is part of an experimental wire-protocol surface
2486 /// and may change or be removed in future SDK or CLI releases.
2487 ///
2488 /// </div>
2489 #[serde(skip_serializing_if = "Option::is_none")]
2490 pub phase_plan: Option<Vec<FusionPhasePlanStep>>,
2491 /// Version of the validated execution-plan format.
2492 #[serde(skip_serializing_if = "Option::is_none")]
2493 pub plan_version: Option<String>,
2494 /// HydraFusion routing policy used to resolve the plan.
2495 pub policy: String,
2496 /// Version of the local routing policy.
2497 #[serde(skip_serializing_if = "Option::is_none")]
2498 pub policy_version: Option<String>,
2499 /// Concrete model selected for the primary solver phase.
2500 pub primary_model: String,
2501 /// Router implementation that supplied the plan.
2502 #[serde(skip_serializing_if = "Option::is_none")]
2503 pub route_source: Option<String>,
2504 /// Elapsed time in milliseconds required to resolve and validate the route.
2505 #[serde(skip_serializing_if = "Option::is_none")]
2506 pub routing_latency_ms: Option<f64>,
2507 /// Identifier of the local policy rule that matched.
2508 #[serde(skip_serializing_if = "Option::is_none")]
2509 pub rule_id: Option<String>,
2510 /// Zero-based index of the local policy rule that matched.
2511 #[serde(skip_serializing_if = "Option::is_none")]
2512 pub rule_index: Option<i64>,
2513 /// Human-readable name of the local policy rule that matched.
2514 #[serde(skip_serializing_if = "Option::is_none")]
2515 pub rule_name: Option<String>,
2516 /// Validated capability scores used to select the route.
2517 #[serde(skip_serializing_if = "Option::is_none")]
2518 pub scores: Option<FusionScores>,
2519 /// Concrete model selected for the review or judge phase, when required.
2520 pub secondary_model: Option<String>,
2521 /// Synthetic HydraFusion model selected for the session.
2522 pub synthetic_model: String,
2523 /// Identifier of the session turn associated with the route.
2524 pub turn_id: String,
2525}
2526
2527/// Session event "session.fusion_completed". Experimental durable aggregate outcome of a HydraFusion turn.
2528///
2529/// <div class="warning">
2530///
2531/// **Experimental.** This type is part of an experimental wire-protocol surface
2532/// and may change or be removed in future SDK or CLI releases.
2533///
2534/// </div>
2535#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2536#[serde(rename_all = "camelCase")]
2537pub struct SessionFusionCompletedData {
2538 /// Total cached input tokens reported across all phases.
2539 pub cached_tokens: i64,
2540 /// Total tokens written to prompt cache across all phases.
2541 #[serde(skip_serializing_if = "Option::is_none")]
2542 pub cache_write_tokens: Option<i64>,
2543 /// Idempotency identifier for the authoritative final commit.
2544 pub commit_id: String,
2545 /// Reason the turn used a degraded route, when applicable.
2546 pub degraded_reason: Option<String>,
2547 /// Total elapsed execution time for the HydraFusion turn in milliseconds.
2548 pub duration_ms: f64,
2549 /// Concrete model that supplied the authoritative final content.
2550 pub final_source_model: Option<String>,
2551 /// Phase whose output supplied the authoritative final content.
2552 pub final_source_phase_id: Option<String>,
2553 /// Concrete model recommended for eligible follow-up turns.
2554 pub follow_up_model: String,
2555 /// Stable identifier for the completed HydraFusion turn.
2556 pub fusion_id: String,
2557 /// Total input tokens consumed across all phases.
2558 pub input_tokens: i64,
2559 /// Stable aggregate outcome of the HydraFusion turn.
2560 pub outcome: String,
2561 /// Total output tokens produced across all phases.
2562 pub output_tokens: i64,
2563 /// HydraFusion orchestration pattern executed for the turn.
2564 pub pattern: FusionPattern,
2565 /// Number of concrete phases attempted by the turn.
2566 pub phase_count: i64,
2567 /// Total concrete model requests made across all phases.
2568 pub request_count: i64,
2569 /// Synthetic HydraFusion model selected for the session.
2570 pub synthetic_model: String,
2571 /// Total normalized AI-unit cost reported across all phases, in nano-AIU.
2572 pub total_nano_aiu: f64,
2573 /// Identifier of the session turn associated with the completion.
2574 pub turn_id: String,
2575}
2576
2577/// Session event "session.permission_recovery". Authoritative snapshot of an Autopilot permission-recovery episode
2578#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2579#[serde(rename_all = "camelCase")]
2580pub struct SessionPermissionRecoveryData {
2581 /// Ordered privacy-safe record of permission attempts and the successful alternative, when any
2582 pub attempts: Vec<PermissionRecoveryAttempt>,
2583 /// Stable identifier shared by every transition in this recovery episode
2584 pub episode_id: String,
2585 /// Maximum number of distinct autonomous permission attempts allowed before escalation
2586 pub max_attempts: i64,
2587 /// Policy selected from the current client's response capability; mode or client changes may update it during recovery
2588 pub on_blocked: PermissionRecoveryOnBlocked,
2589 /// Controlled reason for the latest episode transition
2590 pub reason: PermissionRecoveryReason,
2591 /// Current lifecycle state of the recovery episode
2592 pub status: PermissionRecoveryStatus,
2593}
2594
2595/// Session event "user.message". Payload of `user.message` with displayed and model-transformed content, attachments, source/delivery metadata, mode, and telemetry IDs.
2596#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2597#[serde(rename_all = "camelCase")]
2598pub struct UserMessageData {
2599 /// The agent mode that was active when this message was sent
2600 #[serde(skip_serializing_if = "Option::is_none")]
2601 pub agent_mode: Option<UserMessageAgentMode>,
2602 /// Files, selections, or GitHub references attached to the message
2603 #[serde(skip_serializing_if = "Option::is_none")]
2604 pub attachments: Option<Vec<serde_json::Value>>,
2605 /// The user's message text as displayed in the timeline
2606 pub content: String,
2607 /// 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.
2608 #[serde(skip_serializing_if = "Option::is_none")]
2609 pub delivery: Option<UserMessageDelivery>,
2610 /// CAPI interaction ID for correlating this user message with its turn
2611 #[serde(skip_serializing_if = "Option::is_none")]
2612 pub interaction_id: Option<String>,
2613 /// 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.
2614 #[serde(skip_serializing_if = "Option::is_none")]
2615 pub is_autopilot_continuation: Option<bool>,
2616 /// Stable identity of the logical user message, matching the ID returned by send and retained by pending queue snapshots
2617 #[serde(skip_serializing_if = "Option::is_none")]
2618 pub message_id: Option<String>,
2619 /// 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
2620 #[serde(skip_serializing_if = "Option::is_none")]
2621 pub native_document_path_fallback_paths: Option<Vec<String>>,
2622 /// Parent agent task ID for background telemetry correlated to this user turn
2623 #[serde(skip_serializing_if = "Option::is_none")]
2624 pub parent_agent_task_id: Option<String>,
2625 /// Responses reasoning settings anchored before this model-facing message, for cache-stable history replay
2626 #[serde(skip_serializing_if = "Option::is_none")]
2627 pub responses_reasoning: Option<ResponsesReasoning>,
2628 /// 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)
2629 #[serde(skip_serializing_if = "Option::is_none")]
2630 pub source: Option<String>,
2631 /// Normalized document MIME types that were sent natively instead of through tagged_files XML
2632 #[serde(skip_serializing_if = "Option::is_none")]
2633 pub supported_native_document_mime_types: Option<Vec<String>>,
2634 /// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching
2635 #[serde(skip_serializing_if = "Option::is_none")]
2636 pub transformed_content: Option<String>,
2637 /// The agent-loop turn ID that consumed this message; absent when no agent-loop turn consumed it
2638 #[serde(skip_serializing_if = "Option::is_none")]
2639 pub turn_id: Option<String>,
2640}
2641
2642/// Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
2643#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2644#[serde(rename_all = "camelCase")]
2645pub struct PendingMessagesModifiedData {}
2646
2647/// Session event "assistant.turn_start". Turn initialization metadata including identifier and interaction tracking
2648#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2649#[serde(rename_all = "camelCase")]
2650pub struct AssistantTurnStartData {
2651 /// CAPI interaction ID for correlating this turn with upstream telemetry
2652 #[serde(skip_serializing_if = "Option::is_none")]
2653 pub interaction_id: Option<String>,
2654 /// Model identifier used for this turn, when known
2655 #[serde(skip_serializing_if = "Option::is_none")]
2656 pub model: Option<String>,
2657 /// Identifier for this turn within the agentic loop, typically a stringified turn number
2658 pub turn_id: String,
2659}
2660
2661/// Session event "assistant.turn_retry". Metadata for an additional model inference attempt within an existing assistant turn
2662#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2663#[serde(rename_all = "camelCase")]
2664pub struct AssistantTurnRetryData {
2665 /// Model identifier used for this retry, when known
2666 #[serde(skip_serializing_if = "Option::is_none")]
2667 pub model: Option<String>,
2668 /// Provider or runtime classification that caused the retry, when known
2669 #[serde(skip_serializing_if = "Option::is_none")]
2670 pub reason: Option<String>,
2671 /// Identifier of the turn whose model inference is being retried
2672 pub turn_id: String,
2673}
2674
2675/// Session event "agent.interrupted". Metadata for work the user interrupted while the agent was running
2676#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2677#[serde(rename_all = "camelCase")]
2678pub struct AgentInterruptedData {
2679 /// What the agent was doing when the user interrupted it
2680 pub activity: AgentInterruptedActivity,
2681 /// For an interrupted model call: the provider endpoint the request targeted
2682 #[serde(skip_serializing_if = "Option::is_none")]
2683 pub api_endpoint: Option<String>,
2684 /// For an interrupted model call: whether the user interrupted before any token arrived or while the response was streaming
2685 #[serde(skip_serializing_if = "Option::is_none")]
2686 pub cancel_phase: Option<AgentInterruptedCancelPhase>,
2687 /// How long the interrupted work had been running, in milliseconds
2688 pub elapsed_ms: f64,
2689 /// 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.
2690 #[serde(skip_serializing_if = "Option::is_none")]
2691 pub interrupted_agent_count: Option<i64>,
2692 /// For an interrupted model call: the model the request targeted
2693 #[serde(skip_serializing_if = "Option::is_none")]
2694 pub model: Option<String>,
2695 /// 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.
2696 #[serde(skip_serializing_if = "Option::is_none")]
2697 pub output_ttft_ms: Option<f64>,
2698 /// For an interrupted model call: the reasoning effort the request asked for
2699 #[serde(skip_serializing_if = "Option::is_none")]
2700 pub reasoning_effort: Option<String>,
2701 /// Subset of `toolNames` whose tool metadata marks the tool name as safe to record unhashed in telemetry.
2702 #[serde(skip_serializing_if = "Option::is_none")]
2703 pub safe_tool_names: Option<Vec<String>>,
2704 /// Tool call identifiers that were still running
2705 #[serde(skip_serializing_if = "Option::is_none")]
2706 pub tool_call_ids: Option<Vec<String>>,
2707 /// Names of the tools that were still running. More than one when the model requested a parallel fan-out.
2708 #[serde(skip_serializing_if = "Option::is_none")]
2709 pub tool_names: Option<Vec<String>>,
2710 /// For an interrupted model call: the transport the request used
2711 #[serde(skip_serializing_if = "Option::is_none")]
2712 pub transport: Option<ModelCallFailureTransport>,
2713 /// Zero-based agentic-loop iteration the interrupt landed in
2714 pub turn: i64,
2715}
2716
2717/// Session event "assistant.intent". Agent intent description for current activity or plan
2718#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2719#[serde(rename_all = "camelCase")]
2720pub struct AssistantIntentData {
2721 /// Short description of what the agent is currently doing or planning to do
2722 pub intent: String,
2723}
2724
2725/// Session event "assistant.fusion_phase_started". Experimental transient HydraFusion phase/model/role signal.
2726///
2727/// <div class="warning">
2728///
2729/// **Experimental.** This type is part of an experimental wire-protocol surface
2730/// and may change or be removed in future SDK or CLI releases.
2731///
2732/// </div>
2733#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2734#[serde(rename_all = "camelCase")]
2735pub struct AssistantFusionPhaseStartedData {
2736 /// Conversation scope in which the phase executes.
2737 pub conversation_scope: FusionConversationScope,
2738 /// Identifier of the HydraFusion turn containing the phase.
2739 pub fusion_id: String,
2740 /// Concrete model executing the phase.
2741 pub model: String,
2742 /// HydraFusion orchestration pattern containing the phase.
2743 pub pattern: FusionPattern,
2744 /// Stable identifier for the concrete phase.
2745 pub phase_id: String,
2746 /// Kind of phase being executed.
2747 pub phase_kind: FusionPhaseKind,
2748 /// Semantic role assigned to the phase.
2749 pub role: String,
2750}
2751
2752/// Session event "assistant.fusion_phase_activity". Experimental content-safe activity signal for a running HydraFusion phase.
2753///
2754/// <div class="warning">
2755///
2756/// **Experimental.** This type is part of an experimental wire-protocol surface
2757/// and may change or be removed in future SDK or CLI releases.
2758///
2759/// </div>
2760#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2761#[serde(rename_all = "camelCase")]
2762pub struct AssistantFusionPhaseActivityData {
2763 /// Kind of real activity observed.
2764 pub activity: FusionPhaseActivityKind,
2765 /// Conversation scope in which the phase executes.
2766 pub conversation_scope: FusionConversationScope,
2767 /// Identifier of the HydraFusion turn containing the phase.
2768 pub fusion_id: String,
2769 /// HydraFusion orchestration pattern containing the phase.
2770 pub pattern: FusionPattern,
2771 /// Stable identifier for the concrete phase.
2772 pub phase_id: String,
2773 /// Kind of phase currently executing.
2774 pub phase_kind: FusionPhaseKind,
2775 /// Semantic role assigned to the phase.
2776 pub role: String,
2777 /// 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.
2778 #[serde(skip_serializing_if = "Option::is_none")]
2779 pub tool_call_id: Option<String>,
2780 /// Cumulative private response bytes observed for this model call. The event never includes response text.
2781 #[serde(skip_serializing_if = "Option::is_none")]
2782 pub total_response_size_bytes: Option<i64>,
2783}
2784
2785/// Internal durable terminal request staged by a HydraFusion phase until an idempotent final commit selects it.
2786///
2787/// <div class="warning">
2788///
2789/// **Experimental.** This type is part of an experimental wire-protocol surface
2790/// and may change or be removed in future SDK or CLI releases.
2791///
2792/// </div>
2793#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2794#[serde(rename_all = "camelCase")]
2795pub(crate) struct FusionStagedTerminal {
2796 pub arguments: String,
2797 pub assistant_message: serde_json::Value,
2798 pub phase_id: String,
2799 pub tool_call_id: String,
2800 pub tool_name: String,
2801}
2802
2803/// Aggregate concrete-model usage for one HydraFusion phase.
2804///
2805/// <div class="warning">
2806///
2807/// **Experimental.** This type is part of an experimental wire-protocol surface
2808/// and may change or be removed in future SDK or CLI releases.
2809///
2810/// </div>
2811#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2812#[serde(rename_all = "camelCase")]
2813pub struct FusionPhaseUsage {
2814 /// Total cached input tokens reported for the phase.
2815 pub cached_tokens: i64,
2816 /// Total tokens written to prompt cache during the phase.
2817 #[serde(skip_serializing_if = "Option::is_none")]
2818 pub cache_write_tokens: Option<i64>,
2819 /// Total input tokens consumed by the phase.
2820 pub input_tokens: i64,
2821 /// Total output tokens produced by the phase.
2822 pub output_tokens: i64,
2823 /// Number of concrete model requests made by the phase.
2824 pub request_count: i64,
2825 /// Total normalized AI-unit cost reported for the phase, in nano-AIU.
2826 pub total_nano_aiu: f64,
2827}
2828
2829/// Session event "assistant.fusion_phase_completed". Experimental durable HydraFusion phase output and lossless replay checkpoint.
2830///
2831/// <div class="warning">
2832///
2833/// **Experimental.** This type is part of an experimental wire-protocol surface
2834/// and may change or be removed in future SDK or CLI releases.
2835///
2836/// </div>
2837#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2838#[serde(rename_all = "camelCase")]
2839pub struct AssistantFusionPhaseCompletedData {
2840 /// Provider-normalized textual output produced by the phase.
2841 pub content: String,
2842 /// Conversation scope in which the phase executed.
2843 pub conversation_scope: FusionConversationScope,
2844 /// Elapsed execution time for the phase in milliseconds.
2845 pub duration_ms: f64,
2846 /// Identifier of the HydraFusion turn containing the phase.
2847 pub fusion_id: String,
2848 /// Concrete model that executed the phase.
2849 pub model: String,
2850 /// Stable identifier for the completed phase.
2851 pub phase_id: String,
2852 /// Kind of phase that completed.
2853 pub phase_kind: FusionPhaseKind,
2854 /// Exact provider-normalized message used to reconstruct canonical model history.
2855 #[doc(hidden)]
2856 #[serde(skip_serializing_if = "Option::is_none")]
2857 pub(crate) projection_message: Option<serde_json::Value>,
2858 /// Projection action for the exact internal message.
2859 #[doc(hidden)]
2860 #[serde(skip_serializing_if = "Option::is_none")]
2861 pub(crate) projection_mode: Option<FusionProjectionMode>,
2862 /// Semantic role assigned to the completed phase.
2863 pub role: String,
2864 /// Terminal request held outside canonical state until selected by the final commit.
2865 #[doc(hidden)]
2866 #[serde(skip_serializing_if = "Option::is_none")]
2867 pub(crate) staged_terminal: Option<FusionStagedTerminal>,
2868 /// Durable outcome status of the phase.
2869 pub status: FusionPhaseStatus,
2870 /// Aggregate concrete-model usage consumed by the phase.
2871 pub usage: FusionPhaseUsage,
2872 /// Structured judge or critic verdict, when the phase produces one.
2873 pub verdict: Option<String>,
2874}
2875
2876/// Session event "assistant.fusion_phase_failed". Experimental durable typed HydraFusion phase failure and degradation transition.
2877///
2878/// <div class="warning">
2879///
2880/// **Experimental.** This type is part of an experimental wire-protocol surface
2881/// and may change or be removed in future SDK or CLI releases.
2882///
2883/// </div>
2884#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2885#[serde(rename_all = "camelCase")]
2886pub struct AssistantFusionPhaseFailedData {
2887 /// Conversation scope in which the phase executed.
2888 pub conversation_scope: FusionConversationScope,
2889 /// Identifier of the fallback phase used to continue the turn after degradation.
2890 #[serde(skip_serializing_if = "Option::is_none")]
2891 pub degraded_to_phase_id: Option<String>,
2892 /// Elapsed execution time before the phase failed, in milliseconds.
2893 pub duration_ms: f64,
2894 /// Provider or execution error detail, when available.
2895 #[serde(skip_serializing_if = "Option::is_none")]
2896 pub error_message: Option<String>,
2897 /// Identifier of the HydraFusion turn containing the phase.
2898 pub fusion_id: String,
2899 /// Concrete model that attempted the phase.
2900 pub model: String,
2901 /// Stable identifier for the failed phase.
2902 pub phase_id: String,
2903 /// Kind of phase that failed.
2904 pub phase_kind: FusionPhaseKind,
2905 /// Stable machine-readable reason for the phase failure.
2906 pub reason: String,
2907 /// Semantic role assigned to the failed phase.
2908 pub role: String,
2909 /// Durable outcome status of the phase.
2910 pub status: FusionPhaseStatus,
2911 /// Aggregate concrete-model usage consumed before the failure.
2912 pub usage: FusionPhaseUsage,
2913}
2914
2915/// 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
2916#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2917#[serde(rename_all = "camelCase")]
2918pub struct AssistantServerToolProgressData {
2919 /// Kind of hosted server tool that is running. Only `web_search` is emitted today.
2920 pub kind: String,
2921 /// 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.
2922 pub output_index: i64,
2923 /// Lifecycle status of the hosted call: `in_progress`, `searching`, or `completed`.
2924 pub status: String,
2925}
2926
2927/// Session event "assistant.reasoning". Assistant reasoning content for timeline display with complete thinking text
2928#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2929#[serde(rename_all = "camelCase")]
2930pub struct AssistantReasoningData {
2931 /// The complete extended thinking text from the model
2932 pub content: String,
2933 /// Unique identifier for this reasoning block
2934 pub reasoning_id: String,
2935 /// 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.
2936 #[serde(skip_serializing_if = "Option::is_none")]
2937 pub rte: Option<bool>,
2938}
2939
2940/// Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
2941#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2942#[serde(rename_all = "camelCase")]
2943pub struct AssistantReasoningDeltaData {
2944 /// Incremental text chunk to append to the reasoning content
2945 pub delta_content: String,
2946 /// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event
2947 pub reasoning_id: String,
2948}
2949
2950/// Session event "assistant.tool_call_delta". Streaming tool-call input delta for incremental tool-call updates
2951#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2952#[serde(rename_all = "camelCase")]
2953pub struct AssistantToolCallDeltaData {
2954 /// 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.
2955 pub input_delta: String,
2956 /// Tool call ID this delta belongs to, matching the corresponding assistant.message tool request
2957 pub tool_call_id: String,
2958 /// Name of the tool being invoked, when known from the stream
2959 #[serde(skip_serializing_if = "Option::is_none")]
2960 pub tool_name: Option<String>,
2961 /// Tool call type, when known from the stream
2962 #[serde(skip_serializing_if = "Option::is_none")]
2963 pub tool_type: Option<AssistantMessageToolRequestType>,
2964}
2965
2966/// Session event "assistant.streaming_delta". Streaming response progress with cumulative byte count
2967#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2968#[serde(rename_all = "camelCase")]
2969pub struct AssistantStreamingDeltaData {
2970 /// Cumulative total bytes received from the streaming response so far
2971 pub total_response_size_bytes: i64,
2972}
2973
2974/// A source that backs one or more cited spans in the assistant's response.
2975///
2976/// <div class="warning">
2977///
2978/// **Experimental.** This type is part of an experimental wire-protocol surface
2979/// and may change or be removed in future SDK or CLI releases.
2980///
2981/// </div>
2982#[derive(Debug, Clone, Default, Serialize, Deserialize)]
2983#[serde(rename_all = "camelCase")]
2984pub struct CitationSource {
2985 /// Stable, turn-scoped identifier for this source, referenced by CitationReference.sourceId.
2986 pub id: String,
2987 /// File path relative to the agent's workspace root, when the source is a file.
2988 #[serde(skip_serializing_if = "Option::is_none")]
2989 pub path: Option<String>,
2990 /// The system that produced this citation.
2991 pub provider: CitationProvider,
2992 /// Human-readable title of the source.
2993 #[serde(skip_serializing_if = "Option::is_none")]
2994 pub title: Option<String>,
2995 /// URL of the source, when it is a web resource.
2996 #[serde(skip_serializing_if = "Option::is_none")]
2997 pub url: Option<String>,
2998}
2999
3000/// A single citation occurrence linking a span of generated text to a supporting source.
3001///
3002/// <div class="warning">
3003///
3004/// **Experimental.** This type is part of an experimental wire-protocol surface
3005/// and may change or be removed in future SDK or CLI releases.
3006///
3007/// </div>
3008#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3009#[serde(rename_all = "camelCase")]
3010pub struct CitationReference {
3011 /// The exact text from the source that supports the cited span, when provided by the model.
3012 #[serde(skip_serializing_if = "Option::is_none")]
3013 pub cited_text: Option<String>,
3014 /// Location within the source that supports the cited span, when the provider reports one.
3015 #[serde(skip_serializing_if = "Option::is_none")]
3016 pub location: Option<serde_json::Value>,
3017 /// Provider-native citation correlation data (e.g. Anthropic search_result_index / document_index), passed through opaquely for debugging and forward compatibility.
3018 #[serde(skip_serializing_if = "Option::is_none")]
3019 pub provider_metadata: Option<serde_json::Value>,
3020 /// Identifier of the CitationSource this reference points to (CitationSource.id).
3021 pub source_id: String,
3022}
3023
3024/// A contiguous span of generated assistant text and the source references that support it.
3025///
3026/// <div class="warning">
3027///
3028/// **Experimental.** This type is part of an experimental wire-protocol surface
3029/// and may change or be removed in future SDK or CLI releases.
3030///
3031/// </div>
3032#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3033#[serde(rename_all = "camelCase")]
3034pub struct CitationSpan {
3035 /// End offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, exclusive).
3036 pub end_index: i64,
3037 /// The sources that support this span of generated text.
3038 pub references: Vec<CitationReference>,
3039 /// Start offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, inclusive).
3040 pub start_index: i64,
3041}
3042
3043/// Provider-agnostic citations linking spans of the assistant's response to their supporting sources.
3044///
3045/// <div class="warning">
3046///
3047/// **Experimental.** This type is part of an experimental wire-protocol surface
3048/// and may change or be removed in future SDK or CLI releases.
3049///
3050/// </div>
3051#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3052#[serde(rename_all = "camelCase")]
3053pub struct Citations {
3054 /// Deduplicated set of sources referenced by the citation spans.
3055 pub sources: Vec<CitationSource>,
3056 /// Spans of generated text annotated with the sources that support them.
3057 pub spans: Vec<CitationSpan>,
3058}
3059
3060/// Experimental attribution linking an ordinary event to the HydraFusion turn, phase, and concrete source that produced it.
3061///
3062/// <div class="warning">
3063///
3064/// **Experimental.** This type is part of an experimental wire-protocol surface
3065/// and may change or be removed in future SDK or CLI releases.
3066///
3067/// </div>
3068#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3069#[serde(rename_all = "camelCase")]
3070pub struct FusionAttribution {
3071 /// Idempotency identifier for the authoritative commit, when the event belongs to the selected output.
3072 #[serde(skip_serializing_if = "Option::is_none")]
3073 pub commit_id: Option<String>,
3074 /// Conversation scope in which the concrete phase executed.
3075 #[serde(skip_serializing_if = "Option::is_none")]
3076 pub conversation_scope: Option<String>,
3077 /// Stable identifier for the HydraFusion turn that produced the event.
3078 pub fusion_id: String,
3079 /// HydraFusion orchestration pattern selected for the turn.
3080 pub pattern: String,
3081 /// Identifier of the concrete phase that produced the event.
3082 #[serde(skip_serializing_if = "Option::is_none")]
3083 pub phase_id: Option<String>,
3084 /// Kind of concrete phase that produced the event.
3085 #[serde(skip_serializing_if = "Option::is_none")]
3086 pub phase_kind: Option<String>,
3087 /// HydraFusion routing policy used for the turn.
3088 pub policy: String,
3089 /// Semantic role assigned to the concrete phase.
3090 #[serde(skip_serializing_if = "Option::is_none")]
3091 pub role: Option<String>,
3092 /// Concrete model that produced the attributed event.
3093 #[serde(skip_serializing_if = "Option::is_none")]
3094 pub source_model: Option<String>,
3095 /// Phase whose output supplied the authoritative content, when different from the executing phase.
3096 #[serde(skip_serializing_if = "Option::is_none")]
3097 pub source_phase_id: Option<String>,
3098 /// Synthetic HydraFusion model selected for the session.
3099 pub synthetic_model: String,
3100}
3101
3102/// Neutral provider-tagged reasoning content blocks preserved verbatim for round-tripping
3103///
3104/// <div class="warning">
3105///
3106/// **Experimental.** This type is part of an experimental wire-protocol surface
3107/// and may change or be removed in future SDK or CLI releases.
3108///
3109/// </div>
3110#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3111#[serde(rename_all = "camelCase")]
3112pub struct AssistantMessageReasoningBlocks {
3113 /// 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.
3114 #[serde(skip_serializing_if = "Option::is_none")]
3115 pub blocks: Option<Vec<serde_json::Value>>,
3116 /// Model provider that produced these reasoning blocks.
3117 pub provider: String,
3118}
3119
3120/// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
3121///
3122/// <div class="warning">
3123///
3124/// **Experimental.** This type is part of an experimental wire-protocol surface
3125/// and may change or be removed in future SDK or CLI releases.
3126///
3127/// </div>
3128#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3129#[serde(rename_all = "camelCase")]
3130pub struct AssistantMessageServerTools {
3131 /// Advisor model identifier associated with the server-tool payload.
3132 #[serde(skip_serializing_if = "Option::is_none")]
3133 pub advisor_model: Option<String>,
3134 /// Provider function-call namespaces keyed by function-call identifier.
3135 #[serde(skip_serializing_if = "Option::is_none")]
3136 pub function_call_namespaces: Option<HashMap<String, String>>,
3137 /// Provider-native server-tool call and output items preserved verbatim for replay.
3138 #[serde(skip_serializing_if = "Option::is_none")]
3139 pub items: Option<Vec<serde_json::Value>>,
3140 /// Model provider that produced this server-tool payload.
3141 pub provider: String,
3142 /// Raw provider content blocks retained for verbatim round-tripping.
3143 #[serde(skip_serializing_if = "Option::is_none")]
3144 pub raw_content_blocks: Option<Vec<serde_json::Value>>,
3145}
3146
3147/// Hosted program that requested this client tool call
3148#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3149#[serde(rename_all = "camelCase")]
3150pub struct AssistantMessageToolRequestCaller {
3151 /// Provider-assigned identifier for the hosted caller.
3152 pub caller_id: String,
3153 /// Kind of hosted caller that requested the client tool call.
3154 pub r#type: AssistantMessageToolRequestCallerType,
3155}
3156
3157/// A tool invocation request from the assistant
3158#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3159#[serde(rename_all = "camelCase")]
3160pub struct AssistantMessageToolRequest {
3161 /// Arguments to pass to the tool, format depends on the tool
3162 #[serde(skip_serializing_if = "Option::is_none")]
3163 pub arguments: Option<serde_json::Value>,
3164 /// Hosted program that requested this client tool call
3165 #[serde(skip_serializing_if = "Option::is_none")]
3166 pub caller: Option<AssistantMessageToolRequestCaller>,
3167 /// Resolved intention summary describing what this specific call does
3168 #[serde(skip_serializing_if = "Option::is_none")]
3169 pub intention_summary: Option<String>,
3170 /// Name of the MCP server hosting this tool, when the tool is an MCP tool
3171 #[serde(skip_serializing_if = "Option::is_none")]
3172 pub mcp_server_name: Option<String>,
3173 /// Original tool name on the MCP server, when the tool is an MCP tool
3174 #[serde(skip_serializing_if = "Option::is_none")]
3175 pub mcp_tool_name: Option<String>,
3176 /// Name of the tool being invoked
3177 pub name: String,
3178 /// Unique identifier for this tool call
3179 pub tool_call_id: String,
3180 /// Human-readable display title for the tool
3181 #[serde(skip_serializing_if = "Option::is_none")]
3182 pub tool_title: Option<String>,
3183 /// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
3184 #[serde(skip_serializing_if = "Option::is_none")]
3185 pub r#type: Option<AssistantMessageToolRequestType>,
3186}
3187
3188/// Session event "assistant.message". Assistant response containing text content, optional tool requests, and interaction metadata
3189#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3190#[serde(rename_all = "camelCase")]
3191pub struct AssistantMessageData {
3192 /// Provider's completion / response identifier; shared across all chunks of a single API call. Used to group multi-chunk assistant utterances.
3193 #[serde(skip_serializing_if = "Option::is_none")]
3194 pub api_call_id: Option<String>,
3195 /// 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.
3196 #[serde(skip_serializing_if = "Option::is_none")]
3197 pub chunk_count: Option<i64>,
3198 /// Zero-based position of this message within its model call's response. Absent when the response was not split into chunks.
3199 #[serde(skip_serializing_if = "Option::is_none")]
3200 pub chunk_index: Option<i64>,
3201 /// Provider-agnostic citations linking spans of this message's content to the sources that support them. Experimental; only populated when citation emission is enabled.
3202 ///
3203 /// <div class="warning">
3204 ///
3205 /// **Experimental.** This type is part of an experimental wire-protocol surface
3206 /// and may change or be removed in future SDK or CLI releases.
3207 ///
3208 /// </div>
3209 #[serde(skip_serializing_if = "Option::is_none")]
3210 pub citations: Option<Citations>,
3211 /// 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).
3212 #[serde(skip_serializing_if = "Option::is_none")]
3213 pub client_request_id: Option<String>,
3214 /// The assistant's text response content
3215 pub content: String,
3216 /// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
3217 #[serde(skip_serializing_if = "Option::is_none")]
3218 pub encrypted_content: Option<String>,
3219 /// Experimental HydraFusion source attribution for this ordinary authoritative assistant message.
3220 ///
3221 /// <div class="warning">
3222 ///
3223 /// **Experimental.** This type is part of an experimental wire-protocol surface
3224 /// and may change or be removed in future SDK or CLI releases.
3225 ///
3226 /// </div>
3227 #[serde(skip_serializing_if = "Option::is_none")]
3228 pub fusion: Option<FusionAttribution>,
3229 /// CAPI interaction ID for correlating this message with upstream telemetry
3230 #[serde(skip_serializing_if = "Option::is_none")]
3231 pub interaction_id: Option<String>,
3232 /// Unique identifier for this assistant message
3233 pub message_id: String,
3234 /// Model that produced this assistant message, if known
3235 #[serde(skip_serializing_if = "Option::is_none")]
3236 pub model: Option<String>,
3237 /// 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.
3238 #[serde(skip_serializing_if = "Option::is_none")]
3239 pub originating_message_id: Option<String>,
3240 /// Actual output token count from the API response (completion_tokens), used for accurate token accounting
3241 #[serde(skip_serializing_if = "Option::is_none")]
3242 pub output_tokens: Option<i64>,
3243 /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3244 #[doc(hidden)]
3245 #[deprecated]
3246 #[serde(skip_serializing_if = "Option::is_none")]
3247 pub parent_tool_call_id: Option<String>,
3248 /// Generation phase for phased-output models (e.g., thinking vs. response phases)
3249 #[serde(skip_serializing_if = "Option::is_none")]
3250 pub phase: Option<String>,
3251 /// 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.
3252 #[serde(skip_serializing_if = "Option::is_none")]
3253 pub reasoning_blocks: Option<AssistantMessageReasoningBlocks>,
3254 /// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
3255 #[serde(skip_serializing_if = "Option::is_none")]
3256 pub reasoning_opaque: Option<String>,
3257 /// Readable reasoning text from the model's extended thinking
3258 #[serde(skip_serializing_if = "Option::is_none")]
3259 pub reasoning_text: Option<String>,
3260 /// 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.
3261 #[serde(skip_serializing_if = "Option::is_none")]
3262 pub reasoning_wire_field: Option<String>,
3263 /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
3264 #[serde(skip_serializing_if = "Option::is_none")]
3265 pub request_id: Option<RequestId>,
3266 /// 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.
3267 #[serde(skip_serializing_if = "Option::is_none")]
3268 pub rte: Option<bool>,
3269 /// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
3270 #[serde(skip_serializing_if = "Option::is_none")]
3271 pub server_tools: Option<AssistantMessageServerTools>,
3272 /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3273 #[serde(skip_serializing_if = "Option::is_none")]
3274 pub service_request_id: Option<String>,
3275 /// Tool invocations requested by the assistant in this message
3276 #[serde(skip_serializing_if = "Option::is_none")]
3277 pub tool_requests: Option<Vec<AssistantMessageToolRequest>>,
3278 /// Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
3279 #[serde(skip_serializing_if = "Option::is_none")]
3280 pub turn_id: Option<String>,
3281}
3282
3283/// Session event "assistant.message_start". Streaming assistant message start metadata
3284#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3285#[serde(rename_all = "camelCase")]
3286pub struct AssistantMessageStartData {
3287 /// Message ID this start event belongs to, matching subsequent deltas and assistant.message
3288 pub message_id: String,
3289 /// Generation phase this message belongs to for phased-output models
3290 #[serde(skip_serializing_if = "Option::is_none")]
3291 pub phase: Option<String>,
3292}
3293
3294/// Session event "assistant.message_delta". Streaming assistant message delta for incremental response updates
3295#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3296#[serde(rename_all = "camelCase")]
3297pub struct AssistantMessageDeltaData {
3298 /// Incremental text chunk to append to the message content
3299 pub delta_content: String,
3300 /// Message ID this delta belongs to, matching the corresponding assistant.message event
3301 pub message_id: String,
3302 /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3303 #[doc(hidden)]
3304 #[deprecated]
3305 #[serde(skip_serializing_if = "Option::is_none")]
3306 pub parent_tool_call_id: Option<String>,
3307}
3308
3309/// Session event "assistant.turn_end". Turn completion metadata including the turn identifier
3310#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3311#[serde(rename_all = "camelCase")]
3312pub struct AssistantTurnEndData {
3313 /// Model identifier used for this turn, when known
3314 #[serde(skip_serializing_if = "Option::is_none")]
3315 pub model: Option<String>,
3316 /// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event
3317 pub turn_id: String,
3318}
3319
3320/// 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
3321#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3322#[serde(rename_all = "camelCase")]
3323pub struct AssistantIdleData {
3324 /// True when the preceding agentic loop was cancelled via abort signal
3325 #[serde(skip_serializing_if = "Option::is_none")]
3326 pub aborted: Option<bool>,
3327}
3328
3329/// Token usage detail for a single billing category
3330#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3331#[serde(rename_all = "camelCase")]
3332pub struct AssistantUsageCopilotUsageTokenDetail {
3333 /// Number of tokens in this billing batch
3334 pub batch_size: i64,
3335 /// Cost per batch of tokens
3336 pub cost_per_batch: i64,
3337 /// Model responsible for this billing entry
3338 #[serde(skip_serializing_if = "Option::is_none")]
3339 pub model: Option<String>,
3340 /// Total token count for this entry
3341 pub token_count: i64,
3342 /// Token category (e.g., "input", "output")
3343 pub token_type: String,
3344}
3345
3346/// Per-request cost and usage data from the CAPI copilot_usage response field
3347#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3348#[serde(rename_all = "camelCase")]
3349pub struct AssistantUsageCopilotUsage {
3350 /// Default billing model for token details that do not identify their own model
3351 #[serde(skip_serializing_if = "Option::is_none")]
3352 pub model: Option<String>,
3353 /// Itemized token usage breakdown
3354 #[doc(hidden)]
3355 #[serde(skip_serializing_if = "Option::is_none")]
3356 pub(crate) token_details: Option<Vec<AssistantUsageCopilotUsageTokenDetail>>,
3357 /// Total cost in nano-AI units for this request
3358 pub total_nano_aiu: f64,
3359}
3360
3361/// Internal per-quota snapshot for assistant usage, including entitlement, consumed requests, overage, reset date, and remaining quota.
3362#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3363#[serde(rename_all = "camelCase")]
3364pub(crate) struct AssistantUsageQuotaSnapshot {
3365 /// Total requests allowed by the entitlement
3366 #[doc(hidden)]
3367 pub(crate) entitlement_requests: i64,
3368 /// Whether the user currently has quota available for use
3369 #[doc(hidden)]
3370 #[serde(skip_serializing_if = "Option::is_none")]
3371 pub(crate) has_quota: Option<bool>,
3372 /// Whether the user has an unlimited usage entitlement
3373 #[doc(hidden)]
3374 pub(crate) is_unlimited_entitlement: bool,
3375 /// Number of additional usage requests made this period
3376 #[doc(hidden)]
3377 pub(crate) overage: f64,
3378 /// Whether additional usage is allowed when quota is exhausted
3379 #[doc(hidden)]
3380 pub(crate) overage_allowed_with_exhausted_quota: bool,
3381 /// Pay-as-you-go additional-usage budget cap in AI credits (1 credit = $0.01); present only when CAPI emits a finite value
3382 #[doc(hidden)]
3383 #[serde(skip_serializing_if = "Option::is_none")]
3384 pub(crate) overage_entitlement: Option<f64>,
3385 /// Percentage of quota remaining (0 to 100)
3386 #[doc(hidden)]
3387 pub(crate) remaining_percentage: f64,
3388 /// Date when the quota resets
3389 #[doc(hidden)]
3390 #[serde(skip_serializing_if = "Option::is_none")]
3391 pub(crate) reset_date: Option<String>,
3392 /// Whether this snapshot uses token-based billing (AI-credits allocation)
3393 #[doc(hidden)]
3394 #[serde(skip_serializing_if = "Option::is_none")]
3395 pub(crate) token_based_billing: Option<bool>,
3396 /// Whether usage is still permitted after quota exhaustion
3397 #[doc(hidden)]
3398 pub(crate) usage_allowed_with_exhausted_quota: bool,
3399 /// Number of requests already consumed
3400 #[doc(hidden)]
3401 pub(crate) used_requests: i64,
3402}
3403
3404/// Session event "assistant.usage". LLM API call usage metrics including tokens, costs, quotas, and billing information
3405#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3406#[serde(rename_all = "camelCase")]
3407pub struct AssistantUsageData {
3408 /// Number of accepted speculative prediction tokens
3409 #[serde(skip_serializing_if = "Option::is_none")]
3410 pub accepted_prediction_tokens: Option<i64>,
3411 /// Completion ID from the model provider (e.g., chatcmpl-abc123)
3412 #[serde(skip_serializing_if = "Option::is_none")]
3413 pub api_call_id: Option<String>,
3414 /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
3415 #[serde(skip_serializing_if = "Option::is_none")]
3416 pub api_endpoint: Option<AssistantUsageApiEndpoint>,
3417 /// Number of tools available to the model for this call
3418 #[doc(hidden)]
3419 #[serde(skip_serializing_if = "Option::is_none")]
3420 pub(crate) available_tool_count: Option<i64>,
3421 /// Whether the provider reported prompt-cache usage details for this call
3422 #[doc(hidden)]
3423 #[serde(skip_serializing_if = "Option::is_none")]
3424 pub(crate) cache_details_reported: Option<bool>,
3425 /// Updated prompt-cache expiration for this model call. Present only when the call establishes or refreshes known cache state.
3426 #[serde(skip_serializing_if = "Option::is_none")]
3427 pub cache_expires_at: Option<String>,
3428 /// Number of tokens read from prompt cache
3429 #[serde(skip_serializing_if = "Option::is_none")]
3430 pub cache_read_tokens: Option<i64>,
3431 /// Effective prompt-cache lifetime in seconds for this call
3432 #[doc(hidden)]
3433 #[serde(skip_serializing_if = "Option::is_none")]
3434 pub(crate) cache_ttl_seconds: Option<i64>,
3435 /// Number of tokens written to prompt cache
3436 #[serde(skip_serializing_if = "Option::is_none")]
3437 pub cache_write_tokens: Option<i64>,
3438 /// 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.
3439 #[serde(skip_serializing_if = "Option::is_none")]
3440 pub content_filter_triggered: Option<bool>,
3441 /// Per-request cost and usage data from the CAPI copilot_usage response field
3442 #[serde(skip_serializing_if = "Option::is_none")]
3443 pub copilot_usage: Option<AssistantUsageCopilotUsage>,
3444 /// Model multiplier cost for billing purposes
3445 ///
3446 /// <div class="warning">
3447 ///
3448 /// **Experimental.** This type is part of an experimental wire-protocol surface
3449 /// and may change or be removed in future SDK or CLI releases.
3450 ///
3451 /// </div>
3452 #[serde(skip_serializing_if = "Option::is_none")]
3453 pub cost: Option<f64>,
3454 /// Duration of the API call in milliseconds
3455 #[serde(skip_serializing_if = "Option::is_none")]
3456 pub duration: Option<i64>,
3457 /// 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".
3458 #[serde(skip_serializing_if = "Option::is_none")]
3459 pub finish_reason: Option<String>,
3460 /// How the prompt-cache frontier was determined for this call
3461 #[doc(hidden)]
3462 #[serde(skip_serializing_if = "Option::is_none")]
3463 pub(crate) frontier_source: Option<String>,
3464 /// Experimental HydraFusion attribution for this concrete model call's usage.
3465 ///
3466 /// <div class="warning">
3467 ///
3468 /// **Experimental.** This type is part of an experimental wire-protocol surface
3469 /// and may change or be removed in future SDK or CLI releases.
3470 ///
3471 /// </div>
3472 #[serde(skip_serializing_if = "Option::is_none")]
3473 pub fusion: Option<FusionAttribution>,
3474 /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
3475 #[serde(skip_serializing_if = "Option::is_none")]
3476 pub initiator: Option<String>,
3477 /// Number of input tokens consumed
3478 #[serde(skip_serializing_if = "Option::is_none")]
3479 pub input_tokens: Option<i64>,
3480 /// 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.
3481 #[serde(skip_serializing_if = "Option::is_none")]
3482 pub interaction_type: Option<String>,
3483 /// Average inter-token latency in milliseconds. Only available for streaming requests
3484 #[serde(skip_serializing_if = "Option::is_none")]
3485 pub inter_token_latency_ms: Option<f64>,
3486 /// Whether Auto mode was selected for this model call
3487 #[serde(skip_serializing_if = "Option::is_none")]
3488 pub is_auto: Option<bool>,
3489 /// Whether this model call used a bring-your-own-key provider
3490 #[serde(skip_serializing_if = "Option::is_none")]
3491 pub is_byok: Option<bool>,
3492 /// Requested maximum output tokens used for this model call
3493 #[serde(skip_serializing_if = "Option::is_none")]
3494 pub max_output_tokens: Option<i64>,
3495 /// Effective maximum prompt-token limit used for this model call
3496 #[serde(skip_serializing_if = "Option::is_none")]
3497 pub max_prompt_tokens: Option<i64>,
3498 /// Model identifier used for this API call
3499 pub model: String,
3500 /// Number of tool calls returned by the model
3501 #[doc(hidden)]
3502 #[serde(skip_serializing_if = "Option::is_none")]
3503 pub(crate) num_tool_calls: Option<i64>,
3504 /// Number of output tokens produced
3505 #[serde(skip_serializing_if = "Option::is_none")]
3506 pub output_tokens: Option<i64>,
3507 /// Time to first observable model output in milliseconds. Includes text, reasoning, and tool-call output; only available for streaming requests that produce observable output.
3508 #[serde(skip_serializing_if = "Option::is_none")]
3509 pub output_ttft_ms: Option<f64>,
3510 /// Parent tool call ID when this usage originates from a sub-agent
3511 #[doc(hidden)]
3512 #[deprecated]
3513 #[serde(skip_serializing_if = "Option::is_none")]
3514 pub parent_tool_call_id: Option<String>,
3515 /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
3516 #[serde(skip_serializing_if = "Option::is_none")]
3517 pub provider_call_id: Option<String>,
3518 /// Per-quota resource usage snapshots, keyed by quota identifier
3519 #[doc(hidden)]
3520 #[serde(skip_serializing_if = "Option::is_none")]
3521 pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
3522 /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
3523 #[serde(skip_serializing_if = "Option::is_none")]
3524 pub reasoning_effort: Option<String>,
3525 /// Reasoning summary mode used for this model call, if applicable
3526 #[serde(skip_serializing_if = "Option::is_none")]
3527 pub reasoning_summary: Option<ReasoningSummary>,
3528 /// Number of output tokens used for reasoning (e.g., chain-of-thought)
3529 #[serde(skip_serializing_if = "Option::is_none")]
3530 pub reasoning_tokens: Option<i64>,
3531 /// Number of rejected speculative prediction tokens
3532 #[serde(skip_serializing_if = "Option::is_none")]
3533 pub rejected_prediction_tokens: Option<i64>,
3534 /// 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.
3535 #[serde(skip_serializing_if = "Option::is_none")]
3536 pub rte: Option<bool>,
3537 /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3538 #[serde(skip_serializing_if = "Option::is_none")]
3539 pub service_request_id: Option<String>,
3540 /// Number of prior thinking blocks the provider dropped while transforming the request
3541 #[doc(hidden)]
3542 #[serde(skip_serializing_if = "Option::is_none")]
3543 pub(crate) thinking_dropped_blocks: Option<i64>,
3544 /// Recognized provider-reported reasons for dropped thinking blocks, in response order
3545 #[doc(hidden)]
3546 #[serde(skip_serializing_if = "Option::is_none")]
3547 pub(crate) thinking_dropped_reasons: Option<Vec<String>>,
3548 /// Time to first token in milliseconds. Only available for streaming requests
3549 #[serde(skip_serializing_if = "Option::is_none")]
3550 pub time_to_first_token_ms: Option<f64>,
3551 /// Tool-call counts keyed by tool name
3552 #[doc(hidden)]
3553 #[serde(skip_serializing_if = "Option::is_none")]
3554 pub(crate) tool_counts: Option<HashMap<String, i64>>,
3555 /// Number of tokens used by tool definitions for this call
3556 #[doc(hidden)]
3557 #[serde(skip_serializing_if = "Option::is_none")]
3558 pub(crate) tool_token_count: Option<i64>,
3559 /// Transport used for this model call (http or websocket)
3560 #[serde(skip_serializing_if = "Option::is_none")]
3561 pub transport: Option<AssistantUsageTransport>,
3562}
3563
3564/// Session event "prompt_cache_break". A detected loss of a previously cached prompt prefix
3565#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3566#[serde(rename_all = "camelCase")]
3567pub struct PromptCacheBreakData {
3568 /// Request state whose cached prefix fell short
3569 #[doc(hidden)]
3570 #[serde(skip_serializing_if = "Option::is_none")]
3571 pub(crate) after_request: Option<serde_json::Value>,
3572 /// Name of the sub-agent whose conversation broke, stamped by the parent bridge
3573 #[doc(hidden)]
3574 #[serde(skip_serializing_if = "Option::is_none")]
3575 pub(crate) agent_name: Option<String>,
3576 /// Request state that established the prior cache frontier
3577 #[doc(hidden)]
3578 #[serde(skip_serializing_if = "Option::is_none")]
3579 pub(crate) before_request: Option<serde_json::Value>,
3580 /// Names of the cache-configuration fields that changed
3581 #[doc(hidden)]
3582 #[serde(skip_serializing_if = "Option::is_none")]
3583 pub(crate) cache_config_changed_fields: Option<Vec<String>>,
3584 /// All reasons that contributed to the cache break, ordered by precedence
3585 pub contributing_reasons: Vec<String>,
3586 /// Prior cached prompt frontier in tokens
3587 pub frontier_tokens: i64,
3588 /// Model that held the prior cache frontier, when the call changed models
3589 #[doc(hidden)]
3590 #[serde(skip_serializing_if = "Option::is_none")]
3591 pub(crate) model_from: Option<String>,
3592 /// Model this call targeted, when the call changed models
3593 #[doc(hidden)]
3594 #[serde(skip_serializing_if = "Option::is_none")]
3595 pub(crate) model_to: Option<String>,
3596 /// The highest-precedence reason for the cache break
3597 pub primary_reason: String,
3598 /// Fraction of the prior cache frontier that survived
3599 pub retention_ratio: f64,
3600 /// Index of the first conversation message whose content changed
3601 #[doc(hidden)]
3602 #[serde(skip_serializing_if = "Option::is_none")]
3603 pub(crate) rewrite_message_index: Option<i64>,
3604 /// Shape of the history rewrite, for example whether the history grew or shrank
3605 #[doc(hidden)]
3606 #[serde(skip_serializing_if = "Option::is_none")]
3607 pub(crate) rewrite_shape: Option<String>,
3608 /// Subsystems that announced a history rewrite before this call, for example compaction or truncation
3609 #[doc(hidden)]
3610 #[serde(skip_serializing_if = "Option::is_none")]
3611 pub(crate) rewrite_source: Option<Vec<String>>,
3612 /// Cached prefix tokens lost since the prior call
3613 pub shortfall_tokens: i64,
3614 /// Number of cached prefix tokens that survived
3615 pub survived_tokens: i64,
3616 /// Names of the system-prompt segments whose content changed
3617 #[doc(hidden)]
3618 #[serde(skip_serializing_if = "Option::is_none")]
3619 pub(crate) system_segments_changed: Option<Vec<String>>,
3620 /// Telemetry-safe names of tools added since the prior call
3621 #[doc(hidden)]
3622 #[serde(skip_serializing_if = "Option::is_none")]
3623 pub(crate) tools_added: Option<Vec<String>>,
3624 /// Raw names of tools added since the prior call, restricted because a tool name can be user-authored
3625 #[doc(hidden)]
3626 #[serde(skip_serializing_if = "Option::is_none")]
3627 pub(crate) tools_added_raw: Option<Vec<String>>,
3628 /// Telemetry-safe names of tools whose definition changed since the prior call
3629 #[doc(hidden)]
3630 #[serde(skip_serializing_if = "Option::is_none")]
3631 pub(crate) tools_redefined: Option<Vec<String>>,
3632 /// Raw names of tools redefined since the prior call, restricted because a tool name can be user-authored
3633 #[doc(hidden)]
3634 #[serde(skip_serializing_if = "Option::is_none")]
3635 pub(crate) tools_redefined_raw: Option<Vec<String>>,
3636 /// Telemetry-safe names of tools removed since the prior call
3637 #[doc(hidden)]
3638 #[serde(skip_serializing_if = "Option::is_none")]
3639 pub(crate) tools_removed: Option<Vec<String>>,
3640 /// Raw names of tools removed since the prior call, restricted because a tool name can be user-authored
3641 #[doc(hidden)]
3642 #[serde(skip_serializing_if = "Option::is_none")]
3643 pub(crate) tools_removed_raw: Option<Vec<String>>,
3644 /// Whether the tool list kept its members but changed their order
3645 #[doc(hidden)]
3646 #[serde(skip_serializing_if = "Option::is_none")]
3647 pub(crate) tools_reordered: Option<bool>,
3648}
3649
3650/// Content-free structural summary of the failing request for diagnosing malformed 4xx calls
3651#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3652#[serde(rename_all = "camelCase")]
3653pub struct ModelCallFailureRequestFingerprint {
3654 /// Total number of image content parts
3655 pub image_part_count: i64,
3656 /// Image parts whose media type cannot be determined (rejected by strict providers)
3657 pub image_parts_missing_media_type: i64,
3658 /// Role of the final message in the request
3659 #[serde(skip_serializing_if = "Option::is_none")]
3660 pub last_message_role: Option<String>,
3661 /// Total number of messages in the request
3662 pub message_count: i64,
3663 /// Tool calls whose name is missing or empty (rejected by strict providers)
3664 pub nameless_tool_call_count: i64,
3665 /// Total number of tool calls across assistant messages
3666 pub tool_call_count: i64,
3667 /// Number of "tool" result messages in the request
3668 pub tool_result_message_count: i64,
3669}
3670
3671/// Session event "model.call_failure". Failed LLM API call metadata for telemetry
3672#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3673#[serde(rename_all = "camelCase")]
3674pub struct ModelCallFailureData {
3675 /// Completion ID from the model provider (e.g., chatcmpl-abc123)
3676 #[serde(skip_serializing_if = "Option::is_none")]
3677 pub api_call_id: Option<String>,
3678 /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
3679 #[serde(skip_serializing_if = "Option::is_none")]
3680 pub api_endpoint: Option<AssistantUsageApiEndpoint>,
3681 /// 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.
3682 #[serde(skip_serializing_if = "Option::is_none")]
3683 pub bad_request_kind: Option<ModelCallFailureBadRequestKind>,
3684 /// Duration of the failed API call in milliseconds
3685 #[serde(skip_serializing_if = "Option::is_none")]
3686 pub duration_ms: Option<i64>,
3687 /// 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.
3688 #[serde(skip_serializing_if = "Option::is_none")]
3689 pub error_code: Option<String>,
3690 /// Raw provider/runtime error message for restricted telemetry
3691 #[serde(skip_serializing_if = "Option::is_none")]
3692 pub error_message: Option<String>,
3693 /// 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.
3694 #[serde(skip_serializing_if = "Option::is_none")]
3695 pub error_type: Option<String>,
3696 /// Whether the failure originated from an API response or the request transport
3697 #[serde(skip_serializing_if = "Option::is_none")]
3698 pub failure_kind: Option<ModelCallFailureKind>,
3699 /// Experimental HydraFusion attribution for this failed concrete model call.
3700 ///
3701 /// <div class="warning">
3702 ///
3703 /// **Experimental.** This type is part of an experimental wire-protocol surface
3704 /// and may change or be removed in future SDK or CLI releases.
3705 ///
3706 /// </div>
3707 #[serde(skip_serializing_if = "Option::is_none")]
3708 pub fusion: Option<FusionAttribution>,
3709 /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
3710 #[serde(skip_serializing_if = "Option::is_none")]
3711 pub initiator: Option<String>,
3712 /// 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.
3713 #[serde(skip_serializing_if = "Option::is_none")]
3714 pub interaction_type: Option<String>,
3715 /// Whether the session selected Auto mode for the failed call
3716 #[serde(skip_serializing_if = "Option::is_none")]
3717 pub is_auto: Option<bool>,
3718 /// Whether the failed call used a bring-your-own-key provider
3719 #[serde(skip_serializing_if = "Option::is_none")]
3720 pub is_byok: Option<bool>,
3721 /// Effective maximum output-token limit for the failed call
3722 #[serde(skip_serializing_if = "Option::is_none")]
3723 pub max_output_tokens: Option<i64>,
3724 /// Effective maximum prompt-token limit for the failed call
3725 #[serde(skip_serializing_if = "Option::is_none")]
3726 pub max_prompt_tokens: Option<i64>,
3727 /// Model identifier used for the failed API call
3728 #[serde(skip_serializing_if = "Option::is_none")]
3729 pub model: Option<String>,
3730 /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
3731 #[serde(skip_serializing_if = "Option::is_none")]
3732 pub provider_call_id: Option<String>,
3733 /// 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.
3734 #[doc(hidden)]
3735 #[serde(skip_serializing_if = "Option::is_none")]
3736 pub(crate) quota_snapshots: Option<HashMap<String, AssistantUsageQuotaSnapshot>>,
3737 /// Reasoning effort level used for the failed model call, if applicable
3738 #[serde(skip_serializing_if = "Option::is_none")]
3739 pub reasoning_effort: Option<String>,
3740 /// 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.
3741 #[serde(skip_serializing_if = "Option::is_none")]
3742 pub request_fingerprint: Option<ModelCallFailureRequestFingerprint>,
3743 /// 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.
3744 #[serde(skip_serializing_if = "Option::is_none")]
3745 pub rte: Option<bool>,
3746 /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
3747 #[serde(skip_serializing_if = "Option::is_none")]
3748 pub service_request_id: Option<String>,
3749 /// Where the failed model call originated
3750 pub source: ModelCallFailureSource,
3751 /// HTTP status code from the failed request
3752 #[serde(skip_serializing_if = "Option::is_none")]
3753 pub status_code: Option<i32>,
3754 /// Transport used for the failed model call (http or websocket)
3755 #[serde(skip_serializing_if = "Option::is_none")]
3756 pub transport: Option<ModelCallFailureTransport>,
3757}
3758
3759/// 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.
3760#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3761#[serde(rename_all = "camelCase")]
3762pub struct ModelCallFinishedData {
3763 /// 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.
3764 #[serde(skip_serializing_if = "Option::is_none")]
3765 pub contains_built_in_file_edit_request: Option<bool>,
3766 /// 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
3767 pub dispatch_duration_ms: f64,
3768 /// Version of the built-in file-edit semantic classifier used for this event
3769 pub edit_classifier_version: i64,
3770 /// Identifier of the user interaction that owns the model dispatch, matching assistant.turn_start.interactionId when available
3771 #[serde(skip_serializing_if = "Option::is_none")]
3772 pub interaction_id: Option<String>,
3773 /// Final outcome after post-response acceptance processing
3774 pub outcome: ModelCallFinishedOutcome,
3775 /// Agent-loop iteration within the interaction that initiated the model dispatch
3776 pub turn_id: String,
3777}
3778
3779/// Session event "model.call_start". Model API dispatch metadata for internal telemetry
3780#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3781#[serde(rename_all = "camelCase")]
3782pub struct ModelCallStartData {
3783 /// Experimental HydraFusion attribution for this concrete model call.
3784 ///
3785 /// <div class="warning">
3786 ///
3787 /// **Experimental.** This type is part of an experimental wire-protocol surface
3788 /// and may change or be removed in future SDK or CLI releases.
3789 ///
3790 /// </div>
3791 #[serde(skip_serializing_if = "Option::is_none")]
3792 pub fusion: Option<FusionAttribution>,
3793 /// Model identifier used for this API call, when known
3794 #[serde(skip_serializing_if = "Option::is_none")]
3795 pub model: Option<String>,
3796 /// Previous response or interaction identifier included in the model request, when present
3797 #[doc(hidden)]
3798 #[serde(skip_serializing_if = "Option::is_none")]
3799 pub(crate) previous_response_id: Option<String>,
3800 /// Identifier of the assistant turn that initiated the model call
3801 pub turn_id: String,
3802}
3803
3804/// Session event "abort". Turn abort information including the reason for termination
3805#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3806#[serde(rename_all = "camelCase")]
3807pub struct AbortData {
3808 /// Finite reason code describing why the current turn was aborted
3809 pub reason: AbortReason,
3810}
3811
3812/// Session event "tool.user_requested". User-initiated tool invocation request with tool name and arguments
3813#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3814#[serde(rename_all = "camelCase")]
3815pub struct ToolUserRequestedData {
3816 /// Arguments for the tool invocation
3817 #[serde(skip_serializing_if = "Option::is_none")]
3818 pub arguments: Option<serde_json::Value>,
3819 /// Unique identifier for this tool call
3820 pub tool_call_id: String,
3821 /// Name of the tool the user wants to invoke
3822 pub tool_name: String,
3823}
3824
3825/// 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.
3826#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3827#[serde(rename_all = "camelCase")]
3828pub struct ToolExecutionStartShellToolInfo {
3829 /// 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.
3830 ///
3831 /// <div class="warning">
3832 ///
3833 /// **Experimental.** This type is part of an experimental wire-protocol surface
3834 /// and may change or be removed in future SDK or CLI releases.
3835 ///
3836 /// </div>
3837 #[serde(skip_serializing_if = "Option::is_none")]
3838 pub display_command: Option<String>,
3839 /// Whether the command includes a file write redirection (e.g., > or >>).
3840 pub has_write_file_redirection: bool,
3841 /// 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.
3842 pub possible_paths: Vec<String>,
3843}
3844
3845/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
3846#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3847#[serde(rename_all = "camelCase")]
3848pub struct ToolExecutionStartToolDescriptionMetaUI {
3849 /// URI of the UI resource
3850 #[serde(skip_serializing_if = "Option::is_none")]
3851 pub resource_uri: Option<String>,
3852 /// Who can access this tool
3853 #[serde(skip_serializing_if = "Option::is_none")]
3854 pub visibility: Option<Vec<ToolExecutionStartToolDescriptionMetaUIVisibility>>,
3855}
3856
3857/// MCP Apps metadata for UI resource association
3858#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3859#[serde(rename_all = "camelCase")]
3860pub struct ToolExecutionStartToolDescriptionMeta {
3861 /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_start`.
3862 #[serde(skip_serializing_if = "Option::is_none")]
3863 pub ui: Option<ToolExecutionStartToolDescriptionMetaUI>,
3864}
3865
3866/// Tool definition metadata, present for MCP tools with MCP Apps support
3867#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3868#[serde(rename_all = "camelCase")]
3869pub struct ToolExecutionStartToolDescription {
3870 /// MCP Apps metadata for UI resource association
3871 #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
3872 pub meta: Option<ToolExecutionStartToolDescriptionMeta>,
3873 /// Tool description
3874 #[serde(skip_serializing_if = "Option::is_none")]
3875 pub description: Option<String>,
3876 /// Tool name
3877 pub name: String,
3878}
3879
3880/// Session event "tool.execution_start". Tool execution startup details including MCP server information when applicable
3881#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3882#[serde(rename_all = "camelCase")]
3883pub struct ToolExecutionStartData {
3884 /// Arguments passed to the tool
3885 #[serde(skip_serializing_if = "Option::is_none")]
3886 pub arguments: Option<serde_json::Value>,
3887 /// When true, the tool output should be displayed expanded (verbatim) in the CLI timeline
3888 #[serde(skip_serializing_if = "Option::is_none")]
3889 pub display_verbatim: Option<bool>,
3890 /// Experimental HydraFusion attribution for this tool execution.
3891 ///
3892 /// <div class="warning">
3893 ///
3894 /// **Experimental.** This type is part of an experimental wire-protocol surface
3895 /// and may change or be removed in future SDK or CLI releases.
3896 ///
3897 /// </div>
3898 #[serde(skip_serializing_if = "Option::is_none")]
3899 pub fusion: Option<FusionAttribution>,
3900 /// 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.
3901 #[serde(skip_serializing_if = "Option::is_none")]
3902 pub mcp_config_server_name: Option<String>,
3903 /// 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
3904 #[serde(skip_serializing_if = "Option::is_none")]
3905 pub mcp_config_source: Option<McpServerSource>,
3906 /// Name of the MCP server hosting this tool, when the tool is an MCP tool
3907 #[serde(skip_serializing_if = "Option::is_none")]
3908 pub mcp_server_name: Option<String>,
3909 /// Original tool name on the MCP server, when the tool is an MCP tool
3910 #[serde(skip_serializing_if = "Option::is_none")]
3911 pub mcp_tool_name: Option<String>,
3912 /// Transport the MCP server hosting this tool is connected over, when the tool is an MCP tool and the server is configured
3913 #[serde(skip_serializing_if = "Option::is_none")]
3914 pub mcp_transport: Option<McpServerTransport>,
3915 /// Model identifier that generated this tool call
3916 #[serde(skip_serializing_if = "Option::is_none")]
3917 pub model: Option<String>,
3918 /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
3919 #[doc(hidden)]
3920 #[deprecated]
3921 #[serde(skip_serializing_if = "Option::is_none")]
3922 pub parent_tool_call_id: Option<String>,
3923 /// 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.
3924 #[serde(skip_serializing_if = "Option::is_none")]
3925 pub rte: Option<bool>,
3926 /// 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.
3927 #[serde(skip_serializing_if = "Option::is_none")]
3928 pub shell_tool_info: Option<ToolExecutionStartShellToolInfo>,
3929 /// Unique identifier for this tool call
3930 pub tool_call_id: String,
3931 /// Tool definition metadata, present for MCP tools with MCP Apps support
3932 #[serde(skip_serializing_if = "Option::is_none")]
3933 pub tool_description: Option<ToolExecutionStartToolDescription>,
3934 /// Name of the tool being executed
3935 pub tool_name: String,
3936 /// Human-readable display title for the tool, when the selected tool descriptor has a non-empty title.
3937 #[serde(skip_serializing_if = "Option::is_none")]
3938 pub tool_title: Option<String>,
3939 /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
3940 #[serde(skip_serializing_if = "Option::is_none")]
3941 pub turn_id: Option<String>,
3942}
3943
3944/// Session event "tool.execution_partial_result". Streaming tool execution output for incremental result display
3945#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3946#[serde(rename_all = "camelCase")]
3947pub struct ToolExecutionPartialResultData {
3948 /// Incremental output chunk from the running tool
3949 pub partial_output: String,
3950 /// Tool call ID this partial result belongs to
3951 pub tool_call_id: String,
3952}
3953
3954/// Session event "tool.execution_progress". Tool execution progress notification with status message
3955#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3956#[serde(rename_all = "camelCase")]
3957pub struct ToolExecutionProgressData {
3958 /// Human-readable progress status message (e.g., from an MCP server)
3959 pub progress_message: String,
3960 /// Tool call ID this progress notification belongs to
3961 pub tool_call_id: String,
3962}
3963
3964/// Error details when the tool execution failed
3965#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3966#[serde(rename_all = "camelCase")]
3967pub struct ToolExecutionCompleteError {
3968 /// Machine-readable error code
3969 #[serde(skip_serializing_if = "Option::is_none")]
3970 pub code: Option<String>,
3971 /// Human-readable error message
3972 pub message: String,
3973 /// 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.
3974 #[serde(skip_serializing_if = "Option::is_none")]
3975 pub remediation: Option<RemediationAction>,
3976}
3977
3978/// Binary result returned by a tool for the model
3979#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3980#[serde(rename_all = "camelCase")]
3981pub struct PersistedBinaryImage {
3982 /// Base64-encoded binary data
3983 pub data: String,
3984 /// Human-readable description of the binary data
3985 #[serde(skip_serializing_if = "Option::is_none")]
3986 pub description: Option<String>,
3987 /// Optional metadata from the producing tool.
3988 #[serde(skip_serializing_if = "Option::is_none")]
3989 pub metadata: Option<HashMap<String, serde_json::Value>>,
3990 /// MIME type of the binary data
3991 pub mime_type: String,
3992 /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
3993 pub r#type: PersistedBinaryImageType,
3994}
3995
3996/// A binary result whose data was omitted from persistence due to the inline size limit
3997///
3998/// <div class="warning">
3999///
4000/// **Experimental.** This type is part of an experimental wire-protocol surface
4001/// and may change or be removed in future SDK or CLI releases.
4002///
4003/// </div>
4004#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4005#[serde(rename_all = "camelCase")]
4006pub struct OmittedBinaryResult {
4007 /// Decoded byte length of the omitted binary data
4008 pub byte_length: i64,
4009 /// Human-readable description of the binary data
4010 #[serde(skip_serializing_if = "Option::is_none")]
4011 pub description: Option<String>,
4012 /// Optional metadata from the producing tool.
4013 #[serde(skip_serializing_if = "Option::is_none")]
4014 pub metadata: Option<HashMap<String, serde_json::Value>>,
4015 /// MIME type of the omitted binary data
4016 pub mime_type: String,
4017 /// Why the binary data is absent: it exceeded the inline size limit, or its asset was unavailable
4018 pub omitted_reason: OmittedBinaryOmittedReason,
4019 /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
4020 pub r#type: OmittedBinaryType,
4021}
4022
4023/// A reference to binary data persisted once on a session.binary_asset event and shared by id
4024///
4025/// <div class="warning">
4026///
4027/// **Experimental.** This type is part of an experimental wire-protocol surface
4028/// and may change or be removed in future SDK or CLI releases.
4029///
4030/// </div>
4031#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4032#[serde(rename_all = "camelCase")]
4033pub struct BinaryAssetReference {
4034 /// Content-addressed id of the session.binary_asset event that holds this binary's bytes (e.g. "sha256:...").
4035 pub asset_id: String,
4036 /// Decoded byte length of the referenced binary data
4037 pub byte_length: i64,
4038 /// Human-readable description of the binary data
4039 #[serde(skip_serializing_if = "Option::is_none")]
4040 pub description: Option<String>,
4041 /// Optional metadata from the producing tool.
4042 #[serde(skip_serializing_if = "Option::is_none")]
4043 pub metadata: Option<HashMap<String, serde_json::Value>>,
4044 /// MIME type of the referenced binary data
4045 pub mime_type: String,
4046 /// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
4047 pub r#type: BinaryAssetReferenceType,
4048}
4049
4050/// A source supplied by a tool that should be made available to the model as citable content.
4051///
4052/// <div class="warning">
4053///
4054/// **Experimental.** This type is part of an experimental wire-protocol surface
4055/// and may change or be removed in future SDK or CLI releases.
4056///
4057/// </div>
4058#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4059#[serde(rename_all = "camelCase")]
4060pub struct CitableSource {
4061 /// The source text made available to the model as citable content.
4062 pub content: String,
4063 /// 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.
4064 pub id: String,
4065 /// File path relative to the agent's workspace root, when the source is a file.
4066 #[serde(skip_serializing_if = "Option::is_none")]
4067 pub path: Option<String>,
4068 /// Human-readable title of the source.
4069 #[serde(skip_serializing_if = "Option::is_none")]
4070 pub title: Option<String>,
4071 /// URL of the source, when it is a web resource.
4072 #[serde(skip_serializing_if = "Option::is_none")]
4073 pub url: Option<String>,
4074}
4075
4076/// Plain text content block
4077#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4078#[serde(rename_all = "camelCase")]
4079pub struct ToolExecutionCompleteContentText {
4080 /// The text content
4081 pub text: String,
4082 /// Content block type discriminator
4083 pub r#type: ToolExecutionCompleteContentTextType,
4084}
4085
4086/// Deprecated for shell command exit metadata. Use ToolExecutionCompleteContentShellExit instead.
4087#[doc(hidden)]
4088#[deprecated]
4089#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4090#[serde(rename_all = "camelCase")]
4091pub struct ToolExecutionCompleteContentTerminal {
4092 /// Working directory where the command was executed
4093 #[serde(skip_serializing_if = "Option::is_none")]
4094 pub cwd: Option<String>,
4095 /// Process exit code, if the command has completed
4096 #[serde(skip_serializing_if = "Option::is_none")]
4097 pub exit_code: Option<i64>,
4098 /// Terminal/shell output text
4099 pub text: String,
4100 /// Content block type discriminator
4101 pub r#type: ToolExecutionCompleteContentTerminalType,
4102}
4103
4104/// Shell command exit metadata with optional output preview
4105#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4106#[serde(rename_all = "camelCase")]
4107pub struct ToolExecutionCompleteContentShellExit {
4108 /// Working directory where the shell command was executed
4109 #[serde(skip_serializing_if = "Option::is_none")]
4110 pub cwd: Option<String>,
4111 /// Exit code from the completed shell command
4112 pub exit_code: i64,
4113 /// Path reported in the shell session's filesystem namespace when shell output exceeded the configured large-output threshold.
4114 #[serde(skip_serializing_if = "Option::is_none")]
4115 pub output_file_path: Option<String>,
4116 /// Output associated with this shell command, if available. May be partial, truncated, or a preview; not guaranteed to be full output.
4117 #[serde(skip_serializing_if = "Option::is_none")]
4118 pub output_preview: Option<String>,
4119 /// Whether outputPreview is known to be incomplete or truncated
4120 #[serde(skip_serializing_if = "Option::is_none")]
4121 pub output_truncated: Option<bool>,
4122 /// Shell id, as assigned by Copilot runtime
4123 pub shell_id: String,
4124 /// Content block type discriminator
4125 pub r#type: ToolExecutionCompleteContentShellExitType,
4126}
4127
4128/// Image content block with base64-encoded data
4129#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4130#[serde(rename_all = "camelCase")]
4131pub struct ToolExecutionCompleteContentImage {
4132 /// Base64-encoded image data
4133 pub data: String,
4134 /// MIME type of the image (e.g., image/png, image/jpeg)
4135 pub mime_type: String,
4136 /// Content block type discriminator
4137 pub r#type: ToolExecutionCompleteContentImageType,
4138}
4139
4140/// Audio content block with base64-encoded data
4141#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4142#[serde(rename_all = "camelCase")]
4143pub struct ToolExecutionCompleteContentAudio {
4144 /// Base64-encoded audio data
4145 pub data: String,
4146 /// MIME type of the audio (e.g., audio/wav, audio/mpeg)
4147 pub mime_type: String,
4148 /// Content block type discriminator
4149 pub r#type: ToolExecutionCompleteContentAudioType,
4150}
4151
4152/// Icon image for a resource
4153#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4154#[serde(rename_all = "camelCase")]
4155pub struct ToolExecutionCompleteContentResourceLinkIcon {
4156 /// MIME type of the icon image
4157 #[serde(skip_serializing_if = "Option::is_none")]
4158 pub mime_type: Option<String>,
4159 /// Available icon sizes (e.g., ['16x16', '32x32'])
4160 #[serde(skip_serializing_if = "Option::is_none")]
4161 pub sizes: Option<Vec<String>>,
4162 /// URL or path to the icon image
4163 pub src: String,
4164 /// Theme variant this icon is intended for
4165 #[serde(skip_serializing_if = "Option::is_none")]
4166 pub theme: Option<ToolExecutionCompleteContentResourceLinkIconTheme>,
4167}
4168
4169/// Resource link content block referencing an external resource
4170#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4171#[serde(rename_all = "camelCase")]
4172pub struct ToolExecutionCompleteContentResourceLink {
4173 /// Human-readable description of the resource
4174 #[serde(skip_serializing_if = "Option::is_none")]
4175 pub description: Option<String>,
4176 /// Icons associated with this resource
4177 #[serde(skip_serializing_if = "Option::is_none")]
4178 pub icons: Option<Vec<ToolExecutionCompleteContentResourceLinkIcon>>,
4179 /// MIME type of the resource content
4180 #[serde(skip_serializing_if = "Option::is_none")]
4181 pub mime_type: Option<String>,
4182 /// Resource name identifier
4183 pub name: String,
4184 /// Size of the resource in bytes
4185 #[serde(skip_serializing_if = "Option::is_none")]
4186 pub size: Option<i64>,
4187 /// Human-readable display title for the resource
4188 #[serde(skip_serializing_if = "Option::is_none")]
4189 pub title: Option<String>,
4190 /// Content block type discriminator
4191 pub r#type: ToolExecutionCompleteContentResourceLinkType,
4192 /// URI identifying the resource
4193 pub uri: String,
4194}
4195
4196/// Embedded text resource contents identified by a URI, with an optional MIME type and a text payload.
4197#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4198#[serde(rename_all = "camelCase")]
4199pub struct EmbeddedTextResourceContents {
4200 /// MIME type of the text content
4201 #[serde(skip_serializing_if = "Option::is_none")]
4202 pub mime_type: Option<String>,
4203 /// Text content of the resource
4204 pub text: String,
4205 /// URI identifying the resource
4206 pub uri: String,
4207}
4208
4209/// Embedded binary resource contents identified by a URI, with an optional MIME type and a base64-encoded blob.
4210#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4211#[serde(rename_all = "camelCase")]
4212pub struct EmbeddedBlobResourceContents {
4213 /// Base64-encoded binary content of the resource
4214 pub blob: String,
4215 /// MIME type of the blob content
4216 #[serde(skip_serializing_if = "Option::is_none")]
4217 pub mime_type: Option<String>,
4218 /// URI identifying the resource
4219 pub uri: String,
4220}
4221
4222/// Embedded resource content block with inline text or binary data
4223#[derive(Debug, Clone, Serialize, Deserialize)]
4224#[serde(rename_all = "camelCase")]
4225pub struct ToolExecutionCompleteContentResource {
4226 /// The embedded resource contents, either text or base64-encoded binary
4227 pub resource: ToolExecutionCompleteContentResourceDetails,
4228 /// Content block type discriminator
4229 pub r#type: ToolExecutionCompleteContentResourceType,
4230}
4231
4232/// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
4233#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4234#[serde(rename_all = "camelCase")]
4235pub struct ToolExecutionCompleteUIResourceMetaUICsp {
4236 /// Domains the UI resource may use as document base URIs.
4237 #[serde(skip_serializing_if = "Option::is_none")]
4238 pub base_uri_domains: Option<Vec<String>>,
4239 /// Domains the UI resource may connect to.
4240 #[serde(skip_serializing_if = "Option::is_none")]
4241 pub connect_domains: Option<Vec<String>>,
4242 /// Domains the UI resource may embed as nested frames.
4243 #[serde(skip_serializing_if = "Option::is_none")]
4244 pub frame_domains: Option<Vec<String>>,
4245 /// Domains from which the UI resource may load scripts, styles, images, and other resources.
4246 #[serde(skip_serializing_if = "Option::is_none")]
4247 pub resource_domains: Option<Vec<String>>,
4248}
4249
4250/// Marker object for camera permission on an MCP Apps UI resource.
4251#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4252#[serde(rename_all = "camelCase")]
4253pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsCamera {}
4254
4255/// Marker object for clipboard-write permission on an MCP Apps UI resource.
4256#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4257#[serde(rename_all = "camelCase")]
4258pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite {}
4259
4260/// Marker object for geolocation permission on an MCP Apps UI resource.
4261#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4262#[serde(rename_all = "camelCase")]
4263pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation {}
4264
4265/// Marker object for microphone permission on an MCP Apps UI resource.
4266#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4267#[serde(rename_all = "camelCase")]
4268pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone {}
4269
4270/// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
4271#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4272#[serde(rename_all = "camelCase")]
4273pub struct ToolExecutionCompleteUIResourceMetaUIPermissions {
4274 /// Marker object for camera permission on an MCP Apps UI resource.
4275 #[serde(skip_serializing_if = "Option::is_none")]
4276 pub camera: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsCamera>,
4277 /// Marker object for clipboard-write permission on an MCP Apps UI resource.
4278 #[serde(skip_serializing_if = "Option::is_none")]
4279 pub clipboard_write: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite>,
4280 /// Marker object for geolocation permission on an MCP Apps UI resource.
4281 #[serde(skip_serializing_if = "Option::is_none")]
4282 pub geolocation: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation>,
4283 /// Marker object for microphone permission on an MCP Apps UI resource.
4284 #[serde(skip_serializing_if = "Option::is_none")]
4285 pub microphone: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone>,
4286}
4287
4288/// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
4289#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4290#[serde(rename_all = "camelCase")]
4291pub struct ToolExecutionCompleteUIResourceMetaUI {
4292 /// CSP domain allowlists for an MCP Apps UI resource, including connect, resource, frame, and base URI domains.
4293 #[serde(skip_serializing_if = "Option::is_none")]
4294 pub csp: Option<ToolExecutionCompleteUIResourceMetaUICsp>,
4295 /// Optional dedicated origin for the rendered MCP Apps UI resource.
4296 #[serde(skip_serializing_if = "Option::is_none")]
4297 pub domain: Option<String>,
4298 /// Browser permission metadata for an MCP Apps UI resource, including camera, microphone, geolocation, and clipboard-write.
4299 #[serde(skip_serializing_if = "Option::is_none")]
4300 pub permissions: Option<ToolExecutionCompleteUIResourceMetaUIPermissions>,
4301 /// Whether the host should render a border around the MCP Apps UI resource.
4302 #[serde(skip_serializing_if = "Option::is_none")]
4303 pub prefers_border: Option<bool>,
4304}
4305
4306/// Resource-level UI metadata (CSP, permissions, visual preferences)
4307#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4308#[serde(rename_all = "camelCase")]
4309pub struct ToolExecutionCompleteUIResourceMeta {
4310 /// MCP Apps UI resource metadata for a completed tool result, including CSP, permissions, domain, and border preference.
4311 #[serde(skip_serializing_if = "Option::is_none")]
4312 pub ui: Option<ToolExecutionCompleteUIResourceMetaUI>,
4313}
4314
4315/// MCP Apps UI resource content for rendering in a sandboxed iframe
4316#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4317#[serde(rename_all = "camelCase")]
4318pub struct ToolExecutionCompleteUIResource {
4319 /// Resource-level UI metadata (CSP, permissions, visual preferences)
4320 #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
4321 pub meta: Option<ToolExecutionCompleteUIResourceMeta>,
4322 /// Base64-encoded HTML content
4323 #[serde(skip_serializing_if = "Option::is_none")]
4324 pub blob: Option<String>,
4325 /// MIME type of the content
4326 pub mime_type: String,
4327 /// HTML content as a string
4328 #[serde(skip_serializing_if = "Option::is_none")]
4329 pub text: Option<String>,
4330 /// The ui:// URI of the resource
4331 pub uri: String,
4332}
4333
4334/// Tool execution result on success
4335#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4336#[serde(rename_all = "camelCase")]
4337pub struct ToolExecutionCompleteResult {
4338 /// Model-facing binary results (base64 inline or size-omitted markers) sent to the LLM for this tool call
4339 ///
4340 /// <div class="warning">
4341 ///
4342 /// **Experimental.** This type is part of an experimental wire-protocol surface
4343 /// and may change or be removed in future SDK or CLI releases.
4344 ///
4345 /// </div>
4346 #[serde(skip_serializing_if = "Option::is_none")]
4347 pub binary_results_for_llm: Option<Vec<PersistedBinaryResult>>,
4348 /// Provider-neutral source material this tool makes available to the model as citable content. Persisted so it survives session resume. Experimental.
4349 ///
4350 /// <div class="warning">
4351 ///
4352 /// **Experimental.** This type is part of an experimental wire-protocol surface
4353 /// and may change or be removed in future SDK or CLI releases.
4354 ///
4355 /// </div>
4356 #[serde(skip_serializing_if = "Option::is_none")]
4357 pub citable_sources: Option<Vec<CitableSource>>,
4358 /// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency
4359 pub content: String,
4360 /// Structured content blocks (text, images, audio, resources) returned by the tool in their native format
4361 #[serde(skip_serializing_if = "Option::is_none")]
4362 pub contents: Option<Vec<ToolExecutionCompleteContent>>,
4363 /// 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.
4364 #[serde(skip_serializing_if = "Option::is_none")]
4365 pub detailed_content: Option<String>,
4366 /// 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.
4367 ///
4368 /// <div class="warning">
4369 ///
4370 /// **Experimental.** This type is part of an experimental wire-protocol surface
4371 /// and may change or be removed in future SDK or CLI releases.
4372 ///
4373 /// </div>
4374 #[serde(skip_serializing_if = "Option::is_none")]
4375 pub mcp_meta: Option<serde_json::Value>,
4376 /// Structured content (arbitrary JSON) returned verbatim by the MCP tool
4377 #[serde(skip_serializing_if = "Option::is_none")]
4378 pub structured_content: Option<serde_json::Value>,
4379 /// MCP Apps UI resource content for rendering in a sandboxed iframe
4380 #[serde(skip_serializing_if = "Option::is_none")]
4381 pub ui_resource: Option<ToolExecutionCompleteUIResource>,
4382}
4383
4384/// Experimental shell completion facts retained independently of the full tool result.
4385///
4386/// <div class="warning">
4387///
4388/// **Experimental.** This type is part of an experimental wire-protocol surface
4389/// and may change or be removed in future SDK or CLI releases.
4390///
4391/// </div>
4392#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4393#[serde(rename_all = "camelCase")]
4394pub struct ToolExecutionCompleteShellExecution {
4395 /// Process exit code reported by the shell driver.
4396 pub exit_code: i64,
4397}
4398
4399/// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
4400#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4401#[serde(rename_all = "camelCase")]
4402pub struct ToolExecutionCompleteToolDescriptionMetaUI {
4403 /// URI of the UI resource
4404 #[serde(skip_serializing_if = "Option::is_none")]
4405 pub resource_uri: Option<String>,
4406 /// Who can access this tool
4407 #[serde(skip_serializing_if = "Option::is_none")]
4408 pub visibility: Option<Vec<ToolExecutionCompleteToolDescriptionMetaUIVisibility>>,
4409}
4410
4411/// MCP Apps metadata for UI resource association
4412#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4413#[serde(rename_all = "camelCase")]
4414pub struct ToolExecutionCompleteToolDescriptionMeta {
4415 /// MCP Apps tool `_meta.ui` resource URI and visibility captured on `tool.execution_complete`.
4416 #[serde(skip_serializing_if = "Option::is_none")]
4417 pub ui: Option<ToolExecutionCompleteToolDescriptionMetaUI>,
4418}
4419
4420/// Tool definition metadata, present for MCP tools with MCP Apps support
4421#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4422#[serde(rename_all = "camelCase")]
4423pub struct ToolExecutionCompleteToolDescription {
4424 /// MCP Apps metadata for UI resource association
4425 #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
4426 pub meta: Option<ToolExecutionCompleteToolDescriptionMeta>,
4427 /// Tool description
4428 #[serde(skip_serializing_if = "Option::is_none")]
4429 pub description: Option<String>,
4430 /// Tool name
4431 pub name: String,
4432}
4433
4434/// Session event "tool.execution_complete". Tool execution completion results including success status, detailed output, and error information
4435#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4436#[serde(rename_all = "camelCase")]
4437pub struct ToolExecutionCompleteData {
4438 /// Error details when the tool execution failed
4439 #[serde(skip_serializing_if = "Option::is_none")]
4440 pub error: Option<ToolExecutionCompleteError>,
4441 /// Experimental HydraFusion attribution for this tool completion.
4442 ///
4443 /// <div class="warning">
4444 ///
4445 /// **Experimental.** This type is part of an experimental wire-protocol surface
4446 /// and may change or be removed in future SDK or CLI releases.
4447 ///
4448 /// </div>
4449 #[serde(skip_serializing_if = "Option::is_none")]
4450 pub fusion: Option<FusionAttribution>,
4451 /// CAPI interaction ID for correlating this tool execution with upstream telemetry
4452 #[serde(skip_serializing_if = "Option::is_none")]
4453 pub interaction_id: Option<String>,
4454 /// Whether this tool call was explicitly requested by the user rather than the assistant
4455 #[serde(skip_serializing_if = "Option::is_none")]
4456 pub is_user_requested: Option<bool>,
4457 /// 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.
4458 ///
4459 /// <div class="warning">
4460 ///
4461 /// **Experimental.** This type is part of an experimental wire-protocol surface
4462 /// and may change or be removed in future SDK or CLI releases.
4463 ///
4464 /// </div>
4465 #[serde(skip_serializing_if = "Option::is_none")]
4466 pub mcp_meta: Option<serde_json::Value>,
4467 /// Model identifier that generated this tool call
4468 #[serde(skip_serializing_if = "Option::is_none")]
4469 pub model: Option<String>,
4470 /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
4471 #[doc(hidden)]
4472 #[deprecated]
4473 #[serde(skip_serializing_if = "Option::is_none")]
4474 pub parent_tool_call_id: Option<String>,
4475 /// Tool execution result on success
4476 #[serde(skip_serializing_if = "Option::is_none")]
4477 pub result: Option<ToolExecutionCompleteResult>,
4478 /// 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.
4479 #[serde(skip_serializing_if = "Option::is_none")]
4480 pub rte: Option<bool>,
4481 /// Whether this tool execution ran inside a sandbox container
4482 #[serde(skip_serializing_if = "Option::is_none")]
4483 pub sandboxed: Option<bool>,
4484 /// Experimental shell completion facts captured before the persisted result contents are stripped.
4485 ///
4486 /// <div class="warning">
4487 ///
4488 /// **Experimental.** This type is part of an experimental wire-protocol surface
4489 /// and may change or be removed in future SDK or CLI releases.
4490 ///
4491 /// </div>
4492 #[serde(skip_serializing_if = "Option::is_none")]
4493 pub shell_execution: Option<ToolExecutionCompleteShellExecution>,
4494 /// Whether the tool execution completed successfully
4495 pub success: bool,
4496 /// Unique identifier for the completed tool call
4497 pub tool_call_id: String,
4498 /// Tool definition metadata, present for MCP tools with MCP Apps support
4499 #[serde(skip_serializing_if = "Option::is_none")]
4500 pub tool_description: Option<ToolExecutionCompleteToolDescription>,
4501 /// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
4502 #[serde(skip_serializing_if = "Option::is_none")]
4503 pub tool_telemetry: Option<HashMap<String, serde_json::Value>>,
4504 /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
4505 #[serde(skip_serializing_if = "Option::is_none")]
4506 pub turn_id: Option<String>,
4507}
4508
4509/// Session event "tool_search.activated". Persisted generic client-side tool activations restored when a session resumes.
4510#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4511#[serde(rename_all = "camelCase")]
4512pub struct ToolSearchActivatedData {
4513 /// Tool-search strategy that activated the definitions.
4514 pub strategy: String,
4515 /// Names of tool definitions activated by this search invocation.
4516 pub tool_names: Vec<String>,
4517}
4518
4519/// Session event "skill.invoked". Skill invocation details including content, allowed tools, and plugin metadata
4520#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4521#[serde(rename_all = "camelCase")]
4522pub struct SkillInvokedData {
4523 /// Tool names that should be auto-approved when this skill is active
4524 #[serde(skip_serializing_if = "Option::is_none")]
4525 pub allowed_tools: Option<Vec<String>>,
4526 /// Full content of the skill file, injected into the conversation for the model
4527 pub content: String,
4528 /// Description of the skill from its SKILL.md frontmatter
4529 #[serde(skip_serializing_if = "Option::is_none")]
4530 pub description: Option<String>,
4531 /// Whether model invocation is disabled for this skill
4532 #[serde(skip_serializing_if = "Option::is_none")]
4533 pub disable_model_invocation: Option<bool>,
4534 /// Projected chat-message count when the skill was invoked. New writers persist this so replay does not need to reconstruct superseded history; readers derive it for legacy events when absent.
4535 #[serde(skip_serializing_if = "Option::is_none")]
4536 pub invoked_at_turn: Option<i64>,
4537 /// Model identifier active when the skill was invoked, when known
4538 #[serde(skip_serializing_if = "Option::is_none")]
4539 pub model: Option<String>,
4540 /// Name of the invoked skill
4541 pub name: String,
4542 /// File path to the SKILL.md definition, or an empty string for an SDK-provided skill without a filesystem identity
4543 pub path: String,
4544 /// Name of the plugin this skill originated from, when applicable
4545 #[serde(skip_serializing_if = "Option::is_none")]
4546 pub plugin_name: Option<String>,
4547 /// Version of the plugin this skill originated from, when applicable
4548 #[serde(skip_serializing_if = "Option::is_none")]
4549 pub plugin_version: Option<String>,
4550 /// 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)
4551 #[serde(skip_serializing_if = "Option::is_none")]
4552 pub source: Option<String>,
4553 /// 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)
4554 #[serde(skip_serializing_if = "Option::is_none")]
4555 pub trigger: Option<SkillInvokedTrigger>,
4556}
4557
4558/// Session event "skill.invoked_ref". Internal durable skill invocation receipt whose content resolves from an earlier inline skill event in the same session.
4559#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4560#[serde(rename_all = "camelCase")]
4561pub struct SkillInvokedRefData {
4562 /// Tool names that should be auto-approved when this skill is active
4563 #[serde(skip_serializing_if = "Option::is_none")]
4564 pub allowed_tools: Option<Vec<String>>,
4565 /// 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`
4566 pub content_id: String,
4567 /// 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
4568 pub content_length: i64,
4569 /// Description of the skill from its SKILL.md frontmatter
4570 #[serde(skip_serializing_if = "Option::is_none")]
4571 pub description: Option<String>,
4572 /// Whether model invocation is disabled for this skill
4573 #[serde(skip_serializing_if = "Option::is_none")]
4574 pub disable_model_invocation: Option<bool>,
4575 /// Projected chat-message count when the skill was invoked. Preserved from the inline event data when the authored body is deduplicated.
4576 #[serde(skip_serializing_if = "Option::is_none")]
4577 pub invoked_at_turn: Option<i64>,
4578 /// Model identifier active when the skill was invoked, when known
4579 #[serde(skip_serializing_if = "Option::is_none")]
4580 pub model: Option<String>,
4581 /// Name of the invoked skill
4582 pub name: String,
4583 /// File path to the SKILL.md definition, or an empty string for an SDK-provided skill without a filesystem identity
4584 pub path: String,
4585 /// Name of the plugin this skill originated from, when applicable
4586 #[serde(skip_serializing_if = "Option::is_none")]
4587 pub plugin_name: Option<String>,
4588 /// Version of the plugin this skill originated from, when applicable
4589 #[serde(skip_serializing_if = "Option::is_none")]
4590 pub plugin_version: Option<String>,
4591 /// Source identifier for where the skill was discovered
4592 #[serde(skip_serializing_if = "Option::is_none")]
4593 pub source: Option<String>,
4594 /// What triggered the skill invocation
4595 #[serde(skip_serializing_if = "Option::is_none")]
4596 pub trigger: Option<SkillInvokedTrigger>,
4597}
4598
4599/// 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.
4600#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4601#[serde(rename_all = "camelCase")]
4602pub struct SkillContextDeliveredData {
4603 /// Exact model-facing skill wrapper, including its invocation-time file context
4604 pub content: String,
4605 /// Interaction that delivered this context, when known
4606 #[serde(skip_serializing_if = "Option::is_none")]
4607 pub interaction_id: Option<String>,
4608 /// Unmodified injection provenance, in the form skill-`<invocation-name>`
4609 pub source: String,
4610}
4611
4612/// Session event "skill.context_delivered_ref". Internal durable receipt that reconstructs exact model-visible skill context from earlier session content.
4613#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4614#[serde(rename_all = "camelCase")]
4615pub struct SkillContextDeliveredRefData {
4616 /// 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`
4617 pub content_id: String,
4618 /// Interaction that delivered this context, when known
4619 #[serde(skip_serializing_if = "Option::is_none")]
4620 pub interaction_id: Option<String>,
4621 /// Exact text preceding the referenced content in the delivered wrapper
4622 #[serde(skip_serializing_if = "Option::is_none")]
4623 pub prefix: Option<String>,
4624 /// Unmodified injection provenance, in the form skill-`<invocation-name>`
4625 pub source: String,
4626 /// Exact text following the referenced content in the delivered wrapper
4627 #[serde(skip_serializing_if = "Option::is_none")]
4628 pub suffix: Option<String>,
4629}
4630
4631/// Effective sandbox filesystem rules, in policy order. Only populated when content capture is enabled, since these are real host paths.
4632#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4633#[serde(rename_all = "camelCase")]
4634pub struct SandboxFilesystemPolicyDetails {
4635 /// Paths the sandboxed process may not access at all
4636 pub denied_paths: Vec<String>,
4637 /// Paths the sandboxed process may read but not write
4638 pub readonly_paths: Vec<String>,
4639 /// Paths the sandboxed process may read and write
4640 pub readwrite_paths: Vec<String>,
4641}
4642
4643#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4644#[serde(rename_all = "camelCase")]
4645pub struct SandboxDecisionDataPolicyResolved {
4646 /// Whether the current working directory was granted automatically
4647 pub add_current_working_directory: bool,
4648 /// Whether callers may opt an individual command out of the sandbox
4649 pub allow_bypass: bool,
4650 /// Whether the sandboxed process may reach loopback and private-range addresses
4651 pub allow_local_network: bool,
4652 /// Whether the sandboxed process may open outbound network connections
4653 pub allow_outbound: bool,
4654 /// Process-containment implementation backing the sandbox
4655 pub backend: SandboxBackend,
4656 /// Enforcement mechanism this decision describes
4657 pub control: SandboxControl,
4658 /// Why enforcement is weaker than configured, when it is
4659 #[serde(skip_serializing_if = "Option::is_none")]
4660 pub degradation_reason: Option<SandboxDegradationReason>,
4661 /// Number of denied path rules in the effective policy
4662 pub denied_paths_count: i64,
4663 /// Effective filesystem rules. Populated only when content capture is enabled; the counts above are always present.
4664 #[serde(skip_serializing_if = "Option::is_none")]
4665 pub effective_filesystem_policy: Option<SandboxFilesystemPolicyDetails>,
4666 /// Runtime subsystem that applied the policy
4667 pub enforcement_point: SandboxEnforcementPoint,
4668 /// Whether the sandbox policy permits GitHub CLI credentials inside the sandbox. A policy capability, not proof that a credential was injected into this spawn: injection is per-command
4669 pub gh_auth: bool,
4670 /// Whether the sandbox policy permits git credentials inside the sandbox. A policy capability, not proof that a credential was injected into this spawn: injection is per-command
4671 pub git_auth: bool,
4672 /// Whether the macOS keychain was reachable from inside the sandbox. Always false on other platforms.
4673 pub keychain_access: bool,
4674 /// Sandbox decision variant discriminator.
4675 pub kind: SandboxDecisionDataPolicyResolvedKind,
4676 /// Whether the resolved policy is fully active or degraded
4677 pub outcome: SandboxOutcome,
4678 /// Host platform the sandbox is running on
4679 pub platform: SandboxPlatform,
4680 /// Whether the policy came from built-in defaults or user configuration
4681 pub policy_source: SandboxPolicySource,
4682 /// Whether outbound traffic is unproxied, routed through a loopback proxy, or routed through an external proxy
4683 pub proxy_mode: SandboxProxyMode,
4684 /// Number of read-only path rules in the effective policy
4685 pub readonly_paths_count: i64,
4686 /// Number of read-write path rules in the effective policy
4687 pub readwrite_paths_count: i64,
4688 /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4689 #[serde(skip_serializing_if = "Option::is_none")]
4690 pub tool_call_id: Option<String>,
4691}
4692
4693#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4694#[serde(rename_all = "camelCase")]
4695pub struct SandboxDecisionDataSpawnCompleted {
4696 /// Process-containment implementation backing the sandbox
4697 pub backend: SandboxBackend,
4698 /// Enforcement mechanism this decision describes
4699 pub control: SandboxControl,
4700 /// Why enforcement is weaker than configured, when it is
4701 #[serde(skip_serializing_if = "Option::is_none")]
4702 pub degradation_reason: Option<SandboxDegradationReason>,
4703 /// Wall-clock time spent spawning the sandboxed process, in milliseconds
4704 pub duration_ms: f64,
4705 /// Runtime subsystem that applied the policy
4706 pub enforcement_point: SandboxEnforcementPoint,
4707 /// Sandbox decision variant discriminator.
4708 pub kind: SandboxDecisionDataSpawnCompletedKind,
4709 /// Whether the sandboxed process launched under the named backend. Not the exit status of the command that ran inside it.
4710 pub outcome: SandboxOutcome,
4711 /// Host platform the sandbox is running on
4712 pub platform: SandboxPlatform,
4713 /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4714 #[serde(skip_serializing_if = "Option::is_none")]
4715 pub tool_call_id: Option<String>,
4716}
4717
4718#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4719#[serde(rename_all = "camelCase")]
4720pub struct SandboxDecisionDataEnforcementState {
4721 /// Runtime observation backing the state. Omitted for `inactive`, which has nothing to attest.
4722 #[serde(skip_serializing_if = "Option::is_none")]
4723 pub attestation: Option<SandboxAttestation>,
4724 /// Containment backend that engaged. `unsupported` for any state other than `engaged`, since no backend is known to have run.
4725 pub backend: SandboxBackend,
4726 /// Command the enforcement governed. Populated only when content capture is enabled, and only for shell commands; MCP, LSP, and search command lines are runtime plumbing.
4727 #[serde(skip_serializing_if = "Option::is_none")]
4728 pub command: Option<String>,
4729 /// Enforcement mechanism this decision describes
4730 pub control: SandboxControl,
4731 /// Runtime subsystem whose enforcement this describes
4732 pub enforcement_point: SandboxEnforcementPoint,
4733 /// Sandbox decision variant discriminator.
4734 pub kind: SandboxDecisionDataEnforcementStateKind,
4735 /// Observed enforcement state: `engaged`, `inactive`, or `failed`. Derived from runtime evidence, never from the configured posture or the compile-time target platform.
4736 pub outcome: SandboxOutcome,
4737 /// Host platform the sandbox is running on
4738 pub platform: SandboxPlatform,
4739 /// Internal tool-call ID, used only to correlate the decision with its owning span. Omitted when the decision is not attributable to a tool call.
4740 #[serde(skip_serializing_if = "Option::is_none")]
4741 pub tool_call_id: Option<String>,
4742}
4743
4744/// An enforcement check refused a specific access. Emitted per refusal with no deduplication, including when policy permits the caller to bypass the denial. Carries no backend: the built-in checks that produce this run in-process against the effective policy.
4745#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4746#[serde(rename_all = "camelCase")]
4747pub struct SandboxDecisionDataAccessDenied {
4748 /// Runtime observation backing the denial.
4749 pub attestation: SandboxAttestation,
4750 /// Command whose execution the denial arose from. Populated only when content capture is enabled.
4751 #[serde(skip_serializing_if = "Option::is_none")]
4752 pub command: Option<String>,
4753 /// How strong the evidence behind this denial is. Lets an analysis separate denials the sandbox recorded from ones inferred from output text, which otherwise look identical.
4754 #[serde(skip_serializing_if = "Option::is_none")]
4755 pub confidence: Option<SandboxDenialConfidence>,
4756 /// Sandbox control the denial belongs to. Follows from `denialClass`.
4757 pub control: SandboxControl,
4758 /// Bounded class of the refused access.
4759 pub denial_class: SandboxDenialClass,
4760 /// Resource the check refused, when identified and content capture is enabled.
4761 #[serde(skip_serializing_if = "Option::is_none")]
4762 pub denied_resource: Option<String>,
4763 /// Runtime subsystem that performed the check
4764 pub enforcement_point: SandboxEnforcementPoint,
4765 /// Sandbox decision variant discriminator.
4766 pub kind: SandboxDecisionDataAccessDeniedKind,
4767 /// Always `denied`.
4768 pub outcome: SandboxOutcome,
4769 /// Host operating-system family
4770 pub platform: SandboxPlatform,
4771 /// Executable image associated with the captured denial, normalized to a basename. Populated only when content capture is enabled.
4772 #[serde(skip_serializing_if = "Option::is_none")]
4773 pub process_name: Option<String>,
4774 /// Tool call the denial belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4775 #[serde(skip_serializing_if = "Option::is_none")]
4776 pub tool_call_id: Option<String>,
4777}
4778
4779/// A request to run outside the process sandbox was resolved. This is what makes an `inactive` `enforcement_state` readable: without it, a command that ran unsandboxed because a person approved a bypass looks identical to one that ran unsandboxed because the session never had a sandbox. Reported only when a sandbox was in force, since bypassing a disabled sandbox bypasses nothing. Carries neither backend nor attestation: the verdict comes from the runtime's own permission flow or the local escalation prompt, not from a containment backend and not from the built-in policy check, so `source` is what records where it came from.
4780#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4781#[serde(rename_all = "camelCase")]
4782pub struct SandboxDecisionDataBypassDecided {
4783 /// Command the verdict governs. Populated only when content capture is enabled.
4784 #[serde(skip_serializing_if = "Option::is_none")]
4785 pub command: Option<String>,
4786 /// How strong the evidence behind `denialClass` was. Present exactly when `denialClass` is, so a verdict that relaxed the sandbox on a guess is distinguishable from one that relaxed it on a recorded refusal. Named to match `access_denied`, which reports the same pair.
4787 #[serde(skip_serializing_if = "Option::is_none")]
4788 pub confidence: Option<SandboxDenialConfidence>,
4789 /// Always `bypass`.
4790 pub control: SandboxControl,
4791 /// Bounded class of the access whose refusal raised this escalation. Omitted for a pre-execution bypass, such as a detached command that cannot be sandboxed and therefore resolves no denial.
4792 #[serde(skip_serializing_if = "Option::is_none")]
4793 pub denial_class: Option<SandboxDenialClass>,
4794 /// Resource whose refusal raised this escalation. Populated only when content capture is enabled.
4795 #[serde(skip_serializing_if = "Option::is_none")]
4796 pub denied_resource: Option<String>,
4797 /// Runtime subsystem the bypass applies to
4798 pub enforcement_point: SandboxEnforcementPoint,
4799 /// Sandbox decision variant discriminator.
4800 pub kind: SandboxDecisionDataBypassDecidedKind,
4801 /// Whether the bypass was granted: `approved` or `declined`. `declined` also covers the cases where nobody answered, since the sandboxed denial stands either way.
4802 pub outcome: SandboxOutcome,
4803 /// Host operating-system family
4804 pub platform: SandboxPlatform,
4805 /// Executable image associated with the denial that raised this escalation, normalized to a basename. Populated only when content capture is enabled.
4806 #[serde(skip_serializing_if = "Option::is_none")]
4807 pub process_name: Option<String>,
4808 /// Where the request originated. Orthogonal to `outcome`.
4809 pub source: SandboxBypassSource,
4810 /// Tool call the decision belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4811 #[serde(skip_serializing_if = "Option::is_none")]
4812 pub tool_call_id: Option<String>,
4813}
4814
4815/// A permissive retry was resolved. Distinct from `bypass_decided` because this rung never requests a run outside the process sandbox: it relaxes the process container for one run while the sandbox, and with it the network policy, stays attached. Reported for both outcomes, so an escalation the user declined still leaves evidence that the runtime asked and that the sandboxed denial stood.
4816#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4817#[serde(rename_all = "camelCase")]
4818pub struct SandboxDecisionDataPermissiveRetryDecided {
4819 /// Command the verdict governs. Populated only when content capture is enabled.
4820 #[serde(skip_serializing_if = "Option::is_none")]
4821 pub command: Option<String>,
4822 /// How strong the evidence behind `denialClass` was. Present exactly when `denialClass` is.
4823 #[serde(skip_serializing_if = "Option::is_none")]
4824 pub confidence: Option<SandboxDenialConfidence>,
4825 /// Always `process`: the process container is what this rung relaxes, and the network control is deliberately untouched.
4826 pub control: SandboxControl,
4827 /// Bounded class of the access whose refusal raised this escalation.
4828 #[serde(skip_serializing_if = "Option::is_none")]
4829 pub denial_class: Option<SandboxDenialClass>,
4830 /// Resource whose refusal raised this escalation. Populated only when content capture is enabled.
4831 #[serde(skip_serializing_if = "Option::is_none")]
4832 pub denied_resource: Option<String>,
4833 /// Runtime subsystem the retry applies to
4834 pub enforcement_point: SandboxEnforcementPoint,
4835 /// Sandbox decision variant discriminator.
4836 pub kind: SandboxDecisionDataPermissiveRetryDecidedKind,
4837 /// Whether the permissive retry was granted: `approved` or `declined`. `declined` also covers the cases where nobody answered, since the sandboxed denial stands either way.
4838 pub outcome: SandboxOutcome,
4839 /// Host operating-system family
4840 pub platform: SandboxPlatform,
4841 /// Executable image associated with the denial that raised this escalation, normalized to a basename. Populated only when content capture is enabled.
4842 #[serde(skip_serializing_if = "Option::is_none")]
4843 pub process_name: Option<String>,
4844 /// Where the request originated. Orthogonal to `outcome`.
4845 pub source: SandboxBypassSource,
4846 /// Tool call the decision belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4847 #[serde(skip_serializing_if = "Option::is_none")]
4848 pub tool_call_id: Option<String>,
4849}
4850
4851/// An approved permissive retry finished. `succeeded` means the retry exited successfully without another correlated sandbox denial; `failed` means it failed or remained blocked and may therefore be followed by a full bypass.
4852#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4853#[serde(rename_all = "camelCase")]
4854pub struct SandboxDecisionDataPermissiveRetryCompleted {
4855 /// Command the retry executed. Populated only when content capture is enabled.
4856 #[serde(skip_serializing_if = "Option::is_none")]
4857 pub command: Option<String>,
4858 /// How strong the evidence behind `denialClass` was.
4859 #[serde(skip_serializing_if = "Option::is_none")]
4860 pub confidence: Option<SandboxDenialConfidence>,
4861 /// Always `process`: the retry changes process-container enforcement while leaving network policy attached.
4862 pub control: SandboxControl,
4863 /// Bounded class of the access whose refusal raised the permissive retry.
4864 #[serde(skip_serializing_if = "Option::is_none")]
4865 pub denial_class: Option<SandboxDenialClass>,
4866 /// Resource whose refusal raised the retry. Populated only when content capture is enabled.
4867 #[serde(skip_serializing_if = "Option::is_none")]
4868 pub denied_resource: Option<String>,
4869 /// Runtime subsystem that ran the retry
4870 pub enforcement_point: SandboxEnforcementPoint,
4871 /// Sandbox decision variant discriminator.
4872 pub kind: SandboxDecisionDataPermissiveRetryCompletedKind,
4873 /// Whether the permissive retry completed successfully: `succeeded` or `failed`.
4874 pub outcome: SandboxOutcome,
4875 /// Host operating-system family
4876 pub platform: SandboxPlatform,
4877 /// Executable image associated with the denial that raised the retry, normalized to a basename. Populated only when content capture is enabled.
4878 #[serde(skip_serializing_if = "Option::is_none")]
4879 pub process_name: Option<String>,
4880 /// Tool call the completion belongs to, for span correlation only. Never exported as a telemetry attribute or metric dimension.
4881 #[serde(skip_serializing_if = "Option::is_none")]
4882 pub tool_call_id: Option<String>,
4883}
4884
4885/// Session event "subagent.started". Sub-agent startup details including parent tool call and agent information
4886#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4887#[serde(rename_all = "camelCase")]
4888pub struct SubagentStartedData {
4889 /// Description of what the sub-agent does
4890 pub agent_description: String,
4891 /// Human-readable display name of the sub-agent
4892 pub agent_display_name: String,
4893 /// Internal name of the sub-agent
4894 pub agent_name: String,
4895 /// Type of the sub-agent selected at spawn time.
4896 #[serde(skip_serializing_if = "Option::is_none")]
4897 pub agent_type: Option<String>,
4898 /// Whether the sub-agent runs synchronously or in the background.
4899 #[serde(skip_serializing_if = "Option::is_none")]
4900 pub execution_mode: Option<String>,
4901 /// Root id of the factory run that spawned this sub-agent, when it was spawned by one.
4902 #[serde(skip_serializing_if = "Option::is_none")]
4903 pub factory_run_id: Option<String>,
4904 /// Model the sub-agent will run with, when known at start.
4905 #[serde(skip_serializing_if = "Option::is_none")]
4906 pub model: Option<String>,
4907 /// Authority or runtime mechanism responsible for sub-agent model selection, when known at start.
4908 #[serde(skip_serializing_if = "Option::is_none")]
4909 pub model_selection_source: Option<SubagentModelSelectionSource>,
4910 /// Task-registry ID of the spawning sub-agent. Absent when the root session spawned this child.
4911 #[serde(skip_serializing_if = "Option::is_none")]
4912 pub parent_id: Option<String>,
4913 /// Whether this sub-agent can be resumed. Currently always false.
4914 #[serde(skip_serializing_if = "Option::is_none")]
4915 pub resumable: Option<bool>,
4916 /// 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.
4917 #[serde(skip_serializing_if = "Option::is_none")]
4918 pub task_model_source: Option<SubagentTaskModelSource>,
4919 /// Tool call ID of the parent tool invocation that spawned this sub-agent
4920 pub tool_call_id: String,
4921}
4922
4923/// Session event "subagent.configured". Resolved runtime configuration for a configured sub-agent
4924#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4925#[serde(rename_all = "camelCase")]
4926pub struct SubagentConfiguredData {
4927 /// Resolved context tier, when configured for the model
4928 #[serde(skip_serializing_if = "Option::is_none")]
4929 pub context_tier: Option<String>,
4930 /// Resolved model the sub-agent will run with
4931 pub model: String,
4932 /// Whether the sub-agent accepts follow-up turns
4933 pub multi_turn: bool,
4934 /// Resolved reasoning effort, when configured for the model
4935 #[serde(skip_serializing_if = "Option::is_none")]
4936 pub reasoning_effort: Option<String>,
4937}
4938
4939/// Session event "subagent.completed". Sub-agent completion details for successful execution
4940#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4941#[serde(rename_all = "camelCase")]
4942pub struct SubagentCompletedData {
4943 /// Human-readable display name of the sub-agent
4944 pub agent_display_name: String,
4945 /// Internal name of the sub-agent
4946 pub agent_name: String,
4947 /// 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.
4948 #[serde(skip_serializing_if = "Option::is_none")]
4949 pub cancelled: Option<bool>,
4950 /// Whether the first model actually dispatched matched the user's configured preference
4951 #[serde(skip_serializing_if = "Option::is_none")]
4952 pub configured_model_matches_actual: Option<bool>,
4953 /// Concrete model the user configured for this sub-agent via `/subagents`, when present
4954 #[serde(skip_serializing_if = "Option::is_none")]
4955 pub configured_model_preference: Option<String>,
4956 /// Wall-clock duration of the sub-agent execution in milliseconds
4957 #[serde(skip_serializing_if = "Option::is_none")]
4958 pub duration_ms: Option<i64>,
4959 /// Whether the explicit task-call model matched the user's configured preference
4960 #[serde(skip_serializing_if = "Option::is_none")]
4961 pub explicit_model_matches_preference: Option<bool>,
4962 /// Explicit model supplied by the parent agent on the task call, when present
4963 #[serde(skip_serializing_if = "Option::is_none")]
4964 pub explicit_model_override: Option<String>,
4965 /// First model for which the sub-agent started an inference request, when one was dispatched
4966 #[serde(skip_serializing_if = "Option::is_none")]
4967 pub first_dispatched_model: Option<String>,
4968 /// Model used by the sub-agent
4969 #[serde(skip_serializing_if = "Option::is_none")]
4970 pub model: Option<String>,
4971 /// Why an explicit task-call model did not become the effective model
4972 #[serde(skip_serializing_if = "Option::is_none")]
4973 pub model_override_reason: Option<String>,
4974 /// Authority or runtime mechanism responsible for sub-agent model selection
4975 #[serde(skip_serializing_if = "Option::is_none")]
4976 pub model_selection_source: Option<SubagentModelSelectionSource>,
4977 /// Tool call ID of the parent tool invocation that spawned this sub-agent
4978 pub tool_call_id: String,
4979 /// Total tokens (input + output) consumed by the sub-agent
4980 #[serde(skip_serializing_if = "Option::is_none")]
4981 pub total_tokens: Option<i64>,
4982 /// Total number of tool calls made by the sub-agent
4983 #[serde(skip_serializing_if = "Option::is_none")]
4984 pub total_tool_calls: Option<i64>,
4985}
4986
4987/// Session event "subagent.failed". Sub-agent failure details including error message and agent information
4988#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4989#[serde(rename_all = "camelCase")]
4990pub struct SubagentFailedData {
4991 /// Human-readable display name of the sub-agent
4992 pub agent_display_name: String,
4993 /// Internal name of the sub-agent
4994 pub agent_name: String,
4995 /// Whether the first model actually dispatched matched the user's configured preference
4996 #[serde(skip_serializing_if = "Option::is_none")]
4997 pub configured_model_matches_actual: Option<bool>,
4998 /// Concrete model the user configured for this sub-agent via `/subagents`, when present
4999 #[serde(skip_serializing_if = "Option::is_none")]
5000 pub configured_model_preference: Option<String>,
5001 /// Wall-clock duration of the sub-agent execution in milliseconds
5002 #[serde(skip_serializing_if = "Option::is_none")]
5003 pub duration_ms: Option<i64>,
5004 /// Error message describing why the sub-agent failed
5005 pub error: String,
5006 /// Whether the explicit task-call model matched the user's configured preference
5007 #[serde(skip_serializing_if = "Option::is_none")]
5008 pub explicit_model_matches_preference: Option<bool>,
5009 /// Explicit model supplied by the parent agent on the task call, when present
5010 #[serde(skip_serializing_if = "Option::is_none")]
5011 pub explicit_model_override: Option<String>,
5012 /// First model for which the sub-agent started an inference request, when one was dispatched
5013 #[serde(skip_serializing_if = "Option::is_none")]
5014 pub first_dispatched_model: Option<String>,
5015 /// Model selected for the sub-agent, when known
5016 #[serde(skip_serializing_if = "Option::is_none")]
5017 pub model: Option<String>,
5018 /// Why an explicit task-call model did not become the effective model
5019 #[serde(skip_serializing_if = "Option::is_none")]
5020 pub model_override_reason: Option<String>,
5021 /// Authority or runtime mechanism responsible for sub-agent model selection
5022 #[serde(skip_serializing_if = "Option::is_none")]
5023 pub model_selection_source: Option<SubagentModelSelectionSource>,
5024 /// Tool call ID of the parent tool invocation that spawned this sub-agent
5025 pub tool_call_id: String,
5026 /// Total tokens (input + output) consumed before the sub-agent failed
5027 #[serde(skip_serializing_if = "Option::is_none")]
5028 pub total_tokens: Option<i64>,
5029 /// Total number of tool calls made before the sub-agent failed
5030 #[serde(skip_serializing_if = "Option::is_none")]
5031 pub total_tool_calls: Option<i64>,
5032}
5033
5034/// Session event "subagent.selected". Custom agent selection details including name and available tools
5035#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5036#[serde(rename_all = "camelCase")]
5037pub struct SubagentSelectedData {
5038 /// Human-readable display name of the selected custom agent
5039 pub agent_display_name: String,
5040 /// Internal name of the selected custom agent
5041 pub agent_name: String,
5042 /// List of tool names available to this agent, or null for all tools
5043 pub tools: Option<Vec<String>>,
5044}
5045
5046/// Session event "subagent.deselected". Empty payload; the event signals that the custom agent was deselected, returning to the default agent
5047#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5048#[serde(rename_all = "camelCase")]
5049pub struct SubagentDeselectedData {}
5050
5051/// Session event "hook.start". Hook invocation start details including type and input data
5052#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5053#[serde(rename_all = "camelCase")]
5054pub struct HookStartData {
5055 /// Unique identifier for this hook invocation
5056 pub hook_invocation_id: String,
5057 /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
5058 pub hook_type: String,
5059 /// 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.
5060 #[serde(skip_serializing_if = "Option::is_none")]
5061 pub input: Option<serde_json::Value>,
5062 /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
5063 #[serde(skip_serializing_if = "Option::is_none")]
5064 pub parent_tool_call_id: Option<String>,
5065}
5066
5067/// Error details when the hook failed
5068#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5069#[serde(rename_all = "camelCase")]
5070pub struct HookEndError {
5071 /// Human-readable error message
5072 pub message: String,
5073 /// Source label of the hook that errored (e.g. the plugin it was loaded from), when known
5074 #[serde(skip_serializing_if = "Option::is_none")]
5075 pub source: Option<String>,
5076 /// Error stack trace, when available
5077 #[serde(skip_serializing_if = "Option::is_none")]
5078 pub stack: Option<String>,
5079}
5080
5081/// Session event "hook.end". Hook invocation completion details including output, success status, and error information
5082#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5083#[serde(rename_all = "camelCase")]
5084pub struct HookEndData {
5085 /// Error details when the hook failed
5086 #[serde(skip_serializing_if = "Option::is_none")]
5087 pub error: Option<HookEndError>,
5088 /// Identifier matching the corresponding hook.start event
5089 pub hook_invocation_id: String,
5090 /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
5091 pub hook_type: String,
5092 /// 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.
5093 #[serde(skip_serializing_if = "Option::is_none")]
5094 pub output: Option<serde_json::Value>,
5095 /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
5096 #[serde(skip_serializing_if = "Option::is_none")]
5097 pub parent_tool_call_id: Option<String>,
5098 /// Whether the hook completed successfully
5099 pub success: bool,
5100}
5101
5102/// Session event "hook.progress". Ephemeral progress update from a running hook process
5103#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5104#[serde(rename_all = "camelCase")]
5105pub struct HookProgressData {
5106 /// Human-readable progress message from the hook process
5107 pub message: String,
5108 /// When true, this status message replaces the previous temporary one instead of accumulating
5109 #[serde(skip_serializing_if = "Option::is_none")]
5110 pub temporary: Option<bool>,
5111}
5112
5113/// Session event "session.binary_asset". Canonical bytes for a content-addressed binary asset shared by reference across events
5114#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5115#[serde(rename_all = "camelCase")]
5116pub struct SessionBinaryAssetData {
5117 /// Content-addressed id for this binary asset (e.g. "sha256:...").
5118 pub asset_id: String,
5119 /// Decoded byte length of the binary asset
5120 pub byte_length: i64,
5121 /// Base64-encoded binary data
5122 pub data: String,
5123 /// Human-readable description of the binary data
5124 #[serde(skip_serializing_if = "Option::is_none")]
5125 pub description: Option<String>,
5126 /// Optional metadata from the producing tool.
5127 #[serde(skip_serializing_if = "Option::is_none")]
5128 pub metadata: Option<HashMap<String, serde_json::Value>>,
5129 /// MIME type of the binary asset
5130 pub mime_type: String,
5131 /// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
5132 pub r#type: BinaryAssetType,
5133}
5134
5135/// One persisted structured system-message block and its cache intent
5136#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5137#[serde(rename_all = "camelCase")]
5138pub struct SystemMessageContentBlock {
5139 /// Explicit prompt-cache intent. True places a breakpoint after this block, false suppresses one, and absence preserves the provider's legacy default.
5140 #[serde(skip_serializing_if = "Option::is_none")]
5141 pub cache_breakpoint: Option<bool>,
5142 /// Text content for this system-message block.
5143 pub content: String,
5144 /// Diagnostic classification indicating whether the block is stable across equivalent sessions.
5145 #[serde(skip_serializing_if = "Option::is_none")]
5146 pub is_static: Option<bool>,
5147}
5148
5149/// Metadata about the prompt template and its construction
5150#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5151#[serde(rename_all = "camelCase")]
5152pub struct SystemMessageMetadata {
5153 /// Version identifier of the prompt template or structured prompt layout used
5154 #[serde(skip_serializing_if = "Option::is_none")]
5155 pub prompt_version: Option<String>,
5156 /// Template variables used when constructing the prompt
5157 #[serde(skip_serializing_if = "Option::is_none")]
5158 pub variables: Option<HashMap<String, serde_json::Value>>,
5159}
5160
5161/// Session event "system.message". System/developer instruction content with role and optional template metadata
5162#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5163#[serde(rename_all = "camelCase")]
5164pub struct SystemMessageData {
5165 /// The system or developer prompt text sent as model input
5166 pub content: String,
5167 /// Optional ordered structured blocks corresponding to content, retained for prompt-cache layout restoration.
5168 #[serde(skip_serializing_if = "Option::is_none")]
5169 pub content_blocks: Option<Vec<SystemMessageContentBlock>>,
5170 /// Logical interaction identifier for the model run receiving this prompt
5171 #[serde(skip_serializing_if = "Option::is_none")]
5172 pub interaction_id: Option<String>,
5173 /// Metadata about the prompt template and its construction
5174 #[serde(skip_serializing_if = "Option::is_none")]
5175 pub metadata: Option<SystemMessageMetadata>,
5176 /// Optional name identifier for the message source
5177 #[serde(skip_serializing_if = "Option::is_none")]
5178 pub name: Option<String>,
5179 /// Message role: "system" for system prompts, "developer" for developer-injected instructions
5180 pub role: SystemMessageRole,
5181}
5182
5183/// Session event "system.notification". System-generated notification for runtime events like background task completion
5184#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5185#[serde(rename_all = "camelCase")]
5186pub struct SystemNotificationData {
5187 /// The notification text, typically wrapped in `<system_notification>` XML tags
5188 pub content: String,
5189 /// Structured metadata identifying what triggered this notification
5190 pub kind: serde_json::Value,
5191 /// Responses reasoning settings anchored before this model-facing message, for cache-stable history replay
5192 #[serde(skip_serializing_if = "Option::is_none")]
5193 pub responses_reasoning: Option<ResponsesReasoning>,
5194}
5195
5196/// A parsed command identifier in a shell permission request, including whether it is read-only.
5197#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5198#[serde(rename_all = "camelCase")]
5199pub struct PermissionRequestShellCommand {
5200 /// Command identifier (e.g., executable name)
5201 pub identifier: String,
5202 /// Whether this command is read-only (no side effects)
5203 pub read_only: bool,
5204}
5205
5206/// A parsed shell command segment used for argument-aware managed policy matching.
5207#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5208#[serde(rename_all = "camelCase")]
5209pub struct PermissionRequestShellCommandSegment {
5210 /// Full text of this command segment, including arguments
5211 pub full_command_text: String,
5212 /// Command identifier (e.g., executable name)
5213 pub identifier: String,
5214}
5215
5216/// A URL that may be accessed by a command in a shell permission request.
5217#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5218#[serde(rename_all = "camelCase")]
5219pub struct PermissionRequestShellPossibleUrl {
5220 /// URL that may be accessed by the command
5221 pub url: String,
5222}
5223
5224/// Shell command permission request
5225#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5226#[serde(rename_all = "camelCase")]
5227pub struct PermissionRequestShell {
5228 /// Whether the UI can offer session-wide approval for this command pattern
5229 pub can_offer_session_approval: bool,
5230 /// Parsed command identifiers found in the command text
5231 pub commands: Vec<PermissionRequestShellCommand>,
5232 /// Parsed command segments, including arguments, used for managed policy matching
5233 #[serde(skip_serializing_if = "Option::is_none")]
5234 pub command_segments: Option<Vec<PermissionRequestShellCommandSegment>>,
5235 /// The complete shell command text to be executed
5236 pub full_command_text: String,
5237 /// Whether the command includes a file write redirection (e.g., > or >>)
5238 pub has_write_file_redirection: bool,
5239 /// Human-readable description of what the command intends to do
5240 pub intention: String,
5241 /// Permission kind discriminator
5242 pub kind: PermissionRequestShellKind,
5243 /// Whether managed policy requires a human response and forbids host auto-approval
5244 #[serde(skip_serializing_if = "Option::is_none")]
5245 pub managed_approval_required: Option<bool>,
5246 /// File paths that may be read or written by the command
5247 pub possible_paths: Vec<String>,
5248 /// URLs that may be accessed by the command
5249 pub possible_urls: Vec<PermissionRequestShellPossibleUrl>,
5250 /// 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.
5251 #[serde(skip_serializing_if = "Option::is_none")]
5252 pub request_sandbox_bypass: Option<bool>,
5253 /// 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.
5254 #[serde(skip_serializing_if = "Option::is_none")]
5255 pub request_sandbox_bypass_reason: Option<String>,
5256 /// 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.
5257 #[serde(skip_serializing_if = "Option::is_none")]
5258 pub request_sandbox_permissive: Option<bool>,
5259 /// 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.
5260 ///
5261 /// <div class="warning">
5262 ///
5263 /// **Experimental.** This type is part of an experimental wire-protocol surface
5264 /// and may change or be removed in future SDK or CLI releases.
5265 ///
5266 /// </div>
5267 #[serde(skip_serializing_if = "Option::is_none")]
5268 pub resolved_paths: Option<HashMap<String, String>>,
5269 /// Runtime-resolved canonical working directory the command runs in, used for authorization identity checks. Internal and experimental; clients should not display it.
5270 ///
5271 /// <div class="warning">
5272 ///
5273 /// **Experimental.** This type is part of an experimental wire-protocol surface
5274 /// and may change or be removed in future SDK or CLI releases.
5275 ///
5276 /// </div>
5277 #[serde(skip_serializing_if = "Option::is_none")]
5278 pub resolved_working_directory: Option<String>,
5279 /// Tool call ID that triggered this permission request
5280 #[serde(skip_serializing_if = "Option::is_none")]
5281 pub tool_call_id: Option<String>,
5282 /// Optional warning message about risks of running this command
5283 #[serde(skip_serializing_if = "Option::is_none")]
5284 pub warning: Option<String>,
5285}
5286
5287/// File write permission request
5288#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5289#[serde(rename_all = "camelCase")]
5290pub struct PermissionRequestWrite {
5291 /// Whether the UI can offer session-wide approval for file write operations
5292 pub can_offer_session_approval: bool,
5293 /// Unified diff showing the proposed changes
5294 pub diff: String,
5295 /// Path of the file being written to
5296 pub file_name: String,
5297 /// Human-readable description of the intended file change
5298 pub intention: String,
5299 /// Permission kind discriminator
5300 pub kind: PermissionRequestWriteKind,
5301 /// Whether managed policy requires a human response and forbids host auto-approval
5302 #[serde(skip_serializing_if = "Option::is_none")]
5303 pub managed_approval_required: Option<bool>,
5304 /// Complete new file contents for newly created files
5305 #[serde(skip_serializing_if = "Option::is_none")]
5306 pub new_file_contents: Option<String>,
5307 /// 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.
5308 #[serde(skip_serializing_if = "Option::is_none")]
5309 pub request_sandbox_bypass: Option<bool>,
5310 /// Justification for the sandbox-bypass request. Only meaningful when requestSandboxBypass is true.
5311 #[serde(skip_serializing_if = "Option::is_none")]
5312 pub request_sandbox_bypass_reason: Option<String>,
5313 /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display fileName.
5314 ///
5315 /// <div class="warning">
5316 ///
5317 /// **Experimental.** This type is part of an experimental wire-protocol surface
5318 /// and may change or be removed in future SDK or CLI releases.
5319 ///
5320 /// </div>
5321 #[serde(skip_serializing_if = "Option::is_none")]
5322 pub resolved_path: Option<String>,
5323 /// Tool call ID that triggered this permission request
5324 #[serde(skip_serializing_if = "Option::is_none")]
5325 pub tool_call_id: Option<String>,
5326}
5327
5328/// File or directory read permission request
5329#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5330#[serde(rename_all = "camelCase")]
5331pub struct PermissionRequestRead {
5332 /// Human-readable description of why the file is being read
5333 pub intention: String,
5334 /// Permission kind discriminator
5335 pub kind: PermissionRequestReadKind,
5336 /// Whether managed policy requires a human response and forbids host auto-approval
5337 #[serde(skip_serializing_if = "Option::is_none")]
5338 pub managed_approval_required: Option<bool>,
5339 /// Path of the file or directory being read
5340 pub path: String,
5341 /// 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.
5342 #[serde(skip_serializing_if = "Option::is_none")]
5343 pub request_sandbox_bypass: Option<bool>,
5344 /// 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.
5345 #[serde(skip_serializing_if = "Option::is_none")]
5346 pub request_sandbox_bypass_reason: Option<String>,
5347 /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display path.
5348 ///
5349 /// <div class="warning">
5350 ///
5351 /// **Experimental.** This type is part of an experimental wire-protocol surface
5352 /// and may change or be removed in future SDK or CLI releases.
5353 ///
5354 /// </div>
5355 #[serde(skip_serializing_if = "Option::is_none")]
5356 pub resolved_path: Option<String>,
5357 /// Tool call ID that triggered this permission request
5358 #[serde(skip_serializing_if = "Option::is_none")]
5359 pub tool_call_id: Option<String>,
5360}
5361
5362/// MCP tool invocation permission request
5363#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5364#[serde(rename_all = "camelCase")]
5365pub struct PermissionRequestMcp {
5366 /// Arguments to pass to the MCP tool
5367 #[serde(skip_serializing_if = "Option::is_none")]
5368 pub args: Option<serde_json::Value>,
5369 /// Permission kind discriminator
5370 pub kind: PermissionRequestMcpKind,
5371 /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5372 #[serde(skip_serializing_if = "Option::is_none")]
5373 pub managed_approval_required: Option<bool>,
5374 /// Advisory runtime permission recommendation. The SDK host remains responsible for deciding the request and may reject it.
5375 ///
5376 /// <div class="warning">
5377 ///
5378 /// **Experimental.** This type is part of an experimental wire-protocol surface
5379 /// and may change or be removed in future SDK or CLI releases.
5380 ///
5381 /// </div>
5382 #[serde(skip_serializing_if = "Option::is_none")]
5383 pub permission_recommendation: Option<PermissionRecommendation>,
5384 /// Whether this MCP tool is read-only (no side effects)
5385 pub read_only: bool,
5386 /// Name of the MCP server providing the tool
5387 pub server_name: String,
5388 /// Tool call ID that triggered this permission request
5389 #[serde(skip_serializing_if = "Option::is_none")]
5390 pub tool_call_id: Option<String>,
5391 /// Internal name of the MCP tool
5392 pub tool_name: String,
5393 /// Human-readable title of the MCP tool
5394 pub tool_title: String,
5395}
5396
5397/// URL access permission request
5398#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5399#[serde(rename_all = "camelCase")]
5400pub struct PermissionRequestUrl {
5401 /// Human-readable description of why the URL is being accessed
5402 pub intention: String,
5403 /// Permission kind discriminator
5404 pub kind: PermissionRequestUrlKind,
5405 /// Whether managed policy requires a human response and forbids host auto-approval
5406 #[serde(skip_serializing_if = "Option::is_none")]
5407 pub managed_approval_required: Option<bool>,
5408 /// Immediately preceding URL when this request is for a redirect target
5409 #[serde(skip_serializing_if = "Option::is_none")]
5410 pub redirected_from: Option<String>,
5411 /// 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.
5412 #[serde(skip_serializing_if = "Option::is_none")]
5413 pub request_sandbox_bypass: Option<bool>,
5414 /// 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.
5415 #[serde(skip_serializing_if = "Option::is_none")]
5416 pub request_sandbox_bypass_reason: Option<String>,
5417 /// Tool call ID that triggered this permission request
5418 #[serde(skip_serializing_if = "Option::is_none")]
5419 pub tool_call_id: Option<String>,
5420 /// URL to be fetched
5421 pub url: String,
5422}
5423
5424/// Bounded runtime attribution, independent of free-text rationale. Telemetry revalidates this vocabulary before standard collection.
5425#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5426#[serde(rename_all = "camelCase")]
5427pub struct PermissionApprovalEvaluation {
5428 /// Stage that produced this attribution.
5429 pub evaluation_stage: PermissionApprovalEvaluationEvaluationStage,
5430 /// Whether the request invoked the judge interface. A cached recommendation retains the original attempt fact. Omitted means unknown, including inherited outcomes.
5431 #[serde(skip_serializing_if = "Option::is_none")]
5432 pub judge_attempted: Option<bool>,
5433 /// Status of the local judge interface, not proof of a model network call.
5434 pub judge_status: PermissionApprovalEvaluationJudgeStatus,
5435 /// Machine-readable runtime gate reason, never a command, path or human rationale.
5436 pub reason_code: PermissionApprovalEvaluationReasonCode,
5437}
5438
5439/// 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.
5440///
5441/// <div class="warning">
5442///
5443/// **Experimental.** This type is part of an experimental wire-protocol surface
5444/// and may change or be removed in future SDK or CLI releases.
5445///
5446/// </div>
5447#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5448#[serde(rename_all = "camelCase")]
5449pub struct PermissionAssistedApproval {
5450 /// Runtime reason and judge-call metadata. Absent on older events; missing metadata means unknown, not that the judge was skipped.
5451 #[serde(skip_serializing_if = "Option::is_none")]
5452 pub evaluation: Option<PermissionApprovalEvaluation>,
5453 /// Classified cause of an `error` recommendation. Absent for every other recommendation.
5454 #[serde(skip_serializing_if = "Option::is_none")]
5455 pub failure_reason: Option<AssistedApprovalJudgeFailureReason>,
5456 /// 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.
5457 #[serde(skip_serializing_if = "Option::is_none")]
5458 pub model: Option<String>,
5459 /// Human-readable reason for the judge's recommendation, when available.
5460 #[serde(skip_serializing_if = "Option::is_none")]
5461 pub reason: Option<String>,
5462 /// The assisted-approval safety judge's outcome for this request.
5463 pub recommendation: AssistedApprovalRecommendation,
5464}
5465
5466/// Memory operation permission request
5467#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5468#[serde(rename_all = "camelCase")]
5469pub struct PermissionRequestMemory {
5470 /// Whether this is a store or vote memory operation
5471 #[serde(skip_serializing_if = "Option::is_none")]
5472 pub action: Option<PermissionRequestMemoryAction>,
5473 /// Assisted-approval judge information for this request; present only in assisted mode.
5474 ///
5475 /// <div class="warning">
5476 ///
5477 /// **Experimental.** This type is part of an experimental wire-protocol surface
5478 /// and may change or be removed in future SDK or CLI releases.
5479 ///
5480 /// </div>
5481 #[serde(skip_serializing_if = "Option::is_none")]
5482 pub assisted_approval: Option<PermissionAssistedApproval>,
5483 /// Source references for the stored fact (store only)
5484 #[serde(skip_serializing_if = "Option::is_none")]
5485 pub citations: Option<String>,
5486 /// Vote direction (vote only)
5487 #[serde(skip_serializing_if = "Option::is_none")]
5488 pub direction: Option<PermissionRequestMemoryDirection>,
5489 /// The fact being stored or voted on
5490 pub fact: String,
5491 /// Permission kind discriminator
5492 pub kind: PermissionRequestMemoryKind,
5493 /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5494 #[serde(skip_serializing_if = "Option::is_none")]
5495 pub managed_approval_required: Option<bool>,
5496 /// Reason for the vote (vote only)
5497 #[serde(skip_serializing_if = "Option::is_none")]
5498 pub reason: Option<String>,
5499 /// Repository name with owner associated with the stored memory (store only)
5500 #[serde(skip_serializing_if = "Option::is_none")]
5501 pub repo_nwo: Option<String>,
5502 /// Scope of the stored memory (store only)
5503 #[serde(skip_serializing_if = "Option::is_none")]
5504 pub scope: Option<PermissionRequestMemoryScope>,
5505 /// Topic or subject of the memory (store only)
5506 #[serde(skip_serializing_if = "Option::is_none")]
5507 pub subject: Option<String>,
5508 /// Tool call ID that triggered this permission request
5509 #[serde(skip_serializing_if = "Option::is_none")]
5510 pub tool_call_id: Option<String>,
5511}
5512
5513/// Custom tool invocation permission request
5514#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5515#[serde(rename_all = "camelCase")]
5516pub struct PermissionRequestCustomTool {
5517 /// Arguments to pass to the custom tool
5518 #[serde(skip_serializing_if = "Option::is_none")]
5519 pub args: Option<serde_json::Value>,
5520 /// Permission kind discriminator
5521 pub kind: PermissionRequestCustomToolKind,
5522 /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5523 #[serde(skip_serializing_if = "Option::is_none")]
5524 pub managed_approval_required: Option<bool>,
5525 /// Whether the tool declared that permission may be skipped unless a deny rule matches
5526 #[serde(skip_serializing_if = "Option::is_none")]
5527 pub skip_permission: Option<bool>,
5528 /// Tool call ID that triggered this permission request
5529 #[serde(skip_serializing_if = "Option::is_none")]
5530 pub tool_call_id: Option<String>,
5531 /// Description of what the custom tool does
5532 pub tool_description: String,
5533 /// Name of the custom tool
5534 pub tool_name: String,
5535}
5536
5537/// Hook confirmation permission request
5538#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5539#[serde(rename_all = "camelCase")]
5540pub struct PermissionRequestHook {
5541 /// Optional message from the hook explaining why confirmation is needed
5542 #[serde(skip_serializing_if = "Option::is_none")]
5543 pub hook_message: Option<String>,
5544 /// Permission kind discriminator
5545 pub kind: PermissionRequestHookKind,
5546 /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5547 #[serde(skip_serializing_if = "Option::is_none")]
5548 pub managed_approval_required: Option<bool>,
5549 /// Arguments of the tool call being gated
5550 #[serde(skip_serializing_if = "Option::is_none")]
5551 pub tool_args: Option<serde_json::Value>,
5552 /// Tool call ID that triggered this permission request
5553 #[serde(skip_serializing_if = "Option::is_none")]
5554 pub tool_call_id: Option<String>,
5555 /// Name of the tool the hook is gating
5556 pub tool_name: String,
5557}
5558
5559/// Extension management permission request
5560#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5561#[serde(rename_all = "camelCase")]
5562pub struct PermissionRequestExtensionManagement {
5563 /// Name of the extension being managed
5564 #[serde(skip_serializing_if = "Option::is_none")]
5565 pub extension_name: Option<String>,
5566 /// Permission kind discriminator
5567 pub kind: PermissionRequestExtensionManagementKind,
5568 /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5569 #[serde(skip_serializing_if = "Option::is_none")]
5570 pub managed_approval_required: Option<bool>,
5571 /// The extension management operation (scaffold, reload)
5572 pub operation: String,
5573 /// Tool call ID that triggered this permission request
5574 #[serde(skip_serializing_if = "Option::is_none")]
5575 pub tool_call_id: Option<String>,
5576}
5577
5578/// A declared phase shown in a factory permission prompt.
5579#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5580#[serde(rename_all = "camelCase")]
5581pub struct FactoryPermissionPhase {
5582 /// Optional phase detail
5583 #[serde(skip_serializing_if = "Option::is_none")]
5584 pub detail: Option<String>,
5585 /// Phase title
5586 pub title: String,
5587}
5588
5589/// Factory run or authoring permission request
5590#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5591#[serde(rename_all = "camelCase")]
5592pub struct PermissionRequestFactory {
5593 /// Canonical key used for scoped factory approvals
5594 pub approval_key: String,
5595 /// Whether this factory is eligible for persistent approval
5596 pub can_persist_approval: bool,
5597 /// Factory-declared AI-credit limit before any run/resume caller override is applied.
5598 #[serde(skip_serializing_if = "Option::is_none")]
5599 pub declared_max_ai_credits: Option<f64>,
5600 /// Factory-declared concurrent-subagent limit before any run/resume caller override is applied.
5601 #[serde(skip_serializing_if = "Option::is_none")]
5602 pub declared_max_concurrent_subagents: Option<i64>,
5603 /// Factory-declared total-subagent limit before any run/resume caller override is applied.
5604 #[serde(skip_serializing_if = "Option::is_none")]
5605 pub declared_max_total_subagents: Option<i64>,
5606 /// Factory-declared active-time limit in seconds before any run/resume caller override is applied.
5607 #[serde(skip_serializing_if = "Option::is_none")]
5608 pub declared_timeout_seconds: Option<f64>,
5609 /// Factory description
5610 pub description: String,
5611 /// Permission kind discriminator
5612 pub kind: PermissionRequestFactoryKind,
5613 /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5614 #[serde(skip_serializing_if = "Option::is_none")]
5615 pub managed_approval_required: Option<bool>,
5616 /// Effective AI-credit limit; omitted means unlimited
5617 #[serde(skip_serializing_if = "Option::is_none")]
5618 pub max_ai_credits: Option<f64>,
5619 /// Effective concurrent-subagent limit; omitted means unlimited
5620 #[serde(skip_serializing_if = "Option::is_none")]
5621 pub max_concurrent_subagents: Option<i64>,
5622 /// Effective total-subagent limit; omitted means unlimited
5623 #[serde(skip_serializing_if = "Option::is_none")]
5624 pub max_total_subagents: Option<i64>,
5625 /// Factory name
5626 pub name: String,
5627 /// Factory operation, either run or author
5628 pub operation: FactoryPermissionOperation,
5629 /// Declared factory phases
5630 pub phases: Vec<FactoryPermissionPhase>,
5631 /// Effective active-time limit in seconds; omitted means unlimited
5632 #[serde(skip_serializing_if = "Option::is_none")]
5633 pub timeout_seconds: Option<f64>,
5634 /// Tool call ID that triggered this permission request
5635 #[serde(skip_serializing_if = "Option::is_none")]
5636 pub tool_call_id: Option<String>,
5637}
5638
5639/// Extension permission access request
5640#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5641#[serde(rename_all = "camelCase")]
5642pub struct PermissionRequestExtensionPermissionAccess {
5643 /// Capabilities the extension is requesting
5644 pub capabilities: Vec<String>,
5645 /// Name of the extension requesting permission access
5646 pub extension_name: String,
5647 /// Permission kind discriminator
5648 pub kind: PermissionRequestExtensionPermissionAccessKind,
5649 /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5650 #[serde(skip_serializing_if = "Option::is_none")]
5651 pub managed_approval_required: Option<bool>,
5652 /// Tool call ID that triggered this permission request
5653 #[serde(skip_serializing_if = "Option::is_none")]
5654 pub tool_call_id: Option<String>,
5655}
5656
5657/// Extension sensitive environment variable access request
5658#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5659#[serde(rename_all = "camelCase")]
5660pub struct PermissionRequestExtensionEnvAccess {
5661 /// Names of the sensitive environment variables the extension is requesting. Values never appear here.
5662 pub environment_variables: Vec<String>,
5663 /// Name of the extension requesting environment variable access
5664 pub extension_name: String,
5665 /// Permission kind discriminator
5666 pub kind: PermissionRequestExtensionEnvAccessKind,
5667 /// When true, managed policy requires an explicit user decision and automatic approval must be bypassed.
5668 #[serde(skip_serializing_if = "Option::is_none")]
5669 pub managed_approval_required: Option<bool>,
5670 /// Tool call ID that triggered this permission request
5671 #[serde(skip_serializing_if = "Option::is_none")]
5672 pub tool_call_id: Option<String>,
5673}
5674
5675/// Shell command permission prompt
5676#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5677#[serde(rename_all = "camelCase")]
5678pub struct PermissionPromptRequestCommands {
5679 /// Assisted-approval judge information for this request; present only in assisted mode.
5680 ///
5681 /// <div class="warning">
5682 ///
5683 /// **Experimental.** This type is part of an experimental wire-protocol surface
5684 /// and may change or be removed in future SDK or CLI releases.
5685 ///
5686 /// </div>
5687 #[serde(skip_serializing_if = "Option::is_none")]
5688 pub assisted_approval: Option<PermissionAssistedApproval>,
5689 /// Whether the UI can offer session-wide approval for this command pattern
5690 pub can_offer_session_approval: bool,
5691 /// Command identifiers covered by this approval prompt
5692 pub command_identifiers: Vec<String>,
5693 /// The complete shell command text to be executed
5694 pub full_command_text: String,
5695 /// Human-readable description of what the command intends to do
5696 pub intention: String,
5697 /// Prompt kind discriminator
5698 pub kind: PermissionPromptRequestCommandsKind,
5699 /// Whether managed policy requires a human response and forbids host auto-approval
5700 #[serde(skip_serializing_if = "Option::is_none")]
5701 pub managed_approval_required: Option<bool>,
5702 /// True when the shell command is requesting sandbox escalation. This is a request, not a grant.
5703 #[serde(skip_serializing_if = "Option::is_none")]
5704 pub request_sandbox_bypass: Option<bool>,
5705 /// Reason for the sandbox escalation request.
5706 #[serde(skip_serializing_if = "Option::is_none")]
5707 pub request_sandbox_bypass_reason: Option<String>,
5708 /// 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.
5709 #[serde(skip_serializing_if = "Option::is_none")]
5710 pub request_sandbox_permissive: Option<bool>,
5711 /// Tool call ID that triggered this permission request
5712 #[serde(skip_serializing_if = "Option::is_none")]
5713 pub tool_call_id: Option<String>,
5714 /// Optional warning message about risks of running this command
5715 #[serde(skip_serializing_if = "Option::is_none")]
5716 pub warning: Option<String>,
5717}
5718
5719/// File write permission prompt
5720#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5721#[serde(rename_all = "camelCase")]
5722pub struct PermissionPromptRequestWrite {
5723 /// Assisted-approval judge information for this request; present only in assisted mode.
5724 ///
5725 /// <div class="warning">
5726 ///
5727 /// **Experimental.** This type is part of an experimental wire-protocol surface
5728 /// and may change or be removed in future SDK or CLI releases.
5729 ///
5730 /// </div>
5731 #[serde(skip_serializing_if = "Option::is_none")]
5732 pub assisted_approval: Option<PermissionAssistedApproval>,
5733 /// Whether the UI can offer session-wide approval for file write operations
5734 pub can_offer_session_approval: bool,
5735 /// Unified diff showing the proposed changes
5736 pub diff: String,
5737 /// Path of the file being written to
5738 pub file_name: String,
5739 /// Human-readable description of the intended file change
5740 pub intention: String,
5741 /// Prompt kind discriminator
5742 pub kind: PermissionPromptRequestWriteKind,
5743 /// Whether managed policy requires a human response and forbids host auto-approval
5744 #[serde(skip_serializing_if = "Option::is_none")]
5745 pub managed_approval_required: Option<bool>,
5746 /// Complete new file contents for newly created files
5747 #[serde(skip_serializing_if = "Option::is_none")]
5748 pub new_file_contents: Option<String>,
5749 /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display fileName.
5750 ///
5751 /// <div class="warning">
5752 ///
5753 /// **Experimental.** This type is part of an experimental wire-protocol surface
5754 /// and may change or be removed in future SDK or CLI releases.
5755 ///
5756 /// </div>
5757 #[serde(skip_serializing_if = "Option::is_none")]
5758 pub resolved_path: Option<String>,
5759 /// Tool call ID that triggered this permission request
5760 #[serde(skip_serializing_if = "Option::is_none")]
5761 pub tool_call_id: Option<String>,
5762}
5763
5764/// File read permission prompt
5765#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5766#[serde(rename_all = "camelCase")]
5767pub struct PermissionPromptRequestRead {
5768 /// Assisted-approval judge information for this request; present only in assisted mode.
5769 ///
5770 /// <div class="warning">
5771 ///
5772 /// **Experimental.** This type is part of an experimental wire-protocol surface
5773 /// and may change or be removed in future SDK or CLI releases.
5774 ///
5775 /// </div>
5776 #[serde(skip_serializing_if = "Option::is_none")]
5777 pub assisted_approval: Option<PermissionAssistedApproval>,
5778 /// Human-readable description of why the file is being read
5779 pub intention: String,
5780 /// Prompt kind discriminator
5781 pub kind: PermissionPromptRequestReadKind,
5782 /// Whether managed policy requires a human response and forbids host auto-approval
5783 #[serde(skip_serializing_if = "Option::is_none")]
5784 pub managed_approval_required: Option<bool>,
5785 /// Path of the file or directory being read
5786 pub path: String,
5787 /// Runtime-resolved canonical path used for authorization identity checks. Internal and experimental; clients should continue to display path.
5788 ///
5789 /// <div class="warning">
5790 ///
5791 /// **Experimental.** This type is part of an experimental wire-protocol surface
5792 /// and may change or be removed in future SDK or CLI releases.
5793 ///
5794 /// </div>
5795 #[serde(skip_serializing_if = "Option::is_none")]
5796 pub resolved_path: Option<String>,
5797 /// Tool call ID that triggered this permission request
5798 #[serde(skip_serializing_if = "Option::is_none")]
5799 pub tool_call_id: Option<String>,
5800}
5801
5802/// MCP tool invocation permission prompt
5803#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5804#[serde(rename_all = "camelCase")]
5805pub struct PermissionPromptRequestMcp {
5806 /// Arguments to pass to the MCP tool
5807 #[serde(skip_serializing_if = "Option::is_none")]
5808 pub args: Option<serde_json::Value>,
5809 /// Assisted-approval judge information for this request; present only in assisted mode.
5810 ///
5811 /// <div class="warning">
5812 ///
5813 /// **Experimental.** This type is part of an experimental wire-protocol surface
5814 /// and may change or be removed in future SDK or CLI releases.
5815 ///
5816 /// </div>
5817 #[serde(skip_serializing_if = "Option::is_none")]
5818 pub assisted_approval: Option<PermissionAssistedApproval>,
5819 /// 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.
5820 #[serde(skip_serializing_if = "Option::is_none")]
5821 pub can_offer_server_wide_approval: Option<bool>,
5822 /// Prompt kind discriminator
5823 pub kind: PermissionPromptRequestMcpKind,
5824 /// Advisory runtime permission recommendation. The host remains responsible for deciding the request and may reject it.
5825 ///
5826 /// <div class="warning">
5827 ///
5828 /// **Experimental.** This type is part of an experimental wire-protocol surface
5829 /// and may change or be removed in future SDK or CLI releases.
5830 ///
5831 /// </div>
5832 #[serde(skip_serializing_if = "Option::is_none")]
5833 pub permission_recommendation: Option<PermissionRecommendation>,
5834 /// Name of the MCP server providing the tool
5835 pub server_name: String,
5836 /// Tool call ID that triggered this permission request
5837 #[serde(skip_serializing_if = "Option::is_none")]
5838 pub tool_call_id: Option<String>,
5839 /// Internal name of the MCP tool
5840 pub tool_name: String,
5841 /// Human-readable title of the MCP tool
5842 pub tool_title: String,
5843}
5844
5845/// URL access permission prompt
5846#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5847#[serde(rename_all = "camelCase")]
5848pub struct PermissionPromptRequestUrl {
5849 /// Assisted-approval judge information for this request; present only in assisted mode.
5850 ///
5851 /// <div class="warning">
5852 ///
5853 /// **Experimental.** This type is part of an experimental wire-protocol surface
5854 /// and may change or be removed in future SDK or CLI releases.
5855 ///
5856 /// </div>
5857 #[serde(skip_serializing_if = "Option::is_none")]
5858 pub assisted_approval: Option<PermissionAssistedApproval>,
5859 /// Human-readable description of why the URL is being accessed
5860 pub intention: String,
5861 /// Prompt kind discriminator
5862 pub kind: PermissionPromptRequestUrlKind,
5863 /// Whether managed policy requires a human response and forbids host auto-approval
5864 #[serde(skip_serializing_if = "Option::is_none")]
5865 pub managed_approval_required: Option<bool>,
5866 /// Immediately preceding URL when this prompt is for a redirect target
5867 #[serde(skip_serializing_if = "Option::is_none")]
5868 pub redirected_from: Option<String>,
5869 /// 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.
5870 #[serde(skip_serializing_if = "Option::is_none")]
5871 pub request_sandbox_bypass: Option<bool>,
5872 /// 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.
5873 #[serde(skip_serializing_if = "Option::is_none")]
5874 pub request_sandbox_bypass_reason: Option<String>,
5875 /// Tool call ID that triggered this permission request
5876 #[serde(skip_serializing_if = "Option::is_none")]
5877 pub tool_call_id: Option<String>,
5878 /// URL to be fetched
5879 pub url: String,
5880}
5881
5882/// Memory operation permission prompt
5883#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5884#[serde(rename_all = "camelCase")]
5885pub struct PermissionPromptRequestMemory {
5886 /// Whether this is a store or vote memory operation
5887 #[serde(skip_serializing_if = "Option::is_none")]
5888 pub action: Option<PermissionRequestMemoryAction>,
5889 /// Assisted-approval judge information for this request; present only in assisted mode.
5890 ///
5891 /// <div class="warning">
5892 ///
5893 /// **Experimental.** This type is part of an experimental wire-protocol surface
5894 /// and may change or be removed in future SDK or CLI releases.
5895 ///
5896 /// </div>
5897 #[serde(skip_serializing_if = "Option::is_none")]
5898 pub assisted_approval: Option<PermissionAssistedApproval>,
5899 /// Source references for the stored fact (store only)
5900 #[serde(skip_serializing_if = "Option::is_none")]
5901 pub citations: Option<String>,
5902 /// Vote direction (vote only)
5903 #[serde(skip_serializing_if = "Option::is_none")]
5904 pub direction: Option<PermissionRequestMemoryDirection>,
5905 /// The fact being stored or voted on
5906 pub fact: String,
5907 /// Prompt kind discriminator
5908 pub kind: PermissionPromptRequestMemoryKind,
5909 /// Reason for the vote (vote only)
5910 #[serde(skip_serializing_if = "Option::is_none")]
5911 pub reason: Option<String>,
5912 /// Topic or subject of the memory (store only)
5913 #[serde(skip_serializing_if = "Option::is_none")]
5914 pub subject: Option<String>,
5915 /// Tool call ID that triggered this permission request
5916 #[serde(skip_serializing_if = "Option::is_none")]
5917 pub tool_call_id: Option<String>,
5918}
5919
5920/// Custom tool invocation permission prompt
5921#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5922#[serde(rename_all = "camelCase")]
5923pub struct PermissionPromptRequestCustomTool {
5924 /// Arguments to pass to the custom tool
5925 #[serde(skip_serializing_if = "Option::is_none")]
5926 pub args: Option<serde_json::Value>,
5927 /// Assisted-approval judge information for this request; present only in assisted mode.
5928 ///
5929 /// <div class="warning">
5930 ///
5931 /// **Experimental.** This type is part of an experimental wire-protocol surface
5932 /// and may change or be removed in future SDK or CLI releases.
5933 ///
5934 /// </div>
5935 #[serde(skip_serializing_if = "Option::is_none")]
5936 pub assisted_approval: Option<PermissionAssistedApproval>,
5937 /// Prompt kind discriminator
5938 pub kind: PermissionPromptRequestCustomToolKind,
5939 /// Tool call ID that triggered this permission request
5940 #[serde(skip_serializing_if = "Option::is_none")]
5941 pub tool_call_id: Option<String>,
5942 /// Description of what the custom tool does
5943 pub tool_description: String,
5944 /// Name of the custom tool
5945 pub tool_name: String,
5946}
5947
5948/// Path access permission prompt
5949#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5950#[serde(rename_all = "camelCase")]
5951pub struct PermissionPromptRequestPath {
5952 /// Underlying permission kind that needs path approval
5953 pub access_kind: PermissionPromptRequestPathAccessKind,
5954 /// Assisted-approval judge information for this request; present only in assisted mode.
5955 ///
5956 /// <div class="warning">
5957 ///
5958 /// **Experimental.** This type is part of an experimental wire-protocol surface
5959 /// and may change or be removed in future SDK or CLI releases.
5960 ///
5961 /// </div>
5962 #[serde(skip_serializing_if = "Option::is_none")]
5963 pub assisted_approval: Option<PermissionAssistedApproval>,
5964 /// Prompt kind discriminator
5965 pub kind: PermissionPromptRequestPathKind,
5966 /// File paths that require explicit approval
5967 pub paths: Vec<String>,
5968 /// Tool call ID that triggered this permission request
5969 #[serde(skip_serializing_if = "Option::is_none")]
5970 pub tool_call_id: Option<String>,
5971}
5972
5973/// Hook confirmation permission prompt
5974#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5975#[serde(rename_all = "camelCase")]
5976pub struct PermissionPromptRequestHook {
5977 /// Assisted-approval judge information for this request; present only in assisted mode.
5978 ///
5979 /// <div class="warning">
5980 ///
5981 /// **Experimental.** This type is part of an experimental wire-protocol surface
5982 /// and may change or be removed in future SDK or CLI releases.
5983 ///
5984 /// </div>
5985 #[serde(skip_serializing_if = "Option::is_none")]
5986 pub assisted_approval: Option<PermissionAssistedApproval>,
5987 /// Optional message from the hook explaining why confirmation is needed
5988 #[serde(skip_serializing_if = "Option::is_none")]
5989 pub hook_message: Option<String>,
5990 /// Prompt kind discriminator
5991 pub kind: PermissionPromptRequestHookKind,
5992 /// Arguments of the tool call being gated
5993 #[serde(skip_serializing_if = "Option::is_none")]
5994 pub tool_args: Option<serde_json::Value>,
5995 /// Tool call ID that triggered this permission request
5996 #[serde(skip_serializing_if = "Option::is_none")]
5997 pub tool_call_id: Option<String>,
5998 /// Name of the tool the hook is gating
5999 pub tool_name: String,
6000}
6001
6002/// Extension management permission prompt
6003#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6004#[serde(rename_all = "camelCase")]
6005pub struct PermissionPromptRequestExtensionManagement {
6006 /// Assisted-approval judge information for this request; present only in assisted mode.
6007 ///
6008 /// <div class="warning">
6009 ///
6010 /// **Experimental.** This type is part of an experimental wire-protocol surface
6011 /// and may change or be removed in future SDK or CLI releases.
6012 ///
6013 /// </div>
6014 #[serde(skip_serializing_if = "Option::is_none")]
6015 pub assisted_approval: Option<PermissionAssistedApproval>,
6016 /// Name of the extension being managed
6017 #[serde(skip_serializing_if = "Option::is_none")]
6018 pub extension_name: Option<String>,
6019 /// Prompt kind discriminator
6020 pub kind: PermissionPromptRequestExtensionManagementKind,
6021 /// The extension management operation (scaffold, reload)
6022 pub operation: String,
6023 /// Tool call ID that triggered this permission request
6024 #[serde(skip_serializing_if = "Option::is_none")]
6025 pub tool_call_id: Option<String>,
6026}
6027
6028/// Factory run or authoring permission prompt
6029#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6030#[serde(rename_all = "camelCase")]
6031pub struct PermissionPromptRequestFactory {
6032 /// Canonical key used for scoped factory approvals
6033 pub approval_key: String,
6034 /// Assisted-approval judge information for this request; present only in assisted mode.
6035 ///
6036 /// <div class="warning">
6037 ///
6038 /// **Experimental.** This type is part of an experimental wire-protocol surface
6039 /// and may change or be removed in future SDK or CLI releases.
6040 ///
6041 /// </div>
6042 #[serde(skip_serializing_if = "Option::is_none")]
6043 pub assisted_approval: Option<PermissionAssistedApproval>,
6044 /// Whether this factory is eligible for persistent approval
6045 pub can_persist_approval: bool,
6046 /// Factory-declared AI-credit limit before any run/resume caller override is applied.
6047 #[serde(skip_serializing_if = "Option::is_none")]
6048 pub declared_max_ai_credits: Option<f64>,
6049 /// Factory-declared concurrent-subagent limit before any run/resume caller override is applied.
6050 #[serde(skip_serializing_if = "Option::is_none")]
6051 pub declared_max_concurrent_subagents: Option<i64>,
6052 /// Factory-declared total-subagent limit before any run/resume caller override is applied.
6053 #[serde(skip_serializing_if = "Option::is_none")]
6054 pub declared_max_total_subagents: Option<i64>,
6055 /// Factory-declared active-time limit in seconds before any run/resume caller override is applied.
6056 #[serde(skip_serializing_if = "Option::is_none")]
6057 pub declared_timeout_seconds: Option<f64>,
6058 /// Factory description
6059 pub description: String,
6060 /// Prompt kind discriminator
6061 pub kind: PermissionPromptRequestFactoryKind,
6062 /// Whether managed policy requires a human response and forbids host auto-approval
6063 #[serde(skip_serializing_if = "Option::is_none")]
6064 pub managed_approval_required: Option<bool>,
6065 /// Effective AI-credit limit; omitted means unlimited
6066 #[serde(skip_serializing_if = "Option::is_none")]
6067 pub max_ai_credits: Option<f64>,
6068 /// Effective concurrent-subagent limit; omitted means unlimited
6069 #[serde(skip_serializing_if = "Option::is_none")]
6070 pub max_concurrent_subagents: Option<i64>,
6071 /// Effective total-subagent limit; omitted means unlimited
6072 #[serde(skip_serializing_if = "Option::is_none")]
6073 pub max_total_subagents: Option<i64>,
6074 /// Factory name
6075 pub name: String,
6076 /// Factory operation, either run or author
6077 pub operation: FactoryPermissionOperation,
6078 /// Declared factory phases
6079 pub phases: Vec<FactoryPermissionPhase>,
6080 /// Effective active-time limit in seconds; omitted means unlimited
6081 #[serde(skip_serializing_if = "Option::is_none")]
6082 pub timeout_seconds: Option<f64>,
6083 /// Tool call ID that triggered this permission request
6084 #[serde(skip_serializing_if = "Option::is_none")]
6085 pub tool_call_id: Option<String>,
6086}
6087
6088/// Extension permission access prompt
6089#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6090#[serde(rename_all = "camelCase")]
6091pub struct PermissionPromptRequestExtensionPermissionAccess {
6092 /// Assisted-approval judge information for this request; present only in assisted mode.
6093 ///
6094 /// <div class="warning">
6095 ///
6096 /// **Experimental.** This type is part of an experimental wire-protocol surface
6097 /// and may change or be removed in future SDK or CLI releases.
6098 ///
6099 /// </div>
6100 #[serde(skip_serializing_if = "Option::is_none")]
6101 pub assisted_approval: Option<PermissionAssistedApproval>,
6102 /// Capabilities the extension is requesting
6103 pub capabilities: Vec<String>,
6104 /// Name of the extension requesting permission access
6105 pub extension_name: String,
6106 /// Prompt kind discriminator
6107 pub kind: PermissionPromptRequestExtensionPermissionAccessKind,
6108 /// Tool call ID that triggered this permission request
6109 #[serde(skip_serializing_if = "Option::is_none")]
6110 pub tool_call_id: Option<String>,
6111}
6112
6113/// Extension sensitive environment variable access prompt
6114#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6115#[serde(rename_all = "camelCase")]
6116pub struct PermissionPromptRequestExtensionEnvAccess {
6117 /// Assisted-approval judge information for this request; present only in assisted mode.
6118 ///
6119 /// <div class="warning">
6120 ///
6121 /// **Experimental.** This type is part of an experimental wire-protocol surface
6122 /// and may change or be removed in future SDK or CLI releases.
6123 ///
6124 /// </div>
6125 #[serde(skip_serializing_if = "Option::is_none")]
6126 pub assisted_approval: Option<PermissionAssistedApproval>,
6127 /// Names of the sensitive environment variables the extension is requesting. Values never appear here.
6128 pub environment_variables: Vec<String>,
6129 /// Name of the extension requesting environment variable access
6130 pub extension_name: String,
6131 /// Prompt kind discriminator
6132 pub kind: PermissionPromptRequestExtensionEnvAccessKind,
6133 /// Tool call ID that triggered this permission request
6134 #[serde(skip_serializing_if = "Option::is_none")]
6135 pub tool_call_id: Option<String>,
6136}
6137
6138/// Session event "permission.requested". Permission request notification requiring client approval with request details
6139#[derive(Debug, Clone, Serialize, Deserialize)]
6140#[serde(rename_all = "camelCase")]
6141pub struct PermissionRequestedData {
6142 /// Agent mode captured from the owning turn when permission evaluation began.
6143 #[serde(skip_serializing_if = "Option::is_none")]
6144 pub agent_mode: Option<SessionMode>,
6145 /// Permission mode captured when evaluation began. Absent on historical events.
6146 #[serde(skip_serializing_if = "Option::is_none")]
6147 pub permission_mode: Option<PermissionMode>,
6148 /// Details of the permission being requested
6149 pub permission_request: PermissionRequest,
6150 /// Derived user-facing permission prompt details for UI consumers
6151 #[serde(skip_serializing_if = "Option::is_none")]
6152 pub prompt_request: Option<PermissionPromptRequest>,
6153 /// Permission-recovery episode that authorized this request to surface for interactive attention
6154 #[serde(skip_serializing_if = "Option::is_none")]
6155 pub recovery_episode_id: Option<String>,
6156 /// Unique identifier for this permission request; used to respond via session.respondToPermission()
6157 pub request_id: RequestId,
6158 /// When true, this permission was already resolved by a permissionRequest hook and requires no client action
6159 #[serde(skip_serializing_if = "Option::is_none")]
6160 pub resolved_by_hook: Option<bool>,
6161 /// Neutral risk metadata supplied by the tool host. Consumers may display this value but must not use it to bypass the permission decision.
6162 #[serde(skip_serializing_if = "Option::is_none")]
6163 pub risk_assessment: Option<serde_json::Value>,
6164}
6165
6166/// Permission response variant indicating the request was approved without persisting an approval rule.
6167#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6168#[serde(rename_all = "camelCase")]
6169pub struct PermissionApproved {
6170 /// The permission request was approved
6171 pub kind: PermissionApprovedKind,
6172 /// Whether a managed approval policy already handled this request
6173 #[serde(skip_serializing_if = "Option::is_none")]
6174 pub managed_approval_handled: Option<bool>,
6175}
6176
6177/// Session-scoped tool-approval rule for specific shell command identifiers.
6178#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6179#[serde(rename_all = "camelCase")]
6180pub struct UserToolSessionApprovalCommands {
6181 /// Command identifiers approved by the user
6182 pub command_identifiers: Vec<String>,
6183 /// Command approval kind
6184 pub kind: UserToolSessionApprovalCommandsKind,
6185}
6186
6187/// Session-scoped tool-approval rule for read-only filesystem operations.
6188#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6189#[serde(rename_all = "camelCase")]
6190pub struct UserToolSessionApprovalRead {
6191 /// Read approval kind
6192 pub kind: UserToolSessionApprovalReadKind,
6193}
6194
6195/// Session-scoped tool-approval rule for filesystem write operations.
6196#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6197#[serde(rename_all = "camelCase")]
6198pub struct UserToolSessionApprovalWrite {
6199 /// Write approval kind
6200 pub kind: UserToolSessionApprovalWriteKind,
6201}
6202
6203/// Session-scoped tool-approval rule for an MCP server tool, or all tools on the server when `toolName` is null.
6204#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6205#[serde(rename_all = "camelCase")]
6206pub struct UserToolSessionApprovalMcp {
6207 /// MCP tool approval kind
6208 pub kind: UserToolSessionApprovalMcpKind,
6209 /// MCP server name
6210 pub server_name: String,
6211 /// Optional MCP tool name, or null for all tools on the server
6212 pub tool_name: Option<String>,
6213}
6214
6215/// Session-scoped tool-approval rule for writes to long-term memory.
6216#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6217#[serde(rename_all = "camelCase")]
6218pub struct UserToolSessionApprovalMemory {
6219 /// Memory approval kind
6220 pub kind: UserToolSessionApprovalMemoryKind,
6221}
6222
6223/// Session-scoped tool-approval rule for a custom tool, keyed by tool name.
6224#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6225#[serde(rename_all = "camelCase")]
6226pub struct UserToolSessionApprovalCustomTool {
6227 /// Custom tool approval kind
6228 pub kind: UserToolSessionApprovalCustomToolKind,
6229 /// Custom tool name
6230 pub tool_name: String,
6231}
6232
6233/// Session-scoped tool-approval rule for extension-management operations, optionally narrowed by operation.
6234#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6235#[serde(rename_all = "camelCase")]
6236pub struct UserToolSessionApprovalExtensionManagement {
6237 /// Extension management approval kind
6238 pub kind: UserToolSessionApprovalExtensionManagementKind,
6239 /// Optional operation identifier
6240 #[serde(skip_serializing_if = "Option::is_none")]
6241 pub operation: Option<String>,
6242}
6243
6244/// Session-scoped factory approval, optionally narrowed by approval key.
6245#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6246#[serde(rename_all = "camelCase")]
6247pub struct UserToolSessionApprovalFactory {
6248 /// Optional factory operation name or canonical approval key
6249 #[serde(skip_serializing_if = "Option::is_none")]
6250 pub approval_key: Option<String>,
6251 /// Factory approval kind
6252 pub kind: UserToolSessionApprovalFactoryKind,
6253}
6254
6255/// Session-scoped tool-approval rule for an extension's permission-gated capability access, keyed by extension name.
6256#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6257#[serde(rename_all = "camelCase")]
6258pub struct UserToolSessionApprovalExtensionPermissionAccess {
6259 /// Extension name
6260 pub extension_name: String,
6261 /// Extension permission access approval kind
6262 pub kind: UserToolSessionApprovalExtensionPermissionAccessKind,
6263}
6264
6265/// 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.
6266#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6267#[serde(rename_all = "camelCase")]
6268pub struct UserToolSessionApprovalExtensionEnvAccess {
6269 /// Names of the sensitive environment variables this approval covers. Values are never persisted.
6270 pub environment_variables: Vec<String>,
6271 /// Extension name
6272 pub extension_name: String,
6273 /// Extension environment access approval kind
6274 pub kind: UserToolSessionApprovalExtensionEnvAccessKind,
6275}
6276
6277/// Permission response variant that approves a request and remembers the provided approval for the rest of the session.
6278#[derive(Debug, Clone, Serialize, Deserialize)]
6279#[serde(rename_all = "camelCase")]
6280pub struct PermissionApprovedForSession {
6281 /// The approval to add as a session-scoped rule
6282 pub approval: UserToolSessionApproval,
6283 /// Approved and remembered for the rest of the session
6284 pub kind: PermissionApprovedForSessionKind,
6285 /// Whether a managed approval policy already handled this request
6286 #[serde(skip_serializing_if = "Option::is_none")]
6287 pub managed_approval_handled: Option<bool>,
6288}
6289
6290/// Permission response variant that approves a request and persists the provided approval to a project location key.
6291#[derive(Debug, Clone, Serialize, Deserialize)]
6292#[serde(rename_all = "camelCase")]
6293pub struct PermissionApprovedForLocation {
6294 /// The approval to persist for this location
6295 pub approval: UserToolSessionApproval,
6296 /// Approved and persisted for this project location
6297 pub kind: PermissionApprovedForLocationKind,
6298 /// The location key (git root or cwd) to persist the approval to
6299 pub location_key: String,
6300 /// Whether a managed approval policy already handled this request
6301 #[serde(skip_serializing_if = "Option::is_none")]
6302 pub managed_approval_handled: Option<bool>,
6303}
6304
6305/// Permission response variant indicating the request was cancelled before use, with an optional reason.
6306#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6307#[serde(rename_all = "camelCase")]
6308pub struct PermissionCancelled {
6309 /// The permission request was cancelled before a response was used
6310 pub kind: PermissionCancelledKind,
6311 /// Optional explanation of why the request was cancelled
6312 #[serde(skip_serializing_if = "Option::is_none")]
6313 pub reason: Option<String>,
6314}
6315
6316/// A permission approval or denial rule matched against a tool request, identified by a rule kind with an optional argument value.
6317#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6318#[serde(rename_all = "camelCase")]
6319pub struct PermissionRule {
6320 /// Argument value matched against the request, or null when the rule kind has no argument (e.g. 'read', 'write', 'memory').
6321 pub argument: Option<String>,
6322 /// The rule kind, such as Shell or GitHubMCP
6323 pub kind: String,
6324}
6325
6326/// Permission response variant denied because matching approval rules explicitly blocked the request.
6327#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6328#[serde(rename_all = "camelCase")]
6329pub struct PermissionDeniedByRules {
6330 /// Denied because approval rules explicitly blocked it
6331 pub kind: PermissionDeniedByRulesKind,
6332 /// Rules that denied the request
6333 pub rules: Vec<PermissionRule>,
6334}
6335
6336/// Permission response variant denied because no approval rule matched and user confirmation was unavailable.
6337#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6338#[serde(rename_all = "camelCase")]
6339pub struct PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
6340 /// Denied because no approval rule matched and user confirmation was unavailable
6341 pub kind: PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind,
6342}
6343
6344/// Permission response variant denied in an interactive user prompt, with optional feedback and force-reject flag.
6345#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6346#[serde(rename_all = "camelCase")]
6347pub struct PermissionDeniedInteractivelyByUser {
6348 /// Optional feedback from the user explaining the denial
6349 #[serde(skip_serializing_if = "Option::is_none")]
6350 pub feedback: Option<String>,
6351 /// Whether to force-reject the current agent turn
6352 #[serde(skip_serializing_if = "Option::is_none")]
6353 pub force_reject: Option<bool>,
6354 /// Denied by the user during an interactive prompt
6355 pub kind: PermissionDeniedInteractivelyByUserKind,
6356}
6357
6358/// Permission response variant denying a path under content exclusion policy, with the path and message.
6359#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6360#[serde(rename_all = "camelCase")]
6361pub struct PermissionDeniedByContentExclusionPolicy {
6362 /// Denied by the organization's content exclusion policy
6363 pub kind: PermissionDeniedByContentExclusionPolicyKind,
6364 /// Human-readable explanation of why the path was excluded
6365 pub message: String,
6366 /// File path that triggered the exclusion
6367 pub path: String,
6368}
6369
6370/// Permission response variant denied by a permission-request hook, with optional message and interrupt flag.
6371#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6372#[serde(rename_all = "camelCase")]
6373pub struct PermissionDeniedByPermissionRequestHook {
6374 /// Whether to interrupt the current agent turn
6375 #[serde(skip_serializing_if = "Option::is_none")]
6376 pub interrupt: Option<bool>,
6377 /// Denied by a permission request hook registered by an extension or plugin
6378 pub kind: PermissionDeniedByPermissionRequestHookKind,
6379 /// Optional message from the hook explaining the denial
6380 #[serde(skip_serializing_if = "Option::is_none")]
6381 pub message: Option<String>,
6382}
6383
6384/// Session event "permission.completed". Permission request completion notification signaling UI dismissal
6385#[derive(Debug, Clone, Serialize, Deserialize)]
6386#[serde(rename_all = "camelCase")]
6387pub struct PermissionCompletedData {
6388 /// Atomic structured blocked outcome when this permission response ended an Autopilot recovery episode unsuccessfully
6389 #[serde(skip_serializing_if = "Option::is_none")]
6390 pub blocker: Option<TaskBlocker>,
6391 /// 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.
6392 ///
6393 /// <div class="warning">
6394 ///
6395 /// **Experimental.** This type is part of an experimental wire-protocol surface
6396 /// and may change or be removed in future SDK or CLI releases.
6397 ///
6398 /// </div>
6399 #[serde(skip_serializing_if = "Option::is_none")]
6400 pub decision_source: Option<PermissionDecisionSource>,
6401 /// Permission-recovery episode settled by this response, when the request was escalated by Autopilot
6402 #[serde(skip_serializing_if = "Option::is_none")]
6403 pub recovery_episode_id: Option<String>,
6404 /// Request ID of the resolved permission request; clients should dismiss any UI for this request
6405 pub request_id: RequestId,
6406 /// The result of the permission request
6407 pub result: PermissionResult,
6408 /// Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
6409 #[serde(skip_serializing_if = "Option::is_none")]
6410 pub tool_call_id: Option<String>,
6411}
6412
6413/// 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.
6414///
6415/// <div class="warning">
6416///
6417/// **Experimental.** This type is part of an experimental wire-protocol surface
6418/// and may change or be removed in future SDK or CLI releases.
6419///
6420/// </div>
6421#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6422#[serde(rename_all = "camelCase")]
6423pub struct PermissionCarriedForwardData {
6424 /// Always `authorization_carry_forward`. Stated explicitly so a consumer reading this event cannot mistake it for a human, host-policy, or assisted-approval decision.
6425 ///
6426 /// <div class="warning">
6427 ///
6428 /// **Experimental.** This type is part of an experimental wire-protocol surface
6429 /// and may change or be removed in future SDK or CLI releases.
6430 ///
6431 /// </div>
6432 pub decision_source: PermissionDecisionSource,
6433 /// Identity of the prior authorization record that contained the proposal.
6434 ///
6435 /// <div class="warning">
6436 ///
6437 /// **Experimental.** This type is part of an experimental wire-protocol surface
6438 /// and may change or be removed in future SDK or CLI releases.
6439 ///
6440 /// </div>
6441 pub record_id: String,
6442 /// Authorization edge minted for this admission. Not a prompt id: no prompt was raised, so no client should expect a request with this id.
6443 ///
6444 /// <div class="warning">
6445 ///
6446 /// **Experimental.** This type is part of an experimental wire-protocol surface
6447 /// and may change or be removed in future SDK or CLI releases.
6448 ///
6449 /// </div>
6450 pub request_id: RequestId,
6451 /// 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.
6452 ///
6453 /// <div class="warning">
6454 ///
6455 /// **Experimental.** This type is part of an experimental wire-protocol surface
6456 /// and may change or be removed in future SDK or CLI releases.
6457 ///
6458 /// </div>
6459 pub tool_call_id: String,
6460}
6461
6462/// 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.
6463///
6464/// <div class="warning">
6465///
6466/// **Experimental.** This type is part of an experimental wire-protocol surface
6467/// and may change or be removed in future SDK or CLI releases.
6468///
6469/// </div>
6470#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6471#[serde(rename_all = "camelCase")]
6472pub struct PermissionMessageAuthorizationData {
6473 /// The kind of effect authorized, as an action-class identifier.
6474 ///
6475 /// <div class="warning">
6476 ///
6477 /// **Experimental.** This type is part of an experimental wire-protocol surface
6478 /// and may change or be removed in future SDK or CLI releases.
6479 ///
6480 /// </div>
6481 pub action_class: String,
6482 /// Whether the claim granted or denied authority.
6483 ///
6484 /// <div class="warning">
6485 ///
6486 /// **Experimental.** This type is part of an experimental wire-protocol surface
6487 /// and may change or be removed in future SDK or CLI releases.
6488 ///
6489 /// </div>
6490 pub polarity: PermissionMessageAuthorizationPolarity,
6491 /// Deterministic identity of the record, derived from the turn and span offsets so re-extracting the same span mints nothing new.
6492 ///
6493 /// <div class="warning">
6494 ///
6495 /// **Experimental.** This type is part of an experimental wire-protocol surface
6496 /// and may change or be removed in future SDK or CLI releases.
6497 ///
6498 /// </div>
6499 pub record_id: String,
6500 /// End byte offset of the authorizing span within the turn.
6501 ///
6502 /// <div class="warning">
6503 ///
6504 /// **Experimental.** This type is part of an experimental wire-protocol surface
6505 /// and may change or be removed in future SDK or CLI releases.
6506 ///
6507 /// </div>
6508 pub span_end: i64,
6509 /// Start byte offset of the authorizing span within the turn.
6510 ///
6511 /// <div class="warning">
6512 ///
6513 /// **Experimental.** This type is part of an experimental wire-protocol surface
6514 /// and may change or be removed in future SDK or CLI releases.
6515 ///
6516 /// </div>
6517 pub span_start: i64,
6518 /// Concrete named targets that appear verbatim inside the span.
6519 ///
6520 /// <div class="warning">
6521 ///
6522 /// **Experimental.** This type is part of an experimental wire-protocol surface
6523 /// and may change or be removed in future SDK or CLI releases.
6524 ///
6525 /// </div>
6526 #[serde(skip_serializing_if = "Option::is_none")]
6527 pub target_members: Option<Vec<String>>,
6528 /// The task the permission is scoped to, when the human named one.
6529 ///
6530 /// <div class="warning">
6531 ///
6532 /// **Experimental.** This type is part of an experimental wire-protocol surface
6533 /// and may change or be removed in future SDK or CLI releases.
6534 ///
6535 /// </div>
6536 #[serde(skip_serializing_if = "Option::is_none")]
6537 pub task: Option<String>,
6538 /// The human turn the quoted span was read from.
6539 ///
6540 /// <div class="warning">
6541 ///
6542 /// **Experimental.** This type is part of an experimental wire-protocol surface
6543 /// and may change or be removed in future SDK or CLI releases.
6544 ///
6545 /// </div>
6546 pub turn_index: i64,
6547 /// 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.
6548 ///
6549 /// <div class="warning">
6550 ///
6551 /// **Experimental.** This type is part of an experimental wire-protocol surface
6552 /// and may change or be removed in future SDK or CLI releases.
6553 ///
6554 /// </div>
6555 #[serde(skip_serializing_if = "Option::is_none")]
6556 pub world: Option<serde_json::Value>,
6557}
6558
6559/// 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.
6560///
6561/// <div class="warning">
6562///
6563/// **Experimental.** This type is part of an experimental wire-protocol surface
6564/// and may change or be removed in future SDK or CLI releases.
6565///
6566/// </div>
6567#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6568#[serde(rename_all = "camelCase")]
6569pub struct PermissionMessageAuthorizationReadData {
6570 /// 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.
6571 ///
6572 /// <div class="warning">
6573 ///
6574 /// **Experimental.** This type is part of an experimental wire-protocol surface
6575 /// and may change or be removed in future SDK or CLI releases.
6576 ///
6577 /// </div>
6578 #[serde(skip_serializing_if = "Option::is_none")]
6579 pub activates_extraction: Option<bool>,
6580 /// The human turn that was read by the proposer.
6581 ///
6582 /// <div class="warning">
6583 ///
6584 /// **Experimental.** This type is part of an experimental wire-protocol surface
6585 /// and may change or be removed in future SDK or CLI releases.
6586 ///
6587 /// </div>
6588 pub turn_index: i64,
6589}
6590
6591/// 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.
6592///
6593/// <div class="warning">
6594///
6595/// **Experimental.** This type is part of an experimental wire-protocol surface
6596/// and may change or be removed in future SDK or CLI releases.
6597///
6598/// </div>
6599#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6600#[serde(rename_all = "camelCase")]
6601pub struct PermissionMessageAuthorizationDegradedData {
6602 /// The human turn that could not be represented safely.
6603 ///
6604 /// <div class="warning">
6605 ///
6606 /// **Experimental.** This type is part of an experimental wire-protocol surface
6607 /// and may change or be removed in future SDK or CLI releases.
6608 ///
6609 /// </div>
6610 pub turn_index: i64,
6611}
6612
6613/// 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.
6614///
6615/// <div class="warning">
6616///
6617/// **Experimental.** This type is part of an experimental wire-protocol surface
6618/// and may change or be removed in future SDK or CLI releases.
6619///
6620/// </div>
6621#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6622#[serde(rename_all = "camelCase")]
6623pub struct PermissionAssentDetectedData {
6624 /// 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.
6625 ///
6626 /// <div class="warning">
6627 ///
6628 /// **Experimental.** This type is part of an experimental wire-protocol surface
6629 /// and may change or be removed in future SDK or CLI releases.
6630 ///
6631 /// </div>
6632 pub request_id: RequestId,
6633 /// Human turn whose text triggered the deterministic assent recognizer.
6634 ///
6635 /// <div class="warning">
6636 ///
6637 /// **Experimental.** This type is part of an experimental wire-protocol surface
6638 /// and may change or be removed in future SDK or CLI releases.
6639 ///
6640 /// </div>
6641 pub turn_index: i64,
6642}
6643
6644/// 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.
6645///
6646/// <div class="warning">
6647///
6648/// **Experimental.** This type is part of an experimental wire-protocol surface
6649/// and may change or be removed in future SDK or CLI releases.
6650///
6651/// </div>
6652#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6653#[serde(rename_all = "camelCase")]
6654pub struct PermissionContextualAuthorizationData {
6655 /// Whether the contextual human span granted or denied authority.
6656 ///
6657 /// <div class="warning">
6658 ///
6659 /// **Experimental.** This type is part of an experimental wire-protocol surface
6660 /// and may change or be removed in future SDK or CLI releases.
6661 ///
6662 /// </div>
6663 pub polarity: PermissionMessageAuthorizationPolarity,
6664 /// Deterministic identity of the contextual message grant.
6665 ///
6666 /// <div class="warning">
6667 ///
6668 /// **Experimental.** This type is part of an experimental wire-protocol surface
6669 /// and may change or be removed in future SDK or CLI releases.
6670 ///
6671 /// </div>
6672 pub record_id: String,
6673 /// Original blocked permission request selected by deterministic event ordering, never by the extraction model.
6674 ///
6675 /// <div class="warning">
6676 ///
6677 /// **Experimental.** This type is part of an experimental wire-protocol surface
6678 /// and may change or be removed in future SDK or CLI releases.
6679 ///
6680 /// </div>
6681 pub request_id: RequestId,
6682 /// End byte offset of the contextual decision span within the turn.
6683 ///
6684 /// <div class="warning">
6685 ///
6686 /// **Experimental.** This type is part of an experimental wire-protocol surface
6687 /// and may change or be removed in future SDK or CLI releases.
6688 ///
6689 /// </div>
6690 pub span_end: i64,
6691 /// Start byte offset of the contextual decision span within the turn.
6692 ///
6693 /// <div class="warning">
6694 ///
6695 /// **Experimental.** This type is part of an experimental wire-protocol surface
6696 /// and may change or be removed in future SDK or CLI releases.
6697 ///
6698 /// </div>
6699 pub span_start: i64,
6700 /// Human turn containing the contextual decision.
6701 ///
6702 /// <div class="warning">
6703 ///
6704 /// **Experimental.** This type is part of an experimental wire-protocol surface
6705 /// and may change or be removed in future SDK or CLI releases.
6706 ///
6707 /// </div>
6708 pub turn_index: i64,
6709}
6710
6711/// Session event "user_input.requested". User input request notification with question and optional predefined choices
6712#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6713#[serde(rename_all = "camelCase")]
6714pub struct UserInputRequestedData {
6715 /// Whether the user can provide a free-form text response in addition to predefined choices
6716 #[serde(skip_serializing_if = "Option::is_none")]
6717 pub allow_freeform: Option<bool>,
6718 /// Predefined choices for the user to select from, if applicable
6719 #[serde(skip_serializing_if = "Option::is_none")]
6720 pub choices: Option<Vec<String>>,
6721 /// The question or prompt to present to the user
6722 pub question: String,
6723 /// Unique identifier for this input request; used to respond via session.respondToUserInput()
6724 pub request_id: RequestId,
6725 /// The LLM-assigned tool call ID that triggered this request; used by remote UIs to correlate responses
6726 #[serde(skip_serializing_if = "Option::is_none")]
6727 pub tool_call_id: Option<String>,
6728}
6729
6730/// Session event "user_input.completed". User input request completion with the user's response
6731#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6732#[serde(rename_all = "camelCase")]
6733pub struct UserInputCompletedData {
6734 /// The user's answer to the input request
6735 #[serde(skip_serializing_if = "Option::is_none")]
6736 pub answer: Option<String>,
6737 /// Request ID of the resolved user input request; clients should dismiss any UI for this request
6738 pub request_id: RequestId,
6739 /// Whether the answer was typed as free-form text rather than selected from choices
6740 #[serde(skip_serializing_if = "Option::is_none")]
6741 pub was_freeform: Option<bool>,
6742}
6743
6744/// JSON Schema describing the form fields to present to the user (form mode only)
6745#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6746#[serde(rename_all = "camelCase")]
6747pub struct ElicitationRequestedSchema {
6748 /// Form field definitions, keyed by field name
6749 pub properties: HashMap<String, serde_json::Value>,
6750 /// List of required field names
6751 #[serde(skip_serializing_if = "Option::is_none")]
6752 pub required: Option<Vec<String>>,
6753 /// Schema type indicator (always 'object')
6754 pub r#type: ElicitationRequestedSchemaType,
6755}
6756
6757/// Session event "elicitation.requested". Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
6758#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6759#[serde(rename_all = "camelCase")]
6760pub struct ElicitationRequestedData {
6761 /// The source that initiated the request (MCP server name, or absent for agent-initiated)
6762 #[serde(skip_serializing_if = "Option::is_none")]
6763 pub elicitation_source: Option<String>,
6764 /// Message describing what information is needed from the user
6765 pub message: String,
6766 /// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
6767 #[serde(skip_serializing_if = "Option::is_none")]
6768 pub mode: Option<ElicitationRequestedMode>,
6769 /// JSON Schema describing the form fields to present to the user (form mode only)
6770 #[serde(skip_serializing_if = "Option::is_none")]
6771 pub requested_schema: Option<ElicitationRequestedSchema>,
6772 /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation()
6773 pub request_id: RequestId,
6774 /// Tool call ID from the LLM completion; used to correlate with CompletionChunk.toolCall.id for remote UIs
6775 #[serde(skip_serializing_if = "Option::is_none")]
6776 pub tool_call_id: Option<String>,
6777 /// URL to open in the user's browser (url mode only)
6778 #[serde(skip_serializing_if = "Option::is_none")]
6779 pub url: Option<String>,
6780}
6781
6782/// Session event "elicitation.completed". Elicitation request completion with the user's response
6783#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6784#[serde(rename_all = "camelCase")]
6785pub struct ElicitationCompletedData {
6786 /// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
6787 #[serde(skip_serializing_if = "Option::is_none")]
6788 pub action: Option<ElicitationCompletedAction>,
6789 /// The submitted form data when action is 'accept'; keys match the requested schema fields
6790 #[serde(skip_serializing_if = "Option::is_none")]
6791 pub content: Option<HashMap<String, serde_json::Value>>,
6792 /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request
6793 pub request_id: RequestId,
6794}
6795
6796/// Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
6797#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6798#[serde(rename_all = "camelCase")]
6799pub struct SamplingRequestedData {
6800 /// The JSON-RPC request ID from the MCP protocol
6801 pub mcp_request_id: serde_json::Value,
6802 /// Unique identifier for this sampling request; used to respond via session.respondToSampling()
6803 pub request_id: RequestId,
6804 /// Name of the MCP server that initiated the sampling request
6805 pub server_name: String,
6806}
6807
6808/// Session event "sampling.completed". Sampling request completion notification signaling UI dismissal
6809#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6810#[serde(rename_all = "camelCase")]
6811pub struct SamplingCompletedData {
6812 /// Request ID of the resolved sampling request; clients should dismiss any UI for this request
6813 pub request_id: RequestId,
6814}
6815
6816/// Single HTTP header entry as a name/value pair.
6817#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6818#[serde(rename_all = "camelCase")]
6819pub struct HeaderEntry {
6820 /// HTTP response header name as observed by the runtime.
6821 pub name: String,
6822 /// HTTP response header value as observed by the runtime.
6823 pub value: String,
6824}
6825
6826/// Raw HTTP response details from the OAuth auth challenge, as observed by the runtime.
6827#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6828#[serde(rename_all = "camelCase")]
6829pub struct McpOauthHttpResponse {
6830 /// 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.
6831 #[serde(skip_serializing_if = "Option::is_none")]
6832 pub body: Option<String>,
6833 /// HTTP response headers as observed by the runtime. Order and casing are transport-dependent, and duplicate header names may appear multiple times.
6834 pub headers: Vec<HeaderEntry>,
6835 /// HTTP status code returned with the auth challenge.
6836 pub status_code: i32,
6837}
6838
6839/// Static OAuth client configuration, if the server specifies one
6840#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6841#[serde(rename_all = "camelCase")]
6842pub struct McpOauthRequiredStaticClientConfig {
6843 /// OAuth client ID for the server
6844 pub client_id: String,
6845 /// Optional OAuth client secret for confidential static clients, when the runtime can resolve one
6846 #[serde(skip_serializing_if = "Option::is_none")]
6847 pub client_secret: Option<String>,
6848 /// 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).
6849 #[serde(skip_serializing_if = "Option::is_none")]
6850 pub grant_type: Option<McpOauthRequiredStaticClientConfigGrantType>,
6851 /// Whether this is a public OAuth client
6852 #[serde(skip_serializing_if = "Option::is_none")]
6853 pub public_client: Option<bool>,
6854}
6855
6856/// OAuth WWW-Authenticate parameters parsed from an MCP auth challenge
6857#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6858#[serde(rename_all = "camelCase")]
6859pub struct McpOauthWWWAuthenticateParams {
6860 /// OAuth error from the WWW-Authenticate error parameter, if present
6861 #[serde(skip_serializing_if = "Option::is_none")]
6862 pub error: Option<String>,
6863 /// Protected resource metadata URL from the WWW-Authenticate resource_metadata parameter, if present
6864 #[serde(skip_serializing_if = "Option::is_none")]
6865 pub resource_metadata_url: Option<String>,
6866 /// Requested OAuth scopes from the WWW-Authenticate scope parameter, if present
6867 #[serde(skip_serializing_if = "Option::is_none")]
6868 pub scope: Option<String>,
6869}
6870
6871/// Session event "mcp.oauth_required". OAuth authentication request for an MCP server
6872#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6873#[serde(rename_all = "camelCase")]
6874pub struct McpOauthRequiredData {
6875 /// 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.
6876 #[serde(skip_serializing_if = "Option::is_none")]
6877 pub http_response: Option<McpOauthHttpResponse>,
6878 /// Why the runtime is requesting host-provided OAuth credentials.
6879 pub reason: McpOauthRequestReason,
6880 /// Unique identifier for this OAuth request; used to respond via session.mcp.oauth.handlePendingRequest
6881 pub request_id: RequestId,
6882 /// Raw OAuth protected-resource metadata document fetched for the MCP server, if available
6883 #[serde(skip_serializing_if = "Option::is_none")]
6884 pub resource_metadata: Option<String>,
6885 /// Display name of the MCP server that requires OAuth
6886 pub server_name: String,
6887 /// URL of the MCP server that requires OAuth
6888 pub server_url: String,
6889 /// Static OAuth client configuration, if the server specifies one
6890 #[serde(skip_serializing_if = "Option::is_none")]
6891 pub static_client_config: Option<McpOauthRequiredStaticClientConfig>,
6892 /// OAuth WWW-Authenticate parameters parsed from the auth challenge, if available
6893 #[serde(skip_serializing_if = "Option::is_none")]
6894 pub www_authenticate_params: Option<McpOauthWWWAuthenticateParams>,
6895}
6896
6897/// Session event "mcp.oauth_completed". MCP OAuth request completion notification
6898#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6899#[serde(rename_all = "camelCase")]
6900pub struct McpOauthCompletedData {
6901 /// How the pending OAuth request was completed
6902 pub outcome: McpOauthCompletionOutcome,
6903 /// Request ID of the resolved OAuth request
6904 pub request_id: RequestId,
6905}
6906
6907/// Session event "mcp.headers_refresh_required". Dynamic headers refresh request for a remote MCP server
6908#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6909#[serde(rename_all = "camelCase")]
6910pub struct McpHeadersRefreshRequiredData {
6911 /// Why dynamic headers are being requested.
6912 pub reason: McpHeadersRefreshRequiredReason,
6913 /// Unique identifier for this headers refresh request; used to respond via session.mcp.headers.handlePendingHeadersRefreshRequest()
6914 pub request_id: RequestId,
6915 /// Display name of the remote MCP server requesting headers
6916 pub server_name: String,
6917 /// URL of the remote MCP server requesting headers
6918 pub server_url: String,
6919}
6920
6921/// Session event "mcp.headers_refresh_completed". MCP headers refresh request completion notification
6922#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6923#[serde(rename_all = "camelCase")]
6924pub struct McpHeadersRefreshCompletedData {
6925 /// How the pending MCP headers refresh request resolved.
6926 pub outcome: McpHeadersRefreshCompletedOutcome,
6927 /// Request ID of the resolved headers refresh request
6928 pub request_id: RequestId,
6929}
6930
6931/// Session event "session.custom_notification". Opaque custom notification data. Consumers may branch on source and name, but payload semantics are source-defined.
6932#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6933#[serde(rename_all = "camelCase")]
6934pub struct SessionCustomNotificationData {
6935 /// Source-defined custom notification name
6936 pub name: String,
6937 /// Source-defined JSON payload for the custom notification
6938 pub payload: serde_json::Value,
6939 /// Namespace for the custom notification producer
6940 pub source: String,
6941 /// Optional source-defined string identifiers describing the payload subject
6942 #[serde(skip_serializing_if = "Option::is_none")]
6943 pub subject: Option<HashMap<String, String>>,
6944 /// Optional source-defined payload schema version
6945 #[serde(skip_serializing_if = "Option::is_none")]
6946 pub version: Option<i64>,
6947}
6948
6949/// Session event "ui.ephemeral_query". Ordered output and terminal state for a transient query that does not modify conversation history.
6950///
6951/// <div class="warning">
6952///
6953/// **Experimental.** This type is part of an experimental wire-protocol surface
6954/// and may change or be removed in future SDK or CLI releases.
6955///
6956/// </div>
6957#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6958#[serde(rename_all = "camelCase")]
6959pub struct UiEphemeralQueryData {
6960 /// Full response text, present for the `completed` phase.
6961 #[serde(skip_serializing_if = "Option::is_none")]
6962 pub answer: Option<String>,
6963 /// Ordered text delta, present for the `chunk` phase.
6964 #[serde(skip_serializing_if = "Option::is_none")]
6965 pub chunk: Option<String>,
6966 /// Model or transport failure message, present for the `failed` phase.
6967 #[serde(skip_serializing_if = "Option::is_none")]
6968 pub error: Option<String>,
6969 /// Current query lifecycle phase.
6970 pub phase: UIEphemeralQueryPhase,
6971 /// Runtime-minted query identifier.
6972 pub request_id: RequestId,
6973}
6974
6975/// Session event "external_tool.requested". External tool invocation request for client-side tool execution
6976#[derive(Debug, Clone, Default, Serialize, Deserialize)]
6977#[serde(rename_all = "camelCase")]
6978pub struct ExternalToolRequestedData {
6979 /// Arguments to pass to the external tool
6980 #[serde(skip_serializing_if = "Option::is_none")]
6981 pub arguments: Option<serde_json::Value>,
6982 /// 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
6983 #[serde(skip_serializing_if = "Option::is_none")]
6984 pub provider_id: Option<String>,
6985 /// Unique identifier for this request; used to respond via session.respondToExternalTool()
6986 pub request_id: RequestId,
6987 /// Session ID that this external tool request belongs to
6988 pub session_id: SessionId,
6989 /// Tool call ID assigned to this external tool invocation
6990 pub tool_call_id: String,
6991 /// Name of the external tool to invoke
6992 pub tool_name: String,
6993 /// W3C Trace Context traceparent header for the execute_tool span
6994 #[serde(skip_serializing_if = "Option::is_none")]
6995 pub traceparent: Option<String>,
6996 /// W3C Trace Context tracestate header for the execute_tool span
6997 #[serde(skip_serializing_if = "Option::is_none")]
6998 pub tracestate: Option<String>,
6999 /// Active session working directory, when known.
7000 #[serde(skip_serializing_if = "Option::is_none")]
7001 pub working_directory: Option<String>,
7002}
7003
7004/// Session event "external_tool.completed". External tool completion notification signaling UI dismissal
7005#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7006#[serde(rename_all = "camelCase")]
7007pub struct ExternalToolCompletedData {
7008 /// Request ID of the resolved external tool request; clients should dismiss any UI for this request
7009 pub request_id: RequestId,
7010}
7011
7012/// Session event "command.queued". Queued slash command dispatch request for client execution
7013#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7014#[serde(rename_all = "camelCase")]
7015pub struct CommandQueuedData {
7016 /// The slash command text to be executed (e.g., /help, /clear)
7017 pub command: String,
7018 /// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
7019 pub request_id: RequestId,
7020}
7021
7022/// Session event "command.execute". Registered command dispatch request routed to the owning client
7023#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7024#[serde(rename_all = "camelCase")]
7025pub struct CommandExecuteData {
7026 /// Raw argument string after the command name
7027 pub args: String,
7028 /// The full command text (e.g., /deploy production)
7029 pub command: String,
7030 /// Command name without leading /
7031 pub command_name: String,
7032 /// Unique identifier; used to respond via session.commands.handlePendingCommand()
7033 pub request_id: RequestId,
7034}
7035
7036/// Session event "command.completed". Queued command completion notification signaling UI dismissal
7037#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7038#[serde(rename_all = "camelCase")]
7039pub struct CommandCompletedData {
7040 /// Request ID of the resolved command request; clients should dismiss any UI for this request
7041 pub request_id: RequestId,
7042}
7043
7044/// Session event "auto_mode_switch.requested". Auto mode switch request notification requiring user approval
7045#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7046#[serde(rename_all = "camelCase")]
7047pub struct AutoModeSwitchRequestedData {
7048 /// The rate limit error code that triggered this request
7049 #[serde(skip_serializing_if = "Option::is_none")]
7050 pub error_code: Option<String>,
7051 /// Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
7052 pub request_id: RequestId,
7053 /// Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
7054 #[serde(skip_serializing_if = "Option::is_none")]
7055 pub retry_after_seconds: Option<i64>,
7056}
7057
7058/// Session event "auto_mode_switch.completed". Auto mode switch completion notification
7059#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7060#[serde(rename_all = "camelCase")]
7061pub struct AutoModeSwitchCompletedData {
7062 /// Request ID of the resolved request; clients should dismiss any UI for this request
7063 pub request_id: RequestId,
7064 /// The user's auto-mode-switch choice
7065 pub response: AutoModeSwitchResponse,
7066}
7067
7068/// Session event "session_limits_exhausted.requested". Session limit exhaustion notification requiring user action.
7069#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7070#[serde(rename_all = "camelCase")]
7071pub struct SessionLimitsExhaustedRequestedData {
7072 /// Configured max AI Credits for the current accounting window.
7073 pub max_ai_credits: f64,
7074 /// Unique identifier for this request; used to respond via session.ui.handlePendingSessionLimitsExhausted().
7075 pub request_id: RequestId,
7076 /// AI Credits already consumed in the current accounting window.
7077 pub used_ai_credits: f64,
7078}
7079
7080/// The user's selected action for an exhausted session limit.
7081#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7082#[serde(rename_all = "camelCase")]
7083pub struct SessionLimitsExhaustedResponse {
7084 /// Action selected by the user.
7085 pub action: SessionLimitsExhaustedResponseAction,
7086 /// AI Credits to add to the current max when action is 'add'.
7087 #[serde(skip_serializing_if = "Option::is_none")]
7088 pub additional_ai_credits: Option<f64>,
7089 /// New absolute max AI Credits when action is 'set'.
7090 #[serde(skip_serializing_if = "Option::is_none")]
7091 pub max_ai_credits: Option<f64>,
7092}
7093
7094/// Session event "session_limits_exhausted.completed". Session limit exhaustion prompt completion notification.
7095#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7096#[serde(rename_all = "camelCase")]
7097pub struct SessionLimitsExhaustedCompletedData {
7098 /// Request ID of the resolved request; clients should dismiss any UI for this request.
7099 pub request_id: RequestId,
7100 /// The user's selected session-limit action.
7101 pub response: SessionLimitsExhaustedResponse,
7102}
7103
7104/// 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.
7105///
7106/// <div class="warning">
7107///
7108/// **Experimental.** This type is part of an experimental wire-protocol surface
7109/// and may change or be removed in future SDK or CLI releases.
7110///
7111/// </div>
7112#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7113#[serde(rename_all = "camelCase")]
7114pub struct SessionAutoModeResolvedData {
7115 /// Models offered to the router for this resolution
7116 #[serde(skip_serializing_if = "Option::is_none")]
7117 pub available_models: Option<Vec<String>>,
7118 /// Ordered candidate model list the router returned, when not a fallback
7119 #[serde(skip_serializing_if = "Option::is_none")]
7120 pub candidate_models: Option<Vec<String>>,
7121 /// 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.
7122 #[serde(skip_serializing_if = "Option::is_none")]
7123 pub category_scores: Option<HashMap<String, f64>>,
7124 /// The concrete model the session will use after any intent refinement
7125 pub chosen_model: String,
7126 /// The chosen model's score shortfall relative to the top candidate
7127 #[serde(skip_serializing_if = "Option::is_none")]
7128 pub chosen_shortfall: Option<f64>,
7129 /// Classifier confidence for the predicted label, when available
7130 #[serde(skip_serializing_if = "Option::is_none")]
7131 pub confidence: Option<f64>,
7132 /// End-to-end client wait time for the router request in milliseconds
7133 #[serde(skip_serializing_if = "Option::is_none")]
7134 pub end_to_end_latency_ms: Option<f64>,
7135 /// Whether the router fell back to the standard Auto selection
7136 #[serde(skip_serializing_if = "Option::is_none")]
7137 pub fallback: Option<bool>,
7138 /// Server-provided reason for falling back, when available
7139 #[serde(skip_serializing_if = "Option::is_none")]
7140 pub fallback_reason: Option<String>,
7141 /// Whether the routed prompt contained an image
7142 #[serde(skip_serializing_if = "Option::is_none")]
7143 pub has_image: Option<bool>,
7144 /// The predicted classifier label (e.g. `needs_reasoning`), when available
7145 #[serde(skip_serializing_if = "Option::is_none")]
7146 pub predicted_label: Option<String>,
7147 /// Coarse request-difficulty bucket, for explaining why a model was chosen ("picked X because this looks like high-reasoning work")
7148 #[serde(skip_serializing_if = "Option::is_none")]
7149 pub reasoning_bucket: Option<AutoModeResolvedReasoningBucket>,
7150 /// Server-reported router processing time in milliseconds
7151 #[serde(skip_serializing_if = "Option::is_none")]
7152 pub router_latency_ms: Option<f64>,
7153 /// The routing method the server applied, when Auto Intent ran
7154 #[serde(skip_serializing_if = "Option::is_none")]
7155 pub routing_method: Option<String>,
7156 /// Whether a sticky model choice overrode the router result
7157 #[serde(skip_serializing_if = "Option::is_none")]
7158 pub sticky_override: Option<bool>,
7159}
7160
7161/// 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.
7162///
7163/// <div class="warning">
7164///
7165/// **Experimental.** This type is part of an experimental wire-protocol surface
7166/// and may change or be removed in future SDK or CLI releases.
7167///
7168/// </div>
7169#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7170#[serde(rename_all = "camelCase")]
7171pub struct SessionManagedSettingsResolvedData {
7172 /// Whether enterprise policy disables bypass-permissions ("yolo") mode for this session. Deny-wins across layers, and forced on when `failClosed` is true.
7173 pub bypass_permissions_disabled: bool,
7174 /// Whether a session-local permissions layer injected by the SDK host was present
7175 #[serde(skip_serializing_if = "Option::is_none")]
7176 pub client_managed: Option<bool>,
7177 /// Whether an actual device MDM/plist/registry/file managed-settings layer was present
7178 pub device_managed: bool,
7179 /// 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.
7180 pub fail_closed: bool,
7181 /// The setting keys under enterprise management in the effective managed settings (e.g. `model`, `enabledPlugins`, `permissions`). Empty when no managed settings are in force.
7182 pub managed_keys: Vec<String>,
7183 /// Whether at least two managed sources supplied permission allowlists, so enforcement intersects them and the flattened settings payload omits `permissions.allow`.
7184 #[serde(skip_serializing_if = "Option::is_none")]
7185 pub permissions_allow_intersected: Option<bool>,
7186 /// 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.
7187 #[serde(skip_serializing_if = "Option::is_none")]
7188 pub policy_helper_managed: Option<bool>,
7189 /// 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.
7190 #[serde(skip_serializing_if = "Option::is_none")]
7191 pub sandbox_enabled_by_undetermined_policy: Option<bool>,
7192 /// Whether the server (account/org) managed-settings layer was present
7193 pub server_managed: bool,
7194 /// The effective (resolved) managed settings values, so clients can render exactly what is enforced. Absent when no managed policy is in force.
7195 #[serde(skip_serializing_if = "Option::is_none")]
7196 pub settings: Option<serde_json::Value>,
7197 /// 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.
7198 pub source: ManagedSettingsResolvedSource,
7199}
7200
7201/// 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.
7202///
7203/// <div class="warning">
7204///
7205/// **Experimental.** This type is part of an experimental wire-protocol surface
7206/// and may change or be removed in future SDK or CLI releases.
7207///
7208/// </div>
7209#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7210#[serde(rename_all = "camelCase")]
7211pub struct SessionManagedSettingsEnforcedData {
7212 /// The category of runtime action that managed policy governed.
7213 pub action: ManagedSettingsEnforcedAction,
7214 /// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused. Absent for actions without a specific escalation primitive.
7215 #[serde(skip_serializing_if = "Option::is_none")]
7216 pub escalation: Option<ManagedSettingsEnforcedEscalation>,
7217 /// 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.
7218 pub fail_closed: bool,
7219 /// A human-readable explanation of why the action was governed, suitable for surfacing to the user.
7220 pub message: String,
7221 /// The managed setting key responsible for the enforcement (e.g. `permissions.disableBypassPermissionsMode`).
7222 pub setting: String,
7223}
7224
7225/// A single slash command available in the session, as listed by the `commands.changed` event.
7226#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7227#[serde(rename_all = "camelCase")]
7228pub struct CommandsChangedCommand {
7229 /// Optional human-readable command description.
7230 #[serde(skip_serializing_if = "Option::is_none")]
7231 pub description: Option<String>,
7232 /// Slash command name without the leading slash.
7233 pub name: String,
7234}
7235
7236/// Session event "commands.changed". SDK command registration change notification
7237#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7238#[serde(rename_all = "camelCase")]
7239pub struct CommandsChangedData {
7240 /// Current list of registered SDK commands
7241 pub commands: Vec<CommandsChangedCommand>,
7242}
7243
7244/// UI capability changes
7245#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7246#[serde(rename_all = "camelCase")]
7247pub struct CapabilitiesChangedUI {
7248 /// Whether canvas rendering is now supported
7249 #[serde(skip_serializing_if = "Option::is_none")]
7250 pub canvases: Option<bool>,
7251 /// Whether elicitation is now supported
7252 #[serde(skip_serializing_if = "Option::is_none")]
7253 pub elicitation: Option<bool>,
7254 /// Whether MCP Apps (SEP-1865) UI passthrough is now supported
7255 #[serde(skip_serializing_if = "Option::is_none")]
7256 pub mcp_apps: Option<bool>,
7257}
7258
7259/// Session event "capabilities.changed". Session capability change notification
7260#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7261#[serde(rename_all = "camelCase")]
7262pub struct CapabilitiesChangedData {
7263 /// UI capability changes
7264 #[serde(skip_serializing_if = "Option::is_none")]
7265 pub ui: Option<CapabilitiesChangedUI>,
7266}
7267
7268/// Session event "exit_plan_mode.requested". Plan approval request with plan content and available user actions
7269#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7270#[serde(rename_all = "camelCase")]
7271pub struct ExitPlanModeRequestedData {
7272 /// Available actions the user can take
7273 pub actions: Vec<ExitPlanModeAction>,
7274 /// Model the session had selected when the plan was authored, when one is known
7275 #[serde(skip_serializing_if = "Option::is_none")]
7276 pub model: Option<String>,
7277 /// Full content of the plan file
7278 pub plan_content: String,
7279 /// Recommended action to preselect for the user
7280 pub recommended_action: ExitPlanModeAction,
7281 /// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
7282 pub request_id: RequestId,
7283 /// Summary of the plan that was created
7284 pub summary: String,
7285}
7286
7287/// Session event "exit_plan_mode.completed". Plan mode exit completion with the user's approval decision and optional feedback
7288#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7289#[serde(rename_all = "camelCase")]
7290pub struct ExitPlanModeCompletedData {
7291 /// Whether the plan was approved by the user
7292 #[serde(skip_serializing_if = "Option::is_none")]
7293 pub approved: Option<bool>,
7294 /// Whether edits should be auto-approved without confirmation
7295 #[serde(skip_serializing_if = "Option::is_none")]
7296 pub auto_approve_edits: Option<bool>,
7297 /// Free-form feedback from the user if they requested changes to the plan
7298 #[serde(skip_serializing_if = "Option::is_none")]
7299 pub feedback: Option<String>,
7300 /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
7301 pub request_id: RequestId,
7302 /// Action selected by the user
7303 #[serde(skip_serializing_if = "Option::is_none")]
7304 pub selected_action: Option<ExitPlanModeAction>,
7305}
7306
7307/// Session event "session.tools_updated". Payload of `session.tools_updated` identifying the model whose resolved tools were updated.
7308#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7309#[serde(rename_all = "camelCase")]
7310pub struct SessionToolsUpdatedData {
7311 /// Identifier of the model the resolved tools apply to.
7312 pub model: String,
7313}
7314
7315/// Session event "session.background_tasks_changed". Empty payload for `session.background_tasks_changed`, indicating background task state changed.
7316#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7317#[serde(rename_all = "camelCase")]
7318pub struct SessionBackgroundTasksChangedData {}
7319
7320/// Session event "factory.run_updated". Ephemeral invalidation signal for a changed factory run.
7321///
7322/// <div class="warning">
7323///
7324/// **Experimental.** This type is part of an experimental wire-protocol surface
7325/// and may change or be removed in future SDK or CLI releases.
7326///
7327/// </div>
7328#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7329#[serde(rename_all = "camelCase")]
7330pub struct FactoryRunUpdatedData {
7331 /// Monotonic revision now available for the run.
7332 pub revision: i64,
7333 /// Factory run identifier.
7334 pub run_id: String,
7335}
7336
7337/// Session event "factory.run_started". Ephemeral signal that a factory run attempt began executing.
7338///
7339/// <div class="warning">
7340///
7341/// **Experimental.** This type is part of an experimental wire-protocol surface
7342/// and may change or be removed in future SDK or CLI releases.
7343///
7344/// </div>
7345#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7346#[serde(rename_all = "camelCase")]
7347pub struct FactoryRunStartedData {
7348 /// Attempt number this start committed; a resumed run increments it.
7349 pub attempt: i64,
7350 /// Name of the factory this run executes. Low cardinality by construction.
7351 pub factory_name: String,
7352 /// Identifier of the factory run that started.
7353 pub run_id: String,
7354}
7355
7356/// Session event "factory.run_settled". Ephemeral signal that a factory run reached a terminal status.
7357///
7358/// <div class="warning">
7359///
7360/// **Experimental.** This type is part of an experimental wire-protocol surface
7361/// and may change or be removed in future SDK or CLI releases.
7362///
7363/// </div>
7364#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7365#[serde(rename_all = "camelCase")]
7366pub struct FactoryRunSettledData {
7367 /// AI credits this run consumed, in nano-AIU.
7368 pub consumed_nano_aiu: i64,
7369 /// Subagents this run consumed against its limits.
7370 pub consumed_subagents: i64,
7371 /// Active milliseconds accumulated across every attempt of this run.
7372 pub elapsed_ms: i64,
7373 /// Typed failure class recorded on the run, when it failed with one (e.g. `factory_limit_reached`).
7374 #[serde(skip_serializing_if = "Option::is_none")]
7375 pub failure_type: Option<String>,
7376 /// Identifier of the factory run that settled.
7377 pub run_id: String,
7378 /// Terminal status the run committed.
7379 pub status: FactoryRunSettledStatus,
7380}
7381
7382/// A single resolved skill in `session.skills_loaded`, including source, invocability, enabled state, path, and argument hint.
7383#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7384#[serde(rename_all = "camelCase")]
7385pub struct SkillsLoadedSkill {
7386 /// Optional freeform hint describing the skill's expected arguments, from the `argument-hint` frontmatter field
7387 #[serde(skip_serializing_if = "Option::is_none")]
7388 pub argument_hint: Option<String>,
7389 /// Canonical slash command name used to invoke the skill, without the leading '/'
7390 #[serde(skip_serializing_if = "Option::is_none")]
7391 pub command_name: Option<String>,
7392 /// Description of what the skill does
7393 pub description: String,
7394 /// Whether the skill is currently enabled
7395 pub enabled: bool,
7396 /// Unique identifier for the skill
7397 pub name: String,
7398 /// Absolute path to the skill file, if available
7399 #[serde(skip_serializing_if = "Option::is_none")]
7400 pub path: Option<String>,
7401 /// Source location type (e.g., project, personal-copilot, plugin, builtin, remote, sdk)
7402 pub source: SkillSource,
7403 /// Whether the skill can be invoked by the user as a slash command
7404 pub user_invocable: bool,
7405}
7406
7407/// Session event "session.skills_loaded". Payload of `session.skills_loaded` listing resolved skill metadata.
7408#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7409#[serde(rename_all = "camelCase")]
7410pub struct SessionSkillsLoadedData {
7411 /// Array of resolved skill metadata
7412 pub skills: Vec<SkillsLoadedSkill>,
7413}
7414
7415/// A single loaded custom agent in `session.custom_agents_updated`, with identity, source, tools, invocability, and authored model configuration.
7416#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7417#[serde(rename_all = "camelCase")]
7418pub struct CustomAgentsUpdatedAgent {
7419 /// Description of what the agent does
7420 pub description: String,
7421 /// Whether model-driven invocation is disabled for this agent.
7422 #[serde(skip_serializing_if = "Option::is_none")]
7423 pub disable_model_invocation: Option<bool>,
7424 /// Human-readable display name
7425 pub display_name: String,
7426 /// Unique identifier for the agent
7427 pub id: String,
7428 /// Model override for this agent, if set
7429 #[serde(skip_serializing_if = "Option::is_none")]
7430 pub model: Option<String>,
7431 /// Whether authored models are preferences or required constraints
7432 #[serde(skip_serializing_if = "Option::is_none")]
7433 pub model_policy: Option<AgentModelPolicy>,
7434 /// Authored model ids in priority order, if configured
7435 #[serde(skip_serializing_if = "Option::is_none")]
7436 pub models: Option<Vec<String>>,
7437 /// Internal name of the agent
7438 pub name: String,
7439 /// Source location: user, project, inherited, remote, or plugin
7440 pub source: String,
7441 /// List of tool names available to this agent, or null when all tools are available
7442 pub tools: Option<Vec<String>>,
7443 /// Whether the agent can be selected by the user
7444 pub user_invocable: bool,
7445}
7446
7447/// Session event "session.custom_agents_updated". Payload of `session.custom_agents_updated` with loaded custom agents plus non-fatal warnings and fatal errors.
7448#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7449#[serde(rename_all = "camelCase")]
7450pub struct SessionCustomAgentsUpdatedData {
7451 /// Array of loaded custom agent metadata
7452 pub agents: Vec<CustomAgentsUpdatedAgent>,
7453 /// Fatal errors from agent loading
7454 pub errors: Vec<String>,
7455 /// Non-fatal warnings from agent loading
7456 pub warnings: Vec<String>,
7457}
7458
7459/// Server-advertised metadata learned through modern discovery or legacy initialization.
7460#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7461#[serde(rename_all = "camelCase")]
7462pub struct McpServerMetadata {
7463 /// Non-empty natural-language guidance for using the server, or null when the server omitted instructions or advertised an empty string.
7464 pub instructions: Option<String>,
7465}
7466
7467/// A single MCP server status summary in `session.mcp_servers_loaded`, including name, status, source, transport, and plugin metadata.
7468#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7469#[serde(rename_all = "camelCase")]
7470pub struct McpServersLoadedServer {
7471 /// Human-readable display name supplied by a managed server catalog.
7472 #[serde(skip_serializing_if = "Option::is_none")]
7473 pub display_name: Option<String>,
7474 /// Error message if the server failed to connect
7475 #[serde(skip_serializing_if = "Option::is_none")]
7476 pub error: Option<String>,
7477 /// Server name (config key)
7478 pub name: String,
7479 /// Name of the plugin that supplied the effective MCP server config, only when source is plugin
7480 #[serde(skip_serializing_if = "Option::is_none")]
7481 pub plugin_name: Option<String>,
7482 /// Version of the plugin that supplied the effective MCP server config, only when source is plugin
7483 #[serde(skip_serializing_if = "Option::is_none")]
7484 pub plugin_version: Option<String>,
7485 /// 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.
7486 #[serde(skip_serializing_if = "Option::is_none")]
7487 pub server_metadata: Option<McpServerMetadata>,
7488 /// Configuration source: user, workspace, plugin, builtin, or managed
7489 #[serde(skip_serializing_if = "Option::is_none")]
7490 pub source: Option<McpServerSource>,
7491 /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
7492 pub status: McpServerStatus,
7493 /// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
7494 #[serde(skip_serializing_if = "Option::is_none")]
7495 pub transport: Option<McpServerTransport>,
7496}
7497
7498/// Session event "session.mcp_servers_loaded". Payload of `session.mcp_servers_loaded` listing MCP server status summaries.
7499#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7500#[serde(rename_all = "camelCase")]
7501pub struct SessionMcpServersLoadedData {
7502 /// Array of MCP server status summaries
7503 pub servers: Vec<McpServersLoadedServer>,
7504}
7505
7506/// Session event "session.mcp_server_status_changed". Payload of `session.mcp_server_status_changed` for one MCP server's status and optional failure error.
7507#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7508#[serde(rename_all = "camelCase")]
7509pub struct SessionMcpServerStatusChangedData {
7510 /// Error message if the server entered a failed state
7511 #[serde(skip_serializing_if = "Option::is_none")]
7512 pub error: Option<String>,
7513 /// Name of the MCP server whose status changed
7514 pub server_name: String,
7515 /// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
7516 pub status: McpServerStatus,
7517}
7518
7519/// Session event "session.mcp_server_removed". Payload of `session.mcp_server_removed` identifying an MCP server the graph no longer runs.
7520#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7521#[serde(rename_all = "camelCase")]
7522pub struct SessionMcpServerRemovedData {
7523 /// Name of the MCP server that was removed from the graph
7524 pub server_name: String,
7525}
7526
7527/// Session event "session.mcp_server_needs_reconnect". Payload of `session.mcp_server_needs_reconnect` identifying an MCP server whose connection must be re-established.
7528#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7529#[serde(rename_all = "camelCase")]
7530pub struct SessionMcpServerNeedsReconnectData {
7531 /// Name of the MCP server that needs to reconnect
7532 pub server_name: String,
7533}
7534
7535/// Session event "mcp.tools.list_changed". Payload identifying the MCP server associated with a list change.
7536#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7537#[serde(rename_all = "camelCase")]
7538pub struct McpToolsListChangedData {
7539 /// Name of the MCP server whose list changed
7540 pub server_name: String,
7541}
7542
7543/// Session event "mcp.resources.list_changed". Payload identifying the MCP server associated with a list change.
7544#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7545#[serde(rename_all = "camelCase")]
7546pub struct McpResourcesListChangedData {
7547 /// Name of the MCP server whose list changed
7548 pub server_name: String,
7549}
7550
7551/// Session event "mcp.prompts.list_changed". Payload identifying the MCP server associated with a list change.
7552#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7553#[serde(rename_all = "camelCase")]
7554pub struct McpPromptsListChangedData {
7555 /// Name of the MCP server whose list changed
7556 pub server_name: String,
7557}
7558
7559/// A single extension discovered by `session.extensions_loaded`, including qualified ID, source, and current status.
7560#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7561#[serde(rename_all = "camelCase")]
7562pub struct ExtensionsLoadedExtension {
7563 /// Source-qualified extension ID (e.g., 'project:my-ext', 'user:auth-helper', 'plugin:my-plugin:my-ext')
7564 pub id: String,
7565 /// Extension name (directory name)
7566 pub name: String,
7567 /// Discovery source
7568 pub source: ExtensionsLoadedExtensionSource,
7569 /// Current status: running, disabled, failed, or starting
7570 pub status: ExtensionsLoadedExtensionStatus,
7571}
7572
7573/// Session event "session.extensions_loaded". Payload of `session.extensions_loaded` listing discovered extensions and their statuses.
7574#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7575#[serde(rename_all = "camelCase")]
7576pub struct SessionExtensionsLoadedData {
7577 /// Array of discovered extensions and their status
7578 pub extensions: Vec<ExtensionsLoadedExtension>,
7579}
7580
7581/// Session event "session.canvas.opened". Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional icon, title, status, URL, and input.
7582///
7583/// <div class="warning">
7584///
7585/// **Experimental.** This type is part of an experimental wire-protocol surface
7586/// and may change or be removed in future SDK or CLI releases.
7587///
7588/// </div>
7589#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7590#[serde(rename_all = "camelCase")]
7591pub struct SessionCanvasOpenedData {
7592 /// Provider-local canvas identifier
7593 pub canvas_id: String,
7594 /// Owning provider identifier
7595 pub extension_id: String,
7596 /// Owning extension display name, when available
7597 #[serde(skip_serializing_if = "Option::is_none")]
7598 pub extension_name: Option<String>,
7599 /// Host-local PNG path for the canvas icon, when supplied
7600 #[serde(skip_serializing_if = "Option::is_none")]
7601 pub icon: Option<String>,
7602 /// Input supplied when the instance was opened
7603 #[serde(skip_serializing_if = "Option::is_none")]
7604 pub input: Option<serde_json::Value>,
7605 /// Stable caller-supplied canvas instance identifier
7606 pub instance_id: String,
7607 /// Provider-supplied status text
7608 #[serde(skip_serializing_if = "Option::is_none")]
7609 pub status: Option<String>,
7610 /// Rendered title
7611 #[serde(skip_serializing_if = "Option::is_none")]
7612 pub title: Option<String>,
7613 /// URL for web-rendered canvases
7614 #[serde(skip_serializing_if = "Option::is_none")]
7615 pub url: Option<String>,
7616}
7617
7618/// A single action within a canvas declaration, with its name, optional description, and optional input schema.
7619///
7620/// <div class="warning">
7621///
7622/// **Experimental.** This type is part of an experimental wire-protocol surface
7623/// and may change or be removed in future SDK or CLI releases.
7624///
7625/// </div>
7626#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7627#[serde(rename_all = "camelCase")]
7628pub struct CanvasRegistryChangedCanvasAction {
7629 /// Action description
7630 #[serde(skip_serializing_if = "Option::is_none")]
7631 pub description: Option<String>,
7632 /// JSON Schema for action input
7633 #[serde(skip_serializing_if = "Option::is_none")]
7634 pub input_schema: Option<serde_json::Value>,
7635 /// Action name
7636 pub name: String,
7637}
7638
7639/// A single canvas declaration in `session.canvas.registry_changed`, including provider IDs, display metadata, input schema, and actions.
7640///
7641/// <div class="warning">
7642///
7643/// **Experimental.** This type is part of an experimental wire-protocol surface
7644/// and may change or be removed in future SDK or CLI releases.
7645///
7646/// </div>
7647#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7648#[serde(rename_all = "camelCase")]
7649pub struct CanvasRegistryChangedCanvas {
7650 /// Actions the agent or host may invoke
7651 #[serde(skip_serializing_if = "Option::is_none")]
7652 pub actions: Option<Vec<CanvasRegistryChangedCanvasAction>>,
7653 /// Provider-local canvas identifier
7654 pub canvas_id: String,
7655 /// Short, single-sentence description shown to the agent in canvas catalogs.
7656 pub description: String,
7657 /// Human-readable canvas name
7658 pub display_name: String,
7659 /// Owning provider identifier
7660 pub extension_id: String,
7661 /// Owning extension display name, when available
7662 #[serde(skip_serializing_if = "Option::is_none")]
7663 pub extension_name: Option<String>,
7664 /// Host-local PNG path for the canvas icon, when supplied
7665 #[serde(skip_serializing_if = "Option::is_none")]
7666 pub icon: Option<String>,
7667 /// JSON Schema for canvas open input
7668 #[serde(skip_serializing_if = "Option::is_none")]
7669 pub input_schema: Option<serde_json::Value>,
7670}
7671
7672/// Session event "session.canvas.registry_changed". Payload of `session.canvas.registry_changed` listing the canvas declarations currently available.
7673///
7674/// <div class="warning">
7675///
7676/// **Experimental.** This type is part of an experimental wire-protocol surface
7677/// and may change or be removed in future SDK or CLI releases.
7678///
7679/// </div>
7680#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7681#[serde(rename_all = "camelCase")]
7682pub struct SessionCanvasRegistryChangedData {
7683 /// Canvas declarations currently available
7684 pub canvases: Vec<CanvasRegistryChangedCanvas>,
7685}
7686
7687/// Session event "session.canvas.closed". Payload of `session.canvas.closed` with the closed canvas instance ID, provider ID, and canvas ID.
7688///
7689/// <div class="warning">
7690///
7691/// **Experimental.** This type is part of an experimental wire-protocol surface
7692/// and may change or be removed in future SDK or CLI releases.
7693///
7694/// </div>
7695#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7696#[serde(rename_all = "camelCase")]
7697pub struct SessionCanvasClosedData {
7698 /// Provider-local canvas identifier
7699 pub canvas_id: String,
7700 /// Owning provider identifier
7701 pub extension_id: String,
7702 /// Stable caller-supplied identifier of the canvas instance that was closed
7703 pub instance_id: String,
7704}
7705
7706/// 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.
7707///
7708/// <div class="warning">
7709///
7710/// **Experimental.** This type is part of an experimental wire-protocol surface
7711/// and may change or be removed in future SDK or CLI releases.
7712///
7713/// </div>
7714#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7715#[serde(rename_all = "camelCase")]
7716pub struct SessionCanvasUnavailableData {
7717 /// Provider-local canvas identifier
7718 pub canvas_id: String,
7719 /// Owning provider identifier
7720 pub extension_id: String,
7721 /// Stable caller-supplied identifier of the canvas instance whose provider became unavailable
7722 pub instance_id: String,
7723}
7724
7725/// 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.
7726///
7727/// <div class="warning">
7728///
7729/// **Experimental.** This type is part of an experimental wire-protocol surface
7730/// and may change or be removed in future SDK or CLI releases.
7731///
7732/// </div>
7733#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7734#[serde(rename_all = "camelCase")]
7735pub struct SessionCanvasRecordedData {
7736 /// Provider-local canvas identifier
7737 pub canvas_id: String,
7738 /// Owning provider identifier
7739 pub extension_id: String,
7740 /// Input supplied when the instance was opened
7741 #[serde(skip_serializing_if = "Option::is_none")]
7742 pub input: Option<serde_json::Value>,
7743 /// Stable caller-supplied canvas instance identifier
7744 pub instance_id: String,
7745 /// Rendered title
7746 #[serde(skip_serializing_if = "Option::is_none")]
7747 pub title: Option<String>,
7748}
7749
7750/// Session event "session.canvas.removed". Durable record that a canvas instance was closed, superseding a prior instance_recorded during resume replay.
7751///
7752/// <div class="warning">
7753///
7754/// **Experimental.** This type is part of an experimental wire-protocol surface
7755/// and may change or be removed in future SDK or CLI releases.
7756///
7757/// </div>
7758#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7759#[serde(rename_all = "camelCase")]
7760pub struct SessionCanvasRemovedData {
7761 /// Provider-local canvas identifier
7762 pub canvas_id: String,
7763 /// Owning provider identifier
7764 pub extension_id: String,
7765 /// Stable caller-supplied identifier of the canvas instance that was closed
7766 pub instance_id: String,
7767}
7768
7769/// Session event "session.extensions.attachments_pushed". Payload of `session.extensions.attachments_pushed` with extension-contributed attachments for the next send.
7770#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7771#[serde(rename_all = "camelCase")]
7772pub struct SessionExtensionsAttachmentsPushedData {
7773 /// Attachments contributed by an extension; the host should surface these as composer pills and forward them via the next session.send call.
7774 pub attachments: Vec<serde_json::Value>,
7775}
7776
7777/// Set when the underlying tools/call threw an error before returning a CallToolResult
7778#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7779#[serde(rename_all = "camelCase")]
7780pub struct McpAppToolCallCompleteError {
7781 /// Human-readable error message
7782 pub message: String,
7783}
7784
7785/// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
7786#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7787#[serde(rename_all = "camelCase")]
7788pub struct McpAppToolCallCompleteToolMetaUI {
7789 /// `ui://` URI declared by the tool's `_meta.ui.resourceUri`
7790 #[serde(skip_serializing_if = "Option::is_none")]
7791 pub resource_uri: Option<String>,
7792 /// Tool visibility per SEP-1865 (typically a subset of `["model","app"]`)
7793 #[serde(skip_serializing_if = "Option::is_none")]
7794 pub visibility: Option<Vec<String>>,
7795}
7796
7797/// 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.
7798#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7799#[serde(rename_all = "camelCase")]
7800pub struct McpAppToolCallCompleteToolMeta {
7801 /// MCP App tool `_meta.ui` resource URI and SEP-1865 visibility captured with an `mcp_app.tool_call_complete` result.
7802 #[serde(skip_serializing_if = "Option::is_none")]
7803 pub ui: Option<McpAppToolCallCompleteToolMetaUI>,
7804}
7805
7806/// Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
7807#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7808#[serde(rename_all = "camelCase")]
7809pub struct McpAppToolCallCompleteData {
7810 /// Arguments passed to the tool by the app view, if any
7811 #[serde(skip_serializing_if = "Option::is_none")]
7812 pub arguments: Option<HashMap<String, serde_json::Value>>,
7813 /// Wall-clock duration of the underlying tools/call in milliseconds
7814 pub duration_ms: f64,
7815 /// Set when the underlying tools/call threw an error before returning a CallToolResult
7816 #[serde(skip_serializing_if = "Option::is_none")]
7817 pub error: Option<McpAppToolCallCompleteError>,
7818 /// Standard MCP CallToolResult returned by the server. Present whether or not the call set isError.
7819 #[serde(skip_serializing_if = "Option::is_none")]
7820 pub result: Option<HashMap<String, serde_json::Value>>,
7821 /// Name of the MCP server hosting the tool
7822 pub server_name: String,
7823 /// True when the call completed without throwing AND the MCP CallToolResult did not set isError
7824 pub success: bool,
7825 /// 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.
7826 #[serde(skip_serializing_if = "Option::is_none")]
7827 pub tool_meta: Option<McpAppToolCallCompleteToolMeta>,
7828 /// MCP tool name that was invoked
7829 pub tool_name: String,
7830}
7831
7832/// Session event "session.indexed_search". Transient indexed-search status and diagnostics from the live runtime service. Never persisted or used to infer activation from session history.
7833pub type SessionIndexedSearchData = IndexedSearchData;
7834
7835/// 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.
7836#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7837pub enum AutoTier {
7838 /// Optimize for efficiency.
7839 #[serde(rename = "efficiency")]
7840 Efficiency,
7841 /// Balance efficiency and intelligence.
7842 #[serde(rename = "balance")]
7843 Balance,
7844 /// Optimize for intelligence.
7845 #[serde(rename = "intelligence")]
7846 Intelligence,
7847 /// Integrator-only preset that optimizes for latency.
7848 #[serde(rename = "fast")]
7849 Fast,
7850 /// Unknown variant for forward compatibility.
7851 #[default]
7852 #[serde(other)]
7853 Unknown,
7854}
7855
7856/// Hosting platform type of the repository (github or ado)
7857#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7858pub enum WorkingDirectoryContextHostType {
7859 /// Repository is hosted on GitHub.
7860 #[serde(rename = "github")]
7861 GitHub,
7862 /// Repository is hosted on Azure DevOps.
7863 #[serde(rename = "ado")]
7864 Ado,
7865 /// Unknown variant for forward compatibility.
7866 #[default]
7867 #[serde(other)]
7868 Unknown,
7869}
7870
7871/// Allowed values for the `ContextTier` enumeration.
7872#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7873pub enum ContextTier {
7874 /// Default context tier with standard context window size.
7875 #[serde(rename = "default")]
7876 Default,
7877 /// Extended context tier with a larger context window.
7878 #[serde(rename = "long_context")]
7879 LongContext,
7880 /// Unknown variant for forward compatibility.
7881 #[default]
7882 #[serde(other)]
7883 Unknown,
7884}
7885
7886/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
7887#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7888pub enum ReasoningSummary {
7889 /// Do not request reasoning summaries from the model.
7890 #[serde(rename = "none")]
7891 None,
7892 /// Request a concise summary of the model's reasoning.
7893 #[serde(rename = "concise")]
7894 Concise,
7895 /// Request a detailed summary of the model's reasoning.
7896 #[serde(rename = "detailed")]
7897 Detailed,
7898 /// Unknown variant for forward compatibility.
7899 #[default]
7900 #[serde(other)]
7901 Unknown,
7902}
7903
7904/// Output verbosity level used for supported model calls (e.g. "low", "medium", "high")
7905#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7906pub enum Verbosity {
7907 /// A terse response was requested.
7908 #[serde(rename = "low")]
7909 Low,
7910 /// A medium amount of response detail was requested.
7911 #[serde(rename = "medium")]
7912 Medium,
7913 /// A more detailed response was requested.
7914 #[serde(rename = "high")]
7915 High,
7916 /// Unknown variant for forward compatibility.
7917 #[default]
7918 #[serde(other)]
7919 Unknown,
7920}
7921
7922/// 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.
7923#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7924pub enum RemediationAction {
7925 /// Authenticate again with the Copilot backend. The current credential is absent, expired, or rejected.
7926 #[serde(rename = "sign_in")]
7927 SignIn,
7928 /// Authenticate as a different account. The current account exists but lacks access to the requested resource.
7929 #[serde(rename = "switch_account")]
7930 SwitchAccount,
7931 /// Inspect which account is currently authenticated before deciding what to change.
7932 #[serde(rename = "show_account")]
7933 ShowAccount,
7934 /// 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.
7935 #[serde(rename = "review_sandbox_policy")]
7936 ReviewSandboxPolicy,
7937 /// Permit outbound network access in the sandbox policy.
7938 #[serde(rename = "allow_sandbox_outbound")]
7939 AllowSandboxOutbound,
7940 /// Unknown variant for forward compatibility.
7941 #[default]
7942 #[serde(other)]
7943 Unknown,
7944}
7945
7946/// The session mode the agent is operating in
7947#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7948pub enum SessionMode {
7949 /// The agent is responding interactively to the user.
7950 #[serde(rename = "interactive")]
7951 Interactive,
7952 /// The agent is preparing a plan before making changes.
7953 #[serde(rename = "plan")]
7954 Plan,
7955 /// The agent is working autonomously toward task completion.
7956 #[serde(rename = "autopilot")]
7957 Autopilot,
7958 /// Unknown variant for forward compatibility.
7959 #[default]
7960 #[serde(other)]
7961 Unknown,
7962}
7963
7964/// 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.
7965#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7966pub enum ScheduleOrigin {
7967 /// The schedule was created by an explicit user action, such as `/every` or `/after`.
7968 #[serde(rename = "user")]
7969 User,
7970 /// The schedule was created by the agent via the `manage_schedule` tool.
7971 #[serde(rename = "model")]
7972 Model,
7973 /// Unknown variant for forward compatibility.
7974 #[default]
7975 #[serde(other)]
7976 Unknown,
7977}
7978
7979/// The type of operation performed on the autopilot objective state file
7980#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7981pub enum AutopilotObjectiveChangedOperation {
7982 /// Autopilot objective state file was created for a new objective.
7983 #[serde(rename = "create")]
7984 Create,
7985 /// Autopilot objective state file was updated for an existing objective.
7986 #[serde(rename = "update")]
7987 Update,
7988 /// Autopilot objective state file was deleted or cleared.
7989 #[serde(rename = "delete")]
7990 Delete,
7991 /// Unknown variant for forward compatibility.
7992 #[default]
7993 #[serde(other)]
7994 Unknown,
7995}
7996
7997/// Current autopilot objective status, if one exists
7998#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
7999pub enum AutopilotObjectiveChangedStatus {
8000 /// Objective is active and can drive autopilot continuations.
8001 #[serde(rename = "active")]
8002 Active,
8003 /// Objective is paused and will not drive autopilot continuations.
8004 #[serde(rename = "paused")]
8005 Paused,
8006 /// Legacy objective state indicating the previous continuation cap was reached.
8007 #[serde(rename = "cap_reached")]
8008 CapReached,
8009 /// Objective was completed by the agent.
8010 #[serde(rename = "completed")]
8011 Completed,
8012 /// Unknown variant for forward compatibility.
8013 #[default]
8014 #[serde(other)]
8015 Unknown,
8016}
8017
8018/// Indexed-search event variant discriminator.
8019#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8020pub enum IndexedSearchDataStatusKind {
8021 #[serde(rename = "status")]
8022 #[default]
8023 Status,
8024}
8025
8026/// Live indexed-search state for this session activation, never inferred from persisted history.
8027#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8028pub enum IndexedSearchState {
8029 /// Indexed search is not active for this session.
8030 #[serde(rename = "disabled")]
8031 Disabled,
8032 /// Indexed-search startup is in progress.
8033 #[serde(rename = "starting")]
8034 Starting,
8035 /// The indexed-search server started successfully; its index may still be warming.
8036 #[serde(rename = "enabled")]
8037 Enabled,
8038 /// The indexed-search server and its index are ready.
8039 #[serde(rename = "ready")]
8040 Ready,
8041 /// Indexed-search startup or the active server failed.
8042 #[serde(rename = "failed")]
8043 Failed,
8044 /// Unknown variant for forward compatibility.
8045 #[default]
8046 #[serde(other)]
8047 Unknown,
8048}
8049
8050/// Configuration, policy, or workspace condition that disabled indexed search.
8051#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8052pub enum IndexedSearchDisabledReason {
8053 /// Indexed search was explicitly disabled by the environment.
8054 #[serde(rename = "use_tgrep_false")]
8055 UseTgrepFalse,
8056 /// Search uses the external ripgrep binary instead of bundled search.
8057 #[serde(rename = "use_builtin_ripgrep_false")]
8058 UseBuiltinRipgrepFalse,
8059 /// Organization policy disables indexed search.
8060 #[serde(rename = "organization")]
8061 Organization,
8062 /// Authentication has not resolved organization policy.
8063 #[serde(rename = "organization_policy_auth_pending")]
8064 OrganizationPolicyAuthPending,
8065 /// Organization policy could not be determined.
8066 #[serde(rename = "organization_policy_unknown")]
8067 OrganizationPolicyUnknown,
8068 /// The workspace uses a virtualized or network filesystem.
8069 #[serde(rename = "virtual_filesystem")]
8070 VirtualFilesystem,
8071 /// The workspace is inside a Windows cloud-sync root.
8072 #[serde(rename = "cloud_sync_root")]
8073 CloudSyncRoot,
8074 /// The Windows cloud-sync safety check failed.
8075 #[serde(rename = "cloud_sync_detection_failed")]
8076 CloudSyncDetectionFailed,
8077 /// The workspace is not available on the runtime's local filesystem.
8078 #[serde(rename = "workspace_not_local")]
8079 WorkspaceNotLocal,
8080 /// Unknown variant for forward compatibility.
8081 #[default]
8082 #[serde(other)]
8083 Unknown,
8084}
8085
8086/// Indexed-search event variant discriminator.
8087#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8088pub enum IndexedSearchDataStartupKind {
8089 #[serde(rename = "startup")]
8090 #[default]
8091 Startup,
8092}
8093
8094/// Result of an indexed-search startup attempt.
8095#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8096pub enum IndexedSearchOutcome {
8097 /// A new indexed-search server was started.
8098 #[serde(rename = "started")]
8099 Started,
8100 /// The repository has too few files for automatic indexing.
8101 #[serde(rename = "skipped_below_threshold")]
8102 SkippedBelowThreshold,
8103 /// No Git repository was found and indexing was not forced.
8104 #[serde(rename = "skipped_no_gitroot")]
8105 SkippedNoGitroot,
8106 /// Configuration, policy, or workspace safety disabled indexing.
8107 #[serde(rename = "skipped_disabled")]
8108 SkippedDisabled,
8109 /// An existing indexed-search server was reused.
8110 #[serde(rename = "reused_existing")]
8111 ReusedExisting,
8112 /// The startup attempt failed.
8113 #[serde(rename = "failed")]
8114 Failed,
8115 /// Unknown variant for forward compatibility.
8116 #[default]
8117 #[serde(other)]
8118 Unknown,
8119}
8120
8121/// Category of an indexed-search server failure.
8122#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8123pub enum IndexedSearchErrorType {
8124 /// The indexed-search server could not be spawned.
8125 #[serde(rename = "spawn_error")]
8126 SpawnError,
8127 /// The indexed-search server exited unexpectedly.
8128 #[serde(rename = "unexpected_exit")]
8129 UnexpectedExit,
8130 /// The indexed-search server was terminated by a signal.
8131 #[serde(rename = "killed_by_signal")]
8132 KilledBySignal,
8133 /// Unknown variant for forward compatibility.
8134 #[default]
8135 #[serde(other)]
8136 Unknown,
8137}
8138
8139/// Indexed-search event variant discriminator.
8140#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8141pub enum IndexedSearchDataServerErrorKind {
8142 #[serde(rename = "server_error")]
8143 #[default]
8144 ServerError,
8145}
8146
8147/// Indexed-search event variant discriminator.
8148#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8149pub enum IndexedSearchDataIncrementalKind {
8150 #[serde(rename = "incremental")]
8151 #[default]
8152 Incremental,
8153}
8154
8155/// Phase of an incremental indexed-search update.
8156#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8157pub enum IndexedSearchIncrementalPhase {
8158 /// A workspace scan found changes to index.
8159 #[serde(rename = "changes_detected")]
8160 ChangesDetected,
8161 /// The incremental index update completed.
8162 #[serde(rename = "updated")]
8163 Updated,
8164 /// Unknown variant for forward compatibility.
8165 #[default]
8166 #[serde(other)]
8167 Unknown,
8168}
8169
8170/// Transient indexed-search status and diagnostics from the live runtime service. Never persisted or used to infer activation from session history.
8171#[derive(Debug, Clone, Serialize, Deserialize)]
8172#[serde(untagged)]
8173pub enum IndexedSearchData {
8174 Status(IndexedSearchDataStatus),
8175 Startup(IndexedSearchDataStartup),
8176 ServerError(IndexedSearchDataServerError),
8177 Incremental(IndexedSearchDataIncremental),
8178}
8179
8180/// Origin of an effective session model change.
8181#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8182pub enum ModelChangeSource {
8183 /// The user selected a model directly with `/model <id>`.
8184 #[serde(rename = "model_command")]
8185 ModelCommand,
8186 /// The user selected the model with `/settings`.
8187 #[serde(rename = "settings_command")]
8188 SettingsCommand,
8189 /// The user selected the model with the `/config` alias.
8190 #[serde(rename = "config_command")]
8191 ConfigCommand,
8192 /// The user selected the model in the model picker, including the picker opened by bare `/model`.
8193 #[serde(rename = "model_picker")]
8194 ModelPicker,
8195 /// Organization-managed settings selected the model.
8196 #[serde(rename = "managed_settings")]
8197 ManagedSettings,
8198 /// Repository settings selected the model.
8199 #[serde(rename = "repo_settings")]
8200 RepoSettings,
8201 /// Startup model resolution selected the model.
8202 #[serde(rename = "startup")]
8203 Startup,
8204 /// Selecting an agent selected its configured model.
8205 #[serde(rename = "agent")]
8206 Agent,
8207 /// Entering, leaving, or reconfiguring plan mode selected the model.
8208 #[serde(rename = "plan_mode")]
8209 PlanMode,
8210 /// The runtime selected the model automatically, such as rate-limit recovery or refusal fallback.
8211 #[serde(rename = "automatic")]
8212 Automatic,
8213 /// The user selected the promoted model from the changeboarding card or its keyboard shortcut.
8214 #[serde(rename = "changeboarding_shortcut")]
8215 ChangeboardingShortcut,
8216 /// An SDK or RPC caller selected the model.
8217 #[serde(rename = "sdk")]
8218 Sdk,
8219 /// Unknown variant for forward compatibility.
8220 #[default]
8221 #[serde(other)]
8222 Unknown,
8223}
8224
8225/// Why the session no longer has an explicitly selected model.
8226#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8227pub enum ModelDeselectedReason {
8228 /// A host-managed provider snapshot no longer publishes the selected model.
8229 #[serde(rename = "provider_withdrawn")]
8230 ProviderWithdrawn,
8231 /// Unknown variant for forward compatibility.
8232 #[default]
8233 #[serde(other)]
8234 Unknown,
8235}
8236
8237/// Auto preferences that Copilot API can recommend.
8238#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8239pub enum RecommendedAutoTier {
8240 /// Optimize for efficiency.
8241 #[serde(rename = "efficiency")]
8242 Efficiency,
8243 /// Balance efficiency and intelligence.
8244 #[serde(rename = "balance")]
8245 Balance,
8246 /// Optimize for intelligence.
8247 #[serde(rename = "intelligence")]
8248 Intelligence,
8249 /// Unknown variant for forward compatibility.
8250 #[default]
8251 #[serde(other)]
8252 Unknown,
8253}
8254
8255/// Terminal reason an Auto preference activation failed.
8256#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8257pub enum AutoTierSwitchFailureReason {
8258 /// The candidate model was rejected by model policy.
8259 #[serde(rename = "policy_rejected")]
8260 PolicyRejected,
8261 /// The Auto routing request failed or returned an unusable response.
8262 #[serde(rename = "request_failed")]
8263 RequestFailed,
8264 /// The runtime could not prepare the Auto routing request.
8265 #[serde(rename = "setup_failed")]
8266 SetupFailed,
8267 /// The provider does not support Auto routing.
8268 #[serde(rename = "unsupported")]
8269 Unsupported,
8270 /// Unknown variant for forward compatibility.
8271 #[default]
8272 #[serde(other)]
8273 Unknown,
8274}
8275
8276/// Permission mode for the session.
8277///
8278/// <div class="warning">
8279///
8280/// **Experimental.** This type is part of an experimental wire-protocol surface
8281/// and may change or be removed in future SDK or CLI releases.
8282///
8283/// </div>
8284#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8285pub enum PermissionMode {
8286 /// Permission requests follow the normal approval flow.
8287 #[serde(rename = "manual")]
8288 Manual,
8289 /// Permission requests include an LLM safety recommendation; clients may automatically approve requests judged acceptable.
8290 #[serde(rename = "assisted")]
8291 Assisted,
8292 /// Tool, path, and URL permission requests are automatically approved.
8293 #[serde(rename = "allow-all")]
8294 AllowAll,
8295 /// Unknown variant for forward compatibility.
8296 #[default]
8297 #[serde(other)]
8298 Unknown,
8299}
8300
8301/// The type of operation performed on the plan file
8302#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8303pub enum PlanChangedOperation {
8304 /// The plan file was created.
8305 #[serde(rename = "create")]
8306 Create,
8307 /// The plan file was updated.
8308 #[serde(rename = "update")]
8309 Update,
8310 /// The plan file was deleted.
8311 #[serde(rename = "delete")]
8312 Delete,
8313 /// Unknown variant for forward compatibility.
8314 #[default]
8315 #[serde(other)]
8316 Unknown,
8317}
8318
8319/// Whether the file was newly created or updated
8320#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8321pub enum WorkspaceFileChangedOperation {
8322 /// The workspace file was created.
8323 #[serde(rename = "create")]
8324 Create,
8325 /// The workspace file was updated.
8326 #[serde(rename = "update")]
8327 Update,
8328 /// Unknown variant for forward compatibility.
8329 #[default]
8330 #[serde(other)]
8331 Unknown,
8332}
8333
8334/// Origin type of the session being handed off
8335#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8336pub enum HandoffSourceType {
8337 /// The handoff originated from a remote session.
8338 #[serde(rename = "remote")]
8339 Remote,
8340 /// The handoff originated from a local session.
8341 #[serde(rename = "local")]
8342 Local,
8343 /// Unknown variant for forward compatibility.
8344 #[default]
8345 #[serde(other)]
8346 Unknown,
8347}
8348
8349/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
8350#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8351pub enum ShutdownType {
8352 /// The session ended normally.
8353 #[serde(rename = "routine")]
8354 Routine,
8355 /// The session ended because of a crash or fatal error.
8356 #[serde(rename = "error")]
8357 Error,
8358 /// Unknown variant for forward compatibility.
8359 #[default]
8360 #[serde(other)]
8361 Unknown,
8362}
8363
8364/// What initiated a conversation compaction
8365#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8366pub enum CompactionTrigger {
8367 /// Background compaction started automatically because context utilization crossed the background threshold.
8368 #[serde(rename = "threshold")]
8369 Threshold,
8370 /// Compaction forced by a context-limit model response (e.g. HTTP 413) before retrying the request.
8371 #[serde(rename = "context_limit_retry")]
8372 ContextLimitRetry,
8373 /// User-requested compaction, e.g. the /compact command or the history.compact API.
8374 #[serde(rename = "manual")]
8375 Manual,
8376 /// Emergency compaction triggered by high process memory usage.
8377 #[serde(rename = "memory_pressure")]
8378 MemoryPressure,
8379 /// Compaction requested while switching to a model with a smaller context window.
8380 #[serde(rename = "model_switch")]
8381 ModelSwitch,
8382 /// Unknown variant for forward compatibility.
8383 #[default]
8384 #[serde(other)]
8385 Unknown,
8386}
8387
8388/// Category of structured task blocker
8389#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8390pub enum TaskBlockerKind {
8391 /// Autopilot permission recovery requires intervention or has no safe autonomous path.
8392 #[serde(rename = "permission_recovery")]
8393 PermissionRecovery,
8394 /// Unknown variant for forward compatibility.
8395 #[default]
8396 #[serde(other)]
8397 Unknown,
8398}
8399
8400/// Runtime handling applied to a recovery attempt
8401#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8402pub enum PermissionRecoveryAttemptDisposition {
8403 /// The request was denied without prompting so the agent could try an alternative.
8404 #[serde(rename = "deferred")]
8405 Deferred,
8406 /// The request was surfaced to an interactive responder.
8407 #[serde(rename = "prompted")]
8408 Prompted,
8409 /// The interactive responder approved the request.
8410 #[serde(rename = "approved")]
8411 Approved,
8412 /// The interactive responder denied the request or became unavailable.
8413 #[serde(rename = "denied")]
8414 Denied,
8415 /// The request exhausted unattended recovery and produced a blocked outcome.
8416 #[serde(rename = "blocked")]
8417 Blocked,
8418 /// A tool call succeeded as an equivalent alternative.
8419 #[serde(rename = "succeeded")]
8420 Succeeded,
8421 /// Unknown variant for forward compatibility.
8422 #[default]
8423 #[serde(other)]
8424 Unknown,
8425}
8426
8427/// Controlled reason for an individual attempt disposition
8428#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8429pub enum PermissionRecoveryAttemptReason {
8430 /// The attempt required permission that Assisted Permissions could not grant.
8431 #[serde(rename = "permission_required")]
8432 PermissionRequired,
8433 /// The request repeated an earlier attempt.
8434 #[serde(rename = "repeated_attempt")]
8435 RepeatedAttempt,
8436 /// The request exceeded the bounded number of distinct attempts.
8437 #[serde(rename = "attempts_exhausted")]
8438 AttemptsExhausted,
8439 /// The interactive responder approved the request.
8440 #[serde(rename = "permission_approved")]
8441 PermissionApproved,
8442 /// The interactive responder denied the request.
8443 #[serde(rename = "permission_denied")]
8444 PermissionDenied,
8445 /// The interactive responder became unavailable.
8446 #[serde(rename = "responder_unavailable")]
8447 ResponderUnavailable,
8448 /// The tool call succeeded without the blocked permission.
8449 #[serde(rename = "equivalent_alternative_succeeded")]
8450 EquivalentAlternativeSucceeded,
8451 /// Unknown variant for forward compatibility.
8452 #[default]
8453 #[serde(other)]
8454 Unknown,
8455}
8456
8457/// Relationship of an attempt to earlier permission requests
8458#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8459pub enum PermissionRecoveryAttemptRelation {
8460 /// The first denied permission request in the episode.
8461 #[serde(rename = "initial")]
8462 Initial,
8463 /// A request equivalent to an earlier attempt.
8464 #[serde(rename = "retry")]
8465 Retry,
8466 /// A distinct request or a successful alternative tool call.
8467 #[serde(rename = "alternative")]
8468 Alternative,
8469 /// Unknown variant for forward compatibility.
8470 #[default]
8471 #[serde(other)]
8472 Unknown,
8473}
8474
8475/// Action selected when autonomous recovery cannot continue
8476#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8477pub enum PermissionRecoveryOnBlocked {
8478 /// Surface the existing permission prompt to a response-capable client.
8479 #[serde(rename = "ask")]
8480 Ask,
8481 /// Return a structured unsuccessful blocked outcome because no responder is available.
8482 #[serde(rename = "fail")]
8483 Fail,
8484 /// Unknown variant for forward compatibility.
8485 #[default]
8486 #[serde(other)]
8487 Unknown,
8488}
8489
8490/// Controlled reason for a permission-recovery episode transition
8491#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8492pub enum PermissionRecoveryReason {
8493 /// An action required permission that Assisted Permissions could not grant.
8494 #[serde(rename = "permission_required")]
8495 PermissionRequired,
8496 /// The agent repeated an equivalent permission request instead of making progress.
8497 #[serde(rename = "repeated_attempt")]
8498 RepeatedAttempt,
8499 /// The bounded number of distinct permission attempts was exhausted.
8500 #[serde(rename = "attempts_exhausted")]
8501 AttemptsExhausted,
8502 /// A responder approved the escalated permission request.
8503 #[serde(rename = "permission_approved")]
8504 PermissionApproved,
8505 /// A responder denied the escalated permission request.
8506 #[serde(rename = "permission_denied")]
8507 PermissionDenied,
8508 /// The response-capable client became unavailable while escalation was pending.
8509 #[serde(rename = "responder_unavailable")]
8510 ResponderUnavailable,
8511 /// A later tool call succeeded without requiring the blocked permission.
8512 #[serde(rename = "equivalent_alternative_succeeded")]
8513 EquivalentAlternativeSucceeded,
8514 /// Unknown variant for forward compatibility.
8515 #[default]
8516 #[serde(other)]
8517 Unknown,
8518}
8519
8520/// Lifecycle state of a permission-recovery episode
8521#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8522pub enum PermissionRecoveryStatus {
8523 /// Autopilot may try a bounded equivalent alternative.
8524 #[serde(rename = "recovering")]
8525 Recovering,
8526 /// An interactive permission response is required.
8527 #[serde(rename = "awaiting_approval")]
8528 AwaitingApproval,
8529 /// The episode ended through approval or a successful equivalent alternative.
8530 #[serde(rename = "resolved")]
8531 Resolved,
8532 /// No autonomous path remains and the task requires intervention.
8533 #[serde(rename = "blocked")]
8534 Blocked,
8535 /// Unknown variant for forward compatibility.
8536 #[default]
8537 #[serde(other)]
8538 Unknown,
8539}
8540
8541/// Semantic result of evaluating a task completion request
8542#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8543pub enum TaskCompletionOutcome {
8544 /// The completion request was accepted and the objective is complete.
8545 #[serde(rename = "completed")]
8546 Completed,
8547 /// The completion request was rejected because more work or validation remains.
8548 #[serde(rename = "continue")]
8549 Continue,
8550 /// Completion cannot proceed without intervention; the active objective is paused when one is identified.
8551 #[serde(rename = "blocked")]
8552 Blocked,
8553 /// Unknown variant for forward compatibility.
8554 #[default]
8555 #[serde(other)]
8556 Unknown,
8557}
8558
8559/// Structured terminal status from a tool completion event.
8560#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8561pub enum CompletionReceiptToolStatus {
8562 /// The tool completed successfully.
8563 #[serde(rename = "success")]
8564 Success,
8565 /// The tool failed without a more specific structured status.
8566 #[serde(rename = "failure")]
8567 Failure,
8568 /// The tool exceeded its time budget.
8569 #[serde(rename = "timeout")]
8570 Timeout,
8571 /// The user rejected the tool call.
8572 #[serde(rename = "rejected")]
8573 Rejected,
8574 /// The permissions service denied the tool call.
8575 #[serde(rename = "denied")]
8576 Denied,
8577 /// Unknown variant for forward compatibility.
8578 #[default]
8579 #[serde(other)]
8580 Unknown,
8581}
8582
8583/// Runtime reason the completion decision was accepted.
8584#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8585pub enum CompletionReceiptStopReason {
8586 /// The model reached a natural terminal response.
8587 #[serde(rename = "natural")]
8588 Natural,
8589 /// A terminal tool ended the interaction.
8590 #[serde(rename = "terminal_tool")]
8591 TerminalTool,
8592 /// The configured agentStop continuation limit was reached.
8593 #[serde(rename = "agent_stop_block_limit")]
8594 AgentStopBlockLimit,
8595 /// Unknown variant for forward compatibility.
8596 #[default]
8597 #[serde(other)]
8598 Unknown,
8599}
8600
8601/// Kind of turn for which HydraFusion routing is running.
8602///
8603/// <div class="warning">
8604///
8605/// **Experimental.** This type is part of an experimental wire-protocol surface
8606/// and may change or be removed in future SDK or CLI releases.
8607///
8608/// </div>
8609#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8610pub enum FusionTurnKind {
8611 /// A user-message turn.
8612 #[serde(rename = "user")]
8613 User,
8614 /// A conversation-compaction turn.
8615 #[serde(rename = "compaction")]
8616 Compaction,
8617 /// Unknown variant for forward compatibility.
8618 #[default]
8619 #[serde(other)]
8620 Unknown,
8621}
8622
8623/// Server-recommended routing behavior for a later HydraFusion turn.
8624///
8625/// <div class="warning">
8626///
8627/// **Experimental.** This type is part of an experimental wire-protocol surface
8628/// and may change or be removed in future SDK or CLI releases.
8629///
8630/// </div>
8631#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8632pub enum FusionFollowUpAction {
8633 /// Reuse the durable primary model without routing.
8634 #[serde(rename = "reuse_primary")]
8635 ReusePrimary,
8636 /// Request a new routing decision.
8637 #[serde(rename = "reroute")]
8638 Reroute,
8639 /// Unknown variant for forward compatibility.
8640 #[default]
8641 #[serde(other)]
8642 Unknown,
8643}
8644
8645/// Validated HydraFusion execution pattern.
8646///
8647/// <div class="warning">
8648///
8649/// **Experimental.** This type is part of an experimental wire-protocol surface
8650/// and may change or be removed in future SDK or CLI releases.
8651///
8652/// </div>
8653#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8654pub enum FusionPattern {
8655 /// Run one primary solver phase.
8656 #[serde(rename = "single")]
8657 Single,
8658 /// Run a primary phase, a judge, and an optional repair.
8659 #[serde(rename = "cascade")]
8660 Cascade,
8661 /// Run a primary draft, a read-only critique, and a revision.
8662 #[serde(rename = "critique")]
8663 Critique,
8664 /// Unknown variant for forward compatibility.
8665 #[default]
8666 #[serde(other)]
8667 Unknown,
8668}
8669
8670/// HydraFusion phase kind.
8671///
8672/// <div class="warning">
8673///
8674/// **Experimental.** This type is part of an experimental wire-protocol surface
8675/// and may change or be removed in future SDK or CLI releases.
8676///
8677/// </div>
8678#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8679pub enum FusionPhaseKind {
8680 /// Primary solver phase.
8681 #[serde(rename = "primary")]
8682 Primary,
8683 /// Read-only cascade judge phase.
8684 #[serde(rename = "judge")]
8685 Judge,
8686 /// Cascade repair phase.
8687 #[serde(rename = "repair")]
8688 Repair,
8689 /// Initial critique-pattern draft phase.
8690 #[serde(rename = "draft")]
8691 Draft,
8692 /// Read-only critique phase.
8693 #[serde(rename = "critic")]
8694 Critic,
8695 /// Critique-pattern revision phase.
8696 #[serde(rename = "revision")]
8697 Revision,
8698 /// Follow-up phase continuing from the resolved model.
8699 #[serde(rename = "follow_up")]
8700 FollowUp,
8701 /// Unknown variant for forward compatibility.
8702 #[default]
8703 #[serde(other)]
8704 Unknown,
8705}
8706
8707/// Conversation scope in which a HydraFusion phase executes.
8708///
8709/// <div class="warning">
8710///
8711/// **Experimental.** This type is part of an experimental wire-protocol surface
8712/// and may change or be removed in future SDK or CLI releases.
8713///
8714/// </div>
8715#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8716pub enum FusionConversationScope {
8717 /// Canonical root conversation history.
8718 #[serde(rename = "root")]
8719 Root,
8720 /// Isolated read-only review history that does not enter the root conversation.
8721 #[serde(rename = "review")]
8722 Review,
8723 /// Unknown variant for forward compatibility.
8724 #[default]
8725 #[serde(other)]
8726 Unknown,
8727}
8728
8729/// The agent mode that was active when this message was sent
8730#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8731pub enum UserMessageAgentMode {
8732 /// The agent is responding interactively to the user.
8733 #[serde(rename = "interactive")]
8734 Interactive,
8735 /// The agent is preparing a plan before making changes.
8736 #[serde(rename = "plan")]
8737 Plan,
8738 /// The agent is working autonomously toward task completion.
8739 #[serde(rename = "autopilot")]
8740 Autopilot,
8741 /// The agent is in shell-focused UI mode.
8742 #[serde(rename = "shell")]
8743 Shell,
8744 /// Unknown variant for forward compatibility.
8745 #[default]
8746 #[serde(other)]
8747 Unknown,
8748}
8749
8750/// 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.
8751#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8752pub enum UserMessageDelivery {
8753 /// Delivered while the loop was idle; starts its own run immediately (a human's fresh turn, or a system notification waking an idle agent).
8754 #[serde(rename = "idle")]
8755 Idle,
8756 /// Injected into the current in-flight run while the agent was busy (immediate mode).
8757 #[serde(rename = "steering")]
8758 Steering,
8759 /// Enqueued while the agent was busy; processed as its own run afterward.
8760 #[serde(rename = "queued")]
8761 Queued,
8762 /// Unknown variant for forward compatibility.
8763 #[default]
8764 #[serde(other)]
8765 Unknown,
8766}
8767
8768/// What the agent was doing when the user interrupted it.
8769#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8770pub enum AgentInterruptedActivity {
8771 /// A request to the model was open.
8772 #[serde(rename = "model_call")]
8773 ModelCall,
8774 /// The turn was sleeping between retry attempts.
8775 #[serde(rename = "retry_backoff")]
8776 RetryBackoff,
8777 /// One or more tools were executing.
8778 #[serde(rename = "tool_call")]
8779 ToolCall,
8780 /// Background sub-agents were running while the main loop was idle.
8781 #[serde(rename = "background_agent")]
8782 BackgroundAgent,
8783 /// Unknown variant for forward compatibility.
8784 #[default]
8785 #[serde(other)]
8786 Unknown,
8787}
8788
8789/// Where the interruption landed relative to the first streamed token.
8790#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8791pub enum AgentInterruptedCancelPhase {
8792 /// No output had been produced when the request was cancelled.
8793 #[serde(rename = "pre_first_token")]
8794 PreFirstToken,
8795 /// The response was already streaming when the request was cancelled.
8796 #[serde(rename = "mid_stream")]
8797 MidStream,
8798 /// Unknown variant for forward compatibility.
8799 #[default]
8800 #[serde(other)]
8801 Unknown,
8802}
8803
8804/// Transport used for a failed model call
8805#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8806pub enum ModelCallFailureTransport {
8807 /// HTTP transport, including SSE streams.
8808 #[serde(rename = "http")]
8809 Http,
8810 /// WebSocket transport.
8811 #[serde(rename = "websocket")]
8812 Websocket,
8813 /// Unknown variant for forward compatibility.
8814 #[default]
8815 #[serde(other)]
8816 Unknown,
8817}
8818
8819/// Content-safe activity observed while a HydraFusion phase is running.
8820///
8821/// <div class="warning">
8822///
8823/// **Experimental.** This type is part of an experimental wire-protocol surface
8824/// and may change or be removed in future SDK or CLI releases.
8825///
8826/// </div>
8827#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8828pub enum FusionPhaseActivityKind {
8829 /// The provider produced additional private output bytes.
8830 #[serde(rename = "model_output")]
8831 ModelOutput,
8832 /// A tool began executing inside the phase.
8833 #[serde(rename = "tool_started")]
8834 ToolStarted,
8835 /// A tool finished executing inside the phase.
8836 #[serde(rename = "tool_completed")]
8837 ToolCompleted,
8838 /// Unknown variant for forward compatibility.
8839 #[default]
8840 #[serde(other)]
8841 Unknown,
8842}
8843
8844/// How a durable phase checkpoint contributes its exact message to canonical root history.
8845///
8846/// <div class="warning">
8847///
8848/// **Experimental.** This type is part of an experimental wire-protocol surface
8849/// and may change or be removed in future SDK or CLI releases.
8850///
8851/// </div>
8852#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8853pub enum FusionProjectionMode {
8854 /// Append the exact root message immediately.
8855 #[serde(rename = "append")]
8856 Append,
8857 /// Hold a terminal message outside canonical history until the final commit selects it.
8858 #[serde(rename = "staged")]
8859 Staged,
8860 /// Do not project the checkpoint into root history.
8861 #[serde(rename = "none")]
8862 None,
8863 /// Unknown variant for forward compatibility.
8864 #[default]
8865 #[serde(other)]
8866 Unknown,
8867}
8868
8869/// Durable outcome status of a HydraFusion phase.
8870///
8871/// <div class="warning">
8872///
8873/// **Experimental.** This type is part of an experimental wire-protocol surface
8874/// and may change or be removed in future SDK or CLI releases.
8875///
8876/// </div>
8877#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8878pub enum FusionPhaseStatus {
8879 /// The phase completed successfully.
8880 #[serde(rename = "succeeded")]
8881 Succeeded,
8882 /// The phase failed.
8883 #[serde(rename = "failed")]
8884 Failed,
8885 /// The phase was cancelled.
8886 #[serde(rename = "cancelled")]
8887 Cancelled,
8888 /// Unknown variant for forward compatibility.
8889 #[default]
8890 #[serde(other)]
8891 Unknown,
8892}
8893
8894/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
8895#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8896pub enum AssistantMessageToolRequestType {
8897 /// Standard function-style tool call.
8898 #[serde(rename = "function")]
8899 Function,
8900 /// Custom grammar-based tool call.
8901 #[serde(rename = "custom")]
8902 Custom,
8903 /// Unknown variant for forward compatibility.
8904 #[default]
8905 #[serde(other)]
8906 Unknown,
8907}
8908
8909/// The system that produced a citation.
8910///
8911/// <div class="warning">
8912///
8913/// **Experimental.** This type is part of an experimental wire-protocol surface
8914/// and may change or be removed in future SDK or CLI releases.
8915///
8916/// </div>
8917#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8918pub enum CitationProvider {
8919 /// Citation produced by an Anthropic (Claude) model response.
8920 #[serde(rename = "anthropic")]
8921 Anthropic,
8922 /// Citation produced by an OpenAI model response.
8923 #[serde(rename = "openai")]
8924 Openai,
8925 /// Citation synthesized client-side by the runtime from tool output.
8926 #[serde(rename = "client")]
8927 Client,
8928 /// Unknown variant for forward compatibility.
8929 #[default]
8930 #[serde(other)]
8931 Unknown,
8932}
8933
8934/// Hosted program caller type
8935#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8936pub enum AssistantMessageToolRequestCallerType {
8937 #[serde(rename = "program")]
8938 Program,
8939 /// Unknown variant for forward compatibility.
8940 #[default]
8941 #[serde(other)]
8942 Unknown,
8943}
8944
8945/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
8946#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8947pub enum AssistantUsageApiEndpoint {
8948 /// Chat Completions API endpoint.
8949 #[serde(rename = "/chat/completions")]
8950 ChatCompletions,
8951 /// Anthropic Messages API endpoint.
8952 #[serde(rename = "/v1/messages")]
8953 V1Messages,
8954 /// Responses API endpoint.
8955 #[serde(rename = "/responses")]
8956 Responses,
8957 /// WebSocket Responses API endpoint.
8958 #[serde(rename = "ws:/responses")]
8959 WsResponses,
8960 /// Unknown variant for forward compatibility.
8961 #[default]
8962 #[serde(other)]
8963 Unknown,
8964}
8965
8966/// Transport used for a successful model call
8967#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8968pub enum AssistantUsageTransport {
8969 /// HTTP transport, including SSE streams.
8970 #[serde(rename = "http")]
8971 Http,
8972 /// WebSocket transport.
8973 #[serde(rename = "websocket")]
8974 Websocket,
8975 /// Unknown variant for forward compatibility.
8976 #[default]
8977 #[serde(other)]
8978 Unknown,
8979}
8980
8981/// 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.
8982#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8983pub enum ModelCallFailureBadRequestKind {
8984 /// The 400 response carried no error body (transient gateway/proxy signature).
8985 #[serde(rename = "bodyless")]
8986 Bodyless,
8987 /// The 400 response carried a structured CAPI error envelope (deterministic validation failure).
8988 #[serde(rename = "structured_error")]
8989 StructuredError,
8990 /// Unknown variant for forward compatibility.
8991 #[default]
8992 #[serde(other)]
8993 Unknown,
8994}
8995
8996/// Boundary that produced a model call failure
8997#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8998pub enum ModelCallFailureKind {
8999 /// The provider returned an API error response.
9000 #[serde(rename = "api")]
9001 Api,
9002 /// The request transport failed before a usable API response completed.
9003 #[serde(rename = "transport")]
9004 Transport,
9005 /// Unknown variant for forward compatibility.
9006 #[default]
9007 #[serde(other)]
9008 Unknown,
9009}
9010
9011/// Where the failed model call originated
9012#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9013pub enum ModelCallFailureSource {
9014 /// Model call from the top-level agent.
9015 #[serde(rename = "top_level")]
9016 TopLevel,
9017 /// Model call from a sub-agent.
9018 #[serde(rename = "subagent")]
9019 Subagent,
9020 /// Model call from MCP sampling.
9021 #[serde(rename = "mcp_sampling")]
9022 McpSampling,
9023 /// Unknown variant for forward compatibility.
9024 #[default]
9025 #[serde(other)]
9026 Unknown,
9027}
9028
9029/// Final outcome of one logical model dispatch after response acceptance processing
9030#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9031pub enum ModelCallFinishedOutcome {
9032 /// The provider response was accepted for continued agent processing.
9033 #[serde(rename = "success")]
9034 Success,
9035 /// The dispatch ended with a provider or transport error.
9036 #[serde(rename = "error")]
9037 Error,
9038 /// The dispatch was cancelled before an accepted response was produced.
9039 #[serde(rename = "cancelled")]
9040 Cancelled,
9041 /// The provider response was rejected during post-response acceptance processing.
9042 #[serde(rename = "rejected")]
9043 Rejected,
9044 /// Unknown variant for forward compatibility.
9045 #[default]
9046 #[serde(other)]
9047 Unknown,
9048}
9049
9050/// Finite reason code describing why the current turn was aborted
9051#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9052pub enum AbortReason {
9053 /// The local user requested the abort, for example by pressing Ctrl+C in the CLI.
9054 #[serde(rename = "user_initiated")]
9055 UserInitiated,
9056 /// A remote command requested the abort.
9057 #[serde(rename = "remote_command")]
9058 RemoteCommand,
9059 /// An MCP server delivered a user.abort notification.
9060 #[serde(rename = "user_abort")]
9061 UserAbort,
9062 /// Autopilot stopped the run because the active objective reached its user-set --max-ai-credits limit.
9063 #[serde(rename = "autopilot_credit_limit")]
9064 AutopilotCreditLimit,
9065 /// Unknown variant for forward compatibility.
9066 #[default]
9067 #[serde(other)]
9068 Unknown,
9069}
9070
9071/// Configuration source: user, workspace, plugin, builtin, or managed
9072#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9073pub enum McpServerSource {
9074 /// Server configured in the user's global MCP configuration.
9075 #[serde(rename = "user")]
9076 User,
9077 /// Server configured by the current workspace.
9078 #[serde(rename = "workspace")]
9079 Workspace,
9080 /// Server contributed by an installed plugin.
9081 #[serde(rename = "plugin")]
9082 Plugin,
9083 /// Server bundled with the runtime.
9084 #[serde(rename = "builtin")]
9085 Builtin,
9086 /// Server supplied by a trusted host-managed catalog.
9087 #[serde(rename = "managed")]
9088 Managed,
9089 /// Unknown variant for forward compatibility.
9090 #[default]
9091 #[serde(other)]
9092 Unknown,
9093}
9094
9095/// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
9096#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9097pub enum McpServerTransport {
9098 /// Server communicates over stdio with a local child process.
9099 #[serde(rename = "stdio")]
9100 Stdio,
9101 /// Server communicates over streamable HTTP.
9102 #[serde(rename = "http")]
9103 Http,
9104 /// Server communicates over Server-Sent Events (deprecated).
9105 #[serde(rename = "sse")]
9106 Sse,
9107 /// Server is backed by an in-memory runtime implementation.
9108 #[serde(rename = "memory")]
9109 Memory,
9110 /// Unknown variant for forward compatibility.
9111 #[default]
9112 #[serde(other)]
9113 Unknown,
9114}
9115
9116/// Allowed values for the `ToolExecutionStartToolDescriptionMetaUIVisibility` enumeration.
9117#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9118pub enum ToolExecutionStartToolDescriptionMetaUIVisibility {
9119 /// Tool is callable by the model (LLM tool surface)
9120 #[serde(rename = "model")]
9121 Model,
9122 /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
9123 #[serde(rename = "app")]
9124 App,
9125 /// Unknown variant for forward compatibility.
9126 #[default]
9127 #[serde(other)]
9128 Unknown,
9129}
9130
9131/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9132#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9133pub enum PersistedBinaryImageType {
9134 /// Binary image data.
9135 #[serde(rename = "image")]
9136 Image,
9137 /// Other binary resource data.
9138 #[serde(rename = "resource")]
9139 Resource,
9140 /// Unknown variant for forward compatibility.
9141 #[default]
9142 #[serde(other)]
9143 Unknown,
9144}
9145
9146/// Why the binary data is absent: it exceeded the inline size limit, or its asset was unavailable
9147#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9148pub enum OmittedBinaryOmittedReason {
9149 /// Bytes exceeded the session's inline size limit.
9150 #[serde(rename = "too_large")]
9151 TooLarge,
9152 /// The referenced binary asset could not be found (e.g. a truncated log).
9153 #[serde(rename = "asset_unavailable")]
9154 AssetUnavailable,
9155 /// Unknown variant for forward compatibility.
9156 #[default]
9157 #[serde(other)]
9158 Unknown,
9159}
9160
9161/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9162#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9163pub enum OmittedBinaryType {
9164 /// Binary image data.
9165 #[serde(rename = "image")]
9166 Image,
9167 /// Other binary resource data.
9168 #[serde(rename = "resource")]
9169 Resource,
9170 /// Unknown variant for forward compatibility.
9171 #[default]
9172 #[serde(other)]
9173 Unknown,
9174}
9175
9176/// Binary result type discriminator. Use "image" for images and "resource" for other binary data.
9177#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9178pub enum BinaryAssetReferenceType {
9179 /// Binary image data.
9180 #[serde(rename = "image")]
9181 Image,
9182 /// Other binary resource data.
9183 #[serde(rename = "resource")]
9184 Resource,
9185 /// Unknown variant for forward compatibility.
9186 #[default]
9187 #[serde(other)]
9188 Unknown,
9189}
9190
9191/// A model-facing binary result as persisted: full inline data, a size-omitted marker, or a deduplicated asset reference
9192///
9193/// <div class="warning">
9194///
9195/// **Experimental.** This type is part of an experimental wire-protocol surface
9196/// and may change or be removed in future SDK or CLI releases.
9197///
9198/// </div>
9199#[derive(Debug, Clone, Serialize, Deserialize)]
9200#[serde(untagged)]
9201pub enum PersistedBinaryResult {
9202 PersistedBinaryImage(PersistedBinaryImage),
9203 OmittedBinaryResult(OmittedBinaryResult),
9204 BinaryAssetReference(BinaryAssetReference),
9205}
9206
9207/// Content block type discriminator
9208#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9209pub enum ToolExecutionCompleteContentTextType {
9210 #[serde(rename = "text")]
9211 #[default]
9212 Text,
9213}
9214
9215/// Content block type discriminator
9216#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9217pub enum ToolExecutionCompleteContentTerminalType {
9218 #[serde(rename = "terminal")]
9219 #[default]
9220 Terminal,
9221}
9222
9223/// Content block type discriminator
9224#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9225pub enum ToolExecutionCompleteContentShellExitType {
9226 #[serde(rename = "shell_exit")]
9227 #[default]
9228 ShellExit,
9229}
9230
9231/// Content block type discriminator
9232#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9233pub enum ToolExecutionCompleteContentImageType {
9234 #[serde(rename = "image")]
9235 #[default]
9236 Image,
9237}
9238
9239/// Content block type discriminator
9240#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9241pub enum ToolExecutionCompleteContentAudioType {
9242 #[serde(rename = "audio")]
9243 #[default]
9244 Audio,
9245}
9246
9247/// Theme variant this icon is intended for
9248#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9249pub enum ToolExecutionCompleteContentResourceLinkIconTheme {
9250 /// Icon intended for light themes.
9251 #[serde(rename = "light")]
9252 Light,
9253 /// Icon intended for dark themes.
9254 #[serde(rename = "dark")]
9255 Dark,
9256 /// Unknown variant for forward compatibility.
9257 #[default]
9258 #[serde(other)]
9259 Unknown,
9260}
9261
9262/// Content block type discriminator
9263#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9264pub enum ToolExecutionCompleteContentResourceLinkType {
9265 #[serde(rename = "resource_link")]
9266 #[default]
9267 ResourceLink,
9268}
9269
9270/// The embedded resource contents, either text or base64-encoded binary
9271#[derive(Debug, Clone, Serialize, Deserialize)]
9272#[serde(untagged)]
9273pub enum ToolExecutionCompleteContentResourceDetails {
9274 EmbeddedTextResourceContents(EmbeddedTextResourceContents),
9275 EmbeddedBlobResourceContents(EmbeddedBlobResourceContents),
9276}
9277
9278/// Content block type discriminator
9279#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9280pub enum ToolExecutionCompleteContentResourceType {
9281 #[serde(rename = "resource")]
9282 #[default]
9283 Resource,
9284}
9285
9286/// A content block within a tool result, which may be text, terminal output, image, audio, or a resource
9287#[derive(Debug, Clone, Serialize, Deserialize)]
9288#[serde(untagged)]
9289pub enum ToolExecutionCompleteContent {
9290 Text(ToolExecutionCompleteContentText),
9291 Terminal(ToolExecutionCompleteContentTerminal),
9292 ShellExit(ToolExecutionCompleteContentShellExit),
9293 Image(ToolExecutionCompleteContentImage),
9294 Audio(ToolExecutionCompleteContentAudio),
9295 ResourceLink(ToolExecutionCompleteContentResourceLink),
9296 Resource(ToolExecutionCompleteContentResource),
9297}
9298
9299/// Allowed values for the `ToolExecutionCompleteToolDescriptionMetaUIVisibility` enumeration.
9300#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9301pub enum ToolExecutionCompleteToolDescriptionMetaUIVisibility {
9302 /// Tool is callable by the model (LLM tool surface)
9303 #[serde(rename = "model")]
9304 Model,
9305 /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
9306 #[serde(rename = "app")]
9307 App,
9308 /// Unknown variant for forward compatibility.
9309 #[default]
9310 #[serde(other)]
9311 Unknown,
9312}
9313
9314/// 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)
9315#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9316pub enum SkillInvokedTrigger {
9317 /// Skill invocation requested explicitly by the user, such as via a slash command or UI affordance.
9318 #[serde(rename = "user-invoked")]
9319 UserInvoked,
9320 /// Skill invocation requested by the agent.
9321 #[serde(rename = "agent-invoked")]
9322 AgentInvoked,
9323 /// Skill content loaded as part of another context, such as a configured custom agent or subagent.
9324 #[serde(rename = "context-load")]
9325 ContextLoad,
9326 /// Unknown variant for forward compatibility.
9327 #[default]
9328 #[serde(other)]
9329 Unknown,
9330}
9331
9332/// Process-containment backend selected for the host platform
9333#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9334pub enum SandboxBackend {
9335 /// Apple Seatbelt process sandbox.
9336 #[serde(rename = "seatbelt")]
9337 Seatbelt,
9338 /// Linux Bubblewrap process sandbox.
9339 #[serde(rename = "bubblewrap")]
9340 Bubblewrap,
9341 /// Windows ProcessContainer sandbox.
9342 #[serde(rename = "process_container")]
9343 ProcessContainer,
9344 /// No supported process-containment backend is available.
9345 #[serde(rename = "unsupported")]
9346 Unsupported,
9347 /// Unknown variant for forward compatibility.
9348 #[default]
9349 #[serde(other)]
9350 Unknown,
9351}
9352
9353/// Customer-controllable sandbox governance area
9354#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9355pub enum SandboxControl {
9356 /// Process containment and sandbox spawn behavior.
9357 #[serde(rename = "process")]
9358 Process,
9359 /// Filesystem read, write, and deny policy.
9360 #[serde(rename = "filesystem")]
9361 Filesystem,
9362 /// Outbound and local-network access policy.
9363 #[serde(rename = "network")]
9364 Network,
9365 /// Selection of the sandbox or built-in enforcement route.
9366 #[serde(rename = "routing")]
9367 Routing,
9368 /// Decisions to run outside the process sandbox, whether requested by the model or resolved by a person.
9369 #[serde(rename = "bypass")]
9370 Bypass,
9371 /// Credential and keychain capability injection.
9372 #[serde(rename = "credentials")]
9373 Credentials,
9374 /// Host-platform and backend support behavior.
9375 #[serde(rename = "platform")]
9376 Platform,
9377 /// Unknown variant for forward compatibility.
9378 #[default]
9379 #[serde(other)]
9380 Unknown,
9381}
9382
9383/// Finite reason why sandbox enforcement is weaker than configured
9384#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9385pub enum SandboxDegradationReason {
9386 /// The selected backend cannot enforce per-path deny rules.
9387 #[serde(rename = "denied_paths_unsupported")]
9388 DeniedPathsUnsupported,
9389 /// The host platform has no supported process-containment backend.
9390 #[serde(rename = "unsupported_platform")]
9391 UnsupportedPlatform,
9392 /// Unknown variant for forward compatibility.
9393 #[default]
9394 #[serde(other)]
9395 Unknown,
9396}
9397
9398/// Runtime boundary that enforced or routed a sandbox decision
9399#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9400pub enum SandboxEnforcementPoint {
9401 /// Shell command process containment.
9402 #[serde(rename = "shell")]
9403 Shell,
9404 /// Built-in filesystem policy enforcement.
9405 #[serde(rename = "builtin_filesystem")]
9406 BuiltinFilesystem,
9407 /// Search-tool sandbox or policy enforcement.
9408 #[serde(rename = "search")]
9409 Search,
9410 /// Web-fetch network policy enforcement.
9411 #[serde(rename = "web_fetch")]
9412 WebFetch,
9413 /// Model Context Protocol server routing.
9414 #[serde(rename = "mcp")]
9415 Mcp,
9416 /// Language server process routing.
9417 #[serde(rename = "lsp")]
9418 Lsp,
9419 /// Unknown variant for forward compatibility.
9420 #[default]
9421 #[serde(other)]
9422 Unknown,
9423}
9424
9425/// Sandbox decision variant discriminator.
9426#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9427pub enum SandboxDecisionDataPolicyResolvedKind {
9428 #[serde(rename = "policy_resolved")]
9429 #[default]
9430 PolicyResolved,
9431}
9432
9433/// Finite result of a sandbox decision. Each `SandboxDecisionData` variant uses a disjoint subset: `policy_resolved` is `resolved | degraded`, `spawn_completed` and `permissive_retry_completed` are `succeeded | failed`, `enforcement_state` is `engaged | inactive | failed`, `access_denied` is `denied`, and escalation decisions are `approved | declined`.
9434#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9435pub enum SandboxOutcome {
9436 /// The sandbox policy resolved successfully. Describes configuration only and makes no claim that a backend engaged.
9437 #[serde(rename = "resolved")]
9438 Resolved,
9439 /// No sandbox governed the workload.
9440 #[serde(rename = "inactive")]
9441 Inactive,
9442 /// A runtime-owned containment backend accepted the workload. Evidence of engagement, not of verified containment for the workload's lifetime.
9443 #[serde(rename = "engaged")]
9444 Engaged,
9445 /// The sandbox operation completed successfully.
9446 #[serde(rename = "succeeded")]
9447 Succeeded,
9448 /// The sandbox operation failed.
9449 #[serde(rename = "failed")]
9450 Failed,
9451 /// The sandbox is active with one or more controls weakened by platform limitations or an explicitly selected relaxed mode.
9452 #[serde(rename = "degraded")]
9453 Degraded,
9454 /// An enforcement check refused the requested access.
9455 #[serde(rename = "denied")]
9456 Denied,
9457 /// A request to run outside the process sandbox was granted.
9458 #[serde(rename = "approved")]
9459 Approved,
9460 /// A request to run outside the process sandbox was not granted.
9461 #[serde(rename = "declined")]
9462 Declined,
9463 /// Unknown variant for forward compatibility.
9464 #[default]
9465 #[serde(other)]
9466 Unknown,
9467}
9468
9469/// Host operating-system family used for sandbox enforcement
9470#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9471pub enum SandboxPlatform {
9472 /// Apple macOS host.
9473 #[serde(rename = "macos")]
9474 Macos,
9475 /// Linux host.
9476 #[serde(rename = "linux")]
9477 Linux,
9478 /// Microsoft Windows host.
9479 #[serde(rename = "windows")]
9480 Windows,
9481 /// Host platform outside the explicitly supported families.
9482 #[serde(rename = "other")]
9483 Other,
9484 /// Unknown variant for forward compatibility.
9485 #[default]
9486 #[serde(other)]
9487 Unknown,
9488}
9489
9490/// Origin of the effective sandbox policy
9491#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9492pub enum SandboxPolicySource {
9493 /// Runtime default sandbox policy.
9494 #[serde(rename = "default_policy")]
9495 DefaultPolicy,
9496 /// User-configured sandbox policy merged with runtime-required grants.
9497 #[serde(rename = "user_policy")]
9498 UserPolicy,
9499 /// Unknown variant for forward compatibility.
9500 #[default]
9501 #[serde(other)]
9502 Unknown,
9503}
9504
9505/// Bounded classification of effective sandbox proxy routing
9506#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9507pub enum SandboxProxyMode {
9508 /// No sandbox proxy is configured.
9509 #[serde(rename = "none")]
9510 None,
9511 /// Traffic routes through a loopback proxy.
9512 #[serde(rename = "loopback")]
9513 Loopback,
9514 /// Traffic routes through a non-loopback proxy endpoint.
9515 #[serde(rename = "external")]
9516 External,
9517 /// Unknown variant for forward compatibility.
9518 #[default]
9519 #[serde(other)]
9520 Unknown,
9521}
9522
9523/// Sandbox decision variant discriminator.
9524#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9525pub enum SandboxDecisionDataSpawnCompletedKind {
9526 #[serde(rename = "spawn_completed")]
9527 #[default]
9528 SpawnCompleted,
9529}
9530
9531/// Runtime observation backing an enforcement-state or denial claim. Absent on `enforcement_state` when no observation backs the state.
9532#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9533pub enum SandboxAttestation {
9534 /// A containment backend accepted and applied the spawn request.
9535 #[serde(rename = "spawn_succeeded")]
9536 SpawnSucceeded,
9537 /// The spawn was refused for lack of a usable containment backend.
9538 #[serde(rename = "unsupported")]
9539 Unsupported,
9540 /// A runtime-owned policy check ran and returned a verdict. Attests the check, not that the caller honoured it.
9541 #[serde(rename = "builtin_policy_checked")]
9542 BuiltinPolicyChecked,
9543 /// Unknown variant for forward compatibility.
9544 #[default]
9545 #[serde(other)]
9546 Unknown,
9547}
9548
9549/// Sandbox decision variant discriminator.
9550#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9551pub enum SandboxDecisionDataEnforcementStateKind {
9552 #[serde(rename = "enforcement_state")]
9553 #[default]
9554 EnforcementState,
9555}
9556
9557/// How strong the evidence behind a denial is. A denial the sandbox itself recorded is a fact; one inferred from a command's output text is a judgement, and an analysis that cannot tell them apart will treat a false positive as enforcement.
9558#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9559pub enum SandboxDenialConfidence {
9560 /// The sandbox's own denial capture recorded the refused access. The strongest evidence available: the kernel observed it, not the runtime.
9561 #[serde(rename = "captured")]
9562 Captured,
9563 /// The command named a path that the effective policy independently denies. No capture confirmed it, but the policy did.
9564 #[serde(rename = "policy_corroborated")]
9565 PolicyCorroborated,
9566 /// The failure carried a fingerprint the sandbox itself emits, so the sandbox is known to have refused something even though the resource was not confirmed.
9567 #[serde(rename = "sandbox_reported")]
9568 SandboxReported,
9569 /// Classified from the command's own output text alone. The weakest evidence: a command that merely prints sandbox-like wording reaches this level.
9570 #[serde(rename = "output_classified")]
9571 OutputClassified,
9572 /// Unknown variant for forward compatibility.
9573 #[default]
9574 #[serde(other)]
9575 Unknown,
9576}
9577
9578/// Bounded class of access an enforcement check refused. Raw resources, commands, and process names accompany it only when content capture is enabled; diagnostic text and matched rules are never exported.
9579#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9580pub enum SandboxDenialClass {
9581 /// A read was refused because the effective policy does not grant it.
9582 #[serde(rename = "filesystem_read")]
9583 FilesystemRead,
9584 /// A write was refused. Distinct from `filesystem_read` because a read-only grant denies writes to a path it otherwise permits.
9585 #[serde(rename = "filesystem_write")]
9586 FilesystemWrite,
9587 /// A process could not start because the sandbox refused a required process-scoped resource. Currently emitted for the Windows MSYS `BaseNamedObjects` fork failure confirmed by learning-mode capture.
9588 #[serde(rename = "process_startup")]
9589 ProcessStartup,
9590 /// Windows registry access was refused and correlated with capture evidence.
9591 #[serde(rename = "registry_access")]
9592 RegistryAccess,
9593 /// Windows ALPC or RPC access was refused and correlated with capture evidence.
9594 #[serde(rename = "ipc_access")]
9595 IpcAccess,
9596 /// Access to another Windows process was refused and correlated with capture evidence.
9597 #[serde(rename = "process_access")]
9598 ProcessAccess,
9599 /// Windows job-object access was refused and correlated with capture evidence.
9600 #[serde(rename = "job_access")]
9601 JobAccess,
9602 /// Windows UI-handle access was refused and correlated with capture evidence.
9603 #[serde(rename = "ui_access")]
9604 UiAccess,
9605 /// Windows service-control-manager access was refused and correlated with capture evidence.
9606 #[serde(rename = "service_access")]
9607 ServiceAccess,
9608 /// An outbound connection was refused by `network.allowOutbound`.
9609 #[serde(rename = "network_outbound")]
9610 NetworkOutbound,
9611 /// A connection to a local or loopback destination was refused by `network.allowLocalNetwork`.
9612 #[serde(rename = "network_local")]
9613 NetworkLocal,
9614 /// A destination was refused by the sandbox host allow/deny rules.
9615 #[serde(rename = "network_host")]
9616 NetworkHost,
9617 /// The sandbox's denial capture recorded a refusal its record does not attribute to a more specific control: an unclassified resource (registry, COM, section object) or an AppContainer capability with no network meaning. Deliberately generic — the capture proves the denial happened, and naming a narrower class than the record supports would be a guess.
9618 #[serde(rename = "other_access")]
9619 OtherAccess,
9620 /// Unknown variant for forward compatibility.
9621 #[default]
9622 #[serde(other)]
9623 Unknown,
9624}
9625
9626/// Sandbox decision variant discriminator.
9627#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9628pub enum SandboxDecisionDataAccessDeniedKind {
9629 #[serde(rename = "access_denied")]
9630 #[default]
9631 AccessDenied,
9632}
9633
9634/// Sandbox decision variant discriminator.
9635#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9636pub enum SandboxDecisionDataBypassDecidedKind {
9637 #[serde(rename = "bypass_decided")]
9638 #[default]
9639 BypassDecided,
9640}
9641
9642/// Where a request to run outside the process sandbox originated. Orthogonal to the outcome: the same verdict means a different thing depending on where the request came from.
9643#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9644pub enum SandboxBypassSource {
9645 /// No longer produced. The model could once ask for a bypass in the tool call itself; no tool exposes that parameter now. Retained so historical events still deserialize.
9646 #[serde(rename = "model_requested")]
9647 ModelRequested,
9648 /// The runtime raised the prompt itself — either after a sandboxed attempt looked blocked, or before a run the sandbox cannot enforce at all, such as a detached command — and a person answered it. In the second case nothing had executed when the decision was made.
9649 #[serde(rename = "user_prompted")]
9650 UserPrompted,
9651 /// The runtime raised the prompt itself — after a sandboxed attempt looked blocked, or before a run it cannot enforce — but the permission flow produced no confirmed human answer. This includes unavailable or unreadable prompts, cancellation, and automated rule, hook, or content-exclusion denials.
9652 #[serde(rename = "prompt_unavailable")]
9653 PromptUnavailable,
9654 /// Unknown variant for forward compatibility.
9655 #[default]
9656 #[serde(other)]
9657 Unknown,
9658}
9659
9660/// Sandbox decision variant discriminator.
9661#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9662pub enum SandboxDecisionDataPermissiveRetryDecidedKind {
9663 #[serde(rename = "permissive_retry_decided")]
9664 #[default]
9665 PermissiveRetryDecided,
9666}
9667
9668/// Sandbox decision variant discriminator.
9669#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9670pub enum SandboxDecisionDataPermissiveRetryCompletedKind {
9671 #[serde(rename = "permissive_retry_completed")]
9672 #[default]
9673 PermissiveRetryCompleted,
9674}
9675
9676/// 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`.
9677#[derive(Debug, Clone, Serialize, Deserialize)]
9678#[serde(untagged)]
9679pub enum SandboxDecisionData {
9680 PolicyResolved(SandboxDecisionDataPolicyResolved),
9681 SpawnCompleted(SandboxDecisionDataSpawnCompleted),
9682 EnforcementState(SandboxDecisionDataEnforcementState),
9683 AccessDenied(SandboxDecisionDataAccessDenied),
9684 BypassDecided(SandboxDecisionDataBypassDecided),
9685 PermissiveRetryDecided(SandboxDecisionDataPermissiveRetryDecided),
9686 PermissiveRetryCompleted(SandboxDecisionDataPermissiveRetryCompleted),
9687}
9688
9689/// Authority or runtime mechanism responsible for sub-agent model selection.
9690#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9691pub enum SubagentModelSelectionSource {
9692 /// Explicit model supplied by the parent agent on the task call and selected for dispatch.
9693 #[serde(rename = "explicit_override")]
9694 ExplicitOverride,
9695 /// Required model policy configured for the sub-agent.
9696 #[serde(rename = "configured_required")]
9697 ConfiguredRequired,
9698 /// Non-required model preference configured for the sub-agent.
9699 #[serde(rename = "configured_preference")]
9700 ConfiguredPreference,
9701 /// Complementary-model default selected for the sub-agent.
9702 #[serde(rename = "complementary_default")]
9703 ComplementaryDefault,
9704 /// Model inherited from the parent session.
9705 #[serde(rename = "session_inheritance")]
9706 SessionInheritance,
9707 /// Default model declared by the agent definition.
9708 #[serde(rename = "agent_definition_default")]
9709 AgentDefinitionDefault,
9710 /// Runtime policy, Auto mode, or an experiment selected the model.
9711 #[serde(rename = "runtime_policy")]
9712 RuntimePolicy,
9713 /// Unknown variant for forward compatibility.
9714 #[default]
9715 #[serde(other)]
9716 Unknown,
9717}
9718
9719/// Where the model input for a task-tool sub-agent came from.
9720#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9721pub enum SubagentTaskModelSource {
9722 /// The spawning agent supplied the task tool's model argument.
9723 #[serde(rename = "task_argument")]
9724 TaskArgument,
9725 /// The task omitted a model and the per-sub-agent settings entry supplied a concrete one.
9726 #[serde(rename = "subagent_configuration")]
9727 SubagentConfiguration,
9728 /// The task omitted a model and the user-defined custom agent's definition supplied one.
9729 #[serde(rename = "custom_agent_definition")]
9730 CustomAgentDefinition,
9731 /// Neither the task call, the per-sub-agent settings entry, nor a custom agent definition supplied a model.
9732 #[serde(rename = "unset")]
9733 Unset,
9734 /// Unknown variant for forward compatibility.
9735 #[default]
9736 #[serde(other)]
9737 Unknown,
9738}
9739
9740/// Binary asset type discriminator. Use "image" for images and "resource" otherwise.
9741#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9742pub enum BinaryAssetType {
9743 /// Binary image data.
9744 #[serde(rename = "image")]
9745 Image,
9746 /// Other binary resource data.
9747 #[serde(rename = "resource")]
9748 Resource,
9749 /// Unknown variant for forward compatibility.
9750 #[default]
9751 #[serde(other)]
9752 Unknown,
9753}
9754
9755/// Message role: "system" for system prompts, "developer" for developer-injected instructions
9756#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9757pub enum SystemMessageRole {
9758 /// System prompt message.
9759 #[serde(rename = "system")]
9760 System,
9761 /// Developer instruction message.
9762 #[serde(rename = "developer")]
9763 Developer,
9764 /// Unknown variant for forward compatibility.
9765 #[default]
9766 #[serde(other)]
9767 Unknown,
9768}
9769
9770/// Permission kind discriminator
9771#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9772pub enum PermissionRequestShellKind {
9773 #[serde(rename = "shell")]
9774 #[default]
9775 Shell,
9776}
9777
9778/// Permission kind discriminator
9779#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9780pub enum PermissionRequestWriteKind {
9781 #[serde(rename = "write")]
9782 #[default]
9783 Write,
9784}
9785
9786/// Permission kind discriminator
9787#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9788pub enum PermissionRequestReadKind {
9789 #[serde(rename = "read")]
9790 #[default]
9791 Read,
9792}
9793
9794/// Permission kind discriminator
9795#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9796pub enum PermissionRequestMcpKind {
9797 #[serde(rename = "mcp")]
9798 #[default]
9799 Mcp,
9800}
9801
9802/// 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.
9803///
9804/// <div class="warning">
9805///
9806/// **Experimental.** This type is part of an experimental wire-protocol surface
9807/// and may change or be removed in future SDK or CLI releases.
9808///
9809/// </div>
9810#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9811pub enum PermissionRecommendation {
9812 /// 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.
9813 #[serde(rename = "approve")]
9814 Approve,
9815 /// Unknown variant for forward compatibility.
9816 #[default]
9817 #[serde(other)]
9818 Unknown,
9819}
9820
9821/// Permission kind discriminator
9822#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9823pub enum PermissionRequestUrlKind {
9824 #[serde(rename = "url")]
9825 #[default]
9826 Url,
9827}
9828
9829/// Whether this is a store or vote memory operation
9830#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9831pub enum PermissionRequestMemoryAction {
9832 /// Store a new memory.
9833 #[serde(rename = "store")]
9834 Store,
9835 /// Vote on an existing memory.
9836 #[serde(rename = "vote")]
9837 Vote,
9838 /// Unknown variant for forward compatibility.
9839 #[default]
9840 #[serde(other)]
9841 Unknown,
9842}
9843
9844/// Stage that produced this attribution.
9845#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9846pub enum PermissionApprovalEvaluationEvaluationStage {
9847 /// The attribution stage is unknown.
9848 #[serde(rename = "unknown")]
9849 UnknownValue,
9850 /// The request resolved before assisted-approval evaluation.
9851 #[serde(rename = "not_reached")]
9852 NotReached,
9853 /// A runtime gate skipped the judge.
9854 #[serde(rename = "pre_judge")]
9855 PreJudge,
9856 /// The judge interface produced the evaluation.
9857 #[serde(rename = "judge")]
9858 Judge,
9859 /// A cached recommendation or another request's outcome was reused.
9860 #[serde(rename = "reuse")]
9861 Reuse,
9862 /// Unknown variant for forward compatibility.
9863 #[default]
9864 #[serde(other)]
9865 Unknown,
9866}
9867
9868/// Status of the local judge interface, not proof of a model network call.
9869#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9870pub enum PermissionApprovalEvaluationJudgeStatus {
9871 /// No authoritative attribution is available.
9872 #[serde(rename = "unknown")]
9873 UnknownValue,
9874 /// This evaluation did not invoke the judge interface.
9875 #[serde(rename = "not_called")]
9876 NotCalled,
9877 /// The judge interface returned a usable verdict.
9878 #[serde(rename = "completed")]
9879 Completed,
9880 /// The judge interface returned an error.
9881 #[serde(rename = "failed")]
9882 Failed,
9883 /// This evaluation reused a cached recommendation.
9884 #[serde(rename = "cached")]
9885 Cached,
9886 /// This request inherited another decision without local judge attribution.
9887 #[serde(rename = "inherited")]
9888 Inherited,
9889 /// Unknown variant for forward compatibility.
9890 #[default]
9891 #[serde(other)]
9892 Unknown,
9893}
9894
9895/// Machine-readable runtime gate reason, never a command, path or human rationale.
9896#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9897pub enum PermissionApprovalEvaluationReasonCode {
9898 /// Attribution is missing or outside the supported vocabulary.
9899 #[serde(rename = "unknown")]
9900 UnknownValue,
9901 /// The request resolved before assisted-approval evaluation.
9902 #[serde(rename = "not-reached")]
9903 NotReached,
9904 /// Assisted approval was inactive for this request.
9905 #[serde(rename = "inactive")]
9906 Inactive,
9907 /// The judge was skipped because authorization extraction could not safely establish a complete recent history.
9908 #[serde(rename = "authorization-history-incomplete")]
9909 AuthorizationHistoryIncomplete,
9910 /// Managed policy required a human decision.
9911 #[serde(rename = "managed-approval-required")]
9912 ManagedApprovalRequired,
9913 /// The request asked to bypass sandbox restrictions.
9914 #[serde(rename = "sandbox-bypass")]
9915 SandboxBypass,
9916 /// An action field exceeded the judge input limit.
9917 #[serde(rename = "action-too-long")]
9918 ActionTooLong,
9919 /// The script path was not authorized for inspection.
9920 #[serde(rename = "path-not-authorized")]
9921 PathNotAuthorized,
9922 /// The script working directory was invalid.
9923 #[serde(rename = "invalid-working-directory")]
9924 InvalidWorkingDirectory,
9925 /// The script snapshot could not be read.
9926 #[serde(rename = "unreadable")]
9927 Unreadable,
9928 /// The script path was not a regular file.
9929 #[serde(rename = "not-regular-file")]
9930 NotRegularFile,
9931 /// The script snapshot exceeded the size limit.
9932 #[serde(rename = "too-large")]
9933 TooLarge,
9934 /// The script snapshot was not UTF-8.
9935 #[serde(rename = "non-utf8")]
9936 NonUtf8,
9937 /// The script interpreter could not be inspected.
9938 #[serde(rename = "interpreter-unavailable")]
9939 InterpreterUnavailable,
9940 /// The interpreter snapshot exceeded the size limit.
9941 #[serde(rename = "interpreter-too-large")]
9942 InterpreterTooLarge,
9943 /// The shell environment could not be reviewed.
9944 #[serde(rename = "shell-environment-unreviewable")]
9945 ShellEnvironmentUnreviewable,
9946 /// A script path could not be represented for review.
9947 #[serde(rename = "unrepresentable-path")]
9948 UnrepresentablePath,
9949 /// An interpreter wrapped a script that could not be reviewed.
9950 #[serde(rename = "interpreter-wrapped-script")]
9951 InterpreterWrappedScript,
9952 /// The script invocation could not be reviewed.
9953 #[serde(rename = "unreviewable-script-invocation")]
9954 UnreviewableScriptInvocation,
9955 /// The script argument binding could not be reviewed.
9956 #[serde(rename = "argument-binding-unreviewable")]
9957 ArgumentBindingUnreviewable,
9958 /// The script review metadata was malformed.
9959 #[serde(rename = "malformed-script-action-review")]
9960 MalformedScriptActionReview,
9961 /// The script snapshot manifest was malformed.
9962 #[serde(rename = "malformed-script-action-manifest")]
9963 MalformedScriptActionManifest,
9964 /// Script review was unavailable.
9965 #[serde(rename = "unavailable")]
9966 Unavailable,
9967 /// The judge interface returned a usable verdict.
9968 #[serde(rename = "judge-verdict")]
9969 JudgeVerdict,
9970 /// The judge interface returned an error.
9971 #[serde(rename = "judge-error")]
9972 JudgeError,
9973 /// The request inherited an outcome from another decision.
9974 #[serde(rename = "inherited")]
9975 Inherited,
9976 /// Unknown variant for forward compatibility.
9977 #[default]
9978 #[serde(other)]
9979 Unknown,
9980}
9981
9982/// 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.
9983///
9984/// <div class="warning">
9985///
9986/// **Experimental.** This type is part of an experimental wire-protocol surface
9987/// and may change or be removed in future SDK or CLI releases.
9988///
9989/// </div>
9990#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
9991pub enum AssistedApprovalJudgeFailureReason {
9992 /// The judge model call exceeded its deadline.
9993 #[serde(rename = "timeout")]
9994 Timeout,
9995 /// The judge model call was cancelled before it returned.
9996 #[serde(rename = "abort")]
9997 Abort,
9998 /// The judge model call completed but returned no content.
9999 #[serde(rename = "empty_response")]
10000 EmptyResponse,
10001 /// The judge model call failed (for example a transport, authentication, or rate-limit error).
10002 #[serde(rename = "model_error")]
10003 ModelError,
10004 /// The judge model replied, but the reply carried no ALLOW/DENY verdict.
10005 #[serde(rename = "parse_error")]
10006 ParseError,
10007 /// Unknown variant for forward compatibility.
10008 #[default]
10009 #[serde(other)]
10010 Unknown,
10011}
10012
10013/// 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.
10014///
10015/// <div class="warning">
10016///
10017/// **Experimental.** This type is part of an experimental wire-protocol surface
10018/// and may change or be removed in future SDK or CLI releases.
10019///
10020/// </div>
10021#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10022pub enum AssistedApprovalRecommendation {
10023 /// The judge evaluated the request and recommends automatically approving it.
10024 #[serde(rename = "approve")]
10025 Approve,
10026 /// 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.
10027 #[serde(rename = "requireApproval")]
10028 RequireApproval,
10029 /// Assisted mode is enabled, but this request category is never automatically approvable (for example, sandbox-bypass requests), so the judge was not consulted.
10030 #[serde(rename = "excluded")]
10031 Excluded,
10032 /// The judge was consulted but did not return a usable recommendation, so the request requires explicit approval.
10033 #[serde(rename = "error")]
10034 Error,
10035 /// Unknown variant for forward compatibility.
10036 #[default]
10037 #[serde(other)]
10038 Unknown,
10039}
10040
10041/// Vote direction (vote only)
10042#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10043pub enum PermissionRequestMemoryDirection {
10044 /// Vote that the memory is useful or accurate.
10045 #[serde(rename = "upvote")]
10046 Upvote,
10047 /// Vote that the memory is incorrect or outdated.
10048 #[serde(rename = "downvote")]
10049 Downvote,
10050 /// Unknown variant for forward compatibility.
10051 #[default]
10052 #[serde(other)]
10053 Unknown,
10054}
10055
10056/// Permission kind discriminator
10057#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10058pub enum PermissionRequestMemoryKind {
10059 #[serde(rename = "memory")]
10060 #[default]
10061 Memory,
10062}
10063
10064/// Scope of a stored memory.
10065#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10066pub enum PermissionRequestMemoryScope {
10067 /// Store the memory for the current repository.
10068 #[serde(rename = "repository")]
10069 Repository,
10070 /// Store the memory for the current user.
10071 #[serde(rename = "user")]
10072 User,
10073 /// Unknown variant for forward compatibility.
10074 #[default]
10075 #[serde(other)]
10076 Unknown,
10077}
10078
10079/// Permission kind discriminator
10080#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10081pub enum PermissionRequestCustomToolKind {
10082 #[serde(rename = "custom-tool")]
10083 #[default]
10084 CustomTool,
10085}
10086
10087/// Permission kind discriminator
10088#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10089pub enum PermissionRequestHookKind {
10090 #[serde(rename = "hook")]
10091 #[default]
10092 Hook,
10093}
10094
10095/// Permission kind discriminator
10096#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10097pub enum PermissionRequestExtensionManagementKind {
10098 #[serde(rename = "extension-management")]
10099 #[default]
10100 ExtensionManagement,
10101}
10102
10103/// Permission kind discriminator
10104#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10105pub enum PermissionRequestFactoryKind {
10106 #[serde(rename = "factory")]
10107 #[default]
10108 Factory,
10109}
10110
10111/// Operation gated by a factory permission request.
10112#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10113pub enum FactoryPermissionOperation {
10114 /// Running a registered factory, which spends subagents, active time, and AI credits under the approved limits.
10115 #[serde(rename = "run")]
10116 Run,
10117 /// Authoring a factory, which writes JavaScript into a session-scoped extension and loads it.
10118 #[serde(rename = "author")]
10119 Author,
10120 /// Unknown variant for forward compatibility.
10121 #[default]
10122 #[serde(other)]
10123 Unknown,
10124}
10125
10126/// Permission kind discriminator
10127#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10128pub enum PermissionRequestExtensionPermissionAccessKind {
10129 #[serde(rename = "extension-permission-access")]
10130 #[default]
10131 ExtensionPermissionAccess,
10132}
10133
10134/// Permission kind discriminator
10135#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10136pub enum PermissionRequestExtensionEnvAccessKind {
10137 #[serde(rename = "extension-env-access")]
10138 #[default]
10139 ExtensionEnvAccess,
10140}
10141
10142/// Details of the permission being requested
10143#[derive(Debug, Clone, Serialize, Deserialize)]
10144#[serde(untagged)]
10145pub enum PermissionRequest {
10146 Shell(PermissionRequestShell),
10147 Write(PermissionRequestWrite),
10148 Read(PermissionRequestRead),
10149 Mcp(PermissionRequestMcp),
10150 Url(PermissionRequestUrl),
10151 Memory(PermissionRequestMemory),
10152 CustomTool(PermissionRequestCustomTool),
10153 Hook(PermissionRequestHook),
10154 ExtensionManagement(PermissionRequestExtensionManagement),
10155 Factory(PermissionRequestFactory),
10156 ExtensionPermissionAccess(PermissionRequestExtensionPermissionAccess),
10157 ExtensionEnvAccess(PermissionRequestExtensionEnvAccess),
10158}
10159
10160/// Prompt kind discriminator
10161#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10162pub enum PermissionPromptRequestCommandsKind {
10163 #[serde(rename = "commands")]
10164 #[default]
10165 Commands,
10166}
10167
10168/// Prompt kind discriminator
10169#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10170pub enum PermissionPromptRequestWriteKind {
10171 #[serde(rename = "write")]
10172 #[default]
10173 Write,
10174}
10175
10176/// Prompt kind discriminator
10177#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10178pub enum PermissionPromptRequestReadKind {
10179 #[serde(rename = "read")]
10180 #[default]
10181 Read,
10182}
10183
10184/// Prompt kind discriminator
10185#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10186pub enum PermissionPromptRequestMcpKind {
10187 #[serde(rename = "mcp")]
10188 #[default]
10189 Mcp,
10190}
10191
10192/// Prompt kind discriminator
10193#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10194pub enum PermissionPromptRequestUrlKind {
10195 #[serde(rename = "url")]
10196 #[default]
10197 Url,
10198}
10199
10200/// Prompt kind discriminator
10201#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10202pub enum PermissionPromptRequestMemoryKind {
10203 #[serde(rename = "memory")]
10204 #[default]
10205 Memory,
10206}
10207
10208/// Prompt kind discriminator
10209#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10210pub enum PermissionPromptRequestCustomToolKind {
10211 #[serde(rename = "custom-tool")]
10212 #[default]
10213 CustomTool,
10214}
10215
10216/// Underlying permission kind that needs path approval
10217#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10218pub enum PermissionPromptRequestPathAccessKind {
10219 /// Read access to a filesystem path.
10220 #[serde(rename = "read")]
10221 Read,
10222 /// Shell command access involving a filesystem path.
10223 #[serde(rename = "shell")]
10224 Shell,
10225 /// Write access to a filesystem path.
10226 #[serde(rename = "write")]
10227 Write,
10228 /// Unknown variant for forward compatibility.
10229 #[default]
10230 #[serde(other)]
10231 Unknown,
10232}
10233
10234/// Prompt kind discriminator
10235#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10236pub enum PermissionPromptRequestPathKind {
10237 #[serde(rename = "path")]
10238 #[default]
10239 Path,
10240}
10241
10242/// Prompt kind discriminator
10243#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10244pub enum PermissionPromptRequestHookKind {
10245 #[serde(rename = "hook")]
10246 #[default]
10247 Hook,
10248}
10249
10250/// Prompt kind discriminator
10251#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10252pub enum PermissionPromptRequestExtensionManagementKind {
10253 #[serde(rename = "extension-management")]
10254 #[default]
10255 ExtensionManagement,
10256}
10257
10258/// Prompt kind discriminator
10259#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10260pub enum PermissionPromptRequestFactoryKind {
10261 #[serde(rename = "factory")]
10262 #[default]
10263 Factory,
10264}
10265
10266/// Prompt kind discriminator
10267#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10268pub enum PermissionPromptRequestExtensionPermissionAccessKind {
10269 #[serde(rename = "extension-permission-access")]
10270 #[default]
10271 ExtensionPermissionAccess,
10272}
10273
10274/// Prompt kind discriminator
10275#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10276pub enum PermissionPromptRequestExtensionEnvAccessKind {
10277 #[serde(rename = "extension-env-access")]
10278 #[default]
10279 ExtensionEnvAccess,
10280}
10281
10282/// Derived user-facing permission prompt details for UI consumers
10283#[derive(Debug, Clone, Serialize, Deserialize)]
10284#[serde(untagged)]
10285pub enum PermissionPromptRequest {
10286 Commands(PermissionPromptRequestCommands),
10287 Write(PermissionPromptRequestWrite),
10288 Read(PermissionPromptRequestRead),
10289 Mcp(PermissionPromptRequestMcp),
10290 Url(PermissionPromptRequestUrl),
10291 Memory(PermissionPromptRequestMemory),
10292 CustomTool(PermissionPromptRequestCustomTool),
10293 Path(PermissionPromptRequestPath),
10294 Hook(PermissionPromptRequestHook),
10295 ExtensionManagement(PermissionPromptRequestExtensionManagement),
10296 Factory(PermissionPromptRequestFactory),
10297 ExtensionPermissionAccess(PermissionPromptRequestExtensionPermissionAccess),
10298 ExtensionEnvAccess(PermissionPromptRequestExtensionEnvAccess),
10299}
10300
10301/// Controlled reason or actor responsible for a permission response.
10302#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10303pub enum PermissionDecisionSource {
10304 /// The response followed the assisted-approval judge recommendation.
10305 #[serde(rename = "assisted_approval")]
10306 AssistedApproval,
10307 /// A human supplied the response through an interactive prompt.
10308 #[serde(rename = "human_response")]
10309 HumanResponse,
10310 /// The host applied a standing policy or override rather than a judge recommendation or human decision.
10311 #[serde(rename = "host_policy")]
10312 HostPolicy,
10313 /// The host denied the request because no interactive user response was available.
10314 #[serde(rename = "unattended_fallback")]
10315 UnattendedFallback,
10316 /// 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.
10317 #[serde(rename = "authorization_carry_forward")]
10318 AuthorizationCarryForward,
10319 /// Unknown variant for forward compatibility.
10320 #[default]
10321 #[serde(other)]
10322 Unknown,
10323}
10324
10325/// The permission request was approved
10326#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10327pub enum PermissionApprovedKind {
10328 #[serde(rename = "approved")]
10329 #[default]
10330 Approved,
10331}
10332
10333/// Command approval kind
10334#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10335pub enum UserToolSessionApprovalCommandsKind {
10336 #[serde(rename = "commands")]
10337 #[default]
10338 Commands,
10339}
10340
10341/// Read approval kind
10342#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10343pub enum UserToolSessionApprovalReadKind {
10344 #[serde(rename = "read")]
10345 #[default]
10346 Read,
10347}
10348
10349/// Write approval kind
10350#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10351pub enum UserToolSessionApprovalWriteKind {
10352 #[serde(rename = "write")]
10353 #[default]
10354 Write,
10355}
10356
10357/// MCP tool approval kind
10358#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10359pub enum UserToolSessionApprovalMcpKind {
10360 #[serde(rename = "mcp")]
10361 #[default]
10362 Mcp,
10363}
10364
10365/// Memory approval kind
10366#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10367pub enum UserToolSessionApprovalMemoryKind {
10368 #[serde(rename = "memory")]
10369 #[default]
10370 Memory,
10371}
10372
10373/// Custom tool approval kind
10374#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10375pub enum UserToolSessionApprovalCustomToolKind {
10376 #[serde(rename = "custom-tool")]
10377 #[default]
10378 CustomTool,
10379}
10380
10381/// Extension management approval kind
10382#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10383pub enum UserToolSessionApprovalExtensionManagementKind {
10384 #[serde(rename = "extension-management")]
10385 #[default]
10386 ExtensionManagement,
10387}
10388
10389/// Factory approval kind
10390#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10391pub enum UserToolSessionApprovalFactoryKind {
10392 #[serde(rename = "factory")]
10393 #[default]
10394 Factory,
10395}
10396
10397/// Extension permission access approval kind
10398#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10399pub enum UserToolSessionApprovalExtensionPermissionAccessKind {
10400 #[serde(rename = "extension-permission-access")]
10401 #[default]
10402 ExtensionPermissionAccess,
10403}
10404
10405/// Extension environment access approval kind
10406#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10407pub enum UserToolSessionApprovalExtensionEnvAccessKind {
10408 #[serde(rename = "extension-env-access")]
10409 #[default]
10410 ExtensionEnvAccess,
10411}
10412
10413/// The approval to add as a session-scoped rule
10414#[derive(Debug, Clone, Serialize, Deserialize)]
10415#[serde(untagged)]
10416pub enum UserToolSessionApproval {
10417 Commands(UserToolSessionApprovalCommands),
10418 Read(UserToolSessionApprovalRead),
10419 Write(UserToolSessionApprovalWrite),
10420 Mcp(UserToolSessionApprovalMcp),
10421 Memory(UserToolSessionApprovalMemory),
10422 CustomTool(UserToolSessionApprovalCustomTool),
10423 ExtensionManagement(UserToolSessionApprovalExtensionManagement),
10424 Factory(UserToolSessionApprovalFactory),
10425 ExtensionPermissionAccess(UserToolSessionApprovalExtensionPermissionAccess),
10426 ExtensionEnvAccess(UserToolSessionApprovalExtensionEnvAccess),
10427}
10428
10429/// Approved and remembered for the rest of the session
10430#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10431pub enum PermissionApprovedForSessionKind {
10432 #[serde(rename = "approved-for-session")]
10433 #[default]
10434 ApprovedForSession,
10435}
10436
10437/// Approved and persisted for this project location
10438#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10439pub enum PermissionApprovedForLocationKind {
10440 #[serde(rename = "approved-for-location")]
10441 #[default]
10442 ApprovedForLocation,
10443}
10444
10445/// The permission request was cancelled before a response was used
10446#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10447pub enum PermissionCancelledKind {
10448 #[serde(rename = "cancelled")]
10449 #[default]
10450 Cancelled,
10451}
10452
10453/// Denied because approval rules explicitly blocked it
10454#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10455pub enum PermissionDeniedByRulesKind {
10456 #[serde(rename = "denied-by-rules")]
10457 #[default]
10458 DeniedByRules,
10459}
10460
10461/// Denied because no approval rule matched and user confirmation was unavailable
10462#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10463pub enum PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind {
10464 #[serde(rename = "denied-no-approval-rule-and-could-not-request-from-user")]
10465 #[default]
10466 DeniedNoApprovalRuleAndCouldNotRequestFromUser,
10467}
10468
10469/// Denied by the user during an interactive prompt
10470#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10471pub enum PermissionDeniedInteractivelyByUserKind {
10472 #[serde(rename = "denied-interactively-by-user")]
10473 #[default]
10474 DeniedInteractivelyByUser,
10475}
10476
10477/// Denied by the organization's content exclusion policy
10478#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10479pub enum PermissionDeniedByContentExclusionPolicyKind {
10480 #[serde(rename = "denied-by-content-exclusion-policy")]
10481 #[default]
10482 DeniedByContentExclusionPolicy,
10483}
10484
10485/// Denied by a permission request hook registered by an extension or plugin
10486#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10487pub enum PermissionDeniedByPermissionRequestHookKind {
10488 #[serde(rename = "denied-by-permission-request-hook")]
10489 #[default]
10490 DeniedByPermissionRequestHook,
10491}
10492
10493/// The result of the permission request
10494#[derive(Debug, Clone, Serialize, Deserialize)]
10495#[serde(untagged)]
10496pub enum PermissionResult {
10497 Approved(PermissionApproved),
10498 ApprovedForSession(PermissionApprovedForSession),
10499 ApprovedForLocation(PermissionApprovedForLocation),
10500 Cancelled(PermissionCancelled),
10501 DeniedByRules(PermissionDeniedByRules),
10502 DeniedNoApprovalRuleAndCouldNotRequestFromUser(
10503 PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser,
10504 ),
10505 DeniedInteractivelyByUser(PermissionDeniedInteractivelyByUser),
10506 DeniedByContentExclusionPolicy(PermissionDeniedByContentExclusionPolicy),
10507 DeniedByPermissionRequestHook(PermissionDeniedByPermissionRequestHook),
10508}
10509
10510/// Which direction a message-backed authorization claim moves authority in.
10511///
10512/// <div class="warning">
10513///
10514/// **Experimental.** This type is part of an experimental wire-protocol surface
10515/// and may change or be removed in future SDK or CLI releases.
10516///
10517/// </div>
10518#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10519pub enum PermissionMessageAuthorizationPolarity {
10520 /// The human's words authorized an effect.
10521 #[serde(rename = "grant")]
10522 Grant,
10523 /// The human's words refused an effect.
10524 #[serde(rename = "denial")]
10525 Denial,
10526 /// Unknown variant for forward compatibility.
10527 #[default]
10528 #[serde(other)]
10529 Unknown,
10530}
10531
10532/// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
10533#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10534pub enum ElicitationRequestedMode {
10535 /// Structured form-based elicitation.
10536 #[serde(rename = "form")]
10537 Form,
10538 /// Browser URL-based elicitation.
10539 #[serde(rename = "url")]
10540 Url,
10541 /// Unknown variant for forward compatibility.
10542 #[default]
10543 #[serde(other)]
10544 Unknown,
10545}
10546
10547/// Schema type indicator (always 'object')
10548#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10549pub enum ElicitationRequestedSchemaType {
10550 #[serde(rename = "object")]
10551 #[default]
10552 Object,
10553}
10554
10555/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
10556#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10557pub enum ElicitationCompletedAction {
10558 /// The user submitted the requested form.
10559 #[serde(rename = "accept")]
10560 Accept,
10561 /// The user explicitly declined the request.
10562 #[serde(rename = "decline")]
10563 Decline,
10564 /// The user dismissed the request.
10565 #[serde(rename = "cancel")]
10566 Cancel,
10567 /// Unknown variant for forward compatibility.
10568 #[default]
10569 #[serde(other)]
10570 Unknown,
10571}
10572
10573/// Reason the runtime is requesting host-provided MCP OAuth credentials
10574#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10575pub enum McpOauthRequestReason {
10576 /// Initial credentials are required before connecting to the MCP server.
10577 #[serde(rename = "initial")]
10578 Initial,
10579 /// The current host-provided credential was rejected and a replacement is requested.
10580 #[serde(rename = "refresh")]
10581 Refresh,
10582 /// The server requires a new host authorization flow before continuing.
10583 #[serde(rename = "reauth")]
10584 Reauth,
10585 /// The server requires a credential with additional scope or audience.
10586 #[serde(rename = "upscope")]
10587 Upscope,
10588 /// Unknown variant for forward compatibility.
10589 #[default]
10590 #[serde(other)]
10591 Unknown,
10592}
10593
10594/// 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).
10595#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10596pub enum McpOauthRequiredStaticClientConfigGrantType {
10597 #[serde(rename = "client_credentials")]
10598 #[default]
10599 ClientCredentials,
10600}
10601
10602/// How the pending MCP OAuth request was completed
10603#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10604pub enum McpOauthCompletionOutcome {
10605 /// The request completed with a token-backed OAuth provider.
10606 #[serde(rename = "token")]
10607 Token,
10608 /// The request completed without an OAuth provider.
10609 #[serde(rename = "cancelled")]
10610 Cancelled,
10611 /// Unknown variant for forward compatibility.
10612 #[default]
10613 #[serde(other)]
10614 Unknown,
10615}
10616
10617/// Why dynamic headers are being requested.
10618#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10619pub enum McpHeadersRefreshRequiredReason {
10620 /// The transport is making its first dynamic header request for this server.
10621 #[serde(rename = "startup")]
10622 Startup,
10623 /// The previously cached dynamic headers expired.
10624 #[serde(rename = "ttl-expired")]
10625 TtlExpired,
10626 /// The server returned 401 and stale dynamic headers were invalidated.
10627 #[serde(rename = "auth-failed")]
10628 AuthFailed,
10629 /// Unknown variant for forward compatibility.
10630 #[default]
10631 #[serde(other)]
10632 Unknown,
10633}
10634
10635/// How the pending MCP headers refresh request resolved.
10636#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10637pub enum McpHeadersRefreshCompletedOutcome {
10638 /// The host supplied dynamic headers.
10639 #[serde(rename = "headers")]
10640 Headers,
10641 /// The host responded with no dynamic headers.
10642 #[serde(rename = "none")]
10643 None,
10644 /// The host credential broker rejected or failed the refresh.
10645 #[serde(rename = "error")]
10646 Error,
10647 /// No response arrived within the bounded window.
10648 #[serde(rename = "timeout")]
10649 Timeout,
10650 /// Unknown variant for forward compatibility.
10651 #[default]
10652 #[serde(other)]
10653 Unknown,
10654}
10655
10656/// Lifecycle phase for a Rust-owned ephemeral query stream.
10657///
10658/// <div class="warning">
10659///
10660/// **Experimental.** This type is part of an experimental wire-protocol surface
10661/// and may change or be removed in future SDK or CLI releases.
10662///
10663/// </div>
10664#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10665pub enum UIEphemeralQueryPhase {
10666 /// The ephemeral query stream has begun.
10667 #[serde(rename = "started")]
10668 Started,
10669 /// A partial result chunk was produced by the stream.
10670 #[serde(rename = "chunk")]
10671 Chunk,
10672 /// The ephemeral query stream finished successfully.
10673 #[serde(rename = "completed")]
10674 Completed,
10675 /// The ephemeral query stream ended with an error.
10676 #[serde(rename = "failed")]
10677 Failed,
10678 /// The ephemeral query stream was cancelled before completing.
10679 #[serde(rename = "aborted")]
10680 Aborted,
10681 /// Unknown variant for forward compatibility.
10682 #[default]
10683 #[serde(other)]
10684 Unknown,
10685}
10686
10687/// The user's auto-mode-switch choice
10688#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10689pub enum AutoModeSwitchResponse {
10690 /// Switch models for this request.
10691 #[serde(rename = "yes")]
10692 Yes,
10693 /// Switch models now and keep using the replacement automatically.
10694 #[serde(rename = "yes_always")]
10695 YesAlways,
10696 /// Do not switch models.
10697 #[serde(rename = "no")]
10698 No,
10699 /// Unknown variant for forward compatibility.
10700 #[default]
10701 #[serde(other)]
10702 Unknown,
10703}
10704
10705/// User action selected for an exhausted session limit.
10706#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10707pub enum SessionLimitsExhaustedResponseAction {
10708 /// Increase the current max by an exact AI Credits amount.
10709 #[serde(rename = "add")]
10710 Add,
10711 /// Set a new absolute max AI Credits value.
10712 #[serde(rename = "set")]
10713 Set,
10714 /// Remove the current session limit.
10715 #[serde(rename = "unset")]
10716 Unset,
10717 /// Leave the limit unchanged and cancel the blocked model request.
10718 #[serde(rename = "cancel")]
10719 Cancel,
10720 /// Unknown variant for forward compatibility.
10721 #[default]
10722 #[serde(other)]
10723 Unknown,
10724}
10725
10726/// Coarse request-difficulty bucket for UX explainability
10727#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10728pub enum AutoModeResolvedReasoningBucket {
10729 /// The request looks low-reasoning; a lighter model is appropriate.
10730 #[serde(rename = "low")]
10731 Low,
10732 /// The request needs a moderate amount of reasoning.
10733 #[serde(rename = "medium")]
10734 Medium,
10735 /// The request looks high-reasoning; a stronger model is appropriate.
10736 #[serde(rename = "high")]
10737 High,
10738 /// Unknown variant for forward compatibility.
10739 #[default]
10740 #[serde(other)]
10741 Unknown,
10742}
10743
10744/// Summary of which managed-settings channels contributed to the effective session policy. Use the per-channel booleans for exact provenance.
10745#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10746pub enum ManagedSettingsResolvedSource {
10747 /// Only the server/account channel contributed.
10748 #[serde(rename = "server")]
10749 Server,
10750 /// Only the device MDM/plist/registry/file channel contributed.
10751 #[serde(rename = "device")]
10752 Device,
10753 /// Only session-local SDK-host injection contributed.
10754 #[serde(rename = "client")]
10755 Client,
10756 /// A policy helper registered by device or server policy contributed. Device registration takes priority when present.
10757 #[serde(rename = "policyHelper")]
10758 PolicyHelper,
10759 /// More than one channel contributed. Ordinary keys resolve device over server over policy helper per key, while permissions compose restrictively across all present layers.
10760 #[serde(rename = "mixed")]
10761 Mixed,
10762 /// No managed policy is in force (no channel contributed).
10763 #[serde(rename = "none")]
10764 None,
10765 /// Unknown variant for forward compatibility.
10766 #[default]
10767 #[serde(other)]
10768 Unknown,
10769}
10770
10771/// The category of runtime action that enterprise managed settings governed (blocked or capped)
10772#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10773pub enum ManagedSettingsEnforcedAction {
10774 /// An attempt to turn on a bypass-permissions ("yolo") escalation was refused or capped because policy disables bypass-permissions mode.
10775 #[serde(rename = "bypass_permissions_blocked")]
10776 BypassPermissionsBlocked,
10777 /// Unknown variant for forward compatibility.
10778 #[default]
10779 #[serde(other)]
10780 Unknown,
10781}
10782
10783/// For a `bypass_permissions_blocked` action, which permission-escalation primitive was refused
10784#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10785pub enum ManagedSettingsEnforcedEscalation {
10786 /// Full allow-all permissions — automatically approving tools, paths, and URLs.
10787 #[serde(rename = "allow_all")]
10788 AllowAll,
10789 /// Automatic approval of all tool permission requests.
10790 #[serde(rename = "approve_all")]
10791 ApproveAll,
10792 /// Assisted mode — keeps normal prompt paths and adds an LLM recommendation, distinct from allow-all.
10793 #[serde(rename = "assisted_approval")]
10794 AssistedApproval,
10795 /// Unrestricted filesystem access outside the session's allowed directories.
10796 #[serde(rename = "unrestricted_paths")]
10797 UnrestrictedPaths,
10798 /// Unrestricted URL fetch access.
10799 #[serde(rename = "unrestricted_urls")]
10800 UnrestrictedUrls,
10801 /// 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.
10802 #[serde(rename = "server_wide_mcp_approval")]
10803 ServerWideMcpApproval,
10804 /// Unknown variant for forward compatibility.
10805 #[default]
10806 #[serde(other)]
10807 Unknown,
10808}
10809
10810/// Exit plan mode action
10811#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10812pub enum ExitPlanModeAction {
10813 /// Exit plan mode without starting implementation.
10814 #[serde(rename = "exit_only")]
10815 ExitOnly,
10816 /// Exit plan mode and continue in interactive mode.
10817 #[serde(rename = "interactive")]
10818 Interactive,
10819 /// Exit plan mode and continue autonomously.
10820 #[serde(rename = "autopilot")]
10821 Autopilot,
10822 /// Exit plan mode and continue with parallel autonomous workers.
10823 #[serde(rename = "autopilot_fleet")]
10824 AutopilotFleet,
10825 /// Unknown variant for forward compatibility.
10826 #[default]
10827 #[serde(other)]
10828 Unknown,
10829}
10830
10831/// 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.
10832#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10833pub enum FactoryRunSettledStatus {
10834 /// The factory body resolved and its result was committed.
10835 #[serde(rename = "completed")]
10836 Completed,
10837 /// The run was stopped by a limit, an approval refusal or another policy decision.
10838 #[serde(rename = "halted")]
10839 Halted,
10840 /// The attempt paused intentionally while preserving resumable run state.
10841 #[serde(rename = "paused")]
10842 Paused,
10843 /// The run was cancelled by its caller or by session disposal.
10844 #[serde(rename = "cancelled")]
10845 Cancelled,
10846 /// The run failed, with `failureType` carrying the class when it has one.
10847 #[serde(rename = "error")]
10848 Error,
10849 /// Unknown variant for forward compatibility.
10850 #[default]
10851 #[serde(other)]
10852 Unknown,
10853}
10854
10855/// Source location type (e.g., project, personal-copilot, plugin, builtin, sdk)
10856#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10857pub enum SkillSource {
10858 /// Skill defined in the current project's skill directories.
10859 #[serde(rename = "project")]
10860 Project,
10861 /// Skill discovered from a parent directory in the current workspace tree.
10862 #[serde(rename = "inherited")]
10863 Inherited,
10864 /// Skill defined in the user's Copilot skill directory.
10865 #[serde(rename = "personal-copilot")]
10866 PersonalCopilot,
10867 /// Skill defined in the user's personal agents skill directory.
10868 #[serde(rename = "personal-agents")]
10869 PersonalAgents,
10870 /// Skill provided by an installed plugin.
10871 #[serde(rename = "plugin")]
10872 Plugin,
10873 /// Skill loaded from a configured custom skill directory.
10874 #[serde(rename = "custom")]
10875 Custom,
10876 /// Skill bundled with the runtime.
10877 #[serde(rename = "builtin")]
10878 Builtin,
10879 /// Pathless skill supplied lazily by an SDK skill provider.
10880 #[serde(rename = "sdk")]
10881 Sdk,
10882 /// Unknown variant for forward compatibility.
10883 #[default]
10884 #[serde(other)]
10885 Unknown,
10886}
10887
10888/// Whether configured models are advisory preferences or required constraints
10889#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10890pub enum AgentModelPolicy {
10891 /// Treat the authored models as advisory preferences that callers may override.
10892 #[serde(rename = "preferred")]
10893 Preferred,
10894 /// Require subagent execution to use one of the authored models.
10895 #[serde(rename = "required")]
10896 Required,
10897 /// Unknown variant for forward compatibility.
10898 #[default]
10899 #[serde(other)]
10900 Unknown,
10901}
10902
10903/// Connection status: connected, failed, needs-auth, pending, disabled, stopped, or not_configured
10904#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10905pub enum McpServerStatus {
10906 /// The server is connected and available.
10907 #[serde(rename = "connected")]
10908 Connected,
10909 /// The server failed to connect or initialize.
10910 #[serde(rename = "failed")]
10911 Failed,
10912 /// The server requires authentication before it can connect.
10913 #[serde(rename = "needs-auth")]
10914 NeedsAuth,
10915 /// The server connection is still being established.
10916 #[serde(rename = "pending")]
10917 Pending,
10918 /// The server is configured but disabled.
10919 #[serde(rename = "disabled")]
10920 Disabled,
10921 /// 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.
10922 #[serde(rename = "stopped")]
10923 Stopped,
10924 /// The server is not configured for this session.
10925 #[serde(rename = "not_configured")]
10926 NotConfigured,
10927 /// Unknown variant for forward compatibility.
10928 #[default]
10929 #[serde(other)]
10930 Unknown,
10931}
10932
10933/// Discovery source
10934#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10935pub enum ExtensionsLoadedExtensionSource {
10936 /// Extension discovered from the current project.
10937 #[serde(rename = "project")]
10938 Project,
10939 /// Extension discovered from the user's extension directory.
10940 #[serde(rename = "user")]
10941 User,
10942 /// Extension contributed by an installed plugin.
10943 #[serde(rename = "plugin")]
10944 Plugin,
10945 /// Extension discovered from the current session's state directory.
10946 #[serde(rename = "session")]
10947 Session,
10948 /// Unknown variant for forward compatibility.
10949 #[default]
10950 #[serde(other)]
10951 Unknown,
10952}
10953
10954/// Current status: running, disabled, failed, or starting
10955#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
10956pub enum ExtensionsLoadedExtensionStatus {
10957 /// The extension process is running.
10958 #[serde(rename = "running")]
10959 Running,
10960 /// The extension is installed but disabled.
10961 #[serde(rename = "disabled")]
10962 Disabled,
10963 /// The extension failed to start or crashed.
10964 #[serde(rename = "failed")]
10965 Failed,
10966 /// The extension process is starting.
10967 #[serde(rename = "starting")]
10968 Starting,
10969 /// Unknown variant for forward compatibility.
10970 #[default]
10971 #[serde(other)]
10972 Unknown,
10973}