@tangle-network/agent-app 3.0.28 → 3.0.30
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/dist/assistant/index.js +2 -85
- package/dist/assistant/index.js.map +1 -1
- package/dist/assistant/sse.d.ts +5 -20
- package/dist/chat-routes/index.js +1 -1
- package/dist/{chunk-4XFPMDIM.js → chunk-LRUH36LD.js} +17 -6
- package/dist/chunk-LRUH36LD.js.map +1 -0
- package/dist/public-consultation/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4XFPMDIM.js.map +0 -1
package/dist/assistant/sse.d.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
+
import { type ParsedSSEEvent } from "@tangle-network/agent-core/sse";
|
|
1
2
|
/**
|
|
2
|
-
* POST
|
|
3
|
-
*
|
|
4
|
-
* off a `fetch` POST response.
|
|
3
|
+
* Read the assistant's POST response through the shared SSE transport. The
|
|
4
|
+
* native EventSource is GET-only and cannot send the chat request body.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* standard SSE wire format: events separated by a blank line, `event:` / `data:`
|
|
9
|
-
* fields, `:`-prefixed comments ignored, multi-line `data:` joined with `\n`, and
|
|
10
|
-
* each event's data JSON-parsed (falling back to the raw string).
|
|
11
|
-
*/
|
|
12
|
-
interface ParsedSSEEvent<T = unknown> {
|
|
13
|
-
data: T;
|
|
14
|
-
rawData: string;
|
|
15
|
-
eventId?: string;
|
|
16
|
-
eventType?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Read a fetch `Response` body and invoke `onEvent` for each parsed SSE event
|
|
20
|
-
* (its `eventType` plus JSON-parsed `data`), in wire order. Resolves when the
|
|
21
|
-
* stream closes. The caller owns abort (via the fetch `signal`).
|
|
6
|
+
* Events retain their wire order and JSON/raw payload mapping. The shared
|
|
7
|
+
* reader owns UTF-8 framing, cancellation on failure, and releasing its lock.
|
|
22
8
|
*/
|
|
23
9
|
export declare function readSSEEvents(body: ReadableStream<Uint8Array>, onEvent: (event: ParsedSSEEvent) => void): Promise<void>;
|
|
24
|
-
export {};
|
|
@@ -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
|
-
|
|
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-
|
|
4202
|
+
//# sourceMappingURL=chunk-LRUH36LD.js.map
|