n8n-nodes-github-copilot 3.12.1 → 3.12.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.
- package/dist/credentials/GitHubApi.credentials.js +1 -1
- package/dist/credentials/GitHubCopilotApi.credentials.d.ts +9 -0
- package/dist/credentials/GitHubCopilotApi.credentials.js +63 -0
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.js +11 -0
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js +1 -1
- package/dist/nodes/GitHubCopilotChatAPI/utils/helpers.d.ts +6 -7
- package/dist/nodes/GitHubCopilotChatAPI/utils/helpers.js +41 -7
- package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.js +2 -2
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js +2 -2
- package/dist/shared/utils/GitHubCopilotApiUtils.d.ts +1 -1
- package/dist/shared/utils/GitHubCopilotApiUtils.js +3 -3
- package/package.json +2 -3
|
@@ -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',
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { IExecuteFunctions } from
|
|
2
|
-
import { CopilotResponse, downloadFileFromUrl as sharedDownloadFileFromUrl, getFileFromBinary as sharedGetFileFromBinary,
|
|
1
|
+
import { IExecuteFunctions } from "n8n-workflow";
|
|
2
|
+
import { CopilotResponse, downloadFileFromUrl as sharedDownloadFileFromUrl, getFileFromBinary as sharedGetFileFromBinary, estimateTokens as sharedEstimateTokens } 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
6
|
export declare const estimateTokens: typeof sharedEstimateTokens;
|
|
10
|
-
export declare
|
|
11
|
-
export declare
|
|
7
|
+
export declare function getImageMimeType(buffer: Buffer): string;
|
|
8
|
+
export declare function getImageMimeTypeFromFilename(filename: string): string;
|
|
9
|
+
export declare function validateFileSize(buffer: Buffer, maxSize?: number): boolean;
|
|
10
|
+
export type { CopilotResponse };
|
|
@@ -1,16 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.estimateTokens = exports.getFileFromBinary = exports.downloadFileFromUrl = void 0;
|
|
4
4
|
exports.makeApiRequest = makeApiRequest;
|
|
5
|
+
exports.getImageMimeType = getImageMimeType;
|
|
6
|
+
exports.getImageMimeTypeFromFilename = getImageMimeTypeFromFilename;
|
|
7
|
+
exports.validateFileSize = validateFileSize;
|
|
5
8
|
const GitHubCopilotApiUtils_1 = require("../../../shared/utils/GitHubCopilotApiUtils");
|
|
6
9
|
async function makeApiRequest(context, endpoint, body, hasMedia = false) {
|
|
7
|
-
return (0, GitHubCopilotApiUtils_1.makeGitHubCopilotRequest)(context, endpoint, body,
|
|
10
|
+
return await (0, GitHubCopilotApiUtils_1.makeGitHubCopilotRequest)(context, endpoint, body, "githubCopilotApi", hasMedia);
|
|
8
11
|
}
|
|
9
12
|
exports.downloadFileFromUrl = GitHubCopilotApiUtils_1.downloadFileFromUrl;
|
|
10
13
|
exports.getFileFromBinary = GitHubCopilotApiUtils_1.getFileFromBinary;
|
|
11
|
-
exports.getImageMimeType = GitHubCopilotApiUtils_1.getImageMimeType;
|
|
12
|
-
exports.getAudioMimeType = GitHubCopilotApiUtils_1.getAudioMimeType;
|
|
13
|
-
exports.validateFileSize = GitHubCopilotApiUtils_1.validateFileSize;
|
|
14
14
|
exports.estimateTokens = GitHubCopilotApiUtils_1.estimateTokens;
|
|
15
|
-
|
|
16
|
-
|
|
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,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)(
|
|
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)(
|
|
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: '
|
|
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('
|
|
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?: '
|
|
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 = '
|
|
12
|
+
async function makeGitHubCopilotRequest(context, endpoint, body, credentialType = 'githubCopilotApi', hasMedia = false) {
|
|
13
13
|
var _a;
|
|
14
14
|
let token;
|
|
15
|
-
if (credentialType === '
|
|
16
|
-
const credentials = await context.getCredentials('
|
|
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.
|
|
3
|
+
"version": "3.12.3",
|
|
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/
|
|
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",
|