@stll/folio-agents 0.8.2 → 0.8.4

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/bridge.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { FolioAgentChange, FolioAgentComment } from "./types.js";
2
2
  import { FolioAIEditSnapshot, FolioDocumentNavigationTarget, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, FolioDocumentStory, FolioDocumentStoryHandle } from "@stll/folio-core/server";
3
-
4
3
  //#region src/bridge.d.ts
5
4
  /**
6
5
  * The structural contract every folio surface (headless reviewer, live
@@ -16,24 +15,38 @@ import { FolioAIEditSnapshot, FolioDocumentNavigationTarget, FolioDocumentOperat
16
15
  * crash.
17
16
  */
18
17
  type FolioAgentBridge = {
19
- /** Snapshot the current document into AI-facing blocks + anchors. */snapshot(): FolioAIEditSnapshot;
18
+ /** Snapshot the current document into AI-facing blocks + anchors. */
19
+ snapshot(): FolioAIEditSnapshot;
20
20
  /**
21
21
  * Apply a versioned operation batch against the current document. The
22
22
  * bridge decides mode (tracked-changes by default) and author internally.
23
23
  */
24
- applyDocumentOperations(batch: FolioDocumentOperationBatch): FolioDocumentOperationResult; /** Undo the latest unchanged batch when the execution surface supports it. */
25
- undoDocumentOperations?(undoHandle: FolioDocumentOperationUndoHandle): FolioDocumentOperationUndoResult; /** The comment threads present in the document. */
26
- getComments(): FolioAgentComment[]; /** The pending tracked changes (insertions/deletions) present in the document. */
27
- getChanges(): FolioAgentChange[]; /** Discover typed document stories when the surface exposes package parts. */
28
- listStories?(): FolioDocumentStory[]; /** Read one previously discovered story. */
29
- readStory?(handle: FolioDocumentStoryHandle): FolioDocumentStory | null; /** Reply to a comment thread. Returns `false` when the target comment does not exist. */
30
- replyToComment(commentId: string, text: string): boolean; /** Mark a comment thread resolved or reopen it. Returns `false` when the target comment does not exist. */
31
- resolveComment(commentId: string, resolved: boolean): boolean; /** Scroll the live editor to the given block and select it. */
32
- scrollToBlock?(blockId: string): boolean; /** The user's current text selection in the live editor, as plain text. */
33
- getSelectionText?(): string; /** Total page count in the live, paginated editor. */
34
- getPageCount?(): number; /** Plain text of the given 1-based page in the live editor. */
35
- getPageText?(page: number): string; /** Resolve a main-story block or exact text range to its real rendered page. */
36
- getTargetPage?(target: FolioDocumentNavigationTarget): number | null; /** Select and reveal a stable block or text range in the live editor. */
24
+ applyDocumentOperations(batch: FolioDocumentOperationBatch): FolioDocumentOperationResult;
25
+ /** Undo the latest unchanged batch when the execution surface supports it. */
26
+ undoDocumentOperations?(undoHandle: FolioDocumentOperationUndoHandle): FolioDocumentOperationUndoResult;
27
+ /** The comment threads present in the document. */
28
+ getComments(): FolioAgentComment[];
29
+ /** The pending tracked changes (insertions/deletions) present in the document. */
30
+ getChanges(): FolioAgentChange[];
31
+ /** Discover typed document stories when the surface exposes package parts. */
32
+ listStories?(): FolioDocumentStory[];
33
+ /** Read one previously discovered story. */
34
+ readStory?(handle: FolioDocumentStoryHandle): FolioDocumentStory | null;
35
+ /** Reply to a comment thread. Returns `false` when the target comment does not exist. */
36
+ replyToComment(commentId: string, text: string): boolean;
37
+ /** Mark a comment thread resolved or reopen it. Returns `false` when the target comment does not exist. */
38
+ resolveComment(commentId: string, resolved: boolean): boolean;
39
+ /** Scroll the live editor to the given block and select it. */
40
+ scrollToBlock?(blockId: string): boolean;
41
+ /** The user's current text selection in the live editor, as plain text. */
42
+ getSelectionText?(): string;
43
+ /** Total page count in the live, paginated editor. */
44
+ getPageCount?(): number;
45
+ /** Plain text of the given 1-based page in the live editor. */
46
+ getPageText?(page: number): string;
47
+ /** Resolve a main-story block or exact text range to its real rendered page. */
48
+ getTargetPage?(target: FolioDocumentNavigationTarget): number | null;
49
+ /** Select and reveal a stable block or text range in the live editor. */
37
50
  showInDocument?(target: FolioDocumentNavigationTarget): boolean;
38
51
  };
