import type { DevToolsSys } from "../types"; import type { CLIArgs } from "./index"; import type { Feature } from "#ai-utils"; export type AuthStatusEvent = { type: "auth-url"; url: string; name: string; } | { type: "auth-waiting"; name: string; } | { type: "auth-success"; name: string; } | { type: "auth-error"; name: string; message: string; }; export interface CredentialsOptions { forceSpaceId?: string; builderPublicKey?: boolean; builderPrivateKey?: boolean; /** * `always`: Figma auth will be required even if Figma credentials have already been set. * `if-unset`: Figma auth will be required only if Figma credentials have not been set. * `undefined` (default): Figma auth will never be required. * */ requireFigmaAuth?: "always" | "if-unset"; /** * If `true`, Builder.io auth will be required even if Builder.io credentials have * already been set. */ force?: boolean; /** * If `true`, suppresses all stdout output (clack log, spinner, select). * Use with `onAuthStatus` so the caller can own rendering. */ silent?: boolean; /** * Callback for auth status events when `silent` is true. */ onAuthStatus?: (event: AuthStatusEvent) => void; /** * `user` (default): credentials are stored in the user's home directory * (`~/.builder/config/data.json`) and apply to all projects. * `local`: credentials are stored in the project directory (legacy behavior). */ scope?: "local" | "user"; } export interface FigmaAuth { access_token: string; oauth: boolean; } export interface BuilderCodegenUsage { total: number | undefined; fast: number | undefined; quality: number | undefined; features?: Feature[]; limits?: { aiGeneration: number; aiGenerationContextWindow: number; }; } export interface BuilderAuth { privateKey: string; spaceId: string; spaceName: string; userId: string; } export declare const isCI: (args: CLIArgs) => boolean; export interface Credentials { figmaAuth?: FigmaAuth; builderPublicKey?: string; builderPrivateKey?: string; spaceName?: string; userId?: string; timestamp?: string; } export declare const readCredentials: (sys: DevToolsSys, args: CLIArgs, scope?: "local" | "user") => { spaceName: string | undefined; userId: string | undefined; builderPublicKey: string | undefined; builderPrivateKey: string | undefined; figmaAuth: FigmaAuth | undefined; timestamp: string | undefined; }; export declare const getCredentials: (sys: DevToolsSys, args: CLIArgs, opts: CredentialsOptions) => Promise; interface SilentAuthOptions { silent: boolean; onAuthStatus?: (event: AuthStatusEvent) => void; } export declare function getFigmaAuth(sys: DevToolsSys, silentOpts?: SilentAuthOptions): Promise; export declare function getBuilderCodegenUsage(builderPublicKey: string, builderPrivateKey: string): Promise; export declare function getBuilderAuth(sys: DevToolsSys, preferSpaceId?: string, silentOpts?: SilentAuthOptions): Promise; export declare function storeCredentials(sys: DevToolsSys, credentials: Credentials, scope?: "local" | "user"): void; export declare function clearCredentials(sys: DevToolsSys, scope?: "local" | "user"): boolean; export {};