n8n-nodes-github-copilot 1.1.0 → 1.1.2

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.
@@ -64,11 +64,21 @@ class GitHubCopilot {
64
64
  name: 'gitHubApi',
65
65
  displayName: 'GitHub API (OAuth2)',
66
66
  required: false,
67
+ displayOptions: {
68
+ show: {
69
+ authType: ['oauth2'],
70
+ },
71
+ },
67
72
  },
68
73
  {
69
74
  name: 'gitHubApiManual',
70
75
  displayName: 'GitHub API (Manual Token)',
71
76
  required: false,
77
+ displayOptions: {
78
+ show: {
79
+ authType: ['manual'],
80
+ },
81
+ },
72
82
  },
73
83
  ],
74
84
  properties: [
@@ -198,6 +208,7 @@ class GitHubCopilot {
198
208
  };
199
209
  }
200
210
  async execute() {
211
+ var _a;
201
212
  const items = this.getInputData();
202
213
  const returnData = [];
203
214
  for (let i = 0; i < items.length; i++) {
@@ -210,12 +221,17 @@ class GitHubCopilot {
210
221
  let credentialType = '';
211
222
  if (authType === 'oauth2') {
212
223
  const oauthCredentials = await this.getCredentials('gitHubApi');
213
- if ((oauthCredentials === null || oauthCredentials === void 0 ? void 0 : oauthCredentials.accessToken) && typeof oauthCredentials.accessToken === 'string') {
214
- accessToken = oauthCredentials.accessToken;
224
+ console.log('OAuth2 credentials object:', JSON.stringify(oauthCredentials, null, 2));
225
+ const creds = oauthCredentials;
226
+ accessToken = (creds === null || creds === void 0 ? void 0 : creds.accessToken) ||
227
+ (creds === null || creds === void 0 ? void 0 : creds.access_token) ||
228
+ (creds === null || creds === void 0 ? void 0 : creds.token) ||
229
+ ((_a = creds === null || creds === void 0 ? void 0 : creds.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token);
230
+ if (accessToken && typeof accessToken === 'string') {
215
231
  credentialType = 'OAuth2';
216
232
  }
217
233
  else {
218
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'OAuth2 credentials not found or invalid. Please configure OAuth2 authentication or switch to Manual Token.');
234
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `OAuth2 token not found. Available fields: ${Object.keys(oauthCredentials || {}).join(', ')}. Please switch to Manual Token.`);
219
235
  }
220
236
  }
221
237
  else {
@@ -268,19 +284,41 @@ class GitHubCopilot {
268
284
  default:
269
285
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
270
286
  }
271
- const { stdout, stderr } = await execAsync(command, {
272
- env: {
273
- ...process.env,
274
- GH_TOKEN: accessToken,
275
- GITHUB_TOKEN: accessToken,
276
- GH_PAT: accessToken,
277
- HOME: '/opt/n8n-source/packages/cli/bin',
278
- },
279
- timeout: 30000,
280
- maxBuffer: 1024 * 1024,
281
- });
282
- if (stderr && !stdout) {
283
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot CLI error: ${stderr}`);
287
+ let stdout = '';
288
+ let stderr = '';
289
+ try {
290
+ const result = await execAsync(command, {
291
+ env: {
292
+ ...process.env,
293
+ GH_TOKEN: accessToken,
294
+ GITHUB_TOKEN: accessToken,
295
+ GH_PAT: accessToken,
296
+ HOME: '/opt/n8n-source/packages/cli/bin',
297
+ },
298
+ timeout: 30000,
299
+ maxBuffer: 1024 * 1024,
300
+ });
301
+ stdout = result.stdout;
302
+ stderr = result.stderr;
303
+ }
304
+ catch (execError) {
305
+ const err = execError;
306
+ stderr = err.stderr || err.message || String(execError);
307
+ stdout = err.stdout || '';
308
+ }
309
+ if (stderr) {
310
+ if (stderr.includes('internal server error') || stderr.includes('code: 400')) {
311
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot service is temporarily unavailable (HTTP 400). This is a GitHub server issue. Please try again in a few moments. Error: ${stderr}`);
312
+ }
313
+ else if (stderr.includes('401') || stderr.includes('Unauthorized') || stderr.includes('Bad credentials')) {
314
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub authentication failed. Please check your token has Copilot permissions. Error: ${stderr}`);
315
+ }
316
+ else if (stderr.includes('403') || stderr.includes('Forbidden')) {
317
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot access denied. Please ensure your account has Copilot subscription. Error: ${stderr}`);
318
+ }
319
+ else if (!stdout) {
320
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot CLI error: ${stderr}`);
321
+ }
284
322
  }
285
323
  const filterOutput = this.getNodeParameter('filterOutput', i, true);
286
324
  let processedOutput = stdout;
@@ -299,6 +337,7 @@ class GitHubCopilot {
299
337
  commandType: operation === 'shell' ? this.getNodeParameter('commandType', i) : undefined,
300
338
  output: processedOutput,
301
339
  cliRawOutput: stdout,
340
+ cliStderr: stderr || undefined,
302
341
  timestamp: new Date().toISOString(),
303
342
  },
304
343
  pairedItem: { item: i },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "n8n community node for GitHub Copilot CLI integration",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",