@ohtaman/washi 0.10.0-rc.1 → 0.10.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/README.md CHANGED
@@ -201,12 +201,13 @@ console.log(res.conflicts); // HiGHS: ["rush_required"]
201
201
  - **Standalone ESM / Script Tag / CDN**: Serve `dist/` (`washi.js`, `core-*.js`, `washi.min.js`, and `solvers/`) or load from a CDN. `washi.js` and `washi.min.js` both include HiGHS and Pumpkin out of the box.
202
202
 
203
203
  ```html
204
- <!-- Browser ESM (includes both HiGHS and Pumpkin) -->
204
+ <!-- Browser ESM via CDN (includes both HiGHS and Pumpkin out of the box) -->
205
205
  <script type="module">
206
- import { Model } from "./washi/washi.js";
206
+ import { Model } from "https://esm.sh/@ohtaman/washi";
207
+ // Or direct jsDelivr / self-hosted: "https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/washi.js" / "./washi/washi.js"
207
208
  // Optional solver plugins:
208
- // import "./washi/solvers/glpk.js"; // Optional GLPK plugin
209
- // import "./washi/solvers/z3.js"; // Optional Z3 plugin (see note below)
209
+ // import "https://esm.sh/@ohtaman/washi/solvers/glpk"; // Optional GLPK plugin
210
+ // import "https://esm.sh/@ohtaman/washi/solvers/z3"; // Optional Z3 plugin (see note below)
210
211
  const m = new Model();
211
212
  await m.solve();
212
213
  </script>
@@ -216,7 +217,7 @@ console.log(res.conflicts); // HiGHS: ["rush_required"]
216
217
  ```
217
218
 
218
219
  > [!TIP]
