# Benchlight Repair Café

**An open agentic website for a volunteer repair café: triage a broken household
item, decide whether it is safe to open at the bench, plan the minutes, tools and
parts, book a slot, print the ticket — and ask a partner parts co-op for a donor
part, with only the fields you allow leaving your browser.**

Built for the [Open Agentic Web Challenge](https://cognizant-agenticweb.devpost.com/)
against the *Minimum Viable Specification for a Worldwide Agentic Web*, MVP
Profile 0.3.

![Benchlight home page](screenshots/01-home.png)

## Why this use case

Repair cafés are a real, under-served civic service. Volunteers lose most of a
session discovering that the part is wrong, the item is unsafe to open, or the
job needed two people and forty minutes. Visitors carry in things that should
never be opened by a volunteer at all. The useful work happens **before** the
item reaches the bench: triage, a safety decision, a realistic plan and a
correct part.

That is exactly the shape of a small multi-agent network, and it has a hard
safety boundary the software can enforce in data rather than in a prompt:

- **Safe / caution** items get a plan and a bookable ticket.
- **Stop-class** items (microwave, gas hob, swollen e-bike battery) are referred
  to a qualified technician and are never booked, no matter what the visitor or
  the model asks for.
- Out-of-stock parts can be requested from a **separate published agent site**
  (the Parts Co-op) under an explicit, per-origin consent gate.

The result is less waste, safer volunteers, and a partner lookup that does not
require handing a visitor record to another site.

## See it

| Screen | What it shows |
| --- | --- |
| ![Triage](screenshots/02-triage-kettle.png) | Triage from the guide data: safety class, bench minutes, parts, tools, steps. |
| ![Schedule](screenshots/03-booked-schedule.png) | Real slot capacity, a booking and the ticket list. |
| ![Ticket](screenshots/05-ticket.png) | The printable bench ticket, built from the same data as the chat answer. |
| ![Stop](screenshots/06-stop-referral.png) | A sparking microwave is referred out; no slot can be booked. |
| ![Assistant](screenshots/04-assistant-answer.png) | The portable network answering with grounded tool results, no key. |
| ![Consent](screenshots/07-peer-consent.png) | Consent before another origin is contacted; withheld fields are named. |
| ![Co-op](screenshots/08-assistant-coop.png) | The partner network runs in this browser and answers from its own published data. |
| ![Spec](screenshots/09-spec-checks.png) | Manifest, graph, budgets and peer policy validated in the page. |
| ![Mobile](screenshots/10-mobile.png) | The same site on a 390 px viewport. |

The screenshots are real headless-Chromium renders produced by
`node tools/screenshots` (`tools/capture.mjs`). `demo.mp4` is the silent
screen recording to narrate over; `demo/demo.mp4` is the 1:20 cut published
to YouTube (TTS voice) with captions in `demo/subtitles.srt`, and
`VIDEO_SCRIPT.md` is the timed script for a human re-record.

**Live:** <https://afei8732-hub.github.io/open-agentic-web/> ·
**Video:** <https://youtu.be/F8yvkQrqp94> ·
**Repo:** <https://github.com/afei8732-hub/open-agentic-web>

## Run it

Requires Node 22 or newer. No dependencies, no build step, no network services.

```bash
npm start            # serves the site on http://127.0.0.1:8765 (loopback only)
npm test             # 42 node:test cases
npm run check        # published network is current + tests
```

Open `http://127.0.0.1:8765/`. A static file server is required because browsers
do not run ES modules from `file://`.

Try:

- `My kettle K-1200 stays cold. What parts will I need?`
- `The toaster won't heat and the lever sticks. Book me in.`
- `A microwave that sparks when I run it.`
- `Is the blender gasket in stock? If not, ask the Parts Co-op for a donor.`
- `Show my tickets and the open bench slots.`

The site is fully useful with **no key and no network**. Everything below runs
locally from `data/benchlight.data.json`.

## How it conforms to the MVP profile

| Profile capability | Where it lives |
| --- | --- |
| **Public manifest** | `agent-manifest.json` — brand, network name, front agent, resolved network path, sample queries, router/BYOK, peer policy, private-context fields, enabled site actions and link metadata. |
| **Portable, resolved network** | `networks/benchlight.network.json` (published) and `networks/benchlight.hocon` (authored source). JSON is a valid HOCON serialization; the resolved file has no includes, substitutions or executable definitions. `node tools/build-network.mjs --check` fails if the published file is stale. |
| **Browser runtime** | `runtime/agentic-runtime.js` — an original, dependency-free JavaScript orchestrator: manifest/network validation, graph execution, tool calls, delegation, budgets, action confirmation, peer consent and private-field filtering. |
| **Interaction UI** | `index.html`, `styles.css`, `app.js` — the site's own buttons and the assistant call the same registered site actions. |
| **Optional LLM/key configuration** | The Settings card. Leave the key empty for the guided planner, or enter any OpenAI-compatible router base URL, model and key. The key is used only in the `Authorization` header of requests to that router. |
| **Interact with the website** | Nine named actions (`get_site_state`, `find_faults`, `get_guide`, `plan_session`, `check_parts`, `prepare_part_request`, `book_bench`, `cancel_booking`, `get_ticket`) read and write the page's own state. |
| **Interact with other agentic sites** | The `shelf_keeper` agent declares a peer link to the Parts Co-op. The peer manifest and network are fetched from a different path/origin, validated, and run locally after consent. |
| **Callable by other agentic sites** | `agent-manifest.json` exports the network and front agent via `linking.exports`; `allowed_peers` and a closed `peer_policy` bound who may call it. The Node tests exercise a caller on a second origin loading and running the co-op network with only allow-listed fields. |

### Trust boundaries in this implementation

- **Writes are confirmed.** `book_bench` and `cancel_booking` have effect
  `write`; the runtime asks the visitor first and never retries an ambiguous
  outcome (a timeout after a write starts is reported as `unknown`).
- **Peers are opted in per origin.** A peer origin must be in `allowed_peers`,
  not denied by policy, and approved by the visitor. Approval lasts for the
  session unless the visitor asks to be asked again.
- **Private context is denied by default.** The peer link allow-lists
  `appliance_model`, `part_numbers` and `region`. Everything else — name,
  contact details, postcode, notes — is removed from the outbound arguments and
  scrubbed from free text before the peer sees it.
- **The key never travels.** It is not in the manifest, the network, a prompt, a
  tool argument, a ticket or a peer request. `providers.js` also redacts
  credential-shaped strings from errors shown in the page.
- **Finite budgets.** Steps, agent calls, composition depth, remote calls and
  elapsed time all have limits; the page shows them in the spec panel.

## Architecture

```
index.html / app.js ── page buttons ─────┐
        │                                ▼
        │                    bench/actions.js  (9 named actions)
        │                                │
        └── runtime.run(text) ── runtime/agentic-runtime.js
                                         │
                       ┌─────────────────┼──────────────────┐
                       ▼                 ▼                  ▼
             demo-model.js        providers.js         peer network
          (guided, keyless)   (BYOK OpenAI-compat)   (Parts Co-op,
                                                      after consent)
                                         │
                              bench/engine.js + data/benchlight.data.json
```

- `bench/engine.js` is the deterministic site backend: fault matching, safety
  classes, skill-adjusted minutes, shelf checks, booking capacity and tickets.
  The runtime never invents a number; every value in an answer comes from a tool
  result or the printed ticket.
- `runtime/demo-model.js` is a clearly-labelled guided planner, not an LLM. It
  chooses a tool pipeline from the visitor's words and writes the answer from
  real results. Adding a key swaps only `providers.js` into the same graph.
- `runtime/hocon-lite.js` parses the authored subset; `runtime/schema-lite.js`
  validates JSON Schema arguments strictly and rejects unknown keywords.

### The published network

Five agents, one front desk and one peer link:

- `bench_concierge` — front desk; routes to the specialists.
- `fault_triage` — reads symptoms and safety class from guides.
- `bench_planner` — minutes, tools and parts for a known guide.
- `shelf_keeper` — shelf stock and the donor request; the only agent that
  declares the `partshare` peer link.
- `bench_scribe` — bookings and printable tickets.

## Tests

`npm test` runs 42 cases with the Node test runner:

- parsers: strict schema validation, HOCON subset, published JSON equals the
  resolved authored source;
- engine: deterministic fault matching, stop-class refusal, skill-adjusted
  minutes, stock states, peer payload construction, booking capacity, ticket ids;
- runtime: manifest/network validation before any model call, cycles and
  executable definitions rejected, grounded keyless answers, write confirmation
  and decline, unknown write outcomes and no retry, peer consent and private-field
  scrubbing, allow-list refusal before fetch, budgets, bounded history;
- providers/BYOK: router URL normalisation, header-only key placement, streamed
  deltas and fragmented tool calls, redacted router errors, aborts, missing model,
  and a full runtime run through a stubbed router that executes a site action
  without the key appearing in any trace, event, tool result or answer;
- site: no remote assets, every referenced file exists, manifest artifacts and
  peer policy, screenshots present.

Screenshots and the demo are reproducible:

```bash
npm run screenshots  # headless Chromium over CDP, writes screenshots/
npm run demo         # silent screencast -> demo.mp4 via ffmpeg
```

Both drive **this** page against a temporary `127.0.0.1` server. No credentials
are used or typed.

## Deploy to GitHub Pages

The site is static and path-relative, so GitHub Pages needs no build:

1. Push this repository to a public GitHub repository.
2. Settings → Pages → deploy from the branch and `/ (root)`.
3. Open `https://<user>.github.io/<repo>/`.

`allowed_peers` includes `self`, so the bundled co-op works on the deployed
origin. To host the co-op separately, deploy `peer/` on its own origin, change
the peer link URL in `networks/benchlight.hocon`, rebuild with
`node tools/build-network.mjs`, and add that origin to `allowed_peers`. The
visitor is still asked before the first contact with any new origin.

## Honest limits

- Benchlight, its guides, stock, slots and the Parts Co-op are **fictional
  sample data** for a demonstration. The repair steps are plausible but are not
  instructions for mains electrical work; the safety copy deliberately refers
  dangerous classes out.
- The keyless mode is a deterministic guided planner, not a language model. It
  is useful, inspectable and honest about what it is; free-form conversation
  needs a key.
- Bookings live in the tab and disappear on reload. There is no server, account
  or payment.
- The API key is held in memory, or in `sessionStorage` if you tick the box. Any
  script running on the page could read it; that is the normal BYOK trade-off.
  Use a scoped, short-lived key.

## Original work

All code, copy and SVG in this repository is original for this entry. The
runtime is not the reference `nsdeploy` runtime and shares no code with it; it
was written against the public specification. The `spec/` checkout referenced
during development is not part of the submission. Licensed MIT (see `LICENSE`).
