#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_schemastring → text, plus a ValidJsonSchemaStructure constraint (checkAiConstraints: false = plain valid-JSON, matching the form).
  • Agent.php — added getPluginSchemaKey() mapping the START component to ai_agents.ai_agent.* so the modeller (BPMN/off-canvas) can locate the schema.
  • AiAgentForm.php — wrapped the field in a container with #states on the wrapper (#parents preserved), 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

  1. Edit an agent → Advanced → Structured output → tick Enable Structured Output. CodeMirror JSON Schema field appears; unticking hides it.
  2. Enter valid JSON ({"type":"object","properties":{"name":{"type":"string"}}}) and save. Saves; reopens with value intact.
  3. Enter malformed JSON ({bad json) and save. Rejected with a JSON error.
  4. With bpmn_io, edit the agent via the modeller; open the START component off-canvas. Schema field renders and persists.
  5. drush config:validate on agents with a schema. No errors / no PluginNotFoundException.

Merge request reports

Loading