@caldrix-ai/caldrix 0.0.0-stage → 0.1.0
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/CHANGELOG.md +25 -0
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +176 -2
- package/THIRD_PARTY_NOTICES.md +5281 -0
- package/dist/chunk-PZGTLL5H.js +1 -0
- package/dist/index.d.ts +228 -0
- package/dist/index.js +1 -0
- package/dist/worker.js +1 -0
- package/host/caldrix_web.d.ts +165 -0
- package/host/caldrix_web.js +1 -0
- package/host/caldrix_web_bg.wasm +0 -0
- package/host/caldrix_web_bg.wasm.d.ts +35 -0
- package/package.json +63 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Format after [Keep a Changelog](https://keepachangelog.com/); versions are independent semver, tagged
|
|
4
|
+
`caldrix-js-v<version>`.
|
|
5
|
+
|
|
6
|
+
## 0.1.0 — 2026-10-27
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- The first release, published to npm as `@caldrix-ai/caldrix` (the product is caldrix.js).
|
|
11
|
+
- `Caldrix.load(alias, options)`: loads a model by alias into a dedicated worker and returns an engine
|
|
12
|
+
with `chat`, `complete` (both async iterables of deltas), `doctor` and `dispose`; `probe()` reports
|
|
13
|
+
what the browser offers.
|
|
14
|
+
- Two tiers behind one API: the wasm tier (plan dtypes f32 and bf16) and the WebGPU tier (f32 plan, f32
|
|
15
|
+
or f16 weight storage; f16 has not run in a browser), chosen by `backend: "auto"` from the probe, with the reason in `doctor().why`.
|
|
16
|
+
- Model files from the Hugging Face Hub, digest-checked where the Hub exposes one, cached in the
|
|
17
|
+
browser; `hubBaseUrl` and `offline` options.
|
|
18
|
+
- `assets` option for where the package's worker and `.wasm` come from, and a jsdelivr fallback for the
|
|
19
|
+
package's own files at the installed version (on by default; reported in `doctor().assets` and on
|
|
20
|
+
the console; `assets.fallback: false` turns it off).
|
|
21
|
+
- A same-origin shim so the worker can be served from another origin.
|
|
22
|
+
- Built and driven under Vite 8.3.5 and Next.js 16.4.3 (Turbopack and webpack, `output: "export"`) on the wasm tier, with no bundler configuration.
|
|
23
|
+
- A default context clamp on WebGPU, reported by `doctor()`.
|
|
24
|
+
- Apache-2.0 license for the package, including the compiled browser host it ships, and
|
|
25
|
+
`THIRD_PARTY_NOTICES.md` for the crates compiled into it.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,177 @@
|
|
|
1
|
-
#
|
|
1
|
+
# caldrix.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Run a language model in the browser, in a worker, on WebGPU or WebAssembly. One package: the engine's
|
|
4
|
+
compiled browser host (WebAssembly), the worker that drives it, and the typed API around them. On npm it
|
|
5
|
+
is [`@caldrix-ai/caldrix`](https://www.npmjs.com/package/@caldrix-ai/caldrix).
|
|
6
|
+
|
|
7
|
+
This page states only what `inferno/WEB-VERIFICATION.md` records (in
|
|
8
|
+
the Caldrix repository, which is private, so you cannot open it), what the package's own tests run in
|
|
9
|
+
CI, and what the source does.
|
|
10
|
+
|
|
11
|
+
<!-- host-commit: 16f90f2ef2c3f43cdb9c2520f8d7b573aa13a4d8 -->
|
|
12
|
+
|
|
13
|
+
The compiled host in `host/` is built from the `caldrix-web` crate at the commit in the marker above.
|
|
14
|
+
The release workflow overwrites that marker with the commit it builds; the value in a source checkout
|
|
15
|
+
is a placeholder.
|
|
16
|
+
|
|
17
|
+
## Install and quick start
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install @caldrix-ai/caldrix
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { Caldrix } from "@caldrix-ai/caldrix";
|
|
25
|
+
|
|
26
|
+
const engine = await Caldrix.load("smollm2-instruct", {
|
|
27
|
+
onProgress: ({ file, loaded, total }) => console.log(file, loaded, total),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
for await (const delta of engine.chat([{ role: "user", content: "Say hello." }], { maxTokens: 32 })) {
|
|
31
|
+
if (!delta.done) document.body.append(delta.text);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log(engine.doctor());
|
|
35
|
+
engine.dispose();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The API, as the package's declarations have it:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
class Caldrix {
|
|
42
|
+
static load(alias: string, opts?: LoadOptions): Promise<Engine>;
|
|
43
|
+
}
|
|
44
|
+
class Engine {
|
|
45
|
+
chat(messages: ChatMessage[], opts?: GenerateOptions): AsyncIterable<Delta>;
|
|
46
|
+
complete(input: string | { ids: number[] }, opts?: GenerateOptions): AsyncIterable<Delta>;
|
|
47
|
+
doctor(): DoctorReport;
|
|
48
|
+
/** Release the worker and everything in it. Every later call throws `request`. */
|
|
49
|
+
dispose(): void;
|
|
50
|
+
}
|
|
51
|
+
declare function probe(): Promise<Capabilities>;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
A `Delta` is `{ text, token?, done, finishReason?: "stop" | "length" | "abort", usage? }`. Generation
|
|
55
|
+
options are `temperature`, `topK`, `topP`, `minP`, `repetitionPenalty`, `seed` and `maxTokens`, plus a
|
|
56
|
+
`signal` (an `AbortSignal`). Errors are `CaldrixError` with a `kind` of `probe`, `fit`, `architecture`,
|
|
57
|
+
`fetch`, `digest`, `validate`, `lowering`, `backend` or `request`.
|
|
58
|
+
|
|
59
|
+
## Options
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
interface LoadOptions {
|
|
63
|
+
backend?: "auto" | "webgpu" | "wasm" | "webgl";
|
|
64
|
+
offline?: boolean;
|
|
65
|
+
onProgress?: (p: { file: string; loaded: number; total: number | null }) => void;
|
|
66
|
+
hubBaseUrl?: string;
|
|
67
|
+
dtype?: "f32" | "bf16";
|
|
68
|
+
maxContext?: number;
|
|
69
|
+
storage?: "auto" | "f32";
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
assets?: { worker?: string | URL; hostWasm?: string | URL; fallback?: boolean; cdn?: string | URL };
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- **`backend`**: `"auto"` (the default) probes the browser and picks WebGPU when an adapter is present
|
|
76
|
+
and `requestDevice` succeeds, wasm otherwise; a bf16 plan goes to wasm on the page, before the worker starts. `"webgpu"` and `"wasm"` force a tier. `"webgl"` is declared and refused: the backend is
|
|
77
|
+
not built. Under `"auto"`, a load WebGPU then refuses (a larger explicit context, a limit, a
|
|
78
|
+
device that fails to open) is served by the wasm tier, and `doctor().why` says so.
|
|
79
|
+
- **`storage`**: the WebGPU tier's weight storage. `"auto"` stores the block GEMM weights as f16 when the
|
|
80
|
+
adapter has `shader-f16`; `"f32"` keeps them f32 on any adapter. `doctor().storage` reports it (`null`
|
|
81
|
+
on wasm). `storage: "f32"` with `backend: "wasm"` is refused.
|
|
82
|
+
- **`hubBaseUrl`**: where model files are fetched from (default `https://huggingface.co`). `offline`
|
|
83
|
+
uses only the browser's cache and fails with `fetch` for a file it lacks.
|
|
84
|
+
- **`assets`**: where the package's own files come from; see "Network" below.
|
|
85
|
+
- **`doctor()`** reports the tier that runs, `device`, `dtype`, `storage`, `adapter`, on WebGPU only `maxContext` and `contextClamp`, where each model file came from and whether its digest was checked, `assets` (the
|
|
86
|
+
source and URL of the worker and the `.wasm`: `bundle`, `cdn` or `page`), and `why`.
|
|
87
|
+
|
|
88
|
+
## What has run, and where
|
|
89
|
+
|
|
90
|
+
Only these runs are recorded (`inferno/WEB-VERIFICATION.md`, entries 5, 8 and 9); nothing else is claimed.
|
|
91
|
+
|
|
92
|
+
- **Model:** SmolLM2-135M-Instruct, one prompt, 8 greedy tokens. No other model or prompt.
|
|
93
|
+
- **Browser:** Chromium driven by Playwright, headless only: the headless shell 153.0.8010.12 on Linux and on
|
|
94
|
+
the operator's Apple M1 Max, and on that Mac Playwright's full Chromium (new headless mode, userAgent
|
|
95
|
+
`HeadlessChrome/153.0.0.0`) for the WebGPU tier. No other browser.
|
|
96
|
+
- **wasm tier:** both plan dtypes, f32 and bf16, on Linux and on the Mac with the same lines. The tokens
|
|
97
|
+
equal the references' tokens. The f32 logits stayed inside the 1e-2 bound on every row, worst 7.796401e-4.
|
|
98
|
+
The bf16 result rests on token equality alone; the logits were recorded, not gated.
|
|
99
|
+
- **WebGPU tier on a real adapter:** the Mac's own, vendor `apple`, architecture `metal-3` (its own
|
|
100
|
+
strings; `device` and `description` empty), with `shader-f16`. The f32 plan at f32 weight storage,
|
|
101
|
+
token-exact, logits worst 6.6792103e-4 against the same 1e-2 bound; at f16 weight storage, a diagnostic
|
|
102
|
+
gated by no bound, every row finite, worst 5.0272985e-4, token-exact. The product path's tokens equal the
|
|
103
|
+
test worker's at both storage forms.
|
|
104
|
+
- **WebGPU tier on SwiftShader:** Dawn on SwiftShader, Google's CPU Vulkan implementation, which is a CPU and
|
|
105
|
+
not a GPU. The f32 plan at f32 weight storage, token-exact, logits worst 5.874168e-4 against the same bound.
|
|
106
|
+
- **Phase 2's exit is closed on the gates** (entry 9), with the run's two process deviations recorded there:
|
|
107
|
+
the browser stages ran outside the sandbox, and the build's first attempt failed at its install step.
|
|
108
|
+
- **Not run:** any other adapter or GPU; a headed browser; the browser stages inside a sandbox; the scalar
|
|
109
|
+
(non-SIMD) wasm spelling in a browser; real-Hub digest behaviour (the runs used a loopback Hub stand-in);
|
|
110
|
+
any browser other than Playwright's headless Chromium; any other model. No performance figure is recorded
|
|
111
|
+
or claimed.
|
|
112
|
+
|
|
113
|
+
## The WebGPU default context
|
|
114
|
+
|
|
115
|
+
Without `maxContext`, the WebGPU tier clamps the context so the attention kernel's grid stays within
|
|
116
|
+
`maxComputeWorkgroupsPerDimension`. At the standard 65535 workgroups per dimension, SmolLM2's 8192
|
|
117
|
+
default context loads at 7282; `doctor()` reports the clamp in `contextClamp` and the value in
|
|
118
|
+
`maxContext`. A larger `maxContext` that the adapter's limits cannot hold is refused by WebGPU, and
|
|
119
|
+
`"auto"` then serves the load on wasm.
|
|
120
|
+
|
|
121
|
+
## Network
|
|
122
|
+
|
|
123
|
+
No telemetry. The network is the Hub, for the model files you asked for, and jsdelivr, for the
|
|
124
|
+
package's own assets when the bundle's copy fails.
|
|
125
|
+
|
|
126
|
+
- **When the fallback fires:** the worker falls back if it fails before it is ready (its script, a chunk
|
|
127
|
+
or the host glue did not load, or the page refused to construct it); the `.wasm` falls back, inside
|
|
128
|
+
the worker, if its fetch fails. Each asset is tried locally first and falls back independently.
|
|
129
|
+
- **What it fetches:** `https://cdn.jsdelivr.net/npm/@caldrix-ai/caldrix@<installed version>/dist/worker.js` and
|
|
130
|
+
`.../host/caldrix_web_bg.wasm`, at the version you installed, so the `.wasm` matches the glue.
|
|
131
|
+
- **It is never silent:** it is warned once per load on the console, and `doctor().assets` reports the
|
|
132
|
+
source and URL of each asset.
|
|
133
|
+
- **Opt out:** `assets: { fallback: false }`. An explicit `assets.worker` or `assets.hostWasm` is used as
|
|
134
|
+
given, with no fallback for that asset. `assets.cdn` points the fallback at your own mirror.
|
|
135
|
+
- **What it trusts:** the fallback runs jsdelivr's copy of that version with your page's origin (the
|
|
136
|
+
worker can fetch your origin with its credentials and read its IndexedDB and caches), and no integrity
|
|
137
|
+
check is possible for a worker's module import, so a page that cannot accept that sets
|
|
138
|
+
`assets.fallback: false`.
|
|
139
|
+
- **Not yet exercised:** until the package is on npm, the real jsdelivr path has not run; the tests point
|
|
140
|
+
`assets.cdn` at a loopback origin.
|
|
141
|
+
- **Content-Security-Policy:** a page that uses the fallback needs `worker-src blob:` (a cross-origin
|
|
142
|
+
worker starts through a same-origin module shim), `script-src` and `connect-src` for the CDN origin,
|
|
143
|
+
and `'wasm-unsafe-eval'` for any WebAssembly.
|
|
144
|
+
|
|
145
|
+
## Bundlers
|
|
146
|
+
|
|
147
|
+
What ran: Vite 8.3.5 and Next.js 16.4.3 (Turbopack and webpack) with `output: "export"`, a minimal app
|
|
148
|
+
each, on the wasm tier with a tiny Llama fixture served from a loopback Hub, in headless Chromium. The
|
|
149
|
+
package's own bundler test (`tests/bundlers/`) installs the packed tarball into those apps and runs in
|
|
150
|
+
CI. Those apps needed no bundler configuration. Nothing else is claimed: other versions, other bundlers
|
|
151
|
+
and the WebGPU tier under a bundler have not been run. Production builds only (`vite build`, `next build`);
|
|
152
|
+
`vite dev` and `next dev` were not run. Notes:
|
|
153
|
+
|
|
154
|
+
- Each app ships an unused copy of the worker, about 16 kB, and (Next only) an unused copy of the host
|
|
155
|
+
glue, about 13.5 kB. The worker copy comes from the package's `new URL("./worker.js", import.meta.url)`
|
|
156
|
+
literal, which it keeps so bundlers find the worker; the glue copy comes from wasm-bindgen's own
|
|
157
|
+
`.wasm` URL literal inside the glue, which the package does not control.
|
|
158
|
+
- By the package's design, not run: with assets on another origin (Vite `base`, Next `assetPrefix`) the
|
|
159
|
+
bundle try is cross-origin, the shim imports the raw copy of the worker whose `../host/` is not beside
|
|
160
|
+
it, and every load falls back to jsdelivr. Set `assets.worker` and `assets.hostWasm` instead, serving
|
|
161
|
+
`dist/` and `host/` together on that origin.
|
|
162
|
+
- Next pages that import the package are client components.
|
|
163
|
+
|
|
164
|
+
## Releases and provenance
|
|
165
|
+
|
|
166
|
+
Versions are independent semver; releases are tagged `caldrix-js-v0.x.y` and the tag must equal the
|
|
167
|
+
version in `package.json`. There is no npm provenance: the source repository is private, and npm does not
|
|
168
|
+
generate provenance for a private repository. Publishes are staged by a limited token and released by
|
|
169
|
+
hand with 2FA: the release workflow's token can only stage a version (npm's "stage only" access), and
|
|
170
|
+
a staged version goes live only when the owner approves it on npmjs.com with two-factor
|
|
171
|
+
authentication. The tarball carries no sourcemaps.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
The npm package `@caldrix-ai/caldrix` (caldrix.js) is under Apache-2.0 (`LICENSE`, `NOTICE`). The compiler itself is not open source; this package ships its compiled
|
|
176
|
+
browser host (`host/`) under this license. Third-party components compiled into the host remain under
|
|
177
|
+
their own licenses; see `THIRD_PARTY_NOTICES.md`.
|