n8n-nodes-github-copilot 3.6.2 → 3.8.0

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/README.md CHANGED
@@ -143,12 +143,24 @@ gh auth token
143
143
  ```
144
144
 
145
145
  ### 1. Adicionar o Node
146
+
146
147
  1. Crie um novo workflow
147
148
  2. Procure por **GitHub Copilot** na lista de nodes
148
149
  3. Arraste para o canvas
149
150
  4. **Deixe o campo token vazio** (se o servidor tem `gh auth login`)
150
151
  5. **OU** insira um token gerado por `gh auth token`
151
152
 
153
+ ### 2. Configuração para GitHub Copilot Chat API
154
+
155
+ Para usar o **GitHub Copilot Chat API** (com modelos GPT-5, Claude, etc.):
156
+
157
+ 1. **Selecione credenciais built-in**: Use **"GitHub API"** (credencial padrão do n8n)
158
+ 2. **Configure a credencial**:
159
+ - **GitHub Server**: `https://api.github.com`
160
+ - **User**: Seu username do GitHub
161
+ - **Access Token**: Token obtido via `gh auth token` (formato `gho_*`)
162
+ 3. **Importante**: Apenas tokens GitHub Copilot funcionam - Personal Access Tokens (`ghp_*`) são rejeitados pela API
163
+
152
164
  ## 🎮 Como Usar
153
165
 
154
166
  ### Operações Disponíveis
@@ -307,12 +319,17 @@ npm run format
307
319
 
308
320
  ### Estrutura do Projeto
