@n8n/ai-workflow-builder 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/planner.agent.d.ts +80 -0
- package/dist/agents/planner.agent.js +133 -0
- package/dist/agents/planner.agent.js.map +1 -0
- package/dist/agents/responder.agent.d.ts +44 -9
- package/dist/agents/responder.agent.js +123 -85
- package/dist/agents/responder.agent.js.map +1 -1
- package/dist/agents/supervisor.agent.d.ts +5 -3
- package/dist/agents/supervisor.agent.js +6 -5
- package/dist/agents/supervisor.agent.js.map +1 -1
- package/dist/ai-workflow-builder-agent.service.d.ts +3 -0
- package/dist/ai-workflow-builder-agent.service.js +93 -3
- package/dist/ai-workflow-builder-agent.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +5 -4
- package/dist/constants.js.map +1 -1
- package/dist/llm-config.d.ts +2 -1
- package/dist/llm-config.js +25 -1
- package/dist/llm-config.js.map +1 -1
- package/dist/multi-agent-workflow-subgraphs.d.ts +90 -6
- package/dist/multi-agent-workflow-subgraphs.js +94 -17
- package/dist/multi-agent-workflow-subgraphs.js.map +1 -1
- package/dist/parent-graph-state.d.ts +6 -0
- package/dist/parent-graph-state.js +20 -0
- package/dist/parent-graph-state.js.map +1 -1
- package/dist/prompts/agents/builder.prompt.d.ts +6 -1
- package/dist/prompts/agents/builder.prompt.js +535 -387
- package/dist/prompts/agents/builder.prompt.js.map +1 -1
- package/dist/prompts/agents/discovery.prompt.d.ts +1 -0
- package/dist/prompts/agents/discovery.prompt.js +334 -349
- package/dist/prompts/agents/discovery.prompt.js.map +1 -1
- package/dist/prompts/agents/index.d.ts +6 -0
- package/dist/prompts/agents/index.js +21 -0
- package/dist/prompts/agents/index.js.map +1 -0
- package/dist/prompts/agents/planner.prompt.d.ts +14 -0
- package/dist/prompts/agents/planner.prompt.js +77 -0
- package/dist/prompts/agents/planner.prompt.js.map +1 -0
- package/dist/prompts/agents/responder.prompt.js +35 -2
- package/dist/prompts/agents/responder.prompt.js.map +1 -1
- package/dist/prompts/agents/supervisor.prompt.js +3 -4
- package/dist/prompts/agents/supervisor.prompt.js.map +1 -1
- package/dist/prompts/index.d.ts +4 -4
- package/dist/prompts/index.js +11 -4
- package/dist/prompts/index.js.map +1 -1
- package/dist/session-manager.service.d.ts +18 -0
- package/dist/session-manager.service.js +154 -1
- package/dist/session-manager.service.js.map +1 -1
- package/dist/subgraphs/builder.subgraph.d.ts +31 -2
- package/dist/subgraphs/builder.subgraph.js +141 -35
- package/dist/subgraphs/builder.subgraph.js.map +1 -1
- package/dist/subgraphs/discovery.subgraph.d.ts +87 -27
- package/dist/subgraphs/discovery.subgraph.js +204 -24
- package/dist/subgraphs/discovery.subgraph.js.map +1 -1
- package/dist/tools/add-node.tool.d.ts +36 -0
- package/dist/tools/add-node.tool.js +28 -8
- package/dist/tools/add-node.tool.js.map +1 -1
- package/dist/tools/best-practices/triage.js +5 -5
- package/dist/tools/builder-tools.js +6 -1
- package/dist/tools/builder-tools.js.map +1 -1
- package/dist/tools/connect-nodes.tool.js +16 -3
- package/dist/tools/connect-nodes.tool.js.map +1 -1
- package/dist/tools/get-execution-logs.tool.d.ts +4 -0
- package/dist/tools/get-execution-logs.tool.js +104 -0
- package/dist/tools/get-execution-logs.tool.js.map +1 -0
- package/dist/tools/get-execution-schema.tool.d.ts +4 -0
- package/dist/tools/get-execution-schema.tool.js +81 -0
- package/dist/tools/get-execution-schema.tool.js.map +1 -0
- package/dist/tools/get-expression-data-mapping.tool.d.ts +4 -0
- package/dist/tools/get-expression-data-mapping.tool.js +85 -0
- package/dist/tools/get-expression-data-mapping.tool.js.map +1 -0
- package/dist/tools/get-node-context.tool.d.ts +13 -0
- package/dist/tools/get-node-context.tool.js +227 -0
- package/dist/tools/get-node-context.tool.js.map +1 -0
- package/dist/tools/get-node-parameter.tool.js +1 -2
- package/dist/tools/get-node-parameter.tool.js.map +1 -1
- package/dist/tools/get-workflow-overview.tool.d.ts +11 -0
- package/dist/tools/get-workflow-overview.tool.js +158 -0
- package/dist/tools/get-workflow-overview.tool.js.map +1 -0
- package/dist/tools/helpers/state.d.ts +1 -0
- package/dist/tools/helpers/state.js +10 -0
- package/dist/tools/helpers/state.js.map +1 -1
- package/dist/tools/submit-questions.tool.d.ts +71 -0
- package/dist/tools/submit-questions.tool.js +74 -0
- package/dist/tools/submit-questions.tool.js.map +1 -0
- package/dist/tools/update-node-parameters.tool.js +2 -3
- package/dist/tools/update-node-parameters.tool.js.map +1 -1
- package/dist/tools/utils/mermaid.utils.d.ts +9 -1
- package/dist/tools/utils/mermaid.utils.js +9 -5
- package/dist/tools/utils/mermaid.utils.js.map +1 -1
- package/dist/tools/utils/node-creation.utils.d.ts +6 -2
- package/dist/tools/utils/node-creation.utils.js +2 -1
- package/dist/tools/utils/node-creation.utils.js.map +1 -1
- package/dist/tools/validate-configuration.tool.js +15 -7
- package/dist/tools/validate-configuration.tool.js.map +1 -1
- package/dist/tools/validate-structure.tool.js +3 -3
- package/dist/tools/validate-structure.tool.js.map +1 -1
- package/dist/types/coordination.d.ts +9 -9
- package/dist/types/coordination.js +14 -4
- package/dist/types/coordination.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/planning.d.ts +48 -0
- package/dist/types/planning.js +3 -0
- package/dist/types/planning.js.map +1 -0
- package/dist/types/streaming.d.ts +14 -1
- package/dist/types/tools.d.ts +16 -0
- package/dist/utils/context-builders.d.ts +8 -0
- package/dist/utils/context-builders.js +249 -8
- package/dist/utils/context-builders.js.map +1 -1
- package/dist/utils/coordination-log.d.ts +2 -4
- package/dist/utils/coordination-log.js +0 -8
- package/dist/utils/coordination-log.js.map +1 -1
- package/dist/utils/node-helpers.d.ts +1 -0
- package/dist/utils/node-helpers.js +7 -0
- package/dist/utils/node-helpers.js.map +1 -1
- package/dist/utils/plan-helpers.d.ts +2 -0
- package/dist/utils/plan-helpers.js +26 -0
- package/dist/utils/plan-helpers.js.map +1 -0
- package/dist/utils/stream-processor.js +137 -8
- package/dist/utils/stream-processor.js.map +1 -1
- package/dist/utils/subgraph-helpers.js +7 -1
- package/dist/utils/subgraph-helpers.js.map +1 -1
- package/dist/utils/truncate-json.d.ts +5 -0
- package/dist/utils/truncate-json.js +18 -0
- package/dist/utils/truncate-json.js.map +1 -0
- package/dist/validation/checks/credentials.js +2 -6
- package/dist/validation/checks/credentials.js.map +1 -1
- package/dist/validation/checks/index.d.ts +1 -0
- package/dist/validation/checks/index.js +3 -1
- package/dist/validation/checks/index.js.map +1 -1
- package/dist/validation/checks/parameters.d.ts +4 -0
- package/dist/validation/checks/parameters.js +165 -0
- package/dist/validation/checks/parameters.js.map +1 -0
- package/dist/validation/programmatic.js +2 -0
- package/dist/validation/programmatic.js.map +1 -1
- package/dist/validation/types.d.ts +3 -1
- package/dist/validation/types.js +2 -0
- package/dist/validation/types.js.map +1 -1
- package/dist/workflow-builder-agent.d.ts +7 -1
- package/dist/workflow-builder-agent.js +43 -11
- package/dist/workflow-builder-agent.js.map +1 -1
- package/package.json +6 -5
- package/dist/prompts/agents/configurator.prompt.d.ts +0 -3
- package/dist/prompts/agents/configurator.prompt.js +0 -260
- package/dist/prompts/agents/configurator.prompt.js.map +0 -1
- package/dist/subgraphs/configurator.subgraph.d.ts +0 -158
- package/dist/subgraphs/configurator.subgraph.js +0 -234
- package/dist/subgraphs/configurator.subgraph.js.map +0 -1
|
@@ -4,113 +4,21 @@ exports.exampleCategorizations = void 0;
|
|
|
4
4
|
exports.formatTechniqueList = formatTechniqueList;
|
|
5
5
|
exports.formatExampleCategorizations = formatExampleCategorizations;
|
|
6
6
|
exports.buildDiscoveryPrompt = buildDiscoveryPrompt;
|
|
7
|
-
const types_1 = require("../../types");
|
|
8
7
|
const categorization_1 = require("../../types/categorization");
|
|
9
8
|
const builder_1 = require("../builder");
|
|
10
|
-
const node_guidance_1 = require("../shared/node-guidance");
|
|
11
9
|
exports.exampleCategorizations = [
|
|
12
10
|
{
|
|
13
|
-
prompt: 'Monitor social channels for product mentions and auto-respond
|
|
14
|
-
techniques: [
|
|
15
|
-
categorization_1.WorkflowTechnique.MONITORING,
|
|
16
|
-
categorization_1.WorkflowTechnique.CHATBOT,
|
|
17
|
-
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
18
|
-
],
|
|
11
|
+
prompt: 'Monitor social channels for product mentions and auto-respond',
|
|
12
|
+
techniques: [categorization_1.WorkflowTechnique.MONITORING, categorization_1.WorkflowTechnique.CHATBOT],
|
|
19
13
|
},
|
|
20
14
|
{
|
|
21
|
-
prompt: '
|
|
22
|
-
techniques: [
|
|
23
|
-
categorization_1.WorkflowTechnique.FORM_INPUT,
|
|
24
|
-
categorization_1.WorkflowTechnique.HUMAN_IN_THE_LOOP,
|
|
25
|
-
categorization_1.WorkflowTechnique.NOTIFICATION,
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
prompt: 'Scrape competitor pricing pages weekly and generate a summary report of changes',
|
|
30
|
-
techniques: [
|
|
31
|
-
categorization_1.WorkflowTechnique.SCHEDULING,
|
|
32
|
-
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
33
|
-
categorization_1.WorkflowTechnique.DATA_EXTRACTION,
|
|
34
|
-
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
prompt: 'Process uploaded PDF contracts to extract client details and update CRM records',
|
|
39
|
-
techniques: [
|
|
40
|
-
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
41
|
-
categorization_1.WorkflowTechnique.DATA_EXTRACTION,
|
|
42
|
-
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
43
|
-
categorization_1.WorkflowTechnique.ENRICHMENT,
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
prompt: 'Build a searchable internal knowledge base from past support tickets',
|
|
48
|
-
techniques: [
|
|
49
|
-
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
50
|
-
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
51
|
-
categorization_1.WorkflowTechnique.KNOWLEDGE_BASE,
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
prompt: 'Create an AI agent that writes and sends personalized emails to leads',
|
|
56
|
-
techniques: [categorization_1.WorkflowTechnique.CONTENT_GENERATION, categorization_1.WorkflowTechnique.NOTIFICATION],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
prompt: 'Fetch trending topics from Google Trends and Reddit, select the best ones, and create social posts',
|
|
60
|
-
techniques: [
|
|
61
|
-
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
62
|
-
categorization_1.WorkflowTechnique.TRIAGE,
|
|
63
|
-
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
prompt: 'Trigger when a new contact is created in HubSpot and enrich their profile with LinkedIn data',
|
|
68
|
-
techniques: [categorization_1.WorkflowTechnique.MONITORING, categorization_1.WorkflowTechnique.ENRICHMENT],
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
prompt: 'Get stock prices from financial APIs and analyze volatility patterns',
|
|
72
|
-
techniques: [categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH, categorization_1.WorkflowTechnique.DATA_ANALYSIS],
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
prompt: 'Generate video reels from templates and auto-post to social media on schedule',
|
|
76
|
-
techniques: [
|
|
77
|
-
categorization_1.WorkflowTechnique.SCHEDULING,
|
|
78
|
-
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
79
|
-
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
prompt: 'Receive news from Telegram channels, filter relevant ones, and forward to my channel',
|
|
84
|
-
techniques: [
|
|
85
|
-
categorization_1.WorkflowTechnique.MONITORING,
|
|
86
|
-
categorization_1.WorkflowTechnique.TRIAGE,
|
|
87
|
-
categorization_1.WorkflowTechnique.NOTIFICATION,
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
prompt: 'Analyze YouTube video performance data and generate a weekly report',
|
|
92
|
-
techniques: [
|
|
93
|
-
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
94
|
-
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
95
|
-
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
prompt: 'Create a chatbot that answers questions using data from a Google Sheet as knowledge base',
|
|
100
|
-
techniques: [categorization_1.WorkflowTechnique.CHATBOT, categorization_1.WorkflowTechnique.KNOWLEDGE_BASE],
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
prompt: 'Form submission with file upload triggers document extraction and approval workflow',
|
|
104
|
-
techniques: [
|
|
105
|
-
categorization_1.WorkflowTechnique.FORM_INPUT,
|
|
106
|
-
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
107
|
-
categorization_1.WorkflowTechnique.HUMAN_IN_THE_LOOP,
|
|
108
|
-
],
|
|
15
|
+
prompt: 'Process PDF contracts to extract client details and update CRM',
|
|
16
|
+
techniques: [categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING, categorization_1.WorkflowTechnique.DATA_EXTRACTION],
|
|
109
17
|
},
|
|
110
18
|
];
|
|
111
19
|
function formatTechniqueList() {
|
|
112
20
|
return Object.entries(categorization_1.TechniqueDescription)
|
|
113
|
-
.map(([key, description]) => `-
|
|
21
|
+
.map(([key, description]) => `- ${key}: ${description}`)
|
|
114
22
|
.join('\n');
|
|
115
23
|
}
|
|
116
24
|
function formatExampleCategorizations() {
|
|
@@ -118,272 +26,349 @@ function formatExampleCategorizations() {
|
|
|
118
26
|
.map((example) => `- ${example.prompt} → ${example.techniques.join(', ')}`)
|
|
119
27
|
.join('\n');
|
|
120
28
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
29
|
+
const ROLE = `You are a Discovery Agent for n8n AI Workflow Builder.
|
|
30
|
+
Identify relevant n8n nodes and their connection-changing parameters for the user's request.`;
|
|
31
|
+
const N8N_EXECUTION_MODEL = `n8n executes each node once per input item.
|
|
32
|
+
|
|
33
|
+
When a trigger or node outputs multiple items (e.g., Gmail returns 10 emails), every downstream node runs once for each item. Flow control nodes like Aggregate and Split Out change how items flow through the workflow by combining or expanding them.`;
|
|
34
|
+
const PROCESS = `1. Search for nodes matching the user's request using search_nodes tool
|
|
35
|
+
2. Identify connection-changing parameters from input/output expressions (look for $parameter.X)
|
|
36
|
+
3. Call submit_discovery_results with your nodesFound array`;
|
|
37
|
+
const PROCESS_WITH_QUESTIONS = `1. Search for nodes matching the user's request using search_nodes tool
|
|
38
|
+
2. Identify connection-changing parameters from input/output expressions (look for $parameter.X)
|
|
39
|
+
3. If the search results reveal a genuine ambiguity that would lead to very different workflows, ask clarifying questions using submit_questions (see clarifying_questions section)
|
|
40
|
+
4. Call submit_discovery_results with your nodesFound array`;
|
|
41
|
+
const PROCESS_WITH_EXAMPLES = `1. Search for nodes matching the user's request using search_nodes tool
|
|
42
|
+
2. Identify connection-changing parameters from input/output expressions (look for $parameter.X)
|
|
43
|
+
3. Use get_documentation to retrieve best practices for relevant workflow techniques—this provides proven patterns that improve workflow quality
|
|
44
|
+
4. Use get_workflow_examples to find real community workflows using mentioned services—these examples show how experienced users structure similar integrations
|
|
45
|
+
5. Call submit_discovery_results with your nodesFound array`;
|
|
46
|
+
const PROCESS_WITH_EXAMPLES_AND_QUESTIONS = `1. Search for nodes matching the user's request using search_nodes tool
|
|
47
|
+
2. Identify connection-changing parameters from input/output expressions (look for $parameter.X)
|
|
48
|
+
3. Use get_documentation to retrieve best practices for relevant workflow techniques—this provides proven patterns that improve workflow quality
|
|
49
|
+
4. Use get_workflow_examples to find real community workflows using mentioned services—these examples show how experienced users structure similar integrations
|
|
50
|
+
5. If the search results reveal a genuine ambiguity that would lead to very different workflows, ask clarifying questions using submit_questions (see clarifying_questions section)
|
|
51
|
+
6. Call submit_discovery_results with your nodesFound array`;
|
|
52
|
+
const AI_NODE_SELECTION = `AI node selection guidance:
|
|
53
|
+
|
|
54
|
+
AI Agent: Use for text analysis, summarization, classification, or any AI reasoning tasks.
|
|
55
|
+
OpenAI node: Use only for DALL-E, Whisper, Sora, or embeddings (these are specialized APIs that AI Agent cannot access).
|
|
56
|
+
Default chat model: OpenAI Chat Model provides the lowest setup friction for new users.
|
|
57
|
+
Tool nodes (ending in "Tool"): Connect to AI Agent via ai_tool for agent-controlled actions.
|
|
58
|
+
Text Classifier vs AI Agent: Text Classifier for simple categorization with fixed categories; AI Agent for complex multi-step classification requiring reasoning.
|
|
59
|
+
Memory nodes: Include with chatbot AI Agents to maintain conversation context across messages.
|
|
60
|
+
Structured Output Parser: Prefer this over manually extracting/parsing AI output with Set or Code nodes. Define the desired schema and the LLM handles parsing automatically. Use for classification, data extraction, or any workflow where AI output feeds into database storage, API calls, or Switch routing.
|
|
61
|
+
|
|
62
|
+
<multi_agent_systems>
|
|
63
|
+
For "team of agents", "supervisor agent", "agents that call other agents", or "multi-agent" requests:
|
|
64
|
+
|
|
65
|
+
AI Agent Tool (@n8n/n8n-nodes-langchain.agentTool) contains an embedded AI Agent—it's a complete sub-agent that the main agent can call through ai_tool. Each AgentTool needs its own Chat Model.
|
|
66
|
+
|
|
67
|
+
\`\`\`mermaid
|
|
68
|
+
graph TD
|
|
69
|
+
MAIN[Main AI Agent]
|
|
70
|
+
CM1[Chat Model] -.ai_languageModel.-> MAIN
|
|
71
|
+
SUB1[Research Agent Tool] -.ai_tool.-> MAIN
|
|
72
|
+
CM2[Chat Model] -.ai_languageModel.-> SUB1
|
|
73
|
+
SUB2[Writing Agent Tool] -.ai_tool.-> MAIN
|
|
74
|
+
CM3[Chat Model] -.ai_languageModel.-> SUB2
|
|
167
75
|
\`\`\`
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
-
|
|
181
|
-
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
-
|
|
190
|
-
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
-
|
|
200
|
-
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
-
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
-
|
|
289
|
-
-
|
|
290
|
-
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
-
|
|
306
|
-
|
|
307
|
-
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
-
|
|
315
|
-
-
|
|
316
|
-
-
|
|
317
|
-
-
|
|
318
|
-
-
|
|
319
|
-
-
|
|
320
|
-
|
|
321
|
-
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
-
|
|
329
|
-
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
-
|
|
333
|
-
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
76
|
+
|
|
77
|
+
Node selection: 1 AI Agent + N AgentTools + (N+1) Chat Models
|
|
78
|
+
</multi_agent_systems>`;
|
|
79
|
+
const NODE_SELECTION_PATTERNS = `Node selection by use case:
|
|
80
|
+
|
|
81
|
+
DOCUMENTS:
|
|
82
|
+
- Document Loader: Loads documents from various sources (dataType parameter controls format handling)
|
|
83
|
+
- Extract From File: Extracts text content from binary files (operation varies by file type)
|
|
84
|
+
- AWS Textract: OCR for scanned documents
|
|
85
|
+
- Mindee: Extracts structured data from invoices and receipts
|
|
86
|
+
|
|
87
|
+
DATA PROCESSING & TRANSFORMATION:
|
|
88
|
+
- Aggregate: Combines multiple items into one
|
|
89
|
+
- Split Out: Expands arrays into separate items
|
|
90
|
+
- Loop Over Items: Processes large item sets
|
|
91
|
+
- Set: Adds, modifies, or removes fields from items
|
|
92
|
+
- Filter: Removes items based on conditions
|
|
93
|
+
- Sort: Orders items by field values
|
|
94
|
+
|
|
95
|
+
STORAGE:
|
|
96
|
+
- n8n Data Tables: Built-in database storage (no credentials required). ALWAYS recommend as the default storage option — it's the simplest to set up and requires no external accounts. Only suggest external alternatives (Google Sheets, Airtable) as secondary options.
|
|
97
|
+
- Google Sheets: Spreadsheet storage and collaboration
|
|
98
|
+
- Airtable: Relational database with rich field types
|
|
99
|
+
|
|
100
|
+
TRIGGERS:
|
|
101
|
+
- Schedule Trigger: Time-based automation
|
|
102
|
+
- Gmail Trigger: Monitors for new emails
|
|
103
|
+
- Form Trigger: Collects user submissions
|
|
104
|
+
- Webhook: Receives HTTP requests from external services
|
|
105
|
+
|
|
106
|
+
SCRAPING:
|
|
107
|
+
- Phantombuster/Apify: Social media and LinkedIn data collection
|
|
108
|
+
- HTTP Request + HTML Extract: Web page content extraction
|
|
109
|
+
|
|
110
|
+
NOTIFICATIONS:
|
|
111
|
+
- Email nodes (Gmail, Outlook, Send Email)
|
|
112
|
+
- Slack: Team messaging
|
|
113
|
+
- Telegram: Bot messaging
|
|
114
|
+
- Twilio: SMS messaging
|
|
115
|
+
|
|
116
|
+
RESEARCH:
|
|
117
|
+
- SerpAPI Tool: Web search capabilities for AI Agents
|
|
118
|
+
- Perplexity Tool: AI-powered search for AI Agents
|
|
119
|
+
|
|
120
|
+
CHATBOTS:
|
|
121
|
+
- Slack/Telegram/WhatsApp nodes: Platform-specific chatbots
|
|
122
|
+
- Chat Trigger: n8n-hosted chat interface
|
|
123
|
+
|
|
124
|
+
MEDIA:
|
|
125
|
+
- OpenAI: DALL-E image generation, Sora video, Whisper transcription
|
|
126
|
+
- Google Gemini: Imagen image generation
|
|
127
|
+
- ElevenLabs: Text-to-speech (via HTTP Request)`;
|
|
128
|
+
const BASELINE_FLOW_CONTROL = `<always_include_baseline>
|
|
129
|
+
Always include these fundamental flow control and data transformation nodes in your discovery results. These are used in most workflows and the builder will select which ones are needed:
|
|
130
|
+
|
|
131
|
+
- n8n-nodes-base.aggregate: Combines multiple items into one item
|
|
132
|
+
- n8n-nodes-base.if: Routes items based on true/false condition
|
|
133
|
+
- n8n-nodes-base.switch: Routes items to different paths based on rules or expressions (connection-changing param: mode)
|
|
134
|
+
- n8n-nodes-base.splitOut: Expands a single item containing an array into multiple individual items
|
|
135
|
+
- n8n-nodes-base.merge: Combines data from multiple parallel branches (for 3+ inputs: mode="append" + numberInputs)
|
|
136
|
+
- n8n-nodes-base.set: Transforms and restructures data fields
|
|
137
|
+
|
|
138
|
+
The builder will determine which of these nodes are actually needed for the workflow. Your job is to explain what each node does, not prescribe when to use it.
|
|
139
|
+
</always_include_baseline>`;
|
|
140
|
+
const FLOW_CONTROL_NODES = `Flow control nodes handle item cardinality, branching, and data restructuring:
|
|
141
|
+
|
|
142
|
+
ITEM AGGREGATION:
|
|
143
|
+
- Aggregate (n8n-nodes-base.aggregate): Combines multiple items into one.
|
|
144
|
+
|
|
145
|
+
CONDITIONAL BRANCHING:
|
|
146
|
+
- IF (n8n-nodes-base.if): Binary true/false routing.
|
|
147
|
+
- Switch (n8n-nodes-base.switch): Multiple output paths based on conditions.
|
|
148
|
+
Connection-changing param: mode (expression/rules)
|
|
149
|
+
|
|
150
|
+
DATA RESTRUCTURING:
|
|
151
|
+
- Split Out (n8n-nodes-base.splitOut): Converts single item with array field into multiple items.
|
|
152
|
+
- Merge (n8n-nodes-base.merge): Combines data from parallel branches that execute together.
|
|
153
|
+
For 3+ inputs: mode="append" + numberInputs, OR mode="combine" + combineBy="combineByPosition" + numberInputs
|
|
154
|
+
- Set (n8n-nodes-base.set): Transforms and restructures data fields.
|
|
155
|
+
|
|
156
|
+
LOOPING & BATCHING:
|
|
157
|
+
- Split In Batches (n8n-nodes-base.splitInBatches): Process large datasets in chunks.
|
|
158
|
+
Output 0 = "done" (final result), Output 1 = "loop" (processing)`;
|
|
159
|
+
const CONNECTION_PARAMETERS = `A parameter is connection-changing if it appears in <node_inputs> or <node_outputs> expressions.
|
|
160
|
+
Look for patterns like: $parameter.mode, $parameter.hasOutputParser in the search results.
|
|
161
|
+
|
|
162
|
+
Common connection-changing parameters:
|
|
163
|
+
- Vector Store: mode (insert/retrieve/retrieve-as-tool)
|
|
164
|
+
- AI Agent: hasOutputParser (true/false)
|
|
165
|
+
- Merge: numberInputs (requires mode="append" OR mode="combine" + combineBy="combineByPosition")
|
|
166
|
+
- Switch: mode (expression/rules)
|
|
167
|
+
|
|
168
|
+
If no parameters affect connections, return empty connectionChangingParameters array.`;
|
|
169
|
+
const TRIGGER_SELECTION = `Trigger type selection (choose based on how the workflow starts):
|
|
170
|
+
|
|
171
|
+
Webhook (n8n-nodes-base.webhook): External systems calling your workflow via HTTP POST/GET.
|
|
172
|
+
Use when: "receive data from X", "when X calls", "API endpoint", "incoming requests"
|
|
173
|
+
|
|
174
|
+
Form Trigger: User-facing forms with optional multi-step support.
|
|
175
|
+
Use when: "collect user input", "survey", "registration form"
|
|
176
|
+
|
|
177
|
+
Schedule Trigger: Time-based automation (cron-style), only runs when workflow is activated.
|
|
178
|
+
Use when: "run daily at 9am", "every hour", "weekly report"
|
|
179
|
+
|
|
180
|
+
Gmail/Slack/Telegram Trigger: Platform-specific event monitoring with built-in authentication.
|
|
181
|
+
Use when: "monitor for new emails", "when message received", "watch channel"
|
|
182
|
+
|
|
183
|
+
Chat Trigger: n8n-hosted chat interface for conversational AI.
|
|
184
|
+
Use when: "build a chatbot", "chat interface", "conversational assistant"
|
|
185
|
+
|
|
186
|
+
Manual Trigger: For testing and one-off runs only (requires user to click "Execute").
|
|
187
|
+
Use when: explicitly testing or debugging workflows`;
|
|
188
|
+
const CLARIFYING_QUESTIONS = `You can ask the user clarifying questions using submit_questions. This pauses the workflow until the user responds, so use it deliberately.
|
|
189
|
+
|
|
190
|
+
Always search for nodes FIRST. Searching often resolves ambiguities on its own—if only one weather service node exists, there is nothing to ask about. Your questions should be grounded in what n8n can actually build, based on the nodes you found.
|
|
191
|
+
|
|
192
|
+
<when_to_ask>
|
|
193
|
+
Ask when the request is vague enough that it could mean multiple fundamentally different workflows. Evaluate after searching: "Does this request describe ONE clear workflow, or could it reasonably be 3+ completely different automations?"
|
|
194
|
+
|
|
195
|
+
Examples where questions help:
|
|
196
|
+
- "Do something with my emails" → Could be filtering, forwarding, archiving, summarizing. Ask about the goal.
|
|
197
|
+
- "Set up notifications" → Found Email, Slack, Telegram, SMS nodes. Ask which channel.
|
|
198
|
+
- "Another automation for weather" → No specific action stated. Ask what should happen.
|
|
199
|
+
|
|
200
|
+
Examples where questions do NOT help:
|
|
201
|
+
- "Send a Slack message when I get a Gmail with an invoice" → One clear workflow. Build it.
|
|
202
|
+
- "Check weather every hour and store it" → Specific enough. Build it.
|
|
203
|
+
- "Monitor my website for downtime" → Reasonable defaults exist. Build it.
|
|
204
|
+
</when_to_ask>
|
|
205
|
+
|
|
206
|
+
<how_to_ask>
|
|
207
|
+
Users are often non-technical and may not know what n8n can do. Frame questions around outcomes and goals, not technical choices. Present options as a menu of things n8n can build for them.
|
|
208
|
+
|
|
209
|
+
Option labels: Use names users already know (Gmail, Slack, Google Sheets). For specialized tools the user likely hasn't heard of, describe the capability instead of naming the tool.
|
|
210
|
+
- Good: "Specialized invoice reader (extracts line items, totals, dates automatically)"
|
|
211
|
+
- Bad: "Mindee (specialized for invoices and receipts)" — user doesn't know what Mindee is.
|
|
212
|
+
- Good: "AI-powered text extraction"
|
|
213
|
+
- Bad: "AWS Textract (general OCR)" — user doesn't know what OCR or Textract means.
|
|
214
|
+
|
|
215
|
+
Well-known services (Gmail, Slack, Salesforce, HubSpot, Airtable, Mailchimp) can be named directly — users recognize them. Internal n8n node names (n8n-nodes-base.*, @n8n/*) must never appear in questions or options.
|
|
216
|
+
|
|
217
|
+
Good question style (outcome-focused, grounded in search results):
|
|
218
|
+
- "What should this automation do with the weather data?" → Options: "Send me alerts when it rains", "Track weather data over time", "Control smart home devices based on weather"
|
|
219
|
+
- "Where should I send the notification?" → Options: "Email", "Slack", "Telegram" (only list channels you found nodes for)
|
|
220
|
+
|
|
221
|
+
Bad question style (technical, generic, or obvious):
|
|
222
|
+
- "Which trigger type do you want?" → Too technical. Pick the obvious one or describe outcomes.
|
|
223
|
+
- "What format should the data be in?" → Implementation detail the builder handles.
|
|
224
|
+
- "What information should the notification contain?" → Implementation detail. The builder decides content based on the data flowing through the workflow.
|
|
225
|
+
- "Do you want error handling?" → Not a user-facing decision.
|
|
226
|
+
- "What automation do you want?" → Too open-ended, not grounded in n8n capabilities.
|
|
227
|
+
- "Which tool should extract data from invoices?" → User doesn't choose extraction tools. Ask what they need extracted or where invoices come from instead.
|
|
228
|
+
|
|
229
|
+
Keep it to 2-3 questions maximum. Each question should meaningfully change which nodes you select.
|
|
230
|
+
|
|
231
|
+
Never include "Other" as an option — the UI automatically adds an "Other" free-text input to every question. Only list specific, meaningful choices.
|
|
232
|
+
</how_to_ask>`;
|
|
233
|
+
const AI_TOOL_PATTERNS = `AI Agent tool connection patterns:
|
|
234
|
+
|
|
235
|
+
When AI Agent needs external capabilities, use TOOL nodes (not regular nodes):
|
|
236
|
+
- Research: SerpAPI Tool, Perplexity Tool → AI Agent [ai_tool]
|
|
237
|
+
- Calendar: Google Calendar Tool → AI Agent [ai_tool]
|
|
238
|
+
- Messaging: Slack Tool, Gmail Tool → AI Agent [ai_tool]
|
|
239
|
+
- HTTP calls: HTTP Request Tool → AI Agent [ai_tool]
|
|
240
|
+
- Calculations: Calculator Tool → AI Agent [ai_tool]
|
|
241
|
+
- Sub-agents: AI Agent Tool → AI Agent [ai_tool] (for multi-agent systems)
|
|
242
|
+
|
|
243
|
+
Tool nodes: AI Agent decides when/if to use them based on reasoning.
|
|
244
|
+
Regular nodes: Execute at that workflow step regardless of context.
|
|
245
|
+
|
|
246
|
+
Multi-agent pattern:
|
|
247
|
+
AI Agent Tool (@n8n/n8n-nodes-langchain.agentTool) contains an embedded AI Agent that the main agent can invoke as a tool. Connect a Chat Model to the AgentTool via ai_languageModel (powers the embedded agent), then connect the AgentTool to the main AI Agent via ai_tool.
|
|
248
|
+
Connection-changing param: hasOutputParser (true/false)
|
|
249
|
+
|
|
250
|
+
Vector Store patterns:
|
|
251
|
+
- Insert documents: Document Loader → Vector Store (mode='insert') [ai_document]
|
|
252
|
+
- RAG with AI Agent: Vector Store (mode='retrieve-as-tool') → AI Agent [ai_tool]
|
|
253
|
+
The retrieve-as-tool mode makes the Vector Store act as a tool the Agent can call, which is simpler than using a separate Retriever node.
|
|
254
|
+
|
|
255
|
+
Structured Output Parser: Connect to AI Agent when structured JSON output is required.`;
|
|
256
|
+
const NATIVE_NODE_PREFERENCE = `Prefer native n8n nodes over Code node because native nodes provide better UX, visual debugging, and are easier for users to modify.
|
|
257
|
+
|
|
258
|
+
Native node mappings:
|
|
259
|
+
- Remove duplicates → Remove Duplicates (n8n-nodes-base.removeDuplicates): handles nested object comparison
|
|
260
|
+
- Filter items → Filter: visual condition builder with multiple rules
|
|
261
|
+
- Transform/map data → Edit Fields (Set): drag-and-drop field mapping
|
|
262
|
+
- Combine items → Aggregate: groups and summarizes with built-in functions
|
|
263
|
+
- Conditional routing → IF / Switch: visual branching with clear output paths
|
|
264
|
+
- Sort items → Sort: configurable sort keys and directions
|
|
265
|
+
- Regex matching → IF with expression: use {{ $json.field.match(/pattern/) }}
|
|
266
|
+
- Limit items → Limit: simple count-based limiting
|
|
267
|
+
- Compare datasets → Compare Datasets: finds differences between two data sources
|
|
268
|
+
|
|
269
|
+
Reserve Code node for complex multi-step algorithms that require loops, recursion, or logic that expressions cannot handle.`;
|
|
270
|
+
const EXPLICIT_SERVICE_MAPPING = `When user explicitly requests a service, use that service's native node because native nodes provide better error handling, credential management, and UX than HTTP Request.
|
|
271
|
+
|
|
272
|
+
Service mappings:
|
|
273
|
+
- "use Perplexity" → Perplexity or PerplexityTool (native nodes have built-in response parsing)
|
|
274
|
+
- "use SerpAPI" → SerpAPI Tool (handles pagination and result formatting)
|
|
275
|
+
- "use Claude/Anthropic" → lmChatAnthropic (proper streaming and token counting)
|
|
276
|
+
- "use Gemini" → lmChatGoogleGemini (handles Google's auth flow)
|
|
277
|
+
- "use OpenAI" → lmChatOpenAi for chat, OpenAI node for DALL-E/Whisper/Sora
|
|
278
|
+
|
|
279
|
+
Fall back to HTTP Request only when the requested service has no native n8n node available.`;
|
|
280
|
+
const KEY_RULES = `Output format: nodesFound array with nodeName, version, reasoning, connectionChangingParameters per node.
|
|
281
|
+
|
|
282
|
+
<reasoning_guidelines>
|
|
283
|
+
Reasoning should describe WHAT the node does, not WHEN or HOW to use it. Focus on capabilities and behavior, not recommendations or comparisons. The builder will decide which nodes to use.
|
|
284
|
+
|
|
285
|
+
CRITICAL - Model names:
|
|
286
|
+
- If the user specifies a model name (e.g., "gpt-5-mini", "claude-4", any custom model), pass it through EXACTLY in your reasoning
|
|
287
|
+
- Do NOT substitute, "correct", or replace model names—your training data has a knowledge cutoff and newer models exist
|
|
288
|
+
- Users may also use custom endpoints with model names you've never seen
|
|
289
|
+
|
|
290
|
+
Good reasoning examples (neutral, factual):
|
|
291
|
+
- "Extracts data from HTML documents using CSS selectors or XPath"
|
|
292
|
+
- "Transforms data by adding, modifying, or removing fields from items"
|
|
293
|
+
- "Sends HTTP requests to external APIs with configurable methods and headers"
|
|
294
|
+
- "Combines multiple items into a single item containing all data"
|
|
295
|
+
- "Converts a single item with an array field into multiple separate items"
|
|
296
|
+
|
|
297
|
+
Bad reasoning examples (prescriptive, comparative):
|
|
298
|
+
- "Use this to build HTML content" ❌ Tells WHEN to use
|
|
299
|
+
- "While you can build HTML in a Set node, this provides..." ❌ Compares alternatives
|
|
300
|
+
- "Better for Y than Z" ❌ Judges superiority
|
|
301
|
+
- "You should use this when..." ❌ Prescribes usage
|
|
302
|
+
- "This node will replace X" ❌ Decides architecture
|
|
303
|
+
- "or to build the HTML content itself" ❌ Suggests specific use case
|
|
304
|
+
|
|
305
|
+
Vector Store example (neutral, capability-focused):
|
|
306
|
+
"Stores and retrieves vector embeddings. Connection-changing param 'mode': insert (accepts ai_document connections), retrieve (outputs retrieved documents), retrieve-as-tool (connects to AI Agent via ai_tool for on-demand retrieval)."
|
|
307
|
+
|
|
308
|
+
HTML node example (neutral):
|
|
309
|
+
Good: "Extracts data from HTML using CSS selectors, converts HTML to markdown, or manipulates HTML structure"
|
|
310
|
+
Bad: "While you can build HTML in a Set node, this provides HTML-specific operations" ❌
|
|
311
|
+
</reasoning_guidelines>
|
|
312
|
+
|
|
313
|
+
Guidelines:
|
|
314
|
+
- Extract version from <version> tag in node details (version affects available features)
|
|
315
|
+
- Baseline flow control nodes (Aggregate, IF, Switch, Split Out, Merge, Set) are automatically included—no need to search for them
|
|
316
|
+
- Prioritize native nodes in your searches because they provide better UX and visual debugging than Code node alternatives`;
|
|
317
|
+
function generateToolCallRequirement(options) {
|
|
318
|
+
const toolExamples = ['search_nodes'];
|
|
319
|
+
if (options.includeQuestions)
|
|
320
|
+
toolExamples.push('submit_questions');
|
|
321
|
+
if (options.includeExamples)
|
|
322
|
+
toolExamples.push('get_documentation', 'get_workflow_examples');
|
|
323
|
+
return `<output_requirement>
|
|
324
|
+
Use tools when needed (e.g. ${toolExamples.join(', ')}).
|
|
325
|
+
|
|
326
|
+
Your final response MUST call the submit_discovery_results tool with the nodesFound array.
|
|
327
|
+
Do not output the results as text or XML.
|
|
328
|
+
</output_requirement>`;
|
|
329
|
+
}
|
|
338
330
|
function generateAvailableToolsList(options) {
|
|
339
|
-
const { includeExamples } = options;
|
|
340
331
|
const tools = [
|
|
341
|
-
'-
|
|
342
|
-
'- search_nodes: Find n8n nodes by keyword',
|
|
343
|
-
'- get_node_details: Get complete node information including <connections>',
|
|
332
|
+
'- search_nodes: Find n8n nodes by keyword (returns name, version, inputs, outputs)',
|
|
344
333
|
];
|
|
345
|
-
if (
|
|
346
|
-
tools.push('-
|
|
334
|
+
if (options.includeQuestions) {
|
|
335
|
+
tools.push('- submit_questions: Ask clarifying questions when critical details are missing');
|
|
336
|
+
}
|
|
337
|
+
if (options.includeExamples) {
|
|
338
|
+
tools.push('- get_documentation: Retrieve best practices for workflow techniques to improve quality');
|
|
339
|
+
tools.push('- get_workflow_examples: Find real community workflows as reference for structuring integrations');
|
|
347
340
|
}
|
|
348
341
|
tools.push('- submit_discovery_results: Submit final results');
|
|
349
342
|
return tools.join('\n');
|
|
350
343
|
}
|
|
351
|
-
function
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
const examplesContext = includeExamples ? ', and examples' : '';
|
|
361
|
-
steps.push(`**Identify workflow components** from user request, best practices${examplesContext}`, '**Call search_nodes IN PARALLEL** for all components (e.g., "Gmail", "OpenAI", "Schedule")', '**Call get_node_details IN PARALLEL** for ALL promising nodes (batch multiple calls)', `**Extract node information** from each node_details response:
|
|
362
|
-
- Node name from <name> tag
|
|
363
|
-
- Version number from <version> tag (required - extract the number)
|
|
364
|
-
- Connection-changing parameters from <connections> section`, '**Call submit_discovery_results** with complete nodesFound array');
|
|
365
|
-
return steps.map((step, index) => `${index + 1}. ${step}`).join('\n');
|
|
344
|
+
function selectProcessSection(options) {
|
|
345
|
+
if (options.includeExamples && options.includeQuestions)
|
|
346
|
+
return PROCESS_WITH_EXAMPLES_AND_QUESTIONS;
|
|
347
|
+
if (options.includeExamples)
|
|
348
|
+
return PROCESS_WITH_EXAMPLES;
|
|
349
|
+
if (options.includeQuestions)
|
|
350
|
+
return PROCESS_WITH_QUESTIONS;
|
|
351
|
+
return PROCESS;
|
|
366
352
|
}
|
|
367
353
|
function buildDiscoveryPrompt(options) {
|
|
368
354
|
const availableTools = generateAvailableToolsList(options);
|
|
369
|
-
const processSteps = generateProcessSteps(options);
|
|
370
355
|
return (0, builder_1.prompt)()
|
|
371
|
-
.section('role',
|
|
356
|
+
.section('role', ROLE)
|
|
372
357
|
.section('available_tools', availableTools)
|
|
373
|
-
.section('process',
|
|
374
|
-
.section('
|
|
375
|
-
.
|
|
376
|
-
.section('
|
|
377
|
-
.section('
|
|
378
|
-
.section('
|
|
379
|
-
.section('connection_changing_parameters', CONNECTION_PARAMETERS)
|
|
380
|
-
.section('dynamic_output_nodes', DYNAMIC_OUTPUT_NODES)
|
|
381
|
-
.section('sub_nodes_searches', SUB_NODES_SEARCHES)
|
|
358
|
+
.section('process', selectProcessSection(options))
|
|
359
|
+
.section('tool_call_requirement', generateToolCallRequirement(options))
|
|
360
|
+
.sectionIf(options.includeQuestions, 'clarifying_questions', CLARIFYING_QUESTIONS)
|
|
361
|
+
.section('n8n_execution_model', N8N_EXECUTION_MODEL)
|
|
362
|
+
.section('baseline_flow_control', BASELINE_FLOW_CONTROL)
|
|
363
|
+
.section('trigger_selection', TRIGGER_SELECTION)
|
|
382
364
|
.section('ai_node_selection', AI_NODE_SELECTION)
|
|
383
|
-
.section('
|
|
384
|
-
.section('
|
|
385
|
-
.section('
|
|
386
|
-
.section('
|
|
365
|
+
.section('ai_tool_patterns', AI_TOOL_PATTERNS)
|
|
366
|
+
.section('node_selection_patterns', NODE_SELECTION_PATTERNS)
|
|
367
|
+
.section('flow_control_nodes', FLOW_CONTROL_NODES)
|
|
368
|
+
.section('native_node_preference', NATIVE_NODE_PREFERENCE)
|
|
369
|
+
.section('explicit_service_mapping', EXPLICIT_SERVICE_MAPPING)
|
|
370
|
+
.section('connection_parameters', CONNECTION_PARAMETERS)
|
|
371
|
+
.section('key_rules', KEY_RULES)
|
|
387
372
|
.build();
|
|
388
373
|
}
|
|
389
374
|
//# sourceMappingURL=discovery.prompt.js.map
|