ai_agents_canvas_direct_edit
No security coverage
When users make simple changes to Canvas components ("set the color to blue," "change the heading to Welcome"), the correct result is deterministic. The prop name and value can be resolved directly from the SDC component schema without any AI reasoning.
This module does exactly that. It reads your theme's component YAML schemas, builds prop alias and enum value maps, and resolves edits through seven match tiers:
- Exact and alias matches: "set text_color to primary" or "set the color to blue"
- Bare value inference: Just "blue" resolves to the correct prop when unambiguous
- Relative adjustments: "bigger" or "smaller" navigates enum ordinals
- Boolean toggles: "show the header" or "hide the footer"
- Reset patterns: "reset the color" returns the prop to its default
- Compound edits: "change the heading to Welcome and set the color to blue"
Anything the matcher can't resolve with certainty gets a 422 response, routing the request to the existing AI agent chain. Zero false positives by design.
Key features
- 8 Tool API plugins with automatic MCP, CLI, and AI agent discovery
- HTTP bridge controller at the same endpoint the Canvas frontend already calls
- Optional MCP server submodule (JSON-RPC 2.0) for external clients
- Schema-driven: adapts automatically when theme components change
- Config-driven verb and alias lists for customization without patching
- Opt-in telemetry with PII-safe defaults (SHA-256 hashing, no raw text storage)
- Works without AI providers configured (Canvas Lite mode: deterministic edits succeed, unmatched edits return 503 instead of routing to AI)
Measured results
All measurements on a 15-component demo page:
- Deterministic path: 0 tokens, <7ms
- AI baseline: ~101K tokens, 16.4s
- Hit rate: 60% on 20 mixed edits, zero false positives
59 kernel tests, 221 assertions. PHPCS clean (Drupal + DrupalPractice).