@ai-sdk/workflow 1.0.18 → 1.0.20

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,27 @@
1
1
  # @ai-sdk/workflow
2
2
 
3
+ ## 1.0.20
4
+
5
+ ### Patch Changes
6
+
7
+ - a4186d6: Promote the `repairToolCall` option to stable, with a deprecated `experimental_repairToolCall` alias for backwards compatibility.
8
+ - c29e0d7: fix (workflow): mark package as ESM so the published files match the `main`, `types`, and `exports` entrypoints in package.json. Previously `require('@ai-sdk/workflow')` failed with `MODULE_NOT_FOUND` because the declared CommonJS entrypoints were never published.
9
+ - Updated dependencies [b9ac19f]
10
+ - Updated dependencies [a4186d6]
11
+ - ai@7.0.20
12
+
13
+ ## 1.0.19
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [be7f05a]
18
+ - Updated dependencies [ee55a07]
19
+ - Updated dependencies [aad737d]
20
+ - Updated dependencies [0f93c57]
21
+ - ai@7.0.19
22
+ - @ai-sdk/provider@4.0.3
23
+ - @ai-sdk/provider-utils@5.0.7
24
+
3
25
  ## 1.0.18
4
26
 
5
27
  ### Patch Changes
@@ -358,7 +358,15 @@ type WorkflowAgentOptions<TTools extends ToolSet = ToolSet, TRuntimeContext exte
358
358
  /**
359
359
  * Default function that attempts to repair a tool call that failed to parse.
360
360
  *
361
- * Per-stream `experimental_repairToolCall` values passed to `stream()` override this default.
361
+ * Per-stream `repairToolCall` values passed to `stream()` override this default.
362
+ */
363
+ repairToolCall?: ToolCallRepairFunction<TTools>;
364
+ /**
365
+ * Default function that attempts to repair a tool call that failed to parse.
366
+ *
367
+ * Per-stream `repairToolCall` values passed to `stream()` override this default.
368
+ *
369
+ * @deprecated Use `repairToolCall` instead.
362
370
  */
363
371
  experimental_repairToolCall?: ToolCallRepairFunction<TTools>;
364
372
  /**
@@ -711,6 +719,12 @@ type WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, TRuntimeContex
711
719
  /**
712
720
  * A function that attempts to repair a tool call that failed to parse.
713
721
  */
722
+ repairToolCall?: ToolCallRepairFunction<TTools>;
723
+ /**
724
+ * A function that attempts to repair a tool call that failed to parse.
725
+ *
726
+ * @deprecated Use `repairToolCall` instead.
727
+ */
714
728
  experimental_repairToolCall?: ToolCallRepairFunction<TTools>;
