@copilotkit/aimock 1.42.1 → 1.44.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 +65 -0
- package/README.md +108 -16
- package/dist/agui-handler.d.ts.map +1 -1
- package/dist/agui-mock.cjs +1 -1
- 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 +1 -1
- package/dist/agui-mock.js.map +1 -1
- package/dist/agui-recorder.cjs +33 -11
- package/dist/agui-recorder.cjs.map +1 -1
- package/dist/agui-recorder.d.cts +10 -1
- package/dist/agui-recorder.d.cts.map +1 -1
- package/dist/agui-recorder.d.ts +10 -1
- package/dist/agui-recorder.d.ts.map +1 -1
- package/dist/agui-recorder.js +33 -11
- package/dist/agui-recorder.js.map +1 -1
- package/dist/agui-types.d.cts +1 -0
- package/dist/agui-types.d.cts.map +1 -1
- package/dist/agui-types.d.ts +1 -0
- package/dist/agui-types.d.ts.map +1 -1
- package/dist/aimock-cli.cjs +38 -10
- package/dist/aimock-cli.cjs.map +1 -1
- package/dist/aimock-cli.d.cts +5 -0
- package/dist/aimock-cli.d.cts.map +1 -1
- package/dist/aimock-cli.d.ts +5 -0
- package/dist/aimock-cli.d.ts.map +1 -1
- package/dist/aimock-cli.js +38 -10
- package/dist/aimock-cli.js.map +1 -1
- package/dist/batches.cjs +458 -0
- package/dist/batches.cjs.map +1 -0
- package/dist/batches.d.cts +57 -0
- package/dist/batches.d.cts.map +1 -0
- package/dist/batches.d.ts +57 -0
- package/dist/batches.d.ts.map +1 -0
- package/dist/batches.js +453 -0
- package/dist/batches.js.map +1 -0
- package/dist/bedrock-converse.cjs +44 -12
- 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 +46 -14
- package/dist/bedrock-converse.js.map +1 -1
- package/dist/bedrock.cjs +10 -8
- 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 +12 -10
- package/dist/bedrock.js.map +1 -1
- package/dist/byteplus-video.cjs +3 -3
- package/dist/byteplus-video.cjs.map +1 -1
- package/dist/byteplus-video.js +4 -4
- package/dist/byteplus-video.js.map +1 -1
- package/dist/chaos.cjs +625 -72
- package/dist/chaos.cjs.map +1 -1
- package/dist/chaos.d.cts +164 -7
- package/dist/chaos.d.cts.map +1 -1
- package/dist/chaos.d.ts +164 -7
- package/dist/chaos.d.ts.map +1 -1
- package/dist/chaos.js +616 -74
- package/dist/chaos.js.map +1 -1
- package/dist/cli.cjs +131 -30
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +132 -31
- package/dist/cli.js.map +1 -1
- package/dist/cohere.cjs +37 -9
- 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 +39 -11
- package/dist/cohere.js.map +1 -1
- package/dist/config-loader.cjs +1 -1
- package/dist/config-loader.js +1 -1
- package/dist/constants.cjs +8 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +6 -2
- package/dist/constants.d.ts +6 -2
- package/dist/constants.js +8 -1
- package/dist/constants.js.map +1 -1
- package/dist/convert.cjs +1 -1
- package/dist/convert.cjs.map +1 -1
- package/dist/convert.js +1 -1
- package/dist/convert.js.map +1 -1
- package/dist/echo-text.cjs +65 -0
- package/dist/echo-text.cjs.map +1 -0
- package/dist/echo-text.d.cts +22 -0
- package/dist/echo-text.d.cts.map +1 -0
- package/dist/echo-text.d.ts +22 -0
- package/dist/echo-text.d.ts.map +1 -0
- package/dist/echo-text.js +65 -0
- package/dist/echo-text.js.map +1 -0
- package/dist/elevenlabs-audio.cjs +3 -3
- package/dist/elevenlabs-audio.cjs.map +1 -1
- package/dist/elevenlabs-audio.js +4 -4
- package/dist/elevenlabs-audio.js.map +1 -1
- package/dist/elevenlabs-voice.cjs +1053 -0
- package/dist/elevenlabs-voice.cjs.map +1 -0
- package/dist/elevenlabs-voice.d.cts +72 -0
- package/dist/elevenlabs-voice.d.cts.map +1 -0
- package/dist/elevenlabs-voice.d.ts +72 -0
- package/dist/elevenlabs-voice.d.ts.map +1 -0
- package/dist/elevenlabs-voice.js +1048 -0
- package/dist/elevenlabs-voice.js.map +1 -0
- package/dist/embeddings.cjs +26 -5
- package/dist/embeddings.cjs.map +1 -1
- package/dist/embeddings.d.cts +1 -1
- package/dist/embeddings.d.cts.map +1 -1
- package/dist/embeddings.d.ts +1 -1
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/embeddings.js +27 -6
- package/dist/embeddings.js.map +1 -1
- package/dist/fal-audio.cjs +3 -3
- package/dist/fal-audio.cjs.map +1 -1
- package/dist/fal-audio.js +4 -4
- package/dist/fal-audio.js.map +1 -1
- package/dist/fal.cjs +28 -4
- package/dist/fal.cjs.map +1 -1
- package/dist/fal.d.cts +16 -1
- package/dist/fal.d.cts.map +1 -1
- package/dist/fal.d.ts +16 -1
- package/dist/fal.d.ts.map +1 -1
- package/dist/fal.js +28 -5
- package/dist/fal.js.map +1 -1
- package/dist/files.cjs +1069 -0
- package/dist/files.cjs.map +1 -0
- package/dist/files.d.cts +68 -0
- package/dist/files.d.cts.map +1 -0
- package/dist/files.d.ts +68 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +1056 -0
- package/dist/files.js.map +1 -0
- package/dist/fine-tuning.cjs +1033 -0
- package/dist/fine-tuning.cjs.map +1 -0
- package/dist/fine-tuning.d.cts +96 -0
- package/dist/fine-tuning.d.cts.map +1 -0
- package/dist/fine-tuning.d.ts +96 -0
- package/dist/fine-tuning.d.ts.map +1 -0
- package/dist/fine-tuning.js +1026 -0
- package/dist/fine-tuning.js.map +1 -0
- package/dist/fixture-loader-services.cjs +116 -0
- package/dist/fixture-loader-services.cjs.map +1 -0
- package/dist/fixture-loader-services.d.cts +48 -0
- package/dist/fixture-loader-services.d.cts.map +1 -0
- package/dist/fixture-loader-services.d.ts +48 -0
- package/dist/fixture-loader-services.d.ts.map +1 -0
- package/dist/fixture-loader-services.js +114 -0
- package/dist/fixture-loader-services.js.map +1 -0
- package/dist/fixture-loader.cjs +0 -0
- package/dist/fixture-loader.cjs.map +1 -1
- package/dist/fixture-loader.d.cts +131 -5
- package/dist/fixture-loader.d.cts.map +1 -1
- package/dist/fixture-loader.d.ts +131 -5
- package/dist/fixture-loader.d.ts.map +1 -1
- package/dist/fixture-loader.js +0 -0
- package/dist/fixture-loader.js.map +1 -1
- package/dist/gemini-embeddings.cjs +44 -4
- package/dist/gemini-embeddings.cjs.map +1 -1
- package/dist/gemini-embeddings.js +46 -6
- package/dist/gemini-embeddings.js.map +1 -1
- package/dist/gemini-interactions.cjs +51 -7
- package/dist/gemini-interactions.cjs.map +1 -1
- package/dist/gemini-interactions.d.cts.map +1 -1
- package/dist/gemini-interactions.d.ts.map +1 -1
- package/dist/gemini-interactions.js +53 -9
- package/dist/gemini-interactions.js.map +1 -1
- package/dist/gemini.cjs +19 -8
- 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 +21 -10
- package/dist/gemini.js.map +1 -1
- package/dist/grok-video.cjs +14 -14
- package/dist/grok-video.cjs.map +1 -1
- package/dist/grok-video.js +15 -15
- package/dist/grok-video.js.map +1 -1
- package/dist/helpers.cjs +497 -10
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +38 -2
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.ts +38 -2
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +487 -12
- package/dist/helpers.js.map +1 -1
- package/dist/images.cjs +57 -125
- 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 +58 -126
- package/dist/images.js.map +1 -1
- package/dist/index.cjs +71 -9
- package/dist/index.d.cts +17 -7
- package/dist/index.d.ts +17 -7
- package/dist/index.js +21 -11
- package/dist/jest.cjs +24 -12
- package/dist/jest.cjs.map +1 -1
- package/dist/jest.d.cts +6 -3
- package/dist/jest.d.cts.map +1 -1
- package/dist/jest.d.ts +6 -3
- package/dist/jest.d.ts.map +1 -1
- package/dist/jest.js +25 -13
- package/dist/jest.js.map +1 -1
- package/dist/journal.cjs +61 -4
- package/dist/journal.cjs.map +1 -1
- package/dist/journal.d.cts +60 -3
- package/dist/journal.d.cts.map +1 -1
- package/dist/journal.d.ts +60 -3
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +61 -5
- package/dist/journal.js.map +1 -1
- package/dist/live-fixture.cjs +1192 -0
- package/dist/live-fixture.cjs.map +1 -0
- package/dist/live-fixture.js +1187 -0
- package/dist/live-fixture.js.map +1 -0
- package/dist/live-recorder.cjs +256 -0
- package/dist/live-recorder.cjs.map +1 -0
- package/dist/live-recorder.js +254 -0
- package/dist/live-recorder.js.map +1 -0
- package/dist/live-replay.cjs +286 -0
- package/dist/live-replay.cjs.map +1 -0
- package/dist/live-replay.js +285 -0
- package/dist/live-replay.js.map +1 -0
- package/dist/live-sanitize.cjs +196 -0
- package/dist/live-sanitize.cjs.map +1 -0
- package/dist/live-sanitize.js +196 -0
- package/dist/live-sanitize.js.map +1 -0
- package/dist/live-types.d.cts +71 -0
- package/dist/live-types.d.cts.map +1 -0
- package/dist/live-types.d.ts +71 -0
- package/dist/live-types.d.ts.map +1 -0
- package/dist/llmock.cjs +132 -49
- package/dist/llmock.cjs.map +1 -1
- package/dist/llmock.d.cts +51 -5
- package/dist/llmock.d.cts.map +1 -1
- package/dist/llmock.d.ts +51 -5
- package/dist/llmock.d.ts.map +1 -1
- package/dist/llmock.js +133 -50
- package/dist/llmock.js.map +1 -1
- package/dist/mcp-fakes-mount.cjs +216 -0
- package/dist/mcp-fakes-mount.cjs.map +1 -0
- package/dist/mcp-fakes-mount.js +210 -0
- package/dist/mcp-fakes-mount.js.map +1 -0
- package/dist/mcp-fakes.cjs +1619 -0
- package/dist/mcp-fakes.cjs.map +1 -0
- package/dist/mcp-fakes.d.cts +101 -0
- package/dist/mcp-fakes.d.cts.map +1 -0
- package/dist/mcp-fakes.d.ts +101 -0
- package/dist/mcp-fakes.d.ts.map +1 -0
- package/dist/mcp-fakes.js +1614 -0
- package/dist/mcp-fakes.js.map +1 -0
- package/dist/mcp-handler.cjs +331 -17
- package/dist/mcp-handler.cjs.map +1 -1
- package/dist/mcp-handler.js +330 -18
- package/dist/mcp-handler.js.map +1 -1
- package/dist/mcp-mock.cjs +217 -49
- package/dist/mcp-mock.cjs.map +1 -1
- package/dist/mcp-mock.d.cts +66 -1
- package/dist/mcp-mock.d.cts.map +1 -1
- package/dist/mcp-mock.d.ts +66 -1
- package/dist/mcp-mock.d.ts.map +1 -1
- package/dist/mcp-mock.js +218 -50
- package/dist/mcp-mock.js.map +1 -1
- package/dist/mcp-stub.cjs +5 -1
- package/dist/mcp-stub.d.cts +3 -1
- package/dist/mcp-stub.d.ts +3 -1
- package/dist/mcp-stub.js +3 -1
- package/dist/mcp-types.d.cts +6 -0
- package/dist/mcp-types.d.ts +6 -0
- package/dist/message-text.cjs +192 -0
- package/dist/message-text.cjs.map +1 -0
- package/dist/message-text.d.cts +31 -0
- package/dist/message-text.d.cts.map +1 -0
- package/dist/message-text.d.ts +31 -0
- package/dist/message-text.d.ts.map +1 -0
- package/dist/message-text.js +184 -0
- package/dist/message-text.js.map +1 -0
- package/dist/messages.cjs +49 -7
- 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 +51 -9
- package/dist/messages.js.map +1 -1
- package/dist/metrics.cjs +278 -45
- package/dist/metrics.cjs.map +1 -1
- package/dist/metrics.d.cts +17 -7
- package/dist/metrics.d.cts.map +1 -1
- package/dist/metrics.d.ts +17 -7
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +270 -29
- package/dist/metrics.js.map +1 -1
- package/dist/moderation.cjs +10 -1
- package/dist/moderation.cjs.map +1 -1
- package/dist/moderation.d.cts.map +1 -1
- package/dist/moderation.d.ts.map +1 -1
- package/dist/moderation.js +10 -1
- package/dist/moderation.js.map +1 -1
- package/dist/ollama.cjs +10 -6
- 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 +11 -7
- package/dist/ollama.js.map +1 -1
- package/dist/openapi.cjs +3405 -0
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +30 -0
- package/dist/openapi.d.cts.map +1 -0
- package/dist/openapi.d.ts +30 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +3404 -0
- package/dist/openapi.js.map +1 -0
- package/dist/openrouter-video.cjs +9 -9
- 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 +10 -10
- package/dist/openrouter-video.js.map +1 -1
- package/dist/recorder.cjs +54 -10
- 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 +52 -12
- package/dist/recorder.js.map +1 -1
- package/dist/responses.cjs +47 -7
- 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 +48 -9
- package/dist/responses.js.map +1 -1
- package/dist/route-registry.cjs +951 -0
- package/dist/route-registry.cjs.map +1 -0
- package/dist/route-registry.d.cts +33 -0
- package/dist/route-registry.d.cts.map +1 -0
- package/dist/route-registry.d.ts +33 -0
- package/dist/route-registry.d.ts.map +1 -0
- package/dist/route-registry.js +866 -0
- package/dist/route-registry.js.map +1 -0
- package/dist/router.cjs +21 -34
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +4 -1
- package/dist/router.d.cts.map +1 -1
- package/dist/router.d.ts +4 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +21 -35
- package/dist/router.js.map +1 -1
- package/dist/server.cjs +1252 -777
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +5 -1
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +5 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1185 -710
- package/dist/server.js.map +1 -1
- package/dist/speech.cjs +6 -4
- package/dist/speech.cjs.map +1 -1
- package/dist/speech.js +7 -5
- package/dist/speech.js.map +1 -1
- package/dist/suite.cjs +1 -1
- package/dist/suite.js +1 -1
- package/dist/transcription.cjs +6 -6
- 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 +7 -7
- package/dist/transcription.js.map +1 -1
- package/dist/types.cjs +18 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +320 -17
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +320 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/validate-cli.cjs +983 -0
- package/dist/validate-cli.cjs.map +1 -0
- package/dist/validate-cli.js +982 -0
- package/dist/validate-cli.js.map +1 -0
- package/dist/vector-stores.cjs +1180 -0
- package/dist/vector-stores.cjs.map +1 -0
- package/dist/vector-stores.d.cts +106 -0
- package/dist/vector-stores.d.cts.map +1 -0
- package/dist/vector-stores.d.ts +106 -0
- package/dist/vector-stores.d.ts.map +1 -0
- package/dist/vector-stores.js +1164 -0
- package/dist/vector-stores.js.map +1 -0
- package/dist/vector-types.d.cts.map +1 -1
- package/dist/vector-types.d.ts.map +1 -1
- package/dist/veo-video.cjs +13 -13
- package/dist/veo-video.cjs.map +1 -1
- package/dist/veo-video.js +14 -14
- package/dist/veo-video.js.map +1 -1
- package/dist/video.cjs +23 -4
- package/dist/video.cjs.map +1 -1
- package/dist/video.d.cts +1 -1
- package/dist/video.d.cts.map +1 -1
- package/dist/video.d.ts +1 -1
- package/dist/video.d.ts.map +1 -1
- package/dist/video.js +24 -5
- package/dist/video.js.map +1 -1
- package/dist/vitest.cjs +23 -11
- package/dist/vitest.cjs.map +1 -1
- package/dist/vitest.d.cts +5 -2
- package/dist/vitest.d.cts.map +1 -1
- package/dist/vitest.d.ts +5 -2
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +25 -13
- package/dist/vitest.js.map +1 -1
- package/dist/watcher.cjs +2 -1
- package/dist/watcher.cjs.map +1 -1
- package/dist/watcher.js +2 -1
- package/dist/watcher.js.map +1 -1
- package/dist/ws-framing.cjs +150 -35
- package/dist/ws-framing.cjs.map +1 -1
- package/dist/ws-framing.d.cts +18 -3
- package/dist/ws-framing.d.cts.map +1 -1
- package/dist/ws-framing.d.ts +18 -3
- package/dist/ws-framing.d.ts.map +1 -1
- package/dist/ws-framing.js +151 -36
- package/dist/ws-framing.js.map +1 -1
- package/dist/ws-gemini-live.cjs +2 -2
- package/dist/ws-gemini-live.js +2 -2
- package/dist/ws-live.cjs +401 -0
- package/dist/ws-live.cjs.map +1 -0
- package/dist/ws-live.js +400 -0
- package/dist/ws-live.js.map +1 -0
- package/dist/ws-realtime.cjs +46 -2
- 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 +46 -2
- package/dist/ws-realtime.js.map +1 -1
- package/dist/ws-responses.cjs +16 -4
- package/dist/ws-responses.cjs.map +1 -1
- package/dist/ws-responses.js +16 -4
- package/dist/ws-responses.js.map +1 -1
- package/dist/ws-upstream.cjs +118 -0
- package/dist/ws-upstream.cjs.map +1 -0
- package/dist/ws-upstream.js +115 -0
- package/dist/ws-upstream.js.map +1 -0
- package/fixtures/openai-live-client.json +390 -0
- package/fixtures/openai-live-managed.json +709 -0
- package/package.json +4 -1
|
@@ -0,0 +1,1192 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/live-fixture.ts
|
|
3
|
+
const DEFAULT_LIVE_OPTIONS = Object.freeze({
|
|
4
|
+
maxSessions: 16,
|
|
5
|
+
maxMessageBytes: 1024 * 1024,
|
|
6
|
+
maxBufferedBytes: 2 * 1024 * 1024,
|
|
7
|
+
maxWriteBytes: 1024 * 1024,
|
|
8
|
+
maxDecodedAudioBytes: 16 * 1024 * 1024,
|
|
9
|
+
maxDurationMs: 12e4,
|
|
10
|
+
idleTimeoutMs: 3e4,
|
|
11
|
+
mismatchTimeoutMs: 3e4
|
|
12
|
+
});
|
|
13
|
+
const DEFINITIONS = {
|
|
14
|
+
Pcm24: {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
type: { const: "audio/pcm" },
|
|
18
|
+
rate: { const: 24e3 }
|
|
19
|
+
},
|
|
20
|
+
required: ["type", "rate"],
|
|
21
|
+
additionalProperties: true
|
|
22
|
+
},
|
|
23
|
+
Voice: { anyOf: [{ type: "string" }, {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: { id: { type: "string" } },
|
|
26
|
+
required: ["id"],
|
|
27
|
+
additionalProperties: true
|
|
28
|
+
}] },
|
|
29
|
+
Audio: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
format: { $ref: "#/$defs/Pcm24" },
|
|
33
|
+
output: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: { voice: { $ref: "#/$defs/Voice" } },
|
|
36
|
+
required: [],
|
|
37
|
+
additionalProperties: true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
required: [],
|
|
41
|
+
additionalProperties: true
|
|
42
|
+
},
|
|
43
|
+
FunctionTool: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
type: { const: "function" },
|
|
47
|
+
name: { type: "string" },
|
|
48
|
+
description: { type: ["string", "null"] },
|
|
49
|
+
parameters: { type: ["object", "null"] },
|
|
50
|
+
strict: { type: ["boolean", "null"] }
|
|
51
|
+
},
|
|
52
|
+
required: ["type", "name"],
|
|
53
|
+
additionalProperties: true
|
|
54
|
+
},
|
|
55
|
+
Backend: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
model: { type: "string" },
|
|
59
|
+
instructions: { type: ["string", "null"] },
|
|
60
|
+
max_output_tokens: { type: ["number", "null"] },
|
|
61
|
+
parallel_tool_calls: { type: ["boolean", "null"] },
|
|
62
|
+
reasoning: { anyOf: [{ type: "null" }, {
|
|
63
|
+
type: "object",
|
|
64
|
+
properties: {
|
|
65
|
+
effort: { enum: [
|
|
66
|
+
"none",
|
|
67
|
+
"minimal",
|
|
68
|
+
"low",
|
|
69
|
+
"medium",
|
|
70
|
+
"high",
|
|
71
|
+
"xhigh",
|
|
72
|
+
null
|
|
73
|
+
] },
|
|
74
|
+
summary: { enum: [
|
|
75
|
+
"concise",
|
|
76
|
+
"detailed",
|
|
77
|
+
"auto",
|
|
78
|
+
null
|
|
79
|
+
] }
|
|
80
|
+
},
|
|
81
|
+
required: [],
|
|
82
|
+
additionalProperties: true
|
|
83
|
+
}] },
|
|
84
|
+
service_tier: { enum: [
|
|
85
|
+
"auto",
|
|
86
|
+
"default",
|
|
87
|
+
"fast_tier_temp_pilot",
|
|
88
|
+
"flex",
|
|
89
|
+
"priority",
|
|
90
|
+
"ultrafast",
|
|
91
|
+
null
|
|
92
|
+
] },
|
|
93
|
+
text: { anyOf: [{ type: "null" }, {
|
|
94
|
+
type: "object",
|
|
95
|
+
properties: { verbosity: { enum: [
|
|
96
|
+
"low",
|
|
97
|
+
"medium",
|
|
98
|
+
"high",
|
|
99
|
+
null
|
|
100
|
+
] } },
|
|
101
|
+
required: [],
|
|
102
|
+
additionalProperties: true
|
|
103
|
+
}] },
|
|
104
|
+
tool_choice: { anyOf: [
|
|
105
|
+
{ enum: [
|
|
106
|
+
"auto",
|
|
107
|
+
"none",
|
|
108
|
+
"required"
|
|
109
|
+
] },
|
|
110
|
+
{
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
type: { const: "function" },
|
|
114
|
+
name: { type: "string" }
|
|
115
|
+
},
|
|
116
|
+
required: ["type", "name"],
|
|
117
|
+
additionalProperties: true
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: "object",
|
|
121
|
+
properties: {
|
|
122
|
+
type: { const: "mcp" },
|
|
123
|
+
name: { type: "string" },
|
|
124
|
+
server_label: { type: "string" }
|
|
125
|
+
},
|
|
126
|
+
required: [
|
|
127
|
+
"type",
|
|
128
|
+
"name",
|
|
129
|
+
"server_label"
|
|
130
|
+
],
|
|
131
|
+
additionalProperties: true
|
|
132
|
+
}
|
|
133
|
+
] },
|
|
134
|
+
tools: {
|
|
135
|
+
type: "array",
|
|
136
|
+
items: { anyOf: [{ $ref: "#/$defs/FunctionTool" }, {
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: { type: { const: "web_search" } },
|
|
139
|
+
required: ["type"],
|
|
140
|
+
additionalProperties: true
|
|
141
|
+
}] }
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
required: ["model"],
|
|
145
|
+
additionalProperties: true
|
|
146
|
+
},
|
|
147
|
+
BackendPatch: {
|
|
148
|
+
type: "object",
|
|
149
|
+
properties: {
|
|
150
|
+
model: { type: "string" },
|
|
151
|
+
instructions: { type: ["string", "null"] },
|
|
152
|
+
max_output_tokens: { type: ["number", "null"] },
|
|
153
|
+
parallel_tool_calls: { type: ["boolean", "null"] },
|
|
154
|
+
reasoning: { anyOf: [{ type: "null" }, {
|
|
155
|
+
type: "object",
|
|
156
|
+
properties: {
|
|
157
|
+
effort: { enum: [
|
|
158
|
+
"none",
|
|
159
|
+
"minimal",
|
|
160
|
+
"low",
|
|
161
|
+
"medium",
|
|
162
|
+
"high",
|
|
163
|
+
"xhigh",
|
|
164
|
+
null
|
|
165
|
+
] },
|
|
166
|
+
summary: { enum: [
|
|
167
|
+
"concise",
|
|
168
|
+
"detailed",
|
|
169
|
+
"auto",
|
|
170
|
+
null
|
|
171
|
+
] }
|
|
172
|
+
},
|
|
173
|
+
required: [],
|
|
174
|
+
additionalProperties: true
|
|
175
|
+
}] },
|
|
176
|
+
service_tier: { enum: [
|
|
177
|
+
"auto",
|
|
178
|
+
"default",
|
|
179
|
+
"fast_tier_temp_pilot",
|
|
180
|
+
"flex",
|
|
181
|
+
"priority",
|
|
182
|
+
"ultrafast",
|
|
183
|
+
null
|
|
184
|
+
] },
|
|
185
|
+
text: { anyOf: [{ type: "null" }, {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties: { verbosity: { enum: [
|
|
188
|
+
"low",
|
|
189
|
+
"medium",
|
|
190
|
+
"high",
|
|
191
|
+
null
|
|
192
|
+
] } },
|
|
193
|
+
required: [],
|
|
194
|
+
additionalProperties: true
|
|
195
|
+
}] },
|
|
196
|
+
tool_choice: { anyOf: [
|
|
197
|
+
{ enum: [
|
|
198
|
+
"auto",
|
|
199
|
+
"none",
|
|
200
|
+
"required"
|
|
201
|
+
] },
|
|
202
|
+
{
|
|
203
|
+
type: "object",
|
|
204
|
+
properties: {
|
|
205
|
+
type: { const: "function" },
|
|
206
|
+
name: { type: "string" }
|
|
207
|
+
},
|
|
208
|
+
required: ["type", "name"],
|
|
209
|
+
additionalProperties: true
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
type: "object",
|
|
213
|
+
properties: {
|
|
214
|
+
type: { const: "mcp" },
|
|
215
|
+
name: { type: "string" },
|
|
216
|
+
server_label: { type: "string" }
|
|
217
|
+
},
|
|
218
|
+
required: [
|
|
219
|
+
"type",
|
|
220
|
+
"name",
|
|
221
|
+
"server_label"
|
|
222
|
+
],
|
|
223
|
+
additionalProperties: true
|
|
224
|
+
}
|
|
225
|
+
] },
|
|
226
|
+
tools: {
|
|
227
|
+
type: "array",
|
|
228
|
+
items: { anyOf: [{ $ref: "#/$defs/FunctionTool" }, {
|
|
229
|
+
type: "object",
|
|
230
|
+
properties: { type: { const: "web_search" } },
|
|
231
|
+
required: ["type"],
|
|
232
|
+
additionalProperties: true
|
|
233
|
+
}] }
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
required: [],
|
|
237
|
+
additionalProperties: true
|
|
238
|
+
},
|
|
239
|
+
Delegation: { anyOf: [
|
|
240
|
+
{ type: "null" },
|
|
241
|
+
{
|
|
242
|
+
type: "object",
|
|
243
|
+
properties: { type: { const: "client" } },
|
|
244
|
+
required: ["type"],
|
|
245
|
+
additionalProperties: true
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
type: "object",
|
|
249
|
+
properties: {
|
|
250
|
+
type: { const: "responses" },
|
|
251
|
+
responses: { $ref: "#/$defs/Backend" }
|
|
252
|
+
},
|
|
253
|
+
required: ["type", "responses"],
|
|
254
|
+
additionalProperties: true
|
|
255
|
+
}
|
|
256
|
+
] },
|
|
257
|
+
DelegationPatch: { anyOf: [
|
|
258
|
+
{ type: "null" },
|
|
259
|
+
{
|
|
260
|
+
type: "object",
|
|
261
|
+
properties: { type: { const: "client" } },
|
|
262
|
+
required: ["type"],
|
|
263
|
+
additionalProperties: true
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
type: "object",
|
|
267
|
+
properties: {
|
|
268
|
+
type: { const: "responses" },
|
|
269
|
+
responses: { $ref: "#/$defs/BackendPatch" }
|
|
270
|
+
},
|
|
271
|
+
required: ["type"],
|
|
272
|
+
additionalProperties: true
|
|
273
|
+
}
|
|
274
|
+
] },
|
|
275
|
+
SessionConfig: {
|
|
276
|
+
type: "object",
|
|
277
|
+
properties: {
|
|
278
|
+
model: { const: "gpt-live-1" },
|
|
279
|
+
audio: { $ref: "#/$defs/Audio" },
|
|
280
|
+
delegation: { $ref: "#/$defs/Delegation" },
|
|
281
|
+
instructions: { type: ["string", "null"] },
|
|
282
|
+
store: { type: "boolean" },
|
|
283
|
+
input: {
|
|
284
|
+
type: "array",
|
|
285
|
+
items: { type: "object" }
|
|
286
|
+
},
|
|
287
|
+
client: { type: "object" }
|
|
288
|
+
},
|
|
289
|
+
required: ["model"],
|
|
290
|
+
additionalProperties: true
|
|
291
|
+
},
|
|
292
|
+
SessionResource: {
|
|
293
|
+
type: "object",
|
|
294
|
+
properties: {
|
|
295
|
+
model: { const: "gpt-live-1" },
|
|
296
|
+
audio: { $ref: "#/$defs/Audio" },
|
|
297
|
+
delegation: { $ref: "#/$defs/Delegation" },
|
|
298
|
+
instructions: { type: ["string", "null"] },
|
|
299
|
+
store: { type: "boolean" },
|
|
300
|
+
input: {
|
|
301
|
+
type: "array",
|
|
302
|
+
items: { type: "object" }
|
|
303
|
+
},
|
|
304
|
+
client: { type: "object" },
|
|
305
|
+
id: { type: "string" },
|
|
306
|
+
expires_at: { type: "number" },
|
|
307
|
+
status: { const: "active" }
|
|
308
|
+
},
|
|
309
|
+
required: [
|
|
310
|
+
"id",
|
|
311
|
+
"expires_at",
|
|
312
|
+
"model",
|
|
313
|
+
"status"
|
|
314
|
+
],
|
|
315
|
+
additionalProperties: true
|
|
316
|
+
},
|
|
317
|
+
SessionPatch: {
|
|
318
|
+
type: "object",
|
|
319
|
+
properties: { delegation: { $ref: "#/$defs/DelegationPatch" } },
|
|
320
|
+
required: [],
|
|
321
|
+
additionalProperties: true
|
|
322
|
+
},
|
|
323
|
+
Usage: {
|
|
324
|
+
type: "object",
|
|
325
|
+
properties: { seconds: { type: "number" } },
|
|
326
|
+
required: ["seconds"],
|
|
327
|
+
additionalProperties: true
|
|
328
|
+
},
|
|
329
|
+
DelegationEventBody: {
|
|
330
|
+
type: "object",
|
|
331
|
+
properties: {
|
|
332
|
+
id: { type: "string" },
|
|
333
|
+
type: { const: "delegation" },
|
|
334
|
+
target: { enum: ["client", "responses"] },
|
|
335
|
+
response_id: { type: "string" }
|
|
336
|
+
},
|
|
337
|
+
required: [
|
|
338
|
+
"id",
|
|
339
|
+
"type",
|
|
340
|
+
"target"
|
|
341
|
+
],
|
|
342
|
+
additionalProperties: true
|
|
343
|
+
},
|
|
344
|
+
Error: {
|
|
345
|
+
type: "object",
|
|
346
|
+
properties: {
|
|
347
|
+
type: { type: "string" },
|
|
348
|
+
code: { type: "string" },
|
|
349
|
+
message: { type: "string" },
|
|
350
|
+
param: { type: ["string", "null"] },
|
|
351
|
+
client_event_id: { type: "string" }
|
|
352
|
+
},
|
|
353
|
+
required: [
|
|
354
|
+
"type",
|
|
355
|
+
"code",
|
|
356
|
+
"message"
|
|
357
|
+
],
|
|
358
|
+
additionalProperties: true
|
|
359
|
+
},
|
|
360
|
+
FunctionOutput: {
|
|
361
|
+
type: "object",
|
|
362
|
+
properties: {
|
|
363
|
+
type: { const: "function_call_output" },
|
|
364
|
+
call_id: { type: "string" },
|
|
365
|
+
output: { type: "string" },
|
|
366
|
+
id: { type: "string" },
|
|
367
|
+
status: { enum: [
|
|
368
|
+
"in_progress",
|
|
369
|
+
"completed",
|
|
370
|
+
"incomplete"
|
|
371
|
+
] }
|
|
372
|
+
},
|
|
373
|
+
required: [
|
|
374
|
+
"type",
|
|
375
|
+
"call_id",
|
|
376
|
+
"output"
|
|
377
|
+
],
|
|
378
|
+
additionalProperties: true
|
|
379
|
+
},
|
|
380
|
+
NestedResponse: {
|
|
381
|
+
type: "object",
|
|
382
|
+
properties: {
|
|
383
|
+
type: { type: "string" },
|
|
384
|
+
sequence_number: { type: "number" },
|
|
385
|
+
response: {
|
|
386
|
+
type: "object",
|
|
387
|
+
properties: {
|
|
388
|
+
id: { type: "string" },
|
|
389
|
+
previous_response_id: { type: ["string", "null"] },
|
|
390
|
+
status: { type: "string" },
|
|
391
|
+
usage: { type: ["object", "null"] },
|
|
392
|
+
output: { type: "array" },
|
|
393
|
+
instructions: { type: ["string", "null"] },
|
|
394
|
+
tools: { type: "array" }
|
|
395
|
+
},
|
|
396
|
+
required: [],
|
|
397
|
+
additionalProperties: true
|
|
398
|
+
},
|
|
399
|
+
item: {
|
|
400
|
+
type: "object",
|
|
401
|
+
properties: {
|
|
402
|
+
id: { type: "string" },
|
|
403
|
+
type: { type: "string" },
|
|
404
|
+
call_id: { type: "string" },
|
|
405
|
+
arguments: { type: "string" },
|
|
406
|
+
name: { type: "string" },
|
|
407
|
+
status: { type: "string" }
|
|
408
|
+
},
|
|
409
|
+
required: [],
|
|
410
|
+
additionalProperties: true
|
|
411
|
+
},
|
|
412
|
+
item_id: { type: "string" },
|
|
413
|
+
output_index: { type: "number" },
|
|
414
|
+
delta: { type: "string" },
|
|
415
|
+
arguments: { type: "string" }
|
|
416
|
+
},
|
|
417
|
+
required: [],
|
|
418
|
+
additionalProperties: true
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
const CLIENT_SCHEMAS = {
|
|
422
|
+
"session.start": {
|
|
423
|
+
type: "object",
|
|
424
|
+
properties: {
|
|
425
|
+
type: { const: "session.start" },
|
|
426
|
+
event_id: { type: ["string", "null"] },
|
|
427
|
+
session: { $ref: "#/$defs/SessionConfig" }
|
|
428
|
+
},
|
|
429
|
+
required: ["type", "session"],
|
|
430
|
+
additionalProperties: true
|
|
431
|
+
},
|
|
432
|
+
"session.update": {
|
|
433
|
+
type: "object",
|
|
434
|
+
properties: {
|
|
435
|
+
type: { const: "session.update" },
|
|
436
|
+
event_id: { type: ["string", "null"] },
|
|
437
|
+
session: { $ref: "#/$defs/SessionPatch" }
|
|
438
|
+
},
|
|
439
|
+
required: ["type", "session"],
|
|
440
|
+
additionalProperties: true
|
|
441
|
+
},
|
|
442
|
+
"session.input_audio.append": {
|
|
443
|
+
type: "object",
|
|
444
|
+
properties: {
|
|
445
|
+
type: { const: "session.input_audio.append" },
|
|
446
|
+
event_id: { type: ["string", "null"] },
|
|
447
|
+
audio: { type: "string" }
|
|
448
|
+
},
|
|
449
|
+
required: ["type", "audio"],
|
|
450
|
+
additionalProperties: true
|
|
451
|
+
},
|
|
452
|
+
"response.item.create": {
|
|
453
|
+
type: "object",
|
|
454
|
+
properties: {
|
|
455
|
+
type: { const: "response.item.create" },
|
|
456
|
+
event_id: { type: ["string", "null"] },
|
|
457
|
+
item: { $ref: "#/$defs/FunctionOutput" }
|
|
458
|
+
},
|
|
459
|
+
required: ["type", "item"],
|
|
460
|
+
additionalProperties: true
|
|
461
|
+
},
|
|
462
|
+
"response.create": {
|
|
463
|
+
type: "object",
|
|
464
|
+
properties: {
|
|
465
|
+
type: { const: "response.create" },
|
|
466
|
+
event_id: { type: ["string", "null"] }
|
|
467
|
+
},
|
|
468
|
+
required: ["type"],
|
|
469
|
+
additionalProperties: true
|
|
470
|
+
},
|
|
471
|
+
"session.close": {
|
|
472
|
+
type: "object",
|
|
473
|
+
properties: {
|
|
474
|
+
type: { const: "session.close" },
|
|
475
|
+
event_id: { type: ["string", "null"] }
|
|
476
|
+
},
|
|
477
|
+
required: ["type"],
|
|
478
|
+
additionalProperties: true
|
|
479
|
+
},
|
|
480
|
+
"session.instructions.append": {
|
|
481
|
+
type: "object",
|
|
482
|
+
properties: {
|
|
483
|
+
type: { const: "session.instructions.append" },
|
|
484
|
+
event_id: { type: ["string", "null"] },
|
|
485
|
+
content: { type: "string" },
|
|
486
|
+
delegation_id: { type: ["string", "null"] }
|
|
487
|
+
},
|
|
488
|
+
required: [
|
|
489
|
+
"type",
|
|
490
|
+
"content",
|
|
491
|
+
"delegation_id"
|
|
492
|
+
],
|
|
493
|
+
additionalProperties: true
|
|
494
|
+
},
|
|
495
|
+
"session.thinking.append": {
|
|
496
|
+
type: "object",
|
|
497
|
+
properties: {
|
|
498
|
+
type: { const: "session.thinking.append" },
|
|
499
|
+
event_id: { type: ["string", "null"] },
|
|
500
|
+
content: { type: "string" },
|
|
501
|
+
delegation_id: { type: ["string", "null"] }
|
|
502
|
+
},
|
|
503
|
+
required: [
|
|
504
|
+
"type",
|
|
505
|
+
"content",
|
|
506
|
+
"delegation_id"
|
|
507
|
+
],
|
|
508
|
+
additionalProperties: true
|
|
509
|
+
},
|
|
510
|
+
"session.commentary.append": {
|
|
511
|
+
type: "object",
|
|
512
|
+
properties: {
|
|
513
|
+
type: { const: "session.commentary.append" },
|
|
514
|
+
event_id: { type: ["string", "null"] },
|
|
515
|
+
content: { type: "string" },
|
|
516
|
+
delegation_id: { type: ["string", "null"] }
|
|
517
|
+
},
|
|
518
|
+
required: [
|
|
519
|
+
"type",
|
|
520
|
+
"content",
|
|
521
|
+
"delegation_id"
|
|
522
|
+
],
|
|
523
|
+
additionalProperties: true
|
|
524
|
+
},
|
|
525
|
+
"session.input_audio.mute": {
|
|
526
|
+
type: "object",
|
|
527
|
+
properties: {
|
|
528
|
+
type: { const: "session.input_audio.mute" },
|
|
529
|
+
event_id: { type: ["string", "null"] }
|
|
530
|
+
},
|
|
531
|
+
required: ["type"],
|
|
532
|
+
additionalProperties: true
|
|
533
|
+
},
|
|
534
|
+
"session.input_audio.unmute": {
|
|
535
|
+
type: "object",
|
|
536
|
+
properties: {
|
|
537
|
+
type: { const: "session.input_audio.unmute" },
|
|
538
|
+
event_id: { type: ["string", "null"] }
|
|
539
|
+
},
|
|
540
|
+
required: ["type"],
|
|
541
|
+
additionalProperties: true
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
const SERVER_SCHEMAS = {
|
|
545
|
+
"session.started": {
|
|
546
|
+
type: "object",
|
|
547
|
+
properties: {
|
|
548
|
+
type: { const: "session.started" },
|
|
549
|
+
event_id: { type: "string" },
|
|
550
|
+
client_event_id: { type: "string" },
|
|
551
|
+
session: { $ref: "#/$defs/SessionResource" }
|
|
552
|
+
},
|
|
553
|
+
required: [
|
|
554
|
+
"type",
|
|
555
|
+
"event_id",
|
|
556
|
+
"session"
|
|
557
|
+
],
|
|
558
|
+
additionalProperties: true
|
|
559
|
+
},
|
|
560
|
+
"session.updated": {
|
|
561
|
+
type: "object",
|
|
562
|
+
properties: {
|
|
563
|
+
type: { const: "session.updated" },
|
|
564
|
+
event_id: { type: "string" },
|
|
565
|
+
client_event_id: { type: "string" },
|
|
566
|
+
session: { $ref: "#/$defs/SessionResource" }
|
|
567
|
+
},
|
|
568
|
+
required: [
|
|
569
|
+
"type",
|
|
570
|
+
"event_id",
|
|
571
|
+
"session"
|
|
572
|
+
],
|
|
573
|
+
additionalProperties: true
|
|
574
|
+
},
|
|
575
|
+
"session.closed": {
|
|
576
|
+
type: "object",
|
|
577
|
+
properties: {
|
|
578
|
+
type: { const: "session.closed" },
|
|
579
|
+
event_id: { type: "string" },
|
|
580
|
+
client_event_id: { type: "string" },
|
|
581
|
+
session: { $ref: "#/$defs/SessionResource" },
|
|
582
|
+
usage: { $ref: "#/$defs/Usage" },
|
|
583
|
+
reason: { enum: [
|
|
584
|
+
"close_requested",
|
|
585
|
+
"expired",
|
|
586
|
+
"content",
|
|
587
|
+
"remote_hangup",
|
|
588
|
+
"connection_lost"
|
|
589
|
+
] }
|
|
590
|
+
},
|
|
591
|
+
required: [
|
|
592
|
+
"type",
|
|
593
|
+
"event_id",
|
|
594
|
+
"session",
|
|
595
|
+
"usage",
|
|
596
|
+
"reason"
|
|
597
|
+
],
|
|
598
|
+
additionalProperties: true
|
|
599
|
+
},
|
|
600
|
+
"session.output_audio.delta": {
|
|
601
|
+
type: "object",
|
|
602
|
+
properties: {
|
|
603
|
+
type: { const: "session.output_audio.delta" },
|
|
604
|
+
delta: { type: "string" },
|
|
605
|
+
start_ms: { type: "number" },
|
|
606
|
+
end_ms: { type: "number" }
|
|
607
|
+
},
|
|
608
|
+
required: ["type", "delta"],
|
|
609
|
+
additionalProperties: true
|
|
610
|
+
},
|
|
611
|
+
"session.input_transcript.delta": {
|
|
612
|
+
type: "object",
|
|
613
|
+
properties: {
|
|
614
|
+
type: { const: "session.input_transcript.delta" },
|
|
615
|
+
event_id: { type: "string" },
|
|
616
|
+
client_event_id: { type: "string" },
|
|
617
|
+
start_ms: { type: "number" },
|
|
618
|
+
end_ms: { type: "number" },
|
|
619
|
+
delta: { type: "string" }
|
|
620
|
+
},
|
|
621
|
+
required: [
|
|
622
|
+
"type",
|
|
623
|
+
"event_id",
|
|
624
|
+
"start_ms",
|
|
625
|
+
"end_ms",
|
|
626
|
+
"delta"
|
|
627
|
+
],
|
|
628
|
+
additionalProperties: true
|
|
629
|
+
},
|
|
630
|
+
"session.output_transcript.delta": {
|
|
631
|
+
type: "object",
|
|
632
|
+
properties: {
|
|
633
|
+
type: { const: "session.output_transcript.delta" },
|
|
634
|
+
event_id: { type: "string" },
|
|
635
|
+
client_event_id: { type: "string" },
|
|
636
|
+
start_ms: { type: "number" },
|
|
637
|
+
end_ms: { type: "number" },
|
|
638
|
+
delta: { type: "string" }
|
|
639
|
+
},
|
|
640
|
+
required: [
|
|
641
|
+
"type",
|
|
642
|
+
"event_id",
|
|
643
|
+
"start_ms",
|
|
644
|
+
"end_ms",
|
|
645
|
+
"delta"
|
|
646
|
+
],
|
|
647
|
+
additionalProperties: true
|
|
648
|
+
},
|
|
649
|
+
"session.instructions.appended": {
|
|
650
|
+
type: "object",
|
|
651
|
+
properties: {
|
|
652
|
+
type: { const: "session.instructions.appended" },
|
|
653
|
+
event_id: { type: "string" },
|
|
654
|
+
client_event_id: { type: "string" },
|
|
655
|
+
start_ms: { type: "number" },
|
|
656
|
+
end_ms: { type: "number" }
|
|
657
|
+
},
|
|
658
|
+
required: [
|
|
659
|
+
"type",
|
|
660
|
+
"event_id",
|
|
661
|
+
"start_ms",
|
|
662
|
+
"end_ms"
|
|
663
|
+
],
|
|
664
|
+
additionalProperties: true
|
|
665
|
+
},
|
|
666
|
+
"session.thinking.appended": {
|
|
667
|
+
type: "object",
|
|
668
|
+
properties: {
|
|
669
|
+
type: { const: "session.thinking.appended" },
|
|
670
|
+
event_id: { type: "string" },
|
|
671
|
+
client_event_id: { type: "string" },
|
|
672
|
+
start_ms: { type: "number" },
|
|
673
|
+
end_ms: { type: "number" }
|
|
674
|
+
},
|
|
675
|
+
required: [
|
|
676
|
+
"type",
|
|
677
|
+
"event_id",
|
|
678
|
+
"start_ms",
|
|
679
|
+
"end_ms"
|
|
680
|
+
],
|
|
681
|
+
additionalProperties: true
|
|
682
|
+
},
|
|
683
|
+
"session.commentary.appended": {
|
|
684
|
+
type: "object",
|
|
685
|
+
properties: {
|
|
686
|
+
type: { const: "session.commentary.appended" },
|
|
687
|
+
event_id: { type: "string" },
|
|
688
|
+
client_event_id: { type: "string" },
|
|
689
|
+
start_ms: { type: "number" },
|
|
690
|
+
end_ms: { type: "number" }
|
|
691
|
+
},
|
|
692
|
+
required: [
|
|
693
|
+
"type",
|
|
694
|
+
"event_id",
|
|
695
|
+
"start_ms",
|
|
696
|
+
"end_ms"
|
|
697
|
+
],
|
|
698
|
+
additionalProperties: true
|
|
699
|
+
},
|
|
700
|
+
"session.input_audio.muted": {
|
|
701
|
+
type: "object",
|
|
702
|
+
properties: {
|
|
703
|
+
type: { const: "session.input_audio.muted" },
|
|
704
|
+
event_id: { type: "string" },
|
|
705
|
+
client_event_id: { type: "string" }
|
|
706
|
+
},
|
|
707
|
+
required: ["type", "event_id"],
|
|
708
|
+
additionalProperties: true
|
|
709
|
+
},
|
|
710
|
+
"session.input_audio.unmuted": {
|
|
711
|
+
type: "object",
|
|
712
|
+
properties: {
|
|
713
|
+
type: { const: "session.input_audio.unmuted" },
|
|
714
|
+
event_id: { type: "string" },
|
|
715
|
+
client_event_id: { type: "string" }
|
|
716
|
+
},
|
|
717
|
+
required: ["type", "event_id"],
|
|
718
|
+
additionalProperties: true
|
|
719
|
+
},
|
|
720
|
+
"session.delegation.created": {
|
|
721
|
+
type: "object",
|
|
722
|
+
properties: {
|
|
723
|
+
type: { const: "session.delegation.created" },
|
|
724
|
+
event_id: { type: "string" },
|
|
725
|
+
client_event_id: { type: "string" },
|
|
726
|
+
delegation: { $ref: "#/$defs/DelegationEventBody" },
|
|
727
|
+
offset_ms: { type: "number" }
|
|
728
|
+
},
|
|
729
|
+
required: [
|
|
730
|
+
"type",
|
|
731
|
+
"event_id",
|
|
732
|
+
"delegation",
|
|
733
|
+
"offset_ms"
|
|
734
|
+
],
|
|
735
|
+
additionalProperties: true
|
|
736
|
+
},
|
|
737
|
+
"session.usage.updated": {
|
|
738
|
+
type: "object",
|
|
739
|
+
properties: {
|
|
740
|
+
type: { const: "session.usage.updated" },
|
|
741
|
+
event_id: { type: "string" },
|
|
742
|
+
client_event_id: { type: "string" },
|
|
743
|
+
usage: { $ref: "#/$defs/Usage" },
|
|
744
|
+
context_window: {
|
|
745
|
+
type: "object",
|
|
746
|
+
properties: { usage_ratio: { type: "number" } },
|
|
747
|
+
required: ["usage_ratio"],
|
|
748
|
+
additionalProperties: true
|
|
749
|
+
}
|
|
750
|
+
},
|
|
751
|
+
required: [
|
|
752
|
+
"type",
|
|
753
|
+
"event_id",
|
|
754
|
+
"usage"
|
|
755
|
+
],
|
|
756
|
+
additionalProperties: true
|
|
757
|
+
},
|
|
758
|
+
"response.event": {
|
|
759
|
+
type: "object",
|
|
760
|
+
properties: {
|
|
761
|
+
type: { const: "response.event" },
|
|
762
|
+
event_id: { type: "string" },
|
|
763
|
+
client_event_id: { type: "string" },
|
|
764
|
+
event: { $ref: "#/$defs/NestedResponse" },
|
|
765
|
+
delegation_id: { type: ["string", "null"] }
|
|
766
|
+
},
|
|
767
|
+
required: [
|
|
768
|
+
"type",
|
|
769
|
+
"event_id",
|
|
770
|
+
"event"
|
|
771
|
+
],
|
|
772
|
+
additionalProperties: true
|
|
773
|
+
},
|
|
774
|
+
error: {
|
|
775
|
+
type: "object",
|
|
776
|
+
properties: {
|
|
777
|
+
type: { const: "error" },
|
|
778
|
+
event_id: { type: "string" },
|
|
779
|
+
client_event_id: { type: "string" },
|
|
780
|
+
error: { $ref: "#/$defs/Error" }
|
|
781
|
+
},
|
|
782
|
+
required: [
|
|
783
|
+
"type",
|
|
784
|
+
"event_id",
|
|
785
|
+
"error"
|
|
786
|
+
],
|
|
787
|
+
additionalProperties: true
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
const DOCUMENTED_ONLY = new Set([
|
|
791
|
+
"session.instructions.append",
|
|
792
|
+
"session.input_audio.mute",
|
|
793
|
+
"session.input_audio.unmute"
|
|
794
|
+
]);
|
|
795
|
+
const MAX_JSON_BYTES = 64 * 1024 * 1024;
|
|
796
|
+
const MAX_ENTRIES = 5e6;
|
|
797
|
+
const dangerous = new Set([
|
|
798
|
+
"__proto__",
|
|
799
|
+
"prototype",
|
|
800
|
+
"constructor"
|
|
801
|
+
]);
|
|
802
|
+
function fail(path, message) {
|
|
803
|
+
throw new Error(`Live fixture ${path}: ${message}`);
|
|
804
|
+
}
|
|
805
|
+
function object(value, path) {
|
|
806
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) fail(path, "must be an object");
|
|
807
|
+
return value;
|
|
808
|
+
}
|
|
809
|
+
function string(value, path) {
|
|
810
|
+
if (typeof value !== "string" || !value.length) fail(path, "must be a nonempty string");
|
|
811
|
+
return value;
|
|
812
|
+
}
|
|
813
|
+
function integer(value, path) {
|
|
814
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) fail(path, "must be a nonnegative safe integer");
|
|
815
|
+
return value;
|
|
816
|
+
}
|
|
817
|
+
function array(value, path) {
|
|
818
|
+
if (!Array.isArray(value)) fail(path, "must be an array");
|
|
819
|
+
return value;
|
|
820
|
+
}
|
|
821
|
+
/** Clone before registration; reject getters, prototypes, cycles and oversized JSON before allocating. */
|
|
822
|
+
function cloneJson(value, maxBytes = MAX_JSON_BYTES, rootPath = "live") {
|
|
823
|
+
let bytes = 0;
|
|
824
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
825
|
+
function charge(count, path) {
|
|
826
|
+
bytes += count;
|
|
827
|
+
if (bytes > maxBytes) fail(path, "exceeds JSON byte limit");
|
|
828
|
+
}
|
|
829
|
+
function visit(current, path, depth) {
|
|
830
|
+
if (depth > 32) fail(path, "exceeds JSON depth 32");
|
|
831
|
+
if (current === null || typeof current === "boolean" || typeof current === "number" || typeof current === "string") {
|
|
832
|
+
if (typeof current === "number" && !Number.isFinite(current)) fail(path, "must be finite JSON");
|
|
833
|
+
if (typeof current === "string" && current.length > maxBytes - bytes) fail(path, "exceeds JSON byte limit");
|
|
834
|
+
charge(Buffer.byteLength(JSON.stringify(current)), path);
|
|
835
|
+
return current;
|
|
836
|
+
}
|
|
837
|
+
if (typeof current !== "object") fail(path, "must be JSON");
|
|
838
|
+
if (ancestors.has(current)) fail(path, "contains a cycle");
|
|
839
|
+
const isArray = Array.isArray(current);
|
|
840
|
+
if (Object.getPrototypeOf(current) !== (isArray ? Array.prototype : Object.prototype) && Object.getPrototypeOf(current) !== null) fail(path, "must have a plain JSON prototype");
|
|
841
|
+
if (Object.getOwnPropertySymbols(current).length) fail(path, "symbol properties are not JSON");
|
|
842
|
+
ancestors.add(current);
|
|
843
|
+
charge(2, path);
|
|
844
|
+
const result = isArray ? [] : {};
|
|
845
|
+
const keys = Object.getOwnPropertyNames(current);
|
|
846
|
+
if (isArray && current.length > MAX_ENTRIES) fail(path, "exceeds array entry limit");
|
|
847
|
+
let count = 0;
|
|
848
|
+
for (const key of keys) {
|
|
849
|
+
if (isArray && key === "length") continue;
|
|
850
|
+
if (dangerous.has(key)) fail(`${path}.${key}`, "unsafe property");
|
|
851
|
+
const desc = Object.getOwnPropertyDescriptor(current, key);
|
|
852
|
+
if (!desc || !desc.enumerable || !("value" in desc)) fail(`${path}.${key}`, "must be an enumerable data property");
|
|
853
|
+
if (isArray && key !== String(count)) fail(path, "must be a dense JSON array");
|
|
854
|
+
charge((count++ ? 1 : 0) + (isArray ? 0 : Buffer.byteLength(JSON.stringify(key)) + 1), path);
|
|
855
|
+
const child = visit(desc.value, isArray ? `${path}[${key}]` : `${path}.${key}`, depth + 1);
|
|
856
|
+
if (Array.isArray(result)) result.push(child);
|
|
857
|
+
else result[key] = child;
|
|
858
|
+
}
|
|
859
|
+
if (isArray && count !== current.length) fail(path, "must be a dense JSON array");
|
|
860
|
+
ancestors.delete(current);
|
|
861
|
+
return result;
|
|
862
|
+
}
|
|
863
|
+
return visit(value, rootPath, 0);
|
|
864
|
+
}
|
|
865
|
+
function shape(value, schema, path) {
|
|
866
|
+
if (schema.$ref) return shape(value, DEFINITIONS[schema.$ref.slice(8)], path);
|
|
867
|
+
if (schema.anyOf) {
|
|
868
|
+
for (const option of schema.anyOf) try {
|
|
869
|
+
shape(value, option, path);
|
|
870
|
+
return;
|
|
871
|
+
} catch {}
|
|
872
|
+
fail(path, "does not match documented shape");
|
|
873
|
+
}
|
|
874
|
+
if ("const" in schema && value !== schema.const) fail(path, `must equal ${JSON.stringify(schema.const)}`);
|
|
875
|
+
if (schema.enum && !schema.enum.includes(value ?? null)) fail(path, "is not a documented value");
|
|
876
|
+
if (schema.type) {
|
|
877
|
+
const types = typeof schema.type === "string" ? [schema.type] : schema.type;
|
|
878
|
+
const actual = value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
|
|
879
|
+
if (!types.includes(actual)) fail(path, `must be ${types.join(" or ")}`);
|
|
880
|
+
}
|
|
881
|
+
if (schema.properties || schema.required) {
|
|
882
|
+
const obj = object(value, path);
|
|
883
|
+
for (const key of schema.required ?? []) if (!Object.hasOwn(obj, key)) fail(`${path}.${key}`, "is required");
|
|
884
|
+
for (const [key, child] of Object.entries(schema.properties ?? {})) if (Object.hasOwn(obj, key)) shape(obj[key], child, `${path}.${key}`);
|
|
885
|
+
}
|
|
886
|
+
if (schema.items) array(value, path).forEach((item, i) => shape(item, schema.items, `${path}[${i}]`));
|
|
887
|
+
}
|
|
888
|
+
function normalizeLiveOptions(options = {}) {
|
|
889
|
+
const result = { ...DEFAULT_LIVE_OPTIONS };
|
|
890
|
+
for (const key of Object.keys(DEFAULT_LIVE_OPTIONS)) {
|
|
891
|
+
const value = options[key];
|
|
892
|
+
if (value !== void 0) {
|
|
893
|
+
if (!Number.isSafeInteger(value) || value <= 0) fail(`options.${key}`, "must be a positive safe integer");
|
|
894
|
+
result[key] = value;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
if (options.secretValues !== void 0 && (!Array.isArray(options.secretValues) || options.secretValues.some((value) => typeof value !== "string"))) fail("options.secretValues", "must be strings");
|
|
898
|
+
return {
|
|
899
|
+
...result,
|
|
900
|
+
secretValues: options.secretValues?.slice() ?? []
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
/** Canonical object ordering without changing arrays or literal unknown fields. */
|
|
904
|
+
function canonical(value) {
|
|
905
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
906
|
+
if (value && typeof value === "object") return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
|
|
907
|
+
return JSON.stringify(value);
|
|
908
|
+
}
|
|
909
|
+
function matchConfiguration(expected, actual, path) {
|
|
910
|
+
if (expected && typeof expected === "object" && !Array.isArray(expected)) {
|
|
911
|
+
const actualObject = object(actual, path);
|
|
912
|
+
for (const [key, value] of Object.entries(expected)) matchConfiguration(value, actualObject[key], `${path}.${key}`);
|
|
913
|
+
} else if (actual === void 0 || canonical(expected) !== canonical(actual)) fail(path, "differs from accepted configuration");
|
|
914
|
+
}
|
|
915
|
+
function pcmBytes(value, path, remaining) {
|
|
916
|
+
if (typeof value !== "string") fail(path, "must be canonical base64 PCM");
|
|
917
|
+
if (value.length % 4 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)) fail(path, "must be canonical base64 PCM");
|
|
918
|
+
const bytes = value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0);
|
|
919
|
+
if (bytes > remaining) fail(path, "exceeds decoded audio byte limit");
|
|
920
|
+
if (bytes % 2) fail(path, "must contain complete PCM16 samples");
|
|
921
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
922
|
+
if (value.endsWith("==") && alphabet.indexOf(value.at(-3)) & 15 || value.endsWith("=") && !value.endsWith("==") && alphabet.indexOf(value.at(-2)) & 3) fail(path, "must be canonical base64 PCM");
|
|
923
|
+
return bytes;
|
|
924
|
+
}
|
|
925
|
+
/** Shared shape check; callers retain capture source, mode and lifecycle policy. */
|
|
926
|
+
function validateClientShape(event, path) {
|
|
927
|
+
const type = string(event.type, `${path}.type`);
|
|
928
|
+
if (!Object.hasOwn(CLIENT_SCHEMAS, type)) fail(`${path}.type`, "unsupported client command");
|
|
929
|
+
shape(event, CLIENT_SCHEMAS[type], path);
|
|
930
|
+
}
|
|
931
|
+
/** Validate one inbound command before matching a fixture or starting a recording.
|
|
932
|
+
* Per-session audio totals, startup configuration and update/lifecycle policy belong to the caller.
|
|
933
|
+
*/
|
|
934
|
+
function validateLiveClientEvent(value, options = {}) {
|
|
935
|
+
const limits = normalizeLiveOptions(options);
|
|
936
|
+
const event = object(cloneJson(value, Math.min(limits.maxMessageBytes, MAX_JSON_BYTES), "event"), "event");
|
|
937
|
+
validateClientShape(event, "event");
|
|
938
|
+
if (event.type === "session.input_audio.append") pcmBytes(event.audio, "event.audio", limits.maxDecodedAudioBytes);
|
|
939
|
+
return event;
|
|
940
|
+
}
|
|
941
|
+
function pointer(event, path) {
|
|
942
|
+
if (!path.startsWith("/") || /~(?![01])/u.test(path)) fail("bindings.pointer", "must be a JSON Pointer");
|
|
943
|
+
let value = event;
|
|
944
|
+
for (const segment of path.slice(1).split("/")) {
|
|
945
|
+
const key = segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
946
|
+
if (dangerous.has(key)) fail("bindings.pointer", "unsafe segment");
|
|
947
|
+
if (!value || typeof value !== "object" || !Object.hasOwn(value, key)) return void 0;
|
|
948
|
+
value = Array.isArray(value) ? value[Number(key)] : value[key];
|
|
949
|
+
}
|
|
950
|
+
return value;
|
|
951
|
+
}
|
|
952
|
+
const lifecycle = new Set([
|
|
953
|
+
"response.created",
|
|
954
|
+
"response.in_progress",
|
|
955
|
+
"response.completed"
|
|
956
|
+
]);
|
|
957
|
+
function bindingSites(event, direction) {
|
|
958
|
+
const sites = /* @__PURE__ */ new Map();
|
|
959
|
+
const server = direction === "server";
|
|
960
|
+
function add(path, namespace, define = false, owner = "server", imported = false) {
|
|
961
|
+
if (typeof pointer(event, path) === "string") sites.set(path, {
|
|
962
|
+
namespace,
|
|
963
|
+
owner,
|
|
964
|
+
define,
|
|
965
|
+
imported
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
add("/event_id", server ? "server-event" : "client-event", true, server ? "server" : "client");
|
|
969
|
+
if (server) add("/client_event_id", "client-event", false, "client");
|
|
970
|
+
if (server && event.type === "error") add("/error/client_event_id", "client-event", false, "client");
|
|
971
|
+
if (server && [
|
|
972
|
+
"session.started",
|
|
973
|
+
"session.updated",
|
|
974
|
+
"session.closed"
|
|
975
|
+
].includes(String(event.type))) add("/session/id", "session", event.type === "session.started");
|
|
976
|
+
if (server && event.type === "session.delegation.created") {
|
|
977
|
+
add("/delegation/id", "delegation", true);
|
|
978
|
+
add("/delegation/response_id", "response", true);
|
|
979
|
+
}
|
|
980
|
+
if (!server && [
|
|
981
|
+
"session.thinking.append",
|
|
982
|
+
"session.commentary.append",
|
|
983
|
+
"session.instructions.append"
|
|
984
|
+
].includes(String(event.type)) || server && event.type === "response.event") add("/delegation_id", "delegation");
|
|
985
|
+
if (!server && event.type === "response.item.create") add("/item/call_id", "tool-call");
|
|
986
|
+
if (server && event.type === "response.event") {
|
|
987
|
+
const nested = object(event.event, "event.event");
|
|
988
|
+
add("/event/response/id", "response", nested.type === "response.created");
|
|
989
|
+
add("/event/response/previous_response_id", "response", false, "server", lifecycle.has(String(nested.type)));
|
|
990
|
+
add("/event/item/id", "response-item", nested.type === "response.output_item.added");
|
|
991
|
+
add("/event/item_id", "response-item");
|
|
992
|
+
add("/event/item/call_id", "tool-call", nested.type === "response.output_item.added");
|
|
993
|
+
}
|
|
994
|
+
return sites;
|
|
995
|
+
}
|
|
996
|
+
function validateLiveTranscript(value, options = {}) {
|
|
997
|
+
const limits = normalizeLiveOptions(options);
|
|
998
|
+
const root = object(cloneJson(value), "live");
|
|
999
|
+
if (root.version !== 1) fail("version", "must equal 1");
|
|
1000
|
+
if (root.model !== "gpt-live-1") fail("model", "must equal gpt-live-1");
|
|
1001
|
+
if (root.mode !== "client" && root.mode !== "managed") fail("mode", "must be client or managed");
|
|
1002
|
+
const audio = object(root.audio, "audio");
|
|
1003
|
+
if (audio.encoding !== "pcm16le" || audio.sampleRateHz !== 24e3 || audio.channels !== 1) fail("audio", "requires mono PCM16LE at 24000 Hz");
|
|
1004
|
+
const config = object(root.configuration, "configuration");
|
|
1005
|
+
shape(config, DEFINITIONS.SessionConfig, "configuration");
|
|
1006
|
+
shape(object(config.audio, "configuration.audio").format, DEFINITIONS.Pcm24, "configuration.audio.format");
|
|
1007
|
+
if (object(config.delegation, "configuration.delegation").type !== (root.mode === "managed" ? "responses" : "client")) fail("configuration.delegation", "must match mode explicitly");
|
|
1008
|
+
let effectiveConfiguration = structuredClone(config);
|
|
1009
|
+
const capture = object(root.capture, "capture");
|
|
1010
|
+
if (capture.complete !== true) fail("capture.complete", "only complete successful captures are loadable");
|
|
1011
|
+
if (capture.source !== "authored" && capture.source !== "provider") fail("capture.source", "must be authored or provider");
|
|
1012
|
+
if (capture.provenance !== void 0) {
|
|
1013
|
+
const provenance = object(capture.provenance, "capture.provenance");
|
|
1014
|
+
string(provenance.host, "capture.provenance.host");
|
|
1015
|
+
string(provenance.referenceVersion, "capture.provenance.referenceVersion");
|
|
1016
|
+
if (!Number.isFinite(Date.parse(string(provenance.observedAt, "capture.provenance.observedAt")))) fail("capture.provenance.observedAt", "must be a timestamp");
|
|
1017
|
+
if (provenance.path !== "/v1/live/sessions" || provenance.sanitationVersion !== 1) fail("capture.provenance", "invalid path or sanitationVersion");
|
|
1018
|
+
}
|
|
1019
|
+
const entries = array(root.entries, "entries");
|
|
1020
|
+
if (!entries.length || entries.length > MAX_ENTRIES) fail("entries", "invalid entry count");
|
|
1021
|
+
const terminal = integer(capture.terminalEntry, "capture.terminalEntry");
|
|
1022
|
+
if (terminal !== entries.length - 1) fail("capture.terminalEntry", "must identify the final session.closed event");
|
|
1023
|
+
const bindings = array(root.bindings, "bindings");
|
|
1024
|
+
const byEntry = /* @__PURE__ */ new Map();
|
|
1025
|
+
bindings.forEach((raw, index) => {
|
|
1026
|
+
const path = `bindings[${index}]`;
|
|
1027
|
+
const binding = object(raw, path);
|
|
1028
|
+
const entry = integer(binding.entry, `${path}.entry`);
|
|
1029
|
+
if (entry >= entries.length) fail(`${path}.entry`, "out of range");
|
|
1030
|
+
const bucket = byEntry.get(entry) ?? [];
|
|
1031
|
+
bucket.push({
|
|
1032
|
+
binding,
|
|
1033
|
+
path
|
|
1034
|
+
});
|
|
1035
|
+
byEntry.set(entry, bucket);
|
|
1036
|
+
});
|
|
1037
|
+
const identities = /* @__PURE__ */ new Map();
|
|
1038
|
+
const names = /* @__PURE__ */ new Map();
|
|
1039
|
+
let command = 0, audioBytes = 0, previousTime = -1, previousServerCommand = 0, previousServerAudio = 0;
|
|
1040
|
+
const runBytes = new Map([[0, 0]]);
|
|
1041
|
+
const totals = {
|
|
1042
|
+
client: 0,
|
|
1043
|
+
server: 0
|
|
1044
|
+
};
|
|
1045
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1046
|
+
const path = `entries[${i}]`;
|
|
1047
|
+
const entry = object(entries[i], path);
|
|
1048
|
+
if (entry.direction !== "client" && entry.direction !== "server") fail(`${path}.direction`, "must be client or server");
|
|
1049
|
+
const atMs = integer(entry.atMs, `${path}.atMs`);
|
|
1050
|
+
if (atMs < previousTime || atMs > limits.maxDurationMs) fail(`${path}.atMs`, "must be monotonic and within duration limit");
|
|
1051
|
+
previousTime = atMs;
|
|
1052
|
+
const event = object(entry.event, `${path}.event`);
|
|
1053
|
+
const type = string(event.type, `${path}.event.type`);
|
|
1054
|
+
const client = entry.direction === "client";
|
|
1055
|
+
if (client) {
|
|
1056
|
+
validateClientShape(event, `${path}.event`);
|
|
1057
|
+
if (capture.source === "provider" && DOCUMENTED_ONLY.has(type)) fail(`${path}.event.type`, "unsupported client command for this capture source");
|
|
1058
|
+
} else if (Object.hasOwn(SERVER_SCHEMAS, type)) shape(event, SERVER_SCHEMAS[type], `${path}.event`);
|
|
1059
|
+
if (Buffer.byteLength(JSON.stringify(event)) > limits.maxMessageBytes) fail(`${path}.event`, "exceeds message byte limit");
|
|
1060
|
+
if (type === "error") fail(`${path}.event`, "error probes are not successful fixtures");
|
|
1061
|
+
if (i === 0 && (!client || type !== "session.start")) fail(path, "must begin with client session.start");
|
|
1062
|
+
if (type === "session.start") {
|
|
1063
|
+
if (!client || i !== 0) fail(`${path}.event.type`, "session.start is only valid at startup");
|
|
1064
|
+
if (canonical(event.session) !== canonical(config)) fail(`${path}.event.session`, "must equal configuration");
|
|
1065
|
+
}
|
|
1066
|
+
if (type === "session.update" && client) {
|
|
1067
|
+
const patch = object(event.session, `${path}.event.session`);
|
|
1068
|
+
const del = object(patch.delegation, `${path}.event.session.delegation`);
|
|
1069
|
+
const backend = object(del.responses, `${path}.event.session.delegation.responses`);
|
|
1070
|
+
if (root.mode !== "managed" || Object.keys(patch).some((key) => key !== "delegation") || Object.keys(del).some((key) => key !== "type" && key !== "responses") || del.type !== void 0 && del.type !== "responses" || Object.keys(backend).some((key) => key !== "instructions") || !Object.hasOwn(backend, "instructions")) fail(`${path}.event.session`, "only observed backend instructions update is supported");
|
|
1071
|
+
}
|
|
1072
|
+
if (client && type === "session.update") {
|
|
1073
|
+
const backend = object(object(object(event.session, `${path}.event.session`).delegation, `${path}.event.session.delegation`).responses, `${path}.event.session.delegation.responses`);
|
|
1074
|
+
const del = object(effectiveConfiguration.delegation, "configuration.delegation");
|
|
1075
|
+
effectiveConfiguration = {
|
|
1076
|
+
...effectiveConfiguration,
|
|
1077
|
+
delegation: {
|
|
1078
|
+
...del,
|
|
1079
|
+
responses: {
|
|
1080
|
+
...object(del.responses, "configuration.delegation.responses"),
|
|
1081
|
+
instructions: backend.instructions
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
if (!client && [
|
|
1087
|
+
"session.started",
|
|
1088
|
+
"session.updated",
|
|
1089
|
+
"session.closed"
|
|
1090
|
+
].includes(type)) matchConfiguration(effectiveConfiguration, event.session, `${path}.event.session`);
|
|
1091
|
+
if (!client && type === "response.event") {
|
|
1092
|
+
const nested = object(event.event, `${path}.event.event`);
|
|
1093
|
+
if (lifecycle.has(String(nested.type))) string(object(nested.response, `${path}.event.event.response`).id, `${path}.event.event.response.id`);
|
|
1094
|
+
if (["response.output_item.added", "response.output_item.done"].includes(String(nested.type)) && object(nested.item, `${path}.event.event.item`).type === "function_call") {
|
|
1095
|
+
const item = object(nested.item, `${path}.event.event.item`);
|
|
1096
|
+
for (const field of [
|
|
1097
|
+
"id",
|
|
1098
|
+
"call_id",
|
|
1099
|
+
"name"
|
|
1100
|
+
]) string(item[field], `${path}.event.event.item.${field}`);
|
|
1101
|
+
if (typeof item.arguments !== "string") fail(`${path}.event.event.item.arguments`, "must be a string");
|
|
1102
|
+
}
|
|
1103
|
+
if (["response.function_call_arguments.delta", "response.function_call_arguments.done"].includes(String(nested.type))) string(nested.item_id, `${path}.event.event.item_id`);
|
|
1104
|
+
}
|
|
1105
|
+
let decoded = 0;
|
|
1106
|
+
if (client && type === "session.input_audio.append" || !client && type === "session.output_audio.delta") {
|
|
1107
|
+
decoded = pcmBytes(event[client ? "audio" : "delta"], `${path}.event.${client ? "audio" : "delta"}`, limits.maxDecodedAudioBytes - totals[entry.direction]);
|
|
1108
|
+
totals[entry.direction] += decoded;
|
|
1109
|
+
}
|
|
1110
|
+
if (client) {
|
|
1111
|
+
if (entry.barrier !== void 0) fail(`${path}.barrier`, "client entries cannot have barriers");
|
|
1112
|
+
if (type === "session.input_audio.append") audioBytes += decoded;
|
|
1113
|
+
else {
|
|
1114
|
+
command++;
|
|
1115
|
+
audioBytes = 0;
|
|
1116
|
+
}
|
|
1117
|
+
runBytes.set(command, audioBytes);
|
|
1118
|
+
} else {
|
|
1119
|
+
const barrier = object(entry.barrier, `${path}.barrier`);
|
|
1120
|
+
const c = integer(barrier.command, `${path}.barrier.command`);
|
|
1121
|
+
const a = integer(barrier.audioBytes, `${path}.barrier.audioBytes`);
|
|
1122
|
+
if (a % 2 || c > command || a > (runBytes.get(c) ?? -1) || c < previousServerCommand || c === previousServerCommand && a < previousServerAudio) fail(`${path}.barrier`, "must be monotonic, sample-aligned and within preceding client prefix");
|
|
1123
|
+
previousServerCommand = c;
|
|
1124
|
+
previousServerAudio = a;
|
|
1125
|
+
}
|
|
1126
|
+
if (i === terminal && (client || type !== "session.closed" || !["close_requested", "remote_hangup"].includes(String(event.reason)))) fail("capture.terminalEntry", "must identify successful server session.closed");
|
|
1127
|
+
if (i !== terminal && type === "session.closed") fail(`${path}.event.type`, "session.closed must be terminal");
|
|
1128
|
+
const sites = bindingSites(event, entry.direction);
|
|
1129
|
+
const annotated = /* @__PURE__ */ new Set();
|
|
1130
|
+
const ordered = (byEntry.get(i) ?? []).slice().sort((a, b) => {
|
|
1131
|
+
const rank = (binding) => binding.action === "reference" ? 2 : binding.origin === "imported-context" ? 1 : 0;
|
|
1132
|
+
return rank(a.binding) - rank(b.binding);
|
|
1133
|
+
});
|
|
1134
|
+
for (const { binding, path: bindingPath } of ordered) {
|
|
1135
|
+
const ptr = string(binding.pointer, `${bindingPath}.pointer`);
|
|
1136
|
+
const value = pointer(event, ptr);
|
|
1137
|
+
const site = sites.get(ptr);
|
|
1138
|
+
if (!site || typeof value !== "string" || !value.length) fail(`${bindingPath}.pointer`, "not a non-null described identifier field");
|
|
1139
|
+
if (annotated.has(ptr)) fail(bindingPath, "duplicate pointer annotation");
|
|
1140
|
+
annotated.add(ptr);
|
|
1141
|
+
const name = string(binding.name, `${bindingPath}.name`);
|
|
1142
|
+
if (binding.owner !== site.owner) fail(`${bindingPath}.owner`, "does not match descriptor");
|
|
1143
|
+
if (binding.action !== "define" && binding.action !== "reference") fail(`${bindingPath}.action`, "must be define or reference");
|
|
1144
|
+
if (binding.origin !== void 0 && binding.origin !== "observed" && binding.origin !== "imported-context") fail(`${bindingPath}.origin`, "invalid origin");
|
|
1145
|
+
const imported = binding.origin === "imported-context";
|
|
1146
|
+
if (imported && (binding.action !== "define" || !site.imported || client || site.owner !== "server")) fail(`${bindingPath}.origin`, "illegal imported-context site");
|
|
1147
|
+
const key = JSON.stringify([site.namespace, value]);
|
|
1148
|
+
const prior = identities.get(key);
|
|
1149
|
+
const named = names.get(name);
|
|
1150
|
+
if (binding.action === "define") {
|
|
1151
|
+
if (!site.define && !imported || prior || named) fail(bindingPath, "invalid or duplicate identity definition");
|
|
1152
|
+
identities.set(key, {
|
|
1153
|
+
name,
|
|
1154
|
+
owner: site.owner,
|
|
1155
|
+
value
|
|
1156
|
+
});
|
|
1157
|
+
names.set(name, {
|
|
1158
|
+
namespace: site.namespace,
|
|
1159
|
+
owner: site.owner,
|
|
1160
|
+
value,
|
|
1161
|
+
...client ? { acceptedAt: {
|
|
1162
|
+
command,
|
|
1163
|
+
audioBytes
|
|
1164
|
+
} } : {}
|
|
1165
|
+
});
|
|
1166
|
+
} else if (!prior || !named || prior.name !== name || named.namespace !== site.namespace || named.owner !== site.owner || named.value !== value) fail(bindingPath, "reference precedes definition or violates identifier bijection");
|
|
1167
|
+
else if (!client && named.acceptedAt && (previousServerCommand < named.acceptedAt.command || previousServerCommand === named.acceptedAt.command && previousServerAudio < named.acceptedAt.audioBytes)) fail(`${path}.barrier`, `precedes referenced client input at ${ptr}`);
|
|
1168
|
+
}
|
|
1169
|
+
for (const ptr of sites.keys()) if (!annotated.has(ptr)) fail(`${path}.event${ptr}`, "missing identifier binding");
|
|
1170
|
+
}
|
|
1171
|
+
return root;
|
|
1172
|
+
}
|
|
1173
|
+
function normalizeLiveFixture(value, options = {}) {
|
|
1174
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) fail("response", "must be an object");
|
|
1175
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, "live");
|
|
1176
|
+
if (!descriptor || !("value" in descriptor)) fail("response.live", "must be an own data property");
|
|
1177
|
+
const timing = Object.getOwnPropertyDescriptor(value, "liveTiming");
|
|
1178
|
+
if (timing && (!("value" in timing) || timing.value !== "recorded" && timing.value !== "immediate")) fail("response.liveTiming", "must be recorded or immediate");
|
|
1179
|
+
const live = validateLiveTranscript(descriptor.value, options);
|
|
1180
|
+
return timing ? {
|
|
1181
|
+
live,
|
|
1182
|
+
liveTiming: timing.value
|
|
1183
|
+
} : { live };
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
//#endregion
|
|
1187
|
+
exports.bindingSites = bindingSites;
|
|
1188
|
+
exports.normalizeLiveFixture = normalizeLiveFixture;
|
|
1189
|
+
exports.normalizeLiveOptions = normalizeLiveOptions;
|
|
1190
|
+
exports.validateLiveClientEvent = validateLiveClientEvent;
|
|
1191
|
+
exports.validateLiveTranscript = validateLiveTranscript;
|
|
1192
|
+
//# sourceMappingURL=live-fixture.cjs.map
|