@stll/folio-agents 0.15.5 → 0.16.1

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.
package/README.md CHANGED
@@ -39,9 +39,16 @@ bun add @stll/folio-agents
39
39
 
40
40
  A `read_document` / `read_section` block also carries, when present, the
41
41
  number or bullet the document shows beside it (`displayLabel`: `2.1.`, `a)`,
42
- `•`; an unnumbered heading's style id), its `headingLevel` (one-based) and
43
- its `listLevel` (zero-based). A numbered heading is `kind: "heading"` with its
44
- number in `displayLabel`; absent fields are omitted.
42
+ `•`; an unnumbered heading's style id), its `headingLevel` (one-based),
43
+ `statedNumbering` (the authored paragraph state), and `listReference` (the
44
+ resolved numbering instance and zero-based level, when present). A numbered
45
+ heading is `kind: "heading"` with its number in `displayLabel`; absent fields
46
+ are omitted. Diagnostic blocks report preserved content Folio cannot interpret
47
+ and omit paragraph numbering fields.
48
+
49
+ For `suggest_changes`, `numbering` is a named state: `none`, `inherit`,
50
+ `{ kind: "levelOnly", ilvl }`, `{ kind: "reference", numId, ilvl? }`, or
51
+ `{ kind: "newList", format: "numbered" | "bullet", level? }`.
45
52
 
46
53
  Block ids and comment ids always come from a prior tool call
47
54
  (`read_document`, `find_text`, `read_comments`) within the same conversation —
@@ -49,7 +56,7 @@ never guess them. `suggest_changes` reports a plain-language reason when an
49
56
  operation is skipped (e.g. the block changed since it was last read, an
50
57
  earlier operation of the same call already deletes, rewrites, splits or merges
51
58
  its target, an offset falls inside a character, its `styleId` names no
52
- paragraph style the document defines, or its `numbering.numId` names an
59
+ paragraph style the document defines, or a `numbering` reference names an
53
60
  instance the document does not define), so the model can re-read and retry.
54
61
  An operation whose result would leave a document that cannot be saved is
55
62
  skipped with `invalidResult` and nothing from it is applied. Successful
@@ -1,9 +1,10 @@
1
1
  import { FolioAgentBridge } from "../bridge.js";
2
2
  import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioDocumentNavigationTarget, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult } from "@stll/folio-core/server";
3
- import { FolioCommentAnchor, FolioReviewChange as FolioReviewChange$1 } from "@stll/folio-core/ai-edits";
3
+ import { FolioCommentAnchor, FolioReviewChange as FolioReviewChange$1, FolioUndefinedReferencePolicy } from "@stll/folio-core/ai-edits";
4
4
  import { Comment } from "@stll/folio-core/types/content";
5
5
  //#region src/bridges/editor-ref.d.ts
