ai 0.0.0-8777c42a-20250115032312 → 0.0.0-9477ebb9-20250403064906
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 +660 -2
- package/README.md +19 -6
- package/dist/index.d.mts +3036 -1314
- package/dist/index.d.ts +3036 -1314
- package/dist/index.js +2705 -985
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2667 -962
- package/dist/index.mjs.map +1 -1
- package/mcp-stdio/create-child-process.test.ts +92 -0
- package/mcp-stdio/create-child-process.ts +21 -0
- package/mcp-stdio/dist/index.d.mts +169 -0
- package/mcp-stdio/dist/index.d.ts +169 -0
- package/mcp-stdio/dist/index.js +352 -0
- package/mcp-stdio/dist/index.js.map +1 -0
- package/mcp-stdio/dist/index.mjs +337 -0
- package/mcp-stdio/dist/index.mjs.map +1 -0
- package/mcp-stdio/get-environment.ts +43 -0
- package/mcp-stdio/index.ts +4 -0
- package/mcp-stdio/mcp-stdio-transport.test.ts +262 -0
- package/mcp-stdio/mcp-stdio-transport.ts +157 -0
- package/package.json +14 -10
- package/react/dist/index.d.mts +12 -4
- package/react/dist/index.d.ts +12 -4
- package/react/dist/index.js +0 -3
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +0 -3
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/index.d.ts +108 -18
- package/rsc/dist/rsc-server.d.mts +108 -18
- package/rsc/dist/rsc-server.mjs +550 -256
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.mjs +1 -3
- package/rsc/dist/rsc-shared.mjs.map +1 -1
- package/test/dist/index.d.mts +2 -4
- package/test/dist/index.d.ts +2 -4
- package/test/dist/index.js +4 -14
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +7 -14
- package/test/dist/index.mjs.map +1 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import { LanguageModelV1FinishReason, LanguageModelV1CallWarning, LanguageModelV1ProviderMetadata, LanguageModelV1 } from '@ai-sdk/provider';
|
2
2
|
import { ReactNode } from 'react';
|
3
3
|
import { z } from 'zod';
|
4
|
-
import {
|
4
|
+
import { Message } from '@ai-sdk/ui-utils';
|
5
5
|
|
6
6
|
type AIAction<T = any, R = any> = (...args: T[]) => Promise<R>;
|
7
7
|
type AIActions<T = any, R = any> = Record<string, AIAction<T, R>>;
|
@@ -197,17 +197,25 @@ Tool choice for the generation. It supports the following settings:
|
|
197
197
|
- `none`: the model must not call tools
|
198
198
|
- `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool
|
199
199
|
*/
|
200
|
-
type
|
200
|
+
type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'required' | {
|
201
201
|
type: 'tool';
|
202
202
|
toolName: keyof TOOLS;
|
203
203
|
};
|
204
204
|
|
205
205
|
/**
|
206
|
-
Additional provider-specific metadata
|
207
|
-
|
208
|
-
|
206
|
+
Additional provider-specific metadata that is returned from the provider.
|
207
|
+
|
208
|
+
This is needed to enable provider-specific functionality that can be
|
209
|
+
fully encapsulated in the provider.
|
209
210
|
*/
|
210
211
|
type ProviderMetadata = LanguageModelV1ProviderMetadata;
|
212
|
+
/**
|
213
|
+
Additional provider-specific options.
|
214
|
+
|
215
|
+
They are passed through to the provider from the AI SDK and enable
|
216
|
+
provider-specific functionality that can be fully encapsulated in the provider.
|
217
|
+
*/
|
218
|
+
type ProviderOptions = LanguageModelV1ProviderMetadata;
|
211
219
|
|
212
220
|
/**
|
213
221
|
Represents the number of tokens used in a prompt and completion.
|
@@ -254,6 +262,10 @@ interface TextPart {
|
|
254
262
|
Additional provider-specific metadata. They are passed through
|
255
263
|
to the provider from the AI SDK and enable provider-specific
|
256
264
|
functionality that can be fully encapsulated in the provider.
|
265
|
+
*/
|
266
|
+
providerOptions?: ProviderOptions;
|
267
|
+
/**
|
268
|
+
@deprecated Use `providerOptions` instead.
|
257
269
|
*/
|
258
270
|
experimental_providerMetadata?: ProviderMetadata;
|
259
271
|
}
|
@@ -277,6 +289,10 @@ interface ImagePart {
|
|
277
289
|
Additional provider-specific metadata. They are passed through
|
278
290
|
to the provider from the AI SDK and enable provider-specific
|
279
291
|
functionality that can be fully encapsulated in the provider.
|
292
|
+
*/
|
293
|
+
providerOptions?: ProviderOptions;
|
294
|
+
/**
|
295
|
+
@deprecated Use `providerOptions` instead.
|
280
296
|
*/
|
281
297
|
experimental_providerMetadata?: ProviderMetadata;
|
282
298
|
}
|
@@ -293,6 +309,10 @@ interface FilePart {
|
|
293
309
|
*/
|
294
310
|
data: DataContent | URL;
|
295
311
|
/**
|
312
|
+
Optional filename of the file.
|
313
|
+
*/
|
314
|
+
filename?: string;
|
315
|
+
/**
|
296
316
|
Mime type of the file.
|
297
317
|
*/
|
298
318
|
mimeType: string;
|
@@ -300,6 +320,54 @@ interface FilePart {
|
|
300
320
|
Additional provider-specific metadata. They are passed through
|
301
321
|
to the provider from the AI SDK and enable provider-specific
|
302
322
|
functionality that can be fully encapsulated in the provider.
|
323
|
+
*/
|
324
|
+
providerOptions?: ProviderOptions;
|
325
|
+
/**
|
326
|
+
@deprecated Use `providerOptions` instead.
|
327
|
+
*/
|
328
|
+
experimental_providerMetadata?: ProviderMetadata;
|
329
|
+
}
|
330
|
+
/**
|
331
|
+
* Reasoning content part of a prompt. It contains a reasoning.
|
332
|
+
*/
|
333
|
+
interface ReasoningPart {
|
334
|
+
type: 'reasoning';
|
335
|
+
/**
|
336
|
+
The reasoning text.
|
337
|
+
*/
|
338
|
+
text: string;
|
339
|
+
/**
|
340
|
+
An optional signature for verifying that the reasoning originated from the model.
|
341
|
+
*/
|
342
|
+
signature?: string;
|
343
|
+
/**
|
344
|
+
Additional provider-specific metadata. They are passed through
|
345
|
+
to the provider from the AI SDK and enable provider-specific
|
346
|
+
functionality that can be fully encapsulated in the provider.
|
347
|
+
*/
|
348
|
+
providerOptions?: ProviderOptions;
|
349
|
+
/**
|
350
|
+
@deprecated Use `providerOptions` instead.
|
351
|
+
*/
|
352
|
+
experimental_providerMetadata?: ProviderMetadata;
|
353
|
+
}
|
354
|
+
/**
|
355
|
+
Redacted reasoning content part of a prompt.
|
356
|
+
*/
|
357
|
+
interface RedactedReasoningPart {
|
358
|
+
type: 'redacted-reasoning';
|
359
|
+
/**
|
360
|
+
Redacted reasoning data.
|
361
|
+
*/
|
362
|
+
data: string;
|
363
|
+
/**
|
364
|
+
Additional provider-specific metadata. They are passed through
|
365
|
+
to the provider from the AI SDK and enable provider-specific
|
366
|
+
functionality that can be fully encapsulated in the provider.
|
367
|
+
*/
|
368
|
+
providerOptions?: ProviderOptions;
|
369
|
+
/**
|
370
|
+
@deprecated Use `providerOptions` instead.
|
303
371
|
*/
|
304
372
|
experimental_providerMetadata?: ProviderMetadata;
|
305
373
|
}
|
@@ -324,6 +392,10 @@ interface ToolCallPart {
|
|
324
392
|
Additional provider-specific metadata. They are passed through
|
325
393
|
to the provider from the AI SDK and enable provider-specific
|
326
394
|
functionality that can be fully encapsulated in the provider.
|
395
|
+
*/
|
396
|
+
providerOptions?: ProviderOptions;
|
397
|
+
/**
|
398
|
+
@deprecated Use `providerOptions` instead.
|
327
399
|
*/
|
328
400
|
experimental_providerMetadata?: ProviderMetadata;
|
329
401
|
}
|
@@ -356,6 +428,10 @@ interface ToolResultPart {
|
|
356
428
|
Additional provider-specific metadata. They are passed through
|
357
429
|
to the provider from the AI SDK and enable provider-specific
|
358
430
|
functionality that can be fully encapsulated in the provider.
|
431
|
+
*/
|
432
|
+
providerOptions?: ProviderOptions;
|
433
|
+
/**
|
434
|
+
@deprecated Use `providerOptions` instead.
|
359
435
|
*/
|
360
436
|
experimental_providerMetadata?: ProviderMetadata;
|
361
437
|
}
|
@@ -374,6 +450,10 @@ type CoreSystemMessage = {
|
|
374
450
|
Additional provider-specific metadata. They are passed through
|
375
451
|
to the provider from the AI SDK and enable provider-specific
|
376
452
|
functionality that can be fully encapsulated in the provider.
|
453
|
+
*/
|
454
|
+
providerOptions?: ProviderOptions;
|
455
|
+
/**
|
456
|
+
@deprecated Use `providerOptions` instead.
|
377
457
|
*/
|
378
458
|
experimental_providerMetadata?: ProviderMetadata;
|
379
459
|
};
|
@@ -388,6 +468,10 @@ type CoreUserMessage = {
|
|
388
468
|
to the provider from the AI SDK and enable provider-specific
|
389
469
|
functionality that can be fully encapsulated in the provider.
|
390
470
|
*/
|
471
|
+
providerOptions?: ProviderOptions;
|
472
|
+
/**
|
473
|
+
@deprecated Use `providerOptions` instead.
|
474
|
+
*/
|
391
475
|
experimental_providerMetadata?: ProviderMetadata;
|
392
476
|
};
|
393
477
|
/**
|
@@ -405,12 +489,17 @@ type CoreAssistantMessage = {
|
|
405
489
|
to the provider from the AI SDK and enable provider-specific
|
406
490
|
functionality that can be fully encapsulated in the provider.
|
407
491
|
*/
|
492
|
+
providerOptions?: ProviderOptions;
|
493
|
+
/**
|
494
|
+
@deprecated Use `providerOptions` instead.
|
495
|
+
*/
|
408
496
|
experimental_providerMetadata?: ProviderMetadata;
|
409
497
|
};
|
410
498
|
/**
|
411
|
-
Content of an assistant message.
|
499
|
+
Content of an assistant message.
|
500
|
+
It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
412
501
|
*/
|
413
|
-
type AssistantContent = string | Array<TextPart | ToolCallPart>;
|
502
|
+
type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | RedactedReasoningPart | ToolCallPart>;
|
414
503
|
/**
|
415
504
|
A tool message. It contains the result of one or more tool calls.
|
416
505
|
*/
|
@@ -422,6 +511,10 @@ type CoreToolMessage = {
|
|
422
511
|
to the provider from the AI SDK and enable provider-specific
|
423
512
|
functionality that can be fully encapsulated in the provider.
|
424
513
|
*/
|
514
|
+
providerOptions?: ProviderOptions;
|
515
|
+
/**
|
516
|
+
@deprecated Use `providerOptions` instead.
|
517
|
+
*/
|
425
518
|
experimental_providerMetadata?: ProviderMetadata;
|
426
519
|
};
|
427
520
|
/**
|
@@ -434,13 +527,6 @@ It can be a user message, an assistant message, or a tool message.
|
|
434
527
|
*/
|
435
528
|
type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage | CoreToolMessage;
|
436
529
|
|
437
|
-
type UIMessage = {
|
438
|
-
role: 'system' | 'user' | 'assistant' | 'data';
|
439
|
-
content: string;
|
440
|
-
toolInvocations?: ToolInvocation[];
|
441
|
-
experimental_attachments?: Attachment[];
|
442
|
-
};
|
443
|
-
|
444
530
|
/**
|
445
531
|
Prompt part of the AI function options.
|
446
532
|
It contains a system message, a simple text prompt, or a list of messages.
|
@@ -457,7 +543,7 @@ type Prompt = {
|
|
457
543
|
/**
|
458
544
|
A list of messages. You can either use `prompt` or `messages` but not both.
|
459
545
|
*/
|
460
|
-
messages?: Array<CoreMessage> | Array<
|
546
|
+
messages?: Array<CoreMessage> | Array<Omit<Message, 'id'>>;
|
461
547
|
};
|
462
548
|
|
463
549
|
type Streamable = ReactNode | Promise<ReactNode>;
|
@@ -498,7 +584,7 @@ type RenderResult = {
|
|
498
584
|
*/
|
499
585
|
declare function streamUI<TOOLS extends {
|
500
586
|
[name: string]: z.ZodTypeAny;
|
501
|
-
} = {}>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, initial, text, experimental_providerMetadata
|
587
|
+
} = {}>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, initial, text, experimental_providerMetadata, providerOptions, onFinish, ...settings }: CallSettings & Prompt & {
|
502
588
|
/**
|
503
589
|
* The language model to use.
|
504
590
|
*/
|
@@ -512,14 +598,18 @@ declare function streamUI<TOOLS extends {
|
|
512
598
|
/**
|
513
599
|
* The tool choice strategy. Default: 'auto'.
|
514
600
|
*/
|
515
|
-
toolChoice?:
|
601
|
+
toolChoice?: ToolChoice<TOOLS>;
|
516
602
|
text?: RenderText;
|
517
603
|
initial?: ReactNode;
|
518
604
|
/**
|
519
|
-
Additional provider-specific
|
605
|
+
Additional provider-specific options. They are passed through
|
520
606
|
to the provider from the AI SDK and enable provider-specific
|
521
607
|
functionality that can be fully encapsulated in the provider.
|
522
608
|
*/
|
609
|
+
providerOptions?: ProviderOptions;
|
610
|
+
/**
|
611
|
+
@deprecated Use `providerOptions` instead.
|
612
|
+
*/
|
523
613
|
experimental_providerMetadata?: ProviderMetadata;
|
524
614
|
/**
|
525
615
|
* Callback that is called when the LLM response and the final object validation are finished.
|