AIActions exposes two layers of functionality:
- Wrapper methods on the
AIActionsinstance (lifecycle & raw completions). - Action helpers under
ai.action, which combine prompting, response parsing, and editor updates.
Instance methods
waitUntilReady
Resolves once provider/user set-up completes. Safe to call multiple times.
Returns: Promise<void>
Example:
getIsReady
Returns true after initialisation.
Returns: boolean
Example:
getCompletion
Single-shot completion that includes the serialized document context.
Parameters:
The user prompt for the AI
Optional completion configuration
Promise<string>
Example:
streamCompletion
Streams a completion, firing hooks for each chunk and resolving with the full string.
Parameters:
The user prompt for the AI
Optional streaming configuration
Promise<string>
Example:
getDocumentContext
Retrieves the current document context for AI processing. Returns the plain text content of the active editor document.
Returns: string
Example:
Action helpers
All actions return aResult object containing { success: boolean; results: FoundMatch[] }. Each FoundMatch includes the AI text (originalText, suggestedText) alongside the resolved document positions.
find
Finds the first occurrence and resolves its document positions.
Parameters:
AI instruction describing what to find
Promise<Result>
Example:
findAll
Finds every occurrence matching the instruction.
Parameters:
AI instruction describing what to find
Promise<Result>
highlight
Highlights the first match in the editor with the specified color.
Parameters:
AI instruction describing what to highlight
Hex color code for the highlight
Promise<Result>
replace
Replaces a single match with AI-generated text.
Parameters:
AI instruction describing what to replace and how
Promise<Result>
Example:
replaceAll
Replaces every match with AI-generated text.
Parameters:
AI instruction describing what to replace and how
Promise<Result>
insertTrackedChange
Inserts a tracked change attributed to the configured user (e.g., “RedlineBot”).
Parameters:
AI instruction describing what change to track
Promise<Result>
Example:
insertTrackedChanges
Inserts tracked changes for multiple matches.
Parameters:
AI instruction describing what changes to track
Promise<Result>
insertComment
Inserts a comment annotating the first match.
Parameters:
AI instruction describing what to comment on
Promise<Result>
insertComments
Inserts comments for every match.
Parameters:
AI instruction describing what to comment on
Promise<Result>
summarize
Returns AI-generated summary text in the suggestedText field. Streams results if the provider supports streaming.
Parameters:
AI instruction describing what to summarize
Promise<Result>
Example:
insertContent
Inserts AI-generated content into the document at the current cursor position, or appends it to the end if no cursor location is set. Content streams directly into the editor as it arrives from the provider.
Parameters:
AI instruction describing what content to insert
Promise<Result>
Types
Result
FoundMatch
DocumentPosition
CompletionOptions
getCompletion() calls.
StreamOptions
streamCompletion() calls. Extends CompletionOptions with a stream flag.
Advanced Exports
For advanced use cases, the package exports additional classes and utilities:AIActionsService- Core service with direct access to action implementationsEditorAdapter- Editor interaction layer for custom integrationscreateAIProvider(config)- Factory function for creating AI providersisAIProvider(value)- Type guard to check if value is an AIProvider- Utilities:
validateInput(),parseJSON(),removeMarkdownCodeBlocks(),generateId()

