@livekit/agents-plugin-openai 1.0.50 → 1.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/index.cjs +5 -2
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +4 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/llm.test.cjs +31 -16
  9. package/dist/llm.test.cjs.map +1 -1
  10. package/dist/llm.test.js +32 -17
  11. package/dist/llm.test.js.map +1 -1
  12. package/dist/responses/llm.cjs +71 -16
  13. package/dist/responses/llm.cjs.map +1 -1
  14. package/dist/responses/llm.d.cts +10 -25
  15. package/dist/responses/llm.d.ts +10 -25
  16. package/dist/responses/llm.d.ts.map +1 -1
  17. package/dist/responses/llm.js +71 -14
  18. package/dist/responses/llm.js.map +1 -1
  19. package/dist/responses/llm.test.cjs +32 -17
  20. package/dist/responses/llm.test.cjs.map +1 -1
  21. package/dist/responses/llm.test.js +33 -18
  22. package/dist/responses/llm.test.js.map +1 -1
  23. package/dist/stt.cjs +7 -3
  24. package/dist/stt.cjs.map +1 -1
  25. package/dist/stt.d.ts.map +1 -1
  26. package/dist/stt.js +8 -4
  27. package/dist/stt.js.map +1 -1
  28. package/dist/stt.test.cjs +11 -3
  29. package/dist/stt.test.cjs.map +1 -1
  30. package/dist/stt.test.js +12 -4
  31. package/dist/stt.test.js.map +1 -1
  32. package/dist/tts.test.cjs +11 -3
  33. package/dist/tts.test.cjs.map +1 -1
  34. package/dist/tts.test.js +12 -4
  35. package/dist/tts.test.js.map +1 -1
  36. package/dist/ws/index.cjs +29 -0
  37. package/dist/ws/index.cjs.map +1 -0
  38. package/dist/ws/index.d.cts +3 -0
  39. package/dist/ws/index.d.ts +3 -0
  40. package/dist/ws/index.d.ts.map +1 -0
  41. package/dist/ws/index.js +5 -0
  42. package/dist/ws/index.js.map +1 -0
  43. package/dist/ws/llm.cjs +502 -0
  44. package/dist/ws/llm.cjs.map +1 -0
  45. package/dist/ws/llm.d.cts +74 -0
  46. package/dist/ws/llm.d.ts +74 -0
  47. package/dist/ws/llm.d.ts.map +1 -0
  48. package/dist/ws/llm.js +485 -0
  49. package/dist/ws/llm.js.map +1 -0
  50. package/dist/ws/llm.test.cjs +26 -0
  51. package/dist/ws/llm.test.cjs.map +1 -0
  52. package/dist/ws/llm.test.d.cts +2 -0
  53. package/dist/ws/llm.test.d.ts +2 -0
  54. package/dist/ws/llm.test.d.ts.map +1 -0
  55. package/dist/ws/llm.test.js +25 -0
  56. package/dist/ws/llm.test.js.map +1 -0
  57. package/dist/ws/types.cjs +128 -0
  58. package/dist/ws/types.cjs.map +1 -0
  59. package/dist/ws/types.d.cts +167 -0
  60. package/dist/ws/types.d.ts +167 -0
  61. package/dist/ws/types.d.ts.map +1 -0
  62. package/dist/ws/types.js +95 -0
  63. package/dist/ws/types.js.map +1 -0
  64. package/package.json +6 -5
  65. package/src/index.ts +1 -0
  66. package/src/llm.test.ts +31 -17
  67. package/src/responses/llm.test.ts +32 -18
  68. package/src/responses/llm.ts +105 -19
  69. package/src/stt.test.ts +12 -4
  70. package/src/stt.ts +8 -4
  71. package/src/tts.test.ts +12 -4
  72. package/src/ws/index.ts +17 -0
  73. package/src/ws/llm.test.ts +30 -0
  74. package/src/ws/llm.ts +665 -0
  75. package/src/ws/types.ts +131 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ws/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { APIConnectOptions } from '@livekit/agents';\nimport {\n APIConnectionError,\n APIStatusError,\n APITimeoutError,\n ConnectionPool,\n DEFAULT_API_CONNECT_OPTIONS,\n llm,\n stream,\n toError,\n} from '@livekit/agents';\nimport type OpenAI from 'openai';\nimport { WebSocket } from 'ws';\nimport type { ChatModels } from '../models.js';\nimport type {\n WsOutputItemDoneEvent,\n WsOutputTextDeltaEvent,\n WsResponseCompletedEvent,\n WsResponseCreateEvent,\n WsResponseCreatedEvent,\n WsResponseFailedEvent,\n WsServerEvent,\n} from './types.js';\nimport { wsServerEventSchema } from './types.js';\n\nconst OPENAI_RESPONSES_WS_URL = 'wss://api.openai.com/v1/responses';\n\n// OpenAI enforces a 60-minute maximum duration on Responses WebSocket connections.\nconst WS_MAX_SESSION_DURATION = 3_600_000;\n\n// ============================================================================\n// Internal: ResponsesWebSocket\n//\n// Wraps a single raw WebSocket connection. Maintains a FIFO queue of\n// StreamChannels — one per outstanding response.create request — and\n// dispatches every incoming server-event to the front of the queue.\n// A response is terminated (and its channel closed) when the service sends\n// response.completed, response.failed, or error.\n//\n// ============================================================================\n\nexport class ResponsesWebSocket {\n #ws: WebSocket;\n // FIFO queue: the front entry receives validated WsServerEvents for the in-flight response.\n #outputQueue: stream.StreamChannel<WsServerEvent>[] = [];\n\n constructor(ws: WebSocket) {\n this.#ws = ws;\n\n ws.on('message', (data: Buffer) => {\n const current = this.#outputQueue[0];\n if (!current) return;\n\n let raw: unknown;\n try {\n raw = JSON.parse(data.toString());\n } catch {\n return;\n }\n\n // Validate and type-narrow with Zod at write time so readers always\n // receive a fully-typed WsServerEvent.\n const parsed = wsServerEventSchema.safeParse(raw);\n if (!parsed.success) return;\n\n const event = parsed.data;\n void current.write(event);\n\n // Close and dequeue on any terminal event.\n if (\n event.type === 'response.completed' ||\n event.type === 'response.failed' ||\n event.type === 'error'\n ) {\n void current.close();\n this.#outputQueue.shift();\n }\n });\n\n ws.on('close', () => {\n // If the WebSocket closes while requests are still in flight, synthesise\n // a typed error event so all readers can handle it cleanly.\n for (const current of this.#outputQueue) {\n if (!current.closed) {\n const closeError: WsServerEvent = {\n type: 'error',\n error: {\n code: 'websocket_closed',\n message: 'OpenAI Responses WebSocket closed unexpectedly',\n },\n };\n void current.write(closeError).finally(() => current.close());\n }\n }\n this.#outputQueue = [];\n });\n }\n\n /**\n * Send a response.create event. Returns a typed `StreamChannel<WsServerEvent>`\n * that yields validated server events until the response terminates.\n */\n sendRequest(payload: WsResponseCreateEvent): stream.StreamChannel<WsServerEvent> {\n if (this.#ws.readyState !== WebSocket.OPEN) {\n throw new APIConnectionError({\n message: `OpenAI Responses WebSocket is not open (state ${getWebSocketStateLabel(this.#ws.readyState)})`,\n options: { retryable: true },\n });\n }\n\n const channel = stream.createStreamChannel<WsServerEvent>();\n this.#outputQueue.push(channel);\n this.#ws.send(JSON.stringify(payload));\n return channel;\n }\n\n close(): void {\n // Drain pending channels before closing the socket.\n for (const ch of this.#outputQueue) {\n void ch.close();\n }\n this.#outputQueue = [];\n this.#ws.close();\n }\n}\n\n// ============================================================================\n// LLMOptions\n// ============================================================================\n\nexport interface WSLLMOptions {\n model: string | ChatModels;\n apiKey?: string;\n baseURL?: string;\n temperature?: number;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n store?: boolean;\n metadata?: Record<string, string>;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: WSLLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.OPENAI_API_KEY,\n strictToolSchema: true,\n};\n\n// ============================================================================\n// LLM\n// ============================================================================\n\nexport class WSLLM extends llm.LLM {\n #opts: WSLLMOptions;\n #pool: ConnectionPool<ResponsesWebSocket>;\n #prevResponseId = '';\n #prevChatCtx: llm.ChatContext | null = null;\n #pendingToolCalls = new Set<string>();\n\n /**\n * Create a new instance of the OpenAI Responses API WebSocket LLM.\n *\n * @remarks\n * `apiKey` must be set to your OpenAI API key, either using the argument or\n * by setting the `OPENAI_API_KEY` environment variable.\n *\n * A persistent WebSocket connection to `/v1/responses` is maintained and\n * reused across turns, reducing per-turn continuation overhead for\n * tool-call-heavy workflows.\n */\n constructor(opts: Partial<WSLLMOptions> = defaultLLMOptions) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n if (!this.#opts.apiKey) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#pool = new ConnectionPool<ResponsesWebSocket>({\n maxSessionDuration: WS_MAX_SESSION_DURATION,\n connectCb: async (timeoutMs: number) => {\n const wsUrl = this.#opts.baseURL\n ? `${this.#opts.baseURL.replace(/^https?/, 'wss').replace(/\\/+$/, '')}/responses`\n : OPENAI_RESPONSES_WS_URL;\n const ws = await connectWs(wsUrl, this.#opts.apiKey!, timeoutMs);\n return new ResponsesWebSocket(ws);\n },\n closeCb: async (conn: ResponsesWebSocket) => {\n conn.close();\n },\n });\n }\n\n label(): string {\n return 'openai.ws.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n prewarm(): void {\n this.#pool.prewarm();\n }\n\n async close(): Promise<void> {\n await this.#pool.close();\n }\n\n override async aclose(): Promise<void> {\n await this.close();\n }\n\n /** Called by LLMStream once response.created fires to atomically persist both the\n * response ID and its corresponding chat context for the next turn's diff. */\n _onResponseCreated(responseId: string, chatCtx: llm.ChatContext): void {\n this.#prevResponseId = responseId;\n this.#prevChatCtx = chatCtx;\n }\n\n _setPendingToolCalls(callIds: Set<string>): void {\n this.#pendingToolCalls = callIds;\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): WSLLMStream {\n const modelOptions: Record<string, unknown> = { ...(extraKwargs ?? {}) };\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n modelOptions.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice =\n toolChoice !== undefined ? toolChoice : (this.#opts.toolChoice as llm.ToolChoice | undefined);\n if (toolChoice) {\n modelOptions.tool_choice = toolChoice;\n }\n\n if (this.#opts.temperature !== undefined) {\n modelOptions.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.store !== undefined) {\n modelOptions.store = this.#opts.store;\n }\n\n if (this.#opts.metadata) {\n modelOptions.metadata = this.#opts.metadata;\n }\n\n let inputChatCtx = chatCtx;\n let prevResponseId: string | undefined;\n const canUseStoredResponse = modelOptions.store !== false;\n\n if (canUseStoredResponse && this.#prevChatCtx && this.#prevResponseId) {\n const diff = llm.computeChatCtxDiff(this.#prevChatCtx, chatCtx);\n const lastPrevItemId = this.#prevChatCtx.items.at(-1)?.id ?? null;\n\n if (\n diff.toRemove.length === 0 &&\n diff.toCreate.length > 0 &&\n diff.toCreate[0]![0] === lastPrevItemId\n ) {\n // All new items are appended after the tail of the previous context —\n // safe to send only the incremental input with previous_response_id,\n // but only if all pending tool calls from the previous response have\n // their corresponding function_call_output in the new items.\n const newItemIds = new Set(diff.toCreate.map(([, id]) => id));\n const newItems = chatCtx.items.filter((item: llm.ChatItem) => newItemIds.has(item.id));\n const pendingToolCallsCompleted = this.#pendingToolCallsCompleted(newItems);\n if (pendingToolCallsCompleted) {\n inputChatCtx = new llm.ChatContext(newItems);\n prevResponseId = this.#prevResponseId;\n }\n }\n // Otherwise: items were removed or inserted mid-history — fall back to\n // sending the full context with no previous_response_id.\n }\n\n return new WSLLMStream(this, {\n pool: this.#pool,\n model: this.#opts.model,\n chatCtx: inputChatCtx,\n fullChatCtx: chatCtx,\n toolCtx,\n connOptions,\n modelOptions,\n prevResponseId,\n strictToolSchema: this.#opts.strictToolSchema ?? true,\n });\n }\n\n #pendingToolCallsCompleted(items: llm.ChatItem[]): boolean {\n if (this.#pendingToolCalls.size === 0) return true;\n const completedCallIds = new Set(\n items\n .filter((item): item is llm.FunctionCallOutput => item.type === 'function_call_output')\n .map((item) => item.callId),\n );\n return [...this.#pendingToolCalls].every((callId) => completedCallIds.has(callId));\n }\n}\n\n// ============================================================================\n// WsLLMStream\n// ============================================================================\n\nexport class WSLLMStream extends llm.LLMStream {\n #llm: WSLLM;\n #pool: ConnectionPool<ResponsesWebSocket>;\n #model: string | ChatModels;\n #modelOptions: Record<string, unknown>;\n #strictToolSchema: boolean;\n #prevResponseId?: string;\n /** Full chat context — used as fallback when previous_response_id is stale. */\n #fullChatCtx: llm.ChatContext;\n #responseId = '';\n #pendingToolCalls = new Set<string>();\n\n constructor(\n llm: WSLLM,\n {\n pool,\n model,\n chatCtx,\n fullChatCtx,\n toolCtx,\n connOptions,\n modelOptions,\n prevResponseId,\n strictToolSchema,\n }: {\n pool: ConnectionPool<ResponsesWebSocket>;\n model: string | ChatModels;\n chatCtx: llm.ChatContext;\n fullChatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions: APIConnectOptions;\n modelOptions: Record<string, unknown>;\n prevResponseId?: string;\n strictToolSchema: boolean;\n },\n ) {\n super(llm, { chatCtx, toolCtx, connOptions });\n this.#llm = llm;\n this.#pool = pool;\n this.#model = model;\n this.#modelOptions = modelOptions;\n this.#strictToolSchema = strictToolSchema;\n this.#prevResponseId = prevResponseId;\n this.#fullChatCtx = fullChatCtx;\n }\n\n protected async run(): Promise<void> {\n let retryable = true;\n\n try {\n await this.#pool.withConnection(async (conn: ResponsesWebSocket) => {\n const needsRetry = await this.#runWithConn(conn, this.chatCtx, this.#prevResponseId);\n\n if (needsRetry) {\n // previous_response_id was evicted from the server-side cache.\n // Retry once on the same connection with the full context and no ID.\n retryable = true;\n await this.#runWithConn(conn, this.#fullChatCtx, undefined);\n }\n });\n } catch (error) {\n if (\n error instanceof APIStatusError ||\n error instanceof APITimeoutError ||\n error instanceof APIConnectionError\n ) {\n throw error;\n }\n throw new APIConnectionError({\n message: toError(error).message,\n options: { retryable },\n });\n }\n }\n\n /**\n * Execute a single response.create round-trip on the given connection.\n * Returns `true` when the caller should retry with the full chat context\n * (i.e. `previous_response_not_found`), `false` otherwise.\n */\n async #runWithConn(\n conn: ResponsesWebSocket,\n chatCtx: llm.ChatContext,\n prevResponseId: string | undefined,\n ): Promise<boolean> {\n const messages = (await chatCtx.toProviderFormat(\n 'openai.responses',\n )) as OpenAI.Responses.ResponseInputItem[];\n\n const tools = this.toolCtx\n ? Object.entries(this.toolCtx).map(([name, func]) => {\n const oaiParams = {\n type: 'function' as const,\n name,\n description: func.description,\n parameters: llm.toJsonSchema(\n func.parameters,\n true,\n this.#strictToolSchema,\n ) as unknown as OpenAI.Responses.FunctionTool['parameters'],\n } as OpenAI.Responses.FunctionTool;\n\n if (this.#strictToolSchema) {\n oaiParams.strict = true;\n }\n\n return oaiParams;\n })\n : undefined;\n\n const requestOptions: Record<string, unknown> = { ...this.#modelOptions };\n if (!tools) {\n delete requestOptions.tool_choice;\n }\n\n const payload: WsResponseCreateEvent = {\n type: 'response.create',\n model: this.#model as string,\n input: messages as unknown[],\n tools: (tools ?? []) as unknown[],\n ...(prevResponseId ? { previous_response_id: prevResponseId } : {}),\n ...requestOptions,\n };\n\n let channel: stream.StreamChannel<WsServerEvent>;\n try {\n channel = conn.sendRequest(payload);\n } catch (error) {\n if (error instanceof APIConnectionError) {\n conn.close();\n this.#pool.invalidate();\n }\n throw error;\n }\n const reader = channel.stream().getReader();\n\n // Events are already Zod-validated by ResponsesWebSocket before being\n // written to the channel, so no re-parsing is needed here.\n try {\n while (true) {\n const { done, value: event } = await reader.read();\n if (done) break;\n\n let chunk: llm.ChatChunk | undefined;\n\n switch (event.type) {\n case 'error': {\n const retry = this.#handleError(event, conn);\n if (retry) return true;\n break;\n }\n case 'response.created':\n this.#handleResponseCreated(event);\n break;\n case 'response.output_item.done':\n chunk = this.#handleOutputItemDone(event);\n break;\n case 'response.output_text.delta':\n chunk = this.#handleOutputTextDelta(event);\n break;\n case 'response.completed':\n chunk = this.#handleResponseCompleted(event);\n break;\n case 'response.failed':\n this.#handleResponseFailed(event);\n break;\n default:\n break;\n }\n\n if (chunk) {\n this.queue.put(chunk);\n }\n }\n } finally {\n reader.releaseLock();\n }\n\n return false;\n }\n\n /**\n * Returns `true` when the caller should retry with full context\n * (`previous_response_not_found`), throws for all other errors.\n */\n #handleError(event: WsServerEvent & { type: 'error' }, conn: ResponsesWebSocket): boolean {\n const code = event.error?.code;\n\n if (code === 'previous_response_not_found') {\n // The server-side in-memory cache was evicted (e.g. after a failed turn\n // or reconnect). Signal the caller to retry with the full context.\n return true;\n }\n\n if (code === 'websocket_connection_limit_reached' || code === 'websocket_closed') {\n // Transient connection issue (timeout, network drop, or 60-min limit).\n // Evict this connection so the pool opens a fresh one on retry.\n conn.close();\n this.#pool.invalidate();\n throw new APIConnectionError({\n message: event.error?.message ?? `WebSocket closed (${code})`,\n options: { retryable: true },\n });\n }\n\n throw new APIStatusError({\n message: event.error?.message ?? event.message ?? 'Unknown error from OpenAI Responses WS',\n options: {\n statusCode: event.status ?? -1,\n retryable: false,\n },\n });\n }\n\n #handleResponseCreated(event: WsResponseCreatedEvent): void {\n this.#responseId = event.response.id;\n this.#llm._onResponseCreated(event.response.id, this.#fullChatCtx);\n }\n\n #handleOutputItemDone(event: WsOutputItemDoneEvent): llm.ChatChunk | undefined {\n if (event.item.type === 'function_call') {\n this.#pendingToolCalls.add(event.item.call_id);\n return {\n id: this.#responseId,\n delta: {\n role: 'assistant',\n content: undefined,\n toolCalls: [\n llm.FunctionCall.create({\n callId: event.item.call_id,\n name: event.item.name,\n args: event.item.arguments,\n }),\n ],\n },\n };\n }\n return undefined;\n }\n\n #handleOutputTextDelta(event: WsOutputTextDeltaEvent): llm.ChatChunk {\n return {\n id: this.#responseId,\n delta: {\n role: 'assistant',\n content: event.delta,\n },\n };\n }\n\n #handleResponseCompleted(event: WsResponseCompletedEvent): llm.ChatChunk | undefined {\n this.#llm._setPendingToolCalls(this.#pendingToolCalls);\n\n if (event.response.usage) {\n return {\n id: this.#responseId,\n usage: {\n completionTokens: event.response.usage.output_tokens,\n promptTokens: event.response.usage.input_tokens,\n promptCachedTokens: event.response.usage.input_tokens_details.cached_tokens,\n totalTokens: event.response.usage.total_tokens,\n },\n };\n }\n return undefined;\n }\n\n #handleResponseFailed(event: WsResponseFailedEvent): void {\n throw new APIStatusError({\n message: event.response?.error?.message ?? 'Response failed',\n options: { statusCode: -1, retryable: false },\n });\n }\n}\n\n// ============================================================================\n// Internal helpers\n// ============================================================================\n\nasync function connectWs(url: string, apiKey: string, timeoutMs: number): Promise<WebSocket> {\n return new Promise<WebSocket>((resolve, reject) => {\n const ws = new WebSocket(url, {\n headers: { Authorization: `Bearer ${apiKey}` },\n });\n\n let settled = false;\n\n const timer = setTimeout(() => {\n settled = true;\n ws.close();\n reject(\n new APIConnectionError({ message: 'Timeout connecting to OpenAI Responses WebSocket' }),\n );\n }, timeoutMs);\n\n ws.once('open', () => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(ws);\n });\n\n ws.once('error', (err) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(\n new APIConnectionError({\n message: `Error connecting to OpenAI Responses WebSocket: ${err.message}`,\n }),\n );\n });\n\n ws.once('close', (code) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(\n new APIConnectionError({\n message: `OpenAI Responses WebSocket closed unexpectedly during connect (code ${code})`,\n }),\n );\n });\n });\n}\n\nfunction getWebSocketStateLabel(readyState: number): string {\n switch (readyState) {\n case WebSocket.CONNECTING:\n return 'CONNECTING';\n case WebSocket.OPEN:\n return 'OPEN';\n case WebSocket.CLOSING:\n return 'CLOSING';\n case WebSocket.CLOSED:\n return 'CLOSED';\n default:\n return `UNKNOWN:${readyState}`;\n }\n}\n"],"mappings":"AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;AAW1B,SAAS,2BAA2B;AAEpC,MAAM,0BAA0B;AAGhC,MAAM,0BAA0B;AAazB,MAAM,mBAAmB;AAAA,EAC9B;AAAA;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AAI,QAAS;AACb,gBAAU;AACV,mBAAa,KAAK;AAClB;AAAA,QACE,IAAI,mBAAmB;AAAA,UACrB,SAAS,uEAAuE,IAAI;AAAA,QACtF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AAEA,SAAS,uBAAuB,YAA4B;AAC1D,UAAQ,YAAY;AAAA,IAClB,KAAK,UAAU;AACb,aAAO;AAAA,IACT,KAAK,UAAU;AACb,aAAO;AAAA,IACT,KAAK,UAAU;AACb,aAAO;AAAA,IACT,KAAK,UAAU;AACb,aAAO;AAAA,IACT;AACE,aAAO,WAAW,UAAU;AAAA,EAChC;AACF;","names":["llm"]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var import_agents = require("@livekit/agents");
