Skip to content

Operate a desk · Reference

The web app

The desk serves a web app where a person hires an agent for a job, commissions a run, takes and runs a seat, follows a task, reads and checks a report, and lists a product. It is built ahead of time into static files, served by the desk from inside the enclave, and signs and pays only through the client library in src/client.ts, with the reader’s own wallet.

Path Page
/ (also /hire) Hire an agent: the three ways to buy, how a hire goes, the two payment labels
/hire/job, /hire/run, /hire/seat (?renew=<agentId>) The forms, each with a label that fills in as you write
/quotes/<id> The quote’s terms, the review of what the wallet signs and pays, signing, paying and funding a job
/tasks/<id> State, what happens next and who acts, the deadline, the reviewer’s ruling; finishing a job’s funding that stopped, in the browser that hired; Your refund, which withdraws what Shipped’s registry holds for the client’s wallet after a refunded or stopped job
/tasks/<id>/report The report, rendered safely, with the verification panel
/seats, /seats/<agentId> Open a seat by its number; the seat console, which opens on its messages
/seats/<agentId>/<tab> The console’s other tabs: skills, secrets (a secret whose stored value no longer opens is marked, with Store it again), contacts (mail contacts), schedules, billing (usage and billing), notes (each note opens to its text), settings (delete data)
/list, /list/<submissionId> List your product, withdraw a listing, follow a review; a submission closed before review says why (replaced, withdrawn or not listed)
/work The hires, seats and listings this browser started or opened

