@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.
Files changed (124) hide show
  1. package/dist/agents/responder.agent.d.ts +20 -0
  2. package/dist/agents/responder.agent.js +95 -0
  3. package/dist/agents/responder.agent.js.map +1 -0
  4. package/dist/agents/supervisor.agent.d.ts +30 -0
  5. package/dist/agents/supervisor.agent.js +99 -0
  6. package/dist/agents/supervisor.agent.js.map +1 -0
  7. package/dist/ai-workflow-builder-agent.service.js +4 -0
  8. package/dist/ai-workflow-builder-agent.service.js.map +1 -1
  9. package/dist/build.tsbuildinfo +1 -1
  10. package/dist/constants.d.ts +4 -0
  11. package/dist/constants.js +5 -1
  12. package/dist/constants.js.map +1 -1
  13. package/dist/llm-config.d.ts +1 -0
  14. package/dist/llm-config.js +20 -1
  15. package/dist/llm-config.js.map +1 -1
  16. package/dist/multi-agent-workflow-subgraphs.d.ts +85 -0
  17. package/dist/multi-agent-workflow-subgraphs.js +121 -0
  18. package/dist/multi-agent-workflow-subgraphs.js.map +1 -0
  19. package/dist/parent-graph-state.d.ts +23 -0
  20. package/dist/parent-graph-state.js +34 -0
  21. package/dist/parent-graph-state.js.map +1 -0
  22. package/dist/subgraphs/builder.subgraph.d.ts +120 -0
  23. package/dist/subgraphs/builder.subgraph.js +322 -0
  24. package/dist/subgraphs/builder.subgraph.js.map +1 -0
  25. package/dist/subgraphs/configurator.subgraph.d.ts +130 -0
  26. package/dist/subgraphs/configurator.subgraph.js +242 -0
  27. package/dist/subgraphs/configurator.subgraph.js.map +1 -0
  28. package/dist/subgraphs/discovery.subgraph.d.ts +140 -0
  29. package/dist/subgraphs/discovery.subgraph.js +415 -0
  30. package/dist/subgraphs/discovery.subgraph.js.map +1 -0
  31. package/dist/subgraphs/subgraph-interface.d.ts +23 -0
  32. package/dist/subgraphs/subgraph-interface.js +7 -0
  33. package/dist/subgraphs/subgraph-interface.js.map +1 -0
  34. package/dist/tools/builder-tools.d.ts +5 -2
  35. package/dist/tools/builder-tools.js +15 -25
  36. package/dist/tools/builder-tools.js.map +1 -1
  37. package/dist/tools/get-best-practices.tool.d.ts +1 -1
  38. package/dist/tools/get-workflow-examples.tool.d.ts +34 -0
  39. package/dist/tools/get-workflow-examples.tool.js +172 -0
  40. package/dist/tools/get-workflow-examples.tool.js.map +1 -0
  41. package/dist/tools/node-details.tool.d.ts +4 -4
  42. package/dist/tools/node-details.tool.js +30 -2
  43. package/dist/tools/node-details.tool.js.map +1 -1
  44. package/dist/tools/node-search.tool.d.ts +1 -1
  45. package/dist/tools/prompts/main-agent.prompt.d.ts +4 -0
  46. package/dist/tools/prompts/main-agent.prompt.js +113 -57
  47. package/dist/tools/prompts/main-agent.prompt.js.map +1 -1
  48. package/dist/tools/utils/markdown-workflow.utils.d.ts +14 -0
  49. package/dist/tools/utils/markdown-workflow.utils.js +174 -0
  50. package/dist/tools/utils/markdown-workflow.utils.js.map +1 -0
  51. package/dist/tools/utils/test/workflows/ai-assistant.workflow.d.ts +2 -0
  52. package/dist/tools/utils/test/workflows/ai-assistant.workflow.js +541 -0
  53. package/dist/tools/utils/test/workflows/ai-assistant.workflow.js.map +1 -0
  54. package/dist/tools/validate-configuration.tool.d.ts +4 -0
  55. package/dist/tools/validate-configuration.tool.js +70 -0
  56. package/dist/tools/validate-configuration.tool.js.map +1 -0
  57. package/dist/tools/validate-structure.tool.d.ts +4 -0
  58. package/dist/tools/validate-structure.tool.js +66 -0
  59. package/dist/tools/validate-structure.tool.js.map +1 -0
  60. package/dist/tools/web/templates.d.ts +7 -0
  61. package/dist/tools/web/templates.js +71 -0
  62. package/dist/tools/web/templates.js.map +1 -0
  63. package/dist/types/coordination.d.ts +36 -0
  64. package/dist/types/coordination.js +19 -0
  65. package/dist/types/coordination.js.map +1 -0
  66. package/dist/types/discovery-types.d.ts +12 -0
  67. package/dist/types/discovery-types.js +3 -0
  68. package/dist/types/discovery-types.js.map +1 -0
  69. package/dist/types/index.d.ts +1 -0
  70. package/dist/types/index.js +15 -0
  71. package/dist/types/index.js.map +1 -1
  72. package/dist/types/langchain.d.ts +1 -0
  73. package/dist/types/langchain.js +8 -0
  74. package/dist/types/langchain.js.map +1 -1
  75. package/dist/types/tools.d.ts +20 -0
  76. package/dist/types/web/templates.d.ts +44 -0
  77. package/dist/types/web/templates.js +37 -0
  78. package/dist/types/web/templates.js.map +1 -0
  79. package/dist/utils/cache-control/helpers.d.ts +1 -0
  80. package/dist/utils/cache-control/helpers.js +36 -0
  81. package/dist/utils/cache-control/helpers.js.map +1 -1
  82. package/dist/utils/cache-control/index.d.ts +1 -1
  83. package/dist/utils/cache-control/index.js +2 -1
  84. package/dist/utils/cache-control/index.js.map +1 -1
  85. package/dist/utils/context-builders.d.ts +10 -0
  86. package/dist/utils/context-builders.js +71 -0
  87. package/dist/utils/context-builders.js.map +1 -0
  88. package/dist/utils/coordination-log.d.ts +14 -0
  89. package/dist/utils/coordination-log.js +75 -0
  90. package/dist/utils/coordination-log.js.map +1 -0
  91. package/dist/utils/operations-processor.d.ts +4 -2
  92. package/dist/utils/operations-processor.js.map +1 -1
  93. package/dist/utils/stream-processor.d.ts +6 -2
  94. package/dist/utils/stream-processor.js +164 -81
  95. package/dist/utils/stream-processor.js.map +1 -1
  96. package/dist/utils/subgraph-helpers.d.ts +13 -0
  97. package/dist/utils/subgraph-helpers.js +95 -0
  98. package/dist/utils/subgraph-helpers.js.map +1 -0
  99. package/dist/utils/token-usage.js +4 -1
  100. package/dist/utils/token-usage.js.map +1 -1
  101. package/dist/utils/tool-executor.js +55 -38
  102. package/dist/utils/tool-executor.js.map +1 -1
  103. package/dist/utils/workflow-validation.js +1 -0
  104. package/dist/utils/workflow-validation.js.map +1 -1
  105. package/dist/validation/checks/index.d.ts +2 -1
  106. package/dist/validation/checks/index.js +3 -1
  107. package/dist/validation/checks/index.js.map +1 -1
  108. package/dist/validation/checks/nodes.d.ts +4 -0
  109. package/dist/validation/checks/nodes.js +36 -0
  110. package/dist/validation/checks/nodes.js.map +1 -0
  111. package/dist/validation/checks/trigger.js +0 -6
  112. package/dist/validation/checks/trigger.js.map +1 -1
  113. package/dist/validation/programmatic.js +2 -0
  114. package/dist/validation/programmatic.js.map +1 -1
  115. package/dist/validation/types.d.ts +5 -1
  116. package/dist/validation/types.js +8 -0
  117. package/dist/validation/types.js.map +1 -1
  118. package/dist/workflow-builder-agent.d.ts +8 -0
  119. package/dist/workflow-builder-agent.js +38 -9
  120. package/dist/workflow-builder-agent.js.map +1 -1
  121. package/dist/workflow-state.d.ts +4 -2
  122. package/dist/workflow-state.js +20 -0
  123. package/dist/workflow-state.js.map +1 -1
  124. package/package.json +9 -8
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfiguratorSubgraph = exports.ConfiguratorSubgraphState = 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 get_node_parameter_tool_1 = require("../tools/get-node-parameter.tool");
9
+ const update_node_parameters_tool_1 = require("../tools/update-node-parameters.tool");
10
+ const validate_configuration_tool_1 = require("../tools/validate-configuration.tool");
11
+ const coordination_1 = require("../types/coordination");
12
+ const langchain_1 = require("../types/langchain");
13
+ const cache_control_1 = require("../utils/cache-control");
14
+ const context_builders_1 = require("../utils/context-builders");
15
+ const operations_processor_1 = require("../utils/operations-processor");
16
+ const subgraph_helpers_1 = require("../utils/subgraph-helpers");
17
+ const CONFIGURATOR_PROMPT = `You are a Configurator Agent specialized in setting up n8n node parameters.
18
+
19
+ MANDATORY EXECUTION SEQUENCE:
20
+ You MUST follow these steps IN ORDER. Do not skip any step.
21
+
22
+ STEP 1: CONFIGURE ALL NODES
23
+ - Call update_node_parameters for EVERY node in the workflow
24
+ - Configure multiple nodes in PARALLEL for efficiency
25
+ - Do NOT respond with text - START CONFIGURING immediately
26
+
27
+ STEP 2: VALIDATE (REQUIRED)
28
+ - After ALL configurations complete, call validate_configuration
29
+ - This step is MANDATORY - you cannot finish without it
30
+ - If validation finds issues, fix them and validate again
31
+
32
+ STEP 3: RESPOND TO USER
33
+ - Only after validation passes, provide your response
34
+
35
+ NEVER respond to the user without calling validate_configuration first
36
+
37
+ WORKFLOW JSON DETECTION:
38
+ - You receive <current_workflow_json> in your context
39
+ - If you see nodes in the workflow JSON, you MUST configure them IMMEDIATELY
40
+ - Look at the workflow JSON, identify each node, and call update_node_parameters for ALL of them
41
+
42
+ PARAMETER CONFIGURATION:
43
+ Use update_node_parameters with natural language instructions:
44
+ - "Set URL to https://api.example.com/weather"
45
+ - "Add header Authorization: Bearer token"
46
+ - "Set method to POST"
47
+ - "Add field 'status' with value 'processed'"
48
+
49
+ SPECIAL EXPRESSIONS FOR TOOL NODES:
50
+ Tool nodes (types ending in "Tool") support $fromAI expressions:
51
+ - "Set sendTo to ={{ $fromAI('to') }}"
52
+ - "Set subject to ={{ $fromAI('subject') }}"
53
+ - "Set message to ={{ $fromAI('message_html') }}"
54
+ - "Set timeMin to ={{ $fromAI('After', '', 'string') }}"
55
+
56
+ $fromAI syntax: ={{ $fromAI('key', 'description', 'type', defaultValue) }}
57
+ - ONLY use in tool nodes (check node type ends with "Tool")
58
+ - Use for dynamic values that AI determines at runtime
59
+ - For regular nodes, use static values or standard expressions
60
+
61
+ CRITICAL PARAMETERS TO ALWAYS SET:
62
+ - HTTP Request: URL, method, headers (if auth needed)
63
+ - Set node: Fields to set with values
64
+ - Code node: The actual code to execute
65
+ - IF node: Conditions to check
66
+ - Document Loader: dataType parameter ('binary' for files like PDF, 'json' for JSON data)
67
+ - AI nodes: Prompts, models, configurations
68
+ - Tool nodes: Use $fromAI for dynamic recipient/subject/message fields
69
+
70
+ NEVER RELY ON DEFAULT VALUES:
71
+ Defaults are traps that cause runtime failures. Examples:
72
+ - Document Loader defaults to 'json' but MUST be 'binary' when processing files
73
+ - HTTP Request defaults to GET but APIs often need POST
74
+ - Vector Store mode affects available connections - set explicitly (retrieve-as-tool when using with AI Agent)
75
+
76
+ <response_format>
77
+ After validation passes, provide a concise summary:
78
+ - List any placeholders requiring user configuration (e.g., "URL placeholder needs actual endpoint")
79
+ - Note which nodes were configured and key settings applied
80
+ - Keep it brief - this output is used for coordination with other LLM agents, not displayed directly to users
81
+ </response_format>
82
+
83
+ DO NOT:
84
+ - Respond before calling validate_configuration
85
+ - Skip validation even if you think configuration is correct
86
+ - Add commentary between tool calls - execute tools silently`;
87
+ const INSTANCE_URL_PROMPT = `
88
+ <instance_url>
89
+ The n8n instance base URL is: {instanceUrl}
90
+
91
+ This URL is essential for webhook nodes and chat triggers as it provides the base URL for:
92
+ - Webhook URLs that external services need to call
93
+ - Chat trigger URLs for conversational interfaces
94
+ - Any node that requires the full instance URL to generate proper callback URLs
95
+
96
+ When working with webhook or chat trigger nodes, use this URL as the base for constructing proper endpoint URLs.
97
+ </instance_url>
98
+ `;
99
+ exports.ConfiguratorSubgraphState = langgraph_1.Annotation.Root({
100
+ workflowJSON: (0, langgraph_1.Annotation)({
101
+ reducer: (x, y) => y ?? x,
102
+ default: () => ({ nodes: [], connections: {}, name: '' }),
103
+ }),
104
+ workflowContext: (0, langgraph_1.Annotation)({
105
+ reducer: (x, y) => y ?? x,
106
+ }),
107
+ instanceUrl: (0, langgraph_1.Annotation)({
108
+ reducer: (x, y) => y ?? x,
109
+ default: () => '',
110
+ }),
111
+ userRequest: (0, langgraph_1.Annotation)({
112
+ reducer: (x, y) => y ?? x,
113
+ default: () => '',
114
+ }),
115
+ discoveryContext: (0, langgraph_1.Annotation)({
116
+ reducer: (x, y) => y ?? x,
117
+ default: () => null,
118
+ }),
119
+ messages: (0, langgraph_1.Annotation)({
120
+ reducer: (x, y) => x.concat(y),
121
+ default: () => [],
122
+ }),
123
+ workflowOperations: (0, langgraph_1.Annotation)({
124
+ reducer: (x, y) => {
125
+ if (y === null)
126
+ return [];
127
+ if (!y || y.length === 0)
128
+ return x ?? [];
129
+ return [...(x ?? []), ...y];
130
+ },
131
+ default: () => [],
132
+ }),
133
+ });
134
+ class ConfiguratorSubgraph extends subgraph_interface_1.BaseSubgraph {
135
+ name = 'configurator_subgraph';
136
+ description = 'Configures node parameters after structure is built';
137
+ agent;
138
+ toolMap;
139
+ instanceUrl = '';
140
+ create(config) {
141
+ this.instanceUrl = config.instanceUrl ?? '';
142
+ const tools = [
143
+ (0, update_node_parameters_tool_1.createUpdateNodeParametersTool)(config.parsedNodeTypes, config.llm, config.logger, config.instanceUrl),
144
+ (0, get_node_parameter_tool_1.createGetNodeParameterTool)(),
145
+ (0, validate_configuration_tool_1.createValidateConfigurationTool)(config.parsedNodeTypes),
146
+ ];
147
+ this.toolMap = new Map(tools.map((bt) => [bt.tool.name, bt.tool]));
148
+ const systemPromptTemplate = prompts_1.ChatPromptTemplate.fromMessages([
149
+ [
150
+ 'system',
151
+ [
152
+ {
153
+ type: 'text',
154
+ text: CONFIGURATOR_PROMPT,
155
+ },
156
+ {
157
+ type: 'text',
158
+ text: INSTANCE_URL_PROMPT,
159
+ cache_control: { type: 'ephemeral' },
160
+ },
161
+ ],
162
+ ],
163
+ ['placeholder', '{messages}'],
164
+ ]);
165
+ if (typeof config.llm.bindTools !== 'function') {
166
+ throw new errors_1.LLMServiceError('LLM does not support tools', {
167
+ llmModel: config.llm._llmType(),
168
+ });
169
+ }
170
+ this.agent = systemPromptTemplate.pipe(config.llm.bindTools(tools.map((bt) => bt.tool)));
171
+ const callAgent = async (state) => {
172
+ (0, cache_control_1.applySubgraphCacheMarkers)(state.messages);
173
+ const response = await this.agent.invoke({
174
+ messages: state.messages,
175
+ instanceUrl: state.instanceUrl ?? '',
176
+ });
177
+ if (!(0, langchain_1.isBaseMessage)(response)) {
178
+ throw new errors_1.LLMServiceError('Configurator agent did not return a valid message');
179
+ }
180
+ return { messages: [response] };
181
+ };
182
+ const subgraph = new langgraph_1.StateGraph(exports.ConfiguratorSubgraphState)
183
+ .addNode('agent', callAgent)
184
+ .addNode('tools', async (state) => await (0, subgraph_helpers_1.executeSubgraphTools)(state, this.toolMap))
185
+ .addNode('process_operations', operations_processor_1.processOperations)
186
+ .addEdge('__start__', 'agent')
187
+ .addConditionalEdges('agent', (0, subgraph_helpers_1.createStandardShouldContinue)())
188
+ .addEdge('tools', 'process_operations')
189
+ .addEdge('process_operations', 'agent');
190
+ return subgraph.compile();
191
+ }
192
+ transformInput(parentState) {
193
+ const userRequest = (0, subgraph_helpers_1.extractUserRequest)(parentState.messages);
194
+ const contextParts = [];
195
+ if (userRequest) {
196
+ contextParts.push('=== USER REQUEST ===');
197
+ contextParts.push(userRequest);
198
+ }
199
+ if (parentState.discoveryContext?.bestPractices) {
200
+ contextParts.push(parentState.discoveryContext.bestPractices);
201
+ }
202
+ contextParts.push('=== WORKFLOW TO CONFIGURE ===');
203
+ contextParts.push((0, context_builders_1.buildWorkflowJsonBlock)(parentState.workflowJSON));
204
+ contextParts.push('=== EXECUTION CONTEXT ===');
205
+ contextParts.push((0, context_builders_1.buildExecutionContextBlock)(parentState.workflowContext));
206
+ const contextMessage = (0, context_builders_1.createContextMessage)(contextParts);
207
+ return {
208
+ workflowJSON: parentState.workflowJSON,
209
+ workflowContext: parentState.workflowContext,
210
+ instanceUrl: this.instanceUrl,
211
+ userRequest,
212
+ discoveryContext: parentState.discoveryContext,
213
+ messages: [contextMessage],
214
+ };
215
+ }
216
+ transformOutput(subgraphOutput, _parentState) {
217
+ const lastMessage = subgraphOutput.messages[subgraphOutput.messages.length - 1];
218
+ const setupInstructions = typeof lastMessage?.content === 'string' ? lastMessage.content : 'Configuration complete';
219
+ const nodesConfigured = subgraphOutput.workflowJSON.nodes.length;
220
+ const hasSetupInstructions = setupInstructions.includes('Setup') ||
221
+ setupInstructions.includes('setup') ||
222
+ setupInstructions.length > 50;
223
+ const logEntry = {
224
+ phase: 'configurator',
225
+ status: 'completed',
226
+ timestamp: Date.now(),
227
+ summary: `Configured ${nodesConfigured} nodes`,
228
+ output: setupInstructions,
229
+ metadata: (0, coordination_1.createConfiguratorMetadata)({
230
+ nodesConfigured,
231
+ hasSetupInstructions,
232
+ }),
233
+ };
234
+ return {
235
+ workflowJSON: subgraphOutput.workflowJSON,
236
+ workflowOperations: subgraphOutput.workflowOperations ?? [],
237
+ coordinationLog: [logEntry],
238
+ };
239
+ }
240
+ }
241
+ exports.ConfiguratorSubgraph = ConfiguratorSubgraph;
242
+ //# sourceMappingURL=configurator.subgraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configurator.subgraph.js","sourceRoot":"","sources":["../../src/subgraphs/configurator.subgraph.ts"],"names":[],"mappings":";;;AAEA,qDAA6D;AAG7D,oDAA8D;AAI9D,qCAA2C;AAE3C,6DAAoD;AAEpD,8EAA8E;AAC9E,sFAAsF;AACtF,sFAAuF;AAEvF,wDAAmE;AAEnE,kDAAmD;AAEnD,0DAAmE;AACnE,gEAImC;AACnC,wEAAkE;AAClE,gEAImC;AAMnC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6DAqEiC,CAAC;AAK9D,MAAM,mBAAmB,GAAG;;;;;;;;;;;CAW3B,CAAC;AAKW,QAAA,yBAAyB,GAAG,sBAAU,CAAC,IAAI,CAAC;IAExD,YAAY,EAAE,IAAA,sBAAU,EAAiB;QACxC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;QACzB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;KACzD,CAAC;IAGF,eAAe,EAAE,IAAA,sBAAU,EAA6C;QACvE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;KACzB,CAAC;IAG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oB,GACzB,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC;YACnC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC;YACnC,iBAAiB,CAAC,MAAM,GAAG,EAAE,CAAC;QAG/B,MAAM,QAAQ,GAAyB;YACtC,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,OAAO,EAAE,cAAc,eAAe,QAAQ;YAC9C,MAAM,EAAE,iBAAiB;YACzB,QAAQ,EAAE,IAAA,yCAA0B,EAAC;gBACpC,eAAe;gBACf,oBAAoB;aACpB,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;SAE3B,CAAC;IACH,CAAC;CACD;AAjKD,oDAiKC"}
@@ -0,0 +1,140 @@
1
+ import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
2
+ import type { BaseMessage, AIMessage } 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
+ export declare const DiscoverySubgraphState: import("@langchain/langgraph").AnnotationRoot<{
9
+ userRequest: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
10
+ 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>[]>;
11
+ nodesFound: import("@langchain/langgraph").BinaryOperatorAggregate<{
12
+ nodeName: string;
13
+ version: number;
14
+ reasoning: string;
15
+ connectionChangingParameters: Array<{
16
+ name: string;
17
+ possibleValues: Array<string | boolean | number>;
18
+ }>;
19
+ }[], {
20
+ nodeName: string;
21
+ version: number;
22
+ reasoning: string;
23
+ connectionChangingParameters: Array<{
24
+ name: string;
25
+ possibleValues: Array<string | boolean | number>;
26
+ }>;
27
+ }[]>;
28
+ bestPractices: import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
29
+ }>;
30
+ export interface DiscoverySubgraphConfig {
31
+ parsedNodeTypes: INodeTypeDescription[];
32
+ llm: BaseChatModel;
33
+ logger?: Logger;
34
+ }
35
+ export declare class DiscoverySubgraph extends BaseSubgraph<DiscoverySubgraphConfig, typeof DiscoverySubgraphState.State, typeof ParentGraphState.State> {
36
+ name: string;
37
+ description: string;
38
+ private agent;
39
+ private toolMap;
40
+ private logger?;
41
+ create(config: DiscoverySubgraphConfig): import("@langchain/langgraph").CompiledStateGraph<{
42
+ userRequest: string;
43
+ messages: BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[];
44
+ nodesFound: {
45
+ nodeName: string;
46
+ version: number;
47
+ reasoning: string;
48
+ connectionChangingParameters: Array<{
49
+ name: string;
50
+ possibleValues: Array<string | boolean | number>;
51
+ }>;
52
+ }[];
53
+ bestPractices: string | undefined;
54
+ }, {
55
+ userRequest?: string | undefined;
56
+ messages?: BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[] | undefined;
57
+ nodesFound?: {
58
+ nodeName: string;
59
+ version: number;
60
+ reasoning: string;
61
+ connectionChangingParameters: Array<{
62
+ name: string;
63
+ possibleValues: Array<string | boolean | number>;
64
+ }>;
65
+ }[] | undefined;
66
+ bestPractices?: string | undefined;
67
+ }, "agent" | "tools" | "__start__" | "format_output", {
68
+ userRequest: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
69
+ 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>[]>;
70
+ nodesFound: import("@langchain/langgraph").BinaryOperatorAggregate<{
71
+ nodeName: string;
72
+ version: number;
73
+ reasoning: string;
74
+ connectionChangingParameters: Array<{
75
+ name: string;
76
+ possibleValues: Array<string | boolean | number>;
77
+ }>;
78
+ }[], {
79
+ nodeName: string;
80
+ version: number;
81
+ reasoning: string;
82
+ connectionChangingParameters: Array<{
83
+ name: string;
84
+ possibleValues: Array<string | boolean | number>;
85
+ }>;
86
+ }[]>;
87
+ bestPractices: import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
88
+ }, {
89
+ userRequest: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
90
+ 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>[]>;
91
+ nodesFound: import("@langchain/langgraph").BinaryOperatorAggregate<{
92
+ nodeName: string;
93
+ version: number;
94
+ reasoning: string;
95
+ connectionChangingParameters: Array<{
96
+ name: string;
97
+ possibleValues: Array<string | boolean | number>;
98
+ }>;
99
+ }[], {
100
+ nodeName: string;
101
+ version: number;
102
+ reasoning: string;
103
+ connectionChangingParameters: Array<{
104
+ name: string;
105
+ possibleValues: Array<string | boolean | number>;
106
+ }>;
107
+ }[]>;
108
+ bestPractices: import("@langchain/langgraph").BinaryOperatorAggregate<string | undefined, string | undefined>;
109
+ }, import("@langchain/langgraph").StateDefinition, {
110
+ agent: {
111
+ messages: AIMessage<import("@langchain/core/messages").MessageStructure>[];
112
+ };
113
+ tools: {
114
+ messages?: BaseMessage[];
115
+ workflowOperations?: import("..").WorkflowOperation[] | null;
116
+ };
117
+ }, unknown, unknown>;
118
+ private callAgent;
119
+ private formatOutput;
120
+ private shouldContinue;
121
+ transformInput(parentState: typeof ParentGraphState.State): {
122
+ userRequest: string;
123
+ messages: import("@langchain/core/messages").HumanMessage<import("@langchain/core/messages").MessageStructure>[];
124
+ };
125
+ transformOutput(subgraphOutput: typeof DiscoverySubgraphState.State, _parentState: typeof ParentGraphState.State): {
126
+ discoveryContext: {
127
+ nodesFound: {
128
+ nodeName: string;
129
+ version: number;
130
+ reasoning: string;
131
+ connectionChangingParameters: Array<{
132
+ name: string;
133
+ possibleValues: Array<string | boolean | number>;
134
+ }>;
135
+ }[];
136
+ bestPractices: string | undefined;
137
+ };
138
+ coordinationLog: CoordinationLogEntry[];
139
+ };
140
+ }