import { type ComposeService, type DockerRunner } from "./docker.js"; import type { HarnessMode, SandboxStackEnv } from "./env-file.js"; import { type StackPaths } from "./paths.js"; import type { PortProbe } from "./ports.js"; import { type FetchLike } from "./studio-login.js"; import { type OperateEndpoint } from "./operator-keys.js"; export declare const STACK_SERVICES: readonly ["postgres", "restate", "s2-lite", "rustfs", "gateway", "runtime", "harness", "studio"]; export declare const stackUsage = " up|start [--tenant ] [--no-link] [--no-studio] [--allow-downgrade] [--studio-embed-origin ]... [--studio-embed-origin-reset] [--restate-ui]\n start the project's Tenant, creating it and the Project link (.nylorun/link.json,\n credentials.json) on the first run; print the Runtime and Studio URLs (it opens no\n browser). --tenant attaches to (or creates) a named Tenant; --no-link\n starts the default Tenant (or --tenant's) without linking the current directory;\n --restate-ui (or NYLORUN_RESTATE_UI=1) publishes Restate's UI on loopback for debugging\n down|stop [--tenant | --all] stop the Tenant's containers (--all: every Tenant's); keep volumes\n status [--tenant ] [--json] the Tenant, its id, services, endpoints and Runtime health\n studio [--tenant ] [--no-open]\n sign a browser in to Studio on the Tenant; --no-open prints the login URL; start the Tenant if it is stopped"; export interface StackDeps { /** Environment snapshot (NYLORUN_HOME, NYLORUN_TENANT, image overrides, NYLORUN_COMPOSE_PROJECT). */ env: Readonly>; docker: DockerRunner; fetch: FetchLike; ports: PortProbe; uid: number; gid: number; runtimeVersion: string; studioVersion: string; out(line: string): void; err(line: string): void; /** Ask a yes/no question on the terminal; undefined when not interactive. */ confirm?(question: string): Promise; /** A developer is at a terminal. */ interactive?: boolean; /** Standard input, for a body or a secret piped in; undefined when there is none. */ stdin?: { isTTY: boolean; text(): Promise; }; /** Open `url` in a browser; false when no browser could be started. */ openBrowser(url: string): Promise; /** Is this process id alive? (launcher-managed Runtime detection) */ pidAlive(pid: number): boolean; /** Where the project is looked for (default: the process's working directory). */ cwd?: string; /** `~/.nylorun`: the Tenants (tests use a temporary directory). */ nylorunRoot?: string; /** Delay between health polls; tests shorten it. */ pollMs?: number; /** How long `start` waits for the Runtime's /health, and then its Tenant, after Compose. */ healthTimeoutMs?: number; /** How long a Studio login is retried before warning. */ loginTimeoutMs?: number; } /** The Compose project of Tenant `name`: `nylorun-`, or `NYLORUN_COMPOSE_PROJECT`. */ export declare function stackProject(env: StackDeps["env"], name: string): string; interface Flags { rest: string[]; booleans: Set; values: Map; /** Options that may repeat, in order. */ lists: Map; } /** A command's `usage` line (or block, when it starts indented), as `--help` prints it. */ export declare const usageText: (usage: string) => string; /** * The lines of a group's usage block that start with command `name` (`secrets`, `settings`), * with the lines that continue them, as `--help` prints them. */ export declare function usageLinesOf(usage: string, name: string): string; /** * `args` as the options `allowed` names, and the rest. `--help` or `-h` anywhere is a * `HelpRequest` for `usage`; an option `allowed` does not name is a usage error. */ export declare function parseStackFlags(args: readonly string[], allowed: { booleans?: readonly string[]; values?: readonly string[]; lists?: readonly string[]; aliases?: Record; }, usage: string): Flags; /** The Host's one Tenant as `nylorun-operate status --json` reports it. */ export interface StackTenant { /** Null until the Tenant row has been read. */ id: string | null; name: string | null; state: "open" | "unavailable"; /** Why it cannot open (`schema-too-new`, `database-layout-old`, …); `message` says more. */ cause?: string; message?: string; } /** Printed by `start`, which prints Studio's URL and opens no browser. */ export declare const STUDIO_SIGN_IN_HINT = "To sign a browser in to Studio, run \"npx nylorun studio\"."; /** Printed last by `start`. */ export declare const HELP_HINT = "Run \"npx nylorun --help\" to see what else nylorun can do."; export interface StackStatus { /** The Tenant's name. */ name: string; /** The Compose project. */ project: string; /** The Host root. */ home: string; state: "running" | "stopped" | "absent"; runtime: { url?: string; healthy: boolean; /** `/ready`: the Tenant is open and the Runtime's stores answer. */ ready: boolean; version?: string; hostId?: string; }; /** The Tenant as `nylorun-operate status` reports it, while the runtime container runs. */ tenant?: StackTenant; studio: { /** `http://localhost:`: also what an embedding app frames (same site as its own localhost). */ url?: string; state: string; /** Exact origins that may show Studio in a frame (Studio §8.9). */ embedOrigins?: string[]; }; /** Restate's UI: `url` only while published (`nylorun start --restate-ui`). */ restate: { url?: string; published: boolean; }; /** The gateway container (the Model Gate), in the combined packing. */ gateway: { state: string; healthy: boolean; }; /** * Where agent turns, MCP servers and workspaces run (F6.2): `remote`, the harness container, * or `in-process`, the runtime container (`NYLORUN_HARNESS` in .env). `connected` counts the * harnesses attached to the Tenant, as the Runtime reports them. */ harness: { mode: HarnessMode; state: string; healthy: boolean; connected?: number; }; services: ComposeService[]; } /** What `nylorun status` reports, as data (`nylorun doctor`). */ export declare function readStackStatus(deps: StackDeps, options?: { name?: string; }): Promise; /** The running Tenant as clients reach it. */ export interface StackEndpoints { /** The Tenant's name. */ name: string; /** The Host root. */ home: string; /** `http://localhost:` */ runtimeUrl: string; hostId: string; /** The admin key (host-credentials.json): it mints Studio logins. */ adminKey: string; studioPort: number; /** `http://localhost:` */ studioUrl: string; /** Studio is running and healthy. */ studioUp: boolean; /** This call started the Runtime (it was not running before). */ started: boolean; } /** The running Tenant's APIs and their keys (`nylorun local sandbox`). */ export interface TenantApi { /** The Tenant's name. */ name: string; runtimeUrl: string; /** * The linked project's keys (`.nylorun/credentials.json`) when both reach the Tenant, else * the keys `cli` and `cli-management` the Host root keeps (`cli-credentials.json`). */ applicationKey: string; managementKey: string; } /** The selected Tenant's `nylorun-operate` while it runs: `nylorun key` and `runningTenantApi`. */ export interface RunningOperate extends OperateEndpoint { /** The Tenant's name. */ name: string; runtimeUrl: string; paths: StackPaths; } /** * The selected Tenant's `nylorun-operate` while it runs; exit 3 when it is not running, 7 when * it is not open. */ export declare function runningOperate(deps: StackDeps, options?: { name?: string; }): Promise; /** * The selected Tenant's API while it runs: commands that read or change the Tenant's data never * start it. Exit 3 when it is not running, 7 when it is not open. */ export declare function runningTenantApi(deps: StackDeps, options?: { name?: string; }): Promise; /** * Start the selected Tenant unless it is already running (`nylorun studio`): the * `start` code path without its output, its Tenant wait or the Project link. Compose * progress still streams, since the first run pulls images. */ export declare function ensureStack(deps: StackDeps, options: { studio: boolean; name?: string; }): Promise; /** A started Tenant as `nylorun local sandbox` sees it. */ export interface SelectedTenant { name: string; paths: StackPaths; project: string; /** `docker compose` arguments for this Tenant's project and files. */ compose(...args: string[]): string[]; } /** The Tenant `nylorun local sandbox` acts on; it must have been started once. */ export declare function selectTenant(deps: StackDeps, options?: { name?: string; }): Promise; /** * Rewrite the Tenant's Compose files with `sandboxes` set (an object) or removed (null), * and bring it up again: Compose recreates the containers whose settings changed. */ export declare function restartTenant(deps: StackDeps, options: { name?: string; sandboxes: SandboxStackEnv | null; }): Promise; /** Ports every Tenant on this machine keeps for sandboxes, but the one under `except`. */ export declare function reservedSandboxPorts(deps: StackDeps, except: string): Promise>; /** Add Studio's `next` path (e.g. `/tenants/`) to a login URL. */ export declare function withNext(loginUrl: string, next: string | undefined): string; /** The Tenant's Studio page, as a login `next` path. */ export declare function tenantStudioPath(tenantId: string): string; /** * Mint a fresh Studio login URL on a running Tenant, landing on `next`. * Undefined (after a warning) when Studio does not answer. */ export declare function studioLoginUrl(deps: StackDeps, running: Pick, next?: string): Promise; /** `nylorun studio`, landing on `next` when given, else on the Tenant's page. */ export declare function runStudioCommand(args: readonly string[], deps: StackDeps, options?: { next?: string; }): Promise; export declare function isStackCommand(name: string | undefined): boolean; /** Run one Tenant command (`up`/`start`, `down`/`stop`, `status`, `logs`, `reset`, `studio`, `ls`, `delete`). */ export declare function runStackCommand(name: string, args: readonly string[], deps: StackDeps): Promise; export {};