/** * Slash-command bridge: forwards terminal command lines into the shared * `ctx.commands` registry (the same surface the web composer dispatches * through) and exposes the live descriptor list as completion candidates. * The runner keeps only its own TUI-local commands (`/help`, `/quit`, * `/clear`, `/model`) ahead of the registry dispatch. * * @module @deepseek-ai/dsh-tui/commands */ import type { Context } from '@deepseek-ai/cordis'; import type { Agent } from '@deepseek-ai/dsh-agent'; import type { CommandDescriptor } from '@deepseek-ai/dsh-commands'; /** Descriptor list snapshot the completion menu renders from. */ export interface CommandsView { /** Name-sorted descriptors after scoped shadowing. */ readonly descriptors: readonly CommandDescriptor[]; /** Latest descriptor-read failure; the help panel exposes it in place. */ readonly error?: string; /** Subscribe to list changes (`commands/change`); returns the unsubscribe function. */ subscribe(listener: () => void): () => void; /** Retarget the agent whose scoped view the list is read through. */ setAgent(agent: Agent): void; } /** * Watch the live command registry. Reads the current list immediately and * re-reads on every registry mutation or agent retarget; notification * failures are contained by the registry itself, so this watcher only ever * re-reads. Without a `commands` service the view stays empty and all lines * fall through to normal prompts. * @param ctx - context carrying the `commands` service (optional). * @returns the view the completion menu subscribes to. */ export declare function watchCommands(ctx: Context): CommandsView; /** * Whether one command line is a syntactically valid slash command. * @param line - the complete candidate line. * @returns true when the line parses as `/name` or `/name input`. */ export declare function isSlashLine(line: string): boolean; /** * The submission payload for one composer line. Trim is a blank check, not a * rewrite: an ordinary prompt keeps its exact leading indentation, inner * layout, and trailing spaces (pasted code must reach the model verbatim). * Only trailing line terminators are stripped — a draft's final newline is a * paste/Enter artifact (an open bracketed paste turns Enter into an inserted * newline), never deliberate content. A syntactic slash line still normalizes * fully so command routing stays stable (completion inserts a trailing space * after `/name`). * @param line - the complete draft text. * @returns the text to submit verbatim. */ export declare function submissionPayload(line: string): string;