Connection Rules
components/builder/connectionRules.ts is the single source of truth for which nodes can connect to which handles. It’s used by:
- The canvas drag-drop validation (live rejection of invalid connections)
- The AI flow generator’s system prompt (so the AI knows what’s allowed)
- The graph validation before applying AI operations
Rule structure
findTargetRule(sourceType, sourceHandleId, targetType, targetCategory)
When a user drags an edge and drops it on a target node (without specifying the exact handle),findTargetRule() auto-routes to the correct handle:
- Look up the source node’s rules from
connectionRules[sourceType] - Get the
outputsrule - Priority 1: Find a rule with exact
nodeTypematch on the target - Priority 2: Find a rule with
nodeCategorymatch, excludingexcludeNodeTypes - Return the first matching
TargetRule(containstargetHandleId)
Key rules summary
Component → Framework wiring
| Source | Auto-routes to |
|---|---|
persona | framework.persona_in |
llm | framework.llm_in |
tts | framework.tts_in |
stt | framework.stt_in |
avatar | framework.avatar_in |
Conversation step constraints
startcan connect to any conversation node exceptstartifelseandcategorizecannot immediately followstart(require an intermediate step)ifelseandcategorizecannot connect to each otherendconnects towebhookonly (optional)transferconnects toframework.transfer_inorwebhook
Integration → Framework
| Source | Connects to |
|---|---|
mcp | framework.tools_in |
exa | framework.tools_in |
Validation in the AI generator
The AI flow generator builds anALLOWED_INPUTS map from connectionRules.ts and simulates the operations against the current graph. If any operation would violate a rule, the AI retries with error feedback (max 3 attempts).