@addai/flows-mcp 0.5.0 → 1.0.0-rc.1
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 +3 -0
- 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 +15 -3
- 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/recipes.md
CHANGED
|
@@ -1,308 +1,199 @@
|
|
|
1
|
-
# Flow
|
|
1
|
+
# Flow recipes
|
|
2
2
|
|
|
3
|
-
Each recipe
|
|
3
|
+
Patterns to compose. Each recipe is a flow shape that solves a class of problem. Read the recipe header to find the right one; then follow the exact tool-call sequence inside.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
When in doubt, build with these recipes as templates and adapt — don't invent from scratch.
|
|
6
6
|
|
|
7
|
-
## Recipe 1
|
|
7
|
+
## Recipe 1 — Form-driven flow
|
|
8
8
|
|
|
9
|
+
**Use when:** Public form collects input → process → email confirmation.
|
|
10
|
+
|
|
11
|
+
**Shape:**
|
|
12
|
+
```
|
|
13
|
+
[page trigger] → [code: validate] → [httpRequest: save] → [code: build email] → [respondToWebhook] → [goal]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Tool sequence:**
|
|
9
17
|
```
|
|
10
|
-
create_flow({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
method: "POST",
|
|
29
|
-
bodyType: "json",
|
|
30
|
-
body: '{"id": "{{trigger-id.body.id}}"}',
|
|
31
|
-
authentication: { type: "bearer", token: "{{Variables.apiKey}}" }
|
|
32
|
-
}},
|
|
33
|
-
{ type: "goal", temp_id: "ok", data: { goalName: "fulfilled" } },
|
|
34
|
-
{ type: "exit", temp_id: "low", data: { exitName: "below_threshold" } }
|
|
35
|
-
],
|
|
36
|
-
edges: [
|
|
37
|
-
{ source: "trigger-id", target: "check" },
|
|
38
|
-
{ source: "check", target: "fulfill", source_handle: "true" },
|
|
39
|
-
{ source: "check", target: "low", source_handle: "false" },
|
|
40
|
-
{ source: "fulfill", target: "ok" }
|
|
41
|
-
]
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
validate_flow({ flow_id: "flow-id" })
|
|
45
|
-
test_flow({ flow_id: "flow-id", input_data: { total: 150, id: "ord-123" } })
|
|
46
|
-
publish_flow({ flow_id: "flow-id" })
|
|
18
|
+
1. create_flow({name: "signup", description: "Public signup form"})
|
|
19
|
+
2. describe_node_type("page") # confirm config shape for isStartForm
|
|
20
|
+
3. add_nodes({flow_id, nodes: [
|
|
21
|
+
{id: "form", type: "page", data: {isStartForm: true, elements: [...]}},
|
|
22
|
+
{id: "validate", type: "code", data: {code: "...", mode: "runOnce"}},
|
|
23
|
+
{id: "save", type: "httpRequest", data: {url: "...", method: "POST"}},
|
|
24
|
+
{id: "email", type: "code", data: {code: "..."}},
|
|
25
|
+
{id: "respond", type: "respondToWebhook", data: {status: 200, body: "ok"}},
|
|
26
|
+
{id: "done", type: "goal", data: {goalName: "signup_complete"}},
|
|
27
|
+
], edges: [
|
|
28
|
+
{source: "form", target: "validate", sourceHandle: "right"},
|
|
29
|
+
{source: "validate", target: "save"},
|
|
30
|
+
{source: "save", target: "email"},
|
|
31
|
+
{source: "email", target: "respond"},
|
|
32
|
+
{source: "respond", target: "done"},
|
|
33
|
+
]})
|
|
34
|
+
4. validate_flow({flow_id})
|
|
35
|
+
5. test_flow({flow_id, input_data: {email: "test@example.com"}})
|
|
47
36
|
```
|
|
48
37
|
|
|
49
|
-
|
|
38
|
+
## Recipe 2 — HTTP fan-out with retries
|
|
50
39
|
|
|
51
|
-
|
|
40
|
+
**Use when:** Loop over a list, call an HTTP API per item, collect results, continue.
|
|
52
41
|
|
|
42
|
+
**Shape:**
|
|
53
43
|
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
get_flow({ flow_id: "flow-id" })
|
|
57
|
-
remove_nodes({ flow_id: "flow-id", node_ids: ["trigger-id"] })
|
|
58
|
-
|
|
59
|
-
add_nodes({
|
|
60
|
-
flow_id: "flow-id",
|
|
61
|
-
nodes: [
|
|
62
|
-
{ type: "page", temp_id: "form", data: {
|
|
63
|
-
isStartForm: true,
|
|
64
|
-
formSlug: "signup",
|
|
65
|
-
elements: [
|
|
66
|
-
{ id: crypto.randomUUID(), type: "shortText", label: "Name", required: true },
|
|
67
|
-
{ id: crypto.randomUUID(), type: "email", label: "Email", required: true }
|
|
68
|
-
]
|
|
69
|
-
}},
|
|
70
|
-
{ type: "map", temp_id: "transform", data: {
|
|
71
|
-
mappings: [
|
|
72
|
-
{ id: crypto.randomUUID(), inputExpression: "{{form.submissionData.Name}}",
|
|
73
|
-
outputName: "display_name", transformType: "trim", enabled: true },
|
|
74
|
-
{ id: crypto.randomUUID(), inputExpression: "{{form.submissionData.Email}}",
|
|
75
|
-
outputName: "email_lower", transformType: "lowercase", enabled: true }
|
|
76
|
-
]
|
|
77
|
-
}},
|
|
78
|
-
{ type: "goal", temp_id: "done", data: { goalName: "signed_up" } }
|
|
79
|
-
],
|
|
80
|
-
edges: [
|
|
81
|
-
{ source: "form", target: "transform", source_handle: "right" },
|
|
82
|
-
{ source: "transform", target: "done" }
|
|
83
|
-
]
|
|
84
|
-
})
|
|
44
|
+
[trigger] → [loop] -loop-> [httpRequest] → [code: accumulate] → (back to loop)
|
|
45
|
+
\-done-> [code: summarize] → [respondToWebhook]
|
|
85
46
|
```
|
|
86
47
|
|
|
87
|
-
|
|
48
|
+
**Key points:**
|
|
49
|
+
- The `httpRequest` `onError` config controls retry. Use `retries: 3` and `onError: "continue"` for tolerant fan-out.
|
|
50
|
+
- After the loop's `done` handle, gather the iteration results via `$("loop1").items` in a code node.
|
|
51
|
+
|
|
52
|
+
## Recipe 3 — Branching with fallback exit
|
|
88
53
|
|
|
89
|
-
|
|
54
|
+
**Use when:** Decide between two paths; one path may fail; provide an explicit alternative termination.
|
|
90
55
|
|
|
56
|
+
**Shape:**
|
|
91
57
|
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
add_nodes({
|
|
95
|
-
flow_id: "flow-id",
|
|
96
|
-
nodes: [
|
|
97
|
-
{ type: "httpRequest", temp_id: "fetch", data: {
|
|
98
|
-
url: "https://api.x/pending-items", method: "GET"
|
|
99
|
-
}},
|
|
100
|
-
{ type: "loop", temp_id: "each", data: {
|
|
101
|
-
arraySources: ["{{fetch.body.items}}"]
|
|
102
|
-
}},
|
|
103
|
-
{ type: "variable", temp_id: "bump", data: {
|
|
104
|
-
action: "update", variableName: "processed_count", operator: "add", value: "1"
|
|
105
|
-
}},
|
|
106
|
-
{ type: "goal", temp_id: "done", data: { goalName: "batch_complete" } }
|
|
107
|
-
],
|
|
108
|
-
edges: [
|
|
109
|
-
{ source: "schedule-trigger-id", target: "fetch" },
|
|
110
|
-
{ source: "fetch", target: "each" },
|
|
111
|
-
{ source: "each", target: "bump", source_handle: "loop" },
|
|
112
|
-
{ source: "each", target: "done", source_handle: "done" }
|
|
113
|
-
]
|
|
114
|
-
})
|
|
58
|
+
[trigger] → [if] -true-> [httpRequest: primary] → [goal: success]
|
|
59
|
+
\-false-> [httpRequest: fallback] → [exit: fallback_used]
|
|
115
60
|
```
|
|
116
61
|
|
|
117
|
-
|
|
62
|
+
The two terminators (`goal` vs `exit`) let you measure the rate of fallback usage via `get_outcome_breakdown`.
|
|
63
|
+
|
|
64
|
+
## Recipe 4 — A/B test setup
|
|
118
65
|
|
|
119
|
-
|
|
66
|
+
**Use when:** Compare two flow variants on production traffic.
|
|
120
67
|
|
|
68
|
+
**Tool sequence:**
|
|
121
69
|
```
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const category = body.toLowerCase().includes("billing") ? "billing"
|
|
134
|
-
: body.toLowerCase().includes("bug") ? "bug"
|
|
135
|
-
: "general";
|
|
136
|
-
return { isUrgent, category };
|
|
137
|
-
`
|
|
138
|
-
}},
|
|
139
|
-
{ type: "switch", temp_id: "route", data: {
|
|
140
|
-
mode: "first",
|
|
141
|
-
hasDefault: true,
|
|
142
|
-
cases: [
|
|
143
|
-
{ id: crypto.randomUUID(), outputLabel: "case-billing", logicOperator: "AND", enabled: true,
|
|
144
|
-
conditions: [{ id: crypto.randomUUID(), leftValue: "{{parse.category}}",
|
|
145
|
-
operator: "equals", rightValue: "billing", dataType: "string" }] },
|
|
146
|
-
{ id: crypto.randomUUID(), outputLabel: "case-bug", logicOperator: "AND", enabled: true,
|
|
147
|
-
conditions: [{ id: crypto.randomUUID(), leftValue: "{{parse.category}}",
|
|
148
|
-
operator: "equals", rightValue: "bug", dataType: "string" }] }
|
|
149
|
-
]
|
|
150
|
-
}}
|
|
151
|
-
// + downstream nodes for each branch...
|
|
152
|
-
],
|
|
153
|
-
edges: [
|
|
154
|
-
{ source: "email-trigger-id", target: "parse" },
|
|
155
|
-
{ source: "parse", target: "route" }
|
|
156
|
-
// edges from route with source_handle: "case-billing" / "case-bug" / "default"
|
|
157
|
-
]
|
|
158
|
-
})
|
|
70
|
+
1. create_version({flow_id, name: "v1-baseline"}) # snapshot current state
|
|
71
|
+
2. (edit flow into variant B)
|
|
72
|
+
3. publish_flow({flow_id, version_name: "v2-experiment"})
|
|
73
|
+
4. create_split_test({flow_id, name: "homepage_copy", variants: [
|
|
74
|
+
{version_id: "<v1_id>", label: "control", percentage: 50},
|
|
75
|
+
{version_id: "<v2_id>", label: "variant", percentage: 50},
|
|
76
|
+
]})
|
|
77
|
+
5. start_split_test({split_test_id})
|
|
78
|
+
# Wait for results...
|
|
79
|
+
6. get_split_test_analytics({split_test_id})
|
|
80
|
+
7. declare_split_test_winner({split_test_id, winner_version_id: "<winner>"})
|
|
159
81
|
```
|
|
160
82
|
|
|
161
|
-
|
|
83
|
+
## Recipe 5 — Child-flow composition
|
|
162
84
|
|
|
163
|
-
|
|
85
|
+
**Use when:** A reusable subroutine called by multiple parent flows.
|
|
86
|
+
|
|
87
|
+
**Shape:** Parent uses a `flow` node that invokes a child flow.
|
|
164
88
|
|
|
165
89
|
```
|
|
166
|
-
|
|
167
|
-
flow_id: "flow-id",
|
|
168
|
-
nodes: [
|
|
169
|
-
{ type: "review", temp_id: "approval", data: {
|
|
170
|
-
title: "New row needs approval",
|
|
171
|
-
description: "Review the row data and approve or reject",
|
|
172
|
-
fields: [
|
|
173
|
-
{ id: crypto.randomUUID(), label: "Requested by", value: "{{table-trigger-id.row.requester}}" },
|
|
174
|
-
{ id: crypto.randomUUID(), label: "Amount", value: "{{table-trigger-id.row.amount}}" }
|
|
175
|
-
],
|
|
176
|
-
options: [
|
|
177
|
-
{ id: "option_0", label: "Approve", color: "green" },
|
|
178
|
-
{ id: "option_1", label: "Reject", color: "red" }
|
|
179
|
-
]
|
|
180
|
-
}},
|
|
181
|
-
{ type: "httpRequest", temp_id: "approve-api", data: {
|
|
182
|
-
url: "https://api.x/approve/{{table-trigger-id.rowId}}", method: "POST"
|
|
183
|
-
}},
|
|
184
|
-
{ type: "goal", temp_id: "ok", data: { goalName: "approved" } },
|
|
185
|
-
{ type: "exit", temp_id: "no", data: { exitName: "rejected" } }
|
|
186
|
-
],
|
|
187
|
-
edges: [
|
|
188
|
-
{ source: "table-trigger-id", target: "approval" },
|
|
189
|
-
{ source: "approval", target: "approve-api", source_handle: "option_0" },
|
|
190
|
-
{ source: "approval", target: "no", source_handle: "option_1" },
|
|
191
|
-
{ source: "approve-api", target: "ok" }
|
|
192
|
-
]
|
|
193
|
-
})
|
|
90
|
+
[parent trigger] → [code: prep input] → [flow: invoke_child(flowId)] → [code: handle output] → [goal]
|
|
194
91
|
```
|
|
195
92
|
|
|
196
|
-
|
|
93
|
+
The child receives `body` as its trigger input; output of the `flow` node has `runId`, `status`, `outputs`.
|
|
94
|
+
|
|
95
|
+
## Recipe 6 — Paginated HTTP fetch
|
|
197
96
|
|
|
198
|
-
|
|
97
|
+
**Use when:** External API returns paginated results; need to walk pages until empty.
|
|
199
98
|
|
|
99
|
+
**Shape:**
|
|
200
100
|
```
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
{ type: "httpRequest", temp_id: "fetch", data: {
|
|
205
|
-
url: "https://api.x/users", method: "GET"
|
|
206
|
-
}},
|
|
207
|
-
{ type: "code", temp_id: "filter", data: {
|
|
208
|
-
mode: "runOnce",
|
|
209
|
-
code: `
|
|
210
|
-
const res = $("fetch");
|
|
211
|
-
const active = (res.body.users || []).filter(u => u.active);
|
|
212
|
-
return { users: active, count: active.length };
|
|
213
|
-
`
|
|
214
|
-
}},
|
|
215
|
-
{ type: "splitTest", temp_id: "variant", data: {
|
|
216
|
-
variants: [
|
|
217
|
-
{ id: crypto.randomUUID(), label: "Variant A", percentage: 50 },
|
|
218
|
-
{ id: crypto.randomUUID(), label: "Variant B", percentage: 50 }
|
|
219
|
-
]
|
|
220
|
-
}},
|
|
221
|
-
{ type: "httpRequest", temp_id: "notify-a", data: {
|
|
222
|
-
url: "https://api.x/notify/a", method: "POST",
|
|
223
|
-
bodyType: "json", body: '{"count": "{{filter.count}}"}'
|
|
224
|
-
}},
|
|
225
|
-
{ type: "httpRequest", temp_id: "notify-b", data: {
|
|
226
|
-
url: "https://api.x/notify/b", method: "POST",
|
|
227
|
-
bodyType: "json", body: '{"count": "{{filter.count}}"}'
|
|
228
|
-
}}
|
|
229
|
-
],
|
|
230
|
-
edges: [
|
|
231
|
-
{ source: "trigger-id", target: "fetch" },
|
|
232
|
-
{ source: "fetch", target: "filter" },
|
|
233
|
-
{ source: "filter", target: "variant" },
|
|
234
|
-
{ source: "variant", target: "notify-a", source_handle: "Variant A" },
|
|
235
|
-
{ source: "variant", target: "notify-b", source_handle: "Variant B" }
|
|
236
|
-
]
|
|
237
|
-
})
|
|
101
|
+
[trigger] → [variable: init cursor=null] → [httpRequest: fetch page] →
|
|
102
|
+
[if: hasMore] -true-> [variable: update cursor] → (back to httpRequest)
|
|
103
|
+
\-false-> [code: aggregate] → [goal]
|
|
238
104
|
```
|
|
239
105
|
|
|
240
|
-
|
|
106
|
+
Variables hold the cursor; `goTo` to the `httpRequest` re-runs with updated state.
|
|
107
|
+
|
|
108
|
+
## Recipe 7 — Retry-on-failure with exponential backoff (code-node version)
|
|
241
109
|
|
|
242
|
-
|
|
110
|
+
**Use when:** A flaky external dependency needs retry logic beyond what `httpRequest` provides.
|
|
243
111
|
|
|
112
|
+
Inside a code node:
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
async function tryFetch(url, attempt = 1, maxAttempts = 5) {
|
|
116
|
+
const r = await fetch(url);
|
|
117
|
+
if (r.ok) return await r.json();
|
|
118
|
+
if (attempt >= maxAttempts) throw new Error(`Failed after ${attempt} attempts`);
|
|
119
|
+
await new Promise(res => setTimeout(res, 200 * Math.pow(2, attempt - 1)));
|
|
120
|
+
return tryFetch(url, attempt + 1, maxAttempts);
|
|
121
|
+
}
|
|
122
|
+
return { data: await tryFetch($("trigger").body.url) };
|
|
244
123
|
```
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
flowId: "child-flow-id",
|
|
253
|
-
flowName: "Send Reminder",
|
|
254
|
-
waitForCompletion: true,
|
|
255
|
-
body: '{"email": "{{trigger-id.body.email}}"}'
|
|
256
|
-
}},
|
|
257
|
-
{ type: "goal", temp_id: "done", data: { goalName: "reminder_sent" } }
|
|
258
|
-
],
|
|
259
|
-
edges: [
|
|
260
|
-
{ source: "trigger-id", target: "pause" },
|
|
261
|
-
{ source: "pause", target: "sub" },
|
|
262
|
-
{ source: "sub", target: "done" }
|
|
263
|
-
]
|
|
264
|
-
})
|
|
124
|
+
|
|
125
|
+
When this pattern recurs, **promote it to a custom node** so other flows can reuse it (see Recipe 8).
|
|
126
|
+
|
|
127
|
+
## Recipe 8 — Promote a code node to a custom node
|
|
128
|
+
|
|
129
|
+
**Use when:** The same code pattern appears in 3+ flows.
|
|
130
|
+
|
|
265
131
|
```
|
|
132
|
+
1. test_custom_node_code({code, input_schema, output_schema, inputs: {...}})
|
|
133
|
+
2. create_custom_node({name, code, input_schema, output_schema, secret_requirements})
|
|
134
|
+
3. publish_custom_node({custom_node_id, version: "1.0.0"})
|
|
135
|
+
4. Inside each consumer flow, replace the inline code with a customNode reference:
|
|
136
|
+
{type: "customNode", data: {customNodeId, customVersionId}}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Always pin `customVersionId`** — see flow-semantics.md.
|
|
266
140
|
|
|
267
|
-
|
|
141
|
+
## Recipe 9 — Webhook trigger with HMAC verification
|
|
268
142
|
|
|
269
|
-
|
|
143
|
+
**Use when:** External service signs requests; verify before processing.
|
|
270
144
|
|
|
271
145
|
```
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
{ type: "page", temp_id: "form", data: {
|
|
276
|
-
elements: [
|
|
277
|
-
{ id: crypto.randomUUID(), type: "longText", label: "Feedback", required: true }
|
|
278
|
-
]
|
|
279
|
-
}},
|
|
280
|
-
{ type: "review", temp_id: "check", data: {
|
|
281
|
-
title: "Review submitted feedback",
|
|
282
|
-
fields: [{ id: crypto.randomUUID(), label: "Feedback", value: "{{form.submissionData.Feedback}}" }],
|
|
283
|
-
options: [
|
|
284
|
-
{ id: "option_0", label: "Publish", color: "green" },
|
|
285
|
-
{ id: "option_1", label: "Spam", color: "red" }
|
|
286
|
-
]
|
|
287
|
-
}},
|
|
288
|
-
{ type: "map", temp_id: "prep", data: {
|
|
289
|
-
mappings: [
|
|
290
|
-
{ id: crypto.randomUUID(), inputExpression: "{{form.submissionData.Feedback}}",
|
|
291
|
-
outputName: "trimmed", transformType: "trim", enabled: true }
|
|
292
|
-
]
|
|
293
|
-
}},
|
|
294
|
-
{ type: "respondToWebhook", temp_id: "resp", data: {
|
|
295
|
-
statusCode: 200, bodyType: "json",
|
|
296
|
-
responseBody: '{"status":"published","content":"{{prep.trimmed}}"}'
|
|
297
|
-
}},
|
|
298
|
-
{ type: "exit", temp_id: "spam", data: { exitName: "rejected" } }
|
|
299
|
-
],
|
|
300
|
-
edges: [
|
|
301
|
-
{ source: "trigger-id", target: "form" },
|
|
302
|
-
{ source: "form", target: "check", source_handle: "right" },
|
|
303
|
-
{ source: "check", target: "prep", source_handle: "option_0" },
|
|
304
|
-
{ source: "check", target: "spam", source_handle: "option_1" },
|
|
305
|
-
{ source: "prep", target: "resp" }
|
|
306
|
-
]
|
|
307
|
-
})
|
|
146
|
+
[trigger (webhook)] → [code: verifyHmac] →
|
|
147
|
+
[if: valid] -true-> [process...] -> [respondToWebhook(200)] -> [goal]
|
|
148
|
+
\-false-> [respondToWebhook(401)] -> [exit: invalid_signature]
|
|
308
149
|
```
|
|
150
|
+
|
|
151
|
+
Inside the verify code node:
|
|
152
|
+
```javascript
|
|
153
|
+
import crypto from 'crypto';
|
|
154
|
+
const sig = $("trigger").headers['x-signature'];
|
|
155
|
+
const payload = JSON.stringify($("trigger").body);
|
|
156
|
+
const expected = crypto.createHmac('sha256', secrets.WEBHOOK_SECRET).update(payload).digest('hex');
|
|
157
|
+
return { valid: sig === expected };
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Recipe 10 — Schedule trigger with TZ-aware cron
|
|
161
|
+
|
|
162
|
+
**Use when:** Run a flow on a recurring schedule in a specific timezone.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
[scheduleTrigger: cron="0 9 * * MON" tz="America/New_York"] → [...] → [goal]
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Before adding: `preview_schedule({cron_expression: "0 9 * * MON", timezone: "America/New_York", count: 10})` (Phase 2 tool — for Phase 1, manually verify the cron in [crontab.guru](https://crontab.guru) with the TZ in mind).
|
|
169
|
+
|
|
170
|
+
Anti-pattern: don't use UTC cron when the business meaning is local time. DST will silently shift fires.
|
|
171
|
+
|
|
172
|
+
## Recipe 11 — Tables-driven flow
|
|
173
|
+
|
|
174
|
+
**Use when:** Trigger on row insert/update in a +Ai Tables table.
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
[tableTrigger(insert)] → [code: enrich] → [httpRequest: notify] → [goal]
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Trigger output shape:
|
|
181
|
+
```
|
|
182
|
+
{ event: "INSERT", row: {...}, oldRow: null, rowId: "...", databaseId: "...", tableId: "..." }
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Validate referenced columns exist before publish: `list_table_triggers(table_id)` then check via Tables API (Phase 2: `validate_table_columns`).
|
|
186
|
+
|
|
187
|
+
## Recipe 12 — Approval-gated publish
|
|
188
|
+
|
|
189
|
+
**Use when:** A flow change requires human approval before going live.
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
[trigger] → [...changes...] →
|
|
193
|
+
[review (approver_email)] -approved-> [respondToWebhook(200)] -> [goal]
|
|
194
|
+
\-rejected-> [exit: review_rejected]
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The `review` node pauses execution until a human responds. Use `respond_to_review` (tool) to act as approver during dev — or wire to your actual approval channel.
|
|
198
|
+
|
|
199
|
+
Pre-publish always: `pre_publish_check` (Phase 2) gates publishing on approval status.
|
package/skill/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
2.0.0
|
package/skill/node-cheatsheet.md
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Node Cheatsheet — Auto-Generated
|
|
2
|
-
|
|
3
|
-
> Generated from NODE_TYPES at build time. Do NOT edit by hand — changes will be overwritten.
|
|
4
|
-
|
|
5
|
-
| Type | Category | Required fields | Source handles | Key output fields | Gotcha |
|
|
6
|
-
|------|----------|-----------------|----------------|-------------------|--------|
|
|
7
|
-
| `trigger` | triggers | — | (default) | `body`, `headers`, `query`, `method` | The webhook URL is auto-generated after the flow is published |
|
|
8
|
-
| `scheduleTrigger` | triggers | — | (default) | `scheduledTime`, `scheduleType` | intervalUnit options: seconds, minutes, hours, days |
|
|
9
|
-
| `tablesSchedule` | triggers | — | (default) | `scheduledTime`, `databaseId`, `tableId` | — |
|
|
10
|
-
| `tableButton` | triggers | — | (default) | `row`, `rowId`, `tableId`, `columnId` | — |
|
|
11
|
-
| `tableActionTrigger` | triggers | — | (default) | `row`, `rowId`, `buttonId`, `databaseId` | — |
|
|
12
|
-
| `batchActionTrigger` | triggers | — | (default) | `row`, `rowId`, `actionId`, `databaseId` | — |
|
|
13
|
-
| `tableTrigger` | triggers | — | (default) | `event`, `row`, `oldRow`, `rowId` | — |
|
|
14
|
-
| `emailTrigger` | triggers | — | (default) | `from`, `to`, `subject`, `text` | — |
|
|
15
|
-
| `httpRequest` | processing | url, method | (default) | `status`, `body`, `headers`, `success` | URL supports {{nodeId.field}} templates, e.g. "https://api.example.com/users/... |
|
|
16
|
-
| `respondToWebhook` | processing | — | (default) | `success`, `statusCode`, `responseBody`, `skipped` | Must be used in a flow that starts with a Webhook Trigger |
|
|
17
|
-
| `code` | processing | code, mode | `right` | `<user-defined>` | Always return an object: return { result: data } |
|
|
18
|
-
| `map` | processing | mappings | (default) | `<outputName>`, `_metadata`, `transformMode` | inputExpression supports {{nodeId.field}} template syntax |
|
|
19
|
-
| `if` | logic | conditions, conditionLogic | `true`, `false` | `conditionMet`, `evaluatedConditions`, `logicOperator` | leftValue and rightValue support {{nodeId.field}} templates |
|
|
20
|
-
| `switch` | logic | cases | `<case.outputLabel>`, `default` | `matchedHandles`, `matchedCaseLabels`, `hasDefault`, `mode` | source_handle must match the case's outputLabel value (e.g. "case-0") |
|
|
21
|
-
| `wait` | logic | waitType | (default) | `type`, `duration`, `completedAt`, `pauseInDatabase` | durationUnit options: seconds, minutes, hours, days |
|
|
22
|
-
| `flow` | logic | flowId | (default) | `flowId`, `flowName`, `runId`, `waitedForCompletion` | body supports {{}} templates for passing dynamic data to the child flow |
|
|
23
|
-
| `goal` | logic | — | (default) | `goalName`, `isEndNode`, `endType`, `success` | Goal nodes have no output handles — they terminate the flow path |
|
|
24
|
-
| `exit` | logic | — | (default) | `exitName`, `isEndNode`, `endType`, `success` | Exit nodes have no output handles — they terminate the flow path |
|
|
25
|
-
| `review` | logic | options | `option_0`, `option_1`, `option_N` | `selectedOption`, `selectedOptionLabel`, `reviewData`, `respondedBy` | source_handle must match the option's id (e.g. "option_0" for Approve) |
|
|
26
|
-
| `page` | logic | — | `right`, `<abandonment.id>` | `submissionData`, `submittedDate`, `status`, `activeHandle` | Use source_handle "right" for the submission path |
|
|
27
|
-
| `loop` | logic | arraySources | `loop`, `done`, `fail` | `items`, `totalItems`, `currentItem`, `currentIndex` | arraySources uses {{nodeId.field}} syntax, e.g. ["{{httpRequestId.body.data}}"] |
|
|
28
|
-
| `subflow` | logic | — | (default) | — | Subflows are purely visual — they don't change execution behavior |
|
|
29
|
-
| `variable` | logic | action | (default) | `action`, `variableName`, `previousValue`, `newValue` | Reference variables in other node config fields as {{Variables.varName}} |
|
|
30
|
-
| `splitTest` | logic | variants | `Variant A`, `Variant B` | `selectedHandle`, `selectedLabel`, `selectedVariantId` | source_handle must match the variant's label string (e.g. "Variant A") |
|
|
31
|
-
| `customNode` | custom | — | (default) | `<defined by output_schema>` | Custom node code uses inputs.keyName, NOT $("nodeId") — $() is only for inlin... |
|
|
32
|
-
| `note` | utility | — | (default) | — | Notes are not connected to the flow — they are visual only |
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
For full per-type detail (defaultData, tips, guide), call `get_node_type_info(type)` at runtime.
|
|
37
|
-
For form element types, call `list_page_elements` and `get_page_element_info(element_type)`.
|