@n8n/instance-ai 1.19.3 → 1.20.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.
Files changed (70) hide show
  1. package/dist/agent/instance-agent.js +1 -0
  2. package/dist/agent/instance-agent.js.map +1 -1
  3. package/dist/agent/system-prompt.d.ts +1 -0
  4. package/dist/agent/system-prompt.js +18 -4
  5. package/dist/agent/system-prompt.js.map +1 -1
  6. package/dist/build.tsbuildinfo +1 -1
  7. package/dist/index.d.ts +5 -2
  8. package/dist/index.js +8 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/knowledge-base/materialize-knowledge-base.js +12 -1
  11. package/dist/knowledge-base/materialize-knowledge-base.js.map +1 -1
  12. package/dist/skills/runtime-skills.js +1 -1
  13. package/dist/skills/runtime-skills.js.map +1 -1
  14. package/dist/stream/map-chunk.js +22 -0
  15. package/dist/stream/map-chunk.js.map +1 -1
  16. package/dist/stream/output-redaction.js +30 -0
  17. package/dist/stream/output-redaction.js.map +1 -1
  18. package/dist/tools/credentials.tool.d.ts +212 -0
  19. package/dist/tools/credentials.tool.js +155 -21
  20. package/dist/tools/credentials.tool.js.map +1 -1
  21. package/dist/tools/data-tables.tool.js +31 -8
  22. package/dist/tools/data-tables.tool.js.map +1 -1
  23. package/dist/tools/index.js +4 -0
  24. package/dist/tools/index.js.map +1 -1
  25. package/dist/tools/mcp-servers.tool.d.ts +2 -0
  26. package/dist/tools/mcp-servers.tool.js +56 -0
  27. package/dist/tools/mcp-servers.tool.js.map +1 -0
  28. package/dist/tools/orchestration/agent-target-binding.d.ts +3 -0
  29. package/dist/tools/orchestration/agent-target-binding.js +64 -0
  30. package/dist/tools/orchestration/agent-target-binding.js.map +1 -1
  31. package/dist/tools/orchestration/build-agent.tool.js +57 -30
  32. package/dist/tools/orchestration/build-agent.tool.js.map +1 -1
  33. package/dist/tools/tool-ids.d.ts +2 -0
  34. package/dist/tools/tool-ids.js +5 -1
  35. package/dist/tools/tool-ids.js.map +1 -1
  36. package/dist/tools/workflows/build-workflow.tool.js +41 -12
  37. package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
  38. package/dist/tools/workflows/credential-utils.d.ts +3 -0
  39. package/dist/tools/workflows/credential-utils.js +31 -1
  40. package/dist/tools/workflows/credential-utils.js.map +1 -1
  41. package/dist/tools/workflows/resolve-credentials.js +54 -1
  42. package/dist/tools/workflows/resolve-credentials.js.map +1 -1
  43. package/dist/tools/workflows/setup-workflow.schema.d.ts +151 -0
  44. package/dist/tools/workflows/setup-workflow.service.d.ts +6 -0
  45. package/dist/tools/workflows/setup-workflow.service.js +77 -13
  46. package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
  47. package/dist/tools/workflows/workflow-file-bindings.d.ts +3 -1
  48. package/dist/tools/workflows/workflow-file-bindings.js +5 -2
  49. package/dist/tools/workflows/workflow-file-bindings.js.map +1 -1
  50. package/dist/tools/workflows.tool.js +44 -0
  51. package/dist/tools/workflows.tool.js.map +1 -1
  52. package/dist/tracing/agent-snapshot-event.d.ts +17 -0
  53. package/dist/tracing/agent-snapshot-event.js +56 -0
  54. package/dist/tracing/agent-snapshot-event.js.map +1 -0
  55. package/dist/types.d.ts +30 -1
  56. package/dist/types.js.map +1 -1
  57. package/dist/workspace/workspace-paths.d.ts +4 -2
  58. package/dist/workspace/workspace-paths.js +15 -2
  59. package/dist/workspace/workspace-paths.js.map +1 -1
  60. package/knowledge-base/reference/anthropic-output-shape.md +72 -0
  61. package/knowledge-base/reference/open-ai-output-shape.md +3 -0
  62. package/package.json +12 -12
  63. package/skills/agent-builder/SKILL.md +94 -0
  64. package/skills/credential-recipe-research/SKILL.md +88 -0
  65. package/skills/debugging-executions/SKILL.md +2 -1
  66. package/skills/intent-recognition/SKILL.md +23 -30
  67. package/skills/planning/SKILL.md +7 -5
  68. package/skills/post-build-flow/SKILL.md +111 -28
  69. package/skills/workflow-builder/SKILL.md +68 -23
  70. package/skills/workflow-builder/references/error-workflows.md +2 -2
