Skip to content

Interface: Command ​

Defined in: packages/sdk/src/types.ts:362

A named, invokable action. Register with ExtensionContext.registerCommand and trigger from menu items, keybindings, status items, or ExtensionContext.executeCommand.

Properties ​

id ​

ts
id: string;

Defined in: packages/sdk/src/types.ts:364

Unique id, conventionally area.verb (e.g. "view.toggleLeftPanel").


label ​

ts
label: string;

Defined in: packages/sdk/src/types.ts:366

Human-readable label (shown where the command surfaces in UI).


run ​

ts
run: (...args) => unknown;

Defined in: packages/sdk/src/types.ts:390

The action. May return a value (sync or async); executeCommand resolves with whatever this returns.

What args holds depends on how the command was invoked — the host does not synthesize a target for invocations that carry none:

Invoked fromargs[0]
ExtensionContext.registerToolbarItemToolbarItemContext[S]
ExtensionContext.registerContextMenuItemMenuContext[S]
ExtensionContext.executeCommandwhatever the caller passed
a keybinding, a menu item, the command palettenothing

So a command that reads its target only from args cannot be bound to a key: it will run and silently do nothing. If the same command backs both a surface and a shortcut, fall back to the active tab (EditorService.getState().active, TerminalService.getActive) when no context arrives.

Zero-argument, void-returning commands are still valid — () => void satisfies this type, so existing registrations compile unchanged.

Parameters ​

args ​

...unknown[]

Returns ​

unknown