39
52
  //#endregion
@@ -2,7 +2,6 @@ import { FolioAgentBridge } from "../bridge.js";
2
2
  import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioDocumentNavigationTarget, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult } from "@stll/folio-core/server";
3
3
  import { FolioCommentAnchor, FolioReviewChange as FolioReviewChange$1 } from "@stll/folio-core/ai-edits";
4
4
  import { Comment } from "@stll/folio-core/types/content";
5
-
6
5
  //#region src/bridges/editor-ref.d.ts
7
6
  type FolioAgentEditorApplyDocumentOperationsOptions = {
8
7
  snapshot: FolioAIEditSnapshot;
@@ -24,16 +23,22 @@ type FolioAgentEditorApplyDocumentOperationsOptions = {
24
23
  * not find.
25
24
  */
26
25
  type FolioAgentEditorRefLike = {
27
- /** `DocxEditorRef.createAIEditSnapshot`. `null` before the editor view mounts. */createAIEditSnapshot(): FolioAIEditSnapshot | null; /** `DocxEditorRef.applyAIEditOperations`. */
26
+ /** `DocxEditorRef.createAIEditSnapshot`. `null` before the editor view mounts. */
27
+ createAIEditSnapshot(): FolioAIEditSnapshot | null;
28
+ /** `DocxEditorRef.applyAIEditOperations`. */
28
29
  applyAIEditOperations(options: {
29
30
  snapshot: FolioAIEditSnapshot;
30
31
  operations: FolioAIEditOperation[];
31
32
  mode?: FolioAIEditApplyMode;
32
33
  author?: string;
33
- }): FolioAIEditApplyResult; /** `DocxEditorRef.applyDocumentOperations`, when available on newer refs. */
34
- applyDocumentOperations?(options: FolioAgentEditorApplyDocumentOperationsOptions): FolioDocumentOperationResult; /** `DocxEditorRef.undoDocumentOperations`, when available on newer refs. */
35
- undoDocumentOperations?(undoHandle: FolioDocumentOperationUndoHandle): FolioDocumentOperationUndoResult; /** `DocxEditorRef.scrollToBlock`. */
36
- scrollToBlock(blockId: string, snapshot?: FolioAIEditSnapshot): boolean; /** `DocxEditorRef.getTotalPages`. */
34
+ }): FolioAIEditApplyResult;
35
+ /** `DocxEditorRef.applyDocumentOperations`, when available on newer refs. */
36
+ applyDocumentOperations?(options: FolioAgentEditorApplyDocumentOperationsOptions): FolioDocumentOperationResult;
37
+ /** `DocxEditorRef.undoDocumentOperations`, when available on newer refs. */
38
+ undoDocumentOperations?(undoHandle: FolioDocumentOperationUndoHandle): FolioDocumentOperationUndoResult;
39
+ /** `DocxEditorRef.scrollToBlock`. */
40
+ scrollToBlock(blockId: string, snapshot?: FolioAIEditSnapshot): boolean;
41
+ /** `DocxEditorRef.getTotalPages`. */
37
42
  getTotalPages(): number;
38
43
  /**
39
44
  * `DocxEditorRef.getTrackedChanges`. When present, `getChanges()` maps its
@@ -59,16 +64,22 @@ type FolioAgentEditorRefLike = {
59
64
  * on a ref that lacks it. See {@link createEditorRefBridge} for how a
60
65
  * `null` return (page in range, layout not yet computed) is handled.
61
66
  */
62
- getPageText?(page: number): string | null; /** `DocxEditorRef.getTargetPage`, when available on newer refs. */
63
- getTargetPage?(target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot): number | null; /** `DocxEditorRef.showInDocument`, when available on newer refs. */
67
+ getPageText?(page: number): string | null;
68
+ /** `DocxEditorRef.getTargetPage`, when available on newer refs. */
69
+ getTargetPage?(target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot): number | null;
70
+ /** `DocxEditorRef.showInDocument`, when available on newer refs. */
64
71
  showInDocument?(target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot): boolean;
65
72
  };
66
73
  /** Options for {@link createEditorRefBridge}. */
