@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
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { renderError } from "./response/errors.js";
|
|
2
|
+
import { resolveRequestDecisions, strictOverrideField } from "./response/policy.js";
|
|
3
|
+
import { extractOverrides, flattenHeaders, generateToolCallId, getContext, getTestId, isCombinedFixtureResponse, isErrorResponse, isJsonObject, isRawResponse, isTextResponse, isToolCallResponse, prepareOpenAIChatMisbehavior, requireEmittedFunctionToolCalls, resolveFixtureBlockOutcome, resolveOpenAIChatMisbehaviorUsage, resolveResponse, servedToolArgs, strictNoMatchLogLine, strictNoMatchMessage } from "./helpers.js";
|
|
4
|
+
import { sseCodec, writeErrorResponse } from "./sse-writer.js";
|
|
3
5
|
import { applyChaosAsync } from "./chaos.js";
|
|
4
6
|
import { planMisbehavior, recordMisbehaviorOutcome } from "./misbehavior.js";
|
|
5
7
|
import { matchFixtureDiagnostic } from "./router.js";
|
|
6
8
|
import { proxyAndRecord } from "./recorder.js";
|
|
7
|
-
import {
|
|
9
|
+
import { misbehaviorPayloadLength, servedPayloadLength } from "./response/timing.js";
|
|
10
|
+
import { deliverJson, deliverStream } from "./response/deliver.js";
|
|
11
|
+
import { proxyInterruption, withHangUpDetection } from "./response/proxy.js";
|
|
12
|
+
import { serveRawResponse } from "./response/raw.js";
|
|
13
|
+
import { render } from "./response/usage/codecs/interactions.js";
|
|
8
14
|
|
|
9
15
|
//#region src/gemini-interactions.ts
|
|
16
|
+
/**
|
|
17
|
+
* Google Gemini Interactions API support.
|
|
18
|
+
*
|
|
19
|
+
* Translates incoming Interactions requests into the ChatCompletionRequest
|
|
20
|
+
* format used by the fixture router, and converts fixture responses back
|
|
21
|
+
* into the Gemini Interactions format — either a single JSON response or
|
|
22
|
+
* an SSE stream with event_type-based framing.
|
|
23
|
+
*/
|
|
10
24
|
/** Step types whose payload is a tool/agent result keyed by call_id. */
|
|
11
25
|
const STEP_RESULT_TYPES = new Set([
|
|
12
26
|
"function_result",
|
|
@@ -185,18 +199,7 @@ function nextInteractionId() {
|
|
|
185
199
|
return `aimock-int-${interactionCounter++}`;
|
|
186
200
|
}
|
|
187
201
|
function interactionsUsage(overrides) {
|
|
188
|
-
|
|
189
|
-
total_input_tokens: 0,
|
|
190
|
-
total_output_tokens: 0,
|
|
191
|
-
total_tokens: 0
|
|
192
|
-
};
|
|
193
|
-
const input = overrides.usage.input_tokens ?? overrides.usage.prompt_tokens ?? overrides.usage.promptTokenCount ?? 0;
|
|
194
|
-
const output = overrides.usage.output_tokens ?? overrides.usage.completion_tokens ?? overrides.usage.candidatesTokenCount ?? 0;
|
|
195
|
-
return {
|
|
196
|
-
total_input_tokens: input,
|
|
197
|
-
total_output_tokens: output,
|
|
198
|
-
total_tokens: overrides.usage.total_tokens ?? overrides.usage.totalTokenCount ?? input + output
|
|
199
|
-
};
|
|
202
|
+
return render(overrides);
|
|
200
203
|
}
|
|
201
204
|
function buildInteractionsTextResponse(content, model, interactionId, overrides) {
|
|
202
205
|
return {
|
|
@@ -277,12 +280,6 @@ function buildInteractionsContentWithToolCallsResponse(content, toolCalls, model
|
|
|
277
280
|
usage: interactionsUsage(overrides)
|
|
278
281
|
};
|
|
279
282
|
}
|
|
280
|
-
function buildInteractionsErrorResponse(message, code) {
|
|
281
|
-
return { error: {
|
|
282
|
-
code: code ?? "INVALID_ARGUMENT",
|
|
283
|
-
message
|
|
284
|
-
} };
|
|
285
|
-
}
|
|
286
283
|
let eventIdCounter = 0;
|
|
287
284
|
function resetEventIdCounter() {
|
|
288
285
|
eventIdCounter = 0;
|
|
@@ -495,33 +492,10 @@ function buildInteractionsContentWithToolCallsSSEEvents(content, toolCalls, inte
|
|
|
495
492
|
});
|
|
496
493
|
return events;
|
|
497
494
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
const { recordedTimings, replaySpeed } = opts;
|
|
503
|
-
const signal = opts.signal;
|
|
504
|
-
const onChunkSent = opts.onChunkSent;
|
|
505
|
-
if (res.writableEnded) return true;
|
|
506
|
-
res.setHeader("Content-Type", "text/event-stream");
|
|
507
|
-
res.setHeader("Cache-Control", "no-cache");
|
|
508
|
-
res.setHeader("Connection", "keep-alive");
|
|
509
|
-
let chunkIndex = 0;
|
|
510
|
-
for (const event of events) {
|
|
511
|
-
const chunkDelay = calculateDelay(chunkIndex, profile, latency, recordedTimings, replaySpeed);
|
|
512
|
-
if (chunkDelay > 0) await delay(chunkDelay, signal);
|
|
513
|
-
if (signal?.aborted) return false;
|
|
514
|
-
if (res.writableEnded) return true;
|
|
515
|
-
res.write(`data: ${JSON.stringify(event)}\n\n`);
|
|
516
|
-
if (event.event_type === "step.delta") {
|
|
517
|
-
onChunkSent?.();
|
|
518
|
-
chunkIndex++;
|
|
519
|
-
}
|
|
520
|
-
if (signal?.aborted) return false;
|
|
521
|
-
}
|
|
522
|
-
if (!res.writableEnded) res.end();
|
|
523
|
-
return true;
|
|
524
|
-
}
|
|
495
|
+
const interactionsCodec = {
|
|
496
|
+
...sseCodec({ done: false }),
|
|
497
|
+
counts: (event) => event.event_type === "step.delta"
|
|
498
|
+
};
|
|
525
499
|
function prepareInteractionsMisbehavior(plan, streaming) {
|
|
526
500
|
if (!streaming && plan.summary.fault === "stop-length-mid-tool") {
|
|
527
501
|
const response = plan.response;
|
|
@@ -570,7 +544,10 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
570
544
|
fixture: null
|
|
571
545
|
}
|
|
572
546
|
});
|
|
573
|
-
writeErrorResponse(res, 400,
|
|
547
|
+
writeErrorResponse(res, 400, renderError("interactions", "validation", {
|
|
548
|
+
message: `Malformed JSON body: ${detail}`,
|
|
549
|
+
code: "INVALID_ARGUMENT"
|
|
550
|
+
}).body);
|
|
574
551
|
return;
|
|
575
552
|
}
|
|
576
553
|
if (!isJsonObject(interactionsReq)) {
|
|
@@ -584,7 +561,10 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
584
561
|
fixture: null
|
|
585
562
|
}
|
|
586
563
|
});
|
|
587
|
-
writeErrorResponse(res, 400,
|
|
564
|
+
writeErrorResponse(res, 400, renderError("interactions", "validation", {
|
|
565
|
+
message: "Request body must be a JSON object",
|
|
566
|
+
code: "INVALID_ARGUMENT"
|
|
567
|
+
}).body);
|
|
588
568
|
return;
|
|
589
569
|
}
|
|
590
570
|
const validationError = validateInteractionsInput(interactionsReq.input) ?? validateInteractionsTools(interactionsReq.tools);
|
|
@@ -599,7 +579,10 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
599
579
|
fixture: null
|
|
600
580
|
}
|
|
601
581
|
});
|
|
602
|
-
writeErrorResponse(res, 400,
|
|
582
|
+
writeErrorResponse(res, 400, renderError("interactions", "validation", {
|
|
583
|
+
message: validationError,
|
|
584
|
+
code: "INVALID_ARGUMENT"
|
|
585
|
+
}).body);
|
|
603
586
|
return;
|
|
604
587
|
}
|
|
605
588
|
const completionReq = geminiInteractionsToCompletionRequest(interactionsReq);
|
|
@@ -608,7 +591,7 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
608
591
|
const streaming = interactionsReq.stream !== false;
|
|
609
592
|
const model = completionReq.model;
|
|
610
593
|
const testId = getTestId(req);
|
|
611
|
-
const { fixture, skippedBySequenceOrTurn } = matchFixtureDiagnostic(fixtures, completionReq, journal.getFixtureMatchCountsForTest(testId), defaults.requestTransform);
|
|
594
|
+
const { fixture, skippedBySequenceOrTurn } = matchFixtureDiagnostic(fixtures, completionReq, journal.getFixtureMatchCountsForTest(testId), defaults.requestTransform, { wire: "gemini-interactions" });
|
|
612
595
|
if (fixture) journal.incrementFixtureMatchCount(fixture, fixtures, testId);
|
|
613
596
|
if (await applyChaosAsync(res, fixture, defaults.chaos, req.headers, req.url, journal, {
|
|
614
597
|
method: req.method ?? "POST",
|
|
@@ -617,7 +600,8 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
617
600
|
body: completionReq
|
|
618
601
|
}, fixture ? "fixture" : "proxy", defaults.registry, defaults.logger)) return;
|
|
619
602
|
if (!fixture) {
|
|
620
|
-
|
|
603
|
+
const decisions = resolveRequestDecisions(defaults.strict, req.headers);
|
|
604
|
+
if (decisions.fixtureMiss) {
|
|
621
605
|
const strictStatus = 503;
|
|
622
606
|
const strictMessage = strictNoMatchMessage(skippedBySequenceOrTurn);
|
|
623
607
|
logger.error(strictNoMatchLogLine(req.method ?? "POST", urlPath, skippedBySequenceOrTurn));
|
|
@@ -632,11 +616,14 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
632
616
|
...strictOverrideField(defaults.strict, req.headers)
|
|
633
617
|
}
|
|
634
618
|
});
|
|
635
|
-
writeErrorResponse(res, strictStatus,
|
|
619
|
+
writeErrorResponse(res, strictStatus, renderError("interactions", "strict-miss", {
|
|
620
|
+
message: strictMessage,
|
|
621
|
+
code: "UNAVAILABLE"
|
|
622
|
+
}).body);
|
|
636
623
|
return;
|
|
637
624
|
}
|
|
638
|
-
if (defaults.record) {
|
|
639
|
-
const outcome = await proxyAndRecord(req, res, completionReq, "gemini-interactions", urlPath, fixtures, defaults, raw);
|
|
625
|
+
if (decisions.upstream && defaults.record) {
|
|
626
|
+
const { outcome, clientHungUp } = await withHangUpDetection(req, res, () => proxyAndRecord(req, res, completionReq, "gemini-interactions", urlPath, fixtures, defaults, raw));
|
|
640
627
|
if (outcome === "handled_by_hook") return;
|
|
641
628
|
if (outcome !== "not_configured") {
|
|
642
629
|
journal.add({
|
|
@@ -647,7 +634,8 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
647
634
|
response: {
|
|
648
635
|
status: res.statusCode ?? 200,
|
|
649
636
|
fixture: null,
|
|
650
|
-
source: "proxy"
|
|
637
|
+
source: "proxy",
|
|
638
|
+
...proxyInterruption(res, clientHungUp)
|
|
651
639
|
}
|
|
652
640
|
});
|
|
653
641
|
return;
|
|
@@ -664,7 +652,10 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
664
652
|
...strictOverrideField(defaults.strict, req.headers)
|
|
665
653
|
}
|
|
666
654
|
});
|
|
667
|
-
writeErrorResponse(res, 404,
|
|
655
|
+
writeErrorResponse(res, 404, renderError("interactions", "fixture-miss", {
|
|
656
|
+
message: "No fixture matched",
|
|
657
|
+
code: "NOT_FOUND"
|
|
658
|
+
}).body);
|
|
668
659
|
return;
|
|
669
660
|
}
|
|
670
661
|
let response = await resolveResponse(fixture, completionReq);
|
|
@@ -696,7 +687,10 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
696
687
|
testId
|
|
697
688
|
});
|
|
698
689
|
if (!misbehavior.summary?.evaluations.some((evaluation) => evaluation.outcome === "error")) logger.error(`${req.method ?? "POST"} ${urlPath}: ${misbehavior.message}`);
|
|
699
|
-
writeErrorResponse(res, misbehavior.status,
|
|
690
|
+
writeErrorResponse(res, misbehavior.status, renderError("interactions", "misbehavior", {
|
|
691
|
+
message: misbehavior.message,
|
|
692
|
+
code: misbehavior.code
|
|
693
|
+
}).body);
|
|
700
694
|
return;
|
|
701
695
|
}
|
|
702
696
|
if (misbehavior.kind === "applied") {
|
|
@@ -707,6 +701,42 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
707
701
|
const latency = fixture.latency ?? defaults.latency;
|
|
708
702
|
const chunkSize = Math.max(1, fixture.chunkSize ?? defaults.chunkSize);
|
|
709
703
|
const replaySpeed = fixture.replaySpeed ?? defaults.replaySpeed;
|
|
704
|
+
const streamTiming = {
|
|
705
|
+
latency,
|
|
706
|
+
streamingProfile: fixture.streamingProfile,
|
|
707
|
+
recordedTimings: fixture.recordedTimings,
|
|
708
|
+
replaySpeed
|
|
709
|
+
};
|
|
710
|
+
const applied = misbehavior.kind === "applied" ? misbehavior : void 0;
|
|
711
|
+
const jsonOpts = () => ({
|
|
712
|
+
surface: "other",
|
|
713
|
+
payloadLength: applied ? misbehaviorPayloadLength(applied, void 0) : servedPayloadLength(response),
|
|
714
|
+
chunkSize,
|
|
715
|
+
recordedTimings: fixture.recordedTimings,
|
|
716
|
+
duplicateId: !!applied?.duplicateId,
|
|
717
|
+
replaySpeed
|
|
718
|
+
});
|
|
719
|
+
const markIncomplete = (body) => applied?.summary.fault === "stop-length-mid-tool" ? {
|
|
720
|
+
...body,
|
|
721
|
+
status: "incomplete"
|
|
722
|
+
} : body;
|
|
723
|
+
if (isRawResponse(response)) {
|
|
724
|
+
await serveRawResponse({
|
|
725
|
+
wire: "gemini-interactions",
|
|
726
|
+
stream: streaming,
|
|
727
|
+
req,
|
|
728
|
+
res,
|
|
729
|
+
fixture,
|
|
730
|
+
response,
|
|
731
|
+
body: completionReq,
|
|
732
|
+
journal,
|
|
733
|
+
defaults,
|
|
734
|
+
testId,
|
|
735
|
+
misbehaviorSummary: misbehavior.summary,
|
|
736
|
+
errorWire: "interactions"
|
|
737
|
+
});
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
710
740
|
if (isErrorResponse(response)) {
|
|
711
741
|
const status = response.status ?? 500;
|
|
712
742
|
recordMisbehaviorOutcome({
|
|
@@ -724,7 +754,10 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
724
754
|
defaults,
|
|
725
755
|
testId
|
|
726
756
|
});
|
|
727
|
-
writeErrorResponse(res, status,
|
|
757
|
+
writeErrorResponse(res, status, renderError("interactions", "fixture", {
|
|
758
|
+
message: response.error.message,
|
|
759
|
+
code: response.error.type ?? "ERROR"
|
|
760
|
+
}).body, { retryAfter: response.retryAfter });
|
|
728
761
|
return;
|
|
729
762
|
}
|
|
730
763
|
if (misbehavior.kind === "applied" && misbehavior.summary.fault === "reasoning-only") {
|
|
@@ -745,15 +778,11 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
745
778
|
testId
|
|
746
779
|
});
|
|
747
780
|
const interactionId = nextInteractionId();
|
|
748
|
-
const usage = {
|
|
749
|
-
...interactionsUsage({ usage: appliedUsage }),
|
|
750
|
-
total_output_tokens: 0,
|
|
751
|
-
total_thought_tokens: appliedUsage?.completion_tokens ?? 0
|
|
752
|
-
};
|
|
781
|
+
const usage = render({ usage: appliedUsage }, "applied-reasoning-only");
|
|
753
782
|
if (!streaming) {
|
|
754
783
|
const overrides = isTextResponse(response) || isToolCallResponse(response) || isCombinedFixtureResponse(response) ? extractOverrides(response) : void 0;
|
|
755
|
-
|
|
756
|
-
res
|
|
784
|
+
const reasoning = misbehavior.reasoning ?? "";
|
|
785
|
+
await deliverJson(res, journalEntry, fixture, () => ({
|
|
757
786
|
id: interactionId,
|
|
758
787
|
model: overrides?.model ?? model,
|
|
759
788
|
status: "incomplete",
|
|
@@ -762,14 +791,14 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
762
791
|
signature: "",
|
|
763
792
|
summary: [{
|
|
764
793
|
type: "text",
|
|
765
|
-
text:
|
|
794
|
+
text: reasoning
|
|
766
795
|
}]
|
|
767
796
|
}],
|
|
768
797
|
usage
|
|
769
|
-
}));
|
|
798
|
+
}), jsonOpts());
|
|
770
799
|
return;
|
|
771
800
|
}
|
|
772
|
-
|
|
801
|
+
await deliverStream(res, journalEntry, fixture, interactionsCodec, [
|
|
773
802
|
{
|
|
774
803
|
event_type: "interaction.created",
|
|
775
804
|
interaction: {
|
|
@@ -810,21 +839,7 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
810
839
|
},
|
|
811
840
|
event_id: nextEventId()
|
|
812
841
|
}
|
|
813
|
-
];
|
|
814
|
-
const interruption = createInterruptionSignal(fixture);
|
|
815
|
-
if (!await writeGeminiInteractionsSSEStream(res, events, {
|
|
816
|
-
latency,
|
|
817
|
-
streamingProfile: fixture.streamingProfile,
|
|
818
|
-
recordedTimings: fixture.recordedTimings,
|
|
819
|
-
replaySpeed,
|
|
820
|
-
signal: interruption?.signal,
|
|
821
|
-
onChunkSent: interruption?.tick
|
|
822
|
-
})) {
|
|
823
|
-
if (!res.writableEnded) res.destroy();
|
|
824
|
-
journalEntry.response.interrupted = true;
|
|
825
|
-
journalEntry.response.interruptReason = interruption?.reason();
|
|
826
|
-
}
|
|
827
|
-
interruption?.cleanup();
|
|
842
|
+
], streamTiming);
|
|
828
843
|
return;
|
|
829
844
|
}
|
|
830
845
|
if (isCombinedFixtureResponse(response)) {
|
|
@@ -852,29 +867,10 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
852
867
|
const functionToolCalls = requireEmittedFunctionToolCalls(response, "Gemini Interactions");
|
|
853
868
|
const interactionId = nextInteractionId();
|
|
854
869
|
if (!streaming) {
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
res
|
|
858
|
-
|
|
859
|
-
status: "incomplete"
|
|
860
|
-
} : body));
|
|
861
|
-
} else {
|
|
862
|
-
const events = buildInteractionsContentWithToolCallsSSEEvents(response.content ?? "", functionToolCalls, interactionId, chunkSize, logger, overrides, response.blocks);
|
|
863
|
-
const interruption = createInterruptionSignal(fixture);
|
|
864
|
-
if (!await writeGeminiInteractionsSSEStream(res, finalizeInteractionsMisbehavior(events, misbehavior), {
|
|
865
|
-
latency,
|
|
866
|
-
streamingProfile: fixture.streamingProfile,
|
|
867
|
-
recordedTimings: fixture.recordedTimings,
|
|
868
|
-
replaySpeed,
|
|
869
|
-
signal: interruption?.signal,
|
|
870
|
-
onChunkSent: interruption?.tick
|
|
871
|
-
})) {
|
|
872
|
-
if (!res.writableEnded) res.destroy();
|
|
873
|
-
journalEntry.response.interrupted = true;
|
|
874
|
-
journalEntry.response.interruptReason = interruption?.reason();
|
|
875
|
-
}
|
|
876
|
-
interruption?.cleanup();
|
|
877
|
-
}
|
|
870
|
+
const content = response.content ?? "";
|
|
871
|
+
const blocks = response.blocks;
|
|
872
|
+
await deliverJson(res, journalEntry, fixture, () => markIncomplete(buildInteractionsContentWithToolCallsResponse(content, functionToolCalls, model, interactionId, logger, overrides, blocks)), jsonOpts());
|
|
873
|
+
} else await deliverStream(res, journalEntry, fixture, interactionsCodec, finalizeInteractionsMisbehavior(buildInteractionsContentWithToolCallsSSEEvents(response.content ?? "", functionToolCalls, interactionId, chunkSize, logger, overrides, response.blocks), misbehavior), streamTiming);
|
|
878
874
|
return;
|
|
879
875
|
}
|
|
880
876
|
if (isTextResponse(response)) {
|
|
@@ -901,29 +897,9 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
901
897
|
});
|
|
902
898
|
const interactionId = nextInteractionId();
|
|
903
899
|
if (!streaming) {
|
|
904
|
-
const
|
|
905
|
-
res
|
|
906
|
-
|
|
907
|
-
...body,
|
|
908
|
-
status: "incomplete"
|
|
909
|
-
} : body));
|
|
910
|
-
} else {
|
|
911
|
-
const events = buildInteractionsTextSSEEvents(response.content, interactionId, chunkSize, overrides);
|
|
912
|
-
const interruption = createInterruptionSignal(fixture);
|
|
913
|
-
if (!await writeGeminiInteractionsSSEStream(res, finalizeInteractionsMisbehavior(events, misbehavior), {
|
|
914
|
-
latency,
|
|
915
|
-
streamingProfile: fixture.streamingProfile,
|
|
916
|
-
recordedTimings: fixture.recordedTimings,
|
|
917
|
-
replaySpeed,
|
|
918
|
-
signal: interruption?.signal,
|
|
919
|
-
onChunkSent: interruption?.tick
|
|
920
|
-
})) {
|
|
921
|
-
if (!res.writableEnded) res.destroy();
|
|
922
|
-
journalEntry.response.interrupted = true;
|
|
923
|
-
journalEntry.response.interruptReason = interruption?.reason();
|
|
924
|
-
}
|
|
925
|
-
interruption?.cleanup();
|
|
926
|
-
}
|
|
900
|
+
const content = response.content;
|
|
901
|
+
await deliverJson(res, journalEntry, fixture, () => markIncomplete(buildInteractionsTextResponse(content, model, interactionId, overrides)), jsonOpts());
|
|
902
|
+
} else await deliverStream(res, journalEntry, fixture, interactionsCodec, finalizeInteractionsMisbehavior(buildInteractionsTextSSEEvents(response.content, interactionId, chunkSize, overrides), misbehavior), streamTiming);
|
|
927
903
|
return;
|
|
928
904
|
}
|
|
929
905
|
if (isToolCallResponse(response)) {
|
|
@@ -950,30 +926,8 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
950
926
|
});
|
|
951
927
|
const functionToolCalls = requireEmittedFunctionToolCalls(response, "Gemini Interactions");
|
|
952
928
|
const interactionId = nextInteractionId();
|
|
953
|
-
if (!streaming)
|
|
954
|
-
|
|
955
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
956
|
-
res.end(JSON.stringify(misbehavior.kind === "applied" && misbehavior.summary.fault === "stop-length-mid-tool" ? {
|
|
957
|
-
...body,
|
|
958
|
-
status: "incomplete"
|
|
959
|
-
} : body));
|
|
960
|
-
} else {
|
|
961
|
-
const events = buildInteractionsToolCallSSEEvents(functionToolCalls, interactionId, logger, overrides);
|
|
962
|
-
const interruption = createInterruptionSignal(fixture);
|
|
963
|
-
if (!await writeGeminiInteractionsSSEStream(res, finalizeInteractionsMisbehavior(events, misbehavior), {
|
|
964
|
-
latency,
|
|
965
|
-
streamingProfile: fixture.streamingProfile,
|
|
966
|
-
recordedTimings: fixture.recordedTimings,
|
|
967
|
-
replaySpeed,
|
|
968
|
-
signal: interruption?.signal,
|
|
969
|
-
onChunkSent: interruption?.tick
|
|
970
|
-
})) {
|
|
971
|
-
if (!res.writableEnded) res.destroy();
|
|
972
|
-
journalEntry.response.interrupted = true;
|
|
973
|
-
journalEntry.response.interruptReason = interruption?.reason();
|
|
974
|
-
}
|
|
975
|
-
interruption?.cleanup();
|
|
976
|
-
}
|
|
929
|
+
if (!streaming) await deliverJson(res, journalEntry, fixture, () => markIncomplete(buildInteractionsToolCallResponse(functionToolCalls, model, interactionId, logger, overrides)), jsonOpts());
|
|
930
|
+
else await deliverStream(res, journalEntry, fixture, interactionsCodec, finalizeInteractionsMisbehavior(buildInteractionsToolCallSSEEvents(functionToolCalls, interactionId, logger, overrides), misbehavior), streamTiming);
|
|
977
931
|
return;
|
|
978
932
|
}
|
|
979
933
|
recordMisbehaviorOutcome({
|
|
@@ -991,7 +945,10 @@ async function handleGeminiInteractions(req, res, raw, fixtures, journal, defaul
|
|
|
991
945
|
defaults,
|
|
992
946
|
testId
|
|
993
947
|
});
|
|
994
|
-
writeErrorResponse(res, 500,
|
|
948
|
+
writeErrorResponse(res, 500, renderError("interactions", "unknown-response", {
|
|
949
|
+
message: "Fixture response did not match any known type",
|
|
950
|
+
code: "INTERNAL"
|
|
951
|
+
}).body);
|
|
995
952
|
}
|
|
996
953
|
|
|
997
954
|
//#endregion
|