Docs sites: build, check, publish#

Every family repository publishes its documentation site to its own subdomain of the FTP host (Apache, one docroot per site) through one reusable workflow, .github/workflows/build-docs.yml: build the site in the family image, add the hub’s .htaccess, check every internal link, publish. The upload is deploy-over-ftp.

The reusable workflow#

# .github/workflows/docs.yml in the repository
name: Docs · build + publish
permissions:
  contents: read
on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main, develop]
  workflow_dispatch:
jobs:
  docs:
    uses: Kataglyphis/ANTfrastructure/.github/workflows/build-docs.yml@develop
    with:
      builder: rustdoc
    secrets:
      FTP_SERVER: ${{ secrets.SERVER }}
      FTP_USERNAME: ${{ secrets.USERNAME }}
      FTP_PASSWORD: ${{ secrets.PW }}

The jobs:

  • site builds the site in the family image (command or builder) and clicks its sidebar toggles, or takes the artifact an earlier job of the run uploaded (artifact). docs-site.sh stage then adds the .htaccess and 404 page and runs the link gate; the checked tree is uploaded as docs-site-<site-name>, hidden files included. A newer commit on the same ref cancels this job.

  • publish downloads that tree and runs deploy-over-ftp. It runs only on a push to develop or main, or a dispatch there with publish-on-dispatch: true; never on a pull request. Its concurrency group is docs-publish-<site-name>, one per repository and site, with cancel-in-progress: false: a newer run waits, an upload is never cut off. It holds the only FTP secrets; the build never sees them.

  • await-green runs between site and publish when await-green: true. The lanes run beside the docs workflow, so without it a red commit still goes live. Its script, linux/scripts/await-green-runs.sh, always comes from the hub’s develop; only the hub itself (hub-path: '.') runs its own commit’s copy. The script polls the Actions API once a minute. It waits for every other run that a push started at github.sha. It passes when each one ends success, skipped or neutral. Any other conclusion fails it and names the run. So does the timeout, and so do three failed reads in a row. A run re-run green later does not publish; the next push does. When the branch has moved on, the job passes but marks the commit superseded. Then publish skips, and the newer tip’s run publishes. It reads the runs with contents: read. That works on a public repository only. A lane run only on request has no run when nobody asks for it. await-green-jobs names jobs that must pass in one of those runs. A called workflow’s job is <caller job> / <job name>. Without one, the job passes with withheld=true. Then publish skips and the site stays as it was. Suite: test-await-green-runs.sh.

There is no continue-on-error anywhere: a red link gate or a failed upload is a red job, and the site keeps its last good deploy.

Image-backed site builds use the full runner disk cleanup before pulling the family image. The pull is serialized after cleanup so its layers do not consume the space being reclaimed; the caller’s selected submodule checkout, including a pinned theme, is unchanged.

Call it from a docs.yml of its own. A caller workflow with a cancelling concurrency: (most linux-x64.ymls) cancels a publish half-way on the next push, and a docs site published from inside a build or test job goes stale when a test is red or a commit changes only docs. The hub’s own caller is .github/workflows/docs.yml.

Inputs#

Input

Default

Meaning

command

''

Builds the site: bash -lc in the family image at the repository root

builder

''

A hub driver instead: rustdoc (cargo_build_doc.sh, site target/doc), python (ci_build_docs.sh, site docs/build/html) or dartdoc (doc/api cleared, then dartdoc_build_main with DocumANTation’s theme after flutter pub get, images/ copied when the repository has one, site doc/api)

guides

''

builder: dartdoc or rustdoc: the Markdown guides rendered beside the API pages, one <source>|<slug>|<nav title> per line (a YAML | block), sources relative to the repository root. dartdoc writes guide-<slug>.html at the site root; rustdoc writes it beside the root package’s <crate>/index.html, whose page it reuses, and lists every guide atop each page’s sidebar. docs-site.sh plan refuses it with any other source, a source outside the checkout, and a slug that is not [A-Za-z0-9_-]

artifact

''

A site an earlier job of the run uploaded; nothing is built

site-dir

''

The built site, relative to the repository root; required with command, empty with artifact

site-name

docs

Names the uploaded site and the publish group; a second site of the same repository needs its own

link-allow

''

The link gate’s allow file, relative to the repository root

htaccess

true

Add the hub’s .htaccess and 404 page; false for a site that ships its own

isolated-apps

''

Web apps below the site’s root, space-separated paths relative to it. Each gets the isolated-app .htaccess; docs-site.sh stage refuses a path outside the site, one without an index.html, and an app that ships its own .htaccess

live-url

''

The published site’s https:// address. With isolated-apps, a live-check job after the publish runs check-live-site.js --isolated on each app at <live-url>/<app>/, against the files and models it published. A red job means the live app is broken now

publish

true

false builds and checks only, and needs no secrets

publish-on-dispatch

false

Also publish a workflow_dispatch run on develop or main

await-green

false

Publish only once the commit’s other push runs are green. See await-green above

await-green-timeout-minutes

180

How long await-green waits before it fails. A whole number from 1 to 350; its job stops at 360

await-green-jobs

''

With await-green: job names, one per line, that must pass. Without one, nothing publishes

publish-timeout-minutes

30

The publish job’s limit. An upload it cuts off saves no sync state, so a file too large to finish in time is retried from scratch on every run: BeschleunigerBallett’s 61 MB demo scene at about 74 kB/s never landed under 30

server-dir

''

Remote directory; empty is the FTP login directory, every family site’s docroot

submodules

recursive

actions/checkout submodules. Pass a value as an expression (${{ 'true' }}): actionlint reads a bare 'true' as a bool

container-args

''

Extra docker run arguments for the build, verbatim: never untrusted text

hub-path

''

A hub checkout to take the drivers, the stager and the gate from; empty checks the hub out at develop into antfrastructure-tools, so they match the workflow. The hub passes .

runner

ubuntu-26.04

Runner label

Exactly one of command, builder and artifact; docs-site.sh plan refuses anything else, and a site-dir or hub-path that is not a plain relative path.

Secrets#

The workflow takes FTP_SERVER, FTP_USERNAME and FTP_PASSWORD, the names python-ci-linux.yml already used, and no other spelling. A caller maps its repository secrets onto them in its secrets: block: most repositories store SERVER, USERNAME and PW, WebDavClient PASSWORD, jotrockenmitlocken’s docs site DOC_WEBSITE_SERVER, DOC_WEBSITE_USER and DOC_WEBSITE_PW. No repository secret has to be renamed. A publish without them fails in its first step and names the missing ones. The SERVER/USERNAME/PW secret inputs of the consumers’ own reusable-*.yml go away with their deploy steps (below).

Moving a repository onto it#

