import { Disposable } from "../../../../../base/common/lifecycle.js"; import { type ICloudSandboxClientToken, type ICloudSandboxConnectionRequest } from "../../../../../platform/agentHost/common/cloudSandboxAgentHost.js"; import { ICloudSandboxApiService } from "../../../../../platform/agentHost/common/cloudSandboxAgentHost.service.js"; import { ILogService } from "../../../../../platform/log/common/log.service.js"; import { ICloudSandboxTelemetryService } from "./cloudSandboxTelemetry.service.js"; /** A broker may omit unchanged sealing material; a replacement key needs matching new ciphertext. */ export declare function mergeCloudSandboxConnectionToken(previous: ICloudSandboxClientToken, refreshed: ICloudSandboxClientToken): ICloudSandboxClientToken | undefined; /** Minimum delay between connection repairs or failed credential requests. */ export declare const MIN_CREDENTIAL_REFRESH_DELAY_MS = 30000; /** Maximum consecutive failed on-demand acquisitions, retained across protocol-client replacements. */ export declare const MAX_CONSECUTIVE_CREDENTIAL_REFRESH_FAILURES = 10; /** Mutable holder for the current Web PubSub credentials, read by the transport factory. */ export interface ICloudSandboxCreds { token: ICloudSandboxClientToken; } /** Retry bookkeeping retained by a staged sandbox connection across protocol-client replacements. */ export declare class CloudSandboxCredentialRefreshState { unhealthyCycles: number; lastRefreshAt: number | undefined; nextRetryAt: number | undefined; stopped: boolean; permanentFailure: boolean; permanentFailureStatus: number | undefined; requestFailures: number; requestFailureStartedAt: number | undefined; } /** * Acquires credentials on demand for connection repair and authentication, sharing requests and bounding retries. * Web PubSub token expiry governs admission to new sockets, not the lifetime of an established connection. */ export declare class CloudSandboxCredentialRefresher extends Disposable { private readonly _address; private readonly _request; private readonly _clientId; private readonly _creds; private readonly _refreshState; private readonly _apiService; private readonly _telemetry; private readonly _logService; private readonly _cts; private _refreshInFlight; constructor(_address: string, _request: ICloudSandboxConnectionRequest, _clientId: string, _creds: ICloudSandboxCreds, _refreshState: CloudSandboxCredentialRefreshState, _apiService: ICloudSandboxApiService, _telemetry: ICloudSandboxTelemetryService, _logService: ILogService); /** Share an in-flight refresh or refresh expired credentials before opening a replacement transport. */ ensureUnexpiredCredentials(): Promise; /** Repair connection setup even with a valid cached ticket, waiting for any refresh backoff or rate limit. */ refreshConnectionCredentials(): Promise; /** Renew authentication without falling back to the previously used sealed envelope. */ refreshAuthenticationCredentials(): Promise; private get _lifecycleContext(); private _ensureCredentials; private _hasUnexpiredCredentials; private _stop; /** Record a failed acquisition and its earliest retry time without scheduling a request. */ private _recordFailure; private _refresh; private _doRefresh; }