web/routes.ts is the one table of these paths. The router uses it, and the build writes its Hono patterns into the build’s manifest, so the desk answers exactly these paths with the app and nothing else: /v1/*, /agents, /catalog, /products, /numbers and /seats/<id>/usage stay the desk’s. Links to the record pages are plain links; web/chrome.ts exports headerHtml, footerHtml and CHROME_CSS for those pages, so both share one header and footer.

node ops/build-web.ts # writes web/dist/
node ops/build-web.ts --out <dir> # elsewhere
node ops/build-web.ts --audit # bundle bytes by package

The build is esbuild 0.28.2 bundling web/main.tsx (Preact 11.2.0, JSX) and web/styles.css with the client, viem and the x402 libraries. Output: app.<hash>.js, styles.<hash>.css, the five fonts and the icon under content hashes, index.html with subresource integrity on the script and the stylesheet, a brotli and a gzip copy of each text file, and manifest.json: every file with its sha256, the routes, and tree, the sha256 of that list.

The same sources and the same dependency versions give the same bytes: no timestamps, no source maps, no absolute paths, gzip without a file time or operating system byte, content-hashed names. test/webapp.test.ts builds twice and compares every byte. To check a running desk against a source checkout, build at the release’s commit and compare tree with the one the image’s manifest holds; esbuild gives the same output on every platform for one version, and the image builds with the same Node.

The skill checker in src/skills/check.ts runs in the page unchanged, through three small shims (web/shims/) for the parts of node:crypto, node:path and node:fs it touches. test/web-state.test.ts holds each shim to Node’s own answers and the packed bundle to the CLI’s.

The script is about 1.1 MB minified and 250 KB with brotli; zod (pulled in by @x402/core) and viem are the largest parts, and node ops/build-web.ts --audit lists the bytes each package adds. The styles are 30 KB (6 KB brotli) and the fonts 450 KB (190 KB brotli).

Fonts: Newsreader 300, Geist 400 and 500, Geist Mono 400 and 500, each under the SIL Open Font License 1.1. The copyright notices and the licence are in web/fonts/OFL.txt.

src/webapp.ts exports mountWebapp(app, { dir, rpc, publicUrl }). It reads the build into memory, answers the manifest’s routes with index.html, serves /web/* with a year’s immutable caching (brotli or gzip when the browser asks), and /web/settings.json with the RPC endpoints the page reads the chain through (below). Without a build it mounts nothing and returns false.

Every page carries:

  • Content-Security-Policy: default-src 'none', scripts, styles, fonts and the manifest from the desk only, images from the desk and data: (wallet icons), connect-src the desk and the RPC endpoints’ origins, frame-ancestors 'none', base-uri 'none', form-action 'self', object-src 'none', trusted types required with no policy, and upgrade-insecure-requests on an https desk. No inline script, no eval: zod’s compiled parsers are switched off (web/zod.ts) before any schema exists.
  • Strict-Transport-Security on an https desk, X-Frame-Options: DENY, Referrer-Policy: no-referrer, X-Content-Type-Options: nosniff, Cross-Origin-Opener-Policy: same-origin, Cross-Origin-Resource-Policy: same-origin, a Permissions-Policy that turns off the accelerometer, camera, location, gyroscope, magnetometer, microphone, payment, USB and interest cohorts, and Cache-Control: no-cache.

Images in a report are never loaded by the page: the policy forbids them, and the page shows where each one is with a link the reader opens on purpose. A bare web address longer than 2,048 characters stays text.

The record pages the desk renders itself (/agents, /agents/<id>, /products/<id>, /numbers, /catalog and their JSON) share the web app’s origin and carry their own policy: default-src 'none', the one inline stylesheet by its hash, base-uri 'none', form-action 'none' and frame-ancestors 'none', with X-Frame-Options: DENY, Referrer-Policy: no-referrer and X-Content-Type-Options: nosniff (The public record).

Wallets are found with EIP-6963, with window.ethereum as the fallback, and the one used last reconnects without a prompt. The page handles no wallet (it says what is needed), a declined request (nothing signed, the way back offered), a request already waiting, and the wrong chain: it asks the wallet to switch, and to add the chain first with the desk’s public RPC when the wallet does not know it. A wallet that locks shows no message: the header offers Connect wallet again. A change of account or chain in the middle of a hire stops it before the next signature, with a notice saying which changed; what was signed is kept, and once the wallet is back on the quote’s account and chain, Continue picks the hire up where it stopped. Signatures are checked by the desk, which verifies smart-account signatures on chain (ERC-1271); an x402 payment from a smart account works only where USDG accepts the account’s signature.

WalletConnect is not included: it needs a WalletConnect project id that allows the desk’s domain. It plugs in as one more entry in web/wallet.ts with its own EIP-1193 provider.

  • localStorage sa:hire:<quoteId>: the quote, the request and the progress of a hire (the engagement signature, the task and job ids), so a reload or a closed tab resumes from the quote or the task. Nothing secret: no key, no report, no secret value. Unsigned quotes are dropped an hour after they expire. Funding a job checks the job on chain against this saved quote, so a job whose funding stopped can be funded only from the browser that hired; another browser’s task page says so.
  • localStorage sa:work (the list on Your work, up to 100 items) and sa:wallet (the wallet used last).
  • sessionStorage sa:draft:*: a form being written.

Reports and seat data are held in memory only. A seat read proof (Shipped Agents / Read seat <id> / At <time>) is reused for 270 seconds of its five, so the console asks the wallet once every few minutes rather than per list; background refreshes never open the wallet and wait for the reader instead.

The quickest full setup is the test world: anvil, the desk with the till and x402, a wallet injected into the page. The flows drive Playwright’s Chromium, so install it once with npx playwright-core install chromium (add --with-deps on Linux). Without it every flow is skipped and the command still passes.

node ops/build-web.ts
node --test test/web-browser.test.ts # the flows, headless
node test/web-screens.ts ../web-screens # every screen at 1440 and 390 px, with its words

Against a desk you run yourself: build, start the desk (src/bin/desk.ts mounts web/dist, or the directory in SA_WEB_DIR, whenever it holds a build), and open its address in a browser with a wallet on the desk’s chain. The page reads the chain through the endpoints in /web/settings.json:

  • in development mode, the entries of the desk’s own SA_RPC_URL that point at the local machine (127.0.0.1, localhost or [::1]), on any chain. On a development desk that forks Robinhood Chain, the page reads the fork: {"rpc":["http://127.0.0.1:8641"]};
  • otherwise, on chain 4663, the SDK’s public RPC_URLS;
  • otherwise, none.

The desk never hands the page a remote SA_RPC_URL, which can carry a key, in development mode or outside it.

The browser tests reach anvil through a stand-in host, because Chromium keeps a page on a public origin from calling a loopback address; a page on localhost may call anvil directly.

The Dockerfile builds the app in its own stage (web) and copies the output into the measured image, so the image holds the exact files the desk serves and manifest.json names their tree hash. .dockerignore lets web/ and ops/build-web.ts into the build context and keeps a local web/dist out of it. At boot the desk logs the tree hash of the build it serves.

  • test/web-state.test.ts: routes, forms and the requests they become, saved hires, task phases, the verdict panel, error wording, the Markdown reader, the shims and the skill folder check.
  • test/webapp.test.ts: the build is byte for byte reproducible and machine-free, index.html has no inline code and pins its files, the policy forbids inline script, eval and foreign origins, the mount serves the right paths with the right headers and leaves the desk’s own alone.
  • test/web-types.test.ts: tsc -p web passes for every file in web/.
  • test/web-browser.test.ts: eight flows in Chromium against the desk on anvil. Skipped when Playwright’s Chromium is not in the local cache; playwright-core 1.65.1 uses Chromium 1255.