ai 6.0.272 → 6.0.274

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
@@ -1224,7 +1224,7 @@ import {
1224
1224
  } from "@ai-sdk/provider-utils";
1225
1225
 
1226
1226
  // src/version.ts
1227
- var VERSION = true ? "6.0.272" : "0.0.0-test";
1227
+ var VERSION = true ? "6.0.274" : "0.0.0-test";
1228
1228
 
1229
1229
  // src/util/download/download.ts
1230
1230
  var download = async ({
@@ -5661,6 +5661,7 @@ var uiMessageChunkSchema = lazySchema(
5661
5661
  type: z7.literal("tool-approval-request"),
5662
5662
  approvalId: z7.string(),
5663
5663
  toolCallId: z7.string(),
5664
+ approvalDescriptor: z7.unknown().optional(),
5664
5665
  signature: z7.string().optional()
5665
5666
  }),
5666
5667
  z7.looseObject({
@@ -6240,6 +6241,7 @@ function processUIMessageStream({
6240
6241
  toolInvocation.state = "approval-requested";
6241
6242
  toolInvocation.approval = {
6242
6243
  id: chunk.approvalId,
6244
+ ...chunk.approvalDescriptor != null ? { descriptor: chunk.approvalDescriptor } : {},
6243
6245
  ...chunk.signature != null ? { signature: chunk.signature } : {}
6244
6246
  };
6245
6247
  write();
@@ -7554,40 +7556,51 @@ var DefaultStreamTextResult = class {
7554
7556
  self._totalUsage.resolve(totalUsage);
7555
7557
  self._steps.resolve(recordedSteps);
7556
7558
  const finalStep = recordedSteps[recordedSteps.length - 1];
7557
- await notify({
7558
- event: {
7559
- stepNumber: finalStep.stepNumber,
7560
- model: finalStep.model,
7561
- functionId: finalStep.functionId,
7562
- metadata: finalStep.metadata,
7563
- experimental_context: finalStep.experimental_context,
7564
- finishReason: finalStep.finishReason,
7565
- rawFinishReason: finalStep.rawFinishReason,
7566
- totalUsage,
7567
- usage: finalStep.usage,
7568
- content: finalStep.content,
7569
- text: finalStep.text,
7570
- reasoningText: finalStep.reasoningText,
7571
- reasoning: finalStep.reasoning,
7572
- files: finalStep.files,
7573
- sources: finalStep.sources,
7574
- toolCalls: finalStep.toolCalls,
7575
- staticToolCalls: finalStep.staticToolCalls,
7576
- dynamicToolCalls: finalStep.dynamicToolCalls,
7577
- toolResults: finalStep.toolResults,
7578
- staticToolResults: finalStep.staticToolResults,
7579
- dynamicToolResults: finalStep.dynamicToolResults,
7580
- request: finalStep.request,
7581
- response: finalStep.response,
7582
- warnings: finalStep.warnings,
7583
- providerMetadata: finalStep.providerMetadata,
7584
- steps: recordedSteps
7585
- },
7586
- callbacks: [
7587
- onFinish,
7588
- globalTelemetry.onFinish
7589
- ]
7590
- });
7559
+ const onFinishEvent = {
7560
+ stepNumber: finalStep.stepNumber,
7561
+ model: finalStep.model,
7562
+ functionId: finalStep.functionId,
7563
+ metadata: finalStep.metadata,
7564
+ experimental_context: finalStep.experimental_context,
7565
+ finishReason: finalStep.finishReason,
7566
+ rawFinishReason: finalStep.rawFinishReason,
7567
+ totalUsage,
7568
+ usage: finalStep.usage,
7569
+ content: finalStep.content,
7570
+ text: finalStep.text,
7571
+ reasoningText: finalStep.reasoningText,
7572
+ reasoning: finalStep.reasoning,
7573
+ files: finalStep.files,
7574
+ sources: finalStep.sources,
7575
+ toolCalls: finalStep.toolCalls,
7576
+ staticToolCalls: finalStep.staticToolCalls,
7577
+ dynamicToolCalls: finalStep.dynamicToolCalls,
7578
+ toolResults: finalStep.toolResults,
7579
+ staticToolResults: finalStep.staticToolResults,
7580
+ dynamicToolResults: finalStep.dynamicToolResults,
7581
+ request: finalStep.request,
7582
+ response: finalStep.response,
7583
+ warnings: finalStep.warnings,
7584
+ providerMetadata: finalStep.providerMetadata,
7585
+ steps: recordedSteps
7586
+ };
7587
+ const onFinishWithOutput = onFinish == null ? void 0 : async (event) => {
7588
+ const parsedOutput = output == null ? void 0 : await self.getOutputPromise().catch(() => void 0);
7589
+ await onFinish({
7590
+ ...event,
7591
+ ...output != null ? { output: parsedOutput } : {}
7592
+ });
7593
+ };
7594
+ await Promise.all([
7595
+ notify({
7596
+ event: onFinishEvent,
7597
+ callbacks: onFinishWithOutput
7598
+ }),
7599
+ notify({
7600
+ event: onFinishEvent,
7601
+ callbacks: globalTelemetry.onFinish
7602
+ })
7603
+ ]);
7591
7604
  rootSpan.setAttributes(
7592
7605
  await selectTelemetryAttributes({
7593
7606
  telemetry,
@@ -8649,19 +8662,25 @@ var DefaultStreamTextResult = class {
8649
8662
  }
8650
8663
  return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
8651
8664
  }
8665
+ getOutputPromise() {
8666
+ if (this.outputPromise == null) {
8667
+ this.outputPromise = this.finalStep.then((step) => {
8668
+ var _a23;
8669
+ const output = (_a23 = this.outputSpecification) != null ? _a23 : text();
8670
+ return output.parseCompleteOutput(
8671
+ { text: step.text },
8672
+ {
8673
+ response: step.response,
8674
+ usage: step.usage,
8675
+ finishReason: step.finishReason
8676
+ }
8677
+ );
8678
+ });
8679
+ }
8680
+ return this.outputPromise;
8681
+ }
8652
8682
  get output() {
8653
- return this.finalStep.then((step) => {
8654
- var _a23;
8655
- const output = (_a23 = this.outputSpecification) != null ? _a23 : text();
8656
- return output.parseCompleteOutput(
8657
- { text: step.text },
8658
- {
8659
- response: step.response,
8660
- usage: step.usage,
8661
- finishReason: step.finishReason
8662
- }
8663
- );
8664
- });
8683
+ return this.getOutputPromise();
8665
8684
  }
8666
8685
  toUIMessageStream({
8667
8686
  originalMessages,
@@ -9714,6 +9733,7 @@ var uiMessagesSchema = lazySchema2(
9714
9733
  approval: z8.object({
9715
9734
  id: z8.string(),
9716
9735
  approved: z8.never().optional(),
9736
+ descriptor: z8.unknown().optional(),
9717
9737
  reason: z8.never().optional(),
9718
9738
  signature: z8.string().optional()
9719
9739
  })
@@ -9732,6 +9752,7 @@ var uiMessagesSchema = lazySchema2(
9732
9752
  approval: z8.object({
9733
9753
  id: z8.string(),
9734
9754
  approved: z8.boolean(),
9755
+ descriptor: z8.unknown().optional(),
9735
9756
  reason: z8.string().optional(),
9736
9757
  signature: z8.string().optional()
9737
9758
  })
@@ -9752,6 +9773,7 @@ var uiMessagesSchema = lazySchema2(
9752
9773
  approval: z8.object({
9753
9774
  id: z8.string(),
9754
9775
  approved: z8.literal(true),
9776
+ descriptor: z8.unknown().optional(),
9755
9777
  reason: z8.string().optional(),
9756
9778
  signature: z8.string().optional()
9757
9779
  }).optional()
@@ -9772,6 +9794,7 @@ var uiMessagesSchema = lazySchema2(
9772
9794
  approval: z8.object({
9773
9795
  id: z8.string(),
9774
9796
  approved: z8.literal(true),
9797
+ descriptor: z8.unknown().optional(),
9775
9798
  reason: z8.string().optional(),
9776
9799
  signature: z8.string().optional()
9777
9800
  }).optional()
@@ -9790,6 +9813,7 @@ var uiMessagesSchema = lazySchema2(
9790
9813
  approval: z8.object({
9791
9814
  id: z8.string(),
9792
9815
  approved: z8.literal(false),
9816
+ descriptor: z8.unknown().optional(),
9793
9817
  reason: z8.string().optional(),
9794
9818
  signature: z8.string().optional()
9795
9819
  })
@@ -9831,6 +9855,7 @@ var uiMessagesSchema = lazySchema2(
9831
9855
  approval: z8.object({
9832
9856
  id: z8.string(),
9833
9857
  approved: z8.never().optional(),
9858
+ descriptor: z8.unknown().optional(),
9834
9859
  reason: z8.never().optional(),
9835
9860
  signature: z8.string().optional()
9836
9861
  })
@@ -9848,6 +9873,7 @@ var uiMessagesSchema = lazySchema2(
9848
9873
  approval: z8.object({
9849
9874
  id: z8.string(),
9850
9875
  approved: z8.boolean(),
9876
+ descriptor: z8.unknown().optional(),
9851
9877
  reason: z8.string().optional(),
9852
9878
  signature: z8.string().optional()
9853
9879
  })
@@ -9867,6 +9893,7 @@ var uiMessagesSchema = lazySchema2(
9867
9893
  approval: z8.object({
9868
9894
  id: z8.string(),
9869
9895
  approved: z8.literal(true),
9896
+ descriptor: z8.unknown().optional(),
9870
9897
  reason: z8.string().optional(),
9871
9898
  signature: z8.string().optional()
9872
9899
  }).optional()
@@ -9886,6 +9913,7 @@ var uiMessagesSchema = lazySchema2(
9886
9913
  approval: z8.object({
9887
9914
  id: z8.string(),
9888
9915
  approved: z8.literal(true),
9916
+ descriptor: z8.unknown().optional(),
9889
9917
  reason: z8.string().optional(),
9890
9918
  signature: z8.string().optional()
9891
9919
  }).optional()
@@ -9903,6 +9931,7 @@ var uiMessagesSchema = lazySchema2(
9903
9931
  approval: z8.object({
9904
9932
  id: z8.string(),
9905
9933
  approved: z8.literal(false),
9934
+ descriptor: z8.unknown().optional(),
9906
9935
  reason: z8.string().optional(),
9907
9936
  signature: z8.string().optional()
9908
9937
  })