@n8n/instance-ai 1.22.0 → 1.23.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.
Files changed (88) hide show
  1. package/README.md +9 -5
  2. package/dist/agent/credential-guardrails.prompt.d.ts +1 -0
  3. package/dist/agent/credential-guardrails.prompt.js +2 -1
  4. package/dist/agent/credential-guardrails.prompt.js.map +1 -1
  5. package/dist/agent/shared-prompts.d.ts +1 -1
  6. package/dist/agent/shared-prompts.js +1 -1
  7. package/dist/agent/shared-prompts.js.map +1 -1
  8. package/dist/agent/sub-agent-factory.d.ts +1 -1
  9. package/dist/agent/sub-agent-factory.js +2 -1
  10. package/dist/agent/sub-agent-factory.js.map +1 -1
  11. package/dist/agent/system-prompt.js +7 -3
  12. package/dist/agent/system-prompt.js.map +1 -1
  13. package/dist/build.tsbuildinfo +1 -1
  14. package/dist/event-bus/event-bus.interface.d.ts +0 -4
  15. package/dist/index.d.ts +3 -1
  16. package/dist/index.js +10 -4
  17. package/dist/index.js.map +1 -1
  18. package/dist/planned-tasks/planned-task-permissions.d.ts +1 -2
  19. package/dist/planned-tasks/planned-task-permissions.js +0 -13
  20. package/dist/planned-tasks/planned-task-permissions.js.map +1 -1
  21. package/dist/runtime/resumable-stream-executor.js.map +1 -1
  22. package/dist/runtime/stream-runner.js.map +1 -1
  23. package/dist/stream/consume-with-hitl.js.map +1 -1
  24. package/dist/stream/output-redaction.js.map +1 -1
  25. package/dist/tools/credentials.tool.d.ts +3 -3
  26. package/dist/tools/credentials.tool.js +82 -15
  27. package/dist/tools/credentials.tool.js.map +1 -1
  28. package/dist/tools/evals/evals.tool.js +1 -3
  29. package/dist/tools/evals/evals.tool.js.map +1 -1
  30. package/dist/tools/filesystem/create-tools-from-mcp-server.js +4 -51
  31. package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
  32. package/dist/tools/nodes.tool.js +3 -3
  33. package/dist/tools/nodes.tool.js.map +1 -1
  34. package/dist/tools/orchestration/build-agent.tool.js +37 -6
  35. package/dist/tools/orchestration/build-agent.tool.js.map +1 -1
  36. package/dist/tools/orchestration/builder-required-artifact.d.ts +202 -0
  37. package/dist/tools/orchestration/builder-required-artifact.js +39 -0
  38. package/dist/tools/orchestration/builder-required-artifact.js.map +1 -0
  39. package/dist/tools/orchestration/verification/analyze-result.d.ts +1 -0
  40. package/dist/tools/orchestration/verification/analyze-result.js +21 -5
  41. package/dist/tools/orchestration/verification/analyze-result.js.map +1 -1
  42. package/dist/tools/orchestration/verification/scripted-gate-run.d.ts +1 -0
  43. package/dist/tools/orchestration/verification/scripted-gate-run.js +2 -0
  44. package/dist/tools/orchestration/verification/scripted-gate-run.js.map +1 -1
  45. package/dist/tools/orchestration/verification/types.d.ts +1 -0
  46. package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +3 -0
  47. package/dist/tools/orchestration/verify-built-workflow.tool.js +13 -0
  48. package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
  49. package/dist/tools/workflows/build-workflow.tool.d.ts +0 -3
  50. package/dist/tools/workflows/build-workflow.tool.js +14 -19
  51. package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
  52. package/dist/tools/workflows/chat-model-validation.d.ts +2 -2
  53. package/dist/tools/workflows/chat-model-validation.js +6 -28
  54. package/dist/tools/workflows/chat-model-validation.js.map +1 -1
  55. package/dist/tools/workflows/credential-utils.d.ts +1 -1
  56. package/dist/tools/workflows/credential-utils.js +2 -2
  57. package/dist/tools/workflows/credential-utils.js.map +1 -1
  58. package/dist/tools/workflows/detect-python-code-constraints.d.ts +3 -0
  59. package/dist/tools/workflows/detect-python-code-constraints.js +42 -0
  60. package/dist/tools/workflows/detect-python-code-constraints.js.map +1 -0
  61. package/dist/tools/workflows/detect-slack-blocks-shape.d.ts +3 -0
  62. package/dist/tools/workflows/detect-slack-blocks-shape.js +129 -0
  63. package/dist/tools/workflows/detect-slack-blocks-shape.js.map +1 -0
  64. package/dist/tools/workflows/resolve-credentials.d.ts +4 -1
  65. package/dist/tools/workflows/resolve-credentials.js +27 -5
  66. package/dist/tools/workflows/resolve-credentials.js.map +1 -1
  67. package/dist/tools/workflows/setup-workflow.service.d.ts +2 -1
  68. package/dist/tools/workflows/setup-workflow.service.js +22 -13
  69. package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
  70. package/dist/tools/workflows/validate-workflow.service.js +4 -4
  71. package/dist/tools/workflows/validate-workflow.service.js.map +1 -1
  72. package/dist/tools/workflows/workflow-source-compiler.js +4 -0
  73. package/dist/tools/workflows/workflow-source-compiler.js.map +1 -1
  74. package/dist/tools/workflows.tool.js +22 -10
  75. package/dist/tools/workflows.tool.js.map +1 -1
  76. package/dist/tracing/thread-provenance.d.ts +1 -0
  77. package/dist/tracing/thread-provenance.js +18 -0
  78. package/dist/tracing/thread-provenance.js.map +1 -0
  79. package/dist/types.d.ts +7 -3
  80. package/dist/types.js.map +1 -1
  81. package/dist/workspace/snapshot-manager.d.ts +8 -0
  82. package/dist/workspace/snapshot-manager.js +352 -14
  83. package/dist/workspace/snapshot-manager.js.map +1 -1
  84. package/knowledge-base/reference/workflow-builder-guardrails.md +11 -0
  85. package/package.json +12 -12
  86. package/skills/agent-builder/SKILL.md +30 -17
  87. package/skills/post-build-flow/SKILL.md +38 -16
  88. package/skills/workflow-builder/SKILL.md +37 -20
