def44338ff
Updates the canonical Anthropic Opus model in every fallback chain (sisyphus, oracle, prometheus, metis, momus, visual-engineering, ultrabrain, deep, artistry, unspecified-high), the unspecified-high category default, the think-mode HIGH_VARIANT_MAP, the Claude Code alias map, the claude-thinking legacy alias, the context-limit GA regex, and event.ts fallback strings. Widens supportsCachedAnthropicLimit to accept both claude-*-4-6 and claude-*-4-7 so the 1M context cache still applies across the bump. Regenerates the bundled model-capabilities snapshot from models.dev and the model-fallback snapshot to match the new source output.
187 lines
4.8 KiB
TypeScript
187 lines
4.8 KiB
TypeScript
import { describe, expect, spyOn, test } from "bun:test"
|
|
import * as dbOverrideModule from "./ultrawork-db-model-override"
|
|
import { applyUltraworkModelOverrideOnMessage } from "./ultrawork-model-override"
|
|
import { resolveValidUltraworkVariant } from "./ultrawork-variant-availability"
|
|
|
|
describe("resolveValidUltraworkVariant", () => {
|
|
function createClient(models: Record<string, Record<string, unknown>>) {
|
|
return {
|
|
provider: {
|
|
list: async () => ({
|
|
data: {
|
|
all: Object.entries(models).map(([providerID, providerModels]) => ({
|
|
id: providerID,
|
|
models: providerModels,
|
|
})),
|
|
},
|
|
}),
|
|
},
|
|
}
|
|
}
|
|
|
|
test("#given provider sdk metadata #when variant exists #then returns variant", async () => {
|
|
// given
|
|
const client = createClient({
|
|
anthropic: {
|
|
"claude-opus-4-7": {
|
|
variants: {
|
|
max: {},
|
|
high: {},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
// when
|
|
const result = await resolveValidUltraworkVariant(
|
|
client,
|
|
{ providerID: "anthropic", modelID: "claude-opus-4-7" },
|
|
"max",
|
|
)
|
|
|
|
// then
|
|
expect(result).toBe("max")
|
|
})
|
|
|
|
test("#given provider sdk metadata #when variant does not exist #then returns undefined", async () => {
|
|
// given
|
|
const client = createClient({
|
|
anthropic: {
|
|
"claude-opus-4-7": {
|
|
variants: {
|
|
high: {},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
// when
|
|
const result = await resolveValidUltraworkVariant(
|
|
client,
|
|
{ providerID: "anthropic", modelID: "claude-opus-4-7" },
|
|
"max",
|
|
)
|
|
|
|
// then
|
|
expect(result).toBeUndefined()
|
|
})
|
|
})
|
|
|
|
describe("applyUltraworkModelOverrideOnMessage variant guard", () => {
|
|
function createClient(models: Record<string, Record<string, unknown>>) {
|
|
return {
|
|
provider: {
|
|
list: async () => ({
|
|
data: {
|
|
all: Object.entries(models).map(([providerID, providerModels]) => ({
|
|
id: providerID,
|
|
models: providerModels,
|
|
})),
|
|
},
|
|
}),
|
|
},
|
|
}
|
|
}
|
|
|
|
test("#given ultrawork variant missing from target model #when override applies #then skips forced variant change", async () => {
|
|
// given
|
|
const client = createClient({
|
|
anthropic: {
|
|
"claude-opus-4-7": {
|
|
variants: {
|
|
high: {},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
const dbOverrideSpy = spyOn(dbOverrideModule, "scheduleDeferredModelOverride").mockImplementation(() => {})
|
|
|
|
const config = {
|
|
agents: {
|
|
sisyphus: {
|
|
ultrawork: {
|
|
model: "anthropic/claude-opus-4-7",
|
|
variant: "max",
|
|
},
|
|
},
|
|
},
|
|
} as Parameters<typeof applyUltraworkModelOverrideOnMessage>[0]
|
|
|
|
const output = {
|
|
message: {
|
|
id: "msg_123",
|
|
model: { providerID: "anthropic", modelID: "claude-sonnet-4-6" },
|
|
} as Record<string, unknown>,
|
|
parts: [{ type: "text", text: "ultrawork do something" }],
|
|
}
|
|
|
|
// when
|
|
await applyUltraworkModelOverrideOnMessage(
|
|
config,
|
|
"sisyphus",
|
|
output,
|
|
{ showToast: async () => {} },
|
|
undefined,
|
|
client,
|
|
)
|
|
|
|
// then
|
|
expect(output.message["variant"]).toBeUndefined()
|
|
expect(output.message["thinking"]).toBeUndefined()
|
|
expect(dbOverrideSpy).toHaveBeenCalledWith(
|
|
"msg_123",
|
|
{ providerID: "anthropic", modelID: "claude-opus-4-7" },
|
|
undefined,
|
|
)
|
|
dbOverrideSpy.mockRestore()
|
|
})
|
|
|
|
test("#given variant only ultrawork config without valid current model variant #when override applies #then skips override entirely", async () => {
|
|
// given
|
|
const client = createClient({
|
|
anthropic: {
|
|
"claude-sonnet-4-6": {
|
|
variants: {
|
|
high: {},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
const dbOverrideSpy = spyOn(dbOverrideModule, "scheduleDeferredModelOverride").mockImplementation(() => {})
|
|
|
|
const config = {
|
|
agents: {
|
|
sisyphus: {
|
|
ultrawork: {
|
|
variant: "max",
|
|
},
|
|
},
|
|
},
|
|
} as Parameters<typeof applyUltraworkModelOverrideOnMessage>[0]
|
|
|
|
const output = {
|
|
message: {
|
|
model: { providerID: "anthropic", modelID: "claude-sonnet-4-6" },
|
|
} as Record<string, unknown>,
|
|
parts: [{ type: "text", text: "ultrawork do something" }],
|
|
}
|
|
|
|
// when
|
|
await applyUltraworkModelOverrideOnMessage(
|
|
config,
|
|
"sisyphus",
|
|
output,
|
|
{ showToast: async () => {} },
|
|
undefined,
|
|
client,
|
|
)
|
|
|
|
// then
|
|
expect(output.message["variant"]).toBeUndefined()
|
|
expect(output.message["thinking"]).toBeUndefined()
|
|
expect(dbOverrideSpy).not.toHaveBeenCalled()
|
|
expect(output.message.model).toEqual({ providerID: "anthropic", modelID: "claude-sonnet-4-6" })
|
|
dbOverrideSpy.mockRestore()
|
|
})
|
|
})
|