@n8n/node-cli 0.20.0 → 0.21.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/build.tsbuildinfo +1 -1
- package/dist/commands/new/index.js +30 -1
- package/dist/commands/new/index.js.map +1 -1
- package/dist/commands/new/prompts.d.ts +2 -0
- package/dist/commands/new/prompts.js +46 -2
- package/dist/commands/new/prompts.js.map +1 -1
- package/dist/template/templates/index.d.ts +4 -0
- package/dist/template/templates/index.js +10 -2
- package/dist/template/templates/index.js.map +1 -1
- package/dist/template/templates/index.ts +8 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template/README.md +46 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template/nodes/ExampleChatMemory/ExampleChatMemory.node.json +18 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template/nodes/ExampleChatMemory/ExampleChatMemory.node.ts +84 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template/nodes/ExampleChatMemory/example.dark.svg +13 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template/nodes/ExampleChatMemory/example.svg +13 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template/nodes/ExampleChatMemory/memory.ts +29 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template/package.json +50 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template/tsconfig.json +25 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template.d.ts +1 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template.js +14 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template.js.map +1 -0
- package/dist/template/templates/programmatic/ai/memory-custom/template.ts +9 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/README.md +46 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/credentials/ExampleApi.credentials.ts +54 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/icons/example.dark.svg +13 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/icons/example.svg +13 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/nodes/ExampleChatModel/ExampleChatModel.node.json +18 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/nodes/ExampleChatModel/ExampleChatModel.node.ts +113 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/nodes/ExampleChatModel/model.ts +115 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/package.json +52 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template/tsconfig.json +25 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template.d.ts +1 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template.js +14 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template.js.map +1 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom/template.ts +9 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/README.md +46 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/credentials/ExampleApi.credentials.ts +52 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/icons/example.dark.svg +13 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/icons/example.svg +13 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/nodes/ExampleChatModel/ExampleChatModel.node.json +18 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/nodes/ExampleChatModel/ExampleChatModel.node.ts +114 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/nodes/ExampleChatModel/common.ts +43 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/nodes/ExampleChatModel/model.ts +534 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/nodes/ExampleChatModel/properties.ts +130 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/package.json +52 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template/tsconfig.json +25 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template.d.ts +1 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template.js +14 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template.js.map +1 -0
- package/dist/template/templates/programmatic/ai/model-ai-custom-example/template.ts +9 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template/README.md +46 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template/credentials/ExampleApi.credentials.ts +52 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template/icons/example.dark.svg +13 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template/icons/example.svg +13 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template/nodes/ExampleChatModel/ExampleChatModel.node.json +18 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template/nodes/ExampleChatModel/ExampleChatModel.node.ts +84 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template/package.json +52 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template/tsconfig.json +25 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template.d.ts +1 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template.js +14 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template.js.map +1 -0
- package/dist/template/templates/programmatic/ai/model-openai-compatible/template.ts +9 -0
- package/dist/template/templates/programmatic/example/template/nodes/Example/Example.node.ts +1 -1
- package/package.json +5 -4
|
@@ -54,6 +54,27 @@ class New extends core_1.Command {
|
|
|
54
54
|
const chosenTemplate = await (0, prompts_2.declarativeTemplatePrompt)();
|
|
55
55
|
template = (0, templates_1.getTemplate)('declarative', chosenTemplate);
|
|
56
56
|
}
|
|
57
|
+
else if (type === 'programmatic') {
|
|
58
|
+
const programmaticNodeType = await (0, prompts_2.programmaticNodeTypePrompt)();
|
|
59
|
+
if (programmaticNodeType === 'basic') {
|
|
60
|
+
template = templates_1.templates.programmatic.example;
|
|
61
|
+
}
|
|
62
|
+
else if (programmaticNodeType === 'chatModel') {
|
|
63
|
+
const chatModelType = await (0, prompts_2.chatModelTypePrompt)();
|
|
64
|
+
if (chatModelType === 'openaiCompatible') {
|
|
65
|
+
template = templates_1.templates.programmatic.openaiChatModel;
|
|
66
|
+
}
|
|
67
|
+
else if (chatModelType === 'custom') {
|
|
68
|
+
template = templates_1.templates.programmatic.customChatModel;
|
|
69
|
+
}
|
|
70
|
+
else if (chatModelType === 'customExample') {
|
|
71
|
+
template = templates_1.templates.programmatic.customChatModelExample;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (programmaticNodeType === 'chatMemory') {
|
|
75
|
+
template = templates_1.templates.programmatic.customChatMemory;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
57
78
|
const config = (await template.prompts?.()) ?? {};
|
|
58
79
|
const packageManager = (await (0, package_manager_1.detectPackageManager)()) ?? 'npm';
|
|
59
80
|
const templateData = {
|
|
@@ -134,7 +155,15 @@ New.flags = {
|
|
|
134
155
|
}),
|
|
135
156
|
'skip-install': core_1.Flags.boolean({ description: 'Skip installing dependencies' }),
|
|
136
157
|
template: core_1.Flags.string({
|
|
137
|
-
options: [
|
|
158
|
+
options: [
|
|
159
|
+
'declarative/github-issues',
|
|
160
|
+
'declarative/custom',
|
|
161
|
+
'programmatic/example',
|
|
162
|
+
'programmatic/openai-chat-model',
|
|
163
|
+
'programmatic/custom-chat-model',
|
|
164
|
+
'programmatic/custom-chat-model-example',
|
|
165
|
+
'programmatic/custom-chat-memory',
|
|
166
|
+
],
|
|
138
167
|
}),
|
|
139
168
|
};
|
|
140
169
|
exports.default = New;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/new/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAqF;AACrF,sCAAmD;AACnD,6CAAwC;AACxC,gEAAkC;AAClC,0DAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/new/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAqF;AACrF,sCAAmD;AACnD,6CAAwC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AK,CAAC,IAAI,IAAI,SAAS,CACvB,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;gBAC/B,CAAC;qBAAM,CAAC;oBACP,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC;YAED,iBAAiB,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAClD,CAAC;QAED,IAAA,cAAI,EACH,QAAQ,QAAQ,OAAO,cAAc;;0EAEkC,IAAI;uCACvC,EACpC,YAAY,CACZ,CAAC;QAEF,IAAA,eAAK,EAAC,aAAa,QAAQ,IAAI,CAAC,CAAC;IAClC,CAAC;;AArKe,eAAW,GAAG,oDAAoD,CAAC;AACnE,YAAQ,GAAG;IAC1B,qCAAqC;IACrC,qEAAqE;IACrE,8DAA8D;IAC9D,oFAAoF;CACpF,CAAC;AACc,QAAI,GAAG;IACtB,IAAI,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;CACnC,CAAC;AACc,SAAK,GAAG;IACvB,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC;QACpB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,mDAAmD;KAChE,CAAC;IACF,cAAc,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC9E,QAAQ,EAAE,YAAK,CAAC,MAAM,CAAC;QACtB,OAAO,EAAE;YACR,2BAA2B;YAC3B,oBAAoB;YACpB,sBAAsB;YACtB,gCAAgC;YAChC,gCAAgC;YAChC,wCAAwC;YACxC,iCAAiC;SACxB;KACV,CAAC;CACF,CAAC;kBA5BkB,GAAG"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const nodeNamePrompt: () => Promise<string>;
|
|
2
2
|
export declare const nodeTypePrompt: () => Promise<"declarative" | "programmatic">;
|
|
3
3
|
export declare const declarativeTemplatePrompt: () => Promise<"custom" | "githubIssues">;
|
|
4
|
+
export declare const programmaticNodeTypePrompt: () => Promise<"basic" | "chatModel" | "chatMemory">;
|
|
5
|
+
export declare const chatModelTypePrompt: () => Promise<"custom" | "openaiCompatible" | "customExample">;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.declarativeTemplatePrompt = exports.nodeTypePrompt = exports.nodeNamePrompt = void 0;
|
|
3
|
+
exports.chatModelTypePrompt = exports.programmaticNodeTypePrompt = exports.declarativeTemplatePrompt = exports.nodeTypePrompt = exports.nodeNamePrompt = void 0;
|
|
4
4
|
const prompts_1 = require("@clack/prompts");
|
|
5
5
|
const templates_1 = require("../../template/templates");
|
|
6
6
|
const prompts_2 = require("../../utils/prompts");
|
|
@@ -21,7 +21,7 @@ const nodeTypePrompt = async () => await (0, prompts_2.withCancelHandler)((0, pr
|
|
|
21
21
|
hint: 'Low-code, faster approval for n8n Cloud',
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
label: '
|
|
24
|
+
label: 'Programmatic',
|
|
25
25
|
value: 'programmatic',
|
|
26
26
|
hint: 'Programmatic node with full flexibility',
|
|
27
27
|
},
|
|
@@ -39,4 +39,48 @@ const declarativeTemplatePrompt = async () => await (0, prompts_2.withCancelHand
|
|
|
39
39
|
initialValue: 'githubIssues',
|
|
40
40
|
}));
|
|
41
41
|
exports.declarativeTemplatePrompt = declarativeTemplatePrompt;
|
|
42
|
+
const programmaticNodeTypePrompt = async () => await (0, prompts_2.withCancelHandler)((0, prompts_1.select)({
|
|
43
|
+
message: 'What type of programmatic node are you building?',
|
|
44
|
+
options: [
|
|
45
|
+
{
|
|
46
|
+
label: 'Basic',
|
|
47
|
+
value: 'basic',
|
|
48
|
+
hint: 'Standard programmatic node',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: 'Chat Model (preview)',
|
|
52
|
+
value: 'chatModel',
|
|
53
|
+
hint: 'AI chat model node',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: 'Chat Memory (preview)',
|
|
57
|
+
value: 'chatMemory',
|
|
58
|
+
hint: 'AI chat memory node',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
initialValue: 'basic',
|
|
62
|
+
}));
|
|
63
|
+
exports.programmaticNodeTypePrompt = programmaticNodeTypePrompt;
|
|
64
|
+
const chatModelTypePrompt = async () => await (0, prompts_2.withCancelHandler)((0, prompts_1.select)({
|
|
65
|
+
message: 'What type of chat model?',
|
|
66
|
+
options: [
|
|
67
|
+
{
|
|
68
|
+
label: 'OpenAI compatible',
|
|
69
|
+
value: 'openaiCompatible',
|
|
70
|
+
hint: 'Chat model for OpenAI-compatible providers',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: 'Custom',
|
|
74
|
+
value: 'custom',
|
|
75
|
+
hint: 'Custom chat model implementation',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
label: 'Custom Example',
|
|
79
|
+
value: 'customExample',
|
|
80
|
+
hint: 'OpenAI chat model example implementation',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
initialValue: 'openaiCompatible',
|
|
84
|
+
}));
|
|
85
|
+
exports.chatModelTypePrompt = chatModelTypePrompt;
|
|
42
86
|
//# sourceMappingURL=prompts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/commands/new/prompts.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAE9C,wDAAqD;AACrD,iDAAwD;AACxD,uDAA0D;AAEnD,MAAM,cAAc,GAAG,KAAK,IAAI,EAAE,CACxC,MAAM,IAAA,2BAAiB,EACtB,IAAA,cAAI,EAAC;IACJ,OAAO,EAAE,kEAAkE;IAC3E,WAAW,EAAE,kBAAkB;IAC/B,QAAQ,EAAE,6BAAgB;IAC1B,YAAY,EAAE,kBAAkB;CAChC,CAAC,CACF,CAAC;AARU,QAAA,c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AvBU,QAAA,mBAAmB,uBAuB7B"}
|
|
@@ -5,6 +5,10 @@ export declare const templates: {
|
|
|
5
5
|
};
|
|
6
6
|
readonly programmatic: {
|
|
7
7
|
readonly example: import("../core").TemplateWithRun<object>;
|
|
8
|
+
readonly openaiChatModel: import("../core").TemplateWithRun<object>;
|
|
9
|
+
readonly customChatModel: import("../core").TemplateWithRun<object>;
|
|
10
|
+
readonly customChatMemory: import("../core").TemplateWithRun<object>;
|
|
11
|
+
readonly customChatModelExample: import("../core").TemplateWithRun<object>;
|
|
8
12
|
};
|
|
9
13
|
};
|
|
10
14
|
export type TemplateMap = typeof templates;
|
|
@@ -6,14 +6,22 @@ exports.isTemplateType = isTemplateType;
|
|
|
6
6
|
exports.isTemplateName = isTemplateName;
|
|
7
7
|
const template_1 = require("./declarative/custom/template");
|
|
8
8
|
const template_2 = require("./declarative/github-issues/template");
|
|
9
|
-
const template_3 = require("./programmatic/
|
|
9
|
+
const template_3 = require("./programmatic/ai/memory-custom/template");
|
|
10
|
+
const template_4 = require("./programmatic/ai/model-ai-custom/template");
|
|
11
|
+
const template_5 = require("./programmatic/ai/model-ai-custom-example/template");
|
|
12
|
+
const template_6 = require("./programmatic/ai/model-openai-compatible/template");
|
|
13
|
+
const template_7 = require("./programmatic/example/template");
|
|
10
14
|
exports.templates = {
|
|
11
15
|
declarative: {
|
|
12
16
|
githubIssues: template_2.githubIssuesTemplate,
|
|
13
17
|
custom: template_1.customTemplate,
|
|
14
18
|
},
|
|
15
19
|
programmatic: {
|
|
16
|
-
example:
|
|
20
|
+
example: template_7.exampleTemplate,
|
|
21
|
+
openaiChatModel: template_6.openaiChatModelTemplate,
|
|
22
|
+
customChatModel: template_4.customChatModelTemplate,
|
|
23
|
+
customChatMemory: template_3.customMemoryTemplate,
|
|
24
|
+
customChatModelExample: template_5.customChatModelExampleTemplate,
|
|
17
25
|
},
|
|
18
26
|
};
|
|
19
27
|
function getTemplate(type, name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/template/templates/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/template/templates/index.ts"],"names":[],"mappings":";;;AA0BA,kCAKC;AAED,wCAEC;AAED,wCAKC;AA1CD,4DAA+D;AAC/D,mEAA4E;AAC5E,uEAAgF;AAChF,yEAAqF;AACrF,iFAAoG;AACpG,iFAA6F;AAC7F,8DAAkE;AAErD,QAAA,SAAS,GAAG;IACxB,WAAW,EAAE;QACZ,YAAY,EAAE,+BAAoB;QAClC,MAAM,EAAE,yBAAc;KACtB;IACD,YAAY,EAAE;QACb,OAAO,EAAE,0BAAe;QACxB,eAAe,EAAE,kCAAuB;QACxC,eAAe,EAAE,kCAAuB;QACxC,gBAAgB,EAAE,+BAAoB;QACtC,sBAAsB,EAAE,yCAA8B;KACtD;CACQ,CAAC;AAMX,SAAgB,WAAW,CAC1B,IAAO,EACP,IAAO;IAEP,OAAO,iBAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,SAAgB,cAAc,CAAC,GAAY;IAC1C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,iBAAS,CAAC;AACpD,CAAC;AAED,SAAgB,cAAc,CAC7B,IAAO,EACP,IAAa;IAEb,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,iBAAS,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { customTemplate } from './declarative/custom/template';
|
|
2
2
|
import { githubIssuesTemplate } from './declarative/github-issues/template';
|
|
3
|
+
import { customMemoryTemplate } from './programmatic/ai/memory-custom/template';
|
|
4
|
+
import { customChatModelTemplate } from './programmatic/ai/model-ai-custom/template';
|
|
5
|
+
import { customChatModelExampleTemplate } from './programmatic/ai/model-ai-custom-example/template';
|
|
6
|
+
import { openaiChatModelTemplate } from './programmatic/ai/model-openai-compatible/template';
|
|
3
7
|
import { exampleTemplate } from './programmatic/example/template';
|
|
4
8
|
|
|
5
9
|
export const templates = {
|
|
@@ -9,6 +13,10 @@ export const templates = {
|
|
|
9
13
|
},
|
|
10
14
|
programmatic: {
|
|
11
15
|
example: exampleTemplate,
|
|
16
|
+
openaiChatModel: openaiChatModelTemplate,
|
|
17
|
+
customChatModel: customChatModelTemplate,
|
|
18
|
+
customChatMemory: customMemoryTemplate,
|
|
19
|
+
customChatModelExample: customChatModelExampleTemplate,
|
|
12
20
|
},
|
|
13
21
|
} as const;
|
|
14
22
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# {{nodePackageName}}
|
|
2
|
+
|
|
3
|
+
This is an n8n community node. It lets you use _app/service name_ in your n8n workflows.
|
|
4
|
+
|
|
5
|
+
_App/service name_ is _one or two sentences describing the service this node integrates with_.
|
|
6
|
+
|
|
7
|
+
[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/sustainable-use-license/) workflow automation platform.
|
|
8
|
+
|
|
9
|
+
[Installation](#installation)
|
|
10
|
+
[Operations](#operations)
|
|
11
|
+
[Credentials](#credentials)
|
|
12
|
+
[Compatibility](#compatibility)
|
|
13
|
+
[Usage](#usage)
|
|
14
|
+
[Resources](#resources)
|
|
15
|
+
[Version history](#version-history)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
|
|
20
|
+
|
|
21
|
+
## Operations
|
|
22
|
+
|
|
23
|
+
_List the operations supported by your node._
|
|
24
|
+
|
|
25
|
+
## Credentials
|
|
26
|
+
|
|
27
|
+
_If users need to authenticate with the app/service, provide details here. You should include prerequisites (such as signing up with the service), available authentication methods, and how to set them up._
|
|
28
|
+
|
|
29
|
+
## Compatibility
|
|
30
|
+
|
|
31
|
+
_State the minimum n8n version, as well as which versions you test against. You can also include any known version incompatibility issues._
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
_This is an optional section. Use it to help users with any difficult or confusing aspects of the node._
|
|
36
|
+
|
|
37
|
+
_By the time users are looking for community nodes, they probably already know n8n basics. But if you expect new users, you can link to the [Try it out](https://docs.n8n.io/try-it-out/) documentation to help them get started._
|
|
38
|
+
|
|
39
|
+
## Resources
|
|
40
|
+
|
|
41
|
+
* [n8n community nodes documentation](https://docs.n8n.io/integrations/#community-nodes)
|
|
42
|
+
* _Link to app/service documentation._
|
|
43
|
+
|
|
44
|
+
## Version history
|
|
45
|
+
|
|
46
|
+
_This is another optional section. If your node has multiple versions, include a short description of available versions and what changed, as well as any compatibility impact._
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "{{nodePackageName}}",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Development", "Developer Tools"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://github.com/org/repo?tab=readme-ov-file#credentials"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://github.com/org/repo?tab=readme-ov-file"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { INodeType, INodeTypeDescription, ISupplyDataFunctions } from 'n8n-workflow';
|
|
2
|
+
import { NodeConnectionTypes } from 'n8n-workflow';
|
|
3
|
+
import { supplyMemory, WindowedChatMemory } from '@n8n/ai-node-sdk';
|
|
4
|
+
import { InMemoryChatHistory } from './memory';
|
|
5
|
+
|
|
6
|
+
type MemoryOptions = {
|
|
7
|
+
windowSize?: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export class ExampleChatMemory implements INodeType {
|
|
11
|
+
description: INodeTypeDescription = {
|
|
12
|
+
displayName: 'Example Memory',
|
|
13
|
+
name: 'exampleChatMemory',
|
|
14
|
+
icon: { light: 'file:example.svg', dark: 'file:example.dark.svg' },
|
|
15
|
+
group: ['transform'],
|
|
16
|
+
version: [1],
|
|
17
|
+
description: 'Store conversation history in memory',
|
|
18
|
+
defaults: {
|
|
19
|
+
name: 'Example Memory',
|
|
20
|
+
},
|
|
21
|
+
codex: {
|
|
22
|
+
categories: ['assistant'],
|
|
23
|
+
subcategories: {
|
|
24
|
+
AI: ['Memory', 'Root Nodes'],
|
|
25
|
+
Memory: ['Other memories'],
|
|
26
|
+
},
|
|
27
|
+
resources: {
|
|
28
|
+
primaryDocumentation: [],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
inputs: [],
|
|
33
|
+
|
|
34
|
+
outputs: [NodeConnectionTypes.AiMemory],
|
|
35
|
+
outputNames: ['Memory'],
|
|
36
|
+
credentials: [],
|
|
37
|
+
properties: [
|
|
38
|
+
{
|
|
39
|
+
displayName: 'Session ID',
|
|
40
|
+
name: 'sessionId',
|
|
41
|
+
type: 'string',
|
|
42
|
+
default: '={{ $json.sessionId }}',
|
|
43
|
+
description: 'Unique identifier for the conversation session',
|
|
44
|
+
placeholder: 'user-123',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
displayName: 'Options',
|
|
48
|
+
name: 'options',
|
|
49
|
+
placeholder: 'Add Option',
|
|
50
|
+
description: 'Additional options for memory management',
|
|
51
|
+
type: 'collection',
|
|
52
|
+
default: {},
|
|
53
|
+
options: [
|
|
54
|
+
{
|
|
55
|
+
displayName: 'Window Size',
|
|
56
|
+
name: 'windowSize',
|
|
57
|
+
type: 'number',
|
|
58
|
+
default: 10,
|
|
59
|
+
description: 'Number of recent message pairs to keep in context',
|
|
60
|
+
typeOptions: {
|
|
61
|
+
minValue: 1,
|
|
62
|
+
maxValue: 100,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
async supplyData(this: ISupplyDataFunctions, itemIndex: number) {
|
|
71
|
+
const sessionId = this.getNodeParameter('sessionId', itemIndex) as string;
|
|
72
|
+
const options = this.getNodeParameter('options', itemIndex, {}) as MemoryOptions;
|
|
73
|
+
|
|
74
|
+
// Create the in-memory chat history storage
|
|
75
|
+
const history = new InMemoryChatHistory(sessionId);
|
|
76
|
+
|
|
77
|
+
// Wrap with windowed memory to limit context size
|
|
78
|
+
const memory = new WindowedChatMemory(history, {
|
|
79
|
+
windowSize: options.windowSize ?? 10,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return supplyMemory(this, memory);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="aquamarine"
|
|
2
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-cpu">
|
|
3
|
+
<rect x="4" y="4" width="16" height="16" rx="2" ry="2"></rect>
|
|
4
|
+
<rect x="9" y="9" width="6" height="6"></rect>
|
|
5
|
+
<line x1="9" y1="1" x2="9" y2="4"></line>
|
|
6
|
+
<line x1="15" y1="1" x2="15" y2="4"></line>
|
|
7
|
+
<line x1="9" y1="20" x2="9" y2="23"></line>
|
|
8
|
+
<line x1="15" y1="20" x2="15" y2="23"></line>
|
|
9
|
+
<line x1="20" y1="9" x2="23" y2="9"></line>
|
|
10
|
+
<line x1="20" y1="14" x2="23" y2="14"></line>
|
|
11
|
+
<line x1="1" y1="9" x2="4" y2="9"></line>
|
|
12
|
+
<line x1="1" y1="14" x2="4" y2="14"></line>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="darkblue"
|
|
2
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-cpu">
|
|
3
|
+
<rect x="4" y="4" width="16" height="16" rx="2" ry="2"></rect>
|
|
4
|
+
<rect x="9" y="9" width="6" height="6"></rect>
|
|
5
|
+
<line x1="9" y1="1" x2="9" y2="4"></line>
|
|
6
|
+
<line x1="15" y1="1" x2="15" y2="4"></line>
|
|
7
|
+
<line x1="9" y1="20" x2="9" y2="23"></line>
|
|
8
|
+
<line x1="15" y1="20" x2="15" y2="23"></line>
|
|
9
|
+
<line x1="20" y1="9" x2="23" y2="9"></line>
|
|
10
|
+
<line x1="20" y1="14" x2="23" y2="14"></line>
|
|
11
|
+
<line x1="1" y1="9" x2="4" y2="9"></line>
|
|
12
|
+
<line x1="1" y1="14" x2="4" y2="14"></line>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseChatHistory, Message } from '@n8n/ai-node-sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* In-memory chat history storage
|
|
5
|
+
* Stores conversation messages in memory by session ID
|
|
6
|
+
* DO NOT use this in production, in-memory storage is not persistent
|
|
7
|
+
*/
|
|
8
|
+
export class InMemoryChatHistory extends BaseChatHistory {
|
|
9
|
+
private static storage: Map<string, Message[]> = new Map();
|
|
10
|
+
|
|
11
|
+
constructor(private sessionId: string) {
|
|
12
|
+
super();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async getMessages(): Promise<Message[]> {
|
|
16
|
+
const messages = InMemoryChatHistory.storage.get(this.sessionId);
|
|
17
|
+
return messages ? [...messages] : [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async addMessage(message: Message): Promise<void> {
|
|
21
|
+
const messages = InMemoryChatHistory.storage.get(this.sessionId) || [];
|
|
22
|
+
messages.push(message);
|
|
23
|
+
InMemoryChatHistory.storage.set(this.sessionId, messages);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async clear(): Promise<void> {
|
|
27
|
+
InMemoryChatHistory.storage.delete(this.sessionId);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{nodePackageName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"n8n-community-node-package"
|
|
9
|
+
],
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "{{user.name}}",
|
|
12
|
+
"email": "{{user.email}}"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/<...>/n8n-nodes-<...>.git"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "n8n-node build",
|
|
20
|
+
"build:watch": "tsc --watch",
|
|
21
|
+
"dev": "n8n-node dev",
|
|
22
|
+
"lint": "n8n-node lint",
|
|
23
|
+
"lint:fix": "n8n-node lint --fix",
|
|
24
|
+
"release": "n8n-node release",
|
|
25
|
+
"prepublishOnly": "n8n-node prerelease"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"n8n": {
|
|
31
|
+
"n8nNodesApiVersion": 1,
|
|
32
|
+
"aiNodeSdkVersion": 1,
|
|
33
|
+
"strict": true,
|
|
34
|
+
"credentials": [],
|
|
35
|
+
"nodes": [
|
|
36
|
+
"dist/nodes/ExampleChatMemory/ExampleChatMemory.node.js"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@n8n/node-cli": "*",
|
|
41
|
+
"eslint": "9.32.0",
|
|
42
|
+
"prettier": "3.6.2",
|
|
43
|
+
"release-it": "^19.0.4",
|
|
44
|
+
"typescript": "5.9.2"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"n8n-workflow": "*",
|
|
48
|
+
"@n8n/ai-node-sdk": "*"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"target": "es2019",
|
|
7
|
+
"lib": ["es2019", "es2020", "es2022.error"],
|
|
8
|
+
"removeComments": true,
|
|
9
|
+
"useUnknownInCatchVariables": false,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"noImplicitAny": true,
|
|
12
|
+
"noImplicitReturns": true,
|
|
13
|
+
"noUnusedLocals": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"preserveConstEnums": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"incremental": true,
|
|
19
|
+
"declaration": true,
|
|
20
|
+
"sourceMap": true,
|
|
21
|
+
"skipLibCheck": true,
|
|
22
|
+
"outDir": "./dist/"
|
|
23
|
+
},
|
|
24
|
+
"include": ["credentials/**/*", "nodes/**/*", "nodes/**/*.json", "package.json"]
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const customMemoryTemplate: import("../../../../core").TemplateWithRun<object>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.customMemoryTemplate = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const core_1 = require("../../../../core");
|
|
9
|
+
exports.customMemoryTemplate = (0, core_1.createTemplate)({
|
|
10
|
+
name: 'Custom memory node',
|
|
11
|
+
description: 'Memory node with custom in-memory storage implementation',
|
|
12
|
+
path: node_path_1.default.join(__dirname, 'template'),
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../../src/template/templates/programmatic/ai/memory-custom/template.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAE7B,2CAAkD;AAErC,QAAA,oBAAoB,GAAG,IAAA,qBAAc,EAAC;IAClD,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,0DAA0D;IACvE,IAAI,EAAE,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;CACtC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { createTemplate } from '../../../../core';
|
|
4
|
+
|
|
5
|
+
export const customMemoryTemplate = createTemplate({
|
|
6
|
+
name: 'Custom memory node',
|
|
7
|
+
description: 'Memory node with custom in-memory storage implementation',
|
|
8
|
+
path: path.join(__dirname, 'template'),
|
|
9
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# {{nodePackageName}}
|
|
2
|
+
|
|
3
|
+
This is an n8n community node. It lets you use _app/service name_ in your n8n workflows.
|
|
4
|
+
|
|
5
|
+
_App/service name_ is _one or two sentences describing the service this node integrates with_.
|
|
6
|
+
|
|
7
|
+
[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/sustainable-use-license/) workflow automation platform.
|
|
8
|
+
|
|
9
|
+
[Installation](#installation)
|
|
10
|
+
[Operations](#operations)
|
|
11
|
+
[Credentials](#credentials)
|
|
12
|
+
[Compatibility](#compatibility)
|
|
13
|
+
[Usage](#usage)
|
|
14
|
+
[Resources](#resources)
|
|
15
|
+
[Version history](#version-history)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
|
|
20
|
+
|
|
21
|
+
## Operations
|
|
22
|
+
|
|
23
|
+
_List the operations supported by your node._
|
|
24
|
+
|
|
25
|
+
## Credentials
|
|
26
|
+
|
|
27
|
+
_If users need to authenticate with the app/service, provide details here. You should include prerequisites (such as signing up with the service), available authentication methods, and how to set them up._
|
|
28
|
+
|
|
29
|
+
## Compatibility
|
|
30
|
+
|
|
31
|
+
_State the minimum n8n version, as well as which versions you test against. You can also include any known version incompatibility issues._
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
_This is an optional section. Use it to help users with any difficult or confusing aspects of the node._
|
|
36
|
+
|
|
37
|
+
_By the time users are looking for community nodes, they probably already know n8n basics. But if you expect new users, you can link to the [Try it out](https://docs.n8n.io/try-it-out/) documentation to help them get started._
|
|
38
|
+
|
|
39
|
+
## Resources
|
|
40
|
+
|
|
41
|
+
* [n8n community nodes documentation](https://docs.n8n.io/integrations/#community-nodes)
|
|
42
|
+
* _Link to app/service documentation._
|
|
43
|
+
|
|
44
|
+
## Version history
|
|
45
|
+
|
|
46
|
+
_This is another optional section. If your node has multiple versions, include a short description of available versions and what changed, as well as any compatibility impact._
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ICredentialDataDecryptedObject,
|
|
3
|
+
ICredentialTestRequest,
|
|
4
|
+
ICredentialType,
|
|
5
|
+
IHttpRequestOptions,
|
|
6
|
+
INodeProperties,
|
|
7
|
+
Icon,
|
|
8
|
+
} from 'n8n-workflow';
|
|
9
|
+
|
|
10
|
+
export class ExampleApi implements ICredentialType {
|
|
11
|
+
name = 'exampleApi';
|
|
12
|
+
|
|
13
|
+
displayName = 'Example API';
|
|
14
|
+
|
|
15
|
+
documentationUrl = 'https://github.com/org/repo?tab=readme-ov-file#credentials';
|
|
16
|
+
|
|
17
|
+
icon: Icon = { light: 'file:../icons/example.svg', dark: 'file:../icons/example.dark.svg' };
|
|
18
|
+
|
|
19
|
+
properties: INodeProperties[] = [
|
|
20
|
+
{
|
|
21
|
+
displayName: 'API Key',
|
|
22
|
+
name: 'apiKey',
|
|
23
|
+
type: 'string',
|
|
24
|
+
typeOptions: { password: true },
|
|
25
|
+
required: true,
|
|
26
|
+
default: '',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Base URL',
|
|
30
|
+
name: 'url',
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: '',
|
|
33
|
+
description: 'Override the default base URL for the API',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
test: ICredentialTestRequest = {
|
|
38
|
+
request: {
|
|
39
|
+
baseURL: '={{$credentials?.url}}',
|
|
40
|
+
url: '/',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
async authenticate(
|
|
45
|
+
credentials: ICredentialDataDecryptedObject,
|
|
46
|
+
requestOptions: IHttpRequestOptions,
|
|
47
|
+
): Promise<IHttpRequestOptions> {
|
|
48
|
+
requestOptions.headers ??= {};
|
|
49
|
+
|
|
50
|
+
requestOptions.headers['Authorization'] = `Bearer ${credentials.apiKey}`;
|
|
51
|
+
|
|
52
|
+
return requestOptions;
|
|
53
|
+
}
|
|
54
|
+
}
|