ai 6.0.13 → 6.0.14
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 +6 -0
- package/dist/index.d.mts +20 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.js +51 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +5 -0
- package/dist/internal/index.d.ts +5 -0
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1006,6 +1006,11 @@ type CallSettings = {
|
|
|
1006
1006
|
*/
|
|
1007
1007
|
abortSignal?: AbortSignal;
|
|
1008
1008
|
/**
|
|
1009
|
+
Timeout in milliseconds. The call will be aborted if it takes longer
|
|
1010
|
+
than the specified timeout. Can be used alongside abortSignal.
|
|
1011
|
+
*/
|
|
1012
|
+
timeout?: number;
|
|
1013
|
+
/**
|
|
1009
1014
|
Additional HTTP headers to be sent with the request.
|
|
1010
1015
|
Only applicable for HTTP-based providers.
|
|
1011
1016
|
*/
|
|
@@ -1317,6 +1322,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
1317
1322
|
|
|
1318
1323
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
|
1319
1324
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
|
1325
|
+
@param timeout - An optional timeout in milliseconds. The call will be aborted if it takes longer than the specified timeout.
|
|
1320
1326
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
|
1321
1327
|
|
|
1322
1328
|
@param experimental_generateMessageId - Generate a unique ID for each message.
|
|
@@ -1327,7 +1333,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
1327
1333
|
@returns
|
|
1328
1334
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
1329
1335
|
*/
|
|
1330
|
-
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, _internal: { generateId, currentDate, }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1336
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, _internal: { generateId, currentDate, }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1331
1337
|
/**
|
|
1332
1338
|
The language model to use.
|
|
1333
1339
|
*/
|
|
@@ -2611,6 +2617,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
2611
2617
|
|
|
2612
2618
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
|
2613
2619
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
|
2620
|
+
@param timeout - An optional timeout in milliseconds. The call will be aborted if it takes longer than the specified timeout.
|
|
2614
2621
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
|
2615
2622
|
|
|
2616
2623
|
@param onChunk - Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
|
@@ -2621,7 +2628,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
2621
2628
|
@return
|
|
2622
2629
|
A result object for accessing different stream types and additional information.
|
|
2623
2630
|
*/
|
|
2624
|
-
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
|
2631
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
|
2625
2632
|
/**
|
|
2626
2633
|
The language model to use.
|
|
2627
2634
|
*/
|
|
@@ -2784,6 +2791,10 @@ type AgentCallParameters<CALL_OPTIONS> = ([CALL_OPTIONS] extends [never] ? {
|
|
|
2784
2791
|
* Abort signal.
|
|
2785
2792
|
*/
|
|
2786
2793
|
abortSignal?: AbortSignal;
|
|
2794
|
+
/**
|
|
2795
|
+
* Timeout in milliseconds.
|
|
2796
|
+
*/
|
|
2797
|
+
timeout?: number;
|
|
2787
2798
|
};
|
|
2788
2799
|
/**
|
|
2789
2800
|
* Parameters for streaming an output from an agent.
|
|
@@ -2979,11 +2990,11 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OU
|
|
|
2979
2990
|
/**
|
|
2980
2991
|
* Generates an output from the agent (non-streaming).
|
|
2981
2992
|
*/
|
|
2982
|
-
generate({ abortSignal, ...options }: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2993
|
+
generate({ abortSignal, timeout, ...options }: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2983
2994
|
/**
|
|
2984
2995
|
* Streams an output from the agent (streaming).
|
|
2985
2996
|
*/
|
|
2986
|
-
stream({ abortSignal, experimental_transform, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
|
|
2997
|
+
stream({ abortSignal, timeout, experimental_transform, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
|
|
2987
2998
|
}
|
|
2988
2999
|
|
|
2989
3000
|
/**
|
|
@@ -3008,6 +3019,7 @@ declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
3008
3019
|
agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
|
|
3009
3020
|
uiMessages: unknown[];
|
|
3010
3021
|
abortSignal?: AbortSignal;
|
|
3022
|
+
timeout?: number;
|
|
3011
3023
|
options?: CALL_OPTIONS;
|
|
3012
3024
|
experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
|
|
3013
3025
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<Response>;
|
|
@@ -3718,15 +3730,17 @@ declare const UI_MESSAGE_STREAM_HEADERS: {
|
|
|
3718
3730
|
* @param agent - The agent to run.
|
|
3719
3731
|
* @param uiMessages - The input UI messages.
|
|
3720
3732
|
* @param abortSignal - The abort signal. Optional.
|
|
3733
|
+
* @param timeout - Timeout in milliseconds. Optional.
|
|
3721
3734
|
* @param options - The options for the agent.
|
|
3722
3735
|
* @param experimental_transform - The stream transformations. Optional.
|
|
3723
3736
|
*
|
|
3724
3737
|
* @returns The UI message stream.
|
|
3725
3738
|
*/
|
|
3726
|
-
declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends Output = never, MESSAGE_METADATA = unknown>({ agent, uiMessages, options, abortSignal, experimental_transform, ...uiMessageStreamOptions }: {
|
|
3739
|
+
declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends Output = never, MESSAGE_METADATA = unknown>({ agent, uiMessages, options, abortSignal, timeout, experimental_transform, ...uiMessageStreamOptions }: {
|
|
3727
3740
|
agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
|
|
3728
3741
|
uiMessages: unknown[];
|
|
3729
3742
|
abortSignal?: AbortSignal;
|
|
3743
|
+
timeout?: number;
|
|
3730
3744
|
options?: CALL_OPTIONS;
|
|
3731
3745
|
experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
|
|
3732
3746
|
} & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<AsyncIterableStream<InferUIMessageChunk<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>>>;
|
|
@@ -3742,6 +3756,7 @@ declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
3742
3756
|
agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
|
|
3743
3757
|
uiMessages: unknown[];
|
|
3744
3758
|
abortSignal?: AbortSignal;
|
|
3759
|
+
timeout?: number;
|
|
3745
3760
|
options?: CALL_OPTIONS;
|
|
3746
3761
|
experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
|
|
3747
3762
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1006,6 +1006,11 @@ type CallSettings = {
|
|
|
1006
1006
|
*/
|
|
1007
1007
|
abortSignal?: AbortSignal;
|
|
1008
1008
|
/**
|
|
1009
|
+
Timeout in milliseconds. The call will be aborted if it takes longer
|
|
1010
|
+
than the specified timeout. Can be used alongside abortSignal.
|
|
1011
|
+
*/
|
|
1012
|
+
timeout?: number;
|
|
1013
|
+
/**
|
|
1009
1014
|
Additional HTTP headers to be sent with the request.
|
|
1010
1015
|
Only applicable for HTTP-based providers.
|
|
1011
1016
|
*/
|
|
@@ -1317,6 +1322,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
1317
1322
|
|
|
1318
1323
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
|
1319
1324
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
|
1325
|
+
@param timeout - An optional timeout in milliseconds. The call will be aborted if it takes longer than the specified timeout.
|
|
1320
1326
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
|
1321
1327
|
|
|
1322
1328
|
@param experimental_generateMessageId - Generate a unique ID for each message.
|
|
@@ -1327,7 +1333,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
1327
1333
|
@returns
|
|
1328
1334
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
1329
1335
|
*/
|
|
1330
|
-
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, _internal: { generateId, currentDate, }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1336
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, _internal: { generateId, currentDate, }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1331
1337
|
/**
|
|
1332
1338
|
The language model to use.
|
|
1333
1339
|
*/
|
|
@@ -2611,6 +2617,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
2611
2617
|
|
|
2612
2618
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
|
2613
2619
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
|
2620
|
+
@param timeout - An optional timeout in milliseconds. The call will be aborted if it takes longer than the specified timeout.
|
|
2614
2621
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
|
2615
2622
|
|
|
2616
2623
|
@param onChunk - Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
|
@@ -2621,7 +2628,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
2621
2628
|
@return
|
|
2622
2629
|
A result object for accessing different stream types and additional information.
|
|
2623
2630
|
*/
|
|
2624
|
-
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
|
2631
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
|
2625
2632
|
/**
|
|
2626
2633
|
The language model to use.
|
|
2627
2634
|
*/
|
|
@@ -2784,6 +2791,10 @@ type AgentCallParameters<CALL_OPTIONS> = ([CALL_OPTIONS] extends [never] ? {
|
|
|
2784
2791
|
* Abort signal.
|
|
2785
2792
|
*/
|
|
2786
2793
|
abortSignal?: AbortSignal;
|
|
2794
|
+
/**
|
|
2795
|
+
* Timeout in milliseconds.
|
|
2796
|
+
*/
|
|
2797
|
+
timeout?: number;
|
|
2787
2798
|
};
|
|
2788
2799
|
/**
|
|
2789
2800
|
* Parameters for streaming an output from an agent.
|
|
@@ -2979,11 +2990,11 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OU
|
|
|
2979
2990
|
/**
|
|
2980
2991
|
* Generates an output from the agent (non-streaming).
|
|
2981
2992
|
*/
|
|
2982
|
-
generate({ abortSignal, ...options }: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2993
|
+
generate({ abortSignal, timeout, ...options }: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2983
2994
|
/**
|
|
2984
2995
|
* Streams an output from the agent (streaming).
|
|
2985
2996
|
*/
|
|
2986
|
-
stream({ abortSignal, experimental_transform, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
|
|
2997
|
+
stream({ abortSignal, timeout, experimental_transform, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
|
|
2987
2998
|
}
|
|
2988
2999
|
|
|
2989
3000
|
/**
|
|
@@ -3008,6 +3019,7 @@ declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
3008
3019
|
agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
|
|
3009
3020
|
uiMessages: unknown[];
|
|
3010
3021
|
abortSignal?: AbortSignal;
|
|
3022
|
+
timeout?: number;
|
|
3011
3023
|
options?: CALL_OPTIONS;
|
|
3012
3024
|
experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
|
|
3013
3025
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<Response>;
|
|
@@ -3718,15 +3730,17 @@ declare const UI_MESSAGE_STREAM_HEADERS: {
|
|
|
3718
3730
|
* @param agent - The agent to run.
|
|
3719
3731
|
* @param uiMessages - The input UI messages.
|
|
3720
3732
|
* @param abortSignal - The abort signal. Optional.
|
|
3733
|
+
* @param timeout - Timeout in milliseconds. Optional.
|
|
3721
3734
|
* @param options - The options for the agent.
|
|
3722
3735
|
* @param experimental_transform - The stream transformations. Optional.
|
|
3723
3736
|
*
|
|
3724
3737
|
* @returns The UI message stream.
|
|
3725
3738
|
*/
|
|
3726
|
-
declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends Output = never, MESSAGE_METADATA = unknown>({ agent, uiMessages, options, abortSignal, experimental_transform, ...uiMessageStreamOptions }: {
|
|
3739
|
+
declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends Output = never, MESSAGE_METADATA = unknown>({ agent, uiMessages, options, abortSignal, timeout, experimental_transform, ...uiMessageStreamOptions }: {
|
|
3727
3740
|
agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
|
|
3728
3741
|
uiMessages: unknown[];
|
|
3729
3742
|
abortSignal?: AbortSignal;
|
|
3743
|
+
timeout?: number;
|
|
3730
3744
|
options?: CALL_OPTIONS;
|
|
3731
3745
|
experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
|
|
3732
3746
|
} & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<AsyncIterableStream<InferUIMessageChunk<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>>>;
|
|
@@ -3742,6 +3756,7 @@ declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends
|
|
|
3742
3756
|
agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
|
|
3743
3757
|
uiMessages: unknown[];
|
|
3744
3758
|
abortSignal?: AbortSignal;
|
|
3759
|
+
timeout?: number;
|
|
3745
3760
|
options?: CALL_OPTIONS;
|
|
3746
3761
|
experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
|
|
3747
3762
|
} & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1001,7 +1001,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
|
1001
1001
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1002
1002
|
|
|
1003
1003
|
// src/version.ts
|
|
1004
|
-
var VERSION = true ? "6.0.
|
|
1004
|
+
var VERSION = true ? "6.0.14" : "0.0.0-test";
|
|
1005
1005
|
|
|
1006
1006
|
// src/util/download/download.ts
|
|
1007
1007
|
var download = async ({ url }) => {
|
|
@@ -3582,6 +3582,34 @@ async function toResponseMessages({
|
|
|
3582
3582
|
return responseMessages;
|
|
3583
3583
|
}
|
|
3584
3584
|
|
|
3585
|
+
// src/util/merge-abort-signals.ts
|
|
3586
|
+
function mergeAbortSignals(...signals) {
|
|
3587
|
+
const validSignals = signals.filter(
|
|
3588
|
+
(signal) => signal != null
|
|
3589
|
+
);
|
|
3590
|
+
if (validSignals.length === 0) {
|
|
3591
|
+
return void 0;
|
|
3592
|
+
}
|
|
3593
|
+
if (validSignals.length === 1) {
|
|
3594
|
+
return validSignals[0];
|
|
3595
|
+
}
|
|
3596
|
+
const controller = new AbortController();
|
|
3597
|
+
for (const signal of validSignals) {
|
|
3598
|
+
if (signal.aborted) {
|
|
3599
|
+
controller.abort(signal.reason);
|
|
3600
|
+
return controller.signal;
|
|
3601
|
+
}
|
|
3602
|
+
signal.addEventListener(
|
|
3603
|
+
"abort",
|
|
3604
|
+
() => {
|
|
3605
|
+
controller.abort(signal.reason);
|
|
3606
|
+
},
|
|
3607
|
+
{ once: true }
|
|
3608
|
+
);
|
|
3609
|
+
}
|
|
3610
|
+
return controller.signal;
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3585
3613
|
// src/generate-text/generate-text.ts
|
|
3586
3614
|
var originalGenerateId = (0, import_provider_utils15.createIdGenerator)({
|
|
3587
3615
|
prefix: "aitxt",
|
|
@@ -3596,6 +3624,7 @@ async function generateText({
|
|
|
3596
3624
|
messages,
|
|
3597
3625
|
maxRetries: maxRetriesArg,
|
|
3598
3626
|
abortSignal,
|
|
3627
|
+
timeout,
|
|
3599
3628
|
headers,
|
|
3600
3629
|
stopWhen = stepCountIs(1),
|
|
3601
3630
|
experimental_output,
|
|
@@ -3619,9 +3648,13 @@ async function generateText({
|
|
|
3619
3648
|
}) {
|
|
3620
3649
|
const model = resolveLanguageModel(modelArg);
|
|
3621
3650
|
const stopConditions = asArray(stopWhen);
|
|
3651
|
+
const mergedAbortSignal = mergeAbortSignals(
|
|
3652
|
+
abortSignal,
|
|
3653
|
+
timeout != null ? AbortSignal.timeout(timeout) : void 0
|
|
3654
|
+
);
|
|
3622
3655
|
const { maxRetries, retry } = prepareRetries({
|
|
3623
3656
|
maxRetries: maxRetriesArg,
|
|
3624
|
-
abortSignal
|
|
3657
|
+
abortSignal: mergedAbortSignal
|
|
3625
3658
|
});
|
|
3626
3659
|
const callSettings = prepareCallSettings(settings);
|
|
3627
3660
|
const headersWithUserAgent = (0, import_provider_utils15.withUserAgentSuffix)(
|
|
@@ -3678,7 +3711,7 @@ async function generateText({
|
|
|
3678
3711
|
tracer,
|
|
3679
3712
|
telemetry,
|
|
3680
3713
|
messages: initialMessages,
|
|
3681
|
-
abortSignal,
|
|
3714
|
+
abortSignal: mergedAbortSignal,
|
|
3682
3715
|
experimental_context
|
|
3683
3716
|
});
|
|
3684
3717
|
const toolContent = [];
|
|
@@ -3824,7 +3857,7 @@ async function generateText({
|
|
|
3824
3857
|
responseFormat: await (output == null ? void 0 : output.responseFormat),
|
|
3825
3858
|
prompt: promptMessages,
|
|
3826
3859
|
providerOptions: stepProviderOptions,
|
|
3827
|
-
abortSignal,
|
|
3860
|
+
abortSignal: mergedAbortSignal,
|
|
3828
3861
|
headers: headersWithUserAgent
|
|
3829
3862
|
});
|
|
3830
3863
|
const responseData = {
|
|
@@ -3900,7 +3933,7 @@ async function generateText({
|
|
|
3900
3933
|
input: toolCall.input,
|
|
3901
3934
|
toolCallId: toolCall.toolCallId,
|
|
3902
3935
|
messages: stepInputMessages,
|
|
3903
|
-
abortSignal,
|
|
3936
|
+
abortSignal: mergedAbortSignal,
|
|
3904
3937
|
experimental_context
|
|
3905
3938
|
});
|
|
3906
3939
|
}
|
|
@@ -3944,7 +3977,7 @@ async function generateText({
|
|
|
3944
3977
|
tracer,
|
|
3945
3978
|
telemetry,
|
|
3946
3979
|
messages: stepInputMessages,
|
|
3947
|
-
abortSignal,
|
|
3980
|
+
abortSignal: mergedAbortSignal,
|
|
3948
3981
|
experimental_context
|
|
3949
3982
|
})
|
|
3950
3983
|
);
|
|
@@ -5674,6 +5707,7 @@ function streamText({
|
|
|
5674
5707
|
messages,
|
|
5675
5708
|
maxRetries,
|
|
5676
5709
|
abortSignal,
|
|
5710
|
+
timeout,
|
|
5677
5711
|
headers,
|
|
5678
5712
|
stopWhen = stepCountIs(1),
|
|
5679
5713
|
experimental_output,
|
|
@@ -5708,7 +5742,10 @@ function streamText({
|
|
|
5708
5742
|
headers,
|
|
5709
5743
|
settings,
|
|
5710
5744
|
maxRetries,
|
|
5711
|
-
abortSignal
|
|
5745
|
+
abortSignal: mergeAbortSignals(
|
|
5746
|
+
abortSignal,
|
|
5747
|
+
timeout != null ? AbortSignal.timeout(timeout) : void 0
|
|
5748
|
+
),
|
|
5712
5749
|
system,
|
|
5713
5750
|
prompt,
|
|
5714
5751
|
messages,
|
|
@@ -7204,11 +7241,13 @@ var ToolLoopAgent = class {
|
|
|
7204
7241
|
*/
|
|
7205
7242
|
async generate({
|
|
7206
7243
|
abortSignal,
|
|
7244
|
+
timeout,
|
|
7207
7245
|
...options
|
|
7208
7246
|
}) {
|
|
7209
7247
|
return generateText({
|
|
7210
7248
|
...await this.prepareCall(options),
|
|
7211
|
-
abortSignal
|
|
7249
|
+
abortSignal,
|
|
7250
|
+
timeout
|
|
7212
7251
|
});
|
|
7213
7252
|
}
|
|
7214
7253
|
/**
|
|
@@ -7216,12 +7255,14 @@ var ToolLoopAgent = class {
|
|
|
7216
7255
|
*/
|
|
7217
7256
|
async stream({
|
|
7218
7257
|
abortSignal,
|
|
7258
|
+
timeout,
|
|
7219
7259
|
experimental_transform,
|
|
7220
7260
|
...options
|
|
7221
7261
|
}) {
|
|
7222
7262
|
return streamText({
|
|
7223
7263
|
...await this.prepareCall(options),
|
|
7224
7264
|
abortSignal,
|
|
7265
|
+
timeout,
|
|
7225
7266
|
experimental_transform
|
|
7226
7267
|
});
|
|
7227
7268
|
}
|
|
@@ -7975,6 +8016,7 @@ async function createAgentUIStream({
|
|
|
7975
8016
|
uiMessages,
|
|
7976
8017
|
options,
|
|
7977
8018
|
abortSignal,
|
|
8019
|
+
timeout,
|
|
7978
8020
|
experimental_transform,
|
|
7979
8021
|
...uiMessageStreamOptions
|
|
7980
8022
|
}) {
|
|
@@ -7989,6 +8031,7 @@ async function createAgentUIStream({
|
|
|
7989
8031
|
prompt: modelMessages,
|
|
7990
8032
|
options,
|
|
7991
8033
|
abortSignal,
|
|
8034
|
+
timeout,
|
|
7992
8035
|
experimental_transform
|
|
7993
8036
|
});
|
|
7994
8037
|
return result.toUIMessageStream(uiMessageStreamOptions);
|