Remove internal Zod schemas (#26974)
This commit is contained in:
@@ -4,7 +4,6 @@ import { createWrapper } from "@parcel/watcher/wrapper"
|
|||||||
import type ParcelWatcher from "@parcel/watcher"
|
import type ParcelWatcher from "@parcel/watcher"
|
||||||
import { readdir } from "fs/promises"
|
import { readdir } from "fs/promises"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import z from "zod"
|
|
||||||
import { Bus } from "@/bus"
|
import { Bus } from "@/bus"
|
||||||
import { BusEvent } from "@/bus/bus-event"
|
import { BusEvent } from "@/bus/bus-event"
|
||||||
import { InstanceState } from "@/effect/instance-state"
|
import { InstanceState } from "@/effect/instance-state"
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
|||||||
import { withTransientReadRetry } from "@/util/effect-http-client"
|
import { withTransientReadRetry } from "@/util/effect-http-client"
|
||||||
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
|
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import z from "zod"
|
|
||||||
import { BusEvent } from "@/bus/bus-event"
|
import { BusEvent } from "@/bus/bus-event"
|
||||||
import { Flag } from "@opencode-ai/core/flag/flag"
|
import { Flag } from "@opencode-ai/core/flag/flag"
|
||||||
import * as Log from "@opencode-ai/core/util/log"
|
import * as Log from "@opencode-ai/core/util/log"
|
||||||
@@ -45,15 +44,11 @@ export function getReleaseType(current: string, latest: string): ReleaseType {
|
|||||||
return "patch"
|
return "patch"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Info = z
|
export const Info = Schema.Struct({
|
||||||
.object({
|
version: Schema.String,
|
||||||
version: z.string(),
|
latest: Schema.String,
|
||||||
latest: z.string(),
|
}).annotate({ identifier: "InstallationInfo" })
|
||||||
})
|
export type Info = Schema.Schema.Type<typeof Info>
|
||||||
.meta({
|
|
||||||
ref: "InstallationInfo",
|
|
||||||
})
|
|
||||||
export type Info = z.infer<typeof Info>
|
|
||||||
|
|
||||||
export const USER_AGENT = `opencode/${InstallationChannel}/${InstallationVersion}/${Flag.OPENCODE_CLIENT}`
|
export const USER_AGENT = `opencode/${InstallationChannel}/${InstallationVersion}/${Flag.OPENCODE_CLIENT}`
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import z from "zod"
|
import { Schema } from "effect"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import * as fs from "fs/promises"
|
import * as fs from "fs/promises"
|
||||||
import { readFileSync } from "fs"
|
import { readFileSync } from "fs"
|
||||||
@@ -7,12 +7,11 @@ import * as Bom from "../util/bom"
|
|||||||
|
|
||||||
const log = Log.create({ service: "patch" })
|
const log = Log.create({ service: "patch" })
|
||||||
|
|
||||||
// Schema definitions
|
export const PatchSchema = Schema.Struct({
|
||||||
export const PatchSchema = z.object({
|
patchText: Schema.String.annotate({ description: "The full patch text that describes all changes to be made" }),
|
||||||
patchText: z.string().describe("The full patch text that describes all changes to be made"),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export type PatchParams = z.infer<typeof PatchSchema>
|
export type PatchParams = Schema.Schema.Type<typeof PatchSchema>
|
||||||
|
|
||||||
// Core types matching the Rust implementation
|
// Core types matching the Rust implementation
|
||||||
export interface ApplyPatchArgs {
|
export interface ApplyPatchArgs {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { ModelMessage, ToolResultPart } from "ai"
|
import type { ModelMessage, ToolResultPart } from "ai"
|
||||||
import { mergeDeep, unique } from "remeda"
|
import { mergeDeep, unique } from "remeda"
|
||||||
import type { JSONSchema7 } from "@ai-sdk/provider"
|
import type { JSONSchema7 } from "@ai-sdk/provider"
|
||||||
import type { JSONSchema } from "zod/v4/core"
|
|
||||||
import type * as Provider from "./provider"
|
import type * as Provider from "./provider"
|
||||||
import type * as ModelsDev from "./models"
|
import type * as ModelsDev from "./models"
|
||||||
import { iife } from "@/util/iife"
|
import { iife } from "@/util/iife"
|
||||||
@@ -1281,7 +1280,7 @@ export function maxOutputTokens(model: Provider.Model): number {
|
|||||||
return Math.min(model.limit.output, OUTPUT_TOKEN_MAX) || OUTPUT_TOKEN_MAX
|
return Math.min(model.limit.output, OUTPUT_TOKEN_MAX) || OUTPUT_TOKEN_MAX
|
||||||
}
|
}
|
||||||
|
|
||||||
export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JSONSchema7): JSONSchema7 {
|
export function schema(model: Provider.Model, schema: JSONSchema7): JSONSchema7 {
|
||||||
/*
|
/*
|
||||||
if (["openai", "azure"].includes(providerID)) {
|
if (["openai", "azure"].includes(providerID)) {
|
||||||
if (schema.type === "object" && schema.properties) {
|
if (schema.type === "object" && schema.properties) {
|
||||||
@@ -1312,7 +1311,10 @@ export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JS
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
schema = sanitizeMoonshot(schema) as JSONSchema.BaseSchema | JSONSchema7
|
const sanitized = sanitizeMoonshot(schema)
|
||||||
|
if (typeof sanitized === "object" && sanitized !== null && !Array.isArray(sanitized)) {
|
||||||
|
schema = sanitized
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert integer enums to string enums for Google/Gemini
|
// Convert integer enums to string enums for Google/Gemini
|
||||||
@@ -1394,7 +1396,7 @@ export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema | JS
|
|||||||
schema = sanitizeGemini(schema)
|
schema = sanitizeGemini(schema)
|
||||||
}
|
}
|
||||||
|
|
||||||
return schema as JSONSchema7
|
return schema
|
||||||
}
|
}
|
||||||
|
|
||||||
export * as ProviderTransform from "./transform"
|
export * as ProviderTransform from "./transform"
|
||||||
|
|||||||
Reference in New Issue
Block a user