@n8n/instance-ai 1.12.4 → 1.13.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 (253) hide show
  1. package/dist/agent/apply-agent-thinking.d.ts +2 -0
  2. package/dist/agent/apply-agent-thinking.js +41 -0
  3. package/dist/agent/apply-agent-thinking.js.map +1 -0
  4. package/dist/agent/instance-agent.js +10 -2
  5. package/dist/agent/instance-agent.js.map +1 -1
  6. package/dist/agent/sanitize-mcp-schemas.js +133 -125
  7. package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
  8. package/dist/agent/shared-prompts.d.ts +0 -1
  9. package/dist/agent/shared-prompts.js +4 -11
  10. package/dist/agent/shared-prompts.js.map +1 -1
  11. package/dist/agent/sub-agent-debriefing.d.ts +4 -4
  12. package/dist/agent/system-prompt.js +3 -10
  13. package/dist/agent/system-prompt.js.map +1 -1
  14. package/dist/build.tsbuildinfo +1 -1
  15. package/dist/debug/run-debug-buffer.d.ts +63 -0
  16. package/dist/debug/run-debug-buffer.js +177 -0
  17. package/dist/debug/run-debug-buffer.js.map +1 -0
  18. package/dist/debug/sanitize-debug-snapshot.d.ts +2 -0
  19. package/dist/debug/sanitize-debug-snapshot.js +88 -0
  20. package/dist/debug/sanitize-debug-snapshot.js.map +1 -0
  21. package/dist/error-formatting.js +3 -5
  22. package/dist/error-formatting.js.map +1 -1
  23. package/dist/index.d.ts +5 -2
  24. package/dist/index.js +8 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/knowledge-base/build-templates-index.d.ts +1 -0
  27. package/dist/knowledge-base/build-templates-index.js +18 -2
  28. package/dist/knowledge-base/build-templates-index.js.map +1 -1
  29. package/dist/knowledge-base/materialize-knowledge-base.d.ts +2 -3
  30. package/dist/knowledge-base/materialize-knowledge-base.js +10 -7
  31. package/dist/knowledge-base/materialize-knowledge-base.js.map +1 -1
  32. package/dist/mcp/mcp-client-manager.d.ts +1 -1
  33. package/dist/mcp/mcp-client-manager.js +13 -9
  34. package/dist/mcp/mcp-client-manager.js.map +1 -1
  35. package/dist/runtime/memory-task-registry.d.ts +8 -0
  36. package/dist/runtime/memory-task-registry.js +42 -0
  37. package/dist/runtime/memory-task-registry.js.map +1 -0
  38. package/dist/runtime/resumable-stream-executor.d.ts +3 -0
  39. package/dist/runtime/resumable-stream-executor.js +171 -90
  40. package/dist/runtime/resumable-stream-executor.js.map +1 -1
  41. package/dist/runtime/run-state-registry.d.ts +2 -0
  42. package/dist/runtime/run-state-registry.js +3 -0
  43. package/dist/runtime/run-state-registry.js.map +1 -1
  44. package/dist/runtime/stream-runner.d.ts +3 -0
  45. package/dist/runtime/stream-runner.js +3 -0
  46. package/dist/runtime/stream-runner.js.map +1 -1
  47. package/dist/skills/materialize-runtime-skills.d.ts +3 -3
  48. package/dist/skills/materialize-runtime-skills.js +1 -1
  49. package/dist/skills/materialize-runtime-skills.js.map +1 -1
  50. package/dist/source-map-filter.js +0 -1
  51. package/dist/source-map-filter.js.map +1 -1
  52. package/dist/storage/terminal-outcome-storage.d.ts +2 -2
  53. package/dist/storage/workflow-loop-storage.d.ts +75 -4
  54. package/dist/stream/map-chunk.js +198 -237
  55. package/dist/stream/map-chunk.js.map +1 -1
  56. package/dist/stream/output-redaction.js +2 -2
  57. package/dist/stream/output-redaction.js.map +1 -1
  58. package/dist/stream/usage-accumulator.d.ts +90 -0
  59. package/dist/stream/usage-accumulator.js +89 -0
  60. package/dist/stream/usage-accumulator.js.map +1 -0
  61. package/dist/stream/work-summary-accumulator.d.ts +6 -6
  62. package/dist/tools/attachments/parse-file.tool.js +1 -1
  63. package/dist/tools/attachments/parse-file.tool.js.map +1 -1
  64. package/dist/tools/credentials.tool.js +4 -1
  65. package/dist/tools/credentials.tool.js.map +1 -1
  66. package/dist/tools/data-tables.tool.js +5 -2
  67. package/dist/tools/data-tables.tool.js.map +1 -1
  68. package/dist/tools/evals/column-ref-utils.d.ts +1 -2
  69. package/dist/tools/evals/column-ref-utils.js +19 -18
  70. package/dist/tools/evals/column-ref-utils.js.map +1 -1
  71. package/dist/tools/evals/describe-metric-for-workflow.service.js +7 -25
  72. package/dist/tools/evals/describe-metric-for-workflow.service.js.map +1 -1
  73. package/dist/tools/evals/detect-tool-refs.service.js +2 -1
  74. package/dist/tools/evals/detect-tool-refs.service.js.map +1 -1
  75. package/dist/tools/evals/eval-data-requirements.service.js +10 -9
  76. package/dist/tools/evals/eval-data-requirements.service.js.map +1 -1
  77. package/dist/tools/evals/evals.tool.js +2 -2
  78. package/dist/tools/evals/evals.tool.js.map +1 -1
  79. package/dist/tools/evals/extract-rows-from-history.service.js +8 -8
  80. package/dist/tools/evals/extract-rows-from-history.service.js.map +1 -1
  81. package/dist/tools/evals/generate-sample-rows.service.d.ts +2 -2
  82. package/dist/tools/evals/generate-sample-rows.service.js +30 -49
  83. package/dist/tools/evals/generate-sample-rows.service.js.map +1 -1
  84. package/dist/tools/evals/generate-tool-ref-pin-data.service.js +10 -23
  85. package/dist/tools/evals/generate-tool-ref-pin-data.service.js.map +1 -1
  86. package/dist/tools/evals/metric-catalog.js +3 -3
  87. package/dist/tools/evals/metric-catalog.js.map +1 -1
  88. package/dist/tools/executions.tool.js +10 -2
  89. package/dist/tools/executions.tool.js.map +1 -1
  90. package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +1 -1
  91. package/dist/tools/filesystem/create-tools-from-mcp-server.js +8 -10
  92. package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
  93. package/dist/tools/index.js +1 -1
  94. package/dist/tools/index.js.map +1 -1
  95. package/dist/tools/nodes/node-search-engine.js +21 -42
  96. package/dist/tools/nodes/node-search-engine.js.map +1 -1
  97. package/dist/tools/nodes/node-search-engine.types.d.ts +2 -0
  98. package/dist/tools/nodes/preferred-chat-model.d.ts +1 -0
  99. package/dist/tools/nodes/preferred-chat-model.js +19 -0
  100. package/dist/tools/nodes/preferred-chat-model.js.map +1 -0
  101. package/dist/tools/nodes/suggested-nodes-data.js +13 -3
  102. package/dist/tools/nodes/suggested-nodes-data.js.map +1 -1
  103. package/dist/tools/nodes.tool.js +32 -7
  104. package/dist/tools/nodes.tool.js.map +1 -1
  105. package/dist/tools/orchestration/complete-checkpoint.tool.js +3 -5
  106. package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -1
  107. package/dist/tools/orchestration/eval-data-agent.tool.js +2 -1
  108. package/dist/tools/orchestration/eval-data-agent.tool.js.map +1 -1
  109. package/dist/tools/orchestration/eval-setup-agent.prompt.d.ts +1 -1
  110. package/dist/tools/orchestration/eval-setup-agent.prompt.js +3 -3
  111. package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +2 -2
  112. package/dist/tools/orchestration/report-verification-verdict.tool.js +1 -1
  113. package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
  114. package/dist/tools/orchestration/verify-built-workflow.tool.js +328 -315
  115. package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
  116. package/dist/tools/research.tool.js +1 -1
  117. package/dist/tools/research.tool.js.map +1 -1
  118. package/dist/tools/shared/ask-user.tool.d.ts +4 -4
  119. package/dist/tools/shared/ask-user.tool.js +6 -1
  120. package/dist/tools/shared/ask-user.tool.js.map +1 -1
  121. package/dist/tools/tool-ids.d.ts +0 -1
  122. package/dist/tools/tool-ids.js +0 -1
  123. package/dist/tools/tool-ids.js.map +1 -1
  124. package/dist/tools/workflows/build-workflow.tool.d.ts +4 -22
  125. package/dist/tools/workflows/build-workflow.tool.js +374 -328
  126. package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
  127. package/dist/tools/workflows/classify-node-destructiveness.service.d.ts +7 -0
  128. package/dist/tools/workflows/classify-node-destructiveness.service.js +307 -0
  129. package/dist/tools/workflows/classify-node-destructiveness.service.js.map +1 -0
  130. package/dist/tools/workflows/generate-simulation-fixtures.service.d.ts +8 -0
  131. package/dist/tools/workflows/generate-simulation-fixtures.service.js +95 -0
  132. package/dist/tools/workflows/generate-simulation-fixtures.service.js.map +1 -0
  133. package/dist/tools/workflows/plan-verification-simulation.d.ts +16 -0
  134. package/dist/tools/workflows/plan-verification-simulation.js +76 -0
  135. package/dist/tools/workflows/plan-verification-simulation.js.map +1 -0
  136. package/dist/tools/workflows/resolve-credentials.d.ts +0 -2
  137. package/dist/tools/workflows/resolve-credentials.js +0 -13
  138. package/dist/tools/workflows/resolve-credentials.js.map +1 -1
  139. package/dist/tools/workflows/setup-workflow.service.js +259 -215
  140. package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
  141. package/dist/tools/workflows/validate-workflow.service.js +81 -66
  142. package/dist/tools/workflows/validate-workflow.service.js.map +1 -1
  143. package/dist/tools/workflows/workflow-build-context.d.ts +33 -0
  144. package/dist/tools/workflows/workflow-build-context.js +80 -0
  145. package/dist/tools/workflows/workflow-build-context.js.map +1 -0
  146. package/dist/tools/workflows/workflow-build-remediation.d.ts +11 -0
  147. package/dist/tools/workflows/workflow-build-remediation.js +89 -0
  148. package/dist/tools/workflows/workflow-build-remediation.js.map +1 -0
  149. package/dist/tools/workflows/workflow-build-reporting.d.ts +19 -0
  150. package/dist/tools/workflows/workflow-build-reporting.js +78 -0
  151. package/dist/tools/workflows/workflow-build-reporting.js.map +1 -0
  152. package/dist/tools/workflows/workflow-build-routing.d.ts +2 -0
  153. package/dist/tools/workflows/workflow-build-routing.js +60 -0
  154. package/dist/tools/workflows/workflow-build-routing.js.map +1 -0
  155. package/dist/tools/workflows/workflow-build-telemetry.d.ts +18 -0
  156. package/dist/tools/workflows/workflow-build-telemetry.js +33 -0
  157. package/dist/tools/workflows/workflow-build-telemetry.js.map +1 -0
  158. package/dist/tools/workflows/workflow-file-bindings.d.ts +28 -0
  159. package/dist/tools/workflows/workflow-file-bindings.js +104 -0
  160. package/dist/tools/workflows/workflow-file-bindings.js.map +1 -0
  161. package/dist/tools/workflows/workflow-json-utils.d.ts +3 -0
  162. package/dist/tools/workflows/workflow-json-utils.js +54 -5
  163. package/dist/tools/workflows/workflow-json-utils.js.map +1 -1
  164. package/dist/tools/workflows/workflow-source-compiler.d.ts +20 -0
  165. package/dist/tools/workflows/workflow-source-compiler.js +236 -0
  166. package/dist/tools/workflows/workflow-source-compiler.js.map +1 -0
  167. package/dist/tools/workflows/workflow-validation-warnings.d.ts +14 -0
  168. package/dist/tools/workflows/workflow-validation-warnings.js +28 -0
  169. package/dist/tools/workflows/workflow-validation-warnings.js.map +1 -0
  170. package/dist/tools/workflows.tool.js +107 -99
  171. package/dist/tools/workflows.tool.js.map +1 -1
  172. package/dist/tracing/langsmith-tracing.js +7 -7
  173. package/dist/tracing/langsmith-tracing.js.map +1 -1
  174. package/dist/tracing/trace-payloads.d.ts +2 -1
  175. package/dist/tracing/trace-payloads.js +152 -114
  176. package/dist/tracing/trace-payloads.js.map +1 -1
  177. package/dist/types.d.ts +24 -4
  178. package/dist/types.js.map +1 -1
  179. package/dist/utils/eval-agents.d.ts +0 -3
  180. package/dist/utils/eval-agents.js +3 -11
  181. package/dist/utils/eval-agents.js.map +1 -1
  182. package/dist/utils/generate-validated-json.d.ts +16 -0
  183. package/dist/utils/generate-validated-json.js +38 -0
  184. package/dist/utils/generate-validated-json.js.map +1 -0
  185. package/dist/utils/stream-helpers.d.ts +0 -1
  186. package/dist/utils/stream-helpers.js +5 -8
  187. package/dist/utils/stream-helpers.js.map +1 -1
  188. package/dist/workflow-builder/build-failure-tracker.js +25 -1
  189. package/dist/workflow-builder/build-failure-tracker.js.map +1 -1
  190. package/dist/workflow-builder/index.d.ts +0 -4
  191. package/dist/workflow-builder/index.js +1 -11
  192. package/dist/workflow-builder/index.js.map +1 -1
  193. package/dist/workflow-loop/guidance.js +14 -15
  194. package/dist/workflow-loop/guidance.js.map +1 -1
  195. package/dist/workflow-loop/runtime.js +1 -0
  196. package/dist/workflow-loop/runtime.js.map +1 -1
  197. package/dist/workflow-loop/setup-verification-policy.d.ts +8 -0
  198. package/dist/workflow-loop/setup-verification-policy.js +25 -0
  199. package/dist/workflow-loop/setup-verification-policy.js.map +1 -0
  200. package/dist/workflow-loop/verification-obligation.js +13 -8
  201. package/dist/workflow-loop/verification-obligation.js.map +1 -1
  202. package/dist/workflow-loop/workflow-loop-controller.js +26 -7
  203. package/dist/workflow-loop/workflow-loop-controller.js.map +1 -1
  204. package/dist/workflow-loop/workflow-loop-state.d.ts +90 -6
  205. package/dist/workflow-loop/workflow-loop-state.js +13 -1
  206. package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
  207. package/dist/workspace/builder-templates-service.d.ts +5 -5
  208. package/dist/workspace/builder-templates-service.js +17 -14
  209. package/dist/workspace/builder-templates-service.js.map +1 -1
  210. package/dist/workspace/create-workspace.js +8 -1
  211. package/dist/workspace/create-workspace.js.map +1 -1
  212. package/dist/workspace/prebaked-workspace-bundle.d.ts +2 -2
  213. package/dist/workspace/prebaked-workspace-bundle.js +5 -5
  214. package/dist/workspace/prebaked-workspace-bundle.js.map +1 -1
  215. package/dist/workspace/sandbox-setup.d.ts +2 -2
  216. package/dist/workspace/sandbox-setup.js +15 -38
  217. package/dist/workspace/sandbox-setup.js.map +1 -1
  218. package/dist/workspace/snapshot-manager.d.ts +1 -1
  219. package/dist/workspace/template-telemetry.js +2 -5
  220. package/dist/workspace/template-telemetry.js.map +1 -1
  221. package/dist/workspace/workspace-files.d.ts +1 -1
  222. package/dist/workspace/workspace-files.js +3 -3
  223. package/dist/workspace/workspace-files.js.map +1 -1
  224. package/dist/workspace/workspace-manifest.js +2 -2
  225. package/dist/workspace/workspace-manifest.js.map +1 -1
  226. package/dist/workspace/workspace-paths.d.ts +4 -0
  227. package/dist/workspace/workspace-paths.js +25 -0
  228. package/dist/workspace/workspace-paths.js.map +1 -0
  229. package/knowledge-base/reference/open-ai-output-shape.md +79 -0
  230. package/knowledge-base/reference/workflow-builder-guardrails.md +15 -0
  231. package/package.json +13 -12
  232. package/skills/planned-task-runtime/SKILL.md +3 -2
  233. package/skills/planning/SKILL.md +5 -0
  234. package/skills/post-build-flow/SKILL.md +25 -9
  235. package/skills/workflow-builder/SKILL.md +96 -134
  236. package/dist/tools/workflows/submit-workflow-identity.d.ts +0 -39
  237. package/dist/tools/workflows/submit-workflow-identity.js +0 -181
  238. package/dist/tools/workflows/submit-workflow-identity.js.map +0 -1
  239. package/dist/tools/workflows/submit-workflow.tool.d.ts +0 -223
  240. package/dist/tools/workflows/submit-workflow.tool.js +0 -491
  241. package/dist/tools/workflows/submit-workflow.tool.js.map +0 -1
  242. package/dist/workflow-builder/extract-code.d.ts +0 -5
  243. package/dist/workflow-builder/extract-code.js +0 -105
  244. package/dist/workflow-builder/extract-code.js.map +0 -1
  245. package/dist/workflow-builder/parse-validate.d.ts +0 -10
  246. package/dist/workflow-builder/parse-validate.js +0 -50
  247. package/dist/workflow-builder/parse-validate.js.map +0 -1
  248. package/dist/workflow-builder/patch-code.d.ts +0 -14
  249. package/dist/workflow-builder/patch-code.js +0 -117
  250. package/dist/workflow-builder/patch-code.js.map +0 -1
  251. package/dist/workflow-builder/types.d.ts +0 -11
  252. package/dist/workflow-builder/types.js +0 -3
  253. package/dist/workflow-builder/types.js.map +0 -1