309
321
  ```
310
- ├── credentials/
311
- │ └── GitHubApi.credentials.ts
312
322
  ├── nodes/
313
- └── GitHubCopilot/
314
- ├── GitHubCopilot.node.ts
315
- └── githubcopilot.svg
323
+ ├── GitHubCopilot/
324
+ ├── GitHubCopilot.node.ts
325
+ └── githubcopilot.svg
326
+ │ ├── GitHubCopilotChatAPI/
327
+ │ │ └── GitHubCopilotChatAPI.node.ts
328
+ │ └── GitHubCopilotChatModel/
329
+ │ └── GitHubCopilotChatModel.node.ts
330
+ ├── shared/
331
+ │ └── models/
332
+ │ └── GitHubCopilotModels.ts
316
333
  ├── package.json
317
334
  ├── tsconfig.json
318
335
  ├── gulpfile.js
@@ -1,8 +1,9 @@
1
- import { ICredentialType, INodeProperties } from 'n8n-workflow';
1
+ import { ICredentialType, INodeProperties, ICredentialTestRequest } from 'n8n-workflow';
2
2
  export declare class GitHubApi implements ICredentialType {
3
3
  name: string;
4
4
  displayName: string;
5
5
  extends: string[];
6
6
  documentationUrl: string;
7
7
  properties: INodeProperties[];
8
+ test: ICredentialTestRequest;
8
9
  }
@@ -45,6 +45,13 @@ class GitHubApi {
45
45
  default: 'header',
46
46
  },
47
47
  ];
48
+ this.test = {
49
+ request: {
50
+ baseURL: 'https://api.githubcopilot.com',
51
+ url: '/models',
52
+ method: 'GET',
53
+ },
54
+ };
48
55
  }
49
56
  }
50
57
  exports.GitHubApi = GitHubApi;
@@ -15,7 +15,7 @@ class GitHubApiManual {
15
15
  required: true,
16
16
  default: '',
17
17
  placeholder: 'gho_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
18
- description: 'GitHub Personal Access Token with Copilot permissions. Must start with "gho_" for OAuth or "ghp_" for classic.',
18
+ description: 'GitHub Copilot access token. Must start with "gho_" for GitHub Copilot API. Personal Access Tokens (ghp_*) are not supported.',
19
19
  },
20
20
  {
21
21
  displayName: 'Token Type Info',
@@ -25,7 +25,7 @@ class GitHubApiManual {
25
25
  displayOptions: {
26
26
  show: {},
27
27
  },
28
- description: 'For GitHub Copilot CLI, OAuth tokens (gho_) are recommended. Create at: GitHub Settings Developer settings Personal access tokens Fine-grained tokens',
28
+ description: '⚠️ IMPORTANT: Only GitHub Copilot tokens (gho_*) work with this API. Personal Access Tokens (ghp_*) and other formats will be rejected with authentication errors. Contact your organization admin to obtain a proper GitHub Copilot access token.',
29
29
  },
30
30
  ];
31
31
  }
@@ -11,8 +11,24 @@ exports.validateTokenLimit = validateTokenLimit;
11
11
  exports.truncateToTokenLimit = truncateToTokenLimit;
12
12
  async function makeApiRequest(context, endpoint, body, hasMedia = false) {
13
13
  const credentials = await context.getCredentials('githubApi');
14
+ const token = credentials.accessToken;
15
+ if (!token) {
16
+ throw new Error('GitHub Copilot: No access token found in credentials');
17
+ }
18
+ if (!token.startsWith('gho_')) {
19
+ const tokenPrefix = token.substring(0, token.indexOf('_') + 1) || token.substring(0, 4);
20
+ const tokenSuffix = token.length > 5 ? token.substring(token.length - 5) : token;
21
+ console.error(`❌ GitHub Copilot Auth Debug: Invalid token format. Got: ${tokenPrefix}...${tokenSuffix}`);
22
+ throw new Error(`GitHub Copilot API requires GitHub Copilot tokens (gho_*). ` +
23
+ `Received token with prefix: ${tokenPrefix}...${tokenSuffix}. ` +
24
+ `Personal Access Tokens (ghp_*) and other formats are not supported. ` +
25
+ `Please obtain a GitHub Copilot access token from your organization.`);
26
+ }
27
+ const tokenPrefix = token.substring(0, token.indexOf('_') + 1);
28
+ const tokenSuffix = token.substring(token.length - 5);
29
+ console.log(`🔍 GitHub Copilot Auth Debug: Using token ${tokenPrefix}...${tokenSuffix}`);
14
30
  const headers = {
15
- 'Authorization': `Bearer ${credentials.accessToken}`,
31
+ 'Authorization': `Bearer ${token}`,
16
32
  'Content-Type': 'application/json',
17
33
  'User-Agent': 'n8n-github-copilot-chat-api-node',
18
34
  };
@@ -108,6 +108,22 @@ class GitHubCopilotChatModel {
108
108
  const options = this.getNodeParameter('options', itemIndex, {});
109
109
  const modelInfo = GitHubCopilotModels_1.GitHubCopilotModelsManager.getModelByValue(model);
110
110
  const credentials = await this.getCredentials('gitHubApiManual');
111
+ const token = credentials.accessToken;
112
+ if (!token) {
113
+ throw new Error('GitHub Copilot: No access token found in credentials');
114
+ }
115
+ if (!token.startsWith('gho_')) {
116
+ const tokenPrefix = token.substring(0, token.indexOf('_') + 1) || token.substring(0, 4);
117
+ const tokenSuffix = token.length > 5 ? token.substring(token.length - 5) : token;
118
+ console.error(`❌ GitHub Copilot Auth Debug: Invalid token format. Got: ${tokenPrefix}...${tokenSuffix}`);
119
+ throw new Error(`GitHub Copilot API requires GitHub Copilot tokens (gho_*). ` +
120
+ `Received token with prefix: ${tokenPrefix}...${tokenSuffix}. ` +
121
+ `Personal Access Tokens (ghp_*) and other formats are not supported. ` +
122
+ `Please obtain a GitHub Copilot access token from your organization.`);
123
+ }
124
+ const tokenPrefix = token.substring(0, token.indexOf('_') + 1);
125
+ const tokenSuffix = token.substring(token.length - 5);
126
+ console.log(`🔍 GitHub Copilot Auth Debug: Using token ${tokenPrefix}...${tokenSuffix}`);
111
127
  const safeModel = modelInfo ? model : GitHubCopilotModels_1.DEFAULT_MODELS.GENERAL;
112
128
  const safeModelInfo = modelInfo || GitHubCopilotModels_1.GitHubCopilotModelsManager.getModelByValue(GitHubCopilotModels_1.DEFAULT_MODELS.GENERAL);
113
129
  const modelConfig = {
@@ -117,7 +133,7 @@ class GitHubCopilotChatModel {
117
133
  topP: options.topP || 1,
118
134
  configuration: {
119
135
  baseURL: 'https://api.githubcopilot.com',
120
- apiKey: credentials.accessToken,
136
+ apiKey: token,
121
137
  defaultHeaders: {
122
138
  'User-Agent': 'n8n-github-copilot-chat-model',
123
139
  'Accept': 'application/json',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.6.2",
3
+ "version": "3.8.0",
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",
@@ -16,9 +16,9 @@
16
16
  "scripts": {
17
17
  "build": "tsc && gulp build:icons",
18
18
  "dev": "tsc --watch",
19
- "format": "prettier nodes credentials --write",
20
- "lint": "eslint nodes credentials package.json",
21
- "lintfix": "eslint nodes credentials package.json --fix",
19
+ "format": "prettier nodes --write",
20
+ "lint": "eslint nodes package.json",
21
+ "lintfix": "eslint nodes package.json --fix",
22
22
  "prepublishOnly": "npm run build && npm run lint -s"
23
23
  },
24
24
  "files": [
@@ -26,10 +26,7 @@
26
26
  ],
27
27
  "n8n": {
28
28
  "n8nNodesApiVersion": 1,
29
- "credentials": [
30
- "dist/credentials/GitHubApi.credentials.js",
31
- "dist/credentials/GitHubApiManual.credentials.js"
32
- ],
29
+ "credentials": [],
33
30
  "nodes": [
34
31
  "dist/nodes/GitHubCopilot/GitHubCopilot.node.js",
35
32
  "dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js",