import { type BundleValue, type SecretRef } from './index.js'; export type SecretsBackend = 'keychain' | 'file' | 'vault'; export declare function setKeychainAgentOnlyBypassForTest(bypass: boolean): void; export declare function bundleBackend(name: string): SecretsBackend; export declare const SECRET_TYPES: readonly ["api-key", "token", "password", "url", "database-url", "ssh-key", "certificate", "webhook", "note"]; export type SecretType = typeof SECRET_TYPES[number]; export interface VarMeta { type?: SecretType; expires?: string; note?: string; } export type SecretsPolicy = 'always' | 'hold' | 'never'; export interface SecretsBundle { name: string; description?: string; allow_exec?: boolean; backend?: SecretsBackend; policy?: SecretsPolicy; created_at?: string; updated_at?: string; last_used?: string; vars: Record; meta?: Record; } export interface LegacyBundleCandidate { name: string; file: string; keys: string[]; } export declare const BUNDLE_NAME_PATTERN: RegExp; export declare function isReservedShapeName(name: string): boolean; export declare function assertNotReservedShape(name: string, verb: string): void; export declare const ENV_KEY_PATTERN: RegExp; export declare const BUNDLE_KEY_PATTERN: RegExp; export declare const BUNDLE_META_PREFIX = "agents-cli.bundles."; export declare const RESERVED_ENV_NAMES: Set; export declare const AUTH_BUNDLE_NAME = "auth"; export declare const AUTH_BUNDLE_BACKEND: SecretsBackend; export declare const RESERVED_BUNDLE_NAMES: Set; export declare function isReservedBundleName(name: string): boolean; export declare class ReservedBundleWrongBackendError extends Error { readonly bundle: string; readonly backend: SecretsBackend; constructor(bundle: string, backend: SecretsBackend); } export declare function assertReservedBundleBackend(name: string, backend: SecretsBackend): void; export declare function inspectReservedAuthBundle(): { exists: boolean; backend: SecretsBackend | null; ok: boolean; }; export declare function assertFileBundleDecryptable(name: string, keys: string[]): void; export declare function bundleToEnvPrefix(name: string): string; export declare function isReservedEnvName(key: string): boolean; export declare function bundleKeyToEnvKey(key: string): string; export declare function isLoaderOrInterpreterEnv(name: string): boolean; export declare function sanitizeProcessEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv; export declare function validateBundleName(name: string): void; export declare function validateEnvKey(key: string): void; export declare function validateSecretType(t: string): asserts t is SecretType; export declare function validateExpiresFutureDated(iso: string): void; export declare function bundleExists(name: string): boolean; export declare class BundleUndecryptableError extends Error { constructor(message: string); } export declare function readBundleIfDecryptable(name: string): SecretsBundle | null; export declare function readBundle(name: string): SecretsBundle; export declare function secretsDefaultPolicy(): SecretsPolicy; export declare function bundlePolicy(bundle: SecretsBundle): SecretsPolicy; export interface WriteBundleOptions { skipBrokerEviction?: boolean; } export declare function shouldEvictAfterBundleWrite(skipRequested: boolean, noAgentEnv: string | undefined, backendOverridden: boolean): boolean; export declare function writeBundle(bundle: SecretsBundle, opts?: WriteBundleOptions): void; export declare function writeBundleWithItems(bundle: SecretsBundle, items: Map, opts?: WriteBundleOptions): void; export declare function deleteBundle(name: string): boolean; declare function readBundleMetaIndex(): string[] | null; declare function writeBundleMetaIndex(services: string[]): void; declare function addBundleToMetaIndex(name: string): void; declare function removeBundleFromMetaIndex(name: string): void; export declare const __metaIndexForTest: { read: typeof readBundleMetaIndex; write: typeof writeBundleMetaIndex; add: typeof addBundleToMetaIndex; remove: typeof removeBundleFromMetaIndex; }; export declare function healKeychainBundleMetadata(metaJsonByName: Map): number; export declare function healKeychainBundleMetadataAclOnce(metaJsonByName: Map, opts?: { complete?: boolean; }): void; export declare function listBundles(opts?: { known?: Iterable; }): SecretsBundle[]; export interface BundleEntryInfo { key: string; kind: 'literal' | 'keychain' | 'env' | 'file' | 'exec'; detail: string; } export declare function describeBundle(bundle: SecretsBundle): BundleEntryInfo[]; export declare function stampLastUsed(bundle: SecretsBundle): void; export interface ResolveBundleOptions { caller?: string; agent?: string; duration?: string; interactiveUnlock?: boolean; noAgent?: boolean; agentOnly?: boolean; keys?: string[]; allowExpired?: boolean; keyMode?: 'process' | 'storage'; prefetched?: PrefetchedKeychain; } export interface PrefetchedKeychain { requested: Set; values: Map; } export declare function canCacheResolvedEnv(bundle: SecretsBundle, selectedKeys: Set, keyMode: ResolveBundleOptions['keyMode']): boolean; export declare function filterAgentHitBySubsetAndExpiry(hit: { bundle: SecretsBundle; env: Record; }, opts: ResolveBundleOptions): { bundle: SecretsBundle; env: Record; }; export declare function assertRemoteBundleFlagsUnsupported(bundleName: string, host: string, opts: { keys?: string[]; allowExpired?: boolean; }, flagLabels: { keysFlag: string; allowExpiredFlag: string; }): void; export declare function resolveBundleEnv(bundle: SecretsBundle, _opts?: ResolveBundleOptions): Record; export { isHeadlessSecretsContext, isAgentInvocationContext } from './headless.js'; export declare function prefetchKeychainBundles(names: string[], opts: { agent: string; caller: string; duration: string; }): PrefetchedKeychain; export declare function readAndResolveBundleEnv(name: string, opts?: ResolveBundleOptions): { bundle: SecretsBundle; env: Record; }; export declare function humanUnlockDuration(ms: number): string; export declare function keychainRef(key: string): string; export interface RotateOptions { newValue: string; clearMeta?: boolean; meta?: Partial; } export declare function rotateBundleSecret(bundle: SecretsBundle, key: string, opts: RotateOptions): void; export declare function reAclBundleItems(bundle: SecretsBundle): void; export interface RenameOptions { force?: boolean; } export declare function renameBundle(oldName: string, newName: string, opts?: RenameOptions): void; export declare function bundleItemStore(backend: SecretsBackend | undefined, opts?: { noAcl?: boolean; }): { set(item: string, value: string): void; delete(item: string): boolean; get(item: string): string; has(item: string): boolean; }; export declare function keychainItemsForBundle(bundle: SecretsBundle): Array<{ key: string; item: string; }>; export declare function parseDotenv(content: string): Record; export declare function migrateLegacyBundles(confirmBundle: (candidate: LegacyBundleCandidate) => boolean | Promise): Promise; export type { SecretRef };