ai 6.0.217 → 6.0.218

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.218
4
+
5
+ ### Patch Changes
6
+
7
+ - ea1e95b: feat(mcp): add maxRetries option for failed mcp tool calls
8
+ - Updated dependencies [ea1e95b]
9
+ - @ai-sdk/provider-utils@4.0.35
10
+ - @ai-sdk/gateway@3.0.142
11
+
3
12
  ## 6.0.217
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1281,7 +1281,7 @@ function detectMediaType({
1281
1281
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
1282
1282
 
1283
1283
  // src/version.ts
1284
- var VERSION = true ? "6.0.217" : "0.0.0-test";
1284
+ var VERSION = true ? "6.0.218" : "0.0.0-test";
1285
1285
 
1286
1286
  // src/util/download/download.ts
1287
1287
  var download = async ({
@@ -2812,66 +2812,18 @@ var retryWithExponentialBackoffRespectingRetryHeaders = ({
2812
2812
  initialDelayInMs = 2e3,
2813
2813
  backoffFactor = 2,
2814
2814
  abortSignal
2815
- } = {}) => async (f) => _retryWithExponentialBackoff(f, {
2815
+ } = {}) => (0, import_provider_utils8.retryWithExponentialBackoff)({
2816
2816
  maxRetries,
2817
- delayInMs: initialDelayInMs,
2817
+ initialDelayInMs,
2818
2818
  backoffFactor,
2819
- abortSignal
2819
+ abortSignal,
2820
+ shouldRetry: (error) => error instanceof Error && (import_provider27.APICallError.isInstance(error) && error.isRetryable === true || import_gateway3.GatewayError.isInstance(error) && error.isRetryable === true),
2821
+ getDelayInMs: ({ error, exponentialBackoffDelay }) => getRetryDelayInMs({
2822
+ error,
2823
+ exponentialBackoffDelay
2824
+ }),
2825
+ createRetryError: ({ message, reason, errors }) => new RetryError({ message, reason, errors })
2820
2826
  });
2821
- async function _retryWithExponentialBackoff(f, {
2822
- maxRetries,
2823
- delayInMs,
2824
- backoffFactor,
2825
- abortSignal
2826
- }, errors = []) {
2827
- try {
2828
- return await f();
2829
- } catch (error) {
2830
- if ((0, import_provider_utils8.isAbortError)(error)) {
2831
- throw error;
2832
- }
2833
- if (maxRetries === 0) {
2834
- throw error;
2835
- }
2836
- const errorMessage = (0, import_provider_utils8.getErrorMessage)(error);
2837
- const newErrors = [...errors, error];
2838
- const tryNumber = newErrors.length;
2839
- if (tryNumber > maxRetries) {
2840
- throw new RetryError({
2841
- message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
2842
- reason: "maxRetriesExceeded",
2843
- errors: newErrors
2844
- });
2845
- }
2846
- if (error instanceof Error && (import_provider27.APICallError.isInstance(error) && error.isRetryable === true || import_gateway3.GatewayError.isInstance(error) && error.isRetryable === true) && tryNumber <= maxRetries) {
2847
- await (0, import_provider_utils8.delay)(
2848
- getRetryDelayInMs({
2849
- error,
2850
- exponentialBackoffDelay: delayInMs
2851
- }),
2852
- { abortSignal }
2853
- );
2854
- return _retryWithExponentialBackoff(
2855
- f,
2856
- {
2857
- maxRetries,
2858
- delayInMs: backoffFactor * delayInMs,
2859
- backoffFactor,
2860
- abortSignal
2861
- },
2862
- newErrors
2863
- );
2864
- }
2865
- if (tryNumber === 1) {
2866
- throw error;
2867
- }
2868
- throw new RetryError({
2869
- message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
2870
- reason: "errorNotRetryable",
2871
- errors: newErrors
2872
- });
2873
- }
2874
- }
2875
2827
 
2876
2828
  // src/util/prepare-retries.ts
2877
2829
  function prepareRetries({
@@ -11046,12 +10998,12 @@ function simulateReadableStream({
11046
10998
  _internal
11047
10999
  }) {
11048
11000
  var _a22;
11049
- const delay2 = (_a22 = _internal == null ? void 0 : _internal.delay) != null ? _a22 : import_provider_utils31.delay;
11001
+ const delay = (_a22 = _internal == null ? void 0 : _internal.delay) != null ? _a22 : import_provider_utils31.delay;
11050
11002
  let index = 0;
11051
11003
  return new ReadableStream({
11052
11004
  async pull(controller) {
11053
11005
  if (index < chunks.length) {
11054
- await delay2(index === 0 ? initialDelayInMs : chunkDelayInMs);
11006
+ await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);
11055
11007
  controller.enqueue(chunks[index++]);
11056
11008
  } else {
11057
11009
  controller.close();
@@ -11791,7 +11743,7 @@ var CHUNKING_REGEXPS = {
11791
11743
  function smoothStream({
11792
11744
  delayInMs = 10,
11793
11745
  chunking = "word",
11794
- _internal: { delay: delay2 = import_provider_utils34.delay } = {}
11746
+ _internal: { delay = import_provider_utils34.delay } = {}
11795
11747
  } = {}) {
11796
11748
  let detectChunk;
11797
11749
  if (chunking != null && typeof chunking === "object" && "segment" in chunking && typeof chunking.segment === "function") {
@@ -11872,7 +11824,7 @@ function smoothStream({
11872
11824
  while ((match = detectChunk(buffer)) != null) {
11873
11825
  controller.enqueue({ type, text: match, id });
11874
11826
  buffer = buffer.slice(match.length);
11875
- await delay2(delayInMs);
11827
+ await delay(delayInMs);
11876
11828
  }
11877
11829
  }
11878
11830
  });