@reviseio/engine 0.0.0-stage → 3.0.0

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 (77) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
  3. package/FONT-LICENSE-KATEX.txt +95 -0
  4. package/FONT-LICENSE-LIBERATION.txt +102 -0
  5. package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
  6. package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
  7. package/FONT-LICENSE-NOTO.txt +94 -0
  8. package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
  9. package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
  10. package/LICENSE +141 -0
  11. package/README.md +11 -2
  12. package/THIRD-PARTY-NOTICES.md +3376 -0
  13. package/assets/historyMaterializeWorker-Kl0syEbc.js +618 -0
  14. package/chunks/AgentHtmlConverter-BnK7NaYA.js +379 -0
  15. package/chunks/AgentPageRenderViews-BTLjPZJQ.js +2 -0
  16. package/chunks/AgentPageRenderer-DLwq6nAa.js +180 -0
  17. package/chunks/BidiText-Bkp4Y90s.js +160 -0
  18. package/chunks/BlockDiff-BdlcKY-t.js +42 -0
  19. package/chunks/CanvasRenderer-Bqsj1S0p.js +110 -0
  20. package/chunks/ColorParserFull-BKH72fK8.js +446 -0
  21. package/chunks/DocumentCompare-BqyiP87r.js +6 -0
  22. package/chunks/DocumentLayout-CsU5MR-3.js +12 -0
  23. package/chunks/DocumentLayoutEngine-7iOYvyVb.js +218 -0
  24. package/chunks/DocumentMutator-DIrZBuLr.js +13 -0
  25. package/chunks/DocumentScrubber-Cz8Q05hF.js +21 -0
  26. package/chunks/DocumentSession-lXSXqua5.js +1 -0
  27. package/chunks/DocumentStylesheet-CEEt18sr.js +7 -0
  28. package/chunks/DocxConverter-BfDw7777.js +1236 -0
  29. package/chunks/DocxGraft-D0uCnGCo.js +8 -0
  30. package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -0
  31. package/chunks/HtmlConverter-7Xj_g9Jr.js +267 -0
  32. package/chunks/ListNumbering-Qlu6AuRZ.js +23 -0
  33. package/chunks/MarkdownConverter-cnW_oePY.js +57 -0
  34. package/chunks/MathRenderer-Bz9WEVvF.js +68 -0
  35. package/chunks/OdtConverter-GwRDMnwS.js +125 -0
  36. package/chunks/OfficeImportShared-nlMtIUni.js +30 -0
  37. package/chunks/PageNumeralFonts-BWzI061X.js +5 -0
  38. package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
  39. package/chunks/PdfConverter-yOlWiVIj.js +457 -0
  40. package/chunks/RtfConverter--wLd0qrw.js +186 -0
  41. package/chunks/TableBorders-C5pNsuxP.js +32 -0
  42. package/chunks/TableGrid-DbroRucl.js +12 -0
  43. package/chunks/TextFileDecoder--rsVs3NR.js +9 -0
  44. package/chunks/TxtConverter-BoRVCDZw.js +14 -0
  45. package/chunks/Typography-DAGM5kfI.js +28 -0
  46. package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
  47. package/chunks/XmlConverter-CO8Z28dX.js +55 -0
  48. package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -0
  49. package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -0
  50. package/chunks/base64-Di1bxoXD.js +1 -0
  51. package/chunks/browser-module-CFmqfGkE.js +1791 -0
  52. package/chunks/bundle.min-DRpfgV69.js +782 -0
  53. package/chunks/capture-Dtinb4bY.js +11 -0
  54. package/chunks/carrier-RNy67HN4.js +6 -0
  55. package/chunks/chromeImageLayout-bgHYmqTp.js +18 -0
  56. package/chunks/engine-TnK8N-gT.js +520 -0
  57. package/chunks/footnoteFlatten-BcKaWzVs.js +6 -0
  58. package/chunks/graftExport-DxAALMHp.js +104 -0
  59. package/chunks/html2canvas.esm-CntiHiYW.js +997 -0
  60. package/chunks/index-BWdRWxoH.js +1807 -0
  61. package/chunks/index-CTti7wRd.js +1002 -0
  62. package/chunks/index.es-CI0QPo8w.js +780 -0
  63. package/chunks/jspdf.es.min-DU74zN8b.js +1792 -0
  64. package/chunks/jszip.min-CPW0h1Kx.js +476 -0
  65. package/chunks/katex-DWj8TvwO.js +1462 -0
  66. package/chunks/pdf-BLWDCiFF.js +1828 -0
  67. package/chunks/purify.es-BwLardii.js +107 -0
  68. package/chunks/serverDocumentSession-BmYdjC6e.js +1011 -0
  69. package/chunks/signatures-CU2LMLBp.js +21 -0
  70. package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
  71. package/chunks/web-tree-sitter-BXGZGnNj.js +2 -0
  72. package/chunks/xmlScan-DXjt2cTS.js +8 -0
  73. package/engine.d.ts +179 -0
  74. package/engine.js +3 -0
  75. package/package.json +64 -4
  76. package/serverToolContract.d.ts +420 -0
  77. package/serverToolInputs.generated.d.ts +264 -0
