Files
oh-my-openagent/src/plugin/ultrawork-variant-availability.ts
YeonGyu-Kim 29e1136813 Guard ultrawork variant overrides with SDK metadata
Ultrawork now checks provider SDK metadata before forcing a variant, so unsupported variants are skipped instead of being written into the message state.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-11 15:33:05 +09:00

52 lines
1.1 KiB
TypeScript

import { normalizeSDKResponse } from "../shared"
type ModelDescriptor = {
providerID: string
modelID: string
}
type ProviderListClient = {
provider?: {
list?: () => Promise<unknown>
}
}
type ProviderModelMetadata = {
variants?: Record<string, unknown>
}
type ProviderListEntry = {
id?: string
models?: Record<string, ProviderModelMetadata>
}
type ProviderListData = {
all?: ProviderListEntry[]
}
export async function resolveValidUltraworkVariant(
client: unknown,
model: ModelDescriptor | undefined,
variant: string | undefined,
): Promise<string | undefined> {
if (!model || !variant) {
return undefined
}
const providerList = (client as ProviderListClient | null | undefined)?.provider?.list
if (typeof providerList !== "function") {
return undefined
}
const response = await providerList()
const data = normalizeSDKResponse<ProviderListData>(response, {})
const providerEntry = data.all?.find((entry) => entry.id === model.providerID)
const variants = providerEntry?.models?.[model.modelID]?.variants
if (!variants) {
return undefined
}
return Object.hasOwn(variants, variant) ? variant : undefined
}