Skip to main content

slashCommand

function

Declare a command the user types inside a chat session. The `id` is the name typed after the slash, `description` is the line shown in the typeahead, and `argumentHint` is the placeholder for whatever the user types after the name. `argument` declares whether that text is `'required'`, `'optional'`, or `'none'`. The host trims it, answers a missing required argument with the usage line, and hands the handler `{ ctx, argument }`, where `ctx` carries the AI session the command was typed into. Use this instead of `command` when the behavior belongs to a conversation and needs the session. Use `command` when it belongs to the workbench and runs from the palette. Use `tool` when the model, not the user, should decide to run it. Slash commands go in the same top-level `commands` array as palette commands.

function slashCommand<const TId extends string, TResult>(slashCommandValue: SlashCommandInput<TId, TResult>): SlashCommand<TId, TResult>

Import

import { slashCommand } from '@modular/sdk';