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

assistant_image_data()

@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.

bearer_token_provider()

@type bearer_token_provider() :: (ProviderTokenArgs.t() -> String.t())

BYOK bearer-token provider: mints a fresh bearer token per session.

command_handler()

@type command_handler() :: (CommandContext.t() -> :ok | {:error, any()})

Command handler callback.

content_block()

@type content_block() ::
  %{type: :text, text: String.t()}
  | %{type: :image, image: assistant_image_data()}

A content block in an assistant response (text or image).

copilot_request_handler()

@type copilot_request_handler() :: (map(), map() -> map())

Intercepts outbound LLM inference HTTP/WebSocket requests.

elicitation_handler()

@type elicitation_handler() ::
  (ElicitationContext.t() -> ElicitationResult.t() | {:error, any()})

Elicitation handler callback.

image_options()

@type image_options() :: %{
  optional(:size) => String.t(),
  optional(:quality) => String.t(),
  optional(:style) => String.t()
}

Options for image generation.

mcp_auth_handler()

@type mcp_auth_handler() :: (map() -> map() | String.t())

MCP OAuth host token handler: supplies an OAuth token for an MCP auth request.

mcp_server_config()

permission_handler()

@type permission_handler() ::
  (Copilot.Types.PermissionRequest.t(), %{session_id: String.t()} ->
     Copilot.Types.PermissionRequestResult.t())

Permission handler callback.

response_format()

@type response_format() :: :text | :image | :json_object

The response format for a message.

session_event()

@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.).

session_event_type()

@type session_event_type() :: String.t()

All possible session event type strings.

system_message_config()

tool_handler()

@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.

tool_result_type()

@type tool_result_type() :: :success | :failure | :rejected | :denied

user_input_handler()

@type user_input_handler() ::
  (Copilot.Types.UserInputRequest.t(), %{session_id: String.t()} ->
     Copilot.Types.UserInputResponse.t())

User input handler callback.

Functions

response_format_to_string(atom)

Convert response format atom to JSON string.