whistle
Import
Section titled “Import”import * as api from "@fungi.computer/whistle";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| class | WhistleActionError | An owning handler’s explicit failure code and optional structured details. |
| class | WhistleClosedError | A valid contribution was attempted after the runtime closed. |
| type alias | WhistleExecutionOrigin | The trusted host origin entering the single execution door. |
| type alias | WhistleCommandHandler | A source-owned command’s execution callback, invoked only through the execution door. |
| type alias | WhistlePromptAnswer | The answer type for one prompt kind. |
| type alias | WhistleInteraction | A human conversation attached to one execution. prompt rejects when the human
cancels; signal aborts when the whole interaction is dismissed. |
| type alias | WhistleInteractionEnd | How an execution with an attached interaction ended. |
| type alias | WhistleInteractionSession | One interaction a presenter opened for one execution. |
| type alias | WhistlePresenter | A mounted client that can render interactions. Whistle opens one session per human execution that has no caller-supplied interaction. |
| type alias | WhistleExecutionInput | The already-typed input supplied to a command handler. |
| type alias | WhistleExecutionOutcome | The normalized result of one command execution request. |
| type alias | WhistleCommand | One semantic command definition. |
| type alias | WhistleContribution | One contribution of source-owned commands to a namespace. |
| type alias | WhistleProjectionRow | Shared immutable metadata carried by each projection row. |
| type alias | WhistleAgentProjection | Immutable agent snapshot row composed from the schema-owned action data. |
| type alias | WhistleBindingProjection | One binding value projected from a command. |
| type alias | WhistlePaletteProjection | One palette value projected from a command. |
| type alias | WhistleSlashProjection | One slash alias projected from a command. |
| type alias | WhistleHelpProjection | One help value projected from a command. |
| type alias | WhistleMenuProjection | One menu value projected from a command. |
| type alias | WhistleSnapshot | The six immutable views of one semantic command graph. |
| type alias | WhistleContributionLease | An idempotent lease for one contribution generation. |
| type alias | WhistleRuntime | The provisional Whistle semantic runtime seam. |
| type alias | WhistleKeymapAdapter | Lifecycle operations for a projection into a maintained host keymap. |
| type alias | WhistleKeymapBinding | One physical key string mapped to a Whistle command identifier. |
| type alias | WhistleKeymapCommand | Host callback that executes one semantic Whistle command. |
| type alias | WhistleKeymapLayer | Binding and command records accepted by a maintained keymap host. |
| type alias | WhistleKeymapHost | Minimal registration surface implemented by a maintained host keymap. |
| function | scopeSnapshot() | The projection for one focused scope: global rows plus the focused scope’s rows. A focused slash alias or binding shadows the same global one. Agent rows follow the same scope filter; the complete runtime remains whole. |
| function | createWhistle() | Construct the provisional semantic runtime shell. |
| function | createWhistleKeymapAdapter() | Project Whistle bindings into a host-created maintained OpenTUI keymap. |
WhistleActionErrorclass
Section titled “WhistleActionError”An owning handler’s explicit failure code and optional structured details.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WhistleActionError( code, message, details?): WhistleActionError;Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
code |
string |
Stable failure identity supplied by the handler owner. |
message |
string |
- |
details? |
WhistleJsonValue |
Optional JSON context safe to return to the caller. |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor;Properties
Section titled “Properties”readonly code: string;Stable failure identity supplied by the handler owner.
details?
Section titled “details?”readonly optional details?: WhistleJsonValue;Optional JSON context safe to return to the caller.
WhistleClosedErrorclass
Section titled “WhistleClosedError”A valid contribution was attempted after the runtime closed.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WhistleClosedError(): WhistleClosedError;Construct the provisional error for a valid post-close contribution.
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor;WhistleExecutionOrigintype alias
Section titled “WhistleExecutionOrigin”type WhistleExecutionOrigin = | "agent" | "browser" | "keyboard" | "menu" | "palette" | "programmatic" | "slash" | "terminal";The trusted host origin entering the single execution door.
WhistleCommandHandlertype alias
Section titled “WhistleCommandHandler”type WhistleCommandHandler<Arguments, Result> = object["bivarianceHack"];A source-owned command’s execution callback, invoked only through the execution door.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Arguments |
Result |
WhistlePromptAnswertype alias
Section titled “WhistlePromptAnswer”type WhistlePromptAnswer<Prompt> = WhistlePromptAnswers[Prompt["type"]];The answer type for one prompt kind.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Prompt extends WhistlePrompt |
WhistleInteractiontype alias
Section titled “WhistleInteraction”type WhistleInteraction = Readonly<{ signal: AbortSignal; prompt: <Kind>(prompt, options?) => Promise<WhistlePromptAnswers[Kind]>; notify: (notice) => void; run: <Result>(operation) => Promise<Result>;}>;A human conversation attached to one execution. prompt rejects when the human
cancels; signal aborts when the whole interaction is dismissed.
WhistleInteractionEndtype alias
Section titled “WhistleInteractionEnd”type WhistleInteractionEnd = | Readonly<{ status: "handled"; }> | Readonly<{ status: "cancelled"; }> | Readonly<{ status: "failed"; message: string; }>;How an execution with an attached interaction ended.
WhistleInteractionSessiontype alias
Section titled “WhistleInteractionSession”type WhistleInteractionSession = Readonly<{ interaction: WhistleInteraction; settle: (end) => void;}>;One interaction a presenter opened for one execution.
WhistlePresentertype alias
Section titled “WhistlePresenter”type WhistlePresenter = (request) => WhistleInteractionSession;A mounted client that can render interactions. Whistle opens one session per human execution that has no caller-supplied interaction.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
Readonly<{ commandId: string; title: string; }> |
Returns
Section titled “Returns”WhistleExecutionInputtype alias
Section titled “WhistleExecutionInput”type WhistleExecutionInput<Arguments> = Readonly<{ origin: WhistleExecutionOrigin; arguments?: Arguments; signal?: AbortSignal; interaction?: WhistleInteraction;}>;The already-typed input supplied to a command handler.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Arguments |
unknown |
WhistleExecutionOutcometype alias
Section titled “WhistleExecutionOutcome”type 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.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Result |
unknown |
WhistleCommandtype alias
Section titled “WhistleCommand”type 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.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Arguments |
unknown |
Result |
unknown |
WhistleContributiontype alias
Section titled “WhistleContribution”type WhistleContribution = Readonly<{ sourceId: string; namespace: string; scope?: string; commands: readonly WhistleCommand<never>[];}>;One contribution of source-owned commands to a namespace.
WhistleProjectionRowtype alias
Section titled “WhistleProjectionRow”type 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.
WhistleAgentProjectiontype alias
Section titled “WhistleAgentProjection”type WhistleAgentProjection = Omit<WhistleProjectionRow, "action"> & Readonly<{ action?: Pick<WhistleAction, "inputSchema" | "outputSchema">; keybind?: string; }>;Immutable agent snapshot row composed from the schema-owned action data.
WhistleBindingProjectiontype alias
Section titled “WhistleBindingProjection”type WhistleBindingProjection = WhistleProjectionRow & Readonly<{ binding: string; }>;One binding value projected from a command.
WhistlePaletteProjectiontype alias
Section titled “WhistlePaletteProjection”type WhistlePaletteProjection = WhistleProjectionRow;One palette value projected from a command.
WhistleSlashProjectiontype alias
Section titled “WhistleSlashProjection”type WhistleSlashProjection = WhistleProjectionRow & Readonly<{ alias: string; consumesDraft?: boolean; arguments?: WhistleSlashArguments; }>;One slash alias projected from a command.
WhistleHelpProjectiontype alias
Section titled “WhistleHelpProjection”type WhistleHelpProjection = WhistleProjectionRow;One help value projected from a command.
WhistleMenuProjectiontype alias
Section titled “WhistleMenuProjection”type WhistleMenuProjection = WhistleProjectionRow;One menu value projected from a command.
WhistleSnapshottype alias
Section titled “WhistleSnapshot”type 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.
WhistleContributionLeasetype alias
Section titled “WhistleContributionLease”type WhistleContributionLease = Readonly<{ update: (commands) => void; dispose: () => void;}>;An idempotent lease for one contribution generation.
WhistleRuntimetype alias
Section titled “WhistleRuntime”type 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.
WhistleKeymapAdaptertype alias
Section titled “WhistleKeymapAdapter”type WhistleKeymapAdapter = Readonly<{ cleanup: () => void;}>;Lifecycle operations for a projection into a maintained host keymap.
WhistleKeymapBindingtype alias
Section titled “WhistleKeymapBinding”type WhistleKeymapBinding = Readonly<{ cmd: string; key: string;}>;One physical key string mapped to a Whistle command identifier.
WhistleKeymapCommandtype alias
Section titled “WhistleKeymapCommand”type WhistleKeymapCommand = Readonly<{ name: string; run: () => Promise<boolean>;}>;Host callback that executes one semantic Whistle command.
WhistleKeymapLayertype alias
Section titled “WhistleKeymapLayer”type WhistleKeymapLayer = Readonly<{ bindings: readonly WhistleKeymapBinding[]; commands: readonly WhistleKeymapCommand[];}>;Binding and command records accepted by a maintained keymap host.
WhistleKeymapHosttype alias
Section titled “WhistleKeymapHost”type WhistleKeymapHost = Readonly<{ registerLayer: (layer) => () => void;}>;Minimal registration surface implemented by a maintained host keymap.
scopeSnapshot()function
Section titled “scopeSnapshot()”function scopeSnapshot(snapshot, scope): WhistleSnapshot;The projection for one focused scope: global rows plus the focused scope’s rows. A focused slash alias or binding shadows the same global one. Agent rows follow the same scope filter; the complete runtime remains whole.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
snapshot |
WhistleSnapshot |
A complete runtime snapshot. |
scope |
string | null |
The focused scope, or null when nothing scoped is focused. |
Returns
Section titled “Returns”A frozen snapshot of globals plus the selected scope.
createWhistle()function
Section titled “createWhistle()”function createWhistle(): WhistleRuntime;Construct the provisional semantic runtime shell.
Returns
Section titled “Returns”createWhistleKeymapAdapter()function
Section titled “createWhistleKeymapAdapter()”function createWhistleKeymapAdapter( keymap, whistle, origin,): WhistleKeymapAdapter;Project Whistle bindings into a host-created maintained OpenTUI keymap.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
keymap |
WhistleKeymapHost |
whistle |
Pick<WhistleRuntime, "snapshot" | "subscribe" | "execute"> |
origin |
WhistleExecutionOrigin |
Returns
Section titled “Returns”References
Section titled “References”WhistleAction
Section titled “WhistleAction”Re-exports WhistleAction
WhistleActionPresentation
Section titled “WhistleActionPresentation”Re-exports WhistleActionPresentation
WhistleActionSchema
Section titled “WhistleActionSchema”Re-exports WhistleActionSchema
WhistleAnswerValue
Section titled “WhistleAnswerValue”Re-exports WhistleAnswerValue
WhistleAvailability
Section titled “WhistleAvailability”Re-exports WhistleAvailability
WhistleCommandProjections
Section titled “WhistleCommandProjections”Re-exports WhistleCommandProjections
WhistleCommandDefinition
Section titled “WhistleCommandDefinition”Re-exports WhistleCommandDefinition
WhistleDecisionAnswer
Section titled “WhistleDecisionAnswer”Re-exports WhistleDecisionAnswer
WhistleFailure
Section titled “WhistleFailure”Re-exports WhistleFailure
WhistleJsonObject
Section titled “WhistleJsonObject”Re-exports WhistleJsonObject
WhistleJsonValue
Section titled “WhistleJsonValue”Re-exports WhistleJsonValue
WhistleNotice
Section titled “WhistleNotice”Re-exports WhistleNotice
WhistleNoticeLink
Section titled “WhistleNoticeLink”Re-exports WhistleNoticeLink
WhistlePrompt
Section titled “WhistlePrompt”Re-exports WhistlePrompt
WhistlePromptOption
Section titled “WhistlePromptOption”Re-exports WhistlePromptOption
WhistleSlashArguments
Section titled “WhistleSlashArguments”Re-exports WhistleSlashArguments
WhistleSlashWord
Section titled “WhistleSlashWord”Re-exports WhistleSlashWord