@ai-sdk/workflow 1.0.0-beta.23 → 1.0.0-beta.26

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,42 @@
1
1
  # @ai-sdk/workflow
2
2
 
3
+ ## 1.0.0-beta.26
4
+
5
+ ### Major Changes
6
+
7
+ - 1949571: feat(ai): make experimental_telemetry stable
8
+
9
+ ### Patch Changes
10
+
11
+ - f32c750: refactoring(ai): simplify mergeAbortSignals
12
+ - Updated dependencies [f319fde]
13
+ - Updated dependencies [1949571]
14
+ - Updated dependencies [511902c]
15
+ - Updated dependencies [6542d93]
16
+ - Updated dependencies [2e98477]
17
+ - Updated dependencies [876fd3e]
18
+ - Updated dependencies [f32c750]
19
+ - ai@7.0.0-beta.111
20
+ - @ai-sdk/provider-utils@5.0.0-beta.26
21
+
22
+ ## 1.0.0-beta.25
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [72cb801]
27
+ - ai@7.0.0-beta.110
28
+
29
+ ## 1.0.0-beta.24
30
+
31
+ ### Patch Changes
32
+
33
+ - eea8d98: refactoring: rename tool execution events
34
+ - Updated dependencies [ec98264]
35
+ - Updated dependencies [eea8d98]
36
+ - Updated dependencies [75ef93e]
37
+ - ai@7.0.0-beta.109
38
+ - @ai-sdk/provider-utils@5.0.0-beta.25
39
+
3
40
  ## 1.0.0-beta.23
4
41
 
5
42
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -252,6 +252,10 @@ interface PrepareCallOptions<TTools extends ToolSet = ToolSet> extends Partial<G
252
252
  tools: TTools;
253
253
  instructions?: string | SystemModelMessage | Array<SystemModelMessage>;
254
254
  toolChoice?: ToolChoice<TTools>;
255
+ telemetry?: TelemetryOptions;
256
+ /**
257
+ * @deprecated Use `telemetry` instead. This alias will be removed in a future major release.
258
+ */
255
259
  experimental_telemetry?: TelemetryOptions;
256
260
  experimental_context?: unknown;
257
261
  messages: ModelMessage[];
@@ -303,7 +307,13 @@ interface WorkflowAgentOptions<TTools extends ToolSet = ToolSet> extends Generat
303
307
  */
304
308
  toolChoice?: ToolChoice<TTools>;
305
309
  /**
306
- * Optional telemetry configuration (experimental).
310
+ * Optional telemetry configuration.
311
+ */
312
+ telemetry?: TelemetryOptions;
313
+ /**
314
+ * Optional telemetry configuration.
315
+ *
316
+ * @deprecated Use `telemetry` instead. This alias will be removed in a future major release.
307
317
  */
308
318
  experimental_telemetry?: TelemetryOptions;
309
319
  /**
@@ -374,11 +384,11 @@ interface WorkflowAgentOptions<TTools extends ToolSet = ToolSet> extends Generat
374
384
  /**
375
385
  * Callback called before a tool's execute function runs.
376
386
  */
377
- experimental_onToolCallStart?: WorkflowAgentOnToolCallStartCallback;
387
+ experimental_onToolExecutionStart?: WorkflowAgentOnToolExecutionStartCallback;
378
388
  /**
379
389
  * Callback called after a tool execution completes.
380
390
  */
381
- experimental_onToolCallFinish?: WorkflowAgentOnToolCallFinishCallback;
391
+ experimental_onToolExecutionEnd?: WorkflowAgentOnToolExecutionEndCallback;
382
392
  /**
383
393
  * Prepare the parameters for the stream call.
384
394
  * Called once before the agent loop starts. Use this to transform
@@ -460,7 +470,7 @@ type WorkflowAgentOnStepStartCallback<TTools extends ToolSet = ToolSet> = (event
460
470
  /**
461
471
  * Callback that is called before a tool's execute function runs.
462
472
  */
