ViteHub is still experimental. Expect bugs and breaking changes.

Auth Users and Agent Invokers

Understand how application identity becomes trusted invocation identity.

An Auth User is the person signed in to your application. An Agent Invoker is the trusted caller of one Agent Invocation. Agent and Capability code read that caller from context.invoker.

Auth answers "who is signed in?" An Agent Invoker answers "who or what started this invocation?"

Choose the identity you need

Auth UserAgent Invoker
ScopeThe application sessionOne Agent Invocation
SourceAn auth providerA trusted entry point or Auth bridge
Used byRoutes and application authorizationAgent and Capability code
RequiredOnly where the application requires authEvery invocation, including anonymous calls

Auth can provide the invoker

An Agent can also start from a Channel, schedule, webhook, service account, CLI command, or local development. Those entry points don't need an Auth User, but they still provide an Agent Invoker.

server/agents/support.ts
import { defineAgent } from 'vite-hub/agent'
import { authenticated } from 'vite-hub/auth/agent'

export default defineAgent({
  invoker: authenticated(),
  driver: {
    run: ({ invoker }) => ({ invoker }),
  },
})

authenticated() maps the signed-in user to the Agent Invoker. Configuring Auth alone does not require a user session for every Agent.

The invoker carries trusted caller data

FieldMeaning
idStable caller ID for the invocation.
kindCaller type such as authUser, chat, or anonymous.
labelOptional label for inspection.
metaStructured application data used by Capabilities and callbacks.

Don't put secrets or raw session payloads in meta.

Read Auth for session setup and Access for decisions based on invoker identity.