ViteHub is still experimental. Expect bugs and breaking changes.

Errors and diagnostics

Reference ViteHub error codes and the local proof path for each primitive.

Errors and diagnostics belong to the package that owns the failing boundary. ViteHub exposes one operational error class, ViteHubError from @vite-hub/runtime; use its namespaced code to choose the next proof path.

ViteHubError snapshots its public name, code, message, details, and requestId fields at construction. The snapshot and its details are frozen, cause remains private, and later mutation cannot change toJSON(). Details must be bounded JSON data without accessors, cycles, bigint, non-finite numbers, or class instances; invalid public contracts fail with a fixed TypeError instead of serializing the rejected value.

Code families

Code prefixOwnerUsually means
CAPABILITY_*Runtime PackageCapability lookup or policy failed.
ENV_*Env PackageEnv Declaration or runtime resolution failed.
BLOB_*Blob PackageBlob lookup or Provider-backed storage failed.
KV_*KV PackageProvider-backed key-value storage failed.
AUTH_* and AUTHENTICATION_*Auth PackageAuthentication is required or a provider operation failed. HTTP adapters map AUTHENTICATION_REQUIRED to 401.
EMAIL_*Email PackageMessage validation, configuration, credentials, throttling, network, timeout, or delivery failed.
QUEUE_*, CLOUDFLARE_*, and VERCEL_*Queue PackageQueue dispatch, callback, or Provider handling failed. Queue Delivery owns retry and acknowledgement decisions.
WORKSPACE_*Workspace PackageWorkspace lookup, path, runtime, store, rule, or file-tree behavior failed.
SOURCE_*Source PackageSource lookup, path validation, retrieval, or loader behavior failed.
SCHEDULE_*Schedule PackageStatic or runtime Schedule behavior failed.
SANDBOX_*Sandbox PackageSandbox Provider setup, execution, or output recovery failed.
WORKFLOW_* and OPENWORKFLOW_*Workflow PackageWorkflow run, step, or Provider behavior failed.
Rate Limit policy or driver errorRate Limit PackageA policy is invalid, the selected driver cannot satisfy its guarantees, a Definition is unknown, or a provider binding is unavailable.
RATE_LIMIT_REJECTEDAgent PackageRate Limit Capability rejected an Agent Invocation.
LLM_GATE_REJECTEDAgent PackageLLM Gate Capability rejected before the main Agent Invocation.
Agent Invocation Stream timed out after <ms>.Agent PackageThe dev-loop stream aborted a long or stalled Agent Invocation after its timeout.

Agent public errors

Agent routes and hooks expose a sanitized AgentPublicError beside the original server error. It is safe to serialize to a caller or use in an application-owned reply:

interface AgentPublicError {
  code: AgentPublicErrorCode
  error: string
  details?: {
    capability?: string
    category?: string
    retryAfter?: number
  }
  requestId?: string
}

agent:error hooks receive the raw failure as error and the sanitized value as publicError. Chat error hooks receive the same pair. Keep the raw error in protected diagnostics; provider payloads and causes can contain credentials or private response data.

Public codeMeaning
PROVIDER_AUTHENTICATION_FAILEDThe model provider rejected its credentials.
PROVIDER_QUOTA_EXHAUSTEDThe account or project has no remaining provider quota.
PROVIDER_RATE_LIMITEDThe provider returned a temporary rate limit.
PROVIDER_UNAVAILABLEThe provider returned a server or availability failure.
APPROVAL_REQUIREDA Capability needs approval before it can continue. requestId identifies the approval request when available.
AUTHENTICATION_REQUIRED, RATE_LIMIT_*, LLM_GATE_REJECTED, CAPABILITY_*, TRANSCRIPTION_*ViteHub recognized a public application or Capability failure.
INTERNALThe failure has no approved public mapping. The message stays generic.

The mapper includes only bounded identifiers, categories, retry delays, and request IDs. It replaces unknown errors with a context-specific INTERNAL message instead of copying error.message.

Diagnostics sources

SourceUse
CLI exit code and stderrCommand parsing, provisioning, and Agent Eval failures.
Env diagnosticsMissing, defaulted, valid, and masked Env Declaration status.
Generated filesDiscovery, Runtime Registry, and Provider Output inspection.
Agent Dev Loop responsesLocal Agent inspection and invocation failures.
Trace EventsRuntime policy, approval, capability, lifecycle, and error records.
Package testsContract failures owned by the primitive package.

Local response

Start with getViteHubErrorShape(error)?.code, then inspect the owning package and failing proof path. For packages that generate Provider Output, inspect that output before changing runtime code. Authenticated Agent bridges distinguish AUTHENTICATION_REQUIRED from AUTH_PROVIDER_OPERATION_FAILED; use details.operation for safe diagnostics and cause only in protected server-side diagnostics. Email emits no Provider Output; inspect the EMAIL_* code and details.driver.

For Env, inspect the ENV_* code first. Its code set and public messages are fixed. ENV_DECLARATION_INVALID can include details.path, ENV_REQUIRED_MISSING can include a bounded source identifier and declaration path, and ENV_RUNTIME_VALUE_INVALID and ENV_SOURCE_FAILED can include a bounded source identifier such as env, git:branch, package.json, or custom. Raw labels and diagnostics remain in cause, which the serialized shape omits. Custom source resolvers keep application-owned errors unchanged.

Terminal
pnpm vitehub provision run --provider cloudflare --dry-run
find .vitehub -maxdepth 4 -type f | sort
pnpm --filter @vite-hub/sandbox test

Rate Limit diagnostics

SymptomLikely causeVerify
Conflicting Rate Limit policyMultiple requireRateLimit() calls use the same stable ID with different static policies.Follow both reported source locations and make the policies identical or rename one ID.
Driver provides best-effort enforcementA policy requires strict, but the selected provider cannot guarantee it.Keep strict enforcement and choose another driver, or change the policy only when best-effort protection is acceptable.
Driver does not support the windowThe provider accepts fewer fixed-window periods than the portable policy type.Use a supported period or select a driver that advertises the required window.
Production hosting requires an explicit providerThe build target is unknown or has no native inferred Rate Limit provider.Set provider: 'cloudflare' with a project-unique namespace for Cloudflare, set provider: 'memory' only for a deliberate single-process deployment, or construct a custom Rate Limiter.
Cloudflare binding was not foundGenerated ratelimits output is missing from the running Worker or request context.Inspect wrangler.json, then exercise the deployed Worker rather than an unrelated Node process.
reason: 'unavailable' with allowed: trueA failure: 'allow' policy allowed work after a driver error.Record the unavailable decision and inspect provider health before changing the budget.

Production response

Keep secrets out of production diagnostics. Use Server Env and Secret Env for runtime secret values, and rely on package diagnostics to redact known secret values where supported.