ViteHub is still experimental. Expect bugs and breaking changes.

Input commands

Transform explicit user commands before the main Agent Invocation runs.

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 /.

server/agents/support.ts
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 DriverSupport
Model-backedReceives the transformed prompt, messages, or context before model execution.
Provider-backedReceives the transformed Agent Run Input before provider execution.
Custom-run-backedReceives 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

OptionTypeDefaultDescription
commandsRecord<string, InputCommand>requiredCommand map keyed by lowercase stable command names.
idstring"inputCommands"Capability id.
triggerstring"/"Non-whitespace command prefix.
commands.*.descriptionstringnoneOptional command description for metadata and inspection.
commands.*.call(input) => AgentRunInput | Response | string | voidremove command textHandler that accepts, rejects, transforms, or enriches invocation input.
commands.*.channelsstring[]all channelsOptional configured Channel ID allowlist.
commands.*.hooks{ 'agent:input'?, 'agent:finish'? }noneCommand-scoped lifecycle hooks with ctx.message.reply/update/react delivery primitives.