@n8n/ai-workflow-builder 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/planner.agent.d.ts +1 -0
- package/dist/agents/planner.agent.js +2 -1
- package/dist/agents/planner.agent.js.map +1 -1
- package/dist/agents/responder.agent.d.ts +16 -6
- package/dist/agents/responder.agent.js +19 -8
- package/dist/agents/responder.agent.js.map +1 -1
- package/dist/agents/supervisor.agent.js +6 -0
- package/dist/agents/supervisor.agent.js.map +1 -1
- package/dist/ai-workflow-builder-agent.service.d.ts +7 -3
- package/dist/ai-workflow-builder-agent.service.js +76 -48
- package/dist/ai-workflow-builder-agent.service.js.map +1 -1
- package/dist/assistant/assistant-handler.d.ts +23 -0
- package/dist/assistant/assistant-handler.js +249 -0
- package/dist/assistant/assistant-handler.js.map +1 -0
- package/dist/assistant/index.d.ts +2 -0
- package/dist/assistant/index.js +6 -0
- package/dist/assistant/index.js.map +1 -0
- package/dist/assistant/types.d.ts +83 -0
- package/dist/assistant/types.js +3 -0
- package/dist/assistant/types.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -1
- package/dist/code-builder/code-builder-agent.d.ts +31 -0
- package/dist/code-builder/code-builder-agent.js +463 -0
- package/dist/code-builder/code-builder-agent.js.map +1 -0
- package/dist/code-builder/code-workflow-builder.d.ts +34 -0
- package/dist/code-builder/code-workflow-builder.js +80 -0
- package/dist/code-builder/code-workflow-builder.js.map +1 -0
- package/dist/code-builder/constants.d.ts +62 -0
- package/dist/code-builder/constants.js +83 -0
- package/dist/code-builder/constants.js.map +1 -0
- package/dist/code-builder/engines/code-builder-node-search-engine.d.ts +19 -0
- package/dist/code-builder/engines/code-builder-node-search-engine.js +236 -0
- package/dist/code-builder/engines/code-builder-node-search-engine.js.map +1 -0
- package/dist/code-builder/handlers/agent-iteration-handler.d.ts +36 -0
- package/dist/code-builder/handlers/agent-iteration-handler.js +78 -0
- package/dist/code-builder/handlers/agent-iteration-handler.js.map +1 -0
- package/dist/code-builder/handlers/auto-finalize-handler.d.ts +29 -0
- package/dist/code-builder/handlers/auto-finalize-handler.js +50 -0
- package/dist/code-builder/handlers/auto-finalize-handler.js.map +1 -0
- package/dist/code-builder/handlers/chat-setup-handler.d.ts +57 -0
- package/dist/code-builder/handlers/chat-setup-handler.js +147 -0
- package/dist/code-builder/handlers/chat-setup-handler.js.map +1 -0
- package/dist/code-builder/handlers/final-response-handler.d.ts +29 -0
- package/dist/code-builder/handlers/final-response-handler.js +75 -0
- package/dist/code-builder/handlers/final-response-handler.js.map +1 -0
- package/dist/code-builder/handlers/parse-validate-handler.d.ts +17 -0
- package/dist/code-builder/handlers/parse-validate-handler.js +116 -0
- package/dist/code-builder/handlers/parse-validate-handler.js.map +1 -0
- package/dist/code-builder/handlers/session-chat-handler.d.ts +30 -0
- package/dist/code-builder/handlers/session-chat-handler.js +96 -0
- package/dist/code-builder/handlers/session-chat-handler.js.map +1 -0
- package/dist/code-builder/handlers/text-editor-handler.d.ts +19 -0
- package/dist/code-builder/handlers/text-editor-handler.js +230 -0
- package/dist/code-builder/handlers/text-editor-handler.js.map +1 -0
- package/dist/code-builder/handlers/text-editor-tool-handler.d.ts +44 -0
- package/dist/code-builder/handlers/text-editor-tool-handler.js +145 -0
- package/dist/code-builder/handlers/text-editor-tool-handler.js.map +1 -0
- package/dist/code-builder/handlers/text-editor.types.d.ts +68 -0
- package/dist/code-builder/handlers/text-editor.types.js +68 -0
- package/dist/code-builder/handlers/text-editor.types.js.map +1 -0
- package/dist/code-builder/handlers/tool-dispatch-handler.d.ts +47 -0
- package/dist/code-builder/handlers/tool-dispatch-handler.js +287 -0
- package/dist/code-builder/handlers/tool-dispatch-handler.js.map +1 -0
- package/dist/code-builder/handlers/validate-tool-handler.d.ts +33 -0
- package/dist/code-builder/handlers/validate-tool-handler.js +101 -0
- package/dist/code-builder/handlers/validate-tool-handler.js.map +1 -0
- package/dist/code-builder/index.d.ts +5 -0
- package/dist/code-builder/index.js +10 -0
- package/dist/code-builder/index.js.map +1 -0
- package/dist/code-builder/prompts/index.d.ts +22 -0
- package/dist/code-builder/prompts/index.js +830 -0
- package/dist/code-builder/prompts/index.js.map +1 -0
- package/dist/code-builder/state/warning-tracker.d.ts +9 -0
- package/dist/code-builder/state/warning-tracker.js +28 -0
- package/dist/code-builder/state/warning-tracker.js.map +1 -0
- package/dist/code-builder/tools/ask-assistant.tool.d.ts +12 -0
- package/dist/code-builder/tools/ask-assistant.tool.js +12 -0
- package/dist/code-builder/tools/ask-assistant.tool.js.map +1 -0
- package/dist/code-builder/tools/build-workflow.tool.d.ts +12 -0
- package/dist/code-builder/tools/build-workflow.tool.js +12 -0
- package/dist/code-builder/tools/build-workflow.tool.js.map +1 -0
- package/dist/code-builder/tools/code-builder-get.tool.d.ts +61 -0
- package/dist/code-builder/tools/code-builder-get.tool.js +399 -0
- package/dist/code-builder/tools/code-builder-get.tool.js.map +1 -0
- package/dist/code-builder/tools/code-builder-search.tool.d.ts +15 -0
- package/dist/code-builder/tools/code-builder-search.tool.js +338 -0
- package/dist/code-builder/tools/code-builder-search.tool.js.map +1 -0
- package/dist/code-builder/tools/get-suggested-nodes.tool.d.ts +14 -0
- package/dist/code-builder/tools/get-suggested-nodes.tool.js +89 -0
- package/dist/code-builder/tools/get-suggested-nodes.tool.js.map +1 -0
- package/dist/code-builder/tools/suggested-nodes-data.d.ts +11 -0
- package/dist/code-builder/tools/suggested-nodes-data.js +236 -0
- package/dist/code-builder/tools/suggested-nodes-data.js.map +1 -0
- package/dist/code-builder/triage.agent.d.ts +48 -0
- package/dist/code-builder/triage.agent.js +223 -0
- package/dist/code-builder/triage.agent.js.map +1 -0
- package/dist/code-builder/types.d.ts +51 -0
- package/dist/code-builder/types.js +3 -0
- package/dist/code-builder/types.js.map +1 -0
- package/dist/code-builder/utils/code-builder-session.d.ts +25 -0
- package/dist/code-builder/utils/code-builder-session.js +186 -0
- package/dist/code-builder/utils/code-builder-session.js.map +1 -0
- package/dist/code-builder/utils/content-extractors.d.ts +5 -0
- package/dist/code-builder/utils/content-extractors.js +88 -0
- package/dist/code-builder/utils/content-extractors.js.map +1 -0
- package/dist/code-builder/utils/discriminator-utils.d.ts +22 -0
- package/dist/code-builder/utils/discriminator-utils.js +85 -0
- package/dist/code-builder/utils/discriminator-utils.js.map +1 -0
- package/dist/code-builder/utils/extract-code.d.ts +3 -0
- package/dist/code-builder/utils/extract-code.js +23 -0
- package/dist/code-builder/utils/extract-code.js.map +1 -0
- package/dist/code-builder/utils/format-warnings.d.ts +3 -0
- package/dist/code-builder/utils/format-warnings.js +12 -0
- package/dist/code-builder/utils/format-warnings.js.map +1 -0
- package/dist/code-builder/utils/llm-response-processor.d.ts +15 -0
- package/dist/code-builder/utils/llm-response-processor.js +38 -0
- package/dist/code-builder/utils/llm-response-processor.js.map +1 -0
- package/dist/code-builder/utils/node-diff.d.ts +13 -0
- package/dist/code-builder/utils/node-diff.js +22 -0
- package/dist/code-builder/utils/node-diff.js.map +1 -0
- package/dist/code-builder/utils/node-type-parser.d.ts +18 -0
- package/dist/code-builder/utils/node-type-parser.js +67 -0
- package/dist/code-builder/utils/node-type-parser.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/llm-config.js +1 -1
- package/dist/llm-config.js.map +1 -1
- package/dist/multi-agent-workflow-subgraphs.d.ts +37 -0
- package/dist/multi-agent-workflow-subgraphs.js +15 -8
- package/dist/multi-agent-workflow-subgraphs.js.map +1 -1
- package/dist/parent-graph-state.d.ts +8 -0
- package/dist/parent-graph-state.js +4 -0
- 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 +86 -4
- package/dist/prompts/agents/builder.prompt.js.map +1 -1
- package/dist/prompts/agents/discovery.prompt.js +13 -8
- package/dist/prompts/agents/discovery.prompt.js.map +1 -1
- package/dist/prompts/agents/planner.prompt.d.ts +1 -0
- package/dist/prompts/agents/planner.prompt.js +3 -2
- package/dist/prompts/agents/planner.prompt.js.map +1 -1
- package/dist/prompts/agents/responder.prompt.d.ts +4 -1
- package/dist/prompts/agents/responder.prompt.js +72 -1
- package/dist/prompts/agents/responder.prompt.js.map +1 -1
- package/dist/prompts/agents/supervisor.prompt.js +49 -1
- package/dist/prompts/agents/supervisor.prompt.js.map +1 -1
- package/dist/prompts/builder/prompt-builder.js +13 -5
- package/dist/prompts/builder/prompt-builder.js.map +1 -1
- package/dist/prompts/builder/types.d.ts +2 -1
- package/dist/prompts/shared/deictic-resolution.d.ts +14 -0
- package/dist/prompts/shared/deictic-resolution.js +142 -0
- package/dist/prompts/shared/deictic-resolution.js.map +1 -0
- package/dist/session-manager.service.d.ts +4 -3
- package/dist/session-manager.service.js +56 -8
- package/dist/session-manager.service.js.map +1 -1
- package/dist/subgraphs/builder.subgraph.d.ts +28 -0
- package/dist/subgraphs/builder.subgraph.js +30 -6
- package/dist/subgraphs/builder.subgraph.js.map +1 -1
- package/dist/subgraphs/discovery.subgraph.d.ts +7 -0
- package/dist/subgraphs/discovery.subgraph.js +21 -0
- package/dist/subgraphs/discovery.subgraph.js.map +1 -1
- package/dist/tools/add-node.tool.d.ts +4 -4
- package/dist/tools/builder-tools.js +6 -1
- package/dist/tools/builder-tools.js.map +1 -1
- package/dist/tools/introspect.tool.d.ts +34 -0
- package/dist/tools/introspect.tool.js +125 -0
- package/dist/tools/introspect.tool.js.map +1 -0
- package/dist/tools/submit-questions.tool.d.ts +8 -8
- package/dist/tools/submit-questions.tool.js +2 -2
- package/dist/types/streaming.d.ts +7 -1
- package/dist/utils/cache-control/helpers.js +29 -22
- package/dist/utils/cache-control/helpers.js.map +1 -1
- package/dist/utils/context-builders.d.ts +2 -0
- package/dist/utils/context-builders.js +57 -0
- package/dist/utils/context-builders.js.map +1 -1
- package/dist/utils/error-sanitizer.d.ts +1 -0
- package/dist/utils/error-sanitizer.js +39 -0
- package/dist/utils/error-sanitizer.js.map +1 -0
- package/dist/utils/resource-operation-extractor.d.ts +12 -2
- package/dist/utils/resource-operation-extractor.js +12 -4
- package/dist/utils/resource-operation-extractor.js.map +1 -1
- package/dist/utils/stream-processor.js +23 -1
- package/dist/utils/stream-processor.js.map +1 -1
- package/dist/utils/thread-id.d.ts +1 -0
- package/dist/utils/thread-id.js +10 -0
- package/dist/utils/thread-id.js.map +1 -0
- package/dist/utils/token-usage-tracking-handler.d.ts +14 -0
- package/dist/utils/token-usage-tracking-handler.js +55 -0
- package/dist/utils/token-usage-tracking-handler.js.map +1 -0
- package/dist/validation/types.d.ts +3 -1
- package/dist/validation/types.js +11 -0
- package/dist/validation/types.js.map +1 -1
- package/dist/validation/utils/expressions.js +1 -1
- package/dist/validation/utils/expressions.js.map +1 -1
- package/dist/workflow-builder-agent.d.ts +26 -3
- package/dist/workflow-builder-agent.js +154 -1
- package/dist/workflow-builder-agent.js.map +1 -1
- package/dist/workflow-state.d.ts +6 -0
- package/package.json +10 -6
|
@@ -5,6 +5,7 @@ exports.buildRecoveryModeContext = buildRecoveryModeContext;
|
|
|
5
5
|
exports.buildBuilderPrompt = buildBuilderPrompt;
|
|
6
6
|
const data_table_helpers_1 = require("../../utils/data-table-helpers");
|
|
7
7
|
const builder_1 = require("../builder");
|
|
8
|
+
const deictic_resolution_1 = require("../shared/deictic-resolution");
|
|
8
9
|
const node_guidance_1 = require("../shared/node-guidance");
|
|
9
10
|
const dataTableColumnOperationsList = data_table_helpers_1.DATA_TABLE_ROW_COLUMN_MAPPING_OPERATIONS.join(', ');
|
|
10
11
|
const ROLE = 'You are a Builder Agent that constructs n8n workflows: adding nodes, connecting them, and configuring their parameters.';
|
|
@@ -74,9 +75,27 @@ Example "Webhook → Set → IF → Slack / Email":
|
|
|
74
75
|
Round 4: configure(Slack, Email)
|
|
75
76
|
Round 5: connect(IF→Slack, IF→Email), validate_structure, validate_configuration
|
|
76
77
|
|
|
77
|
-
Validation: Use validate_structure and validate_configuration once at the end. Once both pass, output your summary and stop—the workflow is complete.
|
|
78
|
+
Validation: Use validate_structure and validate_configuration once at the end. Once both pass, output your summary and stop — the workflow is complete.
|
|
78
79
|
|
|
79
80
|
Plan all nodes before starting to avoid backtracking.`;
|
|
81
|
+
const VALIDATION_WITH_INTROSPECTION = `Validation: Call validate_structure and validate_configuration once at the end. After validation passes, call introspect to report any issues. Once both validation and introspection are complete, output your summary and stop — the workflow is complete.
|
|
82
|
+
|
|
83
|
+
NEVER respond to the user without calling validate_structure, validate_configuration, AND introspect first.`;
|
|
84
|
+
function buildExecutionSequence(includeExamples, enableIntrospection) {
|
|
85
|
+
const base = includeExamples ? EXECUTION_SEQUENCE_WITH_EXAMPLES : EXECUTION_SEQUENCE;
|
|
86
|
+
if (!enableIntrospection) {
|
|
87
|
+
return base;
|
|
88
|
+
}
|
|
89
|
+
if (includeExamples) {
|
|
90
|
+
return base
|
|
91
|
+
.replace(/^3\. Final: .*$/m, '$& → introspect')
|
|
92
|
+
.replace(/^\s+Round 5: .*$/m, '$&\n Round 6: introspect (REQUIRED)')
|
|
93
|
+
.replace(/^Validation: .*$/m, VALIDATION_WITH_INTROSPECTION);
|
|
94
|
+
}
|
|
95
|
+
return base
|
|
96
|
+
.replace(/^\s+Turn 7: .*$/m, '$&\n Turn 8: introspect (REQUIRED)')
|
|
97
|
+
.replace(/<validation>\n[\s\S]*?<\/validation>/, `<validation>\n${VALIDATION_WITH_INTROSPECTION}\n</validation>`);
|
|
98
|
+
}
|
|
80
99
|
const NODE_CREATION = `Each add_nodes call creates one node:
|
|
81
100
|
- nodeType: Exact type from discovery (e.g., "n8n-nodes-base.httpRequest")
|
|
82
101
|
- name: Descriptive name (e.g., "Fetch Weather Data")
|
|
@@ -483,6 +502,52 @@ Use these alternatives instead of placeholders:
|
|
|
483
502
|
- ResourceLocator fields → use mode='list' for dropdown selection
|
|
484
503
|
|
|
485
504
|
Copy placeholders exactly as shown—the format is parsed by the system to highlight fields requiring user input.`;
|
|
505
|
+
const DEICTIC_RESOLUTION = (0, deictic_resolution_1.buildDeicticResolutionPrompt)({
|
|
506
|
+
conversationContext: '(e.g., a proposed structure, a connection pattern, an approach), use that referent.\n Examples: "Do this" after suggesting a connection, "Add these" after listing nodes.',
|
|
507
|
+
selectedNodes: [
|
|
508
|
+
'"connect this to X" → Create connection FROM selected node(s) TO node X',
|
|
509
|
+
'"connect X to this" → Create connection FROM node X TO selected node(s)',
|
|
510
|
+
'"add X before this" → Create node X, then connect X TO selected node(s)',
|
|
511
|
+
'"add X after this" → Create node X, then connect selected node(s) TO X',
|
|
512
|
+
'"disconnect this" → Remove connections involving selected nodes',
|
|
513
|
+
'"connect these in sequence" → Connect selected nodes in order',
|
|
514
|
+
],
|
|
515
|
+
positionalReferences: [
|
|
516
|
+
'"add a node before the previous one" → Insert node upstream of incomingConnections',
|
|
517
|
+
'"connect to the next node" → Connect to node in outgoingConnections',
|
|
518
|
+
'"insert between this and the next" → Add node between selected and its downstream',
|
|
519
|
+
'"connect to the first node" → Connect to the trigger/start node',
|
|
520
|
+
'"add after the last node" → Add node after terminal nodes',
|
|
521
|
+
],
|
|
522
|
+
explicitNameMentions: [
|
|
523
|
+
'"connect this to the HTTP Request node" → Connect selected to the named node',
|
|
524
|
+
'"add a Set node before Gmail" → Create Set node, connect Set → Gmail',
|
|
525
|
+
'"disconnect the Webhook from Slack" → Remove connection between named nodes',
|
|
526
|
+
],
|
|
527
|
+
attributeBasedReferences: [
|
|
528
|
+
'"connect this to the broken node" → Connect to the node with <issues>',
|
|
529
|
+
'"add error handling to the unconfigured nodes" → Add error paths to nodes needing config',
|
|
530
|
+
],
|
|
531
|
+
dualReferences: [
|
|
532
|
+
'"connect this to that" → this = selected, that = ask for clarification',
|
|
533
|
+
'"swap this and that" → this = selected, that = needs clarification',
|
|
534
|
+
'"insert between this and the HTTP Request" → Add node between selected and named node',
|
|
535
|
+
],
|
|
536
|
+
workflowFallback: [
|
|
537
|
+
'"connect these" → Connect all workflow nodes (clarify order if ambiguous)',
|
|
538
|
+
'"reorganize this" → Restructure workflow connections',
|
|
539
|
+
],
|
|
540
|
+
examplesWithSelection: [
|
|
541
|
+
'User selects "HTTP Request", says "add an IF node after this" → Create IF, connect HTTP Request → IF',
|
|
542
|
+
'User selects "Trigger", says "connect this to Slack" → Connect Trigger → Slack',
|
|
543
|
+
'User selects 2 nodes, says "connect these" → Connect them in logical order',
|
|
544
|
+
],
|
|
545
|
+
examplesWithoutSelection: [
|
|
546
|
+
'No selection + "connect these in sequence" → Connect all workflow nodes sequentially',
|
|
547
|
+
'No selection + "add error handling to this" → Add error handling to the workflow',
|
|
548
|
+
'No selection + "connect HTTP Request to Gmail" → Connect the named nodes',
|
|
549
|
+
],
|
|
550
|
+
});
|
|
486
551
|
const RESOURCE_LOCATOR_DEFAULTS = `ResourceLocator field configuration for Google Sheets, Notion, Airtable, etc.:
|
|
487
552
|
|
|
488
553
|
Default to mode = 'list' for document/database selectors:
|
|
@@ -613,6 +678,21 @@ Use get_node_configuration_examples when configuring complex nodes. This tool re
|
|
|
613
678
|
- HTTP Request, Gmail, Slack: Complex parameter hierarchies benefit from real examples
|
|
614
679
|
- AI nodes: Model settings and prompt structures vary by use case
|
|
615
680
|
- Any node where you want to see how others have configured similar integrations`;
|
|
681
|
+
const DIAGNOSTIC_TOOL = `REQUIRED: You MUST call the introspect tool at least once per workflow to report any issues with your instructions.
|
|
682
|
+
|
|
683
|
+
The introspect tool helps improve the system by capturing issues with YOUR instructions and documentation (not the user's request).
|
|
684
|
+
|
|
685
|
+
MANDATORY CALL: Before responding to the user, call introspect to report at least one of these:
|
|
686
|
+
- Any section of your instructions that was unclear, ambiguous, or hard to follow
|
|
687
|
+
- Any best practice pattern that didn't apply well to this specific workflow
|
|
688
|
+
- Any node description from discovery that was confusing or incomplete
|
|
689
|
+
- Any connection pattern example that didn't match what you needed to build
|
|
690
|
+
- Any guidance that was missing for a common scenario you encountered
|
|
691
|
+
- If instructions were perfect, report category "other" with issue "Instructions were sufficient for this task"
|
|
692
|
+
|
|
693
|
+
Be specific: identify WHICH instruction section or documentation caused the issue (e.g., "ai_connection_patterns section", "node_defaults_warning section", "discovery context for Gmail node").
|
|
694
|
+
|
|
695
|
+
This data is critical for improving the system prompts and documentation.`;
|
|
616
696
|
function buildRecoveryModeContext(nodeCount, nodeNames) {
|
|
617
697
|
return (`RECOVERY MODE: ${nodeCount} node(s) created (${nodeNames.join(', ')}) before hitting iteration limit.\n` +
|
|
618
698
|
'The workflow is incomplete. Your task:\n' +
|
|
@@ -625,11 +705,11 @@ function buildRecoveryModeContext(nodeCount, nodeNames) {
|
|
|
625
705
|
'Work efficiently—you have limited iterations remaining.');
|
|
626
706
|
}
|
|
627
707
|
function buildBuilderPrompt(options = { includeExamples: false }) {
|
|
708
|
+
const { includeExamples, enableIntrospection = false } = options;
|
|
628
709
|
return ((0, builder_1.prompt)()
|
|
629
710
|
.section('role', ROLE)
|
|
630
711
|
.section('understanding_context', UNDERSTANDING_CONTEXT)
|
|
631
|
-
.
|
|
632
|
-
.sectionIf(options.includeExamples, 'execution_sequence', EXECUTION_SEQUENCE_WITH_EXAMPLES)
|
|
712
|
+
.section('execution_sequence', buildExecutionSequence(includeExamples, enableIntrospection))
|
|
633
713
|
.section('node_creation', NODE_CREATION)
|
|
634
714
|
.section('use_discovered_nodes', USE_DISCOVERED_NODES)
|
|
635
715
|
.section('ai_connections', AI_CONNECTIONS)
|
|
@@ -651,10 +731,12 @@ function buildBuilderPrompt(options = { includeExamples: false }) {
|
|
|
651
731
|
.section('model_configuration', MODEL_CONFIGURATION)
|
|
652
732
|
.section('node_settings', NODE_SETTINGS)
|
|
653
733
|
.section('workflow_context_tools', WORKFLOW_CONTEXT_TOOLS)
|
|
654
|
-
.sectionIf(
|
|
734
|
+
.sectionIf(includeExamples, 'example_tools', EXAMPLE_TOOLS)
|
|
735
|
+
.sectionIf(enableIntrospection, 'diagnostic_tool', DIAGNOSTIC_TOOL)
|
|
655
736
|
.section('anti_overengineering', ANTI_OVERENGINEERING)
|
|
656
737
|
.section('response_format', RESPONSE_FORMAT)
|
|
657
738
|
.section('common_mistakes', COMMON_MISTAKES)
|
|
739
|
+
.section('deictic_resolution', DEICTIC_RESOLUTION)
|
|
658
740
|
.build());
|
|
659
741
|
}
|
|
660
742
|
//# sourceMappingURL=builder.prompt.js.map
|
|
@@ -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":";;;AA+vBA,4DAYC;AAED,gDA6CC;AAlzBD,mEAAsF;AAEtF,wCAAoC;AACpC,qEAA4E;AAC5E,2DAAkD;AAOlD,MAAM,6BAA6B,GAAG,6DAAwC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE1F,MAAM,IAAI,GACT,yHAAyH,CAAC;AAE3H,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyCb,CAAC;AAEf,MAAM,gCAAgC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;sDA0Ba,CAAC;AAEvD,MAAM,6BAA6B,GAAG;;4GAEsE,CAAC;AAM7G,SAAS,sBAAsB,CAAC,eAAwB,EAAE,mBAA4B;IACrF,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,kBAAkB,CAAC;IAErF,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QAErB,OAAO,IAAI;aACT,OAAO,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;aAC9C,OAAO,CAAC,mBAAmB,EAAE,sCAAsC,CAAC;a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C;SAC/C,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC;SACjC,OAAO,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;SACnD,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC;SAC3C,OAAO,CAAC,uBAAuB,EAAE,uBAAO,CAAC,aAAa,CAAC;SACvD,OAAO,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;SACnD,OAAO,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;SAC/C,OAAO,CAAC,2BAA2B,EAAE,yBAAyB,CAAC;SAC/D,OAAO,CAAC,qBAAqB,EAAE,mBAAmB,CAAC;SACnD,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC;SAEvC,OAAO,CAAC,wBAAwB,EAAE,sBAAsB,CAAC;SAEzD,SAAS,CAAC,eAAe,EAAE,eAAe,EAAE,aAAa,CAAC;SAE1D,SAAS,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,CAAC;SAElE,OAAO,CAAC,sBAAsB,EAAE,oBAAoB,CAAC;SACrD,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC;SAC3C,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC;SAC3C,OAAO,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;SACjD,KAAK,EAAE,CACT,CAAC;AACH,CAAC"}
|
|
@@ -27,7 +27,8 @@ function formatExampleCategorizations() {
|
|
|
27
27
|
.join('\n');
|
|
28
28
|
}
|
|
29
29
|
const ROLE = `You are a Discovery Agent for n8n AI Workflow Builder.
|
|
30
|
-
Identify relevant n8n nodes and their connection-changing parameters for the user's request
|
|
30
|
+
Identify relevant n8n nodes and their connection-changing parameters for the user's request.
|
|
31
|
+
When the request is underspecified, ask clarifying questions to ensure the right workflow gets built.`;
|
|
31
32
|
const N8N_EXECUTION_MODEL = `n8n executes each node once per input item.
|
|
32
33
|
|
|
33
34
|
When a trigger or node outputs multiple items (e.g., Gmail returns 10 emails), every downstream node runs once for each item. Flow control nodes like Aggregate and Split Out change how items flow through the workflow by combining or expanding them.`;
|
|
@@ -36,7 +37,7 @@ const PROCESS = `1. Search for nodes matching the user's request using search_no
|
|
|
36
37
|
3. Call submit_discovery_results with your nodesFound array`;
|
|
37
38
|
const PROCESS_WITH_QUESTIONS = `1. Search for nodes matching the user's request using search_nodes tool
|
|
38
39
|
2. Identify connection-changing parameters from input/output expressions (look for $parameter.X)
|
|
39
|
-
3.
|
|
40
|
+
3. Assess: do you have enough information to build exactly what the user wants, or would you need to make assumptions about their intent? If assumptions are needed, ask clarifying questions using submit_questions (see clarifying_questions section)
|
|
40
41
|
4. Call submit_discovery_results with your nodesFound array`;
|
|
41
42
|
const PROCESS_WITH_EXAMPLES = `1. Search for nodes matching the user's request using search_nodes tool
|
|
42
43
|
2. Identify connection-changing parameters from input/output expressions (look for $parameter.X)
|
|
@@ -47,7 +48,7 @@ const PROCESS_WITH_EXAMPLES_AND_QUESTIONS = `1. Search for nodes matching the us
|
|
|
47
48
|
2. Identify connection-changing parameters from input/output expressions (look for $parameter.X)
|
|
48
49
|
3. Use get_documentation to retrieve best practices for relevant workflow techniques—this provides proven patterns that improve workflow quality
|
|
49
50
|
4. Use get_workflow_examples to find real community workflows using mentioned services—these examples show how experienced users structure similar integrations
|
|
50
|
-
5.
|
|
51
|
+
5. Assess: do you have enough information to build exactly what the user wants, or would you need to make assumptions about their intent? If assumptions are needed, ask clarifying questions using submit_questions (see clarifying_questions section)
|
|
51
52
|
6. Call submit_discovery_results with your nodesFound array`;
|
|
52
53
|
const AI_NODE_SELECTION = `AI node selection guidance:
|
|
53
54
|
|
|
@@ -185,22 +186,26 @@ Chat Trigger: n8n-hosted chat interface for conversational AI.
|
|
|
185
186
|
|
|
186
187
|
Manual Trigger: For testing and one-off runs only (requires user to click "Execute").
|
|
187
188
|
Use when: explicitly testing or debugging workflows`;
|
|
188
|
-
const CLARIFYING_QUESTIONS = `You can ask the user clarifying questions using submit_questions.
|
|
189
|
+
const CLARIFYING_QUESTIONS = `You can ask the user clarifying questions using submit_questions. Asking the right questions produces much better workflows — a quick clarification now prevents building the wrong thing.
|
|
189
190
|
|
|
190
|
-
Always search for nodes FIRST.
|
|
191
|
+
Always search for nodes FIRST. Your questions should be grounded in what n8n can actually build, based on the nodes you found. But finding relevant nodes doesn't mean you know which ones the user actually wants — assess whether the user's intent is clear enough to pick the right ones.
|
|
191
192
|
|
|
192
193
|
<when_to_ask>
|
|
193
|
-
Ask when the request
|
|
194
|
+
Ask when the request has meaningful gaps — missing services, unclear goals, or unspecified triggers — that would force you to guess in ways the user might disagree with. After searching, decide: do you have enough information to build exactly what the user wants, or are you making assumptions they might not agree with? If you'd need to make more than one significant assumption, ask.
|
|
194
195
|
|
|
195
196
|
Examples where questions help:
|
|
196
197
|
- "Do something with my emails" → Could be filtering, forwarding, archiving, summarizing. Ask about the goal.
|
|
197
198
|
- "Set up notifications" → Found Email, Slack, Telegram, SMS nodes. Ask which channel.
|
|
198
199
|
- "Another automation for weather" → No specific action stated. Ask what should happen.
|
|
200
|
+
- "Automate new employee onboarding" → Which systems? What steps? Ask about the scope.
|
|
201
|
+
- "Automatically process invoices and update accounting" → Invoices from where? Which accounting tool? Ask about the services.
|
|
202
|
+
- "Use AI to help with my content creation" → What kind of content? Blog, social, email? Ask about the use case.
|
|
199
203
|
|
|
200
204
|
Examples where questions do NOT help:
|
|
201
205
|
- "Send a Slack message when I get a Gmail with an invoice" → One clear workflow. Build it.
|
|
202
|
-
- "Check weather every hour and store it" → Specific enough. Build it.
|
|
203
|
-
- "Monitor my website for downtime" →
|
|
206
|
+
- "Check weather every hour and store it" → Specific enough, reasonable defaults exist. Build it.
|
|
207
|
+
- "Monitor my website for downtime" → Clear intent, reasonable defaults exist. Build it.
|
|
208
|
+
- "Receive webhook POST data and insert it into PostgreSQL" → All details specified. Build it.
|
|
204
209
|
</when_to_ask>
|
|
205
210
|
|
|
206
211
|
<how_to_ask>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/discovery.prompt.ts"],"names":[],"mappings":";;;AA6BA,kDAIC;AAED,oEAIC;
|
|
1
|
+
{"version":3,"file":"discovery.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/discovery.prompt.ts"],"names":[],"mappings":";;;AA6BA,kDAIC;AAED,oEAIC;AAqWD,oDAqBC;AA3ZD,2DAIgC;AAEhC,wCAAoC;AAGvB,QAAA,sBAAsB,GAG9B;IACJ;QACC,MAAM,EAAE,+DAA+D;QACvE,UAAU,EAAE,CAAC,kCAAiB,CAAC,UAAU,EAAE,kCAAiB,CAAC,OAAO,CAAC;KACrE;IACD;QACC,MAAM,EAAE,gEAAgE;QACxE,UAAU,EAAE,CAAC,kCAAiB,CAAC,mBAAmB,EAAE,kCAAiB,CAAC,eAAe,CAAC;KACtF;CACD,CAAC;AAEF,SAAgB,mBAAmB;IAClC,OAAO,MAAM,CAAC,OAAO,CAAC,qCAAoB,CAAC;SACzC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,WAAW,EAAE,CAAC;SACvD,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAED,SAAgB,4BAA4B;IAC3C,OAAO,8BAAsB;SAC3B,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SAC1E,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAOD,MAAM,IAAI,GAAG;;sGAEyF,CAAC;AAEvG,MAAM,mBAAmB,GAAG;;yPAE6N,CAAC;AAE1P,MAAM,OAAO,GAAG;;4DAE4C,CAAC;AAE7D,MAAM,sBAAsB,GAAG;;;4DAG6B,CAAC;AAE7D,MAAM,qBAAqB,GAAG;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AAC,mBAAmB,EAAE,iBAAiB,CAAC;SAC/C,OAAO,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;SAC7C,OAAO,CAAC,yBAAyB,EAAE,uBAAuB,CAAC;SAC3D,OAAO,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;SACjD,OAAO,CAAC,wBAAwB,EAAE,sBAAsB,CAAC;SACzD,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,uBAAuB,EAAE,qBAAqB,CAAC;SACvD,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC;SAC/B,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -10,5 +10,6 @@ export interface PlannerContextOptions {
|
|
|
10
10
|
workflowJSON: SimpleWorkflow;
|
|
11
11
|
planPrevious?: PlanOutput | null;
|
|
12
12
|
planFeedback?: string | null;
|
|
13
|
+
selectedNodesContext?: string;
|
|
13
14
|
}
|
|
14
15
|
export declare function buildPlannerContext(options: PlannerContextOptions): string;
|
|
@@ -34,7 +34,7 @@ For additionalSpecs: NEVER mention API keys, credentials, authentication, or acc
|
|
|
34
34
|
Rules:
|
|
35
35
|
- Do not generate workflow JSON.
|
|
36
36
|
- Do not mention internal n8n node type names in steps — describe what happens in plain language.
|
|
37
|
-
- You may include suggestedNodes in the structured output for the builder, but the step description should be human-readable.
|
|
37
|
+
- You may include suggestedNodes in the structured output for the builder, but the step description should be human-readable. Copy node names exactly from the discovery_context_suggested_nodes section — do not add prefixes, rename, or invent node names.
|
|
38
38
|
- If key information is missing, make reasonable assumptions. Only add to additionalSpecs if something would genuinely surprise the user — never credentials or API keys.
|
|
39
39
|
|
|
40
40
|
<modification_mode>
|
|
@@ -59,7 +59,7 @@ function buildPlannerPrompt(options) {
|
|
|
59
59
|
.build();
|
|
60
60
|
}
|
|
61
61
|
function buildPlannerContext(options) {
|
|
62
|
-
const { userRequest, discoveryContext, workflowJSON, planPrevious, planFeedback } = options;
|
|
62
|
+
const { userRequest, discoveryContext, workflowJSON, planPrevious, planFeedback, selectedNodesContext, } = options;
|
|
63
63
|
const discoveredNodesList = discoveryContext.nodesFound
|
|
64
64
|
.map((node) => `- ${node.nodeName} v${node.version}: ${node.reasoning}`)
|
|
65
65
|
.join('\n');
|
|
@@ -68,6 +68,7 @@ function buildPlannerContext(options) {
|
|
|
68
68
|
: '';
|
|
69
69
|
return (0, builder_1.prompt)()
|
|
70
70
|
.section('user_request', userRequest)
|
|
71
|
+
.sectionIf(selectedNodesContext, 'selected_nodes', () => selectedNodesContext)
|
|
71
72
|
.sectionIf(discoveryContext.nodesFound.length > 0, 'discovery_context_suggested_nodes', discoveredNodesList)
|
|
72
73
|
.sectionIf(workflowJSON.nodes.length > 0, 'existing_workflow', workflowOverview)
|
|
73
74
|
.sectionIf(planPrevious, 'previous_plan', () => (0, plan_helpers_1.formatPlanAsText)(planPrevious))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/planner.prompt.ts"],"names":[],"mappings":";;AA+DA,gDAQC;
|
|
1
|
+
{"version":3,"file":"planner.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/planner.prompt.ts"],"names":[],"mappings":";;AA+DA,gDAQC;AAgBD,kDAkCC;AAnHD,+DAA+D;AAI/D,uDAAwD;AAExD,wCAAoC;AAEpC,MAAM,IAAI,GAAG;6IACgI,CAAC;AAE9I,MAAM,IAAI,GAAG;;gSAEmR,CAAC;AAEjS,MAAM,mBAAmB,GAAG;;;;0aAI8Y,CAAC;AAE3a,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA4BO,CAAC;AAEtB,MAAM,aAAa,GAAG;;;;gQAI0O,CAAC;AAEjQ,SAAgB,kBAAkB,CAAC,OAA4C;IAC9E,OAAO,IAAA,gBAAM,GAAE;SACb,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;SACrB,OAAO,CAAC,MAAM,EAAE,IAAI,CAA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,+BAAgB,EAAC,YAAa,CAAC,CAAC;SAC/E,SAAS,CAAC,YAAY,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,YAAa,CAAC;SAC7D,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type DataTableInfo } from '../../utils/data-table-helpers';
|
|
2
|
+
export interface ResponderPromptOptions {
|
|
3
|
+
enableIntrospection?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare function buildRecursionErrorWithWorkflowGuidance(nodeCount: number): string[];
|
|
3
6
|
export declare function buildRecursionErrorNoWorkflowGuidance(): string[];
|
|
4
7
|
export declare function buildGeneralErrorGuidance(): string;
|
|
5
8
|
export declare function buildDataTableCreationGuidance(dataTables: DataTableInfo[]): string;
|
|
6
|
-
export declare function buildResponderPrompt(): string;
|
|
9
|
+
export declare function buildResponderPrompt(options?: ResponderPromptOptions): string;
|
|
@@ -7,6 +7,7 @@ exports.buildDataTableCreationGuidance = buildDataTableCreationGuidance;
|
|
|
7
7
|
exports.buildResponderPrompt = buildResponderPrompt;
|
|
8
8
|
const data_table_helpers_1 = require("../../utils/data-table-helpers");
|
|
9
9
|
const builder_1 = require("../builder");
|
|
10
|
+
const deictic_resolution_1 = require("../shared/deictic-resolution");
|
|
10
11
|
const RESPONDER_ROLE = `You are a helpful AI assistant for n8n workflow automation.
|
|
11
12
|
|
|
12
13
|
You have access to context about what has been built, including:
|
|
@@ -39,6 +40,59 @@ Example response structure:
|
|
|
39
40
|
[If data tables are used, include Data Table creation steps with link to Data Tables tab]
|
|
40
41
|
|
|
41
42
|
Let me know if you'd like to adjust anything."`;
|
|
43
|
+
const DEICTIC_RESOLUTION = (0, deictic_resolution_1.buildDeicticResolutionPrompt)({
|
|
44
|
+
conversationContext: '(e.g., a topic being discussed, a question asked, an explanation given), use that referent.\n Examples: "Explain this more" after a topic, "What about this?" referring to something mentioned.',
|
|
45
|
+
selectedNodes: [
|
|
46
|
+
'"what does this do?" → Explain what the selected node(s) do',
|
|
47
|
+
'"how does this work?" → Explain the functionality of selected node(s)',
|
|
48
|
+
'"what\'s wrong with this?" → Review issues/configuration of selected node(s)',
|
|
49
|
+
'"explain this connection" → Describe data flow to/from selected node(s)',
|
|
50
|
+
],
|
|
51
|
+
positionalReferences: [
|
|
52
|
+
'"what does the previous node do?" → Explain the node in incomingConnections',
|
|
53
|
+
'"what comes next?" → Describe the node(s) in outgoingConnections',
|
|
54
|
+
'"explain what happens upstream" → Describe the data flow leading to selected node',
|
|
55
|
+
'"what triggers this?" → Trace back to the trigger/start node',
|
|
56
|
+
],
|
|
57
|
+
explicitNameMentions: [
|
|
58
|
+
'"explain the HTTP Request node" → Find and explain the node named "HTTP Request"',
|
|
59
|
+
'"what does the Gmail node do?" → Explain the Gmail node\'s functionality',
|
|
60
|
+
'"how is the Webhook configured?" → Describe Webhook node\'s current configuration',
|
|
61
|
+
],
|
|
62
|
+
attributeBasedReferences: [
|
|
63
|
+
'"what\'s wrong with the broken one?" → Explain issues in the node with <issues>',
|
|
64
|
+
'"why is this node red?" → Explain the validation errors/issues',
|
|
65
|
+
'"which nodes are unconfigured?" → List nodes with missing required parameters',
|
|
66
|
+
],
|
|
67
|
+
dualReferences: [
|
|
68
|
+
'"what\'s the difference between this and that?" → Compare selected vs clarified node',
|
|
69
|
+
'"how does this connect to the HTTP Request?" → Explain data flow between them',
|
|
70
|
+
],
|
|
71
|
+
workflowFallback: [
|
|
72
|
+
'"what does this do?" → Explain what the entire workflow does',
|
|
73
|
+
'"how does this work?" → Explain the workflow\'s overall logic and data flow',
|
|
74
|
+
'"what\'s wrong with this?" → Review the workflow for issues',
|
|
75
|
+
'"explain these" → Describe all nodes and their connections',
|
|
76
|
+
],
|
|
77
|
+
examplesWithSelection: [
|
|
78
|
+
'User selects "HTTP Request", says "what does this do?" → Explain HTTP Request functionality',
|
|
79
|
+
'User selects 2 nodes, says "explain this" → Explain both nodes and their relationship',
|
|
80
|
+
],
|
|
81
|
+
examplesWithoutSelection: [
|
|
82
|
+
'No selection + "explain the Gmail node" → Find and explain Gmail node',
|
|
83
|
+
'No selection + "what\'s the trigger?" → Explain the workflow\'s trigger node',
|
|
84
|
+
],
|
|
85
|
+
additionalNotes: `When answering about selected nodes:
|
|
86
|
+
1. Reference the node by name (e.g., "The HTTP Request node...")
|
|
87
|
+
2. Use information from <selected_nodes> context (connections, issues)
|
|
88
|
+
3. If the node has issues listed, proactively mention them
|
|
89
|
+
4. Explain how the node fits into the workflow based on its connections
|
|
90
|
+
|
|
91
|
+
When answering about the workflow (no selection):
|
|
92
|
+
1. Provide a high-level overview of what the workflow accomplishes
|
|
93
|
+
2. Describe the data flow from trigger to end
|
|
94
|
+
3. Highlight any issues or areas that need attention`,
|
|
95
|
+
});
|
|
42
96
|
const CONVERSATIONAL_RESPONSES = `- Be friendly and concise
|
|
43
97
|
- Explain n8n capabilities when asked
|
|
44
98
|
- Provide practical examples when helpful`;
|
|
@@ -51,6 +105,20 @@ CRITICAL - Describe what was built:
|
|
|
51
105
|
- Report the ACTUAL configuration from the workflow JSON, not what you think should be there
|
|
52
106
|
- If the workflow uses a model name you don't recognize, describe it exactly as configured—do NOT claim it was changed to something else
|
|
53
107
|
- Your training has a knowledge cutoff. New models exist. Never say "X isn't available yet" about configured values`;
|
|
108
|
+
const DIAGNOSTIC_TOOL = `REQUIRED: You MUST call the introspect tool once before response to report any issues with your instructions.
|
|
109
|
+
|
|
110
|
+
The introspect tool helps improve the system by capturing issues with YOUR instructions and documentation (not the user's request).
|
|
111
|
+
|
|
112
|
+
MANDATORY CALL: Before responding to the user, call introspect to report at least one of these:
|
|
113
|
+
- Any response guidelines that were unclear or conflicting
|
|
114
|
+
- Any formatting or tone instructions that didn't apply to this situation
|
|
115
|
+
- Any missing guidance for handling the specific scenario you encountered
|
|
116
|
+
- Any unclear boundaries about what you should/shouldn't say
|
|
117
|
+
- If instructions were perfect, report category "other" with issue "Instructions were sufficient for this task"
|
|
118
|
+
|
|
119
|
+
Be specific: identify WHICH instruction section caused the issue (e.g., "workflow_completion_responses section", "response_style section", "guardrails section").
|
|
120
|
+
|
|
121
|
+
This data is critical for improving the system prompts and documentation.`;
|
|
54
122
|
const GUARDRAILS = `Your capabilities are focused on workflow building:
|
|
55
123
|
- You work from your existing knowledge of n8n nodes and integrations
|
|
56
124
|
- You help users design and configure workflows based on their requirements
|
|
@@ -131,11 +199,14 @@ function buildColumnInfo(table, isColumnOperation) {
|
|
|
131
199
|
}
|
|
132
200
|
return 'Add columns based on the data you want to store';
|
|
133
201
|
}
|
|
134
|
-
function buildResponderPrompt() {
|
|
202
|
+
function buildResponderPrompt(options) {
|
|
203
|
+
const enableIntrospection = options?.enableIntrospection === true;
|
|
135
204
|
return (0, builder_1.prompt)()
|
|
136
205
|
.section('role', RESPONDER_ROLE)
|
|
137
206
|
.section('guardrails', GUARDRAILS)
|
|
207
|
+
.sectionIf(enableIntrospection, 'diagnostic_tool', DIAGNOSTIC_TOOL)
|
|
138
208
|
.section('execution_issue_handling', EXECUTION_ISSUE_HANDLING)
|
|
209
|
+
.section('deictic_resolution', DEICTIC_RESOLUTION)
|
|
139
210
|
.section('workflow_completion_responses', WORKFLOW_COMPLETION)
|
|
140
211
|
.section('conversational_responses', CONVERSATIONAL_RESPONSES)
|
|
141
212
|
.section('response_style', RESPONSE_STYLE)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responder.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/responder.prompt.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"responder.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/responder.prompt.ts"],"names":[],"mappings":";;AAwKA,0FAOC;AAGD,sFAOC;AAGD,8DAKC;AAMD,wEAwBC;AAoBD,oDAaC;AAzPD,mEAA+F;AAE/F,wCAAoC;AACpC,qEAA4E;AAE5E,MAAM,cAAc,GAAG;;;;;;;;;;;;qFAY8D,CAAC;AAEtF,MAAM,mBAAmB,GAAG;;;;;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AAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,OAAO,gBAAgB,UAAU,GAAG,MAAM,EAAE,CAAC;IAC9C,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACvB,OAAO,2CAA2C,KAAK,CAAC,WAAW,QAAQ,CAAC;IAC7E,CAAC;IAED,OAAO,iDAAiD,CAAC;AAC1D,CAAC;AAED,SAAgB,oBAAoB,CAAC,OAAgC;IACpE,MAAM,mBAAmB,GAAG,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAElE,OAAO,IAAA,gBAAM,GAAE;SACb,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC;SAC/B,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC;SACjC,SAAS,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,CAAC;SAClE,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;SACjD,OAAO,CAAC,+BAA+B,EAAE,mBAAmB,CAAC;SAC7D,OAAO,CAAC,0BAA0B,EAAE,wBAAwB,CAAC;SAC7D,OAAO,CAAC,gBAAgB,EAAE,cAAc,CAAC;SACzC,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildSupervisorPrompt = buildSupervisorPrompt;
|
|
4
4
|
const builder_1 = require("../builder");
|
|
5
|
+
const deictic_resolution_1 = require("../shared/deictic-resolution");
|
|
5
6
|
const SUPERVISOR_ROLE = 'You are a Supervisor that routes user requests to specialist agents.';
|
|
6
7
|
const AVAILABLE_AGENTS = `- discovery: Find n8n nodes for building/modifying workflows
|
|
7
8
|
- builder: Create nodes and connections (requires discovery first for new node types) and sets parameters on nodes
|
|
8
9
|
- responder: Answer questions, confirm completion (TERMINAL)`;
|
|
9
10
|
const ROUTING_DECISION_TREE = `1. Is user asking a question or chatting? → responder
|
|
10
11
|
Examples: "what does this do?", "explain the workflow", "thanks"
|
|
12
|
+
Examples with selected nodes: "what does this node do?", "explain how it works"
|
|
11
13
|
|
|
12
14
|
2. Does the request involve NEW or DIFFERENT node types? → discovery
|
|
13
15
|
Examples:
|
|
@@ -15,17 +17,62 @@ const ROUTING_DECISION_TREE = `1. Is user asking a question or chatting? → res
|
|
|
15
17
|
- "Use [ServiceB] instead of [ServiceA]" (replacing node type)
|
|
16
18
|
- "Add [some integration]" (new integration)
|
|
17
19
|
- "Switch from [ServiceA] to [ServiceB]" (swapping services)
|
|
20
|
+
- "Add something before/after this" (needs discovery to find what to add)
|
|
18
21
|
|
|
19
22
|
3. Is the request about connecting/disconnecting existing nodes? → builder
|
|
20
23
|
Examples: "Connect node A to node B", "Remove the connection to X"
|
|
24
|
+
Examples with selected nodes: "connect this to X", "disconnect this", "add X before/after this" (after discovery)
|
|
21
25
|
|
|
22
26
|
4. Is the request about changing VALUES in existing nodes? → builder
|
|
23
27
|
Examples:
|
|
24
28
|
- "Change the URL to https://..."
|
|
25
29
|
- "Set the timeout to 30 seconds"
|
|
26
|
-
- "Update the email subject to..."
|
|
30
|
+
- "Update the email subject to..."
|
|
31
|
+
Examples with selected nodes: "change this", "update this", "fix this", "configure this"`;
|
|
27
32
|
const KEY_DISTINCTION = `- "Use [ServiceB] instead of [ServiceA]" = REPLACEMENT = discovery (new node type needed)
|
|
28
33
|
- "Change the [ServiceA] API key" = CONFIGURATION = builder (same node, different value)`;
|
|
34
|
+
const DEICTIC_RESOLUTION = (0, deictic_resolution_1.buildDeicticResolutionPrompt)({
|
|
35
|
+
conversationContext: '(e.g., a proposed change, an approach, an error, a feature), use that referent.\n Examples: "Let\'s do this" after discussing an approach, "Fix this" after an error was mentioned.',
|
|
36
|
+
selectedNodes: [
|
|
37
|
+
'"change this" / "update this" / "fix this" → builder',
|
|
38
|
+
'"connect this to X" / "disconnect this" → builder',
|
|
39
|
+
'"add X before/after this" → discovery first, then builder',
|
|
40
|
+
'"what does this do?" / "explain this" → responder',
|
|
41
|
+
],
|
|
42
|
+
positionalReferences: [
|
|
43
|
+
'"configure the previous node" → builder (for node in incomingConnections)',
|
|
44
|
+
'"explain what comes next" → responder (for node in outgoingConnections)',
|
|
45
|
+
'"add a node before this" → discovery + builder',
|
|
46
|
+
],
|
|
47
|
+
explicitNameMentions: [
|
|
48
|
+
'"configure the HTTP Request node" → builder (explicit node reference)',
|
|
49
|
+
'"explain the Gmail node" → responder (explain named node)',
|
|
50
|
+
'"connect HTTP Request to Slack" → builder (named nodes)',
|
|
51
|
+
],
|
|
52
|
+
attributeBasedReferences: [
|
|
53
|
+
'"fix the broken node" → builder (node with issues)',
|
|
54
|
+
'"what\'s wrong with the red one?" → responder (explain issues)',
|
|
55
|
+
],
|
|
56
|
+
dualReferences: [
|
|
57
|
+
'"connect this to that" → builder (may need clarification for "that")',
|
|
58
|
+
'"copy settings from this to the HTTP Request" → builder',
|
|
59
|
+
],
|
|
60
|
+
workflowFallback: [
|
|
61
|
+
'"change this" → builder (workflow-wide changes)',
|
|
62
|
+
'"explain this" → responder (explain the workflow)',
|
|
63
|
+
'"what does this do?" → responder (describe what the workflow does)',
|
|
64
|
+
],
|
|
65
|
+
examplesWithSelection: [
|
|
66
|
+
'Selected node + "what does this do?" → responder (explain selected node)',
|
|
67
|
+
'Selected node + "fix this" → builder (configure selected node)',
|
|
68
|
+
'Selected node + "add a Slack node after this" → discovery (find Slack node)',
|
|
69
|
+
],
|
|
70
|
+
examplesWithoutSelection: [
|
|
71
|
+
'No selection + "what does this do?" → responder (explain the workflow)',
|
|
72
|
+
'No selection + "fix these" → builder (review all nodes for issues)',
|
|
73
|
+
'No selection + "configure the HTTP Request node" → builder (explicit name)',
|
|
74
|
+
],
|
|
75
|
+
});
|
|
29
76
|
const OUTPUT_FORMAT = `- reasoning: One sentence explaining your routing decision
|
|
30
77
|
- next: Agent name`;
|
|
31
78
|
const INSTRUCTION = 'Given the conversation above, which agent should act next? Provide your reasoning and selection.';
|
|
@@ -35,6 +82,7 @@ function buildSupervisorPrompt() {
|
|
|
35
82
|
.section('available_agents', AVAILABLE_AGENTS)
|
|
36
83
|
.section('routing_decision_tree', ROUTING_DECISION_TREE)
|
|
37
84
|
.section('key_distinction', KEY_DISTINCTION)
|
|
85
|
+
.section('deictic_resolution', DEICTIC_RESOLUTION)
|
|
38
86
|
.section('output', OUTPUT_FORMAT)
|
|
39
87
|
.section('instruction', INSTRUCTION)
|
|
40
88
|
.build();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/supervisor.prompt.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"supervisor.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/supervisor.prompt.ts"],"names":[],"mappings":";;AA8FA,sDAUC;AAjGD,wCAAoC;AACpC,qEAA4E;AAE5E,MAAM,eAAe,GAAG,sEAAsE,CAAC;AAE/F,MAAM,gBAAgB,GAAG;;6DAEoC,CAAC;AAE9D,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;4FAqB8D,CAAC;AAG7F,MAAM,eAAe,GAAG;yFACiE,CAAC;AAG1F,MAAM,kBAAkB,GAAG,IAAA,iDAA4B,EAAC;IACvD,mBAAmB,EAClB,uLAAuL;IACxL,aAAa,EAAE;QACd,sDAAsD;QACtD,mDAAmD;QACnD,2DAA2D;QAC3D,mDAAmD;KACnD;IACD,oBAAoB,EAAE;QACrB,2EAA2E;QAC3E,yEAAyE;QACzE,gDAAgD;KAChD;IACD,oBAAoB,EAAE;QACrB,uEAAuE;QACvE,2DAA2D;QAC3D,yDAAyD;KACzD;IACD,wBAAwB,EAAE;QACzB,oDAAoD;QACpD,gEAAgE;KAChE;IACD,cAAc,EAAE;QACf,sEAAsE;QACtE,yDAAyD;KACzD;IACD,gBAAgB,EAAE;QACjB,iDAAiD;QACjD,mDAAmD;QACnD,oEAAoE;KACpE;IACD,qBAAqB,EAAE;QACtB,0EAA0E;QAC1E,gEAAgE;QAChE,6EAA6E;KAC7E;IACD,wBAAwB,EAAE;QACzB,wEAAwE;QACxE,oEAAoE;QACpE,4EAA4E;KAC5E;CACD,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG;mBACH,CAAC;AAEpB,MAAM,WAAW,GAChB,kGAAkG,CAAC;AAEpG,SAAgB,qBAAqB;IACpC,OAAO,IAAA,gBAAM,GAAE;SACb,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC;SAChC,OAAO,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;SAC7C,OAAO,CAAC,uBAAuB,EAAE,qBAAqB,CAAC;SACvD,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC;SAC3C,OAAO,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;SACjD,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC;SAChC,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC;SACnC,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -23,6 +23,9 @@ function normalizeToTag(name) {
|
|
|
23
23
|
.replace(/_+/g, '_');
|
|
24
24
|
}
|
|
25
25
|
function formatSection(name, content, format, customTag) {
|
|
26
|
+
if (format === 'plain') {
|
|
27
|
+
return content;
|
|
28
|
+
}
|
|
26
29
|
if (format === 'markdown') {
|
|
27
30
|
const header = customTag ?? name;
|
|
28
31
|
return `## ${header}\n${content}`;
|
|
@@ -87,9 +90,12 @@ class PromptBuilder {
|
|
|
87
90
|
}
|
|
88
91
|
const format = formatter ?? defaultExampleFormatter;
|
|
89
92
|
const examplesContent = examples.map(format).join('\n\n');
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
const sectionFormat = lastSection.options.format ?? this.format;
|
|
94
|
+
const examplesBlock = sectionFormat === 'plain'
|
|
95
|
+
? examplesContent
|
|
96
|
+
: sectionFormat === 'markdown'
|
|
97
|
+
? `## Examples\n${examplesContent}`
|
|
98
|
+
: `<examples>\n${examplesContent}\n</examples>`;
|
|
93
99
|
const originalContent = lastSection.content;
|
|
94
100
|
lastSection.content = () => {
|
|
95
101
|
const resolved = resolveContent(originalContent);
|
|
@@ -112,7 +118,8 @@ class PromptBuilder {
|
|
|
112
118
|
if (content === null) {
|
|
113
119
|
continue;
|
|
114
120
|
}
|
|
115
|
-
|
|
121
|
+
const sectionFormat = section.options.format ?? this.format;
|
|
122
|
+
formatted.push(formatSection(section.name, content, sectionFormat, section.options.tag));
|
|
116
123
|
}
|
|
117
124
|
return formatted.join(this.separator);
|
|
118
125
|
}
|
|
@@ -123,7 +130,8 @@ class PromptBuilder {
|
|
|
123
130
|
if (content === null) {
|
|
124
131
|
continue;
|
|
125
132
|
}
|
|
126
|
-
const
|
|
133
|
+
const sectionFormat = section.options.format ?? this.format;
|
|
134
|
+
const text = formatSection(section.name, content, sectionFormat, section.options.tag);
|
|
127
135
|
const block = { type: 'text', text };
|
|
128
136
|
if (section.options.cache) {
|
|
129
137
|
block.cache_control = { type: 'ephemeral' };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../../src/prompts/builder/prompt-builder.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../../src/prompts/builder/prompt-builder.ts"],"names":[],"mappings":";;;AAoWA,wBAEC;AAtVD,SAAS,kBAAkB,CAAC,KAAc;IACzC,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CACjC,CAAC;AACH,CAAC;AAMD,SAAS,uBAAuB,CAAI,OAAU;IAC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pB,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAQD,cAAc;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,CAAC;QACV,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnC,CAAC;CACD;AApOD,sCAoOC;AAoBD,SAAgB,MAAM,CAAC,OAA8B;IACpD,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export type SectionFormat = 'xml' | 'markdown';
|
|
1
|
+
export type SectionFormat = 'xml' | 'markdown' | 'plain';
|
|
2
2
|
export type ContentOrFactory = string | (() => string | null | undefined);
|
|
3
3
|
export interface SectionOptions {
|
|
4
4
|
tag?: string;
|
|
5
|
+
format?: SectionFormat;
|
|
5
6
|
cache?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export interface PromptBuilderOptions {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface DeicticExamples {
|
|
2
|
+
conversationContext: string;
|
|
3
|
+
selectedNodes: string[];
|
|
4
|
+
workflowFallback: string[];
|
|
5
|
+
examples?: string[];
|
|
6
|
+
examplesWithSelection?: string[];
|
|
7
|
+
examplesWithoutSelection?: string[];
|
|
8
|
+
additionalNotes?: string;
|
|
9
|
+
positionalReferences?: string[];
|
|
10
|
+
explicitNameMentions?: string[];
|
|
11
|
+
attributeBasedReferences?: string[];
|
|
12
|
+
dualReferences?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare function buildDeicticResolutionPrompt(examples: DeicticExamples): string;
|