/** * Security utilities for handling untrusted external content. * * Aligned with OpenClaw's `src/security/external-content.ts`. * * External content (emails, webhooks, web search results, web-fetched pages) * must NEVER be directly interpolated into system prompts or treated as trusted * instructions. This module wraps such content with security boundaries and * strips LLM special tokens to prevent prompt injection and role spoofing. */ /** * Detect patterns in content that may indicate prompt injection attempts. * Returns matched pattern sources for logging/monitoring. */ export declare function detectSuspiciousPatterns(content: string): string[]; export type ExternalContentSource = 'email' | 'webhook' | 'api' | 'browser' | 'channel_metadata' | 'web_search' | 'web_fetch' | 'unknown'; export interface WrapExternalContentOptions { source: ExternalContentSource; sender?: string; subject?: string; includeWarning?: boolean; } /** * Wrap external untrusted content with security boundaries and warnings. * * Use this whenever processing content from external sources (emails, webhooks, * API calls from untrusted clients, web search/fetch results) before passing * to the LLM. * * @example * ```ts * const safeContent = wrapExternalContent(emailBody, { * source: 'email', * sender: 'user@example.com', * subject: 'Help request', * }); * ``` */ export declare function wrapExternalContent(content: string, options: WrapExternalContentOptions): string; /** * Wrap web search/fetch content with security markers. * Simpler wrapper for web tools that just need content wrapped. */ export declare function wrapWebContent(content: string, source?: 'web_search' | 'web_fetch'): string;