@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,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET_WORKFLOW_EXAMPLES_TOOL = void 0;
|
|
4
|
+
exports.createGetWorkflowExamplesTool = createGetWorkflowExamplesTool;
|
|
5
|
+
const tools_1 = require("@langchain/core/tools");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
9
|
+
const markdown_workflow_utils_1 = require("./utils/markdown-workflow.utils");
|
|
10
|
+
const templates_1 = require("./web/templates");
|
|
11
|
+
const workflowExampleQuerySchema = zod_1.z.object({
|
|
12
|
+
search: zod_1.z.string().optional().describe('Search term to find workflow examples'),
|
|
13
|
+
});
|
|
14
|
+
const getWorkflowExamplesSchema = zod_1.z.object({
|
|
15
|
+
queries: zod_1.z
|
|
16
|
+
.array(workflowExampleQuerySchema)
|
|
17
|
+
.min(1)
|
|
18
|
+
.describe('Array of search queries to find workflow examples'),
|
|
19
|
+
});
|
|
20
|
+
async function fetchWorkflowExamples(query, logger) {
|
|
21
|
+
logger?.debug('Fetching workflow examples with query', { query });
|
|
22
|
+
const response = await (0, templates_1.fetchTemplateList)({
|
|
23
|
+
search: query.search,
|
|
24
|
+
});
|
|
25
|
+
const workflowResults = await Promise.all(response.workflows.map(async (workflow) => {
|
|
26
|
+
try {
|
|
27
|
+
const fullWorkflow = await (0, templates_1.fetchTemplateByID)(workflow.id);
|
|
28
|
+
return {
|
|
29
|
+
metadata: {
|
|
30
|
+
name: workflow.name,
|
|
31
|
+
description: workflow.description,
|
|
32
|
+
workflow: fullWorkflow.workflow,
|
|
33
|
+
},
|
|
34
|
+
templateId: workflow.id,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
logger?.warn(`Failed to fetch full workflow for template ${workflow.id}`, { error });
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
const validResults = workflowResults.filter((result) => result !== undefined);
|
|
43
|
+
return {
|
|
44
|
+
workflows: validResults.map((r) => r.metadata),
|
|
45
|
+
totalFound: response.totalWorkflows,
|
|
46
|
+
templateIds: validResults.map((r) => r.templateId),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function buildQueryIdentifier(query) {
|
|
50
|
+
const parts = [];
|
|
51
|
+
if (query.search) {
|
|
52
|
+
parts.push(`search: ${query.search}`);
|
|
53
|
+
}
|
|
54
|
+
return parts.join(',');
|
|
55
|
+
}
|
|
56
|
+
function buildResponseMessage(output) {
|
|
57
|
+
if (output.examples.length === 0) {
|
|
58
|
+
return 'No workflow examples found';
|
|
59
|
+
}
|
|
60
|
+
const sections = [`Found ${output.totalResults} workflow example(s):`];
|
|
61
|
+
for (const example of output.examples) {
|
|
62
|
+
sections.push(`\n## ${example.name}`);
|
|
63
|
+
if (example.description) {
|
|
64
|
+
sections.push(example.description);
|
|
65
|
+
}
|
|
66
|
+
sections.push(example.workflow);
|
|
67
|
+
}
|
|
68
|
+
return sections.join('\n');
|
|
69
|
+
}
|
|
70
|
+
exports.GET_WORKFLOW_EXAMPLES_TOOL = {
|
|
71
|
+
toolName: 'get_workflow_examples',
|
|
72
|
+
displayTitle: 'Retrieving workflow examples',
|
|
73
|
+
};
|
|
74
|
+
const TOOL_DESCRIPTION = `Retrieve workflow examples from n8n's workflow library to use as reference for building workflows.
|
|
75
|
+
|
|
76
|
+
This tool searches for existing workflow examples that match specific criteria.
|
|
77
|
+
The retrieved workflows serve as reference material to understand common patterns, node usage and connections.
|
|
78
|
+
Consider these workflows as ideal solutions.
|
|
79
|
+
The workflows will be returned in a token efficient format rather than JSON.
|
|
80
|
+
|
|
81
|
+
Usage:
|
|
82
|
+
- Provide search criteria to find relevant workflow examples
|
|
83
|
+
- Results include workflow metadata, summaries, and full workflow data for reference
|
|
84
|
+
|
|
85
|
+
Parameters:
|
|
86
|
+
- search: Keywords to search for in workflow names/descriptions based on the user prompt`;
|
|
87
|
+
function createGetWorkflowExamplesTool(logger) {
|
|
88
|
+
const dynamicTool = (0, tools_1.tool)(async (input, config) => {
|
|
89
|
+
const reporter = (0, helpers_1.createProgressReporter)(config, exports.GET_WORKFLOW_EXAMPLES_TOOL.toolName, exports.GET_WORKFLOW_EXAMPLES_TOOL.displayTitle);
|
|
90
|
+
try {
|
|
91
|
+
const validatedInput = getWorkflowExamplesSchema.parse(input);
|
|
92
|
+
const { queries } = validatedInput;
|
|
93
|
+
reporter.start(validatedInput);
|
|
94
|
+
let allResults = [];
|
|
95
|
+
let allTemplateIds = [];
|
|
96
|
+
const batchReporter = (0, helpers_1.createBatchProgressReporter)(reporter, 'Retrieving workflow examples');
|
|
97
|
+
batchReporter.init(queries.length);
|
|
98
|
+
for (const query of queries) {
|
|
99
|
+
const identifier = buildQueryIdentifier(query);
|
|
100
|
+
try {
|
|
101
|
+
batchReporter.next(identifier);
|
|
102
|
+
const result = await fetchWorkflowExamples(query, logger);
|
|
103
|
+
allResults = allResults.concat(result.workflows);
|
|
104
|
+
allTemplateIds = allTemplateIds.concat(result.templateIds);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
logger?.error('Error fetching workflow examples', { error });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
batchReporter.complete();
|
|
111
|
+
const uniqueWorkflows = new Map();
|
|
112
|
+
for (const workflow of allResults) {
|
|
113
|
+
if (!uniqueWorkflows.has(workflow.name)) {
|
|
114
|
+
uniqueWorkflows.set(workflow.name, workflow);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const deduplicatedResults = Array.from(uniqueWorkflows.values());
|
|
118
|
+
const processedResults = (0, markdown_workflow_utils_1.processWorkflowExamples)(deduplicatedResults, {
|
|
119
|
+
includeNodeParameters: false,
|
|
120
|
+
});
|
|
121
|
+
const nodeConfigurations = processedResults.length > 0
|
|
122
|
+
? processedResults[processedResults.length - 1].nodeConfigurations
|
|
123
|
+
: {};
|
|
124
|
+
logger?.debug('Collected node configurations from workflow examples', {
|
|
125
|
+
nodeTypeCount: Object.keys(nodeConfigurations).length,
|
|
126
|
+
nodeTypes: Object.keys(nodeConfigurations),
|
|
127
|
+
configCounts: Object.fromEntries(Object.entries(nodeConfigurations).map(([type, configs]) => [type, configs.length])),
|
|
128
|
+
});
|
|
129
|
+
const formattedResults = deduplicatedResults.map((workflow, index) => ({
|
|
130
|
+
name: workflow.name,
|
|
131
|
+
description: workflow.description,
|
|
132
|
+
workflow: processedResults[index].mermaid,
|
|
133
|
+
}));
|
|
134
|
+
const output = {
|
|
135
|
+
examples: formattedResults,
|
|
136
|
+
totalResults: deduplicatedResults.length,
|
|
137
|
+
nodeConfigurations,
|
|
138
|
+
};
|
|
139
|
+
const responseMessage = buildResponseMessage(output);
|
|
140
|
+
reporter.complete(output);
|
|
141
|
+
const uniqueTemplateIds = [...new Set(allTemplateIds)];
|
|
142
|
+
return (0, helpers_1.createSuccessResponse)(config, responseMessage, {
|
|
143
|
+
nodeConfigurations,
|
|
144
|
+
templateIds: uniqueTemplateIds,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
149
|
+
const validationError = new errors_1.ValidationError('Invalid input parameters', {
|
|
150
|
+
extra: { errors: error.errors },
|
|
151
|
+
});
|
|
152
|
+
reporter.error(validationError);
|
|
153
|
+
return (0, helpers_1.createErrorResponse)(config, validationError);
|
|
154
|
+
}
|
|
155
|
+
const toolError = new errors_1.ToolExecutionError(error instanceof Error ? error.message : 'Unknown error occurred', {
|
|
156
|
+
toolName: exports.GET_WORKFLOW_EXAMPLES_TOOL.toolName,
|
|
157
|
+
cause: error instanceof Error ? error : undefined,
|
|
158
|
+
});
|
|
159
|
+
reporter.error(toolError);
|
|
160
|
+
return (0, helpers_1.createErrorResponse)(config, toolError);
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
name: exports.GET_WORKFLOW_EXAMPLES_TOOL.toolName,
|
|
164
|
+
description: TOOL_DESCRIPTION,
|
|
165
|
+
schema: getWorkflowExamplesSchema,
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
tool: dynamicTool,
|
|
169
|
+
...exports.GET_WORKFLOW_EXAMPLES_TOOL,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=get-workflow-examples.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-workflow-examples.tool.js","sourceRoot":"","sources":["../../src/tools/get-workflow-examples.tool.ts"],"names":[],"mappings":";;;AAwJA,sEAmIC;AA3RD,iDAA6C;AAE7C,6BAAwB;AAKxB,sCAAgE;AAChE,uCAKmB;AACnB,6EAA0E;AAC1E,+CAAuE;AAKvE,MAAM,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;CAC/E,CAAC,CAAC;AAKH,MAAM,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,OAAO,EAAE,OAAC;SACR,KAAK,CAAC,0BAA0B,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,mDAAmD,CAAC;CAC/D,CAAC,CAAC;AAmBH,KAAK,UAAU,qBAAqB,CACnC,KAA2B,EAC3B,MAAe;IAEf,MAAM,EAAE,KAAK,CAAC,uCAAuC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAGlE,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAiB,EAAC;QACxC,MAAM,EAAE,KAAK,CAAC,MAAM;KACpB,CAAC,CAAC;IAGH,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,eAAe,EAAE;gBACrD,kBAAkB;gBAClB,WAAW,EAAE,iBAAiB;aAC9B,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEhB,IAAI,KAAK,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;gBACjC,MAAM,eAAe,GAAG,IAAI,wBAAe,CAAC,0BAA0B,EAAE;oBACvE,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;iBAC/B,CAAC,CAAC;gBACH,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBAChC,OAAO,IAAA,6BAAmB,EAAC,MAAM,EAAE,eAAe,CAAC,CAAC;YACrD,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,2BAAkB,CACvC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,EACjE;gBACC,QAAQ,EAAE,kCAA0B,CAAC,QAAQ;gBAC7C,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;aACjD,CACD,CAAC;YACF,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC1B,OAAO,IAAA,6BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC,EACD;QACC,IAAI,EAAE,kCAA0B,CAAC,QAAQ;QACzC,WAAW,EAAE,gBAAgB;QAC7B,MAAM,EAAE,yBAAyB;KACjC,CACD,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,GAAG,kCAA0B;KAC7B,CAAC;AACH,CAAC"}
|
|
@@ -12,19 +12,19 @@ export declare function createNodeDetailsTool(nodeTypes: INodeTypeDescription[])
|
|
|
12
12
|
withParameters: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
13
13
|
withConnections: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
nodeVersion: number;
|
|
16
15
|
nodeName: string;
|
|
16
|
+
nodeVersion: number;
|
|
17
17
|
withParameters: boolean;
|
|
18
18
|
withConnections: boolean;
|
|
19
19
|
}, {
|
|
20
|
-
nodeVersion: number;
|
|
21
20
|
nodeName: string;
|
|
21
|
+
nodeVersion: number;
|
|
22
22
|
withParameters?: boolean | undefined;
|
|
23
23
|
withConnections?: boolean | undefined;
|
|
24
24
|
}>, unknown, {
|
|
25
|
-
nodeVersion: number;
|
|
26
25
|
nodeName: string;
|
|
26
|
+
nodeVersion: number;
|
|
27
27
|
withParameters?: boolean | undefined;
|
|
28
28
|
withConnections?: boolean | undefined;
|
|
29
|
-
}, import("@langchain/langgraph").Command<unknown>>;
|
|
29
|
+
}, import("@langchain/langgraph").Command<unknown, Record<string, unknown>, string>>;
|
|
30
30
|
};
|
|
@@ -4,9 +4,11 @@ exports.NODE_DETAILS_TOOL = void 0;
|
|
|
4
4
|
exports.createNodeDetailsTool = createNodeDetailsTool;
|
|
5
5
|
const tools_1 = require("@langchain/core/tools");
|
|
6
6
|
const zod_1 = require("zod");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
7
8
|
const errors_1 = require("../errors");
|
|
8
9
|
const progress_1 = require("./helpers/progress");
|
|
9
10
|
const response_1 = require("./helpers/response");
|
|
11
|
+
const state_1 = require("./helpers/state");
|
|
10
12
|
const validation_1 = require("./helpers/validation");
|
|
11
13
|
const nodeDetailsSchema = zod_1.z.object({
|
|
12
14
|
nodeName: zod_1.z.string().describe('The exact node type name (e.g., n8n-nodes-base.httpRequest)'),
|
|
@@ -52,7 +54,7 @@ function formatOutputs(outputs) {
|
|
|
52
54
|
});
|
|
53
55
|
return formattedOutputs.join('\n');
|
|
54
56
|
}
|
|
55
|
-
function formatNodeDetails(details, withParameters = false, withConnections = true) {
|
|
57
|
+
function formatNodeDetails(details, withParameters = false, withConnections = true, examples = []) {
|
|
56
58
|
const parts = [];
|
|
57
59
|
parts.push('<node_details>');
|
|
58
60
|
parts.push(`<name>${details.name}</name>`);
|
|
@@ -73,6 +75,21 @@ function formatNodeDetails(details, withParameters = false, withConnections = tr
|
|
|
73
75
|
parts.push(formatOutputs(details.outputs));
|
|
74
76
|
parts.push('</connections>');
|
|
75
77
|
}
|
|
78
|
+
if (examples.length > 0) {
|
|
79
|
+
const { parts: exampleParts } = examples.reduce((acc, example) => {
|
|
80
|
+
const exampleStr = JSON.stringify(example, null, 2);
|
|
81
|
+
if (acc.chars + exampleStr.length <= constants_1.MAX_NODE_EXAMPLE_CHARS) {
|
|
82
|
+
acc.parts.push(exampleStr);
|
|
83
|
+
acc.chars += exampleStr.length;
|
|
84
|
+
}
|
|
85
|
+
return acc;
|
|
86
|
+
}, { parts: [], chars: 0 });
|
|
87
|
+
if (exampleParts.length > 0) {
|
|
88
|
+
parts.push('<node_examples>');
|
|
89
|
+
parts.push(...exampleParts);
|
|
90
|
+
parts.push('</node_examples>');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
76
93
|
parts.push('</node_details>');
|
|
77
94
|
return parts.join('\n');
|
|
78
95
|
}
|
|
@@ -106,7 +123,18 @@ function createNodeDetailsTool(nodeTypes) {
|
|
|
106
123
|
return (0, response_1.createErrorResponse)(config, error);
|
|
107
124
|
}
|
|
108
125
|
const details = extractNodeDetails(nodeType);
|
|
109
|
-
|
|
126
|
+
let examples = [];
|
|
127
|
+
try {
|
|
128
|
+
const state = (0, state_1.getWorkflowState)();
|
|
129
|
+
const allNodeConfigs = state?.nodeConfigurations?.[nodeName] ?? [];
|
|
130
|
+
examples = allNodeConfigs
|
|
131
|
+
.filter((config) => config.version === nodeVersion)
|
|
132
|
+
.map((config) => config.parameters);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
examples = [];
|
|
136
|
+
}
|
|
137
|
+
const message = formatNodeDetails(details, withParameters, withConnections, examples);
|
|
110
138
|
const output = {
|
|
111
139
|
details,
|
|
112
140
|
found: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-details.tool.js","sourceRoot":"","sources":["../../src/tools/node-details.tool.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"node-details.tool.js","sourceRoot":"","sources":["../../src/tools/node-details.tool.ts"],"names":[],"mappings":";;;AA+JA,sDA2FC;AA1PD,iDAA6C;AAE7C,6BAAwB;AAExB,2CAAqD;AAGrD,sCAAgE;AAChE,iDAA4E;AAC5E,iDAAgF;AAChF,2CAAmD;AACnD,qDAAiF;AAOjF,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6DAA6D,CAAC;IAC5F,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC1D,cAAc,EAAE,OAAC;SACf,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CAAC,kDAAkD,CAAC;IAC9D,eAAe,EAAE,OAAC;SAChB,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,IAAI,CAAC;SACb,QAAQ,CAAC,6DAA6D,CAAC;CACzE,CAAC,CAAC;AAKH,SAAS,YAAY,CAAC,MAAsC;IAC3D,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,uBAAuB,CAAC;IAChC,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,UAAU,MAAM,UAAU,CAAC;IACnC,CAAC;IACD,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,UAAU,KAAK,UAAU,CAAC;QAClC,CAAC;QAED,OAAO,UAAU,IA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AAM,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEhB,IAAI,KAAK,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;gBACjC,MAAM,eAAe,GAAG,IAAI,wBAAe,CAAC,0BAA0B,EAAE;oBACvE,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;iBAC/B,CAAC,CAAC;gBACH,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBAChC,OAAO,IAAA,8BAAmB,EAAC,MAAM,EAAE,eAAe,CAAC,CAAC;YACrD,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,2BAAkB,CACvC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,EACjE;gBACC,QAAQ,EAAE,yBAAiB,CAAC,QAAQ;gBACpC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;aACjD,CACD,CAAC;YACF,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC1B,OAAO,IAAA,8BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC,EACD;QACC,IAAI,EAAE,yBAAiB,CAAC,QAAQ;QAChC,WAAW,EACV,kLAAkL;QACnL,MAAM,EAAE,iBAAiB;KACzB,CACD,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,GAAG,yBAAiB;KACpB,CAAC;AACH,CAAC"}
|
|
@@ -58,5 +58,5 @@ export declare function createNodeSearchTool(nodeTypes: INodeTypeDescription[]):
|
|
|
58
58
|
connectionType?: "ai_agent" | "ai_chain" | "ai_document" | "ai_embedding" | "ai_languageModel" | "ai_memory" | "ai_outputParser" | "ai_retriever" | "ai_reranker" | "ai_textSplitter" | "ai_tool" | "ai_vectorStore" | "main" | undefined;
|
|
59
59
|
query?: string | undefined;
|
|
60
60
|
}[];
|
|
61
|
-
}, import("@langchain/langgraph").Command<unknown>>;
|
|
61
|
+
}, import("@langchain/langgraph").Command<unknown, Record<string, unknown>, string>>;
|
|
62
62
|
};
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
|
2
|
+
export interface MainAgentPromptOptions {
|
|
3
|
+
includeExamplesPhase?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function createMainAgentPrompt(options?: MainAgentPromptOptions): ChatPromptTemplate<any, any>;
|
|
2
6
|
export declare const mainAgentPrompt: ChatPromptTemplate<any, any>;
|
|
@@ -1,9 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mainAgentPrompt = void 0;
|
|
4
|
+
exports.createMainAgentPrompt = createMainAgentPrompt;
|
|
4
5
|
const prompts_1 = require("@langchain/core/prompts");
|
|
5
6
|
const instance_url_1 = require("../../chains/prompts/instance-url");
|
|
6
|
-
|
|
7
|
+
function generateWorkflowCreationPhases(options = {}) {
|
|
8
|
+
const { includeExamplesPhase = false } = options;
|
|
9
|
+
const phases = [
|
|
10
|
+
{
|
|
11
|
+
name: 'Categorization Phase',
|
|
12
|
+
metadata: '- MANDATORY',
|
|
13
|
+
content: [
|
|
14
|
+
'Categorize the prompt and search for best practices documentation based on the techniques found',
|
|
15
|
+
'Why: Best practices help to inform which nodes to search for and use to build the workflow plus mistakes to avoid',
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
if (includeExamplesPhase) {
|
|
20
|
+
phases.push({
|
|
21
|
+
name: 'Examples Phase',
|
|
22
|
+
metadata: '(parallel execution)',
|
|
23
|
+
content: [
|
|
24
|
+
'Search for workflow examples using simple, relevant search terms',
|
|
25
|
+
'Why: Examples provide complete, working implementations showing nodes, connections and parameter configurations',
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
phases.push({
|
|
30
|
+
name: 'Discovery Phase',
|
|
31
|
+
metadata: '(parallel execution)',
|
|
32
|
+
content: [
|
|
33
|
+
'Search for all required node types simultaneously, review the <node_selection> section for tips and best practices',
|
|
34
|
+
'Why: Ensures you work with actual available nodes, not assumptions',
|
|
35
|
+
],
|
|
36
|
+
}, {
|
|
37
|
+
name: 'Analysis Phase',
|
|
38
|
+
metadata: '(parallel execution)',
|
|
39
|
+
content: [
|
|
40
|
+
'Get details for ALL nodes before proceeding',
|
|
41
|
+
'Why: Understanding inputs/outputs prevents connection errors and ensures proper parameter configuration',
|
|
42
|
+
],
|
|
43
|
+
}, {
|
|
44
|
+
name: 'Creation Phase',
|
|
45
|
+
metadata: '(parallel execution)',
|
|
46
|
+
content: [
|
|
47
|
+
'Add nodes individually by calling add_nodes for each node',
|
|
48
|
+
'Execute multiple add_nodes calls in parallel for efficiency',
|
|
49
|
+
'Why: Each node addition is independent, parallel execution is faster, and the operations processor ensures consistency',
|
|
50
|
+
],
|
|
51
|
+
}, {
|
|
52
|
+
name: 'Connection Phase',
|
|
53
|
+
metadata: '(parallel execution)',
|
|
54
|
+
content: [
|
|
55
|
+
'Connect all nodes based on discovered input/output structure',
|
|
56
|
+
'Why: Parallel connections are safe and faster',
|
|
57
|
+
],
|
|
58
|
+
}, {
|
|
59
|
+
name: 'Configuration Phase',
|
|
60
|
+
metadata: '(parallel execution) - MANDATORY',
|
|
61
|
+
content: [
|
|
62
|
+
'ALWAYS configure nodes using update_node_parameters',
|
|
63
|
+
'Even for "simple" nodes like HTTP Request, Set, etc.',
|
|
64
|
+
'Configure all nodes in parallel for efficiency',
|
|
65
|
+
'Why: Unconfigured nodes will fail at runtime',
|
|
66
|
+
'Pay special attention to parameters that control node behavior (dataType, mode, operation)',
|
|
67
|
+
'Why: Unconfigured nodes will fail at runtime, defaults are unreliable',
|
|
68
|
+
],
|
|
69
|
+
}, {
|
|
70
|
+
name: 'Validation Phase',
|
|
71
|
+
metadata: '(tool call) - MANDATORY',
|
|
72
|
+
content: [
|
|
73
|
+
'Run validate_workflow after applying changes to refresh the workflow validation report',
|
|
74
|
+
'Review <workflow_validation_report> and resolve any violations before finalizing',
|
|
75
|
+
'Why: Ensures structural issues are surfaced early; rerun validation after major updates',
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
return phases
|
|
79
|
+
.map((phase, index) => {
|
|
80
|
+
const phaseNumber = index + 1;
|
|
81
|
+
const metadataStr = phase.metadata ? ` ${phase.metadata}` : '';
|
|
82
|
+
const contentStr = phase.content.map((line) => ` - ${line}`).join('\n');
|
|
83
|
+
return `${phaseNumber}. **${phase.name}**${metadataStr}\n${contentStr}`;
|
|
84
|
+
})
|
|
85
|
+
.join('\n\n');
|
|
86
|
+
}
|
|
87
|
+
function generateSystemPrompt(options = {}) {
|
|
88
|
+
const workflowPhases = generateWorkflowCreationPhases(options);
|
|
89
|
+
return `You are an AI assistant specialized in creating and editing n8n workflows. Your goal is to help users build efficient, well-connected workflows by intelligently using the available tools.
|
|
7
90
|
<core_principle>
|
|
8
91
|
After receiving tool results, reflect on their quality and determine optimal next steps. Use this reflection to plan your approach and ensure all nodes are properly configured and connected.
|
|
9
92
|
</core_principle>
|
|
@@ -33,39 +116,7 @@ The system's operations processor ensures state consistency across all parallel
|
|
|
33
116
|
<workflow_creation_sequence>
|
|
34
117
|
Follow this proven sequence for creating robust workflows:
|
|
35
118
|
|
|
36
|
-
|
|
37
|
-
- Categorize the prompt and search for best practices documentation based on the techniques found
|
|
38
|
-
- Why: Best practices help to inform which nodes to search for and use to build the workflow plus mistakes to avoid
|
|
39
|
-
|
|
40
|
-
2. **Discovery Phase** (parallel execution)
|
|
41
|
-
- Search for all required node types simultaneously, review the <node_selection> section for tips and best practices
|
|
42
|
-
- Why: Ensures you work with actual available nodes, not assumptions
|
|
43
|
-
|
|
44
|
-
3. **Analysis Phase** (parallel execution)
|
|
45
|
-
- Get details for ALL nodes before proceeding
|
|
46
|
-
- Why: Understanding inputs/outputs prevents connection errors and ensures proper parameter configuration
|
|
47
|
-
|
|
48
|
-
4. **Creation Phase** (parallel execution)
|
|
49
|
-
- Add nodes individually by calling add_nodes for each node
|
|
50
|
-
- Execute multiple add_nodes calls in parallel for efficiency
|
|
51
|
-
- Why: Each node addition is independent, parallel execution is faster, and the operations processor ensures consistency
|
|
52
|
-
|
|
53
|
-
5. **Connection Phase** (parallel execution)
|
|
54
|
-
- Connect all nodes based on discovered input/output structure
|
|
55
|
-
- Why: Parallel connections are safe and faster
|
|
56
|
-
|
|
57
|
-
6. **Configuration Phase** (parallel execution) - MANDATORY
|
|
58
|
-
- ALWAYS configure nodes using update_node_parameters
|
|
59
|
-
- Even for "simple" nodes like HTTP Request, Set, etc.
|
|
60
|
-
- Configure all nodes in parallel for efficiency
|
|
61
|
-
- Why: Unconfigured nodes will fail at runtime
|
|
62
|
-
- Pay special attention to parameters that control node behavior (dataType, mode, operation)
|
|
63
|
-
- Why: Unconfigured nodes will fail at runtime, defaults are unreliable
|
|
64
|
-
|
|
65
|
-
6. **Validation Phase** (tool call) - MANDATORY
|
|
66
|
-
- Run validate_workflow after applying changes to refresh the workflow validation report
|
|
67
|
-
- Review <workflow_validation_report> and resolve any violations before finalizing
|
|
68
|
-
- Why: Ensures structural issues are surfaced early; rerun validation after major updates
|
|
119
|
+
${workflowPhases}
|
|
69
120
|
|
|
70
121
|
<node_selection>
|
|
71
122
|
When building AI workflows prefer the AI agent node to other text LLM nodes, unless the user specifies them by name. Summarization, analysis, information
|
|
@@ -483,6 +534,7 @@ update_node_parameters({{
|
|
|
483
534
|
</handling_uncertainty>
|
|
484
535
|
|
|
485
536
|
`;
|
|
537
|
+
}
|
|
486
538
|
const responsePatterns = `
|
|
487
539
|
<response_patterns>
|
|
488
540
|
IMPORTANT: Only provide ONE response AFTER all tool executions are complete.
|
|
@@ -527,29 +579,33 @@ const previousConversationSummary = `
|
|
|
527
579
|
<previous_summary>
|
|
528
580
|
{previousSummary}
|
|
529
581
|
</previous_summary>`;
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
582
|
+
function createMainAgentPrompt(options = {}) {
|
|
583
|
+
const systemPrompt = generateSystemPrompt(options);
|
|
584
|
+
return prompts_1.ChatPromptTemplate.fromMessages([
|
|
533
585
|
[
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
586
|
+
'system',
|
|
587
|
+
[
|
|
588
|
+
{
|
|
589
|
+
type: 'text',
|
|
590
|
+
text: systemPrompt,
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
type: 'text',
|
|
594
|
+
text: instance_url_1.instanceUrlPrompt,
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
type: 'text',
|
|
598
|
+
text: responsePatterns,
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
type: 'text',
|
|
602
|
+
text: previousConversationSummary,
|
|
603
|
+
cache_control: { type: 'ephemeral' },
|
|
604
|
+
},
|
|
605
|
+
],
|
|
551
606
|
],
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
607
|
+
['placeholder', '{messages}'],
|
|
608
|
+
]);
|
|
609
|
+
}
|
|
610
|
+
exports.mainAgentPrompt = createMainAgentPrompt();
|
|
555
611
|
//# sourceMappingURL=main-agent.prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/prompts/main-agent.prompt.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"main-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/prompts/main-agent.prompt.ts"],"names":[],"mappings":";;;AA6mBA,sDA4BC;AAzoBD,qDAA6D;AAE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;;;;;;;;;;;;;;;;;;;;;;;;;CAiaf,CAAC;AACF,CAAC;AAED,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCxB,CAAC;AAEF,MAAM,2BAA2B,GAAG;;;oBAGhB,CAAC;AAKrB,SAAgB,qBAAqB,CAAC,UAAkC,EAAE;IACzE,MAAM,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAEnD,OAAO,4BAAkB,CAAC,YAAY,CAAC;QACtC;YACC,QAAQ;YACR;gBACC;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,YAAY;iBAClB;gBACD;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,gCAAiB;iBACvB;gBACD;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,gBAAgB;iBACtB;gBACD;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,2BAA2B;oBACjC,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;iBACpC;aACD;SACD;QACD,CAAC,aAAa,EAAE,YAAY,CAAC;KAC7B,CAAC,CAAC;AACJ,CAAC;AAMY,QAAA,eAAe,GAAG,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NodeConfigurationsMap, WorkflowMetadata } from '../../types';
|
|
2
|
+
export interface MermaidOptions {
|
|
3
|
+
includeNodeType?: boolean;
|
|
4
|
+
includeNodeParameters?: boolean;
|
|
5
|
+
includeNodeName?: boolean;
|
|
6
|
+
collectNodeConfigurations?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface MermaidResult {
|
|
9
|
+
mermaid: string;
|
|
10
|
+
nodeConfigurations: NodeConfigurationsMap;
|
|
11
|
+
}
|
|
12
|
+
export declare function mermaidStringify(workflow: WorkflowMetadata, options?: MermaidOptions): string;
|
|
13
|
+
export declare function processWorkflowExamples(workflows: WorkflowMetadata[], options?: Omit<MermaidOptions, 'collectNodeConfigurations'>): MermaidResult[];
|
|
14
|
+
export declare function stickyNotesStringify(workflow: WorkflowMetadata): string;
|