/** * The `/mode` picker's list: which presets to show, in what order, and what to * say about each one. * * The dialog is a flat list of options, so the grouping a browser surface can * draw is carried in three cheap ways: the groups are ordered (shipped first, * then authored locally), every description names its group, and a preset that * declares a position shows it. Nothing here touches the filesystem or the * service — the caller passes what `list()` returned. * @module dsh-ssh-tui/preset-picker */ import type { AgentPreset } from './preset-compat.js'; /** One option as the question dialog wants it, plus the id it stands for. */ export interface PresetPickerOption { id: string; label: string; description: string; /** Why this preset cannot run, carried so the dialog can refuse it on pick. */ broken?: string; /** * Every name this preset answers to: the id, and the name it published even * when the display label resolves elsewhere. `/mode ` matched a * published name before the list was grouped, and dropping that would break * a script that uses one. */ aliases: string[]; } /** The shipped presets, then the locally authored ones. */ export interface PresetPickerGroup { trust: 'system' | 'user'; title: string; options: PresetPickerOption[]; } /** * Within a group: a declared position first, in ascending order, then the rest * by id. `order` is the preset's own statement about where it belongs, so a * deployment's curated sequence survives discovery. */ export declare function comparePresets(left: AgentPreset, right: AgentPreset): number; /** * What one preset's line says underneath its name: where it sits, what it is * for, and why it cannot run — in that order, because a broken preset's reason * is the only thing the reader needs. */ export declare function presetOptionDescription(preset: AgentPreset, currentId: string): string; /** One option's label: the name the roster publishes, never empty. */ export declare function presetOptionLabel(preset: AgentPreset): string; /** * Group and order the roster for the picker. * @param presets - what the service listed. * @param currentId - the preset in effect, marked in each description. * @returns shipped presets first, then authored ones; empty groups are omitted. */ export declare function groupPresets(presets: readonly AgentPreset[], currentId: string): PresetPickerGroup[]; /** The same list, flattened the way the dialog takes it. */ export declare function flattenGroups(groups: readonly PresetPickerGroup[]): PresetPickerOption[]; /** Whether a preset answers to the name a caller typed. */ export declare function optionMatches(option: PresetPickerOption, query: string): boolean; /** * Narrow the roster to what a typed query matches: the id, the published name, * and the description, case-insensitively. An empty query keeps everything, so * the picker opens on the full roster. */ export declare function filterPresets(presets: readonly AgentPreset[], query: string): AgentPreset[];