@stll/folio-agents 0.11.2 → 0.12.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.
package/dist/compare.js CHANGED
@@ -18,14 +18,19 @@ const renderSegment = (segment) => {
18
18
  default: return "";
19
19
  }
20
20
  };
21
+ const renderChangedProperties = (properties) => properties && properties.length > 0 ? ` (${properties.join(", ")})` : "";
21
22
  const formatChangeLine = (change) => {
22
23
  switch (change.type) {
23
24
  case "added": return `+ [${change.blockId}] added: ${change.text}`;
24
25
  case "deleted": return `- [${change.blockId}] deleted: ${change.text}`;
25
- case "modified": return `~ [${change.blockId}] modified: ${change.segments.map(renderSegment).join("")}`;
26
+ case "modified": return `~ [${change.blockId}] modified${renderChangedProperties(change.changedProperties)}: ${change.segments.map(renderSegment).join("")}`;
26
27
  case "formatChanged": return `~ [${change.blockId}] format changed (${change.changedProperties.join(", ")}): ${truncateUnchangedRun(change.text)}`;
27
28
  case "movedFrom": return `< [${change.blockId}] moved away (move ${change.moveGroupId}): ${truncateUnchangedRun(change.text)}`;
28
- case "movedTo": return `> [${change.blockId}] moved here (move ${change.moveGroupId}): ${truncateUnchangedRun(change.text)}`;
29
+ case "movedTo": {
30
+ const changedProperties = change.changedProperties?.length ? `; changed: ${change.changedProperties.join(", ")}` : "";
31
+ const content = change.segments ? change.segments.map(renderSegment).join("") : truncateUnchangedRun(change.text);
32
+ return `> [${change.blockId}] moved here (move ${change.moveGroupId}${changedProperties}): ${content}`;
33
+ }
29
34
  default: return "";
30
35
  }
31
36
  };
