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.

Installation

Import the Capability factory from -hub/agent/capabilities and add it to defineAgent({ capabilities }). Use the configuration example below as the starting point, then tighten modes, policies, stores, and providers for the Agent boundary.

What it adds

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.

Configuration

Define lowercase stable command names and a description for each command. 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.',
          run: ({ args }) => `Use documentation context for: ${args}`,
        },
      },
    }),
  ],
})

Runtime behavior

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.

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.
Harness-backedReceives the transformed Agent Run Input before harness execution.
Custom-run-backedReceives the transformed Agent Run Input; driver.run decides how to use context values.

Inspect and verify

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 DevTools metadata for the inputCommands Capability and its command descriptions.

Options

OptionTypeDefaultDescription
commandsRecord<string, InputCommand>requiredCommand map keyed by lowercase stable command names.
idstring"input-commands"Capability id.
triggerstring"/"Non-whitespace command prefix.
commands.*.descriptionstringrequiredCommand description for metadata and inspection.
commands.*.run(input) => AgentRunInput | Response | string | voidrequiredHandler that accepts, rejects, transforms, or enriches invocation input.

Reference

Copyright © 2026