67
74
  type CreateEditorRefBridgeOptions = {
68
- ref: FolioAgentEditorRefLike; /** Author attributed to tracked changes, comments, and replies this bridge creates. */
69
- author: string; /** Read the host app's current comment state (e.g. the `DocxEditor` `comments` prop). */
70
- getComments(): Comment[]; /** Replace the host app's comment state (e.g. the setter backing that same prop). */
71
- setComments(comments: Comment[]): void; /** `"tracked-changes"` (default) produces ins/del redlines; `"direct"` edits in place. */
75
+ ref: FolioAgentEditorRefLike;
76
+ /** Author attributed to tracked changes, comments, and replies this bridge creates. */
77
+ author: string;
78
+ /** Read the host app's current comment state (e.g. the `DocxEditor` `comments` prop). */
79
+ getComments(): Comment[];
80
+ /** Replace the host app's comment state (e.g. the setter backing that same prop). */
81
+ setComments(comments: Comment[]): void;
82
+ /** `"tracked-changes"` (default) produces ins/del redlines; `"direct"` edits in place. */
72
83
  mode?: FolioAIEditApplyMode;
73
84
  };
74
85
  /**
@@ -1,10 +1,10 @@
1
1
  import { FolioAgentBridge } from "../bridge.js";
2
2
  import { FolioAIEditApplyMode, FolioDocxReviewer } from "@stll/folio-core/server";
3
-
4
3
  //#region src/bridges/reviewer.d.ts
5
4
  /** Options for {@link createReviewerBridge}. */
6
5
  type CreateReviewerBridgeOptions = {
7
- /** `"tracked-changes"` (default) produces ins/del redlines; `"direct"` edits in place. */mode?: FolioAIEditApplyMode;
6
+ /** `"tracked-changes"` (default) produces ins/del redlines; `"direct"` edits in place. */
7
+ mode?: FolioAIEditApplyMode;
8
8
  };
9
9
  /**
10
10
  * Build a {@link FolioAgentBridge} over a headless {@link FolioDocxReviewer}
@@ -1,6 +1,5 @@
1
1
  import { FolioAgentChange } from "../types.js";
2
2
  import { FolioReviewChange } from "@stll/folio-core/server";
3
-
4
3
  //#region src/bridges/shared.d.ts
5
4
  /**
6
5
  * Map a core {@link FolioReviewChange} — from `FolioDocxReviewer.getChanges`
package/dist/compare.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { FolioBlockDiff, FolioCompareDocxVersionsOptions, FolioVersionDiff, FolioVersionDiffSegment, GenerateRedlineDocxOptions, GenerateRedlineDocxResult } from "@stll/folio-core/server";
2
-
3
2
  //#region src/compare.d.ts
4
3
  /** Backward-compatible name for a core word-level version-diff segment. */
5
4
  type FolioAgentVersionDiffSegment = FolioVersionDiffSegment;
package/dist/execute.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { FolioToolCallResult } from "./types.js";
2
2
  import { FolioAgentBridge } from "./bridge.js";
3
-
4
3
  //#region src/execute.d.ts
5
4
  /**
6
5
  * Execute one tool call against a {@link FolioAgentBridge}. Every EXPECTED
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { compareDocxVersions, formatVersionDiffForLLM, generateRedlineDocx } from "./compare.js";
2
- import { parseAddCommentInput, parseSuggestChangesInput } from "./parse.js";
3
- import { FOLIO_AGENT_TOOL_NAMES } from "./types.js";
4
- import { executeFolioToolCall } from "./execute.js";
5
1
  import { createEditorRefBridge } from "./bridges/editor-ref.js";
6
2
  import { createReviewerBridge } from "./bridges/reviewer.js";
3
+ import { compareDocxVersions, formatVersionDiffForLLM, generateRedlineDocx } from "./compare.js";
4
+ import { executeFolioToolCall } from "./execute.js";
7
5
  import { FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, folioDocumentOperationBatchSchema } from "./operation-schema.js";
6
+ import { parseAddCommentInput, parseSuggestChangesInput } from "./parse.js";
8
7
  import { toAnthropicTools, toOpenAITools } from "./providers.js";
9
8
  import { FOLIO_AGENT_TOOLS, getFolioToolDefinitions } from "./tools.js";
9
+ import { FOLIO_AGENT_TOOL_NAMES } from "./types.js";
10
10
  export { FOLIO_AGENT_TOOLS, FOLIO_AGENT_TOOL_NAMES, FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, compareDocxVersions, createEditorRefBridge, createReviewerBridge, executeFolioToolCall, folioDocumentOperationBatchSchema, formatVersionDiffForLLM, generateRedlineDocx, getFolioToolDefinitions, parseAddCommentInput, parseSuggestChangesInput, toAnthropicTools, toOpenAITools };
@@ -1,5 +1,4 @@
1
1
  import { FolioDocumentOperationBatch } from "@stll/folio-core/server";
2
-
3
2
  //#region src/operation-schema.d.ts
4
3
  /**
5
4
  * JSON Schema for the contract's `textRange` handle (a serializable range
package/dist/parse.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { FolioAIEditOperation } from "@stll/folio-core/server";
2
-
3
2
  //#region src/parse.d.ts
4
3
  /**
5
4
  * Hard caps on `suggest_changes` / `add_comment` / `reply_comment` input
@@ -1,5 +1,4 @@
1
1
  import { FolioAgentToolDefinition } from "./types.js";
2
-
3
2
  //#region src/providers.d.ts
4
3
  /** Anthropic Messages API tool-definition shape (`input_schema`, snake_case). */
