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/dist/index.js CHANGED
@@ -112,7 +112,8 @@ __export(src_exports, {
112
112
  toolModelMessageSchema: () => toolModelMessageSchema,
113
113
  userModelMessageSchema: () => userModelMessageSchema,
114
114
  wrapLanguageModel: () => wrapLanguageModel,
115
- wrapProvider: () => wrapProvider
115
+ wrapProvider: () => wrapProvider,
116
+ zodSchema: () => import_provider_utils27.zodSchema
116
117
  });
117
118
  module.exports = __toCommonJS(src_exports);
118
119
  var import_provider_utils27 = require("@ai-sdk/provider-utils");
@@ -414,6 +415,11 @@ var audioMediaTypeSignatures = [
414
415
  mediaType: "audio/mp4",
415
416
  bytesPrefix: [102, 116, 121, 112],
416
417
  base64Prefix: "ZnR5cA"
418
+ },
419
+ {
420
+ mediaType: "audio/webm",
421
+ bytesPrefix: [26, 69, 223, 163],
422
+ base64Prefix: "GkXf"
417
423
  }
418
424
  ];
419
425
  var stripID3 = (data) => {
@@ -1835,9 +1841,29 @@ var DefaultStepResult = class {
1835
1841
  get toolCalls() {
1836
1842
  return this.content.filter((part) => part.type === "tool-call");
1837
1843
  }
1844
+ get staticToolCalls() {
1845
+ return this.toolCalls.filter(
1846
+ (toolCall) => toolCall.dynamic === false
1847
+ );
1848
+ }
1849
+ get dynamicToolCalls() {
1850
+ return this.toolCalls.filter(
1851
+ (toolCall) => toolCall.dynamic === true
1852
+ );
1853
+ }
1838
1854
  get toolResults() {
1839
1855
  return this.content.filter((part) => part.type === "tool-result");
1840
1856
  }
1857
+ get staticToolResults() {
1858
+ return this.toolResults.filter(
1859
+ (toolResult) => toolResult.dynamic === false
1860
+ );
1861
+ }
1862
+ get dynamicToolResults() {
1863
+ return this.toolResults.filter(
1864
+ (toolResult) => toolResult.dynamic === true
1865
+ );
1866
+ }
1841
1867
  };
1842
1868
 
1843
1869
  // src/generate-text/stop-condition.ts
@@ -2298,7 +2324,7 @@ async function executeTools({
2298
2324
  }),
2299
2325
  "ai.toolCall.name": toolName,
2300
2326
  "ai.toolCall.id": toolCallId,
2301
- "ai.toolCall.input": {
2327
+ "ai.toolCall.args": {
2302
2328
  output: () => JSON.stringify(input)
2303
2329
  }
2304
2330
  }
@@ -2306,7 +2332,7 @@ async function executeTools({
2306
2332
  tracer,
2307
2333
  fn: async (span) => {
2308
2334
  try {
2309
- const result = await tool3.execute(input, {
2335
+ const output = await tool3.execute(input, {
2310
2336
  toolCallId,
2311
2337
  messages,
2312
2338
  abortSignal
@@ -2317,7 +2343,7 @@ async function executeTools({
2317
2343
  telemetry,
2318
2344
  attributes: {
2319
2345
  "ai.toolCall.result": {
2320
- output: () => JSON.stringify(result)
2346
+ output: () => JSON.stringify(output)
2321
2347
  }
2322
2348
  }
2323
2349
  })
@@ -2329,7 +2355,7 @@ async function executeTools({
2329
2355
  toolCallId,
2330
2356
  toolName,
2331
2357
  input,
2332
- output: result,
2358
+ output,
2333
2359
  dynamic: tool3.type === "dynamic"
2334
2360
  };
2335
2361
  } catch (error) {
@@ -2377,9 +2403,21 @@ var DefaultGenerateTextResult = class {
2377
2403
  get toolCalls() {
2378
2404
  return this.finalStep.toolCalls;
2379
2405
  }
2406
+ get staticToolCalls() {
2407
+ return this.finalStep.staticToolCalls;
2408
+ }
2409
+ get dynamicToolCalls() {
2410
+ return this.finalStep.dynamicToolCalls;
2411
+ }
2380
2412
  get toolResults() {
2381
2413
  return this.finalStep.toolResults;
2382
2414
  }
2415
+ get staticToolResults() {
2416
+ return this.finalStep.staticToolResults;
2417
+ }
2418
+ get dynamicToolResults() {
2419
+ return this.finalStep.dynamicToolResults;
2420
+ }
2383
2421
  get sources() {
2384
2422
  return this.finalStep.sources;
2385
2423
  }
@@ -3431,7 +3469,7 @@ function processUIMessageStream({
3431
3469
  });
3432
3470
  }
3433
3471
  write();
3434
- if (onToolCall && !chunk.providerExecuted && !chunk.dynamic) {
3472
+ if (onToolCall && !chunk.providerExecuted) {
3435
3473
  await onToolCall({
3436
3474
  toolCall: chunk
3437
3475
  });
@@ -3955,7 +3993,7 @@ function runToolsTransformation({
3955
3993
  }),
3956
3994
  "ai.toolCall.name": toolCall.toolName,
3957
3995
  "ai.toolCall.id": toolCall.toolCallId,
3958
- "ai.toolCall.input": {
3996
+ "ai.toolCall.args": {
3959
3997
  output: () => JSON.stringify(toolCall.input)
3960
3998
  }
3961
3999
  }
@@ -3992,7 +4030,7 @@ function runToolsTransformation({
3992
4030
  selectTelemetryAttributes({
3993
4031
  telemetry,
3994
4032
  attributes: {
3995
- "ai.toolCall.output": {
4033
+ "ai.toolCall.result": {
3996
4034
  output: () => JSON.stringify(output)
3997
4035
  }
3998
4036
  }
@@ -4399,7 +4437,11 @@ var DefaultStreamTextResult = class {
4399
4437
  files: finalStep.files,
4400
4438
  sources: finalStep.sources,
4401
4439
  toolCalls: finalStep.toolCalls,
4440
+ staticToolCalls: finalStep.staticToolCalls,
4441
+ dynamicToolCalls: finalStep.dynamicToolCalls,
4402
4442
  toolResults: finalStep.toolResults,
4443
+ staticToolResults: finalStep.staticToolResults,
4444
+ dynamicToolResults: finalStep.dynamicToolResults,
4403
4445
  request: finalStep.request,
4404
4446
  response: finalStep.response,
4405
4447
  warnings: finalStep.warnings,
@@ -4929,9 +4971,21 @@ var DefaultStreamTextResult = class {
4929
4971
  get toolCalls() {
4930
4972
  return this.finalStep.then((step) => step.toolCalls);
4931
4973
  }
4974
+ get staticToolCalls() {
4975
+ return this.finalStep.then((step) => step.staticToolCalls);
4976
+ }
4977
+ get dynamicToolCalls() {
4978
+ return this.finalStep.then((step) => step.dynamicToolCalls);
4979
+ }
4932
4980
  get toolResults() {
4933
4981
  return this.finalStep.then((step) => step.toolResults);
4934
4982
  }
4983
+ get staticToolResults() {
4984
+ return this.finalStep.then((step) => step.staticToolResults);
4985
+ }
4986
+ get dynamicToolResults() {
4987
+ return this.finalStep.then((step) => step.dynamicToolResults);
4988
+ }
4935
4989
  get usage() {
4936
4990
  return this.finalStep.then((step) => step.usage);
4937
4991
  }
@@ -6645,6 +6699,7 @@ var DefaultStreamObjectResult = class {
6645
6699
  this._warnings = new DelayedPromise();
6646
6700
  this._request = new DelayedPromise();
6647
6701
  this._response = new DelayedPromise();
6702
+ this._finishReason = new DelayedPromise();
6648
6703
  const model = resolveLanguageModel(modelArg);
6649
6704
  const { maxRetries, retry } = prepareRetries({
6650
6705
  maxRetries: maxRetriesArg
@@ -6864,6 +6919,7 @@ var DefaultStreamObjectResult = class {
6864
6919
  ...fullResponse,
6865
6920
  headers: response == null ? void 0 : response.headers
6866
6921
  });
6922
+ self._finishReason.resolve(finishReason != null ? finishReason : "unknown");
6867
6923
  const validationResult = await outputStrategy.validateFinalResult(
6868
6924
  latestObjectJson,
6869
6925
  {
@@ -6998,6 +7054,9 @@ var DefaultStreamObjectResult = class {
6998
7054
  get response() {
6999
7055
  return this._response.promise;
7000
7056
  }
7057
+ get finishReason() {
7058
+ return this._finishReason.promise;
7059
+ }
7001
7060
  get partialObjectStream() {
7002
7061
  return createAsyncIterableStream(
7003
7062
  this.baseStream.pipeThrough(
@@ -7850,38 +7909,38 @@ var SUPPORTED_PROTOCOL_VERSIONS = [
7850
7909
  "2025-03-26",
7851
7910
  "2024-11-05"
7852
7911
  ];
7853
- var ClientOrServerImplementationSchema = import_v48.z.object({
7912
+ var ClientOrServerImplementationSchema = import_v48.z.looseObject({
7854
7913
  name: import_v48.z.string(),
7855
7914
  version: import_v48.z.string()
7856
- }).passthrough();
7857
- var BaseParamsSchema = import_v48.z.object({
7858
- _meta: import_v48.z.optional(import_v48.z.object({}).passthrough())
7859
- }).passthrough();
7915
+ });
7916
+ var BaseParamsSchema = import_v48.z.looseObject({
7917
+ _meta: import_v48.z.optional(import_v48.z.object({}).loose())
7918
+ });
7860
7919
  var ResultSchema = BaseParamsSchema;
7861
7920
  var RequestSchema = import_v48.z.object({
7862
7921
  method: import_v48.z.string(),
7863
7922
  params: import_v48.z.optional(BaseParamsSchema)
7864
7923
  });
7865
- var ServerCapabilitiesSchema = import_v48.z.object({
7866
- experimental: import_v48.z.optional(import_v48.z.object({}).passthrough()),
7867
- logging: import_v48.z.optional(import_v48.z.object({}).passthrough()),
7924
+ var ServerCapabilitiesSchema = import_v48.z.looseObject({
7925
+ experimental: import_v48.z.optional(import_v48.z.object({}).loose()),
7926
+ logging: import_v48.z.optional(import_v48.z.object({}).loose()),
7868
7927
  prompts: import_v48.z.optional(
7869
- import_v48.z.object({
7928
+ import_v48.z.looseObject({
7870
7929
  listChanged: import_v48.z.optional(import_v48.z.boolean())
7871
- }).passthrough()
7930
+ })
7872
7931
  ),
7873
7932
  resources: import_v48.z.optional(
7874
- import_v48.z.object({
7933
+ import_v48.z.looseObject({
7875
7934
  subscribe: import_v48.z.optional(import_v48.z.boolean()),
7876
7935
  listChanged: import_v48.z.optional(import_v48.z.boolean())
7877
- }).passthrough()
7936
+ })
7878
7937
  ),
7879
7938
  tools: import_v48.z.optional(
7880
- import_v48.z.object({
7939
+ import_v48.z.looseObject({
7881
7940
  listChanged: import_v48.z.optional(import_v48.z.boolean())
7882
- }).passthrough()
7941
+ })
7883
7942
  )
7884
- }).passthrough();
7943
+ });
7885
7944
  var InitializeResultSchema = ResultSchema.extend({
7886
7945
  protocolVersion: import_v48.z.string(),
7887
7946
  capabilities: ServerCapabilitiesSchema,
@@ -7896,21 +7955,21 @@ var ToolSchema = import_v48.z.object({
7896
7955
  description: import_v48.z.optional(import_v48.z.string()),
7897
7956
  inputSchema: import_v48.z.object({
7898
7957
  type: import_v48.z.literal("object"),
7899
- properties: import_v48.z.optional(import_v48.z.object({}).passthrough())
7900
- }).passthrough()
7901
- }).passthrough();
7958
+ properties: import_v48.z.optional(import_v48.z.object({}).loose())
7959
+ }).loose()
7960
+ }).loose();
7902
7961
  var ListToolsResultSchema = PaginatedResultSchema.extend({
7903
7962
  tools: import_v48.z.array(ToolSchema)
7904
7963
  });
7905
7964
  var TextContentSchema = import_v48.z.object({
7906
7965
  type: import_v48.z.literal("text"),
7907
7966
  text: import_v48.z.string()
7908
- }).passthrough();
7967
+ }).loose();
7909
7968
  var ImageContentSchema = import_v48.z.object({
7910
7969
  type: import_v48.z.literal("image"),
7911
- data: import_v48.z.string().base64(),
7970
+ data: import_v48.z.base64(),
7912
7971
  mimeType: import_v48.z.string()
7913
- }).passthrough();
7972
+ }).loose();
7914
7973
  var ResourceContentsSchema = import_v48.z.object({
7915
7974
  /**
7916
7975
  * The URI of this resource.
@@ -7920,17 +7979,17 @@ var ResourceContentsSchema = import_v48.z.object({
7920
7979
  * The MIME type of this resource, if known.
7921
7980
  */
7922
7981
  mimeType: import_v48.z.optional(import_v48.z.string())
7923
- }).passthrough();
7982
+ }).loose();
7924
7983
  var TextResourceContentsSchema = ResourceContentsSchema.extend({
7925
7984
  text: import_v48.z.string()
7926
7985
  });
7927
7986
  var BlobResourceContentsSchema = ResourceContentsSchema.extend({
7928
- blob: import_v48.z.string().base64()
7987
+ blob: import_v48.z.base64()
7929
7988
  });
7930
7989
  var EmbeddedResourceSchema = import_v48.z.object({
7931
7990
  type: import_v48.z.literal("resource"),
7932
7991
  resource: import_v48.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
7933
- }).passthrough();
7992
+ }).loose();
7934
7993
  var CallToolResultSchema = ResultSchema.extend({
7935
7994
  content: import_v48.z.array(
7936
7995
  import_v48.z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
@@ -8128,11 +8187,11 @@ function isCustomMcpTransport(transport) {
8128
8187
  // src/tool/mcp/mcp-client.ts
8129
8188
  var CLIENT_VERSION = "1.0.0";
8130
8189
  async function createMCPClient(config) {
8131
- const client = new MCPClient(config);
8190
+ const client = new DefaultMCPClient(config);
8132
8191
  await client.init();
8133
8192
  return client;
8134
8193
  }
8135
- var MCPClient = class {
8194
+ var DefaultMCPClient = class {
8136
8195
  constructor({
8137
8196
  transport: transportConfig,
8138
8197
  name: name16 = "ai-sdk-mcp-client",
@@ -9531,6 +9590,7 @@ function readUIMessageStream({
9531
9590
  toolModelMessageSchema,
9532
9591
  userModelMessageSchema,
9533
9592
  wrapLanguageModel,
9534
- wrapProvider
9593
+ wrapProvider,
9594
+ zodSchema
9535
9595
  });
9536
9596
  //# sourceMappingURL=index.js.map