@n8n/ai-workflow-builder 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +88 -0
- package/LICENSE_EE.md +27 -0
- package/dist/ai-workflow-builder.service.d.ts +25 -0
- package/dist/ai-workflow-builder.service.js +308 -0
- package/dist/ai-workflow-builder.service.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -0
- package/dist/chains/connection-composer.d.ts +10 -0
- package/dist/chains/connection-composer.js +135 -0
- package/dist/chains/connection-composer.js.map +1 -0
- package/dist/chains/node-selector.d.ts +8 -0
- package/dist/chains/node-selector.js +90 -0
- package/dist/chains/node-selector.js.map +1 -0
- package/dist/chains/nodes-composer.d.ts +8 -0
- package/dist/chains/nodes-composer.js +451 -0
- package/dist/chains/nodes-composer.js.map +1 -0
- package/dist/chains/planner.d.ts +4 -0
- package/dist/chains/planner.js +87 -0
- package/dist/chains/planner.js.map +1 -0
- package/dist/chains/validator.d.ts +2 -0
- package/dist/chains/validator.js +67 -0
- package/dist/chains/validator.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +4 -0
- package/dist/interfaces.js +3 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/llm-config.d.ts +11 -0
- package/dist/llm-config.js +36 -0
- package/dist/llm-config.js.map +1 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/workflow-state.d.ts +11 -0
- package/dist/workflow-state.js +18 -0
- package/dist/workflow-state.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChatAnthropic } from '@langchain/anthropic';
|
|
2
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
3
|
+
type LLMConfig = {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export declare const o4mini: (config: LLMConfig) => ChatOpenAI<import("@langchain/openai").ChatOpenAICallOptions>;
|
|
9
|
+
export declare const gpt41mini: (config: LLMConfig) => ChatOpenAI<import("@langchain/openai").ChatOpenAICallOptions>;
|
|
10
|
+
export declare const anthropicClaude37Sonnet: (config: LLMConfig) => ChatAnthropic;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.anthropicClaude37Sonnet = exports.gpt41mini = exports.o4mini = void 0;
|
|
4
|
+
const anthropic_1 = require("@langchain/anthropic");
|
|
5
|
+
const openai_1 = require("@langchain/openai");
|
|
6
|
+
const o4mini = (config) => new openai_1.ChatOpenAI({
|
|
7
|
+
modelName: 'o4-mini-2025-04-16',
|
|
8
|
+
apiKey: config.apiKey,
|
|
9
|
+
configuration: {
|
|
10
|
+
baseURL: config.baseUrl,
|
|
11
|
+
defaultHeaders: config.headers,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
exports.o4mini = o4mini;
|
|
15
|
+
const gpt41mini = (config) => new openai_1.ChatOpenAI({
|
|
16
|
+
modelName: 'gpt-4.1-mini-2025-04-14',
|
|
17
|
+
apiKey: config.apiKey,
|
|
18
|
+
temperature: 0,
|
|
19
|
+
configuration: {
|
|
20
|
+
baseURL: config.baseUrl,
|
|
21
|
+
defaultHeaders: config.headers,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
exports.gpt41mini = gpt41mini;
|
|
25
|
+
const anthropicClaude37Sonnet = (config) => new anthropic_1.ChatAnthropic({
|
|
26
|
+
modelName: 'claude-3-7-sonnet-20250219',
|
|
27
|
+
apiKey: config.apiKey,
|
|
28
|
+
temperature: 0,
|
|
29
|
+
maxTokens: 16000,
|
|
30
|
+
anthropicApiUrl: config.baseUrl,
|
|
31
|
+
clientOptions: {
|
|
32
|
+
defaultHeaders: config.headers,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
exports.anthropicClaude37Sonnet = anthropicClaude37Sonnet;
|
|
36
|
+
//# sourceMappingURL=llm-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-config.js","sourceRoot":"","sources":["../src/llm-config.ts"],"names":[],"mappings":";;;AAAA,oDAAqD;AACrD,8CAA+C;AAQxC,MAAM,MAAM,GAAG,CAAC,MAAiB,EAAE,EAAE,CAC3C,IAAI,mBAAU,CAAC;IACd,SAAS,EAAE,oBAAoB;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,aAAa,EAAE;QACd,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,cAAc,EAAE,MAAM,CAAC,OAAO;KAC9B;CACD,CAAC,CAAC;AARS,QAAA,MAAM,UAQf;AAEG,MAAM,SAAS,GAAG,CAAC,MAAiB,EAAE,EAAE,CAC9C,IAAI,mBAAU,CAAC;IACd,SAAS,EAAE,yBAAyB;IACpC,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,WAAW,EAAE,CAAC;IACd,aAAa,EAAE;QACd,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,cAAc,EAAE,MAAM,CAAC,OAAO;KAC9B;CACD,CAAC,CAAC;AATS,QAAA,SAAS,aASlB;AAEG,MAAM,uBAAuB,GAAG,CAAC,MAAiB,EAAE,EAAE,CAC5D,IAAI,yBAAa,CAAC;IACjB,SAAS,EAAE,4BAA4B;IACvC,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,KAAK;IAChB,eAAe,EAAE,MAAM,CAAC,OAAO;IAC/B,aAAa,EAAE;QACd,cAAc,EAAE,MAAM,CAAC,OAAO;KAC9B;CACD,CAAC,CAAC;AAVS,QAAA,uBAAuB,2BAUhC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { IWorkflowBase } from 'n8n-workflow';
|
|
2
|
+
export type SimpleWorkflow = Pick<IWorkflowBase, 'nodes' | 'connections'>;
|
|
3
|
+
export interface CodeDiffMessage {
|
|
4
|
+
role: 'assistant';
|
|
5
|
+
type: 'code-diff';
|
|
6
|
+
description?: string;
|
|
7
|
+
codeDiff?: string;
|
|
8
|
+
suggestionId: string;
|
|
9
|
+
solution_count: number;
|
|
10
|
+
}
|
|
11
|
+
export interface QuickReplyOption {
|
|
12
|
+
text: string;
|
|
13
|
+
type: string;
|
|
14
|
+
isFeedback?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface AssistantChatMessage {
|
|
17
|
+
role: 'assistant';
|
|
18
|
+
type: 'message';
|
|
19
|
+
text: string;
|
|
20
|
+
step?: string;
|
|
21
|
+
codeSnippet?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AssistantSummaryMessage {
|
|
24
|
+
role: 'assistant';
|
|
25
|
+
type: 'summary';
|
|
26
|
+
title: string;
|
|
27
|
+
content: string;
|
|
28
|
+
}
|
|
29
|
+
export interface EndSessionMessage {
|
|
30
|
+
role: 'assistant';
|
|
31
|
+
type: 'event';
|
|
32
|
+
eventName: 'end-session';
|
|
33
|
+
}
|
|
34
|
+
export interface AgentChatMessage {
|
|
35
|
+
role: 'assistant';
|
|
36
|
+
type: 'agent-suggestion';
|
|
37
|
+
title: string;
|
|
38
|
+
text: string;
|
|
39
|
+
}
|
|
40
|
+
export interface AgentThinkingStep {
|
|
41
|
+
role: 'assistant';
|
|
42
|
+
type: 'intermediate-step';
|
|
43
|
+
text: string;
|
|
44
|
+
step: string;
|
|
45
|
+
}
|
|
46
|
+
export interface WorkflowStepMessage {
|
|
47
|
+
role: 'assistant';
|
|
48
|
+
type: 'workflow-step';
|
|
49
|
+
steps: string[];
|
|
50
|
+
id: string;
|
|
51
|
+
read: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface WorkflowNodeMessage {
|
|
54
|
+
role: 'assistant';
|
|
55
|
+
type: 'workflow-node';
|
|
56
|
+
nodes: string[];
|
|
57
|
+
id: string;
|
|
58
|
+
read: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface WorkflowComposedMessage {
|
|
61
|
+
role: 'assistant';
|
|
62
|
+
type: 'workflow-composed';
|
|
63
|
+
nodes: Array<{
|
|
64
|
+
parameters: Record<string, unknown>;
|
|
65
|
+
type: string;
|
|
66
|
+
name: string;
|
|
67
|
+
position: [number, number];
|
|
68
|
+
}>;
|
|
69
|
+
id: string;
|
|
70
|
+
read: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface WorkflowConnectionsMessage {
|
|
73
|
+
role: 'assistant';
|
|
74
|
+
type: 'workflow-connections';
|
|
75
|
+
workflowJSON: SimpleWorkflow;
|
|
76
|
+
id: string;
|
|
77
|
+
read: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface PromptValidationMessage {
|
|
80
|
+
role: 'assistant';
|
|
81
|
+
type: 'prompt-validation';
|
|
82
|
+
isWorkflowPrompt: boolean;
|
|
83
|
+
id: string;
|
|
84
|
+
}
|
|
85
|
+
export type MessageResponse = ((AssistantChatMessage | CodeDiffMessage | AssistantSummaryMessage | AgentChatMessage | AgentThinkingStep | WorkflowStepMessage | WorkflowNodeMessage | WorkflowComposedMessage | WorkflowConnectionsMessage | PromptValidationMessage) & {
|
|
86
|
+
quickReplies?: QuickReplyOption[];
|
|
87
|
+
}) | EndSessionMessage;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { SimpleWorkflow } from './types';
|
|
3
|
+
export declare const WorkflowState: import("@langchain/langgraph")._INTERNAL_ANNOTATION_ROOT<{
|
|
4
|
+
messages: import("@langchain/langgraph").BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
|
|
5
|
+
prompt: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
6
|
+
steps: import("@langchain/langgraph").BinaryOperatorAggregate<string[], string[]>;
|
|
7
|
+
nodes: import("@langchain/langgraph").BinaryOperatorAggregate<string[], string[]>;
|
|
8
|
+
workflowJSON: import("@langchain/langgraph").BinaryOperatorAggregate<SimpleWorkflow, SimpleWorkflow>;
|
|
9
|
+
isWorkflowPrompt: import("@langchain/langgraph").BinaryOperatorAggregate<boolean, boolean>;
|
|
10
|
+
next: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowState = void 0;
|
|
4
|
+
const langgraph_1 = require("@langchain/langgraph");
|
|
5
|
+
exports.WorkflowState = langgraph_1.Annotation.Root({
|
|
6
|
+
messages: (0, langgraph_1.Annotation)({
|
|
7
|
+
reducer: (x, y) => x.concat(y),
|
|
8
|
+
}),
|
|
9
|
+
prompt: (0, langgraph_1.Annotation)({ reducer: (x, y) => y ?? x ?? '' }),
|
|
10
|
+
steps: (0, langgraph_1.Annotation)({ reducer: (x, y) => y ?? x ?? [] }),
|
|
11
|
+
nodes: (0, langgraph_1.Annotation)({ reducer: (x, y) => y ?? x ?? [] }),
|
|
12
|
+
workflowJSON: (0, langgraph_1.Annotation)({
|
|
13
|
+
reducer: (x, y) => y ?? x ?? { nodes: [], connections: {} },
|
|
14
|
+
}),
|
|
15
|
+
isWorkflowPrompt: (0, langgraph_1.Annotation)({ reducer: (x, y) => y ?? x ?? false }),
|
|
16
|
+
next: (0, langgraph_1.Annotation)({ reducer: (x, y) => y ?? x ?? langgraph_1.END, default: () => langgraph_1.END }),
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=workflow-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-state.js","sourceRoot":"","sources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 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@n8n/ai-workflow-builder",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "src/index.ts",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*",
|
|
9
|
+
"LICENSE.md",
|
|
10
|
+
"LICENSE_EE.md"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
|
+
"import": "./src/index.ts",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@langchain/anthropic": "0.3.11",
|
|
21
|
+
"@langchain/core": "0.3.30",
|
|
22
|
+
"@langchain/langgraph": "0.2.45",
|
|
23
|
+
"@langchain/openai": "0.3.17",
|
|
24
|
+
"@n8n_io/ai-assistant-sdk": "1.14.0",
|
|
25
|
+
"zod": "3.24.1",
|
|
26
|
+
"@n8n/di": "0.5.0",
|
|
27
|
+
"n8n-workflow": "1.89.0",
|
|
28
|
+
"@n8n/config": "1.38.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@n8n/typescript-config": "1.2.0"
|
|
32
|
+
},
|
|
33
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
34
|
+
"homepage": "https://n8n.io",
|
|
35
|
+
"author": {
|
|
36
|
+
"name": "Jan Oberhauser",
|
|
37
|
+
"email": "jan@n8n.io"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/n8n-io/n8n.git"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"clean": "rimraf dist .turbo",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"build": "tsc -p ./tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
47
|
+
"format": "biome format --write src",
|
|
48
|
+
"format:check": "biome ci src",
|
|
49
|
+
"test": "jest",
|
|
50
|
+
"test:watch": "jest --watch",
|
|
51
|
+
"lint": "eslint . --quiet",
|
|
52
|
+
"lintfix": "eslint . --fix",
|
|
53
|
+
"watch": "tsc-watch -p tsconfig.build.json --onCompilationComplete \"tsc-alias -p tsconfig.build.json\""
|
|
54
|
+
}
|
|
55
|
+
}
|