@@ -2,11 +2,15 @@
2
2
  name: workflow-builder
3
3
  description: >-
4
4
  Default path for all single-workflow work: new one-off workflows, existing-
5
- workflow edits, verification repairs, and workflow-local data tables. Use
6
- build-workflow directly do not load planning or create-tasks first. Load
7
- planning only when multiple coordinated workflows or shared cross-task data
8
- tables require a dependency-aware task graph.
5
+ workflow edits, verification repairs, and workflow-local data tables. Write
6
+ or edit a workspace source file, then call build-workflow with filePath. Do
7
+ not load planning or create-tasks first. Load planning only when multiple
8
+ coordinated workflows or shared cross-task data tables require a
9
+ dependency-aware task graph.
9
10
  recommended_tools:
11
+ - read_file
12
+ - write_file
13
+ - edit_file
10
14
  - build-workflow
11
15
  - workflows
12
16
  - nodes
@@ -19,103 +23,50 @@ recommended_tools:
19
23
  # Workflow Builder
20
24
 
21
25
  You are an expert n8n workflow builder. You generate complete, valid
22
- TypeScript code using `@n8n/workflow-sdk`.
26
+ TypeScript code using `@n8n/workflow-sdk` for new workflows and for existing
27
+ saved workflow changes.
23
28
 
