mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-12-03 03:29:51 +00:00
fix(models): keep getShortModelName unary for Array.map
CI typecheck failed: sessions-report maps getShortModelName, and the Extra High cycle Set was a second parameter. Array.map fed the index as `seen`. Cycle tracking stays on an internal helper. Display and alias behavior unchanged. No second Extra High.
This commit is contained in:
parent
d5ced78595
commit
827a41241c
2 changed files with 17 additions and 4 deletions
|
|
@ -994,7 +994,12 @@ function lookupShortName(id: string): string | undefined {
|
|||
return undefined
|
||||
}
|
||||
|
||||
export function getShortModelName(model: string, seen: Set<string> = new Set()): string {
|
||||
// Public API stays unary so Array.map/forEach cannot feed index as cycle state.
|
||||
export function getShortModelName(model: string): string {
|
||||
return shortModelName(model, new Set())
|
||||
}
|
||||
|
||||
function shortModelName(model: string, seen: Set<string>): string {
|
||||
if (autoModelNames[model]) return autoModelNames[model]
|
||||
if (seen.has(model)) {
|
||||
const leaf = model.includes('/') ? model.slice(model.lastIndexOf('/') + 1) : model
|
||||
|
|
@ -1005,13 +1010,13 @@ export function getShortModelName(model: string, seen: Set<string> = new Set()):
|
|||
// User aliases win over built-in display names. A remap of gpt-4o must
|
||||
// show the target, not "GPT-4o".
|
||||
if (Object.hasOwn(userAliases, model)) {
|
||||
return getShortModelName(userAliases[model]!, seen)
|
||||
return shortModelName(userAliases[model]!, seen)
|
||||
}
|
||||
|
||||
const stripped = getCanonicalName(model)
|
||||
if (stripped !== model) {
|
||||
if (Object.hasOwn(userAliases, stripped)) {
|
||||
return getShortModelName(userAliases[stripped]!, seen)
|
||||
return shortModelName(userAliases[stripped]!, seen)
|
||||
}
|
||||
const knownStripped = lookupShortName(stripped)
|
||||
if (knownStripped && !Object.hasOwn(BUILTIN_ALIASES, stripped) && !Object.hasOwn(BUILTIN_ALIASES, stripped.toLowerCase())) {
|
||||
|
|
@ -1028,7 +1033,7 @@ export function getShortModelName(model: string, seen: Set<string> = new Set()):
|
|||
if (!segment || seen.has(segment) || segment === stripped) {
|
||||
return lookupShortName(segment) ?? segment
|
||||
}
|
||||
return getShortModelName(segment, seen)
|
||||
return shortModelName(segment, seen)
|
||||
}
|
||||
return lookupShortName(canonical) ?? canonical
|
||||
}
|
||||
|
|
|
|||
|
|
@ -776,6 +776,14 @@ describe('observed provider model aliases', () => {
|
|||
expect(getShortModelName('cline-pass/mimo-v2.5-pro')).toBe('MiMo v2.5 Pro')
|
||||
})
|
||||
|
||||
it('stays unary so Array.map cannot feed the index as cycle state', () => {
|
||||
expect(['mimo-v2.5', 'gpt-4o', 'cline-pass/mimo-v2.5-pro'].map(getShortModelName)).toEqual([
|
||||
'mimo-v2.5',
|
||||
'GPT-4o',
|
||||
'MiMo v2.5 Pro',
|
||||
])
|
||||
})
|
||||
|
||||
it('does not map dated Qwen3 Max to a reseller price without provider context', () => {
|
||||
expect(getModelCosts('qwen3-max-2026-01-23')).toBeNull()
|
||||
expect(calculateCost('qwen3-max-2026-01-23', 1_000_000, 1_000_000, 0, 0, 0)).toBe(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue