@stll/folio-agents 0.12.1 → 0.12.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.
@@ -15,6 +15,7 @@ type FolioJsonSchema = {
15
15
  readonly additionalProperties?: boolean;
16
16
  readonly items?: FolioJsonSchema;
17
17
  readonly oneOf?: readonly FolioJsonSchema[];
18
+ readonly not?: FolioJsonSchema;
18
19
  };
19
20
  /**
20
21
  * JSON Schema for the contract's `textRange` handle (a serializable range
@@ -49,8 +50,74 @@ declare const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA: {
49
50
  }, {
50
51
  readonly type: "null";
51
52
  }];
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
+ 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.";
53
54
  };
55
+ /** Complete direct `w:ind` attributes, or null to restore style inheritance. */
56
+ declare const FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA: {
57
+ readonly oneOf: readonly [{
58
+ readonly type: "object";
59
+ readonly properties: {
60
+ readonly indentLeft: {
61
+ readonly type: "integer";
62
+ readonly minimum: number;
63
+ readonly maximum: number;
64
+ };
65
+ readonly indentRight: {
66
+ readonly type: "integer";
67
+ readonly minimum: number;
68
+ readonly maximum: number;
69
+ };
70
+ readonly indentFirstLine: {
71
+ readonly type: "integer";
72
+ readonly minimum: number;
73
+ readonly maximum: number;
74
+ };
75
+ readonly hangingIndent: {
76
+ readonly type: "boolean";
77
+ };
78
+ };
79
+ readonly minProperties: 1;
80
+ readonly additionalProperties: false;
81
+ }, {
82
+ readonly type: "null";
83
+ }];
84
+ readonly description: "Complete direct paragraph indentation (`w:ind`); null removes the direct child and restores style inheritance.";
85
+ };
86
+ declare const FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA: {
87
+ readonly oneOf: readonly [{
88
+ readonly type: "object";
89
+ readonly properties: {
90
+ readonly numId: {
91
+ readonly type: "integer";
92
+ readonly minimum: 1;
93
+ readonly maximum: number;
94
+ };
95
+ readonly level: {
96
+ readonly type: "integer";
97
+ readonly minimum: 0;
98
+ readonly maximum: number;
99
+ };
100
+ };
101
+ readonly required: readonly ["numId", "level"];
102
+ readonly additionalProperties: false;
103
+ }, {
104
+ readonly type: "null";
105
+ }];
106
+ readonly description: "Concrete numbering instance and level; null removes paragraph numbering.";
107
+ };
108
+ declare const FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA: {
109
+ readonly type: "object";
110
+ readonly properties: {
111
+ readonly clear: {
112
+ readonly type: "string";
113
+ readonly enum: readonly ["none", "left", "right", "all"];
114
+ };
115
+ };
116
+ readonly additionalProperties: false;
117
+ readonly description: "Insert an empty hard page-break run; it cannot be combined with text, pageBreakBefore, or lineBreakMode.";
118
+ };
119
+ /** Shared cross-field constraint for insertion and suggest-changes projections. */
120
+ declare const FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT: Pick<FolioJsonSchema, "oneOf">;
54
121
  /** Complete direct `w:spacing` attributes, or null to restore style inheritance. */
55
122
  declare const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA: {
56
123
  readonly oneOf: readonly [{
@@ -115,12 +182,64 @@ declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
115
182
  }, {
116
183
  readonly type: "null";
117
184
  }];
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.";
185
+ 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.";
186
+ };
187
+ readonly numbering: {
188
+ readonly oneOf: readonly [{
189
+ readonly type: "object";
190
+ readonly properties: {
191
+ readonly numId: {
192
+ readonly type: "integer";
193
+ readonly minimum: 1;
194
+ readonly maximum: number;
195
+ };
196
+ readonly level: {
197
+ readonly type: "integer";
198
+ readonly minimum: 0;
199
+ readonly maximum: number;
200
+ };
201
+ };
202
+ readonly required: readonly ["numId", "level"];
203
+ readonly additionalProperties: false;
204
+ }, {
205
+ readonly type: "null";
206
+ }];
207
+ readonly description: "Concrete numbering instance and level; null removes paragraph numbering.";
208
+ };
209
+ readonly indentation: {
210
+ readonly oneOf: readonly [{
211
+ readonly type: "object";
212
+ readonly properties: {
213
+ readonly indentLeft: {
214
+ readonly type: "integer";
215
+ readonly minimum: number;
216
+ readonly maximum: number;
217
+ };
218
+ readonly indentRight: {
219
+ readonly type: "integer";
220
+ readonly minimum: number;
221
+ readonly maximum: number;
222
+ };
223
+ readonly indentFirstLine: {
224
+ readonly type: "integer";
225
+ readonly minimum: number;
226
+ readonly maximum: number;
227
+ };
228
+ readonly hangingIndent: {
229
+ readonly type: "boolean";
230
+ };
231
+ };
232
+ readonly minProperties: 1;
233
+ readonly additionalProperties: false;
234
+ }, {
235
+ readonly type: "null";
236
+ }];
237
+ readonly description: "Complete direct paragraph indentation (`w:ind`); null removes the direct child and restores style inheritance.";
119
238
  };
