ai 5.0.0-beta.1 → 5.0.0-beta.11
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 +84 -0
- package/dist/index.d.mts +1863 -2578
- package/dist/index.d.ts +1863 -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.ts
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';
|
@@ -928,18 +1085,24 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
|
|
928
1085
|
state: 'input-streaming';
|
929
1086
|
input: DeepPartial<TOOLS[NAME]['input']>;
|
930
1087
|
providerExecuted?: boolean;
|
1088
|
+
output?: never;
|
1089
|
+
errorText?: never;
|
931
1090
|
} | {
|
932
1091
|
state: 'input-available';
|
933
1092
|
input: TOOLS[NAME]['input'];
|
934
1093
|
providerExecuted?: boolean;
|
1094
|
+
output?: never;
|
1095
|
+
errorText?: never;
|
935
1096
|
} | {
|
936
1097
|
state: 'output-available';
|
937
1098
|
input: TOOLS[NAME]['input'];
|
938
1099
|
output: TOOLS[NAME]['output'];
|
1100
|
+
errorText?: never;
|
939
1101
|
providerExecuted?: boolean;
|
940
1102
|
} | {
|
941
1103
|
state: 'output-error';
|
942
1104
|
input: TOOLS[NAME]['input'];
|
1105
|
+
output?: never;
|
943
1106
|
errorText: string;
|
944
1107
|
providerExecuted?: boolean;
|
945
1108
|
});
|
@@ -949,82 +1112,15 @@ declare function getToolName<TOOLS extends UITools>(part: ToolUIPart<TOOLS>): ke
|
|
949
1112
|
type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA> ? METADATA : unknown;
|
950
1113
|
type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unknown, infer DATA_TYPES> ? DATA_TYPES : UIDataTypes;
|
951
1114
|
|
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<{
|
1115
|
+
type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
1021
1116
|
[NAME in keyof DATA_TYPES & string]: {
|
1022
1117
|
type: `data-${NAME}`;
|
1023
1118
|
id?: string;
|
1024
1119
|
data: DATA_TYPES[NAME];
|
1120
|
+
transient?: boolean;
|
1025
1121
|
};
|
1026
1122
|
}>;
|
1027
|
-
type
|
1123
|
+
type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataTypes> = {
|
1028
1124
|
type: 'text-start';
|
1029
1125
|
id: string;
|
1030
1126
|
} | {
|
@@ -1092,7 +1188,7 @@ type UIMessageStreamPart<METADATA = unknown, DATA_TYPES extends UIDataTypes = UI
|
|
1092
1188
|
type: 'file';
|
1093
1189
|
url: string;
|
1094
1190
|
mediaType: string;
|
1095
|
-
} |
|
1191
|
+
} | DataUIMessageChunk<DATA_TYPES> | {
|
1096
1192
|
type: 'start-step';
|
1097
1193
|
} | {
|
1098
1194
|
type: 'finish-step';
|
@@ -1107,30 +1203,19 @@ type UIMessageStreamPart<METADATA = unknown, DATA_TYPES extends UIDataTypes = UI
|
|
1107
1203
|
type: 'message-metadata';
|
1108
1204
|
messageMetadata: METADATA;
|
1109
1205
|
};
|
1110
|
-
type
|
1206
|
+
type InferUIMessageChunk<T extends UIMessage> = UIMessageChunk<InferUIMessageMetadata<T>, InferUIMessageData<T>>;
|
1111
1207
|
|
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
|
-
}
|
1208
|
+
type UIMessageStreamResponseInit = ResponseInit & {
|
1209
|
+
consumeSseStream?: (options: {
|
1210
|
+
stream: ReadableStream<string>;
|
1211
|
+
}) => PromiseLike<void> | void;
|
1212
|
+
};
|
1128
1213
|
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1214
|
+
type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
1215
|
+
|
1216
|
+
type ErrorHandler = (error: unknown) => void;
|
1217
|
+
|
1218
|
+
type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
1134
1219
|
/**
|
1135
1220
|
* The original messages. If they are provided, persistence mode is assumed,
|
1136
1221
|
* and a message ID is provided for the response message.
|
@@ -1152,615 +1237,446 @@ declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute,
|
|
1152
1237
|
*/
|
1153
1238
|
responseMessage: UI_MESSAGE;
|
1154
1239
|
}) => 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
1240
|
/**
|
1212
|
-
|
1241
|
+
* Extracts message metadata that will be send to the client.
|
1242
|
+
*
|
1243
|
+
* Called on `start` and `finish` events.
|
1213
1244
|
*/
|
1214
|
-
|
1245
|
+
messageMetadata?: (options: {
|
1246
|
+
part: TextStreamPart<ToolSet>;
|
1247
|
+
}) => InferUIMessageMetadata<UI_MESSAGE> | undefined;
|
1215
1248
|
/**
|
1216
|
-
|
1249
|
+
* Send reasoning parts to the client.
|
1250
|
+
* Default to true.
|
1217
1251
|
*/
|
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[];
|
1252
|
+
sendReasoning?: boolean;
|
1240
1253
|
/**
|
1241
|
-
*
|
1242
|
-
*
|
1254
|
+
* Send source parts to the client.
|
1255
|
+
* Default to false.
|
1243
1256
|
*/
|
1244
|
-
|
1245
|
-
transport?: ChatTransport<UI_MESSAGE>;
|
1246
|
-
maxSteps?: number;
|
1257
|
+
sendSources?: boolean;
|
1247
1258
|
/**
|
1248
|
-
*
|
1259
|
+
* Send the finish event to the client.
|
1260
|
+
* Set to false if you are using additional streamText calls
|
1261
|
+
* that send additional data.
|
1262
|
+
* Default to true.
|
1249
1263
|
*/
|
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;
|
1264
|
+
sendFinish?: boolean;
|
1261
1265
|
/**
|
1262
|
-
*
|
1266
|
+
* Send the message start event to the client.
|
1267
|
+
* Set to false if you are using additional streamText calls
|
1268
|
+
* and the message start event has already been sent.
|
1269
|
+
* Default to true.
|
1263
1270
|
*
|
1264
|
-
*
|
1271
|
+
* Note: this setting is currently not used, but you should
|
1272
|
+
* already set it to false if you are using additional
|
1273
|
+
* streamText calls that send additional data to prevent
|
1274
|
+
* the message start event from being sent multiple times.
|
1265
1275
|
*/
|
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
|
-
});
|
1276
|
+
sendStart?: boolean;
|
1286
1277
|
/**
|
1287
|
-
*
|
1278
|
+
* Process an error, e.g. to log it. Default to `() => 'An error occurred.'`.
|
1288
1279
|
*
|
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.
|
1280
|
+
* @return error message to include in the data stream.
|
1293
1281
|
*/
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1282
|
+
onError?: (error: unknown) => string;
|
1283
|
+
};
|
1284
|
+
type ConsumeStreamOptions = {
|
1285
|
+
onError?: ErrorHandler;
|
1286
|
+
};
|
1287
|
+
/**
|
1288
|
+
A result object for accessing different stream types and additional information.
|
1289
|
+
*/
|
1290
|
+
interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
1303
1291
|
/**
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
* If a messageId is provided, the message will be replaced.
|
1292
|
+
The content that was generated in the last step.
|
1293
|
+
|
1294
|
+
Resolved when the response is finished.
|
1308
1295
|
*/
|
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>;
|
1296
|
+
readonly content: Promise<Array<ContentPart<TOOLS>>>;
|
1325
1297
|
/**
|
1326
|
-
|
1327
|
-
|
1298
|
+
The full text that has been generated by the last step.
|
1299
|
+
|
1300
|
+
Resolved when the response is finished.
|
1301
|
+
*/
|
1302
|
+
readonly text: Promise<string>;
|
1303
|
+
/**
|
1304
|
+
The full reasoning that the model has generated.
|
1305
|
+
|
1306
|
+
Resolved when the response is finished.
|
1328
1307
|
*/
|
1329
|
-
|
1330
|
-
messageId?: string;
|
1331
|
-
} & ChatRequestOptions) => Promise<void>;
|
1308
|
+
readonly reasoning: Promise<Array<ReasoningPart>>;
|
1332
1309
|
/**
|
1333
|
-
|
1310
|
+
The reasoning that has been generated by the last step.
|
1311
|
+
|
1312
|
+
Resolved when the response is finished.
|
1313
|
+
*/
|
1314
|
+
readonly reasoningText: Promise<string | undefined>;
|
1315
|
+
/**
|
1316
|
+
Files that have been generated by the model in the last step.
|
1317
|
+
|
1318
|
+
Resolved when the response is finished.
|
1334
1319
|
*/
|
1335
|
-
|
1336
|
-
addToolResult: ({ toolCallId, output, }: {
|
1337
|
-
toolCallId: string;
|
1338
|
-
output: unknown;
|
1339
|
-
}) => Promise<void>;
|
1320
|
+
readonly files: Promise<GeneratedFile[]>;
|
1340
1321
|
/**
|
1341
|
-
|
1322
|
+
Sources that have been used as references in the last step.
|
1323
|
+
|
1324
|
+
Resolved when the response is finished.
|
1342
1325
|
*/
|
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;
|
1326
|
+
readonly sources: Promise<Source[]>;
|
1392
1327
|
/**
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1328
|
+
The tool calls that have been executed in the last step.
|
1329
|
+
|
1330
|
+
Resolved when the response is finished.
|
1331
|
+
*/
|
1332
|
+
readonly toolCalls: Promise<ToolCallUnion<TOOLS>[]>;
|
1333
|
+
/**
|
1334
|
+
The tool results that have been generated in the last step.
|
1335
|
+
|
1336
|
+
Resolved when the all tool executions are finished.
|
1396
1337
|
*/
|
1397
|
-
|
1338
|
+
readonly toolResults: Promise<ToolResultUnion<TOOLS>[]>;
|
1398
1339
|
/**
|
1399
|
-
|
1340
|
+
The reason why the generation finished. Taken from the last step.
|
1341
|
+
|
1342
|
+
Resolved when the response is finished.
|
1343
|
+
*/
|
1344
|
+
readonly finishReason: Promise<FinishReason>;
|
1345
|
+
/**
|
1346
|
+
The token usage of the last step.
|
1347
|
+
|
1348
|
+
Resolved when the response is finished.
|
1400
1349
|
*/
|
1401
|
-
|
1350
|
+
readonly usage: Promise<LanguageModelUsage>;
|
1402
1351
|
/**
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1352
|
+
The total token usage of the generated response.
|
1353
|
+
When there are multiple steps, the usage is the sum of all step usages.
|
1354
|
+
|
1355
|
+
Resolved when the response is finished.
|
1356
|
+
*/
|
1357
|
+
readonly totalUsage: Promise<LanguageModelUsage>;
|
1358
|
+
/**
|
1359
|
+
Warnings from the model provider (e.g. unsupported settings) for the first step.
|
1360
|
+
*/
|
1361
|
+
readonly warnings: Promise<CallWarning[] | undefined>;
|
1362
|
+
/**
|
1363
|
+
Details for all steps.
|
1364
|
+
You can use this to get information about intermediate steps,
|
1365
|
+
such as the tool calls or the response headers.
|
1413
1366
|
*/
|
1414
|
-
|
1367
|
+
readonly steps: Promise<Array<StepResult<TOOLS>>>;
|
1415
1368
|
/**
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
fetch?: FetchFunction;
|
1369
|
+
Additional request information from the last step.
|
1370
|
+
*/
|
1371
|
+
readonly request: Promise<LanguageModelRequestMetadata>;
|
1420
1372
|
/**
|
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 = {
|
1373
|
+
Additional response information from the last step.
|
1374
|
+
*/
|
1375
|
+
readonly response: Promise<LanguageModelResponseMetadata & {
|
1376
|
+
/**
|
1377
|
+
The response messages that were generated during the call. It consists of an assistant message,
|
1378
|
+
potentially containing tool calls.
|
1379
|
+
|
1380
|
+
When there are tool results, there is an additional tool message with the tool results that are available.
|
1381
|
+
If there are tools that do not have execute functions, they are not included in the tool results and
|
1382
|
+
need to be added separately.
|
1383
|
+
*/
|
1384
|
+
messages: Array<ResponseMessage>;
|
1385
|
+
}>;
|
1457
1386
|
/**
|
1458
|
-
|
1387
|
+
Additional provider-specific metadata from the last step.
|
1388
|
+
Metadata is passed through from the provider to the AI SDK and
|
1389
|
+
enables provider-specific results that can be fully encapsulated in the provider.
|
1459
1390
|
*/
|
1460
|
-
|
1391
|
+
readonly providerMetadata: Promise<ProviderMetadata | undefined>;
|
1461
1392
|
/**
|
1462
|
-
|
1393
|
+
A text stream that returns only the generated text deltas. You can use it
|
1394
|
+
as either an AsyncIterable or a ReadableStream. When an error occurs, the
|
1395
|
+
stream will throw the error.
|
1463
1396
|
*/
|
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;
|
1397
|
+
readonly textStream: AsyncIterableStream<string>;
|
1482
1398
|
/**
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1399
|
+
A stream with all events, including text deltas, tool calls, tool results, and
|
1400
|
+
errors.
|
1401
|
+
You can use it as either an AsyncIterable or a ReadableStream.
|
1402
|
+
Only errors that stop the stream, such as network errors, are thrown.
|
1403
|
+
*/
|
1404
|
+
readonly fullStream: AsyncIterableStream<TextStreamPart<TOOLS>>;
|
1486
1405
|
/**
|
1487
|
-
|
1406
|
+
A stream of partial outputs. It uses the `experimental_output` specification.
|
1488
1407
|
*/
|
1489
|
-
|
1408
|
+
readonly experimental_partialOutputStream: AsyncIterableStream<PARTIAL_OUTPUT>;
|
1490
1409
|
/**
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1410
|
+
Consumes the stream without processing the parts.
|
1411
|
+
This is useful to force the stream to finish.
|
1412
|
+
It effectively removes the backpressure and allows the stream to finish,
|
1413
|
+
triggering the `onFinish` callback and the promise resolution.
|
1414
|
+
|
1415
|
+
If an error occurs, it is passed to the optional `onError` callback.
|
1416
|
+
*/
|
1417
|
+
consumeStream(options?: ConsumeStreamOptions): Promise<void>;
|
1494
1418
|
/**
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1419
|
+
Converts the result to a UI message stream.
|
1420
|
+
|
1421
|
+
@param options.getErrorMessage an optional function that converts an error to an error message.
|
1422
|
+
@param options.sendUsage whether to send the usage information to the client. Defaults to true.
|
1423
|
+
@param options.sendReasoning whether to send the reasoning information to the client. Defaults to false.
|
1424
|
+
@param options.sendSources whether to send the sources information to the client. Defaults to false.
|
1425
|
+
@param options.experimental_sendFinish whether to send the finish information to the client. Defaults to true.
|
1426
|
+
@param options.experimental_sendStart whether to send the start information to the client. Defaults to true.
|
1427
|
+
|
1428
|
+
@return A UI message stream.
|
1429
|
+
*/
|
1430
|
+
toUIMessageStream<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamOptions<UI_MESSAGE>): ReadableStream<InferUIMessageChunk<UI_MESSAGE>>;
|
1500
1431
|
/**
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1432
|
+
Writes UI message stream output to a Node.js response-like object.
|
1433
|
+
@param response A Node.js response-like object (ServerResponse).
|
1434
|
+
@param options.status The status code.
|
1435
|
+
@param options.statusText The status text.
|
1436
|
+
@param options.headers The headers.
|
1437
|
+
@param options.getErrorMessage An optional function that converts an error to an error message.
|
1438
|
+
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
1439
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
1440
|
+
*/
|
1441
|
+
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): void;
|
1504
1442
|
/**
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
* }
|
1513
|
-
* })
|
1514
|
-
* ```
|
1515
|
-
*/
|
1516
|
-
body?: object;
|
1443
|
+
Writes text delta output to a Node.js response-like object.
|
1444
|
+
It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
1445
|
+
writes each text delta as a separate chunk.
|
1446
|
+
@param response A Node.js response-like object (ServerResponse).
|
1447
|
+
@param init Optional headers, status code, and status text.
|
1448
|
+
*/
|
1449
|
+
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void;
|
1517
1450
|
/**
|
1518
|
-
|
1451
|
+
Converts the result to a streamed response object with a stream data part stream.
|
1452
|
+
|
1453
|
+
@param options.status The status code.
|
1454
|
+
@param options.statusText The status text.
|
1455
|
+
@param options.headers The headers.
|
1456
|
+
@param options.getErrorMessage An optional function that converts an error to an error message.
|
1457
|
+
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
1458
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
1459
|
+
@return A response object.
|
1519
1460
|
*/
|
1520
|
-
|
1461
|
+
toUIMessageStreamResponse<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Response;
|
1521
1462
|
/**
|
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>;
|
1463
|
+
Creates a simple text stream response.
|
1464
|
+
Each text delta is encoded as UTF-8 and sent as a separate chunk.
|
1465
|
+
Non-text-delta events are ignored.
|
1466
|
+
@param init Optional headers, status code, and status text.
|
1467
|
+
*/
|
1468
|
+
toTextStreamResponse(init?: ResponseInit): Response;
|
1568
1469
|
}
|
1470
|
+
type TextStreamPart<TOOLS extends ToolSet> = {
|
1471
|
+
type: 'text-start';
|
1472
|
+
id: string;
|
1473
|
+
providerMetadata?: ProviderMetadata;
|
1474
|
+
} | {
|
1475
|
+
type: 'text-end';
|
1476
|
+
id: string;
|
1477
|
+
providerMetadata?: ProviderMetadata;
|
1478
|
+
} | {
|
1479
|
+
type: 'text';
|
1480
|
+
id: string;
|
1481
|
+
providerMetadata?: ProviderMetadata;
|
1482
|
+
text: string;
|
1483
|
+
} | {
|
1484
|
+
type: 'reasoning-start';
|
1485
|
+
id: string;
|
1486
|
+
providerMetadata?: ProviderMetadata;
|
1487
|
+
} | {
|
1488
|
+
type: 'reasoning-end';
|
1489
|
+
id: string;
|
1490
|
+
providerMetadata?: ProviderMetadata;
|
1491
|
+
} | {
|
1492
|
+
type: 'reasoning';
|
1493
|
+
providerMetadata?: ProviderMetadata;
|
1494
|
+
id: string;
|
1495
|
+
text: string;
|
1496
|
+
} | {
|
1497
|
+
type: 'tool-input-start';
|
1498
|
+
id: string;
|
1499
|
+
toolName: string;
|
1500
|
+
providerMetadata?: ProviderMetadata;
|
1501
|
+
providerExecuted?: boolean;
|
1502
|
+
} | {
|
1503
|
+
type: 'tool-input-end';
|
1504
|
+
id: string;
|
1505
|
+
providerMetadata?: ProviderMetadata;
|
1506
|
+
} | {
|
1507
|
+
type: 'tool-input-delta';
|
1508
|
+
id: string;
|
1509
|
+
delta: string;
|
1510
|
+
providerMetadata?: ProviderMetadata;
|
1511
|
+
} | ({
|
1512
|
+
type: 'source';
|
1513
|
+
} & Source) | {
|
1514
|
+
type: 'file';
|
1515
|
+
file: GeneratedFile;
|
1516
|
+
} | ({
|
1517
|
+
type: 'tool-call';
|
1518
|
+
} & ToolCallUnion<TOOLS>) | ({
|
1519
|
+
type: 'tool-result';
|
1520
|
+
} & ToolResultUnion<TOOLS>) | ({
|
1521
|
+
type: 'tool-error';
|
1522
|
+
} & ToolErrorUnion<TOOLS>) | {
|
1523
|
+
type: 'start-step';
|
1524
|
+
request: LanguageModelRequestMetadata;
|
1525
|
+
warnings: CallWarning[];
|
1526
|
+
} | {
|
1527
|
+
type: 'finish-step';
|
1528
|
+
response: LanguageModelResponseMetadata;
|
1529
|
+
usage: LanguageModelUsage;
|
1530
|
+
finishReason: FinishReason;
|
1531
|
+
providerMetadata: ProviderMetadata | undefined;
|
1532
|
+
} | {
|
1533
|
+
type: 'start';
|
1534
|
+
} | {
|
1535
|
+
type: 'finish';
|
1536
|
+
finishReason: FinishReason;
|
1537
|
+
totalUsage: LanguageModelUsage;
|
1538
|
+
} | {
|
1539
|
+
type: 'error';
|
1540
|
+
error: unknown;
|
1541
|
+
} | {
|
1542
|
+
type: 'raw';
|
1543
|
+
rawValue: unknown;
|
1544
|
+
};
|
1569
1545
|
|
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;
|
1546
|
+
type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
|
1601
1547
|
/**
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1548
|
+
* The system prompt to use.
|
1549
|
+
*/
|
1550
|
+
system?: string;
|
1605
1551
|
/**
|
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, }: {
|
1552
|
+
The language model to use.
|
1553
|
+
*/
|
1554
|
+
model: LanguageModel;
|
1633
1555
|
/**
|
1634
|
-
The
|
1635
|
-
|
1636
|
-
|
1556
|
+
The tools that the model can call. The model needs to support calling tools.
|
1557
|
+
*/
|
1558
|
+
tools?: TOOLS;
|
1637
1559
|
/**
|
1638
|
-
The
|
1560
|
+
The tool choice strategy. Default: 'auto'.
|
1639
1561
|
*/
|
1640
|
-
|
1562
|
+
toolChoice?: ToolChoice<NoInfer<TOOLS>>;
|
1641
1563
|
/**
|
1642
|
-
|
1564
|
+
Condition for stopping the generation when there are tool results in the last step.
|
1565
|
+
When the condition is an array, any of the conditions can be met to stop the generation.
|
1643
1566
|
|
1644
|
-
@default
|
1567
|
+
@default stepCountIs(1)
|
1645
1568
|
*/
|
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;
|
1569
|
+
stopWhen?: StopCondition<NoInfer<TOOLS>> | Array<StopCondition<NoInfer<TOOLS>>>;
|
1662
1570
|
/**
|
1663
|
-
|
1571
|
+
Optional telemetry configuration (experimental).
|
1664
1572
|
*/
|
1665
1573
|
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
1574
|
/**
|
1722
|
-
|
1575
|
+
Limits the tools that are available for the model to call without
|
1576
|
+
changing the tool call and result types in the result.
|
1723
1577
|
*/
|
1724
|
-
|
1578
|
+
activeTools?: Array<keyof NoInfer<TOOLS>>;
|
1725
1579
|
/**
|
1726
|
-
|
1727
|
-
|
1728
|
-
@default 2
|
1580
|
+
Optional specification for parsing structured outputs from the LLM response.
|
1729
1581
|
*/
|
1730
|
-
|
1582
|
+
experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
|
1731
1583
|
/**
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1584
|
+
* @deprecated Use `prepareStep` instead.
|
1585
|
+
*/
|
1586
|
+
experimental_prepareStep?: PrepareStepFunction<NoInfer<TOOLS>>;
|
1735
1587
|
/**
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
headers?: Record<string, string>;
|
1588
|
+
Optional function that you can use to provide different settings for a step.
|
1589
|
+
*/
|
1590
|
+
prepareStep?: PrepareStepFunction<NoInfer<TOOLS>>;
|
1740
1591
|
/**
|
1741
|
-
|
1592
|
+
A function that attempts to repair a tool call that failed to parse.
|
1742
1593
|
*/
|
1743
|
-
|
1594
|
+
experimental_repairToolCall?: ToolCallRepairFunction<NoInfer<TOOLS>>;
|
1744
1595
|
/**
|
1745
|
-
|
1746
|
-
to the provider from the AI SDK and enable provider-specific
|
1747
|
-
functionality that can be fully encapsulated in the provider.
|
1596
|
+
Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
1748
1597
|
*/
|
1749
|
-
|
1598
|
+
onStepFinish?: GenerateTextOnStepFinishCallback<NoInfer<TOOLS>>;
|
1750
1599
|
/**
|
1751
|
-
*
|
1752
|
-
*
|
1753
|
-
* @default Infinity
|
1600
|
+
* Internal. For test use only. May change without notice.
|
1754
1601
|
*/
|
1755
|
-
|
1756
|
-
|
1602
|
+
_internal?: {
|
1603
|
+
generateId?: IdGenerator;
|
1604
|
+
currentDate?: () => Date;
|
1605
|
+
};
|
1606
|
+
};
|
1607
|
+
declare class Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> {
|
1608
|
+
private readonly settings;
|
1609
|
+
constructor(settings: AgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
|
1610
|
+
generate(options: Prompt & {
|
1611
|
+
/**
|
1612
|
+
Additional provider-specific metadata. They are passed through
|
1613
|
+
from the provider to the AI SDK and enable provider-specific
|
1614
|
+
results that can be fully encapsulated in the provider.
|
1615
|
+
*/
|
1616
|
+
providerMetadata?: ProviderMetadata;
|
1617
|
+
}): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
1618
|
+
stream(options: Prompt & {
|
1619
|
+
/**
|
1620
|
+
Additional provider-specific metadata. They are passed through
|
1621
|
+
from the provider to the AI SDK and enable provider-specific
|
1622
|
+
results that can be fully encapsulated in the provider.
|
1623
|
+
*/
|
1624
|
+
providerMetadata?: ProviderMetadata;
|
1625
|
+
}): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
|
1626
|
+
}
|
1757
1627
|
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1628
|
+
declare const symbol$c: unique symbol;
|
1629
|
+
declare class InvalidArgumentError extends AISDKError {
|
1630
|
+
private readonly [symbol$c];
|
1631
|
+
readonly parameter: string;
|
1632
|
+
readonly value: unknown;
|
1633
|
+
constructor({ parameter, value, message, }: {
|
1634
|
+
parameter: string;
|
1635
|
+
value: unknown;
|
1636
|
+
message: string;
|
1637
|
+
});
|
1638
|
+
static isInstance(error: unknown): error is InvalidArgumentError;
|
1639
|
+
}
|
1640
|
+
|
1641
|
+
type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
1642
|
+
type: 'text-start';
|
1643
|
+
providerMetadata?: ProviderMetadata;
|
1644
|
+
id: string;
|
1761
1645
|
} | {
|
1762
|
-
type: '
|
1763
|
-
|
1646
|
+
type: 'text-delta';
|
1647
|
+
id: string;
|
1648
|
+
providerMetadata?: ProviderMetadata;
|
1649
|
+
delta: string;
|
1650
|
+
} | {
|
1651
|
+
type: 'text-end';
|
1652
|
+
providerMetadata?: ProviderMetadata;
|
1653
|
+
id: string;
|
1654
|
+
} | {
|
1655
|
+
type: 'reasoning-start';
|
1656
|
+
providerMetadata?: ProviderMetadata;
|
1657
|
+
id: string;
|
1658
|
+
} | {
|
1659
|
+
type: 'reasoning-delta';
|
1660
|
+
id: string;
|
1661
|
+
providerMetadata?: ProviderMetadata;
|
1662
|
+
delta: string;
|
1663
|
+
} | {
|
1664
|
+
type: 'reasoning-end';
|
1665
|
+
id: string;
|
1666
|
+
providerMetadata?: ProviderMetadata;
|
1667
|
+
} | {
|
1668
|
+
type: 'tool-input-start';
|
1669
|
+
id: string;
|
1670
|
+
toolName: string;
|
1671
|
+
providerMetadata?: ProviderMetadata;
|
1672
|
+
} | {
|
1673
|
+
type: 'tool-input-delta';
|
1674
|
+
id: string;
|
1675
|
+
delta: string;
|
1676
|
+
providerMetadata?: ProviderMetadata;
|
1677
|
+
} | {
|
1678
|
+
type: 'tool-input-end';
|
1679
|
+
id: string;
|
1764
1680
|
providerMetadata?: ProviderMetadata;
|
1765
1681
|
} | ({
|
1766
1682
|
type: 'source';
|
@@ -1773,695 +1689,910 @@ type ContentPart<TOOLS extends ToolSet> = {
|
|
1773
1689
|
type: 'tool-result';
|
1774
1690
|
} & ToolResultUnion<TOOLS>) | ({
|
1775
1691
|
type: 'tool-error';
|
1776
|
-
} & ToolErrorUnion<TOOLS>)
|
1692
|
+
} & ToolErrorUnion<TOOLS>) | {
|
1693
|
+
type: 'file';
|
1694
|
+
file: GeneratedFile;
|
1695
|
+
} | {
|
1696
|
+
type: 'stream-start';
|
1697
|
+
warnings: LanguageModelV2CallWarning[];
|
1698
|
+
} | {
|
1699
|
+
type: 'response-metadata';
|
1700
|
+
id?: string;
|
1701
|
+
timestamp?: Date;
|
1702
|
+
modelId?: string;
|
1703
|
+
} | {
|
1704
|
+
type: 'finish';
|
1705
|
+
finishReason: FinishReason;
|
1706
|
+
usage: LanguageModelUsage;
|
1707
|
+
providerMetadata?: ProviderMetadata;
|
1708
|
+
} | {
|
1709
|
+
type: 'error';
|
1710
|
+
error: unknown;
|
1711
|
+
} | {
|
1712
|
+
type: 'raw';
|
1713
|
+
rawValue: unknown;
|
1714
|
+
};
|
1715
|
+
|
1716
|
+
declare const symbol$b: unique symbol;
|
1717
|
+
declare class InvalidStreamPartError extends AISDKError {
|
1718
|
+
private readonly [symbol$b];
|
1719
|
+
readonly chunk: SingleRequestTextStreamPart<any>;
|
1720
|
+
constructor({ chunk, message, }: {
|
1721
|
+
chunk: SingleRequestTextStreamPart<any>;
|
1722
|
+
message: string;
|
1723
|
+
});
|
1724
|
+
static isInstance(error: unknown): error is InvalidStreamPartError;
|
1725
|
+
}
|
1777
1726
|
|
1727
|
+
declare const symbol$a: unique symbol;
|
1778
1728
|
/**
|
1779
|
-
|
1780
|
-
It can be either an assistant message or a tool message.
|
1729
|
+
* An error occurred with the MCP client.
|
1781
1730
|
*/
|
1782
|
-
|
1731
|
+
declare class MCPClientError extends AISDKError {
|
1732
|
+
private readonly [symbol$a];
|
1733
|
+
constructor({ name, message, cause, }: {
|
1734
|
+
name?: string;
|
1735
|
+
message: string;
|
1736
|
+
cause?: unknown;
|
1737
|
+
});
|
1738
|
+
static isInstance(error: unknown): error is MCPClientError;
|
1739
|
+
}
|
1783
1740
|
|
1741
|
+
declare const symbol$9: unique symbol;
|
1784
1742
|
/**
|
1785
|
-
|
1743
|
+
Thrown when no image could be generated. This can have multiple causes:
|
1744
|
+
|
1745
|
+
- The model failed to generate a response.
|
1746
|
+
- The model generated a response that could not be parsed.
|
1786
1747
|
*/
|
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
|
-
};
|
1748
|
+
declare class NoImageGeneratedError extends AISDKError {
|
1749
|
+
private readonly [symbol$9];
|
1851
1750
|
/**
|
1852
|
-
|
1853
|
-
from the provider to the AI SDK and enable provider-specific
|
1854
|
-
results that can be fully encapsulated in the provider.
|
1751
|
+
The response metadata for each call.
|
1855
1752
|
*/
|
1856
|
-
readonly
|
1857
|
-
}
|
1753
|
+
readonly responses: Array<ImageModelResponseMetadata> | undefined;
|
1754
|
+
constructor({ message, cause, responses, }: {
|
1755
|
+
message?: string;
|
1756
|
+
cause?: Error;
|
1757
|
+
responses?: Array<ImageModelResponseMetadata>;
|
1758
|
+
});
|
1759
|
+
static isInstance(error: unknown): error is NoImageGeneratedError;
|
1760
|
+
}
|
1858
1761
|
|
1762
|
+
declare const symbol$8: unique symbol;
|
1859
1763
|
/**
|
1860
|
-
|
1861
|
-
|
1764
|
+
Thrown when no object could be generated. This can have several causes:
|
1765
|
+
|
1766
|
+
- The model failed to generate a response.
|
1767
|
+
- The model generated a response that could not be parsed.
|
1768
|
+
- The model generated a response that could not be validated against the schema.
|
1769
|
+
|
1770
|
+
The error contains the following properties:
|
1771
|
+
|
1772
|
+
- `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
1773
|
*/
|
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>;
|
1774
|
+
declare class NoObjectGeneratedError extends AISDKError {
|
1775
|
+
private readonly [symbol$8];
|
1890
1776
|
/**
|
1891
|
-
|
1777
|
+
The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
|
1892
1778
|
*/
|
1893
|
-
readonly
|
1779
|
+
readonly text: string | undefined;
|
1894
1780
|
/**
|
1895
|
-
|
1781
|
+
The response metadata.
|
1896
1782
|
*/
|
1897
|
-
readonly
|
1783
|
+
readonly response: LanguageModelResponseMetadata | undefined;
|
1898
1784
|
/**
|
1899
|
-
|
1785
|
+
The usage of the model.
|
1900
1786
|
*/
|
1901
|
-
readonly
|
1787
|
+
readonly usage: LanguageModelUsage | undefined;
|
1902
1788
|
/**
|
1903
|
-
|
1789
|
+
Reason why the model finished generating a response.
|
1904
1790
|
*/
|
1905
|
-
readonly
|
1791
|
+
readonly finishReason: FinishReason | undefined;
|
1792
|
+
constructor({ message, cause, text, response, usage, finishReason, }: {
|
1793
|
+
message?: string;
|
1794
|
+
cause?: Error;
|
1795
|
+
text?: string;
|
1796
|
+
response: LanguageModelResponseMetadata;
|
1797
|
+
usage: LanguageModelUsage;
|
1798
|
+
finishReason: FinishReason;
|
1799
|
+
});
|
1800
|
+
static isInstance(error: unknown): error is NoObjectGeneratedError;
|
1801
|
+
}
|
1802
|
+
|
1803
|
+
declare const symbol$7: unique symbol;
|
1804
|
+
/**
|
1805
|
+
Thrown when no output type is specified and output-related methods are called.
|
1806
|
+
*/
|
1807
|
+
declare class NoOutputSpecifiedError extends AISDKError {
|
1808
|
+
private readonly [symbol$7];
|
1809
|
+
constructor({ message }?: {
|
1810
|
+
message?: string;
|
1811
|
+
});
|
1812
|
+
static isInstance(error: unknown): error is NoOutputSpecifiedError;
|
1813
|
+
}
|
1814
|
+
|
1815
|
+
declare const symbol$6: unique symbol;
|
1816
|
+
declare class ToolCallRepairError extends AISDKError {
|
1817
|
+
private readonly [symbol$6];
|
1818
|
+
readonly originalError: NoSuchToolError | InvalidToolInputError;
|
1819
|
+
constructor({ cause, originalError, message, }: {
|
1820
|
+
message?: string;
|
1821
|
+
cause: unknown;
|
1822
|
+
originalError: NoSuchToolError | InvalidToolInputError;
|
1823
|
+
});
|
1824
|
+
static isInstance(error: unknown): error is ToolCallRepairError;
|
1825
|
+
}
|
1826
|
+
|
1827
|
+
declare const symbol$5: unique symbol;
|
1828
|
+
declare class InvalidDataContentError extends AISDKError {
|
1829
|
+
private readonly [symbol$5];
|
1830
|
+
readonly content: unknown;
|
1831
|
+
constructor({ content, cause, message, }: {
|
1832
|
+
content: unknown;
|
1833
|
+
cause?: unknown;
|
1834
|
+
message?: string;
|
1835
|
+
});
|
1836
|
+
static isInstance(error: unknown): error is InvalidDataContentError;
|
1837
|
+
}
|
1838
|
+
|
1839
|
+
declare const symbol$4: unique symbol;
|
1840
|
+
declare class InvalidMessageRoleError extends AISDKError {
|
1841
|
+
private readonly [symbol$4];
|
1842
|
+
readonly role: string;
|
1843
|
+
constructor({ role, message, }: {
|
1844
|
+
role: string;
|
1845
|
+
message?: string;
|
1846
|
+
});
|
1847
|
+
static isInstance(error: unknown): error is InvalidMessageRoleError;
|
1848
|
+
}
|
1849
|
+
|
1850
|
+
declare const symbol$3: unique symbol;
|
1851
|
+
declare class MessageConversionError extends AISDKError {
|
1852
|
+
private readonly [symbol$3];
|
1853
|
+
readonly originalMessage: Omit<UIMessage, 'id'>;
|
1854
|
+
constructor({ originalMessage, message, }: {
|
1855
|
+
originalMessage: Omit<UIMessage, 'id'>;
|
1856
|
+
message: string;
|
1857
|
+
});
|
1858
|
+
static isInstance(error: unknown): error is MessageConversionError;
|
1859
|
+
}
|
1860
|
+
|
1861
|
+
declare const symbol$2: unique symbol;
|
1862
|
+
declare class DownloadError extends AISDKError {
|
1863
|
+
private readonly [symbol$2];
|
1864
|
+
readonly url: string;
|
1865
|
+
readonly statusCode?: number;
|
1866
|
+
readonly statusText?: string;
|
1867
|
+
constructor({ url, statusCode, statusText, cause, message, }: {
|
1868
|
+
url: string;
|
1869
|
+
statusCode?: number;
|
1870
|
+
statusText?: string;
|
1871
|
+
message?: string;
|
1872
|
+
cause?: unknown;
|
1873
|
+
});
|
1874
|
+
static isInstance(error: unknown): error is DownloadError;
|
1875
|
+
}
|
1876
|
+
|
1877
|
+
declare const symbol$1: unique symbol;
|
1878
|
+
type RetryErrorReason = 'maxRetriesExceeded' | 'errorNotRetryable' | 'abort';
|
1879
|
+
declare class RetryError extends AISDKError {
|
1880
|
+
private readonly [symbol$1];
|
1881
|
+
readonly reason: RetryErrorReason;
|
1882
|
+
readonly lastError: unknown;
|
1883
|
+
readonly errors: Array<unknown>;
|
1884
|
+
constructor({ message, reason, errors, }: {
|
1885
|
+
message: string;
|
1886
|
+
reason: RetryErrorReason;
|
1887
|
+
errors: Array<unknown>;
|
1888
|
+
});
|
1889
|
+
static isInstance(error: unknown): error is RetryError;
|
1890
|
+
}
|
1891
|
+
|
1892
|
+
declare function createTextStreamResponse({ status, statusText, headers, textStream, }: ResponseInit & {
|
1893
|
+
textStream: ReadableStream<string>;
|
1894
|
+
}): Response;
|
1895
|
+
|
1896
|
+
declare function pipeTextStreamToResponse({ response, status, statusText, headers, textStream, }: {
|
1897
|
+
response: ServerResponse;
|
1898
|
+
textStream: ReadableStream<string>;
|
1899
|
+
} & ResponseInit): void;
|
1900
|
+
|
1901
|
+
declare const getOriginalFetch: () => typeof fetch;
|
1902
|
+
declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
|
1903
|
+
api: string;
|
1904
|
+
prompt: string;
|
1905
|
+
credentials: RequestCredentials | undefined;
|
1906
|
+
headers: HeadersInit | undefined;
|
1907
|
+
body: Record<string, any>;
|
1908
|
+
streamProtocol: 'data' | 'text' | undefined;
|
1909
|
+
setCompletion: (completion: string) => void;
|
1910
|
+
setLoading: (loading: boolean) => void;
|
1911
|
+
setError: (error: Error | undefined) => void;
|
1912
|
+
setAbortController: (abortController: AbortController | null) => void;
|
1913
|
+
onFinish: ((prompt: string, completion: string) => void) | undefined;
|
1914
|
+
onError: ((error: Error) => void) | undefined;
|
1915
|
+
fetch: ReturnType<typeof getOriginalFetch> | undefined;
|
1916
|
+
}): Promise<string | null | undefined>;
|
1917
|
+
|
1918
|
+
interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
1906
1919
|
/**
|
1907
|
-
|
1908
|
-
When there are multiple steps, the usage is the sum of all step usages.
|
1920
|
+
* Appends a data stream part to the stream.
|
1909
1921
|
*/
|
1910
|
-
|
1922
|
+
write(part: InferUIMessageChunk<UI_MESSAGE>): void;
|
1911
1923
|
/**
|
1912
|
-
|
1924
|
+
* Merges the contents of another stream to this stream.
|
1913
1925
|
*/
|
1914
|
-
|
1926
|
+
merge(stream: ReadableStream<InferUIMessageChunk<UI_MESSAGE>>): void;
|
1915
1927
|
/**
|
1916
|
-
|
1928
|
+
* Error handler that is used by the data stream writer.
|
1929
|
+
* This is intended for forwarding when merging streams
|
1930
|
+
* to prevent duplicated error masking.
|
1917
1931
|
*/
|
1918
|
-
|
1932
|
+
onError: ErrorHandler | undefined;
|
1933
|
+
}
|
1934
|
+
|
1935
|
+
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, originalMessages, onFinish, generateId, }: {
|
1936
|
+
execute: (options: {
|
1937
|
+
writer: UIMessageStreamWriter<UI_MESSAGE>;
|
1938
|
+
}) => Promise<void> | void;
|
1939
|
+
onError?: (error: unknown) => string;
|
1919
1940
|
/**
|
1920
|
-
|
1941
|
+
* The original messages. If they are provided, persistence mode is assumed,
|
1942
|
+
* and a message ID is provided for the response message.
|
1921
1943
|
*/
|
1922
|
-
|
1944
|
+
originalMessages?: UI_MESSAGE[];
|
1945
|
+
onFinish?: (options: {
|
1923
1946
|
/**
|
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>;
|
1947
|
+
* The updates list of UI messages.
|
1948
|
+
*/
|
1949
|
+
messages: UI_MESSAGE[];
|
1932
1950
|
/**
|
1933
|
-
|
1951
|
+
* Indicates whether the response message is a continuation of the last original message,
|
1952
|
+
* or if a new message was created.
|
1934
1953
|
*/
|
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
|
-
}
|
1954
|
+
isContinuation: boolean;
|
1955
|
+
/**
|
1956
|
+
* The message that was sent to the client as a response
|
1957
|
+
* (including the original message if it was extended).
|
1958
|
+
*/
|
1959
|
+
responseMessage: UI_MESSAGE;
|
1960
|
+
}) => void;
|
1961
|
+
generateId?: IdGenerator;
|
1962
|
+
}): ReadableStream<InferUIMessageChunk<UI_MESSAGE>>;
|
1954
1963
|
|
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>>;
|
1964
|
+
declare function createUIMessageStreamResponse({ status, statusText, headers, stream, consumeSseStream, }: UIMessageStreamResponseInit & {
|
1965
|
+
stream: ReadableStream<UIMessageChunk>;
|
1966
|
+
}): Response;
|
1975
1967
|
|
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
|
-
};
|
1968
|
+
declare class JsonToSseTransformStream extends TransformStream<unknown, string> {
|
1969
|
+
constructor();
|
1985
1970
|
}
|
1986
1971
|
|
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>;
|
1972
|
+
declare function pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, consumeSseStream, }: {
|
1973
|
+
response: ServerResponse;
|
1974
|
+
stream: ReadableStream<UIMessageChunk>;
|
1975
|
+
} & UIMessageStreamResponseInit): void;
|
2015
1976
|
|
2016
1977
|
/**
|
2017
|
-
|
2018
|
-
|
2019
|
-
@param
|
1978
|
+
* Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
|
1979
|
+
*
|
1980
|
+
* @param options.message - The last assistant message to use as a starting point when the conversation is resumed. Otherwise undefined.
|
1981
|
+
* @param options.stream - The stream of `UIMessageChunk`s to read.
|
1982
|
+
*
|
1983
|
+
* @returns An `AsyncIterableStream` of `UIMessage`s. Each stream part is a different state of the same message
|
1984
|
+
* as it is being completed.
|
2020
1985
|
*/
|
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.
|
1986
|
+
declare function readUIMessageStream<UI_MESSAGE extends UIMessage>({ message, stream, }: {
|
1987
|
+
message?: UI_MESSAGE;
|
1988
|
+
stream: ReadableStream<UIMessageChunk>;
|
1989
|
+
}): AsyncIterableStream<UI_MESSAGE>;
|
2035
1990
|
|
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.
|
1991
|
+
declare const UI_MESSAGE_STREAM_HEADERS: {
|
1992
|
+
'content-type': string;
|
1993
|
+
'cache-control': string;
|
1994
|
+
connection: string;
|
1995
|
+
'x-vercel-ai-ui-message-stream': string;
|
1996
|
+
'x-accel-buffering': string;
|
1997
|
+
};
|
2062
1998
|
|
2063
|
-
|
1999
|
+
interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
2000
|
+
sendMessages: (options: {
|
2001
|
+
chatId: string;
|
2002
|
+
messages: UI_MESSAGE[];
|
2003
|
+
abortSignal: AbortSignal | undefined;
|
2004
|
+
} & {
|
2005
|
+
trigger: 'submit-user-message' | 'submit-tool-result' | 'regenerate-assistant-message';
|
2006
|
+
messageId: string | undefined;
|
2007
|
+
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
2008
|
+
reconnectToStream: (options: {
|
2009
|
+
chatId: string;
|
2010
|
+
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk> | null>;
|
2011
|
+
}
|
2064
2012
|
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2013
|
+
type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'role'> & {
|
2014
|
+
id?: UI_MESSAGE['id'];
|
2015
|
+
role?: UI_MESSAGE['role'];
|
2016
|
+
};
|
2017
|
+
type UIDataPartSchemas = Record<string, Validator<any> | StandardSchemaV1<any>>;
|
2018
|
+
type UIDataTypesToSchemas<T extends UIDataTypes> = {
|
2019
|
+
[K in keyof T]: Validator<T[K]> | StandardSchemaV1<T[K]>;
|
2020
|
+
};
|
2021
|
+
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
2022
|
+
[K in keyof T]: T[K] extends Validator<infer U> ? U : T[K] extends StandardSchemaV1<infer U> ? U : unknown;
|
2023
|
+
};
|
2024
|
+
type ChatRequestOptions = {
|
2025
|
+
/**
|
2026
|
+
Additional headers that should be to be passed to the API endpoint.
|
2027
|
+
*/
|
2028
|
+
headers?: Record<string, string> | Headers;
|
2069
2029
|
/**
|
2070
|
-
|
2030
|
+
Additional body JSON properties that should be sent to the API endpoint.
|
2071
2031
|
*/
|
2072
|
-
|
2032
|
+
body?: object;
|
2033
|
+
metadata?: unknown;
|
2034
|
+
};
|
2035
|
+
type ChatStatus = 'submitted' | 'streaming' | 'ready' | 'error';
|
2036
|
+
interface ChatState<UI_MESSAGE extends UIMessage> {
|
2037
|
+
status: ChatStatus;
|
2038
|
+
error: Error | undefined;
|
2039
|
+
messages: UI_MESSAGE[];
|
2040
|
+
pushMessage: (message: UI_MESSAGE) => void;
|
2041
|
+
popMessage: () => void;
|
2042
|
+
replaceMessage: (index: number, message: UI_MESSAGE) => void;
|
2043
|
+
snapshot: <T>(thing: T) => T;
|
2044
|
+
}
|
2045
|
+
type ChatOnErrorCallback = (error: Error) => void;
|
2046
|
+
type ChatOnToolCallCallback = ({ toolCall, }: {
|
2047
|
+
toolCall: ToolCall<string, unknown>;
|
2048
|
+
}) => void | Promise<unknown> | unknown;
|
2049
|
+
type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<InferUIMessageData<UI_MESSAGE>>) => void;
|
2050
|
+
type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
2051
|
+
message: UI_MESSAGE;
|
2052
|
+
}) => void;
|
2053
|
+
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
2073
2054
|
/**
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2055
|
+
* A unique identifier for the chat. If not provided, a random one will be
|
2056
|
+
* generated.
|
2057
|
+
*/
|
2058
|
+
id?: string;
|
2059
|
+
messageMetadataSchema?: Validator<InferUIMessageMetadata<UI_MESSAGE>> | StandardSchemaV1<InferUIMessageMetadata<UI_MESSAGE>>;
|
2060
|
+
dataPartSchemas?: UIDataTypesToSchemas<InferUIMessageData<UI_MESSAGE>>;
|
2061
|
+
messages?: UI_MESSAGE[];
|
2077
2062
|
/**
|
2078
|
-
|
2063
|
+
* A way to provide a function that is going to be used for ids for messages and the chat.
|
2064
|
+
* If not provided the default AI SDK `generateId` is used.
|
2079
2065
|
*/
|
2080
|
-
|
2066
|
+
generateId?: IdGenerator;
|
2067
|
+
transport?: ChatTransport<UI_MESSAGE>;
|
2068
|
+
maxSteps?: number;
|
2081
2069
|
/**
|
2082
|
-
|
2083
|
-
When the condition is an array, any of the conditions can be met to stop the generation.
|
2084
|
-
|
2085
|
-
@default stepCountIs(1)
|
2070
|
+
* Callback function to be called when an error is encountered.
|
2086
2071
|
*/
|
2087
|
-
|
2072
|
+
onError?: ChatOnErrorCallback;
|
2088
2073
|
/**
|
2089
|
-
Optional
|
2074
|
+
Optional callback function that is invoked when a tool call is received.
|
2075
|
+
Intended for automatic client-side tool execution.
|
2076
|
+
|
2077
|
+
You can optionally return a result for the tool call,
|
2078
|
+
either synchronously or asynchronously.
|
2079
|
+
*/
|
2080
|
+
onToolCall?: ChatOnToolCallCallback;
|
2081
|
+
/**
|
2082
|
+
* Optional callback function that is called when the assistant message is finished streaming.
|
2083
|
+
*
|
2084
|
+
* @param message The message that was streamed.
|
2090
2085
|
*/
|
2091
|
-
|
2086
|
+
onFinish?: ChatOnFinishCallback<UI_MESSAGE>;
|
2092
2087
|
/**
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2088
|
+
* Optional callback function that is called when a data part is received.
|
2089
|
+
*
|
2090
|
+
* @param data The data part that was received.
|
2091
|
+
*/
|
2092
|
+
onData?: ChatOnDataCallback<UI_MESSAGE>;
|
2093
|
+
}
|
2094
|
+
declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
2095
|
+
readonly id: string;
|
2096
|
+
readonly generateId: IdGenerator;
|
2097
|
+
protected state: ChatState<UI_MESSAGE>;
|
2098
|
+
private messageMetadataSchema;
|
2099
|
+
private dataPartSchemas;
|
2100
|
+
private readonly transport;
|
2101
|
+
private maxSteps;
|
2102
|
+
private onError?;
|
2103
|
+
private onToolCall?;
|
2104
|
+
private onFinish?;
|
2105
|
+
private onData?;
|
2106
|
+
private activeResponse;
|
2107
|
+
private jobExecutor;
|
2108
|
+
constructor({ generateId, id, transport, maxSteps, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, onData, }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
2109
|
+
state: ChatState<UI_MESSAGE>;
|
2110
|
+
});
|
2098
2111
|
/**
|
2099
|
-
*
|
2112
|
+
* Hook status:
|
2113
|
+
*
|
2114
|
+
* - `submitted`: The message has been sent to the API and we're awaiting the start of the response stream.
|
2115
|
+
* - `streaming`: The response is actively streaming in from the API, receiving chunks of data.
|
2116
|
+
* - `ready`: The full response has been received and processed; a new user message can be submitted.
|
2117
|
+
* - `error`: An error occurred during the API request, preventing successful completion.
|
2100
2118
|
*/
|
2101
|
-
|
2119
|
+
get status(): ChatStatus;
|
2120
|
+
protected setStatus({ status, error, }: {
|
2121
|
+
status: ChatStatus;
|
2122
|
+
error?: Error;
|
2123
|
+
}): void;
|
2124
|
+
get error(): Error | undefined;
|
2125
|
+
get messages(): UI_MESSAGE[];
|
2126
|
+
get lastMessage(): UI_MESSAGE | undefined;
|
2127
|
+
set messages(messages: UI_MESSAGE[]);
|
2102
2128
|
/**
|
2103
|
-
|
2104
|
-
|
2129
|
+
* Appends or replaces a user message to the chat list. This triggers the API call to fetch
|
2130
|
+
* the assistant's response.
|
2131
|
+
*
|
2132
|
+
* If a messageId is provided, the message will be replaced.
|
2105
2133
|
*/
|
2106
|
-
|
2134
|
+
sendMessage: (message: (CreateUIMessage<UI_MESSAGE> & {
|
2135
|
+
text?: never;
|
2136
|
+
files?: never;
|
2137
|
+
messageId?: string;
|
2138
|
+
}) | {
|
2139
|
+
text: string;
|
2140
|
+
files?: FileList | FileUIPart[];
|
2141
|
+
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
2142
|
+
parts?: never;
|
2143
|
+
messageId?: string;
|
2144
|
+
} | {
|
2145
|
+
files: FileList | FileUIPart[];
|
2146
|
+
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
2147
|
+
parts?: never;
|
2148
|
+
messageId?: string;
|
2149
|
+
}, options?: ChatRequestOptions) => Promise<void>;
|
2107
2150
|
/**
|
2108
|
-
|
2151
|
+
* Regenerate the assistant message with the provided message id.
|
2152
|
+
* If no message id is provided, the last assistant message will be regenerated.
|
2109
2153
|
*/
|
2110
|
-
|
2154
|
+
regenerate: ({ messageId, ...options }?: {
|
2155
|
+
messageId?: string;
|
2156
|
+
} & ChatRequestOptions) => Promise<void>;
|
2111
2157
|
/**
|
2112
|
-
*
|
2158
|
+
* Attempt to resume an ongoing streaming response.
|
2113
2159
|
*/
|
2114
|
-
|
2160
|
+
resumeStream: (options?: ChatRequestOptions) => Promise<void>;
|
2161
|
+
addToolResult: ({ toolCallId, output, }: {
|
2162
|
+
toolCallId: string;
|
2163
|
+
output: unknown;
|
2164
|
+
}) => Promise<void>;
|
2115
2165
|
/**
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2166
|
+
* Abort the current request immediately, keep the generated tokens if any.
|
2167
|
+
*/
|
2168
|
+
stop: () => Promise<void>;
|
2169
|
+
private makeRequest;
|
2170
|
+
}
|
2171
|
+
|
2172
|
+
declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
2173
|
+
|
2174
|
+
/**
|
2175
|
+
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2176
|
+
with the AI core functions (e.g. `streamText`).
|
2177
|
+
|
2178
|
+
@param messages - The messages to convert.
|
2179
|
+
@param options.tools - The tools to use.
|
2180
|
+
@param options.ignoreIncompleteToolCalls - Whether to ignore incomplete tool calls. Default is `false`.
|
2181
|
+
*/
|
2182
|
+
declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
|
2183
|
+
tools?: ToolSet;
|
2184
|
+
ignoreIncompleteToolCalls?: boolean;
|
2185
|
+
}): ModelMessage[];
|
2186
|
+
/**
|
2187
|
+
@deprecated Use `convertToModelMessages` instead.
|
2188
|
+
*/
|
2189
|
+
declare const convertToCoreMessages: typeof convertToModelMessages;
|
2190
|
+
|
2191
|
+
type PrepareSendMessagesRequest<UI_MESSAGE extends UIMessage> = (options: {
|
2192
|
+
id: string;
|
2193
|
+
messages: UI_MESSAGE[];
|
2194
|
+
requestMetadata: unknown;
|
2195
|
+
body: Record<string, any> | undefined;
|
2196
|
+
credentials: RequestCredentials | undefined;
|
2197
|
+
headers: HeadersInit | undefined;
|
2198
|
+
api: string;
|
2199
|
+
} & {
|
2200
|
+
trigger: 'submit-user-message' | 'submit-tool-result' | 'regenerate-assistant-message';
|
2201
|
+
messageId: string | undefined;
|
2202
|
+
}) => {
|
2203
|
+
body: object;
|
2204
|
+
headers?: HeadersInit;
|
2205
|
+
credentials?: RequestCredentials;
|
2206
|
+
api?: string;
|
2207
|
+
} | PromiseLike<{
|
2208
|
+
body: object;
|
2209
|
+
headers?: HeadersInit;
|
2210
|
+
credentials?: RequestCredentials;
|
2211
|
+
api?: string;
|
2212
|
+
}>;
|
2213
|
+
type PrepareReconnectToStreamRequest = (options: {
|
2214
|
+
id: string;
|
2215
|
+
requestMetadata: unknown;
|
2216
|
+
body: Record<string, any> | undefined;
|
2217
|
+
credentials: RequestCredentials | undefined;
|
2218
|
+
headers: HeadersInit | undefined;
|
2219
|
+
api: string;
|
2220
|
+
}) => {
|
2221
|
+
headers?: HeadersInit;
|
2222
|
+
credentials?: RequestCredentials;
|
2223
|
+
api?: string;
|
2224
|
+
} | PromiseLike<{
|
2225
|
+
headers?: HeadersInit;
|
2226
|
+
credentials?: RequestCredentials;
|
2227
|
+
api?: string;
|
2228
|
+
}>;
|
2229
|
+
type HttpChatTransportInitOptions<UI_MESSAGE extends UIMessage> = {
|
2230
|
+
api?: string;
|
2119
2231
|
/**
|
2120
|
-
|
2232
|
+
* The credentials mode to be used for the fetch request.
|
2233
|
+
* Possible values are: 'omit', 'same-origin', 'include'.
|
2234
|
+
* Defaults to 'same-origin'.
|
2121
2235
|
*/
|
2122
|
-
|
2236
|
+
credentials?: RequestCredentials;
|
2123
2237
|
/**
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2238
|
+
* HTTP headers to be sent with the API request.
|
2239
|
+
*/
|
2240
|
+
headers?: Record<string, string> | Headers;
|
2127
2241
|
/**
|
2128
|
-
*
|
2242
|
+
* Extra body object to be sent with the API request.
|
2243
|
+
* @example
|
2244
|
+
* Send a `sessionId` to the API along with the messages.
|
2245
|
+
* ```js
|
2246
|
+
* useChat({
|
2247
|
+
* body: {
|
2248
|
+
* sessionId: '123',
|
2249
|
+
* }
|
2250
|
+
* })
|
2251
|
+
* ```
|
2129
2252
|
*/
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2253
|
+
body?: object;
|
2254
|
+
/**
|
2255
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
2256
|
+
or to provide a custom fetch implementation for e.g. testing.
|
2257
|
+
*/
|
2258
|
+
fetch?: FetchFunction;
|
2259
|
+
/**
|
2260
|
+
* When a function is provided, it will be used
|
2261
|
+
* to prepare the request body for the chat API. This can be useful for
|
2262
|
+
* customizing the request body based on the messages and data in the chat.
|
2263
|
+
*
|
2264
|
+
* @param id The id of the chat.
|
2265
|
+
* @param messages The current messages in the chat.
|
2266
|
+
* @param requestBody The request body object passed in the chat request.
|
2267
|
+
*/
|
2268
|
+
prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
2269
|
+
prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
2270
|
+
};
|
2271
|
+
declare abstract class HttpChatTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
|
2272
|
+
protected api: string;
|
2273
|
+
protected credentials?: RequestCredentials;
|
2274
|
+
protected headers?: Record<string, string> | Headers;
|
2275
|
+
protected body?: object;
|
2276
|
+
protected fetch?: FetchFunction;
|
2277
|
+
protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
2278
|
+
protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
2279
|
+
constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest, }: HttpChatTransportInitOptions<UI_MESSAGE>);
|
2280
|
+
sendMessages({ abortSignal, ...options }: Parameters<ChatTransport<UI_MESSAGE>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
2281
|
+
reconnectToStream(options: Parameters<ChatTransport<UI_MESSAGE>['reconnectToStream']>[0]): Promise<ReadableStream<UIMessageChunk> | null>;
|
2282
|
+
protected abstract processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
2283
|
+
}
|
2135
2284
|
|
2136
|
-
|
2285
|
+
declare class DefaultChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
|
2286
|
+
constructor(options?: HttpChatTransportInitOptions<UI_MESSAGE>);
|
2287
|
+
protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
2288
|
+
}
|
2289
|
+
|
2290
|
+
declare class TextStreamChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
|
2291
|
+
constructor(options?: HttpChatTransportInitOptions<UI_MESSAGE>);
|
2292
|
+
protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
2293
|
+
}
|
2137
2294
|
|
2138
|
-
type
|
2295
|
+
type CompletionRequestOptions = {
|
2139
2296
|
/**
|
2140
|
-
|
2141
|
-
* and a message ID is provided for the response message.
|
2297
|
+
An optional object of headers to be passed to the API endpoint.
|
2142
2298
|
*/
|
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;
|
2299
|
+
headers?: Record<string, string> | Headers;
|
2160
2300
|
/**
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
part: TextStreamPart<ToolSet>;
|
2167
|
-
}) => InferUIMessageMetadata<UI_MESSAGE> | undefined;
|
2301
|
+
An optional object to be passed to the API endpoint.
|
2302
|
+
*/
|
2303
|
+
body?: object;
|
2304
|
+
};
|
2305
|
+
type UseCompletionOptions = {
|
2168
2306
|
/**
|
2169
|
-
*
|
2170
|
-
*
|
2307
|
+
* The API endpoint that accepts a `{ prompt: string }` object and returns
|
2308
|
+
* a stream of tokens of the AI completion response. Defaults to `/api/completion`.
|
2171
2309
|
*/
|
2172
|
-
|
2310
|
+
api?: string;
|
2173
2311
|
/**
|
2174
|
-
*
|
2175
|
-
*
|
2312
|
+
* An unique identifier for the chat. If not provided, a random one will be
|
2313
|
+
* generated. When provided, the `useChat` hook with the same `id` will
|
2314
|
+
* have shared states across components.
|
2176
2315
|
*/
|
2177
|
-
|
2316
|
+
id?: string;
|
2178
2317
|
/**
|
2179
|
-
*
|
2180
|
-
* Set to false if you are using additional streamText calls
|
2181
|
-
* that send additional data.
|
2182
|
-
* Default to true.
|
2318
|
+
* Initial prompt input of the completion.
|
2183
2319
|
*/
|
2184
|
-
|
2320
|
+
initialInput?: string;
|
2185
2321
|
/**
|
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.
|
2322
|
+
* Initial completion result. Useful to load an existing history.
|
2195
2323
|
*/
|
2196
|
-
|
2324
|
+
initialCompletion?: string;
|
2197
2325
|
/**
|
2198
|
-
*
|
2199
|
-
*
|
2200
|
-
* @return error message to include in the data stream.
|
2326
|
+
* Callback function to be called when the completion is finished streaming.
|
2201
2327
|
*/
|
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> {
|
2328
|
+
onFinish?: (prompt: string, completion: string) => void;
|
2211
2329
|
/**
|
2212
|
-
|
2213
|
-
|
2214
|
-
Resolved when the response is finished.
|
2330
|
+
* Callback function to be called when an error is encountered.
|
2215
2331
|
*/
|
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>;
|
2332
|
+
onError?: (error: Error) => void;
|
2223
2333
|
/**
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2334
|
+
* The credentials mode to be used for the fetch request.
|
2335
|
+
* Possible values are: 'omit', 'same-origin', 'include'.
|
2336
|
+
* Defaults to 'same-origin'.
|
2227
2337
|
*/
|
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>;
|
2338
|
+
credentials?: RequestCredentials;
|
2235
2339
|
/**
|
2236
|
-
|
2237
|
-
|
2238
|
-
Resolved when the response is finished.
|
2340
|
+
* HTTP headers to be sent with the API request.
|
2239
2341
|
*/
|
2240
|
-
|
2342
|
+
headers?: Record<string, string> | Headers;
|
2241
2343
|
/**
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2344
|
+
* Extra body object to be sent with the API request.
|
2345
|
+
* @example
|
2346
|
+
* Send a `sessionId` to the API along with the prompt.
|
2347
|
+
* ```js
|
2348
|
+
* useChat({
|
2349
|
+
* body: {
|
2350
|
+
* sessionId: '123',
|
2351
|
+
* }
|
2352
|
+
* })
|
2353
|
+
* ```
|
2245
2354
|
*/
|
2246
|
-
|
2355
|
+
body?: object;
|
2247
2356
|
/**
|
2248
|
-
|
2249
|
-
|
2250
|
-
Resolved when the response is finished.
|
2357
|
+
Streaming protocol that is used. Defaults to `data`.
|
2251
2358
|
*/
|
2252
|
-
|
2359
|
+
streamProtocol?: 'data' | 'text';
|
2253
2360
|
/**
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2361
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
2362
|
+
or to provide a custom fetch implementation for e.g. testing.
|
2363
|
+
*/
|
2364
|
+
fetch?: FetchFunction;
|
2365
|
+
};
|
2366
|
+
|
2367
|
+
/**
|
2368
|
+
* Calculates the cosine similarity between two vectors. This is a useful metric for
|
2369
|
+
* comparing the similarity of two vectors such as embeddings.
|
2370
|
+
*
|
2371
|
+
* @param vector1 - The first vector.
|
2372
|
+
* @param vector2 - The second vector.
|
2373
|
+
*
|
2374
|
+
* @returns The cosine similarity between vector1 and vector2.
|
2375
|
+
* @returns 0 if either vector is the zero vector.
|
2376
|
+
*
|
2377
|
+
* @throws {InvalidArgumentError} If the vectors do not have the same length.
|
2378
|
+
*/
|
2379
|
+
declare function cosineSimilarity(vector1: number[], vector2: number[]): number;
|
2380
|
+
|
2381
|
+
/**
|
2382
|
+
* Converts a data URL of type text/* to a text string.
|
2383
|
+
*/
|
2384
|
+
declare function getTextFromDataUrl(dataUrl: string): string;
|
2385
|
+
|
2386
|
+
/**
|
2387
|
+
* Performs a deep-equal comparison of two parsed JSON objects.
|
2388
|
+
*
|
2389
|
+
* @param {any} obj1 - The first object to compare.
|
2390
|
+
* @param {any} obj2 - The second object to compare.
|
2391
|
+
* @returns {boolean} - Returns true if the two objects are deeply equal, false otherwise.
|
2392
|
+
*/
|
2393
|
+
declare function isDeepEqualData(obj1: any, obj2: any): boolean;
|
2394
|
+
|
2395
|
+
declare function parsePartialJson(jsonText: string | undefined): Promise<{
|
2396
|
+
value: JSONValue$1 | undefined;
|
2397
|
+
state: 'undefined-input' | 'successful-parse' | 'repaired-parse' | 'failed-parse';
|
2398
|
+
}>;
|
2399
|
+
|
2400
|
+
type Job = () => Promise<void>;
|
2401
|
+
|
2402
|
+
declare class SerialJobExecutor {
|
2403
|
+
private queue;
|
2404
|
+
private isProcessing;
|
2405
|
+
private processQueue;
|
2406
|
+
run(job: Job): Promise<void>;
|
2407
|
+
}
|
2408
|
+
|
2409
|
+
/**
|
2410
|
+
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
2411
|
+
*
|
2412
|
+
* @param options - The configuration options
|
2413
|
+
* @param options.chunks - Array of values to be emitted by the stream
|
2414
|
+
* @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.
|
2415
|
+
* @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.
|
2416
|
+
* @returns A ReadableStream that emits the provided values
|
2417
|
+
*/
|
2418
|
+
declare function simulateReadableStream<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal, }: {
|
2419
|
+
chunks: T[];
|
2420
|
+
initialDelayInMs?: number | null;
|
2421
|
+
chunkDelayInMs?: number | null;
|
2422
|
+
_internal?: {
|
2423
|
+
delay?: (ms: number | null) => Promise<void>;
|
2424
|
+
};
|
2425
|
+
}): ReadableStream<T>;
|
2426
|
+
|
2427
|
+
/**
|
2428
|
+
The result of an `embed` call.
|
2429
|
+
It contains the embedding, the value, and additional information.
|
2430
|
+
*/
|
2431
|
+
interface EmbedResult<VALUE> {
|
2259
2432
|
/**
|
2260
|
-
|
2261
|
-
|
2262
|
-
Resolved when the response is finished.
|
2433
|
+
The value that was embedded.
|
2263
2434
|
*/
|
2264
|
-
readonly
|
2435
|
+
readonly value: VALUE;
|
2265
2436
|
/**
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
*/
|
2270
|
-
readonly usage: Promise<LanguageModelUsage>;
|
2437
|
+
The embedding of the value.
|
2438
|
+
*/
|
2439
|
+
readonly embedding: Embedding;
|
2271
2440
|
/**
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2441
|
+
The embedding token usage.
|
2442
|
+
*/
|
2443
|
+
readonly usage: EmbeddingModelUsage;
|
2444
|
+
/**
|
2445
|
+
Optional response data.
|
2276
2446
|
*/
|
2277
|
-
readonly
|
2447
|
+
readonly response?: {
|
2448
|
+
/**
|
2449
|
+
Response headers.
|
2450
|
+
*/
|
2451
|
+
headers?: Record<string, string>;
|
2452
|
+
/**
|
2453
|
+
The response body.
|
2454
|
+
*/
|
2455
|
+
body?: unknown;
|
2456
|
+
};
|
2457
|
+
}
|
2458
|
+
|
2459
|
+
/**
|
2460
|
+
Embed a value using an embedding model. The type of the value is defined by the embedding model.
|
2461
|
+
|
2462
|
+
@param model - The embedding model to use.
|
2463
|
+
@param value - The value that should be embedded.
|
2464
|
+
|
2465
|
+
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
2466
|
+
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
2467
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
2468
|
+
|
2469
|
+
@returns A result object that contains the embedding, the value, and additional information.
|
2470
|
+
*/
|
2471
|
+
declare function embed<VALUE>({ model, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
|
2278
2472
|
/**
|
2279
|
-
|
2473
|
+
The embedding model to use.
|
2280
2474
|
*/
|
2281
|
-
|
2475
|
+
model: EmbeddingModel<VALUE>;
|
2282
2476
|
/**
|
2283
|
-
|
2284
|
-
You can use this to get information about intermediate steps,
|
2285
|
-
such as the tool calls or the response headers.
|
2477
|
+
The value that should be embedded.
|
2286
2478
|
*/
|
2287
|
-
|
2479
|
+
value: VALUE;
|
2288
2480
|
/**
|
2289
|
-
|
2481
|
+
Maximum number of retries per embedding model call. Set to 0 to disable retries.
|
2482
|
+
|
2483
|
+
@default 2
|
2484
|
+
*/
|
2485
|
+
maxRetries?: number;
|
2486
|
+
/**
|
2487
|
+
Abort signal.
|
2290
2488
|
*/
|
2291
|
-
|
2489
|
+
abortSignal?: AbortSignal;
|
2292
2490
|
/**
|
2293
|
-
Additional
|
2491
|
+
Additional headers to include in the request.
|
2492
|
+
Only applicable for HTTP-based providers.
|
2294
2493
|
*/
|
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
|
-
}>;
|
2494
|
+
headers?: Record<string, string>;
|
2306
2495
|
/**
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2496
|
+
Additional provider-specific options. They are passed through
|
2497
|
+
to the provider from the AI SDK and enable provider-specific
|
2498
|
+
functionality that can be fully encapsulated in the provider.
|
2499
|
+
*/
|
2500
|
+
providerOptions?: ProviderOptions;
|
2312
2501
|
/**
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2502
|
+
* Optional telemetry configuration (experimental).
|
2503
|
+
*/
|
2504
|
+
experimental_telemetry?: TelemetrySettings;
|
2505
|
+
}): Promise<EmbedResult<VALUE>>;
|
2506
|
+
|
2507
|
+
/**
|
2508
|
+
The result of a `embedMany` call.
|
2509
|
+
It contains the embeddings, the values, and additional information.
|
2510
|
+
*/
|
2511
|
+
interface EmbedManyResult<VALUE> {
|
2318
2512
|
/**
|
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.
|
2513
|
+
The values that were embedded.
|
2323
2514
|
*/
|
2324
|
-
readonly
|
2515
|
+
readonly values: Array<VALUE>;
|
2325
2516
|
/**
|
2326
|
-
|
2327
|
-
|
2328
|
-
readonly
|
2517
|
+
The embeddings. They are in the same order as the values.
|
2518
|
+
*/
|
2519
|
+
readonly embeddings: Array<Embedding>;
|
2329
2520
|
/**
|
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>;
|
2521
|
+
The embedding token usage.
|
2522
|
+
*/
|
2523
|
+
readonly usage: EmbeddingModelUsage;
|
2338
2524
|
/**
|
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.
|
2525
|
+
Optional raw response data.
|
2349
2526
|
*/
|
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.
|
2527
|
+
readonly responses?: Array<{
|
2528
|
+
/**
|
2529
|
+
Response headers.
|
2360
2530
|
*/
|
2361
|
-
|
2531
|
+
headers?: Record<string, string>;
|
2532
|
+
/**
|
2533
|
+
The response body.
|
2534
|
+
*/
|
2535
|
+
body?: unknown;
|
2536
|
+
} | undefined>;
|
2537
|
+
}
|
2538
|
+
|
2539
|
+
/**
|
2540
|
+
Embed several values using an embedding model. The type of the value is defined
|
2541
|
+
by the embedding model.
|
2542
|
+
|
2543
|
+
`embedMany` automatically splits large requests into smaller chunks if the model
|
2544
|
+
has a limit on how many embeddings can be generated in a single call.
|
2545
|
+
|
2546
|
+
@param model - The embedding model to use.
|
2547
|
+
@param values - The values that should be embedded.
|
2548
|
+
|
2549
|
+
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
2550
|
+
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
2551
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
2552
|
+
|
2553
|
+
@returns A result object that contains the embeddings, the value, and additional information.
|
2554
|
+
*/
|
2555
|
+
declare function embedMany<VALUE>({ model, values, maxParallelCalls, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
|
2362
2556
|
/**
|
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.
|
2557
|
+
The embedding model to use.
|
2368
2558
|
*/
|
2369
|
-
|
2559
|
+
model: EmbeddingModel<VALUE>;
|
2370
2560
|
/**
|
2371
|
-
|
2561
|
+
The values that should be embedded.
|
2562
|
+
*/
|
2563
|
+
values: Array<VALUE>;
|
2564
|
+
/**
|
2565
|
+
Maximum number of retries per embedding model call. Set to 0 to disable retries.
|
2372
2566
|
|
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;
|
2567
|
+
@default 2
|
2568
|
+
*/
|
2569
|
+
maxRetries?: number;
|
2382
2570
|
/**
|
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
|
-
};
|
2571
|
+
Abort signal.
|
2572
|
+
*/
|
2573
|
+
abortSignal?: AbortSignal;
|
2574
|
+
/**
|
2575
|
+
Additional headers to include in the request.
|
2576
|
+
Only applicable for HTTP-based providers.
|
2577
|
+
*/
|
2578
|
+
headers?: Record<string, string>;
|
2579
|
+
/**
|
2580
|
+
* Optional telemetry configuration (experimental).
|
2581
|
+
*/
|
2582
|
+
experimental_telemetry?: TelemetrySettings;
|
2583
|
+
/**
|
2584
|
+
Additional provider-specific options. They are passed through
|
2585
|
+
to the provider from the AI SDK and enable provider-specific
|
2586
|
+
functionality that can be fully encapsulated in the provider.
|
2587
|
+
*/
|
2588
|
+
providerOptions?: ProviderOptions;
|
2589
|
+
/**
|
2590
|
+
* Maximum number of concurrent requests.
|
2591
|
+
*
|
2592
|
+
* @default Infinity
|
2593
|
+
*/
|
2594
|
+
maxParallelCalls?: number;
|
2595
|
+
}): Promise<EmbedManyResult<VALUE>>;
|
2465
2596
|
|
2466
2597
|
/**
|
2467
2598
|
* Detects the first chunk in a buffer.
|
@@ -2919,7 +3050,7 @@ functionality that can be fully encapsulated in the provider.
|
|
2919
3050
|
@returns
|
2920
3051
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
2921
3052
|
*/
|
2922
|
-
declare function generateObject<SCHEMA extends z3.Schema | z4
|
3053
|
+
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
3054
|
/**
|
2924
3055
|
The enum values that the model should use.
|
2925
3056
|
*/
|
@@ -3176,7 +3307,7 @@ functionality that can be fully encapsulated in the provider.
|
|
3176
3307
|
@returns
|
3177
3308
|
A result object for accessing the partial object stream and additional information.
|
3178
3309
|
*/
|
3179
|
-
declare function streamObject<SCHEMA extends z3.Schema | z4
|
3310
|
+
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
3311
|
/**
|
3181
3312
|
The enum values that the model should use.
|
3182
3313
|
*/
|
@@ -3494,227 +3625,67 @@ declare const experimental_createProviderRegistry: typeof createProviderRegistry
|
|
3494
3625
|
|
3495
3626
|
declare const JSONRPCRequestSchema: z.ZodObject<{
|
3496
3627
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3497
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3498
|
-
} & {
|
3628
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3499
3629
|
method: z.ZodString;
|
3500
3630
|
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
|
-
}>;
|
3631
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3632
|
+
}, z.core.$loose>>;
|
3633
|
+
}, z.core.$strict>;
|
3522
3634
|
type JSONRPCRequest = z.infer<typeof JSONRPCRequestSchema>;
|
3523
3635
|
declare const JSONRPCResponseSchema: z.ZodObject<{
|
3524
3636
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3525
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3637
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3526
3638
|
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
|
-
}>;
|
3639
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3640
|
+
}, z.core.$loose>;
|
3641
|
+
}, z.core.$strict>;
|
3550
3642
|
type JSONRPCResponse = z.infer<typeof JSONRPCResponseSchema>;
|
3551
3643
|
declare const JSONRPCErrorSchema: z.ZodObject<{
|
3552
3644
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3553
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3645
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3554
3646
|
error: z.ZodObject<{
|
3555
3647
|
code: z.ZodNumber;
|
3556
3648
|
message: z.ZodString;
|
3557
3649
|
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
|
-
}>;
|
3650
|
+
}, z.core.$strip>;
|
3651
|
+
}, z.core.$strict>;
|
3584
3652
|
type JSONRPCError = z.infer<typeof JSONRPCErrorSchema>;
|
3585
3653
|
declare const JSONRPCNotificationSchema: z.ZodObject<{
|
3586
3654
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3587
|
-
} & {
|
3588
3655
|
method: z.ZodString;
|
3589
3656
|
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
|
-
}>;
|
3657
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3658
|
+
}, z.core.$loose>>;
|
3659
|
+
}, z.core.$strict>;
|
3609
3660
|
type JSONRPCNotification = z.infer<typeof JSONRPCNotificationSchema>;
|
3610
|
-
declare const JSONRPCMessageSchema: z.ZodUnion<[z.ZodObject<{
|
3661
|
+
declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
|
3611
3662
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3612
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3613
|
-
} & {
|
3663
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3614
3664
|
method: z.ZodString;
|
3615
3665
|
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<{
|
3666
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3667
|
+
}, z.core.$loose>>;
|
3668
|
+
}, z.core.$strict>, z.ZodObject<{
|
3637
3669
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3638
|
-
} & {
|
3639
3670
|
method: z.ZodString;
|
3640
3671
|
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<{
|
3672
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3673
|
+
}, z.core.$loose>>;
|
3674
|
+
}, z.core.$strict>, z.ZodObject<{
|
3660
3675
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3661
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3676
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3662
3677
|
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<{
|
3678
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3679
|
+
}, z.core.$loose>;
|
3680
|
+
}, z.core.$strict>, z.ZodObject<{
|
3686
3681
|
jsonrpc: z.ZodLiteral<"2.0">;
|
3687
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
3682
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
3688
3683
|
error: z.ZodObject<{
|
3689
3684
|
code: z.ZodNumber;
|
3690
3685
|
message: z.ZodString;
|
3691
3686
|
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
|
-
}>]>;
|
3687
|
+
}, z.core.$strip>;
|
3688
|
+
}, z.core.$strict>]>;
|
3718
3689
|
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
|
3719
3690
|
|
3720
3691
|
/**
|
@@ -3772,717 +3743,31 @@ type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS e
|
|
3772
3743
|
inputSchema: FlexibleSchema<unknown>;
|
3773
3744
|
}>>;
|
3774
3745
|
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<{
|
3746
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
3747
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
4250
3748
|
type: z.ZodLiteral<"text">;
|
4251
3749
|
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<{
|
3750
|
+
}, z.core.$loose>, z.ZodObject<{
|
4261
3751
|
type: z.ZodLiteral<"image">;
|
4262
3752
|
data: z.ZodString;
|
4263
3753
|
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<{
|
3754
|
+
}, z.core.$loose>, z.ZodObject<{
|
4403
3755
|
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
|
-
*/
|
3756
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
4430
3757
|
uri: z.ZodString;
|
4431
|
-
/**
|
4432
|
-
* The MIME type of this resource, if known.
|
4433
|
-
*/
|
4434
3758
|
mimeType: z.ZodOptional<z.ZodString>;
|
4435
|
-
} & {
|
4436
3759
|
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
|
-
*/
|
3760
|
+
}, z.core.$loose>, z.ZodObject<{
|
4452
3761
|
uri: z.ZodString;
|
4453
|
-
/**
|
4454
|
-
* The MIME type of this resource, if known.
|
4455
|
-
*/
|
4456
3762
|
mimeType: z.ZodOptional<z.ZodString>;
|
4457
|
-
} & {
|
4458
3763
|
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">;
|
3764
|
+
}, z.core.$loose>]>;
|
3765
|
+
}, z.core.$loose>]>>;
|
4472
3766
|
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
|
-
} & {
|
3767
|
+
}, z.core.$loose>, z.ZodObject<{
|
3768
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
4484
3769
|
toolResult: z.ZodUnknown;
|
4485
|
-
}, z.
|
3770
|
+
}, z.core.$loose>]>;
|
4486
3771
|
type CallToolResult = z.infer<typeof CallToolResultSchema>;
|
4487
3772
|
|
4488
3773
|
interface MCPClientConfig {
|
@@ -4648,4 +3933,4 @@ declare global {
|
|
4648
3933
|
var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
|
4649
3934
|
}
|
4650
3935
|
|
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,
|
3936
|
+
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 };
|