@stll/folio-agents 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge.d.ts +28 -15
- package/dist/bridges/editor-ref.d.ts +23 -12
- package/dist/bridges/reviewer.d.ts +2 -2
- package/dist/bridges/shared.d.ts +0 -1
- package/dist/compare.d.ts +0 -1
- package/dist/execute.d.ts +0 -1
- package/dist/index.js +4 -4
- package/dist/operation-schema.d.ts +0 -1
- package/dist/parse.d.ts +0 -1
- package/dist/providers.d.ts +0 -1
- package/dist/tools.d.ts +0 -1
- package/dist/tools.js +1 -1
- package/dist/types.d.ts +12 -7
- package/package.json +2 -2
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. */
|
|
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;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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. */
|
|
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;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
63
|
-
|
|
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;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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. */
|
|
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}
|
package/dist/bridges/shared.d.ts
CHANGED
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
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 };
|
package/dist/parse.d.ts
CHANGED
package/dist/providers.d.ts
CHANGED
package/dist/tools.d.ts
CHANGED
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. */
|
|
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;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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;
|
|
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.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Framework-neutral LLM tool layer over folio's ai-edits engine: function-calling tools so an agent can read and mutate .docx documents through @stll/folio-core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"test": "bun test src"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@stll/folio-core": "^0.
|
|
57
|
+
"@stll/folio-core": "^0.16.0"
|
|
58
58
|
},
|
|
59
59
|
"main": "./dist/index.js",
|
|
60
60
|
"types": "./dist/index.d.ts"
|