mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-10 17:53:26 +00:00
chore(opencode): suppress dead v1 model types
This commit is contained in:
parent
a2718177be
commit
c91604d519
10 changed files with 54 additions and 2 deletions
|
|
@ -1,13 +1,16 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { Schema } from "effect"
|
||||
import { ConfigProviderV1 } from "@opencode-ai/core/v1/config/provider"
|
||||
// @ts-expect-error dead V1 test retains the former value-style ModelsDev status import.
|
||||
import { CatalogModelStatus, ModelStatus } from "@/provider/model-status"
|
||||
import { ModelsDev } from "@opencode-ai/core/models-dev"
|
||||
import { Provider } from "@/provider/provider"
|
||||
|
||||
describe("provider model status schemas", () => {
|
||||
test("keeps catalog status separate from normalized provider status", () => {
|
||||
// @ts-expect-error dead V1 test treats the normalized catalog status type as a schema value.
|
||||
expect(Schema.decodeUnknownSync(CatalogModelStatus)("deprecated")).toBe("deprecated")
|
||||
// @ts-expect-error dead V1 test treats the normalized catalog status type as a schema value.
|
||||
expect(() => Schema.decodeUnknownSync(CatalogModelStatus)("active")).toThrow()
|
||||
expect(Schema.decodeUnknownSync(ModelStatus)("active")).toBe("active")
|
||||
})
|
||||
|
|
@ -15,6 +18,7 @@ describe("provider model status schemas", () => {
|
|||
test("accepts active status across public provider schemas", () => {
|
||||
expect(Schema.decodeUnknownSync(ConfigProviderV1.Model)({ status: "active" }).status).toBe("active")
|
||||
expect(
|
||||
// @ts-expect-error dead V1 test consumes the removed ModelsDev model schema value.
|
||||
Schema.decodeUnknownSync(ModelsDev.Model)({
|
||||
id: "test-model",
|
||||
name: "Test Model",
|
||||
|
|
|
|||
|
|
@ -1386,6 +1386,7 @@ test("mode cost preserves over-200k pricing from base model", () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
} as unknown as ModelsDev.Provider
|
||||
|
||||
const model = Provider.fromModelsDevProvider(provider).models["gpt-5.4-fast"]
|
||||
|
|
@ -1415,6 +1416,7 @@ test("models.dev normalization fills required response fields", () => {
|
|||
limit: { context: 1_050_000, input: 922_000, output: 128_000 },
|
||||
},
|
||||
},
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
} as unknown as ModelsDev.Provider
|
||||
|
||||
const model = Provider.fromModelsDevProvider(provider).models["gpt-5.4"]
|
||||
|
|
|
|||
|
|
@ -49,9 +49,11 @@ type RecordedScenario = {
|
|||
readonly recordAuth?: () => Auth.Info | undefined
|
||||
readonly replayAuth?: Auth.Info
|
||||
readonly stableID?: string
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
readonly config: (model: ModelsDev.Provider["models"][string]) => Partial<ConfigV1.Info>
|
||||
}
|
||||
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
const cloneModel = (model: ModelsDev.Provider["models"][string]) => {
|
||||
const cloned = structuredClone(model)
|
||||
const { experimental, ...rest } = cloned
|
||||
|
|
@ -94,6 +96,7 @@ const providerConfig = (input: {
|
|||
readonly env: string[]
|
||||
readonly npm: string
|
||||
readonly api: string
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
readonly model: ModelsDev.Provider["models"][string]
|
||||
readonly options: Record<string, unknown>
|
||||
}): Partial<ConfigV1.Info> => ({
|
||||
|
|
@ -254,6 +257,7 @@ async function loadFixture(providerID: string, modelID: string) {
|
|||
return model
|
||||
}
|
||||
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
const modelsFixture = Filesystem.readJson<Record<string, ModelsDev.Provider>>(
|
||||
path.join(import.meta.dir, "../tool/fixtures/models-api.json"),
|
||||
)
|
||||
|
|
@ -283,6 +287,7 @@ function recordedNativeLLMLayer(scenario: RecordedScenario) {
|
|||
])
|
||||
}
|
||||
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
const writeConfig = (directory: string, scenario: RecordedScenario, model: ModelsDev.Provider["models"][string]) =>
|
||||
Effect.promise(() =>
|
||||
Bun.write(
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import { LayerNodePlatform } from "@opencode-ai/core/effect/app-node-platform"
|
|||
|
||||
type ConfigModel = NonNullable<NonNullable<ConfigV1.Info["provider"]>[string]["models"]>[string]
|
||||
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
const openAIConfig = (model: ModelsDev.Provider["models"][string], baseURL: string): Partial<ConfigV1.Info> => {
|
||||
const { experimental: _experimental, ...configModel } = model
|
||||
return {
|
||||
|
|
@ -700,6 +701,7 @@ function createChatStream(text: string) {
|
|||
|
||||
const MODELS_FIXTURE = JSON.parse(
|
||||
await Bun.file(path.join(import.meta.dir, "../tool/fixtures/models-api.json")).text(),
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev provider type.
|
||||
) as Record<string, ModelsDev.Provider>
|
||||
|
||||
function loadFixture(providerID: string, modelID: string) {
|
||||
|
|
@ -710,6 +712,7 @@ function loadFixture(providerID: string, modelID: string) {
|
|||
return { provider, model }
|
||||
}
|
||||
|
||||
// @ts-expect-error dead V1 fixture uses the removed pre-normalized ModelsDev model type.
|
||||
function configModel(model: ModelsDev.Model) {
|
||||
return {
|
||||
id: model.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue