@addai/flows-mcp 0.5.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/install.js +4 -2
- package/dist/bin/install.js.map +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +26 -0
- package/dist/layout.js +54 -0
- package/dist/layout.js.map +1 -0
- package/dist/node-defaults.d.ts +1 -0
- package/dist/node-defaults.js +26 -0
- package/dist/node-defaults.js.map +1 -1
- package/dist/tools/custom-nodes.js +1 -4
- package/dist/tools/custom-nodes.js.map +1 -1
- package/dist/tools/discover.d.ts +9 -0
- package/dist/tools/discover.js +56 -0
- package/dist/tools/discover.js.map +1 -0
- package/dist/tools/edits.d.ts +12 -0
- package/dist/tools/edits.js +66 -0
- package/dist/tools/edits.js.map +1 -0
- package/dist/tools/flows.js +1 -5
- package/dist/tools/flows.js.map +1 -1
- package/dist/tools/nodes.js +1 -6
- package/dist/tools/nodes.js.map +1 -1
- package/dist/tools/preview.js +1 -6
- package/dist/tools/preview.js.map +1 -1
- package/dist/tools/test.d.ts +10 -0
- package/dist/tools/test.js +51 -0
- package/dist/tools/test.js.map +1 -0
- package/dist/tools/validate.d.ts +9 -0
- package/dist/tools/validate.js +50 -0
- package/dist/tools/validate.js.map +1 -0
- package/dist/tools/workspaces.d.ts +1 -1
- package/dist/tools/workspaces.js +4 -5
- package/dist/tools/workspaces.js.map +1 -1
- package/dist/v2-client.d.ts +65 -0
- package/dist/v2-client.js +179 -0
- package/dist/v2-client.js.map +1 -0
- package/package.json +1 -1
- package/skill/SKILL.md +64 -102
- package/skill/anti-patterns.md +106 -176
- package/skill/flow-semantics.md +142 -0
- package/skill/recipes.md +158 -267
- package/skill/version.txt +1 -1
- package/skill/node-cheatsheet.md +0 -37
package/skill/anti-patterns.md
CHANGED
|
@@ -1,207 +1,137 @@
|
|
|
1
|
-
# Anti-
|
|
1
|
+
# Anti-patterns
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Specific mistakes Claude (and humans) make repeatedly. Each has a fix.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## AP1 — Vertical-stacked flows
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Mistake:** Assigning incrementing `y` values to each new node and leaving `x` at `0`. The result: a flow that reads top-to-bottom like a debug log.
|
|
8
8
|
|
|
9
|
-
**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
method: "get", // ← lowercase — will be healed but illegal if healing fails
|
|
18
|
-
bodyType: "JSON", // ← uppercase — illegal
|
|
19
|
-
body: "not json", // ← invalid JSON when bodyType is "json"
|
|
20
|
-
authentication: { type: "Bearer", token: "x" } // ← "Bearer" not in enum
|
|
21
|
-
}
|
|
22
|
-
}]
|
|
23
|
-
})
|
|
24
|
-
```
|
|
9
|
+
**Why it's wrong:**
|
|
10
|
+
- Unreadable on a wide canvas (most of the canvas is empty space).
|
|
11
|
+
- Violates team convention (P9: horizontal is default).
|
|
12
|
+
- `validate_flow` will issue `LAYOUT_VERTICAL_DRIFT` warnings.
|
|
13
|
+
|
|
14
|
+
**Do instead:**
|
|
15
|
+
- Pass NO `position` to `add_nodes`. It auto-places horizontally.
|
|
16
|
+
- If positions got messy during a refactor, call `autolayout({flow_id})`.
|
|
25
17
|
|
|
26
|
-
|
|
18
|
+
## AP2 — `{{}}` inside a code node
|
|
27
19
|
|
|
28
|
-
**
|
|
20
|
+
**Mistake:**
|
|
21
|
+
```javascript
|
|
22
|
+
const email = "{{trigger.body.email}}"; // ← does NOT resolve
|
|
29
23
|
```
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
nodes: [{
|
|
37
|
-
type: "httpRequest",
|
|
38
|
-
data: {
|
|
39
|
-
url: "https://api.example.com/data",
|
|
40
|
-
method: "GET",
|
|
41
|
-
bodyType: "none",
|
|
42
|
-
authentication: { type: "bearer", token: "{{Variables.apiKey}}" }
|
|
43
|
-
}
|
|
44
|
-
}]
|
|
45
|
-
})
|
|
24
|
+
|
|
25
|
+
**Why it's wrong:** `{{}}` syntax is only resolved in node *config fields*. Code nodes run in a JavaScript sandbox where `{{}}` is a literal string.
|
|
26
|
+
|
|
27
|
+
**Do instead:**
|
|
28
|
+
```javascript
|
|
29
|
+
const email = $("trigger").body.email;
|
|
46
30
|
```
|
|
47
31
|
|
|
48
|
-
|
|
32
|
+
## AP3 — `$()` inside custom node code
|
|
49
33
|
|
|
50
|
-
|
|
34
|
+
**Mistake:** Using `$("nodeId")` inside a custom node's `code`.
|
|
51
35
|
|
|
52
|
-
**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
data: {
|
|
59
|
-
conditions: [
|
|
60
|
-
{ leftValue: "{{trigger.body.status}}", operator: "equals", rightValue: "active" }
|
|
61
|
-
// ← no id — UI evaluation order becomes non-deterministic, editor breaks
|
|
62
|
-
],
|
|
63
|
-
conditionLogic: "and"
|
|
64
|
-
}
|
|
65
|
-
}]
|
|
66
|
-
})
|
|
36
|
+
**Why it's wrong:** Custom nodes run in a separate sandbox. They don't have access to other nodes' outputs — only the declared `inputs` and `secrets`.
|
|
37
|
+
|
|
38
|
+
**Do instead:**
|
|
39
|
+
```javascript
|
|
40
|
+
const url = inputs.endpoint; // declared in input_schema
|
|
41
|
+
const token = secrets.API_TOKEN; // declared in secret_requirements
|
|
67
42
|
```
|
|
68
43
|
|
|
69
|
-
|
|
44
|
+
## AP4 — Forgetting `customVersionId`
|
|
45
|
+
|
|
46
|
+
**Mistake:** Inserting a `customNode` with only `customNodeId`, expecting it to use "the latest version."
|
|
70
47
|
|
|
71
|
-
**
|
|
48
|
+
**Why it's wrong:** Custom node versions do not auto-update on publish (deliberate design decision). A flow without `customVersionId` will fail at runtime — there is no implicit latest.
|
|
49
|
+
|
|
50
|
+
**Do instead:** Always pin:
|
|
72
51
|
```
|
|
73
|
-
|
|
74
|
-
flow_id: "...",
|
|
75
|
-
nodes: [{
|
|
76
|
-
type: "if",
|
|
77
|
-
data: {
|
|
78
|
-
conditions: [{
|
|
79
|
-
id: crypto.randomUUID(),
|
|
80
|
-
leftValue: "{{trigger.body.status}}",
|
|
81
|
-
operator: "equals",
|
|
82
|
-
rightValue: "active",
|
|
83
|
-
dataType: "string"
|
|
84
|
-
}],
|
|
85
|
-
conditionLogic: "and"
|
|
86
|
-
}
|
|
87
|
-
}]
|
|
88
|
-
})
|
|
52
|
+
{type: "customNode", data: {customNodeId: "cn_x", customVersionId: "v_abc"}}
|
|
89
53
|
```
|
|
90
54
|
|
|
91
|
-
|
|
55
|
+
To upgrade later, edit `customVersionId` deliberately and validate.
|
|
92
56
|
|
|
93
|
-
|
|
57
|
+
## AP5 — Wrong `sourceHandle` on branching nodes
|
|
94
58
|
|
|
95
|
-
|
|
59
|
+
**Mistake:** Adding an edge from an `if` node without `sourceHandle`, or using `"yes"`/`"no"` instead of `"true"`/`"false"`.
|
|
96
60
|
|
|
97
|
-
**Wrong
|
|
98
|
-
```
|
|
99
|
-
add_nodes({
|
|
100
|
-
flow_id: "...",
|
|
101
|
-
nodes: [
|
|
102
|
-
{ type: "if", temp_id: "check" },
|
|
103
|
-
{ type: "goal", temp_id: "ok" },
|
|
104
|
-
{ type: "exit", temp_id: "fail" }
|
|
105
|
-
],
|
|
106
|
-
edges: [
|
|
107
|
-
{ source: "check", target: "ok" }, // ← no source_handle — error
|
|
108
|
-
{ source: "check", target: "fail" } // ← no source_handle — error
|
|
109
|
-
]
|
|
110
|
-
})
|
|
111
|
-
```
|
|
61
|
+
**Why it's wrong:** Branching nodes require specific handle values. Wrong handle → edge ignored at runtime → mysterious "the flow just stopped."
|
|
112
62
|
|
|
113
|
-
**
|
|
63
|
+
**Do instead:** Look up handles per node type:
|
|
114
64
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
{ type: "goal", temp_id: "ok", data: { goalName: "approved" } },
|
|
122
|
-
{ type: "exit", temp_id: "fail", data: { exitName: "rejected" } }
|
|
123
|
-
],
|
|
124
|
-
edges: [
|
|
125
|
-
{ source: "check", target: "ok", source_handle: "true" },
|
|
126
|
-
{ source: "check", target: "fail", source_handle: "false" }
|
|
127
|
-
]
|
|
128
|
-
})
|
|
129
|
-
```
|
|
65
|
+
| Node type | Valid handles |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `if` | `"true"`, `"false"` |
|
|
68
|
+
| `switch` | case `outputLabel`s, or `"default"` |
|
|
69
|
+
| `loop` | `"loop"`, `"done"`, `"fail"` |
|
|
70
|
+
| `review` | `"option_0"`, `"option_1"`, … |
|
|
130
71
|
|
|
131
|
-
|
|
132
|
-
For loop: `"loop"`, `"done"`, or `"fail"` (only if `enableFailRoute: true`).
|
|
133
|
-
For review: the option's `id` (e.g. `"option_0"`).
|
|
134
|
-
For page: `"right"` or an abandonment id.
|
|
135
|
-
For splitTest: the variant's `label` string.
|
|
72
|
+
Or just call `describe_node_type(type)` and read `source_handles`.
|
|
136
73
|
|
|
137
|
-
|
|
74
|
+
## AP6 — `set_variable` inside a `loop`
|
|
138
75
|
|
|
139
|
-
|
|
76
|
+
**Mistake:** Calling `set_variable` from within a loop iteration to accumulate state.
|
|
140
77
|
|
|
141
|
-
**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
url: "https://api.x/$(\"trigger\").body.id", // ← $() in config field
|
|
151
|
-
method: "GET"
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
type: "code",
|
|
156
|
-
temp_id: "process",
|
|
157
|
-
data: {
|
|
158
|
-
code: "return { result: \"{{trigger.body.id}}\" }", // ← {{}} in code body
|
|
159
|
-
mode: "runOnce"
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
type: "httpRequest",
|
|
164
|
-
temp_id: "api2",
|
|
165
|
-
data: {
|
|
166
|
-
url: "https://api.x/{{ghostNodeId.data}}", // ← nodeId doesn't exist
|
|
167
|
-
method: "GET"
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
]
|
|
171
|
-
})
|
|
172
|
-
```
|
|
78
|
+
**Why it's wrong:** Variables are flow-scoped and shared across concurrent iterations. Race condition; values overwrite each other unpredictably.
|
|
79
|
+
|
|
80
|
+
**Do instead:** Use the `code` node's return value to push items onto an array stored as variable, OR use a state store (`set_state`, Phase 3). For now: collect via code node after the `loop` `done` handle.
|
|
81
|
+
|
|
82
|
+
## AP7 — Recursion via `claudeCode`
|
|
83
|
+
|
|
84
|
+
**Mistake:** A flow's `claudeCode` node dispatches work to a paired Claude Code agent. That agent happens to be using *this* MCP — and starts building a flow that itself has a `claudeCode` node.
|
|
85
|
+
|
|
86
|
+
**Why it's wrong:** Infinite recursion. Resource exhaustion. Possible runaway billing.
|
|
173
87
|
|
|
174
|
-
**
|
|
175
|
-
- `$()` in a config field is a literal string — templates use `{{}}`. `validate_flow` flags `dollar_in_config`.
|
|
176
|
-
- `{{}}` in a code body is a literal string inside JS — code nodes resolve fields via `$("nodeId")`. `validate_flow` warns `template_in_code`.
|
|
177
|
-
- `ghostNodeId` references a node that doesn't exist. `validate_flow` errors `unknown_node_reference`.
|
|
88
|
+
**Do instead:** When using `claudeCode`, restrict its prompt to tasks that do **not** modify flows. Better: scope the paired Claude Code agent's MCPs to exclude `addai-flows`.
|
|
178
89
|
|
|
179
|
-
|
|
90
|
+
## AP8 — Publishing without `pre_publish_check`
|
|
91
|
+
|
|
92
|
+
**Mistake:** Calling `publish_flow` directly because validation passed.
|
|
93
|
+
|
|
94
|
+
**Why it's wrong:** Validation is necessary but not sufficient. The flow may have inline secrets, deprecated nodes, failing snapshot tests, or unbacked Vault references. All of those will pass `validate_flow` but should still block publish.
|
|
95
|
+
|
|
96
|
+
**Do instead:**
|
|
180
97
|
```
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
nodes: [
|
|
184
|
-
{
|
|
185
|
-
type: "httpRequest",
|
|
186
|
-
temp_id: "api",
|
|
187
|
-
data: {
|
|
188
|
-
url: "https://api.x/{{trigger-real-id.body.id}}", // config: {{}}
|
|
189
|
-
method: "GET"
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
type: "code",
|
|
194
|
-
temp_id: "process",
|
|
195
|
-
data: {
|
|
196
|
-
code: `
|
|
197
|
-
const t = $("trigger-real-id"); // code: $()
|
|
198
|
-
return { result: t.body.id };
|
|
199
|
-
`,
|
|
200
|
-
mode: "runOnce"
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
]
|
|
204
|
-
})
|
|
98
|
+
pre_publish_check(flow_id) # → ready or blocked with reasons
|
|
99
|
+
publish_flow(flow_id) # only if check returned ready
|
|
205
100
|
```
|
|
206
101
|
|
|
207
|
-
|
|
102
|
+
(`pre_publish_check` is Phase 2 — until then, run validate_flow + manual inspection for inline secrets in code nodes.)
|
|
103
|
+
|
|
104
|
+
## AP9 — Polling instead of streaming
|
|
105
|
+
|
|
106
|
+
**Mistake:** Wrapping `test_flow` in a manual loop because you want to watch progress.
|
|
107
|
+
|
|
108
|
+
**Why it's wrong:** `test_flow` already polls internally. Wrapping it again multiplies the poll rate and wastes tokens.
|
|
109
|
+
|
|
110
|
+
**Do instead:** Use `test_flow_stream` (Phase 2 — SSE-based progress events). For Phase 1, `test_flow` is fine; don't add an outer loop.
|
|
111
|
+
|
|
112
|
+
## AP10 — Saving fixtures with PII
|
|
113
|
+
|
|
114
|
+
**Mistake:** `save_fixture(name, payload)` where the payload contains real user emails / phone numbers / card numbers.
|
|
115
|
+
|
|
116
|
+
**Why it's wrong:** Fixtures get reused in tests, shared in logs, possibly exported. Real PII in test data is a compliance leak.
|
|
117
|
+
|
|
118
|
+
**Do instead:**
|
|
119
|
+
- The MCP applies `data_masking_default=true` to fixtures by default — but only on display, not on save.
|
|
120
|
+
- Run the payload through `detect_pii(flow_id)` (Phase 2) before saving, or manually sanitize.
|
|
121
|
+
- Replace real values with synthetic ones (`user@example.com`, `+1 555 000 0000`).
|
|
122
|
+
|
|
123
|
+
## AP11 — Vertical drift from "I'll just add one more node"
|
|
124
|
+
|
|
125
|
+
**Mistake:** Repeatedly adding nodes downstream without thinking about the canvas. Result: a flow that has technically horizontal positions but is *narrower than tall* because branches stacked deeply.
|
|
126
|
+
|
|
127
|
+
**Why it's wrong:** `validate_flow` raises `LAYOUT_VERTICAL_DRIFT` when `height > 1.2 × width` with < 3 active branches. Looks weird; harder for the human to read.
|
|
128
|
+
|
|
129
|
+
**Do instead:** After significant additions, run `autolayout(flow_id)`. It's idempotent — safe to call any time.
|
|
130
|
+
|
|
131
|
+
## AP12 — Hand-rolling validation
|
|
132
|
+
|
|
133
|
+
**Mistake:** Writing your own checks ("does this flow have a trigger?") inside Claude's response instead of calling `validate_flow`.
|
|
134
|
+
|
|
135
|
+
**Why it's wrong:** Your hand-rolled check will drift from the real validator. It will miss rules that the server checks (template syntax, custom-node version pinning, schema version compatibility). Worse, it gives a false sense of correctness.
|
|
136
|
+
|
|
137
|
+
**Do instead:** Always `validate_flow`. The server is authoritative.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Flow semantics
|
|
2
|
+
|
|
3
|
+
The durable reference. Mechanics that do not change between releases. Catalog data (specific node types and their config schemas) is **not** here — fetch it via `describe_node_type` / `describe_page_element` / `describe_custom_node`.
|
|
4
|
+
|
|
5
|
+
## Graph model
|
|
6
|
+
|
|
7
|
+
A flow is `{ nodes[], edges[], variables[], end_conditions }`.
|
|
8
|
+
|
|
9
|
+
- **Node:** `{ id, type, data, position: {x, y} }`. The `data` shape depends on `type` (look up via `describe_node_type`).
|
|
10
|
+
- **Edge:** `{ id, source, target, sourceHandle?, targetHandle? }`. `sourceHandle` is required for branching nodes (see below).
|
|
11
|
+
- **Variables:** `[{ name, value, type }]`. Flow-scoped; reachable via `{{Variables.name}}`.
|
|
12
|
+
- **End conditions:** `{ goals: [{ id, label, nodeId }], exits: [{ id, label, nodeId }] }`. Tracks named termination points for analytics.
|
|
13
|
+
|
|
14
|
+
## The three variable systems
|
|
15
|
+
|
|
16
|
+
This is the most common source of confusion. Each context resolves variables differently. Mixing them up silently fails or produces `undefined`.
|
|
17
|
+
|
|
18
|
+
### 1. Config fields — `{{nodeId.field}}`
|
|
19
|
+
|
|
20
|
+
Used in any node's `data` fields that accept templates (URL, body, condition values, etc.). The engine resolves before the node executes.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
{{trigger.body.email}} # field from trigger output
|
|
24
|
+
{{http1.body.user.id}} # nested via dot
|
|
25
|
+
{{loop1.items[0]}} # array index
|
|
26
|
+
{{Variables.apiBase}} # flow variable
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Code node sandbox — `$("nodeId")`
|
|
30
|
+
|
|
31
|
+
Used **only** inside `code` nodes. The runner injects globals; `{{}}` syntax does **not** work here.
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
const email = $("trigger").body.email;
|
|
35
|
+
const items = $("http1").body.items;
|
|
36
|
+
return { count: items.length, email };
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
In `runForEachItem` mode you also get `item` (current element) and `index`.
|
|
40
|
+
|
|
41
|
+
### 3. Custom node sandbox — `inputs.x` / `secrets.x`
|
|
42
|
+
|
|
43
|
+
Used **only** inside custom node code. Inputs and secrets are pre-resolved by the engine before the function runs.
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
// custom node code
|
|
47
|
+
const url = inputs.endpoint; // declared in input_schema
|
|
48
|
+
const token = secrets.API_TOKEN; // declared in secret_requirements
|
|
49
|
+
return { ok: true, status: 200 };
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Do not use `$()` inside custom node code. Do not use `{{}}` inside custom node code.
|
|
53
|
+
|
|
54
|
+
## Edge handles per branching node
|
|
55
|
+
|
|
56
|
+
Branching nodes require a `sourceHandle` on every outgoing edge.
|
|
57
|
+
|
|
58
|
+
| Node type | Valid `sourceHandle` values |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `if` | `"true"`, `"false"` |
|
|
61
|
+
| `switch` | Each case's `outputLabel` value, or `"default"` |
|
|
62
|
+
| `loop` | `"loop"` (per-iteration), `"done"` (after all), `"fail"` (errors, if enableFailRoute) |
|
|
63
|
+
| `review` | `"option_0"`, `"option_1"`, … (one per option) |
|
|
64
|
+
| `page` | `"right"` (submission), or an abandonment ID per element |
|
|
65
|
+
| `splitTest` | Each variant's `label` |
|
|
66
|
+
| `aiSwitch` / `claudeSwitch` | Each route's `outputLabel`, or `"default"` |
|
|
67
|
+
|
|
68
|
+
Non-branching nodes (most node types) need no `sourceHandle` — leave it `null` or omit it.
|
|
69
|
+
|
|
70
|
+
## Goals and exits
|
|
71
|
+
|
|
72
|
+
Both terminate a run. The difference is semantic:
|
|
73
|
+
- `goal` — successful termination ("user signed up", "order processed"). Recorded as `status: "goal"`.
|
|
74
|
+
- `exit` — alternative termination ("user declined", "timeout reached"). Recorded as `status: "exit"`.
|
|
75
|
+
|
|
76
|
+
A flow can have multiple of each. Reaching any one terminates *that path* through the graph. Used for outcome breakdowns (`get_outcome_breakdown`).
|
|
77
|
+
|
|
78
|
+
## Run lifecycle
|
|
79
|
+
|
|
80
|
+
States: `running`, `completed`, `failed`, `cancelled`, `waiting`, `paused`, `error`, `goal`, `exit`.
|
|
81
|
+
|
|
82
|
+
- `running` — currently executing.
|
|
83
|
+
- `waiting` — paused at an async node, will resume.
|
|
84
|
+
- `paused` — paused for review or page submission.
|
|
85
|
+
- `completed` — all paths finished without hitting a goal/exit (rare; usually flows have terminators).
|
|
86
|
+
- `goal` / `exit` — reached a terminator node.
|
|
87
|
+
- `failed` / `error` — unhandled error.
|
|
88
|
+
- `cancelled` — explicit cancellation via `manage_run`.
|
|
89
|
+
|
|
90
|
+
## Pause and resume
|
|
91
|
+
|
|
92
|
+
Some node types pause execution. The resume server polls Supabase for waiting runs and resumes them with millisecond precision.
|
|
93
|
+
|
|
94
|
+
**Async pausers:**
|
|
95
|
+
- `wait` (when duration > 30s)
|
|
96
|
+
- `page` (waits for form submission)
|
|
97
|
+
- `review` (waits for human approval)
|
|
98
|
+
- `claudeCode` (waits for paired Claude Code agent response)
|
|
99
|
+
- `redirect` (waits for user to follow link)
|
|
100
|
+
|
|
101
|
+
Short waits (≤ 30s) are in-memory; longer waits persist. Either way, the run resumes automatically.
|
|
102
|
+
|
|
103
|
+
## Sandbox boundaries
|
|
104
|
+
|
|
105
|
+
| Sandbox | Globals available | Variable syntax |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| **Code node** | `$("nodeId")`, `console.log`, `fetch` (some URLs blocked), `item`/`index` in forEach mode | `$()` |
|
|
108
|
+
| **Custom node** | `inputs.x`, `secrets.x`, `fetch` (restricted to declared domains), `console.log` | `inputs` / `secrets` |
|
|
109
|
+
| **Config field** | (resolved by engine before node runs) | `{{}}` |
|
|
110
|
+
|
|
111
|
+
Don't cross sandboxes. Cross-sandbox confusion is the #1 source of "why is this undefined."
|
|
112
|
+
|
|
113
|
+
## Layout rules (P9 — horizontal by default)
|
|
114
|
+
|
|
115
|
+
Every node has a `position: {x, y}`. The canonical convention:
|
|
116
|
+
|
|
117
|
+
- **Trigger** at `x ≈ 0`.
|
|
118
|
+
- Each downstream node `x = previous.x + h_spacing` (default `280`).
|
|
119
|
+
- Branching node's branches: same `x`, different `y`. Each branch gets a lane at `y = branching.y + (lane_index - center) × v_spacing` (default `160`).
|
|
120
|
+
- Loops: loop body lanes above, `done` continues right at center.
|
|
121
|
+
- **Goals and exits** on the **rightmost** `x` in the flow.
|
|
122
|
+
|
|
123
|
+
You almost never need to assign positions yourself — pass no `position` to `add_nodes` and the MCP places nodes correctly. If positions get messy after refactoring, call `autolayout(flow_id)`.
|
|
124
|
+
|
|
125
|
+
Constants: `get_layout_config()` returns the canonical values for `h_spacing`, `v_spacing`, and per-node-type widths.
|
|
126
|
+
|
|
127
|
+
## Custom node versioning
|
|
128
|
+
|
|
129
|
+
Custom nodes are versioned. **Versions do not auto-update on publish.** When inserting a `customNode` node, you must provide:
|
|
130
|
+
- `customNodeId` — which custom node
|
|
131
|
+
- `customVersionId` — which exact version (pin to specific version)
|
|
132
|
+
|
|
133
|
+
If you don't pin, the flow is broken. There is no implicit "use latest" — that would silently break flows on every custom-node publish.
|
|
134
|
+
|
|
135
|
+
To upgrade a flow's custom node version, edit the `customVersionId` deliberately and validate.
|
|
136
|
+
|
|
137
|
+
## Trace IDs
|
|
138
|
+
|
|
139
|
+
Every MCP tool error includes a `trace_id` field. When a tool fails:
|
|
140
|
+
- Report the trace_id to the user — they can quote it to support.
|
|
141
|
+
- Don't paper over the error with a generic retry.
|
|
142
|
+
- Use `diagnose_run` (Phase 2) to get the full failure context.
|