Fix Antigravity

This commit is contained in:
decolua 2026-01-13 16:19:27 +07:00
parent ef49595866
commit e989796024

View file

@ -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)) {