Capabilities API
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.
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
| Contribution | Purpose |
|---|---|
| Requirements | Primitive, Workspace mode, path, store, or policy requirements checked early. |
| Instructions | Capability-owned model-facing guidance, usually placed through instruction slots. |
| Tools | Model-facing operations such as read, edit, query, execute, search, or transcribe. |
| Trigger behavior | Product events that start Agent Invocations. |
| Policy | Approval and safety decisions for model-facing actions. |
| Invocation context values | Typed data that later Agent and Capability callbacks can read. |
| Metadata | Inspectable 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
- Read the Capabilities section.
- Read Runtime policy, approvals, and traces.
- Read First agent for a minimal Agent Definition.