n8n-nodes-github-copilot-agent-tool 0.1.1
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 +21 -0
- package/README.md +119 -0
- package/dist/credentials/GitHubCopilotApi.credentials.d.ts +10 -0
- package/dist/credentials/GitHubCopilotApi.credentials.js +69 -0
- package/dist/credentials/GitHubCopilotApi.credentials.js.map +1 -0
- package/dist/credentials/gitHubCopilotApi.svg +12 -0
- package/dist/nodes/GitHubCopilotAgentTool/GitHubCopilotAgentTool.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotAgentTool/GitHubCopilotAgentTool.node.js +196 -0
- package/dist/nodes/GitHubCopilotAgentTool/GitHubCopilotAgentTool.node.js.map +1 -0
- package/dist/nodes/GitHubCopilotAgentTool/GitHubCopilotAgentTool.node.json +16 -0
- package/dist/nodes/GitHubCopilotAgentTool/gitHubCopilotAgentTool.dark.svg +12 -0
- package/dist/nodes/GitHubCopilotAgentTool/gitHubCopilotAgentTool.svg +12 -0
- package/dist/nodes/GitHubCopilotAuthHelper/GitHubCopilotAuthHelper.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotAuthHelper/GitHubCopilotAuthHelper.node.js +194 -0
- package/dist/nodes/GitHubCopilotAuthHelper/GitHubCopilotAuthHelper.node.js.map +1 -0
- package/dist/nodes/GitHubCopilotAuthHelper/GitHubCopilotAuthHelper.node.json +13 -0
- package/dist/nodes/GitHubCopilotAuthHelper/gitHubCopilotAuthHelper.dark.svg +12 -0
- package/dist/nodes/GitHubCopilotAuthHelper/gitHubCopilotAuthHelper.svg +12 -0
- package/dist/nodes/GitHubCopilotChatApi/GitHubCopilotChatApi.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotChatApi/GitHubCopilotChatApi.node.js +181 -0
- package/dist/nodes/GitHubCopilotChatApi/GitHubCopilotChatApi.node.js.map +1 -0
- package/dist/nodes/GitHubCopilotChatApi/GitHubCopilotChatApi.node.json +13 -0
- package/dist/nodes/GitHubCopilotChatApi/gitHubCopilotChatApi.dark.svg +12 -0
- package/dist/nodes/GitHubCopilotChatApi/gitHubCopilotChatApi.svg +12 -0
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js +188 -0
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js.map +1 -0
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.json +16 -0
- package/dist/nodes/GitHubCopilotChatModel/gitHubCopilotChatModel.dark.svg +12 -0
- package/dist/nodes/GitHubCopilotChatModel/gitHubCopilotChatModel.svg +12 -0
- package/dist/nodes/GitHubCopilotCli/GitHubCopilotCli.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotCli/GitHubCopilotCli.node.js +159 -0
- package/dist/nodes/GitHubCopilotCli/GitHubCopilotCli.node.js.map +1 -0
- package/dist/nodes/GitHubCopilotCli/GitHubCopilotCli.node.json +13 -0
- package/dist/nodes/GitHubCopilotCli/gitHubCopilotCli.dark.svg +12 -0
- package/dist/nodes/GitHubCopilotCli/gitHubCopilotCli.svg +12 -0
- package/dist/nodes/GitHubCopilotEmbeddings/GitHubCopilotEmbeddings.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotEmbeddings/GitHubCopilotEmbeddings.node.js +133 -0
- package/dist/nodes/GitHubCopilotEmbeddings/GitHubCopilotEmbeddings.node.js.map +1 -0
- package/dist/nodes/GitHubCopilotEmbeddings/GitHubCopilotEmbeddings.node.json +16 -0
- package/dist/nodes/GitHubCopilotEmbeddings/gitHubCopilotEmbeddings.dark.svg +12 -0
- package/dist/nodes/GitHubCopilotEmbeddings/gitHubCopilotEmbeddings.svg +12 -0
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.json +13 -0
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAi.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAi.node.js +177 -0
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAi.node.js.map +1 -0
- package/dist/nodes/GitHubCopilotOpenAI/gitHubCopilotOpenAI.dark.svg +12 -0
- package/dist/nodes/GitHubCopilotOpenAI/gitHubCopilotOpenAI.svg +12 -0
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.js +173 -0
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.js.map +1 -0
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.json +13 -0
- package/dist/nodes/GitHubCopilotTest/gitHubCopilotTest.dark.svg +12 -0
- package/dist/nodes/GitHubCopilotTest/gitHubCopilotTest.svg +12 -0
- package/dist/nodes/shared/apiClient.d.ts +11 -0
- package/dist/nodes/shared/apiClient.js +98 -0
- package/dist/nodes/shared/apiClient.js.map +1 -0
- package/dist/nodes/shared/types.d.ts +144 -0
- package/dist/nodes/shared/types.js +44 -0
- package/dist/nodes/shared/types.js.map +1 -0
- package/dist/package.json +75 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
|
2
|
+
<circle cx="20" cy="20" r="19" fill="#24292e"/>
|
|
3
|
+
<ellipse cx="20" cy="18" rx="9" ry="8" fill="#f6f8fa"/>
|
|
4
|
+
<rect x="13" y="15" width="14" height="5.5" rx="2.75" fill="#24292e"/>
|
|
5
|
+
<circle cx="17" cy="17.75" r="1.6" fill="#f6f8fa"/>
|
|
6
|
+
<circle cx="23" cy="17.75" r="1.6" fill="#f6f8fa"/>
|
|
7
|
+
<circle cx="17" cy="17.75" r="0.75" fill="#58a6ff"/>
|
|
8
|
+
<circle cx="23" cy="17.75" r="0.75" fill="#58a6ff"/>
|
|
9
|
+
<rect x="18.5" y="25.5" width="3" height="4" rx="1.5" fill="#f6f8fa"/>
|
|
10
|
+
<circle cx="13" cy="18" r="1.5" fill="#f6f8fa"/>
|
|
11
|
+
<circle cx="27" cy="18" r="1.5" fill="#f6f8fa"/>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-github-copilot-agent-tool.gitHubCopilotOpenAI",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["AI", "Developer Tools"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"primaryDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://github.com/CyberLaboratory/n8n-github-copilot-ai-tool"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class GitHubCopilotOpenAI implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitHubCopilotOpenAI = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const apiClient_1 = require("../shared/apiClient");
|
|
6
|
+
const types_1 = require("../shared/types");
|
|
7
|
+
class GitHubCopilotOpenAI {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.description = {
|
|
10
|
+
displayName: 'GitHub Copilot OpenAI',
|
|
11
|
+
name: 'gitHubCopilotOpenAi',
|
|
12
|
+
icon: {
|
|
13
|
+
light: 'file:gitHubCopilotOpenAI.svg',
|
|
14
|
+
dark: 'file:gitHubCopilotOpenAI.dark.svg',
|
|
15
|
+
},
|
|
16
|
+
group: ['transform'],
|
|
17
|
+
version: 1,
|
|
18
|
+
subtitle: '={{ $parameter["model"] }}',
|
|
19
|
+
description: 'Full OpenAI-compatible chat completions interface with messaging and tools support via GitHub Copilot.',
|
|
20
|
+
defaults: { name: 'GitHub Copilot OpenAI' },
|
|
21
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
22
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
23
|
+
credentials: [{ name: 'gitHubCopilotApi', required: true }],
|
|
24
|
+
properties: [
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Model',
|
|
27
|
+
name: 'model',
|
|
28
|
+
type: 'options',
|
|
29
|
+
options: types_1.SUPPORTED_MODELS.map((m) => ({ name: m.name, value: m.value })),
|
|
30
|
+
default: 'gpt-4',
|
|
31
|
+
description: 'Model to use for chat completion',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Custom Model ID',
|
|
35
|
+
name: 'customModel',
|
|
36
|
+
type: 'string',
|
|
37
|
+
default: '',
|
|
38
|
+
description: 'Custom model identifier when "Custom (Specify Below)" is selected',
|
|
39
|
+
displayOptions: { show: { model: ['custom'] } },
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Messages (JSON)',
|
|
43
|
+
name: 'messages',
|
|
44
|
+
type: 'string',
|
|
45
|
+
typeOptions: { rows: 8 },
|
|
46
|
+
required: true,
|
|
47
|
+
default: '[{"role":"user","content":"Hello!"}]',
|
|
48
|
+
description: 'Messages as a JSON array in OpenAI format. Each item needs a "role" (system/user/assistant/tool) and "content".',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
displayName: 'Tools (JSON)',
|
|
52
|
+
name: 'tools',
|
|
53
|
+
type: 'string',
|
|
54
|
+
typeOptions: { rows: 6 },
|
|
55
|
+
default: '[]',
|
|
56
|
+
description: 'Tool definitions as a JSON array in OpenAI function-calling format. Leave empty to disable.',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Tool Choice',
|
|
60
|
+
name: 'toolChoice',
|
|
61
|
+
type: 'options',
|
|
62
|
+
options: [
|
|
63
|
+
{ name: 'Auto', value: 'auto' },
|
|
64
|
+
{ name: 'None', value: 'none' },
|
|
65
|
+
],
|
|
66
|
+
default: 'auto',
|
|
67
|
+
description: 'Whether the model may call tools automatically',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
displayName: 'Options',
|
|
71
|
+
name: 'options',
|
|
72
|
+
type: 'collection',
|
|
73
|
+
placeholder: 'Add Option',
|
|
74
|
+
default: {},
|
|
75
|
+
options: [
|
|
76
|
+
{
|
|
77
|
+
displayName: 'Temperature',
|
|
78
|
+
name: 'temperature',
|
|
79
|
+
type: 'number',
|
|
80
|
+
typeOptions: { minValue: 0, maxValue: 2, numberPrecision: 2 },
|
|
81
|
+
default: 1,
|
|
82
|
+
description: 'Sampling temperature',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
displayName: 'Max Tokens',
|
|
86
|
+
name: 'maxTokens',
|
|
87
|
+
type: 'number',
|
|
88
|
+
typeOptions: { minValue: 1 },
|
|
89
|
+
default: 2048,
|
|
90
|
+
description: 'Maximum tokens to generate',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
displayName: 'Top P',
|
|
94
|
+
name: 'topP',
|
|
95
|
+
type: 'number',
|
|
96
|
+
typeOptions: { minValue: 0, maxValue: 1, numberPrecision: 2 },
|
|
97
|
+
default: 1,
|
|
98
|
+
description: 'Nucleus sampling probability mass',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
displayName: 'N (Completions)',
|
|
102
|
+
name: 'n',
|
|
103
|
+
type: 'number',
|
|
104
|
+
typeOptions: { minValue: 1, maxValue: 10 },
|
|
105
|
+
default: 1,
|
|
106
|
+
description: 'Number of completions to generate',
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
usableAsTool: true,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async execute() {
|
|
115
|
+
const items = this.getInputData();
|
|
116
|
+
const returnData = [];
|
|
117
|
+
for (let i = 0; i < items.length; i++) {
|
|
118
|
+
const start = Date.now();
|
|
119
|
+
try {
|
|
120
|
+
const { authToken, baseUrl } = await (0, apiClient_1.getCredentials)(this, i);
|
|
121
|
+
const modelParam = this.getNodeParameter('model', i);
|
|
122
|
+
const customModel = this.getNodeParameter('customModel', i, '');
|
|
123
|
+
const model = modelParam === 'custom' ? customModel : modelParam;
|
|
124
|
+
const messagesRaw = this.getNodeParameter('messages', i);
|
|
125
|
+
const toolsRaw = this.getNodeParameter('tools', i, '[]');
|
|
126
|
+
const toolChoice = this.getNodeParameter('toolChoice', i, 'auto');
|
|
127
|
+
const options = this.getNodeParameter('options', i, {});
|
|
128
|
+
let messages;
|
|
129
|
+
try {
|
|
130
|
+
messages = JSON.parse(messagesRaw);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
throw new n8n_workflow_1.ApplicationError('Messages field is not valid JSON.');
|
|
134
|
+
}
|
|
135
|
+
let tools = [];
|
|
136
|
+
try {
|
|
137
|
+
tools = JSON.parse(toolsRaw);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
}
|
|
141
|
+
const completion = await (0, apiClient_1.chatCompletion)(this, authToken, baseUrl, {
|
|
142
|
+
model,
|
|
143
|
+
messages: messages,
|
|
144
|
+
temperature: options.temperature,
|
|
145
|
+
max_tokens: options.maxTokens,
|
|
146
|
+
top_p: options.topP,
|
|
147
|
+
n: options.n,
|
|
148
|
+
tools: tools.length > 0 ? tools : undefined,
|
|
149
|
+
tool_choice: tools.length > 0 ? toolChoice : undefined,
|
|
150
|
+
});
|
|
151
|
+
returnData.push({
|
|
152
|
+
json: {
|
|
153
|
+
id: completion.id,
|
|
154
|
+
model_used: completion.model,
|
|
155
|
+
choices: completion.choices,
|
|
156
|
+
usage: completion.usage,
|
|
157
|
+
latency_ms: Date.now() - start,
|
|
158
|
+
},
|
|
159
|
+
pairedItem: { item: i },
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (this.continueOnFail()) {
|
|
164
|
+
returnData.push({
|
|
165
|
+
json: (0, apiClient_1.normalizeError)(error, undefined, Date.now() - start),
|
|
166
|
+
pairedItem: { item: i },
|
|
167
|
+
});
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return [returnData];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.GitHubCopilotOpenAI = GitHubCopilotOpenAI;
|
|
177
|
+
//# sourceMappingURL=GitHubCopilotOpenAi.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubCopilotOpenAi.node.js","sourceRoot":"","sources":["../../../nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAi.node.ts"],"names":[],"mappings":";;;AAMA,+CAAqE;AAErE,mDAAqF;AACrF,2CAAmD;AAEnD,MAAa,mBAAmB;IAAhC;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,uBAAuB;YACpC,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE;gBACL,KAAK,EAAE,8BAA8B;gBACrC,IAAI,EAAE,mCAAmC;aACzC;YACD,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,4BAA4B;YACtC,WAAW,EACV,wGAAwG;YACzG,QAAQ,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE;YAC3C,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE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SAAS;gBACV,CAAC;gBAED,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AAzLD,kDAyLC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
|
2
|
+
<circle cx="20" cy="20" r="19" fill="#161b22"/>
|
|
3
|
+
<ellipse cx="20" cy="18" rx="9" ry="8" fill="#c9d1d9"/>
|
|
4
|
+
<rect x="13" y="15" width="14" height="5.5" rx="2.75" fill="#161b22"/>
|
|
5
|
+
<circle cx="17" cy="17.75" r="1.6" fill="#c9d1d9"/>
|
|
6
|
+
<circle cx="23" cy="17.75" r="1.6" fill="#c9d1d9"/>
|
|
7
|
+
<circle cx="17" cy="17.75" r="0.75" fill="#79c0ff"/>
|
|
8
|
+
<circle cx="23" cy="17.75" r="0.75" fill="#79c0ff"/>
|
|
9
|
+
<rect x="18.5" y="25.5" width="3" height="4" rx="1.5" fill="#c9d1d9"/>
|
|
10
|
+
<circle cx="13" cy="18" r="1.5" fill="#c9d1d9"/>
|
|
11
|
+
<circle cx="27" cy="18" r="1.5" fill="#c9d1d9"/>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
|
2
|
+
<circle cx="20" cy="20" r="19" fill="#24292e"/>
|
|
3
|
+
<ellipse cx="20" cy="18" rx="9" ry="8" fill="#f6f8fa"/>
|
|
4
|
+
<rect x="13" y="15" width="14" height="5.5" rx="2.75" fill="#24292e"/>
|
|
5
|
+
<circle cx="17" cy="17.75" r="1.6" fill="#f6f8fa"/>
|
|
6
|
+
<circle cx="23" cy="17.75" r="1.6" fill="#f6f8fa"/>
|
|
7
|
+
<circle cx="17" cy="17.75" r="0.75" fill="#58a6ff"/>
|
|
8
|
+
<circle cx="23" cy="17.75" r="0.75" fill="#58a6ff"/>
|
|
9
|
+
<rect x="18.5" y="25.5" width="3" height="4" rx="1.5" fill="#f6f8fa"/>
|
|
10
|
+
<circle cx="13" cy="18" r="1.5" fill="#f6f8fa"/>
|
|
11
|
+
<circle cx="27" cy="18" r="1.5" fill="#f6f8fa"/>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class GitHubCopilotTest implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitHubCopilotTest = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const apiClient_1 = require("../shared/apiClient");
|
|
6
|
+
class GitHubCopilotTest {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.description = {
|
|
9
|
+
displayName: 'GitHub Copilot Test',
|
|
10
|
+
name: 'gitHubCopilotTest',
|
|
11
|
+
icon: {
|
|
12
|
+
light: 'file:gitHubCopilotTest.svg',
|
|
13
|
+
dark: 'file:gitHubCopilotTest.dark.svg',
|
|
14
|
+
},
|
|
15
|
+
group: ['transform'],
|
|
16
|
+
version: 1,
|
|
17
|
+
description: 'Verify GitHub Copilot API credentials and connectivity with predefined checks.',
|
|
18
|
+
defaults: { name: 'GitHub Copilot Test' },
|
|
19
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
20
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
21
|
+
credentials: [{ name: 'gitHubCopilotApi', required: true }],
|
|
22
|
+
properties: [
|
|
23
|
+
{
|
|
24
|
+
displayName: 'Test',
|
|
25
|
+
name: 'test',
|
|
26
|
+
type: 'options',
|
|
27
|
+
noDataExpression: true,
|
|
28
|
+
options: [
|
|
29
|
+
{
|
|
30
|
+
name: 'List Models',
|
|
31
|
+
value: 'listModels',
|
|
32
|
+
description: 'Verify connectivity and list all available models',
|
|
33
|
+
action: 'List available models',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Simple Chat',
|
|
37
|
+
value: 'simpleChat',
|
|
38
|
+
description: 'Send a hello message to verify chat completions work',
|
|
39
|
+
action: 'Test a simple chat completion',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Full Diagnostics',
|
|
43
|
+
value: 'fullDiagnostics',
|
|
44
|
+
description: 'Run all checks and return a full diagnostics report',
|
|
45
|
+
action: 'Run full diagnostics',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
default: 'listModels',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
displayName: 'Model',
|
|
52
|
+
name: 'model',
|
|
53
|
+
type: 'string',
|
|
54
|
+
default: 'claude-sonnet-4-5',
|
|
55
|
+
description: 'Model to use for the chat test',
|
|
56
|
+
displayOptions: { show: { test: ['simpleChat', 'fullDiagnostics'] } },
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
usableAsTool: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async execute() {
|
|
63
|
+
var _a, _b, _c, _d, _e, _f;
|
|
64
|
+
const items = this.getInputData();
|
|
65
|
+
const returnData = [];
|
|
66
|
+
for (let i = 0; i < items.length; i++) {
|
|
67
|
+
const start = Date.now();
|
|
68
|
+
try {
|
|
69
|
+
const { authToken, baseUrl } = await (0, apiClient_1.getCredentials)(this, i);
|
|
70
|
+
const test = this.getNodeParameter('test', i);
|
|
71
|
+
if (test === 'listModels') {
|
|
72
|
+
const modelsResponse = await (0, apiClient_1.listModels)(this, authToken, baseUrl);
|
|
73
|
+
returnData.push({
|
|
74
|
+
json: {
|
|
75
|
+
status: 'ok',
|
|
76
|
+
models_count: modelsResponse.data.length,
|
|
77
|
+
models: modelsResponse.data.map((m) => m.id),
|
|
78
|
+
latency_ms: Date.now() - start,
|
|
79
|
+
},
|
|
80
|
+
pairedItem: { item: i },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else if (test === 'simpleChat') {
|
|
84
|
+
const model = this.getNodeParameter('model', i);
|
|
85
|
+
const completion = await (0, apiClient_1.chatCompletion)(this, authToken, baseUrl, {
|
|
86
|
+
model,
|
|
87
|
+
messages: [
|
|
88
|
+
{ role: 'system', content: 'You are a test assistant.' },
|
|
89
|
+
{
|
|
90
|
+
role: 'user',
|
|
91
|
+
content: 'Say "Hello from GitHub Copilot!" and nothing else.',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
max_tokens: 50,
|
|
95
|
+
temperature: 0,
|
|
96
|
+
});
|
|
97
|
+
returnData.push({
|
|
98
|
+
json: {
|
|
99
|
+
status: 'ok',
|
|
100
|
+
model_used: completion.model,
|
|
101
|
+
response: (_c = (_b = (_a = completion.choices[0]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.content) !== null && _c !== void 0 ? _c : '',
|
|
102
|
+
usage: completion.usage,
|
|
103
|
+
latency_ms: Date.now() - start,
|
|
104
|
+
},
|
|
105
|
+
pairedItem: { item: i },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const model = this.getNodeParameter('model', i);
|
|
110
|
+
const diagnostics = {
|
|
111
|
+
timestamp: new Date().toISOString(),
|
|
112
|
+
base_url: baseUrl,
|
|
113
|
+
};
|
|
114
|
+
try {
|
|
115
|
+
const modelsResponse = await (0, apiClient_1.listModels)(this, authToken, baseUrl);
|
|
116
|
+
diagnostics.models_check = {
|
|
117
|
+
status: 'ok',
|
|
118
|
+
count: modelsResponse.data.length,
|
|
119
|
+
models: modelsResponse.data.map((m) => m.id),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
diagnostics.models_check = {
|
|
124
|
+
status: 'failed',
|
|
125
|
+
error: err instanceof Error ? err.message : String(err),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const chatStart = Date.now();
|
|
130
|
+
const completion = await (0, apiClient_1.chatCompletion)(this, authToken, baseUrl, {
|
|
131
|
+
model,
|
|
132
|
+
messages: [{ role: 'user', content: 'Reply with the word "OK".' }],
|
|
133
|
+
max_tokens: 10,
|
|
134
|
+
temperature: 0,
|
|
135
|
+
});
|
|
136
|
+
diagnostics.chat_check = {
|
|
137
|
+
status: 'ok',
|
|
138
|
+
model_used: completion.model,
|
|
139
|
+
response: (_f = (_e = (_d = completion.choices[0]) === null || _d === void 0 ? void 0 : _d.message) === null || _e === void 0 ? void 0 : _e.content) !== null && _f !== void 0 ? _f : '',
|
|
140
|
+
latency_ms: Date.now() - chatStart,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
diagnostics.chat_check = {
|
|
145
|
+
status: 'failed',
|
|
146
|
+
error: err instanceof Error ? err.message : String(err),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
diagnostics.total_latency_ms = Date.now() - start;
|
|
150
|
+
diagnostics.overall_status =
|
|
151
|
+
diagnostics.models_check.status === 'ok' &&
|
|
152
|
+
diagnostics.chat_check.status === 'ok'
|
|
153
|
+
? 'ok'
|
|
154
|
+
: 'degraded';
|
|
155
|
+
returnData.push({ json: diagnostics, pairedItem: { item: i } });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
if (this.continueOnFail()) {
|
|
160
|
+
returnData.push({
|
|
161
|
+
json: (0, apiClient_1.normalizeError)(error, undefined, Date.now() - start),
|
|
162
|
+
pairedItem: { item: i },
|
|
163
|
+
});
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return [returnData];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.GitHubCopilotTest = GitHubCopilotTest;
|
|
173
|
+
//# sourceMappingURL=GitHubCopilotTest.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubCopilotTest.node.js","sourceRoot":"","sources":["../../../nodes/GitHubCopilotTest/GitHubCopilotTest.node.ts"],"names":[],"mappings":";;;AAOA,+CAAmD;AAEnD,mDAAiG;AAEjG,MAAa,iBAAiB;IAA9B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,qBAAqB;YAClC,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE;gBACL,KAAK,EAAE,4BAA4B;gBACnC,IAAI,EAAE,iCAAiC;aACvC;YACD,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,gFAAgF;YAC7F,QAAQ,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE;YACzC,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC3D,UAAU,EAAE;gBACX;oBACC,WAAW,EAAE,MAAM;oBACnB,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,aAAa;4BACnB,KAAK,EAAE,YAAY;4BACnB,WAAW,EAAE,mDAAmD;4BAChE,MAAM,EAAE,uBAAuB;yBAC/B;wBACD;4BACC,IAAI,EAAE,aAAa;4BACnB,KAAK,EAAE,YAAY;4BACnB,WAAW,EAAE,sDAAsD;4BACnE,MAAM,EAAE,+BAA+B;yBACvC;wBACD;4BACC,IAAI,EAAE,kBAAkB;4BACxB,KAAK,EAAE,iBAAiB;4B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
|
|
7
|
+
"primaryDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://github.com/CyberLaboratory/n8n-github-copilot-ai-tool"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
|
2
|
+
<circle cx="20" cy="20" r="19" fill="#161b22"/>
|
|
3
|
+
<ellipse cx="20" cy="18" rx="9" ry="8" fill="#c9d1d9"/>
|
|
4
|
+
<rect x="13" y="15" width="14" height="5.5" rx="2.75" fill="#161b22"/>
|
|
5
|
+
<circle cx="17" cy="17.75" r="1.6" fill="#c9d1d9"/>
|
|
6
|
+
<circle cx="23" cy="17.75" r="1.6" fill="#c9d1d9"/>
|
|
7
|
+
<circle cx="17" cy="17.75" r="0.75" fill="#79c0ff"/>
|
|
8
|
+
<circle cx="23" cy="17.75" r="0.75" fill="#79c0ff"/>
|
|
9
|
+
<rect x="18.5" y="25.5" width="3" height="4" rx="1.5" fill="#c9d1d9"/>
|
|
10
|
+
<circle cx="13" cy="18" r="1.5" fill="#c9d1d9"/>
|
|
11
|
+
<circle cx="27" cy="18" r="1.5" fill="#c9d1d9"/>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
|
2
|
+
<circle cx="20" cy="20" r="19" fill="#24292e"/>
|
|
3
|
+
<ellipse cx="20" cy="18" rx="9" ry="8" fill="#f6f8fa"/>
|
|
4
|
+
<rect x="13" y="15" width="14" height="5.5" rx="2.75" fill="#24292e"/>
|
|
5
|
+
<circle cx="17" cy="17.75" r="1.6" fill="#f6f8fa"/>
|
|
6
|
+
<circle cx="23" cy="17.75" r="1.6" fill="#f6f8fa"/>
|
|
7
|
+
<circle cx="17" cy="17.75" r="0.75" fill="#58a6ff"/>
|
|
8
|
+
<circle cx="23" cy="17.75" r="0.75" fill="#58a6ff"/>
|
|
9
|
+
<rect x="18.5" y="25.5" width="3" height="4" rx="1.5" fill="#f6f8fa"/>
|
|
10
|
+
<circle cx="13" cy="18" r="1.5" fill="#f6f8fa"/>
|
|
11
|
+
<circle cx="27" cy="18" r="1.5" fill="#f6f8fa"/>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
import type { AgentToolError, CopilotChatCompletion, CopilotChatRequest, CopilotEmbeddingRequest, CopilotEmbeddingResponse, CopilotModelsResponse } from './types';
|
|
3
|
+
export declare const COPILOT_API_BASE = "https://api.githubcopilot.com";
|
|
4
|
+
export declare function chatCompletion(executeFunctions: IExecuteFunctions, token: string, baseUrl: string, request: CopilotChatRequest): Promise<CopilotChatCompletion>;
|
|
5
|
+
export declare function createEmbeddings(executeFunctions: IExecuteFunctions, token: string, baseUrl: string, request: CopilotEmbeddingRequest): Promise<CopilotEmbeddingResponse>;
|
|
6
|
+
export declare function listModels(executeFunctions: IExecuteFunctions, token: string, baseUrl: string): Promise<CopilotModelsResponse>;
|
|
7
|
+
export declare function getCredentials(executeFunctions: IExecuteFunctions, itemIndex: number): Promise<{
|
|
8
|
+
authToken: string;
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function normalizeError(error: unknown, modelUsed?: string, latencyMs?: number): AgentToolError;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COPILOT_API_BASE = void 0;
|
|
4
|
+
exports.chatCompletion = chatCompletion;
|
|
5
|
+
exports.createEmbeddings = createEmbeddings;
|
|
6
|
+
exports.listModels = listModels;
|
|
7
|
+
exports.getCredentials = getCredentials;
|
|
8
|
+
exports.normalizeError = normalizeError;
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
exports.COPILOT_API_BASE = 'https://api.githubcopilot.com';
|
|
11
|
+
const INTEGRATION_ID = 'n8n-github-copilot-agent-tool';
|
|
12
|
+
const PLUGIN_VERSION = 'n8n-nodes-github-copilot-agent-tool/0.1.0';
|
|
13
|
+
function buildHeaders(token) {
|
|
14
|
+
return {
|
|
15
|
+
Authorization: `Bearer ${token}`,
|
|
16
|
+
'Content-Type': 'application/json',
|
|
17
|
+
'Copilot-Integration-Id': INTEGRATION_ID,
|
|
18
|
+
'Editor-Version': 'n8n/1.0',
|
|
19
|
+
'Editor-Plugin-Version': PLUGIN_VERSION,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function chatCompletion(executeFunctions, token, baseUrl, request) {
|
|
23
|
+
return (await executeFunctions.helpers.request({
|
|
24
|
+
method: 'POST',
|
|
25
|
+
url: `${baseUrl}/chat/completions`,
|
|
26
|
+
headers: buildHeaders(token),
|
|
27
|
+
body: JSON.stringify(request),
|
|
28
|
+
json: true,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
async function createEmbeddings(executeFunctions, token, baseUrl, request) {
|
|
32
|
+
return (await executeFunctions.helpers.request({
|
|
33
|
+
method: 'POST',
|
|
34
|
+
url: `${baseUrl}/embeddings`,
|
|
35
|
+
headers: buildHeaders(token),
|
|
36
|
+
body: JSON.stringify(request),
|
|
37
|
+
json: true,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
async function listModels(executeFunctions, token, baseUrl) {
|
|
41
|
+
return (await executeFunctions.helpers.request({
|
|
42
|
+
method: 'GET',
|
|
43
|
+
url: `${baseUrl}/models`,
|
|
44
|
+
headers: buildHeaders(token),
|
|
45
|
+
json: true,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
async function getCredentials(executeFunctions, itemIndex) {
|
|
49
|
+
const credentials = await executeFunctions.getCredentials('gitHubCopilotApi', itemIndex);
|
|
50
|
+
return {
|
|
51
|
+
authToken: credentials.authToken,
|
|
52
|
+
baseUrl: credentials.baseUrl || exports.COPILOT_API_BASE,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function normalizeError(error, modelUsed, latencyMs) {
|
|
56
|
+
var _a, _b, _c, _d;
|
|
57
|
+
const latency = latencyMs !== null && latencyMs !== void 0 ? latencyMs : 0;
|
|
58
|
+
if (error && typeof error === 'object' && 'statusCode' in error) {
|
|
59
|
+
const httpErr = error;
|
|
60
|
+
const code = (0, types_1.mapHttpStatusToErrorCode)(httpErr.statusCode);
|
|
61
|
+
let message = (_a = httpErr.message) !== null && _a !== void 0 ? _a : 'API request failed.';
|
|
62
|
+
if ((_b = httpErr.response) === null || _b === void 0 ? void 0 : _b.body) {
|
|
63
|
+
try {
|
|
64
|
+
const body = JSON.parse(httpErr.response.body);
|
|
65
|
+
message = (_d = (_c = body === null || body === void 0 ? void 0 : body.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : message;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
success: false,
|
|
72
|
+
error_code: code,
|
|
73
|
+
error_message: `[${httpErr.statusCode}] ${message}`,
|
|
74
|
+
model_used: modelUsed,
|
|
75
|
+
latency_ms: latency,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (error instanceof Error) {
|
|
79
|
+
const isNetwork = error.message.includes('ECONNREFUSED') ||
|
|
80
|
+
error.message.includes('ETIMEDOUT') ||
|
|
81
|
+
error.message.includes('ENOTFOUND');
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
error_code: isNetwork ? types_1.CopilotErrorCode.NETWORK_ERROR : types_1.CopilotErrorCode.UNKNOWN,
|
|
85
|
+
error_message: error.message,
|
|
86
|
+
model_used: modelUsed,
|
|
87
|
+
latency_ms: latency,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
success: false,
|
|
92
|
+
error_code: types_1.CopilotErrorCode.UNKNOWN,
|
|
93
|
+
error_message: String(error),
|
|
94
|
+
model_used: modelUsed,
|
|
95
|
+
latency_ms: latency,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=apiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../../nodes/shared/apiClient.ts"],"names":[],"mappings":";;;AAkCA,wCAaC;AAED,4CAaC;AAED,gCAWC;AAMD,wCASC;AAMD,wCAoDC;AA1ID,mCAAqE;AAExD,QAAA,gBAAgB,GAAG,+BAA+B,CAAC;AAChE,MAAM,cAAc,GAAG,+BAA+B,CAAC;AACvD,MAAM,cAAc,GAAG,2CAA2C,CAAC;AAMnE,SAAS,YAAY,CAAC,KAAa;IAClC,OAAO;QACN,aAAa,EAAE,UAAU,KAAK,EAAE;QAChC,cAAc,EAAE,kBAAkB;QAClC,wBAAwB,EAAE,cAAc;QACxC,gBAAgB,EAAE,SAAS;QAC3B,uBAAuB,EAAE,cAAc;KACvC,CAAC;AACH,CAAC;AAMM,KAAK,UAAU,cAAc,CACnC,gBAAmC,EACnC,KAAa,EACb,OAAe,EACf,OAA2B;IAE3B,OAAO,CAAC,MAAM,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC;QAC9C,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,OAAO,mBAAmB;QAClC,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC;QAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAC7B,IAAI,EAAE,IAAI;KACV,CAAC,CAA0B,CAAC;AAC9B,CAAC;AAEM,KAAK,UAAU,gBAAgB,CACrC,gBAAmC,EACnC,KAAa,EACb,OAAe,EACf,OAAgC;IAEhC,OAAO,CAAC,MAAM,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC;QAC9C,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,OAAO,aAAa;QAC5B,OAAO,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