openai 7.5.0 → 7.6.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/CHANGELOG.md +105 -0
- package/README.md +46 -2
- package/auth/index.d.mts +1 -1
- package/auth/index.d.mts.map +1 -1
- package/auth/index.d.ts +1 -1
- package/auth/index.d.ts.map +1 -1
- package/auth/index.js.map +1 -1
- package/auth/index.mjs.map +1 -1
- package/auth/subject-token-providers.d.mts.map +1 -1
- package/auth/subject-token-providers.d.ts.map +1 -1
- package/auth/subject-token-providers.js +176 -4
- package/auth/subject-token-providers.js.map +1 -1
- package/auth/subject-token-providers.mjs +176 -4
- package/auth/subject-token-providers.mjs.map +1 -1
- package/auth/types.d.mts +17 -0
- package/auth/types.d.mts.map +1 -1
- package/auth/types.d.ts +17 -0
- package/auth/types.d.ts.map +1 -1
- package/auth/workload-identity-auth.d.mts.map +1 -1
- package/auth/workload-identity-auth.d.ts.map +1 -1
- package/auth/workload-identity-auth.js +80 -7
- package/auth/workload-identity-auth.js.map +1 -1
- package/auth/workload-identity-auth.mjs +80 -7
- package/auth/workload-identity-auth.mjs.map +1 -1
- package/auth/x509-transport.d.mts +5 -0
- package/auth/x509-transport.d.mts.map +1 -0
- package/auth/x509-transport.d.ts +5 -0
- package/auth/x509-transport.d.ts.map +1 -0
- package/auth/x509-transport.js +39 -0
- package/auth/x509-transport.js.map +1 -0
- package/auth/x509-transport.mjs +36 -0
- package/auth/x509-transport.mjs.map +1 -0
- package/azure.d.mts +11 -2
- package/azure.d.mts.map +1 -1
- package/azure.d.ts +11 -2
- package/azure.d.ts.map +1 -1
- package/azure.js +7 -1
- package/azure.js.map +1 -1
- package/azure.mjs +7 -1
- package/azure.mjs.map +1 -1
- package/bedrock.d.mts +6 -2
- package/bedrock.d.mts.map +1 -1
- package/bedrock.d.ts +6 -2
- package/bedrock.d.ts.map +1 -1
- package/bedrock.js +34 -4
- package/bedrock.js.map +1 -1
- package/bedrock.mjs +35 -5
- package/bedrock.mjs.map +1 -1
- package/beta/realtime/internal-base.d.mts +2 -0
- package/beta/realtime/internal-base.d.mts.map +1 -1
- package/beta/realtime/internal-base.d.ts +2 -0
- package/beta/realtime/internal-base.d.ts.map +1 -1
- package/beta/realtime/internal-base.js +15 -0
- package/beta/realtime/internal-base.js.map +1 -1
- package/beta/realtime/internal-base.mjs +14 -0
- package/beta/realtime/internal-base.mjs.map +1 -1
- package/beta/realtime/websocket.d.mts +11 -5
- package/beta/realtime/websocket.d.mts.map +1 -1
- package/beta/realtime/websocket.d.ts +11 -5
- package/beta/realtime/websocket.d.ts.map +1 -1
- package/beta/realtime/websocket.js +106 -31
- package/beta/realtime/websocket.js.map +1 -1
- package/beta/realtime/websocket.mjs +107 -32
- package/beta/realtime/websocket.mjs.map +1 -1
- package/beta/realtime/ws.d.mts +0 -2
- package/beta/realtime/ws.d.mts.map +1 -1
- package/beta/realtime/ws.d.ts +0 -2
- package/beta/realtime/ws.d.ts.map +1 -1
- package/beta/realtime/ws.js +24 -5
- package/beta/realtime/ws.js.map +1 -1
- package/beta/realtime/ws.mjs +25 -6
- package/beta/realtime/ws.mjs.map +1 -1
- package/client.d.mts +17 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +17 -2
- package/client.d.ts.map +1 -1
- package/client.js +422 -70
- package/client.js.map +1 -1
- package/client.mjs +423 -71
- package/client.mjs.map +1 -1
- package/core/EventEmitter.d.mts.map +1 -1
- package/core/EventEmitter.d.ts.map +1 -1
- package/core/EventEmitter.js +67 -9
- package/core/EventEmitter.js.map +1 -1
- package/core/EventEmitter.mjs +68 -10
- package/core/EventEmitter.mjs.map +1 -1
- package/core/streaming.d.mts +1 -0
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts +1 -0
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +58 -19
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +58 -19
- package/core/streaming.mjs.map +1 -1
- package/helpers/audio.d.mts +5 -5
- package/helpers/audio.d.mts.map +1 -1
- package/helpers/audio.d.ts +5 -5
- package/helpers/audio.d.ts.map +1 -1
- package/helpers/audio.js +93 -22
- package/helpers/audio.js.map +1 -1
- package/helpers/audio.mjs +93 -22
- package/helpers/audio.mjs.map +1 -1
- package/helpers/standard-schema.d.mts.map +1 -1
- package/helpers/standard-schema.d.ts.map +1 -1
- package/helpers/standard-schema.js +34 -14
- package/helpers/standard-schema.js.map +1 -1
- package/helpers/standard-schema.mjs +35 -15
- package/helpers/standard-schema.mjs.map +1 -1
- package/helpers/zod-v3-strict-schema.d.mts +7 -0
- package/helpers/zod-v3-strict-schema.d.mts.map +1 -0
- package/helpers/zod-v3-strict-schema.d.ts +7 -0
- package/helpers/zod-v3-strict-schema.d.ts.map +1 -0
- package/helpers/zod-v3-strict-schema.js +403 -0
- package/helpers/zod-v3-strict-schema.js.map +1 -0
- package/helpers/zod-v3-strict-schema.mjs +399 -0
- package/helpers/zod-v3-strict-schema.mjs.map +1 -0
- package/helpers/zod.d.mts.map +1 -1
- package/helpers/zod.d.ts.map +1 -1
- package/helpers/zod.js +11 -3
- package/helpers/zod.js.map +1 -1
- package/helpers/zod.mjs +12 -4
- package/helpers/zod.mjs.map +1 -1
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/internal/assistant-stream-delta.d.mts.map +1 -1
- package/internal/assistant-stream-delta.d.ts.map +1 -1
- package/internal/assistant-stream-delta.js +28 -8
- package/internal/assistant-stream-delta.js.map +1 -1
- package/internal/assistant-stream-delta.mjs +28 -8
- package/internal/assistant-stream-delta.mjs.map +1 -1
- package/internal/auth/x509-token-exchange.d.mts +16 -0
- package/internal/auth/x509-token-exchange.d.mts.map +1 -0
- package/internal/auth/x509-token-exchange.d.ts +16 -0
- package/internal/auth/x509-token-exchange.d.ts.map +1 -0
- package/internal/auth/x509-token-exchange.js +246 -0
- package/internal/auth/x509-token-exchange.js.map +1 -0
- package/internal/auth/x509-token-exchange.mjs +243 -0
- package/internal/auth/x509-token-exchange.mjs.map +1 -0
- package/internal/auth/x509-transport-capability.d.mts +37 -0
- package/internal/auth/x509-transport-capability.d.mts.map +1 -0
- package/internal/auth/x509-transport-capability.d.ts +37 -0
- package/internal/auth/x509-transport-capability.d.ts.map +1 -0
- package/internal/auth/x509-transport-capability.js +169 -0
- package/internal/auth/x509-transport-capability.js.map +1 -0
- package/internal/auth/x509-transport-capability.mjs +164 -0
- package/internal/auth/x509-transport-capability.mjs.map +1 -0
- package/internal/auth/x509-transport-registry.d.mts +63 -0
- package/internal/auth/x509-transport-registry.d.mts.map +1 -0
- package/internal/auth/x509-transport-registry.d.ts +63 -0
- package/internal/auth/x509-transport-registry.d.ts.map +1 -0
- package/internal/auth/x509-transport-registry.js +53 -0
- package/internal/auth/x509-transport-registry.js.map +1 -0
- package/internal/auth/x509-transport-registry.mjs +48 -0
- package/internal/auth/x509-transport-registry.mjs.map +1 -0
- package/internal/auth/x509-transport-state-browser.d.mts +21 -0
- package/internal/auth/x509-transport-state-browser.d.mts.map +1 -0
- package/internal/auth/x509-transport-state-browser.d.ts +21 -0
- package/internal/auth/x509-transport-state-browser.d.ts.map +1 -0
- package/internal/auth/x509-transport-state-browser.js +30 -0
- package/internal/auth/x509-transport-state-browser.js.map +1 -0
- package/internal/auth/x509-transport-state-browser.mjs +27 -0
- package/internal/auth/x509-transport-state-browser.mjs.map +1 -0
- package/internal/auth/x509-transport-state.cjs +30 -0
- package/internal/auth/x509-transport-state.cjs.map +1 -0
- package/internal/auth/x509-transport-state.d.cts +21 -0
- package/internal/auth/x509-transport-state.d.cts.map +1 -0
- package/internal/auth/x509-workload-identity-auth.d.mts +128 -0
- package/internal/auth/x509-workload-identity-auth.d.mts.map +1 -0
- package/internal/auth/x509-workload-identity-auth.d.ts +128 -0
- package/internal/auth/x509-workload-identity-auth.d.ts.map +1 -0
- package/internal/auth/x509-workload-identity-auth.js +767 -0
- package/internal/auth/x509-workload-identity-auth.js.map +1 -0
- package/internal/auth/x509-workload-identity-auth.mjs +757 -0
- package/internal/auth/x509-workload-identity-auth.mjs.map +1 -0
- package/internal/bedrock.d.mts +2 -0
- package/internal/bedrock.d.mts.map +1 -1
- package/internal/bedrock.d.ts +2 -0
- package/internal/bedrock.d.ts.map +1 -1
- package/internal/bedrock.js +169 -5
- package/internal/bedrock.js.map +1 -1
- package/internal/bedrock.mjs +168 -5
- package/internal/bedrock.mjs.map +1 -1
- package/internal/data-residency.d.mts +12 -0
- package/internal/data-residency.d.mts.map +1 -0
- package/internal/data-residency.d.ts +12 -0
- package/internal/data-residency.d.ts.map +1 -0
- package/internal/data-residency.js +34 -0
- package/internal/data-residency.js.map +1 -0
- package/internal/data-residency.mjs +30 -0
- package/internal/data-residency.mjs.map +1 -0
- package/internal/multipart-encoding.d.mts +8 -0
- package/internal/multipart-encoding.d.mts.map +1 -0
- package/internal/multipart-encoding.d.ts +8 -0
- package/internal/multipart-encoding.d.ts.map +1 -0
- package/internal/multipart-encoding.js +51 -0
- package/internal/multipart-encoding.js.map +1 -0
- package/internal/multipart-encoding.mjs +48 -0
- package/internal/multipart-encoding.mjs.map +1 -0
- package/internal/qs/utils.d.mts.map +1 -1
- package/internal/qs/utils.d.ts.map +1 -1
- package/internal/qs/utils.js +307 -10
- package/internal/qs/utils.js.map +1 -1
- package/internal/qs/utils.mjs +307 -10
- package/internal/qs/utils.mjs.map +1 -1
- package/internal/request-options.d.mts +7 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +7 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js +43 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs +42 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/responses/canonical-output-text.js +3 -3
- package/internal/responses/canonical-output-text.js.map +1 -1
- package/internal/responses/canonical-output-text.mjs +3 -3
- package/internal/responses/canonical-output-text.mjs.map +1 -1
- package/internal/responses/response-accumulator.d.mts +1 -1
- package/internal/responses/response-accumulator.d.mts.map +1 -1
- package/internal/responses/response-accumulator.d.ts +1 -1
- package/internal/responses/response-accumulator.d.ts.map +1 -1
- package/internal/responses/response-accumulator.js +331 -25
- package/internal/responses/response-accumulator.js.map +1 -1
- package/internal/responses/response-accumulator.mjs +331 -25
- package/internal/responses/response-accumulator.mjs.map +1 -1
- package/internal/tslib.js +6 -0
- package/internal/tslib.mjs +6 -1
- package/internal/uploads.d.mts +10 -6
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +10 -6
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +65 -24
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +65 -24
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/env.d.mts.map +1 -1
- package/internal/utils/env.d.ts.map +1 -1
- package/internal/utils/env.js +9 -4
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs +9 -4
- package/internal/utils/env.mjs.map +1 -1
- package/internal/ws.d.mts.map +1 -1
- package/internal/ws.d.ts.map +1 -1
- package/internal/ws.js +23 -1
- package/internal/ws.js.map +1 -1
- package/internal/ws.mjs +23 -1
- package/internal/ws.mjs.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
- package/lib/AbstractChatCompletionRunner.js +32 -7
- package/lib/AbstractChatCompletionRunner.js.map +1 -1
- package/lib/AbstractChatCompletionRunner.mjs +34 -9
- package/lib/AbstractChatCompletionRunner.mjs.map +1 -1
- package/lib/AssistantStream.d.mts.map +1 -1
- package/lib/AssistantStream.d.ts.map +1 -1
- package/lib/AssistantStream.js +211 -23
- package/lib/AssistantStream.js.map +1 -1
- package/lib/AssistantStream.mjs +211 -23
- package/lib/AssistantStream.mjs.map +1 -1
- package/lib/ChatCompletionStream.d.mts +1 -1
- package/lib/ChatCompletionStream.d.mts.map +1 -1
- package/lib/ChatCompletionStream.d.ts +1 -1
- package/lib/ChatCompletionStream.d.ts.map +1 -1
- package/lib/ChatCompletionStream.js +1118 -67
- package/lib/ChatCompletionStream.js.map +1 -1
- package/lib/ChatCompletionStream.mjs +1119 -68
- package/lib/ChatCompletionStream.mjs.map +1 -1
- package/lib/EventEmitter.d.mts.map +1 -1
- package/lib/EventEmitter.d.ts.map +1 -1
- package/lib/EventEmitter.js +67 -9
- package/lib/EventEmitter.js.map +1 -1
- package/lib/EventEmitter.mjs +68 -10
- package/lib/EventEmitter.mjs.map +1 -1
- package/lib/EventStream.d.mts +4 -0
- package/lib/EventStream.d.mts.map +1 -1
- package/lib/EventStream.d.ts +4 -0
- package/lib/EventStream.d.ts.map +1 -1
- package/lib/EventStream.js +1096 -11
- package/lib/EventStream.js.map +1 -1
- package/lib/EventStream.mjs +1097 -12
- package/lib/EventStream.mjs.map +1 -1
- package/lib/ResponsesParser.d.mts.map +1 -1
- package/lib/ResponsesParser.d.ts.map +1 -1
- package/lib/ResponsesParser.js +1 -1
- package/lib/ResponsesParser.js.map +1 -1
- package/lib/ResponsesParser.mjs +1 -1
- package/lib/ResponsesParser.mjs.map +1 -1
- package/lib/Util.d.mts +2 -0
- package/lib/Util.d.mts.map +1 -1
- package/lib/Util.d.ts +2 -0
- package/lib/Util.d.ts.map +1 -1
- package/lib/Util.js +7 -4
- package/lib/Util.js.map +1 -1
- package/lib/Util.mjs +7 -4
- package/lib/Util.mjs.map +1 -1
- package/lib/assistant-run-polling.d.mts +12 -0
- package/lib/assistant-run-polling.d.mts.map +1 -0
- package/lib/assistant-run-polling.d.ts +12 -0
- package/lib/assistant-run-polling.d.ts.map +1 -0
- package/lib/assistant-run-polling.js +17 -0
- package/lib/assistant-run-polling.js.map +1 -0
- package/lib/assistant-run-polling.mjs +14 -0
- package/lib/assistant-run-polling.mjs.map +1 -0
- package/lib/embeddings.d.mts +18 -0
- package/lib/embeddings.d.mts.map +1 -0
- package/lib/embeddings.d.ts +18 -0
- package/lib/embeddings.d.ts.map +1 -0
- package/lib/embeddings.js +50 -0
- package/lib/embeddings.js.map +1 -0
- package/lib/embeddings.mjs +47 -0
- package/lib/embeddings.mjs.map +1 -0
- package/lib/file-processing.d.mts +10 -0
- package/lib/file-processing.d.mts.map +1 -0
- package/lib/file-processing.d.ts +10 -0
- package/lib/file-processing.d.ts.map +1 -0
- package/lib/file-processing.js +30 -0
- package/lib/file-processing.js.map +1 -0
- package/lib/file-processing.mjs +27 -0
- package/lib/file-processing.mjs.map +1 -0
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js +16 -4
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs +16 -4
- package/lib/parser.mjs.map +1 -1
- package/lib/polling.d.mts +20 -0
- package/lib/polling.d.mts.map +1 -0
- package/lib/polling.d.ts +20 -0
- package/lib/polling.d.ts.map +1 -0
- package/lib/polling.js +130 -0
- package/lib/polling.js.map +1 -0
- package/lib/polling.mjs +127 -0
- package/lib/polling.mjs.map +1 -0
- package/lib/responses/ResponseStream.d.mts.map +1 -1
- package/lib/responses/ResponseStream.d.ts.map +1 -1
- package/lib/responses/ResponseStream.js +21 -11
- package/lib/responses/ResponseStream.js.map +1 -1
- package/lib/responses/ResponseStream.mjs +21 -11
- package/lib/responses/ResponseStream.mjs.map +1 -1
- package/lib/vector-store-polling.d.mts +22 -0
- package/lib/vector-store-polling.d.mts.map +1 -0
- package/lib/vector-store-polling.d.ts +22 -0
- package/lib/vector-store-polling.d.ts.map +1 -0
- package/lib/vector-store-polling.js +24 -0
- package/lib/vector-store-polling.js.map +1 -0
- package/lib/vector-store-polling.mjs +20 -0
- package/lib/vector-store-polling.mjs.map +1 -0
- package/lib/vector-store-upload.d.mts +17 -0
- package/lib/vector-store-upload.d.mts.map +1 -0
- package/lib/vector-store-upload.d.ts +17 -0
- package/lib/vector-store-upload.d.ts.map +1 -0
- package/lib/vector-store-upload.js +37 -0
- package/lib/vector-store-upload.js.map +1 -0
- package/lib/vector-store-upload.mjs +34 -0
- package/lib/vector-store-upload.mjs.map +1 -0
- package/lib/webhook-signature.d.mts +15 -0
- package/lib/webhook-signature.d.mts.map +1 -0
- package/lib/webhook-signature.d.ts +15 -0
- package/lib/webhook-signature.d.ts.map +1 -0
- package/lib/webhook-signature.js +125 -0
- package/lib/webhook-signature.js.map +1 -0
- package/lib/webhook-signature.mjs +121 -0
- package/lib/webhook-signature.mjs.map +1 -0
- package/package.json +14 -1
- package/realtime/internal-base.d.mts +2 -0
- package/realtime/internal-base.d.mts.map +1 -1
- package/realtime/internal-base.d.ts +2 -0
- package/realtime/internal-base.d.ts.map +1 -1
- package/realtime/internal-base.js +15 -0
- package/realtime/internal-base.js.map +1 -1
- package/realtime/internal-base.mjs +14 -0
- package/realtime/internal-base.mjs.map +1 -1
- package/realtime/websocket.d.mts +3 -2
- package/realtime/websocket.d.mts.map +1 -1
- package/realtime/websocket.d.ts +3 -2
- package/realtime/websocket.d.ts.map +1 -1
- package/realtime/websocket.js +90 -26
- package/realtime/websocket.js.map +1 -1
- package/realtime/websocket.mjs +91 -27
- package/realtime/websocket.mjs.map +1 -1
- package/realtime/ws.d.mts.map +1 -1
- package/realtime/ws.d.ts.map +1 -1
- package/realtime/ws.js +9 -1
- package/realtime/ws.js.map +1 -1
- package/realtime/ws.mjs +10 -2
- package/realtime/ws.mjs.map +1 -1
- package/resources/admin/organization/index.d.mts +2 -2
- package/resources/admin/organization/index.d.mts.map +1 -1
- package/resources/admin/organization/index.d.ts +2 -2
- package/resources/admin/organization/index.d.ts.map +1 -1
- package/resources/admin/organization/index.js.map +1 -1
- package/resources/admin/organization/index.mjs.map +1 -1
- package/resources/admin/organization/organization.d.mts +4 -4
- package/resources/admin/organization/organization.d.mts.map +1 -1
- package/resources/admin/organization/organization.d.ts +4 -4
- package/resources/admin/organization/organization.d.ts.map +1 -1
- package/resources/admin/organization/organization.js.map +1 -1
- package/resources/admin/organization/organization.mjs.map +1 -1
- package/resources/admin/organization/projects/index.d.mts +1 -1
- package/resources/admin/organization/projects/index.d.mts.map +1 -1
- package/resources/admin/organization/projects/index.d.ts +1 -1
- package/resources/admin/organization/projects/index.d.ts.map +1 -1
- package/resources/admin/organization/projects/index.js.map +1 -1
- package/resources/admin/organization/projects/index.mjs.map +1 -1
- package/resources/admin/organization/projects/projects.d.mts +22 -5
- package/resources/admin/organization/projects/projects.d.mts.map +1 -1
- package/resources/admin/organization/projects/projects.d.ts +22 -5
- package/resources/admin/organization/projects/projects.d.ts.map +1 -1
- package/resources/admin/organization/projects/projects.js.map +1 -1
- package/resources/admin/organization/projects/projects.mjs.map +1 -1
- package/resources/admin/organization/usage.d.mts +62 -1
- package/resources/admin/organization/usage.d.mts.map +1 -1
- package/resources/admin/organization/usage.d.ts +62 -1
- package/resources/admin/organization/usage.d.ts.map +1 -1
- package/resources/admin/organization/usage.js.map +1 -1
- package/resources/admin/organization/usage.mjs.map +1 -1
- package/resources/beta/responses/internal-base.d.mts.map +1 -1
- package/resources/beta/responses/internal-base.d.ts.map +1 -1
- package/resources/beta/responses/internal-base.js +2 -0
- package/resources/beta/responses/internal-base.js.map +1 -1
- package/resources/beta/responses/internal-base.mjs +2 -0
- package/resources/beta/responses/internal-base.mjs.map +1 -1
- package/resources/beta/responses/responses.d.mts +9 -12
- package/resources/beta/responses/responses.d.mts.map +1 -1
- package/resources/beta/responses/responses.d.ts +9 -12
- package/resources/beta/responses/responses.d.ts.map +1 -1
- package/resources/beta/responses/responses.js.map +1 -1
- package/resources/beta/responses/responses.mjs.map +1 -1
- package/resources/beta/threads/runs/index.d.mts +1 -1
- package/resources/beta/threads/runs/index.d.mts.map +1 -1
- package/resources/beta/threads/runs/index.d.ts +1 -1
- package/resources/beta/threads/runs/index.d.ts.map +1 -1
- package/resources/beta/threads/runs/runs.d.mts.map +1 -1
- package/resources/beta/threads/runs/runs.d.ts.map +1 -1
- package/resources/beta/threads/runs/runs.js +2 -43
- package/resources/beta/threads/runs/runs.js.map +1 -1
- package/resources/beta/threads/runs/runs.mjs +2 -43
- package/resources/beta/threads/runs/runs.mjs.map +1 -1
- package/resources/chat/completions/completions.d.mts +6 -0
- package/resources/chat/completions/completions.d.mts.map +1 -1
- package/resources/chat/completions/completions.d.ts +6 -0
- package/resources/chat/completions/completions.d.ts.map +1 -1
- package/resources/chat/completions/completions.js.map +1 -1
- package/resources/chat/completions/completions.mjs.map +1 -1
- package/resources/embeddings.d.mts.map +1 -1
- package/resources/embeddings.d.ts.map +1 -1
- package/resources/embeddings.js +2 -36
- package/resources/embeddings.js.map +1 -1
- package/resources/embeddings.mjs +2 -36
- package/resources/embeddings.mjs.map +1 -1
- package/resources/files.d.mts.map +1 -1
- package/resources/files.d.ts.map +1 -1
- package/resources/files.js +2 -15
- package/resources/files.js.map +1 -1
- package/resources/files.mjs +2 -15
- package/resources/files.mjs.map +1 -1
- package/resources/images.d.mts +12 -22
- package/resources/images.d.mts.map +1 -1
- package/resources/images.d.ts +12 -22
- package/resources/images.d.ts.map +1 -1
- package/resources/realtime/calls.d.mts +23 -1
- package/resources/realtime/calls.d.mts.map +1 -1
- package/resources/realtime/calls.d.ts +23 -1
- package/resources/realtime/calls.d.ts.map +1 -1
- package/resources/realtime/calls.js +24 -0
- package/resources/realtime/calls.js.map +1 -1
- package/resources/realtime/calls.mjs +24 -0
- package/resources/realtime/calls.mjs.map +1 -1
- package/resources/realtime/index.d.mts +1 -1
- package/resources/realtime/index.d.mts.map +1 -1
- package/resources/realtime/index.d.ts +1 -1
- package/resources/realtime/index.d.ts.map +1 -1
- package/resources/realtime/index.js.map +1 -1
- package/resources/realtime/index.mjs +1 -1
- package/resources/realtime/index.mjs.map +1 -1
- package/resources/realtime/realtime.d.mts +5 -4
- package/resources/realtime/realtime.d.mts.map +1 -1
- package/resources/realtime/realtime.d.ts +5 -4
- package/resources/realtime/realtime.d.ts.map +1 -1
- package/resources/realtime/realtime.js.map +1 -1
- package/resources/realtime/realtime.mjs.map +1 -1
- package/resources/responses/internal-base.d.mts.map +1 -1
- package/resources/responses/internal-base.d.ts.map +1 -1
- package/resources/responses/internal-base.js +2 -0
- package/resources/responses/internal-base.js.map +1 -1
- package/resources/responses/internal-base.mjs +2 -0
- package/resources/responses/internal-base.mjs.map +1 -1
- package/resources/responses/responses.d.mts +9 -12
- package/resources/responses/responses.d.mts.map +1 -1
- package/resources/responses/responses.d.ts +9 -12
- package/resources/responses/responses.d.ts.map +1 -1
- package/resources/responses/responses.js.map +1 -1
- package/resources/responses/responses.mjs.map +1 -1
- package/resources/vector-stores/file-batches.d.mts.map +1 -1
- package/resources/vector-stores/file-batches.d.ts.map +1 -1
- package/resources/vector-stores/file-batches.js +4 -61
- package/resources/vector-stores/file-batches.js.map +1 -1
- package/resources/vector-stores/file-batches.mjs +4 -61
- package/resources/vector-stores/file-batches.mjs.map +1 -1
- package/resources/vector-stores/files.d.mts +1 -1
- package/resources/vector-stores/files.d.mts.map +1 -1
- package/resources/vector-stores/files.d.ts +1 -1
- package/resources/vector-stores/files.d.ts.map +1 -1
- package/resources/vector-stores/files.js +2 -35
- package/resources/vector-stores/files.js.map +1 -1
- package/resources/vector-stores/files.mjs +2 -35
- package/resources/vector-stores/files.mjs.map +1 -1
- package/resources/webhooks/webhooks.d.mts.map +1 -1
- package/resources/webhooks/webhooks.d.ts.map +1 -1
- package/resources/webhooks/webhooks.js +5 -43
- package/resources/webhooks/webhooks.js.map +1 -1
- package/resources/webhooks/webhooks.mjs +5 -43
- package/resources/webhooks/webhooks.mjs.map +1 -1
- package/src/auth/index.ts +6 -1
- package/src/auth/subject-token-providers.ts +196 -4
- package/src/auth/types.ts +24 -0
- package/src/auth/workload-identity-auth.ts +104 -7
- package/src/auth/x509-transport.ts +49 -0
- package/src/azure.ts +22 -1
- package/src/bedrock.ts +49 -5
- package/src/beta/realtime/internal-base.ts +15 -0
- package/src/beta/realtime/websocket.ts +148 -40
- package/src/beta/realtime/ws.ts +31 -13
- package/src/client.ts +536 -92
- package/src/core/EventEmitter.ts +91 -7
- package/src/core/streaming.ts +71 -20
- package/src/helpers/audio.ts +93 -22
- package/src/helpers/standard-schema.ts +50 -16
- package/src/helpers/zod-v3-strict-schema.ts +514 -0
- package/src/helpers/zod.ts +17 -4
- package/src/index.ts +1 -1
- package/src/internal/assistant-stream-delta.ts +33 -10
- package/src/internal/auth/x509-token-exchange.ts +310 -0
- package/src/internal/auth/x509-transport-capability.ts +219 -0
- package/src/internal/auth/x509-transport-registry.ts +118 -0
- package/src/internal/auth/x509-transport-state-browser.ts +36 -0
- package/src/internal/auth/x509-transport-state.cts +36 -0
- package/src/internal/auth/x509-workload-identity-auth.ts +958 -0
- package/src/internal/bedrock.ts +182 -5
- package/src/internal/data-residency.ts +44 -0
- package/src/internal/multipart-encoding.ts +53 -0
- package/src/internal/qs/utils.ts +375 -13
- package/src/internal/request-options.ts +52 -1
- package/src/internal/responses/canonical-output-text.ts +3 -3
- package/src/internal/responses/response-accumulator.ts +411 -24
- package/src/internal/uploads.ts +81 -26
- package/src/internal/utils/env.ts +9 -5
- package/src/internal/ws.ts +24 -3
- package/src/lib/AbstractChatCompletionRunner.ts +33 -6
- package/src/lib/AssistantStream.ts +262 -22
- package/src/lib/ChatCompletionStream.ts +1467 -103
- package/src/lib/EventEmitter.ts +91 -7
- package/src/lib/EventStream.ts +1483 -10
- package/src/lib/ResponsesParser.ts +4 -1
- package/src/lib/Util.ts +7 -5
- package/src/lib/assistant-run-polling.ts +27 -0
- package/src/lib/embeddings.ts +65 -0
- package/src/lib/file-processing.ts +36 -0
- package/src/lib/parser.ts +19 -4
- package/src/lib/polling.ts +144 -0
- package/src/lib/responses/ResponseStream.ts +22 -10
- package/src/lib/vector-store-polling.ts +46 -0
- package/src/lib/vector-store-upload.ts +53 -0
- package/src/lib/webhook-signature.ts +164 -0
- package/src/realtime/internal-base.ts +15 -0
- package/src/realtime/websocket.ts +130 -27
- package/src/realtime/ws.ts +15 -2
- package/src/resources/admin/organization/index.ts +2 -0
- package/src/resources/admin/organization/organization.ts +4 -0
- package/src/resources/admin/organization/projects/index.ts +1 -0
- package/src/resources/admin/organization/projects/projects.ts +37 -4
- package/src/resources/admin/organization/usage.ts +83 -0
- package/src/resources/beta/responses/internal-base.ts +2 -0
- package/src/resources/beta/responses/responses.ts +9 -12
- package/src/resources/beta/threads/runs/index.ts +1 -1
- package/src/resources/beta/threads/runs/runs.ts +2 -45
- package/src/resources/chat/completions/completions.ts +7 -0
- package/src/resources/embeddings.ts +2 -42
- package/src/resources/files.ts +2 -19
- package/src/resources/images.ts +12 -22
- package/src/resources/realtime/api.md +1 -0
- package/src/resources/realtime/calls.ts +46 -0
- package/src/resources/realtime/index.ts +7 -1
- package/src/resources/realtime/realtime.ts +5 -3
- package/src/resources/responses/internal-base.ts +2 -0
- package/src/resources/responses/responses.ts +9 -12
- package/src/resources/vector-stores/file-batches.ts +8 -77
- package/src/resources/vector-stores/files.ts +3 -43
- package/src/resources/webhooks/webhooks.ts +5 -61
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
interface SchemaNode {
|
|
2
|
+
_def: SchemaDefinition;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
interface ZodV3Schema {
|
|
6
|
+
_def: unknown;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface SchemaDefinition {
|
|
10
|
+
typeName: string;
|
|
11
|
+
checks?: readonly { kind: string; value?: unknown }[];
|
|
12
|
+
coerce?: boolean;
|
|
13
|
+
shape: () => Record<string, SchemaNode>;
|
|
14
|
+
type: SchemaNode;
|
|
15
|
+
innerType: SchemaNode;
|
|
16
|
+
catchall?: SchemaNode;
|
|
17
|
+
unknownKeys?: string;
|
|
18
|
+
options: readonly SchemaNode[] | Map<unknown, SchemaNode>;
|
|
19
|
+
getter: () => SchemaNode;
|
|
20
|
+
value?: unknown;
|
|
21
|
+
values?: readonly unknown[] | Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface JSONDomain {
|
|
25
|
+
type: 'array' | 'boolean' | 'null' | 'number' | 'object' | 'string' | 'unknown';
|
|
26
|
+
values?: ReadonlySet<string | number | boolean | null>;
|
|
27
|
+
discriminators?: ReadonlyMap<string, readonly JSONDomain[]>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface SchemaChild {
|
|
31
|
+
schema: SchemaNode;
|
|
32
|
+
path: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const simpleJSONDomains: Readonly<Record<string, JSONDomain['type']>> = {
|
|
36
|
+
ZodString: 'string',
|
|
37
|
+
ZodNumber: 'number',
|
|
38
|
+
ZodBoolean: 'boolean',
|
|
39
|
+
ZodNull: 'null',
|
|
40
|
+
ZodObject: 'object',
|
|
41
|
+
ZodArray: 'array',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const transparentWrappers = new Set(['ZodOptional', 'ZodNullable', 'ZodDefault', 'ZodReadonly']);
|
|
45
|
+
|
|
46
|
+
const supportedLeaves = new Set([
|
|
47
|
+
'ZodString',
|
|
48
|
+
'ZodNumber',
|
|
49
|
+
'ZodBoolean',
|
|
50
|
+
'ZodNull',
|
|
51
|
+
'ZodEnum',
|
|
52
|
+
'ZodNativeEnum',
|
|
53
|
+
'ZodAny',
|
|
54
|
+
'ZodUnknown',
|
|
55
|
+
'ZodLiteral',
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
const unsupportedReasons = new Map([
|
|
59
|
+
['ZodBigInt', 'encode integers as decimal strings and convert with BigInt after parsing'],
|
|
60
|
+
['ZodDate', 'native dates do not have a synchronous JSON representation'],
|
|
61
|
+
['ZodMap', 'native maps do not have a synchronous JSON representation'],
|
|
62
|
+
['ZodSet', 'native sets do not have a synchronous JSON representation'],
|
|
63
|
+
['ZodPromise', 'asynchronous values do not have a synchronous JSON representation'],
|
|
64
|
+
['ZodEffects', 'custom transformations and refinements are opaque to JSON Schema'],
|
|
65
|
+
['ZodPipeline', 'custom pipelines are opaque to JSON Schema'],
|
|
66
|
+
['ZodIntersection', 'intersections cannot prove that both branches produce the same value'],
|
|
67
|
+
['ZodCatch', 'catch fallbacks cannot be proven to produce JSON-native values'],
|
|
68
|
+
['ZodTuple', 'tuple schemas require unsupported array-valued items'],
|
|
69
|
+
['ZodRecord', 'open-ended record schemas require unsupported additionalProperties'],
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
const valueChangingStringChecks = new Set(['trim', 'toLowerCase', 'toUpperCase']);
|
|
73
|
+
const patternProducingStringChecks = new Set([
|
|
74
|
+
'regex',
|
|
75
|
+
'cuid',
|
|
76
|
+
'cuid2',
|
|
77
|
+
'startsWith',
|
|
78
|
+
'endsWith',
|
|
79
|
+
'includes',
|
|
80
|
+
'emoji',
|
|
81
|
+
'ulid',
|
|
82
|
+
'nanoid',
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
function unsupported(path: string, kind: string, explanation: string): never {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Zod schema field \`${path}\` uses \`${kind}\`, which cannot be represented by strict Structured Outputs: ${explanation}`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function literalDomain(value: unknown): JSONDomain | undefined {
|
|
92
|
+
if (value === null) {
|
|
93
|
+
return { type: 'null', values: new Set([null]) };
|
|
94
|
+
}
|
|
95
|
+
if (typeof value === 'string') {
|
|
96
|
+
return { type: 'string', values: new Set([value]) };
|
|
97
|
+
}
|
|
98
|
+
if (typeof value === 'boolean') {
|
|
99
|
+
return { type: 'boolean', values: new Set([value]) };
|
|
100
|
+
}
|
|
101
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
102
|
+
return { type: 'number', values: new Set([value]) };
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function nativeEnumDomains(def: SchemaDefinition): JSONDomain[] {
|
|
108
|
+
const definitionValues = def.values;
|
|
109
|
+
if (!definitionValues || Array.isArray(definitionValues)) {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
const object = definitionValues as Record<string, unknown>;
|
|
113
|
+
const values = Object.keys(object)
|
|
114
|
+
.filter((key) => {
|
|
115
|
+
const value = object[key];
|
|
116
|
+
return (
|
|
117
|
+
(typeof value === 'string' || typeof value === 'number') && typeof object[String(value)] !== 'number'
|
|
118
|
+
);
|
|
119
|
+
})
|
|
120
|
+
.map((key) => object[key])
|
|
121
|
+
.filter(
|
|
122
|
+
(value): value is string | number =>
|
|
123
|
+
typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value)),
|
|
124
|
+
);
|
|
125
|
+
return (['string', 'number'] as const)
|
|
126
|
+
.map((type) => ({
|
|
127
|
+
type,
|
|
128
|
+
values: new Set(values.filter((value) => typeof value === type)),
|
|
129
|
+
}))
|
|
130
|
+
.filter((domain) => domain.values.size > 0);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function stringEnumDomain(def: SchemaDefinition): JSONDomain {
|
|
134
|
+
const values = Array.isArray(def.values)
|
|
135
|
+
? def.values.filter((value): value is string => typeof value === 'string')
|
|
136
|
+
: [];
|
|
137
|
+
return { type: 'string', values: new Set(values) };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function finiteDiscriminatorDomains(def: SchemaDefinition): JSONDomain[] {
|
|
141
|
+
if (def.typeName === 'ZodLiteral') {
|
|
142
|
+
const domain = literalDomain(def.value);
|
|
143
|
+
return domain ? [domain] : [];
|
|
144
|
+
}
|
|
145
|
+
if (def.typeName === 'ZodEnum') {
|
|
146
|
+
return [stringEnumDomain(def)];
|
|
147
|
+
}
|
|
148
|
+
return def.typeName === 'ZodNativeEnum' ? nativeEnumDomains(def) : [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function objectDomain(def: SchemaDefinition): JSONDomain {
|
|
152
|
+
const discriminators = new Map<string, readonly JSONDomain[]>();
|
|
153
|
+
for (const [name, child] of Object.entries(def.shape())) {
|
|
154
|
+
const domains = finiteDiscriminatorDomains(child._def);
|
|
155
|
+
if (domains.length > 0 && domains.every(({ values }) => values !== undefined && values.size > 0)) {
|
|
156
|
+
discriminators.set(name, domains);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return { type: 'object', discriminators };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function domainsFor(schema: SchemaNode, seen = new Set<SchemaDefinition>()): JSONDomain[] {
|
|
163
|
+
const def = schema._def;
|
|
164
|
+
if (seen.has(def)) {
|
|
165
|
+
return [{ type: 'unknown' }];
|
|
166
|
+
}
|
|
167
|
+
seen.add(def);
|
|
168
|
+
|
|
169
|
+
if (def.typeName === 'ZodObject') {
|
|
170
|
+
return [objectDomain(def)];
|
|
171
|
+
}
|
|
172
|
+
const simpleDomain = simpleJSONDomains[def.typeName];
|
|
173
|
+
if (simpleDomain !== undefined) {
|
|
174
|
+
return [{ type: simpleDomain }];
|
|
175
|
+
}
|
|
176
|
+
if (def.typeName === 'ZodLiteral') {
|
|
177
|
+
const domain = literalDomain(def.value);
|
|
178
|
+
return domain ? [domain] : [{ type: 'unknown' }];
|
|
179
|
+
}
|
|
180
|
+
if (def.typeName === 'ZodEnum') {
|
|
181
|
+
return [stringEnumDomain(def)];
|
|
182
|
+
}
|
|
183
|
+
if (def.typeName === 'ZodNativeEnum') {
|
|
184
|
+
return nativeEnumDomains(def);
|
|
185
|
+
}
|
|
186
|
+
if (def.typeName === 'ZodUnion' || def.typeName === 'ZodDiscriminatedUnion') {
|
|
187
|
+
return [...def.options.values()].flatMap((option) => domainsFor(option, new Set(seen)));
|
|
188
|
+
}
|
|
189
|
+
if (def.typeName === 'ZodNullable') {
|
|
190
|
+
return [...domainsFor(def.innerType, new Set(seen)), { type: 'null' }];
|
|
191
|
+
}
|
|
192
|
+
if (transparentWrappers.has(def.typeName)) {
|
|
193
|
+
return domainsFor(def.innerType, seen);
|
|
194
|
+
}
|
|
195
|
+
if (def.typeName === 'ZodBranded') {
|
|
196
|
+
return domainsFor(def.type, seen);
|
|
197
|
+
}
|
|
198
|
+
if (def.typeName === 'ZodLazy') {
|
|
199
|
+
return domainsFor(def.getter(), seen);
|
|
200
|
+
}
|
|
201
|
+
return [{ type: 'unknown' }];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function domainsOverlap(left: JSONDomain, right: JSONDomain): boolean {
|
|
205
|
+
if (left.type === 'unknown' || right.type === 'unknown') {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
if (left.type !== right.type) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (left.discriminators && right.discriminators) {
|
|
213
|
+
for (const [name, first] of left.discriminators) {
|
|
214
|
+
const second = right.discriminators.get(name);
|
|
215
|
+
if (
|
|
216
|
+
second &&
|
|
217
|
+
!first.some((leftDomain) => second.some((rightDomain) => domainsOverlap(leftDomain, rightDomain)))
|
|
218
|
+
) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const rightValues = right.values;
|
|
225
|
+
if (!left.values || !rightValues) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
return [...left.values].some((value) => rightValues.has(value));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function assertUnambiguousUnion(options: readonly SchemaNode[], path: string): void {
|
|
232
|
+
const domains = options.map((option) => domainsFor(option));
|
|
233
|
+
|
|
234
|
+
for (const [index, left] of domains.entries()) {
|
|
235
|
+
for (const right of domains.slice(index + 1)) {
|
|
236
|
+
if (left.some((first) => right.some((second) => domainsOverlap(first, second)))) {
|
|
237
|
+
unsupported(
|
|
238
|
+
path,
|
|
239
|
+
'ZodUnion',
|
|
240
|
+
'ambiguous union branches overlap; use disjoint JSON types, distinct literals, or a discriminated union',
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function schemaChildren(def: SchemaDefinition, path: string): SchemaChild[] | undefined {
|
|
248
|
+
switch (def.typeName) {
|
|
249
|
+
case 'ZodObject': {
|
|
250
|
+
const children = Object.entries(def.shape()).map(([name, schema]) => ({
|
|
251
|
+
schema,
|
|
252
|
+
path: `${path}.${name}`,
|
|
253
|
+
}));
|
|
254
|
+
if (def.catchall && def.catchall._def.typeName !== 'ZodNever') {
|
|
255
|
+
children.push({ schema: def.catchall, path: `${path}.<catchall>` });
|
|
256
|
+
}
|
|
257
|
+
return children;
|
|
258
|
+
}
|
|
259
|
+
case 'ZodArray': {
|
|
260
|
+
return [{ schema: def.type, path: `${path}[]` }];
|
|
261
|
+
}
|
|
262
|
+
case 'ZodUnion':
|
|
263
|
+
case 'ZodDiscriminatedUnion': {
|
|
264
|
+
return [...def.options.values()].map((schema, index) => ({
|
|
265
|
+
schema,
|
|
266
|
+
path: `${path}[${index}]`,
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
case 'ZodOptional':
|
|
270
|
+
case 'ZodNullable':
|
|
271
|
+
case 'ZodDefault':
|
|
272
|
+
case 'ZodReadonly': {
|
|
273
|
+
return [{ schema: def.innerType, path }];
|
|
274
|
+
}
|
|
275
|
+
case 'ZodBranded': {
|
|
276
|
+
return [{ schema: def.type, path }];
|
|
277
|
+
}
|
|
278
|
+
case 'ZodLazy': {
|
|
279
|
+
return [{ schema: def.getter(), path }];
|
|
280
|
+
}
|
|
281
|
+
default: {
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function hasFiniteNumberOutput(def: SchemaDefinition): boolean {
|
|
288
|
+
const checks = def.checks ?? [];
|
|
289
|
+
if (checks.some(({ kind }) => kind === 'finite' || kind === 'int')) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
return (
|
|
293
|
+
checks.some(({ kind, value }) => kind === 'min' && typeof value === 'number' && Number.isFinite(value)) &&
|
|
294
|
+
checks.some(({ kind, value }) => kind === 'max' && typeof value === 'number' && Number.isFinite(value))
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function hasClosedJSONNativeObjectOutput(
|
|
299
|
+
def: SchemaDefinition,
|
|
300
|
+
active: Set<SchemaDefinition>,
|
|
301
|
+
inspect: (schema: SchemaNode, active: Set<SchemaDefinition>) => boolean,
|
|
302
|
+
): boolean {
|
|
303
|
+
return (
|
|
304
|
+
def.unknownKeys !== 'passthrough' &&
|
|
305
|
+
(def.catchall === undefined || def.catchall._def.typeName === 'ZodNever') &&
|
|
306
|
+
Object.values(def.shape()).every((child) => inspect(child, new Set(active)))
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function hasProvablyJSONNativeOutput(schema: SchemaNode, active = new Set<SchemaDefinition>()): boolean {
|
|
311
|
+
const def = schema._def;
|
|
312
|
+
if (active.has(def)) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
active.add(def);
|
|
316
|
+
|
|
317
|
+
switch (def.typeName) {
|
|
318
|
+
case 'ZodString':
|
|
319
|
+
case 'ZodBoolean':
|
|
320
|
+
case 'ZodNull':
|
|
321
|
+
case 'ZodEnum':
|
|
322
|
+
case 'ZodNativeEnum': {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
case 'ZodLiteral': {
|
|
326
|
+
return literalDomain(def.value) !== undefined;
|
|
327
|
+
}
|
|
328
|
+
case 'ZodNumber': {
|
|
329
|
+
return hasFiniteNumberOutput(def);
|
|
330
|
+
}
|
|
331
|
+
case 'ZodArray': {
|
|
332
|
+
return hasProvablyJSONNativeOutput(def.type, active);
|
|
333
|
+
}
|
|
334
|
+
case 'ZodObject': {
|
|
335
|
+
return hasClosedJSONNativeObjectOutput(def, active, hasProvablyJSONNativeOutput);
|
|
336
|
+
}
|
|
337
|
+
case 'ZodUnion':
|
|
338
|
+
case 'ZodDiscriminatedUnion': {
|
|
339
|
+
return [...def.options.values()].every((child) => hasProvablyJSONNativeOutput(child, new Set(active)));
|
|
340
|
+
}
|
|
341
|
+
case 'ZodNullable':
|
|
342
|
+
case 'ZodDefault':
|
|
343
|
+
case 'ZodReadonly': {
|
|
344
|
+
return hasProvablyJSONNativeOutput(def.innerType, active);
|
|
345
|
+
}
|
|
346
|
+
case 'ZodBranded': {
|
|
347
|
+
return hasProvablyJSONNativeOutput(def.type, active);
|
|
348
|
+
}
|
|
349
|
+
case 'ZodLazy': {
|
|
350
|
+
return hasProvablyJSONNativeOutput(def.getter(), active);
|
|
351
|
+
}
|
|
352
|
+
default: {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function assertSupportedSchemaValue(def: SchemaDefinition, path: string): void {
|
|
359
|
+
const rejection = unsupportedReasons.get(def.typeName);
|
|
360
|
+
if (rejection) {
|
|
361
|
+
unsupported(path, def.typeName, rejection);
|
|
362
|
+
}
|
|
363
|
+
if (def.typeName === 'ZodLiteral' && !literalDomain(def.value)) {
|
|
364
|
+
unsupported(path, def.typeName, 'literal values must be finite JSON primitives');
|
|
365
|
+
}
|
|
366
|
+
if (def.typeName === 'ZodNumber' && def.coerce === true && !hasFiniteNumberOutput(def)) {
|
|
367
|
+
unsupported(path, def.typeName, 'number coercion must prove its parsed output is finite');
|
|
368
|
+
}
|
|
369
|
+
if (def.typeName === 'ZodDefault' && !hasProvablyJSONNativeOutput(def.innerType)) {
|
|
370
|
+
unsupported(
|
|
371
|
+
path,
|
|
372
|
+
def.typeName,
|
|
373
|
+
'default factory output is not independently guaranteed to be finite and JSON-native; it may contain bigint',
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
if (def.typeName === 'ZodString' && def.checks?.some(({ kind }) => valueChangingStringChecks.has(kind))) {
|
|
377
|
+
unsupported(path, def.typeName, 'value-changing string checks are not represented in JSON Schema');
|
|
378
|
+
}
|
|
379
|
+
if (
|
|
380
|
+
def.typeName === 'ZodString' &&
|
|
381
|
+
(def.checks?.filter(({ kind }) => patternProducingStringChecks.has(kind)).length ?? 0) > 1
|
|
382
|
+
) {
|
|
383
|
+
unsupported(path, def.typeName, 'multiple pattern-producing checks require unsupported allOf');
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function visit(schema: SchemaNode, path: string, visited: Set<SchemaDefinition>): void {
|
|
388
|
+
const def = schema._def;
|
|
389
|
+
if (visited.has(def)) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
visited.add(def);
|
|
393
|
+
|
|
394
|
+
// Preserve the existing concrete-root diagnostic for intersections.
|
|
395
|
+
if (def.typeName === 'ZodIntersection' && path === '$') {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
assertSupportedSchemaValue(def, path);
|
|
400
|
+
|
|
401
|
+
const children = schemaChildren(def, path);
|
|
402
|
+
if (!children) {
|
|
403
|
+
if (!supportedLeaves.has(def.typeName)) {
|
|
404
|
+
unsupported(path, def.typeName, 'this Zod schema is outside the documented JSON-native subset');
|
|
405
|
+
}
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
for (const child of children) {
|
|
410
|
+
visit(child.schema, child.path, visited);
|
|
411
|
+
}
|
|
412
|
+
if (
|
|
413
|
+
def.typeName === 'ZodObject' &&
|
|
414
|
+
(def.unknownKeys === 'passthrough' ||
|
|
415
|
+
(def.catchall !== undefined && def.catchall._def.typeName !== 'ZodNever'))
|
|
416
|
+
) {
|
|
417
|
+
unsupported(path, def.typeName, 'open object schemas require additionalProperties: false');
|
|
418
|
+
}
|
|
419
|
+
if (def.typeName === 'ZodUnion' && path !== '$') {
|
|
420
|
+
assertUnambiguousUnion(
|
|
421
|
+
children.map(({ schema: child }) => child),
|
|
422
|
+
path,
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export function assertSupportedZodV3Schema(
|
|
428
|
+
schema: ZodV3Schema,
|
|
429
|
+
definitions: Record<string, ZodV3Schema> | undefined,
|
|
430
|
+
): void {
|
|
431
|
+
const visited = new Set<SchemaDefinition>();
|
|
432
|
+
visit(schema as unknown as SchemaNode, '$', visited);
|
|
433
|
+
for (const [name, definition] of Object.entries(definitions ?? {})) {
|
|
434
|
+
visit(definition as unknown as SchemaNode, `$.definitions.${name}`, visited);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function assertNoJSONSerializationHook(value: object, path: string): void {
|
|
439
|
+
for (let current: object | null = value; current !== null; current = Object.getPrototypeOf(current)) {
|
|
440
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, 'toJSON');
|
|
441
|
+
if (!descriptor) {
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (!('value' in descriptor) || typeof descriptor.value === 'function') {
|
|
445
|
+
throw new Error(
|
|
446
|
+
`Strict Structured Outputs schema field \`${path}\` contains an unsupported \`toJSON\` serialization hook`,
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function assertJSONSerializableNumber(value: number, path: string): void {
|
|
454
|
+
if (Object.is(value, -0)) {
|
|
455
|
+
throw new TypeError(
|
|
456
|
+
`Strict Structured Outputs schema field \`${path}\` contains negative zero, which cannot round-trip through JSON`,
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export function assertJSONSerializableSchema(
|
|
462
|
+
value: unknown,
|
|
463
|
+
path = '$',
|
|
464
|
+
ancestors = new Set<object>(),
|
|
465
|
+
): void {
|
|
466
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean') {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
470
|
+
assertJSONSerializableNumber(value, path);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (typeof value !== 'object') {
|
|
474
|
+
throw new TypeError(
|
|
475
|
+
`Strict Structured Outputs schema field \`${path}\` contains a non-JSON ${typeof value} value`,
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
if (ancestors.has(value)) {
|
|
479
|
+
throw new Error(`Strict Structured Outputs schema field \`${path}\` contains a circular JSON value`);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const prototype = Object.getPrototypeOf(value);
|
|
483
|
+
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) {
|
|
484
|
+
throw new Error(`Strict Structured Outputs schema field \`${path}\` contains a non-JSON native object`);
|
|
485
|
+
}
|
|
486
|
+
assertNoJSONSerializationHook(value, path);
|
|
487
|
+
|
|
488
|
+
ancestors.add(value);
|
|
489
|
+
if (Array.isArray(value)) {
|
|
490
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
491
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
492
|
+
if (!descriptor) {
|
|
493
|
+
throw new Error(
|
|
494
|
+
`Strict Structured Outputs schema field \`${path}[${index}]\` contains a sparse array`,
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
if (!('value' in descriptor)) {
|
|
498
|
+
throw new Error(
|
|
499
|
+
`Strict Structured Outputs schema field \`${path}[${index}]\` contains an array accessor`,
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
assertJSONSerializableSchema(descriptor.value, `${path}[${index}]`, ancestors);
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
for (const key of Object.keys(value)) {
|
|
506
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
507
|
+
if (!descriptor || !('value' in descriptor)) {
|
|
508
|
+
throw new Error(`Strict Structured Outputs schema field \`${path}.${key}\` contains an accessor`);
|
|
509
|
+
}
|
|
510
|
+
assertJSONSerializableSchema(descriptor.value, `${path}.${key}`, ancestors);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
ancestors.delete(value);
|
|
514
|
+
}
|
package/src/helpers/zod.ts
CHANGED
|
@@ -3,7 +3,12 @@ import type * as z3 from 'zod/v3';
|
|
|
3
3
|
import * as z4 from 'zod/v4';
|
|
4
4
|
import type * as z4Mini from 'zod/v4-mini';
|
|
5
5
|
import type { AutoParseableResponseFormat, AutoParseableTextFormat, AutoParseableTool } from '../lib/parser';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
makeParseableResponseFormat,
|
|
8
|
+
makeParseableTextFormat,
|
|
9
|
+
makeParseableTool,
|
|
10
|
+
parseResponseFormatContent,
|
|
11
|
+
} from '../lib/parser';
|
|
7
12
|
import { zodToJsonSchema as _zodToJsonSchema } from '../_vendor/zod-to-json-schema';
|
|
8
13
|
import type { AutoParseableResponseTool } from '../lib/ResponsesParser';
|
|
9
14
|
import { makeParseableResponseTool } from '../lib/ResponsesParser';
|
|
@@ -12,6 +17,7 @@ import type { RealtimeFunctionTool } from '../resources/realtime/realtime';
|
|
|
12
17
|
import { forEachJSONSchemaChild, toStrictJsonSchema } from '../lib/transform';
|
|
13
18
|
import type { JSONSchema } from '../lib/jsonschema';
|
|
14
19
|
import { hasOwn } from '../internal/utils/values';
|
|
20
|
+
import { assertJSONSerializableSchema, assertSupportedZodV3Schema } from './zod-v3-strict-schema';
|
|
15
21
|
|
|
16
22
|
type ZodV4Schema = z4.ZodType | z4Mini.ZodMiniType;
|
|
17
23
|
type ZodSchema = z3.ZodType | ZodV4Schema;
|
|
@@ -128,6 +134,7 @@ function zodV3ToJsonSchema(
|
|
|
128
134
|
schema: z3.ZodType,
|
|
129
135
|
options: { name: string; schemaDefinitions?: ZodSchemaDefinitions | undefined },
|
|
130
136
|
): Record<string, unknown> {
|
|
137
|
+
assertSupportedZodV3Schema(schema, options.schemaDefinitions as Record<string, z3.ZodType> | undefined);
|
|
131
138
|
const rootName = getZodV3RootName(options.name, options.schemaDefinitions);
|
|
132
139
|
const jsonSchema = _zodToJsonSchema(schema, {
|
|
133
140
|
openaiStrictMode: true,
|
|
@@ -140,7 +147,9 @@ function zodV3ToJsonSchema(
|
|
|
140
147
|
: undefined),
|
|
141
148
|
});
|
|
142
149
|
|
|
143
|
-
|
|
150
|
+
const escapedSchema = escapeSchemaDefinitionRefs(jsonSchema, options.schemaDefinitions);
|
|
151
|
+
assertJSONSerializableSchema(escapedSchema);
|
|
152
|
+
return escapedSchema;
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
function zodV4ToJsonSchema(
|
|
@@ -202,11 +211,15 @@ function parseZodObject<ZodInput extends ZodTypeLike>(
|
|
|
202
211
|
zodObject: ZodInput,
|
|
203
212
|
content: string,
|
|
204
213
|
): InferZodType<ZodInput> {
|
|
205
|
-
const parsed =
|
|
214
|
+
const parsed = parseResponseFormatContent({ type: 'json_schema', $parseRaw: undefined }, content);
|
|
206
215
|
const parser = (zodObject as { parse?: (data: unknown) => unknown }).parse;
|
|
207
216
|
|
|
208
217
|
if (typeof parser === 'function') {
|
|
209
|
-
|
|
218
|
+
const result = parser.call(zodObject, parsed) as InferZodType<ZodInput>;
|
|
219
|
+
if (!isZodV4(zodObject as unknown as ZodSchema)) {
|
|
220
|
+
assertJSONSerializableSchema(result);
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
210
223
|
}
|
|
211
224
|
|
|
212
225
|
return z4.parse(zodObject as unknown as ZodV4Schema, parsed) as InferZodType<ZodInput>;
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { OpenAI as default } from './client';
|
|
|
2
2
|
|
|
3
3
|
export { type Uploadable, toFile, toStreamingFile } from './core/uploads';
|
|
4
4
|
export { APIPromise } from './core/api-promise';
|
|
5
|
-
export { OpenAI, type ClientOptions } from './client';
|
|
5
|
+
export { OpenAI, type ClientOptions, type DataResidency } from './client';
|
|
6
6
|
export { PagePromise } from './core/pagination';
|
|
7
7
|
export {
|
|
8
8
|
OpenAIError,
|
|
@@ -6,6 +6,28 @@ const MAX_EXTERNALLY_MUTABLE_ASSISTANT_STREAM_ARRAY_LENGTH = 65_536;
|
|
|
6
6
|
|
|
7
7
|
type AssistantStreamRecord = Record<string, unknown>;
|
|
8
8
|
|
|
9
|
+
function getAssistantStreamDiagnosticProperty(property: string): string {
|
|
10
|
+
switch (property) {
|
|
11
|
+
case 'value':
|
|
12
|
+
case 'arguments':
|
|
13
|
+
case 'input':
|
|
14
|
+
case 'text':
|
|
15
|
+
case 'content':
|
|
16
|
+
case 'annotations':
|
|
17
|
+
case 'metadata':
|
|
18
|
+
case 'name':
|
|
19
|
+
case 'role':
|
|
20
|
+
case 'status':
|
|
21
|
+
case 'tool_calls':
|
|
22
|
+
case 'step_details': {
|
|
23
|
+
return property;
|
|
24
|
+
}
|
|
25
|
+
default: {
|
|
26
|
+
return 'unknown';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
9
31
|
interface AssistantStreamArrayState {
|
|
10
32
|
length: number;
|
|
11
33
|
ownEntryCount: number;
|
|
@@ -87,12 +109,13 @@ function getAssistantStreamDeltaIndex(
|
|
|
87
109
|
const { index } = deltaEntry;
|
|
88
110
|
|
|
89
111
|
if (kind === 'array' && (index === null || index === undefined)) {
|
|
90
|
-
console.error(deltaEntry);
|
|
91
112
|
throw new Error('Expected array delta entry to have an `index` property');
|
|
92
113
|
}
|
|
93
114
|
|
|
94
115
|
if (kind === 'array' && typeof index !== 'number') {
|
|
95
|
-
throw new TypeError(
|
|
116
|
+
throw new TypeError(
|
|
117
|
+
'Expected array delta entry `index` property to be a number but got an invalid value',
|
|
118
|
+
);
|
|
96
119
|
}
|
|
97
120
|
|
|
98
121
|
if (
|
|
@@ -101,7 +124,8 @@ function getAssistantStreamDeltaIndex(
|
|
|
101
124
|
(index as number) >= baselineLength + MAX_ASSISTANT_STREAM_ARRAY_GROWTH ||
|
|
102
125
|
(index as number) >= MAX_EXTERNALLY_MUTABLE_ASSISTANT_STREAM_ARRAY_LENGTH
|
|
103
126
|
) {
|
|
104
|
-
|
|
127
|
+
const safeIndex = typeof index === 'number' ? index : 'unknown';
|
|
128
|
+
throw new OpenAIError(`Assistant stream delta contains an invalid ${kind} index: ${safeIndex}`);
|
|
105
129
|
}
|
|
106
130
|
|
|
107
131
|
return index as number;
|
|
@@ -139,7 +163,7 @@ function assertValidAssistantStreamArrayDelta(
|
|
|
139
163
|
|
|
140
164
|
for (const deltaEntry of delta) {
|
|
141
165
|
if (!isObj(deltaEntry)) {
|
|
142
|
-
throw new Error(
|
|
166
|
+
throw new Error('Expected array delta entry to be an object but got an invalid value');
|
|
143
167
|
}
|
|
144
168
|
|
|
145
169
|
const validatedIndex = getAssistantStreamDeltaIndex(deltaEntry, kind, projectedArray.baselineLength);
|
|
@@ -259,11 +283,12 @@ export function defineAssistantStreamArrayEntry(accumulator: unknown[], index: n
|
|
|
259
283
|
function getRequiredAssistantStreamArrayIndex(deltaEntry: AssistantStreamRecord): number {
|
|
260
284
|
const { index } = deltaEntry;
|
|
261
285
|
if (index === null || index === undefined) {
|
|
262
|
-
console.error(deltaEntry);
|
|
263
286
|
throw new Error('Expected array delta entry to have an `index` property');
|
|
264
287
|
}
|
|
265
288
|
if (typeof index !== 'number') {
|
|
266
|
-
throw new TypeError(
|
|
289
|
+
throw new TypeError(
|
|
290
|
+
'Expected array delta entry `index` property to be a number but got an invalid value',
|
|
291
|
+
);
|
|
267
292
|
}
|
|
268
293
|
return index;
|
|
269
294
|
}
|
|
@@ -286,7 +311,7 @@ function applyAssistantStreamArrayDelta(
|
|
|
286
311
|
|
|
287
312
|
for (const deltaEntry of delta) {
|
|
288
313
|
if (!isObj(deltaEntry)) {
|
|
289
|
-
throw new Error(
|
|
314
|
+
throw new Error('Expected array delta entry to be an object but got an invalid value');
|
|
290
315
|
}
|
|
291
316
|
|
|
292
317
|
const index = getRequiredAssistantStreamArrayIndex(deltaEntry);
|
|
@@ -349,9 +374,7 @@ function applyAssistantStreamDelta(
|
|
|
349
374
|
applyAssistantStreamArrayDelta(accumulatedValue, deltaValue, applyAssistantStreamDelta);
|
|
350
375
|
continue;
|
|
351
376
|
} else {
|
|
352
|
-
throw new TypeError(
|
|
353
|
-
`Unhandled record type: ${key}, deltaValue: ${deltaValue}, accValue: ${accumulatedValue}`,
|
|
354
|
-
);
|
|
377
|
+
throw new TypeError(`Unhandled record type: ${getAssistantStreamDiagnosticProperty(key)}`);
|
|
355
378
|
}
|
|
356
379
|
accumulator[key] = accumulatedValue;
|
|
357
380
|
}
|