Available tools
The Tiptap AI Toolkit provides a comprehensive set of tools for interacting with Tiptap documents. These tools enable reading content, making edits, and navigating through large documents efficiently.
The tool definitions are available in the format of popular AI provider libraries:
When you add the tool definitions to your AI provider library, your AI Agent will generate tool calls. You can then execute the tool calls using the executeTool
method.
// Insert content at the current selection
await agent.executeTool({
toolName: 'insertContent',
input: {
html: '<h1>New Document</h1><p>This is completely new content.</p>',
position: 'selection',
},
})
insertContent
Insert HTML content at a specific position of the document.
Parameters
html
(string
): The HTML content to insertposition
('document' | 'documentStart' | 'documentEnd' | 'selection' | 'selectionStart' | 'selectionEnd'
): Where to insert the content'document'
: Replace the entire document with the HTML content'documentStart'
: Insert the HTML content at the start of the document'documentEnd'
: Insert the HTML content at the end of the document'selection'
: Replace the current selection with the HTML content'selectionStart'
: Insert the HTML content before the selection'selectionEnd'
: Insert the HTML content after the selection
applyDiff
Apply targeted edits via diffs to make precise changes to document content.
Parameters
diffs
(Array<Diff>
): Array of diffs to apply in sequencecontext
(string
): Context string to help locate the correct positiondelete
(string
): The content to delete from the document (must match exactly)insert
(string
): The content to insert in place of the deleted content (can be empty for pure deletions)
readFirstChunk
Get the first chunk of the document for efficient processing of large content.
Parameters
No parameters required.
readNextChunk
Get the next chunk of the document in sequence.
Parameters
No parameters required.
readPreviousChunk
Get the previous chunk of the document to navigate backward.
Parameters
No parameters required.
readSelection
Get the currently selected content in the editor.
Parameters
No parameters required.