UNPKG

@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.

60 lines 3.35 kB
import { FolioDocumentOperationType } from "@stll/folio-core/server"; //#region src/suggest-changes-options.d.ts /** Whether every operation must carry `severity` and `area`. */ 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). */ 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. */ 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. */ type FolioAgentToolOptions = { suggestChanges?: FolioSuggestChangesOptions; }; 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`. */ declare const DEFAULT_SUGGEST_CHANGES_OPERATION_TYPES: readonly FolioDocumentOperationType[]; declare const DEFAULT_MAX_OPERATIONS_PER_CALL = 50; declare const MAX_OPERATIONS_PER_CALL_LIMIT = 200; declare const InvalidFolioSuggestChangesOptionsError_base: import("better-result").TaggedErrorClass<"InvalidFolioSuggestChangesOptionsError">; /** Programmer misuse of {@link FolioSuggestChangesOptions}; never reaches the model. */ declare class InvalidFolioSuggestChangesOptionsError extends InvalidFolioSuggestChangesOptionsError_base<{ message: string; option: keyof FolioSuggestChangesOptions; }> {} /** Validate and default a host's options; throws {@link InvalidFolioSuggestChangesOptionsError} on misuse. */ declare const resolveSuggestChangesOptions: (options?: FolioSuggestChangesOptions) => ResolvedFolioSuggestChangesOptions; //#endregion export { DEFAULT_MAX_OPERATIONS_PER_CALL, DEFAULT_SUGGEST_CHANGES_OPERATION_TYPES, FolioAgentToolOptions, FolioSuggestChangesDocumentVersionOption, FolioSuggestChangesOptions, FolioSuggestChangesReviewMetaPolicy, InvalidFolioSuggestChangesOptionsError, MAX_OPERATIONS_PER_CALL_LIMIT, ResolvedFolioSuggestChangesOptions, resolveSuggestChangesOptions };