/** * Lifecycle for the optional egress guard: bind the loopback listener, prove * the wiring, record decisions, and expose a count-only view to `/guard egress`. * The listener fills DSH's existing `HTTPS_PROXY` seam; it is not a sandbox and * never inspects content. * @module dsh-sensitive-guard/egress */ import type { AuditLog } from '../audit.js'; import type { GuardConfig } from '../config.js'; import type { GuardMode, Logger } from '../contracts.js'; import { type CanaryResult } from './canary.js'; /** The loopback address the guard always binds; never a wildcard. */ export declare const EGRESS_HOST = "127.0.0.1"; export interface EgressCounts { tunnels: number; allowed: number; denied: number; bytesIn: number; bytesOut: number; } /** One recent destination, host and port only. */ export interface EgressRecent { host: string; port: number; decision: 'allow' | 'deny'; enforced: boolean; reason: string; } export interface EgressSnapshot { enabled: true; bound: boolean; host: string; port: number; mode: GuardMode; unknown: 'allow' | 'deny'; failClosed: boolean; allowRules: number; denyRules: number; upstream?: string; /** Sanitized proxy value this process was launched with, if any. */ proxyEnv?: string; /** True when that value names this listener's host and port. */ envMatches: boolean; counts: EgressCounts; recent: EgressRecent[]; lastCanary?: CanaryResult; } export interface EgressController { readonly port: number; readonly bound: boolean; snapshot(): EgressSnapshot; canary(): Promise; close(): Promise; } export interface EgressMountOptions { config: GuardConfig['egress']; modeOf: () => GuardMode; audit: AuditLog; logger: Logger; /** Injectable environment for tests. */ env?: NodeJS.ProcessEnv; } /** * Read the HTTPS proxy value DSH resolved for this process. Lowercase wins, as * in `@deepseek-ai/dsh-http-proxy`; a blank value counts as unset. */ export declare function resolveProxyEnv(env?: NodeJS.ProcessEnv): string | undefined; /** Strip userinfo before a proxy value reaches a log or the model contract. */ export declare function sanitizeProxyValue(value: string): string; /** True when a proxy value points at the loopback listener on this port. */ export declare function proxyEnvMatches(value: string | undefined, port: number): boolean; /** * Mount the guard. Rejects when the listener cannot bind and `failClosed` is * on, which turns a misconfigured port into a failed plugin instead of silent * no coverage. The returned controller's disposer closes the listener. */ export declare function mountEgress(options: EgressMountOptions): Promise; //# sourceMappingURL=index.d.ts.map