UNPKG

@openai/agents-realtime

Version:

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. This package contains the logic for building realtime voice agents on the server or in the browser.

40 lines (39 loc) • 1.94 kB
import type OpenAI from 'openai'; import { z } from 'zod'; import type { MessageEvent as WebSocketMessageEvent } from 'ws'; type LegacyMcpCall = Omit<OpenAI.Realtime.RealtimeMcpToolCall, 'type'> & { type: 'mcp_tool_call'; }; type WithLegacyItem<T> = T extends { item: unknown; } ? Omit<T, 'item'> & { item: (OpenAI.Realtime.ConversationItem | LegacyMcpCall) & Record<string, unknown>; } : T; export type RealtimeServerEvent = WithLegacyItem<OpenAI.Realtime.RealtimeServerEvent>; export type RealtimeClientEvent = OpenAI.Realtime.RealtimeClientEvent; export type RealtimeServerGenericEvent = { type: string; } & Record<string, any>; export declare const responseDoneEventSchema: z.ZodObject<{ response: z.ZodObject<{ id: z.ZodOptional<z.ZodNullable<z.ZodString>>; output: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodAny>>>; usage: z.ZodOptional<z.ZodNullable<z.ZodObject<{ input_tokens: z.ZodOptional<z.ZodNumber>; output_tokens: z.ZodOptional<z.ZodNumber>; input_token_details: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, z.core.util.JSONType>, unknown, z.core.$ZodTypeInternals<Record<string, z.core.util.JSONType>, unknown>>>>; output_token_details: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, z.core.util.JSONType>, unknown, z.core.$ZodTypeInternals<Record<string, z.core.util.JSONType>, unknown>>>>; }, z.core.$strip>>>; }, z.core.$loose>; }, z.core.$loose>; type ParseResult = { data: RealtimeServerEvent | null; raw: RealtimeServerGenericEvent | null; }; /** * Decode the provider envelope and check only handler prerequisites. Unknown * events and extension fields remain available to listeners. SDK types describe * known payloads; they are not a runtime allowlist of server events. */ export declare function parseRealtimeEvent(event: MessageEvent | WebSocketMessageEvent): ParseResult; export {};