Documentation Index
Fetch the complete documentation index at: https://bastani.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
hostLocalWorkflows is the explicit handoff that makes your CLI atomic-dispatchable. It registers the supplied workflows so atomic can resolve them and responds to atomic’s two internal sub-commands when atomic spawns this CLI as a subprocess. Anything else returns silently — your own CLI surface is yours to shape however you want.
Why explicit?
ESM evaluation is depth-first: a dependency module’s body runs before its importer’s body. If the SDK ran the meta-emit / dispatch handler at module load (top-levelawait), it would execute before the user CLI’s defineWorkflow().compile() line — draining an empty registry and process.exit(0)-ing the user’s main(). Explicit hostLocalWorkflows([wf]) after compile() removes that race.
The _orchestrator-entry and _cc-debounce subcommands continue to dispatch at module load — they don’t depend on user-registered state.
Usage
API
Behavior
hostLocalWorkflows:
- Registers the supplied
workflowsinto a process-local registry keyed by(agent, name). The orchestrator pane atomic spawns later re-imports the file and uses this registry to resolve the definition — noexport defaultrequired. - Inspects
argvfor_emit-workflow-meta/_atomic-runand validates the dispatch token (ATOMIC_HOST=1env +--dispatch-token=<hex>argv must matchATOMIC_DISPATCH_TOKENenv). When matched:_emit-workflow-meta— writesATOMIC_WORKFLOW_META: <json>\nto stdout, exits 0._atomic-run— parses--name <X> --agent <Y> [--detach] [--<input> <v>]…, runs viarunWorkflow, exits 0 on success / 1 on error.
- Otherwise — including bare invocation, the consumer’s own commander flags, attempts to hijack the meta channel from a user terminal without
ATOMIC_HOST=1, and the orchestrator pane’s re-import — returns silently. Your own argv parser stays in control.
Composing with your own CLI
hostLocalWorkflows deliberately stays out of your CLI surface. To expose your workflow as a directly-invokable CLI, set up commander (or any argv parser) after hostLocalWorkflows and call runWorkflow yourself:
process.exit before your parser runs.
See also
Registering workflows
The settings.json registration walkthrough.
Settings
.atomic/settings.json schema and resolution.