@@ -225,9 +225,10 @@ to force data through the trigger.
225
225
  **Reserve `executions(action="run")` for runs the user explicitly asked for**
226
226
  (e.g. "run it now", "execute it against my real data"). Never call it on your own
227
227
  to re-test, expand coverage, or "prove the full chain" of a workflow you just
228
- built or verified: re-run `verify-built-workflow` (with `fixtureOverrides` to
229
- reach an unverified branch) instead, or report the partial coverage and let the
230
- user decide whether to run it.
228
+ built or verified: re-run `verify-built-workflow` instead with
229
+ `triggerNodeName` to reach another trigger's branch, or `fixtureOverrides` to
230
+ reach another branch within one trigger's run — or report the partial coverage
231
+ and let the user decide whether to run it.
231
232
  If `fixtureOverrides` is rejected with `invalid_fixture_override`, the target
232
233
  node was not classified as simulated in the build outcome. Do not retry the same
233
234
  override. If that node's data controls a branch that needs verification and you
@@ -235,18 +236,30 @@ have the source file, load `workflow-builder`, declare representative `output`
235
236
  fixtures on the controlling upstream node, rebuild the same workflow, and verify
236
237
  again.
237
238
 
238
- **Never edit a saved workflow to reach a branch.** Disabling or deleting nodes to
239
- steer a test mutates the user's workflow and leaves it broken for as long as the
240
- test runs — if it is published, its triggers fire against the broken version.
241
- For a workflow with more than one trigger (`triggerNodes` has multiple entries):
242
-
239
+ **Never edit or copy a saved workflow to reach a branch.** Disabling, deleting,
240
+ or reordering nodes to steer a test mutates the user's workflow and leaves it
241
+ broken for as long as the test runs — if it is published, its triggers fire
242
+ against the broken version. Building a throwaway second workflow is no better:
243
+ the evidence is gathered against a copy that can drift from the workflow the
244
+ user keeps, and the copy is left behind whenever the cleanup delete fails.
245
+
246
+ For a workflow with more than one trigger (`triggerNodes` has multiple entries),
247
+ **verify once per trigger**:
248
+
249
+ - Pass `triggerNodeName` to `verify-built-workflow` and call it once for each
250
+ entry in `triggerNodes`. Naming no trigger verifies only the auto-detected
251
+ one. An unresolvable name is rejected outright, so a rejected call means the
252
+ name is wrong — re-read `triggerNodes`, never fall back to editing.
253
+ - Each pass covers its own trigger's branch, so its `nodesNotReached` will list
254
+ the other triggers' nodes. That is expected, not a defect: coverage is the
255
+ **union** across passes. Only treat a node as unverified once no pass reached
256
+ it.
257
+ - Report per-trigger coverage — name each trigger and whether its branch ran.
258
+ Claim the workflow is verified only when every trigger's branch has a
259
+ successful pass.
243
260
  - When the user asked for a live run, pass `triggerNodeName` to
