* Check if a family alias is narrowed by more specific entries in the allowlist. * When the allowlist contains both "opus" and "opus-4-5", the specific entry * takes precedence — "opus" alone would be a wildcard, but "opus-4-5" narrows * it to only that version.
( family: string, allowlist: string[], )
| 63 | * it to only that version. |
| 64 | */ |
| 65 | function familyHasSpecificEntries( |
| 66 | family: string, |
| 67 | allowlist: string[], |
| 68 | ): boolean { |
| 69 | for (const entry of allowlist) { |
| 70 | if (isModelFamilyAlias(entry)) { |
| 71 | continue |
| 72 | } |
| 73 | // Check if entry is a version-qualified variant of this family |
| 74 | // e.g., "opus-4-5" or "claude-opus-4-5-20251101" for the "opus" family |
| 75 | // Must match at a segment boundary (followed by '-' or end) to avoid |
| 76 | // false positives like "opusplan" matching "opus" |
| 77 | const idx = entry.indexOf(family) |
| 78 | if (idx === -1) { |
| 79 | continue |
| 80 | } |
| 81 | const afterFamily = idx + family.length |
| 82 | if (afterFamily === entry.length || entry[afterFamily] === '-') { |
| 83 | return true |
| 84 | } |
| 85 | } |
| 86 | return false |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Check if a model is allowed by the availableModels allowlist in settings. |
no test coverage detected