219
- > **CSP-restricted single-file pages (`connect-src 'none'`)**: If your host allows CDN scripts (`script-src`) but blocks `.wasm` `fetch()`, load the self-registering inline WASM packs (`solvers/highs-inline.js` / `solvers/pumpkin-inline.js` — usable as either an ES module `import` or a classic `<script>` tag) before your first `solve()` / `check()` call, with no base64 decoding or setter boilerplate. See the [Runtime Environments & Deployment Guide](https://washi.ohtaman.dev/getting-started/runtimes#csp-fetch-free).
220
+ > **CSP-restricted single-file previews (Claude.ai Artifacts, ChatGPT, Codex — `connect-src 'none'` / `'self'`)**: Where CDN scripts (`script-src`) are allowed but `.wasm` `fetch()` is blocked, also import the self-registering inline WASM packs (`dist/solvers/highs-inline.js` / `dist/solvers/pumpkin-inline.js`, or `@ohtaman/washi/solvers/*-inline`) before your first `solve()` / `check()` call—zero base64 or setter boilerplate required. See the [Runtime Environments & Deployment Guide](https://washi.ohtaman.dev/getting-started/runtimes#csp-fetch-free).
220
221
 
221
222
  > [!NOTE]
222
223
  > **Z3 in the Browser**: Because Z3's WebAssembly build uses `SharedArrayBuffer`, browsers require a **Secure Context** (`HTTPS` or `localhost`) and Cross-Origin Isolation headers (`Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`). See the [Cross-Origin Isolation Guide](https://washi.ohtaman.dev/getting-started/cross-origin) and [`examples/distribution/`](https://github.com/ohtaman/washi/blob/main/examples/distribution/README.md). **HiGHS**, **Pumpkin**, and **GLPK** work without Cross-Origin Isolation headers.
@@ -129,7 +129,20 @@ Include a sample test case with contradictory named rules, print res.status and
129
129
 
130
130
  ## 4. Packaging & Deployment Prompts (Single-File HTML, Sharing, Desktop & Mobile)
131
131
 
132
- Once a CLI script produces verified results—or directly inside an AI HTML preview—you can package the model as a hosted single-file preview, a zero-network offline `.html` file, or a desktop/mobile app.
132
+ Once a CLI script produces verified results—or directly inside an AI HTML preview—you can package the model as a hosted single-file preview, a lightweight online `.html` file, a zero-network offline `.html` file, or a desktop/mobile app.
133
+
134
+ ### Describing Your Target Without Naming Files
135
+
136
+ When your agent already has the WaSHI Agent Skill (`npx skills add ohtaman/washi`) or web access, you do **not** need to memorize or specify filenames or loaders (`dist/washi.js`, `dist/washi.min.js`, `*-inline.js`, `single-html.md`). Just state **where and under what network/runtime conditions** the code should run:
137
+
138
+ | What you want | How to ask naturally | What the agent selects |
139
+ | --- | --- | --- |
140
+ | **Standard project** (Node.js / Vite / Next.js) | *"Build this optimization app in Node.js / Vite with `@ohtaman/washi`."* | `npm install @ohtaman/washi` + standard `import { ... } from "@ohtaman/washi"`. |
141
+ | **Lightweight HTML, no build or server** *(online OK)* | *"Create a lightweight single-file `.html` with no build step or local server that opens directly via `file://` (online OK)."* | CDN `dist/washi.js` (ESM) or `dist/washi.min.js` (IIFE)—no build step and no `*-inline.js` required. |
142
+ | **Zero-network offline HTML** *(air-gapped / airplane mode)* | *"Make a completely offline single-file `.html` that works by double-clicking (`file://`) with zero internet access."* | Single-file Vite build (`references/single-html.md`) embedding WaSHI and gzipped WASM. |
143
+ | **Web chat preview** *(Claude / ChatGPT / Gemini)* | *"Build an interactive visualization for this model using `@ohtaman/washi`."* | CDN imports matching the sandbox's CSP (including `*-inline.js` where `fetch()` is blocked). |
144
+
145
+ Use the explicit prompt templates below when you want to pin a specific output format or when working in an environment without the WaSHI skill or documentation loaded.
133
146
 
134
147
  ### Hosted AI Previews & Instant URL Sharing (`*-inline.js` + ESM)
135
148
 
@@ -168,7 +181,7 @@ Read skills/washi/references/single-html.md (or node_modules/@ohtaman/washi/skil
168
181
  - Verify that dist/index.html runs over file:// in headless Chromium with zero external HTTP requests and zero console errors.
169
182
  ```
170
183
 
171
- **`file://` runtime notes**: Loading `washi.min.js` from an HTTPS CDN runs directly on `file://`. Self-hosted `.wasm` files require `http://` or `https://`, and browser Z3 requires Cross-Origin Isolation. Pass `{ useWorker: true }` in interactive `http(s):` apps when long solves should run off the UI thread; see [Runtime Environments](./runtimes.md) and [Cross-Origin Isolation](./cross-origin.md).
184
+ **`file://` runtime notes**: Loading `washi.min.js` or `dist/washi.js` from an HTTPS CDN runs directly on `file://` with no `*-inline.js` pack. Self-hosted `.wasm` files require `http://` or `https://`, and browser Z3 requires Cross-Origin Isolation. Pass `{ useWorker: true }` in interactive `http(s):` apps when long solves should run off the UI thread; see [Runtime Environments](./runtimes.md) and [Cross-Origin Isolation](./cross-origin.md).
172
185
 
173
186
  ### Offline Desktop & Mobile Apps (Vite + Tauri / Capacitor / PWA)
174
187
 
@@ -44,6 +44,8 @@ npm install glpk.js # Optional: GLPK solver (GPL-3.0)
44
44
 
45
45
  In browsers, Z3 requires a Secure Context and Cross-Origin Isolation headers — `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy`, abbreviated `COOP`/`COEP`. See [Cross-Origin Isolation](./cross-origin.md) for server setup.
46
46
 
47
+ For bundler-free browser or CDN usage (`https://esm.sh/@ohtaman/washi`, `dist/washi.js`, or Gemini Canvas), HiGHS and Pumpkin run out of the box with no extra imports. In `fetch()`-restricted HTML sandboxes (`connect-src 'none'` / `'self'`, such as **Claude.ai Artifacts**, **ChatGPT**, and **Codex**), also load `dist/solvers/highs-inline.js` / `pumpkin-inline.js`—see [Runtime Environments & Deployment](./runtimes.md#csp-fetch-free).
48
+
47
49
  ---
48
50
 
49
51
  ## 🚀 Quick Start
@@ -323,7 +323,7 @@ Load the self-registering inline WASM packs (`solvers/highs-inline.js` / `@ohtam
323
323
  | **Claude.ai Artifacts** *(edit & published links)* | Blocked | Works *(ESM & Classic)* | Blocked | Option A (ESM + `*-inline.js`) |
324
324
  | **ChatGPT Inline Visualization** *(`codex-inline-visualization-*`)* | Blocked | Works *(ESM reliable; Classic can race on cold load)* | Blocked | Option A (ESM + `*-inline.js`) |
325
325
  | **Codex Inline Visualization** *(`codex-sandbox://...`)* | Blocked | Works *(ESM & Classic)* | Blocked | Option A (ESM + `*-inline.js`) |
326
- | **Gemini Canvas & Google Sites** *(1-click publish)* | Works | Works *(ESM & Classic)* | Works | Option A works everywhere; `{ useWorker: true }` also works |
326
+ | **Gemini Canvas & Google Sites** *(1-click publish)* | Works | Works *(ESM & Classic)* | Works *(Classic `washi.min.js`)* | Option A works everywhere (default `useWorker: false`); use Option B (`washi.min.js`) for `{ useWorker: true }` |
327
327
  | **Antigravity HTML Artifact Preview** | Blocked *(CDN blocked)* | Blocked *(CSP omits `'wasm-unsafe-eval'`)* | Blocked | Preview via local server + built-in browser or open `.html` in Chrome/Safari |
328
328
  | **Local Browser `file://`** *(Chrome / Safari)* | Works via HTTPS CDN | Works *(CDN or Vite offline bundle)* | Blocked | CDN Option A or offline [`skills/washi/references/single-html.md`](https://github.com/ohtaman/washi/blob/main/skills/washi/references/single-html.md) |
329
329
 
package/llms-full.txt CHANGED
@@ -489,6 +489,8 @@ npm install glpk.js # Optional: GLPK solver (GPL-3.0)
489
489
 
490
490
  In browsers, Z3 requires a Secure Context and Cross-Origin Isolation headers — `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy`, abbreviated `COOP`/`COEP`. See [Cross-Origin Isolation](docs/getting-started/cross-origin.md) for server setup.
491
491
 
492
+ For bundler-free browser or CDN usage (`https://esm.sh/@ohtaman/washi`, `dist/washi.js`, or Gemini Canvas), HiGHS and Pumpkin run out of the box with no extra imports. In `fetch()`-restricted HTML sandboxes (`connect-src 'none'` / `'self'`, such as **Claude.ai Artifacts**, **ChatGPT**, and **Codex**), also load `dist/solvers/highs-inline.js` / `pumpkin-inline.js`—see [Runtime Environments & Deployment](docs/getting-started/runtimes.md#csp-fetch-free).
493
+
492
494
  ---
493
495
 
494
496
  ## 🚀 Quick Start
@@ -864,7 +866,7 @@ Load the self-registering inline WASM packs (`solvers/highs-inline.js` / `@ohtam
864
866
  | **Claude.ai Artifacts** *(edit & published links)* | Blocked | Works *(ESM & Classic)* | Blocked | Option A (ESM + `*-inline.js`) |
865
867
  | **ChatGPT Inline Visualization** *(`codex-inline-visualization-*`)* | Blocked | Works *(ESM reliable; Classic can race on cold load)* | Blocked | Option A (ESM + `*-inline.js`) |
866
868
  | **Codex Inline Visualization** *(`codex-sandbox://...`)* | Blocked | Works *(ESM & Classic)* | Blocked | Option A (ESM + `*-inline.js`) |
867
- | **Gemini Canvas & Google Sites** *(1-click publish)* | Works | Works *(ESM & Classic)* | Works | Option A works everywhere; `{ useWorker: true }` also works |
869
+ | **Gemini Canvas & Google Sites** *(1-click publish)* | Works | Works *(ESM & Classic)* | Works *(Classic `washi.min.js`)* | Option A works everywhere (default `useWorker: false`); use Option B (`washi.min.js`) for `{ useWorker: true }` |
868
870
  | **Antigravity HTML Artifact Preview** | Blocked *(CDN blocked)* | Blocked *(CSP omits `'wasm-unsafe-eval'`)* | Blocked | Preview via local server + built-in browser or open `.html` in Chrome/Safari |
869
871
  | **Local Browser `file://`** *(Chrome / Safari)* | Works via HTTPS CDN | Works *(CDN or Vite offline bundle)* | Blocked | CDN Option A or offline [`skills/washi/references/single-html.md`](https://github.com/ohtaman/washi/blob/main/skills/washi/references/single-html.md) |
870
872
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohtaman/washi",
3
- "version": "0.10.0-rc.1",
3
+ "version": "0.10.0",
4
4
  "description": "WaSHI: TypeScript & JavaScript algebraic modeler for Mathematical Optimization & Constraint Programming (LP, MILP, QP, CP, SMT) powered by WebAssembly (HiGHS, Pumpkin, Z3, GLPK)",
5
5
  "type": "module",
6
6
  "main": "./dist/washi.js",
@@ -27,6 +27,7 @@ Select the solver engine and execution method that match the problem class:
27
27
  - **HiGHS**, **Pumpkin**, and **GLPK** all run without `COOP`/`COEP` headers (**GLPK** is an optional peer dependency that rejects `useWorker: true`).
28
28
  - **Z3** uses `SharedArrayBuffer` pthreads and requires `window.isSecureContext === true`, `window.crossOriginIsolated === true` (`Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`), and explicit browser asset URLs via `registerZ3Solver({ z3JsUrl, z3WasmUrl })` (or per-call options), since `z3-solver` / `z3-built.{js,wasm}` are not bundled inside `@ohtaman/washi`.
29
29
  - **Single-file / CSP-restricted AI sandboxes (blocked `fetch()`)**: Environments such as Claude.ai Artifacts (edit & published links), ChatGPT inline visualizations, and Codex inline visualizations allow CDN scripts (`script-src`) while blocking `fetch()` (`connect-src 'none'`). Prefer **ESM `<script type="module">` + `solvers/highs-inline.js` / `solvers/pumpkin-inline.js`** (with a `timeLimit` on non-trivial solves) before the first `solve()` / `check()` call (see Recipe 5 below). Note that embedded previews omitting `'wasm-unsafe-eval'` from `script-src` (such as Antigravity's HTML artifact preview) cannot compile WebAssembly; export `.html` and open in Chrome/Safari or via a local server.
30
+ - **Zero-build online single-file HTML (`file://` or static page)**: When the user asks for a lightweight no-build HTML file that runs online (including double-clicking via `file://`), emit a single `.html` importing `https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/washi.js` (ESM) or `<script src="https://cdn.jsdelivr.net/npm/@ohtaman/washi/dist/washi.min.js"></script>` (IIFE) with default `useWorker: false`—no build script, local server, or `*-inline.js` pack is required.
30
31
  - **Single-file offline HTML + npm packages (`file://`)**: To bundle `@ohtaman/washi` (HiGHS and/or Pumpkin) alongside arbitrary third-party npm packages (React, Chart.js, KaTeX, Tailwind) into one zero-network, double-clickable offline `file://` HTML file using Vite + `vite-plugin-singlefile` + gzipped WASM, follow [`references/single-html.md`](./references/single-html.md) (`node_modules/@ohtaman/washi/skills/washi/references/single-html.md`).
31
32
 
32
33
  ---
@@ -259,7 +260,7 @@ export async function solveAndDiagnoseWithPumpkin() {
259
260
 
260
261
  ### Recipe 5: Single-File HTML & CSP-Restricted AI Sandboxes (No `fetch`)
261
262
 
262
- Hosted AI preview environments—including **Claude.ai Artifacts** (edit and published links), **ChatGPT inline visualizations**, and **Codex inline visualizations**—allow CDN scripts (`script-src`) while blocking `.wasm` `fetch()` (`connect-src 'none'`). Meanwhile, **Gemini Canvas** and **Google Sites** allow both `fetch()` and Web Workers, while embedded previews that omit `'wasm-unsafe-eval'` from `script-src` (such as Antigravity's HTML artifact preview) cannot run WebAssembly at all.
263
+ Hosted AI preview environments—including **Claude.ai Artifacts** (edit and published links), **ChatGPT inline visualizations**, and **Codex inline visualizations**—allow CDN scripts (`script-src`) while blocking `.wasm` `fetch()` (`connect-src 'none'`). Meanwhile, **Gemini Canvas** and **Google Sites** allow both `fetch()` and Web Workers (use classic `dist/washi.min.js` for cross-origin `{ useWorker: true }`, or keep default `useWorker: false` with ESM `dist/washi.js`), while embedded previews that omit `'wasm-unsafe-eval'` from `script-src` (such as Antigravity's HTML artifact preview) cannot run WebAssembly at all.
263
264
 
264
265
  Load the self-registering inline WASM packs (`solvers/highs-inline.js` / `@ohtaman/washi/solvers/highs-inline` and `solvers/pumpkin-inline.js` / `@ohtaman/washi/solvers/pumpkin-inline`) **before** the first `solve()`, `check()`, or `warmup*()` call—no manual base64 decoding or binary setters are needed, and the same `*-inline.js` file works in both ESM and classic `<script>` mode (use default `useWorker: false` for cross-origin CDN ESM, or `dist/washi.min.js` if you need cross-origin `{ useWorker: true }`):
265
266