What each repository changes, read 2026-10-19 from its develop. Each one seeds link-allow from its first run’s findings (verify_site_links.py <site> --print-keys) or fixes them.

Repository

Today

Change

ANTfrastructure

linux-x64.yml called build-docs.yml under a cancelling group

done: docs.yml, command: bash linux/scripts/build-docs.sh, site-dir: docs/_build/html, hub-path: .

OrchestrANT, WebDavClient

python-ci-linux.yml published from its x64 build job, on any push

nothing: its new docs job calls this workflow with artifact: python-docs-site and publishes on develop and main only; optional docs-link-allow

OxidANT

reusable-linux.yml built rustdoc and published with continue-on-error: true

a docs.yml with builder: rustdoc; the docs input, both docs steps and the three secrets leave reusable-linux.yml and linux-x64.yml. Its 11-crate site has 20 missing <module>/dispatcher keys from tracing’s blanket-impl docs, so it needs an allow file. Since 2026-10-21 its eight docs/ pages ride along as guides

OmniAccelerANT

reusable-linux.yml published doc/api after the whole native lane

a docs.yml with command: bash scripts/linux/generate-docs.sh, site-dir: doc/api; run-docs off, the deploy step and its three secrets go

AccelerANTgine

reusable-linux.yml published from the clang x64 build, whose docs carry its coverage, on every event but a dispatch, pull requests included

artifact mode: the deploy step becomes an upload-artifact of docs/build/html/ named accelerantgine-docs-site (include-hidden-files: true, if-no-files-found: error), and linux-x64.yml gets a docs job that needs: build-ubuntu26_04_clang-x64 with artifact: accelerantgine-docs-site

BeschleunigerBallett

reusable-linux.yml published on every event but a dispatch, pull requests included, with continue-on-error: true

artifact mode as AccelerANTgine: upload docs/build/html/ as bb-docs-site after the wasm budget step; linux-x64.yml gets a docs job, needs: build-x64, if: ${{ !cancelled() }}

ANThology

docs.yml ran dart doc after the Dart checks, in the same job

done (c3615ca): a docs job with command: bash scripts/build-docs.sh, site-dir: doc/api, because the builder took no guide list then. It can move to builder: dartdoc with guides: docs/getting-started.md|getting-started|Getting started: run twice in :latest over its checkout, 1071 documents, 0 findings, 57 s, the rebuild 29 s

jotrockenmitlocken

web.yml published doc/api with no if:, after the whole web build

a docs job with command: bash scripts/ci-container-steps.sh dart-doc, site-dir: doc/api, container-args: --platform linux/amd64, secrets from DOC_WEBSITE_*. Its three web-app deploys stay on deploy-over-ftp: an app ships its own .htaccess

DocumANTation publishes to GitHub Pages and is not an FTP site.

The sidebar toggle check#

linux/scripts/check-docs-sidebars.js <site dir | https URL> [page ...] serves a built Sphinx book-theme, dartdoc or rustdoc site on 127.0.0.1 (or opens a published one), and in the image’s headless Chrome clicks every sidebar toggle a reader can see, at the widths where the layout changes: 1400, 1100, 850 and 400 px for Sphinx, 1400, 800 and 400 px for dartdoc, 1400, 700 and 400 px for rustdoc. A toggle fails when it is off-screen, covered, does nothing, or opens a sidebar that does not close again (second click, the overlay, or Escape for a dialog); a hidden sidebar with no toggle fails too. Exit 1 on a failure, 2 on a usage error or no Chrome; any other site has nothing to toggle and passes.

It opens index.html, each page named (a path under the site root), and in a built Sphinx site every page with an Exhale tree view (class="collapsibleList"); a published site has no file list, so name its API page (api/library_root.html). A built rustdoc site’s index.html is a redirect at best, so there it opens each crate page with guides beside it and those guides, else the first crate of crates.js. On each page and width:

  • any uncaught exception or rejection fails, with its message and source line;

  • an Exhale tree view gets its first foldable item clicked on its own text, never its link: an item that never folds (its script did not run), stays put, or does not unfold again fails.

For this hub, docs.yml type-checks docs/conf.py against the checked-out DocumANTation theme before the reusable site job starts; a missing theme or type finding prevents publication. linux/scripts/lint-python-types.sh --docs-conf writes its ignored report under logs/code-quality/, while the Sphinx build checks runtime rendering. The sidebar check runs where each site is built, in the image: docs-site.sh build <site> builds and then checks in one container command in build-docs.yml (the action’s script is docker run’s argv, so a shell && would run on the runner), and for the artifact sites after make html in lib/docs-build.sh (BeschleunigerBallett, AccelerANTgine) and 02-toolchain/python/ci_build_docs.sh (OrchestrANT, WebDavClient), with --if-chrome, which skips only where the image sets no CHROME_EXECUTABLE (riscv64).

CHECK_DOCS_SIDEBARS_JOBS (default 4, at most the CPU count) is how many Chromes check pages and widths at once; the report is the same, in page order. 1 checks them in turn (CON126).

Normal shared Chrome cleanup waits up to five seconds for child exit after sending SIGKILL, then removes its profile with bounded filesystem retries. A still-running profile writer previously caused ENOTEMPTY after a successful page check. Sidebar, live-site and WebGPU callers await cleanup; exhausted retries, permission failures or a child that does not exit remain fatal. All browsers finish cleanup before a peer’s failure is reported. The immediate process-exit handler only sends the kill.

test-chrome-close.sh uses real Node child processes and injected cleanup failures to prove exit-before-removal, bounded retry policy, timeout, fatal errors and peer cleanup. The browser/CDP behavior remains covered by the fixture sites below. Real Chrome launches terminate their detached process group before reaping the main child; standalone child fixtures keep direct termination as their default. Signal handlers retain best-effort emergency cleanup. DevTools calls fail after 30 s. A slower page’s caller passes send(method, params, timeoutMs). If endpoint/page discovery, the WebSocket or initial DevTools calls fail before return, the launcher cleans its group, profile and signal hooks itself. Cleanup failures retain the startup error as well and remain fatal; fake-CDP cases cover this otherwise unowned launch path.

Why (CON121, 2026-10-20): every Sphinx site had dead or unreachable toggles and no gate saw it.

  • pydata-sphinx-theme 0.20, which sphinx-book-theme 1.4.0 pins, defaults navbar_persistent to the search field and renders its own header, with a hidden .primary-toggle and .secondary-toggle, before the book theme’s article header. Both themes’ JS bind document.querySelector('.primary-toggle'), the hidden one, so the visible toggles did nothing at any width on the five sites built from PyPI. DocumANTation’s setup_theme() sets navbar_persistent: [].

  • The theme’s custom.css made .bd-sidebar-primary position: sticky at every width. Below the drawer breakpoint the sidebar is position: fixed with a negative margin; sticky kept it in the flow and moved the article’s toggle to x=-242 at 850 px.

