@n8n/ai-workflow-builder 1.8.1 → 1.10.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 +1 -0
- 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.d.ts +8 -5
- package/dist/agents/supervisor.agent.js +37 -21
- package/dist/agents/supervisor.agent.js.map +1 -1
- package/dist/ai-workflow-builder-agent.service.d.ts +12 -4
- package/dist/ai-workflow-builder-agent.service.js +102 -51
- 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 +265 -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 +16 -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 +16 -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 +253 -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 +3 -0
- package/dist/constants.js +4 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +8 -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 +103 -12
- package/dist/multi-agent-workflow-subgraphs.js +158 -51
- package/dist/multi-agent-workflow-subgraphs.js.map +1 -1
- package/dist/parent-graph-state.d.ts +9 -0
- package/dist/parent-graph-state.js +8 -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/planner.prompt.d.ts +1 -0
- package/dist/prompts/agents/planner.prompt.js +2 -1
- 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.d.ts +3 -1
- package/dist/prompts/agents/supervisor.prompt.js +133 -13
- 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 +15 -5
- package/dist/session-manager.service.js +265 -74
- package/dist/session-manager.service.js.map +1 -1
- package/dist/subgraphs/builder.subgraph.d.ts +29 -0
- package/dist/subgraphs/builder.subgraph.js +32 -6
- package/dist/subgraphs/builder.subgraph.js.map +1 -1
- package/dist/subgraphs/discovery.subgraph.d.ts +8 -0
- package/dist/subgraphs/discovery.subgraph.js +23 -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/types/coordination.d.ts +8 -2
- package/dist/types/coordination.js +5 -0
- package/dist/types/coordination.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/session-storage.d.ts +11 -0
- package/dist/types/session-storage.js +3 -0
- package/dist/types/session-storage.js.map +1 -0
- package/dist/types/streaming.d.ts +20 -1
- package/dist/utils/cache-control/helpers.d.ts +6 -0
- package/dist/utils/cache-control/helpers.js +42 -22
- package/dist/utils/cache-control/helpers.js.map +1 -1
- package/dist/utils/cache-control/index.d.ts +1 -1
- package/dist/utils/cache-control/index.js +3 -1
- package/dist/utils/cache-control/index.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/coordination-log.d.ts +5 -2
- package/dist/utils/coordination-log.js +14 -0
- package/dist/utils/coordination-log.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/state-modifier.d.ts +1 -1
- package/dist/utils/state-modifier.js +15 -19
- package/dist/utils/state-modifier.js.map +1 -1
- package/dist/utils/stream-processor.js +29 -8
- package/dist/utils/stream-processor.js.map +1 -1
- package/dist/utils/subgraph-helpers.d.ts +2 -0
- package/dist/utils/subgraph-helpers.js +34 -1
- package/dist/utils/subgraph-helpers.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 +29 -4
- package/dist/workflow-builder-agent.js +162 -5
- package/dist/workflow-builder-agent.js.map +1 -1
- package/dist/workflow-state.d.ts +6 -0
- package/package.json +10 -6
|
@@ -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,CAAC;SACrB,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,CAAC;SACpF,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC;SACvB,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC;SACvC,KAAK,EAAE,CAAC;AACX,CAAC;AAgBD,SAAgB,mBAAmB,CAAC,OAA8B;IACjE,MAAM,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,oBAAoB,GACpB,GAAG,OAAO,CAAC;IAEZ,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,UAAU;SACrD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;SACvE,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,MAAM,gBAAgB,GACrB,YAAY,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAC5B,CAAC,CAAC,IAAA,gCAAgB,EAChB,EAAE,QAAQ,EAAE,YAAY,EAAE,EAC1B,EAAE,eAAe,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAC7E;QACF,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,IAAA,gBAAM,GAAE;SACb,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC;SACpC,SAAS,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAqB,CAAC;SAC9E,SAAS,CACT,gBAAgB,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EACtC,mCAAmC,EACnC,mBAAmB,CACnB;SACA,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC;SAC/E,SAAS,CAAC,YAAY,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,IAAA,+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;;;;;;;;;;;;;;;;;;+CAkBmB,CAAC;AAEhD,MAAM,kBAAkB,GAAG,IAAA,iDAA4B,EAAC;IACvD,mBAAmB,EAClB,mMAAmM;IACpM,aAAa,EAAE;QACd,6DAA6D;QAC7D,uEAAuE;QACvE,8EAA8E;QAC9E,yEAAyE;KACzE;IACD,oBAAoB,EAAE;QACrB,6EAA6E;QAC7E,kEAAkE;QAClE,mFAAmF;QACnF,8DAA8D;KAC9D;IACD,oBAAoB,EAAE;QACrB,kFAAkF;QAClF,0EAA0E;QAC1E,mFAAmF;KACnF;IACD,wBAAwB,EAAE;QACzB,iFAAiF;QACjF,gEAAgE;QAChE,+EAA+E;KAC/E;IACD,cAAc,EAAE;QACf,sFAAsF;QACtF,+EAA+E;KAC/E;IACD,gBAAgB,EAAE;QACjB,8DAA8D;QAC9D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AO,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,39 +2,159 @@
|
|
|
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
|
-
const
|
|
7
|
+
const AVAILABLE_AGENTS_WITH_ASSISTANT = `- 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
|
|
9
|
+
- assistant: Answer pure knowledge questions about errors, debugging, and n8n concepts (NOT for action requests)
|
|
8
10
|
- responder: Answer questions, confirm completion (TERMINAL)`;
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
+
const AVAILABLE_AGENTS_WITHOUT_ASSISTANT = `- discovery: Find n8n nodes for building/modifying workflows
|
|
12
|
+
- builder: Create nodes and connections (requires discovery first for new node types) and sets parameters on nodes
|
|
13
|
+
- responder: Answer questions, confirm completion (TERMINAL)`;
|
|
14
|
+
const ROUTING_DECISION_TREE_WITH_ASSISTANT = `1. Is user asking a conversational question or chatting? → responder
|
|
15
|
+
Examples: "what does this do?", "explain the workflow", "thanks", "what does this node do?"
|
|
16
|
+
Responder explains THIS specific workflow/node using current workflow context.
|
|
17
|
+
|
|
18
|
+
2. Is user asking a pure KNOWLEDGE QUESTION about errors, credentials, debugging, or n8n concepts? → assistant
|
|
19
|
+
Only route here when the user is asking for information, NOT when they want you to take action.
|
|
20
|
+
Assistant provides general n8n knowledge, credential help, error diagnosis, and best practices.
|
|
21
|
+
Examples: "why is this node failing?", "how do I set up Gmail credentials?", "what does this error mean?", "how does the HTTP Request node work?", "help me debug this"
|
|
22
|
+
Examples with selected nodes: "why is this failing?", "help me fix this error"
|
|
23
|
+
|
|
24
|
+
3. Does the message contain BOTH a knowledge question AND an action request? → discovery or builder
|
|
25
|
+
When the user asks a question AND requests an action in the same message, always prefer the action path.
|
|
26
|
+
The responder will address the knowledge question when summarizing the build result.
|
|
27
|
+
Examples: "what are Slack credentials? set them up", "how does OAuth work? add it to this node", "explain webhooks and add one to my workflow"
|
|
11
28
|
|
|
12
|
-
|
|
29
|
+
4. Is the user asking you to DO something to the workflow (create, modify, configure, set up nodes)? → discovery or builder
|
|
30
|
+
IMPORTANT: If the message is an action request (imperative/instructional tone), it goes to discovery or builder, NOT assistant.
|
|
31
|
+
Examples: "set them up", "configure the node", "now add a Slack node", "connect these", "do it"
|
|
32
|
+
Continue to steps 5-7 to choose between discovery and builder.
|
|
33
|
+
|
|
34
|
+
5. Does the request involve NEW or DIFFERENT node types? → discovery
|
|
13
35
|
Examples:
|
|
14
36
|
- "Build a workflow that..." (new workflow)
|
|
15
37
|
- "Use [ServiceB] instead of [ServiceA]" (replacing node type)
|
|
16
38
|
- "Add [some integration]" (new integration)
|
|
17
39
|
- "Switch from [ServiceA] to [ServiceB]" (swapping services)
|
|
40
|
+
- "Add something before/after this" (needs discovery to find what to add)
|
|
18
41
|
|
|
19
|
-
|
|
42
|
+
6. Is the request about connecting/disconnecting existing nodes? → builder
|
|
20
43
|
Examples: "Connect node A to node B", "Remove the connection to X"
|
|
44
|
+
Examples with selected nodes: "connect this to X", "disconnect this", "add X before/after this" (after discovery)
|
|
21
45
|
|
|
22
|
-
|
|
46
|
+
7. Is the request about changing VALUES in existing nodes? → builder
|
|
23
47
|
Examples:
|
|
24
48
|
- "Change the URL to https://..."
|
|
25
49
|
- "Set the timeout to 30 seconds"
|
|
26
|
-
- "Update the email subject to..."
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
- "Update the email subject to..."
|
|
51
|
+
Examples with selected nodes: "change this", "update this", "fix this", "configure this"`;
|
|
52
|
+
const ROUTING_DECISION_TREE_WITHOUT_ASSISTANT = `1. Is user asking a conversational question or chatting? → responder
|
|
53
|
+
Examples: "what does this do?", "explain the workflow", "thanks"
|
|
54
|
+
Examples with selected nodes: "what does this node do?", "explain how it works"
|
|
55
|
+
Responder explains THIS specific workflow/node using current workflow context.
|
|
56
|
+
|
|
57
|
+
2. Is the user asking you to DO something to the workflow? → discovery or builder
|
|
58
|
+
IMPORTANT: Action requests (imperative/instructional tone) always go to discovery or builder.
|
|
59
|
+
Continue to steps 3-4 to choose between discovery and builder.
|
|
60
|
+
|
|
61
|
+
3. Does the request involve NEW or DIFFERENT node types? → discovery
|
|
62
|
+
Examples:
|
|
63
|
+
- "Build a workflow that..." (new workflow)
|
|
64
|
+
- "Use [ServiceB] instead of [ServiceA]" (replacing node type)
|
|
65
|
+
- "Add [some integration]" (new integration)
|
|
66
|
+
- "Switch from [ServiceA] to [ServiceB]" (swapping services)
|
|
67
|
+
- "Add something before/after this" (needs discovery to find what to add)
|
|
68
|
+
|
|
69
|
+
4. Is the request about connecting/disconnecting existing nodes or changing VALUES? → builder
|
|
70
|
+
Examples: "Connect node A to node B", "Remove the connection to X"
|
|
71
|
+
Examples with selected nodes: "connect this to X", "disconnect this", "add X before/after this" (after discovery)
|
|
72
|
+
Value changes: "Change the URL to https://...", "Set the timeout to 30 seconds", "Update the email subject to..."
|
|
73
|
+
Examples with selected nodes: "change this", "update this", "fix this", "configure this"`;
|
|
74
|
+
const KEY_DISTINCTION_WITH_ASSISTANT = `RESPONDER vs ASSISTANT:
|
|
75
|
+
- Responder = explains THIS specific workflow/node using current workflow context
|
|
76
|
+
- Assistant = general n8n knowledge, credential help, error diagnosis, best practices
|
|
77
|
+
- "What does this node do?" = EXPLANATION of current workflow = responder
|
|
78
|
+
- "How does the HTTP Request node work in general?" = KNOWLEDGE = assistant
|
|
79
|
+
- "Is this set up correctly?" / "What's wrong with this?" = DIAGNOSIS = assistant
|
|
80
|
+
|
|
81
|
+
ACTION vs KNOWLEDGE:
|
|
82
|
+
- "Why is this node failing?" = ERROR DEBUG = assistant (needs SDK troubleshooting)
|
|
83
|
+
- "How do I set up OAuth?" = CREDENTIAL HELP = assistant (SDK has credential documentation)
|
|
84
|
+
- "Set up OAuth on this node" = ACTION REQUEST = builder (user wants you to configure, not explain)
|
|
85
|
+
- "Now set them up for this workflow" = ACTION REQUEST = builder (imperative tone = action, not question)
|
|
86
|
+
- "Use [ServiceB] instead of [ServiceA]" = REPLACEMENT = discovery (new node type needed)
|
|
87
|
+
- "Change the [ServiceA] API key" = CONFIGURATION = builder (same node, different value)
|
|
88
|
+
|
|
89
|
+
MIXED INTENT (question + action in same message):
|
|
90
|
+
- "What are Slack credentials? Set them up" = ACTION (builder) — responder will explain credentials in summary
|
|
91
|
+
- "How does OAuth work? Add it to this node" = ACTION (discovery/builder) — responder covers the explanation
|
|
92
|
+
- "Explain webhooks and add one" = ACTION (discovery) — responder addresses the explanation part
|
|
93
|
+
- When in doubt between assistant and action, prefer action — the responder can always explain
|
|
94
|
+
|
|
95
|
+
COMMON PATTERNS:
|
|
96
|
+
- Polite wrappers: "Help me set up X" / "Can you configure this?" / "Could you add a node?" = ACTION = discovery or builder (not assistant)
|
|
97
|
+
- Complaints: "This doesn't work" / "It's broken" / "Something went wrong" = DIAGNOSIS = assistant
|
|
98
|
+
- Implicit actions: "The timeout should be higher" / "This node needs OAuth" = ACTION = builder (implicit "change it")
|
|
99
|
+
- Statements of need: "I need to send emails when X happens" = NEW WORKFLOW = discovery`;
|
|
100
|
+
const KEY_DISTINCTION_WITHOUT_ASSISTANT = `- "What does this workflow do?" = EXPLANATION = responder (generates explanation from current workflow context)
|
|
101
|
+
- "Use [ServiceB] instead of [ServiceA]" = REPLACEMENT = discovery (new node type needed)
|
|
102
|
+
- "Change the [ServiceA] API key" = CONFIGURATION = builder (same node, different value)
|
|
103
|
+
- Polite wrappers: "Help me set up X" / "Can you configure this?" = ACTION = discovery or builder
|
|
104
|
+
- Implicit actions: "The timeout should be higher" = ACTION = builder (implicit "change it")`;
|
|
105
|
+
const DEICTIC_RESOLUTION = (0, deictic_resolution_1.buildDeicticResolutionPrompt)({
|
|
106
|
+
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.',
|
|
107
|
+
selectedNodes: [
|
|
108
|
+
'"change this" / "update this" / "fix this" → builder',
|
|
109
|
+
'"connect this to X" / "disconnect this" → builder',
|
|
110
|
+
'"add X before/after this" → discovery first, then builder',
|
|
111
|
+
'"what does this do?" / "explain this" → responder',
|
|
112
|
+
],
|
|
113
|
+
positionalReferences: [
|
|
114
|
+
'"configure the previous node" → builder (for node in incomingConnections)',
|
|
115
|
+
'"explain what comes next" → responder (for node in outgoingConnections)',
|
|
116
|
+
'"add a node before this" → discovery + builder',
|
|
117
|
+
],
|
|
118
|
+
explicitNameMentions: [
|
|
119
|
+
'"configure the HTTP Request node" → builder (explicit node reference)',
|
|
120
|
+
'"explain the Gmail node" → responder (explain named node)',
|
|
121
|
+
'"connect HTTP Request to Slack" → builder (named nodes)',
|
|
122
|
+
],
|
|
123
|
+
attributeBasedReferences: [
|
|
124
|
+
'"fix the broken node" → builder (node with issues)',
|
|
125
|
+
'"what\'s wrong with the red one?" → responder (explain issues)',
|
|
126
|
+
],
|
|
127
|
+
dualReferences: [
|
|
128
|
+
'"connect this to that" → builder (may need clarification for "that")',
|
|
129
|
+
'"copy settings from this to the HTTP Request" → builder',
|
|
130
|
+
],
|
|
131
|
+
workflowFallback: [
|
|
132
|
+
'"change this" → builder (workflow-wide changes)',
|
|
133
|
+
'"explain this" → responder (explain the workflow)',
|
|
134
|
+
'"what does this do?" → responder (describe what the workflow does)',
|
|
135
|
+
],
|
|
136
|
+
examplesWithSelection: [
|
|
137
|
+
'Selected node + "what does this do?" → responder (explain selected node)',
|
|
138
|
+
'Selected node + "fix this" → builder (configure selected node)',
|
|
139
|
+
'Selected node + "add a Slack node after this" → discovery (find Slack node)',
|
|
140
|
+
],
|
|
141
|
+
examplesWithoutSelection: [
|
|
142
|
+
'No selection + "what does this do?" → responder (explain the workflow)',
|
|
143
|
+
'No selection + "fix these" → builder (review all nodes for issues)',
|
|
144
|
+
'No selection + "configure the HTTP Request node" → builder (explicit name)',
|
|
145
|
+
],
|
|
146
|
+
});
|
|
29
147
|
const OUTPUT_FORMAT = `- reasoning: One sentence explaining your routing decision
|
|
30
148
|
- next: Agent name`;
|
|
31
149
|
const INSTRUCTION = 'Given the conversation above, which agent should act next? Provide your reasoning and selection.';
|
|
32
|
-
function buildSupervisorPrompt() {
|
|
150
|
+
function buildSupervisorPrompt(options) {
|
|
151
|
+
const hasAssistant = options?.mergeAskBuild === true;
|
|
33
152
|
return (0, builder_1.prompt)()
|
|
34
153
|
.section('role', SUPERVISOR_ROLE)
|
|
35
|
-
.section('available_agents',
|
|
36
|
-
.section('routing_decision_tree',
|
|
37
|
-
.section('key_distinction',
|
|
154
|
+
.section('available_agents', hasAssistant ? AVAILABLE_AGENTS_WITH_ASSISTANT : AVAILABLE_AGENTS_WITHOUT_ASSISTANT)
|
|
155
|
+
.section('routing_decision_tree', hasAssistant ? ROUTING_DECISION_TREE_WITH_ASSISTANT : ROUTING_DECISION_TREE_WITHOUT_ASSISTANT)
|
|
156
|
+
.section('key_distinction', hasAssistant ? KEY_DISTINCTION_WITH_ASSISTANT : KEY_DISTINCTION_WITHOUT_ASSISTANT)
|
|
157
|
+
.section('deictic_resolution', DEICTIC_RESOLUTION)
|
|
38
158
|
.section('output', OUTPUT_FORMAT)
|
|
39
159
|
.section('instruction', INSTRUCTION)
|
|
40
160
|
.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":";;AAwKA,sDAqBC;AAtLD,wCAAoC;AACpC,qEAA4E;AAE5E,MAAM,eAAe,GAAG,sEAAsE,CAAC;AAE/F,MAAM,+BAA+B,GAAG;;;6DAGqB,CAAC;AAE9D,MAAM,kCAAkC,GAAG;;6DAEkB,CAAC;AAE9D,MAAM,oCAAoC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4FAqC+C,CAAC;AAE7F,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;;;;;;;4FAqB4C,CAAC;AAG7F,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;wFAyBiD,CAAC;AAEzF,MAAM,iCAAiC,GAAG;;;;6FAImD,CAAC;AAG9F,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,CAAC,OAAqC;IAC1E,MAAM,YAAY,GAAG,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAErD,OAAO,IAAA,gBAAM,GAAE;SACb,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC;SAChC,OAAO,CACP,kBAAkB,EAClB,YAAY,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,kCAAkC,CACnF;SACA,OAAO,CACP,uBAAuB,EACvB,YAAY,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,uCAAuC,CAC7F;SACA,OAAO,CACP,iBAAiB,EACjB,YAAY,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,iCAAiC,CACjF;SACA,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,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7C,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,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;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildDeicticResolutionPrompt = buildDeicticResolutionPrompt;
|
|
4
|
+
function hasItems(arr) {
|
|
5
|
+
return Boolean(arr && arr.length > 0);
|
|
6
|
+
}
|
|
7
|
+
function formatExamples(examples) {
|
|
8
|
+
return examples.map((line) => ` - ${line}`);
|
|
9
|
+
}
|
|
10
|
+
function formatBulletList(examples) {
|
|
11
|
+
return examples.map((example) => `- ${example}`);
|
|
12
|
+
}
|
|
13
|
+
function buildCoreTiers(examples) {
|
|
14
|
+
return [
|
|
15
|
+
'DEICTIC REFERENCE RESOLUTION (in priority order):',
|
|
16
|
+
'',
|
|
17
|
+
'1. CONVERSATION CONTEXT (highest priority):',
|
|
18
|
+
' If the conversation has established something that "this"/"these" could refer to',
|
|
19
|
+
` ${examples.conversationContext}`,
|
|
20
|
+
'',
|
|
21
|
+
'2. SELECTED NODES (when <selected_nodes> is present and non-empty):',
|
|
22
|
+
' - "this node" / "it" / "this" → The selected node(s)',
|
|
23
|
+
...formatExamples(examples.selectedNodes),
|
|
24
|
+
'',
|
|
25
|
+
' SINGULAR vs PLURAL handling:',
|
|
26
|
+
' - If user uses singular ("this", "it") but multiple nodes are selected:',
|
|
27
|
+
' - If nodes are similar (same type), address them together',
|
|
28
|
+
' - If nodes are different types, briefly describe each or ask which one they mean',
|
|
29
|
+
' - If user uses plural ("these") with single selection, treat as referring to that node',
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
function buildPositionalReferencesSection(examples) {
|
|
33
|
+
if (!hasItems(examples.positionalReferences))
|
|
34
|
+
return [];
|
|
35
|
+
return [
|
|
36
|
+
'',
|
|
37
|
+
'3. POSITIONAL REFERENCES (relative to selected nodes, using connection info):',
|
|
38
|
+
' Use <incoming_connections> and <outgoing_connections> from selected node context',
|
|
39
|
+
' - "previous" / "before" / "upstream" → nodes in incomingConnections',
|
|
40
|
+
' - "next" / "after" / "downstream" → nodes in outgoingConnections',
|
|
41
|
+
' - "first" / "start" → trigger/start nodes with no incoming connections',
|
|
42
|
+
' - "last" / "end" → terminal nodes with no outgoing connections',
|
|
43
|
+
...formatExamples(examples.positionalReferences),
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
function buildExplicitNameMentionsSection(examples) {
|
|
47
|
+
if (!hasItems(examples.explicitNameMentions))
|
|
48
|
+
return [];
|
|
49
|
+
const tierNumber = hasItems(examples.positionalReferences) ? '4' : '3';
|
|
50
|
+
return [
|
|
51
|
+
'',
|
|
52
|
+
`${tierNumber}. EXPLICIT NAME MENTIONS (when user mentions a node by name without @ selection):`,
|
|
53
|
+
' - "the [NodeName] node" → resolve by exact name match in workflow',
|
|
54
|
+
' - "the [NodeType]" (e.g., "the Webhook") → resolve by type match if unique',
|
|
55
|
+
' - If multiple nodes match, ask for clarification',
|
|
56
|
+
...formatExamples(examples.explicitNameMentions),
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
function buildAttributeBasedReferencesSection(examples) {
|
|
60
|
+
if (!hasItems(examples.attributeBasedReferences))
|
|
61
|
+
return [];
|
|
62
|
+
const tierNumber = (hasItems(examples.positionalReferences) ? 1 : 0) +
|
|
63
|
+
(hasItems(examples.explicitNameMentions) ? 1 : 0) +
|
|
64
|
+
3;
|
|
65
|
+
return [
|
|
66
|
+
'',
|
|
67
|
+
`${tierNumber}. ATTRIBUTE-BASED REFERENCES (when no explicit selection):`,
|
|
68
|
+
' - "the broken one" / "the red one" → nodes with non-empty <issues>',
|
|
69
|
+
' - "the unconfigured one" → nodes with missing required parameters',
|
|
70
|
+
' - "the new one" → most recently added node (if trackable)',
|
|
71
|
+
...formatExamples(examples.attributeBasedReferences),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
function buildWorkflowFallbackSection(examples) {
|
|
75
|
+
const fallbackTierNumber = (hasItems(examples.positionalReferences) ? 1 : 0) +
|
|
76
|
+
(hasItems(examples.explicitNameMentions) ? 1 : 0) +
|
|
77
|
+
(hasItems(examples.attributeBasedReferences) ? 1 : 0) +
|
|
78
|
+
3;
|
|
79
|
+
return [
|
|
80
|
+
'',
|
|
81
|
+
`${fallbackTierNumber}. WORKFLOW FALLBACK (when no nodes selected and no conversation context):`,
|
|
82
|
+
' - "this" → The workflow as a whole',
|
|
83
|
+
' - "these" / "these nodes" → All nodes in the workflow',
|
|
84
|
+
...formatExamples(examples.workflowFallback),
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
function buildDualReferencesSection(examples) {
|
|
88
|
+
if (!hasItems(examples.dualReferences))
|
|
89
|
+
return [];
|
|
90
|
+
return [
|
|
91
|
+
'',
|
|
92
|
+
'DUAL REFERENCES (when user references two things):',
|
|
93
|
+
' - "connect this to that" → this = selected node, that = requires clarification or context',
|
|
94
|
+
' - "connect this to [NodeName]" → this = selected, NodeName = explicit mention',
|
|
95
|
+
' - "move this before that" → resolve both, ask if "that" is ambiguous',
|
|
96
|
+
...formatExamples(examples.dualReferences),
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
function buildDisambiguationAndNegation() {
|
|
100
|
+
return [
|
|
101
|
+
'',
|
|
102
|
+
'DISAMBIGUATION:',
|
|
103
|
+
' - If 2+ nodes match a reference equally well, ask: "Which node do you mean: X or Y?"',
|
|
104
|
+
' - For destructive actions (delete, disconnect), always confirm the target',
|
|
105
|
+
' - If no match found, suggest similar names: "I don\'t see a node called X. Did you mean Y?"',
|
|
106
|
+
' - Never guess for ambiguous references - clarification is better than wrong actions',
|
|
107
|
+
'',
|
|
108
|
+
'NEGATION:',
|
|
109
|
+
' - "not this one" / "not X" → explicitly exclude X from consideration',
|
|
110
|
+
' - "the other one" → if 2 candidates, pick the one NOT selected/NOT recently mentioned',
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
function buildExampleSections(examples) {
|
|
114
|
+
const lines = [];
|
|
115
|
+
if (hasItems(examples.examples)) {
|
|
116
|
+
lines.push('', 'Examples:', ...formatBulletList(examples.examples));
|
|
117
|
+
}
|
|
118
|
+
if (hasItems(examples.examplesWithSelection)) {
|
|
119
|
+
lines.push('', 'Examples with selection:', ...formatBulletList(examples.examplesWithSelection));
|
|
120
|
+
}
|
|
121
|
+
if (hasItems(examples.examplesWithoutSelection)) {
|
|
122
|
+
lines.push('', 'Examples without selection:', ...formatBulletList(examples.examplesWithoutSelection));
|
|
123
|
+
}
|
|
124
|
+
if (examples.additionalNotes) {
|
|
125
|
+
lines.push('', examples.additionalNotes);
|
|
126
|
+
}
|
|
127
|
+
return lines;
|
|
128
|
+
}
|
|
129
|
+
function buildDeicticResolutionPrompt(examples) {
|
|
130
|
+
const lines = [
|
|
131
|
+
...buildCoreTiers(examples),
|
|
132
|
+
...buildPositionalReferencesSection(examples),
|
|
133
|
+
...buildExplicitNameMentionsSection(examples),
|
|
134
|
+
...buildAttributeBasedReferencesSection(examples),
|
|
135
|
+
...buildWorkflowFallbackSection(examples),
|
|
136
|
+
...buildDualReferencesSection(examples),
|
|
137
|
+
...buildDisambiguationAndNegation(),
|
|
138
|
+
...buildExampleSections(examples),
|
|
139
|
+
];
|
|
140
|
+
return lines.join('\n');
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=deictic-resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deictic-resolution.js","sourceRoot":"","sources":["../../../src/prompts/shared/deictic-resolution.ts"],"names":[],"mappings":";;AAmNA,oEAaC;AArLD,SAAS,QAAQ,CAAC,GAAyB;IAC1C,OAAO,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAGD,SAAS,cAAc,CAAC,QAAkB;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC;AAGD,SAAS,gBAAgB,CAAC,QAAkB;IAC3C,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO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,CAAC,QAAQ,CAAC;QACvC,GAAG,8BAA8B,EAAE;QACnC,GAAG,oBAAoB,CAAC,QAAQ,CAAC;KACjC,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -2,17 +2,20 @@ import { MemorySaver } from '@langchain/langgraph';
|
|
|
2
2
|
import { Logger } from '@n8n/backend-common';
|
|
3
3
|
import type { INodeTypeDescription } from 'n8n-workflow';
|
|
4
4
|
import type { HITLHistoryEntry, HITLInterruptValue } from './types/planning';
|
|
5
|
-
import {
|
|
5
|
+
import { ISessionStorage } from './types/session-storage';
|
|
6
|
+
import { LangchainMessage, Session } from './types/sessions';
|
|
6
7
|
export declare class SessionManagerService {
|
|
8
|
+
private readonly storage?;
|
|
7
9
|
private readonly logger?;
|
|
8
10
|
private checkpointer;
|
|
9
11
|
private nodeTypes;
|
|
10
12
|
private static readonly HITL_TTL_MS;
|
|
11
13
|
private pendingHitlByThreadId;
|
|
12
14
|
private hitlHistoryByThreadId;
|
|
13
|
-
constructor(parsedNodeTypes: INodeTypeDescription[], logger?: Logger | undefined);
|
|
15
|
+
constructor(parsedNodeTypes: INodeTypeDescription[], storage?: ISessionStorage | undefined, logger?: Logger | undefined);
|
|
16
|
+
get usesPersistence(): boolean;
|
|
14
17
|
updateNodeTypes(nodeTypes: INodeTypeDescription[]): void;
|
|
15
|
-
static generateThreadId(workflowId?: string, userId?: string): string;
|
|
18
|
+
static generateThreadId(workflowId?: string, userId?: string, agentType?: 'code-builder'): string;
|
|
16
19
|
getCheckpointer(): MemorySaver;
|
|
17
20
|
setPendingHitl(threadId: string, value: HITLInterruptValue, triggeringMessageId?: string): void;
|
|
18
21
|
clearPendingHitl(threadId: string): void;
|
|
@@ -28,8 +31,15 @@ export declare class SessionManagerService {
|
|
|
28
31
|
private hitlEntryToMessages;
|
|
29
32
|
private findInsertPosition;
|
|
30
33
|
private evictExpiredHitl;
|
|
31
|
-
|
|
34
|
+
loadSessionMessages(threadId: string): Promise<LangchainMessage[]>;
|
|
35
|
+
saveSessionFromCheckpointer(threadId: string, previousSummary?: string): Promise<void>;
|
|
36
|
+
getPreviousSummary(threadId: string): Promise<string | undefined>;
|
|
37
|
+
clearSession(threadId: string): Promise<void>;
|
|
38
|
+
clearAllSessions(workflowId: string, userId: string): Promise<void>;
|
|
39
|
+
getSessions(workflowId: string | undefined, userId: string | undefined, agentType?: 'code-builder'): Promise<{
|
|
32
40
|
sessions: Session[];
|
|
33
41
|
}>;
|
|
34
|
-
|
|
42
|
+
private loadMessagesForTruncation;
|
|
43
|
+
truncateMessagesAfter(workflowId: string, userId: string | undefined, messageId: string, agentType?: 'code-builder'): Promise<boolean>;
|
|
44
|
+
private resetCodeBuilderSession;
|
|
35
45
|
}
|