/** * Network Policy Manager - Network Isolation for Code-Mode * Phase 4: Prevent data exfiltration via network * Phase 4.1: Runtime permissions via elicitations * * Security Model: * - Worker threads have NO direct network access * - All network requests go through main thread * - Whitelist-based URL filtering * - Runtime permission prompts for restricted access (elicitations) * - User consent required for private IPs and localhost */ /** * Elicitation function signature * Returns user's decision (approve/deny) */ export type ElicitationFunction = (params: { message: string; title?: string; options?: string[]; }) => Promise; /** * Network policy definition */ export interface NetworkPolicy { allowedDomains: string[]; blockedDomains: string[]; allowAllLocalhost: boolean; allowPrivateIPs: boolean; maxRequestSize: number; maxResponseSize: number; timeout: number; } /** * Network request from worker */ export interface NetworkRequest { url: string; method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; headers?: Record; body?: any; } /** * Network response to worker */ export interface NetworkResponse { status: number; statusText: string; headers: Record; body: any; } /** * Manages network access policies and controlled requests */ export declare class NetworkPolicyManager { private policy; private elicitationFunction?; private permissionCache; private enableElicitations; constructor(policy?: Partial, elicitationFunction?: ElicitationFunction); /** * Check if a URL is allowed by policy (with runtime permissions) */ isUrlAllowedAsync(url: string, context?: { mcpName?: string; bindingName?: string; }): Promise<{ allowed: boolean; reason?: string; }>; /** * Check if a URL is allowed by policy (sync, no elicitations) */ isUrlAllowed(url: string): { allowed: boolean; reason?: string; }; /** * Request network permission from user via elicitation */ private requestNetworkPermission; /** * Execute a controlled network request */ executeRequest(request: NetworkRequest, context?: { mcpName?: string; bindingName?: string; }): Promise; /** * Update policy at runtime */ updatePolicy(updates: Partial): void; /** * Get current policy */ getPolicy(): NetworkPolicy; /** * Add allowed domain */ allowDomain(domain: string): void; /** * Block domain */ blockDomain(domain: string): void; /** * Clear all cached permissions */ clearPermissions(): void; /** * Revoke permission for a specific URL */ revokePermission(url: string): boolean; /** * Get all cached permissions (for debugging/management) */ getPermissions(): Array<{ url: string; approved: boolean; permanent: boolean; }>; /** * Check if hostname matches allowed domains (supports wildcards) */ private isHostnameAllowed; /** * Check if hostname matches blocked domains */ private isHostnameBlocked; /** * Match hostname against domain pattern (supports wildcards) */ private matchDomainPattern; /** * Check if hostname is localhost */ private isLocalhost; /** * Check if hostname is a private IP */ private isPrivateIP; } /** * Default secure network policy */ export declare const SECURE_NETWORK_POLICY: NetworkPolicy; /** * Permissive policy for development */ export declare const PERMISSIVE_NETWORK_POLICY: NetworkPolicy; //# sourceMappingURL=network-policy.d.ts.map