244
- `executions(action="run")` — one run per trigger — and report each branch's
245
- result. Naming no trigger runs only the auto-detected one.
246
- - `verify-built-workflow` always exercises the auto-detected trigger, so it
247
- covers one branch. Say which trigger was verified and which branches were not,
248
- and offer the user a live run for the rest. Do not force coverage by editing
249
- the workflow.
261
+ `executions(action="run")` the same way — one run per trigger — and report
262
+ each branch's result.
250
263
 
251
264
  ## After build-workflow succeeds
252
265
 
@@ -268,7 +281,8 @@ For a workflow with more than one trigger (`triggerNodes` has multiple entries):
268
281
 
269
282
  - If `verificationReadiness.status === "ready"`, call
270
283
  `verify-built-workflow` with the `workflowId`, the `workItemId` when you
271
- have it, and the trigger-appropriate `inputData` shape.
284
+ have it, and the trigger-appropriate `inputData` shape. When `triggerNodes`
285
+ has more than one entry, call it once per trigger with `triggerNodeName`.
272
286
  - If `verificationReadiness.status === "needs_setup"`, call
273
287
  `workflows(action="setup")` with the workflowId so the user can configure it
274
288
  through the inline setup card in the AI Assistant panel.
@@ -291,7 +305,9 @@ For a workflow with more than one trigger (`triggerNodes` has multiple entries):
291
305
  were verified and which were not, and tell the user the unreached part
292
306
  needs a manual test. Do not start a live `executions(action="run")`
293
307
  yourself to reach those nodes; offer the user a test instead. Never claim
294
- end-to-end verification when `nodesNotReached` is non-empty.
308
+ end-to-end verification when `nodesNotReached` is non-empty — except for
309
+ nodes another trigger's pass already reached, since per-trigger coverage
310
+ is the union across passes.
295
311
  - If the unreached nodes sit behind IF/Switch logic controlled by a live or
296
312
  nondeterministic upstream node, and alternate-branch verification is part
297
313
  of this turn's goal, first try one source-file repair: add representative
@@ -319,6 +335,8 @@ For a workflow with more than one trigger (`triggerNodes` has multiple entries):
319
335
  when the latest verification evidence used mocks or simulations. If this
320
336
  follow-up is due, ask only whether the user wants the live test. Do not
321
337
  mention publishing or ask about the error workflow in the same response.
338
+ If `credentialResolutionNote` says Gateway credits are depleted,
339
+ that note wins: do not offer a live test.
322
340
  7. Before your final summary, scan the **whole conversation** for live runs that
323
341
  already wrote test data into an external system — earlier turns included, not
324
342
  just this one. For each such record still sitting there, follow
@@ -402,6 +420,10 @@ test without mocks. Ask only about the live test. Do not run it automatically.
402
420
  Do not offer publishing as an alternative or describe the workflow as ready to
403
421
  use or publish.
404
422
 
423
+ If `credentialResolutionNote` says Gateway credits are depleted, that
424
+ note wins over this live-test offer: do not offer a live test. Tell the user
425
+ they must top up Gateway credits or add their own key on the node first.
426
+
405
427
  If the user agrees, use the explicit live execution path (`executions(action="run")`
406
428
  for a direct live run) and report the result separately from the earlier mocked
