ai 4.0.32 → 4.0.34

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
@@ -1907,7 +1907,7 @@ var arrayOutputStrategy = (schema) => {
1907
1907
  // be able to generate an array directly:
1908
1908
  // possible future optimization: use arrays directly when model supports grammar-guided generation
1909
1909
  jsonSchema: {
1910
- $schema: "http://json-schema.org/draft-07/schema#",
1910
+ $schema: "https://json-schema.org/draft/2019-09/schema#",
1911
1911
  type: "object",
1912
1912
  properties: {
1913
1913
  elements: { type: "array", items: itemSchema }
@@ -2019,7 +2019,7 @@ var enumOutputStrategy = (enumValues) => {
2019
2019
  // be able to generate an enum value directly:
2020
2020
  // possible future optimization: use enums directly when model supports top-level enums
2021
2021
  jsonSchema: {
2022
- $schema: "http://json-schema.org/draft-07/schema#",
2022
+ $schema: "https://json-schema.org/draft/2019-09/schema#",
2023
2023
  type: "object",
2024
2024
  properties: {
2025
2025
  result: { type: "string", enum: enumValues }
@@ -2714,12 +2714,27 @@ function createStitchableStream() {
2714
2714
  innerStreamReaders.push(innerStream.getReader());
2715
2715
  waitForNewStream.resolve();
2716
2716
  },
2717
+ /**
2718
+ * Gracefully close the outer stream. This will let the inner streams
2719
+ * finish processing and then close the outer stream.
2720
+ */
2717
2721
  close: () => {
2718
2722
  isClosed = true;
2719
2723
  waitForNewStream.resolve();
2720
2724
  if (innerStreamReaders.length === 0) {
2721
2725
  controller == null ? void 0 : controller.close();
2722
2726
  }
2727
+ },
2728
+ /**
2729
+ * Immediately close the outer stream. This will cancel all inner streams
2730
+ * and close the outer stream.
2731
+ */
2732
+ terminate: () => {
2733
+ isClosed = true;
2734
+ waitForNewStream.resolve();
2735
+ innerStreamReaders.forEach((reader) => reader.cancel());
2736
+ innerStreamReaders = [];
2737
+ controller == null ? void 0 : controller.close();
2723
2738
  }
2724
2739
  };
2725
2740
  }
@@ -4419,7 +4434,7 @@ function streamText({
4419
4434
  tools,
4420
4435
  toolChoice,
4421
4436
  toolCallStreaming,
4422
- transform: transform == null ? void 0 : transform({ tools }),
4437
+ transform,
4423
4438
  activeTools,
4424
4439
  repairToolCall,
4425
4440
  maxSteps,
@@ -4693,7 +4708,14 @@ var DefaultStreamTextResult = class {
4693
4708
  this.closeStream = stitchableStream.close;
4694
4709
  let stream = stitchableStream.stream;
4695
4710
  if (transform) {
4696
- stream = stream.pipeThrough(transform);
4711
+ stream = stream.pipeThrough(
4712
+ transform({
4713
+ tools,
4714
+ stopStream() {
4715
+ stitchableStream.terminate();
4716
+ }
4717
+ })
4718
+ );
4697
4719
  }
4698
4720
  this.baseStream = stream.pipeThrough(createOutputTransformStream(output)).pipeThrough(eventProcessor);
4699
4721
  const { maxRetries, retry } = prepareRetries({