n8n-nodes-github-copilot 3.27.6 → 3.28.1

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.
Files changed (37) hide show
  1. package/dist/credentials/GitHubCopilotApi.credentials.d.ts +1 -1
  2. package/dist/credentials/GitHubCopilotApi.credentials.js +19 -19
  3. package/dist/credentials/GitHubCopilotOAuth2Api.credentials.backup.d.ts +1 -1
  4. package/dist/credentials/GitHubCopilotOAuth2Api.credentials.backup.js +71 -71
  5. package/dist/credentials/GitHubCopilotOAuth2Api.credentials.d.ts +1 -1
  6. package/dist/credentials/GitHubCopilotOAuth2Api.credentials.js +67 -67
  7. package/dist/credentials/GitHubCopilotOAuth2Api.credentials.oauth.d.ts +1 -1
  8. package/dist/credentials/GitHubCopilotOAuth2Api.credentials.oauth.js +38 -38
  9. package/dist/nodes/GitHubCopilot/GitHubCopilot.node.d.ts +1 -1
  10. package/dist/nodes/GitHubCopilot/GitHubCopilot.node.js +188 -181
  11. package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.d.ts +1 -1
  12. package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js +38 -38
  13. package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.d.ts +1 -1
  14. package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.js +97 -97
  15. package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.d.ts +2 -2
  16. package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.js +16 -15
  17. package/dist/nodes/GitHubCopilotChatAPI/utils/index.d.ts +3 -3
  18. package/dist/nodes/GitHubCopilotChatAPI/utils/mediaDetection.d.ts +3 -3
  19. package/dist/nodes/GitHubCopilotChatAPI/utils/mediaDetection.js +20 -26
  20. package/dist/nodes/GitHubCopilotChatAPI/utils/modelCapabilities.d.ts +1 -1
  21. package/dist/nodes/GitHubCopilotChatAPI/utils/modelCapabilities.js +24 -24
  22. package/dist/nodes/GitHubCopilotChatAPI/utils/types.d.ts +4 -4
  23. package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.d.ts +1 -1
  24. package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js +86 -82
  25. package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.d.ts +5 -0
  26. package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.js +142 -0
  27. package/dist/nodes/GitHubCopilotOpenAI/nodeProperties.d.ts +2 -0
  28. package/dist/nodes/GitHubCopilotOpenAI/nodeProperties.js +326 -0
  29. package/dist/nodes/GitHubCopilotOpenAI/utils/index.d.ts +2 -0
  30. package/dist/nodes/GitHubCopilotOpenAI/utils/index.js +24 -0
  31. package/dist/nodes/GitHubCopilotOpenAI/utils/openaiCompat.d.ts +95 -0
  32. package/dist/nodes/GitHubCopilotOpenAI/utils/openaiCompat.js +175 -0
  33. package/dist/nodes/GitHubCopilotOpenAI/utils/types.d.ts +101 -0
  34. package/dist/nodes/GitHubCopilotOpenAI/utils/types.js +2 -0
  35. package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.d.ts +1 -1
  36. package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.js +96 -94
  37. package/package.json +77 -74
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapOpenAIModelToCopilot = mapOpenAIModelToCopilot;
4
+ exports.convertOpenAIMessagesToCopilot = convertOpenAIMessagesToCopilot;
5
+ exports.convertCopilotResponseToOpenAI = convertCopilotResponseToOpenAI;
6
+ exports.parseOpenAIRequest = parseOpenAIRequest;
7
+ exports.debugLog = debugLog;
8
+ function mapOpenAIModelToCopilot(openaiModel) {
9
+ const modelMappings = {
10
+ "gpt-4": "gpt-4o",
11
+ "gpt-4o": "gpt-4o",
12
+ "gpt-4o-mini": "gpt-4o-mini",
13
+ "gpt-4-turbo": "gpt-4o",
14
+ "gpt-3.5-turbo": "gpt-4o-mini",
15
+ "claude-3-5-sonnet": "claude-3.5-sonnet",
16
+ "claude-3-haiku": "claude-3-haiku",
17
+ "claude-3-opus": "claude-3-opus",
18
+ "gemini-1.5-pro": "gemini-1.5-pro",
19
+ "gemini-1.5-flash": "gemini-1.5-flash",
20
+ "o1-preview": "o1-preview",
21
+ "o1-mini": "o1-mini",
22
+ };
23
+ return modelMappings[openaiModel] || "gpt-4o";
24
+ }
25
+ function convertOpenAIMessagesToCopilot(messages) {
26
+ let systemMessage = "";
27
+ const userMessages = [];
28
+ const assistantMessages = [];
29
+ for (const msg of messages) {
30
+ switch (msg.role) {
31
+ case "system":
32
+ systemMessage += (systemMessage ? "\n\n" : "") + msg.content;
33
+ break;
34
+ case "user":
35
+ userMessages.push(msg.content);
36
+ break;
37
+ case "assistant":
38
+ assistantMessages.push(msg.content);
39
+ break;
40
+ }
41
+ }
42
+ let conversationContext = "";
43
+ const maxLength = Math.max(userMessages.length, assistantMessages.length);
44
+ for (let i = 0; i < maxLength - 1; i++) {
45
+ if (i < userMessages.length - 1) {
46
+ conversationContext += `User: ${userMessages[i]}\n`;
47
+ }
48
+ if (i < assistantMessages.length) {
49
+ conversationContext += `Assistant: ${assistantMessages[i]}\n`;
50
+ }
51
+ }
52
+ const finalUserMessage = userMessages[userMessages.length - 1] || "";
53
+ const message = conversationContext
54
+ ? `${conversationContext}\nUser: ${finalUserMessage}`
55
+ : finalUserMessage;
56
+ return {
57
+ message,
58
+ system_message: systemMessage || undefined,
59
+ };
60
+ }
61
+ function convertCopilotResponseToOpenAI(copilotResponse, model) {
62
+ const timestamp = Math.floor(Date.now() / 1000);
63
+ return {
64
+ id: `chatcmpl-${timestamp}-${Math.random().toString(36).substr(2, 9)}`,
65
+ object: "chat.completion",
66
+ created: timestamp,
67
+ model: model,
68
+ choices: [
69
+ {
70
+ index: 0,
71
+ message: {
72
+ role: "assistant",
73
+ content: copilotResponse.message,
74
+ tool_calls: copilotResponse.tool_calls,
75
+ },
76
+ finish_reason: mapFinishReason(copilotResponse.finish_reason),
77
+ },
78
+ ],
79
+ usage: {
80
+ prompt_tokens: copilotResponse.usage.prompt_tokens,
81
+ completion_tokens: copilotResponse.usage.completion_tokens,
82
+ total_tokens: copilotResponse.usage.total_tokens,
83
+ },
84
+ };
85
+ }
86
+ function mapFinishReason(copilotReason) {
87
+ switch (copilotReason) {
88
+ case "stop":
89
+ case "end_turn":
90
+ return "stop";
91
+ case "max_tokens":
92
+ case "length":
93
+ return "length";
94
+ case "tool_calls":
95
+ case "function_call":
96
+ return "tool_calls";
97
+ case "content_filter":
98
+ case "safety":
99
+ return "content_filter";
100
+ default:
101
+ return "stop";
102
+ }
103
+ }
104
+ function parseOpenAIRequest(context, itemIndex) {
105
+ const model = context.getNodeParameter("model", itemIndex, "gpt-4o");
106
+ const messagesParam = context.getNodeParameter("messages", itemIndex, {
107
+ message: [],
108
+ });
109
+ const tools = context.getNodeParameter("tools", itemIndex, "");
110
+ const toolChoice = context.getNodeParameter("tool_choice", itemIndex, "auto");
111
+ const responseFormat = context.getNodeParameter("response_format", itemIndex, "text");
112
+ const temperature = context.getNodeParameter("temperature", itemIndex, 1);
113
+ const maxTokens = context.getNodeParameter("max_tokens", itemIndex, "");
114
+ const topP = context.getNodeParameter("top_p", itemIndex, 1);
115
+ const frequencyPenalty = context.getNodeParameter("frequency_penalty", itemIndex, 0);
116
+ const presencePenalty = context.getNodeParameter("presence_penalty", itemIndex, 0);
117
+ const stop = context.getNodeParameter("stop", itemIndex, "");
118
+ const stream = context.getNodeParameter("stream", itemIndex, false);
119
+ const seed = context.getNodeParameter("seed", itemIndex, "");
120
+ const user = context.getNodeParameter("user", itemIndex, "");
121
+ const messages = [];
122
+ if (messagesParam.message && Array.isArray(messagesParam.message)) {
123
+ for (const msg of messagesParam.message) {
124
+ messages.push({
125
+ role: msg.role,
126
+ content: msg.content,
127
+ });
128
+ }
129
+ }
130
+ const request = {
131
+ model,
132
+ messages,
133
+ temperature,
134
+ top_p: topP,
135
+ frequency_penalty: frequencyPenalty,
136
+ presence_penalty: presencePenalty,
137
+ stream,
138
+ };
139
+ if (tools) {
140
+ try {
141
+ request.tools = JSON.parse(tools);
142
+ request.tool_choice = toolChoice;
143
+ }
144
+ catch (error) {
145
+ throw new Error(`Invalid tools JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
146
+ }
147
+ }
148
+ if (responseFormat !== "text") {
149
+ request.response_format = { type: responseFormat };
150
+ }
151
+ if (maxTokens) {
152
+ request.max_tokens = maxTokens;
153
+ }
154
+ if (stop) {
155
+ try {
156
+ request.stop = JSON.parse(stop);
157
+ }
158
+ catch {
159
+ request.stop = stop;
160
+ }
161
+ }
162
+ if (seed) {
163
+ request.seed = seed;
164
+ }
165
+ if (user) {
166
+ request.user = user;
167
+ }
168
+ return request;
169
+ }
170
+ function debugLog(context, itemIndex, message, data) {
171
+ const advancedOptions = context.getNodeParameter("advancedOptions", itemIndex, {});
172
+ if (advancedOptions.debugMode) {
173
+ console.log(`[GitHub Copilot OpenAI Debug] ${message}`, data ? JSON.stringify(data, null, 2) : "");
174
+ }
175
+ }
@@ -0,0 +1,101 @@
1
+ import { IDataObject, IExecuteFunctions } from "n8n-workflow";
2
+ import { CopilotResponse } from "../../../shared/utils/GitHubCopilotApiUtils";
3
+ export { CopilotResponse };
4
+ export interface OpenAIMessage {
5
+ role: "system" | "user" | "assistant" | "tool";
6
+ content: string;
7
+ name?: string;
8
+ tool_calls?: ToolCall[];
9
+ tool_call_id?: string;
10
+ }
11
+ export interface ToolCall {
12
+ id: string;
13
+ type: "function";
14
+ function: {
15
+ name: string;
16
+ arguments: string;
17
+ };
18
+ }
19
+ export interface OpenAITool {
20
+ type: "function";
21
+ function: {
22
+ name: string;
23
+ description: string;
24
+ parameters: IDataObject;
25
+ };
26
+ }
27
+ export interface OpenAIRequest {
28
+ model: string;
29
+ messages: OpenAIMessage[];
30
+ tools?: OpenAITool[];
31
+ tool_choice?: "auto" | "none" | "required" | {
32
+ type: "function";
33
+ function: {
34
+ name: string;
35
+ };
36
+ };
37
+ response_format?: {
38
+ type: "text" | "json_object";
39
+ };
40
+ temperature?: number;
41
+ max_tokens?: number;
42
+ top_p?: number;
43
+ frequency_penalty?: number;
44
+ presence_penalty?: number;
45
+ stop?: string | string[];
46
+ stream?: boolean;
47
+ seed?: number;
48
+ user?: string;
49
+ }
50
+ export interface OpenAIResponse {
51
+ id: string;
52
+ object: "chat.completion";
53
+ created: number;
54
+ model: string;
55
+ choices: Array<{
56
+ index: number;
57
+ message: {
58
+ role: "assistant";
59
+ content: string | null;
60
+ tool_calls?: ToolCall[];
61
+ };
62
+ finish_reason: "stop" | "length" | "tool_calls" | "content_filter";
63
+ }>;
64
+ usage: {
65
+ prompt_tokens: number;
66
+ completion_tokens: number;
67
+ total_tokens: number;
68
+ };
69
+ }
70
+ export interface FileProcessOptions {
71
+ context: IExecuteFunctions;
72
+ itemIndex: number;
73
+ source: "manual" | "url" | "binary";
74
+ filePath?: string;
75
+ url?: string;
76
+ binaryProperty?: string;
77
+ }
78
+ export interface ProcessedFileResult {
79
+ data: string;
80
+ mimeType: string;
81
+ filename: string;
82
+ size: number;
83
+ estimatedTokens: number;
84
+ }
85
+ export interface OptimizationOptions {
86
+ maxWidth?: number;
87
+ maxHeight?: number;
88
+ quality?: number;
89
+ maxSizeKB?: number;
90
+ }
91
+ export interface ModelCapabilities {
92
+ supportsImages: boolean;
93
+ supportsAudio: boolean;
94
+ maxContextTokens: number;
95
+ description: string;
96
+ }
97
+ export interface ModelValidationResult {
98
+ isValid: boolean;
99
+ errorMessage?: string;
100
+ warnings?: string[];
101
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from "n8n-workflow";
2
2
  export declare class GitHubCopilotTest implements INodeType {
3
3
  description: INodeTypeDescription;
4
4
  execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;