ai 5.0.0-beta.1 → 5.0.0-beta.2
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 +15 -0
- package/dist/index.d.mts +65 -899
- package/dist/index.d.ts +65 -899
- package/dist/index.js +275 -267
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -27
- 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.mjs
CHANGED
@@ -425,7 +425,7 @@ function pipeTextStreamToResponse({
|
|
425
425
|
import { parseJsonEventStream } from "@ai-sdk/provider-utils";
|
426
426
|
|
427
427
|
// src/ui-message-stream/ui-message-stream-parts.ts
|
428
|
-
import { z } from "zod";
|
428
|
+
import { z } from "zod/v4";
|
429
429
|
var uiMessageStreamPartSchema = z.union([
|
430
430
|
z.strictObject({
|
431
431
|
type: z.literal("text-start"),
|
@@ -477,23 +477,23 @@ var uiMessageStreamPartSchema = z.union([
|
|
477
477
|
z.strictObject({
|
478
478
|
type: z.literal("reasoning"),
|
479
479
|
text: z.string(),
|
480
|
-
providerMetadata: z.record(z.any()).optional()
|
480
|
+
providerMetadata: z.record(z.string(), z.any()).optional()
|
481
481
|
}),
|
482
482
|
z.strictObject({
|
483
483
|
type: z.literal("reasoning-start"),
|
484
484
|
id: z.string(),
|
485
|
-
providerMetadata: z.record(z.any()).optional()
|
485
|
+
providerMetadata: z.record(z.string(), z.any()).optional()
|
486
486
|
}),
|
487
487
|
z.strictObject({
|
488
488
|
type: z.literal("reasoning-delta"),
|
489
489
|
id: z.string(),
|
490
490
|
delta: z.string(),
|
491
|
-
providerMetadata: z.record(z.any()).optional()
|
491
|
+
providerMetadata: z.record(z.string(), z.any()).optional()
|
492
492
|
}),
|
493
493
|
z.strictObject({
|
494
494
|
type: z.literal("reasoning-end"),
|
495
495
|
id: z.string(),
|
496
|
-
providerMetadata: z.record(z.any()).optional()
|
496
|
+
providerMetadata: z.record(z.string(), z.any()).optional()
|
497
497
|
}),
|
498
498
|
z.strictObject({
|
499
499
|
type: z.literal("reasoning-part-finish")
|
@@ -790,7 +790,7 @@ var HttpChatTransport = class {
|
|
790
790
|
...options
|
791
791
|
}) {
|
792
792
|
var _a16, _b, _c, _d;
|
793
|
-
const preparedRequest = (_a16 = this.prepareSendMessagesRequest) == null ? void 0 : _a16.call(this, {
|
793
|
+
const preparedRequest = await ((_a16 = this.prepareSendMessagesRequest) == null ? void 0 : _a16.call(this, {
|
794
794
|
api: this.api,
|
795
795
|
id: options.chatId,
|
796
796
|
messages: options.messages,
|
@@ -800,7 +800,7 @@ var HttpChatTransport = class {
|
|
800
800
|
requestMetadata: options.metadata,
|
801
801
|
trigger: options.trigger,
|
802
802
|
messageId: options.messageId
|
803
|
-
});
|
803
|
+
}));
|
804
804
|
const api = (_b = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b : this.api;
|
805
805
|
const headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...options.headers };
|
806
806
|
const body = (preparedRequest == null ? void 0 : preparedRequest.body) !== void 0 ? preparedRequest.body : {
|
@@ -834,14 +834,14 @@ var HttpChatTransport = class {
|
|
834
834
|
}
|
835
835
|
async reconnectToStream(options) {
|
836
836
|
var _a16, _b, _c, _d;
|
837
|
-
const preparedRequest = (_a16 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a16.call(this, {
|
837
|
+
const preparedRequest = await ((_a16 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a16.call(this, {
|
838
838
|
api: this.api,
|
839
839
|
id: options.chatId,
|
840
840
|
body: { ...this.body, ...options.body },
|
841
841
|
headers: { ...this.headers, ...options.headers },
|
842
842
|
credentials: this.credentials,
|
843
843
|
requestMetadata: options.metadata
|
844
|
-
});
|
844
|
+
}));
|
845
845
|
const api = (_b = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b : `${this.api}/${options.chatId}/stream`;
|
846
846
|
const headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...options.headers };
|
847
847
|
const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
|
@@ -1292,7 +1292,8 @@ function processUIMessageStream({
|
|
1292
1292
|
onToolCall,
|
1293
1293
|
messageMetadataSchema,
|
1294
1294
|
dataPartSchemas,
|
1295
|
-
runUpdateMessageJob
|
1295
|
+
runUpdateMessageJob,
|
1296
|
+
onError
|
1296
1297
|
}) {
|
1297
1298
|
return stream.pipeThrough(
|
1298
1299
|
new TransformStream({
|
@@ -1565,7 +1566,8 @@ function processUIMessageStream({
|
|
1565
1566
|
break;
|
1566
1567
|
}
|
1567
1568
|
case "error": {
|
1568
|
-
|
1569
|
+
onError == null ? void 0 : onError(new Error(part.errorText));
|
1570
|
+
break;
|
1569
1571
|
}
|
1570
1572
|
default: {
|
1571
1573
|
if (isDataUIMessageStreamPart(part)) {
|
@@ -1869,7 +1871,10 @@ var AbstractChat = class {
|
|
1869
1871
|
onToolCall: this.onToolCall,
|
1870
1872
|
messageMetadataSchema: this.messageMetadataSchema,
|
1871
1873
|
dataPartSchemas: this.dataPartSchemas,
|
1872
|
-
runUpdateMessageJob
|
1874
|
+
runUpdateMessageJob,
|
1875
|
+
onError: (error) => {
|
1876
|
+
throw error;
|
1877
|
+
}
|
1873
1878
|
}),
|
1874
1879
|
onError: (error) => {
|
1875
1880
|
throw error;
|
@@ -1878,7 +1883,6 @@ var AbstractChat = class {
|
|
1878
1883
|
(_b = this.onFinish) == null ? void 0 : _b.call(this, { message: activeResponse.state.message });
|
1879
1884
|
this.setStatus({ status: "ready" });
|
1880
1885
|
} catch (err) {
|
1881
|
-
console.error(err);
|
1882
1886
|
if (err.name === "AbortError") {
|
1883
1887
|
this.setStatus({ status: "ready" });
|
1884
1888
|
return null;
|
@@ -2149,6 +2153,7 @@ function handleUIMessageStreamFinish({
|
|
2149
2153
|
messageId,
|
2150
2154
|
originalMessages = [],
|
2151
2155
|
onFinish,
|
2156
|
+
onError,
|
2152
2157
|
stream
|
2153
2158
|
}) {
|
2154
2159
|
if (onFinish == null) {
|
@@ -2178,7 +2183,8 @@ function handleUIMessageStreamFinish({
|
|
2178
2183
|
}
|
2179
2184
|
})
|
2180
2185
|
),
|
2181
|
-
runUpdateMessageJob
|
2186
|
+
runUpdateMessageJob,
|
2187
|
+
onError
|
2182
2188
|
}).pipeThrough(
|
2183
2189
|
new TransformStream({
|
2184
2190
|
transform(chunk, controller) {
|
@@ -2279,7 +2285,8 @@ function createUIMessageStream({
|
|
2279
2285
|
stream,
|
2280
2286
|
messageId: generateId3(),
|
2281
2287
|
originalMessages,
|
2282
|
-
onFinish
|
2288
|
+
onFinish,
|
2289
|
+
onError
|
2283
2290
|
});
|
2284
2291
|
}
|
2285
2292
|
|
@@ -3378,7 +3385,7 @@ import {
|
|
3378
3385
|
convertBase64ToUint8Array as convertBase64ToUint8Array3,
|
3379
3386
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase642
|
3380
3387
|
} from "@ai-sdk/provider-utils";
|
3381
|
-
import { z as z2 } from "zod";
|
3388
|
+
import { z as z2 } from "zod/v4";
|
3382
3389
|
|
3383
3390
|
// core/prompt/split-data-url.ts
|
3384
3391
|
function splitDataUrl(dataUrl) {
|
@@ -3631,7 +3638,7 @@ async function downloadAssets(messages, downloadImplementation, supportedUrls) {
|
|
3631
3638
|
);
|
3632
3639
|
}
|
3633
3640
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
3634
|
-
var _a16
|
3641
|
+
var _a16;
|
3635
3642
|
if (part.type === "text") {
|
3636
3643
|
return {
|
3637
3644
|
type: "text",
|
@@ -3658,13 +3665,13 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
3658
3665
|
const downloadedFile = downloadedAssets[data.toString()];
|
3659
3666
|
if (downloadedFile) {
|
3660
3667
|
data = downloadedFile.data;
|
3661
|
-
mediaType
|
3668
|
+
mediaType != null ? mediaType : mediaType = downloadedFile.mediaType;
|
3662
3669
|
}
|
3663
3670
|
}
|
3664
3671
|
switch (type) {
|
3665
3672
|
case "image": {
|
3666
3673
|
if (data instanceof Uint8Array || typeof data === "string") {
|
3667
|
-
mediaType = (
|
3674
|
+
mediaType = (_a16 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a16 : mediaType;
|
3668
3675
|
}
|
3669
3676
|
return {
|
3670
3677
|
type: "file",
|
@@ -3796,16 +3803,16 @@ function resolveLanguageModel(model) {
|
|
3796
3803
|
// core/prompt/standardize-prompt.ts
|
3797
3804
|
import { InvalidPromptError as InvalidPromptError2 } from "@ai-sdk/provider";
|
3798
3805
|
import { safeValidateTypes } from "@ai-sdk/provider-utils";
|
3799
|
-
import { z as z7 } from "zod";
|
3806
|
+
import { z as z7 } from "zod/v4";
|
3800
3807
|
|
3801
3808
|
// core/prompt/message.ts
|
3802
|
-
import { z as z6 } from "zod";
|
3809
|
+
import { z as z6 } from "zod/v4";
|
3803
3810
|
|
3804
3811
|
// core/types/provider-metadata.ts
|
3805
|
-
import { z as z4 } from "zod";
|
3812
|
+
import { z as z4 } from "zod/v4";
|
3806
3813
|
|
3807
3814
|
// core/types/json-value.ts
|
3808
|
-
import { z as z3 } from "zod";
|
3815
|
+
import { z as z3 } from "zod/v4";
|
3809
3816
|
var jsonValueSchema = z3.lazy(
|
3810
3817
|
() => z3.union([
|
3811
3818
|
z3.null(),
|
@@ -3824,7 +3831,7 @@ var providerMetadataSchema = z4.record(
|
|
3824
3831
|
);
|
3825
3832
|
|
3826
3833
|
// core/prompt/content-part.ts
|
3827
|
-
import { z as z5 } from "zod";
|
3834
|
+
import { z as z5 } from "zod/v4";
|
3828
3835
|
var textPartSchema = z5.object({
|
3829
3836
|
type: z5.literal("text"),
|
3830
3837
|
text: z5.string(),
|
@@ -7778,7 +7785,8 @@ var DefaultStreamTextResult = class {
|
|
7778
7785
|
stream: baseStream,
|
7779
7786
|
messageId: responseMessageId != null ? responseMessageId : this.generateId(),
|
7780
7787
|
originalMessages,
|
7781
|
-
onFinish
|
7788
|
+
onFinish,
|
7789
|
+
onError
|
7782
7790
|
});
|
7783
7791
|
}
|
7784
7792
|
pipeUIMessageStreamToResponse(response, {
|
@@ -8343,10 +8351,10 @@ import { tool } from "@ai-sdk/provider-utils";
|
|
8343
8351
|
import { EventSourceParserStream } from "@ai-sdk/provider-utils";
|
8344
8352
|
|
8345
8353
|
// core/tool/mcp/json-rpc-message.ts
|
8346
|
-
import { z as z9 } from "zod";
|
8354
|
+
import { z as z9 } from "zod/v4";
|
8347
8355
|
|
8348
8356
|
// core/tool/mcp/types.ts
|
8349
|
-
import { z as z8 } from "zod";
|
8357
|
+
import { z as z8 } from "zod/v4";
|
8350
8358
|
var LATEST_PROTOCOL_VERSION = "2024-11-05";
|
8351
8359
|
var SUPPORTED_PROTOCOL_VERSIONS = [
|
8352
8360
|
LATEST_PROTOCOL_VERSION,
|