/** * Instance registry (#367): the named Coolify instances this server manages. * * Single-instance configs (COOLIFY_BASE_URL + COOLIFY_ACCESS_TOKEN) are a * registry of one, named "default", and behave exactly as before — no new * tool arguments, no new output. COOLIFY_INSTANCES (a JSON array) adds more; * only then does the fleet surface appear. * * Trust model, decided on #367 ("option 1"): a fleet is ONE trust domain. * Every instance in a registry belongs to the same owner. Agencies with a * Coolify per client run one server per client; per-instance OAuth scopes * are a 3.2 concern, not something this registry pretends to solve. * * Errors thrown here name the entry and the problem, never a value. */ import type { CoolifyConfig } from '../types/coolify.js'; /** * An intersection rather than `interface ... extends`, because `CoolifyConfig` * is a union expressing "a token, or a token file" and an interface cannot * extend a union. */ export type InstanceDefinition = CoolifyConfig & { /** Unique, used as the tools' `instance` argument. */ name: string; }; /** `instance: "all"` is a fan-out selector on the tools that support it, never a name. */ export declare const ALL_INSTANCES = "all"; export declare const DEFAULT_INSTANCE_NAME = "default"; export declare class UnknownInstanceError extends Error { constructor(requested: string, known: string[]); } export declare class InstanceRegistry { private readonly byName; constructor(instances: InstanceDefinition[]); /** The first configured instance — what an omitted `instance` argument means. */ get default(): InstanceDefinition; get all(): InstanceDefinition[]; get names(): string[]; /** True once there is anything to choose between — the fleet surface's switch. */ get isFleet(): boolean; /** Resolve an `instance` argument; undefined means the default. */ get(name?: string): InstanceDefinition; } /** * Build the registry from the environment. * * COOLIFY_BASE_URL / COOLIFY_ACCESS_TOKEN (with the CF Access pair and any * CLI `--header` flags) define the "default" instance and come first, so an * existing single-instance config keeps its meaning when COOLIFY_INSTANCES * is added alongside it. With only COOLIFY_INSTANCES set, its first entry is * the default. */ export declare function registryFromEnv(env: NodeJS.ProcessEnv, cliHeaders?: Record): InstanceRegistry;