fix(llm): preserve browser-safe provider imports · openclaw/openclaw@8c8eb86
vincentkoc
·
2026-06-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,6 @@ import type {
|
6 | 6 | ResponseInput, |
7 | 7 | ResponseStreamEvent, |
8 | 8 | } from "openai/resources/responses/responses.js"; |
9 | | -import { toErrorObject } from "../../infra/errors.js"; |
10 | 9 | |
11 | 10 | // NEVER convert to top-level runtime imports - breaks browser/Vite builds |
12 | 11 | let os: typeof NodeOs | null = null; |
@@ -1326,7 +1325,7 @@ async function* parseWebSocket(
|
1326 | 1325 | } |
1327 | 1326 | |
1328 | 1327 | if (failed) { |
1329 | | -throw toErrorObject(failed, "Non-Error thrown"); |
| 1328 | +throw toLintErrorObject(failed, "Non-Error thrown"); |
1330 | 1329 | } |
1331 | 1330 | if (!sawCompletion) { |
1332 | 1331 | throw new Error("WebSocket stream closed before response.completed"); |
@@ -1640,3 +1639,17 @@ function buildWebSocketHeaders(
|
1640 | 1639 | headers.set("session_id", requestId); |
1641 | 1640 | return headers; |
1642 | 1641 | } |
| 1642 | + |
| 1643 | +function toLintErrorObject(value: unknown, fallbackMessage: string): Error { |
| 1644 | +if (value instanceof Error) { |
| 1645 | +return value; |
| 1646 | +} |
| 1647 | +if (typeof value === "string") { |
| 1648 | +return new Error(value); |
| 1649 | +} |
| 1650 | +const error = new Error(fallbackMessage, { cause: value }); |
| 1651 | +if ((typeof value === "object" && value !== null) || typeof value === "function") { |
| 1652 | +Object.assign(error, value); |
| 1653 | +} |
| 1654 | +return error; |
| 1655 | +} |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。