Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

docs(remesh): record the Manifold build step and lock the caster's deps

nirholas7dad381b379f
diff --git a/STRUCTURE.md b/STRUCTURE.md
index f992ea477..6aa689618 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -191,7 +191,7 @@ bottom.
| Base58 difficulty model (the honest math) | [src/solana/vanity/base58-distribution.js](src/solana/vanity/base58-distribution.js), dispatch in [src/solana/vanity/validation.js](src/solana/vanity/validation.js); ported copies in [solana-agent-sdk/src/vanity/verify.ts](solana-agent-sdk/src/vanity/verify.ts) and [mcp-server/src/lib/base58-distribution.js](mcp-server/src/lib/base58-distribution.js), held in agreement by [tests/vanity-model-parity.test.js](tests/vanity-model-parity.test.js) | In-repo | The exact probability that a random Solana address matches a vanity pattern, and the single source of truth behind every quote, price, rarity tier, bounty payout and signed receipt. Base58 is a positional encoding of a 256-bit integer, so the *leading* character is not uniform: the 40 symbols `K`-`z` are 17.2x harder to lead with than `5`-`H`, a 58x spread the old flat 58ⁿ model erased. Models are versioned (`base58-exact/v2`, superseding `58^effectiveLength`) and receipts name theirs, so attestations issued before the correction still verify. Spec: [docs/PROTOCOL-vanity.md](docs/PROTOCOL-vanity.md#41-difficulty-model-versioning) |
| Vanity address grinder (Rust → WASM) | [crates/vanity-grinder/](crates/vanity-grinder) → compiled to [src/solana/vanity/wasm/](src/solana/vanity/wasm); consumed by [src/agent-vanity-grinder.js](src/agent-vanity-grinder.js), [src/agent-eth-vanity-card.js](src/agent-eth-vanity-card.js) | In-repo | The Rust source behind in-browser Solana/EVM vanity-address mining. Compiled to WebAssembly so grinding runs on the visitor's machine, never the server. Surfaced as the `vanity_grinder` MCP tool and the premium pre-ground inventory (`vanity_premium`). |
| x402 payment modal (drop-in UI) | [x402-payment-modal/](x402-payment-modal) | Published as `@three-ws/x402-payment-modal` | A drop-in payment modal for any x402 paid endpoint — one ES import turns a 402 challenge into a wallet-connect + pay flow. Has a build step, so it sits outside the zero-dependency `packages/*` SDK family. |
-| x402 modal SDK | [x402-modal-sdk/](x402-modal-sdk) | Published as `@three-ws/x402-modal` | The lower-level modal SDK the payment modal builds on. Ships a bundled `dist/`; see [x402-modal-sdk/TUTORIAL.md](x402-modal-sdk/TUTORIAL.md). |
+| x402 modal SDK | [x402-modal-sdk/](x402-modal-sdk) | Published as `@three-ws/x402-modal` | The lower-level modal SDK the payment modal builds on. Ships a bundled `dist/` (built by `build.mjs`, never committed); see [x402-modal-sdk/README.md](x402-modal-sdk/README.md) and [x402-modal-sdk/TUTORIAL.md](x402-modal-sdk/TUTORIAL.md). Exports `pay()` plus `discover()`, the UI-free 402 probe a server or agent can price a call with. Tests: `npm --prefix x402-modal-sdk test` (protocol + helpers, zero deps) and real-browser conformance [scripts/x402-modal-e2e.mjs](scripts/x402-modal-e2e.mjs). |
| React components | [packages/react/](packages/react) | Published as `@three-ws/react` (v1.0.1) | React components for embedding three.ws 3D AI agents |
| x402 auto-paying fetch | [packages/x402-fetch/](packages/x402-fetch) | Published as `@three-ws/x402-fetch` (v1.0.2) | Drop-in fetch wrapper that auto-pays x402 challenges |
| AgentCore payments MCP | [packages/agentcore-payments-mcp/](packages/agentcore-payments-mcp) | Published as `@three-ws/agentcore-payments-mcp` (v0.1.2) | MCP server for platform-managed agent payment sessions |
diff --git a/docs/guards.md b/docs/guards.md
index db6ab8c67..4866a26c2 100644
--- a/docs/guards.md
+++ b/docs/guards.md
@@ -173,6 +173,48 @@ These are the rules the existing guards follow. A new guard that breaks one of t
---
+## Proving a guard still works
+
+`npm run audit:guards` proves a guard is *wired*. It cannot prove the guard still *catches* anything. A checker that has rotted into a no-op (a directory it no longer scans, a regex that stopped matching, an exclusion list that grew until it excluded everything) exits 0 forever, and exit 0 is indistinguishable from a clean tree. That is the worst failure mode a safety net has: loudest when it works, silent when it dies.
+
+So every registry entry carries a `proof`: the violation the guard must reject.
+
+```bash
+npm run prove:guards # prove all of them, write public/guard-proofs.json
+npm run prove:guards -- --only check-claude-md
+npm run prove:guards -- --stage gate
+npm run prove:guards -- --help
+```
+
+Each proof runs twice inside a throwaway git worktree overlaid with your working tree, and both halves are required:
+
+1. **Control.** The sandbox is arranged so the guard must pass. A clean exit pins a known baseline; without it, "the guard exited non-zero" could just mean the sandbox is broken.
+2. **Violation.** One surgical mutation is applied. The guard must now exit non-zero **and** print the expected fragment, because a guard that fails for the wrong reason is not a working guard.
+
+A mutation proof is a fixture, not code:
+
+```json
+"proof": {
+ "summary": "CLAUDE.md telling an agent to run an npm script that does not exist.",
+ "violation": {
+ "append": { "CLAUDE.md": "\n\nVerify with `npm run guard-proof-nonexistent`.\n" }
+ },
+ "expect": "guard-proof-nonexistent"
+}
+```
+
+`violation` takes any of `write`, `append`, `delete`, `link`, and `json` (each `json` op needs a `file`, a `pointer`, and exactly one of `insert` / `set` / `removeWhere`), and an optional `setup` block arranges the control side first. A guard that genuinely cannot be proven offline (it needs `gcloud`, a browser, live credentials, or the network) declares the honest gap instead of a fake green:
+
+```json
+"proof": { "kind": "live", "reason": "Needs Playwright plus a server serving dist/, because the thing under test is the browser's own policy evaluation." }
+```
+
+`audit-guards` rejects a guard with no proof block at all, so this cannot be skipped. Results land in [`public/guard-proofs.json`](https://github.com/nirholas/three.ws/blob/main/public/guard-proofs.json) with a verdict per guard and the commit they were measured at.
+
+The runner is deliberately safe to run while other agents are working in this same tree: each run gets its own sandbox worktree keyed to its process id, and reclaims sandboxes left behind by runs that were killed before their teardown.
+
+---
+
## Adding a guard
The full walkthrough, with a complete worked example you can run, is in the tutorial: [Write a repository guard](/docs/tutorials/write-a-guard).
@@ -181,10 +223,12 @@ The short version:
1. Write `scripts/check-<thing>.mjs`. Exit non-zero with an actionable message.
2. Add an npm script for it in `package.json`.
-3. Add it to `data/guards.json` with the stage it runs in and the incident that motivated it.
+3. Add it to `data/guards.json` with the stage it runs in, the incident that motivated it, and a `proof` block (see [Proving a guard still works](#proving-a-guard-still-works)).
4. Wire it into that stage's chain.
-5. Write `tests/check-<thing>.test.js` covering the pass case and the fail case.
-6. Run `npm run audit:guards`. It will tell you if step 3 and step 4 disagree.
+5. Add a row for it to the tables above, so the page that lists every guard still does.
+6. Write `tests/check-<thing>.test.js` covering the pass case and the fail case.
+7. Run `npm run audit:guards`. It will tell you if steps 3, 4, and 5 disagree.
+8. Run `npm run prove:guards -- --only <id>`. It will tell you whether the guard actually catches what you claimed.
---
diff --git a/services/agent-screen-caster/package-lock.json b/services/agent-screen-caster/package-lock.json
new file mode 100644
index 000000000..807604d39
--- /dev/null
+++ b/services/agent-screen-caster/package-lock.json
@@ -0,0 +1,62 @@
+{
+ "name": "agent-screen-caster",
+ "version": "0.1.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "agent-screen-caster",
+ "version": "0.1.0",
+ "dependencies": {
+ "playwright": "1.60.0"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
+ "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/playwright": {
+ "version": "1.60.0",
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.60.0.tgz",
+ "integrity": "sha512-hheHdokM8cdqCb0lcE3s+zT4t4W+vvjpGxsZlDnikarzx8tSzMebh3UiFtgqwFwnTnjYQcsyMF8ei2mCO/tpeA==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "playwright-core": "1.60.0"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "optionalDependencies": {
+ "fsevents": "2.3.2"
+ }
+ },
+ "node_modules/playwright-core": {
+ "version": "1.60.0",
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0.tgz",
+ "integrity": "sha512-9bW6zvX/m0lEbgTKJ6YppOKx8H3VOPBMOCFh2irXFOT4BbHgrx5hPjwJYLT40Lu+4qtD36qKc/Hn56StUW57IA==",
+ "license": "Apache-2.0",
+ "bin": {
+ "playwright-core": "cli.js"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ }
+ }
+}
diff --git a/workers/remesh/README.md b/workers/remesh/README.md
index 2112d09d4..1fb16afa9 100644
--- a/workers/remesh/README.md
+++ b/workers/remesh/README.md
@@ -42,12 +42,33 @@ yields a static FBX.
| `remesh_mode` | What it does |
|---|---|
| `triangle` (default) | Repair + quadric-error triangle decimation (open3d, trimesh fallback). Geometry only — drops materials. Honors `operation`. |
-| `quad` | Field-aligned quad-dominant topology via QuadriFlow, then xatlas UV re-unwrap + source-texture re-bake. Reports a real `quad_ratio`. |
+| `quad` | Field-aligned quad-dominant topology via QuadriFlow, then xatlas UV re-unwrap + source-texture re-bake. Reports a real `quad_ratio`. An open or non-manifold input is cleaned and rebuilt watertight first (see below); QuadriFlow refuses anything else. |
| `lowpoly` | Silhouette-preserving QEM decimation + UV re-unwrap + texture re-bake. |
`operation` (`convert` · `simplify` · `repair` · `full`) applies to `triangle`
mode; `full` (default) runs repair then decimate.
+### What quad mode does to your mesh before QuadriFlow
+
+QuadriFlow needs a watertight manifold, and no real character export is one:
+they are assembled from overlapping parts, so seams share edges between more
+than two faces, and they are open at the wrists, neck, and hems. Fed such a mesh
+QuadriFlow aborts in its index-map solve with `wrong init`, whichever flow solver
+it is given. Quad mode therefore runs three preparation steps, each of which
+falls through rather than failing the job:
+
+1. `_repair_mesh` fills holes, drops degenerate faces, and merges vertices.
+2. `_make_manifold` removes duplicate and non-manifold geometry via open3d.
+3. `_watertight_obj` rebuilds an open mesh with
+ [Manifold](https://github.com/hjwdzh/Manifold) (MIT, same author as
+ QuadriFlow, which is what its README prescribes). A mesh that is already
+ watertight skips this, since the rebuild is an approximation.
+
+QuadriFlow then walks a solver ladder (`-mcf -sharp`, `-sharp`, bare) under one
+shared wall-clock budget. Falling back to triangle soup is never one of the
+rungs: a quad request that cannot be met is reported as failed, with the solver
+output in the message.
+
## API
All routes require `Authorization: Bearer $API_KEY`, except `/health`.
@@ -122,6 +143,9 @@ Unauthenticated, so Cloud Run's startup probe can reach it.
| `MAX_CONCURRENT` | no | `2` | In-flight jobs |
| `QUADRIFLOW_BIN` | no | `quadriflow` | Path to the QuadriFlow executable. The image builds it and sets this to `/usr/local/bin/quadriflow` |
| `BLENDER_TIMEOUT` | no | `300` | Seconds before a Blender FBX export is killed |
+| `MANIFOLD_BIN` | no | `manifold` | Path to the [Manifold](https://github.com/hjwdzh/Manifold) executable (built into the image). Quad mode rebuilds an open mesh watertight with it before QuadriFlow, which requires watertight manifold input |
+| `MANIFOLD_RESOLUTION` | no | `50000` | Octree resolution for that rebuild |
+| `MANIFOLD_TIMEOUT` | no | `120` | Seconds before the rebuild is abandoned and the raw mesh is used |
## Build and test locally