Why the exceptions and tree views (CON127, 2026-10-20): Exhale 0.3.7’s apply-collapsible-lists.js is $(document).ready(...), and Sphinx 6 stopped shipping jQuery, so every page of AccelerANTgine’s and BeschleunigerBallett’s sites threw ReferenceError: $ is not defined and their API trees never folded, while every toggle passed. DocumANTation’s theme copies a jQuery-free applier over Exhale’s when a site builds one; Exhale’s own CollapsibleLists.js needs no jQuery.

Suite linux/scripts/tests/test-docs-sidebars.sh (fixture sites, one per failure); the docs-site.sidebars-* and docs-site.*-clicks-the-toggles mutations prove it.

Proving a WebGPU page#

In the image’s headless Chrome 155 a WebGPU canvas screenshots white even when the page renders it (CON128). Read the frame back instead:

node linux/scripts/webgpu-canvas-readback.js <URL | page.html> [--min-colours N] [--wait-ms N] [--screenshot FILE]
  • Chrome runs WebGPU on SwiftShader (--enable-unsafe-webgpu --enable-features=Vulkan --use-angle=swiftshader --use-webgpu-adapter=swiftshader): the image has no GPU. A consumer driving its own page takes them from require('webgpu-canvas-readback.js').WEBGPU_FLAGS (frozen) for check-docs-sidebars.js’s launch(chrome, WEBGPU_FLAGS), with install for the read-back. A traced frame can hold the page past 30 s.

  • An init script (Page.addScriptToEvaluateOnNewDocument) adds COPY_SRC to the canvas’s configure() usage and keeps the texture getCurrentTexture() hands out. After --wait-ms (3000) it copies the next frame out after that frame’s last submit() (copyTextureToBuffer, rows padded to 256 bytes, then mapAsync).

  • It prints size, format and distinct colours and paints the frame into a 2D canvas over the WebGPU one, so --screenshot shows it. Exit 1 on fewer than --min-colours (2: a cleared canvas has one), no frame in 10 s, or a format other than 8-bit RGBA/BGRA; 2 on a usage error or no Chrome.

BeschleunigerBallett’s published demo (/webgpu-demo/index.html), 2026-10-20: 3575 colours for the proof of run 39440853860, 3124 from this tool at --wait-ms 8000, both 1280x743 rgba8unorm; its plain screenshot was white.

Suite linux/scripts/tests/test-webgpu-canvas-readback.sh (the read-back against fakes of the WebGPU API, the exported flags, a page with no frame in Chrome); the docs-site.webgpu-readback-* mutations prove it.

The site’s .htaccess#

linux/webserver/templates/docs-site.htaccess goes into every docs site’s root, with docs-site-404.html as 404.html when the build wrote none:

Directive

Why

RewriteCond %{HTTPS} !=on + RewriteCond %{HTTP:X-Forwarded-Proto} !=https + RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

plain http answered 200 on every family site; the second condition stops a loop behind a proxy that ends TLS

Header always set Strict-Transport-Security "max-age=31536000"

HSTS for a year, this subdomain only

Header always set X-Content-Type-Options "nosniff"

no content sniffing

RedirectMatch 404 (^|/)\.ftp-deploy-sync-state\.json$

the FTP library’s state file lists every published file with its hash, and it was served

AddType application/wasm .wasm, AddType model/gltf-binary .glb, AddType model/gltf+json .gltf

WebAssembly.instantiateStreaming refuses a wasm under any other type, and none of the three may hang on the host’s mime.types

AddOutputFilterByType DEFLATE application/wasm model/gltf-binary model/gltf+json

the host gzips text itself but serves these whole: BeschleunigerBallett’s demo is a 7 MB wasm and a 61 MB .glb that gzips to 30 MB. Inside mod_filter (owns the directive) and mod_deflate (owns the filter)

ErrorDocument 404 /404.html

a dead link shows a page with a way back, not Apache’s default

Every directive is in Apache’s FileInfo override class, and the suite fails on any other. That class is what the host is proven to allow: jonasheinle.de, on the same address as every docs site, serves exactly the headers of jotrockenmitlocken’s deployed web/.htaccess (Header, AddType, and AddOutputFilterByType DEFLATE, which gzips its .wasm). A directive the host’s AllowOverride does not grant (Options, Require, Order) would make every page a 500, so the state file is denied by RedirectMatch rather than Require all denied. Each block sits in <IfModule>: a missing module drops its rules instead of failing the site.

The server, read 2026-10-19 with curl -sI: containerization.jonasheinle.de and the other eight FTP sites answer Server: Apache from 85.13.169.97; http:// answers 200 with no redirect; /.ftp-deploy-sync-state.json answers 200; an unknown page gets Apache’s default 404; /.htaccess answers 403, so the server config denies .ht* files itself. Read 2026-11-15: HTML, CSS and JavaScript come back Content-Encoding: gzip without any .htaccess rule, and beschleunigerballette.jonasheinle.de sent its demo’s .wasm as application/wasm but uncompressed, so the template compresses the binary types only.

The family image carries no httpd, so the directives are checked by linux/scripts/tests/test-docs-site-htaccess.sh (each directive, the <IfModule> guards around the types and the filter, the state-file regex against sample paths, the 404 page through the link gate) and by curl -sI after the first publish, not by a server in a container. The docs-site.* mutations prove the suite.

An isolated app’s .htaccess#

A web app that needs crossOriginIsolated gets linux/webserver/templates/flutter-web-isolated.htaccess as the .htaccess of its own directory. On a docs site, name the app’s directory in isolated-apps, and the stager copies the template there before the link gate runs. Wasm threads, SharedArrayBuffer and ORT Web’s threaded builds need isolation. OmniAccelerANT’s /app/ takes this template below its docs site’s root. The root keeps docs-site.htaccess, and jotrockenmitlocken keeps flutter-web.htaccess.

Directive

Why

Header always set Cross-Origin-Opener-Policy "same-origin"

one of the two headers that isolate the page

Header always set Cross-Origin-Embedder-Policy "require-corp"

the other one; Safari has no credentialless

Header always set Permissions-Policy "camera=(self)"

getUserMedia for this origin, and for no embedded frame

AddType application/wasm .wasm, AddType text/javascript .mjs

the browser refuses a wasm or a module script served under another type

Header set Cache-Control "no-cache"

main.dart.wasm and flutter_bootstrap.js keep their names across builds, so the browser must revalidate them

