@tangle-network/agent-app 3.0.28 → 3.0.29

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.
@@ -86,7 +86,7 @@ import {
86
86
  turnCarriesFiles,
87
87
  turnPromptText,
88
88
  withProducerStream
89
- } from "../chunk-4XFPMDIM.js";
89
+ } from "../chunk-LRUH36LD.js";
90
90
  import "../chunk-SBHFMDR7.js";
91
91
  import "../chunk-H6BRJU5M.js";
92
92
  import "../chunk-4DBHC63F.js";
@@ -1532,6 +1532,15 @@ function sandboxStreamErrorCode(data) {
1532
1532
  function toProducerWireEvent(event) {
1533
1533
  return event;
1534
1534
  }
1535
+ function plainFailureEvent(event) {
1536
+ const data = asRecord(event.data);
1537
+ if (!data || !["error", "warning", "done", "session.run.failed"].includes(String(event.type))) return event;
1538
+ const reasons = ["message", "error", "reason"].filter((key) => typeof data[key] === "string" && data[key]);
1539
+ const raw = reasons.map((key) => data[key]).join(" | ");
1540
+ const plain = raw ? providerResetSentence(raw) ?? modelKeyRefusedSentence(raw) : void 0;
1541
+ if (!plain) return event;
1542
+ return { ...event, data: { ...data, ...Object.fromEntries(reasons.map((key) => [key, plain])), details: { ...asRecord(data.details), raw } } };
1543
+ }
1535
1544
  function sandboxStreamFailureDiagnostic(error) {
1536
1545
  const streamMessage = error?.streamMessage;
1537
1546
  const message = typeof streamMessage === "string" ? streamMessage : error instanceof Error ? error.message : "Sandbox stream failed";
@@ -1667,7 +1676,9 @@ function createSandboxChatProducer(options) {
1667
1676
  }
1668
1677
  if (event.type === "warning") {
1669
1678
  const message = asString(event.data?.message);
1670
- if (message) {
1679
+ const plainFailure = message && (providerResetSentence(message) ?? modelKeyRefusedSentence(message));
1680
+ if (plainFailure) log("[chat-routes] failure warning folded into its error notice", { code: asString(event.data?.code), error: message });
1681
+ if (message && !plainFailure) {
1671
1682
  projectionState.warningCount += 1;
1672
1683
  const code = asString(event.data?.code);
1673
1684
  const text = code ? `${code}: ${message}` : message;
@@ -1675,7 +1686,7 @@ function createSandboxChatProducer(options) {
1675
1686
  recordPersistedPart(notice, void 0, noticePartKey(notice.id));
1676
1687
  yield { type: "notice", id: notice.id, noticeKind: "warning", text };
1677
1688
  }
1678
- yield toProducerWireEvent(record);
1689
+ yield toProducerWireEvent(plainFailureEvent(record));
1679
1690
  continue;
1680
1691
  }
1681
1692
  if (event.type === "usage") {
@@ -1712,7 +1723,7 @@ function createSandboxChatProducer(options) {
1712
1723
  yield* emitFinalUsage();
1713
1724
  }
1714
1725
  yield* emitTerminalizedTools();
1715
- yield toProducerWireEvent(record);
1726
+ yield toProducerWireEvent(plainFailureEvent(record));
1716
1727
  continue;
1717
1728
  }
1718
1729
  if (event.type === "error") {
@@ -1736,10 +1747,10 @@ ${errorContent}` : errorContent;
1736
1747
  }
1737
1748
  projectionState.interactionOutcome = "expired";
1738
1749
  yield* emitTerminalizedTools();
1739
- yield toProducerWireEvent(record);
1750
+ yield toProducerWireEvent(plainFailureEvent(record));
1740
1751
  continue;
1741
1752
  }
1742
- yield toProducerWireEvent(record);
1753
+ yield toProducerWireEvent(plainFailureEvent(record));
1743
1754
  }
1744
1755
  yield* drainModelNotices();
1745
1756
  } catch (streamErr) {
@@ -4188,4 +4199,4 @@ export {
4188
4199
  createChatTurnRoutes,
4189
4200
  streamChatRouteAsSandboxEvents
4190
4201
  };
4191
- //# sourceMappingURL=chunk-4XFPMDIM.js.map
4202
+ //# sourceMappingURL=chunk-LRUH36LD.js.map