(value: SafeValue)
| 46 | } |
| 47 | |
| 48 | export function parseSafeFeatures(value: SafeValue): Set<SafetyFeature> { |
| 49 | const normalized = normalizeSafeValue(value); |
| 50 | if (!normalized) return new Set(); |
| 51 | |
| 52 | const features = new Set<SafetyFeature>(); |
| 53 | for (const part of normalized.split(",")) { |
| 54 | const token = part.trim().toLowerCase(); |
| 55 | if (!VALID_SAFE_TOKENS.has(token)) continue; |
| 56 | if (DISABLED_SAFE_TOKENS.has(token)) continue; |
| 57 | for (const feature of SAFETY_ALIASES[token] ?? [ |
| 58 | token as SafetyFeature, |
| 59 | ]) { |
| 60 | features.add(feature); |
| 61 | } |
| 62 | } |
| 63 | return features; |
| 64 | } |
| 65 | |
| 66 | export const SafeSchema = z |
| 67 | .union([z.string(), z.boolean()]) |
no test coverage detected