ai 5.0.0-alpha.10 → 5.0.0-alpha.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/dist/index.mjs CHANGED
@@ -498,6 +498,15 @@ var uiMessageStreamPartSchema = z.union([
498
498
  providerMetadata: z.any().optional()
499
499
  // Use z.any() for generic metadata
500
500
  }),
501
+ z.object({
502
+ type: z.literal("source-document"),
503
+ sourceId: z.string(),
504
+ mediaType: z.string(),
505
+ title: z.string(),
506
+ filename: z.string().optional(),
507
+ providerMetadata: z.any().optional()
508
+ // Use z.any() for generic metadata
509
+ }),
501
510
  z.object({
502
511
  type: z.literal("file"),
503
512
  url: z.string(),
@@ -1212,6 +1221,18 @@ function processUIMessageStream({
1212
1221
  write();
1213
1222
  break;
1214
1223
  }
1224
+ case "source-document": {
1225
+ state.message.parts.push({
1226
+ type: "source-document",
1227
+ sourceId: part.sourceId,
1228
+ mediaType: part.mediaType,
1229
+ title: part.title,
1230
+ filename: part.filename,
1231
+ providerMetadata: part.providerMetadata
1232
+ });
1233
+ write();
1234
+ break;
1235
+ }
1215
1236
  case "tool-call-streaming-start": {
1216
1237
  const toolInvocations = getToolInvocations(state.message);
1217
1238
  state.partialToolCalls[part.toolCallId] = {
@@ -5907,6 +5928,14 @@ async function executeTools({
5907
5928
  const toolResults = await Promise.all(
5908
5929
  toolCalls.map(async ({ toolCallId, toolName, args }) => {
5909
5930
  const tool2 = tools[toolName];
5931
+ if ((tool2 == null ? void 0 : tool2.onArgsAvailable) != null) {
5932
+ await tool2.onArgsAvailable({
5933
+ args,
5934
+ toolCallId,
5935
+ messages,
5936
+ abortSignal
5937
+ });
5938
+ }
5910
5939
  if ((tool2 == null ? void 0 : tool2.execute) == null) {
5911
5940
  return void 0;
5912
5941
  }
@@ -6295,6 +6324,14 @@ function runToolsTransformation({
6295
6324
  });
6296
6325
  controller.enqueue(toolCall);
6297
6326
  const tool2 = tools[toolCall.toolName];
6327
+ if (tool2.onArgsAvailable != null) {
6328
+ await tool2.onArgsAvailable({
6329
+ args: toolCall.args,
6330
+ toolCallId: toolCall.toolCallId,
6331
+ messages,
6332
+ abortSignal
6333
+ });
6334
+ }
6298
6335
  if (tool2.execute != null) {
6299
6336
  const toolExecutionId = generateId();
6300
6337
  outstandingToolResults.add(toolExecutionId);
@@ -6985,8 +7022,28 @@ var DefaultStreamTextResult = class {
6985
7022
  controller.enqueue(chunk);
6986
7023
  break;
6987
7024
  }
6988
- case "tool-call-streaming-start":
7025
+ case "tool-call-streaming-start": {
7026
+ const tool2 = tools == null ? void 0 : tools[chunk.toolName];
7027
+ if ((tool2 == null ? void 0 : tool2.onArgsStreamingStart) != null) {
7028
+ await tool2.onArgsStreamingStart({
7029
+ toolCallId: chunk.toolCallId,
7030
+ messages: stepInputMessages,
7031
+ abortSignal
7032
+ });
7033
+ }
7034
+ controller.enqueue(chunk);
7035
+ break;
7036
+ }
6989
7037
  case "tool-call-delta": {
7038
+ const tool2 = tools == null ? void 0 : tools[chunk.toolName];
7039
+ if ((tool2 == null ? void 0 : tool2.onArgsStreamingDelta) != null) {
7040
+ await tool2.onArgsStreamingDelta({
7041
+ argsTextDelta: chunk.argsTextDelta,
7042
+ toolCallId: chunk.toolCallId,
7043
+ messages: stepInputMessages,
7044
+ abortSignal
7045
+ });
7046
+ }
6990
7047
  controller.enqueue(chunk);
6991
7048
  break;
6992
7049
  }
@@ -7266,7 +7323,7 @@ var DefaultStreamTextResult = class {
7266
7323
  break;
7267
7324
  }
7268
7325
  case "source": {
7269
- if (sendSources) {
7326
+ if (sendSources && part.sourceType === "url") {
7270
7327
  controller.enqueue({
7271
7328
  type: "source-url",
7272
7329
  sourceId: part.id,
@@ -7275,6 +7332,16 @@ var DefaultStreamTextResult = class {
7275
7332
  providerMetadata: part.providerMetadata
7276
7333
  });
7277
7334
  }
7335
+ if (sendSources && part.sourceType === "document") {
7336
+ controller.enqueue({
7337
+ type: "source-document",
7338
+ sourceId: part.id,
7339
+ mediaType: part.mediaType,
7340
+ title: part.title,
7341
+ filename: part.filename,
7342
+ providerMetadata: part.providerMetadata
7343
+ });
7344
+ }
7278
7345
  break;
7279
7346
  }
7280
7347
  case "tool-call-streaming-start": {