@lmnr-ai/lmnr 0.8.48 → 0.8.50
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/dist/cli.cjs +19 -14
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +2 -2
- package/dist/cli.d.mts +2 -2
- package/dist/cli.mjs +16 -11
- package/dist/cli.mjs.map +1 -1
- package/dist/{evaluations-4bQ4UuTj.d.mts → evaluations-BVaPPf0j.d.mts} +1679 -1305
- package/dist/{evaluations-CbHnDCAY.d.cts → evaluations-C8cI_XIE.d.cts} +1682 -1307
- package/dist/{file-utils-Ci0oAv2f.mjs → file-utils-DOEv6ccL.mjs} +47 -18
- package/dist/file-utils-DOEv6ccL.mjs.map +1 -0
- package/dist/{file-utils-BvYQiFYO.cjs → file-utils-RXJzJyiI.cjs} +47 -18
- package/dist/file-utils-RXJzJyiI.cjs.map +1 -0
- package/dist/index.cjs +164 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1762 -1284
- package/dist/index.d.mts +1762 -1284
- package/dist/index.mjs +164 -54
- package/dist/index.mjs.map +1 -1
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.cjs +114 -102
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.cjs.map +1 -1
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.d.cts +776 -372
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.d.mts +776 -372
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.mjs +114 -102
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.mjs.map +1 -1
- package/dist/{rolldown-runtime-2rV9d50f.mjs → rolldown-runtime-B4iAMlE-.mjs} +2 -2
- package/dist/{rolldown-runtime-CVvi-lCc.cjs → rolldown-runtime-Ctb5zv51.cjs} +1 -1
- package/dist/{utils-BNApHb06.cjs → utils-CNR1tzh5.cjs} +10 -9
- package/dist/utils-CNR1tzh5.cjs.map +1 -0
- package/dist/{utils-OZ7rROM9.mjs → utils-DRrXCfun.mjs} +9 -8
- package/dist/{utils-OZ7rROM9.mjs.map → utils-DRrXCfun.mjs.map} +1 -1
- package/package.json +6 -8
- package/dist/file-utils-BvYQiFYO.cjs.map +0 -1
- package/dist/file-utils-Ci0oAv2f.mjs.map +0 -1
- package/dist/utils-BNApHb06.cjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as TracingLevel, _ as MaskInputOptions, a as HumanEvaluator, b as SpanType, c as InitializeOptions, d as LaminarClient, f as Dataset, g as LaminarSpanContext, h as Event, i as EvaluatorFunctionReturn, l as EvaluationDataset, m as EvaluationDatapointDatasetLink, o as evaluate, p as EvaluationDatapoint, r as EvaluatorFunction, s as StringUUID, t as Datapoint, u as LaminarDataset, v as PushDatapointsResponse, x as TraceType, y as SessionRecordingOptions } from "./evaluations-C8cI_XIE.cjs";
|
|
2
2
|
import { ServerResponse } from "node:http";
|
|
3
3
|
import { ReadableSpan, SpanExporter, SpanProcessor, TimedEvent } from "@opentelemetry/sdk-trace-base";
|
|
4
4
|
import { AttributeValue, Attributes, Context, Exception, HrTime, Link, Span, Span as Span$1, SpanContext, SpanKind, SpanStatus, TimeInput, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
@@ -9,7 +9,6 @@ import { $ZodType } from "zod/v4/core";
|
|
|
9
9
|
import { ServerResponse as ServerResponse$1 } from "http";
|
|
10
10
|
import { ZodType } from "zod/v4";
|
|
11
11
|
import { Instrumentation } from "@opentelemetry/instrumentation";
|
|
12
|
-
|
|
13
12
|
//#region src/decorators.d.ts
|
|
14
13
|
interface ObserveOptions {
|
|
15
14
|
name?: string;
|
|
@@ -59,7 +58,7 @@ interface ObserveOptions {
|
|
|
59
58
|
* }, 'hello');
|
|
60
59
|
* ```
|
|
61
60
|
*/
|
|
62
|
-
declare function observe<A extends unknown[], F extends (...args: A) => ReturnType<F>>(options: ObserveOptions, fn: F, ...args: A): ReturnType<F>;
|
|
61
|
+
export declare function observe<A extends unknown[], F extends (...args: A) => ReturnType<F>>(options: ObserveOptions, fn: F, ...args: A): ReturnType<F>;
|
|
63
62
|
/**
|
|
64
63
|
* Sets the tracing level for any spans inside the function. This is useful for
|
|
65
64
|
* conditionally disabling the tracing for certain functions.
|
|
@@ -79,7 +78,7 @@ declare function observe<A extends unknown[], F extends (...args: A) => ReturnTy
|
|
|
79
78
|
* });
|
|
80
79
|
* ```
|
|
81
80
|
*/
|
|
82
|
-
declare function withTracingLevel<A extends unknown[], F extends (...args: A) => ReturnType<F>>(tracingLevel: TracingLevel, fn: F, ...args: A): ReturnType<F>;
|
|
81
|
+
export declare function withTracingLevel<A extends unknown[], F extends (...args: A) => ReturnType<F>>(tracingLevel: TracingLevel, fn: F, ...args: A): ReturnType<F>;
|
|
83
82
|
/**
|
|
84
83
|
* Decorator that wraps a method to automatically observe it with Laminar tracing.
|
|
85
84
|
* This decorator uses the TypeScript 5.0+ standard decorator syntax.
|
|
@@ -121,7 +120,7 @@ declare function withTracingLevel<A extends unknown[], F extends (...args: A) =>
|
|
|
121
120
|
* }
|
|
122
121
|
* ```
|
|
123
122
|
*/
|
|
124
|
-
declare function observeDecorator<This, Args extends unknown[], Return>(config: Partial<ObserveOptions> | ((thisArg: This, ...funcArgs: Args) => Partial<ObserveOptions>)): (originalMethod: (this: This, ...args: Args) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>) => (this: This, ...args: Args) => Return;
|
|
123
|
+
export declare function observeDecorator<This, Args extends unknown[], Return>(config: Partial<ObserveOptions> | ((thisArg: This, ...funcArgs: Args) => Partial<ObserveOptions>)): (originalMethod: (this: This, ...args: Args) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>) => (this: This, ...args: Args) => Return;
|
|
125
124
|
/**
|
|
126
125
|
* Decorator that wraps a method to automatically observe it with Laminar tracing.
|
|
127
126
|
* This decorator uses the legacy experimental decorator syntax
|
|
@@ -167,7 +166,7 @@ declare function observeDecorator<This, Args extends unknown[], Return>(config:
|
|
|
167
166
|
* }
|
|
168
167
|
* ```
|
|
169
168
|
*/
|
|
170
|
-
declare function observeExperimentalDecorator(config: Partial<ObserveOptions> | ((thisArg: unknown, ...funcArgs: unknown[]) => Partial<ObserveOptions>)): (_target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
169
|
+
export declare function observeExperimentalDecorator(config: Partial<ObserveOptions> | ((thisArg: unknown, ...funcArgs: unknown[]) => Partial<ObserveOptions>)): (_target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
171
170
|
//#endregion
|
|
172
171
|
//#region src/integrations/eve.d.ts
|
|
173
172
|
/**
|
|
@@ -358,7 +357,7 @@ interface LaminarReporterOptions {
|
|
|
358
357
|
* });
|
|
359
358
|
* ```
|
|
360
359
|
*/
|
|
361
|
-
declare class LaminarReporter implements EvalReporter {
|
|
360
|
+
export declare class LaminarReporter implements EvalReporter {
|
|
362
361
|
private readonly options;
|
|
363
362
|
private client?;
|
|
364
363
|
private evalId?;
|
|
@@ -1136,11 +1135,7 @@ declare class AISDKError extends Error {
|
|
|
1136
1135
|
* @param {string} params.message - The error message.
|
|
1137
1136
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
1138
1137
|
*/
|
|
1139
|
-
constructor({
|
|
1140
|
-
name,
|
|
1141
|
-
message,
|
|
1142
|
-
cause
|
|
1143
|
-
}: {
|
|
1138
|
+
constructor({ name, message, cause }: {
|
|
1144
1139
|
name: string;
|
|
1145
1140
|
message: string;
|
|
1146
1141
|
cause?: unknown;
|
|
@@ -1163,18 +1158,7 @@ declare class APICallError extends AISDKError {
|
|
|
1163
1158
|
readonly responseBody?: string;
|
|
1164
1159
|
readonly isRetryable: boolean;
|
|
1165
1160
|
readonly data?: unknown;
|
|
1166
|
-
constructor({
|
|
1167
|
-
message,
|
|
1168
|
-
url,
|
|
1169
|
-
requestBodyValues,
|
|
1170
|
-
statusCode,
|
|
1171
|
-
responseHeaders,
|
|
1172
|
-
responseBody,
|
|
1173
|
-
cause,
|
|
1174
|
-
isRetryable,
|
|
1175
|
-
// server error
|
|
1176
|
-
data
|
|
1177
|
-
}: {
|
|
1161
|
+
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable, data }: {
|
|
1178
1162
|
message: string;
|
|
1179
1163
|
url: string;
|
|
1180
1164
|
requestBodyValues: unknown;
|
|
@@ -1190,13 +1174,12 @@ declare class APICallError extends AISDKError {
|
|
|
1190
1174
|
declare const symbol$c$1: unique symbol;
|
|
1191
1175
|
declare class EmptyResponseBodyError extends AISDKError {
|
|
1192
1176
|
private readonly [symbol$c$1];
|
|
1193
|
-
constructor({
|
|
1194
|
-
message
|
|
1195
|
-
}?: {
|
|
1177
|
+
constructor({ message }?: {
|
|
1196
1178
|
message?: string;
|
|
1197
1179
|
});
|
|
1198
1180
|
static isInstance(error: unknown): error is EmptyResponseBodyError;
|
|
1199
1181
|
}
|
|
1182
|
+
declare function getErrorMessage(error: unknown | undefined): string;
|
|
1200
1183
|
declare const symbol$a$1: unique symbol;
|
|
1201
1184
|
/**
|
|
1202
1185
|
* A prompt is invalid. This error should be thrown by providers when they cannot
|
|
@@ -1205,91 +1188,70 @@ declare const symbol$a$1: unique symbol;
|
|
|
1205
1188
|
declare class InvalidPromptError extends AISDKError {
|
|
1206
1189
|
private readonly [symbol$a$1];
|
|
1207
1190
|
readonly prompt: unknown;
|
|
1208
|
-
constructor({
|
|
1209
|
-
prompt,
|
|
1210
|
-
message,
|
|
1211
|
-
cause
|
|
1212
|
-
}: {
|
|
1191
|
+
constructor({ prompt, message, cause }: {
|
|
1213
1192
|
prompt: unknown;
|
|
1214
1193
|
message: string;
|
|
1215
1194
|
cause?: unknown;
|
|
1216
1195
|
});
|
|
1217
1196
|
static isInstance(error: unknown): error is InvalidPromptError;
|
|
1218
1197
|
}
|
|
1219
|
-
declare const symbol$9$
|
|
1198
|
+
declare const symbol$9$2: unique symbol;
|
|
1220
1199
|
/**
|
|
1221
1200
|
* Server returned a response with invalid data content.
|
|
1222
1201
|
* This should be thrown by providers when they cannot parse the response from the API.
|
|
1223
1202
|
*/
|
|
1224
1203
|
declare class InvalidResponseDataError extends AISDKError {
|
|
1225
|
-
private readonly [symbol$9$
|
|
1204
|
+
private readonly [symbol$9$2];
|
|
1226
1205
|
readonly data: unknown;
|
|
1227
|
-
constructor({
|
|
1228
|
-
data,
|
|
1229
|
-
message
|
|
1230
|
-
}: {
|
|
1206
|
+
constructor({ data, message }: {
|
|
1231
1207
|
data: unknown;
|
|
1232
1208
|
message?: string;
|
|
1233
1209
|
});
|
|
1234
1210
|
static isInstance(error: unknown): error is InvalidResponseDataError;
|
|
1235
1211
|
}
|
|
1236
|
-
declare const symbol$8$
|
|
1212
|
+
declare const symbol$8$2: unique symbol;
|
|
1237
1213
|
declare class JSONParseError extends AISDKError {
|
|
1238
|
-
private readonly [symbol$8$
|
|
1214
|
+
private readonly [symbol$8$2];
|
|
1239
1215
|
readonly text: string;
|
|
1240
|
-
constructor({
|
|
1241
|
-
text,
|
|
1242
|
-
cause
|
|
1243
|
-
}: {
|
|
1216
|
+
constructor({ text, cause }: {
|
|
1244
1217
|
text: string;
|
|
1245
1218
|
cause: unknown;
|
|
1246
1219
|
});
|
|
1247
1220
|
static isInstance(error: unknown): error is JSONParseError;
|
|
1248
1221
|
}
|
|
1249
|
-
declare const symbol$7$
|
|
1222
|
+
declare const symbol$7$2: unique symbol;
|
|
1250
1223
|
declare class LoadAPIKeyError extends AISDKError {
|
|
1251
|
-
private readonly [symbol$7$
|
|
1252
|
-
constructor({
|
|
1253
|
-
message
|
|
1254
|
-
}: {
|
|
1224
|
+
private readonly [symbol$7$2];
|
|
1225
|
+
constructor({ message }: {
|
|
1255
1226
|
message: string;
|
|
1256
1227
|
});
|
|
1257
1228
|
static isInstance(error: unknown): error is LoadAPIKeyError;
|
|
1258
1229
|
}
|
|
1259
|
-
declare const symbol$6$
|
|
1230
|
+
declare const symbol$6$2: unique symbol;
|
|
1260
1231
|
declare class LoadSettingError extends AISDKError {
|
|
1261
|
-
private readonly [symbol$6$
|
|
1262
|
-
constructor({
|
|
1263
|
-
message
|
|
1264
|
-
}: {
|
|
1232
|
+
private readonly [symbol$6$2];
|
|
1233
|
+
constructor({ message }: {
|
|
1265
1234
|
message: string;
|
|
1266
1235
|
});
|
|
1267
1236
|
static isInstance(error: unknown): error is LoadSettingError;
|
|
1268
1237
|
}
|
|
1269
|
-
declare const symbol$5$
|
|
1238
|
+
declare const symbol$5$2: unique symbol;
|
|
1270
1239
|
/**
|
|
1271
1240
|
* Thrown when the AI provider fails to generate any content.
|
|
1272
1241
|
*/
|
|
1273
1242
|
declare class NoContentGeneratedError extends AISDKError {
|
|
1274
|
-
private readonly [symbol$5$
|
|
1275
|
-
constructor({
|
|
1276
|
-
message
|
|
1277
|
-
}?: {
|
|
1243
|
+
private readonly [symbol$5$2];
|
|
1244
|
+
constructor({ message }?: {
|
|
1278
1245
|
message?: string;
|
|
1279
1246
|
});
|
|
1280
1247
|
static isInstance(error: unknown): error is NoContentGeneratedError;
|
|
1281
1248
|
}
|
|
1282
|
-
declare const symbol$4$
|
|
1249
|
+
declare const symbol$4$2: unique symbol;
|
|
1283
1250
|
declare class NoSuchModelError extends AISDKError {
|
|
1284
|
-
private readonly [symbol$4$
|
|
1251
|
+
private readonly [symbol$4$2];
|
|
1285
1252
|
readonly modelId: string;
|
|
1286
1253
|
readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
|
|
1287
|
-
constructor({
|
|
1288
|
-
errorName,
|
|
1289
|
-
modelId,
|
|
1290
|
-
modelType,
|
|
1291
|
-
message
|
|
1292
|
-
}: {
|
|
1254
|
+
constructor({ errorName, modelId, modelType, message }: {
|
|
1293
1255
|
errorName?: string;
|
|
1294
1256
|
modelId: string;
|
|
1295
1257
|
modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
|
|
@@ -1297,29 +1259,25 @@ declare class NoSuchModelError extends AISDKError {
|
|
|
1297
1259
|
});
|
|
1298
1260
|
static isInstance(error: unknown): error is NoSuchModelError;
|
|
1299
1261
|
}
|
|
1300
|
-
declare const symbol$3$
|
|
1262
|
+
declare const symbol$3$2: unique symbol;
|
|
1301
1263
|
/**
|
|
1302
1264
|
* Thrown when a provider reference cannot be resolved because the specified
|
|
1303
1265
|
* provider is not found in the provider reference mapping.
|
|
1304
1266
|
*/
|
|
1305
1267
|
declare class NoSuchProviderReferenceError extends AISDKError {
|
|
1306
|
-
private readonly [symbol$3$
|
|
1268
|
+
private readonly [symbol$3$2];
|
|
1307
1269
|
readonly provider: string;
|
|
1308
1270
|
readonly reference: SharedV4ProviderReference;
|
|
1309
|
-
constructor({
|
|
1310
|
-
provider,
|
|
1311
|
-
reference,
|
|
1312
|
-
message
|
|
1313
|
-
}: {
|
|
1271
|
+
constructor({ provider, reference, message }: {
|
|
1314
1272
|
provider: string;
|
|
1315
1273
|
reference: SharedV4ProviderReference;
|
|
1316
1274
|
message?: string;
|
|
1317
1275
|
});
|
|
1318
1276
|
static isInstance(error: unknown): error is NoSuchProviderReferenceError;
|
|
1319
1277
|
}
|
|
1320
|
-
declare const symbol$2$
|
|
1278
|
+
declare const symbol$2$2: unique symbol;
|
|
1321
1279
|
declare class TooManyEmbeddingValuesForCallError extends AISDKError {
|
|
1322
|
-
private readonly [symbol$2$
|
|
1280
|
+
private readonly [symbol$2$2];
|
|
1323
1281
|
readonly provider: string;
|
|
1324
1282
|
readonly modelId: string;
|
|
1325
1283
|
readonly maxEmbeddingsPerCall: number;
|
|
@@ -1332,7 +1290,7 @@ declare class TooManyEmbeddingValuesForCallError extends AISDKError {
|
|
|
1332
1290
|
});
|
|
1333
1291
|
static isInstance(error: unknown): error is TooManyEmbeddingValuesForCallError;
|
|
1334
1292
|
}
|
|
1335
|
-
declare const symbol$1$
|
|
1293
|
+
declare const symbol$1$11: unique symbol;
|
|
1336
1294
|
interface TypeValidationContext {
|
|
1337
1295
|
/**
|
|
1338
1296
|
* Field path in dot notation (e.g., "message.metadata", "message.parts[3].data")
|
|
@@ -1348,14 +1306,10 @@ interface TypeValidationContext {
|
|
|
1348
1306
|
entityId?: string;
|
|
1349
1307
|
}
|
|
1350
1308
|
declare class TypeValidationError extends AISDKError {
|
|
1351
|
-
private readonly [symbol$1$
|
|
1309
|
+
private readonly [symbol$1$11];
|
|
1352
1310
|
readonly value: unknown;
|
|
1353
1311
|
readonly context?: TypeValidationContext;
|
|
1354
|
-
constructor({
|
|
1355
|
-
value,
|
|
1356
|
-
cause,
|
|
1357
|
-
context
|
|
1358
|
-
}: {
|
|
1312
|
+
constructor({ value, cause, context }: {
|
|
1359
1313
|
value: unknown;
|
|
1360
1314
|
cause: unknown;
|
|
1361
1315
|
context?: TypeValidationContext;
|
|
@@ -1372,24 +1326,17 @@ declare class TypeValidationError extends AISDKError {
|
|
|
1372
1326
|
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
1373
1327
|
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
1374
1328
|
*/
|
|
1375
|
-
static wrap({
|
|
1376
|
-
value,
|
|
1377
|
-
cause,
|
|
1378
|
-
context
|
|
1379
|
-
}: {
|
|
1329
|
+
static wrap({ value, cause, context }: {
|
|
1380
1330
|
value: unknown;
|
|
1381
1331
|
cause: unknown;
|
|
1382
1332
|
context?: TypeValidationContext;
|
|
1383
1333
|
}): TypeValidationError;
|
|
1384
1334
|
}
|
|
1385
|
-
declare const symbol$
|
|
1335
|
+
declare const symbol$12: unique symbol;
|
|
1386
1336
|
declare class UnsupportedFunctionalityError extends AISDKError {
|
|
1387
|
-
private readonly [symbol$
|
|
1337
|
+
private readonly [symbol$12];
|
|
1388
1338
|
readonly functionality: string;
|
|
1389
|
-
constructor({
|
|
1390
|
-
functionality,
|
|
1391
|
-
message
|
|
1392
|
-
}: {
|
|
1339
|
+
constructor({ functionality, message }: {
|
|
1393
1340
|
functionality: string;
|
|
1394
1341
|
message?: string;
|
|
1395
1342
|
});
|
|
@@ -2084,11 +2031,6 @@ type ImageModelV4Middleware = {
|
|
|
2084
2031
|
model: ImageModelV4;
|
|
2085
2032
|
}) => Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>>;
|
|
2086
2033
|
};
|
|
2087
|
-
/**
|
|
2088
|
-
* Middleware for ImageModelV3.
|
|
2089
|
-
* This type defines the structure for middleware that can be used to modify
|
|
2090
|
-
* the behavior of ImageModelV3 operations.
|
|
2091
|
-
*/
|
|
2092
2034
|
/**
|
|
2093
2035
|
* A tool has a name, a description, and a set of parameters.
|
|
2094
2036
|
*
|
|
@@ -4165,7 +4107,7 @@ type LanguageModelV3$1 = {
|
|
|
4165
4107
|
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
4166
4108
|
/**
|
|
4167
4109
|
* Generates a language model output (non-streaming).
|
|
4168
|
-
|
|
4110
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
4169
4111
|
* by the user.
|
|
4170
4112
|
*/
|
|
4171
4113
|
doGenerate(options: LanguageModelV3CallOptions$1): PromiseLike<LanguageModelV3GenerateResult$1>;
|
|
@@ -4179,11 +4121,6 @@ type LanguageModelV3$1 = {
|
|
|
4179
4121
|
*/
|
|
4180
4122
|
doStream(options: LanguageModelV3CallOptions$1): PromiseLike<LanguageModelV3StreamResult$1>;
|
|
4181
4123
|
};
|
|
4182
|
-
/**
|
|
4183
|
-
* Experimental middleware for LanguageModelV3.
|
|
4184
|
-
* This type defines the structure for middleware that can be used to modify
|
|
4185
|
-
* the behavior of LanguageModelV3 operations.
|
|
4186
|
-
*/
|
|
4187
4124
|
/**
|
|
4188
4125
|
* A tool has a name, a description, and a set of parameters.
|
|
4189
4126
|
*
|
|
@@ -4925,11 +4862,6 @@ type LanguageModelV2$1 = {
|
|
|
4925
4862
|
};
|
|
4926
4863
|
}>;
|
|
4927
4864
|
};
|
|
4928
|
-
/**
|
|
4929
|
-
* Experimental middleware for LanguageModelV2.
|
|
4930
|
-
* This type defines the structure for middleware that can be used to modify
|
|
4931
|
-
* the behavior of LanguageModelV2 operations.
|
|
4932
|
-
*/
|
|
4933
4865
|
/**
|
|
4934
4866
|
* Middleware for EmbeddingModelV4.
|
|
4935
4867
|
* This type defines the structure for middleware that can be used to modify
|
|
@@ -4994,11 +4926,6 @@ type EmbeddingModelV4Middleware = {
|
|
|
4994
4926
|
model: EmbeddingModelV4;
|
|
4995
4927
|
}) => Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
|
|
4996
4928
|
};
|
|
4997
|
-
/**
|
|
4998
|
-
* Middleware for EmbeddingModelV3.
|
|
4999
|
-
* This type defines the structure for middleware that can be used to modify
|
|
5000
|
-
* the behavior of EmbeddingModelV3 operations.
|
|
5001
|
-
*/
|
|
5002
4929
|
/**
|
|
5003
4930
|
* A normalized language model call within a batch.
|
|
5004
4931
|
*/
|
|
@@ -7950,7 +7877,7 @@ type VideoModelV3 = {
|
|
|
7950
7877
|
}>;
|
|
7951
7878
|
};
|
|
7952
7879
|
//#endregion
|
|
7953
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+provider@2.0.
|
|
7880
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+provider@2.0.4/node_modules/@ai-sdk/provider/dist/index.d.ts
|
|
7954
7881
|
type SharedV2Headers = Record<string, string>;
|
|
7955
7882
|
/**
|
|
7956
7883
|
A JSON value can be a string, number, boolean, object, array, or null.
|
|
@@ -8006,10 +7933,6 @@ type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue$2>>;
|
|
|
8006
7933
|
*/
|
|
8007
7934
|
type SharedV2ProviderOptions = Record<string, Record<string, JSONValue$2>>;
|
|
8008
7935
|
/**
|
|
8009
|
-
An embedding is a vector, i.e. an array of numbers.
|
|
8010
|
-
It is e.g. used to represent a text as a vector of word embeddings.
|
|
8011
|
-
*/
|
|
8012
|
-
/**
|
|
8013
7936
|
A tool has a name, a description, and a set of parameters.
|
|
8014
7937
|
|
|
8015
7938
|
Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
@@ -8018,25 +7941,25 @@ map the user-facing tool definitions to this format.
|
|
|
8018
7941
|
type LanguageModelV2FunctionTool = {
|
|
8019
7942
|
/**
|
|
8020
7943
|
The type of the tool (always 'function').
|
|
8021
|
-
|
|
7944
|
+
*/
|
|
8022
7945
|
type: 'function';
|
|
8023
7946
|
/**
|
|
8024
7947
|
The name of the tool. Unique within this model call.
|
|
8025
|
-
|
|
7948
|
+
*/
|
|
8026
7949
|
name: string;
|
|
8027
7950
|
/**
|
|
8028
7951
|
A description of the tool. The language model uses this to understand the
|
|
8029
7952
|
tool's purpose and to provide better completion suggestions.
|
|
8030
|
-
|
|
7953
|
+
*/
|
|
8031
7954
|
description?: string;
|
|
8032
7955
|
/**
|
|
8033
7956
|
The parameters that the tool expects. The language model uses this to
|
|
8034
7957
|
understand the tool's input requirements and to provide matching suggestions.
|
|
8035
|
-
|
|
7958
|
+
*/
|
|
8036
7959
|
inputSchema: JSONSchema7;
|
|
8037
7960
|
/**
|
|
8038
7961
|
The provider-specific options for the tool.
|
|
8039
|
-
|
|
7962
|
+
*/
|
|
8040
7963
|
providerOptions?: SharedV2ProviderOptions;
|
|
8041
7964
|
};
|
|
8042
7965
|
/**
|
|
@@ -8080,7 +8003,7 @@ interface LanguageModelV2TextPart {
|
|
|
8080
8003
|
type: 'text';
|
|
8081
8004
|
/**
|
|
8082
8005
|
The text content.
|
|
8083
|
-
|
|
8006
|
+
*/
|
|
8084
8007
|
text: string;
|
|
8085
8008
|
/**
|
|
8086
8009
|
* Additional provider-specific options. They are passed through
|
|
@@ -8096,7 +8019,7 @@ interface LanguageModelV2ReasoningPart {
|
|
|
8096
8019
|
type: 'reasoning';
|
|
8097
8020
|
/**
|
|
8098
8021
|
The reasoning text.
|
|
8099
|
-
|
|
8022
|
+
*/
|
|
8100
8023
|
text: string;
|
|
8101
8024
|
/**
|
|
8102
8025
|
* Additional provider-specific options. They are passed through
|
|
@@ -8120,9 +8043,11 @@ interface LanguageModelV2FilePart {
|
|
|
8120
8043
|
data: LanguageModelV2DataContent;
|
|
8121
8044
|
/**
|
|
8122
8045
|
IANA media type of the file.
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8046
|
+
|
|
8047
|
+
Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
|
|
8048
|
+
|
|
8049
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
8050
|
+
*/
|
|
8126
8051
|
mediaType: string;
|
|
8127
8052
|
/**
|
|
8128
8053
|
* Additional provider-specific options. They are passed through
|
|
@@ -8138,15 +8063,15 @@ interface LanguageModelV2ToolCallPart {
|
|
|
8138
8063
|
type: 'tool-call';
|
|
8139
8064
|
/**
|
|
8140
8065
|
ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
8141
|
-
|
|
8066
|
+
*/
|
|
8142
8067
|
toolCallId: string;
|
|
8143
8068
|
/**
|
|
8144
8069
|
Name of the tool that is being called.
|
|
8145
|
-
|
|
8070
|
+
*/
|
|
8146
8071
|
toolName: string;
|
|
8147
8072
|
/**
|
|
8148
8073
|
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
8149
|
-
|
|
8074
|
+
*/
|
|
8150
8075
|
input: unknown;
|
|
8151
8076
|
/**
|
|
8152
8077
|
* Whether the tool call will be executed by the provider.
|
|
@@ -8167,15 +8092,15 @@ interface LanguageModelV2ToolResultPart {
|
|
|
8167
8092
|
type: 'tool-result';
|
|
8168
8093
|
/**
|
|
8169
8094
|
ID of the tool call that this result is associated with.
|
|
8170
|
-
|
|
8095
|
+
*/
|
|
8171
8096
|
toolCallId: string;
|
|
8172
8097
|
/**
|
|
8173
8098
|
Name of the tool that generated this result.
|
|
8174
|
-
|
|
8099
|
+
*/
|
|
8175
8100
|
toolName: string;
|
|
8176
8101
|
/**
|
|
8177
8102
|
Result of the tool call.
|
|
8178
|
-
|
|
8103
|
+
*/
|
|
8179
8104
|
output: LanguageModelV2ToolResultOutput;
|
|
8180
8105
|
/**
|
|
8181
8106
|
* Additional provider-specific options. They are passed through
|
|
@@ -8201,19 +8126,19 @@ type LanguageModelV2ToolResultOutput = {
|
|
|
8201
8126
|
value: Array<{
|
|
8202
8127
|
type: 'text';
|
|
8203
8128
|
/**
|
|
8204
|
-
|
|
8205
|
-
|
|
8129
|
+
Text content.
|
|
8130
|
+
*/
|
|
8206
8131
|
text: string;
|
|
8207
8132
|
} | {
|
|
8208
8133
|
type: 'media';
|
|
8209
8134
|
/**
|
|
8210
|
-
|
|
8211
|
-
|
|
8135
|
+
Base-64 encoded media data.
|
|
8136
|
+
*/
|
|
8212
8137
|
data: string;
|
|
8213
8138
|
/**
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8139
|
+
IANA media type.
|
|
8140
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
8141
|
+
*/
|
|
8217
8142
|
mediaType: string;
|
|
8218
8143
|
}>;
|
|
8219
8144
|
};
|
|
@@ -8223,19 +8148,19 @@ The configuration of a tool that is defined by the provider.
|
|
|
8223
8148
|
type LanguageModelV2ProviderDefinedTool = {
|
|
8224
8149
|
/**
|
|
8225
8150
|
The type of the tool (always 'provider-defined').
|
|
8226
|
-
|
|
8151
|
+
*/
|
|
8227
8152
|
type: 'provider-defined';
|
|
8228
8153
|
/**
|
|
8229
8154
|
The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
|
|
8230
|
-
|
|
8155
|
+
*/
|
|
8231
8156
|
id: `${string}.${string}`;
|
|
8232
8157
|
/**
|
|
8233
8158
|
The name of the tool that the user must use in the tool set.
|
|
8234
|
-
|
|
8159
|
+
*/
|
|
8235
8160
|
name: string;
|
|
8236
8161
|
/**
|
|
8237
8162
|
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
|
8238
|
-
|
|
8163
|
+
*/
|
|
8239
8164
|
args: Record<string, unknown>;
|
|
8240
8165
|
};
|
|
8241
8166
|
type LanguageModelV2ToolChoice = {
|
|
@@ -8251,50 +8176,53 @@ type LanguageModelV2ToolChoice = {
|
|
|
8251
8176
|
type LanguageModelV2CallOptions = {
|
|
8252
8177
|
/**
|
|
8253
8178
|
A language mode prompt is a standardized prompt type.
|
|
8254
|
-
|
|
8179
|
+
|
|
8180
|
+
Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
|
8255
8181
|
user-facing prompt types such as chat or instruction prompts to this format.
|
|
8256
8182
|
That approach allows us to evolve the user facing prompts without breaking
|
|
8257
8183
|
the language model interface.
|
|
8258
|
-
|
|
8184
|
+
*/
|
|
8259
8185
|
prompt: LanguageModelV2Prompt;
|
|
8260
8186
|
/**
|
|
8261
8187
|
Maximum number of tokens to generate.
|
|
8262
|
-
|
|
8188
|
+
*/
|
|
8263
8189
|
maxOutputTokens?: number;
|
|
8264
8190
|
/**
|
|
8265
8191
|
Temperature setting. The range depends on the provider and model.
|
|
8266
|
-
|
|
8192
|
+
*/
|
|
8267
8193
|
temperature?: number;
|
|
8268
8194
|
/**
|
|
8269
8195
|
Stop sequences.
|
|
8270
8196
|
If set, the model will stop generating text when one of the stop sequences is generated.
|
|
8271
8197
|
Providers may have limits on the number of stop sequences.
|
|
8272
|
-
|
|
8198
|
+
*/
|
|
8273
8199
|
stopSequences?: string[];
|
|
8274
8200
|
/**
|
|
8275
8201
|
Nucleus sampling.
|
|
8276
|
-
|
|
8202
|
+
*/
|
|
8277
8203
|
topP?: number;
|
|
8278
8204
|
/**
|
|
8279
8205
|
Only sample from the top K options for each subsequent token.
|
|
8280
|
-
|
|
8206
|
+
|
|
8207
|
+
Used to remove "long tail" low probability responses.
|
|
8281
8208
|
Recommended for advanced use cases only. You usually only need to use temperature.
|
|
8282
|
-
|
|
8209
|
+
*/
|
|
8283
8210
|
topK?: number;
|
|
8284
8211
|
/**
|
|
8285
8212
|
Presence penalty setting. It affects the likelihood of the model to
|
|
8286
8213
|
repeat information that is already in the prompt.
|
|
8287
|
-
|
|
8214
|
+
*/
|
|
8288
8215
|
presencePenalty?: number;
|
|
8289
8216
|
/**
|
|
8290
8217
|
Frequency penalty setting. It affects the likelihood of the model
|
|
8291
8218
|
to repeatedly use the same words or phrases.
|
|
8292
|
-
|
|
8219
|
+
*/
|
|
8293
8220
|
frequencyPenalty?: number;
|
|
8294
8221
|
/**
|
|
8295
8222
|
Response format. The output can either be text or JSON. Default is text.
|
|
8296
|
-
|
|
8297
|
-
|
|
8223
|
+
|
|
8224
|
+
If JSON is selected, a schema can optionally be provided to guide the LLM.
|
|
8225
|
+
*/
|
|
8298
8226
|
responseFormat?: {
|
|
8299
8227
|
type: 'text';
|
|
8300
8228
|
} | {
|
|
@@ -8315,11 +8243,11 @@ type LanguageModelV2CallOptions = {
|
|
|
8315
8243
|
/**
|
|
8316
8244
|
The seed (integer) to use for random sampling. If set and supported
|
|
8317
8245
|
by the model, calls will generate deterministic results.
|
|
8318
|
-
|
|
8246
|
+
*/
|
|
8319
8247
|
seed?: number;
|
|
8320
8248
|
/**
|
|
8321
8249
|
The tools that are available for the model.
|
|
8322
|
-
|
|
8250
|
+
*/
|
|
8323
8251
|
tools?: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>;
|
|
8324
8252
|
/**
|
|
8325
8253
|
Specifies how the tool should be selected. Defaults to 'auto'.
|
|
@@ -8327,16 +8255,16 @@ type LanguageModelV2CallOptions = {
|
|
|
8327
8255
|
toolChoice?: LanguageModelV2ToolChoice;
|
|
8328
8256
|
/**
|
|
8329
8257
|
Include raw chunks in the stream. Only applicable for streaming calls.
|
|
8330
|
-
|
|
8258
|
+
*/
|
|
8331
8259
|
includeRawChunks?: boolean;
|
|
8332
8260
|
/**
|
|
8333
8261
|
Abort signal for cancelling the operation.
|
|
8334
|
-
|
|
8262
|
+
*/
|
|
8335
8263
|
abortSignal?: AbortSignal;
|
|
8336
8264
|
/**
|
|
8337
8265
|
Additional HTTP headers to be sent with the request.
|
|
8338
8266
|
Only applicable for HTTP-based providers.
|
|
8339
|
-
|
|
8267
|
+
*/
|
|
8340
8268
|
headers?: Record<string, string | undefined>;
|
|
8341
8269
|
/**
|
|
8342
8270
|
* Additional provider-specific options. They are passed through
|
|
@@ -8370,16 +8298,18 @@ type LanguageModelV2File = {
|
|
|
8370
8298
|
type: 'file';
|
|
8371
8299
|
/**
|
|
8372
8300
|
The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
8373
|
-
|
|
8374
|
-
|
|
8301
|
+
|
|
8302
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
8303
|
+
*/
|
|
8375
8304
|
mediaType: string;
|
|
8376
8305
|
/**
|
|
8377
8306
|
Generated file data as base64 encoded strings or binary data.
|
|
8378
|
-
|
|
8307
|
+
|
|
8308
|
+
The file data should be returned without any unnecessary conversion.
|
|
8379
8309
|
If the API returns base64 encoded strings, the file data should be returned
|
|
8380
8310
|
as base64 encoded strings. If the API returns binary data, the file data should
|
|
8381
8311
|
be returned as binary data.
|
|
8382
|
-
|
|
8312
|
+
*/
|
|
8383
8313
|
data: string | Uint8Array;
|
|
8384
8314
|
};
|
|
8385
8315
|
/**
|
|
@@ -8452,7 +8382,7 @@ type LanguageModelV2Text = {
|
|
|
8452
8382
|
type: 'text';
|
|
8453
8383
|
/**
|
|
8454
8384
|
The text content.
|
|
8455
|
-
|
|
8385
|
+
*/
|
|
8456
8386
|
text: string;
|
|
8457
8387
|
providerMetadata?: SharedV2ProviderMetadata;
|
|
8458
8388
|
};
|
|
@@ -8533,7 +8463,7 @@ type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-
|
|
|
8533
8463
|
interface LanguageModelV2ResponseMetadata {
|
|
8534
8464
|
/**
|
|
8535
8465
|
ID for the generated response, if the provider sends one.
|
|
8536
|
-
|
|
8466
|
+
*/
|
|
8537
8467
|
id?: string;
|
|
8538
8468
|
/**
|
|
8539
8469
|
Timestamp for the start of the generated response, if the provider sends one.
|
|
@@ -8553,25 +8483,25 @@ provider metadata under your provider's key.
|
|
|
8553
8483
|
type LanguageModelV2Usage = {
|
|
8554
8484
|
/**
|
|
8555
8485
|
The number of input (prompt) tokens used.
|
|
8556
|
-
|
|
8486
|
+
*/
|
|
8557
8487
|
inputTokens: number | undefined;
|
|
8558
8488
|
/**
|
|
8559
8489
|
The number of output (completion) tokens used.
|
|
8560
|
-
|
|
8490
|
+
*/
|
|
8561
8491
|
outputTokens: number | undefined;
|
|
8562
8492
|
/**
|
|
8563
8493
|
The total number of tokens as reported by the provider.
|
|
8564
8494
|
This number might be different from the sum of `inputTokens` and `outputTokens`
|
|
8565
8495
|
and e.g. include reasoning tokens or other overhead.
|
|
8566
|
-
|
|
8496
|
+
*/
|
|
8567
8497
|
totalTokens: number | undefined;
|
|
8568
8498
|
/**
|
|
8569
8499
|
The number of reasoning tokens used.
|
|
8570
|
-
|
|
8500
|
+
*/
|
|
8571
8501
|
reasoningTokens?: number | undefined;
|
|
8572
8502
|
/**
|
|
8573
8503
|
The number of cached input tokens.
|
|
8574
|
-
|
|
8504
|
+
*/
|
|
8575
8505
|
cachedInputTokens?: number | undefined;
|
|
8576
8506
|
};
|
|
8577
8507
|
type LanguageModelV2StreamPart = {
|
|
@@ -8638,65 +8568,70 @@ Specification for a language model that implements the language model interface
|
|
|
8638
8568
|
type LanguageModelV2 = {
|
|
8639
8569
|
/**
|
|
8640
8570
|
The language model must specify which language model interface version it implements.
|
|
8641
|
-
|
|
8571
|
+
*/
|
|
8642
8572
|
readonly specificationVersion: 'v2';
|
|
8643
8573
|
/**
|
|
8644
8574
|
Name of the provider for logging purposes.
|
|
8645
|
-
|
|
8575
|
+
*/
|
|
8646
8576
|
readonly provider: string;
|
|
8647
8577
|
/**
|
|
8648
8578
|
Provider-specific model ID for logging purposes.
|
|
8649
|
-
|
|
8579
|
+
*/
|
|
8650
8580
|
readonly modelId: string;
|
|
8651
8581
|
/**
|
|
8652
8582
|
Supported URL patterns by media type for the provider.
|
|
8653
|
-
|
|
8583
|
+
|
|
8584
|
+
The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
|
|
8654
8585
|
and the values are arrays of regular expressions that match the URL paths.
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8586
|
+
|
|
8587
|
+
The matching should be against lower-case URLs.
|
|
8588
|
+
|
|
8589
|
+
Matched URLs are supported natively by the model and are not downloaded.
|
|
8590
|
+
|
|
8591
|
+
@returns A map of supported URL patterns by media type (as a promise or a plain object).
|
|
8592
|
+
*/
|
|
8659
8593
|
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
8660
8594
|
/**
|
|
8661
8595
|
Generates a language model output (non-streaming).
|
|
8662
|
-
|
|
8596
|
+
|
|
8597
|
+
Naming: "do" prefix to prevent accidental direct usage of the method
|
|
8663
8598
|
by the user.
|
|
8664
|
-
|
|
8599
|
+
*/
|
|
8665
8600
|
doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{
|
|
8666
8601
|
/**
|
|
8667
8602
|
Ordered content that the model has generated.
|
|
8668
|
-
|
|
8603
|
+
*/
|
|
8669
8604
|
content: Array<LanguageModelV2Content>;
|
|
8670
8605
|
/**
|
|
8671
8606
|
Finish reason.
|
|
8672
|
-
|
|
8607
|
+
*/
|
|
8673
8608
|
finishReason: LanguageModelV2FinishReason;
|
|
8674
8609
|
/**
|
|
8675
|
-
|
|
8676
|
-
|
|
8610
|
+
Usage information.
|
|
8611
|
+
*/
|
|
8677
8612
|
usage: LanguageModelV2Usage;
|
|
8678
8613
|
/**
|
|
8679
8614
|
Additional provider-specific metadata. They are passed through
|
|
8680
8615
|
from the provider to the AI SDK and enable provider-specific
|
|
8681
8616
|
results that can be fully encapsulated in the provider.
|
|
8682
|
-
|
|
8617
|
+
*/
|
|
8683
8618
|
providerMetadata?: SharedV2ProviderMetadata;
|
|
8684
8619
|
/**
|
|
8685
8620
|
Optional request information for telemetry and debugging purposes.
|
|
8686
|
-
|
|
8621
|
+
*/
|
|
8687
8622
|
request?: {
|
|
8688
8623
|
/**
|
|
8689
8624
|
Request HTTP body that was sent to the provider API.
|
|
8690
|
-
|
|
8625
|
+
*/
|
|
8691
8626
|
body?: unknown;
|
|
8692
8627
|
};
|
|
8693
8628
|
/**
|
|
8694
8629
|
Optional response information for telemetry and debugging purposes.
|
|
8695
|
-
|
|
8630
|
+
*/
|
|
8696
8631
|
response?: LanguageModelV2ResponseMetadata & {
|
|
8697
8632
|
/**
|
|
8698
8633
|
Response headers.
|
|
8699
|
-
|
|
8634
|
+
*/
|
|
8700
8635
|
headers?: SharedV2Headers;
|
|
8701
8636
|
/**
|
|
8702
8637
|
Response HTTP body.
|
|
@@ -8705,45 +8640,41 @@ type LanguageModelV2 = {
|
|
|
8705
8640
|
};
|
|
8706
8641
|
/**
|
|
8707
8642
|
Warnings for the call, e.g. unsupported settings.
|
|
8708
|
-
|
|
8643
|
+
*/
|
|
8709
8644
|
warnings: Array<LanguageModelV2CallWarning>;
|
|
8710
8645
|
}>;
|
|
8711
8646
|
/**
|
|
8712
8647
|
Generates a language model output (streaming).
|
|
8713
|
-
|
|
8648
|
+
|
|
8649
|
+
Naming: "do" prefix to prevent accidental direct usage of the method
|
|
8714
8650
|
by the user.
|
|
8715
|
-
|
|
8651
|
+
*
|
|
8716
8652
|
@return A stream of higher-level language model output parts.
|
|
8717
|
-
|
|
8653
|
+
*/
|
|
8718
8654
|
doStream(options: LanguageModelV2CallOptions): PromiseLike<{
|
|
8719
8655
|
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
8720
8656
|
/**
|
|
8721
8657
|
Optional request information for telemetry and debugging purposes.
|
|
8722
|
-
|
|
8658
|
+
*/
|
|
8723
8659
|
request?: {
|
|
8724
8660
|
/**
|
|
8725
8661
|
Request HTTP body that was sent to the provider API.
|
|
8726
|
-
|
|
8662
|
+
*/
|
|
8727
8663
|
body?: unknown;
|
|
8728
8664
|
};
|
|
8729
8665
|
/**
|
|
8730
8666
|
Optional response data.
|
|
8731
|
-
|
|
8667
|
+
*/
|
|
8732
8668
|
response?: {
|
|
8733
8669
|
/**
|
|
8734
8670
|
Response headers.
|
|
8735
|
-
|
|
8671
|
+
*/
|
|
8736
8672
|
headers?: SharedV2Headers;
|
|
8737
8673
|
};
|
|
8738
8674
|
}>;
|
|
8739
8675
|
};
|
|
8740
|
-
/**
|
|
8741
|
-
* Experimental middleware for LanguageModelV2.
|
|
8742
|
-
* This type defines the structure for middleware that can be used to modify
|
|
8743
|
-
* the behavior of LanguageModelV2 operations.
|
|
8744
|
-
*/
|
|
8745
8676
|
//#endregion
|
|
8746
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+provider@3.0.
|
|
8677
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+provider@3.0.16/node_modules/@ai-sdk/provider/dist/index.d.ts
|
|
8747
8678
|
type SharedV3Headers = Record<string, string>;
|
|
8748
8679
|
/**
|
|
8749
8680
|
* A JSON value can be a string, number, boolean, object, array, or null.
|
|
@@ -9811,7 +9742,7 @@ type LanguageModelV3 = {
|
|
|
9811
9742
|
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
9812
9743
|
/**
|
|
9813
9744
|
* Generates a language model output (non-streaming).
|
|
9814
|
-
|
|
9745
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
9815
9746
|
* by the user.
|
|
9816
9747
|
*/
|
|
9817
9748
|
doGenerate(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3GenerateResult>;
|
|
@@ -9825,11 +9756,6 @@ type LanguageModelV3 = {
|
|
|
9825
9756
|
*/
|
|
9826
9757
|
doStream(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3StreamResult>;
|
|
9827
9758
|
};
|
|
9828
|
-
/**
|
|
9829
|
-
* Experimental middleware for LanguageModelV3.
|
|
9830
|
-
* This type defines the structure for middleware that can be used to modify
|
|
9831
|
-
* the behavior of LanguageModelV3 operations.
|
|
9832
|
-
*/
|
|
9833
9759
|
//#endregion
|
|
9834
9760
|
//#region src/opentelemetry-lib/tracing/processor.d.ts
|
|
9835
9761
|
interface LaminarSpanProcessorOptions {
|
|
@@ -9897,7 +9823,7 @@ interface LaminarSpanProcessorOptions {
|
|
|
9897
9823
|
*/
|
|
9898
9824
|
httpPort?: number;
|
|
9899
9825
|
}
|
|
9900
|
-
declare class LaminarSpanProcessor implements SpanProcessor {
|
|
9826
|
+
export declare class LaminarSpanProcessor implements SpanProcessor {
|
|
9901
9827
|
private instance;
|
|
9902
9828
|
private logger;
|
|
9903
9829
|
private readonly _spanIdToPath;
|
|
@@ -9948,7 +9874,7 @@ declare class LaminarSpanProcessor implements SpanProcessor {
|
|
|
9948
9874
|
}
|
|
9949
9875
|
//#endregion
|
|
9950
9876
|
//#region src/opentelemetry-lib/tracing/attributes.d.ts
|
|
9951
|
-
declare const LaminarAttributes: {
|
|
9877
|
+
export declare const LaminarAttributes: {
|
|
9952
9878
|
INPUT_TOKEN_COUNT: string;
|
|
9953
9879
|
OUTPUT_TOKEN_COUNT: string;
|
|
9954
9880
|
TOTAL_TOKEN_COUNT: string;
|
|
@@ -10041,7 +9967,7 @@ interface LaminarInitializeProps {
|
|
|
10041
9967
|
spanProcessor?: SpanProcessor;
|
|
10042
9968
|
}
|
|
10043
9969
|
type LaminarAttributesProp = Record<(typeof LaminarAttributes)[keyof typeof LaminarAttributes], AttributeValue>;
|
|
10044
|
-
declare class Laminar {
|
|
9970
|
+
export declare class Laminar {
|
|
10045
9971
|
private static baseHttpUrl;
|
|
10046
9972
|
private static projectApiKey;
|
|
10047
9973
|
private static isInitialized;
|
|
@@ -10128,25 +10054,7 @@ declare class Laminar {
|
|
|
10128
10054
|
*
|
|
10129
10055
|
* @throws {Error} - If project API key is not set
|
|
10130
10056
|
*/
|
|
10131
|
-
static initialize({
|
|
10132
|
-
projectApiKey,
|
|
10133
|
-
baseUrl,
|
|
10134
|
-
baseHttpUrl,
|
|
10135
|
-
httpPort,
|
|
10136
|
-
grpcPort,
|
|
10137
|
-
instrumentModules,
|
|
10138
|
-
disableBatch,
|
|
10139
|
-
traceExportTimeoutMillis,
|
|
10140
|
-
logLevel,
|
|
10141
|
-
maxExportBatchSize,
|
|
10142
|
-
maxExportBatchSizeBytes,
|
|
10143
|
-
flushBySize,
|
|
10144
|
-
forceHttp,
|
|
10145
|
-
sessionRecordingOptions,
|
|
10146
|
-
metadata,
|
|
10147
|
-
inheritGlobalContext,
|
|
10148
|
-
spanProcessor
|
|
10149
|
-
}?: LaminarInitializeProps): void;
|
|
10057
|
+
static initialize({ projectApiKey, baseUrl, baseHttpUrl, httpPort, grpcPort, instrumentModules, disableBatch, traceExportTimeoutMillis, logLevel, maxExportBatchSize, maxExportBatchSizeBytes, flushBySize, forceHttp, sessionRecordingOptions, metadata, inheritGlobalContext, spanProcessor }?: LaminarInitializeProps): void;
|
|
10150
10058
|
/**
|
|
10151
10059
|
* Initialize Laminar context from the LMNR_SPAN_CONTEXT environment variable.
|
|
10152
10060
|
* This allows continuing traces across process boundaries.
|
|
@@ -10222,13 +10130,7 @@ declare class Laminar {
|
|
|
10222
10130
|
* @param {string} options.userId - The user ID to associate with the event. If not specified,
|
|
10223
10131
|
* the user ID of the current trace is used.
|
|
10224
10132
|
*/
|
|
10225
|
-
static event({
|
|
10226
|
-
name,
|
|
10227
|
-
attributes,
|
|
10228
|
-
timestamp,
|
|
10229
|
-
sessionId,
|
|
10230
|
-
userId
|
|
10231
|
-
}: {
|
|
10133
|
+
static event({ name, attributes, timestamp, sessionId, userId }: {
|
|
10232
10134
|
name: string;
|
|
10233
10135
|
attributes?: Record<string, AttributeValue>;
|
|
10234
10136
|
timestamp?: TimeInput;
|
|
@@ -10312,18 +10214,7 @@ declare class Laminar {
|
|
|
10312
10214
|
* // | | | ...
|
|
10313
10215
|
* // | | openai.chat
|
|
10314
10216
|
*/
|
|
10315
|
-
static startSpan({
|
|
10316
|
-
name,
|
|
10317
|
-
input,
|
|
10318
|
-
spanType,
|
|
10319
|
-
context,
|
|
10320
|
-
parentSpanContext,
|
|
10321
|
-
tags,
|
|
10322
|
-
userId,
|
|
10323
|
-
sessionId,
|
|
10324
|
-
metadata,
|
|
10325
|
-
startTime
|
|
10326
|
-
}: {
|
|
10217
|
+
static startSpan({ name, input, spanType, context, parentSpanContext, tags, userId, sessionId, metadata, startTime }: {
|
|
10327
10218
|
name: string;
|
|
10328
10219
|
input?: any;
|
|
10329
10220
|
spanType?: SpanType;
|
|
@@ -10393,19 +10284,7 @@ declare class Laminar {
|
|
|
10393
10284
|
* // | | bar
|
|
10394
10285
|
* // | | | openai.chat
|
|
10395
10286
|
*/
|
|
10396
|
-
static startActiveSpan({
|
|
10397
|
-
name,
|
|
10398
|
-
input,
|
|
10399
|
-
spanType,
|
|
10400
|
-
context,
|
|
10401
|
-
parentSpanContext,
|
|
10402
|
-
tags,
|
|
10403
|
-
userId,
|
|
10404
|
-
sessionId,
|
|
10405
|
-
metadata,
|
|
10406
|
-
startTime,
|
|
10407
|
-
global
|
|
10408
|
-
}: {
|
|
10287
|
+
static startActiveSpan({ name, input, spanType, context, parentSpanContext, tags, userId, sessionId, metadata, startTime, global }: {
|
|
10409
10288
|
name: string;
|
|
10410
10289
|
input?: any;
|
|
10411
10290
|
spanType?: SpanType;
|
|
@@ -10584,7 +10463,116 @@ declare namespace StandardJSONSchemaV1 {
|
|
|
10584
10463
|
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
10585
10464
|
}
|
|
10586
10465
|
//#endregion
|
|
10587
|
-
//#region ../../node_modules/.pnpm/@
|
|
10466
|
+
//#region ../../node_modules/.pnpm/@workflow+serde@4.1.0/node_modules/@workflow/serde/dist/index.d.ts
|
|
10467
|
+
/**
|
|
10468
|
+
* Symbol used to define custom serialization for user-defined class instances.
|
|
10469
|
+
* The static method should accept an instance and return serializable data.
|
|
10470
|
+
*
|
|
10471
|
+
* @example
|
|
10472
|
+
* ```ts
|
|
10473
|
+
* import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
10474
|
+
*
|
|
10475
|
+
* class MyClass {
|
|
10476
|
+
* constructor(public value: string) {}
|
|
10477
|
+
*
|
|
10478
|
+
* static [WORKFLOW_SERIALIZE](instance: MyClass) {
|
|
10479
|
+
* return { value: instance.value };
|
|
10480
|
+
* }
|
|
10481
|
+
*
|
|
10482
|
+
* static [WORKFLOW_DESERIALIZE](data: { value: string }) {
|
|
10483
|
+
* return new MyClass(data.value);
|
|
10484
|
+
* }
|
|
10485
|
+
* }
|
|
10486
|
+
* ```
|
|
10487
|
+
*/
|
|
10488
|
+
declare const WORKFLOW_SERIALIZE: unique symbol;
|
|
10489
|
+
/**
|
|
10490
|
+
* Symbol used to define custom deserialization for user-defined class instances.
|
|
10491
|
+
* The static method should accept serialized data and return a class instance.
|
|
10492
|
+
*
|
|
10493
|
+
* @see WORKFLOW_SERIALIZE for usage example
|
|
10494
|
+
*/
|
|
10495
|
+
declare const WORKFLOW_DESERIALIZE: unique symbol;
|
|
10496
|
+
//#endregion
|
|
10497
|
+
//#region ../../node_modules/.pnpm/eventsource-parser@3.0.8/node_modules/eventsource-parser/dist/stream.d.ts
|
|
10498
|
+
/**
|
|
10499
|
+
* A parsed EventSource message event
|
|
10500
|
+
*
|
|
10501
|
+
* @public
|
|
10502
|
+
*/
|
|
10503
|
+
declare interface EventSourceMessage {
|
|
10504
|
+
/**
|
|
10505
|
+
* The event type sent from the server. Note that this differs from the browser `EventSource`
|
|
10506
|
+
* implementation in that browsers will default this to `message`, whereas this parser will
|
|
10507
|
+
* leave this as `undefined` if not explicitly declared.
|
|
10508
|
+
*/
|
|
10509
|
+
event?: string | undefined;
|
|
10510
|
+
/**
|
|
10511
|
+
* ID of the message, if any was provided by the server. Can be used by clients to keep the
|
|
10512
|
+
* last received message ID in sync when reconnecting.
|
|
10513
|
+
*/
|
|
10514
|
+
id?: string | undefined;
|
|
10515
|
+
/**
|
|
10516
|
+
* The data received for this message
|
|
10517
|
+
*/
|
|
10518
|
+
data: string;
|
|
10519
|
+
}
|
|
10520
|
+
/**
|
|
10521
|
+
* A TransformStream that ingests a stream of strings and produces a stream of `EventSourceMessage`.
|
|
10522
|
+
*
|
|
10523
|
+
* @example Basic usage
|
|
10524
|
+
* ```
|
|
10525
|
+
* const eventStream =
|
|
10526
|
+
* response.body
|
|
10527
|
+
* .pipeThrough(new TextDecoderStream())
|
|
10528
|
+
* .pipeThrough(new EventSourceParserStream())
|
|
10529
|
+
* ```
|
|
10530
|
+
*
|
|
10531
|
+
* @example Terminate stream on parsing errors
|
|
10532
|
+
* ```
|
|
10533
|
+
* const eventStream =
|
|
10534
|
+
* response.body
|
|
10535
|
+
* .pipeThrough(new TextDecoderStream())
|
|
10536
|
+
* .pipeThrough(new EventSourceParserStream({terminateOnError: true}))
|
|
10537
|
+
* ```
|
|
10538
|
+
*
|
|
10539
|
+
* @public
|
|
10540
|
+
*/
|
|
10541
|
+
declare class EventSourceParserStream extends TransformStream<string, EventSourceMessage> {
|
|
10542
|
+
constructor({ onError, onRetry, onComment }?: StreamOptions);
|
|
10543
|
+
}
|
|
10544
|
+
/**
|
|
10545
|
+
* Options for the EventSourceParserStream.
|
|
10546
|
+
*
|
|
10547
|
+
* @public
|
|
10548
|
+
*/
|
|
10549
|
+
declare interface StreamOptions {
|
|
10550
|
+
/**
|
|
10551
|
+
* Behavior when a parsing error occurs.
|
|
10552
|
+
*
|
|
10553
|
+
* - A custom function can be provided to handle the error.
|
|
10554
|
+
* - `'terminate'` will error the stream and stop parsing.
|
|
10555
|
+
* - Any other value will ignore the error and continue parsing.
|
|
10556
|
+
*
|
|
10557
|
+
* @defaultValue `undefined`
|
|
10558
|
+
*/
|
|
10559
|
+
onError?: ("terminate" | ((error: Error) => void)) | undefined;
|
|
10560
|
+
/**
|
|
10561
|
+
* Callback for when a reconnection interval is sent from the server.
|
|
10562
|
+
*
|
|
10563
|
+
* @param retry - The number of milliseconds to wait before reconnecting.
|
|
10564
|
+
*/
|
|
10565
|
+
onRetry?: ((retry: number) => void) | undefined;
|
|
10566
|
+
/**
|
|
10567
|
+
* Callback for when a comment is encountered in the stream.
|
|
10568
|
+
*
|
|
10569
|
+
* @param comment - The comment encountered in the stream.
|
|
10570
|
+
*/
|
|
10571
|
+
onComment?: ((comment: string) => void) | undefined;
|
|
10572
|
+
}
|
|
10573
|
+
declare namespace index_d_exports$1 {
|
|
10574
|
+
export { Arrayable, AssistantContent, AssistantModelMessage, Context$1 as Context, CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, DataContent, DelayedPromise, DownloadError, DynamicTool, TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE as EXPERIMENTAL_TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE, TRANSCRIPTION_STREAM_START_FRAME_TYPE as EXPERIMENTAL_TRANSCRIPTION_STREAM_START_FRAME_TYPE, EventSourceMessage, EventSourceParserStream, ExecutableTool, SandboxProcess as Experimental_SandboxProcess, SandboxSession as Experimental_SandboxSession, ToolCallerDefinition as Experimental_ToolCallerDefinition, ToolCallerTool as Experimental_ToolCallerTool, TranscriptionStreamClientFrame as Experimental_TranscriptionStreamClientFrame, TranscriptionStreamStartFrame as Experimental_TranscriptionStreamStartFrame, FetchFunction, FileData, FileDataData, FileDataReference, FileDataText, FileDataUrl, FilePart, FlexibleSchema, FunctionTool, HasRequiredKey, IdGenerator, ImagePart, InferSchema, InferToolContext, InferToolInput, InferToolOutput, InferToolSetContext, LazySchema, MaybePromiseLike, ModelMessage, ParseResult, ProviderDefinedTool, ProviderDefinedToolFactory, ProviderDefinedToolFactoryWithOutputSchema, ProviderExecutedTool, ProviderExecutedToolFactory, ProviderOptions, ProviderReference$1 as ProviderReference, ReasoningFilePart, ReasoningPart, Resolvable, ResponseHandler, RetryDelayProvider, RetryErrorFactory, RetryErrorReason$1 as RetryErrorReason, RetryFunction, Schema, SerializationError, ShouldRetryFunction, StandardJSONSchemaV1, StandardSchemaV1, StandardTypedV1, StreamingToolCallDelta, StreamingToolCallTracker, StreamingToolCallTrackerOptions, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCall, ToolCallPart, ToolContent, ToolExecuteFunction, ToolExecutionOptions, ToolModelMessage, ToolNameMapping, ToolNeedsApprovalFunction, ToolResult, ToolResultOutput, ToolResultPart, ToolSet, UserContent, UserModelMessage, VERSION, ValidationResult, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, WebSocketConnection, WebSocketConstructor, WebSocketLike, asArray, asSchema, cancelResponseBody, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createStatusCodeErrorResponseHandler, createToolNameMapping, delay$1 as delay, detectMediaType, downloadBlob, dynamicTool, executeTool, getToolCaller as experimental_getToolCaller, parseTranscriptionStreamClientFrame as experimental_parseTranscriptionStreamClientFrame, parseTranscriptionStreamPart as experimental_parseTranscriptionStreamPart, serializeTranscriptionStreamPart as experimental_serializeTranscriptionStreamPart, toolCaller as experimental_toolCaller, extractLines, extractResponseHeaders, fetchWithValidatedRedirects, filterNullable, generateId$1 as generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, getWebSocketConstructor, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isBuffer, isCustomReasoning, isExecutableTool, isFullMediaType, isNonNullable, isParsableJson, isProviderReference, isRecord, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, readWebSocketMessageText, removeUndefinedEntries, resolve, resolveFullMediaType, resolveProviderReference, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, stripFileExtension, toWebSocketUrl, tool$1 as tool, validateBaseURL, validateDownloadUrl, validateTypes, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
10575
|
+
}
|
|
10588
10576
|
/**
|
|
10589
10577
|
* A value that can be provided either as a single item, an array of items,
|
|
10590
10578
|
* or be left undefined.
|
|
@@ -10593,8 +10581,11 @@ type Arrayable<T> = T | T[] | undefined;
|
|
|
10593
10581
|
/**
|
|
10594
10582
|
* Normalizes a possibly undefined or non-array value into an array.
|
|
10595
10583
|
*/
|
|
10584
|
+
declare function asArray<T>(value: Arrayable<T>): T[];
|
|
10585
|
+
declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
|
|
10596
10586
|
type WebSocketLike = {
|
|
10597
|
-
readyState: number;
|
|
10587
|
+
readyState: number;
|
|
10588
|
+
/** Bytes queued by `send` but not yet transmitted (native + `ws`). */
|
|
10598
10589
|
readonly bufferedAmount?: number;
|
|
10599
10590
|
send(data: string | Uint8Array | ArrayBuffer): void;
|
|
10600
10591
|
close(code?: number, reason?: string): void;
|
|
@@ -10608,6 +10599,74 @@ type WebSocketLike = {
|
|
|
10608
10599
|
type WebSocketConstructor = new (url: string | URL, protocols?: string | string[], options?: {
|
|
10609
10600
|
headers?: Record<string, string | undefined>;
|
|
10610
10601
|
}) => WebSocketLike;
|
|
10602
|
+
declare function getWebSocketConstructor(webSocket: WebSocketConstructor | undefined): WebSocketConstructor;
|
|
10603
|
+
/**
|
|
10604
|
+
* Converts an http(s) URL to the corresponding ws(s) URL.
|
|
10605
|
+
*/
|
|
10606
|
+
declare function toWebSocketUrl(url: string | URL): URL;
|
|
10607
|
+
/**
|
|
10608
|
+
* Reads WebSocket message data as text, handling string, binary,
|
|
10609
|
+
* and Blob payloads.
|
|
10610
|
+
*/
|
|
10611
|
+
declare function readWebSocketMessageText(data: unknown): Promise<string>;
|
|
10612
|
+
/**
|
|
10613
|
+
* Waits until the socket's send buffer drains below `highWaterMark` bytes.
|
|
10614
|
+
* No-op for implementations that do not expose `bufferedAmount`. There is no
|
|
10615
|
+
* portable drain event, so this polls. Returns as soon as the socket is no
|
|
10616
|
+
* longer open or the signal aborts — `bufferedAmount` never drains on a
|
|
10617
|
+
* closed socket, so waiting on would poll forever.
|
|
10618
|
+
*/
|
|
10619
|
+
declare function waitForWebSocketBufferDrain(socket: WebSocketLike, { highWaterMark, pollIntervalMs, abortSignal }?: {
|
|
10620
|
+
highWaterMark?: number;
|
|
10621
|
+
pollIntervalMs?: number;
|
|
10622
|
+
abortSignal?: AbortSignal;
|
|
10623
|
+
}): Promise<void>;
|
|
10624
|
+
interface WebSocketConnection {
|
|
10625
|
+
/** Undefined when the constructor threw or the signal was already aborted. */
|
|
10626
|
+
socket: WebSocketLike | undefined;
|
|
10627
|
+
/**
|
|
10628
|
+
* Unregisters the abort listener and closes the socket. Never throws.
|
|
10629
|
+
* Handlers stay attached; callers guard their own terminal state.
|
|
10630
|
+
*/
|
|
10631
|
+
close: (code?: number) => void;
|
|
10632
|
+
}
|
|
10633
|
+
/**
|
|
10634
|
+
* Opens a WebSocket for a provider model, owning the transport-generic layer
|
|
10635
|
+
* (analogous to `postToApi` for HTTP): constructor resolution, header hygiene,
|
|
10636
|
+
* abort wiring, and message decoding. Callers own the URL, the auth channel
|
|
10637
|
+
* (subprotocols vs headers), and the wire protocol.
|
|
10638
|
+
*/
|
|
10639
|
+
declare function connectToWebSocket({ url, protocols, headers, webSocket, abortSignal, onOpen, onMessageText, onProcessingError, onSocketError, onClose, onAbort }: {
|
|
10640
|
+
url: string | URL;
|
|
10641
|
+
protocols?: string | string[];
|
|
10642
|
+
headers?: Record<string, string | undefined>;
|
|
10643
|
+
webSocket?: WebSocketConstructor;
|
|
10644
|
+
abortSignal?: AbortSignal;
|
|
10645
|
+
onOpen?: (socket: WebSocketLike) => void;
|
|
10646
|
+
/** One decoded message. Throws and rejections go to `onProcessingError`. */
|
|
10647
|
+
onMessageText: (text: string) => void | PromiseLike<void>;
|
|
10648
|
+
/** Constructor throws and message decoding/processing failures. */
|
|
10649
|
+
onProcessingError: (error: unknown) => void;
|
|
10650
|
+
onSocketError?: () => void;
|
|
10651
|
+
/**
|
|
10652
|
+
* Receives the close code and reason when the transport provides them
|
|
10653
|
+
* (native `CloseEvent` / `ws` close event).
|
|
10654
|
+
*/
|
|
10655
|
+
onClose?: (info: {
|
|
10656
|
+
code?: number;
|
|
10657
|
+
reason?: string;
|
|
10658
|
+
}) => void;
|
|
10659
|
+
/** Also called (without opening a socket) when the signal is already aborted. */
|
|
10660
|
+
onAbort?: (reason: unknown) => void;
|
|
10661
|
+
}): WebSocketConnection;
|
|
10662
|
+
/**
|
|
10663
|
+
* Converts an AsyncIterator to a ReadableStream.
|
|
10664
|
+
*
|
|
10665
|
+
* @template T - The type of elements produced by the AsyncIterator.
|
|
10666
|
+
* @param { <T>} iterator - The AsyncIterator to convert.
|
|
10667
|
+
* @returns {ReadableStream<T>} - A ReadableStream that provides the same data as the AsyncIterator.
|
|
10668
|
+
*/
|
|
10669
|
+
declare function convertAsyncIteratorToReadableStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
10611
10670
|
/**
|
|
10612
10671
|
* Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
|
|
10613
10672
|
*/
|
|
@@ -11117,58 +11176,237 @@ type ToolResultOutput = {
|
|
|
11117
11176
|
providerOptions?: ProviderOptions;
|
|
11118
11177
|
}>;
|
|
11119
11178
|
};
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
readonly statusText?: string;
|
|
11126
|
-
constructor({
|
|
11127
|
-
url,
|
|
11128
|
-
statusCode,
|
|
11129
|
-
statusText,
|
|
11130
|
-
cause,
|
|
11131
|
-
message
|
|
11132
|
-
}: {
|
|
11133
|
-
url: string;
|
|
11134
|
-
statusCode?: number;
|
|
11135
|
-
statusText?: string;
|
|
11136
|
-
message?: string;
|
|
11137
|
-
cause?: unknown;
|
|
11138
|
-
});
|
|
11139
|
-
static isInstance(error: unknown): error is DownloadError;
|
|
11140
|
-
}
|
|
11179
|
+
type InlineFileData = Extract<FilePart['data'], {
|
|
11180
|
+
type: 'data';
|
|
11181
|
+
} | {
|
|
11182
|
+
type: 'text';
|
|
11183
|
+
}>;
|
|
11141
11184
|
/**
|
|
11142
|
-
*
|
|
11185
|
+
* Converts inline file data (a tagged `data` or `text` shape) into raw bytes.
|
|
11186
|
+
*
|
|
11187
|
+
* - `{ type: 'text', text }` → UTF-8 encoded bytes
|
|
11188
|
+
* - `{ type: 'data', data: Uint8Array | Buffer }` → returned as-is
|
|
11189
|
+
* - `{ type: 'data', data: ArrayBuffer }` → wrapped in a `Uint8Array`
|
|
11190
|
+
* - `{ type: 'data', data: string }` → decoded as base64
|
|
11143
11191
|
*/
|
|
11144
|
-
|
|
11192
|
+
declare function convertInlineFileDataToUint8Array(data: InlineFileData): Uint8Array;
|
|
11145
11193
|
/**
|
|
11146
|
-
*
|
|
11194
|
+
* Convert an ImageModelV4File to a URL or data URI string.
|
|
11147
11195
|
*
|
|
11148
|
-
*
|
|
11149
|
-
*
|
|
11150
|
-
*
|
|
11151
|
-
|
|
11152
|
-
|
|
11196
|
+
* If the file is a URL, it returns the URL as-is.
|
|
11197
|
+
* If the file is base64 data, it returns a data URI with the base64 data.
|
|
11198
|
+
* If the file is a Uint8Array, it converts it to base64 and returns a data URI.
|
|
11199
|
+
*/
|
|
11200
|
+
declare function convertImageModelFileToDataUri(file: ImageModelV4File): string;
|
|
11201
|
+
/**
|
|
11202
|
+
* Converts an input object to FormData for multipart/form-data requests.
|
|
11153
11203
|
*
|
|
11154
|
-
*
|
|
11155
|
-
*
|
|
11156
|
-
*
|
|
11157
|
-
*
|
|
11158
|
-
*
|
|
11159
|
-
*
|
|
11160
|
-
* must be dropped here as well.
|
|
11204
|
+
* Handles the following cases:
|
|
11205
|
+
* - `null` or `undefined` values are skipped
|
|
11206
|
+
* - Arrays with a single element are appended as a single value
|
|
11207
|
+
* - Arrays with multiple elements are appended with `[]` suffix (e.g., `image[]`)
|
|
11208
|
+
* unless `useArrayBrackets` is set to `false`
|
|
11209
|
+
* - All other values are appended directly
|
|
11161
11210
|
*
|
|
11162
|
-
*
|
|
11163
|
-
*
|
|
11164
|
-
*
|
|
11165
|
-
*
|
|
11166
|
-
*
|
|
11167
|
-
* cloud-metadata). On any other runtime we cannot validate the hop, so we fail
|
|
11168
|
-
* closed rather than follow it blindly and bypass the guard.
|
|
11211
|
+
* @param input - The input object to convert. Use a generic type for type validation.
|
|
11212
|
+
* @param options - Optional configuration object.
|
|
11213
|
+
* @param options.useArrayBrackets - Whether to add `[]` suffix for multi-element arrays.
|
|
11214
|
+
* Defaults to `true`. Set to `false` for APIs that expect repeated keys without brackets.
|
|
11215
|
+
* @returns A FormData object containing the input values.
|
|
11169
11216
|
*
|
|
11170
|
-
*
|
|
11171
|
-
*
|
|
11217
|
+
* @example
|
|
11218
|
+
* ```ts
|
|
11219
|
+
* type MyInput = {
|
|
11220
|
+
* model: string;
|
|
11221
|
+
* prompt: string;
|
|
11222
|
+
* images: Blob[];
|
|
11223
|
+
* };
|
|
11224
|
+
*
|
|
11225
|
+
* const formData = convertToFormData<MyInput>({
|
|
11226
|
+
* model: 'gpt-image-1',
|
|
11227
|
+
* prompt: 'A cat',
|
|
11228
|
+
* images: [blob1, blob2],
|
|
11229
|
+
* });
|
|
11230
|
+
* ```
|
|
11231
|
+
*/
|
|
11232
|
+
declare function convertToFormData<T extends Record<string, unknown>>(input: T, options?: {
|
|
11233
|
+
useArrayBrackets?: boolean;
|
|
11234
|
+
}): FormData;
|
|
11235
|
+
/**
|
|
11236
|
+
* Converts common provider response fields into language model response
|
|
11237
|
+
* metadata.
|
|
11238
|
+
*/
|
|
11239
|
+
declare function createLanguageModelResponseMetadata({ id, model, created }: {
|
|
11240
|
+
id?: string | null;
|
|
11241
|
+
model?: string | null;
|
|
11242
|
+
created?: number | null;
|
|
11243
|
+
}): LanguageModelV4ResponseMetadata;
|
|
11244
|
+
/**
|
|
11245
|
+
* Creates an empty language model usage result for unavailable usage data.
|
|
11246
|
+
*/
|
|
11247
|
+
declare function createNullLanguageModelUsage(): LanguageModelV4Usage;
|
|
11248
|
+
/**
|
|
11249
|
+
* Interface for mapping between custom tool names and provider tool names.
|
|
11250
|
+
*/
|
|
11251
|
+
interface ToolNameMapping {
|
|
11252
|
+
/**
|
|
11253
|
+
* Maps a custom tool name (used by the client) to the provider's tool name.
|
|
11254
|
+
* If the custom tool name does not have a mapping, returns the input name.
|
|
11255
|
+
*
|
|
11256
|
+
* @param customToolName - The custom name of the tool defined by the client.
|
|
11257
|
+
* @returns The corresponding provider tool name, or the input name if not mapped.
|
|
11258
|
+
*/
|
|
11259
|
+
toProviderToolName: (customToolName: string) => string;
|
|
11260
|
+
/**
|
|
11261
|
+
* Maps a provider tool name to the custom tool name used by the client.
|
|
11262
|
+
* If the provider tool name does not have a mapping, returns the input name.
|
|
11263
|
+
*
|
|
11264
|
+
* @param providerToolName - The name of the tool as understood by the provider.
|
|
11265
|
+
* @returns The corresponding custom tool name, or the input name if not mapped.
|
|
11266
|
+
*/
|
|
11267
|
+
toCustomToolName: (providerToolName: string) => string;
|
|
11268
|
+
}
|
|
11269
|
+
/**
|
|
11270
|
+
* @param tools - Tools that were passed to the language model.
|
|
11271
|
+
* @param providerToolNames - Maps the provider tool ids to the provider tool names.
|
|
11272
|
+
*/
|
|
11273
|
+
declare function createToolNameMapping({ tools, providerToolNames }: {
|
|
11274
|
+
/**
|
|
11275
|
+
* Tools that were passed to the language model.
|
|
11276
|
+
*/
|
|
11277
|
+
tools: Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool> | undefined;
|
|
11278
|
+
/**
|
|
11279
|
+
* Maps the provider tool ids to the provider tool names.
|
|
11280
|
+
*/
|
|
11281
|
+
providerToolNames: Record<`${string}.${string}`, string>;
|
|
11282
|
+
}): ToolNameMapping;
|
|
11283
|
+
/**
|
|
11284
|
+
* Creates a Promise that resolves after a specified delay
|
|
11285
|
+
* @param delayInMs - The delay duration in milliseconds. If null or undefined, resolves immediately.
|
|
11286
|
+
* @param signal - Optional AbortSignal to cancel the delay
|
|
11287
|
+
* @returns A Promise that resolves after the specified delay
|
|
11288
|
+
* @throws {DOMException} When the signal is aborted
|
|
11289
|
+
*/
|
|
11290
|
+
declare function delay$1(delayInMs?: number | null, options?: {
|
|
11291
|
+
abortSignal?: AbortSignal;
|
|
11292
|
+
}): Promise<void>;
|
|
11293
|
+
/**
|
|
11294
|
+
* Delayed promise. It is only constructed once the value is accessed.
|
|
11295
|
+
* This is useful to avoid unhandled promise rejections when the promise is created
|
|
11296
|
+
* but not accessed.
|
|
11297
|
+
*/
|
|
11298
|
+
declare class DelayedPromise<T> {
|
|
11299
|
+
private status;
|
|
11300
|
+
private _promise;
|
|
11301
|
+
private _resolve;
|
|
11302
|
+
private _reject;
|
|
11303
|
+
get promise(): Promise<T>;
|
|
11304
|
+
resolve(value: T): void;
|
|
11305
|
+
reject(error: unknown): void;
|
|
11306
|
+
isResolved(): boolean;
|
|
11307
|
+
isRejected(): boolean;
|
|
11308
|
+
isPending(): boolean;
|
|
11309
|
+
}
|
|
11310
|
+
/**
|
|
11311
|
+
* Detect the IANA media type of a file from its raw bytes or base64 string.
|
|
11312
|
+
*
|
|
11313
|
+
* - When `topLevelType` is omitted, every known signature is considered
|
|
11314
|
+
* (image, audio, video, and application). Returns `undefined` when the
|
|
11315
|
+
* bytes do not match any known signature.
|
|
11316
|
+
* - When `topLevelType` is provided, only signatures for that top-level
|
|
11317
|
+
* segment are considered. Returns `undefined` for unsupported segments
|
|
11318
|
+
* (e.g. `"text"`) or when no signature matches.
|
|
11319
|
+
*/
|
|
11320
|
+
declare function detectMediaType({ data, topLevelType }: {
|
|
11321
|
+
data: Uint8Array | string;
|
|
11322
|
+
topLevelType?: string;
|
|
11323
|
+
}): string | undefined;
|
|
11324
|
+
/**
|
|
11325
|
+
* Returns the top-level segment of a media type (the portion before `/`).
|
|
11326
|
+
*
|
|
11327
|
+
* Examples:
|
|
11328
|
+
* - `"image/png"` -> `"image"`
|
|
11329
|
+
* - `"image/*"` -> `"image"`
|
|
11330
|
+
* - `"image"` -> `"image"`
|
|
11331
|
+
* - `"image/"` -> `"image"`
|
|
11332
|
+
* - `""` -> `""`
|
|
11333
|
+
* - `"/"` -> `""`
|
|
11334
|
+
*/
|
|
11335
|
+
declare function getTopLevelMediaType(mediaType: string): string;
|
|
11336
|
+
/**
|
|
11337
|
+
* Returns `true` only when the given media type has a non-empty, non-wildcard
|
|
11338
|
+
* subtype (i.e. matches the form `type/subtype`, and `subtype` is not `*`).
|
|
11339
|
+
*
|
|
11340
|
+
* Examples:
|
|
11341
|
+
* - `"image/png"` -> `true`
|
|
11342
|
+
* - `"image/*"` -> `false`
|
|
11343
|
+
* - `"image"` -> `false`
|
|
11344
|
+
* - `"image/"` -> `false`
|
|
11345
|
+
* - `""` -> `false`
|
|
11346
|
+
* - `"/"` -> `false`
|
|
11347
|
+
*/
|
|
11348
|
+
declare function isFullMediaType(mediaType: string): boolean;
|
|
11349
|
+
/**
|
|
11350
|
+
* Download a file from a URL and return it as a Blob.
|
|
11351
|
+
*
|
|
11352
|
+
* @param url - The URL to download from.
|
|
11353
|
+
* @param options - Optional settings for the download.
|
|
11354
|
+
* @param options.maxBytes - Maximum allowed download size in bytes. Defaults to 100 MiB.
|
|
11355
|
+
* @param options.abortSignal - An optional abort signal to cancel the download.
|
|
11356
|
+
* @returns A Promise that resolves to the downloaded Blob.
|
|
11357
|
+
*
|
|
11358
|
+
* @throws DownloadError if the download fails or exceeds maxBytes.
|
|
11359
|
+
*/
|
|
11360
|
+
declare function downloadBlob(url: string, options?: {
|
|
11361
|
+
maxBytes?: number;
|
|
11362
|
+
abortSignal?: AbortSignal;
|
|
11363
|
+
}): Promise<Blob>;
|
|
11364
|
+
declare const symbol$1$1: unique symbol;
|
|
11365
|
+
declare class DownloadError extends AISDKError {
|
|
11366
|
+
private readonly [symbol$1$1];
|
|
11367
|
+
readonly url: string;
|
|
11368
|
+
readonly statusCode?: number;
|
|
11369
|
+
readonly statusText?: string;
|
|
11370
|
+
constructor({ url, statusCode, statusText, cause, message }: {
|
|
11371
|
+
url: string;
|
|
11372
|
+
statusCode?: number;
|
|
11373
|
+
statusText?: string;
|
|
11374
|
+
message?: string;
|
|
11375
|
+
cause?: unknown;
|
|
11376
|
+
});
|
|
11377
|
+
static isInstance(error: unknown): error is DownloadError;
|
|
11378
|
+
}
|
|
11379
|
+
/**
|
|
11380
|
+
* Fetch function type (standardizes the version of fetch used).
|
|
11381
|
+
*/
|
|
11382
|
+
type FetchFunction = typeof globalThis.fetch;
|
|
11383
|
+
/**
|
|
11384
|
+
* Fetches a URL while enforcing the download guard on every hop.
|
|
11385
|
+
*
|
|
11386
|
+
* Redirects are followed manually (`redirect: 'manual'`) so each hop is
|
|
11387
|
+
* validated with {@link validateDownloadUrl} *before* it is requested. Relying
|
|
11388
|
+
* on the default `redirect: 'follow'` would issue the request to a redirect
|
|
11389
|
+
* target (e.g. an internal address) before we ever see its URL, defeating the
|
|
11390
|
+
* guard.
|
|
11391
|
+
*
|
|
11392
|
+
* Request headers are also protected: {@link sanitizeRequestHeaders} strips
|
|
11393
|
+
* proxy/metadata/cookie/hop-by-hop headers before the first request, and all
|
|
11394
|
+
* caller headers except `User-Agent` are dropped on a cross-origin redirect.
|
|
11395
|
+
* The fetch spec only strips `Authorization` on cross-origin redirects because
|
|
11396
|
+
* in a browser, CORS preflighting protects custom headers; there is no CORS on
|
|
11397
|
+
* the server, so provider API keys carried in custom headers (e.g. `x-key`)
|
|
11398
|
+
* must be dropped here as well.
|
|
11399
|
+
*
|
|
11400
|
+
* A `redirect: 'manual'` request yields an unreadable opaque response in the
|
|
11401
|
+
* browser (and in other spec-compliant fetch implementations), so the redirect
|
|
11402
|
+
* target cannot be validated here. In a real browser this is safe to follow
|
|
11403
|
+
* natively because reaching an internal network is not possible (fetch is
|
|
11404
|
+
* constrained by CORS and cannot reach a server's internal network or
|
|
11405
|
+
* cloud-metadata). On any other runtime we cannot validate the hop, so we fail
|
|
11406
|
+
* closed rather than follow it blindly and bypass the guard.
|
|
11407
|
+
*
|
|
11408
|
+
* A hop that is same-origin with `trustedOrigin` (the developer-configured
|
|
11409
|
+
* provider endpoint) skips target validation: that origin is exactly what an
|
|
11172
11410
|
* unvalidated, config-derived request would fetch anyway, and validating it
|
|
11173
11411
|
* would break legitimate self-hosted / localhost deployments whose response
|
|
11174
11412
|
* URLs point back at the configured host. Hops on any other origin are always
|
|
@@ -11186,6 +11424,48 @@ type FetchFunction = typeof globalThis.fetch;
|
|
|
11186
11424
|
* @throws DownloadError if a hop is unsafe, the redirect limit is exceeded, or
|
|
11187
11425
|
* a redirect cannot be validated on a non-browser runtime.
|
|
11188
11426
|
*/
|
|
11427
|
+
declare function fetchWithValidatedRedirects({ url, headers, abortSignal, maxRedirects, fetch: customFetch, trustedOrigin }: {
|
|
11428
|
+
url: string;
|
|
11429
|
+
headers?: HeadersInit;
|
|
11430
|
+
abortSignal?: AbortSignal;
|
|
11431
|
+
maxRedirects?: number;
|
|
11432
|
+
fetch?: FetchFunction;
|
|
11433
|
+
/**
|
|
11434
|
+
* A developer-configured origin (e.g. the provider's `baseURL`) whose hops
|
|
11435
|
+
* skip target validation. Must never be derived from response data.
|
|
11436
|
+
*/
|
|
11437
|
+
trustedOrigin?: string;
|
|
11438
|
+
}): Promise<Response>;
|
|
11439
|
+
/**
|
|
11440
|
+
* Extracts a 1-based inclusive line range from `text`, auto-detecting the
|
|
11441
|
+
* file's line ending (`\r\n`, `\n`, or `\r`, in that priority).
|
|
11442
|
+
*
|
|
11443
|
+
* Mixed line endings are not supported: detection picks one and uses it for
|
|
11444
|
+
* both the split and the rejoin, so files that mix conventions will not slice
|
|
11445
|
+
* cleanly. When neither `startLine` nor `endLine` is provided, the input is
|
|
11446
|
+
* returned unchanged. `endLine` past EOF clamps to the last line.
|
|
11447
|
+
*/
|
|
11448
|
+
declare function extractLines({ text, startLine, endLine }: {
|
|
11449
|
+
text: string;
|
|
11450
|
+
startLine?: number;
|
|
11451
|
+
endLine?: number;
|
|
11452
|
+
}): string;
|
|
11453
|
+
/**
|
|
11454
|
+
* Extracts the headers from a response object and returns them as a key-value object.
|
|
11455
|
+
*
|
|
11456
|
+
* @param response - The response object to extract headers from.
|
|
11457
|
+
* @returns The headers as a key-value object.
|
|
11458
|
+
*/
|
|
11459
|
+
declare function extractResponseHeaders(response: Response): {
|
|
11460
|
+
[k: string]: string;
|
|
11461
|
+
};
|
|
11462
|
+
/**
|
|
11463
|
+
* Filters `null` and `undefined` values out of a list of values.
|
|
11464
|
+
*
|
|
11465
|
+
* @param values - The values to filter.
|
|
11466
|
+
* @returns A new array containing only non-nullish values.
|
|
11467
|
+
*/
|
|
11468
|
+
declare function filterNullable<T>(...values: Array<T | undefined | null>): Array<T>;
|
|
11189
11469
|
/**
|
|
11190
11470
|
* Creates an ID generator.
|
|
11191
11471
|
* The total length of the ID is the sum of the prefix, separator, and random part length.
|
|
@@ -11196,12 +11476,7 @@ type FetchFunction = typeof globalThis.fetch;
|
|
|
11196
11476
|
* @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
|
|
11197
11477
|
* @param size - The size of the random part of the ID to generate. Default: 16.
|
|
11198
11478
|
*/
|
|
11199
|
-
declare const createIdGenerator: ({
|
|
11200
|
-
prefix,
|
|
11201
|
-
size,
|
|
11202
|
-
alphabet,
|
|
11203
|
-
separator
|
|
11204
|
-
}?: {
|
|
11479
|
+
declare const createIdGenerator: ({ prefix, size, alphabet, separator }?: {
|
|
11205
11480
|
prefix?: string;
|
|
11206
11481
|
separator?: string;
|
|
11207
11482
|
size?: number;
|
|
@@ -11254,6 +11529,7 @@ type Schema<OBJECT = unknown> = {
|
|
|
11254
11529
|
* @param createValidator A function that creates a schema.
|
|
11255
11530
|
* @returns A function that returns a schema.
|
|
11256
11531
|
*/
|
|
11532
|
+
declare function lazySchema<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazySchema<SCHEMA>;
|
|
11257
11533
|
type LazySchema<SCHEMA> = () => Schema<SCHEMA>;
|
|
11258
11534
|
type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | $ZodType<SCHEMA, any>;
|
|
11259
11535
|
type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & {
|
|
@@ -11269,9 +11545,7 @@ type InferSchema<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extend
|
|
|
11269
11545
|
* @param jsonSchema The JSON Schema for the schema.
|
|
11270
11546
|
* @param options.validate Optional. A validation function for the schema.
|
|
11271
11547
|
*/
|
|
11272
|
-
declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7$1 | PromiseLike<JSONSchema7$1> | (() => JSONSchema7$1 | PromiseLike<JSONSchema7$1>), {
|
|
11273
|
-
validate
|
|
11274
|
-
}?: {
|
|
11548
|
+
declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7$1 | PromiseLike<JSONSchema7$1> | (() => JSONSchema7$1 | PromiseLike<JSONSchema7$1>), { validate }?: {
|
|
11275
11549
|
validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
|
|
11276
11550
|
}): Schema<OBJECT>;
|
|
11277
11551
|
declare function asSchema<OBJECT>(schema: FlexibleSchema<OBJECT> | undefined): Schema<OBJECT>;
|
|
@@ -11290,6 +11564,22 @@ declare function zodSchema<OBJECT>(zodSchema: $ZodType<OBJECT, any> | z3.Schema<
|
|
|
11290
11564
|
* @param text - The JSON string to parse.
|
|
11291
11565
|
* @returns {JSONValue} - The parsed JSON object.
|
|
11292
11566
|
*/
|
|
11567
|
+
declare function parseJSON(options: {
|
|
11568
|
+
text: string;
|
|
11569
|
+
schema?: undefined;
|
|
11570
|
+
}): Promise<JSONValue$3>;
|
|
11571
|
+
/**
|
|
11572
|
+
* Parses a JSON string into a strongly-typed object using the provided schema.
|
|
11573
|
+
*
|
|
11574
|
+
* @template T - The type of the object to parse the JSON into.
|
|
11575
|
+
* @param {string} text - The JSON string to parse.
|
|
11576
|
+
* @param {Validator<T>} schema - The schema to use for parsing the JSON.
|
|
11577
|
+
* @returns {Promise<T>} - The parsed object.
|
|
11578
|
+
*/
|
|
11579
|
+
declare function parseJSON<T>(options: {
|
|
11580
|
+
text: string;
|
|
11581
|
+
schema: FlexibleSchema<T>;
|
|
11582
|
+
}): Promise<T>;
|
|
11293
11583
|
type ParseResult<T> = {
|
|
11294
11584
|
success: true;
|
|
11295
11585
|
value: T;
|
|
@@ -11305,12 +11595,231 @@ type ParseResult<T> = {
|
|
|
11305
11595
|
* @param text - The JSON string to parse.
|
|
11306
11596
|
* @returns {Promise<object>} Either an object with `success: true` and the parsed data, or an object with `success: false` and the error that occurred.
|
|
11307
11597
|
*/
|
|
11598
|
+
declare function safeParseJSON(options: {
|
|
11599
|
+
text: string;
|
|
11600
|
+
schema?: undefined;
|
|
11601
|
+
}): Promise<ParseResult<JSONValue$3>>;
|
|
11602
|
+
/**
|
|
11603
|
+
* Safely parses a JSON string into a strongly-typed object, using a provided schema to validate the object.
|
|
11604
|
+
*
|
|
11605
|
+
* @template T - The type of the object to parse the JSON into.
|
|
11606
|
+
* @param {string} text - The JSON string to parse.
|
|
11607
|
+
* @param {Validator<T>} schema - The schema to use for parsing the JSON.
|
|
11608
|
+
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
|
11609
|
+
*/
|
|
11610
|
+
declare function safeParseJSON<T>(options: {
|
|
11611
|
+
text: string;
|
|
11612
|
+
schema: FlexibleSchema<T>;
|
|
11613
|
+
}): Promise<ParseResult<T>>;
|
|
11614
|
+
declare function isParsableJson(input: string): boolean;
|
|
11615
|
+
type ResponseHandler<RETURN_TYPE> = (options: {
|
|
11616
|
+
url: string;
|
|
11617
|
+
requestBodyValues: unknown;
|
|
11618
|
+
response: Response;
|
|
11619
|
+
}) => PromiseLike<{
|
|
11620
|
+
value: RETURN_TYPE;
|
|
11621
|
+
rawValue?: unknown;
|
|
11622
|
+
responseHeaders?: Record<string, string>;
|
|
11623
|
+
}>;
|
|
11624
|
+
declare const createJsonErrorResponseHandler: <T>({ errorSchema, errorToMessage, isRetryable }: {
|
|
11625
|
+
errorSchema: FlexibleSchema<T>;
|
|
11626
|
+
errorToMessage: (error: T) => string;
|
|
11627
|
+
isRetryable?: (response: Response, error?: T) => boolean;
|
|
11628
|
+
}) => ResponseHandler<APICallError>;
|
|
11629
|
+
declare const createEventSourceResponseHandler: <T>(chunkSchema: FlexibleSchema<T>) => ResponseHandler<ReadableStream<ParseResult<T>>>;
|
|
11630
|
+
declare const createJsonResponseHandler: <T>(responseSchema: FlexibleSchema<T>) => ResponseHandler<T>;
|
|
11631
|
+
declare const createBinaryResponseHandler: () => ResponseHandler<Uint8Array>;
|
|
11632
|
+
declare const createStatusCodeErrorResponseHandler: () => ResponseHandler<APICallError>;
|
|
11633
|
+
declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin }: {
|
|
11634
|
+
url: string;
|
|
11635
|
+
headers?: Record<string, string | undefined>;
|
|
11636
|
+
failedResponseHandler: ResponseHandler<Error>;
|
|
11637
|
+
successfulResponseHandler: ResponseHandler<T>;
|
|
11638
|
+
abortSignal?: AbortSignal;
|
|
11639
|
+
fetch?: FetchFunction;
|
|
11640
|
+
/**
|
|
11641
|
+
* Set `true` when `url` is untrusted (e.g. taken from a provider response
|
|
11642
|
+
* body): it is routed through {@link fetchWithValidatedRedirects}, which
|
|
11643
|
+
* rejects private/loopback/link-local targets and re-validates redirect
|
|
11644
|
+
* hops; blocked URLs throw `DownloadError`. Set `false` only for URLs built
|
|
11645
|
+
* from a developer-configured endpoint.
|
|
11646
|
+
*
|
|
11647
|
+
* Optional for backwards compatibility with existing callers; omitting it
|
|
11648
|
+
* behaves like `false` (no validation). Provider code in this repository
|
|
11649
|
+
* must always pass it explicitly so every call site makes a visible trust
|
|
11650
|
+
* decision — see `contributing/secure-url-handling.md`.
|
|
11651
|
+
*/
|
|
11652
|
+
validateUrl?: boolean;
|
|
11653
|
+
/**
|
|
11654
|
+
* When set, `headers` are sent only if `url` is same-origin with this origin
|
|
11655
|
+
* (the user-agent suffix is always kept). Pass the provider's configured
|
|
11656
|
+
* base URL alongside `validateUrl: true` so credentials never ride a request
|
|
11657
|
+
* to a response-supplied host on a different origin (e.g. a CDN). Redirects
|
|
11658
|
+
* that later cross origin drop all caller headers regardless (see
|
|
11659
|
+
* {@link fetchWithValidatedRedirects}).
|
|
11660
|
+
*/
|
|
11661
|
+
credentialedOrigin?: string;
|
|
11662
|
+
/**
|
|
11663
|
+
* A developer-configured origin (e.g. the provider's `baseURL`) that is
|
|
11664
|
+
* exempt from URL validation when `validateUrl` is `true`. A response URL
|
|
11665
|
+
* (or redirect hop) that is same-origin with it is fetched without target
|
|
11666
|
+
* validation — it points at exactly the host a config-derived
|
|
11667
|
+
* `validateUrl: false` request would fetch anyway, so blocking it would
|
|
11668
|
+
* only break legitimate self-hosted / localhost deployments whose response
|
|
11669
|
+
* URLs point back at the configured host. Hops on any other origin are
|
|
11670
|
+
* still validated. Must never be derived from response data.
|
|
11671
|
+
*/
|
|
11672
|
+
trustedOrigin?: string;
|
|
11673
|
+
}) => Promise<{
|
|
11674
|
+
value: T;
|
|
11675
|
+
rawValue?: unknown;
|
|
11676
|
+
responseHeaders?: Record<string, string>;
|
|
11677
|
+
}>;
|
|
11678
|
+
declare function getRuntimeEnvironmentUserAgent(globalThisAny?: any): string;
|
|
11308
11679
|
/**
|
|
11309
11680
|
* Checks if an object has required keys.
|
|
11310
11681
|
* @param OBJECT - The object to check.
|
|
11311
11682
|
* @returns True if the object has required keys, false otherwise.
|
|
11312
11683
|
*/
|
|
11313
11684
|
type HasRequiredKey<OBJECT> = {} extends OBJECT ? false : true;
|
|
11685
|
+
declare function injectJsonInstructionIntoMessages({ messages, schema, schemaPrefix, schemaSuffix }: {
|
|
11686
|
+
messages: LanguageModelV4Prompt;
|
|
11687
|
+
schema?: JSONSchema7$1;
|
|
11688
|
+
schemaPrefix?: string;
|
|
11689
|
+
schemaSuffix?: string;
|
|
11690
|
+
}): LanguageModelV4Prompt;
|
|
11691
|
+
declare function isAbortError(error: unknown): error is Error;
|
|
11692
|
+
/**
|
|
11693
|
+
* Returns `true` when running in a browser.
|
|
11694
|
+
*
|
|
11695
|
+
* Detection keys on the presence of a global `window`, matching the browser
|
|
11696
|
+
* check used elsewhere in this package (see `getRuntimeEnvironmentUserAgent`)
|
|
11697
|
+
* so the SDK has a single, consistent definition of "browser". Server runtimes
|
|
11698
|
+
* (Node.js, Deno, Bun, edge/workers) do not define `window`.
|
|
11699
|
+
*/
|
|
11700
|
+
declare function isBrowserRuntime(globalThisAny?: any): boolean;
|
|
11701
|
+
/**
|
|
11702
|
+
* Type-guard for Node.js `Buffer` instances.
|
|
11703
|
+
*
|
|
11704
|
+
* Uses optional chaining on `globalThis.Buffer` so it returns `false` in
|
|
11705
|
+
* runtimes where `Buffer` is not available (e.g. CloudFlare Workers).
|
|
11706
|
+
*/
|
|
11707
|
+
declare function isBuffer(value: unknown): value is Buffer;
|
|
11708
|
+
/**
|
|
11709
|
+
* Returns true when `url` has the same origin (scheme + host + port) as
|
|
11710
|
+
* `baseUrl`.
|
|
11711
|
+
*
|
|
11712
|
+
* Used to decide whether provider credentials may be attached to a request to a
|
|
11713
|
+
* URL taken from a provider response (e.g. a polling or media-download URL).
|
|
11714
|
+
* Credentials must only be sent to the provider's own origin; a response that
|
|
11715
|
+
* names a foreign host (a CDN, or an attacker-controlled host if the response
|
|
11716
|
+
* is tampered with) must not receive the API key.
|
|
11717
|
+
*
|
|
11718
|
+
* Returns false if either value is not a valid absolute URL (fail-closed).
|
|
11719
|
+
*/
|
|
11720
|
+
declare function isSameOrigin(url: string, baseUrl: string): boolean;
|
|
11721
|
+
/**
|
|
11722
|
+
* Type guard that checks whether a value is not `null` or `undefined`.
|
|
11723
|
+
*
|
|
11724
|
+
* @template T - The type of the value to check.
|
|
11725
|
+
* @param value - The value to check.
|
|
11726
|
+
* @returns `true` if the value is neither `null` nor `undefined`, otherwise `false`.
|
|
11727
|
+
*/
|
|
11728
|
+
declare function isNonNullable<T>(value: T | undefined | null): value is NonNullable<T>;
|
|
11729
|
+
/**
|
|
11730
|
+
* Checks whether a value is a provider reference (a mapping of provider names
|
|
11731
|
+
* to provider-specific identifiers) as opposed to raw bytes, a URL, or a
|
|
11732
|
+
* tagged `{ type: ... }` object.
|
|
11733
|
+
*/
|
|
11734
|
+
declare function isProviderReference(data: unknown): data is SharedV4ProviderReference;
|
|
11735
|
+
/**
|
|
11736
|
+
* Checks whether a value is a non-null, non-array object.
|
|
11737
|
+
*/
|
|
11738
|
+
declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
11739
|
+
/**
|
|
11740
|
+
* Checks if the given URL is supported natively by the model.
|
|
11741
|
+
*
|
|
11742
|
+
* @param mediaType - The media type of the URL. Case-sensitive. May be a full
|
|
11743
|
+
* `type/subtype`, a wildcard `type/*`, or just the
|
|
11744
|
+
* top-level segment (e.g. `image`).
|
|
11745
|
+
* @param url - The URL to check.
|
|
11746
|
+
* @param supportedUrls - A record where keys are case-sensitive media types (or '*')
|
|
11747
|
+
* and values are arrays of RegExp patterns for URLs.
|
|
11748
|
+
*
|
|
11749
|
+
* @returns `true` if the URL matches a pattern under the specific media type
|
|
11750
|
+
* or the wildcard '*', `false` otherwise.
|
|
11751
|
+
*/
|
|
11752
|
+
declare function isUrlSupported({ mediaType, url, supportedUrls }: {
|
|
11753
|
+
mediaType: string;
|
|
11754
|
+
url: string;
|
|
11755
|
+
supportedUrls: Record<string, RegExp[]>;
|
|
11756
|
+
}): boolean;
|
|
11757
|
+
declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName, description }: {
|
|
11758
|
+
apiKey: string | undefined;
|
|
11759
|
+
environmentVariableName: string;
|
|
11760
|
+
apiKeyParameterName?: string;
|
|
11761
|
+
description: string;
|
|
11762
|
+
}): string;
|
|
11763
|
+
/**
|
|
11764
|
+
* Loads an optional `string` setting from the environment or a parameter.
|
|
11765
|
+
*
|
|
11766
|
+
* @param settingValue - The setting value.
|
|
11767
|
+
* @param environmentVariableName - The environment variable name.
|
|
11768
|
+
* @returns The setting value.
|
|
11769
|
+
*/
|
|
11770
|
+
declare function loadOptionalSetting({ settingValue, environmentVariableName }: {
|
|
11771
|
+
settingValue: string | undefined;
|
|
11772
|
+
environmentVariableName: string;
|
|
11773
|
+
}): string | undefined;
|
|
11774
|
+
/**
|
|
11775
|
+
* Loads a `string` setting from the environment or a parameter.
|
|
11776
|
+
*
|
|
11777
|
+
* @param settingValue - The setting value.
|
|
11778
|
+
* @param environmentVariableName - The environment variable name.
|
|
11779
|
+
* @param settingName - The setting name.
|
|
11780
|
+
* @param description - The description of the setting.
|
|
11781
|
+
* @returns The setting value.
|
|
11782
|
+
*/
|
|
11783
|
+
declare function loadSetting({ settingValue, environmentVariableName, settingName, description }: {
|
|
11784
|
+
settingValue: string | undefined;
|
|
11785
|
+
environmentVariableName: string;
|
|
11786
|
+
settingName: string;
|
|
11787
|
+
description: string;
|
|
11788
|
+
}): string;
|
|
11789
|
+
type ReasoningLevel = Exclude<LanguageModelV4CallOptions['reasoning'], 'none' | 'provider-default' | undefined>;
|
|
11790
|
+
declare function isCustomReasoning(reasoning: LanguageModelV4CallOptions['reasoning']): reasoning is Exclude<LanguageModelV4CallOptions['reasoning'], 'provider-default' | undefined>;
|
|
11791
|
+
/**
|
|
11792
|
+
* Maps a top-level reasoning level to a provider-specific effort string using
|
|
11793
|
+
* the given effort map. Pushes a compatibility warning if the reasoning level
|
|
11794
|
+
* maps to a different string, or an unsupported warning if the level is not
|
|
11795
|
+
* present in the map.
|
|
11796
|
+
*
|
|
11797
|
+
* @returns The mapped effort string, or `undefined` if the level is not
|
|
11798
|
+
* supported.
|
|
11799
|
+
*/
|
|
11800
|
+
declare function mapReasoningToProviderEffort<T extends string>({ reasoning, effortMap, warnings }: {
|
|
11801
|
+
reasoning: ReasoningLevel;
|
|
11802
|
+
effortMap: Partial<Record<ReasoningLevel, T>>;
|
|
11803
|
+
warnings: SharedV4Warning[];
|
|
11804
|
+
}): T | undefined;
|
|
11805
|
+
/**
|
|
11806
|
+
* Maps a top-level reasoning level to an absolute token budget by multiplying
|
|
11807
|
+
* the model's max output tokens by a percentage from the budget percentages
|
|
11808
|
+
* map. The result is clamped between `minReasoningBudget` (default 1024) and
|
|
11809
|
+
* `maxReasoningBudget`. Pushes an unsupported warning if the level is not
|
|
11810
|
+
* present in the budget percentages map.
|
|
11811
|
+
*
|
|
11812
|
+
* @returns The computed token budget, or `undefined` if the level is not
|
|
11813
|
+
* supported.
|
|
11814
|
+
*/
|
|
11815
|
+
declare function mapReasoningToProviderBudget({ reasoning, maxOutputTokens, maxReasoningBudget, minReasoningBudget, budgetPercentages, warnings }: {
|
|
11816
|
+
reasoning: ReasoningLevel;
|
|
11817
|
+
maxOutputTokens: number;
|
|
11818
|
+
maxReasoningBudget: number;
|
|
11819
|
+
minReasoningBudget?: number;
|
|
11820
|
+
budgetPercentages?: Partial<Record<ReasoningLevel, number>>;
|
|
11821
|
+
warnings: SharedV4Warning[];
|
|
11822
|
+
}): number | undefined;
|
|
11314
11823
|
/**
|
|
11315
11824
|
* A value that can be provided either synchronously or as a promise-like.
|
|
11316
11825
|
*/
|
|
@@ -11324,16 +11833,69 @@ type MaybePromiseLike<T> = T | PromiseLike<T>;
|
|
|
11324
11833
|
* @returns The corresponding file extension
|
|
11325
11834
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types
|
|
11326
11835
|
*/
|
|
11836
|
+
declare function mediaTypeToExtension(mediaType: string): string;
|
|
11837
|
+
/**
|
|
11838
|
+
* Normalizes different header inputs into a plain record with lower-case keys.
|
|
11839
|
+
* Entries with `undefined` or `null` values are removed.
|
|
11840
|
+
*
|
|
11841
|
+
* @param headers - Input headers (`Headers`, tuples array, plain record) to normalize.
|
|
11842
|
+
* @returns A record containing the normalized header entries.
|
|
11843
|
+
*/
|
|
11844
|
+
declare function normalizeHeaders(headers: HeadersInit | Record<string, string | undefined> | Array<[string, string | undefined]> | undefined): Record<string, string>;
|
|
11327
11845
|
/**
|
|
11328
11846
|
* Parses a JSON event stream into a stream of parsed JSON objects.
|
|
11329
11847
|
*/
|
|
11330
|
-
declare function parseJsonEventStream<T>({
|
|
11331
|
-
stream,
|
|
11332
|
-
schema
|
|
11333
|
-
}: {
|
|
11848
|
+
declare function parseJsonEventStream<T>({ stream, schema }: {
|
|
11334
11849
|
stream: ReadableStream<Uint8Array>;
|
|
11335
11850
|
schema: FlexibleSchema<T>;
|
|
11336
11851
|
}): ReadableStream<ParseResult<T>>;
|
|
11852
|
+
declare function parseProviderOptions<OPTIONS>({ provider, providerOptions, schema }: {
|
|
11853
|
+
provider: string;
|
|
11854
|
+
providerOptions: Record<string, unknown> | undefined;
|
|
11855
|
+
schema: FlexibleSchema<OPTIONS>;
|
|
11856
|
+
}): Promise<OPTIONS | undefined>;
|
|
11857
|
+
declare const postJsonToApi: <T>({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch }: {
|
|
11858
|
+
url: string;
|
|
11859
|
+
headers?: Record<string, string | undefined>;
|
|
11860
|
+
body: unknown;
|
|
11861
|
+
failedResponseHandler: ResponseHandler<APICallError>;
|
|
11862
|
+
successfulResponseHandler: ResponseHandler<T>;
|
|
11863
|
+
abortSignal?: AbortSignal;
|
|
11864
|
+
fetch?: FetchFunction;
|
|
11865
|
+
}) => Promise<{
|
|
11866
|
+
value: T;
|
|
11867
|
+
rawValue?: unknown;
|
|
11868
|
+
responseHeaders?: Record<string, string>;
|
|
11869
|
+
}>;
|
|
11870
|
+
declare const postFormDataToApi: <T>({ url, headers, formData, failedResponseHandler, successfulResponseHandler, abortSignal, fetch }: {
|
|
11871
|
+
url: string;
|
|
11872
|
+
headers?: Record<string, string | undefined>;
|
|
11873
|
+
formData: FormData;
|
|
11874
|
+
failedResponseHandler: ResponseHandler<APICallError>;
|
|
11875
|
+
successfulResponseHandler: ResponseHandler<T>;
|
|
11876
|
+
abortSignal?: AbortSignal;
|
|
11877
|
+
fetch?: FetchFunction;
|
|
11878
|
+
}) => Promise<{
|
|
11879
|
+
value: T;
|
|
11880
|
+
rawValue?: unknown;
|
|
11881
|
+
responseHeaders?: Record<string, string>;
|
|
11882
|
+
}>;
|
|
11883
|
+
declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch }: {
|
|
11884
|
+
url: string;
|
|
11885
|
+
headers?: Record<string, string | undefined>;
|
|
11886
|
+
body: {
|
|
11887
|
+
content: string | FormData | Uint8Array | Blob;
|
|
11888
|
+
values: unknown;
|
|
11889
|
+
};
|
|
11890
|
+
failedResponseHandler: ResponseHandler<Error>;
|
|
11891
|
+
successfulResponseHandler: ResponseHandler<T>;
|
|
11892
|
+
abortSignal?: AbortSignal;
|
|
11893
|
+
fetch?: FetchFunction;
|
|
11894
|
+
}) => Promise<{
|
|
11895
|
+
value: T;
|
|
11896
|
+
rawValue?: unknown;
|
|
11897
|
+
responseHeaders?: Record<string, string>;
|
|
11898
|
+
}>;
|
|
11337
11899
|
/**
|
|
11338
11900
|
* A context object that is passed into tool execution.
|
|
11339
11901
|
*/
|
|
@@ -11347,6 +11909,7 @@ type ExecutableTool<TOOL extends Tool = Tool> = TOOL & {
|
|
|
11347
11909
|
/**
|
|
11348
11910
|
* Checks whether a tool exposes an execute function.
|
|
11349
11911
|
*/
|
|
11912
|
+
declare function isExecutableTool<TOOL extends Tool>(tool: TOOL | undefined): tool is ExecutableTool<TOOL>;
|
|
11350
11913
|
type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
|
|
11351
11914
|
/**
|
|
11352
11915
|
* Tool approval request prompt part.
|
|
@@ -11970,6 +12533,31 @@ declare function dynamicTool(tool: Omit<DynamicTool<unknown, unknown, Context$1>
|
|
|
11970
12533
|
* A provider-defined tool is a tool for which the provider defines the input
|
|
11971
12534
|
* and output schemas, but does not execute the tool.
|
|
11972
12535
|
*/
|
|
12536
|
+
type ProviderDefinedToolFactory<INPUT, ARGS extends object, CONTEXT extends Context$1 = {}> = <OUTPUT>(options: ARGS & {
|
|
12537
|
+
execute?: ToolExecuteFunction<INPUT, OUTPUT, CONTEXT>;
|
|
12538
|
+
needsApproval?: Tool<INPUT, OUTPUT, CONTEXT>['needsApproval'];
|
|
12539
|
+
toModelOutput?: Tool<INPUT, OUTPUT, CONTEXT>['toModelOutput'];
|
|
12540
|
+
onInputStart?: Tool<INPUT, OUTPUT, CONTEXT>['onInputStart'];
|
|
12541
|
+
onInputDelta?: Tool<INPUT, OUTPUT, CONTEXT>['onInputDelta'];
|
|
12542
|
+
onInputAvailable?: Tool<INPUT, OUTPUT, CONTEXT>['onInputAvailable'];
|
|
12543
|
+
}) => ProviderDefinedTool<INPUT, OUTPUT, CONTEXT>;
|
|
12544
|
+
declare function createProviderDefinedToolFactory<INPUT, ARGS extends object, CONTEXT extends Context$1 = {}>({ id, inputSchema }: {
|
|
12545
|
+
id: `${string}.${string}`;
|
|
12546
|
+
inputSchema: FlexibleSchema<INPUT>;
|
|
12547
|
+
}): ProviderDefinedToolFactory<INPUT, ARGS, CONTEXT>;
|
|
12548
|
+
type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object, CONTEXT extends Context$1 = {}> = (options: ARGS & {
|
|
12549
|
+
execute?: ToolExecuteFunction<INPUT, OUTPUT, CONTEXT>;
|
|
12550
|
+
needsApproval?: Tool<INPUT, OUTPUT, CONTEXT>['needsApproval'];
|
|
12551
|
+
toModelOutput?: Tool<INPUT, OUTPUT, CONTEXT>['toModelOutput'];
|
|
12552
|
+
onInputStart?: Tool<INPUT, OUTPUT, CONTEXT>['onInputStart'];
|
|
12553
|
+
onInputDelta?: Tool<INPUT, OUTPUT, CONTEXT>['onInputDelta'];
|
|
12554
|
+
onInputAvailable?: Tool<INPUT, OUTPUT, CONTEXT>['onInputAvailable'];
|
|
12555
|
+
}) => ProviderDefinedTool<INPUT, OUTPUT, CONTEXT>;
|
|
12556
|
+
declare function createProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object, CONTEXT extends Context$1 = {}>({ id, inputSchema, outputSchema }: {
|
|
12557
|
+
id: `${string}.${string}`;
|
|
12558
|
+
inputSchema: FlexibleSchema<INPUT>;
|
|
12559
|
+
outputSchema: FlexibleSchema<OUTPUT>;
|
|
12560
|
+
}): ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS, CONTEXT>;
|
|
11973
12561
|
/**
|
|
11974
12562
|
* A provider-executed tool is a tool for which the provider executes the tool.
|
|
11975
12563
|
*/
|
|
@@ -11978,6 +12566,71 @@ type ProviderExecutedToolFactory<INPUT, OUTPUT, ARGS extends object, CONTEXT ext
|
|
|
11978
12566
|
onInputDelta?: Tool<INPUT, OUTPUT, CONTEXT>['onInputDelta'];
|
|
11979
12567
|
onInputAvailable?: Tool<INPUT, OUTPUT, CONTEXT>['onInputAvailable'];
|
|
11980
12568
|
}) => ProviderExecutedTool<INPUT, OUTPUT, CONTEXT>;
|
|
12569
|
+
declare function createProviderExecutedToolFactory<INPUT, OUTPUT, ARGS extends object, CONTEXT extends Context$1 = {}>({ id, inputSchema, outputSchema, supportsDeferredResults }: {
|
|
12570
|
+
id: `${string}.${string}`;
|
|
12571
|
+
inputSchema: FlexibleSchema<INPUT>;
|
|
12572
|
+
outputSchema: FlexibleSchema<OUTPUT>;
|
|
12573
|
+
/**
|
|
12574
|
+
* Whether this provider-executed tool supports deferred results.
|
|
12575
|
+
*
|
|
12576
|
+
* When true, the tool result may not be returned in the same turn as the
|
|
12577
|
+
* tool call (e.g., when using programmatic tool calling where a server tool
|
|
12578
|
+
* triggers a client-executed tool, and the server tool's result is deferred
|
|
12579
|
+
* until the client tool is resolved).
|
|
12580
|
+
*
|
|
12581
|
+
* @default false
|
|
12582
|
+
*/
|
|
12583
|
+
supportsDeferredResults?: boolean;
|
|
12584
|
+
}): ProviderExecutedToolFactory<INPUT, OUTPUT, ARGS, CONTEXT>;
|
|
12585
|
+
/**
|
|
12586
|
+
* Cancels a response body to release the underlying connection.
|
|
12587
|
+
*
|
|
12588
|
+
* When a fetch Response is rejected without consuming its body (e.g. a failed
|
|
12589
|
+
* status code, an open-redirect rejection, or a Content-Length that exceeds the
|
|
12590
|
+
* size limit), the underlying TCP socket is not returned to the connection pool
|
|
12591
|
+
* and may stay open until the process runs out of file descriptors. Cancelling
|
|
12592
|
+
* the body avoids this leak.
|
|
12593
|
+
*
|
|
12594
|
+
* Errors thrown while cancelling are ignored: the body may already be locked,
|
|
12595
|
+
* disturbed, or absent, none of which should mask the original rejection.
|
|
12596
|
+
*/
|
|
12597
|
+
declare function cancelResponseBody(response: Response): Promise<void>;
|
|
12598
|
+
/**
|
|
12599
|
+
* Default maximum download size: 2 GiB.
|
|
12600
|
+
*
|
|
12601
|
+
* `fetch().arrayBuffer()` has ~2x peak memory overhead (undici buffers the
|
|
12602
|
+
* body internally, then creates the JS ArrayBuffer), so very large downloads
|
|
12603
|
+
* risk exceeding the default V8 heap limit on 64-bit systems and terminating
|
|
12604
|
+
* the process with an out-of-memory error.
|
|
12605
|
+
*
|
|
12606
|
+
* Setting this limit converts an unrecoverable OOM crash into a catchable
|
|
12607
|
+
* `DownloadError`.
|
|
12608
|
+
*/
|
|
12609
|
+
declare const DEFAULT_MAX_DOWNLOAD_SIZE: number;
|
|
12610
|
+
/**
|
|
12611
|
+
* Reads a fetch Response body with a size limit to prevent memory exhaustion.
|
|
12612
|
+
*
|
|
12613
|
+
* Checks the Content-Length header for early rejection, then reads the body
|
|
12614
|
+
* incrementally via ReadableStream and aborts with a DownloadError when the
|
|
12615
|
+
* limit is exceeded.
|
|
12616
|
+
*
|
|
12617
|
+
* @param response - The fetch Response to read.
|
|
12618
|
+
* @param url - The URL being downloaded (used in error messages).
|
|
12619
|
+
* @param maxBytes - Maximum allowed bytes. Defaults to DEFAULT_MAX_DOWNLOAD_SIZE.
|
|
12620
|
+
* @returns A Uint8Array containing the response body.
|
|
12621
|
+
* @throws DownloadError if the response exceeds maxBytes.
|
|
12622
|
+
*/
|
|
12623
|
+
declare function readResponseWithSizeLimit({ response, url, maxBytes }: {
|
|
12624
|
+
response: Response;
|
|
12625
|
+
url: string;
|
|
12626
|
+
maxBytes?: number;
|
|
12627
|
+
}): Promise<Uint8Array>;
|
|
12628
|
+
/**
|
|
12629
|
+
* Removes entries from a record where the value is null or undefined.
|
|
12630
|
+
* @param record - The input object whose entries may be null or undefined.
|
|
12631
|
+
* @returns A new object containing only entries with non-null and non-undefined values.
|
|
12632
|
+
*/
|
|
12633
|
+
declare function removeUndefinedEntries<T>(record: Record<string, T | undefined>): Record<string, T>;
|
|
11981
12634
|
/**
|
|
11982
12635
|
* A value or a lazy provider of a value, each of which may be synchronous or asynchronous.
|
|
11983
12636
|
*
|
|
@@ -11998,6 +12651,338 @@ type Resolvable<T> = MaybePromiseLike<T> | (() => MaybePromiseLike<T>);
|
|
|
11998
12651
|
* Resolves a value that could be a raw value, a Promise, a function returning a value,
|
|
11999
12652
|
* or a function returning a Promise.
|
|
12000
12653
|
*/
|
|
12654
|
+
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
|
12655
|
+
/**
|
|
12656
|
+
* Resolves a file part's media type to a full `type/subtype` form required by
|
|
12657
|
+
* providers whose API demands the full IANA media type.
|
|
12658
|
+
*
|
|
12659
|
+
* - If `part.mediaType` is already a full media type (e.g. `image/png`), it is
|
|
12660
|
+
* returned as-is.
|
|
12661
|
+
* - Otherwise, when inline bytes are available (`part.data.type === 'data'`),
|
|
12662
|
+
* the subtype is sniffed from the bytes using the signature table that
|
|
12663
|
+
* corresponds to the top-level segment.
|
|
12664
|
+
* - When neither applies (e.g. top-level-only with a URL source, or bytes that
|
|
12665
|
+
* cannot be detected), an `UnsupportedFunctionalityError` is thrown.
|
|
12666
|
+
*/
|
|
12667
|
+
declare function resolveFullMediaType({ part }: {
|
|
12668
|
+
part: LanguageModelV4FilePart;
|
|
12669
|
+
}): string;
|
|
12670
|
+
/**
|
|
12671
|
+
* Resolves a provider reference to the provider-specific identifier for the
|
|
12672
|
+
* given provider. Throws `NoSuchProviderReferenceError` if the provider is not
|
|
12673
|
+
* found in the reference mapping.
|
|
12674
|
+
*/
|
|
12675
|
+
declare function resolveProviderReference({ reference, provider }: {
|
|
12676
|
+
reference: SharedV4ProviderReference;
|
|
12677
|
+
provider: string;
|
|
12678
|
+
}): string;
|
|
12679
|
+
type RetryFunction = <OUTPUT>(fn: () => PromiseLike<OUTPUT>) => PromiseLike<OUTPUT>;
|
|
12680
|
+
type RetryErrorReason$1 = 'maxRetriesExceeded' | 'errorNotRetryable';
|
|
12681
|
+
type RetryErrorFactory = ({ message, reason, errors }: {
|
|
12682
|
+
message: string;
|
|
12683
|
+
reason: RetryErrorReason$1;
|
|
12684
|
+
errors: Array<unknown>;
|
|
12685
|
+
}) => unknown;
|
|
12686
|
+
type RetryDelayProvider = ({ error, exponentialBackoffDelay }: {
|
|
12687
|
+
error: unknown;
|
|
12688
|
+
exponentialBackoffDelay: number;
|
|
12689
|
+
}) => number;
|
|
12690
|
+
type ShouldRetryFunction = (error: unknown) => boolean | Promise<boolean>;
|
|
12691
|
+
/**
|
|
12692
|
+
* Retries a failed operation with exponential backoff.
|
|
12693
|
+
*/
|
|
12694
|
+
declare const retryWithExponentialBackoff: ({ maxRetries, initialDelayInMs, backoffFactor, abortSignal, shouldRetry, getDelayInMs, createRetryError }: {
|
|
12695
|
+
maxRetries?: number;
|
|
12696
|
+
initialDelayInMs?: number;
|
|
12697
|
+
backoffFactor?: number;
|
|
12698
|
+
abortSignal?: AbortSignal;
|
|
12699
|
+
shouldRetry: ShouldRetryFunction;
|
|
12700
|
+
getDelayInMs?: RetryDelayProvider;
|
|
12701
|
+
createRetryError?: RetryErrorFactory;
|
|
12702
|
+
}) => RetryFunction;
|
|
12703
|
+
/**
|
|
12704
|
+
* Serializes a model instance for workflow step boundaries.
|
|
12705
|
+
* Returns the `modelId` plus the JSON-serializable config properties.
|
|
12706
|
+
*
|
|
12707
|
+
* Non-serializable values are omitted. As a special case, a
|
|
12708
|
+
* function-valued `headers` property is resolved during serialization
|
|
12709
|
+
* and included if the returned value is JSON-serializable.
|
|
12710
|
+
*
|
|
12711
|
+
* Used as the body of `static [WORKFLOW_SERIALIZE]` in provider models.
|
|
12712
|
+
*
|
|
12713
|
+
* @example
|
|
12714
|
+
* ```ts
|
|
12715
|
+
* static [WORKFLOW_SERIALIZE](model: MyLanguageModel) {
|
|
12716
|
+
* return serializeModelOptions({
|
|
12717
|
+
* modelId: model.modelId,
|
|
12718
|
+
* config: model.config,
|
|
12719
|
+
* });
|
|
12720
|
+
* }
|
|
12721
|
+
* ```
|
|
12722
|
+
*/
|
|
12723
|
+
declare function serializeModelOptions<CONFIG extends {
|
|
12724
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
12725
|
+
}>(options: {
|
|
12726
|
+
modelId: string;
|
|
12727
|
+
config: CONFIG;
|
|
12728
|
+
}): {
|
|
12729
|
+
modelId: string;
|
|
12730
|
+
config: JSONObject$2;
|
|
12731
|
+
};
|
|
12732
|
+
declare const symbol$10: unique symbol;
|
|
12733
|
+
declare class SerializationError extends AISDKError {
|
|
12734
|
+
private readonly [symbol$10];
|
|
12735
|
+
constructor({ message, cause }?: {
|
|
12736
|
+
message?: string;
|
|
12737
|
+
cause?: unknown;
|
|
12738
|
+
});
|
|
12739
|
+
static isInstance(error: unknown): error is SerializationError;
|
|
12740
|
+
}
|
|
12741
|
+
declare function secureJsonParse(text: string): any;
|
|
12742
|
+
/**
|
|
12743
|
+
* Minimal interface for a streaming tool call delta from an OpenAI-compatible API.
|
|
12744
|
+
*/
|
|
12745
|
+
interface StreamingToolCallDelta {
|
|
12746
|
+
index?: number | null;
|
|
12747
|
+
id?: string | null;
|
|
12748
|
+
type?: string | null;
|
|
12749
|
+
function?: {
|
|
12750
|
+
name?: string | null;
|
|
12751
|
+
arguments?: string | null;
|
|
12752
|
+
} | null;
|
|
12753
|
+
}
|
|
12754
|
+
interface StreamingToolCallTrackerOptions<DELTA extends StreamingToolCallDelta = StreamingToolCallDelta> {
|
|
12755
|
+
/**
|
|
12756
|
+
* ID generator function for tool call IDs.
|
|
12757
|
+
* Defaults to the standard generateId.
|
|
12758
|
+
*/
|
|
12759
|
+
generateId?: () => string;
|
|
12760
|
+
/**
|
|
12761
|
+
* How to validate the `type` field on new tool call deltas.
|
|
12762
|
+
* - `'none'`: no validation (default)
|
|
12763
|
+
* - `'if-present'`: throw if type is present and not `'function'`
|
|
12764
|
+
* - `'required'`: throw if type is not exactly `'function'`
|
|
12765
|
+
*/
|
|
12766
|
+
typeValidation?: 'none' | 'if-present' | 'required';
|
|
12767
|
+
/**
|
|
12768
|
+
* Extract provider-specific metadata from a tool call delta.
|
|
12769
|
+
* Called once when a new tool call is detected.
|
|
12770
|
+
* The returned metadata is stored on the tool call and passed to
|
|
12771
|
+
* `buildToolCallProviderMetadata` when the tool call is finalized.
|
|
12772
|
+
*/
|
|
12773
|
+
extractMetadata?: (delta: DELTA) => SharedV4ProviderMetadata | undefined;
|
|
12774
|
+
/**
|
|
12775
|
+
* Build the `providerMetadata` object for a `tool-call` event.
|
|
12776
|
+
* Receives the metadata previously extracted via `extractMetadata`.
|
|
12777
|
+
* If `undefined` is returned, no `providerMetadata` is included in the event.
|
|
12778
|
+
*/
|
|
12779
|
+
buildToolCallProviderMetadata?: (metadata: SharedV4ProviderMetadata | undefined) => SharedV4ProviderMetadata | undefined;
|
|
12780
|
+
}
|
|
12781
|
+
type StreamingToolCallTrackerController = Pick<TransformStreamDefaultController<LanguageModelV4StreamPart>, 'enqueue'>;
|
|
12782
|
+
/**
|
|
12783
|
+
* Tracks streaming tool call state across multiple deltas from an
|
|
12784
|
+
* OpenAI-compatible chat completion stream. Handles argument accumulation,
|
|
12785
|
+
* emits tool-input-start/delta/end and tool-call events, and finalizes
|
|
12786
|
+
* unfinished tool calls on flush.
|
|
12787
|
+
*
|
|
12788
|
+
* Used by openai, openai-compatible, groq, deepseek, and alibaba providers.
|
|
12789
|
+
*/
|
|
12790
|
+
declare class StreamingToolCallTracker<DELTA extends StreamingToolCallDelta = StreamingToolCallDelta> {
|
|
12791
|
+
private toolCalls;
|
|
12792
|
+
private toolCallsById;
|
|
12793
|
+
private toolCallsByIndex;
|
|
12794
|
+
private latestToolCall;
|
|
12795
|
+
private readonly controller;
|
|
12796
|
+
private readonly _generateId;
|
|
12797
|
+
private readonly typeValidation;
|
|
12798
|
+
private readonly extractMetadata?;
|
|
12799
|
+
private readonly buildToolCallProviderMetadata?;
|
|
12800
|
+
constructor(controller: StreamingToolCallTrackerController, options?: StreamingToolCallTrackerOptions<DELTA>);
|
|
12801
|
+
/**
|
|
12802
|
+
* Process a tool call delta from a streaming response chunk.
|
|
12803
|
+
* Emits tool-input-start, tool-input-delta, tool-input-end, and tool-call
|
|
12804
|
+
* events as appropriate.
|
|
12805
|
+
*/
|
|
12806
|
+
processDelta(toolCallDelta: DELTA): void;
|
|
12807
|
+
/**
|
|
12808
|
+
* Finalize any unfinished tool calls. Should be called during the stream's
|
|
12809
|
+
* flush handler to ensure all tool calls are properly completed.
|
|
12810
|
+
*/
|
|
12811
|
+
flush(): void;
|
|
12812
|
+
private processNewToolCall;
|
|
12813
|
+
private processExistingToolCall;
|
|
12814
|
+
private finishToolCall;
|
|
12815
|
+
}
|
|
12816
|
+
/**
|
|
12817
|
+
* Strips file extension segments from a filename.
|
|
12818
|
+
*
|
|
12819
|
+
* Examples:
|
|
12820
|
+
* - "report.pdf" -> "report"
|
|
12821
|
+
* - "archive.tar.gz" -> "archive"
|
|
12822
|
+
* - "filename" -> "filename"
|
|
12823
|
+
*/
|
|
12824
|
+
declare function stripFileExtension(filename: string): string;
|
|
12825
|
+
/**
|
|
12826
|
+
* Experimental transcription-stream WebSocket envelope (v1): the standard
|
|
12827
|
+
* serialization of `TranscriptionModelV4.doStream` over a WebSocket. Clients
|
|
12828
|
+
* (e.g. the `@ai-sdk/gateway` provider) encode with this module and servers
|
|
12829
|
+
* (e.g. AI Gateway) decode with it, so the two sides cannot drift.
|
|
12830
|
+
*
|
|
12831
|
+
* Envelope rules:
|
|
12832
|
+
*
|
|
12833
|
+
* 1. The client sends exactly one `transcription-stream.start` TEXT frame
|
|
12834
|
+
* first.
|
|
12835
|
+
* 2. Audio rides BINARY frames containing raw bytes in the declared
|
|
12836
|
+
* `inputAudioFormat` (base64 string chunks are decoded before sending).
|
|
12837
|
+
* 3. The client signals end of audio with the
|
|
12838
|
+
* `transcription-stream.audio-done` TEXT frame; a plain close without it
|
|
12839
|
+
* is an abort.
|
|
12840
|
+
* 4. Every server→client TEXT frame is one JSON-serialized
|
|
12841
|
+
* `TranscriptionModelV4StreamPart` (flattened, no wrapper). Payloads must
|
|
12842
|
+
* be JSON-serializable. `Date` values (`response-metadata.timestamp`)
|
|
12843
|
+
* serialize to ISO 8601 strings and are revived by
|
|
12844
|
+
* `parseTranscriptionStreamPart`. `Error` payloads in `error` parts
|
|
12845
|
+
* serialize as `{ name, message }`.
|
|
12846
|
+
* 5. The server closes with code 1000 after the `finish` part; on failure it
|
|
12847
|
+
* sends an `error` part and closes non-1000. A close without a prior
|
|
12848
|
+
* `finish` is an error.
|
|
12849
|
+
* 6. Unknown frame/part types are ignored in both directions (forward
|
|
12850
|
+
* compatibility).
|
|
12851
|
+
* 7. Servers may enforce a maximum frame size (the AI Gateway rejects frames
|
|
12852
|
+
* over 256 KiB); clients should split audio into frames of at most
|
|
12853
|
+
* 64 KiB.
|
|
12854
|
+
* 8. Connection establishment (URL, auth) is transport-specific and out of
|
|
12855
|
+
* scope.
|
|
12856
|
+
*
|
|
12857
|
+
* The envelope validates frame shape only; server policy (accepted audio
|
|
12858
|
+
* formats, required `rate`, size limits) layers on top. Both parsers use
|
|
12859
|
+
* `secureJsonParse`, so frames carrying `__proto__` / `constructor.prototype`
|
|
12860
|
+
* keys are rejected (prototype-pollution protection) rather than parsed.
|
|
12861
|
+
*/
|
|
12862
|
+
/** Type of the first client TEXT frame. */
|
|
12863
|
+
declare const TRANSCRIPTION_STREAM_START_FRAME_TYPE = "transcription-stream.start";
|
|
12864
|
+
/** Type of the client TEXT frame that signals the end of the audio input. */
|
|
12865
|
+
declare const TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE = "transcription-stream.audio-done";
|
|
12866
|
+
/**
|
|
12867
|
+
* The client's session start frame. Optional keys are omitted when undefined.
|
|
12868
|
+
*/
|
|
12869
|
+
type TranscriptionStreamStartFrame = {
|
|
12870
|
+
type: typeof TRANSCRIPTION_STREAM_START_FRAME_TYPE;
|
|
12871
|
+
/** Audio format of the binary audio frames, e.g. `{ type: 'audio/pcm', rate: 16000 }`. */
|
|
12872
|
+
inputAudioFormat: {
|
|
12873
|
+
type: string;
|
|
12874
|
+
rate?: number;
|
|
12875
|
+
};
|
|
12876
|
+
/** Provider-specific options, passed through verbatim. */
|
|
12877
|
+
providerOptions?: Record<string, JSONObject$2>;
|
|
12878
|
+
/** When true, the server should include `raw` parts in the stream. */
|
|
12879
|
+
includeRawChunks?: boolean;
|
|
12880
|
+
};
|
|
12881
|
+
/** Server-side classification of a client TEXT frame. */
|
|
12882
|
+
type TranscriptionStreamClientFrame = {
|
|
12883
|
+
type: 'start';
|
|
12884
|
+
frame: TranscriptionStreamStartFrame;
|
|
12885
|
+
} | {
|
|
12886
|
+
type: 'audio-done';
|
|
12887
|
+
} | {
|
|
12888
|
+
/** Malformed JSON or a recognized frame with an invalid shape. */
|
|
12889
|
+
type: 'invalid';
|
|
12890
|
+
message: string;
|
|
12891
|
+
} | {
|
|
12892
|
+
/** Unrecognized frame type; ignore for forward compatibility. */
|
|
12893
|
+
type: 'unknown';
|
|
12894
|
+
};
|
|
12895
|
+
/**
|
|
12896
|
+
* Server-side: parse a client TEXT frame. Validates envelope shape only and
|
|
12897
|
+
* rejects prototype-pollution payloads (parsed with `secureJsonParse`). Never
|
|
12898
|
+
* throws.
|
|
12899
|
+
*/
|
|
12900
|
+
declare function parseTranscriptionStreamClientFrame(text: string): TranscriptionStreamClientFrame;
|
|
12901
|
+
/**
|
|
12902
|
+
* Server-side: serialize a transcription stream part as one TEXT frame.
|
|
12903
|
+
* `Error` payloads in `error` parts serialize as `{ name, message }` —
|
|
12904
|
+
* `Error` properties are non-enumerable, so a plain `JSON.stringify` would
|
|
12905
|
+
* serialize them to `{}` and lose the message end-to-end. Returns
|
|
12906
|
+
* `undefined` for payloads that are not JSON-serializable (envelope rule 4,
|
|
12907
|
+
* e.g. bigint or cyclic values); callers drop the frame.
|
|
12908
|
+
*/
|
|
12909
|
+
declare function serializeTranscriptionStreamPart(part: TranscriptionModelV4StreamPart): string | undefined;
|
|
12910
|
+
/**
|
|
12911
|
+
* Client-side: parse a server TEXT frame into a transcription stream part.
|
|
12912
|
+
* Returns `undefined` for malformed or unsafe (prototype-polluting) JSON
|
|
12913
|
+
* (parsed with `secureJsonParse`), unknown part types, and known part types
|
|
12914
|
+
* whose required or optional fields are missing or mistyped (including
|
|
12915
|
+
* warning and segment elements) — downstream SDK code dereferences those
|
|
12916
|
+
* fields, so a drifted server must not crash or pollute the stream.
|
|
12917
|
+
* Revives `response-metadata.timestamp` to a `Date`.
|
|
12918
|
+
*/
|
|
12919
|
+
declare function parseTranscriptionStreamPart(text: string): TranscriptionModelV4StreamPart | undefined;
|
|
12920
|
+
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
|
12921
|
+
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
|
12922
|
+
declare function convertToBase64(value: string | Uint8Array): string;
|
|
12923
|
+
declare function validateBaseURL(baseURL: string | undefined): string | undefined;
|
|
12924
|
+
/**
|
|
12925
|
+
* Validates that a URL is safe to download from, blocking private/internal addresses
|
|
12926
|
+
* to prevent SSRF attacks.
|
|
12927
|
+
*
|
|
12928
|
+
* Note: this function performs string/literal-IP checks only. The Node.js
|
|
12929
|
+
* download fetch additionally validates and pins DNS results at connect time.
|
|
12930
|
+
*
|
|
12931
|
+
* @param url - The URL string to validate.
|
|
12932
|
+
* @throws DownloadError if the URL is unsafe.
|
|
12933
|
+
*/
|
|
12934
|
+
declare function validateDownloadUrl(url: string): void;
|
|
12935
|
+
/**
|
|
12936
|
+
* Validates the types of an unknown object using a schema and
|
|
12937
|
+
* return a strongly-typed object.
|
|
12938
|
+
*
|
|
12939
|
+
* @template T - The type of the object to validate.
|
|
12940
|
+
* @param {string} options.value - The object to validate.
|
|
12941
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
|
12942
|
+
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
|
|
12943
|
+
* @returns {Promise<T>} - The typed object.
|
|
12944
|
+
*/
|
|
12945
|
+
declare function validateTypes<OBJECT>({ value, schema, context }: {
|
|
12946
|
+
value: unknown;
|
|
12947
|
+
schema: FlexibleSchema<OBJECT>;
|
|
12948
|
+
context?: TypeValidationContext;
|
|
12949
|
+
}): Promise<OBJECT>;
|
|
12950
|
+
/**
|
|
12951
|
+
* Safely validates the types of an unknown object using a schema and
|
|
12952
|
+
* return a strongly-typed object.
|
|
12953
|
+
*
|
|
12954
|
+
* @template T - The type of the object to validate.
|
|
12955
|
+
* @param {string} options.value - The JSON object to validate.
|
|
12956
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
|
12957
|
+
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
|
|
12958
|
+
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
|
12959
|
+
*/
|
|
12960
|
+
declare function safeValidateTypes<OBJECT>({ value, schema, context }: {
|
|
12961
|
+
value: unknown;
|
|
12962
|
+
schema: FlexibleSchema<OBJECT>;
|
|
12963
|
+
context?: TypeValidationContext;
|
|
12964
|
+
}): Promise<{
|
|
12965
|
+
success: true;
|
|
12966
|
+
value: OBJECT;
|
|
12967
|
+
rawValue: unknown;
|
|
12968
|
+
} | {
|
|
12969
|
+
success: false;
|
|
12970
|
+
error: TypeValidationError;
|
|
12971
|
+
rawValue: unknown;
|
|
12972
|
+
}>;
|
|
12973
|
+
declare const VERSION: string;
|
|
12974
|
+
/**
|
|
12975
|
+
* Appends suffix parts to the `user-agent` header.
|
|
12976
|
+
* If a `user-agent` header already exists, the suffix parts are appended to it.
|
|
12977
|
+
* If no `user-agent` header exists, a new one is created with the suffix parts.
|
|
12978
|
+
* Automatically removes undefined entries from the headers.
|
|
12979
|
+
*
|
|
12980
|
+
* @param headers - The original headers.
|
|
12981
|
+
* @param userAgentSuffixParts - The parts to append to the `user-agent` header.
|
|
12982
|
+
* @returns The new headers with the `user-agent` header set or updated.
|
|
12983
|
+
*/
|
|
12984
|
+
declare function withUserAgentSuffix(headers: HeadersInit | Record<string, string | undefined> | undefined, ...userAgentSuffixParts: string[]): Record<string, string>;
|
|
12985
|
+
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
|
12001
12986
|
/**
|
|
12002
12987
|
* Detects the `any` type so untyped tools can be treated as having no explicit
|
|
12003
12988
|
* context type.
|
|
@@ -12039,6 +13024,17 @@ type InferToolOutput<TOOL extends Tool<any, any, any>> = TOOL extends Tool<any,
|
|
|
12039
13024
|
* @yields A preliminary output for each streamed value, followed by a final output, or a single final
|
|
12040
13025
|
* output for non-streaming tools.
|
|
12041
13026
|
*/
|
|
13027
|
+
declare function executeTool<TOOL extends Tool>({ tool: tool$1, input, options }: {
|
|
13028
|
+
tool: ExecutableTool<TOOL>;
|
|
13029
|
+
input: InferToolInput<TOOL>;
|
|
13030
|
+
options: ToolExecutionOptions<InferToolContext<TOOL>>;
|
|
13031
|
+
}): AsyncGenerator<{
|
|
13032
|
+
type: 'preliminary';
|
|
13033
|
+
output: InferToolOutput<TOOL>;
|
|
13034
|
+
} | {
|
|
13035
|
+
type: 'final';
|
|
13036
|
+
output: InferToolOutput<TOOL>;
|
|
13037
|
+
}>;
|
|
12042
13038
|
/**
|
|
12043
13039
|
* A mapping of tool names to tool definitions.
|
|
12044
13040
|
*/
|
|
@@ -12047,17 +13043,17 @@ type ToolSet = Record<string, (Tool<never, never, any> | Tool<any, any, any> | T
|
|
|
12047
13043
|
* Builds the required portion of the tool context map for tools whose context
|
|
12048
13044
|
* type does not include `undefined`.
|
|
12049
13045
|
*/
|
|
12050
|
-
type RequiredToolSetContext<TOOLS extends ToolSet> = { [K in keyof TOOLS as InferToolContext<NoInfer<TOOLS[K]>> extends never ? never : undefined extends InferToolContext<NoInfer<TOOLS[K]>> ? never : K]: InferToolContext<NoInfer<TOOLS[K]
|
|
13046
|
+
type RequiredToolSetContext<TOOLS extends ToolSet> = { [K in keyof TOOLS as InferToolContext<NoInfer<TOOLS[K]>> extends never ? never : undefined extends InferToolContext<NoInfer<TOOLS[K]>> ? never : K]: InferToolContext<NoInfer<TOOLS[K]>>; };
|
|
12051
13047
|
/**
|
|
12052
13048
|
* Builds the optional portion of the tool context map for tools whose context
|
|
12053
13049
|
* object itself may be `undefined`.
|
|
12054
13050
|
*/
|
|
12055
|
-
type OptionalToolSetContext<TOOLS extends ToolSet> = { [K in keyof TOOLS as InferToolContext<NoInfer<TOOLS[K]>> extends never ? never : undefined extends InferToolContext<NoInfer<TOOLS[K]>> ? K : never]?: InferToolContext<NoInfer<TOOLS[K]
|
|
13051
|
+
type OptionalToolSetContext<TOOLS extends ToolSet> = { [K in keyof TOOLS as InferToolContext<NoInfer<TOOLS[K]>> extends never ? never : undefined extends InferToolContext<NoInfer<TOOLS[K]>> ? K : never]?: InferToolContext<NoInfer<TOOLS[K]>>; };
|
|
12056
13052
|
/**
|
|
12057
13053
|
* Flattens intersected mapped types so type equality assertions and editor
|
|
12058
13054
|
* hovers show the resulting object shape.
|
|
12059
13055
|
*/
|
|
12060
|
-
type Normalize<OBJECT> = { [KEY in keyof OBJECT]: OBJECT[KEY] };
|
|
13056
|
+
type Normalize<OBJECT> = { [KEY in keyof OBJECT]: OBJECT[KEY]; };
|
|
12061
13057
|
/**
|
|
12062
13058
|
* Infer the context type for a tool set.
|
|
12063
13059
|
*
|
|
@@ -12105,37 +13101,42 @@ type ToolCallerTool<TOOL extends Tool = Tool> = TOOL & {
|
|
|
12105
13101
|
readonly experimental_toolCaller: ToolCallerDefinition;
|
|
12106
13102
|
};
|
|
12107
13103
|
declare function toolCaller<TOOL extends Tool>(tool: TOOL, definition: ToolCallerDefinition): ToolCallerTool<TOOL>;
|
|
13104
|
+
declare function getToolCaller(tool: Tool | undefined): ToolCallerDefinition | undefined;
|
|
13105
|
+
/**
|
|
13106
|
+
* Typed tool result that is returned by `generateText` and `streamText`.
|
|
13107
|
+
* It contains the tool call ID, the tool name, the tool arguments, and the tool result.
|
|
13108
|
+
*/
|
|
13109
|
+
interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
13110
|
+
/**
|
|
13111
|
+
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
13112
|
+
*/
|
|
13113
|
+
toolCallId: string;
|
|
13114
|
+
/**
|
|
13115
|
+
* Name of the tool that was called.
|
|
13116
|
+
*/
|
|
13117
|
+
toolName: NAME;
|
|
13118
|
+
/**
|
|
13119
|
+
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
13120
|
+
*/
|
|
13121
|
+
input: INPUT;
|
|
13122
|
+
/**
|
|
13123
|
+
* Result of the tool call. This is the result of the tool's execution.
|
|
13124
|
+
*/
|
|
13125
|
+
output: OUTPUT;
|
|
13126
|
+
/**
|
|
13127
|
+
* Whether the tool result has been executed by the provider.
|
|
13128
|
+
*/
|
|
13129
|
+
providerExecuted?: boolean;
|
|
13130
|
+
/**
|
|
13131
|
+
* Whether the tool is dynamic.
|
|
13132
|
+
*/
|
|
13133
|
+
dynamic?: boolean;
|
|
13134
|
+
}
|
|
12108
13135
|
//#endregion
|
|
12109
13136
|
//#region ../../node_modules/.pnpm/@ai-sdk+gateway@4.0.52_zod@4.4.3/node_modules/@ai-sdk/gateway/dist/index.d.ts
|
|
12110
13137
|
type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/gemini-embedding-2' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | 'perplexity/pplx-embed-v1-0.6b' | 'perplexity/pplx-embed-v1-4b' | 'voyage/voyage-3-large' | 'voyage/voyage-3.5' | 'voyage/voyage-3.5-lite' | 'voyage/voyage-4' | 'voyage/voyage-4-large' | 'voyage/voyage-4-lite' | 'voyage/voyage-code-2' | 'voyage/voyage-code-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | (string & {});
|
|
12111
13138
|
type GatewayImageModelId = 'bfl/flux-2-flex' | 'bfl/flux-2-klein-4b' | 'bfl/flux-2-klein-9b' | 'bfl/flux-2-max' | 'bfl/flux-2-pro' | 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'bytedance/seedream-4.0' | 'bytedance/seedream-4.5' | 'bytedance/seedream-5.0-lite' | 'bytedance/seedream-5.0-pro' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'openai/gpt-image-1' | 'openai/gpt-image-1-mini' | 'openai/gpt-image-1.5' | 'openai/gpt-image-2' | 'prodia/flux-fast-schnell' | 'quiverai/arrow-1.1' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | 'recraft/recraft-v4' | 'recraft/recraft-v4-pro' | 'recraft/recraft-v4.1' | 'recraft/recraft-v4.1-pro' | 'recraft/recraft-v4.1-utility' | 'recraft/recraft-v4.1-utility-pro' | 'xai/grok-imagine-image' | 'xai/grok-imagine-image-2.0' | (string & {});
|
|
12112
13139
|
type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen-3.6-max-preview' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-235b-a22b-instruct' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'alibaba/qwen3.5-flash' | 'alibaba/qwen3.5-plus' | 'alibaba/qwen3.6-27b' | 'alibaba/qwen3.6-plus' | 'alibaba/qwen3.7-flash' | 'alibaba/qwen3.7-max' | 'alibaba/qwen3.7-plus' | 'alibaba/qwen3.8-max' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-fable-5' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-opus-4.6' | 'anthropic/claude-opus-4.7' | 'anthropic/claude-opus-4.8' | 'anthropic/claude-opus-4.8-fast' | 'anthropic/claude-opus-5' | 'anthropic/claude-opus-5-fast' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'anthropic/claude-sonnet-5' | 'arcee-ai/trinity-large-thinking' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-thinking' | 'deepseek/deepseek-v4-flash' | 'deepseek/deepseek-v4-flash-0731' | 'deepseek/deepseek-v4-pro' | 'deepseek/deepseek-v4-pro-0813' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3.1-flash-image' | 'google/gemini-3.1-flash-image-preview' | 'google/gemini-3.1-flash-lite' | 'google/gemini-3.1-flash-lite-image' | 'google/gemini-3.1-pro-preview' | 'google/gemini-3.5-flash' | 'google/gemini-3.5-flash-lite' | 'google/gemini-3.6-flash' | 'google/gemini-3.7-flash' | 'google/gemini-omni-flash-preview' | 'google/gemma-4-26b-a4b-it' | 'google/gemma-4-31b-it' | 'inception/mercury-2' | 'inception/mercury-coder-small' | 'inclusionai/ling-3.0-flash' | 'inclusionai/ling-3.0-tiny-free' | 'interfaze/interfaze-beta' | 'kwaipilot/kat-coder-air-v2.5' | 'kwaipilot/kat-coder-pro-v1' | 'kwaipilot/kat-coder-pro-v2' | 'kwaipilot/kat-coder-pro-v2.5' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'meta/muse-glimmer-30b' | 'meta/muse-spark-1.1' | 'meta/muse-spark-1.2' | 'meta/muse-spark-1.2-contributor' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'minimax/minimax-m2.5' | 'minimax/minimax-m2.5-highspeed' | 'minimax/minimax-m2.7' | 'minimax/minimax-m2.7-highspeed' | 'minimax/minimax-m3' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-medium-3.5' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/pixtral-12b' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2.5' | 'moonshotai/kimi-k2.6' | 'moonshotai/kimi-k2.7-code' | 'moonshotai/kimi-k2.7-code-highspeed' | 'moonshotai/kimi-k3' | 'moonshotai/kimi-k3-fast' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-3-super-120b-a12b' | 'nvidia/nemotron-3-ultra-550b-a55b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/gpt-3.5-turbo' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-search-preview' | 'openai/gpt-5' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-5.3-codex' | 'openai/gpt-5.4' | 'openai/gpt-5.4-mini' | 'openai/gpt-5.4-nano' | 'openai/gpt-5.4-pro' | 'openai/gpt-5.5' | 'openai/gpt-5.5-pro' | 'openai/gpt-5.6-luna' | 'openai/gpt-5.6-sol' | 'openai/gpt-5.6-terra' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning-pro' | 'poolside/laguna-s-2.1' | 'poolside/laguna-s-2.1-free' | 'sakana/fugu-ultra' | 'sakana/namazu' | 'stepfun/step-3.5-flash' | 'stepfun/step-3.7-flash' | 'tencent/hy3' | 'thinkingmachines/inkling' | 'thinkingmachines/inkling-small' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-4.20-multi-agent' | 'xai/grok-4.20-multi-agent-beta' | 'xai/grok-4.20-non-reasoning' | 'xai/grok-4.20-non-reasoning-beta' | 'xai/grok-4.20-reasoning' | 'xai/grok-4.20-reasoning-beta' | 'xai/grok-4.3' | 'xai/grok-4.5' | 'xai/grok-4.6' | 'xai/grok-build-0.1' | 'xiaomi/mimo-v2.5' | 'xiaomi/mimo-v2.5-pro' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flash' | 'zai/glm-4.7-flashx' | 'zai/glm-5' | 'zai/glm-5-turbo' | 'zai/glm-5.1' | 'zai/glm-5.2' | 'zai/glm-5.2-fast' | 'zai/glm-5v-turbo' | (string & {});
|
|
12113
|
-
/**
|
|
12114
|
-
* Shared WebSocket subprotocol contract for AI Gateway realtime and streaming
|
|
12115
|
-
* transcription auth.
|
|
12116
|
-
*
|
|
12117
|
-
* The browser `WebSocket` API cannot set request headers, so the Gateway auth
|
|
12118
|
-
* (bearer) token is carried through the `Sec-WebSocket-Protocol` handshake
|
|
12119
|
-
* instead of an `Authorization` header — the same workaround OpenAI uses for
|
|
12120
|
-
* `openai-insecure-api-key.<token>`.
|
|
12121
|
-
*
|
|
12122
|
-
* This module is the single source of truth for that contract so the client and
|
|
12123
|
-
* the Gateway server can't drift: the client encodes values with
|
|
12124
|
-
* `getGatewayRealtimeProtocols` / `getGatewayTranscriptionProtocols`, and the
|
|
12125
|
-
* Gateway server decodes them with `getGatewayRealtimeAuthToken` /
|
|
12126
|
-
* `getGatewayRealtimeTeamIdOrSlug`.
|
|
12127
|
-
*
|
|
12128
|
-
* WebSocket subprotocol values must fit the RFC token grammar. The auth token is
|
|
12129
|
-
* sent as-is, so callers must use tokens that are valid subprotocol tokens; the
|
|
12130
|
-
* optional team scope is base64url-encoded by this module. Keep the complete
|
|
12131
|
-
* `Sec-WebSocket-Protocol` header compact (target under an 8 KiB safe header
|
|
12132
|
-
* budget) because intermediaries may reject large upgrade headers.
|
|
12133
|
-
*/
|
|
12134
|
-
/**
|
|
12135
|
-
* Marker subprotocol offered on every realtime handshake so the Gateway can
|
|
12136
|
-
* echo a negotiated subprotocol on the 101 response (some clients require the
|
|
12137
|
-
* server to select one of the offered subprotocols).
|
|
12138
|
-
*/
|
|
12139
13140
|
type GatewayRerankingModelId = 'cohere/rerank-v3.5' | 'cohere/rerank-v4-fast' | 'cohere/rerank-v4-pro' | 'voyage/rerank-2.5' | 'voyage/rerank-2.5-lite' | (string & {});
|
|
12140
13141
|
type GatewaySpeechModelId = 'fish-audio/s1' | 'fish-audio/s2-pro' | 'fish-audio/s2.1-pro' | 'openai/tts-1' | 'openai/tts-1-hd' | 'xai/grok-tts' | (string & {});
|
|
12141
13142
|
type GatewayTranscriptionModelId = 'fish-audio/transcribe-1' | 'openai/gpt-4o-mini-transcribe' | 'openai/gpt-4o-transcribe' | 'openai/gpt-realtime-whisper' | 'openai/whisper-1' | 'xai/grok-stt' | (string & {});
|
|
@@ -12808,12 +13809,16 @@ interface GatewayProvider extends ProviderV4 {
|
|
|
12808
13809
|
tools: typeof gatewayTools;
|
|
12809
13810
|
}
|
|
12810
13811
|
type GatewayTranscriptionFactoryGetTokenOptions = {
|
|
12811
|
-
model: GatewayTranscriptionModelId;
|
|
13812
|
+
model: GatewayTranscriptionModelId;
|
|
13813
|
+
/** Token lifetime in seconds. Gateway default is 60s (max 300s). */
|
|
12812
13814
|
expiresAfterSeconds?: number;
|
|
12813
13815
|
};
|
|
12814
13816
|
type GatewayTranscriptionFactoryGetTokenResult = {
|
|
12815
|
-
/** The minted `vcst_` client secret. */
|
|
12816
|
-
|
|
13817
|
+
/** The minted `vcst_` client secret. */
|
|
13818
|
+
token: string;
|
|
13819
|
+
/** WebSocket URL of the streaming transcription surface for this model. */
|
|
13820
|
+
url: string;
|
|
13821
|
+
/** Token expiry, epoch seconds. */
|
|
12817
13822
|
expiresAt?: number;
|
|
12818
13823
|
};
|
|
12819
13824
|
/**
|
|
@@ -13258,13 +14263,21 @@ type LogWarningsFunction = (options: {
|
|
|
13258
14263
|
* Called when the operation begins, before the embedding model is called.
|
|
13259
14264
|
*/
|
|
13260
14265
|
type EmbedStartEvent = {
|
|
13261
|
-
/** Unique identifier for this embed call, used to correlate events. */
|
|
13262
|
-
readonly
|
|
13263
|
-
|
|
13264
|
-
readonly
|
|
13265
|
-
|
|
13266
|
-
readonly
|
|
13267
|
-
|
|
14266
|
+
/** Unique identifier for this embed call, used to correlate events. */
|
|
14267
|
+
readonly callId: string;
|
|
14268
|
+
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
14269
|
+
readonly operationId: string;
|
|
14270
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
14271
|
+
readonly provider: string;
|
|
14272
|
+
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
14273
|
+
readonly modelId: string;
|
|
14274
|
+
/** The value(s) being embedded. A string for embed, an array for embedMany. */
|
|
14275
|
+
readonly value: string | Array<string>;
|
|
14276
|
+
/** Maximum number of retries for failed requests. */
|
|
14277
|
+
readonly maxRetries: number;
|
|
14278
|
+
/** Additional HTTP headers sent with the request. */
|
|
14279
|
+
readonly headers: Record<string, string | undefined> | undefined;
|
|
14280
|
+
/** Additional provider-specific options. */
|
|
13268
14281
|
readonly providerOptions: ProviderOptions | undefined;
|
|
13269
14282
|
};
|
|
13270
14283
|
/**
|
|
@@ -13273,15 +14286,25 @@ type EmbedStartEvent = {
|
|
|
13273
14286
|
* Called when the operation completes, after the embedding model returns.
|
|
13274
14287
|
*/
|
|
13275
14288
|
type EmbedEndEvent = {
|
|
13276
|
-
/** Unique identifier for this embed call, used to correlate events. */
|
|
13277
|
-
readonly
|
|
13278
|
-
|
|
13279
|
-
readonly
|
|
13280
|
-
|
|
13281
|
-
readonly
|
|
13282
|
-
|
|
13283
|
-
readonly
|
|
13284
|
-
|
|
14289
|
+
/** Unique identifier for this embed call, used to correlate events. */
|
|
14290
|
+
readonly callId: string;
|
|
14291
|
+
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
14292
|
+
readonly operationId: string;
|
|
14293
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
14294
|
+
readonly provider: string;
|
|
14295
|
+
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
14296
|
+
readonly modelId: string;
|
|
14297
|
+
/** The value(s) that were embedded. A string for embed, an array for embedMany. */
|
|
14298
|
+
readonly value: string | Array<string>;
|
|
14299
|
+
/** The resulting embedding(s). A single vector for embed, an array for embedMany. */
|
|
14300
|
+
readonly embedding: Embedding | Array<Embedding>;
|
|
14301
|
+
/** Token usage for the embedding operation. */
|
|
14302
|
+
readonly usage: EmbeddingModelUsage;
|
|
14303
|
+
/** Warnings from the embedding model, e.g. unsupported settings. */
|
|
14304
|
+
readonly warnings: Array<Warning>;
|
|
14305
|
+
/** Optional provider-specific metadata. */
|
|
14306
|
+
readonly providerMetadata: ProviderMetadata | undefined;
|
|
14307
|
+
/** Response data including headers and body. A single response for embed, an array for embedMany. */
|
|
13285
14308
|
readonly response: {
|
|
13286
14309
|
headers?: Record<string, string>;
|
|
13287
14310
|
body?: unknown;
|
|
@@ -13297,11 +14320,17 @@ type EmbedEndEvent = {
|
|
|
13297
14320
|
* calls when values are chunked.
|
|
13298
14321
|
*/
|
|
13299
14322
|
type EmbeddingModelCallStartEvent = {
|
|
13300
|
-
/** Unique identifier for this embed call, used to correlate events. */
|
|
13301
|
-
readonly
|
|
13302
|
-
|
|
13303
|
-
readonly
|
|
13304
|
-
|
|
14323
|
+
/** Unique identifier for this embed call, used to correlate events. */
|
|
14324
|
+
readonly callId: string;
|
|
14325
|
+
/** Unique identifier for this individual doEmbed invocation, used to correlate start/finish within parallel chunks. */
|
|
14326
|
+
readonly embedCallId: string;
|
|
14327
|
+
/** Identifies the inner operation (e.g. 'ai.embed.doEmbed' or 'ai.embedMany.doEmbed'). */
|
|
14328
|
+
readonly operationId: string;
|
|
14329
|
+
/** The provider identifier. */
|
|
14330
|
+
readonly provider: string;
|
|
14331
|
+
/** The specific model identifier. */
|
|
14332
|
+
readonly modelId: string;
|
|
14333
|
+
/** The values being embedded in this particular model call. */
|
|
13305
14334
|
readonly values: Array<string>;
|
|
13306
14335
|
};
|
|
13307
14336
|
/**
|
|
@@ -13310,13 +14339,21 @@ type EmbeddingModelCallStartEvent = {
|
|
|
13310
14339
|
* Contains the embeddings, usage, and any warnings from the model response.
|
|
13311
14340
|
*/
|
|
13312
14341
|
type EmbeddingModelCallEndEvent = {
|
|
13313
|
-
/** Unique identifier for this embed call, used to correlate events. */
|
|
13314
|
-
readonly
|
|
13315
|
-
|
|
13316
|
-
readonly
|
|
13317
|
-
|
|
13318
|
-
readonly
|
|
13319
|
-
|
|
14342
|
+
/** Unique identifier for this embed call, used to correlate events. */
|
|
14343
|
+
readonly callId: string;
|
|
14344
|
+
/** Unique identifier for this individual doEmbed invocation, used to correlate start/finish within parallel chunks. */
|
|
14345
|
+
readonly embedCallId: string;
|
|
14346
|
+
/** Identifies the inner operation (e.g. 'ai.embed.doEmbed' or 'ai.embedMany.doEmbed'). */
|
|
14347
|
+
readonly operationId: string;
|
|
14348
|
+
/** The provider identifier. */
|
|
14349
|
+
readonly provider: string;
|
|
14350
|
+
/** The specific model identifier. */
|
|
14351
|
+
readonly modelId: string;
|
|
14352
|
+
/** The values that were embedded in this particular model call. */
|
|
14353
|
+
readonly values: Array<string>;
|
|
14354
|
+
/** The resulting embeddings from the model call. */
|
|
14355
|
+
readonly embeddings: Array<Embedding>;
|
|
14356
|
+
/** Token usage for this model call. */
|
|
13320
14357
|
readonly usage: EmbeddingModelUsage;
|
|
13321
14358
|
};
|
|
13322
14359
|
/**
|
|
@@ -13718,9 +14755,9 @@ type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, Dee
|
|
|
13718
14755
|
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
|
13719
14756
|
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
13720
14757
|
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
|
13721
|
-
type PartialObject<ObjectType extends object> = { [KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]
|
|
13722
|
-
type IncludedContext<CONTEXT extends Context$1 | unknown | never> = { [KEY in keyof NoInfer<CONTEXT>]?: boolean } | undefined;
|
|
13723
|
-
type IncludedToolsContext<TOOLS extends ToolSet> = { [TOOL_NAME in keyof NoInfer<InferToolSetContext<TOOLS>>]?: IncludedContext<NoInfer<InferToolSetContext<TOOLS>[TOOL_NAME]
|
|
14758
|
+
type PartialObject<ObjectType extends object> = { [KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>; };
|
|
14759
|
+
type IncludedContext<CONTEXT extends Context$1 | unknown | never> = { [KEY in keyof NoInfer<CONTEXT>]?: boolean; } | undefined;
|
|
14760
|
+
type IncludedToolsContext<TOOLS extends ToolSet> = { [TOOL_NAME in keyof NoInfer<InferToolSetContext<TOOLS>>]?: IncludedContext<NoInfer<InferToolSetContext<TOOLS>[TOOL_NAME]>>; } | undefined;
|
|
13724
14761
|
/**
|
|
13725
14762
|
* Telemetry configuration.
|
|
13726
14763
|
*/
|
|
@@ -13819,10 +14856,7 @@ declare class DefaultGeneratedFile implements GeneratedFile {
|
|
|
13819
14856
|
private base64Data;
|
|
13820
14857
|
private uint8ArrayData;
|
|
13821
14858
|
readonly mediaType: string;
|
|
13822
|
-
constructor({
|
|
13823
|
-
data,
|
|
13824
|
-
mediaType
|
|
13825
|
-
}: {
|
|
14859
|
+
constructor({ data, mediaType }: {
|
|
13826
14860
|
data: string | Uint8Array;
|
|
13827
14861
|
mediaType: string;
|
|
13828
14862
|
});
|
|
@@ -13921,7 +14955,7 @@ type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]: Ba
|
|
|
13921
14955
|
invalid?: false | undefined;
|
|
13922
14956
|
error?: never;
|
|
13923
14957
|
title?: string;
|
|
13924
|
-
} }>;
|
|
14958
|
+
}; }>;
|
|
13925
14959
|
/**
|
|
13926
14960
|
* A tool call whose `toolName` is only known at runtime, such as an invalid
|
|
13927
14961
|
* or otherwise untyped call that cannot be matched to the declared tool set.
|
|
@@ -14010,7 +15044,7 @@ type StaticToolError<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]: {
|
|
|
14010
15044
|
toolMetadata?: JSONObject$2;
|
|
14011
15045
|
dynamic?: false | undefined;
|
|
14012
15046
|
title?: string;
|
|
14013
|
-
} }>;
|
|
15047
|
+
}; }>;
|
|
14014
15048
|
type DynamicToolError = {
|
|
14015
15049
|
type: 'tool-error';
|
|
14016
15050
|
toolCallId: string;
|
|
@@ -14036,7 +15070,7 @@ type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]:
|
|
|
14036
15070
|
dynamic?: false | undefined;
|
|
14037
15071
|
preliminary?: boolean;
|
|
14038
15072
|
title?: string;
|
|
14039
|
-
} }>;
|
|
15073
|
+
}; }>;
|
|
14040
15074
|
type DynamicToolResult = {
|
|
14041
15075
|
type: 'tool-result';
|
|
14042
15076
|
toolCallId: string;
|
|
@@ -14082,11 +15116,17 @@ type ContentPart<TOOLS extends ToolSet> = {
|
|
|
14082
15116
|
* Timing statistics for the gaps between generated output chunks.
|
|
14083
15117
|
*/
|
|
14084
15118
|
type OutputChunkTimingStats = {
|
|
14085
|
-
/** Shortest observed time between output chunks in milliseconds. */
|
|
14086
|
-
readonly
|
|
14087
|
-
|
|
14088
|
-
readonly
|
|
14089
|
-
|
|
15119
|
+
/** Shortest observed time between output chunks in milliseconds. */
|
|
15120
|
+
readonly min: number;
|
|
15121
|
+
/** 10th percentile time between output chunks in milliseconds. */
|
|
15122
|
+
readonly p10: number;
|
|
15123
|
+
/** Median time between output chunks in milliseconds. */
|
|
15124
|
+
readonly median: number;
|
|
15125
|
+
/** Average time between output chunks in milliseconds. */
|
|
15126
|
+
readonly avg: number;
|
|
15127
|
+
/** 90th percentile time between output chunks in milliseconds. */
|
|
15128
|
+
readonly p90: number;
|
|
15129
|
+
/** Longest observed time between output chunks in milliseconds. */
|
|
14090
15130
|
readonly max: number;
|
|
14091
15131
|
};
|
|
14092
15132
|
/**
|
|
@@ -14172,7 +15212,9 @@ type StepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context$1 = Conte
|
|
|
14172
15212
|
* Information about the model that produced this step.
|
|
14173
15213
|
*/
|
|
14174
15214
|
readonly model: {
|
|
14175
|
-
/** The provider of the model. */
|
|
15215
|
+
/** The provider of the model. */
|
|
15216
|
+
readonly provider: string;
|
|
15217
|
+
/** The ID of the model. */
|
|
14176
15218
|
readonly modelId: string;
|
|
14177
15219
|
};
|
|
14178
15220
|
/**
|
|
@@ -14274,7 +15316,9 @@ type StepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context$1 = Conte
|
|
|
14274
15316
|
* Common model information used across callback events.
|
|
14275
15317
|
*/
|
|
14276
15318
|
type ModelInfo = {
|
|
14277
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
15319
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
15320
|
+
readonly provider: string;
|
|
15321
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
14278
15322
|
readonly modelId: string;
|
|
14279
15323
|
};
|
|
14280
15324
|
/**
|
|
@@ -14284,7 +15328,9 @@ type ModelInfo = {
|
|
|
14284
15328
|
* Unlike `onStepStart`, this only represents model invocation work.
|
|
14285
15329
|
*/
|
|
14286
15330
|
type LanguageModelCallStartEvent = ModelInfo & {
|
|
14287
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
15331
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
15332
|
+
readonly callId: string;
|
|
15333
|
+
/** Prepared tool definitions for the model call, if any. */
|
|
14288
15334
|
readonly tools: ReadonlyArray<Record<string, unknown>> | undefined;
|
|
14289
15335
|
} & StandardizedPrompt & LanguageModelCallOptions;
|
|
14290
15336
|
/**
|
|
@@ -14294,14 +15340,22 @@ type LanguageModelCallStartEvent = ModelInfo & {
|
|
|
14294
15340
|
* any client-side tool execution begins.
|
|
14295
15341
|
*/
|
|
14296
15342
|
type LanguageModelCallEndEvent<TOOLS extends ToolSet = ToolSet> = ModelInfo & {
|
|
14297
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
14298
|
-
readonly
|
|
14299
|
-
|
|
14300
|
-
readonly
|
|
14301
|
-
|
|
14302
|
-
readonly
|
|
15343
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
15344
|
+
readonly callId: string;
|
|
15345
|
+
/** The unified reason why the model call finished. */
|
|
15346
|
+
readonly finishReason: FinishReason;
|
|
15347
|
+
/** The token usage reported by the model call. */
|
|
15348
|
+
readonly usage: LanguageModelUsage;
|
|
15349
|
+
/** The content parts produced by the model call. */
|
|
15350
|
+
readonly content: ReadonlyArray<ContentPart<TOOLS>>;
|
|
15351
|
+
/** The provider-returned response id for this model call. */
|
|
15352
|
+
readonly responseId: string;
|
|
15353
|
+
/** Optional provider-specific metadata for this model call. */
|
|
15354
|
+
readonly providerMetadata?: ProviderMetadata;
|
|
15355
|
+
/** Performance metrics for the model call. */
|
|
14303
15356
|
readonly performance: {
|
|
14304
|
-
/** Time spent waiting for the language model response in milliseconds. */
|
|
15357
|
+
/** Time spent waiting for the language model response in milliseconds. */
|
|
15358
|
+
readonly responseTimeMs: number;
|
|
14305
15359
|
/**
|
|
14306
15360
|
* Effective number of output tokens per second over the full language
|
|
14307
15361
|
* model response.
|
|
@@ -14556,7 +15610,7 @@ type InferUITool<TOOL extends Tool> = {
|
|
|
14556
15610
|
/**
|
|
14557
15611
|
* Infer the input and output types of a tool set so it can be used as a UI tool set.
|
|
14558
15612
|
*/
|
|
14559
|
-
type InferUITools<TOOLS extends ToolSet> = { [NAME in keyof TOOLS & string]: InferUITool<TOOLS[NAME]
|
|
15613
|
+
type InferUITools<TOOLS extends ToolSet> = { [NAME in keyof TOOLS & string]: InferUITool<TOOLS[NAME]>; };
|
|
14560
15614
|
type UITools = Record<string, UITool>;
|
|
14561
15615
|
/**
|
|
14562
15616
|
* AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
|
|
@@ -14731,7 +15785,7 @@ type DataUIPart<DATA_TYPES extends UIDataTypes> = ValueOf<{ [NAME in keyof DATA_
|
|
|
14731
15785
|
type: `data-${NAME}`;
|
|
14732
15786
|
id?: string;
|
|
14733
15787
|
data: DATA_TYPES[NAME];
|
|
14734
|
-
} }>;
|
|
15788
|
+
}; }>;
|
|
14735
15789
|
type asUITool<TOOL extends UITool | Tool> = TOOL extends Tool ? InferUITool<TOOL> : TOOL;
|
|
14736
15790
|
/**
|
|
14737
15791
|
* Check if a message part is a data part.
|
|
@@ -14839,7 +15893,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
14839
15893
|
});
|
|
14840
15894
|
type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{ [NAME in keyof TOOLS & string]: {
|
|
14841
15895
|
type: `tool-${NAME}`;
|
|
14842
|
-
} & UIToolInvocation<TOOLS[NAME]
|
|
15896
|
+
} & UIToolInvocation<TOOLS[NAME]>; }>;
|
|
14843
15897
|
type DynamicToolUIPart = {
|
|
14844
15898
|
type: 'dynamic-tool';
|
|
14845
15899
|
/**
|
|
@@ -15003,7 +16057,7 @@ type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{ [NAME in k
|
|
|
15003
16057
|
input: infer INPUT;
|
|
15004
16058
|
} ? INPUT : never> & {
|
|
15005
16059
|
dynamic?: false;
|
|
15006
|
-
} }> | (ToolCall<string, unknown> & {
|
|
16060
|
+
}; }> | (ToolCall<string, unknown> & {
|
|
15007
16061
|
dynamic: true;
|
|
15008
16062
|
});
|
|
15009
16063
|
declare const uiMessageChunkSchema: LazySchema<UIMessageChunk<unknown, UIDataTypes>>;
|
|
@@ -15012,7 +16066,7 @@ type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{ [NAME in key
|
|
|
15012
16066
|
id?: string;
|
|
15013
16067
|
data: DATA_TYPES[NAME];
|
|
15014
16068
|
transient?: boolean;
|
|
15015
|
-
} }>;
|
|
16069
|
+
}; }>;
|
|
15016
16070
|
type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataTypes> = {
|
|
15017
16071
|
type: 'text-start';
|
|
15018
16072
|
id: string;
|
|
@@ -15221,7 +16275,7 @@ type StaticToolOutputDenied<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TO
|
|
|
15221
16275
|
toolName: NAME & string;
|
|
15222
16276
|
providerExecuted?: boolean;
|
|
15223
16277
|
dynamic?: false | undefined;
|
|
15224
|
-
} }>;
|
|
16278
|
+
}; }>;
|
|
15225
16279
|
/**
|
|
15226
16280
|
* Tool output when the tool execution has been denied.
|
|
15227
16281
|
*/
|
|
@@ -15748,20 +16802,15 @@ type GenericToolApprovalFunction<TOOLS extends ToolSet, TOOLS_CONTEXT extends In
|
|
|
15748
16802
|
*
|
|
15749
16803
|
* In addition to the string statuses, you can also use object statuses with a reason property.
|
|
15750
16804
|
*/
|
|
15751
|
-
type ToolApprovalConfiguration<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context$1 | unknown | never> = GenericToolApprovalFunction<TOOLS, InferToolSetContext<TOOLS>, RUNTIME_CONTEXT> | { [key in keyof TOOLS]?: ToolApprovalStatus | SingleToolApprovalFunction<InferToolInput<TOOLS[key]>, InferToolContext<TOOLS[key]>, RUNTIME_CONTEXT
|
|
15752
|
-
type ToolCallerName<TOOLS extends ToolSet> = { [NAME in keyof TOOLS]: TOOLS[NAME] extends ToolCallerTool ? NAME : never }[keyof TOOLS] & string;
|
|
15753
|
-
type Experimental_ToolCallers<TOOLS extends ToolSet> = { [NAME in keyof TOOLS]?: ReadonlyArray<'AI_SDK_DIRECT_TOOL_CALL' | ToolCallerName<TOOLS
|
|
16805
|
+
type ToolApprovalConfiguration<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context$1 | unknown | never> = GenericToolApprovalFunction<TOOLS, InferToolSetContext<TOOLS>, RUNTIME_CONTEXT> | { [key in keyof TOOLS]?: ToolApprovalStatus | SingleToolApprovalFunction<InferToolInput<TOOLS[key]>, InferToolContext<TOOLS[key]>, RUNTIME_CONTEXT>; };
|
|
16806
|
+
type ToolCallerName<TOOLS extends ToolSet> = { [NAME in keyof TOOLS]: TOOLS[NAME] extends ToolCallerTool ? NAME : never; }[keyof TOOLS] & string;
|
|
16807
|
+
type Experimental_ToolCallers<TOOLS extends ToolSet> = { [NAME in keyof TOOLS]?: ReadonlyArray<'AI_SDK_DIRECT_TOOL_CALL' | ToolCallerName<TOOLS>>; };
|
|
15754
16808
|
declare const symbol$l: unique symbol;
|
|
15755
16809
|
declare class InvalidToolInputError extends AISDKError {
|
|
15756
16810
|
private readonly [symbol$l];
|
|
15757
16811
|
readonly toolName: string;
|
|
15758
16812
|
readonly toolInput: string;
|
|
15759
|
-
constructor({
|
|
15760
|
-
toolInput,
|
|
15761
|
-
toolName,
|
|
15762
|
-
cause,
|
|
15763
|
-
message
|
|
15764
|
-
}: {
|
|
16813
|
+
constructor({ toolInput, toolName, cause, message }: {
|
|
15765
16814
|
message?: string;
|
|
15766
16815
|
toolInput: string;
|
|
15767
16816
|
toolName: string;
|
|
@@ -15774,11 +16823,7 @@ declare class NoSuchToolError extends AISDKError {
|
|
|
15774
16823
|
private readonly [symbol$k];
|
|
15775
16824
|
readonly toolName: string;
|
|
15776
16825
|
readonly availableTools: string[] | undefined;
|
|
15777
|
-
constructor({
|
|
15778
|
-
toolName,
|
|
15779
|
-
availableTools,
|
|
15780
|
-
message
|
|
15781
|
-
}: {
|
|
16826
|
+
constructor({ toolName, availableTools, message }: {
|
|
15782
16827
|
toolName: string;
|
|
15783
16828
|
availableTools?: string[] | undefined;
|
|
15784
16829
|
message?: string;
|
|
@@ -15820,7 +16865,8 @@ type ToolOutput<TOOLS extends ToolSet> = TypedToolResult<TOOLS> | TypedToolError
|
|
|
15820
16865
|
*/
|
|
15821
16866
|
type ToolContextFor<TOOL extends ToolSet[keyof ToolSet]> = [InferToolContext<TOOL>] extends [never] ? undefined : InferToolContext<TOOL>;
|
|
15822
16867
|
type BaseToolExecutionStartFields = {
|
|
15823
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
16868
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
16869
|
+
readonly callId: string;
|
|
15824
16870
|
/**
|
|
15825
16871
|
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
|
15826
16872
|
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
|
@@ -15838,7 +16884,7 @@ type StaticToolExecutionStartEvent<TOOLS extends ToolSet> = ValueOf<{ [NAME in k
|
|
|
15838
16884
|
toolName: NAME;
|
|
15839
16885
|
}>;
|
|
15840
16886
|
readonly toolContext: ToolContextFor<TOOLS[NAME]>;
|
|
15841
|
-
} }>;
|
|
16887
|
+
}; }>;
|
|
15842
16888
|
/**
|
|
15843
16889
|
* Start event shape for dynamic or untyped tool calls.
|
|
15844
16890
|
*/
|
|
@@ -15863,7 +16909,9 @@ type WidenedToolExecutionStartEvent = BaseToolExecutionStartFields & {
|
|
|
15863
16909
|
*/
|
|
15864
16910
|
type ToolExecutionStartEvent<TOOLS extends ToolSet = ToolSet> = [ToolSet] extends [TOOLS] ? WidenedToolExecutionStartEvent : StaticToolExecutionStartEvent<TOOLS> | DynamicToolExecutionStartEvent;
|
|
15865
16911
|
type BaseToolExecutionEndFields = {
|
|
15866
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
16912
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
16913
|
+
readonly callId: string;
|
|
16914
|
+
/** Execution time of the tool call in milliseconds. */
|
|
15867
16915
|
readonly toolExecutionMs: number;
|
|
15868
16916
|
/**
|
|
15869
16917
|
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
|
@@ -15883,7 +16931,7 @@ type StaticToolExecutionEndEvent<TOOLS extends ToolSet> = ValueOf<{ [NAME in key
|
|
|
15883
16931
|
}>;
|
|
15884
16932
|
readonly toolContext: ToolContextFor<TOOLS[NAME]>;
|
|
15885
16933
|
readonly toolOutput: ToolOutput<TOOLS>;
|
|
15886
|
-
} }>;
|
|
16934
|
+
}; }>;
|
|
15887
16935
|
/**
|
|
15888
16936
|
* End event shape for dynamic or untyped tool calls.
|
|
15889
16937
|
*/
|
|
@@ -15943,7 +16991,7 @@ type OnToolCallFinishEvent<TOOLS extends ToolSet = ToolSet> = ToolExecutionEndEv
|
|
|
15943
16991
|
* an input with the same type shape. Refined inputs are used for tool execution,
|
|
15944
16992
|
* output parts, lifecycle callbacks, and telemetry.
|
|
15945
16993
|
*/
|
|
15946
|
-
type ToolInputRefinement<TOOLS extends ToolSet> = { [NAME in keyof TOOLS]?: (input: InferToolInput<TOOLS[NAME]>) => MaybePromiseLike<InferToolInput<TOOLS[NAME]
|
|
16994
|
+
type ToolInputRefinement<TOOLS extends ToolSet> = { [NAME in keyof TOOLS]?: (input: InferToolInput<TOOLS[NAME]>) => MaybePromiseLike<InferToolInput<TOOLS[NAME]>>; };
|
|
15947
16995
|
/**
|
|
15948
16996
|
* Checks whether a tool context map contains any contextual tool entries.
|
|
15949
16997
|
*/
|
|
@@ -16092,67 +17140,7 @@ type StreamTextOnAbortCallback<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Co
|
|
|
16092
17140
|
* @returns
|
|
16093
17141
|
* A result object for accessing different stream types and additional information.
|
|
16094
17142
|
*/
|
|
16095
|
-
declare function streamText<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = Output<string, string, never>>({
|
|
16096
|
-
model,
|
|
16097
|
-
tools,
|
|
16098
|
-
toolChoice,
|
|
16099
|
-
instructions,
|
|
16100
|
-
system,
|
|
16101
|
-
prompt,
|
|
16102
|
-
messages,
|
|
16103
|
-
allowSystemInMessages,
|
|
16104
|
-
maxRetries,
|
|
16105
|
-
abortSignal,
|
|
16106
|
-
timeout,
|
|
16107
|
-
headers,
|
|
16108
|
-
stopWhen,
|
|
16109
|
-
experimental_sandbox: sandbox,
|
|
16110
|
-
output,
|
|
16111
|
-
toolApproval,
|
|
16112
|
-
experimental_toolCallers,
|
|
16113
|
-
experimental_toolApprovalSecret,
|
|
16114
|
-
experimental_telemetry,
|
|
16115
|
-
telemetry,
|
|
16116
|
-
prepareStep,
|
|
16117
|
-
providerOptions,
|
|
16118
|
-
activeTools,
|
|
16119
|
-
toolOrder,
|
|
16120
|
-
experimental_repairToolCall,
|
|
16121
|
-
repairToolCall,
|
|
16122
|
-
experimental_refineToolInput: refineToolInput,
|
|
16123
|
-
experimental_transform: transform,
|
|
16124
|
-
experimental_download: download,
|
|
16125
|
-
includeRawChunks,
|
|
16126
|
-
onChunk,
|
|
16127
|
-
onError,
|
|
16128
|
-
onFinish,
|
|
16129
|
-
onEnd,
|
|
16130
|
-
onAbort,
|
|
16131
|
-
onStepEnd,
|
|
16132
|
-
onStepFinish,
|
|
16133
|
-
onStart,
|
|
16134
|
-
experimental_onStart,
|
|
16135
|
-
onStepStart,
|
|
16136
|
-
experimental_onStepStart,
|
|
16137
|
-
onLanguageModelCallStart,
|
|
16138
|
-
experimental_onLanguageModelCallStart,
|
|
16139
|
-
onLanguageModelCallEnd,
|
|
16140
|
-
experimental_onLanguageModelCallEnd,
|
|
16141
|
-
onToolExecutionStart,
|
|
16142
|
-
onToolExecutionEnd,
|
|
16143
|
-
experimental_onToolCallStart,
|
|
16144
|
-
experimental_onToolCallFinish,
|
|
16145
|
-
runtimeContext,
|
|
16146
|
-
toolsContext,
|
|
16147
|
-
experimental_include,
|
|
16148
|
-
include,
|
|
16149
|
-
_internal: {
|
|
16150
|
-
now,
|
|
16151
|
-
generateId,
|
|
16152
|
-
generateCallId
|
|
16153
|
-
},
|
|
16154
|
-
...settings
|
|
16155
|
-
}: LanguageModelCallOptions & RequestOptions<TOOLS> & Prompt & ToolsContextParameter<TOOLS> & {
|
|
17143
|
+
declare function streamText<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, instructions, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_sandbox: sandbox, output, toolApproval, experimental_toolCallers, experimental_toolApprovalSecret, experimental_telemetry, telemetry, prepareStep, providerOptions, activeTools, toolOrder, experimental_repairToolCall, repairToolCall, experimental_refineToolInput: refineToolInput, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onEnd, onAbort, onStepEnd, onStepFinish, onStart, experimental_onStart, onStepStart, experimental_onStepStart, onLanguageModelCallStart, experimental_onLanguageModelCallStart, onLanguageModelCallEnd, experimental_onLanguageModelCallEnd, onToolExecutionStart, onToolExecutionEnd, experimental_onToolCallStart, experimental_onToolCallFinish, runtimeContext, toolsContext, experimental_include, include, _internal: { now, generateId, generateCallId }, ...settings }: LanguageModelCallOptions & RequestOptions<TOOLS> & Prompt & ToolsContextParameter<TOOLS> & {
|
|
16156
17144
|
/**
|
|
16157
17145
|
* The language model to use.
|
|
16158
17146
|
*/
|
|
@@ -16456,11 +17444,7 @@ declare const text$1: () => Output<string, string, never>;
|
|
|
16456
17444
|
*
|
|
16457
17445
|
* @returns An output specification for generating objects with the specified schema.
|
|
16458
17446
|
*/
|
|
16459
|
-
declare const object: <OBJECT>({
|
|
16460
|
-
schema: inputSchema,
|
|
16461
|
-
name,
|
|
16462
|
-
description
|
|
16463
|
-
}: {
|
|
17447
|
+
declare const object: <OBJECT>({ schema: inputSchema, name, description }: {
|
|
16464
17448
|
schema: FlexibleSchema<OBJECT>;
|
|
16465
17449
|
/**
|
|
16466
17450
|
* Optional name of the output that should be generated.
|
|
@@ -16483,11 +17467,7 @@ declare const object: <OBJECT>({
|
|
|
16483
17467
|
*
|
|
16484
17468
|
* @returns An output specification for generating an array of elements.
|
|
16485
17469
|
*/
|
|
16486
|
-
declare const array: <ELEMENT>({
|
|
16487
|
-
element: inputElementSchema,
|
|
16488
|
-
name,
|
|
16489
|
-
description
|
|
16490
|
-
}: {
|
|
17470
|
+
declare const array: <ELEMENT>({ element: inputElementSchema, name, description }: {
|
|
16491
17471
|
element: FlexibleSchema<ELEMENT>;
|
|
16492
17472
|
/**
|
|
16493
17473
|
* Optional name of the output that should be generated.
|
|
@@ -16510,11 +17490,7 @@ declare const array: <ELEMENT>({
|
|
|
16510
17490
|
*
|
|
16511
17491
|
* @returns An output specification for generating a choice.
|
|
16512
17492
|
*/
|
|
16513
|
-
declare const choice: <CHOICE extends string>({
|
|
16514
|
-
options: choiceOptions,
|
|
16515
|
-
name,
|
|
16516
|
-
description
|
|
16517
|
-
}: {
|
|
17493
|
+
declare const choice: <CHOICE extends string>({ options: choiceOptions, name, description }: {
|
|
16518
17494
|
options: Array<CHOICE>;
|
|
16519
17495
|
/**
|
|
16520
17496
|
* Optional name of the output that should be generated.
|
|
@@ -16536,10 +17512,7 @@ declare const choice: <CHOICE extends string>({
|
|
|
16536
17512
|
*
|
|
16537
17513
|
* @returns An output specification for generating JSON.
|
|
16538
17514
|
*/
|
|
16539
|
-
declare const json: ({
|
|
16540
|
-
name,
|
|
16541
|
-
description
|
|
16542
|
-
}?: {
|
|
17515
|
+
declare const json: ({ name, description }?: {
|
|
16543
17516
|
/**
|
|
16544
17517
|
* Optional name of the output that should be generated.
|
|
16545
17518
|
* Used by some providers for additional LLM guidance, e.g. via tool or schema name.
|
|
@@ -16566,23 +17539,35 @@ declare namespace output {
|
|
|
16566
17539
|
* Called when the generation operation begins, before any LLM calls.
|
|
16567
17540
|
*/
|
|
16568
17541
|
type GenerateTextStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = Output> = {
|
|
16569
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
16570
|
-
readonly
|
|
16571
|
-
|
|
16572
|
-
readonly
|
|
16573
|
-
|
|
16574
|
-
readonly
|
|
16575
|
-
|
|
16576
|
-
readonly
|
|
17542
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
17543
|
+
readonly callId: string;
|
|
17544
|
+
/** Identifies the operation type (e.g. 'ai.generateText' or 'ai.streamText'). */
|
|
17545
|
+
readonly operationId: string;
|
|
17546
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
17547
|
+
readonly provider: string;
|
|
17548
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
17549
|
+
readonly modelId: string;
|
|
17550
|
+
/** The tools available for this generation. */
|
|
17551
|
+
readonly tools: TOOLS | undefined;
|
|
17552
|
+
/** The tool choice strategy for this generation. */
|
|
17553
|
+
readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
|
|
17554
|
+
/** Limits which tools are available for the model to call. */
|
|
17555
|
+
readonly activeTools: ActiveTools<TOOLS>;
|
|
17556
|
+
/** Controls the order in which tools are sent to the provider. */
|
|
17557
|
+
readonly toolOrder: ToolOrder<TOOLS>;
|
|
17558
|
+
/** Maximum number of retries for failed requests. */
|
|
16577
17559
|
readonly maxRetries: number;
|
|
16578
17560
|
/**
|
|
16579
17561
|
* Timeout configuration for the generation.
|
|
16580
17562
|
* Can be a number (milliseconds) or an object with totalMs, stepMs,
|
|
16581
17563
|
* firstChunkMs (streaming only), chunkMs, toolMs, and per-tool overrides via tools.
|
|
16582
17564
|
*/
|
|
16583
|
-
readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
|
|
16584
|
-
|
|
16585
|
-
readonly
|
|
17565
|
+
readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
|
|
17566
|
+
/** Additional HTTP headers sent with the request. */
|
|
17567
|
+
readonly headers: Record<string, string | undefined> | undefined;
|
|
17568
|
+
/** Additional provider-specific options. */
|
|
17569
|
+
readonly providerOptions: ProviderOptions | undefined;
|
|
17570
|
+
/** The output specification for structured outputs, if configured. */
|
|
16586
17571
|
readonly output: OUTPUT | undefined;
|
|
16587
17572
|
/**
|
|
16588
17573
|
* Tool context.
|
|
@@ -16600,16 +17585,27 @@ type GenerateTextStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT ext
|
|
|
16600
17585
|
* Each step represents a single LLM invocation.
|
|
16601
17586
|
*/
|
|
16602
17587
|
type GenerateTextStepStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = Output> = {
|
|
16603
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
16604
|
-
readonly
|
|
16605
|
-
|
|
16606
|
-
readonly
|
|
16607
|
-
|
|
16608
|
-
readonly
|
|
16609
|
-
|
|
16610
|
-
readonly
|
|
16611
|
-
|
|
16612
|
-
readonly
|
|
17588
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
17589
|
+
readonly callId: string;
|
|
17590
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
17591
|
+
readonly provider: string;
|
|
17592
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
17593
|
+
readonly modelId: string;
|
|
17594
|
+
/** Zero-based index of the current step. */
|
|
17595
|
+
readonly stepNumber: number;
|
|
17596
|
+
/** The tools available for this generation. */
|
|
17597
|
+
readonly tools: TOOLS | undefined;
|
|
17598
|
+
/** The tool choice configuration for this step. */
|
|
17599
|
+
readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
|
|
17600
|
+
/** Limits which tools are available for this step. */
|
|
17601
|
+
readonly activeTools: ActiveTools<TOOLS>;
|
|
17602
|
+
/** Controls the order in which tools are sent to the provider for this step. */
|
|
17603
|
+
readonly toolOrder: ToolOrder<TOOLS>;
|
|
17604
|
+
/** Array of results from previous steps (empty for first step). */
|
|
17605
|
+
readonly steps: ReadonlyArray<StepResult<TOOLS, RUNTIME_CONTEXT>>;
|
|
17606
|
+
/** Additional provider-specific options for this step. */
|
|
17607
|
+
readonly providerOptions: ProviderOptions | undefined;
|
|
17608
|
+
/** The output specification for structured outputs, if configured. */
|
|
16613
17609
|
readonly output: OUTPUT | undefined;
|
|
16614
17610
|
/**
|
|
16615
17611
|
* Runtime context. May be updated from `prepareStep` between steps.
|
|
@@ -16634,8 +17630,11 @@ type GenerateTextStepEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT e
|
|
|
16634
17630
|
* Includes the final step's result along with aggregated data from all steps.
|
|
16635
17631
|
*/
|
|
16636
17632
|
type GenerateTextEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context$1 = Context$1> = {
|
|
16637
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
16638
|
-
readonly
|
|
17633
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
17634
|
+
readonly callId: string;
|
|
17635
|
+
/** Zero-based index of the final step. */
|
|
17636
|
+
readonly stepNumber: number;
|
|
17637
|
+
/** Information about the model that produced the final step. */
|
|
16639
17638
|
readonly model: StepResult<TOOLS, RUNTIME_CONTEXT>['model'];
|
|
16640
17639
|
/**
|
|
16641
17640
|
* Tool context from the final step.
|
|
@@ -16648,8 +17647,10 @@ type GenerateTextEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT exten
|
|
|
16648
17647
|
*
|
|
16649
17648
|
* @deprecated Use `finalStep.runtimeContext` instead.
|
|
16650
17649
|
*/
|
|
16651
|
-
readonly runtimeContext: RUNTIME_CONTEXT;
|
|
16652
|
-
|
|
17650
|
+
readonly runtimeContext: RUNTIME_CONTEXT;
|
|
17651
|
+
/** The content that was generated in all steps. */
|
|
17652
|
+
readonly content: StepResult<TOOLS, RUNTIME_CONTEXT>['content'];
|
|
17653
|
+
/** The text that was generated in the final step. */
|
|
16653
17654
|
readonly text: StepResult<TOOLS, RUNTIME_CONTEXT>['text'];
|
|
16654
17655
|
/**
|
|
16655
17656
|
* The reasoning that was generated in the final step.
|
|
@@ -16662,24 +17663,36 @@ type GenerateTextEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT exten
|
|
|
16662
17663
|
*
|
|
16663
17664
|
* @deprecated Use `finalStep.reasoningText` instead.
|
|
16664
17665
|
*/
|
|
16665
|
-
readonly reasoningText: StepResult<TOOLS, RUNTIME_CONTEXT>['reasoningText'];
|
|
16666
|
-
|
|
16667
|
-
readonly
|
|
16668
|
-
|
|
16669
|
-
readonly
|
|
16670
|
-
|
|
16671
|
-
readonly
|
|
16672
|
-
|
|
16673
|
-
readonly
|
|
16674
|
-
|
|
16675
|
-
readonly
|
|
17666
|
+
readonly reasoningText: StepResult<TOOLS, RUNTIME_CONTEXT>['reasoningText'];
|
|
17667
|
+
/** Files that were generated in all steps. */
|
|
17668
|
+
readonly files: StepResult<TOOLS, RUNTIME_CONTEXT>['files'];
|
|
17669
|
+
/** Sources that were used as references in all steps. */
|
|
17670
|
+
readonly sources: StepResult<TOOLS, RUNTIME_CONTEXT>['sources'];
|
|
17671
|
+
/** Tool calls that were made in all steps. */
|
|
17672
|
+
readonly toolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['toolCalls'];
|
|
17673
|
+
/** Static tool calls that were made in all steps. */
|
|
17674
|
+
readonly staticToolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['staticToolCalls'];
|
|
17675
|
+
/** Dynamic tool calls that were made in all steps. */
|
|
17676
|
+
readonly dynamicToolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['dynamicToolCalls'];
|
|
17677
|
+
/** Tool results that were generated in all steps. */
|
|
17678
|
+
readonly toolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['toolResults'];
|
|
17679
|
+
/** Static tool results that were generated in all steps. */
|
|
17680
|
+
readonly staticToolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['staticToolResults'];
|
|
17681
|
+
/** Dynamic tool results that were generated in all steps. */
|
|
17682
|
+
readonly dynamicToolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['dynamicToolResults'];
|
|
17683
|
+
/** The unified reason why the generation finished. Taken from the final step. */
|
|
17684
|
+
readonly finishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['finishReason'];
|
|
17685
|
+
/** The raw reason why the generation finished. Taken from the final step. */
|
|
17686
|
+
readonly rawFinishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['rawFinishReason'];
|
|
17687
|
+
/** Aggregated token usage across all steps. */
|
|
16676
17688
|
readonly usage: LanguageModelUsage;
|
|
16677
17689
|
/**
|
|
16678
17690
|
* Aggregated token usage across all steps.
|
|
16679
17691
|
*
|
|
16680
17692
|
* @deprecated Use `usage` instead.
|
|
16681
17693
|
*/
|
|
16682
|
-
readonly totalUsage: LanguageModelUsage;
|
|
17694
|
+
readonly totalUsage: LanguageModelUsage;
|
|
17695
|
+
/** Warnings from the model provider in all steps. */
|
|
16683
17696
|
readonly warnings: StepResult<TOOLS, RUNTIME_CONTEXT>['warnings'];
|
|
16684
17697
|
/**
|
|
16685
17698
|
* Additional request information from the final step.
|
|
@@ -16698,9 +17711,12 @@ type GenerateTextEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT exten
|
|
|
16698
17711
|
*
|
|
16699
17712
|
* @deprecated Use `finalStep.providerMetadata` instead.
|
|
16700
17713
|
*/
|
|
16701
|
-
readonly providerMetadata: StepResult<TOOLS, RUNTIME_CONTEXT>['providerMetadata'];
|
|
16702
|
-
|
|
16703
|
-
readonly
|
|
17714
|
+
readonly providerMetadata: StepResult<TOOLS, RUNTIME_CONTEXT>['providerMetadata'];
|
|
17715
|
+
/** The response messages that were generated during the call. */
|
|
17716
|
+
readonly responseMessages: ResponseMessage[];
|
|
17717
|
+
/** Array containing results from all steps in the generation. */
|
|
17718
|
+
readonly steps: StepResult<TOOLS, RUNTIME_CONTEXT>[];
|
|
17719
|
+
/** The final step. This is a shortcut for `steps.at(-1)`. */
|
|
16704
17720
|
readonly finalStep: StepResult<TOOLS, RUNTIME_CONTEXT>;
|
|
16705
17721
|
};
|
|
16706
17722
|
/**
|
|
@@ -16710,8 +17726,11 @@ type GenerateTextEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT exten
|
|
|
16710
17726
|
* completes.
|
|
16711
17727
|
*/
|
|
16712
17728
|
type GenerateTextAbortEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context$1 = Context$1> = {
|
|
16713
|
-
/** Unique identifier for this generation call, used to correlate events. */
|
|
16714
|
-
readonly
|
|
17729
|
+
/** Unique identifier for this generation call, used to correlate events. */
|
|
17730
|
+
readonly callId: string;
|
|
17731
|
+
/** Details for all previously finished steps. */
|
|
17732
|
+
readonly steps: StepResult<TOOLS, RUNTIME_CONTEXT>[];
|
|
17733
|
+
/** The abort reason from the AbortSignal, when one is available. */
|
|
16715
17734
|
readonly reason?: unknown;
|
|
16716
17735
|
};
|
|
16717
17736
|
/** @deprecated Use `GenerateTextStartEvent` instead. */
|
|
@@ -16788,15 +17807,24 @@ type GenerateTextOnFinishCallback<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTE
|
|
|
16788
17807
|
* Called when the operation begins, before the reranking model is called.
|
|
16789
17808
|
*/
|
|
16790
17809
|
type RerankStartEvent = {
|
|
16791
|
-
/** Unique identifier for this rerank call, used to correlate events. */
|
|
17810
|
+
/** Unique identifier for this rerank call, used to correlate events. */
|
|
17811
|
+
readonly callId: string;
|
|
17812
|
+
/** Identifies the operation type ('ai.rerank'). */
|
|
16792
17813
|
readonly operationId: string;
|
|
16793
|
-
readonly provider: string;
|
|
16794
|
-
|
|
16795
|
-
readonly
|
|
16796
|
-
|
|
16797
|
-
readonly
|
|
16798
|
-
|
|
16799
|
-
readonly
|
|
17814
|
+
readonly provider: string;
|
|
17815
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
17816
|
+
readonly modelId: string;
|
|
17817
|
+
/** The documents being reranked. */
|
|
17818
|
+
readonly documents: Array<JSONObject$2 | string>;
|
|
17819
|
+
/** The query to rerank the documents against. */
|
|
17820
|
+
readonly query: string;
|
|
17821
|
+
/** Number of top documents to return. */
|
|
17822
|
+
readonly topN: number | undefined;
|
|
17823
|
+
/** Maximum number of retries for failed requests. */
|
|
17824
|
+
readonly maxRetries: number;
|
|
17825
|
+
/** Additional HTTP headers sent with the request. */
|
|
17826
|
+
readonly headers: Record<string, string | undefined> | undefined;
|
|
17827
|
+
/** Additional provider-specific options. */
|
|
16800
17828
|
readonly providerOptions: ProviderOptions | undefined;
|
|
16801
17829
|
};
|
|
16802
17830
|
/**
|
|
@@ -16805,19 +17833,28 @@ type RerankStartEvent = {
|
|
|
16805
17833
|
* Called when the operation completes, after the reranking model returns.
|
|
16806
17834
|
*/
|
|
16807
17835
|
type RerankEndEvent = {
|
|
16808
|
-
/** Unique identifier for this rerank call, used to correlate events. */
|
|
17836
|
+
/** Unique identifier for this rerank call, used to correlate events. */
|
|
17837
|
+
readonly callId: string;
|
|
17838
|
+
/** Identifies the operation type ('ai.rerank'). */
|
|
16809
17839
|
readonly operationId: string;
|
|
16810
|
-
readonly provider: string;
|
|
16811
|
-
|
|
16812
|
-
readonly
|
|
16813
|
-
|
|
17840
|
+
readonly provider: string;
|
|
17841
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
17842
|
+
readonly modelId: string;
|
|
17843
|
+
/** The documents that were reranked. */
|
|
17844
|
+
readonly documents: Array<JSONObject$2 | string>;
|
|
17845
|
+
/** The query that documents were reranked against. */
|
|
17846
|
+
readonly query: string;
|
|
17847
|
+
/** The reranked results sorted by relevance score in descending order. */
|
|
16814
17848
|
readonly ranking: Array<{
|
|
16815
17849
|
originalIndex: number;
|
|
16816
17850
|
score: number;
|
|
16817
17851
|
document: JSONObject$2 | string;
|
|
16818
|
-
}>;
|
|
16819
|
-
|
|
16820
|
-
readonly
|
|
17852
|
+
}>;
|
|
17853
|
+
/** Warnings from the reranking model. */
|
|
17854
|
+
readonly warnings: Array<Warning>;
|
|
17855
|
+
/** Optional provider-specific metadata. */
|
|
17856
|
+
readonly providerMetadata: ProviderMetadata | undefined;
|
|
17857
|
+
/** Response data including headers and body. */
|
|
16821
17858
|
readonly response: {
|
|
16822
17859
|
id?: string;
|
|
16823
17860
|
timestamp: Date;
|
|
@@ -16830,13 +17867,21 @@ type RerankEndEvent = {
|
|
|
16830
17867
|
* Event fired when an individual reranking model call (inner doRerank) begins.
|
|
16831
17868
|
*/
|
|
16832
17869
|
type RerankingModelCallStartEvent = {
|
|
16833
|
-
/** Unique identifier for this rerank call, used to correlate events. */
|
|
16834
|
-
readonly
|
|
16835
|
-
|
|
16836
|
-
readonly
|
|
16837
|
-
|
|
16838
|
-
readonly
|
|
16839
|
-
|
|
17870
|
+
/** Unique identifier for this rerank call, used to correlate events. */
|
|
17871
|
+
readonly callId: string;
|
|
17872
|
+
/** Identifies the inner operation ('ai.rerank.doRerank'). */
|
|
17873
|
+
readonly operationId: string;
|
|
17874
|
+
/** The provider identifier. */
|
|
17875
|
+
readonly provider: string;
|
|
17876
|
+
/** The specific model identifier. */
|
|
17877
|
+
readonly modelId: string;
|
|
17878
|
+
/** The documents being reranked. */
|
|
17879
|
+
readonly documents: Array<JSONObject$2 | string>;
|
|
17880
|
+
/** The type of documents ('text' or 'object'). */
|
|
17881
|
+
readonly documentsType: string;
|
|
17882
|
+
/** The query to rerank against. */
|
|
17883
|
+
readonly query: string;
|
|
17884
|
+
/** Number of top documents to return. */
|
|
16840
17885
|
readonly topN: number | undefined;
|
|
16841
17886
|
};
|
|
16842
17887
|
/**
|
|
@@ -16845,11 +17890,17 @@ type RerankingModelCallStartEvent = {
|
|
|
16845
17890
|
* Contains the ranking results from the model response.
|
|
16846
17891
|
*/
|
|
16847
17892
|
type RerankingModelCallEndEvent = {
|
|
16848
|
-
/** Unique identifier for this rerank call, used to correlate events. */
|
|
16849
|
-
readonly
|
|
16850
|
-
|
|
16851
|
-
readonly
|
|
16852
|
-
|
|
17893
|
+
/** Unique identifier for this rerank call, used to correlate events. */
|
|
17894
|
+
readonly callId: string;
|
|
17895
|
+
/** Identifies the inner operation ('ai.rerank.doRerank'). */
|
|
17896
|
+
readonly operationId: string;
|
|
17897
|
+
/** The provider identifier. */
|
|
17898
|
+
readonly provider: string;
|
|
17899
|
+
/** The specific model identifier. */
|
|
17900
|
+
readonly modelId: string;
|
|
17901
|
+
/** The type of documents ('text' or 'object'). */
|
|
17902
|
+
readonly documentsType: string;
|
|
17903
|
+
/** The ranking results from the model. */
|
|
16853
17904
|
readonly ranking: Array<{
|
|
16854
17905
|
index: number;
|
|
16855
17906
|
relevanceScore: number;
|
|
@@ -17404,62 +18455,7 @@ type GenerateTextInclude = {
|
|
|
17404
18455
|
* @returns
|
|
17405
18456
|
* A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
17406
18457
|
*/
|
|
17407
|
-
declare function generateText<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = Output<string, string>>({
|
|
17408
|
-
model: modelArg,
|
|
17409
|
-
tools,
|
|
17410
|
-
toolChoice,
|
|
17411
|
-
instructions,
|
|
17412
|
-
system,
|
|
17413
|
-
prompt,
|
|
17414
|
-
messages,
|
|
17415
|
-
allowSystemInMessages,
|
|
17416
|
-
maxRetries: maxRetriesArg,
|
|
17417
|
-
abortSignal,
|
|
17418
|
-
timeout,
|
|
17419
|
-
headers,
|
|
17420
|
-
stopWhen,
|
|
17421
|
-
experimental_sandbox: sandbox,
|
|
17422
|
-
output,
|
|
17423
|
-
toolApproval,
|
|
17424
|
-
experimental_toolCallers,
|
|
17425
|
-
experimental_toolApprovalSecret,
|
|
17426
|
-
experimental_telemetry,
|
|
17427
|
-
telemetry,
|
|
17428
|
-
providerOptions,
|
|
17429
|
-
activeTools,
|
|
17430
|
-
toolOrder,
|
|
17431
|
-
prepareStep,
|
|
17432
|
-
experimental_repairToolCall,
|
|
17433
|
-
repairToolCall,
|
|
17434
|
-
experimental_refineToolInput: refineToolInput,
|
|
17435
|
-
experimental_download: download,
|
|
17436
|
-
runtimeContext,
|
|
17437
|
-
toolsContext,
|
|
17438
|
-
experimental_include,
|
|
17439
|
-
include,
|
|
17440
|
-
_internal: {
|
|
17441
|
-
generateId,
|
|
17442
|
-
generateCallId,
|
|
17443
|
-
now
|
|
17444
|
-
},
|
|
17445
|
-
onStart,
|
|
17446
|
-
experimental_onStart,
|
|
17447
|
-
onStepStart,
|
|
17448
|
-
experimental_onStepStart,
|
|
17449
|
-
onLanguageModelCallStart,
|
|
17450
|
-
experimental_onLanguageModelCallStart,
|
|
17451
|
-
onLanguageModelCallEnd,
|
|
17452
|
-
experimental_onLanguageModelCallEnd,
|
|
17453
|
-
onToolExecutionStart,
|
|
17454
|
-
onToolExecutionEnd,
|
|
17455
|
-
experimental_onToolCallStart,
|
|
17456
|
-
experimental_onToolCallFinish,
|
|
17457
|
-
onStepEnd,
|
|
17458
|
-
onStepFinish,
|
|
17459
|
-
onFinish,
|
|
17460
|
-
onEnd,
|
|
17461
|
-
...settings
|
|
17462
|
-
}: LanguageModelCallOptions & RequestOptions<TOOLS> & Prompt & ToolsContextParameter<TOOLS> & {
|
|
18458
|
+
declare function generateText<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, instructions, system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_sandbox: sandbox, output, toolApproval, experimental_toolCallers, experimental_toolApprovalSecret, experimental_telemetry, telemetry, providerOptions, activeTools, toolOrder, prepareStep, experimental_repairToolCall, repairToolCall, experimental_refineToolInput: refineToolInput, experimental_download: download, runtimeContext, toolsContext, experimental_include, include, _internal: { generateId, generateCallId, now }, onStart, experimental_onStart, onStepStart, experimental_onStepStart, onLanguageModelCallStart, experimental_onLanguageModelCallStart, onLanguageModelCallEnd, experimental_onLanguageModelCallEnd, onToolExecutionStart, onToolExecutionEnd, experimental_onToolCallStart, experimental_onToolCallFinish, onStepEnd, onStepFinish, onFinish, onEnd, ...settings }: LanguageModelCallOptions & RequestOptions<TOOLS> & Prompt & ToolsContextParameter<TOOLS> & {
|
|
17463
18459
|
/**
|
|
17464
18460
|
* The language model to use.
|
|
17465
18461
|
*/
|
|
@@ -17905,42 +18901,11 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RU
|
|
|
17905
18901
|
/**
|
|
17906
18902
|
* Generates an output from the agent (non-streaming).
|
|
17907
18903
|
*/
|
|
17908
|
-
generate({
|
|
17909
|
-
abortSignal,
|
|
17910
|
-
timeout,
|
|
17911
|
-
experimental_sandbox: sandbox,
|
|
17912
|
-
onStart,
|
|
17913
|
-
experimental_onStart,
|
|
17914
|
-
onStepStart,
|
|
17915
|
-
experimental_onStepStart,
|
|
17916
|
-
onToolExecutionStart,
|
|
17917
|
-
onToolExecutionEnd,
|
|
17918
|
-
onStepEnd,
|
|
17919
|
-
onStepFinish,
|
|
17920
|
-
onFinish,
|
|
17921
|
-
onEnd,
|
|
17922
|
-
...options
|
|
17923
|
-
}: AgentCallParameters<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT>): Promise<GenerateTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>>;
|
|
18904
|
+
generate({ abortSignal, timeout, experimental_sandbox: sandbox, onStart, experimental_onStart, onStepStart, experimental_onStepStart, onToolExecutionStart, onToolExecutionEnd, onStepEnd, onStepFinish, onFinish, onEnd, ...options }: AgentCallParameters<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT>): Promise<GenerateTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>>;
|
|
17924
18905
|
/**
|
|
17925
18906
|
* Streams an output from the agent (streaming).
|
|
17926
18907
|
*/
|
|
17927
|
-
stream({
|
|
17928
|
-
abortSignal,
|
|
17929
|
-
timeout,
|
|
17930
|
-
experimental_sandbox: sandbox,
|
|
17931
|
-
experimental_transform,
|
|
17932
|
-
onStart,
|
|
17933
|
-
experimental_onStart,
|
|
17934
|
-
onStepStart,
|
|
17935
|
-
experimental_onStepStart,
|
|
17936
|
-
onToolExecutionStart,
|
|
17937
|
-
onToolExecutionEnd,
|
|
17938
|
-
onStepEnd,
|
|
17939
|
-
onStepFinish,
|
|
17940
|
-
onFinish,
|
|
17941
|
-
onEnd,
|
|
17942
|
-
...options
|
|
17943
|
-
}: AgentStreamParameters<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT>): Promise<StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>>;
|
|
18908
|
+
stream({ abortSignal, timeout, experimental_sandbox: sandbox, experimental_transform, onStart, experimental_onStart, onStepStart, experimental_onStepStart, onToolExecutionStart, onToolExecutionEnd, onStepEnd, onStepFinish, onFinish, onEnd, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT>): Promise<StreamTextResult<TOOLS, RUNTIME_CONTEXT, OUTPUT>>;
|
|
17944
18909
|
}
|
|
17945
18910
|
/**
|
|
17946
18911
|
* Infer the type of the tools of an agent.
|
|
@@ -17969,13 +18934,7 @@ type InferAgentUIMessage<AGENT, MESSAGE_METADATA = unknown> = UIMessage<MESSAGE_
|
|
|
17969
18934
|
*
|
|
17970
18935
|
* @returns The response object.
|
|
17971
18936
|
*/
|
|
17972
|
-
declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = never, MESSAGE_METADATA = unknown>({
|
|
17973
|
-
headers,
|
|
17974
|
-
status,
|
|
17975
|
-
statusText,
|
|
17976
|
-
consumeSseStream,
|
|
17977
|
-
...options
|
|
17978
|
-
}: {
|
|
18937
|
+
declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = never, MESSAGE_METADATA = unknown>({ headers, status, statusText, consumeSseStream, ...options }: {
|
|
17979
18938
|
agent: Agent$1<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT, OUTPUT>;
|
|
17980
18939
|
uiMessages: unknown[];
|
|
17981
18940
|
abortSignal?: AbortSignal;
|
|
@@ -17983,7 +18942,8 @@ declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
17983
18942
|
experimental_sandbox?: SandboxSession;
|
|
17984
18943
|
options?: CALL_OPTIONS;
|
|
17985
18944
|
experimental_transform?: Arrayable<StreamTextTransform<TOOLS>>;
|
|
17986
|
-
onStepEnd?: GenerateTextOnStepEndCallback<TOOLS>;
|
|
18945
|
+
onStepEnd?: GenerateTextOnStepEndCallback<TOOLS>;
|
|
18946
|
+
/** @deprecated Use `onStepEnd` instead. */
|
|
17987
18947
|
onStepFinish?: GenerateTextOnStepFinishCallback<TOOLS>;
|
|
17988
18948
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<Response>;
|
|
17989
18949
|
/**
|
|
@@ -18014,21 +18974,7 @@ type UIMessageStreamOnStepEndCallback<UI_MESSAGE extends UIMessage> = (event: {
|
|
|
18014
18974
|
*/
|
|
18015
18975
|
type UIMessageStreamOnStepFinishCallback<UI_MESSAGE extends UIMessage> = UIMessageStreamOnStepEndCallback<UI_MESSAGE>;
|
|
18016
18976
|
declare const getOriginalFetch: () => typeof fetch;
|
|
18017
|
-
declare function callCompletionApi({
|
|
18018
|
-
api,
|
|
18019
|
-
prompt,
|
|
18020
|
-
credentials,
|
|
18021
|
-
headers,
|
|
18022
|
-
body,
|
|
18023
|
-
streamProtocol,
|
|
18024
|
-
setCompletion,
|
|
18025
|
-
setLoading,
|
|
18026
|
-
setError,
|
|
18027
|
-
setAbortController,
|
|
18028
|
-
onFinish,
|
|
18029
|
-
onError,
|
|
18030
|
-
fetch
|
|
18031
|
-
}: {
|
|
18977
|
+
declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch }: {
|
|
18032
18978
|
api: string;
|
|
18033
18979
|
prompt: string;
|
|
18034
18980
|
credentials: RequestCredentials | undefined;
|
|
@@ -18082,10 +19028,15 @@ interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
|
|
18082
19028
|
* @throws Error when the API request fails or response is invalid
|
|
18083
19029
|
*/
|
|
18084
19030
|
sendMessages: (options: {
|
|
18085
|
-
/** The type of message submission - either new message or regeneration */
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
19031
|
+
/** The type of message submission - either new message or regeneration */
|
|
19032
|
+
trigger: 'submit-message' | 'regenerate-message';
|
|
19033
|
+
/** Unique identifier for the chat session */
|
|
19034
|
+
chatId: string;
|
|
19035
|
+
/** ID of the message to regenerate, or undefined for new messages */
|
|
19036
|
+
messageId: string | undefined;
|
|
19037
|
+
/** Array of UI messages representing the conversation history */
|
|
19038
|
+
messages: UI_MESSAGE[];
|
|
19039
|
+
/** Signal to abort the request if needed */
|
|
18089
19040
|
abortSignal: AbortSignal | undefined;
|
|
18090
19041
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
|
18091
19042
|
/**
|
|
@@ -18109,7 +19060,9 @@ interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
|
|
18109
19060
|
* @throws Error when the reconnection request fails or response is invalid
|
|
18110
19061
|
*/
|
|
18111
19062
|
reconnectToStream: (options: {
|
|
18112
|
-
/** Unique identifier for the chat session to reconnect to */
|
|
19063
|
+
/** Unique identifier for the chat session to reconnect to */
|
|
19064
|
+
chatId: string;
|
|
19065
|
+
/** Signal to abort the reconnection request if needed */
|
|
18113
19066
|
abortSignal?: AbortSignal;
|
|
18114
19067
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk> | null>;
|
|
18115
19068
|
}
|
|
@@ -18118,8 +19071,8 @@ type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'ro
|
|
|
18118
19071
|
role?: UI_MESSAGE['role'];
|
|
18119
19072
|
};
|
|
18120
19073
|
type UIDataPartSchemas = Record<string, FlexibleSchema>;
|
|
18121
|
-
type UIDataTypesToSchemas<T extends UIDataTypes> = { [K in keyof T]: FlexibleSchema<T[K]
|
|
18122
|
-
type InferUIDataParts<T extends UIDataPartSchemas> = { [K in keyof T]: InferSchema<T[K]
|
|
19074
|
+
type UIDataTypesToSchemas<T extends UIDataTypes> = { [K in keyof T]: FlexibleSchema<T[K]>; };
|
|
19075
|
+
type InferUIDataParts<T extends UIDataPartSchemas> = { [K in keyof T]: InferSchema<T[K]>; };
|
|
18123
19076
|
type ChatRequestOptions = {
|
|
18124
19077
|
/**
|
|
18125
19078
|
* Additional headers that should be to be passed to the API endpoint.
|
|
@@ -18134,12 +19087,7 @@ type ChatRequestOptions = {
|
|
|
18134
19087
|
/**
|
|
18135
19088
|
* Function that can be called to add a tool approval response to the chat.
|
|
18136
19089
|
*/
|
|
18137
|
-
type ChatAddToolApproveResponseFunction = ({
|
|
18138
|
-
id,
|
|
18139
|
-
approved,
|
|
18140
|
-
reason,
|
|
18141
|
-
options
|
|
18142
|
-
}: {
|
|
19090
|
+
type ChatAddToolApproveResponseFunction = ({ id, approved, reason, options }: {
|
|
18143
19091
|
id: string;
|
|
18144
19092
|
/**
|
|
18145
19093
|
* Flag indicating whether the approval was granted or denied.
|
|
@@ -18157,14 +19105,7 @@ type ChatAddToolApproveResponseFunction = ({
|
|
|
18157
19105
|
/**
|
|
18158
19106
|
* Function that can be called to add a tool output to the chat.
|
|
18159
19107
|
*/
|
|
18160
|
-
type ChatAddToolOutputFunction<UI_MESSAGE extends UIMessage> = <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({
|
|
18161
|
-
state,
|
|
18162
|
-
tool,
|
|
18163
|
-
toolCallId,
|
|
18164
|
-
output,
|
|
18165
|
-
errorText,
|
|
18166
|
-
options
|
|
18167
|
-
}: {
|
|
19108
|
+
type ChatAddToolOutputFunction<UI_MESSAGE extends UIMessage> = <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ state, tool, toolCallId, output, errorText, options }: {
|
|
18168
19109
|
/**
|
|
18169
19110
|
* Name of the tool that was called.
|
|
18170
19111
|
*/
|
|
@@ -18281,19 +19222,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
18281
19222
|
private activeResponse;
|
|
18282
19223
|
private activeResumeRequest;
|
|
18283
19224
|
private jobExecutor;
|
|
18284
|
-
constructor({
|
|
18285
|
-
generateId,
|
|
18286
|
-
id,
|
|
18287
|
-
transport,
|
|
18288
|
-
messageMetadataSchema,
|
|
18289
|
-
dataPartSchemas,
|
|
18290
|
-
state,
|
|
18291
|
-
onError,
|
|
18292
|
-
onToolCall,
|
|
18293
|
-
onFinish,
|
|
18294
|
-
onData,
|
|
18295
|
-
sendAutomaticallyWhen
|
|
18296
|
-
}: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
|
19225
|
+
constructor({ generateId, id, transport, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, onData, sendAutomaticallyWhen }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
|
18297
19226
|
state: ChatState<UI_MESSAGE>;
|
|
18298
19227
|
});
|
|
18299
19228
|
/**
|
|
@@ -18305,10 +19234,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
18305
19234
|
* - `error`: An error occurred during the API request, preventing successful completion.
|
|
18306
19235
|
*/
|
|
18307
19236
|
get status(): ChatStatus;
|
|
18308
|
-
protected setStatus({
|
|
18309
|
-
status,
|
|
18310
|
-
error
|
|
18311
|
-
}: {
|
|
19237
|
+
protected setStatus({ status, error }: {
|
|
18312
19238
|
status: ChatStatus;
|
|
18313
19239
|
error?: Error;
|
|
18314
19240
|
}): void;
|
|
@@ -18342,10 +19268,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
18342
19268
|
* Regenerate the assistant message with the provided message id.
|
|
18343
19269
|
* If no message id is provided, the last assistant message will be regenerated.
|
|
18344
19270
|
*/
|
|
18345
|
-
regenerate: ({
|
|
18346
|
-
messageId,
|
|
18347
|
-
...options
|
|
18348
|
-
}?: {
|
|
19271
|
+
regenerate: ({ messageId, ...options }?: {
|
|
18349
19272
|
messageId?: string;
|
|
18350
19273
|
} & ChatRequestOptions) => Promise<void>;
|
|
18351
19274
|
/**
|
|
@@ -18482,19 +19405,8 @@ declare abstract class HttpChatTransport<UI_MESSAGE extends UIMessage> implement
|
|
|
18482
19405
|
protected fetch?: FetchFunction;
|
|
18483
19406
|
protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
|
18484
19407
|
protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
|
18485
|
-
constructor({
|
|
18486
|
-
|
|
18487
|
-
credentials,
|
|
18488
|
-
headers,
|
|
18489
|
-
body,
|
|
18490
|
-
fetch,
|
|
18491
|
-
prepareSendMessagesRequest,
|
|
18492
|
-
prepareReconnectToStreamRequest
|
|
18493
|
-
}: HttpChatTransportInitOptions<UI_MESSAGE>);
|
|
18494
|
-
sendMessages({
|
|
18495
|
-
abortSignal,
|
|
18496
|
-
...options
|
|
18497
|
-
}: Parameters<ChatTransport<UI_MESSAGE>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
|
19408
|
+
constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest }: HttpChatTransportInitOptions<UI_MESSAGE>);
|
|
19409
|
+
sendMessages({ abortSignal, ...options }: Parameters<ChatTransport<UI_MESSAGE>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
|
18498
19410
|
reconnectToStream(options: Parameters<ChatTransport<UI_MESSAGE>['reconnectToStream']>[0]): Promise<ReadableStream<UIMessageChunk> | null>;
|
|
18499
19411
|
protected abstract processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
|
18500
19412
|
}
|
|
@@ -18537,15 +19449,8 @@ declare class DirectChatTransport<CALL_OPTIONS = never, TOOLS extends ToolSet =
|
|
|
18537
19449
|
private readonly agent;
|
|
18538
19450
|
private readonly agentOptions;
|
|
18539
19451
|
private readonly uiMessageStreamOptions;
|
|
18540
|
-
constructor({
|
|
18541
|
-
|
|
18542
|
-
options,
|
|
18543
|
-
...uiMessageStreamOptions
|
|
18544
|
-
}: DirectChatTransportOptions<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT, OUTPUT, UI_MESSAGE>);
|
|
18545
|
-
sendMessages({
|
|
18546
|
-
messages,
|
|
18547
|
-
abortSignal
|
|
18548
|
-
}: Parameters<ChatTransport<UI_MESSAGE>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
|
19452
|
+
constructor({ agent, options, ...uiMessageStreamOptions }: DirectChatTransportOptions<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT, OUTPUT, UI_MESSAGE>);
|
|
19453
|
+
sendMessages({ messages, abortSignal }: Parameters<ChatTransport<UI_MESSAGE>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
|
18549
19454
|
/**
|
|
18550
19455
|
* Direct transport does not support reconnection since there is no
|
|
18551
19456
|
* persistent server-side stream to reconnect to.
|
|
@@ -18559,9 +19464,7 @@ declare class DirectChatTransport<CALL_OPTIONS = never, TOOLS extends ToolSet =
|
|
|
18559
19464
|
* The last step of the message must have at least one tool approval response and
|
|
18560
19465
|
* all tool approvals must have a response.
|
|
18561
19466
|
*/
|
|
18562
|
-
declare function lastAssistantMessageIsCompleteWithApprovalResponses({
|
|
18563
|
-
messages
|
|
18564
|
-
}: {
|
|
19467
|
+
declare function lastAssistantMessageIsCompleteWithApprovalResponses({ messages }: {
|
|
18565
19468
|
messages: UIMessage[];
|
|
18566
19469
|
}): boolean;
|
|
18567
19470
|
/**
|
|
@@ -18569,9 +19472,7 @@ declare function lastAssistantMessageIsCompleteWithApprovalResponses({
|
|
|
18569
19472
|
* The last step of the message must have at least one tool invocation and
|
|
18570
19473
|
* all tool invocations must have a result.
|
|
18571
19474
|
*/
|
|
18572
|
-
declare function lastAssistantMessageIsCompleteWithToolCalls({
|
|
18573
|
-
messages
|
|
18574
|
-
}: {
|
|
19475
|
+
declare function lastAssistantMessageIsCompleteWithToolCalls({ messages }: {
|
|
18575
19476
|
messages: UIMessage[];
|
|
18576
19477
|
}): boolean;
|
|
18577
19478
|
declare class TextStreamChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
|
|
@@ -18661,16 +19562,11 @@ type SafeValidateUIMessagesResult<UI_MESSAGE extends UIMessage> = {
|
|
|
18661
19562
|
* but instead of throwing it returns `{ success: true, data }`
|
|
18662
19563
|
* or `{ success: false, error }`.
|
|
18663
19564
|
*/
|
|
18664
|
-
declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({
|
|
18665
|
-
messages,
|
|
18666
|
-
metadataSchema,
|
|
18667
|
-
dataSchemas,
|
|
18668
|
-
tools
|
|
18669
|
-
}: {
|
|
19565
|
+
declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages, metadataSchema, dataSchemas, tools }: {
|
|
18670
19566
|
messages: unknown;
|
|
18671
19567
|
metadataSchema?: FlexibleSchema<UIMessage['metadata']>;
|
|
18672
|
-
dataSchemas?: { [NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]
|
|
18673
|
-
tools?: { [NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']
|
|
19568
|
+
dataSchemas?: { [NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]>; };
|
|
19569
|
+
tools?: { [NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']>; };
|
|
18674
19570
|
}): Promise<SafeValidateUIMessagesResult<UI_MESSAGE>>;
|
|
18675
19571
|
/**
|
|
18676
19572
|
* Validates a list of UI messages.
|
|
@@ -18679,16 +19575,11 @@ declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({
|
|
|
18679
19575
|
* the corresponding schemas are provided. Otherwise, they are assumed to be
|
|
18680
19576
|
* valid.
|
|
18681
19577
|
*/
|
|
18682
|
-
declare function validateUIMessages<UI_MESSAGE extends UIMessage>({
|
|
18683
|
-
messages,
|
|
18684
|
-
metadataSchema,
|
|
18685
|
-
dataSchemas,
|
|
18686
|
-
tools
|
|
18687
|
-
}: {
|
|
19578
|
+
declare function validateUIMessages<UI_MESSAGE extends UIMessage>({ messages, metadataSchema, dataSchemas, tools }: {
|
|
18688
19579
|
messages: unknown;
|
|
18689
19580
|
metadataSchema?: FlexibleSchema<UIMessage['metadata']>;
|
|
18690
|
-
dataSchemas?: { [NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]
|
|
18691
|
-
tools?: { [NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']
|
|
19581
|
+
dataSchemas?: { [NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]>; };
|
|
19582
|
+
tools?: { [NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']>; };
|
|
18692
19583
|
}): Promise<Array<UI_MESSAGE>>;
|
|
18693
19584
|
interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
18694
19585
|
/**
|
|
@@ -18721,17 +19612,7 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
|
18721
19612
|
*
|
|
18722
19613
|
* @returns A `ReadableStream` of UI message chunks.
|
|
18723
19614
|
*/
|
|
18724
|
-
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
18725
|
-
execute,
|
|
18726
|
-
onError,
|
|
18727
|
-
// prevent leaking server error details to the client by default
|
|
18728
|
-
originalMessages,
|
|
18729
|
-
onStepEnd,
|
|
18730
|
-
onStepFinish,
|
|
18731
|
-
onEnd,
|
|
18732
|
-
onFinish,
|
|
18733
|
-
generateId
|
|
18734
|
-
}: {
|
|
19615
|
+
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, originalMessages, onStepEnd, onStepFinish, onEnd, onFinish, generateId }: {
|
|
18735
19616
|
execute: (options: {
|
|
18736
19617
|
writer: UIMessageStreamWriter<UI_MESSAGE>;
|
|
18737
19618
|
}) => Promise<void> | void;
|
|
@@ -18770,13 +19651,7 @@ declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
|
18770
19651
|
*
|
|
18771
19652
|
* @returns A `Response` object with the UI message stream as the body.
|
|
18772
19653
|
*/
|
|
18773
|
-
declare function createUIMessageStreamResponse({
|
|
18774
|
-
status,
|
|
18775
|
-
statusText,
|
|
18776
|
-
headers,
|
|
18777
|
-
stream,
|
|
18778
|
-
consumeSseStream
|
|
18779
|
-
}: UIMessageStreamResponseInit & {
|
|
19654
|
+
declare function createUIMessageStreamResponse({ status, statusText, headers, stream, consumeSseStream }: UIMessageStreamResponseInit & {
|
|
18780
19655
|
stream: ReadableStream<UIMessageChunk>;
|
|
18781
19656
|
}): Response;
|
|
18782
19657
|
/**
|
|
@@ -18799,14 +19674,7 @@ declare class JsonToSseTransformStream extends TransformStream<unknown, string>
|
|
|
18799
19674
|
* @param options.consumeSseStream - Optional callback to consume a copy of the SSE stream independently.
|
|
18800
19675
|
* @returns A promise that resolves when the stream has been written.
|
|
18801
19676
|
*/
|
|
18802
|
-
declare function pipeUIMessageStreamToResponse({
|
|
18803
|
-
response,
|
|
18804
|
-
status,
|
|
18805
|
-
statusText,
|
|
18806
|
-
headers,
|
|
18807
|
-
stream,
|
|
18808
|
-
consumeSseStream
|
|
18809
|
-
}: {
|
|
19677
|
+
declare function pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, consumeSseStream }: {
|
|
18810
19678
|
response: ServerResponse;
|
|
18811
19679
|
stream: ReadableStream<UIMessageChunk>;
|
|
18812
19680
|
} & UIMessageStreamResponseInit): Promise<void>;
|
|
@@ -18821,12 +19689,7 @@ declare function pipeUIMessageStreamToResponse({
|
|
|
18821
19689
|
* @returns An `AsyncIterableStream` of `UIMessage`s. Each stream part is a different state of the same message
|
|
18822
19690
|
* as it is being completed.
|
|
18823
19691
|
*/
|
|
18824
|
-
declare function readUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
18825
|
-
message,
|
|
18826
|
-
stream,
|
|
18827
|
-
onError,
|
|
18828
|
-
terminateOnError
|
|
18829
|
-
}: {
|
|
19692
|
+
declare function readUIMessageStream<UI_MESSAGE extends UIMessage>({ message, stream, onError, terminateOnError }: {
|
|
18830
19693
|
message?: UI_MESSAGE;
|
|
18831
19694
|
stream: ReadableStream<UIMessageChunk>;
|
|
18832
19695
|
onError?: (error: unknown) => void;
|
|
@@ -18848,38 +19711,14 @@ type ToUIMessageChunkOptions<TOOLS extends ToolSet = ToolSet, UI_MESSAGE extends
|
|
|
18848
19711
|
*
|
|
18849
19712
|
* Returns `undefined` for stream parts that do not produce UI message chunks.
|
|
18850
19713
|
*/
|
|
18851
|
-
declare function toUIMessageChunk<TOOLS extends ToolSet = ToolSet, UI_MESSAGE extends UIMessage = UIMessage>(part: TextStreamPart<TOOLS>, {
|
|
18852
|
-
tools,
|
|
18853
|
-
sendReasoning,
|
|
18854
|
-
sendSources,
|
|
18855
|
-
sendStart,
|
|
18856
|
-
sendFinish,
|
|
18857
|
-
onError,
|
|
18858
|
-
// prevent leaking server error details to the client by default
|
|
18859
|
-
messageMetadata,
|
|
18860
|
-
responseMessageId
|
|
18861
|
-
}?: ToUIMessageChunkOptions<TOOLS, UI_MESSAGE>): InferUIMessageChunk<UI_MESSAGE> | undefined;
|
|
19714
|
+
declare function toUIMessageChunk<TOOLS extends ToolSet = ToolSet, UI_MESSAGE extends UIMessage = UIMessage>(part: TextStreamPart<TOOLS>, { tools, sendReasoning, sendSources, sendStart, sendFinish, onError, messageMetadata, responseMessageId }?: ToUIMessageChunkOptions<TOOLS, UI_MESSAGE>): InferUIMessageChunk<UI_MESSAGE> | undefined;
|
|
18862
19715
|
/**
|
|
18863
19716
|
* Converts a stream of `TextStreamPart<TOOLS>` chunks (as emitted by
|
|
18864
19717
|
* `streamText`'s `stream`) into a stream of `UIMessageChunk`s suitable for
|
|
18865
19718
|
* UI message streaming, including response message ID injection and
|
|
18866
19719
|
* `onEnd` handling.
|
|
18867
19720
|
*/
|
|
18868
|
-
declare function toUIMessageStream<TOOLS extends ToolSet = ToolSet, UI_MESSAGE extends UIMessage = UIMessage>({
|
|
18869
|
-
stream,
|
|
18870
|
-
tools,
|
|
18871
|
-
sendReasoning,
|
|
18872
|
-
sendSources,
|
|
18873
|
-
sendStart,
|
|
18874
|
-
sendFinish,
|
|
18875
|
-
onError,
|
|
18876
|
-
// prevent leaking server error details to the client by default
|
|
18877
|
-
messageMetadata,
|
|
18878
|
-
originalMessages,
|
|
18879
|
-
generateMessageId,
|
|
18880
|
-
onEnd,
|
|
18881
|
-
onFinish
|
|
18882
|
-
}: {
|
|
19721
|
+
declare function toUIMessageStream<TOOLS extends ToolSet = ToolSet, UI_MESSAGE extends UIMessage = UIMessage>({ stream, tools, sendReasoning, sendSources, sendStart, sendFinish, onError, messageMetadata, originalMessages, generateMessageId, onEnd, onFinish }: {
|
|
18883
19722
|
stream: ReadableStream<TextStreamPart<TOOLS>>;
|
|
18884
19723
|
tools?: TOOLS;
|
|
18885
19724
|
} & UIMessageStreamOptions<UI_MESSAGE>): ReadableStream<InferUIMessageChunk<UI_MESSAGE>>;
|
|
@@ -18909,18 +19748,7 @@ type UIMessageStreamOnFinishCallback<UI_MESSAGE extends UIMessage> = UIMessageSt
|
|
|
18909
19748
|
*
|
|
18910
19749
|
* @returns The UI message stream.
|
|
18911
19750
|
*/
|
|
18912
|
-
declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = never, MESSAGE_METADATA = unknown, UI_MESSAGE extends UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>> = UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>({
|
|
18913
|
-
agent,
|
|
18914
|
-
uiMessages,
|
|
18915
|
-
options,
|
|
18916
|
-
abortSignal,
|
|
18917
|
-
timeout,
|
|
18918
|
-
experimental_sandbox: sandbox,
|
|
18919
|
-
experimental_transform,
|
|
18920
|
-
onStepEnd,
|
|
18921
|
-
onStepFinish,
|
|
18922
|
-
...uiMessageStreamOptions
|
|
18923
|
-
}: {
|
|
19751
|
+
declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = never, MESSAGE_METADATA = unknown, UI_MESSAGE extends UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>> = UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>({ agent, uiMessages, options, abortSignal, timeout, experimental_sandbox: sandbox, experimental_transform, onStepEnd, onStepFinish, ...uiMessageStreamOptions }: {
|
|
18924
19752
|
agent: Agent$1<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT, OUTPUT>;
|
|
18925
19753
|
uiMessages: unknown[];
|
|
18926
19754
|
abortSignal?: AbortSignal;
|
|
@@ -18928,7 +19756,8 @@ declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet
|
|
|
18928
19756
|
experimental_sandbox?: SandboxSession;
|
|
18929
19757
|
options?: CALL_OPTIONS;
|
|
18930
19758
|
experimental_transform?: Arrayable<StreamTextTransform<TOOLS>>;
|
|
18931
|
-
onStepEnd?: GenerateTextOnStepEndCallback<TOOLS>;
|
|
19759
|
+
onStepEnd?: GenerateTextOnStepEndCallback<TOOLS>;
|
|
19760
|
+
/** @deprecated Use `onStepEnd` instead. */
|
|
18932
19761
|
onStepFinish?: GenerateTextOnStepFinishCallback<TOOLS>;
|
|
18933
19762
|
} & UIMessageStreamOptions<UI_MESSAGE>): Promise<AsyncIterableStream<InferUIMessageChunk<UI_MESSAGE>>>;
|
|
18934
19763
|
/**
|
|
@@ -18949,14 +19778,7 @@ declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet
|
|
|
18949
19778
|
* @param statusText - The status text for the response. Optional.
|
|
18950
19779
|
* @param consumeSseStream - Whether to consume the SSE stream. Optional.
|
|
18951
19780
|
*/
|
|
18952
|
-
declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = never, MESSAGE_METADATA = unknown>({
|
|
18953
|
-
response,
|
|
18954
|
-
headers,
|
|
18955
|
-
status,
|
|
18956
|
-
statusText,
|
|
18957
|
-
consumeSseStream,
|
|
18958
|
-
...options
|
|
18959
|
-
}: {
|
|
19781
|
+
declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RUNTIME_CONTEXT extends Context$1 = Context$1, OUTPUT extends Output = never, MESSAGE_METADATA = unknown>({ response, headers, status, statusText, consumeSseStream, ...options }: {
|
|
18960
19782
|
response: ServerResponse;
|
|
18961
19783
|
agent: Agent$1<CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT, OUTPUT>;
|
|
18962
19784
|
uiMessages: unknown[];
|
|
@@ -18965,7 +19787,8 @@ declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
18965
19787
|
experimental_sandbox?: SandboxSession;
|
|
18966
19788
|
options?: CALL_OPTIONS;
|
|
18967
19789
|
experimental_transform?: Arrayable<StreamTextTransform<TOOLS>>;
|
|
18968
|
-
onStepEnd?: GenerateTextOnStepEndCallback<TOOLS>;
|
|
19790
|
+
onStepEnd?: GenerateTextOnStepEndCallback<TOOLS>;
|
|
19791
|
+
/** @deprecated Use `onStepEnd` instead. */
|
|
18969
19792
|
onStepFinish?: GenerateTextOnStepFinishCallback<TOOLS>;
|
|
18970
19793
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<void>;
|
|
18971
19794
|
/**
|
|
@@ -19075,38 +19898,15 @@ type TextBatchItemResult = (TextBatchGenerationResult & {
|
|
|
19075
19898
|
/**
|
|
19076
19899
|
* Starts a durable text-generation batch.
|
|
19077
19900
|
*/
|
|
19078
|
-
declare function startTextBatch({
|
|
19079
|
-
model: modelArg,
|
|
19080
|
-
requests,
|
|
19081
|
-
providerOptions,
|
|
19082
|
-
abortSignal,
|
|
19083
|
-
headers,
|
|
19084
|
-
timeout
|
|
19085
|
-
}: StartTextBatchOptions): Promise<StartTextBatchResult>;
|
|
19901
|
+
declare function startTextBatch({ model: modelArg, requests, providerOptions, abortSignal, headers, timeout }: StartTextBatchOptions): Promise<StartTextBatchResult>;
|
|
19086
19902
|
/**
|
|
19087
19903
|
* Retrieves the latest normalized status for a durable batch.
|
|
19088
19904
|
*/
|
|
19089
|
-
declare function getBatchStatus({
|
|
19090
|
-
model: modelArg,
|
|
19091
|
-
batch,
|
|
19092
|
-
providerOptions,
|
|
19093
|
-
maxRetries,
|
|
19094
|
-
abortSignal,
|
|
19095
|
-
headers,
|
|
19096
|
-
timeout
|
|
19097
|
-
}: BatchOperationOptions): Promise<BatchStatus>;
|
|
19905
|
+
declare function getBatchStatus({ model: modelArg, batch, providerOptions, maxRetries, abortSignal, headers, timeout }: BatchOperationOptions): Promise<BatchStatus>;
|
|
19098
19906
|
/**
|
|
19099
19907
|
* Streams complete terminal results for the requests in a durable batch.
|
|
19100
19908
|
*/
|
|
19101
|
-
declare function getBatchResults({
|
|
19102
|
-
model: modelArg,
|
|
19103
|
-
batch,
|
|
19104
|
-
providerOptions,
|
|
19105
|
-
maxRetries,
|
|
19106
|
-
abortSignal,
|
|
19107
|
-
headers,
|
|
19108
|
-
timeout
|
|
19109
|
-
}: BatchOperationOptions): AsyncIterableStream<TextBatchItemResult>;
|
|
19909
|
+
declare function getBatchResults({ model: modelArg, batch, providerOptions, maxRetries, abortSignal, headers, timeout }: BatchOperationOptions): AsyncIterableStream<TextBatchItemResult>;
|
|
19110
19910
|
/**
|
|
19111
19911
|
* The result of an `embed` call.
|
|
19112
19912
|
* It contains the embedding, the value, and additional information.
|
|
@@ -19164,23 +19964,7 @@ interface EmbedResult {
|
|
|
19164
19964
|
*
|
|
19165
19965
|
* @returns A result object that contains the embedding, the value, and additional information.
|
|
19166
19966
|
*/
|
|
19167
|
-
declare function embed({
|
|
19168
|
-
model: modelArg,
|
|
19169
|
-
value,
|
|
19170
|
-
providerOptions,
|
|
19171
|
-
maxRetries: maxRetriesArg,
|
|
19172
|
-
abortSignal,
|
|
19173
|
-
headers,
|
|
19174
|
-
experimental_telemetry,
|
|
19175
|
-
telemetry,
|
|
19176
|
-
onStart,
|
|
19177
|
-
experimental_onStart,
|
|
19178
|
-
onEnd,
|
|
19179
|
-
experimental_onEnd,
|
|
19180
|
-
_internal: {
|
|
19181
|
-
generateCallId
|
|
19182
|
-
}
|
|
19183
|
-
}: {
|
|
19967
|
+
declare function embed({ model: modelArg, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry, telemetry, onStart, experimental_onStart, onEnd, experimental_onEnd, _internal: { generateCallId } }: {
|
|
19184
19968
|
/**
|
|
19185
19969
|
* The embedding model to use.
|
|
19186
19970
|
*/
|
|
@@ -19314,24 +20098,7 @@ interface EmbedManyResult {
|
|
|
19314
20098
|
*
|
|
19315
20099
|
* @returns A result object that contains the embeddings, the value, and additional information.
|
|
19316
20100
|
*/
|
|
19317
|
-
declare function embedMany({
|
|
19318
|
-
model: modelArg,
|
|
19319
|
-
values,
|
|
19320
|
-
maxParallelCalls,
|
|
19321
|
-
maxRetries: maxRetriesArg,
|
|
19322
|
-
abortSignal,
|
|
19323
|
-
headers,
|
|
19324
|
-
providerOptions,
|
|
19325
|
-
experimental_telemetry,
|
|
19326
|
-
telemetry,
|
|
19327
|
-
onStart,
|
|
19328
|
-
experimental_onStart,
|
|
19329
|
-
onEnd,
|
|
19330
|
-
experimental_onEnd,
|
|
19331
|
-
_internal: {
|
|
19332
|
-
generateCallId
|
|
19333
|
-
}
|
|
19334
|
-
}: {
|
|
20101
|
+
declare function embedMany({ model: modelArg, values, maxParallelCalls, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry, telemetry, onStart, experimental_onStart, onEnd, experimental_onEnd, _internal: { generateCallId } }: {
|
|
19335
20102
|
/**
|
|
19336
20103
|
* The embedding model to use.
|
|
19337
20104
|
*/
|
|
@@ -19413,11 +20180,7 @@ declare class InvalidArgumentError extends AISDKError {
|
|
|
19413
20180
|
private readonly [symbol$j];
|
|
19414
20181
|
readonly parameter: string;
|
|
19415
20182
|
readonly value: unknown;
|
|
19416
|
-
constructor({
|
|
19417
|
-
parameter,
|
|
19418
|
-
value,
|
|
19419
|
-
message
|
|
19420
|
-
}: {
|
|
20183
|
+
constructor({ parameter, value, message }: {
|
|
19421
20184
|
parameter: string;
|
|
19422
20185
|
value: unknown;
|
|
19423
20186
|
message: string;
|
|
@@ -19508,38 +20271,7 @@ type LanguageModelStreamPart<TOOLS extends ToolSet = ToolSet> = Exclude<TextStre
|
|
|
19508
20271
|
*
|
|
19509
20272
|
* @returns A stream of model call parts together with request and response metadata when available.
|
|
19510
20273
|
*/
|
|
19511
|
-
declare function streamLanguageModelCall<TOOLS extends ToolSet, OUTPUT extends Output = Output>({
|
|
19512
|
-
model,
|
|
19513
|
-
tools,
|
|
19514
|
-
toolOrder,
|
|
19515
|
-
output,
|
|
19516
|
-
toolChoice,
|
|
19517
|
-
prompt,
|
|
19518
|
-
system,
|
|
19519
|
-
instructions,
|
|
19520
|
-
messages,
|
|
19521
|
-
allowSystemInMessages,
|
|
19522
|
-
download,
|
|
19523
|
-
abortSignal,
|
|
19524
|
-
headers,
|
|
19525
|
-
includeRawChunks,
|
|
19526
|
-
providerOptions,
|
|
19527
|
-
repairToolCall,
|
|
19528
|
-
refineToolInput,
|
|
19529
|
-
executeLanguageModelCallInTelemetryContext,
|
|
19530
|
-
callId,
|
|
19531
|
-
toolsContext,
|
|
19532
|
-
experimental_sandbox: sandbox,
|
|
19533
|
-
_internal: {
|
|
19534
|
-
generateId,
|
|
19535
|
-
generateCallId,
|
|
19536
|
-
now
|
|
19537
|
-
},
|
|
19538
|
-
onStart,
|
|
19539
|
-
onLanguageModelCallStart,
|
|
19540
|
-
onLanguageModelCallEnd,
|
|
19541
|
-
...callSettings
|
|
19542
|
-
}: {
|
|
20274
|
+
declare function streamLanguageModelCall<TOOLS extends ToolSet, OUTPUT extends Output = Output>({ model, tools, toolOrder, output, toolChoice, prompt, system, instructions, messages, allowSystemInMessages, download, abortSignal, headers, includeRawChunks, providerOptions, repairToolCall, refineToolInput, executeLanguageModelCallInTelemetryContext, callId, toolsContext, experimental_sandbox: sandbox, _internal: { generateId, generateCallId, now }, onStart, onLanguageModelCallStart, onLanguageModelCallEnd, ...callSettings }: {
|
|
19543
20275
|
model: LanguageModel;
|
|
19544
20276
|
tools?: TOOLS;
|
|
19545
20277
|
toolOrder?: ToolOrder<TOOLS>;
|
|
@@ -19592,10 +20324,7 @@ declare const symbol$i: unique symbol;
|
|
|
19592
20324
|
declare class InvalidStreamPartError extends AISDKError {
|
|
19593
20325
|
private readonly [symbol$i];
|
|
19594
20326
|
readonly chunk: LanguageModelStreamPart<any>;
|
|
19595
|
-
constructor({
|
|
19596
|
-
chunk,
|
|
19597
|
-
message
|
|
19598
|
-
}: {
|
|
20327
|
+
constructor({ chunk, message }: {
|
|
19599
20328
|
chunk: LanguageModelStreamPart<any>;
|
|
19600
20329
|
message: string;
|
|
19601
20330
|
});
|
|
@@ -19605,9 +20334,7 @@ declare const symbol$h: unique symbol;
|
|
|
19605
20334
|
declare class InvalidToolApprovalError extends AISDKError {
|
|
19606
20335
|
private readonly [symbol$h];
|
|
19607
20336
|
readonly approvalId: string;
|
|
19608
|
-
constructor({
|
|
19609
|
-
approvalId
|
|
19610
|
-
}: {
|
|
20337
|
+
constructor({ approvalId }: {
|
|
19611
20338
|
approvalId: string;
|
|
19612
20339
|
});
|
|
19613
20340
|
static isInstance(error: unknown): error is InvalidToolApprovalError;
|
|
@@ -19617,11 +20344,7 @@ declare class InvalidToolApprovalSignatureError extends AISDKError {
|
|
|
19617
20344
|
private readonly [symbol$g];
|
|
19618
20345
|
readonly approvalId: string;
|
|
19619
20346
|
readonly toolCallId: string;
|
|
19620
|
-
constructor({
|
|
19621
|
-
approvalId,
|
|
19622
|
-
toolCallId,
|
|
19623
|
-
reason
|
|
19624
|
-
}: {
|
|
20347
|
+
constructor({ approvalId, toolCallId, reason }: {
|
|
19625
20348
|
approvalId: string;
|
|
19626
20349
|
toolCallId: string;
|
|
19627
20350
|
reason: string;
|
|
@@ -19633,10 +20356,7 @@ declare class ToolCallNotFoundForApprovalError extends AISDKError {
|
|
|
19633
20356
|
private readonly [symbol$f];
|
|
19634
20357
|
readonly toolCallId: string;
|
|
19635
20358
|
readonly approvalId: string;
|
|
19636
|
-
constructor({
|
|
19637
|
-
toolCallId,
|
|
19638
|
-
approvalId
|
|
19639
|
-
}: {
|
|
20359
|
+
constructor({ toolCallId, approvalId }: {
|
|
19640
20360
|
toolCallId: string;
|
|
19641
20361
|
approvalId: string;
|
|
19642
20362
|
});
|
|
@@ -19646,9 +20366,7 @@ declare const symbol$e: unique symbol;
|
|
|
19646
20366
|
declare class MissingToolResultsError extends AISDKError {
|
|
19647
20367
|
private readonly [symbol$e];
|
|
19648
20368
|
readonly toolCallIds: string[];
|
|
19649
|
-
constructor({
|
|
19650
|
-
toolCallIds
|
|
19651
|
-
}: {
|
|
20369
|
+
constructor({ toolCallIds }: {
|
|
19652
20370
|
toolCallIds: string[];
|
|
19653
20371
|
});
|
|
19654
20372
|
static isInstance(error: unknown): error is MissingToolResultsError;
|
|
@@ -19666,11 +20384,7 @@ declare class NoImageGeneratedError extends AISDKError {
|
|
|
19666
20384
|
* The response metadata for each call.
|
|
19667
20385
|
*/
|
|
19668
20386
|
readonly responses: Array<ImageModelResponseMetadata> | undefined;
|
|
19669
|
-
constructor({
|
|
19670
|
-
message,
|
|
19671
|
-
cause,
|
|
19672
|
-
responses
|
|
19673
|
-
}: {
|
|
20387
|
+
constructor({ message, cause, responses }: {
|
|
19674
20388
|
message?: string;
|
|
19675
20389
|
cause?: Error;
|
|
19676
20390
|
responses?: Array<ImageModelResponseMetadata>;
|
|
@@ -19707,14 +20421,7 @@ declare class NoObjectGeneratedError extends AISDKError {
|
|
|
19707
20421
|
* Reason why the model finished generating a response.
|
|
19708
20422
|
*/
|
|
19709
20423
|
readonly finishReason: FinishReason | undefined;
|
|
19710
|
-
constructor({
|
|
19711
|
-
message,
|
|
19712
|
-
cause,
|
|
19713
|
-
text: text$1,
|
|
19714
|
-
response,
|
|
19715
|
-
usage,
|
|
19716
|
-
finishReason
|
|
19717
|
-
}: {
|
|
20424
|
+
constructor({ message, cause, text: text$1, response, usage, finishReason }: {
|
|
19718
20425
|
message?: string;
|
|
19719
20426
|
cause?: Error;
|
|
19720
20427
|
text?: string;
|
|
@@ -19730,10 +20437,7 @@ declare const symbol$b: unique symbol;
|
|
|
19730
20437
|
*/
|
|
19731
20438
|
declare class NoOutputGeneratedError extends AISDKError {
|
|
19732
20439
|
private readonly [symbol$b];
|
|
19733
|
-
constructor({
|
|
19734
|
-
message,
|
|
19735
|
-
cause
|
|
19736
|
-
}?: {
|
|
20440
|
+
constructor({ message, cause }?: {
|
|
19737
20441
|
message?: string;
|
|
19738
20442
|
cause?: Error;
|
|
19739
20443
|
});
|
|
@@ -19822,11 +20526,7 @@ declare const symbol$7: unique symbol;
|
|
|
19822
20526
|
declare class NoVideoGeneratedError extends AISDKError {
|
|
19823
20527
|
private readonly [symbol$7];
|
|
19824
20528
|
readonly responses: Array<VideoModelResponseMetadata>;
|
|
19825
|
-
constructor({
|
|
19826
|
-
message,
|
|
19827
|
-
cause,
|
|
19828
|
-
responses
|
|
19829
|
-
}: {
|
|
20529
|
+
constructor({ message, cause, responses }: {
|
|
19830
20530
|
message?: string;
|
|
19831
20531
|
cause?: unknown;
|
|
19832
20532
|
responses: Array<VideoModelResponseMetadata>;
|
|
@@ -19851,11 +20551,7 @@ declare const symbol$6: unique symbol;
|
|
|
19851
20551
|
declare class ToolCallRepairError extends AISDKError {
|
|
19852
20552
|
private readonly [symbol$6];
|
|
19853
20553
|
readonly originalError: NoSuchToolError | InvalidToolInputError;
|
|
19854
|
-
constructor({
|
|
19855
|
-
cause,
|
|
19856
|
-
originalError,
|
|
19857
|
-
message
|
|
19858
|
-
}: {
|
|
20554
|
+
constructor({ cause, originalError, message }: {
|
|
19859
20555
|
message?: string;
|
|
19860
20556
|
cause: unknown;
|
|
19861
20557
|
originalError: NoSuchToolError | InvalidToolInputError;
|
|
@@ -19896,11 +20592,7 @@ declare class UIMessageStreamError extends AISDKError {
|
|
|
19896
20592
|
* The ID associated with the failing chunk (part ID or toolCallId).
|
|
19897
20593
|
*/
|
|
19898
20594
|
readonly chunkId: string;
|
|
19899
|
-
constructor({
|
|
19900
|
-
chunkType,
|
|
19901
|
-
chunkId,
|
|
19902
|
-
message
|
|
19903
|
-
}: {
|
|
20595
|
+
constructor({ chunkType, chunkId, message }: {
|
|
19904
20596
|
chunkType: string;
|
|
19905
20597
|
chunkId: string;
|
|
19906
20598
|
message: string;
|
|
@@ -19911,11 +20603,7 @@ declare const symbol$4: unique symbol;
|
|
|
19911
20603
|
declare class InvalidDataContentError extends AISDKError {
|
|
19912
20604
|
private readonly [symbol$4];
|
|
19913
20605
|
readonly content: unknown;
|
|
19914
|
-
constructor({
|
|
19915
|
-
content,
|
|
19916
|
-
cause,
|
|
19917
|
-
message
|
|
19918
|
-
}: {
|
|
20606
|
+
constructor({ content, cause, message }: {
|
|
19919
20607
|
content: unknown;
|
|
19920
20608
|
cause?: unknown;
|
|
19921
20609
|
message?: string;
|
|
@@ -19926,10 +20614,7 @@ declare const symbol$3: unique symbol;
|
|
|
19926
20614
|
declare class InvalidMessageRoleError extends AISDKError {
|
|
19927
20615
|
private readonly [symbol$3];
|
|
19928
20616
|
readonly role: string;
|
|
19929
|
-
constructor({
|
|
19930
|
-
role,
|
|
19931
|
-
message
|
|
19932
|
-
}: {
|
|
20617
|
+
constructor({ role, message }: {
|
|
19933
20618
|
role: string;
|
|
19934
20619
|
message?: string;
|
|
19935
20620
|
});
|
|
@@ -19939,10 +20624,7 @@ declare const symbol$2: unique symbol;
|
|
|
19939
20624
|
declare class MessageConversionError extends AISDKError {
|
|
19940
20625
|
private readonly [symbol$2];
|
|
19941
20626
|
readonly originalMessage: Omit<UIMessage, 'id'>;
|
|
19942
|
-
constructor({
|
|
19943
|
-
originalMessage,
|
|
19944
|
-
message
|
|
19945
|
-
}: {
|
|
20627
|
+
constructor({ originalMessage, message }: {
|
|
19946
20628
|
originalMessage: Omit<UIMessage, 'id'>;
|
|
19947
20629
|
message: string;
|
|
19948
20630
|
});
|
|
@@ -19955,11 +20637,7 @@ declare class RetryError extends AISDKError {
|
|
|
19955
20637
|
readonly reason: RetryErrorReason;
|
|
19956
20638
|
readonly lastError: unknown;
|
|
19957
20639
|
readonly errors: Array<unknown>;
|
|
19958
|
-
constructor({
|
|
19959
|
-
message,
|
|
19960
|
-
reason,
|
|
19961
|
-
errors
|
|
19962
|
-
}: {
|
|
20640
|
+
constructor({ message, reason, errors }: {
|
|
19963
20641
|
message: string;
|
|
19964
20642
|
reason: RetryErrorReason;
|
|
19965
20643
|
errors: Array<unknown>;
|
|
@@ -19975,10 +20653,7 @@ type ActiveToolSubset<TOOLS extends ToolSet | undefined, ACTIVE_TOOL_NAMES exten
|
|
|
19975
20653
|
* @param activeTools - The active tools to include.
|
|
19976
20654
|
* @returns The filtered tools.
|
|
19977
20655
|
*/
|
|
19978
|
-
declare function filterActiveTools<TOOLS extends ToolSet | undefined, ACTIVE_TOOL_NAMES extends ActiveTools<NonNullable<TOOLS>>>({
|
|
19979
|
-
tools,
|
|
19980
|
-
activeTools
|
|
19981
|
-
}: {
|
|
20656
|
+
declare function filterActiveTools<TOOLS extends ToolSet | undefined, ACTIVE_TOOL_NAMES extends ActiveTools<NonNullable<TOOLS>>>({ tools, activeTools }: {
|
|
19982
20657
|
tools: TOOLS;
|
|
19983
20658
|
activeTools: ACTIVE_TOOL_NAMES;
|
|
19984
20659
|
}): ActiveToolSubset<TOOLS, ACTIVE_TOOL_NAMES>;
|
|
@@ -19992,12 +20667,7 @@ declare function filterActiveTools<TOOLS extends ToolSet | undefined, ACTIVE_TOO
|
|
|
19992
20667
|
*
|
|
19993
20668
|
* @returns The pruned list of model messages.
|
|
19994
20669
|
*/
|
|
19995
|
-
declare function pruneMessages({
|
|
19996
|
-
messages,
|
|
19997
|
-
reasoning,
|
|
19998
|
-
toolCalls,
|
|
19999
|
-
emptyMessages
|
|
20000
|
-
}: {
|
|
20670
|
+
declare function pruneMessages({ messages, reasoning, toolCalls, emptyMessages }: {
|
|
20001
20671
|
messages: ModelMessage[];
|
|
20002
20672
|
reasoning?: 'all' | 'before-last-message' | 'none';
|
|
20003
20673
|
toolCalls?: 'all' | 'before-last-message' | `before-last-${number}-messages` | 'none' | Array<{
|
|
@@ -20022,13 +20692,7 @@ type ChunkDetector = (buffer: string) => string | undefined | null;
|
|
|
20022
20692
|
*
|
|
20023
20693
|
* @returns A transform stream that smooths text streaming output.
|
|
20024
20694
|
*/
|
|
20025
|
-
declare function smoothStream<TOOLS extends ToolSet>({
|
|
20026
|
-
delayInMs,
|
|
20027
|
-
chunking,
|
|
20028
|
-
_internal: {
|
|
20029
|
-
delay
|
|
20030
|
-
}
|
|
20031
|
-
}?: {
|
|
20695
|
+
declare function smoothStream<TOOLS extends ToolSet>({ delayInMs, chunking, _internal: { delay } }?: {
|
|
20032
20696
|
delayInMs?: number | null;
|
|
20033
20697
|
chunking?: 'word' | 'line' | RegExp | ChunkDetector | Intl.Segmenter;
|
|
20034
20698
|
/**
|
|
@@ -20115,19 +20779,7 @@ type GenerateImagePrompt = string | {
|
|
|
20115
20779
|
*
|
|
20116
20780
|
* @returns A result object that contains the generated images.
|
|
20117
20781
|
*/
|
|
20118
|
-
declare function generateImage({
|
|
20119
|
-
model: modelArg,
|
|
20120
|
-
prompt: promptArg,
|
|
20121
|
-
n,
|
|
20122
|
-
maxImagesPerCall,
|
|
20123
|
-
size,
|
|
20124
|
-
aspectRatio,
|
|
20125
|
-
seed,
|
|
20126
|
-
providerOptions,
|
|
20127
|
-
maxRetries: maxRetriesArg,
|
|
20128
|
-
abortSignal,
|
|
20129
|
-
headers
|
|
20130
|
-
}: {
|
|
20782
|
+
declare function generateImage({ model: modelArg, prompt: promptArg, n, maxImagesPerCall, size, aspectRatio, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers }: {
|
|
20131
20783
|
/**
|
|
20132
20784
|
* The image model to use.
|
|
20133
20785
|
*/
|
|
@@ -20317,7 +20969,7 @@ type RepairTextFunction = (options: {
|
|
|
20317
20969
|
*
|
|
20318
20970
|
* @deprecated Use `generateText` with an `output` setting instead.
|
|
20319
20971
|
*/
|
|
20320
|
-
declare function generateObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue$3>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' =
|
|
20972
|
+
declare function generateObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue$3>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<LanguageModelCallOptions, 'stopSequences'> & Omit<RequestOptions, 'timeout'> & Prompt & (OUTPUT extends 'enum' ? {
|
|
20321
20973
|
/**
|
|
20322
20974
|
* The enum values that the model should use.
|
|
20323
20975
|
*/
|
|
@@ -20441,11 +21093,7 @@ declare function generateObject<SCHEMA extends FlexibleSchema<unknown> = Flexibl
|
|
|
20441
21093
|
* @param options.onError - Optional callback to handle errors that occur during consumption.
|
|
20442
21094
|
* @returns A promise that resolves when the stream is fully consumed.
|
|
20443
21095
|
*/
|
|
20444
|
-
declare function consumeStream({
|
|
20445
|
-
stream,
|
|
20446
|
-
onError,
|
|
20447
|
-
abortSignal
|
|
20448
|
-
}: {
|
|
21096
|
+
declare function consumeStream({ stream, onError, abortSignal }: {
|
|
20449
21097
|
stream: ReadableStream;
|
|
20450
21098
|
onError?: (error: unknown) => void;
|
|
20451
21099
|
abortSignal?: AbortSignal;
|
|
@@ -20471,10 +21119,7 @@ declare function cosineSimilarity(vector1: number[], vector2: number[]): number;
|
|
|
20471
21119
|
*/
|
|
20472
21120
|
declare function createDownload(options?: {
|
|
20473
21121
|
maxBytes?: number;
|
|
20474
|
-
}): ({
|
|
20475
|
-
url,
|
|
20476
|
-
abortSignal
|
|
20477
|
-
}: {
|
|
21122
|
+
}): ({ url, abortSignal }: {
|
|
20478
21123
|
url: URL;
|
|
20479
21124
|
abortSignal?: AbortSignal;
|
|
20480
21125
|
}) => Promise<{
|
|
@@ -20513,12 +21158,7 @@ declare class SerialJobExecutor {
|
|
|
20513
21158
|
* @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
20514
21159
|
* @returns A ReadableStream that emits the provided values
|
|
20515
21160
|
*/
|
|
20516
|
-
declare function simulateReadableStream<T>({
|
|
20517
|
-
chunks,
|
|
20518
|
-
initialDelayInMs,
|
|
20519
|
-
chunkDelayInMs,
|
|
20520
|
-
_internal
|
|
20521
|
-
}: {
|
|
21161
|
+
declare function simulateReadableStream<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal }: {
|
|
20522
21162
|
chunks: T[];
|
|
20523
21163
|
initialDelayInMs?: number | null;
|
|
20524
21164
|
chunkDelayInMs?: number | null;
|
|
@@ -20726,7 +21366,7 @@ type StreamObjectOnFinishCallback<RESULT> = (event: {
|
|
|
20726
21366
|
*
|
|
20727
21367
|
* @deprecated Use `streamText` with an `output` setting instead.
|
|
20728
21368
|
*/
|
|
20729
|
-
declare function streamObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue$3>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' =
|
|
21369
|
+
declare function streamObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue$3>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<LanguageModelCallOptions, 'stopSequences'> & Omit<RequestOptions, 'timeout'> & Prompt & (OUTPUT extends 'enum' ? {
|
|
20730
21370
|
/**
|
|
20731
21371
|
* The enum values that the model should use.
|
|
20732
21372
|
*/
|
|
@@ -20893,19 +21533,7 @@ interface SpeechResult {
|
|
|
20893
21533
|
*
|
|
20894
21534
|
* @returns A result object that contains the generated audio data.
|
|
20895
21535
|
*/
|
|
20896
|
-
declare function generateSpeech({
|
|
20897
|
-
model,
|
|
20898
|
-
text: text$1,
|
|
20899
|
-
voice,
|
|
20900
|
-
outputFormat,
|
|
20901
|
-
instructions,
|
|
20902
|
-
speed,
|
|
20903
|
-
language,
|
|
20904
|
-
providerOptions,
|
|
20905
|
-
maxRetries: maxRetriesArg,
|
|
20906
|
-
abortSignal,
|
|
20907
|
-
headers
|
|
20908
|
-
}: {
|
|
21536
|
+
declare function generateSpeech({ model, text: text$1, voice, outputFormat, instructions, speed, language, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers }: {
|
|
20909
21537
|
/**
|
|
20910
21538
|
* The speech model to use.
|
|
20911
21539
|
*/
|
|
@@ -21049,27 +21677,7 @@ type GenerateVideoWebhookFactory = () => PromiseLike<{
|
|
|
21049
21677
|
url: string;
|
|
21050
21678
|
received: PromiseLike<VideoModelV4OperationWebhook>;
|
|
21051
21679
|
}>;
|
|
21052
|
-
declare function experimental_generateVideo({
|
|
21053
|
-
model: modelArg,
|
|
21054
|
-
prompt: promptArg,
|
|
21055
|
-
n,
|
|
21056
|
-
maxVideosPerCall,
|
|
21057
|
-
aspectRatio,
|
|
21058
|
-
resolution,
|
|
21059
|
-
duration,
|
|
21060
|
-
fps,
|
|
21061
|
-
seed,
|
|
21062
|
-
frameImages,
|
|
21063
|
-
inputReferences,
|
|
21064
|
-
generateAudio,
|
|
21065
|
-
providerOptions,
|
|
21066
|
-
maxRetries: maxRetriesArg,
|
|
21067
|
-
abortSignal,
|
|
21068
|
-
headers,
|
|
21069
|
-
download: downloadFn,
|
|
21070
|
-
poll,
|
|
21071
|
-
webhook
|
|
21072
|
-
}: {
|
|
21680
|
+
declare function experimental_generateVideo({ model: modelArg, prompt: promptArg, n, maxVideosPerCall, aspectRatio, resolution, duration, fps, seed, frameImages, inputReferences, generateAudio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn, poll, webhook }: {
|
|
21073
21681
|
/**
|
|
21074
21682
|
* The video model to use.
|
|
21075
21683
|
*/
|
|
@@ -21199,9 +21807,7 @@ declare function experimental_generateVideo({
|
|
|
21199
21807
|
/**
|
|
21200
21808
|
* Applies default settings for an embedding model.
|
|
21201
21809
|
*/
|
|
21202
|
-
declare function defaultEmbeddingSettingsMiddleware({
|
|
21203
|
-
settings
|
|
21204
|
-
}: {
|
|
21810
|
+
declare function defaultEmbeddingSettingsMiddleware({ settings }: {
|
|
21205
21811
|
settings: Partial<{
|
|
21206
21812
|
headers?: EmbeddingModelV4CallOptions['headers'];
|
|
21207
21813
|
providerOptions?: EmbeddingModelV4CallOptions['providerOptions'];
|
|
@@ -21211,9 +21817,7 @@ declare function defaultEmbeddingSettingsMiddleware({
|
|
|
21211
21817
|
* Applies default instructions to a language model when a call does not
|
|
21212
21818
|
* already contain a system message.
|
|
21213
21819
|
*/
|
|
21214
|
-
declare function defaultInstructionsMiddleware({
|
|
21215
|
-
instructions
|
|
21216
|
-
}: {
|
|
21820
|
+
declare function defaultInstructionsMiddleware({ instructions }: {
|
|
21217
21821
|
/**
|
|
21218
21822
|
* Default instructions to prepend to calls that do not contain a system
|
|
21219
21823
|
* message.
|
|
@@ -21223,9 +21827,7 @@ declare function defaultInstructionsMiddleware({
|
|
|
21223
21827
|
/**
|
|
21224
21828
|
* Applies default settings for a language model.
|
|
21225
21829
|
*/
|
|
21226
|
-
declare function defaultSettingsMiddleware({
|
|
21227
|
-
settings
|
|
21228
|
-
}: {
|
|
21830
|
+
declare function defaultSettingsMiddleware({ settings }: {
|
|
21229
21831
|
settings: Partial<{
|
|
21230
21832
|
maxOutputTokens?: LanguageModelV4CallOptions['maxOutputTokens'];
|
|
21231
21833
|
temperature?: LanguageModelV4CallOptions['temperature'];
|
|
@@ -21269,11 +21871,7 @@ declare function extractJsonMiddleware(options?: {
|
|
|
21269
21871
|
* @param separator - The separator to use between reasoning and text sections.
|
|
21270
21872
|
* @param startWithReasoning - Whether to start with reasoning tokens.
|
|
21271
21873
|
*/
|
|
21272
|
-
declare function extractReasoningMiddleware({
|
|
21273
|
-
tagName,
|
|
21274
|
-
separator,
|
|
21275
|
-
startWithReasoning
|
|
21276
|
-
}: {
|
|
21874
|
+
declare function extractReasoningMiddleware({ tagName, separator, startWithReasoning }: {
|
|
21277
21875
|
tagName: string;
|
|
21278
21876
|
separator?: string;
|
|
21279
21877
|
startWithReasoning?: boolean;
|
|
@@ -21305,11 +21903,7 @@ declare function simulateStreamingMiddleware(): LanguageModelMiddleware;
|
|
|
21305
21903
|
* });
|
|
21306
21904
|
* ```
|
|
21307
21905
|
*/
|
|
21308
|
-
declare function addToolInputExamplesMiddleware({
|
|
21309
|
-
prefix,
|
|
21310
|
-
format,
|
|
21311
|
-
remove
|
|
21312
|
-
}?: {
|
|
21906
|
+
declare function addToolInputExamplesMiddleware({ prefix, format, remove }?: {
|
|
21313
21907
|
/**
|
|
21314
21908
|
* A prefix to prepend before the examples.
|
|
21315
21909
|
*/
|
|
@@ -21340,12 +21934,7 @@ declare function addToolInputExamplesMiddleware({
|
|
|
21340
21934
|
* @param options.providerId - Optional custom provider ID to override the original model's provider ID.
|
|
21341
21935
|
* @returns A new LanguageModelV4 instance with middleware applied.
|
|
21342
21936
|
*/
|
|
21343
|
-
declare const wrapLanguageModel$1: ({
|
|
21344
|
-
model: inputModel,
|
|
21345
|
-
middleware: middlewareArg,
|
|
21346
|
-
modelId,
|
|
21347
|
-
providerId
|
|
21348
|
-
}: {
|
|
21937
|
+
declare const wrapLanguageModel$1: ({ model: inputModel, middleware: middlewareArg, modelId, providerId }: {
|
|
21349
21938
|
model: LanguageModelV2$1 | LanguageModelV3$1 | LanguageModelV4;
|
|
21350
21939
|
middleware: LanguageModelMiddleware | LanguageModelMiddleware[];
|
|
21351
21940
|
modelId?: string;
|
|
@@ -21363,12 +21952,7 @@ declare const wrapLanguageModel$1: ({
|
|
|
21363
21952
|
* @param options.providerId - Optional custom provider ID to override the original model's provider ID.
|
|
21364
21953
|
* @returns A new EmbeddingModelV4 instance with middleware applied.
|
|
21365
21954
|
*/
|
|
21366
|
-
declare const wrapEmbeddingModel: ({
|
|
21367
|
-
model: inputModel,
|
|
21368
|
-
middleware: middlewareArg,
|
|
21369
|
-
modelId,
|
|
21370
|
-
providerId
|
|
21371
|
-
}: {
|
|
21955
|
+
declare const wrapEmbeddingModel: ({ model: inputModel, middleware: middlewareArg, modelId, providerId }: {
|
|
21372
21956
|
model: EmbeddingModelV3 | EmbeddingModelV4;
|
|
21373
21957
|
middleware: EmbeddingModelMiddleware | EmbeddingModelMiddleware[];
|
|
21374
21958
|
modelId?: string;
|
|
@@ -21386,12 +21970,7 @@ declare const wrapEmbeddingModel: ({
|
|
|
21386
21970
|
* @param options.providerId - Optional custom provider ID to override the original model's provider ID.
|
|
21387
21971
|
* @returns A new ImageModelV4 instance with middleware applied.
|
|
21388
21972
|
*/
|
|
21389
|
-
declare const wrapImageModel: ({
|
|
21390
|
-
model: inputModel,
|
|
21391
|
-
middleware: middlewareArg,
|
|
21392
|
-
modelId,
|
|
21393
|
-
providerId
|
|
21394
|
-
}: {
|
|
21973
|
+
declare const wrapImageModel: ({ model: inputModel, middleware: middlewareArg, modelId, providerId }: {
|
|
21395
21974
|
model: ImageModelV2 | ImageModelV3 | ImageModelV4;
|
|
21396
21975
|
middleware: ImageModelMiddleware | ImageModelMiddleware[];
|
|
21397
21976
|
modelId?: string;
|
|
@@ -21409,11 +21988,7 @@ declare const wrapImageModel: ({
|
|
|
21409
21988
|
* @param options.imageModelMiddleware - Optional middleware to be applied to all image models from the provider. When multiple middlewares are provided, the first middleware will transform the input first, and the last middleware will be wrapped directly around the model.
|
|
21410
21989
|
* @returns A new ProviderV4 instance with middleware applied to all language models.
|
|
21411
21990
|
*/
|
|
21412
|
-
declare function wrapProvider({
|
|
21413
|
-
provider,
|
|
21414
|
-
languageModelMiddleware,
|
|
21415
|
-
imageModelMiddleware
|
|
21416
|
-
}: {
|
|
21991
|
+
declare function wrapProvider({ provider, languageModelMiddleware, imageModelMiddleware }: {
|
|
21417
21992
|
provider: ProviderV4 | ProviderV3 | ProviderV2;
|
|
21418
21993
|
languageModelMiddleware: LanguageModelMiddleware | LanguageModelMiddleware[];
|
|
21419
21994
|
imageModelMiddleware?: ImageModelMiddleware | ImageModelMiddleware[];
|
|
@@ -21452,10 +22027,7 @@ type RealtimeClientEvent = RealtimeModelV4ClientEvent;
|
|
|
21452
22027
|
type RealtimeServerEvent = RealtimeModelV4ServerEvent;
|
|
21453
22028
|
type RealtimeSessionConfig = RealtimeModelV4SessionConfig;
|
|
21454
22029
|
type RealtimeToolDefinition = RealtimeModelV4ToolDefinition;
|
|
21455
|
-
declare function getRealtimeToolDefinitions<TOOLS extends ToolSet>({
|
|
21456
|
-
tools,
|
|
21457
|
-
toolsContext
|
|
21458
|
-
}: {
|
|
22030
|
+
declare function getRealtimeToolDefinitions<TOOLS extends ToolSet>({ tools, toolsContext }: {
|
|
21459
22031
|
tools: TOOLS;
|
|
21460
22032
|
toolsContext?: InferToolSetContext<TOOLS>;
|
|
21461
22033
|
}): Promise<RealtimeToolDefinition[]>;
|
|
@@ -21560,18 +22132,7 @@ type RealtimeSetupResponse = {
|
|
|
21560
22132
|
*
|
|
21561
22133
|
* @throws {NoSuchModelError} Throws when a requested model is not found and no fallback provider is available.
|
|
21562
22134
|
*/
|
|
21563
|
-
declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModel>, EMBEDDING_MODELS extends Record<string, EmbeddingModel>, IMAGE_MODELS extends Record<string, ImageModel>, TRANSCRIPTION_MODELS extends Record<string, TranscriptionModel>, SPEECH_MODELS extends Record<string, SpeechModel>, RERANKING_MODELS extends Record<string, RerankingModel>, VIDEO_MODELS extends Record<string, VideoModel>, FILES extends FilesV4 | undefined = undefined, SKILLS extends SkillsV4 | undefined = undefined, FALLBACK extends ProviderV2 | ProviderV3 | ProviderV4 | undefined = undefined>({
|
|
21564
|
-
languageModels,
|
|
21565
|
-
embeddingModels,
|
|
21566
|
-
imageModels,
|
|
21567
|
-
transcriptionModels,
|
|
21568
|
-
speechModels,
|
|
21569
|
-
rerankingModels,
|
|
21570
|
-
videoModels,
|
|
21571
|
-
files,
|
|
21572
|
-
skills,
|
|
21573
|
-
fallbackProvider: fallbackProviderArg
|
|
21574
|
-
}: {
|
|
22135
|
+
declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModel>, EMBEDDING_MODELS extends Record<string, EmbeddingModel>, IMAGE_MODELS extends Record<string, ImageModel>, TRANSCRIPTION_MODELS extends Record<string, TranscriptionModel>, SPEECH_MODELS extends Record<string, SpeechModel>, RERANKING_MODELS extends Record<string, RerankingModel>, VIDEO_MODELS extends Record<string, VideoModel>, FILES extends FilesV4 | undefined = undefined, SKILLS extends SkillsV4 | undefined = undefined, FALLBACK extends ProviderV2 | ProviderV3 | ProviderV4 | undefined = undefined>({ languageModels, embeddingModels, imageModels, transcriptionModels, speechModels, rerankingModels, videoModels, files, skills, fallbackProvider: fallbackProviderArg }: {
|
|
21575
22136
|
languageModels?: LANGUAGE_MODELS;
|
|
21576
22137
|
embeddingModels?: EMBEDDING_MODELS;
|
|
21577
22138
|
imageModels?: IMAGE_MODELS;
|
|
@@ -21613,13 +22174,7 @@ declare class NoSuchProviderError extends NoSuchModelError {
|
|
|
21613
22174
|
private readonly [symbol];
|
|
21614
22175
|
readonly providerId: string;
|
|
21615
22176
|
readonly availableProviders: string[];
|
|
21616
|
-
constructor({
|
|
21617
|
-
modelId,
|
|
21618
|
-
modelType,
|
|
21619
|
-
providerId,
|
|
21620
|
-
availableProviders,
|
|
21621
|
-
message
|
|
21622
|
-
}: {
|
|
22177
|
+
constructor({ modelId, modelType, providerId, availableProviders, message }: {
|
|
21623
22178
|
modelId: string;
|
|
21624
22179
|
modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel';
|
|
21625
22180
|
providerId: string;
|
|
@@ -21676,11 +22231,7 @@ interface ProviderRegistryProvider<PROVIDERS extends Record<string, ProviderV4 |
|
|
|
21676
22231
|
* @param options.imageModelMiddleware - Optional middleware to be applied to all image models from the registry. When multiple middlewares are provided, the first middleware will transform the input first, and the last middleware will be wrapped directly around the model.
|
|
21677
22232
|
* @returns A new ProviderRegistryProvider instance that provides access to all registered providers with optional middleware applied to language and image models.
|
|
21678
22233
|
*/
|
|
21679
|
-
declare function createProviderRegistry<PROVIDERS extends Record<string, ProviderV4 | ProviderV3>, SEPARATOR extends string = ':'>(providers: PROVIDERS, {
|
|
21680
|
-
separator,
|
|
21681
|
-
languageModelMiddleware,
|
|
21682
|
-
imageModelMiddleware
|
|
21683
|
-
}?: {
|
|
22234
|
+
declare function createProviderRegistry<PROVIDERS extends Record<string, ProviderV4 | ProviderV3>, SEPARATOR extends string = ':'>(providers: PROVIDERS, { separator, languageModelMiddleware, imageModelMiddleware }?: {
|
|
21684
22235
|
separator?: SEPARATOR;
|
|
21685
22236
|
languageModelMiddleware?: LanguageModelMiddleware | LanguageModelMiddleware[];
|
|
21686
22237
|
imageModelMiddleware?: ImageModelMiddleware | ImageModelMiddleware[];
|
|
@@ -21765,25 +22316,7 @@ interface RerankResult<VALUE> {
|
|
|
21765
22316
|
*
|
|
21766
22317
|
* @returns A result object that contains the reranked documents, the reranked indices, and additional information.
|
|
21767
22318
|
*/
|
|
21768
|
-
declare function rerank<VALUE extends JSONObject$2 | string>({
|
|
21769
|
-
model: modelArg,
|
|
21770
|
-
documents,
|
|
21771
|
-
query,
|
|
21772
|
-
topN,
|
|
21773
|
-
maxRetries: maxRetriesArg,
|
|
21774
|
-
abortSignal,
|
|
21775
|
-
headers,
|
|
21776
|
-
providerOptions,
|
|
21777
|
-
experimental_telemetry,
|
|
21778
|
-
telemetry,
|
|
21779
|
-
onStart,
|
|
21780
|
-
experimental_onStart,
|
|
21781
|
-
onEnd,
|
|
21782
|
-
experimental_onEnd,
|
|
21783
|
-
_internal: {
|
|
21784
|
-
generateCallId
|
|
21785
|
-
}
|
|
21786
|
-
}: {
|
|
22319
|
+
declare function rerank<VALUE extends JSONObject$2 | string>({ model: modelArg, documents, query, topN, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry, telemetry, onStart, experimental_onStart, onEnd, experimental_onEnd, _internal: { generateCallId } }: {
|
|
21787
22320
|
/**
|
|
21788
22321
|
* The reranking model to use.
|
|
21789
22322
|
*/
|
|
@@ -21878,12 +22411,7 @@ declare function registerTelemetry(...integrations: Telemetry[]): void;
|
|
|
21878
22411
|
* @param options.stream - The text stream to send.
|
|
21879
22412
|
* @returns A Response object with the text stream body.
|
|
21880
22413
|
*/
|
|
21881
|
-
declare function createTextStreamResponse({
|
|
21882
|
-
status,
|
|
21883
|
-
statusText,
|
|
21884
|
-
headers,
|
|
21885
|
-
stream
|
|
21886
|
-
}: ResponseInit & {
|
|
22414
|
+
declare function createTextStreamResponse({ status, statusText, headers, stream }: ResponseInit & {
|
|
21887
22415
|
stream: ReadableStream<string>;
|
|
21888
22416
|
}): Response;
|
|
21889
22417
|
/**
|
|
@@ -21899,22 +22427,14 @@ declare function createTextStreamResponse({
|
|
|
21899
22427
|
* @param options.stream - The text stream to pipe.
|
|
21900
22428
|
* @returns A promise that resolves when the stream has been written.
|
|
21901
22429
|
*/
|
|
21902
|
-
declare function pipeTextStreamToResponse({
|
|
21903
|
-
response,
|
|
21904
|
-
status,
|
|
21905
|
-
statusText,
|
|
21906
|
-
headers,
|
|
21907
|
-
stream
|
|
21908
|
-
}: {
|
|
22430
|
+
declare function pipeTextStreamToResponse({ response, status, statusText, headers, stream }: {
|
|
21909
22431
|
response: ServerResponse;
|
|
21910
22432
|
stream: ReadableStream<string>;
|
|
21911
22433
|
} & ResponseInit): Promise<void>;
|
|
21912
22434
|
/**
|
|
21913
22435
|
* Converts a stream of `TextStreamPart` chunks into a stream of text deltas.
|
|
21914
22436
|
*/
|
|
21915
|
-
declare function toTextStream<TOOLS extends ToolSet = ToolSet>({
|
|
21916
|
-
stream
|
|
21917
|
-
}: {
|
|
22437
|
+
declare function toTextStream<TOOLS extends ToolSet = ToolSet>({ stream }: {
|
|
21918
22438
|
stream: ReadableStream<TextStreamPart<TOOLS>>;
|
|
21919
22439
|
}): ReadableStream<string>;
|
|
21920
22440
|
/**
|
|
@@ -21967,15 +22487,7 @@ interface TranscriptionResult {
|
|
|
21967
22487
|
*/
|
|
21968
22488
|
readonly providerMetadata: Record<string, JSONObject$2>;
|
|
21969
22489
|
}
|
|
21970
|
-
declare function transcribe({
|
|
21971
|
-
model,
|
|
21972
|
-
audio,
|
|
21973
|
-
providerOptions,
|
|
21974
|
-
maxRetries: maxRetriesArg,
|
|
21975
|
-
abortSignal,
|
|
21976
|
-
headers,
|
|
21977
|
-
download: downloadFn
|
|
21978
|
-
}: {
|
|
22490
|
+
declare function transcribe({ model, audio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn }: {
|
|
21979
22491
|
/**
|
|
21980
22492
|
* The transcription model to use.
|
|
21981
22493
|
*/
|
|
@@ -22111,18 +22623,7 @@ interface StreamTranscriptionResult {
|
|
|
22111
22623
|
*
|
|
22112
22624
|
* @returns A result object that contains the streaming transcript and final transcript metadata.
|
|
22113
22625
|
*/
|
|
22114
|
-
declare function streamTranscribe({
|
|
22115
|
-
model,
|
|
22116
|
-
audio,
|
|
22117
|
-
inputAudioFormat,
|
|
22118
|
-
providerOptions,
|
|
22119
|
-
abortSignal,
|
|
22120
|
-
headers,
|
|
22121
|
-
includeRawChunks,
|
|
22122
|
-
_internal: {
|
|
22123
|
-
currentDate
|
|
22124
|
-
}
|
|
22125
|
-
}: {
|
|
22626
|
+
declare function streamTranscribe({ model, audio, inputAudioFormat, providerOptions, abortSignal, headers, includeRawChunks, _internal: { currentDate } }: {
|
|
22126
22627
|
/**
|
|
22127
22628
|
* The transcription model to use.
|
|
22128
22629
|
*/
|
|
@@ -22308,21 +22809,7 @@ interface StreamTranslationResult {
|
|
|
22308
22809
|
*
|
|
22309
22810
|
* @returns A result object that contains the streaming translation and final translation metadata.
|
|
22310
22811
|
*/
|
|
22311
|
-
declare function streamTranslate({
|
|
22312
|
-
model,
|
|
22313
|
-
audio,
|
|
22314
|
-
inputAudioFormat,
|
|
22315
|
-
targetLanguage,
|
|
22316
|
-
sourceLanguage,
|
|
22317
|
-
outputAudioFormat,
|
|
22318
|
-
providerOptions,
|
|
22319
|
-
abortSignal,
|
|
22320
|
-
headers,
|
|
22321
|
-
includeRawChunks,
|
|
22322
|
-
_internal: {
|
|
22323
|
-
currentDate
|
|
22324
|
-
}
|
|
22325
|
-
}: {
|
|
22812
|
+
declare function streamTranslate({ model, audio, inputAudioFormat, targetLanguage, sourceLanguage, outputAudioFormat, providerOptions, abortSignal, headers, includeRawChunks, _internal: { currentDate } }: {
|
|
22326
22813
|
/**
|
|
22327
22814
|
* The speech translation model to use.
|
|
22328
22815
|
*/
|
|
@@ -22393,13 +22880,7 @@ interface UploadFileResult {
|
|
|
22393
22880
|
*
|
|
22394
22881
|
* @returns A result object containing the provider reference and optional metadata.
|
|
22395
22882
|
*/
|
|
22396
|
-
declare function uploadFile({
|
|
22397
|
-
api,
|
|
22398
|
-
data: dataArg,
|
|
22399
|
-
mediaType: mediaTypeArg,
|
|
22400
|
-
filename,
|
|
22401
|
-
providerOptions
|
|
22402
|
-
}: {
|
|
22883
|
+
declare function uploadFile({ api, data: dataArg, mediaType: mediaTypeArg, filename, providerOptions }: {
|
|
22403
22884
|
/**
|
|
22404
22885
|
* The files API interface to use for uploading.
|
|
22405
22886
|
* Can be a `FilesV4` instance or a `ProviderV4` instance with a `files()` method.
|
|
@@ -22428,29 +22909,24 @@ type UploadSkillFile = Omit<SkillsV4File, 'data'> & {
|
|
|
22428
22909
|
*/
|
|
22429
22910
|
data: SkillsV4File['data'] | Uint8Array | string;
|
|
22430
22911
|
};
|
|
22431
|
-
declare function uploadSkill({
|
|
22432
|
-
api,
|
|
22433
|
-
files,
|
|
22434
|
-
displayTitle,
|
|
22435
|
-
providerOptions
|
|
22436
|
-
}: {
|
|
22912
|
+
declare function uploadSkill({ api, files, displayTitle, providerOptions }: {
|
|
22437
22913
|
api: SkillsV4 | ProviderV4;
|
|
22438
22914
|
} & Omit<SkillsV4UploadSkillCallOptions, 'files'> & {
|
|
22439
22915
|
files: UploadSkillFile[];
|
|
22440
22916
|
}): Promise<UploadSkillResult>;
|
|
22441
22917
|
//#endregion
|
|
22442
22918
|
//#region src/opentelemetry-lib/instrumentation/aisdk/index.d.ts
|
|
22443
|
-
declare const wrapAISDK: (ai: typeof index_d_exports) => typeof index_d_exports;
|
|
22444
|
-
declare function wrapLanguageModel(languageModel: LanguageModelV4): LanguageModelV4;
|
|
22445
|
-
declare function wrapLanguageModel(languageModel: LanguageModelV3): LanguageModelV3;
|
|
22446
|
-
declare function wrapLanguageModel(languageModel: LanguageModelV2): LanguageModelV2;
|
|
22919
|
+
export declare const wrapAISDK: (ai: typeof index_d_exports) => typeof index_d_exports;
|
|
22920
|
+
export declare function wrapLanguageModel(languageModel: LanguageModelV4): LanguageModelV4;
|
|
22921
|
+
export declare function wrapLanguageModel(languageModel: LanguageModelV3): LanguageModelV3;
|
|
22922
|
+
export declare function wrapLanguageModel(languageModel: LanguageModelV2): LanguageModelV2;
|
|
22447
22923
|
//#endregion
|
|
22448
22924
|
//#region src/opentelemetry-lib/instrumentation/aisdk/v7-integration/index.d.ts
|
|
22449
22925
|
/**
|
|
22450
22926
|
* The AI SDK v7 diagnostics channel name. Every lifecycle event fires
|
|
22451
22927
|
* `{ type, event }` through this channel.
|
|
22452
22928
|
*/
|
|
22453
|
-
declare const AI_SDK_TELEMETRY_DIAGNOSTIC_CHANNEL = "aisdk:telemetry";
|
|
22929
|
+
export declare const AI_SDK_TELEMETRY_DIAGNOSTIC_CHANNEL = "aisdk:telemetry";
|
|
22454
22930
|
interface LaminarAiSdkTelemetryOptions {
|
|
22455
22931
|
/**
|
|
22456
22932
|
* When true, record prompt messages and response content on spans.
|
|
@@ -22478,7 +22954,7 @@ interface LaminarAiSdkTelemetryOptions {
|
|
|
22478
22954
|
* `Telemetry` interface from `ai` so users can pick up the integration even
|
|
22479
22955
|
* when they are on a narrower `ai` version that doesn't export it yet.
|
|
22480
22956
|
*/
|
|
22481
|
-
declare class LaminarAiSdkTelemetry {
|
|
22957
|
+
export declare class LaminarAiSdkTelemetry {
|
|
22482
22958
|
private readonly recordInputs;
|
|
22483
22959
|
private readonly recordOutputs;
|
|
22484
22960
|
private readonly createStepSpan;
|
|
@@ -22516,6 +22992,8 @@ declare class LaminarAiSdkTelemetry {
|
|
|
22516
22992
|
onEmbedEnd: (event: any) => void;
|
|
22517
22993
|
onRerankStart: () => void;
|
|
22518
22994
|
onRerankEnd: () => void;
|
|
22995
|
+
experimental_onDecideStart: (event: any) => void;
|
|
22996
|
+
experimental_onDecideEnd: (event: any) => void;
|
|
22519
22997
|
onEnd: (event: any) => void;
|
|
22520
22998
|
onError: (event: any) => void;
|
|
22521
22999
|
onAbort: (event: any) => void;
|
|
@@ -22564,7 +23042,7 @@ declare class LaminarAiSdkTelemetry {
|
|
|
22564
23042
|
* });
|
|
22565
23043
|
* ```
|
|
22566
23044
|
*/
|
|
22567
|
-
declare const aiSdkTelemetry: (options?: LaminarAiSdkTelemetryOptions) => LaminarAiSdkTelemetry;
|
|
23045
|
+
export declare const aiSdkTelemetry: (options?: LaminarAiSdkTelemetryOptions) => LaminarAiSdkTelemetry;
|
|
22568
23046
|
/**
|
|
22569
23047
|
* Registers a Laminar `Telemetry` integration as a global receiver for every
|
|
22570
23048
|
* AI SDK v7 call that has telemetry enabled.
|
|
@@ -22574,7 +23052,7 @@ declare const aiSdkTelemetry: (options?: LaminarAiSdkTelemetryOptions) => Lamina
|
|
|
22574
23052
|
* of `ai` — callers often want to register telemetry before the first
|
|
22575
23053
|
* provider call and must not pay the cost of eagerly loading the AI SDK.
|
|
22576
23054
|
*/
|
|
22577
|
-
declare const registerAiSdkTelemetry: (options?: LaminarAiSdkTelemetryOptions) => LaminarAiSdkTelemetry;
|
|
23055
|
+
export declare const registerAiSdkTelemetry: (options?: LaminarAiSdkTelemetryOptions) => LaminarAiSdkTelemetry;
|
|
22578
23056
|
/**
|
|
22579
23057
|
* Subscribes a pino-style logger to AI SDK v7's `diagnostics_channel`, which
|
|
22580
23058
|
* fires every lifecycle event as `{ type, event }`. Use this for debugging
|
|
@@ -22582,7 +23060,7 @@ declare const registerAiSdkTelemetry: (options?: LaminarAiSdkTelemetryOptions) =
|
|
|
22582
23060
|
*
|
|
22583
23061
|
* Returns an unsubscribe function.
|
|
22584
23062
|
*/
|
|
22585
|
-
declare const enableAiSdkTelemetryDebug: (log?: (entry: {
|
|
23063
|
+
export declare const enableAiSdkTelemetryDebug: (log?: (entry: {
|
|
22586
23064
|
type: string;
|
|
22587
23065
|
event: unknown;
|
|
22588
23066
|
}) => void) => (() => void);
|
|
@@ -22595,7 +23073,7 @@ declare const enableAiSdkTelemetryDebug: (log?: (entry: {
|
|
|
22595
23073
|
* @param originalQuery - The original query function from claude-agent-sdk
|
|
22596
23074
|
* @returns The instrumented query function
|
|
22597
23075
|
*/
|
|
22598
|
-
declare function instrumentClaudeAgentQuery(originalQuery: any): any;
|
|
23076
|
+
export declare function instrumentClaudeAgentQuery(originalQuery: any): any;
|
|
22599
23077
|
//#endregion
|
|
22600
23078
|
//#region src/opentelemetry-lib/instrumentation/mastra/types.d.ts
|
|
22601
23079
|
interface MastraSpanErrorInfo {
|
|
@@ -22668,7 +23146,7 @@ interface MastraExporterOptions {
|
|
|
22668
23146
|
* `ai.response.toolCalls` so Laminar's backend parser threads them into
|
|
22669
23147
|
* the LLM message history view.
|
|
22670
23148
|
*/
|
|
22671
|
-
declare class MastraExporter {
|
|
23149
|
+
export declare class MastraExporter {
|
|
22672
23150
|
readonly name = "laminar";
|
|
22673
23151
|
private readonly config;
|
|
22674
23152
|
private readonly traceMap;
|
|
@@ -22841,7 +23319,7 @@ declare const ActivityInterceptorFactory: (options?: LaminarTemporalInterceptorO
|
|
|
22841
23319
|
//#endregion
|
|
22842
23320
|
//#region src/opentelemetry-lib/instrumentation/temporal/index.d.ts
|
|
22843
23321
|
/** Namespace export: `LaminarTemporalInterceptors.WorkflowClientInterceptor`. */
|
|
22844
|
-
declare const LaminarTemporalInterceptors: {
|
|
23322
|
+
export declare const LaminarTemporalInterceptors: {
|
|
22845
23323
|
WorkflowClientInterceptor: typeof WorkflowClientInterceptor;
|
|
22846
23324
|
ScheduleClientInterceptor: typeof ScheduleClientInterceptor;
|
|
22847
23325
|
ActivityClientInterceptor: typeof ActivityClientInterceptor;
|
|
@@ -22875,7 +23353,7 @@ declare const TRACEPARENT_HEADER = "traceparent";
|
|
|
22875
23353
|
* otherwise returns the global tracer provider.
|
|
22876
23354
|
* @returns The tracer provider.
|
|
22877
23355
|
*/
|
|
22878
|
-
declare const getTracerProvider: () => TracerProvider;
|
|
23356
|
+
export declare const getTracerProvider: () => TracerProvider;
|
|
22879
23357
|
/**
|
|
22880
23358
|
* Get the tracer.
|
|
22881
23359
|
* @returns Laminar's tracer if Laminar is initialized,
|
|
@@ -22900,7 +23378,7 @@ declare const getTracerProvider: () => TracerProvider;
|
|
|
22900
23378
|
* }
|
|
22901
23379
|
* })
|
|
22902
23380
|
*/
|
|
22903
|
-
declare const getTracer: () => Tracer;
|
|
23381
|
+
export declare const getTracer: () => Tracer;
|
|
22904
23382
|
//#endregion
|
|
22905
23383
|
//#region src/opentelemetry-lib/tracing/instrumentations.d.ts
|
|
22906
23384
|
/**
|
|
@@ -22927,7 +23405,7 @@ declare const getTracer: () => Tracer;
|
|
|
22927
23405
|
* to enable them and register them with the OpenTelemetry SDK. For example, you could use
|
|
22928
23406
|
* registerInstrumentations from the opentelemetry-api to register them.
|
|
22929
23407
|
*/
|
|
22930
|
-
declare const initializeLaminarInstrumentations: (options?: {
|
|
23408
|
+
export declare const initializeLaminarInstrumentations: (options?: {
|
|
22931
23409
|
baseUrl?: string;
|
|
22932
23410
|
apiKey?: string;
|
|
22933
23411
|
httpPort?: number;
|
|
@@ -22936,5 +23414,5 @@ declare const initializeLaminarInstrumentations: (options?: {
|
|
|
22936
23414
|
sessionRecordingOptions?: SessionRecordingOptions;
|
|
22937
23415
|
}) => Instrumentation<import("@opentelemetry/instrumentation").InstrumentationConfig>[];
|
|
22938
23416
|
//#endregion
|
|
22939
|
-
export {
|
|
23417
|
+
export { type Datapoint, EvaluationDataset as Dataset, type Dataset as DatasetType, type EvalReporter, type EvaluationDatapoint, type EvaluationDatapointDatasetLink, type EvaluatorFunction, type EvaluatorFunctionReturn, type EveAssertionResult, type EveAssertionSeverity, type EveEval, type EveEvalDerivedFacts, type EveEvalResult, type EveEvalRunSummary, type EveEvalTarget, type EveEvalTaskResult, type EveEvalToolCall, type EveEvalVerdict, type EveRuntimeIdentity, type Event, HumanEvaluator, LAMINAR_SPAN_CONTEXT_HEADER as LAMINAR_TEMPORAL_SPAN_CONTEXT_HEADER, TRACEPARENT_HEADER as LAMINAR_TEMPORAL_TRACEPARENT_HEADER, type LaminarAiSdkTelemetryOptions, LaminarClient, LaminarDataset, type LaminarInitializeProps, type LaminarReporterOptions, type LaminarSpanContext, ActivityClientInterceptor as LaminarTemporalActivityClientInterceptor, ActivityInterceptorFactory as LaminarTemporalActivityInterceptorFactory, ScheduleClientInterceptor as LaminarTemporalScheduleClientInterceptor, WorkflowClientInterceptor as LaminarTemporalWorkflowClientInterceptor, type MaskInputOptions, type MastraExporterOptions, type PushDatapointsResponse, type SessionRecordingOptions, type Span, TracingLevel, evaluate };
|
|
22940
23418
|
//# sourceMappingURL=index.d.cts.map
|