Input commands
inputCommands() adds command parsing for explicit user input before the main Agent Invocation runs.
Use it for commands that transform or enrich the user's prompt, not for host UI state or shell execution.
The Capability scans the latest prompt or user message for configured Input Commands. Each command can replace text, update the Agent Run Input, or add invocation context before model execution. Commands that produce model-facing text must return it. Accepting a command without handler text removes the matched text.
Configure input commands
Define lowercase command names. Add a description to include the command's purpose in CLI and inspection output.
The default trigger is /.
import { defineAgent } from 'vite-hub/agent'
import { inputCommands } from 'vite-hub/agent/capabilities'
export default defineAgent({
driver: { model },
capabilities: [
inputCommands({
commands: {
docs: {
description: 'Add documentation context to the request.',
call: ({ args }) => `Use documentation context for: ${args}`,
},
},
}),
],
})
How input commands work
inputCommands() runs during the input phase.
It finds command invocations in the latest user text, calls the matching command handler, and updates the Agent Run Input before other model-facing behavior consumes it.
Commands without a handler are accepted and removed from model input; they do not implicitly pass arguments or command names through as prompts.
Command agent:input hooks run after the command updates the input and before the Agent Driver runs.
Command agent:finish hooks run for completed and failed Agent Invocations.
The Capability records command names and descriptions in metadata. It stops command expansion when no configured command remains.
Requirements
Command names must be lowercase stable identifiers. The trigger must be a non-empty string without whitespace.
Input Commands are Capability concerns. Host Commands that change chat, session, UI, or product state belong outside this Capability.
Driver support
| Agent Driver | Support |
|---|---|
| Model-backed | Receives the transformed prompt, messages, or context before model execution. |
| Provider-backed | Receives the transformed Agent Run Input before provider execution. |
| Custom-run-backed | Receives the transformed Agent Run Input; driver.run decides how to use context values. |
Verify input commands
Run an invocation with the configured command text. Inspect the final Agent Run Input and confirm the command text was replaced or the expected context value was added before the Agent Driver ran.
Check Agent inspection metadata for the inputCommands Capability and its command descriptions.
Options
| Option | Type | Default | Description |
|---|---|---|---|
commands | Record<string, InputCommand> | required | Command map keyed by lowercase stable command names. |
id | string | "inputCommands" | Capability id. |
trigger | string | "/" | Non-whitespace command prefix. |
commands.*.description | string | none | Optional command description for metadata and inspection. |
commands.*.call | (input) => AgentRunInput | Response | string | void | remove command text | Handler that accepts, rejects, transforms, or enriches invocation input. |
commands.*.channels | string[] | all channels | Optional configured Channel ID allowlist. |
commands.*.hooks | { 'agent:input'?, 'agent:finish'? } | none | Command-scoped lifecycle hooks with ctx.message.reply/update/react delivery primitives. |