@n8n/ai-workflow-builder 0.32.1 → 0.33.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 +20 -0
- package/dist/agents/responder.agent.js +95 -0
- package/dist/agents/responder.agent.js.map +1 -0
- package/dist/agents/supervisor.agent.d.ts +30 -0
- package/dist/agents/supervisor.agent.js +99 -0
- package/dist/agents/supervisor.agent.js.map +1 -0
- package/dist/ai-workflow-builder-agent.service.js +4 -0
- package/dist/ai-workflow-builder-agent.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +5 -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 +85 -0
- package/dist/multi-agent-workflow-subgraphs.js +121 -0
- package/dist/multi-agent-workflow-subgraphs.js.map +1 -0
- package/dist/parent-graph-state.d.ts +23 -0
- package/dist/parent-graph-state.js +34 -0
- package/dist/parent-graph-state.js.map +1 -0
- package/dist/subgraphs/builder.subgraph.d.ts +120 -0
- package/dist/subgraphs/builder.subgraph.js +322 -0
- package/dist/subgraphs/builder.subgraph.js.map +1 -0
- package/dist/subgraphs/configurator.subgraph.d.ts +130 -0
- package/dist/subgraphs/configurator.subgraph.js +242 -0
- package/dist/subgraphs/configurator.subgraph.js.map +1 -0
- package/dist/subgraphs/discovery.subgraph.d.ts +140 -0
- package/dist/subgraphs/discovery.subgraph.js +415 -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/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/coordination.d.ts +36 -0
- package/dist/types/coordination.js +19 -0
- package/dist/types/coordination.js.map +1 -0
- package/dist/types/discovery-types.d.ts +12 -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 +14 -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/stream-processor.d.ts +6 -2
- package/dist/utils/stream-processor.js +164 -81
- package/dist/utils/stream-processor.js.map +1 -1
- package/dist/utils/subgraph-helpers.d.ts +13 -0
- package/dist/utils/subgraph-helpers.js +95 -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/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/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 +8 -0
- package/dist/workflow-builder-agent.js +38 -9
- package/dist/workflow-builder-agent.js.map +1 -1
- package/dist/workflow-state.d.ts +4 -2
- package/dist/workflow-state.js +20 -0
- package/dist/workflow-state.js.map +1 -1
- package/package.json +9 -8
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscoverySubgraph = exports.DiscoverySubgraphState = void 0;
|
|
4
|
+
const messages_1 = require("@langchain/core/messages");
|
|
5
|
+
const prompts_1 = require("@langchain/core/prompts");
|
|
6
|
+
const tools_1 = require("@langchain/core/tools");
|
|
7
|
+
const langgraph_1 = require("@langchain/langgraph");
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const errors_1 = require("../errors");
|
|
10
|
+
const categorization_1 = require("../types/categorization");
|
|
11
|
+
const subgraph_interface_1 = require("./subgraph-interface");
|
|
12
|
+
const get_best_practices_tool_1 = require("../tools/get-best-practices.tool");
|
|
13
|
+
const node_details_tool_1 = require("../tools/node-details.tool");
|
|
14
|
+
const node_search_tool_1 = require("../tools/node-search.tool");
|
|
15
|
+
const coordination_1 = require("../types/coordination");
|
|
16
|
+
const cache_control_1 = require("../utils/cache-control");
|
|
17
|
+
const context_builders_1 = require("../utils/context-builders");
|
|
18
|
+
const subgraph_helpers_1 = require("../utils/subgraph-helpers");
|
|
19
|
+
const exampleCategorizations = [
|
|
20
|
+
{
|
|
21
|
+
prompt: 'Monitor social channels for product mentions and auto-respond with campaign messages',
|
|
22
|
+
techniques: [
|
|
23
|
+
categorization_1.WorkflowTechnique.MONITORING,
|
|
24
|
+
categorization_1.WorkflowTechnique.CHATBOT,
|
|
25
|
+
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
prompt: 'Collect partner referral submissions and verify client instances via BigQuery',
|
|
30
|
+
techniques: [
|
|
31
|
+
categorization_1.WorkflowTechnique.FORM_INPUT,
|
|
32
|
+
categorization_1.WorkflowTechnique.HUMAN_IN_THE_LOOP,
|
|
33
|
+
categorization_1.WorkflowTechnique.NOTIFICATION,
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
prompt: 'Scrape competitor pricing pages weekly and generate a summary report of changes',
|
|
38
|
+
techniques: [
|
|
39
|
+
categorization_1.WorkflowTechnique.SCHEDULING,
|
|
40
|
+
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
41
|
+
categorization_1.WorkflowTechnique.DATA_EXTRACTION,
|
|
42
|
+
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
prompt: 'Process uploaded PDF contracts to extract client details and update CRM records',
|
|
47
|
+
techniques: [
|
|
48
|
+
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
49
|
+
categorization_1.WorkflowTechnique.DATA_EXTRACTION,
|
|
50
|
+
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
51
|
+
categorization_1.WorkflowTechnique.ENRICHMENT,
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
prompt: 'Build a searchable internal knowledge base from past support tickets',
|
|
56
|
+
techniques: [
|
|
57
|
+
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
58
|
+
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
59
|
+
categorization_1.WorkflowTechnique.KNOWLEDGE_BASE,
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
prompt: 'Create an AI agent that writes and sends personalized emails to leads',
|
|
64
|
+
techniques: [categorization_1.WorkflowTechnique.CONTENT_GENERATION, categorization_1.WorkflowTechnique.NOTIFICATION],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
prompt: 'Fetch trending topics from Google Trends and Reddit, select the best ones, and create social posts',
|
|
68
|
+
techniques: [
|
|
69
|
+
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
70
|
+
categorization_1.WorkflowTechnique.TRIAGE,
|
|
71
|
+
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
prompt: 'Trigger when a new contact is created in HubSpot and enrich their profile with LinkedIn data',
|
|
76
|
+
techniques: [categorization_1.WorkflowTechnique.MONITORING, categorization_1.WorkflowTechnique.ENRICHMENT],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
prompt: 'Get stock prices from financial APIs and analyze volatility patterns',
|
|
80
|
+
techniques: [categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH, categorization_1.WorkflowTechnique.DATA_ANALYSIS],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
prompt: 'Generate video reels from templates and auto-post to social media on schedule',
|
|
84
|
+
techniques: [
|
|
85
|
+
categorization_1.WorkflowTechnique.SCHEDULING,
|
|
86
|
+
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
87
|
+
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
prompt: 'Receive news from Telegram channels, filter relevant ones, and forward to my channel',
|
|
92
|
+
techniques: [
|
|
93
|
+
categorization_1.WorkflowTechnique.MONITORING,
|
|
94
|
+
categorization_1.WorkflowTechnique.TRIAGE,
|
|
95
|
+
categorization_1.WorkflowTechnique.NOTIFICATION,
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
prompt: 'Analyze YouTube video performance data and generate a weekly report',
|
|
100
|
+
techniques: [
|
|
101
|
+
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
102
|
+
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
103
|
+
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
prompt: 'Create a chatbot that answers questions using data from a Google Sheet as knowledge base',
|
|
108
|
+
techniques: [categorization_1.WorkflowTechnique.CHATBOT, categorization_1.WorkflowTechnique.KNOWLEDGE_BASE],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
prompt: 'Form submission with file upload triggers document extraction and approval workflow',
|
|
112
|
+
techniques: [
|
|
113
|
+
categorization_1.WorkflowTechnique.FORM_INPUT,
|
|
114
|
+
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
115
|
+
categorization_1.WorkflowTechnique.HUMAN_IN_THE_LOOP,
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
function formatTechniqueList() {
|
|
120
|
+
return Object.entries(categorization_1.TechniqueDescription)
|
|
121
|
+
.map(([key, description]) => `- **${key}**: ${description}`)
|
|
122
|
+
.join('\n');
|
|
123
|
+
}
|
|
124
|
+
function formatExampleCategorizations() {
|
|
125
|
+
return exampleCategorizations
|
|
126
|
+
.map((example) => `- ${example.prompt} → ${example.techniques.join(', ')}`)
|
|
127
|
+
.join('\n');
|
|
128
|
+
}
|
|
129
|
+
const discoveryOutputSchema = zod_1.z.object({
|
|
130
|
+
nodesFound: zod_1.z
|
|
131
|
+
.array(zod_1.z.object({
|
|
132
|
+
nodeName: zod_1.z.string().describe('The internal name of the node (e.g., n8n-nodes-base.gmail)'),
|
|
133
|
+
version: zod_1.z
|
|
134
|
+
.number()
|
|
135
|
+
.describe('The version number of the node (e.g., 1, 1.1, 2, 3, 3.2, etc.)'),
|
|
136
|
+
reasoning: zod_1.z.string().describe('Why this node is relevant for the workflow'),
|
|
137
|
+
connectionChangingParameters: zod_1.z
|
|
138
|
+
.array(zod_1.z.object({
|
|
139
|
+
name: zod_1.z
|
|
140
|
+
.string()
|
|
141
|
+
.describe('Parameter name (e.g., "mode", "operation", "hasOutputParser")'),
|
|
142
|
+
possibleValues: zod_1.z
|
|
143
|
+
.array(zod_1.z.union([zod_1.z.string(), zod_1.z.boolean(), zod_1.z.number()]))
|
|
144
|
+
.describe('Possible values this parameter can take'),
|
|
145
|
+
}))
|
|
146
|
+
.describe('Parameters that affect node connections (inputs/outputs). ONLY include if parameter appears in <input> or <output> expressions'),
|
|
147
|
+
}))
|
|
148
|
+
.describe('List of n8n nodes identified as necessary for the workflow'),
|
|
149
|
+
});
|
|
150
|
+
const DISCOVERY_PROMPT = `You are a Discovery Agent for n8n AI Workflow Builder.
|
|
151
|
+
|
|
152
|
+
YOUR ROLE: Identify relevant n8n nodes and their connection-changing parameters.
|
|
153
|
+
|
|
154
|
+
AVAILABLE TOOLS:
|
|
155
|
+
- get_best_practices: Retrieve best practices (internal context)
|
|
156
|
+
- search_nodes: Find n8n nodes by keyword
|
|
157
|
+
- get_node_details: Get complete node information including <connections>
|
|
158
|
+
- submit_discovery_results: Submit final results
|
|
159
|
+
|
|
160
|
+
PROCESS:
|
|
161
|
+
1. **Call get_best_practices** with identified techniques (internal context)
|
|
162
|
+
2. **Identify workflow components** from user request and best practices
|
|
163
|
+
3. **Call search_nodes IN PARALLEL** for all components (e.g., "Gmail", "OpenAI", "Schedule")
|
|
164
|
+
4. **Call get_node_details IN PARALLEL** for ALL promising nodes (batch multiple calls)
|
|
165
|
+
5. **Extract node information** from each node_details response:
|
|
166
|
+
- Node name from <name> tag
|
|
167
|
+
- Version number from <version> tag (required - extract the number)
|
|
168
|
+
- Connection-changing parameters from <connections> section
|
|
169
|
+
6. **Call submit_discovery_results** with complete nodesFound array
|
|
170
|
+
|
|
171
|
+
TECHNIQUE CATEGORIZATION:
|
|
172
|
+
When calling get_best_practices, select techniques that match the user's workflow intent.
|
|
173
|
+
|
|
174
|
+
<available_techniques>
|
|
175
|
+
{techniques}
|
|
176
|
+
</available_techniques>
|
|
177
|
+
|
|
178
|
+
<example_categorizations>
|
|
179
|
+
{exampleCategorizations}
|
|
180
|
+
</example_categorizations>
|
|
181
|
+
|
|
182
|
+
<technique_clarifications>
|
|
183
|
+
Common distinctions to get right:
|
|
184
|
+
- **NOTIFICATION vs CHATBOT**: Use NOTIFICATION when SENDING emails/messages/alerts (including to Telegram CHANNELS which are broadcast-only). Use CHATBOT only when RECEIVING and REPLYING to direct messages in a conversation.
|
|
185
|
+
- **MONITORING**: Use when workflow TRIGGERS on external events (new record created, status changed, incoming webhook, new message in channel). NOT just scheduled runs.
|
|
186
|
+
- **SCRAPING_AND_RESEARCH vs DATA_EXTRACTION**: Use SCRAPING when fetching from EXTERNAL sources (APIs, websites, social media). Use DATA_EXTRACTION for parsing INTERNAL data you already have.
|
|
187
|
+
- **TRIAGE**: Use when SELECTING, PRIORITIZING, ROUTING, or QUALIFYING items (e.g., "pick the best", "route to correct team", "qualify leads").
|
|
188
|
+
- **DOCUMENT_PROCESSING**: Use for ANY file handling - PDFs, images, videos, Excel, Google Sheets, audio files, file uploads in forms.
|
|
189
|
+
- **HUMAN_IN_THE_LOOP**: Use when workflow PAUSES for human approval, review, signing documents, responding to polls, or any manual input before continuing.
|
|
190
|
+
- **DATA_ANALYSIS**: Use when ANALYZING, CLASSIFYING, IDENTIFYING PATTERNS, or UNDERSTANDING data (e.g., "analyze outcomes", "learn from previous", "classify by type", "identify trends").
|
|
191
|
+
- **KNOWLEDGE_BASE**: Use when storing/retrieving from a DATA SOURCE for Q&A - includes vector DBs, spreadsheets used as databases, document collections.
|
|
192
|
+
- **DATA_TRANSFORMATION**: Use when CONVERTING data format, creating REPORTS/SUMMARIES from analyzed data, or restructuring output.
|
|
193
|
+
</technique_clarifications>
|
|
194
|
+
|
|
195
|
+
Technique selection rules:
|
|
196
|
+
- Select ALL techniques that apply (most workflows use 2-4)
|
|
197
|
+
- Maximum 5 techniques
|
|
198
|
+
- Only select techniques you're confident apply
|
|
199
|
+
|
|
200
|
+
CONNECTION-CHANGING PARAMETERS - CRITICAL RULES:
|
|
201
|
+
|
|
202
|
+
A parameter is connection-changing ONLY IF it appears in <input> or <output> expressions within <node_details>.
|
|
203
|
+
|
|
204
|
+
**How to identify:**
|
|
205
|
+
1. Look at the <connections> section in node details
|
|
206
|
+
2. Check if <input> or <output> uses expressions like: ={{...parameterName...}}
|
|
207
|
+
3. If a parameter is referenced in these expressions, it IS connection-changing
|
|
208
|
+
4. If a parameter is NOT in <input>/<output> expressions, it is NOT connection-changing
|
|
209
|
+
|
|
210
|
+
**Example from AI Agent:**
|
|
211
|
+
\`\`\`xml
|
|
212
|
+
<input>={{...hasOutputParser, needsFallback...}}</input>
|
|
213
|
+
\`\`\`
|
|
214
|
+
→ hasOutputParser and needsFallback ARE connection-changing (they control which inputs appear)
|
|
215
|
+
|
|
216
|
+
**Counter-example:**
|
|
217
|
+
\`\`\`xml
|
|
218
|
+
<properties>
|
|
219
|
+
<property name="promptType">...</property> <!-- NOT in <input>/<output> -->
|
|
220
|
+
<property name="systemMessage">...</property> <!-- NOT in <input>/<output> -->
|
|
221
|
+
</properties>
|
|
222
|
+
\`\`\`
|
|
223
|
+
→ promptType and systemMessage are NOT connection-changing (they don't affect connections)
|
|
224
|
+
|
|
225
|
+
**Common connection-changing parameters:**
|
|
226
|
+
- Vector Store: mode (appears in <input>/<output> expressions)
|
|
227
|
+
- AI Agent: hasOutputParser, needsFallback (appears in <input> expression)
|
|
228
|
+
- Merge: numberInputs (appears in <input> expression)
|
|
229
|
+
- Webhook: responseMode (appears in <output> expression)
|
|
230
|
+
|
|
231
|
+
SUB-NODES SEARCHES:
|
|
232
|
+
When searching for AI nodes, ALSO search for their required sub-nodes:
|
|
233
|
+
- "AI Agent" → also search for "Chat Model", "Memory", "Output Parser"
|
|
234
|
+
- "Basic LLM Chain" → also search for "Chat Model", "Output Parser"
|
|
235
|
+
- "Vector Store" → also search for "Embeddings", "Document Loader"
|
|
236
|
+
- Always use search_nodes to find the exact node names and versions - NEVER guess versions
|
|
237
|
+
|
|
238
|
+
CRITICAL RULES:
|
|
239
|
+
- NEVER ask clarifying questions
|
|
240
|
+
- ALWAYS call get_best_practices first
|
|
241
|
+
- THEN Call search_nodes to learn about available nodes and their inputs and outputs
|
|
242
|
+
- FINALLY call get_node_details IN PARALLEL for speed to get more details about RELVANT node
|
|
243
|
+
- ALWAYS extract version number from <version> tag in node details
|
|
244
|
+
- NEVER guess node versions - always use search_nodes to find exact versions
|
|
245
|
+
- ONLY flag connectionChangingParameters if they appear in <input> or <output> expressions
|
|
246
|
+
- If no parameters appear in connection expressions, return empty array []
|
|
247
|
+
- Output ONLY: nodesFound with {{ nodeName, version, reasoning, connectionChangingParameters }}
|
|
248
|
+
|
|
249
|
+
DO NOT:
|
|
250
|
+
- Output text commentary between tool calls
|
|
251
|
+
- Include bestPractices or categorization in submit_discovery_results
|
|
252
|
+
- Flag parameters that don't affect connections
|
|
253
|
+
- Stop without calling submit_discovery_results
|
|
254
|
+
`;
|
|
255
|
+
exports.DiscoverySubgraphState = langgraph_1.Annotation.Root({
|
|
256
|
+
userRequest: (0, langgraph_1.Annotation)({
|
|
257
|
+
reducer: (x, y) => y ?? x,
|
|
258
|
+
default: () => '',
|
|
259
|
+
}),
|
|
260
|
+
messages: (0, langgraph_1.Annotation)({
|
|
261
|
+
reducer: (x, y) => x.concat(y),
|
|
262
|
+
default: () => [],
|
|
263
|
+
}),
|
|
264
|
+
nodesFound: (0, langgraph_1.Annotation)({
|
|
265
|
+
reducer: (x, y) => y ?? x,
|
|
266
|
+
default: () => [],
|
|
267
|
+
}),
|
|
268
|
+
bestPractices: (0, langgraph_1.Annotation)({
|
|
269
|
+
reducer: (x, y) => y ?? x,
|
|
270
|
+
}),
|
|
271
|
+
});
|
|
272
|
+
class DiscoverySubgraph extends subgraph_interface_1.BaseSubgraph {
|
|
273
|
+
name = 'discovery_subgraph';
|
|
274
|
+
description = 'Discovers nodes and context for the workflow';
|
|
275
|
+
agent;
|
|
276
|
+
toolMap;
|
|
277
|
+
logger;
|
|
278
|
+
create(config) {
|
|
279
|
+
this.logger = config.logger;
|
|
280
|
+
const tools = [
|
|
281
|
+
(0, get_best_practices_tool_1.createGetBestPracticesTool)(),
|
|
282
|
+
(0, node_search_tool_1.createNodeSearchTool)(config.parsedNodeTypes),
|
|
283
|
+
(0, node_details_tool_1.createNodeDetailsTool)(config.parsedNodeTypes),
|
|
284
|
+
];
|
|
285
|
+
this.toolMap = new Map(tools.map((bt) => [bt.tool.name, bt.tool]));
|
|
286
|
+
const submitTool = (0, tools_1.tool)(() => { }, {
|
|
287
|
+
name: 'submit_discovery_results',
|
|
288
|
+
description: 'Submit the final discovery results',
|
|
289
|
+
schema: discoveryOutputSchema,
|
|
290
|
+
});
|
|
291
|
+
const systemPrompt = prompts_1.ChatPromptTemplate.fromMessages([
|
|
292
|
+
[
|
|
293
|
+
'system',
|
|
294
|
+
[
|
|
295
|
+
{
|
|
296
|
+
type: 'text',
|
|
297
|
+
text: DISCOVERY_PROMPT,
|
|
298
|
+
cache_control: { type: 'ephemeral' },
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
],
|
|
302
|
+
['human', '{prompt}'],
|
|
303
|
+
['placeholder', '{messages}'],
|
|
304
|
+
]);
|
|
305
|
+
if (typeof config.llm.bindTools !== 'function') {
|
|
306
|
+
throw new errors_1.LLMServiceError('LLM does not support tools', {
|
|
307
|
+
llmModel: config.llm._llmType(),
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
const allTools = [...tools.map((bt) => bt.tool), submitTool];
|
|
311
|
+
this.agent = systemPrompt.pipe(config.llm.bindTools(allTools));
|
|
312
|
+
const subgraph = new langgraph_1.StateGraph(exports.DiscoverySubgraphState)
|
|
313
|
+
.addNode('agent', this.callAgent.bind(this))
|
|
314
|
+
.addNode('tools', async (state) => await (0, subgraph_helpers_1.executeSubgraphTools)(state, this.toolMap))
|
|
315
|
+
.addNode('format_output', this.formatOutput.bind(this))
|
|
316
|
+
.addEdge('__start__', 'agent')
|
|
317
|
+
.addConditionalEdges('agent', this.shouldContinue.bind(this), {
|
|
318
|
+
tools: 'tools',
|
|
319
|
+
format_output: 'format_output',
|
|
320
|
+
end: langgraph_1.END,
|
|
321
|
+
})
|
|
322
|
+
.addEdge('tools', 'agent')
|
|
323
|
+
.addEdge('format_output', langgraph_1.END);
|
|
324
|
+
return subgraph.compile();
|
|
325
|
+
}
|
|
326
|
+
async callAgent(state) {
|
|
327
|
+
if (state.messages.length > 0) {
|
|
328
|
+
(0, cache_control_1.applySubgraphCacheMarkers)(state.messages);
|
|
329
|
+
}
|
|
330
|
+
const response = (await this.agent.invoke({
|
|
331
|
+
messages: state.messages,
|
|
332
|
+
prompt: state.userRequest,
|
|
333
|
+
techniques: formatTechniqueList(),
|
|
334
|
+
exampleCategorizations: formatExampleCategorizations(),
|
|
335
|
+
}));
|
|
336
|
+
return { messages: [response] };
|
|
337
|
+
}
|
|
338
|
+
formatOutput(state) {
|
|
339
|
+
const lastMessage = state.messages.at(-1);
|
|
340
|
+
let output;
|
|
341
|
+
if (lastMessage && (0, messages_1.isAIMessage)(lastMessage) && lastMessage.tool_calls) {
|
|
342
|
+
const submitCall = lastMessage.tool_calls.find((tc) => tc.name === 'submit_discovery_results');
|
|
343
|
+
if (submitCall) {
|
|
344
|
+
output = submitCall.args;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (!output) {
|
|
348
|
+
this.logger?.error('[Discovery] No submit tool call found in last message');
|
|
349
|
+
return {
|
|
350
|
+
nodesFound: [],
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
const bestPracticesTool = state.messages.find((m) => m.getType() === 'tool' && m?.text?.startsWith('<best_practices>'));
|
|
354
|
+
return {
|
|
355
|
+
nodesFound: output.nodesFound,
|
|
356
|
+
bestPractices: bestPracticesTool?.text,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
shouldContinue(state) {
|
|
360
|
+
const lastMessage = state.messages[state.messages.length - 1];
|
|
361
|
+
if (lastMessage &&
|
|
362
|
+
(0, messages_1.isAIMessage)(lastMessage) &&
|
|
363
|
+
lastMessage.tool_calls &&
|
|
364
|
+
lastMessage.tool_calls.length > 0) {
|
|
365
|
+
const submitCall = lastMessage.tool_calls.find((tc) => tc.name === 'submit_discovery_results');
|
|
366
|
+
if (submitCall) {
|
|
367
|
+
return 'format_output';
|
|
368
|
+
}
|
|
369
|
+
return 'tools';
|
|
370
|
+
}
|
|
371
|
+
this.logger?.warn('[Discovery Subgraph] Agent stopped without submitting results');
|
|
372
|
+
return 'end';
|
|
373
|
+
}
|
|
374
|
+
transformInput(parentState) {
|
|
375
|
+
const userRequest = (0, subgraph_helpers_1.extractUserRequest)(parentState.messages, 'Build a workflow');
|
|
376
|
+
const contextParts = [];
|
|
377
|
+
contextParts.push('<user_request>');
|
|
378
|
+
contextParts.push(userRequest);
|
|
379
|
+
contextParts.push('</user_request>');
|
|
380
|
+
if (parentState.workflowJSON.nodes.length > 0) {
|
|
381
|
+
contextParts.push('<existing_workflow_summary>');
|
|
382
|
+
contextParts.push((0, context_builders_1.buildWorkflowSummary)(parentState.workflowJSON));
|
|
383
|
+
contextParts.push('</existing_workflow_summary>');
|
|
384
|
+
}
|
|
385
|
+
const contextMessage = (0, context_builders_1.createContextMessage)(contextParts);
|
|
386
|
+
return {
|
|
387
|
+
userRequest,
|
|
388
|
+
messages: [contextMessage],
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
transformOutput(subgraphOutput, _parentState) {
|
|
392
|
+
const nodesFound = subgraphOutput.nodesFound || [];
|
|
393
|
+
const discoveryContext = {
|
|
394
|
+
nodesFound,
|
|
395
|
+
bestPractices: subgraphOutput.bestPractices,
|
|
396
|
+
};
|
|
397
|
+
const logEntry = {
|
|
398
|
+
phase: 'discovery',
|
|
399
|
+
status: 'completed',
|
|
400
|
+
timestamp: Date.now(),
|
|
401
|
+
summary: `Discovered ${nodesFound.length} nodes`,
|
|
402
|
+
metadata: (0, coordination_1.createDiscoveryMetadata)({
|
|
403
|
+
nodesFound: nodesFound.length,
|
|
404
|
+
nodeTypes: nodesFound.map((n) => n.nodeName),
|
|
405
|
+
hasBestPractices: !!subgraphOutput.bestPractices,
|
|
406
|
+
}),
|
|
407
|
+
};
|
|
408
|
+
return {
|
|
409
|
+
discoveryContext,
|
|
410
|
+
coordinationLog: [logEntry],
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
exports.DiscoverySubgraph = DiscoverySubgraph;
|
|
415
|
+
//# sourceMappingURL=discovery.subgraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.subgraph.js","sourceRoot":"","sources":["../../src/subgraphs/discovery.subgraph.ts"],"names":[],"mappings":";;;AAEA,uDAAuD;AACvD,qDAA6D;AAE7D,iDAAkE;AAClE,oDAAmE;AAGnE,6BAAwB;AAExB,qCAA2C;AAC3C,2DAIgC;AAEhC,6DAAoD;AAEpD,8EAA8E;AAC9E,kEAAmE;AACnE,gEAAiE;AAEjE,wDAAgE;AAChE,0DAAmE;AACnE,gEAAuF;AACvF,gEAAqF;AAMrF,MAAM,sBAAsB,GAGvB;IACJ;QACC,MAAM,EAAE,sFAAsF;QAC9F,UAAU,EAAE;YACX,kCAAiB,CAAC,UAAU;YAC5B,kCAAiB,CAAC,OAAO;YACzB,kCAAiB,CAAC,kBAAkB;SACpC;KACD;IACD;QACC,MAAM,EAAE,+EAA+E;QACvF,UAAU,EAAE;YACX,kCAAiB,CAAC,UAAU;YAC5B,kCAAiB,CAAC,iBAAiB;YACnC,kCAAiB,CAAC,YAAY;SAC9B;KACD;IACD;QACC,MAAM,EAAE,iFAAiF;QACzF,UAAU,EAAE;YACX,kCAAiB,CAAC,UAAU;YAC5B,kCAAiB,CAAC,qBAAqB;YACvC,kCAAiB,CAAC,eAAe;YACjC,kCAAiB,CAAC,aAAa;SAC/B;KACD;IACD;QACC,MAAM,EAAE,iFAAiF;QACzF,UAAU,EAAE;YACX,kCAAiB,CAAC,mBAAmB;YACrC,kCAAiB,CAAC,eAAe;YACjC,kCAAiB,CAAC,mBAAmB;YACrC,kCAAiB,CAAC,U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G;YACxB,UAAU;YACV,aAAa,EAAE,cAAc,CAAC,aAAa;SAC3C,CAAC;QAGF,MAAM,QAAQ,GAAyB;YACtC,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,OAAO,EAAE,cAAc,UAAU,CAAC,MAAM,QAAQ;YAChD,QAAQ,EAAE,IAAA,sCAAuB,EAAC;gBACjC,UAAU,EAAE,UAAU,CAAC,MAAM;gBAC7B,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;gBAC5C,gBAAgB,EAAE,CAAC,CAAC,cAAc,CAAC,aAAa;aAChD,CAAC;SACF,CAAC;QAEF,OAAO;YACN,gBAAgB;YAChB,eAAe,EAAE,CAAC,QAAQ,CAAC;SAC3B,CAAC;IACH,CAAC;CACD;AAtND,8CAsNC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type StateRecord = Record<string, unknown>;
|
|
2
|
+
interface InvokeConfig {
|
|
3
|
+
recursionLimit?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ISubgraph<TConfig = unknown, TChildState extends StateRecord = StateRecord, TParentState extends StateRecord = StateRecord> {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
create(config: TConfig): {
|
|
9
|
+
invoke: (input: Partial<TChildState>, config?: InvokeConfig) => Promise<TChildState>;
|
|
10
|
+
};
|
|
11
|
+
transformInput: (parentState: TParentState) => Partial<TChildState>;
|
|
12
|
+
transformOutput: (childOutput: TChildState, parentState: TParentState) => Partial<TParentState>;
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class BaseSubgraph<TConfig = unknown, TChildState extends StateRecord = StateRecord, TParentState extends StateRecord = StateRecord> implements ISubgraph<TConfig, TChildState, TParentState> {
|
|
15
|
+
abstract name: string;
|
|
16
|
+
abstract description: string;
|
|
17
|
+
abstract create(config: TConfig): {
|
|
18
|
+
invoke: (input: Partial<TChildState>, config?: InvokeConfig) => Promise<TChildState>;
|
|
19
|
+
};
|
|
20
|
+
abstract transformInput(parentState: TParentState): Partial<TChildState>;
|
|
21
|
+
abstract transformOutput(childOutput: TChildState, parentState: TParentState): Partial<TParentState>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph-interface.js","sourceRoot":"","sources":["../../src/subgraphs/subgraph-interface.ts"],"names":[],"mappings":";;;AAoBA,MAAsB,YAAY;CA2BjC;AA3BD,oCA2BC"}
|
|
@@ -2,12 +2,15 @@ import type { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
|
|
2
2
|
import type { Logger } from '@n8n/backend-common';
|
|
3
3
|
import type { INodeTypeDescription } from 'n8n-workflow';
|
|
4
4
|
import type { BuilderTool, BuilderToolBase } from '../utils/stream-processor';
|
|
5
|
-
|
|
5
|
+
import type { BuilderFeatureFlags } from '../workflow-builder-agent';
|
|
6
|
+
export declare function getBuilderTools({ parsedNodeTypes, logger, llmComplexTask, instanceUrl, featureFlags, }: {
|
|
6
7
|
parsedNodeTypes: INodeTypeDescription[];
|
|
7
8
|
llmComplexTask: BaseChatModel;
|
|
8
9
|
logger?: Logger;
|
|
9
10
|
instanceUrl?: string;
|
|
11
|
+
featureFlags?: BuilderFeatureFlags;
|
|
10
12
|
}): BuilderTool[];
|
|
11
|
-
export declare function getBuilderToolsForDisplay({ nodeTypes, }: {
|
|
13
|
+
export declare function getBuilderToolsForDisplay({ nodeTypes, featureFlags, }: {
|
|
12
14
|
nodeTypes: INodeTypeDescription[];
|
|
15
|
+
featureFlags?: BuilderFeatureFlags;
|
|
13
16
|
}): BuilderToolBase[];
|
|
@@ -7,40 +7,30 @@ const categorize_prompt_tool_1 = require("./categorize-prompt.tool");
|
|
|
7
7
|
const connect_nodes_tool_1 = require("./connect-nodes.tool");
|
|
8
8
|
const get_best_practices_tool_1 = require("./get-best-practices.tool");
|
|
9
9
|
const get_node_parameter_tool_1 = require("./get-node-parameter.tool");
|
|
10
|
+
const get_workflow_examples_tool_1 = require("./get-workflow-examples.tool");
|
|
10
11
|
const node_details_tool_1 = require("./node-details.tool");
|
|
11
12
|
const node_search_tool_1 = require("./node-search.tool");
|
|
12
13
|
const remove_connection_tool_1 = require("./remove-connection.tool");
|
|
13
14
|
const remove_node_tool_1 = require("./remove-node.tool");
|
|
14
15
|
const update_node_parameters_tool_1 = require("./update-node-parameters.tool");
|
|
15
16
|
const validate_workflow_tool_1 = require("./validate-workflow.tool");
|
|
16
|
-
function getBuilderTools({ parsedNodeTypes, logger, llmComplexTask, instanceUrl, }) {
|
|
17
|
-
|
|
17
|
+
function getBuilderTools({ parsedNodeTypes, logger, llmComplexTask, instanceUrl, featureFlags, }) {
|
|
18
|
+
const tools = [
|
|
18
19
|
(0, categorize_prompt_tool_1.createCategorizePromptTool)(llmComplexTask, logger),
|
|
19
20
|
(0, get_best_practices_tool_1.createGetBestPracticesTool)(),
|
|
20
|
-
(0, node_search_tool_1.createNodeSearchTool)(parsedNodeTypes),
|
|
21
|
-
(0, node_details_tool_1.createNodeDetailsTool)(parsedNodeTypes),
|
|
22
|
-
(0, add_node_tool_1.createAddNodeTool)(parsedNodeTypes),
|
|
23
|
-
(0, connect_nodes_tool_1.createConnectNodesTool)(parsedNodeTypes, logger),
|
|
24
|
-
(0, remove_connection_tool_1.createRemoveConnectionTool)(logger),
|
|
25
|
-
(0, remove_node_tool_1.createRemoveNodeTool)(logger),
|
|
26
|
-
(0, update_node_parameters_tool_1.createUpdateNodeParametersTool)(parsedNodeTypes, llmComplexTask, logger, instanceUrl),
|
|
27
|
-
(0, get_node_parameter_tool_1.createGetNodeParameterTool)(),
|
|
28
|
-
(0, validate_workflow_tool_1.createValidateWorkflowTool)(parsedNodeTypes, logger),
|
|
29
21
|
];
|
|
22
|
+
if (featureFlags?.templateExamples === true) {
|
|
23
|
+
tools.push((0, get_workflow_examples_tool_1.createGetWorkflowExamplesTool)(logger));
|
|
24
|
+
}
|
|
25
|
+
tools.push((0, node_search_tool_1.createNodeSearchTool)(parsedNodeTypes), (0, node_details_tool_1.createNodeDetailsTool)(parsedNodeTypes), (0, add_node_tool_1.createAddNodeTool)(parsedNodeTypes), (0, connect_nodes_tool_1.createConnectNodesTool)(parsedNodeTypes, logger), (0, remove_connection_tool_1.createRemoveConnectionTool)(logger), (0, remove_node_tool_1.createRemoveNodeTool)(logger), (0, update_node_parameters_tool_1.createUpdateNodeParametersTool)(parsedNodeTypes, llmComplexTask, logger, instanceUrl), (0, get_node_parameter_tool_1.createGetNodeParameterTool)(), (0, validate_workflow_tool_1.createValidateWorkflowTool)(parsedNodeTypes, logger));
|
|
26
|
+
return tools;
|
|
30
27
|
}
|
|
31
|
-
function getBuilderToolsForDisplay({ nodeTypes, }) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
connect_nodes_tool_1.CONNECT_NODES_TOOL,
|
|
39
|
-
remove_connection_tool_1.REMOVE_CONNECTION_TOOL,
|
|
40
|
-
remove_node_tool_1.REMOVE_NODE_TOOL,
|
|
41
|
-
update_node_parameters_tool_1.UPDATING_NODE_PARAMETER_TOOL,
|
|
42
|
-
get_node_parameter_tool_1.GET_NODE_PARAMETER_TOOL,
|
|
43
|
-
validate_workflow_tool_1.VALIDATE_WORKFLOW_TOOL,
|
|
44
|
-
];
|
|
28
|
+
function getBuilderToolsForDisplay({ nodeTypes, featureFlags, }) {
|
|
29
|
+
const tools = [categorize_prompt_tool_1.CATEGORIZE_PROMPT_TOOL, get_best_practices_tool_1.GET_BEST_PRACTICES_TOOL];
|
|
30
|
+
if (featureFlags?.templateExamples === true) {
|
|
31
|
+
tools.push(get_workflow_examples_tool_1.GET_WORKFLOW_EXAMPLES_TOOL);
|
|
32
|
+
}
|
|
33
|
+
tools.push(node_search_tool_1.NODE_SEARCH_TOOL, node_details_tool_1.NODE_DETAILS_TOOL, (0, add_node_tool_1.getAddNodeToolBase)(nodeTypes), connect_nodes_tool_1.CONNECT_NODES_TOOL, remove_connection_tool_1.REMOVE_CONNECTION_TOOL, remove_node_tool_1.REMOVE_NODE_TOOL, update_node_parameters_tool_1.UPDATING_NODE_PARAMETER_TOOL, get_node_parameter_tool_1.GET_NODE_PARAMETER_TOOL, validate_workflow_tool_1.VALIDATE_WORKFLOW_TOOL);
|
|
34
|
+
return tools;
|
|
45
35
|
}
|
|
46
36
|
//# sourceMappingURL=builder-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder-tools.js","sourceRoot":"","sources":["../../src/tools/builder-tools.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"builder-tools.js","sourceRoot":"","sources":["../../src/tools/builder-tools.ts"],"names":[],"mappings":";;AA0BA,0CAsCC;AAOD,8DA6BC;AA7FD,mDAAwE;AACxE,qEAA8F;AAC9F,6DAAkF;AAClF,uEAAgG;AAChG,uEAAgG;AAChG,6EAGsC;AACtC,2DAA+E;AAC/E,yDAA4E;AAC5E,qEAA8F;AAC9F,yDAA4E;AAC5E,+EAGuC;AACvC,qEAA8F;AAE9F,SAAgB,eAAe,CAAC,EAC/B,eAAe,EACf,MAAM,EACN,cAAc,EACd,WAAW,EACX,YAAY,GAOZ;IACA,MAAM,KAAK,GAAkB;QAC5B,IAAA,mDAA0B,EAAC,cAAc,EAAE,MAAM,CAAC;QAClD,IAAA,oDAA0B,GAAE;KAC5B,CAAC;IAIF,IAAI,YAAY,EAAE,gBAAgB,KAAK,IAAI,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,IAAA,0DAA6B,EAAC,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;IAGD,KAAK,CAAC,IAAI,CACT,IAAA,uCAAoB,EAAC,eAAe,CAAC,EACrC,IAAA,yCAAqB,EAAC,eAAe,CAAC,EACtC,IAAA,iCAAiB,EAAC,eAAe,CAAC,EAClC,IAAA,2CAAsB,EAAC,eAAe,EAAE,MAAM,CAAC,EAC/C,IAAA,mDAA0B,EAAC,MAAM,CAAC,EAClC,IAAA,uCAAoB,EAAC,MAAM,CAAC,EAC5B,IAAA,4DAA8B,EAAC,eAAe,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC,EACpF,IAAA,oDAA0B,GAAE,EAC5B,IAAA,mDAA0B,EAAC,eAAe,EAAE,MAAM,CAAC,CACnD,CAAC;IAEF,OAAO,KAAK,CAAC;AACd,CAAC;AAOD,SAAgB,yBAAyB,CAAC,EACzC,SAAS,EACT,YAAY,GAIZ;IACA,MAAM,KAAK,GAAsB,CAAC,+CAAsB,EAAE,iDAAuB,CAAC,CAAC;IAInF,IAAI,YAAY,EAAE,gBAAgB,KAAK,IAAI,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,uDAA0B,CAAC,CAAC;IACxC,CAAC;IAGD,KAAK,CAAC,IAAI,CACT,mCAAgB,EAChB,qCAAiB,EACjB,IAAA,kCAAkB,EAAC,SAAS,CAAC,EAC7B,uCAAkB,EAClB,+CAAsB,EACtB,mCAAgB,EAChB,0DAA4B,EAC5B,iDAAuB,EACvB,+CAAsB,CACtB,CAAC;IAEF,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -29,5 +29,5 @@ export declare function createGetBestPracticesTool(): {
|
|
|
29
29
|
techniques: ("scheduling" | "chatbot" | "form_input" | "scraping_and_research" | "monitoring" | "enrichment" | "triage" | "content_generation" | "document_processing" | "data_extraction" | "data_analysis" | "data_transformation" | "notification" | "knowledge_base" | "human_in_the_loop")[];
|
|
30
30
|
}>, unknown, {
|
|
31
31
|
techniques: ("scheduling" | "chatbot" | "form_input" | "scraping_and_research" | "monitoring" | "enrichment" | "triage" | "content_generation" | "document_processing" | "data_extraction" | "data_analysis" | "data_transformation" | "notification" | "knowledge_base" | "human_in_the_loop")[];
|
|
32
|
-
}, import("@langchain/langgraph").Command<unknown>>;
|
|
32
|
+
}, import("@langchain/langgraph").Command<unknown, Record<string, unknown>, string>>;
|
|
33
33
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Logger } from '@n8n/backend-common';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { BuilderToolBase } from '../utils/stream-processor';
|
|
4
|
+
export declare const GET_WORKFLOW_EXAMPLES_TOOL: BuilderToolBase;
|
|
5
|
+
export declare function createGetWorkflowExamplesTool(logger?: Logger): {
|
|
6
|
+
toolName: string;
|
|
7
|
+
displayTitle: string;
|
|
8
|
+
getCustomDisplayTitle?: (values: Record<string, unknown>) => string;
|
|
9
|
+
tool: import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
10
|
+
queries: z.ZodArray<z.ZodObject<{
|
|
11
|
+
search: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
search?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
search?: string | undefined;
|
|
16
|
+
}>, "many">;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
queries: {
|
|
19
|
+
search?: string | undefined;
|
|
20
|
+
}[];
|
|
21
|
+
}, {
|
|
22
|
+
queries: {
|
|
23
|
+
search?: string | undefined;
|
|
24
|
+
}[];
|
|
25
|
+
}>, {
|
|
26
|
+
queries: {
|
|
27
|
+
search?: string | undefined;
|
|
28
|
+
}[];
|
|
29
|
+
}, {
|
|
30
|
+
queries: {
|
|
31
|
+
search?: string | undefined;
|
|
32
|
+
}[];
|
|
33
|
+
}, import("@langchain/langgraph").Command<unknown, Record<string, unknown>, string>>;
|
|
34
|
+
};
|