Skip to content

Latest commit

 

History

History
453 lines (362 loc) · 29.3 KB

API.md

File metadata and controls

453 lines (362 loc) · 29.3 KB

AgentHub local API (page ⇄ hub)

The contract between the page in page/ and the hub. The local hub serves the Keys API. The existing page mock supports the earlier screens. Fields marked (added) are additions to the brief's draft, needed by the page.

Basics

  • The hub listens on 127.0.0.1 only. agent-hub open opens http://127.0.0.1:<port>/#t=<token>.
  • The page moves the token to sessionStorage and strips it from the URL at once (history.replaceState).
  • Every /api/* request sends X-Hub-Token: <token>. Wrong or missing token → 401 { error }.
  • (added) GET /api/events takes the token as ?token= because EventSource cannot send headers. Only this route accepts the query form.
  • JSON in, JSON out. Errors: non-2xx with { ok: false, message } (or { error }). message is shown to the user as is, so write it as a plain sentence.
  • The page sends a strict CSP (script-src 'self', connect-src 'self', frames only from 127.0.0.1/localhost). The hub should also send X-Content-Type-Options: nosniff and Cache-Control: no-store on API responses.

State

GET /api/state

{
  "hub": { "version": "0.1.0" },
  "agents": [{ "name": "claude-code", "kind": "terminal" | "extension", "tools": 61, "connectedAt": "ISO",
               "canReceiveInboxPush": true }],
  "apps": [{
    "id": "weather-station", "name": "Weather Station", "version": "0.2.0",
    "trust": "verified" | "community",
    "running": true,
    "phase": "Monitoring",             // short status word(s); "Starting" and "Stopped" are special
    "mcp": "ok" | "failing" | "off",
    "keyNumber": { "label": "Calibrated", "value": 46, "of": 47, "unit": "passed today",
                   "segments": [{ "label": "Rain gauge", "tone": "bad", "text": "failing" }] },  // of, segments: (added, round 2)
    "tabs": [{ "id": "alerts", "label": "Alerts", "count": 1, "tone": "bad" }],   // (added, round 2) optional, see below
    "panels": [{ "type": "kv", "title": "Rain gauge stopped reporting", "tab": "alerts", "wide": true }],  // optional layout metadata
    "trend": [392.1, 401.7, ...],      // (added) optional, last ~24 values of keyNumber for the Home sparkline
    "update": { "version": "0.1.18", "security": true, "summary": "one line" },   // optional
    "attention": [{ "kind": "error", "text": "1 sensor alert needs review", "action": "review",
                    "tab": "alerts" }]  // optional; tab (added, round 2): where Review leads
  }],
  "inbox": 0,                          // requests waiting for the agent
  "inboxItems": [{ "id": "request-id", "at": "ISO", "appId": "pixel-oracle", "delivery": "seen",
                   "pushedTo": "claude-code", "pushedAt": "ISO", "seenAt": "ISO" }],
  "installs": [{ "stagingId": "stg_…", "id": "pixel-oracle", "name": "pixel-oracle",
                 "kind": "install" | "update", "step": "fetch" | "scan" | "review" | "confirm" | "start" | "done" | "failed" }]  // (added)
}

installs lists running installs/updates (and ones finished in the last minute) so the page can reopen their sheet. hub.update uses the hub row from /api/updates when a signed AgentHub upgrade is available. apps[].update and install progress can include requiresAgentHub with the required range and user-facing message. keyNumber.label should not repeat value/unit; the page shows phase · label under the number and drops a phase that contains a digit. (added, round 2) keyNumber.of draws 46 /47. keyNumber.segments replaces the Home sparkline with one bar per part (for example, each sensor check) and a line naming the parts with tone bad/warn. State includes panel layout metadata when the manifest supplies a panel tab or width. App detail supplies the resolved panel data.

App

GET /api/app/:id

Everything in the state entry, plus:

{
  "description": "…", "publisher": "Trac Systems", "toolPrefix": "dex", "tools": 23, "dataDir": "~/.intercom-dex",
  "settings": { "autostart": true, "moneyApproval": "ask" | "agent" | null, "hold": false },          // (added)
  "secrets": [{ "env": "DEX_KEY_PASSWORD", "label": "Wallet password", "set": true }],              // (added) never values
  "permissions": { "network": ["p2p", "localhost", "api.mainnet-beta.solana.com"], "money": true },  // (added)
  "status": { /* the app's own status JSON */ },
  "tabs": [Tab],                              // (added, round 2) the app's own tabs; optional
  "panels": [Panel],
  "dashboardUrl": "http://127.0.0.1:4720/",   // optional; shown as the Dashboard tab (iframe + open in browser)
  "logsTail": [{ "t": "15:41:02", "level": "info" | "warn" | "error", "msg": "…" }],   // (added: structured lines)
  "approvals": [Approval]                     // (added) this app's waiting money actions
}

