export declare const BOTMUX_REDIRECT_URL = "http://127.0.0.1:9768/callback";
export interface StoredCookie {
    name: string;
    value: string;
    domain: string;
    path: string;
    secure: boolean;
    httpOnly: boolean;
    hostOnly: boolean;
    expiresAt?: number;
    sameSite?: string;
}
export interface ScopeManifest {
    scopes?: {
        tenant?: string[];
        user?: string[];
    };
}
export interface OpenPlatformScopeEntry {
    id: string;
    name: string;
    bucket?: 'tenant' | 'user';
}
export interface MappedScopeIds {
    tenantScopeIds: string[];
    userScopeIds: string[];
    missingTenantScopes: string[];
    missingUserScopes: string[];
}
export type OpenPlatformAutomationResult = {
    ok: true;
    sessionFile: string;
    sessionSource: FeishuWebSessionSource;
    cookieCount: number;
    scopeCount: number;
    skippedScopeCount: number;
    scopeWarning?: string;
    versionId?: string;
} | {
    ok: false;
    reason: 'unsupported_brand' | 'missing_session' | 'invalid_session' | 'login_failed' | 'qr_expired' | 'timeout' | 'missing_csrf' | 'scope_mapping_failed' | 'network' | 'api_error';
    message: string;
    sessionFile?: string;
};
export interface OpenPlatformAutomationOptions {
    appId: string;
    brand?: 'feishu' | 'lark';
    sessionFilePath?: string;
    bytedcliFallbackSessionFilePath?: string;
    disableBytedcliFallback?: boolean;
    fetchImpl?: typeof fetch;
    scopeManifest?: ScopeManifest;
    pollIntervalMs?: number;
    maxWaitMs?: number;
    onQrCode?: (info: {
        qrText: string;
        qrPayload: string;
    }) => void | Promise<void>;
    onStatus?: (message: string) => void | Promise<void>;
}
export type FeishuWebSessionSource = 'botmux_cache' | 'qr_login' | 'bytedcli_fallback';
export type FeishuWebSessionFailureReason = 'login_failed' | 'qr_expired' | 'timeout' | 'network' | 'invalid_session';
export type FeishuWebSessionPrepareResult = {
    ok: true;
    sessionFile: string;
    source: FeishuWebSessionSource;
    cookies: StoredCookie[];
    cookieCount: number;
} | {
    ok: false;
    reason: FeishuWebSessionFailureReason;
    message: string;
    sessionFile: string;
    fallbackSessionFile?: string;
};
export interface FeishuWebSessionOptions {
    sessionFilePath?: string;
    bytedcliFallbackSessionFilePath?: string;
    disableBytedcliFallback?: boolean;
    fetchImpl?: typeof fetch;
    pollIntervalMs?: number;
    maxWaitMs?: number;
    onQrCode?: (info: {
        qrText: string;
        qrPayload: string;
    }) => void | Promise<void>;
    onStatus?: (message: string) => void | Promise<void>;
}
export declare function parseSetupOpenPlatformAutoFlag(argv: string[]): boolean;
export declare function botmuxFeishuSessionFilePath(configDir?: string): string;
export declare function bytedcliFeishuSessionFilePath(homeDir?: string): string;
export declare function readStoredCookiesFromSessionFile(filePath: string): StoredCookie[] | null;
export declare function readStoredCookiesFromBytedcliSession(filePath: string): StoredCookie[] | null;
export declare function writeStoredCookiesToSessionFile(filePath: string, cookies: StoredCookie[]): void;
export declare function getCookieHeader(cookies: StoredCookie[], requestUrl: string): string;
export declare function extractOpenPlatformCsrfToken(html: string): string | null;
export declare function extractOpenPlatformScopeEntries(payload: unknown): OpenPlatformScopeEntry[];
export declare function mapManifestScopesToOpenPlatformIds(manifest: ScopeManifest, catalog: OpenPlatformScopeEntry[]): MappedScopeIds;
export declare function buildScopeUpdatePayload(appId: string, mapped: Pick<MappedScopeIds, 'tenantScopeIds' | 'userScopeIds'>): {
    clientId: string;
    appScopeIDs: string[];
    userScopeIDs: string[];
    scopeIds: never[];
    operation: string;
    isDeveloperPanel: boolean;
};
export declare function buildSafeSettingPayload(appId: string): {
    clientId: string;
    redirectURL: string[];
};
export declare function buildAppVersionCreatePayload(appVersion: string, visibleMemberIds?: string[]): {
    appVersion: string;
    mobileDefaultAbility: string;
    pcDefaultAbility: string;
    changeLog: string;
    visibleSuggest: {
        departments: never[];
        members: string[];
        groups: never[];
        isAll: number;
    };
    applyReasonConfig: {
        apiPrivilegeNeedReason: boolean;
        contactPrivilegeNeedReason: boolean;
        dataPrivilegeReasonMap: {};
        visibleScopeNeedReason: boolean;
        apiPrivilegeReasonMap: {};
        contactPrivilegeReason: string;
        isDataPrivilegeExpandMap: {};
        visibleScopeReason: string;
        dataPrivilegeNeedReason: boolean;
        isAutoAudit: boolean;
        isContactExpand: boolean;
    };
    b2cShareSuggest: boolean;
    autoPublish: boolean;
    remark: string;
    blackVisibleSuggest: {
        departments: never[];
        members: never[];
        groups: never[];
        isAll: number;
    };
};
export declare function buildFeishuQrPayload(token: string): string;
export declare function mapFeishuQrPollingStatus(status: number | null): string;
export declare function prepareFeishuWebSession(options?: FeishuWebSessionOptions): Promise<FeishuWebSessionPrepareResult>;
export declare function automateOpenPlatformSetup(options: OpenPlatformAutomationOptions): Promise<OpenPlatformAutomationResult>;
//# sourceMappingURL=open-platform-automation.d.ts.map