@stll/folio-agents
Version:
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.
59 lines • 3.04 kB
TypeScript
import { FolioDocumentOperationType } from "@stll/folio-core/server";
import { TaggedErrorClass } from "better-result";
declare const InvalidFolioSuggestChangesOptionsErrorBase: TaggedErrorClass<"InvalidFolioSuggestChangesOptionsError">;
/** Whether every operation must carry `severity` and `area`. */
export type FolioSuggestChangesReviewMetaPolicy = "optional" | "required";
/**
* Pin the batch to a host document version. The model must echo `current`
* as the tool's top-level `documentVersion` argument; it lands on the batch
* as `precondition.documentVersion`, and the executor skips the whole batch
* with `documentVersionMismatch` when the bridge reports a different version
* at apply time (an approval that ran after the document moved on).
*/
export type FolioSuggestChangesDocumentVersionOption = {
current: string;
};
/**
* Per-surface shape of the `suggest_changes` tool. Pass the same object to
* `getFolioToolDefinitions` and `executeFolioToolCall` so the schema the
* model sees and the parser that checks its calls agree.
*/
export type FolioSuggestChangesOptions = {
/**
* Operation types the model may emit, in any order. Defaults to every
* contract type except `commentOnBlock` (covered by `add_comment`) and
* `insertSignatureTable` (direct-only, so not a tracked change).
*/
operationTypes?: readonly FolioDocumentOperationType[];
/** Defaults to `"optional"`. */
reviewMeta?: FolioSuggestChangesReviewMetaPolicy;
/** Operations accepted per call, 1 to 200. Defaults to 50. */
maxOperations?: number;
documentVersion?: FolioSuggestChangesDocumentVersionOption;
};
/**
* Per-surface configuration shared by `getFolioToolDefinitions` and
* `executeFolioToolCall`; every tool but `suggest_changes` is fixed.
*/
export type FolioAgentToolOptions = {
suggestChanges?: FolioSuggestChangesOptions;
};
export type ResolvedFolioSuggestChangesOptions = {
/** Allowed types in contract order, deduplicated. */
readonly operationTypes: readonly FolioDocumentOperationType[];
readonly reviewMeta: FolioSuggestChangesReviewMetaPolicy;
readonly maxOperations: number;
readonly documentVersion: FolioSuggestChangesDocumentVersionOption | null;
};
/** The operation types `suggest_changes` exposes when a host passes no `operationTypes`. */
export declare const DEFAULT_SUGGEST_CHANGES_OPERATION_TYPES: readonly FolioDocumentOperationType[];
export declare const DEFAULT_MAX_OPERATIONS_PER_CALL = 50;
export declare const MAX_OPERATIONS_PER_CALL_LIMIT = 200;
/** Programmer misuse of {@link FolioSuggestChangesOptions}; never reaches the model. */
export declare class InvalidFolioSuggestChangesOptionsError extends InvalidFolioSuggestChangesOptionsErrorBase<{
message: string;
option: keyof FolioSuggestChangesOptions;
}> {}
/** Validate and default a host's options; throws {@link InvalidFolioSuggestChangesOptionsError} on misuse. */
export declare const resolveSuggestChangesOptions: (options?: FolioSuggestChangesOptions) => ResolvedFolioSuggestChangesOptions;
export {};