ai 6.0.0-beta.98 → 6.0.0-beta.99

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,11 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.0-beta.99
4
+
5
+ ### Patch Changes
6
+
7
+ - 384142c: feat(agent): add abortSignal parameter to generate and stream
8
+
3
9
  ## 6.0.0-beta.98
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2554,7 +2554,12 @@ type AgentCallParameters<CALL_OPTIONS> = ([CALL_OPTIONS] extends [never] ? {
2554
2554
  * You can either use `prompt` or `messages` but not both.
2555
2555
  */
2556
2556
  prompt?: never;
2557
- });
2557
+ }) & {
2558
+ /**
2559
+ * Abort signal.
2560
+ */
2561
+ abortSignal?: AbortSignal;
2562
+ };
2558
2563
  /**
2559
2564
  * An Agent receives a prompt (text or messages) and generates or streams an output
2560
2565
  * that consists of steps, tool calls, data parts, etc.
@@ -2612,7 +2617,7 @@ type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult
2612
2617
  /**
2613
2618
  * Configuration options for an agent.
2614
2619
  */
2615
- type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends Output = never> = CallSettings & {
2620
+ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends Output = never> = Omit<CallSettings, 'abortSignal'> & {
2616
2621
  /**
2617
2622
  * The id of the agent.
2618
2623
  */
@@ -2722,11 +2727,11 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OU
2722
2727
  /**
2723
2728
  * Generates an output from the agent (non-streaming).
2724
2729
  */
2725
- generate(options: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
2730
+ generate({ abortSignal, ...options }: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
2726
2731
  /**
2727
2732
  * Streams an output from the agent (streaming).
2728
2733
  */
2729
- stream(options: AgentCallParameters<CALL_OPTIONS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
2734
+ stream({ abortSignal, ...options }: AgentCallParameters<CALL_OPTIONS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
2730
2735
  }
2731
2736
 
2732
2737
  /**
package/dist/index.d.ts CHANGED
@@ -2554,7 +2554,12 @@ type AgentCallParameters<CALL_OPTIONS> = ([CALL_OPTIONS] extends [never] ? {
2554
2554
  * You can either use `prompt` or `messages` but not both.
2555
2555
  */
2556
2556
  prompt?: never;
2557
- });
2557
+ }) & {
2558
+ /**
2559
+ * Abort signal.
2560
+ */
2561
+ abortSignal?: AbortSignal;
2562
+ };
2558
2563
  /**
2559
2564
  * An Agent receives a prompt (text or messages) and generates or streams an output
2560
2565
  * that consists of steps, tool calls, data parts, etc.
@@ -2612,7 +2617,7 @@ type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult
2612
2617
  /**
2613
2618
  * Configuration options for an agent.
2614
2619
  */
2615
- type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends Output = never> = CallSettings & {
2620
+ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends Output = never> = Omit<CallSettings, 'abortSignal'> & {
2616
2621
  /**
2617
2622
  * The id of the agent.
2618
2623
  */
@@ -2722,11 +2727,11 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OU
2722
2727
  /**
2723
2728
  * Generates an output from the agent (non-streaming).
2724
2729
  */
2725
- generate(options: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
2730
+ generate({ abortSignal, ...options }: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
2726
2731
  /**
2727
2732
  * Streams an output from the agent (streaming).
2728
2733
  */
2729
- stream(options: AgentCallParameters<CALL_OPTIONS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
2734
+ stream({ abortSignal, ...options }: AgentCallParameters<CALL_OPTIONS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
2730
2735
  }
2731
2736
 
2732
2737
  /**
package/dist/index.js CHANGED
@@ -858,7 +858,7 @@ function detectMediaType({
858
858
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
859
859
 
860
860
  // src/version.ts
861
- var VERSION = true ? "6.0.0-beta.98" : "0.0.0-test";
861
+ var VERSION = true ? "6.0.0-beta.99" : "0.0.0-test";
862
862
 
863
863
  // src/util/download/download.ts
864
864
  var download = async ({ url }) => {
@@ -6708,14 +6708,26 @@ var ToolLoopAgent = class {
6708
6708
  /**
6709
6709
  * Generates an output from the agent (non-streaming).
6710
6710
  */
6711
- async generate(options) {
6712
- return generateText(await this.prepareCall(options));
6711
+ async generate({
6712
+ abortSignal,
6713
+ ...options
6714
+ }) {
6715
+ return generateText({
6716
+ ...await this.prepareCall(options),
6717
+ abortSignal
6718
+ });
6713
6719
  }
6714
6720
  /**
6715
6721
  * Streams an output from the agent (streaming).
6716
6722
  */
6717
- async stream(options) {
6718
- return streamText(await this.prepareCall(options));
6723
+ async stream({
6724
+ abortSignal,
6725
+ ...options
6726
+ }) {
6727
+ return streamText({
6728
+ ...await this.prepareCall(options),
6729
+ abortSignal
6730
+ });
6719
6731
  }
6720
6732
  };
6721
6733