/** * Structured error diagnostics from the SDK's session.error event (SessionErrorData), carried on ErrorInfo._meta. The host fully owns this payload (closed shape); every field is optional and is omitted when its SDK source is absent. Stamped only on the translated (non-transient) session.error path - host-synthesized errors (bridge lag, failed MCP server) leave _meta absent. Excludes the first-class ErrorInfo fields (error_type, message, stack). See spec/meta-conventions/copilot/error-info.md. */ export interface CopilotErrorDetail { /** * Fine-grained error code from the upstream provider (SDK error_code). For error_type 'rate_limit', a RateLimitErrorCode value (e.g. 'user_weekly_rate_limited'); for 'quota', a CAPI quota code (e.g. 'quota_exceeded'). */ errorCode?: string; /** * HTTP status code from the upstream request (SDK status_code), when applicable. */ statusCode?: number; /** * Optional URL associated with the error that the user can open in a browser (SDK url). */ url?: string; /** * GitHub request tracing id (SDK provider_call_id, x-github-request-id) for correlating with server-side logs. */ providerCallId?: string; /** * Copilot service request id (SDK service_request_id, x-copilot-service-request-id) for CAPI log correlation. */ serviceRequestId?: string; /** * Set on error_type 'rate_limit' (SDK eligible_for_auto_switch). When true, the runtime will follow this error with an auto_mode_switch.requested event; clients can suppress duplicate rate-limit rendering. */ eligibleForAutoSwitch?: boolean; } /** * Model-picker grouping category on SessionModelInfo._meta. Closed enumeration - readers MUST treat unrecognised strings as 'category unknown'. The host omits the key (and the entire `_meta` envelope, unless another copilot.* key on the same SessionModelInfo provides a value) when the SDK reports `Unknown`. See spec/meta-conventions/copilot/model-info.md. */ export type CopilotModelPickerCategory = "lightweight" | "versatile" | "powerful"; /** * Rich per-LLM-call diagnostics from the SDK's assistant.usage event (AssistantUsageData), carried on UsageInfo._meta. The host fully owns this payload (closed shape); every field is optional and is omitted when its SDK source is absent. Because the carrying UsageInfo is a per-turn cumulative snapshot but per-call diagnostics are not summable, the payload reflects the MOST RECENT LLM call in the turn. Excludes the first-class UsageInfo fields (input/output/cache-read tokens, model), the deprecated parent_tool_call_id, and the SDK-internal quota_snapshots. See spec/meta-conventions/copilot/usage-info.md. */ export interface CopilotUsageDetail { /** * Model multiplier cost for billing purposes (SDK cost). Experimental SDK field. */ cost?: number; /** * Number of tokens written to prompt cache (SDK cache_write_tokens). */ cacheWriteTokens?: number; /** * Updated prompt-cache expiration timestamp for this model call (SDK cache_expires_at), RFC 3339 / ISO 8601. Present only when the call establishes or refreshes known cache state. */ cacheExpiresAt?: string; /** * Number of output tokens used for reasoning (SDK reasoning_tokens). */ reasoningTokens?: number; /** * Reasoning effort level used for the call (SDK reasoning_effort), e.g. 'none', 'low', 'medium', 'high', 'xhigh', 'max'. */ reasoningEffort?: string; /** * Finish reason reported by the model (SDK finish_reason), normalized to OpenAI vocabulary, e.g. 'stop', 'length', 'tool_calls', 'content_filter'. */ finishReason?: string; /** * What initiated the call (SDK initiator), e.g. 'sub-agent', 'mcp-sampling'; absent for user-initiated calls. */ initiator?: string; /** * API endpoint used for the call (SDK api_endpoint), serialized verbatim from the closed AssistantUsageApiEndpoint enum, e.g. '/chat/completions', '/v1/messages', '/responses', 'ws:/responses'. Readers tolerate an unrecognised forward-compatibility token ('Unknown'). */ apiEndpoint?: string; /** * Completion id from the model provider (SDK api_call_id), e.g. 'chatcmpl-abc123'. */ apiCallId?: string; /** * GitHub request tracing id (SDK provider_call_id, x-github-request-id) for server-side log correlation. */ providerCallId?: string; /** * Copilot service request id (SDK service_request_id, x-copilot-service-request-id) for CAPI log correlation. */ serviceRequestId?: string; /** * Whether the response was blocked or truncated by content filtering (SDK content_filter_triggered). */ contentFilterTriggered?: boolean; /** * Duration of the API call in milliseconds (SDK duration). */ duration?: number; /** * Average inter-token latency in milliseconds (SDK inter_token_latency_ms). Streaming requests only. */ interTokenLatencyMs?: number; /** * Time to first token in milliseconds (SDK time_to_first_token_ms, fractional). Streaming requests only. */ timeToFirstTokenMs?: number; /** * Per-request cost and usage data from the CAPI copilot_usage response field (SDK copilot_usage / AssistantUsageCopilotUsage). Verbatim SDK struct - OPEN shape; readers MUST tolerate unknown fields. Carries at least 'totalNanoAiu' (number) and may carry an itemized token-detail breakdown. */ copilotUsage?: { /** * Total cost in nano-AI units for the request. */ totalNanoAiu?: number; [k: string]: unknown; }; } /** * Latest SessionUsageInfoData snapshot on SessionState._meta. Replaces the previous snapshot on each emission. The host serialises the SDK struct verbatim (camelCase serde), so the field set tracks the SDK shape; readers MUST tolerate unknown fields. See spec/meta-conventions/copilot/session-meta.md. */ export interface CopilotUsageInfo { [k: string]: unknown; } /** * Latest ModelCallFailureData snapshot on SessionState._meta. Non-turn-ending telemetry for a failed LLM API call; not cleared on recovery. The host serialises the SDK struct verbatim (camelCase serde), so the field set tracks the SDK shape; readers MUST tolerate unknown fields. See spec/meta-conventions/copilot/session-meta.md. */ export interface CopilotModelCallFailure { /** * Where the failed model call originated (e.g. top_level, subagent, mcp_sampling, unknown). */ source?: string; /** * Raw provider/runtime error string. Diagnostic content; MAY contain request detail. */ errorMessage?: string; /** * HTTP status code from the failed request, when available. */ statusCode?: number; /** * Model identifier used for the failed call. */ model?: string; /** * Duration of the failed API call in milliseconds, when available. */ durationMs?: number; [k: string]: unknown; } /** * Latest Auto tier the runtime could not activate, on SessionState._meta. A live notice, not state: the committed tier did not move, the turn was not failed, and the key is neither cleared by a later commit nor rebuilt after a host restart. The host carries the SDK `session.auto_tier_switch_failed` payload with its two tiers in the session-config vocabulary (`default` where the runtime reports none), plus the event id; values and fields newer than the host pass through, so readers MUST tolerate ones they do not recognise. A payload lacking the required fields is not published. See spec/meta-conventions/copilot/session-meta.md and spec/session-config/copilot/auto-tier.md. */ export interface CopilotAutoTierSwitchFailure { /** * The tier that could not be activated - `default` when returning to provider-default routing is what failed, otherwise a tier name (efficiency, balance, intelligence, fast today; a newer one passes through). */ requestedAutoTier: string; /** * The tier that stays in force - `default` for provider-default routing. Nothing moved, so for a tier this host models it is the same value the session's `effectiveAutoTier` already reports; a tier the host does not model passes through here by name, where `effectiveAutoTier` reports `unknown`. */ effectiveAutoTier: string; /** * Why the activation failed: request_failed, policy_rejected, setup_failed, or unsupported today. */ reason: string; /** * The runtime event's id. Distinguishes a repeat of the same failure from the one before it. */ eventId: string; [k: string]: unknown; } /** * Latest SessionContextChangedData snapshot on SessionState._meta. Reports the working directory and git context after a mid-session change. The host serialises the SDK struct verbatim (camelCase serde), so the field set tracks the SDK shape; readers MUST tolerate unknown fields. See spec/meta-conventions/copilot/session-meta.md. */ export interface CopilotContext { /** * Current working directory path. Always present. */ cwd: string; /** * Current git branch name, when inside a git repository. */ branch?: string; /** * Root directory of the git repository, when inside one. */ gitRoot?: string; /** * Repository identifier derived from the git remote URL (owner/name for GitHub). */ repository?: string; [k: string]: unknown; } /** * The verbatim SDK Attachment blob, carried on a message attachment's _meta slot (SimpleMessageAttachment._meta for a GitHub reference or GitHub-anchored kind, MessageResourceAttachment._meta for a selection) for the attachment kinds whose typed AHP shell drops a meaningful field. OPEN shape: the value is the SDK's `copilot::types::Attachment` struct serialized verbatim, with its `type` discriminator intact; the shape evolves on the SDK's release cadence and readers MUST tolerate unknown fields. Bidirectional: the host stamps this key outbound (for `selection`, `github_reference`, and the GitHub-anchored kinds; the `file` / `directory` / `blob` kinds map losslessly onto a typed shell and carry no _meta), and an AHP client MAY echo it inbound so the host can losslessly rebuild the SDK Attachment on sendMessage. See spec/meta-conventions/copilot/message-attachment.md. */ export interface CopilotAttachmentDetail { /** * SDK attachment discriminator. The host stamps this key only for the lossy kinds, so in practice this is `selection`, `github_reference`, or a GitHub-anchored kind (e.g. `github_commit`); readers MUST tolerate any other value (forward compatibility). */ type: string; /** * selection only: absolute path to the source file. */ filePath?: string; /** * selection only: the selected text - the field the typed Resource shell can't hold. */ text?: string; /** * selection only: the selected range as 0-based { line, character } start/end positions (SDK AttachmentSelectionRange). */ selection?: { start?: { line?: number; character?: number; [k: string]: unknown; }; end?: { line?: number; character?: number; [k: string]: unknown; }; [k: string]: unknown; }; /** * github_reference only: issue / PR / discussion number. */ number?: number; /** * github_reference only: title of the referenced item. */ title?: string; /** * github_reference only: kind of reference, e.g. 'issue', 'pr', 'discussion'. */ referenceType?: string; /** * github_reference only: current state, e.g. 'open', 'closed'. */ state?: string; /** * github_reference only: URL to the referenced item. */ url?: string; /** * Optional UI label carried by the SDK attachment. */ displayName?: string; [k: string]: unknown; } /** * Exact non-empty Copilot SDK user.message.source provenance tag carried on Message._meta. */ export type CopilotSource = string; /** * Presentation hint for runtime-injected Message content carried on Message._meta. */ export type CopilotVisibility = "internal"; /** * How the Copilot runtime sourced and loads one of the server tools the host publishes on SessionState.serverTools, carried on ToolDefinition._meta. Host-produced; the host never reads this key. Closed shape - the host owns every field. See spec/meta-conventions/copilot/tool-definition.md. */ export interface CopilotToolOrigin { /** * Where the tool comes from: 'builtin' for a tool the Copilot runtime implements itself, 'mcp' for one the runtime proxies from a connected MCP server. */ kind: "builtin" | "mcp"; /** * The runtime's namespaced name for the tool, when it has one (e.g. 'playwright/navigate'). Distinct from the flat model-facing ToolDefinition.name. */ namespacedName?: string; /** * Name of the MCP server backing the tool. Present only when kind is 'mcp'; matches the corresponding McpServerCustomization. */ mcpServerName?: string; /** * The tool's raw name on its MCP server, before the runtime flattened it into the session's tool namespace. Present only when kind is 'mcp'. */ mcpToolName?: string; /** * True when the runtime leaves the tool out of the eagerly pre-loaded tool set and surfaces it on demand through tool search. Absent when the runtime expressed no preference. */ deferLoading?: boolean; } /** * Tool-specific telemetry from the SDK's tool.execution_complete event (ToolExecutionCompleteData.tool_telemetry), carried on ToolCallState._meta and delivered on the chat/toolCallComplete action's _meta. The tool's own structured metrics (e.g. a grep tool's match count, a CodeQL tool's check count). The interior is tool-defined and forwarded verbatim (OPEN shape); readers tolerate any keys and any value types. Stamped only on the complete transition and only for server-side tool calls (client-owned tools carry their own complete). Omitted when the SDK reports no telemetry or an empty map - the host never ships an empty {}. Top-level keys are emitted in sorted order for output stability; order is not semantically significant. See spec/meta-conventions/copilot/tool-call.md. */ export interface CopilotToolTelemetry { [k: string]: unknown; } /** * One incremental output chunk from a running tool, carried on ChatToolCallDelta._meta (chat/toolCallDelta). The host maps the SDK's tool.execution_partial_result event's partialOutput verbatim. Each delta carries one chunk on its own independent _meta slot - consumers append chunks in arrival order, they are NOT snapshots. The host fully owns the value (a plain string) and omits the key entirely when the chunk would be the empty string. The delta's first-class `content` field is reserved for partial tool-argument content and stays empty for output deltas. See spec/meta-conventions/copilot/tool-call-delta.md. */ export type CopilotToolOutputDelta = string; /** * Client-supplied deferral preference for an externally-registered tool, carried on ToolDefinition._meta. Closed enumeration - the host MUST treat unrecognised strings (and absence / empty / non-string values) as 'no preference' and leave the SDK default in place. Produced by the AHP client registering the tool; consumed by the host, which maps it to the SDK `DeferMode` via `Tool::with_defer`. See spec/meta-conventions/copilot/tool-definition.md. */ export type CopilotToolDefer = "auto" | "never"; /** * Client-supplied restriction on where an externally-registered tool may be invoked, carried on ToolDefinition._meta. Closed enumeration - the host MUST treat unrecognised strings (and absence / empty / non-string values) as 'session', the unrestricted default. Produced by the AHP client registering the tool; consumed by the host, which refuses a 'userChats' tool invoked from a chat whose ChatOrigin is `tool`. See spec/meta-conventions/copilot/tool-definition.md. */ export type CopilotToolAvailability = "session" | "userChats";