package/dist/execute.js CHANGED
@@ -282,6 +282,7 @@ const explainSkipReason = (reason) => {
282
282
  if (reason === "preconditionFailed") return "the target block changed after the operation was prepared; re-read the document and retry with a fresh operation.";
283
283
  if (reason === "staleRange") return "the selected range changed or shifted; run find_text again and retry with the fresh range.";
284
284
  if (reason === "emptyOperation") return "this operation has no effect; nothing to apply.";
285
+ if (reason === "pendingParagraphPropertyChange") return "this paragraph already has an unresolved tracked formatting change; accept or reject that change before retrying.";
285
286
  if (reason === "noopOperation") return "this operation would not change the document (the text already matches what you asked for).";
286
287
  if (reason === "documentVersionMismatch") return "the document changed after these edits were proposed; re-read it and regenerate the edits against the current version.";
287
288
  if (reason === "documentNotEditable") return "the document is not open for editing right now; nothing was applied or queued. Ask the user to open it for editing, then retry.";
@@ -6,6 +6,7 @@ type FolioJsonSchema = {
6
6
  readonly description?: string;
7
7
  readonly enum?: readonly unknown[];
8
8
  readonly minimum?: number;
9
+ readonly maximum?: number;
9
10
  readonly minLength?: number;
10
11
  readonly minProperties?: number;
11
12
  readonly pattern?: string;
@@ -32,6 +33,68 @@ declare const FOLIO_TEXT_RANGE_JSON_SCHEMA: FolioJsonSchema;
32
33
  * `add_comment` without redeclaring it.
33
34
  */
34
35
  declare const FOLIO_PRECONDITION_JSON_SCHEMA: FolioJsonSchema;
36
+ declare const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA: {
37
+ readonly oneOf: readonly [{
38
+ readonly type: "string";
39
+ }, {
40
+ readonly type: "null";
41
+ }];
42
+ readonly description: "Paragraph style id; null clears the direct style.";
43
+ };
44
+ declare const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA: {
45
+ readonly oneOf: readonly [{
46
+ readonly type: "integer";
47
+ readonly minimum: 0;
48
+ readonly maximum: number;
49
+ }, {
50
+ readonly type: "null";
51
+ }];
52
+ readonly description: "`w:numPr/w:ilvl`, zero-based; a number retains the paragraph or anchor's numbering instance (`numId`), while null removes paragraph numbering.";
53
+ };
54
+ /** Complete direct `w:spacing` attributes, or null to restore style inheritance. */
55
+ declare const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA: {
56
+ readonly oneOf: readonly [{
57
+ readonly type: "object";
58
+ readonly properties: {
59
+ readonly spaceBefore: {
60
+ readonly type: "integer";
61
+ readonly minimum: 0;
62
+ readonly maximum: number;
63
+ readonly description: "Non-negative space before, in twips.";
64
+ };
65
+ readonly spaceAfter: {
66
+ readonly type: "integer";
67
+ readonly minimum: 0;
68
+ readonly maximum: number;
69
+ readonly description: "Non-negative space after, in twips.";
70
+ };
71
+ readonly lineSpacing: {
72
+ readonly type: "integer";
73
+ readonly minimum: number;
74
+ readonly maximum: number;
75
+ readonly description: "Signed line spacing: 240ths of a line with the auto rule, otherwise twips.";
76
+ };
77
+ readonly lineSpacingRule: {
78
+ readonly type: "string";
79
+ readonly enum: readonly ("auto" | "exact" | "atLeast")[];
80
+ readonly description: "How `lineSpacing` is interpreted.";
81
+ };
82
+ readonly beforeAutospacing: {
83
+ readonly type: "boolean";
84
+ readonly description: "Whether the application determines spacing before automatically.";
85
+ };
86
+ readonly afterAutospacing: {
87
+ readonly type: "boolean";
88
+ readonly description: "Whether the application determines spacing after automatically.";
89
+ };
90
+ };
91
+ readonly minProperties: 1;
92
+ readonly additionalProperties: false;
93
+ }, {
94
+ readonly type: "null";
95
+ }];
96
+ readonly description: "Complete direct paragraph spacing (`w:spacing`); omitted attributes stay absent, while zero and false remain explicit. Null removes the direct spacing child and restores style inheritance.";
97
+ };
35
98
  /**
36
99
  * JSON Schema (draft-07 compatible) for ONE document operation: the full
37
100
  * union accepted by `parseFolioDocumentOperationBatch` in
@@ -100,4 +163,4 @@ type FolioDocumentOperationBatchSchema = StandardSchemaV1<unknown, FolioDocument
100
163
  */
101
164
  declare const folioDocumentOperationBatchSchema: FolioDocumentOperationBatchSchema;
102
165
  //#endregion
103
- export { FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, FolioJsonSchema, folioDocumentOperationBatchSchema };
166
+ export { FOLIO_CLEARABLE_LIST_LEVEL_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_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, FolioJsonSchema, folioDocumentOperationBatchSchema };
@@ -1,4 +1,4 @@
1
- import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, parseFolioDocumentOperationBatch } from "@stll/folio-core/server";
1
+ import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, parseFolioDocumentOperationBatch } from "@stll/folio-core/server";
2
2
  //#region src/operation-schema.ts
