Skip to main content
The ExtensionAPI interface provides extensions with methods to interact with the agent, register tools and commands, and respond to events.

Import

Interface

Extensions receive the ExtensionAPI through the ExtensionContext when they are initialized.

Methods

registerTool

Register a custom tool that the agent can invoke.
ToolDefinition
required

registerCommand

Register a slash command that users can invoke.
RegisteredCommand
required

on

Subscribe to extension events.
string
required
Event type to subscribe to (e.g., “tool_call”, “session_start”)
function
required
Event handler function
Available Events:
  • agent_start / agent_end - Agent turn lifecycle
  • tool_call / tool_result - Tool invocation
  • session_start / session_shutdown - Session lifecycle
  • session_compact / session_fork / session_switch - Session operations
  • input - User input events
  • turn_start / turn_end - Turn boundaries

exec

Execute a bash command.
string
required
The bash command to execute
ExecOptions
object

showDialog

Display a dialog to the user (TUI only).
ExtensionUIDialogOptions
required

showWidget

Show a persistent widget in the footer (TUI only).
ExtensionWidgetOptions
required

Example

ExtensionActions

The ExtensionActions interface provides methods for modifying agent state.

sendMessage

Send a user message to the agent.

setModel

Change the active model.

setThinkingLevel

Change the thinking level.

setActiveTools

Set which tools are currently active.