n8n-nodes-github-copilot 3.26.0 → 3.27.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/dist/credentials/GitHubCopilotOAuth2Api.credentials.backup.d.ts +9 -0
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.backup.js +144 -0
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.d.ts +9 -0
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.js +99 -0
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.js +45 -4
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js +14 -0
- package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.js +19 -0
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js +35 -1
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.js +41 -3
- package/dist/shared/utils/GitHubCopilotApiUtils.js +14 -7
- package/package.json +3 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICredentialType, INodeProperties, ICredentialTestRequest, IAuthenticateGeneric } from 'n8n-workflow';
|
|
2
|
+
export declare class GitHubCopilotOAuth2Api implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitHubCopilotOAuth2Api = void 0;
|
|
4
|
+
const GitHubCopilotEndpoints_1 = require("../shared/utils/GitHubCopilotEndpoints");
|
|
5
|
+
class GitHubCopilotOAuth2Api {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.name = 'githubCopilotOAuth2Api';
|
|
8
|
+
this.displayName = 'GitHub Copilot OAuth2 (with Helper)';
|
|
9
|
+
this.documentationUrl = 'https://docs.github.com/en/copilot/github-copilot-chat/copilot-chat-in-ides/using-github-copilot-chat-in-your-ide';
|
|
10
|
+
this.properties = [
|
|
11
|
+
{
|
|
12
|
+
displayName: '🎯 GitHub Copilot OAuth Helper',
|
|
13
|
+
name: 'authNotice',
|
|
14
|
+
type: 'notice',
|
|
15
|
+
default: '',
|
|
16
|
+
description: `<strong>🚀 Easy Token Generation:</strong><br/>
|
|
17
|
+
1. Run the helper script: <code>node get-copilot-token.js</code><br/>
|
|
18
|
+
2. Follow the Device Flow OAuth in your browser<br/>
|
|
19
|
+
3. Copy the generated token below<br/><br/>
|
|
20
|
+
<em>The script handles all OAuth complexity automatically!</em>`,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Authentication Method',
|
|
24
|
+
name: 'authMethod',
|
|
25
|
+
type: 'options',
|
|
26
|
+
options: [
|
|
27
|
+
{
|
|
28
|
+
name: 'Manual Token (Paste from Script)',
|
|
29
|
+
value: 'manual',
|
|
30
|
+
description: 'Paste token generated by get-copilot-token.js script',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'Device Flow OAuth (Interactive)',
|
|
34
|
+
value: 'deviceFlow',
|
|
35
|
+
description: 'Generate Device Flow code for manual authorization',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
default: 'manual',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
displayName: 'GitHub Copilot Token',
|
|
42
|
+
name: 'token',
|
|
43
|
+
type: 'string',
|
|
44
|
+
typeOptions: {
|
|
45
|
+
password: true,
|
|
46
|
+
},
|
|
47
|
+
default: '',
|
|
48
|
+
required: true,
|
|
49
|
+
displayOptions: {
|
|
50
|
+
show: {
|
|
51
|
+
authMethod: ['manual'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
description: '🔑 Paste the token generated by <code>get-copilot-token.js</code> script (format: gho_*)',
|
|
55
|
+
placeholder: 'gho_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: '🔧 Device Flow Setup',
|
|
59
|
+
name: 'deviceFlowSetup',
|
|
60
|
+
type: 'notice',
|
|
61
|
+
default: '',
|
|
62
|
+
displayOptions: {
|
|
63
|
+
show: {
|
|
64
|
+
authMethod: ['deviceFlow'],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
description: `<strong>� Device Flow Configuration:</strong><br/>
|
|
68
|
+
Client ID: <code>01ab8ac9400c4e429b23</code><br/>
|
|
69
|
+
Scopes: <code>repo user:email</code><br/><br/>
|
|
70
|
+
<strong>🌐 Manual Steps:</strong><br/>
|
|
71
|
+
1. Go to: <a href="https://github.com/login/device" target="_blank">https://github.com/login/device</a><br/>
|
|
72
|
+
2. Use Client ID: 01ab8ac9400c4e429b23<br/>
|
|
73
|
+
3. Enter the 8-character code generated below<br/>
|
|
74
|
+
4. Authorize the application<br/>
|
|
75
|
+
5. Get your token and paste it in Manual Token field`,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
displayName: 'Generate Device Code',
|
|
79
|
+
name: 'generateCode',
|
|
80
|
+
type: 'button',
|
|
81
|
+
typeOptions: {
|
|
82
|
+
action: {
|
|
83
|
+
type: 'generateDeviceCode',
|
|
84
|
+
displayName: '🎲 Generate 8-Character Code',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
default: '',
|
|
88
|
+
displayOptions: {
|
|
89
|
+
show: {
|
|
90
|
+
authMethod: ['deviceFlow'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
description: 'Click to generate an 8-character code for Device Flow OAuth',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
displayName: 'Device Code',
|
|
97
|
+
name: 'deviceCode',
|
|
98
|
+
type: 'string',
|
|
99
|
+
default: '',
|
|
100
|
+
displayOptions: {
|
|
101
|
+
show: {
|
|
102
|
+
authMethod: ['deviceFlow'],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
description: '🔤 8-character code for GitHub Device Flow (generated automatically)',
|
|
106
|
+
placeholder: 'ABCD-EFGH',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
displayName: 'Verification URL',
|
|
110
|
+
name: 'verificationUrl',
|
|
111
|
+
type: 'string',
|
|
112
|
+
default: 'https://github.com/login/device',
|
|
113
|
+
displayOptions: {
|
|
114
|
+
show: {
|
|
115
|
+
authMethod: ['deviceFlow'],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
description: '🌐 URL to authorize the application',
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
this.authenticate = {
|
|
122
|
+
type: 'generic',
|
|
123
|
+
properties: {
|
|
124
|
+
headers: {
|
|
125
|
+
'Authorization': '=Bearer {{$credentials.token}}',
|
|
126
|
+
'Accept': 'application/json',
|
|
127
|
+
'Content-Type': 'application/json',
|
|
128
|
+
'User-Agent': 'GitHub-Copilot-Chat/1.0.0 VSCode/1.85.0',
|
|
129
|
+
'Editor-Version': 'vscode/1.85.0',
|
|
130
|
+
'Editor-Plugin-Version': 'copilot-chat/0.12.0',
|
|
131
|
+
'X-GitHub-Api-Version': '2025-04-01',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
this.test = {
|
|
136
|
+
request: {
|
|
137
|
+
baseURL: GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.BASE_URL,
|
|
138
|
+
url: GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ENDPOINTS.MODELS,
|
|
139
|
+
method: 'GET',
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.GitHubCopilotOAuth2Api = GitHubCopilotOAuth2Api;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICredentialType, INodeProperties, ICredentialTestRequest, IAuthenticateGeneric } from 'n8n-workflow';
|
|
2
|
+
export declare class GitHubCopilotOAuth2Api implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitHubCopilotOAuth2Api = void 0;
|
|
4
|
+
const GitHubCopilotEndpoints_1 = require("../shared/utils/GitHubCopilotEndpoints");
|
|
5
|
+
class GitHubCopilotOAuth2Api {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.name = 'githubCopilotOAuth2Api';
|
|
8
|
+
this.displayName = 'GitHub Copilot OAuth2 (with Helper)';
|
|
9
|
+
this.documentationUrl = 'https://docs.github.com/en/copilot/github-copilot-chat/copilot-chat-in-ides/using-github-copilot-chat-in-your-ide';
|
|
10
|
+
this.properties = [
|
|
11
|
+
{
|
|
12
|
+
displayName: '🚀 Automated Token Generation (Recommended)',
|
|
13
|
+
name: 'scriptHelper',
|
|
14
|
+
type: 'notice',
|
|
15
|
+
default: '',
|
|
16
|
+
description: `<strong>Easy 3-Step Process:</strong><br/>
|
|
17
|
+
1. Run: <code>node get-copilot-token.js</code><br/>
|
|
18
|
+
2. Follow OAuth flow in browser<br/>
|
|
19
|
+
3. Paste generated token below<br/><br/>
|
|
20
|
+
<em>Script handles all OAuth complexity automatically!</em>`,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
displayName: 'GitHub Copilot Token',
|
|
24
|
+
name: 'token',
|
|
25
|
+
type: 'string',
|
|
26
|
+
typeOptions: {
|
|
27
|
+
password: true,
|
|
28
|
+
},
|
|
29
|
+
default: '',
|
|
30
|
+
required: true,
|
|
31
|
+
description: '🔑 Your GitHub Copilot token (format: gho_*)',
|
|
32
|
+
placeholder: 'gho_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
displayName: '🔧 Manual OAuth Steps (Alternative)',
|
|
36
|
+
name: 'manualSteps',
|
|
37
|
+
type: 'collection',
|
|
38
|
+
placeholder: 'Expand for Manual Setup',
|
|
39
|
+
default: {},
|
|
40
|
+
options: [
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Step-by-Step Instructions',
|
|
43
|
+
name: 'instructions',
|
|
44
|
+
type: 'notice',
|
|
45
|
+
default: '',
|
|
46
|
+
description: `<strong>Manual Device Flow Process:</strong><br/><br/>
|
|
47
|
+
<strong>1. Generate Device Code:</strong><br/>
|
|
48
|
+
🌐 Visit: <a href="https://github.com/login/device" target="_blank">https://github.com/login/device</a><br/><br/>
|
|
49
|
+
<strong>2. Enter Client ID:</strong><br/>
|
|
50
|
+
🔑 Use: <code>01ab8ac9400c4e429b23</code><br/><br/>
|
|
51
|
+
<strong>3. Get 8-Character Code:</strong><br/>
|
|
52
|
+
📱 GitHub will provide code like: ABCD-1234<br/><br/>
|
|
53
|
+
<strong>4. Complete Authorization:</strong><br/>
|
|
54
|
+
✅ Enter code and authorize application<br/><br/>
|
|
55
|
+
<strong>5. Obtain Token:</strong><br/>
|
|
56
|
+
🎯 Copy final token and paste above`,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Client ID (Fixed)',
|
|
60
|
+
name: 'clientId',
|
|
61
|
+
type: 'string',
|
|
62
|
+
default: '01ab8ac9400c4e429b23',
|
|
63
|
+
description: 'GitHub OAuth Client ID - VS Code application',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
displayName: 'Required Scopes',
|
|
67
|
+
name: 'scopes',
|
|
68
|
+
type: 'string',
|
|
69
|
+
default: 'repo user:email',
|
|
70
|
+
description: 'OAuth permissions needed for Copilot access',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
description: 'Manual configuration for advanced users',
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
this.authenticate = {
|
|
77
|
+
type: 'generic',
|
|
78
|
+
properties: {
|
|
79
|
+
headers: {
|
|
80
|
+
'Authorization': '=Bearer {{$credentials.token}}',
|
|
81
|
+
'Accept': 'application/json',
|
|
82
|
+
'Content-Type': 'application/json',
|
|
83
|
+
'User-Agent': 'GitHub-Copilot-Chat/1.0.0 VSCode/1.85.0',
|
|
84
|
+
'Editor-Version': 'vscode/1.85.0',
|
|
85
|
+
'Editor-Plugin-Version': 'copilot-chat/0.12.0',
|
|
86
|
+
'X-GitHub-Api-Version': '2025-04-01',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
this.test = {
|
|
91
|
+
request: {
|
|
92
|
+
baseURL: GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.BASE_URL,
|
|
93
|
+
url: GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ENDPOINTS.MODELS,
|
|
94
|
+
method: 'GET',
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.GitHubCopilotOAuth2Api = GitHubCopilotOAuth2Api;
|
|
@@ -66,6 +66,17 @@ class GitHubCopilot {
|
|
|
66
66
|
displayOptions: {
|
|
67
67
|
show: {
|
|
68
68
|
useCredential: [true],
|
|
69
|
+
credentialType: ['githubCopilotApi'],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'githubCopilotOAuth2Api',
|
|
75
|
+
required: false,
|
|
76
|
+
displayOptions: {
|
|
77
|
+
show: {
|
|
78
|
+
useCredential: [true],
|
|
79
|
+
credentialType: ['githubCopilotOAuth2Api'],
|
|
69
80
|
},
|
|
70
81
|
},
|
|
71
82
|
},
|
|
@@ -78,6 +89,30 @@ class GitHubCopilot {
|
|
|
78
89
|
default: false,
|
|
79
90
|
description: 'Use GitHub Copilot API credential instead of local GitHub CLI authentication',
|
|
80
91
|
},
|
|
92
|
+
{
|
|
93
|
+
displayName: 'Credential Type',
|
|
94
|
+
name: 'credentialType',
|
|
95
|
+
type: 'options',
|
|
96
|
+
options: [
|
|
97
|
+
{
|
|
98
|
+
name: 'GitHub Copilot API (Manual Token)',
|
|
99
|
+
value: 'githubCopilotApi',
|
|
100
|
+
description: 'Use manual GitHub CLI token',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'GitHub Copilot OAuth2 (with Helper)',
|
|
104
|
+
value: 'githubCopilotOAuth2Api',
|
|
105
|
+
description: 'Use OAuth2 credential with helper script',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
default: 'githubCopilotApi',
|
|
109
|
+
description: 'Type of credential to use for GitHub Copilot authentication',
|
|
110
|
+
displayOptions: {
|
|
111
|
+
show: {
|
|
112
|
+
useCredential: [true],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
81
116
|
{
|
|
82
117
|
displayName: 'Operation',
|
|
83
118
|
name: 'operation',
|
|
@@ -250,6 +285,7 @@ class GitHubCopilot {
|
|
|
250
285
|
};
|
|
251
286
|
}
|
|
252
287
|
async execute() {
|
|
288
|
+
var _a;
|
|
253
289
|
const items = this.getInputData();
|
|
254
290
|
const returnData = [];
|
|
255
291
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -262,10 +298,15 @@ class GitHubCopilot {
|
|
|
262
298
|
let authMethod = 'Local CLI';
|
|
263
299
|
if (useCredential) {
|
|
264
300
|
try {
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
301
|
+
const credentialType = this.getNodeParameter('credentialType', i, 'githubCopilotApi');
|
|
302
|
+
const credentials = await this.getCredentials(credentialType);
|
|
303
|
+
const token = (credentials.accessToken ||
|
|
304
|
+
credentials.access_token ||
|
|
305
|
+
((_a = credentials.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token) ||
|
|
306
|
+
credentials.token);
|
|
307
|
+
if (token) {
|
|
308
|
+
githubToken = token;
|
|
309
|
+
authMethod = `GitHub Copilot ${credentialType === 'githubCopilotOAuth2Api' ? 'OAuth2' : 'API'} Credential`;
|
|
269
310
|
}
|
|
270
311
|
}
|
|
271
312
|
catch (error) {
|
|
@@ -25,6 +25,20 @@ class GitHubCopilotChatAPI {
|
|
|
25
25
|
{
|
|
26
26
|
name: 'githubCopilotApi',
|
|
27
27
|
required: true,
|
|
28
|
+
displayOptions: {
|
|
29
|
+
show: {
|
|
30
|
+
credentialType: ['githubCopilotApi'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'githubCopilotOAuth2Api',
|
|
36
|
+
required: true,
|
|
37
|
+
displayOptions: {
|
|
38
|
+
show: {
|
|
39
|
+
credentialType: ['githubCopilotOAuth2Api'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
28
42
|
},
|
|
29
43
|
],
|
|
30
44
|
properties: nodeProperties_1.nodeProperties,
|
|
@@ -3,6 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.nodeProperties = void 0;
|
|
4
4
|
const GitHubCopilotModels_1 = require("../../shared/models/GitHubCopilotModels");
|
|
5
5
|
exports.nodeProperties = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Credential Type',
|
|
8
|
+
name: 'credentialType',
|
|
9
|
+
type: 'options',
|
|
10
|
+
options: [
|
|
11
|
+
{
|
|
12
|
+
name: 'GitHub Copilot API (Manual Token)',
|
|
13
|
+
value: 'githubCopilotApi',
|
|
14
|
+
description: 'Use manual GitHub CLI token',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'GitHub Copilot OAuth2 (with Helper)',
|
|
18
|
+
value: 'githubCopilotOAuth2Api',
|
|
19
|
+
description: 'Use OAuth2 credential with helper script',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
default: 'githubCopilotApi',
|
|
23
|
+
description: 'Type of credential to use for GitHub Copilot authentication',
|
|
24
|
+
},
|
|
6
25
|
{
|
|
7
26
|
displayName: 'Operation',
|
|
8
27
|
name: 'operation',
|
|
@@ -37,9 +37,42 @@ class GitHubCopilotChatModel {
|
|
|
37
37
|
{
|
|
38
38
|
name: 'githubCopilotApi',
|
|
39
39
|
required: true,
|
|
40
|
+
displayOptions: {
|
|
41
|
+
show: {
|
|
42
|
+
credentialType: ['githubCopilotApi'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'githubCopilotOAuth2Api',
|
|
48
|
+
required: true,
|
|
49
|
+
displayOptions: {
|
|
50
|
+
show: {
|
|
51
|
+
credentialType: ['githubCopilotOAuth2Api'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
40
54
|
},
|
|
41
55
|
],
|
|
42
56
|
properties: [
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Credential Type',
|
|
59
|
+
name: 'credentialType',
|
|
60
|
+
type: 'options',
|
|
61
|
+
options: [
|
|
62
|
+
{
|
|
63
|
+
name: 'GitHub Copilot API (Manual Token)',
|
|
64
|
+
value: 'githubCopilotApi',
|
|
65
|
+
description: 'Use manual GitHub CLI token',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'GitHub Copilot OAuth2 (with Helper)',
|
|
69
|
+
value: 'githubCopilotOAuth2Api',
|
|
70
|
+
description: 'Use OAuth2 credential with helper script',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
default: 'githubCopilotApi',
|
|
74
|
+
description: 'Type of credential to use for GitHub Copilot authentication',
|
|
75
|
+
},
|
|
43
76
|
{
|
|
44
77
|
displayName: 'Model',
|
|
45
78
|
name: 'model',
|
|
@@ -128,7 +161,8 @@ class GitHubCopilotChatModel {
|
|
|
128
161
|
const model = this.getNodeParameter('model', itemIndex);
|
|
129
162
|
const options = this.getNodeParameter('options', itemIndex, {});
|
|
130
163
|
const modelInfo = GitHubCopilotModels_1.GitHubCopilotModelsManager.getModelByValue(model);
|
|
131
|
-
const
|
|
164
|
+
const credentialType = this.getNodeParameter('credentialType', 0, 'githubCopilotApi');
|
|
165
|
+
const credentials = await this.getCredentials(credentialType);
|
|
132
166
|
const token = (credentials.accessToken ||
|
|
133
167
|
credentials.access_token ||
|
|
134
168
|
((_a = credentials.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token) ||
|
|
@@ -325,9 +325,42 @@ class GitHubCopilotTest {
|
|
|
325
325
|
{
|
|
326
326
|
name: 'githubCopilotApi',
|
|
327
327
|
required: true,
|
|
328
|
+
displayOptions: {
|
|
329
|
+
show: {
|
|
330
|
+
credentialType: ['githubCopilotApi'],
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: 'githubCopilotOAuth2Api',
|
|
336
|
+
required: true,
|
|
337
|
+
displayOptions: {
|
|
338
|
+
show: {
|
|
339
|
+
credentialType: ['githubCopilotOAuth2Api'],
|
|
340
|
+
},
|
|
341
|
+
},
|
|
328
342
|
},
|
|
329
343
|
],
|
|
330
344
|
properties: [
|
|
345
|
+
{
|
|
346
|
+
displayName: 'Credential Type',
|
|
347
|
+
name: 'credentialType',
|
|
348
|
+
type: 'options',
|
|
349
|
+
options: [
|
|
350
|
+
{
|
|
351
|
+
name: 'GitHub Copilot API (Manual Token)',
|
|
352
|
+
value: 'githubCopilotApi',
|
|
353
|
+
description: 'Use manual GitHub CLI token',
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: 'GitHub Copilot OAuth2 (with Helper)',
|
|
357
|
+
value: 'githubCopilotOAuth2Api',
|
|
358
|
+
description: 'Use OAuth2 credential with helper script',
|
|
359
|
+
},
|
|
360
|
+
],
|
|
361
|
+
default: 'githubCopilotApi',
|
|
362
|
+
description: 'Type of credential to use for GitHub Copilot authentication',
|
|
363
|
+
},
|
|
331
364
|
{
|
|
332
365
|
displayName: 'Test Function',
|
|
333
366
|
name: 'testFunction',
|
|
@@ -397,6 +430,7 @@ class GitHubCopilotTest {
|
|
|
397
430
|
};
|
|
398
431
|
}
|
|
399
432
|
async execute() {
|
|
433
|
+
var _a;
|
|
400
434
|
const items = this.getInputData();
|
|
401
435
|
const returnData = [];
|
|
402
436
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -408,11 +442,15 @@ class GitHubCopilotTest {
|
|
|
408
442
|
const testsPerModel = testFunction === 'consolidatedTest'
|
|
409
443
|
? this.getNodeParameter('testsPerModel', i)
|
|
410
444
|
: 5;
|
|
411
|
-
const
|
|
412
|
-
|
|
445
|
+
const credentialType = this.getNodeParameter('credentialType', i, 'githubCopilotApi');
|
|
446
|
+
const credentials = await this.getCredentials(credentialType, i);
|
|
447
|
+
const token = (credentials.accessToken ||
|
|
448
|
+
credentials.access_token ||
|
|
449
|
+
((_a = credentials.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token) ||
|
|
450
|
+
credentials.token);
|
|
451
|
+
if (!token) {
|
|
413
452
|
throw new Error(GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ERRORS.CREDENTIALS_REQUIRED);
|
|
414
453
|
}
|
|
415
|
-
const token = credentials.token;
|
|
416
454
|
if (!GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.validateToken(token)) {
|
|
417
455
|
throw new Error(GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ERRORS.INVALID_TOKEN);
|
|
418
456
|
}
|
|
@@ -12,20 +12,27 @@ exports.truncateToTokenLimit = truncateToTokenLimit;
|
|
|
12
12
|
const GitHubCopilotEndpoints_1 = require("./GitHubCopilotEndpoints");
|
|
13
13
|
async function makeGitHubCopilotRequest(context, endpoint, body, hasMedia = false) {
|
|
14
14
|
var _a;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
let credentialType = 'githubCopilotApi';
|
|
16
|
+
try {
|
|
17
|
+
credentialType = context.getNodeParameter('credentialType', 0, 'githubCopilotApi');
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.log('🔍 No credentialType parameter found, using default: githubCopilotApi');
|
|
21
|
+
}
|
|
22
|
+
const credentials = await context.getCredentials(credentialType);
|
|
23
|
+
console.log(`🔍 ${credentialType} Credentials Debug:`, Object.keys(credentials));
|
|
17
24
|
const token = (credentials.accessToken ||
|
|
18
25
|
credentials.access_token ||
|
|
19
26
|
((_a = credentials.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token) ||
|
|
20
27
|
credentials.token);
|
|
21
28
|
if (!token) {
|
|
22
|
-
console.error(
|
|
23
|
-
console.error(
|
|
24
|
-
throw new Error(
|
|
29
|
+
console.error(`❌ Available ${credentialType} credential properties:`, Object.keys(credentials));
|
|
30
|
+
console.error(`❌ Full ${credentialType} credential object:`, JSON.stringify(credentials, null, 2));
|
|
31
|
+
throw new Error(`GitHub Copilot: No access token found in ${credentialType} credentials. Available properties: ` + Object.keys(credentials).join(', '));
|
|
25
32
|
}
|
|
26
33
|
const tokenPrefix = token.substring(0, Math.min(4, token.indexOf('_') + 1)) || token.substring(0, 4);
|
|
27
34
|
const tokenSuffix = token.substring(Math.max(0, token.length - 5));
|
|
28
|
-
console.log(`🔍 GitHub Copilot
|
|
35
|
+
console.log(`🔍 GitHub Copilot ${credentialType} Debug: Using token ${tokenPrefix}...${tokenSuffix}`);
|
|
29
36
|
if (!token.startsWith('gho_') && !token.startsWith('ghu_') && !token.startsWith('github_pat_')) {
|
|
30
37
|
console.warn(`⚠️ Unexpected token format: ${tokenPrefix}...${tokenSuffix}. Trying API call anyway.`);
|
|
31
38
|
}
|
|
@@ -51,7 +58,7 @@ async function makeGitHubCopilotRequest(context, endpoint, body, hasMedia = fals
|
|
|
51
58
|
const tokenInfo = `${tokenPrefix}...${tokenSuffix}`;
|
|
52
59
|
console.error(`❌ GitHub Copilot API Error: ${response.status} ${response.statusText}`);
|
|
53
60
|
console.error(`❌ Error details: ${errorText}`);
|
|
54
|
-
console.error(`❌ Used credential type:
|
|
61
|
+
console.error(`❌ Used credential type: ${credentialType}`);
|
|
55
62
|
console.error(`❌ Token format used: ${tokenInfo}`);
|
|
56
63
|
const enhancedError = `GitHub Copilot API error: ${response.status} ${response.statusText}. ${errorText} [Token used: ${tokenInfo}]`;
|
|
57
64
|
throw new Error(enhancedError);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-github-copilot",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.1",
|
|
4
4
|
"description": "n8n community node for GitHub Copilot with CLI integration, Chat API access, and AI Chat Model for workflows - access GPT-5, Claude, Gemini and more using your Copilot subscription",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"n8n": {
|
|
28
28
|
"n8nNodesApiVersion": 1,
|
|
29
29
|
"credentials": [
|
|
30
|
-
"dist/credentials/GitHubCopilotApi.credentials.js"
|
|
30
|
+
"dist/credentials/GitHubCopilotApi.credentials.js",
|
|
31
|
+
"dist/credentials/GitHubCopilotOAuth2Api.credentials.js"
|
|
31
32
|
],
|
|
32
33
|
"nodes": [
|
|
33
34
|
"dist/nodes/GitHubCopilot/GitHubCopilot.node.js",
|