ai 7.0.0-beta.106 → 7.0.0-beta.107
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 +9 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.js +22 -18
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +3 -3
- package/dist/internal/index.js +4 -7
- package/dist/internal/index.js.map +1 -1
- package/docs/08-migration-guides/23-migration-guide-7-0.mdx +32 -0
- package/package.json +3 -3
- package/src/agent/agent.ts +2 -3
- package/src/agent/create-agent-ui-stream-response.ts +2 -4
- package/src/agent/create-agent-ui-stream.ts +2 -4
- package/src/agent/pipe-agent-ui-stream-to-response.ts +2 -4
- package/src/agent/tool-loop-agent-settings.ts +2 -3
- package/src/generate-text/core-events.ts +3 -8
- package/src/generate-text/generate-text.ts +3 -4
- package/src/generate-text/stream-text.ts +7 -11
- package/src/middleware/wrap-embedding-model.ts +1 -1
- package/src/middleware/wrap-image-model.ts +1 -1
- package/src/middleware/wrap-language-model.ts +1 -1
- package/src/prompt/convert-to-language-model-prompt.ts +1 -1
- package/src/prompt/standardize-prompt.ts +1 -1
- package/src/telemetry/create-unified-telemetry.ts +3 -2
- package/src/telemetry/telemetry-options.ts +2 -1
- package/src/util/notify.ts +3 -4
- package/src/util/as-array.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.0-beta.107
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 350ea38: refactoring: introduce Arrayable type
|
|
8
|
+
- Updated dependencies [350ea38]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
10
|
+
- @ai-sdk/gateway@4.0.0-beta.59
|
|
11
|
+
|
|
3
12
|
## 7.0.0-beta.106
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GatewayModelId } from '@ai-sdk/gateway';
|
|
2
2
|
export { GatewayModelId, createGateway, gateway } from '@ai-sdk/gateway';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
|
-
import { ToolSet, InferToolInput, InferToolOutput, FlexibleSchema, InferSchema, SystemModelMessage, ModelMessage, ProviderOptions, AssistantModelMessage, ToolModelMessage, Context, InferToolSetContext, ReasoningPart, ReasoningFilePart, Tool, ToolCall, IdGenerator, UserModelMessage, DataContent, ToolNeedsApprovalFunction, InferToolContext, HasRequiredKey, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
+
import { ToolSet, InferToolInput, InferToolOutput, FlexibleSchema, InferSchema, SystemModelMessage, ModelMessage, ProviderOptions, AssistantModelMessage, ToolModelMessage, Context, InferToolSetContext, ReasoningPart, ReasoningFilePart, Tool, ToolCall, IdGenerator, Arrayable, UserModelMessage, DataContent, ToolNeedsApprovalFunction, InferToolContext, HasRequiredKey, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
export { AssistantContent, AssistantModelMessage, DataContent, DownloadError, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallPart, ToolContent, ToolExecuteFunction, ToolExecutionOptions, ToolModelMessage, ToolResultPart, ToolSet, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
6
6
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
7
7
|
import { EmbeddingModelV4, EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV4Embedding, EmbeddingModelV4Middleware, ImageModelV4, ImageModelV3, ImageModelV2, ImageModelV4ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV4Middleware, JSONValue as JSONValue$1, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, LanguageModelV4Middleware, RerankingModelV4, RerankingModelV3, SharedV4ProviderMetadata, SharedV4ProviderReference, SpeechModelV4, SpeechModelV3, SpeechModelV2, TranscriptionModelV4, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV4Usage, LanguageModelV4CallOptions, LanguageModelV4Prompt, AISDKError, LanguageModelV4ToolCall, JSONSchema7, SharedV4Headers, JSONParseError, TypeValidationError, Experimental_VideoModelV4, Experimental_VideoModelV3, EmbeddingModelV4CallOptions, ProviderV4, ProviderV3, ProviderV2, FilesV4, SkillsV4, NoSuchModelError, SkillsV4UploadSkillResult, SkillsV4File } from '@ai-sdk/provider';
|
|
@@ -2513,7 +2513,7 @@ interface OnStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends
|
|
|
2513
2513
|
* Condition(s) for stopping the generation.
|
|
2514
2514
|
* When the condition is an array, any of the conditions can be met to stop.
|
|
2515
2515
|
*/
|
|
2516
|
-
readonly stopWhen:
|
|
2516
|
+
readonly stopWhen: Arrayable<StopCondition<NoInfer<TOOLS>, RUNTIME_CONTEXT>>;
|
|
2517
2517
|
/** The output specification for structured outputs, if configured. */
|
|
2518
2518
|
readonly output: OUTPUT | undefined;
|
|
2519
2519
|
/** Whether telemetry is enabled. Defaults to `true`. */
|
|
@@ -2579,7 +2579,7 @@ interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT exte
|
|
|
2579
2579
|
* Condition(s) for stopping the generation.
|
|
2580
2580
|
* When the condition is an array, any of the conditions can be met to stop.
|
|
2581
2581
|
*/
|
|
2582
|
-
readonly stopWhen:
|
|
2582
|
+
readonly stopWhen: Arrayable<StopCondition<TOOLS, RUNTIME_CONTEXT>>;
|
|
2583
2583
|
/** The output specification for structured outputs, if configured. */
|
|
2584
2584
|
readonly output: OUTPUT | undefined;
|
|
2585
2585
|
/** Identifier from telemetry settings for grouping related operations. */
|
|
@@ -2974,7 +2974,7 @@ type TelemetryOptions = {
|
|
|
2974
2974
|
* When provided, these integrations will take precedence over the globally registered
|
|
2975
2975
|
* integrations for this call.
|
|
2976
2976
|
*/
|
|
2977
|
-
integrations?: TelemetryIntegration
|
|
2977
|
+
integrations?: Arrayable<TelemetryIntegration>;
|
|
2978
2978
|
};
|
|
2979
2979
|
|
|
2980
2980
|
/**
|
|
@@ -3318,7 +3318,7 @@ declare function streamText<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Conte
|
|
|
3318
3318
|
*
|
|
3319
3319
|
* @default isStepCount(1)
|
|
3320
3320
|
*/
|
|
3321
|
-
stopWhen?:
|
|
3321
|
+
stopWhen?: Arrayable<StopCondition<NoInfer<TOOLS>, RUNTIME_CONTEXT>>;
|
|
3322
3322
|
/**
|
|
3323
3323
|
* Optional telemetry configuration (experimental).
|
|
3324
3324
|
*/
|
|
@@ -3376,7 +3376,7 @@ declare function streamText<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Conte
|
|
|
3376
3376
|
* They are applied in the order they are provided.
|
|
3377
3377
|
* The stream transformations must maintain the stream structure for streamText to work correctly.
|
|
3378
3378
|
*/
|
|
3379
|
-
experimental_transform?:
|
|
3379
|
+
experimental_transform?: Arrayable<StreamTextTransform<TOOLS>>;
|
|
3380
3380
|
/**
|
|
3381
3381
|
* Custom download function to use for URLs.
|
|
3382
3382
|
*
|
|
@@ -3764,7 +3764,7 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RUN
|
|
|
3764
3764
|
*
|
|
3765
3765
|
* @default isStepCount(20)
|
|
3766
3766
|
*/
|
|
3767
|
-
stopWhen?:
|
|
3767
|
+
stopWhen?: Arrayable<StopCondition<NoInfer<TOOLS>, RUNTIME_CONTEXT>>;
|
|
3768
3768
|
/**
|
|
3769
3769
|
* Optional telemetry configuration (experimental).
|
|
3770
3770
|
*/
|
|
@@ -3925,7 +3925,7 @@ type AgentStreamParameters<CALL_OPTIONS, TOOLS extends ToolSet, RUNTIME_CONTEXT
|
|
|
3925
3925
|
* They are applied in the order they are provided.
|
|
3926
3926
|
* The stream transformations must maintain the stream structure for streamText to work correctly.
|
|
3927
3927
|
*/
|
|
3928
|
-
experimental_transform?:
|
|
3928
|
+
experimental_transform?: Arrayable<StreamTextTransform<TOOLS>>;
|
|
3929
3929
|
};
|
|
3930
3930
|
/**
|
|
3931
3931
|
* An Agent receives a prompt (text or messages) and generates or streams an output
|
|
@@ -4147,7 +4147,7 @@ declare function generateText<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Con
|
|
|
4147
4147
|
*
|
|
4148
4148
|
* @default isStepCount(1)
|
|
4149
4149
|
*/
|
|
4150
|
-
stopWhen?:
|
|
4150
|
+
stopWhen?: Arrayable<StopCondition<NoInfer<TOOLS>, RUNTIME_CONTEXT>>;
|
|
4151
4151
|
/**
|
|
4152
4152
|
* Optional telemetry configuration (experimental).
|
|
4153
4153
|
*/
|
|
@@ -4428,7 +4428,7 @@ declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
4428
4428
|
abortSignal?: AbortSignal;
|
|
4429
4429
|
timeout?: TimeoutConfiguration<TOOLS>;
|
|
4430
4430
|
options?: CALL_OPTIONS;
|
|
4431
|
-
experimental_transform?:
|
|
4431
|
+
experimental_transform?: Arrayable<StreamTextTransform<TOOLS>>;
|
|
4432
4432
|
onStepFinish?: ToolLoopAgentOnStepFinishCallback<TOOLS>;
|
|
4433
4433
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<Response>;
|
|
4434
4434
|
|
|
@@ -5215,7 +5215,7 @@ declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet
|
|
|
5215
5215
|
abortSignal?: AbortSignal;
|
|
5216
5216
|
timeout?: TimeoutConfiguration<TOOLS>;
|
|
5217
5217
|
options?: CALL_OPTIONS;
|
|
5218
|
-
experimental_transform?:
|
|
5218
|
+
experimental_transform?: Arrayable<StreamTextTransform<TOOLS>>;
|
|
5219
5219
|
onStepFinish?: ToolLoopAgentOnStepFinishCallback<TOOLS>;
|
|
5220
5220
|
} & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<AsyncIterableStream<InferUIMessageChunk<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>>>;
|
|
5221
5221
|
|
|
@@ -5242,7 +5242,7 @@ declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
5242
5242
|
abortSignal?: AbortSignal;
|
|
5243
5243
|
timeout?: TimeoutConfiguration<TOOLS>;
|
|
5244
5244
|
options?: CALL_OPTIONS;
|
|
5245
|
-
experimental_transform?:
|
|
5245
|
+
experimental_transform?: Arrayable<StreamTextTransform<TOOLS>>;
|
|
5246
5246
|
onStepFinish?: ToolLoopAgentOnStepFinishCallback<TOOLS>;
|
|
5247
5247
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<void>;
|
|
5248
5248
|
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
|
|
20
20
|
// src/generate-text/generate-text.ts
|
|
21
21
|
import {
|
|
22
|
+
asArray as asArray5,
|
|
22
23
|
createIdGenerator,
|
|
23
24
|
getErrorMessage as getErrorMessage5,
|
|
24
25
|
withUserAgentSuffix as withUserAgentSuffix2
|
|
@@ -1010,6 +1011,7 @@ function getGlobalProvider() {
|
|
|
1010
1011
|
|
|
1011
1012
|
// src/prompt/convert-to-language-model-prompt.ts
|
|
1012
1013
|
import {
|
|
1014
|
+
asArray,
|
|
1013
1015
|
isProviderReference,
|
|
1014
1016
|
isUrlSupported
|
|
1015
1017
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1261,7 +1263,7 @@ import {
|
|
|
1261
1263
|
} from "@ai-sdk/provider-utils";
|
|
1262
1264
|
|
|
1263
1265
|
// src/version.ts
|
|
1264
|
-
var VERSION = true ? "7.0.0-beta.
|
|
1266
|
+
var VERSION = true ? "7.0.0-beta.107" : "0.0.0-test";
|
|
1265
1267
|
|
|
1266
1268
|
// src/util/download/download.ts
|
|
1267
1269
|
var download = async ({
|
|
@@ -1410,11 +1412,6 @@ function convertDataContentToUint8Array(content) {
|
|
|
1410
1412
|
throw new InvalidDataContentError({ content });
|
|
1411
1413
|
}
|
|
1412
1414
|
|
|
1413
|
-
// src/util/as-array.ts
|
|
1414
|
-
function asArray(value) {
|
|
1415
|
-
return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
1415
|
// src/prompt/convert-to-language-model-prompt.ts
|
|
1419
1416
|
async function convertToLanguageModelPrompt({
|
|
1420
1417
|
prompt,
|
|
@@ -2160,6 +2157,7 @@ function getToolTimeoutMs(timeout, toolName) {
|
|
|
2160
2157
|
// src/prompt/standardize-prompt.ts
|
|
2161
2158
|
import { InvalidPromptError as InvalidPromptError2 } from "@ai-sdk/provider";
|
|
2162
2159
|
import {
|
|
2160
|
+
asArray as asArray2,
|
|
2163
2161
|
safeValidateTypes
|
|
2164
2162
|
} from "@ai-sdk/provider-utils";
|
|
2165
2163
|
import { z as z6 } from "zod/v4";
|
|
@@ -2413,7 +2411,7 @@ async function standardizePrompt(prompt) {
|
|
|
2413
2411
|
message: "prompt and messages cannot be defined at the same time"
|
|
2414
2412
|
});
|
|
2415
2413
|
}
|
|
2416
|
-
if (prompt.system != null && typeof prompt.system !== "string" && !
|
|
2414
|
+
if (prompt.system != null && typeof prompt.system !== "string" && !asArray2(prompt.system).every(
|
|
2417
2415
|
(message) => typeof message === "object" && message !== null && "role" in message && message.role === "system"
|
|
2418
2416
|
)) {
|
|
2419
2417
|
throw new InvalidPromptError2({
|
|
@@ -2485,6 +2483,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
2485
2483
|
);
|
|
2486
2484
|
}
|
|
2487
2485
|
|
|
2486
|
+
// src/telemetry/create-unified-telemetry.ts
|
|
2487
|
+
import { asArray as asArray3 } from "@ai-sdk/provider-utils";
|
|
2488
|
+
|
|
2488
2489
|
// src/util/merge-callbacks.ts
|
|
2489
2490
|
function mergeCallbacks(...callbacks) {
|
|
2490
2491
|
return async (event) => {
|
|
@@ -2512,7 +2513,7 @@ function getGlobalTelemetryIntegrations() {
|
|
|
2512
2513
|
function createUnifiedTelemetry({
|
|
2513
2514
|
integrations: localIntegrations
|
|
2514
2515
|
}) {
|
|
2515
|
-
const integrations = localIntegrations != null ?
|
|
2516
|
+
const integrations = localIntegrations != null ? asArray3(localIntegrations) : getGlobalTelemetryIntegrations();
|
|
2516
2517
|
const mergeTelemetryCallback = (key) => mergeCallbacks(
|
|
2517
2518
|
...integrations.map((integration) => {
|
|
2518
2519
|
var _a21;
|
|
@@ -2708,12 +2709,11 @@ function mergeObjects(base, overrides) {
|
|
|
2708
2709
|
}
|
|
2709
2710
|
|
|
2710
2711
|
// src/util/notify.ts
|
|
2712
|
+
import { asArray as asArray4 } from "@ai-sdk/provider-utils";
|
|
2711
2713
|
async function notify(options) {
|
|
2712
|
-
for (const callback of
|
|
2713
|
-
if (callback == null)
|
|
2714
|
-
continue;
|
|
2714
|
+
for (const callback of asArray4(options.callbacks)) {
|
|
2715
2715
|
try {
|
|
2716
|
-
await callback(options.event);
|
|
2716
|
+
await (callback == null ? void 0 : callback(options.event));
|
|
2717
2717
|
} catch (e) {
|
|
2718
2718
|
}
|
|
2719
2719
|
}
|
|
@@ -4256,7 +4256,7 @@ async function generateText({
|
|
|
4256
4256
|
}) {
|
|
4257
4257
|
var _a21, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4258
4258
|
const model = resolveLanguageModel(modelArg);
|
|
4259
|
-
const stopConditions =
|
|
4259
|
+
const stopConditions = asArray5(stopWhen);
|
|
4260
4260
|
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
4261
4261
|
const stepTimeoutMs = getStepTimeoutMs(timeout);
|
|
4262
4262
|
const stepAbortController = stepTimeoutMs != null ? new AbortController() : void 0;
|
|
@@ -4984,6 +4984,7 @@ import {
|
|
|
4984
4984
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
4985
4985
|
} from "@ai-sdk/provider";
|
|
4986
4986
|
import {
|
|
4987
|
+
asArray as asArray6,
|
|
4987
4988
|
createIdGenerator as createIdGenerator2,
|
|
4988
4989
|
DelayedPromise,
|
|
4989
4990
|
isAbortError as isAbortError2
|
|
@@ -6678,10 +6679,10 @@ function streamText({
|
|
|
6678
6679
|
toolsContext,
|
|
6679
6680
|
runtimeContext,
|
|
6680
6681
|
toolChoice,
|
|
6681
|
-
transforms:
|
|
6682
|
+
transforms: asArray6(transform),
|
|
6682
6683
|
activeTools,
|
|
6683
6684
|
repairToolCall,
|
|
6684
|
-
stopConditions:
|
|
6685
|
+
stopConditions: asArray6(stopWhen),
|
|
6685
6686
|
output,
|
|
6686
6687
|
toolNeedsApproval,
|
|
6687
6688
|
providerOptions,
|
|
@@ -12115,6 +12116,7 @@ ${examplesSection}` : examplesSection;
|
|
|
12115
12116
|
}
|
|
12116
12117
|
|
|
12117
12118
|
// src/middleware/wrap-language-model.ts
|
|
12119
|
+
import { asArray as asArray7 } from "@ai-sdk/provider-utils";
|
|
12118
12120
|
var wrapLanguageModel = ({
|
|
12119
12121
|
model: inputModel,
|
|
12120
12122
|
middleware: middlewareArg,
|
|
@@ -12122,7 +12124,7 @@ var wrapLanguageModel = ({
|
|
|
12122
12124
|
providerId
|
|
12123
12125
|
}) => {
|
|
12124
12126
|
const model = asLanguageModelV4(inputModel);
|
|
12125
|
-
return [...
|
|
12127
|
+
return [...asArray7(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {
|
|
12126
12128
|
return doWrap({ model: wrappedModel, middleware, modelId, providerId });
|
|
12127
12129
|
}, model);
|
|
12128
12130
|
};
|
|
@@ -12172,6 +12174,7 @@ var doWrap = ({
|
|
|
12172
12174
|
};
|
|
12173
12175
|
|
|
12174
12176
|
// src/middleware/wrap-embedding-model.ts
|
|
12177
|
+
import { asArray as asArray8 } from "@ai-sdk/provider-utils";
|
|
12175
12178
|
var wrapEmbeddingModel = ({
|
|
12176
12179
|
model: inputModel,
|
|
12177
12180
|
middleware: middlewareArg,
|
|
@@ -12179,7 +12182,7 @@ var wrapEmbeddingModel = ({
|
|
|
12179
12182
|
providerId
|
|
12180
12183
|
}) => {
|
|
12181
12184
|
const model = asEmbeddingModelV4(inputModel);
|
|
12182
|
-
return [...
|
|
12185
|
+
return [...asArray8(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {
|
|
12183
12186
|
return doWrap2({ model: wrappedModel, middleware, modelId, providerId });
|
|
12184
12187
|
}, model);
|
|
12185
12188
|
};
|
|
@@ -12221,6 +12224,7 @@ var doWrap2 = ({
|
|
|
12221
12224
|
};
|
|
12222
12225
|
|
|
12223
12226
|
// src/middleware/wrap-image-model.ts
|
|
12227
|
+
import { asArray as asArray9 } from "@ai-sdk/provider-utils";
|
|
12224
12228
|
var wrapImageModel = ({
|
|
12225
12229
|
model: inputModel,
|
|
12226
12230
|
middleware: middlewareArg,
|
|
@@ -12228,7 +12232,7 @@ var wrapImageModel = ({
|
|
|
12228
12232
|
providerId
|
|
12229
12233
|
}) => {
|
|
12230
12234
|
const model = asImageModelV4(inputModel);
|
|
12231
|
-
return [...
|
|
12235
|
+
return [...asArray9(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {
|
|
12232
12236
|
return doWrap3({ model: wrappedModel, middleware, modelId, providerId });
|
|
12233
12237
|
}, model);
|
|
12234
12238
|
};
|