@stll/folio-agents 0.5.0 → 0.6.0
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 +15 -0
- package/dist/compare.d.ts +11 -3
- package/dist/compare.js +14 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/skills/folio-agents/SKILL.md +4 -0
package/README.md
CHANGED
|
@@ -181,6 +181,21 @@ The natural shape is a host-side tool keyed by version identifiers instead
|
|
|
181
181
|
(e.g. a server tool the model calls with two stored version ids, which your
|
|
182
182
|
backend resolves to buffers, diffs, and returns the formatted text for).
|
|
183
183
|
|
|
184
|
+
To produce a reviewable package from the same pair of buffers, use
|
|
185
|
+
`generateRedlineDocx`. Optional package-metadata privacy transforms are applied
|
|
186
|
+
to the generated output and returned as a structured report:
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
import { generateRedlineDocx } from "@stll/folio-agents";
|
|
190
|
+
|
|
191
|
+
const result = await generateRedlineDocx(previousVersionBuffer, currentVersionBuffer, {
|
|
192
|
+
privacy: { transforms: ["remove-attribution", "remove-timestamps"] },
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
await storeGeneratedPackage(result.buffer);
|
|
196
|
+
console.log(result.privacyReport);
|
|
197
|
+
```
|
|
198
|
+
|
|
184
199
|
## TanStack AI
|
|
185
200
|
|
|
186
201
|
TanStack AI's `toolDefinition` accepts a raw JSON Schema object as
|
package/dist/compare.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FolioBlockDiff, FolioVersionDiff, FolioVersionDiffSegment } from "@stll/folio-core/server";
|
|
1
|
+
import { FolioBlockDiff, FolioCompareDocxVersionsOptions, FolioVersionDiff, FolioVersionDiffSegment, GenerateRedlineDocxOptions, GenerateRedlineDocxResult } from "@stll/folio-core/server";
|
|
2
2
|
|
|
3
3
|
//#region src/compare.d.ts
|
|
4
4
|
/** Backward-compatible name for a core word-level version-diff segment. */
|
|
@@ -7,9 +7,17 @@ type FolioAgentVersionDiffSegment = FolioVersionDiffSegment;
|
|
|
7
7
|
type FolioAgentBlockDiff = FolioBlockDiff;
|
|
8
8
|
/** Backward-compatible name for a structured core version diff. */
|
|
9
9
|
type FolioAgentVersionDiff = FolioVersionDiff;
|
|
10
|
+
/** Backward-compatible name for core comparison options. */
|
|
11
|
+
type FolioAgentCompareDocxVersionsOptions = FolioCompareDocxVersionsOptions;
|
|
12
|
+
/** Agent-facing name for core redline-generation options. */
|
|
13
|
+
type FolioAgentGenerateRedlineDocxOptions = GenerateRedlineDocxOptions;
|
|
14
|
+
/** Agent-facing name for the core redline-generation result. */
|
|
15
|
+
type FolioAgentGenerateRedlineDocxResult = GenerateRedlineDocxResult;
|
|
10
16
|
/** Compare two `.docx` buffers using folio-core's version comparison semantics. */
|
|
11
|
-
declare const compareDocxVersions: (base: ArrayBuffer, revised: ArrayBuffer) => Promise<FolioAgentVersionDiff>;
|
|
17
|
+
declare const compareDocxVersions: (base: ArrayBuffer, revised: ArrayBuffer, options?: FolioAgentCompareDocxVersionsOptions) => Promise<FolioAgentVersionDiff>;
|
|
18
|
+
/** Generate a reviewed package from two `.docx` buffers. */
|
|
19
|
+
declare const generateRedlineDocx: (base: ArrayBuffer, revised: ArrayBuffer, options?: FolioAgentGenerateRedlineDocxOptions) => Promise<FolioAgentGenerateRedlineDocxResult>;
|
|
12
20
|
/** Render a structured version diff as compact, deterministic model input. */
|
|
13
21
|
declare const formatVersionDiffForLLM: (diff: FolioAgentVersionDiff) => string;
|
|
14
22
|
//#endregion
|
|
15
|
-
export { FolioAgentBlockDiff, FolioAgentVersionDiff, FolioAgentVersionDiffSegment, compareDocxVersions, formatVersionDiffForLLM };
|
|
23
|
+
export { FolioAgentBlockDiff, FolioAgentCompareDocxVersionsOptions, FolioAgentGenerateRedlineDocxOptions, FolioAgentGenerateRedlineDocxResult, FolioAgentVersionDiff, FolioAgentVersionDiffSegment, compareDocxVersions, formatVersionDiffForLLM, generateRedlineDocx };
|
package/dist/compare.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { compareDocxVersions as compareDocxVersions$1 } from "@stll/folio-core/server";
|
|
1
|
+
import { compareDocxVersions as compareDocxVersions$1, generateRedlineDocx as generateRedlineDocx$1 } from "@stll/folio-core/server";
|
|
2
2
|
//#region src/compare.ts
|
|
3
3
|
/** Compare two `.docx` buffers using folio-core's version comparison semantics. */
|
|
4
|
-
const compareDocxVersions = (base, revised) => compareDocxVersions$1(base, revised);
|
|
4
|
+
const compareDocxVersions = (base, revised, options = {}) => compareDocxVersions$1(base, revised, options);
|
|
5
|
+
/** Generate a reviewed package from two `.docx` buffers. */
|
|
6
|
+
const generateRedlineDocx = (base, revised, options = {}) => generateRedlineDocx$1(base, revised, options);
|
|
5
7
|
const ELLIPSIS = "…";
|
|
6
8
|
const UNCHANGED_EDGE_CHARS = 30;
|
|
7
9
|
const truncateUnchangedRun = (text) => {
|
|
@@ -29,8 +31,15 @@ const formatChangeLine = (change) => {
|
|
|
29
31
|
};
|
|
30
32
|
/** Render a structured version diff as compact, deterministic model input. */
|
|
31
33
|
const formatVersionDiffForLLM = (diff) => {
|
|
32
|
-
const { added, deleted, modified, formatChanged, moved, unchanged } = diff.summaryCounts;
|
|
33
|
-
|
|
34
|
+
const { added, deleted, modified, formatChanged, moved, metadataChanged, unchanged } = diff.summaryCounts;
|
|
35
|
+
const header = `Version diff: ${added} added, ${deleted} deleted, ${modified} modified, ${formatChanged} format-changed, ${moved} moved${metadataChanged > 0 ? `, ${metadataChanged} metadata-changed` : ""}, ${unchanged} unchanged`;
|
|
36
|
+
const metadataLines = diff.metadataChanges.map(({ property, baseValue, revisedValue }) => `~ metadata.${property}: ${JSON.stringify(baseValue)} -> ${JSON.stringify(revisedValue)}`);
|
|
37
|
+
return [
|
|
38
|
+
header,
|
|
39
|
+
...diff.privacyReport.appliedTransforms.length === 0 ? [] : [`Privacy transforms: ${diff.privacyReport.appliedTransforms.join(", ")}`, `Removed metadata fields: ${diff.privacyReport.removedMetadataProperties.join(", ") || "none"}`],
|
|
40
|
+
...diff.changes.map(formatChangeLine),
|
|
41
|
+
...metadataLines
|
|
42
|
+
].join("\n");
|
|
34
43
|
};
|
|
35
44
|
//#endregion
|
|
36
|
-
export { compareDocxVersions, formatVersionDiffForLLM };
|
|
45
|
+
export { compareDocxVersions, formatVersionDiffForLLM, generateRedlineDocx };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { FOLIO_AGENT_TOOL_NAMES, FolioAgentApplyOperationsSummary, FolioAgentBlo
|
|
|
2
2
|
import { FolioAgentBridge } from "./bridge.js";
|
|
3
3
|
import { CreateEditorRefBridgeOptions, FolioAgentEditorApplyDocumentOperationsOptions, FolioAgentEditorRefLike, createEditorRefBridge } from "./bridges/editor-ref.js";
|
|
4
4
|
import { CreateReviewerBridgeOptions, createReviewerBridge } from "./bridges/reviewer.js";
|
|
5
|
-
import { FolioAgentBlockDiff, FolioAgentVersionDiff, FolioAgentVersionDiffSegment, compareDocxVersions, formatVersionDiffForLLM } from "./compare.js";
|
|
5
|
+
import { FolioAgentBlockDiff, FolioAgentCompareDocxVersionsOptions, FolioAgentGenerateRedlineDocxOptions, FolioAgentGenerateRedlineDocxResult, FolioAgentVersionDiff, FolioAgentVersionDiffSegment, compareDocxVersions, formatVersionDiffForLLM, generateRedlineDocx } from "./compare.js";
|
|
6
6
|
import { executeFolioToolCall } from "./execute.js";
|
|
7
7
|
import { FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, folioDocumentOperationBatchSchema } from "./operation-schema.js";
|
|
8
8
|
import { ParseAddCommentResult, ParseSuggestChangesResult, parseAddCommentInput, parseSuggestChangesInput } from "./parse.js";
|
|
9
9
|
import { AnthropicToolDefinition, OpenAIToolDefinition, toAnthropicTools, toOpenAITools } from "./providers.js";
|
|
10
10
|
import { FOLIO_AGENT_TOOLS, getFolioToolDefinitions } from "./tools.js";
|
|
11
|
-
export { type AnthropicToolDefinition, type CreateEditorRefBridgeOptions, type CreateReviewerBridgeOptions, FOLIO_AGENT_TOOLS, FOLIO_AGENT_TOOL_NAMES, FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, type FolioAgentApplyOperationsSummary, type FolioAgentBlock, type FolioAgentBlockDiff, type FolioAgentBridge, type FolioAgentChange, type FolioAgentComment, type FolioAgentCommentFilter, type FolioAgentCommentReply, type FolioAgentDocumentOutline, type FolioAgentEditorApplyDocumentOperationsOptions, type FolioAgentEditorRefLike, type FolioAgentOutlineEntry, type FolioAgentScopedFindTextResult, type FolioAgentSectionRead, type FolioAgentStoryFindTextResult, type FolioAgentStoryTextMatch, type FolioAgentTextMatch, type FolioAgentToolDefinition, type FolioAgentToolName, type FolioAgentVersionDiff, type FolioAgentVersionDiffSegment, type FolioToolCallResult, type OpenAIToolDefinition, type ParseAddCommentResult, type ParseSuggestChangesResult, compareDocxVersions, createEditorRefBridge, createReviewerBridge, executeFolioToolCall, folioDocumentOperationBatchSchema, formatVersionDiffForLLM, getFolioToolDefinitions, parseAddCommentInput, parseSuggestChangesInput, toAnthropicTools, toOpenAITools };
|
|
11
|
+
export { type AnthropicToolDefinition, type CreateEditorRefBridgeOptions, type CreateReviewerBridgeOptions, FOLIO_AGENT_TOOLS, FOLIO_AGENT_TOOL_NAMES, FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, type FolioAgentApplyOperationsSummary, type FolioAgentBlock, type FolioAgentBlockDiff, type FolioAgentBridge, type FolioAgentChange, type FolioAgentComment, type FolioAgentCommentFilter, type FolioAgentCommentReply, type FolioAgentCompareDocxVersionsOptions, type FolioAgentDocumentOutline, type FolioAgentEditorApplyDocumentOperationsOptions, type FolioAgentEditorRefLike, type FolioAgentGenerateRedlineDocxOptions, type FolioAgentGenerateRedlineDocxResult, type FolioAgentOutlineEntry, type FolioAgentScopedFindTextResult, type FolioAgentSectionRead, type FolioAgentStoryFindTextResult, type FolioAgentStoryTextMatch, type FolioAgentTextMatch, type FolioAgentToolDefinition, type FolioAgentToolName, type FolioAgentVersionDiff, type FolioAgentVersionDiffSegment, type FolioToolCallResult, type OpenAIToolDefinition, type ParseAddCommentResult, type ParseSuggestChangesResult, compareDocxVersions, createEditorRefBridge, createReviewerBridge, executeFolioToolCall, folioDocumentOperationBatchSchema, formatVersionDiffForLLM, generateRedlineDocx, getFolioToolDefinitions, parseAddCommentInput, parseSuggestChangesInput, toAnthropicTools, toOpenAITools };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compareDocxVersions, formatVersionDiffForLLM } from "./compare.js";
|
|
1
|
+
import { compareDocxVersions, formatVersionDiffForLLM, generateRedlineDocx } from "./compare.js";
|
|
2
2
|
import { parseAddCommentInput, parseSuggestChangesInput } from "./parse.js";
|
|
3
3
|
import { FOLIO_AGENT_TOOL_NAMES } from "./types.js";
|
|
4
4
|
import { executeFolioToolCall } from "./execute.js";
|
|
@@ -7,4 +7,4 @@ import { createReviewerBridge } from "./bridges/reviewer.js";
|
|
|
7
7
|
import { FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA, FOLIO_DOCUMENT_OPERATION_JSON_SCHEMA, folioDocumentOperationBatchSchema } from "./operation-schema.js";
|
|
8
8
|
import { toAnthropicTools, toOpenAITools } from "./providers.js";
|
|
9
9
|
import { FOLIO_AGENT_TOOLS, getFolioToolDefinitions } from "./tools.js";
|
|
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, getFolioToolDefinitions, parseAddCommentInput, parseSuggestChangesInput, toAnthropicTools, toOpenAITools };
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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",
|
|
@@ -136,6 +136,10 @@ currentBuffer)` + `formatVersionDiffForLLM(diff)`. Both are plain async
|
|
|
136
136
|
host-side tool keyed by version identifiers instead — the model calls it
|
|
137
137
|
with two version ids, your backend resolves the buffers and returns the
|
|
138
138
|
formatted diff text.
|
|
139
|
+
- **Reviewable output between two saved versions** —
|
|
140
|
+
`generateRedlineDocx(previousBuffer, currentBuffer, options)` returns the
|
|
141
|
+
generated package, operation results, unmatched stories, and a structured
|
|
142
|
+
package-metadata privacy report.
|
|
139
143
|
|
|
140
144
|
`compareDocxVersions` compares the AS-ACCEPTED view of each buffer: any
|
|
141
145
|
tracked changes already pending in either one count as already applied before
|