@n8n/ai-workflow-builder 1.25.1 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/agents/responder.agent.d.ts +4 -4
  2. package/dist/build.tsbuildinfo +1 -1
  3. package/dist/code-builder/constants.d.ts +1 -0
  4. package/dist/code-builder/constants.js +5 -1
  5. package/dist/code-builder/constants.js.map +1 -1
  6. package/dist/code-builder/handlers/chat-setup-handler.js.map +1 -1
  7. package/dist/code-builder/handlers/text-editor-handler.d.ts +1 -3
  8. package/dist/code-builder/handlers/text-editor-handler.js +1 -3
  9. package/dist/code-builder/handlers/text-editor-handler.js.map +1 -1
  10. package/dist/code-builder/handlers/tool-dispatch-handler.d.ts +1 -1
  11. package/dist/code-builder/handlers/tool-dispatch-handler.js.map +1 -1
  12. package/dist/code-builder/index.d.ts +1 -1
  13. package/dist/code-builder/index.js +2 -1
  14. package/dist/code-builder/index.js.map +1 -1
  15. package/dist/code-builder/prompts/index.js +2 -2
  16. package/dist/code-builder/prompts/index.js.map +1 -1
  17. package/dist/code-builder/tools/code-builder-get.tool.d.ts +6 -6
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +2 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/multi-agent-workflow-subgraphs.d.ts +1 -1
  22. package/dist/multi-agent-workflow-subgraphs.js +2 -9
  23. package/dist/multi-agent-workflow-subgraphs.js.map +1 -1
  24. package/dist/prompts/agents/discovery.prompt.d.ts +1 -5
  25. package/dist/prompts/agents/discovery.prompt.js +11 -41
  26. package/dist/prompts/agents/discovery.prompt.js.map +1 -1
  27. package/dist/prompts/agents/index.d.ts +0 -1
  28. package/dist/prompts/agents/index.js.map +1 -1
  29. package/dist/prompts/index.d.ts +1 -1
  30. package/dist/prompts/index.js.map +1 -1
  31. package/dist/subgraphs/discovery.subgraph.d.ts +0 -1
  32. package/dist/subgraphs/discovery.subgraph.js +8 -29
  33. package/dist/subgraphs/discovery.subgraph.js.map +1 -1
  34. package/dist/tools/builder-tools.js +0 -4
  35. package/dist/tools/builder-tools.js.map +1 -1
  36. package/dist/tools/get-documentation.tool.d.ts +6 -6
  37. package/dist/tools/introspect.tool.d.ts +4 -4
  38. package/dist/tools/node-search.tool.d.ts +6 -6
  39. package/dist/tools/submit-questions.tool.d.ts +8 -8
  40. package/dist/types/tools.d.ts +0 -8
  41. package/dist/workflow-builder-agent.d.ts +0 -2
  42. package/dist/workflow-builder-agent.js +1 -2
  43. package/dist/workflow-builder-agent.js.map +1 -1
  44. package/package.json +12 -11
  45. package/dist/code-builder/handlers/text-editor.types.d.ts +0 -2
  46. package/dist/code-builder/handlers/text-editor.types.js +0 -13
  47. package/dist/code-builder/handlers/text-editor.types.js.map +0 -1
  48. package/dist/tools/get-workflow-examples.tool.d.ts +0 -34
  49. package/dist/tools/get-workflow-examples.tool.js +0 -138
  50. package/dist/tools/get-workflow-examples.tool.js.map +0 -1
