@eigenpal/docx-js-editor 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/DocumentAgent-Ci6_T-XM.d.ts +412 -0
  2. package/dist/DocumentAgent-DEGFgYEN.d.cts +412 -0
  3. package/dist/FindReplaceDialog-BAACAU67.cjs +1 -0
  4. package/dist/FindReplaceDialog-RWYDRWHF.js +1 -0
  5. package/dist/FootnotePropertiesDialog-BC6JIPDA.cjs +1 -0
  6. package/dist/FootnotePropertiesDialog-CWQF5EBK.js +1 -0
  7. package/dist/HyperlinkDialog-EG2BSLPD.cjs +1 -0
  8. package/dist/HyperlinkDialog-YAVK64F4.js +1 -0
  9. package/dist/ImagePositionDialog-IGYS5KMK.cjs +1 -0
  10. package/dist/ImagePositionDialog-S6SMH7XH.js +1 -0
  11. package/dist/ImagePropertiesDialog-UO5QUIBS.js +1 -0
  12. package/dist/ImagePropertiesDialog-VGV4E4SN.cjs +1 -0
  13. package/dist/TablePropertiesDialog-VBOU4DID.js +1 -0
  14. package/dist/TablePropertiesDialog-WRM47JI6.cjs +1 -0
  15. package/dist/{types-BALm1KBi.d.cts → agentApi-CbVUCZRu.d.cts} +1 -308
  16. package/dist/{types-BALm1KBi.d.ts → agentApi-CbVUCZRu.d.ts} +1 -308
  17. package/dist/chunk-2ASOEN3V.js +1 -0
  18. package/dist/chunk-6MBDPZVD.js +111 -0
  19. package/dist/chunk-6YLNNCRZ.cjs +10 -0
  20. package/dist/chunk-BVQ2QRHA.cjs +4 -0
  21. package/dist/chunk-COP5BIBZ.js +10 -0
  22. package/dist/chunk-CZ7W7MCM.cjs +2 -0
  23. package/dist/chunk-E6XDMUAM.js +4 -0
  24. package/dist/chunk-EMKABJPH.js +1 -0
  25. package/dist/{chunk-TRAQI6RX.cjs → chunk-EPCZ24TY.cjs} +5 -5
  26. package/dist/chunk-ESI4BSBF.js +1 -0
  27. package/dist/chunk-FLECKDK4.cjs +58 -0
  28. package/dist/chunk-ITWEFKGQ.cjs +1 -0
  29. package/dist/chunk-KESNGXGO.js +1 -0
  30. package/dist/chunk-KVAT5SVD.js +2 -0
  31. package/dist/chunk-L34XFLQZ.cjs +1 -0
  32. package/dist/chunk-M7F2CUUD.js +2 -0
  33. package/dist/chunk-MDPDH7KS.js +58 -0
  34. package/dist/chunk-MTX3EEBJ.js +258 -0
  35. package/dist/chunk-NT2REEAA.cjs +1 -0
  36. package/dist/{chunk-PM4Y7OFN.js → chunk-OTG4NABM.js} +5 -5
  37. package/dist/chunk-OW5H5DNE.cjs +1 -0
  38. package/dist/chunk-PJVI53AH.js +2 -0
  39. package/dist/chunk-PNMZPPPI.cjs +2 -0
  40. package/dist/chunk-SF53KLDZ.cjs +1 -0
  41. package/dist/chunk-TOI5W3HK.js +8 -0
  42. package/dist/chunk-UAVOWAIF.cjs +8 -0
  43. package/dist/chunk-VN7XH644.cjs +258 -0
  44. package/dist/chunk-W4DUKACP.cjs +111 -0
  45. package/dist/chunk-XS2AQFMF.cjs +2 -0
  46. package/dist/chunk-ZDYHAYN6.js +1 -0
  47. package/dist/clipboard-BOocwmAM.d.ts +539 -0
  48. package/dist/clipboard-Cx7cb3kX.d.cts +539 -0
  49. package/dist/{colorResolver-BNj-uZ58.d.ts → colorResolver-CIDiSPWd.d.cts} +3 -411
  50. package/dist/{colorResolver-DiMquGWR.d.cts → colorResolver-KXbUgzWC.d.ts} +3 -411
  51. package/dist/core-plugins.cjs +1 -1
  52. package/dist/core-plugins.d.cts +4 -3
  53. package/dist/core-plugins.d.ts +4 -3
  54. package/dist/core-plugins.js +1 -1
  55. package/dist/core.cjs +1 -0
  56. package/dist/core.d.cts +23 -0
  57. package/dist/core.d.ts +23 -0
  58. package/dist/core.js +1 -0
  59. package/dist/headless.cjs +2 -2
  60. package/dist/headless.d.cts +8 -175
  61. package/dist/headless.d.ts +8 -175
  62. package/dist/headless.js +1 -1
  63. package/dist/index.cjs +9 -378
  64. package/dist/index.d.cts +17 -4161
  65. package/dist/index.d.ts +17 -4161
  66. package/dist/index.js +9 -378
  67. package/dist/insertOperations-CzB5b-Of.d.ts +176 -0
  68. package/dist/insertOperations-DKVmCV32.d.cts +176 -0
  69. package/dist/mcp-cli.js +21 -21
  70. package/dist/mcp.cjs +10 -10
  71. package/dist/mcp.d.cts +2 -1
  72. package/dist/mcp.d.ts +2 -1
  73. package/dist/mcp.js +9 -9
  74. package/dist/processTemplate-BHBTDAIC.js +1 -0
  75. package/dist/processTemplate-QOEAXCKA.cjs +1 -0
  76. package/dist/react-Be1YOl4z.d.ts +1356 -0
  77. package/dist/react-DPuSVbgY.d.cts +1356 -0
  78. package/dist/react.cjs +1 -0
  79. package/dist/react.css +1 -0
  80. package/dist/react.d.cts +9 -0
  81. package/dist/react.d.ts +9 -0
  82. package/dist/react.js +1 -0
  83. package/dist/{registry-CzqAPdui.d.ts → registry-D4tvj9f3.d.ts} +1 -1
  84. package/dist/{registry-BUTMLqSj.d.cts → registry-ngv6Bumt.d.cts} +1 -1
  85. package/dist/types-D96elyJF.d.cts +310 -0
  86. package/dist/types-xMzSPT4i.d.ts +310 -0
  87. package/dist/ui.cjs +1 -0
  88. package/dist/ui.d.cts +2103 -0
  89. package/dist/ui.d.ts +2103 -0
  90. package/dist/ui.js +1 -0
  91. package/dist/variableDetector-CPxKo9jP.d.cts +173 -0
  92. package/dist/variableDetector-DeM1N-_L.d.ts +173 -0
  93. package/package.json +85 -10
  94. package/dist/chunk-GQ4JYQWC.js +0 -58
  95. package/dist/chunk-H3JNHCD7.cjs +0 -10
  96. package/dist/chunk-L2UUZRZI.js +0 -10
  97. package/dist/chunk-QOIY4Y6N.cjs +0 -9
  98. package/dist/chunk-QYKJKSKZ.cjs +0 -58
  99. package/dist/chunk-TPUJJJWA.js +0 -9
