feat(config): add plugin_load_timeout_ms and safe_hook_creation experimental flags
This commit is contained in:
parent
f9742ddfca
commit
1ae7d7d67e
@ -5,6 +5,7 @@ import {
|
|||||||
BrowserAutomationProviderSchema,
|
BrowserAutomationProviderSchema,
|
||||||
BuiltinCategoryNameSchema,
|
BuiltinCategoryNameSchema,
|
||||||
CategoryConfigSchema,
|
CategoryConfigSchema,
|
||||||
|
ExperimentalConfigSchema,
|
||||||
OhMyOpenCodeConfigSchema,
|
OhMyOpenCodeConfigSchema,
|
||||||
} from "./schema"
|
} from "./schema"
|
||||||
|
|
||||||
@ -606,3 +607,59 @@ describe("OhMyOpenCodeConfigSchema - browser_automation_engine", () => {
|
|||||||
expect(result.data?.browser_automation_engine).toBeUndefined()
|
expect(result.data?.browser_automation_engine).toBeUndefined()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("ExperimentalConfigSchema feature flags", () => {
|
||||||
|
test("accepts plugin_load_timeout_ms as number", () => {
|
||||||
|
//#given
|
||||||
|
const config = { plugin_load_timeout_ms: 5000 }
|
||||||
|
|
||||||
|
//#when
|
||||||
|
const result = ExperimentalConfigSchema.safeParse(config)
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(result.success).toBe(true)
|
||||||
|
if (result.success) {
|
||||||
|
expect(result.data.plugin_load_timeout_ms).toBe(5000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("rejects plugin_load_timeout_ms below 1000", () => {
|
||||||
|
//#given
|
||||||
|
const config = { plugin_load_timeout_ms: 500 }
|
||||||
|
|
||||||
|
//#when
|
||||||
|
const result = ExperimentalConfigSchema.safeParse(config)
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(result.success).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("accepts safe_hook_creation as boolean", () => {
|
||||||
|
//#given
|
||||||
|
const config = { safe_hook_creation: false }
|
||||||
|
|
||||||
|
//#when
|
||||||
|
const result = ExperimentalConfigSchema.safeParse(config)
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(result.success).toBe(true)
|
||||||
|
if (result.success) {
|
||||||
|
expect(result.data.safe_hook_creation).toBe(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("both fields are optional", () => {
|
||||||
|
//#given
|
||||||
|
const config = {}
|
||||||
|
|
||||||
|
//#when
|
||||||
|
const result = ExperimentalConfigSchema.safeParse(config)
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(result.success).toBe(true)
|
||||||
|
if (result.success) {
|
||||||
|
expect(result.data.plugin_load_timeout_ms).toBeUndefined()
|
||||||
|
expect(result.data.safe_hook_creation).toBeUndefined()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@ -268,6 +268,10 @@ export const ExperimentalConfigSchema = z.object({
|
|||||||
dynamic_context_pruning: DynamicContextPruningConfigSchema.optional(),
|
dynamic_context_pruning: DynamicContextPruningConfigSchema.optional(),
|
||||||
/** Enable experimental task system for Todowrite disabler hook */
|
/** Enable experimental task system for Todowrite disabler hook */
|
||||||
task_system: z.boolean().optional(),
|
task_system: z.boolean().optional(),
|
||||||
|
/** Timeout in ms for loadAllPluginComponents during config handler init (default: 10000, min: 1000) */
|
||||||
|
plugin_load_timeout_ms: z.number().min(1000).optional(),
|
||||||
|
/** Wrap hook creation in try/catch to prevent one failing hook from crashing the plugin (default: true at call site) */
|
||||||
|
safe_hook_creation: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const SkillSourceSchema = z.union([
|
export const SkillSourceSchema = z.union([
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user