24
29
  This skill runs inside the orchestrator. It does not introduce a separate
25
- builder agent, delegated handoff, sandbox workspace, or separate tool allowlist.
26
- Use the orchestrator tools already available in the current turn. If a relevant
27
- orchestrator or MCP tool is available through tool search, use it when it helps
28
- complete the build.
29
-
30
- For all clear single-workflow requests including new and one-off workflows
31
- build directly with `build-workflow`. Do not load `planning` or call
32
- `create-tasks` first. Only load `planning` when the orchestrator routing rules
33
- require coordinated multi-artifact work. Use this skill during an approved
34
- `<planned-task-follow-up type="build-workflow">` turn, or for direct
35
- single-workflow builds and edits.
36
-
37
- Do not call `delegate` to build, patch, fix, verify, or update workflows. The
38
- builder work happens here with the workflow-builder guidance and the
39
- orchestrator's tools.
40
-
41
- ## Output Discipline
42
-
43
- - Your text output is visible to the user. Be concise and natural.
44
- - Only output text for errors that need attention, or a brief natural completion
45
- message.
46
- - No emojis, no filler phrases, no markdown headers in your text output.
47
- - When conversation context is provided, use it to continue naturally. Do not
48
- repeat information the user already knows.
49
-
50
- ### No Narration
51
-
52
- Do not announce what you are about to do. The user already sees tool calls in
53
- real time. Stay silent while working; speak only on completion or when blocked.
54
-
55
- Bad:
56
-
57
- - "I'll build this workflow. Let me start by discovering credentials..."
58
- - "I'll start by reading the current workflow code..."
59
- - "I don't see any pinData, so let me check..."
60
-
61
- Good:
62
-
63
- - "Workflow ready: Telegram messages are summarized and added to your table."
64
- - "Workflow updated: removed the stale pinData from the weather check node."
65
- - "Blocked: the Linear API credential is missing; setup is required before I can
66
- continue."
67
-
68
- ## Tool Surface
69
-
70
- Tool names are part of the compatibility contract. Keep using the same tool
71
- names the old builder used:
72
-
73
- - `build-workflow` to save TypeScript SDK code or apply targeted patches.
74
- - `workflows(action="get-as-code")` before precise patches to an existing
75
- workflow when you need the current code.
76
- - `workflows(action="get")`, `workflows(action="list")`, and
77
- `workflows(action="setup")` when inspection or setup routing is needed.
78
- - `credentials(action="list" | "get" | "search-types" | "test")` for credential
79
- metadata and connection checks.
80
- - `nodes(action="suggested")` for known workflow categories.
81
- - `nodes(action="search")` for service-specific node discovery.
82
- - `nodes(action="type-definition")` for exact parameter names, enum values,
83
- credential types, display conditions, and `@builderHint` annotations.
84
- - `nodes(action="explore-resources")` for live credential-backed resource lists.
85
- - `data-tables(action="list" | "create" | "schema")` for Data Table work.
86
- - `parse-file` for parseable user attachments.
87
- - `research` for external documentation when node definitions are insufficient.
88
- - `ask-user` only when a human choice is needed.
89
- - `executions` and `verify-built-workflow` for verification when the current
90
- turn is responsible for verification.
91
- - `complete-checkpoint` and `report-verification-verdict` only in checkpoint
92
- follow-up turns.
30
+ builder agent, delegated handoff, or separate tool allowlist. Use the
31
+ orchestrator tools and runtime workspace file tools already available in the
32
+ current turn. If a relevant agent tool or MCP tool is available through tool
33
+ search, use it when it helps complete the build. Do not call `delegate` to build, patch, fix, verify, or update workflows.
34
+
35
+ For clear new single-workflow requests, write or edit a TypeScript SDK source
36
+ file in the workspace, then build directly with `build-workflow({ filePath })`.
37
+ For existing saved workflow edits, call
38
+ `workflows(action="get-as-code", workflowId)`, write the returned code to a
39
+ `.workflow.ts` workspace file, make the requested edit there, then call
40
+ `build-workflow({ filePath, workflowId })` the first time. Do not load
41
+ `planning` or call `create-tasks` first. Only load `planning` when the
42
+ orchestrator routing rules require coordinated multi-artifact work. Use this
43
+ skill during an approved `<planned-task-follow-up type="build-workflow">` turn,
44
+ or for direct single-workflow builds and edits.
45
+
46
+ Existing edits must go through a workspace source file and `build-workflow`.
93
47
 
