n8n-nodes-github-copilot 3.12.1 → 3.12.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.
@@ -0,0 +1,9 @@
1
+ import { ICredentialType, INodeProperties, ICredentialTestRequest } from 'n8n-workflow';
2
+ export declare class GitHubCopilotApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ extends: string[];
6
+ documentationUrl: string;
7
+ properties: INodeProperties[];
8
+ test: ICredentialTestRequest;
9
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GitHubCopilotApi = void 0;
4
+ class GitHubCopilotApi {
5
+ constructor() {
6
+ this.name = 'githubCopilotApi';
7
+ this.displayName = 'GitHub Copilot OAuth2 API';
8
+ this.extends = ['oAuth2Api'];
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: 'Grant Type',
13
+ name: 'grantType',
14
+ type: 'hidden',
15
+ default: 'authorizationCode',
16
+ },
17
+ {
18
+ displayName: 'Authorization URL',
19
+ name: 'authUrl',
20
+ type: 'hidden',
21
+ default: 'https://github.com/login/oauth/authorize',
22
+ },
23
+ {
24
+ displayName: 'Access Token URL',
25
+ name: 'accessTokenUrl',
26
+ type: 'hidden',
27
+ default: 'https://github.com/login/oauth/access_token',
28
+ },
29
+ {
30
+ displayName: 'Scope',
31
+ name: 'scope',
32
+ type: 'hidden',
33
+ default: 'copilot user read:user read:org',
34
+ },
35
+ {
36
+ displayName: 'Auth URI Query Parameters',
37
+ name: 'authQueryParameters',
38
+ type: 'hidden',
39
+ default: '',
40
+ },
41
+ {
42
+ displayName: 'Authentication',
43
+ name: 'authentication',
44
+ type: 'hidden',
45
+ default: 'header',
46
+ },
47
+ ];
48
+ this.test = {
49
+ request: {
50
+ baseURL: 'https://api.githubcopilot.com',
51
+ url: '/models',
52
+ method: 'GET',
53
+ headers: {
54
+ 'User-Agent': 'vscode-copilot',
55
+ 'Copilot-Integration-Id': 'vscode-chat',
56
+ 'Editor-Version': 'vscode/1.85.0',
57
+ 'Editor-Plugin-Version': 'copilot-chat/0.12.0',
58
+ },
59
+ },
60
+ };
61
+ }
62
+ }
63
+ exports.GitHubCopilotApi = GitHubCopilotApi;
@@ -59,6 +59,17 @@ class GitHubCopilot {
59
59
  },
60
60
  inputs: ["main"],
61
61
  outputs: ["main"],
