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