model-status.test.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { describe, expect, test } from "bun:test"
  2. import { Schema } from "effect"
  3. import { ConfigProviderV1 } from "@kirincode-ai/core/v1/config/provider"
  4. import { CatalogModelStatus, ModelStatus } from "@/provider/model-status"
  5. import { ModelsDev } from "@kirincode-ai/core/models-dev"
  6. import { Provider } from "@/provider/provider"
  7. describe("provider model status schemas", () => {
  8. test("keeps catalog status separate from normalized provider status", () => {
  9. expect(Schema.decodeUnknownSync(CatalogModelStatus)("deprecated")).toBe("deprecated")
  10. expect(() => Schema.decodeUnknownSync(CatalogModelStatus)("active")).toThrow()
  11. expect(Schema.decodeUnknownSync(ModelStatus)("active")).toBe("active")
  12. })
  13. test("accepts active status across public provider schemas", () => {
  14. expect(Schema.decodeUnknownSync(ConfigProviderV1.Model)({ status: "active" }).status).toBe("active")
  15. expect(
  16. Schema.decodeUnknownSync(ModelsDev.Model)({
  17. id: "test-model",
  18. name: "Test Model",
  19. release_date: "2026-01-01",
  20. attachment: false,
  21. reasoning: false,
  22. temperature: true,
  23. tool_call: true,
  24. limit: { context: 128000, output: 8192 },
  25. }).status,
  26. ).toBeUndefined()
  27. expect(
  28. Schema.decodeUnknownSync(Provider.Model)({
  29. id: "test-model",
  30. providerID: "test-provider",
  31. api: {
  32. id: "test-model",
  33. url: "",
  34. npm: "@ai-sdk/openai-compatible",
  35. },
  36. name: "Test Model",
  37. capabilities: {
  38. temperature: true,
  39. reasoning: false,
  40. attachment: false,
  41. toolcall: true,
  42. input: { text: true, audio: false, image: false, video: false, pdf: false },
  43. output: { text: true, audio: false, image: false, video: false, pdf: false },
  44. interleaved: false,
  45. },
  46. cost: {
  47. input: 0,
  48. output: 0,
  49. cache: { read: 0, write: 0 },
  50. },
  51. limit: { context: 128000, output: 8192 },
  52. status: "active",
  53. options: {},
  54. headers: {},
  55. release_date: "2026-01-01",
  56. }).status,
  57. ).toBe("active")
  58. })
  59. })