This page covers the low-level headless Editor approach. For production AI agent workflows, use the Document Engine AI tools instead — they provide structured tool definitions, provider-ready schemas, and built-in dispatch.
SuperDoc can run headless in Node.js for server-side document processing, AI agent workflows, and batch automation.
For multi-step workflows — extract block references, send them to an LLM, then apply edits — use the Document API. It returns stable block addresses that work across separate editor sessions:
Copy
Ask AI
// Find all paragraphs and their textconst result = editor.doc.find({ select: { type: 'node', nodeType: 'paragraph' }, includeNodes: true,});// Each item has an address with a best-effort stable nodeIdconst blocks = result.items.map((item) => ({ id: item.address.nodeId, // usually stable across loads for unchanged DOCX content type: item.address.nodeType, text: item.node?.text,}));// Send blocks to LLM, get back edits, apply them
Block addresses from doc.find() prefer DOCX-native IDs (paraId) for imported blocks. This is the best available cross-session anchor, but no ID is guaranteed to survive all Word round-trips. Don’t read node.attrs.sdBlockId directly — it’s regenerated on every load.