@n8n/instance-ai 1.4.1 → 1.6.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 (266) hide show
  1. package/dist/agent/computer-use-prompt.d.ts +5 -0
  2. package/dist/agent/computer-use-prompt.js +97 -0
  3. package/dist/agent/computer-use-prompt.js.map +1 -0
  4. package/dist/agent/instance-agent.js +48 -73
  5. package/dist/agent/instance-agent.js.map +1 -1
  6. package/dist/agent/mcp-tool-name-validation.d.ts +15 -0
  7. package/dist/agent/mcp-tool-name-validation.js +67 -0
  8. package/dist/agent/mcp-tool-name-validation.js.map +1 -0
  9. package/dist/agent/sanitize-mcp-schemas.d.ts +56 -2
  10. package/dist/agent/sanitize-mcp-schemas.js +226 -19
  11. package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
  12. package/dist/agent/sub-agent-debriefing.d.ts +2 -2
  13. package/dist/agent/sub-agent-factory.d.ts +1 -0
  14. package/dist/agent/sub-agent-factory.js +1 -0
  15. package/dist/agent/sub-agent-factory.js.map +1 -1
  16. package/dist/agent/system-prompt.d.ts +1 -1
  17. package/dist/agent/system-prompt.js +46 -104
  18. package/dist/agent/system-prompt.js.map +1 -1
  19. package/dist/build.tsbuildinfo +1 -1
  20. package/dist/constants/model-settings.d.ts +3 -0
  21. package/dist/constants/model-settings.js +7 -0
  22. package/dist/constants/model-settings.js.map +1 -0
  23. package/dist/domain-access/domain-access-tracker.d.ts +3 -0
  24. package/dist/domain-access/domain-access-tracker.js +16 -0
  25. package/dist/domain-access/domain-access-tracker.js.map +1 -1
  26. package/dist/domain-access/domain-gating.d.ts +35 -6
  27. package/dist/domain-access/domain-gating.js +47 -1
  28. package/dist/domain-access/domain-gating.js.map +1 -1
  29. package/dist/domain-access/index.d.ts +1 -1
  30. package/dist/domain-access/index.js +3 -1
  31. package/dist/domain-access/index.js.map +1 -1
  32. package/dist/index.d.ts +14 -6
  33. package/dist/index.js +19 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/logger.d.ts +6 -0
  36. package/dist/mcp/mcp-client-manager.d.ts +18 -2
  37. package/dist/mcp/mcp-client-manager.js +124 -20
  38. package/dist/mcp/mcp-client-manager.js.map +1 -1
  39. package/dist/parsers/docx-parser.d.ts +6 -0
  40. package/dist/parsers/docx-parser.js +65 -0
  41. package/dist/parsers/docx-parser.js.map +1 -0
  42. package/dist/parsers/html-parser.d.ts +7 -0
  43. package/dist/parsers/html-parser.js +67 -0
  44. package/dist/parsers/html-parser.js.map +1 -0
  45. package/dist/parsers/index.d.ts +4 -0
  46. package/dist/parsers/index.js +16 -0
  47. package/dist/parsers/index.js.map +1 -0
  48. package/dist/parsers/pdf-parser.d.ts +7 -0
  49. package/dist/parsers/pdf-parser.js +72 -0
  50. package/dist/parsers/pdf-parser.js.map +1 -0
  51. package/dist/parsers/structured-file-parser.d.ts +8 -3
  52. package/dist/parsers/structured-file-parser.js +36 -4
  53. package/dist/parsers/structured-file-parser.js.map +1 -1
  54. package/dist/parsers/validate-attachments.d.ts +14 -0
  55. package/dist/parsers/validate-attachments.js +61 -0
  56. package/dist/parsers/validate-attachments.js.map +1 -0
  57. package/dist/parsers/xlsx-parser.d.ts +2 -0
  58. package/dist/parsers/xlsx-parser.js +75 -0
  59. package/dist/parsers/xlsx-parser.js.map +1 -0
  60. package/dist/planned-tasks/planned-task-permissions.d.ts +2 -0
  61. package/dist/planned-tasks/planned-task-permissions.js +8 -2
  62. package/dist/planned-tasks/planned-task-permissions.js.map +1 -1
  63. package/dist/planned-tasks/planned-task-service.d.ts +14 -1
  64. package/dist/planned-tasks/planned-task-service.js +138 -2
  65. package/dist/planned-tasks/planned-task-service.js.map +1 -1
  66. package/dist/runtime/background-task-manager.d.ts +32 -1
  67. package/dist/runtime/background-task-manager.js +134 -4
  68. package/dist/runtime/background-task-manager.js.map +1 -1
  69. package/dist/runtime/builder-sandbox-session-registry.d.ts +45 -0
  70. package/dist/runtime/builder-sandbox-session-registry.js +159 -0
  71. package/dist/runtime/builder-sandbox-session-registry.js.map +1 -0
  72. package/dist/runtime/liveness-policy.d.ts +40 -0
  73. package/dist/runtime/liveness-policy.js +74 -0
  74. package/dist/runtime/liveness-policy.js.map +1 -0
  75. package/dist/runtime/resumable-stream-executor.d.ts +1 -0
  76. package/dist/runtime/resumable-stream-executor.js +1 -0
  77. package/dist/runtime/resumable-stream-executor.js.map +1 -1
  78. package/dist/runtime/run-state-registry.d.ts +21 -5
  79. package/dist/runtime/run-state-registry.js +109 -7
  80. package/dist/runtime/run-state-registry.js.map +1 -1
  81. package/dist/runtime/stream-runner.d.ts +3 -0
  82. package/dist/runtime/stream-runner.js +3 -0
  83. package/dist/runtime/stream-runner.js.map +1 -1
  84. package/dist/runtime/terminal-response-guard.d.ts +30 -0
  85. package/dist/runtime/terminal-response-guard.js +149 -0
  86. package/dist/runtime/terminal-response-guard.js.map +1 -0
  87. package/dist/storage/agent-tree-snapshot.d.ts +2 -0
  88. package/dist/storage/index.d.ts +2 -0
  89. package/dist/storage/index.js +3 -1
  90. package/dist/storage/index.js.map +1 -1
  91. package/dist/storage/planned-task-storage.js +2 -1
  92. package/dist/storage/planned-task-storage.js.map +1 -1
  93. package/dist/storage/terminal-outcome-storage.d.ts +48 -0
  94. package/dist/storage/terminal-outcome-storage.js +84 -0
  95. package/dist/storage/terminal-outcome-storage.js.map +1 -0
  96. package/dist/storage/workflow-loop-storage.d.ts +442 -16
  97. package/dist/stream/consume-with-hitl.d.ts +2 -0
  98. package/dist/stream/consume-with-hitl.js +2 -0
  99. package/dist/stream/consume-with-hitl.js.map +1 -1
  100. package/dist/stream/map-chunk.js +6 -0
  101. package/dist/stream/map-chunk.js.map +1 -1
  102. package/dist/tools/attachments/parse-file.tool.d.ts +46 -34
  103. package/dist/tools/attachments/parse-file.tool.js +115 -56
  104. package/dist/tools/attachments/parse-file.tool.js.map +1 -1
  105. package/dist/tools/credentials.tool.d.ts +120 -1
  106. package/dist/tools/credentials.tool.js +65 -12
  107. package/dist/tools/credentials.tool.js.map +1 -1
  108. package/dist/tools/data-tables.tool.d.ts +1 -0
  109. package/dist/tools/data-tables.tool.js +64 -24
  110. package/dist/tools/data-tables.tool.js.map +1 -1
  111. package/dist/tools/executions.tool.js +4 -1
  112. package/dist/tools/executions.tool.js.map +1 -1
  113. package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +2 -1
  114. package/dist/tools/filesystem/create-tools-from-mcp-server.js +74 -5
  115. package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
  116. package/dist/tools/index.d.ts +4 -24
  117. package/dist/tools/index.js +23 -7
  118. package/dist/tools/index.js.map +1 -1
  119. package/dist/tools/nodes.tool.js +15 -15
  120. package/dist/tools/nodes.tool.js.map +1 -1
  121. package/dist/tools/orchestration/add-plan-item.tool.js +3 -1
  122. package/dist/tools/orchestration/add-plan-item.tool.js.map +1 -1
  123. package/dist/tools/orchestration/blueprint-accumulator.d.ts +4 -1
  124. package/dist/tools/orchestration/blueprint-accumulator.js +28 -0
  125. package/dist/tools/orchestration/blueprint-accumulator.js.map +1 -1
  126. package/dist/tools/orchestration/blueprint.schema.d.ts +61 -16
  127. package/dist/tools/orchestration/blueprint.schema.js +15 -1
  128. package/dist/tools/orchestration/blueprint.schema.js.map +1 -1
  129. package/dist/tools/orchestration/browser-credential-setup.nudge.d.ts +5 -0
  130. package/dist/tools/orchestration/browser-credential-setup.nudge.js +11 -0
  131. package/dist/tools/orchestration/browser-credential-setup.nudge.js.map +1 -0
  132. package/dist/tools/orchestration/browser-credential-setup.prompt.js +2 -1
  133. package/dist/tools/orchestration/browser-credential-setup.prompt.js.map +1 -1
  134. package/dist/tools/orchestration/browser-credential-setup.tool.js +55 -7
  135. package/dist/tools/orchestration/browser-credential-setup.tool.js.map +1 -1
  136. package/dist/tools/orchestration/build-workflow-agent.prompt.js +86 -60
  137. package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -1
  138. package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +56 -3
  139. package/dist/tools/orchestration/build-workflow-agent.tool.js +1020 -300
  140. package/dist/tools/orchestration/build-workflow-agent.tool.js.map +1 -1
  141. package/dist/tools/orchestration/builder-memory-compaction.d.ts +38 -0
  142. package/dist/tools/orchestration/builder-memory-compaction.js +146 -0
  143. package/dist/tools/orchestration/builder-memory-compaction.js.map +1 -0
  144. package/dist/tools/orchestration/complete-checkpoint.tool.d.ts +2 -0
  145. package/dist/tools/orchestration/complete-checkpoint.tool.js +76 -0
  146. package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -0
  147. package/dist/tools/orchestration/data-table-agent.tool.js +34 -17
  148. package/dist/tools/orchestration/data-table-agent.tool.js.map +1 -1
  149. package/dist/tools/orchestration/delegate.tool.js +34 -16
  150. package/dist/tools/orchestration/delegate.tool.js.map +1 -1
  151. package/dist/tools/orchestration/plan-agent-prompt.d.ts +1 -1
  152. package/dist/tools/orchestration/plan-agent-prompt.js +7 -0
  153. package/dist/tools/orchestration/plan-agent-prompt.js.map +1 -1
  154. package/dist/tools/orchestration/plan-with-agent.tool.d.ts +23 -0
  155. package/dist/tools/orchestration/plan-with-agent.tool.js +314 -13
  156. package/dist/tools/orchestration/plan-with-agent.tool.js.map +1 -1
  157. package/dist/tools/orchestration/plan.tool.js +17 -1
  158. package/dist/tools/orchestration/plan.tool.js.map +1 -1
  159. package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +40 -2
  160. package/dist/tools/orchestration/report-verification-verdict.tool.js +85 -6
  161. package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
  162. package/dist/tools/orchestration/research-with-agent.tool.js +33 -16
  163. package/dist/tools/orchestration/research-with-agent.tool.js.map +1 -1
  164. package/dist/tools/orchestration/tracing-utils.js +8 -0
  165. package/dist/tools/orchestration/tracing-utils.js.map +1 -1
  166. package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +8 -2
  167. package/dist/tools/orchestration/verify-built-workflow.tool.js +476 -6
  168. package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
  169. package/dist/tools/research.tool.js +56 -10
  170. package/dist/tools/research.tool.js.map +1 -1
  171. package/dist/tools/shared/ask-user.tool.d.ts +1 -0
  172. package/dist/tools/shared/ask-user.tool.js +3 -2
  173. package/dist/tools/shared/ask-user.tool.js.map +1 -1
  174. package/dist/tools/templates.tool.js +5 -90
  175. package/dist/tools/templates.tool.js.map +1 -1
  176. package/dist/tools/web-research/sanitize-web-content.d.ts +0 -1
  177. package/dist/tools/web-research/sanitize-web-content.js +0 -9
  178. package/dist/tools/web-research/sanitize-web-content.js.map +1 -1
  179. package/dist/tools/workflows/apply-workflow-credentials.tool.d.ts +2 -2
  180. package/dist/tools/workflows/build-workflow.tool.d.ts +2 -2
  181. package/dist/tools/workflows/build-workflow.tool.js +6 -4
  182. package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
  183. package/dist/tools/workflows/materialize-node-type.tool.d.ts +8 -8
  184. package/dist/tools/workflows/resolve-credentials.d.ts +9 -4
  185. package/dist/tools/workflows/resolve-credentials.js +59 -27
  186. package/dist/tools/workflows/resolve-credentials.js.map +1 -1
  187. package/dist/tools/workflows/setup-workflow.schema.d.ts +40 -0
  188. package/dist/tools/workflows/setup-workflow.service.d.ts +5 -1
  189. package/dist/tools/workflows/setup-workflow.service.js +71 -5
  190. package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
  191. package/dist/tools/workflows/submit-workflow-identity.d.ts +25 -3
  192. package/dist/tools/workflows/submit-workflow-identity.js +92 -5
  193. package/dist/tools/workflows/submit-workflow-identity.js.map +1 -1
  194. package/dist/tools/workflows/submit-workflow.tool.d.ts +60 -6
  195. package/dist/tools/workflows/submit-workflow.tool.js +102 -19
  196. package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
  197. package/dist/tools/workflows/workflow-json-utils.d.ts +4 -0
  198. package/dist/tools/workflows/workflow-json-utils.js +54 -0
  199. package/dist/tools/workflows/workflow-json-utils.js.map +1 -0
  200. package/dist/tools/workflows.tool.d.ts +7 -1
  201. package/dist/tools/workflows.tool.js +283 -54
  202. package/dist/tools/workflows.tool.js.map +1 -1
  203. package/dist/tracing/langsmith-tracing.d.ts +2 -0
  204. package/dist/tracing/langsmith-tracing.js +12 -3
  205. package/dist/tracing/langsmith-tracing.js.map +1 -1
  206. package/dist/tracing/trace-replay.d.ts +3 -0
  207. package/dist/tracing/trace-replay.js +65 -0
  208. package/dist/tracing/trace-replay.js.map +1 -1
  209. package/dist/types.d.ts +92 -16
  210. package/dist/workflow-builder/parse-validate.d.ts +5 -1
  211. package/dist/workflow-builder/parse-validate.js +5 -4
  212. package/dist/workflow-builder/parse-validate.js.map +1 -1
  213. package/dist/workflow-loop/guidance.js +8 -2
  214. package/dist/workflow-loop/guidance.js.map +1 -1
  215. package/dist/workflow-loop/index.d.ts +3 -2
  216. package/dist/workflow-loop/index.js +11 -1
  217. package/dist/workflow-loop/index.js.map +1 -1
  218. package/dist/workflow-loop/remediation.d.ts +13 -0
  219. package/dist/workflow-loop/remediation.js +36 -0
  220. package/dist/workflow-loop/remediation.js.map +1 -0
  221. package/dist/workflow-loop/runtime.js +7 -0
  222. package/dist/workflow-loop/runtime.js.map +1 -1
  223. package/dist/workflow-loop/workflow-loop-controller.d.ts +1 -1
  224. package/dist/workflow-loop/workflow-loop-controller.js +196 -29
  225. package/dist/workflow-loop/workflow-loop-controller.js.map +1 -1
  226. package/dist/workflow-loop/workflow-loop-state.d.ts +500 -10
  227. package/dist/workflow-loop/workflow-loop-state.js +74 -1
  228. package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
  229. package/dist/workflow-loop/workflow-task-service.d.ts +2 -1
  230. package/dist/workflow-loop/workflow-task-service.js +4 -0
  231. package/dist/workflow-loop/workflow-task-service.js.map +1 -1
  232. package/dist/workspace/builder-sandbox-factory.d.ts +3 -4
  233. package/dist/workspace/builder-sandbox-factory.js +74 -35
  234. package/dist/workspace/builder-sandbox-factory.js.map +1 -1
  235. package/dist/workspace/create-workspace.d.ts +2 -0
  236. package/dist/workspace/create-workspace.js.map +1 -1
  237. package/dist/workspace/n8n-sandbox-filesystem.js +2 -2
  238. package/dist/workspace/n8n-sandbox-filesystem.js.map +1 -1
  239. package/dist/workspace/n8n-sandbox-sandbox.d.ts +2 -3
  240. package/dist/workspace/n8n-sandbox-sandbox.js +3 -7
  241. package/dist/workspace/n8n-sandbox-sandbox.js.map +1 -1
  242. package/dist/workspace/sandbox-setup.d.ts +1 -1
  243. package/dist/workspace/sandbox-setup.js +41 -16
  244. package/dist/workspace/sandbox-setup.js.map +1 -1
  245. package/dist/workspace/snapshot-manager.d.ts +14 -2
  246. package/dist/workspace/snapshot-manager.js +57 -1
  247. package/dist/workspace/snapshot-manager.js.map +1 -1
  248. package/package.json +35 -10
  249. package/dist/tools/templates/template-api.d.ts +0 -21
  250. package/dist/tools/templates/template-api.js +0 -104
  251. package/dist/tools/templates/template-api.js.map +0 -1
  252. package/dist/tools/templates/types.d.ts +0 -52
  253. package/dist/tools/templates/types.js +0 -37
  254. package/dist/tools/templates/types.js.map +0 -1
  255. package/dist/tools/utils/mermaid.utils.d.ts +0 -15
  256. package/dist/tools/utils/mermaid.utils.js +0 -622
  257. package/dist/tools/utils/mermaid.utils.js.map +0 -1
  258. package/dist/tools/utils/node-configuration.utils.d.ts +0 -6
  259. package/dist/tools/utils/node-configuration.utils.js +0 -77
  260. package/dist/tools/utils/node-configuration.utils.js.map +0 -1
  261. package/dist/workspace/n8n-sandbox-client.d.ts +0 -105
  262. package/dist/workspace/n8n-sandbox-client.js +0 -335
  263. package/dist/workspace/n8n-sandbox-client.js.map +0 -1
  264. package/dist/workspace/n8n-sandbox-image-manager.d.ts +0 -5
  265. package/dist/workspace/n8n-sandbox-image-manager.js +0 -25
  266. package/dist/workspace/n8n-sandbox-image-manager.js.map +0 -1
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BUILDER_AGENT_PROMPT = void 0;
4
4
  exports.createSandboxBuilderAgentPrompt = createSandboxBuilderAgentPrompt;
