@voltagent/core 2.6.0 → 2.6.1

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.d.mts CHANGED
@@ -9410,6 +9410,9 @@ declare class Agent {
9410
9410
  private executeWithModelFallback;
9411
9411
  private probeStreamStart;
9412
9412
  private cloneResultWithFullStream;
9413
+ private withProbedFullStream;
9414
+ private usesGetterBasedTeeingFullStream;
9415
+ private findPropertyDescriptor;
9413
9416
  private toAsyncIterableStream;
9414
9417
  private discardStream;
9415
9418
  /**
package/dist/index.d.ts CHANGED
@@ -9410,6 +9410,9 @@ declare class Agent {
9410
9410
  private executeWithModelFallback;
9411
9411
  private probeStreamStart;
9412
9412
  private cloneResultWithFullStream;
9413
+ private withProbedFullStream;
9414
+ private usesGetterBasedTeeingFullStream;
9415
+ private findPropertyDescriptor;
9413
9416
  private toAsyncIterableStream;
9414
9417
  private discardStream;
9415
9418
  /**
package/dist/index.js CHANGED
@@ -31223,8 +31223,13 @@ var Agent = class {
31223
31223
  );
31224
31224
  }, "onFinish")
31225
31225
  });
31226
- const probeResult = await this.probeStreamStart(streamResult.fullStream, attemptState);
31227
- const streamResultForConsumption = probeResult.stream === streamResult.fullStream ? streamResult : this.cloneResultWithFullStream(streamResult, probeResult.stream);
31226
+ const originalFullStream = streamResult.fullStream;
31227
+ const probeResult = await this.probeStreamStart(originalFullStream, attemptState);
31228
+ const streamResultForConsumption = this.withProbedFullStream(
31229
+ streamResult,
31230
+ originalFullStream,
31231
+ probeResult.stream
31232
+ );
31228
31233
  if (probeResult.status === "error") {
31229
31234
  this.discardStream(streamResultForConsumption.fullStream);
31230
31235
  const fallbackEligible = this.shouldFallbackOnError(probeResult.error);
@@ -32095,8 +32100,13 @@ var Agent = class {
32095
32100
  }
32096
32101
  }, "onFinish")
32097
32102
  });
32098
- const probeResult = await this.probeStreamStart(streamResult.fullStream, attemptState);
32099
- const streamResultForConsumption = probeResult.stream === streamResult.fullStream ? streamResult : this.cloneResultWithFullStream(streamResult, probeResult.stream);
32103
+ const originalFullStream = streamResult.fullStream;
32104
+ const probeResult = await this.probeStreamStart(originalFullStream, attemptState);
32105
+ const streamResultForConsumption = this.withProbedFullStream(
32106
+ streamResult,
32107
+ originalFullStream,
32108
+ probeResult.stream
32109
+ );
32100
32110
  if (probeResult.status === "error") {
32101
32111
  this.discardStream(streamResultForConsumption.fullStream);
32102
32112
  const fallbackEligible = this.shouldFallbackOnError(probeResult.error);
@@ -33713,6 +33723,30 @@ ${retrieverContext}`;
33713
33723
  });
33714
33724
  return clone;
33715
33725
  }
33726
+ withProbedFullStream(result, originalFullStream, probedFullStream) {
33727
+ if (probedFullStream === originalFullStream) {
33728
+ return result;
33729
+ }
33730
+ if (this.usesGetterBasedTeeingFullStream(result)) {
33731
+ return result;
33732
+ }
33733
+ return this.cloneResultWithFullStream(result, probedFullStream);
33734
+ }
33735
+ usesGetterBasedTeeingFullStream(result) {
33736
+ const descriptor = this.findPropertyDescriptor(result, "fullStream");
33737
+ return typeof descriptor?.get === "function" && typeof result.teeStream === "function";
33738
+ }
33739
+ findPropertyDescriptor(target, propertyName) {
33740
+ let current = target;
33741
+ while (current) {
33742
+ const descriptor = Object.getOwnPropertyDescriptor(current, propertyName);
33743
+ if (descriptor) {
33744
+ return descriptor;
33745
+ }
33746
+ current = Object.getPrototypeOf(current);
33747
+ }
33748
+ return void 0;
33749
+ }
33716
33750
  toAsyncIterableStream(stream) {
33717
33751
  const asyncStream = stream;
33718
33752
  if (!asyncStream[Symbol.asyncIterator]) {