import { T as TOOL_SCHEMAS, F as FileToolName, A as ApprovalConfig, c as FileReadToolName } from "../../packem_shared/approval.d-C-d-t94D.js"; export type { d as FileWriteToolName } from "../../packem_shared/approval.d-C-d-t94D.js"; import { UnknownContext, FunctionTool } from '@openai/agents'; import { e as executors } from "../../packem_shared/executors.d-HWHR3Ids.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'; /** * 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; } type ListFilesOutput = Awaited>; type GetFileMetadataOutput = Awaited>; type DownloadFileOutput = Awaited>; type GetFileUrlOutput = Awaited>; type UploadFileOutput = Awaited>; type DeleteFileOutput = Awaited>; type CopyFileOutput = Awaited>; type SignUploadUrlOutput = Awaited>; 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 agentsListFiles: (files: Files) => FunctionTool; declare const agentsGetFileMetadata: (files: Files) => FunctionTool; declare const agentsDownloadFile: (files: Files) => FunctionTool; declare const agentsGetFileUrl: (files: Files) => FunctionTool; declare const agentsUploadFile: (files: Files, { needsApproval }?: { needsApproval?: boolean; }) => FunctionTool; declare const agentsDeleteFile: (files: Files, { needsApproval }?: { needsApproval?: boolean; }) => FunctionTool; declare const agentsCopyFile: (files: Files, { needsApproval }?: { needsApproval?: boolean; }) => FunctionTool; declare const agentsSignUploadUrl: (files: Files, { needsApproval }?: { needsApproval?: boolean; }) => FunctionTool; interface AgentsFileTools { copyFile: ReturnType; deleteFile: ReturnType; downloadFile: ReturnType; getFileMetadata: ReturnType; getFileUrl: ReturnType; listFiles: ReturnType; signUploadUrl: ReturnType; uploadFile: ReturnType; } type ReadOnlyAgentsFileTools = Pick; interface AgentsFileToolsOptions { files: Files; overrides?: Partial>; readOnly?: boolean; requireApproval?: ApprovalConfig; } /** * Create a set of storage 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. * @example * ```ts * import { Agent, run } from "@openai/agents"; * import { Files } from "@visulima/storage"; * import { S3Storage } from "@visulima/storage/provider/aws"; * import { createAgentsFileTools } from "@visulima/storage/ai/openai"; * * const files = new Files({ adapter: new S3Storage({ 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(options: AgentsFileToolsOptions & { readOnly: true; }): ReadOnlyAgentsFileTools; declare function createAgentsFileTools(options: AgentsFileToolsOptions & { readOnly?: false | undefined; }): AgentsFileTools; declare function createAgentsFileTools(options: 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 { description: string; name: string; parameters: Record; strict: boolean; type: "function"; } /** * A function call emitted by the Responses API in `response.output[]`. */ interface FunctionCallItem { arguments: string; call_id: string; name: string; type: "function_call"; } /** * A function-call output item to append to the next `responses.create` * input alongside the original `function_call` item. */ interface FunctionCallOutputItem { call_id: string; output: string; type: "function_call_output"; } 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[]`. * Returns a `function_call_output` item ready to push into the next turn's input. * * Approval is **not** enforced. Check {@link ResponsesFileTools.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 { files: Files; overrides?: Partial>; readOnly?: boolean; requireApproval?: ApprovalConfig; } /** * Create a set of storage tools shaped for OpenAI's Responses API (`openai.responses.create`). * @example * ```ts * import OpenAI from "openai"; * import { Files } from "@visulima/storage"; * import { S3Storage } from "@visulima/storage/provider/aws"; * import { createResponsesFileTools } from "@visulima/storage/ai/openai"; * * const client = new OpenAI(); * const files = new Files({ adapter: new S3Storage({ 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, overrides, readOnly, requireApproval }: ResponsesFileToolsOptions) => ResponsesFileTools; export { type AgentsFileTools, type AgentsFileToolsOptions, type AgentsToolOverrides, /** * OpenAI adapter — exposes the shared tool definitions for two surfaces: * `createResponsesFileTools` for `openai.responses.create({ tools })` * (Responses API; requires the `openai` peer dependency >=5) and * `createAgentsFileTools` for `@openai/agents` (Agents SDK; requires * `@openai/agents` peer dependency). */ type ApprovalConfig, type FileReadToolName, type 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 };