94
48
  ## Repair Strategy
95
49
 
96
50
  When called with failure details for an existing workflow, start from the
97
- pre-loaded code or the saved workflow code. Do not re-discover node types that
98
- are already present unless the repair touches their parameters, resources,
99
- credentials, versions, or wiring semantics.
51
+ workspace source file if one is available in the conversation or tool output. If
52
+ you only have a saved n8n workflow ID, use `workflows(action="get-as-code")`,
53
+ write the returned code to a stable `src/workflows/<name>.workflow.ts` file, make
54
+ the smallest requested edit in that file, then call `build-workflow` with both
55
+ `filePath` and `workflowId` once. Later repairs should reuse the same
56
+ `filePath`; `build-workflow` remembers the bound workflow ID.
100
57
 
101
- For small fixes, prefer patch mode:
102
-
103
- ```json
104
- {
105
- "workflowId": "existing-id",
106
- "patches": [{ "old_str": "exact old code", "new_str": "replacement code" }]
107
- }
108
- ```
109
-
110
- Patches apply to the last submitted code, or the tool fetches the saved workflow
111
- when `workflowId` is provided. Use full code for larger rewrites.
58
+ For repairs, edit the workspace file directly and call `build-workflow` again
59
+ with the same `filePath`. Do not send inline workflow code or string patches to
60
+ `build-workflow`.
112
61
 
