import { A as ApprovalConfig, F as FileToolName, a as FileReadToolName } from '../approval-C65iPvEt.js'; export { b as FileWriteToolName } from '../approval-C65iPvEt.js'; import * as _openai_agents from '@openai/agents'; import * as zod_v4_core from 'zod/v4/core'; import * as zod from 'zod'; import { Files } from '../index.js'; /** * Per-tool overrides for `createResponsesFileTools`. `name`, `parameters`, and * `type` are intentionally not overridable — the contract that drives tool * behavior should not be patched at this layer. */ interface ResponsesToolOverrides { description?: string; strict?: boolean; } /** * Per-tool overrides for `createAgentsFileTools`. `name`, `parameters`, * `execute`, and `strict` are intentionally not overridable — the contract * that drives tool behavior should not be patched at this layer. */ interface AgentsToolOverrides { description?: string; needsApproval?: boolean; } declare const agentsListFiles: (files: Files) => _openai_agents.FunctionTool; limit: zod.ZodOptional; prefix: zod.ZodOptional; }, zod_v4_core.$strip>, string>; declare const agentsGetFileMetadata: (files: Files) => _openai_agents.FunctionTool, string>; declare const agentsDownloadFile: (files: Files) => _openai_agents.FunctionTool; key: zod.ZodString; maxBytes: zod.ZodOptional; }, zod_v4_core.$strip>, string>; declare const agentsGetFileUrl: (files: Files) => _openai_agents.FunctionTool; key: zod.ZodString; responseContentDisposition: zod.ZodOptional; }, zod_v4_core.$strip>, string>; declare const agentsUploadFile: (files: Files, { needsApproval }?: { needsApproval?: boolean; }) => _openai_agents.FunctionTool; content: zod.ZodString; contentType: zod.ZodOptional; encoding: zod.ZodOptional>; key: zod.ZodString; metadata: zod.ZodOptional>; }, zod_v4_core.$strip>, string>; declare const agentsDeleteFile: (files: Files, { needsApproval }?: { needsApproval?: boolean; }) => _openai_agents.FunctionTool, string>; declare const agentsCopyFile: (files: Files, { needsApproval }?: { needsApproval?: boolean; }) => _openai_agents.FunctionTool, string>; declare const agentsSignUploadUrl: (files: Files, { needsApproval }?: { needsApproval?: boolean; }) => _openai_agents.FunctionTool; expiresIn: zod.ZodNumber; key: zod.ZodString; maxSize: zod.ZodOptional; minSize: zod.ZodOptional; }, zod_v4_core.$strip>, string>; interface AgentsFileTools { listFiles: ReturnType; getFileMetadata: ReturnType; downloadFile: ReturnType; getFileUrl: ReturnType; uploadFile: ReturnType; deleteFile: ReturnType; copyFile: ReturnType; signUploadUrl: ReturnType; } type ReadOnlyAgentsFileTools = Pick; interface AgentsFileToolsOptions { /** * The configured `Files` instance the tools will operate against. */ 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` (every write * requires approval). Pass `false` to disable, or an object keyed * by write-tool name for fine-grained control. */ requireApproval?: ApprovalConfig; /** * Per-tool overrides for `description` and `needsApproval` without * touching `execute` or `parameters`. */ overrides?: Partial>; } /** * Create a set of files-sdk tools shaped for the OpenAI Agents SDK * (`@openai/agents`). * * Returns a record keyed by tool name — spread `Object.values()` into * `new Agent({ tools })`. Write tools require approval by default; the * Agents SDK surfaces an `interruption` that the program resolves by * approving or rejecting the call. * * @example * ```ts * import { Agent, run } from "@openai/agents"; * import { Files } from "files-sdk"; * import { s3 } from "files-sdk/s3"; * import { createAgentsFileTools } from "files-sdk/openai"; * * const files = new Files({ adapter: s3({ bucket: "uploads" }) }); * const tools = createAgentsFileTools({ files }); * * const agent = new Agent({ * instructions: "Help the user manage their files.", * name: "Files agent", * tools: Object.values(tools), * }); * * const result = await run(agent, "List my files."); * ``` */ declare function createAgentsFileTools(opts: AgentsFileToolsOptions & { readOnly: true; }): ReadOnlyAgentsFileTools; declare function createAgentsFileTools(opts: AgentsFileToolsOptions & { readOnly?: false | undefined; }): AgentsFileTools; declare function createAgentsFileTools(opts: AgentsFileToolsOptions): AgentsFileTools | ReadOnlyAgentsFileTools; /** * A function-tool definition shaped for OpenAI's Responses API. Pass an * array of these to `openai.responses.create({ tools })`. */ interface ResponsesFunctionTool { type: "function"; name: string; description: string; parameters: Record; strict: boolean; } /** * A function call emitted by the Responses API in `response.output[]`. */ interface FunctionCallItem { type: "function_call"; call_id: string; name: string; arguments: string; } /** * A function-call output item to append to the next `responses.create` * input alongside the original `function_call` item. */ interface FunctionCallOutputItem { type: "function_call_output"; call_id: string; output: string; } interface ResponsesFileTools { /** * Function tool definitions. Pass directly to * `openai.responses.create({ tools })`. */ definitions: ResponsesFunctionTool[]; /** * Execute a `function_call` item from the model's `response.output[]`. * Looks up the matching tool by name, parses and validates `arguments`, * runs the underlying `Files` operation, and returns a * `function_call_output` item ready to push into the next turn's input. * * `JSON.parse` failures and Zod validation errors are returned **as the * tool's output** so the model can self-correct on the next turn. * `FilesError` from the underlying SDK is rethrown — the caller decides * how to surface it. * * Approval is **not** enforced. Check {@link needsApproval} first if you * want a human-in-the-loop gate. */ execute(call: FunctionCallItem): Promise; /** * Returns whether the named tool is approval-gated under this config. * Read tools always return `false`. Unknown names return `false`. */ needsApproval(name: string): boolean; } interface ResponsesFileToolsOptions { /** * The configured `Files` instance the tools will operate against. */ files: Files; /** * When `true`, write tools (`uploadFile`, `deleteFile`, `copyFile`, * `signUploadUrl`) are omitted from `definitions` and rejected by * `execute`. The model cannot mutate the bucket regardless of approval * configuration. */ readOnly?: boolean; /** * Approval gating reflected by {@link ResponsesFileTools.needsApproval}. * Defaults to `true` (every write reports as approval-required). Pass * `false` to disable, or an object keyed by write-tool name for * fine-grained control. Unspecified entries in the object form default * to `true`. */ requireApproval?: ApprovalConfig; /** * Per-tool overrides for the OpenAI tool definition (`description`, * `strict`). `name`, `parameters`, and `type` cannot be overridden. */ overrides?: Partial>; } /** * Create a set of files-sdk tools shaped for OpenAI's Responses API * (`openai.responses.create`). * * @example * ```ts * import OpenAI from "openai"; * import { Files } from "files-sdk"; * import { s3 } from "files-sdk/s3"; * import { createResponsesFileTools } from "files-sdk/openai"; * * const client = new OpenAI(); * const files = new Files({ adapter: s3({ bucket: "uploads" }) }); * const ft = createResponsesFileTools({ files }); * * const input: any[] = [{ role: "user", content: "List my files." }]; * while (true) { * const res = await client.responses.create({ * model: "gpt-4.1", * input, * tools: ft.definitions, * }); * const calls = res.output.filter((o) => o.type === "function_call"); * if (calls.length === 0) break; * for (const call of calls) { * if (ft.needsApproval(call.name)) { * // surface approval UX, then continue or break * } * input.push(call, await ft.execute(call)); * } * } * ``` */ declare const createResponsesFileTools: ({ files, readOnly, requireApproval, overrides, }: ResponsesFileToolsOptions) => ResponsesFileTools; export { type AgentsFileTools, type AgentsFileToolsOptions, type AgentsToolOverrides, ApprovalConfig, FileReadToolName, FileToolName, type FunctionCallItem, type FunctionCallOutputItem, type ReadOnlyAgentsFileTools, type ResponsesFileTools, type ResponsesFileToolsOptions, type ResponsesFunctionTool, type ResponsesToolOverrides, agentsCopyFile, agentsDeleteFile, agentsDownloadFile, agentsGetFileMetadata, agentsGetFileUrl, agentsListFiles, agentsSignUploadUrl, agentsUploadFile, createAgentsFileTools, createResponsesFileTools };