@tangle-network/agent-app 0.50.5 → 0.50.7

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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ChatEmptyState,
3
3
  ChatMessages
4
- } from "../chunk-5DEQ2FJK.js";
5
- import "../chunk-3HUFJ5LO.js";
4
+ } from "../chunk-ZYJCWKZ7.js";
6
5
  import "../chunk-F32T3DRJ.js";
6
+ import "../chunk-3HUFJ5LO.js";
7
7
  import "../chunk-FBVLEGEG.js";
8
8
  import "../chunk-ENLRJYVW.js";
9
9
  import {
@@ -35,8 +35,9 @@ import {
35
35
  buildModelChain,
36
36
  isUpstreamUnavailable,
37
37
  readHttpStatusHint,
38
+ readUpstreamUnavailableCode,
38
39
  runWithModelFailover
39
- } from "../chunk-DEXBRUZR.js";
40
+ } from "../chunk-63EKFZOE.js";
40
41
  import {
41
42
  flattenHistory,
42
43
  readSandboxBinaryBytes,
@@ -176,7 +177,7 @@ function classifyTerminalFailure(event) {
176
177
  const data = asRecord(record2.data);
177
178
  const outage = isUpstreamUnavailable(data) || isUpstreamUnavailable(record2);
178
179
  const reason = asString(data?.message) ?? asString(data?.error) ?? asString(data?.reason) ?? asString(record2.message) ?? `sandbox stream reported ${type}`;
179
- const code = asString(data?.errorCode) ?? asString(data?.code);
180
+ const code = readUpstreamUnavailableCode(data) ?? asString(data?.errorCode) ?? asString(data?.code) ?? readUpstreamUnavailableCode(record2) ?? asString(record2.errorCode) ?? asString(record2.code);
180
181
  return { outage, reason, ...code ? { code } : {} };
181
182
  }
182
183
  var DEFAULT_MODEL_STREAM_OPEN_TIMEOUT_MS = 12e4;
@@ -671,7 +672,12 @@ function sandboxStreamFailureDiagnostic(error) {
671
672
  "Please retry. If it repeats, send these support details to the team."
672
673
  ].join("\n\n");
673
674
  const failureNote = diagnosticText ? `sandbox-stream: ${message}; ${diagnosticText}` : `sandbox-stream: ${message}`;
674
- const code = error instanceof ModelFailoverTimeoutError ? error.code : "sandbox.stream_failed";
675
+ let code = "sandbox.stream_failed";
676
+ if (error instanceof ModelFailoverTimeoutError) {
677
+ code = error.code;
678
+ } else if (error instanceof ModelFailoverExhaustedError) {
679
+ code = error.upstreamCode ?? code;
680
+ }
675
681
  return { userMessage, failureNote, code };
676
682
  }
677
683
  function createSandboxChatProducer(options) {
@@ -1033,13 +1039,15 @@ function createSandboxChatProducer(options) {
1033
1039
  Error: ${message}` : `The sandbox agent returned an error before producing a visible answer.
1034
1040
 
1035
1041
  Error: ${message}`;
1036
- const errorDelta = fullText ? `
1042
+ if (options.includeErrorText !== false) {
1043
+ const errorDelta = fullText ? `
1037
1044
 
1038
1045
  ---
1039
1046
  ${errorContent}` : errorContent;
1040
- fullText += errorDelta;
1047
+ fullText += errorDelta;
1048
+ yield { type: "text", text: errorDelta };
1049
+ }
1041
1050
  interactionOutcome = "expired";
1042
- yield { type: "text", text: errorDelta };
1043
1051
  yield* emitTerminalizedTools();
1044
1052
  yield toProducerWireEvent(record2);
1045
1053
  continue;
@@ -1053,13 +1061,15 @@ ${errorContent}` : errorContent;
1053
1061
  failureNote: diagnostic.failureNote,
1054
1062
  error: streamErr instanceof Error ? streamErr.message : String(streamErr)
1055
1063
  });
1056
- const errorDelta = fullText ? `
1064
+ if (options.includeErrorText !== false) {
1065
+ const errorDelta = fullText ? `
1057
1066
 
1058
1067
  ---
1059
1068
  ${diagnostic.userMessage}` : diagnostic.userMessage;
1060
- fullText += errorDelta;
1069
+ fullText += errorDelta;
1070
+ yield { type: "text", text: errorDelta };
1071
+ }
1061
1072
  interactionOutcome = "expired";
1062
- yield { type: "text", text: errorDelta };
1063
1073
  yield* emitTerminalizedTools();
1064
1074
  yield {
1065
1075
  type: "error",