n8n-nodes-github-copilot 3.31.14 → 3.31.16

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.
@@ -1,6 +1,6 @@
1
1
  import { IExecuteFunctions } from "n8n-workflow";
2
- import { CopilotResponse, downloadFileFromUrl as sharedDownloadFileFromUrl, getFileFromBinary as sharedGetFileFromBinary, estimateTokens as sharedEstimateTokens } from "../../../shared/utils/GitHubCopilotApiUtils";
3
- export declare function makeApiRequest(context: IExecuteFunctions, endpoint: string, body: Record<string, unknown>, hasMedia?: boolean): Promise<CopilotResponse>;
2
+ import { CopilotResponse, RetryConfig, downloadFileFromUrl as sharedDownloadFileFromUrl, getFileFromBinary as sharedGetFileFromBinary, estimateTokens as sharedEstimateTokens } from "../../../shared/utils/GitHubCopilotApiUtils";
3
+ export declare function makeApiRequest(context: IExecuteFunctions, endpoint: string, body: Record<string, unknown>, hasMedia?: boolean, retryConfig?: RetryConfig): Promise<CopilotResponse>;
4
4
  export declare const downloadFileFromUrl: typeof sharedDownloadFileFromUrl;
5
5
  export declare const getFileFromBinary: typeof sharedGetFileFromBinary;
6
6
  export declare const estimateTokens: typeof sharedEstimateTokens;
@@ -6,8 +6,8 @@ exports.getImageMimeType = getImageMimeType;
6
6
  exports.getImageMimeTypeFromFilename = getImageMimeTypeFromFilename;
7
7
  exports.validateFileSize = validateFileSize;
8
8
  const GitHubCopilotApiUtils_1 = require("../../../shared/utils/GitHubCopilotApiUtils");
9
- async function makeApiRequest(context, endpoint, body, hasMedia = false) {
10
- return await (0, GitHubCopilotApiUtils_1.makeGitHubCopilotRequest)(context, endpoint, body, hasMedia);
9
+ async function makeApiRequest(context, endpoint, body, hasMedia = false, retryConfig) {
10
+ return await (0, GitHubCopilotApiUtils_1.makeGitHubCopilotRequest)(context, endpoint, body, hasMedia, retryConfig);
11
11
  }
12
12
  exports.downloadFileFromUrl = GitHubCopilotApiUtils_1.downloadFileFromUrl;
13
13
  exports.getFileFromBinary = GitHubCopilotApiUtils_1.getFileFromBinary;
@@ -1,3 +1,4 @@
1
1
  export * from "./types";
2
2
  export * from "./helpers";
3
+ export type { RetryConfig } from "../../../shared/utils/GitHubCopilotApiUtils";
3
4
  export * from "./imageProcessor";
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.31.14",
3
+ "version": "3.31.16",
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",
@@ -18,7 +18,12 @@ export interface CopilotResponse {
18
18
  total_tokens: number;
19
19
  };
20
20
  }
21
- export declare function makeGitHubCopilotRequest(context: IExecuteFunctions, endpoint: string, body: Record<string, unknown>, hasMedia?: boolean): Promise<CopilotResponse>;
21
+ export interface RetryConfig {
22
+ maxRetries?: number;
23
+ baseDelay?: number;
24
+ retryOn403?: boolean;
25
+ }
26
+ export declare function makeGitHubCopilotRequest(context: IExecuteFunctions, endpoint: string, body: Record<string, unknown>, hasMedia?: boolean, retryConfig?: RetryConfig): Promise<CopilotResponse>;
22
27
  export declare function downloadFileFromUrl(url: string): Promise<Buffer>;
23
28
  export declare function getFileFromBinary(context: IExecuteFunctions, itemIndex: number, propertyName: string): Promise<Buffer>;
24
29
  export declare function getImageMimeType(filename: string): string;
@@ -10,8 +10,11 @@ exports.estimateTokens = estimateTokens;
10
10
  exports.validateTokenLimit = validateTokenLimit;
11
11
  exports.truncateToTokenLimit = truncateToTokenLimit;
12
12
  const GitHubCopilotEndpoints_1 = require("./GitHubCopilotEndpoints");
