Skip to content

Commit 9e8274d

Browse files
authored
Remove internal Zod schemas (#26974)
1 parent 74aa735 commit 9e8274d

4 files changed

Lines changed: 15 additions & 20 deletions

File tree

packages/opencode/src/file/watcher.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { createWrapper } from "@parcel/watcher/wrapper"
44
import type ParcelWatcher from "@parcel/watcher"
55
import { readdir } from "fs/promises"
66
import path from "path"
7-
import z from "zod"
87
import { Bus } from "@/bus"
98
import { BusEvent } from "@/bus/bus-event"
109
import { InstanceState } from "@/effect/instance-state"

packages/opencode/src/installation/index.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
44
import { withTransientReadRetry } from "@/util/effect-http-client"
55
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
66
import path from "path"
7-
import z from "zod"
87
import { BusEvent } from "@/bus/bus-event"
98
import { Flag } from "@opencode-ai/core/flag/flag"
109
import * as Log from "@opencode-ai/core/util/log"
@@ -45,15 +44,11 @@ export function getReleaseType(current: string, latest: string): ReleaseType {
4544
return "patch"
4645
}
4746

48-
export const Info = z
49-
.object({
50-
version: z.string(),
51-
latest: z.string(),
52-
})
53-
.meta({
54-
ref: "InstallationInfo",
55-
})
56-
export type Info = z.infer<typeof Info>
47+
export const Info = Schema.Struct({
48+
version: Schema.String,
49+
latest: Schema.String,
50+
}).annotate({ identifier: "InstallationInfo" })
51+
export type Info = Schema.Schema.Type<typeof Info>
5752

5853
export const USER_AGENT = `opencode/${InstallationChannel}/${InstallationVersion}/${Flag.OPENCODE_CLIENT}`
5954

packages/opencode/src/patch/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import z from "zod"
1+
import { Schema } from "effect"
22
import * as path from "path"
33
import * as fs from "fs/promises"
44
import { readFileSync } from "fs"
@@ -7,12 +7,11 @@ import * as Bom from "../util/bom"
77

88
const log = Log.create({ service: "patch" })
99

10-
// Schema definitions
11-
export const PatchSchema = z.object({
12-
patchText: z.string().describe("The full patch text that describes all changes to be made"),
10+
export const PatchSchema = Schema.Struct({
11+
patchText: Schema.String.annotate({ description: "The full patch text that describes all changes to be made" }),
1312
})
1413

15-
export type PatchParams = z.infer<typeof PatchSchema>
14+
export type PatchParams = Schema.Schema.Type<typeof PatchSchema>
1615

1716
// Core types matching the Rust implementation
1817
export interface ApplyPatchArgs {

packages/opencode/src/provider/transform.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { ModelMessage, ToolResultPart } from "ai"
22
import { mergeDeep, unique } from "remeda"
33
import type { JSONSchema7 } from "@ai-sdk/provider"
4-
import type { JSONSchema } from "zod/v4/core"
54
import type * as Provider from "./provider"
65
import type * as ModelsDev from "./models"
76
import { iife } from "@/util/iife"
@@ -1281,7 +1280,7 @@ export function maxOutputTokens(model: Provider.Model): number {
12811280
return Math.min(model.limit.output, OUTPUT_TOKEN_MAX) || OUTPUT_TOKEN_MAX
12821281
}
12831282

1284-
export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JSONSchema7): JSONSchema7 {
1283+
export function schema(model: Provider.Model, schema: JSONSchema7): JSONSchema7 {
12851284
/*
12861285
if (["openai", "azure"].includes(providerID)) {
12871286
if (schema.type === "object" && schema.properties) {
@@ -1312,7 +1311,10 @@ export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JS
13121311
return result
13131312
}
13141313

1315-
schema = sanitizeMoonshot(schema) as JSONSchema.BaseSchema | JSONSchema7
1314+
const sanitized = sanitizeMoonshot(schema)
1315+
if (typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized)) {
1316+
schema = sanitized
1317+
}
13161318
}
13171319

13181320
// Convert integer enums to string enums for Google/Gemini
@@ -1394,7 +1396,7 @@ export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JS
13941396
schema = sanitizeGemini(schema)
13951397
}
13961398

1397-
return schema as JSONSchema7
1399+
return schema
13981400
}
13991401

14001402
export * as ProviderTransform from "./transform"

0 commit comments

Comments
 (0)