openai 7.10.0 → 7.12.1
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 +196 -0
- package/README.md +7 -5
- package/_vendor/partial-json-parser/parser.d.mts.map +1 -1
- package/_vendor/partial-json-parser/parser.d.ts.map +1 -1
- package/_vendor/partial-json-parser/parser.js +4 -3
- package/_vendor/partial-json-parser/parser.js.map +1 -1
- package/_vendor/partial-json-parser/parser.mjs +4 -3
- package/_vendor/partial-json-parser/parser.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/string.js +1 -1
- package/_vendor/zod-to-json-schema/parsers/string.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/string.mjs +1 -1
- package/_vendor/zod-to-json-schema/parsers/string.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/tuple.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/tuple.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/tuple.js +19 -12
- package/_vendor/zod-to-json-schema/parsers/tuple.js.map +1 -1
- package/_vendor/zod-to-json-schema/parsers/tuple.mjs +19 -12
- package/_vendor/zod-to-json-schema/parsers/tuple.mjs.map +1 -1
- package/_vendor/zod-to-json-schema/zodToJsonSchema.d.mts.map +1 -1
- package/_vendor/zod-to-json-schema/zodToJsonSchema.d.ts.map +1 -1
- package/_vendor/zod-to-json-schema/zodToJsonSchema.js +6 -2
- package/_vendor/zod-to-json-schema/zodToJsonSchema.js.map +1 -1
- package/_vendor/zod-to-json-schema/zodToJsonSchema.mjs +6 -2
- package/_vendor/zod-to-json-schema/zodToJsonSchema.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 +10 -5
- package/auth/subject-token-providers.js.map +1 -1
- package/auth/subject-token-providers.mjs +10 -5
- package/auth/subject-token-providers.mjs.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 +21 -11
- package/auth/workload-identity-auth.js.map +1 -1
- package/auth/workload-identity-auth.mjs +21 -11
- package/auth/workload-identity-auth.mjs.map +1 -1
- package/azure.d.mts.map +1 -1
- package/azure.d.ts.map +1 -1
- package/azure.js +31 -2
- package/azure.js.map +1 -1
- package/azure.mjs +32 -3
- package/azure.mjs.map +1 -1
- package/beta/realtime/internal-base.d.mts.map +1 -1
- package/beta/realtime/internal-base.d.ts.map +1 -1
- package/beta/realtime/internal-base.js +3 -2
- package/beta/realtime/internal-base.js.map +1 -1
- package/beta/realtime/internal-base.mjs +3 -2
- package/beta/realtime/internal-base.mjs.map +1 -1
- package/beta/realtime/websocket.d.mts +2 -0
- package/beta/realtime/websocket.d.mts.map +1 -1
- package/beta/realtime/websocket.d.ts +2 -0
- package/beta/realtime/websocket.d.ts.map +1 -1
- package/beta/realtime/websocket.js +12 -7
- package/beta/realtime/websocket.js.map +1 -1
- package/beta/realtime/websocket.mjs +12 -7
- package/beta/realtime/websocket.mjs.map +1 -1
- package/beta/realtime/ws.d.mts +2 -0
- package/beta/realtime/ws.d.mts.map +1 -1
- package/beta/realtime/ws.d.ts +2 -0
- package/beta/realtime/ws.d.ts.map +1 -1
- package/beta/realtime/ws.js +7 -5
- package/beta/realtime/ws.js.map +1 -1
- package/beta/realtime/ws.mjs +7 -5
- package/beta/realtime/ws.mjs.map +1 -1
- package/client.d.mts +9 -1
- package/client.d.mts.map +1 -1
- package/client.d.ts +9 -1
- package/client.d.ts.map +1 -1
- package/client.js +17 -4
- package/client.js.map +1 -1
- package/client.mjs +17 -4
- package/client.mjs.map +1 -1
- package/core/EventEmitter.d.mts +2 -1
- package/core/EventEmitter.d.mts.map +1 -1
- package/core/EventEmitter.d.ts +2 -1
- package/core/EventEmitter.d.ts.map +1 -1
- package/core/EventEmitter.js +2 -1
- package/core/EventEmitter.js.map +1 -1
- package/core/EventEmitter.mjs +2 -1
- package/core/EventEmitter.mjs.map +1 -1
- package/core/pagination.js +1 -1
- package/core/pagination.js.map +1 -1
- package/core/pagination.mjs +1 -1
- package/core/pagination.mjs.map +1 -1
- package/core/streaming.d.mts +8 -0
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts +8 -0
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +68 -15
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +68 -15
- package/core/streaming.mjs.map +1 -1
- package/helpers/audio.d.mts +1 -1
- package/helpers/audio.d.mts.map +1 -1
- package/helpers/audio.d.ts +1 -1
- package/helpers/audio.d.ts.map +1 -1
- package/helpers/audio.js +25 -5
- package/helpers/audio.js.map +1 -1
- package/helpers/audio.mjs +25 -5
- package/helpers/audio.mjs.map +1 -1
- package/helpers/zod.d.mts +28 -15
- package/helpers/zod.d.mts.map +1 -1
- package/helpers/zod.d.ts +28 -15
- package/helpers/zod.d.ts.map +1 -1
- package/helpers/zod.js +30 -23
- package/helpers/zod.js.map +1 -1
- package/helpers/zod.mjs +30 -23
- package/helpers/zod.mjs.map +1 -1
- package/index.js +4 -5
- package/internal/bedrock.d.mts +11 -0
- package/internal/bedrock.d.mts.map +1 -1
- package/internal/bedrock.d.ts +11 -0
- package/internal/bedrock.d.ts.map +1 -1
- package/internal/bedrock.js +71 -55
- package/internal/bedrock.js.map +1 -1
- package/internal/bedrock.mjs +70 -55
- package/internal/bedrock.mjs.map +1 -1
- package/internal/detect-platform.js +2 -2
- package/internal/detect-platform.js.map +1 -1
- package/internal/detect-platform.mjs +2 -2
- package/internal/detect-platform.mjs.map +1 -1
- package/internal/errors.d.mts.map +1 -1
- package/internal/errors.d.ts.map +1 -1
- package/internal/errors.js +3 -2
- package/internal/errors.js.map +1 -1
- package/internal/errors.mjs +3 -2
- package/internal/errors.mjs.map +1 -1
- package/internal/headers.d.mts.map +1 -1
- package/internal/headers.d.ts.map +1 -1
- package/internal/headers.js +4 -5
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +4 -5
- package/internal/headers.mjs.map +1 -1
- package/internal/parse.js +1 -1
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +1 -1
- package/internal/parse.mjs.map +1 -1
- package/internal/realtime-credentials.d.mts +15 -0
- package/internal/realtime-credentials.d.mts.map +1 -0
- package/internal/realtime-credentials.d.ts +15 -0
- package/internal/realtime-credentials.d.ts.map +1 -0
- package/internal/realtime-credentials.js +23 -0
- package/internal/realtime-credentials.js.map +1 -0
- package/internal/realtime-credentials.mjs +19 -0
- package/internal/realtime-credentials.mjs.map +1 -0
- package/internal/responses/response-accumulator.d.mts.map +1 -1
- package/internal/responses/response-accumulator.d.ts.map +1 -1
- package/internal/responses/response-accumulator.js +2 -1
- package/internal/responses/response-accumulator.js.map +1 -1
- package/internal/responses/response-accumulator.mjs +2 -1
- package/internal/responses/response-accumulator.mjs.map +1 -1
- package/internal/to-file.d.mts +2 -1
- package/internal/to-file.d.mts.map +1 -1
- package/internal/to-file.d.ts +2 -1
- package/internal/to-file.d.ts.map +1 -1
- package/internal/to-file.js +5 -4
- package/internal/to-file.js.map +1 -1
- package/internal/to-file.mjs +6 -5
- package/internal/to-file.mjs.map +1 -1
- package/internal/types.d.mts +3 -3
- package/internal/types.d.mts.map +1 -1
- package/internal/types.d.ts +3 -3
- package/internal/types.d.ts.map +1 -1
- package/internal/uploads.d.mts +2 -0
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +2 -0
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +12 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +11 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/base64.d.mts.map +1 -1
- package/internal/utils/base64.d.ts.map +1 -1
- package/internal/utils/base64.js +3 -0
- package/internal/utils/base64.js.map +1 -1
- package/internal/utils/base64.mjs +3 -0
- package/internal/utils/base64.mjs.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.mts +1 -1
- package/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.ts +1 -1
- package/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
- package/lib/AbstractChatCompletionRunner.js +31 -9
- package/lib/AbstractChatCompletionRunner.js.map +1 -1
- package/lib/AbstractChatCompletionRunner.mjs +31 -9
- package/lib/AbstractChatCompletionRunner.mjs.map +1 -1
- package/lib/AssistantStream.d.mts +4 -1
- package/lib/AssistantStream.d.mts.map +1 -1
- package/lib/AssistantStream.d.ts +4 -1
- package/lib/AssistantStream.d.ts.map +1 -1
- package/lib/AssistantStream.js +23 -8
- package/lib/AssistantStream.js.map +1 -1
- package/lib/AssistantStream.mjs +24 -9
- package/lib/AssistantStream.mjs.map +1 -1
- package/lib/ChatCompletionRunner.d.mts +6 -3
- package/lib/ChatCompletionRunner.d.mts.map +1 -1
- package/lib/ChatCompletionRunner.d.ts +6 -3
- package/lib/ChatCompletionRunner.d.ts.map +1 -1
- package/lib/ChatCompletionRunner.js +7 -4
- package/lib/ChatCompletionRunner.js.map +1 -1
- package/lib/ChatCompletionRunner.mjs +7 -4
- package/lib/ChatCompletionRunner.mjs.map +1 -1
- package/lib/ChatCompletionStream.d.mts.map +1 -1
- package/lib/ChatCompletionStream.d.ts.map +1 -1
- package/lib/ChatCompletionStream.js +6 -0
- package/lib/ChatCompletionStream.js.map +1 -1
- package/lib/ChatCompletionStream.mjs +7 -1
- package/lib/ChatCompletionStream.mjs.map +1 -1
- package/lib/ChatCompletionStreamingRunner.d.mts.map +1 -1
- package/lib/ChatCompletionStreamingRunner.d.ts.map +1 -1
- package/lib/ChatCompletionStreamingRunner.js +1 -0
- package/lib/ChatCompletionStreamingRunner.js.map +1 -1
- package/lib/ChatCompletionStreamingRunner.mjs +1 -0
- package/lib/ChatCompletionStreamingRunner.mjs.map +1 -1
- package/lib/EventEmitter.d.mts +3 -1
- package/lib/EventEmitter.d.mts.map +1 -1
- package/lib/EventEmitter.d.ts +3 -1
- package/lib/EventEmitter.d.ts.map +1 -1
- package/lib/EventEmitter.js +2 -1
- package/lib/EventEmitter.js.map +1 -1
- package/lib/EventEmitter.mjs +2 -1
- package/lib/EventEmitter.mjs.map +1 -1
- package/lib/EventStream.d.mts +2 -1
- package/lib/EventStream.d.mts.map +1 -1
- package/lib/EventStream.d.ts +2 -1
- package/lib/EventStream.d.ts.map +1 -1
- package/lib/EventStream.js +99 -46
- package/lib/EventStream.js.map +1 -1
- package/lib/EventStream.mjs +99 -46
- package/lib/EventStream.mjs.map +1 -1
- package/lib/ResponsesParser.d.mts +5 -4
- package/lib/ResponsesParser.d.mts.map +1 -1
- package/lib/ResponsesParser.d.ts +5 -4
- package/lib/ResponsesParser.d.ts.map +1 -1
- package/lib/ResponsesParser.js +21 -7
- package/lib/ResponsesParser.js.map +1 -1
- package/lib/ResponsesParser.mjs +21 -7
- package/lib/ResponsesParser.mjs.map +1 -1
- package/lib/RunnableFunction.d.mts +2 -2
- package/lib/RunnableFunction.d.mts.map +1 -1
- package/lib/RunnableFunction.d.ts +2 -2
- package/lib/RunnableFunction.d.ts.map +1 -1
- package/lib/embeddings.d.mts.map +1 -1
- package/lib/embeddings.d.ts.map +1 -1
- package/lib/embeddings.js +18 -12
- package/lib/embeddings.js.map +1 -1
- package/lib/embeddings.mjs +18 -12
- package/lib/embeddings.mjs.map +1 -1
- package/lib/file-processing.d.mts +3 -2
- package/lib/file-processing.d.mts.map +1 -1
- package/lib/file-processing.d.ts +3 -2
- package/lib/file-processing.d.ts.map +1 -1
- package/lib/file-processing.js +5 -4
- package/lib/file-processing.js.map +1 -1
- package/lib/file-processing.mjs +5 -4
- package/lib/file-processing.mjs.map +1 -1
- package/lib/parser.d.mts +16 -4
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts +16 -4
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js +1 -1
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs +1 -1
- package/lib/parser.mjs.map +1 -1
- package/lib/polling.d.mts +2 -2
- package/lib/polling.d.mts.map +1 -1
- package/lib/polling.d.ts +2 -2
- package/lib/polling.d.ts.map +1 -1
- package/lib/polling.js +5 -4
- package/lib/polling.js.map +1 -1
- package/lib/polling.mjs +5 -4
- package/lib/polling.mjs.map +1 -1
- package/lib/responses/EventTypes.d.mts +2 -2
- package/lib/responses/EventTypes.d.mts.map +1 -1
- package/lib/responses/EventTypes.d.ts +2 -2
- package/lib/responses/EventTypes.d.ts.map +1 -1
- package/lib/responses/ResponseInputItems.d.mts +3 -2
- package/lib/responses/ResponseInputItems.d.mts.map +1 -1
- package/lib/responses/ResponseInputItems.d.ts +3 -2
- package/lib/responses/ResponseInputItems.d.ts.map +1 -1
- package/lib/responses/ResponseInputItems.js +27 -4
- package/lib/responses/ResponseInputItems.js.map +1 -1
- package/lib/responses/ResponseInputItems.mjs +27 -4
- package/lib/responses/ResponseInputItems.mjs.map +1 -1
- package/lib/transform.d.mts.map +1 -1
- package/lib/transform.d.ts.map +1 -1
- package/lib/transform.js +1 -0
- package/lib/transform.js.map +1 -1
- package/lib/transform.mjs +1 -0
- package/lib/transform.mjs.map +1 -1
- package/lib/vector-store-polling.d.mts +2 -2
- package/lib/vector-store-polling.d.ts +2 -2
- package/lib/vector-store-polling.js +3 -3
- package/lib/vector-store-polling.js.map +1 -1
- package/lib/vector-store-polling.mjs +3 -3
- package/lib/vector-store-polling.mjs.map +1 -1
- package/lib/vector-store-upload.d.mts +2 -1
- package/lib/vector-store-upload.d.mts.map +1 -1
- package/lib/vector-store-upload.d.ts +2 -1
- package/lib/vector-store-upload.d.ts.map +1 -1
- package/lib/vector-store-upload.js +5 -1
- package/lib/vector-store-upload.js.map +1 -1
- package/lib/vector-store-upload.mjs +5 -1
- package/lib/vector-store-upload.mjs.map +1 -1
- package/package.json +1 -1
- package/providers/bedrock/aws.d.mts.map +1 -1
- package/providers/bedrock/aws.d.ts.map +1 -1
- package/providers/bedrock/aws.js +14 -16
- package/providers/bedrock/aws.js.map +1 -1
- package/providers/bedrock/aws.mjs +15 -17
- package/providers/bedrock/aws.mjs.map +1 -1
- package/realtime/internal-base.d.mts.map +1 -1
- package/realtime/internal-base.d.ts.map +1 -1
- package/realtime/internal-base.js +3 -5
- package/realtime/internal-base.js.map +1 -1
- package/realtime/internal-base.mjs +3 -5
- package/realtime/internal-base.mjs.map +1 -1
- package/realtime/websocket.d.mts +2 -0
- package/realtime/websocket.d.mts.map +1 -1
- package/realtime/websocket.d.ts +2 -0
- package/realtime/websocket.d.ts.map +1 -1
- package/realtime/websocket.js +12 -6
- package/realtime/websocket.js.map +1 -1
- package/realtime/websocket.mjs +12 -6
- package/realtime/websocket.mjs.map +1 -1
- package/realtime/ws.d.mts +2 -0
- package/realtime/ws.d.mts.map +1 -1
- package/realtime/ws.d.ts +2 -0
- package/realtime/ws.d.ts.map +1 -1
- package/realtime/ws.js +7 -4
- package/realtime/ws.js.map +1 -1
- package/realtime/ws.mjs +7 -4
- package/realtime/ws.mjs.map +1 -1
- package/resources/admin/organization/projects/service-accounts/api-keys.d.mts +9 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.d.mts.map +1 -1
- package/resources/admin/organization/projects/service-accounts/api-keys.d.ts +9 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.d.ts.map +1 -1
- package/resources/beta/responses/responses.d.mts +112 -33
- package/resources/beta/responses/responses.d.mts.map +1 -1
- package/resources/beta/responses/responses.d.ts +112 -33
- 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/conversations/items.d.mts +9 -0
- package/resources/conversations/items.d.mts.map +1 -1
- package/resources/conversations/items.d.ts +9 -0
- package/resources/conversations/items.d.ts.map +1 -1
- package/resources/images.d.mts +73 -58
- package/resources/images.d.mts.map +1 -1
- package/resources/images.d.ts +73 -58
- package/resources/images.d.ts.map +1 -1
- package/resources/images.js.map +1 -1
- package/resources/images.mjs.map +1 -1
- package/resources/responses/responses.d.mts +112 -32
- package/resources/responses/responses.d.mts.map +1 -1
- package/resources/responses/responses.d.ts +112 -32
- 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/webhooks/webhooks.d.mts +6 -4
- package/resources/webhooks/webhooks.d.mts.map +1 -1
- package/resources/webhooks/webhooks.d.ts +6 -4
- package/resources/webhooks/webhooks.d.ts.map +1 -1
- package/src/_vendor/partial-json-parser/parser.ts +4 -3
- package/src/_vendor/zod-to-json-schema/parsers/string.ts +1 -1
- package/src/_vendor/zod-to-json-schema/parsers/tuple.ts +23 -16
- package/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts +11 -6
- package/src/auth/subject-token-providers.ts +12 -7
- package/src/auth/workload-identity-auth.ts +27 -12
- package/src/azure.ts +34 -3
- package/src/beta/realtime/internal-base.ts +3 -2
- package/src/beta/realtime/websocket.ts +17 -7
- package/src/beta/realtime/ws.ts +9 -5
- package/src/client.ts +19 -4
- package/src/core/EventEmitter.ts +5 -8
- package/src/core/pagination.ts +1 -1
- package/src/core/streaming.ts +69 -13
- package/src/helpers/audio.ts +27 -6
- package/src/helpers/zod.ts +78 -29
- package/src/internal/bedrock.ts +84 -58
- package/src/internal/detect-platform.ts +2 -2
- package/src/internal/errors.ts +3 -2
- package/src/internal/headers.ts +7 -5
- package/src/internal/parse.ts +1 -1
- package/src/internal/realtime-credentials.ts +27 -0
- package/src/internal/responses/response-accumulator.ts +1 -0
- package/src/internal/to-file.ts +6 -5
- package/src/internal/uploads.ts +12 -1
- package/src/internal/utils/base64.ts +3 -0
- package/src/lib/AbstractChatCompletionRunner.ts +31 -6
- package/src/lib/AssistantStream.ts +25 -11
- package/src/lib/ChatCompletionRunner.ts +8 -4
- package/src/lib/ChatCompletionStream.ts +8 -0
- package/src/lib/ChatCompletionStreamingRunner.ts +1 -0
- package/src/lib/EventEmitter.ts +17 -8
- package/src/lib/EventStream.ts +105 -52
- package/src/lib/ResponsesParser.ts +33 -12
- package/src/lib/RunnableFunction.ts +2 -2
- package/src/lib/embeddings.ts +18 -12
- package/src/lib/file-processing.ts +5 -4
- package/src/lib/parser.ts +35 -11
- package/src/lib/polling.ts +5 -4
- package/src/lib/responses/EventTypes.ts +3 -69
- package/src/lib/responses/ResponseInputItems.ts +29 -4
- package/src/lib/transform.ts +1 -0
- package/src/lib/vector-store-polling.ts +3 -3
- package/src/lib/vector-store-upload.ts +5 -1
- package/src/providers/bedrock/aws.ts +23 -24
- package/src/realtime/internal-base.ts +3 -5
- package/src/realtime/websocket.ts +14 -6
- package/src/realtime/ws.ts +9 -4
- package/src/resources/admin/organization/projects/service-accounts/api-keys.ts +11 -0
- package/src/resources/beta/responses/responses.ts +143 -31
- package/src/resources/conversations/items.ts +11 -0
- package/src/resources/images.ts +76 -57
- package/src/resources/responses/responses.ts +143 -30
- package/src/resources/webhooks/webhooks.ts +6 -4
- 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
package/src/internal/headers.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isReadonlyArray } from './utils/values';
|
|
2
2
|
|
|
3
3
|
type HeaderValue = string | undefined | null;
|
|
4
|
+
type HeaderEntry = readonly (HeaderValue | readonly HeaderValue[])[];
|
|
4
5
|
export type HeadersLike =
|
|
5
6
|
| Headers
|
|
6
7
|
| readonly HeaderValue[][]
|
|
@@ -39,11 +40,12 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
let shouldClear = false;
|
|
42
|
-
let iter: Iterable<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
let iter: Iterable<HeaderEntry>;
|
|
44
|
+
// Snapshot the iterable protocol across realms without rereading a caller-controlled getter.
|
|
45
|
+
const iterator: (() => Iterator<HeaderEntry>) | undefined =
|
|
46
|
+
Symbol.iterator in headers ? headers[Symbol.iterator] : undefined;
|
|
47
|
+
if (typeof iterator === 'function') {
|
|
48
|
+
iter = { [Symbol.iterator]: () => iterator.call(headers) };
|
|
47
49
|
} else {
|
|
48
50
|
shouldClear = true;
|
|
49
51
|
iter = Object.entries(headers ?? {});
|
package/src/internal/parse.ts
CHANGED
|
@@ -53,7 +53,7 @@ export async function defaultParseResponse<T>(
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const contentType = response.headers.get('content-type');
|
|
56
|
-
const mediaType = contentType?.split(';')[0]?.trim();
|
|
56
|
+
const mediaType = contentType?.split(';')[0]?.trim().toLowerCase();
|
|
57
57
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
58
58
|
if (isJSON) {
|
|
59
59
|
const contentLength = response.headers.get('content-length');
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OpenAI } from '../client';
|
|
2
|
+
|
|
3
|
+
/** Selects a captured credential without treating an explicit null as absent. @internal */
|
|
4
|
+
export function getRealtimeAPIKey(
|
|
5
|
+
client: Pick<OpenAI, 'apiKey'> | undefined,
|
|
6
|
+
captured: string | null | undefined,
|
|
7
|
+
): string | null | undefined {
|
|
8
|
+
return captured === undefined ? client?.apiKey : captured;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Captures the key belonging to this factory invocation while retaining the
|
|
13
|
+
* existing boolean credential-hook contract. Legacy overrides that do not
|
|
14
|
+
* capture a key keep their shared-property behavior and remain responsible for
|
|
15
|
+
* synchronizing concurrent credential updates.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export async function resolveRealtimeAPIKey(client: Pick<OpenAI, 'apiKey' | '_callApiKey'>): Promise<{
|
|
19
|
+
apiKey: string | null;
|
|
20
|
+
isProvider: boolean;
|
|
21
|
+
}> {
|
|
22
|
+
let apiKey: string | null | undefined;
|
|
23
|
+
const isProvider = await client._callApiKey((resolved) => {
|
|
24
|
+
apiKey = resolved;
|
|
25
|
+
});
|
|
26
|
+
return { apiKey: apiKey === undefined ? client.apiKey : apiKey, isProvider };
|
|
27
|
+
}
|
package/src/internal/to-file.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BlobPart } from './uploads';
|
|
2
|
-
import { getName, makeFile, isAsyncIterable, checkFileSupport } from './uploads';
|
|
2
|
+
import { getName, makeFile, isAsyncIterable, isArrayBuffer, checkFileSupport } from './uploads';
|
|
3
3
|
import type { FilePropertyBag } from './builtin-types';
|
|
4
4
|
|
|
5
5
|
/** Text, binary content, or a Blob-compatible value accepted inside a file stream. */
|
|
@@ -106,7 +106,8 @@ export type ToFileInput =
|
|
|
106
106
|
* filename and metadata are unchanged. Renamed native files reuse the original
|
|
107
107
|
* file contents without buffering and retain their MIME type and modification
|
|
108
108
|
* time unless explicitly overridden. Other filenames are inferred from response
|
|
109
|
-
* URLs or input metadata when omitted, falling back to `unknown_file`.
|
|
109
|
+
* URLs or input metadata when omitted or null, falling back to `unknown_file`.
|
|
110
|
+
* An explicit empty filename is preserved. Responses,
|
|
110
111
|
* native or compatible `Blob` values, and compatible non-native files supply
|
|
111
112
|
* their MIME type unless `options.type` provides an explicit override.
|
|
112
113
|
*
|
|
@@ -148,7 +149,7 @@ export async function toFile(
|
|
|
148
149
|
|
|
149
150
|
if (isResponseLike(value)) {
|
|
150
151
|
const blob = await value.blob();
|
|
151
|
-
name
|
|
152
|
+
name ??= getName(value);
|
|
152
153
|
|
|
153
154
|
const responseOptions =
|
|
154
155
|
options?.type === undefined && blob.type ? { ...options, type: blob.type } : options;
|
|
@@ -157,7 +158,7 @@ export async function toFile(
|
|
|
157
158
|
|
|
158
159
|
const parts = await getBytes(value);
|
|
159
160
|
|
|
160
|
-
name
|
|
161
|
+
name ??= getName(value);
|
|
161
162
|
|
|
162
163
|
if (options?.type === undefined) {
|
|
163
164
|
const typedPart = parts.find(
|
|
@@ -176,7 +177,7 @@ async function getBytes(value: BlobLikePart | AsyncIterable<BlobLikePart>): Prom
|
|
|
176
177
|
if (
|
|
177
178
|
typeof value === 'string' ||
|
|
178
179
|
ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
|
|
179
|
-
value
|
|
180
|
+
isArrayBuffer(value)
|
|
180
181
|
) {
|
|
181
182
|
parts.push(value);
|
|
182
183
|
} else if (isBlobLike(value)) {
|
package/src/internal/uploads.ts
CHANGED
|
@@ -196,6 +196,17 @@ function normalizeFilenamePath(value: string): string {
|
|
|
196
196
|
return normalized;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
const arrayBufferByteLengthGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength')?.get;
|
|
200
|
+
|
|
201
|
+
/** Recognizes native ArrayBuffers across realms without trusting their prototype or string tag. */
|
|
202
|
+
export function isArrayBuffer(value: unknown): value is ArrayBuffer {
|
|
203
|
+
try {
|
|
204
|
+
return arrayBufferByteLengthGetter?.call(value) !== undefined;
|
|
205
|
+
} catch {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
199
210
|
/** Identifies objects that expose a callable `Symbol.asyncIterator` method. */
|
|
200
211
|
export const isAsyncIterable = (value: any): value is AsyncIterable<any> =>
|
|
201
212
|
value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
|
|
@@ -538,7 +549,7 @@ async function* iterateBytes(value: unknown): AsyncGenerator<Uint8Array> {
|
|
|
538
549
|
yield encodeUTF8(value);
|
|
539
550
|
} else if (ArrayBuffer.isView(value)) {
|
|
540
551
|
yield new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
541
|
-
} else if (value
|
|
552
|
+
} else if (isArrayBuffer(value)) {
|
|
542
553
|
yield new Uint8Array(value);
|
|
543
554
|
} else if (value instanceof Response) {
|
|
544
555
|
yield* iterateBytes(value.body || (await value.blob()));
|
|
@@ -46,6 +46,9 @@ export const toFloat32Array = (base64Str: string): Array<number> => {
|
|
|
46
46
|
if (typeof Buffer !== 'undefined') {
|
|
47
47
|
// for Node.js environment
|
|
48
48
|
const buf = Buffer.from(base64Str, 'base64');
|
|
49
|
+
if (buf.length % Float32Array.BYTES_PER_ELEMENT !== 0) {
|
|
50
|
+
throw new RangeError('Invalid base64-encoded float32 array: byte length must be a multiple of 4');
|
|
51
|
+
}
|
|
49
52
|
return Array.from(
|
|
50
53
|
new Float32Array(buf.buffer, buf.byteOffset, buf.length / Float32Array.BYTES_PER_ELEMENT),
|
|
51
54
|
);
|
|
@@ -128,6 +128,7 @@ export class AbstractChatCompletionRunner<
|
|
|
128
128
|
> extends EventStream<EventTypes> {
|
|
129
129
|
protected _chatCompletions: ParsedChatCompletion<ParsedT>[] = [];
|
|
130
130
|
#completionArrivedBeforeAbort = false;
|
|
131
|
+
#afterCompletionInvoked = false;
|
|
131
132
|
/** Mutable conversation history, including initial input, assistant replies, and tool results. */
|
|
132
133
|
messages: ChatCompletionMessageParam[] = [];
|
|
133
134
|
|
|
@@ -150,8 +151,9 @@ export class AbstractChatCompletionRunner<
|
|
|
150
151
|
this: AbstractChatCompletionRunner<AbstractChatCompletionRunnerEvents, ParsedT>,
|
|
151
152
|
message: ChatCompletionMessageParam,
|
|
152
153
|
emit = true,
|
|
154
|
+
normalizeContent = true,
|
|
153
155
|
) {
|
|
154
|
-
if (!('content' in message)) {
|
|
156
|
+
if (normalizeContent && !('content' in message)) {
|
|
155
157
|
message.content = null;
|
|
156
158
|
}
|
|
157
159
|
|
|
@@ -305,6 +307,9 @@ export class AbstractChatCompletionRunner<
|
|
|
305
307
|
protected override _emitFinal(
|
|
306
308
|
this: AbstractChatCompletionRunner<AbstractChatCompletionRunnerEvents, ParsedT>,
|
|
307
309
|
) {
|
|
310
|
+
if (this.#afterCompletionInvoked) {
|
|
311
|
+
this.#throwIfAborted();
|
|
312
|
+
}
|
|
308
313
|
const completion = this._chatCompletions[this._chatCompletions.length - 1];
|
|
309
314
|
if (completion) {
|
|
310
315
|
this._emit('finalChatCompletion', completion);
|
|
@@ -333,6 +338,18 @@ export class AbstractChatCompletionRunner<
|
|
|
333
338
|
}
|
|
334
339
|
}
|
|
335
340
|
|
|
341
|
+
#throwIfAborted() {
|
|
342
|
+
if (this.controller.signal.aborted) {
|
|
343
|
+
const error = new APIUserAbortError();
|
|
344
|
+
Object.defineProperty(error, 'cause', {
|
|
345
|
+
value: this.controller.signal.reason,
|
|
346
|
+
writable: true,
|
|
347
|
+
configurable: true,
|
|
348
|
+
});
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
336
353
|
static #validateParams(params: ChatCompletionCreateParams): void {
|
|
337
354
|
if (params.n != null && params.n > 1) {
|
|
338
355
|
throw new OpenAIError(
|
|
@@ -363,7 +380,7 @@ export class AbstractChatCompletionRunner<
|
|
|
363
380
|
options?: RequestOptions,
|
|
364
381
|
): Promise<ChatCompletion> {
|
|
365
382
|
for (const message of params.messages) {
|
|
366
|
-
this._addMessage(message, false);
|
|
383
|
+
this._addMessage(message, false, false);
|
|
367
384
|
}
|
|
368
385
|
return await this._createChatCompletion(client, params, options);
|
|
369
386
|
}
|
|
@@ -384,6 +401,14 @@ export class AbstractChatCompletionRunner<
|
|
|
384
401
|
const singleFunctionToCall =
|
|
385
402
|
typeof tool_choice !== 'string' && tool_choice.type === 'function' && tool_choice?.function?.name;
|
|
386
403
|
const { maxChatCompletions = DEFAULT_MAX_CHAT_COMPLETIONS, afterCompletion } = options || {};
|
|
404
|
+
const runAfterCompletion = async (completion: ChatCompletion) => {
|
|
405
|
+
if (afterCompletion == null) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
this.#afterCompletionInvoked = true;
|
|
409
|
+
await afterCompletion(completion, runner);
|
|
410
|
+
this.#throwIfAborted();
|
|
411
|
+
};
|
|
387
412
|
|
|
388
413
|
// Normalize tool definitions before invoking callbacks.
|
|
389
414
|
const inputTools = params.tools.map((tool): RunnableToolFunction<any> => {
|
|
@@ -433,7 +458,7 @@ export class AbstractChatCompletionRunner<
|
|
|
433
458
|
: (undefined as any);
|
|
434
459
|
|
|
435
460
|
for (const message of params.messages) {
|
|
436
|
-
this._addMessage(message, false);
|
|
461
|
+
this._addMessage(message, false, false);
|
|
437
462
|
}
|
|
438
463
|
|
|
439
464
|
type ToolCallResult = {
|
|
@@ -519,7 +544,7 @@ export class AbstractChatCompletionRunner<
|
|
|
519
544
|
throw new OpenAIError(`missing message in ChatCompletion response`);
|
|
520
545
|
}
|
|
521
546
|
if (!message.tool_calls?.length) {
|
|
522
|
-
await
|
|
547
|
+
await runAfterCompletion(chatCompletion);
|
|
523
548
|
return;
|
|
524
549
|
}
|
|
525
550
|
|
|
@@ -534,7 +559,7 @@ export class AbstractChatCompletionRunner<
|
|
|
534
559
|
}
|
|
535
560
|
|
|
536
561
|
if (singleFunctionToCall && result.functionCalled) {
|
|
537
|
-
await
|
|
562
|
+
await runAfterCompletion(chatCompletion);
|
|
538
563
|
return;
|
|
539
564
|
}
|
|
540
565
|
}
|
|
@@ -563,7 +588,7 @@ export class AbstractChatCompletionRunner<
|
|
|
563
588
|
}
|
|
564
589
|
}
|
|
565
590
|
|
|
566
|
-
await
|
|
591
|
+
await runAfterCompletion(chatCompletion);
|
|
567
592
|
}
|
|
568
593
|
}
|
|
569
594
|
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
} from '../resources/beta/threads/runs/runs';
|
|
21
21
|
import type { ReadableStream } from '../internal/shim-types';
|
|
22
22
|
import { Stream } from '../streaming';
|
|
23
|
-
import { APIUserAbortError, OpenAIError } from '../error';
|
|
23
|
+
import { APIError, APIUserAbortError, OpenAIError } from '../error';
|
|
24
24
|
import type {
|
|
25
25
|
AssistantStreamEvent,
|
|
26
26
|
MessageStreamEvent,
|
|
@@ -322,7 +322,10 @@ export class AssistantStream
|
|
|
322
322
|
return Object.values(this.#runStepSnapshots);
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
/**
|
|
325
|
+
/**
|
|
326
|
+
* Waits for successful completion and returns the final snapshot of every observed message.
|
|
327
|
+
* Terminal message events replace accumulated snapshots without mutating earlier snapshots.
|
|
328
|
+
*/
|
|
326
329
|
async finalMessages(): Promise<Message[]> {
|
|
327
330
|
await this.done();
|
|
328
331
|
|
|
@@ -479,6 +482,9 @@ export class AssistantStream
|
|
|
479
482
|
case 'thread.message.delta':
|
|
480
483
|
case 'thread.message.completed':
|
|
481
484
|
case 'thread.message.incomplete': {
|
|
485
|
+
if (messageID !== undefined && this.#messageSnapshot) {
|
|
486
|
+
this.#reserveMessageAlias(this.#messageSnapshot, messageID);
|
|
487
|
+
}
|
|
482
488
|
this.#handleMessage(stableEvent);
|
|
483
489
|
if (messageID !== undefined) {
|
|
484
490
|
this.#reserveMessageAlias(stableEvent.data, messageID);
|
|
@@ -491,10 +497,7 @@ export class AssistantStream
|
|
|
491
497
|
}
|
|
492
498
|
|
|
493
499
|
case 'error': {
|
|
494
|
-
|
|
495
|
-
throw new Error(
|
|
496
|
-
'Encountered an error event in event processing - errors should be processed earlier',
|
|
497
|
-
);
|
|
500
|
+
throw new APIError(undefined, stableEvent.data, undefined, undefined);
|
|
498
501
|
}
|
|
499
502
|
default: {
|
|
500
503
|
assertNever(stableEvent);
|
|
@@ -522,6 +525,13 @@ export class AssistantStream
|
|
|
522
525
|
throw new OpenAIError('Received assistant run-step event with an invalid run-step ID');
|
|
523
526
|
}
|
|
524
527
|
|
|
528
|
+
if (event.event === 'thread.run.step.delta') {
|
|
529
|
+
const delta = event.data.delta;
|
|
530
|
+
if (delta && hasOwn(delta, 'id')) {
|
|
531
|
+
throw new OpenAIError('Run-step deltas must not contain an id field');
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
525
535
|
if (event.event === 'thread.run.step.created') {
|
|
526
536
|
if (this.#activeRunStepID !== undefined) {
|
|
527
537
|
throw new OpenAIError(
|
|
@@ -839,10 +849,14 @@ export class AssistantStream
|
|
|
839
849
|
throw new Error('Received a RunStepDelta before creation of a snapshot');
|
|
840
850
|
}
|
|
841
851
|
|
|
842
|
-
const
|
|
852
|
+
const delta = event.data.delta;
|
|
843
853
|
|
|
844
|
-
if (
|
|
845
|
-
|
|
854
|
+
if (delta) {
|
|
855
|
+
// Raw-event listeners can replace or modify the delta after initial validation.
|
|
856
|
+
if (hasOwn(delta, 'id')) {
|
|
857
|
+
throw new OpenAIError('Run-step deltas must not contain an id field');
|
|
858
|
+
}
|
|
859
|
+
const accumulated = accumulateAssistantStreamDelta(snapshot, delta, true) as Runs.RunStep;
|
|
846
860
|
this.#runStepSnapshots[runStepID] = accumulated;
|
|
847
861
|
}
|
|
848
862
|
|
|
@@ -921,9 +935,9 @@ export class AssistantStream
|
|
|
921
935
|
case 'thread.message.in_progress':
|
|
922
936
|
case 'thread.message.completed':
|
|
923
937
|
case 'thread.message.incomplete': {
|
|
924
|
-
//
|
|
938
|
+
//Terminal events provide the authoritative message snapshot.
|
|
925
939
|
if (snapshot) {
|
|
926
|
-
return [snapshot, newContent];
|
|
940
|
+
return [event.event === 'thread.message.in_progress' ? snapshot : event.data, newContent];
|
|
927
941
|
}
|
|
928
942
|
throw new Error('Received thread message event with no existing snapshot');
|
|
929
943
|
}
|
|
@@ -11,7 +11,7 @@ import type { AutoParseableTool } from '../lib/parser';
|
|
|
11
11
|
|
|
12
12
|
/** Events emitted while executing a non-streaming chat completion tool run. */
|
|
13
13
|
export interface ChatCompletionRunnerEvents extends AbstractChatCompletionRunnerEvents {
|
|
14
|
-
/** Called when
|
|
14
|
+
/** Called when a new assistant message with nonempty text is received; input history is not emitted. */
|
|
15
15
|
content: (content: string) => void;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -88,14 +88,18 @@ export class ChatCompletionRunner<ParsedT = null> extends AbstractChatCompletion
|
|
|
88
88
|
return runner;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Appends a conversation message and emits text content for assistant replies.
|
|
93
|
+
* @param normalizeContent Defaults to true; initial history passes false to preserve caller-owned messages.
|
|
94
|
+
*/
|
|
92
95
|
override _addMessage(
|
|
93
96
|
this: ChatCompletionRunner<ParsedT>,
|
|
94
97
|
message: ChatCompletionMessageParam,
|
|
95
98
|
emit = true,
|
|
99
|
+
normalizeContent = true,
|
|
96
100
|
) {
|
|
97
|
-
super._addMessage(message, emit);
|
|
98
|
-
if (isAssistantMessage(message) && message.content) {
|
|
101
|
+
super._addMessage(message, emit, normalizeContent);
|
|
102
|
+
if (emit && isAssistantMessage(message) && message.content) {
|
|
99
103
|
this._emit('content', message.content as string);
|
|
100
104
|
}
|
|
101
105
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MalformedJSON, partialParse } from '../_vendor/partial-json-parser/parser';
|
|
2
2
|
import {
|
|
3
|
+
APIError,
|
|
3
4
|
APIUserAbortError,
|
|
4
5
|
ContentFilterFinishReasonError,
|
|
5
6
|
LengthFinishReasonError,
|
|
@@ -1517,6 +1518,9 @@ export class ChatCompletionStream<ParsedT = null>
|
|
|
1517
1518
|
);
|
|
1518
1519
|
}
|
|
1519
1520
|
|
|
1521
|
+
if (choiceSnapshot.finish_reason) {
|
|
1522
|
+
state.done_tool_calls.add(toolCallIndex);
|
|
1523
|
+
}
|
|
1520
1524
|
this._emit('tool_calls.function.arguments.done', {
|
|
1521
1525
|
name: toolCallSnapshot.function.name,
|
|
1522
1526
|
index: toolCallIndex,
|
|
@@ -1771,6 +1775,10 @@ export class ChatCompletionStream<ParsedT = null>
|
|
|
1771
1775
|
);
|
|
1772
1776
|
let chatId;
|
|
1773
1777
|
for await (const item of stream) {
|
|
1778
|
+
if ('error' in item && hasOwn(item, 'error') && typeof item.error === 'object' && item.error !== null) {
|
|
1779
|
+
throw new APIError(undefined, item.error, undefined, undefined);
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1774
1782
|
if (isChatCompletionReadableStreamMessage(item)) {
|
|
1775
1783
|
const message = getChatCompletionReadableStreamMessage(item);
|
|
1776
1784
|
if (this.#currentChatCompletionSnapshot) {
|
|
@@ -96,6 +96,7 @@ export class ChatCompletionStreamingRunner<ParsedT = null>
|
|
|
96
96
|
throw new OpenAIError('cannot serialize a tool message before receiving any chunks');
|
|
97
97
|
}
|
|
98
98
|
push(makeChatCompletionReadableStreamMessageChunk(lastChunk, message, toolCallIds));
|
|
99
|
+
toolCallIds = undefined;
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
102
|
this.on('chunk', onChunk);
|
package/src/lib/EventEmitter.ts
CHANGED
|
@@ -14,6 +14,20 @@ export type EventParameters<Events, EventType extends keyof Events> = Record<
|
|
|
14
14
|
EventListener<Events, EventType> extends (...args: infer P) => any ? P : never
|
|
15
15
|
>[EventType];
|
|
16
16
|
|
|
17
|
+
/** Result of awaiting an event: no value, one unwrapped value, or its argument tuple. */
|
|
18
|
+
export type EmittedEventResult<Args extends unknown[]> = [Args] extends [[infer Param]]
|
|
19
|
+
? Param
|
|
20
|
+
: [Args] extends [[]]
|
|
21
|
+
? void
|
|
22
|
+
: [Args] extends [[unknown?]]
|
|
23
|
+
? Args[0]
|
|
24
|
+
: [Args] extends [[unknown, unknown, ...unknown[]]]
|
|
25
|
+
? Args
|
|
26
|
+
:
|
|
27
|
+
| Args
|
|
28
|
+
| ([] extends Args ? undefined : never)
|
|
29
|
+
| (Args extends [...infer Prefix, infer Last] ? ([] extends Prefix ? Last : never) : Args[0]);
|
|
30
|
+
|
|
17
31
|
/** A lightweight event emitter with type-safe listeners and promise-based event waiting. */
|
|
18
32
|
export class EventEmitter<EventTypes extends Record<string, (...args: any) => any>> {
|
|
19
33
|
#listeners: {
|
|
@@ -145,13 +159,7 @@ export class EventEmitter<EventTypes extends Record<string, (...args: any) => an
|
|
|
145
159
|
*/
|
|
146
160
|
emitted<Event extends keyof EventTypes>(
|
|
147
161
|
event: Event,
|
|
148
|
-
): Promise<
|
|
149
|
-
EventParameters<EventTypes, Event> extends [infer Param]
|
|
150
|
-
? Param
|
|
151
|
-
: EventParameters<EventTypes, Event> extends []
|
|
152
|
-
? void
|
|
153
|
-
: EventParameters<EventTypes, Event>
|
|
154
|
-
> {
|
|
162
|
+
): Promise<EmittedEventResult<EventParameters<EventTypes, Event>>> {
|
|
155
163
|
return new Promise((resolve, reject) => {
|
|
156
164
|
const onError = (error: unknown) => {
|
|
157
165
|
this.off(event, onEvent as any);
|
|
@@ -191,7 +199,8 @@ export class EventEmitter<EventTypes extends Record<string, (...args: any) => an
|
|
|
191
199
|
for (const registration of listeners as any) {
|
|
192
200
|
if (!registration.removed) {
|
|
193
201
|
try {
|
|
194
|
-
|
|
202
|
+
const { listener } = registration;
|
|
203
|
+
listener(...(args as any));
|
|
195
204
|
} catch (error) {
|
|
196
205
|
if (!listenerThrew) {
|
|
197
206
|
listenerThrew = true;
|