n8n-nodes-github-copilot 3.37.1 → 3.37.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.
@@ -5,43 +5,7 @@ const n8n_workflow_1 = require("n8n-workflow");
5
5
  const OAuthTokenManager_1 = require("../../shared/utils/OAuthTokenManager");
6
6
  const GitHubCopilotEndpoints_1 = require("../../shared/utils/GitHubCopilotEndpoints");
7
7
  const DynamicModelLoader_1 = require("../../shared/models/DynamicModelLoader");
8
- async function executeEmbeddingsWithRetry(oauthToken, requestBody, enableRetry, maxRetries) {
9
- let lastError = null;
10
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
11
- try {
12
- const response = await fetch(`${GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.BASE_URL}${GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ENDPOINTS.EMBEDDINGS}`, {
13
- method: "POST",
14
- headers: GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getEmbeddingsHeaders(oauthToken),
15
- body: JSON.stringify(requestBody),
16
- });
17
- if (!response.ok) {
18
- const errorText = await response.text();
19
- if (GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.isTpmQuotaError(response.status) &&
20
- enableRetry &&
21
- attempt < maxRetries) {
22
- const delay = GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getRetryDelay(attempt + 1);
23
- console.log(`Attempt ${attempt + 1} failed with ${response.status}, retrying in ${delay}ms...`);
24
- await new Promise((resolve) => setTimeout(resolve, delay));
25
- continue;
26
- }
27
- throw new Error(`API Error ${response.status}: ${errorText}`);
28
- }
29
- const data = (await response.json());
30
- return data;
31
- }
32
- catch (error) {
33
- lastError = error instanceof Error ? error : new Error(String(error));
34
- if (attempt < maxRetries && enableRetry) {
35
- const delay = GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getRetryDelay(attempt + 1);
36
- console.log(`Attempt ${attempt + 1} failed, retrying in ${delay}ms...`);
37
- await new Promise((resolve) => setTimeout(resolve, delay));
38
- continue;
39
- }
40
- throw lastError;
41
- }
42
- }
43
- throw lastError || new Error("Maximum retry attempts exceeded");
44
- }
8
+ const EmbeddingsApiUtils_1 = require("../../shared/utils/EmbeddingsApiUtils");
45
9
  class GitHubCopilotEmbeddings {
46
10
  constructor() {
47
11
  this.description = {
@@ -336,7 +300,7 @@ class GitHubCopilotEmbeddings {
336
300
  }
337
301
  const requestBody = {
338
302
  model,
339
- input,
303
+ input: input,
340
304
  };
341
305
  if (options.dimensions) {
342
306
  requestBody.dimensions = options.dimensions;
@@ -344,7 +308,7 @@ class GitHubCopilotEmbeddings {
344
308
  if (options.encoding_format) {
345
309
  requestBody.encoding_format = options.encoding_format;
346
310
  }
347
- const result = await executeEmbeddingsWithRetry(oauthToken, requestBody, enableRetry, maxRetries);
311
+ const result = await (0, EmbeddingsApiUtils_1.executeEmbeddingsRequest)(oauthToken, requestBody, enableRetry, maxRetries);
348
312
  const returnFullResponse = options.returnFullResponse === true;
349
313
  if (returnFullResponse) {
350
314
  returnData.push({
@@ -4,6 +4,7 @@ exports.GitHubCopilotTest = void 0;
4
4
  const GitHubCopilotEndpoints_1 = require("../../shared/utils/GitHubCopilotEndpoints");
5
5
  const DynamicModelsManager_1 = require("../../shared/utils/DynamicModelsManager");
6
6
  const OAuthTokenManager_1 = require("../../shared/utils/OAuthTokenManager");
7
+ const EmbeddingsApiUtils_1 = require("../../shared/utils/EmbeddingsApiUtils");
7
8
  async function listAvailableModels(token, enableRetry = true, maxRetries = 3) {
8
9
  const retryInfo = {
9
10
  attempts: 1,
@@ -453,37 +454,19 @@ async function testEmbeddingModels(token, enableRetry = true, maxRetries = 3) {
453
454
  model: model.id,
454
455
  input: [testText],
455
456
  };
456
- const response = await fetch(GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getEmbeddingsUrl(), {
457
- method: "POST",
458
- headers: GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getEmbeddingsHeaders(token),
459
- body: JSON.stringify(requestBody),
460
- });
457
+ const data = await (0, EmbeddingsApiUtils_1.executeEmbeddingsRequestSimple)(token, requestBody);
461
458
  const testDuration = Date.now() - testStart;
462
- if (response.ok) {
463
- const data = (await response.json());
464
- const embeddingLength = ((_c = (_b = (_a = data.data) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.embedding) === null || _c === void 0 ? void 0 : _c.length) || 0;
465
- modelResults.tests.push({
466
- testNumber: testNum,
467
- success: true,
468
- responseTime: testDuration,
469
- embeddingDimensions: embeddingLength,
470
- tokensUsed: ((_d = data.usage) === null || _d === void 0 ? void 0 : _d.total_tokens) || 0,
471
- });
472
- modelResults.summary.successCount++;
473
- modelResults.summary.totalResponseTime += testDuration;
474
- console.log(` ✅ Test ${testNum}/${testsPerModel}: Success (${testDuration}ms, ${embeddingLength}D)`);
475
- }
476
- else {
477
- const errorText = await response.text();
478
- modelResults.tests.push({
479
- testNumber: testNum,
480
- success: false,
481
- responseTime: testDuration,
482
- error: `HTTP ${response.status}: ${errorText.substring(0, 100)}`,
483
- });
484
- modelResults.summary.failureCount++;
485
- console.log(` ❌ Test ${testNum}/${testsPerModel}: Failed (${response.status})`);
486
- }
459
+ const embeddingLength = ((_c = (_b = (_a = data.data) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.embedding) === null || _c === void 0 ? void 0 : _c.length) || 0;
460
+ modelResults.tests.push({
461
+ testNumber: testNum,
462
+ success: true,
463
+ responseTime: testDuration,
464
+ embeddingDimensions: embeddingLength,
465
+ tokensUsed: ((_d = data.usage) === null || _d === void 0 ? void 0 : _d.total_tokens) || 0,
466
+ });
467
+ modelResults.summary.successCount++;
468
+ modelResults.summary.totalResponseTime += testDuration;
469
+ console.log(` ✅ Test ${testNum}/${testsPerModel}: Success (${testDuration}ms, ${embeddingLength}D)`);
487
470
  }
488
471
  catch (error) {
489
472
  const testDuration = Date.now() - testStart;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.37.1",
3
+ "version": "3.37.2",
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",
@@ -0,0 +1,22 @@
1
+ export interface EmbeddingResponse {
2
+ object: string;
3
+ data: Array<{
4
+ object: string;
5
+ index: number;
6
+ embedding: number[];
7
+ }>;
8
+ model: string;
9
+ usage: {
10
+ prompt_tokens: number;
11
+ total_tokens: number;
12
+ };
13
+ }
14
+ export interface EmbeddingRequest {
15
+ model: string;
16
+ input: string[];
17
+ dimensions?: number;
18
+ encoding_format?: "float" | "base64";
19
+ user?: string;
20
+ }
21
+ export declare function executeEmbeddingsRequest(oauthToken: string, requestBody: EmbeddingRequest, enableRetry?: boolean, maxRetries?: number): Promise<EmbeddingResponse>;
22
+ export declare function executeEmbeddingsRequestSimple(oauthToken: string, requestBody: EmbeddingRequest): Promise<EmbeddingResponse>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeEmbeddingsRequest = executeEmbeddingsRequest;
4
+ exports.executeEmbeddingsRequestSimple = executeEmbeddingsRequestSimple;
5
+ const GitHubCopilotEndpoints_1 = require("./GitHubCopilotEndpoints");
6
+ async function executeEmbeddingsRequest(oauthToken, requestBody, enableRetry = true, maxRetries = 3) {
7
+ let lastError = null;
8
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
9
+ try {
10
+ const response = await fetch(GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getEmbeddingsUrl(), {
11
+ method: "POST",
12
+ headers: GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getEmbeddingsHeaders(oauthToken),
13
+ body: JSON.stringify(requestBody),
14
+ });
15
+ if (!response.ok) {
16
+ const errorText = await response.text();
17
+ if (GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.isTpmQuotaError(response.status) &&
18
+ enableRetry &&
19
+ attempt < maxRetries) {
20
+ const delay = GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getRetryDelay(attempt + 1);
21
+ console.log(`Embeddings attempt ${attempt + 1} failed with ${response.status}, retrying in ${delay}ms...`);
22
+ await new Promise((resolve) => setTimeout(resolve, delay));
23
+ continue;
24
+ }
25
+ throw new Error(`Embeddings API Error ${response.status}: ${errorText}`);
26
+ }
27
+ const data = (await response.json());
28
+ return data;
29
+ }
30
+ catch (error) {
31
+ lastError = error instanceof Error ? error : new Error(String(error));
32
+ if (attempt < maxRetries && enableRetry) {
33
+ const delay = GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getRetryDelay(attempt + 1);
34
+ console.log(`Embeddings attempt ${attempt + 1} failed, retrying in ${delay}ms...`);
35
+ await new Promise((resolve) => setTimeout(resolve, delay));
36
+ continue;
37
+ }
38
+ throw lastError;
39
+ }
40
+ }
41
+ throw lastError || new Error("Maximum retry attempts exceeded for embeddings request");
42
+ }
43
+ async function executeEmbeddingsRequestSimple(oauthToken, requestBody) {
44
+ const response = await fetch(GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getEmbeddingsUrl(), {
45
+ method: "POST",
46
+ headers: GitHubCopilotEndpoints_1.GitHubCopilotEndpoints.getEmbeddingsHeaders(oauthToken),
47
+ body: JSON.stringify(requestBody),
48
+ });
49
+ if (!response.ok) {
50
+ const errorText = await response.text();
51
+ throw new Error(`Embeddings API Error ${response.status}: ${errorText}`);
52
+ }
53
+ return (await response.json());
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.37.1",
3
+ "version": "3.37.2",
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",