62
+ credentials: [
63
+ {
64
+ name: 'githubCopilotApi',
65
+ required: false,
66
+ displayOptions: {
67
+ show: {
68
+ operation: ['suggest', 'explain'],
69
+ },
70
+ },
71
+ },
72
+ ],
62
73
  properties: [
63
74
  {
64
75
  displayName: 'Operation',
@@ -22,7 +22,7 @@ class GitHubCopilotChatAPI {
22
22
  outputs: ["main"],
23
23
  credentials: [
24
24
  {
25
- name: 'githubOAuth2Api',
25
+ name: 'githubCopilotApi',
26
26
  required: true,
27
27
  },
28
28
  ],
@@ -1,11 +1,10 @@
1
- import { IExecuteFunctions } from 'n8n-workflow';
2
- import { CopilotResponse, downloadFileFromUrl as sharedDownloadFileFromUrl, getFileFromBinary as sharedGetFileFromBinary, getImageMimeType as sharedGetImageMimeType, getAudioMimeType as sharedGetAudioMimeType, validateFileSize as sharedValidateFileSize, estimateTokens as sharedEstimateTokens, validateTokenLimit as sharedValidateTokenLimit, truncateToTokenLimit as sharedTruncateToTokenLimit } from '../../../shared/utils/GitHubCopilotApiUtils';
1
+ import { IExecuteFunctions } from "n8n-workflow";
2
+ import { CopilotResponse, downloadFileFromUrl as sharedDownloadFileFromUrl, getFileFromBinary as sharedGetFileFromBinary } from "../../../shared/utils/GitHubCopilotApiUtils";
3
3
  export declare function makeApiRequest(context: IExecuteFunctions, endpoint: string, body: Record<string, unknown>, hasMedia?: boolean): Promise<CopilotResponse>;
4
4
  export declare const downloadFileFromUrl: typeof sharedDownloadFileFromUrl;
5
5
  export declare const getFileFromBinary: typeof sharedGetFileFromBinary;
6
- export declare const getImageMimeType: typeof sharedGetImageMimeType;
7
- export declare const getAudioMimeType: typeof sharedGetAudioMimeType;
8
- export declare const validateFileSize: typeof sharedValidateFileSize;
9
- export declare const estimateTokens: typeof sharedEstimateTokens;
10
- export declare const validateTokenLimit: typeof sharedValidateTokenLimit;
11
- export declare const truncateToTokenLimit: typeof sharedTruncateToTokenLimit;
6
+ export declare function getImageMimeType(buffer: Buffer): string;
7
+ export declare function getImageMimeTypeFromFilename(filename: string): string;
8
+ export declare function validateFileSize(buffer: Buffer, maxSize?: number): boolean;
9
+ export declare function estimateTokens(text: string): number;
10
+ export type { CopilotResponse };
@@ -1,16 +1,53 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.truncateToTokenLimit = exports.validateTokenLimit = exports.estimateTokens = exports.validateFileSize = exports.getAudioMimeType = exports.getImageMimeType = exports.getFileFromBinary = exports.downloadFileFromUrl = void 0;
3
+ exports.getFileFromBinary = exports.downloadFileFromUrl = void 0;
4
4
  exports.makeApiRequest = makeApiRequest;
5
+ exports.getImageMimeType = getImageMimeType;
6
+ exports.getImageMimeTypeFromFilename = getImageMimeTypeFromFilename;
7
+ exports.validateFileSize = validateFileSize;
8
+ exports.estimateTokens = estimateTokens;
5
9
  const GitHubCopilotApiUtils_1 = require("../../../shared/utils/GitHubCopilotApiUtils");
6
10
  async function makeApiRequest(context, endpoint, body, hasMedia = false) {
7
- return (0, GitHubCopilotApiUtils_1.makeGitHubCopilotRequest)(context, endpoint, body, 'githubOAuth2Api', hasMedia);
11
+ return await (0, GitHubCopilotApiUtils_1.makeGitHubCopilotRequest)(context, endpoint, body, "githubCopilotApi", hasMedia);
8
12
  }
9
13
  exports.downloadFileFromUrl = GitHubCopilotApiUtils_1.downloadFileFromUrl;
10
14
  exports.getFileFromBinary = GitHubCopilotApiUtils_1.getFileFromBinary;
11
- exports.getImageMimeType = GitHubCopilotApiUtils_1.getImageMimeType;
12
- exports.getAudioMimeType = GitHubCopilotApiUtils_1.getAudioMimeType;
13
- exports.validateFileSize = GitHubCopilotApiUtils_1.validateFileSize;
14
- exports.estimateTokens = GitHubCopilotApiUtils_1.estimateTokens;
15
- exports.validateTokenLimit = GitHubCopilotApiUtils_1.validateTokenLimit;
16
- exports.truncateToTokenLimit = GitHubCopilotApiUtils_1.truncateToTokenLimit;
15
+ function getImageMimeType(buffer) {
16
+ const firstBytes = buffer.toString("hex", 0, 4);
17
+ if (firstBytes.startsWith("ffd8"))
18
+ return "image/jpeg";
19
+ if (firstBytes.startsWith("8950"))
20
+ return "image/png";
21
+ if (firstBytes.startsWith("4749"))
22
+ return "image/gif";
23
+ if (firstBytes.startsWith("5249"))
24
+ return "image/webp";
25
+ return "application/octet-stream";
26
+ }
27
+ function getImageMimeTypeFromFilename(filename) {
28
+ const ext = filename.toLowerCase().split(".").pop();
29
+ switch (ext) {
30
+ case "jpg":
31
+ case "jpeg":
32
+ return "image/jpeg";
33
+ case "png":
34
+ return "image/png";
35
+ case "gif":
36
+ return "image/gif";
37
+ case "webp":
38
+ return "image/webp";
39
+ case "bmp":
40
+ return "image/bmp";
41
+ case "tiff":
42
+ case "tif":
43
+ return "image/tiff";
44
+ default:
45
+ return "application/octet-stream";
46
+ }
47
+ }
48
+ function validateFileSize(buffer, maxSize = 20 * 1024 * 1024) {
49
+ return buffer.length <= maxSize;
50
+ }
51
+ function estimateTokens(text) {
52
+ return Math.ceil(text.length / 4);
53
+ }
@@ -51,14 +51,14 @@ async function processImageFile(context, itemIndex, imageSource, imageFile, imag
51
51
  if (compressedTokens < estimatedTokens) {
52
52
  return {
53
53
  data: compressedBase64,
54
- mimeType: (0, helpers_1.getImageMimeType)(filename),
54
+ mimeType: (0, helpers_1.getImageMimeType)(compressedBuffer),
55
55
  filename,
56
56
  size: compressedBuffer.length,
57
57
  estimatedTokens: compressedTokens
58
58
  };
59
59
  }
60
60
  }
61
- const mimeType = (0, helpers_1.getImageMimeType)(filename);
61
+ const mimeType = (0, helpers_1.getImageMimeType)(imageBuffer);
62
62
  return {
63
63
  data: base64Image,
64
64
  mimeType,
@@ -34,7 +34,7 @@ class GitHubCopilotChatModel {
34
34
  outputNames: ['Model'],
35
35
  credentials: [
36
36
  {
37
- name: 'githubOAuth2Api',
37
+ name: 'githubCopilotApi',
38
38
  required: true,
39
39
  },
40
40
  ],
@@ -108,7 +108,7 @@ class GitHubCopilotChatModel {
108
108
  const model = this.getNodeParameter('model', itemIndex);
109
109
  const options = this.getNodeParameter('options', itemIndex, {});
110
110
  const modelInfo = GitHubCopilotModels_1.GitHubCopilotModelsManager.getModelByValue(model);
111
- const credentials = await this.getCredentials('githubOAuth2Api');
111
+ const credentials = await this.getCredentials('githubCopilotApi');
112
112
  const token = (credentials.accessToken ||
113
113
  credentials.access_token ||
114
114
  ((_a = credentials.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token) ||
@@ -18,7 +18,7 @@ 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>, credentialType?: 'githubOAuth2Api' | 'githubApiManual', hasMedia?: boolean): Promise<CopilotResponse>;
21
+ export declare function makeGitHubCopilotRequest(context: IExecuteFunctions, endpoint: string, body: Record<string, unknown>, credentialType?: 'githubCopilotApi' | 'githubApiManual', hasMedia?: boolean): Promise<CopilotResponse>;
22
22
  export declare function downloadFileFromUrl(url: string): Promise<Buffer>;
23
23
  export declare function getFileFromBinary(context: IExecuteFunctions, itemIndex: number, propertyName: string): Promise<Buffer>;
24
24
  export declare function getImageMimeType(filename: string): string;
@@ -9,11 +9,11 @@ exports.validateFileSize = validateFileSize;
9
9
  exports.estimateTokens = estimateTokens;
10
10
  exports.validateTokenLimit = validateTokenLimit;
11
11
  exports.truncateToTokenLimit = truncateToTokenLimit;
12
- async function makeGitHubCopilotRequest(context, endpoint, body, credentialType = 'githubOAuth2Api', hasMedia = false) {
12
+ async function makeGitHubCopilotRequest(context, endpoint, body, credentialType = 'githubCopilotApi', hasMedia = false) {
13
13
  var _a;
14
14
  let token;
15
- if (credentialType === 'githubOAuth2Api') {
16
- const credentials = await context.getCredentials('githubOAuth2Api');
15
+ if (credentialType === 'githubCopilotApi') {
16
+ const credentials = await context.getCredentials('githubCopilotApi');
17
17
  console.log('🔍 OAuth2 Credentials Debug:', Object.keys(credentials));
18
18
  token = (credentials.accessToken ||
19
19
  credentials.access_token ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.12.1",
3
+ "version": "3.12.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",
@@ -27,8 +27,7 @@
27
27
  "n8n": {
28
28
  "n8nNodesApiVersion": 1,
29
29
  "credentials": [
30
- "dist/credentials/GitHubApi.credentials.js",
31
- "dist/credentials/GitHubApiManual.credentials.js"
30
+ "dist/credentials/GitHubCopilotApi.credentials.js"
32
31
  ],
33
32
  "nodes": [
34
33
  "dist/nodes/GitHubCopilot/GitHubCopilot.node.js",