ai 5.0.0-beta.30 → 5.0.0-beta.32
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 +21 -0
- package/dist/bin/ai.min.js +18 -18
- package/dist/index.d.mts +115 -88
- package/dist/index.d.ts +115 -88
- package/dist/index.js +95 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -35
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +24 -24
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +24 -24
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -11,7 +11,8 @@ import {
|
|
11
11
|
dynamicTool as dynamicTool2,
|
12
12
|
generateId as generateId2,
|
13
13
|
jsonSchema as jsonSchema2,
|
14
|
-
tool as tool2
|
14
|
+
tool as tool2,
|
15
|
+
zodSchema
|
15
16
|
} from "@ai-sdk/provider-utils";
|
16
17
|
|
17
18
|
// src/generate-text/generate-text.ts
|
@@ -315,6 +316,11 @@ var audioMediaTypeSignatures = [
|
|
315
316
|
mediaType: "audio/mp4",
|
316
317
|
bytesPrefix: [102, 116, 121, 112],
|
317
318
|
base64Prefix: "ZnR5cA"
|
319
|
+
},
|
320
|
+
{
|
321
|
+
mediaType: "audio/webm",
|
322
|
+
bytesPrefix: [26, 69, 223, 163],
|
323
|
+
base64Prefix: "GkXf"
|
318
324
|
}
|
319
325
|
];
|
320
326
|
var stripID3 = (data) => {
|
@@ -1761,9 +1767,29 @@ var DefaultStepResult = class {
|
|
1761
1767
|
get toolCalls() {
|
1762
1768
|
return this.content.filter((part) => part.type === "tool-call");
|
1763
1769
|
}
|
1770
|
+
get staticToolCalls() {
|
1771
|
+
return this.toolCalls.filter(
|
1772
|
+
(toolCall) => toolCall.dynamic === false
|
1773
|
+
);
|
1774
|
+
}
|
1775
|
+
get dynamicToolCalls() {
|
1776
|
+
return this.toolCalls.filter(
|
1777
|
+
(toolCall) => toolCall.dynamic === true
|
1778
|
+
);
|
1779
|
+
}
|
1764
1780
|
get toolResults() {
|
1765
1781
|
return this.content.filter((part) => part.type === "tool-result");
|
1766
1782
|
}
|
1783
|
+
get staticToolResults() {
|
1784
|
+
return this.toolResults.filter(
|
1785
|
+
(toolResult) => toolResult.dynamic === false
|
1786
|
+
);
|
1787
|
+
}
|
1788
|
+
get dynamicToolResults() {
|
1789
|
+
return this.toolResults.filter(
|
1790
|
+
(toolResult) => toolResult.dynamic === true
|
1791
|
+
);
|
1792
|
+
}
|
1767
1793
|
};
|
1768
1794
|
|
1769
1795
|
// src/generate-text/stop-condition.ts
|
@@ -2226,7 +2252,7 @@ async function executeTools({
|
|
2226
2252
|
}),
|
2227
2253
|
"ai.toolCall.name": toolName,
|
2228
2254
|
"ai.toolCall.id": toolCallId,
|
2229
|
-
"ai.toolCall.
|
2255
|
+
"ai.toolCall.args": {
|
2230
2256
|
output: () => JSON.stringify(input)
|
2231
2257
|
}
|
2232
2258
|
}
|
@@ -2234,7 +2260,7 @@ async function executeTools({
|
|
2234
2260
|
tracer,
|
2235
2261
|
fn: async (span) => {
|
2236
2262
|
try {
|
2237
|
-
const
|
2263
|
+
const output = await tool3.execute(input, {
|
2238
2264
|
toolCallId,
|
2239
2265
|
messages,
|
2240
2266
|
abortSignal
|
@@ -2245,7 +2271,7 @@ async function executeTools({
|
|
2245
2271
|
telemetry,
|
2246
2272
|
attributes: {
|
2247
2273
|
"ai.toolCall.result": {
|
2248
|
-
output: () => JSON.stringify(
|
2274
|
+
output: () => JSON.stringify(output)
|
2249
2275
|
}
|
2250
2276
|
}
|
2251
2277
|
})
|
@@ -2257,7 +2283,7 @@ async function executeTools({
|
|
2257
2283
|
toolCallId,
|
2258
2284
|
toolName,
|
2259
2285
|
input,
|
2260
|
-
output
|
2286
|
+
output,
|
2261
2287
|
dynamic: tool3.type === "dynamic"
|
2262
2288
|
};
|
2263
2289
|
} catch (error) {
|
@@ -2305,9 +2331,21 @@ var DefaultGenerateTextResult = class {
|
|
2305
2331
|
get toolCalls() {
|
2306
2332
|
return this.finalStep.toolCalls;
|
2307
2333
|
}
|
2334
|
+
get staticToolCalls() {
|
2335
|
+
return this.finalStep.staticToolCalls;
|
2336
|
+
}
|
2337
|
+
get dynamicToolCalls() {
|
2338
|
+
return this.finalStep.dynamicToolCalls;
|
2339
|
+
}
|
2308
2340
|
get toolResults() {
|
2309
2341
|
return this.finalStep.toolResults;
|
2310
2342
|
}
|
2343
|
+
get staticToolResults() {
|
2344
|
+
return this.finalStep.staticToolResults;
|
2345
|
+
}
|
2346
|
+
get dynamicToolResults() {
|
2347
|
+
return this.finalStep.dynamicToolResults;
|
2348
|
+
}
|
2311
2349
|
get sources() {
|
2312
2350
|
return this.finalStep.sources;
|
2313
2351
|
}
|
@@ -3366,7 +3404,7 @@ function processUIMessageStream({
|
|
3366
3404
|
});
|
3367
3405
|
}
|
3368
3406
|
write();
|
3369
|
-
if (onToolCall && !chunk.providerExecuted
|
3407
|
+
if (onToolCall && !chunk.providerExecuted) {
|
3370
3408
|
await onToolCall({
|
3371
3409
|
toolCall: chunk
|
3372
3410
|
});
|
@@ -3890,7 +3928,7 @@ function runToolsTransformation({
|
|
3890
3928
|
}),
|
3891
3929
|
"ai.toolCall.name": toolCall.toolName,
|
3892
3930
|
"ai.toolCall.id": toolCall.toolCallId,
|
3893
|
-
"ai.toolCall.
|
3931
|
+
"ai.toolCall.args": {
|
3894
3932
|
output: () => JSON.stringify(toolCall.input)
|
3895
3933
|
}
|
3896
3934
|
}
|
@@ -3927,7 +3965,7 @@ function runToolsTransformation({
|
|
3927
3965
|
selectTelemetryAttributes({
|
3928
3966
|
telemetry,
|
3929
3967
|
attributes: {
|
3930
|
-
"ai.toolCall.
|
3968
|
+
"ai.toolCall.result": {
|
3931
3969
|
output: () => JSON.stringify(output)
|
3932
3970
|
}
|
3933
3971
|
}
|
@@ -4334,7 +4372,11 @@ var DefaultStreamTextResult = class {
|
|
4334
4372
|
files: finalStep.files,
|
4335
4373
|
sources: finalStep.sources,
|
4336
4374
|
toolCalls: finalStep.toolCalls,
|
4375
|
+
staticToolCalls: finalStep.staticToolCalls,
|
4376
|
+
dynamicToolCalls: finalStep.dynamicToolCalls,
|
4337
4377
|
toolResults: finalStep.toolResults,
|
4378
|
+
staticToolResults: finalStep.staticToolResults,
|
4379
|
+
dynamicToolResults: finalStep.dynamicToolResults,
|
4338
4380
|
request: finalStep.request,
|
4339
4381
|
response: finalStep.response,
|
4340
4382
|
warnings: finalStep.warnings,
|
@@ -4864,9 +4906,21 @@ var DefaultStreamTextResult = class {
|
|
4864
4906
|
get toolCalls() {
|
4865
4907
|
return this.finalStep.then((step) => step.toolCalls);
|
4866
4908
|
}
|
4909
|
+
get staticToolCalls() {
|
4910
|
+
return this.finalStep.then((step) => step.staticToolCalls);
|
4911
|
+
}
|
4912
|
+
get dynamicToolCalls() {
|
4913
|
+
return this.finalStep.then((step) => step.dynamicToolCalls);
|
4914
|
+
}
|
4867
4915
|
get toolResults() {
|
4868
4916
|
return this.finalStep.then((step) => step.toolResults);
|
4869
4917
|
}
|
4918
|
+
get staticToolResults() {
|
4919
|
+
return this.finalStep.then((step) => step.staticToolResults);
|
4920
|
+
}
|
4921
|
+
get dynamicToolResults() {
|
4922
|
+
return this.finalStep.then((step) => step.dynamicToolResults);
|
4923
|
+
}
|
4870
4924
|
get usage() {
|
4871
4925
|
return this.finalStep.then((step) => step.usage);
|
4872
4926
|
}
|
@@ -6596,6 +6650,7 @@ var DefaultStreamObjectResult = class {
|
|
6596
6650
|
this._warnings = new DelayedPromise();
|
6597
6651
|
this._request = new DelayedPromise();
|
6598
6652
|
this._response = new DelayedPromise();
|
6653
|
+
this._finishReason = new DelayedPromise();
|
6599
6654
|
const model = resolveLanguageModel(modelArg);
|
6600
6655
|
const { maxRetries, retry } = prepareRetries({
|
6601
6656
|
maxRetries: maxRetriesArg
|
@@ -6815,6 +6870,7 @@ var DefaultStreamObjectResult = class {
|
|
6815
6870
|
...fullResponse,
|
6816
6871
|
headers: response == null ? void 0 : response.headers
|
6817
6872
|
});
|
6873
|
+
self._finishReason.resolve(finishReason != null ? finishReason : "unknown");
|
6818
6874
|
const validationResult = await outputStrategy.validateFinalResult(
|
6819
6875
|
latestObjectJson,
|
6820
6876
|
{
|
@@ -6949,6 +7005,9 @@ var DefaultStreamObjectResult = class {
|
|
6949
7005
|
get response() {
|
6950
7006
|
return this._response.promise;
|
6951
7007
|
}
|
7008
|
+
get finishReason() {
|
7009
|
+
return this._finishReason.promise;
|
7010
|
+
}
|
6952
7011
|
get partialObjectStream() {
|
6953
7012
|
return createAsyncIterableStream(
|
6954
7013
|
this.baseStream.pipeThrough(
|
@@ -7813,38 +7872,38 @@ var SUPPORTED_PROTOCOL_VERSIONS = [
|
|
7813
7872
|
"2025-03-26",
|
7814
7873
|
"2024-11-05"
|
7815
7874
|
];
|
7816
|
-
var ClientOrServerImplementationSchema = z8.
|
7875
|
+
var ClientOrServerImplementationSchema = z8.looseObject({
|
7817
7876
|
name: z8.string(),
|
7818
7877
|
version: z8.string()
|
7819
|
-
})
|
7820
|
-
var BaseParamsSchema = z8.
|
7821
|
-
_meta: z8.optional(z8.object({}).
|
7822
|
-
})
|
7878
|
+
});
|
7879
|
+
var BaseParamsSchema = z8.looseObject({
|
7880
|
+
_meta: z8.optional(z8.object({}).loose())
|
7881
|
+
});
|
7823
7882
|
var ResultSchema = BaseParamsSchema;
|
7824
7883
|
var RequestSchema = z8.object({
|
7825
7884
|
method: z8.string(),
|
7826
7885
|
params: z8.optional(BaseParamsSchema)
|
7827
7886
|
});
|
7828
|
-
var ServerCapabilitiesSchema = z8.
|
7829
|
-
experimental: z8.optional(z8.object({}).
|
7830
|
-
logging: z8.optional(z8.object({}).
|
7887
|
+
var ServerCapabilitiesSchema = z8.looseObject({
|
7888
|
+
experimental: z8.optional(z8.object({}).loose()),
|
7889
|
+
logging: z8.optional(z8.object({}).loose()),
|
7831
7890
|
prompts: z8.optional(
|
7832
|
-
z8.
|
7891
|
+
z8.looseObject({
|
7833
7892
|
listChanged: z8.optional(z8.boolean())
|
7834
|
-
})
|
7893
|
+
})
|
7835
7894
|
),
|
7836
7895
|
resources: z8.optional(
|
7837
|
-
z8.
|
7896
|
+
z8.looseObject({
|
7838
7897
|
subscribe: z8.optional(z8.boolean()),
|
7839
7898
|
listChanged: z8.optional(z8.boolean())
|
7840
|
-
})
|
7899
|
+
})
|
7841
7900
|
),
|
7842
7901
|
tools: z8.optional(
|
7843
|
-
z8.
|
7902
|
+
z8.looseObject({
|
7844
7903
|
listChanged: z8.optional(z8.boolean())
|
7845
|
-
})
|
7904
|
+
})
|
7846
7905
|
)
|
7847
|
-
})
|
7906
|
+
});
|
7848
7907
|
var InitializeResultSchema = ResultSchema.extend({
|
7849
7908
|
protocolVersion: z8.string(),
|
7850
7909
|
capabilities: ServerCapabilitiesSchema,
|
@@ -7859,21 +7918,21 @@ var ToolSchema = z8.object({
|
|
7859
7918
|
description: z8.optional(z8.string()),
|
7860
7919
|
inputSchema: z8.object({
|
7861
7920
|
type: z8.literal("object"),
|
7862
|
-
properties: z8.optional(z8.object({}).
|
7863
|
-
}).
|
7864
|
-
}).
|
7921
|
+
properties: z8.optional(z8.object({}).loose())
|
7922
|
+
}).loose()
|
7923
|
+
}).loose();
|
7865
7924
|
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
7866
7925
|
tools: z8.array(ToolSchema)
|
7867
7926
|
});
|
7868
7927
|
var TextContentSchema = z8.object({
|
7869
7928
|
type: z8.literal("text"),
|
7870
7929
|
text: z8.string()
|
7871
|
-
}).
|
7930
|
+
}).loose();
|
7872
7931
|
var ImageContentSchema = z8.object({
|
7873
7932
|
type: z8.literal("image"),
|
7874
|
-
data: z8.
|
7933
|
+
data: z8.base64(),
|
7875
7934
|
mimeType: z8.string()
|
7876
|
-
}).
|
7935
|
+
}).loose();
|
7877
7936
|
var ResourceContentsSchema = z8.object({
|
7878
7937
|
/**
|
7879
7938
|
* The URI of this resource.
|
@@ -7883,17 +7942,17 @@ var ResourceContentsSchema = z8.object({
|
|
7883
7942
|
* The MIME type of this resource, if known.
|
7884
7943
|
*/
|
7885
7944
|
mimeType: z8.optional(z8.string())
|
7886
|
-
}).
|
7945
|
+
}).loose();
|
7887
7946
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
7888
7947
|
text: z8.string()
|
7889
7948
|
});
|
7890
7949
|
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
7891
|
-
blob: z8.
|
7950
|
+
blob: z8.base64()
|
7892
7951
|
});
|
7893
7952
|
var EmbeddedResourceSchema = z8.object({
|
7894
7953
|
type: z8.literal("resource"),
|
7895
7954
|
resource: z8.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
7896
|
-
}).
|
7955
|
+
}).loose();
|
7897
7956
|
var CallToolResultSchema = ResultSchema.extend({
|
7898
7957
|
content: z8.array(
|
7899
7958
|
z8.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
|
@@ -8091,11 +8150,11 @@ function isCustomMcpTransport(transport) {
|
|
8091
8150
|
// src/tool/mcp/mcp-client.ts
|
8092
8151
|
var CLIENT_VERSION = "1.0.0";
|
8093
8152
|
async function createMCPClient(config) {
|
8094
|
-
const client = new
|
8153
|
+
const client = new DefaultMCPClient(config);
|
8095
8154
|
await client.init();
|
8096
8155
|
return client;
|
8097
8156
|
}
|
8098
|
-
var
|
8157
|
+
var DefaultMCPClient = class {
|
8099
8158
|
constructor({
|
8100
8159
|
transport: transportConfig,
|
8101
8160
|
name: name16 = "ai-sdk-mcp-client",
|
@@ -9498,6 +9557,7 @@ export {
|
|
9498
9557
|
toolModelMessageSchema,
|
9499
9558
|
userModelMessageSchema,
|
9500
9559
|
wrapLanguageModel,
|
9501
|
-
wrapProvider
|
9560
|
+
wrapProvider,
|
9561
|
+
zodSchema
|
9502
9562
|
};
|
9503
9563
|
//# sourceMappingURL=index.mjs.map
|