n8n-nodes-github-copilot 1.1.1 → 1.1.3
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.
|
@@ -255,10 +255,12 @@ class GitHubCopilot {
|
|
|
255
255
|
if (language !== 'other') {
|
|
256
256
|
fullPrompt = `[${language}] ${fullPrompt}`;
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
const escapedSuggestPrompt = fullPrompt.replace(/'/g, `'"'"'`);
|
|
259
|
+
command = `/usr/bin/gh copilot suggest '${escapedSuggestPrompt}'`;
|
|
259
260
|
break;
|
|
260
261
|
case 'explain':
|
|
261
|
-
|
|
262
|
+
const escapedExplainPrompt = fullPrompt.replace(/'/g, `'"'"'`);
|
|
263
|
+
command = `/usr/bin/gh copilot explain '${escapedExplainPrompt}'`;
|
|
262
264
|
break;
|
|
263
265
|
case 'shell':
|
|
264
266
|
const commandType = this.getNodeParameter('commandType', i);
|
|
@@ -279,24 +281,47 @@ class GitHubCopilot {
|
|
|
279
281
|
default:
|
|
280
282
|
shellPrompt = fullPrompt;
|
|
281
283
|
}
|
|
282
|
-
|
|
284
|
+
const escapedShellPrompt = shellPrompt.replace(/'/g, `'"'"'`);
|
|
285
|
+
command = `/usr/bin/gh copilot suggest '${escapedShellPrompt}' --type shell`;
|
|
283
286
|
break;
|
|
284
287
|
default:
|
|
285
288
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
|
|
286
289
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
290
|
+
let stdout = '';
|
|
291
|
+
let stderr = '';
|
|
292
|
+
try {
|
|
293
|
+
const result = await execAsync(command, {
|
|
294
|
+
env: {
|
|
295
|
+
...process.env,
|
|
296
|
+
GH_TOKEN: accessToken,
|
|
297
|
+
GITHUB_TOKEN: accessToken,
|
|
298
|
+
GH_PAT: accessToken,
|
|
299
|
+
HOME: '/opt/n8n-source/packages/cli/bin',
|
|
300
|
+
},
|
|
301
|
+
timeout: 30000,
|
|
302
|
+
maxBuffer: 1024 * 1024,
|
|
303
|
+
});
|
|
304
|
+
stdout = result.stdout;
|
|
305
|
+
stderr = result.stderr;
|
|
306
|
+
}
|
|
307
|
+
catch (execError) {
|
|
308
|
+
const err = execError;
|
|
309
|
+
stderr = err.stderr || err.message || String(execError);
|
|
310
|
+
stdout = err.stdout || '';
|
|
311
|
+
}
|
|
312
|
+
if (stderr) {
|
|
313
|
+
if (stderr.includes('internal server error') || stderr.includes('code: 400')) {
|
|
314
|
+
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}`);
|
|
315
|
+
}
|
|
316
|
+
else if (stderr.includes('401') || stderr.includes('Unauthorized') || stderr.includes('Bad credentials')) {
|
|
317
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub authentication failed. Please check your token has Copilot permissions. Error: ${stderr}`);
|
|
318
|
+
}
|
|
319
|
+
else if (stderr.includes('403') || stderr.includes('Forbidden')) {
|
|
320
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot access denied. Please ensure your account has Copilot subscription. Error: ${stderr}`);
|
|
321
|
+
}
|
|
322
|
+
else if (!stdout) {
|
|
323
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot CLI error: ${stderr}`);
|
|
324
|
+
}
|
|
300
325
|
}
|
|
301
326
|
const filterOutput = this.getNodeParameter('filterOutput', i, true);
|
|
302
327
|
let processedOutput = stdout;
|
|
@@ -315,6 +340,7 @@ class GitHubCopilot {
|
|
|
315
340
|
commandType: operation === 'shell' ? this.getNodeParameter('commandType', i) : undefined,
|
|
316
341
|
output: processedOutput,
|
|
317
342
|
cliRawOutput: stdout,
|
|
343
|
+
cliStderr: stderr || undefined,
|
|
318
344
|
timestamp: new Date().toISOString(),
|
|
319
345
|
},
|
|
320
346
|
pairedItem: { item: i },
|
package/package.json
CHANGED