@stll/folio-agents 0.10.0 → 0.10.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/execute.js CHANGED
@@ -287,6 +287,23 @@ const explainSkipReason = (reason) => {
287
287
  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.";
288
288
  return reason;
289
289
  };
290
+ /**
291
+ * Turn one apply-time `FolioAIEditNormalization` (an automatic adjustment the
292
+ * applier made to an operation's input, e.g. splitting a multi-line
293
+ * `insertAfterBlock` / `insertBeforeBlock` `text` into several paragraphs)
294
+ * into the same `{ path, message }` shape lenient decoding reports, so the
295
+ * model sees every normalization in one list regardless of where it happened.
296
+ */
297
+ const explainApplyNormalization = (normalization) => {
298
+ if (normalization.code === "splitMultilineText") return {
299
+ path: `operations[id=${normalization.id}].text`,
300
+ message: `\`text\` contained line breaks; split into ${normalization.paragraphCount} consecutive paragraphs (one per non-blank line) instead of one paragraph with embedded newlines.`
301
+ };
302
+ return {
303
+ path: `operations[id=${normalization.id}]`,
304
+ message: `input was normalized (${normalization.code}).`
305
+ };
306
+ };
290
307
  const summarizeApplyResult = (result, normalizations) => ({
291
308
  version: result.version,
292
309
  applied: result.applied.map((entry) => ({ id: entry.id })),
@@ -297,7 +314,7 @@ const summarizeApplyResult = (result, normalizations) => ({
297
314
  })),
298
315
  issues: result.issues ?? [],
299
316
  receipts: result.receipts ?? [],
300
- normalizations: [...normalizations]
317
+ normalizations: [...normalizations, ...(result.normalizations ?? []).map(explainApplyNormalization)]
301
318
  });
302
319
  /** Every operation skipped for one batch-wide reason, before anything reached the bridge. */
303
320
  const rejectBatch = (operations, reason, normalizations) => {
@@ -262,7 +262,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
262
262
  blockId: blockIdProperty,
263
263
  text: {
264
264
  type: "string",
265
- description: "The paragraph text to insert."
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."
266
266
  },
267
267
  inheritFormatting: {
268
268
  type: "boolean",
@@ -299,7 +299,7 @@ const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA = {
299
299
  blockId: blockIdProperty,
300
300
  text: {
301
301
  type: "string",
302
- description: "The paragraph text to insert."
302
+ 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."
303
303
  },
304
304
  inheritFormatting: {
305
305
  type: "boolean",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-agents",
3
- "version": "0.10.0",
3
+ "version": "0.10.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.32.0",
57
+ "@stll/folio-core": "^0.32.2",
58
58
  "better-result": "3.0.1"
59
59
  },
60
60
  "main": "./dist/index.js",