import { SdkMcpToolDefinition, CanUseTool, McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk'; import { T as TOOL_SCHEMAS, F as FileToolName, A as ApprovalConfig } from "../../packem_shared/approval.d-C-d-t94D.js"; export type { c as FileReadToolName, d as FileWriteToolName } from "../../packem_shared/approval.d-C-d-t94D.js"; 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'; /** * MCP tool annotations as accepted by `tool()` and exposed on * `SdkMcpToolDefinition`. Re-derived from the SDK rather than imported from * `@modelcontextprotocol/sdk` directly to avoid taking on a second peer * dependency. */ type ToolAnnotations = NonNullable; /** * Per-tool overrides for `createClaudeFileTools`. `name`, `inputSchema`, and * `handler` are intentionally not overridable — the contract that drives tool * behavior should not be patched at this layer. */ interface ClaudeToolOverrides { annotations?: ToolAnnotations; description?: string; } interface ClaudeWriteToolOptions { annotations?: ToolAnnotations; } type ListFilesShape = (typeof TOOL_SCHEMAS.listFiles.input)["shape"]; type GetFileMetadataShape = (typeof TOOL_SCHEMAS.getFileMetadata.input)["shape"]; type DownloadFileShape = (typeof TOOL_SCHEMAS.downloadFile.input)["shape"]; type GetFileUrlShape = (typeof TOOL_SCHEMAS.getFileUrl.input)["shape"]; type UploadFileShape = (typeof TOOL_SCHEMAS.uploadFile.input)["shape"]; type DeleteFileShape = (typeof TOOL_SCHEMAS.deleteFile.input)["shape"]; type CopyFileShape = (typeof TOOL_SCHEMAS.copyFile.input)["shape"]; type SignUploadUrlShape = (typeof TOOL_SCHEMAS.signUploadUrl.input)["shape"]; declare const claudeListFiles: (files: Files) => SdkMcpToolDefinition; declare const claudeGetFileMetadata: (files: Files) => SdkMcpToolDefinition; declare const claudeDownloadFile: (files: Files) => SdkMcpToolDefinition; declare const claudeGetFileUrl: (files: Files) => SdkMcpToolDefinition; declare const claudeUploadFile: (files: Files, { annotations }?: ClaudeWriteToolOptions) => SdkMcpToolDefinition; declare const claudeDeleteFile: (files: Files, { annotations }?: ClaudeWriteToolOptions) => SdkMcpToolDefinition; declare const claudeCopyFile: (files: Files, { annotations }?: ClaudeWriteToolOptions) => SdkMcpToolDefinition; declare const claudeSignUploadUrl: (files: Files, { annotations }?: ClaudeWriteToolOptions) => SdkMcpToolDefinition; interface ClaudeFileToolsOptions { /** * The configured `Files` instance the tools will operate against. */ files: Files; /** * Per-tool overrides for `description` / `annotations` without touching * the underlying handler or input schema. */ overrides?: Partial>; /** * When `true`, write tools (`uploadFile`, `deleteFile`, `copyFile`, * `signUploadUrl`) are omitted from the MCP server. The model cannot * mutate the bucket regardless of approval configuration. */ readOnly?: boolean; /** * Approval gating reflected by {@link ClaudeFileTools.needsApproval} and * the bundled {@link ClaudeFileTools.canUseTool}. Defaults to `true` * (every write requires approval). Pass `false` to disable, or an object * keyed by write-tool name for fine-grained control. */ requireApproval?: ApprovalConfig; /** * Name of the in-process MCP server that wraps these tools. Affects the * `mcp__<server-name>__<tool-name>` strings the agent uses to address * each tool. Defaults to `"files"`. */ serverName?: string; /** * MCP server `version` metadata. Defaults to `"1.0.0"`. */ serverVersion?: string; } interface ClaudeFileTools { /** * Pass into `query({ options: { allowedTools: tools.allowedTools } })`. * Each entry is of the form `mcp__<serverName>__<toolName>`. */ allowedTools: string[]; /** * Ready-made `canUseTool` callback. Allows reads unconditionally, allows * writes whose `needsApproval` resolves to `false`, denies the rest with * a `"requires approval"` message. Pass directly into `query()`, or * compose your own using {@link ClaudeFileTools.needsApproval}. */ canUseTool: CanUseTool; /** * Pass into `query({ options: { mcpServers: tools.mcpServers } })`. */ mcpServers: Record; /** * Whether the named tool is approval-gated under the configured * `requireApproval`. Accepts both bare names (`"uploadFile"`) and the * MCP-prefixed form (`"mcp__files__uploadFile"`). Read tools and unknown * names return `false`. */ needsApproval: (toolName: string) => boolean; /** * The raw SDK MCP server instance — same value as * `mcpServers[serverName]`. Exposed for callers that want to compose it * into a larger `mcpServers` map. */ server: McpSdkServerConfigWithInstance; /** * The MCP server name used in the `mcp__<server>__*` prefix. */ serverName: string; } /** * Create storage tools shaped for the Claude Agent SDK * (`@anthropic-ai/claude-agent-sdk`). * * The Claude Agent SDK consumes tools by way of an in-process MCP server + * an `allowedTools` allow-list + a `canUseTool` approval callback. The * returned bundle gives you all three, plus the raw server instance and a * `needsApproval()` helper if you want to wire your own `canUseTool`. * @example * ```ts * import { query } from "@anthropic-ai/claude-agent-sdk"; * import { Files } from "@visulima/storage"; * import { S3Storage } from "@visulima/storage/provider/aws"; * import { createClaudeFileTools } from "@visulima/storage/ai/claude"; * * const files = new Files({ adapter: new S3Storage({ bucket: "uploads" }) }); * const tools = createClaudeFileTools({ files }); * * for await (const message of query({ * prompt: "List my files.", * options: { * mcpServers: tools.mcpServers, * allowedTools: tools.allowedTools, * canUseTool: tools.canUseTool, * }, * })) { * // handle messages * } * ``` * @example Read-only agent * ```ts * createClaudeFileTools({ files, readOnly: true }) * ``` * @example Granular approval * ```ts * createClaudeFileTools({ * files, * requireApproval: { * copyFile: false, * deleteFile: true, * signUploadUrl: true, * uploadFile: false, * }, * }) * ``` */ declare const createClaudeFileTools: ({ files, overrides, readOnly, requireApproval, serverName, serverVersion }: ClaudeFileToolsOptions) => ClaudeFileTools; export { type ApprovalConfig, ClaudeFileTools, ClaudeFileToolsOptions, type ClaudeToolOverrides, type ClaudeWriteToolOptions, type FileToolName, type ToolAnnotations, claudeCopyFile, claudeDeleteFile, claudeDownloadFile, claudeGetFileMetadata, claudeGetFileUrl, claudeListFiles, claudeSignUploadUrl, claudeUploadFile, createClaudeFileTools };