ai 7.0.9 → 7.0.11
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 +15 -0
- package/dist/index.js +28 -75
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -3
- package/dist/internal/index.js +20 -67
- package/dist/internal/index.js.map +1 -1
- package/docs/03-ai-sdk-core/16-mcp-tools.mdx +28 -0
- package/docs/03-ai-sdk-core/26-reasoning.mdx +1 -1
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +4 -0
- package/docs/03-ai-sdk-harnesses/03-tools.mdx +49 -0
- package/docs/03-ai-sdk-harnesses/05-harness-adapters.mdx +7 -7
- package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +7 -0
- package/docs/08-migration-guides/23-migration-guide-7-0.mdx +19 -0
- package/package.json +3 -3
- package/src/telemetry/tracing-channel-publisher.ts +3 -6
- package/src/util/prepare-retries.ts +2 -4
- package/src/util/retry-with-exponential-backoff.ts +27 -95
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
2
|
import { EmbeddingModelV4Embedding, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, SharedV4ProviderMetadata, LanguageModelV4Usage, JSONObject, LanguageModelV4CallOptions, LanguageModelV4Prompt, AISDKError, LanguageModelV4ToolCall, JSONSchema7, ProviderV4, ProviderV3, ProviderV2, LanguageModelV4ToolResultOutput, LanguageModelV4ToolChoice, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool } from '@ai-sdk/provider';
|
|
3
3
|
import { GatewayModelId } from '@ai-sdk/gateway';
|
|
4
|
-
import { ModelMessage, AssistantModelMessage, ToolModelMessage, ProviderOptions, ToolSet, SystemModelMessage, Context, InferToolSetContext, Arrayable, InferToolInput, InferToolOutput, ReasoningPart, ReasoningFilePart, InferToolContext, ToolExecutionOptions, MaybePromiseLike, ToolResultOutput, Tool, Experimental_SandboxSession, ToolApprovalRequest, ToolApprovalResponse } from '@ai-sdk/provider-utils';
|
|
4
|
+
import { ModelMessage, AssistantModelMessage, ToolModelMessage, ProviderOptions, ToolSet, SystemModelMessage, Context, InferToolSetContext, Arrayable, InferToolInput, InferToolOutput, ReasoningPart, ReasoningFilePart, InferToolContext, ToolExecutionOptions, MaybePromiseLike, ToolResultOutput, Tool, Experimental_SandboxSession, RetryFunction, ToolApprovalRequest, ToolApprovalResponse } from '@ai-sdk/provider-utils';
|
|
5
5
|
export { convertAsyncIteratorToReadableStream } from '@ai-sdk/provider-utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -2570,8 +2570,6 @@ declare function prepareTools<TOOLS extends ToolSet>({ tools, toolOrder, toolsCo
|
|
|
2570
2570
|
*/
|
|
2571
2571
|
declare function prepareLanguageModelCallOptions({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, seed, stopSequences, reasoning, }: LanguageModelCallOptions): LanguageModelCallOptions;
|
|
2572
2572
|
|
|
2573
|
-
type RetryFunction = <OUTPUT>(fn: () => PromiseLike<OUTPUT>) => PromiseLike<OUTPUT>;
|
|
2574
|
-
|
|
2575
2573
|
/**
|
|
2576
2574
|
* Validate and prepare retries.
|
|
2577
2575
|
*/
|
package/dist/internal/index.js
CHANGED
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
} from "@ai-sdk/provider-utils";
|
|
84
84
|
|
|
85
85
|
// src/version.ts
|
|
86
|
-
var VERSION = true ? "7.0.
|
|
86
|
+
var VERSION = true ? "7.0.11" : "0.0.0-test";
|
|
87
87
|
|
|
88
88
|
// src/util/download/download.ts
|
|
89
89
|
var download = async ({
|
|
@@ -1590,7 +1590,9 @@ function prepareLanguageModelCallOptions({
|
|
|
1590
1590
|
// src/util/retry-with-exponential-backoff.ts
|
|
1591
1591
|
import { APICallError } from "@ai-sdk/provider";
|
|
1592
1592
|
import { GatewayError } from "@ai-sdk/gateway";
|
|
1593
|
-
import {
|
|
1593
|
+
import {
|
|
1594
|
+
retryWithExponentialBackoff
|
|
1595
|
+
} from "@ai-sdk/provider-utils";
|
|
1594
1596
|
|
|
1595
1597
|
// src/util/retry-error.ts
|
|
1596
1598
|
import { AISDKError as AISDKError5 } from "@ai-sdk/provider";
|
|
@@ -1651,66 +1653,18 @@ var retryWithExponentialBackoffRespectingRetryHeaders = ({
|
|
|
1651
1653
|
initialDelayInMs = 2e3,
|
|
1652
1654
|
backoffFactor = 2,
|
|
1653
1655
|
abortSignal
|
|
1654
|
-
} = {}) =>
|
|
1656
|
+
} = {}) => retryWithExponentialBackoff({
|
|
1655
1657
|
maxRetries,
|
|
1656
|
-
|
|
1658
|
+
initialDelayInMs,
|
|
1657
1659
|
backoffFactor,
|
|
1658
|
-
abortSignal
|
|
1660
|
+
abortSignal,
|
|
1661
|
+
shouldRetry: (error) => error instanceof Error && (APICallError.isInstance(error) && error.isRetryable === true || GatewayError.isInstance(error) && error.isRetryable === true),
|
|
1662
|
+
getDelayInMs: ({ error, exponentialBackoffDelay }) => getRetryDelayInMs({
|
|
1663
|
+
error,
|
|
1664
|
+
exponentialBackoffDelay
|
|
1665
|
+
}),
|
|
1666
|
+
createRetryError: ({ message, reason, errors }) => new RetryError({ message, reason, errors })
|
|
1659
1667
|
});
|
|
1660
|
-
async function _retryWithExponentialBackoff(f, {
|
|
1661
|
-
maxRetries,
|
|
1662
|
-
delayInMs,
|
|
1663
|
-
backoffFactor,
|
|
1664
|
-
abortSignal
|
|
1665
|
-
}, errors = []) {
|
|
1666
|
-
try {
|
|
1667
|
-
return await f();
|
|
1668
|
-
} catch (error) {
|
|
1669
|
-
if (isAbortError(error)) {
|
|
1670
|
-
throw error;
|
|
1671
|
-
}
|
|
1672
|
-
if (maxRetries === 0) {
|
|
1673
|
-
throw error;
|
|
1674
|
-
}
|
|
1675
|
-
const errorMessage = getErrorMessage2(error);
|
|
1676
|
-
const newErrors = [...errors, error];
|
|
1677
|
-
const tryNumber = newErrors.length;
|
|
1678
|
-
if (tryNumber > maxRetries) {
|
|
1679
|
-
throw new RetryError({
|
|
1680
|
-
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
1681
|
-
reason: "maxRetriesExceeded",
|
|
1682
|
-
errors: newErrors
|
|
1683
|
-
});
|
|
1684
|
-
}
|
|
1685
|
-
if (error instanceof Error && (APICallError.isInstance(error) && error.isRetryable === true || GatewayError.isInstance(error) && error.isRetryable === true) && tryNumber <= maxRetries) {
|
|
1686
|
-
await delay(
|
|
1687
|
-
getRetryDelayInMs({
|
|
1688
|
-
error,
|
|
1689
|
-
exponentialBackoffDelay: delayInMs
|
|
1690
|
-
}),
|
|
1691
|
-
{ abortSignal }
|
|
1692
|
-
);
|
|
1693
|
-
return _retryWithExponentialBackoff(
|
|
1694
|
-
f,
|
|
1695
|
-
{
|
|
1696
|
-
maxRetries,
|
|
1697
|
-
delayInMs: backoffFactor * delayInMs,
|
|
1698
|
-
backoffFactor,
|
|
1699
|
-
abortSignal
|
|
1700
|
-
},
|
|
1701
|
-
newErrors
|
|
1702
|
-
);
|
|
1703
|
-
}
|
|
1704
|
-
if (tryNumber === 1) {
|
|
1705
|
-
throw error;
|
|
1706
|
-
}
|
|
1707
|
-
throw new RetryError({
|
|
1708
|
-
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
1709
|
-
reason: "errorNotRetryable",
|
|
1710
|
-
errors: newErrors
|
|
1711
|
-
});
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
1668
|
|
|
1715
1669
|
// src/util/prepare-retries.ts
|
|
1716
1670
|
function prepareRetries({
|
|
@@ -1886,7 +1840,7 @@ var InvalidToolApprovalSignatureError = class extends AISDKError7 {
|
|
|
1886
1840
|
_a7 = symbol7;
|
|
1887
1841
|
|
|
1888
1842
|
// src/error/invalid-tool-input-error.ts
|
|
1889
|
-
import { AISDKError as AISDKError8, getErrorMessage as
|
|
1843
|
+
import { AISDKError as AISDKError8, getErrorMessage as getErrorMessage2 } from "@ai-sdk/provider";
|
|
1890
1844
|
var name8 = "AI_InvalidToolInputError";
|
|
1891
1845
|
var marker8 = `vercel.ai.error.${name8}`;
|
|
1892
1846
|
var symbol8 = Symbol.for(marker8);
|
|
@@ -1896,7 +1850,7 @@ var InvalidToolInputError = class extends AISDKError8 {
|
|
|
1896
1850
|
toolInput,
|
|
1897
1851
|
toolName,
|
|
1898
1852
|
cause,
|
|
1899
|
-
message = `Invalid input for tool ${toolName}: ${
|
|
1853
|
+
message = `Invalid input for tool ${toolName}: ${getErrorMessage2(cause)}`
|
|
1900
1854
|
}) {
|
|
1901
1855
|
super({ name: name8, message, cause });
|
|
1902
1856
|
this[_a8] = true;
|
|
@@ -1958,7 +1912,7 @@ var NoSuchToolError = class extends AISDKError10 {
|
|
|
1958
1912
|
_a10 = symbol10;
|
|
1959
1913
|
|
|
1960
1914
|
// src/error/tool-call-repair-error.ts
|
|
1961
|
-
import { AISDKError as AISDKError11, getErrorMessage as
|
|
1915
|
+
import { AISDKError as AISDKError11, getErrorMessage as getErrorMessage3 } from "@ai-sdk/provider";
|
|
1962
1916
|
var name11 = "AI_ToolCallRepairError";
|
|
1963
1917
|
var marker11 = `vercel.ai.error.${name11}`;
|
|
1964
1918
|
var symbol11 = Symbol.for(marker11);
|
|
@@ -1967,7 +1921,7 @@ var ToolCallRepairError = class extends AISDKError11 {
|
|
|
1967
1921
|
constructor({
|
|
1968
1922
|
cause,
|
|
1969
1923
|
originalError,
|
|
1970
|
-
message = `Error repairing tool call: ${
|
|
1924
|
+
message = `Error repairing tool call: ${getErrorMessage3(cause)}`
|
|
1971
1925
|
}) {
|
|
1972
1926
|
super({ name: name11, message, cause });
|
|
1973
1927
|
this[_a11] = true;
|
|
@@ -2349,10 +2303,9 @@ async function loadDiagnosticsChannel() {
|
|
|
2349
2303
|
return void 0;
|
|
2350
2304
|
}
|
|
2351
2305
|
if (diagnosticsChannelPromise == null) {
|
|
2352
|
-
diagnosticsChannelPromise =
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
).catch(() => void 0);
|
|
2306
|
+
diagnosticsChannelPromise = Promise.resolve(
|
|
2307
|
+
loadBuiltinModule("node:diagnostics_channel")
|
|
2308
|
+
);
|
|
2356
2309
|
}
|
|
2357
2310
|
return diagnosticsChannelPromise;
|
|
2358
2311
|
}
|