feat(core): widen interleaved reasoning fields

This commit is contained in:
Aiden Cline 2026-07-18 11:11:45 -05:00
commit f28cc51f12
13 changed files with 140 additions and 37 deletions

View file

@ -41,11 +41,29 @@ export interface Ref extends Schema.Schema.Type<typeof Ref> {}
export const Family = Schema.String.pipe(Schema.brand("Model.Family"))
export type Family = typeof Family.Type
export type InterleavedField =
| "reasoning"
| "reasoning_content"
| "reasoning_text"
| "reasoning_details"
| (string & {})
export const InterleavedField: Schema.Codec<InterleavedField> = Schema.Union([
Schema.Literals(["reasoning", "reasoning_content", "reasoning_text", "reasoning_details"]),
Schema.String,
]).annotate({ identifier: "Model.InterleavedField" })
export type Interleaved = true | { readonly field: InterleavedField }
export const Interleaved: Schema.Codec<Interleaved> = Schema.Union([
Schema.Literal(true),
Schema.Struct({ field: InterleavedField }),
]).annotate({ identifier: "Model.Interleaved" })
export interface Capabilities extends Schema.Schema.Type<typeof Capabilities> {}
export const Capabilities = Schema.Struct({
tools: Schema.Boolean,
input: Schema.Array(Schema.String),
output: Schema.Array(Schema.String),
interleaved: Interleaved.pipe(optional),
}).annotate({ identifier: "Model.Capabilities" })
export interface Cost extends Schema.Schema.Type<typeof Cost> {}

View file

@ -1,4 +1,5 @@
import { describe, expect, test } from "bun:test"
import { Schema } from "effect"
import { Model } from "../src/model.js"
describe("Model.Ref", () => {
@ -20,3 +21,13 @@ describe("Model.Ref", () => {
expect(() => Model.Ref.parse("openai/gpt-5#high#extra")).toThrow()
})
})
describe("Model.Interleaved", () => {
test("accepts known and provider-specific fields", () => {
const decode = Schema.decodeUnknownSync(Model.Interleaved)
const fields = ["reasoning", "reasoning_content", "reasoning_text", "reasoning_details", "vendor_reasoning"]
for (const field of fields) expect(decode({ field })).toEqual({ field })
expect(decode(true)).toBe(true)
})
})