@copilotkit/aimock 1.45.1 → 1.47.0
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +25 -1
- package/README.md +11 -2
- package/dist/agui-mock.cjs +25 -25
- package/dist/agui-mock.cjs.map +1 -1
- package/dist/agui-mock.d.cts.map +1 -1
- package/dist/agui-mock.d.ts.map +1 -1
- package/dist/agui-mock.js +25 -25
- package/dist/agui-mock.js.map +1 -1
- package/dist/agui-types.d.cts.map +1 -1
- package/dist/aimock-cli.cjs +15 -1
- package/dist/aimock-cli.cjs.map +1 -1
- package/dist/aimock-cli.d.cts.map +1 -1
- package/dist/aimock-cli.d.ts.map +1 -1
- package/dist/aimock-cli.js +16 -2
- package/dist/aimock-cli.js.map +1 -1
- package/dist/api-key-auth.cjs +10 -9
- package/dist/api-key-auth.cjs.map +1 -1
- package/dist/api-key-auth.d.cts.map +1 -1
- package/dist/api-key-auth.d.ts.map +1 -1
- package/dist/api-key-auth.js +11 -10
- package/dist/api-key-auth.js.map +1 -1
- package/dist/aws-event-stream.cjs +20 -23
- package/dist/aws-event-stream.cjs.map +1 -1
- package/dist/aws-event-stream.d.cts +0 -1
- package/dist/aws-event-stream.d.ts +0 -1
- package/dist/aws-event-stream.js +20 -24
- package/dist/aws-event-stream.js.map +1 -1
- package/dist/batches.cjs +2 -4
- package/dist/batches.cjs.map +1 -1
- package/dist/batches.d.cts.map +1 -1
- package/dist/batches.d.ts.map +1 -1
- package/dist/batches.js +2 -4
- package/dist/batches.js.map +1 -1
- package/dist/bedrock-converse.cjs +139 -161
- package/dist/bedrock-converse.cjs.map +1 -1
- package/dist/bedrock-converse.d.cts.map +1 -1
- package/dist/bedrock-converse.d.ts.map +1 -1
- package/dist/bedrock-converse.js +137 -159
- package/dist/bedrock-converse.js.map +1 -1
- package/dist/bedrock.cjs +175 -216
- package/dist/bedrock.cjs.map +1 -1
- package/dist/bedrock.d.cts.map +1 -1
- package/dist/bedrock.d.ts.map +1 -1
- package/dist/bedrock.js +172 -213
- package/dist/bedrock.js.map +1 -1
- package/dist/byteplus-video.cjs +11 -10
- package/dist/byteplus-video.cjs.map +1 -1
- package/dist/byteplus-video.d.cts.map +1 -1
- package/dist/byteplus-video.d.ts.map +1 -1
- package/dist/byteplus-video.js +5 -4
- package/dist/byteplus-video.js.map +1 -1
- package/dist/chaos.cjs +5 -4
- package/dist/chaos.cjs.map +1 -1
- package/dist/chaos.d.cts.map +1 -1
- package/dist/chaos.d.ts.map +1 -1
- package/dist/chaos.js +5 -4
- package/dist/chaos.js.map +1 -1
- package/dist/cli.cjs +15 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -1
- package/dist/cohere.cjs +107 -180
- package/dist/cohere.cjs.map +1 -1
- package/dist/cohere.d.cts.map +1 -1
- package/dist/cohere.d.ts.map +1 -1
- package/dist/cohere.js +106 -179
- package/dist/cohere.js.map +1 -1
- package/dist/config-loader.cjs +29 -1
- package/dist/config-loader.cjs.map +1 -1
- package/dist/config-loader.d.cts +7 -1
- package/dist/config-loader.d.cts.map +1 -1
- package/dist/config-loader.d.ts +7 -1
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/config-loader.js +29 -2
- package/dist/config-loader.js.map +1 -1
- package/dist/count-tokens.cjs +146 -0
- package/dist/count-tokens.cjs.map +1 -0
- package/dist/count-tokens.js +146 -0
- package/dist/count-tokens.js.map +1 -0
- package/dist/elevenlabs-audio.cjs +36 -34
- package/dist/elevenlabs-audio.cjs.map +1 -1
- package/dist/elevenlabs-audio.d.cts.map +1 -1
- package/dist/elevenlabs-audio.d.ts.map +1 -1
- package/dist/elevenlabs-audio.js +33 -31
- package/dist/elevenlabs-audio.js.map +1 -1
- package/dist/elevenlabs-voice.cjs +38 -37
- package/dist/elevenlabs-voice.cjs.map +1 -1
- package/dist/elevenlabs-voice.d.cts.map +1 -1
- package/dist/elevenlabs-voice.d.ts.map +1 -1
- package/dist/elevenlabs-voice.js +33 -32
- package/dist/elevenlabs-voice.js.map +1 -1
- package/dist/embedding-request.cjs +16 -0
- package/dist/embedding-request.cjs.map +1 -0
- package/dist/embedding-request.js +14 -0
- package/dist/embedding-request.js.map +1 -0
- package/dist/embeddings.cjs +30 -20
- package/dist/embeddings.cjs.map +1 -1
- package/dist/embeddings.d.cts.map +1 -1
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/embeddings.js +30 -20
- package/dist/embeddings.js.map +1 -1
- package/dist/fal-audio.cjs +45 -43
- package/dist/fal-audio.cjs.map +1 -1
- package/dist/fal-audio.d.cts.map +1 -1
- package/dist/fal-audio.d.ts.map +1 -1
- package/dist/fal-audio.js +42 -40
- package/dist/fal-audio.js.map +1 -1
- package/dist/fal.cjs +17 -15
- package/dist/fal.cjs.map +1 -1
- package/dist/fal.js +16 -14
- package/dist/fal.js.map +1 -1
- package/dist/files.cjs +2 -4
- package/dist/files.cjs.map +1 -1
- package/dist/files.d.cts.map +1 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +2 -4
- package/dist/files.js.map +1 -1
- package/dist/fine-tuning.cjs +2 -4
- package/dist/fine-tuning.cjs.map +1 -1
- package/dist/fine-tuning.d.cts.map +1 -1
- package/dist/fine-tuning.d.ts.map +1 -1
- package/dist/fine-tuning.js +2 -4
- package/dist/fine-tuning.js.map +1 -1
- package/dist/fixture-loader.cjs +140 -44
- package/dist/fixture-loader.cjs.map +1 -1
- package/dist/fixture-loader.d.cts.map +1 -1
- package/dist/fixture-loader.d.ts.map +1 -1
- package/dist/fixture-loader.js +141 -46
- package/dist/fixture-loader.js.map +1 -1
- package/dist/gemini-embeddings.cjs +26 -24
- package/dist/gemini-embeddings.cjs.map +1 -1
- package/dist/gemini-embeddings.js +26 -24
- package/dist/gemini-embeddings.js.map +1 -1
- package/dist/gemini-interactions.cjs +113 -156
- package/dist/gemini-interactions.cjs.map +1 -1
- package/dist/gemini-interactions.d.cts +0 -1
- package/dist/gemini-interactions.d.cts.map +1 -1
- package/dist/gemini-interactions.d.ts +0 -1
- package/dist/gemini-interactions.d.ts.map +1 -1
- package/dist/gemini-interactions.js +113 -156
- package/dist/gemini-interactions.js.map +1 -1
- package/dist/gemini.cjs +295 -218
- package/dist/gemini.cjs.map +1 -1
- package/dist/gemini.d.cts.map +1 -1
- package/dist/gemini.d.ts.map +1 -1
- package/dist/gemini.js +295 -219
- package/dist/gemini.js.map +1 -1
- package/dist/grok-video.cjs +14 -12
- package/dist/grok-video.cjs.map +1 -1
- package/dist/grok-video.d.cts.map +1 -1
- package/dist/grok-video.d.ts.map +1 -1
- package/dist/grok-video.js +8 -6
- package/dist/grok-video.js.map +1 -1
- package/dist/helpers.cjs +411 -75
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +51 -1
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.ts +51 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +402 -74
- package/dist/helpers.js.map +1 -1
- package/dist/images.cjs +30 -28
- package/dist/images.cjs.map +1 -1
- package/dist/images.d.cts.map +1 -1
- package/dist/images.d.ts.map +1 -1
- package/dist/images.js +27 -25
- package/dist/images.js.map +1 -1
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/journal.cjs +3 -1
- package/dist/journal.cjs.map +1 -1
- package/dist/journal.d.cts.map +1 -1
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +2 -1
- package/dist/journal.js.map +1 -1
- package/dist/llmock.cjs +3 -0
- package/dist/llmock.cjs.map +1 -1
- package/dist/llmock.d.cts.map +1 -1
- package/dist/llmock.d.ts.map +1 -1
- package/dist/llmock.js +3 -0
- package/dist/llmock.js.map +1 -1
- package/dist/mcp-fakes.d.cts.map +1 -1
- package/dist/mcp-handler.cjs +7 -3
- package/dist/mcp-handler.cjs.map +1 -1
- package/dist/mcp-handler.js +7 -3
- package/dist/mcp-handler.js.map +1 -1
- package/dist/mcp-recorder.cjs +2 -1
- package/dist/mcp-recorder.cjs.map +1 -1
- package/dist/mcp-recorder.js +3 -2
- package/dist/mcp-recorder.js.map +1 -1
- package/dist/messages.cjs +235 -202
- package/dist/messages.cjs.map +1 -1
- package/dist/messages.d.cts.map +1 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +234 -202
- package/dist/messages.js.map +1 -1
- package/dist/metrics.cjs +5 -2
- package/dist/metrics.cjs.map +1 -1
- package/dist/metrics.d.cts.map +1 -1
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +6 -3
- package/dist/metrics.js.map +1 -1
- package/dist/misbehavior.cjs +62 -3
- package/dist/misbehavior.cjs.map +1 -1
- package/dist/misbehavior.d.cts.map +1 -1
- package/dist/misbehavior.d.ts.map +1 -1
- package/dist/misbehavior.js +63 -4
- package/dist/misbehavior.js.map +1 -1
- package/dist/model-utils.cjs +1 -0
- package/dist/model-utils.cjs.map +1 -1
- package/dist/model-utils.js +1 -1
- package/dist/model-utils.js.map +1 -1
- package/dist/moderation.cjs +15 -12
- package/dist/moderation.cjs.map +1 -1
- package/dist/moderation.js +14 -11
- package/dist/moderation.js.map +1 -1
- package/dist/ndjson-writer.cjs +21 -23
- package/dist/ndjson-writer.cjs.map +1 -1
- package/dist/ndjson-writer.d.cts +0 -1
- package/dist/ndjson-writer.d.cts.map +1 -1
- package/dist/ndjson-writer.d.ts +0 -1
- package/dist/ndjson-writer.d.ts.map +1 -1
- package/dist/ndjson-writer.js +21 -24
- package/dist/ndjson-writer.js.map +1 -1
- package/dist/ollama.cjs +276 -210
- package/dist/ollama.cjs.map +1 -1
- package/dist/ollama.d.cts.map +1 -1
- package/dist/ollama.d.ts.map +1 -1
- package/dist/ollama.js +273 -207
- package/dist/ollama.js.map +1 -1
- package/dist/openapi.cjs +323 -3
- package/dist/openapi.cjs.map +1 -1
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.ts.map +1 -1
- package/dist/openapi.js +324 -4
- package/dist/openapi.js.map +1 -1
- package/dist/openrouter-chat.cjs +11 -155
- package/dist/openrouter-chat.cjs.map +1 -1
- package/dist/openrouter-chat.js +11 -155
- package/dist/openrouter-chat.js.map +1 -1
- package/dist/openrouter-video.cjs +51 -74
- package/dist/openrouter-video.cjs.map +1 -1
- package/dist/openrouter-video.d.cts.map +1 -1
- package/dist/openrouter-video.d.ts.map +1 -1
- package/dist/openrouter-video.js +37 -60
- package/dist/openrouter-video.js.map +1 -1
- package/dist/raw-validation.cjs +177 -0
- package/dist/raw-validation.cjs.map +1 -0
- package/dist/raw-validation.js +176 -0
- package/dist/raw-validation.js.map +1 -0
- package/dist/recorder.cjs +176 -95
- package/dist/recorder.cjs.map +1 -1
- package/dist/recorder.d.cts.map +1 -1
- package/dist/recorder.d.ts.map +1 -1
- package/dist/recorder.js +176 -95
- package/dist/recorder.js.map +1 -1
- package/dist/rerank.cjs +13 -11
- package/dist/rerank.cjs.map +1 -1
- package/dist/rerank.js +12 -10
- package/dist/rerank.js.map +1 -1
- package/dist/response/catalog/anthropic-page.cjs +39 -0
- package/dist/response/catalog/anthropic-page.cjs.map +1 -0
- package/dist/response/catalog/anthropic-page.js +38 -0
- package/dist/response/catalog/anthropic-page.js.map +1 -0
- package/dist/response/catalog/collect.cjs +61 -0
- package/dist/response/catalog/collect.cjs.map +1 -0
- package/dist/response/catalog/collect.js +59 -0
- package/dist/response/catalog/collect.js.map +1 -0
- package/dist/response/catalog/gemini-page.cjs +25 -0
- package/dist/response/catalog/gemini-page.cjs.map +1 -0
- package/dist/response/catalog/gemini-page.js +24 -0
- package/dist/response/catalog/gemini-page.js.map +1 -0
- package/dist/response/catalog/render.cjs +182 -0
- package/dist/response/catalog/render.cjs.map +1 -0
- package/dist/response/catalog/render.js +171 -0
- package/dist/response/catalog/render.js.map +1 -0
- package/dist/response/deliver.cjs +144 -0
- package/dist/response/deliver.cjs.map +1 -0
- package/dist/response/deliver.js +143 -0
- package/dist/response/deliver.js.map +1 -0
- package/dist/response/errors.cjs +225 -0
- package/dist/response/errors.cjs.map +1 -0
- package/dist/response/errors.js +224 -0
- package/dist/response/errors.js.map +1 -0
- package/dist/response/finish.cjs +39 -0
- package/dist/response/finish.cjs.map +1 -0
- package/dist/response/finish.js +35 -0
- package/dist/response/finish.js.map +1 -0
- package/dist/response/frame-loop.cjs +102 -0
- package/dist/response/frame-loop.cjs.map +1 -0
- package/dist/response/frame-loop.js +100 -0
- package/dist/response/frame-loop.js.map +1 -0
- package/dist/response/lifecycle.cjs +223 -0
- package/dist/response/lifecycle.cjs.map +1 -0
- package/dist/response/lifecycle.js +211 -0
- package/dist/response/lifecycle.js.map +1 -0
- package/dist/response/policy.cjs +126 -0
- package/dist/response/policy.cjs.map +1 -0
- package/dist/response/policy.js +120 -0
- package/dist/response/policy.js.map +1 -0
- package/dist/response/profiles.cjs +69 -0
- package/dist/response/profiles.cjs.map +1 -0
- package/dist/response/profiles.js +65 -0
- package/dist/response/profiles.js.map +1 -0
- package/dist/response/proxy.cjs +71 -0
- package/dist/response/proxy.cjs.map +1 -0
- package/dist/response/proxy.js +70 -0
- package/dist/response/proxy.js.map +1 -0
- package/dist/response/raw.cjs +228 -0
- package/dist/response/raw.cjs.map +1 -0
- package/dist/response/raw.js +227 -0
- package/dist/response/raw.js.map +1 -0
- package/dist/response/timing.cjs +157 -0
- package/dist/response/timing.cjs.map +1 -0
- package/dist/response/timing.js +150 -0
- package/dist/response/timing.js.map +1 -0
- package/dist/response/usage/codecs/anthropic.cjs +52 -0
- package/dist/response/usage/codecs/anthropic.cjs.map +1 -0
- package/dist/response/usage/codecs/anthropic.js +50 -0
- package/dist/response/usage/codecs/anthropic.js.map +1 -0
- package/dist/response/usage/codecs/cohere.cjs +36 -0
- package/dist/response/usage/codecs/cohere.cjs.map +1 -0
- package/dist/response/usage/codecs/cohere.js +35 -0
- package/dist/response/usage/codecs/cohere.js.map +1 -0
- package/dist/response/usage/codecs/converse.cjs +16 -0
- package/dist/response/usage/codecs/converse.cjs.map +1 -0
- package/dist/response/usage/codecs/converse.js +15 -0
- package/dist/response/usage/codecs/converse.js.map +1 -0
- package/dist/response/usage/codecs/gemini.cjs +31 -0
- package/dist/response/usage/codecs/gemini.cjs.map +1 -0
- package/dist/response/usage/codecs/gemini.js +31 -0
- package/dist/response/usage/codecs/gemini.js.map +1 -0
- package/dist/response/usage/codecs/interactions.cjs +22 -0
- package/dist/response/usage/codecs/interactions.cjs.map +1 -0
- package/dist/response/usage/codecs/interactions.js +21 -0
- package/dist/response/usage/codecs/interactions.js.map +1 -0
- package/dist/response/usage/codecs/ollama.cjs +17 -0
- package/dist/response/usage/codecs/ollama.cjs.map +1 -0
- package/dist/response/usage/codecs/ollama.js +17 -0
- package/dist/response/usage/codecs/ollama.js.map +1 -0
- package/dist/response/usage/codecs/openai.cjs +52 -0
- package/dist/response/usage/codecs/openai.cjs.map +1 -0
- package/dist/response/usage/codecs/openai.js +50 -0
- package/dist/response/usage/codecs/openai.js.map +1 -0
- package/dist/response/usage/codecs/openrouter.cjs +68 -0
- package/dist/response/usage/codecs/openrouter.cjs.map +1 -0
- package/dist/response/usage/codecs/openrouter.js +67 -0
- package/dist/response/usage/codecs/openrouter.js.map +1 -0
- package/dist/response/usage/codecs/realtime.cjs +19 -0
- package/dist/response/usage/codecs/realtime.cjs.map +1 -0
- package/dist/response/usage/codecs/realtime.js +18 -0
- package/dist/response/usage/codecs/realtime.js.map +1 -0
- package/dist/response/usage/codecs/responses.cjs +21 -0
- package/dist/response/usage/codecs/responses.cjs.map +1 -0
- package/dist/response/usage/codecs/responses.js +20 -0
- package/dist/response/usage/codecs/responses.js.map +1 -0
- package/dist/response/usage/estimate.cjs +23 -0
- package/dist/response/usage/estimate.cjs.map +1 -0
- package/dist/response/usage/estimate.js +21 -0
- package/dist/response/usage/estimate.js.map +1 -0
- package/dist/response/usage/fields.cjs +72 -0
- package/dist/response/usage/fields.cjs.map +1 -0
- package/dist/response/usage/fields.js +70 -0
- package/dist/response/usage/fields.js.map +1 -0
- package/dist/response/usage/recording.cjs +52 -0
- package/dist/response/usage/recording.cjs.map +1 -0
- package/dist/response/usage/recording.js +52 -0
- package/dist/response/usage/recording.js.map +1 -0
- package/dist/responses.cjs +304 -196
- package/dist/responses.cjs.map +1 -1
- package/dist/responses.d.cts.map +1 -1
- package/dist/responses.d.ts.map +1 -1
- package/dist/responses.js +303 -195
- package/dist/responses.js.map +1 -1
- package/dist/route-registry.cjs +45 -0
- package/dist/route-registry.cjs.map +1 -1
- package/dist/route-registry.d.cts.map +1 -1
- package/dist/route-registry.d.ts.map +1 -1
- package/dist/route-registry.js +41 -1
- package/dist/route-registry.js.map +1 -1
- package/dist/router.cjs +24 -4
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +7 -1
- package/dist/router.d.cts.map +1 -1
- package/dist/router.d.ts +7 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +24 -5
- package/dist/router.js.map +1 -1
- package/dist/search.cjs +13 -11
- package/dist/search.cjs.map +1 -1
- package/dist/search.js +12 -10
- package/dist/search.js.map +1 -1
- package/dist/server.cjs +293 -248
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +294 -249
- package/dist/server.js.map +1 -1
- package/dist/speech.cjs +20 -18
- package/dist/speech.cjs.map +1 -1
- package/dist/speech.d.cts.map +1 -1
- package/dist/speech.d.ts.map +1 -1
- package/dist/speech.js +19 -17
- package/dist/speech.js.map +1 -1
- package/dist/sse-writer.cjs +56 -30
- package/dist/sse-writer.cjs.map +1 -1
- package/dist/sse-writer.d.cts +0 -1
- package/dist/sse-writer.d.cts.map +1 -1
- package/dist/sse-writer.d.ts +0 -1
- package/dist/sse-writer.d.ts.map +1 -1
- package/dist/sse-writer.js +55 -31
- package/dist/sse-writer.js.map +1 -1
- package/dist/stream-collapse.cjs +118 -11
- package/dist/stream-collapse.cjs.map +1 -1
- package/dist/stream-collapse.d.cts +10 -9
- package/dist/stream-collapse.d.cts.map +1 -1
- package/dist/stream-collapse.d.ts +10 -9
- package/dist/stream-collapse.d.ts.map +1 -1
- package/dist/stream-collapse.js +118 -11
- package/dist/stream-collapse.js.map +1 -1
- package/dist/transcription.cjs +31 -43
- package/dist/transcription.cjs.map +1 -1
- package/dist/transcription.d.cts.map +1 -1
- package/dist/transcription.d.ts.map +1 -1
- package/dist/transcription.js +31 -43
- package/dist/transcription.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +231 -9
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +231 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vector-mock.cjs +3 -8
- package/dist/vector-mock.cjs.map +1 -1
- package/dist/vector-mock.d.cts.map +1 -1
- package/dist/vector-mock.d.ts.map +1 -1
- package/dist/vector-mock.js +3 -8
- package/dist/vector-mock.js.map +1 -1
- package/dist/vector-stores.cjs +2 -4
- package/dist/vector-stores.cjs.map +1 -1
- package/dist/vector-stores.d.cts.map +1 -1
- package/dist/vector-stores.d.ts.map +1 -1
- package/dist/vector-stores.js +2 -4
- package/dist/vector-stores.js.map +1 -1
- package/dist/veo-video.cjs +16 -14
- package/dist/veo-video.cjs.map +1 -1
- package/dist/veo-video.js +10 -8
- package/dist/veo-video.js.map +1 -1
- package/dist/video.cjs +21 -19
- package/dist/video.cjs.map +1 -1
- package/dist/video.d.cts.map +1 -1
- package/dist/video.d.ts.map +1 -1
- package/dist/video.js +20 -18
- package/dist/video.js.map +1 -1
- package/dist/ws-framing.cjs +12 -6
- package/dist/ws-framing.cjs.map +1 -1
- package/dist/ws-framing.d.cts +2 -0
- package/dist/ws-framing.d.cts.map +1 -1
- package/dist/ws-framing.d.ts +2 -0
- package/dist/ws-framing.d.ts.map +1 -1
- package/dist/ws-framing.js +12 -6
- package/dist/ws-framing.js.map +1 -1
- package/dist/ws-gemini-live.cjs +131 -96
- package/dist/ws-gemini-live.cjs.map +1 -1
- package/dist/ws-gemini-live.d.cts +0 -1
- package/dist/ws-gemini-live.d.cts.map +1 -1
- package/dist/ws-gemini-live.d.ts +0 -1
- package/dist/ws-gemini-live.d.ts.map +1 -1
- package/dist/ws-gemini-live.js +130 -95
- package/dist/ws-gemini-live.js.map +1 -1
- package/dist/ws-live.cjs +6 -5
- package/dist/ws-live.cjs.map +1 -1
- package/dist/ws-live.js +5 -4
- package/dist/ws-live.js.map +1 -1
- package/dist/ws-realtime.cjs +108 -124
- package/dist/ws-realtime.cjs.map +1 -1
- package/dist/ws-realtime.d.cts.map +1 -1
- package/dist/ws-realtime.d.ts.map +1 -1
- package/dist/ws-realtime.js +105 -121
- package/dist/ws-realtime.js.map +1 -1
- package/dist/ws-responses.cjs +80 -59
- package/dist/ws-responses.cjs.map +1 -1
- package/dist/ws-responses.d.cts.map +1 -1
- package/dist/ws-responses.d.ts.map +1 -1
- package/dist/ws-responses.js +79 -58
- package/dist/ws-responses.js.map +1 -1
- package/package.json +4 -1
- package/skills/write-fixtures/SKILL.md +57 -16
package/dist/ws-realtime.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { buildOpenAIError } from "./response/errors.js";
|
|
1
2
|
import { DEFAULT_TEST_ID } from "./constants.js";
|
|
2
|
-
import {
|
|
3
|
+
import { resolveRequestDecisions, strictOverrideField } from "./response/policy.js";
|
|
4
|
+
import { fixtureToolCallErrorCode, flattenHeaders, generateToolCallId, isCombinedFixtureResponse, isErrorResponse, isFixtureToolCallError, isTextResponse, isToolCallResponse, isTranscriptionResponse, journalFixtureToolCallError, prepareOpenAIChatMisbehavior, rejectResponsesOnlyToolCalls, requireServedFunctionToolCalls, resolveFixtureBlocks, resolveOpenAIChatMisbehaviorUsage, resolveResponse, strictNoMatchLogLine, strictNoMatchMessage } from "./helpers.js";
|
|
3
5
|
import { calculateDelay, delay } from "./sse-writer.js";
|
|
4
6
|
import { planMisbehavior, recordMisbehaviorOutcome } from "./misbehavior.js";
|
|
5
7
|
import { matchFixtureDiagnostic } from "./router.js";
|
|
6
8
|
import "./journal.js";
|
|
7
|
-
import {
|
|
9
|
+
import { markInterrupted, markWsTurnStopped, watchWsClose, wsLifecycle } from "./response/lifecycle.js";
|
|
10
|
+
import { render } from "./response/usage/codecs/realtime.js";
|
|
8
11
|
import { randomBytes } from "node:crypto";
|
|
9
12
|
|
|
10
13
|
//#region src/ws-realtime.ts
|
|
@@ -315,11 +318,11 @@ function sendEvent(ws, event, isBeta) {
|
|
|
315
318
|
function buildErrorRealtimeEvent(ws, message, isBeta, type = "invalid_request_error", code) {
|
|
316
319
|
sendEvent(ws, {
|
|
317
320
|
type: "error",
|
|
318
|
-
error: {
|
|
321
|
+
error: buildOpenAIError({
|
|
319
322
|
message,
|
|
320
323
|
type,
|
|
321
324
|
code
|
|
322
|
-
}
|
|
325
|
+
})
|
|
323
326
|
}, isBeta);
|
|
324
327
|
}
|
|
325
328
|
/**
|
|
@@ -365,6 +368,7 @@ function rejectRetiredBetaShape(ws, logger) {
|
|
|
365
368
|
function handleWebSocketRealtime(ws, fixtures, journal, defaults) {
|
|
366
369
|
const { logger } = defaults;
|
|
367
370
|
const sessionId = realtimeId("sess");
|
|
371
|
+
watchWsClose(ws);
|
|
368
372
|
const isBeta = defaults.upgradeHeaders?.["openai-beta"] ? String(defaults.upgradeHeaders["openai-beta"]).includes("realtime=v1") : false;
|
|
369
373
|
if (isBeta) {
|
|
370
374
|
rejectRetiredBetaShape(ws, logger);
|
|
@@ -435,11 +439,11 @@ async function processMessage(raw, ws, fixtures, journal, defaults, session, con
|
|
|
435
439
|
if (!validTypes.has(s.type)) {
|
|
436
440
|
sendEvent(ws, {
|
|
437
441
|
type: "error",
|
|
438
|
-
error: {
|
|
442
|
+
error: buildOpenAIError({
|
|
439
443
|
message: `Invalid session type: ${s.type}`,
|
|
440
444
|
type: "invalid_request_error",
|
|
441
445
|
code: "invalid_session_config"
|
|
442
|
-
}
|
|
446
|
+
})
|
|
443
447
|
}, isBeta);
|
|
444
448
|
return;
|
|
445
449
|
}
|
|
@@ -494,11 +498,11 @@ async function processMessage(raw, ws, fixtures, journal, defaults, session, con
|
|
|
494
498
|
Object.assign(session, prevSession);
|
|
495
499
|
sendEvent(ws, {
|
|
496
500
|
type: "error",
|
|
497
|
-
error: {
|
|
501
|
+
error: buildOpenAIError({
|
|
498
502
|
message: `Model ${candidateTranscriptionModel} does not support session type transcription`,
|
|
499
503
|
type: "invalid_request_error",
|
|
500
504
|
code: "invalid_session_config"
|
|
501
|
-
}
|
|
505
|
+
})
|
|
502
506
|
}, isBeta);
|
|
503
507
|
return;
|
|
504
508
|
}
|
|
@@ -506,11 +510,11 @@ async function processMessage(raw, ws, fixtures, journal, defaults, session, con
|
|
|
506
510
|
Object.assign(session, prevSession);
|
|
507
511
|
sendEvent(ws, {
|
|
508
512
|
type: "error",
|
|
509
|
-
error: {
|
|
513
|
+
error: buildOpenAIError({
|
|
510
514
|
message: `Model ${s.model ?? prevSession.model} does not support session type translation`,
|
|
511
515
|
type: "invalid_request_error",
|
|
512
516
|
code: "invalid_session_config"
|
|
513
|
-
}
|
|
517
|
+
})
|
|
514
518
|
}, isBeta);
|
|
515
519
|
return;
|
|
516
520
|
}
|
|
@@ -585,7 +589,7 @@ async function emitLiveTranscriptionEvents(ws, fixtures, journal, defaults, sess
|
|
|
585
589
|
const { fixture, skippedBySequenceOrTurn } = matchFixtureDiagnostic(fixtures, request, journal.getFixtureMatchCountsForTest(testId), defaults.requestTransform);
|
|
586
590
|
const itemId = audioItem.id ?? realtimeId("item");
|
|
587
591
|
if (!fixture) {
|
|
588
|
-
if (
|
|
592
|
+
if (resolveRequestDecisions(defaults.strict, defaults.upgradeHeaders).fixtureMiss) {
|
|
589
593
|
const strictMessage = strictNoMatchMessage(skippedBySequenceOrTurn);
|
|
590
594
|
defaults.logger.error(strictNoMatchLogLine("WS", "/v1/realtime", skippedBySequenceOrTurn));
|
|
591
595
|
journal.add({
|
|
@@ -673,18 +677,17 @@ async function emitLiveTranscriptionEvents(ws, fixtures, journal, defaults, sess
|
|
|
673
677
|
const latency = fixture.latency ?? defaults.latency;
|
|
674
678
|
const chunkSize = Math.max(1, fixture.chunkSize ?? defaults.chunkSize);
|
|
675
679
|
const replaySpeed = fixture.replaySpeed ?? defaults.replaySpeed;
|
|
676
|
-
const
|
|
680
|
+
const lifecycle = wsLifecycle(ws, fixture);
|
|
677
681
|
let chunkIndex = 0;
|
|
678
682
|
for (let index = 0; index < transcript.length; index += chunkSize) {
|
|
679
683
|
const chunkDelay = calculateDelay(chunkIndex, fixture.streamingProfile, latency, fixture.recordedTimings, replaySpeed);
|
|
680
|
-
if (chunkDelay > 0) await delay(chunkDelay,
|
|
681
|
-
if (
|
|
682
|
-
if (
|
|
683
|
-
journalEntry.
|
|
684
|
-
journalEntry.response.interruptReason = interruption.reason();
|
|
684
|
+
if (chunkDelay > 0) await delay(chunkDelay, lifecycle.signal);
|
|
685
|
+
if (lifecycle.signal.aborted || ws.isClosed) {
|
|
686
|
+
if (lifecycle.signal.aborted) {
|
|
687
|
+
markInterrupted(journalEntry, lifecycle.reason());
|
|
685
688
|
ws.destroy();
|
|
686
|
-
}
|
|
687
|
-
|
|
689
|
+
} else markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
690
|
+
lifecycle.dispose();
|
|
688
691
|
return;
|
|
689
692
|
}
|
|
690
693
|
sendEvent(ws, {
|
|
@@ -693,14 +696,13 @@ async function emitLiveTranscriptionEvents(ws, fixtures, journal, defaults, sess
|
|
|
693
696
|
content_index: 0,
|
|
694
697
|
delta: transcript.slice(index, index + chunkSize)
|
|
695
698
|
}, isBeta);
|
|
696
|
-
|
|
699
|
+
lifecycle.tick();
|
|
697
700
|
chunkIndex++;
|
|
698
701
|
}
|
|
699
|
-
if (
|
|
700
|
-
journalEntry
|
|
701
|
-
journalEntry.response.interruptReason = interruption.reason();
|
|
702
|
+
if (lifecycle.signal.aborted || ws.isClosed) {
|
|
703
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
702
704
|
ws.destroy();
|
|
703
|
-
|
|
705
|
+
lifecycle.dispose();
|
|
704
706
|
return;
|
|
705
707
|
}
|
|
706
708
|
sendEvent(ws, {
|
|
@@ -711,7 +713,7 @@ async function emitLiveTranscriptionEvents(ws, fixtures, journal, defaults, sess
|
|
|
711
713
|
usage,
|
|
712
714
|
...response.transcription.languages !== void 0 ? { languages: response.transcription.languages } : {}
|
|
713
715
|
}, isBeta);
|
|
714
|
-
|
|
716
|
+
lifecycle.dispose();
|
|
715
717
|
}
|
|
716
718
|
function sendLiveTranscriptionFailure(ws, itemId, error, isBeta) {
|
|
717
719
|
sendEvent(ws, {
|
|
@@ -762,11 +764,7 @@ function checkRealtimeFixtureToolCalls(ws, journalEntry, responseId, isBeta, log
|
|
|
762
764
|
code: fixtureToolCallErrorCode(err)
|
|
763
765
|
}
|
|
764
766
|
},
|
|
765
|
-
usage: {
|
|
766
|
-
total_tokens: 0,
|
|
767
|
-
input_tokens: 0,
|
|
768
|
-
output_tokens: 0
|
|
769
|
-
}
|
|
767
|
+
usage: render({ kind: "ordinary-zero" })
|
|
770
768
|
}
|
|
771
769
|
}, isBeta);
|
|
772
770
|
return;
|
|
@@ -794,7 +792,7 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
794
792
|
const responseId = realtimeId("resp");
|
|
795
793
|
if (fixture) journal.incrementFixtureMatchCount(fixture, fixtures, testId);
|
|
796
794
|
if (!fixture) {
|
|
797
|
-
if (
|
|
795
|
+
if (resolveRequestDecisions(defaults.strict, defaults.upgradeHeaders).fixtureMiss) {
|
|
798
796
|
const strictMessage = strictNoMatchMessage(skippedBySequenceOrTurn);
|
|
799
797
|
defaults.logger.error(strictNoMatchLogLine("WS", "/v1/realtime", skippedBySequenceOrTurn));
|
|
800
798
|
journal.add({
|
|
@@ -848,11 +846,7 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
848
846
|
code: "no_fixture_match"
|
|
849
847
|
}
|
|
850
848
|
},
|
|
851
|
-
usage: {
|
|
852
|
-
total_tokens: 0,
|
|
853
|
-
input_tokens: 0,
|
|
854
|
-
output_tokens: 0
|
|
855
|
-
}
|
|
849
|
+
usage: render({ kind: "ordinary-zero" })
|
|
856
850
|
}
|
|
857
851
|
}, isBeta);
|
|
858
852
|
return;
|
|
@@ -916,11 +910,10 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
916
910
|
const usage = resolveOpenAIChatMisbehaviorUsage(misbehavior, completionReq, false);
|
|
917
911
|
await streamRealtimeBlocks(ws, blocks, responseId, fixture, defaults, latency, chunkSize, isBeta, conversationItems, journalEntry, {
|
|
918
912
|
stop: misbehavior.stop,
|
|
919
|
-
usage: {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
913
|
+
usage: render({
|
|
914
|
+
kind: "applied-misbehavior",
|
|
915
|
+
usage
|
|
916
|
+
})
|
|
924
917
|
});
|
|
925
918
|
return;
|
|
926
919
|
}
|
|
@@ -952,11 +945,7 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
952
945
|
code: response.error.code
|
|
953
946
|
}
|
|
954
947
|
},
|
|
955
|
-
usage: {
|
|
956
|
-
total_tokens: 0,
|
|
957
|
-
input_tokens: 0,
|
|
958
|
-
output_tokens: 0
|
|
959
|
-
}
|
|
948
|
+
usage: render({ kind: "ordinary-zero" })
|
|
960
949
|
}
|
|
961
950
|
}, isBeta);
|
|
962
951
|
return;
|
|
@@ -986,7 +975,7 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
986
975
|
usage: null
|
|
987
976
|
}
|
|
988
977
|
}, isBeta);
|
|
989
|
-
const
|
|
978
|
+
const lifecycle = wsLifecycle(ws, fixture);
|
|
990
979
|
let interrupted = false;
|
|
991
980
|
const allOutputItems = [];
|
|
992
981
|
const textItemId = realtimeId("item");
|
|
@@ -1034,8 +1023,8 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1034
1023
|
for (let i = 0; i < content.length; i += chunkSize) {
|
|
1035
1024
|
if (ws.isClosed) break;
|
|
1036
1025
|
const chunkDelay = calculateDelay(eventIndex, void 0, latency, recordedTimings, replaySpeed);
|
|
1037
|
-
if (chunkDelay > 0) await delay(chunkDelay,
|
|
1038
|
-
if (
|
|
1026
|
+
if (chunkDelay > 0) await delay(chunkDelay, lifecycle.signal);
|
|
1027
|
+
if (lifecycle.signal.aborted) {
|
|
1039
1028
|
interrupted = true;
|
|
1040
1029
|
break;
|
|
1041
1030
|
}
|
|
@@ -1055,21 +1044,21 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1055
1044
|
break;
|
|
1056
1045
|
}
|
|
1057
1046
|
eventIndex++;
|
|
1058
|
-
|
|
1059
|
-
if (
|
|
1047
|
+
lifecycle.tick();
|
|
1048
|
+
if (lifecycle.signal.aborted) {
|
|
1060
1049
|
interrupted = true;
|
|
1061
1050
|
break;
|
|
1062
1051
|
}
|
|
1063
1052
|
}
|
|
1064
1053
|
if (interrupted) {
|
|
1065
1054
|
ws.destroy();
|
|
1066
|
-
journalEntry.
|
|
1067
|
-
|
|
1068
|
-
interruption?.cleanup();
|
|
1055
|
+
markInterrupted(journalEntry, lifecycle.reason());
|
|
1056
|
+
lifecycle.dispose();
|
|
1069
1057
|
return;
|
|
1070
1058
|
}
|
|
1071
1059
|
if (ws.isClosed) {
|
|
1072
|
-
|
|
1060
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
1061
|
+
lifecycle.dispose();
|
|
1073
1062
|
return;
|
|
1074
1063
|
}
|
|
1075
1064
|
sendEvent(ws, {
|
|
@@ -1081,7 +1070,8 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1081
1070
|
text: content
|
|
1082
1071
|
}, isBeta);
|
|
1083
1072
|
if (ws.isClosed) {
|
|
1084
|
-
|
|
1073
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
1074
|
+
lifecycle.dispose();
|
|
1085
1075
|
return;
|
|
1086
1076
|
}
|
|
1087
1077
|
sendEvent(ws, {
|
|
@@ -1096,7 +1086,8 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1096
1086
|
}
|
|
1097
1087
|
}, isBeta);
|
|
1098
1088
|
if (ws.isClosed) {
|
|
1099
|
-
|
|
1089
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
1090
|
+
lifecycle.dispose();
|
|
1100
1091
|
return;
|
|
1101
1092
|
}
|
|
1102
1093
|
sendEvent(ws, {
|
|
@@ -1120,7 +1111,8 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1120
1111
|
}
|
|
1121
1112
|
}, isBeta);
|
|
1122
1113
|
if (ws.isClosed) {
|
|
1123
|
-
|
|
1114
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
1115
|
+
lifecycle.dispose();
|
|
1124
1116
|
return;
|
|
1125
1117
|
}
|
|
1126
1118
|
allOutputItems.push(textOutputItem);
|
|
@@ -1156,8 +1148,8 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1156
1148
|
for (let i = 0; i < args.length; i += chunkSize) {
|
|
1157
1149
|
if (ws.isClosed) break;
|
|
1158
1150
|
const chunkDelay = calculateDelay(eventIndex, void 0, latency, recordedTimings, replaySpeed);
|
|
1159
|
-
if (chunkDelay > 0) await delay(chunkDelay,
|
|
1160
|
-
if (
|
|
1151
|
+
if (chunkDelay > 0) await delay(chunkDelay, lifecycle.signal);
|
|
1152
|
+
if (lifecycle.signal.aborted) {
|
|
1161
1153
|
interrupted = true;
|
|
1162
1154
|
break;
|
|
1163
1155
|
}
|
|
@@ -1177,8 +1169,8 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1177
1169
|
break;
|
|
1178
1170
|
}
|
|
1179
1171
|
eventIndex++;
|
|
1180
|
-
|
|
1181
|
-
if (
|
|
1172
|
+
lifecycle.tick();
|
|
1173
|
+
if (lifecycle.signal.aborted) {
|
|
1182
1174
|
interrupted = true;
|
|
1183
1175
|
break;
|
|
1184
1176
|
}
|
|
@@ -1220,13 +1212,15 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1220
1212
|
}
|
|
1221
1213
|
if (interrupted) {
|
|
1222
1214
|
ws.destroy();
|
|
1223
|
-
journalEntry.
|
|
1224
|
-
|
|
1225
|
-
|
|
1215
|
+
markInterrupted(journalEntry, lifecycle.reason());
|
|
1216
|
+
lifecycle.dispose();
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
lifecycle.dispose();
|
|
1220
|
+
if (ws.isClosed) {
|
|
1221
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
1226
1222
|
return;
|
|
1227
1223
|
}
|
|
1228
|
-
interruption?.cleanup();
|
|
1229
|
-
if (ws.isClosed) return;
|
|
1230
1224
|
sendEvent(ws, {
|
|
1231
1225
|
type: "response.done",
|
|
1232
1226
|
response: {
|
|
@@ -1234,11 +1228,7 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1234
1228
|
object: "realtime.response",
|
|
1235
1229
|
status: "completed",
|
|
1236
1230
|
output: allOutputItems,
|
|
1237
|
-
usage: {
|
|
1238
|
-
total_tokens: 0,
|
|
1239
|
-
input_tokens: 0,
|
|
1240
|
-
output_tokens: 0
|
|
1241
|
-
}
|
|
1231
|
+
usage: render({ kind: "ordinary-zero" })
|
|
1242
1232
|
}
|
|
1243
1233
|
}, isBeta);
|
|
1244
1234
|
conversationItems.push({
|
|
@@ -1306,14 +1296,14 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1306
1296
|
const content = response.content ?? "";
|
|
1307
1297
|
const replaySpeed = fixture.replaySpeed ?? defaults.replaySpeed;
|
|
1308
1298
|
const { recordedTimings } = fixture;
|
|
1309
|
-
const
|
|
1299
|
+
const lifecycle = wsLifecycle(ws, fixture);
|
|
1310
1300
|
let interrupted = false;
|
|
1311
1301
|
let eventIndex = 0;
|
|
1312
1302
|
for (let i = 0; i < content.length; i += chunkSize) {
|
|
1313
1303
|
if (ws.isClosed) break;
|
|
1314
1304
|
const chunkDelay = calculateDelay(eventIndex, void 0, latency, recordedTimings, replaySpeed);
|
|
1315
|
-
if (chunkDelay > 0) await delay(chunkDelay,
|
|
1316
|
-
if (
|
|
1305
|
+
if (chunkDelay > 0) await delay(chunkDelay, lifecycle.signal);
|
|
1306
|
+
if (lifecycle.signal.aborted) {
|
|
1317
1307
|
interrupted = true;
|
|
1318
1308
|
break;
|
|
1319
1309
|
}
|
|
@@ -1333,21 +1323,23 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1333
1323
|
break;
|
|
1334
1324
|
}
|
|
1335
1325
|
eventIndex++;
|
|
1336
|
-
|
|
1337
|
-
if (
|
|
1326
|
+
lifecycle.tick();
|
|
1327
|
+
if (lifecycle.signal.aborted) {
|
|
1338
1328
|
interrupted = true;
|
|
1339
1329
|
break;
|
|
1340
1330
|
}
|
|
1341
1331
|
}
|
|
1342
1332
|
if (interrupted) {
|
|
1343
1333
|
ws.destroy();
|
|
1344
|
-
journalEntry.
|
|
1345
|
-
|
|
1346
|
-
|
|
1334
|
+
markInterrupted(journalEntry, lifecycle.reason());
|
|
1335
|
+
lifecycle.dispose();
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
lifecycle.dispose();
|
|
1339
|
+
if (ws.isClosed) {
|
|
1340
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
1347
1341
|
return;
|
|
1348
1342
|
}
|
|
1349
|
-
interruption?.cleanup();
|
|
1350
|
-
if (ws.isClosed) return;
|
|
1351
1343
|
sendEvent(ws, {
|
|
1352
1344
|
type: "response.output_text.done",
|
|
1353
1345
|
response_id: responseId,
|
|
@@ -1394,11 +1386,7 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1394
1386
|
object: "realtime.response",
|
|
1395
1387
|
status: "completed",
|
|
1396
1388
|
output: [outputItem],
|
|
1397
|
-
usage: {
|
|
1398
|
-
total_tokens: 0,
|
|
1399
|
-
input_tokens: 0,
|
|
1400
|
-
output_tokens: 0
|
|
1401
|
-
}
|
|
1389
|
+
usage: render({ kind: "ordinary-zero" })
|
|
1402
1390
|
}
|
|
1403
1391
|
}, isBeta);
|
|
1404
1392
|
conversationItems.push({
|
|
@@ -1428,7 +1416,7 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1428
1416
|
}
|
|
1429
1417
|
}, isBeta);
|
|
1430
1418
|
const outputItems = [];
|
|
1431
|
-
const
|
|
1419
|
+
const lifecycle = wsLifecycle(ws, fixture);
|
|
1432
1420
|
const replaySpeed = fixture.replaySpeed ?? defaults.replaySpeed;
|
|
1433
1421
|
const { recordedTimings } = fixture;
|
|
1434
1422
|
let interrupted = false;
|
|
@@ -1463,8 +1451,8 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1463
1451
|
for (let i = 0; i < args.length; i += chunkSize) {
|
|
1464
1452
|
if (ws.isClosed) break;
|
|
1465
1453
|
const chunkDelay = calculateDelay(eventIndex, void 0, latency, recordedTimings, replaySpeed);
|
|
1466
|
-
if (chunkDelay > 0) await delay(chunkDelay,
|
|
1467
|
-
if (
|
|
1454
|
+
if (chunkDelay > 0) await delay(chunkDelay, lifecycle.signal);
|
|
1455
|
+
if (lifecycle.signal.aborted) {
|
|
1468
1456
|
interrupted = true;
|
|
1469
1457
|
break;
|
|
1470
1458
|
}
|
|
@@ -1484,8 +1472,8 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1484
1472
|
break;
|
|
1485
1473
|
}
|
|
1486
1474
|
eventIndex++;
|
|
1487
|
-
|
|
1488
|
-
if (
|
|
1475
|
+
lifecycle.tick();
|
|
1476
|
+
if (lifecycle.signal.aborted) {
|
|
1489
1477
|
interrupted = true;
|
|
1490
1478
|
break;
|
|
1491
1479
|
}
|
|
@@ -1525,13 +1513,15 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1525
1513
|
}
|
|
1526
1514
|
if (interrupted) {
|
|
1527
1515
|
ws.destroy();
|
|
1528
|
-
journalEntry.
|
|
1529
|
-
|
|
1530
|
-
|
|
1516
|
+
markInterrupted(journalEntry, lifecycle.reason());
|
|
1517
|
+
lifecycle.dispose();
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
lifecycle.dispose();
|
|
1521
|
+
if (ws.isClosed) {
|
|
1522
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
1531
1523
|
return;
|
|
1532
1524
|
}
|
|
1533
|
-
interruption?.cleanup();
|
|
1534
|
-
if (ws.isClosed) return;
|
|
1535
1525
|
sendEvent(ws, {
|
|
1536
1526
|
type: "response.done",
|
|
1537
1527
|
response: {
|
|
@@ -1539,11 +1529,7 @@ async function handleResponseCreate(ws, fixtures, journal, defaults, session, co
|
|
|
1539
1529
|
object: "realtime.response",
|
|
1540
1530
|
status: "completed",
|
|
1541
1531
|
output: outputItems,
|
|
1542
|
-
usage: {
|
|
1543
|
-
total_tokens: 0,
|
|
1544
|
-
input_tokens: 0,
|
|
1545
|
-
output_tokens: 0
|
|
1546
|
-
}
|
|
1532
|
+
usage: render({ kind: "ordinary-zero" })
|
|
1547
1533
|
}
|
|
1548
1534
|
}, isBeta);
|
|
1549
1535
|
for (const item of outputItems) conversationItems.push(item);
|
|
@@ -1573,7 +1559,7 @@ async function streamRealtimeBlocks(ws, blocks, responseId, fixture, defaults, l
|
|
|
1573
1559
|
usage: null
|
|
1574
1560
|
}
|
|
1575
1561
|
}, isBeta);
|
|
1576
|
-
const
|
|
1562
|
+
const lifecycle = wsLifecycle(ws, fixture);
|
|
1577
1563
|
let interrupted = false;
|
|
1578
1564
|
const allOutputItems = [];
|
|
1579
1565
|
const replaySpeed = fixture.replaySpeed ?? defaults.replaySpeed;
|
|
@@ -1625,8 +1611,8 @@ async function streamRealtimeBlocks(ws, blocks, responseId, fixture, defaults, l
|
|
|
1625
1611
|
for (let i = 0; i < text.length; i += chunkSize) {
|
|
1626
1612
|
if (ws.isClosed) break;
|
|
1627
1613
|
const chunkDelay = calculateDelay(eventIndex, void 0, latency, recordedTimings, replaySpeed);
|
|
1628
|
-
if (chunkDelay > 0) await delay(chunkDelay,
|
|
1629
|
-
if (
|
|
1614
|
+
if (chunkDelay > 0) await delay(chunkDelay, lifecycle.signal);
|
|
1615
|
+
if (lifecycle.signal.aborted) {
|
|
1630
1616
|
interrupted = true;
|
|
1631
1617
|
break;
|
|
1632
1618
|
}
|
|
@@ -1646,8 +1632,8 @@ async function streamRealtimeBlocks(ws, blocks, responseId, fixture, defaults, l
|
|
|
1646
1632
|
break;
|
|
1647
1633
|
}
|
|
1648
1634
|
eventIndex++;
|
|
1649
|
-
|
|
1650
|
-
if (
|
|
1635
|
+
lifecycle.tick();
|
|
1636
|
+
if (lifecycle.signal.aborted) {
|
|
1651
1637
|
interrupted = true;
|
|
1652
1638
|
break;
|
|
1653
1639
|
}
|
|
@@ -1726,8 +1712,8 @@ async function streamRealtimeBlocks(ws, blocks, responseId, fixture, defaults, l
|
|
|
1726
1712
|
for (let i = 0; i < args.length; i += chunkSize) {
|
|
1727
1713
|
if (ws.isClosed) break;
|
|
1728
1714
|
const chunkDelay = calculateDelay(eventIndex, void 0, latency, recordedTimings, replaySpeed);
|
|
1729
|
-
if (chunkDelay > 0) await delay(chunkDelay,
|
|
1730
|
-
if (
|
|
1715
|
+
if (chunkDelay > 0) await delay(chunkDelay, lifecycle.signal);
|
|
1716
|
+
if (lifecycle.signal.aborted) {
|
|
1731
1717
|
interrupted = true;
|
|
1732
1718
|
break;
|
|
1733
1719
|
}
|
|
@@ -1747,8 +1733,8 @@ async function streamRealtimeBlocks(ws, blocks, responseId, fixture, defaults, l
|
|
|
1747
1733
|
break;
|
|
1748
1734
|
}
|
|
1749
1735
|
eventIndex++;
|
|
1750
|
-
|
|
1751
|
-
if (
|
|
1736
|
+
lifecycle.tick();
|
|
1737
|
+
if (lifecycle.signal.aborted) {
|
|
1752
1738
|
interrupted = true;
|
|
1753
1739
|
break;
|
|
1754
1740
|
}
|
|
@@ -1790,13 +1776,15 @@ async function streamRealtimeBlocks(ws, blocks, responseId, fixture, defaults, l
|
|
|
1790
1776
|
}
|
|
1791
1777
|
if (interrupted) {
|
|
1792
1778
|
ws.destroy();
|
|
1793
|
-
journalEntry.
|
|
1794
|
-
|
|
1795
|
-
|
|
1779
|
+
markInterrupted(journalEntry, lifecycle.reason());
|
|
1780
|
+
lifecycle.dispose();
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1783
|
+
lifecycle.dispose();
|
|
1784
|
+
if (ws.isClosed) {
|
|
1785
|
+
markWsTurnStopped(journalEntry, ws, lifecycle);
|
|
1796
1786
|
return;
|
|
1797
1787
|
}
|
|
1798
|
-
interruption?.cleanup();
|
|
1799
|
-
if (ws.isClosed) return;
|
|
1800
1788
|
sendEvent(ws, {
|
|
1801
1789
|
type: "response.done",
|
|
1802
1790
|
response: {
|
|
@@ -1808,11 +1796,7 @@ async function streamRealtimeBlocks(ws, blocks, responseId, fixture, defaults, l
|
|
|
1808
1796
|
reason: fault.stop === "length" ? "max_output_tokens" : "content_filter"
|
|
1809
1797
|
} } : {},
|
|
1810
1798
|
output: allOutputItems,
|
|
1811
|
-
usage: fault?.usage ?? {
|
|
1812
|
-
total_tokens: 0,
|
|
1813
|
-
input_tokens: 0,
|
|
1814
|
-
output_tokens: 0
|
|
1815
|
-
}
|
|
1799
|
+
usage: fault?.usage ?? render({ kind: "ordinary-zero" })
|
|
1816
1800
|
}
|
|
1817
1801
|
}, isBeta);
|
|
1818
1802
|
for (const item of allOutputItems) {
|