#3586042: Use the ai_json_schema editor for the structured output schema field.
Closes #3586042
Completes the wiring for the ai_json_schema (CodeMirror) editor on the AI Agent Structured Output Schema field: adds config-level JSON validation, lets the modeller resolve the field's schema, and fixes visibility toggling.
Changes
config/schema/ai_agents.schema.yml—structured_output_schema:string→text, plus aValidJsonSchemaStructureconstraint (checkAiConstraints: false= plain valid-JSON, matching the form).Agent.php— addedgetPluginSchemaKey()mapping the START component toai_agents.ai_agent.*so the modeller (BPMN/off-canvas) can locate the schema.AiAgentForm.php— wrapped the field in acontainerwith#stateson the wrapper (#parentspreserved), added a user-input fallback in validation, fixed a description typo.
Requires drupal/ai ^1.4.0 (already declared) for the ValidJsonSchemaStructure constraint; off-canvas rendering relies on #3586536. Stored value/key unchanged — existing agents load/save as-is; no update hook needed.
Testing steps
- Edit an agent → Advanced → Structured output → tick Enable Structured Output. CodeMirror JSON Schema field appears; unticking hides it.
- Enter valid JSON (
{"type":"object","properties":{"name":{"type":"string"}}}) and save. Saves; reopens with value intact. - Enter malformed JSON (
{bad json) and save. Rejected with a JSON error. - With
bpmn_io, edit the agent via the modeller; open the START component off-canvas. Schema field renders and persists. drush config:validateon agents with a schema. No errors / noPluginNotFoundException.