407
429
  verification. If the live test fails, treat the workflow as unresolved and do
@@ -86,8 +86,8 @@ resources, credentials, channel IDs, or timezone; use placeholders or unresolved
86
86
  `ask-user` only when a missing choice changes the workflow's intent or topology
87
87
  (e.g. which destination service). But when that choice is which service to use
88
88
  for a capability the user did not name,
89
- discover coverage first and use an n8n credits–covered node instead of asking
90
- when the user has no credential for a comparable tool (see n8n credits
89
+ discover coverage first and use a Gateway credits–covered node instead of asking
90
+ when the user has no credential for a comparable tool (see Gateway credits
91
91
  Preference). Setup details — recipients, accounts,
92
92
  resources, channels, credentials, timezone — belong in placeholders or
93
93
  unresolved `newCredential()` calls until post-build setup. After the first
@@ -337,10 +337,10 @@ decision after testing.
337
337
  never by default — reuse is the right behavior everywhere else.
338
338
  - When `build-workflow` returns `resolvedCredentialsByNode`, the build already
339
339
  attached a credential to those nodes — either an existing stored credential or
340
- an n8n credits–managed one (entries with `id: null` and `__aiGatewayManaged:
340
+ a Gateway credits–managed one (entries with `id: null` and `__aiGatewayManaged:
341
341
  true`). Treat them all as connected: do not ask the user to connect or create
342
342
  those credentials, do not route them to credential setup, and mention at most
343
- that the credential (or n8n credits) is being used.
343
+ that the credential (or Gateway credits) is being used.
344
344
  - Never use raw credential objects like `{ id: '...', name: '...' }` in SDK
345
345
  code; replace them with `newCredential()` when editing roundtripped code.
346
346
  - If a required credential type is not listed, call
@@ -368,21 +368,25 @@ decision after testing.
368
368
  only for what a template cannot express: basic auth's base64-encoded
369
369
  pair, digest's challenge-response, OAuth flows — or when the user
370
370
  explicitly asks for a specific plain type.
371
- - `credentials(action="list", type=...)` may include a synthetic n8n credits
372
- entry `{ id: null, name: "n8n credits", type, __aiGatewayManaged: true }`
373
- when the type is covered by n8n credits (see n8n credits Preference). It is
374
- not a stored credential: never pass it to `newCredential(...)` and never
375
- emit `id: null` or the `__aiGatewayManaged` marker in SDK output. Setup
376
- applies it automatically when the user has no stored credential of that type.
371
+ - `credentials(action="list", type=...)` may include a Gateway credits entry
372
+ `{ id: "__AI_GATEWAY_MANAGED__", name: "Gateway credits", type, __aiGatewayManaged: true }`
373
+ when the type is covered by Gateway credits (see Gateway credits Preference). Treat its
374
+ `id` like any credential id: to use Gateway credits, write
375
+ `newCredential('Gateway credits', '__AI_GATEWAY_MANAGED__')` on the node exactly as
376
+ you copy a stored credential's id. The build keeps it and attaches Gateway credits,
377
+ even when the user already has their own credential of that type. Write it
378
+ whenever the user asks for Gateway credits; otherwise the normal reuse/own-credential
379
+ rules apply. (When the user has no stored credential of a covered type, the build
380
+ still auto-attaches Gateway credits even if you didn't write the entry.)
377
381
  - These rules apply to outbound service calls. Inbound trigger nodes (Webhook,
378
382
  Form, Chat, MCP Trigger) keep authentication at its default `none` unless
379
383
  the user explicitly asks to authenticate inbound traffic.
380
384
  - Always declare `output` on nodes that use unresolved credentials when mock
381
385
  data is needed for verification.
382
386
 
383
- ## n8n credits Preference
387
+ ## Gateway credits Preference
384
388
 
385
- "n8n credits" is the user-facing name of n8n's managed credential
389
+ "Gateway credits" is the user-facing name of n8n's managed credential
386
390
  service. On instances licensed for it, several common AI-provider and
387
391
  scraping nodes can run with no API key required on the user's side.
388
392
 
@@ -394,10 +398,10 @@ and has no usable credential for a comparable one* — it runs with no API key.
394
398
  Keep your normal `suggested`/search pick when the user already has a credential
395
399
  for a comparable tool.
396
400
 
397
- The `suggested` list and search *rank* don't prioritize n8n credits coverage
401
+ The `suggested` list and search *rank* don't prioritize Gateway credits coverage
398
402
  (individual search results still flag it). When the user asks for a capability
399
403
  they have no usable credential for, search that
400
- capability — or run `nodes(action="list", n8nConnectOnly=true)` — before
404
+ capability — or run `nodes(action="list", gatewayCreditsOnly=true)` — before
401
405
  committing, and prefer a covered result.
402
406
 
403
407
  Respect the constraints it reports:
@@ -407,28 +411,33 @@ Respect the constraints it reports:
407
411
  use the marker key `__operation_only__`.
408
412
  - Do not set parameters listed in `aiGateway.hiddenProperties`.
409
413
 
410
- **Enumeration (answering "what does n8n credits support?"):**
411
- - All supported nodes: `nodes(action="list", n8nConnectOnly=true)` — each
414
+ **Enumeration (answering "what does Gateway credits support?"):**
415
+ - All supported nodes: `nodes(action="list", gatewayCreditsOnly=true)` — each
412
416
  result carries the full `aiGateway` field (minVersion, operations,
413
417
  hiddenProperties).
414
418
  - All supported credential types:
415
- `credentials(action="search-types", n8nConnectOnly=true)`.
419
+ `credentials(action="search-types", gatewayCreditsOnly=true)`.
416
420
  - Operations for a specific supported node: `nodes(action="describe", …)`
417
421
  → `aiGateway.operations`.
418
422
 
419
423
  **Preference rule:** When adding a new node that has no credential assigned
420
- yet, prefer n8n credits over stored credentials if the credential type is
424
+ yet, prefer Gateway credits over stored credentials if the credential type is
421
425
  supported — it works with no API key required and avoids spending the user's
422
426
  API quota. The synthetic entry in `credentials(action="list", type=...)` (see
423
427
  Credential Rules) is your signal that a type is covered. Do not change
424
428
  credentials on nodes that already have one assigned (editing an existing
425
429
  workflow, or after the user has made a credential choice).
426
430
 
431
+ If `credentialResolutionNote` on the build result says Gateway credits are
432
+ depleted, follow that note: tell the user they must top up Gateway credits
433
+ or add their own key on the node. Do not say the workflow works out of the
434
+ box, and do not offer a live test.
435
+
427
436
  - If the user explicitly specified their own credential (by name or by
428
437
  choosing one from a list), use that credential and do not substitute
429
- n8n credits.
438
+ Gateway credits.
430
439
  - When speaking to the user in chat, always refer to this feature as
431
- "n8n credits" — never "n8n Connect", "AI Gateway", or "gateway". Those are
440
+ "Gateway credits" — never "n8n credits", "n8n Connect", "AI Gateway", or "gateway". Those are
432
441
  internal names only, including the `aiGateway` field on node/credential
433
442
  results: read it to make decisions, but never surface that name to the user.
434
443
 
@@ -496,6 +505,14 @@ every reported error and warning before calling `build-workflow`.
496
505
 
497
506
  - Avoid code node where possible, use n8n nodes that help do the same thing.
498
507
  If it makes it simpler, go ahead and use code node.
508
+ - Write Code nodes in JavaScript unless the user explicitly asks for Python.
509
+ `language: 'pythonNative'` runs a locked-down runner that defines only `_items`
510
+ (all-items mode), `_item` (per-item mode) and `print()` — no `_('Node Name')`,
511
+ `_input` or `$` helpers. Its imports are allowlisted per deployment and the
512
+ allowlist is empty by default: write import-free Python unless the **Python
513
+ Code Nodes** section of your system prompt says this instance allows more.
514
+ `build-workflow` re-checks the code against the real allowlist and reports
515
+ anything the runner would reject.
499
516
  - SDK builder code is a restricted subset of TypeScript that builds a static
500
517
  graph; it is not a Code node and does not run. Build strings with template
501
518
  literals; do runtime joining, aggregation, or transforms in a Code node or