mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 21:14:35 -07:00
feat(core): Have subagents use a JSON schema type for input. (#17152)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import AjvPkg from 'ajv';
|
||||
import AjvPkg, { type AnySchema } from 'ajv';
|
||||
import * as addFormats from 'ajv-formats';
|
||||
// Ajv's ESM/CJS interop: use 'any' for compatibility as recommended by Ajv docs
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -47,4 +47,16 @@ export class SchemaValidator {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a JSON schema itself. Returns null if the schema is valid,
|
||||
* otherwise returns a string describing the validation errors.
|
||||
*/
|
||||
static validateSchema(schema: AnySchema | undefined): string | null {
|
||||
if (!schema) {
|
||||
return null;
|
||||
}
|
||||
const isValid = ajValidator.validateSchema(schema);
|
||||
return isValid ? null : ajValidator.errorsText(ajValidator.errors);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user