From 26312055c5539aa3edf387f5ed2fe23a0ac820b3 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Fri, 16 Jan 2026 10:15:53 +0000 Subject: [PATCH] fix(schema): Allow `undefined` for optional props of `Inputs` (#102) * fix(schema): Add union with undefined to the tool permission props. * fix(schema): Add union with undefined to the tool permission props. * Add CI tests. * fix: reduced nesting in tests. * Add project-based config for vitest to run all tests by a single command. --- entry | 8 +++---- utils/payload.test.ts | 51 +++++++++++++++++++++++++++++++++++++++++++ utils/payload.ts | 8 +++---- 3 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 utils/payload.test.ts diff --git a/entry b/entry index c1af735..420180c 100755 --- a/entry +++ b/entry @@ -119890,10 +119890,10 @@ var Inputs = type({ prompt: "string", "effort?": Effort, "agent?": AgentName.or("null"), - "web?": ToolPermissionInput, - "search?": ToolPermissionInput, - "write?": ToolPermissionInput, - "bash?": BashPermissionInput, + "web?": ToolPermissionInput.or("undefined"), + "search?": ToolPermissionInput.or("undefined"), + "write?": ToolPermissionInput.or("undefined"), + "bash?": BashPermissionInput.or("undefined"), "cwd?": "string|null" }); function isAgentName(value2) { diff --git a/utils/payload.test.ts b/utils/payload.test.ts new file mode 100644 index 0000000..d2306b2 --- /dev/null +++ b/utils/payload.test.ts @@ -0,0 +1,51 @@ +import { Inputs } from './payload.ts'; + +describe('Inputs schema', () => { + it('only prompt is required', () => { + const result = Inputs.assert({prompt: 'test prompt'}); + expect(result).toEqual({prompt: 'test prompt'}); + expect(() => Inputs.assert({})).toThrow(); + }); + + it.each([ + ['web', 'enabled'], + ['web', 'disabled'], + ['web', undefined], + ['search', 'enabled'], + ['search', 'disabled'], + ['search', undefined], + ['write', 'enabled'], + ['write', 'disabled'], + ['write', undefined], + ['bash', 'enabled'], + ['bash', 'restricted'], + ['bash', 'disabled'], + ['bash', undefined], + ['effort', 'mini'], + ['effort', 'auto'], + ['effort', 'max'], + ['agent', 'claude'], + ['agent', 'codex'], + ['agent', 'cursor'], + ['agent', 'gemini'], + ['agent', 'opencode'], + ['agent', null], + ] as const)('should accept %s for %s', (prop, value) => { + const input = {prompt: 'test', [prop]: value}; + expect(() => Inputs.assert(input)).not.toThrow(); + }); + + + it.each([ + ['web'], + ['search'], + ['write'], + ['bash'], + ['effort'], + ['agent'], + ] as const)('should reject invalid %s values', (prop) => { + const input = {prompt: 'test', [prop]: 'invalid' as any}; + expect(() => Inputs.assert(input)).toThrow(); + }); + +}); diff --git a/utils/payload.ts b/utils/payload.ts index cdb87e6..050ad31 100644 --- a/utils/payload.ts +++ b/utils/payload.ts @@ -33,10 +33,10 @@ export const Inputs = type({ prompt: "string", "effort?": Effort, "agent?": AgentName.or("null"), - "web?": ToolPermissionInput, - "search?": ToolPermissionInput, - "write?": ToolPermissionInput, - "bash?": BashPermissionInput, + "web?": ToolPermissionInput.or("undefined"), + "search?": ToolPermissionInput.or("undefined"), + "write?": ToolPermissionInput.or("undefined"), + "bash?": BashPermissionInput.or("undefined"), "cwd?": "string|null", });