Interface: Command
Defined in: packages/sdk/src/types.ts:331
A named, invokable action. Register with ExtensionContext.registerCommand and trigger from menu items, keybindings, status items, or ExtensionContext.executeCommand.
Properties
id
id: string;Defined in: packages/sdk/src/types.ts:333
Unique id, conventionally area.verb (e.g. "view.toggleLeftPanel").
label
label: string;Defined in: packages/sdk/src/types.ts:335
Human-readable label (shown where the command surfaces in UI).
run
run: (...args) => unknown;Defined in: packages/sdk/src/types.ts:359
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 from | args[0] |
|---|---|
| ExtensionContext.registerToolbarItem | ToolbarItemContext[S] |
| ExtensionContext.registerContextMenuItem | MenuContext[S] |
| ExtensionContext.executeCommand | whatever the caller passed |
| a keybinding, a menu item, the command palette | nothing |
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