3
3
  /**
4
4
  * Reusable projections of folio's versioned document-operation contract for
@@ -46,11 +46,13 @@ const FOLIO_TEXT_RANGE_JSON_SCHEMA = {
46
46
  },
47
47
  startOffset: {
48
48
  type: "integer",
49
- minimum: 0
49
+ minimum: 0,
50
+ maximum: Number.MAX_SAFE_INTEGER
50
51
  },
51
52
  endOffset: {
52
53
  type: "integer",
53
54
  minimum: 1,
55
+ maximum: Number.MAX_SAFE_INTEGER,
54
56
  description: "Exclusive end offset; must be greater than `startOffset`."
55
57
  },
56
58
  selectedTextHash: {
@@ -131,6 +133,60 @@ const blockIdProperty = {
131
133
  type: "string",
132
134
  description: "Id of the target block, from a prior document read."
133
135
  };
136
+ const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA = {
137
+ oneOf: [{ type: "string" }, { type: "null" }],
138
+ description: "Paragraph style id; null clears the direct style."
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."
147
+ };
148
+ /** Complete direct `w:spacing` attributes, or null to restore style inheritance. */
149
+ const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA = {
150
+ oneOf: [{
151
+ type: "object",
152
+ properties: {
153
+ spaceBefore: {
154
+ type: "integer",
155
+ minimum: 0,
156
+ maximum: Number.MAX_SAFE_INTEGER,
157
+ description: "Non-negative space before, in twips."
158
+ },
159
+ spaceAfter: {
160
+ type: "integer",
161
+ minimum: 0,
162
+ maximum: Number.MAX_SAFE_INTEGER,
163
+ description: "Non-negative space after, in twips."
164
+ },
165
+ lineSpacing: {
166
+ type: "integer",
167
+ minimum: Number.MIN_SAFE_INTEGER,
168
+ maximum: Number.MAX_SAFE_INTEGER,
169
+ description: "Signed line spacing: 240ths of a line with the auto rule, otherwise twips."
170
+ },
171
+ lineSpacingRule: {
172
+ type: "string",
173
+ enum: FOLIO_LINE_SPACING_RULE_VALUES,
174
+ description: "How `lineSpacing` is interpreted."
175
+ },
176
+ beforeAutospacing: {
177
+ type: "boolean",
178
+ description: "Whether the application determines spacing before automatically."
179
+ },
180
+ afterAutospacing: {
181
+ type: "boolean",
182
+ description: "Whether the application determines spacing after automatically."
183
+ }
184
+ },
185
+ minProperties: 1,
186
+ additionalProperties: false
187
+ }, { type: "null" }],
188
+ description: "Complete direct paragraph spacing (`w:spacing`); omitted attributes stay absent, while zero and false remain explicit. Null removes the direct spacing child and restores style inheritance."
189
+ };
134
190
  /**
135
191
  * JSON Schema (draft-07 compatible) for ONE document operation: the full
136
192
  * union accepted by `parseFolioDocumentOperationBatch` in
@@ -262,7 +318,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
262
318
  blockId: blockIdProperty,
263
319
  text: {
264
320
  type: "string",
265
- 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 — only the first paragraph gets `styleId` / `inheritFormatting`, later ones use body formatting. Prefer one paragraph per operation; only rely on the split for a heading immediately followed by its body text."
321
+ 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 — only the first paragraph gets `styleId` / `alignment` / `spacing` / `inheritFormatting`, later ones use body formatting. Prefer one paragraph per operation; only rely on the split for a heading immediately followed by its body text."
266
322
  },
267
323
  inheritFormatting: {
268
324
  type: "boolean",
@@ -272,15 +328,16 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
272
328
  type: "boolean",
273
329
  description: "Start the inserted paragraph on a new page (`pageBreakBefore`)."
274
330
  },
275
- styleId: {
276
- type: "string",
277
- description: "Paragraph style id for the inserted block (e.g. \"ClauseHeading1\")."
278
- },
279
- listLevel: {
280
- type: "integer",
281
- minimum: 0,
282
- description: "`w:numPr/w:ilvl` for the inserted block, keeping the anchor's list."
331
+ styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
332
+ listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
333
+ alignment: {
334
+ oneOf: [{
335
+ type: "string",
336
+ enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
337
+ }, { type: "null" }],
338
+ description: "Direct paragraph alignment; null restores style inheritance."
283
339
  },
340
+ spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
284
341
  moveId: {
285
342
  type: "string",
286
343
  description: "Links this operation to the other half of one relocation: a `deleteBlock` and an insertion sharing a `moveId` are written as `w:moveFrom` / `w:moveTo`. An id that does not name exactly one of each applies as an ordinary edit."
@@ -308,7 +365,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
308
365
  blockId: blockIdProperty,
309
366
  text: {
310
367
  type: "string",
311
- 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 — only the first paragraph gets `styleId` / `inheritFormatting`, later ones use body formatting. Prefer one paragraph per operation; only rely on the split for a heading immediately followed by its body text."
368
+ 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 — only the first paragraph gets `styleId` / `alignment` / `spacing` / `inheritFormatting`, later ones use body formatting. Prefer one paragraph per operation; only rely on the split for a heading immediately followed by its body text."
312
369
  },
313
370
  inheritFormatting: {
314
371
  type: "boolean",
@@ -318,15 +375,16 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
318
375
  type: "boolean",
319
376
  description: "Start the inserted paragraph on a new page (`pageBreakBefore`)."
320
377
  },
321
- styleId: {
322
- type: "string",
323
- description: "Paragraph style id for the inserted block (e.g. \"ClauseHeading1\")."
324
- },
325
- listLevel: {
326
- type: "integer",
327
- minimum: 0,
328
- description: "`w:numPr/w:ilvl` for the inserted block, keeping the anchor's list."
378
+ styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
379
+ listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
380
+ alignment: {
381
+ oneOf: [{
382
+ type: "string",
383
+ enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
384
+ }, { type: "null" }],
385
+ description: "Direct paragraph alignment; null restores style inheritance."
329
386
  },
387
+ spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
330
388
  moveId: {
331
389
  type: "string",
332
390
  description: "Links this operation to the other half of one relocation: a `deleteBlock` and an insertion sharing a `moveId` are written as `w:moveFrom` / `w:moveTo`. An id that does not name exactly one of each applies as an ordinary edit."
@@ -360,10 +418,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
360
418
  type: "boolean",
361
419
  description: "Keep the block's existing formatting for the replacement text."
362
420
  },
363
- styleId: {
364
- type: "string",
365
- description: "Paragraph style id to set on the replaced block."
366
- },
421
+ styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
367
422
  comment: commentJsonSchema
368
423
  },
369
424
  required: [
@@ -412,6 +467,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
412
467
  offset: {
413
468
  type: "integer",
414
469
  minimum: 0,
470
+ maximum: Number.MAX_SAFE_INTEGER,
415
471
  description: "Character offset in the block's text where the break goes. Must fall strictly inside it."
416
472
  },
417
473
  separator: {
@@ -465,15 +521,16 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
465
521
  type: "object",
466
522
  description: "The paragraph properties to set; at least one.",
467
523
  properties: {
468
- styleId: {
469
- type: "string",
470
- description: "Paragraph style id (e.g. \"ClauseHeading1\")."
524
+ styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
525
+ listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
526
+ alignment: {
527
+ oneOf: [{
528
+ type: "string",
529
+ enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
530
+ }, { type: "null" }],
531
+ description: "Direct paragraph alignment; null restores style inheritance."
471
532
  },
472
- listLevel: {
473
- type: "integer",
474
- minimum: 0,
475
- description: "`w:numPr/w:ilvl`, the zero-based list indent level."
476
- }
533
+ spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA
477
534
  },
478
535
  minProperties: 1,
479
536
  additionalProperties: false
@@ -728,6 +785,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
728
785
  rowCount: {
729
786
  type: "integer",
730
787
  minimum: 2,
788
+ maximum: Number.MAX_SAFE_INTEGER,
731
789
  description: "Number of grid rows to merge downward from the anchored cell."
732
790
  }
733
791
  },
@@ -863,4 +921,4 @@ const folioDocumentOperationBatchSchema = {
863
921
  jsonSchema: FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA
864
922
  };
865
923
  //#endregion
866
- export { FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, folioDocumentOperationBatchSchema };
924
+ export { FOLIO_CLEARABLE_LIST_LEVEL_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_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, folioDocumentOperationBatchSchema };
package/dist/tools.js CHANGED
@@ -1,9 +1,9 @@
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_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA } from "./operation-schema.js";
2
+ import { FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_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";
6
- import { FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE } from "@stll/folio-core/server";
6
+ import { FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_PARAGRAPH_ALIGNMENT_VALUES } from "@stll/folio-core/server";
7
7
  //#region src/tools.ts
8
8
  /**
9
9
  * `suggest_changes` is a host-configurable projection of the document-operation
@@ -25,13 +25,13 @@ const OPERATION_TYPE_SUMMARIES = {
25
25
  replaceRange: "replace the text covered by a `range` copied from find_text",
26
26
  commentOnRange: "attach a comment to a `range` copied from find_text",
27
27
  formatRange: "toggle bold, italic, or underline on a `range` copied from find_text",
28
- insertAfterBlock: "insert a new paragraph after a block",
29
- insertBeforeBlock: "insert a new paragraph before a block",
28
+ insertAfterBlock: "insert a new paragraph after a block, with optional direct alignment and spacing",
29
+ insertBeforeBlock: "insert a new paragraph before a block, with optional direct alignment and spacing",
30
30
  replaceBlock: "replace one block's entire text",
31
31
  deleteBlock: "delete one block",
32
32
  splitBlock: "break one block in two at `offset`, moving a paragraph mark and no words",
33
33
  mergeBlockWithNext: "join one block with the block after it in the same container",
34
- setBlockParagraphProperties: "change one block's paragraph properties (list level, paragraph style) without touching its words",
34
+ setBlockParagraphProperties: "change one block's paragraph properties (list level, paragraph style, direct alignment or spacing) without touching its words",
35
35
  insertTable: "insert a whole table of `rows` next to the anchor block",
36
36
  deleteTable: "delete the whole table the anchor block sits in",
37
37
  commentOnBlock: "attach a comment to one block, optionally quoting text within it",
@@ -81,6 +81,7 @@ const OPERATION_PROPERTY_SCHEMAS = {
81
81
  rowCount: {
82
82
  type: "integer",
83
83
  minimum: 2,
84
+ maximum: Number.MAX_SAFE_INTEGER,
84
85
  description: "For vertical cell merging, the number of grid rows to merge downward."
85
86
  },
86
87
  range: {
@@ -103,10 +104,7 @@ const OPERATION_PROPERTY_SCHEMAS = {
103
104
  type: "string",
104
105
  description: "For `commentOnBlock`: optional exact text within the block the comment is about, up to 100,000 characters."
105
106
  },
106
- styleId: {
107
- type: "string",
108
- description: "For inserts and `replaceBlock`: paragraph style id to apply (e.g. a clause-heading style from the document)."
109
- },
107
+ styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
110
108
  pageBreakBefore: {
111
109
  type: "boolean",
112
110
  description: "For inserts: start the inserted paragraph on a new page."
@@ -115,6 +113,14 @@ const OPERATION_PROPERTY_SCHEMAS = {
115
113
  type: "boolean",
116
114
  description: "For inserts: inherit the anchor block's formatting for the inserted paragraph."
117
115
  },
116
+ alignment: {
117
+ oneOf: [{
118
+ type: "string",
119
+ enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
120
+ }, { type: "null" }],
121
+ description: "For inserts: direct paragraph alignment; null restores style inheritance."
122
+ },
123
+ spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
118
124
  preserveFormatting: {
119
125
  type: "boolean",
120
126
  description: "For `replaceBlock`: keep the block's existing formatting for the replacement text."
@@ -174,29 +180,27 @@ const OPERATION_PROPERTY_SCHEMAS = {
174
180
  },
175
181
  properties: {
176
182
  type: "object",
177
- description: "Required for `setBlockParagraphProperties`: the paragraph properties to set. `styleId: null` clears the style.",
183
+ description: "Required for `setBlockParagraphProperties`: the paragraph properties to set. Null clears a direct property.",
178
184
  properties: {
179
- styleId: {
180
- type: "string",
181
- description: "Paragraph style id."
185
+ styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
186
+ listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
187
+ alignment: {
188
+ oneOf: [{
189
+ type: "string",
190
+ enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
191
+ }, { type: "null" }],
192
+ description: "Direct paragraph alignment; null restores style inheritance."
182
193
  },
183
- listLevel: {
184
- type: "integer",
185
- minimum: 0,
186
- description: "`w:numPr/w:ilvl`, zero-based."
187
- }
194
+ spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA
188
195
  },
189
196
  minProperties: 1,
190
197
  additionalProperties: false
191
198
  },
192
- listLevel: {
193
- type: "integer",
194
- minimum: 0,
195
- description: "For inserts: `w:numPr/w:ilvl` for the inserted block, keeping the anchor's list."
196
- },
199
+ listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
197
200
  offset: {
198
201
  type: "integer",
199
202
  minimum: 0,
203
+ maximum: Number.MAX_SAFE_INTEGER,
200
204
  description: "Required for `splitBlock`: character offset in the block's text where the paragraph break goes. Must fall strictly inside the text."
201
205
  },
202
206
  separator: {
@@ -252,11 +256,13 @@ const describeResolvedCapabilities = (resolved) => {
252
256
  const lines = [`Supported operations: ${summarizeOperationTypes(resolved.operationTypes)}.`];
253
257
  const styleIdTargets = [...hasAnyType(resolved, ["insertAfterBlock", "insertBeforeBlock"]) ? ["an insert"] : [], ...hasAnyType(resolved, ["replaceBlock"]) ? ["replaceBlock"] : []];
254
258
  if (styleIdTargets.length > 0) {
255
- const pageBreak = hasAnyType(resolved, ["insertAfterBlock", "insertBeforeBlock"]) ? "set `pageBreakBefore: true` on an insert to start it on a new page; " : "";
256
- lines.push(`Structural edits: ${pageBreak}set \`styleId\` on ${styleIdTargets.join(" or ")} to apply a paragraph style such as a clause heading. Never emit directive markers or markdown syntax as paragraph text.`);
259
+ const supportsInsert = hasAnyType(resolved, ["insertAfterBlock", "insertBeforeBlock"]);
260
+ const pageBreak = supportsInsert ? "set `pageBreakBefore: true` on an insert to start it on a new page; " : "";
261
+ const insertAlignment = supportsInsert ? " Inserts also accept direct `alignment` and `spacing`, with null restoring style inheritance." : "";
262
+ lines.push(`Structural edits: ${pageBreak}set \`styleId\` on ${styleIdTargets.join(" or ")} to apply a paragraph style such as a clause heading.${insertAlignment} Never emit directive markers or markdown syntax as paragraph text.`);
257
263
  }
258
264
  if (hasAnyType(resolved, ["insertSignatureTable"])) lines.push("Signature blocks: use insertSignatureTable with `parties`; never draw one out of paragraphs.");
259
- if (!hasAnyType(resolved, ["formatRange"])) lines.push("This surface cannot change run formatting (fonts, bold/italic/underline, size, colour, alignment, spacing, list style); do not promise formatting changes.");
265
+ if (!hasAnyType(resolved, ["formatRange"])) lines.push("This surface cannot change run formatting (fonts, bold/italic/underline, size, or colour); do not promise run-formatting changes.");
260
266
  lines.push(`Limits: at most ${resolved.maxOperations} operations per call (batch larger edits across calls); each text field at most 100,000 characters.`);
261
267
  lines.push(resolved.reviewMeta === "required" ? "Every operation must set `severity` (low, medium, or high) and a short `area` label; the review queue sorts and groups by them." : "Set `severity` and `area` on operations when the edit is part of a structured review.");
262
268
  if (resolved.documentVersion !== null) lines.push("Pass `documentVersion` exactly as given in this tool's schema; the batch is skipped as a whole when the document has moved on since.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-agents",
3
- "version": "0.11.2",
3
+ "version": "0.12.0",
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",
@@ -54,7 +54,7 @@
54
54
  "test": "bun test src"
55
55
  },
56
56
  "dependencies": {
57
- "@stll/folio-core": "^0.35.0",
57
+ "@stll/folio-core": "^0.37.0",
58
58
  "better-result": "3.0.1"
59
59
  },
60
60
  "main": "./dist/index.js",