UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

12 lines (11 loc) 503 B
//#region src/security/system-tags.ts const BRACKETED_SYSTEM_TAG_RE = /\[\s*(System\s*Message|System|Assistant|Internal)\s*\]/gi; const LINE_SYSTEM_PREFIX_RE = /^(\s*)System:(?=\s|$)/gim; /** * Neutralize user-controlled strings that spoof internal system markers. */ function sanitizeInboundSystemTags(input) { return input.replace(BRACKETED_SYSTEM_TAG_RE, (_match, tag) => `(${tag})`).replace(LINE_SYSTEM_PREFIX_RE, "$1System (untrusted):"); } //#endregion export { sanitizeInboundSystemTags as t };