BankGPTDocs

Engine API

Every HTTP route and the WebSocket control channel the engine exposes on port 4011.

The engine exposes a Hono HTTP API plus a WebSocket control channel on one listener (default port 4011). Every request body is validated with zod, every JSON response passes through policy redaction, and capabilities / runs / interventions persist in SQLite. The frontend never calls these routes from the browser over HTTP — a server-only typed client sits behind auth-gated /api/engine/* proxies — but the API is documented here for operators and for the CLI.

Health & policy

MethodPathDescription
GET/healthLiveness probe; returns engine status.
GET/policyThe active safety policy (allowlist, action sets, limits).

Capabilities

MethodPathDescription
GET/capabilitiesList every stored capability version, newest first.
GET/capabilities/:idFetch one capability row (latest version) with its full artifact.
POST/capabilitiesImport a validated artifact (zod-checked against the schema).
POST/capabilities/:id/reviewMark an artifact reviewed: true and bump its version.

Runs

MethodPathDescription
POST/discoverStart a discovery run. Body: { goal, targetUrl, model? }. Returns 202 with the runId; follow progress on /ws or poll /runs/:id.
POST/replayStart a replay run. Body: { capabilityId, inputs?, approvalToken?, requestedBy? }. Risky capabilities require a valid approval token.
GET/runsList all runs (discovery and replay).
GET/runs/:idFetch one run row with its structured result.
GET/runs/:id/evidenceThe run's step log (steps.jsonl parsed to JSON).
GET/runs/:id/filesList the run's evidence files.
GET/runs/:id/files/:nameDownload one evidence file (transcript, result, screenshot, snapshot, control log).

Approvals & interventions

MethodPathDescription
GET/approvalsList interventions (approvals and stuck runs).
POST/approvalsRequest an approval. Body: { capabilityId, inputs?, requestedBy, reason? }. Returns the intervention and an approval token.
GET/approvals/:idFetch one intervention.
POST/approvals/:id/approveApprove. Body: { decidedBy, reason? }. Auto-starts the run on the pinned artifact.
POST/approvals/:id/rejectReject. Body: { decidedBy, reason? }.

Live sessions

MethodPathDescription
GET/sessions/:runId/stateCurrent ownership state (owner, paused, epoch).
GET/sessions/:runIdAlias for state.
POST/sessions/:runId/actionDrive the session during a take-over (click/type/navigate per the action body).
POST/sessions/:runIdAlias for the action endpoint.

WebSocket control channel (/ws)

The browser connects directly to the engine's /ws channel (Next.js route handlers cannot proxy WebSocket upgrades). The channel is a localhost trust boundary: it carries control messages and step events, not auth — operator identity flows through the authenticated HTTP proxy.

Server → client events:

typePayloadWhen
helloservice, sessionsOn connect.
run-steprunId, stepIndex, action, intent, okAfter each discovery/replay step.
run-finishedrunId, resultWhen a run completes.
control-staterunId, owner, paused, appliedAfter a pause/cede/resume.
session-opened / session-closedrunIdLive session lifecycle.
intervention-requested / intervention-resolvedinterventionId, runId, status, decidedByApproval/stuck lifecycle.
capability-savedcapability id/versionDiscovery distilled an artifact.
human-actionrunId, detailA human acted during a take-over.

Client → server commands (validated at the boundary; malformed frames are dropped, never coerced):

typeFieldsEffect
pauserunIdAutomation stops issuing actions.
cederunId, operator?Control passes to the human.
resumerunId, operator?, detail?Control returns to automation; resolves pending stuck interventions for the run.
human-actionrunId, detailRecord a human action into the run evidence.

On this page