diff --git a/packages/core/src/models-dev.ts b/packages/core/src/models-dev.ts index 3de39f670c..9cbc3fa73c 100644 --- a/packages/core/src/models-dev.ts +++ b/packages/core/src/models-dev.ts @@ -1,5 +1,5 @@ import path from "path" -import { Context, Duration, Effect, Layer, Option, Schedule } from "effect" +import { Context, Duration, Effect, Layer, Option, Schedule, Schema } from "effect" import { HttpClient, HttpClientRequest } from "effect/unstable/http" import { ModelsDev } from "@opencode-ai/schema/models-dev" import { Money } from "@opencode-ai/schema/money" @@ -15,7 +15,8 @@ import { httpClient } from "./effect/app-node-platform" import { ModelV2 } from "./model" import { ProviderV2 } from "./provider" -export type CatalogModelStatus = "alpha" | "beta" | "deprecated" +export const CatalogModelStatus = Schema.Literals(["alpha", "beta", "deprecated"]) +export type CatalogModelStatus = typeof CatalogModelStatus.Type const USER_AGENT = `opencode/${InstallationChannel}/${InstallationVersion}/${Flag.OPENCODE_CLIENT}` diff --git a/packages/opencode/src/provider/model-status.ts b/packages/opencode/src/provider/model-status.ts index ba0467d260..77bc329aee 100644 --- a/packages/opencode/src/provider/model-status.ts +++ b/packages/opencode/src/provider/model-status.ts @@ -1,6 +1,5 @@ import { Schema } from "effect" -// @ts-expect-error dead V1 retains the former value-style ModelsDev status re-export. export { CatalogModelStatus } from "@opencode-ai/core/models-dev" export const ModelStatus = Schema.Literals(["alpha", "beta", "deprecated", "active"]) diff --git a/packages/opencode/test/provider/model-status.test.ts b/packages/opencode/test/provider/model-status.test.ts index 2bfbffe1e8..3682ebe5a8 100644 --- a/packages/opencode/test/provider/model-status.test.ts +++ b/packages/opencode/test/provider/model-status.test.ts @@ -1,16 +1,13 @@ 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") })