Skip to content

@fungi.computer/whistle

An owning handler’s explicit failure code and optional structured details.

  • Error

new WhistleActionError(code, message, details?): WhistleActionError

string

Stable failure identity supplied by the handler owner.

string

WhistleJsonValue

Optional JSON context safe to return to the caller.

WhistleActionError

Error.constructor

readonly code: string

Stable failure identity supplied by the handler owner.

readonly optional details?: WhistleJsonValue

Optional JSON context safe to return to the caller.


A valid contribution was attempted after the runtime closed.

  • Error

new WhistleClosedError(): WhistleClosedError

Construct the provisional error for a valid post-close contribution.

WhistleClosedError

Error.constructor

WhistleExecutionOrigin = "agent" | "browser" | "keyboard" | "menu" | "palette" | "programmatic" | "slash" | "terminal"

The trusted host origin entering the single execution door.


WhistleCommandHandler<Arguments, Result> > = object["bivarianceHack"]

Runs one command with its parsed arguments. Returning undefined settles the command without a result.

Arguments

Result


WhistlePromptAnswer<Prompt> > = WhistlePromptAnswers[Prompt["type"]]

The answer type for one prompt kind.

Prompt extends WhistlePrompt


WhistleInteraction = Readonly<{ signal: AbortSignal; prompt: <Kind>>(prompt, options?) => Promise<WhistlePromptAnswers[Kind]>; notify: (notice) => void; }>

A human conversation attached to one execution. prompt rejects when the human cancels; signal aborts when the whole interaction is dismissed.


WhistleInteractionEnd = Readonly<{ status: "handled"; }> | Readonly<{ status: "cancelled"; }> | Readonly<{ status: "failed"; message: string; }>

How an execution with an attached interaction ended.


WhistleInteractionSession = Readonly<{ interaction: WhistleInteraction; settle: (end) => void; }>

One interaction a presenter opened for one execution.


WhistlePresenter = (request) => WhistleInteractionSession

A mounted client that can render interactions. Whistle opens one session per human execution that has no caller-supplied interaction.

Readonly<{ commandId: string; title: string; retry: () => void; }>

WhistleInteractionSession


WhistleExecutionInput<Arguments> > = Readonly<{ origin: WhistleExecutionOrigin; arguments?: Arguments; signal?: AbortSignal; interaction?: WhistleInteraction; }>

The already-typed input supplied to a command handler.

Arguments = unknown


WhistleExecutionOutcome<Result> > = Extract<WhistleAvailability, { status: "unavailable"; }> | Readonly<{ status: "handled"; result?: Result; }> | Readonly<{ status: "closed"; }> | Readonly<{ status: "missing"; }> | Readonly<{ status: "invalid"; }> | Readonly<{ error: WhistleFailure; status: "failed"; }>

The normalized result of one command execution request.

Result = unknown


WhistleCommand<Arguments, Result> > = Readonly<{ id: string; title: string; category: string; description?: string; projections?: WhistleCommandProjections; action?: WhistleAction; availability?: () => WhistleAvailability; handler: WhistleCommandHandler<Arguments, Result>>; }>

One semantic command definition.

Arguments = unknown

Result = unknown


WhistleContribution = Readonly<{ sourceId: string; namespace: string; scope?: string; commands: readonly WhistleCommand<never>>[]; }>

One contribution of source-owned commands to a namespace.


WhistleProjectionRow = Readonly<{ commandId: string; sourceId: string; scope?: string; title: string; category: string; description?: string; order: number; action?: WhistleAction; availability: WhistleAvailability; }>

Shared immutable metadata carried by each projection row.


WhistleAgentProjection = Omit<WhistleProjectionRow, "action" | "scope"> > & Readonly<{ action?: Pick<WhistleAction, "inputSchema" | "outputSchema">>; keybind?: string; }>

Immutable agent snapshot row composed from the schema-owned action data.


WhistleBindingProjection = WhistleProjectionRow & Readonly<{ binding: string; }>

One binding value projected from a command.


WhistlePaletteProjection = WhistleProjectionRow

One palette value projected from a command.


WhistleSlashProjection = WhistleProjectionRow & Readonly<{ alias: string; arguments?: WhistleSlashArguments; }>

One slash alias projected from a command.


WhistleHelpProjection = WhistleProjectionRow

One help value projected from a command.


WhistleMenuProjection = WhistleProjectionRow

One menu value projected from a command.


WhistleSnapshot = Readonly<{ bindings: readonly WhistleBindingProjection[]; palette: readonly WhistlePaletteProjection[]; slash: readonly WhistleSlashProjection[]; help: readonly WhistleHelpProjection[]; menu: readonly WhistleMenuProjection[]; agent: readonly WhistleAgentProjection[]; }>

The six immutable views of one semantic command graph.


WhistleContributionLease = Readonly<{ update: (commands) => void; dispose: () => void; }>

An idempotent lease for one contribution generation.


WhistleRuntime = Readonly<{ contribute: (contribution) => WhistleContributionLease; close: () => undefined; execute: (commandId, input) => Promise<WhistleExecutionOutcome>>; snapshot: () => WhistleSnapshot; subscribe: (listener) => () => void; present: (presenter) => () => void; }>

The provisional Whistle semantic runtime seam.


WhistleKeymapAdapter = Readonly<{ cleanup: () => void; }>

Lifecycle operations for a projection into a maintained host keymap.


WhistleKeymapBinding = Readonly<{ cmd: string; key: string; }>

One physical key string mapped to a Whistle command identifier.


WhistleKeymapCommand = Readonly<{ name: string; run: () => Promise<boolean>>; }>

Host callback that executes one semantic Whistle command.


WhistleKeymapLayer = Readonly<{ bindings: readonly WhistleKeymapBinding[]; commands: readonly WhistleKeymapCommand[]; }>

Binding and command records accepted by a maintained keymap host.


WhistleKeymapHost = Readonly<{ registerLayer: (layer) => () => void; }>

Minimal registration surface implemented by a maintained host keymap.

scopeSnapshot(snapshot, scope): WhistleSnapshot

The human-facing view for one focused scope: global rows plus the focused scope’s rows. A focused slash alias or binding shadows the same global one. The agent view is not focus-bound and stays whole.

WhistleSnapshot

A complete runtime snapshot.

string | null

The focused scope, or null when nothing scoped is focused.

WhistleSnapshot

A frozen snapshot with the same agent rows.


createWhistle(): WhistleRuntime

Construct the provisional semantic runtime shell.

WhistleRuntime


createWhistleKeymapAdapter(keymap, whistle, origin): WhistleKeymapAdapter

Project Whistle bindings into a host-created maintained OpenTUI keymap.

WhistleKeymapHost

Pick<WhistleRuntime, "snapshot" | "subscribe" | "execute">

WhistleExecutionOrigin

WhistleKeymapAdapter

Re-exports WhistleAction


Re-exports WhistleActionPresentation


Re-exports WhistleActionSchema


Re-exports WhistleAvailability


Re-exports WhistleCommandProjections


Re-exports WhistleCommandDefinition


Re-exports WhistleFailure


Re-exports WhistleJsonObject


Re-exports WhistleJsonValue


Re-exports WhistleNotice


Re-exports WhistleNoticeLink


Re-exports WhistlePrompt


Re-exports WhistlePromptOption


Re-exports WhistleSlashArguments


Re-exports WhistleSlashWord