@@ -0,0 +1,420 @@
1
+ /**
2
+ * The canonical tool contract, shared by both surfaces. The `Server` prefix
3
+ * marks the headless origin of these types, but since 1.0.0 the browser
4
+ * surface (`editor.tools`) speaks exactly the same envelope: `execute()`
5
+ * returns the same discriminated `ReviseToolResult`, `call()` throws the same
6
+ * `ReviseToolError`, and inputs are typed by the same generated map. Hosts
7
+ * can share result-handling code between web and Node verbatim.
8
+ */
9
+ import type {
10
+ ReviseJsonObject,
11
+ ReviseJsonValue,
12
+ ReviseToolInput,
13
+ ReviseToolName,
14
+ } from "./serverToolInputs.generated.js";
15
+
16
+ export type {
17
+ ReviseJsonObject,
18
+ ReviseJsonPrimitive,
19
+ ReviseJsonValue,
20
+ ReviseToolInput,
21
+ ReviseToolInputMap,
22
+ ReviseToolName,
23
+ } from "./serverToolInputs.generated.js";
24
+
25
+ export type ServerDocumentMode = "editing" | "suggesting";
26
+
27
+ export interface ServerDocumentSessionOptions {
28
+ documentId: string;
29
+ /**
30
+ * Initial mode; the session's mode methods can change it later. Defaults to
31
+ * "suggesting" — the same posture as the browser surface, and the safe one:
32
+ * a service proposes tracked changes unless it explicitly opts into
33
+ * applying edits directly.
34
+ */
35
+ mode?: ServerDocumentMode;
36
+ searchPageSize?: number;
37
+ /**
38
+ * Author name stamped on the suggestions and comments this session's tools
39
+ * create ("Claude", "Contracts bot"). It becomes `w:author` on DOCX
40
+ * revisions. Defaults to "Revise Agent".
41
+ */
42
+ agentName?: string;
43
+ /** How images inserted by URL are fetched (headless sessions embed them
44
+ * in the document; nothing goes through Revise). */
45
+ images?: ImageFetchPolicy;
46
+ }
47
+
48
+ /**
49
+ * Network policy for images an agent inserts by URL. Agent input decides the
50
+ * URL, so by default only public http(s) hosts are reachable: loopback,
51
+ * private, and link-local addresses are refused, every redirect is checked
52
+ * the same way, and the download is capped while it streams.
53
+ */
54
+ export interface ImageFetchPolicy {
55
+ /** Allow loopback, private, and link-local addresses (the CLI does: it
56
+ * runs on the user's own machine, for the user). Default false. */
57
+ allowPrivateNetwork?: boolean;
58
+ /** Largest image accepted, in bytes. Default 20 MB. */
59
+ maxBytes?: number;
60
+ /** Replace the download entirely (a proxy, a cache, an allow-list). */
61
+ fetch?: (url: string, init: { signal: AbortSignal }) => Promise<Response>;
62
+ }
63
+
64
+ export interface ReviseToolCallOptions {
65
+ /** Apply this mutation directly, even when the session is suggesting. */
66
+ directMode?: boolean;
67
+ }
68
+
69
+ /** Discriminant of a pending tracked-suggestion record. */
70
+ export type ReviseSuggestionType =
71
+ | "inline-text"
72
+ | "inline-format"
73
+ | "block-change"
74
+ | "block-insert"
75
+ | "block-delete"
76
+ | "table-change"
77
+ | "paragraph-split"
78
+ | "paragraph-merge";
79
+
80
+ /**
81
+ * One pending tracked-suggestion record, projected for host review flows.
82
+ * Metadata fields are absent when the underlying record predates uniform
83
+ * authorship stamping or was written by an older client.
84
+ */
85
+ export interface ReviseSuggestionRecord {
86
+ id: string;
87
+ /** Absent when only stamped content marks carry the suggestion, which is
88
+ * the norm for inline text edits and for restored documents. */
89
+ type?: ReviseSuggestionType;
90
+ /** The top-level block the suggestion targets, for block-scoped types. */
91
+ blockId?: string;
92
+ /** The table the suggestion targets, for table-change records. */
93
+ tableId?: string;
94
+ authorType?: "ai" | "human";
95
+ /** Author display name: an agent name or a human's display name. */
96
+ agentName?: string;
97
+ /** Provider-qualified model that authored an AI suggestion. */
98
+ agentModel?: string;
99
+ source?: string;
100
+ label?: string;
101
+ createdAt?: number;
102
+ }
103
+
104
+ /**
105
+ * Per-ID outcome of an accept or reject call. IDs a host persisted from an
106
+ * earlier tool result can go stale — a later suggestion can supersede an
107
+ * earlier one — so the settled and unknown sets are reported explicitly
108
+ * instead of an inferred count.
109
+ */
110
+ export interface ReviseSuggestionDecision {
111
+ /** Requested IDs that were pending and are now settled. */
112
+ resolved: string[];
113
+ /** Requested IDs that were not pending suggestions when the call ran. */
114
+ missing: string[];
115
+ /** Requested IDs that were pending but could not be settled. Rare. */
116
+ unresolved: string[];
117
+ }
118
+
119
+ export interface ReviseToolDefinition<
120
+ Name extends ReviseToolName = ReviseToolName,
121
+ > {
122
+ name: Name;
123
+ description: string;
124
+ inputSchema: ReviseJsonObject;
125
+ }
126
+
127
+ export interface ReviseReadCoverage {
128
+ requestedBlockCount: number;
129
+ readBlocksThisTurn: number;
130
+ readTokenBudgetMax: number;
131
+ requestedRanges: Array<{ start: number; end: number }>;
132
+ fullDocumentLoaded: boolean;
133
+ }
134
+
135
+ export interface ReviseReadData {
136
+ kind: "read_context";
137
+ tool: "read_blocks_from_index" | "read_specific_blocks";
138
+ loaded: ReviseJsonObject;
139
+ next: { index: number; blockId?: string } | null;
140
+ endOfDocument: boolean;
141
+ coverage: ReviseReadCoverage;
142
+ }
143
+
144
+ export interface ReviseSearchMatch {
145
+ blockId: string;
146
+ blockIndex: number;
147
+ matchedQueries?: string[];
148
+ matchedColors?: string[];
149
+ }
150
+
151
+ export interface ReviseSearchData {
152
+ kind: "search_context";
153
+ tool: "search_document" | "find_highlights";
154
+ queries?: string[];
155
+ color?: string;
156
+ totalMatches: number;
157
+ search_result_id?: string;
158
+ page: {
159
+ current: number;
160
+ total: number;
161
+ startResult: number;
162
+ endResult: number;
163
+ };
164
+ nextPage: number | null;
165
+ matches: ReviseSearchMatch[];
166
+ coverage: ReviseReadCoverage;
167
+ }
168
+
169
+ export interface ReviseDocumentMeasurementSection {
170
+ startIndex: number;
171
+ endIndex: number;
172
+ startBlockId: string;
173
+ endBlockId: string;
174
+ headingLevel: 1 | 2 | 3;
175
+ title: string;
176
+ wordCount: number;
177
+ paragraphCount: number;
178
+ characterCount: number;
179
+ inclusive: true;
180
+ blockCount: number;
181
+ pageStart?: number;
182
+ pageEnd?: number;
183
+ }
184
+
185
+ export interface ReviseDocumentMeasurementData {
186
+ kind: "document_measurement";
187
+ tool: "measure_document";
188
+ inclusive: true;
189
+ totalBlocks: number;
190
+ wordCount: number;
191
+ paragraphCount: number;
192
+ characterCount: number;
193
+ pageCount?: number;
194
+ fractionalPageCount?: number;
195
+ sections?: ReviseDocumentMeasurementSection[];
196
+ sectionCount?: number;
197
+ sectionOffset?: number;
198
+ sectionLimit?: number;
199
+ returnedSectionCount?: number;
200
+ hasMoreSections?: boolean;
201
+ nextSectionOffset?: number;
202
+ }
203
+
204
+ export interface ReviseMeasuredBlockRange {
205
+ startIndex: number;
206
+ endIndex: number;
207
+ startBlockId: string;
208
+ endBlockId: string;
209
+ inclusive: true;
210
+ blockCount: number;
211
+ wordCount: number;
212
+ paragraphCount: number;
213
+ characterCount: number;
214
+ pageStart?: number;
215
+ pageEnd?: number;
216
+ }
217
+
218
+ export interface ReviseBlockMeasurementData {
219
+ kind: "document_measurement";
220
+ tool: "measure_blocks";
221
+ inclusive: true;
222
+ totalBlocks: number;
223
+ ranges: ReviseMeasuredBlockRange[];
224
+ errors: Array<{
225
+ startBlockId?: string;
226
+ endBlockId?: string;
227
+ error: string;
228
+ }>;
229
+ }
230
+
231
+ export interface ReviseMutationData {
232
+ tool: string;
233
+ target_reference?: string;
234
+ summary?: string;
235
+ effect: {
236
+ requested_target_count: number;
237
+ changed_target_count: number;
238
+ removed_target_count: number;
239
+ inserted_block_count: number;
240
+ top_level_blocks_before: number;
241
+ top_level_blocks_after: number;
242
+ [key: string]: ReviseJsonValue;
243
+ };
244
+ before_block?: string;
245
+ }
246
+
247
+ export interface ReviseCommentData {
248
+ commentId: string;
249
+ /** The block the comment is anchored to. */
250
+ blockId: string;
251
+ /** Set when the requested block did not hold the anchor text and the
252
+ * comment went to the only read block that did. */
253
+ requestedBlockId?: string;
254
+ anchor: ReviseJsonObject;
255
+ }
256
+
257
+ type ReviseReadToolName = "read_blocks_from_index" | "read_specific_blocks";
258
+ type ReviseSearchToolName = "search_document" | "find_highlights";
259
+ type ReviseMeasurementToolName = "measure_document" | "measure_blocks";
260
+ type ReviseSpecializedToolName =
261
+ | ReviseReadToolName
262
+ | ReviseSearchToolName
263
+ | ReviseMeasurementToolName
264
+ | "leave_comment";
265
+ type ReviseMutationToolName = Exclude<
266
+ ReviseToolName,
267
+ ReviseSpecializedToolName
268
+ >;
269
+
270
+ export type ReviseToolDataMap = {
271
+ [Name in ReviseReadToolName]: ReviseReadData;
272
+ } & {
273
+ [Name in ReviseSearchToolName]: ReviseSearchData;
274
+ } & {
275
+ measure_document: ReviseDocumentMeasurementData;
276
+ measure_blocks: ReviseBlockMeasurementData;
277
+ leave_comment: ReviseCommentData;
278
+ } & {
279
+ [Name in ReviseMutationToolName]: ReviseMutationData | null;
280
+ };
281
+
282
+ export type ReviseToolData<Name extends ReviseToolName> =
283
+ ReviseToolDataMap[Name];
284
+
285
+ /**
286
+ * A tool's input as application code writes it for typed `execute()` and
287
+ * `call()`.
288
+ *
289
+ * `context_notes` is a model's working memory, carried from one read to the
290
+ * next, and the model-facing schemas require it. Host code keeps its own
291
+ * state, so the field is optional here and defaults to `"N/A"`.
292
+ * `executeDynamic()`, the path for model-provided calls, still requires it.
293
+ */
294
+ export type ReviseHostToolInput<Name extends ReviseToolName> =
295
+ ReviseToolInput<Name> extends { context_notes: string }
296
+ ? Omit<ReviseToolInput<Name>, "context_notes"> & { context_notes?: string }
297
+ : ReviseToolInput<Name>;
298
+
299
+ /** Tool arguments, with input optional only when its schema has no required fields. */
300
+ export type ReviseToolArguments<Name extends ReviseToolName> =
301
+ Record<string, never> extends ReviseHostToolInput<Name>
302
+ ? [input?: ReviseHostToolInput<Name>, options?: ReviseToolCallOptions]
303
+ : [input: ReviseHostToolInput<Name>, options?: ReviseToolCallOptions];
304
+
305
+ /** Semantic document context returned by read and search calls. */
306
+ export interface ReviseDocumentContext {
307
+ format: "revise-html";
308
+ html: string;
309
+ }
310
+
311
+ /** A successful tool call, ready for application code or a model transcript. */
312
+ export interface ReviseToolResponse<Name extends string = ReviseToolName> {
313
+ callId: string;
314
+ tool: Name;
315
+ /** Concise model-oriented summary of what happened. */
316
+ message: string | null;
317
+ /** Tool-specific structured data. Literal tool names infer this type. */
318
+ data: Name extends ReviseToolName
319
+ ? ReviseToolData<Name>
320
+ : ReviseJsonValue | null;
321
+ /** Block-ID-preserving semantic HTML, when the call loaded document text. */
322
+ context: ReviseDocumentContext | null;
323
+ /**
324
+ * For mutation tools, the tracked suggestion records this call created:
325
+ * non-empty only in suggesting mode. Empty when the edit applied directly,
326
+ * changed nothing, or extended an existing pending suggestion instead of
327
+ * creating its own record. Null for read, search, and measurement tools.
328
+ */
329
+ suggestionIds: string[] | null;
330
+ /**
331
+ * Image payload from browser-only tools (`view_image`). Never present on
332
+ * the server surface, whose sessions exclude the image pipeline.
333
+ */
334
+ image?: {
335
+ id: string;
336
+ fileName?: string;
337
+ urls?: string[];
338
+ dimensions?: Array<{ width: number; height: number }>;
339
+ };
340
+ }
341
+
342
+ /** An expected tool rejection: invalid input, stale context, or unavailable tool. */
343
+ export interface ReviseToolFailure<Name extends string = ReviseToolName> {
344
+ callId: string;
345
+ tool: Name;
346
+ code: string;
347
+ message: string;
348
+ /** What the tool reported with the failure, when it says more than the
349
+ * message: for example `edit_table_cells`' per-cell `errors` and the
350
+ * `recovery_read` that fixes them. */
351
+ details?: unknown;
352
+ }
353
+
354
+ export type ReviseToolResult<Name extends string = ReviseToolName> =
355
+ | { ok: true; value: ReviseToolResponse<Name> }
356
+ | { ok: false; error: ReviseToolFailure<Name> };
357
+
358
+ export interface ServerDocumentTools {
359
+ getDefinitions(): ReviseToolDefinition[];
360
+
361
+ /**
362
+ * Execute a known tool and preserve expected failures as a discriminated
363
+ * result. Environment and disposed-session errors still reject the promise.
364
+ */
365
+ execute<Name extends ReviseToolName>(
366
+ name: Name,
367
+ ...args: ReviseToolArguments<Name>
368
+ ): Promise<ReviseToolResult<Name>>;
369
+
370
+ /** Execute an untrusted model-provided name and JSON input. */
371
+ executeDynamic(
372
+ name: string,
373
+ input?: ReviseJsonObject,
374
+ options?: ReviseToolCallOptions,
375
+ ): Promise<ReviseToolResult<string>>;
376
+
377
+ /**
378
+ * Convenient application-code form. Returns only the successful response
379
+ * and throws ReviseToolError when the tool rejects the call.
380
+ */
381
+ call<Name extends ReviseToolName>(
382
+ name: Name,
383
+ ...args: ReviseToolArguments<Name>
384
+ ): Promise<ReviseToolResponse<Name>>;
385
+ }
386
+
387
+ export interface ServerDocumentSession {
388
+ /** Return the mode subsequent mutations will capture. */
389
+ getMode(): ServerDocumentMode;
390
+ /** Make subsequent mutations produce tracked suggestions. */
391
+ setSuggestingMode(): void;
392
+ /** Make subsequent mutations apply directly. */
393
+ setEditingMode(): void;
394
+ readonly tools: ServerDocumentTools;
395
+ /** IDs of pending tracked suggestions currently stored in the Y.Doc. */
396
+ getPendingSuggestionIds(): string[];
397
+ /**
398
+ * Every pending tracked suggestion in the Y.Doc as a reviewable record —
399
+ * including collaborators' suggestions in a shared document. Filter by
400
+ * author metadata before making bulk decisions on someone else's work.
401
+ */
402
+ listSuggestions(): ReviseSuggestionRecord[];
403
+ /**
404
+ * Accept specific pending suggestions by ID — the primary review path.
405
+ * Collect IDs from mutation results' `suggestionIds` or from
406
+ * `listSuggestions()`.
407
+ */
408
+ acceptSuggestions(suggestionIds: string[]): ReviseSuggestionDecision;
409
+ /** Reject specific pending suggestions by ID. */
410
+ rejectSuggestions(suggestionIds: string[]): ReviseSuggestionDecision;
411
+ /**
412
+ * Accept every pending suggestion in the Y.Doc, including collaborators'.
413
+ * Prefer `acceptSuggestions(ids)` unless the host owns the whole document.
414
+ */
415
+ acceptAllSuggestions(): ReviseSuggestionDecision;
416
+ /** Reject every pending suggestion in the Y.Doc, including collaborators'. */
417
+ rejectAllSuggestions(): ReviseSuggestionDecision;
418
+ /** Release observers without destroying the supplied Y.Doc. */
419
+ dispose(): void;
420
+ }
@@ -0,0 +1,264 @@
1
+ // Input types for every Revise tool, generated from the tool schemas.
2
+ export type ReviseJsonPrimitive = string | number | boolean | null;
3
+ export type ReviseJsonValue =
4
+ | ReviseJsonPrimitive
5
+ | ReviseJsonValue[]
6
+ | { [key: string]: ReviseJsonValue };
7
+ export type ReviseJsonObject = { [key: string]: ReviseJsonValue };
8
+
9
+ export interface ReviseToolInputMap {
10
+ read_blocks_from_index: {
11
+ context_notes: string;
12
+ index: number;
13
+ };
14
+ search_document: {
15
+ context_notes: string;
16
+ page: number;
17
+ queries: Array<string>;
18
+ };
19
+ find_highlights: {
20
+ color?: "yellow" | "orange" | "green" | "blue" | "purple" | "pink" | "gray";
21
+ context_notes: string;
22
+ page: number;
23
+ };
24
+ read_specific_blocks: {
25
+ block_ids: Array<string>;
26
+ context_notes: string;
27
+ };
28
+ read_table: {
29
+ cell_id?: string;
30
+ column_count?: number;
31
+ column_start?: number;
32
+ context_notes: string;
33
+ continuation_revision?: string;
34
+ mode?: "summary" | "rows" | "cell_text";
35
+ row_count?: number;
36
+ row_ids?: Array<string>;
37
+ row_start?: number;
38
+ table_id: string;
39
+ text_offset?: number;
40
+ };
41
+ measure_document: {
42
+ heading_levels?: Array<1 | 2 | 3>;
43
+ include_sections?: boolean;
44
+ section_limit?: number;
45
+ section_offset?: number;
46
+ };
47
+ measure_blocks: {
48
+ mode?: "inclusive";
49
+ ranges: Array<{
50
+ end_block_id?: string;
51
+ start_block_id: string;
52
+ }>;
53
+ };
54
+ insert_block: {
55
+ content: Array<string>;
56
+ position: "before" | "after";
57
+ referenceId: string;
58
+ };
59
+ insert_footnote: {
60
+ find: string;
61
+ id: string;
62
+ kind?: "footnote" | "endnote";
63
+ text: string;
64
+ };
65
+ remove_blocks: {
66
+ end_id?: string;
67
+ id?: string;
68
+ ids?: Array<string>;
69
+ search_result_id?: string;
70
+ through_end?: boolean;
71
+ };
72
+ append_to_paragraph: {
73
+ content: string;
74
+ id: string;
75
+ };
76
+ break_paragraph: {
77
+ id: string;
78
+ substring: string;
79
+ };
80
+ join_paragraphs: {
81
+ firstId: string;
82
+ secondId: string;
83
+ separator?: string;
84
+ };
85
+ replace_block: {
86
+ content: Array<string>;
87
+ end_id?: string;
88
+ id?: string;
89
+ search_result_id?: string;
90
+ };
91
+ style_blocks: {
92
+ attrs: Array<{
93
+ name: string;
94
+ value: string | number | boolean | null;
95
+ }>;
96
+ search_result_id?: string;
97
+ selectors: string | Array<string>;
98
+ };
99
+ clear_formatting: {
100
+ id: string | Array<string>;
101
+ };
102
+ set_title: {
103
+ title: string;
104
+ };
105
+ set_page_layout: {
106
+ blockSpacing?: string;
107
+ clearPageBorders?: boolean;
108
+ columnCount?: 1 | 2 | 3;
109
+ columnGap?: string;
110
+ indentStep?: string;
111
+ margin?: string;
112
+ marginBottom?: string;
113
+ marginLeft?: string;
114
+ marginRight?: string;
115
+ marginTop?: string;
116
+ noteMode?: "footnotes" | "endnotes";
117
+ orientation?: "portrait" | "landscape";
118
+ pageBorders?: {
119
+ bottom?: {
120
+ color: string;
121
+ spacePt: number;
122
+ style: "single" | "double" | "dotted" | "dashed";
123
+ widthPt: number;
124
+ };
125
+ display: "allPages" | "firstPage" | "notFirstPage";
126
+ left?: {
127
+ color: string;
128
+ spacePt: number;
129
+ style: "single" | "double" | "dotted" | "dashed";
130
+ widthPt: number;
131
+ };
132
+ offsetFrom: "page" | "text";
133
+ right?: {
134
+ color: string;
135
+ spacePt: number;
136
+ style: "single" | "double" | "dotted" | "dashed";
137
+ widthPt: number;
138
+ };
139
+ top?: {
140
+ color: string;
141
+ spacePt: number;
142
+ style: "single" | "double" | "dotted" | "dashed";
143
+ widthPt: number;
144
+ };
145
+ zOrder: "front" | "back";
146
+ };
147
+ pageHeight?: string;
148
+ pageNumberFormat?: "decimal" | "lowerRoman" | "upperRoman";
149
+ pageNumberPosition?:
150
+ | "top-left"
151
+ | "top-right"
152
+ | "bottom-left"
153
+ | "bottom-right";
154
+ pageNumberRestart?: boolean;
155
+ pageNumberStart?: number;
156
+ pageSize?:
157
+ | "letter"
158
+ | "tabloid"
159
+ | "legal"
160
+ | "statement"
161
+ | "executive"
162
+ | "folio"
163
+ | "a3"
164
+ | "a4"
165
+ | "a5"
166
+ | "b4"
167
+ | "b5";
168
+ pageWidth?: string;
169
+ pageless?: boolean;
170
+ preset?: "apa7";
171
+ sectionIndex?: number;
172
+ showPageNumbers?: boolean;
173
+ };
174
+ set_header_footer: {
175
+ center?: string;
176
+ clear?: boolean;
177
+ image?: {
178
+ alt?: string;
179
+ height?: number;
180
+ image_id?: string;
181
+ url?: string;
182
+ width?: number;
183
+ zone?: "left" | "center" | "right";
184
+ };
185
+ left?: string;
186
+ right?: string;
187
+ sectionIndex?: number;
188
+ side: "header" | "footer";
189
+ slot?: "default" | "first" | "even";
190
+ };
191
+ replace: {
192
+ id?: string;
193
+ replacements: Array<{
194
+ comment?: string;
195
+ find: string;
196
+ occurrence?: "unique" | "all";
197
+ replace: string;
198
+ }>;
199
+ search_result_id?: string;
200
+ };
201
+ leave_comment: {
202
+ acknowledge_existing_thread_ids?: Array<string>;
203
+ anchor?:
204
+ | {
205
+ text: string;
206
+ }
207
+ | {
208
+ end_text: string;
209
+ start_text: string;
210
+ }
211
+ | {
212
+ whole_block: true;
213
+ };
214
+ comment: string;
215
+ id?: string;
216
+ reply_to_comment_id?: string;
217
+ };
218
+ insert_table_row: {
219
+ content: Array<string>;
220
+ position: "before" | "after";
221
+ referenceIndex?: number;
222
+ referenceRowId?: string;
223
+ tableId: string;
224
+ };
225
+ remove_table_rows: {
226
+ rowIds?: Array<string>;
227
+ rowIndices?: Array<number>;
228
+ tableId: string;
229
+ };
230
+ insert_table_column: {
231
+ content: Array<string>;
232
+ position: "before" | "after";
233
+ referenceIndex: number;
234
+ tableId: string;
235
+ };
236
+ remove_table_column: {
237
+ columnIndex: number;
238
+ tableId: string;
239
+ };
240
+ edit_table_cells: {
241
+ cells: Array<{
242
+ column: number;
243
+ row_id: string;
244
+ text: string;
245
+ }>;
246
+ mode: "fill_if_empty" | "replace";
247
+ table_id: string;
248
+ };
249
+ remove_block: {
250
+ end_id?: string;
251
+ id?: string;
252
+ ids?: Array<string>;
253
+ search_result_id?: string;
254
+ through_end?: boolean;
255
+ };
256
+ remove_table_row: {
257
+ tableId: string;
258
+ rowIndex: number;
259
+ };
260
+ }
261
+
262
+ export type ReviseToolName = keyof ReviseToolInputMap;
263
+ export type ReviseToolInput<Name extends ReviseToolName> =
264
+ ReviseToolInputMap[Name];