Revert "Merge pull request #1951 from edxeth/feat/custom-agents"
This reverts commit47e300b17e, reversing changes made to243ce1b7e8.
This commit is contained in:
@@ -1,25 +1,11 @@
|
||||
export {
|
||||
OhMyOpenCodeConfigSchema,
|
||||
AgentOverrideConfigSchema,
|
||||
AgentOverridesSchema,
|
||||
CustomAgentOverridesSchema,
|
||||
McpNameSchema,
|
||||
AgentNameSchema,
|
||||
OverridableAgentNameSchema,
|
||||
HookNameSchema,
|
||||
BuiltinCommandNameSchema,
|
||||
SisyphusAgentConfigSchema,
|
||||
ExperimentalConfigSchema,
|
||||
RalphLoopConfigSchema,
|
||||
TmuxConfigSchema,
|
||||
TmuxLayoutSchema,
|
||||
} from "./schema"
|
||||
|
||||
export type {
|
||||
OhMyOpenCodeConfig,
|
||||
AgentOverrideConfig,
|
||||
AgentOverrides,
|
||||
CustomAgentOverrides,
|
||||
McpName,
|
||||
AgentName,
|
||||
HookName,
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { createOhMyOpenCodeJsonSchema } from "../../script/build-schema-document"
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
||||
return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : undefined
|
||||
}
|
||||
|
||||
describe("schema document generation", () => {
|
||||
test("custom_agents schema allows arbitrary custom agent keys with override shape", () => {
|
||||
// given
|
||||
const schema = createOhMyOpenCodeJsonSchema()
|
||||
|
||||
// when
|
||||
const rootProperties = asRecord(schema.properties)
|
||||
const agentsSchema = asRecord(rootProperties?.agents)
|
||||
const customAgentsSchema = asRecord(rootProperties?.custom_agents)
|
||||
const customPropertyNames = asRecord(customAgentsSchema?.propertyNames)
|
||||
const customAdditionalProperties = asRecord(customAgentsSchema?.additionalProperties)
|
||||
const defs = asRecord(schema.$defs)
|
||||
const sharedAgentOverrideSchema = asRecord(defs?.agentOverrideConfig)
|
||||
const sharedAgentProperties = asRecord(sharedAgentOverrideSchema?.properties)
|
||||
|
||||
// then
|
||||
expect(agentsSchema).toBeDefined()
|
||||
expect(agentsSchema?.additionalProperties).toBeFalse()
|
||||
expect(customAgentsSchema).toBeDefined()
|
||||
expect(customPropertyNames?.pattern).toBeDefined()
|
||||
expect(customPropertyNames?.pattern).toContain("[bB][uU][iI][lL][dD]")
|
||||
expect(customPropertyNames?.pattern).toContain("[pP][lL][aA][nN]")
|
||||
expect(customAdditionalProperties).toBeDefined()
|
||||
expect(customAdditionalProperties?.$ref).toBe("#/$defs/agentOverrideConfig")
|
||||
expect(sharedAgentOverrideSchema).toBeDefined()
|
||||
expect(sharedAgentProperties?.model).toEqual({ type: "string" })
|
||||
expect(sharedAgentProperties?.temperature).toEqual(
|
||||
expect.objectContaining({ type: "number" }),
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -530,79 +530,6 @@ describe("Sisyphus-Junior agent override", () => {
|
||||
expect(result.data.agents?.momus?.category).toBe("quick")
|
||||
}
|
||||
})
|
||||
|
||||
test("schema accepts custom_agents override keys", () => {
|
||||
// given
|
||||
const config = {
|
||||
custom_agents: {
|
||||
translator: {
|
||||
model: "google/gemini-3-flash-preview",
|
||||
temperature: 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// when
|
||||
const result = OhMyOpenCodeConfigSchema.safeParse(config)
|
||||
|
||||
// then
|
||||
expect(result.success).toBe(true)
|
||||
if (result.success) {
|
||||
expect(result.data.custom_agents?.translator?.model).toBe("google/gemini-3-flash-preview")
|
||||
expect(result.data.custom_agents?.translator?.temperature).toBe(0)
|
||||
}
|
||||
})
|
||||
|
||||
test("schema rejects unknown keys under agents", () => {
|
||||
// given
|
||||
const config = {
|
||||
agents: {
|
||||
sisyphuss: {
|
||||
model: "openai/gpt-5.3-codex",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// when
|
||||
const result = OhMyOpenCodeConfigSchema.safeParse(config)
|
||||
|
||||
// then
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
test("schema rejects built-in agent names under custom_agents", () => {
|
||||
// given
|
||||
const config = {
|
||||
custom_agents: {
|
||||
sisyphus: {
|
||||
model: "openai/gpt-5.3-codex",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// when
|
||||
const result = OhMyOpenCodeConfigSchema.safeParse(config)
|
||||
|
||||
// then
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
test("schema rejects built-in agent names under custom_agents case-insensitively", () => {
|
||||
// given
|
||||
const config = {
|
||||
custom_agents: {
|
||||
Sisyphus: {
|
||||
model: "openai/gpt-5.3-codex",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// when
|
||||
const result = OhMyOpenCodeConfigSchema.safeParse(config)
|
||||
|
||||
// then
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe("BrowserAutomationProviderSchema", () => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { z } from "zod"
|
||||
import { FallbackModelsSchema } from "./fallback-models"
|
||||
import { OverridableAgentNameSchema } from "./agent-names"
|
||||
import { AgentPermissionSchema } from "./internal/permission"
|
||||
|
||||
export const AgentOverrideConfigSchema = z.object({
|
||||
@@ -56,7 +55,7 @@ export const AgentOverrideConfigSchema = z.object({
|
||||
.optional(),
|
||||
})
|
||||
|
||||
const BuiltinAgentOverridesSchema = z.object({
|
||||
export const AgentOverridesSchema = z.object({
|
||||
build: AgentOverrideConfigSchema.optional(),
|
||||
plan: AgentOverrideConfigSchema.optional(),
|
||||
sisyphus: AgentOverrideConfigSchema.optional(),
|
||||
@@ -73,57 +72,7 @@ const BuiltinAgentOverridesSchema = z.object({
|
||||
explore: AgentOverrideConfigSchema.optional(),
|
||||
"multimodal-looker": AgentOverrideConfigSchema.optional(),
|
||||
atlas: AgentOverrideConfigSchema.optional(),
|
||||
}).strict()
|
||||
|
||||
export const AgentOverridesSchema = BuiltinAgentOverridesSchema
|
||||
|
||||
const RESERVED_CUSTOM_AGENT_NAMES = OverridableAgentNameSchema.options
|
||||
const RESERVED_CUSTOM_AGENT_NAME_SET = new Set(
|
||||
RESERVED_CUSTOM_AGENT_NAMES.map((name) => name.toLowerCase()),
|
||||
)
|
||||
function escapeRegexLiteral(value: string): string {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
||||
}
|
||||
|
||||
function toCaseInsensitiveLiteralPattern(value: string): string {
|
||||
return value
|
||||
.split("")
|
||||
.map((char) => {
|
||||
if (/^[A-Za-z]$/.test(char)) {
|
||||
const lower = char.toLowerCase()
|
||||
const upper = char.toUpperCase()
|
||||
return `[${lower}${upper}]`
|
||||
}
|
||||
|
||||
return escapeRegexLiteral(char)
|
||||
})
|
||||
.join("")
|
||||
}
|
||||
|
||||
const RESERVED_CUSTOM_AGENT_NAME_PATTERN = new RegExp(
|
||||
`^(?!(?:${RESERVED_CUSTOM_AGENT_NAMES.map(toCaseInsensitiveLiteralPattern).join("|")})$).+`,
|
||||
)
|
||||
|
||||
export const CustomAgentOverridesSchema = z
|
||||
.record(
|
||||
z.string().regex(
|
||||
RESERVED_CUSTOM_AGENT_NAME_PATTERN,
|
||||
"custom_agents key cannot reuse built-in agent override name",
|
||||
),
|
||||
AgentOverrideConfigSchema,
|
||||
)
|
||||
.superRefine((value, ctx) => {
|
||||
for (const key of Object.keys(value)) {
|
||||
if (RESERVED_CUSTOM_AGENT_NAME_SET.has(key.toLowerCase())) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: [key],
|
||||
message: "custom_agents key cannot reuse built-in agent override name",
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
export type AgentOverrideConfig = z.infer<typeof AgentOverrideConfigSchema>
|
||||
export type AgentOverrides = z.infer<typeof AgentOverridesSchema>
|
||||
export type CustomAgentOverrides = z.infer<typeof CustomAgentOverridesSchema>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod"
|
||||
import { AnyMcpNameSchema } from "../../mcp/types"
|
||||
import { BuiltinAgentNameSchema, BuiltinSkillNameSchema } from "./agent-names"
|
||||
import { AgentOverridesSchema, CustomAgentOverridesSchema } from "./agent-overrides"
|
||||
import { AgentOverridesSchema } from "./agent-overrides"
|
||||
import { BabysittingConfigSchema } from "./babysitting"
|
||||
import { BackgroundTaskConfigSchema } from "./background-task"
|
||||
import { BrowserAutomationConfigSchema } from "./browser-automation"
|
||||
@@ -39,7 +39,6 @@ export const OhMyOpenCodeConfigSchema = z.object({
|
||||
/** Enable model fallback on API errors (default: false). Set to true to enable automatic model switching when model errors occur. */
|
||||
model_fallback: z.boolean().optional(),
|
||||
agents: AgentOverridesSchema.optional(),
|
||||
custom_agents: CustomAgentOverridesSchema.optional(),
|
||||
categories: CategoriesConfigSchema.optional(),
|
||||
claude_code: ClaudeCodeConfigSchema.optional(),
|
||||
sisyphus_agent: SisyphusAgentConfigSchema.optional(),
|
||||
|
||||
Reference in New Issue
Block a user