120
239
  readonly alignment: {
121
240
  readonly oneOf: readonly [{
122
241
  readonly type: "string";
123
- readonly enum: readonly ("left" | "center" | "right" | "both" | "distribute" | "mediumKashida" | "highKashida" | "lowKashida" | "thaiDistribute")[];
242
+ readonly enum: readonly ("left" | "right" | "center" | "both" | "distribute" | "mediumKashida" | "highKashida" | "lowKashida" | "thaiDistribute")[];
124
243
  }, {
125
244
  readonly type: "null";
126
245
  }];
@@ -241,4 +360,4 @@ type FolioDocumentOperationBatchSchema = StandardSchemaV1<unknown, FolioDocument
241
360
  */
242
361
  declare const folioDocumentOperationBatchSchema: FolioDocumentOperationBatchSchema;
243
362
  //#endregion
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 };
363
+ export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_NUMBERING_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_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, FOLIO_LINE_SPACING_RULE_VALUES, 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_PAGE_BREAK_CLEAR_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
@@ -143,8 +143,74 @@ const FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA = {
143
143
  minimum: 0,
144
144
  maximum: Number.MAX_SAFE_INTEGER
145
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."
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
147
  };
148
+ /** Complete direct `w:ind` attributes, or null to restore style inheritance. */
149
+ const FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA = {
150
+ oneOf: [{
151
+ type: "object",
152
+ properties: {
153
+ indentLeft: {
154
+ type: "integer",
155
+ minimum: Number.MIN_SAFE_INTEGER,
156
+ maximum: Number.MAX_SAFE_INTEGER
157
+ },
158
+ indentRight: {
159
+ type: "integer",
160
+ minimum: Number.MIN_SAFE_INTEGER,
161
+ maximum: Number.MAX_SAFE_INTEGER
162
+ },
163
+ indentFirstLine: {
164
+ type: "integer",
165
+ minimum: Number.MIN_SAFE_INTEGER,
166
+ maximum: Number.MAX_SAFE_INTEGER
167
+ },
168
+ hangingIndent: { type: "boolean" }
169
+ },
170
+ minProperties: 1,
171
+ additionalProperties: false
172
+ }, { type: "null" }],
173
+ description: "Complete direct paragraph indentation (`w:ind`); null removes the direct child and restores style inheritance."
174
+ };
175
+ const FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA = {
176
+ oneOf: [{
177
+ type: "object",
178
+ properties: {
179
+ numId: {
180
+ type: "integer",
181
+ minimum: 1,
182
+ maximum: Number.MAX_SAFE_INTEGER
183
+ },
184
+ level: {
185
+ type: "integer",
186
+ minimum: 0,
187
+ maximum: Number.MAX_SAFE_INTEGER
188
+ }
189
+ },
190
+ required: ["numId", "level"],
191
+ additionalProperties: false
192
+ }, { type: "null" }],
193
+ description: "Concrete numbering instance and level; null removes paragraph numbering."
194
+ };
195
+ const FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA = {
196
+ type: "object",
197
+ properties: { clear: {
198
+ type: "string",
199
+ enum: FOLIO_PAGE_BREAK_CLEAR_VALUES
200
+ } },
201
+ additionalProperties: false,
202
+ description: "Insert an empty hard page-break run; it cannot be combined with text, pageBreakBefore, or lineBreakMode."
203
+ };
204
+ /** Shared cross-field constraint for insertion and suggest-changes projections. */
205
+ const FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT = { oneOf: [{ not: { required: ["hardPageBreak"] } }, {
206
+ required: ["hardPageBreak", "text"],
207
+ properties: {
208
+ type: { enum: ["insertAfterBlock", "insertBeforeBlock"] },
209
+ text: { enum: [""] },
210
+ pageBreakBefore: { not: {} },
211
+ lineBreakMode: { not: {} }
212
+ }
213
+ }] };
148
214
  /** Complete direct `w:spacing` attributes, or null to restore style inheritance. */