113
62
  ## Escalation
114
63
 
115
64
  If you are stuck or need information only a human can provide, use `ask-user`.
116
- Do not retry the same failing approach more than twice. Never solicit API keys,
117
- tokens, passwords, or other secrets through `ask-user`; route credential
118
- collection through workflow setup or credential setup surfaces.
65
+ Do not retry the same failing approach more than twice. Never re-ask a question
66
+ the user has already answered, deferred, or skipped treat a skip as permission
67
+ to assume a sensible default or leave the detail for setup, and move on. Never
68
+ solicit API keys, tokens, passwords, or other secrets through `ask-user`; route
69
+ credential collection through workflow setup or credential setup surfaces.
119
70
 
120
71
  ## Placeholders
121
72
 
@@ -146,6 +97,11 @@ digests or reports, non-trivial branching, or Code nodes, read
146
97
  Use it as the build checklist for source preservation, fan-out/fan-in,
147
98
  effect-specific gating, list itemization, and Code-node safety.
148
99
 
100
+ When mapping downstream fields from an OpenAI node, read
101
+ `knowledge-base/reference/open-ai-output-shape.md` (v2+ text/response uses
102
+ `$json.output[0].content[0].text`; v1 text/message uses `$json.message.content`
103
+ — not `$json.text`).
104
+
149
105
  ## Mandatory Process
150
106
 
151
107
  1. Research. If the workflow fits a known category, call
@@ -169,11 +125,21 @@ effect-specific gating, list itemization, and Code-node safety.
169
125
  method name, method type, credential type, and credential ID. This is
170
126
  mandatory for calendars, spreadsheets, channels, folders, databases, models,
171
127
  and any other list-backed parameter when a credential is available.
172
- 6. Build complete TypeScript SDK code and call `build-workflow`.
128
+ 6. Pick a stable workspace `filePath` for the source file, typically
129
+ `src/workflows/main.workflow.ts` for a one-off new workflow, or a clearly
130
+ named `.workflow.ts` file when multiple source files are useful. For an
131
+ existing workflow with no source file in context, call
132
+ `workflows(action="get-as-code", workflowId)`, write the returned code to the
133
+ chosen `.workflow.ts` file, and pass the n8n `workflowId` only on the first
134
+ `build-workflow` call.
135
+ 7. Write complete TypeScript SDK code to the workspace `filePath`, or read and
136
+ selectively edit the existing `.workflow.ts` file for workflow changes. Do
137
+ not put secrets in the source file.
138
+ 8. Call `build-workflow` with `filePath`.
173
139
  For planned build follow-ups where `buildTask.isSupportingWorkflow === true`,
174
140
  pass `isSupportingWorkflow: true`; that saved supporting workflow is the
175
141
  task's final deliverable.
176
- 7. Trace wiring before declaring done. For IF, Switch, Merge, AI-agent, loop, or
142
+ 9. Trace wiring before declaring done. For IF, Switch, Merge, AI-agent, loop, or
177
143
  multi-workflow wiring, trace each branch from source to target. Confirm IF
178
144
  branches are wired on the workflow builder (`.to(ifNode).onTrue(...).onFalse(...)`
179
145
  or `.to(ifNode.onTrue(...).onFalse(...))`), not as standalone calls on the IF
@@ -183,13 +149,15 @@ effect-specific gating, list itemization, and Code-node safety.
183
149
  every requested side effect is on a wired branch. Switch outputs use zero-based
184
150
  `.onCase(index, target)`, Merge modes match the data shape, and sub-nodes are
185
151
  attached to the correct parent.
186
- 8. Fix errors. If `build-workflow` returns errors, repair with targeted patches
187
- when possible, or resubmit full SDK code for larger changes. Save again before
188
- any verification step.
189
- 9. Modify existing workflows with `workflowId` plus patches where possible. Use
190
- `workflows(action="get-as-code")` first when you need to identify exact code
191
- to replace.
192
- 10. Finish with a concise completion message only when the build, required
152
+ 10. Fix errors by editing the same workspace source file and calling
153
+ `build-workflow` again with the same `filePath`. Save again before any
154
+ verification step.
155
+ 11. Modify existing workflows by editing the workspace `.workflow.ts` source
156
+ file. If the file was created from `workflows(action="get-as-code")`, pass
157
+ the real n8n `workflowId` on the first `build-workflow` call so the file is
158
+ bound to the saved workflow. Never pass local SDK workflow IDs as n8n
159
+ workflow IDs.
160
+ 12. Finish with a concise completion message only when the build, required
193
161
  setup routing, or required verification path is complete.
194
162
 
195
163
  Do not produce visible output until the final step, unless blocked.
@@ -208,13 +176,13 @@ Use the current turn's higher-priority instructions to decide who verifies:
208
176
 
209
177
  Build/save success is not workflow-quality evidence. When this turn is
210
178
  responsible for verification or repair, inspect the persisted workflow with
211
- `workflows(action="get-json", workflowId)` after saving or before reporting a
212
- verdict. Judge the saved graph against the user's requested outcome and the
213
- current build/checkpoint goal, not a hidden service-specific or topology
214
- checklist.
179
+ `workflows(action="get-as-code", workflowId)` or read the bound workspace
180
+ source file after saving or before reporting a verdict. Judge the saved graph
181
+ against the user's requested outcome and the current build/checkpoint goal, not
182
+ a hidden service-specific or topology checklist.
215
183
  If the saved workflow is only a draft, misses the intended outcome, or has weak
