/** * What each key powers, and what stops or switches when it is removed. * * `describeSecretUsage` is static metadata for list payloads. The removal * preview adds request-time facts: which engine is the default, what it would * fall back to, and whether a shared key takes over a removed personal one. */ import { type SecretManagedBy, type SecretScope, type SecretUsage } from "./register.js"; /** App id used in effects that apply to every app. */ export declare const ALL_APPS = "all"; /** * Everything known to use `key` in this app: the agent's models for a * provider key, then registered uses, then uses implied by a managed key's * owner. Empty means no known consumer, not a failed lookup. */ export declare function describeSecretUsage(key: string): SecretUsage[]; export type SecretRemovalEffectCode = "models-leave-picker" | "default-model-switches" | "default-model-stops" | "shared-key-takes-over"; export interface SecretRemovalEffect { /** Workspace app id, or `"all"` when every app is affected. */ app: string; feature: string; /** English sentence for the "What happens" list. */ effect: string; /** Set on derived effects so a UI can render localized copy from `params`. */ code?: SecretRemovalEffectCode; params?: Record; /** Models that leave the picker, for `models-leave-picker`. */ models?: readonly string[]; } export type SharedKeyFallback = { status: "none"; } | { status: "shared"; source: "org" | "workspace" | "vault"; } /** The credential store could not be read, so the fallback is not known. */ | { status: "unknown"; error: string; }; export type OtherWorkspaceApps = /** Not part of a workspace; no other app reads these saved keys. */ { status: "standalone"; } /** Other apps in the workspace. Their features are not known here. */ | { status: "listed"; apps: { id: string; name: string; }[]; } | { status: "unavailable"; error: string; }; export interface SecretRemovalPreview { key: string; label?: string; registered: boolean; /** The stored row the removal targets. */ scope: SecretScope; /** Who loses the key: only the caller, or everyone in the organization. */ affects: "only-you" | "organization"; /** Set when the key can only be removed from its owner surface. */ managedBy?: SecretManagedBy; /** For a personal key: a shared key that keeps things working after removal. */ fallback: SharedKeyFallback; effects: SecretRemovalEffect[]; otherApps: OtherWorkspaceApps; } export interface PreviewSecretRemovalInput { key: string; /** Defaults to the registered scope, or `user` for ad-hoc keys. */ scope?: SecretScope; /** The app asking, used for the app's own default model. */ appId?: string; } /** * Whether the default model runs on Builder.io, and what it does once * Builder.io is disconnected. */ export type BuilderDefaultModel = { status: "elsewhere"; } | { status: "builder"; /** The default's model id. */ model: string; whenDisconnected: { status: "switches"; next: string; } | { status: "stops"; }; }; /** * The default model's side of disconnecting Builder.io for the current * request, found the same way as a provider key's removal. Throws when the * settings or credential store can't be read. */ export declare function describeBuilderDefaultModel(appId?: string): Promise; /** * What stops working, per app and feature, if the caller removes `key` at * `scope`. Runs as the request user; never reads or returns a secret value. */ export declare function previewSecretRemoval(input: PreviewSecretRemovalInput): Promise;