Skip to content

Veya Runtime Protocol 0.1 ​

Every participant in Veya speaks this protocol: an instrumented app reports through it, the hub stores and joins it, the MCP tools project it, and the agent reads it. The zod definitions in packages/protocol/src/ are the source of truth; this document is checked against them in packages/protocol/src/docs.test.ts.

Envelope ​

Every event is one envelope.

FieldTypeMeaning
idstringEvent identity, unique inside a session.
seqintegerMonotonic order inside a session, starting at 0.
sessionIdstringThe session the event belongs to.
traceIdstringThe user action this event descends from.
spanIdstringThe work unit that emitted the event.
parentSpanIdstring?The span that caused this one.
tintegerEpoch milliseconds.
sourceruntime | browser | hubWhich channel observed it.
typeevent typeOne of the types below.
payloadJSON objectType specific fields.

A trace is every envelope sharing a traceId, ordered by seq. That is the causal chain an agent reads when it asks why the product did something.

Sessions ​

A session is one instrumented page.

FieldMeaning
idSession identity.
urlPage URL at hello.
routePage route at hello.
titlePage title, when known.
modehuman, agent or managed.
channelRuntime and CDP status.
viewportPage viewport at hello.
startedAtEpoch milliseconds.

The desktop app opens a human product window and an agent product window with its own persistent profile. The preload reports the window kind; the runtime writes it into session.mode.

A page load creates a session. A newer session for the same url and mode replaces the previous one: the hub marks the old session replacedBy and emits session.replaced into the new one. Human and agent sessions for the same URL coexist and do not replace each other.

Event types ​

TypeSourcePayload
session.helloruntimeroute, viewport, framework, channel
session.replacedhubreason, previousSessionId
interaction.startedruntimekind (click, input, submit, key), target, label
interaction.completedruntimedurationMs, outcome (ok, blocked)
state.changedruntimeid, path, previous, current
network.request.startedruntime | browserrequestId, method, url, resourceType
network.request.completedruntime | browserrequestId, status, durationMs, size
network.request.failedruntime | browserrequestId, message, durationMs
component.mountedruntimecomponentId, type, source
component.unmountedruntimecomponentId
error.uncaughtruntime | browsermessage, stack, componentId
error.consoleruntime | browserlevel, message
navigation.committedbrowserfrom, to
human.feedbackruntimetarget, note, artifactId
signal.raisedhubsignalId, rule, severity
cdp.detachedhubreason

Components ​

A component node is what the app says about itself, not what the DOM looks like.

FieldMeaning
idSemantic identity, from <AgentComponent id>.
typeComponent name, from the compiled marker or the React boundary.
purposeWhy the component exists, from <AgentComponent purpose>.
roleprimary-action, navigation, content, status or form.
status, visible, disabled, loadingRuntime state at capture time.
dataStatusidle, loading, ready or error.
source{ file, line, column? } from the build, or null when unknown.
childrenNested components, in render order.

source: null is a fact, not a gap to fill in. Rule R008 reports components the build never annotated.

Snapshot ​

inspect returns a snapshot: protocol version, session, capture time, URL and route, viewport, the component tree, the business state keyed by state id, diagnostics, and the channel status ({ runtime, cdp }).

Diagnostics carry the errors seen, a console error count, failed and slow requests, the pending request count, and the web performance entries the runtime measured.

Context document ​

veya_context returns a ContextDocument, a projection over the session's snapshot history and event stream. It is not an event and adds no event types.

A baseline (baseline: true) is returned without since; a diff (baseline: false) is returned with a cursor from a previous response. Both carry signals as current failing findings, not a delta.

FieldBaselineDiffMeaning
cursoryesyesCursor for the next call.
generatedAtyesyesCompilation time.
baselineReasonoptionalnocursor_unavailable when the supplied cursor was not found.
sincenoyesThe cursor passed by the caller.
budgetyesyesmaxBytes, exact UTF-8 usedBytes and truncated.
pageyesyesSnapshot time, URL, route, title, mode, viewport, channel and last probe viewport.
signalsyesyesCurrent failing signals with evidence.
componentsyesnoFlat pre-order component outlines with parentId and source.
stateyesnoBusiness state packed by top-level state id.
diagnosticsyesnoCounters, failed and slow requests, errors and performance.
eventsyesnoRecent event summaries.
changes.componentsnoyesadded, removed and changed.
changes.statenoyespath, previous and current.
changes.eventsnoyesEvent summaries after since.
omittedyesyesOmitted candidate counts by section.
nextyesyesTool calls that return the omitted material.

A cursor is opaque and session-scoped. It points at a snapshot in a bounded history, 32 points by default. An unknown, expired or other-session cursor returns a baseline with baselineReason: "cursor_unavailable"; it is not an error.

The budget is UTF-8 bytes of compact JSON. usedBytes is exact, truncated says whether anything was left out, and the brief is packed by priority: failing signals, problem components, state, diagnostics, navigation components, recent events and the remaining components.

components omits bounds, props and children; source: null is preserved as a fact. events are summaries with seq, t, type, traceId and summary, not event payloads. The brief never probes: layout signals reuse the last probe, and page.probe reports its viewport when one exists.

The document is additive in protocol 0.1. No event type and no PROTOCOL_VERSION changed.

Signals ​

A signal is a deterministic finding with evidence. status is pass or fail; severity is critical, high, medium or low; evidence points at the trace, component, source file, request or artefact that proves it.

RuleTitleSeverity
R001Uncaught errorcritical
R002Console errormedium
R003Failed requesthigh
R004Stuck loadinghigh
R005Horizontal overflowmedium
R006Interactive control without a namemedium
R007Low text contrastlow
R008Component without source mappinglow

Commands ​

A command is one of navigate, click, resize, screenshot or perform, optionally with target, value, steps and timeoutMs.

perform runs an ordered step list. A step is either { "kind": "click", "target" } or { "kind": "expect", "expect": { "events", "state" } }. The list starts with a click, contains at least one expect and holds at most 12 steps. An expect step waits for event types in the most recent click's trace and for current dotted state paths to match. The first unmet expectation stops the list.

A command result reports ok, the action, the traceId the last click produced, the events observed while verifying, the state changes among them, per-step outcomes, any evidence artefacts, and an error with a stable code and the failing stepIndex. perform answers ok: true only when every expectation held; a click that lands is not a product behaviour that works. timeoutMs is the wait budget for each expect step, not the whole list.

Compatibility ​

PROTOCOL_VERSION is 0.1. The hub accepts a session whose protocol major matches and records a mismatch in the session channel instead of dropping evidence.

Released under the Apache-2.0 License.