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