fix(core): normalize JSON Schema nullable type arrays in toGeminiSchema
MV
1d ago+344+344+012345678901234567890123456789-5-5-0123456789
Fixes #44
Summary
toGeminiSchema already normalizes anyOf / oneOf null unions into { type, nullable: true }, but JSON Schema nullable type arrays (type: ["string", "null"]) reached typeof inputSchema.type === 'string' as an array and had their type dropped. Tools that declare nullable arguments via type arrays (such as OpenCode 2.x tools with type: ["string", "null"]) then failed on Gemini models with HTTP 400.
Changes
- Add
normalizeNullableTypeArrayinpackages/core/src/transform/gemini.tsaftermergeSchemaAllOfto normalize:- 2-element nullable type arrays (
["string", "null"],["null", "integer"], etc., case-insensitive and deduplicated) to{ type: "<type>", nullable: true } - 1-element arrays (
["string"]->type: "string",["null"]->type: "null") - Nested object properties, array items, and
allOf-merged schemas
- 2-element nullable type arrays (
- Leave genuine multi-type arrays (
["string", "number"]) and unknown type entries untouched so existing provider validation handles them without misclassifying schema errors. - Add unit coverage in
packages/core/src/transform/gemini.test.ts.
Verification
bun test --isolate packages/core/src/transform/gemini.test.ts(166 pass, 0 fail)bun run --cwd packages/core typecheck(0 errors)bun x @biomejs/biome check packages/core/src/transform/gemini.ts packages/core/src/transform/gemini.test.ts- Live tool-call round-trips with explicit
nullarguments onantigravity-gemini-3.8-flashandantigravity-gemini-4-argon.