/** * Neutral authorization contract for privileged actions initiated by any host * surface. Executors remain surface-specific; this module owns only the * decision request/result vocabulary and its untrusted-input decoder. */ export declare const TRUST_BOUNDARY_VERSION: 1; export type TrustSurface = 'acp' | 'webui' | 'hq' | 'desktop' | 'cli' | 'tui' | 'plugin' | 'internal'; export type TrustActorKind = 'user' | 'agent' | 'subagent' | 'plugin' | 'remote-client' | 'system'; export type TrustRisk = 'low' | 'elevated' | 'high' | 'critical'; export type TrustAuthMethod = 'interactive' | 'session' | 'bearer-token' | 'scoped-token' | 'local-process'; export type TrustAttribute = string | number | boolean | null; export interface TrustActor { readonly kind: TrustActorKind; readonly id?: string | undefined; readonly sessionId?: string | undefined; } export interface TrustSubject { readonly kind: 'path' | 'command' | 'process' | 'resource' | 'role' | 'url' | 'custom'; readonly id: string; readonly attributes?: Readonly> | undefined; } export interface TrustScope { readonly projectId?: string | undefined; readonly sessionId?: string | undefined; readonly cwd?: string | undefined; readonly constraints?: Readonly> | undefined; } export interface TrustAuthContext { readonly method: TrustAuthMethod; readonly principalId?: string | undefined; readonly tokenId?: string | undefined; readonly expiresAt?: string | undefined; readonly claims?: Readonly> | undefined; } export interface TrustBoundaryRequest { readonly version: typeof TRUST_BOUNDARY_VERSION; readonly requestId: string; readonly actor: TrustActor; readonly surface: TrustSurface; /** Namespaced semantic action, for example `filesystem.write` or `hq.control`. */ readonly capability: string; readonly subject: TrustSubject; readonly risk: TrustRisk; readonly scope: TrustScope; readonly authContext?: TrustAuthContext | undefined; readonly metadata?: Readonly> | undefined; } export interface TrustAllowDecision { readonly kind: 'allow'; readonly reason: string; readonly policyId?: string | undefined; } export interface TrustDenyDecision { readonly kind: 'deny'; readonly reason: string; readonly policyId?: string | undefined; } export interface TrustConfirmDecision { readonly kind: 'confirm'; readonly reason: string; readonly prompt: string; readonly policyId?: string | undefined; } export interface TrustScopedTokenDecision { readonly kind: 'scoped-token'; readonly reason: string; readonly token: string; readonly tokenId: string; readonly expiresAt: string; readonly capabilities: readonly string[]; readonly scope: TrustScope; readonly policyId?: string | undefined; } export type TrustBoundaryDecision = TrustAllowDecision | TrustDenyDecision | TrustConfirmDecision | TrustScopedTokenDecision; export interface TrustBoundary { evaluate(request: TrustBoundaryRequest): Promise; } export interface TrustBoundaryAuditEntry { readonly request: TrustBoundaryRequest; readonly decision: TrustBoundaryDecision; readonly evaluatedAt: string; } export interface CompatibilityTrustBoundaryOptions { readonly policyId?: string | undefined; readonly audit?: ((entry: TrustBoundaryAuditEntry) => void | Promise) | undefined; /** * When {@code true} (the default), the compatibility boundary denies * `critical` risk actions whose actor is `remote-client`. This closes * the trust gap where any WebSocket client that can reach the server * could shut down the host or kill all tracked processes, even though * the boundary is supposed to be a "trusted host" policy. Hosts that * genuinely need the old unconditional-allow behaviour can set this to * {@code false}. */ readonly denyCriticalRiskRemoteClient?: boolean | undefined; } /** * Migration policy for trusted hosts that historically executed privileged * actions directly. It preserves that behaviour while ensuring every action * crosses the shared request/decision contract and can be audited. Hosts can * replace it with a stricter policy without changing their executors. * * By default, `critical` risk requests from `remote-client` actors are * denied to prevent unauthenticated or insufficiently trusted WebSocket * clients from executing host-wide destructive operations (host shutdown, * kill-all processes). Other risk levels (`high`, `elevated`, `low`) and * local/user actors are unaffected — this preserves the migration contract * for legitimate privileged features like terminal spawning and individual * process kills. */ export declare function createCompatibilityTrustBoundary(options?: CompatibilityTrustBoundaryOptions): TrustBoundary; export declare function isTrustDecisionAllowed(decision: TrustBoundaryDecision): boolean; export interface TrustDecodeIssue { readonly path: string; readonly message: string; } export type TrustDecodeResult = { readonly ok: true; readonly value: T; } | { readonly ok: false; readonly issues: readonly TrustDecodeIssue[]; }; export declare function decodeTrustBoundaryRequest(input: unknown): TrustDecodeResult; export declare function decodeTrustBoundaryDecision(input: unknown): TrustDecodeResult; //# sourceMappingURL=trust-boundary.d.ts.map