/** * Slash commands — unified command handling for CLI, HTTP API, and IM Gateway. * * Commands are parsed and executed here; the caller is responsible for rendering * the CommandResult in the appropriate format (terminal, SSE, IM reply, etc.). */ import type { Scheduler } from './scheduler.js'; import type { TaskStore } from './task-store.js'; import { type GolemConfig, type SkillInfo } from './workspace.js'; export interface CommandResult { /** Human-readable text output (may contain markdown). */ text: string; /** Structured data for JSON consumers (HTTP API --json). */ data?: Record; } /** Runtime context provided by the caller (gateway / server / CLI). */ export interface CommandContext { /** Assistant working directory. */ dir: string; /** Read current runtime config + skills. */ getStatus: () => Promise<{ config: GolemConfig; skills: SkillInfo[]; engine: string; model: string | undefined; }>; /** Switch engine at runtime (takes effect on next chat). When clearModel is true, also resets the model. */ setEngine: (engine: string, clearModel?: boolean) => void; /** Switch model at runtime (takes effect on next chat). */ setModel: (model: string) => void; /** Reset the session for the given key. */ resetSession: (sessionKey?: string) => Promise; /** Cancel the currently running invocation for the given key. */ cancelSession: (sessionKey?: string) => Promise; /** List available models for the current engine. */ listModels: () => Promise; /** Current session key (for reset). */ sessionKey?: string; /** Task store for /cron commands (only available in gateway mode). */ taskStore?: TaskStore; /** Scheduler for /cron commands (only available in gateway mode). */ scheduler?: Scheduler; /** Run a scheduled task immediately. */ runTask?: (taskId: string) => Promise; } interface ParsedCommand { /** * The slash-prefixed command token exactly as typed by the user (e.g. * '/ReviewAPI'), case preserved. Built-in recognition/execution normalize * this to lowercase at their own boundaries (isKnownCommand, * executeCommand); callers dispatching to a case-sensitive native command * lookup (e.g. OpenCode) should use this value as-is. */ name: string; args: string[]; /** * Raw text after the command token, with the delimiter whitespace and * outer whitespace removed. Unlike `args`, this preserves internal * spacing/newlines so native engine commands (e.g. OpenCode's `review`) * receive arguments verbatim instead of a whitespace-collapsed * `args.join(' ')`. */ argumentsText: string; } /** * Parse a user message into a command. Returns null if the message is not a * slash command (i.e. should be forwarded to the agent). */ export declare function parseCommand(text: string): ParsedCommand | null; /** * True when `name` matches a recognized Golem built-in slash command (e.g. * '/help', '/status'), case-insensitively. Lets callers decide whether to * show upfront feedback (e.g. a typing indicator) before calling * executeCommand(), without duplicating the built-in command list or * executing it twice. */ export declare function isKnownCommand(name: string): boolean; /** * Execute a parsed slash command. Returns a CommandResult with text output * and optional structured data. * * Built-in command names are matched case-insensitively (e.g. '/HELP' and * '/help' both execute cmdHelp()); `cmd.name`'s original case is otherwise * preserved on the ParsedCommand for callers that need exact-case dispatch * (e.g. native engine command lookup). * * Returns null if the command is not recognized (caller should forward to agent). */ export declare function executeCommand(cmd: ParsedCommand, ctx: CommandContext): Promise; export {}; //# sourceMappingURL=commands.d.ts.map