feat(core): Have subagents use a JSON schema type for input. (#17152)

This commit is contained in:
joshualitt
2026-01-21 16:56:01 -08:00
committed by GitHub
parent b24544c80e
commit 27d21f9921
21 changed files with 271 additions and 500 deletions
+13 -1
View File
@@ -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);
}
}