import type { AgencyConfig } from "../../../config/config.js"; import type { ServeAddress } from "../../statelog/serveUrl.js"; import type { HostedAgentInfo } from "../../statelog/projectClient.js"; /** What every remote command needs: the resolved config and the path it came * from, for messages that point the user at the right file. */ export type RemoteCommandContext = { config: AgencyConfig; configPath: string; }; /** The API key together with the environment variable it came from, so a command * can name that variable in its guidance without the HTTP client knowing it. */ export type ResolvedApiKey = { apiKey: string; apiKeyEnvName: string; }; /** An account-management target: a canonical origin plus the resolved key. */ export type AccountTarget = ResolvedApiKey & { origin: string; }; /** Options common to every account-management command. */ export type AccountCommandOptions = { host?: string; apiKeyEnv?: string; }; /** A project-read command additionally selects a project by slug. */ export type ProjectCommandOptions = AccountCommandOptions & { project?: string; }; /** An account target with the project slug these reads operate on. */ export type ProjectTarget = AccountTarget & { projectSlug: string; }; /** Print an error and exit non-zero. Typed `never` so callers can use it in an * expression position (`const x = maybe() ?? fail(...)`). */ export declare function fail(message: string): never; /** The API key and its variable name, or exit with a clear message. The key is * only ever read from the environment, never a flag. */ export declare function resolveApiKey(options: { apiKeyEnv?: string; }): ResolvedApiKey; /** The API key value alone, for callers that do not need the variable name. */ export declare function apiKeyOrExit(options: { apiKeyEnv?: string; }): string; /** Resolve where an account-management command talks to: a canonical origin * (from `--host`, then `agency.json` `log.host`) and the resolved API key. * Exits with a clear message on a missing or invalid origin, or a missing * key. */ export declare function resolveAccountTarget(context: RemoteCommandContext, options: { host?: string; apiKeyEnv?: string; }): AccountTarget; /** Origin plus slug, from flags or `agency.json`; no credential access. */ export type ProjectLocation = { origin: string; projectSlug: string; }; export declare function resolveProjectLocation(context: RemoteCommandContext, options: { host?: string; project?: string; }): ProjectLocation; /** Resolve a project target: origin, slug, and key. The API key is read LAST, * so a CLI-input error (missing host, empty or absent project) is reported * even with the key unset — no credential access before the input is known * good. */ export declare function resolveProjectTarget(context: RemoteCommandContext, options: ProjectCommandOptions): ProjectTarget; /** A project target plus the deployed agent and its serve address. */ export type ServeTarget = ProjectTarget & { address: ServeAddress; agent: HostedAgentInfo; }; /** The serve address of the project's deployed agent: user id from `whoami`, * file from the project's entry point. Exits when nothing is deployed or a * lookup fails. */ export declare function resolveServeTarget(context: RemoteCommandContext, options: ProjectCommandOptions): Promise; /** Turn a project-read command error into a clean CLI exit. The client is * responsible for secret-free messages; pull errors already carry their * committed-destinations context. No command prints a caught stack. */ export declare function failProjectCommand(error: unknown): never; /** Write exactly one JSON document to stdout and nothing else, so `--json` * output is never contaminated by prose or ANSI. */ export declare function printJson(value: unknown): void; /** Turn a client error into a clean CLI exit. An AccountScopeError becomes * guidance naming the resolved API-key variable — the one place that knows both * the scope error (from the client) and the variable name (from the target). */ export declare function failAccount(error: unknown, apiKeyEnvName: string): never;