@opencode-ai/sdk 1.14.33 → 1.14.35
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/v2/client.js +20 -0
- package/dist/v2/gen/sdk.gen.d.ts +816 -731
- package/dist/v2/gen/sdk.gen.js +1122 -955
- package/dist/v2/gen/types.gen.d.ts +3065 -2113
- package/package.json +1 -1
package/dist/v2/client.js
CHANGED
|
@@ -72,5 +72,25 @@ export function createOpencodeClient(config) {
|
|
|
72
72
|
throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");
|
|
73
73
|
return response;
|
|
74
74
|
});
|
|
75
|
+
// The generated client falls back to throwing a literal `{}` when the server
|
|
76
|
+
// responds with an empty / unparseable error body, which surfaces as a bare
|
|
77
|
+
// `{}` in TUI / CLI error output. Wrap ONLY that case in a real Error so
|
|
78
|
+
// downstream formatters get a useful message — but pass through any parsed
|
|
79
|
+
// JSON error body unchanged so existing consumers can still inspect fields.
|
|
80
|
+
client.interceptors.error.use((error, response, request) => {
|
|
81
|
+
const isEmpty = error === undefined ||
|
|
82
|
+
error === null ||
|
|
83
|
+
error === "" ||
|
|
84
|
+
(typeof error === "object" && !(error instanceof Error) && Object.keys(error).length === 0);
|
|
85
|
+
if (!isEmpty)
|
|
86
|
+
return error;
|
|
87
|
+
const method = request?.method ?? "?";
|
|
88
|
+
const url = request?.url ?? "?";
|
|
89
|
+
if (!response)
|
|
90
|
+
return new Error(`opencode server ${method} ${url}: network error (no response)`);
|
|
91
|
+
const status = response.status;
|
|
92
|
+
const statusText = response.statusText ? " " + response.statusText : "";
|
|
93
|
+
return new Error(`opencode server ${method} ${url} → ${status}${statusText}: (empty response body)`);
|
|
94
|
+
});
|
|
75
95
|
return new OpencodeClient({ client });
|
|
76
96
|
}
|