@ai-sdk/provider-utils 5.0.0-beta.21 → 5.0.0-beta.23
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 +12 -0
- package/dist/index.d.ts +16 -21
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/as-array.ts +12 -0
- package/src/index.ts +2 -0
- package/src/types/infer-tool-set-context.ts +7 -9
- package/src/types/union-to-intersection.ts +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 5.0.0-beta.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 350ea38: refactoring: introduce Arrayable type
|
|
8
|
+
|
|
9
|
+
## 5.0.0-beta.22
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 083947b: feat(ai): separate toolsContext from context
|
|
14
|
+
|
|
3
15
|
## 5.0.0-beta.21
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,16 @@ import * as z4 from 'zod/v4';
|
|
|
7
7
|
export { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from '@workflow/serde';
|
|
8
8
|
export { EventSourceMessage, EventSourceParserStream } from 'eventsource-parser/stream';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* A value that can be provided either as a single item, an array of items,
|
|
12
|
+
* or be left undefined.
|
|
13
|
+
*/
|
|
14
|
+
type Arrayable<T> = T | T[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes a possibly undefined or non-array value into an array.
|
|
17
|
+
*/
|
|
18
|
+
declare function asArray<T>(value: Arrayable<T>): T[];
|
|
19
|
+
|
|
10
20
|
declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
|
|
11
21
|
|
|
12
22
|
/**
|
|
@@ -1604,31 +1614,16 @@ declare function executeTool<TOOL extends Tool>({ tool, input, options, }: {
|
|
|
1604
1614
|
*/
|
|
1605
1615
|
type ToolSet = Record<string, (Tool<never, never, any> | Tool<any, any, any> | Tool<any, never, any> | Tool<never, any, any>) & Pick<Tool<any, any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta' | 'needsApproval'>>;
|
|
1606
1616
|
|
|
1607
|
-
/**
|
|
1608
|
-
* Converts a union type `U` into an intersection type.
|
|
1609
|
-
*
|
|
1610
|
-
* For example:
|
|
1611
|
-
* type A = { a: number };
|
|
1612
|
-
* type B = { b: string };
|
|
1613
|
-
* type Union = A | B;
|
|
1614
|
-
* type Intersection = UnionToIntersection<Union>;
|
|
1615
|
-
* // Intersection is: { a: number } & { b: string }
|
|
1616
|
-
*
|
|
1617
|
-
* This is useful when you have a union of object types and need a type with all possible properties.
|
|
1618
|
-
*/
|
|
1619
|
-
type UnionToIntersection<U> = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
|
|
1620
|
-
|
|
1621
1617
|
/**
|
|
1622
1618
|
* Infer the context type for a tool set.
|
|
1623
1619
|
*
|
|
1624
|
-
* The inferred type
|
|
1625
|
-
* tools in the set.
|
|
1620
|
+
* The inferred type maps each tool name to its required context type.
|
|
1626
1621
|
*
|
|
1627
|
-
*
|
|
1622
|
+
* Tools without required context properties are omitted from the result.
|
|
1628
1623
|
*/
|
|
1629
|
-
type InferToolSetContext<TOOLS extends ToolSet> =
|
|
1630
|
-
[K in keyof TOOLS]: InferToolContext<NoInfer<TOOLS[K]>>;
|
|
1631
|
-
}
|
|
1624
|
+
type InferToolSetContext<TOOLS extends ToolSet> = {
|
|
1625
|
+
[K in keyof TOOLS as InferToolContext<NoInfer<TOOLS[K]>> extends never ? never : K]: InferToolContext<NoInfer<TOOLS[K]>>;
|
|
1626
|
+
};
|
|
1632
1627
|
|
|
1633
1628
|
/**
|
|
1634
1629
|
* Typed tool call that is returned by generateText and streamText.
|
|
@@ -1689,4 +1684,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
1689
1684
|
dynamic?: boolean;
|
|
1690
1685
|
}
|
|
1691
1686
|
|
|
1692
|
-
export { type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type ExecutableTool, type FetchFunction, type FilePart, type FlexibleSchema, type HasRequiredKey, type IdGenerator, type ImagePart, type InferSchema, type InferToolContext, type InferToolInput, type InferToolOutput, type InferToolSetContext, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderReference, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type ToolSet, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isCustomReasoning, isExecutableTool, isNonNullable, isParsableJson, isProviderReference, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1687
|
+
export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type ExecutableTool, type FetchFunction, type FilePart, type FlexibleSchema, type HasRequiredKey, type IdGenerator, type ImagePart, type InferSchema, type InferToolContext, type InferToolInput, type InferToolOutput, type InferToolSetContext, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderReference, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type ToolSet, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asArray, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isCustomReasoning, isExecutableTool, isNonNullable, isParsableJson, isProviderReference, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// src/as-array.ts
|
|
2
|
+
function asArray(value) {
|
|
3
|
+
return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
// src/combine-headers.ts
|
|
2
7
|
function combineHeaders(...headers) {
|
|
3
8
|
return headers.reduce(
|
|
@@ -566,7 +571,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
566
571
|
}
|
|
567
572
|
|
|
568
573
|
// src/version.ts
|
|
569
|
-
var VERSION = true ? "5.0.0-beta.
|
|
574
|
+
var VERSION = true ? "5.0.0-beta.23" : "0.0.0-test";
|
|
570
575
|
|
|
571
576
|
// src/get-from-api.ts
|
|
572
577
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -2818,6 +2823,7 @@ export {
|
|
|
2818
2823
|
VERSION,
|
|
2819
2824
|
WORKFLOW_DESERIALIZE,
|
|
2820
2825
|
WORKFLOW_SERIALIZE,
|
|
2826
|
+
asArray,
|
|
2821
2827
|
asSchema,
|
|
2822
2828
|
combineHeaders,
|
|
2823
2829
|
convertAsyncIteratorToReadableStream,
|