@ai-sdk/provider-utils 3.0.17 → 3.0.18
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 +6 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,24 @@ declare function delay(delayInMs?: number | null, options?: {
|
|
|
28
28
|
abortSignal?: AbortSignal;
|
|
29
29
|
}): Promise<void>;
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Delayed promise. It is only constructed once the value is accessed.
|
|
33
|
+
* This is useful to avoid unhandled promise rejections when the promise is created
|
|
34
|
+
* but not accessed.
|
|
35
|
+
*/
|
|
36
|
+
declare class DelayedPromise<T> {
|
|
37
|
+
private status;
|
|
38
|
+
private _promise;
|
|
39
|
+
private _resolve;
|
|
40
|
+
private _reject;
|
|
41
|
+
get promise(): Promise<T>;
|
|
42
|
+
resolve(value: T): void;
|
|
43
|
+
reject(error: unknown): void;
|
|
44
|
+
isResolved(): boolean;
|
|
45
|
+
isRejected(): boolean;
|
|
46
|
+
isPending(): boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
/**
|
|
32
50
|
Extracts the headers from a response object and returns them as a key-value object.
|
|
33
51
|
|
|
@@ -939,4 +957,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
939
957
|
dynamic?: boolean;
|
|
940
958
|
}
|
|
941
959
|
|
|
942
|
-
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type FlexibleValidator, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type InferValidator, type LazySchema, type LazyValidator, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, lazySchema, lazyValidator, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, tool, validateTypes, validator, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
960
|
+
export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type FlexibleValidator, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type InferValidator, type LazySchema, type LazyValidator, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, lazySchema, lazyValidator, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, tool, validateTypes, validator, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,24 @@ declare function delay(delayInMs?: number | null, options?: {
|
|
|
28
28
|
abortSignal?: AbortSignal;
|
|
29
29
|
}): Promise<void>;
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Delayed promise. It is only constructed once the value is accessed.
|
|
33
|
+
* This is useful to avoid unhandled promise rejections when the promise is created
|
|
34
|
+
* but not accessed.
|
|
35
|
+
*/
|
|
36
|
+
declare class DelayedPromise<T> {
|
|
37
|
+
private status;
|
|
38
|
+
private _promise;
|
|
39
|
+
private _resolve;
|
|
40
|
+
private _reject;
|
|
41
|
+
get promise(): Promise<T>;
|
|
42
|
+
resolve(value: T): void;
|
|
43
|
+
reject(error: unknown): void;
|
|
44
|
+
isResolved(): boolean;
|
|
45
|
+
isRejected(): boolean;
|
|
46
|
+
isPending(): boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
/**
|
|
32
50
|
Extracts the headers from a response object and returns them as a key-value object.
|
|
33
51
|
|
|
@@ -939,4 +957,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
939
957
|
dynamic?: boolean;
|
|
940
958
|
}
|
|
941
959
|
|
|
942
|
-
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type FlexibleValidator, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type InferValidator, type LazySchema, type LazyValidator, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, lazySchema, lazyValidator, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, tool, validateTypes, validator, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
960
|
+
export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type FlexibleValidator, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type InferValidator, type LazySchema, type LazyValidator, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, lazySchema, lazyValidator, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, tool, validateTypes, validator, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
+
DelayedPromise: () => DelayedPromise,
|
|
34
35
|
EventSourceParserStream: () => import_stream2.EventSourceParserStream,
|
|
35
36
|
VERSION: () => VERSION,
|
|
36
37
|
asSchema: () => asSchema,
|
|
@@ -169,6 +170,53 @@ function createAbortError() {
|
|
|
169
170
|
return new DOMException("Delay was aborted", "AbortError");
|
|
170
171
|
}
|
|
171
172
|
|
|
173
|
+
// src/delayed-promise.ts
|
|
174
|
+
var DelayedPromise = class {
|
|
175
|
+
constructor() {
|
|
176
|
+
this.status = { type: "pending" };
|
|
177
|
+
this._resolve = void 0;
|
|
178
|
+
this._reject = void 0;
|
|
179
|
+
}
|
|
180
|
+
get promise() {
|
|
181
|
+
if (this._promise) {
|
|
182
|
+
return this._promise;
|
|
183
|
+
}
|
|
184
|
+
this._promise = new Promise((resolve2, reject) => {
|
|
185
|
+
if (this.status.type === "resolved") {
|
|
186
|
+
resolve2(this.status.value);
|
|
187
|
+
} else if (this.status.type === "rejected") {
|
|
188
|
+
reject(this.status.error);
|
|
189
|
+
}
|
|
190
|
+
this._resolve = resolve2;
|
|
191
|
+
this._reject = reject;
|
|
192
|
+
});
|
|
193
|
+
return this._promise;
|
|
194
|
+
}
|
|
195
|
+
resolve(value) {
|
|
196
|
+
var _a;
|
|
197
|
+
this.status = { type: "resolved", value };
|
|
198
|
+
if (this._promise) {
|
|
199
|
+
(_a = this._resolve) == null ? void 0 : _a.call(this, value);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
reject(error) {
|
|
203
|
+
var _a;
|
|
204
|
+
this.status = { type: "rejected", error };
|
|
205
|
+
if (this._promise) {
|
|
206
|
+
(_a = this._reject) == null ? void 0 : _a.call(this, error);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
isResolved() {
|
|
210
|
+
return this.status.type === "resolved";
|
|
211
|
+
}
|
|
212
|
+
isRejected() {
|
|
213
|
+
return this.status.type === "rejected";
|
|
214
|
+
}
|
|
215
|
+
isPending() {
|
|
216
|
+
return this.status.type === "pending";
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
172
220
|
// src/extract-response-headers.ts
|
|
173
221
|
function extractResponseHeaders(response) {
|
|
174
222
|
return Object.fromEntries([...response.headers]);
|
|
@@ -308,7 +356,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
308
356
|
}
|
|
309
357
|
|
|
310
358
|
// src/version.ts
|
|
311
|
-
var VERSION = true ? "3.0.
|
|
359
|
+
var VERSION = true ? "3.0.18" : "0.0.0-test";
|
|
312
360
|
|
|
313
361
|
// src/get-from-api.ts
|
|
314
362
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -2429,6 +2477,7 @@ __reExport(src_exports, require("@standard-schema/spec"), module.exports);
|
|
|
2429
2477
|
var import_stream2 = require("eventsource-parser/stream");
|
|
2430
2478
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2431
2479
|
0 && (module.exports = {
|
|
2480
|
+
DelayedPromise,
|
|
2432
2481
|
EventSourceParserStream,
|
|
2433
2482
|
VERSION,
|
|
2434
2483
|
asSchema,
|