@kilocode/sdk 7.3.0 → 7.3.5

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 CHANGED
@@ -81,5 +81,25 @@ export function createKiloClient(config) {
81
81
  throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");
82
82
  return response;
83
83
  });
84
+ // The generated client falls back to throwing a literal `{}` when the server
85
+ // responds with an empty / unparseable error body, which surfaces as a bare
86
+ // `{}` in TUI / CLI error output. Wrap ONLY that case in a real Error so
87
+ // downstream formatters get a useful message — but pass through any parsed
88
+ // JSON error body unchanged so existing consumers can still inspect fields.
89
+ client.interceptors.error.use((error, response, request) => {
90
+ const isEmpty = error === undefined ||
91
+ error === null ||
92
+ error === "" ||
93
+ (typeof error === "object" && !(error instanceof Error) && Object.keys(error).length === 0);
94
+ if (!isEmpty)
95
+ return error;
96
+ const method = request?.method ?? "?";
97
+ const url = request?.url ?? "?";
98
+ if (!response)
99
+ return new Error(`kilo server ${method} ${url}: network error (no response)`);
100
+ const status = response.status;
101
+ const statusText = response.statusText ? " " + response.statusText : "";
102
+ return new Error(`kilo server ${method} ${url} → ${status}${statusText}: (empty response body)`);
103
+ });
84
104
  return new KiloClient({ client });
85
105
  }