SetEnvIf Request_URI ... VERSIONED_PATH and Header set Cache-Control "public, max-age=31536000, immutable" env=VERSIONED_PATH

only ort/<version>-<build hash>/ and models/<sha256>/ never change under their name. The guarded line comes after the plain one and overwrites it

The HTTPS redirect, HSTS, nosniff, the sync-state RedirectMatch and the wasm DEFLATE

the root’s rules again, so the file also works at a docroot

The FileInfo rule of the root’s file holds here too, with the same <IfModule> guards. SetEnvIf is in FileInfo. <If> is not: it needs AllowOverride All, so the versioned paths are matched by SetEnvIf.

Apache merges Header and AddType from the root’s file into a subdirectory’s. Rewrite rules do not merge: a subdirectory file with its own RewriteRule replaces the root’s, so the template repeats the redirect.

Under COEP require-corp the page loads nothing from another origin that sends no CORS or CORP header. Build a Flutter app with --no-web-resources-cdn, so CanvasKit comes from the app’s own origin.

Suite linux/scripts/tests/test-flutter-web-isolated-htaccess.sh checks each directive, the guards, the order of the two cache lines and the versioned-path patterns against sample paths. The docs-site.isolated-* mutations prove it. After a publish, check-live-site.js <app URL> --isolated checks the headers and crossOriginIsolated in Chrome: ftp-deploys.md § The live-site check.

build-docs.yml runs that check itself when the caller passes live-url. Its live-check job needs the publish, so it never runs on a pull request. It pulls the family image for node and Chrome, takes the published site, and runs docs-site.sh live. That checks every app, also after a red one, and fails if any is red. It refuses a plain-http address, an empty app list and an app path outside the site. An app published with models/manifest.json also gets --models, which downloads each mirrored file and compares its bytes.

Staging ORT Web for an app#

An app that runs ONNX Runtime in the browser ships the image’s own ORT Web builds. Stage them in the family image, in an amd64 job, before the link gate:

python3 -I linux/scripts/lib/stage-ort-web.py --out <site>/app [--jsep] [--no-js-bundles | --js-dir DIR]

It reads /usr/local/lib/onnxruntime-web (--source changes it) and writes ort/ below --out:

  • One directory per build, ort/<version>-<build hash>/, in the order JSPI, Asyncify, CPU. --jsep adds JSEP last. The build hash is the first 16 hex digits of a SHA-256 over the build’s file hashes, so new bytes get a new path. The isolated-app .htaccess marks only such a path immutable.

  • Each directory holds the build’s .wasm, its loader .mjs, its ort.*.mjs bundles, ORT’s LICENSE and ThirdPartyNotices.txt and the probe’s ort-webgpu-factory-probe.LICENSE. A *.bak, a source map or another build’s bundle never ships.

  • ort/manifest.json lists each build with its path, its build hash, every file with role, SHA-256 and size, and its receipt: the configured flags, the CMake cache hash and the factory probe’s runtime receipt. It also names the ORT version, ref and revision, the image receipt’s hash and where the license texts came from. ort/manifest.json itself keeps its name, so the app revalidates it.

Build

Files

Bundles

JSPI

ort-wasm-simd-threaded.jspi.{wasm,mjs}

ort.jspi*.mjs

Asyncify

ort-wasm-simd-threaded.asyncify.{wasm,mjs}

ort.webgpu*.mjs

CPU

ort-wasm-simd-threaded.{wasm,mjs}

ort.wasm*.mjs

JSEP

ort-wasm-simd-threaded.jsep.{wasm,mjs}

ort.mjs, ort.min.mjs, ort.bundle.min.mjs

It refuses rather than ships fewer builds or other bytes. Exit 1, and no ort/ is written, when:

  1. A requested build’s .wasm or loader is missing, or its bundle is (pass --no-js-bundles where no bundle can exist: the image builds them on amd64 only). --js-dir DIR takes every bundle from DIR. On arm64 that is the npm package’s JS of the same ORT version.

  2. A JSPI or Asyncify build has no flavor in ort-webgpu-wasm.json, or its bytes, its probe license or its runtime receipt differ from the receipt, or that runtime receipt records a failed probe.

  3. ORT’s license texts are neither beside the web output nor in an installed wheel of the receipt’s ORT version, or a wheel’s text differs from its RECORD. --site-packages names the wheel’s directory; the default is the single /opt/venv one.

  4. <out>/ort already exists.

The hashes of a build with a receipt come from the receipt, and the stager checks the bytes against them. The image writes no receipt for CPU and JSEP, so their manifest entry says "receipt": null and every hash there is of the bytes ("hash_from": "bytes").

Suite linux/scripts/tests/test-stage-ort-web.sh covers the order, the file lists, the hashes, the license sources and every refusal over fixture outputs. The docs-site.ort-web-* mutations prove it.

Mirroring an app’s models#

GitHub release downloads send no CORS header. So an app loads its models from its own origin, mirrored from the data locks. The site’s build command runs the mirror in the family image, after the app’s build and before anything that lists the app’s files, such as a license inventory:

python3 -I linux/scripts/lib/mirror-app-models.py --out <site>/<app> [--model <lock> <file>]... \
  [--genai <lock> <archive> <name>]... [--root DIR] [--cache DIR]

Each lock is a data lock of sha256 file url rows (the hub’s fetcher). OmniAccelerANT’s build-docs-site.sh mirrors DEIM-D-FINE-N from OxidANT’s models.lock into doc/api/app.

The mirror fetches each model with its <name>.LICENSE and <name>.NOTICE through fetch-data-lock.py. That checks every file by its SHA-256 and keeps a cache. The mirror then writes models/ below the app by one rename:

  • Every file lands at models/<its sha256>/<file>, each license text under its own hash. The isolated-app .htaccess marks only such a path immutable, so new bytes get a new URL.

  • models/manifest.json keeps its name, so the app revalidates it.

  • --genai takes a GenAI model directory archive and the model’s name. The lock must hold <name>.LICENSE and <name>.NOTICE, as ModelANT releases them. The mirror checks the archive by its SHA-256. The fetcher’s own extraction unpacks it. Each file lands at models/<archive sha256>/<directory>/<file>. So the graph and model.onnx.data stay side by side. The archive is not published.

It exits 1 and leaves the app as the build wrote it when:

  1. A file is not in its lock, or its bytes differ from the lock’s SHA-256.

  2. The lock has no <name>.LICENSE or no <name>.NOTICE for the model. ModelANT releases both with every model.

  3. A --model is an archive: the browser fetches single files. A --genai is no archive, unpacks to a subdirectory, a link or no genai_config.json.

  4. <app>/models exists or the app’s directory does not.

  5. A model is named twice, or a lock lies outside --root. The default root is the working directory, where build-docs.yml runs the build command: the repository root.

