Agent Framework

Word JS API Parity (Office.js for the Web)

Microsoft Word JS API (Office.js) parity for React. Same Range, comments, search, tracked changes verbs. Parity enforced at compile time.

The bridge mirrors a documented subset of the Microsoft Word JS API (Office.js). Parity is enforced at compile time via the exported WordCompatBridge interface: if EditorBridge drifts from the contract, typecheck fails.

The result is a familiar surface for anyone migrating from a Word add-in. Most call sites map one-to-one.

Mapping

Microsoft Word JS APIAgent API equivalent
Range (stable handle)paraId: string
body.search(text) → RangesfindText(query, opts) → FoundMatch[]
range.insertComment(text)addComment({ paraId, text, search? })
comment.reply(text)replyTo(commentId, { text })
comment.resolved = trueresolveComment(commentId)
range.insertText(text, location)proposeChange({ paraId, search, replaceWith }) (three modes via empty-string semantics)
document.getSelection()getSelection() → SelectionInfo | null
range.scrollIntoView()scrollTo(paraId)
commentCollection.getItems()getComments(filter?)
body.paragraphs.getItems()getContent(opts?)
document.body.textgetContentAsText(opts?)
revisionCollection.getItems()getChanges(filter?)
Document.onContentChanged.add(...)onContentChange(listener)
Document.onSelectionChanged.add(...)onSelectionChange(listener)

Intentional differences

  • Tracked changes are always suggestions. The human keeps the final accept/reject.
  • Range.context.sync() is unnecessary. Every call is one PM transaction.
  • Range is a plain { paraId, search? } JSON value, so it survives JSON.stringify and works for tool calls and MCP transports. Office.js Range is stateful and tied to a single RequestContext.

The compile-time contract

WordCompatBridge is exported from the package root. EditorBridge is asserted to satisfy it. Drop or rename a method that's part of the public Word API mirror and tsc fails the build of the package itself.

import type { WordCompatBridge } from '@eigenpal/docx-editor-agents';
import type { EditorBridge } from '@eigenpal/docx-editor-agents/bridge';
 
// Internal to the package; users don't write this themselves:
const _check: WordCompatBridge = {} as EditorBridge;

The contract documents the public surface; the WordCompatBridge JSDoc is the canonical reference for what's mirrored, what's intentionally different, and what's deliberately out of scope (formatting verbs like Range.font.bold, paragraph creation, table mutation, headers/footers, customXmlParts).

Microsoft Word add-in alternative

Teams maintaining a Microsoft Word add-in often want the same review or copilot experience on the web without forcing users into Word. The agent toolkit is the migration path: the verbs match, tracked changes round-trip, and the rendered editor lives in a React app you already deploy.