216
- evidence, patch the same workflow with `build-workflow`, then inspect and verify
217
- again.
184
+ evidence, edit the same workflow source file and call `build-workflow` with the
185
+ same `filePath`, then inspect and verify again.
218
186
 
219
187
  When this turn is responsible for verification, do not stop after a successful
220
188
  save. The job is done when one of these is true:
@@ -238,8 +206,9 @@ Trigger input shapes:
238
206
 
239
207
  If verification returns remediation with `shouldEdit: false`, stop editing and
240
208
  follow its guidance. If verification fails with `shouldEdit: true`, make one
241
- batched code repair, call `build-workflow` again, and retry within the repair
242
- budget. If a failure repeats, stop and explain the blocker.
209
+ batched source-file repair, call `build-workflow` again with the same
210
+ `filePath`, and retry within the repair budget. If a failure repeats, stop and
211
+ explain the blocker.
243
212
 
244
213
  Do not publish the main workflow automatically. Publishing is the user's
245
214
  decision after testing.
@@ -296,14 +265,15 @@ a main workflow. This is part of an approved build task, not a reason to call
296
265
  Use this pattern when a workflow is large, has reusable chunks, or benefits from
297
266
  independent testing. Simple workflows should stay in one workflow.
298
267
 
299
- 1. Build each supporting workflow first with `build-workflow` and
300
- `isSupportingWorkflow: true`.
268
+ 1. Write a source file for each supporting workflow, then build it with
269
+ `build-workflow` and `isSupportingWorkflow: true`.
301
270
  2. Give each supporting workflow an `executeWorkflowTrigger` (version 1.1) with
302
271
  an explicit input schema.
303
272
  3. Use the returned supporting `workflowId` in the main workflow's
304
273
  `executeWorkflow` node with `source: 'database'`.
305
- 4. Save the main workflow last with `build-workflow` and without
306
- `isSupportingWorkflow`; this is the build task's final deliverable outcome.
274
+ 4. Create or edit the main workflow source file last, then save it with
275
+ `build-workflow` and without `isSupportingWorkflow`; this is the build task's
276
+ final deliverable outcome.
307
277
  5. Do not publish the main workflow automatically. Supporting workflows may be
308
278
  published when the parent workflow needs them active for verification or
309
279
  runtime references, but only after their setup requirements are resolved.
@@ -411,6 +381,13 @@ column names.
411
381
  later referenced by `$json` expressions, including optional trigger fields
412
382
  used in filters (for example Slack `subtype`, `bot_id`, `text`, `user`, `ts`,
413
383
  `channel`). Missing optional fields make expression-path validation fail.
384
+ - SDK node `output` mocks are raw `$json` objects. Do not wrap mock items in
385
+ n8n runtime item envelopes like `{ json: { ... } }` unless downstream
386
+ expressions intentionally read `$json.json.*`. Correct:
387
+ `output: [{ orderId: 'ord_123', total: 42 }]`; wrong:
388
+ `output: [{ json: { orderId: 'ord_123', total: 42 } }]`.
389
+ Code node `jsCode` may still return runtime items like `[{ json: { ... } }]`;
390
+ this rule applies to SDK `node({ output: [...] })` mocks.
414
391
 
415
392
  Use this import shape unless the task needs fewer symbols:
416
393
 
@@ -450,12 +427,9 @@ Follow these rules strictly when generating workflows:
450
427
  1. Always use `newCredential()` for authentication. Never use placeholder
451
428
  strings, fake API keys, hardcoded auth values, invented credential IDs, or
452
429
  raw `mock-*` IDs.
453
- 2. Skip-on-empty is n8n's default behaviour: when a node outputs zero items,
454
- downstream nodes simply do not run and the branch ends silently. Trust it
455
- do not add `alwaysOutputData: true` just to keep a chain alive, and do not
456
- add an IF gate before a loop only to check whether items exist. To make an
457
- outcome happen even with zero items, wire it via the control-flow rule
458
- below.
430
+ 2. Zero items end the branch downstream nodes do not run. Trust this default;
431
+ do not add `alwaysOutputData: true` or empty-check IF gates unless rule 4's
432
+ mandatory-outcome case applies.
459
433
  3. Use `executeOnce: true` for a node that receives many items but should run
460
434
  once, such as a summary notification, report generation, shared-context
461
435
  fetch, or API call that does not vary per input item. Duplicate
@@ -470,16 +444,11 @@ Follow these rules strictly when generating workflows:
470
444
  statements on the IF node variable.
471
445
  - Many mutually exclusive paths keyed off a value: Switch with
472
446
  `.onCase(index, target)`.
473
- - An outcome that must happen even when zero items remain: a node that
474
- receives zero items does not run at all `items.length === 0` logic
475
- inside a downstream node is dead code, and an IF placed after an empty
476
- output never fires. The fix goes on the PRODUCER, not the consumer:
477
- `alwaysOutputData: true` in the config of the node whose output can be
478
- empty (the fetch or the filter) makes it emit one empty-marker item
479
- (empty `$json`) instead of ending the branch; an IF then separates that
480
- marker from real items. Putting the flag on the node you want to run
481
- does nothing. Example:
482
- `node({ type: 'n8n-nodes-base.httpRequest', config: { alwaysOutputData: true, name: 'Fetch Posts', parameters: { /* ... */ } } })`
447
+ - Mandatory outcome when upstream can be empty (digest/alert must still send):
448
+ set `alwaysOutputData: true` on every node that can emit zero items before
449
+ the effect often both the HTTP fetch (empty `[]`) and the filter (all rows
450
+ dropped). Not on the formatter or notifier; consumers that receive zero
451
+ items never run.
483
452
  - A Filter or IF only selects items; it does not perform the requested side
484
453
  effect. If the user asks to archive, update, delete, send, or create only
485
454
  matching items, wire the corresponding action node on the matching path.
@@ -505,13 +474,6 @@ Follow these rules strictly when generating workflows:
505
474
  definitions and `@builderHint` annotations are the source of truth.
506
475
  - Use live `nodes(action="explore-resources")` for resource locator, list, and
507
476
  model fields when credentials are available.
