n8n-nodes-github-copilot 4.3.0 → 4.4.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/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.d.ts +1 -0
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js +47 -15
- package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.js +37 -0
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.d.ts +1 -0
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js +174 -10
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.d.ts +1 -0
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.js +65 -4
- package/dist/nodes/GitHubCopilotOpenAI/nodeProperties.js +64 -27
- package/dist/package.json +3 -4
- package/dist/shared/models/DynamicModelLoader.d.ts +1 -0
- package/dist/shared/models/DynamicModelLoader.js +12 -0
- package/dist/shared/models/GitHubCopilotModels.d.ts +14 -8
- package/dist/shared/models/GitHubCopilotModels.js +255 -74
- package/dist/shared/utils/DynamicModelsManager.d.ts +11 -0
- package/dist/shared/utils/DynamicModelsManager.js +50 -0
- package/dist/shared/utils/GitHubCopilotApiUtils.d.ts +1 -0
- package/dist/shared/utils/GitHubCopilotApiUtils.js +85 -6
- package/package.json +3 -4
- package/shared/icons/copilot.svg +0 -34
- package/shared/index.ts +0 -27
- package/shared/models/DynamicModelLoader.ts +0 -124
- package/shared/models/GitHubCopilotModels.ts +0 -420
- package/shared/models/ModelVersionRequirements.ts +0 -165
- package/shared/properties/ModelProperties.ts +0 -52
- package/shared/properties/ModelSelectionProperty.ts +0 -68
- package/shared/utils/DynamicModelsManager.ts +0 -355
- package/shared/utils/EmbeddingsApiUtils.ts +0 -135
- package/shared/utils/FileChunkingApiUtils.ts +0 -176
- package/shared/utils/FileOptimizationUtils.ts +0 -210
- package/shared/utils/GitHubCopilotApiUtils.ts +0 -407
- package/shared/utils/GitHubCopilotEndpoints.ts +0 -212
- package/shared/utils/GitHubDeviceFlowHandler.ts +0 -276
- package/shared/utils/OAuthTokenManager.ts +0 -196
- package/shared/utils/provider-injection.ts +0 -277
- package/shared/utils/version-detection.ts +0 -145
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitHub Copilot Provider Runtime Injection
|
|
3
|
-
*
|
|
4
|
-
* Dynamically injects GitHub Copilot as a Chat Hub provider in n8n v2+.
|
|
5
|
-
* This allows GitHub Copilot to appear in the providers list without modifying n8n core.
|
|
6
|
-
*
|
|
7
|
-
* ⚠️ WARNING: This is advanced runtime modification and may break with n8n updates.
|
|
8
|
-
* Use at your own risk and test thoroughly after n8n upgrades.
|
|
9
|
-
*
|
|
10
|
-
* @module provider-injection
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { isChatHubAvailable, isN8nV2OrHigher, getN8nVersionString } from './version-detection';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Provider injection status
|
|
17
|
-
*/
|
|
18
|
-
export interface ProviderInjectionStatus {
|
|
19
|
-
/** Whether injection was attempted */
|
|
20
|
-
attempted: boolean;
|
|
21
|
-
/** Whether injection was successful */
|
|
22
|
-
success: boolean;
|
|
23
|
-
/** n8n version detected */
|
|
24
|
-
n8nVersion: string;
|
|
25
|
-
/** Whether Chat Hub is available */
|
|
26
|
-
chatHubAvailable: boolean;
|
|
27
|
-
/** Error message if injection failed */
|
|
28
|
-
error?: string;
|
|
29
|
-
/** List of modifications made */
|
|
30
|
-
modifications: string[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let injectionStatus: ProviderInjectionStatus | null = null;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Inject GitHub Copilot provider into n8n Chat Hub
|
|
37
|
-
*
|
|
38
|
-
* Only runs if n8n v2+ is detected and Chat Hub is available.
|
|
39
|
-
* Safe to call multiple times - will only inject once.
|
|
40
|
-
*
|
|
41
|
-
* @param options - Injection options
|
|
42
|
-
* @returns Injection status
|
|
43
|
-
*/
|
|
44
|
-
export function injectGitHubCopilotProvider(options: {
|
|
45
|
-
/** Enable debug logging */
|
|
46
|
-
debug?: boolean;
|
|
47
|
-
/** Force injection even if already done */
|
|
48
|
-
force?: boolean;
|
|
49
|
-
} = {}): ProviderInjectionStatus {
|
|
50
|
-
const { debug = false, force = false } = options;
|
|
51
|
-
|
|
52
|
-
// Return cached status if already injected (unless force=true)
|
|
53
|
-
if (injectionStatus && !force) {
|
|
54
|
-
if (debug) {
|
|
55
|
-
console.log('[GitHub Copilot] Provider already injected:', injectionStatus);
|
|
56
|
-
}
|
|
57
|
-
return injectionStatus;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Initialize status
|
|
61
|
-
const status: ProviderInjectionStatus = {
|
|
62
|
-
attempted: true,
|
|
63
|
-
success: false,
|
|
64
|
-
n8nVersion: getN8nVersionString(),
|
|
65
|
-
chatHubAvailable: false,
|
|
66
|
-
modifications: [],
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
// Check if running in n8n v2+
|
|
71
|
-
if (!isN8nV2OrHigher()) {
|
|
72
|
-
status.error = `n8n v2+ required. Detected: ${status.n8nVersion}`;
|
|
73
|
-
if (debug) {
|
|
74
|
-
console.log('[GitHub Copilot] Skipping injection:', status.error);
|
|
75
|
-
}
|
|
76
|
-
injectionStatus = status;
|
|
77
|
-
return status;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Check if Chat Hub is available
|
|
81
|
-
if (!isChatHubAvailable()) {
|
|
82
|
-
status.error = 'Chat Hub APIs not available';
|
|
83
|
-
if (debug) {
|
|
84
|
-
console.log('[GitHub Copilot] Skipping injection:', status.error);
|
|
85
|
-
}
|
|
86
|
-
injectionStatus = status;
|
|
87
|
-
return status;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
status.chatHubAvailable = true;
|
|
91
|
-
|
|
92
|
-
// Perform injection
|
|
93
|
-
injectIntoApiTypes(status, debug);
|
|
94
|
-
injectIntoConstants(status, debug);
|
|
95
|
-
injectIntoFrontend(status, debug);
|
|
96
|
-
|
|
97
|
-
// Mark as successful if at least one modification was made
|
|
98
|
-
status.success = status.modifications.length > 0;
|
|
99
|
-
|
|
100
|
-
if (debug) {
|
|
101
|
-
console.log('[GitHub Copilot] Provider injection completed:', status);
|
|
102
|
-
}
|
|
103
|
-
} catch (error) {
|
|
104
|
-
status.error = error instanceof Error ? error.message : String(error);
|
|
105
|
-
if (debug) {
|
|
106
|
-
console.error('[GitHub Copilot] Provider injection failed:', error);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
injectionStatus = status;
|
|
111
|
-
return status;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Inject into @n8n/api-types
|
|
116
|
-
*/
|
|
117
|
-
function injectIntoApiTypes(status: ProviderInjectionStatus, debug: boolean): void {
|
|
118
|
-
try {
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
120
|
-
const apiTypes = require('@n8n/api-types');
|
|
121
|
-
|
|
122
|
-
// Inject into provider schema enum
|
|
123
|
-
if (apiTypes.chatHubLLMProviderSchema?._def?.values) {
|
|
124
|
-
const values = apiTypes.chatHubLLMProviderSchema._def.values;
|
|
125
|
-
if (!values.includes('githubCopilot')) {
|
|
126
|
-
values.push('githubCopilot');
|
|
127
|
-
status.modifications.push('Added githubCopilot to chatHubLLMProviderSchema');
|
|
128
|
-
if (debug) {
|
|
129
|
-
console.log('[GitHub Copilot] ✓ Injected into chatHubLLMProviderSchema');
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Inject into credential type map
|
|
135
|
-
if (apiTypes.PROVIDER_CREDENTIAL_TYPE_MAP) {
|
|
136
|
-
if (!apiTypes.PROVIDER_CREDENTIAL_TYPE_MAP.githubCopilot) {
|
|
137
|
-
apiTypes.PROVIDER_CREDENTIAL_TYPE_MAP.githubCopilot = 'gitHubCopilotApi';
|
|
138
|
-
status.modifications.push('Added githubCopilot to PROVIDER_CREDENTIAL_TYPE_MAP');
|
|
139
|
-
if (debug) {
|
|
140
|
-
console.log('[GitHub Copilot] ✓ Injected into PROVIDER_CREDENTIAL_TYPE_MAP');
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Inject into empty chat models response
|
|
146
|
-
if (apiTypes.emptyChatModelsResponse) {
|
|
147
|
-
if (!apiTypes.emptyChatModelsResponse.githubCopilot) {
|
|
148
|
-
apiTypes.emptyChatModelsResponse.githubCopilot = { models: [] };
|
|
149
|
-
status.modifications.push('Added githubCopilot to emptyChatModelsResponse');
|
|
150
|
-
if (debug) {
|
|
151
|
-
console.log('[GitHub Copilot] ✓ Injected into emptyChatModelsResponse');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
} catch (error) {
|
|
156
|
-
if (debug) {
|
|
157
|
-
console.warn('[GitHub Copilot] Failed to inject into @n8n/api-types:', error);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Inject into chat-hub.constants.ts
|
|
164
|
-
*/
|
|
165
|
-
function injectIntoConstants(status: ProviderInjectionStatus, debug: boolean): void {
|
|
166
|
-
try {
|
|
167
|
-
// Try to require the constants module
|
|
168
|
-
// This path may vary depending on n8n installation
|
|
169
|
-
const possiblePaths = [
|
|
170
|
-
'@n8n/cli/dist/modules/chat-hub/chat-hub.constants',
|
|
171
|
-
'n8n/dist/modules/chat-hub/chat-hub.constants',
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
let constants: any = null;
|
|
175
|
-
for (const path of possiblePaths) {
|
|
176
|
-
try {
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
178
|
-
constants = require(path);
|
|
179
|
-
if (constants.PROVIDER_NODE_TYPE_MAP) {
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
} catch {
|
|
183
|
-
// Try next path
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (!constants) {
|
|
189
|
-
if (debug) {
|
|
190
|
-
console.warn('[GitHub Copilot] Could not find chat-hub.constants module');
|
|
191
|
-
}
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Inject into provider node type map
|
|
196
|
-
if (constants.PROVIDER_NODE_TYPE_MAP) {
|
|
197
|
-
if (!constants.PROVIDER_NODE_TYPE_MAP.githubCopilot) {
|
|
198
|
-
constants.PROVIDER_NODE_TYPE_MAP.githubCopilot = 'n8n-nodes-copilot.gitHubCopilotChatModel';
|
|
199
|
-
status.modifications.push('Added githubCopilot to PROVIDER_NODE_TYPE_MAP');
|
|
200
|
-
if (debug) {
|
|
201
|
-
console.log('[GitHub Copilot] ✓ Injected into PROVIDER_NODE_TYPE_MAP');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
} catch (error) {
|
|
206
|
-
if (debug) {
|
|
207
|
-
console.warn('[GitHub Copilot] Failed to inject into constants:', error);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Inject into frontend constants
|
|
214
|
-
*/
|
|
215
|
-
function injectIntoFrontend(status: ProviderInjectionStatus, debug: boolean): void {
|
|
216
|
-
try {
|
|
217
|
-
// Frontend injection is more complex as it's browser-side code
|
|
218
|
-
// We need to inject via window global or store mutation
|
|
219
|
-
if (typeof globalThis !== 'undefined' && (globalThis as any).window) {
|
|
220
|
-
// Running in browser context
|
|
221
|
-
// Try to inject via Vue store or global state
|
|
222
|
-
const win = (globalThis as any).window;
|
|
223
|
-
|
|
224
|
-
// Look for n8n's Vue store
|
|
225
|
-
if (win.__VUE_DEVTOOLS_GLOBAL_HOOK__?.store) {
|
|
226
|
-
// Store mutation would go here
|
|
227
|
-
// This is highly dependent on n8n's internal structure
|
|
228
|
-
if (debug) {
|
|
229
|
-
console.log('[GitHub Copilot] Browser context detected, but store injection not yet implemented');
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
} else {
|
|
233
|
-
if (debug) {
|
|
234
|
-
console.log('[GitHub Copilot] Not in browser context, skipping frontend injection');
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
} catch (error) {
|
|
238
|
-
if (debug) {
|
|
239
|
-
console.warn('[GitHub Copilot] Failed to inject into frontend:', error);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Get current injection status
|
|
246
|
-
*
|
|
247
|
-
* @returns Current injection status or null if not attempted
|
|
248
|
-
*/
|
|
249
|
-
export function getInjectionStatus(): ProviderInjectionStatus | null {
|
|
250
|
-
return injectionStatus;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Check if provider injection is active
|
|
255
|
-
*
|
|
256
|
-
* @returns True if GitHub Copilot provider is injected and active
|
|
257
|
-
*/
|
|
258
|
-
export function isProviderInjected(): boolean {
|
|
259
|
-
return injectionStatus?.success ?? false;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Initialize provider injection automatically on module load (if enabled)
|
|
264
|
-
*
|
|
265
|
-
* Set environment variable GITHUB_COPILOT_AUTO_INJECT=true to enable
|
|
266
|
-
*/
|
|
267
|
-
export function autoInject(): void {
|
|
268
|
-
const autoInjectEnabled = process.env.GITHUB_COPILOT_AUTO_INJECT === 'true';
|
|
269
|
-
const debugEnabled = process.env.GITHUB_COPILOT_DEBUG === 'true';
|
|
270
|
-
|
|
271
|
-
if (autoInjectEnabled) {
|
|
272
|
-
if (debugEnabled) {
|
|
273
|
-
console.log('[GitHub Copilot] Auto-injection enabled');
|
|
274
|
-
}
|
|
275
|
-
injectGitHubCopilotProvider({ debug: debugEnabled });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* n8n Version Detection Utility
|
|
3
|
-
*
|
|
4
|
-
* Detects the n8n version to enable conditional features.
|
|
5
|
-
* Used to enable Chat Hub provider injection only in n8n v2+.
|
|
6
|
-
*
|
|
7
|
-
* @module version-detection
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Detected n8n version information
|
|
12
|
-
*/
|
|
13
|
-
export interface N8nVersionInfo {
|
|
14
|
-
/** Full version string (e.g., "2.15.3") */
|
|
15
|
-
version: string;
|
|
16
|
-
/** Major version number (e.g., 2) */
|
|
17
|
-
major: number;
|
|
18
|
-
/** Minor version number (e.g., 15) */
|
|
19
|
-
minor: number;
|
|
20
|
-
/** Patch version number (e.g., 3) */
|
|
21
|
-
patch: number;
|
|
22
|
-
/** Whether this is n8n v2 or higher */
|
|
23
|
-
isV2OrHigher: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Attempts to detect n8n version from various sources
|
|
28
|
-
*
|
|
29
|
-
* @returns Detected version info or null if detection fails
|
|
30
|
-
*/
|
|
31
|
-
export function detectN8nVersion(): N8nVersionInfo | null {
|
|
32
|
-
try {
|
|
33
|
-
// Method 1: Try to import n8n-workflow package
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
35
|
-
const n8nWorkflow = require('n8n-workflow/package.json');
|
|
36
|
-
if (n8nWorkflow?.version) {
|
|
37
|
-
return parseVersionString(n8nWorkflow.version);
|
|
38
|
-
}
|
|
39
|
-
} catch (error) {
|
|
40
|
-
// n8n-workflow not found, try other methods
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
// Method 2: Try to get version from n8n global (if available in runtime)
|
|
45
|
-
// This works when running inside n8n
|
|
46
|
-
if (typeof global !== 'undefined' && (global as any).N8N_VERSION) {
|
|
47
|
-
return parseVersionString((global as any).N8N_VERSION);
|
|
48
|
-
}
|
|
49
|
-
} catch (error) {
|
|
50
|
-
// Global not available
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
// Method 3: Try to get from process environment
|
|
55
|
-
if (process.env.N8N_VERSION) {
|
|
56
|
-
return parseVersionString(process.env.N8N_VERSION);
|
|
57
|
-
}
|
|
58
|
-
} catch (error) {
|
|
59
|
-
// Environment variable not set
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
// Method 4: Check for n8n v2 specific APIs
|
|
64
|
-
// If Chat Hub APIs exist, it's likely v2
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
66
|
-
const apiTypes = require('@n8n/api-types');
|
|
67
|
-
if (apiTypes.chatHubLLMProviderSchema) {
|
|
68
|
-
// Chat Hub exists, assume v2.0.0 as minimum
|
|
69
|
-
return {
|
|
70
|
-
version: '2.0.0',
|
|
71
|
-
major: 2,
|
|
72
|
-
minor: 0,
|
|
73
|
-
patch: 0,
|
|
74
|
-
isV2OrHigher: true,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
// @n8n/api-types not available or doesn't have Chat Hub
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Detection failed
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Parse version string into structured format
|
|
87
|
-
*
|
|
88
|
-
* @param versionString - Version string like "2.15.3" or "v2.15.3"
|
|
89
|
-
* @returns Parsed version info
|
|
90
|
-
*/
|
|
91
|
-
function parseVersionString(versionString: string): N8nVersionInfo {
|
|
92
|
-
// Remove 'v' prefix if present
|
|
93
|
-
const cleanVersion = versionString.replace(/^v/, '');
|
|
94
|
-
|
|
95
|
-
// Split into parts
|
|
96
|
-
const parts = cleanVersion.split('.').map(p => parseInt(p, 10));
|
|
97
|
-
const [major = 0, minor = 0, patch = 0] = parts;
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
version: cleanVersion,
|
|
101
|
-
major,
|
|
102
|
-
minor,
|
|
103
|
-
patch,
|
|
104
|
-
isV2OrHigher: major >= 2,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Check if running in n8n v2 or higher
|
|
110
|
-
*
|
|
111
|
-
* @returns True if n8n v2+, false otherwise
|
|
112
|
-
*/
|
|
113
|
-
export function isN8nV2OrHigher(): boolean {
|
|
114
|
-
const versionInfo = detectN8nVersion();
|
|
115
|
-
return versionInfo?.isV2OrHigher ?? false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Check if Chat Hub feature is available
|
|
120
|
-
* This is more reliable than version detection for feature checking
|
|
121
|
-
*
|
|
122
|
-
* @returns True if Chat Hub APIs are available
|
|
123
|
-
*/
|
|
124
|
-
export function isChatHubAvailable(): boolean {
|
|
125
|
-
try {
|
|
126
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
127
|
-
const apiTypes = require('@n8n/api-types');
|
|
128
|
-
return !!(apiTypes.chatHubLLMProviderSchema && apiTypes.PROVIDER_CREDENTIAL_TYPE_MAP);
|
|
129
|
-
} catch (error) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Get n8n version info for logging/debugging
|
|
136
|
-
*
|
|
137
|
-
* @returns Version info string or "unknown"
|
|
138
|
-
*/
|
|
139
|
-
export function getN8nVersionString(): string {
|
|
140
|
-
const versionInfo = detectN8nVersion();
|
|
141
|
-
if (!versionInfo) {
|
|
142
|
-
return 'unknown';
|
|
143
|
-
}
|
|
144
|
-
return `${versionInfo.version} (v${versionInfo.major})`;
|
|
145
|
-
}
|