import type { FunctionCallItem, FunctionTool } from '@openai/agents'; import { Codex, type CodexOptions, type SandboxMode, type ThreadEvent, type ThreadOptions, type TurnOptions, type Usage as CodexUsage } from '@openai/codex-sdk'; import { z } from 'zod'; declare const OutputSchemaDescriptorSchema: z.ZodObject<{ title: z.ZodOptional; description: z.ZodOptional; properties: z.ZodArray; schema: z.ZodUnion; description: z.ZodOptional; enum: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"number">; description: z.ZodOptional; enum: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"integer">; description: z.ZodOptional; enum: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"boolean">; description: z.ZodOptional; enum: z.ZodOptional>; }, z.core.$strict>]>, z.ZodObject<{ type: z.ZodLiteral<"array">; description: z.ZodOptional; items: z.ZodUnion; description: z.ZodOptional; enum: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"number">; description: z.ZodOptional; enum: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"integer">; description: z.ZodOptional; enum: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"boolean">; description: z.ZodOptional; enum: z.ZodOptional>; }, z.core.$strict>]>; }, z.core.$strict>]>; }, z.core.$strict>>; required: z.ZodOptional>; }, z.core.$strict>; declare const codexParametersSchema: z.ZodObject<{ inputs: z.ZodArray; text: z.ZodString; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"local_image">; path: z.ZodString; }, z.core.$strict>]>>; threadId: z.ZodDefault>; }, z.core.$strict>; declare const codexRunContextParametersSchema: z.ZodObject<{ inputs: z.ZodArray; text: z.ZodString; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"local_image">; path: z.ZodString; }, z.core.$strict>]>>; }, z.core.$strict>; type CodexToolParametersSchema = typeof codexParametersSchema | typeof codexRunContextParametersSchema; type OutputSchemaDescriptor = z.infer; export type CodexToolStreamEvent = { event: ThreadEvent; threadId: string | null; toolCall?: FunctionCallItem; }; export type CodexToolStreamHandler = (event: CodexToolStreamEvent) => void | Promise; export type CodexToolOptions = { /** * Name of the tool as exposed to the agent model. * * Names are normalized to the `codex` namespace. * Passing `'engineer'` becomes `'codex_engineer'`. * * @defaultValue `'codex'`. */ name?: string; /** * Description surfaced to the agent model. */ description?: string; /** * Explicit Zod parameter schema. When omitted, the default schema is used. * Custom schemas must be compatible with the default `inputs` shape. */ parameters?: CodexToolParametersSchema; /** * Optional descriptor or JSON schema used for Codex structured output. * This schema is applied to every Codex turn. */ outputSchema?: OutputSchemaDescriptor | Record | z.ZodTypeAny; /** * Reuse an existing Codex instance. When omitted a new Codex instance will be created. */ codex?: Codex; /** * Options passed to the Codex constructor when {@link CodexToolOptions.codex} is undefined. */ codexOptions?: CodexOptions; /** * Default options applied to every Codex thread. */ defaultThreadOptions?: ThreadOptions; /** * Resume a specific Codex thread by id. */ threadId?: string; /** * Sandbox permissions for the Codex task. */ sandboxMode?: SandboxMode; /** * Absolute path used as the working directory for the Codex thread. */ workingDirectory?: string; /** * Allow Codex to run outside a Git repository when true. */ skipGitRepoCheck?: boolean; /** * Default options applied to every Codex turn. */ defaultTurnOptions?: TurnOptions; /** * Reuse a single Codex thread across tool invocations. */ persistSession?: boolean; /** * Optional hook to receive streamed Codex events during execution. */ onStream?: CodexToolStreamHandler; /** * Reuse Codex thread IDs stored in `runContext.context`. * * When enabled, the tool reads the prior thread ID from `runContext.context`, * resumes that thread, and stores the latest thread ID after completion. */ useRunContextThreadId?: boolean; /** * Context key used when `useRunContextThreadId` is enabled. * * Defaults to `codexThreadId` for the default tool name, or a name-derived * key such as `codexThreadId_engineer` for `name: 'codex_engineer'`. */ runContextThreadIdKey?: string; }; type CodexToolResult = { threadId: string | null; response: string; usage: CodexUsage | null; }; /** * Wraps the Codex SDK in a function tool that can be consumed by the Agents SDK. * * The tool streams Codex events, creating child spans for reasoning items, command executions, * and MCP tool invocations. Those spans are nested under the Codex tool span automatically when * tracing is enabled. */ export declare function codexTool(options?: CodexToolOptions): FunctionTool; export type CodexOutputSchemaDescriptor = OutputSchemaDescriptor; export type CodexOutputSchema = Record; export {};