@@ -24,9 +24,9 @@ These instructions are in English, but user-visible text you write while
24
24
  following them stays in the user's conversation language.
25
25
 
26
26
  For trigger `inputData` shapes, read
27
- `knowledge-base/reference/trigger-input-data-shapes.md` in the sandbox workspace
28
- when available, or load this skill's `references/trigger-input-data-shapes.md`
29
- linked file.
27
+ `${N8N_WORKSPACE_DIR}/knowledge-base/reference/trigger-input-data-shapes.md` in
28
+ the sandbox workspace when available, or load this skill's
29
+ `references/trigger-input-data-shapes.md` linked file.
30
30
 
31
31
  ## Verification follow-up
32
32
 
@@ -51,6 +51,103 @@ if the payload or prior verification evidence says mocked credentials,
51
51
  simulated node output, fixture overrides, temporary pin data, or another mocked
52
52
  input was used.
53
53
 
54
+ ### Choosing the credential type for a service
55
+
56
+ Pick in this order:
57
+
58
+ 1. **A dedicated credential type** (`slackApi`, `notionApi`, …) whenever one
59
+ exists — search with `credentials(action="search-types")`.
60
+ 2. **Simplified Custom Auth** (`httpTemplatedCustomAuth`) for any service
61
+ without a dedicated type whose auth is expressible as header/query/body
62
+ values — which covers API keys and bearer tokens (`Authorization: Bearer
63
+ <token>` becomes `{"headers":{"Authorization":"Bearer {{api_key}}"}}`, not
64
+ `httpBearerAuth`). Always provide a recipe (below) so the user only pastes
65
+ their secret.
66
+ 3. **Plain generic types** (`httpBasicAuth`, `httpDigestAuth`, `oAuth2Api`, …)
67
+ only for what a template cannot express: basic auth's base64-encoded pair,
68
+ digest's challenge-response, OAuth flows — or when the user explicitly asks
69
+ for a specific plain type: an explicit user choice wins (setup accepts it
70
+ with `allowPlainGenericAuth: true`).
71
+
72
+ ### Credential recipes for Simplified Custom Auth
73
+
74
+ When the workflow authenticates a service through Simplified Custom Auth,
75
+ include `credentialHints` in the same `workflows(action="setup")` call so the
76
+ setup card pre-fills the credential and the user only pastes their secret —
77
+ instead of facing an empty JSON template they'd have to decode from the
78
+ provider's docs. Before composing the hints, load the
79
+ `credential-recipe-research` skill and execute its lookup procedure — the
80
+ template, `docsUrl` and `testUrl` must come from the provider documentation
81
+ it has you fetch, never from memory:
82
+
83
+ - `template` — the auth request parts (headers/qs/body) exactly as documented,
84
+ with `{{placeholder}}` markers where the user's values go.
85
+ - `placeholders` — one entry per marker: `name`, user-facing `title`, an
86
+ optional `info` clarifying the value itself — its format or which of the
87
+ provider's tokens it is (e.g. "Starts with tvly-"). Never where to obtain
88
+ it, and never a URL or domain: the user asks the AI Assistant for that from
89
+ the credential form. `type` is `password` unless clearly non-secret (at
90
+ least one placeholder must stay `password`). Add `optional: true` only when
91
+ the provider documents the value as optional (e.g. an org/region
92
+ qualifier) — template entries referencing an empty optional placeholder are
93
+ omitted from the request.
94
+ - `docsUrl` — the provider page where a logged-in user CREATES/COPIES the
95
+ secret (e.g. `https://replicate.com/account/api-tokens`) — never the API
96
+ reference. Not shown in the form: the AI Assistant help thread uses it to
97
+ send the user to the exact page. Found via the `credential-recipe-research`
98
+ procedure; omit when it finds nothing conclusive.
99
+ - `testUrl` — a documented side-effect-free GET that rejects a bad key with
100
+ 401/403, used to verify the credential on save and later retests; never one
101
+ of the workflow's own endpoints, never anything billable. Found via the
102
+ `credential-recipe-research` procedure; omit when nothing qualifies — a
103
+ credential without a testUrl saves fine and honestly shows "could not be
104
+ verified", which beats a false green.
105
+ - `acceptedStatusCodes` — almost always omit; the user can adjust it later on
106
+ the credential if a service's auth answers 401/403 to valid GETs.
107
+ - `suggestedName` — display name for the created credential.
108
+
109
+ Example — fal.ai's docs say requests use `Authorization: Key <FAL_KEY>` and
110
+ `GET https://api.fal.ai/v1/models/usage` is a documented side-effect-free
111
+ endpoint that rejects a bad key (the model-serving host `fal.run` is not a
112
+ key-check endpoint):
113
+
114
+ ```json
115
+ {
116
+ "action": "setup",
117
+ "workflowId": "...",
118
+ "credentialHints": [
119
+ {
120
+ "suggestedName": "fal.ai API Key",
121
+ "template": {
122
+ "headers": { "Authorization": "Key {{api_key}}" }
123
+ },
124
+ "placeholders": [
125
+ {
126
+ "name": "api_key",
127
+ "title": "fal.ai API key",
128
+ "info": "Key ID and secret, separated by a colon",
129
+ "type": "password"
130
+ }
131
+ ],
132
+ "docsUrl": "https://fal.ai/dashboard/keys",
133
+ "testUrl": "https://api.fal.ai/v1/models/usage"
134
+ }
135
+ ]
136
+ }
137
+ ```
138
+
139
+ Never put a real secret in a recipe — the user pastes it in the setup card and
140
+ it is stored redacted in the credential. Add `nodeName` when several nodes use
141
+ Simplified Custom Auth for different services. You cannot see the secret, but
142
+ once setup reports the credential applied, treat it as fully configured — the
143
+ `{{placeholder}}` markers live only in the template; the stored values replace
144
+ them at request time. If a live test later fails with an auth error, that is
145
+ the moment to have the user re-open the credential and re-paste the value.
146
+
147
+ If the user defers setup instead, don't hand them manual field-by-field
148
+ credential instructions for the n8n editor — tell them to reopen setup when
149
+ they're ready: the card pre-fills everything except their key.
150
+
54
151
  ## Publishing and testing