13
- async function makeGitHubCopilotRequest(context, endpoint, body, hasMedia = false) {
14
- var _a;
13
+ async function makeGitHubCopilotRequest(context, endpoint, body, hasMedia = false, retryConfig) {
14
+ var _a, _b, _c, _d;
15
+ const MAX_RETRIES = (_a = retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.maxRetries) !== null && _a !== void 0 ? _a : 3;
16
+ const BASE_DELAY = (_b = retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.baseDelay) !== null && _b !== void 0 ? _b : 500;
17
+ const RETRY_ON_403 = (_c = retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.retryOn403) !== null && _c !== void 0 ? _c : true;
15
18
  let credentialType = "githubCopilotApi";
16
19
  try {
17
20
  credentialType = context.getNodeParameter("credentialType", 0, "githubCopilotApi");
@@ -23,7 +26,7 @@ async function makeGitHubCopilotRequest(context, endpoint, body, hasMedia = fals
23
26
  console.log(`🔍 ${credentialType} Credentials Debug:`, Object.keys(credentials));
24
27
  const token = (credentials.accessToken ||
25
28
  credentials.access_token ||
26
- ((_a = credentials.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token) ||
29
+ ((_d = credentials.oauthTokenData) === null || _d === void 0 ? void 0 : _d.access_token) ||
27
30
  credentials.token);
28
31
  if (!token) {
29
32
  console.error(`❌ Available ${credentialType} credential properties:`, Object.keys(credentials));
@@ -49,20 +52,44 @@ async function makeGitHubCopilotRequest(context, endpoint, body, hasMedia = fals
49
52
  body: JSON.stringify(body),
50
53
  };
51
54
  const fullUrl = `${GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.BASE_URL}${endpoint}`;
52
- const response = await fetch(fullUrl, options);
53
- if (!response.ok) {
54
- const errorText = await response.text();
55
- const tokenPrefix = token.substring(0, 4);
56
- const tokenSuffix = token.substring(token.length - 5);
57
- const tokenInfo = `${tokenPrefix}...${tokenSuffix}`;
58
- console.error(`❌ GitHub Copilot API Error: ${response.status} ${response.statusText}`);
59
- console.error(`❌ Error details: ${errorText}`);
60
- console.error(`❌ Used credential type: ${credentialType}`);
61
- console.error(`❌ Token format used: ${tokenInfo}`);
62
- const enhancedError = `GitHub Copilot API error: ${response.status} ${response.statusText}. ${errorText} [Token used: ${tokenInfo}]`;
63
- throw new Error(enhancedError);
64
- }
65
- return await response.json();
55
+ let lastError = null;
56
+ for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
57
+ try {
58
+ const response = await fetch(fullUrl, options);
59
+ if (response.status === 403 && RETRY_ON_403 && attempt < MAX_RETRIES) {
60
+ console.warn(`⚠️ GitHub Copilot API 403 error on attempt ${attempt}/${MAX_RETRIES}. Retrying in ${BASE_DELAY * Math.pow(2, attempt - 1)}ms...`);
61
+ await new Promise(resolve => setTimeout(resolve, BASE_DELAY * Math.pow(2, attempt - 1)));
62
+ continue;
63
+ }
64
+ if (!response.ok) {
65
+ const errorText = await response.text();
66
+ const tokenPrefix = token.substring(0, 4);
67
+ const tokenSuffix = token.substring(token.length - 5);
68
+ const tokenInfo = `${tokenPrefix}...${tokenSuffix}`;
69
+ console.error(`❌ GitHub Copilot API Error: ${response.status} ${response.statusText}`);
70
+ console.error(`❌ Error details: ${errorText}`);
71
+ console.error(`❌ Used credential type: ${credentialType}`);
72
+ console.error(`❌ Token format used: ${tokenInfo}`);
73
+ console.error(`❌ Attempt: ${attempt}/${MAX_RETRIES}`);
74
+ const enhancedError = `GitHub Copilot API error: ${response.status} ${response.statusText}. ${errorText} [Token used: ${tokenInfo}] [Attempt: ${attempt}/${MAX_RETRIES}]`;
75
+ throw new Error(enhancedError);
76
+ }
77
+ if (attempt > 1) {
78
+ console.log(`✅ GitHub Copilot API succeeded on attempt ${attempt}/${MAX_RETRIES}`);
79
+ }
80
+ return await response.json();
81
+ }
82
+ catch (error) {
83
+ lastError = error instanceof Error ? error : new Error(String(error));
84
+ if (attempt < MAX_RETRIES) {
85
+ console.warn(`⚠️ GitHub Copilot API error on attempt ${attempt}/${MAX_RETRIES}: ${lastError.message}. Retrying in ${BASE_DELAY * Math.pow(2, attempt - 1)}ms...`);
86
+ await new Promise(resolve => setTimeout(resolve, BASE_DELAY * Math.pow(2, attempt - 1)));
87
+ continue;
88
+ }
89
+ throw lastError;
90
+ }
91
+ }
92
+ throw lastError || new Error("GitHub Copilot API request failed after all retries");
66
93
  }
67
94
  async function downloadFileFromUrl(url) {
68
95
  const response = await fetch(url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.31.14",
3
+ "version": "3.31.16",
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",