@@ -2083,311 +2083,4 @@ declare const DEFAULT_AI_ACTIONS: AIAction[];
2083
2083
  */
2084
2084
  declare function createCommand<T extends AgentCommand>(command: Omit<T, 'id'>): T;
2085
2085
 
2086
- /**
2087
- * Core Plugin System Types
2088
- *
2089
- * Defines the interfaces for headless plugins that work in Node.js
2090
- * without React/DOM dependencies. These plugins extend DocumentAgent
2091
- * with additional commands and expose MCP tools for AI integration.
2092
- */
2093
-
2094
- /**
2095
- * Core plugin interface - headless, works in Node.js
2096
- *
2097
- * Plugins can:
2098
- * - Register command handlers that DocumentAgent dispatches to
2099
- * - Declare MCP tools that the MCP server exposes to AI clients
2100
- * - Have optional initialization logic
2101
- * - Declare dependencies on other plugins
2102
- */
2103
- interface CorePlugin {
2104
- /** Unique plugin identifier */
2105
- id: string;
2106
- /** Human-readable plugin name */
2107
- name: string;
2108
- /** Plugin version (semver) */
2109
- version?: string;
2110
- /** Plugin description */
2111
- description?: string;
2112
- /**
2113
- * Command handlers this plugin provides.
2114
- * DocumentAgent dispatches commands to these handlers.
2115
- *
2116
- * @example
2117
- * ```ts
2118
- * commandHandlers: {
2119
- * 'insertTemplateVariable': (doc, cmd) => {
2120
- * // Transform document
2121
- * return modifiedDoc;
2122
- * },
2123
- * }
2124
- * ```
2125
- */
2126
- commandHandlers?: Record<string, CommandHandler>;
2127
- /**
2128
- * MCP tools this plugin exposes.
2129
- * MCP server collects these from all plugins.
2130
- */
2131
- mcpTools?: McpToolDefinition[];
2132
- /**
2133
- * Optional setup when plugin is registered.
2134
- * Called once during plugin registration.
2135
- */
2136
- initialize?: () => void | Promise<void>;
2137
- /**
2138
- * Optional cleanup when plugin is unregistered.
2139
- */
2140
- destroy?: () => void | Promise<void>;
2141
- /**
2142
- * Dependencies on other plugins (by ID).
2143
- * The registry ensures dependencies are loaded first.
2144
- */
2145
- dependencies?: string[];
2146
- }
2147
- /**
2148
- * Command handler function type
2149
- *
2150
- * Receives a document and a command, returns a modified document.
2151
- * Must be pure/immutable - always return a new document.
2152
- */
2153
- type CommandHandler = (doc: Document, command: PluginCommand) => Document;
2154
- /**
2155
- * Extended command type for plugins
2156
- *
2157
- * Plugins can define custom command types beyond the built-in AgentCommand types.
2158
- */
2159
- interface PluginCommand {
2160
- /** Command type identifier */
2161
- type: string;
2162
- /** Unique command ID (for undo tracking) */
2163
- id?: string;
2164
- /** Position for positional commands */
2165
- position?: Position;
2166
- /** Range for range-based commands */
2167
- range?: Range;
2168
- /** Additional command-specific data */
2169
- [key: string]: unknown;
2170
- }
2171
- /**
2172
- * Result of command execution
2173
- */
2174
- interface CommandResult {
2175
- /** The modified document */
2176
- document: Document;
2177
- /** Whether the command succeeded */
2178
- success: boolean;
2179
- /** Error message if failed */
2180
- error?: string;
2181
- /** Metadata about the operation */
2182
- metadata?: Record<string, unknown>;
2183
- }
2184
- /**
2185
- * MCP tool definition
2186
- *
2187
- * Describes a tool that can be called by AI clients through the MCP server.
2188
- */
2189
- interface McpToolDefinition {
2190
- /** Tool name (used in MCP protocol) */
2191
- name: string;
2192
- /** Human-readable description for AI */
2193
- description: string;
2194
- /**
2195
- * JSON Schema for tool input validation.
2196
- * Can be a Zod schema or plain JSON Schema object.
2197
- */
2198
- inputSchema: JsonSchema | ZodSchemaLike;
2199
- /**
2200
- * Handler function for the tool.
2201
- * Receives validated input and returns a result.
2202
- */
2203
- handler: McpToolHandler;
2204
- /**
2205
- * Optional annotations for the tool
2206
- */
2207
- annotations?: McpToolAnnotations;
2208
- }
2209
- /**
2210
- * MCP tool handler function
2211
- */
2212
- type McpToolHandler = (input: unknown, context: McpToolContext) => Promise<McpToolResult> | McpToolResult;
2213
- /**
2214
- * Context passed to MCP tool handlers
2215
- */
2216
- interface McpToolContext {
2217
- /** Current document (if loaded) */
2218
- document?: Document;
2219
- /** Document buffer (if loaded) */
2220
- documentBuffer?: ArrayBuffer;
2221
- /** Session state */
2222
- session: McpSession;
2223
- /** Logger for debugging */
2224
- log: (message: string, data?: unknown) => void;
2225
- }
2226
- /**
2227
- * MCP session state
2228
- *
2229
- * Maintains state across tool calls within a session.
2230
- */
2231
- interface McpSession {
2232
- /** Session ID */
2233
- id: string;
2234
- /** Loaded documents by ID */
2235
- documents: Map<string, LoadedDocument>;
2236
- /** Custom session data */
2237
- data: Map<string, unknown>;
2238
- }
2239
- /**
2240
- * A loaded document in the session
2241
- */
2242
- interface LoadedDocument {
2243
- /** Document ID */
2244
- id: string;
2245
- /** Parsed document */
2246
- document: Document;
2247
- /** Original buffer (for repacking) */
2248
- buffer?: ArrayBuffer;
2249
- /** Source filename or path */
2250
- source?: string;
2251
- /** Last modified timestamp */
2252
- lastModified: number;
2253
- }
2254
- /**
2255
- * MCP tool result
2256
- */
2257
- interface McpToolResult {
2258
- /** Result content */
2259
- content: McpToolContent[];
2260
- /** Whether this is an error result */
2261
- isError?: boolean;
2262
- }
2263
- /**
2264
- * MCP tool content types
2265
- */
2266
- type McpToolContent = {
2267
- type: 'text';
2268
- text: string;
2269
- } | {
2270
- type: 'image';
2271
- data: string;
2272
- mimeType: string;
2273
- } | {
2274
- type: 'resource';
2275
- uri: string;
2276
- mimeType?: string;
2277
- text?: string;
2278
- };
2279
- /**
2280
- * MCP tool annotations
2281
- */
2282
- interface McpToolAnnotations {
2283
- /** Tool category for organization */
2284
- category?: string;
2285
- /** Whether this tool modifies the document */
2286
- readOnly?: boolean;
2287
- /** Estimated cost/complexity */
2288
- complexity?: 'low' | 'medium' | 'high';
2289
- /** Example usage */
2290
- examples?: McpToolExample[];
2291
- }
2292
- /**
2293
- * MCP tool example
2294
- */
2295
- interface McpToolExample {
2296
- /** Example description */
2297
- description: string;
2298
- /** Example input */
2299
- input: unknown;
2300
- /** Expected output description */
2301
- output?: string;
2302
- }
2303
- /**
2304
- * JSON Schema definition (subset)
2305
- */
2306
- interface JsonSchema {
2307
- type?: string | string[];
2308
- properties?: Record<string, JsonSchema>;
2309
- items?: JsonSchema;
2310
- required?: string[];
2311
- description?: string;
2312
- enum?: unknown[];
2313
- default?: unknown;
2314
- minimum?: number;
2315
- maximum?: number;
2316
- minLength?: number;
2317
- maxLength?: number;
2318
- pattern?: string;
2319
- format?: string;
2320
- additionalProperties?: boolean | JsonSchema;
2321
- anyOf?: JsonSchema[];
2322
- oneOf?: JsonSchema[];
2323
- allOf?: JsonSchema[];
2324
- $ref?: string;
2325
- }
2326
- /**
2327
- * Zod-like schema interface for compatibility
2328
- */
2329
- interface ZodSchemaLike {
2330
- _def?: unknown;
2331
- parse?: (data: unknown) => unknown;
2332
- safeParse?: (data: unknown) => {
2333
- success: boolean;
2334
- data?: unknown;
2335
- error?: unknown;
2336
- };
2337
- }
2338
- /**
2339
- * Check if a schema is Zod-like
2340
- */
2341
- declare function isZodSchema(schema: unknown): schema is ZodSchemaLike;
2342
- /**
2343
- * Plugin lifecycle events
2344
- */
2345
- type PluginEvent = {
2346
- type: 'registered';
2347
- plugin: CorePlugin;
2348
- } | {
2349
- type: 'unregistered';
2350
- pluginId: string;
2351
- } | {
2352
- type: 'error';
2353
- pluginId: string;
2354
- error: Error;
2355
- };
2356
- /**
2357
- * Plugin event listener
2358
- */
2359
- type PluginEventListener = (event: PluginEvent) => void;
2360
- /**
2361
- * Extract command type from a union
2362
- */
2363
- type ExtractCommand<T extends AgentCommand, Type extends string> = T extends {
2364
- type: Type;
2365
- } ? T : never;
2366
- /**
2367
- * Create a typed command handler
2368
- */
2369
- type TypedCommandHandler<T extends PluginCommand> = (doc: Document, command: T) => Document;
2370
- /**
2371
- * Plugin configuration options
2372
- */
2373
- interface PluginOptions {
2374
- /** Enable debug logging */
2375
- debug?: boolean;
2376
- /** Custom configuration */
2377
- config?: Record<string, unknown>;
2378
- }
2379
- /**
2380
- * Result of plugin registration
2381
- */
2382
- interface PluginRegistrationResult {
2383
- /** Whether registration succeeded */
2384
- success: boolean;
2385
- /** Registered plugin (if successful) */
2386
- plugin?: CorePlugin;
2387
- /** Error message (if failed) */
2388
- error?: string;
2389
- /** Warning messages */
2390
- warnings?: string[];
2391
- }
2392
-
2393
- export { type RunContent as $, type AIAction as A, type BlockContent as B, type CorePlugin as C, type DocumentBody as D, type Endnote as E, type Footnote as F, type McpToolContent as G, type Hyperlink as H, type Image as I, type JsonSchema as J, type McpToolContext as K, type ListLevel as L, type McpToolDefinition as M, type McpToolHandler as N, type McpToolResult as O, type PluginOptions as P, type NumberingDefinitions as Q, type Run as R, type ParagraphContext as S, type TextFormatting as T, type ParagraphFormatting as U, type ParagraphOutline as V, type PluginCommand as W, type PluginEvent as X, type Range as Y, type Relationship as Z, type ReplaceTextCommand as _, type PluginRegistrationResult as a, type SectionInfo as a0, type SectionProperties as a1, type SelectionContext as a2, type SetVariableCommand as a3, type Style as a4, type StyleDefinitions as a5, type StyleInfo as a6, type SuggestedAction as a7, type TableCell as a8, type TableRow as a9, type ThemeColorScheme as aA, type ThemeFont as aB, type ThemeFontScheme as aC, type ExtractCommand as aD, type McpToolExample as aE, type TypedCommandHandler as aF, type TextContent as aa, type Theme as ab, type ZodSchemaLike as ac, comparePositions as ad, createCollapsedRange as ae, createCommand as af, createRange as ag, getActionDescription as ah, getActionLabel as ai, isPositionInRange as aj, isZodSchema as ak, type ColorValue as al, type ThemeColorSlot as am, type ParagraphAlignment as an, type StyleType as ao, type TabStop as ap, type ShadingProperties as aq, type BreakContent as ar, type BookmarkEnd as as, type BookmarkStart as at, type Field as au, type FooterReference as av, type HeaderFooter as aw, type HeaderReference as ax, type Shape as ay, type TextBox as az, type CommandHandler as b, type PluginEventListener as c, type McpSession as d, type Paragraph as e, type Table as f, type Position as g, type Document as h, type AIActionRequest as i, type AgentCommand as j, type AgentContext as k, type AgentResponse as l, type ApplyStyleCommand as m, type ApplyVariablesCommand as n, type CommandResult as o, DEFAULT_AI_ACTIONS as p, type DeleteTextCommand as q, type DocxPackage as r, type FormatParagraphCommand as s, type FormatTextCommand as t, type InsertHyperlinkCommand as u, type InsertImageCommand as v, type InsertTableCommand as w, type InsertTextCommand as x, type LoadedDocument as y, type McpToolAnnotations as z };
2086
+ export { type ThemeFontScheme as $, type AIAction as A, type BlockContent as B, type SelectionContext as C, type DeleteTextCommand as D, type Endnote as E, type Field as F, type SetVariableCommand as G, type HeaderFooter as H, type Image as I, type Shape as J, type Style as K, type ListLevel as L, type StyleDefinitions as M, type NumberingDefinitions as N, type SuggestedAction as O, type Paragraph as P, type TableCell as Q, type Range as R, type SectionProperties as S, type Table as T, type TableRow as U, type TextBox as V, type TextContent as W, type TextFormatting as X, type Theme as Y, type ThemeColorScheme as Z, type ThemeFont as _, type AIActionRequest as a, type ApplyVariablesCommand as a0, DEFAULT_AI_ACTIONS as a1, type FormatParagraphCommand as a2, type ParagraphOutline as a3, type SectionInfo as a4, type StyleInfo as a5, comparePositions as a6, createCollapsedRange as a7, createCommand as a8, createRange as a9, getActionDescription as aa, getActionLabel as ab, isPositionInRange as ac, type BreakContent as ad, type ColorValue as ae, type ThemeColorSlot as af, type ParagraphAlignment as ag, type StyleType as ah, type TabStop as ai, type ShadingProperties as aj, type AgentCommand as b, type AgentContext as c, type AgentResponse as d, type ApplyStyleCommand as e, type BookmarkEnd as f, type BookmarkStart as g, type Document as h, type DocumentBody as i, type DocxPackage as j, type FooterReference as k, type Footnote as l, type FormatTextCommand as m, type HeaderReference as n, type Hyperlink as o, type InsertHyperlinkCommand as p, type InsertImageCommand as q, type InsertTableCommand as r, type InsertTextCommand as s, type ParagraphContext as t, type ParagraphFormatting as u, type Position as v, type Relationship as w, type ReplaceTextCommand as x, type Run as y, type RunContent as z };
@@ -2083,311 +2083,4 @@ declare const DEFAULT_AI_ACTIONS: AIAction[];
2083
2083
  */
