import type { IDisposable } from "../../../base/common/lifecycle.js"; import type { AuthenticateParams, IAgentHostAuthTokenRequest } from "./agent.js"; import type { ProtectedResourceMetadata } from "./state/protocol/state.js"; import { ProtocolError } from "./state/sessionProtocol.js"; export interface IAgentHostCredentialPrincipal { readonly apiOrigin: string; readonly userId: string; } /** A validated credential captured for one connection and protected resource. */ export interface IAgentHostScopedCredential { readonly resource: string; readonly token: string; readonly expiresAt: number | undefined; readonly revision: number; readonly scopes?: readonly string[]; readonly isUsable?: () => boolean; } /** A host-owned credential source, never serialized through AHP. */ export interface IAgentHostCredentialSource { readonly principal?: IAgentHostCredentialPrincipal; getCredential(request: IAgentHostAuthTokenRequest): IAgentHostScopedCredential | undefined; } export interface IAgentHostAuthenticationScope extends IAgentHostCredentialSource, IDisposable { authenticate(params: AuthenticateParams, resources: readonly string[]): Promise; validate(params: AuthenticateParams): Promise; } /** A host-local deduplication key for captured grants, containing no tokens. */ export declare function getCapturedCredentialSourceKey(source: IAgentHostCredentialSource): string | undefined; export declare function normalizeAuthenticationScopes(scopes: readonly string[] | undefined): readonly string[]; export declare function parseCredentialPrincipal(serialized: string): IAgentHostCredentialPrincipal; export declare function isScopedCredentialUsable(credential: IAgentHostScopedCredential): boolean; export declare function isAuthRequiredError(error: unknown): error is ProtocolError; /** Captures an execution's credentials before awaiting work; later authentication cannot change them. */ export declare function captureCredentialSource(source: IAgentHostCredentialSource, resources: readonly ProtectedResourceMetadata[]): IAgentHostCredentialSource;