Skip to main content
The root API exposes narrow services for behavior that legitimately belongs outside one node: settings, commands, host UI contributions, backend calls, workflow loading, and per-user storage.

Settings

Declare a setting once at module load:
Setting IDs share one namespace with core and every pack. Include a stable pack prefix. Redeclaring an ID does not reset an existing user’s value. Supported controls are:
  • boolean, number, slider, and knob;
  • combo and radio;
  • text, password, color, image, and url.
For combo and radio choices, a string is both stored value and label. Use { value, label } when they differ so numeric values remain numeric. Read, write, and observe settings:
onChange() can observe a setting the pack did not declare. It fires on change, not on registration. Settings are small preferences. Use comfy.storage for named content the user authors.

Commands, keybindings, and notifications

Command IDs must be namespaced. A label may be dynamic and should return quickly. A keybinding is a default so a user’s custom binding wins. scope: 'canvas' prevents the keybinding from firing while the user is typing in a node widget or another field. Omit it for an application-wide command. Run a host or pack command without reaching into its implementation:
run() rejects when the command does not exist. Use has() for an optional entry. Show a notification:
Severity is success, info, warn, or error and defaults to info. Hand-written modules can render into a host container:
render() can run each time the tab becomes visible. Treat it as a mount and release retained resources from destroy(). A built pack can instead provide a bundled Vue component:
Per ADR 0005, a pack bundles its own Vue. Do not import the host’s internal Vue runtime or pass host reactive objects across the boundary.

Top-bar badges and action buttons

These contributions are declarative so the host retains control of layout and style:
IDs must be namespaced and unique. An update changes only supplied fields. A removed contribution cannot be updated again. If an action also needs a palette entry or shortcut, put behavior in a command and have the button call comfy.commands.run().

Dialogs, menus, and prompts

Dialog

Dialogs also accept a bundled Vue component and optional frozen props. Dialog keys must be namespaced because the host maps them into one dialog keyspace.

Context menu raised by a pack

The MouseEvent positions the menu. A submenu item is mutually exclusive with run. Use NodeDefBuilder.addMenuItem() instead when the host is opening a node’s own context menu.

Prompt

The result is undefined when the user cancels.

Backend URLs, requests, and events

Authenticated API calls

fetch() delegates credentials and authentication behavior to the host. Its route is API-relative and must start with /. backend.url(route) builds the absolute API URL but does not attach credentials to a later plain fetch(). Prefer backend.fetch() for API requests.

Static host files

assetUrl() does not add the API prefix. For a file next to the current pack’s module, use the install-location-safe form:
Do not guess the pack’s install directory.

Backend messages and session identity

Event payloads are unknown because a pack owns its own event schema. Validate before use. The session ID can be undefined until the backend connection is established and must not be persisted.

Workflow service

Open parsed ComfyUI workflow JSON as the active document:
This replaces the current document and is therefore an explicit user-facing action. Validate or confirm untrusted input before calling it. Expand the host’s workflow text tokens against the active root graph:
It throws when no graph is active.

Per-user storage

Storage is for named text documents such as presets, templates, and saved prompts:
Names and namespaces must contain a pack prefix and may not contain ... get() returns undefined for a missing item; list() returns an empty frozen array when the namespace has no entries. Storage lives with the user’s server-side data and follows the user between machines. Use settings for small preferences, and storage for content the user expects to retain and manage by name.