@n8n/ai-workflow-builder 1.1.1 → 1.2.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/ai-workflow-builder-agent.service.d.ts +1 -0
- package/dist/ai-workflow-builder-agent.service.js +3 -0
- package/dist/ai-workflow-builder-agent.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/multi-agent-workflow-subgraphs.d.ts +4 -4
- package/dist/multi-agent-workflow-subgraphs.js +7 -1
- package/dist/multi-agent-workflow-subgraphs.js.map +1 -1
- package/dist/parent-graph-state.d.ts +2 -2
- package/dist/parent-graph-state.js +3 -3
- package/dist/parent-graph-state.js.map +1 -1
- package/dist/prompts/agents/builder.prompt.js +88 -16
- package/dist/prompts/agents/builder.prompt.js.map +1 -1
- package/dist/prompts/agents/configurator.prompt.js +21 -3
- package/dist/prompts/agents/configurator.prompt.js.map +1 -1
- package/dist/prompts/agents/discovery.prompt.js +2 -1
- package/dist/prompts/agents/discovery.prompt.js.map +1 -1
- package/dist/prompts/chains/parameter-updater/guides/embedding-nodes.d.ts +2 -0
- package/dist/prompts/chains/parameter-updater/guides/embedding-nodes.js +70 -0
- package/dist/prompts/chains/parameter-updater/guides/embedding-nodes.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/index.d.ts +1 -0
- package/dist/prompts/chains/parameter-updater/guides/index.js +3 -1
- package/dist/prompts/chains/parameter-updater/guides/index.js.map +1 -1
- package/dist/prompts/chains/parameter-updater/registry.js +1 -0
- package/dist/prompts/chains/parameter-updater/registry.js.map +1 -1
- package/dist/session-manager.service.d.ts +1 -0
- package/dist/session-manager.service.js +55 -4
- package/dist/session-manager.service.js.map +1 -1
- package/dist/subgraphs/builder.subgraph.d.ts +11 -1
- package/dist/subgraphs/builder.subgraph.js +13 -1
- package/dist/subgraphs/builder.subgraph.js.map +1 -1
- package/dist/subgraphs/configurator.subgraph.d.ts +11 -1
- package/dist/subgraphs/configurator.subgraph.js +13 -1
- package/dist/subgraphs/configurator.subgraph.js.map +1 -1
- package/dist/subgraphs/discovery.subgraph.d.ts +9 -9
- package/dist/subgraphs/discovery.subgraph.js +6 -8
- package/dist/subgraphs/discovery.subgraph.js.map +1 -1
- package/dist/tools/best-practices/data-extraction.js +11 -1
- package/dist/tools/best-practices/data-extraction.js.map +1 -1
- package/dist/tools/best-practices/document-processing.js +12 -1
- package/dist/tools/best-practices/document-processing.js.map +1 -1
- package/dist/tools/best-practices/scraping-and-research.js +10 -0
- package/dist/tools/best-practices/scraping-and-research.js.map +1 -1
- package/dist/tools/builder-tools.js +1 -1
- package/dist/tools/builder-tools.js.map +1 -1
- package/dist/tools/get-node-examples.tool.d.ts +119 -0
- package/dist/tools/get-node-examples.tool.js +189 -0
- package/dist/tools/get-node-examples.tool.js.map +1 -0
- package/dist/tools/get-workflow-examples.tool.js +8 -42
- package/dist/tools/get-workflow-examples.tool.js.map +1 -1
- package/dist/tools/node-details.tool.d.ts +2 -1
- package/dist/tools/node-details.tool.js +48 -18
- package/dist/tools/node-details.tool.js.map +1 -1
- package/dist/tools/utils/{markdown-workflow.utils.d.ts → mermaid.utils.d.ts} +0 -1
- package/dist/tools/utils/mermaid.utils.js +647 -0
- package/dist/tools/utils/mermaid.utils.js.map +1 -0
- package/dist/tools/utils/node-configuration.utils.d.ts +13 -0
- package/dist/tools/utils/node-configuration.utils.js +75 -0
- package/dist/tools/utils/node-configuration.utils.js.map +1 -0
- package/dist/tools/utils/test/workflows/ai-assistant.workflow.js +1 -0
- package/dist/tools/utils/test/workflows/ai-assistant.workflow.js.map +1 -1
- package/dist/tools/web/templates.d.ts +17 -1
- package/dist/tools/web/templates.js +35 -0
- package/dist/tools/web/templates.js.map +1 -1
- package/dist/types/discovery-types.d.ts +0 -2
- package/dist/types/tools.d.ts +6 -1
- package/dist/types/web/templates.d.ts +1 -0
- package/dist/utils/state-reducers.d.ts +2 -3
- package/dist/utils/state-reducers.js +10 -15
- package/dist/utils/state-reducers.js.map +1 -1
- package/dist/utils/stream-processor.js +10 -1
- package/dist/utils/stream-processor.js.map +1 -1
- package/dist/utils/subgraph-helpers.d.ts +2 -2
- package/dist/utils/subgraph-helpers.js +8 -9
- package/dist/utils/subgraph-helpers.js.map +1 -1
- package/dist/utils/tool-executor.js +4 -18
- package/dist/utils/tool-executor.js.map +1 -1
- package/dist/validation/checks/from-ai.js +3 -1
- package/dist/validation/checks/from-ai.js.map +1 -1
- package/dist/validation/checks/nodes.js +10 -2
- package/dist/validation/checks/nodes.js.map +1 -1
- package/dist/validation/checks/tools.js +3 -1
- package/dist/validation/checks/tools.js.map +1 -1
- package/dist/validation/checks/trigger.js +3 -1
- package/dist/validation/checks/trigger.js.map +1 -1
- package/dist/workflow-builder-agent.d.ts +1 -0
- package/dist/workflow-builder-agent.js +8 -1
- package/dist/workflow-builder-agent.js.map +1 -1
- package/dist/workflow-state.d.ts +2 -2
- package/dist/workflow-state.js +4 -4
- package/dist/workflow-state.js.map +1 -1
- package/package.json +5 -5
- package/dist/tools/utils/markdown-workflow.utils.js +0 -174
- package/dist/tools/utils/markdown-workflow.utils.js.map +0 -1
|
@@ -28,7 +28,7 @@ export declare function createMultiAgentWorkflowWithSubgraphs(config: MultiAgent
|
|
|
28
28
|
coordinationLog: import("./types/coordination").CoordinationLogEntry[];
|
|
29
29
|
previousSummary: string;
|
|
30
30
|
templateIds: number[];
|
|
31
|
-
|
|
31
|
+
cachedTemplates: import("./types").WorkflowMetadata[];
|
|
32
32
|
}, {
|
|
33
33
|
messages?: import("@langchain/core/messages").BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[] | undefined;
|
|
34
34
|
workflowJSON?: import("./types").SimpleWorkflow | undefined;
|
|
@@ -44,7 +44,7 @@ export declare function createMultiAgentWorkflowWithSubgraphs(config: MultiAgent
|
|
|
44
44
|
coordinationLog?: import("./types/coordination").CoordinationLogEntry[] | undefined;
|
|
45
45
|
previousSummary?: string | undefined;
|
|
46
46
|
templateIds?: number[] | undefined;
|
|
47
|
-
|
|
47
|
+
cachedTemplates?: import("./types").WorkflowMetadata[] | undefined;
|
|
48
48
|
}, "responder" | "supervisor" | "create_workflow_name" | "configurator_subgraph" | "discovery_subgraph" | "builder_subgraph" | "delete_messages" | "compact_messages" | "process_operations" | "__start__" | "cleanup_dangling" | "check_state", {
|
|
49
49
|
messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages").BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[], import("@langchain/core/messages").BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[]>;
|
|
50
50
|
workflowJSON: import("@langchain/langgraph").BinaryOperatorAggregate<import("./types").SimpleWorkflow, import("./types").SimpleWorkflow>;
|
|
@@ -65,7 +65,7 @@ export declare function createMultiAgentWorkflowWithSubgraphs(config: MultiAgent
|
|
|
65
65
|
coordinationLog: import("@langchain/langgraph").BinaryOperatorAggregate<import("./types/coordination").CoordinationLogEntry[], import("./types/coordination").CoordinationLogEntry[]>;
|
|
66
66
|
previousSummary: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
67
67
|
templateIds: import("@langchain/langgraph").BinaryOperatorAggregate<number[], number[]>;
|
|
68
|
-
|
|
68
|
+
cachedTemplates: import("@langchain/langgraph").BinaryOperatorAggregate<import("./types").WorkflowMetadata[], import("./types").WorkflowMetadata[]>;
|
|
69
69
|
}, {
|
|
70
70
|
messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages").BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[], import("@langchain/core/messages").BaseMessage<import("@langchain/core/messages").MessageStructure, import("@langchain/core/messages").MessageType>[]>;
|
|
71
71
|
workflowJSON: import("@langchain/langgraph").BinaryOperatorAggregate<import("./types").SimpleWorkflow, import("./types").SimpleWorkflow>;
|
|
@@ -86,7 +86,7 @@ export declare function createMultiAgentWorkflowWithSubgraphs(config: MultiAgent
|
|
|
86
86
|
coordinationLog: import("@langchain/langgraph").BinaryOperatorAggregate<import("./types/coordination").CoordinationLogEntry[], import("./types/coordination").CoordinationLogEntry[]>;
|
|
87
87
|
previousSummary: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
88
88
|
templateIds: import("@langchain/langgraph").BinaryOperatorAggregate<number[], number[]>;
|
|
89
|
-
|
|
89
|
+
cachedTemplates: import("@langchain/langgraph").BinaryOperatorAggregate<import("./types").WorkflowMetadata[], import("./types").WorkflowMetadata[]>;
|
|
90
90
|
}, import("@langchain/langgraph").StateDefinition, {
|
|
91
91
|
supervisor: {
|
|
92
92
|
nextPhase: "responder" | "discovery" | "builder" | "configurator";
|
|
@@ -72,12 +72,18 @@ function createMultiAgentWorkflowWithSubgraphs(config) {
|
|
|
72
72
|
logger,
|
|
73
73
|
featureFlags,
|
|
74
74
|
});
|
|
75
|
-
const compiledBuilder = builderSubgraph.create({
|
|
75
|
+
const compiledBuilder = builderSubgraph.create({
|
|
76
|
+
parsedNodeTypes,
|
|
77
|
+
llm: llmComplexTask,
|
|
78
|
+
logger,
|
|
79
|
+
featureFlags,
|
|
80
|
+
});
|
|
76
81
|
const compiledConfigurator = configuratorSubgraph.create({
|
|
77
82
|
parsedNodeTypes,
|
|
78
83
|
llm: llmComplexTask,
|
|
79
84
|
logger,
|
|
80
85
|
instanceUrl,
|
|
86
|
+
featureFlags,
|
|
81
87
|
});
|
|
82
88
|
return (new langgraph_1.StateGraph(parent_graph_state_1.ParentGraphState)
|
|
83
89
|
.addNode('supervisor', async (state) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-agent-workflow-subgraphs.js","sourceRoot":"","sources":["../src/multi-agent-workflow-subgraphs.ts"],"names":[],"mappings":";;AAsHA,
|
|
1
|
+
{"version":3,"file":"multi-agent-workflow-subgraphs.js","sourceRoot":"","sources":["../src/multi-agent-workflow-subgraphs.ts"],"names":[],"mappings":";;AAsHA,sFAgLC;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ogEntry } from './types/coordination';
|
|
3
3
|
import type { DiscoveryContext } from './types/discovery-types';
|
|
4
|
-
import type {
|
|
4
|
+
import type { WorkflowMetadata } from './types/tools';
|
|
5
5
|
import type { SimpleWorkflow, WorkflowOperation } from './types/workflow';
|
|
6
6
|
export declare const ParentGraphState: import("@langchain/langgraph").AnnotationRoot<{
|
|
7
7
|
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>[]>;
|
|
@@ -23,5 +23,5 @@ export declare const ParentGraphState: import("@langchain/langgraph").Annotation
|
|
|
23
23
|
coordinationLog: import("@langchain/langgraph").BinaryOperatorAggregate<CoordinationLogEntry[], CoordinationLogEntry[]>;
|
|
24
24
|
previousSummary: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
25
25
|
templateIds: import("@langchain/langgraph").BinaryOperatorAggregate<number[], number[]>;
|
|
26
|
-
|
|
26
|
+
cachedTemplates: import("@langchain/langgraph").BinaryOperatorAggregate<WorkflowMetadata[], WorkflowMetadata[]>;
|
|
27
27
|
}>;
|
|
@@ -39,9 +39,9 @@ exports.ParentGraphState = langgraph_1.Annotation.Root({
|
|
|
39
39
|
reducer: state_reducers_1.appendArrayReducer,
|
|
40
40
|
default: () => [],
|
|
41
41
|
}),
|
|
42
|
-
|
|
43
|
-
reducer: state_reducers_1.
|
|
44
|
-
default: () =>
|
|
42
|
+
cachedTemplates: (0, langgraph_1.Annotation)({
|
|
43
|
+
reducer: state_reducers_1.cachedTemplatesReducer,
|
|
44
|
+
default: () => [],
|
|
45
45
|
}),
|
|
46
46
|
});
|
|
47
47
|
//# sourceMappingURL=parent-graph-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parent-graph-state.js","sourceRoot":"","sources":["../src/parent-graph-state.ts"],"names":[],"mappings":";;;AACA,oDAAwE;AA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,IAAA,sBAAU,EAAyB;QACnD,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KACjB,CAAC;IAGF,eAAe,EAAE,IAAA,sBAAU,EAAS;QACnC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;QACzB,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KACjB,CAAC;IAGF,WAAW,EAAE,IAAA,sBAAU,EAAW;QACjC,OAAO,EAAE,mCAAkB;QAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KACjB,CAAC;IAIF,eAAe,EAAE,IAAA,sBAAU,EAAqB;QAC/C,OAAO,EAAE,uCAAsB;QAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KACjB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -76,16 +76,34 @@ const STRUCTURED_OUTPUT_PARSER = `WHEN TO SET hasOutputParser: true on AI Agent:
|
|
|
76
76
|
- AI is classifying, scoring, or extracting specific data fields`;
|
|
77
77
|
const AI_CONNECTIONS = `n8n connections flow from SOURCE (output) to TARGET (input).
|
|
78
78
|
|
|
79
|
-
Regular
|
|
80
|
-
Example: HTTP Request → Set (HTTP
|
|
79
|
+
Regular "main" connections flow: Source → Target (data flows forward)
|
|
80
|
+
Example: HTTP Request → Set (HTTP outputs data, Set receives it)
|
|
81
81
|
|
|
82
|
-
AI
|
|
82
|
+
AI CAPABILITY CONNECTIONS are REVERSED in direction:
|
|
83
|
+
Sub-nodes (tools, memory, models) connect TO the AI Agent, NOT from it.
|
|
84
|
+
The sub-node is the SOURCE, the AI Agent is the TARGET.
|
|
85
|
+
|
|
86
|
+
⚠️ WRONG: AI Agent → Calculator Tool (NEVER do this)
|
|
87
|
+
✅ CORRECT: Calculator Tool → AI Agent (tool provides capability to agent)
|
|
88
|
+
|
|
89
|
+
When calling connect_nodes for AI sub-nodes:
|
|
90
|
+
- sourceNodeName: The sub-node (tool, memory, model, parser)
|
|
91
|
+
- targetNodeName: The AI Agent (or Vector Store, Document Loader)
|
|
92
|
+
- connectionType: The appropriate ai_* type
|
|
93
|
+
|
|
94
|
+
AI Connection Examples (SOURCE → TARGET [connectionType]):
|
|
83
95
|
- OpenAI Chat Model → AI Agent [ai_languageModel]
|
|
84
96
|
- Calculator Tool → AI Agent [ai_tool]
|
|
97
|
+
- HTTP Request Tool → AI Agent [ai_tool]
|
|
85
98
|
- Window Buffer Memory → AI Agent [ai_memory]
|
|
99
|
+
- Structured Output Parser → AI Agent [ai_outputParser]
|
|
86
100
|
- Token Splitter → Default Data Loader [ai_textSplitter]
|
|
87
101
|
- Default Data Loader → Vector Store [ai_document]
|
|
88
|
-
- Embeddings OpenAI → Vector Store [ai_embedding]
|
|
102
|
+
- Embeddings OpenAI → Vector Store [ai_embedding]
|
|
103
|
+
- Vector Store (retrieve-as-tool mode) → AI Agent [ai_tool]
|
|
104
|
+
|
|
105
|
+
The AI Agent only has ONE "main" output for regular data flow.
|
|
106
|
+
All inputs to the AI Agent come FROM sub-nodes via ai_* connection types.`;
|
|
89
107
|
const BRANCHING = `If two nodes (B and C) are both connected to the same output of a node (A), both will execute (with the same data). Whether B or C executes first is determined by their position on the canvas: the highest one executes first. Execution happens depth-first, i.e. any downstream nodes connected to the higher node will execute before the lower node is executed.
|
|
90
108
|
Nodes that route the flow (e.g. if, switch) apply their conditions independently to each input item. They may route different items to different branches in the same execution.`;
|
|
91
109
|
const MERGING = `If two nodes (A and B) are both connected to the same input of the following node (C), node C will execute TWICE — once with the items from A and once with the items from B. The same goes for any nodes connected to node C. These two executions are called runs and are independent of each other. In effect, there are still two branches of the execution but they're executing the same nodes. No merging of the data between them will occur.
|
|
@@ -182,30 +200,83 @@ Example connectionParameters for 3-way routing:
|
|
|
182
200
|
]
|
|
183
201
|
}}
|
|
184
202
|
}}`;
|
|
185
|
-
const
|
|
203
|
+
const NODE_CONNECTION_EXAMPLES = `<node_connection_examples>
|
|
204
|
+
When connecting nodes with non-standard output patterns, use get_node_connection_examples:
|
|
205
|
+
|
|
206
|
+
Call get_node_connection_examples when:
|
|
207
|
+
- Connecting Loop Over Items (splitInBatches) - has TWO outputs with specific meanings
|
|
208
|
+
- Connecting Switch nodes with multiple outputs
|
|
209
|
+
- Connecting IF nodes with true/false branches
|
|
210
|
+
- Any node where you're unsure about connection patterns
|
|
211
|
+
|
|
212
|
+
Usage:
|
|
213
|
+
- nodeType: "n8n-nodes-base.splitInBatches" (exact node type)
|
|
214
|
+
- Returns mermaid diagrams showing how the node is typically connected
|
|
215
|
+
|
|
216
|
+
CRITICAL for Loop Over Items (splitInBatches):
|
|
217
|
+
This node has TWO outputs that work differently from most nodes:
|
|
218
|
+
- Output 0 (first array element) = "Done" branch - connects to nodes that run AFTER all looping completes
|
|
219
|
+
- Output 1 (second array element) = "Loop" branch - connects to nodes that process each batch during the loop
|
|
220
|
+
This is COUNTERINTUITIVE - the loop processing is on output 1, NOT output 0.
|
|
221
|
+
|
|
222
|
+
When connecting splitInBatches, use sourceOutputIndex to specify which output:
|
|
223
|
+
- sourceOutputIndex: 0 → "Done" branch (post-loop processing, aggregation)
|
|
224
|
+
- sourceOutputIndex: 1 → "Loop" branch (batch processing during loop)
|
|
225
|
+
|
|
226
|
+
Example: Looping over items, processing each batch, then aggregating results:
|
|
227
|
+
- connect_nodes(source: "Loop Over Items", target: "Process Each Batch", sourceOutputIndex: 1) // Loop branch
|
|
228
|
+
- connect_nodes(source: "Loop Over Items", target: "Aggregate Results", sourceOutputIndex: 0) // Done branch
|
|
229
|
+
- connect_nodes(source: "Process Each Batch", target: "Loop Over Items") // Loop back for next batch
|
|
230
|
+
</node_connection_examples>`;
|
|
231
|
+
const CONNECTION_TYPES = `<connection_type_reference>
|
|
232
|
+
CONNECTION TYPES AND DIRECTIONS:
|
|
233
|
+
|
|
234
|
+
**Main Connections** (main) - Regular data flow, source outputs TO target:
|
|
186
235
|
- Trigger → HTTP Request → Set → Email
|
|
236
|
+
- AI Agent → Email (AI Agent's main output goes to next node)
|
|
187
237
|
|
|
188
|
-
**AI
|
|
238
|
+
**AI Capability Connections** - Sub-nodes connect TO their parent node:
|
|
239
|
+
Remember: Sub-node is SOURCE, Parent is TARGET
|
|
240
|
+
|
|
241
|
+
ai_languageModel - Language model provides LLM capability:
|
|
189
242
|
- OpenAI Chat Model → AI Agent
|
|
243
|
+
- Anthropic Chat Model → AI Agent
|
|
190
244
|
|
|
191
|
-
|
|
245
|
+
ai_tool - Tool provides action capability:
|
|
192
246
|
- Calculator Tool → AI Agent
|
|
193
|
-
-
|
|
247
|
+
- HTTP Request Tool → AI Agent
|
|
248
|
+
- Code Tool → AI Agent
|
|
249
|
+
- AI Agent Tool → AI Agent (multi-agent systems)
|
|
194
250
|
|
|
195
|
-
|
|
196
|
-
-
|
|
251
|
+
ai_memory - Memory provides conversation history:
|
|
252
|
+
- Window Buffer Memory → AI Agent
|
|
253
|
+
- Postgres Chat Memory → AI Agent
|
|
197
254
|
|
|
198
|
-
|
|
255
|
+
ai_outputParser - Parser provides structured output capability:
|
|
256
|
+
- Structured Output Parser → AI Agent
|
|
257
|
+
|
|
258
|
+
ai_document - Document loader provides documents:
|
|
259
|
+
- Default Data Loader → Vector Store
|
|
260
|
+
|
|
261
|
+
ai_embedding - Embeddings provides vector generation:
|
|
199
262
|
- OpenAI Embeddings → Vector Store
|
|
263
|
+
- Cohere Embeddings → Vector Store
|
|
200
264
|
|
|
201
|
-
|
|
265
|
+
ai_textSplitter - Splitter provides chunking capability:
|
|
202
266
|
- Token Text Splitter → Document Loader
|
|
267
|
+
- Recursive Character Text Splitter → Document Loader
|
|
203
268
|
|
|
204
|
-
|
|
205
|
-
-
|
|
269
|
+
ai_vectorStore - Vector store provides retrieval (when used as tool):
|
|
270
|
+
- Vector Store (mode: retrieve-as-tool) → AI Agent [ai_tool]
|
|
206
271
|
|
|
207
|
-
|
|
208
|
-
|
|
272
|
+
COMMON MISTAKES TO AVOID:
|
|
273
|
+
❌ AI Agent → OpenAI Chat Model (WRONG - model provides TO agent)
|
|
274
|
+
❌ AI Agent → Calculator Tool (WRONG - tool provides TO agent)
|
|
275
|
+
❌ AI Agent → Window Buffer Memory (WRONG - memory provides TO agent)
|
|
276
|
+
✅ OpenAI Chat Model → AI Agent (CORRECT)
|
|
277
|
+
✅ Calculator Tool → AI Agent (CORRECT)
|
|
278
|
+
✅ Window Buffer Memory → AI Agent (CORRECT)
|
|
279
|
+
</connection_type_reference>`;
|
|
209
280
|
const RESTRICTIONS = `- Respond before calling validate_structure
|
|
210
281
|
- Skip validation even if you think structure is correct
|
|
211
282
|
- Add commentary between tool calls - execute tools silently
|
|
@@ -234,6 +305,7 @@ function buildBuilderPrompt() {
|
|
|
234
305
|
.section('agent_node_distinction', AGENT_NODE_DISTINCTION)
|
|
235
306
|
.section('rag_workflow_pattern', RAG_PATTERN)
|
|
236
307
|
.section('switch_node_pattern', SWITCH_NODE_PATTERN)
|
|
308
|
+
.section('node_connection_examples', NODE_CONNECTION_EXAMPLES)
|
|
237
309
|
.section('connection_type_examples', CONNECTION_TYPES)
|
|
238
310
|
.section('do_not', RESTRICTIONS)
|
|
239
311
|
.section('response_format', RESPONSE_FORMAT)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/builder.prompt.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"builder.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/builder.prompt.ts"],"names":[],"mappings":";;AA0TA,gDAsBC;AAzUD,wCAAoC;AAEpC,MAAM,YAAY,GAAG,oEAAoE,CAAC;AAE1F,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;mEAoBwC,CAAC;AAEpE,MAAM,aAAa,GAAG;;;;oFAI8D,CAAC;AAErF,MAAM,oBAAoB,GAAG;;;;;;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AAC,uBAAuB,EAAE,aAAa,CAAC;SAC/C,OAAO,CAAC,gCAAgC,EAAE,qBAAqB,CAAC;SAChE,OAAO,CAAC,mCAAmC,EAAE,wBAAwB,CAAC;SACtE,OAAO,CAAC,gCAAgC,EAAE,cAAc,CAAC;SACzD,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC;SAC/B,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC;SAC3B,OAAO,CAAC,wBAAwB,EAAE,sBAAsB,CAAC;SACzD,OAAO,CAAC,sBAAsB,EAAE,WAAW,CAAC;SAC5C,OAAO,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;SACnD,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,0BAA0B,EAAE,gBAAgB,CAAC;SACrD,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC;SAC/B,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC;SAC3C,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -6,18 +6,22 @@ const builder_1 = require("../builder");
|
|
|
6
6
|
const CONFIGURATOR_ROLE = 'You are a Configurator Agent specialized in setting up n8n node parameters.';
|
|
7
7
|
const EXECUTION_SEQUENCE = `You MUST follow these steps IN ORDER. Do not skip any step.
|
|
8
8
|
|
|
9
|
-
STEP 1:
|
|
9
|
+
STEP 1: RETRIEVE NODE EXAMPLES
|
|
10
|
+
- Call the get_node_configuration_examples tool for each node type being configured
|
|
11
|
+
- Use the examples to understand how these node types can be configured
|
|
12
|
+
|
|
13
|
+
STEP 2: CONFIGURE ALL NODES
|
|
10
14
|
- Call update_node_parameters for EVERY node in the workflow
|
|
11
15
|
- Configure multiple nodes in PARALLEL for efficiency
|
|
12
16
|
- Do NOT respond with text - START CONFIGURING immediately
|
|
13
17
|
|
|
14
|
-
STEP
|
|
18
|
+
STEP 3: VALIDATE (REQUIRED)
|
|
15
19
|
- After ALL configurations complete, call validate_configuration
|
|
16
20
|
- This step is MANDATORY - you cannot finish without it
|
|
17
21
|
- If validation finds issues, fix them and validate again
|
|
18
22
|
- MAXIMUM 3 VALIDATION ATTEMPTS: After 3 calls to validate_configuration, proceed to respond regardless of remaining issues
|
|
19
23
|
|
|
20
|
-
STEP
|
|
24
|
+
STEP 4: RESPOND TO USER
|
|
21
25
|
- Only after validation passes, provide your response
|
|
22
26
|
|
|
23
27
|
NEVER respond to the user without calling validate_configuration first`;
|
|
@@ -88,6 +92,19 @@ For numeric ranges (e.g., $100-$1000):
|
|
|
88
92
|
- Second: lte (less than or equal)
|
|
89
93
|
|
|
90
94
|
Always set renameOutput: true and provide descriptive outputKey labels.`;
|
|
95
|
+
const NODE_CONFIGURATION_EXAMPLES = `NODE CONFIGURATION EXAMPLES:
|
|
96
|
+
When configuring complex nodes, use get_node_configuration_examples to see real-world examples from community templates:
|
|
97
|
+
|
|
98
|
+
When to use:
|
|
99
|
+
- Before configuring nodes with complex parameters (HTTP Request, Code, IF, Switch)
|
|
100
|
+
- When you need to understand proper parameter structure for unfamiliar nodes
|
|
101
|
+
- When user requests a specific integration pattern
|
|
102
|
+
|
|
103
|
+
Usage:
|
|
104
|
+
- Call with nodeType: "n8n-nodes-base.httpRequest" (exact node type name)
|
|
105
|
+
- Optionally filter by nodeVersion if needed
|
|
106
|
+
- Examples show proven parameter configurations from community workflows
|
|
107
|
+
- Use as reference for proper parameter structure and values`;
|
|
91
108
|
const RESPONSE_FORMAT = `After validation passes, provide a concise summary:
|
|
92
109
|
- List any placeholders requiring user configuration (e.g., "URL placeholder needs actual endpoint")
|
|
93
110
|
- Note which nodes were configured and key settings applied
|
|
@@ -118,6 +135,7 @@ function buildConfiguratorPrompt() {
|
|
|
118
135
|
.section('critical_parameters', CRITICAL_PARAMETERS)
|
|
119
136
|
.section('default_values_warning', DEFAULT_VALUES_WARNING)
|
|
120
137
|
.section('switch_node_configuration', SWITCH_NODE_CONFIGURATION)
|
|
138
|
+
.section('node_configuration_examples', NODE_CONFIGURATION_EXAMPLES)
|
|
121
139
|
.section('response_format', RESPONSE_FORMAT)
|
|
122
140
|
.section('do_not', RESTRICTIONS)
|
|
123
141
|
.build();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurator.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/configurator.prompt.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"configurator.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/configurator.prompt.ts"],"names":[],"mappings":";;;AAiJA,0DAeC;AAzJD,wCAAoC;AAEpC,MAAM,iBAAiB,GACtB,6EAA6E,CAAC;AAE/E,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;uEAoB4C,CAAC;AAExE,MAAM,uBAAuB,GAAG;;iGAEiE,CAAC;AAElG,MAAM,uBAAuB,GAAG;;;;8CAIc,CAAC;AAE/C,MAAM,gBAAgB,GAAG;;;;;;;;;;;8DAWqC,CAAC;AAE/D,MAAM,qBAAqB,GAAG;;;;;;;;;+DASiC,CAAC;AAEhE,MAAM,mBAAmB,GAAG;;;;;;;uEAO2C,CAAC;AAExE,MAAM,sBAAsB,GAAG;;;+GAGgF,CAAC;AAEhH,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;wEAwBsC,CAAC;AAEzE,MAAM,2BAA2B,GAAG;;;;;;;;;;;;6DAYyB,CAAC;AAE9D,MAAM,eAAe,GAAG;;;8GAGsF,CAAC;AAE/G,MAAM,YAAY,GAAG;;6DAEwC,CAAC;AAGjD,QAAA,mBAAmB,GAAG;;;;;;;;;;;CAWlC,CAAC;AAEF,SAAgB,uBAAuB;IACtC,OAAO,IAAA,gBAAM,GAAE;SACb,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC;SAClC,OAAO,CAAC,8BAA8B,EAAE,kBAAkB,CAAC;SAC3D,OAAO,CAAC,yBAAyB,EAAE,uBAAuB,CAAC;SAC3D,OAAO,CAAC,yBAAyB,EAAE,uBAAuB,CAAC;SAC3D,OAAO,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;SAC7C,OAAO,CAAC,uBAAuB,EAAE,qBAAqB,CAAC;SACvD,OAAO,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;SACnD,OAAO,CAAC,wBAAwB,EAAE,sBAAsB,CAAC;SACzD,OAAO,CAAC,2BAA2B,EAAE,yBAAyB,CAAC;SAC/D,OAAO,CAAC,6BAA6B,EAAE,2BAA2B,CAAC;SACnE,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC;SAC3C,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC;SAC/B,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -205,7 +205,8 @@ const CRITICAL_RULES = `- NEVER ask clarifying questions
|
|
|
205
205
|
- NEVER guess node versions - always use search_nodes to find exact versions
|
|
206
206
|
- ONLY flag connectionChangingParameters if they appear in <input> or <output> expressions
|
|
207
207
|
- If no parameters appear in connection expressions, return empty array []
|
|
208
|
-
- Output ONLY: nodesFound with {{ nodeName, version, reasoning, connectionChangingParameters }}
|
|
208
|
+
- Output ONLY: nodesFound with {{ nodeName, version, reasoning, connectionChangingParameters }}
|
|
209
|
+
- When user specifies a model name (e.g., 'gpt-4.1-mini') try to use this if it is a valid option`;
|
|
209
210
|
const RESTRICTIONS = `- Output text commentary between tool calls
|
|
210
211
|
- Include bestPractices or categorization in submit_discovery_results
|
|
211
212
|
- Flag parameters that don't affect connections
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/discovery.prompt.ts"],"names":[],"mappings":";;;AA2HA,kDAIC;AAED,oEAIC;
|
|
1
|
+
{"version":3,"file":"discovery.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/discovery.prompt.ts"],"names":[],"mappings":";;;AA2HA,kDAIC;AAED,oEAIC;AA2JD,oDAiBC;AA1SD,2DAIgC;AAEhC,wCAAoC;AAGvB,QAAA,sBAAsB,GAG9B;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EF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,SAAgB,oBAAoB,CAAC,OAA+B;IACnE,MAAM,cAAc,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAEnD,OAAO,IAAA,gBAAM,GAAE;SACb,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC;SAC/B,OAAO,CAAC,iBAAiB,EAAE,cAAc,CAAC;SAC1C,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC;SAChC,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,gCAAgC,EAAE,qBAAqB,CAAC;SAChE,OAAO,CAAC,sBAAsB,EAAE,oBAAoB,CAAC;SACrD,OAAO,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;SACjD,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,gBAAgB,EAAE,cAAc,CAAC;SACzC,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC;SAC/B,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EMBEDDING_NODES_GUIDE = void 0;
|
|
4
|
+
exports.EMBEDDING_NODES_GUIDE = {
|
|
5
|
+
patterns: ['@n8n/n8n-nodes-langchain.embeddings*'],
|
|
6
|
+
content: `
|
|
7
|
+
## CRITICAL: Embedding Models vs Chat Models
|
|
8
|
+
|
|
9
|
+
Embedding nodes (nodes with "embeddings" in their type name) MUST use embedding models, NOT chat/language models. Using a chat model in an embedding node will cause the workflow to fail.
|
|
10
|
+
|
|
11
|
+
### Common Mistake to Avoid
|
|
12
|
+
NEVER configure an embedding node with chat models like:
|
|
13
|
+
- gpt-4, gpt-4o, gpt-4o-mini, gpt-3.5-turbo (OpenAI chat models)
|
|
14
|
+
- claude-3-opus, claude-3-sonnet (Anthropic chat models)
|
|
15
|
+
- gemini-pro, gemini-1.5-pro (Google chat models)
|
|
16
|
+
- llama-3, mixtral (general LLM models)
|
|
17
|
+
|
|
18
|
+
These are language/chat models designed for text generation, NOT for creating embeddings.
|
|
19
|
+
|
|
20
|
+
### Correct Embedding Models by Provider
|
|
21
|
+
|
|
22
|
+
#### OpenAI Embeddings
|
|
23
|
+
- text-embedding-3-small (RECOMMENDED - default)
|
|
24
|
+
- text-embedding-3-large
|
|
25
|
+
- text-embedding-ada-002 (legacy)
|
|
26
|
+
|
|
27
|
+
#### AWS Bedrock Embeddings
|
|
28
|
+
- amazon.titan-embed-text-v1
|
|
29
|
+
- amazon.titan-embed-text-v2:0
|
|
30
|
+
- cohere.embed-english-v3
|
|
31
|
+
- cohere.embed-multilingual-v3
|
|
32
|
+
|
|
33
|
+
#### Google Gemini Embeddings
|
|
34
|
+
- models/text-embedding-004 (RECOMMENDED - default)
|
|
35
|
+
- models/embedding-001
|
|
36
|
+
|
|
37
|
+
#### Cohere Embeddings
|
|
38
|
+
- embed-english-v3.0 (1024 dimensions)
|
|
39
|
+
- embed-multilingual-v3.0 (1024 dimensions)
|
|
40
|
+
- embed-english-light-v3.0 (384 dimensions)
|
|
41
|
+
- embed-multilingual-light-v3.0 (384 dimensions)
|
|
42
|
+
- embed-english-v2.0 (4096 dimensions)
|
|
43
|
+
|
|
44
|
+
#### Mistral Embeddings
|
|
45
|
+
- mistral-embed (default)
|
|
46
|
+
|
|
47
|
+
#### Ollama Embeddings
|
|
48
|
+
- nomic-embed-text
|
|
49
|
+
- mxbai-embed-large
|
|
50
|
+
- all-minilm
|
|
51
|
+
- snowflake-arctic-embed
|
|
52
|
+
|
|
53
|
+
### How to Identify Embedding Models
|
|
54
|
+
Embedding model names typically contain:
|
|
55
|
+
- "embed" or "embedding" in the name
|
|
56
|
+
- "e5", "bge", "gte" (common embedding model families)
|
|
57
|
+
- "nomic", "minilm", "arctic" (embedding-specific models)
|
|
58
|
+
|
|
59
|
+
### Key Rules
|
|
60
|
+
1. ALWAYS check if the node type contains "embeddings" - if so, use an embedding model
|
|
61
|
+
2. If the user mentions a chat model (gpt-4, claude, gemini-pro, etc.) for embeddings, do NOT use it
|
|
62
|
+
3. Suggest the appropriate embedding model from the same provider instead
|
|
63
|
+
4. When in doubt, use the provider's default embedding model
|
|
64
|
+
|
|
65
|
+
### Parameter Names
|
|
66
|
+
The model parameter may be named:
|
|
67
|
+
- "model" (OpenAI, Bedrock, Mistral, Ollama, Azure)
|
|
68
|
+
- "modelName" (Google Gemini, Cohere)`,
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=embedding-nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding-nodes.js","sourceRoot":"","sources":["../../../../../src/prompts/chains/parameter-updater/guides/embedding-nodes.ts"],"names":[],"mappings":";;;AAEa,QAAA,qBAAqB,GAAkB;IACnD,QAAQ,EAAE,CAAC,sCAAsC,CAAC;IAClD,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCA8D4B;CACrC,CAAC"}
|
|
@@ -4,6 +4,7 @@ export { SWITCH_NODE_GUIDE } from './switch-node';
|
|
|
4
4
|
export { HTTP_REQUEST_GUIDE } from './http-request';
|
|
5
5
|
export { TOOL_NODES_GUIDE } from './tool-nodes';
|
|
6
6
|
export { GMAIL_GUIDE } from './gmail';
|
|
7
|
+
export { EMBEDDING_NODES_GUIDE } from './embedding-nodes';
|
|
7
8
|
export { RESOURCE_LOCATOR_GUIDE } from './resource-locator';
|
|
8
9
|
export { SYSTEM_MESSAGE_GUIDE } from './system-message';
|
|
9
10
|
export { TEXT_FIELDS_GUIDE } from './text-fields';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TEXT_FIELDS_GUIDE = exports.SYSTEM_MESSAGE_GUIDE = exports.RESOURCE_LOCATOR_GUIDE = exports.GMAIL_GUIDE = exports.TOOL_NODES_GUIDE = exports.HTTP_REQUEST_GUIDE = exports.SWITCH_NODE_GUIDE = exports.IF_NODE_GUIDE = exports.SET_NODE_GUIDE = void 0;
|
|
3
|
+
exports.TEXT_FIELDS_GUIDE = exports.SYSTEM_MESSAGE_GUIDE = exports.RESOURCE_LOCATOR_GUIDE = exports.EMBEDDING_NODES_GUIDE = exports.GMAIL_GUIDE = exports.TOOL_NODES_GUIDE = exports.HTTP_REQUEST_GUIDE = exports.SWITCH_NODE_GUIDE = exports.IF_NODE_GUIDE = exports.SET_NODE_GUIDE = void 0;
|
|
4
4
|
var set_node_1 = require("./set-node");
|
|
5
5
|
Object.defineProperty(exports, "SET_NODE_GUIDE", { enumerable: true, get: function () { return set_node_1.SET_NODE_GUIDE; } });
|
|
6
6
|
var if_node_1 = require("./if-node");
|
|
@@ -13,6 +13,8 @@ var tool_nodes_1 = require("./tool-nodes");
|
|
|
13
13
|
Object.defineProperty(exports, "TOOL_NODES_GUIDE", { enumerable: true, get: function () { return tool_nodes_1.TOOL_NODES_GUIDE; } });
|
|
14
14
|
var gmail_1 = require("./gmail");
|
|
15
15
|
Object.defineProperty(exports, "GMAIL_GUIDE", { enumerable: true, get: function () { return gmail_1.GMAIL_GUIDE; } });
|
|
16
|
+
var embedding_nodes_1 = require("./embedding-nodes");
|
|
17
|
+
Object.defineProperty(exports, "EMBEDDING_NODES_GUIDE", { enumerable: true, get: function () { return embedding_nodes_1.EMBEDDING_NODES_GUIDE; } });
|
|
16
18
|
var resource_locator_1 = require("./resource-locator");
|
|
17
19
|
Object.defineProperty(exports, "RESOURCE_LOCATOR_GUIDE", { enumerable: true, get: function () { return resource_locator_1.RESOURCE_LOCATOR_GUIDE; } });
|
|
18
20
|
var system_message_1 = require("./system-message");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/prompts/chains/parameter-updater/guides/index.ts"],"names":[],"mappings":";;;AACA,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,+CAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAC3B,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA;AACzB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/prompts/chains/parameter-updater/guides/index.ts"],"names":[],"mappings":";;;AACA,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,+CAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAC3B,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA;AACzB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,qDAA0D;AAAjD,wHAAA,qBAAqB,OAAA;AAG9B,uDAA4D;AAAnD,0HAAA,sBAAsB,OAAA;AAC/B,mDAAwD;AAA/C,sHAAA,oBAAoB,OAAA;AAC7B,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/prompts/chains/parameter-updater/registry.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/prompts/chains/parameter-updater/registry.ts"],"names":[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,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACtD,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CACzC,CAAC;QACF,IAAI,CAAC,cAAc;YAAE,OAAO,KAAK,CAAC;QAGlC,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAClD,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;AACJ,CAAC;AAQD,SAAgB,mBAAmB,CAAC,OAAsB;IACzD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;QAElC,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACxD,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CACzC,CAAC;QACF,IAAI,CAAC,cAAc;YAAE,OAAO,KAAK,CAAC;QAGlC,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YACtD,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -12,4 +12,5 @@ export declare class SessionManagerService {
|
|
|
12
12
|
getSessions(workflowId: string | undefined, userId: string | undefined): Promise<{
|
|
13
13
|
sessions: Session[];
|
|
14
14
|
}>;
|
|
15
|
+
truncateMessagesAfter(workflowId: string, userId: string | undefined, messageId: string): Promise<boolean>;
|
|
15
16
|
}
|
|
@@ -14,9 +14,9 @@ exports.SessionManagerService = void 0;
|
|
|
14
14
|
const langgraph_1 = require("@langchain/langgraph");
|
|
15
15
|
const backend_common_1 = require("@n8n/backend-common");
|
|
16
16
|
const di_1 = require("@n8n/di");
|
|
17
|
-
const stream_processor_1 = require("./utils/stream-processor");
|
|
18
17
|
const builder_tools_1 = require("./tools/builder-tools");
|
|
19
18
|
const sessions_1 = require("./types/sessions");
|
|
19
|
+
const stream_processor_1 = require("./utils/stream-processor");
|
|
20
20
|
let SessionManagerService = SessionManagerService_1 = class SessionManagerService {
|
|
21
21
|
parsedNodeTypes;
|
|
22
22
|
logger;
|
|
@@ -50,11 +50,12 @@ let SessionManagerService = SessionManagerService_1 = class SessionManagerServic
|
|
|
50
50
|
const messages = (0, sessions_1.isLangchainMessagesArray)(rawMessages)
|
|
51
51
|
? rawMessages
|
|
52
52
|
: [];
|
|
53
|
+
const formattedMessages = (0, stream_processor_1.formatMessages)(messages, (0, builder_tools_1.getBuilderToolsForDisplay)({
|
|
54
|
+
nodeTypes: this.parsedNodeTypes,
|
|
55
|
+
}));
|
|
53
56
|
sessions.push({
|
|
54
57
|
sessionId: threadId,
|
|
55
|
-
messages:
|
|
56
|
-
nodeTypes: this.parsedNodeTypes,
|
|
57
|
-
})),
|
|
58
|
+
messages: formattedMessages,
|
|
58
59
|
lastUpdated: checkpoint.checkpoint.ts,
|
|
59
60
|
});
|
|
60
61
|
}
|
|
@@ -65,6 +66,56 @@ let SessionManagerService = SessionManagerService_1 = class SessionManagerServic
|
|
|
65
66
|
}
|
|
66
67
|
return { sessions };
|
|
67
68
|
}
|
|
69
|
+
async truncateMessagesAfter(workflowId, userId, messageId) {
|
|
70
|
+
const threadId = SessionManagerService_1.generateThreadId(workflowId, userId);
|
|
71
|
+
const threadConfig = {
|
|
72
|
+
configurable: {
|
|
73
|
+
thread_id: threadId,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
try {
|
|
77
|
+
const checkpointTuple = await this.checkpointer.getTuple(threadConfig);
|
|
78
|
+
if (!checkpointTuple?.checkpoint) {
|
|
79
|
+
this.logger?.debug('No checkpoint found for truncation', { threadId, messageId });
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const rawMessages = checkpointTuple.checkpoint.channel_values?.messages;
|
|
83
|
+
if (!(0, sessions_1.isLangchainMessagesArray)(rawMessages)) {
|
|
84
|
+
this.logger?.debug('No valid messages found for truncation', { threadId, messageId });
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const msgIndex = rawMessages.findIndex((msg) => msg.additional_kwargs?.messageId === messageId);
|
|
88
|
+
if (msgIndex === -1) {
|
|
89
|
+
this.logger?.debug('Message with messageId not found', { threadId, messageId });
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
const truncatedMessages = rawMessages.slice(0, msgIndex);
|
|
93
|
+
const updatedCheckpoint = {
|
|
94
|
+
...checkpointTuple.checkpoint,
|
|
95
|
+
channel_values: {
|
|
96
|
+
...checkpointTuple.checkpoint.channel_values,
|
|
97
|
+
messages: truncatedMessages,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
const metadata = checkpointTuple.metadata ?? {
|
|
101
|
+
source: 'update',
|
|
102
|
+
step: -1,
|
|
103
|
+
parents: {},
|
|
104
|
+
};
|
|
105
|
+
await this.checkpointer.put(threadConfig, updatedCheckpoint, metadata);
|
|
106
|
+
this.logger?.debug('Messages truncated successfully', {
|
|
107
|
+
threadId,
|
|
108
|
+
messageId,
|
|
109
|
+
originalCount: rawMessages.length,
|
|
110
|
+
newCount: truncatedMessages.length,
|
|
111
|
+
});
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
this.logger?.error('Failed to truncate messages', { threadId, messageId, error });
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
68
119
|
};
|
|
69
120
|
exports.SessionManagerService = SessionManagerService;
|
|
70
121
|
exports.SessionManagerService = SessionManagerService = SessionManagerService_1 = __decorate([
|