import type { ModelChoice } from '../core/profile-generator.js'; import { type Locale } from '../core/i18n.js'; import { cmdFeishu, type CliResult } from './feishu-login.js'; export interface InitPaths { DATA_DIR: string; CONFIG_DIR: string; STORE_DIR: string; CONTEXT_DIR: string; PROJECTS_DIR: string; WORKSPACE_DIR: string; } /** Resolve DATA_DIR from --home arg, $CORTEX_HOME env, or ~/.cortex/ default. */ export declare function getResolvedPaths(homeDir?: string): InitPaths; export type InitBackend = 'claude' | 'pi'; /** A single selectable interaction platform. */ export type PlatformChoice = 'slack' | 'feishu'; /** @deprecated single-platform alias kept for back-compat; use PlatformChoice[]. */ export type InitPlatform = PlatformChoice | 'none'; export interface SlackInitConfig { botToken: string; signingSecret: string; appToken: string; } export interface FeishuInitConfig { appId: string; appSecret: string; domain?: 'feishu' | 'lark'; /** Identity for MCP document operations: 'bot' (default) or the operator's 'user' account. */ authMode?: 'bot' | 'user'; } export interface GatewayUsageConfig { enabled: boolean; name?: string; org?: string; email?: string; } export interface InitAnswers { /** UI language for system-generated messages. Persisted to config/preferences.json. */ lang: Locale; backends: InitBackend[]; machineName: string; gpuCount: number; /** Selected interaction platforms (multi-select). Empty array = no platform (manual/skip). */ platforms: PlatformChoice[]; slackConfig?: SlackInitConfig; feishuConfig?: FeishuInitConfig; gatewayUsage: GatewayUsageConfig; installService: boolean; /** Explicit (mode, model) for the `plan` profile. Non-interactive only; interactive picks * inside runGatewaySetup once endpoints are discovered. Undefined → auto-infer. */ planChoice?: ModelChoice; /** Explicit (mode, model) for the `execute` profile. Same semantics as planChoice. */ executeChoice?: ModelChoice; /** Additional models to register as standalone named profiles. Non-interactive only. */ extraProfiles?: ModelChoice[]; } /** Generate .env content — includes CORTEX_MACHINE, CORTEX_PLATFORM, and platform-specific tokens. */ export declare function generateDotEnvContent(answers: InitAnswers): string; /** Generate default mode.json content (compact JSON, single line). */ export declare function generateDefaultModeJson(primaryBackend?: InitBackend): string; /** Status info for the config display */ export interface ConfigStatus { dataDirExists: boolean; dotEnvExists: boolean; mcpConfigExists: boolean; modeJsonExists: boolean; } /** Format resolved paths and initialization status for `cortex config` output. */ export declare function formatConfigOutput(paths: InitPaths & { INSTALL_ROOT: string; }, status: ConfigStatus): string; /** Slack App Manifest for Cortex bot. Users paste this when creating a Slack App via "From a manifest". */ export declare const SLACK_APP_MANIFEST: string; /** Check whether a backend binary is on PATH. */ export declare function isBackendInstalled(backend: InitBackend): boolean; /** Return the npm install command for a backend. */ export declare function getInstallCommand(backend: InitBackend): string; /** Path to aistatus config file. */ export declare function getAistatusConfigPath(): string; /** Generate gateway usage config YAML string. */ export declare function generateGatewayUsageYaml(config: GatewayUsageConfig): string; /** Generate systemd unit file content for Linux. */ export declare function generateSystemdUnit(user: string, cortexBin: string, dataDir: string): string; /** Generate launchd plist content for macOS. */ export declare function generateLaunchdPlist(user: string, cortexBin: string, dataDir: string): string; /** * Run the Feishu user-identity login inline during init (OAuth device-authorization flow). * Invoked right after the operator selects authMode='user' so they authorize in one sitting * instead of having to run `cortex feishu login` afterwards. * * Credentials are passed via deps.env (no .env on disk yet at questionnaire time), and the token * is written next to the .env (CONFIG_DIR/feishu-user-token.json) so it matches the --home target * even when that differs from the module-level CONFIG_DIR. Best-effort: returns the CliResult and * never throws, so a failed/abandoned login does not abort init — the operator can retry later. */ export declare function runFeishuUserLogin(config: FeishuInitConfig, configDir: string, deps?: { cmdFeishuImpl?: typeof cmdFeishu; stdout?: (s: string) => void; }): Promise; /** Check whether git is available on PATH. */ export declare function isGitInstalled(): boolean; /** Return a human-readable install instruction for git on the current platform. */ export declare function getGitInstallHint(): string; /** * Ensure git is available on PATH. If missing, attempt automatic installation. * Returns true if git is now available, false otherwise. */ export declare function ensureGitInstalled(): boolean; export declare function safeCopy(src: string, dst: string, force: boolean, _label: string): boolean; export declare function generateConfigs(paths: InitPaths, answers: InitAnswers, force: boolean): void; export interface InitOptions { homeDir?: string; force?: boolean; /** Override gateway.yaml output directory (defaults to ~/.aistatus/ when unset). */ gatewayConfigDir?: string; } export declare function runInit(options?: InitOptions): Promise;