import { Files, SignedUpload } from '../index.js'; import { A as ApprovalConfig, F as FileToolName, a as FileReadToolName } from '../approval-C65iPvEt.js'; export { b as FileWriteToolName } from '../approval-C65iPvEt.js'; import * as ai from 'ai'; import { Tool } from 'ai'; import 'zod'; /** * Common options accepted by every write-tool factory. */ interface ToolOptions { needsApproval?: boolean; } /** * Per-tool overrides for customizing AI SDK `tool()` properties without * changing the underlying implementation. Core properties (`execute`, * `inputSchema`, `outputSchema`) are intentionally excluded — those drive * the tool's behavior and contract and shouldn't be patched at this layer. */ type ToolOverrides = Partial>; declare const listFiles: (files: Files) => ai.Tool<{ cursor?: string | undefined; limit?: number | undefined; prefix?: string | undefined; }, { cursor: string | undefined; items: { etag: string | undefined; key: string; lastModified: number | undefined; size: number; type: string; }[]; }>; declare const getFileMetadata: (files: Files) => ai.Tool<{ key: string; }, { etag: string | undefined; key: string; lastModified: number | undefined; metadata: Record | undefined; size: number; type: string; }>; declare const downloadFile: (files: Files) => ai.Tool<{ key: string; binary?: boolean | undefined; maxBytes?: number | undefined; }, { content: string; encoding: "base64"; key: string; size: number; type: string; } | { content: string; encoding: "text"; key: string; size: number; type: string; }>; declare const getFileUrl: (files: Files) => ai.Tool<{ key: string; expiresIn?: number | undefined; responseContentDisposition?: string | undefined; }, { key: string; url: string; }>; declare const uploadFile: (files: Files, { needsApproval }?: ToolOptions) => ai.Tool<{ content: string; key: string; cacheControl?: string | undefined; contentType?: string | undefined; encoding?: "text" | "base64" | undefined; metadata?: Record | undefined; }, { contentType: string; etag: string | undefined; key: string; lastModified: number | undefined; size: number; }>; declare const deleteFile: (files: Files, { needsApproval }?: ToolOptions) => ai.Tool<{ key: string; }, { deleted: true; key: string; }>; declare const copyFile: (files: Files, { needsApproval }?: ToolOptions) => ai.Tool<{ from: string; to: string; }, { copied: true; from: string; to: string; }>; declare const signUploadUrl: (files: Files, { needsApproval }?: ToolOptions) => ai.Tool<{ expiresIn: number; key: string; contentType?: string | undefined; maxSize?: number | undefined; minSize?: number | undefined; }, SignedUpload>; interface FileToolsOptions { /** * The configured `Files` instance the tools will operate against. * Each tool delegates to the methods on this instance, inheriting its * adapter, key validation, and `FilesError` wrapping. */ files: Files; /** * 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; /** * Per-tool overrides for customizing tool behavior (description, title, * needsApproval, etc.) without changing the underlying implementation. * `execute`, `inputSchema`, and `outputSchema` cannot be overridden. * * @example * ```ts * createFileTools({ * files, * overrides: { * deleteFile: { needsApproval: false }, * listFiles: { description: "List user uploads in the current tenant" }, * }, * }) * ``` */ overrides?: Partial>; } interface FileTools { listFiles: ReturnType; getFileMetadata: ReturnType; downloadFile: ReturnType; getFileUrl: ReturnType; uploadFile: ReturnType; deleteFile: ReturnType; copyFile: ReturnType; signUploadUrl: ReturnType; } type ReadOnlyFileTools = Pick; /** * Create a set of files-sdk tools for the Vercel AI SDK. * * 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 "files-sdk"; * import { createFileTools } from "files-sdk/ai-sdk"; * import { s3 } from "files-sdk/s3"; * import { generateText } from "ai"; * * const files = new Files({ adapter: s3({ bucket: "uploads" }) }); * * const result = await generateText({ * model: yourModel, * tools: createFileTools({ files }), * prompt: "Find every CSV under reports/ and summarize the latest one.", * }); * ``` * * @example Read-only agent * ```ts * createFileTools({ files, readOnly: true }) * ``` * * @example Granular approval * ```ts * createFileTools({ * files, * requireApproval: { * deleteFile: true, * uploadFile: false, * copyFile: false, * signUploadUrl: true, * }, * }) * ``` */ declare function createFileTools(opts: FileToolsOptions & { readOnly: true; }): ReadOnlyFileTools; declare function createFileTools(opts: FileToolsOptions & { readOnly?: false | undefined; }): FileTools; declare function createFileTools(opts: FileToolsOptions): FileTools | ReadOnlyFileTools; export { ApprovalConfig, FileReadToolName, FileToolName, type FileTools, type FileToolsOptions, type ReadOnlyFileTools, type ToolOptions, type ToolOverrides, copyFile, createFileTools, deleteFile, downloadFile, getFileMetadata, getFileUrl, listFiles, signUploadUrl, uploadFile };