@n8n/instance-ai 1.17.3 → 1.19.0
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/agent/apply-agent-thinking.js +1 -1
- package/dist/agent/apply-agent-thinking.js.map +1 -1
- package/dist/agent/computer-use-prompt.js +2 -2
- package/dist/agent/instance-agent.d.ts +7 -1
- package/dist/agent/instance-agent.js +9 -2
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/shared-prompts.d.ts +1 -1
- package/dist/agent/shared-prompts.js +7 -21
- package/dist/agent/shared-prompts.js.map +1 -1
- package/dist/agent/sub-agent-factory.d.ts +1 -1
- package/dist/agent/system-prompt.js +43 -105
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/debug/run-debug-buffer.d.ts +8 -7
- package/dist/debug/run-debug-buffer.js +7 -6
- package/dist/debug/run-debug-buffer.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/mcp-client-manager.d.ts +13 -1
- package/dist/mcp/mcp-client-manager.js +17 -2
- package/dist/mcp/mcp-client-manager.js.map +1 -1
- package/dist/runtime/run-state-registry.d.ts +5 -3
- package/dist/runtime/run-state-registry.js +5 -2
- package/dist/runtime/run-state-registry.js.map +1 -1
- package/dist/storage/workflow-loop-storage.d.ts +94 -0
- package/dist/stream/map-chunk.d.ts +1 -2
- package/dist/stream/map-chunk.js +38 -21
- package/dist/stream/map-chunk.js.map +1 -1
- package/dist/tools/attachments/parse-file.tool.js +2 -0
- package/dist/tools/attachments/parse-file.tool.js.map +1 -1
- package/dist/tools/credentials.tool.js +3 -2
- package/dist/tools/credentials.tool.js.map +1 -1
- package/dist/tools/data-tables.tool.js +5 -1
- package/dist/tools/data-tables.tool.js.map +1 -1
- package/dist/tools/evals/eval-config.tool.js +42 -7
- package/dist/tools/evals/eval-config.tool.js.map +1 -1
- package/dist/tools/index.js +0 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nodes/node-search-engine.js +7 -0
- package/dist/tools/nodes/node-search-engine.js.map +1 -1
- package/dist/tools/nodes/node-search-engine.types.d.ts +3 -0
- package/dist/tools/nodes/node-search-engine.types.js.map +1 -1
- package/dist/tools/orchestration/agent-target-binding.d.ts +18 -2
- package/dist/tools/orchestration/agent-target-binding.js +56 -25
- package/dist/tools/orchestration/agent-target-binding.js.map +1 -1
- package/dist/tools/orchestration/build-agent.tool.js +227 -70
- package/dist/tools/orchestration/build-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/verification/analyze-result.d.ts +5 -0
- package/dist/tools/orchestration/verification/analyze-result.js +14 -3
- package/dist/tools/orchestration/verification/analyze-result.js.map +1 -1
- package/dist/tools/orchestration/verification/prepare-run.d.ts +3 -1
- package/dist/tools/orchestration/verification/prepare-run.js +34 -0
- package/dist/tools/orchestration/verification/prepare-run.js.map +1 -1
- package/dist/tools/orchestration/verification/scripted-gate-run.d.ts +23 -0
- package/dist/tools/orchestration/verification/scripted-gate-run.js +91 -0
- package/dist/tools/orchestration/verification/scripted-gate-run.js.map +1 -0
- package/dist/tools/orchestration/verify-built-workflow.tool.js +33 -12
- package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
- package/dist/tools/research.tool.js +6 -1
- package/dist/tools/research.tool.js.map +1 -1
- package/dist/tools/task-control.tool.js +2 -2
- package/dist/tools/task-control.tool.js.map +1 -1
- package/dist/tools/tool-ids.d.ts +0 -1
- package/dist/tools/tool-ids.js +2 -2
- package/dist/tools/tool-ids.js.map +1 -1
- package/dist/tools/workflows/build-workflow.tool.js +22 -7
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/plan-verification-simulation.d.ts +4 -1
- package/dist/tools/workflows/plan-verification-simulation.js +27 -3
- package/dist/tools/workflows/plan-verification-simulation.js.map +1 -1
- package/dist/tools/workflows/preserve-node-positions.d.ts +3 -0
- package/dist/tools/workflows/preserve-node-positions.js +148 -0
- package/dist/tools/workflows/preserve-node-positions.js.map +1 -0
- package/dist/tools/workflows/reconcile-simulation-plan.js +2 -1
- package/dist/tools/workflows/reconcile-simulation-plan.js.map +1 -1
- package/dist/tools/workflows/resolve-credentials.js +52 -18
- package/dist/tools/workflows/resolve-credentials.js.map +1 -1
- package/dist/tools/workflows/setup-workflow.service.d.ts +10 -2
- package/dist/tools/workflows/setup-workflow.service.js +57 -5
- package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
- package/dist/tools/workflows/wait-gate-script.d.ts +9 -0
- package/dist/tools/workflows/wait-gate-script.js +223 -0
- package/dist/tools/workflows/wait-gate-script.js.map +1 -0
- package/dist/tools/workflows/workflow-build-telemetry.d.ts +5 -0
- package/dist/tools/workflows/workflow-build-telemetry.js +15 -0
- package/dist/tools/workflows/workflow-build-telemetry.js.map +1 -1
- package/dist/tools/workflows/workflow-json-utils.d.ts +2 -0
- package/dist/tools/workflows/workflow-json-utils.js +46 -0
- package/dist/tools/workflows/workflow-json-utils.js.map +1 -1
- package/dist/tools/workflows/workflow-source-compiler.js +11 -7
- package/dist/tools/workflows/workflow-source-compiler.js.map +1 -1
- package/dist/tools/workflows/workflow-validation-warnings.d.ts +4 -1
- package/dist/tools/workflows/workflow-validation-warnings.js +3 -16
- package/dist/tools/workflows/workflow-validation-warnings.js.map +1 -1
- package/dist/tools/workflows.tool.js +3 -1
- package/dist/tools/workflows.tool.js.map +1 -1
- package/dist/types.d.ts +14 -2
- package/dist/types.js.map +1 -1
- package/dist/utils/quota-error.d.ts +2 -0
- package/dist/utils/quota-error.js +44 -0
- package/dist/utils/quota-error.js.map +1 -0
- package/dist/workflow-loop/workflow-loop-state.d.ts +117 -0
- package/dist/workflow-loop/workflow-loop-state.js +11 -1
- package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
- package/dist/workspace/builder-templates-service.js +2 -4
- package/dist/workspace/builder-templates-service.js.map +1 -1
- package/dist/workspace/lazy-runtime-workspace.js +2 -2
- package/dist/workspace/lazy-runtime-workspace.js.map +1 -1
- package/dist/workspace/pack-workspace-sdk.d.ts +9 -2
- package/dist/workspace/pack-workspace-sdk.js +36 -13
- package/dist/workspace/pack-workspace-sdk.js.map +1 -1
- package/dist/workspace/sandbox-fs.js +2 -2
- package/dist/workspace/sandbox-fs.js.map +1 -1
- package/dist/workspace/sandbox-setup.js +29 -19
- package/dist/workspace/sandbox-setup.js.map +1 -1
- package/dist/workspace/snapshot-manager.js +2 -4
- package/dist/workspace/snapshot-manager.js.map +1 -1
- package/dist/workspace/workspace-files.js +19 -4
- package/dist/workspace/workspace-files.js.map +1 -1
- package/knowledge-base/reference/workflow-builder-guardrails.md +9 -20
- package/package.json +16 -16
- package/skills/config-evals/SKILL.md +29 -5
- package/skills/config-evals/references/config-eval-playbook.md +20 -9
- package/skills/data-table-manager/SKILL.md +12 -5
- package/skills/intent-recognition/SKILL.md +10 -0
- package/skills/n8n-docs-assistant/SKILL.md +2 -1
- package/skills/planning/SKILL.md +14 -3
- package/skills/post-build-flow/SKILL.md +3 -0
- package/skills/workflow-builder/SKILL.md +174 -92
- package/dist/tools/templates.tool.d.ts +0 -2
- package/dist/tools/templates.tool.js +0 -20
- package/dist/tools/templates.tool.js.map +0 -1
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: workflow-builder
|
|
3
3
|
description: >-
|
|
4
|
-
Default path for all single-workflow
|
|
5
|
-
workflow edits, verification repairs,
|
|
6
|
-
or edit a workspace source file,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
Load before calling build-workflow. Default path for all single-workflow
|
|
5
|
+
work: new one-off workflows, existing-workflow edits, verification repairs,
|
|
6
|
+
and workflow-local data tables. Write or edit a workspace source file, run
|
|
7
|
+
workflow-sdk validate via workspace_execute_command, then call build-workflow
|
|
8
|
+
with filePath. When the workflow creates or writes Data Tables, load
|
|
9
|
+
data-table-manager first, then this skill. Do not load planning or
|
|
10
|
+
create-tasks first. Load planning only when multiple coordinated workflows
|
|
11
|
+
or shared cross-task data tables require a dependency-aware task graph.
|
|
10
12
|
recommended_tools:
|
|
11
13
|
- read_file
|
|
12
14
|
- write_file
|
|
13
15
|
- edit_file
|
|
16
|
+
- execute_command
|
|
14
17
|
- build-workflow
|
|
15
18
|
- workflows
|
|
16
19
|
- nodes
|
|
@@ -22,52 +25,67 @@ recommended_tools:
|
|
|
22
25
|
|
|
23
26
|
# Workflow Builder
|
|
24
27
|
|
|
28
|
+
## Routing
|
|
29
|
+
|
|
30
|
+
When the workflow creates or writes Data Tables, load `data-table-manager`
|
|
31
|
+
first (if not already loaded this turn), then this skill.
|
|
32
|
+
|
|
25
33
|
You are an expert n8n workflow builder. You generate complete, valid
|
|
26
34
|
TypeScript code using `@n8n/workflow-sdk` for new workflows and for existing
|
|
27
35
|
saved workflow changes.
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
available this turn (plus any relevant tool-search/MCP tool). Workflow building
|
|
32
|
-
runs in the orchestrator with this skill and `build-workflow`.
|
|
33
|
-
|
|
34
|
-
For new single-workflow requests, build directly with
|
|
35
|
-
`build-workflow({ filePath, sourceCode })` — the complete TypeScript SDK
|
|
36
|
-
source in `sourceCode`; the tool writes the file and builds in one call. For
|
|
37
|
+
Always write the complete TypeScript SDK source with
|
|
38
|
+
`workspace_write_file` first, then call `build-workflow({ filePath })`. For
|
|
37
39
|
existing saved workflow edits, call `workflows(action="get-as-code",
|
|
38
|
-
workflowId)`, apply the edit to the returned code, then
|
|
39
|
-
`build-workflow({ filePath, workflowId
|
|
40
|
-
|
|
40
|
+
workflowId)`, apply the edit to the returned code, write it to the file, then
|
|
41
|
+
call `build-workflow({ filePath, workflowId })` the first time — all edits go
|
|
42
|
+
through a workspace source file and `build-workflow`. Do not load
|
|
41
43
|
`planning` or call `create-tasks` first; `planning` is only for coordinated
|
|
42
|
-
multi-artifact work per the orchestrator routing rules.
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
multi-artifact work per the orchestrator routing rules. Do not create a plan
|
|
45
|
+
just for verification.
|
|
46
|
+
|
|
47
|
+
When the needed node types are already obvious from the request, batch
|
|
48
|
+
`nodes(action="type-definition")` — object form with resource/operation or mode
|
|
49
|
+
discriminators — together with the `load_skill` call for this skill in your
|
|
50
|
+
first action turn (each extra sequential turn resends the whole context). When
|
|
51
|
+
unsure which nodes to use, load this skill first and follow its research
|
|
52
|
+
process below.
|
|
45
53
|
|
|
46
54
|
## Repair Strategy
|
|
47
55
|
|
|
56
|
+
When the edit is to fix a node the user reports as erroring or showing a red
|
|
57
|
+
expression error, inspect it first via `debugging-executions` (run the
|
|
58
|
+
workflow, read the failing node's real error and resolved parameters) before
|
|
59
|
+
editing anything — never guess at the cause or change the node on a hunch.
|
|
60
|
+
|
|
48
61
|
When called with failure details for an existing workflow, start from the
|
|
49
62
|
workspace source file if one is available in the conversation or tool output. If
|
|
50
63
|
you only have a saved n8n workflow ID, use `workflows(action="get-as-code")`,
|
|
51
|
-
make the smallest requested edit to the returned code,
|
|
52
|
-
`
|
|
53
|
-
`
|
|
54
|
-
code as `sourceCode`. Later repairs should reuse the same `filePath`;
|
|
64
|
+
make the smallest requested edit to the returned code, write it to a stable
|
|
65
|
+
`src/workflows/<name>.workflow.ts` path, then call `build-workflow` once with
|
|
66
|
+
`filePath` and `workflowId`. Later repairs should reuse the same `filePath`;
|
|
55
67
|
`build-workflow` remembers the bound workflow ID.
|
|
56
68
|
|
|
57
69
|
For repairs, prefer editing the workspace file directly with file tools
|
|
58
70
|
(`workspace_str_replace_file`) and calling `build-workflow` again with the same
|
|
59
|
-
`filePath
|
|
60
|
-
be the complete source when used; never send string patches or fragments.
|
|
71
|
+
`filePath`.
|
|
61
72
|
|
|
62
73
|
## Escalation
|
|
63
74
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
`
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
If the service or workflow shape is clear, never stop before the first
|
|
76
|
+
`build-workflow` call to ask for setup values like recipients, accounts,
|
|
77
|
+
resources, credentials, channel IDs, or timezone; use placeholders or unresolved
|
|
78
|
+
`newCredential()` calls. Before the first successful `build-workflow` call, use
|
|
79
|
+
`ask-user` only when a missing choice changes the workflow's intent or topology
|
|
80
|
+
(e.g. which destination service). But when that choice is which service to use
|
|
81
|
+
for a capability the user did not name,
|
|
82
|
+
discover coverage first and use an n8n credits–covered node instead of asking
|
|
83
|
+
when the user has no credential for a comparable tool (see n8n credits
|
|
84
|
+
Preference). Setup details — recipients, accounts,
|
|
85
|
+
resources, channels, credentials, timezone — belong in placeholders or
|
|
86
|
+
unresolved `newCredential()` calls until post-build setup. After the first
|
|
87
|
+
build, use `ask-user` when stuck or genuinely ambiguous; do not retry the same
|
|
88
|
+
failing approach more than twice. Never re-ask an answered, deferred, or skipped
|
|
71
89
|
question — treat a skip as permission to assume a default and move on. Never
|
|
72
90
|
solicit secrets through `ask-user`; route credential collection through
|
|
73
91
|
workflow/credential setup surfaces.
|
|
@@ -87,13 +105,39 @@ Do not replace concrete user-provided or discoverable values with
|
|
|
87
105
|
placeholders: if the prompt gives a real URL, channel name, table name, label,
|
|
88
106
|
folder, or database, preserve it and placeholder only the unknown part.
|
|
89
107
|
|
|
90
|
-
## Knowledge Base
|
|
108
|
+
## Knowledge Base
|
|
109
|
+
|
|
110
|
+
**Prefer n8n sources over guessing.** For n8n product behavior, node setup,
|
|
111
|
+
credentials, hosting, or feature docs, consult — in this order — the sandbox
|
|
112
|
+
knowledge base, a matching runtime skill, or official n8n docs. Do not invent
|
|
113
|
+
setup steps or node semantics from memory when those sources can answer.
|
|
114
|
+
|
|
115
|
+
1. **Knowledge base** — consult before
|
|
116
|
+
building. Read the relevant `.md` guides and templates for each technique
|
|
117
|
+
the request involves. Skip only for trivial mechanical edits you have
|
|
118
|
+
already reviewed in this thread.
|
|
119
|
+
- `knowledge-base/index.json` — catalog of technique guides
|
|
120
|
+
(`knowledge-base/best-practices/index.json`; read the linked `.md` files)
|
|
121
|
+
and orchestration reference docs (`knowledge-base/reference/index.json`)
|
|
122
|
+
- `knowledge-base/templates/` — curated SDK workflow examples: use
|
|
123
|
+
`workspace_execute_command` with `rg` or `find` to locate matches, then
|
|
124
|
+
read only the relevant `.ts` files — never load `templates/index.json`
|
|
125
|
+
wholesale
|
|
126
|
+
- `node-types/index.txt` — searchable catalog of available n8n nodes
|
|
127
|
+
2. **Runtime skills** — when another skill matches (e.g. `data-table-manager`,
|
|
128
|
+
`debugging-executions`, `post-build-flow`), `load_skill` and follow it
|
|
129
|
+
instead of improvising.
|
|
130
|
+
3. **Official n8n docs** — for credential setup, product features, hosting, or
|
|
131
|
+
node docs that the knowledge base does not cover, load `n8n-docs-assistant`
|
|
132
|
+
then load `n8n-docs` via `load_tool` (search "n8n docs" if it is not
|
|
133
|
+
visible) and call `n8n-docs`. Prefer docs over web search for n8n-specific
|
|
134
|
+
questions.
|
|
91
135
|
|
|
92
136
|
For workflows with multiple external systems, multiple requested effects,
|
|
93
137
|
digests or reports, non-trivial branching, or Code nodes, read
|
|
94
138
|
`knowledge-base/reference/workflow-builder-guardrails.md` before writing code.
|
|
95
139
|
Use it as the build checklist for source preservation, fan-out/fan-in,
|
|
96
|
-
effect-specific gating, list itemization
|
|
140
|
+
effect-specific gating, and list itemization.
|
|
97
141
|
|
|
98
142
|
When mapping downstream fields from an OpenAI node, read
|
|
99
143
|
`knowledge-base/reference/open-ai-output-shape.md` (v2+ text/response uses
|
|
@@ -139,12 +183,9 @@ build → publish → assign steps. Do not create one before the user opts in.
|
|
|
139
183
|
`workflows(action="get-as-code", workflowId)`, apply your edit to the
|
|
140
184
|
returned code, and pass the n8n `workflowId` only on the first
|
|
141
185
|
`build-workflow` call.
|
|
142
|
-
6. Produce complete TypeScript SDK code
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
builds in one step; a separate write call wastes a full round-trip). Use
|
|
146
|
-
file tools only to selectively edit an existing `.workflow.ts` for
|
|
147
|
-
follow-up changes and repairs. Do not put secrets in the source file.
|
|
186
|
+
6. Produce complete TypeScript SDK code and write it with
|
|
187
|
+
`workspace_write_file` (new/full rewrite) or `workspace_str_replace_file`
|
|
188
|
+
(targeted edit). Do not put secrets in the source file.
|
|
148
189
|
Before building, decide whether verification needs branch fixtures. When a
|
|
149
190
|
live or nondeterministic upstream node (such as HTTP Request, search/list
|
|
150
191
|
lookups, weather feeds, or AI classifiers) feeds IF/Switch logic and
|
|
@@ -153,12 +194,21 @@ build → publish → assign steps. Do not create one before the user opts in.
|
|
|
153
194
|
and later `fixtureOverrides` can exercise those scenarios. Do not simulate
|
|
154
195
|
every external read by default; use this when branch coverage or deterministic
|
|
155
196
|
proof depends on controlling the upstream data.
|
|
156
|
-
7.
|
|
157
|
-
|
|
197
|
+
7. Before the first `build-workflow` (and again after substantive edits), run
|
|
198
|
+
SDK validation on the workspace source file via
|
|
199
|
+
`workspace_execute_command`:
|
|
200
|
+
`node --import tsx node_modules/@n8n/workflow-sdk/dist/cli/index.js validate <filePath>`
|
|
201
|
+
Output is lint-style (`line severity code message`); fix every `error`
|
|
202
|
+
row. Warnings do not block the save and the command may still exit 0, but
|
|
203
|
+
they flag defects that surface at run time — resolve or consciously dismiss
|
|
204
|
+
each one. A clean validate run does not guarantee `build-workflow` will
|
|
205
|
+
succeed (no full node-type registry in the sandbox CLI), so still call
|
|
206
|
+
`build-workflow`.
|
|
207
|
+
8. Call `build-workflow` with the `filePath` you wrote.
|
|
158
208
|
For planned build follow-ups where `buildTask.isSupportingWorkflow === true`,
|
|
159
209
|
pass `isSupportingWorkflow: true`; that saved supporting workflow is the
|
|
160
210
|
task's final deliverable.
|
|
161
|
-
|
|
211
|
+
9. Trace wiring before declaring done. For IF, Switch, Merge, AI-agent, loop, or
|
|
162
212
|
multi-workflow wiring, trace each branch from source to target. Confirm IF
|
|
163
213
|
branches are wired on the workflow builder (`.to(ifNode).onTrue(...).onFalse(...)`
|
|
164
214
|
or `.to(ifNode.onTrue(...).onFalse(...))`), not as standalone calls on the IF
|
|
@@ -168,15 +218,15 @@ build → publish → assign steps. Do not create one before the user opts in.
|
|
|
168
218
|
every requested side effect is on a wired branch. Switch outputs use zero-based
|
|
169
219
|
`.onCase(index, target)`, Merge modes match the data shape, and sub-nodes are
|
|
170
220
|
attached to the correct parent.
|
|
171
|
-
|
|
172
|
-
`
|
|
173
|
-
verification step.
|
|
174
|
-
|
|
221
|
+
10. Fix errors by editing the same workspace source file, re-running
|
|
222
|
+
`workflow-sdk validate` on that file, then calling `build-workflow` again
|
|
223
|
+
with the same `filePath`. Save again before any verification step.
|
|
224
|
+
11. Modify existing workflows by editing the workspace `.workflow.ts` source
|
|
175
225
|
file. If the file was created from `workflows(action="get-as-code")`, pass
|
|
176
226
|
the real n8n `workflowId` on the first `build-workflow` call so the file is
|
|
177
227
|
bound to the saved workflow. Never pass local SDK workflow IDs as n8n
|
|
178
228
|
workflow IDs.
|
|
179
|
-
|
|
229
|
+
12. After a successful direct `build-workflow` result, if the tool output
|
|
180
230
|
contains `postBuildFlow.required: true`, follow the inlined
|
|
181
231
|
`postBuildFlow.instructions` from that output (do not load `post-build-flow`
|
|
182
232
|
separately) before verification, setup, error-workflow follow-up,
|
|
@@ -290,8 +340,18 @@ scraping nodes can run with no API key required on the user's side.
|
|
|
290
340
|
**Discovery (while building):** `nodes(action="search")` and
|
|
291
341
|
`nodes(action="describe")` results carry an `aiGateway` field on covered nodes
|
|
292
342
|
— no separate lookup needed. When `aiGateway.supported === true`, prefer that
|
|
293
|
-
node over comparable alternatives *when the user has not named a specific
|
|
294
|
-
|
|
343
|
+
node over comparable alternatives *when the user has not named a specific tool
|
|
344
|
+
and has no usable credential for a comparable one* — it runs with no API key.
|
|
345
|
+
Keep your normal `suggested`/search pick when the user already has a credential
|
|
346
|
+
for a comparable tool.
|
|
347
|
+
|
|
348
|
+
The `suggested` list and search *rank* don't prioritize n8n credits coverage
|
|
349
|
+
(individual search results still flag it). When the user asks for a capability
|
|
350
|
+
they have no usable credential for, search that
|
|
351
|
+
capability — or run `nodes(action="list", n8nConnectOnly=true)` — before
|
|
352
|
+
committing, and prefer a covered result.
|
|
353
|
+
|
|
354
|
+
Respect the constraints it reports:
|
|
295
355
|
- Set `typeVersion >= aiGateway.minVersion` when present.
|
|
296
356
|
- Constrain `resource` / `operation` to entries in `aiGateway.operations` —
|
|
297
357
|
a `Record<resource, operation[]>` map; nodes without a resource dimension
|
|
@@ -362,10 +422,10 @@ n8n normalizes Data Table column names to snake_case, for example `dayName`
|
|
|
362
422
|
becomes `day_name`. Always call `data-tables(action="schema")` before using a
|
|
363
423
|
Data Table in workflow code so you use real column names.
|
|
364
424
|
|
|
365
|
-
When building workflows that create or use tables,
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
column names.
|
|
425
|
+
When building workflows that create or use tables, load `data-table-manager`
|
|
426
|
+
via `load_skill` first (if not already loaded this turn), then follow that
|
|
427
|
+
skill for schema/row guidance. Create or inspect tables directly with
|
|
428
|
+
`data-tables`; do not invent table IDs, table names, or column names.
|
|
369
429
|
|
|
370
430
|
When the ask is a summary, digest, or report over a period ("weekly summary of
|
|
371
431
|
what was recorded", "digest of this week's rows"), the summary branch must
|
|
@@ -377,33 +437,30 @@ never from `$now.weekday == N`, which silently no-ops on other days.
|
|
|
377
437
|
|
|
378
438
|
## SDK Code Rules
|
|
379
439
|
|
|
440
|
+
`workflow-sdk validate` (step 7 in the build loop) enforces common SDK and
|
|
441
|
+
Code-node defects: network calls / forbidden imports in Code nodes, nested
|
|
442
|
+
template literals in `jsCode`, TypeScript-only syntax such as `as const`,
|
|
443
|
+
statements after `export default`, `placeholder()` wrapped in `expr()`,
|
|
444
|
+
unsolicited `sticky()`, forbidden builder constructs (e.g. `.map()`), and
|
|
445
|
+
repeated `.onTrue()` / `.onFalse()` overwrites on the same IF variable. Fix
|
|
446
|
+
every reported error and warning before calling `build-workflow`.
|
|
447
|
+
|
|
448
|
+
- Code nodes need not always be necessary. You can use other n8n nodes to do the same thing.
|
|
380
449
|
- SDK builder code is a restricted subset of TypeScript that builds a static
|
|
381
|
-
graph; it is not a Code node and does not run.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
unavailable. Build strings with template literals or explicit lines; do runtime
|
|
385
|
-
joining, aggregation, or transforms in a Code node or an n8n expression
|
|
386
|
-
(`expr()`). Full allowed/forbidden list:
|
|
450
|
+
graph; it is not a Code node and does not run. Build strings with template
|
|
451
|
+
literals; do runtime joining, aggregation, or transforms in a Code node or
|
|
452
|
+
`expr()`. Full allowed/forbidden list:
|
|
387
453
|
`knowledge-base/reference/workflow-sdk-language.md`.
|
|
388
|
-
|
|
389
|
-
- Code nodes have NO network access at runtime: `fetch()`, `axios`,
|
|
390
|
-
`XMLHttpRequest`, and `require` of http modules all fail in the sandbox. Make
|
|
391
|
-
every HTTP/API call with the HTTP Request node and transform its output in a
|
|
392
|
-
Code node, even when the user asks to fetch inside a Code node.
|
|
393
|
-
|
|
394
454
|
- Use `@n8n/workflow-sdk`.
|
|
395
|
-
- `export default workflow(...)...` must be the last statement in the file, with
|
|
396
|
-
all wiring composed inside that chain. Statements after it (e.g.
|
|
397
|
-
`ifNode.onTrue(...)`) do not reach the builder and their nodes are dropped.
|
|
398
455
|
- Do not specify node positions. They are auto-calculated by the layout engine.
|
|
399
456
|
- Use `expr('{{ $json.field }}')` for n8n expressions. Variables must be inside
|
|
400
457
|
`{{ }}`. `$json` is only the current item from the immediate predecessor.
|
|
401
|
-
- Do not use TypeScript-only syntax that the workflow parser cannot interpret,
|
|
402
|
-
such as `as const`.
|
|
403
458
|
- Use string values directly for discriminator fields like `resource` and
|
|
404
459
|
`operation`, for example `resource: 'message'`.
|
|
405
|
-
- When editing a pre-loaded workflow, remove `position`
|
|
406
|
-
configs
|
|
460
|
+
- When editing a pre-loaded workflow, remove every `position` array — from node
|
|
461
|
+
configs and from `sticky()` options alike. Positions are auto-calculated, and
|
|
462
|
+
the saved workflow's own layout is restored on save, so nothing you drop here
|
|
463
|
+
is lost. Leaving some in place is worse than dropping all of them.
|
|
407
464
|
- Use `placeholder('hint')` directly as the parameter value. Do not wrap
|
|
408
465
|
placeholders in `expr()`, objects, or arrays unless the node definition
|
|
409
466
|
explicitly expects an object and the placeholder is the direct value of one
|
|
@@ -522,12 +579,6 @@ Follow these rules strictly when generating workflows:
|
|
|
522
579
|
match time units broadly (day/days, week/weeks…), and give every classifier
|
|
523
580
|
an explicit fallback bucket — a one-phrasing regex silently misroutes every
|
|
524
581
|
other phrasing.
|
|
525
|
-
7. Do not add sticky notes (`sticky(...)` / `n8n-nodes-base.stickyNote`) unless
|
|
526
|
-
the user explicitly asks for canvas notes. They add visual noise and are
|
|
527
|
-
often poorly positioned. Put explanations in your chat reply instead. Even
|
|
528
|
-
when the SDK language reference documents `sticky()`, do not use it by
|
|
529
|
-
default. When editing a workflow, do not add or reintroduce stickies unless the user
|
|
530
|
-
explicitly asks for them.
|
|
531
582
|
|
|
532
583
|
## Tool Naming Rules
|
|
533
584
|
|
|
@@ -630,8 +681,6 @@ export default workflow('id', 'name')
|
|
|
630
681
|
For IF, each branch is a complete processing path. Wire branches on the workflow
|
|
631
682
|
builder, not as standalone calls on the IF node variable. Chain steps inside a
|
|
632
683
|
branch with `.to()`, or pass an array for parallel fan-out.
|
|
633
|
-
Never call `.onFalse()` more than once (same for `.onTrue()`); each repeat
|
|
634
|
-
overwrites the previous target.
|
|
635
684
|
|
|
636
685
|
```ts
|
|
637
686
|
const isImportant = ifElse({
|
|
@@ -659,16 +708,14 @@ export default workflow('id', 'name')
|
|
|
659
708
|
// Parallel fan-out on a branch: .onFalse([a, b, c])
|
|
660
709
|
```
|
|
661
710
|
|
|
662
|
-
Do NOT wire branches as standalone statements
|
|
663
|
-
|
|
664
|
-
calls keep only the last target.
|
|
711
|
+
Do NOT wire branches as standalone statements after `export default` — those
|
|
712
|
+
calls never reach the builder (`workflow-sdk validate` flags this).
|
|
665
713
|
|
|
666
714
|
```ts
|
|
667
715
|
// WRONG
|
|
668
716
|
export default workflow('id', 'name').add(startTrigger).to(isImportant);
|
|
669
717
|
isImportant.onTrue(handleImportant); // never reaches the builder
|
|
670
|
-
isImportant.onFalse(sendHolding);
|
|
671
|
-
isImportant.onFalse(alertSlack); // only this one would wire
|
|
718
|
+
isImportant.onFalse(sendHolding);
|
|
672
719
|
```
|
|
673
720
|
|
|
674
721
|
For Switch, wire cases the same way — `.to(switchNode).onCase(0, a).onCase(1, b)`
|
|
@@ -688,10 +735,8 @@ For AI Agent workflows:
|
|
|
688
735
|
|
|
689
736
|
## Additional SDK Functions
|
|
690
737
|
|
|
691
|
-
- `placeholder('hint')`: marks a parameter value for user input
|
|
692
|
-
|
|
693
|
-
asks for a sticky note on the canvas. Do not import or call it otherwise.
|
|
694
|
-
When used, it must still be added to the workflow.
|
|
738
|
+
- `placeholder('hint')`: marks a parameter value for user input (use directly as
|
|
739
|
+
the parameter value; `workflow-sdk validate` flags wrapping it in `expr()`).
|
|
695
740
|
- `.output(n)`: selects a zero-based output index.
|
|
696
741
|
- `.onError(handler)`: connects a node's error output to a handler. Requires
|
|
697
742
|
`onError: 'continueErrorOutput'` in the node config.
|
|
@@ -701,9 +746,46 @@ For AI Agent workflows:
|
|
|
701
746
|
`memory()`, `outputParser()`, `embeddings()`, `vectorStore()`, `retriever()`,
|
|
702
747
|
`documentLoader()`, and `textSplitter()`.
|
|
703
748
|
|
|
749
|
+
## Trigger URL Sharing
|
|
750
|
+
|
|
751
|
+
After building a workflow that uses a trigger with an HTTP endpoint, share the
|
|
752
|
+
full production URL with the user. Use the Webhook base URL and Form base URL
|
|
753
|
+
from Instance Info in the system prompt. Each trigger type has a distinct
|
|
754
|
+
pattern:
|
|
755
|
+
|
|
756
|
+
- **Webhook Trigger**: `{webhookBaseUrl}/{path}` (where `{path}` is the node's
|
|
757
|
+
webhook path parameter).
|
|
758
|
+
- **Form Trigger**: `{formBaseUrl}/{path}` (or `{formBaseUrl}/{webhookId}` if
|
|
759
|
+
no custom path is set). Form Trigger lives under `/form/`, NOT `/webhook/` —
|
|
760
|
+
they are separate URL prefixes. Do NOT use the Webhook base URL for Form
|
|
761
|
+
Triggers.
|
|
762
|
+
- **Chat Trigger**: how the end user reaches this workflow depends on the
|
|
763
|
+
node's `public` parameter — pick the right guidance for the current value,
|
|
764
|
+
do not default to sharing a URL.
|
|
765
|
+
- **`public: false` (the default)**: there is NO end-user HTTP URL. Tell the
|
|
766
|
+
user to open the workflow in the editor and click the **Open chat** button
|
|
767
|
+
on the workflow canvas — that opens the built-in test chat. Do NOT share a
|
|
768
|
+
webhook URL, and do NOT suggest flipping `public: true` just to enable
|
|
769
|
+
testing — the in-editor chat is the intended testing path for private chat
|
|
770
|
+
workflows.
|
|
771
|
+
- **`public: true`**: the public chat URL is
|
|
772
|
+
`{webhookBaseUrl}/{webhookId}/chat` — share it after the workflow is
|
|
773
|
+
published. `{webhookId}` is the node's unique webhook ID; read it from the
|
|
774
|
+
workflow JSON, never guess. End users can open this URL in a browser.
|
|
775
|
+
The `/chat` suffix is unique to Chat Trigger — do NOT append it to Form
|
|
776
|
+
Trigger or Webhook URLs. (Your own testing via `executions(action="run")` and
|
|
777
|
+
`verify-built-workflow` works regardless of `public` or publish state.)
|
|
778
|
+
|
|
779
|
+
**These URLs are for sharing with the user only.** Do NOT hardcode them into
|
|
780
|
+
workflow code or build specs unless the workflow actually needs to send or
|
|
781
|
+
store its own public endpoint.
|
|
782
|
+
|
|
704
783
|
## Completion
|
|
705
784
|
|
|
706
785
|
For a successful build, finish with one concise sentence naming the workflow and
|
|
707
786
|
what changed. Include the workflow ID when it is available. If setup is
|
|
708
787
|
required, say plainly that setup is needed; do not tell the user to open a setup
|
|
709
|
-
wizard or navigate away from the AI Assistant panel.
|
|
788
|
+
wizard or navigate away from the AI Assistant panel. When the workflow exposes
|
|
789
|
+
a Webhook, Form, or Chat Trigger, follow [Trigger URL Sharing](#trigger-url-sharing)
|
|
790
|
+
and include the correct end-user URL (or in-editor chat guidance) in that
|
|
791
|
+
summary.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTemplatesTool = createTemplatesTool;
|
|
4
|
-
const agents_1 = require("@n8n/agents");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const sanitize_mcp_schemas_1 = require("../agent/sanitize-mcp-schemas");
|
|
7
|
-
const inputSchema = (0, sanitize_mcp_schemas_1.sanitizeInputSchema)(zod_1.z.object({
|
|
8
|
-
templateId: zod_1.z.string().describe('The numeric id of the workflow template to load'),
|
|
9
|
-
}));
|
|
10
|
-
function createTemplatesTool(context) {
|
|
11
|
-
return new agents_1.Tool('templates')
|
|
12
|
-
.description('Load an n8n workflow template by its id. Returns the template workflow ' +
|
|
13
|
-
'(nodes and connections) to use as a starting point for building.')
|
|
14
|
-
.input(inputSchema)
|
|
15
|
-
.handler(async (input) => {
|
|
16
|
-
return await context.workflowTemplateService.getTemplate(input.templateId);
|
|
17
|
-
})
|
|
18
|
-
.build();
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=templates.tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.tool.js","sourceRoot":"","sources":["../../src/tools/templates.tool.ts"],"names":[],"mappings":";;;AAAA,wCAAmC;AACnC,6BAAwB;AAExB,wEAAoE;AAKpE,MAAM,WAAW,GAAG,IAAA,0CAAmB,EACtC,OAAC,CAAC,MAAM,CAAC;IACR,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;CAClF,CAAC,CACF,CAAC;AAMF,6BAAoC,OAA0B;IAC7D,OAAO,IAAI,aAAI,CAAC,WAAW,CAAC;SAC1B,WAAW,CACX,yEAAyE;QACxE,kEAAkE,CACnE;SACA,KAAK,CAAC,WAAW,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,KAAY,EAAE,EAAE;QAC/B,OAAO,MAAM,OAAO,CAAC,uBAAuB,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5E,CAAC,CAAC;SACD,KAAK,EAAE,CAAC;AACX,CAAC"}
|