llama-web-bridge 0.1.91 → 0.1.92

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.
@@ -364,6 +364,11 @@ export class ModelUnloadedError extends Error {
364
364
  constructor(message?: string);
365
365
  }
366
366
 
367
+ export interface ModelTransferLengthError extends Error {
368
+ readonly name: 'ModelTransferLengthError';
369
+ readonly code: 'MODEL_TRANSFER_LENGTH_ERROR';
370
+ }
371
+
367
372
  export type ModelStagingErrorCode =
368
373
  | 'MODEL_STAGING_ALLOCATION_FAILED'
369
374
  | 'MODEL_TENSOR_SIZE_LIMIT_EXCEEDED'
@@ -553,9 +558,12 @@ export class LlamaWebGpuBridge {
553
558
  static supportsCompletionUsage: boolean;
554
559
  /** This bridge supports cache queries and opt-in projector caching. */
555
560
  static supportsModelCacheQuery: boolean;
561
+ /** This bridge honors `jsBackedModelStaging` and validates worker/core staging support. */
562
+ static supportsJsBackedModelStaging: boolean;
556
563
 
557
564
  constructor(config?: LlamaWebGpuBridgeConfig);
558
565
 
566
+ /** Can reject with `ModelTransferLengthError` if transfer length validation fails. */
559
567
  loadModelFromUrl(url: string | string[], options?: LoadModelOptions): Promise<unknown>;
560
568
  prefetchModelToCache(url: string | string[], options?: LoadModelOptions): Promise<unknown>;
561
569
  evictModelFromCache(url: string | string[], options?: Record<string, unknown>): Promise<unknown>;
@@ -591,6 +599,7 @@ export class LlamaWebGpuBridge {
591
599
  embedBatch(inputs: EmbedInput[], options?: EmbedOptions): Promise<number[][]>;
592
600
  scoreNextToken(prompt: string, options?: NextTokenScoreOptions): Promise<NextTokenScores>;
593
601
 
602
+ /** Can reject with `ModelTransferLengthError` if transfer length validation fails. */
594
603
  loadMultimodalProjector(url: string, options?: MultimodalProjectorLoadOptions): Promise<unknown>;
595
604
  unloadMultimodalProjector(): Promise<unknown>;
596
605
  supportsVision(): boolean;
@@ -1652,9 +1652,10 @@ function sumProgressValues(values) {
1652
1652
  return total;
1653
1653
  }
1654
1654
  function createModelTransferLengthError(message) {
1655
- const error = new Error(message);
1656
- error.name = "ModelTransferLengthError";
1657
- return error;
1655
+ return Object.assign(new Error(message), {
1656
+ name: "ModelTransferLengthError",
1657
+ code: "MODEL_TRANSFER_LENGTH_ERROR"
1658
+ });
1658
1659
  }
1659
1660
  function writeDirectChunk(directWriter, chunk, position, onBytesWritten) {
1660
1661
  let offset = 0;
@@ -7425,6 +7426,7 @@ var BridgeWorkerProxy = class {
7425
7426
  this._stopCspWatch = null;
7426
7427
  this.startMode = "direct";
7427
7428
  this._supportsIncrementalAudio = false;
7429
+ this._supportsJsBackedModelStaging = false;
7428
7430
  this.coreRetired = false;
7429
7431
  let workerInitError = null;
7430
7432
  const moduleCandidates = [moduleUrl];
@@ -7482,6 +7484,7 @@ var BridgeWorkerProxy = class {
7482
7484
  const type = message.type;
7483
7485
  if (type === "ready") {
7484
7486
  this._supportsIncrementalAudio = message.supportsIncrementalAudio === true;
7487
+ this._supportsJsBackedModelStaging = message.supportsJsBackedModelStaging === true;
7485
7488
  this._clearReadyTimeout();
7486
7489
  this._endCspWatch();
7487
7490
  this._readyResolve?.();
@@ -7540,6 +7543,12 @@ var BridgeWorkerProxy = class {
7540
7543
  if (method === "synthesizeSpeech" && args[0]?.streamAudio === true && !this._supportsIncrementalAudio) {
7541
7544
  throw new TextToSpeechStreamingUnsupportedError();
7542
7545
  }
7546
+ if ((method === "loadModelFromUrl" || method === "loadMultimodalProjector") && this._config.jsBackedModelStaging === true && !this._supportsJsBackedModelStaging) {
7547
+ throw new ModelStagingError(
7548
+ "MODEL_STAGING_UNSUPPORTED",
7549
+ "The worker did not declare supportsJsBackedModelStaging. The bridge and worker scripts must come from the same release."
7550
+ );
7551
+ }
7543
7552
  const id = this._nextId++;
7544
7553
  const timeoutMs = this._resolveRequestTimeoutMs(method, args);
7545
7554
  const transfers = Array.isArray(transferList) ? transferList.filter((item) => item != null) : [];
@@ -7705,6 +7714,7 @@ var LlamaWebGpuBridge = class {
7705
7714
  static supportsSafariAdaptiveGpu = LlamaWebGpuBridgeRuntime.supportsSafariAdaptiveGpu === true;
7706
7715
  static supportsCompletionUsage = true;
7707
7716
  static supportsModelCacheQuery = true;
7717
+ static supportsJsBackedModelStaging = true;
7708
7718
  constructor(config = {}) {
7709
7719
  this._config = config;
7710
7720
  this._runtime = null;
@@ -8372,6 +8382,10 @@ var LlamaWebGpuBridge = class {
8372
8382
  }
8373
8383
  return error instanceof ModelStagingError || error.name === "ModelStagingError";
8374
8384
  }
8385
+ _isNonRetryableLoadError(error) {
8386
+ const loadError = error;
8387
+ return loadError?.name === "ModelTransferLengthError" || loadError?.code === "MODEL_TRANSFER_LENGTH_ERROR" || this._isNonRecoverableStagingError(error);
8388
+ }
8375
8389
  _isRecoverableWorkerFsError(error) {
8376
8390
  if (isCoreRetiredError(error) || error instanceof SingleThreadCoreError || this._isNonRecoverableStagingError(error)) {
8377
8391
  return false;
@@ -9488,7 +9502,7 @@ var LlamaWebGpuBridge = class {
9488
9502
  } catch (error) {
9489
9503
  this._throwIfOperationCancelled(error, "Projector operation was cancelled.");
9490
9504
  this._throwIfWorkerCoreRetired(error);
9491
- if (!startedWithWorker || this._isNonRecoverableStagingError(error)) {
9505
+ if (!startedWithWorker || this._isNonRetryableLoadError(error)) {
9492
9506
  throw error;
9493
9507
  }
9494
9508
  const reason = serializeWorkerError(error);
@@ -9506,7 +9520,7 @@ var LlamaWebGpuBridge = class {
9506
9520
  );
9507
9521
  return retryResult;
9508
9522
  } catch (retryError) {
9509
- if (this._isNonRecoverableStagingError(retryError)) {
9523
+ if (this._isNonRetryableLoadError(retryError)) {
9510
9524
  throw retryError;
9511
9525
  }
9512
9526
  const retryReason = serializeWorkerError(retryError);
@@ -10771,11 +10785,12 @@ function installBridgeWorkerHost() {
10771
10785
  } catch (_) {
10772
10786
  state = void 0;
10773
10787
  }
10788
+ const message = error instanceof Error ? error.message || error.name || "Worker request failed" : serializeWorkerError(error);
10774
10789
  const decisionErrorCode = decisionErrorCodeOf(error);
10775
10790
  self.postMessage({
10776
10791
  type: "error",
10777
10792
  id,
10778
- message: serializeWorkerError(error),
10793
+ message,
10779
10794
  ...error instanceof EmbeddingError ? { embeddingErrorCode: error.code } : {},
10780
10795
  ...error instanceof CrossOriginIsolationError || error instanceof SingleThreadCoreError || error instanceof ModelUnloadedError ? { errorCode: error.code } : {},
10781
10796
  ...error instanceof Error && error.name === "ModelTransferLengthError" ? { errorCode: "MODEL_TRANSFER_LENGTH_ERROR" } : {},
@@ -10799,7 +10814,11 @@ function installBridgeWorkerHost() {
10799
10814
  disableWorker: true
10800
10815
  });
10801
10816
  bridge._onCoreRetired = () => self.postMessage({ type: "core-retired" });
10802
- self.postMessage({ type: "ready", supportsIncrementalAudio: true });
10817
+ self.postMessage({
10818
+ type: "ready",
10819
+ supportsIncrementalAudio: true,
10820
+ supportsJsBackedModelStaging: true
10821
+ });
10803
10822
  return;
10804
10823
  }
10805
10824
  if (type !== "call") {
@@ -1652,9 +1652,10 @@ function sumProgressValues(values) {
1652
1652
  return total;
1653
1653
  }
1654
1654
  function createModelTransferLengthError(message) {
1655
- const error = new Error(message);
1656
- error.name = "ModelTransferLengthError";
1657
- return error;
1655
+ return Object.assign(new Error(message), {
1656
+ name: "ModelTransferLengthError",
1657
+ code: "MODEL_TRANSFER_LENGTH_ERROR"
1658
+ });
1658
1659
  }
1659
1660
  function writeDirectChunk(directWriter, chunk, position, onBytesWritten) {
1660
1661
  let offset = 0;
@@ -7425,6 +7426,7 @@ var BridgeWorkerProxy = class {
7425
7426
  this._stopCspWatch = null;
7426
7427
  this.startMode = "direct";
7427
7428
  this._supportsIncrementalAudio = false;
7429
+ this._supportsJsBackedModelStaging = false;
7428
7430
  this.coreRetired = false;
7429
7431
  let workerInitError = null;
7430
7432
  const moduleCandidates = [moduleUrl];
@@ -7482,6 +7484,7 @@ var BridgeWorkerProxy = class {
7482
7484
  const type = message.type;
7483
7485
  if (type === "ready") {
7484
7486
  this._supportsIncrementalAudio = message.supportsIncrementalAudio === true;
7487
+ this._supportsJsBackedModelStaging = message.supportsJsBackedModelStaging === true;
7485
7488
  this._clearReadyTimeout();
7486
7489
  this._endCspWatch();
7487
7490
  this._readyResolve?.();
@@ -7540,6 +7543,12 @@ var BridgeWorkerProxy = class {
7540
7543
  if (method === "synthesizeSpeech" && args[0]?.streamAudio === true && !this._supportsIncrementalAudio) {
7541
7544
  throw new TextToSpeechStreamingUnsupportedError();
7542
7545
  }
7546
+ if ((method === "loadModelFromUrl" || method === "loadMultimodalProjector") && this._config.jsBackedModelStaging === true && !this._supportsJsBackedModelStaging) {
7547
+ throw new ModelStagingError(
7548
+ "MODEL_STAGING_UNSUPPORTED",
7549
+ "The worker did not declare supportsJsBackedModelStaging. The bridge and worker scripts must come from the same release."
7550
+ );
7551
+ }
7543
7552
  const id = this._nextId++;
7544
7553
  const timeoutMs = this._resolveRequestTimeoutMs(method, args);
7545
7554
  const transfers = Array.isArray(transferList) ? transferList.filter((item) => item != null) : [];
@@ -7705,6 +7714,7 @@ var LlamaWebGpuBridge = class {
7705
7714
  static supportsSafariAdaptiveGpu = LlamaWebGpuBridgeRuntime.supportsSafariAdaptiveGpu === true;
7706
7715
  static supportsCompletionUsage = true;
7707
7716
  static supportsModelCacheQuery = true;
7717
+ static supportsJsBackedModelStaging = true;
7708
7718
  constructor(config = {}) {
7709
7719
  this._config = config;
7710
7720
  this._runtime = null;
@@ -8372,6 +8382,10 @@ var LlamaWebGpuBridge = class {
8372
8382
  }
8373
8383
  return error instanceof ModelStagingError || error.name === "ModelStagingError";
8374
8384
  }
8385
+ _isNonRetryableLoadError(error) {
8386
+ const loadError = error;
8387
+ return loadError?.name === "ModelTransferLengthError" || loadError?.code === "MODEL_TRANSFER_LENGTH_ERROR" || this._isNonRecoverableStagingError(error);
8388
+ }
8375
8389
  _isRecoverableWorkerFsError(error) {
8376
8390
  if (isCoreRetiredError(error) || error instanceof SingleThreadCoreError || this._isNonRecoverableStagingError(error)) {
8377
8391
  return false;
@@ -9488,7 +9502,7 @@ var LlamaWebGpuBridge = class {
9488
9502
  } catch (error) {
9489
9503
  this._throwIfOperationCancelled(error, "Projector operation was cancelled.");
9490
9504
  this._throwIfWorkerCoreRetired(error);
9491
- if (!startedWithWorker || this._isNonRecoverableStagingError(error)) {
9505
+ if (!startedWithWorker || this._isNonRetryableLoadError(error)) {
9492
9506
  throw error;
9493
9507
  }
9494
9508
  const reason = serializeWorkerError(error);
@@ -9506,7 +9520,7 @@ var LlamaWebGpuBridge = class {
9506
9520
  );
9507
9521
  return retryResult;
9508
9522
  } catch (retryError) {
9509
- if (this._isNonRecoverableStagingError(retryError)) {
9523
+ if (this._isNonRetryableLoadError(retryError)) {
9510
9524
  throw retryError;
9511
9525
  }
9512
9526
  const retryReason = serializeWorkerError(retryError);
@@ -10771,11 +10785,12 @@ function installBridgeWorkerHost() {
10771
10785
  } catch (_) {
10772
10786
  state = void 0;
10773
10787
  }
10788
+ const message = error instanceof Error ? error.message || error.name || "Worker request failed" : serializeWorkerError(error);
10774
10789
  const decisionErrorCode = decisionErrorCodeOf(error);
10775
10790
  self.postMessage({
10776
10791
  type: "error",
10777
10792
  id,
10778
- message: serializeWorkerError(error),
10793
+ message,
10779
10794
  ...error instanceof EmbeddingError ? { embeddingErrorCode: error.code } : {},
10780
10795
  ...error instanceof CrossOriginIsolationError || error instanceof SingleThreadCoreError || error instanceof ModelUnloadedError ? { errorCode: error.code } : {},
10781
10796
  ...error instanceof Error && error.name === "ModelTransferLengthError" ? { errorCode: "MODEL_TRANSFER_LENGTH_ERROR" } : {},
@@ -10799,7 +10814,11 @@ function installBridgeWorkerHost() {
10799
10814
  disableWorker: true
10800
10815
  });
10801
10816
  bridge._onCoreRetired = () => self.postMessage({ type: "core-retired" });
10802
- self.postMessage({ type: "ready", supportsIncrementalAudio: true });
10817
+ self.postMessage({
10818
+ type: "ready",
10819
+ supportsIncrementalAudio: true,
10820
+ supportsJsBackedModelStaging: true
10821
+ });
10803
10822
  return;
10804
10823
  }
10805
10824
  if (type !== "call") {
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "artifacts": {
3
3
  "llama_webgpu_bridge.d.ts": {
4
- "sha256": "1d032299591d9f7d453994d083341c6a1f923fcb34dc86c11dd65470e02ef181",
5
- "size_bytes": 28340
4
+ "sha256": "bab791021bb7a2654127b7e3eced01f408e7960d75699596f5fe6f7ad6af56a6",
5
+ "size_bytes": 28814
6
6
  },
7
7
  "llama_webgpu_bridge.js": {
8
- "sha256": "afe2aa6317fc029d2fd4a337a8ca475843defca8db3d14705828fcd88108bf12",
9
- "size_bytes": 423426
8
+ "sha256": "c72d480fba9feef0405562bebd7a70b7e44fc63562ad1d7da8018753856d4018",
9
+ "size_bytes": 424423
10
10
  },
11
11
  "llama_webgpu_bridge_worker.js": {
12
- "sha256": "84d7b0448e37bb5fc3e567f437e55e2445171c4c0945ad1aa7de4b7c2db24388",
13
- "size_bytes": 422468
12
+ "sha256": "4c708c879eeaad19dc55c7f01fdd3ab901b8f83e69f63e0669a36024f32d3ef7",
13
+ "size_bytes": 423465
14
14
  },
15
15
  "llama_webgpu_core.js": {
16
16
  "sha256": "63decaee039c8f91b5923494a44bff7b7f3d83e3eafefff40cef274868069b82",
@@ -46,8 +46,8 @@
46
46
  }
47
47
  },
48
48
  "assets_repository": "leehack/llama-web-bridge-assets",
49
- "bridge_assets_tag": "v0.1.91",
50
- "bridge_commit": "f266d06c3d997831ae10c578c562244ed6e4e63f",
49
+ "bridge_assets_tag": "v0.1.92",
50
+ "bridge_commit": "d7236223d2393d51dab541df6caf3ef88f06d49b",
51
51
  "bridge_repository": "leehack/llama-web-bridge",
52
52
  "capabilities": {
53
53
  "memory64": true,
@@ -78,16 +78,16 @@
78
78
  "emscripten_version": "6.0.8",
79
79
  "files": {
80
80
  "llama_webgpu_bridge.d.ts": {
81
- "sha256": "1d032299591d9f7d453994d083341c6a1f923fcb34dc86c11dd65470e02ef181",
82
- "size_bytes": 28340
81
+ "sha256": "bab791021bb7a2654127b7e3eced01f408e7960d75699596f5fe6f7ad6af56a6",
82
+ "size_bytes": 28814
83
83
  },
84
84
  "llama_webgpu_bridge.js": {
85
- "sha256": "afe2aa6317fc029d2fd4a337a8ca475843defca8db3d14705828fcd88108bf12",
86
- "size_bytes": 423426
85
+ "sha256": "c72d480fba9feef0405562bebd7a70b7e44fc63562ad1d7da8018753856d4018",
86
+ "size_bytes": 424423
87
87
  },
88
88
  "llama_webgpu_bridge_worker.js": {
89
- "sha256": "84d7b0448e37bb5fc3e567f437e55e2445171c4c0945ad1aa7de4b7c2db24388",
90
- "size_bytes": 422468
89
+ "sha256": "4c708c879eeaad19dc55c7f01fdd3ab901b8f83e69f63e0669a36024f32d3ef7",
90
+ "size_bytes": 423465
91
91
  },
92
92
  "llama_webgpu_core.js": {
93
93
  "sha256": "63decaee039c8f91b5923494a44bff7b7f3d83e3eafefff40cef274868069b82",
@@ -122,15 +122,15 @@
122
122
  "size_bytes": 10476055
123
123
  }
124
124
  },
125
- "github_run_id": "44969471003",
126
- "github_run_url": "https://github.com/leehack/llama-web-bridge/actions/runs/44969471003",
125
+ "github_run_id": "45031773094",
126
+ "github_run_url": "https://github.com/leehack/llama-web-bridge/actions/runs/45031773094",
127
127
  "llama_cpp_commit": "b1b770d90d94cad9e9ea5b993bdbc383a522fb28",
128
128
  "llama_cpp_tag": "v1.0.0",
129
129
  "native_commit": "4b480fbf303d69c1f67416a25986bd0913728ede",
130
130
  "native_manifest_sha256": "7d8e69971e2e3bd73d258005c86d5f47d0cd96e1d7f08a23fdf44dd244ea1316",
131
131
  "native_release_tag": "v1.0.0-4",
132
132
  "native_repository": "leehack/llamadart-native",
133
- "orchestrator_correlation_id": "manual-v0.1.91-f266d06",
133
+ "orchestrator_correlation_id": "manual-v0.1.92-d723622",
134
134
  "qualification_gates": {
135
135
  "multimodal": "passed",
136
136
  "speech_to_text": "required-automated-qualification",
@@ -139,9 +139,9 @@
139
139
  },
140
140
  "release_channel": "stable",
141
141
  "release_rebuild": 0,
142
- "release_tag": "v0.1.91",
142
+ "release_tag": "v0.1.92",
143
143
  "schema_version": 2,
144
- "source_commit": "f266d06c3d997831ae10c578c562244ed6e4e63f",
144
+ "source_commit": "d7236223d2393d51dab541df6caf3ef88f06d49b",
145
145
  "source_repository": "leehack/llama-web-bridge",
146
146
  "unproven_capabilities": {
147
147
  "hardware_gpu_acceleration": "unavailable-on-hosted-runners",
@@ -1,6 +1,6 @@
1
- afe2aa6317fc029d2fd4a337a8ca475843defca8db3d14705828fcd88108bf12 llama_webgpu_bridge.js
2
- 84d7b0448e37bb5fc3e567f437e55e2445171c4c0945ad1aa7de4b7c2db24388 llama_webgpu_bridge_worker.js
3
- 1d032299591d9f7d453994d083341c6a1f923fcb34dc86c11dd65470e02ef181 llama_webgpu_bridge.d.ts
1
+ c72d480fba9feef0405562bebd7a70b7e44fc63562ad1d7da8018753856d4018 llama_webgpu_bridge.js
2
+ 4c708c879eeaad19dc55c7f01fdd3ab901b8f83e69f63e0669a36024f32d3ef7 llama_webgpu_bridge_worker.js
3
+ bab791021bb7a2654127b7e3eced01f408e7960d75699596f5fe6f7ad6af56a6 llama_webgpu_bridge.d.ts
4
4
  63decaee039c8f91b5923494a44bff7b7f3d83e3eafefff40cef274868069b82 llama_webgpu_core.js
5
5
  6e816f27ca86afca37425b56388f16b777da59016d3609b3d3683f0b3316b4a4 llama_webgpu_core.wasm
6
6
  78f2fc465f8280b63371422954e6146bb5f5cbe386dd203973abcd4844bd3e3d llama_webgpu_core_mem64.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llama-web-bridge",
3
- "version": "0.1.91",
3
+ "version": "0.1.92",
4
4
  "description": "WebGPU and WebAssembly browser bridge runtime for llama.cpp",
5
5
  "license": "MIT",
6
6
  "type": "module",