ai 6.0.272 → 6.0.273

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.273" : "0.0.0-test";
1228
1228
 
1229
1229
  // src/util/download/download.ts
1230
1230
  var download = async ({
@@ -7554,40 +7554,51 @@ var DefaultStreamTextResult = class {
7554
7554
  self._totalUsage.resolve(totalUsage);
7555
7555
  self._steps.resolve(recordedSteps);
7556
7556
  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
- });
7557
+ const onFinishEvent = {
7558
+ stepNumber: finalStep.stepNumber,
7559
+ model: finalStep.model,
7560
+ functionId: finalStep.functionId,
7561
+ metadata: finalStep.metadata,
7562
+ experimental_context: finalStep.experimental_context,
7563
+ finishReason: finalStep.finishReason,
7564
+ rawFinishReason: finalStep.rawFinishReason,
7565
+ totalUsage,
7566
+ usage: finalStep.usage,
7567
+ content: finalStep.content,
7568
+ text: finalStep.text,
7569
+ reasoningText: finalStep.reasoningText,
7570
+ reasoning: finalStep.reasoning,
7571
+ files: finalStep.files,
7572
+ sources: finalStep.sources,
7573
+ toolCalls: finalStep.toolCalls,
7574
+ staticToolCalls: finalStep.staticToolCalls,
7575
+ dynamicToolCalls: finalStep.dynamicToolCalls,
7576
+ toolResults: finalStep.toolResults,
7577
+ staticToolResults: finalStep.staticToolResults,
7578
+ dynamicToolResults: finalStep.dynamicToolResults,
7579
+ request: finalStep.request,
7580
+ response: finalStep.response,
7581
+ warnings: finalStep.warnings,
7582
+ providerMetadata: finalStep.providerMetadata,
7583
+ steps: recordedSteps
7584
+ };
7585
+ const onFinishWithOutput = onFinish == null ? void 0 : async (event) => {
7586
+ const parsedOutput = output == null ? void 0 : await self.getOutputPromise().catch(() => void 0);
7587
+ await onFinish({
7588
+ ...event,
7589
+ ...output != null ? { output: parsedOutput } : {}
7590
+ });
7591
+ };
7592
+ await Promise.all([
7593
+ notify({
7594
+ event: onFinishEvent,
7595
+ callbacks: onFinishWithOutput
7596
+ }),
7597
+ notify({
7598
+ event: onFinishEvent,
7599
+ callbacks: globalTelemetry.onFinish
7600
+ })
7601
+ ]);
7591
7602
  rootSpan.setAttributes(
7592
7603
  await selectTelemetryAttributes({
7593
7604
  telemetry,
@@ -8649,19 +8660,25 @@ var DefaultStreamTextResult = class {
8649
8660
  }
8650
8661
  return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
8651
8662
  }
8663
+ getOutputPromise() {
8664
+ if (this.outputPromise == null) {
8665
+ this.outputPromise = this.finalStep.then((step) => {
8666
+ var _a23;
8667
+ const output = (_a23 = this.outputSpecification) != null ? _a23 : text();
8668
+ return output.parseCompleteOutput(
8669
+ { text: step.text },
8670
+ {
8671
+ response: step.response,
8672
+ usage: step.usage,
8673
+ finishReason: step.finishReason
8674
+ }
8675
+ );
8676
+ });
8677
+ }
8678
+ return this.outputPromise;
8679
+ }
8652
8680
  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
- });
8681
+ return this.getOutputPromise();
8665
8682
  }
8666
8683
  toUIMessageStream({
8667
8684
  originalMessages,