@n8n/ai-workflow-builder 1.7.1 → 1.8.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 +80 -0
- package/dist/agents/planner.agent.js +133 -0
- package/dist/agents/planner.agent.js.map +1 -0
- package/dist/agents/responder.agent.d.ts +44 -9
- package/dist/agents/responder.agent.js +123 -85
- package/dist/agents/responder.agent.js.map +1 -1
- package/dist/agents/supervisor.agent.d.ts +5 -3
- package/dist/agents/supervisor.agent.js +6 -5
- package/dist/agents/supervisor.agent.js.map +1 -1
- package/dist/ai-workflow-builder-agent.service.d.ts +3 -0
- package/dist/ai-workflow-builder-agent.service.js +93 -3
- package/dist/ai-workflow-builder-agent.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +5 -4
- package/dist/constants.js.map +1 -1
- package/dist/llm-config.d.ts +2 -1
- package/dist/llm-config.js +25 -1
- package/dist/llm-config.js.map +1 -1
- package/dist/multi-agent-workflow-subgraphs.d.ts +90 -6
- package/dist/multi-agent-workflow-subgraphs.js +94 -17
- package/dist/multi-agent-workflow-subgraphs.js.map +1 -1
- package/dist/parent-graph-state.d.ts +6 -0
- package/dist/parent-graph-state.js +20 -0
- package/dist/parent-graph-state.js.map +1 -1
- package/dist/prompts/agents/builder.prompt.d.ts +6 -1
- package/dist/prompts/agents/builder.prompt.js +535 -387
- package/dist/prompts/agents/builder.prompt.js.map +1 -1
- package/dist/prompts/agents/discovery.prompt.d.ts +1 -0
- package/dist/prompts/agents/discovery.prompt.js +334 -349
- package/dist/prompts/agents/discovery.prompt.js.map +1 -1
- package/dist/prompts/agents/index.d.ts +6 -0
- package/dist/prompts/agents/index.js +21 -0
- package/dist/prompts/agents/index.js.map +1 -0
- package/dist/prompts/agents/planner.prompt.d.ts +14 -0
- package/dist/prompts/agents/planner.prompt.js +77 -0
- package/dist/prompts/agents/planner.prompt.js.map +1 -0
- package/dist/prompts/agents/responder.prompt.js +35 -2
- package/dist/prompts/agents/responder.prompt.js.map +1 -1
- package/dist/prompts/agents/supervisor.prompt.js +3 -4
- package/dist/prompts/agents/supervisor.prompt.js.map +1 -1
- package/dist/prompts/index.d.ts +4 -4
- package/dist/prompts/index.js +11 -4
- package/dist/prompts/index.js.map +1 -1
- package/dist/session-manager.service.d.ts +18 -0
- package/dist/session-manager.service.js +154 -1
- package/dist/session-manager.service.js.map +1 -1
- package/dist/subgraphs/builder.subgraph.d.ts +31 -2
- package/dist/subgraphs/builder.subgraph.js +141 -35
- package/dist/subgraphs/builder.subgraph.js.map +1 -1
- package/dist/subgraphs/discovery.subgraph.d.ts +87 -27
- package/dist/subgraphs/discovery.subgraph.js +204 -24
- package/dist/subgraphs/discovery.subgraph.js.map +1 -1
- package/dist/tools/add-node.tool.d.ts +36 -0
- package/dist/tools/add-node.tool.js +28 -8
- package/dist/tools/add-node.tool.js.map +1 -1
- package/dist/tools/best-practices/triage.js +5 -5
- package/dist/tools/builder-tools.js +6 -1
- package/dist/tools/builder-tools.js.map +1 -1
- package/dist/tools/connect-nodes.tool.js +16 -3
- package/dist/tools/connect-nodes.tool.js.map +1 -1
- package/dist/tools/get-execution-logs.tool.d.ts +4 -0
- package/dist/tools/get-execution-logs.tool.js +104 -0
- package/dist/tools/get-execution-logs.tool.js.map +1 -0
- package/dist/tools/get-execution-schema.tool.d.ts +4 -0
- package/dist/tools/get-execution-schema.tool.js +81 -0
- package/dist/tools/get-execution-schema.tool.js.map +1 -0
- package/dist/tools/get-expression-data-mapping.tool.d.ts +4 -0
- package/dist/tools/get-expression-data-mapping.tool.js +85 -0
- package/dist/tools/get-expression-data-mapping.tool.js.map +1 -0
- package/dist/tools/get-node-context.tool.d.ts +13 -0
- package/dist/tools/get-node-context.tool.js +227 -0
- package/dist/tools/get-node-context.tool.js.map +1 -0
- package/dist/tools/get-node-parameter.tool.js +1 -2
- package/dist/tools/get-node-parameter.tool.js.map +1 -1
- package/dist/tools/get-workflow-overview.tool.d.ts +11 -0
- package/dist/tools/get-workflow-overview.tool.js +158 -0
- package/dist/tools/get-workflow-overview.tool.js.map +1 -0
- package/dist/tools/helpers/state.d.ts +1 -0
- package/dist/tools/helpers/state.js +10 -0
- package/dist/tools/helpers/state.js.map +1 -1
- package/dist/tools/submit-questions.tool.d.ts +71 -0
- package/dist/tools/submit-questions.tool.js +74 -0
- package/dist/tools/submit-questions.tool.js.map +1 -0
- package/dist/tools/update-node-parameters.tool.js +2 -3
- package/dist/tools/update-node-parameters.tool.js.map +1 -1
- package/dist/tools/utils/mermaid.utils.d.ts +9 -1
- package/dist/tools/utils/mermaid.utils.js +9 -5
- package/dist/tools/utils/mermaid.utils.js.map +1 -1
- package/dist/tools/utils/node-creation.utils.d.ts +6 -2
- package/dist/tools/utils/node-creation.utils.js +2 -1
- package/dist/tools/utils/node-creation.utils.js.map +1 -1
- package/dist/tools/validate-configuration.tool.js +15 -7
- package/dist/tools/validate-configuration.tool.js.map +1 -1
- package/dist/tools/validate-structure.tool.js +3 -3
- package/dist/tools/validate-structure.tool.js.map +1 -1
- package/dist/types/coordination.d.ts +9 -9
- package/dist/types/coordination.js +14 -4
- package/dist/types/coordination.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/planning.d.ts +48 -0
- package/dist/types/planning.js +3 -0
- package/dist/types/planning.js.map +1 -0
- package/dist/types/streaming.d.ts +14 -1
- package/dist/types/tools.d.ts +16 -0
- package/dist/utils/context-builders.d.ts +8 -0
- package/dist/utils/context-builders.js +249 -8
- package/dist/utils/context-builders.js.map +1 -1
- package/dist/utils/coordination-log.d.ts +2 -4
- package/dist/utils/coordination-log.js +0 -8
- package/dist/utils/coordination-log.js.map +1 -1
- package/dist/utils/node-helpers.d.ts +1 -0
- package/dist/utils/node-helpers.js +7 -0
- package/dist/utils/node-helpers.js.map +1 -1
- package/dist/utils/plan-helpers.d.ts +2 -0
- package/dist/utils/plan-helpers.js +26 -0
- package/dist/utils/plan-helpers.js.map +1 -0
- package/dist/utils/stream-processor.js +137 -8
- package/dist/utils/stream-processor.js.map +1 -1
- package/dist/utils/subgraph-helpers.js +7 -1
- package/dist/utils/subgraph-helpers.js.map +1 -1
- package/dist/utils/truncate-json.d.ts +5 -0
- package/dist/utils/truncate-json.js +18 -0
- package/dist/utils/truncate-json.js.map +1 -0
- package/dist/validation/checks/credentials.js +2 -6
- package/dist/validation/checks/credentials.js.map +1 -1
- package/dist/validation/checks/index.d.ts +1 -0
- package/dist/validation/checks/index.js +3 -1
- package/dist/validation/checks/index.js.map +1 -1
- package/dist/validation/checks/parameters.d.ts +4 -0
- package/dist/validation/checks/parameters.js +165 -0
- package/dist/validation/checks/parameters.js.map +1 -0
- package/dist/validation/programmatic.js +2 -0
- package/dist/validation/programmatic.js.map +1 -1
- package/dist/validation/types.d.ts +3 -1
- package/dist/validation/types.js +2 -0
- package/dist/validation/types.js.map +1 -1
- package/dist/workflow-builder-agent.d.ts +7 -1
- package/dist/workflow-builder-agent.js +43 -11
- package/dist/workflow-builder-agent.js.map +1 -1
- package/package.json +6 -5
- package/dist/prompts/agents/configurator.prompt.d.ts +0 -3
- package/dist/prompts/agents/configurator.prompt.js +0 -260
- package/dist/prompts/agents/configurator.prompt.js.map +0 -1
- package/dist/subgraphs/configurator.subgraph.d.ts +0 -158
- package/dist/subgraphs/configurator.subgraph.js +0 -234
- package/dist/subgraphs/configurator.subgraph.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { INodeTypeDescription, NodeConnectionType } from 'n8n-workflow';
|
|
2
2
|
import type { SimpleWorkflow } from '../types';
|
|
3
3
|
export type ProgrammaticViolationType = 'critical' | 'major' | 'minor';
|
|
4
|
-
export declare const PROGRAMMATIC_VIOLATION_NAMES: readonly ["tool-node-has-no-parameters", "tool-node-static-parameters", "agent-static-prompt", "agent-no-system-prompt", "non-tool-node-uses-fromai", "workflow-has-no-nodes", "workflow-has-no-trigger", "workflow-exceeds-max-nodes-limit", "node-missing-required-input", "node-unsupported-connection-input", "node-merge-single-input", "node-merge-incorrect-num-inputs", "node-merge-missing-input", "sub-node-not-connected", "node-type-not-found", "failed-to-resolve-connections", "workflow-similarity-node-insert", "workflow-similarity-node-delete", "workflow-similarity-node-substitute", "workflow-similarity-edge-insert", "workflow-similarity-edge-delete", "workflow-similarity-edge-substitute", "workflow-similarity-evaluation-failed", "http-request-hardcoded-credentials", "set-node-credential-field", "webhook-response-mode-missing-respond-node", "webhook-response-mode-mismatch", "data-table-missing-set-node"];
|
|
4
|
+
export declare const PROGRAMMATIC_VIOLATION_NAMES: readonly ["tool-node-has-no-parameters", "tool-node-static-parameters", "agent-static-prompt", "agent-no-system-prompt", "non-tool-node-uses-fromai", "workflow-has-no-nodes", "workflow-has-no-trigger", "workflow-exceeds-max-nodes-limit", "node-missing-required-input", "node-unsupported-connection-input", "node-merge-single-input", "node-merge-incorrect-num-inputs", "node-merge-missing-input", "sub-node-not-connected", "node-type-not-found", "failed-to-resolve-connections", "workflow-similarity-node-insert", "workflow-similarity-node-delete", "workflow-similarity-node-substitute", "workflow-similarity-edge-insert", "workflow-similarity-edge-delete", "workflow-similarity-edge-substitute", "workflow-similarity-evaluation-failed", "http-request-hardcoded-credentials", "set-node-credential-field", "webhook-response-mode-missing-respond-node", "webhook-response-mode-mismatch", "data-table-missing-set-node", "node-missing-required-parameter", "node-invalid-options-value"];
|
|
5
5
|
export type ProgrammaticViolationName = (typeof PROGRAMMATIC_VIOLATION_NAMES)[number];
|
|
6
6
|
export type TelemetryValidationStatus = Record<ProgrammaticViolationName, 'pass' | 'fail'>;
|
|
7
7
|
export interface ProgrammaticViolation {
|
|
@@ -24,6 +24,7 @@ export interface ProgrammaticChecksResult {
|
|
|
24
24
|
fromAi: ProgrammaticViolation[];
|
|
25
25
|
credentials: ProgrammaticViolation[];
|
|
26
26
|
nodeUsage: ProgrammaticViolation[];
|
|
27
|
+
parameters: ProgrammaticViolation[];
|
|
27
28
|
}
|
|
28
29
|
export interface ProgrammaticEvaluationResult {
|
|
29
30
|
overallScore: number;
|
|
@@ -35,6 +36,7 @@ export interface ProgrammaticEvaluationResult {
|
|
|
35
36
|
fromAi: SingleEvaluatorResult;
|
|
36
37
|
credentials: SingleEvaluatorResult;
|
|
37
38
|
nodeUsage: SingleEvaluatorResult;
|
|
39
|
+
parameters: SingleEvaluatorResult;
|
|
38
40
|
similarity: SingleEvaluatorResult | null;
|
|
39
41
|
}
|
|
40
42
|
export interface ProgrammaticEvaluationInput {
|
package/dist/validation/types.js
CHANGED
|
@@ -30,5 +30,7 @@ exports.PROGRAMMATIC_VIOLATION_NAMES = [
|
|
|
30
30
|
'webhook-response-mode-missing-respond-node',
|
|
31
31
|
'webhook-response-mode-mismatch',
|
|
32
32
|
'data-table-missing-set-node',
|
|
33
|
+
'node-missing-required-parameter',
|
|
34
|
+
'node-invalid-options-value',
|
|
33
35
|
];
|
|
34
36
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/validation/types.ts"],"names":[],"mappings":";;;AAMa,QAAA,4BAA4B,GAAG;IAC3C,6BAA6B;IAE7B,6BAA6B;IAC7B,qBAAqB;IACrB,wBAAwB;IACxB,2BAA2B;IAC3B,uBAAuB;IACvB,yBAAyB;IACzB,kCAAkC;IAClC,6BAA6B;IAC7B,mCAAmC;IACnC,yBAAyB;IACzB,iCAAiC;IACjC,0BAA0B;IAC1B,wBAAwB;IACxB,qBAAqB;IACrB,+BAA+B;IAC/B,iCAAiC;IACjC,iCAAiC;IACjC,qCAAqC;IACrC,iCAAiC;IACjC,iCAAiC;IACjC,qCAAqC;IACrC,uCAAuC;IACvC,oCAAoC;IACpC,2BAA2B;IAC3B,4CAA4C;IAC5C,gCAAgC;IAChC,6BAA6B;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/validation/types.ts"],"names":[],"mappings":";;;AAMa,QAAA,4BAA4B,GAAG;IAC3C,6BAA6B;IAE7B,6BAA6B;IAC7B,qBAAqB;IACrB,wBAAwB;IACxB,2BAA2B;IAC3B,uBAAuB;IACvB,yBAAyB;IACzB,kCAAkC;IAClC,6BAA6B;IAC7B,mCAAmC;IACnC,yBAAyB;IACzB,iCAAiC;IACjC,0BAA0B;IAC1B,wBAAwB;IACxB,qBAAqB;IACrB,+BAA+B;IAC/B,iCAAiC;IACjC,iCAAiC;IACjC,qCAAqC;IACrC,iCAAiC;IACjC,iCAAiC;IACjC,qCAAqC;IACrC,uCAAuC;IACvC,oCAAoC;IACpC,2BAA2B;IAC3B,4CAA4C;IAC5C,gCAAgC;IAChC,6BAA6B;IAC7B,iCAAiC;IACjC,4BAA4B;CACnB,CAAC"}
|
|
@@ -5,6 +5,7 @@ import type { MemorySaver, StateSnapshot } from '@langchain/langgraph';
|
|
|
5
5
|
import type { Logger } from '@n8n/backend-common';
|
|
6
6
|
import { type INodeTypeDescription, type IRunExecutionData, type IWorkflowBase, type NodeExecutionSchema } from 'n8n-workflow';
|
|
7
7
|
import type { ResourceLocatorCallback } from './types/callbacks';
|
|
8
|
+
import type { HITLInterruptValue } from './types/planning';
|
|
8
9
|
import type { WorkflowState } from './workflow-state';
|
|
9
10
|
export type TypedStateSnapshot = Omit<StateSnapshot, 'values'> & {
|
|
10
11
|
values: typeof WorkflowState.State;
|
|
@@ -14,8 +15,8 @@ export interface StageLLMs {
|
|
|
14
15
|
responder: BaseChatModel;
|
|
15
16
|
discovery: BaseChatModel;
|
|
16
17
|
builder: BaseChatModel;
|
|
17
|
-
configurator: BaseChatModel;
|
|
18
18
|
parameterUpdater: BaseChatModel;
|
|
19
|
+
planner: BaseChatModel;
|
|
19
20
|
}
|
|
20
21
|
export interface WorkflowBuilderAgentConfig {
|
|
21
22
|
parsedNodeTypes: INodeTypeDescription[];
|
|
@@ -36,6 +37,7 @@ export interface ExpressionValue {
|
|
|
36
37
|
}
|
|
37
38
|
export interface BuilderFeatureFlags {
|
|
38
39
|
templateExamples?: boolean;
|
|
40
|
+
planMode?: boolean;
|
|
39
41
|
}
|
|
40
42
|
export interface ChatPayload {
|
|
41
43
|
id: string;
|
|
@@ -48,6 +50,9 @@ export interface ChatPayload {
|
|
|
48
50
|
};
|
|
49
51
|
featureFlags?: BuilderFeatureFlags;
|
|
50
52
|
versionId?: string;
|
|
53
|
+
mode?: 'build' | 'plan';
|
|
54
|
+
resumeData?: unknown;
|
|
55
|
+
resumeInterrupt?: HITLInterruptValue;
|
|
51
56
|
}
|
|
52
57
|
export declare class WorkflowBuilderAgent {
|
|
53
58
|
private checkpointer;
|
|
@@ -59,6 +64,7 @@ export declare class WorkflowBuilderAgent {
|
|
|
59
64
|
private runMetadata?;
|
|
60
65
|
private onGenerationSuccess?;
|
|
61
66
|
private resourceLocatorCallback?;
|
|
67
|
+
private sessionFeatureFlags?;
|
|
62
68
|
constructor(config: WorkflowBuilderAgentConfig);
|
|
63
69
|
private createWorkflow;
|
|
64
70
|
getState(workflowId?: string, userId?: string): Promise<TypedStateSnapshot>;
|
|
@@ -21,6 +21,7 @@ class WorkflowBuilderAgent {
|
|
|
21
21
|
runMetadata;
|
|
22
22
|
onGenerationSuccess;
|
|
23
23
|
resourceLocatorCallback;
|
|
24
|
+
sessionFeatureFlags;
|
|
24
25
|
constructor(config) {
|
|
25
26
|
this.parsedNodeTypes = config.parsedNodeTypes;
|
|
26
27
|
this.stageLLMs = config.stageLLMs;
|
|
@@ -78,7 +79,10 @@ class WorkflowBuilderAgent {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
setupAgentAndConfigs(payload, userId, abortSignal, externalCallbacks) {
|
|
81
|
-
|
|
82
|
+
if (!this.sessionFeatureFlags && payload.featureFlags) {
|
|
83
|
+
this.sessionFeatureFlags = payload.featureFlags;
|
|
84
|
+
}
|
|
85
|
+
const agent = this.createWorkflow(this.sessionFeatureFlags ?? payload.featureFlags);
|
|
82
86
|
const workflowId = payload.workflowContext?.currentWorkflow?.id;
|
|
83
87
|
const threadId = session_manager_service_1.SessionManagerService.generateThreadId(workflowId, userId);
|
|
84
88
|
const threadConfig = {
|
|
@@ -98,19 +102,47 @@ class WorkflowBuilderAgent {
|
|
|
98
102
|
return { agent, threadConfig, streamConfig };
|
|
99
103
|
}
|
|
100
104
|
async createAgentStream(payload, streamConfig, agent) {
|
|
105
|
+
const additionalKwargs = {};
|
|
106
|
+
if (payload.versionId)
|
|
107
|
+
additionalKwargs.versionId = payload.versionId;
|
|
108
|
+
if (payload.id)
|
|
109
|
+
additionalKwargs.messageId = payload.id;
|
|
110
|
+
if (payload.resumeData !== undefined)
|
|
111
|
+
additionalKwargs.resumeData = payload.resumeData;
|
|
101
112
|
const humanMessage = new messages_1.HumanMessage({
|
|
102
113
|
content: payload.message,
|
|
103
|
-
additional_kwargs:
|
|
104
|
-
...(payload.versionId && { versionId: payload.versionId }),
|
|
105
|
-
...(payload.id && { messageId: payload.id }),
|
|
106
|
-
},
|
|
114
|
+
additional_kwargs: additionalKwargs,
|
|
107
115
|
});
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
const workflowJSON = this.getDefaultWorkflowJSON(payload);
|
|
117
|
+
const workflowContext = payload.workflowContext;
|
|
118
|
+
const mode = payload.mode ?? 'build';
|
|
119
|
+
const stream = payload.resumeData
|
|
120
|
+
? await agent.stream(new langgraph_1.Command({
|
|
121
|
+
resume: payload.resumeData,
|
|
122
|
+
update: {
|
|
123
|
+
messages: [
|
|
124
|
+
...(payload.resumeInterrupt
|
|
125
|
+
? [
|
|
126
|
+
new messages_1.AIMessage({
|
|
127
|
+
content: JSON.stringify(payload.resumeInterrupt),
|
|
128
|
+
additional_kwargs: { messageType: payload.resumeInterrupt.type },
|
|
129
|
+
}),
|
|
130
|
+
]
|
|
131
|
+
: []),
|
|
132
|
+
humanMessage,
|
|
133
|
+
],
|
|
134
|
+
workflowJSON,
|
|
135
|
+
workflowContext,
|
|
136
|
+
...(payload.mode ? { mode: payload.mode } : {}),
|
|
137
|
+
},
|
|
138
|
+
}), streamConfig)
|
|
139
|
+
: await agent.stream({
|
|
140
|
+
messages: [humanMessage],
|
|
141
|
+
workflowJSON,
|
|
142
|
+
workflowOperations: [],
|
|
143
|
+
workflowContext,
|
|
144
|
+
mode,
|
|
145
|
+
}, streamConfig);
|
|
114
146
|
return stream;
|
|
115
147
|
}
|
|
116
148
|
handleStreamError(error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-builder-agent.js","sourceRoot":"","sources":["../src/workflow-builder-agent.ts"],"names":[],"mappings":";;;AAGA,uDAAmE;AAInE,
|
|
1
|
+
{"version":3,"file":"workflow-builder-agent.js","sourceRoot":"","sources":["../src/workflow-builder-agent.ts"],"names":[],"mappings":";;;AAGA,uDAAmE;AAInE,oDAAoE;AAEpE,+CAMsB;AAEtB,2CAA8F;AAE9F,qCAA2C;AAC3C,qFAAyF;AACzF,uEAAkE;AAIlE,+DAAmF;AAGnF,MAAM,yBAAyB,GAC9B,uIAAuI,CAAC;AAEzI,MAAM,0BAA0B,GAC/B,0OAA0O,CAAC;AAuE5O,MAAa,oBAAoB;IACxB,YAAY,CAAc;IAC1B,eAAe,CAAyB;IACxC,SAAS,CAAY;IACrB,MAAM,CAAU;IAChB,MAAM,CAAmB;IACzB,WAAW,CAAU;IACrB,WAAW,CAA2B;IACtC,mBAAmB,CAAuB;IAC1C,uBAAuB,CAA2B;IAElD,mBAAmB,CAAuB;IAElD,YAAY,MAAkC;QAC7C,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;QAC9C,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,M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index.js",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,17 +21,18 @@
|
|
|
21
21
|
"@langchain/core": "1.1.8",
|
|
22
22
|
"@langchain/langgraph": "1.0.2",
|
|
23
23
|
"@langchain/openai": "1.1.3",
|
|
24
|
+
"langchain": "1.2.3",
|
|
24
25
|
"@n8n_io/ai-assistant-sdk": "1.20.0",
|
|
25
26
|
"csv-parse": "5.5.0",
|
|
26
27
|
"langsmith": "^0.4.2",
|
|
27
28
|
"lodash": "4.17.23",
|
|
28
29
|
"picocolors": "1.0.1",
|
|
29
30
|
"zod": "3.25.67",
|
|
30
|
-
"@n8n/backend-common": "1.
|
|
31
|
-
"@n8n/config": "2.6.0",
|
|
31
|
+
"@n8n/backend-common": "1.8.0",
|
|
32
32
|
"@n8n/di": "0.10.0",
|
|
33
|
-
"
|
|
34
|
-
"n8n
|
|
33
|
+
"n8n-workflow": "2.8.0",
|
|
34
|
+
"@n8n/utils": "1.24.0",
|
|
35
|
+
"@n8n/config": "2.7.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/cli-progress": "^3.11.5",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const INSTANCE_URL_PROMPT = "\n<instance_url>\nThe n8n instance base URL is: {instanceUrl}\n\nThis URL is essential for webhook nodes and chat triggers as it provides the base URL for:\n- Webhook URLs that external services need to call\n- Chat trigger URLs for conversational interfaces\n- Any node that requires the full instance URL to generate proper callback URLs\n\nWhen working with webhook or chat trigger nodes, use this URL as the base for constructing proper endpoint URLs.\n</instance_url>\n";
|
|
2
|
-
export declare function buildRecoveryModeContext(nodeCount: number, nodeNames: string[]): string;
|
|
3
|
-
export declare function buildConfiguratorPrompt(): string;
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INSTANCE_URL_PROMPT = void 0;
|
|
4
|
-
exports.buildRecoveryModeContext = buildRecoveryModeContext;
|
|
5
|
-
exports.buildConfiguratorPrompt = buildConfiguratorPrompt;
|
|
6
|
-
const data_table_helpers_1 = require("../../utils/data-table-helpers");
|
|
7
|
-
const builder_1 = require("../builder");
|
|
8
|
-
const node_guidance_1 = require("../shared/node-guidance");
|
|
9
|
-
const dataTableColumnOperationsList = data_table_helpers_1.DATA_TABLE_ROW_COLUMN_MAPPING_OPERATIONS.join(', ');
|
|
10
|
-
const CONFIGURATOR_ROLE = 'You are a Configurator Agent specialized in setting up n8n node parameters.';
|
|
11
|
-
const EXECUTION_SEQUENCE = `You MUST follow these steps IN ORDER. Do not skip any step.
|
|
12
|
-
|
|
13
|
-
STEP 1: RETRIEVE NODE EXAMPLES
|
|
14
|
-
- Call the get_node_configuration_examples tool for each node type being configured
|
|
15
|
-
- Use the examples to understand how these node types can be configured
|
|
16
|
-
|
|
17
|
-
STEP 2: CONFIGURE ALL NODES
|
|
18
|
-
- Call update_node_parameters for EVERY node in the workflow
|
|
19
|
-
- Configure multiple nodes in PARALLEL for efficiency
|
|
20
|
-
- Do NOT respond with text - START CONFIGURING immediately
|
|
21
|
-
|
|
22
|
-
STEP 3: VALIDATE (REQUIRED)
|
|
23
|
-
- After ALL configurations complete, call validate_configuration
|
|
24
|
-
- This step is MANDATORY - you cannot finish without it
|
|
25
|
-
- If validation finds issues, fix them and validate again
|
|
26
|
-
- MAXIMUM 3 VALIDATION ATTEMPTS: After 3 calls to validate_configuration, proceed to respond regardless of remaining issues
|
|
27
|
-
|
|
28
|
-
STEP 4: RESPOND TO USER
|
|
29
|
-
- Only after validation passes, provide your response
|
|
30
|
-
|
|
31
|
-
NEVER respond to the user without calling validate_configuration first`;
|
|
32
|
-
const WORKFLOW_JSON_DETECTION = `- You receive <current_workflow_json> in your context
|
|
33
|
-
- If you see nodes in the workflow JSON, you MUST configure them IMMEDIATELY
|
|
34
|
-
- Look at the workflow JSON, identify each node, and call update_node_parameters for ALL of them`;
|
|
35
|
-
const PARAMETER_CONFIGURATION = `Use update_node_parameters with natural language instructions:
|
|
36
|
-
- "Set URL to https://api.example.com/weather"
|
|
37
|
-
- "Add header Authorization: Bearer token"
|
|
38
|
-
- "Set method to POST"
|
|
39
|
-
- "Add field 'status' with value 'processed'"
|
|
40
|
-
|
|
41
|
-
RESOURCE/OPERATION HANDLING:
|
|
42
|
-
For nodes with resource/operation patterns (Gmail, Notion, Google Sheets, Google Drive, Slack, etc.):
|
|
43
|
-
- The Builder agent has ALREADY set resource and operation - check the workflow JSON
|
|
44
|
-
- Usually you should NOT change these - focus on configuring other parameters
|
|
45
|
-
- If you DO need to change resource/operation (e.g., user explicitly requests it or Builder made a mistake):
|
|
46
|
-
- ONLY use values from the DISCOVERY CONTEXT section - it lists valid resource/operation combinations
|
|
47
|
-
- NEVER hallucinate or guess operation names - if it's not in discovery context, it doesn't exist
|
|
48
|
-
- The parameter list you receive is filtered based on the current resource/operation`;
|
|
49
|
-
const DATA_REFERENCING = `Nodes output an array of items. Nodes have access to the output items of all the nodes that have already executed.
|
|
50
|
-
|
|
51
|
-
Within a node, data from previous nodes is commonly referenced using the following:
|
|
52
|
-
- $json: the current JSON data of the previous node
|
|
53
|
-
- $('<node_name>').item.json: the JSON data of the matching item of any preceding node
|
|
54
|
-
|
|
55
|
-
Prefer $('<node_name>').item to $('<node_name>').first() or $('<node_name>').last() unless it is explicitly required to fix an error.
|
|
56
|
-
|
|
57
|
-
Examples in parameter configuration:
|
|
58
|
-
- "Set field to ={{ $json.fieldName }}"
|
|
59
|
-
- "Set value to ={{ $('Previous Node').item.json.value }}"
|
|
60
|
-
- "Set message to ={{ $('HTTP Request').item.json.message }}"`;
|
|
61
|
-
const EXPRESSION_TECHNIQUES = `Expressions support JavaScript methods
|
|
62
|
-
|
|
63
|
-
Regex operations:
|
|
64
|
-
- Test pattern: ={{ /pattern/.test($json.text) }}
|
|
65
|
-
- Extract match: ={{ $json.text.match(/pattern/)?.[1] }}
|
|
66
|
-
- Replace text: ={{ $json.text.replace(/pattern/, 'replacement') }}
|
|
67
|
-
- Split by pattern: ={{ $json.text.split(/pattern/) }}
|
|
68
|
-
|
|
69
|
-
String operations:
|
|
70
|
-
- Uppercase: ={{ $json.text.toUpperCase() }}
|
|
71
|
-
- Trim whitespace: ={{ $json.text.trim() }}
|
|
72
|
-
- Substring: ={{ $json.text.substring(0, 10) }}
|
|
73
|
-
|
|
74
|
-
Array operations:
|
|
75
|
-
- First item: ={{ $json.items[0] }}
|
|
76
|
-
- Filter: ={{ $json.items.filter(i => i.active) }}
|
|
77
|
-
- Map: ={{ $json.items.map(i => i.name) }}
|
|
78
|
-
- Join: ={{ $json.items.join(', ') }}
|
|
79
|
-
|
|
80
|
-
Generating items from expressions (use with Split Out node):
|
|
81
|
-
- Create array from comma string: ={{ $json.text.split(',') }}
|
|
82
|
-
- Generate range: ={{ Array.from({{length: 5}}, (_, i) => i + 1) }}
|
|
83
|
-
- Use with Split Out node to create multiple output items from a single input`;
|
|
84
|
-
const TOOL_NODE_EXPRESSIONS = `Tool nodes (types ending in "Tool") support $fromAI expressions:
|
|
85
|
-
- "Set sendTo to ={{ $fromAI('to') }}"
|
|
86
|
-
- "Set subject to ={{ $fromAI('subject') }}"
|
|
87
|
-
- "Set message to ={{ $fromAI('message_html') }}"
|
|
88
|
-
- "Set timeMin to ={{ $fromAI('After', '', 'string') }}"
|
|
89
|
-
|
|
90
|
-
$fromAI syntax: ={{ $fromAI('key', 'description', 'type', defaultValue) }}
|
|
91
|
-
- ONLY use in tool nodes (check node type ends with "Tool")
|
|
92
|
-
- Use for dynamic values that AI determines at runtime
|
|
93
|
-
- For regular nodes, use static values or standard expressions`;
|
|
94
|
-
const CRITICAL_PARAMETERS = `- HTTP Request: URL, method, headers (if auth needed)
|
|
95
|
-
- Set node: Fields to set with values
|
|
96
|
-
- Code node: The actual code to execute
|
|
97
|
-
- IF node: Conditions to check
|
|
98
|
-
- Switch node: Configure rules.values[] with conditions for each output branch (uses same filter structure as IF node)
|
|
99
|
-
- Document Loader: dataType parameter ('binary' for files like PDF, 'json' for JSON data)
|
|
100
|
-
- AI nodes: Prompts, models, configurations
|
|
101
|
-
- Tool nodes: Use $fromAI for dynamic recipient/subject/message fields`;
|
|
102
|
-
const DATA_TABLE_CONFIGURATION = `DATA TABLE NODE CONFIGURATION:
|
|
103
|
-
When configuring Data Table nodes (n8n-nodes-base.dataTable):
|
|
104
|
-
|
|
105
|
-
**For Row Column Operations (${dataTableColumnOperationsList}):**
|
|
106
|
-
- There MUST be a Set node (n8n-nodes-base.set) immediately before the Data Table node
|
|
107
|
-
- Configure the Set node with all the fields the user wants to store
|
|
108
|
-
- Use a PLACEHOLDER for dataTableId (e.g., "<__PLACEHOLDER_VALUE__data_table_name__>")
|
|
109
|
-
- Use columns.mappingMode: "autoMapInputData" (this maps columns from the preceding Set node)
|
|
110
|
-
- Example: "Set dataTableId to placeholder <__PLACEHOLDER_VALUE__my_table__>, set columns mapping mode to autoMapInputData"
|
|
111
|
-
|
|
112
|
-
**For Row Read Operations (get, getAll, delete):**
|
|
113
|
-
- No Set node is required before the Data Table node
|
|
114
|
-
- Still use a PLACEHOLDER for dataTableId
|
|
115
|
-
- Configure any filter or query parameters as needed
|
|
116
|
-
|
|
117
|
-
WHY: Data Tables must be created manually by the user. Using a placeholder ensures users know to create and select their table. For column operations, the Set node defines what columns to create.`;
|
|
118
|
-
const DEFAULT_VALUES_GUIDE = `PRINCIPLE: User requests ALWAYS take precedence. When user specifies a model, parameter, or value - use exactly what they requested.
|
|
119
|
-
|
|
120
|
-
SAFE DEFAULTS - Trust these unless user specifies otherwise:
|
|
121
|
-
- Chat Model nodes (lmChat*): Model defaults are maintained and current by n8n. Only set model parameter when user requests a specific model.
|
|
122
|
-
- Embedding nodes (embeddings*): Model defaults are maintained and current by n8n. Only set model parameter when user requests a specific model.
|
|
123
|
-
- LLM parameters (temperature, topP, maxTokens): Node defaults are sensible. Only configure when user explicitly requests specific values.
|
|
124
|
-
|
|
125
|
-
UNSAFE DEFAULTS - Always set based on workflow context:
|
|
126
|
-
- Document Loader dataType: Defaults to 'json' but MUST be 'binary' when processing files (PDF, DOCX, images, etc.)
|
|
127
|
-
- HTTP Request method: Defaults to GET. Set the request method based on API requirements.
|
|
128
|
-
- Vector Store mode: Context-dependent. Set explicitly: 'insert' for storing documents, 'retrieve' for querying, 'retrieve-as-tool' when used with AI Agent`;
|
|
129
|
-
const SWITCH_NODE_CONFIGURATION = `Switch nodes require configuring rules.values[] array - each entry creates one output:
|
|
130
|
-
|
|
131
|
-
Structure per rule:
|
|
132
|
-
{{
|
|
133
|
-
"conditions": {{
|
|
134
|
-
"options": {{ "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }},
|
|
135
|
-
"conditions": [
|
|
136
|
-
{{
|
|
137
|
-
"leftValue": "={{{{ $json.fieldName }}}}",
|
|
138
|
-
"rightValue": <value>,
|
|
139
|
-
"operator": {{ "type": "number|string", "operation": "lt|gt|equals|etc" }}
|
|
140
|
-
}}
|
|
141
|
-
],
|
|
142
|
-
"combinator": "and"
|
|
143
|
-
}},
|
|
144
|
-
"renameOutput": true,
|
|
145
|
-
"outputKey": "Descriptive Label"
|
|
146
|
-
}}
|
|
147
|
-
|
|
148
|
-
For numeric ranges (e.g., $100-$1000):
|
|
149
|
-
- Use TWO conditions with combinator: "and"
|
|
150
|
-
- First: gte (greater than or equal)
|
|
151
|
-
- Second: lte (less than or equal)
|
|
152
|
-
|
|
153
|
-
Always set renameOutput: true and provide descriptive outputKey labels.`;
|
|
154
|
-
const WEBHOOK_CONFIGURATION = node_guidance_1.webhook.configuration;
|
|
155
|
-
const RESOURCE_LOCATOR_CONFIGURATION = `RESOURCE LOCATOR PARAMETERS:
|
|
156
|
-
Some node parameters use "resource locator" type. This allows user to select from dynamic lists (calendars, documents, boards, channels, etc.).
|
|
157
|
-
These parameters have a specific structure in the node configuration:
|
|
158
|
-
{{
|
|
159
|
-
"__rl": true,
|
|
160
|
-
"mode": "list",
|
|
161
|
-
"value": "<selected_id>",
|
|
162
|
-
"cachedResultName: "<display_name>"
|
|
163
|
-
}}
|
|
164
|
-
|
|
165
|
-
REQUIRED PROCESS for resource locator parameters:
|
|
166
|
-
1. BEFORE configuring any parameter with "__rl": true, call get_resource_locator_options
|
|
167
|
-
- Provide the nodeId and parameterPath (e.g., "documentId", "calendarId", "boardId")
|
|
168
|
-
- The tool returns available options with display names and IDs
|
|
169
|
-
2. If the user specifies which resource they want, match it to the options and use the correct ID
|
|
170
|
-
3. USE BOTH the display name and the ID when updating the parameter:
|
|
171
|
-
- Format: "Document Name (ID: 1abc...xyz)"
|
|
172
|
-
4. ONLY use values returned by get_resource_locator_options - NEVER assume available options, NEVER guess or hallucinate IDs
|
|
173
|
-
|
|
174
|
-
Example:
|
|
175
|
-
- User says "use the Q4 Report document"
|
|
176
|
-
- Call get_resource_locator_options for the documentId parameter
|
|
177
|
-
- Find "Q4 Report" in the results with ID "1mtaEwM07..."
|
|
178
|
-
- Configure the parameter with the correct ID value and display name
|
|
179
|
-
|
|
180
|
-
NEVER configure resource locator parameters without fetching a list of possible options using get_resource_locator_options
|
|
181
|
-
|
|
182
|
-
Run get_resource_locator_options for all resource locator parameters BEFORE configuring nodes IN PARALLEL to save time`;
|
|
183
|
-
const NODE_CONFIGURATION_EXAMPLES = `NODE CONFIGURATION EXAMPLES:
|
|
184
|
-
When configuring complex nodes, use get_node_configuration_examples to see real-world examples from community templates:
|
|
185
|
-
|
|
186
|
-
When to use:
|
|
187
|
-
- Before configuring nodes with complex parameters (HTTP Request, Code, IF, Switch)
|
|
188
|
-
- When you need to understand proper parameter structure for unfamiliar nodes
|
|
189
|
-
- When user requests a specific integration pattern
|
|
190
|
-
|
|
191
|
-
Usage:
|
|
192
|
-
- Call with nodeType: "n8n-nodes-base.httpRequest" (exact node type name)
|
|
193
|
-
- Optionally filter by nodeVersion if needed
|
|
194
|
-
- Examples show proven parameter configurations from community workflows
|
|
195
|
-
- Use as reference for proper parameter structure and values`;
|
|
196
|
-
const RESPONSE_FORMAT = `After validation passes, provide a concise summary:
|
|
197
|
-
- List any placeholders requiring user configuration (e.g., "URL placeholder needs actual endpoint")
|
|
198
|
-
- Note which nodes were configured and key settings applied
|
|
199
|
-
- Keep it brief - this output is used for coordination with other LLM agents, not displayed directly to users`;
|
|
200
|
-
const CREDENTIAL_SECURITY = `SECURITY: Never configure credentials or authentication secrets.
|
|
201
|
-
|
|
202
|
-
The AI Workflow Builder does NOT have access to credentials - they are configured separately by users in the frontend.
|
|
203
|
-
|
|
204
|
-
NEVER set these parameters:
|
|
205
|
-
- apiKey, token, password, secret, or any credential fields
|
|
206
|
-
- Placeholder values like "YOUR_API_KEY_HERE" or "sk-..."
|
|
207
|
-
- Authentication headers with actual secrets
|
|
208
|
-
|
|
209
|
-
Credentials are automatically handled by n8n's credential system when users configure the workflow after generation.`;
|
|
210
|
-
const RESTRICTIONS = `- Respond before calling validate_configuration
|
|
211
|
-
- Skip validation even if you think configuration is correct
|
|
212
|
-
- Add commentary between tool calls - execute tools silently
|
|
213
|
-
- Hallucinate or guess resource/operation values - only use values listed in DISCOVERY CONTEXT
|
|
214
|
-
- Configure credentials, API keys, tokens, or authentication secrets`;
|
|
215
|
-
exports.INSTANCE_URL_PROMPT = `
|
|
216
|
-
<instance_url>
|
|
217
|
-
The n8n instance base URL is: {instanceUrl}
|
|
218
|
-
|
|
219
|
-
This URL is essential for webhook nodes and chat triggers as it provides the base URL for:
|
|
220
|
-
- Webhook URLs that external services need to call
|
|
221
|
-
- Chat trigger URLs for conversational interfaces
|
|
222
|
-
- Any node that requires the full instance URL to generate proper callback URLs
|
|
223
|
-
|
|
224
|
-
When working with webhook or chat trigger nodes, use this URL as the base for constructing proper endpoint URLs.
|
|
225
|
-
</instance_url>
|
|
226
|
-
`;
|
|
227
|
-
function buildRecoveryModeContext(nodeCount, nodeNames) {
|
|
228
|
-
return ('=== CRITICAL: RECOVERY MODE ===\n\n' +
|
|
229
|
-
'WORKFLOW RECOVERY SCENARIO:\n' +
|
|
230
|
-
`The builder created ${nodeCount} node${nodeCount === 1 ? '' : 's'} (${nodeNames.join(', ')}) before hitting a recursion limit.\n\n` +
|
|
231
|
-
'REQUIRED ACTIONS - DO NOT SKIP:\n' +
|
|
232
|
-
'1. Call update_node_parameters for EVERY node listed above to ensure proper configuration\n' +
|
|
233
|
-
'2. Call validate_configuration to check for issues\n' +
|
|
234
|
-
'3. Scan the workflow for placeholders (format: <__PLACEHOLDER_VALUE__*__>) and missing credentials\n' +
|
|
235
|
-
'4. List ALL placeholders and missing credentials in your final response\n\n' +
|
|
236
|
-
'DO NOT respond with "workflow already exists" or "no changes needed". ' +
|
|
237
|
-
'You MUST use tools to analyze this recovered workflow.');
|
|
238
|
-
}
|
|
239
|
-
function buildConfiguratorPrompt() {
|
|
240
|
-
return (0, builder_1.prompt)()
|
|
241
|
-
.section('role', CONFIGURATOR_ROLE)
|
|
242
|
-
.section('mandatory_execution_sequence', EXECUTION_SEQUENCE)
|
|
243
|
-
.section('workflow_json_detection', WORKFLOW_JSON_DETECTION)
|
|
244
|
-
.section('parameter_configuration', PARAMETER_CONFIGURATION)
|
|
245
|
-
.section('resource_locator_configuration', RESOURCE_LOCATOR_CONFIGURATION)
|
|
246
|
-
.section('data_referencing', DATA_REFERENCING)
|
|
247
|
-
.section('expression_techniques', EXPRESSION_TECHNIQUES)
|
|
248
|
-
.section('tool_node_expressions', TOOL_NODE_EXPRESSIONS)
|
|
249
|
-
.section('critical_parameters', CRITICAL_PARAMETERS)
|
|
250
|
-
.section('data_table_configuration', DATA_TABLE_CONFIGURATION)
|
|
251
|
-
.section('default_values_guide', DEFAULT_VALUES_GUIDE)
|
|
252
|
-
.section('switch_node_configuration', SWITCH_NODE_CONFIGURATION)
|
|
253
|
-
.section('webhook_configuration', WEBHOOK_CONFIGURATION)
|
|
254
|
-
.section('node_configuration_examples', NODE_CONFIGURATION_EXAMPLES)
|
|
255
|
-
.section('credential_security', CREDENTIAL_SECURITY)
|
|
256
|
-
.section('response_format', RESPONSE_FORMAT)
|
|
257
|
-
.section('do_not', RESTRICTIONS)
|
|
258
|
-
.build();
|
|
259
|
-
}
|
|
260
|
-
//# sourceMappingURL=configurator.prompt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configurator.prompt.js","sourceRoot":"","sources":["../../../src/prompts/agents/configurator.prompt.ts"],"names":[],"mappings":";;;AA+PA,4DAaC;AAED,0DAoBC;AA3RD,mEAAsF;AAEtF,wCAAoC;AACpC,2DAAkD;AAElD,MAAM,6BAA6B,GAAG,6DAAwC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE1F,MAAM,iBAAiB,GACtB,6EAA6E,CAAC;AAE/E,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;uEAoB4C,CAAC;AAExE,MAAM,uBAAuB,GAAG;;iGAEiE,CAAC;AAElG,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;qFAaqD,CAAC;AAEtF,MAAM,gBAAgB,GAAG;;;;;;;;;;;8DAWqC,CAAC;AAE/D,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;8EAsBgD,CAAC;AAE/E,MAAM,qBAAqB,GAAG;;;;;;;;;+DASiC,CAAC;AAEhE,MAAM,mBAAmB,GAAG;;;;;;;uEAO2C,CAAC;AAExE,MAAM,wBAAwB,GAAG;;;+BAGF,6BAA6B;;;;;;;;;;;;oMAYwI,CAAC;AAErM,MAAM,oBAAoB,GAAG;;;;;;;;;;4JAU+H,CAAC;AAE7J,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;wEAwBsC,CAAC;AAEzE,MAAM,qBAAqB,GAAG,uBAAO,CAAC,aAAa,CAAC;AAEpD,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;uHA2BgF,CAAC;AAExH,MAAM,2BAA2B,GAAG;;;;;;;;;;;;6DAYyB,CAAC;AAE9D,MAAM,eAAe,GAAG;;;8G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