@rulvar/anthropic 1.186.0 → 1.188.0

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -855,6 +855,21 @@ function anthropic(options = {}) {
855
855
  let continuations = 0;
856
856
  const carryRetained = [];
857
857
  const priorSegmentIds = [];
858
+ const withAbsorbed = (error) => {
859
+ if (priorSegmentIds.length === 0) return error;
860
+ const wireRequests = {
861
+ count: priorSegmentIds.length,
862
+ responseIds: priorSegmentIds.filter((id) => typeof id === "string")
863
+ };
864
+ const base = typeof error.data === "object" && error.data !== null && !Array.isArray(error.data) ? error.data : {};
865
+ return {
866
+ ...error,
867
+ data: {
868
+ ...base,
869
+ wireRequests
870
+ }
871
+ };
872
+ };
858
873
  let absorbedUsage;
859
874
  while (true) {
860
875
  let stream;
@@ -867,7 +882,7 @@ function anthropic(options = {}) {
867
882
  if (signal?.aborted === true) return;
868
883
  yield {
869
884
  type: "error",
870
- error: anthropicErrorToWire(thrown)
885
+ error: withAbsorbed(anthropicErrorToWire(thrown))
871
886
  };
872
887
  return;
873
888
  }
@@ -890,7 +905,7 @@ function anthropic(options = {}) {
890
905
  if (signal?.aborted === true) return;
891
906
  yield {
892
907
  type: "error",
893
- error: anthropicErrorToWire(thrown)
908
+ error: withAbsorbed(anthropicErrorToWire(thrown))
894
909
  };
895
910
  return;
896
911
  }
@@ -899,12 +914,12 @@ function anthropic(options = {}) {
899
914
  if (signal?.aborted === true) return;
900
915
  yield {
901
916
  type: "error",
902
- error: {
917
+ error: withAbsorbed({
903
918
  code: "agent",
904
919
  message: "Messages stream ended before message_stop; the read was truncated",
905
920
  retryable: true,
906
921
  data: { kind: "transport" }
907
- }
922
+ })
908
923
  };
909
924
  return;
910
925
  }
@@ -915,12 +930,12 @@ function anthropic(options = {}) {
915
930
  if (continuations > pauseCap) {
916
931
  yield {
917
932
  type: "error",
918
- error: {
933
+ error: withAbsorbed({
919
934
  code: "agent",
920
935
  message: `pause_turn continuation cap (${pauseCap}) exceeded`,
921
936
  retryable: true,
922
937
  data: { kind: "transport" }
923
- }
938
+ })
924
939
  };
925
940
  return;
926
941
  }
@@ -928,7 +943,7 @@ function anthropic(options = {}) {
928
943
  if (denial !== void 0) {
929
944
  yield {
930
945
  type: "error",
931
- error: denial
946
+ error: withAbsorbed(denial)
932
947
  };
933
948
  return;
934
949
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/anthropic",
3
- "version": "1.186.0",
3
+ "version": "1.188.0",
4
4
  "description": "Rulvar first-class provider adapter over @anthropic-ai/sdk.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@anthropic-ai/sdk": "^0.115.0",
26
- "@rulvar/core": "1.186.0"
26
+ "@rulvar/core": "1.188.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^22.20.1",
30
30
  "tsdown": "^0.22.14",
31
31
  "typescript": "~6.0.3",
32
- "@rulvar/testing": "1.186.0"
32
+ "@rulvar/testing": "1.188.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",