55
152
 
56
153
  **Publishing is never required for testing.** Both `executions(action="run")` and
@@ -147,27 +244,19 @@ again.
147
244
  when the latest verification evidence used mocks or simulations. If this
148
245
  follow-up is due, ask only that question now; do not also ask about the error
149
246
  workflow in the same response.
150
- 7. For a direct new primary workflow, follow
151
- [Error workflow follow-up](#error-workflow-follow-up) after the mocked
152
- live-test follow-up is no longer pending for this workflow. If no mocked
153
- live-test follow-up is due, ask about the error workflow before any generic
154
- testing prompt. Do not replace this explicit opt-in with a generic "add
155
- anything else?", publish, or test question.
156
- 8. Ask the user if they want to test the workflow (skip this if
157
- `verify-built-workflow` already proved it works end-to-end with full
158
- coverage). If you need to ask about both generic testing and an error
159
- workflow, ask the error-workflow opt-in first and leave generic testing as a
160
- later follow-up unless the user already requested testing.
161
- 9. Only call `workflows(action="publish")` when the user explicitly asks to
247
+ 7. If testing has not already been offered or completed, ask whether the user
248
+ wants to test the workflow. Skip this if `verify-built-workflow` already
249
+ proved it works end-to-end with full coverage.
250
+ 8. Only call `workflows(action="publish")` when the user explicitly asks to
162
251
  publish. Never publish automatically.
252
+ 9. After a direct new primary workflow is successfully published, follow
253
+ [Error workflow follow-up](#error-workflow-follow-up).
254
+ Do not replace this explicit opt-in with a generic "add
255
+ anything else?", publish, or test question.
163
256
 
164
257
  ## Error workflow follow-up
165
258
 
166
- This follow-up comes after the mocked verification live-test follow-up when that
167
- follow-up is due, and before generic "want to test it?" prompts. For a direct
168
- new primary workflow, ask about the error workflow after the user answers,
169
- declines, or defers any pending live/no-mock testing question. If no mocked
170
- live-test follow-up is due, ask about the error workflow first.
259
+ This follow-up comes only after a direct new primary workflow is successfully published.
171
260
 
172
261
  If you just built an Error Trigger workflow because the user opted into adding
173
262
  one for a known target workflow, do not ask whether to build another error
@@ -175,7 +264,7 @@ workflow. Continue the publish-before-assign flow for the target workflow:
175
264
  ask whether to publish the error workflow and set it on that target workflow,
176
265
  then publish and assign only after the user approves.
177
266
 
178
- After saving and handling verification/setup for a direct new primary workflow,
267
+ After successfully publishing a direct new primary workflow,
179
268
  ask once whether the user wants to build an error workflow for that workflow.
180
269
  Use `ask-user` with a yes/no choice or a concise visible question. Do **not**
181
270
  create an error workflow before the user opts in.
@@ -227,15 +316,9 @@ that workflow used mocked credentials, simulated node output, fixture overrides,
227
316
  temporary pin data, or another mocked input, ask whether the user wants a live
228
317
  test without mocks. Do not run the live test automatically.
229
318
 
230
- This follow-up has priority over the error-workflow opt-in for a direct new
231
- primary workflow. If both follow-ups are due, ask about the live/no-mock test
232
- first and ask the error-workflow question only after the user has answered,
233
- declined, or deferred the live/no-mock test follow-up.
234
-
235
319
  If the user agrees, use the explicit live execution path (`executions(action="run")`
236
320
  for a direct live run) and report the result separately from the earlier mocked
237
- verification. If the user declines or defers, state what remains untested and do
238
- not claim live end-to-end verification.
321
+ verification. If the user declines or defers, state what remains untested and do not claim live end-to-end verification.
239
322
 
240
323
  ## Claiming success
241
324
 
@@ -115,15 +115,19 @@ setup steps or node semantics from memory when those sources can answer.
115
115
  1. **Knowledge base** — consult before
116
116
  building. Read the relevant `.md` guides and templates for each technique
117
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
118
+ already reviewed in this thread. The knowledge base lives at the workspace
119
+ root (NOT inside this skill's directory) all paths below are
120
+ workspace-root-relative:
121
+ - `${N8N_WORKSPACE_DIR}/knowledge-base/index.json` — catalog of technique
122
+ guides (`${N8N_WORKSPACE_DIR}/knowledge-base/best-practices/index.json`;
123
+ read the linked `.md` files) and orchestration reference docs
124
+ (`${N8N_WORKSPACE_DIR}/knowledge-base/reference/index.json`)
125
+ - `${N8N_WORKSPACE_DIR}/knowledge-base/templates/` — curated SDK workflow
126
+ examples: use `workspace_execute_command` with `rg` or `find` to locate
127
+ matches, then read only the relevant `.ts` files —
128
+ never load `templates/index.json` wholesale
129
+ - `${N8N_WORKSPACE_DIR}/node-types/index.txt` — searchable catalog of
130
+ available n8n nodes
127
131
  2. **Runtime skills** — when another skill matches (e.g. `data-table-manager`,
128
132
  `debugging-executions`, `post-build-flow`), `load_skill` and follow it
129
133
  instead of improvising.
@@ -135,14 +139,19 @@ setup steps or node semantics from memory when those sources can answer.
135
139
 
136
140
  For workflows with multiple external systems, multiple requested effects,
137
141
  digests or reports, non-trivial branching, or Code nodes, read
138
- `knowledge-base/reference/workflow-builder-guardrails.md` before writing code.
139
- Use it as the build checklist for source preservation, fan-out/fan-in,
140
- effect-specific gating, and list itemization.
142
+ `${N8N_WORKSPACE_DIR}/knowledge-base/reference/workflow-builder-guardrails.md`
143
+ before writing code. Use it as the build checklist for source preservation,
144
+ fan-out/fan-in, effect-specific gating, and list itemization.
141
145
 
142
146
  When mapping downstream fields from an OpenAI node, read
143
- `knowledge-base/reference/open-ai-output-shape.md` (v2+ text/response uses
144
- `$json.output[0].content[0].text`; v1 text/message uses `$json.message.content`
145
- — not `$json.text`).
147
+ `${N8N_WORKSPACE_DIR}/knowledge-base/reference/open-ai-output-shape.md`
148
+ (v2+ text/response uses `$json.output[0].content[0].text`; v1 text/message
149
+ uses `$json.message.content` — not `$json.text`; `json_object`/`json_schema`
150
+ output is already a parsed object, never `JSON.parse` it). When mapping fields
151
+ from an Anthropic node, read
152
+ `${N8N_WORKSPACE_DIR}/knowledge-base/reference/anthropic-output-shape.md`
153
+ (`$json.content` is an array of blocks — read text with
154
+ `$json.content[0].text`, never treat `$json.content` as a string).
146
155
 
147
156
  ## Workflow-Level Error Workflows
148
157
 
@@ -150,9 +159,10 @@ Error workflows are per-target-workflow (`settings.errorWorkflow` must be the
150
159
  real workflow ID of a separate **published** workflow with an active Error
151
160
  Trigger — never a name, placeholder, `activeVersionId`, or local SDK id).
152
161
  n8n has no global error workflow setting; mention that only if the user asks
153
- about global behavior. Before building or attaching an error workflow, load
154
- this skill's `references/error-workflows.md` linked file and follow its
155
- build publish assign steps. Do not create one before the user opts in.
162
+ about global behavior. Do not offer or build an error workflow before the
163
+ primary workflow is published. Before building or attaching an error
164
+ workflow, load this skill's `references/error-workflows.md` linked file and
165
+ follow its build → publish → assign steps.
156
166
 
157
167
  ## Mandatory Process
158
168
 
@@ -316,9 +326,30 @@ decision after testing.
316
326
  - Never use raw credential objects like `{ id: '...', name: '...' }` in SDK
317
327
  code; replace them with `newCredential()` when editing roundtripped code.
318
328
  - If a required credential type is not listed, call
319
- `credentials(action="search-types")` with the service name. Prefer dedicated
320
- credential types over generic auth; when generic auth is truly needed,
321
- prefer `httpBearerAuth` over `httpHeaderAuth`.
329
+ `credentials(action="search-types")` with the service name. Pick in this
330
+ order:
331
+ 1. A **dedicated credential type** whenever search finds one.
332
+ 2. **Simplified Custom Auth** (`httpTemplatedCustomAuth`) for any service
333
+ without a dedicated type whose auth is expressible as header/query/body
334
+ values — this covers API keys and bearer tokens. When the provider
335
+ documents `Authorization: Bearer <token>`, do NOT reach for
336
+ `httpBearerAuth`: template it as
337
+ `{"headers":{"Authorization":"Bearer {{api_key}}"}}`. Set the HTTP
338
+ Request node's `genericAuthType` to `httpTemplatedCustomAuth`, and note
339
+ the provider's documented auth scheme (header format, key page, a cheap
340
+ authenticated GET endpoint) while you have the docs open: the setup call
341
+ needs them for the `credentialHints` recipe (see the post-build-flow
342
+ skill). Before that setup call, load the `credential-recipe-research`
343
+ skill and execute its lookup procedure — the recipe's template, docsUrl
344
+ and testUrl must come from pages fetched there, never from memory. Setup
345
+ rejects new plain generic credentials on HTTP Request nodes, so picking
346
+ Bearer/Header/Query/Custom Auth here means rebuilding — unless the user
347
+ explicitly asked for that plain type: an explicit user choice wins (setup
348
+ accepts it with `allowPlainGenericAuth: true`), don't argue with it.
349
+ 3. Plain generic types (`httpBasicAuth`, `httpDigestAuth`, `oAuth2Api`, …)
350
+ only for what a template cannot express: basic auth's base64-encoded
351
+ pair, digest's challenge-response, OAuth flows — or when the user
352
+ explicitly asks for a specific plain type.
322
353
  - `credentials(action="list", type=...)` may include a synthetic n8n credits
323
354
  entry `{ id: null, name: "n8n credits", type, __aiGatewayManaged: true }`
324
355
  when the type is covered by n8n credits (see n8n credits Preference). It is
@@ -445,12 +476,12 @@ unsolicited `sticky()`, forbidden builder constructs (e.g. `.map()`), and
445
476
  repeated `.onTrue()` / `.onFalse()` overwrites on the same IF variable. Fix
446
477
  every reported error and warning before calling `build-workflow`.
447
478
 
448
- - Code nodes need not always be necessary. You can use other n8n nodes to do the same thing.
479
+ - Code nodes need not always be necessary. You can use other n8n nodes to do the same thing.
449
480
  - SDK builder code is a restricted subset of TypeScript that builds a static
450
481
  graph; it is not a Code node and does not run. Build strings with template
451
482
  literals; do runtime joining, aggregation, or transforms in a Code node or
452
483
  `expr()`. Full allowed/forbidden list:
453
- `knowledge-base/reference/workflow-sdk-language.md`.
484
+ `${N8N_WORKSPACE_DIR}/knowledge-base/reference/workflow-sdk-language.md`.
454
485
  - Use `@n8n/workflow-sdk`.
455
486
  - Do not specify node positions. They are auto-calculated by the layout engine.
456
487
  - Use `expr('{{ $json.field }}')` for n8n expressions. Variables must be inside
@@ -534,6 +565,20 @@ import {
534
565
  } from '@n8n/workflow-sdk';
535
566
  ```
536
567
 
568
+ ## Node Groups
569
+
570
+ Organise multi-stage workflows into named node groups — visual frames on the canvas — so the
571
+ result is readable the first time the user sees it. Group each clear stage (ingest → transform
572
+ → deliver); small workflows don't need groups. Give every group a one-sentence
573
+ `description` — groups are collapsed by default, so name + description is what the user sees
574
+ first.
575
+
576
+ `.group(name, members, { description })` on the workflow builder; members are the node handles.
577
+ Read `knowledge-base/reference/node-groups.md` for the exact rules (trigger nodes excluded,
578
+ one connected section, AI sub-nodes stay with their Agent) before creating groups — an invalid
579
+ group is rejected on save. When editing an existing workflow, keep existing `.group(...)` calls
580
+ and their descriptions intact unless the change is about grouping.
581
+
537
582
  ## Workflow Rules
538
583
 
539
584
  Follow these rules strictly when generating workflows:
@@ -20,8 +20,8 @@ instance-wide error workflow behavior.
20
20
 
21
21
  When creating an error workflow to attach to another workflow:
22
22
 
23
- 1. Build the target workflow first, then ask whether the user wants an error
24
- workflow for it. Do not create one before the user opts in.
23
+ 1. Wait until the target workflow is published, then ask whether the user wants
24
+ an error workflow for it.
25
25
  2. Build the error workflow as a separate workflow. It starts with an Error
26
26
  Trigger and sends the notification the user requested.
27
27
  3. Publish the error workflow with `workflows(action="publish")` before setting