(base, override)
| 87 | const SYSTEM_PROMPT_KEYS = new Set(Object.keys(DEFAULTS.systemPrompts)); |
| 88 | |
| 89 | function deepMerge(base, override) { |
| 90 | if (!override || typeof override !== 'object') return base; |
| 91 | const out = { ...base }; |
| 92 | for (const [k, v] of Object.entries(override)) { |
| 93 | // Skip prototype-polluting keys — the JSON loaded here is user-writable |
| 94 | // via the dashboard, and a crafted key would otherwise corrupt every |
| 95 | // object in the process. |
| 96 | if (k === '__proto__' || k === 'constructor' || k === 'prototype') continue; |
| 97 | if (v && typeof v === 'object' && !Array.isArray(v)) { |
| 98 | out[k] = deepMerge(base[k] || {}, v); |
| 99 | } else { |
| 100 | out[k] = v; |
| 101 | } |
| 102 | } |
| 103 | return out; |
| 104 | } |
| 105 | |
| 106 | let _state = structuredClone(DEFAULTS); |
| 107 |
no outgoing calls
no test coverage detected