import type { Host } from '../InstallFlow';
/**
 * Install profile v2 — replaces 'framework'/'autonomous' nomenclature with the
 * user-facing names "openlife-core" (local CLI) and "openlife-agent" (long-running daemon).
 *
 * Both maps internally to {profile: 'framework' | 'autonomous'} when calling InstallFlow,
 * preserving backward compat with existing InstallFlow.run() consumers.
 */
export type InstallProfileV2 = 'openlife-core' | 'openlife-agent';
/**
 * Provider IDs — must stay in sync with ProvidersCatalog.ts. Adding a new entry
 * here requires adding the catalog row and (if it gets API key collection) the
 * env-var mapping in InstallModules.API_KEY_ENV_MAP.
 */
export type ProviderId = 'openai-api' | 'anthropic' | 'gemini-api' | 'openrouter' | 'ollama' | 'openai-cli' | 'gemini-cli' | 'xai' | 'deepseek' | 'groq' | 'together' | 'mistral' | 'bedrock' | 'qwen' | 'kimi' | 'minimax' | 'glm' | 'huggingface' | 'nvidia-nim' | 'perplexity' | 'vllm' | 'sglang' | 'llamacpp' | 'lmstudio' | 'litellm' | 'clawrouter' | 'custom-openai';
/**
 * Per-provider authentication strategy. Only meaningful for the agent profile —
 * core profile just collects API keys.
 *
 * OAuth is only supported for providers that ship a CLI with `login` command:
 * Codex (openai-cli), Gemini CLI (gemini-cli), and xAI (grok device-auth).
 * Claude/Anthropic OAuth is EXPLICITLY EXCLUDED per user policy (May 2026).
 */
export type AuthStrategy = 'api-key' | 'oauth' | 'skip';
/** Providers where OAuth is permitted as an auth strategy. */
export declare const OAUTH_ENABLED_PROVIDERS: readonly ProviderId[];
/**
 * Result of the agent block's auth phase — one entry per provider the user
 * elected to configure. The phase that follows reads this to decide whether
 * to prompt for an API key, run the OAuth subprocess, or skip.
 */
export interface AuthDecision {
    provider: ProviderId;
    strategy: AuthStrategy;
}
/**
 * Outcome of running a provider OAuth flow. The OAuth runner spawns the
 * vendor CLI (`codex login`, `gemini login`, etc.) and captures success/failure.
 */
export interface OAuthResult {
    provider: ProviderId;
    ok: boolean;
    /** Vendor CLI that handled the login (eg "@openai/codex", "gemini-cli"). */
    cli: string;
    /** Human-readable detail — for the completion card. */
    detail: string;
}
/**
 * Telegram delivery mode for the agent profile. Polling = local-friendly,
 * webhook = production-friendly (eg Railway). Auto picks the right one based
 * on env detection (PORT, RAILWAY_*, etc.).
 */
export type TelegramMode = 'polling' | 'webhook' | 'auto';
/**
 * Service-supervisor mode chosen for the agent daemon. Determines what
 * `openlife agent start` does post-install — fork into nohup, register a
 * systemd unit, manage via PM2, or expect Railway/Render to handle it.
 */
export type ServiceMode = 'nohup' | 'systemd' | 'pm2' | 'railway' | 'manual';
/**
 * Installation speed mode.
 * - quick: minimal prompts, intelligent defaults (~2 min)
 * - full:  guided wizard, configure everything (~10 min)
 */
export type InstallMode = 'quick' | 'full';
/**
 * Shared mutable state threaded through every phase. The PhaseRunner owns it,
 * each phase reads/writes its slice. Designed to be JSON-serializable so we
 * can checkpoint/resume mid-wizard if needed (future hook — not implemented).
 */
export interface WizardContext {
    /** Project root — defaults to process.cwd(). */
    root: string;
    /** Quick = defaults + minimal prompts; Full = complete guided wizard. */
    installMode: InstallMode;
    /** Was a previous install detected? What did the user choose to do? */
    preExisting?: 'abort' | 'reinstall' | 'repair';
    /** Which products the user wants installed, in installation order. */
    products: InstallProfileV2[];
    /** Currently-installing product (set when entering a product block). */
    currentProduct?: InstallProfileV2;
    /**
     * v1.9.0+ — Project mode for the OpenLife method workflows. Captured by
     * phase `03-project-mode` and persisted to `.openlife/project.json` after
     * final confirmation. `not-applicable` covers cases where the user just
     * wants the CLI without committing to a method workflow.
     */
    projectMode?: 'greenfield' | 'brownfield' | 'not-applicable';
    /** Host CLIs the user wants OpenLife wired into. Multi-select. */
    coreHosts: Host[];
    /** Providers the user wants to configure for the core (local CLI) profile. */
    coreProviders: ProviderId[];
    /** Collected API keys for core providers (only persisted on final confirm). */
    coreApiKeys: Partial<Record<ProviderId, string>>;
    /** Optional model chain override (provider/model strings). */
    coreModelChain?: string[];
    /** Whether to skip the post-install doctor run. */
    coreSkipDoctor?: boolean;
    /** Per-provider auth strategy decisions (agent profile only). */
    agentAuthDecisions: AuthDecision[];
    /** OAuth flow results (post-execution). */
    agentOAuthResults: OAuthResult[];
    /** Collected API keys for agent providers using api-key strategy. */
    agentApiKeys: Partial<Record<ProviderId, string>>;
    /** Telegram bot token (collected, validated, persisted). */
    agentTelegramToken?: string;
    /** Allowed Telegram user ID (single-user by design — defaults to 1344110010). */
    agentTelegramUserId?: string;
    /** Telegram delivery mode (polling vs webhook). */
    agentTelegramMode?: TelegramMode;
    /** Service supervisor mode for the daemon. */
    agentServiceMode?: ServiceMode;
    warnings: string[];
    /** Set to true to abort the wizard cleanly. */
    aborted?: boolean;
    /** Optional reason for abort — surfaced in the WizardResultV2. */
    abortReason?: string;
}
/**
 * Each phase is an async function operating on the shared context.
 * It may prompt, validate, mutate ctx, and decide to abort (set ctx.aborted).
 *
 * Phases SHOULD NOT touch the filesystem outside of `.openlife/install-state.json`
 * (for checkpointing) or write secrets to `.env` — that's the InstallFlow's job
 * after the wizard returns.
 *
 * The only exception: phases that validate a token/credential MAY make a
 * network call (eg getMe for Telegram, login probe for OAuth) — those are
 * read-only externally.
 */
export interface Phase {
    /** Stable id — appears in checkpoints and tests. */
    id: string;
    /** One-line label printed at phase entry. */
    label: string;
    /** Optional condition — phase is skipped when this returns false. */
    when?: (ctx: WizardContext) => boolean;
    /** The phase body. May reject to abort the wizard with an unexpected error. */
    run: (ctx: WizardContext, io: import('./WizardIO').WizardIO) => Promise<void>;
}
export interface WizardResultV2 {
    ok: boolean;
    context: WizardContext;
    reason?: 'user_aborted' | 'invalid_input' | 'unexpected_error';
    detail?: string;
}
