Copilot. Types
(Copilot SDK v2.5.2)
Copy Markdown
Type definitions for the Copilot SDK.
All types are represented as structs with typespecs, following the same patterns as the Node.js and Python SDKs.
Summary
Types
Image data returned by the assistant.
BYOK bearer-token provider: mints a fresh bearer token per session.
Command handler callback.
A content block in an assistant response (text or image).
Intercepts outbound LLM inference HTTP/WebSocket requests.
Elicitation handler callback.
Options for image generation.
MCP OAuth host token handler: supplies an OAuth token for an MCP auth request.
Permission handler callback.
The response format for a message.
A session event from the Copilot CLI server.
All possible session event type strings.
A tool handler function.
User input handler callback.
Functions
Convert response format atom to JSON string.
Types
@type assistant_image_data() :: %{ format: String.t(), base64: String.t(), url: String.t() | nil, revised_prompt: String.t() | nil, width: integer(), height: integer() }
Image data returned by the assistant.
@type bearer_token_provider() :: (ProviderTokenArgs.t() -> String.t())
BYOK bearer-token provider: mints a fresh bearer token per session.
@type command_handler() :: (CommandContext.t() -> :ok | {:error, any()})
Command handler callback.
@type content_block() :: %{type: :text, text: String.t()} | %{type: :image, image: assistant_image_data()}
A content block in an assistant response (text or image).
Intercepts outbound LLM inference HTTP/WebSocket requests.
@type elicitation_handler() :: (ElicitationContext.t() -> ElicitationResult.t() | {:error, any()})
Elicitation handler callback.
@type image_options() :: %{ optional(:size) => String.t(), optional(:quality) => String.t(), optional(:style) => String.t() }
Options for image generation.
MCP OAuth host token handler: supplies an OAuth token for an MCP auth request.
@type mcp_server_config() :: Copilot.Types.MCPLocalServerConfig.t() | Copilot.Types.MCPRemoteServerConfig.t()
@type permission_handler() :: (Copilot.Types.PermissionRequest.t(), %{session_id: String.t()} -> Copilot.Types.PermissionRequestResult.t())
Permission handler callback.
@type response_format() :: :text | :image | :json_object
The response format for a message.
@type session_event() :: %{ :type => String.t(), :id => String.t(), :timestamp => String.t(), optional(:parentId) => String.t() | nil, optional(:ephemeral) => boolean(), optional(:agentId) => String.t() | nil, data: map() }
A session event from the Copilot CLI server.
Events are maps with at least type, id, timestamp, and data keys.
The type field discriminates the event kind (e.g. "assistant.message",
"session.idle", "tool.execution_complete", etc.).
@type session_event_type() :: String.t()
All possible session event type strings.
@type system_message_config() :: Copilot.Types.SystemMessageAppendConfig.t() | Copilot.Types.SystemMessageReplaceConfig.t() | Copilot.Types.SystemMessageCustomizeConfig.t()
@type tool_handler() :: (any(), Copilot.Types.ToolInvocation.t() -> any())
A tool handler function.
Receives the parsed arguments and a ToolInvocation struct. Must return
a ToolResult struct, a plain string, or any term that will be
JSON-encoded as a success result.
@type tool_result_type() :: :success | :failure | :rejected | :denied
@type user_input_handler() :: (Copilot.Types.UserInputRequest.t(), %{session_id: String.t()} -> Copilot.Types.UserInputResponse.t())
User input handler callback.