Tabs (added, round 2)

Tab = { id, label, count?, tone? }. The page shows Overview, then the app's own tabs in manifest order, then the hub's tabs (Dashboard if dashboardUrl, Logs, Settings). Ids overview, dashboard, logs, settings are reserved. count draws a badge (tone: 'bad' makes it red). The same tabs may also be sent in /api/state so they appear before the detail loads. Route: #/app/<id>/<tab>.

Dashboard height (added, 0.1.8)

The Dashboard tab shows the app's page in an iframe across the full content width. Dashboards are cross-origin: the hub opens them through its own /dashboard/<id>/<ticket> redirect, which lands on the app's own loopback port.

  • Default (no messages): the frame fills the space below the hub header (at least 420 px) and the app scrolls inside it. Right for apps with their own scroll areas, sticky sidebars, infinite feeds or 100vh layouts.
  • Opt-in, "as if embedded": a page that reads well as one tall page posts its content height to the hub. The hub sets the frame to that height and the hub page scrolls as one, with no inner scroll bar.
// In the app's dashboard page. Only when embedded.
if (window.parent !== window) {
  const send = () => parent.postMessage({ type: 'agenthub:height',
    height: Math.ceil(document.documentElement.getBoundingClientRect().height) }, '*');
  new ResizeObserver(send).observe(document.documentElement);
  addEventListener('load', send);
}

Post from every page of the dashboard: the frame keeps the last height until a new one arrives. Measure the content, not the viewport: document.documentElement.scrollHeight never drops below the frame's own height, so a page that shrinks would stay tall. Don't post heights from a layout sized with 100vh/100% height.

