@writhq/demo
v0.2.0
Published
Writ end-to-end demo CLI — run the full KYA acceptance flow (onboard, mandate, ALLOW/DENY caps, revocation, anonymous block) against the live sandbox with one command: npx @writhq/demo.
Maintainers
Readme
@writhq/demo
Writ — KYA (Know Your Agent). See the whole thing work in one command.
npx @writhq/demoRuns the full KYA acceptance flow against the live sandbox — no signup, no
checkout, no config. It acts as both the principal and the agent, driving real
HTTP through a demo brokerage's gated /api/refill and the real requireKYA
middleware, and prints a readable transcript. It exits non-zero if any expected
outcome fails, so it doubles as a smoke test.
What you'll see (SPEC §6):
- Principal onboards + passes sandbox KYC
- Registers agent
treasury-bot - Issues a mandate:
account.refill≤ $1,000/tx, ≤ $2,500/week @ Northbank $500refill → ALLOW (resolved chain + verified receipt + co-signature)- Replay the same assertion → DENY
replay $2,000→ DENYper_tx_cap- More
$500s until the weekly cap → DENYperiod_cap - Principal revokes → DENY
mandate_revoked - Anonymous (no header) → 403 KYA required with an onboarding link
Usage
npx @writhq/demo [command] [options]| Command | What it does |
|---|---|
| (default) / live | Run the payment flow against the live sandbox. |
| sign | Run the signature authority flow (see below). |
| local | Spin up the passport + Northbank services from a repo checkout, run the flow, then tear them down. Prints a clear message if you're not inside a checkout. |
| help | Show help. |
| version | Print the version. |
Signature authority
npx @writhq/demo signThe second wedge, same shape. counsel-bot holds one mandate: it may sign
NDAs and order forms, up to $50,000 of liability per document and
$100,000 a month, at this counterparty only.
- Principal onboards + passes sandbox KYC, registers agent
counsel-bot - Issues the signing mandate (document classes + liability caps)
- Signs a $25,000 NDA → ALLOW — the counterparty executes the envelope and co-signs; the receipt names the exact document
- Replay the same authority → DENY
replay - An MSA → DENY
document_class(right agent, wrong kind of paper) - A $75,000 NDA → DENY
per_tx_cap(one document too big) - Two
$50,000order forms → the second DENYperiod_cap - Principal revokes → DENY
mandate_revoked - Anonymous (no header) → 403 KYA required
Writ attests the authority. It never produces the signature — the counterparty's e-signature step still does that — and none of this is a qualified electronic signature (eIDAS/QES).
| Option | Default | Purpose |
|---|---|---|
| --passport <url> | live sandbox / $PASSPORT_URL | Passport base URL. |
| --northbank <url> | live sandbox / $NORTHBANK_URL | Demo brokerage base URL. |
| --platform <id> | plt_northbank | Platform id. |
| --json | off | Machine-readable JSON result (good for CI). |
| --timeout <sec> | 120 | Startup timeout for local mode. |
Examples
npx @writhq/demo # live sandbox
npx @writhq/demo --json # JSON result for CI
npx @writhq/demo local # from a cloned repo
npx @writhq/demo --passport https://my-passport.example.com \
--northbank https://my-broker.example.comJSON output
--json prints one object:
{
"ok": true,
"mode": "live",
"target": { "passport": "...", "northbank": "...", "platform": "plt_northbank" },
"passed": 11, "failed": 0, "total": 11,
"checks": [{ "name": "...", "ok": true, "detail": "..." }],
"ids": { "principal": "prn_...", "agent": "agt_...", "mandate": "mnd_..." }
}Exit code is 0 on all-pass, non-zero otherwise.
local mode
local runs npm run dev in the repo root it finds by walking up from your
current directory, waits for both services to come up, runs the flow against
localhost:3000 / localhost:3100, and tears the services down when done. It
only works inside a Writ checkout; outside
one it tells you so and points you at the default (live) command.
The plt_sk_northbank_dev platform key printed by the demo is an intentionally
public sandbox key — it gates a fake brokerage with no real value.
Live sandbox: https://writhq.com · Home (soon): writhq.com
License
MIT © Tundra Industries
