AgentProvider
Interface for implementing custom AI agent providers. Agent providers handle sending prompts to AI services and streaming responses.Properties
(context: AgentContext<T>, signal: AbortSignal) => AsyncIterable<string>
required
Send a prompt to the agent and receive streaming response. Must return an async iterable that yields status message strings.
context- The agent context with content, prompt, and optionssignal- AbortSignal for cancellation support
(sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncIterable<string>
Resume a previously started session. Only required if
supportsResume is true.sessionId- ID of the session to resumesignal- AbortSignal for cancellationstorage- Storage interface for retrieving session data
(sessionId: string) => Promise<void>
Abort a running session. Called when user cancels an active agent operation.
boolean
default:"false"
Whether this provider supports resuming sessions after page reload.
boolean
default:"false"
Whether this provider supports follow-up prompts in the same session.
string
Custom text for the dismiss button in the agent UI. Defaults to “Dismiss”.
() => Promise<boolean>
Check if the agent service is available. Called before showing agent UI.
() => string | undefined
Get a custom completion message to show when agent finishes successfully.
() => Promise<void>
Undo the last agent action. Only required if
canUndo returns true.() => boolean
Whether undo is currently available. Checked to show/hide undo button.
() => Promise<void>
Redo a previously undone action. Only required if
canRedo returns true.() => boolean
Whether redo is currently available. Checked to show/hide redo button.
AgentContext
Context object passed to agent providers containing the prompt and selected content.Properties
string[]
required
Array of content strings from selected elements. Each string represents the code/content of one grabbed element.
string
required
The user’s prompt/instruction for the agent.
T
Custom options for the agent provider. Type parameter T allows providers to specify their own options interface.
string
Unique session identifier. Useful for tracking and resuming sessions.
AgentSession
Represents an active or completed agent session with its state and metadata.Properties
string
required
Unique session identifier.
AgentContext
required
The agent context (content, prompt, options) for this session.
string
required
The most recent status message from the agent.
boolean
required
Whether the agent is currently streaming responses.
boolean
Whether the session UI is fading out (dismissing).
number
required
Timestamp (ms) when the session was created.
number
required
Timestamp (ms) of the last update to this session.
{ x: number; y: number }
required
Screen position where the agent UI should appear.
OverlayBounds[]
required
Visual bounds of selected elements for highlighting.
string
HTML tag name of the primary selected element.
string
React component name of the primary selected element.
string
Error message if the session failed.
AgentSessionStorage
Storage interface for persisting agent session data. Used for session resumption.Properties
(key: string) => string | null
required
Retrieve a stored value by key. Returns null if not found.
(key: string, value: string) => void
required
Store a value with the given key. Overwrites existing value.
(key: string) => void
required
Remove a stored value by key.
AgentOptions
Configuration options for agent integration.Properties
AgentProvider<T>
The agent provider instance to use for this operation.
AgentSessionStorage | null
Storage implementation for session persistence. Pass null to disable.
() => T
Function that returns custom options to pass to the provider.
(session: AgentSession, elements: Element[]) => void
Called when an agent session starts.
(status: string, session: AgentSession) => void
Called when agent sends a status update.
(session: AgentSession, elements: Element[]) => AgentCompleteResult | void | Promise<AgentCompleteResult | void>
Called when agent completes successfully. Can return an error to show.
(error: Error, session: AgentSession) => void
Called when agent encounters an error.
(session: AgentSession) => void
Called when a session is resumed.
(session: AgentSession, elements: Element[]) => void
Called when user aborts a session.
(session: AgentSession, elements: Element[]) => void
Called when user triggers undo.
(session: AgentSession, elements: Element[]) => void
Called when user dismisses the session UI.