715
729
  /**
716
730
  * Optional stream transformations.
@@ -936,7 +950,7 @@ declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet, TRuntimeContex
936
950
  private stopWhen?;
937
951
  private activeTools?;
938
952
  private output?;
939
- private experimentalRepairToolCall?;
953
+ private repairToolCall?;
940
954
  private experimentalDownload?;
941
955
  private experimentalSandbox?;
942
956
  private prepareStep?;
@@ -710,7 +710,7 @@ function sanitizeProviderMetadataForToolCall(metadata) {
710
710
  // src/workflow-agent.ts
711
711
  var WorkflowAgent = class {
712
712
  constructor(options) {
713
- var _a, _b, _c, _d;
713
+ var _a, _b, _c, _d, _e;
714
714
  this.id = options.id;
715
715
  this.model = options.model;
716
716
  this.tools = (_a = options.tools) != null ? _a : {};
@@ -722,11 +722,11 @@ var WorkflowAgent = class {
722
722
  this.stopWhen = options.stopWhen;
723
723
  this.activeTools = options.activeTools;
724
724
  this.output = options.output;
725
- this.experimentalRepairToolCall = options.experimental_repairToolCall;
725
+ this.repairToolCall = (_c = options.repairToolCall) != null ? _c : options.experimental_repairToolCall;
726
726
  this.experimentalDownload = options.experimental_download;
727
727
  this.experimentalSandbox = options.experimental_sandbox;
728
728
  this.prepareStep = options.prepareStep;
729
- this.constructorOnStepEnd = (_c = options.onStepEnd) != null ? _c : options.onStepFinish;
729
+ this.constructorOnStepEnd = (_d = options.onStepEnd) != null ? _d : options.onStepFinish;
730
730
  const { onFinish, onEnd = onFinish } = options;
731
731
  this.constructorOnEnd = onEnd;
732
732
  this.constructorOnStart = options.experimental_onStart;
@@ -734,7 +734,7 @@ var WorkflowAgent = class {
734
734
  this.constructorOnToolExecutionStart = options.onToolExecutionStart;
735
735
  this.constructorOnToolExecutionEnd = options.onToolExecutionEnd;
736
736
  this.prepareCall = options.prepareCall;
737
- this.allowSystemInMessages = (_d = options.allowSystemInMessages) != null ? _d : false;
737
+ this.allowSystemInMessages = (_e = options.allowSystemInMessages) != null ? _e : false;
738
738
  this.generationSettings = {
739
739
  maxOutputTokens: options.maxOutputTokens,
740
740
  temperature: options.temperature,
@@ -755,7 +755,7 @@ var WorkflowAgent = class {
755
755
  throw new Error("Not implemented");
756
756
  }
757
757
  async stream(options) {
758
- 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, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R;
758
+ 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, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S;
759
759
  const { onFinish, onEnd = onFinish } = options;
760
760
  let effectiveModel = this.model;
761
761
  let effectiveInstructions = (_a = options.system) != null ? _a : this.instructions;
@@ -1371,8 +1371,8 @@ var WorkflowAgent = class {
1371
1371
  toolsContext,
1372
1372
  telemetry: effectiveTelemetry,
1373
1373
  includeRawChunks: (_z = options.includeRawChunks) != null ? _z : false,
1374
- repairToolCall: (_A = options.experimental_repairToolCall) != null ? _A : this.experimentalRepairToolCall,
1375
- responseFormat: await ((_C = (_B = options.output) != null ? _B : this.output) == null ? void 0 : _C.responseFormat),
1374
+ repairToolCall: (_B = (_A = options.repairToolCall) != null ? _A : options.experimental_repairToolCall) != null ? _B : this.repairToolCall,
1375
+ responseFormat: await ((_D = (_C = options.output) != null ? _C : this.output) == null ? void 0 : _D.responseFormat),
1376
1376
  experimental_sandbox: sandbox
1377
1377
  });
1378
1378
  let finalMessages;
@@ -1381,7 +1381,7 @@ var WorkflowAgent = class {
1381
1381
  try {
1382
1382
  let result = await iterator.next();
1383
1383
  while (!result.done) {
1384
- if ((_D = mergedGenerationSettings.abortSignal) == null ? void 0 : _D.aborted) {
1384
+ if ((_E = mergedGenerationSettings.abortSignal) == null ? void 0 : _E.aborted) {
1385
1385
  wasAborted = true;
1386
1386
  if (options.onAbort) {
1387
1387
  await options.onAbort({ steps });
@@ -1513,12 +1513,12 @@ var WorkflowAgent = class {
1513
1513
  const messages2 = iterMessages;
1514
1514
  const lastStep2 = steps[steps.length - 1];
1515
1515
  const totalUsage2 = aggregateUsage(steps);
1516
- const finishReason2 = (_E = lastStep2 == null ? void 0 : lastStep2.finishReason) != null ? _E : "other";
1516
+ const finishReason2 = (_F = lastStep2 == null ? void 0 : lastStep2.finishReason) != null ? _F : "other";
1517
1517
  if (mergedOnEnd && !wasAborted) {
1518
1518
  await mergedOnEnd({
1519
1519
  steps,
1520
1520
  messages: messages2,
1521
- text: (_F = lastStep2 == null ? void 0 : lastStep2.text) != null ? _F : "",
1521
+ text: (_G = lastStep2 == null ? void 0 : lastStep2.text) != null ? _G : "",
1522
1522
  finishReason: finishReason2,
1523
1523
  usage: totalUsage2,
1524
1524
  totalUsage: totalUsage2,
@@ -1530,7 +1530,7 @@ var WorkflowAgent = class {
1530
1530
  if (!wasAborted && steps.length > 0) {
1531
1531
  const telemetrySteps = steps.map(normalizeStepForTelemetry2);
1532
1532
  const lastTelemetryStep = telemetrySteps[telemetrySteps.length - 1];
1533
- await ((_G = telemetryDispatcher.onEnd) == null ? void 0 : _G.call(telemetryDispatcher, {
1533
+ await ((_H = telemetryDispatcher.onEnd) == null ? void 0 : _H.call(telemetryDispatcher, {
1534
1534
  ...lastTelemetryStep,
1535
1535
  steps: telemetrySteps,
1536
1536
  usage: totalUsage2,
@@ -1555,8 +1555,8 @@ var WorkflowAgent = class {
1555
1555
  }
1556
1556
  }
1557
1557
  if (options.writable) {
1558
- const sendFinish = (_H = options.sendFinish) != null ? _H : true;
1559
- const preventClose = (_I = options.preventClose) != null ? _I : false;
1558
+ const sendFinish = (_I = options.sendFinish) != null ? _I : true;
1559
+ const preventClose = (_J = options.preventClose) != null ? _J : false;
1560
1560
  if (sendFinish || !preventClose) {
1561
1561
  await closeStream(options.writable, preventClose, sendFinish);
1562
1562
  }
@@ -1682,10 +1682,10 @@ var WorkflowAgent = class {
1682
1682
  } else if (options.onError) {
1683
1683
  await options.onError({ error });
1684
1684
  }
1685
- await ((_J = telemetryDispatcher.onError) == null ? void 0 : _J.call(telemetryDispatcher, error));
1685
+ await ((_K = telemetryDispatcher.onError) == null ? void 0 : _K.call(telemetryDispatcher, error));
1686
1686
  }
1687
1687
  const messages = finalMessages != null ? finalMessages : prompt.messages;
1688
- const effectiveOutput = (_K = options.output) != null ? _K : this.output;
1688
+ const effectiveOutput = (_L = options.output) != null ? _L : this.output;
1689
1689
  let experimentalOutput = void 0;
1690
1690
  if (effectiveOutput && steps.length > 0) {
1691
1691
  const lastStep2 = steps[steps.length - 1];
@@ -1709,12 +1709,12 @@ var WorkflowAgent = class {
1709
1709
  }
1710
1710
  const lastStep = steps[steps.length - 1];
1711
1711
  const totalUsage = aggregateUsage(steps);
1712
- const finishReason = (_L = lastStep == null ? void 0 : lastStep.finishReason) != null ? _L : "other";
1712
+ const finishReason = (_M = lastStep == null ? void 0 : lastStep.finishReason) != null ? _M : "other";
1713
1713
  if (mergedOnEnd && !wasAborted) {
1714
1714
  await mergedOnEnd({
1715
1715
  steps,
1716
1716
  messages,
1717
- text: (_M = lastStep == null ? void 0 : lastStep.text) != null ? _M : "",
1717
+ text: (_N = lastStep == null ? void 0 : lastStep.text) != null ? _N : "",
1718
1718
  finishReason,
1719
1719
  usage: totalUsage,
1720
1720
  totalUsage,
@@ -1726,7 +1726,7 @@ var WorkflowAgent = class {
1726
1726
  if (!wasAborted && steps.length > 0) {
1727
1727
  const telemetrySteps = steps.map(normalizeStepForTelemetry2);
1728
1728
  const lastTelemetryStep = telemetrySteps[telemetrySteps.length - 1];
1729
- await ((_N = telemetryDispatcher.onEnd) == null ? void 0 : _N.call(telemetryDispatcher, {
1729
+ await ((_O = telemetryDispatcher.onEnd) == null ? void 0 : _O.call(telemetryDispatcher, {
1730
1730
  ...lastTelemetryStep,
1731
1731
  steps: telemetrySteps,
1732
1732
  usage: totalUsage,
@@ -1735,8 +1735,8 @@ var WorkflowAgent = class {
1735
1735
  }
1736
1736
  if (encounteredError) {
1737
1737
  if (options.writable) {
1738
- const sendFinish = (_O = options.sendFinish) != null ? _O : true;
1739
- const preventClose = (_P = options.preventClose) != null ? _P : false;
1738
+ const sendFinish = (_P = options.sendFinish) != null ? _P : true;
1739
+ const preventClose = (_Q = options.preventClose) != null ? _Q : false;
1740
1740
  if (sendFinish || !preventClose) {
1741
1741
  await closeStream(options.writable, preventClose, sendFinish);
1742
1742
  }
@@ -1744,8 +1744,8 @@ var WorkflowAgent = class {
1744
1744
  throw encounteredError;
1745
1745
  }
1746
1746
  if (options.writable) {
1747
- const sendFinish = (_Q = options.sendFinish) != null ? _Q : true;
1748
- const preventClose = (_R = options.preventClose) != null ? _R : false;
1747
+ const sendFinish = (_R = options.sendFinish) != null ? _R : true;
1748
+ const preventClose = (_S = options.preventClose) != null ? _S : false;
1749
1749
  if (sendFinish || !preventClose) {
1750
1750
  await closeStream(options.writable, preventClose, sendFinish);
1751
1751
  }
@@ -2519,4 +2519,4 @@ export {
2519
2519
  normalizeUIMessageStreamParts,
2520
2520
  toUIMessageChunk
2521
2521
  };
2522
- //# sourceMappingURL=index.mjs.map
2522
+ //# sourceMappingURL=index.js.map