5
- const parameter_guides_1 = require("@n8n/workflow-sdk/prompts/node-guidance/parameter-guides");
6
5
  const node_selection_1 = require("@n8n/workflow-sdk/prompts/node-selection");
7
6
  const sdk_reference_1 = require("@n8n/workflow-sdk/prompts/sdk-reference");
8
7
  const shared_prompts_1 = require("../../agent/shared-prompts");
@@ -33,11 +32,14 @@ const SDK_CODE_RULES = `## SDK Code Rules
33
32
  - Use \`expr('{{ $json.field }}')\` for n8n expressions. Variables MUST be inside \`{{ }}\`.
34
33
  - Do NOT use \`as const\` assertions — the workflow parser only supports JavaScript syntax, not TypeScript-only features. Just use plain string literals.
35
34
  - Use string values directly for discriminator fields like \`resource\` and \`operation\` (e.g., \`resource: 'message'\` not \`resource: 'message' as const\`).
36
- - When editing a pre-loaded workflow, **remove \`position\` arrays** from node configs — they are auto-calculated.
37
- - **No em-dash (\`—\`) or other special Unicode characters in node names or string values.** Use plain hyphen (\`-\`) instead. The SDK parser cannot handle em-dashes.
38
- - **IF node combinator** must be \`'and'\` or \`'or'\` (not \`'any'\` or \`'all'\`).`;
39
- function buildBuilderSpecificPatterns(mode) {
40
- const openAiCredExample = mode === 'sandbox' ? "{ id: 'credId', name: 'OpenAI account' }" : "newCredential('OpenAI')";
35
+ - When editing a pre-loaded workflow, **remove \`position\` arrays** from node configs — they are auto-calculated.`;
36
+ const NODE_CONFIGURATION_SAFETY_RULES = `## Node Configuration Safety Rules
37
+
38
+ - Fetch \`nodes(action="type-definition")\` before configuring nodes. Generated definitions and \`@builderHint\` annotations are the source of truth.
39
+ - Use live \`nodes(action="explore-resources")\` for resource locator, list, and model fields when credentials are available.
40
+ - If a configuration is unclear after reading the definition, ask for clarification or use placeholders — do not guess.`;
41
+ function buildBuilderSpecificPatterns() {
42
+ const openAiCredExample = "newCredential('OpenAI')";
41
43
  return `## Critical Patterns (Common Mistakes)
42
44
 
43
45
  **Pay attention to @builderHint annotations in search results and type definitions** — these provide critical guidance on how to correctly configure node parameters. Write them out as notes when reviewing — they prevent common configuration mistakes.
@@ -53,6 +55,16 @@ After writing any workflow with IF, Switch, or Filter nodes, verify:
53
55
 
54
56
  ### AI Agent with Subnodes — use factory functions in subnodes config
55
57
  \`\`\`javascript
58
+ const chatTrigger = trigger({
59
+ type: '@n8n/n8n-nodes-langchain.chatTrigger',
60
+ version: 1.3,
61
+ config: {
62
+ name: 'Chat Trigger',
63
+ parameters: { public: false },
64
+ output: [{ sessionId: 'chat-session-id', chatInput: 'Hello' }]
65
+ }
66
+ });
67
+
56
68
  const model = languageModel({
57
69
  type: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
58
70
  version: 1.3,
@@ -75,6 +87,19 @@ const parser = outputParser({
75
87
  }
76
88
  });
77
89
 
90
+ const memoryNode = memory({
91
+ type: '@n8n/n8n-nodes-langchain.memoryBufferWindow',
92
+ version: 1.3,
93
+ config: {
94
+ name: 'Conversation Memory',
95
+ parameters: {
96
+ sessionIdType: 'customKey',
97
+ sessionKey: nodeJson(chatTrigger, 'sessionId'),
98
+ contextWindowLength: 10
99
+ }
100
+ }
101
+ });
102
+
78
103
  const agent = node({
79
104
  type: '@n8n/n8n-nodes-langchain.agent',
80
105
  version: 3.1,
@@ -86,11 +111,12 @@ const agent = node({
86
111
  hasOutputParser: true,
87
112
  options: { systemMessage: 'You are an expert...' }
88
113
  },
89
- subnodes: { model: model, outputParser: parser }
114
+ subnodes: { model: model, memory: memoryNode, outputParser: parser }
90
115
  }
91
116
  });
92
117
  \`\`\`
93
118
  WRONG: \`.to(agent, { connectionType: 'ai_languageModel' })\` — subnodes MUST be in the config object.
119
+ For values inside AI subnodes, use explicit references such as \`nodeJson(triggerNode, 'sessionId')\` instead of \`$json.sessionId\`. For Chat Trigger memory specifically, \`sessionIdType: 'fromInput'\` is also valid.
94
120
 
95
121
  ### Code Node
96
122
  \`\`\`javascript
@@ -192,10 +218,6 @@ export default workflow('id', 'name')
192
218
  .add(scheduleTrigger).to(processNode);
193
219
  \`\`\`
194
220
 
195
- ### Web App (SPA served from a webhook)
196
-
197
- When the workflow serves HTML from a webhook (dashboards, admin UIs, custom forms), call \`templates(action="best-practices", technique="web_app")\` for the full file-based HTML pattern, data-injection recipe, multi-route architecture, and a complete multi-route dashboard example. Embedding large HTML inline in Code nodes breaks at ~20KB — always use the file-based pattern from the guide.
198
-
199
221
  ### Google Sheets — documentId and sheetName (RLC fields)
200
222
 
201
223
  These are Resource Locator fields that require the \`__rl\` object format:
@@ -224,50 +246,43 @@ ${node_selection_1.CONNECTION_CHANGING_PARAMETERS}
224
246
  ### Baseline Flow Control Nodes
225
247
  ${node_selection_1.BASELINE_FLOW_CONTROL}`;
226
248
  }
227
- const BUILDER_SPECIFIC_PATTERNS_TOOL = buildBuilderSpecificPatterns('tool');
228
- const BUILDER_SPECIFIC_PATTERNS_SANDBOX = buildBuilderSpecificPatterns('sandbox');
249
+ const BUILDER_SPECIFIC_PATTERNS = buildBuilderSpecificPatterns();
229
250
  const SANDBOX_WORKFLOW_RULES = `Follow these rules strictly when generating workflows:
230
251
 
231
- 1. **Always use raw credential objects from \`credentials(action="list")\`**
232
- - Wire credentials as \`{ id, name }\` objects returned by \`credentials(action="list")\`
233
- - NEVER use placeholder strings, fake API keys, or hardcoded auth values
234
- - Example: \`credentials: { slackApi: { id: 'yXYBqho73obh58ZS', name: 'Slack Bot' } }\`
252
+ 1. **Use \`newCredential()\` for authentication**
253
+ - If the user selected a specific credential or an existing workflow already has one, wire it as \`newCredential('Credential Name', 'credential-id')\` using the exact ID from \`credentials(action="list")\` or the pre-loaded workflow
254
+ - If no exact credential was selected, more than one credential matches, or the service needs a new credential, wire \`newCredential('Suggested Credential Name')\`; \`submit-workflow\` will mock it for verification and the orchestrator will route setup after the build
255
+ - NEVER invent credential IDs, placeholder strings, fake API keys, or hardcoded auth values
256
+ - Example: \`credentials: { slackApi: newCredential('Slack Bot') }\`
235
257
  - The key (e.g. \`slackApi\`) is the credential **type** from the node type definition
236
258
 
237
- 2. **Handle empty outputs with \`alwaysOutputData: true\`**
238
- - Nodes that query data (Data Table get, Google Sheets lookup, HTTP Request, etc.) may return 0 items
239
- - When a node returns 0 items, all downstream nodes are SKIPPED the workflow chain breaks silently
240
- - Set \`alwaysOutputData: true\` on any node whose output feeds downstream nodes and might return empty results
241
- - Common cases: fresh/empty Data Tables, filtered queries, conditional lookups, API searches with no matches
242
- - Example: \`config: { ..., alwaysOutputData: true }\`
259
+ 2. **Trust empty item lists don't synthesize fake items**
260
+ - When a query returns 0 items, downstream nodes simply don't run for that execution. For scheduled or polling triggers this is the correct "nothing to do this round" signal — the next run will execute normally when data appears.
261
+ - DO NOT add \`alwaysOutputData: true\` just to "keep the chain alive." Forcing an empty \`{}\` item downstream is what causes \`undefined\` reads, failed HTTP calls to \`GET undefined\`, and Code-node crashes on missing fields.
262
+ - DO NOT add an IF gate before a loop to check "has items?" — loops (\`splitInBatches\`, per-item nodes, \`filter\`) already no-op on empty input. The gate is redundant and adds a failure surface.
263
+ - \`alwaysOutputData: true\` is only correct when you specifically need a downstream branch to run on the "empty" case e.g. a dedicated "no matches found" notification path. In that case, pair it with an \`IF\` that explicitly checks for the empty case and routes accordingly. Never use it as a default.
264
+ - To drop invalid items mid-pipeline, use a \`filter\` node. A \`filter\` that rejects everything emits 0 items and the chain correctly stops — no \`IF\` + \`splitInBatches\` composition needed.
243
265
 
244
266
  3. **Use \`executeOnce: true\` for single-execution nodes**
245
267
  - When a node receives N items but should only execute once (not N times), set \`executeOnce: true\`
246
268
  - Common cases: sending a summary notification, generating a report, calling an API that doesn't need per-item execution
247
- - Example: \`config: { ..., executeOnce: true }\``;
269
+ - Example: \`config: { ..., executeOnce: true }\`
270
+
271
+ 4. **Pick the right control-flow primitive**
272
+ - **Per-item loop with side effects (fetch, embed, write)** → \`splitInBatches\` with \`batchSize: 1\` feeding the per-item work, loop back via \`nextBatch\`. No \`IF\` gate before it.
273
+ - **Drop items that don't match a predicate** → \`filter\`. It emits 0 items when nothing matches, and the chain stops cleanly.
274
+ - **Two mutually exclusive paths that both do real work** → \`IF\` (\`onTrue\` / \`onFalse\`).
275
+ - **Many mutually exclusive paths keyed off a value** → \`switch\` (\`onCase\`).
276
+ - Nested control flow is supported: \`ifNode.onTrue(loopBuilder)\`, \`switchNode.onCase(0, loopBuilder)\`, and \`splitInBatches(sib).onEachBatch(ifElseBuilder)\` all compile and wire correctly. Use them when the semantics genuinely call for it, not as a workaround for empty-list handling.`;
248
277
  function composeSdkRulesAndPatterns(mode) {
249
- const sandboxOverride = mode === 'sandbox'
250
- ? "> **Sandbox credential override**: The SDK pattern examples below use `newCredential('X')`. " +
251
- "In sandbox mode, replace every `newCredential('X')` with the raw `{ id, name }` object from " +
252
- '`credentials(action="list")`. `newCredential()` serializes to `undefined` in sandbox and will ' +
253
- 'silently drop credentials from the saved workflow.'
254
- : null;
255
278
  return [
256
279
  SDK_CODE_RULES,
257
280
  mode === 'sandbox' ? SANDBOX_WORKFLOW_RULES : sdk_reference_1.WORKFLOW_RULES,
258
- ...(sandboxOverride ? [sandboxOverride] : []),
259
281
  '## SDK Patterns Reference\n\n' + sdk_reference_1.WORKFLOW_SDK_PATTERNS,
260
282
  '## Expression Reference\n\n' + sdk_reference_1.EXPRESSION_REFERENCE,
261
283
  '## Additional Functions\n\n' + sdk_reference_1.ADDITIONAL_FUNCTIONS,
262
- '## Node-Specific Configuration Guides',
263
- parameter_guides_1.IF_NODE_GUIDE.content,
264
- parameter_guides_1.SWITCH_NODE_GUIDE.content,
265
- parameter_guides_1.SET_NODE_GUIDE.content,
266
- parameter_guides_1.HTTP_REQUEST_GUIDE.content,
267
- parameter_guides_1.TOOL_NODES_GUIDE.content,
268
- parameter_guides_1.EMBEDDING_NODES_GUIDE.content,
269
- parameter_guides_1.RESOURCE_LOCATOR_GUIDE.content,
270
- mode === 'sandbox' ? BUILDER_SPECIFIC_PATTERNS_SANDBOX : BUILDER_SPECIFIC_PATTERNS_TOOL,
284
+ NODE_CONFIGURATION_SAFETY_RULES,
285
+ BUILDER_SPECIFIC_PATTERNS,
271
286
  ].join('\n\n');
272
287
  }
273
288
  const SDK_RULES_AND_PATTERNS_TOOL = composeSdkRulesAndPatterns('tool');
@@ -294,10 +309,11 @@ ${shared_prompts_1.PLACEHOLDERS_RULE}
294
309
  Do NOT produce visible output until step 5. All reasoning happens internally.
295
310
 
296
311
  ## Credential Rules (tool mode)
297
- - Always use \`newCredential('Credential Name')\` for credentials, never fake keys or placeholders.
298
- - NEVER use raw credential objects like \`{ id: '...', name: '...' }\` that form is for sandbox mode only.
312
+ - Use \`newCredential('Credential Name', 'credential-id')\` only when the user selected a specific existing credential or the workflow already has one.
313
+ - If no exact credential was selected, more than one credential matches, or the service needs a new credential, use \`newCredential('Suggested Credential Name')\`; the build tools mock unresolved credentials for verification.
314
+ - NEVER use raw credential objects like \`{ id: '...', name: '...' }\` in tool mode.
299
315
  - When editing a pre-loaded workflow, the roundtripped code may have credentials as raw objects — replace them with \`newCredential()\` calls.
300
- - Unresolved credentials (where the user chose mock data or no credential is available) will be automatically mocked via pinned data at submit time. Always declare \`output\` on nodes that use credentials so mock data is available. The workflow will be testable via manual/test runs but not production-ready until real credentials are added.
316
+ - Unresolved credentials (where the user chose mock data, no credential is available, or no explicit selection was made) will be automatically mocked via pinned data at submit time. Always declare \`output\` on nodes that use credentials so mock data is available. The workflow will be testable via manual/test runs but not production-ready until real credentials are added.
301
317
 
302
318
  ${SDK_RULES_AND_PATTERNS_TOOL}
303
319
  `;
@@ -408,7 +424,7 @@ Supported input types: \`string\`, \`number\`, \`boolean\`, \`array\`, \`object\
408
424
  ### Step 2: Submit and test the chunk
409
425
 
410
426
  1. Write the chunk file, then submit it: \`submit-workflow\` with the chunk file path.
411
- - Sub-workflows with \`executeWorkflowTrigger\` can be tested immediately via \`executions(action="run")\` without publishing. However, they must be **published** via \`workflows(action="publish")\` before the parent workflow can call them in production (trigger-based) executions.
427
+ - Sub-workflows with \`executeWorkflowTrigger\` can be tested immediately via \`executions(action="run")\`.
412
428
  2. Run the chunk: \`executions(action="run")\` with \`inputData\` matching the trigger schema.
413
429
  - **Webhook workflows**: \`inputData\` IS the request body — do NOT wrap it in \`{ body: ... }\`. The system automatically places \`inputData\` into \`{ headers, query, body: inputData }\`. So to test a webhook expecting \`{ title: "Hello" }\`, pass \`inputData: { title: "Hello" }\`. Inside the workflow, the data arrives at \`$json.body.title\`.
414
430
  - **Event-based triggers** (e.g. Linear Trigger, GitHub Trigger, Slack Trigger): pass \`inputData\` matching what the trigger would normally emit. The system injects it as the trigger node's output — e.g. \`inputData: { action: "create", data: { id: "123", title: "Test issue" } }\` for a Linear Trigger. No need to rebuild the workflow with a Manual Trigger.
@@ -461,14 +477,13 @@ Replace \`CHUNK_WORKFLOW_ID\` with the actual ID returned by \`submit-workflow\`
461
477
 
462
478
  ${shared_prompts_1.PLACEHOLDERS_RULE}
463
479
 
464
- ## Setup Workflows (Create Missing Resources)
480
+ ## Missing Resources
465
481
 
466
482
  When \`nodes(action="explore-resources")\` returns no results for a required resource:
467
483
 
468
- 1. Use \`nodes(action="search")\` and \`nodes(action="type-definition")\` to find the "create" operation for that resource type
469
- 2. Build a one-shot setup workflow in \`chunks/setup-<resource>.ts\` using a manual trigger + the create node
470
- 3. Submit and run it extract the created resource ID from the execution result
471
- 4. Use that real resource ID in the main workflow
484
+ 1. If the resource can be represented as a user choice, use \`placeholder('Select <resource>')\` and let the setup flow collect it after the build
485
+ 2. If the user explicitly asked you to create the resource and the node type definition has a safe create operation, build and verify that resource-creation workflow as part of the requested work
486
+ 3. Otherwise, leave the main workflow as a saved draft and mention the missing resource in the one-line completion summary
472
487
 
473
488
  **For resources that can't be created via n8n** (e.g., Slack channels, external API resources), explain clearly in your summary what the user needs to create manually and what ID to put where.
474
489
 
@@ -486,7 +501,7 @@ ${shared_prompts_1.ASK_USER_FALLBACK}
486
501
  - You CANNOT find or use n8n API keys — they do not exist in the sandbox environment
487
502
  - Do NOT spend time searching for API keys, config files, environment variables, or process info — none of it is accessible
488
503
 
489
- **All interaction with n8n is through the provided tools:** \`submit-workflow\`, \`executions(action="run" | "debug" | "get")\`, \`credentials(action="list" | "test")\`, \`nodes(action="explore-resources")\`, \`workflows(action="publish" | "unpublish")\`, \`data-tables(action="list" | "create" | "schema")\`, etc. These tools communicate with n8n internally — no HTTP required.
504
+ **All interaction with n8n is through the provided tools:** \`submit-workflow\`, \`executions(action="run" | "debug" | "get")\`, \`credentials(action="list" | "get" | "search-types" | "test")\`, \`nodes(action="explore-resources")\`, \`workflows(action="list" | "get" | "get-as-code")\`, \`data-tables(action="list" | "create" | "schema")\`, etc. These tools communicate with n8n internally — no HTTP required.
490
505
 
491
506
  ## Sandbox-Specific Rules
492
507
 
@@ -496,18 +511,30 @@ ${shared_prompts_1.ASK_USER_FALLBACK}
496
511
 
497
512
  ## Credentials (sandbox mode)
498
513
 
499
- Sandbox mode uses **raw credential objects** (not \`newCredential()\`). Call \`credentials(action="list")\` early. Each credential has an \`id\`, \`name\`, and \`type\`. Wire them into nodes like this:
514
+ Sandbox mode uses \`newCredential()\` for authentication. Call \`credentials(action="list")\` early. Each credential has an \`id\`, \`name\`, and \`type\`. Wire selected existing credentials into nodes like this:
500
515
 
501
516
  \`\`\`typescript
502
517
  credentials: {
503
- openWeatherMapApi: { id: 'yXYBqho73obh58ZS', name: 'OpenWeatherMap account' }
518
+ openWeatherMapApi: newCredential('OpenWeatherMap account', 'yXYBqho73obh58ZS')
504
519
  }
505
520
  \`\`\`
506
521
 
507
- The key (\`openWeatherMapApi\`) is the credential **type** from the node type definition. The \`id\` and \`name\` come from \`credentials(action="list")\`.
522
+ For credentials that are not selected yet, keep the credential type key and omit the ID:
523
+
524
+ \`\`\`typescript
525
+ credentials: {
526
+ openWeatherMapApi: newCredential('OpenWeatherMap account')
527
+ }
528
+ \`\`\`
529
+
530
+ The key (\`openWeatherMapApi\`) is the credential **type** from the node type definition. Exact IDs and names come from \`credentials(action="list")\`.
531
+
532
+ Use the two-argument form only when the user selected the credential, there is exactly one matching credential, or you are preserving a credential already present on an existing workflow. If no exact credential was selected, more than one credential matches, or the service needs a new credential, use \`newCredential('Suggested Credential Name')\`; \`submit-workflow\` mocks it for verification and the orchestrator handles setup after the build.
508
533
 
509
534
  If the required credential type is not in \`credentials(action="list")\` results, call \`credentials(action="search-types")\` with the service name (e.g. "linear", "notion") to discover available dedicated credential types. Always prefer dedicated types over generic auth (\`httpHeaderAuth\`, \`httpBearerAuth\`, etc.). When generic auth is truly needed (no dedicated type exists), prefer \`httpBearerAuth\` over \`httpHeaderAuth\`.
510
535
 
536
+ The credential-selection guidance above applies to outbound service calls. For inbound trigger nodes such as Webhook, Form Trigger, Chat Trigger, and MCP Trigger, keep authentication at its default \`none\` unless the user explicitly asks to authenticate inbound traffic.
537
+
511
538
  ## Data Tables
512
539
 
513
540
  n8n normalizes column names to snake_case (e.g., \`dayName\` → \`day_name\`). Always call \`data-tables(action="schema")\` before using a data table in workflow code to get the real column names.
@@ -518,13 +545,12 @@ n8n normalizes column names to snake_case (e.g., \`dayName\` → \`day_name\`).
518
545
  - **Complex workflows (5+ nodes, 2+ integrations) MUST use the Compositional Workflow Pattern.** Decompose into sub-workflows, test each independently, then compose. Do NOT write everything in a single workflow.
519
546
  - **If you edit code after submitting, you MUST call \`submit-workflow\` again before doing anything else (verify, run, or finish).** The system tracks file hashes — if the file changed since the last submit, your work is discarded. The sequence is always: edit → submit → then verify/run/finish.
520
547
  - **Follow the runtime verification instructions in your briefing.** If the briefing says verification is required, do not stop after a successful submit.
521
- - **Do NOT call \`workflows(action="publish")\`.** Publishing is the user's decision after they have tested the workflow. Your job ends at a successful submit.
522
548
 
523
549
  ## Mandatory Process
524
550
 
525
551
  ### For simple workflows (< 5 nodes, single integration):
526
552
 
527
- 1. **Discover credentials**: Call \`credentials(action="list")\`. Note each credential's \`id\`, \`name\`, and \`type\`. You'll wire these into nodes as \`credentials: { credType: { id, name } }\`. If a required credential doesn't exist, mention it in your summary.
553
+ 1. **Discover credentials**: Call \`credentials(action="list")\`. Note each credential's \`id\`, \`name\`, and \`type\`. Use \`newCredential('Name', 'id')\` only for an explicitly selected, exactly matched, or existing workflow credential. For unresolved credentials, use \`newCredential('Suggested Name')\`; \`submit-workflow\` records the mocked credential and the orchestrator routes to setup after verification.
528
554
 
529
555
  2. **Discover nodes**:
530
556
  a. If the workflow fits a known category (notification, data_persistence, chatbot, scheduling, data_transformation, data_extraction, document_processing, form_input, content_generation, triage, scraping_and_research), call \`nodes(action="suggested")\` first — it returns curated node recommendations with pattern hints and configuration notes. **Pay attention to the notes** — they prevent common configuration mistakes.
@@ -540,11 +566,11 @@ n8n normalizes column names to snake_case (e.g., \`dayName\` → \`day_name\`).
540
566
  3. **Get node schemas**: Call \`nodes(action="type-definition")\` with ALL the node IDs you need in a single call (up to 5). For nodes with discriminators (from search results), include the \`resource\` and \`operation\` fields. **Read the definitions carefully** — they contain exact parameter names, types, required fields, valid enum values, credential types, displayOptions conditions, and \`@builderHint\` annotations with critical configuration guidance.
541
567
  **Important**: Only call \`nodes(action="type-definition")\` for nodes you will actually use in the workflow. Do not speculatively fetch definitions "just in case". If a definition returns empty or an error, do not retry — proceed with the information from \`nodes(action="search")\` results instead.
542
568
 
543
- 4. **Resolve real resource IDs**: Check the node schemas from step 3 for parameters with \`searchListMethod\` or \`loadOptionsMethod\`. For EACH one, call \`nodes(action="explore-resources")\` with the node type, method name, and the matching credential from step 1 to discover real resource IDs.
569
+ 4. **Resolve real resource IDs**: Check the node schemas from step 3 for parameters with \`searchListMethod\` or \`loadOptionsMethod\`. For EACH one, call \`nodes(action="explore-resources")\` with the node type, method name, and the matching explicit credential from step 1 to discover real resource IDs.
544
570
  - **This is mandatory for: calendars, spreadsheets, channels, folders, models, databases, and any other list-based parameter.** Do NOT assume values like "primary", "default", or "General" — always look up the real ID.
545
571
  - **LLM models in particular** (OpenAI, Anthropic, Groq, etc.): always call \`explore-resources\` with the node's \`@searchListMethod\` when a credential for that provider is attached. The live list reflects what the credential can actually access — free/cheap tiers are often limited (e.g. an OpenAI free-tier key may only return \`gpt-5-mini\`). Picking a model ID that the credential can't access produces a broken workflow. The list is sorted newest-first; use the \`@builderHint\` as selection guidance (e.g. "prefer the GPT-5.4 family") over the live results, not as a hard-coded pick.
546
572
  - Example: Google Calendar's \`calendar\` parameter uses \`searchListMethod: getCalendars\`. Call \`nodes(action="explore-resources")\` with \`methodName: "getCalendars"\` to get the actual calendar ID (e.g., "user@example.com"), not "primary".
547
- - **Never use \`placeholder()\` or fake IDs for discoverable resources.** Create them via a setup workflow instead (see "Setup Workflows" section). For user-provided values, follow the placeholder rules in "SDK Code Rules".
573
+ - **Never use fake IDs for discoverable resources.** Use \`placeholder()\` when the user needs to choose or create the resource after the build. For user-provided values, follow the placeholder rules in "SDK Code Rules".
548
574
  - **If \`explore-resources\` returns more than one match and the user did not name a specific one, use \`placeholder('Select <resource>')\` for that parameter** (e.g. \`placeholder('Select a calendar')\`, \`placeholder('Select a Slack channel')\`). Picking one silently is a guess; the setup wizard surfaces placeholders so the user can choose after the build. Only pick a single match without prompting.
549
575
  - If the resource can't be created via n8n (e.g., Slack channels), explain clearly in your summary what the user needs to set up.
550
576
 
@@ -569,16 +595,16 @@ Follow the **Compositional Workflow Pattern** above. The process becomes:
569
595
 
570
596
  1. **Discover credentials** (same as above).
571
597
  2. **Discover nodes and get schemas** (same as above).
572
- 3. **Resolve real resource IDs** (same as above — call \`nodes(action="explore-resources")\` for EVERY parameter with \`searchListMethod\` or \`loadOptionsMethod\`). Never assume IDs like "primary" or "default". If a resource doesn't exist, build a setup workflow to create it.
598
+ 3. **Resolve real resource IDs** (same as above — call \`nodes(action="explore-resources")\` for EVERY parameter with \`searchListMethod\` or \`loadOptionsMethod\`). Never assume IDs like "primary" or "default". If a resource doesn't exist, use a placeholder unless the user explicitly asked you to create that resource.
573
599
  4. **Decompose** the workflow into logical chunks. Each chunk is a standalone sub-workflow with 2-4 nodes covering one capability (e.g., "fetch and format weather data", "generate AI recommendation", "store to data table").
574
600
  5. **For each chunk**:
575
601
  a. Write the chunk to \`${workspaceRoot}/chunks/<name>.ts\` with an \`executeWorkflowTrigger\` and explicit input schema.
576
602
  b. Run tsc.
577
- c. Submit the chunk: \`submit-workflow\` with \`filePath\` pointing to the chunk file. Test via \`executions(action="run")\` (no publish needed for manual runs).
603
+ c. Submit the chunk: \`submit-workflow\` with \`filePath\` pointing to the chunk file. Test via \`executions(action="run")\`.
578
604
  d. Fix if needed (max 2 submission fix attempts per chunk).
579
605
  6. **Write the main workflow** in \`${workspaceRoot}/src/workflow.ts\` that composes chunks via \`executeWorkflow\` nodes, referencing each chunk's workflow ID.
580
606
  7. **Submit** the main workflow.
581
- 8. **Done**: Output ONE sentence summarizing what was built, including the workflow ID and any known issues. Do NOT publish — the user will decide when to publish after testing.
607
+ 8. **Done**: Output ONE sentence summarizing what was built, including the workflow ID and any known issues.
582
608
 
583
609
  Do NOT produce visible output until the final step. All reasoning happens internally.
584
610
 
@@ -1 +1 @@
1
- {"version":3,"file":"build-workflow-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/build-workflow-agent.prompt.ts"],"names":[],"mappings":";;;AAqWA,0EA0SC;AAvoBD,+FAQkE;AAClE,6EAIkD;AAClD,2EAKiD;AAEjD,+DAAkF;AAIlF,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;0GAkBwE,CAAC;AAI3G,MAAM,cAAc,GAAG;;;;;;;;;;qFAU8D,CAAC;AAKtF,SAAS,4BAA4B,CAAC,IAAwB;IAC7D,MAAM,iBAAiB,GACtB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,yBAAyB,CAAC;IAC7F,OAAO;;;;;;;;;;;;;;;;;;;;;gCAqBwB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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iB;;;;;;;;;;;;;;;;EAgBjB,kCAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCAqEmB,aAAa;;;;;;;;;;;;;;kCAcjB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;6BAwBlB,aAAa;;;;sCAIJ,aAAa;;;;;;;yFAOsC,aAAa;;;;;;;;;;;;;;EAcpG,8BAA8B;CAC/B,CAAC;AACF,CAAC"}
@@ -1,18 +1,62 @@
1
1
  import { z } from 'zod';
2
- import type { BackgroundTaskResult, OrchestrationContext } from '../../types';
3
- import { type SubmitWorkflowAttempt } from '../workflows/submit-workflow.tool';
2
+ import type { OrchestrationContext } from '../../types';
3
+ import { type WorkflowBuildOutcome, type WorkflowSetupRequirement, type WorkflowVerificationReadiness, type WorkflowLoopState } from '../../workflow-loop';
4
+ import { type SubmitWorkflowAttempt, type SubmitWorkflowOutput } from '../workflows/submit-workflow.tool';
5
+ export declare function buildWarmBuilderFollowUp(input: {
6
+ task: string;
7
+ conversationContext?: string;
8
+ workflowId: string;
9
+ workItemId: string;
10
+ }): string;
4
11
  export declare function recordSuccessfulWorkflowBuilds(tool: unknown, onWorkflowId: (workflowId: string) => void): void;
12
+ export type OutcomeForVerificationReadiness = Pick<WorkflowBuildOutcome, 'submitted' | 'workflowId' | 'triggerNodes' | 'mockedCredentialTypes' | 'mockedCredentialsByNode' | 'verificationPinData' | 'usesWorkflowPinDataForVerification' | 'hasUnresolvedPlaceholders' | 'verification' | 'remediation'>;
13
+ export declare function determineVerificationReadiness(outcome: OutcomeForVerificationReadiness): WorkflowVerificationReadiness;
14
+ export declare function determineSetupRequirement(outcome: OutcomeForVerificationReadiness): WorkflowSetupRequirement;
15
+ export declare function mergeLatestVerificationIntoOutcome(outcome: WorkflowBuildOutcome, latestOutcome: WorkflowBuildOutcome | undefined): WorkflowBuildOutcome;
16
+ export declare function withTerminalLoopState(outcome: WorkflowBuildOutcome, state: WorkflowLoopState | undefined): WorkflowBuildOutcome;
17
+ export declare function finalizeBuildResult(context: OrchestrationContext, workItemId: string, result: {
18
+ text: string;
19
+ outcome: WorkflowBuildOutcome;
20
+ }): Promise<{
21
+ text: string;
22
+ outcome: WorkflowBuildOutcome;
23
+ }>;
24
+ export declare const DETACHED_BUILDER_REQUIREMENTS = "## Detached Task Contract\n\nYou are running as a detached background task. Do not stop after a successful submit \u2014 verify the workflow works.\n\n### Completion criteria\n\nYour job is done when ONE of these is true:\n- the workflow is verified (ran successfully)\n- you are blocked after one repair attempt per unique failure\n\nDo NOT stop after a successful submit without verifying. Every trigger type is testable:\nmanual / schedule via `executions(action=\"run\")`; event-based triggers (form, webhook,\nchat, mcp, linear, github, slack, etc.) via `verify-built-workflow` with an `inputData`\npayload. The pin-data adapter injects it as the trigger node's output.\n\n### Submit discipline\n\n**Every file edit MUST be followed by submit-workflow before you do anything else.**\nThe system tracks file hashes. If you edit the code and then call `executions(action=\"run\")` or finish without re-submitting, your work is discarded. The sequence is always: edit \u2192 submit \u2192 then verify/run.\n\n### Verification\n\n- If submit-workflow returned mocked credentials, call `verify-built-workflow` with the workItemId.\n- Otherwise pick based on trigger type:\n - **Manual / Schedule** \u2014 `executions(action=\"run\")`.\n - **Form Trigger** \u2014 `verify-built-workflow` with `inputData` as a flat field map, e.g. `{name: \"Alice\", email: \"a@b.c\"}`. Do NOT wrap in `formFields` \u2014 production Form Trigger emits fields directly on `$json`, and the adapter rejects wrapped payloads.\n - **Webhook** \u2014 `verify-built-workflow` with `inputData` as the body payload, e.g. `{event: \"signup\", userId: \"...\"}`. Adapter wraps it under `body`; downstream expressions use `$json.body.<field>`.\n - **Chat Trigger** \u2014 `verify-built-workflow` with `{chatInput: \"user message\"}`.\n - **Other event triggers (Linear, GitHub, Slack, MCP, etc.)** \u2014 `verify-built-workflow` with `inputData` matching the trigger's expected payload shape.\n- If verify-built-workflow returns remediation with `shouldEdit: false`, stop editing and follow its guidance.\n- If verification fails with `shouldEdit: true`, make one batched code repair and re-submit. Never exceed the remaining repair budget in the remediation metadata.\n- If verification fails otherwise, call `executions(action=\"debug\")`, fix the code, re-submit, and retry once.\n- If the same failure signature repeats, stop and explain the block.\n\n### Resource discovery\n\nBefore writing code that uses external services, **resolve real resource IDs**:\n- Call `nodes(action=\"explore-resources\")` for any parameter with searchListMethod when a matching explicit credential is attached (calendars, spreadsheets, channels, models, etc.)\n- Do NOT use \"primary\", \"default\", or any assumed identifier \u2014 look up the actual value\n- Call `nodes(action=\"suggested\")` early if the workflow fits a known category (web_app, form_input, data_persistence, etc.) \u2014 the pattern hints prevent common mistakes\n- Check @builderHint annotations in node type definitions for critical configuration guidance\n";
25
+ export declare function supportingWorkflowIdsFromSubmitAttempts(submitAttempts: SubmitWorkflowAttempt[], mainWorkflowPath: string, mainWorkflowId: string | undefined, referencedWorkflowIds?: string[]): string[];
5
26
  export declare function resultFromPostStreamError(input: {
6
27
  error: unknown;
7
28
  submitAttempts: SubmitWorkflowAttempt[];
8
29
  mainWorkflowPath: string;
9
30
  workItemId: string;
31
+ runId: string;
32
+ taskId: string;
33
+ }): {
34
+ text: string;
35
+ outcome: WorkflowBuildOutcome;
36
+ } | undefined;
37
+ export declare function resultFromLaterFailedMainSubmit(input: {
38
+ failedAttempt: SubmitWorkflowAttempt;
39
+ submitAttempts: SubmitWorkflowAttempt[];
40
+ mainWorkflowPath: string;
41
+ workItemId: string;
42
+ runId: string;
10
43
  taskId: string;
11
- }): BackgroundTaskResult | undefined;
44
+ }): {
45
+ text: string;
46
+ outcome: WorkflowBuildOutcome;
47
+ } | undefined;
48
+ export declare function attemptFromAutoResubmit(input: {
49
+ latestAttempt: SubmitWorkflowAttempt | undefined;
50
+ resubmit: SubmitWorkflowOutput;
51
+ filePath: string;
52
+ sourceHash: string;
53
+ }): SubmitWorkflowAttempt | undefined;
54
+ export declare function shouldRecoverSavedWorkflowAfterFailedSubmit(attempt: SubmitWorkflowAttempt): boolean;
12
55
  export interface StartBuildWorkflowAgentInput {
13
56
  task: string;
14
57
  workflowId?: string;
15
58
  conversationContext?: string;
59
+ workItemId?: string;
16
60
  taskId?: string;
17
61
  agentId?: string;
18
62
  plannedTaskId?: string;
@@ -27,13 +71,22 @@ export declare const buildWorkflowAgentInputSchema: z.ZodObject<{
27
71
  task: z.ZodString;
28
72
  workflowId: z.ZodOptional<z.ZodString>;
29
73
  conversationContext: z.ZodOptional<z.ZodString>;
74
+ workItemId: z.ZodOptional<z.ZodString>;
75
+ bypassPlan: z.ZodOptional<z.ZodBoolean>;
76
+ reason: z.ZodOptional<z.ZodString>;
30
77
  }, "strip", z.ZodTypeAny, {
31
78
  task: string;
79
+ reason?: string | undefined;
32
80
  workflowId?: string | undefined;
81
+ workItemId?: string | undefined;
33
82
  conversationContext?: string | undefined;
83
+ bypassPlan?: boolean | undefined;
34
84
  }, {
35
85
  task: string;
86
+ reason?: string | undefined;
36
87
  workflowId?: string | undefined;
88
+ workItemId?: string | undefined;
37
89
  conversationContext?: string | undefined;
90
+ bypassPlan?: boolean | undefined;
38
91
  }>;
39
92
  export declare function createBuildWorkflowAgentTool(context: OrchestrationContext): import("@mastra/core/tools").Tool<InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, import("@mastra/core/tools").ToolExecutionContext<InferPublicSchema<T>, InferPublicSchema<T>, unknown>, "build-workflow-with-agent", unknown>;