tensorlake 0.5.127 → 0.5.128

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.
@@ -46,7 +46,7 @@ var init_defaults = __esm({
46
46
  "src/defaults.ts"() {
47
47
  "use strict";
48
48
  init_esm_shims();
49
- SDK_VERSION = "0.5.127";
49
+ SDK_VERSION = "0.5.128";
50
50
  API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
51
51
  API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
52
52
  NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -81,6 +81,27 @@ function describeError(err) {
81
81
  if (parts.length > 0) return parts.join(": ");
82
82
  return err instanceof Error ? err.message : String(err);
83
83
  }
84
+ function formatErrorDetails(errorDetails) {
85
+ if (errorDetails == null) return void 0;
86
+ if (typeof errorDetails === "string") {
87
+ const detail = errorDetails.trim();
88
+ return detail || void 0;
89
+ }
90
+ if (Array.isArray(errorDetails)) {
91
+ const parts = errorDetails.map((item) => formatErrorDetails(item)).filter((item) => Boolean(item));
92
+ return parts.length > 0 ? parts.join("; ") : JSON.stringify(errorDetails);
93
+ }
94
+ if (typeof errorDetails === "object") {
95
+ for (const key of ["message", "detail", "error", "reason"]) {
96
+ const value = errorDetails[key];
97
+ if (typeof value === "string" && value.trim()) {
98
+ return value.trim();
99
+ }
100
+ }
101
+ return JSON.stringify(errorDetails);
102
+ }
103
+ return String(errorDetails);
104
+ }
84
105
  var SandboxException, SandboxError, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError, RequestNotFinishedError, RequestFailedError, RequestExecutionError;
85
106
  var init_errors = __esm({
86
107
  "src/errors.ts"() {
@@ -132,9 +153,39 @@ var init_errors = __esm({
132
153
  };
133
154
  RemoteAPIError = class extends SandboxError {
134
155
  statusCode;
156
+ /** Original response body, retained for compatibility and diagnostics. */
135
157
  responseMessage;
158
+ sandboxId;
159
+ /** Server reason, including unknown future reasons. */
160
+ reason;
161
+ errorDetails;
136
162
  constructor(statusCode, message) {
137
- super(`API error (status ${statusCode}): ${message}`);
163
+ let failure;
164
+ try {
165
+ const payload = JSON.parse(message);
166
+ if (payload && typeof payload === "object" && !Array.isArray(payload)) {
167
+ const record = payload;
168
+ if (typeof record.sandbox_id === "string" && record.sandbox_id.trim() && (record.status === "failed" || record.status === "terminated"))
169
+ failure = record;
170
+ }
171
+ } catch {
172
+ }
173
+ const sandboxId = failure?.sandbox_id;
174
+ const rawReason = failure?.reason ?? failure?.termination_reason;
175
+ const reason = typeof rawReason === "string" ? rawReason : void 0;
176
+ const errorDetails = failure?.error_details;
177
+ let displayMessage = message;
178
+ if (failure) {
179
+ displayMessage = `Sandbox ${sandboxId} ${failure.status}`;
180
+ if (reason) displayMessage += ` (${reason})`;
181
+ const detail = formatErrorDetails(errorDetails);
182
+ if (detail) displayMessage += `: ${detail}`;
183
+ if (!reason && !detail) displayMessage = message;
184
+ }
185
+ super(`API error (status ${statusCode}): ${displayMessage}`);
186
+ this.sandboxId = sandboxId;
187
+ this.reason = reason;
188
+ this.errorDetails = errorDetails;
138
189
  this.name = "RemoteAPIError";
139
190
  this.statusCode = statusCode;
140
191
  this.responseMessage = message;
@@ -4006,7 +4057,7 @@ function createWorkerBinding(runtime) {
4006
4057
  };
4007
4058
  }
4008
4059
  var runtimeKey = /* @__PURE__ */ Symbol.for(
4009
- `tensorlake.native.worker.${false ? "source" : "0.5.127"}.v1`
4060
+ `tensorlake.native.worker.${false ? "source" : "0.5.128"}.v1`
4010
4061
  );
4011
4062
  var runtimes = globalThis;
4012
4063
  function workerBinding() {