@stll/folio-agents 0.16.3 → 0.16.5

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/README.md CHANGED
@@ -96,15 +96,17 @@ cannot silently apply one.
96
96
  ## Headless quickstart
97
97
 
98
98
  ```ts
99
- import { FolioDocxReviewer } from "@stll/folio-core/server";
100
99
  import {
101
100
  createReviewerBridge,
102
101
  executeFolioToolCallUntyped,
103
102
  getFolioToolDefinitions,
104
103
  toAnthropicTools,
105
104
  } from "@stll/folio-agents";
105
+ import { FolioDocxReviewer } from "@stll/folio-core/server";
106
106
 
107
- const reviewer = await FolioDocxReviewer.fromBuffer(docxBuffer, { author: "AI" });
107
+ const reviewer = await FolioDocxReviewer.fromBuffer(docxBuffer, {
108
+ author: "AI",
109
+ });
108
110
  const bridge = createReviewerBridge(reviewer);
109
111
  const tools = toAnthropicTools(getFolioToolDefinitions());
110
112
 
@@ -154,8 +156,8 @@ host configures per surface instead of re-deriving. Pass the same options to
154
156
  import {
155
157
  describeSuggestChangesCapabilities,
156
158
  executeFolioToolCall,
157
- getFolioToolDefinitions,
158
159
  type FolioSuggestChangesOptions,
160
+ getFolioToolDefinitions,
159
161
  } from "@stll/folio-agents";
160
162
 
161
163
  const suggestChanges: FolioSuggestChangesOptions = {
@@ -170,7 +172,9 @@ const suggestChanges: FolioSuggestChangesOptions = {
170
172
  };
171
173
 
172
174
  const tools = getFolioToolDefinitions({ suggestChanges });
173
- const result = executeFolioToolCall("suggest_changes", args, bridge, { suggestChanges });
175
+ const result = executeFolioToolCall("suggest_changes", args, bridge, {
176
+ suggestChanges,
177
+ });
174
178
  // `describeSuggestChangesCapabilities({ ...suggestChanges })` returns the same
175
179
  // capability text the tool description carries, for reuse in a system prompt.
176
180
  ```
@@ -206,8 +210,8 @@ included, and the host keeps the automatic `precondition` stamping and the
206
210
  document-version check:
207
211
 
208
212
  ```ts
209
- import { getFolioDocumentOperationReceipts } from "@stll/folio-core/server";
210
213
  import type { FolioAgentBridge } from "@stll/folio-agents";
214
+ import { getFolioDocumentOperationReceipts } from "@stll/folio-core/server";
211
215
 
212
216
  const queueBridge: FolioAgentBridge = {
213
217
  snapshot: () => lastSnapshotShownToTheModel,
@@ -258,9 +262,15 @@ independent of whether either one has any tracked changes at all. Use
258
262
  `compareDocxVersions` + `formatVersionDiffForLLM`:
259
263
 
260
264
  ```ts
261
- import { compareDocxVersions, formatVersionDiffForLLM } from "@stll/folio-agents";
265
+ import {
266
+ compareDocxVersions,
267
+ formatVersionDiffForLLM,
268
+ } from "@stll/folio-agents";
262
269
 
263
- const diff = await compareDocxVersions(previousVersionBuffer, currentVersionBuffer);
270
+ const diff = await compareDocxVersions(
271
+ previousVersionBuffer,
272
+ currentVersionBuffer,
273
+ );
264
274
  const prompt = `Summarize what changed between these two document versions:\n${formatVersionDiffForLLM(diff)}`;
265
275
  // -> feed `prompt` to your model as a normal user/system message.
266
276
  ```
@@ -286,9 +296,13 @@ to the generated output and returned as a structured report:
286
296
  ```ts
287
297
  import { generateRedlineDocx } from "@stll/folio-agents";
288
298
 
289
- const result = await generateRedlineDocx(previousVersionBuffer, currentVersionBuffer, {
290
- privacy: { transforms: ["remove-attribution", "remove-timestamps"] },
291
- });
299
+ const result = await generateRedlineDocx(
300
+ previousVersionBuffer,
301
+ currentVersionBuffer,
302
+ {
303
+ privacy: { transforms: ["remove-attribution", "remove-timestamps"] },
304
+ },
305
+ );
292
306
 
293
307
  await storeGeneratedPackage(result.buffer);
294
308
  console.log(result.privacyReport);
@@ -301,6 +315,7 @@ TanStack AI's `toolDefinition` accepts a raw JSON Schema object as
301
315
 
302
316
  ```ts
303
317
  import { toolDefinition } from "@tanstack/ai";
318
+
304
319
  import { getFolioToolDefinitions } from "@stll/folio-agents";
305
320
 
306
321
  const defs = getFolioToolDefinitions().map((def) =>
@@ -328,7 +343,11 @@ SDK's own `jsonSchema()` / `tool()` helpers:
328
343
 
329
344
  ```ts
330
345
  import { jsonSchema, tool } from "ai";
331
- import { executeFolioToolCallUntyped, getFolioToolDefinitions } from "@stll/folio-agents";
346
+
347
+ import {
348
+ executeFolioToolCallUntyped,
349
+ getFolioToolDefinitions,
350
+ } from "@stll/folio-agents";
332
351
 