5
4
  type AnthropicToolDefinition = {
package/dist/tools.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { FolioAgentToolDefinition } from "./types.js";
2
2
  import { FolioDocumentOperationType } from "@stll/folio-core/server";
3
-
4
3
  //#region src/tools.d.ts
5
4
  /**
6
5
  * The contract operation types `suggest_changes` exposes to the model,
package/dist/tools.js CHANGED
@@ -1,5 +1,5 @@
1
- import { FOLIO_AGENT_TOOL_NAMES } from "./types.js";
2
1
  import { FOLIO_PRECONDITION_JSON_SCHEMA, FOLIO_TEXT_RANGE_JSON_SCHEMA } from "./operation-schema.js";
2
+ import { FOLIO_AGENT_TOOL_NAMES } from "./types.js";
3
3
  import { FOLIO_DOCUMENT_OPERATION_TYPES } from "@stll/folio-core/server";
4
4
  //#region src/tools.ts
5
5
  const storyHandleSchema = {
package/dist/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FolioAITextRangeHandle, FolioDocumentOperationIssue, FolioDocumentOperationReceipt, FolioDocumentOutlineEntry, FolioDocumentSectionHandle, FolioDocumentStoryHandle, FolioReviewChange } from "@stll/folio-core/server";
2
-
3
2
  //#region src/types.d.ts
4
3
  /**
5
4
  * Provider-neutral tool-layer types. `FolioAgentToolDefinition` describes a
@@ -70,14 +69,19 @@ type FolioAgentBlock = {
70
69
  };
71
70
  /** One main-story `find_text` match. Existing consumers can keep using its block and range directly. */
72
71
  type FolioAgentTextMatch = {
73
- /** Present on results from the current executor; optional for source compatibility with older hosts. */type?: "main";
72
+ /** Present on results from the current executor; optional for source compatibility with older hosts. */
73
+ type?: "main";
74
74
  story?: {
75
75
  type: "main";
76
76
  };
77
- blockId: string; /** Normalized-text hash of the whole containing block; see {@link FolioAgentBlock.blockTextHash}. */
78
- blockTextHash: string; /** Stable handle that can be passed directly to `show_in_document` or a range operation. */
79
- range: FolioAITextRangeHandle; /** 0-based index of this occurrence within its block. */
80
- occurrenceInBlock: number; /** Real rendered page when a live paginated surface supplies it. */
77
+ blockId: string;
78
+ /** Normalized-text hash of the whole containing block; see {@link FolioAgentBlock.blockTextHash}. */
79
+ blockTextHash: string;
80
+ /** Stable handle that can be passed directly to `show_in_document` or a range operation. */
81
+ range: FolioAITextRangeHandle;
82
+ /** 0-based index of this occurrence within its block. */
83
+ occurrenceInBlock: number;
84
+ /** Real rendered page when a live paginated surface supplies it. */
81
85
  page?: number;
82
86
  context: string;
83
87
  };
@@ -87,7 +91,8 @@ type FolioAgentStoryTextMatch = {
87
91
  type: "main";
88
92
  }>;
89
93
  startOffset: number;
90
- endOffset: number; /** 0-based index of this occurrence within the story. */
94
+ endOffset: number;
95
+ /** 0-based index of this occurrence within the story. */
91
96
  occurrenceInStory: number;
92
97
  context: string;
93
98
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-agents",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
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.15.0"
57
+ "@stll/folio-core": "^0.17.0"
58
58
  },
59
59
  "main": "./dist/index.js",
60
60
  "types": "./dist/index.d.ts"