Skip to content

Commit da4bd03

Browse files
committed
refactor(provider): use Schema.MutableJson instead of hand-rolled recursive schema
effect-smol ships Schema.MutableJson and Schema.Json for exactly this case. The hand-rolled recursive JsonValue + cast is redundant.
1 parent f5cb313 commit da4bd03

1 file changed

Lines changed: 1 addition & 17 deletions

File tree

packages/opencode/src/provider/models.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,6 @@ const filepath = path.join(
2121
)
2222
const ttl = 5 * 60 * 1000
2323

24-
type JsonValue = string | number | boolean | null | { [key: string]: JsonValue } | JsonValue[]
25-
26-
// Declared with a mutable type because `Types.DeepMutable` cannot walk a
27-
// self-recursive readonly type — it trips TS2589. The derived Schema.Type
28-
// is readonly, so we cast at the Schema boundary.
29-
const JsonValue: Schema.Schema<JsonValue> = Schema.suspend(() =>
30-
Schema.Union([
31-
Schema.String,
32-
Schema.Number,
33-
Schema.Boolean,
34-
Schema.Null,
35-
Schema.Array(JsonValue),
36-
Schema.Record(Schema.String, JsonValue),
37-
]),
38-
) as Schema.Schema<JsonValue>
39-
4024
const Cost = Schema.Struct({
4125
input: Schema.Number,
4226
output: Schema.Number,
@@ -90,7 +74,7 @@ export const Model = Schema.Struct({
9074
cost: Schema.optional(Cost),
9175
provider: Schema.optional(
9276
Schema.Struct({
93-
body: Schema.optional(Schema.Record(Schema.String, JsonValue)),
77+
body: Schema.optional(Schema.Record(Schema.String, Schema.MutableJson)),
9478
headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),
9579
}),
9680
),

0 commit comments

Comments
 (0)