import { GuueyJsonV1, GuueyJsonV1Input } from '@guuey/config'; /** * Admin API client for the Guuey CLI. * * Wraps the platform's `/api/admin` endpoints with typed HTTP methods, * automatic auth headers, and structured error handling. */ /** * Error thrown when an admin API request fails. * Contains the HTTP status code for programmatic error handling. */ declare class ApiError extends Error { /** HTTP status code from the failed request */ status: number; constructor( /** HTTP status code from the failed request */ status: number, message: string); } /** * Typed HTTP client for the ggui admin API. * All methods prepend `/api/admin` to the path automatically. */ interface AdminClient { /** Send a GET request to the admin API. */ get(path: string): Promise; /** Send a PUT request with a JSON body to the admin API. */ put(path: string, body: unknown): Promise; /** Send a POST request with a JSON body to the admin API. */ post(path: string, body: unknown): Promise; /** Send a DELETE request to the admin API. */ del(path: string): Promise; } /** * Create an admin API client using the resolved CLI configuration. * Reads endpoint, API key, and app ID from the config chain * (env vars > project config > global config). * * @returns Configured admin client * @throws Error if endpoint, API key, or app ID is not configured */ declare function createClient(): AdminClient; /** * Global CLI configuration stored in `~/.guuey/config.json`. * Contains user-level defaults and secrets (API key). * * Note: `bridgeUrl` is intentionally omitted — it is project-specific * and belongs in `guuey.json`, not global config. */ interface CliConfig { /** Platform host URL (e.g., `https://platform.guuey.com`) */ host?: string; /** API key for authentication (starts with `ggui_sk_`) */ apiKey?: string; /** Default app ID to use when no project config is present */ appId?: string; } /** * Load the global CLI configuration. * Uses --config override if set, otherwise ~/.guuey/config.json. * * @returns Parsed config, or an empty object if the file does not exist */ declare function loadConfig(): CliConfig; /** * Persist the global CLI configuration to `~/.guuey/config.json`. * Creates the `~/.guuey` directory if it does not exist. * * @param config - Configuration to save */ declare function saveConfig(config: CliConfig): void; /** * Project config for the closed `guuey` CLI. This is the Guuey * hosted overlay (`guuey.json`) — its schema is owned by * `@guuey/config`. The CLI deliberately re-exports * the canonical type rather than carrying its own parallel shape * (the legacy parallel interface was deleted 2026-04-21 as part of * the CLI writer migration). See * `docs/plans/2026-04-17-ggui-oss-split.md` §8 and * `docs/plans/2026-04-20-guuey-pull-migration-question.md`. * * Local-dev URL overrides (`GUUEY_HOST`, `GUUEY_BRIDGE_URL`, * `GUUEY_WS_URL`, `GUUEY_RENDER_URL`) are NO LONGER stored in * `guuey.json` — they live in `.env` only per §8.4. `guuey create` * writes them to `.env` on project creation when a sandbox * `amplify_outputs.json` surfaces them. */ type ProjectConfig = GuueyJsonV1; /** Find `guuey.json` in current directory or parents (up to 5 levels). */ declare function findProjectConfig(): string | null; /** * Load and validate the project-level `guuey.json` overlay. * Searches the current directory and up to 5 parent directories. * * Returns `null` if no file is found OR if the file fails canonical * schema validation. Callers that care about the distinction should * use {@link getProjectConfigPath} + {@link safeParseGuueyJson} * directly. */ declare function loadProjectConfig(): ProjectConfig | null; /** * Write a project configuration to a `guuey.json` file. Validates * against the canonical `GuueyJsonV1` schema before writing — throws * `ZodError` on invalid input so callers can't silently ship a * malformed overlay. * * @param config - Canonical overlay to serialize * @param filePath - Target path (defaults to `./guuey.json` in CWD) */ declare function saveProjectConfig(config: GuueyJsonV1Input, filePath?: string): void; /** * Fully resolved configuration with all layers merged. * * Priority: env vars > guuey.json > amplify_outputs.json > ~/.guuey/config.json > defaults * * Note: `apiKey` never comes from `guuey.json` (secrets stay in `.env` * or `~/.guuey/config.json`). */ interface ResolvedConfig { host: string; apiKey?: string; appId?: string; bridgeUrl?: string; /** Platform WebSocket URL (for session events) */ wsUrl?: string; /** Render endpoint base URL (for short code URLs) */ renderUrl?: string; /** App config API URL */ appConfigUrl?: string; /** MCP endpoint URL */ mcpUrl?: string; /** REST API endpoint URL (for BYOK etc.) */ apiUrl?: string; /** Platform app URL (e.g., https://platform.guuey.com) */ platformUrl?: string; /** Portal app URL (e.g., https://app.guuey.com) */ portalUrl?: string; /** MCP proxy URL (e.g., https://mcp-proxy.guuey.com) */ mcpProxyUrl?: string; } /** * Resolve config with priority: * env vars > amplify_outputs.json > ~/.guuey/config.json > defaults * * Local-dev URL overrides (`GUUEY_HOST`, `GUUEY_BRIDGE_URL`, * `GUUEY_WS_URL`, `GUUEY_RENDER_URL`) are `.env`-only — they no longer * fall back through `guuey.json` per §8.4 (the overlay is hosted * state, not a URL-pinning surface). `appId` still comes from the * canonical overlay's `project.id` when present, since that IS * hosted identity. */ declare function resolveConfig(): ResolvedConfig; /** * Resolve full config including the loaded canonical overlay. * Returns the overlay as `null` when no `guuey.json` is present (or * when validation failed) — downstream callers branch on nullability. */ declare function resolveFullConfig(): ResolvedConfig & { project: ProjectConfig | null; }; export { type AdminClient, ApiError, type CliConfig, type ProjectConfig, type ResolvedConfig, createClient, findProjectConfig, loadConfig, loadProjectConfig, resolveConfig, resolveFullConfig, saveConfig, saveProjectConfig };