2084
2084
  declare function createCommand<T extends AgentCommand>(command: Omit<T, 'id'>): T;
2085
2085
 
2086
- /**
2087
- * Core Plugin System Types
2088
- *
2089
- * Defines the interfaces for headless plugins that work in Node.js
2090
- * without React/DOM dependencies. These plugins extend DocumentAgent
2091
- * with additional commands and expose MCP tools for AI integration.
2092
- */
2093
-
2094
- /**
2095
- * Core plugin interface - headless, works in Node.js
2096
- *
2097
- * Plugins can:
2098
- * - Register command handlers that DocumentAgent dispatches to
2099
- * - Declare MCP tools that the MCP server exposes to AI clients
2100
- * - Have optional initialization logic
2101
- * - Declare dependencies on other plugins
2102
- */
2103
- interface CorePlugin {
2104
- /** Unique plugin identifier */
2105
- id: string;
2106
- /** Human-readable plugin name */
2107
- name: string;
2108
- /** Plugin version (semver) */
2109
- version?: string;
2110
- /** Plugin description */
2111
- description?: string;
2112
- /**
2113
- * Command handlers this plugin provides.
2114
- * DocumentAgent dispatches commands to these handlers.
2115
- *
2116
- * @example
2117
- * ```ts
2118
- * commandHandlers: {
2119
- * 'insertTemplateVariable': (doc, cmd) => {
2120
- * // Transform document
2121
- * return modifiedDoc;
2122
- * },
2123
- * }
2124
- * ```
2125
- */
2126
- commandHandlers?: Record<string, CommandHandler>;
2127
- /**
2128
- * MCP tools this plugin exposes.
2129
- * MCP server collects these from all plugins.
2130
- */
2131
- mcpTools?: McpToolDefinition[];
2132
- /**
2133
- * Optional setup when plugin is registered.
2134
- * Called once during plugin registration.
2135
- */
2136
- initialize?: () => void | Promise<void>;
2137
- /**
2138
- * Optional cleanup when plugin is unregistered.
2139
- */
2140
- destroy?: () => void | Promise<void>;
2141
- /**
2142
- * Dependencies on other plugins (by ID).
2143
- * The registry ensures dependencies are loaded first.
2144
- */
2145
- dependencies?: string[];
2146
- }
2147
- /**
2148
- * Command handler function type
2149
- *
2150
- * Receives a document and a command, returns a modified document.
2151
- * Must be pure/immutable - always return a new document.
2152
- */
2153
- type CommandHandler = (doc: Document, command: PluginCommand) => Document;
2154
- /**
2155
- * Extended command type for plugins
2156
- *
2157
- * Plugins can define custom command types beyond the built-in AgentCommand types.
2158
- */
2159
- interface PluginCommand {
2160
- /** Command type identifier */
2161
- type: string;
2162
- /** Unique command ID (for undo tracking) */
2163
- id?: string;
2164
- /** Position for positional commands */
2165
- position?: Position;
2166
- /** Range for range-based commands */
2167
- range?: Range;
2168
- /** Additional command-specific data */
2169
- [key: string]: unknown;
2170
- }
2171
- /**
2172
- * Result of command execution
2173
- */
2174
- interface CommandResult {
2175
- /** The modified document */
2176
- document: Document;
2177
- /** Whether the command succeeded */
2178
- success: boolean;
2179
- /** Error message if failed */
2180
- error?: string;
2181
- /** Metadata about the operation */
2182
- metadata?: Record<string, unknown>;
2183
- }
2184
- /**
2185
- * MCP tool definition
2186
- *
2187
- * Describes a tool that can be called by AI clients through the MCP server.
2188
- */
2189
- interface McpToolDefinition {
2190
- /** Tool name (used in MCP protocol) */
2191
- name: string;
2192
- /** Human-readable description for AI */
2193
- description: string;
2194
- /**
2195
- * JSON Schema for tool input validation.
2196
- * Can be a Zod schema or plain JSON Schema object.
2197
- */
2198
- inputSchema: JsonSchema | ZodSchemaLike;
2199
- /**
2200
- * Handler function for the tool.
2201
- * Receives validated input and returns a result.
2202
- */
2203
- handler: McpToolHandler;
2204
- /**
2205
- * Optional annotations for the tool
2206
- */
2207
- annotations?: McpToolAnnotations;
2208
- }
2209
- /**
2210
- * MCP tool handler function
2211
- */
2212
- type McpToolHandler = (input: unknown, context: McpToolContext) => Promise<McpToolResult> | McpToolResult;
2213
- /**
2214
- * Context passed to MCP tool handlers
2215
- */
2216
- interface McpToolContext {
2217
- /** Current document (if loaded) */
2218
- document?: Document;
2219
- /** Document buffer (if loaded) */
2220
- documentBuffer?: ArrayBuffer;
2221
- /** Session state */
2222
- session: McpSession;
2223
- /** Logger for debugging */
2224
- log: (message: string, data?: unknown) => void;
2225
- }
2226
- /**
2227
- * MCP session state
2228
- *
2229
- * Maintains state across tool calls within a session.
2230
- */
2231
- interface McpSession {
2232
- /** Session ID */
2233
- id: string;
2234
- /** Loaded documents by ID */
2235
- documents: Map<string, LoadedDocument>;
2236
- /** Custom session data */
2237
- data: Map<string, unknown>;
2238
- }
2239
- /**
2240
- * A loaded document in the session
2241
- */
2242
- interface LoadedDocument {
2243
- /** Document ID */
2244
- id: string;
2245
- /** Parsed document */
2246
- document: Document;
2247
- /** Original buffer (for repacking) */
2248
- buffer?: ArrayBuffer;
2249
- /** Source filename or path */
2250
- source?: string;
2251
- /** Last modified timestamp */
2252
- lastModified: number;
2253
- }
2254
- /**
2255
- * MCP tool result
2256
- */
2257
- interface McpToolResult {
2258
- /** Result content */
2259
- content: McpToolContent[];
2260
- /** Whether this is an error result */
2261
- isError?: boolean;
2262
- }
2263
- /**
2264
- * MCP tool content types
2265
- */
2266
- type McpToolContent = {
2267
- type: 'text';
2268
- text: string;
2269
- } | {
2270
- type: 'image';
2271
- data: string;
2272
- mimeType: string;
2273
- } | {
2274
- type: 'resource';
2275
- uri: string;
2276
- mimeType?: string;
2277
- text?: string;
2278
- };
2279
- /**
2280
- * MCP tool annotations
2281
- */
2282
- interface McpToolAnnotations {
2283
- /** Tool category for organization */
2284
- category?: string;
2285
- /** Whether this tool modifies the document */
2286
- readOnly?: boolean;
2287
- /** Estimated cost/complexity */
2288
- complexity?: 'low' | 'medium' | 'high';
2289
- /** Example usage */
2290
- examples?: McpToolExample[];
2291
- }
2292
- /**
2293
- * MCP tool example
2294
- */
2295
- interface McpToolExample {
2296
- /** Example description */
2297
- description: string;
2298
- /** Example input */
2299
- input: unknown;
2300
- /** Expected output description */
2301
- output?: string;
2302
- }
2303
- /**
2304
- * JSON Schema definition (subset)
2305
- */
2306
- interface JsonSchema {
2307
- type?: string | string[];
2308
- properties?: Record<string, JsonSchema>;
2309
- items?: JsonSchema;
2310
- required?: string[];
2311
- description?: string;
2312
- enum?: unknown[];
2313
- default?: unknown;
2314
- minimum?: number;
2315
- maximum?: number;
2316
- minLength?: number;
2317
- maxLength?: number;
2318
- pattern?: string;
2319
- format?: string;
2320
- additionalProperties?: boolean | JsonSchema;
2321
- anyOf?: JsonSchema[];
2322
- oneOf?: JsonSchema[];
2323
- allOf?: JsonSchema[];
2324
- $ref?: string;
2325
- }
2326
- /**
2327
- * Zod-like schema interface for compatibility
2328
- */
2329
- interface ZodSchemaLike {
2330
- _def?: unknown;
2331
- parse?: (data: unknown) => unknown;
2332
- safeParse?: (data: unknown) => {
2333
- success: boolean;
2334
- data?: unknown;
2335
- error?: unknown;
2336
- };
2337
- }
2338
- /**
2339
- * Check if a schema is Zod-like
2340
- */
2341
- declare function isZodSchema(schema: unknown): schema is ZodSchemaLike;
2342
- /**
2343
- * Plugin lifecycle events
2344
- */
2345
- type PluginEvent = {
2346
- type: 'registered';
2347
- plugin: CorePlugin;
2348
- } | {
2349
- type: 'unregistered';
2350
- pluginId: string;
2351
- } | {
2352
- type: 'error';
2353
- pluginId: string;
2354
- error: Error;
2355
- };
2356
- /**
2357
- * Plugin event listener
2358
- */
2359
- type PluginEventListener = (event: PluginEvent) => void;
2360
- /**
2361
- * Extract command type from a union
2362
- */
2363
- type ExtractCommand<T extends AgentCommand, Type extends string> = T extends {
2364
- type: Type;
2365
- } ? T : never;
2366
- /**
2367
- * Create a typed command handler
2368
- */
2369
- type TypedCommandHandler<T extends PluginCommand> = (doc: Document, command: T) => Document;
2370
- /**
2371
- * Plugin configuration options
2372
- */
2373
- interface PluginOptions {
2374
- /** Enable debug logging */
2375
- debug?: boolean;
2376
- /** Custom configuration */
2377
- config?: Record<string, unknown>;
2378
- }
2379
- /**
2380
- * Result of plugin registration
2381
- */
2382
- interface PluginRegistrationResult {
2383
- /** Whether registration succeeded */
2384
- success: boolean;
2385
- /** Registered plugin (if successful) */
2386
- plugin?: CorePlugin;
2387
- /** Error message (if failed) */
2388
- error?: string;
2389
- /** Warning messages */
2390
- warnings?: string[];
2391
- }
2392
-
2393
- export { type RunContent as $, type AIAction as A, type BlockContent as B, type CorePlugin as C, type DocumentBody as D, type Endnote as E, type Footnote as F, type McpToolContent as G, type Hyperlink as H, type Image as I, type JsonSchema as J, type McpToolContext as K, type ListLevel as L, type McpToolDefinition as M, type McpToolHandler as N, type McpToolResult as O, type PluginOptions as P, type NumberingDefinitions as Q, type Run as R, type ParagraphContext as S, type TextFormatting as T, type ParagraphFormatting as U, type ParagraphOutline as V, type PluginCommand as W, type PluginEvent as X, type Range as Y, type Relationship as Z, type ReplaceTextCommand as _, type PluginRegistrationResult as a, type SectionInfo as a0, type SectionProperties as a1, type SelectionContext as a2, type SetVariableCommand as a3, type Style as a4, type StyleDefinitions as a5, type StyleInfo as a6, type SuggestedAction as a7, type TableCell as a8, type TableRow as a9, type ThemeColorScheme as aA, type ThemeFont as aB, type ThemeFontScheme as aC, type ExtractCommand as aD, type McpToolExample as aE, type TypedCommandHandler as aF, type TextContent as aa, type Theme as ab, type ZodSchemaLike as ac, comparePositions as ad, createCollapsedRange as ae, createCommand as af, createRange as ag, getActionDescription as ah, getActionLabel as ai, isPositionInRange as aj, isZodSchema as ak, type ColorValue as al, type ThemeColorSlot as am, type ParagraphAlignment as an, type StyleType as ao, type TabStop as ap, type ShadingProperties as aq, type BreakContent as ar, type BookmarkEnd as as, type BookmarkStart as at, type Field as au, type FooterReference as av, type HeaderFooter as aw, type HeaderReference as ax, type Shape as ay, type TextBox as az, type CommandHandler as b, type PluginEventListener as c, type McpSession as d, type Paragraph as e, type Table as f, type Position as g, type Document as h, type AIActionRequest as i, type AgentCommand as j, type AgentContext as k, type AgentResponse as l, type ApplyStyleCommand as m, type ApplyVariablesCommand as n, type CommandResult as o, DEFAULT_AI_ACTIONS as p, type DeleteTextCommand as q, type DocxPackage as r, type FormatParagraphCommand as s, type FormatTextCommand as t, type InsertHyperlinkCommand as u, type InsertImageCommand as v, type InsertTableCommand as w, type InsertTextCommand as x, type LoadedDocument as y, type McpToolAnnotations as z };
2086
+ export { type ThemeFontScheme as $, type AIAction as A, type BlockContent as B, type SelectionContext as C, type DeleteTextCommand as D, type Endnote as E, type Field as F, type SetVariableCommand as G, type HeaderFooter as H, type Image as I, type Shape as J, type Style as K, type ListLevel as L, type StyleDefinitions as M, type NumberingDefinitions as N, type SuggestedAction as O, type Paragraph as P, type TableCell as Q, type Range as R, type SectionProperties as S, type Table as T, type TableRow as U, type TextBox as V, type TextContent as W, type TextFormatting as X, type Theme as Y, type ThemeColorScheme as Z, type ThemeFont as _, type AIActionRequest as a, type ApplyVariablesCommand as a0, DEFAULT_AI_ACTIONS as a1, type FormatParagraphCommand as a2, type ParagraphOutline as a3, type SectionInfo as a4, type StyleInfo as a5, comparePositions as a6, createCollapsedRange as a7, createCommand as a8, createRange as a9, getActionDescription as aa, getActionLabel as ab, isPositionInRange as ac, type BreakContent as ad, type ColorValue as ae, type ThemeColorSlot as af, type ParagraphAlignment as ag, type StyleType as ah, type TabStop as ai, type ShadingProperties as aj, type AgentCommand as b, type AgentContext as c, type AgentResponse as d, type ApplyStyleCommand as e, type BookmarkEnd as f, type BookmarkStart as g, type Document as h, type DocumentBody as i, type DocxPackage as j, type FooterReference as k, type Footnote as l, type FormatTextCommand as m, type HeaderReference as n, type Hyperlink as o, type InsertHyperlinkCommand as p, type InsertImageCommand as q, type InsertTableCommand as r, type InsertTextCommand as s, type ParagraphContext as t, type ParagraphFormatting as u, type Position as v, type Relationship as w, type ReplaceTextCommand as x, type Run as y, type RunContent as z };
@@ -0,0 +1 @@
1
+ function b(e){return h(e).variables}function h(e){let t=[],r={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let n=d(e.package.document);n.forEach(s=>{t.push({name:s,location:"body"});}),r.body=Array.from(new Set(n)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((n,s)=>{n.properties.headerReferences&&n.properties.headerReferences.forEach(R=>{});}),e.package?.footnotes){let n=u(e.package.footnotes);n.forEach(s=>{t.push({name:s,location:"footnote"});}),r.footnotes=Array.from(new Set(n)).sort();}if(e.package?.endnotes){let n=u(e.package.endnotes);n.forEach(s=>{t.push({name:s,location:"endnote"});}),r.endnotes=Array.from(new Set(n)).sort();}e.templateVariables&&e.templateVariables.forEach(n=>{t.some(s=>s.name===n)||t.push({name:n,location:"body"});});let o=new Set;return t.forEach(n=>o.add(n.name)),{variables:Array.from(o).sort(),totalOccurrences:t.length,byLocation:r,occurrences:t}}function d(e){let t=[];if(e.content&&t.push(...c(e.content)),e.sections)for(let r of e.sections)r.content&&t.push(...c(r.content));return t}function c(e){let t=[];for(let r of e)r.type==="paragraph"?t.push(...a(r)):r.type==="table"&&t.push(...l(r));return t}function a(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="run"?t.push(...i(r)):r.type==="hyperlink"?t.push(...m(r)):r.type==="simpleField"?t.push(...x(r)):r.type==="complexField"&&t.push(...V(r));return t}function i(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="text"&&r.text&&t.push(...g(r.text));return t}function m(e){let t=[];if(!e.children)return t;for(let r of e.children)r.type==="run"&&t.push(...i(r));return t}function x(e){let t=[];if(e.instruction&&t.push(...g(e.instruction)),e.content)for(let r of e.content)r.type==="run"&&t.push(...i(r));return t}function V(e){let t=[];if(e.fieldCode)for(let r of e.fieldCode)r.type==="run"&&t.push(...i(r));if(e.fieldResult)for(let r of e.fieldResult)r.type==="run"&&t.push(...i(r));return t}function l(e){let t=[];if(!e.rows)return t;for(let r of e.rows)if(r.cells)for(let o of r.cells)t.push(...y(o));return t}function y(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="paragraph"?t.push(...a(r)):r.type==="table"&&t.push(...l(r));return t}function u(e){let t=[];for(let r of e)if(r.content)for(let o of r.content)t.push(...a(o));return t}var f=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,p=/\{(.+?)\}/g;function g(e){if(!e)return [];let t=[],r=new RegExp(f),o;for(;(o=r.exec(e))!==null;)t.push(o[1]);return t}function A(e){return f.test(e)}function E(e){return !(!e||typeof e!="string"||e.length===0||e.length>100||!/^[a-zA-Z_]/.test(e)||!/^[a-zA-Z_][a-zA-Z0-9_\-\.]*$/.test(e))}function v(e){if(!e)return "";let t=e.replace(/\s+/g,"_");return t=t.replace(/[^a-zA-Z0-9_\-\.]/g,""),t&&!/^[a-zA-Z_]/.test(t)&&(t="_"+t),t.substring(0,100)}function k(e){return `{${e}}`}function I(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function F(e,t){return e&&e.replace(p,(r,o)=>{let n=o.trim();return n in t?t[n]:r})}function T(e,t=""){return e&&e.replace(p,t)}function _(e){return b(e).length>0}export{b as a,h as b,d as c,a as d,g as e,A as f,E as g,v as h,k as i,I as j,F as k,T as l,_ as m};