Import
import {
assertRunEventSchemaValidator,
fromRunEventWireName,
getRunEventClass,
isRunEventType,
parseTypedRunEventRow,
toRunEventWireName,
} from "veryfront/run-events";
Examples
import { register, tryResolve } from "veryfront/extensions/contracts";
import { createZodAdapter } from "@veryfront/ext-schema-zod";
import {
isRunEventType,
parseTypedRunEventRow,
RUN_EVENT_PAYLOAD_SCHEMAS,
} from "veryfront/run-events";
// Register a validator only when nothing has: outside a Veryfront app this
// installs the Zod adapter, inside one it keeps the validator bootstrap owns.
if (!tryResolve("SchemaValidator")) {
register("SchemaValidator", createZodAdapter());
}
const apiUrl = "https://api.veryfront.example";
const runId = "<RUN_ID>";
const token = "<TOKEN>";
const response = await fetch(`${apiUrl}/runs/${runId}/events?format=typed`, {
headers: { Authorization: `Bearer ${token}` },
});
const body = await response.json() as { data: unknown[] };
for (const raw of body.data) {
const row = parseTypedRunEventRow(raw);
if (!isRunEventType(row.event_type)) {
// A type this build predates: the envelope is still valid, so keep the
// row and render its raw payload rather than dropping it.
console.log(row.event_type, row.span_id, row.payload);
continue;
}
// The sixteen control-plane `AGENT_RUN_*` types have no payload schema:
// the API owns their shape and sanitizes it before a reader ever sees
// it, so fall back to the already-validated raw payload for those.
const schema = RUN_EVENT_PAYLOAD_SCHEMAS[row.event_type];
const result = schema?.().safeParse(row.payload);
console.log(row.event_type, row.span_id, result?.success ? result.data : row.payload);
}
Exports
Components
| Name | Description | Source |
|---|---|---|
NATIVE_RUN_EVENT_TYPES | The stored types this runtime emits natively, for a consumer that needs to tell “Veryfront Code produced this” from “another producer did”. Derived from NATIVE_RUN_EVENTS so the producer list stays the one declaration. | source |
RUN_EVENT_CLASSES | How a reader must treat the event: a fact stands on its own, a delta only means something applied in order on top of the frames before it. | source |
RUN_EVENT_PAYLOAD_SCHEMAS | Every per-type payload schema, keyed by stored type, for a reader that validates a row whose type it only learns at runtime. Types without a declared payload shape (the sixteen control plane types) are absent, which is the signal to validate the envelope only. | source |
RUN_EVENT_SCHEMA_VALIDATOR_CONTRACT | The contract name every schema in this module resolves. | source |
RUN_EVENT_SCHEMA_VALIDATOR_PACKAGE | The package that provides it. | source |
RUN_EVENT_TYPES | Every catalogued run event type, in the API’s declaration order: the AG-UI core types (CUSTOM excluded, it has no typed projection), the Veryfront control plane types, and the twelve extension types that replaced the registered CUSTOM names, followed by UNKNOWN. | source |
Functions
| Name | Description | Source |
|---|---|---|
assertRunEventSchemaValidator | Throw a message a consumer can act on when no SchemaValidator is registered. Every getter in this module calls this before materializing, so the first failure explains the registration rather than surfacing the generic missing-extension throw from the contract registry. | source |
fromRunEventWireName | The stored type behind an SSE frame’s wire name, or null when the frame carries a name this vocabulary does not know. | source |
getRunEventClass | The event class the API reports for a catalogued type, or null for a type this vocabulary does not know. A null is not a fact: the API’s post-cutover rule leaves event_type open, so a newer API can serve a delta this build predates, and the row’s event_class envelope field is the authority for it. Read that field rather than defaulting. | source |
isRunEventType | Reports whether a stored event_type is one this vocabulary knows. | source |
parseTypedRunEventRow | Parse one typed run event row, throwing when it does not match the contract. | source |
toRunEventWireName | The wire name a catalogued type carries on an SSE frame. | source |
Types
| Name | Description | Source |
|---|---|---|
ConversationTypedRunEventRow | A typed run event row keyed by event, as the conversation surfaces serve it. | source |
RunEventClass | Fact or delta, as the API’s event_class envelope field reports it. | source |
RunEventEnvelope | The span envelope and row identity fields of a typed run event. | source |
RunEventType | One catalogued run event type. | source |
RunEventWireName | The AG-UI wire name of a catalogued run event type. | source |
TypedRunEventRow | A typed run event row keyed by payload. | source |
Constants
| Name | Description | Source |
|---|---|---|
getActivityDeltaPayloadSchema | Payload carrying an activity delta. Reserved: no producer emits it yet. | source |
getActivitySnapshotPayloadSchema | Payload carrying an activity snapshot. Reserved: no producer emits it yet. | source |
getChildRunStatusChangedPayloadSchema | Payload of an invoke_agent child run’s lifecycle transition. | source |
getConversationTypedRunEventRowSchema | The same row as the conversation-scoped surfaces serve it, where the payload key is event rather than payload. GraphQL agentRunEvents, the MCP get_agent_run_events tool, and GET /conversations/{conversation_id}/runs/{run_id}/events all use this spelling; the run-scoped route and the SSE frames use payload. | source |
getDocumentCitedPayloadSchema | Payload of a document citation attached to assistant output. | source |
getFileAttachedPayloadSchema | Payload of a file reference the run emitted. | source |
getFilesChangedPayloadSchema | Payload of a file change set a runtime proposed or applied. | source |
getInputRequestCreatedPayloadSchema | Payload of a form or approval input request opened for the run. | source |
getInputRequestUpdatedPayloadSchema | Payload of an open input request that changed. | source |
getMessagesSnapshotPayloadSchema | Payload carrying the authoritative message list for a stream’s start. | source |
getReasoningContentPayloadSchema | Payload carrying one reasoning content delta. | source |
getReasoningEndPayloadSchema | Payload that closes a reasoning block. | source |
getReasoningMessageContentPayloadSchema | Payload carrying one reasoning delta. | source |
getReasoningMessageEndPayloadSchema | Payload that closes a reasoning message. | source |
getReasoningMessageStartPayloadSchema | Payload that opens a reasoning message. | source |
getReasoningStartPayloadSchema | Payload that opens a reasoning block. | source |
getRunErrorPayloadSchema | Payload of a run that failed. | source |
getRunEventEnvelopeSchema | The span envelope plus the row’s own identity fields. | source |
getRunFinishedPayloadSchema | Payload of a run that finished, carrying provider and usage metadata. | source |
getRunLogCapturedPayloadSchema | Payload carrying captured runtime execution logs. | source |
getRunParkedPayloadSchema | Payload of a run parked waiting for integration authentication. Live only. | source |
getRunStartedPayloadSchema | Payload of a run that started. | source |
getRuntimeEventRecordedPayloadSchema | Payload of a runtime-native event with no AG-UI equivalent, recorded for diagnostics. value is unconstrained JSON: this is the catch-all the runtime context snapshot and the codex thread and session events use. | source |
getStateDeltaPayloadSchema | Payload carrying a state change. The delta stays unknown: the public profile accepts both a legacy object delta and a JSON Patch operation array. | source |
getStateSnapshotPayloadSchema | Payload carrying the whole client state. | source |
getStepFinishedPayloadSchema | Payload that closes a step, or a runtime turn when runtime is set. | source |
getStepStartedPayloadSchema | Payload that opens a step, or a runtime turn when runtime is set. | source |
getStreamHeartbeatEmittedPayloadSchema | Payload of a live stream heartbeat. Never persisted. | source |
getTextMessageContentPayloadSchema | Payload carrying one text delta. Apply deltas in event id order. | source |
getTextMessageEndPayloadSchema | Payload that closes an assistant message. | source |
getTextMessageStartPayloadSchema | Payload that opens an assistant message. contentId is required: the API’s public normalization rejects a row without one rather than degrading it. | source |
getToolCallArgsPayloadSchema | Payload carrying one tool argument delta. | source |
getToolCallChunkPayloadSchema | Payload carrying one streamed tool chunk. | source |
getToolCallEndPayloadSchema | Payload that closes a tool call’s argument stream. | source |
getToolCallResultPayloadSchema | Payload of a tool result. isError is null when no producer evidence exists; the API never defaults it to false. | source |
getToolCallStartPayloadSchema | Payload that opens a tool call. parentMessageId names the assistant turn. | source |
getToolCallStatusChangedPayloadSchema | Payload of a tool call status transition (pending_input, streaming_input, in_progress, completed, failed). toolCallName is null when the runtime reported a status before naming the call. | source |
getTypedRunEventRowSchema | A typed run event row as GET /runs/{run_id}/events?format=typed and the typed SSE frames serve it. | source |
getUnknownRunEventPayloadSchema | Payload of a row whose stored type or CUSTOM name has no typed projection. originalType and raw carry what the row actually held. | source |
getUrlCitedPayloadSchema | Payload of a URL citation attached to assistant output. | source |