@copilotkit/aimock 1.45.0 → 1.46.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 +24 -0
- package/README.md +7 -1
- 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.ts.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/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 +61 -80
- 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 +58 -77
- package/dist/bedrock-converse.js.map +1 -1
- package/dist/bedrock.cjs +65 -97
- 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 +62 -94
- 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 +49 -74
- 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 +47 -72
- 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 +37 -42
- 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 +37 -42
- 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 +50 -35
- 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 +49 -34
- package/dist/gemini-interactions.js.map +1 -1
- package/dist/gemini.cjs +57 -67
- 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 +56 -67
- 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 +11 -68
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +12 -67
- 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.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- 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 +14 -4
- package/dist/mcp-handler.cjs.map +1 -1
- package/dist/mcp-handler.js +14 -4
- 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 +111 -96
- 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 +109 -95
- 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/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/ollama.cjs +128 -68
- 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 +124 -64
- 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 +76 -71
- 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 +63 -58
- package/dist/openrouter-video.js.map +1 -1
- 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/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/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/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 +45 -58
- 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 +44 -57
- 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 +4 -0
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +3 -0
- 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 +222 -146
- 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 +223 -147
- 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 +7 -0
- package/dist/sse-writer.cjs.map +1 -1
- package/dist/sse-writer.d.cts.map +1 -1
- package/dist/sse-writer.d.ts.map +1 -1
- package/dist/sse-writer.js +7 -1
- 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 +12 -10
- 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 +11 -9
- package/dist/transcription.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +62 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +62 -3
- 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-gemini-live.cjs +11 -3
- 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 +10 -2
- 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 +28 -54
- 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 +25 -51
- package/dist/ws-realtime.js.map +1 -1
- package/dist/ws-responses.cjs +8 -6
- package/dist/ws-responses.cjs.map +1 -1
- package/dist/ws-responses.js +7 -5
- package/dist/ws-responses.js.map +1 -1
- package/package.json +4 -1
- package/skills/write-fixtures/SKILL.md +25 -16
package/dist/responses.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { renderError } from "./response/errors.js";
|
|
1
2
|
import { isReasoningModel } from "./model-utils.js";
|
|
2
|
-
import {
|
|
3
|
+
import { resolveRequestDecisions, strictOverrideField } from "./response/policy.js";
|
|
4
|
+
import { assertCustomToolCalls, assertResponsesToolCalls, extractOverrides, flattenHeaders, generateId, generateToolCallId, getContext, getTestId, isCombinedFixtureResponse, isErrorResponse, isJsonObject, isTextResponse, isToolCallResponse, prepareOpenAIChatMisbehavior, resolveFixtureBlocks, resolveOpenAIChatMisbehaviorUsage, resolveReasoningForModel, resolveResponse, resolveServedBlockOutcome, serializeErrorResponse, servedToolCalls, strictNoMatchLogLine, strictNoMatchMessage, toolCallFixtureBlock, withoutLegacyNamespaces } from "./helpers.js";
|
|
3
5
|
import { calculateDelay, delay, writeErrorResponse } from "./sse-writer.js";
|
|
4
6
|
import { applyChaosAsync } from "./chaos.js";
|
|
5
7
|
import { planMisbehavior, recordMisbehaviorOutcome } from "./misbehavior.js";
|
|
6
8
|
import { matchFixtureDiagnostic, recordMatchOptions, setResponsesOfferedTools } from "./router.js";
|
|
7
9
|
import { proxyAndRecord } from "./recorder.js";
|
|
8
10
|
import { createInterruptionSignal } from "./interruption.js";
|
|
11
|
+
import { render } from "./response/usage/codecs/responses.js";
|
|
12
|
+
import { mapResponsesFinish } from "./response/finish.js";
|
|
9
13
|
import { randomBytes } from "node:crypto";
|
|
10
14
|
|
|
11
15
|
//#region src/responses.ts
|
|
@@ -310,25 +314,7 @@ function validateResponsesTools(tools) {
|
|
|
310
314
|
}
|
|
311
315
|
function responsesStatus(finishReason, defaultStatus) {
|
|
312
316
|
if (!finishReason) return defaultStatus;
|
|
313
|
-
|
|
314
|
-
if (finishReason === "tool_calls") return "completed";
|
|
315
|
-
if (finishReason === "length") return "incomplete";
|
|
316
|
-
if (finishReason === "content_filter") return "failed";
|
|
317
|
-
return finishReason;
|
|
318
|
-
}
|
|
319
|
-
function responsesUsage(overrides) {
|
|
320
|
-
if (!overrides?.usage) return {
|
|
321
|
-
input_tokens: 0,
|
|
322
|
-
output_tokens: 0,
|
|
323
|
-
total_tokens: 0
|
|
324
|
-
};
|
|
325
|
-
const input = overrides.usage.input_tokens ?? overrides.usage.prompt_tokens ?? 0;
|
|
326
|
-
const output = overrides.usage.output_tokens ?? overrides.usage.completion_tokens ?? 0;
|
|
327
|
-
return {
|
|
328
|
-
input_tokens: input,
|
|
329
|
-
output_tokens: output,
|
|
330
|
-
total_tokens: overrides.usage.total_tokens ?? input + output
|
|
331
|
-
};
|
|
317
|
+
return mapResponsesFinish(finishReason);
|
|
332
318
|
}
|
|
333
319
|
function responseId() {
|
|
334
320
|
return generateId("resp");
|
|
@@ -338,7 +324,7 @@ function itemId() {
|
|
|
338
324
|
}
|
|
339
325
|
function buildTextStreamEvents(content, model, chunkSize, reasoning, webSearches, overrides, emitEncryptedReasoning = false, synthesizeSummarylessReasoning = false) {
|
|
340
326
|
const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(model, chunkSize, reasoning, webSearches, overrides, emitEncryptedReasoning, synthesizeSummarylessReasoning);
|
|
341
|
-
const { events: msgEvents, msgItem } = buildMessageOutputEvents(content, chunkSize, nextOutputIndex);
|
|
327
|
+
const { events: msgEvents, msgItem } = buildMessageOutputEvents(content, chunkSize, nextOutputIndex, overrides?.phase);
|
|
342
328
|
events.push(...msgEvents);
|
|
343
329
|
events.push({
|
|
344
330
|
type: "response.completed",
|
|
@@ -349,7 +335,7 @@ function buildTextStreamEvents(content, model, chunkSize, reasoning, webSearches
|
|
|
349
335
|
model: overrides?.model ?? model,
|
|
350
336
|
status: responsesStatus(overrides?.finishReason, "completed"),
|
|
351
337
|
output: [...prefixOutputItems, msgItem],
|
|
352
|
-
usage:
|
|
338
|
+
usage: render(overrides)
|
|
353
339
|
}
|
|
354
340
|
});
|
|
355
341
|
return events;
|
|
@@ -463,7 +449,7 @@ function toolCallStreamEvents(toolCalls, model, chunkSize, reasoning, webSearche
|
|
|
463
449
|
model: overrides?.model ?? model,
|
|
464
450
|
status: responsesStatus(overrides?.finishReason, "completed"),
|
|
465
451
|
output: [...prefixOutputItems, ...fcOutputItems],
|
|
466
|
-
usage:
|
|
452
|
+
usage: render(overrides)
|
|
467
453
|
}
|
|
468
454
|
});
|
|
469
455
|
return events;
|
|
@@ -734,7 +720,7 @@ function buildResponsePreamble(model, chunkSize, reasoning, webSearches, overrid
|
|
|
734
720
|
nextOutputIndex
|
|
735
721
|
};
|
|
736
722
|
}
|
|
737
|
-
function buildMessageOutputEvents(content, chunkSize, outputIndex) {
|
|
723
|
+
function buildMessageOutputEvents(content, chunkSize, outputIndex, phase) {
|
|
738
724
|
const msgId = itemId();
|
|
739
725
|
const events = [];
|
|
740
726
|
events.push({
|
|
@@ -745,6 +731,7 @@ function buildMessageOutputEvents(content, chunkSize, outputIndex) {
|
|
|
745
731
|
id: msgId,
|
|
746
732
|
status: "in_progress",
|
|
747
733
|
role: "assistant",
|
|
734
|
+
...phase !== void 0 ? { phase } : {},
|
|
748
735
|
content: []
|
|
749
736
|
}
|
|
750
737
|
});
|
|
@@ -789,6 +776,7 @@ function buildMessageOutputEvents(content, chunkSize, outputIndex) {
|
|
|
789
776
|
id: msgId,
|
|
790
777
|
status: "completed",
|
|
791
778
|
role: "assistant",
|
|
779
|
+
...phase !== void 0 ? { phase } : {},
|
|
792
780
|
content: [{
|
|
793
781
|
type: "output_text",
|
|
794
782
|
text: content,
|
|
@@ -907,7 +895,7 @@ function buildCustomToolCallOutputEvents(call, chunkSize, outputIndex) {
|
|
|
907
895
|
function buildToolCallOutputEvents(call, chunkSize, outputIndex) {
|
|
908
896
|
return isCustomEmittable(call) ? buildCustomToolCallOutputEvents(call, chunkSize, outputIndex) : buildFunctionCallOutputEvents(call, chunkSize, outputIndex);
|
|
909
897
|
}
|
|
910
|
-
function buildOutputPrefix(content, model, reasoning, webSearches, emitEncryptedReasoning = false, synthesizeSummarylessReasoning = false) {
|
|
898
|
+
function buildOutputPrefix(content, model, reasoning, webSearches, emitEncryptedReasoning = false, synthesizeSummarylessReasoning = false, phase) {
|
|
911
899
|
const output = [];
|
|
912
900
|
if (reasoning || shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)) output.push(buildReasoningOutputItem(generateId("rs"), {
|
|
913
901
|
summaryText: reasoning,
|
|
@@ -927,6 +915,7 @@ function buildOutputPrefix(content, model, reasoning, webSearches, emitEncrypted
|
|
|
927
915
|
id: itemId(),
|
|
928
916
|
status: "completed",
|
|
929
917
|
role: "assistant",
|
|
918
|
+
...phase !== void 0 ? { phase } : {},
|
|
930
919
|
content: [{
|
|
931
920
|
type: "output_text",
|
|
932
921
|
text: content,
|
|
@@ -943,11 +932,11 @@ function buildResponseEnvelope(model, output, overrides) {
|
|
|
943
932
|
model: overrides?.model ?? model,
|
|
944
933
|
status: responsesStatus(overrides?.finishReason, "completed"),
|
|
945
934
|
output,
|
|
946
|
-
usage:
|
|
935
|
+
usage: render(overrides)
|
|
947
936
|
};
|
|
948
937
|
}
|
|
949
938
|
function buildTextResponse(content, model, reasoning, webSearches, overrides, emitEncryptedReasoning = false, synthesizeSummarylessReasoning = false) {
|
|
950
|
-
return buildResponseEnvelope(model, buildOutputPrefix(content, model, reasoning, webSearches, emitEncryptedReasoning, synthesizeSummarylessReasoning), overrides);
|
|
939
|
+
return buildResponseEnvelope(model, buildOutputPrefix(content, model, reasoning, webSearches, emitEncryptedReasoning, synthesizeSummarylessReasoning, overrides?.phase), overrides);
|
|
951
940
|
}
|
|
952
941
|
function buildToolCallResponse(toolCalls, model, reasoning, webSearches, overrides, emitEncryptedReasoning = false, synthesizeSummarylessReasoning = false) {
|
|
953
942
|
assertResponsesToolCalls(toolCalls);
|
|
@@ -984,7 +973,7 @@ function contentWithToolCallsStreamEvents(content, toolCalls, model, chunkSize,
|
|
|
984
973
|
let outputIndex = nextOutputIndex;
|
|
985
974
|
for (const block of ordered) {
|
|
986
975
|
if (block.type === "text") {
|
|
987
|
-
const { events: msgEvents, msgItem } = buildMessageOutputEvents(block.text, chunkSize, outputIndex);
|
|
976
|
+
const { events: msgEvents, msgItem } = buildMessageOutputEvents(block.text, chunkSize, outputIndex, overrides?.phase);
|
|
988
977
|
events.push(...msgEvents);
|
|
989
978
|
orderedOutputItems.push(msgItem);
|
|
990
979
|
} else {
|
|
@@ -996,7 +985,7 @@ function contentWithToolCallsStreamEvents(content, toolCalls, model, chunkSize,
|
|
|
996
985
|
}
|
|
997
986
|
} else {
|
|
998
987
|
assertResponsesToolCalls(toolCalls);
|
|
999
|
-
const { events: msgEvents, msgItem } = buildMessageOutputEvents(content, chunkSize, nextOutputIndex);
|
|
988
|
+
const { events: msgEvents, msgItem } = buildMessageOutputEvents(content, chunkSize, nextOutputIndex, overrides?.phase);
|
|
1000
989
|
events.push(...msgEvents);
|
|
1001
990
|
orderedOutputItems.push(msgItem);
|
|
1002
991
|
for (let idx = 0; idx < toolCalls.length; idx++) {
|
|
@@ -1014,7 +1003,7 @@ function contentWithToolCallsStreamEvents(content, toolCalls, model, chunkSize,
|
|
|
1014
1003
|
model: overrides?.model ?? model,
|
|
1015
1004
|
status: responsesStatus(overrides?.finishReason, "completed"),
|
|
1016
1005
|
output: [...prefixOutputItems, ...orderedOutputItems],
|
|
1017
|
-
usage:
|
|
1006
|
+
usage: render(overrides)
|
|
1018
1007
|
}
|
|
1019
1008
|
});
|
|
1020
1009
|
return events;
|
|
@@ -1024,12 +1013,13 @@ function buildToolCallOutputItem(tc) {
|
|
|
1024
1013
|
if (isCustomEmittable(tc)) return customToolCallItem(tc, customToolCallItemId(), tc.id || generateToolCallId(), requireFixtureToolInput(tc.input), "completed");
|
|
1025
1014
|
return functionCallItem(tc, generateId("fc"), tc.id || generateToolCallId(), requireFixtureToolArguments(tc.arguments), "completed");
|
|
1026
1015
|
}
|
|
1027
|
-
function buildMessageOutputItem(content) {
|
|
1016
|
+
function buildMessageOutputItem(content, phase) {
|
|
1028
1017
|
return {
|
|
1029
1018
|
type: "message",
|
|
1030
1019
|
id: itemId(),
|
|
1031
1020
|
status: "completed",
|
|
1032
1021
|
role: "assistant",
|
|
1022
|
+
...phase !== void 0 ? { phase } : {},
|
|
1033
1023
|
content: [{
|
|
1034
1024
|
type: "output_text",
|
|
1035
1025
|
text: content,
|
|
@@ -1053,12 +1043,12 @@ function buildContentWithToolCallsResponse(content, toolCalls, model, reasoning,
|
|
|
1053
1043
|
query
|
|
1054
1044
|
}
|
|
1055
1045
|
});
|
|
1056
|
-
for (const block of ordered) if (block.type === "text") output.push(buildMessageOutputItem(block.text));
|
|
1046
|
+
for (const block of ordered) if (block.type === "text") output.push(buildMessageOutputItem(block.text, overrides?.phase));
|
|
1057
1047
|
else output.push(buildToolCallOutputItem(block));
|
|
1058
1048
|
return buildResponseEnvelope(model, output, overrides);
|
|
1059
1049
|
}
|
|
1060
1050
|
assertResponsesToolCalls(toolCalls);
|
|
1061
|
-
const output = buildOutputPrefix(content, model, reasoning, webSearches, emitEncryptedReasoning, synthesizeSummarylessReasoning);
|
|
1051
|
+
const output = buildOutputPrefix(content, model, reasoning, webSearches, emitEncryptedReasoning, synthesizeSummarylessReasoning, overrides?.phase);
|
|
1062
1052
|
for (const tc of toolCalls) output.push(buildToolCallOutputItem(tc));
|
|
1063
1053
|
return buildResponseEnvelope(model, output, overrides);
|
|
1064
1054
|
}
|
|
@@ -1104,11 +1094,11 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1104
1094
|
fixture: null
|
|
1105
1095
|
}
|
|
1106
1096
|
});
|
|
1107
|
-
writeErrorResponse(res, 400,
|
|
1097
|
+
writeErrorResponse(res, 400, renderError("openai", "validation", {
|
|
1108
1098
|
message: `Malformed JSON: ${detail}`,
|
|
1109
1099
|
type: "invalid_request_error",
|
|
1110
1100
|
code: "invalid_json"
|
|
1111
|
-
}
|
|
1101
|
+
}).body);
|
|
1112
1102
|
return;
|
|
1113
1103
|
}
|
|
1114
1104
|
if (!isJsonObject(responsesReq)) {
|
|
@@ -1122,10 +1112,10 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1122
1112
|
fixture: null
|
|
1123
1113
|
}
|
|
1124
1114
|
});
|
|
1125
|
-
writeErrorResponse(res, 400,
|
|
1115
|
+
writeErrorResponse(res, 400, renderError("openai", "validation", {
|
|
1126
1116
|
message: "Request body must be a JSON object",
|
|
1127
1117
|
type: "invalid_request_error"
|
|
1128
|
-
}
|
|
1118
|
+
}).body);
|
|
1129
1119
|
return;
|
|
1130
1120
|
}
|
|
1131
1121
|
let inputError;
|
|
@@ -1152,10 +1142,10 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1152
1142
|
fixture: null
|
|
1153
1143
|
}
|
|
1154
1144
|
});
|
|
1155
|
-
writeErrorResponse(res, 400,
|
|
1145
|
+
writeErrorResponse(res, 400, renderError("openai", "validation", {
|
|
1156
1146
|
message: validationError,
|
|
1157
1147
|
type: "invalid_request_error"
|
|
1158
|
-
}
|
|
1148
|
+
}).body);
|
|
1159
1149
|
return;
|
|
1160
1150
|
}
|
|
1161
1151
|
const extendedTools = defaults.responsesTools === "extended";
|
|
@@ -1180,7 +1170,7 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1180
1170
|
body: completionReq
|
|
1181
1171
|
}, fixture ? "fixture" : "proxy", defaults.registry, defaults.logger)) return;
|
|
1182
1172
|
if (!fixture) {
|
|
1183
|
-
if (
|
|
1173
|
+
if (resolveRequestDecisions(defaults.strict, req.headers).fixtureMiss) {
|
|
1184
1174
|
const strictStatus = 503;
|
|
1185
1175
|
const strictMessage = strictNoMatchMessage(skippedBySequenceOrTurn);
|
|
1186
1176
|
defaults.logger.error(strictNoMatchLogLine(req.method ?? "POST", req.url ?? "/v1/responses", skippedBySequenceOrTurn));
|
|
@@ -1195,11 +1185,11 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1195
1185
|
...strictOverrideField(defaults.strict, req.headers)
|
|
1196
1186
|
}
|
|
1197
1187
|
});
|
|
1198
|
-
writeErrorResponse(res, strictStatus,
|
|
1188
|
+
writeErrorResponse(res, strictStatus, renderError("openai", "strict-miss", {
|
|
1199
1189
|
message: strictMessage,
|
|
1200
1190
|
type: "invalid_request_error",
|
|
1201
1191
|
code: "no_fixture_match"
|
|
1202
|
-
}
|
|
1192
|
+
}).body);
|
|
1203
1193
|
return;
|
|
1204
1194
|
}
|
|
1205
1195
|
if (defaults.record) {
|
|
@@ -1231,11 +1221,11 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1231
1221
|
...strictOverrideField(defaults.strict, req.headers)
|
|
1232
1222
|
}
|
|
1233
1223
|
});
|
|
1234
|
-
writeErrorResponse(res, 404,
|
|
1224
|
+
writeErrorResponse(res, 404, renderError("openai", "fixture-miss", {
|
|
1235
1225
|
message: "No fixture matched",
|
|
1236
1226
|
type: "invalid_request_error",
|
|
1237
1227
|
code: "no_fixture_match"
|
|
1238
|
-
}
|
|
1228
|
+
}).body);
|
|
1239
1229
|
return;
|
|
1240
1230
|
}
|
|
1241
1231
|
const resolvedResponse = await resolveResponse(fixture, completionReq);
|
|
@@ -1268,11 +1258,11 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1268
1258
|
testId
|
|
1269
1259
|
});
|
|
1270
1260
|
if (!misbehavior.summary?.evaluations.some((evaluation) => evaluation.outcome === "error")) defaults.logger.error(misbehavior.message);
|
|
1271
|
-
writeErrorResponse(res, misbehavior.status,
|
|
1261
|
+
writeErrorResponse(res, misbehavior.status, renderError("openai", "misbehavior", {
|
|
1272
1262
|
message: misbehavior.message,
|
|
1273
1263
|
type: "invalid_request_error",
|
|
1274
1264
|
code: misbehavior.code
|
|
1275
|
-
}
|
|
1265
|
+
}).body);
|
|
1276
1266
|
return;
|
|
1277
1267
|
}
|
|
1278
1268
|
const latency = fixture.latency ?? defaults.latency;
|
|
@@ -1349,7 +1339,7 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1349
1339
|
}
|
|
1350
1340
|
if (isCombinedFixtureResponse(response)) {
|
|
1351
1341
|
const overrides = extractOverrides(response);
|
|
1352
|
-
const effectiveStrict =
|
|
1342
|
+
const effectiveStrict = resolveRequestDecisions(defaults.strict, req.headers).reasoningSuppression;
|
|
1353
1343
|
const effReasoning = resolveReasoningForModel(response.reasoning, completionReq.model, effectiveStrict, defaults.logger);
|
|
1354
1344
|
const journalEntry = journal.add({
|
|
1355
1345
|
method: req.method ?? "POST",
|
|
@@ -1395,7 +1385,7 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1395
1385
|
}
|
|
1396
1386
|
if (isTextResponse(response)) {
|
|
1397
1387
|
const overrides = extractOverrides(response);
|
|
1398
|
-
const effectiveStrict =
|
|
1388
|
+
const effectiveStrict = resolveRequestDecisions(defaults.strict, req.headers).reasoningSuppression;
|
|
1399
1389
|
const effReasoning = resolveReasoningForModel(response.reasoning, completionReq.model, effectiveStrict, defaults.logger);
|
|
1400
1390
|
const journalEntry = journal.add({
|
|
1401
1391
|
method: req.method ?? "POST",
|
|
@@ -1438,7 +1428,7 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1438
1428
|
}
|
|
1439
1429
|
if (isToolCallResponse(response)) {
|
|
1440
1430
|
const overrides = extractOverrides(response);
|
|
1441
|
-
const effectiveStrict =
|
|
1431
|
+
const effectiveStrict = resolveRequestDecisions(defaults.strict, req.headers).reasoningSuppression;
|
|
1442
1432
|
const effReasoning = resolveReasoningForModel(response.reasoning, completionReq.model, effectiveStrict, defaults.logger);
|
|
1443
1433
|
const journalEntry = journal.add({
|
|
1444
1434
|
method: req.method ?? "POST",
|
|
@@ -1495,10 +1485,10 @@ async function handleResponses(req, res, raw, fixtures, journal, defaults, setCo
|
|
|
1495
1485
|
defaults,
|
|
1496
1486
|
testId
|
|
1497
1487
|
});
|
|
1498
|
-
writeErrorResponse(res, 500,
|
|
1488
|
+
writeErrorResponse(res, 500, renderError("openai", "unknown-response", {
|
|
1499
1489
|
message: "Fixture response did not match any known type",
|
|
1500
1490
|
type: "server_error"
|
|
1501
|
-
}
|
|
1491
|
+
}).body);
|
|
1502
1492
|
}
|
|
1503
1493
|
/** Prepare call IDs once, retaining the engine's effective blocks and exact served-call metadata. */
|
|
1504
1494
|
function prepareResponsesMisbehavior(plan) {
|
|
@@ -1526,6 +1516,7 @@ function buildResponsesMisbehavior(plan, request, chunkSize, emitEncryptedReason
|
|
|
1526
1516
|
type: "message",
|
|
1527
1517
|
role: "assistant",
|
|
1528
1518
|
status: "completed",
|
|
1519
|
+
...overrides.phase !== void 0 ? { phase: overrides.phase } : {},
|
|
1529
1520
|
content: [part]
|
|
1530
1521
|
};
|
|
1531
1522
|
const position = {
|
|
@@ -1577,7 +1568,7 @@ function buildResponsesMisbehavior(plan, request, chunkSize, emitEncryptedReason
|
|
|
1577
1568
|
let callIndex = 0;
|
|
1578
1569
|
for (const block of blocks) {
|
|
1579
1570
|
if (block.type === "text") {
|
|
1580
|
-
const message = buildMessageOutputEvents(block.text, chunkSize, outputIndex);
|
|
1571
|
+
const message = buildMessageOutputEvents(block.text, chunkSize, outputIndex, overrides.phase);
|
|
1581
1572
|
events.push(...message.events);
|
|
1582
1573
|
output.push(message.msgItem);
|
|
1583
1574
|
} else {
|
|
@@ -1606,11 +1597,7 @@ function buildResponsesMisbehavior(plan, request, chunkSize, emitEncryptedReason
|
|
|
1606
1597
|
status: incomplete ? "incomplete" : responsesStatus(overrides?.finishReason, "completed"),
|
|
1607
1598
|
...incomplete ? { incomplete_details: { reason: plan.stop === "content_filter" ? "content_filter" : "max_output_tokens" } } : {},
|
|
1608
1599
|
output,
|
|
1609
|
-
usage: {
|
|
1610
|
-
input_tokens: usage.prompt_tokens,
|
|
1611
|
-
output_tokens: usage.completion_tokens,
|
|
1612
|
-
total_tokens: usage.total_tokens
|
|
1613
|
-
}
|
|
1600
|
+
usage: render({ usage })
|
|
1614
1601
|
};
|
|
1615
1602
|
events.push({
|
|
1616
1603
|
type: incomplete ? "response.incomplete" : "response.completed",
|