mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-19 00:34:23 +01:00
chore: replace z.union with z.enum for cleaner OpenAPI generation (#4394)
This commit is contained in:
@@ -12,7 +12,7 @@ export namespace Agent {
|
|||||||
.object({
|
.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
mode: z.union([z.literal("subagent"), z.literal("primary"), z.literal("all")]),
|
mode: z.enum(["subagent", "primary", "all"]),
|
||||||
builtIn: z.boolean(),
|
builtIn: z.boolean(),
|
||||||
topP: z.number().optional(),
|
topP: z.number().optional(),
|
||||||
temperature: z.number().optional(),
|
temperature: z.number().optional(),
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ export namespace Config {
|
|||||||
export const Mcp = z.discriminatedUnion("type", [McpLocal, McpRemote])
|
export const Mcp = z.discriminatedUnion("type", [McpLocal, McpRemote])
|
||||||
export type Mcp = z.infer<typeof Mcp>
|
export type Mcp = z.infer<typeof Mcp>
|
||||||
|
|
||||||
export const Permission = z.union([z.literal("ask"), z.literal("allow"), z.literal("deny")])
|
export const Permission = z.enum(["ask", "allow", "deny"])
|
||||||
export type Permission = z.infer<typeof Permission>
|
export type Permission = z.infer<typeof Permission>
|
||||||
|
|
||||||
export const Command = z.object({
|
export const Command = z.object({
|
||||||
@@ -358,7 +358,7 @@ export namespace Config {
|
|||||||
tools: z.record(z.string(), z.boolean()).optional(),
|
tools: z.record(z.string(), z.boolean()).optional(),
|
||||||
disable: z.boolean().optional(),
|
disable: z.boolean().optional(),
|
||||||
description: z.string().optional().describe("Description of when to use the agent"),
|
description: z.string().optional().describe("Description of when to use the agent"),
|
||||||
mode: z.union([z.literal("subagent"), z.literal("primary"), z.literal("all")]).optional(),
|
mode: z.enum(["subagent", "primary", "all"]).optional(),
|
||||||
color: z
|
color: z
|
||||||
.string()
|
.string()
|
||||||
.regex(/^#[0-9a-fA-F]{6}$/, "Invalid hex color format")
|
.regex(/^#[0-9a-fA-F]{6}$/, "Invalid hex color format")
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const ERRORS = {
|
|||||||
schema: resolver(
|
schema: resolver(
|
||||||
z
|
z
|
||||||
.object({
|
.object({
|
||||||
data: z.any().nullable(),
|
data: z.any(),
|
||||||
errors: z.array(z.record(z.string(), z.any())),
|
errors: z.array(z.record(z.string(), z.any())),
|
||||||
success: z.literal(false),
|
success: z.literal(false),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user