Commands
Command handlers tie together menus, toolbar actions, and context menu items.
Global variables
HarborClient stores app-wide variables in Settings → Globals. They use the same Variable shape as collection and environment variables (key, value, defaultValue, share) and participate in {{key}} substitution with the lowest precedence in the static chain:
globals → collection → environment
Request scripts can mutate globals with hc.globals.get / hc.globals.set; values persist after the send completes. See Request scripts — hc.globals.
Reading globals from plugins
Request tab components receive the merged runtime map on RequestTabContext.variables. Global values are included automatically; collection and environment variables override globals when they define the same key:
function AuditTab({ context }: { context: RequestTabContext }) {
const baseUrl = context.variables.baseUrl;
const token = context.variables.token;
// ...
}This snapshot reflects the editor state before send. It does not include ephemeral values from hc.request.variables.set during an in-flight send.
Updating globals from plugins
Replace all global variables with a new list via the built-in host command (requires the ui permission):
await hc.commands.execute('harborclient:updateGlobalVariables', [
{ key: 'baseUrl', value: 'https://api.example.com', defaultValue: '', share: true },
{ key: 'apiKey', value: '', defaultValue: 'dev-key', share: false }
]);Each row uses PluginVariableInput: key, value, optional defaultValue, optional share.
To create or update environment variables instead, use hc.host.createEnvironmentWithVariables and hc.host.updateEnvironmentVariables.
hc.commands.execute(id, ...args)
Available since v2.0.0
Signature:(id: string, ...args: unknown[]) => Promise<void>
Runs a registered command programmatically — for example to open a main view from another part of your plugin.
hc.commands.register('myPlugin.openDashboard', () => {
void hc.commands.execute('myPlugin.navigateToView', 'myPlugin.view');
});hc.commands.register(id, handler)
Available since v2.0.0
Signature:(id: string, handler: (...args: unknown[]) => void | Promise<void>) => Disposable
Manifest: matching contributes.commands entry
Registers a command handler. The id must match a command declared in the manifest and referenced by menu, toolbar, or context menu contributions.
