ViteHub is still experimental. Expect bugs and breaking changes.

Runtime events

Reference runtime event, policy, approval, stream, and usage records across ViteHub packages.

Runtime events describe what happened across package boundaries. The Runtime Package owns Trace Events, Policy Decisions, Approval Requests, runtime capability handles, and wait-until behavior.

Trace Event

TraceEvent is the shared observability event shape. It can describe policy, approval, capability, error, lifecycle, or run activity.

@vite-hub/runtime
interface TraceEvent {
  attributes?: Record<string, unknown>
  name: string
  timestamp?: Date | string
  trace?: {
    id: string
    parentId?: string
    sampled?: boolean
  }
  type: 'approval' | 'capability' | 'error' | 'lifecycle' | 'policy' | 'run'
}

Runtime lifecycle hooks

Runtime lifecycle hooks are host-provided callbacks for observing shared runtime behavior. They do not replace package-owned hooks such as Agent Finish Hooks.

HookPayload
requestRuntime Host Context before work starts.
approvalApproval Request and runtime context.
traceTrace Event and runtime context.
errorError and runtime context.
finishRuntime Host Context after work finishes.

Policy and approvals

Policy Decisions are runtime outcomes, not generic booleans. An Approval Request is created only when policy requires external approval.

ValueMeaning
allowContinue the operation.
denyStop the operation.
require-approvalStop until an Approval Decision permits execution.
retryable-failureTreat the operation as failed but retryable.

Agent stream events

Agent stream output is package-owned Agent behavior. The current event stream includes text deltas, data parts, tool input and result events, approval events, errors, finish events, and usage events.

Event familyUse
text-deltaStream assistant text.
tool-call and tool-resultRepresent model-facing tool execution.
approval-request and approval-decisionRepresent approval-shaped tool policy.
errorRepresent recoverable or terminal stream errors.
finishMark completion.
usageCarry an Agent Usage Record when telemetry is attached.

Agent Usage Record

Agent Usage Records normalize usage across model-backed, harness-backed, and custom-run-backed Agent Drivers when usage exists. Token fields appear only when the provider reports them or ViteHub can derive them safely.

Copyright © 2026