6
6
  type FolioAgentEditorApplyDocumentOperationsOptions = {
7
+ undefinedReferences: FolioUndefinedReferencePolicy;
7
8
  snapshot: FolioAIEditSnapshot;
8
9
  batch: FolioDocumentOperationBatch;
9
10
  mode?: FolioAIEditApplyMode;
@@ -28,6 +29,7 @@ type FolioAgentEditorRefLike = {
28
29
  createAIEditSnapshot(): FolioAIEditSnapshot | null;
29
30
  /** `DocxEditorRef.applyAIEditOperations`. */
30
31
  applyAIEditOperations(options: {
32
+ undefinedReferences: FolioUndefinedReferencePolicy;
31
33
  snapshot: FolioAIEditSnapshot;
32
34
  operations: FolioAIEditOperation[];
33
35
  mode?: FolioAIEditApplyMode;
@@ -88,6 +88,7 @@ const createEditorRefBridge = (options) => {
88
88
  } : batch;
89
89
  if (ref.applyDocumentOperations) {
90
90
  const result = ref.applyDocumentOperations({
91
+ undefinedReferences: "refuse",
91
92
  snapshot,
92
93
  batch: versionedBatch,
93
94
  mode,
@@ -131,6 +132,7 @@ const createEditorRefBridge = (options) => {
131
132
  };
132
133
  }
133
134
  const result = ref.applyAIEditOperations({
135
+ undefinedReferences: "refuse",
134
136
  snapshot,
135
137
  operations: [...versionedBatch.operations],
136
138
  author,
@@ -35,7 +35,10 @@ const createReviewerBridge = (reviewer, options = {}) => {
35
35
  applyDocumentOperations: (batch) => reviewer.applyDocumentOperations(batch.mode === void 0 ? {
36
36
  ...batch,
37
37
  mode
38
- } : batch, applyOptions),
38
+ } : batch, {
39
+ ...applyOptions,
40
+ undefinedReferences: "refuse"
41
+ }),
39
42
  undoDocumentOperations: (undoHandle) => reviewer.undoDocumentOperations(undoHandle),
40
43
  getComments: () => reviewer.getComments().map(toAgentComment),
41
44
  getChanges: () => reviewer.getChanges().map(toAgentChange),
package/dist/execute.js CHANGED
@@ -26,22 +26,35 @@ const VALID_TOOL_NAMES = Object.values(FOLIO_AGENT_TOOL_NAMES);
26
26
  */
27
27
  const blockTextHashOf = (text) => hashFolioAIBlockText(normalizeFolioAIBlockText(text));
28
28
  /**
29
- * A snapshot block as a `read_document` / `read_section` row: the number or
30
- * label a reader sees beside it and its heading and list levels ride along,
31
- * so the model is given the numbers the document shows. Absent fields stay
32
- * absent to keep the rows compact.
29
+ * A snapshot block as a `read_document` / `read_section` row. The authored
30
+ * numbering state and effective list reference stay separate; the display
31
+ * label carries the number the reader sees. Absent references stay omitted.
33
32
  */
34
33
  const toAgentBlock = (block) => {
35
- const row = {
34
+ const fields = {
36
35
  blockId: block.id,
37
- kind: block.kind,
38
36
  text: block.text,
39
37
  blockTextHash: blockTextHashOf(block.text)
40
38
  };
41
- if (block.displayLabel !== void 0) row.displayLabel = block.displayLabel;
42
- if (block.headingLevel !== void 0) row.headingLevel = block.headingLevel;
43
- if (block.listLevel !== void 0) row.listLevel = block.listLevel;
44
- return row;
39
+ switch (block.kind) {
40
+ case "paragraph":
41
+ case "heading":
42
+ case "listItem": return {
43
+ ...fields,
44
+ kind: block.kind,
45
+ ...block.displayLabel !== void 0 && { displayLabel: block.displayLabel },
46
+ ...block.headingLevel !== void 0 && { headingLevel: block.headingLevel },
47
+ statedNumbering: block.statedNumbering,
48
+ ...block.listReference !== void 0 && { listReference: block.listReference }
49
+ };
50
+ case "diagnostic": return {
51
+ ...fields,
52
+ kind: block.kind,
53
+ ...block.displayLabel !== void 0 && { displayLabel: block.displayLabel },
54
+ ...block.headingLevel !== void 0 && { headingLevel: block.headingLevel }
55
+ };
56
+ default: return panic("Unhandled agent snapshot block kind", { block });
57
+ }
45
58
  };
46
59
  /** `find_text` requires a short `query` and caps how much of a large match set it returns in one call. */
47
60
  const MAX_QUERY_LENGTH = 1e3;
@@ -135,7 +148,15 @@ const readStory = (args, bridge) => {
135
148
  const CONTEXT_RADIUS = 40;
136
149
  const WORD_CHARACTER_AT_END = /[\p{L}\p{M}\p{N}_]$/u;
137
150
  /** Whether `[start, end)` of a block's text starts or ends inside a note reference's marker. */
138
- const cutsIntoNoteReference = (block, start, end) => (block.structuralBoundaries ?? []).some((boundary) => boundary.type === "noteReference" && [start, end].some((offset) => offset > boundary.offset && offset < boundary.offset + boundary.length));
151
+ const cutsIntoNoteReference = (block, start, end) => {
152
+ switch (block.kind) {
153
+ case "diagnostic": return false;
154
+ case "paragraph":
155
+ case "heading":
156
+ case "listItem": return (block.structuralBoundaries ?? []).some((boundary) => boundary.type === "noteReference" && [start, end].some((offset) => offset > boundary.offset && offset < boundary.offset + boundary.length));
157
+ default: return panic("Unhandled agent snapshot block kind", { block });
158
+ }
159
+ };
139
160
  const WORD_CHARACTER_AT_START = /^[\p{L}\p{M}\p{N}_]/u;
140
161
  /**
141
162
  * Window (UTF-16 code units) sliced on each side of a match for the
@@ -305,7 +326,7 @@ const explainSkipReason = (reason) => {
305
326
  if (reason === "missingStyle") return "`styleId` names no paragraph style this document defines (it is undefined, or a table or character style); nothing was applied. Use a paragraph style the document defines (the ones it offers are named after this reason), or `null` to clear the style.";
306
327
  if (reason === "pendingDeletion") return "this block is pending deletion (a tracked change deletes it; it reads as a blank block); nothing was applied, since text written there would join the next paragraph once the deletion is accepted. Reject that deletion first, or insert a new block next to it (insertAfterBlock / insertBeforeBlock).";
307
328
  if (reason === "pendingParagraphMarkDeletion") return "this paragraph's mark is pending tracked deletion; resolve that change before editing its properties separately, or provide mergedParagraphProperties on the merge operation.";
308
- if (reason === "missingNumbering") return "`numbering.numId` names a numbering instance this document does not define; nothing was applied. Re-read the document and use a `numId` it defines (the one a neighbouring list item carries), or omit `numbering`.";
329
+ if (reason === "missingNumbering") return "`numbering` names a numbering instance this document does not define; nothing was applied. Re-read the document and use a `{ kind: \"reference\", numId, ilvl? }` the document defines (the one a neighbouring list item carries), or choose another numbering state.";
309
330
  if (reason === "invalidResult") return "applying this operation would have left a document that cannot be saved, so nothing from it was applied. Do not retry it as written; re-read the document and express the change differently.";
310
331
  return reason;
311
332
  };
@@ -42,16 +42,6 @@ declare const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA: {
42
42
  }];
43
43
  readonly description: string;
44
44
  };
45
- declare const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA: {
46
- readonly oneOf: readonly [{
47
- readonly type: "integer";
48
- readonly minimum: 0;
49
- readonly maximum: number;
50
- }, {
51
- readonly type: "null";
52
- }];
53
- readonly description: "`w:numPr/w:ilvl`, zero-based; a number retains the paragraph or anchor's numbering instance (`numId`), while null removes paragraph numbering unless a concrete numbering instance is supplied, in which case it omits the direct level.";
54
- };
55
45
  /** Direct `w:outlineLvl`, or null to restore style inheritance. */
56
46
  declare const FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA: FolioJsonSchema;
57
47
  /** Complete direct `w:ind` attributes, or null to restore style inheritance. */
@@ -90,33 +80,72 @@ declare const FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA: {
90
80
  readonly enum: readonly ["firstParagraph", "allParagraphs"];
91
81
  readonly description: string;
92
82
  };
93
- declare const FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA: {
83
+ declare const FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA: {
94
84
  readonly oneOf: readonly [{
95
85
  readonly type: "object";
96
86
  readonly properties: {
87
+ readonly kind: {
88
+ readonly type: "string";
89
+ readonly enum: readonly ["none"];
90
+ };
91
+ };
92
+ readonly required: readonly ["kind"];
93
+ readonly additionalProperties: false;
94
+ }, {
95
+ readonly type: "object";
96
+ readonly properties: {
97
+ readonly kind: {
98
+ readonly type: "string";
99
+ readonly enum: readonly ["inherit"];
100
+ };
101
+ };
102
+ readonly required: readonly ["kind"];
103
+ readonly additionalProperties: false;
104
+ }, {
105
+ readonly type: "object";
106
+ readonly properties: {
107
+ readonly kind: {
108
+ readonly type: "string";
109
+ readonly enum: readonly ["levelOnly"];
110
+ };
111
+ readonly ilvl: {
112
+ readonly type: "integer";
113
+ readonly minimum: 0;
114
+ readonly maximum: 8;
115
+ };
116
+ };
117
+ readonly required: readonly ["kind", "ilvl"];
118
+ readonly additionalProperties: false;
119
+ }, {
120
+ readonly type: "object";
121
+ readonly properties: {
122
+ readonly kind: {
123
+ readonly type: "string";
124
+ readonly enum: readonly ["reference"];
125
+ };
97
126
  readonly numId: {
98
127
  readonly type: "integer";
99
128
  readonly minimum: 1;
100
129
  readonly maximum: number;
101
130
  };
102
- readonly level: {
131
+ readonly ilvl: {
103
132
  readonly type: "integer";
104
133
  readonly minimum: 0;
105
- readonly maximum: number;
134
+ readonly maximum: 8;
106
135
  };
107
136
  };
108
- readonly required: readonly ["numId", "level"];
137
+ readonly required: readonly ["kind", "numId"];
109
138
  readonly additionalProperties: false;
110
139
  }, {
111
140
  readonly type: "object";
112
141
  readonly properties: {
113
- readonly start: {
142
+ readonly kind: {
114
143
  readonly type: "string";
115
- readonly enum: readonly ["new"];
144
+ readonly enum: readonly ["newList"];
116
145
  };
117
- readonly kind: {
146
+ readonly format: {
118
147
  readonly type: "string";
119
- readonly enum: readonly ["numbered", "bullet"];
148
+ readonly enum: readonly ["bullet", "numbered"];
120
149
  };
121
150
  readonly level: {
122
151
  readonly type: "integer";
@@ -124,10 +153,8 @@ declare const FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA: {
124
153
  readonly maximum: 8;
125
154
  };
126
155
  };
127
- readonly required: readonly ["start", "kind"];
156
+ readonly required: readonly ["kind", "format"];
128
157
  readonly additionalProperties: false;
129
- }, {
130
- readonly type: "null";
131
158
  }];
132
159
  readonly description: string;
133
160
  };
@@ -169,7 +196,7 @@ declare const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA: {
169
196
  };
170
197
  readonly lineSpacingRule: {
171
198
  readonly type: "string";
172
- readonly enum: readonly import("@stll/docx-core/model").LineSpacingRule[];
199
+ readonly enum: readonly undefined[];
173
200
  readonly description: "How `lineSpacing` is interpreted.";
174
201
  };
175
202
  readonly beforeAutospacing: {
@@ -201,43 +228,72 @@ declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
201
228
  readonly description: string;
202
229
  };
203
230
  readonly outlineLevel: FolioJsonSchema;
204
- readonly listLevel: {
205
- readonly oneOf: readonly [{
206
- readonly type: "integer";
207
- readonly minimum: 0;
208
- readonly maximum: number;
209
- }, {
210
- readonly type: "null";
211
- }];
212
- readonly description: "`w:numPr/w:ilvl`, zero-based; a number retains the paragraph or anchor's numbering instance (`numId`), while null removes paragraph numbering unless a concrete numbering instance is supplied, in which case it omits the direct level.";
213
- };
214
231
  readonly numbering: {
215
232
  readonly oneOf: readonly [{
216
233
  readonly type: "object";
217
234
  readonly properties: {
235
+ readonly kind: {
236
+ readonly type: "string";
237
+ readonly enum: readonly ["none"];
238
+ };
239
+ };
240
+ readonly required: readonly ["kind"];
241
+ readonly additionalProperties: false;
242
+ }, {
243
+ readonly type: "object";
244
+ readonly properties: {
245
+ readonly kind: {
246
+ readonly type: "string";
247
+ readonly enum: readonly ["inherit"];
248
+ };
249
+ };
250
+ readonly required: readonly ["kind"];
251
+ readonly additionalProperties: false;
252
+ }, {
253
+ readonly type: "object";
254
+ readonly properties: {
255
+ readonly kind: {
256
+ readonly type: "string";
257
+ readonly enum: readonly ["levelOnly"];
258
+ };
259
+ readonly ilvl: {
260
+ readonly type: "integer";
261
+ readonly minimum: 0;
262
+ readonly maximum: 8;
263
+ };
264
+ };
265
+ readonly required: readonly ["kind", "ilvl"];
266
+ readonly additionalProperties: false;
267
+ }, {
268
+ readonly type: "object";
269
+ readonly properties: {
270
+ readonly kind: {
271
+ readonly type: "string";
272
+ readonly enum: readonly ["reference"];
273
+ };
218
274
  readonly numId: {
219
275
  readonly type: "integer";
220
276
  readonly minimum: 1;
221
277
  readonly maximum: number;
222
278
  };
223
- readonly level: {
279
+ readonly ilvl: {
224
280
  readonly type: "integer";
225
281
  readonly minimum: 0;
226
- readonly maximum: number;
282
+ readonly maximum: 8;
227
283
  };
228
284
  };
229
- readonly required: readonly ["numId", "level"];
285
+ readonly required: readonly ["kind", "numId"];
230
286
  readonly additionalProperties: false;
231
287
  }, {
232
288
  readonly type: "object";
233
289
  readonly properties: {
234
- readonly start: {
290
+ readonly kind: {
235
291
  readonly type: "string";
236
- readonly enum: readonly ["new"];
292
+ readonly enum: readonly ["newList"];
237
293
  };
238
- readonly kind: {
294
+ readonly format: {
239
295
  readonly type: "string";
240
- readonly enum: readonly ["numbered", "bullet"];
296
+ readonly enum: readonly ["bullet", "numbered"];
241
297
  };
242
298
  readonly level: {
243
299
  readonly type: "integer";
@@ -245,10 +301,8 @@ declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
245
301
  readonly maximum: 8;
246
302
  };
247
303
  };
248
- readonly required: readonly ["start", "kind"];
304
+ readonly required: readonly ["kind", "format"];
249
305
  readonly additionalProperties: false;
250
- }, {
251
- readonly type: "null";
252
306
  }];
253
307
  readonly description: string;
254
308
  };
@@ -285,7 +339,7 @@ declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
285
339
  readonly alignment: {
286
340
  readonly oneOf: readonly [{
287
341
  readonly type: "string";
288
- readonly enum: readonly import("@stll/docx-core/model").ParagraphAlignment[];
342
+ readonly enum: readonly undefined[];
289
343
  }, {
290
344
  readonly type: "null";
291
345
  }];
@@ -315,7 +369,7 @@ declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
315
369
  };
316
370
  readonly lineSpacingRule: {
317
371
  readonly type: "string";
318
- readonly enum: readonly import("@stll/docx-core/model").LineSpacingRule[];
372
+ readonly enum: readonly undefined[];
319
373
  readonly description: "How `lineSpacing` is interpreted.";
320
374
  };
321
375
  readonly beforeAutospacing: {
@@ -406,4 +460,4 @@ type FolioDocumentOperationBatchSchema = StandardSchemaV1<unknown, FolioDocument
406
460
  */
407
461
  declare const folioDocumentOperationBatchSchema: FolioDocumentOperationBatchSchema;
408
462
  //#endregion
409
- export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA, FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT, FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, FolioJsonSchema, folioDocumentOperationBatchSchema };
463
+ export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT, FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA, FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, FolioJsonSchema, folioDocumentOperationBatchSchema };
@@ -137,14 +137,6 @@ const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA = {
137
137
  oneOf: [{ type: "string" }, { type: "null" }],
138
138
  description: "Paragraph style id; it must name a paragraph style the document defines, or the operation skips with `missingStyle`. null clears the direct style."
139
139
  };
140
- const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA = {
141
- oneOf: [{
142
- type: "integer",
143
- minimum: 0,
144
- maximum: Number.MAX_SAFE_INTEGER
145
- }, { type: "null" }],
146
- description: "`w:numPr/w:ilvl`, zero-based; a number retains the paragraph or anchor's numbering instance (`numId`), while null removes paragraph numbering unless a concrete numbering instance is supplied, in which case it omits the direct level."
147
- };
148
140
  /** Direct `w:outlineLvl`, or null to restore style inheritance. */
149
141
  const FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA = {
150
142
  oneOf: [
@@ -209,35 +201,73 @@ const FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA = {
209
201
  enum: ["firstParagraph", "allParagraphs"],
210
202
  description: "Which paragraphs split from `text` receive the operation's paragraph formatting: `firstParagraph` (default) formats only the first, for a heading followed by its body; `allParagraphs` formats every paragraph alike, for several list items in one operation."
211
203
  };
212
- const FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA = {
204
+ const FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA = {
213
205
  oneOf: [
206
+ {
207
+ type: "object",
208
+ properties: { kind: {
209
+ type: "string",
210
+ enum: ["none"]
211
+ } },
212
+ required: ["kind"],
213
+ additionalProperties: false
214
+ },
215
+ {
216
+ type: "object",
217
+ properties: { kind: {
218
+ type: "string",
219
+ enum: ["inherit"]
220
+ } },
221
+ required: ["kind"],
222
+ additionalProperties: false
223
+ },
214
224
  {
215
225
  type: "object",
216
226
  properties: {
227
+ kind: {
228
+ type: "string",
229
+ enum: ["levelOnly"]
230
+ },
231
+ ilvl: {
232
+ type: "integer",
233
+ minimum: 0,
234
+ maximum: 8
235
+ }
236
+ },
237
+ required: ["kind", "ilvl"],
238
+ additionalProperties: false
239
+ },
240
+ {
241
+ type: "object",
242
+ properties: {
243
+ kind: {
244
+ type: "string",
245
+ enum: ["reference"]
246
+ },
217
247
  numId: {
218
248
  type: "integer",
219
249
  minimum: 1,
220
250
  maximum: Number.MAX_SAFE_INTEGER
221
251
  },
222
- level: {
252
+ ilvl: {
223
253
  type: "integer",
224
254
  minimum: 0,
225
- maximum: Number.MAX_SAFE_INTEGER
255
+ maximum: 8
226
256
  }
227
257
  },
228
- required: ["numId", "level"],
258
+ required: ["kind", "numId"],
229
259
  additionalProperties: false
230
260
  },
231
261
  {
232
262
  type: "object",
233
263
  properties: {
234
- start: {
264
+ kind: {
235
265
  type: "string",
236
- enum: ["new"]
266
+ enum: ["newList"]
237
267
  },
238
- kind: {
268
+ format: {
239
269
  type: "string",
240
- enum: ["numbered", "bullet"]
270
+ enum: ["bullet", "numbered"]
241
271
  },
242
272
  level: {
243
273
  type: "integer",
@@ -245,12 +275,11 @@ const FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA = {
245
275
  maximum: 8
246
276
  }
247
277
  },
248
- required: ["start", "kind"],
278
+ required: ["kind", "format"],
249
279
  additionalProperties: false
250
- },
251
- { type: "null" }
280
+ }
252
281
  ],
253
- description: "An existing numbering instance and level (`numId` from a prior read; it must name an instance the document defines, one a list block read from it carries, or the operation skips with `missingNumbering`); or `{ start: \"new\", kind: \"numbered\" | \"bullet\", level? }` to start a new list, numbered from the first item, with every paragraph this operation numbers in it (separate operations start separate lists; works in a document with no lists); null removes paragraph numbering."
282
+ description: "A paragraph numbering request: `none` cancels numbering, `inherit` removes the direct numbering reference, `levelOnly` sets only `w:ilvl`, `reference` selects a defined numbering instance with an optional level override, and `newList` starts a list with the requested format."
254
283
  };
255
284
  const FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA = {
256
285
  type: "object",
@@ -319,8 +348,7 @@ const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA = {
319
348
  properties: {
320
349
  styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
321
350
  outlineLevel: FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA,
322
- listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
323
- numbering: FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA,
351
+ numbering: FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA,
324
352
  indentation: FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA,
325
353
  alignment: {
326
354
  oneOf: [{
@@ -466,7 +494,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
466
494
  blockId: blockIdProperty,
467
495
  text: {
468
496
  type: "string",
469
- description: "The paragraph text to insert. A line break splits this into consecutive paragraphs at the same anchor instead of one paragraph with embedded newlines. By default only the first paragraph gets `styleId` / `listLevel` / `numbering` / `alignment` / `spacing` / `inheritFormatting` and later ones use body formatting; set `formattingScope: \"allParagraphs\"` to format every paragraph alike, for example several list items. Prefer one paragraph per operation otherwise."
497
+ description: "The paragraph text to insert. A line break splits this into consecutive paragraphs at the same anchor instead of one paragraph with embedded newlines. By default only the first paragraph gets `styleId` / `numbering` / `alignment` / `spacing` / `inheritFormatting` and later ones use body formatting; set `formattingScope: \"allParagraphs\"` to format every paragraph alike, for example several list items. Prefer one paragraph per operation otherwise."
470
498
  },
471
499
  inheritFormatting: {
472
500
  type: "boolean",
@@ -478,7 +506,6 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
478
506
  },
479
507
  styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
480
508
  outlineLevel: FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA,
481
- listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
482
509
  alignment: {
483
510
  oneOf: [{
484
511
  type: "string",
@@ -493,7 +520,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
493
520
  enum: ["paragraph", "inline"]
494
521
  },
495
522
  formattingScope: FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA,
496
- numbering: FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA,
523
+ numbering: FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA,
497
524
  hardPageBreak: FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA,
498
525
  moveId: {
499
526
  type: "string",
@@ -523,7 +550,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
523
550
  blockId: blockIdProperty,
524
551
  text: {
525
552
  type: "string",
526
- description: "The paragraph text to insert. A line break splits this into consecutive paragraphs at the same anchor instead of one paragraph with embedded newlines. By default only the first paragraph gets `styleId` / `listLevel` / `numbering` / `alignment` / `spacing` / `inheritFormatting` and later ones use body formatting; set `formattingScope: \"allParagraphs\"` to format every paragraph alike, for example several list items. Prefer one paragraph per operation otherwise."
553
+ description: "The paragraph text to insert. A line break splits this into consecutive paragraphs at the same anchor instead of one paragraph with embedded newlines. By default only the first paragraph gets `styleId` / `numbering` / `alignment` / `spacing` / `inheritFormatting` and later ones use body formatting; set `formattingScope: \"allParagraphs\"` to format every paragraph alike, for example several list items. Prefer one paragraph per operation otherwise."
527
554
  },
528
555
  inheritFormatting: {
529
556
  type: "boolean",
@@ -535,7 +562,6 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
535
562
  },
536
563
  styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
537
564
  outlineLevel: FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA,
538
- listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
539
565
  alignment: {
540
566
  oneOf: [{
541
567
  type: "string",
@@ -550,7 +576,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
550
576
  enum: ["paragraph", "inline"]
551
577
  },
552
578
  formattingScope: FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA,
553
- numbering: FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA,
579
+ numbering: FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA,
554
580
  hardPageBreak: FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA,
555
581
  moveId: {
556
582
  type: "string",
@@ -1083,4 +1109,4 @@ const folioDocumentOperationBatchSchema = {
1083
1109
  jsonSchema: FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA
1084
1110
  };
1085
1111
  //#endregion
1086
- export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA, FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT, FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, folioDocumentOperationBatchSchema };
1112
+ export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT, FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA, FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, folioDocumentOperationBatchSchema };
package/dist/tools.d.ts CHANGED
@@ -15,7 +15,7 @@ import { FolioAgentFindTextScope, FolioAgentShowInDocumentArgs } from "./tool-co
15
15
  * string (the parser wraps it into `{ text }`). `suggestionId` is host-side
16
16
  * grouping state and is never exposed to the model.
17
17
  */
18
- declare const SUGGEST_CHANGES_OPERATION_TYPES: readonly ("replaceInBlock" | "replaceRange" | "commentOnRange" | "formatRange" | "insertAfterBlock" | "insertBeforeBlock" | "replaceBlock" | "deleteBlock" | "splitBlock" | "insertTable" | "deleteTable" | "setBlockParagraphProperties" | "mergeBlockWithNext" | "commentOnBlock" | "insertSignatureTable" | "insertTableRow" | "deleteTableRow" | "insertTableColumn" | "deleteTableColumn" | "mergeTableCells" | "splitTableCell")[];
18
+ declare const SUGGEST_CHANGES_OPERATION_TYPES: readonly ("replaceInBlock" | "replaceRange" | "commentOnRange" | "formatRange" | "replaceBlock" | "deleteBlock" | "insertTable" | "deleteTable" | "commentOnBlock" | "insertSignatureTable" | "insertTableRow" | "deleteTableRow" | "insertTableColumn" | "deleteTableColumn" | "mergeTableCells" | "splitTableCell" | "insertAfterBlock" | "insertBeforeBlock" | "splitBlock" | "setBlockParagraphProperties" | "mergeBlockWithNext")[];
19
19
  /**
20
20
  * Plain-language capability statement for a configured `suggest_changes`
21
21
  * surface: the allowed operations, the structural knobs they unlock, the
package/dist/tools.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FOLIO_COMMENT_ID_JSON_SCHEMA, FOLIO_SCOPED_HANDLE_JSON_SCHEMA, FOLIO_SECTION_HANDLE_JSON_SCHEMA, FOLIO_STORY_HANDLE_JSON_SCHEMA } from "./codecs.js";
2
- import { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA, FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT, FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA } from "./operation-schema.js";
2
+ import { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA, FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT, FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA, FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA } from "./operation-schema.js";
3
3
  import { DEFAULT_SUGGEST_CHANGES_OPERATION_TYPES, resolveSuggestChangesOptions } from "./suggest-changes-options.js";
4
4
  import { defineFolioAgentToolDefinition } from "./tool-contract.js";
5
5
  import { FOLIO_AGENT_TOOL_NAMES } from "./types.js";
@@ -132,7 +132,7 @@ const OPERATION_PROPERTY_SCHEMAS = {
132
132
  ...FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA,
133
133
  description: "For inserts: which paragraphs split from `text` get the operation's paragraph formatting. `firstParagraph` (default) formats only the first; `allParagraphs` formats every paragraph alike, for several list items in one operation."
134
134
  },
135
- numbering: FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA,
135
+ numbering: FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA,
136
136
  hardPageBreak: FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA,
137
137
  preserveFormatting: {
138
138
  type: "boolean",
@@ -207,7 +207,6 @@ const OPERATION_PROPERTY_SCHEMAS = {
207
207
  ...FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA,
208
208
  description: "For `mergeBlockWithNext`, properties for the joined result; omitted properties keep the first paragraph's value."
209
209
  },
210
- listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
211
210
  offset: {
212
211
  type: "integer",
213
212
  minimum: 0,
@@ -316,7 +315,7 @@ const definitionsFromRegistry = (registry) => Object.values(registry);
316
315
  const FOLIO_AGENT_TOOL_REGISTRY = {
317
316
  [FOLIO_AGENT_TOOL_NAMES.readDocument]: defineFolioAgentToolDefinition({
318
317
  name: FOLIO_AGENT_TOOL_NAMES.readDocument,
319
- description: "Read the full document body as a list of blocks (paragraphs, headings, list items). Call this first, or whenever you need fresh block ids after a mutation — block ids from a stale read may no longer resolve. A block shows its number or bullet (`2.1.`, `a)`, `•`) as `displayLabel`, a numbered heading included; a heading also has `headingLevel` and a numbered block `listLevel`. Each block includes a `blockTextHash`; echo it as `precondition.blockTextHash` on a suggest_changes / add_comment operation to guard against the block changing before that call runs.",
318
+ description: "Read the full document body as a list of blocks (paragraphs, headings, list items). Call this first, or whenever you need fresh block ids after a mutation — block ids from a stale read may no longer resolve. A block shows its number or bullet (`2.1.`, `a)`, `•`) as `displayLabel`, a numbered heading included; a heading also has `headingLevel`. Paragraph blocks include `statedNumbering`; diagnostic blocks omit paragraph numbering fields. `listReference` is present when numbering resolves to an instance. Each block includes a `blockTextHash`; echo it as `precondition.blockTextHash` on a suggest_changes / add_comment operation to guard against the block changing before that call runs.",
320
319
  inputSchema: {
321
320
  type: "object",
322
321
  properties: {},
@@ -341,7 +340,7 @@ const FOLIO_AGENT_TOOL_REGISTRY = {
341
340
  }),
342
341
  [FOLIO_AGENT_TOOL_NAMES.readSection]: defineFolioAgentToolDefinition({
343
342
  name: FOLIO_AGENT_TOOL_NAMES.readSection,
344
- description: "Read one logical heading section using a handle from get_document_outline. Content is block-bounded and paginated with an afterBlockId cursor, avoiding a full-document read. Blocks have the same fields as read_document's, `displayLabel`, `headingLevel` and `listLevel` included. Each block includes a `blockTextHash`; echo it as `precondition.blockTextHash` on a suggest_changes / add_comment operation.",
343
+ description: "Read one logical heading section using a handle from get_document_outline. Content is block-bounded and paginated with an afterBlockId cursor, avoiding a full-document read. Blocks have the same fields as read_document's, including `displayLabel`, `headingLevel`, and paragraph numbering fields on paragraph blocks. Diagnostic blocks omit paragraph numbering fields. Each block includes a `blockTextHash`; echo it as `precondition.blockTextHash` on a suggest_changes / add_comment operation.",
345
344
  inputSchema: {
346
345
  type: "object",
347
346
  properties: {
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FolioAITextRangeHandle, FolioDocumentOperationIssue, FolioDocumentOperationReceipt, FolioDocumentOutlineEntry, FolioDocumentSectionHandle, FolioDocumentStoryHandle, FolioReviewChange } from "@stll/folio-core/server";
1
+ import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FolioAIDiagnosticBlock, FolioAIParagraphBlock, FolioAITextRangeHandle, FolioDocumentOperationIssue, FolioDocumentOperationReceipt, FolioDocumentOutlineEntry, FolioDocumentSectionHandle, FolioDocumentStoryHandle, FolioReviewChange } from "@stll/folio-core/server";
2
2
  //#region src/types.d.ts
3
3
  /**
4
4
  * Provider-neutral tool-layer types. `FolioAgentToolDefinition` describes a
@@ -68,16 +68,15 @@ type FolioToolCallResult<TResult = unknown> = {
68
68
  error: string;
69
69
  };
70
70
  /**
71
- * One document block as exposed to a model: id, kind, its plain text, and the
72
- * number or level a reader sees beside it. Absent fields are omitted.
71
+ * One document block as exposed to a model. Paragraph blocks carry authored
72
+ * numbering state; diagnostics have no paragraph numbering fields.
73
73
  */
74
- type FolioAgentBlock = {
74
+ type FolioAgentBlockFields = {
75
75
  blockId: string;
76
76
  /**
77
77
  * `heading`, `listItem` or `paragraph`. A numbered heading (`1. Scope`) is a
78
78
  * `heading` with its number in `displayLabel`.
79
79
  */
80
- kind: string;
81
80
  text: string;
82
81
  /**
83
82
  * What the document shows beside the text: the list or heading number
@@ -86,8 +85,6 @@ type FolioAgentBlock = {
86
85
  displayLabel?: string;
87
86
  /** One-based heading level, on headings. */
88
87
  headingLevel?: number;
89
- /** Zero-based numbering level, on numbered paragraphs and headings. */
90
- listLevel?: number;
91
88
  /**
92
89
  * Normalized-text hash of this block at read time. Echo it back as
93
90
  * `precondition.blockTextHash` on a `suggest_changes` / `add_comment`
@@ -98,6 +95,15 @@ type FolioAgentBlock = {
98
95
  */
99
96
  blockTextHash: string;
100
97
  };
98
+ type FolioAgentBlock = (FolioAgentBlockFields & {
99
+ kind: FolioAIParagraphBlock["kind"];
100
+ /** Exact authored numbering state; `inherit` means no direct override. */
101
+ statedNumbering: FolioAIParagraphBlock["statedNumbering"];
102
+ /** Effective numbering instance and zero-based level, when in a list. */
103
+ listReference?: NonNullable<FolioAIParagraphBlock["listReference"]>;
104
+ }) | (FolioAgentBlockFields & {
105
+ kind: FolioAIDiagnosticBlock["kind"];
106
+ });
101
107
  /** One main-story `find_text` match. Existing consumers can keep using its block and range directly. */
102
108
  type FolioAgentTextMatch = {
103
109
  /** Present on results from the current executor; optional for source compatibility with older hosts. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-agents",
3
- "version": "0.15.5",
3
+ "version": "0.16.1",
4
4
  "description": "Framework-neutral LLM tool layer over folio's ai-edits engine: function-calling tools so an agent can read and mutate .docx documents through @stll/folio-core.",
5
5
  "keywords": [
6
6
  "agent",
@@ -50,11 +50,11 @@
50
50
  "build": "rm -rf dist && tsdown",
51
51
  "prepack": "bun run build",
52
52
  "pack:dry-run": "bun pm pack --dry-run",
53
- "typecheck": "bun ../../scripts/tsc-native.ts --noEmit -p tsconfig.build.json",
53
+ "typecheck": "bun check --no-pretty --all --project=tsconfig.build.json",
54
54
  "test": "bun test src"
55
55
  },
56
56
  "dependencies": {
57
- "@stll/folio-core": "^0.58.0",
57
+ "@stll/folio-core": "^0.60.0",
58
58
  "better-result": "3.0.1"
59
59
  },
60
60
  "main": "./dist/index.js",
@@ -126,9 +126,14 @@ stay exported for validation-only paths.
126
126
  `read_comments`. Never invent or reuse one from outside the conversation;
127
127
  ids are opaque values a caller reads, never ones it constructs, and they
128
128
  change whenever the document's structure changes. The same holds for a
129
- numbering instance (`numbering.numId`): use one a list block of this
130
- document carries; an instance the document does not define skips the
131
- operation (`missingNumbering`) before anything is applied.
129
+ numbering reference: use `{ kind: "reference", numId, ilvl? }` with an
130
+ instance a list block of this document carries; an instance the document
131
+ does not define skips the operation (`missingNumbering`) before anything is
132
+ applied. Use `{ kind: "none" }` to cancel numbering or
133
+ `{ kind: "inherit" }` to remove the direct numbering override.
134
+ Use `{ kind: "levelOnly", ilvl }` to set a level without an instance, or
135
+ `{ kind: "newList", format: "numbered" | "bullet", level? }` to start a
136
+ new list.
132
137
  - A clause number ("clause 2.1") is found through a block's `displayLabel`,
133
138
  the number the document shows beside it; a numbered heading is
134
139
  `kind: "heading"` with its `headingLevel` and its number in `displayLabel`.
@@ -209,7 +214,7 @@ Two different questions, two different tools:
209
214
  changes right now: use the `read_changes` tool on a capable bridge or call
210
215
  `reviewer.getChanges()` directly.
211
216
  - **Between two saved `.docx` versions** — `compareDocxVersions(previousBuffer,
212
- currentBuffer)` + `formatVersionDiffForLLM(diff)`. Both are plain async
217
+ currentBuffer)` + `formatVersionDiffForLLM(diff)`. Both are plain async
213
218
  functions, not tool definitions: a model can't attach two buffers to one
214
219
  tool call (they aren't JSON-serializable arguments). Wrap them in a
215
220
  host-side tool keyed by version identifiers instead — the model calls it