@stll/folio-agents 0.11.1 → 0.11.3
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/operation-schema.d.ts +18 -1
- package/dist/operation-schema.js +40 -32
- package/dist/tools.js +28 -26
- package/package.json +2 -2
|
@@ -32,6 +32,23 @@ declare const FOLIO_TEXT_RANGE_JSON_SCHEMA: FolioJsonSchema;
|
|
|
32
32
|
* `add_comment` without redeclaring it.
|
|
33
33
|
*/
|
|
34
34
|
declare const FOLIO_PRECONDITION_JSON_SCHEMA: FolioJsonSchema;
|
|
35
|
+
declare const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA: {
|
|
36
|
+
readonly oneOf: readonly [{
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
}, {
|
|
39
|
+
readonly type: "null";
|
|
40
|
+
}];
|
|
41
|
+
readonly description: "Paragraph style id; null clears the direct style.";
|
|
42
|
+
};
|
|
43
|
+
declare const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA: {
|
|
44
|
+
readonly oneOf: readonly [{
|
|
45
|
+
readonly type: "integer";
|
|
46
|
+
readonly minimum: 0;
|
|
47
|
+
}, {
|
|
48
|
+
readonly type: "null";
|
|
49
|
+
}];
|
|
50
|
+
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
|
+
};
|
|
35
52
|
/**
|
|
36
53
|
* JSON Schema (draft-07 compatible) for ONE document operation: the full
|
|
37
54
|
* union accepted by `parseFolioDocumentOperationBatch` in
|
|
@@ -100,4 +117,4 @@ type FolioDocumentOperationBatchSchema = StandardSchemaV1<unknown, FolioDocument
|
|
|
100
117
|
*/
|
|
101
118
|
declare const folioDocumentOperationBatchSchema: FolioDocumentOperationBatchSchema;
|
|
102
119
|
//#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 };
|
|
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 };
|
package/dist/operation-schema.js
CHANGED
|
@@ -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_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
|
|
@@ -131,6 +131,17 @@ const blockIdProperty = {
|
|
|
131
131
|
type: "string",
|
|
132
132
|
description: "Id of the target block, from a prior document read."
|
|
133
133
|
};
|
|
134
|
+
const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA = {
|
|
135
|
+
oneOf: [{ type: "string" }, { type: "null" }],
|
|
136
|
+
description: "Paragraph style id; null clears the direct style."
|
|
137
|
+
};
|
|
138
|
+
const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA = {
|
|
139
|
+
oneOf: [{
|
|
140
|
+
type: "integer",
|
|
141
|
+
minimum: 0
|
|
142
|
+
}, { type: "null" }],
|
|
143
|
+
description: "`w:numPr/w:ilvl`, zero-based; a number retains the paragraph or anchor's numbering instance (`numId`), while null removes paragraph numbering."
|
|
144
|
+
};
|
|
134
145
|
/**
|
|
135
146
|
* JSON Schema (draft-07 compatible) for ONE document operation: the full
|
|
136
147
|
* union accepted by `parseFolioDocumentOperationBatch` in
|
|
@@ -262,7 +273,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
262
273
|
blockId: blockIdProperty,
|
|
263
274
|
text: {
|
|
264
275
|
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."
|
|
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."
|
|
266
277
|
},
|
|
267
278
|
inheritFormatting: {
|
|
268
279
|
type: "boolean",
|
|
@@ -272,14 +283,14 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
272
283
|
type: "boolean",
|
|
273
284
|
description: "Start the inserted paragraph on a new page (`pageBreakBefore`)."
|
|
274
285
|
},
|
|
275
|
-
styleId:
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
description: "
|
|
286
|
+
styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
|
|
287
|
+
listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
|
|
288
|
+
alignment: {
|
|
289
|
+
oneOf: [{
|
|
290
|
+
type: "string",
|
|
291
|
+
enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
|
|
292
|
+
}, { type: "null" }],
|
|
293
|
+
description: "Direct paragraph alignment; null restores style inheritance."
|
|
283
294
|
},
|
|
284
295
|
moveId: {
|
|
285
296
|
type: "string",
|
|
@@ -308,7 +319,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
308
319
|
blockId: blockIdProperty,
|
|
309
320
|
text: {
|
|
310
321
|
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."
|
|
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."
|
|
312
323
|
},
|
|
313
324
|
inheritFormatting: {
|
|
314
325
|
type: "boolean",
|
|
@@ -318,14 +329,14 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
318
329
|
type: "boolean",
|
|
319
330
|
description: "Start the inserted paragraph on a new page (`pageBreakBefore`)."
|
|
320
331
|
},
|
|
321
|
-
styleId:
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
description: "
|
|
332
|
+
styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
|
|
333
|
+
listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
|
|
334
|
+
alignment: {
|
|
335
|
+
oneOf: [{
|
|
336
|
+
type: "string",
|
|
337
|
+
enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
|
|
338
|
+
}, { type: "null" }],
|
|
339
|
+
description: "Direct paragraph alignment; null restores style inheritance."
|
|
329
340
|
},
|
|
330
341
|
moveId: {
|
|
331
342
|
type: "string",
|
|
@@ -360,10 +371,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
360
371
|
type: "boolean",
|
|
361
372
|
description: "Keep the block's existing formatting for the replacement text."
|
|
362
373
|
},
|
|
363
|
-
styleId:
|
|
364
|
-
type: "string",
|
|
365
|
-
description: "Paragraph style id to set on the replaced block."
|
|
366
|
-
},
|
|
374
|
+
styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
|
|
367
375
|
comment: commentJsonSchema
|
|
368
376
|
},
|
|
369
377
|
required: [
|
|
@@ -465,14 +473,14 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
|
|
|
465
473
|
type: "object",
|
|
466
474
|
description: "The paragraph properties to set; at least one.",
|
|
467
475
|
properties: {
|
|
468
|
-
styleId:
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
description: "
|
|
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."
|
|
476
484
|
}
|
|
477
485
|
},
|
|
478
486
|
minProperties: 1,
|
|
@@ -863,4 +871,4 @@ const folioDocumentOperationBatchSchema = {
|
|
|
863
871
|
jsonSchema: FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA
|
|
864
872
|
};
|
|
865
873
|
//#endregion
|
|
866
|
-
export { FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, folioDocumentOperationBatchSchema };
|
|
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 };
|
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_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",
|
|
29
|
+
insertBeforeBlock: "insert a new paragraph before a block, with optional direct alignment",
|
|
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) 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",
|
|
@@ -103,10 +103,7 @@ const OPERATION_PROPERTY_SCHEMAS = {
|
|
|
103
103
|
type: "string",
|
|
104
104
|
description: "For `commentOnBlock`: optional exact text within the block the comment is about, up to 100,000 characters."
|
|
105
105
|
},
|
|
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
|
-
},
|
|
106
|
+
styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
|
|
110
107
|
pageBreakBefore: {
|
|
111
108
|
type: "boolean",
|
|
112
109
|
description: "For inserts: start the inserted paragraph on a new page."
|
|
@@ -115,6 +112,13 @@ const OPERATION_PROPERTY_SCHEMAS = {
|
|
|
115
112
|
type: "boolean",
|
|
116
113
|
description: "For inserts: inherit the anchor block's formatting for the inserted paragraph."
|
|
117
114
|
},
|
|
115
|
+
alignment: {
|
|
116
|
+
oneOf: [{
|
|
117
|
+
type: "string",
|
|
118
|
+
enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
|
|
119
|
+
}, { type: "null" }],
|
|
120
|
+
description: "For inserts: direct paragraph alignment; null restores style inheritance."
|
|
121
|
+
},
|
|
118
122
|
preserveFormatting: {
|
|
119
123
|
type: "boolean",
|
|
120
124
|
description: "For `replaceBlock`: keep the block's existing formatting for the replacement text."
|
|
@@ -174,26 +178,22 @@ const OPERATION_PROPERTY_SCHEMAS = {
|
|
|
174
178
|
},
|
|
175
179
|
properties: {
|
|
176
180
|
type: "object",
|
|
177
|
-
description: "Required for `setBlockParagraphProperties`: the paragraph properties to set.
|
|
181
|
+
description: "Required for `setBlockParagraphProperties`: the paragraph properties to set. Null clears a direct property.",
|
|
178
182
|
properties: {
|
|
179
|
-
styleId:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
description: "
|
|
183
|
+
styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
|
|
184
|
+
listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
|
|
185
|
+
alignment: {
|
|
186
|
+
oneOf: [{
|
|
187
|
+
type: "string",
|
|
188
|
+
enum: FOLIO_PARAGRAPH_ALIGNMENT_VALUES
|
|
189
|
+
}, { type: "null" }],
|
|
190
|
+
description: "Direct paragraph alignment; null restores style inheritance."
|
|
187
191
|
}
|
|
188
192
|
},
|
|
189
193
|
minProperties: 1,
|
|
190
194
|
additionalProperties: false
|
|
191
195
|
},
|
|
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
|
-
},
|
|
196
|
+
listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
|
|
197
197
|
offset: {
|
|
198
198
|
type: "integer",
|
|
199
199
|
minimum: 0,
|
|
@@ -252,11 +252,13 @@ const describeResolvedCapabilities = (resolved) => {
|
|
|
252
252
|
const lines = [`Supported operations: ${summarizeOperationTypes(resolved.operationTypes)}.`];
|
|
253
253
|
const styleIdTargets = [...hasAnyType(resolved, ["insertAfterBlock", "insertBeforeBlock"]) ? ["an insert"] : [], ...hasAnyType(resolved, ["replaceBlock"]) ? ["replaceBlock"] : []];
|
|
254
254
|
if (styleIdTargets.length > 0) {
|
|
255
|
-
const
|
|
256
|
-
|
|
255
|
+
const supportsInsert = hasAnyType(resolved, ["insertAfterBlock", "insertBeforeBlock"]);
|
|
256
|
+
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." : "";
|
|
258
|
+
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
259
|
}
|
|
258
260
|
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
|
|
261
|
+
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
262
|
lines.push(`Limits: at most ${resolved.maxOperations} operations per call (batch larger edits across calls); each text field at most 100,000 characters.`);
|
|
261
263
|
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
264
|
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.
|
|
3
|
+
"version": "0.11.3",
|
|
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.36.0",
|
|
58
58
|
"better-result": "3.0.1"
|
|
59
59
|
},
|
|
60
60
|
"main": "./dist/index.js",
|