From e989796024df9b5d366af29d704b52dcdbb1ce93 Mon Sep 17 00:00:00 2001 From: decolua Date: Tue, 13 Jan 2026 16:19:27 +0700 Subject: [PATCH] Fix Antigravity --- open-sse/translator/helpers/geminiHelper.js | 32 ++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/open-sse/translator/helpers/geminiHelper.js b/open-sse/translator/helpers/geminiHelper.js index e9c5ca8..5f130cf 100644 --- a/open-sse/translator/helpers/geminiHelper.js +++ b/open-sse/translator/helpers/geminiHelper.js @@ -4,7 +4,8 @@ export const UNSUPPORTED_SCHEMA_CONSTRAINTS = [ "minLength", "maxLength", "exclusiveMinimum", "exclusiveMaximum", "pattern", "minItems", "maxItems", "format", - "default", "examples", "$schema", "const" + "default", "examples", "$schema", "const", "title", + "anyOf", "oneOf", "allOf", "not" ]; // Default safety settings @@ -87,6 +88,35 @@ export function generateProjectId() { export function cleanJSONSchemaForAntigravity(schema) { if (!schema || typeof schema !== "object") return schema; + // Handle anyOf/oneOf - extract the first non-null schema + if (schema.anyOf && Array.isArray(schema.anyOf)) { + const nonNullSchema = schema.anyOf.find(s => s.type !== "null" && s.type !== null); + if (nonNullSchema) { + const baseSchema = { ...nonNullSchema }; + // Copy other properties from parent schema (except unsupported ones) + for (const [key, value] of Object.entries(schema)) { + if (!UNSUPPORTED_SCHEMA_CONSTRAINTS.includes(key)) { + baseSchema[key] = value; + } + } + return cleanJSONSchemaForAntigravity(baseSchema); + } + } + + if (schema.oneOf && Array.isArray(schema.oneOf)) { + const nonNullSchema = schema.oneOf.find(s => s.type !== "null" && s.type !== null); + if (nonNullSchema) { + const baseSchema = { ...nonNullSchema }; + // Copy other properties from parent schema (except unsupported ones) + for (const [key, value] of Object.entries(schema)) { + if (!UNSUPPORTED_SCHEMA_CONSTRAINTS.includes(key)) { + baseSchema[key] = value; + } + } + return cleanJSONSchemaForAntigravity(baseSchema); + } + } + const cleaned = Array.isArray(schema) ? [] : {}; for (const [key, value] of Object.entries(schema)) {