import * as net from 'net'; import type { SecretsBundle } from './bundles.js'; import { GLOBAL_HARNESS, bundleScopeChain } from './scope.js'; import { type SecretLease } from './lease.js'; export { GLOBAL_HARNESS, bundleScopeChain }; export declare const DEFAULT_TTL_MS: number; export declare function isSecretsBrokerEnabled(): boolean; export declare const META_CACHE_PREFIX = "!meta:"; export { SYNC_GET_CMD, SYNC_PING_CMD, SYNC_LOCK_CMD } from './sync-commands.js'; export declare function shouldSelfHealForUpgrade(persistent: boolean, storeSize: number, runningVersion: string, onDiskVersion: string): boolean; export declare function shouldTeardownVersionSkewedBroker(realHeldBundles: number): boolean; export interface StoredBundle { bundle: SecretsBundle; env: Record; expiresAt: number; harness: string; lease?: SecretLease; } export interface AgentStatusEntry { name: string; expiresAt: number; keyCount: number; harness: string; leaseId?: string; keys?: string[]; } export declare function rehydrateStore(now?: number, candidates?: readonly string[]): Map; export declare function secretsBrokerSocketPath(): string; export declare function readAgentToken(): string | null; export declare function uninstallSecretsAgentService(): Promise; export type Request = { cmd: 'ping'; } | { cmd: 'get'; name: string; harness?: string; token?: string; } | { cmd: 'load'; name: string; harness?: string; bundle: SecretsBundle; env: Record; ttlMs: number; lease?: SecretLease; token?: string; snapshotAt?: number; persist?: PersistHold; } | { cmd: 'lock'; name?: string; token?: string; } | { cmd: 'revoke'; leaseId: string; token?: string; } | { cmd: 'status'; token?: string; }; export type Response = { ok: true; cmd: 'ping'; version: number; cliVersion: string; } | { ok: true; cmd: 'get'; hit: false; } | { ok: true; cmd: 'get'; hit: true; bundle: SecretsBundle; env: Record; lease?: SecretLease; } | { ok: true; cmd: 'load'; } | { ok: true; cmd: 'lock'; wiped: number; } | { ok: true; cmd: 'revoke'; wiped: number; } | { ok: true; cmd: 'status'; entries: AgentStatusEntry[]; } | { ok: false; error: string; }; export declare function realBundleCount(store: Map): number; export declare function scopedBundleKey(name: string, harness: string): string; export interface PersistHold { sleepPersist: boolean; operation?: string; } export declare function handleAgentRequest(store: Map, req: Request, now?: number, evictedAt?: Map): Response; export declare function shouldWipeOnWatchEvent(chunk: string): boolean; export declare function handleAgentSleep(store: Map): void; export declare function isRequestAuthorized(req: Request, expectedToken: string | null): boolean; type BrokerConnectionHandler = (conn: net.Socket) => void; export declare function makeConnectionHandler(handle: (req: Request) => Response, token: () => string | null): BrokerConnectionHandler; export declare function releaseBrokerPid(): void; export declare function brokerPidAlive(): boolean; export declare function runSecretsAgent(opts?: { service?: boolean; }): Promise<{ close(): void | Promise; } | null>; export declare function closeServerBounded(server: net.Server, timeoutMs?: number): Promise; export declare function agentSocketExists(): boolean; export declare function syncClientLaunch(sub: string[], agentsBin?: string): { command: string; args: string[]; }; export declare function agentGetSync(name: string, harness?: string): { bundle: SecretsBundle; env: Record; lease?: SecretLease; } | null; export declare function lastLine(stdout: string): string; export declare function agentReachableSync(): boolean; export declare function agentEvictSync(name: string): void; export declare const SYNC_PAYLOAD_FD = 3; export declare const SYNC_PAYLOAD_ENV = "SECRETS_SYNC_PIPE_FD"; export declare function syncPayloadPipePresent(env?: NodeJS.ProcessEnv): boolean; export declare function runAgentGetSync(name: string, harness?: string): Promise; export declare function runAgentPingSync(): Promise; export declare function runAgentLockSync(name: string): Promise; export declare function agentGetMetaSync(nameSetHash: string): SecretsBundle[] | null; export declare function agentAutoLoadMetaSync(nameSetHash: string, bundles: SecretsBundle[], ttlMs: number): void; export declare function secretsAgentAutoEnabled(): boolean; export declare function secretsAgentDurable(): boolean; export declare const MIN_HOLD_MS: number; export declare const MAX_HOLD_MS: number; export declare function secretsHoldMs(): number; export declare function clampHoldMs(v: unknown): number; export declare function agentAutoLoadSync(name: string, bundle: SecretsBundle, env: Record, ttlMs: number, harness?: string, lease?: SecretLease, snapshotAt?: number, persist?: PersistHold): void; export declare function runAgentLoadFromStdin(): Promise; export declare function agentLoad(name: string, bundle: SecretsBundle, env: Record, ttlMs: number, harness?: string, lease?: SecretLease, snapshotAt?: number, persist?: PersistHold): Promise; export declare function agentLock(name?: string): Promise; export declare function agentStatus(): Promise; export declare function agentHoldStatus(): Promise<{ entries: AgentStatusEntry[]; held: Map; durableOnly: Map; }>; export declare function agentPing(): Promise<{ reachable: boolean; cliVersion?: string; }>; export declare function ensureAgentRunning(timeoutMs?: number): Promise;