import { type RegisterAppOptions, type RegisterAppResult } from '../setup/register-app.js';
import { type CredentialValidation, type RemainingStep } from '../setup/verify-permissions.js';
import { type OpenPlatformAutomationOptions, type OpenPlatformAutomationResult } from '../setup/open-platform-automation.js';
import type { CliId } from '../adapters/cli/types.js';
export type BotOnboardingStatus = 'starting' | 'waiting_for_scan' | 'verifying' | 'configuring_permissions' | 'waiting_for_platform_scan' | 'completed' | 'failed';
/** 开放平台权限自动配置结果, 供前端展示成功摘要或手动兜底步骤. */
export interface BotOnboardingPermission {
    ok: boolean;
    /** 成功导入的权限数 */
    scopeCount?: number;
    /** 当前租户目录里没有、被跳过的权限数 */
    skippedScopeCount?: number;
    /** 已提交发布的版本号 */
    versionId?: string;
    /** 部分权限注册失败的告警 */
    scopeWarning?: string;
    /** 失败原因 / 信息 (失败时给出手动步骤) */
    reason?: string;
    message?: string;
}
export interface BotOnboardingSnapshot {
    id: string;
    status: BotOnboardingStatus;
    createdAt: number;
    updatedAt: number;
    qrUrl?: string;
    qrDataUrl?: string;
    expireAt?: number;
    platformQrDataUrl?: string;
    /** 自动配置进度文案 (来自 automation onStatus) */
    permissionStatusMsg?: string;
    appId?: string;
    brand?: 'feishu' | 'lark';
    cliId?: string;
    workingDir?: string;
    addedBotIndex?: number;
    permission?: BotOnboardingPermission;
    /** 自动配置失败时的手动权限步骤 (深链) */
    remainingSteps?: RemainingStep[];
    error?: string;
    message?: string;
}
/** 调用方 (dashboard) 已校验过的表单输入: CLI / 工作目录 / model. */
export interface BotOnboardingInput {
    cliId?: CliId;
    /** 通用启动前缀（如 "aiden x claude"）；aiden×* 选项解析所得，普通 CLI 为空。 */
    wrapperCli?: string;
    workingDir?: string;
    model?: string;
}
type RegisterAppFn = (opts?: RegisterAppOptions) => Promise<RegisterAppResult>;
type ValidateCredentialsFn = (appId: string, appSecret: string, brand?: 'feishu' | 'lark') => Promise<CredentialValidation | {
    ok: true;
}>;
type AutomateOpenPlatformFn = (opts: OpenPlatformAutomationOptions) => Promise<OpenPlatformAutomationResult>;
export interface BotOnboardingManagerOptions {
    botsJsonPath: string;
    registerApp?: RegisterAppFn;
    validateCredentials?: ValidateCredentialsFn;
    automateOpenPlatform?: AutomateOpenPlatformFn;
    renderQrDataUrl?: (url: string) => string;
    now?: () => number;
}
export interface BotOnboardingJob {
    id: string;
    done: Promise<void>;
}
export declare function renderQrSvgDataUrl(value: string): string;
export declare class BotOnboardingManager {
    private readonly opts;
    private readonly jobs;
    private readonly registerApp;
    private readonly validateCredentials;
    private readonly automateOpenPlatform;
    private readonly renderQrDataUrl;
    private readonly now;
    constructor(opts: BotOnboardingManagerOptions);
    start(input?: BotOnboardingInput): BotOnboardingJob;
    get(id: string): BotOnboardingSnapshot | undefined;
    private patch;
    private run;
    /**
     * 跑开放平台权限自动配置. 复用 setup 的 automateOpenPlatformSetup:
     * - 缓存命中 (~/.botmux/feishu-session.json 有效) → 静默自动配置, 不出二维码
     * - 否则 → 通过 onQrCode 抛出第二个二维码 (登录开放平台), 前端渲染让用户扫
     * - 成功 → completed + 权限摘要; 失败 → completed + 手动步骤 (buildRemainingSteps)
     *
     * 无论自动配置成败, bot 都已写入 bots.json, 所以终态恒为 'completed'.
     */
    private configurePermissions;
}
export {};
//# sourceMappingURL=bot-onboarding.d.ts.map