@n8n/ai-workflow-builder 0.32.0 → 0.33.0-exp.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/responder.agent.d.ts +21 -0
- package/dist/agents/responder.agent.js +102 -0
- package/dist/agents/responder.agent.js.map +1 -0
- package/dist/agents/supervisor.agent.d.ts +31 -0
- package/dist/agents/supervisor.agent.js +104 -0
- package/dist/agents/supervisor.agent.js.map +1 -0
- package/dist/ai-workflow-builder-agent.service.d.ts +2 -1
- package/dist/ai-workflow-builder-agent.service.js +13 -4
- package/dist/ai-workflow-builder-agent.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/chains/prompts/examples/basic/switch-node-examples.d.ts +1 -0
- package/dist/chains/prompts/examples/basic/switch-node-examples.js +128 -0
- package/dist/chains/prompts/examples/basic/switch-node-examples.js.map +1 -0
- package/dist/chains/prompts/node-types/switch-node.d.ts +1 -0
- package/dist/chains/prompts/node-types/switch-node.js +72 -0
- package/dist/chains/prompts/node-types/switch-node.js.map +1 -0
- package/dist/chains/prompts/prompt-builder.d.ts +1 -0
- package/dist/chains/prompts/prompt-builder.js +12 -0
- package/dist/chains/prompts/prompt-builder.js.map +1 -1
- package/dist/chains/prompts/prompt-config.js +1 -0
- package/dist/chains/prompts/prompt-config.js.map +1 -1
- package/dist/constants.d.ts +6 -0
- package/dist/constants.js +7 -1
- package/dist/constants.js.map +1 -1
- package/dist/llm-config.d.ts +1 -0
- package/dist/llm-config.js +20 -1
- package/dist/llm-config.js.map +1 -1
- package/dist/multi-agent-workflow-subgraphs.d.ts +122 -0
- package/dist/multi-agent-workflow-subgraphs.js +153 -0
- package/dist/multi-agent-workflow-subgraphs.js.map +1 -0
- package/dist/parent-graph-state.d.ts +27 -0
- package/dist/parent-graph-state.js +47 -0
- package/dist/parent-graph-state.js.map +1 -0
- package/dist/subgraphs/builder.subgraph.d.ts +122 -0
- package/dist/subgraphs/builder.subgraph.js +384 -0
- package/dist/subgraphs/builder.subgraph.js.map +1 -0
- package/dist/subgraphs/configurator.subgraph.d.ts +132 -0
- package/dist/subgraphs/configurator.subgraph.js +272 -0
- package/dist/subgraphs/configurator.subgraph.js.map +1 -0
- package/dist/subgraphs/discovery.subgraph.d.ts +158 -0
- package/dist/subgraphs/discovery.subgraph.js +487 -0
- package/dist/subgraphs/discovery.subgraph.js.map +1 -0
- package/dist/subgraphs/subgraph-interface.d.ts +23 -0
- package/dist/subgraphs/subgraph-interface.js +7 -0
- package/dist/subgraphs/subgraph-interface.js.map +1 -0
- package/dist/tools/best-practices/content-generation.js +38 -2
- package/dist/tools/best-practices/content-generation.js.map +1 -1
- package/dist/tools/builder-tools.d.ts +5 -2
- package/dist/tools/builder-tools.js +15 -25
- package/dist/tools/builder-tools.js.map +1 -1
- package/dist/tools/get-best-practices.tool.d.ts +1 -1
- package/dist/tools/get-workflow-examples.tool.d.ts +34 -0
- package/dist/tools/get-workflow-examples.tool.js +172 -0
- package/dist/tools/get-workflow-examples.tool.js.map +1 -0
- package/dist/tools/node-details.tool.d.ts +4 -4
- package/dist/tools/node-details.tool.js +30 -2
- package/dist/tools/node-details.tool.js.map +1 -1
- package/dist/tools/node-search.tool.d.ts +1 -1
- package/dist/tools/prompts/main-agent.prompt.d.ts +4 -0
- package/dist/tools/prompts/main-agent.prompt.js +113 -57
- package/dist/tools/prompts/main-agent.prompt.js.map +1 -1
- package/dist/tools/utils/markdown-workflow.utils.d.ts +14 -0
- package/dist/tools/utils/markdown-workflow.utils.js +174 -0
- package/dist/tools/utils/markdown-workflow.utils.js.map +1 -0
- package/dist/tools/utils/test/workflows/ai-assistant.workflow.d.ts +2 -0
- package/dist/tools/utils/test/workflows/ai-assistant.workflow.js +541 -0
- package/dist/tools/utils/test/workflows/ai-assistant.workflow.js.map +1 -0
- package/dist/tools/validate-configuration.tool.d.ts +4 -0
- package/dist/tools/validate-configuration.tool.js +70 -0
- package/dist/tools/validate-configuration.tool.js.map +1 -0
- package/dist/tools/validate-structure.tool.d.ts +4 -0
- package/dist/tools/validate-structure.tool.js +66 -0
- package/dist/tools/validate-structure.tool.js.map +1 -0
- package/dist/tools/web/templates.d.ts +7 -0
- package/dist/tools/web/templates.js +71 -0
- package/dist/tools/web/templates.js.map +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/coordination.d.ts +42 -0
- package/dist/types/coordination.js +23 -0
- package/dist/types/coordination.js.map +1 -0
- package/dist/types/discovery-types.d.ts +14 -0
- package/dist/types/discovery-types.js +3 -0
- package/dist/types/discovery-types.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +15 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/langchain.d.ts +1 -0
- package/dist/types/langchain.js +8 -0
- package/dist/types/langchain.js.map +1 -1
- package/dist/types/tools.d.ts +20 -0
- package/dist/types/web/templates.d.ts +44 -0
- package/dist/types/web/templates.js +37 -0
- package/dist/types/web/templates.js.map +1 -0
- package/dist/utils/cache-control/helpers.d.ts +1 -0
- package/dist/utils/cache-control/helpers.js +36 -0
- package/dist/utils/cache-control/helpers.js.map +1 -1
- package/dist/utils/cache-control/index.d.ts +1 -1
- package/dist/utils/cache-control/index.js +2 -1
- package/dist/utils/cache-control/index.js.map +1 -1
- package/dist/utils/context-builders.d.ts +10 -0
- package/dist/utils/context-builders.js +71 -0
- package/dist/utils/context-builders.js.map +1 -0
- package/dist/utils/coordination-log.d.ts +15 -0
- package/dist/utils/coordination-log.js +75 -0
- package/dist/utils/coordination-log.js.map +1 -0
- package/dist/utils/operations-processor.d.ts +4 -2
- package/dist/utils/operations-processor.js.map +1 -1
- package/dist/utils/state-modifier.d.ts +32 -0
- package/dist/utils/state-modifier.js +112 -0
- package/dist/utils/state-modifier.js.map +1 -0
- package/dist/utils/state-reducers.d.ts +4 -0
- package/dist/utils/state-reducers.js +25 -0
- package/dist/utils/state-reducers.js.map +1 -0
- package/dist/utils/stream-processor.d.ts +6 -2
- package/dist/utils/stream-processor.js +138 -83
- package/dist/utils/stream-processor.js.map +1 -1
- package/dist/utils/subgraph-helpers.d.ts +16 -0
- package/dist/utils/subgraph-helpers.js +118 -0
- package/dist/utils/subgraph-helpers.js.map +1 -0
- package/dist/utils/token-usage.js +4 -1
- package/dist/utils/token-usage.js.map +1 -1
- package/dist/utils/tool-executor.js +55 -38
- package/dist/utils/tool-executor.js.map +1 -1
- package/dist/utils/workflow-validation.js +1 -0
- package/dist/utils/workflow-validation.js.map +1 -1
- package/dist/validation/checks/connections.js +6 -14
- package/dist/validation/checks/connections.js.map +1 -1
- package/dist/validation/checks/index.d.ts +2 -1
- package/dist/validation/checks/index.js +3 -1
- package/dist/validation/checks/index.js.map +1 -1
- package/dist/validation/checks/nodes.d.ts +4 -0
- package/dist/validation/checks/nodes.js +36 -0
- package/dist/validation/checks/nodes.js.map +1 -0
- package/dist/validation/checks/tools.js +0 -10
- package/dist/validation/checks/tools.js.map +1 -1
- package/dist/validation/checks/trigger.js +0 -6
- package/dist/validation/checks/trigger.js.map +1 -1
- package/dist/validation/programmatic.js +2 -0
- package/dist/validation/programmatic.js.map +1 -1
- package/dist/validation/types.d.ts +5 -1
- package/dist/validation/types.js +8 -0
- package/dist/validation/types.js.map +1 -1
- package/dist/workflow-builder-agent.d.ts +9 -0
- package/dist/workflow-builder-agent.js +44 -10
- package/dist/workflow-builder-agent.js.map +1 -1
- package/dist/workflow-state.d.ts +4 -2
- package/dist/workflow-state.js +9 -0
- package/dist/workflow-state.js.map +1 -1
- package/package.json +9 -8
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuilderSubgraph = exports.BuilderSubgraphState = void 0;
|
|
4
|
+
const prompts_1 = require("@langchain/core/prompts");
|
|
5
|
+
const langgraph_1 = require("@langchain/langgraph");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const subgraph_interface_1 = require("./subgraph-interface");
|
|
8
|
+
const add_node_tool_1 = require("../tools/add-node.tool");
|
|
9
|
+
const connect_nodes_tool_1 = require("../tools/connect-nodes.tool");
|
|
10
|
+
const remove_connection_tool_1 = require("../tools/remove-connection.tool");
|
|
11
|
+
const remove_node_tool_1 = require("../tools/remove-node.tool");
|
|
12
|
+
const validate_structure_tool_1 = require("../tools/validate-structure.tool");
|
|
13
|
+
const coordination_1 = require("../types/coordination");
|
|
14
|
+
const cache_control_1 = require("../utils/cache-control");
|
|
15
|
+
const context_builders_1 = require("../utils/context-builders");
|
|
16
|
+
const operations_processor_1 = require("../utils/operations-processor");
|
|
17
|
+
const subgraph_helpers_1 = require("../utils/subgraph-helpers");
|
|
18
|
+
const BUILDER_PROMPT = `You are a Builder Agent specialized in constructing n8n workflows.
|
|
19
|
+
|
|
20
|
+
MANDATORY EXECUTION SEQUENCE:
|
|
21
|
+
You MUST follow these steps IN ORDER. Do not skip any step.
|
|
22
|
+
|
|
23
|
+
STEP 1: CREATE NODES
|
|
24
|
+
- Call add_nodes for EVERY node needed based on discovery results
|
|
25
|
+
- Create multiple nodes in PARALLEL for efficiency
|
|
26
|
+
- Do NOT respond with text - START BUILDING immediately
|
|
27
|
+
|
|
28
|
+
STEP 2: CONNECT NODES
|
|
29
|
+
- Call connect_nodes for ALL required connections
|
|
30
|
+
- Connect multiple node pairs in PARALLEL
|
|
31
|
+
|
|
32
|
+
STEP 3: VALIDATE (REQUIRED)
|
|
33
|
+
- After ALL nodes and connections are created, call validate_structure
|
|
34
|
+
- This step is MANDATORY - you cannot finish without it
|
|
35
|
+
- If validation finds issues (missing trigger, invalid connections), fix them and validate again
|
|
36
|
+
- MAXIMUM 3 VALIDATION ATTEMPTS: After 3 calls to validate_structure, proceed to respond regardless of remaining issues
|
|
37
|
+
|
|
38
|
+
STEP 4: RESPOND TO USER
|
|
39
|
+
- Only after validation passes, provide your brief summary
|
|
40
|
+
|
|
41
|
+
⚠️ NEVER respond to the user without calling validate_structure first ⚠️
|
|
42
|
+
|
|
43
|
+
NODE CREATION:
|
|
44
|
+
Each add_nodes call creates ONE node. You must provide:
|
|
45
|
+
- nodeType: The exact type from discovery (e.g., "n8n-nodes-base.httpRequest")
|
|
46
|
+
- name: Descriptive name (e.g., "Fetch Weather Data")
|
|
47
|
+
- connectionParametersReasoning: Explain your thinking about connection parameters
|
|
48
|
+
- connectionParameters: Parameters that affect connections (or {{}} if none needed)
|
|
49
|
+
|
|
50
|
+
<workflow_configuration_node>
|
|
51
|
+
Always include a Workflow Configuration node at the start of every workflow.
|
|
52
|
+
|
|
53
|
+
The Workflow Configuration node (n8n-nodes-base.set) should be placed immediately after the trigger node and before all other processing nodes.
|
|
54
|
+
|
|
55
|
+
Placement rules:
|
|
56
|
+
- Add between trigger and first processing node
|
|
57
|
+
- Connect: Trigger → Workflow Configuration → First processing node
|
|
58
|
+
- Name it "Workflow Configuration"
|
|
59
|
+
</workflow_configuration_node>
|
|
60
|
+
|
|
61
|
+
<data_parsing_strategy>
|
|
62
|
+
For AI-generated structured data, prefer Structured Output Parser nodes over Code nodes.
|
|
63
|
+
For binary file data, use Extract From File node to extract content from files before processing.
|
|
64
|
+
Use Code nodes only for custom business logic beyond parsing.
|
|
65
|
+
|
|
66
|
+
STRUCTURED OUTPUT PARSER RULE:
|
|
67
|
+
When Discovery results include Structured Output Parser:
|
|
68
|
+
1. Create the Structured Output Parser node
|
|
69
|
+
2. Set AI Agent's hasOutputParser: true in connectionParameters
|
|
70
|
+
3. Connect: Structured Output Parser → AI Agent (ai_outputParser connection)
|
|
71
|
+
</data_parsing_strategy>
|
|
72
|
+
|
|
73
|
+
<proactive_design>
|
|
74
|
+
Anticipate workflow needs:
|
|
75
|
+
- IF nodes for conditional logic when multiple outcomes exist
|
|
76
|
+
- Set nodes for data transformation between incompatible formats
|
|
77
|
+
- Schedule Triggers for recurring tasks
|
|
78
|
+
- Error handling for external service calls
|
|
79
|
+
|
|
80
|
+
NEVER use Split In Batches nodes.
|
|
81
|
+
</proactive_design>
|
|
82
|
+
|
|
83
|
+
<node_defaults_warning>
|
|
84
|
+
CRITICAL: NEVER RELY ON DEFAULT PARAMETER VALUES FOR CONNECTIONS
|
|
85
|
+
|
|
86
|
+
Default values often hide connection inputs/outputs. You MUST explicitly configure parameters that affect connections:
|
|
87
|
+
- Vector Store: Mode parameter affects available connections - always set explicitly (e.g., mode: "insert", "retrieve", "retrieve-as-tool")
|
|
88
|
+
- AI Agent: hasOutputParser default may not match your workflow needs
|
|
89
|
+
- Document Loader: textSplittingMode affects whether it accepts a text splitter input
|
|
90
|
+
|
|
91
|
+
ALWAYS check node details and set connectionParameters explicitly.
|
|
92
|
+
</node_defaults_warning>
|
|
93
|
+
|
|
94
|
+
CONNECTION PARAMETERS EXAMPLES:
|
|
95
|
+
- Static nodes (HTTP Request, Set, Code): reasoning="Static inputs/outputs", parameters={{}}
|
|
96
|
+
- AI Agent with structured output: reasoning="hasOutputParser enables ai_outputParser input for Structured Output Parser", parameters={{ hasOutputParser: true }}
|
|
97
|
+
- Vector Store insert: reasoning="Insert mode requires document input", parameters={{ mode: "insert" }}
|
|
98
|
+
- Document Loader custom: reasoning="Custom mode enables text splitter input", parameters={{ textSplittingMode: "custom" }}
|
|
99
|
+
- Switch with routing rules: reasoning="Switch needs N outputs, creating N rules.values entries with outputKeys", parameters={{ mode: "rules", rules: {{ values: [...] }} }} - see <switch_node_pattern> for full structure
|
|
100
|
+
|
|
101
|
+
<structured_output_parser_guidance>
|
|
102
|
+
WHEN TO SET hasOutputParser: true on AI Agent:
|
|
103
|
+
- Discovery found Structured Output Parser node → MUST set hasOutputParser: true
|
|
104
|
+
- AI output will be used in conditions (IF/Switch nodes checking $json.field)
|
|
105
|
+
- AI output will be formatted/displayed (HTML emails, reports with specific sections)
|
|
106
|
+
- AI output will be stored in database/data tables with specific fields
|
|
107
|
+
- AI is classifying, scoring, or extracting specific data fields
|
|
108
|
+
</structured_output_parser_guidance>
|
|
109
|
+
|
|
110
|
+
<node_connections_understanding>
|
|
111
|
+
n8n connections flow from SOURCE (output) to TARGET (input).
|
|
112
|
+
|
|
113
|
+
Regular data flow: Source node output → Target node input
|
|
114
|
+
Example: HTTP Request → Set (HTTP Request is source, Set is target)
|
|
115
|
+
|
|
116
|
+
AI sub-nodes PROVIDE capabilities, making them the SOURCE:
|
|
117
|
+
- OpenAI Chat Model → AI Agent [ai_languageModel]
|
|
118
|
+
- Calculator Tool → AI Agent [ai_tool]
|
|
119
|
+
- Window Buffer Memory → AI Agent [ai_memory]
|
|
120
|
+
- Token Splitter → Default Data Loader [ai_textSplitter]
|
|
121
|
+
- Default Data Loader → Vector Store [ai_document]
|
|
122
|
+
- Embeddings OpenAI → Vector Store [ai_embedding]
|
|
123
|
+
</node_connections_understanding>
|
|
124
|
+
|
|
125
|
+
<agent_node_distinction>
|
|
126
|
+
Distinguish between two different agent node types:
|
|
127
|
+
|
|
128
|
+
1. **AI Agent** (@n8n/n8n-nodes-langchain.agent)
|
|
129
|
+
- Main workflow node that orchestrates AI tasks
|
|
130
|
+
- Use for: Primary AI logic, chatbots, autonomous workflows
|
|
131
|
+
|
|
132
|
+
2. **AI Agent Tool** (@n8n/n8n-nodes-langchain.agentTool)
|
|
133
|
+
- Sub-node that acts as a tool for another AI Agent
|
|
134
|
+
- Use for: Multi-agent systems where one agent calls another
|
|
135
|
+
|
|
136
|
+
Default assumption: When discovery results include "agent", use AI Agent
|
|
137
|
+
unless explicitly specified as "agent tool" or "sub-agent".
|
|
138
|
+
</agent_node_distinction>
|
|
139
|
+
|
|
140
|
+
<rag_workflow_pattern>
|
|
141
|
+
For RAG (Retrieval-Augmented Generation) workflows:
|
|
142
|
+
|
|
143
|
+
Main data flow:
|
|
144
|
+
- Data source (e.g., HTTP Request) → Vector Store [main connection]
|
|
145
|
+
|
|
146
|
+
AI capability connections:
|
|
147
|
+
- Document Loader → Vector Store [ai_document]
|
|
148
|
+
- Embeddings → Vector Store [ai_embedding]
|
|
149
|
+
- Text Splitter → Document Loader [ai_textSplitter]
|
|
150
|
+
|
|
151
|
+
Common mistake to avoid:
|
|
152
|
+
- NEVER connect Document Loader to main data outputs
|
|
153
|
+
- Document Loader is an AI sub-node that gives Vector Store document processing capability
|
|
154
|
+
</rag_workflow_pattern>
|
|
155
|
+
|
|
156
|
+
<switch_node_pattern>
|
|
157
|
+
For Switch nodes with multiple routing paths:
|
|
158
|
+
- The number of outputs is determined by the number of entries in rules.values[]
|
|
159
|
+
- You MUST create the rules.values[] array with placeholder entries for each output branch
|
|
160
|
+
- Each entry needs: conditions structure (with empty leftValue/rightValue) + renameOutput: true + descriptive outputKey
|
|
161
|
+
- Configurator will fill in the actual condition values later
|
|
162
|
+
- Use descriptive node names like "Route by Amount" or "Route by Status"
|
|
163
|
+
|
|
164
|
+
Example connectionParameters for 3-way routing:
|
|
165
|
+
{{
|
|
166
|
+
"mode": "rules",
|
|
167
|
+
"rules": {{
|
|
168
|
+
"values": [
|
|
169
|
+
{{
|
|
170
|
+
"conditions": {{
|
|
171
|
+
"options": {{ "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }},
|
|
172
|
+
"conditions": [{{ "leftValue": "", "rightValue": "", "operator": {{ "type": "string", "operation": "equals" }} }}],
|
|
173
|
+
"combinator": "and"
|
|
174
|
+
}},
|
|
175
|
+
"renameOutput": true,
|
|
176
|
+
"outputKey": "Output 1 Name"
|
|
177
|
+
}},
|
|
178
|
+
{{
|
|
179
|
+
"conditions": {{
|
|
180
|
+
"options": {{ "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }},
|
|
181
|
+
"conditions": [{{ "leftValue": "", "rightValue": "", "operator": {{ "type": "string", "operation": "equals" }} }}],
|
|
182
|
+
"combinator": "and"
|
|
183
|
+
}},
|
|
184
|
+
"renameOutput": true,
|
|
185
|
+
"outputKey": "Output 2 Name"
|
|
186
|
+
}},
|
|
187
|
+
{{
|
|
188
|
+
"conditions": {{
|
|
189
|
+
"options": {{ "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }},
|
|
190
|
+
"conditions": [{{ "leftValue": "", "rightValue": "", "operator": {{ "type": "string", "operation": "equals" }} }}],
|
|
191
|
+
"combinator": "and"
|
|
192
|
+
}},
|
|
193
|
+
"renameOutput": true,
|
|
194
|
+
"outputKey": "Output 3 Name"
|
|
195
|
+
}}
|
|
196
|
+
]
|
|
197
|
+
}}
|
|
198
|
+
}}
|
|
199
|
+
</switch_node_pattern>
|
|
200
|
+
|
|
201
|
+
<connection_type_examples>
|
|
202
|
+
**Main Connections** (regular data flow):
|
|
203
|
+
- Trigger → HTTP Request → Set → Email
|
|
204
|
+
|
|
205
|
+
**AI Language Model Connections** (ai_languageModel):
|
|
206
|
+
- OpenAI Chat Model → AI Agent
|
|
207
|
+
|
|
208
|
+
**AI Tool Connections** (ai_tool):
|
|
209
|
+
- Calculator Tool → AI Agent
|
|
210
|
+
- AI Agent Tool → AI Agent (for multi-agent systems)
|
|
211
|
+
|
|
212
|
+
**AI Document Connections** (ai_document):
|
|
213
|
+
- Document Loader → Vector Store
|
|
214
|
+
|
|
215
|
+
**AI Embedding Connections** (ai_embedding):
|
|
216
|
+
- OpenAI Embeddings → Vector Store
|
|
217
|
+
|
|
218
|
+
**AI Text Splitter Connections** (ai_textSplitter):
|
|
219
|
+
- Token Text Splitter → Document Loader
|
|
220
|
+
|
|
221
|
+
**AI Memory Connections** (ai_memory):
|
|
222
|
+
- Window Buffer Memory → AI Agent
|
|
223
|
+
|
|
224
|
+
**AI Vector Store in retrieve-as-tool mode** (ai_tool):
|
|
225
|
+
- Vector Store → AI Agent
|
|
226
|
+
</connection_type_examples>
|
|
227
|
+
|
|
228
|
+
DO NOT:
|
|
229
|
+
- Respond before calling validate_structure
|
|
230
|
+
- Skip validation even if you think structure is correct
|
|
231
|
+
- Add commentary between tool calls - execute tools silently
|
|
232
|
+
- Configure node parameters (that's the Configurator Agent's job)
|
|
233
|
+
- Search for nodes (that's the Discovery Agent's job)
|
|
234
|
+
- Make assumptions about node types - use exactly what Discovery found
|
|
235
|
+
|
|
236
|
+
RESPONSE FORMAT (only after validation):
|
|
237
|
+
Provide ONE brief text message summarizing:
|
|
238
|
+
- What nodes were added
|
|
239
|
+
- How they're connected
|
|
240
|
+
|
|
241
|
+
Example: "Created 4 nodes: Trigger → Weather → Image Generation → Email"`;
|
|
242
|
+
exports.BuilderSubgraphState = langgraph_1.Annotation.Root({
|
|
243
|
+
workflowJSON: (0, langgraph_1.Annotation)({
|
|
244
|
+
reducer: (x, y) => y ?? x,
|
|
245
|
+
default: () => ({ nodes: [], connections: {}, name: '' }),
|
|
246
|
+
}),
|
|
247
|
+
userRequest: (0, langgraph_1.Annotation)({
|
|
248
|
+
reducer: (x, y) => y ?? x,
|
|
249
|
+
default: () => '',
|
|
250
|
+
}),
|
|
251
|
+
workflowContext: (0, langgraph_1.Annotation)({
|
|
252
|
+
reducer: (x, y) => y ?? x,
|
|
253
|
+
}),
|
|
254
|
+
discoveryContext: (0, langgraph_1.Annotation)({
|
|
255
|
+
reducer: (x, y) => y ?? x,
|
|
256
|
+
default: () => null,
|
|
257
|
+
}),
|
|
258
|
+
messages: (0, langgraph_1.Annotation)({
|
|
259
|
+
reducer: (x, y) => x.concat(y),
|
|
260
|
+
default: () => [],
|
|
261
|
+
}),
|
|
262
|
+
workflowOperations: (0, langgraph_1.Annotation)({
|
|
263
|
+
reducer: (x, y) => {
|
|
264
|
+
if (y === null)
|
|
265
|
+
return [];
|
|
266
|
+
if (!y || y.length === 0)
|
|
267
|
+
return x ?? [];
|
|
268
|
+
return [...(x ?? []), ...y];
|
|
269
|
+
},
|
|
270
|
+
default: () => [],
|
|
271
|
+
}),
|
|
272
|
+
});
|
|
273
|
+
class BuilderSubgraph extends subgraph_interface_1.BaseSubgraph {
|
|
274
|
+
name = 'builder_subgraph';
|
|
275
|
+
description = 'Constructs workflow structure: creating nodes and connections';
|
|
276
|
+
create(config) {
|
|
277
|
+
const tools = [
|
|
278
|
+
(0, add_node_tool_1.createAddNodeTool)(config.parsedNodeTypes),
|
|
279
|
+
(0, connect_nodes_tool_1.createConnectNodesTool)(config.parsedNodeTypes, config.logger),
|
|
280
|
+
(0, remove_node_tool_1.createRemoveNodeTool)(config.logger),
|
|
281
|
+
(0, remove_connection_tool_1.createRemoveConnectionTool)(config.logger),
|
|
282
|
+
(0, validate_structure_tool_1.createValidateStructureTool)(config.parsedNodeTypes),
|
|
283
|
+
];
|
|
284
|
+
const toolMap = new Map(tools.map((bt) => [bt.tool.name, bt.tool]));
|
|
285
|
+
const systemPrompt = prompts_1.ChatPromptTemplate.fromMessages([
|
|
286
|
+
[
|
|
287
|
+
'system',
|
|
288
|
+
[
|
|
289
|
+
{
|
|
290
|
+
type: 'text',
|
|
291
|
+
text: BUILDER_PROMPT,
|
|
292
|
+
cache_control: { type: 'ephemeral' },
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
],
|
|
296
|
+
['placeholder', '{messages}'],
|
|
297
|
+
]);
|
|
298
|
+
if (typeof config.llm.bindTools !== 'function') {
|
|
299
|
+
throw new errors_1.LLMServiceError('LLM does not support tools', {
|
|
300
|
+
llmModel: config.llm._llmType(),
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
const agent = systemPrompt.pipe(config.llm.bindTools(tools.map((bt) => bt.tool)));
|
|
304
|
+
const callAgent = async (state) => {
|
|
305
|
+
(0, cache_control_1.applySubgraphCacheMarkers)(state.messages);
|
|
306
|
+
const response = await agent.invoke({
|
|
307
|
+
messages: state.messages,
|
|
308
|
+
});
|
|
309
|
+
return { messages: [response] };
|
|
310
|
+
};
|
|
311
|
+
const shouldContinue = (0, subgraph_helpers_1.createStandardShouldContinue)();
|
|
312
|
+
const subgraph = new langgraph_1.StateGraph(exports.BuilderSubgraphState)
|
|
313
|
+
.addNode('agent', callAgent)
|
|
314
|
+
.addNode('tools', async (state) => await (0, subgraph_helpers_1.executeSubgraphTools)(state, toolMap))
|
|
315
|
+
.addNode('process_operations', operations_processor_1.processOperations)
|
|
316
|
+
.addEdge('__start__', 'agent')
|
|
317
|
+
.addConditionalEdges('agent', shouldContinue)
|
|
318
|
+
.addEdge('tools', 'process_operations')
|
|
319
|
+
.addEdge('process_operations', 'agent');
|
|
320
|
+
return subgraph.compile();
|
|
321
|
+
}
|
|
322
|
+
transformInput(parentState) {
|
|
323
|
+
const userRequest = (0, subgraph_helpers_1.extractUserRequest)(parentState.messages);
|
|
324
|
+
const contextParts = [];
|
|
325
|
+
contextParts.push('=== USER REQUEST ===');
|
|
326
|
+
contextParts.push(userRequest);
|
|
327
|
+
if (parentState.discoveryContext) {
|
|
328
|
+
contextParts.push('=== DISCOVERY CONTEXT ===');
|
|
329
|
+
contextParts.push((0, context_builders_1.buildDiscoveryContextBlock)(parentState.discoveryContext, true));
|
|
330
|
+
}
|
|
331
|
+
contextParts.push('=== CURRENT WORKFLOW ===');
|
|
332
|
+
if (parentState.workflowJSON.nodes.length > 0) {
|
|
333
|
+
contextParts.push((0, context_builders_1.buildWorkflowJsonBlock)(parentState.workflowJSON));
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
contextParts.push('Empty workflow - ready to build');
|
|
337
|
+
}
|
|
338
|
+
const schemaBlock = (0, context_builders_1.buildExecutionSchemaBlock)(parentState.workflowContext);
|
|
339
|
+
if (schemaBlock) {
|
|
340
|
+
contextParts.push('=== AVAILABLE DATA SCHEMA ===');
|
|
341
|
+
contextParts.push(schemaBlock);
|
|
342
|
+
}
|
|
343
|
+
const contextMessage = (0, context_builders_1.createContextMessage)(contextParts);
|
|
344
|
+
return {
|
|
345
|
+
userRequest,
|
|
346
|
+
workflowJSON: parentState.workflowJSON,
|
|
347
|
+
workflowContext: parentState.workflowContext,
|
|
348
|
+
discoveryContext: parentState.discoveryContext,
|
|
349
|
+
messages: [contextMessage],
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
transformOutput(subgraphOutput, _parentState) {
|
|
353
|
+
const nodes = subgraphOutput.workflowJSON.nodes;
|
|
354
|
+
const connections = subgraphOutput.workflowJSON.connections;
|
|
355
|
+
const connectionCount = Object.values(connections).flat().length;
|
|
356
|
+
const builderSummary = subgraphOutput.messages
|
|
357
|
+
.slice()
|
|
358
|
+
.reverse()
|
|
359
|
+
.find((m) => m.content &&
|
|
360
|
+
(!('tool_calls' in m) ||
|
|
361
|
+
!m.tool_calls ||
|
|
362
|
+
(m.tool_calls && Array.isArray(m.tool_calls) && m.tool_calls.length === 0)));
|
|
363
|
+
const summaryText = typeof builderSummary?.content === 'string' ? builderSummary.content : undefined;
|
|
364
|
+
const logEntry = {
|
|
365
|
+
phase: 'builder',
|
|
366
|
+
status: 'completed',
|
|
367
|
+
timestamp: Date.now(),
|
|
368
|
+
summary: `Created ${nodes.length} nodes with ${connectionCount} connections`,
|
|
369
|
+
output: summaryText,
|
|
370
|
+
metadata: (0, coordination_1.createBuilderMetadata)({
|
|
371
|
+
nodesCreated: nodes.length,
|
|
372
|
+
connectionsCreated: connectionCount,
|
|
373
|
+
nodeNames: nodes.map((n) => n.name),
|
|
374
|
+
}),
|
|
375
|
+
};
|
|
376
|
+
return {
|
|
377
|
+
workflowJSON: subgraphOutput.workflowJSON,
|
|
378
|
+
workflowOperations: subgraphOutput.workflowOperations ?? [],
|
|
379
|
+
coordinationLog: [logEntry],
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
exports.BuilderSubgraph = BuilderSubgraph;
|
|
384
|
+
//# sourceMappingURL=builder.subgraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.subgraph.js","sourceRoot":"","sources":["../../src/subgraphs/builder.subgraph.ts"],"names":[],"mappings":";;;AAEA,qDAA6D;AAE7D,oDAA8D;AAI9D,qCAA2C;AAG3C,6DAAoD;AAEpD,0DAA2D;AAC3D,oEAAqE;AACrE,4EAA6E;AAC7E,gEAAiE;AACjE,8EAA+E;AAE/E,wDAA8D;AAG9D,0DAAmE;AACnE,gEAKmC;AACnC,wEAAkE;AAClE,gEAImC;AAKnC,MAAM,cAAc,GAAG;;;;;;;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C,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aACnC,CAAC;SACF,CAAC;QAEF,OAAO;YACN,YAAY,EAAE,cAAc,CAAC,YAAY;YACzC,kBAAkB,EAAE,cAAc,CAAC,kBAAkB,IAAI,EAAE;YAC3D,eAAe,EAAE,CAAC,QAAQ,CAAC;SAC3B,CAAC;IACH,CAAC;CACD;AAhKD,0CAgKC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
2
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
3
|
+
import type { Logger } from '@n8n/backend-common';
|
|
4
|
+
import type { INodeTypeDescription } from 'n8n-workflow';
|
|
5
|
+
import { BaseSubgraph } from './subgraph-interface';
|
|
6
|
+
import type { ParentGraphState } from '../parent-graph-state';
|
|
7
|
+
import type { CoordinationLogEntry } from '../types/coordination';
|
|
8
|
+
import type { DiscoveryContext } from '../types/discovery-types';
|
|
9
|
+
import type { SimpleWorkflow, WorkflowOperation } from '../types/workflow';
|
|
10
|
+
export declare const ConfiguratorSubgraphState: import("@langchain/langgraph").AnnotationRoot<{
|
|
11
|
+
workflowJSON: import("@langchain/langgraph").BinaryOperatorAggregate<SimpleWorkflow, SimpleWorkflow>;
|
|
12
|
+
workflowContext: import("@langchain/langgraph").BinaryOperatorAggregate<{
|
|
13
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
14
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
15
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
16
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
17
|
+
} | undefined, {
|
|
18
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
19
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
20
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
21
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
22
|
+
} | undefined>;
|
|
23
|
+
instanceUrl: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
24
|
+
userRequest: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
25
|
+
discoveryContext: import("@langchain/langgraph").BinaryOperatorAggregate<DiscoveryContext | null, DiscoveryContext | null>;
|
|
26
|
+
messages: import("@langchain/langgraph").BinaryOperatorAggregate<BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[], BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[]>;
|
|
27
|
+
workflowOperations: import("@langchain/langgraph").BinaryOperatorAggregate<WorkflowOperation[] | null, WorkflowOperation[] | null>;
|
|
28
|
+
}>;
|
|
29
|
+
export interface ConfiguratorSubgraphConfig {
|
|
30
|
+
parsedNodeTypes: INodeTypeDescription[];
|
|
31
|
+
llm: BaseChatModel;
|
|
32
|
+
logger?: Logger;
|
|
33
|
+
instanceUrl?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare class ConfiguratorSubgraph extends BaseSubgraph<ConfiguratorSubgraphConfig, typeof ConfiguratorSubgraphState.State, typeof ParentGraphState.State> {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
private agent;
|
|
39
|
+
private toolMap;
|
|
40
|
+
private instanceUrl;
|
|
41
|
+
create(config: ConfiguratorSubgraphConfig): import("@langchain/langgraph").CompiledStateGraph<{
|
|
42
|
+
workflowJSON: SimpleWorkflow;
|
|
43
|
+
workflowContext: {
|
|
44
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
45
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
46
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
47
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
48
|
+
} | undefined;
|
|
49
|
+
instanceUrl: string;
|
|
50
|
+
userRequest: string;
|
|
51
|
+
discoveryContext: DiscoveryContext | null;
|
|
52
|
+
messages: BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[];
|
|
53
|
+
workflowOperations: WorkflowOperation[] | null;
|
|
54
|
+
}, {
|
|
55
|
+
workflowJSON?: SimpleWorkflow | undefined;
|
|
56
|
+
workflowContext?: {
|
|
57
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
58
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
59
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
60
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
61
|
+
} | undefined;
|
|
62
|
+
instanceUrl?: string | undefined;
|
|
63
|
+
userRequest?: string | undefined;
|
|
64
|
+
discoveryContext?: DiscoveryContext | null | undefined;
|
|
65
|
+
messages?: BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[] | undefined;
|
|
66
|
+
workflowOperations?: WorkflowOperation[] | null | undefined;
|
|
67
|
+
}, "agent" | "tools" | "process_operations" | "__start__", {
|
|
68
|
+
workflowJSON: import("@langchain/langgraph").BinaryOperatorAggregate<SimpleWorkflow, SimpleWorkflow>;
|
|
69
|
+
workflowContext: import("@langchain/langgraph").BinaryOperatorAggregate<{
|
|
70
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
71
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
72
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
73
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
74
|
+
} | undefined, {
|
|
75
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
76
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
77
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
78
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
79
|
+
} | undefined>;
|
|
80
|
+
instanceUrl: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
81
|
+
userRequest: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
82
|
+
discoveryContext: import("@langchain/langgraph").BinaryOperatorAggregate<DiscoveryContext | null, DiscoveryContext | null>;
|
|
83
|
+
messages: import("@langchain/langgraph").BinaryOperatorAggregate<BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[], BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[]>;
|
|
84
|
+
workflowOperations: import("@langchain/langgraph").BinaryOperatorAggregate<WorkflowOperation[] | null, WorkflowOperation[] | null>;
|
|
85
|
+
}, {
|
|
86
|
+
workflowJSON: import("@langchain/langgraph").BinaryOperatorAggregate<SimpleWorkflow, SimpleWorkflow>;
|
|
87
|
+
workflowContext: import("@langchain/langgraph").BinaryOperatorAggregate<{
|
|
88
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
89
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
90
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
91
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
92
|
+
} | undefined, {
|
|
93
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
94
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
95
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
96
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
97
|
+
} | undefined>;
|
|
98
|
+
instanceUrl: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
99
|
+
userRequest: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
100
|
+
discoveryContext: import("@langchain/langgraph").BinaryOperatorAggregate<DiscoveryContext | null, DiscoveryContext | null>;
|
|
101
|
+
messages: import("@langchain/langgraph").BinaryOperatorAggregate<BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[], BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[]>;
|
|
102
|
+
workflowOperations: import("@langchain/langgraph").BinaryOperatorAggregate<WorkflowOperation[] | null, WorkflowOperation[] | null>;
|
|
103
|
+
}, import("@langchain/langgraph").StateDefinition, {
|
|
104
|
+
agent: {
|
|
105
|
+
messages: BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[];
|
|
106
|
+
};
|
|
107
|
+
tools: {
|
|
108
|
+
messages?: BaseMessage[];
|
|
109
|
+
workflowOperations?: WorkflowOperation[] | null;
|
|
110
|
+
templateIds?: number[];
|
|
111
|
+
nodeConfigurations?: import("..").NodeConfigurationsMap;
|
|
112
|
+
};
|
|
113
|
+
}, unknown, unknown>;
|
|
114
|
+
transformInput(parentState: typeof ParentGraphState.State): {
|
|
115
|
+
workflowJSON: SimpleWorkflow;
|
|
116
|
+
workflowContext: {
|
|
117
|
+
executionSchema?: import("n8n-workflow").NodeExecutionSchema[];
|
|
118
|
+
currentWorkflow?: Partial<import("n8n-workflow").IWorkflowBase>;
|
|
119
|
+
executionData?: import("n8n-workflow").IRunExecutionData["resultData"];
|
|
120
|
+
expressionValues?: Record<string, import("../workflow-builder-agent").ExpressionValue[]>;
|
|
121
|
+
} | undefined;
|
|
122
|
+
instanceUrl: string;
|
|
123
|
+
userRequest: string;
|
|
124
|
+
discoveryContext: DiscoveryContext | null;
|
|
125
|
+
messages: import("@langchain/core/messages").HumanMessage<import("@langchain/core/messages").MessageStructure>[];
|
|
126
|
+
};
|
|
127
|
+
transformOutput(subgraphOutput: typeof ConfiguratorSubgraphState.State, _parentState: typeof ParentGraphState.State): {
|
|
128
|
+
workflowJSON: SimpleWorkflow;
|
|
129
|
+
workflowOperations: WorkflowOperation[];
|
|
130
|
+
coordinationLog: CoordinationLogEntry[];
|
|
131
|
+
};
|
|
132
|
+
}
|