ViteHub is still experimental. Expect bugs and breaking changes.

Capabilities API

Understand how Agents attach controlled model-facing abilities without raw top-level tools.

A Capability is a shareable ViteHub bundle that adds a named Agent ability. Capabilities attach through defineAgent({ capabilities }) and can contribute tools, instructions, requirements, trigger behavior, policy, metadata, and invocation context values.

Tools belong to Capability Definitions. They are not top-level Agent Definition fields.

Why it exists

Raw tools make validation, policy, DevTools metadata, and driver support hard to inspect. A Capability keeps the ability, requirements, model-facing instructions, and runtime behavior together.

Capabilities also keep primitive access explicit. Installing KV does not let every Agent read KV; attaching kv() decides whether a model receives KV read or edit tools.

Official capability imports

Official Capability factories live on @vite-hub/agent/capabilities.

server/agents/support.ts
import { gateway } from '@ai-sdk/gateway'
import { defineAgent } from '@vite-hub/agent'
import { kv, workspaceShell } from '@vite-hub/agent/capabilities'

export default defineAgent({
  driver: {
    instructions: [
      'Answer from the workspace before using storage.',
      '{{ capabilities }}',
    ].join('\n\n'),
    model: gateway('openai/gpt-5.1-mini'),
  },
  workspace: {
    sources: {},
  },
  capabilities: [
    workspaceShell({ mode: 'read' }),
    kv({ mode: 'read' }),
  ],
})

The Agent Package root stays focused on Agent Definition, invocation, message, and composition primitives. Capability factories stay on the capability subpath so model-facing abilities remain visible.

What a Capability can contribute

ContributionPurpose
RequirementsPrimitive, Workspace mode, path, store, or policy requirements checked early.
InstructionsCapability-owned model-facing guidance, usually placed through instruction slots.
ToolsModel-facing operations such as read, edit, query, execute, search, or transcribe.
Trigger behaviorProduct events that start Agent Invocations.
PolicyApproval and safety decisions for model-facing actions.
Invocation context valuesTyped data that later Agent and Capability callbacks can read.
MetadataInspectable configuration for runtime and DevTools surfaces.

Static attachment

Capabilities are attached before the Agent Invocation runs. Pre-Invocation Decisions can record context values, reject, or influence conditional contributions, but they do not dynamically attach new Capabilities.

Next steps

Copyright © 2026