508
- - Resource-locator `list` and `id` modes hold opaque IDs picked from real data —
509
- never put a human-readable name in their `value` (a sheet/board/folder title
510
- in `list` mode can never resolve, in production or in tests). When you only
511
- know the resource by name and the locator offers a `name` (or `url`) mode,
512
- use that mode with the known name. Fall back to id mode with an empty value
513
- and a `cachedResultName` only when no name mode exists and no credential is
514
- available to resolve a real ID.
515
477
  - If a configuration is unclear after reading the definition, ask for
516
478
  clarification or use placeholders. Do not guess.
517
479
  - Pay attention to `@builderHint` annotations in search results and type
@@ -1,39 +0,0 @@
1
- import type { CredentialMap } from './resolve-credentials';
2
- import { type SubmitWorkflowAttempt, type SubmitWorkflowInput, type SubmitWorkflowOutput } from './submit-workflow.tool';
3
- import type { InstanceAiContext } from '../../types';
4
- import type { RemediationMetadata, WorkflowLoopState } from '../../workflow-loop/workflow-loop-state';
5
- import type { SandboxWorkspace } from '../../workspace/sandbox-fs';
6
- export type SubmitExecute = (input: SubmitWorkflowInput) => Promise<SubmitWorkflowOutput>;
7
- interface SubmitGuardOptions {
8
- getWorkflowLoopState?: () => Promise<WorkflowLoopState | undefined>;
9
- getTerminalRemediation?: () => RemediationMetadata | undefined;
10
- currentRunId?: string;
11
- onGuardFired?: (event: {
12
- workflowId?: string;
13
- category: RemediationMetadata['category'];
14
- attemptCount?: number;
15
- reason?: string;
16
- }) => void;
17
- onTerminalRemediation?: (remediation: RemediationMetadata) => void;
18
- }
19
- interface SubmitBudgetTracker {
20
- recordAttempt(attempt: SubmitWorkflowAttempt): SubmitWorkflowAttempt;
21
- applyToOutput(path: string, output: SubmitWorkflowOutput): SubmitWorkflowOutput;
22
- }
23
- export declare function createPreSaveBudgetTracker(): SubmitBudgetTracker;
24
- export declare function wrapSubmitExecuteWithIdentity(underlying: SubmitExecute, resolvePath: (rawFilePath: string | undefined) => string, options?: SubmitGuardOptions & {
25
- budgetTracker?: SubmitBudgetTracker;
26
- }): SubmitExecute;
27
- export declare function withDefaultWorkflowFilePath(input: SubmitWorkflowInput, defaultFilePath: string | undefined): SubmitWorkflowInput;
28
- export declare function createIdentityEnforcedSubmitWorkflowTool(args: {
29
- context: InstanceAiContext;
30
- workspace: SandboxWorkspace;
31
- credentialMap?: CredentialMap;
32
- onAttempt: (attempt: SubmitWorkflowAttempt) => Promise<void> | void;
33
- root: string;
34
- defaultFilePath?: string;
35
- currentRunId?: string;
36
- getWorkflowLoopState?: () => Promise<WorkflowLoopState | undefined>;
37
- onGuardFired?: SubmitGuardOptions['onGuardFired'];
38
- }): import("@n8n/agents").BuiltTool;
39
- export {};
@@ -1,181 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPreSaveBudgetTracker = createPreSaveBudgetTracker;
4
- exports.wrapSubmitExecuteWithIdentity = wrapSubmitExecuteWithIdentity;
5
- exports.withDefaultWorkflowFilePath = withDefaultWorkflowFilePath;
6
- exports.createIdentityEnforcedSubmitWorkflowTool = createIdentityEnforcedSubmitWorkflowTool;
7
- const agents_1 = require("@n8n/agents");
8
- const submit_workflow_tool_1 = require("./submit-workflow.tool");
9
- const remediation_1 = require("../../workflow-loop/remediation");
10
- function createPreSaveBudgetTracker() {
11
- const failuresByPath = new Map();
12
- function blockRemediation(attemptCount) {
13
- return (0, remediation_1.createRemediation)({
14
- category: 'blocked',
15
- shouldEdit: false,
16
- reason: 'pre_save_submit_budget_exhausted',
17
- attemptCount,
18
- remainingSubmitFixes: 0,
19
- guidance: 'The workflow could not be saved after three submit attempts. Stop editing and explain the blocker to the user.',
20
- });
21
- }
22
- return {
23
- recordAttempt(attempt) {
24
- if (attempt.success) {
25
- failuresByPath.delete(attempt.filePath);
26
- return attempt;
27
- }
28
- const attemptCount = (failuresByPath.get(attempt.filePath) ?? 0) + 1;
29
- failuresByPath.set(attempt.filePath, attemptCount);
30
- if (attemptCount < remediation_1.MAX_PRE_SAVE_SUBMIT_FAILURES)
31
- return attempt;
32
- return {
33
- ...attempt,
34
- remediation: blockRemediation(attemptCount),
35
- errors: [
36
- ...(attempt.errors ?? []),
37
- 'Submit remediation budget exhausted for this workflow file.',
38
- ],
39
- };
40
- },
41
- applyToOutput(path, output) {
42
- if (output.success)
43
- return output;
44
- const attemptCount = failuresByPath.get(path) ?? 0;
45
- if (attemptCount < remediation_1.MAX_PRE_SAVE_SUBMIT_FAILURES)
46
- return output;
47
- return {
48
- ...output,
49
- remediation: blockRemediation(attemptCount),
50
- errors: [
51
- ...(output.errors ?? []),
52
- 'Submit remediation budget exhausted for this workflow file.',
53
- ],
54
- };
55
- },
56
- };
57
- }
58
- function wrapSubmitExecuteWithIdentity(underlying, resolvePath, options = {}) {
59
- const pending = new Map();
60
- function recordTerminalRemediation(workflowId, remediation) {
61
- if (!remediation || remediation.shouldEdit)
62
- return;
63
- options.onTerminalRemediation?.(remediation);
64
- options.onGuardFired?.({
65
- workflowId,
66
- category: remediation.category,
67
- attemptCount: remediation.attemptCount,
68
- reason: remediation.reason,
69
- });
70
- }
71
- function applyOutputGuards(path, output, fallbackWorkflowId) {
72
- const guarded = options.budgetTracker?.applyToOutput(path, output) ?? output;
73
- recordTerminalRemediation(guarded.workflowId ?? fallbackWorkflowId, guarded.remediation);
74
- return guarded;
75
- }
76
- async function blockedByTerminalRemediation(workflowId) {
77
- const terminalRemediation = options.getTerminalRemediation?.() ??
78
- (0, remediation_1.terminalRemediationFromState)(await options.getWorkflowLoopState?.(), options.currentRunId);
79
- if (!terminalRemediation)
80
- return undefined;
81
- options.onTerminalRemediation?.(terminalRemediation);
82
- options.onGuardFired?.({
83
- workflowId,
84
- category: terminalRemediation.category,
85
- attemptCount: terminalRemediation.attemptCount,
86
- reason: terminalRemediation.reason,
87
- });
88
- return {
89
- success: false,
90
- errors: [terminalRemediation.guidance],
91
- remediation: terminalRemediation,
92
- };
93
- }
94
- return async (input) => {
95
- const resolvedPath = resolvePath(input.filePath);
96
- const terminalResult = await blockedByTerminalRemediation(input.workflowId);
97
- if (terminalResult)
98
- return terminalResult;
99
- const existing = pending.get(resolvedPath);
100
- if (existing) {
101
- let boundId;
102
- try {
103
- boundId = await existing;
104
- }
105
- catch (error) {
106
- const terminalAfterFailure = await blockedByTerminalRemediation(input.workflowId);
107
- if (terminalAfterFailure)
108
- return terminalAfterFailure;
109
- const message = error instanceof Error ? error.message : String(error);
110
- return {
111
- success: false,
112
- errors: [`Previous submit-workflow for this file failed: ${message}`],
113
- remediation: (0, remediation_1.createRemediation)({
114
- category: 'code_fixable',
115
- shouldEdit: true,
116
- reason: 'previous_submit_failed',
117
- guidance: 'The previous submit-workflow call for this file failed. Fix the workflow code and submit again.',
118
- }),
119
- };
120
- }
121
- const terminalAfterWait = await blockedByTerminalRemediation(boundId);
122
- if (terminalAfterWait)
123
- return terminalAfterWait;
124
- const result = await underlying({ ...input, workflowId: boundId });
125
- return applyOutputGuards(resolvedPath, result, boundId);
126
- }
127
- let resolveFn;
128
- let rejectFn;
129
- const promise = new Promise((res, rej) => {
130
- resolveFn = res;
131
- rejectFn = rej;
132
- });
133
- promise.catch(() => { });
134
- pending.set(resolvedPath, promise);
135
- try {
136
- const result = await underlying(input);
137
- const guarded = applyOutputGuards(resolvedPath, result, input.workflowId);
138
- if (guarded.success && typeof guarded.workflowId === 'string') {
139
- resolveFn?.(guarded.workflowId);
140
- }
141
- else {
142
- rejectFn?.(new Error(guarded.errors?.join(' ') ?? 'submit-workflow failed'));
143
- pending.delete(resolvedPath);
144
- }
145
- return guarded;
146
- }
147
- catch (error) {
148
- rejectFn?.(error);
149
- pending.delete(resolvedPath);
150
- throw error;
151
- }
152
- };
153
- }
154
- function withDefaultWorkflowFilePath(input, defaultFilePath) {
155
- return defaultFilePath && !input.filePath ? { ...input, filePath: defaultFilePath } : input;
156
- }
157
- function createIdentityEnforcedSubmitWorkflowTool(args) {
158
- const budgetTracker = createPreSaveBudgetTracker();
159
- const underlying = (0, submit_workflow_tool_1.createSubmitWorkflowTool)(args.context, args.workspace, args.credentialMap, async (attempt) => {
160
- await args.onAttempt(budgetTracker.recordAttempt(attempt));
161
- }, { root: args.root, defaultFilePath: args.defaultFilePath });
162
- const underlyingExecute = underlying.handler;
163
- if (!underlyingExecute) {
164
- throw new Error('createSubmitWorkflowTool returned a tool without a handler');
165
- }
166
- const wrappedExecute = wrapSubmitExecuteWithIdentity(underlyingExecute, (rawFilePath) => rawFilePath
167
- ? (0, submit_workflow_tool_1.resolveSandboxWorkflowFilePath)(rawFilePath, args.root)
168
- : (args.defaultFilePath ?? (0, submit_workflow_tool_1.resolveSandboxWorkflowFilePath)(rawFilePath, args.root)), {
169
- budgetTracker,
170
- currentRunId: args.currentRunId,
171
- getWorkflowLoopState: args.getWorkflowLoopState,
172
- onGuardFired: args.onGuardFired,
173
- });
174
- return new agents_1.Tool('submit-workflow')
175
- .description(underlying.description)
176
- .input(submit_workflow_tool_1.submitWorkflowInputSchema)
177
- .output(submit_workflow_tool_1.submitWorkflowOutputSchema)
178
- .handler(async (input) => await wrappedExecute(withDefaultWorkflowFilePath(input, args.defaultFilePath)))
179
- .build();
180
- }
181
- //# sourceMappingURL=submit-workflow-identity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"submit-workflow-identity.js","sourceRoot":"","sources":["../../../src/tools/workflows/submit-workflow-identity.ts"],"names":[],"mappings":";;AA4DA,gEAkDC;AAYD,sEAoHC;AAED,kEAKC;AAMD,4FAkDC;AA7RD,wCAAmC;AAGnC,iEAQgC;AAEhC,iEAIyC;AA2BzC,SAAgB,0BAA0B;IACzC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEjD,SAAS,gBAAgB,CAAC,YAAoB;QAC7C,OAAO,IAAA,+BAAiB,EAAC;YACxB,QAAQ,EAAE,SAAS;YACnB,UAAU,EAAE,KAAK;YACjB,MAAM,EAAE,kCAAkC;YAC1C,YAAY;YACZ,oBAAoB,EAAE,CAAC;YACvB,QAAQ,EACP,gHAAgH;SACjH,CAAC,CAAC;IACJ,CAAC;IAED,OAAO;QACN,aAAa,CAAC,OAAO;YACpB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrB,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACxC,OAAO,OAAO,CAAC;YAChB,CAAC;YAED,MAAM,YAAY,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,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