Capabilities
A Capability gives an Agent a selected ability. It can add tools, instructions, requirements, policy, triggers, metadata, or invocation context.
Installing a Server Primitive does not give an Agent access to it. Attach a Capability when the Agent needs that operation.
Choose the API by its caller
| Server Primitive | Capability | |
|---|---|---|
| Caller | Application server code | An Agent during an Invocation |
| Access | A documented server import | Selected tools, policy, requirements, or context |
| Selection | Application code calls it | The Agent Definition or invocation selects it |
| Model access | None | Only the operations the Capability contributes |
Select the abilities an Agent can use
import { defineAgent } from 'vite-hub/agent'
import { kv, workspaceShell } from 'vite-hub/agent/capabilities'
export default defineAgent({
workspace: { mode: 'read' },
capabilities: [
workspaceShell({ mode: 'read' }),
kv({ mode: 'read' }),
],
driver: {
run: ({ input }) => input,
},
})
The Agent receives only what the selected Capabilities contribute. Application code can call the same Server Primitives through their server APIs.
Use a fixed or resolved list
Use an array when every invocation needs the same abilities. Use a resolver when trusted invocation data changes the list:
capabilities: ({ actor }) => [
customerRecords,
...(actor.meta?.support === true ? [internalDiagnostics] : []),
],
ViteHub resolves the Agent Invoker before it calls the resolver. The returned array is the complete Capability list for that request.
Limit what the Agent can use
A Capability does not expose the full Runtime Context or unrestricted host access. Its tools, requirements, policy, and metadata define what the Agent can inspect and use.
Read the Capabilities section for implementation details and First agent for a runnable Definition.