The hub accepts a message only when event.source is that dashboard's frame window and event.origin is a dashboard origin: http://127.0.0.1:<port> or http://localhost:<port> other than the hub page's own origin (the only places the hub's dashboard redirect can land, see src/page/dashboard.mjs). The first accepted origin is pinned for that frame; later messages from another origin are ignored. height must be a finite number and is clamped to 200–20000 px. Anything else is ignored. Messages carry nothing but the number; the hub sends nothing back.

Panels

The hub resolves each manifest panel's source and sends the result as data. A panel may carry tab (default overview) and wide: true. The page draws each tab's panels with one component set:

  1. number panels as a row of tiles;
  2. kv and status panels as a row of compact cards (up to three across; a single one spreads across the row); a kv or status panel marked wide gets a row of its own above them (added, 0.1.8);
  3. table, checks, form with layout: 'row' and any wide panel at full width;
  4. everything else in two columns.
type data
number `{ value, unit?, of?, ratio? (0–1, draws a bar), caption?, trend?: number[], tone?: 'ok'
chart { unit, window: '30 min', series: [{ name, points: [[iso, value], …] }], tip? } — one series, one axis
table `{ columns: [{ key, label, align?: 'end', format?: 'mono'
list { items: [{ id?, title, text, tone?, badge?, detail?: { text?, code?, note? }, actions?: [Action] }], more?, empty?, tip? }
timeline { items: [{ at, text, kind }] }
form `{ fields: [{ name, label, type: 'select'
kv (added, round 2) { lead?: { value, unit?, tone?, dot?, caption? }, text?, items: [{ label, value, mono?, copy?: true | string, short?, wrap?, qr?, tone?, tip? }], link?: { label, href, primary? }, more?: { label, tab }, tip? } — text, wrap, qr (added, 0.1.8)
status (added, round 2) { state, label, tone?, busy?, off?, since?, sinceText?, text?, facts?: [{ label, value }], steps?: [string], step?, action?: Action, tip? }
checks (added, round 2) `{ items: [{ id, label, state: 'pass'

Action = { label, tool, args, primary?, tip?, money?, confirm?, disabled? }: a button that calls that app tool directly (below). (added, round 2) money: { value, unit, text } makes the button show the amount and ask for an inline confirm (amber, text says what moves); confirm: "sentence" asks for a plain inline confirm; disabled: "reason" greys it out and shows the reason.

  • kv: labelled values. lead is the one big value (a word like "Synced" with a status dot, or an amount with a unit); tone: 'warn' turns it amber. copy adds a copy button (true copies value, a string copies that); short shows the middle of a long value as … (full value on hover and in the copy). wrap shows the whole value on its own line, wrapping (addresses people must check character by character). qr draws a QR code of that value (UTF-8, up to 200 bytes) on the card's right, below it on phones; it implies wrap, and only the first qr item gets a code. text is one sentence under the lead, e.g. how to use the value. Example, a deposit box: { lead: { value: '12.5', unit: 'TNK', caption: 'Confirmed balance' }, text: 'Send test TNK from your TAP Wallet to this address. It shows up here once confirmed.', items: [{ label: 'Lab deposit address', value: 'testtrac1…', mono: true, copy: true, qr: true }] } with wide: true in the manifest. The QR encoder is page/lib/qr.js (self-contained, MIT, byte mode, versions 1–10, level M). link is one external link (opens in the browser). Set primary to show an amber button. more links to one of the app's tabs.
  • status: a state machine with one action per state. steps draws a stepper with step (0-based) as the current one. busy pulses it. off marks a state off the normal path, such as an expired calibration (tone: 'warn') or sensor error (tone: 'bad'). text describes the state and facts can show values such as the temperature offset in its place. sinceText is the hub's "2 h" so the page does not need the app's clock.
  • checks: one cell per area with pass/fail, passed/total, the last run and a one-line text (the failure, or why it waits). A cell with tab links there. The header sums passed/total over cells that ran (pass, fail, running) and have a total; blocked and idle cells have missions but no result yet, so they do not count. (round 3)

Weather Station (GET /api/app/weather-station)

Weather Station is a fictional app in the page preview. Its tabs show invented sensor readings and exercise the same panel types used by installed apps.

tab panels
Overview kv Current readings and Station balance, status Temperature sensor, checks Sensor checks
Sensors kv Sensor details, including a copyable station ID
Sampling form Sampling request with a daily readings meter
Alerts kv Rain gauge status, linked from Home and the failing check

Temperature sensor states can expose one action each.

state label action
disconnected Sensor disconnected Pair sensor (weather_pair_sensor)
pairing Pairing… —
ready Ready to calibrate Calibrate sensor (weather_calibrate_sensor, confirms 2.50 USD, disabled below that balance)
calibrating Calibrating… —
calibrated Calibrated Disconnect sensor (weather_disconnect_sensor, plain confirmation)
expired Calibration expired Calibrate sensor
fault Sensor error —

The app's status contains { mode, balance, temperature }. On Home, keyNumber shows checks passed out of checks run. Its label is the calibration state and segments show each sensor check.

POST /api/app/:id/start → { ok, message }

Answers at once; progress arrives as state events (phase: "Starting", then running: true).

POST /api/app/:id/stop { force? } → { ok, message }

If the stop guard fails: 409 { ok: false, blocked: true, guard: "no unfinished trades", canForce: false, message }. (added) blocked, guard, canForce. The page shows message next to the Stop button.

POST /api/app/:id/settings { autostart?, moneyApproval?, hold? } → { ok, settings } (added)

POST /api/app/:id/call { tool, args, confirm? } → { ok, message } (added)

Runs one app tool through the gateway. For a declared action the tool and arguments must match the current panel. A disabled action answers 409 with its reason. A plain confirmation sends confirm: true. A money action must be declared with money and send the matching amount and unit, for example confirm: { value: "2.50", unit: "USD" }. An amount mismatch returns 409 { ok: false, message: "Confirm 2.50 USD first." }. The inline confirmation satisfies the user's approval for a page action and Activity records the confirmed amount. Money calls initiated through the agent connector use moneyApproval. The page reloads the app detail right after a call.

Agent loops

Apps offer an agent loop by publishing the MCP prompt <toolPrefix>_start with no required arguments. The prompt starts from a fresh session, uses app tools to read the app's saved state, and tells the agent when to end. An optional <toolPrefix>_start_prompt tool can return the same text for clients without MCP prompt support. The existing manifest format is sufficient.

  • GET /api/app/:id/prompts → { start: { name, text } | null }. Use text for Copy start prompt.
  • GET /api/app/:id/loop → { id, available, schedule, running }. available reports whether the app currently offers its start prompt. schedule is null until configured, then { enabled, agent, everyHours, maxMinutes, lastRun, nextRun }. Dates are ISO 8601 strings or null. running is { startedAt, agent } during a run and null otherwise.
  • POST /api/app/:id/loop with { enabled?, agent?, everyHours?, maxMinutes? } → the same view. Choose claude or codex and an interval of 1, 2, 4, 8, 12, or 24 hours when setting up a loop. The run limit is 10–120 minutes, at least 10 minutes shorter than the interval, and defaults to 45. A new schedule starts after one interval. { "enabled": false } turns off future runs and keeps the settings and history. Use the stop route to end an active run.
  • POST /api/app/:id/loop/run → the same view. A saved schedule supplies the agent and run limit, even if future runs are off. Run now leaves the next scheduled time in place. Only one run per app can be active and only one scheduled run can be active across AgentHub. A missing CLI is recorded and the next scheduled attempt waits until the next slot.
  • POST /api/app/:id/loop/stop → { id, stopped }. Waits for the active run to end before returning.
  • GET /api/app/:id/loop/history?lines=100 → { id, runs, log }. Up to 50 runs, newest first, with { startedAt, endedAt, exitCode, reason, agent }. exitCode is null when no exit code was available. log is recent stdout and stderr. The requested line count can range from 1 to 1000.

Mutations use the usual page token and local origin. Missing apps return 404. Invalid settings return 400. Run and setup requests can return 409 if the app is unavailable or the requested run is already active. Removing an app removes its schedule and history. Updating the app preserves the settings. A schedule waits if the app's current release does not offer a start prompt.

hub_agent_loop takes no arguments to list available apps, or { id } for one app. To change a schedule, pass id, the schedule fields, and userConfirmed: true only after the user agrees.

Activity

GET /api/activity?kind=&appId=&limit=

kind may be a comma list. Newest first.

[{ "at": "ISO", "appId": "intercom-dex" | null, "kind": "agent"|"user"|"money"|"finding"|"update"|"security"|"app",
   "text": "plain sentence", "agent": "Claude Code", "amount": "61.25 USDC" }]

(added) app kind (the app did it by itself), optional amount, appId query filter.

Library and sources

  • GET /api/library → [{ id, name, description, version, trust, sourceId, publisher, installed }] (publisher added)
  • GET /api/sources → [{ id, name, url, trust, builtIn, count }]
  • POST /api/sources { url } → { ok, source }; 400 { message } for an unusable URL
  • DELETE /api/sources/:id → { ok } (added); built-in sources cannot be removed

Installs and updates

The page never installs anything. The agent drives hub_install_plan → hub_security_scan → hub_submit_review; the page shows progress and sends the user's OK.

GET /api/installs/:stagingId

{
  "stagingId": "stg_…", "id": "pixel-oracle", "name": "pixel-oracle", "kind": "install" | "update",
  "version": "0.3.1", "from": "0.1.17",                 // from: updates only
  "step": "fetch" | "scan" | "review" | "confirm" | "start" | "done" | "failed",   // (added)
  "trust": "community",
  "manifest": { "id", "name", "version", "publisher", "description" },
  "fetch": { "status": "done", "summary": "Checksum matches the release. Publisher key seen for the first time." },  // (added)
  "permissions": { "network": [], "secrets": ["labels"], "money": false, "moneyTools": [], "files": [], "installScripts": [] },
  "scan": { "status": "running" | "pass" | "warn" | "fail", "packages": 318,
            "findings": [{ "severity": "info" | "warn" | "fail", "rule": "network.undeclared",
                           "title": "Talks to a server it does not declare: cdn.pxl-assets.io",   // (added) plain words
                           "file": "src/thumbs.js", "line": 41, "evidence": "…" }] },
  "review": { "verdict": "pass" | "warn" | "fail", "agent": "Claude Code", "summary": "…",
              "findings": [{ "severity", "title", "file", "line" }] },
  "ready": true                                          // scan done, review in, nothing failed
}

POST /api/installs/:stagingId/confirm { acceptWarnings } → { ok, message }

The user's click. 409 unless ready; 409 if there are warnings and acceptWarnings is not true. Progress (start → done) arrives as install events. Same endpoint for updates.

DELETE /api/installs/:stagingId → { ok } (added 0.2.18)

Cancels a staged install or update before it is confirmed and removes its files; nothing from the release has run. 404 if the plan is gone. Sends an install event with step: "cancelled". The hub also removes plans that are older than a day or were made against a version that is no longer installed (at start and hourly). /api/state.installs lists only the newest plan per app.

GET /api/updates → [{ id, name, from, to, security, breaking, notes, compat }]

notes (changed) is a list: [{ kind: "security" | "new" | "fix" | "breaking", text }]. breaking is false or a sentence. compat (added) is one sentence. The hub release has kind: "hub" and appears first, followed by security updates. A queued hub release has status waiting or switching. A waiting release also lists its blockers in waitingFor. An incompatible app update includes requiresAgentHub and an applicable hubUpdate when available.

POST /api/updates/agent-hub/plan → { stagingId }

Verifies and stages the signed AgentHub release. The owner approves it through the same install confirmation endpoint.

POST /api/updates/:id/hold · POST /api/updates/:id/skip → { ok }

Keys

Every Keys route requires X-Hub-Token. POST and DELETE also require the page's loopback Origin. Send sensitive input as JSON in the request body. All responses use Cache-Control: no-store.

GET /api/keys

{
  "apps": [{
    "id": "my-app",
    "name": "My app",
    "dataDir": "/absolute/app/data",
    "declared": true,
    "keys": [{
      "id": "wallet", "label": "Trac wallet", "kind": "trac-wallet",
      "files": ["/absolute/app/data/wallet/keypair.json"],
      "available": true,
      "lastBackupAt": "ISO timestamp or null",
      "public": { "address": "trac1…", "publicKey": "…", "note": "…" },
      "canReveal": false
    }]
  }],
  "archives": [{
    "appId": "my-app", "date": "ISO timestamp", "size": 327,
    "kind": "data", "path": "/absolute/hub/data-archive/my-app-20261130T123456Z"
  }],
  "requests": [{ "id": "uuid", "action": "backup", "selection": { "appId": "my-app", "keyId": "wallet" }, "at": "ISO timestamp" }]
}

Show apps with declared: false and keys: [] as “Not declared” and show their data folder. public is optional and contains only fields the app supplied. publicUnavailable: true means the command failed. An unsafe path can produce an error on the app or key row. Archive kinds are data and keys. Size is the sum of regular-file bytes, or null if it could not be read. archiveUnavailable: true means the archive could not be listed.

hub_keys returns the same app and archive information. hub_keys_backup { appId?, keyId? } and hub_keys_restore {} queue owner requests and return { requestId, message }. Requests disappear after completion, dismissal, expiry (24 hours) or daemon restart. DELETE /api/keys/requests/:id dismisses a request. The optional requestId in the following endpoints lets the page complete it. The owner can use the same actions directly from the page.

POST /api/keys/backup

Body { appId?, keyId?, passphrase, requestId? }. Omit both IDs to back up all declared keys that have files. Set appId for one app and both IDs for one key. A request ID uses the scope saved with that request. Passphrases require at least 10 characters and at most 1024 UTF-8 bytes.

Returns an OS download response with Content-Type: application/octet-stream and an attachment named agenthub-keys-<UTC YYYYMMDDThhmmssZ>.akb. The page can save the response as a Blob and use the attachment filename. The hub’s filesystem backup writer uses mode 0600. The browser manages permissions for its downloaded copy.

The UTF-8 file is a version-1 JSON envelope. kdf contains { name: "scrypt", N: 131072, r: 8, p: 1, salt }. cipher contains { name: "aes-256-gcm", nonce, tag }. Salt, nonce, tag and ciphertext use standard base64. The authenticated payload records the app IDs and versions, public info, relative paths, file and directory modes, and base64 file bytes. The encrypted file is limited to 10 MiB and each source file to 1 MiB.

POST /api/keys/restore/preview

Body { backup, passphrase, requestId? }, where backup is the UTF-8 text of the .akb file (for example, await file.text()). The upload limit for the file is 10 MiB. Invalid credentials or authentication return a generic error. On success the response is { previewId, expiresAt, keys }. Each key row contains { appId, keyId, label, version, backupVersion, current, imported, changed }. current and imported contain the available public fields. Imported fields were recorded when the backup was created.

AgentHub retains one preview in memory for five minutes. A new preview replaces it. A preview ID is consumed by confirmation and is valid only for the current app versions, declarations and key contents.

POST /api/keys/restore/confirm

Body { previewId, confirm: true }. Returns { ok: true, changed, archives: [{ appId, path }] }. Identical key contents return changed: false without restarting the app. Otherwise AgentHub stops affected running apps, saves previous key files in private data-archive/<id>-keys-<timestamp>/ directories, checks the candidates, replaces files and restarts apps that were running. If a step fails, the response describes whether recovery completed and can include the paths of the previous key archives in archives. AgentHub refuses a restore when another installed app shares the app's data folder. A stale preview must be uploaded and previewed again.

POST /api/keys/reveal

Body { appId, keyId, confirm: true }. Returns { value } from the app's declared reveal command. Display the value only in the confirmation flow. Keep it out of event payloads, page storage and logs.

Agent hand-off

  • POST /api/inbox { appId?, text } → { ok, id }: queued for the agent (hub_inbox). With no agent connected the page shows the request as one short line to paste into a new agent chat (Use AgentHub to install <id>, Use AgentHub: <text>).
  • GET /api/inbox returns unclaimed requests with id, at (queued at), appId (or null), text, and the delivery fields below. Add ?includeHistory=1 to include up to 100 recent seen, handled and removed records. These records omit request text (the hub keeps it in its local inbox file).
  • DELETE /api/inbox/:id → { ok: true } removes a pending request and records it as removed (removedAt). It marks a request an agent already claimed (seen) handled.
  • /api/state.inbox counts unclaimed requests. /api/state.inboxItems lists delivery metadata for unclaimed and recent seen or handled requests. State events carry the same fields. Match records by the ID returned by POST /api/inbox.
  • /api/state.agents[].canReceiveInboxPush is true when the session opted into the Claude Code channel protocol. The hub sends at most one notification for a new request, to the first connected session with that field set to true.
  • GET /api/prompt?action=install|update|uninstall&id= → { text } (id added), e.g. Install RESET with AgentHub.
  • GET /api/connect → [{ agent, command, note }] (added): the one-line connect command per agent for the Agents view. The hub owns these so they stay right as agents change their CLIs.
delivery Meaning Additional fields
queued Waiting for the agent to read the inbox
pushed The notification was written to a connected client pushedTo (client name), pushedAt (ISO timestamp)
seen An agent claimed the request with hub_inbox seenAt (ISO timestamp)
handled The agent acknowledged the request with hub_inbox { handledIds }, or the user removed it after the agent claimed it handledAt (ISO timestamp)
removed The user removed the request before any agent claimed it removedAt (ISO timestamp)

Later states keep earlier delivery fields when available. pushed records a transport write. Wait for seenAt to know that an agent read the request. Install and update status is tracked separately in /api/state.installs.

Money approvals

  • GET /api/approvals → [{ id, appId, tool, summary, amount: { value: "250", unit: "TNK" }, at }] (amount structured, at added)
  • POST /api/approvals/:id { approve: bool } → { ok, message }

Events — GET /api/events?token= (SSE)

event data
state the full /api/state body; sent on connect and on every change
activity one new activity entry
install the full /api/installs/:stagingId body on every step change
update {} — refetch /api/updates
keys {} — refetch /api/keys
loop { id } — refetch agent loop settings and history for that app
approval { id, done? } — refetch /api/approvals

The page reconnects with backoff (1 s → 15 s) and shows "Lost the hub. Reconnecting…" meanwhile.

Dev-only (mock)

POST /api/dev/stage/:libraryId creates an install staged up to "Your OK" at once (screenshots). Not part of the hub. POST /api/dev/weather-station { mode?, balance? } sets the fictional sensor state and balance for screenshots and the flow test. POST /api/dev/agents { connected, count?, drop? } disconnects every agent, or connects them again (only the first count); connected agents pick up the inbox. drop empties the inbox first (screenshots and the flow test). POST /api/dev/keys { action?, selection?, clear?, reset? } queues a Keys request like hub_keys_backup/hub_keys_restore (action: "backup"|"restore"), drops all requests (clear) or puts the fixture keys back (reset). The mock's .akb files are not encrypted; they only carry a passphrase hash so the page flows can run (page/dev/keys-mock.mjs).