//! Auto-generated from session-events.schema.json — do not edit manually.
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::types::{RequestId, SessionId};
/// Identifies the kind of session event.
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SessionEventType {
#[serde(rename = "session.start")]
SessionStart,
#[serde(rename = "session.resume")]
SessionResume,
#[serde(rename = "session.remote_steerable_changed")]
SessionRemoteSteerableChanged,
#[serde(rename = "session.error")]
SessionError,
#[serde(rename = "session.idle")]
SessionIdle,
#[serde(rename = "session.title_changed")]
SessionTitleChanged,
#[serde(rename = "session.schedule_created")]
SessionScheduleCreated,
#[serde(rename = "session.schedule_cancelled")]
SessionScheduleCancelled,
#[serde(rename = "session.autopilot_objective_changed")]
SessionAutopilotObjectiveChanged,
#[serde(rename = "session.info")]
SessionInfo,
#[serde(rename = "session.warning")]
SessionWarning,
#[serde(rename = "session.model_change")]
SessionModelChange,
#[serde(rename = "session.mode_changed")]
SessionModeChanged,
#[serde(rename = "session.permissions_changed")]
SessionPermissionsChanged,
#[serde(rename = "session.plan_changed")]
SessionPlanChanged,
#[serde(rename = "session.todos_changed")]
SessionTodosChanged,
#[serde(rename = "session.workspace_file_changed")]
SessionWorkspaceFileChanged,
#[serde(rename = "session.handoff")]
SessionHandoff,
#[serde(rename = "session.truncation")]
SessionTruncation,
#[serde(rename = "session.snapshot_rewind")]
SessionSnapshotRewind,
#[serde(rename = "session.shutdown")]
SessionShutdown,
#[serde(rename = "session.context_changed")]
SessionContextChanged,
#[serde(rename = "session.usage_info")]
SessionUsageInfo,
#[serde(rename = "session.compaction_start")]
SessionCompactionStart,
#[serde(rename = "session.compaction_complete")]
SessionCompactionComplete,
#[serde(rename = "session.task_complete")]
SessionTaskComplete,
#[serde(rename = "user.message")]
UserMessage,
#[serde(rename = "pending_messages.modified")]
PendingMessagesModified,
#[serde(rename = "assistant.turn_start")]
AssistantTurnStart,
#[serde(rename = "assistant.intent")]
AssistantIntent,
#[serde(rename = "assistant.reasoning")]
AssistantReasoning,
#[serde(rename = "assistant.reasoning_delta")]
AssistantReasoningDelta,
#[serde(rename = "assistant.streaming_delta")]
AssistantStreamingDelta,
#[serde(rename = "assistant.message")]
AssistantMessage,
#[serde(rename = "assistant.message_start")]
AssistantMessageStart,
#[serde(rename = "assistant.message_delta")]
AssistantMessageDelta,
#[serde(rename = "assistant.turn_end")]
AssistantTurnEnd,
#[serde(rename = "assistant.usage")]
AssistantUsage,
#[serde(rename = "model.call_failure")]
ModelCallFailure,
#[serde(rename = "abort")]
Abort,
#[serde(rename = "tool.user_requested")]
ToolUserRequested,
#[serde(rename = "tool.execution_start")]
ToolExecutionStart,
#[serde(rename = "tool.execution_partial_result")]
ToolExecutionPartialResult,
#[serde(rename = "tool.execution_progress")]
ToolExecutionProgress,
#[serde(rename = "tool.execution_complete")]
ToolExecutionComplete,
#[serde(rename = "skill.invoked")]
SkillInvoked,
#[serde(rename = "subagent.started")]
SubagentStarted,
#[serde(rename = "subagent.completed")]
SubagentCompleted,
#[serde(rename = "subagent.failed")]
SubagentFailed,
#[serde(rename = "subagent.selected")]
SubagentSelected,
#[serde(rename = "subagent.deselected")]
SubagentDeselected,
#[serde(rename = "hook.start")]
HookStart,
#[serde(rename = "hook.end")]
HookEnd,
#[serde(rename = "hook.progress")]
HookProgress,
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(rename = "session.binary_asset")]
SessionBinaryAsset,
#[serde(rename = "system.message")]
SystemMessage,
#[serde(rename = "system.notification")]
SystemNotification,
#[serde(rename = "permission.requested")]
PermissionRequested,
#[serde(rename = "permission.completed")]
PermissionCompleted,
#[serde(rename = "user_input.requested")]
UserInputRequested,
#[serde(rename = "user_input.completed")]
UserInputCompleted,
#[serde(rename = "elicitation.requested")]
ElicitationRequested,
#[serde(rename = "elicitation.completed")]
ElicitationCompleted,
#[serde(rename = "sampling.requested")]
SamplingRequested,
#[serde(rename = "sampling.completed")]
SamplingCompleted,
#[serde(rename = "mcp.oauth_required")]
McpOauthRequired,
#[serde(rename = "mcp.oauth_completed")]
McpOauthCompleted,
#[serde(rename = "session.custom_notification")]
SessionCustomNotification,
#[serde(rename = "external_tool.requested")]
ExternalToolRequested,
#[serde(rename = "external_tool.completed")]
ExternalToolCompleted,
#[serde(rename = "command.queued")]
CommandQueued,
#[serde(rename = "command.execute")]
CommandExecute,
#[serde(rename = "command.completed")]
CommandCompleted,
#[serde(rename = "auto_mode_switch.requested")]
AutoModeSwitchRequested,
#[serde(rename = "auto_mode_switch.completed")]
AutoModeSwitchCompleted,
#[serde(rename = "commands.changed")]
CommandsChanged,
#[serde(rename = "capabilities.changed")]
CapabilitiesChanged,
#[serde(rename = "exit_plan_mode.requested")]
ExitPlanModeRequested,
#[serde(rename = "exit_plan_mode.completed")]
ExitPlanModeCompleted,
#[serde(rename = "session.tools_updated")]
SessionToolsUpdated,
#[serde(rename = "session.background_tasks_changed")]
SessionBackgroundTasksChanged,
#[serde(rename = "session.skills_loaded")]
SessionSkillsLoaded,
#[serde(rename = "session.custom_agents_updated")]
SessionCustomAgentsUpdated,
#[serde(rename = "session.mcp_servers_loaded")]
SessionMcpServersLoaded,
#[serde(rename = "session.mcp_server_status_changed")]
SessionMcpServerStatusChanged,
#[serde(rename = "session.extensions_loaded")]
SessionExtensionsLoaded,
#[serde(rename = "session.canvas.opened")]
SessionCanvasOpened,
#[serde(rename = "session.canvas.registry_changed")]
SessionCanvasRegistryChanged,
#[serde(rename = "session.canvas.closed")]
SessionCanvasClosed,
#[serde(rename = "session.extensions.attachments_pushed")]
SessionExtensionsAttachmentsPushed,
#[serde(rename = "mcp_app.tool_call_complete")]
McpAppToolCallComplete,
/// Unknown event type for forward compatibility.
#[default]
#[serde(other)]
Unknown,
}
/// Typed session event data, discriminated by the event `type` field.
///
/// Use with [`TypedSessionEvent`] for fully typed event handling.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", content = "data")]
pub enum SessionEventData {
#[serde(rename = "session.start")]
SessionStart(SessionStartData),
#[serde(rename = "session.resume")]
SessionResume(SessionResumeData),
#[serde(rename = "session.remote_steerable_changed")]
SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
#[serde(rename = "session.error")]
SessionError(SessionErrorData),
#[serde(rename = "session.idle")]
SessionIdle(SessionIdleData),
#[serde(rename = "session.title_changed")]
SessionTitleChanged(SessionTitleChangedData),
#[serde(rename = "session.schedule_created")]
SessionScheduleCreated(SessionScheduleCreatedData),
#[serde(rename = "session.schedule_cancelled")]
SessionScheduleCancelled(SessionScheduleCancelledData),
#[serde(rename = "session.autopilot_objective_changed")]
SessionAutopilotObjectiveChanged(SessionAutopilotObjectiveChangedData),
#[serde(rename = "session.info")]
SessionInfo(SessionInfoData),
#[serde(rename = "session.warning")]
SessionWarning(SessionWarningData),
#[serde(rename = "session.model_change")]
SessionModelChange(SessionModelChangeData),
#[serde(rename = "session.mode_changed")]
SessionModeChanged(SessionModeChangedData),
#[serde(rename = "session.permissions_changed")]
SessionPermissionsChanged(SessionPermissionsChangedData),
#[serde(rename = "session.plan_changed")]
SessionPlanChanged(SessionPlanChangedData),
#[serde(rename = "session.todos_changed")]
SessionTodosChanged(SessionTodosChangedData),
#[serde(rename = "session.workspace_file_changed")]
SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
#[serde(rename = "session.handoff")]
SessionHandoff(SessionHandoffData),
#[serde(rename = "session.truncation")]
SessionTruncation(SessionTruncationData),
#[serde(rename = "session.snapshot_rewind")]
SessionSnapshotRewind(SessionSnapshotRewindData),
#[serde(rename = "session.shutdown")]
SessionShutdown(SessionShutdownData),
#[serde(rename = "session.context_changed")]
SessionContextChanged(SessionContextChangedData),
#[serde(rename = "session.usage_info")]
SessionUsageInfo(SessionUsageInfoData),
#[serde(rename = "session.compaction_start")]
SessionCompactionStart(SessionCompactionStartData),
#[serde(rename = "session.compaction_complete")]
SessionCompactionComplete(SessionCompactionCompleteData),
#[serde(rename = "session.task_complete")]
SessionTaskComplete(SessionTaskCompleteData),
#[serde(rename = "user.message")]
UserMessage(UserMessageData),
#[serde(rename = "pending_messages.modified")]
PendingMessagesModified(PendingMessagesModifiedData),
#[serde(rename = "assistant.turn_start")]
AssistantTurnStart(AssistantTurnStartData),
#[serde(rename = "assistant.intent")]
AssistantIntent(AssistantIntentData),
#[serde(rename = "assistant.reasoning")]
AssistantReasoning(AssistantReasoningData),
#[serde(rename = "assistant.reasoning_delta")]
AssistantReasoningDelta(AssistantReasoningDeltaData),
#[serde(rename = "assistant.streaming_delta")]
AssistantStreamingDelta(AssistantStreamingDeltaData),
#[serde(rename = "assistant.message")]
AssistantMessage(AssistantMessageData),
#[serde(rename = "assistant.message_start")]
AssistantMessageStart(AssistantMessageStartData),
#[serde(rename = "assistant.message_delta")]
AssistantMessageDelta(AssistantMessageDeltaData),
#[serde(rename = "assistant.turn_end")]
AssistantTurnEnd(AssistantTurnEndData),
#[serde(rename = "assistant.usage")]
AssistantUsage(AssistantUsageData),
#[serde(rename = "model.call_failure")]
ModelCallFailure(ModelCallFailureData),
#[serde(rename = "abort")]
Abort(AbortData),
#[serde(rename = "tool.user_requested")]
ToolUserRequested(ToolUserRequestedData),
#[serde(rename = "tool.execution_start")]
ToolExecutionStart(ToolExecutionStartData),
#[serde(rename = "tool.execution_partial_result")]
ToolExecutionPartialResult(ToolExecutionPartialResultData),
#[serde(rename = "tool.execution_progress")]
ToolExecutionProgress(ToolExecutionProgressData),
#[serde(rename = "tool.execution_complete")]
ToolExecutionComplete(ToolExecutionCompleteData),
#[serde(rename = "skill.invoked")]
SkillInvoked(SkillInvokedData),
#[serde(rename = "subagent.started")]
SubagentStarted(SubagentStartedData),
#[serde(rename = "subagent.completed")]
SubagentCompleted(SubagentCompletedData),
#[serde(rename = "subagent.failed")]
SubagentFailed(SubagentFailedData),
#[serde(rename = "subagent.selected")]
SubagentSelected(SubagentSelectedData),
#[serde(rename = "subagent.deselected")]
SubagentDeselected(SubagentDeselectedData),
#[serde(rename = "hook.start")]
HookStart(HookStartData),
#[serde(rename = "hook.end")]
HookEnd(HookEndData),
#[serde(rename = "hook.progress")]
HookProgress(HookProgressData),
#[serde(rename = "session.binary_asset")]
SessionBinaryAsset(SessionBinaryAssetData),
#[serde(rename = "system.message")]
SystemMessage(SystemMessageData),
#[serde(rename = "system.notification")]
SystemNotification(SystemNotificationData),
#[serde(rename = "permission.requested")]
PermissionRequested(PermissionRequestedData),
#[serde(rename = "permission.completed")]
PermissionCompleted(PermissionCompletedData),
#[serde(rename = "user_input.requested")]
UserInputRequested(UserInputRequestedData),
#[serde(rename = "user_input.completed")]
UserInputCompleted(UserInputCompletedData),
#[serde(rename = "elicitation.requested")]
ElicitationRequested(ElicitationRequestedData),
#[serde(rename = "elicitation.completed")]
ElicitationCompleted(ElicitationCompletedData),
#[serde(rename = "sampling.requested")]
SamplingRequested(SamplingRequestedData),
#[serde(rename = "sampling.completed")]
SamplingCompleted(SamplingCompletedData),
#[serde(rename = "mcp.oauth_required")]
McpOauthRequired(McpOauthRequiredData),
#[serde(rename = "mcp.oauth_completed")]
McpOauthCompleted(McpOauthCompletedData),
#[serde(rename = "session.custom_notification")]
SessionCustomNotification(SessionCustomNotificationData),
#[serde(rename = "external_tool.requested")]
ExternalToolRequested(ExternalToolRequestedData),
#[serde(rename = "external_tool.completed")]
ExternalToolCompleted(ExternalToolCompletedData),
#[serde(rename = "command.queued")]
CommandQueued(CommandQueuedData),
#[serde(rename = "command.execute")]
CommandExecute(CommandExecuteData),
#[serde(rename = "command.completed")]
CommandCompleted(CommandCompletedData),
#[serde(rename = "auto_mode_switch.requested")]
AutoModeSwitchRequested(AutoModeSwitchRequestedData),
#[serde(rename = "auto_mode_switch.completed")]
AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
#[serde(rename = "commands.changed")]
CommandsChanged(CommandsChangedData),
#[serde(rename = "capabilities.changed")]
CapabilitiesChanged(CapabilitiesChangedData),
#[serde(rename = "exit_plan_mode.requested")]
ExitPlanModeRequested(ExitPlanModeRequestedData),
#[serde(rename = "exit_plan_mode.completed")]
ExitPlanModeCompleted(ExitPlanModeCompletedData),
#[serde(rename = "session.tools_updated")]
SessionToolsUpdated(SessionToolsUpdatedData),
#[serde(rename = "session.background_tasks_changed")]
SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
#[serde(rename = "session.skills_loaded")]
SessionSkillsLoaded(SessionSkillsLoadedData),
#[serde(rename = "session.custom_agents_updated")]
SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
#[serde(rename = "session.mcp_servers_loaded")]
SessionMcpServersLoaded(SessionMcpServersLoadedData),
#[serde(rename = "session.mcp_server_status_changed")]
SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
#[serde(rename = "session.extensions_loaded")]
SessionExtensionsLoaded(SessionExtensionsLoadedData),
#[serde(rename = "session.canvas.opened")]
SessionCanvasOpened(SessionCanvasOpenedData),
#[serde(rename = "session.canvas.registry_changed")]
SessionCanvasRegistryChanged(SessionCanvasRegistryChangedData),
#[serde(rename = "session.canvas.closed")]
SessionCanvasClosed(SessionCanvasClosedData),
#[serde(rename = "session.extensions.attachments_pushed")]
SessionExtensionsAttachmentsPushed(SessionExtensionsAttachmentsPushedData),
#[serde(rename = "mcp_app.tool_call_complete")]
McpAppToolCallComplete(McpAppToolCallCompleteData),
}
/// A session event with typed data payload.
///
/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
/// are available directly. The event-specific data is in the `payload`
/// field as a [`SessionEventData`] enum.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TypedSessionEvent {
/// Unique event identifier (UUID v4).
pub id: String,
/// ISO 8601 timestamp when the event was created.
pub timestamp: String,
/// ID of the preceding event in the chain.
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_id: Option,
/// When true, the event is transient and not persisted.
#[serde(skip_serializing_if = "Option::is_none")]
pub ephemeral: Option,
/// Sub-agent instance identifier. Absent for events from the root /
/// main agent and session-level events.
#[serde(skip_serializing_if = "Option::is_none")]
pub agent_id: Option,
/// The typed event payload (discriminated by event type).
#[serde(flatten)]
pub payload: SessionEventData,
}
/// Working directory and git context at session start
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WorkingDirectoryContext {
/// Base commit of current git branch at session start time
#[serde(skip_serializing_if = "Option::is_none")]
pub base_commit: Option,
/// Current git branch name
#[serde(skip_serializing_if = "Option::is_none")]
pub branch: Option,
/// Current working directory path
pub cwd: String,
/// Root directory of the git repository, resolved via git rev-parse
#[serde(skip_serializing_if = "Option::is_none")]
pub git_root: Option,
/// Head commit of current git branch at session start time
#[serde(skip_serializing_if = "Option::is_none")]
pub head_commit: Option,
/// Hosting platform type of the repository (github or ado)
#[serde(skip_serializing_if = "Option::is_none")]
pub host_type: Option,
/// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
#[serde(skip_serializing_if = "Option::is_none")]
pub repository: Option,
/// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
#[serde(skip_serializing_if = "Option::is_none")]
pub repository_host: Option,
}
/// Session event "session.start". Session initialization metadata including context and configuration
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionStartData {
/// Whether the session was already in use by another client at start time
#[serde(skip_serializing_if = "Option::is_none")]
pub already_in_use: Option,
/// Working directory and git context at session start
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option,
/// Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
#[serde(skip_serializing_if = "Option::is_none")]
pub context_tier: Option,
/// Version string of the Copilot application
pub copilot_version: String,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub detached_from_spawning_parent_session_id: Option,
/// Identifier of the software producing the events (e.g., "copilot-agent")
pub producer: String,
/// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_effort: Option,
/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_summary: Option,
/// Whether this session supports remote steering via GitHub
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_steerable: Option,
/// Model selected at session creation time, if any
#[serde(skip_serializing_if = "Option::is_none")]
pub selected_model: Option,
/// Unique identifier for the session
pub session_id: SessionId,
/// ISO 8601 timestamp when the session was created
pub start_time: String,
/// Schema version number for the session event format
pub version: i64,
}
/// Session event "session.resume". Session resume metadata including current context and event count
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionResumeData {
/// Whether the session was already in use by another client at resume time
#[serde(skip_serializing_if = "Option::is_none")]
pub already_in_use: Option,
/// Updated working directory and git context at resume time
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option,
/// Context tier currently selected at resume time; null when no tier is active
#[serde(skip_serializing_if = "Option::is_none")]
pub context_tier: Option,
/// 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 (the default), any such tool calls and permission requests are immediately marked as interrupted on resume.
#[serde(skip_serializing_if = "Option::is_none")]
pub continue_pending_work: Option,
/// Total number of persisted events in the session at the time of resume
pub event_count: i64,
/// 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
#[serde(skip_serializing_if = "Option::is_none")]
pub events_file_size_bytes: Option,
/// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_effort: Option,
/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_summary: Option,
/// Whether this session supports remote steering via GitHub
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_steerable: Option,
/// ISO 8601 timestamp when the session was resumed
pub resume_time: String,
/// Model currently selected at resume time
#[serde(skip_serializing_if = "Option::is_none")]
pub selected_model: Option,
/// True when this resume attached to a session that the runtime already had running in-memory (for example, an extension joining a session another client was actively driving). False (or omitted) for cold resumes — the runtime had to reconstitute the session from its persisted event log.
#[serde(skip_serializing_if = "Option::is_none")]
pub session_was_active: Option,
}
/// Session event "session.remote_steerable_changed". Notifies that the session's remote steering capability has changed
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionRemoteSteerableChangedData {
/// Whether this session now supports remote steering via GitHub
pub remote_steerable: bool,
}
/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionErrorData {
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub eligible_for_auto_switch: Option,
/// 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"`).
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option,
/// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
pub error_type: String,
/// Human-readable error message
pub message: String,
/// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
#[serde(skip_serializing_if = "Option::is_none")]
pub provider_call_id: Option,
/// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
#[serde(skip_serializing_if = "Option::is_none")]
pub service_request_id: Option,
/// Error stack trace, when available
#[serde(skip_serializing_if = "Option::is_none")]
pub stack: Option,
/// HTTP status code from the upstream request, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub status_code: Option,
/// Optional URL associated with this error that the user can open in a browser
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option,
}
/// Session event "session.idle". Payload indicating the session is idle with no background agents or attached shell commands in flight
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionIdleData {
/// True when the preceding agentic loop was cancelled via abort signal
#[serde(skip_serializing_if = "Option::is_none")]
pub aborted: Option,
}
/// Session event "session.title_changed". Session title change payload containing the new display title
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTitleChangedData {
/// The new display title for the session
pub title: String,
}
/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionScheduleCreatedData {
/// Absolute fire time (epoch milliseconds) for a one-shot calendar schedule
#[serde(skip_serializing_if = "Option::is_none")]
pub at: Option,
/// 5-field cron expression for a recurring calendar schedule, evaluated in `tz`
#[serde(skip_serializing_if = "Option::is_none")]
pub cron: Option,
/// 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)
#[serde(skip_serializing_if = "Option::is_none")]
pub display_prompt: Option,
/// Sequential id assigned to the scheduled prompt within the session
pub id: i64,
/// Interval between ticks in milliseconds (relative-interval schedules)
#[serde(skip_serializing_if = "Option::is_none")]
pub interval_ms: Option,
/// Prompt text that gets enqueued on every tick
pub prompt: String,
/// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
#[serde(skip_serializing_if = "Option::is_none")]
pub recurring: Option,
/// IANA timezone the `cron` expression is evaluated in
#[serde(skip_serializing_if = "Option::is_none")]
pub tz: Option,
}
/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionScheduleCancelledData {
/// Id of the scheduled prompt that was cancelled
pub id: i64,
}
/// Session event "session.autopilot_objective_changed". Autopilot objective state file operation details indicating what changed
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionAutopilotObjectiveChangedData {
/// Current autopilot objective id, if one exists
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option,
/// The type of operation performed on the autopilot objective state file
pub operation: AutopilotObjectiveChangedOperation,
/// Current autopilot objective status, if one exists
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option,
}
/// Session event "session.info". Informational message for timeline display with categorization
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionInfoData {
/// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
pub info_type: String,
/// Human-readable informational message for display in the timeline
pub message: String,
/// Optional actionable tip displayed with this message
#[serde(skip_serializing_if = "Option::is_none")]
pub tip: Option,
/// Optional URL associated with this message that the user can open in a browser
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option,
}
/// Session event "session.warning". Warning message for timeline display with categorization
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionWarningData {
/// Human-readable warning message for display in the timeline
pub message: String,
/// Optional URL associated with this warning that the user can open in a browser
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option,
/// Category of warning (e.g., "subscription", "policy", "mcp")
pub warning_type: String,
}
/// Session event "session.model_change". Model change details including previous and new model identifiers
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionModelChangeData {
/// Reason the change happened, when not user-initiated. Currently `"rate_limit_auto_switch"` for changes triggered by the auto-mode-switch rate-limit recovery path. UI clients can use this to render contextual copy.
#[serde(skip_serializing_if = "Option::is_none")]
pub cause: Option,
/// Context tier after the model change; null explicitly clears a previously selected tier
#[serde(skip_serializing_if = "Option::is_none")]
pub context_tier: Option,
/// Newly selected model identifier
pub new_model: String,
/// Model that was previously selected, if any
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_model: Option,
/// Reasoning effort level before the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_reasoning_effort: Option,
/// Reasoning summary mode before the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_reasoning_summary: Option,
/// Reasoning effort level after the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_effort: Option,
/// Reasoning summary mode after the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_summary: Option,
}
/// Session event "session.mode_changed". Agent mode change details including previous and new modes
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionModeChangedData {
/// The session mode the agent is operating in
pub new_mode: SessionMode,
/// The session mode the agent is operating in
pub previous_mode: SessionMode,
}
/// Session event "session.permissions_changed". Permissions change details carrying the aggregate allow-all boolean transition.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionPermissionsChangedData {
/// Aggregate allow-all flag after the change
pub allow_all_permissions: bool,
/// Aggregate allow-all flag before the change
pub previous_allow_all_permissions: bool,
}
/// Session event "session.plan_changed". Plan file operation details indicating what changed
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionPlanChangedData {
/// The type of operation performed on the plan file
pub operation: PlanChangedOperation,
}
/// 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.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTodosChangedData {}
/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionWorkspaceFileChangedData {
/// Whether the file was newly created or updated
pub operation: WorkspaceFileChangedOperation,
/// Relative path within the session workspace files directory
pub path: String,
}
/// Repository context for the handed-off session
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HandoffRepository {
/// Git branch name, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub branch: Option,
/// Repository name
pub name: String,
/// Repository owner (user or organization)
pub owner: String,
}
/// Session event "session.handoff". Session handoff metadata including source, context, and repository information
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionHandoffData {
/// Additional context information for the handoff
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option,
/// ISO 8601 timestamp when the handoff occurred
pub handoff_time: String,
/// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
#[serde(skip_serializing_if = "Option::is_none")]
pub host: Option,
/// Session ID of the remote session being handed off
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_session_id: Option,
/// Repository context for the handed-off session
#[serde(skip_serializing_if = "Option::is_none")]
pub repository: Option,
/// Origin type of the session being handed off
pub source_type: HandoffSourceType,
/// Summary of the work done in the source session
#[serde(skip_serializing_if = "Option::is_none")]
pub summary: Option,
}
/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTruncationData {
/// Number of messages removed by truncation
pub messages_removed_during_truncation: i64,
/// Identifier of the component that performed truncation (e.g., "BasicTruncator")
pub performed_by: String,
/// Number of conversation messages after truncation
pub post_truncation_messages_length: i64,
/// Total tokens in conversation messages after truncation
pub post_truncation_tokens_in_messages: i64,
/// Number of conversation messages before truncation
pub pre_truncation_messages_length: i64,
/// Total tokens in conversation messages before truncation
pub pre_truncation_tokens_in_messages: i64,
/// Maximum token count for the model's context window
pub token_limit: i64,
/// Number of tokens removed by truncation
pub tokens_removed_during_truncation: i64,
}
/// Session event "session.snapshot_rewind". Session rewind details including target event and count of removed events
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionSnapshotRewindData {
/// Number of events that were removed by the rewind
pub events_removed: i64,
/// Event ID that was rewound to; this event and all after it were removed
pub up_to_event_id: String,
}
/// Aggregate code change metrics for the session
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownCodeChanges {
/// List of file paths that were modified during the session
pub files_modified: Vec,
/// Total number of lines added during the session
pub lines_added: i64,
/// Total number of lines removed during the session
pub lines_removed: i64,
}
/// Request count and cost metrics
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetricRequests {
/// Cumulative cost multiplier for requests to this model
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(skip_serializing_if = "Option::is_none")]
pub cost: Option,
/// Total number of API requests made to this model
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(skip_serializing_if = "Option::is_none")]
pub count: Option,
}
/// Schema for the `ShutdownModelMetricTokenDetail` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetricTokenDetail {
/// Accumulated token count for this token type
pub token_count: i64,
}
/// Token usage breakdown
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetricUsage {
/// Total tokens read from prompt cache across all requests
pub cache_read_tokens: i64,
/// Total tokens written to prompt cache across all requests
pub cache_write_tokens: i64,
/// Total input tokens consumed across all requests to this model
pub input_tokens: i64,
/// Total output tokens produced across all requests to this model
pub output_tokens: i64,
/// Total reasoning tokens produced across all requests to this model
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_tokens: Option,
}
/// Schema for the `ShutdownModelMetric` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetric {
/// Request count and cost metrics
pub requests: ShutdownModelMetricRequests,
/// Token count details per type
#[serde(skip_serializing_if = "Option::is_none")]
pub token_details: Option>,
/// Accumulated nano-AI units cost for this model
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(skip_serializing_if = "Option::is_none")]
pub total_nano_aiu: Option,
/// Token usage breakdown
pub usage: ShutdownModelMetricUsage,
}
/// Schema for the `ShutdownTokenDetail` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownTokenDetail {
/// Accumulated token count for this token type
pub token_count: i64,
}
/// Session event "session.shutdown". Session termination metrics including usage statistics, code changes, and shutdown reason
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionShutdownData {
/// Aggregate code change metrics for the session
pub code_changes: ShutdownCodeChanges,
/// Non-system message token count at shutdown
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_tokens: Option,
/// Model that was selected at the time of shutdown
#[serde(skip_serializing_if = "Option::is_none")]
pub current_model: Option,
/// Total tokens in context window at shutdown
#[serde(skip_serializing_if = "Option::is_none")]
pub current_tokens: Option,
/// Error description when shutdownType is "error"
#[serde(skip_serializing_if = "Option::is_none")]
pub error_reason: Option,
/// 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
#[serde(skip_serializing_if = "Option::is_none")]
pub events_file_size_bytes: Option,
/// Per-model usage breakdown, keyed by model identifier
pub model_metrics: HashMap,
/// Unix timestamp (milliseconds) when the session started
pub session_start_time: i64,
/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
pub shutdown_type: ShutdownType,
/// System message token count at shutdown
#[serde(skip_serializing_if = "Option::is_none")]
pub system_tokens: Option,
/// Session-wide per-token-type accumulated token counts
#[serde(skip_serializing_if = "Option::is_none")]
pub token_details: Option>,
/// Tool definitions token count at shutdown
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_definitions_tokens: Option,
/// Cumulative time spent in API calls during the session, in milliseconds
pub total_api_duration_ms: i64,
/// Session-wide accumulated nano-AI units cost
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(skip_serializing_if = "Option::is_none")]
pub total_nano_aiu: Option,
/// Total number of premium API requests used during the session
#[doc(hidden)]
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) total_premium_requests: Option,
}
/// Session event "session.context_changed". Updated working directory and git context after the change
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionContextChangedData {
/// Base commit of current git branch at session start time
#[serde(skip_serializing_if = "Option::is_none")]
pub base_commit: Option,
/// Current git branch name
#[serde(skip_serializing_if = "Option::is_none")]
pub branch: Option,
/// Current working directory path
pub cwd: String,
/// Root directory of the git repository, resolved via git rev-parse
#[serde(skip_serializing_if = "Option::is_none")]
pub git_root: Option,
/// Head commit of current git branch at session start time
#[serde(skip_serializing_if = "Option::is_none")]
pub head_commit: Option,
/// Hosting platform type of the repository (github or ado)
#[serde(skip_serializing_if = "Option::is_none")]
pub host_type: Option,
/// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
#[serde(skip_serializing_if = "Option::is_none")]
pub repository: Option,
/// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
#[serde(skip_serializing_if = "Option::is_none")]
pub repository_host: Option,
}
/// Session event "session.usage_info". Current context window usage statistics including token and message counts
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionUsageInfoData {
/// Token count from non-system messages (user, assistant, tool)
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_tokens: Option,
/// Current number of tokens in the context window
pub current_tokens: i64,
/// Whether this is the first usage_info event emitted in this session
#[serde(skip_serializing_if = "Option::is_none")]
pub is_initial: Option,
/// Current number of messages in the conversation
pub messages_length: i64,
/// Token count from system message(s)
#[serde(skip_serializing_if = "Option::is_none")]
pub system_tokens: Option,
/// Maximum token count for the model's context window
pub token_limit: i64,
/// Token count from tool definitions
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_definitions_tokens: Option,
}
/// Session event "session.compaction_start". Context window breakdown at the start of LLM-powered conversation compaction
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionCompactionStartData {
/// Token count from non-system messages (user, assistant, tool) at compaction start
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_tokens: Option,
/// Token count from system message(s) at compaction start
#[serde(skip_serializing_if = "Option::is_none")]
pub system_tokens: Option,
/// Token count from tool definitions at compaction start
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_definitions_tokens: Option,
}
/// Token usage detail for a single billing category
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
/// Number of tokens in this billing batch
pub batch_size: i64,
/// Cost per batch of tokens
pub cost_per_batch: i64,
/// Total token count for this entry
pub token_count: i64,
/// Token category (e.g., "input", "output")
pub token_type: String,
}
/// Per-request cost and usage data from the CAPI copilot_usage response field
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct CompactionCompleteCompactionTokensUsedCopilotUsage {
/// Itemized token usage breakdown
#[doc(hidden)]
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) token_details:
Option>,
/// Total cost in nano-AI units for this request
pub total_nano_aiu: f64,
}
/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompactionCompleteCompactionTokensUsed {
/// Cached input tokens reused in the compaction LLM call
#[serde(skip_serializing_if = "Option::is_none")]
pub cache_read_tokens: Option,
/// Tokens written to prompt cache in the compaction LLM call
#[serde(skip_serializing_if = "Option::is_none")]
pub cache_write_tokens: Option,
/// Per-request cost and usage data from the CAPI copilot_usage response field
#[doc(hidden)]
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) copilot_usage: Option,
/// Duration of the compaction LLM call in milliseconds
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option,
/// Input tokens consumed by the compaction LLM call
#[serde(skip_serializing_if = "Option::is_none")]
pub input_tokens: Option,
/// Model identifier used for the compaction LLM call
#[serde(skip_serializing_if = "Option::is_none")]
pub model: Option,
/// Output tokens produced by the compaction LLM call
#[serde(skip_serializing_if = "Option::is_none")]
pub output_tokens: Option,
}
/// Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionCompactionCompleteData {
/// Checkpoint snapshot number created for recovery
#[serde(skip_serializing_if = "Option::is_none")]
pub checkpoint_number: Option,
/// File path where the checkpoint was stored
#[serde(skip_serializing_if = "Option::is_none")]
pub checkpoint_path: Option,
/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
#[serde(skip_serializing_if = "Option::is_none")]
pub compaction_tokens_used: Option,
/// Token count from non-system messages (user, assistant, tool) after compaction
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_tokens: Option,
/// User-supplied focus instructions provided to a manual `/compact` invocation. Omitted for automatic compaction and for manual compaction with no focus text.
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_instructions: Option,
/// Error message if compaction failed
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option,
/// Number of messages removed during compaction
#[serde(skip_serializing_if = "Option::is_none")]
pub messages_removed: Option,
/// Total tokens in conversation after compaction
#[serde(skip_serializing_if = "Option::is_none")]
pub post_compaction_tokens: Option,
/// Number of messages before compaction
#[serde(skip_serializing_if = "Option::is_none")]
pub pre_compaction_messages_length: Option,
/// Total tokens in conversation before compaction
#[serde(skip_serializing_if = "Option::is_none")]
pub pre_compaction_tokens: Option,
/// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
#[serde(skip_serializing_if = "Option::is_none")]
pub request_id: Option,
/// Copilot service request ID (x-copilot-service-request-id header) for the compaction LLM call
#[serde(skip_serializing_if = "Option::is_none")]
pub service_request_id: Option,
/// Whether compaction completed successfully
pub success: bool,
/// LLM-generated summary of the compacted conversation history
#[serde(skip_serializing_if = "Option::is_none")]
pub summary_content: Option,
/// Token count from system message(s) after compaction
#[serde(skip_serializing_if = "Option::is_none")]
pub system_tokens: Option,
/// Number of tokens removed during compaction
#[serde(skip_serializing_if = "Option::is_none")]
pub tokens_removed: Option,
/// Token count from tool definitions after compaction
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_definitions_tokens: Option,
}
/// Session event "session.task_complete". Task completion notification with summary from the agent
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTaskCompleteData {
/// Whether the tool call succeeded. False when validation failed (e.g., invalid arguments)
#[serde(skip_serializing_if = "Option::is_none")]
pub success: Option,
/// Summary of the completed task, provided by the agent
#[serde(skip_serializing_if = "Option::is_none")]
pub summary: Option,
}
/// Session event "user.message".
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserMessageData {
/// The agent mode that was active when this message was sent
#[serde(skip_serializing_if = "Option::is_none")]
pub agent_mode: Option,
/// Files, selections, or GitHub references attached to the message
#[serde(skip_serializing_if = "Option::is_none")]
pub attachments: Option>,
/// The user's message text as displayed in the timeline
pub content: String,
/// CAPI interaction ID for correlating this user message with its turn
#[serde(skip_serializing_if = "Option::is_none")]
pub interaction_id: Option,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub is_autopilot_continuation: Option,
/// 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
#[serde(skip_serializing_if = "Option::is_none")]
pub native_document_path_fallback_paths: Option>,
/// Parent agent task ID for background telemetry correlated to this user turn
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_agent_task_id: Option,
/// Origin of this message, used for timeline filtering (e.g., "skill-pdf" for skill-injected messages that should be hidden from the user)
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option,
/// Normalized document MIME types that were sent natively instead of through tagged_files XML
#[serde(skip_serializing_if = "Option::is_none")]
pub supported_native_document_mime_types: Option>,
/// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching
#[serde(skip_serializing_if = "Option::is_none")]
pub transformed_content: Option,
}
/// Session event "pending_messages.modified". Empty payload; the event signals that the pending message queue has changed
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PendingMessagesModifiedData {}
/// Session event "assistant.turn_start". Turn initialization metadata including identifier and interaction tracking
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantTurnStartData {
/// CAPI interaction ID for correlating this turn with upstream telemetry
#[serde(skip_serializing_if = "Option::is_none")]
pub interaction_id: Option,
/// Identifier for this turn within the agentic loop, typically a stringified turn number
pub turn_id: String,
}
/// Session event "assistant.intent". Agent intent description for current activity or plan
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantIntentData {
/// Short description of what the agent is currently doing or planning to do
pub intent: String,
}
/// Session event "assistant.reasoning". Assistant reasoning content for timeline display with complete thinking text
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantReasoningData {
/// The complete extended thinking text from the model
pub content: String,
/// Unique identifier for this reasoning block
pub reasoning_id: String,
}
/// Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantReasoningDeltaData {
/// Incremental text chunk to append to the reasoning content
pub delta_content: String,
/// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event
pub reasoning_id: String,
}
/// Session event "assistant.streaming_delta". Streaming response progress with cumulative byte count
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantStreamingDeltaData {
/// Cumulative total bytes received from the streaming response so far
pub total_response_size_bytes: i64,
}
/// A source that backs one or more cited spans in the assistant's response.
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CitationSource {
/// Stable, turn-scoped identifier for this source, referenced by CitationReference.sourceId.
pub id: String,
/// File path relative to the agent's workspace root, when the source is a file.
#[serde(skip_serializing_if = "Option::is_none")]
pub path: Option,
/// The system that produced this citation.
pub provider: CitationProvider,
/// Human-readable title of the source.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option,
/// URL of the source, when it is a web resource.
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option,
}
/// A single citation occurrence linking a span of generated text to a supporting source.
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CitationReference {
/// The exact text from the source that supports the cited span, when provided by the model.
#[serde(skip_serializing_if = "Option::is_none")]
pub cited_text: Option,
/// Location within the source that supports the cited span, when the provider reports one.
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option,
/// Provider-native citation correlation data (e.g. Anthropic search_result_index / document_index), passed through opaquely for debugging and forward compatibility.
#[serde(skip_serializing_if = "Option::is_none")]
pub provider_metadata: Option,
/// Identifier of the CitationSource this reference points to (CitationSource.id).
pub source_id: String,
}
/// A contiguous span of generated assistant text and the source references that support it.
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CitationSpan {
/// End offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, exclusive).
pub end_index: i64,
/// The sources that support this span of generated text.
pub references: Vec,
/// Start offset of the cited span within the final assistant message content (UTF-16 code units, zero-based, inclusive).
pub start_index: i64,
}
/// Provider-agnostic citations linking spans of the assistant's response to their supporting sources.
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Citations {
/// Deduplicated set of sources referenced by the citation spans.
pub sources: Vec,
/// Spans of generated text annotated with the sources that support them.
pub spans: Vec,
}
/// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageServerTools {
#[serde(skip_serializing_if = "Option::is_none")]
pub advisor_model: Option,
#[serde(skip_serializing_if = "Option::is_none")]
pub function_call_namespaces: Option>,
#[serde(skip_serializing_if = "Option::is_none")]
pub items: Option>,
pub provider: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub raw_content_blocks: Option>,
}
/// A tool invocation request from the assistant
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageToolRequest {
/// Arguments to pass to the tool, format depends on the tool
#[serde(skip_serializing_if = "Option::is_none")]
pub arguments: Option,
/// Resolved intention summary describing what this specific call does
#[serde(skip_serializing_if = "Option::is_none")]
pub intention_summary: Option,
/// Name of the MCP server hosting this tool, when the tool is an MCP tool
#[serde(skip_serializing_if = "Option::is_none")]
pub mcp_server_name: Option,
/// Original tool name on the MCP server, when the tool is an MCP tool
#[serde(skip_serializing_if = "Option::is_none")]
pub mcp_tool_name: Option,
/// Name of the tool being invoked
pub name: String,
/// Unique identifier for this tool call
pub tool_call_id: String,
/// Human-readable display title for the tool
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_title: Option,
/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
#[serde(skip_serializing_if = "Option::is_none")]
pub r#type: Option,
}
/// Session event "assistant.message". Assistant response containing text content, optional tool requests, and interaction metadata
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageData {
/// Provider's completion / response identifier; shared across all chunks of a single API call. Used to group multi-chunk assistant utterances.
#[serde(skip_serializing_if = "Option::is_none")]
pub api_call_id: Option,
/// Provider-agnostic citations linking spans of this message's content to the sources that support them. Experimental; only populated when citation emission is enabled.
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(skip_serializing_if = "Option::is_none")]
pub citations: Option,
/// The assistant's text response content
pub content: String,
/// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
#[serde(skip_serializing_if = "Option::is_none")]
pub encrypted_content: Option,
/// CAPI interaction ID for correlating this message with upstream telemetry
#[serde(skip_serializing_if = "Option::is_none")]
pub interaction_id: Option,
/// Unique identifier for this assistant message
pub message_id: String,
/// Model that produced this assistant message, if known
#[serde(skip_serializing_if = "Option::is_none")]
pub model: Option,
/// Actual output token count from the API response (completion_tokens), used for accurate token accounting
#[serde(skip_serializing_if = "Option::is_none")]
pub output_tokens: Option,
/// Tool call ID of the parent tool invocation when this event originates from a sub-agent
#[doc(hidden)]
#[deprecated]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_tool_call_id: Option,
/// Generation phase for phased-output models (e.g., thinking vs. response phases)
#[serde(skip_serializing_if = "Option::is_none")]
pub phase: Option,
/// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_opaque: Option,
/// Readable reasoning text from the model's extended thinking
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_text: Option,
/// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
#[serde(skip_serializing_if = "Option::is_none")]
pub request_id: Option,
/// Neutral provider-tagged server-side tool-use payload (tool search, advisor) for verbatim round-tripping
#[serde(skip_serializing_if = "Option::is_none")]
pub server_tools: Option,
/// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
#[serde(skip_serializing_if = "Option::is_none")]
pub service_request_id: Option,
/// Tool invocations requested by the assistant in this message
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_requests: Option>,
/// Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
#[serde(skip_serializing_if = "Option::is_none")]
pub turn_id: Option,
}
/// Session event "assistant.message_start". Streaming assistant message start metadata
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageStartData {
/// Message ID this start event belongs to, matching subsequent deltas and assistant.message
pub message_id: String,
/// Generation phase this message belongs to for phased-output models
#[serde(skip_serializing_if = "Option::is_none")]
pub phase: Option,
}
/// Session event "assistant.message_delta". Streaming assistant message delta for incremental response updates
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageDeltaData {
/// Incremental text chunk to append to the message content
pub delta_content: String,
/// Message ID this delta belongs to, matching the corresponding assistant.message event
pub message_id: String,
/// Tool call ID of the parent tool invocation when this event originates from a sub-agent
#[doc(hidden)]
#[deprecated]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_tool_call_id: Option,
}
/// Session event "assistant.turn_end". Turn completion metadata including the turn identifier
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantTurnEndData {
/// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event
pub turn_id: String,
}
/// Token usage detail for a single billing category
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantUsageCopilotUsageTokenDetail {
/// Number of tokens in this billing batch
pub batch_size: i64,
/// Cost per batch of tokens
pub cost_per_batch: i64,
/// Total token count for this entry
pub token_count: i64,
/// Token category (e.g., "input", "output")
pub token_type: String,
}
/// Per-request cost and usage data from the CAPI copilot_usage response field
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantUsageCopilotUsage {
/// Itemized token usage breakdown
#[doc(hidden)]
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) token_details: Option>,
/// Total cost in nano-AI units for this request
pub total_nano_aiu: f64,
}
/// Schema for the `AssistantUsageQuotaSnapshot` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct AssistantUsageQuotaSnapshot {
/// Total requests allowed by the entitlement
#[doc(hidden)]
pub(crate) entitlement_requests: i64,
/// Whether the user has an unlimited usage entitlement
#[doc(hidden)]
pub(crate) is_unlimited_entitlement: bool,
/// Number of additional usage requests made this period
#[doc(hidden)]
pub(crate) overage: f64,
/// Whether additional usage is allowed when quota is exhausted
#[doc(hidden)]
pub(crate) overage_allowed_with_exhausted_quota: bool,
/// Percentage of quota remaining (0 to 100)
#[doc(hidden)]
pub(crate) remaining_percentage: f64,
/// Date when the quota resets
#[doc(hidden)]
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) reset_date: Option,
/// Whether usage is still permitted after quota exhaustion
#[doc(hidden)]
pub(crate) usage_allowed_with_exhausted_quota: bool,
/// Number of requests already consumed
#[doc(hidden)]
pub(crate) used_requests: i64,
}
/// Session event "assistant.usage". LLM API call usage metrics including tokens, costs, quotas, and billing information
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantUsageData {
/// Completion ID from the model provider (e.g., chatcmpl-abc123)
#[serde(skip_serializing_if = "Option::is_none")]
pub api_call_id: Option,
/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
#[serde(skip_serializing_if = "Option::is_none")]
pub api_endpoint: Option,
/// Number of tokens read from prompt cache
#[serde(skip_serializing_if = "Option::is_none")]
pub cache_read_tokens: Option,
/// Number of tokens written to prompt cache
#[serde(skip_serializing_if = "Option::is_none")]
pub cache_write_tokens: Option,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub content_filter_triggered: Option,
/// Per-request cost and usage data from the CAPI copilot_usage response field
#[serde(skip_serializing_if = "Option::is_none")]
pub copilot_usage: Option,
/// Model multiplier cost for billing purposes
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(skip_serializing_if = "Option::is_none")]
pub cost: Option,
/// Duration of the API call in milliseconds
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option,
/// 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".
#[serde(skip_serializing_if = "Option::is_none")]
pub finish_reason: Option,
/// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
#[serde(skip_serializing_if = "Option::is_none")]
pub initiator: Option,
/// Number of input tokens consumed
#[serde(skip_serializing_if = "Option::is_none")]
pub input_tokens: Option,
/// Average inter-token latency in milliseconds. Only available for streaming requests
#[serde(skip_serializing_if = "Option::is_none")]
pub inter_token_latency_ms: Option,
/// Model identifier used for this API call
pub model: String,
/// Number of output tokens produced
#[serde(skip_serializing_if = "Option::is_none")]
pub output_tokens: Option,
/// Parent tool call ID when this usage originates from a sub-agent
#[doc(hidden)]
#[deprecated]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_tool_call_id: Option,
/// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
#[serde(skip_serializing_if = "Option::is_none")]
pub provider_call_id: Option,
/// Per-quota resource usage snapshots, keyed by quota identifier
#[doc(hidden)]
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) quota_snapshots: Option>,
/// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_effort: Option,
/// Number of output tokens used for reasoning (e.g., chain-of-thought)
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_tokens: Option,
/// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
#[serde(skip_serializing_if = "Option::is_none")]
pub service_request_id: Option,
/// Time to first token in milliseconds. Only available for streaming requests
#[serde(skip_serializing_if = "Option::is_none")]
pub time_to_first_token_ms: Option,
}
/// Content-free structural summary of the failing request for diagnosing malformed 4xx calls
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ModelCallFailureRequestFingerprint {
/// Total number of image content parts
pub image_part_count: i64,
/// Image parts whose media type cannot be determined (rejected by strict providers)
pub image_parts_missing_media_type: i64,
/// Role of the final message in the request
#[serde(skip_serializing_if = "Option::is_none")]
pub last_message_role: Option,
/// Total number of messages in the request
pub message_count: i64,
/// Tool calls whose name is missing or empty (rejected by strict providers)
pub nameless_tool_call_count: i64,
/// Total number of tool calls across assistant messages
pub tool_call_count: i64,
/// Number of "tool" result messages in the request
pub tool_result_message_count: i64,
}
/// Session event "model.call_failure". Failed LLM API call metadata for telemetry
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ModelCallFailureData {
/// Completion ID from the model provider (e.g., chatcmpl-abc123)
#[serde(skip_serializing_if = "Option::is_none")]
pub api_call_id: Option,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub bad_request_kind: Option,
/// Duration of the failed API call in milliseconds
#[serde(skip_serializing_if = "Option::is_none")]
pub duration_ms: Option,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option,
/// Raw provider/runtime error message for restricted telemetry
#[serde(skip_serializing_if = "Option::is_none")]
pub error_message: Option,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub error_type: Option,
/// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
#[serde(skip_serializing_if = "Option::is_none")]
pub initiator: Option,
/// Model identifier used for the failed API call
#[serde(skip_serializing_if = "Option::is_none")]
pub model: Option,
/// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
#[serde(skip_serializing_if = "Option::is_none")]
pub provider_call_id: Option,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub request_fingerprint: Option,
/// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
#[serde(skip_serializing_if = "Option::is_none")]
pub service_request_id: Option,
/// Where the failed model call originated
pub source: ModelCallFailureSource,
/// HTTP status code from the failed request
#[serde(skip_serializing_if = "Option::is_none")]
pub status_code: Option,
}
/// Session event "abort". Turn abort information including the reason for termination
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AbortData {
/// Finite reason code describing why the current turn was aborted
pub reason: AbortReason,
}
/// Session event "tool.user_requested". User-initiated tool invocation request with tool name and arguments
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolUserRequestedData {
/// Arguments for the tool invocation
#[serde(skip_serializing_if = "Option::is_none")]
pub arguments: Option,
/// Unique identifier for this tool call
pub tool_call_id: String,
/// Name of the tool the user wants to invoke
pub tool_name: String,
}
/// Schema for the `ToolExecutionStartToolDescriptionMetaUI` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionStartToolDescriptionMetaUI {
/// URI of the UI resource
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_uri: Option,
/// Who can access this tool
#[serde(skip_serializing_if = "Option::is_none")]
pub visibility: Option>,
}
/// MCP Apps metadata for UI resource association
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionStartToolDescriptionMeta {
/// Schema for the `ToolExecutionStartToolDescriptionMetaUI` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub ui: Option,
}
/// Tool definition metadata, present for MCP tools with MCP Apps support
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionStartToolDescription {
/// MCP Apps metadata for UI resource association
#[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
pub meta: Option,
/// Tool description
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option,
/// Tool name
pub name: String,
}
/// Session event "tool.execution_start". Tool execution startup details including MCP server information when applicable
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionStartData {
/// Arguments passed to the tool
#[serde(skip_serializing_if = "Option::is_none")]
pub arguments: Option,
/// When true, the tool output should be displayed expanded (verbatim) in the CLI timeline
#[serde(skip_serializing_if = "Option::is_none")]
pub display_verbatim: Option,
/// Name of the MCP server hosting this tool, when the tool is an MCP tool
#[serde(skip_serializing_if = "Option::is_none")]
pub mcp_server_name: Option,
/// Original tool name on the MCP server, when the tool is an MCP tool
#[serde(skip_serializing_if = "Option::is_none")]
pub mcp_tool_name: Option,
/// Model identifier that generated this tool call
#[serde(skip_serializing_if = "Option::is_none")]
pub model: Option,
/// Tool call ID of the parent tool invocation when this event originates from a sub-agent
#[doc(hidden)]
#[deprecated]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_tool_call_id: Option,
/// Unique identifier for this tool call
pub tool_call_id: String,
/// Tool definition metadata, present for MCP tools with MCP Apps support
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_description: Option,
/// Name of the tool being executed
pub tool_name: String,
/// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
#[serde(skip_serializing_if = "Option::is_none")]
pub turn_id: Option,
}
/// Session event "tool.execution_partial_result". Streaming tool execution output for incremental result display
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionPartialResultData {
/// Incremental output chunk from the running tool
pub partial_output: String,
/// Tool call ID this partial result belongs to
pub tool_call_id: String,
}
/// Session event "tool.execution_progress". Tool execution progress notification with status message
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionProgressData {
/// Human-readable progress status message (e.g., from an MCP server)
pub progress_message: String,
/// Tool call ID this progress notification belongs to
pub tool_call_id: String,
}
/// Error details when the tool execution failed
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteError {
/// Machine-readable error code
#[serde(skip_serializing_if = "Option::is_none")]
pub code: Option,
/// Human-readable error message
pub message: String,
}
/// A source supplied by a tool that should be made available to the model as citable content.
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CitableSource {
/// The source text made available to the model as citable content.
pub content: String,
/// 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.
pub id: String,
/// File path relative to the agent's workspace root, when the source is a file.
#[serde(skip_serializing_if = "Option::is_none")]
pub path: Option,
/// Human-readable title of the source.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option,
/// URL of the source, when it is a web resource.
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option,
}
/// Plain text content block
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentText {
/// The text content
pub text: String,
/// Content block type discriminator
pub r#type: ToolExecutionCompleteContentTextType,
}
/// Terminal/shell output content block with optional exit code and working directory
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentTerminal {
/// Working directory where the command was executed
#[serde(skip_serializing_if = "Option::is_none")]
pub cwd: Option,
/// Process exit code, if the command has completed
#[serde(skip_serializing_if = "Option::is_none")]
pub exit_code: Option,
/// Terminal/shell output text
pub text: String,
/// Content block type discriminator
pub r#type: ToolExecutionCompleteContentTerminalType,
}
/// Image content block with base64-encoded data
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentImage {
/// Base64-encoded image data
pub data: String,
/// MIME type of the image (e.g., image/png, image/jpeg)
pub mime_type: String,
/// Content block type discriminator
pub r#type: ToolExecutionCompleteContentImageType,
}
/// Audio content block with base64-encoded data
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentAudio {
/// Base64-encoded audio data
pub data: String,
/// MIME type of the audio (e.g., audio/wav, audio/mpeg)
pub mime_type: String,
/// Content block type discriminator
pub r#type: ToolExecutionCompleteContentAudioType,
}
/// Icon image for a resource
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentResourceLinkIcon {
/// MIME type of the icon image
#[serde(skip_serializing_if = "Option::is_none")]
pub mime_type: Option,
/// Available icon sizes (e.g., ['16x16', '32x32'])
#[serde(skip_serializing_if = "Option::is_none")]
pub sizes: Option>,
/// URL or path to the icon image
pub src: String,
/// Theme variant this icon is intended for
#[serde(skip_serializing_if = "Option::is_none")]
pub theme: Option,
}
/// Resource link content block referencing an external resource
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentResourceLink {
/// Human-readable description of the resource
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option,
/// Icons associated with this resource
#[serde(skip_serializing_if = "Option::is_none")]
pub icons: Option>,
/// MIME type of the resource content
#[serde(skip_serializing_if = "Option::is_none")]
pub mime_type: Option,
/// Resource name identifier
pub name: String,
/// Size of the resource in bytes
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option,
/// Human-readable display title for the resource
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option,
/// Content block type discriminator
pub r#type: ToolExecutionCompleteContentResourceLinkType,
/// URI identifying the resource
pub uri: String,
}
/// Schema for the `EmbeddedTextResourceContents` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EmbeddedTextResourceContents {
/// MIME type of the text content
#[serde(skip_serializing_if = "Option::is_none")]
pub mime_type: Option,
/// Text content of the resource
pub text: String,
/// URI identifying the resource
pub uri: String,
}
/// Schema for the `EmbeddedBlobResourceContents` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EmbeddedBlobResourceContents {
/// Base64-encoded binary content of the resource
pub blob: String,
/// MIME type of the blob content
#[serde(skip_serializing_if = "Option::is_none")]
pub mime_type: Option,
/// URI identifying the resource
pub uri: String,
}
/// Embedded resource content block with inline text or binary data
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentResource {
/// The embedded resource contents, either text or base64-encoded binary
pub resource: ToolExecutionCompleteContentResourceDetails,
/// Content block type discriminator
pub r#type: ToolExecutionCompleteContentResourceType,
}
/// Schema for the `ToolExecutionCompleteUIResourceMetaUICsp` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUICsp {
#[serde(skip_serializing_if = "Option::is_none")]
pub base_uri_domains: Option>,
#[serde(skip_serializing_if = "Option::is_none")]
pub connect_domains: Option>,
#[serde(skip_serializing_if = "Option::is_none")]
pub frame_domains: Option>,
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_domains: Option>,
}
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsCamera` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsCamera {}
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite {}
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation {}
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone {}
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissions` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissions {
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsCamera` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub camera: Option,
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub clipboard_write: Option,
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub geolocation: Option,
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub microphone: Option,
}
/// Schema for the `ToolExecutionCompleteUIResourceMetaUI` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUI {
/// Schema for the `ToolExecutionCompleteUIResourceMetaUICsp` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub csp: Option,
#[serde(skip_serializing_if = "Option::is_none")]
pub domain: Option,
/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissions` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub permissions: Option,
#[serde(skip_serializing_if = "Option::is_none")]
pub prefers_border: Option,
}
/// Resource-level UI metadata (CSP, permissions, visual preferences)
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMeta {
/// Schema for the `ToolExecutionCompleteUIResourceMetaUI` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub ui: Option,
}
/// MCP Apps UI resource content for rendering in a sandboxed iframe
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResource {
/// Resource-level UI metadata (CSP, permissions, visual preferences)
#[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
pub meta: Option,
/// Base64-encoded HTML content
#[serde(skip_serializing_if = "Option::is_none")]
pub blob: Option,
/// MIME type of the content
pub mime_type: String,
/// HTML content as a string
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option,
/// The ui:// URI of the resource
pub uri: String,
}
/// Tool execution result on success
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteResult {
/// Model-facing binary results (base64 inline or size-omitted markers) sent to the LLM for this tool call
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(skip_serializing_if = "Option::is_none")]
pub binary_results_for_llm: Option>,
/// Provider-neutral source material this tool makes available to the model as citable content. Persisted so it survives session resume. Experimental.
///
///
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
///
#[serde(skip_serializing_if = "Option::is_none")]
pub citable_sources: Option>,
/// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency
pub content: String,
/// Structured content blocks (text, images, audio, resources) returned by the tool in their native format
#[serde(skip_serializing_if = "Option::is_none")]
pub contents: Option>,
/// Full detailed tool result for UI/timeline display, preserving complete content such as diffs. Falls back to content when absent.
#[serde(skip_serializing_if = "Option::is_none")]
pub detailed_content: Option,
/// Structured content (arbitrary JSON) returned verbatim by the MCP tool
#[serde(skip_serializing_if = "Option::is_none")]
pub structured_content: Option,
/// MCP Apps UI resource content for rendering in a sandboxed iframe
#[serde(skip_serializing_if = "Option::is_none")]
pub ui_resource: Option,
}
/// Schema for the `ToolExecutionCompleteToolDescriptionMetaUI` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteToolDescriptionMetaUI {
/// URI of the UI resource
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_uri: Option,
/// Who can access this tool
#[serde(skip_serializing_if = "Option::is_none")]
pub visibility: Option>,
}
/// MCP Apps metadata for UI resource association
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteToolDescriptionMeta {
/// Schema for the `ToolExecutionCompleteToolDescriptionMetaUI` type.
#[serde(skip_serializing_if = "Option::is_none")]
pub ui: Option,
}
/// Tool definition metadata, present for MCP tools with MCP Apps support
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteToolDescription {
/// MCP Apps metadata for UI resource association
#[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
pub meta: Option