463
- type WorkflowAgentOnToolCallStartCallback = (event: {
473
+ type WorkflowAgentOnToolExecutionStartCallback = (event: {
464
474
  /** The tool call being executed */
465
475
  readonly toolCall: ToolCall;
466
476
  /** The current step number (0-based) */
@@ -471,7 +481,7 @@ type WorkflowAgentOnToolCallStartCallback = (event: {
471
481
  * Uses a discriminated union pattern: check `success` to determine
472
482
  * whether `output` or `error` is available.
473
483
  */
474
- type WorkflowAgentOnToolCallFinishCallback = (event: {
484
+ type WorkflowAgentOnToolExecutionEndCallback = (event: {
475
485
  /** The tool call that was executed */
476
486
  readonly toolCall: ToolCall;
477
487
  /** The current step number (0-based) */
@@ -569,7 +579,13 @@ type WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, OUTPUT = never
569
579
  */
570
580
  activeTools?: Array<keyof NoInfer<TTools>>;
571
581
  /**
572
- * Optional telemetry configuration (experimental).
582
+ * Optional telemetry configuration.
583
+ */
584
+ telemetry?: TelemetryOptions;
585
+ /**
586
+ * Optional telemetry configuration.
587
+ *
588
+ * @deprecated Use `telemetry` instead. This alias will be removed in a future major release.
573
589
  */
574
590
  experimental_telemetry?: TelemetryOptions;
575
591
  /**
@@ -653,11 +669,11 @@ type WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, OUTPUT = never
653
669
  /**
654
670
  * Callback called before a tool's execute function runs.
655
671
  */
656
- experimental_onToolCallStart?: WorkflowAgentOnToolCallStartCallback;
672
+ experimental_onToolExecutionStart?: WorkflowAgentOnToolExecutionStartCallback;
657
673
  /**
658
674
  * Callback called after a tool execution completes.
659
675
  */
660
- experimental_onToolCallFinish?: WorkflowAgentOnToolCallFinishCallback;
676
+ experimental_onToolExecutionEnd?: WorkflowAgentOnToolExecutionEndCallback;
661
677
  /**
662
678
  * Callback function called before each step in the agent loop.
663
679
  * Use this to modify settings, manage context, or inject messages dynamically.
@@ -817,8 +833,8 @@ declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet> {
817
833
  private constructorOnFinish?;
818
834
  private constructorOnStart?;
819
835
  private constructorOnStepStart?;
820
- private constructorOnToolCallStart?;
821
- private constructorOnToolCallFinish?;
836
+ private constructorOnToolExecutionStart?;
837
+ private constructorOnToolExecutionEnd?;
822
838
  private prepareCall?;
823
839
  constructor(options: WorkflowAgentOptions<TBaseTools>);
824
840
  generate(): void;
@@ -991,4 +1007,4 @@ declare class WorkflowChatTransport<UI_MESSAGE extends UIMessage> implements Cha
991
1007
  private onFinish;
992
1008
  }
993
1009
 
994
- export { type CompatibleLanguageModel, type DownloadFunction, type GenerationSettings, type InferWorkflowAgentTools, type InferWorkflowAgentUIMessage, type OutputSpecification, type PrepareCallCallback, type PrepareCallOptions, type PrepareCallResult, type PrepareStepCallback, type PrepareStepInfo, type PrepareStepResult, type ProviderOptions, type ReconnectToStreamOptions, type SendMessagesOptions, type StreamTextTransform, type TelemetryOptions, WorkflowAgent, type WorkflowAgentOnAbortCallback, type WorkflowAgentOnErrorCallback, type WorkflowAgentOnFinishCallback, type WorkflowAgentOnStartCallback, type WorkflowAgentOnStepFinishCallback, type WorkflowAgentOnStepStartCallback, type WorkflowAgentOnToolCallFinishCallback, type WorkflowAgentOnToolCallStartCallback, type WorkflowAgentOptions, type WorkflowAgentStreamOptions, type WorkflowAgentStreamResult, WorkflowChatTransport, type WorkflowChatTransportOptions, createModelCallToUIChunkTransform, toUIMessageChunk };
1010
+ export { type CompatibleLanguageModel, type DownloadFunction, type GenerationSettings, type InferWorkflowAgentTools, type InferWorkflowAgentUIMessage, type OutputSpecification, type PrepareCallCallback, type PrepareCallOptions, type PrepareCallResult, type PrepareStepCallback, type PrepareStepInfo, type PrepareStepResult, type ProviderOptions, type ReconnectToStreamOptions, type SendMessagesOptions, type StreamTextTransform, type TelemetryOptions, WorkflowAgent, type WorkflowAgentOnAbortCallback, type WorkflowAgentOnErrorCallback, type WorkflowAgentOnFinishCallback, type WorkflowAgentOnStartCallback, type WorkflowAgentOnStepFinishCallback, type WorkflowAgentOnStepStartCallback, type WorkflowAgentOnToolExecutionEndCallback, type WorkflowAgentOnToolExecutionStartCallback, type WorkflowAgentOptions, type WorkflowAgentStreamOptions, type WorkflowAgentStreamResult, WorkflowChatTransport, type WorkflowChatTransportOptions, createModelCallToUIChunkTransform, toUIMessageChunk };
package/dist/index.mjs CHANGED
@@ -279,7 +279,7 @@ async function* streamTextIterator({
279
279
  generationSettings,
280
280
  toolChoice,
281
281
  experimental_context,
282
- experimental_telemetry,
282
+ telemetry,
283
283
  includeRawChunks = false,
284
284
  repairToolCall,
285
285
  responseFormat
@@ -427,7 +427,7 @@ async function* streamTextIterator({
427
427
  ...currentGenerationSettings,
428
428
  toolChoice: currentToolChoice,
429
429
  includeRawChunks,
430
- experimental_telemetry,
430
+ telemetry,
431
431
  repairToolCall,
432
432
  responseFormat
433
433
  }
@@ -544,13 +544,13 @@ function sanitizeProviderMetadataForToolCall(metadata) {
544
544
  // src/workflow-agent.ts
545
545
  var WorkflowAgent = class {
546
546
  constructor(options) {
547
- var _a, _b;
547
+ var _a, _b, _c;
548
548
  this.id = options.id;
549
549
  this.model = options.model;
550
550
  this.tools = (_a = options.tools) != null ? _a : {};
551
551
  this.instructions = (_b = options.instructions) != null ? _b : options.system;
552
552
  this.toolChoice = options.toolChoice;
553
- this.telemetry = options.experimental_telemetry;
553
+ this.telemetry = (_c = options.telemetry) != null ? _c : options.experimental_telemetry;
554
554
  this.experimentalContext = options.experimental_context;
555
555
  this.stopWhen = options.stopWhen;
556
556
  this.activeTools = options.activeTools;
@@ -562,8 +562,8 @@ var WorkflowAgent = class {
562
562
  this.constructorOnFinish = options.onFinish;
563
563
  this.constructorOnStart = options.experimental_onStart;
564
564
  this.constructorOnStepStart = options.experimental_onStepStart;
565
- this.constructorOnToolCallStart = options.experimental_onToolCallStart;
566
- this.constructorOnToolCallFinish = options.experimental_onToolCallFinish;
565
+ this.constructorOnToolExecutionStart = options.experimental_onToolExecutionStart;
566
+ this.constructorOnToolExecutionEnd = options.experimental_onToolExecutionEnd;
567
567
  this.prepareCall = options.prepareCall;
568
568
  this.generationSettings = {
569
569
  maxOutputTokens: options.maxOutputTokens,
@@ -584,7 +584,7 @@ var WorkflowAgent = class {
584
584
  throw new Error("Not implemented");
585
585
  }
586
586
  async stream(options) {
587
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
587
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C;
588
588
  let effectiveModel = this.model;
589
589
  let effectiveInstructions = (_a = options.system) != null ? _a : this.instructions;
590
590
  let effectivePrompt = options.prompt;
@@ -592,14 +592,15 @@ var WorkflowAgent = class {
592
592
  let effectiveGenerationSettings = { ...this.generationSettings };
593
593
  let effectiveExperimentalContext = (_b = options.experimental_context) != null ? _b : this.experimentalContext;
594
594
  let effectiveToolChoiceFromPrepare = (_c = options.toolChoice) != null ? _c : this.toolChoice;
595
- let effectiveTelemetryFromPrepare = (_d = options.experimental_telemetry) != null ? _d : this.telemetry;
596
- const resolvedMessagesForPrepareCall = (_e = effectiveMessages != null ? effectiveMessages : typeof effectivePrompt === "string" ? [{ role: "user", content: effectivePrompt }] : effectivePrompt) != null ? _e : [];
595
+ let effectiveTelemetryFromPrepare = (_e = (_d = options.telemetry) != null ? _d : options.experimental_telemetry) != null ? _e : this.telemetry;
596
+ const resolvedMessagesForPrepareCall = (_f = effectiveMessages != null ? effectiveMessages : typeof effectivePrompt === "string" ? [{ role: "user", content: effectivePrompt }] : effectivePrompt) != null ? _f : [];
597
597
  if (this.prepareCall) {
598
598
  const prepared = await this.prepareCall({
599
599
  model: effectiveModel,
600
600
  tools: this.tools,
601
601
  instructions: effectiveInstructions,
602
602
  toolChoice: effectiveToolChoiceFromPrepare,
603
+ telemetry: effectiveTelemetryFromPrepare,
603
604
  experimental_telemetry: effectiveTelemetryFromPrepare,
604
605
  experimental_context: effectiveExperimentalContext,
605
606
  messages: resolvedMessagesForPrepareCall,
@@ -616,7 +617,9 @@ var WorkflowAgent = class {
616
617
  effectiveExperimentalContext = prepared.experimental_context;
617
618
  if (prepared.toolChoice !== void 0)
618
619
  effectiveToolChoiceFromPrepare = prepared.toolChoice;
619
- if (prepared.experimental_telemetry !== void 0)
620
+ if (prepared.telemetry !== void 0)
621
+ effectiveTelemetryFromPrepare = prepared.telemetry;
622
+ else if (prepared.experimental_telemetry !== void 0)
620
623
  effectiveTelemetryFromPrepare = prepared.experimental_telemetry;
621
624
  if (prepared.maxOutputTokens !== void 0)
622
625
  effectiveGenerationSettings.maxOutputTokens = prepared.maxOutputTokens;
@@ -737,11 +740,11 @@ var WorkflowAgent = class {
737
740
  const modelPrompt = await convertToLanguageModelPrompt({
738
741
  prompt,
739
742
  supportedUrls: {},
740
- download: (_f = options.experimental_download) != null ? _f : this.experimentalDownload
743
+ download: (_g = options.experimental_download) != null ? _g : this.experimentalDownload
741
744
  });
742
745
  const effectiveAbortSignal = mergeAbortSignals(
743
- (_g = options.abortSignal) != null ? _g : effectiveGenerationSettings.abortSignal,
744
- options.timeout != null ? AbortSignal.timeout(options.timeout) : void 0
746
+ (_h = options.abortSignal) != null ? _h : effectiveGenerationSettings.abortSignal,
747
+ options.timeout
745
748
  );
746
749
  const mergedGenerationSettings = {
747
750
  ...effectiveGenerationSettings,
@@ -790,21 +793,21 @@ var WorkflowAgent = class {
790
793
  this.constructorOnStepStart,
791
794
  options.experimental_onStepStart
792
795
  );
793
- const mergedOnToolCallStart = mergeCallbacks(
794
- this.constructorOnToolCallStart,
795
- options.experimental_onToolCallStart
796
+ const mergedOnToolExecutionStart = mergeCallbacks(
797
+ this.constructorOnToolExecutionStart,
798
+ options.experimental_onToolExecutionStart
796
799
  );
797
- const mergedOnToolCallFinish = mergeCallbacks(
798
- this.constructorOnToolCallFinish,
799
- options.experimental_onToolCallFinish
800
+ const mergedOnToolExecutionEnd = mergeCallbacks(
801
+ this.constructorOnToolExecutionEnd,
802
+ options.experimental_onToolExecutionEnd
800
803
  );
801
804
  const effectiveToolChoice = effectiveToolChoiceFromPrepare;
802
805
  const effectiveTelemetry = effectiveTelemetryFromPrepare;
803
- const effectiveActiveTools = (_h = options.activeTools) != null ? _h : this.activeTools;
804
- const effectiveTools = effectiveActiveTools && effectiveActiveTools.length > 0 ? (_i = filterActiveTools2({
806
+ const effectiveActiveTools = (_i = options.activeTools) != null ? _i : this.activeTools;
807
+ const effectiveTools = effectiveActiveTools && effectiveActiveTools.length > 0 ? (_j = filterActiveTools2({
805
808
  tools: this.tools,
806
809
  activeTools: effectiveActiveTools
807
- })) != null ? _i : this.tools : this.tools;
810
+ })) != null ? _j : this.tools : this.tools;
808
811
  let experimentalContext = effectiveExperimentalContext;
809
812
  const steps = [];
810
813
  let lastStepToolCalls = [];
@@ -822,8 +825,8 @@ var WorkflowAgent = class {
822
825
  toolName: toolCall.toolName,
823
826
  input: toolCall.input
824
827
  };
825
- if (mergedOnToolCallStart) {
826
- await mergedOnToolCallStart({
828
+ if (mergedOnToolExecutionStart) {
829
+ await mergedOnToolExecutionStart({
827
830
  toolCall: toolCallEvent,
828
831
  stepNumber: currentStepNumber
829
832
  });
@@ -834,8 +837,8 @@ var WorkflowAgent = class {
834
837
  result = await executeTool(toolCall, tools, messages2, context);
835
838
  } catch (err) {
836
839
  const durationMs2 = Date.now() - startTime;
837
- if (mergedOnToolCallFinish) {
838
- await mergedOnToolCallFinish({
840
+ if (mergedOnToolExecutionEnd) {
841
+ await mergedOnToolExecutionEnd({
839
842
  toolCall: toolCallEvent,
840
843
  stepNumber: currentStepNumber,
841
844
  durationMs: durationMs2,
@@ -846,10 +849,10 @@ var WorkflowAgent = class {
846
849
  throw err;
847
850
  }
848
851
  const durationMs = Date.now() - startTime;
849
- if (mergedOnToolCallFinish) {
852
+ if (mergedOnToolExecutionEnd) {
850
853
  const isError = result.output && "type" in result.output && (result.output.type === "error-text" || result.output.type === "error-json");
851
854
  if (isError) {
852
- await mergedOnToolCallFinish({
855
+ await mergedOnToolExecutionEnd({
853
856
  toolCall: toolCallEvent,
854
857
  stepNumber: currentStepNumber,
855
858
  durationMs,
@@ -857,7 +860,7 @@ var WorkflowAgent = class {
857
860
  error: "value" in result.output ? result.output.value : void 0
858
861
  });
859
862
  } else {
860
- await mergedOnToolCallFinish({
863
+ await mergedOnToolExecutionEnd({
861
864
  toolCall: toolCallEvent,
862
865
  stepNumber: currentStepNumber,
863
866
  durationMs,
@@ -868,7 +871,7 @@ var WorkflowAgent = class {
868
871
  }
869
872
  return result;
870
873
  };
871
- if ((_j = mergedGenerationSettings.abortSignal) == null ? void 0 : _j.aborted) {
874
+ if ((_k = mergedGenerationSettings.abortSignal) == null ? void 0 : _k.aborted) {
872
875
  if (options.onAbort) {
873
876
  await options.onAbort({ steps });
874
877
  }
@@ -885,18 +888,18 @@ var WorkflowAgent = class {
885
888
  tools: effectiveTools,
886
889
  writable: options.writable,
887
890
  prompt: modelPrompt,
888
- stopConditions: (_k = options.stopWhen) != null ? _k : this.stopWhen,
891
+ stopConditions: (_l = options.stopWhen) != null ? _l : this.stopWhen,
889
892
  onStepFinish: mergedOnStepFinish,
890
893
  onStepStart: mergedOnStepStart,
891
894
  onError: options.onError,
892
- prepareStep: (_l = options.prepareStep) != null ? _l : this.prepareStep,
895
+ prepareStep: (_m = options.prepareStep) != null ? _m : this.prepareStep,
893
896
  generationSettings: mergedGenerationSettings,
894
897
  toolChoice: effectiveToolChoice,
895
898
  experimental_context: experimentalContext,
896
- experimental_telemetry: effectiveTelemetry,
897
- includeRawChunks: (_m = options.includeRawChunks) != null ? _m : false,
898
- repairToolCall: (_n = options.experimental_repairToolCall) != null ? _n : this.experimentalRepairToolCall,
899
- responseFormat: await ((_p = (_o = options.output) != null ? _o : this.output) == null ? void 0 : _p.responseFormat)
899
+ telemetry: effectiveTelemetry,
900
+ includeRawChunks: (_n = options.includeRawChunks) != null ? _n : false,
901
+ repairToolCall: (_o = options.experimental_repairToolCall) != null ? _o : this.experimentalRepairToolCall,
902
+ responseFormat: await ((_q = (_p = options.output) != null ? _p : this.output) == null ? void 0 : _q.responseFormat)
900
903
  });
901
904
  let finalMessages;
902
905
  let encounteredError;
@@ -904,7 +907,7 @@ var WorkflowAgent = class {
904
907
  try {
905
908
  let result = await iterator.next();
906
909
  while (!result.done) {
907
- if ((_q = mergedGenerationSettings.abortSignal) == null ? void 0 : _q.aborted) {
910
+ if ((_r = mergedGenerationSettings.abortSignal) == null ? void 0 : _r.aborted) {
908
911
  wasAborted = true;
909
912
  if (options.onAbort) {
910
913
  await options.onAbort({ steps });
@@ -999,8 +1002,8 @@ var WorkflowAgent = class {
999
1002
  await mergedOnFinish({
1000
1003
  steps,
1001
1004
  messages: messages2,
1002
- text: (_r = lastStep == null ? void 0 : lastStep.text) != null ? _r : "",
1003
- finishReason: (_s = lastStep == null ? void 0 : lastStep.finishReason) != null ? _s : "other",
1005
+ text: (_s = lastStep == null ? void 0 : lastStep.text) != null ? _s : "",
1006
+ finishReason: (_t = lastStep == null ? void 0 : lastStep.finishReason) != null ? _t : "other",
1004
1007
  totalUsage: aggregateUsage(steps),
1005
1008
  experimental_context: experimentalContext,
1006
1009
  output: void 0
@@ -1024,8 +1027,8 @@ var WorkflowAgent = class {
1024
1027
  }
1025
1028
  }
1026
1029
  if (options.writable) {
1027
- const sendFinish = (_t = options.sendFinish) != null ? _t : true;
1028
- const preventClose = (_u = options.preventClose) != null ? _u : false;
1030
+ const sendFinish = (_u = options.sendFinish) != null ? _u : true;
1031
+ const preventClose = (_v = options.preventClose) != null ? _v : false;
1029
1032
  if (sendFinish || !preventClose) {
1030
1033
  await closeStream(options.writable, preventClose, sendFinish);
1031
1034
  }
@@ -1120,7 +1123,7 @@ var WorkflowAgent = class {
1120
1123
  }
1121
1124
  }
1122
1125
  const messages = finalMessages != null ? finalMessages : prompt.messages;
1123
- const effectiveOutput = (_v = options.output) != null ? _v : this.output;
1126
+ const effectiveOutput = (_w = options.output) != null ? _w : this.output;
1124
1127
  let experimentalOutput = void 0;
1125
1128
  if (effectiveOutput && steps.length > 0) {
1126
1129
  const lastStep = steps[steps.length - 1];
@@ -1147,8 +1150,8 @@ var WorkflowAgent = class {
1147
1150
  await mergedOnFinish({
1148
1151
  steps,
1149
1152
  messages,
1150
- text: (_w = lastStep == null ? void 0 : lastStep.text) != null ? _w : "",
1151
- finishReason: (_x = lastStep == null ? void 0 : lastStep.finishReason) != null ? _x : "other",
1153
+ text: (_x = lastStep == null ? void 0 : lastStep.text) != null ? _x : "",
1154
+ finishReason: (_y = lastStep == null ? void 0 : lastStep.finishReason) != null ? _y : "other",
1152
1155
  totalUsage: aggregateUsage(steps),
1153
1156
  experimental_context: experimentalContext,
1154
1157
  output: experimentalOutput
@@ -1156,8 +1159,8 @@ var WorkflowAgent = class {
1156
1159
  }
1157
1160
  if (encounteredError) {
1158
1161
  if (options.writable) {
1159
- const sendFinish = (_y = options.sendFinish) != null ? _y : true;
1160
- const preventClose = (_z = options.preventClose) != null ? _z : false;
1162
+ const sendFinish = (_z = options.sendFinish) != null ? _z : true;
1163
+ const preventClose = (_A = options.preventClose) != null ? _A : false;
1161
1164
  if (sendFinish || !preventClose) {
1162
1165
  await closeStream(options.writable, preventClose, sendFinish);
1163
1166
  }
@@ -1165,8 +1168,8 @@ var WorkflowAgent = class {
1165
1168
  throw encounteredError;
1166
1169
  }
1167
1170
  if (options.writable) {
1168
- const sendFinish = (_A = options.sendFinish) != null ? _A : true;
1169
- const preventClose = (_B = options.preventClose) != null ? _B : false;
1171
+ const sendFinish = (_B = options.sendFinish) != null ? _B : true;
1172
+ const preventClose = (_C = options.preventClose) != null ? _C : false;
1170
1173
  if (sendFinish || !preventClose) {
1171
1174
  await closeStream(options.writable, preventClose, sendFinish);
1172
1175
  }