@ai-sdk/workflow 2.0.37 → 2.0.38

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,26 @@
1
1
  # @ai-sdk/workflow
2
2
 
3
+ ## 2.0.38
4
+
5
+ ### Patch Changes
6
+
7
+ - a105059: fix(workflow): support deferred tool discovery in WorkflowAgent
8
+ - Updated dependencies [79681c4]
9
+ - Updated dependencies [98c7275]
10
+ - Updated dependencies [2973485]
11
+ - Updated dependencies [a105059]
12
+ - Updated dependencies [31532f3]
13
+ - Updated dependencies [e61cbd8]
14
+ - Updated dependencies [8ade040]
15
+ - Updated dependencies [970a01e]
16
+ - Updated dependencies [85539c5]
17
+ - Updated dependencies [a4db5ea]
18
+ - Updated dependencies [2937ea2]
19
+ - Updated dependencies [611d301]
20
+ - Updated dependencies [c415657]
21
+ - ai@7.0.107
22
+ - @ai-sdk/provider-utils@5.0.45
23
+
3
24
  ## 2.0.37
4
25
 
5
26
  ### Patch Changes
package/dist/index.js CHANGED
@@ -180,7 +180,10 @@ import {
180
180
  DefaultGeneratedFile,
181
181
  experimental_filterActiveTools as filterActiveTools
182
182
  } from "ai";
183
- import { createRestrictedTelemetryDispatcher } from "ai/internal";
183
+ import {
184
+ createRestrictedTelemetryDispatcher,
185
+ createToolSearchState
186
+ } from "ai/internal";
184
187
 
185
188
  // src/do-stream-step.ts
186
189
  import { isAbortError } from "@ai-sdk/provider-utils";
@@ -684,6 +687,10 @@ async function* streamTextIterator({
684
687
  let wasAborted = false;
685
688
  let terminalError;
686
689
  let hasTerminalError = false;
690
+ const prepareToolSearch = createToolSearchState({
691
+ tools,
692
+ toolCallers: void 0
693
+ });
687
694
  const telemetryDispatcher = createRestrictedTelemetryDispatcher({
688
695
  telemetry,
689
696
  includeRuntimeContext: telemetry == null ? void 0 : telemetry.includeRuntimeContext,
@@ -771,10 +778,14 @@ async function* streamTextIterator({
771
778
  toolsContext: currentToolsContext
772
779
  }));
773
780
  try {
774
- const effectiveTools = currentActiveTools !== void 0 ? (_d = filterActiveTools({
781
+ const stepActiveTools = filterActiveTools({
775
782
  tools,
776
783
  activeTools: currentActiveTools
777
- })) != null ? _d : tools : tools;
784
+ });
785
+ const effectiveTools = (_d = prepareToolSearch(stepActiveTools, {
786
+ toolsContext: currentToolsContext,
787
+ experimental_sandbox: stepSandbox
788
+ })) != null ? _d : {};
778
789
  const serializedTools = serializeToolSet(effectiveTools, {
779
790
  toolsContext: currentToolsContext,
780
791
  experimental_sandbox: stepSandbox
@@ -897,6 +908,7 @@ async function* streamTextIterator({
897
908
  });
898
909
  const toolResults = yield {
899
910
  toolCalls,
911
+ tools: effectiveTools,
900
912
  messages: conversationPrompt,
901
913
  step,
902
914
  runtimeContext: currentRuntimeContext,
@@ -2004,6 +2016,7 @@ var WorkflowAgent = class {
2004
2016
  }
2005
2017
  const {
2006
2018
  toolCalls,
2019
+ tools: stepTools = effectiveTools,
2007
2020
  messages: iterMessages,
2008
2021
  step,
2009
2022
  runtimeContext: yieldedRuntimeContext,
@@ -2057,7 +2070,7 @@ var WorkflowAgent = class {
2057
2070
  ];
2058
2071
  const approvalNeeded = await Promise.all(
2059
2072
  nonProviderToolCalls.map(async (tc) => {
2060
- const tool2 = effectiveTools[tc.toolName];
2073
+ const tool2 = stepTools[tc.toolName];
2061
2074
  if (!tool2) return false;
2062
2075
  if (tool2.needsApproval == null) return false;
2063
2076
  if (typeof tool2.needsApproval === "boolean")
@@ -2075,11 +2088,11 @@ var WorkflowAgent = class {
2075
2088
  })
2076
2089
  );
2077
2090
  const executableToolCalls = nonProviderToolCalls.filter((tc, i) => {
2078
- const tool2 = effectiveTools[tc.toolName];
2091
+ const tool2 = stepTools[tc.toolName];
2079
2092
  return (!tool2 || typeof tool2.execute === "function") && !approvalNeeded[i];
2080
2093
  });
2081
2094
  const pausedToolCalls = nonProviderToolCalls.filter((tc, i) => {
2082
- const tool2 = effectiveTools[tc.toolName];
2095
+ const tool2 = stepTools[tc.toolName];
2083
2096
  return tool2 && typeof tool2.execute !== "function" || approvalNeeded[i];
2084
2097
  });
2085
2098
  if (pausedToolCalls.length > 0) {
@@ -2087,7 +2100,7 @@ var WorkflowAgent = class {
2087
2100
  executableToolCalls.map(
2088
2101
  (toolCall) => executeToolWithCallbacks(
2089
2102
  toolCall,
2090
- effectiveTools,
2103
+ stepTools,
2091
2104
  iterMessages,
2092
2105
  toolsContext,
2093
2106
  currentStepNumber,
@@ -2101,7 +2114,7 @@ var WorkflowAgent = class {
2101
2114
  result: await resolveProviderToolResult(
2102
2115
  toolCall,
2103
2116
  capturedProviderToolResults,
2104
- effectiveTools,
2117
+ stepTools,
2105
2118
  download
2106
2119
  )
2107
2120
  }))
@@ -2253,7 +2266,7 @@ var WorkflowAgent = class {
2253
2266
  nonProviderToolCalls.map(
2254
2267
  (toolCall) => executeToolWithCallbacks(
2255
2268
  toolCall,
2256
- effectiveTools,
2269
+ stepTools,
2257
2270
  iterMessages,
2258
2271
  toolsContext,
2259
2272
  currentStepNumber,
@@ -2267,7 +2280,7 @@ var WorkflowAgent = class {
2267
2280
  result: await resolveProviderToolResult(
2268
2281
  toolCall,
2269
2282
  capturedProviderToolResults,
2270
- effectiveTools,
2283
+ stepTools,
2271
2284
  download
2272
2285
  )
2273
2286
  }))