import { ToolDefinition } from "./_chunks/index.mjs"; import { McpServerInfo } from "./_chunks/mcp-answers.mjs"; export interface CliOptions { /** Executable name, also the MCP server name. */ readonly name: string; readonly version: string; readonly description: string; readonly tools: readonly ToolDefinition[]; /** * The package's own commands, as tool definitions that only the CLI gets: * no MCP, Pi, OMP or AI SDK host sees them. One whose command name matches * a generated command, `mcp` included, takes its place. Bytes are the * command's own business: it reads `-` from stdin itself in `execute`, and * writes to stdout itself, answering with no content and `cli.json: false`. * A command that prints rows as they land reads `--json` off its {@link CliHost}, * and leaves `progress` alone: on a terminal its line would sit in front of the rows. */ readonly commands?: readonly ToolDefinition[]; /** * Groups the `cli.command` hints open with a first word, as `servers` in * `servers list`: their line in the command list and more words for them. */ readonly groups?: Readonly>; /** Command for an empty command line, two words for a command in a group. */ readonly default?: string; /** Command for a first word that names no command: `hashes sha256 x` runs `hashes hash sha256 x`. */ readonly fallback?: string; /** Adds `mcp` over stdio, named by the CLI on `true` or by the server info it's handed. */ readonly mcp?: boolean | McpServerInfo; /** * Errors the package throws on purpose. They print as one line with a `caused by:` * line per cause and exit code 1; any other error keeps its stack trace. */ readonly expected?: (error: unknown) => boolean; } /** A group of commands: `servers` in `servers list` and `servers add`. */ export interface CliGroup { /** Line in the command list. Defaults to the names of its commands. */ readonly description?: string; readonly aliases?: readonly string[]; } /** What a CLI command finds in `host`: narrow to it and look at `json` before writing a byte. */ export interface CliHost { readonly cli: true; /** `--json` was given, so the details are the answer and stdout stays theirs. */ readonly json: boolean; } /** * @param tool - Tool to name. * @returns {string} The hinted command, two words for one in a group, or the tool name without * its package prefix, in kebab case. */ export declare function commandName(tool: ToolDefinition): string; /** A built command line interface. */ export interface Cli { /** Runs one command line: the words after the executable and script. */ run(argv: readonly string[]): Promise; } /** * Builds the commands and checks every definition, so a broken hint fails at * startup and not on the first call that reaches it. * * @param options - CLI options. * @returns {Cli} The CLI. * @throws {ToolDefinitionError} When two commands share a name or alias, a hint does not fit its * schema, `groups` names no group, or `default` or `fallback` names no command. */ export declare function createCli(options: CliOptions): Cli; /** * Applies `default` and `fallback`: an empty command line runs `default`, and * a first word that names no command goes to `fallback` as its first * argument, a flag included, so `web --provider brave query` searches. Only * the root's own `--help` and `--version` stay at the root. * * @param options - CLI options. * @param argv - Words after the executable and script. * @returns {string[]} The words to dispatch. */ export declare function normalizeArgv(options: CliOptions, argv: readonly string[]): string[]; /** * Runs the CLI on `process.argv`. The CLI writes no colors; a terminal on * stderr only gets the progress line, which never reaches a pipe. * * @param options - CLI options. * @param argv - Words after the executable and script. */ export declare function runCli(options: CliOptions, argv?: readonly string[]): Promise;