3
+ var import_agents_plugins_test = require("@livekit/agents-plugins-test");
4
+ var import_vitest = require("vitest");
5
+ var import_llm = require("../responses/llm.cjs");
6
+ (0, import_agents.initializeLogger)({ level: "silent", pretty: false });
7
+ (0, import_vitest.describe)("OpenAI Responses WS wrapper", async () => {
8
+ await (0, import_agents_plugins_test.llm)(
9
+ new import_llm.LLM({
10
+ temperature: 0,
11
+ strictToolSchema: false,
12
+ useWebSocket: true
13
+ }),
14
+ true
15
+ );
16
+ });
17
+ (0, import_vitest.describe)("OpenAI Responses WS wrapper strict tool schema", async () => {
18
+ await (0, import_agents_plugins_test.llmStrict)(
19
+ new import_llm.LLM({
20
+ temperature: 0,
21
+ strictToolSchema: true,
22
+ useWebSocket: true
23
+ })
24
+ );
25
+ });
26
+ //# sourceMappingURL=llm.test.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ws/llm.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { initializeLogger } from '@livekit/agents';\nimport { llm, llmStrict } from '@livekit/agents-plugins-test';\nimport { describe } from 'vitest';\nimport { LLM } from '../responses/llm.js';\n\ninitializeLogger({ level: 'silent', pretty: false });\n\ndescribe('OpenAI Responses WS wrapper', async () => {\n await llm(\n new LLM({\n temperature: 0,\n strictToolSchema: false,\n useWebSocket: true,\n }),\n true,\n );\n});\n\ndescribe('OpenAI Responses WS wrapper strict tool schema', async () => {\n await llmStrict(\n new LLM({\n temperature: 0,\n strictToolSchema: true,\n useWebSocket: true,\n }),\n );\n});\n"],"mappings":";AAGA,oBAAiC;AACjC,iCAA+B;AAC/B,oBAAyB;AACzB,iBAAoB;AAAA,IAEpB,gCAAiB,EAAE,OAAO,UAAU,QAAQ,MAAM,CAAC;AAAA,IAEnD,wBAAS,+BAA+B,YAAY;AAClD,YAAM;AAAA,IACJ,IAAI,eAAI;AAAA,MACN,aAAa;AAAA,MACb,kBAAkB;AAAA,MAClB,cAAc;AAAA,IAChB,CAAC;AAAA,IACD;AAAA,EACF;AACF,CAAC;AAAA,IAED,wBAAS,kDAAkD,YAAY;AACrE,YAAM;AAAA,IACJ,IAAI,eAAI;AAAA,MACN,aAAa;AAAA,MACb,kBAAkB;AAAA,MAClB,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=llm.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=llm.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.test.d.ts","sourceRoot":"","sources":["../../src/ws/llm.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import { initializeLogger } from "@livekit/agents";
2
+ import { llm, llmStrict } from "@livekit/agents-plugins-test";
3
+ import { describe } from "vitest";
4
+ import { LLM } from "../responses/llm.js";
5
+ initializeLogger({ level: "silent", pretty: false });
6
+ describe("OpenAI Responses WS wrapper", async () => {
7
+ await llm(
8
+ new LLM({
9
+ temperature: 0,
10
+ strictToolSchema: false,
11
+ useWebSocket: true
12
+ }),
13
+ true
14
+ );
15
+ });
16
+ describe("OpenAI Responses WS wrapper strict tool schema", async () => {
17
+ await llmStrict(
18
+ new LLM({
19
+ temperature: 0,
20
+ strictToolSchema: true,
21
+ useWebSocket: true
22
+ })
23
+ );
24
+ });
25
+ //# sourceMappingURL=llm.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ws/llm.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { initializeLogger } from '@livekit/agents';\nimport { llm, llmStrict } from '@livekit/agents-plugins-test';\nimport { describe } from 'vitest';\nimport { LLM } from '../responses/llm.js';\n\ninitializeLogger({ level: 'silent', pretty: false });\n\ndescribe('OpenAI Responses WS wrapper', async () => {\n await llm(\n new LLM({\n temperature: 0,\n strictToolSchema: false,\n useWebSocket: true,\n }),\n true,\n );\n});\n\ndescribe('OpenAI Responses WS wrapper strict tool schema', async () => {\n await llmStrict(\n new LLM({\n temperature: 0,\n strictToolSchema: true,\n useWebSocket: true,\n }),\n );\n});\n"],"mappings":"AAGA,SAAS,wBAAwB;AACjC,SAAS,KAAK,iBAAiB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,WAAW;AAEpB,iBAAiB,EAAE,OAAO,UAAU,QAAQ,MAAM,CAAC;AAEnD,SAAS,+BAA+B,YAAY;AAClD,QAAM;AAAA,IACJ,IAAI,IAAI;AAAA,MACN,aAAa;AAAA,MACb,kBAAkB;AAAA,MAClB,cAAc;AAAA,IAChB,CAAC;AAAA,IACD;AAAA,EACF;AACF,CAAC;AAED,SAAS,kDAAkD,YAAY;AACrE,QAAM;AAAA,IACJ,IAAI,IAAI;AAAA,MACN,aAAa;AAAA,MACb,kBAAkB;AAAA,MAClB,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var types_exports = {};
20
+ __export(types_exports, {
21
+ wsErrorEventSchema: () => wsErrorEventSchema,
22
+ wsFunctionCallItemSchema: () => wsFunctionCallItemSchema,
23
+ wsOutputItemDoneEventSchema: () => wsOutputItemDoneEventSchema,
24
+ wsOutputItemSchema: () => wsOutputItemSchema,
25
+ wsOutputTextDeltaEventSchema: () => wsOutputTextDeltaEventSchema,
26
+ wsResponseCompletedEventSchema: () => wsResponseCompletedEventSchema,
27
+ wsResponseCreateEventSchema: () => wsResponseCreateEventSchema,
28
+ wsResponseCreatedEventSchema: () => wsResponseCreatedEventSchema,
29
+ wsResponseFailedEventSchema: () => wsResponseFailedEventSchema,
30
+ wsServerEventSchema: () => wsServerEventSchema
31
+ });
32
+ module.exports = __toCommonJS(types_exports);
33
+ var import_zod = require("zod");
34
+ const wsResponseCreateEventSchema = import_zod.z.object({
35
+ type: import_zod.z.literal("response.create"),
36
+ model: import_zod.z.string(),
37
+ input: import_zod.z.array(import_zod.z.unknown()),
38
+ tools: import_zod.z.array(import_zod.z.unknown()).optional(),
39
+ previous_response_id: import_zod.z.string().nullable().optional(),
40
+ store: import_zod.z.boolean().optional(),
41
+ temperature: import_zod.z.number().optional(),
42
+ metadata: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).optional()
43
+ }).passthrough();
44
+ const wsResponseCreatedEventSchema = import_zod.z.object({
45
+ type: import_zod.z.literal("response.created"),
46
+ response: import_zod.z.object({
47
+ id: import_zod.z.string()
48
+ }).passthrough()
49
+ });
50
+ const wsFunctionCallItemSchema = import_zod.z.object({
51
+ type: import_zod.z.literal("function_call"),
52
+ call_id: import_zod.z.string(),
53
+ name: import_zod.z.string(),
54
+ arguments: import_zod.z.string()
55
+ });
56
+ const wsOutputItemSchema = import_zod.z.discriminatedUnion("type", [
57
+ wsFunctionCallItemSchema,
58
+ import_zod.z.object({ type: import_zod.z.literal("message") }).passthrough(),
59
+ import_zod.z.object({ type: import_zod.z.literal("reasoning") }).passthrough(),
60
+ import_zod.z.object({ type: import_zod.z.literal("file") }).passthrough(),
61
+ import_zod.z.object({ type: import_zod.z.literal("computer_call") }).passthrough(),
62
+ import_zod.z.object({ type: import_zod.z.literal("web_search_call") }).passthrough()
63
+ ]);
64
+ const wsOutputItemDoneEventSchema = import_zod.z.object({
65
+ type: import_zod.z.literal("response.output_item.done"),
66
+ item: wsOutputItemSchema
67
+ });
68
+ const wsOutputTextDeltaEventSchema = import_zod.z.object({
69
+ type: import_zod.z.literal("response.output_text.delta"),
70
+ delta: import_zod.z.string()
71
+ });
72
+ const wsResponseCompletedEventSchema = import_zod.z.object({
73
+ type: import_zod.z.literal("response.completed"),
74
+ response: import_zod.z.object({
75
+ id: import_zod.z.string(),
76
+ usage: import_zod.z.object({
77
+ output_tokens: import_zod.z.number(),
78
+ input_tokens: import_zod.z.number(),
79
+ total_tokens: import_zod.z.number(),
80
+ input_tokens_details: import_zod.z.object({
81
+ cached_tokens: import_zod.z.number()
82
+ }).passthrough()
83
+ }).optional()
84
+ }).passthrough()
85
+ });
86
+ const wsResponseFailedEventSchema = import_zod.z.object({
87
+ type: import_zod.z.literal("response.failed"),
88
+ response: import_zod.z.object({
89
+ id: import_zod.z.string().optional(),
90
+ error: import_zod.z.object({
91
+ code: import_zod.z.string().optional(),
92
+ message: import_zod.z.string().optional()
93
+ }).optional()
94
+ }).passthrough()
95
+ });
96
+ const wsErrorEventSchema = import_zod.z.object({
97
+ type: import_zod.z.literal("error"),
98
+ status: import_zod.z.number().optional(),
99
+ error: import_zod.z.object({
100
+ type: import_zod.z.string().optional(),
101
+ code: import_zod.z.string().optional(),
102
+ message: import_zod.z.string().optional(),
103
+ param: import_zod.z.string().optional()
104
+ }).optional(),
105
+ message: import_zod.z.string().optional()
106
+ });
107
+ const wsServerEventSchema = import_zod.z.discriminatedUnion("type", [
108
+ wsResponseCreatedEventSchema,
109
+ wsOutputItemDoneEventSchema,
110
+ wsOutputTextDeltaEventSchema,
111
+ wsResponseCompletedEventSchema,
112
+ wsResponseFailedEventSchema,
113
+ wsErrorEventSchema
114
+ ]);
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ wsErrorEventSchema,
118
+ wsFunctionCallItemSchema,
119
+ wsOutputItemDoneEventSchema,
120
+ wsOutputItemSchema,
121
+ wsOutputTextDeltaEventSchema,
122
+ wsResponseCompletedEventSchema,
123
+ wsResponseCreateEventSchema,
124
+ wsResponseCreatedEventSchema,
125
+ wsResponseFailedEventSchema,
126
+ wsServerEventSchema
127
+ });
128
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ws/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\n// ============================================================================\n// Client → Server events\n// ============================================================================\n\nexport const wsResponseCreateEventSchema = z\n .object({\n type: z.literal('response.create'),\n model: z.string(),\n input: z.array(z.unknown()),\n tools: z.array(z.unknown()).optional(),\n previous_response_id: z.string().nullable().optional(),\n store: z.boolean().optional(),\n temperature: z.number().optional(),\n metadata: z.record(z.string(), z.string()).optional(),\n })\n .passthrough();\n\nexport type WsResponseCreateEvent = z.infer<typeof wsResponseCreateEventSchema>;\n\n// ============================================================================\n// Server → Client events\n// ============================================================================\n\nexport const wsResponseCreatedEventSchema = z.object({\n type: z.literal('response.created'),\n response: z\n .object({\n id: z.string(),\n })\n .passthrough(),\n});\n\nexport const wsFunctionCallItemSchema = z.object({\n type: z.literal('function_call'),\n call_id: z.string(),\n name: z.string(),\n arguments: z.string(),\n});\n\nexport const wsOutputItemSchema = z.discriminatedUnion('type', [\n wsFunctionCallItemSchema,\n z.object({ type: z.literal('message') }).passthrough(),\n z.object({ type: z.literal('reasoning') }).passthrough(),\n z.object({ type: z.literal('file') }).passthrough(),\n z.object({ type: z.literal('computer_call') }).passthrough(),\n z.object({ type: z.literal('web_search_call') }).passthrough(),\n]);\n\nexport const wsOutputItemDoneEventSchema = z.object({\n type: z.literal('response.output_item.done'),\n item: wsOutputItemSchema,\n});\n\nexport const wsOutputTextDeltaEventSchema = z.object({\n type: z.literal('response.output_text.delta'),\n delta: z.string(),\n});\n\nexport const wsResponseCompletedEventSchema = z.object({\n type: z.literal('response.completed'),\n response: z\n .object({\n id: z.string(),\n usage: z\n .object({\n output_tokens: z.number(),\n input_tokens: z.number(),\n total_tokens: z.number(),\n input_tokens_details: z\n .object({\n cached_tokens: z.number(),\n })\n .passthrough(),\n })\n .optional(),\n })\n .passthrough(),\n});\n\nexport const wsResponseFailedEventSchema = z.object({\n type: z.literal('response.failed'),\n response: z\n .object({\n id: z.string().optional(),\n error: z\n .object({\n code: z.string().optional(),\n message: z.string().optional(),\n })\n .optional(),\n })\n .passthrough(),\n});\n\nexport const wsErrorEventSchema = z.object({\n type: z.literal('error'),\n status: z.number().optional(),\n error: z\n .object({\n type: z.string().optional(),\n code: z.string().optional(),\n message: z.string().optional(),\n param: z.string().optional(),\n })\n .optional(),\n message: z.string().optional(),\n});\n\nexport const wsServerEventSchema = z.discriminatedUnion('type', [\n wsResponseCreatedEventSchema,\n wsOutputItemDoneEventSchema,\n wsOutputTextDeltaEventSchema,\n wsResponseCompletedEventSchema,\n wsResponseFailedEventSchema,\n wsErrorEventSchema,\n]);\n\nexport type WsResponseCreatedEvent = z.infer<typeof wsResponseCreatedEventSchema>;\nexport type WsFunctionCallItem = z.infer<typeof wsFunctionCallItemSchema>;\nexport type WsOutputItem = z.infer<typeof wsOutputItemSchema>;\nexport type WsOutputItemDoneEvent = z.infer<typeof wsOutputItemDoneEventSchema>;\nexport type WsOutputTextDeltaEvent = z.infer<typeof wsOutputTextDeltaEventSchema>;\nexport type WsResponseCompletedEvent = z.infer<typeof wsResponseCompletedEventSchema>;\nexport type WsResponseFailedEvent = z.infer<typeof wsResponseFailedEventSchema>;\nexport type WsErrorEvent = z.infer<typeof wsErrorEventSchema>;\nexport type WsServerEvent = z.infer<typeof wsServerEventSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAkB;AAMX,MAAM,8BAA8B,aACxC,OAAO;AAAA,EACN,MAAM,aAAE,QAAQ,iBAAiB;AAAA,EACjC,OAAO,aAAE,OAAO;AAAA,EAChB,OAAO,aAAE,MAAM,aAAE,QAAQ,CAAC;AAAA,EAC1B,OAAO,aAAE,MAAM,aAAE,QAAQ,CAAC,EAAE,SAAS;AAAA,EACrC,sBAAsB,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACrD,OAAO,aAAE,QAAQ,EAAE,SAAS;AAAA,EAC5B,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,aAAE,OAAO,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,EAAE,SAAS;AACtD,CAAC,EACA,YAAY;AAQR,MAAM,+BAA+B,aAAE,OAAO;AAAA,EACnD,MAAM,aAAE,QAAQ,kBAAkB;AAAA,EAClC,UAAU,aACP,OAAO;AAAA,IACN,IAAI,aAAE,OAAO;AAAA,EACf,CAAC,EACA,YAAY;AACjB,CAAC;AAEM,MAAM,2BAA2B,aAAE,OAAO;AAAA,EAC/C,MAAM,aAAE,QAAQ,eAAe;AAAA,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D,MAAM,aAAE,QAAQ,iBAAiB;AAAA,EACjC,UAAU,aACP,OAAO;AAAA,IACN,IAAI,aAAE,OAAO,EAAE,SAAS;AAAA,IACxB,OAAO,aACJ,OAAO;AAAA,MACN,MAAM,aAAE,OAAO,EAAE,SAAS;AAAA,MAC1B,SAAS,aAAE,OAAO,EAAE,SAAS;AAAA,IAC/B,CAAC,EACA,SAAS;AAAA,EACd,CAAC,EACA,YAAY;AACjB,CAAC;AAEM,MAAM,qBAAqB,aAAE,OAAO;AAAA,EACzC,MAAM,aAAE,QAAQ,OAAO;AAAA,EACvB,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,OAAO,aACJ,OAAO;AAAA,IACN,MAAM,aAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,MAAM,aAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,SAAS,aAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,OAAO,aAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,CAAC,EACA,SAAS;AAAA,EACZ,SAAS,aAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAEM,MAAM,sBAAsB,aAAE,mBAAmB,QAAQ;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;","names":[]}
@@ -0,0 +1,167 @@
1
+ import { z } from 'zod';
2
+ export declare const wsResponseCreateEventSchema: z.ZodObject<{
3
+ type: z.ZodLiteral<"response.create">;
4
+ model: z.ZodString;
5
+ input: z.ZodArray<z.ZodUnknown>;
6
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
7
+ previous_response_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ store: z.ZodOptional<z.ZodBoolean>;
9
+ temperature: z.ZodOptional<z.ZodNumber>;
10
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
11
+ }, z.core.$loose>;
12
+ export type WsResponseCreateEvent = z.infer<typeof wsResponseCreateEventSchema>;
13
+ export declare const wsResponseCreatedEventSchema: z.ZodObject<{
14
+ type: z.ZodLiteral<"response.created">;
15
+ response: z.ZodObject<{
16
+ id: z.ZodString;
17
+ }, z.core.$loose>;
18
+ }, z.core.$strip>;
19
+ export declare const wsFunctionCallItemSchema: z.ZodObject<{
20
+ type: z.ZodLiteral<"function_call">;
21
+ call_id: z.ZodString;
22
+ name: z.ZodString;
23
+ arguments: z.ZodString;
24
+ }, z.core.$strip>;
25
+ export declare const wsOutputItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ type: z.ZodLiteral<"function_call">;
27
+ call_id: z.ZodString;
28
+ name: z.ZodString;
29
+ arguments: z.ZodString;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<"message">;
32
+ }, z.core.$loose>, z.ZodObject<{
33
+ type: z.ZodLiteral<"reasoning">;
34
+ }, z.core.$loose>, z.ZodObject<{
35
+ type: z.ZodLiteral<"file">;
36
+ }, z.core.$loose>, z.ZodObject<{
37
+ type: z.ZodLiteral<"computer_call">;
38
+ }, z.core.$loose>, z.ZodObject<{
39
+ type: z.ZodLiteral<"web_search_call">;
40
+ }, z.core.$loose>], "type">;
41
+ export declare const wsOutputItemDoneEventSchema: z.ZodObject<{
42
+ type: z.ZodLiteral<"response.output_item.done">;
43
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
44
+ type: z.ZodLiteral<"function_call">;
45
+ call_id: z.ZodString;
46
+ name: z.ZodString;
47
+ arguments: z.ZodString;
48
+ }, z.core.$strip>, z.ZodObject<{
49
+ type: z.ZodLiteral<"message">;
50
+ }, z.core.$loose>, z.ZodObject<{
51
+ type: z.ZodLiteral<"reasoning">;
52
+ }, z.core.$loose>, z.ZodObject<{
53
+ type: z.ZodLiteral<"file">;
54
+ }, z.core.$loose>, z.ZodObject<{
55
+ type: z.ZodLiteral<"computer_call">;
56
+ }, z.core.$loose>, z.ZodObject<{
57
+ type: z.ZodLiteral<"web_search_call">;
58
+ }, z.core.$loose>], "type">;
59
+ }, z.core.$strip>;
60
+ export declare const wsOutputTextDeltaEventSchema: z.ZodObject<{
61
+ type: z.ZodLiteral<"response.output_text.delta">;
62
+ delta: z.ZodString;
63
+ }, z.core.$strip>;
64
+ export declare const wsResponseCompletedEventSchema: z.ZodObject<{
65
+ type: z.ZodLiteral<"response.completed">;
66
+ response: z.ZodObject<{
67
+ id: z.ZodString;
68
+ usage: z.ZodOptional<z.ZodObject<{
69
+ output_tokens: z.ZodNumber;
70
+ input_tokens: z.ZodNumber;
71
+ total_tokens: z.ZodNumber;
72
+ input_tokens_details: z.ZodObject<{
73
+ cached_tokens: z.ZodNumber;
74
+ }, z.core.$loose>;
75
+ }, z.core.$strip>>;
76
+ }, z.core.$loose>;
77
+ }, z.core.$strip>;
78
+ export declare const wsResponseFailedEventSchema: z.ZodObject<{
79
+ type: z.ZodLiteral<"response.failed">;
80
+ response: z.ZodObject<{
81
+ id: z.ZodOptional<z.ZodString>;
82
+ error: z.ZodOptional<z.ZodObject<{
83
+ code: z.ZodOptional<z.ZodString>;
84
+ message: z.ZodOptional<z.ZodString>;
85
+ }, z.core.$strip>>;
86
+ }, z.core.$loose>;
87
+ }, z.core.$strip>;
88
+ export declare const wsErrorEventSchema: z.ZodObject<{
89
+ type: z.ZodLiteral<"error">;
90
+ status: z.ZodOptional<z.ZodNumber>;
91
+ error: z.ZodOptional<z.ZodObject<{
92
+ type: z.ZodOptional<z.ZodString>;
93
+ code: z.ZodOptional<z.ZodString>;
94
+ message: z.ZodOptional<z.ZodString>;
95
+ param: z.ZodOptional<z.ZodString>;
96
+ }, z.core.$strip>>;
97
+ message: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>;
99
+ export declare const wsServerEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
100
+ type: z.ZodLiteral<"response.created">;
101
+ response: z.ZodObject<{
102
+ id: z.ZodString;
103
+ }, z.core.$loose>;
104
+ }, z.core.$strip>, z.ZodObject<{
105
+ type: z.ZodLiteral<"response.output_item.done">;
106
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
107
+ type: z.ZodLiteral<"function_call">;
108
+ call_id: z.ZodString;
109
+ name: z.ZodString;
110
+ arguments: z.ZodString;
111
+ }, z.core.$strip>, z.ZodObject<{
112
+ type: z.ZodLiteral<"message">;
113
+ }, z.core.$loose>, z.ZodObject<{
114
+ type: z.ZodLiteral<"reasoning">;
115
+ }, z.core.$loose>, z.ZodObject<{
116
+ type: z.ZodLiteral<"file">;
117
+ }, z.core.$loose>, z.ZodObject<{
118
+ type: z.ZodLiteral<"computer_call">;
119
+ }, z.core.$loose>, z.ZodObject<{
120
+ type: z.ZodLiteral<"web_search_call">;
121
+ }, z.core.$loose>], "type">;
122
+ }, z.core.$strip>, z.ZodObject<{
123
+ type: z.ZodLiteral<"response.output_text.delta">;
124
+ delta: z.ZodString;
125
+ }, z.core.$strip>, z.ZodObject<{
126
+ type: z.ZodLiteral<"response.completed">;
127
+ response: z.ZodObject<{
128
+ id: z.ZodString;
129
+ usage: z.ZodOptional<z.ZodObject<{
130
+ output_tokens: z.ZodNumber;
131
+ input_tokens: z.ZodNumber;
132
+ total_tokens: z.ZodNumber;
133
+ input_tokens_details: z.ZodObject<{
134
+ cached_tokens: z.ZodNumber;
135
+ }, z.core.$loose>;
136
+ }, z.core.$strip>>;
137
+ }, z.core.$loose>;
138
+ }, z.core.$strip>, z.ZodObject<{
139
+ type: z.ZodLiteral<"response.failed">;
140
+ response: z.ZodObject<{
141
+ id: z.ZodOptional<z.ZodString>;
142
+ error: z.ZodOptional<z.ZodObject<{
143
+ code: z.ZodOptional<z.ZodString>;
144
+ message: z.ZodOptional<z.ZodString>;
145
+ }, z.core.$strip>>;
146
+ }, z.core.$loose>;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ type: z.ZodLiteral<"error">;
149
+ status: z.ZodOptional<z.ZodNumber>;
150
+ error: z.ZodOptional<z.ZodObject<{
151
+ type: z.ZodOptional<z.ZodString>;
152
+ code: z.ZodOptional<z.ZodString>;
153
+ message: z.ZodOptional<z.ZodString>;
154
+ param: z.ZodOptional<z.ZodString>;
155
+ }, z.core.$strip>>;
156
+ message: z.ZodOptional<z.ZodString>;
157
+ }, z.core.$strip>], "type">;
158
+ export type WsResponseCreatedEvent = z.infer<typeof wsResponseCreatedEventSchema>;
159
+ export type WsFunctionCallItem = z.infer<typeof wsFunctionCallItemSchema>;
160
+ export type WsOutputItem = z.infer<typeof wsOutputItemSchema>;
161
+ export type WsOutputItemDoneEvent = z.infer<typeof wsOutputItemDoneEventSchema>;
162
+ export type WsOutputTextDeltaEvent = z.infer<typeof wsOutputTextDeltaEventSchema>;
163
+ export type WsResponseCompletedEvent = z.infer<typeof wsResponseCompletedEventSchema>;
164
+ export type WsResponseFailedEvent = z.infer<typeof wsResponseFailedEventSchema>;
165
+ export type WsErrorEvent = z.infer<typeof wsErrorEventSchema>;
166
+ export type WsServerEvent = z.infer<typeof wsServerEventSchema>;
167
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,167 @@
1
+ import { z } from 'zod';
2
+ export declare const wsResponseCreateEventSchema: z.ZodObject<{
3
+ type: z.ZodLiteral<"response.create">;
4
+ model: z.ZodString;
5
+ input: z.ZodArray<z.ZodUnknown>;
6
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
7
+ previous_response_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ store: z.ZodOptional<z.ZodBoolean>;
9
+ temperature: z.ZodOptional<z.ZodNumber>;
10
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
11
+ }, z.core.$loose>;
12
+ export type WsResponseCreateEvent = z.infer<typeof wsResponseCreateEventSchema>;
13
+ export declare const wsResponseCreatedEventSchema: z.ZodObject<{
14
+ type: z.ZodLiteral<"response.created">;
15
+ response: z.ZodObject<{
16
+ id: z.ZodString;
17
+ }, z.core.$loose>;
18
+ }, z.core.$strip>;
19
+ export declare const wsFunctionCallItemSchema: z.ZodObject<{
20
+ type: z.ZodLiteral<"function_call">;
21
+ call_id: z.ZodString;
22
+ name: z.ZodString;
23
+ arguments: z.ZodString;
24
+ }, z.core.$strip>;
25
+ export declare const wsOutputItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ type: z.ZodLiteral<"function_call">;
27
+ call_id: z.ZodString;
28
+ name: z.ZodString;
29
+ arguments: z.ZodString;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<"message">;
32
+ }, z.core.$loose>, z.ZodObject<{
33
+ type: z.ZodLiteral<"reasoning">;
34
+ }, z.core.$loose>, z.ZodObject<{
35
+ type: z.ZodLiteral<"file">;
36
+ }, z.core.$loose>, z.ZodObject<{
37
+ type: z.ZodLiteral<"computer_call">;
38
+ }, z.core.$loose>, z.ZodObject<{
39
+ type: z.ZodLiteral<"web_search_call">;
40
+ }, z.core.$loose>], "type">;
41
+ export declare const wsOutputItemDoneEventSchema: z.ZodObject<{
42
+ type: z.ZodLiteral<"response.output_item.done">;
43
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
44
+ type: z.ZodLiteral<"function_call">;
45
+ call_id: z.ZodString;
46
+ name: z.ZodString;
47
+ arguments: z.ZodString;
48
+ }, z.core.$strip>, z.ZodObject<{
49
+ type: z.ZodLiteral<"message">;
50
+ }, z.core.$loose>, z.ZodObject<{
51
+ type: z.ZodLiteral<"reasoning">;
52
+ }, z.core.$loose>, z.ZodObject<{
53
+ type: z.ZodLiteral<"file">;
54
+ }, z.core.$loose>, z.ZodObject<{
55
+ type: z.ZodLiteral<"computer_call">;
56
+ }, z.core.$loose>, z.ZodObject<{
57
+ type: z.ZodLiteral<"web_search_call">;
58
+ }, z.core.$loose>], "type">;
59
+ }, z.core.$strip>;
60
+ export declare const wsOutputTextDeltaEventSchema: z.ZodObject<{
61
+ type: z.ZodLiteral<"response.output_text.delta">;
62
+ delta: z.ZodString;
63
+ }, z.core.$strip>;
64
+ export declare const wsResponseCompletedEventSchema: z.ZodObject<{
65
+ type: z.ZodLiteral<"response.completed">;
66
+ response: z.ZodObject<{
67
+ id: z.ZodString;
68
+ usage: z.ZodOptional<z.ZodObject<{
69
+ output_tokens: z.ZodNumber;
70
+ input_tokens: z.ZodNumber;
71
+ total_tokens: z.ZodNumber;
72
+ input_tokens_details: z.ZodObject<{
73
+ cached_tokens: z.ZodNumber;
74
+ }, z.core.$loose>;
75
+ }, z.core.$strip>>;
76
+ }, z.core.$loose>;
77
+ }, z.core.$strip>;
78
+ export declare const wsResponseFailedEventSchema: z.ZodObject<{
79
+ type: z.ZodLiteral<"response.failed">;
80
+ response: z.ZodObject<{
81
+ id: z.ZodOptional<z.ZodString>;
82
+ error: z.ZodOptional<z.ZodObject<{
83
+ code: z.ZodOptional<z.ZodString>;
84
+ message: z.ZodOptional<z.ZodString>;
85
+ }, z.core.$strip>>;
86
+ }, z.core.$loose>;
87
+ }, z.core.$strip>;
88
+ export declare const wsErrorEventSchema: z.ZodObject<{
89
+ type: z.ZodLiteral<"error">;
90
+ status: z.ZodOptional<z.ZodNumber>;
91
+ error: z.ZodOptional<z.ZodObject<{
92
+ type: z.ZodOptional<z.ZodString>;
93
+ code: z.ZodOptional<z.ZodString>;
94
+ message: z.ZodOptional<z.ZodString>;
95
+ param: z.ZodOptional<z.ZodString>;
96
+ }, z.core.$strip>>;
97
+ message: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>;
99
+ export declare const wsServerEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
100
+ type: z.ZodLiteral<"response.created">;
101
+ response: z.ZodObject<{
102
+ id: z.ZodString;
103
+ }, z.core.$loose>;
104
+ }, z.core.$strip>, z.ZodObject<{
105
+ type: z.ZodLiteral<"response.output_item.done">;
106
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
107
+ type: z.ZodLiteral<"function_call">;
108
+ call_id: z.ZodString;
109
+ name: z.ZodString;
110
+ arguments: z.ZodString;
111
+ }, z.core.$strip>, z.ZodObject<{
112
+ type: z.ZodLiteral<"message">;
113
+ }, z.core.$loose>, z.ZodObject<{
114
+ type: z.ZodLiteral<"reasoning">;
115
+ }, z.core.$loose>, z.ZodObject<{
116
+ type: z.ZodLiteral<"file">;
117
+ }, z.core.$loose>, z.ZodObject<{
118
+ type: z.ZodLiteral<"computer_call">;
119
+ }, z.core.$loose>, z.ZodObject<{
120
+ type: z.ZodLiteral<"web_search_call">;
121
+ }, z.core.$loose>], "type">;
122
+ }, z.core.$strip>, z.ZodObject<{
123
+ type: z.ZodLiteral<"response.output_text.delta">;
124
+ delta: z.ZodString;
125
+ }, z.core.$strip>, z.ZodObject<{
126
+ type: z.ZodLiteral<"response.completed">;
127
+ response: z.ZodObject<{
128
+ id: z.ZodString;
129
+ usage: z.ZodOptional<z.ZodObject<{
130
+ output_tokens: z.ZodNumber;
131
+ input_tokens: z.ZodNumber;
132
+ total_tokens: z.ZodNumber;
133
+ input_tokens_details: z.ZodObject<{
134
+ cached_tokens: z.ZodNumber;
135
+ }, z.core.$loose>;
136
+ }, z.core.$strip>>;
137
+ }, z.core.$loose>;
138
+ }, z.core.$strip>, z.ZodObject<{
139
+ type: z.ZodLiteral<"response.failed">;
140
+ response: z.ZodObject<{
141
+ id: z.ZodOptional<z.ZodString>;
142
+ error: z.ZodOptional<z.ZodObject<{
143
+ code: z.ZodOptional<z.ZodString>;
144
+ message: z.ZodOptional<z.ZodString>;
145
+ }, z.core.$strip>>;
146
+ }, z.core.$loose>;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ type: z.ZodLiteral<"error">;
149
+ status: z.ZodOptional<z.ZodNumber>;
150
+ error: z.ZodOptional<z.ZodObject<{
151
+ type: z.ZodOptional<z.ZodString>;
152
+ code: z.ZodOptional<z.ZodString>;
153
+ message: z.ZodOptional<z.ZodString>;
154
+ param: z.ZodOptional<z.ZodString>;
155
+ }, z.core.$strip>>;
156
+ message: z.ZodOptional<z.ZodString>;
157
+ }, z.core.$strip>], "type">;
158
+ export type WsResponseCreatedEvent = z.infer<typeof wsResponseCreatedEventSchema>;
159
+ export type WsFunctionCallItem = z.infer<typeof wsFunctionCallItemSchema>;
160
+ export type WsOutputItem = z.infer<typeof wsOutputItemSchema>;
161
+ export type WsOutputItemDoneEvent = z.infer<typeof wsOutputItemDoneEventSchema>;
162
+ export type WsOutputTextDeltaEvent = z.infer<typeof wsOutputTextDeltaEventSchema>;
163
+ export type WsResponseCompletedEvent = z.infer<typeof wsResponseCompletedEventSchema>;
164
+ export type WsResponseFailedEvent = z.infer<typeof wsResponseFailedEventSchema>;
165
+ export type WsErrorEvent = z.infer<typeof wsErrorEventSchema>;
166
+ export type WsServerEvent = z.infer<typeof wsServerEventSchema>;
167
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ws/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,2BAA2B;;;;;;;;;iBAWxB,CAAC;AAEjB,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAMhF,eAAO,MAAM,4BAA4B;;;;;iBAOvC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;iBAKnC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;2BAO7B,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;iBAGtC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;iBAmBzC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;iBAatC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;iBAY7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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