@superlinked/sie-sdk 0.3.0 → 0.3.1

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/index.d.cts CHANGED
@@ -732,7 +732,7 @@ declare class SIEClient {
732
732
  private detectEndpointType;
733
733
  }
734
734
 
735
- declare const SDK_VERSION = "0.3.0";
735
+ declare const SDK_VERSION = "0.3.1";
736
736
 
737
737
  /**
738
738
  * Helpers for converting SIE encode results to plain JavaScript types.
@@ -948,6 +948,39 @@ declare class ModelLoadingError extends SIEError {
948
948
  readonly model: string | undefined;
949
949
  constructor(message: string, model?: string);
950
950
  }
951
+ /**
952
+ * Error when the server reports a *terminal* model-load failure.
953
+ *
954
+ * Distinct from {@link ModelLoadingError} — this is thrown on the first
955
+ * response (no retry budget consumed) when the server returns HTTP
956
+ * `502 MODEL_LOAD_FAILED`. The server uses this code for permanent-class
957
+ * failures (gated repos, missing dependencies, unrecognised model
958
+ * architectures) where retrying would waste time. See sie-test#85.
959
+ *
960
+ * Permanent failures will not auto-clear; an operator must fix the
961
+ * underlying cause (e.g. set `HF_TOKEN`, accept the model license on
962
+ * HuggingFace, upgrade `transformers`).
963
+ */
964
+ declare class ModelLoadFailedError extends ServerError {
965
+ /** The model that was requested */
966
+ readonly model: string | undefined;
967
+ /**
968
+ * Server-side classification: one of `GATED`, `OOM`, `DEPENDENCY`,
969
+ * `NOT_FOUND`, `NETWORK`, `UNKNOWN`. Use this to route to specific
970
+ * remediation paths (e.g. surface a "set HF_TOKEN" hint for `GATED`).
971
+ */
972
+ readonly errorClass: string | undefined;
973
+ /** Whether the failure is non-retryable per server policy. */
974
+ readonly permanent: boolean;
975
+ /** How many load attempts the server has logged. */
976
+ readonly attempts: number;
977
+ constructor(message: string, options?: {
978
+ model?: string;
979
+ errorClass?: string;
980
+ permanent?: boolean;
981
+ attempts?: number;
982
+ });
983
+ }
951
984
 
952
985
  /**
953
986
  * MessagePack serialization with msgpack-numpy compatibility.
@@ -1053,4 +1086,4 @@ declare function toImageWireFormat(input: ImageInput, format?: "jpeg" | "png" |
1053
1086
  */
1054
1087
  declare function detectImageFormat(bytes: Uint8Array): "jpeg" | "png" | "webp" | "unknown";
1055
1088
 
1056
- export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
1089
+ export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
package/dist/index.d.ts CHANGED
@@ -732,7 +732,7 @@ declare class SIEClient {
732
732
  private detectEndpointType;
733
733
  }
734
734
 
735
- declare const SDK_VERSION = "0.3.0";
735
+ declare const SDK_VERSION = "0.3.1";
736
736
 
737
737
  /**
738
738
  * Helpers for converting SIE encode results to plain JavaScript types.
@@ -948,6 +948,39 @@ declare class ModelLoadingError extends SIEError {
948
948
  readonly model: string | undefined;
949
949
  constructor(message: string, model?: string);
950
950
  }
951
+ /**
952
+ * Error when the server reports a *terminal* model-load failure.
953
+ *
954
+ * Distinct from {@link ModelLoadingError} — this is thrown on the first
955
+ * response (no retry budget consumed) when the server returns HTTP
956
+ * `502 MODEL_LOAD_FAILED`. The server uses this code for permanent-class
957
+ * failures (gated repos, missing dependencies, unrecognised model
958
+ * architectures) where retrying would waste time. See sie-test#85.
959
+ *
960
+ * Permanent failures will not auto-clear; an operator must fix the
961
+ * underlying cause (e.g. set `HF_TOKEN`, accept the model license on
962
+ * HuggingFace, upgrade `transformers`).
963
+ */
964
+ declare class ModelLoadFailedError extends ServerError {
965
+ /** The model that was requested */
966
+ readonly model: string | undefined;
967
+ /**
968
+ * Server-side classification: one of `GATED`, `OOM`, `DEPENDENCY`,
969
+ * `NOT_FOUND`, `NETWORK`, `UNKNOWN`. Use this to route to specific
970
+ * remediation paths (e.g. surface a "set HF_TOKEN" hint for `GATED`).
971
+ */
972
+ readonly errorClass: string | undefined;
973
+ /** Whether the failure is non-retryable per server policy. */
974
+ readonly permanent: boolean;
975
+ /** How many load attempts the server has logged. */
976
+ readonly attempts: number;
977
+ constructor(message: string, options?: {
978
+ model?: string;
979
+ errorClass?: string;
980
+ permanent?: boolean;
981
+ attempts?: number;
982
+ });
983
+ }
951
984
 
952
985
  /**
953
986
  * MessagePack serialization with msgpack-numpy compatibility.
@@ -1053,4 +1086,4 @@ declare function toImageWireFormat(input: ImageInput, format?: "jpeg" | "png" |
1053
1086
  */
1054
1087
  declare function detectImageFormat(bytes: Uint8Array): "jpeg" | "png" | "webp" | "unknown";
1055
1088
 
1056
- export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
1089
+ export { type CapacityInfo, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type GPUMetrics, type ImageInput, type ImageWireFormat, type Item, LoraLoadingError, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type TimingInfo, type WorkerInfo, type WorkerStatusMessage, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
package/dist/index.js CHANGED
@@ -85,6 +85,28 @@ var ModelLoadingError = class extends SIEError {
85
85
  this.model = model;
86
86
  }
87
87
  };