The web manifest#

{
  "schema_version": 1,
  "models": [
    {
      "name": "deim_dfine_n_coco",
      "file": "deim_dfine_n_coco.onnx",
      "path": "models/<sha256>/deim_dfine_n_coco.onnx",
      "sha256": "<sha256>",
      "size": 15540167,
      "lock": {
        "path": "third_party/OxidANT/resources/models/models.lock",
        "line": 4,
        "url": "https://github.com/Kataglyphis/ModelANT/releases/download/deim_dfine_n_coco-v2/deim_dfine_n_coco.onnx"
      },
      "release": {"repository": "Kataglyphis/ModelANT", "tag": "deim_dfine_n_coco-v2"},
      "licenses": [
        {"file": "deim_dfine_n_coco.LICENSE", "path": "models/<sha256>/deim_dfine_n_coco.LICENSE",
         "sha256": "<sha256>", "size": 11564, "lock": {"path": "...", "line": 5, "url": "..."}},
        {"file": "deim_dfine_n_coco.NOTICE", "path": "models/<sha256>/deim_dfine_n_coco.NOTICE",
         "sha256": "<sha256>", "size": 1155, "lock": {"path": "...", "line": 6, "url": "..."}}
      ]
    }
  ]
}

Field

Meaning

schema_version

1; a reader refuses any other

models

One entry per model, in the order of the --model and --genai options

name

The file name without its last suffix, or the --genai name; the license texts are <name>.LICENSE and <name>.NOTICE

kind

file for a --model, genai for a --genai

file

The file name in the lock

path

file only: the URL relative to the app’s directory, new URL(path, <app base>)

sha256, size

The file’s or the archive’s bytes, as the lock pins them

directory, files

genai only: the directory the archive unpacks to, and each of its files with file, path, sha256 and size

lock

The row the file came from: the lock’s path in the repository, its line and its URL

release

The GitHub release the URL names, or null for any other URL

licenses

The model’s license texts, each with file, path, sha256, size and lock

A browser reads it in three steps:

  1. Fetch models/manifest.json, then each model at its path.

  2. Check the size and the SHA-256 of the bytes with crypto.subtle.digest before ORT sees them. A missing file can come back as a page with status 200, from a host’s catch-all rule or a service worker.

  3. Cache the bytes by their hash. A hash the cache holds needs no download.

After each publish, the live-check job finds the manifest in the published tree and passes it to check-live-site.js --models. That downloads every file the manifest names and fails on another status, size or hash: ftp-deploys.md § The live-site check.

Suite linux/scripts/tests/test-mirror-app-models.sh covers the tree, the manifest and every refusal over file:// locks and a seeded cache. The docs-site.app-models-* mutations prove it; docs-site.live-models and the live-site.models-* mutations prove the live check.

Detector parity of the ORT Web builds#

An app ships a staged build only if it detects what native ORT detects. Run the check in the family image after staging:

python3 -I shared/python/ort_web_parity.py --site <site>/app --model deim_dfine_n_coco.onnx \
  --image two_cats.jpg --out <report dir> [--jsep] [--build NAME]... [--js-dir DIR]

The model is ModelANT’s deim_dfine_n_coco-v2 and the photo its contracts/fixtures/two_cats.jpg. Both are checked by SHA-256. linux/scripts/ort-web-parity-ci.sh <report dir> [--jsep] stages the image’s builds, fetches both through linux/scripts/lib/ort-web-parity.lock and runs the check.

How it runs:

  • The photo becomes one input tensor, stretched to 640x640 by nearest neighbour as OxidANT’s vision_core does it. Native ORT and every build get the same bytes, so the report compares ORT builds, not decoders.

  • Native ORT runs that tensor on CPUExecutionProvider. Its result must pass the comparator’s two-cats baseline.

  • linux/scripts/ort-web-detector-parity.js serves the site with COOP and COEP and drives headless Chrome. JSPI, Asyncify and JSEP run the webgpu provider on SwiftShader’s WebGPU. CPU runs the wasm provider with --disable-gpu.

  • The page imports the build’s own ort.*.min.mjs with wasmPaths at the build’s directory. It runs one session twice.

A build gets "verdict": "ship" when all four hold, else "refuse" with its reasons:

  1. Its first run matches the native run within compare_detector_parity.py’s tolerances: the same count and classes, IoU 0.90 or more, scores within 0.05.

  2. Its second run matches its first.

  3. Each run finds at least two cats at 0.4 or more.

  4. ORT placed nodes on the build’s provider: WebGpuExecutionProvider, JsExecutionProvider or CPUExecutionProvider. ORT moves a node it cannot run to the CPU without a word.

The node counts come from the session’s verbose log, because no profile file leaves the wasm. verify_ort_profile.py LOG.json --device webgpu --placements applies the same rule to a JSON list of log lines and prints each provider’s share.

It exits 1 and writes no report when a requested build is not staged, a staged file differs from the manifest, the model or the photo is another, or the report directory exists.

<report dir>/<build>.json holds the verdict, the reasons and the tolerances. It also holds the worst IoU and score difference measured, the cats per run, the nodes and shares per provider, the operators placed elsewhere, the Chrome version, the adapter and the times. summary.json lists the verdicts. Each run’s detections sit beside them in the comparator’s format, and <build>-page.json keeps the page’s answer with ORT’s whole log.

"decides": true only when the page loaded the build’s own bundle. The arm64 image has none, so --js-dir can name the ort.*.mjs of the npm package of the same ORT version. Such a report proves the build’s wasm and loader, and decides nothing.

Workflow ort-web-parity.yml runs ort-web-parity-ci.sh in the amd64 image on a push to its files, on Mondays and on dispatch, which can add --jsep. It uploads the reports as ort-web-parity, and they decide which builds ship.

On a Pi 5 in the arm64 image, Chrome 157 on SwiftShader with two threads, against the npm package’s JS of ORT 1.31.1. These reports decide nothing:

Build

Verdict

Worst IoU, score difference

Nodes on its provider

Session, first run, repeat

JSPI

refuse

none: the first run failed

727 of 737

10.6 s, failed

Asyncify

ship

0.999999, 0.00003

727 of 737

12.7 s, 219 s, 19 s

CPU

ship

0.999999, 0.00002

717 of 717

1.8 s, 0.9 s, 0.5 s

JSEP

refuse

none: the first run failed

760 of 773

