ai 5.0.0-beta.1 → 5.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -0
- package/dist/index.d.mts +1857 -2578
- package/dist/index.d.ts +1857 -2578
- package/dist/index.js +7496 -7391
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7040 -6937
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +91 -91
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +9 -9
- package/dist/internal/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.d.mts +16 -96
- package/dist/mcp-stdio/index.d.ts +16 -96
- package/dist/mcp-stdio/index.js +71 -71
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +2 -2
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
@@ -1,26 +1,108 @@
|
|
1
|
-
import {
|
1
|
+
import { ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, Schema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, Validator, StandardSchemaV1, ToolCall, FetchFunction, InferSchema, FlexibleSchema, DataContent } from '@ai-sdk/provider-utils';
|
2
2
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, generateId, jsonSchema, tool } from '@ai-sdk/provider-utils';
|
3
|
-
import {
|
3
|
+
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
4
|
+
import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SharedV2ProviderMetadata, SpeechModelV2, SpeechModelV2CallWarning, TranscriptionModelV2, TranscriptionModelV2CallWarning, LanguageModelV2Usage, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
4
5
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
5
6
|
import * as z3 from 'zod/v3';
|
7
|
+
import * as z4$1 from 'zod/v4';
|
8
|
+
import { z } from 'zod/v4';
|
6
9
|
import * as z4 from 'zod/v4/core';
|
7
10
|
import { ServerResponse } from 'node:http';
|
8
|
-
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
9
11
|
import { ServerResponse as ServerResponse$1 } from 'http';
|
10
|
-
import { z } from 'zod';
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
type CallSettings = {
|
14
|
+
/**
|
15
|
+
Maximum number of tokens to generate.
|
16
|
+
*/
|
17
|
+
maxOutputTokens?: number;
|
18
|
+
/**
|
19
|
+
Temperature setting. The range depends on the provider and model.
|
20
|
+
|
21
|
+
It is recommended to set either `temperature` or `topP`, but not both.
|
22
|
+
*/
|
23
|
+
temperature?: number;
|
24
|
+
/**
|
25
|
+
Nucleus sampling. This is a number between 0 and 1.
|
26
|
+
|
27
|
+
E.g. 0.1 would mean that only tokens with the top 10% probability mass
|
28
|
+
are considered.
|
29
|
+
|
30
|
+
It is recommended to set either `temperature` or `topP`, but not both.
|
31
|
+
*/
|
32
|
+
topP?: number;
|
33
|
+
/**
|
34
|
+
Only sample from the top K options for each subsequent token.
|
35
|
+
|
36
|
+
Used to remove "long tail" low probability responses.
|
37
|
+
Recommended for advanced use cases only. You usually only need to use temperature.
|
38
|
+
*/
|
39
|
+
topK?: number;
|
40
|
+
/**
|
41
|
+
Presence penalty setting. It affects the likelihood of the model to
|
42
|
+
repeat information that is already in the prompt.
|
43
|
+
|
44
|
+
The presence penalty is a number between -1 (increase repetition)
|
45
|
+
and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
46
|
+
*/
|
47
|
+
presencePenalty?: number;
|
48
|
+
/**
|
49
|
+
Frequency penalty setting. It affects the likelihood of the model
|
50
|
+
to repeatedly use the same words or phrases.
|
51
|
+
|
52
|
+
The frequency penalty is a number between -1 (increase repetition)
|
53
|
+
and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
54
|
+
*/
|
55
|
+
frequencyPenalty?: number;
|
56
|
+
/**
|
57
|
+
Stop sequences.
|
58
|
+
If set, the model will stop generating text when one of the stop sequences is generated.
|
59
|
+
Providers may have limits on the number of stop sequences.
|
60
|
+
*/
|
61
|
+
stopSequences?: string[];
|
62
|
+
/**
|
63
|
+
The seed (integer) to use for random sampling. If set and supported
|
64
|
+
by the model, calls will generate deterministic results.
|
65
|
+
*/
|
66
|
+
seed?: number;
|
67
|
+
/**
|
68
|
+
Maximum number of retries. Set to 0 to disable retries.
|
69
|
+
|
70
|
+
@default 2
|
71
|
+
*/
|
72
|
+
maxRetries?: number;
|
73
|
+
/**
|
74
|
+
Abort signal.
|
75
|
+
*/
|
76
|
+
abortSignal?: AbortSignal;
|
77
|
+
/**
|
78
|
+
Additional HTTP headers to be sent with the request.
|
79
|
+
Only applicable for HTTP-based providers.
|
80
|
+
*/
|
81
|
+
headers?: Record<string, string | undefined>;
|
82
|
+
};
|
83
|
+
|
84
|
+
/**
|
85
|
+
Prompt part of the AI function options.
|
86
|
+
It contains a system message, a simple text prompt, or a list of messages.
|
87
|
+
*/
|
88
|
+
type Prompt = {
|
89
|
+
/**
|
90
|
+
System message to include in the prompt. Can be used with `prompt` or `messages`.
|
91
|
+
*/
|
92
|
+
system?: string;
|
93
|
+
/**
|
94
|
+
A prompt. It can be either a text prompt or a list of messages.
|
95
|
+
|
96
|
+
You can either use `prompt` or `messages` but not both.
|
97
|
+
*/
|
98
|
+
prompt?: string | Array<ModelMessage>;
|
99
|
+
/**
|
100
|
+
A list of messages.
|
101
|
+
|
102
|
+
You can either use `prompt` or `messages` but not both.
|
103
|
+
*/
|
104
|
+
messages?: Array<ModelMessage>;
|
105
|
+
};
|
24
106
|
|
25
107
|
/**
|
26
108
|
* Telemetry configuration.
|
@@ -295,546 +377,621 @@ interface GeneratedFile {
|
|
295
377
|
readonly mediaType: string;
|
296
378
|
}
|
297
379
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
380
|
+
/**
|
381
|
+
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
382
|
+
|
383
|
+
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
|
384
|
+
|
385
|
+
@example
|
386
|
+
```
|
387
|
+
// data.json
|
388
|
+
{
|
389
|
+
'foo': 1,
|
390
|
+
'bar': 2,
|
391
|
+
'biz': 3
|
310
392
|
}
|
311
393
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
toolName: string;
|
319
|
-
availableTools?: string[] | undefined;
|
320
|
-
message?: string;
|
321
|
-
});
|
322
|
-
static isInstance(error: unknown): error is NoSuchToolError;
|
394
|
+
// main.ts
|
395
|
+
import type {ValueOf} from 'type-fest';
|
396
|
+
import data = require('./data.json');
|
397
|
+
|
398
|
+
export function getData(name: string): ValueOf<typeof data> {
|
399
|
+
return data[name];
|
323
400
|
}
|
324
401
|
|
325
|
-
|
402
|
+
export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
|
403
|
+
return data[name];
|
404
|
+
}
|
405
|
+
|
406
|
+
// file.ts
|
407
|
+
import {getData, onlyBar} from './main';
|
408
|
+
|
409
|
+
getData('foo');
|
410
|
+
//=> 1
|
411
|
+
|
412
|
+
onlyBar('foo');
|
413
|
+
//=> TypeError ...
|
414
|
+
|
415
|
+
onlyBar('bar');
|
416
|
+
//=> 2
|
417
|
+
```
|
418
|
+
* @see https://github.com/sindresorhus/type-fest/blob/main/source/value-of.d.ts
|
419
|
+
*/
|
420
|
+
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
421
|
+
|
422
|
+
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
|
423
|
+
|
424
|
+
type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
|
425
|
+
[NAME in keyof TOOLS]: {
|
426
|
+
type: 'tool-call';
|
427
|
+
toolCallId: string;
|
428
|
+
toolName: NAME & string;
|
429
|
+
input: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
|
430
|
+
providerExecuted?: boolean;
|
431
|
+
};
|
432
|
+
}>;
|
433
|
+
type ToolCallArray<TOOLS extends ToolSet> = Array<ToolCallUnion<TOOLS>>;
|
434
|
+
|
435
|
+
type ToToolResultObject<TOOLS extends ToolSet> = ValueOf<{
|
436
|
+
[NAME in keyof TOOLS]: {
|
437
|
+
type: 'tool-result';
|
438
|
+
toolCallId: string;
|
439
|
+
toolName: NAME & string;
|
440
|
+
input: InferToolInput<TOOLS[NAME]>;
|
441
|
+
output: InferToolOutput<TOOLS[NAME]>;
|
442
|
+
providerExecuted?: boolean;
|
443
|
+
};
|
444
|
+
}>;
|
445
|
+
type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<TOOLS>;
|
446
|
+
type ToolResultArray<TOOLS extends ToolSet> = Array<ToolResultUnion<TOOLS>>;
|
447
|
+
type ToToolErrorObject<TOOLS extends ToolSet> = ValueOf<{
|
448
|
+
[NAME in keyof TOOLS]: {
|
449
|
+
type: 'tool-error';
|
450
|
+
toolCallId: string;
|
451
|
+
toolName: NAME & string;
|
452
|
+
input: InferToolInput<TOOLS[NAME]>;
|
453
|
+
error: unknown;
|
454
|
+
providerExecuted?: boolean;
|
455
|
+
};
|
456
|
+
}>;
|
457
|
+
type ToolErrorUnion<TOOLS extends ToolSet> = ToToolErrorObject<TOOLS>;
|
458
|
+
|
459
|
+
type ContentPart<TOOLS extends ToolSet> = {
|
460
|
+
type: 'text';
|
461
|
+
text: string;
|
462
|
+
} | {
|
463
|
+
type: 'reasoning';
|
464
|
+
text: string;
|
465
|
+
providerMetadata?: ProviderMetadata;
|
466
|
+
} | ({
|
467
|
+
type: 'source';
|
468
|
+
} & Source) | {
|
469
|
+
type: 'file';
|
470
|
+
file: GeneratedFile;
|
471
|
+
} | ({
|
472
|
+
type: 'tool-call';
|
473
|
+
} & ToolCallUnion<TOOLS>) | ({
|
474
|
+
type: 'tool-result';
|
475
|
+
} & ToolResultUnion<TOOLS>) | ({
|
476
|
+
type: 'tool-error';
|
477
|
+
} & ToolErrorUnion<TOOLS>);
|
478
|
+
|
479
|
+
/**
|
480
|
+
A message that was generated during the generation process.
|
481
|
+
It can be either an assistant message or a tool message.
|
482
|
+
*/
|
483
|
+
type ResponseMessage = AssistantModelMessage | ToolModelMessage;
|
484
|
+
|
485
|
+
/**
|
486
|
+
* The result of a single step in the generation process.
|
487
|
+
*/
|
488
|
+
type StepResult<TOOLS extends ToolSet> = {
|
326
489
|
/**
|
327
|
-
|
490
|
+
The content that was generated in the last step.
|
328
491
|
*/
|
329
|
-
|
492
|
+
readonly content: Array<ContentPart<TOOLS>>;
|
330
493
|
/**
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
*/
|
335
|
-
temperature?: number;
|
494
|
+
The generated text.
|
495
|
+
*/
|
496
|
+
readonly text: string;
|
336
497
|
/**
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
are considered.
|
341
|
-
|
342
|
-
It is recommended to set either `temperature` or `topP`, but not both.
|
343
|
-
*/
|
344
|
-
topP?: number;
|
498
|
+
The reasoning that was generated during the generation.
|
499
|
+
*/
|
500
|
+
readonly reasoning: Array<ReasoningPart>;
|
345
501
|
/**
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
502
|
+
The reasoning text that was generated during the generation.
|
503
|
+
*/
|
504
|
+
readonly reasoningText: string | undefined;
|
505
|
+
/**
|
506
|
+
The files that were generated during the generation.
|
507
|
+
*/
|
508
|
+
readonly files: Array<GeneratedFile>;
|
509
|
+
/**
|
510
|
+
The sources that were used to generate the text.
|
511
|
+
*/
|
512
|
+
readonly sources: Array<Source>;
|
513
|
+
/**
|
514
|
+
The tool calls that were made during the generation.
|
515
|
+
*/
|
516
|
+
readonly toolCalls: ToolCallArray<TOOLS>;
|
517
|
+
/**
|
518
|
+
The results of the tool calls.
|
519
|
+
*/
|
520
|
+
readonly toolResults: ToolResultArray<TOOLS>;
|
521
|
+
/**
|
522
|
+
The reason why the generation finished.
|
523
|
+
*/
|
524
|
+
readonly finishReason: FinishReason;
|
525
|
+
/**
|
526
|
+
The token usage of the generated text.
|
527
|
+
*/
|
528
|
+
readonly usage: LanguageModelUsage;
|
529
|
+
/**
|
530
|
+
Warnings from the model provider (e.g. unsupported settings).
|
531
|
+
*/
|
532
|
+
readonly warnings: CallWarning[] | undefined;
|
533
|
+
/**
|
534
|
+
Additional request information.
|
350
535
|
*/
|
351
|
-
|
536
|
+
readonly request: LanguageModelRequestMetadata;
|
352
537
|
/**
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
538
|
+
Additional response information.
|
539
|
+
*/
|
540
|
+
readonly response: LanguageModelResponseMetadata & {
|
541
|
+
/**
|
542
|
+
The response messages that were generated during the call.
|
543
|
+
Response messages can be either assistant messages or tool messages.
|
544
|
+
They contain a generated id.
|
545
|
+
*/
|
546
|
+
readonly messages: Array<ResponseMessage>;
|
547
|
+
/**
|
548
|
+
Response body (available only for providers that use HTTP requests).
|
549
|
+
*/
|
550
|
+
body?: unknown;
|
551
|
+
};
|
552
|
+
/**
|
553
|
+
Additional provider-specific metadata. They are passed through
|
554
|
+
from the provider to the AI SDK and enable provider-specific
|
555
|
+
results that can be fully encapsulated in the provider.
|
358
556
|
*/
|
359
|
-
|
557
|
+
readonly providerMetadata: ProviderMetadata | undefined;
|
558
|
+
};
|
559
|
+
|
560
|
+
/**
|
561
|
+
The result of a `generateText` call.
|
562
|
+
It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
563
|
+
*/
|
564
|
+
interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
360
565
|
/**
|
361
|
-
|
362
|
-
to repeatedly use the same words or phrases.
|
363
|
-
|
364
|
-
The frequency penalty is a number between -1 (increase repetition)
|
365
|
-
and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
566
|
+
The content that was generated in the last step.
|
366
567
|
*/
|
367
|
-
|
568
|
+
readonly content: Array<ContentPart<TOOLS>>;
|
368
569
|
/**
|
369
|
-
|
370
|
-
|
371
|
-
|
570
|
+
The text that was generated in the last step.
|
571
|
+
*/
|
572
|
+
readonly text: string;
|
573
|
+
/**
|
574
|
+
The full reasoning that the model has generated in the last step.
|
372
575
|
*/
|
373
|
-
|
576
|
+
readonly reasoning: Array<ReasoningPart>;
|
374
577
|
/**
|
375
|
-
The
|
376
|
-
|
578
|
+
The reasoning text that the model has generated in the last step. Can be undefined if the model
|
579
|
+
has only generated text.
|
377
580
|
*/
|
378
|
-
|
581
|
+
readonly reasoningText: string | undefined;
|
379
582
|
/**
|
380
|
-
|
381
|
-
|
382
|
-
|
583
|
+
The files that were generated in the last step.
|
584
|
+
Empty array if no files were generated.
|
585
|
+
*/
|
586
|
+
readonly files: Array<GeneratedFile>;
|
587
|
+
/**
|
588
|
+
Sources that have been used as references in the last step.
|
383
589
|
*/
|
384
|
-
|
590
|
+
readonly sources: Array<Source>;
|
385
591
|
/**
|
386
|
-
|
592
|
+
The tool calls that were made in the last step.
|
387
593
|
*/
|
388
|
-
|
594
|
+
readonly toolCalls: ToolCallArray<TOOLS>;
|
389
595
|
/**
|
390
|
-
|
391
|
-
Only applicable for HTTP-based providers.
|
596
|
+
The results of the tool calls from the last step.
|
392
597
|
*/
|
393
|
-
|
394
|
-
};
|
395
|
-
|
396
|
-
/**
|
397
|
-
@deprecated Use `SystemModelMessage` instead.
|
398
|
-
*/
|
399
|
-
type CoreSystemMessage = SystemModelMessage;
|
400
|
-
declare const systemModelMessageSchema: z.ZodType<SystemModelMessage>;
|
401
|
-
/**
|
402
|
-
@deprecated Use `systemModelMessageSchema` instead.
|
403
|
-
*/
|
404
|
-
declare const coreSystemMessageSchema: z.ZodType<SystemModelMessage, z.ZodTypeDef, SystemModelMessage>;
|
405
|
-
/**
|
406
|
-
@deprecated Use `UserModelMessage` instead.
|
407
|
-
*/
|
408
|
-
type CoreUserMessage = UserModelMessage;
|
409
|
-
declare const userModelMessageSchema: z.ZodType<UserModelMessage>;
|
410
|
-
/**
|
411
|
-
@deprecated Use `userModelMessageSchema` instead.
|
412
|
-
*/
|
413
|
-
declare const coreUserMessageSchema: z.ZodType<UserModelMessage, z.ZodTypeDef, UserModelMessage>;
|
414
|
-
/**
|
415
|
-
@deprecated Use `AssistantModelMessage` instead.
|
416
|
-
*/
|
417
|
-
type CoreAssistantMessage = AssistantModelMessage;
|
418
|
-
declare const assistantModelMessageSchema: z.ZodType<AssistantModelMessage>;
|
419
|
-
/**
|
420
|
-
@deprecated Use `assistantModelMessageSchema` instead.
|
421
|
-
*/
|
422
|
-
declare const coreAssistantMessageSchema: z.ZodType<AssistantModelMessage, z.ZodTypeDef, AssistantModelMessage>;
|
423
|
-
/**
|
424
|
-
@deprecated Use `ToolModelMessage` instead.
|
425
|
-
*/
|
426
|
-
type CoreToolMessage = ToolModelMessage;
|
427
|
-
declare const toolModelMessageSchema: z.ZodType<ToolModelMessage>;
|
428
|
-
/**
|
429
|
-
@deprecated Use `toolModelMessageSchema` instead.
|
430
|
-
*/
|
431
|
-
declare const coreToolMessageSchema: z.ZodType<ToolModelMessage, z.ZodTypeDef, ToolModelMessage>;
|
432
|
-
/**
|
433
|
-
@deprecated Use `ModelMessage` instead.
|
434
|
-
*/
|
435
|
-
type CoreMessage = ModelMessage;
|
436
|
-
declare const modelMessageSchema: z.ZodType<ModelMessage>;
|
437
|
-
/**
|
438
|
-
@deprecated Use `modelMessageSchema` instead.
|
439
|
-
*/
|
440
|
-
declare const coreMessageSchema: z.ZodType<CoreMessage>;
|
441
|
-
|
442
|
-
/**
|
443
|
-
Prompt part of the AI function options.
|
444
|
-
It contains a system message, a simple text prompt, or a list of messages.
|
445
|
-
*/
|
446
|
-
type Prompt = {
|
598
|
+
readonly toolResults: ToolResultArray<TOOLS>;
|
447
599
|
/**
|
448
|
-
|
600
|
+
The reason why the generation finished.
|
449
601
|
*/
|
450
|
-
|
602
|
+
readonly finishReason: FinishReason;
|
451
603
|
/**
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
*/
|
456
|
-
prompt?: string | Array<ModelMessage>;
|
604
|
+
The token usage of the last step.
|
605
|
+
*/
|
606
|
+
readonly usage: LanguageModelUsage;
|
457
607
|
/**
|
458
|
-
|
459
|
-
|
460
|
-
You can either use `prompt` or `messages` but not both.
|
608
|
+
The total token usage of all steps.
|
609
|
+
When there are multiple steps, the usage is the sum of all step usages.
|
461
610
|
*/
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
611
|
+
readonly totalUsage: LanguageModelUsage;
|
612
|
+
/**
|
613
|
+
Warnings from the model provider (e.g. unsupported settings)
|
614
|
+
*/
|
615
|
+
readonly warnings: CallWarning[] | undefined;
|
616
|
+
/**
|
617
|
+
Additional request information.
|
618
|
+
*/
|
619
|
+
readonly request: LanguageModelRequestMetadata;
|
620
|
+
/**
|
621
|
+
Additional response information.
|
622
|
+
*/
|
623
|
+
readonly response: LanguageModelResponseMetadata & {
|
624
|
+
/**
|
625
|
+
The response messages that were generated during the call. It consists of an assistant message,
|
626
|
+
potentially containing tool calls.
|
627
|
+
|
628
|
+
When there are tool results, there is an additional tool message with the tool results that are available.
|
629
|
+
If there are tools that do not have execute functions, they are not included in the tool results and
|
630
|
+
need to be added separately.
|
631
|
+
*/
|
632
|
+
messages: Array<ResponseMessage>;
|
633
|
+
/**
|
634
|
+
Response body (available only for providers that use HTTP requests).
|
635
|
+
*/
|
636
|
+
body?: unknown;
|
637
|
+
};
|
638
|
+
/**
|
639
|
+
Additional provider-specific metadata. They are passed through
|
640
|
+
from the provider to the AI SDK and enable provider-specific
|
641
|
+
results that can be fully encapsulated in the provider.
|
642
|
+
*/
|
643
|
+
readonly providerMetadata: ProviderMetadata | undefined;
|
644
|
+
/**
|
645
|
+
Details for all steps.
|
646
|
+
You can use this to get information about intermediate steps,
|
647
|
+
such as the tool calls or the response headers.
|
648
|
+
*/
|
649
|
+
readonly steps: Array<StepResult<TOOLS>>;
|
650
|
+
/**
|
651
|
+
The generated structured output. It uses the `experimental_output` specification.
|
652
|
+
*/
|
653
|
+
readonly experimental_output: OUTPUT;
|
654
|
+
}
|
466
655
|
|
467
656
|
/**
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
* @param options.system - The system prompt.
|
474
|
-
* @param options.messages - The messages in the current generation step.
|
475
|
-
* @param options.toolCall - The tool call that failed to parse.
|
476
|
-
* @param options.tools - The tools that are available.
|
477
|
-
* @param options.inputSchema - A function that returns the JSON Schema for a tool.
|
478
|
-
* @param options.error - The error that occurred while parsing the tool call.
|
657
|
+
Create a type from an object with all keys and nested keys set to optional.
|
658
|
+
The helper supports normal objects and Zod schemas (which are resolved automatically).
|
659
|
+
It always recurses into arrays.
|
660
|
+
|
661
|
+
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
479
662
|
*/
|
480
|
-
type
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
}) => Promise<LanguageModelV2ToolCall | null>;
|
490
|
-
|
491
|
-
/**
|
492
|
-
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
493
|
-
|
494
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
|
495
|
-
|
496
|
-
@example
|
497
|
-
```
|
498
|
-
// data.json
|
499
|
-
{
|
500
|
-
'foo': 1,
|
501
|
-
'bar': 2,
|
502
|
-
'biz': 3
|
503
|
-
}
|
504
|
-
|
505
|
-
// main.ts
|
506
|
-
import type {ValueOf} from 'type-fest';
|
507
|
-
import data = require('./data.json');
|
663
|
+
type DeepPartial<T> = T extends z3.ZodTypeAny ? DeepPartialInternal<z3.infer<T>> : T extends z4.$ZodType ? DeepPartialInternal<z4.infer<T>> : DeepPartialInternal<T>;
|
664
|
+
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
665
|
+
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
666
|
+
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
667
|
+
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
668
|
+
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
669
|
+
type PartialObject<ObjectType extends object> = {
|
670
|
+
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
671
|
+
};
|
508
672
|
|
509
|
-
|
510
|
-
|
673
|
+
interface Output<OUTPUT, PARTIAL> {
|
674
|
+
readonly type: 'object' | 'text';
|
675
|
+
responseFormat: LanguageModelV2CallOptions['responseFormat'];
|
676
|
+
parsePartial(options: {
|
677
|
+
text: string;
|
678
|
+
}): Promise<{
|
679
|
+
partial: PARTIAL;
|
680
|
+
} | undefined>;
|
681
|
+
parseOutput(options: {
|
682
|
+
text: string;
|
683
|
+
}, context: {
|
684
|
+
response: LanguageModelResponseMetadata;
|
685
|
+
usage: LanguageModelUsage;
|
686
|
+
finishReason: FinishReason;
|
687
|
+
}): Promise<OUTPUT>;
|
511
688
|
}
|
689
|
+
declare const text: () => Output<string, string>;
|
690
|
+
declare const object: <OUTPUT>({ schema: inputSchema, }: {
|
691
|
+
schema: z4$1.ZodType<OUTPUT, any> | z3.Schema<OUTPUT, z3.ZodTypeDef, any> | Schema<OUTPUT>;
|
692
|
+
}) => Output<OUTPUT, DeepPartial<OUTPUT>>;
|
512
693
|
|
513
|
-
|
514
|
-
|
694
|
+
type output_Output<OUTPUT, PARTIAL> = Output<OUTPUT, PARTIAL>;
|
695
|
+
declare const output_object: typeof object;
|
696
|
+
declare const output_text: typeof text;
|
697
|
+
declare namespace output {
|
698
|
+
export {
|
699
|
+
output_Output as Output,
|
700
|
+
output_object as object,
|
701
|
+
output_text as text,
|
702
|
+
};
|
515
703
|
}
|
516
704
|
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
getData('foo');
|
521
|
-
//=> 1
|
522
|
-
|
523
|
-
onlyBar('foo');
|
524
|
-
//=> TypeError ...
|
525
|
-
|
526
|
-
onlyBar('bar');
|
527
|
-
//=> 2
|
528
|
-
```
|
529
|
-
* @see https://github.com/sindresorhus/type-fest/blob/main/source/value-of.d.ts
|
530
|
-
*/
|
531
|
-
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
705
|
+
/**
|
706
|
+
Function that you can use to provide different settings for a step.
|
532
707
|
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
toolName: NAME & string;
|
538
|
-
input: InferToolInput<TOOLS[NAME]>;
|
539
|
-
output: InferToolOutput<TOOLS[NAME]>;
|
540
|
-
providerExecuted?: boolean;
|
541
|
-
};
|
542
|
-
}>;
|
543
|
-
type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<TOOLS>;
|
544
|
-
type ToolResultArray<TOOLS extends ToolSet> = Array<ToolResultUnion<TOOLS>>;
|
545
|
-
type ToToolErrorObject<TOOLS extends ToolSet> = ValueOf<{
|
546
|
-
[NAME in keyof TOOLS]: {
|
547
|
-
type: 'tool-error';
|
548
|
-
toolCallId: string;
|
549
|
-
toolName: NAME & string;
|
550
|
-
input: InferToolInput<TOOLS[NAME]>;
|
551
|
-
error: unknown;
|
552
|
-
providerExecuted?: boolean;
|
553
|
-
};
|
554
|
-
}>;
|
555
|
-
type ToolErrorUnion<TOOLS extends ToolSet> = ToToolErrorObject<TOOLS>;
|
708
|
+
@param options - The options for the step.
|
709
|
+
@param options.steps - The steps that have been executed so far.
|
710
|
+
@param options.stepNumber - The number of the step that is being executed.
|
711
|
+
@param options.model - The model that is being used.
|
556
712
|
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
713
|
+
@returns An object that contains the settings for the step.
|
714
|
+
If you return undefined (or for undefined settings), the settings from the outer level will be used.
|
715
|
+
*/
|
716
|
+
type PrepareStepFunction<TOOLS extends Record<string, Tool> = Record<string, Tool>> = (options: {
|
717
|
+
steps: Array<StepResult<NoInfer<TOOLS>>>;
|
718
|
+
stepNumber: number;
|
719
|
+
model: LanguageModel;
|
720
|
+
}) => PromiseLike<PrepareStepResult<TOOLS>> | PrepareStepResult<TOOLS>;
|
721
|
+
type PrepareStepResult<TOOLS extends Record<string, Tool> = Record<string, Tool>> = {
|
722
|
+
model?: LanguageModel;
|
723
|
+
toolChoice?: ToolChoice<NoInfer<TOOLS>>;
|
724
|
+
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
725
|
+
system?: string;
|
726
|
+
} | undefined;
|
567
727
|
|
568
|
-
type
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
type: 'text-delta';
|
574
|
-
id: string;
|
575
|
-
providerMetadata?: ProviderMetadata;
|
576
|
-
delta: string;
|
577
|
-
} | {
|
578
|
-
type: 'text-end';
|
579
|
-
providerMetadata?: ProviderMetadata;
|
580
|
-
id: string;
|
581
|
-
} | {
|
582
|
-
type: 'reasoning-start';
|
583
|
-
providerMetadata?: ProviderMetadata;
|
584
|
-
id: string;
|
585
|
-
} | {
|
586
|
-
type: 'reasoning-delta';
|
587
|
-
id: string;
|
588
|
-
providerMetadata?: ProviderMetadata;
|
589
|
-
delta: string;
|
590
|
-
} | {
|
591
|
-
type: 'reasoning-end';
|
592
|
-
id: string;
|
593
|
-
providerMetadata?: ProviderMetadata;
|
594
|
-
} | {
|
595
|
-
type: 'tool-input-start';
|
596
|
-
id: string;
|
597
|
-
toolName: string;
|
598
|
-
providerMetadata?: ProviderMetadata;
|
599
|
-
} | {
|
600
|
-
type: 'tool-input-delta';
|
601
|
-
id: string;
|
602
|
-
delta: string;
|
603
|
-
providerMetadata?: ProviderMetadata;
|
604
|
-
} | {
|
605
|
-
type: 'tool-input-end';
|
606
|
-
id: string;
|
607
|
-
providerMetadata?: ProviderMetadata;
|
608
|
-
} | ({
|
609
|
-
type: 'source';
|
610
|
-
} & Source) | {
|
611
|
-
type: 'file';
|
612
|
-
file: GeneratedFile;
|
613
|
-
} | ({
|
614
|
-
type: 'tool-call';
|
615
|
-
} & ToolCallUnion<TOOLS>) | ({
|
616
|
-
type: 'tool-result';
|
617
|
-
} & ToolResultUnion<TOOLS>) | ({
|
618
|
-
type: 'tool-error';
|
619
|
-
} & ToolErrorUnion<TOOLS>) | {
|
620
|
-
type: 'file';
|
621
|
-
file: GeneratedFile;
|
622
|
-
} | {
|
623
|
-
type: 'stream-start';
|
624
|
-
warnings: LanguageModelV2CallWarning[];
|
625
|
-
} | {
|
626
|
-
type: 'response-metadata';
|
627
|
-
id?: string;
|
628
|
-
timestamp?: Date;
|
629
|
-
modelId?: string;
|
630
|
-
} | {
|
631
|
-
type: 'finish';
|
632
|
-
finishReason: FinishReason;
|
633
|
-
usage: LanguageModelUsage;
|
634
|
-
providerMetadata?: ProviderMetadata;
|
635
|
-
} | {
|
636
|
-
type: 'error';
|
637
|
-
error: unknown;
|
638
|
-
} | {
|
639
|
-
type: 'raw';
|
640
|
-
rawValue: unknown;
|
641
|
-
};
|
728
|
+
type StopCondition<TOOLS extends ToolSet> = (options: {
|
729
|
+
steps: Array<StepResult<TOOLS>>;
|
730
|
+
}) => PromiseLike<boolean> | boolean;
|
731
|
+
declare function stepCountIs(stepCount: number): StopCondition<any>;
|
732
|
+
declare function hasToolCall(toolName: string): StopCondition<any>;
|
642
733
|
|
643
|
-
declare const symbol$
|
644
|
-
declare class
|
645
|
-
private readonly [symbol$
|
646
|
-
readonly
|
647
|
-
|
648
|
-
|
649
|
-
message
|
734
|
+
declare const symbol$e: unique symbol;
|
735
|
+
declare class InvalidToolInputError extends AISDKError {
|
736
|
+
private readonly [symbol$e];
|
737
|
+
readonly toolName: string;
|
738
|
+
readonly toolInput: string;
|
739
|
+
constructor({ toolInput, toolName, cause, message, }: {
|
740
|
+
message?: string;
|
741
|
+
toolInput: string;
|
742
|
+
toolName: string;
|
743
|
+
cause: unknown;
|
650
744
|
});
|
651
|
-
static isInstance(error: unknown): error is
|
745
|
+
static isInstance(error: unknown): error is InvalidToolInputError;
|
652
746
|
}
|
653
747
|
|
654
|
-
declare const symbol$
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
message
|
663
|
-
cause?: unknown;
|
748
|
+
declare const symbol$d: unique symbol;
|
749
|
+
declare class NoSuchToolError extends AISDKError {
|
750
|
+
private readonly [symbol$d];
|
751
|
+
readonly toolName: string;
|
752
|
+
readonly availableTools: string[] | undefined;
|
753
|
+
constructor({ toolName, availableTools, message, }: {
|
754
|
+
toolName: string;
|
755
|
+
availableTools?: string[] | undefined;
|
756
|
+
message?: string;
|
664
757
|
});
|
665
|
-
static isInstance(error: unknown): error is
|
758
|
+
static isInstance(error: unknown): error is NoSuchToolError;
|
666
759
|
}
|
667
760
|
|
668
|
-
declare const symbol$9: unique symbol;
|
669
761
|
/**
|
670
|
-
|
671
|
-
|
672
|
-
- The model failed to generate a response.
|
673
|
-
- The model generated a response that could not be parsed.
|
762
|
+
@deprecated Use `SystemModelMessage` instead.
|
674
763
|
*/
|
675
|
-
|
676
|
-
|
677
|
-
/**
|
678
|
-
The response metadata for each call.
|
679
|
-
*/
|
680
|
-
readonly responses: Array<ImageModelResponseMetadata> | undefined;
|
681
|
-
constructor({ message, cause, responses, }: {
|
682
|
-
message?: string;
|
683
|
-
cause?: Error;
|
684
|
-
responses?: Array<ImageModelResponseMetadata>;
|
685
|
-
});
|
686
|
-
static isInstance(error: unknown): error is NoImageGeneratedError;
|
687
|
-
}
|
688
|
-
|
689
|
-
declare const symbol$8: unique symbol;
|
764
|
+
type CoreSystemMessage = SystemModelMessage;
|
765
|
+
declare const systemModelMessageSchema: z.ZodType<SystemModelMessage>;
|
690
766
|
/**
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
767
|
+
@deprecated Use `systemModelMessageSchema` instead.
|
768
|
+
*/
|
769
|
+
declare const coreSystemMessageSchema: z.ZodType<SystemModelMessage, unknown>;
|
770
|
+
/**
|
771
|
+
@deprecated Use `UserModelMessage` instead.
|
772
|
+
*/
|
773
|
+
type CoreUserMessage = UserModelMessage;
|
774
|
+
declare const userModelMessageSchema: z.ZodType<UserModelMessage>;
|
775
|
+
/**
|
776
|
+
@deprecated Use `userModelMessageSchema` instead.
|
777
|
+
*/
|
778
|
+
declare const coreUserMessageSchema: z.ZodType<UserModelMessage, unknown>;
|
779
|
+
/**
|
780
|
+
@deprecated Use `AssistantModelMessage` instead.
|
781
|
+
*/
|
782
|
+
type CoreAssistantMessage = AssistantModelMessage;
|
783
|
+
declare const assistantModelMessageSchema: z.ZodType<AssistantModelMessage>;
|
784
|
+
/**
|
785
|
+
@deprecated Use `assistantModelMessageSchema` instead.
|
786
|
+
*/
|
787
|
+
declare const coreAssistantMessageSchema: z.ZodType<AssistantModelMessage, unknown>;
|
788
|
+
/**
|
789
|
+
@deprecated Use `ToolModelMessage` instead.
|
790
|
+
*/
|
791
|
+
type CoreToolMessage = ToolModelMessage;
|
792
|
+
declare const toolModelMessageSchema: z.ZodType<ToolModelMessage>;
|
793
|
+
/**
|
794
|
+
@deprecated Use `toolModelMessageSchema` instead.
|
795
|
+
*/
|
796
|
+
declare const coreToolMessageSchema: z.ZodType<ToolModelMessage, unknown>;
|
797
|
+
/**
|
798
|
+
@deprecated Use `ModelMessage` instead.
|
799
|
+
*/
|
800
|
+
type CoreMessage = ModelMessage;
|
801
|
+
declare const modelMessageSchema: z.ZodType<ModelMessage>;
|
802
|
+
/**
|
803
|
+
@deprecated Use `modelMessageSchema` instead.
|
804
|
+
*/
|
805
|
+
declare const coreMessageSchema: z.ZodType<CoreMessage>;
|
698
806
|
|
699
|
-
|
807
|
+
/**
|
808
|
+
* A function that attempts to repair a tool call that failed to parse.
|
809
|
+
*
|
810
|
+
* It receives the error and the context as arguments and returns the repair
|
811
|
+
* tool call JSON as text.
|
812
|
+
*
|
813
|
+
* @param options.system - The system prompt.
|
814
|
+
* @param options.messages - The messages in the current generation step.
|
815
|
+
* @param options.toolCall - The tool call that failed to parse.
|
816
|
+
* @param options.tools - The tools that are available.
|
817
|
+
* @param options.inputSchema - A function that returns the JSON Schema for a tool.
|
818
|
+
* @param options.error - The error that occurred while parsing the tool call.
|
700
819
|
*/
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
/**
|
712
|
-
The usage of the model.
|
713
|
-
*/
|
714
|
-
readonly usage: LanguageModelUsage | undefined;
|
715
|
-
/**
|
716
|
-
Reason why the model finished generating a response.
|
717
|
-
*/
|
718
|
-
readonly finishReason: FinishReason | undefined;
|
719
|
-
constructor({ message, cause, text, response, usage, finishReason, }: {
|
720
|
-
message?: string;
|
721
|
-
cause?: Error;
|
722
|
-
text?: string;
|
723
|
-
response: LanguageModelResponseMetadata;
|
724
|
-
usage: LanguageModelUsage;
|
725
|
-
finishReason: FinishReason;
|
726
|
-
});
|
727
|
-
static isInstance(error: unknown): error is NoObjectGeneratedError;
|
728
|
-
}
|
820
|
+
type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
|
821
|
+
system: string | undefined;
|
822
|
+
messages: ModelMessage[];
|
823
|
+
toolCall: LanguageModelV2ToolCall;
|
824
|
+
tools: TOOLS;
|
825
|
+
inputSchema: (options: {
|
826
|
+
toolName: string;
|
827
|
+
}) => JSONSchema7;
|
828
|
+
error: NoSuchToolError | InvalidToolInputError;
|
829
|
+
}) => Promise<LanguageModelV2ToolCall | null>;
|
729
830
|
|
730
|
-
declare const symbol$7: unique symbol;
|
731
831
|
/**
|
732
|
-
|
832
|
+
Callback that is set using the `onStepFinish` option.
|
833
|
+
|
834
|
+
@param stepResult - The result of the step.
|
733
835
|
*/
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
message?: string;
|
738
|
-
});
|
739
|
-
static isInstance(error: unknown): error is NoOutputSpecifiedError;
|
740
|
-
}
|
836
|
+
type GenerateTextOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
|
837
|
+
/**
|
838
|
+
Generate a text and call tools for a given prompt using a language model.
|
741
839
|
|
742
|
-
|
743
|
-
declare class ToolCallRepairError extends AISDKError {
|
744
|
-
private readonly [symbol$6];
|
745
|
-
readonly originalError: NoSuchToolError | InvalidToolInputError;
|
746
|
-
constructor({ cause, originalError, message, }: {
|
747
|
-
message?: string;
|
748
|
-
cause: unknown;
|
749
|
-
originalError: NoSuchToolError | InvalidToolInputError;
|
750
|
-
});
|
751
|
-
static isInstance(error: unknown): error is ToolCallRepairError;
|
752
|
-
}
|
840
|
+
This function does not stream the output. If you want to stream the output, use `streamText` instead.
|
753
841
|
|
754
|
-
|
755
|
-
declare class InvalidDataContentError extends AISDKError {
|
756
|
-
private readonly [symbol$5];
|
757
|
-
readonly content: unknown;
|
758
|
-
constructor({ content, cause, message, }: {
|
759
|
-
content: unknown;
|
760
|
-
cause?: unknown;
|
761
|
-
message?: string;
|
762
|
-
});
|
763
|
-
static isInstance(error: unknown): error is InvalidDataContentError;
|
764
|
-
}
|
842
|
+
@param model - The language model to use.
|
765
843
|
|
766
|
-
|
767
|
-
|
768
|
-
private readonly [symbol$4];
|
769
|
-
readonly role: string;
|
770
|
-
constructor({ role, message, }: {
|
771
|
-
role: string;
|
772
|
-
message?: string;
|
773
|
-
});
|
774
|
-
static isInstance(error: unknown): error is InvalidMessageRoleError;
|
775
|
-
}
|
844
|
+
@param tools - Tools that are accessible to and can be called by the model. The model needs to support calling tools.
|
845
|
+
@param toolChoice - The tool choice strategy. Default: 'auto'.
|
776
846
|
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
It always recurses into arrays.
|
847
|
+
@param system - A system message that will be part of the prompt.
|
848
|
+
@param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
849
|
+
@param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
781
850
|
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
851
|
+
@param maxOutputTokens - Maximum number of tokens to generate.
|
852
|
+
@param temperature - Temperature setting.
|
853
|
+
The value is passed through to the provider. The range depends on the provider and model.
|
854
|
+
It is recommended to set either `temperature` or `topP`, but not both.
|
855
|
+
@param topP - Nucleus sampling.
|
856
|
+
The value is passed through to the provider. The range depends on the provider and model.
|
857
|
+
It is recommended to set either `temperature` or `topP`, but not both.
|
858
|
+
@param topK - Only sample from the top K options for each subsequent token.
|
859
|
+
Used to remove "long tail" low probability responses.
|
860
|
+
Recommended for advanced use cases only. You usually only need to use temperature.
|
861
|
+
@param presencePenalty - Presence penalty setting.
|
862
|
+
It affects the likelihood of the model to repeat information that is already in the prompt.
|
863
|
+
The value is passed through to the provider. The range depends on the provider and model.
|
864
|
+
@param frequencyPenalty - Frequency penalty setting.
|
865
|
+
It affects the likelihood of the model to repeatedly use the same words or phrases.
|
866
|
+
The value is passed through to the provider. The range depends on the provider and model.
|
867
|
+
@param stopSequences - Stop sequences.
|
868
|
+
If set, the model will stop generating text when one of the stop sequences is generated.
|
869
|
+
@param seed - The seed (integer) to use for random sampling.
|
870
|
+
If set and supported by the model, calls will generate deterministic results.
|
793
871
|
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
output: InferToolOutput<TOOL>;
|
805
|
-
};
|
806
|
-
type UITools = Record<string, UITool>;
|
807
|
-
/**
|
808
|
-
AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
|
872
|
+
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
873
|
+
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
874
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
875
|
+
|
876
|
+
@param experimental_generateMessageId - Generate a unique ID for each message.
|
877
|
+
|
878
|
+
@param onStepFinish - Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
879
|
+
|
880
|
+
@returns
|
881
|
+
A result object that contains the generated text, the results of the tool calls, and additional information.
|
809
882
|
*/
|
810
|
-
|
883
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, stopWhen, experimental_output: output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
|
811
884
|
/**
|
812
|
-
|
885
|
+
The language model to use.
|
813
886
|
*/
|
814
|
-
|
887
|
+
model: LanguageModel;
|
815
888
|
/**
|
816
|
-
|
889
|
+
The tools that the model can call. The model needs to support calling tools.
|
890
|
+
*/
|
891
|
+
tools?: TOOLS;
|
892
|
+
/**
|
893
|
+
The tool choice strategy. Default: 'auto'.
|
817
894
|
*/
|
818
|
-
|
895
|
+
toolChoice?: ToolChoice<NoInfer<TOOLS>>;
|
819
896
|
/**
|
820
|
-
|
897
|
+
Condition for stopping the generation when there are tool results in the last step.
|
898
|
+
When the condition is an array, any of the conditions can be met to stop the generation.
|
899
|
+
|
900
|
+
@default stepCountIs(1)
|
821
901
|
*/
|
822
|
-
|
902
|
+
stopWhen?: StopCondition<NoInfer<TOOLS>> | Array<StopCondition<NoInfer<TOOLS>>>;
|
823
903
|
/**
|
824
|
-
|
825
|
-
|
826
|
-
System messages should be avoided (set the system prompt on the server instead).
|
827
|
-
They can have text parts.
|
828
|
-
|
829
|
-
User messages can have text parts and file parts.
|
830
|
-
|
831
|
-
Assistant messages can have text, reasoning, tool invocation, and file parts.
|
904
|
+
Optional telemetry configuration (experimental).
|
832
905
|
*/
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
906
|
+
experimental_telemetry?: TelemetrySettings;
|
907
|
+
/**
|
908
|
+
Additional provider-specific options. They are passed through
|
909
|
+
to the provider from the AI SDK and enable provider-specific
|
910
|
+
functionality that can be fully encapsulated in the provider.
|
911
|
+
*/
|
912
|
+
providerOptions?: ProviderOptions;
|
913
|
+
/**
|
914
|
+
* @deprecated Use `activeTools` instead.
|
915
|
+
*/
|
916
|
+
experimental_activeTools?: Array<keyof NoInfer<TOOLS>>;
|
917
|
+
/**
|
918
|
+
Limits the tools that are available for the model to call without
|
919
|
+
changing the tool call and result types in the result.
|
920
|
+
*/
|
921
|
+
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
922
|
+
/**
|
923
|
+
Optional specification for parsing structured outputs from the LLM response.
|
924
|
+
*/
|
925
|
+
experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
|
926
|
+
/**
|
927
|
+
* @deprecated Use `prepareStep` instead.
|
928
|
+
*/
|
929
|
+
experimental_prepareStep?: PrepareStepFunction<NoInfer<TOOLS>>;
|
930
|
+
/**
|
931
|
+
Optional function that you can use to provide different settings for a step.
|
932
|
+
*/
|
933
|
+
prepareStep?: PrepareStepFunction<NoInfer<TOOLS>>;
|
934
|
+
/**
|
935
|
+
A function that attempts to repair a tool call that failed to parse.
|
936
|
+
*/
|
937
|
+
experimental_repairToolCall?: ToolCallRepairFunction<NoInfer<TOOLS>>;
|
938
|
+
/**
|
939
|
+
Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
940
|
+
*/
|
941
|
+
onStepFinish?: GenerateTextOnStepFinishCallback<NoInfer<TOOLS>>;
|
942
|
+
/**
|
943
|
+
* Internal. For test use only. May change without notice.
|
944
|
+
*/
|
945
|
+
_internal?: {
|
946
|
+
generateId?: IdGenerator;
|
947
|
+
currentDate?: () => Date;
|
948
|
+
};
|
949
|
+
}): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
950
|
+
|
951
|
+
/**
|
952
|
+
The data types that can be used in the UI message for the UI message data parts.
|
953
|
+
*/
|
954
|
+
type UIDataTypes = Record<string, unknown>;
|
955
|
+
type UITool = {
|
956
|
+
input: unknown;
|
957
|
+
output: unknown | undefined;
|
958
|
+
};
|
959
|
+
type InferUITool<TOOL extends Tool> = {
|
960
|
+
input: InferToolInput<TOOL>;
|
961
|
+
output: InferToolOutput<TOOL>;
|
962
|
+
};
|
963
|
+
type UITools = Record<string, UITool>;
|
964
|
+
/**
|
965
|
+
AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
|
966
|
+
*/
|
967
|
+
interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataTypes, TOOLS extends UITools = UITools> {
|
968
|
+
/**
|
969
|
+
A unique identifier for the message.
|
970
|
+
*/
|
971
|
+
id: string;
|
972
|
+
/**
|
973
|
+
The role of the message.
|
974
|
+
*/
|
975
|
+
role: 'system' | 'user' | 'assistant';
|
976
|
+
/**
|
977
|
+
The metadata of the message.
|
978
|
+
*/
|
979
|
+
metadata?: METADATA;
|
980
|
+
/**
|
981
|
+
The parts of the message. Use this for rendering the message in the UI.
|
982
|
+
|
983
|
+
System messages should be avoided (set the system prompt on the server instead).
|
984
|
+
They can have text parts.
|
985
|
+
|
986
|
+
User messages can have text parts and file parts.
|
987
|
+
|
988
|
+
Assistant messages can have text, reasoning, tool invocation, and file parts.
|
989
|
+
*/
|
990
|
+
parts: Array<UIMessagePart<DATA_PARTS, TOOLS>>;
|
991
|
+
}
|
992
|
+
type UIMessagePart<DATA_TYPES extends UIDataTypes, TOOLS extends UITools> = TextUIPart | ReasoningUIPart | ToolUIPart<TOOLS> | SourceUrlUIPart | SourceDocumentUIPart | FileUIPart | DataUIPart<DATA_TYPES> | StepStartUIPart;
|
993
|
+
/**
|
994
|
+
* A text part of a message.
|
838
995
|
*/
|
839
996
|
type TextUIPart = {
|
840
997
|
type: 'text';
|
@@ -949,82 +1106,15 @@ declare function getToolName<TOOLS extends UITools>(part: ToolUIPart<TOOLS>): ke
|
|
949
1106
|
type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA> ? METADATA : unknown;
|
950
1107
|
type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unknown, infer DATA_TYPES> ? DATA_TYPES : UIDataTypes;
|
951
1108
|
|
952
|
-
|
953
|
-
declare class MessageConversionError extends AISDKError {
|
954
|
-
private readonly [symbol$3];
|
955
|
-
readonly originalMessage: Omit<UIMessage, 'id'>;
|
956
|
-
constructor({ originalMessage, message, }: {
|
957
|
-
originalMessage: Omit<UIMessage, 'id'>;
|
958
|
-
message: string;
|
959
|
-
});
|
960
|
-
static isInstance(error: unknown): error is MessageConversionError;
|
961
|
-
}
|
962
|
-
|
963
|
-
declare const symbol$2: unique symbol;
|
964
|
-
declare class DownloadError extends AISDKError {
|
965
|
-
private readonly [symbol$2];
|
966
|
-
readonly url: string;
|
967
|
-
readonly statusCode?: number;
|
968
|
-
readonly statusText?: string;
|
969
|
-
constructor({ url, statusCode, statusText, cause, message, }: {
|
970
|
-
url: string;
|
971
|
-
statusCode?: number;
|
972
|
-
statusText?: string;
|
973
|
-
message?: string;
|
974
|
-
cause?: unknown;
|
975
|
-
});
|
976
|
-
static isInstance(error: unknown): error is DownloadError;
|
977
|
-
}
|
978
|
-
|
979
|
-
declare const symbol$1: unique symbol;
|
980
|
-
type RetryErrorReason = 'maxRetriesExceeded' | 'errorNotRetryable' | 'abort';
|
981
|
-
declare class RetryError extends AISDKError {
|
982
|
-
private readonly [symbol$1];
|
983
|
-
readonly reason: RetryErrorReason;
|
984
|
-
readonly lastError: unknown;
|
985
|
-
readonly errors: Array<unknown>;
|
986
|
-
constructor({ message, reason, errors, }: {
|
987
|
-
message: string;
|
988
|
-
reason: RetryErrorReason;
|
989
|
-
errors: Array<unknown>;
|
990
|
-
});
|
991
|
-
static isInstance(error: unknown): error is RetryError;
|
992
|
-
}
|
993
|
-
|
994
|
-
declare function createTextStreamResponse({ status, statusText, headers, textStream, }: ResponseInit & {
|
995
|
-
textStream: ReadableStream<string>;
|
996
|
-
}): Response;
|
997
|
-
|
998
|
-
declare function pipeTextStreamToResponse({ response, status, statusText, headers, textStream, }: {
|
999
|
-
response: ServerResponse;
|
1000
|
-
textStream: ReadableStream<string>;
|
1001
|
-
} & ResponseInit): void;
|
1002
|
-
|
1003
|
-
declare const getOriginalFetch: () => typeof fetch;
|
1004
|
-
declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
|
1005
|
-
api: string;
|
1006
|
-
prompt: string;
|
1007
|
-
credentials: RequestCredentials | undefined;
|
1008
|
-
headers: HeadersInit | undefined;
|
1009
|
-
body: Record<string, any>;
|
1010
|
-
streamProtocol: 'data' | 'text' | undefined;
|
1011
|
-
setCompletion: (completion: string) => void;
|
1012
|
-
setLoading: (loading: boolean) => void;
|
1013
|
-
setError: (error: Error | undefined) => void;
|
1014
|
-
setAbortController: (abortController: AbortController | null) => void;
|
1015
|
-
onFinish: ((prompt: string, completion: string) => void) | undefined;
|
1016
|
-
onError: ((error: Error) => void) | undefined;
|
1017
|
-
fetch: ReturnType<typeof getOriginalFetch> | undefined;
|
1018
|
-
}): Promise<string | null | undefined>;
|
1019
|
-
|
1020
|
-
type DataUIMessageStreamPart<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
1109
|
+
type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
1021
1110
|
[NAME in keyof DATA_TYPES & string]: {
|
1022
1111
|
type: `data-${NAME}`;
|
1023
1112
|
id?: string;
|
1024
1113
|
data: DATA_TYPES[NAME];
|
1114
|
+
transient?: boolean;
|
1025
1115
|
};
|
1026
1116
|
}>;
|
1027
|
-
type
|
1117
|
+
type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataTypes> = {
|
1028
1118
|
type: 'text-start';
|
1029
1119
|
id: string;
|
1030
1120
|
} | {
|
@@ -1092,7 +1182,7 @@ type UIMessageStreamPart<METADATA = unknown, DATA_TYPES extends UIDataTypes = UI
|
|
1092
1182
|
type: 'file';
|
1093
1183
|
url: string;
|
1094
1184
|
mediaType: string;
|
1095
|
-
} |
|
1185
|
+
} | DataUIMessageChunk<DATA_TYPES> | {
|
1096
1186
|
type: 'start-step';
|
1097
1187
|
} | {
|
1098
1188
|
type: 'finish-step';
|
@@ -1107,30 +1197,19 @@ type UIMessageStreamPart<METADATA = unknown, DATA_TYPES extends UIDataTypes = UI
|
|
1107
1197
|
type: 'message-metadata';
|
1108
1198
|
messageMetadata: METADATA;
|
1109
1199
|
};
|
1110
|
-
type
|
1200
|
+
type InferUIMessageChunk<T extends UIMessage> = UIMessageChunk<InferUIMessageMetadata<T>, InferUIMessageData<T>>;
|
1111
1201
|
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
/**
|
1118
|
-
* Merges the contents of another stream to this stream.
|
1119
|
-
*/
|
1120
|
-
merge(stream: ReadableStream<InferUIMessageStreamPart<UI_MESSAGE>>): void;
|
1121
|
-
/**
|
1122
|
-
* Error handler that is used by the data stream writer.
|
1123
|
-
* This is intended for forwarding when merging streams
|
1124
|
-
* to prevent duplicated error masking.
|
1125
|
-
*/
|
1126
|
-
onError: ((error: unknown) => string) | undefined;
|
1127
|
-
}
|
1202
|
+
type UIMessageStreamResponseInit = ResponseInit & {
|
1203
|
+
consumeSseStream?: (options: {
|
1204
|
+
stream: ReadableStream<string>;
|
1205
|
+
}) => PromiseLike<void> | void;
|
1206
|
+
};
|
1128
1207
|
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1208
|
+
type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
1209
|
+
|
1210
|
+
type ErrorHandler = (error: unknown) => void;
|
1211
|
+
|
1212
|
+
type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
1134
1213
|
/**
|
1135
1214
|
* The original messages. If they are provided, persistence mode is assumed,
|
1136
1215
|
* and a message ID is provided for the response message.
|
@@ -1152,615 +1231,446 @@ declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute,
|
|
1152
1231
|
*/
|
1153
1232
|
responseMessage: UI_MESSAGE;
|
1154
1233
|
}) => void;
|
1155
|
-
generateId?: IdGenerator;
|
1156
|
-
}): ReadableStream<InferUIMessageStreamPart<UI_MESSAGE>>;
|
1157
|
-
|
1158
|
-
type UIMessageStreamResponseInit = ResponseInit & {
|
1159
|
-
consumeSseStream?: (options: {
|
1160
|
-
stream: ReadableStream<string>;
|
1161
|
-
}) => PromiseLike<void> | void;
|
1162
|
-
};
|
1163
|
-
|
1164
|
-
declare function createUIMessageStreamResponse({ status, statusText, headers, stream, consumeSseStream, }: UIMessageStreamResponseInit & {
|
1165
|
-
stream: ReadableStream<UIMessageStreamPart>;
|
1166
|
-
}): Response;
|
1167
|
-
|
1168
|
-
declare class JsonToSseTransformStream extends TransformStream<unknown, string> {
|
1169
|
-
constructor();
|
1170
|
-
}
|
1171
|
-
|
1172
|
-
declare function pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, consumeSseStream, }: {
|
1173
|
-
response: ServerResponse;
|
1174
|
-
stream: ReadableStream<UIMessageStreamPart>;
|
1175
|
-
} & UIMessageStreamResponseInit): void;
|
1176
|
-
|
1177
|
-
declare const UI_MESSAGE_STREAM_HEADERS: {
|
1178
|
-
'content-type': string;
|
1179
|
-
'cache-control': string;
|
1180
|
-
connection: string;
|
1181
|
-
'x-vercel-ai-ui-message-stream': string;
|
1182
|
-
'x-accel-buffering': string;
|
1183
|
-
};
|
1184
|
-
|
1185
|
-
interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
1186
|
-
sendMessages: (options: {
|
1187
|
-
chatId: string;
|
1188
|
-
messages: UI_MESSAGE[];
|
1189
|
-
abortSignal: AbortSignal | undefined;
|
1190
|
-
} & {
|
1191
|
-
trigger: 'submit-user-message' | 'submit-tool-result' | 'regenerate-assistant-message';
|
1192
|
-
messageId: string | undefined;
|
1193
|
-
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageStreamPart>>;
|
1194
|
-
reconnectToStream: (options: {
|
1195
|
-
chatId: string;
|
1196
|
-
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageStreamPart> | null>;
|
1197
|
-
}
|
1198
|
-
|
1199
|
-
type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'role'> & {
|
1200
|
-
id?: UI_MESSAGE['id'];
|
1201
|
-
role?: UI_MESSAGE['role'];
|
1202
|
-
};
|
1203
|
-
type UIDataPartSchemas = Record<string, Validator<any> | StandardSchemaV1<any>>;
|
1204
|
-
type UIDataTypesToSchemas<T extends UIDataTypes> = {
|
1205
|
-
[K in keyof T]: Validator<T[K]> | StandardSchemaV1<T[K]>;
|
1206
|
-
};
|
1207
|
-
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
1208
|
-
[K in keyof T]: T[K] extends Validator<infer U> ? U : T[K] extends StandardSchemaV1<infer U> ? U : unknown;
|
1209
|
-
};
|
1210
|
-
type ChatRequestOptions = {
|
1211
1234
|
/**
|
1212
|
-
|
1235
|
+
* Extracts message metadata that will be send to the client.
|
1236
|
+
*
|
1237
|
+
* Called on `start` and `finish` events.
|
1213
1238
|
*/
|
1214
|
-
|
1239
|
+
messageMetadata?: (options: {
|
1240
|
+
part: TextStreamPart<ToolSet>;
|
1241
|
+
}) => InferUIMessageMetadata<UI_MESSAGE> | undefined;
|
1215
1242
|
/**
|
1216
|
-
|
1243
|
+
* Send reasoning parts to the client.
|
1244
|
+
* Default to true.
|
1217
1245
|
*/
|
1218
|
-
|
1219
|
-
metadata?: unknown;
|
1220
|
-
};
|
1221
|
-
type ChatStatus = 'submitted' | 'streaming' | 'ready' | 'error';
|
1222
|
-
interface ChatState<UI_MESSAGE extends UIMessage> {
|
1223
|
-
status: ChatStatus;
|
1224
|
-
error: Error | undefined;
|
1225
|
-
messages: UI_MESSAGE[];
|
1226
|
-
pushMessage: (message: UI_MESSAGE) => void;
|
1227
|
-
popMessage: () => void;
|
1228
|
-
replaceMessage: (index: number, message: UI_MESSAGE) => void;
|
1229
|
-
snapshot: <T>(thing: T) => T;
|
1230
|
-
}
|
1231
|
-
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
1232
|
-
/**
|
1233
|
-
* A unique identifier for the chat. If not provided, a random one will be
|
1234
|
-
* generated.
|
1235
|
-
*/
|
1236
|
-
id?: string;
|
1237
|
-
messageMetadataSchema?: Validator<InferUIMessageMetadata<UI_MESSAGE>> | StandardSchemaV1<InferUIMessageMetadata<UI_MESSAGE>>;
|
1238
|
-
dataPartSchemas?: UIDataTypesToSchemas<InferUIMessageData<UI_MESSAGE>>;
|
1239
|
-
messages?: UI_MESSAGE[];
|
1246
|
+
sendReasoning?: boolean;
|
1240
1247
|
/**
|
1241
|
-
*
|
1242
|
-
*
|
1248
|
+
* Send source parts to the client.
|
1249
|
+
* Default to false.
|
1243
1250
|
*/
|
1244
|
-
|
1245
|
-
transport?: ChatTransport<UI_MESSAGE>;
|
1246
|
-
maxSteps?: number;
|
1251
|
+
sendSources?: boolean;
|
1247
1252
|
/**
|
1248
|
-
*
|
1253
|
+
* Send the finish event to the client.
|
1254
|
+
* Set to false if you are using additional streamText calls
|
1255
|
+
* that send additional data.
|
1256
|
+
* Default to true.
|
1249
1257
|
*/
|
1250
|
-
|
1251
|
-
/**
|
1252
|
-
Optional callback function that is invoked when a tool call is received.
|
1253
|
-
Intended for automatic client-side tool execution.
|
1254
|
-
|
1255
|
-
You can optionally return a result for the tool call,
|
1256
|
-
either synchronously or asynchronously.
|
1257
|
-
*/
|
1258
|
-
onToolCall?: ({ toolCall, }: {
|
1259
|
-
toolCall: ToolCall<string, unknown>;
|
1260
|
-
}) => void | Promise<unknown> | unknown;
|
1258
|
+
sendFinish?: boolean;
|
1261
1259
|
/**
|
1262
|
-
*
|
1260
|
+
* Send the message start event to the client.
|
1261
|
+
* Set to false if you are using additional streamText calls
|
1262
|
+
* and the message start event has already been sent.
|
1263
|
+
* Default to true.
|
1263
1264
|
*
|
1264
|
-
*
|
1265
|
+
* Note: this setting is currently not used, but you should
|
1266
|
+
* already set it to false if you are using additional
|
1267
|
+
* streamText calls that send additional data to prevent
|
1268
|
+
* the message start event from being sent multiple times.
|
1265
1269
|
*/
|
1266
|
-
|
1267
|
-
message: UI_MESSAGE;
|
1268
|
-
}) => void;
|
1269
|
-
}
|
1270
|
-
declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
1271
|
-
readonly id: string;
|
1272
|
-
readonly generateId: IdGenerator;
|
1273
|
-
protected state: ChatState<UI_MESSAGE>;
|
1274
|
-
private messageMetadataSchema;
|
1275
|
-
private dataPartSchemas;
|
1276
|
-
private readonly transport;
|
1277
|
-
private maxSteps;
|
1278
|
-
private onError?;
|
1279
|
-
private onToolCall?;
|
1280
|
-
private onFinish?;
|
1281
|
-
private activeResponse;
|
1282
|
-
private jobExecutor;
|
1283
|
-
constructor({ generateId, id, transport, maxSteps, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
1284
|
-
state: ChatState<UI_MESSAGE>;
|
1285
|
-
});
|
1270
|
+
sendStart?: boolean;
|
1286
1271
|
/**
|
1287
|
-
*
|
1272
|
+
* Process an error, e.g. to log it. Default to `() => 'An error occurred.'`.
|
1288
1273
|
*
|
1289
|
-
*
|
1290
|
-
* - `streaming`: The response is actively streaming in from the API, receiving chunks of data.
|
1291
|
-
* - `ready`: The full response has been received and processed; a new user message can be submitted.
|
1292
|
-
* - `error`: An error occurred during the API request, preventing successful completion.
|
1274
|
+
* @return error message to include in the data stream.
|
1293
1275
|
*/
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1276
|
+
onError?: (error: unknown) => string;
|
1277
|
+
};
|
1278
|
+
type ConsumeStreamOptions = {
|
1279
|
+
onError?: ErrorHandler;
|
1280
|
+
};
|
1281
|
+
/**
|
1282
|
+
A result object for accessing different stream types and additional information.
|
1283
|
+
*/
|
1284
|
+
interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
1303
1285
|
/**
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
* If a messageId is provided, the message will be replaced.
|
1286
|
+
The content that was generated in the last step.
|
1287
|
+
|
1288
|
+
Resolved when the response is finished.
|
1308
1289
|
*/
|
1309
|
-
|
1310
|
-
text?: never;
|
1311
|
-
files?: never;
|
1312
|
-
messageId?: string;
|
1313
|
-
}) | {
|
1314
|
-
text: string;
|
1315
|
-
files?: FileList | FileUIPart[];
|
1316
|
-
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
1317
|
-
parts?: never;
|
1318
|
-
messageId?: string;
|
1319
|
-
} | {
|
1320
|
-
files: FileList | FileUIPart[];
|
1321
|
-
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
1322
|
-
parts?: never;
|
1323
|
-
messageId?: string;
|
1324
|
-
}, options?: ChatRequestOptions) => Promise<void>;
|
1290
|
+
readonly content: Promise<Array<ContentPart<TOOLS>>>;
|
1325
1291
|
/**
|
1326
|
-
|
1327
|
-
|
1292
|
+
The full text that has been generated by the last step.
|
1293
|
+
|
1294
|
+
Resolved when the response is finished.
|
1295
|
+
*/
|
1296
|
+
readonly text: Promise<string>;
|
1297
|
+
/**
|
1298
|
+
The full reasoning that the model has generated.
|
1299
|
+
|
1300
|
+
Resolved when the response is finished.
|
1328
1301
|
*/
|
1329
|
-
|
1330
|
-
messageId?: string;
|
1331
|
-
} & ChatRequestOptions) => Promise<void>;
|
1302
|
+
readonly reasoning: Promise<Array<ReasoningPart>>;
|
1332
1303
|
/**
|
1333
|
-
|
1304
|
+
The reasoning that has been generated by the last step.
|
1305
|
+
|
1306
|
+
Resolved when the response is finished.
|
1307
|
+
*/
|
1308
|
+
readonly reasoningText: Promise<string | undefined>;
|
1309
|
+
/**
|
1310
|
+
Files that have been generated by the model in the last step.
|
1311
|
+
|
1312
|
+
Resolved when the response is finished.
|
1334
1313
|
*/
|
1335
|
-
|
1336
|
-
addToolResult: ({ toolCallId, output, }: {
|
1337
|
-
toolCallId: string;
|
1338
|
-
output: unknown;
|
1339
|
-
}) => Promise<void>;
|
1314
|
+
readonly files: Promise<GeneratedFile[]>;
|
1340
1315
|
/**
|
1341
|
-
|
1316
|
+
Sources that have been used as references in the last step.
|
1317
|
+
|
1318
|
+
Resolved when the response is finished.
|
1342
1319
|
*/
|
1343
|
-
|
1344
|
-
private makeRequest;
|
1345
|
-
}
|
1346
|
-
|
1347
|
-
declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
1348
|
-
|
1349
|
-
/**
|
1350
|
-
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
1351
|
-
with the AI core functions (e.g. `streamText`).
|
1352
|
-
*/
|
1353
|
-
declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
|
1354
|
-
tools?: ToolSet;
|
1355
|
-
}): ModelMessage[];
|
1356
|
-
/**
|
1357
|
-
@deprecated Use `convertToModelMessages` instead.
|
1358
|
-
*/
|
1359
|
-
declare const convertToCoreMessages: typeof convertToModelMessages;
|
1360
|
-
|
1361
|
-
type PrepareSendMessagesRequest<UI_MESSAGE extends UIMessage> = (options: {
|
1362
|
-
id: string;
|
1363
|
-
messages: UI_MESSAGE[];
|
1364
|
-
requestMetadata: unknown;
|
1365
|
-
body: Record<string, any> | undefined;
|
1366
|
-
credentials: RequestCredentials | undefined;
|
1367
|
-
headers: HeadersInit | undefined;
|
1368
|
-
api: string;
|
1369
|
-
} & {
|
1370
|
-
trigger: 'submit-user-message' | 'submit-tool-result' | 'regenerate-assistant-message';
|
1371
|
-
messageId: string | undefined;
|
1372
|
-
}) => {
|
1373
|
-
body: object;
|
1374
|
-
headers?: HeadersInit;
|
1375
|
-
credentials?: RequestCredentials;
|
1376
|
-
api?: string;
|
1377
|
-
};
|
1378
|
-
type PrepareReconnectToStreamRequest = (options: {
|
1379
|
-
id: string;
|
1380
|
-
requestMetadata: unknown;
|
1381
|
-
body: Record<string, any> | undefined;
|
1382
|
-
credentials: RequestCredentials | undefined;
|
1383
|
-
headers: HeadersInit | undefined;
|
1384
|
-
api: string;
|
1385
|
-
}) => {
|
1386
|
-
headers?: HeadersInit;
|
1387
|
-
credentials?: RequestCredentials;
|
1388
|
-
api?: string;
|
1389
|
-
};
|
1390
|
-
type HttpChatTransportInitOptions<UI_MESSAGE extends UIMessage> = {
|
1391
|
-
api?: string;
|
1320
|
+
readonly sources: Promise<Source[]>;
|
1392
1321
|
/**
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1322
|
+
The tool calls that have been executed in the last step.
|
1323
|
+
|
1324
|
+
Resolved when the response is finished.
|
1325
|
+
*/
|
1326
|
+
readonly toolCalls: Promise<ToolCallUnion<TOOLS>[]>;
|
1327
|
+
/**
|
1328
|
+
The tool results that have been generated in the last step.
|
1329
|
+
|
1330
|
+
Resolved when the all tool executions are finished.
|
1396
1331
|
*/
|
1397
|
-
|
1332
|
+
readonly toolResults: Promise<ToolResultUnion<TOOLS>[]>;
|
1398
1333
|
/**
|
1399
|
-
|
1334
|
+
The reason why the generation finished. Taken from the last step.
|
1335
|
+
|
1336
|
+
Resolved when the response is finished.
|
1337
|
+
*/
|
1338
|
+
readonly finishReason: Promise<FinishReason>;
|
1339
|
+
/**
|
1340
|
+
The token usage of the last step.
|
1341
|
+
|
1342
|
+
Resolved when the response is finished.
|
1400
1343
|
*/
|
1401
|
-
|
1344
|
+
readonly usage: Promise<LanguageModelUsage>;
|
1402
1345
|
/**
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1346
|
+
The total token usage of the generated response.
|
1347
|
+
When there are multiple steps, the usage is the sum of all step usages.
|
1348
|
+
|
1349
|
+
Resolved when the response is finished.
|
1350
|
+
*/
|
1351
|
+
readonly totalUsage: Promise<LanguageModelUsage>;
|
1352
|
+
/**
|
1353
|
+
Warnings from the model provider (e.g. unsupported settings) for the first step.
|
1354
|
+
*/
|
1355
|
+
readonly warnings: Promise<CallWarning[] | undefined>;
|
1356
|
+
/**
|
1357
|
+
Details for all steps.
|
1358
|
+
You can use this to get information about intermediate steps,
|
1359
|
+
such as the tool calls or the response headers.
|
1413
1360
|
*/
|
1414
|
-
|
1361
|
+
readonly steps: Promise<Array<StepResult<TOOLS>>>;
|
1415
1362
|
/**
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
fetch?: FetchFunction;
|
1363
|
+
Additional request information from the last step.
|
1364
|
+
*/
|
1365
|
+
readonly request: Promise<LanguageModelRequestMetadata>;
|
1420
1366
|
/**
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
protected credentials?: RequestCredentials;
|
1435
|
-
protected headers?: Record<string, string> | Headers;
|
1436
|
-
protected body?: object;
|
1437
|
-
protected fetch: FetchFunction;
|
1438
|
-
protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
1439
|
-
protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
1440
|
-
constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest, }: HttpChatTransportInitOptions<UI_MESSAGE>);
|
1441
|
-
sendMessages({ abortSignal, ...options }: Parameters<ChatTransport<UI_MESSAGE>['sendMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
|
1442
|
-
reconnectToStream(options: Parameters<ChatTransport<UI_MESSAGE>['reconnectToStream']>[0]): Promise<ReadableStream<UIMessageStreamPart> | null>;
|
1443
|
-
protected abstract processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageStreamPart>;
|
1444
|
-
}
|
1445
|
-
|
1446
|
-
declare class DefaultChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
|
1447
|
-
constructor(options?: HttpChatTransportInitOptions<UI_MESSAGE>);
|
1448
|
-
protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageStreamPart>;
|
1449
|
-
}
|
1450
|
-
|
1451
|
-
declare class TextStreamChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
|
1452
|
-
constructor(options?: HttpChatTransportInitOptions<UI_MESSAGE>);
|
1453
|
-
protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageStreamPart>;
|
1454
|
-
}
|
1455
|
-
|
1456
|
-
type CompletionRequestOptions = {
|
1367
|
+
Additional response information from the last step.
|
1368
|
+
*/
|
1369
|
+
readonly response: Promise<LanguageModelResponseMetadata & {
|
1370
|
+
/**
|
1371
|
+
The response messages that were generated during the call. It consists of an assistant message,
|
1372
|
+
potentially containing tool calls.
|
1373
|
+
|
1374
|
+
When there are tool results, there is an additional tool message with the tool results that are available.
|
1375
|
+
If there are tools that do not have execute functions, they are not included in the tool results and
|
1376
|
+
need to be added separately.
|
1377
|
+
*/
|
1378
|
+
messages: Array<ResponseMessage>;
|
1379
|
+
}>;
|
1457
1380
|
/**
|
1458
|
-
|
1381
|
+
Additional provider-specific metadata from the last step.
|
1382
|
+
Metadata is passed through from the provider to the AI SDK and
|
1383
|
+
enables provider-specific results that can be fully encapsulated in the provider.
|
1459
1384
|
*/
|
1460
|
-
|
1385
|
+
readonly providerMetadata: Promise<ProviderMetadata | undefined>;
|
1461
1386
|
/**
|
1462
|
-
|
1387
|
+
A text stream that returns only the generated text deltas. You can use it
|
1388
|
+
as either an AsyncIterable or a ReadableStream. When an error occurs, the
|
1389
|
+
stream will throw the error.
|
1463
1390
|
*/
|
1464
|
-
|
1465
|
-
};
|
1466
|
-
type UseCompletionOptions = {
|
1467
|
-
/**
|
1468
|
-
* The API endpoint that accepts a `{ prompt: string }` object and returns
|
1469
|
-
* a stream of tokens of the AI completion response. Defaults to `/api/completion`.
|
1470
|
-
*/
|
1471
|
-
api?: string;
|
1472
|
-
/**
|
1473
|
-
* An unique identifier for the chat. If not provided, a random one will be
|
1474
|
-
* generated. When provided, the `useChat` hook with the same `id` will
|
1475
|
-
* have shared states across components.
|
1476
|
-
*/
|
1477
|
-
id?: string;
|
1478
|
-
/**
|
1479
|
-
* Initial prompt input of the completion.
|
1480
|
-
*/
|
1481
|
-
initialInput?: string;
|
1391
|
+
readonly textStream: AsyncIterableStream<string>;
|
1482
1392
|
/**
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1393
|
+
A stream with all events, including text deltas, tool calls, tool results, and
|
1394
|
+
errors.
|
1395
|
+
You can use it as either an AsyncIterable or a ReadableStream.
|
1396
|
+
Only errors that stop the stream, such as network errors, are thrown.
|
1397
|
+
*/
|
1398
|
+
readonly fullStream: AsyncIterableStream<TextStreamPart<TOOLS>>;
|
1486
1399
|
/**
|
1487
|
-
|
1400
|
+
A stream of partial outputs. It uses the `experimental_output` specification.
|
1488
1401
|
*/
|
1489
|
-
|
1402
|
+
readonly experimental_partialOutputStream: AsyncIterableStream<PARTIAL_OUTPUT>;
|
1490
1403
|
/**
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1404
|
+
Consumes the stream without processing the parts.
|
1405
|
+
This is useful to force the stream to finish.
|
1406
|
+
It effectively removes the backpressure and allows the stream to finish,
|
1407
|
+
triggering the `onFinish` callback and the promise resolution.
|
1408
|
+
|
1409
|
+
If an error occurs, it is passed to the optional `onError` callback.
|
1410
|
+
*/
|
1411
|
+
consumeStream(options?: ConsumeStreamOptions): Promise<void>;
|
1494
1412
|
/**
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1413
|
+
Converts the result to a UI message stream.
|
1414
|
+
|
1415
|
+
@param options.getErrorMessage an optional function that converts an error to an error message.
|
1416
|
+
@param options.sendUsage whether to send the usage information to the client. Defaults to true.
|
1417
|
+
@param options.sendReasoning whether to send the reasoning information to the client. Defaults to false.
|
1418
|
+
@param options.sendSources whether to send the sources information to the client. Defaults to false.
|
1419
|
+
@param options.experimental_sendFinish whether to send the finish information to the client. Defaults to true.
|
1420
|
+
@param options.experimental_sendStart whether to send the start information to the client. Defaults to true.
|
1421
|
+
|
1422
|
+
@return A UI message stream.
|
1423
|
+
*/
|
1424
|
+
toUIMessageStream<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamOptions<UI_MESSAGE>): ReadableStream<InferUIMessageChunk<UI_MESSAGE>>;
|
1500
1425
|
/**
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1426
|
+
Writes UI message stream output to a Node.js response-like object.
|
1427
|
+
@param response A Node.js response-like object (ServerResponse).
|
1428
|
+
@param options.status The status code.
|
1429
|
+
@param options.statusText The status text.
|
1430
|
+
@param options.headers The headers.
|
1431
|
+
@param options.getErrorMessage An optional function that converts an error to an error message.
|
1432
|
+
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
1433
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
1434
|
+
*/
|
1435
|
+
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): void;
|
1504
1436
|
/**
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
* }
|
1513
|
-
* })
|
1514
|
-
* ```
|
1515
|
-
*/
|
1516
|
-
body?: object;
|
1437
|
+
Writes text delta output to a Node.js response-like object.
|
1438
|
+
It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
1439
|
+
writes each text delta as a separate chunk.
|
1440
|
+
@param response A Node.js response-like object (ServerResponse).
|
1441
|
+
@param init Optional headers, status code, and status text.
|
1442
|
+
*/
|
1443
|
+
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void;
|
1517
1444
|
/**
|
1518
|
-
|
1445
|
+
Converts the result to a streamed response object with a stream data part stream.
|
1446
|
+
|
1447
|
+
@param options.status The status code.
|
1448
|
+
@param options.statusText The status text.
|
1449
|
+
@param options.headers The headers.
|
1450
|
+
@param options.getErrorMessage An optional function that converts an error to an error message.
|
1451
|
+
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
1452
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
1453
|
+
@return A response object.
|
1519
1454
|
*/
|
1520
|
-
|
1455
|
+
toUIMessageStreamResponse<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Response;
|
1521
1456
|
/**
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
/**
|
1529
|
-
* Calculates the cosine similarity between two vectors. This is a useful metric for
|
1530
|
-
* comparing the similarity of two vectors such as embeddings.
|
1531
|
-
*
|
1532
|
-
* @param vector1 - The first vector.
|
1533
|
-
* @param vector2 - The second vector.
|
1534
|
-
*
|
1535
|
-
* @returns The cosine similarity between vector1 and vector2.
|
1536
|
-
* @returns 0 if either vector is the zero vector.
|
1537
|
-
*
|
1538
|
-
* @throws {InvalidArgumentError} If the vectors do not have the same length.
|
1539
|
-
*/
|
1540
|
-
declare function cosineSimilarity(vector1: number[], vector2: number[]): number;
|
1541
|
-
|
1542
|
-
/**
|
1543
|
-
* Converts a data URL of type text/* to a text string.
|
1544
|
-
*/
|
1545
|
-
declare function getTextFromDataUrl(dataUrl: string): string;
|
1546
|
-
|
1547
|
-
/**
|
1548
|
-
* Performs a deep-equal comparison of two parsed JSON objects.
|
1549
|
-
*
|
1550
|
-
* @param {any} obj1 - The first object to compare.
|
1551
|
-
* @param {any} obj2 - The second object to compare.
|
1552
|
-
* @returns {boolean} - Returns true if the two objects are deeply equal, false otherwise.
|
1553
|
-
*/
|
1554
|
-
declare function isDeepEqualData(obj1: any, obj2: any): boolean;
|
1555
|
-
|
1556
|
-
declare function parsePartialJson(jsonText: string | undefined): Promise<{
|
1557
|
-
value: JSONValue$1 | undefined;
|
1558
|
-
state: 'undefined-input' | 'successful-parse' | 'repaired-parse' | 'failed-parse';
|
1559
|
-
}>;
|
1560
|
-
|
1561
|
-
type Job = () => Promise<void>;
|
1562
|
-
|
1563
|
-
declare class SerialJobExecutor {
|
1564
|
-
private queue;
|
1565
|
-
private isProcessing;
|
1566
|
-
private processQueue;
|
1567
|
-
run(job: Job): Promise<void>;
|
1457
|
+
Creates a simple text stream response.
|
1458
|
+
Each text delta is encoded as UTF-8 and sent as a separate chunk.
|
1459
|
+
Non-text-delta events are ignored.
|
1460
|
+
@param init Optional headers, status code, and status text.
|
1461
|
+
*/
|
1462
|
+
toTextStreamResponse(init?: ResponseInit): Response;
|
1568
1463
|
}
|
1464
|
+
type TextStreamPart<TOOLS extends ToolSet> = {
|
1465
|
+
type: 'text-start';
|
1466
|
+
id: string;
|
1467
|
+
providerMetadata?: ProviderMetadata;
|
1468
|
+
} | {
|
1469
|
+
type: 'text-end';
|
1470
|
+
id: string;
|
1471
|
+
providerMetadata?: ProviderMetadata;
|
1472
|
+
} | {
|
1473
|
+
type: 'text';
|
1474
|
+
id: string;
|
1475
|
+
providerMetadata?: ProviderMetadata;
|
1476
|
+
text: string;
|
1477
|
+
} | {
|
1478
|
+
type: 'reasoning-start';
|
1479
|
+
id: string;
|
1480
|
+
providerMetadata?: ProviderMetadata;
|
1481
|
+
} | {
|
1482
|
+
type: 'reasoning-end';
|
1483
|
+
id: string;
|
1484
|
+
providerMetadata?: ProviderMetadata;
|
1485
|
+
} | {
|
1486
|
+
type: 'reasoning';
|
1487
|
+
providerMetadata?: ProviderMetadata;
|
1488
|
+
id: string;
|
1489
|
+
text: string;
|
1490
|
+
} | {
|
1491
|
+
type: 'tool-input-start';
|
1492
|
+
id: string;
|
1493
|
+
toolName: string;
|
1494
|
+
providerMetadata?: ProviderMetadata;
|
1495
|
+
providerExecuted?: boolean;
|
1496
|
+
} | {
|
1497
|
+
type: 'tool-input-end';
|
1498
|
+
id: string;
|
1499
|
+
providerMetadata?: ProviderMetadata;
|
1500
|
+
} | {
|
1501
|
+
type: 'tool-input-delta';
|
1502
|
+
id: string;
|
1503
|
+
delta: string;
|
1504
|
+
providerMetadata?: ProviderMetadata;
|
1505
|
+
} | ({
|
1506
|
+
type: 'source';
|
1507
|
+
} & Source) | {
|
1508
|
+
type: 'file';
|
1509
|
+
file: GeneratedFile;
|
1510
|
+
} | ({
|
1511
|
+
type: 'tool-call';
|
1512
|
+
} & ToolCallUnion<TOOLS>) | ({
|
1513
|
+
type: 'tool-result';
|
1514
|
+
} & ToolResultUnion<TOOLS>) | ({
|
1515
|
+
type: 'tool-error';
|
1516
|
+
} & ToolErrorUnion<TOOLS>) | {
|
1517
|
+
type: 'start-step';
|
1518
|
+
request: LanguageModelRequestMetadata;
|
1519
|
+
warnings: CallWarning[];
|
1520
|
+
} | {
|
1521
|
+
type: 'finish-step';
|
1522
|
+
response: LanguageModelResponseMetadata;
|
1523
|
+
usage: LanguageModelUsage;
|
1524
|
+
finishReason: FinishReason;
|
1525
|
+
providerMetadata: ProviderMetadata | undefined;
|
1526
|
+
} | {
|
1527
|
+
type: 'start';
|
1528
|
+
} | {
|
1529
|
+
type: 'finish';
|
1530
|
+
finishReason: FinishReason;
|
1531
|
+
totalUsage: LanguageModelUsage;
|
1532
|
+
} | {
|
1533
|
+
type: 'error';
|
1534
|
+
error: unknown;
|
1535
|
+
} | {
|
1536
|
+
type: 'raw';
|
1537
|
+
rawValue: unknown;
|
1538
|
+
};
|
1569
1539
|
|
1570
|
-
|
1571
|
-
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
1572
|
-
*
|
1573
|
-
* @param options - The configuration options
|
1574
|
-
* @param options.chunks - Array of values to be emitted by the stream
|
1575
|
-
* @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
1576
|
-
* @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.
|
1577
|
-
* @returns A ReadableStream that emits the provided values
|
1578
|
-
*/
|
1579
|
-
declare function simulateReadableStream<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal, }: {
|
1580
|
-
chunks: T[];
|
1581
|
-
initialDelayInMs?: number | null;
|
1582
|
-
chunkDelayInMs?: number | null;
|
1583
|
-
_internal?: {
|
1584
|
-
delay?: (ms: number | null) => Promise<void>;
|
1585
|
-
};
|
1586
|
-
}): ReadableStream<T>;
|
1587
|
-
|
1588
|
-
/**
|
1589
|
-
The result of an `embed` call.
|
1590
|
-
It contains the embedding, the value, and additional information.
|
1591
|
-
*/
|
1592
|
-
interface EmbedResult<VALUE> {
|
1593
|
-
/**
|
1594
|
-
The value that was embedded.
|
1595
|
-
*/
|
1596
|
-
readonly value: VALUE;
|
1597
|
-
/**
|
1598
|
-
The embedding of the value.
|
1599
|
-
*/
|
1600
|
-
readonly embedding: Embedding;
|
1540
|
+
type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
|
1601
1541
|
/**
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1542
|
+
* The system prompt to use.
|
1543
|
+
*/
|
1544
|
+
system?: string;
|
1605
1545
|
/**
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
/**
|
1610
|
-
Response headers.
|
1611
|
-
*/
|
1612
|
-
headers?: Record<string, string>;
|
1613
|
-
/**
|
1614
|
-
The response body.
|
1615
|
-
*/
|
1616
|
-
body?: unknown;
|
1617
|
-
};
|
1618
|
-
}
|
1619
|
-
|
1620
|
-
/**
|
1621
|
-
Embed a value using an embedding model. The type of the value is defined by the embedding model.
|
1622
|
-
|
1623
|
-
@param model - The embedding model to use.
|
1624
|
-
@param value - The value that should be embedded.
|
1625
|
-
|
1626
|
-
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
1627
|
-
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1628
|
-
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1629
|
-
|
1630
|
-
@returns A result object that contains the embedding, the value, and additional information.
|
1631
|
-
*/
|
1632
|
-
declare function embed<VALUE>({ model, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
|
1546
|
+
The language model to use.
|
1547
|
+
*/
|
1548
|
+
model: LanguageModel;
|
1633
1549
|
/**
|
1634
|
-
The
|
1635
|
-
|
1636
|
-
|
1550
|
+
The tools that the model can call. The model needs to support calling tools.
|
1551
|
+
*/
|
1552
|
+
tools?: TOOLS;
|
1637
1553
|
/**
|
1638
|
-
The
|
1554
|
+
The tool choice strategy. Default: 'auto'.
|
1639
1555
|
*/
|
1640
|
-
|
1556
|
+
toolChoice?: ToolChoice<NoInfer<TOOLS>>;
|
1641
1557
|
/**
|
1642
|
-
|
1558
|
+
Condition for stopping the generation when there are tool results in the last step.
|
1559
|
+
When the condition is an array, any of the conditions can be met to stop the generation.
|
1643
1560
|
|
1644
|
-
@default
|
1561
|
+
@default stepCountIs(1)
|
1645
1562
|
*/
|
1646
|
-
|
1647
|
-
/**
|
1648
|
-
Abort signal.
|
1649
|
-
*/
|
1650
|
-
abortSignal?: AbortSignal;
|
1651
|
-
/**
|
1652
|
-
Additional headers to include in the request.
|
1653
|
-
Only applicable for HTTP-based providers.
|
1654
|
-
*/
|
1655
|
-
headers?: Record<string, string>;
|
1656
|
-
/**
|
1657
|
-
Additional provider-specific options. They are passed through
|
1658
|
-
to the provider from the AI SDK and enable provider-specific
|
1659
|
-
functionality that can be fully encapsulated in the provider.
|
1660
|
-
*/
|
1661
|
-
providerOptions?: ProviderOptions;
|
1563
|
+
stopWhen?: StopCondition<NoInfer<TOOLS>> | Array<StopCondition<NoInfer<TOOLS>>>;
|
1662
1564
|
/**
|
1663
|
-
|
1565
|
+
Optional telemetry configuration (experimental).
|
1664
1566
|
*/
|
1665
1567
|
experimental_telemetry?: TelemetrySettings;
|
1666
|
-
}): Promise<EmbedResult<VALUE>>;
|
1667
|
-
|
1668
|
-
/**
|
1669
|
-
The result of a `embedMany` call.
|
1670
|
-
It contains the embeddings, the values, and additional information.
|
1671
|
-
*/
|
1672
|
-
interface EmbedManyResult<VALUE> {
|
1673
|
-
/**
|
1674
|
-
The values that were embedded.
|
1675
|
-
*/
|
1676
|
-
readonly values: Array<VALUE>;
|
1677
|
-
/**
|
1678
|
-
The embeddings. They are in the same order as the values.
|
1679
|
-
*/
|
1680
|
-
readonly embeddings: Array<Embedding>;
|
1681
|
-
/**
|
1682
|
-
The embedding token usage.
|
1683
|
-
*/
|
1684
|
-
readonly usage: EmbeddingModelUsage;
|
1685
|
-
/**
|
1686
|
-
Optional raw response data.
|
1687
|
-
*/
|
1688
|
-
readonly responses?: Array<{
|
1689
|
-
/**
|
1690
|
-
Response headers.
|
1691
|
-
*/
|
1692
|
-
headers?: Record<string, string>;
|
1693
|
-
/**
|
1694
|
-
The response body.
|
1695
|
-
*/
|
1696
|
-
body?: unknown;
|
1697
|
-
} | undefined>;
|
1698
|
-
}
|
1699
|
-
|
1700
|
-
/**
|
1701
|
-
Embed several values using an embedding model. The type of the value is defined
|
1702
|
-
by the embedding model.
|
1703
|
-
|
1704
|
-
`embedMany` automatically splits large requests into smaller chunks if the model
|
1705
|
-
has a limit on how many embeddings can be generated in a single call.
|
1706
|
-
|
1707
|
-
@param model - The embedding model to use.
|
1708
|
-
@param values - The values that should be embedded.
|
1709
|
-
|
1710
|
-
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
1711
|
-
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1712
|
-
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1713
|
-
|
1714
|
-
@returns A result object that contains the embeddings, the value, and additional information.
|
1715
|
-
*/
|
1716
|
-
declare function embedMany<VALUE>({ model, values, maxParallelCalls, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
|
1717
|
-
/**
|
1718
|
-
The embedding model to use.
|
1719
|
-
*/
|
1720
|
-
model: EmbeddingModel<VALUE>;
|
1721
1568
|
/**
|
1722
|
-
|
1569
|
+
Limits the tools that are available for the model to call without
|
1570
|
+
changing the tool call and result types in the result.
|
1723
1571
|
*/
|
1724
|
-
|
1572
|
+
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
1725
1573
|
/**
|
1726
|
-
|
1727
|
-
|
1728
|
-
@default 2
|
1574
|
+
Optional specification for parsing structured outputs from the LLM response.
|
1729
1575
|
*/
|
1730
|
-
|
1576
|
+
experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
|
1731
1577
|
/**
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1578
|
+
* @deprecated Use `prepareStep` instead.
|
1579
|
+
*/
|
1580
|
+
experimental_prepareStep?: PrepareStepFunction<NoInfer<TOOLS>>;
|
1735
1581
|
/**
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
headers?: Record<string, string>;
|
1582
|
+
Optional function that you can use to provide different settings for a step.
|
1583
|
+
*/
|
1584
|
+
prepareStep?: PrepareStepFunction<NoInfer<TOOLS>>;
|
1740
1585
|
/**
|
1741
|
-
|
1586
|
+
A function that attempts to repair a tool call that failed to parse.
|
1742
1587
|
*/
|
1743
|
-
|
1588
|
+
experimental_repairToolCall?: ToolCallRepairFunction<NoInfer<TOOLS>>;
|
1744
1589
|
/**
|
1745
|
-
|
1746
|
-
to the provider from the AI SDK and enable provider-specific
|
1747
|
-
functionality that can be fully encapsulated in the provider.
|
1590
|
+
Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
1748
1591
|
*/
|
1749
|
-
|
1592
|
+
onStepFinish?: GenerateTextOnStepFinishCallback<NoInfer<TOOLS>>;
|
1750
1593
|
/**
|
1751
|
-
*
|
1752
|
-
*
|
1753
|
-
* @default Infinity
|
1594
|
+
* Internal. For test use only. May change without notice.
|
1754
1595
|
*/
|
1755
|
-
|
1756
|
-
|
1596
|
+
_internal?: {
|
1597
|
+
generateId?: IdGenerator;
|
1598
|
+
currentDate?: () => Date;
|
1599
|
+
};
|
1600
|
+
};
|
1601
|
+
declare class Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> {
|
1602
|
+
private readonly settings;
|
1603
|
+
constructor(settings: AgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
|
1604
|
+
generate(options: Prompt & {
|
1605
|
+
/**
|
1606
|
+
Additional provider-specific metadata. They are passed through
|
1607
|
+
from the provider to the AI SDK and enable provider-specific
|
1608
|
+
results that can be fully encapsulated in the provider.
|
1609
|
+
*/
|
1610
|
+
providerMetadata?: ProviderMetadata;
|
1611
|
+
}): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
1612
|
+
stream(options: Prompt & {
|
1613
|
+
/**
|
1614
|
+
Additional provider-specific metadata. They are passed through
|
1615
|
+
from the provider to the AI SDK and enable provider-specific
|
1616
|
+
results that can be fully encapsulated in the provider.
|
1617
|
+
*/
|
1618
|
+
providerMetadata?: ProviderMetadata;
|
1619
|
+
}): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
|
1620
|
+
}
|
1757
1621
|
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1622
|
+
declare const symbol$c: unique symbol;
|
1623
|
+
declare class InvalidArgumentError extends AISDKError {
|
1624
|
+
private readonly [symbol$c];
|
1625
|
+
readonly parameter: string;
|
1626
|
+
readonly value: unknown;
|
1627
|
+
constructor({ parameter, value, message, }: {
|
1628
|
+
parameter: string;
|
1629
|
+
value: unknown;
|
1630
|
+
message: string;
|
1631
|
+
});
|
1632
|
+
static isInstance(error: unknown): error is InvalidArgumentError;
|
1633
|
+
}
|
1634
|
+
|
1635
|
+
type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
1636
|
+
type: 'text-start';
|
1637
|
+
providerMetadata?: ProviderMetadata;
|
1638
|
+
id: string;
|
1761
1639
|
} | {
|
1762
|
-
type: '
|
1763
|
-
|
1640
|
+
type: 'text-delta';
|
1641
|
+
id: string;
|
1642
|
+
providerMetadata?: ProviderMetadata;
|
1643
|
+
delta: string;
|
1644
|
+
} | {
|
1645
|
+
type: 'text-end';
|
1646
|
+
providerMetadata?: ProviderMetadata;
|
1647
|
+
id: string;
|
1648
|
+
} | {
|
1649
|
+
type: 'reasoning-start';
|
1650
|
+
providerMetadata?: ProviderMetadata;
|
1651
|
+
id: string;
|
1652
|
+
} | {
|
1653
|
+
type: 'reasoning-delta';
|
1654
|
+
id: string;
|
1655
|
+
providerMetadata?: ProviderMetadata;
|
1656
|
+
delta: string;
|
1657
|
+
} | {
|
1658
|
+
type: 'reasoning-end';
|
1659
|
+
id: string;
|
1660
|
+
providerMetadata?: ProviderMetadata;
|
1661
|
+
} | {
|
1662
|
+
type: 'tool-input-start';
|
1663
|
+
id: string;
|
1664
|
+
toolName: string;
|
1665
|
+
providerMetadata?: ProviderMetadata;
|
1666
|
+
} | {
|
1667
|
+
type: 'tool-input-delta';
|
1668
|
+
id: string;
|
1669
|
+
delta: string;
|
1670
|
+
providerMetadata?: ProviderMetadata;
|
1671
|
+
} | {
|
1672
|
+
type: 'tool-input-end';
|
1673
|
+
id: string;
|
1764
1674
|
providerMetadata?: ProviderMetadata;
|
1765
1675
|
} | ({
|
1766
1676
|
type: 'source';
|
@@ -1773,695 +1683,910 @@ type ContentPart<TOOLS extends ToolSet> = {
|
|
1773
1683
|
type: 'tool-result';
|
1774
1684
|
} & ToolResultUnion<TOOLS>) | ({
|
1775
1685
|
type: 'tool-error';
|
1776
|
-
} & ToolErrorUnion<TOOLS>)
|
1686
|
+
} & ToolErrorUnion<TOOLS>) | {
|
1687
|
+
type: 'file';
|
1688
|
+
file: GeneratedFile;
|
1689
|
+
} | {
|
1690
|
+
type: 'stream-start';
|
1691
|
+
warnings: LanguageModelV2CallWarning[];
|
1692
|
+
} | {
|
1693
|
+
type: 'response-metadata';
|
1694
|
+
id?: string;
|
1695
|
+
timestamp?: Date;
|
1696
|
+
modelId?: string;
|
1697
|
+
} | {
|
1698
|
+
type: 'finish';
|
1699
|
+
finishReason: FinishReason;
|
1700
|
+
usage: LanguageModelUsage;
|
1701
|
+
providerMetadata?: ProviderMetadata;
|
1702
|
+
} | {
|
1703
|
+
type: 'error';
|
1704
|
+
error: unknown;
|
1705
|
+
} | {
|
1706
|
+
type: 'raw';
|
1707
|
+
rawValue: unknown;
|
1708
|
+
};
|
1709
|
+
|
1710
|
+
declare const symbol$b: unique symbol;
|
1711
|
+
declare class InvalidStreamPartError extends AISDKError {
|
1712
|
+
private readonly [symbol$b];
|
1713
|
+
readonly chunk: SingleRequestTextStreamPart<any>;
|
1714
|
+
constructor({ chunk, message, }: {
|
1715
|
+
chunk: SingleRequestTextStreamPart<any>;
|
1716
|
+
message: string;
|
1717
|
+
});
|
1718
|
+
static isInstance(error: unknown): error is InvalidStreamPartError;
|
1719
|
+
}
|
1777
1720
|
|
1721
|
+
declare const symbol$a: unique symbol;
|
1778
1722
|
/**
|
1779
|
-
|
1780
|
-
It can be either an assistant message or a tool message.
|
1723
|
+
* An error occurred with the MCP client.
|
1781
1724
|
*/
|
1782
|
-
|
1725
|
+
declare class MCPClientError extends AISDKError {
|
1726
|
+
private readonly [symbol$a];
|
1727
|
+
constructor({ name, message, cause, }: {
|
1728
|
+
name?: string;
|
1729
|
+
message: string;
|
1730
|
+
cause?: unknown;
|
1731
|
+
});
|
1732
|
+
static isInstance(error: unknown): error is MCPClientError;
|
1733
|
+
}
|
1783
1734
|
|
1735
|
+
declare const symbol$9: unique symbol;
|
1784
1736
|
/**
|
1785
|
-
|
1737
|
+
Thrown when no image could be generated. This can have multiple causes:
|
1738
|
+
|
1739
|
+
- The model failed to generate a response.
|
1740
|
+
- The model generated a response that could not be parsed.
|
1786
1741
|
*/
|
1787
|
-
|
1788
|
-
|
1789
|
-
The content that was generated in the last step.
|
1790
|
-
*/
|
1791
|
-
readonly content: Array<ContentPart<TOOLS>>;
|
1792
|
-
/**
|
1793
|
-
The generated text.
|
1794
|
-
*/
|
1795
|
-
readonly text: string;
|
1796
|
-
/**
|
1797
|
-
The reasoning that was generated during the generation.
|
1798
|
-
*/
|
1799
|
-
readonly reasoning: Array<ReasoningPart>;
|
1800
|
-
/**
|
1801
|
-
The reasoning text that was generated during the generation.
|
1802
|
-
*/
|
1803
|
-
readonly reasoningText: string | undefined;
|
1804
|
-
/**
|
1805
|
-
The files that were generated during the generation.
|
1806
|
-
*/
|
1807
|
-
readonly files: Array<GeneratedFile>;
|
1808
|
-
/**
|
1809
|
-
The sources that were used to generate the text.
|
1810
|
-
*/
|
1811
|
-
readonly sources: Array<Source>;
|
1812
|
-
/**
|
1813
|
-
The tool calls that were made during the generation.
|
1814
|
-
*/
|
1815
|
-
readonly toolCalls: ToolCallArray<TOOLS>;
|
1816
|
-
/**
|
1817
|
-
The results of the tool calls.
|
1818
|
-
*/
|
1819
|
-
readonly toolResults: ToolResultArray<TOOLS>;
|
1820
|
-
/**
|
1821
|
-
The reason why the generation finished.
|
1822
|
-
*/
|
1823
|
-
readonly finishReason: FinishReason;
|
1824
|
-
/**
|
1825
|
-
The token usage of the generated text.
|
1826
|
-
*/
|
1827
|
-
readonly usage: LanguageModelUsage;
|
1828
|
-
/**
|
1829
|
-
Warnings from the model provider (e.g. unsupported settings).
|
1830
|
-
*/
|
1831
|
-
readonly warnings: CallWarning[] | undefined;
|
1832
|
-
/**
|
1833
|
-
Additional request information.
|
1834
|
-
*/
|
1835
|
-
readonly request: LanguageModelRequestMetadata;
|
1836
|
-
/**
|
1837
|
-
Additional response information.
|
1838
|
-
*/
|
1839
|
-
readonly response: LanguageModelResponseMetadata & {
|
1840
|
-
/**
|
1841
|
-
The response messages that were generated during the call.
|
1842
|
-
Response messages can be either assistant messages or tool messages.
|
1843
|
-
They contain a generated id.
|
1844
|
-
*/
|
1845
|
-
readonly messages: Array<ResponseMessage>;
|
1846
|
-
/**
|
1847
|
-
Response body (available only for providers that use HTTP requests).
|
1848
|
-
*/
|
1849
|
-
body?: unknown;
|
1850
|
-
};
|
1742
|
+
declare class NoImageGeneratedError extends AISDKError {
|
1743
|
+
private readonly [symbol$9];
|
1851
1744
|
/**
|
1852
|
-
|
1853
|
-
from the provider to the AI SDK and enable provider-specific
|
1854
|
-
results that can be fully encapsulated in the provider.
|
1745
|
+
The response metadata for each call.
|
1855
1746
|
*/
|
1856
|
-
readonly
|
1857
|
-
}
|
1747
|
+
readonly responses: Array<ImageModelResponseMetadata> | undefined;
|
1748
|
+
constructor({ message, cause, responses, }: {
|
1749
|
+
message?: string;
|
1750
|
+
cause?: Error;
|
1751
|
+
responses?: Array<ImageModelResponseMetadata>;
|
1752
|
+
});
|
1753
|
+
static isInstance(error: unknown): error is NoImageGeneratedError;
|
1754
|
+
}
|
1858
1755
|
|
1756
|
+
declare const symbol$8: unique symbol;
|
1859
1757
|
/**
|
1860
|
-
|
1861
|
-
|
1758
|
+
Thrown when no object could be generated. This can have several causes:
|
1759
|
+
|
1760
|
+
- The model failed to generate a response.
|
1761
|
+
- The model generated a response that could not be parsed.
|
1762
|
+
- The model generated a response that could not be validated against the schema.
|
1763
|
+
|
1764
|
+
The error contains the following properties:
|
1765
|
+
|
1766
|
+
- `text`: The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
|
1862
1767
|
*/
|
1863
|
-
|
1864
|
-
|
1865
|
-
The content that was generated in the last step.
|
1866
|
-
*/
|
1867
|
-
readonly content: Array<ContentPart<TOOLS>>;
|
1868
|
-
/**
|
1869
|
-
The text that was generated in the last step.
|
1870
|
-
*/
|
1871
|
-
readonly text: string;
|
1872
|
-
/**
|
1873
|
-
The full reasoning that the model has generated in the last step.
|
1874
|
-
*/
|
1875
|
-
readonly reasoning: Array<ReasoningPart>;
|
1876
|
-
/**
|
1877
|
-
The reasoning text that the model has generated in the last step. Can be undefined if the model
|
1878
|
-
has only generated text.
|
1879
|
-
*/
|
1880
|
-
readonly reasoningText: string | undefined;
|
1881
|
-
/**
|
1882
|
-
The files that were generated in the last step.
|
1883
|
-
Empty array if no files were generated.
|
1884
|
-
*/
|
1885
|
-
readonly files: Array<GeneratedFile>;
|
1886
|
-
/**
|
1887
|
-
Sources that have been used as references in the last step.
|
1888
|
-
*/
|
1889
|
-
readonly sources: Array<Source>;
|
1768
|
+
declare class NoObjectGeneratedError extends AISDKError {
|
1769
|
+
private readonly [symbol$8];
|
1890
1770
|
/**
|
1891
|
-
|
1771
|
+
The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
|
1892
1772
|
*/
|
1893
|
-
readonly
|
1773
|
+
readonly text: string | undefined;
|
1894
1774
|
/**
|
1895
|
-
|
1775
|
+
The response metadata.
|
1896
1776
|
*/
|
1897
|
-
readonly
|
1777
|
+
readonly response: LanguageModelResponseMetadata | undefined;
|
1898
1778
|
/**
|
1899
|
-
|
1779
|
+
The usage of the model.
|
1900
1780
|
*/
|
1901
|
-
readonly
|
1781
|
+
readonly usage: LanguageModelUsage | undefined;
|
1902
1782
|
/**
|
1903
|
-
|
1783
|
+
Reason why the model finished generating a response.
|
1904
1784
|
*/
|
1905
|
-
readonly
|
1785
|
+
readonly finishReason: FinishReason | undefined;
|
1786
|
+
constructor({ message, cause, text, response, usage, finishReason, }: {
|
1787
|
+
message?: string;
|
1788
|
+
cause?: Error;
|
1789
|
+
text?: string;
|
1790
|
+
response: LanguageModelResponseMetadata;
|
1791
|
+
usage: LanguageModelUsage;
|
1792
|
+
finishReason: FinishReason;
|
1793
|
+
});
|
1794
|
+
static isInstance(error: unknown): error is NoObjectGeneratedError;
|
1795
|
+
}
|
1796
|
+
|
1797
|
+
declare const symbol$7: unique symbol;
|
1798
|
+
/**
|
1799
|
+
Thrown when no output type is specified and output-related methods are called.
|
1800
|
+
*/
|
1801
|
+
declare class NoOutputSpecifiedError extends AISDKError {
|
1802
|
+
private readonly [symbol$7];
|
1803
|
+
constructor({ message }?: {
|
1804
|
+
message?: string;
|
1805
|
+
});
|
1806
|
+
static isInstance(error: unknown): error is NoOutputSpecifiedError;
|
1807
|
+
}
|
1808
|
+
|
1809
|
+
declare const symbol$6: unique symbol;
|
1810
|
+
declare class ToolCallRepairError extends AISDKError {
|
1811
|
+
private readonly [symbol$6];
|
1812
|
+
readonly originalError: NoSuchToolError | InvalidToolInputError;
|
1813
|
+
constructor({ cause, originalError, message, }: {
|
1814
|
+
message?: string;
|
1815
|
+
cause: unknown;
|
1816
|
+
originalError: NoSuchToolError | InvalidToolInputError;
|
1817
|
+
});
|
1818
|
+
static isInstance(error: unknown): error is ToolCallRepairError;
|
1819
|
+
}
|
1820
|
+
|
1821
|
+
declare const symbol$5: unique symbol;
|
1822
|
+
declare class InvalidDataContentError extends AISDKError {
|
1823
|
+
private readonly [symbol$5];
|
1824
|
+
readonly content: unknown;
|
1825
|
+
constructor({ content, cause, message, }: {
|
1826
|
+
content: unknown;
|
1827
|
+
cause?: unknown;
|
1828
|
+
message?: string;
|
1829
|
+
});
|
1830
|
+
static isInstance(error: unknown): error is InvalidDataContentError;
|
1831
|
+
}
|
1832
|
+
|
1833
|
+
declare const symbol$4: unique symbol;
|
1834
|
+
declare class InvalidMessageRoleError extends AISDKError {
|
1835
|
+
private readonly [symbol$4];
|
1836
|
+
readonly role: string;
|
1837
|
+
constructor({ role, message, }: {
|
1838
|
+
role: string;
|
1839
|
+
message?: string;
|
1840
|
+
});
|
1841
|
+
static isInstance(error: unknown): error is InvalidMessageRoleError;
|
1842
|
+
}
|
1843
|
+
|
1844
|
+
declare const symbol$3: unique symbol;
|
1845
|
+
declare class MessageConversionError extends AISDKError {
|
1846
|
+
private readonly [symbol$3];
|
1847
|
+
readonly originalMessage: Omit<UIMessage, 'id'>;
|
1848
|
+
constructor({ originalMessage, message, }: {
|
1849
|
+
originalMessage: Omit<UIMessage, 'id'>;
|
1850
|
+
message: string;
|
1851
|
+
});
|
1852
|
+
static isInstance(error: unknown): error is MessageConversionError;
|
1853
|
+
}
|
1854
|
+
|
1855
|
+
declare const symbol$2: unique symbol;
|
1856
|
+
declare class DownloadError extends AISDKError {
|
1857
|
+
private readonly [symbol$2];
|
1858
|
+
readonly url: string;
|
1859
|
+
readonly statusCode?: number;
|
1860
|
+
readonly statusText?: string;
|
1861
|
+
constructor({ url, statusCode, statusText, cause, message, }: {
|
1862
|
+
url: string;
|
1863
|
+
statusCode?: number;
|
1864
|
+
statusText?: string;
|
1865
|
+
message?: string;
|
1866
|
+
cause?: unknown;
|
1867
|
+
});
|
1868
|
+
static isInstance(error: unknown): error is DownloadError;
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
declare const symbol$1: unique symbol;
|
1872
|
+
type RetryErrorReason = 'maxRetriesExceeded' | 'errorNotRetryable' | 'abort';
|
1873
|
+
declare class RetryError extends AISDKError {
|
1874
|
+
private readonly [symbol$1];
|
1875
|
+
readonly reason: RetryErrorReason;
|
1876
|
+
readonly lastError: unknown;
|
1877
|
+
readonly errors: Array<unknown>;
|
1878
|
+
constructor({ message, reason, errors, }: {
|
1879
|
+
message: string;
|
1880
|
+
reason: RetryErrorReason;
|
1881
|
+
errors: Array<unknown>;
|
1882
|
+
});
|
1883
|
+
static isInstance(error: unknown): error is RetryError;
|
1884
|
+
}
|
1885
|
+
|
1886
|
+
declare function createTextStreamResponse({ status, statusText, headers, textStream, }: ResponseInit & {
|
1887
|
+
textStream: ReadableStream<string>;
|
1888
|
+
}): Response;
|
1889
|
+
|
1890
|
+
declare function pipeTextStreamToResponse({ response, status, statusText, headers, textStream, }: {
|
1891
|
+
response: ServerResponse;
|
1892
|
+
textStream: ReadableStream<string>;
|
1893
|
+
} & ResponseInit): void;
|
1894
|
+
|
1895
|
+
declare const getOriginalFetch: () => typeof fetch;
|
1896
|
+
declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
|
1897
|
+
api: string;
|
1898
|
+
prompt: string;
|
1899
|
+
credentials: RequestCredentials | undefined;
|
1900
|
+
headers: HeadersInit | undefined;
|
1901
|
+
body: Record<string, any>;
|
1902
|
+
streamProtocol: 'data' | 'text' | undefined;
|
1903
|
+
setCompletion: (completion: string) => void;
|
1904
|
+
setLoading: (loading: boolean) => void;
|
1905
|
+
setError: (error: Error | undefined) => void;
|
1906
|
+
setAbortController: (abortController: AbortController | null) => void;
|
1907
|
+
onFinish: ((prompt: string, completion: string) => void) | undefined;
|
1908
|
+
onError: ((error: Error) => void) | undefined;
|
1909
|
+
fetch: ReturnType<typeof getOriginalFetch> | undefined;
|
1910
|
+
}): Promise<string | null | undefined>;
|
1911
|
+
|
1912
|
+
interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
1906
1913
|
/**
|
1907
|
-
|
1908
|
-
When there are multiple steps, the usage is the sum of all step usages.
|
1914
|
+
* Appends a data stream part to the stream.
|
1909
1915
|
*/
|
1910
|
-
|
1916
|
+
write(part: InferUIMessageChunk<UI_MESSAGE>): void;
|
1911
1917
|
/**
|
1912
|
-
|
1918
|
+
* Merges the contents of another stream to this stream.
|
1913
1919
|
*/
|
1914
|
-
|
1920
|
+
merge(stream: ReadableStream<InferUIMessageChunk<UI_MESSAGE>>): void;
|
1915
1921
|
/**
|
1916
|
-
|
1922
|
+
* Error handler that is used by the data stream writer.
|
1923
|
+
* This is intended for forwarding when merging streams
|
1924
|
+
* to prevent duplicated error masking.
|
1917
1925
|
*/
|
1918
|
-
|
1926
|
+
onError: ErrorHandler | undefined;
|
1927
|
+
}
|
1928
|
+
|
1929
|
+
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, originalMessages, onFinish, generateId, }: {
|
1930
|
+
execute: (options: {
|
1931
|
+
writer: UIMessageStreamWriter<UI_MESSAGE>;
|
1932
|
+
}) => Promise<void> | void;
|
1933
|
+
onError?: (error: unknown) => string;
|
1919
1934
|
/**
|
1920
|
-
|
1935
|
+
* The original messages. If they are provided, persistence mode is assumed,
|
1936
|
+
* and a message ID is provided for the response message.
|
1921
1937
|
*/
|
1922
|
-
|
1938
|
+
originalMessages?: UI_MESSAGE[];
|
1939
|
+
onFinish?: (options: {
|
1923
1940
|
/**
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
When there are tool results, there is an additional tool message with the tool results that are available.
|
1928
|
-
If there are tools that do not have execute functions, they are not included in the tool results and
|
1929
|
-
need to be added separately.
|
1930
|
-
*/
|
1931
|
-
messages: Array<ResponseMessage>;
|
1941
|
+
* The updates list of UI messages.
|
1942
|
+
*/
|
1943
|
+
messages: UI_MESSAGE[];
|
1932
1944
|
/**
|
1933
|
-
|
1945
|
+
* Indicates whether the response message is a continuation of the last original message,
|
1946
|
+
* or if a new message was created.
|
1934
1947
|
*/
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
Details for all steps.
|
1945
|
-
You can use this to get information about intermediate steps,
|
1946
|
-
such as the tool calls or the response headers.
|
1947
|
-
*/
|
1948
|
-
readonly steps: Array<StepResult<TOOLS>>;
|
1949
|
-
/**
|
1950
|
-
The generated structured output. It uses the `experimental_output` specification.
|
1951
|
-
*/
|
1952
|
-
readonly experimental_output: OUTPUT;
|
1953
|
-
}
|
1948
|
+
isContinuation: boolean;
|
1949
|
+
/**
|
1950
|
+
* The message that was sent to the client as a response
|
1951
|
+
* (including the original message if it was extended).
|
1952
|
+
*/
|
1953
|
+
responseMessage: UI_MESSAGE;
|
1954
|
+
}) => void;
|
1955
|
+
generateId?: IdGenerator;
|
1956
|
+
}): ReadableStream<InferUIMessageChunk<UI_MESSAGE>>;
|
1954
1957
|
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
parsePartial(options: {
|
1959
|
-
text: string;
|
1960
|
-
}): Promise<{
|
1961
|
-
partial: PARTIAL;
|
1962
|
-
} | undefined>;
|
1963
|
-
parseOutput(options: {
|
1964
|
-
text: string;
|
1965
|
-
}, context: {
|
1966
|
-
response: LanguageModelResponseMetadata;
|
1967
|
-
usage: LanguageModelUsage;
|
1968
|
-
finishReason: FinishReason;
|
1969
|
-
}): Promise<OUTPUT>;
|
1970
|
-
}
|
1971
|
-
declare const text: () => Output<string, string>;
|
1972
|
-
declare const object: <OUTPUT>({ schema: inputSchema, }: {
|
1973
|
-
schema: z4.$ZodType<OUTPUT, any> | z3.Schema<OUTPUT, z3.ZodTypeDef, any> | Schema<OUTPUT>;
|
1974
|
-
}) => Output<OUTPUT, DeepPartial<OUTPUT>>;
|
1958
|
+
declare function createUIMessageStreamResponse({ status, statusText, headers, stream, consumeSseStream, }: UIMessageStreamResponseInit & {
|
1959
|
+
stream: ReadableStream<UIMessageChunk>;
|
1960
|
+
}): Response;
|
1975
1961
|
|
1976
|
-
|
1977
|
-
|
1978
|
-
declare const output_text: typeof text;
|
1979
|
-
declare namespace output {
|
1980
|
-
export {
|
1981
|
-
output_Output as Output,
|
1982
|
-
output_object as object,
|
1983
|
-
output_text as text,
|
1984
|
-
};
|
1962
|
+
declare class JsonToSseTransformStream extends TransformStream<unknown, string> {
|
1963
|
+
constructor();
|
1985
1964
|
}
|
1986
1965
|
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
@param options.steps - The steps that have been executed so far.
|
1992
|
-
@param options.stepNumber - The number of the step that is being executed.
|
1993
|
-
@param options.model - The model that is being used.
|
1994
|
-
|
1995
|
-
@returns An object that contains the settings for the step.
|
1996
|
-
If you return undefined (or for undefined settings), the settings from the outer level will be used.
|
1997
|
-
*/
|
1998
|
-
type PrepareStepFunction<TOOLS extends Record<string, Tool> = Record<string, Tool>> = (options: {
|
1999
|
-
steps: Array<StepResult<NoInfer<TOOLS>>>;
|
2000
|
-
stepNumber: number;
|
2001
|
-
model: LanguageModel;
|
2002
|
-
}) => PromiseLike<PrepareStepResult<TOOLS>> | PrepareStepResult<TOOLS>;
|
2003
|
-
type PrepareStepResult<TOOLS extends Record<string, Tool> = Record<string, Tool>> = {
|
2004
|
-
model?: LanguageModel;
|
2005
|
-
toolChoice?: ToolChoice<NoInfer<TOOLS>>;
|
2006
|
-
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
2007
|
-
system?: string;
|
2008
|
-
} | undefined;
|
2009
|
-
|
2010
|
-
type StopCondition<TOOLS extends ToolSet> = (options: {
|
2011
|
-
steps: Array<StepResult<TOOLS>>;
|
2012
|
-
}) => PromiseLike<boolean> | boolean;
|
2013
|
-
declare function stepCountIs(stepCount: number): StopCondition<any>;
|
2014
|
-
declare function hasToolCall(toolName: string): StopCondition<any>;
|
1966
|
+
declare function pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, consumeSseStream, }: {
|
1967
|
+
response: ServerResponse;
|
1968
|
+
stream: ReadableStream<UIMessageChunk>;
|
1969
|
+
} & UIMessageStreamResponseInit): void;
|
2015
1970
|
|
2016
1971
|
/**
|
2017
|
-
|
2018
|
-
|
2019
|
-
@param
|
1972
|
+
* Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
|
1973
|
+
*
|
1974
|
+
* @param options.message - The last assistant message to use as a starting point when the conversation is resumed. Otherwise undefined.
|
1975
|
+
* @param options.stream - The stream of `UIMessageChunk`s to read.
|
1976
|
+
*
|
1977
|
+
* @returns An `AsyncIterableStream` of `UIMessage`s. Each stream part is a different state of the same message
|
1978
|
+
* as it is being completed.
|
2020
1979
|
*/
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
This function does not stream the output. If you want to stream the output, use `streamText` instead.
|
2026
|
-
|
2027
|
-
@param model - The language model to use.
|
2028
|
-
|
2029
|
-
@param tools - Tools that are accessible to and can be called by the model. The model needs to support calling tools.
|
2030
|
-
@param toolChoice - The tool choice strategy. Default: 'auto'.
|
2031
|
-
|
2032
|
-
@param system - A system message that will be part of the prompt.
|
2033
|
-
@param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
2034
|
-
@param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
1980
|
+
declare function readUIMessageStream<UI_MESSAGE extends UIMessage>({ message, stream, }: {
|
1981
|
+
message?: UI_MESSAGE;
|
1982
|
+
stream: ReadableStream<UIMessageChunk>;
|
1983
|
+
}): AsyncIterableStream<UI_MESSAGE>;
|
2035
1984
|
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
@param topK - Only sample from the top K options for each subsequent token.
|
2044
|
-
Used to remove "long tail" low probability responses.
|
2045
|
-
Recommended for advanced use cases only. You usually only need to use temperature.
|
2046
|
-
@param presencePenalty - Presence penalty setting.
|
2047
|
-
It affects the likelihood of the model to repeat information that is already in the prompt.
|
2048
|
-
The value is passed through to the provider. The range depends on the provider and model.
|
2049
|
-
@param frequencyPenalty - Frequency penalty setting.
|
2050
|
-
It affects the likelihood of the model to repeatedly use the same words or phrases.
|
2051
|
-
The value is passed through to the provider. The range depends on the provider and model.
|
2052
|
-
@param stopSequences - Stop sequences.
|
2053
|
-
If set, the model will stop generating text when one of the stop sequences is generated.
|
2054
|
-
@param seed - The seed (integer) to use for random sampling.
|
2055
|
-
If set and supported by the model, calls will generate deterministic results.
|
2056
|
-
|
2057
|
-
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
2058
|
-
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
2059
|
-
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
2060
|
-
|
2061
|
-
@param experimental_generateMessageId - Generate a unique ID for each message.
|
1985
|
+
declare const UI_MESSAGE_STREAM_HEADERS: {
|
1986
|
+
'content-type': string;
|
1987
|
+
'cache-control': string;
|
1988
|
+
connection: string;
|
1989
|
+
'x-vercel-ai-ui-message-stream': string;
|
1990
|
+
'x-accel-buffering': string;
|
1991
|
+
};
|
2062
1992
|
|
2063
|
-
|
1993
|
+
interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
1994
|
+
sendMessages: (options: {
|
1995
|
+
chatId: string;
|
1996
|
+
messages: UI_MESSAGE[];
|
1997
|
+
abortSignal: AbortSignal | undefined;
|
1998
|
+
} & {
|
1999
|
+
trigger: 'submit-user-message' | 'submit-tool-result' | 'regenerate-assistant-message';
|
2000
|
+
messageId: string | undefined;
|
2001
|
+
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
2002
|
+
reconnectToStream: (options: {
|
2003
|
+
chatId: string;
|
2004
|
+
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk> | null>;
|
2005
|
+
}
|
2064
2006
|
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2007
|
+
type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'role'> & {
|
2008
|
+
id?: UI_MESSAGE['id'];
|
2009
|
+
role?: UI_MESSAGE['role'];
|
2010
|
+
};
|
2011
|
+
type UIDataPartSchemas = Record<string, Validator<any> | StandardSchemaV1<any>>;
|
2012
|
+
type UIDataTypesToSchemas<T extends UIDataTypes> = {
|
2013
|
+
[K in keyof T]: Validator<T[K]> | StandardSchemaV1<T[K]>;
|
2014
|
+
};
|
2015
|
+
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
2016
|
+
[K in keyof T]: T[K] extends Validator<infer U> ? U : T[K] extends StandardSchemaV1<infer U> ? U : unknown;
|
2017
|
+
};
|
2018
|
+
type ChatRequestOptions = {
|
2019
|
+
/**
|
2020
|
+
Additional headers that should be to be passed to the API endpoint.
|
2021
|
+
*/
|
2022
|
+
headers?: Record<string, string> | Headers;
|
2069
2023
|
/**
|
2070
|
-
|
2024
|
+
Additional body JSON properties that should be sent to the API endpoint.
|
2071
2025
|
*/
|
2072
|
-
|
2026
|
+
body?: object;
|
2027
|
+
metadata?: unknown;
|
2028
|
+
};
|
2029
|
+
type ChatStatus = 'submitted' | 'streaming' | 'ready' | 'error';
|
2030
|
+
interface ChatState<UI_MESSAGE extends UIMessage> {
|
2031
|
+
status: ChatStatus;
|
2032
|
+
error: Error | undefined;
|
2033
|
+
messages: UI_MESSAGE[];
|
2034
|
+
pushMessage: (message: UI_MESSAGE) => void;
|
2035
|
+
popMessage: () => void;
|
2036
|
+
replaceMessage: (index: number, message: UI_MESSAGE) => void;
|
2037
|
+
snapshot: <T>(thing: T) => T;
|
2038
|
+
}
|
2039
|
+
type ChatOnErrorCallback = (error: Error) => void;
|
2040
|
+
type ChatOnToolCallCallback = ({ toolCall, }: {
|
2041
|
+
toolCall: ToolCall<string, unknown>;
|
2042
|
+
}) => void | Promise<unknown> | unknown;
|
2043
|
+
type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<InferUIMessageData<UI_MESSAGE>>) => void;
|
2044
|
+
type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
2045
|
+
message: UI_MESSAGE;
|
2046
|
+
}) => void;
|
2047
|
+
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
2073
2048
|
/**
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2049
|
+
* A unique identifier for the chat. If not provided, a random one will be
|
2050
|
+
* generated.
|
2051
|
+
*/
|
2052
|
+
id?: string;
|
2053
|
+
messageMetadataSchema?: Validator<InferUIMessageMetadata<UI_MESSAGE>> | StandardSchemaV1<InferUIMessageMetadata<UI_MESSAGE>>;
|
2054
|
+
dataPartSchemas?: UIDataTypesToSchemas<InferUIMessageData<UI_MESSAGE>>;
|
2055
|
+
messages?: UI_MESSAGE[];
|
2077
2056
|
/**
|
2078
|
-
|
2057
|
+
* A way to provide a function that is going to be used for ids for messages and the chat.
|
2058
|
+
* If not provided the default AI SDK `generateId` is used.
|
2079
2059
|
*/
|
2080
|
-
|
2060
|
+
generateId?: IdGenerator;
|
2061
|
+
transport?: ChatTransport<UI_MESSAGE>;
|
2062
|
+
maxSteps?: number;
|
2081
2063
|
/**
|
2082
|
-
|
2083
|
-
When the condition is an array, any of the conditions can be met to stop the generation.
|
2084
|
-
|
2085
|
-
@default stepCountIs(1)
|
2064
|
+
* Callback function to be called when an error is encountered.
|
2086
2065
|
*/
|
2087
|
-
|
2066
|
+
onError?: ChatOnErrorCallback;
|
2088
2067
|
/**
|
2089
|
-
Optional
|
2068
|
+
Optional callback function that is invoked when a tool call is received.
|
2069
|
+
Intended for automatic client-side tool execution.
|
2070
|
+
|
2071
|
+
You can optionally return a result for the tool call,
|
2072
|
+
either synchronously or asynchronously.
|
2073
|
+
*/
|
2074
|
+
onToolCall?: ChatOnToolCallCallback;
|
2075
|
+
/**
|
2076
|
+
* Optional callback function that is called when the assistant message is finished streaming.
|
2077
|
+
*
|
2078
|
+
* @param message The message that was streamed.
|
2090
2079
|
*/
|
2091
|
-
|
2080
|
+
onFinish?: ChatOnFinishCallback<UI_MESSAGE>;
|
2092
2081
|
/**
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2082
|
+
* Optional callback function that is called when a data part is received.
|
2083
|
+
*
|
2084
|
+
* @param data The data part that was received.
|
2085
|
+
*/
|
2086
|
+
onData?: ChatOnDataCallback<UI_MESSAGE>;
|
2087
|
+
}
|
2088
|
+
declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
2089
|
+
readonly id: string;
|
2090
|
+
readonly generateId: IdGenerator;
|
2091
|
+
protected state: ChatState<UI_MESSAGE>;
|
2092
|
+
private messageMetadataSchema;
|
2093
|
+
private dataPartSchemas;
|
2094
|
+
private readonly transport;
|
2095
|
+
private maxSteps;
|
2096
|
+
private onError?;
|
2097
|
+
private onToolCall?;
|
2098
|
+
private onFinish?;
|
2099
|
+
private onData?;
|
2100
|
+
private activeResponse;
|
2101
|
+
private jobExecutor;
|
2102
|
+
constructor({ generateId, id, transport, maxSteps, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, onData, }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
2103
|
+
state: ChatState<UI_MESSAGE>;
|
2104
|
+
});
|
2098
2105
|
/**
|
2099
|
-
*
|
2106
|
+
* Hook status:
|
2107
|
+
*
|
2108
|
+
* - `submitted`: The message has been sent to the API and we're awaiting the start of the response stream.
|
2109
|
+
* - `streaming`: The response is actively streaming in from the API, receiving chunks of data.
|
2110
|
+
* - `ready`: The full response has been received and processed; a new user message can be submitted.
|
2111
|
+
* - `error`: An error occurred during the API request, preventing successful completion.
|
2100
2112
|
*/
|
2101
|
-
|
2113
|
+
get status(): ChatStatus;
|
2114
|
+
protected setStatus({ status, error, }: {
|
2115
|
+
status: ChatStatus;
|
2116
|
+
error?: Error;
|
2117
|
+
}): void;
|
2118
|
+
get error(): Error | undefined;
|
2119
|
+
get messages(): UI_MESSAGE[];
|
2120
|
+
get lastMessage(): UI_MESSAGE | undefined;
|
2121
|
+
set messages(messages: UI_MESSAGE[]);
|
2102
2122
|
/**
|
2103
|
-
|
2104
|
-
|
2123
|
+
* Appends or replaces a user message to the chat list. This triggers the API call to fetch
|
2124
|
+
* the assistant's response.
|
2125
|
+
*
|
2126
|
+
* If a messageId is provided, the message will be replaced.
|
2105
2127
|
*/
|
2106
|
-
|
2128
|
+
sendMessage: (message: (CreateUIMessage<UI_MESSAGE> & {
|
2129
|
+
text?: never;
|
2130
|
+
files?: never;
|
2131
|
+
messageId?: string;
|
2132
|
+
}) | {
|
2133
|
+
text: string;
|
2134
|
+
files?: FileList | FileUIPart[];
|
2135
|
+
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
2136
|
+
parts?: never;
|
2137
|
+
messageId?: string;
|
2138
|
+
} | {
|
2139
|
+
files: FileList | FileUIPart[];
|
2140
|
+
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
2141
|
+
parts?: never;
|
2142
|
+
messageId?: string;
|
2143
|
+
}, options?: ChatRequestOptions) => Promise<void>;
|
2107
2144
|
/**
|
2108
|
-
|
2145
|
+
* Regenerate the assistant message with the provided message id.
|
2146
|
+
* If no message id is provided, the last assistant message will be regenerated.
|
2109
2147
|
*/
|
2110
|
-
|
2148
|
+
regenerate: ({ messageId, ...options }?: {
|
2149
|
+
messageId?: string;
|
2150
|
+
} & ChatRequestOptions) => Promise<void>;
|
2111
2151
|
/**
|
2112
|
-
*
|
2152
|
+
* Attempt to resume an ongoing streaming response.
|
2113
2153
|
*/
|
2114
|
-
|
2154
|
+
resumeStream: (options?: ChatRequestOptions) => Promise<void>;
|
2155
|
+
addToolResult: ({ toolCallId, output, }: {
|
2156
|
+
toolCallId: string;
|
2157
|
+
output: unknown;
|
2158
|
+
}) => Promise<void>;
|
2115
2159
|
/**
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2160
|
+
* Abort the current request immediately, keep the generated tokens if any.
|
2161
|
+
*/
|
2162
|
+
stop: () => Promise<void>;
|
2163
|
+
private makeRequest;
|
2164
|
+
}
|
2165
|
+
|
2166
|
+
declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
2167
|
+
|
2168
|
+
/**
|
2169
|
+
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2170
|
+
with the AI core functions (e.g. `streamText`).
|
2171
|
+
|
2172
|
+
@param messages - The messages to convert.
|
2173
|
+
@param options.tools - The tools to use.
|
2174
|
+
@param options.ignoreIncompleteToolCalls - Whether to ignore incomplete tool calls. Default is `false`.
|
2175
|
+
*/
|
2176
|
+
declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
|
2177
|
+
tools?: ToolSet;
|
2178
|
+
ignoreIncompleteToolCalls?: boolean;
|
2179
|
+
}): ModelMessage[];
|
2180
|
+
/**
|
2181
|
+
@deprecated Use `convertToModelMessages` instead.
|
2182
|
+
*/
|
2183
|
+
declare const convertToCoreMessages: typeof convertToModelMessages;
|
2184
|
+
|
2185
|
+
type PrepareSendMessagesRequest<UI_MESSAGE extends UIMessage> = (options: {
|
2186
|
+
id: string;
|
2187
|
+
messages: UI_MESSAGE[];
|
2188
|
+
requestMetadata: unknown;
|
2189
|
+
body: Record<string, any> | undefined;
|
2190
|
+
credentials: RequestCredentials | undefined;
|
2191
|
+
headers: HeadersInit | undefined;
|
2192
|
+
api: string;
|
2193
|
+
} & {
|
2194
|
+
trigger: 'submit-user-message' | 'submit-tool-result' | 'regenerate-assistant-message';
|
2195
|
+
messageId: string | undefined;
|
2196
|
+
}) => {
|
2197
|
+
body: object;
|
2198
|
+
headers?: HeadersInit;
|
2199
|
+
credentials?: RequestCredentials;
|
2200
|
+
api?: string;
|
2201
|
+
} | PromiseLike<{
|
2202
|
+
body: object;
|
2203
|
+
headers?: HeadersInit;
|
2204
|
+
credentials?: RequestCredentials;
|
2205
|
+
api?: string;
|
2206
|
+
}>;
|
2207
|
+
type PrepareReconnectToStreamRequest = (options: {
|
2208
|
+
id: string;
|
2209
|
+
requestMetadata: unknown;
|
2210
|
+
body: Record<string, any> | undefined;
|
2211
|
+
credentials: RequestCredentials | undefined;
|
2212
|
+
headers: HeadersInit | undefined;
|
2213
|
+
api: string;
|
2214
|
+
}) => {
|
2215
|
+
headers?: HeadersInit;
|
2216
|
+
credentials?: RequestCredentials;
|
2217
|
+
api?: string;
|
2218
|
+
} | PromiseLike<{
|
2219
|
+
headers?: HeadersInit;
|
2220
|
+
credentials?: RequestCredentials;
|
2221
|
+
api?: string;
|
2222
|
+
}>;
|
2223
|
+
type HttpChatTransportInitOptions<UI_MESSAGE extends UIMessage> = {
|
2224
|
+
api?: string;
|
2119
2225
|
/**
|
2120
|
-
|
2226
|
+
* The credentials mode to be used for the fetch request.
|
2227
|
+
* Possible values are: 'omit', 'same-origin', 'include'.
|
2228
|
+
* Defaults to 'same-origin'.
|
2121
2229
|
*/
|
2122
|
-
|
2230
|
+
credentials?: RequestCredentials;
|
2123
2231
|
/**
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2232
|
+
* HTTP headers to be sent with the API request.
|
2233
|
+
*/
|
2234
|
+
headers?: Record<string, string> | Headers;
|
2127
2235
|
/**
|
2128
|
-
*
|
2236
|
+
* Extra body object to be sent with the API request.
|
2237
|
+
* @example
|
2238
|
+
* Send a `sessionId` to the API along with the messages.
|
2239
|
+
* ```js
|
2240
|
+
* useChat({
|
2241
|
+
* body: {
|
2242
|
+
* sessionId: '123',
|
2243
|
+
* }
|
2244
|
+
* })
|
2245
|
+
* ```
|
2129
2246
|
*/
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2247
|
+
body?: object;
|
2248
|
+
/**
|
2249
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
2250
|
+
or to provide a custom fetch implementation for e.g. testing.
|
2251
|
+
*/
|
2252
|
+
fetch?: FetchFunction;
|
2253
|
+
/**
|
2254
|
+
* When a function is provided, it will be used
|
2255
|
+
* to prepare the request body for the chat API. This can be useful for
|
2256
|
+
* customizing the request body based on the messages and data in the chat.
|
2257
|
+
*
|
2258
|
+
* @param id The id of the chat.
|
2259
|
+
* @param messages The current messages in the chat.
|
2260
|
+
* @param requestBody The request body object passed in the chat request.
|
2261
|
+
*/
|
2262
|
+
prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
2263
|
+
prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
2264
|
+
};
|
2265
|
+
declare abstract class HttpChatTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
|
2266
|
+
protected api: string;
|
2267
|
+
protected credentials?: RequestCredentials;
|
2268
|
+
protected headers?: Record<string, string> | Headers;
|
2269
|
+
protected body?: object;
|
2270
|
+
protected fetch?: FetchFunction;
|
2271
|
+
protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
2272
|
+
protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
2273
|
+
constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest, }: HttpChatTransportInitOptions<UI_MESSAGE>);
|
2274
|
+
sendMessages({ abortSignal, ...options }: Parameters<ChatTransport<UI_MESSAGE>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
2275
|
+
reconnectToStream(options: Parameters<ChatTransport<UI_MESSAGE>['reconnectToStream']>[0]): Promise<ReadableStream<UIMessageChunk> | null>;
|
2276
|
+
protected abstract processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
2277
|
+
}
|
2135
2278
|
|
2136
|
-
|
2279
|
+
declare class DefaultChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
|
2280
|
+
constructor(options?: HttpChatTransportInitOptions<UI_MESSAGE>);
|
2281
|
+
protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
2282
|
+
}
|
2283
|
+
|
2284
|
+
declare class TextStreamChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
|
2285
|
+
constructor(options?: HttpChatTransportInitOptions<UI_MESSAGE>);
|
2286
|
+
protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
2287
|
+
}
|
2137
2288
|
|
2138
|
-
type
|
2289
|
+
type CompletionRequestOptions = {
|
2139
2290
|
/**
|
2140
|
-
|
2141
|
-
* and a message ID is provided for the response message.
|
2291
|
+
An optional object of headers to be passed to the API endpoint.
|
2142
2292
|
*/
|
2143
|
-
|
2144
|
-
onFinish?: (options: {
|
2145
|
-
/**
|
2146
|
-
* The updates list of UI messages.
|
2147
|
-
*/
|
2148
|
-
messages: UI_MESSAGE[];
|
2149
|
-
/**
|
2150
|
-
* Indicates whether the response message is a continuation of the last original message,
|
2151
|
-
* or if a new message was created.
|
2152
|
-
*/
|
2153
|
-
isContinuation: boolean;
|
2154
|
-
/**
|
2155
|
-
* The message that was sent to the client as a response
|
2156
|
-
* (including the original message if it was extended).
|
2157
|
-
*/
|
2158
|
-
responseMessage: UI_MESSAGE;
|
2159
|
-
}) => void;
|
2293
|
+
headers?: Record<string, string> | Headers;
|
2160
2294
|
/**
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
part: TextStreamPart<ToolSet>;
|
2167
|
-
}) => InferUIMessageMetadata<UI_MESSAGE> | undefined;
|
2295
|
+
An optional object to be passed to the API endpoint.
|
2296
|
+
*/
|
2297
|
+
body?: object;
|
2298
|
+
};
|
2299
|
+
type UseCompletionOptions = {
|
2168
2300
|
/**
|
2169
|
-
*
|
2170
|
-
*
|
2301
|
+
* The API endpoint that accepts a `{ prompt: string }` object and returns
|
2302
|
+
* a stream of tokens of the AI completion response. Defaults to `/api/completion`.
|
2171
2303
|
*/
|
2172
|
-
|
2304
|
+
api?: string;
|
2173
2305
|
/**
|
2174
|
-
*
|
2175
|
-
*
|
2306
|
+
* An unique identifier for the chat. If not provided, a random one will be
|
2307
|
+
* generated. When provided, the `useChat` hook with the same `id` will
|
2308
|
+
* have shared states across components.
|
2176
2309
|
*/
|
2177
|
-
|
2310
|
+
id?: string;
|
2178
2311
|
/**
|
2179
|
-
*
|
2180
|
-
* Set to false if you are using additional streamText calls
|
2181
|
-
* that send additional data.
|
2182
|
-
* Default to true.
|
2312
|
+
* Initial prompt input of the completion.
|
2183
2313
|
*/
|
2184
|
-
|
2314
|
+
initialInput?: string;
|
2185
2315
|
/**
|
2186
|
-
*
|
2187
|
-
* Set to false if you are using additional streamText calls
|
2188
|
-
* and the message start event has already been sent.
|
2189
|
-
* Default to true.
|
2190
|
-
*
|
2191
|
-
* Note: this setting is currently not used, but you should
|
2192
|
-
* already set it to false if you are using additional
|
2193
|
-
* streamText calls that send additional data to prevent
|
2194
|
-
* the message start event from being sent multiple times.
|
2316
|
+
* Initial completion result. Useful to load an existing history.
|
2195
2317
|
*/
|
2196
|
-
|
2318
|
+
initialCompletion?: string;
|
2197
2319
|
/**
|
2198
|
-
*
|
2199
|
-
*
|
2200
|
-
* @return error message to include in the data stream.
|
2320
|
+
* Callback function to be called when the completion is finished streaming.
|
2201
2321
|
*/
|
2202
|
-
|
2203
|
-
};
|
2204
|
-
type ConsumeStreamOptions = {
|
2205
|
-
onError?: (error: unknown) => void;
|
2206
|
-
};
|
2207
|
-
/**
|
2208
|
-
A result object for accessing different stream types and additional information.
|
2209
|
-
*/
|
2210
|
-
interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
2322
|
+
onFinish?: (prompt: string, completion: string) => void;
|
2211
2323
|
/**
|
2212
|
-
|
2213
|
-
|
2214
|
-
Resolved when the response is finished.
|
2324
|
+
* Callback function to be called when an error is encountered.
|
2215
2325
|
*/
|
2216
|
-
|
2217
|
-
/**
|
2218
|
-
The full text that has been generated by the last step.
|
2219
|
-
|
2220
|
-
Resolved when the response is finished.
|
2221
|
-
*/
|
2222
|
-
readonly text: Promise<string>;
|
2326
|
+
onError?: (error: Error) => void;
|
2223
2327
|
/**
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2328
|
+
* The credentials mode to be used for the fetch request.
|
2329
|
+
* Possible values are: 'omit', 'same-origin', 'include'.
|
2330
|
+
* Defaults to 'same-origin'.
|
2227
2331
|
*/
|
2228
|
-
|
2229
|
-
/**
|
2230
|
-
The reasoning that has been generated by the last step.
|
2231
|
-
|
2232
|
-
Resolved when the response is finished.
|
2233
|
-
*/
|
2234
|
-
readonly reasoningText: Promise<string | undefined>;
|
2332
|
+
credentials?: RequestCredentials;
|
2235
2333
|
/**
|
2236
|
-
|
2237
|
-
|
2238
|
-
Resolved when the response is finished.
|
2334
|
+
* HTTP headers to be sent with the API request.
|
2239
2335
|
*/
|
2240
|
-
|
2336
|
+
headers?: Record<string, string> | Headers;
|
2241
2337
|
/**
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2338
|
+
* Extra body object to be sent with the API request.
|
2339
|
+
* @example
|
2340
|
+
* Send a `sessionId` to the API along with the prompt.
|
2341
|
+
* ```js
|
2342
|
+
* useChat({
|
2343
|
+
* body: {
|
2344
|
+
* sessionId: '123',
|
2345
|
+
* }
|
2346
|
+
* })
|
2347
|
+
* ```
|
2245
2348
|
*/
|
2246
|
-
|
2349
|
+
body?: object;
|
2247
2350
|
/**
|
2248
|
-
|
2249
|
-
|
2250
|
-
Resolved when the response is finished.
|
2351
|
+
Streaming protocol that is used. Defaults to `data`.
|
2251
2352
|
*/
|
2252
|
-
|
2353
|
+
streamProtocol?: 'data' | 'text';
|
2253
2354
|
/**
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2355
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
2356
|
+
or to provide a custom fetch implementation for e.g. testing.
|
2357
|
+
*/
|
2358
|
+
fetch?: FetchFunction;
|
2359
|
+
};
|
2360
|
+
|
2361
|
+
/**
|
2362
|
+
* Calculates the cosine similarity between two vectors. This is a useful metric for
|
2363
|
+
* comparing the similarity of two vectors such as embeddings.
|
2364
|
+
*
|
2365
|
+
* @param vector1 - The first vector.
|
2366
|
+
* @param vector2 - The second vector.
|
2367
|
+
*
|
2368
|
+
* @returns The cosine similarity between vector1 and vector2.
|
2369
|
+
* @returns 0 if either vector is the zero vector.
|
2370
|
+
*
|
2371
|
+
* @throws {InvalidArgumentError} If the vectors do not have the same length.
|
2372
|
+
*/
|
2373
|
+
declare function cosineSimilarity(vector1: number[], vector2: number[]): number;
|
2374
|
+
|
2375
|
+
/**
|
2376
|
+
* Converts a data URL of type text/* to a text string.
|
2377
|
+
*/
|
2378
|
+
declare function getTextFromDataUrl(dataUrl: string): string;
|
2379
|
+
|
2380
|
+
/**
|
2381
|
+
* Performs a deep-equal comparison of two parsed JSON objects.
|
2382
|
+
*
|
2383
|
+
* @param {any} obj1 - The first object to compare.
|
2384
|
+
* @param {any} obj2 - The second object to compare.
|
2385
|
+
* @returns {boolean} - Returns true if the two objects are deeply equal, false otherwise.
|
2386
|
+
*/
|
2387
|
+
declare function isDeepEqualData(obj1: any, obj2: any): boolean;
|
2388
|
+
|
2389
|
+
declare function parsePartialJson(jsonText: string | undefined): Promise<{
|
2390
|
+
value: JSONValue$1 | undefined;
|
2391
|
+
state: 'undefined-input' | 'successful-parse' | 'repaired-parse' | 'failed-parse';
|
2392
|
+
}>;
|
2393
|
+
|
2394
|
+
type Job = () => Promise<void>;
|
2395
|
+
|
2396
|
+
declare class SerialJobExecutor {
|
2397
|
+
private queue;
|
2398
|
+
private isProcessing;
|
2399
|
+
private processQueue;
|
2400
|
+
run(job: Job): Promise<void>;
|
2401
|
+
}
|
2402
|
+
|
2403
|
+
/**
|
2404
|
+
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
2405
|
+
*
|
2406
|
+
* @param options - The configuration options
|
2407
|
+
* @param options.chunks - Array of values to be emitted by the stream
|
2408
|
+
* @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
2409
|
+
* @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.
|
2410
|
+
* @returns A ReadableStream that emits the provided values
|
2411
|
+
*/
|
2412
|
+
declare function simulateReadableStream<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal, }: {
|
2413
|
+
chunks: T[];
|
2414
|
+
initialDelayInMs?: number | null;
|
2415
|
+
chunkDelayInMs?: number | null;
|
2416
|
+
_internal?: {
|
2417
|
+
delay?: (ms: number | null) => Promise<void>;
|
2418
|
+
};
|
2419
|
+
}): ReadableStream<T>;
|
2420
|
+
|
2421
|
+
/**
|
2422
|
+
The result of an `embed` call.
|
2423
|
+
It contains the embedding, the value, and additional information.
|
2424
|
+
*/
|
2425
|
+
interface EmbedResult<VALUE> {
|
2259
2426
|
/**
|
2260
|
-
|
2261
|
-
|
2262
|
-
Resolved when the response is finished.
|
2427
|
+
The value that was embedded.
|
2263
2428
|
*/
|
2264
|
-
readonly
|
2429
|
+
readonly value: VALUE;
|
2265
2430
|
/**
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
*/
|
2270
|
-
readonly usage: Promise<LanguageModelUsage>;
|
2431
|
+
The embedding of the value.
|
2432
|
+
*/
|
2433
|
+
readonly embedding: Embedding;
|
2271
2434
|
/**
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2435
|
+
The embedding token usage.
|
2436
|
+
*/
|
2437
|
+
readonly usage: EmbeddingModelUsage;
|
2438
|
+
/**
|
2439
|
+
Optional response data.
|
2276
2440
|
*/
|
2277
|
-
readonly
|
2441
|
+
readonly response?: {
|
2442
|
+
/**
|
2443
|
+
Response headers.
|
2444
|
+
*/
|
2445
|
+
headers?: Record<string, string>;
|
2446
|
+
/**
|
2447
|
+
The response body.
|
2448
|
+
*/
|
2449
|
+
body?: unknown;
|
2450
|
+
};
|
2451
|
+
}
|
2452
|
+
|
2453
|
+
/**
|
2454
|
+
Embed a value using an embedding model. The type of the value is defined by the embedding model.
|
2455
|
+
|
2456
|
+
@param model - The embedding model to use.
|
2457
|
+
@param value - The value that should be embedded.
|
2458
|
+
|
2459
|
+
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
2460
|
+
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
2461
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
2462
|
+
|
2463
|
+
@returns A result object that contains the embedding, the value, and additional information.
|
2464
|
+
*/
|
2465
|
+
declare function embed<VALUE>({ model, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
|
2278
2466
|
/**
|
2279
|
-
|
2467
|
+
The embedding model to use.
|
2280
2468
|
*/
|
2281
|
-
|
2469
|
+
model: EmbeddingModel<VALUE>;
|
2282
2470
|
/**
|
2283
|
-
|
2284
|
-
You can use this to get information about intermediate steps,
|
2285
|
-
such as the tool calls or the response headers.
|
2471
|
+
The value that should be embedded.
|
2286
2472
|
*/
|
2287
|
-
|
2473
|
+
value: VALUE;
|
2288
2474
|
/**
|
2289
|
-
|
2475
|
+
Maximum number of retries per embedding model call. Set to 0 to disable retries.
|
2476
|
+
|
2477
|
+
@default 2
|
2478
|
+
*/
|
2479
|
+
maxRetries?: number;
|
2480
|
+
/**
|
2481
|
+
Abort signal.
|
2290
2482
|
*/
|
2291
|
-
|
2483
|
+
abortSignal?: AbortSignal;
|
2292
2484
|
/**
|
2293
|
-
Additional
|
2485
|
+
Additional headers to include in the request.
|
2486
|
+
Only applicable for HTTP-based providers.
|
2294
2487
|
*/
|
2295
|
-
|
2296
|
-
/**
|
2297
|
-
The response messages that were generated during the call. It consists of an assistant message,
|
2298
|
-
potentially containing tool calls.
|
2299
|
-
|
2300
|
-
When there are tool results, there is an additional tool message with the tool results that are available.
|
2301
|
-
If there are tools that do not have execute functions, they are not included in the tool results and
|
2302
|
-
need to be added separately.
|
2303
|
-
*/
|
2304
|
-
messages: Array<ResponseMessage>;
|
2305
|
-
}>;
|
2488
|
+
headers?: Record<string, string>;
|
2306
2489
|
/**
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2490
|
+
Additional provider-specific options. They are passed through
|
2491
|
+
to the provider from the AI SDK and enable provider-specific
|
2492
|
+
functionality that can be fully encapsulated in the provider.
|
2493
|
+
*/
|
2494
|
+
providerOptions?: ProviderOptions;
|
2312
2495
|
/**
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2496
|
+
* Optional telemetry configuration (experimental).
|
2497
|
+
*/
|
2498
|
+
experimental_telemetry?: TelemetrySettings;
|
2499
|
+
}): Promise<EmbedResult<VALUE>>;
|
2500
|
+
|
2501
|
+
/**
|
2502
|
+
The result of a `embedMany` call.
|
2503
|
+
It contains the embeddings, the values, and additional information.
|
2504
|
+
*/
|
2505
|
+
interface EmbedManyResult<VALUE> {
|
2318
2506
|
/**
|
2319
|
-
|
2320
|
-
errors.
|
2321
|
-
You can use it as either an AsyncIterable or a ReadableStream.
|
2322
|
-
Only errors that stop the stream, such as network errors, are thrown.
|
2507
|
+
The values that were embedded.
|
2323
2508
|
*/
|
2324
|
-
readonly
|
2509
|
+
readonly values: Array<VALUE>;
|
2325
2510
|
/**
|
2326
|
-
|
2327
|
-
|
2328
|
-
readonly
|
2511
|
+
The embeddings. They are in the same order as the values.
|
2512
|
+
*/
|
2513
|
+
readonly embeddings: Array<Embedding>;
|
2329
2514
|
/**
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
triggering the `onFinish` callback and the promise resolution.
|
2334
|
-
|
2335
|
-
If an error occurs, it is passed to the optional `onError` callback.
|
2336
|
-
*/
|
2337
|
-
consumeStream(options?: ConsumeStreamOptions): Promise<void>;
|
2515
|
+
The embedding token usage.
|
2516
|
+
*/
|
2517
|
+
readonly usage: EmbeddingModelUsage;
|
2338
2518
|
/**
|
2339
|
-
|
2340
|
-
|
2341
|
-
@param options.getErrorMessage an optional function that converts an error to an error message.
|
2342
|
-
@param options.sendUsage whether to send the usage information to the client. Defaults to true.
|
2343
|
-
@param options.sendReasoning whether to send the reasoning information to the client. Defaults to false.
|
2344
|
-
@param options.sendSources whether to send the sources information to the client. Defaults to false.
|
2345
|
-
@param options.experimental_sendFinish whether to send the finish information to the client. Defaults to true.
|
2346
|
-
@param options.experimental_sendStart whether to send the start information to the client. Defaults to true.
|
2347
|
-
|
2348
|
-
@return A UI message stream.
|
2519
|
+
Optional raw response data.
|
2349
2520
|
*/
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
@param response A Node.js response-like object (ServerResponse).
|
2354
|
-
@param options.status The status code.
|
2355
|
-
@param options.statusText The status text.
|
2356
|
-
@param options.headers The headers.
|
2357
|
-
@param options.getErrorMessage An optional function that converts an error to an error message.
|
2358
|
-
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
2359
|
-
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
2521
|
+
readonly responses?: Array<{
|
2522
|
+
/**
|
2523
|
+
Response headers.
|
2360
2524
|
*/
|
2361
|
-
|
2525
|
+
headers?: Record<string, string>;
|
2526
|
+
/**
|
2527
|
+
The response body.
|
2528
|
+
*/
|
2529
|
+
body?: unknown;
|
2530
|
+
} | undefined>;
|
2531
|
+
}
|
2532
|
+
|
2533
|
+
/**
|
2534
|
+
Embed several values using an embedding model. The type of the value is defined
|
2535
|
+
by the embedding model.
|
2536
|
+
|
2537
|
+
`embedMany` automatically splits large requests into smaller chunks if the model
|
2538
|
+
has a limit on how many embeddings can be generated in a single call.
|
2539
|
+
|
2540
|
+
@param model - The embedding model to use.
|
2541
|
+
@param values - The values that should be embedded.
|
2542
|
+
|
2543
|
+
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
2544
|
+
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
2545
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
2546
|
+
|
2547
|
+
@returns A result object that contains the embeddings, the value, and additional information.
|
2548
|
+
*/
|
2549
|
+
declare function embedMany<VALUE>({ model, values, maxParallelCalls, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
|
2362
2550
|
/**
|
2363
|
-
|
2364
|
-
It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
2365
|
-
writes each text delta as a separate chunk.
|
2366
|
-
@param response A Node.js response-like object (ServerResponse).
|
2367
|
-
@param init Optional headers, status code, and status text.
|
2551
|
+
The embedding model to use.
|
2368
2552
|
*/
|
2369
|
-
|
2553
|
+
model: EmbeddingModel<VALUE>;
|
2370
2554
|
/**
|
2371
|
-
|
2555
|
+
The values that should be embedded.
|
2556
|
+
*/
|
2557
|
+
values: Array<VALUE>;
|
2558
|
+
/**
|
2559
|
+
Maximum number of retries per embedding model call. Set to 0 to disable retries.
|
2372
2560
|
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2376
|
-
@param options.getErrorMessage An optional function that converts an error to an error message.
|
2377
|
-
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
2378
|
-
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
2379
|
-
@return A response object.
|
2380
|
-
*/
|
2381
|
-
toUIMessageStreamResponse<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Response;
|
2561
|
+
@default 2
|
2562
|
+
*/
|
2563
|
+
maxRetries?: number;
|
2382
2564
|
/**
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
}
|
2408
|
-
type: 'reasoning-end';
|
2409
|
-
id: string;
|
2410
|
-
providerMetadata?: ProviderMetadata;
|
2411
|
-
} | {
|
2412
|
-
type: 'reasoning';
|
2413
|
-
providerMetadata?: ProviderMetadata;
|
2414
|
-
id: string;
|
2415
|
-
text: string;
|
2416
|
-
} | {
|
2417
|
-
type: 'tool-input-start';
|
2418
|
-
id: string;
|
2419
|
-
toolName: string;
|
2420
|
-
providerMetadata?: ProviderMetadata;
|
2421
|
-
providerExecuted?: boolean;
|
2422
|
-
} | {
|
2423
|
-
type: 'tool-input-end';
|
2424
|
-
id: string;
|
2425
|
-
providerMetadata?: ProviderMetadata;
|
2426
|
-
} | {
|
2427
|
-
type: 'tool-input-delta';
|
2428
|
-
id: string;
|
2429
|
-
delta: string;
|
2430
|
-
providerMetadata?: ProviderMetadata;
|
2431
|
-
} | ({
|
2432
|
-
type: 'source';
|
2433
|
-
} & Source) | {
|
2434
|
-
type: 'file';
|
2435
|
-
file: GeneratedFile;
|
2436
|
-
} | ({
|
2437
|
-
type: 'tool-call';
|
2438
|
-
} & ToolCallUnion<TOOLS>) | ({
|
2439
|
-
type: 'tool-result';
|
2440
|
-
} & ToolResultUnion<TOOLS>) | ({
|
2441
|
-
type: 'tool-error';
|
2442
|
-
} & ToolErrorUnion<TOOLS>) | {
|
2443
|
-
type: 'start-step';
|
2444
|
-
request: LanguageModelRequestMetadata;
|
2445
|
-
warnings: CallWarning[];
|
2446
|
-
} | {
|
2447
|
-
type: 'finish-step';
|
2448
|
-
response: LanguageModelResponseMetadata;
|
2449
|
-
usage: LanguageModelUsage;
|
2450
|
-
finishReason: FinishReason;
|
2451
|
-
providerMetadata: ProviderMetadata | undefined;
|
2452
|
-
} | {
|
2453
|
-
type: 'start';
|
2454
|
-
} | {
|
2455
|
-
type: 'finish';
|
2456
|
-
finishReason: FinishReason;
|
2457
|
-
totalUsage: LanguageModelUsage;
|
2458
|
-
} | {
|
2459
|
-
type: 'error';
|
2460
|
-
error: unknown;
|
2461
|
-
} | {
|
2462
|
-
type: 'raw';
|
2463
|
-
rawValue: unknown;
|
2464
|
-
};
|
2565
|
+
Abort signal.
|
2566
|
+
*/
|
2567
|
+
abortSignal?: AbortSignal;
|
2568
|
+
/**
|
2569
|
+
Additional headers to include in the request.
|
2570
|
+
Only applicable for HTTP-based providers.
|
2571
|
+
*/
|
2572
|
+
headers?: Record<string, string>;
|
2573
|
+
/**
|
2574
|
+
* Optional telemetry configuration (experimental).
|
2575
|
+
*/
|
2576
|
+
experimental_telemetry?: TelemetrySettings;
|
2577
|
+
/**
|
2578
|
+
Additional provider-specific options. They are passed through
|
2579
|
+
to the provider from the AI SDK and enable provider-specific
|
2580
|
+
functionality that can be fully encapsulated in the provider.
|
2581
|
+
*/
|
2582
|
+
providerOptions?: ProviderOptions;
|
2583
|
+
/**
|
2584
|
+
* Maximum number of concurrent requests.
|
2585
|
+
*
|
2586
|
+
* @default Infinity
|
2587
|
+
*/
|
2588
|
+
maxParallelCalls?: number;
|
2589
|
+
}): Promise<EmbedManyResult<VALUE>>;
|
2465
2590
|
|
2466
2591
|
/**
|
2467
2592
|
* Detects the first chunk in a buffer.
|
@@ -2919,7 +3044,7 @@ functionality that can be fully encapsulated in the provider.
|
|
2919
3044
|
@returns
|
2920
3045
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
2921
3046
|
*/
|
2922
|
-
declare function generateObject<SCHEMA extends z3.Schema | z4
|
3047
|
+
declare function generateObject<SCHEMA extends z3.Schema | z4$1.ZodType | Schema = z4$1.ZodType<JSONValue$1>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (OUTPUT extends 'enum' ? {
|
2923
3048
|
/**
|
2924
3049
|
The enum values that the model should use.
|
2925
3050
|
*/
|
@@ -3176,7 +3301,7 @@ functionality that can be fully encapsulated in the provider.
|
|
3176
3301
|
@returns
|
3177
3302
|
A result object for accessing the partial object stream and additional information.
|
3178
3303
|
*/
|
3179
|
-
declare function streamObject<SCHEMA extends z3.Schema | z4
|
3304
|
+
declare function streamObject<SCHEMA extends z3.Schema | z4$1.ZodType | Schema = z4$1.ZodType<JSONValue$1>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (OUTPUT extends 'enum' ? {
|
3180
3305
|
/**
|
3181
3306
|
The enum values that the model should use.
|
3182
3307
|
*/
|
@@ -3494,227 +3619,67 @@ declare const experimental_createProviderRegistry: typeof createProviderRegistry
|
|
3494
3619
|
|
3495
3620
|
declare const JSONRPCRequestSchema: z.ZodObject<{
|
3496
3621
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3497
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3498
|
-
} & {
|
3622
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3499
3623
|
method: z.ZodString;
|
3500
3624
|
params: z.ZodOptional<z.ZodObject<{
|
3501
|
-
_meta: z.ZodOptional<z.ZodObject<{},
|
3502
|
-
},
|
3503
|
-
|
3504
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3505
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3506
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
3507
|
-
}, "strict", z.ZodTypeAny, {
|
3508
|
-
id: string | number;
|
3509
|
-
method: string;
|
3510
|
-
jsonrpc: "2.0";
|
3511
|
-
params?: z.objectOutputType<{
|
3512
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3513
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
3514
|
-
}, {
|
3515
|
-
id: string | number;
|
3516
|
-
method: string;
|
3517
|
-
jsonrpc: "2.0";
|
3518
|
-
params?: z.objectInputType<{
|
3519
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3520
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
3521
|
-
}>;
|
3625
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3626
|
+
}, z.core.$loose>>;
|
3627
|
+
}, z.core.$strict>;
|
3522
3628
|
type JSONRPCRequest = z.infer<typeof JSONRPCRequestSchema>;
|
3523
3629
|
declare const JSONRPCResponseSchema: z.ZodObject<{
|
3524
3630
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3525
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3631
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3526
3632
|
result: z.ZodObject<{
|
3527
|
-
_meta: z.ZodOptional<z.ZodObject<{},
|
3528
|
-
},
|
3529
|
-
|
3530
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3531
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3532
|
-
}, z.ZodTypeAny, "passthrough">>;
|
3533
|
-
}, "strict", z.ZodTypeAny, {
|
3534
|
-
id: string | number;
|
3535
|
-
result: {
|
3536
|
-
_meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
3537
|
-
} & {
|
3538
|
-
[k: string]: unknown;
|
3539
|
-
};
|
3540
|
-
jsonrpc: "2.0";
|
3541
|
-
}, {
|
3542
|
-
id: string | number;
|
3543
|
-
result: {
|
3544
|
-
_meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
3545
|
-
} & {
|
3546
|
-
[k: string]: unknown;
|
3547
|
-
};
|
3548
|
-
jsonrpc: "2.0";
|
3549
|
-
}>;
|
3633
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3634
|
+
}, z.core.$loose>;
|
3635
|
+
}, z.core.$strict>;
|
3550
3636
|
type JSONRPCResponse = z.infer<typeof JSONRPCResponseSchema>;
|
3551
3637
|
declare const JSONRPCErrorSchema: z.ZodObject<{
|
3552
3638
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3553
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3639
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3554
3640
|
error: z.ZodObject<{
|
3555
3641
|
code: z.ZodNumber;
|
3556
3642
|
message: z.ZodString;
|
3557
3643
|
data: z.ZodOptional<z.ZodUnknown>;
|
3558
|
-
},
|
3559
|
-
|
3560
|
-
code: number;
|
3561
|
-
data?: unknown;
|
3562
|
-
}, {
|
3563
|
-
message: string;
|
3564
|
-
code: number;
|
3565
|
-
data?: unknown;
|
3566
|
-
}>;
|
3567
|
-
}, "strict", z.ZodTypeAny, {
|
3568
|
-
error: {
|
3569
|
-
message: string;
|
3570
|
-
code: number;
|
3571
|
-
data?: unknown;
|
3572
|
-
};
|
3573
|
-
id: string | number;
|
3574
|
-
jsonrpc: "2.0";
|
3575
|
-
}, {
|
3576
|
-
error: {
|
3577
|
-
message: string;
|
3578
|
-
code: number;
|
3579
|
-
data?: unknown;
|
3580
|
-
};
|
3581
|
-
id: string | number;
|
3582
|
-
jsonrpc: "2.0";
|
3583
|
-
}>;
|
3644
|
+
}, z.core.$strip>;
|
3645
|
+
}, z.core.$strict>;
|
3584
3646
|
type JSONRPCError = z.infer<typeof JSONRPCErrorSchema>;
|
3585
3647
|
declare const JSONRPCNotificationSchema: z.ZodObject<{
|
3586
3648
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3587
|
-
} & {
|
3588
3649
|
method: z.ZodString;
|
3589
3650
|
params: z.ZodOptional<z.ZodObject<{
|
3590
|
-
_meta: z.ZodOptional<z.ZodObject<{},
|
3591
|
-
},
|
3592
|
-
|
3593
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3594
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3595
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
3596
|
-
}, "strict", z.ZodTypeAny, {
|
3597
|
-
method: string;
|
3598
|
-
jsonrpc: "2.0";
|
3599
|
-
params?: z.objectOutputType<{
|
3600
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3601
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
3602
|
-
}, {
|
3603
|
-
method: string;
|
3604
|
-
jsonrpc: "2.0";
|
3605
|
-
params?: z.objectInputType<{
|
3606
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3607
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
3608
|
-
}>;
|
3651
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3652
|
+
}, z.core.$loose>>;
|
3653
|
+
}, z.core.$strict>;
|
3609
3654
|
type JSONRPCNotification = z.infer<typeof JSONRPCNotificationSchema>;
|
3610
|
-
declare const JSONRPCMessageSchema: z.ZodUnion<[z.ZodObject<{
|
3655
|
+
declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
|
3611
3656
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3612
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3613
|
-
} & {
|
3657
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3614
3658
|
method: z.ZodString;
|
3615
3659
|
params: z.ZodOptional<z.ZodObject<{
|
3616
|
-
_meta: z.ZodOptional<z.ZodObject<{},
|
3617
|
-
},
|
3618
|
-
|
3619
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3620
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3621
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
3622
|
-
}, "strict", z.ZodTypeAny, {
|
3623
|
-
id: string | number;
|
3624
|
-
method: string;
|
3625
|
-
jsonrpc: "2.0";
|
3626
|
-
params?: z.objectOutputType<{
|
3627
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3628
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
3629
|
-
}, {
|
3630
|
-
id: string | number;
|
3631
|
-
method: string;
|
3632
|
-
jsonrpc: "2.0";
|
3633
|
-
params?: z.objectInputType<{
|
3634
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3635
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
3636
|
-
}>, z.ZodObject<{
|
3660
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3661
|
+
}, z.core.$loose>>;
|
3662
|
+
}, z.core.$strict>, z.ZodObject<{
|
3637
3663
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3638
|
-
} & {
|
3639
3664
|
method: z.ZodString;
|
3640
3665
|
params: z.ZodOptional<z.ZodObject<{
|
3641
|
-
_meta: z.ZodOptional<z.ZodObject<{},
|
3642
|
-
},
|
3643
|
-
|
3644
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3645
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3646
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
3647
|
-
}, "strict", z.ZodTypeAny, {
|
3648
|
-
method: string;
|
3649
|
-
jsonrpc: "2.0";
|
3650
|
-
params?: z.objectOutputType<{
|
3651
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3652
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
3653
|
-
}, {
|
3654
|
-
method: string;
|
3655
|
-
jsonrpc: "2.0";
|
3656
|
-
params?: z.objectInputType<{
|
3657
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3658
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
3659
|
-
}>, z.ZodObject<{
|
3666
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3667
|
+
}, z.core.$loose>>;
|
3668
|
+
}, z.core.$strict>, z.ZodObject<{
|
3660
3669
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3661
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3670
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3662
3671
|
result: z.ZodObject<{
|
3663
|
-
_meta: z.ZodOptional<z.ZodObject<{},
|
3664
|
-
},
|
3665
|
-
|
3666
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3667
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
3668
|
-
}, z.ZodTypeAny, "passthrough">>;
|
3669
|
-
}, "strict", z.ZodTypeAny, {
|
3670
|
-
id: string | number;
|
3671
|
-
result: {
|
3672
|
-
_meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
3673
|
-
} & {
|
3674
|
-
[k: string]: unknown;
|
3675
|
-
};
|
3676
|
-
jsonrpc: "2.0";
|
3677
|
-
}, {
|
3678
|
-
id: string | number;
|
3679
|
-
result: {
|
3680
|
-
_meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
3681
|
-
} & {
|
3682
|
-
[k: string]: unknown;
|
3683
|
-
};
|
3684
|
-
jsonrpc: "2.0";
|
3685
|
-
}>, z.ZodObject<{
|
3672
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3673
|
+
}, z.core.$loose>;
|
3674
|
+
}, z.core.$strict>, z.ZodObject<{
|
3686
3675
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3687
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3676
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3688
3677
|
error: z.ZodObject<{
|
3689
3678
|
code: z.ZodNumber;
|
3690
3679
|
message: z.ZodString;
|
3691
3680
|
data: z.ZodOptional<z.ZodUnknown>;
|
3692
|
-
},
|
3693
|
-
|
3694
|
-
code: number;
|
3695
|
-
data?: unknown;
|
3696
|
-
}, {
|
3697
|
-
message: string;
|
3698
|
-
code: number;
|
3699
|
-
data?: unknown;
|
3700
|
-
}>;
|
3701
|
-
}, "strict", z.ZodTypeAny, {
|
3702
|
-
error: {
|
3703
|
-
message: string;
|
3704
|
-
code: number;
|
3705
|
-
data?: unknown;
|
3706
|
-
};
|
3707
|
-
id: string | number;
|
3708
|
-
jsonrpc: "2.0";
|
3709
|
-
}, {
|
3710
|
-
error: {
|
3711
|
-
message: string;
|
3712
|
-
code: number;
|
3713
|
-
data?: unknown;
|
3714
|
-
};
|
3715
|
-
id: string | number;
|
3716
|
-
jsonrpc: "2.0";
|
3717
|
-
}>]>;
|
3681
|
+
}, z.core.$strip>;
|
3682
|
+
}, z.core.$strict>]>;
|
3718
3683
|
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
|
3719
3684
|
|
3720
3685
|
/**
|
@@ -3772,717 +3737,31 @@ type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS e
|
|
3772
3737
|
inputSchema: FlexibleSchema<unknown>;
|
3773
3738
|
}>>;
|
3774
3739
|
declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
3775
|
-
_meta: z.ZodOptional<z.ZodObject<{},
|
3776
|
-
|
3777
|
-
content: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
3778
|
-
type: z.ZodLiteral<"text">;
|
3779
|
-
text: z.ZodString;
|
3780
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3781
|
-
type: z.ZodLiteral<"text">;
|
3782
|
-
text: z.ZodString;
|
3783
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3784
|
-
type: z.ZodLiteral<"text">;
|
3785
|
-
text: z.ZodString;
|
3786
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
3787
|
-
type: z.ZodLiteral<"image">;
|
3788
|
-
data: z.ZodString;
|
3789
|
-
mimeType: z.ZodString;
|
3790
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3791
|
-
type: z.ZodLiteral<"image">;
|
3792
|
-
data: z.ZodString;
|
3793
|
-
mimeType: z.ZodString;
|
3794
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3795
|
-
type: z.ZodLiteral<"image">;
|
3796
|
-
data: z.ZodString;
|
3797
|
-
mimeType: z.ZodString;
|
3798
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
3799
|
-
type: z.ZodLiteral<"resource">;
|
3800
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
3801
|
-
/**
|
3802
|
-
* The URI of this resource.
|
3803
|
-
*/
|
3804
|
-
uri: z.ZodString;
|
3805
|
-
/**
|
3806
|
-
* The MIME type of this resource, if known.
|
3807
|
-
*/
|
3808
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3809
|
-
} & {
|
3810
|
-
text: z.ZodString;
|
3811
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3812
|
-
/**
|
3813
|
-
* The URI of this resource.
|
3814
|
-
*/
|
3815
|
-
uri: z.ZodString;
|
3816
|
-
/**
|
3817
|
-
* The MIME type of this resource, if known.
|
3818
|
-
*/
|
3819
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3820
|
-
} & {
|
3821
|
-
text: z.ZodString;
|
3822
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3823
|
-
/**
|
3824
|
-
* The URI of this resource.
|
3825
|
-
*/
|
3826
|
-
uri: z.ZodString;
|
3827
|
-
/**
|
3828
|
-
* The MIME type of this resource, if known.
|
3829
|
-
*/
|
3830
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3831
|
-
} & {
|
3832
|
-
text: z.ZodString;
|
3833
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
3834
|
-
/**
|
3835
|
-
* The URI of this resource.
|
3836
|
-
*/
|
3837
|
-
uri: z.ZodString;
|
3838
|
-
/**
|
3839
|
-
* The MIME type of this resource, if known.
|
3840
|
-
*/
|
3841
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3842
|
-
} & {
|
3843
|
-
blob: z.ZodString;
|
3844
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3845
|
-
/**
|
3846
|
-
* The URI of this resource.
|
3847
|
-
*/
|
3848
|
-
uri: z.ZodString;
|
3849
|
-
/**
|
3850
|
-
* The MIME type of this resource, if known.
|
3851
|
-
*/
|
3852
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3853
|
-
} & {
|
3854
|
-
blob: z.ZodString;
|
3855
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3856
|
-
/**
|
3857
|
-
* The URI of this resource.
|
3858
|
-
*/
|
3859
|
-
uri: z.ZodString;
|
3860
|
-
/**
|
3861
|
-
* The MIME type of this resource, if known.
|
3862
|
-
*/
|
3863
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3864
|
-
} & {
|
3865
|
-
blob: z.ZodString;
|
3866
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
3867
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3868
|
-
type: z.ZodLiteral<"resource">;
|
3869
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
3870
|
-
/**
|
3871
|
-
* The URI of this resource.
|
3872
|
-
*/
|
3873
|
-
uri: z.ZodString;
|
3874
|
-
/**
|
3875
|
-
* The MIME type of this resource, if known.
|
3876
|
-
*/
|
3877
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3878
|
-
} & {
|
3879
|
-
text: z.ZodString;
|
3880
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3881
|
-
/**
|
3882
|
-
* The URI of this resource.
|
3883
|
-
*/
|
3884
|
-
uri: z.ZodString;
|
3885
|
-
/**
|
3886
|
-
* The MIME type of this resource, if known.
|
3887
|
-
*/
|
3888
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3889
|
-
} & {
|
3890
|
-
text: z.ZodString;
|
3891
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3892
|
-
/**
|
3893
|
-
* The URI of this resource.
|
3894
|
-
*/
|
3895
|
-
uri: z.ZodString;
|
3896
|
-
/**
|
3897
|
-
* The MIME type of this resource, if known.
|
3898
|
-
*/
|
3899
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3900
|
-
} & {
|
3901
|
-
text: z.ZodString;
|
3902
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
3903
|
-
/**
|
3904
|
-
* The URI of this resource.
|
3905
|
-
*/
|
3906
|
-
uri: z.ZodString;
|
3907
|
-
/**
|
3908
|
-
* The MIME type of this resource, if known.
|
3909
|
-
*/
|
3910
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3911
|
-
} & {
|
3912
|
-
blob: z.ZodString;
|
3913
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3914
|
-
/**
|
3915
|
-
* The URI of this resource.
|
3916
|
-
*/
|
3917
|
-
uri: z.ZodString;
|
3918
|
-
/**
|
3919
|
-
* The MIME type of this resource, if known.
|
3920
|
-
*/
|
3921
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3922
|
-
} & {
|
3923
|
-
blob: z.ZodString;
|
3924
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3925
|
-
/**
|
3926
|
-
* The URI of this resource.
|
3927
|
-
*/
|
3928
|
-
uri: z.ZodString;
|
3929
|
-
/**
|
3930
|
-
* The MIME type of this resource, if known.
|
3931
|
-
*/
|
3932
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3933
|
-
} & {
|
3934
|
-
blob: z.ZodString;
|
3935
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
3936
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3937
|
-
type: z.ZodLiteral<"resource">;
|
3938
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
3939
|
-
/**
|
3940
|
-
* The URI of this resource.
|
3941
|
-
*/
|
3942
|
-
uri: z.ZodString;
|
3943
|
-
/**
|
3944
|
-
* The MIME type of this resource, if known.
|
3945
|
-
*/
|
3946
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3947
|
-
} & {
|
3948
|
-
text: z.ZodString;
|
3949
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3950
|
-
/**
|
3951
|
-
* The URI of this resource.
|
3952
|
-
*/
|
3953
|
-
uri: z.ZodString;
|
3954
|
-
/**
|
3955
|
-
* The MIME type of this resource, if known.
|
3956
|
-
*/
|
3957
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3958
|
-
} & {
|
3959
|
-
text: z.ZodString;
|
3960
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3961
|
-
/**
|
3962
|
-
* The URI of this resource.
|
3963
|
-
*/
|
3964
|
-
uri: z.ZodString;
|
3965
|
-
/**
|
3966
|
-
* The MIME type of this resource, if known.
|
3967
|
-
*/
|
3968
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3969
|
-
} & {
|
3970
|
-
text: z.ZodString;
|
3971
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
3972
|
-
/**
|
3973
|
-
* The URI of this resource.
|
3974
|
-
*/
|
3975
|
-
uri: z.ZodString;
|
3976
|
-
/**
|
3977
|
-
* The MIME type of this resource, if known.
|
3978
|
-
*/
|
3979
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3980
|
-
} & {
|
3981
|
-
blob: z.ZodString;
|
3982
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
3983
|
-
/**
|
3984
|
-
* The URI of this resource.
|
3985
|
-
*/
|
3986
|
-
uri: z.ZodString;
|
3987
|
-
/**
|
3988
|
-
* The MIME type of this resource, if known.
|
3989
|
-
*/
|
3990
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
3991
|
-
} & {
|
3992
|
-
blob: z.ZodString;
|
3993
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3994
|
-
/**
|
3995
|
-
* The URI of this resource.
|
3996
|
-
*/
|
3997
|
-
uri: z.ZodString;
|
3998
|
-
/**
|
3999
|
-
* The MIME type of this resource, if known.
|
4000
|
-
*/
|
4001
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4002
|
-
} & {
|
4003
|
-
blob: z.ZodString;
|
4004
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
4005
|
-
}, z.ZodTypeAny, "passthrough">>]>, "many">;
|
4006
|
-
isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
4007
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4008
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
4009
|
-
} & {
|
4010
|
-
content: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
4011
|
-
type: z.ZodLiteral<"text">;
|
4012
|
-
text: z.ZodString;
|
4013
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4014
|
-
type: z.ZodLiteral<"text">;
|
4015
|
-
text: z.ZodString;
|
4016
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4017
|
-
type: z.ZodLiteral<"text">;
|
4018
|
-
text: z.ZodString;
|
4019
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
4020
|
-
type: z.ZodLiteral<"image">;
|
4021
|
-
data: z.ZodString;
|
4022
|
-
mimeType: z.ZodString;
|
4023
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4024
|
-
type: z.ZodLiteral<"image">;
|
4025
|
-
data: z.ZodString;
|
4026
|
-
mimeType: z.ZodString;
|
4027
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4028
|
-
type: z.ZodLiteral<"image">;
|
4029
|
-
data: z.ZodString;
|
4030
|
-
mimeType: z.ZodString;
|
4031
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
4032
|
-
type: z.ZodLiteral<"resource">;
|
4033
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
4034
|
-
/**
|
4035
|
-
* The URI of this resource.
|
4036
|
-
*/
|
4037
|
-
uri: z.ZodString;
|
4038
|
-
/**
|
4039
|
-
* The MIME type of this resource, if known.
|
4040
|
-
*/
|
4041
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4042
|
-
} & {
|
4043
|
-
text: z.ZodString;
|
4044
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4045
|
-
/**
|
4046
|
-
* The URI of this resource.
|
4047
|
-
*/
|
4048
|
-
uri: z.ZodString;
|
4049
|
-
/**
|
4050
|
-
* The MIME type of this resource, if known.
|
4051
|
-
*/
|
4052
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4053
|
-
} & {
|
4054
|
-
text: z.ZodString;
|
4055
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4056
|
-
/**
|
4057
|
-
* The URI of this resource.
|
4058
|
-
*/
|
4059
|
-
uri: z.ZodString;
|
4060
|
-
/**
|
4061
|
-
* The MIME type of this resource, if known.
|
4062
|
-
*/
|
4063
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4064
|
-
} & {
|
4065
|
-
text: z.ZodString;
|
4066
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
4067
|
-
/**
|
4068
|
-
* The URI of this resource.
|
4069
|
-
*/
|
4070
|
-
uri: z.ZodString;
|
4071
|
-
/**
|
4072
|
-
* The MIME type of this resource, if known.
|
4073
|
-
*/
|
4074
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4075
|
-
} & {
|
4076
|
-
blob: z.ZodString;
|
4077
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4078
|
-
/**
|
4079
|
-
* The URI of this resource.
|
4080
|
-
*/
|
4081
|
-
uri: z.ZodString;
|
4082
|
-
/**
|
4083
|
-
* The MIME type of this resource, if known.
|
4084
|
-
*/
|
4085
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4086
|
-
} & {
|
4087
|
-
blob: z.ZodString;
|
4088
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4089
|
-
/**
|
4090
|
-
* The URI of this resource.
|
4091
|
-
*/
|
4092
|
-
uri: z.ZodString;
|
4093
|
-
/**
|
4094
|
-
* The MIME type of this resource, if known.
|
4095
|
-
*/
|
4096
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4097
|
-
} & {
|
4098
|
-
blob: z.ZodString;
|
4099
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
4100
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4101
|
-
type: z.ZodLiteral<"resource">;
|
4102
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
4103
|
-
/**
|
4104
|
-
* The URI of this resource.
|
4105
|
-
*/
|
4106
|
-
uri: z.ZodString;
|
4107
|
-
/**
|
4108
|
-
* The MIME type of this resource, if known.
|
4109
|
-
*/
|
4110
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4111
|
-
} & {
|
4112
|
-
text: z.ZodString;
|
4113
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4114
|
-
/**
|
4115
|
-
* The URI of this resource.
|
4116
|
-
*/
|
4117
|
-
uri: z.ZodString;
|
4118
|
-
/**
|
4119
|
-
* The MIME type of this resource, if known.
|
4120
|
-
*/
|
4121
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4122
|
-
} & {
|
4123
|
-
text: z.ZodString;
|
4124
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4125
|
-
/**
|
4126
|
-
* The URI of this resource.
|
4127
|
-
*/
|
4128
|
-
uri: z.ZodString;
|
4129
|
-
/**
|
4130
|
-
* The MIME type of this resource, if known.
|
4131
|
-
*/
|
4132
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4133
|
-
} & {
|
4134
|
-
text: z.ZodString;
|
4135
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
4136
|
-
/**
|
4137
|
-
* The URI of this resource.
|
4138
|
-
*/
|
4139
|
-
uri: z.ZodString;
|
4140
|
-
/**
|
4141
|
-
* The MIME type of this resource, if known.
|
4142
|
-
*/
|
4143
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4144
|
-
} & {
|
4145
|
-
blob: z.ZodString;
|
4146
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4147
|
-
/**
|
4148
|
-
* The URI of this resource.
|
4149
|
-
*/
|
4150
|
-
uri: z.ZodString;
|
4151
|
-
/**
|
4152
|
-
* The MIME type of this resource, if known.
|
4153
|
-
*/
|
4154
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4155
|
-
} & {
|
4156
|
-
blob: z.ZodString;
|
4157
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4158
|
-
/**
|
4159
|
-
* The URI of this resource.
|
4160
|
-
*/
|
4161
|
-
uri: z.ZodString;
|
4162
|
-
/**
|
4163
|
-
* The MIME type of this resource, if known.
|
4164
|
-
*/
|
4165
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4166
|
-
} & {
|
4167
|
-
blob: z.ZodString;
|
4168
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
4169
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4170
|
-
type: z.ZodLiteral<"resource">;
|
4171
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
4172
|
-
/**
|
4173
|
-
* The URI of this resource.
|
4174
|
-
*/
|
4175
|
-
uri: z.ZodString;
|
4176
|
-
/**
|
4177
|
-
* The MIME type of this resource, if known.
|
4178
|
-
*/
|
4179
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4180
|
-
} & {
|
4181
|
-
text: z.ZodString;
|
4182
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4183
|
-
/**
|
4184
|
-
* The URI of this resource.
|
4185
|
-
*/
|
4186
|
-
uri: z.ZodString;
|
4187
|
-
/**
|
4188
|
-
* The MIME type of this resource, if known.
|
4189
|
-
*/
|
4190
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4191
|
-
} & {
|
4192
|
-
text: z.ZodString;
|
4193
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4194
|
-
/**
|
4195
|
-
* The URI of this resource.
|
4196
|
-
*/
|
4197
|
-
uri: z.ZodString;
|
4198
|
-
/**
|
4199
|
-
* The MIME type of this resource, if known.
|
4200
|
-
*/
|
4201
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4202
|
-
} & {
|
4203
|
-
text: z.ZodString;
|
4204
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
4205
|
-
/**
|
4206
|
-
* The URI of this resource.
|
4207
|
-
*/
|
4208
|
-
uri: z.ZodString;
|
4209
|
-
/**
|
4210
|
-
* The MIME type of this resource, if known.
|
4211
|
-
*/
|
4212
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4213
|
-
} & {
|
4214
|
-
blob: z.ZodString;
|
4215
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4216
|
-
/**
|
4217
|
-
* The URI of this resource.
|
4218
|
-
*/
|
4219
|
-
uri: z.ZodString;
|
4220
|
-
/**
|
4221
|
-
* The MIME type of this resource, if known.
|
4222
|
-
*/
|
4223
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4224
|
-
} & {
|
4225
|
-
blob: z.ZodString;
|
4226
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4227
|
-
/**
|
4228
|
-
* The URI of this resource.
|
4229
|
-
*/
|
4230
|
-
uri: z.ZodString;
|
4231
|
-
/**
|
4232
|
-
* The MIME type of this resource, if known.
|
4233
|
-
*/
|
4234
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4235
|
-
} & {
|
4236
|
-
blob: z.ZodString;
|
4237
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
4238
|
-
}, z.ZodTypeAny, "passthrough">>]>, "many">;
|
4239
|
-
isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
4240
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4241
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
4242
|
-
} & {
|
4243
|
-
content: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
4244
|
-
type: z.ZodLiteral<"text">;
|
4245
|
-
text: z.ZodString;
|
4246
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4247
|
-
type: z.ZodLiteral<"text">;
|
4248
|
-
text: z.ZodString;
|
4249
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3740
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3741
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
4250
3742
|
type: z.ZodLiteral<"text">;
|
4251
3743
|
text: z.ZodString;
|
4252
|
-
}, z.
|
4253
|
-
type: z.ZodLiteral<"image">;
|
4254
|
-
data: z.ZodString;
|
4255
|
-
mimeType: z.ZodString;
|
4256
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4257
|
-
type: z.ZodLiteral<"image">;
|
4258
|
-
data: z.ZodString;
|
4259
|
-
mimeType: z.ZodString;
|
4260
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3744
|
+
}, z.core.$loose>, z.ZodObject<{
|
4261
3745
|
type: z.ZodLiteral<"image">;
|
4262
3746
|
data: z.ZodString;
|
4263
3747
|
mimeType: z.ZodString;
|
4264
|
-
}, z.
|
4265
|
-
type: z.ZodLiteral<"resource">;
|
4266
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
4267
|
-
/**
|
4268
|
-
* The URI of this resource.
|
4269
|
-
*/
|
4270
|
-
uri: z.ZodString;
|
4271
|
-
/**
|
4272
|
-
* The MIME type of this resource, if known.
|
4273
|
-
*/
|
4274
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4275
|
-
} & {
|
4276
|
-
text: z.ZodString;
|
4277
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4278
|
-
/**
|
4279
|
-
* The URI of this resource.
|
4280
|
-
*/
|
4281
|
-
uri: z.ZodString;
|
4282
|
-
/**
|
4283
|
-
* The MIME type of this resource, if known.
|
4284
|
-
*/
|
4285
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4286
|
-
} & {
|
4287
|
-
text: z.ZodString;
|
4288
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4289
|
-
/**
|
4290
|
-
* The URI of this resource.
|
4291
|
-
*/
|
4292
|
-
uri: z.ZodString;
|
4293
|
-
/**
|
4294
|
-
* The MIME type of this resource, if known.
|
4295
|
-
*/
|
4296
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4297
|
-
} & {
|
4298
|
-
text: z.ZodString;
|
4299
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
4300
|
-
/**
|
4301
|
-
* The URI of this resource.
|
4302
|
-
*/
|
4303
|
-
uri: z.ZodString;
|
4304
|
-
/**
|
4305
|
-
* The MIME type of this resource, if known.
|
4306
|
-
*/
|
4307
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4308
|
-
} & {
|
4309
|
-
blob: z.ZodString;
|
4310
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4311
|
-
/**
|
4312
|
-
* The URI of this resource.
|
4313
|
-
*/
|
4314
|
-
uri: z.ZodString;
|
4315
|
-
/**
|
4316
|
-
* The MIME type of this resource, if known.
|
4317
|
-
*/
|
4318
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4319
|
-
} & {
|
4320
|
-
blob: z.ZodString;
|
4321
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4322
|
-
/**
|
4323
|
-
* The URI of this resource.
|
4324
|
-
*/
|
4325
|
-
uri: z.ZodString;
|
4326
|
-
/**
|
4327
|
-
* The MIME type of this resource, if known.
|
4328
|
-
*/
|
4329
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4330
|
-
} & {
|
4331
|
-
blob: z.ZodString;
|
4332
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
4333
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4334
|
-
type: z.ZodLiteral<"resource">;
|
4335
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
4336
|
-
/**
|
4337
|
-
* The URI of this resource.
|
4338
|
-
*/
|
4339
|
-
uri: z.ZodString;
|
4340
|
-
/**
|
4341
|
-
* The MIME type of this resource, if known.
|
4342
|
-
*/
|
4343
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4344
|
-
} & {
|
4345
|
-
text: z.ZodString;
|
4346
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4347
|
-
/**
|
4348
|
-
* The URI of this resource.
|
4349
|
-
*/
|
4350
|
-
uri: z.ZodString;
|
4351
|
-
/**
|
4352
|
-
* The MIME type of this resource, if known.
|
4353
|
-
*/
|
4354
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4355
|
-
} & {
|
4356
|
-
text: z.ZodString;
|
4357
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4358
|
-
/**
|
4359
|
-
* The URI of this resource.
|
4360
|
-
*/
|
4361
|
-
uri: z.ZodString;
|
4362
|
-
/**
|
4363
|
-
* The MIME type of this resource, if known.
|
4364
|
-
*/
|
4365
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4366
|
-
} & {
|
4367
|
-
text: z.ZodString;
|
4368
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
4369
|
-
/**
|
4370
|
-
* The URI of this resource.
|
4371
|
-
*/
|
4372
|
-
uri: z.ZodString;
|
4373
|
-
/**
|
4374
|
-
* The MIME type of this resource, if known.
|
4375
|
-
*/
|
4376
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4377
|
-
} & {
|
4378
|
-
blob: z.ZodString;
|
4379
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4380
|
-
/**
|
4381
|
-
* The URI of this resource.
|
4382
|
-
*/
|
4383
|
-
uri: z.ZodString;
|
4384
|
-
/**
|
4385
|
-
* The MIME type of this resource, if known.
|
4386
|
-
*/
|
4387
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4388
|
-
} & {
|
4389
|
-
blob: z.ZodString;
|
4390
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4391
|
-
/**
|
4392
|
-
* The URI of this resource.
|
4393
|
-
*/
|
4394
|
-
uri: z.ZodString;
|
4395
|
-
/**
|
4396
|
-
* The MIME type of this resource, if known.
|
4397
|
-
*/
|
4398
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4399
|
-
} & {
|
4400
|
-
blob: z.ZodString;
|
4401
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
4402
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
3748
|
+
}, z.core.$loose>, z.ZodObject<{
|
4403
3749
|
type: z.ZodLiteral<"resource">;
|
4404
|
-
resource: z.ZodUnion<[z.ZodObject<{
|
4405
|
-
/**
|
4406
|
-
* The URI of this resource.
|
4407
|
-
*/
|
4408
|
-
uri: z.ZodString;
|
4409
|
-
/**
|
4410
|
-
* The MIME type of this resource, if known.
|
4411
|
-
*/
|
4412
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4413
|
-
} & {
|
4414
|
-
text: z.ZodString;
|
4415
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4416
|
-
/**
|
4417
|
-
* The URI of this resource.
|
4418
|
-
*/
|
4419
|
-
uri: z.ZodString;
|
4420
|
-
/**
|
4421
|
-
* The MIME type of this resource, if known.
|
4422
|
-
*/
|
4423
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4424
|
-
} & {
|
4425
|
-
text: z.ZodString;
|
4426
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4427
|
-
/**
|
4428
|
-
* The URI of this resource.
|
4429
|
-
*/
|
3750
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
4430
3751
|
uri: z.ZodString;
|
4431
|
-
/**
|
4432
|
-
* The MIME type of this resource, if known.
|
4433
|
-
*/
|
4434
3752
|
mimeType: z.ZodOptional<z.ZodString>;
|
4435
|
-
} & {
|
4436
3753
|
text: z.ZodString;
|
4437
|
-
}, z.
|
4438
|
-
/**
|
4439
|
-
* The URI of this resource.
|
4440
|
-
*/
|
4441
|
-
uri: z.ZodString;
|
4442
|
-
/**
|
4443
|
-
* The MIME type of this resource, if known.
|
4444
|
-
*/
|
4445
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4446
|
-
} & {
|
4447
|
-
blob: z.ZodString;
|
4448
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4449
|
-
/**
|
4450
|
-
* The URI of this resource.
|
4451
|
-
*/
|
3754
|
+
}, z.core.$loose>, z.ZodObject<{
|
4452
3755
|
uri: z.ZodString;
|
4453
|
-
/**
|
4454
|
-
* The MIME type of this resource, if known.
|
4455
|
-
*/
|
4456
3756
|
mimeType: z.ZodOptional<z.ZodString>;
|
4457
|
-
} & {
|
4458
3757
|
blob: z.ZodString;
|
4459
|
-
}, z.
|
4460
|
-
|
4461
|
-
* The URI of this resource.
|
4462
|
-
*/
|
4463
|
-
uri: z.ZodString;
|
4464
|
-
/**
|
4465
|
-
* The MIME type of this resource, if known.
|
4466
|
-
*/
|
4467
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
4468
|
-
} & {
|
4469
|
-
blob: z.ZodString;
|
4470
|
-
}, z.ZodTypeAny, "passthrough">>]>;
|
4471
|
-
}, z.ZodTypeAny, "passthrough">>]>, "many">;
|
3758
|
+
}, z.core.$loose>]>;
|
3759
|
+
}, z.core.$loose>]>>;
|
4472
3760
|
isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
4473
|
-
}, z.
|
4474
|
-
_meta: z.ZodOptional<z.ZodObject<{},
|
4475
|
-
} & {
|
4476
|
-
toolResult: z.ZodUnknown;
|
4477
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
4478
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
4479
|
-
} & {
|
4480
|
-
toolResult: z.ZodUnknown;
|
4481
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
4482
|
-
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
4483
|
-
} & {
|
3761
|
+
}, z.core.$loose>, z.ZodObject<{
|
3762
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
4484
3763
|
toolResult: z.ZodUnknown;
|
4485
|
-
}, z.
|
3764
|
+
}, z.core.$loose>]>;
|
4486
3765
|
type CallToolResult = z.infer<typeof CallToolResultSchema>;
|
4487
3766
|
|
4488
3767
|
interface MCPClientConfig {
|
@@ -4648,4 +3927,4 @@ declare global {
|
|
4648
3927
|
var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
|
4649
3928
|
}
|
4650
3929
|
|
4651
|
-
export { AbstractChat, CallSettings, CallWarning, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUITool, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolErrorUnion, ToolResultUnion, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions,
|
3930
|
+
export { AbstractChat, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUITool, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolErrorUnion, ToolResultUnion, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };
|