88
+ var ModelLoadFailedError = class extends ServerError {
89
+ /** The model that was requested */
90
+ model;
91
+ /**
92
+ * Server-side classification: one of `GATED`, `OOM`, `DEPENDENCY`,
93
+ * `NOT_FOUND`, `NETWORK`, `UNKNOWN`. Use this to route to specific
94
+ * remediation paths (e.g. surface a "set HF_TOKEN" hint for `GATED`).
95
+ */
96
+ errorClass;
97
+ /** Whether the failure is non-retryable per server policy. */
98
+ permanent;
99
+ /** How many load attempts the server has logged. */
100
+ attempts;
101
+ constructor(message, options) {
102
+ super(message, "MODEL_LOAD_FAILED", 502);
103
+ this.name = "ModelLoadFailedError";
104
+ this.model = options?.model;
105
+ this.errorClass = options?.errorClass;
106
+ this.permanent = options?.permanent ?? true;
107
+ this.attempts = options?.attempts ?? 1;
108
+ }
109
+ };
88
110
 
89
111
  // src/internal/constants.ts
90
112
  var MSGPACK_CONTENT_TYPE = "application/msgpack";
@@ -309,7 +331,7 @@ function getRetryAfter2(response) {
309
331
  const header = response.headers.get("Retry-After");
310
332
  return getRetryAfter(header);
311
333
  }
312
- async function getErrorCode(response) {
334
+ async function getErrorDetail(response) {
313
335
  try {
314
336
  const contentType = response.headers.get("content-type") ?? "";
315
337
  let data;
@@ -320,24 +342,42 @@ async function getErrorCode(response) {
320
342
  data = await response.json();
321
343
  }
322
344
  if (data.error && typeof data.error === "object") {
323
- const error = data.error;
324
- if (typeof error.code === "string") {
325
- return error.code;
326
- }
345
+ return data.error;
327
346
  }
328
347
  if (data.detail && typeof data.detail === "object") {
329
- const detail = data.detail;
330
- if (typeof detail.code === "string") {
331
- return detail.code;
332
- }
348
+ return data.detail;
333
349
  }
334
350
  if (typeof data.code === "string") {
335
- return data.code;
351
+ return data;
336
352
  }
337
353
  } catch {
338
354
  }
339
355
  return void 0;
340
356
  }
357
+ async function getErrorCode(response) {
358
+ const detail = await getErrorDetail(response);
359
+ if (!detail) return void 0;
360
+ const code = detail.code;
361
+ return typeof code === "string" ? code : void 0;
362
+ }
363
+ async function throwIfModelLoadFailed(response, model) {
364
+ if (response.status !== 502) return;
365
+ const detail = await getErrorDetail(response.clone());
366
+ if (!detail) return;
367
+ if (detail.code !== "MODEL_LOAD_FAILED") return;
368
+ const errorClass = typeof detail.error_class === "string" ? detail.error_class : void 0;
369
+ const permanent = typeof detail.permanent === "boolean" ? detail.permanent : true;
370
+ const attemptsRaw = detail.attempts;
371
+ const parsedAttempts = typeof attemptsRaw === "number" ? attemptsRaw : typeof attemptsRaw === "string" ? Number.parseInt(attemptsRaw, 10) : Number.NaN;
372
+ const attempts = Number.isFinite(parsedAttempts) ? parsedAttempts : 1;
373
+ const message = typeof detail.message === "string" ? detail.message : `Model '${model ?? "?"}' failed to load`;
374
+ throw new ModelLoadFailedError(message, {
375
+ model,
376
+ errorClass,
377
+ permanent,
378
+ attempts
379
+ });
380
+ }
341
381
  async function handleError(response, gpu) {
342
382
  const { status } = response;
343
383
  let errorBody = {};
@@ -474,7 +514,7 @@ function parseCapacityInfo(data, gpuFilter) {
474
514
  }
475
515
 
476
516
  // src/version.ts
477
- var SDK_VERSION = "0.3.0";
517
+ var SDK_VERSION = "0.3.1";
478
518
 
479
519
  // src/client.ts
480
520
  function sleep(ms) {
@@ -1178,6 +1218,7 @@ var SIEClient = class {
1178
1218
  await sleep(actualDelay);
1179
1219
  continue;
1180
1220
  }
1221
+ await throwIfModelLoadFailed(response, model);
1181
1222
  if (response.status === 503) {
1182
1223
  const clonedResponse = response.clone();
1183
1224
  const errorCode = await getErrorCode(clonedResponse);
@@ -1499,6 +1540,6 @@ function detectImageFormat(bytes) {
1499
1540
  return "unknown";
1500
1541
  }
1501
1542
 
1502
- export { LoraLoadingError, ModelLoadingError, PoolError, ProvisioningError, RequestError, SDK_VERSION, SIEClient, SIEConnectionError, SIEError, ServerError, denseEmbedding, detectImageFormat, maxsim, maxsimBatch, maxsimDocuments, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
1543
+ export { LoraLoadingError, ModelLoadFailedError, ModelLoadingError, PoolError, ProvisioningError, RequestError, SDK_VERSION, SIEClient, SIEConnectionError, SIEError, ServerError, denseEmbedding, detectImageFormat, maxsim, maxsimBatch, maxsimDocuments, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
1503
1544
  //# sourceMappingURL=index.js.map
1504
1545
  //# sourceMappingURL=index.js.map