Skip to content

index

@fungi.computer/whistle


@fungi.computer/whistle / index

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

WhistleCommandProjections = Readonly<{ bindings?: Readonly<{ order?: number; values: readonly string[]; }>; agent?: Readonly<{ keybind?: string; order?: number; }>; help?: Readonly<{ order?: number; }>; menu?: Readonly<{ order?: number; }>; palette?: Readonly<{ order?: number; }>; slash?: Readonly<{ aliases: readonly string[]; order?: number; }>; }>

The six explicit discoverability choices for one command.


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

The trusted host origin entering the single execution door.


WhistleJsonValue = null | boolean | number | string | readonly WhistleJsonValue[] | WhistleJsonObject

JSON data used to describe an action at a client boundary.


WhistleJsonObject = object

JSON object node used by the recursive action schema document type.

[key: string]: WhistleJsonValue


WhistleActionSchema = Readonly<WhistleJsonObject>>

JSON Schema document describing action arguments or results.


WhistleActionChoice = Readonly<{ value: WhistleJsonValue; label: string; description?: string; }>

One choice a client may present for a declarative action.


WhistleActionPresentation = Readonly<{ type: "action"; }> | Readonly<{ type: "custom"; data: WhistleJsonObject; }> | Readonly<{ type: "choice"; options: readonly WhistleActionChoice[]; }> | Readonly<{ type: "form"; submitLabel?: string; }> | Readonly<{ type: "confirmation"; message: string; confirmLabel?: string; cancelLabel?: string; }>

Renderer-neutral presentation metadata for one action.


WhistleAction = Readonly<{ inputSchema?: WhistleActionSchema; outputSchema?: WhistleActionSchema; presentation?: WhistleActionPresentation; }>

Data-only action description carried by a semantic command.


WhistlePromptOption = Readonly<{ value: string; label: string; description?: string; }>

One option offered by a choice prompt.


WhistlePrompt = Readonly<{ type: "choice"; message: string; options: readonly WhistlePromptOption[]; }> | Readonly<{ type: "text"; message: string; placeholder?: string; secret?: boolean; }> | Readonly<{ type: "confirmation"; message: string; confirmLabel?: string; cancelLabel?: string; }>

One renderer-neutral question an executing command asks its human caller. Hosts choose the widgets; the vocabulary only names the kind of answer.


WhistlePromptAnswer<Prompt> > = Prompt["type"] extends "confirmation" ? boolean : string

The answer type for one prompt kind.

Prompt extends WhistlePrompt


WhistleNoticeLink = Readonly<{ url: string; label?: string; }>

One labelled link inside a notice.


WhistleNotice = Readonly<{ type: "info"; message: string; links?: readonly WhistleNoticeLink[]; }> | Readonly<{ type: "progress"; message: string; }> | Readonly<{ type: "handoff"; url: string; code?: string; message?: string; }> | Readonly<{ type: "success"; message: string; }>

One renderer-neutral status update from an executing command.


WhistleInteraction = Readonly<{ signal: AbortSignal; prompt: <Prompt>>(prompt, options?) => Promise<WhistlePromptAnswer<Prompt>>>>; 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


WhistleAvailability = Readonly<{ status: "available"; }> | Readonly<{ status: "unavailable"; reason: string; }>

Host-owned semantic availability; domain admission still runs in the handler.


WhistleFailure = Readonly<{ code: string; message: string; details?: WhistleJsonValue; }>

Portable failure data, without stack traces or executable error objects.


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


WhistleCommandDefinition = Readonly<Pick<WhistleCommand, "action" | "category" | "description" | "id" | "projections" | "title"> > & object>>

Data-only command definition accepted by a transport adapter.


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

One contribution of source-owned commands to a namespace.


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

Shared immutable metadata carried by each projection row.


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; }>

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.


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

One agent 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.

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