@ai-sdk/harness 1.0.73 → 1.0.75

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,18 @@
1
1
  # @ai-sdk/harness
2
2
 
3
+ ## 1.0.75
4
+
5
+ ### Patch Changes
6
+
7
+ - d300737: fix(harness): keep the runtime's error message on failed provider-executed tool results
8
+ - ai@7.0.68
9
+
10
+ ## 1.0.74
11
+
12
+ ### Patch Changes
13
+
14
+ - ai@7.0.67
15
+
3
16
  ## 1.0.73
4
17
 
5
18
  ### Patch Changes
@@ -759,21 +759,10 @@ var HarnessStreamTextResult = class {
759
759
  return;
760
760
  }
761
761
  case "tool-call":
762
- this.currentStepContent.push({
763
- ...part
764
- });
765
- return;
766
762
  case "tool-approval-request":
767
- this.currentStepContent.push({
768
- ...part
769
- });
770
- return;
771
763
  case "tool-approval-response":
772
- this.currentStepContent.push({
773
- ...part
774
- });
775
- return;
776
764
  case "tool-result":
765
+ case "tool-error":
777
766
  this.currentStepContent.push({
778
767
  ...part
779
768
  });
@@ -870,7 +859,8 @@ function notSupportedYet(feature) {
870
859
 
871
860
  // src/agent/internal/translate-stream-part.ts
872
861
  import { generateId as generateId2 } from "@ai-sdk/provider-utils";
873
- function translateStreamPart(event) {
862
+ function translateStreamPart(event, options = {}) {
863
+ var _a4, _b4;
874
864
  switch (event.type) {
875
865
  case "stream-start":
876
866
  return [];
@@ -929,6 +919,20 @@ function translateStreamPart(event) {
929
919
  case "tool-approval-request":
930
920
  return [];
931
921
  case "tool-result":
922
+ if (event.isError === true && ((_b4 = (_a4 = options.isProviderExecuted) == null ? void 0 : _a4.call(options, event.toolCallId)) != null ? _b4 : true)) {
923
+ return [
924
+ {
925
+ type: "tool-error",
926
+ toolCallId: event.toolCallId,
927
+ toolName: event.toolName,
928
+ input: void 0,
929
+ error: event.result,
930
+ providerExecuted: true,
931
+ ...event.dynamic !== void 0 ? { dynamic: event.dynamic } : {},
932
+ ...event.providerMetadata !== void 0 ? { providerMetadata: event.providerMetadata } : {}
933
+ }
934
+ ];
935
+ }
932
936
  return [
933
937
  {
934
938
  type: "tool-result",
@@ -1575,6 +1579,12 @@ function runPrompt(input) {
1575
1579
  const reader = stream.getReader();
1576
1580
  const toolCallsByToolCallId = /* @__PURE__ */ new Map();
1577
1581
  const rawToolCallsByToolCallId = /* @__PURE__ */ new Map();
1582
+ const translateOptions = {
1583
+ isProviderExecuted: (toolCallId) => {
1584
+ const rawToolCall = rawToolCallsByToolCallId.get(toolCallId);
1585
+ return rawToolCall == null || rawToolCall.providerExecuted === true;
1586
+ }
1587
+ };
1578
1588
  const pendingApprovalsByApprovalId = new Map(
1579
1589
  pendingToolApprovals.map((approval) => [approval.approvalId, approval])
1580
1590
  );
@@ -1956,7 +1966,10 @@ function runPrompt(input) {
1956
1966
  settleFailure(displayValue.error);
1957
1967
  return;
1958
1968
  }
1959
- for (const part of translateStreamPart(displayValue)) {
1969
+ for (const part of translateStreamPart(
1970
+ displayValue,
1971
+ translateOptions
1972
+ )) {
1960
1973
  result.enqueue(part);
1961
1974
  }
1962
1975
  if (displayValue.type === "tool-call") {