5.0 s, failed

  • JSPI stopped in a Conv2dMM with No cached or pending pipeline for deferred dispatch. Three other runs of the JSPI build passed with Asyncify’s numbers in about 210 s and 19 s. The failure is intermittent, so JSPI waits for the amd64 reports.

  • JSEP stopped at a MaxPool with ceil_mode, which its WebGPU kernel does not implement, and it put TopK on the CPU. JSEP is no fallback for DEIM.

  • On the WebGPU builds the ten CPU nodes are shape arithmetic: Unsqueeze, Tile, Div, Mul, Sub and Cast. GridSample, GatherElements and TopK ran on WebGPU.

  • The first WebGPU run compiles every shader on SwiftShader, so the repeat takes a tenth of its time.

The deciding reports come from the amd64 image’s own bundles, dispatch run 46103260764 on b224ed00 with Chrome 157 on SwiftShader:

Build

Verdict

Worst IoU, score difference

Nodes on its provider

Session, first run, repeat

JSPI

ship

0.999999, 0.000008

727 of 737

2.2 s, 38 s, 27 s

Asyncify

ship

0.999999, 0.000008

727 of 737

2.5 s, 35 s, 27 s

CPU

ship

0.999999, 0.00001

717 of 717

0.9 s, 0.3 s, 0.2 s

JSEP

refuse

none: the first run failed

760 of 773

failed

  • JSPI passed both runs on amd64; the Pi’s Conv2dMM failure did not show.

  • JSEP failed at the same MaxPool with ceil_mode. It runs only on request and never ships, so its report informs and the three shipping builds decide the job’s exit. A run of JSEP alone still fails on its refusal.

Suite linux/scripts/tests/test-ort-web-parity.sh covers the verdicts, the tolerance edges, the cat rule, every refusal and the report’s shape over fixture builds, and the page and its server against a fake ORT module. The docs-site.ort-web-parity-*, docs-site.ort-web-harness-* and packaging.ort-profile-* mutations prove it.

Loading ORT Web in an app#

shared/web/javascript/ort-web-loader.mjs picks the staged build a browser can run and loads that build’s files only. A consumer copies it into web/javascript/ (shared asset web-ort-loader-mjs) and imports it in the worker that runs ORT:

import { createSession, loadOrtWeb, planOrtWeb } from '../javascript/ort-web-loader.mjs';

const base = new URL('../', import.meta.url);  // the directory that holds ort/
const { provenance } = await planOrtWeb({ base });  // the choice, from ort/manifest.json alone
const loaded = await loadOrtWeb({ base });  // { ort, provenance, executionProviders }
const session = await createSession(loaded, modelBytes);

The choice, first match wins:

Build

When

reason

any

the caller passes build

requested

CPU

isSecureContext is false: the page has no WebGPU

no-secure-context

CPU

no navigator.gpu

no-webgpu

CPU

requestAdapter() does not answer in 5 s, throws, or answers null

adapter-timeout, adapter-error, no-adapter

JSPI

WebAssembly.Suspending and WebAssembly.promising exist

jspi-webgpu

Asyncify

JSPI is missing

no-jspi

  • planOrtWeb reads <base>/ort/manifest.json and fetches nothing of the build. Its provenance has "verified": false and "ort_web": null.

  • loadOrtWeb fetches the build’s bundle, loader and wasm. It checks each SHA-256 against the manifest with crypto.subtle. Then it imports the bundle. env.wasm.wasmPaths gets that build’s { mjs, wasm }, and env.wasm.wasmBinary the checked bytes. So no other build’s loader or wasm can load. The bundle is ort.<prefix>.min.mjs, else .mjs, else .bundle.min.mjs, as in the parity check.

  • Threads: ORT’s own default, min(4, ceil(cores / 2)), when crossOriginIsolated; one otherwise, with "threads_note": "not-isolated".

  • createSession(loaded, model) creates the session with ORT’s verbose log. It counts the placement lines into provenance.session: placements, nodes, on_provider, share and proven. ORT moves a node it cannot run to the CPU without a word. So the requested provider proves nothing. ORT’s glue binds console.log and console.error once, when it loads. So loadOrtWeb taps the console before the import. Sessions are created one at a time, so each count is its own.

It refuses with an OrtWebLoadError. Its code says why. Its provenance holds the choice made so far:

code

When

unknown-build

build is not jspi, asyncify or cpu

bad-manifest

not a schema 1 manifest, a path other than ort/<version>-<build hash>/, a file name with a slash, no SHA-256, or not one wasm and one loader

build-not-staged, no-bundle

the chosen build or its bundle is missing (the image builds bundles on amd64 only)

fetch-failed, hash-mismatch

a file does not answer 200, or its bytes are not the manifest’s: a missing file can come back as index.html

unverifiable

no crypto.subtle, which only a secure context has; verify: false loads unchecked and says "verified": false

version-mismatch

the bundle’s env.versions.web is not the manifest’s ORT version

The provenance is plain JSON:

  • build, provider (webgpu or wasm), reason, reason_text.

  • build_hash, path, ort_version, ort_revision, ort_web.

  • files: bundle, loader and wasm, each with file, sha256 and size.

  • verified, threads, threads_note.

  • capabilities: secure_context, cross_origin_isolated, jspi, webgpu, adapter_error, hardware_concurrency, and adapter with vendor, architecture, device, description, is_fallback.

  • manifest: url, image_receipt_sha256.

  • session, after createSession.

linux/scripts/ort-web-loader-check.js runs it in the image’s headless Chrome under one browser condition:

node linux/scripts/ort-web-loader-check.js --site <app dir> --case <case> --out <report.json> \
  [--in page|worker | --worker <app-relative worker> [--build NAME] [--image FILE | --camera FILE] [--threshold T]] [--fake-ort] \
  [--model FILE --input-dims 1,3,640,640 --runs N]

--case

Chrome

The page

jspi

SwiftShader’s WebGPU

isolated

asyncify

SwiftShader’s WebGPU; WebAssembly.Suspending deleted where the loader runs, since no flag turns JSPI off in Chrome 156 and later

isolated

no-adapter

--disable-gpu

isolated

no-webgpu

SwiftShader, --disable-features=WebGPU

isolated

insecure

SwiftShader; the page opens at http://insecure.test, mapped to loopback

not a secure context

not-isolated

SwiftShader’s WebGPU

without COOP and COEP

  • --in page (default) or worker runs the loader in the page or in a module worker. --model then creates a session and runs it on a zero tensor.

  • --worker REL runs the app’s own worker below --site instead. It is sent {"id": 1, "op": "plan"}, then {"id": 2, "op": "load"}, as JSON strings, and answers each with {"id", "ok", "provenance", "error": {"code", "message"}}. OmniAccelerANT’s web/inference/inference_worker.mjs speaks it. --build NAME puts "build" into each request. --image FILE then sends {"id": 3, "op": "detect", "threshold"} as {request, image}, the file’s bytes transferred as an ArrayBuffer; --threshold defaults to 0.25, the comparator’s lowest score. --camera FILE makes FILE (.y4m or .mjpeg) Chrome’s only camera. The page opens it with getUserMedia, grabs one frame of the playing video as an ImageBitmap, and sends {"id": 3, "op": "detectFrame"} as {request, frame}, the frame transferred. That is the path a webcam page takes.

  • --fake-ort serves a stand-in ort/: each build’s files with their real hashes, each bundle a fake ORT module. It proves the choice and the checks without ORT, also on arm64, where the image has no bundles.