333
352
  const tools = Object.fromEntries(
334
353
  getFolioToolDefinitions().map((def) => [
@@ -336,7 +355,8 @@ const tools = Object.fromEntries(
336
355
  tool({
337
356
  description: def.description,
338
357
  inputSchema: jsonSchema(def.inputSchema),
339
- execute: async (input) => executeFolioToolCallUntyped(def.name, input, bridge),
358
+ execute: async (input) =>
359
+ executeFolioToolCallUntyped(def.name, input, bridge),
340
360
  }),
341
361
  ]),
342
362
  );
package/dist/bridge.d.ts CHANGED
@@ -15,7 +15,7 @@ import { FolioAIEditSnapshot, FolioDocumentNavigationTarget, FolioDocumentOperat
15
15
  * model driving a headless reviewer gets a plain-language reason instead of a
16
16
  * crash.
17
17
  */
18
- type FolioAgentBridge = {
18
+ export type FolioAgentBridge = {
19
19
  /** Snapshot the current document into AI-facing blocks + anchors. */
20
20
  snapshot(): FolioAIEditSnapshot;
21
21
  /**
@@ -69,9 +69,9 @@ type DecodedCommentHandlers = {
69
69
  replyToComment(commentId: FolioAgentCommentId, text: string): boolean;
70
70
  resolveComment(commentId: FolioAgentCommentId, resolved: boolean): boolean;
71
71
  };
72
- declare const registerDecodedCommentHandlers: (bridge: FolioAgentBridge, handlers: DecodedCommentHandlers) => FolioAgentBridge;
73
- declare const getDecodedCommentHandlers: (bridge: FolioAgentBridge) => DecodedCommentHandlers | undefined;
74
- declare const registerOperationSession: (bridge: FolioAgentBridge, session: object) => FolioAgentBridge;
75
- declare const getOperationSession: (bridge: FolioAgentBridge) => object;
72
+ export declare const registerDecodedCommentHandlers: (bridge: FolioAgentBridge, handlers: DecodedCommentHandlers) => FolioAgentBridge;
73
+ export declare const getDecodedCommentHandlers: (bridge: FolioAgentBridge) => DecodedCommentHandlers | undefined;
74
+ export declare const registerOperationSession: (bridge: FolioAgentBridge, session: object) => FolioAgentBridge;
75
+ export declare const getOperationSession: (bridge: FolioAgentBridge) => object;
76
76
  //#endregion
77
- export { FolioAgentBridge, getDecodedCommentHandlers, getOperationSession, registerDecodedCommentHandlers, registerOperationSession };
77
+ export {};
@@ -1,9 +1,10 @@
1
1
  import { FolioAgentBridge } from "../bridge.js";
2
- import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioDocumentNavigationTarget, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult } from "@stll/folio-core/server";
3
- import { FolioCommentAnchor, FolioReviewChange as FolioReviewChange$1, FolioUndefinedReferencePolicy } from "@stll/folio-core/ai-edits";
2
+ import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioDocumentNavigationTarget, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, FolioReviewChange } from "@stll/folio-core/server";
3
+ import { FolioUndefinedReferencePolicy } from "@stll/folio-core/ai-edits/apply";
4
+ import { FolioCommentAnchor } from "@stll/folio-core/ai-edits/read";
4
5
  import { Comment } from "@stll/folio-core/types/content";
5
6
  //#region src/bridges/editor-ref.d.ts
6
- type FolioAgentEditorApplyDocumentOperationsOptions = {
7
+ export type FolioAgentEditorApplyDocumentOperationsOptions = {
7
8
  undefinedReferences: FolioUndefinedReferencePolicy;
8
9
  snapshot: FolioAIEditSnapshot;
9
10
  batch: FolioDocumentOperationBatch;
@@ -24,7 +25,7 @@ type FolioAgentEditorApplyDocumentOperationsOptions = {
24
25
  * below falls back to the pre-existing degraded behavior for each one it does
25
26
  * not find.
26
27
  */
27
- type FolioAgentEditorRefLike = {
28
+ export type FolioAgentEditorRefLike = {
28
29
  /** `DocxEditorRef.createAIEditSnapshot`. `null` before the editor view mounts. */
29
30
  createAIEditSnapshot(): FolioAIEditSnapshot | null;
30
31
  /** `DocxEditorRef.applyAIEditOperations`. */
@@ -48,7 +49,7 @@ type FolioAgentEditorRefLike = {
48
49
  * output to {@link FolioAgentChange} (same mapping as the reviewer
49
50
  * bridge's); when absent, `getChanges()` returns `[]`.
50
51
  */
51
- getTrackedChanges?(): FolioReviewChange$1[];
52
+ getTrackedChanges?(): FolioReviewChange[];
52
53
  /**
53
54
  * `DocxEditorRef.getCommentAnchors`. When present, `getComments()` merges
54
55
  * each anchor's `blockId` / `quote` into the matching host-state comment
@@ -74,7 +75,7 @@ type FolioAgentEditorRefLike = {
74
75
  showInDocument?(target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot): boolean;
75
76
  };
76
77
  /** Options for {@link createEditorRefBridge}. */
77
- type CreateEditorRefBridgeOptions = {
78
+ export type CreateEditorRefBridgeOptions = {
78
79
  ref: FolioAgentEditorRefLike;
79
80
  /** Author attributed to tracked changes, comments, and replies this bridge creates. */
80
81
  author: string;
@@ -111,6 +112,5 @@ type CreateEditorRefBridgeOptions = {
111
112
  * - Page-scoped search and `show_in_document` report an unsupported-capability
112
113
  * error when `ref.getTargetPage` / `ref.showInDocument` are absent.
113
114
  */
114
- declare const createEditorRefBridge: (options: CreateEditorRefBridgeOptions) => FolioAgentBridge;
115
- //#endregion
116
- export { CreateEditorRefBridgeOptions, FolioAgentEditorApplyDocumentOperationsOptions, FolioAgentEditorRefLike, createEditorRefBridge };
115
+ export declare const createEditorRefBridge: (options: CreateEditorRefBridgeOptions) => FolioAgentBridge;
116
+ //#endregion
@@ -2,7 +2,7 @@ import { FolioAgentBridge } from "../bridge.js";
2
2
  import { FolioAIEditApplyMode, FolioDocxReviewer, FolioRevisionStamp } from "@stll/folio-core/server";
3
3
  //#region src/bridges/reviewer.d.ts
4
4
  /** Options for {@link createReviewerBridge}. */
5
- type CreateReviewerBridgeOptions = {
5
+ export type CreateReviewerBridgeOptions = {
6
6
  /** `"tracked-changes"` (default) produces ins/del redlines; `"direct"` edits in place. */
7
7
  mode?: FolioAIEditApplyMode;
8
8
  /**
@@ -21,6 +21,5 @@ type CreateReviewerBridgeOptions = {
21
21
  * unsupported-capability error via {@link executeFolioToolCall} on this
22
22
  * bridge.
23
23
  */
24
- declare const createReviewerBridge: (reviewer: FolioDocxReviewer, options?: CreateReviewerBridgeOptions) => FolioAgentBridge;
25
- //#endregion
26
- export { CreateReviewerBridgeOptions, createReviewerBridge };
24
+ export declare const createReviewerBridge: (reviewer: FolioDocxReviewer, options?: CreateReviewerBridgeOptions) => FolioAgentBridge;
25
+ //#endregion
@@ -10,6 +10,5 @@ import { FolioReviewChange } from "@stll/folio-core/server";
10
10
  * `@stll/folio-core/ai-edits`), so they share this one mapping instead of
11
11
  * drifting into two subtly different shapes.
12
12
  */
13
- declare const toAgentChange: (change: FolioReviewChange) => FolioAgentChange;
14
- //#endregion
15
- export { toAgentChange };
13
+ export declare const toAgentChange: (change: FolioReviewChange) => FolioAgentChange;
14
+ //#endregion
package/dist/codecs.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FOLIO_TEXT_RANGE_JSON_SCHEMA } from "./operation-schema.js";
2
2
  import { FolioAITextRangeHandle, FolioDocumentSectionHandle, FolioDocumentStoryHandle } from "@stll/folio-core/server";
3
3
  //#region src/codecs.d.ts
4
- declare const FOLIO_STORY_HANDLE_JSON_SCHEMA: {
4
+ export declare const FOLIO_STORY_HANDLE_JSON_SCHEMA: {
5
5
  readonly type: "object";
6
6
  readonly properties: {
7
7
  readonly type: {
@@ -18,7 +18,7 @@ declare const FOLIO_STORY_HANDLE_JSON_SCHEMA: {
18
18
  readonly required: readonly ["type"];
19
19
  readonly additionalProperties: false;
20
20
  };
21
- declare const FOLIO_SECTION_HANDLE_JSON_SCHEMA: {
21
+ export declare const FOLIO_SECTION_HANDLE_JSON_SCHEMA: {
22
22
  readonly type: "object";
23
23
  readonly properties: {
24
24
  readonly type: {
@@ -44,7 +44,7 @@ declare const FOLIO_SECTION_HANDLE_JSON_SCHEMA: {
44
44
  readonly required: readonly ["type", "story", "headingBlockId", "headingTextHash", "headingLevel"];
45
45
  readonly additionalProperties: false;
46
46
  };
47
- declare const FOLIO_SCOPED_HANDLE_JSON_SCHEMA: {
47
+ export declare const FOLIO_SCOPED_HANDLE_JSON_SCHEMA: {
48
48
  readonly type: "object";
49
49
  readonly properties: {
50
50
  readonly type: {
@@ -76,17 +76,17 @@ declare const FOLIO_SCOPED_HANDLE_JSON_SCHEMA: {
76
76
  readonly required: readonly ["type"];
77
77
  readonly additionalProperties: false;
78
78
  };
79
- declare const FOLIO_COMMENT_ID_JSON_SCHEMA: {
79
+ export declare const FOLIO_COMMENT_ID_JSON_SCHEMA: {
80
80
  readonly type: "string";
81
81
  readonly description: "The comment id string from `read_comments`.";
82
82
  };
83
- type FolioAgentCommentId = {
83
+ export type FolioAgentCommentId = {
84
84
  raw: string;
85
85
  numeric: number;
86
86
  };
87
- declare const decodeSectionHandle: (value: unknown) => FolioDocumentSectionHandle | null;
88
- declare const decodeStoryHandle: (value: unknown) => FolioDocumentStoryHandle | null;
89
- declare const decodeMainStoryTextRangeHandle: (value: unknown) => FolioAITextRangeHandle | null;
90
- declare const decodeCommentId: (value: unknown) => FolioAgentCommentId | null;
87
+ export declare const decodeSectionHandle: (value: unknown) => FolioDocumentSectionHandle | null;
88
+ export declare const decodeStoryHandle: (value: unknown) => FolioDocumentStoryHandle | null;
89
+ export declare const decodeMainStoryTextRangeHandle: (value: unknown) => FolioAITextRangeHandle | null;
90
+ export declare const decodeCommentId: (value: unknown) => FolioAgentCommentId | null;
91
91
  //#endregion
92
- export { FOLIO_COMMENT_ID_JSON_SCHEMA, FOLIO_SCOPED_HANDLE_JSON_SCHEMA, FOLIO_SECTION_HANDLE_JSON_SCHEMA, FOLIO_STORY_HANDLE_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, FolioAgentCommentId, decodeCommentId, decodeMainStoryTextRangeHandle, decodeSectionHandle, decodeStoryHandle };
92
+ export { FOLIO_TEXT_RANGE_JSON_SCHEMA };
package/dist/compare.d.ts CHANGED
@@ -1,22 +1,21 @@
1
1
  import { FolioBlockDiff, FolioCompareDocxVersionsOptions, FolioVersionDiff, FolioVersionDiffSegment, GenerateRedlineDocxOptions, GenerateRedlineDocxResult } from "@stll/folio-core/server";
2
2
  //#region src/compare.d.ts
3
3
  /** Backward-compatible name for a core word-level version-diff segment. */
4
- type FolioAgentVersionDiffSegment = FolioVersionDiffSegment;
4
+ export type FolioAgentVersionDiffSegment = FolioVersionDiffSegment;
5
5
  /** Backward-compatible name for a core block-level version diff. */
6
- type FolioAgentBlockDiff = FolioBlockDiff;
6
+ export type FolioAgentBlockDiff = FolioBlockDiff;
7
7
  /** Backward-compatible name for a structured core version diff. */
8
- type FolioAgentVersionDiff = FolioVersionDiff;
8
+ export type FolioAgentVersionDiff = FolioVersionDiff;
9
9
  /** Backward-compatible name for core comparison options. */
10
- type FolioAgentCompareDocxVersionsOptions = FolioCompareDocxVersionsOptions;
10
+ export type FolioAgentCompareDocxVersionsOptions = FolioCompareDocxVersionsOptions;
11
11
  /** Agent-facing name for core redline-generation options. */
12
- type FolioAgentGenerateRedlineDocxOptions = GenerateRedlineDocxOptions;
12
+ export type FolioAgentGenerateRedlineDocxOptions = GenerateRedlineDocxOptions;
13
13
  /** Agent-facing name for the core redline-generation result. */
14
- type FolioAgentGenerateRedlineDocxResult = GenerateRedlineDocxResult;
14
+ export type FolioAgentGenerateRedlineDocxResult = GenerateRedlineDocxResult;
15
15
  /** Compare two `.docx` buffers using folio-core's version comparison semantics. */
16
- declare const compareDocxVersions: (base: ArrayBuffer, revised: ArrayBuffer, options?: FolioAgentCompareDocxVersionsOptions) => Promise<FolioAgentVersionDiff>;
16
+ export declare const compareDocxVersions: (base: ArrayBuffer, revised: ArrayBuffer, options?: FolioAgentCompareDocxVersionsOptions) => Promise<FolioAgentVersionDiff>;
17
17
  /** Generate a reviewed package from two `.docx` buffers. */
18
- declare const generateRedlineDocx: (base: ArrayBuffer, revised: ArrayBuffer, options?: FolioAgentGenerateRedlineDocxOptions) => Promise<FolioAgentGenerateRedlineDocxResult>;
18
+ export declare const generateRedlineDocx: (base: ArrayBuffer, revised: ArrayBuffer, options?: FolioAgentGenerateRedlineDocxOptions) => Promise<FolioAgentGenerateRedlineDocxResult>;
19
19
  /** Render a structured version diff as compact, deterministic model input. */
20
- declare const formatVersionDiffForLLM: (diff: FolioAgentVersionDiff) => string;
21
- //#endregion
22
- export { FolioAgentBlockDiff, FolioAgentCompareDocxVersionsOptions, FolioAgentGenerateRedlineDocxOptions, FolioAgentGenerateRedlineDocxResult, FolioAgentVersionDiff, FolioAgentVersionDiffSegment, compareDocxVersions, formatVersionDiffForLLM, generateRedlineDocx };
20
+ export declare const formatVersionDiffForLLM: (diff: FolioAgentVersionDiff) => string;
21
+ //#endregion
package/dist/execute.d.ts CHANGED
@@ -15,7 +15,6 @@ import { FolioAgentToolInputByName, FolioToolCallResultFor } from "./tool-contra
15
15
  * Every bridge member used here ({@link FolioDocxReviewer} and the live-editor
16
16
  * ref) is synchronous, so this stays synchronous too.
17
17
  */
18
- declare const executeFolioToolCallUntyped: (name: string, args: unknown, bridge: FolioAgentBridge, options?: FolioAgentToolOptions) => FolioToolCallResult;
19
- declare function executeFolioToolCall<TName extends FolioAgentToolName>(name: TName, args: FolioAgentToolInputByName[TName], bridge: FolioAgentBridge, options?: FolioAgentToolOptions): FolioToolCallResultFor<TName>;
20
- //#endregion
21
- export { executeFolioToolCall, executeFolioToolCallUntyped };
18
+ export declare const executeFolioToolCallUntyped: (name: string, args: unknown, bridge: FolioAgentBridge, options?: FolioAgentToolOptions) => FolioToolCallResult;
19
+ export declare function executeFolioToolCall<TName extends FolioAgentToolName>(name: TName, args: FolioAgentToolInputByName[TName], bridge: FolioAgentBridge, options?: FolioAgentToolOptions): FolioToolCallResultFor<TName>;
20
+ //#endregion
@@ -1,7 +1,8 @@
1
1
  import { FolioDocumentOperationBatch } from "@stll/folio-core/server";
2
+ import { LineSpacingRule, ParagraphAlignment } from "@stll/folio-core/types/document";
2
3
  //#region src/operation-schema.d.ts
3
4
  /** Compact public shape for the runtime JSON Schema projections. */
4
- type FolioJsonSchema = {
5
+ export type FolioJsonSchema = {
5
6
  readonly type?: string;
6
7
  readonly description?: string;
7
8
  readonly enum?: readonly unknown[];
@@ -25,7 +26,7 @@ type FolioJsonSchema = {
25
26
  * drift. `endOffset` must be greater than `startOffset`; JSON Schema cannot
26
27
  * express that relation, the parser enforces it.
27
28
  */
28
- declare const FOLIO_TEXT_RANGE_JSON_SCHEMA: FolioJsonSchema;
29
+ export declare const FOLIO_TEXT_RANGE_JSON_SCHEMA: FolioJsonSchema;
29
30
  /**
30
31
  * JSON Schema for the contract's optional `precondition` guard: `{
31
32
  * blockTextHash }`, echoed from a `blockTextHash` returned by a document
@@ -33,8 +34,8 @@ declare const FOLIO_TEXT_RANGE_JSON_SCHEMA: FolioJsonSchema;
33
34
  * `tools.ts` can attach the same shape to `suggest_changes` and
34
35
  * `add_comment` without redeclaring it.
35
36
  */
36
- declare const FOLIO_PRECONDITION_JSON_SCHEMA: FolioJsonSchema;
37
- declare const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA: {
37
+ export declare const FOLIO_PRECONDITION_JSON_SCHEMA: FolioJsonSchema;
38
+ export declare const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA: {
38
39
  readonly oneOf: readonly [{
39
40
  readonly type: "string";
40
41
  }, {
@@ -43,9 +44,9 @@ declare const FOLIO_CLEARABLE_PARAGRAPH_STYLE_ID_JSON_SCHEMA: {
43
44
  readonly description: string;
44
45
  };
45
46
  /** Direct `w:outlineLvl`, or null to restore style inheritance. */
46
- declare const FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA: FolioJsonSchema;
47
+ export declare const FOLIO_CLEARABLE_OUTLINE_LEVEL_JSON_SCHEMA: FolioJsonSchema;
47
48
  /** Complete direct `w:ind` attributes, or null to restore style inheritance. */
48
- declare const FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA: {
49
+ export declare const FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA: {
49
50
  readonly oneOf: readonly [{
50
51
  readonly type: "object";
51
52
  readonly properties: {
@@ -75,12 +76,12 @@ declare const FOLIO_CLEARABLE_PARAGRAPH_INDENTATION_JSON_SCHEMA: {
75
76
  }];
76
77
  readonly description: "Complete direct paragraph indentation (`w:ind`); null removes the direct child and restores style inheritance.";
77
78
  };
78
- declare const FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA: {
79
+ export declare const FOLIO_INSERT_FORMATTING_SCOPE_JSON_SCHEMA: {
79
80
  readonly type: "string";
80
81
  readonly enum: readonly ["firstParagraph", "allParagraphs"];
81
82
  readonly description: string;
82
83
  };
83
- declare const FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA: {
84
+ export declare const FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA: {
84
85
  readonly oneOf: readonly [{
85
86
  readonly type: "object";
86
87
  readonly properties: {
@@ -158,7 +159,7 @@ declare const FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA: {
158
159
  }];
159
160
  readonly description: string;
160
161
  };
161
- declare const FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA: {
162
+ export declare const FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA: {
162
163
  readonly type: "object";
163
164
  readonly properties: {
164
165
  readonly clear: {
@@ -170,9 +171,9 @@ declare const FOLIO_HARD_PAGE_BREAK_JSON_SCHEMA: {
170
171
  readonly description: "Insert an empty hard page-break run; it cannot be combined with text, pageBreakBefore, or lineBreakMode.";
171
172
  };
172
173
  /** Shared cross-field constraint for insertion and suggest-changes projections. */
173
- declare const FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT: Pick<FolioJsonSchema, "oneOf">;
174
+ export declare const FOLIO_HARD_PAGE_BREAK_OPERATION_CONSTRAINT: Pick<FolioJsonSchema, "oneOf">;
174
175
  /** Complete direct `w:spacing` attributes, or null to restore style inheritance. */
175
- declare const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA: {
176
+ export declare const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA: {
176
177
  readonly oneOf: readonly [{
177
178
  readonly type: "object";
178
179
  readonly properties: {
@@ -196,7 +197,7 @@ declare const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA: {
196
197
  };
197
198
  readonly lineSpacingRule: {
198
199
  readonly type: "string";
199
- readonly enum: readonly undefined[];
200
+ readonly enum: readonly LineSpacingRule[];
200
201
  readonly description: "How `lineSpacing` is interpreted.";
201
202
  };
202
203
  readonly beforeAutospacing: {
@@ -215,7 +216,7 @@ declare const FOLIO_CLEARABLE_PARAGRAPH_SPACING_JSON_SCHEMA: {
215
216
  }];
216
217
  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.";
217
218
  };
218
- declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
219
+ export declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
219
220
  readonly type: "object";
220
221
  readonly description: "The paragraph properties to set; at least one.";
221
222
  readonly properties: {
@@ -339,7 +340,7 @@ declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
339
340
  readonly alignment: {
340
341
  readonly oneOf: readonly [{
341
342
  readonly type: "string";
342
- readonly enum: readonly undefined[];
343
+ readonly enum: readonly ParagraphAlignment[];
343
344
  }, {
344
345
  readonly type: "null";
345
346
  }];
@@ -369,7 +370,7 @@ declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
369
370
  };
370
371
  readonly lineSpacingRule: {
371
372
  readonly type: "string";
372
- readonly enum: readonly undefined[];
373
+ readonly enum: readonly LineSpacingRule[];
373
374
  readonly description: "How `lineSpacing` is interpreted.";
374
375
  };
375
376
  readonly beforeAutospacing: {
@@ -401,7 +402,7 @@ declare const FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA: {
401
402
  * it; note that the `suggest_changes` tool in `tools.ts` deliberately
402
403
  * narrows this union (see the comment there).
403
404
  */
404
- declare const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA: FolioJsonSchema;
405
+ export declare const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA: FolioJsonSchema;
405
406
  /**
406
407
  * JSON Schema (draft-07 compatible) for the versioned batch envelope accepted
407
408
  * by `parseFolioDocumentOperationBatch`: `version` (always
@@ -410,7 +411,7 @@ declare const FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA: FolioJsonSchema;
410
411
  * `FolioDocumentOperationBatch`. Hand this to an LLM tool definition (or any
411
412
  * JSON Schema consumer) instead of re-declaring the contract.
412
413
  */
413
- declare const FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA: FolioJsonSchema;
414
+ export declare const FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA: FolioJsonSchema;
414
415
  /**
415
416
  * Minimal structural subset of the Standard Schema V1 interface
416
417
  * (https://standardschema.dev). Declared locally instead of depending on
@@ -458,6 +459,6 @@ type FolioDocumentOperationBatchSchema = StandardSchemaV1<unknown, FolioDocument
458
459
  * reported one) on failure. The matching LLM-facing JSON schema is attached
459
460
  * as {@link FolioDocumentOperationBatchSchema.jsonSchema}.
460
461
  */
461
- declare const folioDocumentOperationBatchSchema: FolioDocumentOperationBatchSchema;
462
+ export declare const folioDocumentOperationBatchSchema: FolioDocumentOperationBatchSchema;
462
463
  //#endregion
463
- export { FOLIO_BLOCK_PARAGRAPH_PROPERTIES_JSON_SCHEMA, FOLIO_CLEARABLE_OUTLINE_LEVEL_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_INSERT_FORMATTING_SCOPE_JSON_SCHEMA, FOLIO_PARAGRAPH_NUMBERING_JSON_SCHEMA, FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA, FolioJsonSchema, folioDocumentOperationBatchSchema };
464
+ export {};
package/dist/parse.d.ts CHANGED
@@ -13,7 +13,7 @@ import { FolioAIEditOperation, FolioDocumentOperationBatch, FolioDocumentOperati
13
13
  * (`FolioSuggestChangesOptions.maxOperations`), defaulting to
14
14
  * {@link DEFAULT_MAX_OPERATIONS_PER_CALL}.
15
15
  */
16
- declare const MAX_OPERATION_TEXT_LENGTH = 100000;
16
+ export declare const MAX_OPERATION_TEXT_LENGTH = 1e5;
17
17
  /**
18
18
  * Aggregate cap on the SUM of every text-bearing field's length across one
19
19
  * `suggest_changes` call. Each field alone is bounded by
@@ -25,10 +25,10 @@ declare const MAX_OPERATION_TEXT_LENGTH = 100000;
25
25
  * tracked-changes engine in one call even though every per-field cap was
26
26
  * respected. This budget bounds the running total instead.
27
27
  */
28
- declare const MAX_TOTAL_OPERATION_TEXT_LENGTH = 2000000;
28
+ export declare const MAX_TOTAL_OPERATION_TEXT_LENGTH = 2e6;
29
29
  /** Plain-language error for a string argument over {@link MAX_OPERATION_TEXT_LENGTH}. */
30
- declare const explainTextTooLong: (label: string, length: number) => string;
31
- type PrepareFolioAgentDocumentOperationBatchOptions = {
30
+ export declare const explainTextTooLong: (label: string, length: number) => string;
31
+ export type PrepareFolioAgentDocumentOperationBatchOptions = {
32
32
  operations: readonly FolioAIEditOperation[];
33
33
  mode?: FolioDocumentOperationMode;
34
34
  atomic?: boolean;
@@ -41,9 +41,9 @@ type PrepareFolioAgentDocumentOperationBatchOptions = {
41
41
  * batch is safe to hand straight to `applyDocumentOperations`; core marks
42
42
  * parsed batches internally so the downstream apply path can skip reparsing.
43
43
  */
44
- declare const prepareFolioAgentDocumentOperationBatch: ({ operations, mode, atomic, dryRun, precondition }: PrepareFolioAgentDocumentOperationBatchOptions) => FolioDocumentOperationBatch;
44
+ export declare const prepareFolioAgentDocumentOperationBatch: ({ operations, mode, atomic, dryRun, precondition }: PrepareFolioAgentDocumentOperationBatchOptions) => FolioDocumentOperationBatch;
45
45
  /** Result of {@link parseAddCommentInput}. */
46
- type ParseAddCommentResult = {
46
+ export type ParseAddCommentResult = {
47
47
  ok: true;
48
48
  operation: FolioAIEditOperation;
49
49
  } | {
@@ -55,9 +55,9 @@ type ParseAddCommentResult = {
55
55
  * `commentOnBlock` {@link FolioAIEditOperation} it applies. Pure: does not
56
56
  * touch a bridge or document.
57
57
  */
58
- declare const parseAddCommentInput: (args: unknown) => ParseAddCommentResult;
58
+ export declare const parseAddCommentInput: (args: unknown) => ParseAddCommentResult;
59
59
  /** Result of {@link parseSuggestChangesInput}. */
60
- type ParseSuggestChangesResult = {
60
+ export type ParseSuggestChangesResult = {
61
61
  ok: true;
62
62
  operations: FolioAIEditOperation[];
63
63
  /** Present when the call pinned a host document version. */
@@ -73,6 +73,5 @@ type ParseSuggestChangesResult = {
73
73
  * document. `options` must match the {@link FolioSuggestChangesOptions} the
74
74
  * tool definition was built with.
75
75
  */
76
- declare const parseSuggestChangesInput: (args: unknown, options?: FolioSuggestChangesOptions) => ParseSuggestChangesResult;
77
- //#endregion
78
- export { MAX_OPERATION_TEXT_LENGTH, MAX_TOTAL_OPERATION_TEXT_LENGTH, ParseAddCommentResult, ParseSuggestChangesResult, PrepareFolioAgentDocumentOperationBatchOptions, explainTextTooLong, parseAddCommentInput, parseSuggestChangesInput, prepareFolioAgentDocumentOperationBatch };
76
+ export declare const parseSuggestChangesInput: (args: unknown, options?: FolioSuggestChangesOptions) => ParseSuggestChangesResult;
77
+ //#endregion
@@ -1,15 +1,15 @@
1
1
  import { FolioAgentToolDefinition } from "./types.js";
2
2
  //#region src/providers.d.ts
3
3
  /** Anthropic Messages API tool-definition shape (`input_schema`, snake_case). */
4
- type AnthropicToolDefinition = {
4
+ export type AnthropicToolDefinition = {
5
5
  name: string;
6
6
  description: string;
7
7
  input_schema: Record<string, unknown>;
8
8
  };
9
9
  /** Map folio's provider-neutral tool definitions onto Anthropic's tool shape. */
10
- declare const toAnthropicTools: (definitions: FolioAgentToolDefinition[]) => AnthropicToolDefinition[];
10
+ export declare const toAnthropicTools: (definitions: FolioAgentToolDefinition[]) => AnthropicToolDefinition[];
11
11
  /** OpenAI Chat Completions / Responses API function-tool shape. */
12
- type OpenAIToolDefinition = {
12
+ export type OpenAIToolDefinition = {
13
13
  type: "function";
14
14
  function: {
15
15
  name: string;
@@ -18,6 +18,5 @@ type OpenAIToolDefinition = {
18
18
  };
19
19
  };
20
20
  /** Map folio's provider-neutral tool definitions onto OpenAI's function-tool shape. */
21
- declare const toOpenAITools: (definitions: FolioAgentToolDefinition[]) => OpenAIToolDefinition[];
22
- //#endregion
23
- export { AnthropicToolDefinition, OpenAIToolDefinition, toAnthropicTools, toOpenAITools };
21
+ export declare const toOpenAITools: (definitions: FolioAgentToolDefinition[]) => OpenAIToolDefinition[];
22
+ //#endregion
@@ -1,7 +1,9 @@
1
1
  import { FolioDocumentOperationType } from "@stll/folio-core/server";
2
+ import { TaggedErrorClass } from "better-result";
2
3
  //#region src/suggest-changes-options.d.ts
4
+ declare const InvalidFolioSuggestChangesOptionsErrorBase: TaggedErrorClass<"InvalidFolioSuggestChangesOptionsError">;
3
5
  /** Whether every operation must carry `severity` and `area`. */
4
- type FolioSuggestChangesReviewMetaPolicy = "optional" | "required";
6
+ export type FolioSuggestChangesReviewMetaPolicy = "optional" | "required";
5
7
  /**
6
8
  * Pin the batch to a host document version. The model must echo `current`
7
9
  * as the tool's top-level `documentVersion` argument; it lands on the batch
@@ -9,7 +11,7 @@ type FolioSuggestChangesReviewMetaPolicy = "optional" | "required";
9
11
  * with `documentVersionMismatch` when the bridge reports a different version
10
12
  * at apply time (an approval that ran after the document moved on).
11
13
  */
12
- type FolioSuggestChangesDocumentVersionOption = {
14
+ export type FolioSuggestChangesDocumentVersionOption = {
13
15
  current: string;
14
16
  };
15
17
  /**
@@ -17,7 +19,7 @@ type FolioSuggestChangesDocumentVersionOption = {
17
19
  * `getFolioToolDefinitions` and `executeFolioToolCall` so the schema the
18
20
  * model sees and the parser that checks its calls agree.
19
21
  */
20
- type FolioSuggestChangesOptions = {
22
+ export type FolioSuggestChangesOptions = {
21
23
  /**
22
24
  * Operation types the model may emit, in any order. Defaults to every
23
25
  * contract type except `commentOnBlock` (covered by `add_comment`) and
@@ -34,10 +36,10 @@ type FolioSuggestChangesOptions = {
34
36
  * Per-surface configuration shared by `getFolioToolDefinitions` and
35
37
  * `executeFolioToolCall`; every tool but `suggest_changes` is fixed.
36
38
  */
37
- type FolioAgentToolOptions = {
39
+ export type FolioAgentToolOptions = {
38
40
  suggestChanges?: FolioSuggestChangesOptions;
39
41
  };
40
- type ResolvedFolioSuggestChangesOptions = {
42
+ export type ResolvedFolioSuggestChangesOptions = {
41
43
  /** Allowed types in contract order, deduplicated. */
42
44
  readonly operationTypes: readonly FolioDocumentOperationType[];
43
45
  readonly reviewMeta: FolioSuggestChangesReviewMetaPolicy;
@@ -45,16 +47,15 @@ type ResolvedFolioSuggestChangesOptions = {
45
47
  readonly documentVersion: FolioSuggestChangesDocumentVersionOption | null;
46
48
  };
47
49
  /** The operation types `suggest_changes` exposes when a host passes no `operationTypes`. */
48
- declare const DEFAULT_SUGGEST_CHANGES_OPERATION_TYPES: readonly FolioDocumentOperationType[];
49
- declare const DEFAULT_MAX_OPERATIONS_PER_CALL = 50;
50
- declare const MAX_OPERATIONS_PER_CALL_LIMIT = 200;
51
- declare const InvalidFolioSuggestChangesOptionsError_base: import("better-result").TaggedErrorClass<"InvalidFolioSuggestChangesOptionsError">;
50
+ export declare const DEFAULT_SUGGEST_CHANGES_OPERATION_TYPES: readonly FolioDocumentOperationType[];
51
+ export declare const DEFAULT_MAX_OPERATIONS_PER_CALL = 50;
52
+ export declare const MAX_OPERATIONS_PER_CALL_LIMIT = 200;
52
53
  /** Programmer misuse of {@link FolioSuggestChangesOptions}; never reaches the model. */
53
- declare class InvalidFolioSuggestChangesOptionsError extends InvalidFolioSuggestChangesOptionsError_base<{
54
+ export declare class InvalidFolioSuggestChangesOptionsError extends InvalidFolioSuggestChangesOptionsErrorBase<{
54
55
  message: string;
55
56
  option: keyof FolioSuggestChangesOptions;
56
57
  }> {}
57
58
  /** Validate and default a host's options; throws {@link InvalidFolioSuggestChangesOptionsError} on misuse. */
58
- declare const resolveSuggestChangesOptions: (options?: FolioSuggestChangesOptions) => ResolvedFolioSuggestChangesOptions;
59
+ export declare const resolveSuggestChangesOptions: (options?: FolioSuggestChangesOptions) => ResolvedFolioSuggestChangesOptions;
59
60
  //#endregion
60
- export { DEFAULT_MAX_OPERATIONS_PER_CALL, DEFAULT_SUGGEST_CHANGES_OPERATION_TYPES, FolioAgentToolOptions, FolioSuggestChangesDocumentVersionOption, FolioSuggestChangesOptions, FolioSuggestChangesReviewMetaPolicy, InvalidFolioSuggestChangesOptionsError, MAX_OPERATIONS_PER_CALL_LIMIT, ResolvedFolioSuggestChangesOptions, resolveSuggestChangesOptions };
61
+ export {};
@@ -8,13 +8,14 @@ import { TaggedError } from "better-result";
8
8
  * narrower or stricter surface configures instead of re-deriving the
9
9
  * contract.
10
10
  */
11
+ const InvalidFolioSuggestChangesOptionsErrorBase = TaggedError("InvalidFolioSuggestChangesOptionsError");
11
12
  const DEFAULT_EXCLUDED_OPERATION_TYPES = /* @__PURE__ */ new Set(["commentOnBlock", "insertSignatureTable"]);
12
13
  /** The operation types `suggest_changes` exposes when a host passes no `operationTypes`. */
13
14
  const DEFAULT_SUGGEST_CHANGES_OPERATION_TYPES = FOLIO_DOCUMENT_OPERATION_TYPES.filter((type) => !DEFAULT_EXCLUDED_OPERATION_TYPES.has(type));
14
15
  const DEFAULT_MAX_OPERATIONS_PER_CALL = 50;
15
16
  const MAX_OPERATIONS_PER_CALL_LIMIT = 200;
16
17
  /** Programmer misuse of {@link FolioSuggestChangesOptions}; never reaches the model. */
17
- var InvalidFolioSuggestChangesOptionsError = class extends TaggedError("InvalidFolioSuggestChangesOptionsError") {};
18
+ var InvalidFolioSuggestChangesOptionsError = class extends InvalidFolioSuggestChangesOptionsErrorBase {};
18
19
  const invalidOption = (option, message) => {
19
20
  throw new InvalidFolioSuggestChangesOptionsError({
20
21
  message: `Invalid suggest_changes option \`${option}\`: ${message}.`,
@@ -2,7 +2,7 @@ import { FOLIO_AGENT_TOOL_NAMES, FolioAgentApplyOperationsSummary, FolioAgentBlo
2
2
  import { FolioAITextRangeHandle, FolioDocumentSectionHandle, FolioDocumentStory, FolioDocumentStoryHandle } from "@stll/folio-core/server";
3
3
  //#region src/tool-contract.d.ts
4
4
  type EmptyArgs = Readonly<Record<string, never>>;
5
- type FolioAgentFindTextScope = {
5
+ export type FolioAgentFindTextScope = {
6
6
  type: "document";
7
7
  } | {
8
8
  type: "section";
@@ -14,14 +14,14 @@ type FolioAgentFindTextScope = {
14
14
  type: "story";
15
15
  handle: FolioDocumentStoryHandle;
16
16
  };
17
- type FolioAgentShowInDocumentArgs = {
17
+ export type FolioAgentShowInDocumentArgs = {
18
18
  blockId: string;
19
19
  range?: never;
20
20
  } | {
21
21
  blockId?: never;
22
22
  range: FolioAITextRangeHandle;
23
23
  };
24
- type FolioAgentToolInputByName = {
24
+ export type FolioAgentToolInputByName = {
25
25
  [FOLIO_AGENT_TOOL_NAMES.readDocument]: EmptyArgs;
26
26
  [FOLIO_AGENT_TOOL_NAMES.getDocumentOutline]: {
27
27
  maxDepth?: number;
@@ -75,7 +75,7 @@ type FolioAgentToolInputByName = {
75
75
  };
76
76
  [FOLIO_AGENT_TOOL_NAMES.showInDocument]: FolioAgentShowInDocumentArgs;
77
77
  };
78
- type FolioAgentToolOutputByName = {
78
+ export type FolioAgentToolOutputByName = {
79
79
  [FOLIO_AGENT_TOOL_NAMES.readDocument]: FolioAgentBlock[];
80
80
  [FOLIO_AGENT_TOOL_NAMES.getDocumentOutline]: FolioAgentDocumentOutline;
81
81
  [FOLIO_AGENT_TOOL_NAMES.readSection]: FolioAgentSectionRead;
@@ -107,7 +107,7 @@ type FolioAgentToolOutputByName = {
107
107
  shown: boolean;
108
108
  };
109
109
  };
110
- type FolioToolCallResultFor<TName extends FolioAgentToolName> = FolioToolCallResult<FolioAgentToolOutputByName[TName]>;
111
- declare const defineFolioAgentToolDefinition: <TName extends FolioAgentToolName>(definition: FolioAgentTypedToolDefinition<TName, FolioAgentToolInputByName[TName], FolioAgentToolOutputByName[TName]>) => FolioAgentTypedToolDefinition<TName, FolioAgentToolInputByName[TName], FolioAgentToolOutputByName[TName]>;
110
+ export type FolioToolCallResultFor<TName extends FolioAgentToolName> = FolioToolCallResult<FolioAgentToolOutputByName[TName]>;
111
+ export declare const defineFolioAgentToolDefinition: <TName extends FolioAgentToolName>(definition: FolioAgentTypedToolDefinition<TName, FolioAgentToolInputByName[TName], FolioAgentToolOutputByName[TName]>) => FolioAgentTypedToolDefinition<TName, FolioAgentToolInputByName[TName], FolioAgentToolOutputByName[TName]>;
112
112
  //#endregion
113
- export { FolioAgentFindTextScope, FolioAgentShowInDocumentArgs, FolioAgentToolInputByName, FolioAgentToolOutputByName, FolioToolCallResultFor, defineFolioAgentToolDefinition };
113
+ export {};
package/dist/tools.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { FolioAgentApplyOperationsSummary, FolioAgentBlock, FolioAgentChange, FolioAgentComment, FolioAgentCommentFilter, FolioAgentDocumentOutline, FolioAgentScopedFindTextResult, FolioAgentSectionRead, FolioAgentToolDefinition, FolioAgentTypedToolDefinition } from "./types.js";
2
2
  import { FolioAgentToolOptions, FolioSuggestChangesOptions } from "./suggest-changes-options.js";
3
3
  import { FolioAgentFindTextScope, FolioAgentShowInDocumentArgs } from "./tool-contract.js";
4
+ import { FolioDocumentOperationType, FolioDocumentSectionHandle, FolioDocumentStory, FolioDocumentStoryHandle } from "@stll/folio-core/server";
4
5
  //#region src/tools.d.ts
5
6
  /**
6
7
  * `suggest_changes` is a host-configurable projection of the document-operation
@@ -15,7 +16,7 @@ import { FolioAgentFindTextScope, FolioAgentShowInDocumentArgs } from "./tool-co
15
16
  * string (the parser wraps it into `{ text }`). `suggestionId` is host-side
16
17
  * grouping state and is never exposed to the model.
17
18
  */
18
- declare const SUGGEST_CHANGES_OPERATION_TYPES: readonly ("replaceInBlock" | "replaceRange" | "commentOnRange" | "formatRange" | "replaceBlock" | "deleteBlock" | "insertTable" | "deleteTable" | "commentOnBlock" | "insertSignatureTable" | "insertTableRow" | "deleteTableRow" | "insertTableColumn" | "deleteTableColumn" | "mergeTableCells" | "splitTableCell" | "insertAfterBlock" | "insertBeforeBlock" | "splitBlock" | "setBlockParagraphProperties" | "mergeBlockWithNext")[];
19
+ export declare const SUGGEST_CHANGES_OPERATION_TYPES: readonly FolioDocumentOperationType[];
19
20
  /**
20
21
  * Plain-language capability statement for a configured `suggest_changes`
21
22
  * surface: the allowed operations, the structural knobs they unlock, the
@@ -23,7 +24,7 @@ declare const SUGGEST_CHANGES_OPERATION_TYPES: readonly ("replaceInBlock" | "rep
23
24
  * inside the tool description and exported so a host can paste the same
24
25
  * text into its system prompt instead of hand-maintaining a copy that drifts.
25
26
  */
26
- declare const describeSuggestChangesCapabilities: (options?: FolioSuggestChangesOptions) => string;
27
+ export declare const describeSuggestChangesCapabilities: (options?: FolioSuggestChangesOptions) => string;
27
28
  /**
28
29
  * The tools this package exposes, described for an LLM. Every tool that reads
29
30
  * or mutates the document expects `blockId` values that came from
@@ -32,20 +33,20 @@ declare const describeSuggestChangesCapabilities: (options?: FolioSuggestChanges
32
33
  * mutation (`add_comment`, `suggest_changes`) becomes a tracked change or
33
34
  * comment pending human review; nothing is silently finalized.
34
35
  */
35
- declare const FOLIO_AGENT_TOOL_REGISTRY: {
36
+ export declare const FOLIO_AGENT_TOOL_REGISTRY: {
36
37
  readonly read_document: FolioAgentTypedToolDefinition<"read_document", Readonly<Record<string, never>>, FolioAgentBlock[]>;
37
38
  readonly get_document_outline: FolioAgentTypedToolDefinition<"get_document_outline", {
38
39
  maxDepth?: number;
39
40
  }, FolioAgentDocumentOutline>;
40
41
  readonly read_section: FolioAgentTypedToolDefinition<"read_section", {
41
- handle: import("@stll/folio-core/server").FolioDocumentSectionHandle;
42
+ handle: FolioDocumentSectionHandle;
42
43
  maxBlocks?: number;
43
44
  afterBlockId?: string;
44
45
  }, FolioAgentSectionRead>;
45
- readonly list_stories: FolioAgentTypedToolDefinition<"list_stories", Readonly<Record<string, never>>, import("@stll/folio-core/server").FolioDocumentStory[]>;
46
+ readonly list_stories: FolioAgentTypedToolDefinition<"list_stories", Readonly<Record<string, never>>, FolioDocumentStory[]>;
46
47
  readonly read_story: FolioAgentTypedToolDefinition<"read_story", {
47
- handle: import("@stll/folio-core/server").FolioDocumentStoryHandle;
48
- }, import("@stll/folio-core/server").FolioDocumentStory>;
48
+ handle: FolioDocumentStoryHandle;
49
+ }, FolioDocumentStory>;
49
50
  readonly find_text: FolioAgentTypedToolDefinition<"find_text", {
50
51
  query: string;
51
52
  matchCase?: boolean;
@@ -99,7 +100,7 @@ declare const FOLIO_AGENT_TOOL_REGISTRY: {
99
100
  scrolled: boolean;
100
101
  }>;
101
102
  };
102
- declare const FOLIO_AGENT_TOOLS: FolioAgentToolDefinition[];
103
+ export declare const FOLIO_AGENT_TOOLS: FolioAgentToolDefinition[];
103
104
  /**
104
105
  * The tool definitions this package exposes. Without options this is
105
106
  * {@link FOLIO_AGENT_TOOLS}; with `suggestChanges` options the
@@ -107,6 +108,5 @@ declare const FOLIO_AGENT_TOOLS: FolioAgentToolDefinition[];
107
108
  * options to `executeFolioToolCall` so the parser enforces what the schema
108
109
  * advertises.
109
110
  */
110
- declare const getFolioToolDefinitions: (options?: FolioAgentToolOptions) => FolioAgentToolDefinition[];
111
- //#endregion
112
- export { FOLIO_AGENT_TOOLS, FOLIO_AGENT_TOOL_REGISTRY, SUGGEST_CHANGES_OPERATION_TYPES, describeSuggestChangesCapabilities, getFolioToolDefinitions };
111
+ export declare const getFolioToolDefinitions: (options?: FolioAgentToolOptions) => FolioAgentToolDefinition[];
112
+ //#endregion
package/dist/types.d.ts CHANGED
@@ -7,14 +7,14 @@ import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FolioAIDiagnosticBlock, Foli
7
7
  * that single shape onto each SDK's own tool-definition envelope.
8
8
  */
9
9
  declare const folioAgentToolDefinitionBrand: unique symbol;
10
- type FolioAgentJsonObjectSchema = {
10
+ export type FolioAgentJsonObjectSchema = {
11
11
  readonly type: "object";
12
12
  readonly properties: Record<string, unknown>;
13
13
  readonly required: readonly string[];
14
14
  readonly additionalProperties: false;
15
15
  } & Record<string, unknown>;
16
16
  /** Every tool name this package exposes, as a stable string union (no enums). */
17
- declare const FOLIO_AGENT_TOOL_NAMES: {
17
+ export declare const FOLIO_AGENT_TOOL_NAMES: {
18
18
  readonly readDocument: "read_document";
19
19
  readonly getDocumentOutline: "get_document_outline";
20
20
  readonly readSection: "read_section";
@@ -32,19 +32,19 @@ declare const FOLIO_AGENT_TOOL_NAMES: {
32
32
  readonly scrollToBlock: "scroll_to_block";
33
33
  readonly showInDocument: "show_in_document";
34
34
  };
35
- type FolioAgentToolName = (typeof FOLIO_AGENT_TOOL_NAMES)[keyof typeof FOLIO_AGENT_TOOL_NAMES];
35
+ export type FolioAgentToolName = (typeof FOLIO_AGENT_TOOL_NAMES)[keyof typeof FOLIO_AGENT_TOOL_NAMES];
36
36
  /**
37
37
  * A provider-neutral tool definition: name, an LLM-facing description (when to
38
38
  * call it, what it returns), and a JSON-Schema (draft-07-ish) object schema for
39
39
  * its arguments. `providers.ts` maps a list of these onto Anthropic's or
40
40
  * OpenAI's tool-definition shape.
41
41
  */
42
- type FolioAgentToolDefinition = {
42
+ export type FolioAgentToolDefinition = {
43
43
  name: FolioAgentToolName;
44
44
  description: string;
45
45
  inputSchema: Record<string, unknown>;
46
46
  };
47
- type FolioAgentTypedToolDefinition<TName extends FolioAgentToolName = FolioAgentToolName, TInput = unknown, TOutput = unknown, TSchema extends FolioAgentJsonObjectSchema = FolioAgentJsonObjectSchema> = FolioAgentToolDefinition & {
47
+ export type FolioAgentTypedToolDefinition<TName extends FolioAgentToolName = FolioAgentToolName, TInput = unknown, TOutput = unknown, TSchema extends FolioAgentJsonObjectSchema = FolioAgentJsonObjectSchema> = FolioAgentToolDefinition & {
48
48
  readonly name: TName;
49
49
  readonly inputSchema: TSchema;
50
50
  readonly [folioAgentToolDefinitionBrand]?: {
@@ -60,7 +60,7 @@ type FolioAgentTypedToolDefinition<TName extends FolioAgentToolName = FolioAgent
60
60
  * is the only boundary layer allowed to catch an unexpected throw and fold it
61
61
  * into this shape too.
62
62
  */
63
- type FolioToolCallResult<TResult = unknown> = {
63
+ export type FolioToolCallResult<TResult = unknown> = {
64
64
  ok: true;
65
65
  result: TResult;
66
66
  } | {
@@ -95,7 +95,7 @@ type FolioAgentBlockFields = {
95
95
  */
96
96
  blockTextHash: string;
97
97
  };
98
- type FolioAgentBlock = (FolioAgentBlockFields & {
98
+ export type FolioAgentBlock = (FolioAgentBlockFields & {
99
99
  kind: FolioAIParagraphBlock["kind"];
100
100
  /** Exact authored numbering state; `inherit` means no direct override. */
101
101
  statedNumbering: FolioAIParagraphBlock["statedNumbering"];
@@ -105,7 +105,7 @@ type FolioAgentBlock = (FolioAgentBlockFields & {
105
105
  kind: FolioAIDiagnosticBlock["kind"];
106
106
  });
107
107
  /** One main-story `find_text` match. Existing consumers can keep using its block and range directly. */
108
- type FolioAgentTextMatch = {
108
+ export type FolioAgentTextMatch = {
109
109
  /** Present on results from the current executor; optional for source compatibility with older hosts. */
110
110
  type?: "main";
111
111
  story?: {
@@ -122,7 +122,7 @@ type FolioAgentTextMatch = {
122
122
  page?: number;
123
123
  context: string;
124
124
  };
125
- type FolioAgentStoryTextMatch = {
125
+ export type FolioAgentStoryTextMatch = {
126
126
  type: "story";
127
127
  story: Exclude<FolioDocumentStoryHandle, {
128
128
  type: "main";
@@ -133,15 +133,15 @@ type FolioAgentStoryTextMatch = {
133
133
  occurrenceInStory: number;
134
134
  context: string;
135
135
  };
136
- type FolioAgentOutlineEntry = FolioDocumentOutlineEntry & {
136
+ export type FolioAgentOutlineEntry = FolioDocumentOutlineEntry & {
137
137
  page?: number;
138
138
  };
139
- type FolioAgentDocumentOutline = {
139
+ export type FolioAgentDocumentOutline = {
140
140
  sections: FolioAgentOutlineEntry[];
141
141
  totalSections: number;
142
142
  truncated: boolean;
143
143
  };
144
- type FolioAgentSectionRead = {
144
+ export type FolioAgentSectionRead = {
145
145
  handle: FolioDocumentSectionHandle;
146
146
  heading: FolioDocumentOutlineEntry;
147
147
  blocks: FolioAgentBlock[];
@@ -155,19 +155,19 @@ type FolioAgentSectionRead = {
155
155
  * and `totalMatches` reports the real count so the model knows to narrow the
156
156
  * query instead of assuming it saw everything.
157
157
  */
158
- type FolioAgentFindTextResult = {
158
+ export type FolioAgentFindTextResult = {
159
159
  matches: FolioAgentTextMatch[];
160
160
  truncated: boolean;
161
161
  totalMatches: number;
162
162
  };
163
- type FolioAgentStoryFindTextResult = {
163
+ export type FolioAgentStoryFindTextResult = {
164
164
  matches: FolioAgentStoryTextMatch[];
165
165
  truncated: boolean;
166
166
  totalMatches: number;
167
167
  };
168
- type FolioAgentScopedFindTextResult = FolioAgentFindTextResult | FolioAgentStoryFindTextResult;
168
+ export type FolioAgentScopedFindTextResult = FolioAgentFindTextResult | FolioAgentStoryFindTextResult;
169
169
  /** One reply within a comment thread. */
170
- type FolioAgentCommentReply = {
170
+ export type FolioAgentCommentReply = {
171
171
  id: string;
172
172
  author: string;
173
173
  text: string;
@@ -179,7 +179,7 @@ type FolioAgentCommentReply = {
179
179
  * `done` flag; `quote` mirrors `anchoredText` (the text the comment is
180
180
  * attached to, empty when unavailable).
181
181
  */
182
- type FolioAgentComment = {
182
+ export type FolioAgentComment = {
183
183
  id: string;
184
184
  author: string;
185
185
  text: string;
@@ -189,7 +189,7 @@ type FolioAgentComment = {
189
189
  replies: FolioAgentCommentReply[];
190
190
  };
191
191
  /** A pending tracked change, shaped to match {@link FolioDocxReviewer.getChanges}. */
192
- type FolioAgentChange = {
192
+ export type FolioAgentChange = {
193
193
  id: string;
194
194
  type: FolioReviewChange["type"];
195
195
  author: string;
@@ -197,20 +197,20 @@ type FolioAgentChange = {
197
197
  blockId: string | null;
198
198
  };
199
199
  /** Filter for {@link FOLIO_AGENT_TOOL_NAMES.readComments}. */
200
- type FolioAgentCommentFilter = "all" | "open" | "resolved";
200
+ export type FolioAgentCommentFilter = "all" | "open" | "resolved";
201
201
  /**
202
202
  * One lenient-decoding step the parser took on a tool call's arguments
203
203
  * (a `kind` key read as `type`, an operation supplied as a JSON string, a
204
204
  * stray property dropped). Reported back to the model so sloppy calls
205
205
  * still succeed without the normalisation going unnoticed.
206
206
  */
207
- type FolioAgentInputNormalization = {
207
+ export type FolioAgentInputNormalization = {
208
208
  /** Where in the arguments, e.g. `operations[2].kind`. */
209
209
  path: string;
210
210
  message: string;
211
211
  };
212
212
  /** Result of {@link FOLIO_AGENT_TOOL_NAMES.addComment} / `suggest_changes`. */
213
- type FolioAgentApplyOperationsSummary = {
213
+ export type FolioAgentApplyOperationsSummary = {
214
214
  version: typeof FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION;
215
215
  applied: {
216
216
  id: string;
@@ -236,4 +236,4 @@ type FolioAgentApplyOperationsSummary = {
236
236
  normalizations: FolioAgentInputNormalization[];
237
237
  };
238
238
  //#endregion
239
- export { FOLIO_AGENT_TOOL_NAMES, FolioAgentApplyOperationsSummary, FolioAgentBlock, FolioAgentChange, FolioAgentComment, FolioAgentCommentFilter, FolioAgentCommentReply, FolioAgentDocumentOutline, FolioAgentFindTextResult, FolioAgentInputNormalization, FolioAgentJsonObjectSchema, FolioAgentOutlineEntry, FolioAgentScopedFindTextResult, FolioAgentSectionRead, FolioAgentStoryFindTextResult, FolioAgentStoryTextMatch, FolioAgentTextMatch, FolioAgentToolDefinition, FolioAgentToolName, FolioAgentTypedToolDefinition, FolioToolCallResult };
239
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-agents",
3
- "version": "0.16.3",
3
+ "version": "0.16.5",
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",
@@ -56,8 +56,8 @@
56
56
  "test": "bun test src"
57
57
  },
58
58
  "dependencies": {
59
- "@stll/folio-core": "^0.62.0",
60
- "@stll/utf8-boundaries": "0.1.0",
59
+ "@stll/folio-core": "^0.63.1",
60
+ "@stll/utf8-boundaries": "0.1.2",
61
61
  "better-result": "3.0.1"
62
62
  },
63
63
  "peerDependencies": {
@@ -79,9 +79,9 @@ since a headless document has no live page/selection/scroll surface at all.
79
79
  ## Configuring `suggest_changes`
80
80
 
81
81
  `suggest_changes` is configured per host surface, never re-derived. Pass one
82
- `FolioSuggestChangesOptions` object to both `getFolioToolDefinitions({
83
- suggestChanges })` and `executeFolioToolCall(name, args, bridge, {
84
- suggestChanges })`:
82
+ `FolioSuggestChangesOptions` object to both
83
+ `getFolioToolDefinitions({ suggestChanges })` and
84
+ `executeFolioToolCall(name, args, bridge, { suggestChanges })`:
85
85
 
86
86
  - `operationTypes`: any subset of the contract's operation types (default:
87
87
  everything except `commentOnBlock`, covered by `add_comment`, and
@@ -213,8 +213,8 @@ Two different questions, two different tools:
213
213
  - **Pending redlines in one document** — what a reviewer would see as tracked
214
214
  changes right now: use the `read_changes` tool on a capable bridge or call
215
215
  `reviewer.getChanges()` directly.
216
- - **Between two saved `.docx` versions** — `compareDocxVersions(previousBuffer,
217
- currentBuffer)` + `formatVersionDiffForLLM(diff)`. Both are plain async
216
+ - **Between two saved `.docx` versions** —
217
+ `compareDocxVersions(previousBuffer, currentBuffer)` + `formatVersionDiffForLLM(diff)`. Both are plain async
218
218
  functions, not tool definitions: a model can't attach two buffers to one
219
219
  tool call (they aren't JSON-serializable arguments). Wrap them in a
220
220
  host-side tool keyed by version identifiers instead — the model calls it