@@ -1,138 +0,0 @@
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 mermaid_utils_1 = require("./utils/mermaid.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
- function buildQueryIdentifier(query) {
21
- const parts = [];
22
- if (query.search) {
23
- parts.push(`search: ${query.search}`);
24
- }
25
- return parts.join(',');
26
- }
27
- function buildResponseMessage(output) {
28
- if (output.examples.length === 0) {
29
- return 'No workflow examples found';
30
- }
31
- const sections = [`Found ${output.totalResults} workflow example(s):`];
32
- for (const example of output.examples) {
33
- sections.push(`\n## ${example.name}`);
34
- if (example.description) {
35
- sections.push(example.description);
36
- }
37
- sections.push(example.workflow);
38
- }
39
- return sections.join('\n');
40
- }
41
- exports.GET_WORKFLOW_EXAMPLES_TOOL = {
42
- toolName: 'get_workflow_examples',
43
- displayTitle: 'Retrieving workflow examples',
44
- };
45
- const TOOL_DESCRIPTION = `Retrieve workflow examples from n8n's workflow library to use as reference for building workflows.
46
-
47
- This tool searches for existing workflow examples that match specific criteria.
48
- The retrieved workflows serve as reference material to understand common patterns, node usage and connections.
49
- Consider these workflows as ideal solutions.
50
- The workflows will be returned in a token efficient format rather than JSON.
51
-
52
- Usage:
53
- - Provide search criteria to find relevant workflow examples
54
- - Results include workflow metadata, summaries, and full workflow data for reference
55
-
56
- Parameters:
57
- - search: Keywords to search for in workflow names/descriptions based on the user prompt`;
58
- function createGetWorkflowExamplesTool(logger) {
59
- const dynamicTool = (0, tools_1.tool)(async (input, config) => {
60
- const reporter = (0, helpers_1.createProgressReporter)(config, exports.GET_WORKFLOW_EXAMPLES_TOOL.toolName, exports.GET_WORKFLOW_EXAMPLES_TOOL.displayTitle);
61
- try {
62
- const validatedInput = getWorkflowExamplesSchema.parse(input);
63
- const { queries } = validatedInput;
64
- reporter.start(validatedInput);
65
- let allResults = [];
66
- let allTemplateIds = [];
67
- const batchReporter = (0, helpers_1.createBatchProgressReporter)(reporter, 'Retrieving workflow examples');
68
- batchReporter.init(queries.length);
69
- for (const query of queries) {
70
- const identifier = buildQueryIdentifier(query);
71
- try {
72
- batchReporter.next(identifier);
73
- const result = await (0, templates_1.fetchWorkflowsFromTemplates)({ search: query.search }, { logger });
74
- allResults = allResults.concat(result.workflows);
75
- allTemplateIds = allTemplateIds.concat(result.templateIds);
76
- }
77
- catch (error) {
78
- logger?.error('Error fetching workflow examples', { error });
79
- }
80
- }
81
- batchReporter.complete();
82
- const uniqueWorkflows = new Map();
83
- for (const workflow of allResults) {
84
- if (!uniqueWorkflows.has(workflow.name)) {
85
- uniqueWorkflows.set(workflow.name, workflow);
86
- }
87
- }
88
- const deduplicatedResults = Array.from(uniqueWorkflows.values());
89
- const processedResults = (0, mermaid_utils_1.processWorkflowExamples)(deduplicatedResults, {
90
- includeNodeParameters: false,
91
- });
92
- const formattedResults = deduplicatedResults.map((workflow, index) => ({
93
- name: workflow.name,
94
- description: workflow.description,
95
- workflow: processedResults[index].mermaid,
96
- }));
97
- const output = {
98
- examples: formattedResults,
99
- totalResults: deduplicatedResults.length,
100
- };
101
- const responseMessage = buildResponseMessage(output);
102
- reporter.complete(output);
103
- const uniqueTemplateIds = [...new Set(allTemplateIds)];
104
- logger?.debug('Caching workflow templates in state', {
105
- templateCount: deduplicatedResults.length,
106
- templateNames: deduplicatedResults.map((w) => w.name),
107
- });
108
- return (0, helpers_1.createSuccessResponse)(config, responseMessage, {
109
- templateIds: uniqueTemplateIds,
110
- cachedTemplates: deduplicatedResults,
111
- });
112
- }
113
- catch (error) {
114
- if (error instanceof zod_1.z.ZodError) {
115
- const validationError = new errors_1.ValidationError('Invalid input parameters', {
116
- extra: { errors: error.errors },
117
- });
118
- reporter.error(validationError);
119
- return (0, helpers_1.createErrorResponse)(config, validationError);
120
- }
121
- const toolError = new errors_1.ToolExecutionError(error instanceof Error ? error.message : 'Unknown error occurred', {
122
- toolName: exports.GET_WORKFLOW_EXAMPLES_TOOL.toolName,
123
- cause: error instanceof Error ? error : undefined,
124
- });
125
- reporter.error(toolError);
126
- return (0, helpers_1.createErrorResponse)(config, toolError);
127
- }
128
- }, {
129
- name: exports.GET_WORKFLOW_EXAMPLES_TOOL.toolName,
130
- description: TOOL_DESCRIPTION,
131
- schema: getWorkflowExamplesSchema,
132
- });
133
- return {
134
- tool: dynamicTool,
135
- ...exports.GET_WORKFLOW_EXAMPLES_TOOL,
136
- };
137
- }
138
- //# sourceMappingURL=get-workflow-examples.tool.js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