@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.
113 lines • 4.18 kB
TypeScript
import { FOLIO_AGENT_TOOL_NAMES, FolioAgentApplyOperationsSummary, FolioAgentBlock, FolioAgentChange, FolioAgentComment, FolioAgentCommentFilter, FolioAgentDocumentOutline, FolioAgentScopedFindTextResult, FolioAgentSectionRead, FolioAgentToolName, FolioAgentTypedToolDefinition, FolioToolCallResult } from "./types.js";
import { FolioAITextRangeHandle, FolioDocumentSectionHandle, FolioDocumentStory, FolioDocumentStoryHandle } from "@stll/folio-core/server";
//#region src/tool-contract.d.ts
type EmptyArgs = Readonly<Record<string, never>>;
type FolioAgentFindTextScope = {
type: "document";
} | {
type: "section";
handle: FolioDocumentSectionHandle;
} | {
type: "page";
page: number;
} | {
type: "story";
handle: FolioDocumentStoryHandle;
};
type FolioAgentShowInDocumentArgs = {
blockId: string;
range?: never;
} | {
blockId?: never;
range: FolioAITextRangeHandle;
};
type FolioAgentToolInputByName = {
[]: EmptyArgs;
[]: {
maxDepth?: number;
};
[]: {
handle: FolioDocumentSectionHandle;
maxBlocks?: number;
afterBlockId?: string;
};
[]: EmptyArgs;
[]: {
handle: FolioDocumentStoryHandle;
};
[]: {
query: string;
matchCase?: boolean;
wholeWord?: boolean;
scope?: FolioAgentFindTextScope;
};
[]: {
filter?: FolioAgentCommentFilter;
};
[]: EmptyArgs;
[]: {
blockId: string;
quote?: string;
text: string;
precondition?: {
blockTextHash: string;
};
};
[]: {
operations: unknown[];
/** Present when the tool was defined with a `documentVersion` option. */
documentVersion?: string;
};
[]: {
commentId: string;
text: string;
};
[]: {
commentId: string;
reopen?: boolean;
};
[]: {
page: number;
};
[]: EmptyArgs;
[]: {
blockId: string;
};
[]: FolioAgentShowInDocumentArgs;
};
type FolioAgentToolOutputByName = {
[]: FolioAgentBlock[];
[]: FolioAgentDocumentOutline;
[]: FolioAgentSectionRead;
[]: FolioDocumentStory[];
[]: FolioDocumentStory;
[]: FolioAgentScopedFindTextResult;
[]: FolioAgentComment[];
[]: FolioAgentChange[];
[]: FolioAgentApplyOperationsSummary;
[]: FolioAgentApplyOperationsSummary;
[]: {
replied: true;
};
[]: {
resolved: boolean;
};
[]: {
page: number;
totalPages?: number;
text: string;
};
[]: {
text: string;
};
[]: {
scrolled: boolean;
};
[]: {
shown: boolean;
};
};
type FolioToolCallResultFor<TName extends FolioAgentToolName> = FolioToolCallResult<FolioAgentToolOutputByName[TName]>;
declare const defineFolioAgentToolDefinition: <TName extends FolioAgentToolName>(definition: FolioAgentTypedToolDefinition<TName, FolioAgentToolInputByName[TName], FolioAgentToolOutputByName[TName]>) => FolioAgentTypedToolDefinition<TName, FolioAgentToolInputByName[TName], FolioAgentToolOutputByName[TName]>;
//#endregion
export { FolioAgentFindTextScope, FolioAgentShowInDocumentArgs, FolioAgentToolInputByName, FolioAgentToolOutputByName, FolioToolCallResultFor, defineFolioAgentToolDefinition };