Copilot.Types (Copilot SDK v2.3.0)

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.

Command handler callback.

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

Elicitation handler callback.

Exit plan mode handler callback.

Options for image generation.

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.

Trace context provider callback.

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.

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

elicitation_handler()

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

Elicitation handler callback.

exit_plan_mode_handler()

Exit plan mode handler callback.

image_options()

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

Options for image generation.

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

trace_context_provider()

@type trace_context_provider() :: (-> Copilot.Types.TraceContext.t())

Trace context provider callback.

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.