@stll/folio-agents 0.11.3 → 0.12.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/dist/compare.js +7 -2
- package/dist/execute.js +1 -0
- package/dist/operation-schema.d.ts +125 -1
- package/dist/operation-schema.js +86 -23
- package/dist/tools.js +22 -20
- package/package.json +2 -2
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":
|
|
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;
|
|
@@ -44,11 +45,134 @@ declare const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA: {
|
|
|
44
45
|
readonly oneOf: readonly [{
|
|
45
46
|
readonly type: "integer";
|
|
46
47
|
readonly minimum: 0;
|
|
48
|
+
readonly maximum: number;
|
|
47
49
|
}, {
|
|
48
50
|
readonly type: "null";
|
|
49
51
|
}];
|
|
50
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.";
|
|
51
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
|
+
};
|
|
98
|
+
declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
|
|
99
|
+
readonly type: "object";
|
|
100
|
+
readonly description: "The paragraph properties to set; at least one.";
|
|
101
|
+
readonly properties: {
|
|
102
|
+
readonly styleId: {
|
|
103
|
+
readonly oneOf: readonly [{
|
|
104
|
+
readonly type: "string";
|
|
105
|
+
}, {
|
|
106
|
+
readonly type: "null";
|
|
107
|
+
}];
|
|
108
|
+
readonly description: "Paragraph style id; null clears the direct style.";
|
|
109
|
+
};
|
|
110
|
+
readonly listLevel: {
|
|
111
|
+
readonly oneOf: readonly [{
|
|
112
|
+
readonly type: "integer";
|
|
113
|
+
readonly minimum: 0;
|
|
114
|
+
readonly maximum: number;
|
|
115
|
+
}, {
|
|
116
|
+
readonly type: "null";
|
|
117
|
+
}];
|
|
118
|
+
readonly description: "`w:numPr/w:ilvl`, zero-based; a number retains the paragraph or anchor's numbering instance (`numId`), while null removes paragraph numbering.";
|
|
119
|
+
};
|
|
120
|
+
readonly alignment: {
|
|
121
|
+
readonly oneOf: readonly [{
|
|
122
|
+
readonly type: "string";
|
|
123
|
+
readonly enum: readonly ("left" | "center" | "right" | "both" | "distribute" | "mediumKashida" | "highKashida" | "lowKashida" | "thaiDistribute")[];
|
|
124
|
+
}, {
|
|
125
|
+
readonly type: "null";
|
|
126
|
+
}];
|
|
127
|
+
readonly description: "Direct paragraph alignment; null restores style inheritance.";
|
|
128
|
+
};
|
|
129
|
+
readonly spacing: {
|
|
130
|
+
readonly oneOf: readonly [{
|
|
131
|
+
readonly type: "object";
|
|
132
|
+
readonly properties: {
|
|
133
|
+
readonly spaceBefore: {
|
|
134
|
+
readonly type: "integer";
|
|
135
|
+
readonly minimum: 0;
|
|
136
|
+
readonly maximum: number;
|
|
137
|
+
readonly description: "Non-negative space before, in twips.";
|
|
138
|
+
};
|
|
139
|
+
readonly spaceAfter: {
|
|
140
|
+
readonly type: "integer";
|
|
141
|
+
readonly minimum: 0;
|
|
142
|
+
readonly maximum: number;
|
|
143
|
+
readonly description: "Non-negative space after, in twips.";
|
|
144
|
+
};
|
|
145
|
+
readonly lineSpacing: {
|
|
146
|
+
readonly type: "integer";
|
|
147
|
+
readonly minimum: number;
|
|
148
|
+
readonly maximum: number;
|
|
149
|
+
readonly description: "Signed line spacing: 240ths of a line with the auto rule, otherwise twips.";
|
|
150
|
+
};
|
|
151
|
+
readonly lineSpacingRule: {
|
|
152
|
+
readonly type: "string";
|
|
153
|
+
readonly enum: readonly ("auto" | "exact" | "atLeast")[];
|
|
154
|
+
readonly description: "How `lineSpacing` is interpreted.";
|
|
155
|
+
};
|
|
156
|
+
readonly beforeAutospacing: {
|
|
157
|
+
readonly type: "boolean";
|
|
158
|
+
readonly description: "Whether the application determines spacing before automatically.";
|
|
159
|
+
};
|
|
160
|
+
readonly afterAutospacing: {
|
|
161
|
+
readonly type: "boolean";
|
|
162
|
+
readonly description: "Whether the application determines spacing after automatically.";
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
readonly minProperties: 1;
|
|
166
|
+
readonly additionalProperties: false;
|
|
167
|
+
}, {
|
|
168
|
+
readonly type: "null";
|
|
169
|
+
}];
|
|
170
|
+
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.";
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
readonly minProperties: 1;
|
|
174
|
+
readonly additionalProperties: false;
|
|
175
|
+
};
|
|
52
176
|
/**
|
|
53
177
|
* JSON Schema (draft-07 compatible) for ONE document operation: the full
|
|
54
178
|
* union accepted by `parseFolioDocumentOperationBatch` in
|
|
@@ -117,4 +241,4 @@ type FolioDocumentOperationBatchSchema = StandardSchemaV1<unknown, FolioDocument
|
|
|
117
241
|
*/
|
|
118
242
|
declare const folioDocumentOperationBatchSchema: FolioDocumentOperationBatchSchema;
|
|
119
243
|
//#endregion
|
|
120
|
-
export { FOLIO_CLEARABLE_LIST_LEVEL_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 };
|
|
244
|
+
export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, 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 };
|
package/dist/operation-schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, 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: {
|
|
@@ -138,10 +140,71 @@ const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA = {
|
|
|
138
140
|
const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA = {
|
|
139
141
|
oneOf: [{
|
|
140
142
|
type: "integer",
|
|
141
|
-
minimum: 0
|
|
143
|
+
minimum: 0,
|
|
144
|
+
maximum: Number.MAX_SAFE_INTEGER
|
|
142
145
|
}, { type: "null" }],
|
|
143
146
|
description: "`w:numPr/w:ilvl`, zero-based; a number retains the paragraph or anchor's numbering instance (`numId`), while null removes paragraph numbering."
|
|
144
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
|
+
};
|
|
190
|
+
const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA = {
|
|
191
|
+
type: "object",
|
|
192
|
+
description: "The paragraph properties to set; at least one.",
|
|
193
|
+
properties: {
|
|
194
|
+
styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
|
|
195
|
+
listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
|
|
196
|
+
alignment: {
|
|
197
|
+
oneOf: [{
|
|
198
|
+
type: "string",
|
|
199
|
+
enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
|
|
200
|
+
}, { type: "null" }],
|
|
201
|
+
description: "Direct paragraph alignment; null restores style inheritance."
|
|
202
|
+
},
|
|
203
|
+
spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA
|
|
204
|
+
},
|
|
205
|
+
minProperties: 1,
|
|
206
|
+
additionalProperties: false
|
|
207
|
+
};
|
|
145
208
|
/**
|
|
146
209
|
* JSON Schema (draft-07 compatible) for ONE document operation: the full
|
|
147
210
|
* union accepted by `parseFolioDocumentOperationBatch` in
|
|
@@ -273,7 +336,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
273
336
|
blockId: blockIdProperty,
|
|
274
337
|
text: {
|
|
275
338
|
type: "string",
|
|
276
|
-
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` / `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."
|
|
339
|
+
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."
|
|
277
340
|
},
|
|
278
341
|
inheritFormatting: {
|
|
279
342
|
type: "boolean",
|
|
@@ -292,6 +355,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
292
355
|
}, { type: "null" }],
|
|
293
356
|
description: "Direct paragraph alignment; null restores style inheritance."
|
|
294
357
|
},
|
|
358
|
+
spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
|
|
295
359
|
moveId: {
|
|
296
360
|
type: "string",
|
|
297
361
|
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."
|
|
@@ -319,7 +383,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
319
383
|
blockId: blockIdProperty,
|
|
320
384
|
text: {
|
|
321
385
|
type: "string",
|
|
322
|
-
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` / `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."
|
|
386
|
+
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."
|
|
323
387
|
},
|
|
324
388
|
inheritFormatting: {
|
|
325
389
|
type: "boolean",
|
|
@@ -338,6 +402,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
338
402
|
}, { type: "null" }],
|
|
339
403
|
description: "Direct paragraph alignment; null restores style inheritance."
|
|
340
404
|
},
|
|
405
|
+
spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
|
|
341
406
|
moveId: {
|
|
342
407
|
type: "string",
|
|
343
408
|
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."
|
|
@@ -420,11 +485,20 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
420
485
|
offset: {
|
|
421
486
|
type: "integer",
|
|
422
487
|
minimum: 0,
|
|
488
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
423
489
|
description: "Character offset in the block's text where the break goes. Must fall strictly inside it."
|
|
424
490
|
},
|
|
425
491
|
separator: {
|
|
426
492
|
type: "string",
|
|
427
493
|
description: "Text at `offset` the break replaces, usually the space between the halves."
|
|
494
|
+
},
|
|
495
|
+
firstParagraphProperties: {
|
|
496
|
+
...FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA,
|
|
497
|
+
description: "Properties for the first result; omitted properties keep the source paragraph's value."
|
|
498
|
+
},
|
|
499
|
+
secondParagraphProperties: {
|
|
500
|
+
...FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA,
|
|
501
|
+
description: "Properties for the second result; omitted properties keep the source paragraph's value."
|
|
428
502
|
}
|
|
429
503
|
},
|
|
430
504
|
required: [
|
|
@@ -449,6 +523,10 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
449
523
|
separator: {
|
|
450
524
|
type: "string",
|
|
451
525
|
description: "Text the join inserts between the two halves, usually a space."
|
|
526
|
+
},
|
|
527
|
+
mergedParagraphProperties: {
|
|
528
|
+
...FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA,
|
|
529
|
+
description: "Properties for the joined result; omitted properties keep the first paragraph's value."
|
|
452
530
|
}
|
|
453
531
|
},
|
|
454
532
|
required: [
|
|
@@ -469,23 +547,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
469
547
|
enum: ["setBlockParagraphProperties"]
|
|
470
548
|
},
|
|
471
549
|
blockId: blockIdProperty,
|
|
472
|
-
properties:
|
|
473
|
-
type: "object",
|
|
474
|
-
description: "The paragraph properties to set; at least one.",
|
|
475
|
-
properties: {
|
|
476
|
-
styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
|
|
477
|
-
listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
|
|
478
|
-
alignment: {
|
|
479
|
-
oneOf: [{
|
|
480
|
-
type: "string",
|
|
481
|
-
enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
|
|
482
|
-
}, { type: "null" }],
|
|
483
|
-
description: "Direct paragraph alignment; null restores style inheritance."
|
|
484
|
-
}
|
|
485
|
-
},
|
|
486
|
-
minProperties: 1,
|
|
487
|
-
additionalProperties: false
|
|
488
|
-
}
|
|
550
|
+
properties: FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA
|
|
489
551
|
},
|
|
490
552
|
required: [
|
|
491
553
|
"id",
|
|
@@ -736,6 +798,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
736
798
|
rowCount: {
|
|
737
799
|
type: "integer",
|
|
738
800
|
minimum: 2,
|
|
801
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
739
802
|
description: "Number of grid rows to merge downward from the anchored cell."
|
|
740
803
|
}
|
|
741
804
|
},
|
|
@@ -871,4 +934,4 @@ const folioDocumentOperationBatchSchema = {
|
|
|
871
934
|
jsonSchema: FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA
|
|
872
935
|
};
|
|
873
936
|
//#endregion
|
|
874
|
-
export { FOLIO_CLEARABLE_LIST_LEVEL_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 };
|
|
937
|
+
export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, 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,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_CLEARABLE_LIST_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_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_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";
|
|
@@ -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, with optional direct alignment",
|
|
29
|
-
insertBeforeBlock: "insert a new paragraph before a block, with optional direct alignment",
|
|
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, direct alignment) 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: {
|
|
@@ -119,6 +120,7 @@ const OPERATION_PROPERTY_SCHEMAS = {
|
|
|
119
120
|
}, { type: "null" }],
|
|
120
121
|
description: "For inserts: direct paragraph alignment; null restores style inheritance."
|
|
121
122
|
},
|
|
123
|
+
spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
|
|
122
124
|
preserveFormatting: {
|
|
123
125
|
type: "boolean",
|
|
124
126
|
description: "For `replaceBlock`: keep the block's existing formatting for the replacement text."
|
|
@@ -177,26 +179,26 @@ const OPERATION_PROPERTY_SCHEMAS = {
|
|
|
177
179
|
additionalProperties: false
|
|
178
180
|
},
|
|
179
181
|
properties: {
|
|
180
|
-
|
|
181
|
-
description: "Required for `setBlockParagraphProperties`: the paragraph properties to set. Null clears a direct property."
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
additionalProperties: false
|
|
182
|
+
...FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA,
|
|
183
|
+
description: "Required for `setBlockParagraphProperties`: the paragraph properties to set. Null clears a direct property."
|
|
184
|
+
},
|
|
185
|
+
firstParagraphProperties: {
|
|
186
|
+
...FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA,
|
|
187
|
+
description: "For `splitBlock`, properties for the first result; omitted properties keep the source paragraph's value."
|
|
188
|
+
},
|
|
189
|
+
secondParagraphProperties: {
|
|
190
|
+
...FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA,
|
|
191
|
+
description: "For `splitBlock`, properties for the second result; omitted properties keep the source paragraph's value."
|
|
192
|
+
},
|
|
193
|
+
mergedParagraphProperties: {
|
|
194
|
+
...FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA,
|
|
195
|
+
description: "For `mergeBlockWithNext`, properties for the joined result; omitted properties keep the first paragraph's value."
|
|
195
196
|
},
|
|
196
197
|
listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
|
|
197
198
|
offset: {
|
|
198
199
|
type: "integer",
|
|
199
200
|
minimum: 0,
|
|
201
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
200
202
|
description: "Required for `splitBlock`: character offset in the block's text where the paragraph break goes. Must fall strictly inside the text."
|
|
201
203
|
},
|
|
202
204
|
separator: {
|
|
@@ -254,7 +256,7 @@ const describeResolvedCapabilities = (resolved) => {
|
|
|
254
256
|
if (styleIdTargets.length > 0) {
|
|
255
257
|
const supportsInsert = hasAnyType(resolved, ["insertAfterBlock", "insertBeforeBlock"]);
|
|
256
258
|
const pageBreak = supportsInsert ? "set `pageBreakBefore: true` on an insert to start it on a new page; " : "";
|
|
257
|
-
const insertAlignment = supportsInsert ? " Inserts also accept direct `alignment`, with null restoring style inheritance." : "";
|
|
259
|
+
const insertAlignment = supportsInsert ? " Inserts also accept direct `alignment` and `spacing`, with null restoring style inheritance." : "";
|
|
258
260
|
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.`);
|
|
259
261
|
}
|
|
260
262
|
if (hasAnyType(resolved, ["insertSignatureTable"])) lines.push("Signature blocks: use insertSignatureTable with `parties`; never draw one out of paragraphs.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"test": "bun test src"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@stll/folio-core": "^0.
|
|
57
|
+
"@stll/folio-core": "^0.37.1",
|
|
58
58
|
"better-result": "3.0.1"
|
|
59
59
|
},
|
|
60
60
|
"main": "./dist/index.js",
|