On a Pi 5 in the arm64 image, Chrome 157 on SwiftShader, with ORT 1.31.1’s staged wasm and the npm package’s bundles of the same version. The image builds no bundle there, so this proves the loader and decides nothing about the shipped bundles. Each case chose the same in the page, in a worker and through OmniAccelerANT’s worker:

--case

Build, reason

Load

Nodes on its provider

DEIM, first run and repeat

jspi

JSPI, jspi-webgpu

checked, 2 threads

727 of 737

209 s, 21 s in a worker

asyncify

Asyncify, no-jspi

checked, 2 threads

727 of 737

a session only

no-adapter

CPU, no-adapter

checked, 2 threads

717 of 717

0.9 s, 0.5 s in a worker

no-webgpu

CPU, no-webgpu

checked, 2 threads

717 of 717

0.9 s in the page

insecure

CPU, no-secure-context

refused: unverifiable

none

none

not-isolated

JSPI, jspi-webgpu

checked, 1 thread

727 of 737

a session only

No flag of Chrome 157 turns JSPI off or removes navigator.gpu: --js-flags=--no-experimental-wasm-jspi, --js-flags=--no-wasm-jspi, --disable-features=WebAssemblyJSPromiseIntegration, --disable-features=WebGPU and --disable-webgpu all left them in place. So asyncify and no-webgpu delete WebAssembly.Suspending or navigator.gpu where the loader runs; around an app’s worker, a wrapper module deletes them, imports the worker and hands it the messages sent meanwhile. A page without isolation still creates shared wasm memory, so the threaded builds load there on one thread.

Suite linux/scripts/tests/test-ort-web-loader.sh covers the choice, the probe, the threads, the manifest reading, the plan, the load with each build’s own files, every refusal and the session placements in node against fakes, and the check’s arguments, stand-in and server. The docs-site.ort-web-loader-* mutations prove it. test-ort-web-loader-chrome.sh runs each case in Chrome, in the page and in a worker, against --fake-ort.

Generating text with ORT Web#

GenAI has no web build. So the browser runs the decoder of a GenAI model directory on ORT Web, with shared/web/javascript/ort-web-generate.mjs. Its shared asset is web-ort-generate-mjs. It runs in the worker that loaded ORT:

import { decoderSpec, generate, sessionOptions } from '../javascript/ort-web-generate.mjs';

const spec = decoderSpec(genaiConfig);  // genai_config.json: tensor names, cache shape, context, end tokens
const session = await createSession(loaded, modelBytes, { options: sessionOptions(spec, loaded.provenance.provider) });
const result = await generate({ ort: loaded.ort, session, spec, promptIds, options: { max_new_tokens: 8 },
  onToken: (id) => postMessage({ token: id }), decode, signal });
  • The prompt goes in one run. Then each run adds one token.

  • Each run’s present.* outputs are the next run’s past_key_values.*, the same tensors. The first past is empty.

  • On WebGPU, sessionOptions keeps the present.* outputs on the GPU (preferredOutputLocation: 'gpu-buffer'). Each replaced past is disposed. On the CPU build ORT’s outputs stay where ORT puts them.

  • The attention mask spans the past and the new tokens. position_ids go in only where the decoder has them.

  • Temperature 0, the default, is greedy: the highest logit wins, and a tie keeps the lowest id, as GenAI’s top-1 does. It ignores top_p, top_k and seed.

  • Above 0, it samples. The logits are divided by the temperature. top_k keeps the k highest (default 50, 0 keeps all). top_p keeps the fewest of them whose probability reaches it (default 1). Then a seeded draw picks one. The PRNG is mulberry32, so one seed gives the same ids in every browser. Without a seed it draws one.

  • An end token from eos_token_id or an id in stop_token_ids is kept and ends the answer with stop.

  • A stop string needs decode, the tokenizer’s ids-to-text. After each token the text is decoded. At a stop string the answer ends with stop, and text ends before it. The budget ends it with length, an aborted signal with cancelled. max_millis, an agent’s time left, ends it with length after the current token.

  • The result holds ids, text (null without decode), finish_reason, the token counts, time_to_first_token_ms, decode_tokens_per_s and run_ms, the time inside session.run.

  • It takes token ids. The tokenizer and the chat template live elsewhere.

  • A guide holds the answer to a schema. It compiles the schema to a constraint. Before each draw the constraint’s mask names the allowed ids, one bit per id as llguidance lays them out, and every other logit drops out. Then the constraint takes the drawn id. OxidANT’s text_web crate gives the llguidance guide GenAI uses.

It refuses before any run. The TextGenerationError’s code is the error name of the text contract:

code

When

invalid_options

no prompt ids; a budget that is no positive integer; a negative or not finite temperature; a top_p outside (0, 1]; a top_k that is no integer of 0 or more; a seed outside 0 to 2^31 - 1, as GenAI reads it; an empty stop string or one with a NUL byte; a stop id that is no token id; a schema that is no JSON object

json_schema_unsupported

a schema that is a JSON object, and no guide

generation_failed

the guide refused the schema, or its mask allows no token

stop_unsupported

a stop string without decode: it could never match

context_length_exceeded

the prompt and the budget exceed context_length

invalid_model

the config lacks the layers, head size, context length or an end token

ort-web-loader-check.js --generate DIR replays DIR’s fixture.json in Chrome, through the loader. It runs each case whose messages are the fixture’s prompt, with the fixture’s prompt_ids. Other cases are skipped, since their ids need the tokenizer. Weights in model.onnx.data beside the graph go to ORT as external data. --threads N asks the loader for N threads. It takes no --model, --worker or --fake-ort.

--chat FILE replays through a consumer’s chat layer: a module whose load() gives a generate() over messages, tools and options, with its own tokenizer, template and guide. Then every case runs, and the tool cases too. lib/ort-web-fixture-verdict.js grades the report in one line. With a chat module a schema decodes, and each tool case’s calls must match by name and by their arguments as JSON values.

