@n8n/ai-workflow-builder 1.0.2 → 1.1.1
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 +1 -0
- package/dist/agents/responder.agent.js +9 -33
- package/dist/agents/responder.agent.js.map +1 -1
- package/dist/agents/supervisor.agent.d.ts +1 -0
- package/dist/agents/supervisor.agent.js +7 -38
- package/dist/agents/supervisor.agent.js.map +1 -1
- package/dist/ai-workflow-builder-agent.service.d.ts +2 -1
- package/dist/ai-workflow-builder-agent.service.js +18 -12
- package/dist/ai-workflow-builder-agent.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/chains/conversation-compact.js +2 -13
- package/dist/chains/conversation-compact.js.map +1 -1
- package/dist/chains/parameter-updater.js +21 -7
- package/dist/chains/parameter-updater.js.map +1 -1
- package/dist/chains/prompt-categorization.js +3 -81
- package/dist/chains/prompt-categorization.js.map +1 -1
- package/dist/chains/workflow-name.js +2 -10
- package/dist/chains/workflow-name.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/multi-agent-workflow-subgraphs.d.ts +38 -1
- package/dist/multi-agent-workflow-subgraphs.js +34 -2
- package/dist/multi-agent-workflow-subgraphs.js.map +1 -1
- package/dist/parent-graph-state.d.ts +4 -0
- package/dist/parent-graph-state.js +14 -1
- package/dist/parent-graph-state.js.map +1 -1
- package/dist/prompts/agents/builder.prompt.d.ts +1 -0
- package/dist/prompts/agents/builder.prompt.js +242 -0
- package/dist/prompts/agents/builder.prompt.js.map +1 -0
- package/dist/prompts/agents/configurator.prompt.d.ts +2 -0
- package/dist/prompts/agents/configurator.prompt.js +125 -0
- package/dist/prompts/agents/configurator.prompt.js.map +1 -0
- package/dist/prompts/agents/discovery.prompt.d.ts +11 -0
- package/dist/prompts/agents/discovery.prompt.js +259 -0
- package/dist/prompts/agents/discovery.prompt.js.map +1 -0
- package/dist/prompts/agents/responder.prompt.d.ts +1 -0
- package/dist/prompts/agents/responder.prompt.js +41 -0
- package/dist/prompts/agents/responder.prompt.js.map +1 -0
- package/dist/prompts/agents/supervisor.prompt.d.ts +1 -0
- package/dist/prompts/agents/supervisor.prompt.js +43 -0
- package/dist/prompts/agents/supervisor.prompt.js.map +1 -0
- package/dist/prompts/builder/index.d.ts +2 -0
- package/dist/prompts/builder/index.js +7 -0
- package/dist/prompts/builder/index.js.map +1 -0
- package/dist/prompts/builder/prompt-builder.d.ts +17 -0
- package/dist/prompts/builder/prompt-builder.js +147 -0
- package/dist/prompts/builder/prompt-builder.js.map +1 -0
- package/dist/prompts/builder/types.d.ts +22 -0
- package/dist/prompts/builder/types.js +3 -0
- package/dist/prompts/builder/types.js.map +1 -0
- package/dist/prompts/chains/categorization.prompt.d.ts +43 -0
- package/dist/prompts/chains/categorization.prompt.js +86 -0
- package/dist/prompts/chains/categorization.prompt.js.map +1 -0
- package/dist/prompts/chains/compact.prompt.d.ts +2 -0
- package/dist/prompts/chains/compact.prompt.js +16 -0
- package/dist/prompts/chains/compact.prompt.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/examples/if-node.d.ts +2 -0
- package/dist/{chains/prompts/examples/basic/if-node-examples.js → prompts/chains/parameter-updater/examples/if-node.js} +6 -3
- package/dist/prompts/chains/parameter-updater/examples/if-node.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/examples/index.d.ts +6 -0
- package/dist/prompts/chains/parameter-updater/examples/index.js +16 -0
- package/dist/prompts/chains/parameter-updater/examples/index.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/examples/resource-locator.d.ts +2 -0
- package/dist/{chains/prompts/examples/advanced/resource-locator-examples.js → prompts/chains/parameter-updater/examples/resource-locator.js} +7 -3
- package/dist/prompts/chains/parameter-updater/examples/resource-locator.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/examples/set-node.d.ts +2 -0
- package/dist/{chains/prompts/examples/basic/set-node-examples.js → prompts/chains/parameter-updater/examples/set-node.js} +6 -3
- package/dist/prompts/chains/parameter-updater/examples/set-node.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/examples/simple-updates.d.ts +2 -0
- package/dist/{chains/prompts/examples/basic → prompts/chains/parameter-updater/examples}/simple-updates.js +8 -5
- package/dist/prompts/chains/parameter-updater/examples/simple-updates.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/examples/switch-node.d.ts +2 -0
- package/dist/prompts/chains/parameter-updater/examples/switch-node.js +131 -0
- package/dist/prompts/chains/parameter-updater/examples/switch-node.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/examples/tool-nodes.d.ts +2 -0
- package/dist/{chains/prompts/examples/advanced/tool-node-examples.js → prompts/chains/parameter-updater/examples/tool-nodes.js} +6 -3
- package/dist/prompts/chains/parameter-updater/examples/tool-nodes.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/gmail.d.ts +2 -0
- package/dist/prompts/chains/parameter-updater/guides/gmail.js +28 -0
- package/dist/prompts/chains/parameter-updater/guides/gmail.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/http-request.d.ts +2 -0
- package/dist/{chains/prompts/node-types → prompts/chains/parameter-updater/guides}/http-request.js +34 -8
- package/dist/prompts/chains/parameter-updater/guides/http-request.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/if-node.d.ts +2 -0
- package/dist/{chains/prompts/node-types → prompts/chains/parameter-updater/guides}/if-node.js +6 -5
- package/dist/prompts/chains/parameter-updater/guides/if-node.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/index.d.ts +9 -0
- package/dist/prompts/chains/parameter-updater/guides/index.js +22 -0
- package/dist/prompts/chains/parameter-updater/guides/index.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/resource-locator.d.ts +2 -0
- package/dist/{chains/prompts/parameter-types → prompts/chains/parameter-updater/guides}/resource-locator.js +6 -2
- package/dist/prompts/chains/parameter-updater/guides/resource-locator.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/set-node.d.ts +2 -0
- package/dist/{chains/prompts/node-types → prompts/chains/parameter-updater/guides}/set-node.js +5 -2
- package/dist/prompts/chains/parameter-updater/guides/set-node.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/switch-node.d.ts +2 -0
- package/dist/prompts/chains/parameter-updater/guides/switch-node.js +75 -0
- package/dist/prompts/chains/parameter-updater/guides/switch-node.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/system-message.d.ts +2 -0
- package/dist/{chains/prompts/parameter-types → prompts/chains/parameter-updater/guides}/system-message.js +25 -4
- package/dist/prompts/chains/parameter-updater/guides/system-message.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/text-fields.d.ts +2 -0
- package/dist/{chains/prompts/parameter-types → prompts/chains/parameter-updater/guides}/text-fields.js +11 -2
- package/dist/prompts/chains/parameter-updater/guides/text-fields.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/guides/tool-nodes.d.ts +2 -0
- package/dist/{chains/prompts/node-types → prompts/chains/parameter-updater/guides}/tool-nodes.js +5 -2
- package/dist/prompts/chains/parameter-updater/guides/tool-nodes.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/index.d.ts +8 -0
- package/dist/prompts/chains/parameter-updater/index.js +35 -0
- package/dist/prompts/chains/parameter-updater/index.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/instance-url.d.ts +1 -0
- package/dist/{chains/prompts → prompts/chains/parameter-updater}/instance-url.js +5 -6
- package/dist/prompts/chains/parameter-updater/instance-url.js.map +1 -0
- package/dist/{chains/prompts/base/core-instructions.d.ts → prompts/chains/parameter-updater/parameter-updater.prompt.d.ts} +3 -0
- package/dist/{chains/prompts/base/core-instructions.js → prompts/chains/parameter-updater/parameter-updater.prompt.js} +25 -2
- package/dist/prompts/chains/parameter-updater/parameter-updater.prompt.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/registry.d.ts +4 -0
- package/dist/prompts/chains/parameter-updater/registry.js +65 -0
- package/dist/prompts/chains/parameter-updater/registry.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/types.d.ts +18 -0
- package/dist/prompts/chains/parameter-updater/types.js +3 -0
- package/dist/prompts/chains/parameter-updater/types.js.map +1 -0
- package/dist/prompts/chains/parameter-updater/utils.d.ts +2 -0
- package/dist/prompts/chains/parameter-updater/utils.js +16 -0
- package/dist/prompts/chains/parameter-updater/utils.js.map +1 -0
- package/dist/prompts/chains/workflow-name.prompt.d.ts +2 -0
- package/dist/prompts/chains/workflow-name.prompt.js +11 -0
- package/dist/prompts/chains/workflow-name.prompt.js.map +1 -0
- package/dist/prompts/index.d.ts +12 -0
- package/dist/prompts/index.js +50 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/{tools/prompts/main-agent.prompt.js → prompts/legacy-agent.prompt.js} +14 -31
- package/dist/prompts/legacy-agent.prompt.js.map +1 -0
- package/dist/subgraphs/builder.subgraph.d.ts +2 -0
- package/dist/subgraphs/builder.subgraph.js +2 -163
- package/dist/subgraphs/builder.subgraph.js.map +1 -1
- package/dist/subgraphs/configurator.subgraph.d.ts +2 -0
- package/dist/subgraphs/configurator.subgraph.js +3 -84
- package/dist/subgraphs/configurator.subgraph.js.map +1 -1
- package/dist/subgraphs/discovery.subgraph.d.ts +18 -0
- package/dist/subgraphs/discovery.subgraph.js +28 -220
- package/dist/subgraphs/discovery.subgraph.js.map +1 -1
- package/dist/tools/add-node.tool.js +1 -1
- package/dist/tools/best-practices/chatbot.js +6 -7
- package/dist/tools/best-practices/chatbot.js.map +1 -1
- package/dist/tools/best-practices/content-generation.js +38 -2
- package/dist/tools/best-practices/content-generation.js.map +1 -1
- package/dist/tools/best-practices/data-transformation.js +17 -22
- package/dist/tools/best-practices/data-transformation.js.map +1 -1
- package/dist/tools/best-practices/index.js +2 -1
- package/dist/tools/best-practices/index.js.map +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/coordination.d.ts +8 -2
- package/dist/types/coordination.js +4 -0
- package/dist/types/coordination.js.map +1 -1
- package/dist/types/discovery-types.d.ts +2 -0
- package/dist/utils/coordination-log.d.ts +2 -1
- package/dist/utils/coordination-log.js.map +1 -1
- package/dist/utils/state-modifier.d.ts +32 -0
- package/dist/utils/state-modifier.js +112 -0
- package/dist/utils/state-modifier.js.map +1 -0
- package/dist/utils/state-reducers.d.ts +4 -0
- package/dist/utils/state-reducers.js +25 -0
- package/dist/utils/state-reducers.js.map +1 -0
- package/dist/utils/stream-processor.js +2 -30
- package/dist/utils/stream-processor.js.map +1 -1
- package/dist/utils/subgraph-helpers.d.ts +3 -0
- package/dist/utils/subgraph-helpers.js +23 -0
- package/dist/utils/subgraph-helpers.js.map +1 -1
- package/dist/validation/checks/connections.js +9 -16
- package/dist/validation/checks/connections.js.map +1 -1
- package/dist/validation/checks/credentials.d.ts +3 -0
- package/dist/validation/checks/credentials.js +125 -0
- package/dist/validation/checks/credentials.js.map +1 -0
- package/dist/validation/checks/index.d.ts +1 -0
- package/dist/validation/checks/index.js +3 -1
- package/dist/validation/checks/index.js.map +1 -1
- package/dist/validation/checks/tools.js +0 -10
- package/dist/validation/checks/tools.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 +4 -1
- package/dist/validation/types.js +2 -0
- package/dist/validation/types.js.map +1 -1
- package/dist/validation/utils/node-type-map.d.ts +8 -0
- package/dist/validation/utils/node-type-map.js +50 -0
- package/dist/validation/utils/node-type-map.js.map +1 -0
- package/dist/workflow-builder-agent.d.ts +7 -3
- package/dist/workflow-builder-agent.js +24 -15
- package/dist/workflow-builder-agent.js.map +1 -1
- package/dist/workflow-state.js +3 -14
- package/dist/workflow-state.js.map +1 -1
- package/package.json +8 -7
- package/dist/chains/prompts/base/common-patterns.d.ts +0 -1
- package/dist/chains/prompts/base/common-patterns.js +0 -13
- package/dist/chains/prompts/base/common-patterns.js.map +0 -1
- package/dist/chains/prompts/base/core-instructions.js.map +0 -1
- package/dist/chains/prompts/base/expression-rules.d.ts +0 -1
- package/dist/chains/prompts/base/expression-rules.js +0 -15
- package/dist/chains/prompts/base/expression-rules.js.map +0 -1
- package/dist/chains/prompts/base/output-format.d.ts +0 -1
- package/dist/chains/prompts/base/output-format.js +0 -7
- package/dist/chains/prompts/base/output-format.js.map +0 -1
- package/dist/chains/prompts/examples/advanced/resource-locator-examples.d.ts +0 -1
- package/dist/chains/prompts/examples/advanced/resource-locator-examples.js.map +0 -1
- package/dist/chains/prompts/examples/advanced/tool-node-examples.d.ts +0 -1
- package/dist/chains/prompts/examples/advanced/tool-node-examples.js.map +0 -1
- package/dist/chains/prompts/examples/basic/if-node-examples.d.ts +0 -1
- package/dist/chains/prompts/examples/basic/if-node-examples.js.map +0 -1
- package/dist/chains/prompts/examples/basic/set-node-examples.d.ts +0 -1
- package/dist/chains/prompts/examples/basic/set-node-examples.js.map +0 -1
- package/dist/chains/prompts/examples/basic/simple-updates.d.ts +0 -1
- package/dist/chains/prompts/examples/basic/simple-updates.js.map +0 -1
- package/dist/chains/prompts/instance-url.d.ts +0 -1
- package/dist/chains/prompts/instance-url.js.map +0 -1
- package/dist/chains/prompts/node-types/http-request.d.ts +0 -1
- package/dist/chains/prompts/node-types/http-request.js.map +0 -1
- package/dist/chains/prompts/node-types/if-node.d.ts +0 -1
- package/dist/chains/prompts/node-types/if-node.js.map +0 -1
- package/dist/chains/prompts/node-types/set-node.d.ts +0 -1
- package/dist/chains/prompts/node-types/set-node.js.map +0 -1
- package/dist/chains/prompts/node-types/tool-nodes.d.ts +0 -1
- package/dist/chains/prompts/node-types/tool-nodes.js.map +0 -1
- package/dist/chains/prompts/parameter-types/resource-locator.d.ts +0 -1
- package/dist/chains/prompts/parameter-types/resource-locator.js.map +0 -1
- package/dist/chains/prompts/parameter-types/system-message.d.ts +0 -1
- package/dist/chains/prompts/parameter-types/system-message.js.map +0 -1
- package/dist/chains/prompts/parameter-types/text-fields.d.ts +0 -1
- package/dist/chains/prompts/parameter-types/text-fields.js.map +0 -1
- package/dist/chains/prompts/prompt-builder.d.ts +0 -15
- package/dist/chains/prompts/prompt-builder.js +0 -140
- package/dist/chains/prompts/prompt-builder.js.map +0 -1
- package/dist/chains/prompts/prompt-config.d.ts +0 -5
- package/dist/chains/prompts/prompt-config.js +0 -52
- package/dist/chains/prompts/prompt-config.js.map +0 -1
- package/dist/tools/prompts/main-agent.prompt.js.map +0 -1
- /package/dist/{tools/prompts/main-agent.prompt.d.ts → prompts/legacy-agent.prompt.d.ts} +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBuilderPrompt = buildBuilderPrompt;
|
|
4
|
+
const builder_1 = require("../builder");
|
|
5
|
+
const BUILDER_ROLE = 'You are a Builder Agent specialized in constructing n8n workflows.';
|
|
6
|
+
const EXECUTION_SEQUENCE = `You MUST follow these steps IN ORDER. Do not skip any step.
|
|
7
|
+
|
|
8
|
+
STEP 1: CREATE NODES
|
|
9
|
+
- Call add_nodes for EVERY node needed based on discovery results
|
|
10
|
+
- Create multiple nodes in PARALLEL for efficiency
|
|
11
|
+
- Do NOT respond with text - START BUILDING immediately
|
|
12
|
+
|
|
13
|
+
STEP 2: CONNECT NODES
|
|
14
|
+
- Call connect_nodes for ALL required connections
|
|
15
|
+
- Connect multiple node pairs in PARALLEL
|
|
16
|
+
|
|
17
|
+
STEP 3: VALIDATE (REQUIRED)
|
|
18
|
+
- After ALL nodes and connections are created, call validate_structure
|
|
19
|
+
- This step is MANDATORY - you cannot finish without it
|
|
20
|
+
- If validation finds issues (missing trigger, invalid connections), fix them and validate again
|
|
21
|
+
- MAXIMUM 3 VALIDATION ATTEMPTS: After 3 calls to validate_structure, proceed to respond regardless of remaining issues
|
|
22
|
+
|
|
23
|
+
STEP 4: RESPOND TO USER
|
|
24
|
+
- Only after validation passes, provide your brief summary
|
|
25
|
+
|
|
26
|
+
NEVER respond to the user without calling validate_structure first`;
|
|
27
|
+
const NODE_CREATION = `Each add_nodes call creates ONE node. You must provide:
|
|
28
|
+
- nodeType: The exact type from discovery (e.g., "n8n-nodes-base.httpRequest" for the "HTTP Request node")
|
|
29
|
+
- name: Descriptive name (e.g., "Fetch Weather Data")
|
|
30
|
+
- connectionParametersReasoning: Explain your thinking about connection parameters
|
|
31
|
+
- connectionParameters: Parameters that affect connections (or {{}} if none needed)`;
|
|
32
|
+
const WORKFLOW_CONFIG_NODE = `Always include a Workflow Configuration node at the start of every workflow.
|
|
33
|
+
|
|
34
|
+
The Workflow Configuration node (n8n-nodes-base.set) should be placed immediately after the trigger node and before all other processing nodes.
|
|
35
|
+
|
|
36
|
+
Placement rules:
|
|
37
|
+
- Add between trigger and first processing node
|
|
38
|
+
- Connect: Trigger → Workflow Configuration → First processing node
|
|
39
|
+
- Name it "Workflow Configuration"`;
|
|
40
|
+
const DATA_PARSING = `Code nodes are slower than core n8n nodes (like Edit Fields, If, Switch, etc.) as they run in a sandboxed environment. Use Code nodes as a last resort for custom business logic.
|
|
41
|
+
For binary file data, use Extract From File node to extract content from files before processing.
|
|
42
|
+
|
|
43
|
+
For AI-generated structured data, use a Structured Output Parser node. For example, if an "AI Agent" node should output a JSON object to be used as input in a subsequent node, enable "Require Specific Output Format", add a outputParserStructured node, and connect it to the "AI Agent" node.
|
|
44
|
+
|
|
45
|
+
When Discovery results include AI Agent or Structured Output Parser:
|
|
46
|
+
1. Create the Structured Output Parser node
|
|
47
|
+
2. Set AI Agent's hasOutputParser: true in connectionParameters
|
|
48
|
+
3. Connect: Structured Output Parser → AI Agent (ai_outputParser connection)`;
|
|
49
|
+
const PROACTIVE_DESIGN = `Anticipate workflow needs:
|
|
50
|
+
- Switch or If nodes for conditional logic when multiple outcomes exist
|
|
51
|
+
- Edit Fields nodes for data transformation between incompatible formats
|
|
52
|
+
- Edit Fields nodes to prepare data for a node like Gmail, Slack, Telegram, or Google Sheets
|
|
53
|
+
- Schedule Triggers for recurring tasks
|
|
54
|
+
- Error handling for external service calls
|
|
55
|
+
|
|
56
|
+
NEVER use Split In Batches nodes.`;
|
|
57
|
+
const NODE_DEFAULTS = `CRITICAL: NEVER RELY ON DEFAULT PARAMETER VALUES FOR CONNECTIONS
|
|
58
|
+
|
|
59
|
+
Default values often hide connection inputs/outputs. You MUST explicitly configure parameters that affect connections:
|
|
60
|
+
- Vector Store: Mode parameter affects available connections - always set explicitly (e.g., mode: "insert", "retrieve", "retrieve-as-tool")
|
|
61
|
+
- AI Agent: hasOutputParser is off by default, but your workflow may need it to be on
|
|
62
|
+
- Document Loader: textSplittingMode affects whether it accepts a text splitter input - always set explicitly (e.g., textSplittingMode: "custom")
|
|
63
|
+
|
|
64
|
+
ALWAYS check node details and set connectionParameters explicitly.`;
|
|
65
|
+
const CONNECTION_PARAMETERS = `- Static nodes (HTTP Request, Set, Code): reasoning="Static inputs/outputs", parameters={{}}
|
|
66
|
+
- AI Agent with structured output: reasoning="hasOutputParser enables ai_outputParser input for Structured Output Parser", parameters={{ hasOutputParser: true }}
|
|
67
|
+
- Vector Store insert: reasoning="Insert mode requires document input", parameters={{ mode: "insert" }}
|
|
68
|
+
- Vector Store insert for AI Agent: reasoning="Vector store will be used for AI Agent needs retrieve-as-tool mode", parameters={{ mode: "retrieve-as-tool" }}
|
|
69
|
+
- Document Loader custom: reasoning="Custom mode enables text splitter input", parameters={{ textSplittingMode: "custom" }}
|
|
70
|
+
- Switch with routing rules: reasoning="Switch needs N outputs, creating N rules.values entries with outputKeys", parameters={{ mode: "rules", rules: {{ values: [...] }} }} - see <switch_node_pattern> for full structure`;
|
|
71
|
+
const STRUCTURED_OUTPUT_PARSER = `WHEN TO SET hasOutputParser: true on AI Agent:
|
|
72
|
+
- Discovery found Structured Output Parser node → MUST set hasOutputParser: true
|
|
73
|
+
- AI output will be used in conditions (IF/Switch nodes checking $json.field)
|
|
74
|
+
- AI output will be formatted/displayed (HTML emails, reports with specific sections)
|
|
75
|
+
- AI output will be stored in database/data tables with specific fields
|
|
76
|
+
- AI is classifying, scoring, or extracting specific data fields`;
|
|
77
|
+
const AI_CONNECTIONS = `n8n connections flow from SOURCE (output) to TARGET (input).
|
|
78
|
+
|
|
79
|
+
Regular data flow: Source node output → Target node input
|
|
80
|
+
Example: HTTP Request → Set (HTTP Request is source, Set is target)
|
|
81
|
+
|
|
82
|
+
AI sub-nodes PROVIDE capabilities, making them the SOURCE:
|
|
83
|
+
- OpenAI Chat Model → AI Agent [ai_languageModel]
|
|
84
|
+
- Calculator Tool → AI Agent [ai_tool]
|
|
85
|
+
- Window Buffer Memory → AI Agent [ai_memory]
|
|
86
|
+
- Token Splitter → Default Data Loader [ai_textSplitter]
|
|
87
|
+
- Default Data Loader → Vector Store [ai_document]
|
|
88
|
+
- Embeddings OpenAI → Vector Store [ai_embedding]`;
|
|
89
|
+
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
|
+
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
|
+
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.
|
|
92
|
+
To merge the data of two branches together in a single run, use a merge node. This node performs set operations on the inputs it receives:
|
|
93
|
+
- Union
|
|
94
|
+
- Mode: append
|
|
95
|
+
- Inner join
|
|
96
|
+
- Mode: combine
|
|
97
|
+
- Combine by: Matching fields
|
|
98
|
+
- Output type: Keep matches
|
|
99
|
+
- Left join
|
|
100
|
+
- Mode: combine
|
|
101
|
+
- Combine by: Matching fields
|
|
102
|
+
- Output type: Enrich input 1
|
|
103
|
+
- Right join
|
|
104
|
+
- Mode: combine
|
|
105
|
+
- Combine by: Matching fields
|
|
106
|
+
- Output type: Enrich input 2
|
|
107
|
+
- Cross join
|
|
108
|
+
- Mode: combine
|
|
109
|
+
- Combine by: All possible combinations
|
|
110
|
+
- Outer join
|
|
111
|
+
- Mode: combine
|
|
112
|
+
- Combine by: Matching fields
|
|
113
|
+
- Output type: Keep everything
|
|
114
|
+
|
|
115
|
+
Examples:
|
|
116
|
+
- Enriching a dataset with another one
|
|
117
|
+
- Matching items between two datasets`;
|
|
118
|
+
const AGENT_NODE_DISTINCTION = `Distinguish between two different agent node types:
|
|
119
|
+
|
|
120
|
+
1. **AI Agent** (@n8n/n8n-nodes-langchain.agent)
|
|
121
|
+
- Main workflow node that orchestrates AI tasks
|
|
122
|
+
- Use for: Primary AI logic, chatbots, autonomous workflows
|
|
123
|
+
|
|
124
|
+
2. **AI Agent Tool** (@n8n/n8n-nodes-langchain.agentTool)
|
|
125
|
+
- Sub-node that acts as a tool for another AI Agent
|
|
126
|
+
- Use for: Multi-agent systems where one agent calls another
|
|
127
|
+
|
|
128
|
+
When discovery results include "agent", use AI Agent unless explicitly specified as "agent tool" or "sub-agent".
|
|
129
|
+
When discovery results include "AI", use the AI Agent node, instead of a provider-specific node like googleGemini or openAi nodes.`;
|
|
130
|
+
const RAG_PATTERN = `For RAG (Retrieval-Augmented Generation) workflows:
|
|
131
|
+
|
|
132
|
+
Main data flow:
|
|
133
|
+
- Data source (e.g., HTTP Request) → Vector Store [main connection]
|
|
134
|
+
|
|
135
|
+
AI capability connections:
|
|
136
|
+
- Document Loader → Vector Store [ai_document]
|
|
137
|
+
- Embeddings → Vector Store [ai_embedding]
|
|
138
|
+
- Text Splitter → Document Loader [ai_textSplitter]
|
|
139
|
+
|
|
140
|
+
Common mistake to avoid:
|
|
141
|
+
- NEVER connect Document Loader to main data outputs
|
|
142
|
+
- Document Loader is an AI sub-node that gives Vector Store document processing capability`;
|
|
143
|
+
const SWITCH_NODE_PATTERN = `For Switch nodes with multiple routing paths:
|
|
144
|
+
- The number of outputs is determined by the number of entries in rules.values[]
|
|
145
|
+
- You MUST create the rules.values[] array with placeholder entries for each output branch
|
|
146
|
+
- Each entry needs: conditions structure (with empty leftValue/rightValue) + renameOutput: true + descriptive outputKey
|
|
147
|
+
- Configurator will fill in the actual condition values later
|
|
148
|
+
- Use descriptive node names like "Route by Amount" or "Route by Status"
|
|
149
|
+
|
|
150
|
+
Example connectionParameters for 3-way routing:
|
|
151
|
+
{{
|
|
152
|
+
"mode": "rules",
|
|
153
|
+
"rules": {{
|
|
154
|
+
"values": [
|
|
155
|
+
{{
|
|
156
|
+
"conditions": {{
|
|
157
|
+
"options": {{ "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }},
|
|
158
|
+
"conditions": [{{ "leftValue": "", "rightValue": "", "operator": {{ "type": "string", "operation": "equals" }} }}],
|
|
159
|
+
"combinator": "and"
|
|
160
|
+
}},
|
|
161
|
+
"renameOutput": true,
|
|
162
|
+
"outputKey": "Output 1 Name"
|
|
163
|
+
}},
|
|
164
|
+
{{
|
|
165
|
+
"conditions": {{
|
|
166
|
+
"options": {{ "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }},
|
|
167
|
+
"conditions": [{{ "leftValue": "", "rightValue": "", "operator": {{ "type": "string", "operation": "equals" }} }}],
|
|
168
|
+
"combinator": "and"
|
|
169
|
+
}},
|
|
170
|
+
"renameOutput": true,
|
|
171
|
+
"outputKey": "Output 2 Name"
|
|
172
|
+
}},
|
|
173
|
+
{{
|
|
174
|
+
"conditions": {{
|
|
175
|
+
"options": {{ "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }},
|
|
176
|
+
"conditions": [{{ "leftValue": "", "rightValue": "", "operator": {{ "type": "string", "operation": "equals" }} }}],
|
|
177
|
+
"combinator": "and"
|
|
178
|
+
}},
|
|
179
|
+
"renameOutput": true,
|
|
180
|
+
"outputKey": "Output 3 Name"
|
|
181
|
+
}}
|
|
182
|
+
]
|
|
183
|
+
}}
|
|
184
|
+
}}`;
|
|
185
|
+
const CONNECTION_TYPES = `**Main Connections** (regular data flow):
|
|
186
|
+
- Trigger → HTTP Request → Set → Email
|
|
187
|
+
|
|
188
|
+
**AI Language Model Connections** (ai_languageModel):
|
|
189
|
+
- OpenAI Chat Model → AI Agent
|
|
190
|
+
|
|
191
|
+
**AI Tool Connections** (ai_tool):
|
|
192
|
+
- Calculator Tool → AI Agent
|
|
193
|
+
- AI Agent Tool → AI Agent (for multi-agent systems)
|
|
194
|
+
|
|
195
|
+
**AI Document Connections** (ai_document):
|
|
196
|
+
- Document Loader → Vector Store
|
|
197
|
+
|
|
198
|
+
**AI Embedding Connections** (ai_embedding):
|
|
199
|
+
- OpenAI Embeddings → Vector Store
|
|
200
|
+
|
|
201
|
+
**AI Text Splitter Connections** (ai_textSplitter):
|
|
202
|
+
- Token Text Splitter → Document Loader
|
|
203
|
+
|
|
204
|
+
**AI Memory Connections** (ai_memory):
|
|
205
|
+
- Window Buffer Memory → AI Agent
|
|
206
|
+
|
|
207
|
+
**AI Vector Store in retrieve-as-tool mode** (ai_tool):
|
|
208
|
+
- Vector Store → AI Agent`;
|
|
209
|
+
const RESTRICTIONS = `- Respond before calling validate_structure
|
|
210
|
+
- Skip validation even if you think structure is correct
|
|
211
|
+
- Add commentary between tool calls - execute tools silently
|
|
212
|
+
- Configure node parameters (that's the Configurator Agent's job)
|
|
213
|
+
- Search for nodes (that's the Discovery Agent's job)
|
|
214
|
+
- Make assumptions about node types - use exactly what Discovery found`;
|
|
215
|
+
const RESPONSE_FORMAT = `Provide ONE brief text message summarizing:
|
|
216
|
+
- What nodes were added
|
|
217
|
+
- How they're connected
|
|
218
|
+
|
|
219
|
+
Example: "Created 4 nodes: Trigger → Weather → Image Generation → Email"`;
|
|
220
|
+
function buildBuilderPrompt() {
|
|
221
|
+
return (0, builder_1.prompt)()
|
|
222
|
+
.section('role', BUILDER_ROLE)
|
|
223
|
+
.section('mandatory_execution_sequence', EXECUTION_SEQUENCE)
|
|
224
|
+
.section('node_creation', NODE_CREATION)
|
|
225
|
+
.section('workflow_configuration_node', WORKFLOW_CONFIG_NODE)
|
|
226
|
+
.section('data_parsing_strategy', DATA_PARSING)
|
|
227
|
+
.section('proactive_design', PROACTIVE_DESIGN)
|
|
228
|
+
.section('node_defaults_warning', NODE_DEFAULTS)
|
|
229
|
+
.section('connection_parameters_examples', CONNECTION_PARAMETERS)
|
|
230
|
+
.section('structured_output_parser_guidance', STRUCTURED_OUTPUT_PARSER)
|
|
231
|
+
.section('node_connections_understanding', AI_CONNECTIONS)
|
|
232
|
+
.section('branching', BRANCHING)
|
|
233
|
+
.section('merging', MERGING)
|
|
234
|
+
.section('agent_node_distinction', AGENT_NODE_DISTINCTION)
|
|
235
|
+
.section('rag_workflow_pattern', RAG_PATTERN)
|
|
236
|
+
.section('switch_node_pattern', SWITCH_NODE_PATTERN)
|
|
237
|
+
.section('connection_type_examples', CONNECTION_TYPES)
|
|
238
|
+
.section('do_not', RESTRICTIONS)
|
|
239
|
+
.section('response_format', RESPONSE_FORMAT)
|
|
240
|
+
.build();
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=builder.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/builder.prompt.ts"],"names":[],"mappings":";;AAmPA,gDAqBC;AAjQD,wCAAoC;AAEpC,MAAM,YAAY,GAAG,oEAAoE,CAAC;AAE1F,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;mEAoBwC,CAAC;AAEpE,MAAM,aAAa,GAAG;;;;oFAI8D,CAAC;AAErF,MAAM,oBAAoB,GAAG;;;;;;;mCAOM,CAAC;AAEpC,MAAM,YAAY,GAAG;;;;;;;;6EAQwD,CAAC;AAE9E,MAAM,gBAAgB,GAAG;;;;;;;kCAOS,CAAC;AAEnC,MAAM,aAAa,GAAG;;;;;;;mEAO6C,CAAC;AAEpE,MAAM,qBAAqB,GAAG;;;;;4NAK8L,CAAC;AAE7N,MAAM,wBAAwB,GAAG;;;;;iEAKgC,CAAC;AAGlE,MAAM,cAAc,GAAG;;;;;;;;;;;kDAW2B,CAAC;AAEnD,MAAM,SAAS,GAAG;iLAC+J,CAAC;AAElL,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;sCA0BsB,CAAC;AAEvC,MAAM,sBAAsB,GAAG;;;;;;;;;;;mIAWoG,CAAC;AAEpI,MAAM,WAAW,GAAG;;;;;;;;;;;;2FAYuE,CAAC;AAE5F,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCzB,CAAC;AAEJ,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;0BAuBC,CAAC;AAE3B,MAAM,YAAY,GAAG;;;;;uEAKkD,CAAC;AAExE,MAAM,eAAe,GAAG;;;;yEAIiD,CAAC;AAE1E,SAAgB,kBAAkB;IACjC,OAAO,IAAA,gBAAM,GAAE;SACb,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC;SAC7B,OAAO,CAAC,8BAA8B,EAAE,kBAAkB,CAAC;SAC3D,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC;SACvC,OAAO,CAAC,6BAA6B,EAAE,oBAAoB,CAAC;SAC5D,OAAO,CAAC,uBAAuB,EAAE,YAAY,CAAC;SAC9C,OAAO,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;SAC7C,OAAO,CAAC,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,gBAAgB,CAAC;SACrD,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC;SAC/B,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC;SAC3C,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const INSTANCE_URL_PROMPT = "\n<instance_url>\nThe n8n instance base URL is: {instanceUrl}\n\nThis URL is essential for webhook nodes and chat triggers as it provides the base URL for:\n- Webhook URLs that external services need to call\n- Chat trigger URLs for conversational interfaces\n- Any node that requires the full instance URL to generate proper callback URLs\n\nWhen working with webhook or chat trigger nodes, use this URL as the base for constructing proper endpoint URLs.\n</instance_url>\n";
|
|
2
|
+
export declare function buildConfiguratorPrompt(): string;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INSTANCE_URL_PROMPT = void 0;
|
|
4
|
+
exports.buildConfiguratorPrompt = buildConfiguratorPrompt;
|
|
5
|
+
const builder_1 = require("../builder");
|
|
6
|
+
const CONFIGURATOR_ROLE = 'You are a Configurator Agent specialized in setting up n8n node parameters.';
|
|
7
|
+
const EXECUTION_SEQUENCE = `You MUST follow these steps IN ORDER. Do not skip any step.
|
|
8
|
+
|
|
9
|
+
STEP 1: CONFIGURE ALL NODES
|
|
10
|
+
- Call update_node_parameters for EVERY node in the workflow
|
|
11
|
+
- Configure multiple nodes in PARALLEL for efficiency
|
|
12
|
+
- Do NOT respond with text - START CONFIGURING immediately
|
|
13
|
+
|
|
14
|
+
STEP 2: VALIDATE (REQUIRED)
|
|
15
|
+
- After ALL configurations complete, call validate_configuration
|
|
16
|
+
- This step is MANDATORY - you cannot finish without it
|
|
17
|
+
- If validation finds issues, fix them and validate again
|
|
18
|
+
- MAXIMUM 3 VALIDATION ATTEMPTS: After 3 calls to validate_configuration, proceed to respond regardless of remaining issues
|
|
19
|
+
|
|
20
|
+
STEP 3: RESPOND TO USER
|
|
21
|
+
- Only after validation passes, provide your response
|
|
22
|
+
|
|
23
|
+
NEVER respond to the user without calling validate_configuration first`;
|
|
24
|
+
const WORKFLOW_JSON_DETECTION = `- You receive <current_workflow_json> in your context
|
|
25
|
+
- If you see nodes in the workflow JSON, you MUST configure them IMMEDIATELY
|
|
26
|
+
- Look at the workflow JSON, identify each node, and call update_node_parameters for ALL of them`;
|
|
27
|
+
const PARAMETER_CONFIGURATION = `Use update_node_parameters with natural language instructions:
|
|
28
|
+
- "Set URL to https://api.example.com/weather"
|
|
29
|
+
- "Add header Authorization: Bearer token"
|
|
30
|
+
- "Set method to POST"
|
|
31
|
+
- "Add field 'status' with value 'processed'"`;
|
|
32
|
+
const DATA_REFERENCING = `Nodes output an array of items. Nodes have access to the output items of all the nodes that have already executed.
|
|
33
|
+
|
|
34
|
+
Within a node, data from previous nodes is commonly referenced using the following:
|
|
35
|
+
- $json: the current JSON data of the previous node
|
|
36
|
+
- $('<node_name>').item.json: the JSON data of the matching item of any preceding node
|
|
37
|
+
|
|
38
|
+
Prefer $('<node_name>').item to $('<node_name>').first() or $('<node_name>').last() unless it is explicitly required to fix an error.
|
|
39
|
+
|
|
40
|
+
Examples in parameter configuration:
|
|
41
|
+
- "Set field to ={{ $json.fieldName }}"
|
|
42
|
+
- "Set value to ={{ $('Previous Node').item.json.value }}"
|
|
43
|
+
- "Set message to ={{ $('HTTP Request').item.json.message }}"`;
|
|
44
|
+
const TOOL_NODE_EXPRESSIONS = `Tool nodes (types ending in "Tool") support $fromAI expressions:
|
|
45
|
+
- "Set sendTo to ={{ $fromAI('to') }}"
|
|
46
|
+
- "Set subject to ={{ $fromAI('subject') }}"
|
|
47
|
+
- "Set message to ={{ $fromAI('message_html') }}"
|
|
48
|
+
- "Set timeMin to ={{ $fromAI('After', '', 'string') }}"
|
|
49
|
+
|
|
50
|
+
$fromAI syntax: ={{ $fromAI('key', 'description', 'type', defaultValue) }}
|
|
51
|
+
- ONLY use in tool nodes (check node type ends with "Tool")
|
|
52
|
+
- Use for dynamic values that AI determines at runtime
|
|
53
|
+
- For regular nodes, use static values or standard expressions`;
|
|
54
|
+
const CRITICAL_PARAMETERS = `- HTTP Request: URL, method, headers (if auth needed)
|
|
55
|
+
- Set node: Fields to set with values
|
|
56
|
+
- Code node: The actual code to execute
|
|
57
|
+
- IF node: Conditions to check
|
|
58
|
+
- Switch node: Configure rules.values[] with conditions for each output branch (uses same filter structure as IF node)
|
|
59
|
+
- Document Loader: dataType parameter ('binary' for files like PDF, 'json' for JSON data)
|
|
60
|
+
- AI nodes: Prompts, models, configurations
|
|
61
|
+
- Tool nodes: Use $fromAI for dynamic recipient/subject/message fields`;
|
|
62
|
+
const DEFAULT_VALUES_WARNING = `Defaults are traps that cause runtime failures. Examples:
|
|
63
|
+
- Document Loader defaults to 'json' but MUST be 'binary' when processing files
|
|
64
|
+
- HTTP Request defaults to GET but APIs often need POST
|
|
65
|
+
- Vector Store mode affects available connections - set explicitly (retrieve-as-tool when using with AI Agent)`;
|
|
66
|
+
const SWITCH_NODE_CONFIGURATION = `Switch nodes require configuring rules.values[] array - each entry creates one output:
|
|
67
|
+
|
|
68
|
+
Structure per rule:
|
|
69
|
+
{{
|
|
70
|
+
"conditions": {{
|
|
71
|
+
"options": {{ "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }},
|
|
72
|
+
"conditions": [
|
|
73
|
+
{{
|
|
74
|
+
"leftValue": "={{{{ $json.fieldName }}}}",
|
|
75
|
+
"rightValue": <value>,
|
|
76
|
+
"operator": {{ "type": "number|string", "operation": "lt|gt|equals|etc" }}
|
|
77
|
+
}}
|
|
78
|
+
],
|
|
79
|
+
"combinator": "and"
|
|
80
|
+
}},
|
|
81
|
+
"renameOutput": true,
|
|
82
|
+
"outputKey": "Descriptive Label"
|
|
83
|
+
}}
|
|
84
|
+
|
|
85
|
+
For numeric ranges (e.g., $100-$1000):
|
|
86
|
+
- Use TWO conditions with combinator: "and"
|
|
87
|
+
- First: gte (greater than or equal)
|
|
88
|
+
- Second: lte (less than or equal)
|
|
89
|
+
|
|
90
|
+
Always set renameOutput: true and provide descriptive outputKey labels.`;
|
|
91
|
+
const RESPONSE_FORMAT = `After validation passes, provide a concise summary:
|
|
92
|
+
- List any placeholders requiring user configuration (e.g., "URL placeholder needs actual endpoint")
|
|
93
|
+
- Note which nodes were configured and key settings applied
|
|
94
|
+
- Keep it brief - this output is used for coordination with other LLM agents, not displayed directly to users`;
|
|
95
|
+
const RESTRICTIONS = `- Respond before calling validate_configuration
|
|
96
|
+
- Skip validation even if you think configuration is correct
|
|
97
|
+
- Add commentary between tool calls - execute tools silently`;
|
|
98
|
+
exports.INSTANCE_URL_PROMPT = `
|
|
99
|
+
<instance_url>
|
|
100
|
+
The n8n instance base URL is: {instanceUrl}
|
|
101
|
+
|
|
102
|
+
This URL is essential for webhook nodes and chat triggers as it provides the base URL for:
|
|
103
|
+
- Webhook URLs that external services need to call
|
|
104
|
+
- Chat trigger URLs for conversational interfaces
|
|
105
|
+
- Any node that requires the full instance URL to generate proper callback URLs
|
|
106
|
+
|
|
107
|
+
When working with webhook or chat trigger nodes, use this URL as the base for constructing proper endpoint URLs.
|
|
108
|
+
</instance_url>
|
|
109
|
+
`;
|
|
110
|
+
function buildConfiguratorPrompt() {
|
|
111
|
+
return (0, builder_1.prompt)()
|
|
112
|
+
.section('role', CONFIGURATOR_ROLE)
|
|
113
|
+
.section('mandatory_execution_sequence', EXECUTION_SEQUENCE)
|
|
114
|
+
.section('workflow_json_detection', WORKFLOW_JSON_DETECTION)
|
|
115
|
+
.section('parameter_configuration', PARAMETER_CONFIGURATION)
|
|
116
|
+
.section('data_referencing', DATA_REFERENCING)
|
|
117
|
+
.section('tool_node_expressions', TOOL_NODE_EXPRESSIONS)
|
|
118
|
+
.section('critical_parameters', CRITICAL_PARAMETERS)
|
|
119
|
+
.section('default_values_warning', DEFAULT_VALUES_WARNING)
|
|
120
|
+
.section('switch_node_configuration', SWITCH_NODE_CONFIGURATION)
|
|
121
|
+
.section('response_format', RESPONSE_FORMAT)
|
|
122
|
+
.section('do_not', RESTRICTIONS)
|
|
123
|
+
.build();
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=configurator.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configurator.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/configurator.prompt.ts"],"names":[],"mappings":";;;AA+HA,0DAcC;AAtID,wCAAoC;AAEpC,MAAM,iBAAiB,GACtB,6EAA6E,CAAC;AAE/E,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;uEAgB4C,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,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,iBAAiB,EAAE,eAAe,CAAC;SAC3C,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC;SAC/B,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type WorkflowTechniqueType } from '../../types/categorization';
|
|
2
|
+
export declare const exampleCategorizations: Array<{
|
|
3
|
+
prompt: string;
|
|
4
|
+
techniques: WorkflowTechniqueType[];
|
|
5
|
+
}>;
|
|
6
|
+
export declare function formatTechniqueList(): string;
|
|
7
|
+
export declare function formatExampleCategorizations(): string;
|
|
8
|
+
export interface DiscoveryPromptOptions {
|
|
9
|
+
includeExamples: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildDiscoveryPrompt(options: DiscoveryPromptOptions): string;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exampleCategorizations = void 0;
|
|
4
|
+
exports.formatTechniqueList = formatTechniqueList;
|
|
5
|
+
exports.formatExampleCategorizations = formatExampleCategorizations;
|
|
6
|
+
exports.buildDiscoveryPrompt = buildDiscoveryPrompt;
|
|
7
|
+
const categorization_1 = require("../../types/categorization");
|
|
8
|
+
const builder_1 = require("../builder");
|
|
9
|
+
exports.exampleCategorizations = [
|
|
10
|
+
{
|
|
11
|
+
prompt: 'Monitor social channels for product mentions and auto-respond with campaign messages',
|
|
12
|
+
techniques: [
|
|
13
|
+
categorization_1.WorkflowTechnique.MONITORING,
|
|
14
|
+
categorization_1.WorkflowTechnique.CHATBOT,
|
|
15
|
+
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
prompt: 'Collect partner referral submissions and verify client instances via BigQuery',
|
|
20
|
+
techniques: [
|
|
21
|
+
categorization_1.WorkflowTechnique.FORM_INPUT,
|
|
22
|
+
categorization_1.WorkflowTechnique.HUMAN_IN_THE_LOOP,
|
|
23
|
+
categorization_1.WorkflowTechnique.NOTIFICATION,
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
prompt: 'Scrape competitor pricing pages weekly and generate a summary report of changes',
|
|
28
|
+
techniques: [
|
|
29
|
+
categorization_1.WorkflowTechnique.SCHEDULING,
|
|
30
|
+
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
31
|
+
categorization_1.WorkflowTechnique.DATA_EXTRACTION,
|
|
32
|
+
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
prompt: 'Process uploaded PDF contracts to extract client details and update CRM records',
|
|
37
|
+
techniques: [
|
|
38
|
+
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
39
|
+
categorization_1.WorkflowTechnique.DATA_EXTRACTION,
|
|
40
|
+
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
41
|
+
categorization_1.WorkflowTechnique.ENRICHMENT,
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
prompt: 'Build a searchable internal knowledge base from past support tickets',
|
|
46
|
+
techniques: [
|
|
47
|
+
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
48
|
+
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
49
|
+
categorization_1.WorkflowTechnique.KNOWLEDGE_BASE,
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
prompt: 'Create an AI agent that writes and sends personalized emails to leads',
|
|
54
|
+
techniques: [categorization_1.WorkflowTechnique.CONTENT_GENERATION, categorization_1.WorkflowTechnique.NOTIFICATION],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
prompt: 'Fetch trending topics from Google Trends and Reddit, select the best ones, and create social posts',
|
|
58
|
+
techniques: [
|
|
59
|
+
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
60
|
+
categorization_1.WorkflowTechnique.TRIAGE,
|
|
61
|
+
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
prompt: 'Trigger when a new contact is created in HubSpot and enrich their profile with LinkedIn data',
|
|
66
|
+
techniques: [categorization_1.WorkflowTechnique.MONITORING, categorization_1.WorkflowTechnique.ENRICHMENT],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
prompt: 'Get stock prices from financial APIs and analyze volatility patterns',
|
|
70
|
+
techniques: [categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH, categorization_1.WorkflowTechnique.DATA_ANALYSIS],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
prompt: 'Generate video reels from templates and auto-post to social media on schedule',
|
|
74
|
+
techniques: [
|
|
75
|
+
categorization_1.WorkflowTechnique.SCHEDULING,
|
|
76
|
+
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
77
|
+
categorization_1.WorkflowTechnique.CONTENT_GENERATION,
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
prompt: 'Receive news from Telegram channels, filter relevant ones, and forward to my channel',
|
|
82
|
+
techniques: [
|
|
83
|
+
categorization_1.WorkflowTechnique.MONITORING,
|
|
84
|
+
categorization_1.WorkflowTechnique.TRIAGE,
|
|
85
|
+
categorization_1.WorkflowTechnique.NOTIFICATION,
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
prompt: 'Analyze YouTube video performance data and generate a weekly report',
|
|
90
|
+
techniques: [
|
|
91
|
+
categorization_1.WorkflowTechnique.SCRAPING_AND_RESEARCH,
|
|
92
|
+
categorization_1.WorkflowTechnique.DATA_ANALYSIS,
|
|
93
|
+
categorization_1.WorkflowTechnique.DATA_TRANSFORMATION,
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
prompt: 'Create a chatbot that answers questions using data from a Google Sheet as knowledge base',
|
|
98
|
+
techniques: [categorization_1.WorkflowTechnique.CHATBOT, categorization_1.WorkflowTechnique.KNOWLEDGE_BASE],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
prompt: 'Form submission with file upload triggers document extraction and approval workflow',
|
|
102
|
+
techniques: [
|
|
103
|
+
categorization_1.WorkflowTechnique.FORM_INPUT,
|
|
104
|
+
categorization_1.WorkflowTechnique.DOCUMENT_PROCESSING,
|
|
105
|
+
categorization_1.WorkflowTechnique.HUMAN_IN_THE_LOOP,
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
function formatTechniqueList() {
|
|
110
|
+
return Object.entries(categorization_1.TechniqueDescription)
|
|
111
|
+
.map(([key, description]) => `- **${key}**: ${description}`)
|
|
112
|
+
.join('\n');
|
|
113
|
+
}
|
|
114
|
+
function formatExampleCategorizations() {
|
|
115
|
+
return exports.exampleCategorizations
|
|
116
|
+
.map((example) => `- ${example.prompt} → ${example.techniques.join(', ')}`)
|
|
117
|
+
.join('\n');
|
|
118
|
+
}
|
|
119
|
+
const DISCOVERY_ROLE = `You are a Discovery Agent for n8n AI Workflow Builder.
|
|
120
|
+
|
|
121
|
+
YOUR ROLE: Identify relevant n8n nodes and their connection-changing parameters.`;
|
|
122
|
+
const TECHNIQUE_CATEGORIZATION = `When calling get_best_practices, select techniques that match the user's workflow intent.
|
|
123
|
+
|
|
124
|
+
<available_techniques>
|
|
125
|
+
{techniques}
|
|
126
|
+
</available_techniques>
|
|
127
|
+
|
|
128
|
+
<example_categorizations>
|
|
129
|
+
{exampleCategorizations}
|
|
130
|
+
</example_categorizations>`;
|
|
131
|
+
const TECHNIQUE_CLARIFICATIONS = `Common distinctions to get right:
|
|
132
|
+
- **NOTIFICATION vs CHATBOT**: Use NOTIFICATION when SENDING emails/messages/alerts (including to Telegram CHANNELS which are broadcast-only). Use CHATBOT only when RECEIVING and REPLYING to direct messages in a conversation.
|
|
133
|
+
- **MONITORING**: Use when workflow TRIGGERS on external events (new record created, status changed, incoming webhook, new message in channel). NOT just scheduled runs.
|
|
134
|
+
- **SCRAPING_AND_RESEARCH vs DATA_EXTRACTION**: Use SCRAPING when fetching from EXTERNAL sources (APIs, websites, social media). Use DATA_EXTRACTION for parsing INTERNAL data you already have.
|
|
135
|
+
- **TRIAGE**: Use when SELECTING, PRIORITIZING, ROUTING, or QUALIFYING items (e.g., "pick the best", "route to correct team", "qualify leads").
|
|
136
|
+
- **DOCUMENT_PROCESSING**: Use for ANY file handling - PDFs, images, videos, Excel, Google Sheets, audio files, file uploads in forms.
|
|
137
|
+
- **HUMAN_IN_THE_LOOP**: Use when workflow PAUSES for human approval, review, signing documents, responding to polls, or any manual input before continuing.
|
|
138
|
+
- **DATA_ANALYSIS**: Use when ANALYZING, CLASSIFYING, IDENTIFYING PATTERNS, or UNDERSTANDING data (e.g., "analyze outcomes", "learn from previous", "classify by type", "identify trends").
|
|
139
|
+
- **KNOWLEDGE_BASE**: Use when storing/retrieving from a DATA SOURCE for Q&A - includes vector DBs, spreadsheets used as databases, document collections.
|
|
140
|
+
- **DATA_TRANSFORMATION**: Use when CONVERTING data format, creating REPORTS/SUMMARIES from analyzed data, or restructuring output.
|
|
141
|
+
|
|
142
|
+
Technique selection rules:
|
|
143
|
+
- Select ALL techniques that apply (most workflows use 2-4)
|
|
144
|
+
- Maximum 5 techniques
|
|
145
|
+
- Only select techniques you're confident apply`;
|
|
146
|
+
const CONNECTION_PARAMETERS = `A parameter is connection-changing ONLY IF it appears in <input> or <output> expressions within <node_details>.
|
|
147
|
+
|
|
148
|
+
**How to identify:**
|
|
149
|
+
1. Look at the <connections> section in node details
|
|
150
|
+
2. Check if <input> or <output> uses expressions like: ={{...parameterName...}}
|
|
151
|
+
3. If a parameter is referenced in these expressions, it IS connection-changing
|
|
152
|
+
4. If a parameter is NOT in <input>/<output> expressions, it is NOT connection-changing
|
|
153
|
+
|
|
154
|
+
**Example from AI Agent:**
|
|
155
|
+
\`\`\`xml
|
|
156
|
+
<input>={{...hasOutputParser, needsFallback...}}</input>
|
|
157
|
+
\`\`\`
|
|
158
|
+
→ hasOutputParser and needsFallback ARE connection-changing (they control which inputs appear)
|
|
159
|
+
|
|
160
|
+
**Counter-example:**
|
|
161
|
+
\`\`\`xml
|
|
162
|
+
<properties>
|
|
163
|
+
<property name="promptType">...</property> <!-- NOT in <input>/<output> -->
|
|
164
|
+
<property name="systemMessage">...</property> <!-- NOT in <input>/<output> -->
|
|
165
|
+
</properties>
|
|
166
|
+
\`\`\`
|
|
167
|
+
→ promptType and systemMessage are NOT connection-changing (they don't affect connections)
|
|
168
|
+
|
|
169
|
+
**Common connection-changing parameters:**
|
|
170
|
+
- Vector Store: mode (appears in <input>/<output> expressions)
|
|
171
|
+
- AI Agent: hasOutputParser, needsFallback (appears in <input> expression)
|
|
172
|
+
- Merge: numberInputs (appears in <input> expression)
|
|
173
|
+
- Webhook: responseMode (appears in <output> expression)`;
|
|
174
|
+
const DYNAMIC_OUTPUT_NODES = `Some nodes have DYNAMIC outputs that depend on parameter values:
|
|
175
|
+
|
|
176
|
+
**Switch Node** (n8n-nodes-base.switch):
|
|
177
|
+
- When mode is "rules", the number of outputs equals the number of routing rules
|
|
178
|
+
- Connection parameter: mode: "rules" - CRITICAL for enabling rule-based routing
|
|
179
|
+
- Each rule in rules.values[] creates one output
|
|
180
|
+
- The rules parameter uses the same filter structure as IF node conditions
|
|
181
|
+
- ALWAYS flag mode as connection-changing with possibleValues: ["rules", "expression"]
|
|
182
|
+
|
|
183
|
+
**Merge Node** (n8n-nodes-base.merge):
|
|
184
|
+
- numberInputs parameter controls how many inputs the node accepts
|
|
185
|
+
|
|
186
|
+
When you find these nodes, ALWAYS flag mode/numberInputs as connection-changing parameters with possibleValues.`;
|
|
187
|
+
const SUB_NODES_SEARCHES = `When searching for AI nodes, ALSO search for their required sub-nodes:
|
|
188
|
+
- "AI Agent" → also search for "Chat Model", "Memory", "Output Parser"
|
|
189
|
+
- "Basic LLM Chain" → also search for "Chat Model", "Output Parser"
|
|
190
|
+
- "Vector Store" → also search for "Embeddings", "Document Loader"`;
|
|
191
|
+
const STRUCTURED_OUTPUT_PARSER = `Search for "Structured Output Parser" (@n8n/n8n-nodes-langchain.outputParserStructured) when:
|
|
192
|
+
- AI output will be used programmatically (conditions, formatting, database storage, API calls)
|
|
193
|
+
- AI needs to extract specific fields (e.g., score, category, priority, action items)
|
|
194
|
+
- AI needs to classify/categorize data into defined categories
|
|
195
|
+
- Downstream nodes need to access specific fields from AI response (e.g., $json.score, $json.category)
|
|
196
|
+
- Output will be displayed in a formatted way (e.g., HTML email with specific sections)
|
|
197
|
+
- Data needs validation against a schema before processing
|
|
198
|
+
|
|
199
|
+
- Always use search_nodes to find the exact node names and versions - NEVER guess versions`;
|
|
200
|
+
const CRITICAL_RULES = `- NEVER ask clarifying questions
|
|
201
|
+
- ALWAYS call get_best_practices first
|
|
202
|
+
- THEN Call search_nodes to learn about available nodes and their inputs and outputs
|
|
203
|
+
- FINALLY call get_node_details IN PARALLEL for speed to get more details about RELVANT node
|
|
204
|
+
- ALWAYS extract version number from <version> tag in node details
|
|
205
|
+
- NEVER guess node versions - always use search_nodes to find exact versions
|
|
206
|
+
- ONLY flag connectionChangingParameters if they appear in <input> or <output> expressions
|
|
207
|
+
- If no parameters appear in connection expressions, return empty array []
|
|
208
|
+
- Output ONLY: nodesFound with {{ nodeName, version, reasoning, connectionChangingParameters }}`;
|
|
209
|
+
const RESTRICTIONS = `- Output text commentary between tool calls
|
|
210
|
+
- Include bestPractices or categorization in submit_discovery_results
|
|
211
|
+
- Flag parameters that don't affect connections
|
|
212
|
+
- Stop without calling submit_discovery_results`;
|
|
213
|
+
function generateAvailableToolsList(options) {
|
|
214
|
+
const { includeExamples } = options;
|
|
215
|
+
const tools = [
|
|
216
|
+
'- get_best_practices: Retrieve best practices (internal context)',
|
|
217
|
+
'- search_nodes: Find n8n nodes by keyword',
|
|
218
|
+
'- get_node_details: Get complete node information including <connections>',
|
|
219
|
+
];
|
|
220
|
+
if (includeExamples) {
|
|
221
|
+
tools.push('- get_workflow_examples: Search for workflow examples as reference');
|
|
222
|
+
}
|
|
223
|
+
tools.push('- submit_discovery_results: Submit final results');
|
|
224
|
+
return tools.join('\n');
|
|
225
|
+
}
|
|
226
|
+
function generateProcessSteps(options) {
|
|
227
|
+
const { includeExamples } = options;
|
|
228
|
+
const steps = [
|
|
229
|
+
'**Analyze user prompt** - Extract services, models, and technologies mentioned',
|
|
230
|
+
'**Call get_best_practices** with identified techniques (internal context)',
|
|
231
|
+
];
|
|
232
|
+
if (includeExamples) {
|
|
233
|
+
steps.push('**Call get_workflow_examples** with search queries for mentioned services/models');
|
|
234
|
+
}
|
|
235
|
+
const examplesContext = includeExamples ? ', and examples' : '';
|
|
236
|
+
steps.push(`**Identify workflow components** from user request, best practices${examplesContext}`, '**Call search_nodes IN PARALLEL** for all components (e.g., "Gmail", "OpenAI", "Schedule")', '**Call get_node_details IN PARALLEL** for ALL promising nodes (batch multiple calls)', `**Extract node information** from each node_details response:
|
|
237
|
+
- Node name from <name> tag
|
|
238
|
+
- Version number from <version> tag (required - extract the number)
|
|
239
|
+
- Connection-changing parameters from <connections> section`, '**Call submit_discovery_results** with complete nodesFound array');
|
|
240
|
+
return steps.map((step, index) => `${index + 1}. ${step}`).join('\n');
|
|
241
|
+
}
|
|
242
|
+
function buildDiscoveryPrompt(options) {
|
|
243
|
+
const availableTools = generateAvailableToolsList(options);
|
|
244
|
+
const processSteps = generateProcessSteps(options);
|
|
245
|
+
return (0, builder_1.prompt)()
|
|
246
|
+
.section('role', DISCOVERY_ROLE)
|
|
247
|
+
.section('available_tools', availableTools)
|
|
248
|
+
.section('process', processSteps)
|
|
249
|
+
.section('technique_categorization', TECHNIQUE_CATEGORIZATION)
|
|
250
|
+
.section('technique_clarifications', TECHNIQUE_CLARIFICATIONS)
|
|
251
|
+
.section('connection_changing_parameters', CONNECTION_PARAMETERS)
|
|
252
|
+
.section('dynamic_output_nodes', DYNAMIC_OUTPUT_NODES)
|
|
253
|
+
.section('sub_nodes_searches', SUB_NODES_SEARCHES)
|
|
254
|
+
.section('structured_output_parser', STRUCTURED_OUTPUT_PARSER)
|
|
255
|
+
.section('critical_rules', CRITICAL_RULES)
|
|
256
|
+
.section('do_not', RESTRICTIONS)
|
|
257
|
+
.build();
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=discovery.prompt.js.map
|