import { T as TOOL_SCHEMAS, c as FileReadToolName, F as FileToolName, A as ApprovalConfig } from "../../packem_shared/approval.d-C-d-t94D.js"; export type { d as FileWriteToolName } from "../../packem_shared/approval.d-C-d-t94D.js"; import { ServerTool } from '@tanstack/ai'; import { F as Files } from "../../packem_shared/files.d-DuIceNg2.js"; import 'zod'; import "../../packem_shared/storage.d-C9EdfTf1.js"; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; /** * Common options accepted by every write-tool factory. */ interface ToolOptions { needsApproval?: boolean; } /** * Per-tool overrides for customizing TanStack AI `ServerTool` properties * without changing the underlying implementation. Core properties * (`execute`, `inputSchema`, `outputSchema`, `__toolSide`) are intentionally * excluded — those drive the tool's behavior and contract. */ type ToolOverrides = Partial>; type ListFilesParameters = typeof TOOL_SCHEMAS.listFiles.input; type GetFileMetadataParameters = typeof TOOL_SCHEMAS.getFileMetadata.input; type DownloadFileParameters = typeof TOOL_SCHEMAS.downloadFile.input; type GetFileUrlParameters = typeof TOOL_SCHEMAS.getFileUrl.input; type UploadFileParameters = typeof TOOL_SCHEMAS.uploadFile.input; type DeleteFileParameters = typeof TOOL_SCHEMAS.deleteFile.input; type CopyFileParameters = typeof TOOL_SCHEMAS.copyFile.input; type SignUploadUrlParameters = typeof TOOL_SCHEMAS.signUploadUrl.input; declare const listFiles: (files: Files) => ServerTool; declare const getFileMetadata: (files: Files) => ServerTool; declare const downloadFile: (files: Files) => ServerTool; declare const getFileUrl: (files: Files) => ServerTool; declare const uploadFile: (files: Files, { needsApproval }?: ToolOptions) => ServerTool; declare const deleteFile: (files: Files, { needsApproval }?: ToolOptions) => ServerTool; declare const copyFile: (files: Files, { needsApproval }?: ToolOptions) => ServerTool; declare const signUploadUrl: (files: Files, { needsApproval }?: ToolOptions) => ServerTool; interface TanstackFileToolsOptions { /** * The configured `Files` instance the tools will operate against. * Each tool delegates to the methods on this instance. */ files: Files; /** * Per-tool overrides for customizing tool behavior (description, * needsApproval, metadata) without changing the underlying implementation. * `execute` and `inputSchema` cannot be overridden. */ overrides?: Partial>; /** * When `true`, write tools (`uploadFile`, `deleteFile`, `copyFile`, * `signUploadUrl`) are omitted entirely. The model cannot mutate the * bucket regardless of approval configuration. */ readOnly?: boolean; /** * Approval gating for write tools. Defaults to `true` (all writes * require approval). See {@link ApprovalConfig}. */ requireApproval?: ApprovalConfig; } interface TanstackFileTools { copyFile: ReturnType; deleteFile: ReturnType; downloadFile: ReturnType; getFileMetadata: ReturnType; getFileUrl: ReturnType; listFiles: ReturnType; signUploadUrl: ReturnType; uploadFile: ReturnType; } type ReadOnlyTanstackFileTools = Pick; /** * Create a set of visulima/storage tools for TanStack AI. * * Each entry is a `ServerTool` built via `toolDefinition(...).server(...)`, * ready to be passed to `chat({ tools: [...] })` or registered with a * `ToolRegistry`. Write operations require user approval by default; * control globally or per-tool via `requireApproval`, or strip writes * entirely with `readOnly: true`. * @example * ```ts * import { Files } from "@visulima/storage"; * import { S3Storage } from "@visulima/storage/provider/aws"; * import { createTanstackFileTools } from "@visulima/storage/ai/tanstack"; * import { chat } from "@tanstack/ai"; * * const files = new Files({ adapter: new S3Storage({ bucket: "uploads" }) }); * const tools = createTanstackFileTools({ files }); * * const stream = chat({ * adapter, * messages, * tools: Object.values(tools), * }); * ``` */ declare function createTanstackFileTools(options: TanstackFileToolsOptions & { readOnly: true; }): ReadOnlyTanstackFileTools; declare function createTanstackFileTools(options: TanstackFileToolsOptions & { readOnly?: false | undefined; }): TanstackFileTools; declare function createTanstackFileTools(options: TanstackFileToolsOptions): ReadOnlyTanstackFileTools | TanstackFileTools; export { type ApprovalConfig, type FileReadToolName, type FileToolName, ReadOnlyTanstackFileTools, TanstackFileTools, TanstackFileToolsOptions, type ToolOptions, type ToolOverrides, copyFile, createTanstackFileTools, deleteFile, downloadFile, getFileMetadata, getFileUrl, listFiles, signUploadUrl, uploadFile };