The suites:

  • linux/scripts/tests/test-ort-web-generate.sh runs the loop and the replay in node against a fake decoder.

  • test-genai-contract-fixture.sh covers linux/scripts/lib/genai-contract-fixture.py against a stand-in GenAI, and the released-model gate.

  • ort-web-generate-chrome-check.sh stages the image’s ORT Web and runs the native check, tiny-genai-model.py --check. Then it decodes the tiny model’s fixture on the CPU build, in a worker and in the page. Each case answers as the fixture says. Only a schema object differs: it answers json_schema_unsupported. Then a stand-in chat module, whose guide knows only a one-value enum, decodes the schema case to its one answer through the mask. It needs the image, so it is no test-*.sh: run-tests.sh would run it on the bare preflight runner. ort-web-generate-ci.sh runs it in the parity workflow.

  • The docs-site.ort-web-generate-*, docs-site.ort-web-llm-gate-* and docs-site.genai-contract-fixture-* mutations prove them.

The arm64 image has no ort.*.mjs bundles. There ORT_WEB_JS_DIR may name the npm package’s JS of the same ORT version. The suite hands it to the stager as --js-dir. Such a run proves the wasm and the loop, not the shipped bundles. Without it the Chrome suite skips there.

SmolLM2 runs in amd64 CI only. linux/scripts/lib/ort-web-llm-gate.sh decides it:

Host

ORT_WEB_LLM_DIR

Gate

not x86_64 (the Pi, arm64)

any

skip: the tiny model only

x86_64

none, CI set

fail

x86_64

none, no CI

skip

x86_64

no genai_config.json in it

fail

x86_64

a model directory

run

linux/scripts/ort-web-generate-ci.sh fetches ModelANT’s smollm2_135m_instruct_web-v1 by linux/scripts/lib/ort-web-generate.lock: the int8 web export and the contract of that release. An older contract has no case for the web model. Workflow ort-web-parity.yml runs it after the parity step. genai-contract-fixture.py --out writes the fixture of text-generation-v1 for the model. The prompt ids are what GenAI’s tokenizer and chat template give, with the generation prompt. --report judges the browser’s answer: the exact ids, or other ids whose decoded text holds must_contain.

Measured on a Pi 5 in the arm64 image, Chrome 157, ORT 1.31.1 with the npm package’s JS, SmolLM2 with the 42-token capital-of-france prompt and 8 new tokens. Every run gave the contract’s exact ids:

Build

Threads

First token

Decode

Time in session.run

CPU

2

1.1 s

2.2 tokens/s

4.2 s of 4.3 s

CPU

1

1.7 s

1.7 tokens/s

5.8 s

CPU

4

1.4 s

1.4 tokens/s

6.3 s

JSPI on SwiftShader

2

58 s

0.12 tokens/s

117 s

That was the int4 export. The int8 web export (MatMulInteger, tied embedding) decodes 12.2 tokens/s on the CPU build at 2 threads on the same Pi, with the contract’s exact ids.

  • Almost all the time is inside session.run. The JS around it (tensors, the cache hand-over, the argmax over 49 152 logits) takes milliseconds.

  • ORT’s profile puts 95 % of the CPU time in MatMulNBits: per decode step about 108 ms for lm_head and 2.5 to 3 ms for each MLP projection of the 30 layers. The wasm build has no 4-bit GEMM kernel, so each call dequantizes its weights first.

  • More threads do not help on the Pi’s 4 cores, which the page shares with Chrome itself.

  • SwiftShader is a CPU emulation of a GPU. Its numbers say nothing about a real GPU.

Generating text over an endpoint#

The browser’s fallback when no model is loaded: shared/web/javascript/endpoint-generate.mjs, shared asset web-endpoint-generate-mjs, next to ort-web-generate.mjs, whose option checks and TextGenerationError it imports. It posts OpenAI chat requests to <url>/v1/chat/completions and reads the answer under the text contract:

import { endpointGen } from '../javascript/endpoint-generate.mjs';

const gen = endpointGen({ url: 'http://127.0.0.1:11434', model: 'qwen3:0.6b', apiKey, headers, requestExtra });
const result = await gen.generate({ messages, tools, tool_choice: 'auto', options: { max_new_tokens: 512, max_millis },
  signal, onText: (piece) => postMessage({ piece }), onThinking });
// result: { text, thinking, tool_calls: [{ id, name, arguments }], finish_reason, raw_finish_reason, prompt_tokens,
//           completion_tokens, time_to_first_token_ms, decode_tokens_per_s, answered_by: 'endpoint', model, ids: [] }
  • It takes messages, never token ids: the server holds the tokenizer, the template, stop strings and the grammar. promptIds alone is invalid_options.

  • Messages and tools go out as openai-tool-calls.json says: a call {id, name, arguments} in OpenAI’s shape, a tool’s acts flag left out, tool_choice only beside tools.

  • The body is requestExtra first, then the caller’s keys. top_p and top_k go out only above temperature 0 and away from their defaults. seed and stop as given. json_schema becomes a strict response_format. A Qwen3 agent turns thinking off with requestExtra: { chat_template_kwargs: { enable_thinking: false } }.

  • It streams by default (endpointGen(endpoint, { stream: false }) asks for a whole answer). Text pieces go to onText, reasoning under either name to onThinking.

  • finish_reason is stop, length, tool_calls or cancelled. Any other raw reason ends as stop; raw_finish_reason keeps it. A stream that ends with no reason is generation_failed.

  • An aborted signal ends it at once with cancelled and what arrived. max_millis ends an unfinished answer with length. Without usage the completion count is the pieces read.

  • CORS is the server’s concern. The browser sends Content-Type and, with a key, Authorization.

Beside the option refusals of ort-web-generate.mjs:

code

When

invalid_options

no messages, no model, a URL that is not http(s), a tool that is no named function, two tools under one name, a choice naming no tool, a tool message answering no earlier call

endpoint_status

an HTTP status of 400 or more; status holds it, the message the body’s first 2000 characters

endpoint_unreachable

the fetch failed

endpoint_timed_out

no whole answer in timeoutMillis (default 300 s)

stream_line_too_long

a streamed line over 1 MiB

generation_failed

an error the server sent, a chunk that is no JSON object, a call without a name

linux/scripts/tests/test-endpoint-generate.sh replays the requests, whole answers and streams of openai-tool-calls.json, openai-stream-lines.json and openai-chat-answers.json in node against a fake fetch that splits lines across reads, then the body, every refusal, cancel, the time budget and the timeout. The docs-site.endpoint-generate-* mutations prove it. Its template cases are a local reader’s: the server parses its own model’s calls.

OxidANT’s agentRun (text-web-agent.mjs) takes an endpointGen as its gen: WebAgent.advanceMessages hands it the turn’s messages and tools, and replied takes its reply (OxidANT 1feed7c0). OmniAccelerANT’s worker runs its Agent tab on it while no browser model is loaded.