149
215
  const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA = {
150
216
  oneOf: [{
@@ -193,6 +259,8 @@ const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA = {
193
259
  properties: {
194
260
  styleId: FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA,
195
261
  listLevel: FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA,
262
+ numbering: FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA,
263
+ indentation: FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA,
196
264
  alignment: {
197
265
  oneOf: [{
198
266
  type: "string",
@@ -326,6 +394,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
326
394
  {
327
395
  type: "object",
328
396
  description: "Insert a new paragraph after the anchor block.",
397
+ ...FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT,
329
398
  properties: {
330
399
  ...operationMetaProperties,
331
400
  ...suggestionIdProperty,
@@ -356,6 +425,13 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
356
425
  description: "Direct paragraph alignment; null restores style inheritance."
357
426
  },
358
427
  spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
428
+ indentation: FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA,
429
+ lineBreakMode: {
430
+ type: "string",
431
+ enum: ["paragraph", "inline"]
432
+ },
433
+ numbering: FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA,
434
+ hardPageBreak: FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA,
359
435
  moveId: {
360
436
  type: "string",
361
437
  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."
@@ -373,6 +449,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
373
449
  {
374
450
  type: "object",
375
451
  description: "Insert a new paragraph before the anchor block.",
452
+ ...FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT,
376
453
  properties: {
377
454
  ...operationMetaProperties,
378
455
  ...suggestionIdProperty,
@@ -403,6 +480,13 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
403
480
  description: "Direct paragraph alignment; null restores style inheritance."
404
481
  },
405
482
  spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
483
+ indentation: FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA,
484
+ lineBreakMode: {
485
+ type: "string",
486
+ enum: ["paragraph", "inline"]
487
+ },
488
+ numbering: FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA,
489
+ hardPageBreak: FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA,
406
490
  moveId: {
407
491
  type: "string",
408
492
  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."
@@ -934,4 +1018,4 @@ const folioDocumentOperationBatchSchema = {
934
1018
  jsonSchema: FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA
935
1019
  };
936
1020
  //#endregion
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 };
1021
+ export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_NUMBERING_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_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_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";
2
+ import { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_LIST_LEVEL_JSON_SCHEMA, FOLIO_CLEARABLE_NUMBERING_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_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";
@@ -121,6 +121,14 @@ const OPERATION_PROPERTY_SCHEMAS = {
121
121
  description: "For inserts: direct paragraph alignment; null restores style inheritance."
122
122
  },
123
123
  spacing: FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA,
124
+ indentation: FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA,
125
+ lineBreakMode: {
126
+ type: "string",
127
+ enum: ["paragraph", "inline"],
128
+ description: "For inserts: interpret line breaks as paragraph boundaries (default) or inline breaks."
129
+ },
130
+ numbering: FOLIO_CLEARABLE_NUMBERING_JSON_SCHEMA,
131
+ hardPageBreak: FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA,
124
132
  preserveFormatting: {
125
133
  type: "boolean",
126
134
  description: "For `replaceBlock`: keep the block's existing formatting for the replacement text."
@@ -233,6 +241,7 @@ const buildSuggestChangesOperationSchema = (resolved) => {
233
241
  return {
234
242
  type: "object",
235
243
  properties,
244
+ ...FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT,
236
245
  required: resolved.reviewMeta === "required" ? [
237
246
  "type",
238
247
  "severity",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-agents",
3
- "version": "0.12.1",
3
+ "version": "0.12.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.37.1",
57
+ "@stll/folio-core": "^0.39.0",
58
58
  "better-result": "3.0.1"
59
59
  },
60
60
  "main": "./dist/index.js",