n8n-nodes-github-copilot 3.38.20 → 3.38.22

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.
@@ -7,6 +7,53 @@ const GitHubCopilotEndpoints_1 = require("../../shared/utils/GitHubCopilotEndpoi
7
7
  const DynamicModelLoader_1 = require("../../shared/models/DynamicModelLoader");
8
8
  const ModelProperties_1 = require("../../shared/properties/ModelProperties");
9
9
  const ModelVersionRequirements_1 = require("../../shared/models/ModelVersionRequirements");
10
+ const GitHubCopilotApiUtils_1 = require("../../shared/utils/GitHubCopilotApiUtils");
11
+ class GitHubCopilotChatOpenAI extends openai_1.ChatOpenAI {
12
+ constructor(context, options, config) {
13
+ super(config);
14
+ this.context = context;
15
+ this.options = options;
16
+ }
17
+ async _generate(messages, options) {
18
+ const copilotMessages = messages.map(msg => ({
19
+ role: msg._getType(),
20
+ content: typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content),
21
+ }));
22
+ const requestBody = {
23
+ model: this.modelName || this.model,
24
+ messages: copilotMessages,
25
+ temperature: this.temperature,
26
+ max_tokens: this.maxTokens,
27
+ top_p: this.topP,
28
+ stream: false,
29
+ };
30
+ if (this.options.tools && this.options.tools.length > 0) {
31
+ requestBody.tools = this.options.tools;
32
+ requestBody.tool_choice = this.options.tool_choice || "auto";
33
+ }
34
+ try {
35
+ const response = await (0, GitHubCopilotApiUtils_1.makeGitHubCopilotRequest)(this.context, GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ENDPOINTS.CHAT_COMPLETIONS, requestBody, false);
36
+ const choice = response.choices[0];
37
+ const langchainMessage = {
38
+ _getType: () => choice.message.role,
39
+ content: choice.message.content || "",
40
+ tool_calls: choice.message.tool_calls,
41
+ };
42
+ return {
43
+ generations: [{
44
+ text: choice.message.content || "",
45
+ message: langchainMessage,
46
+ }],
47
+ llmOutput: {
48
+ tokenUsage: response.usage,
49
+ },
50
+ };
51
+ }
52
+ catch (error) {
53
+ throw new Error(`GitHub Copilot API error: ${error instanceof Error ? error.message : String(error)}`);
54
+ }
55
+ }
56
+ }
10
57
  class GitHubCopilotChatModel {
11
58
  constructor() {
12
59
  this.description = {
@@ -15,7 +62,7 @@ class GitHubCopilotChatModel {
15
62
  icon: "file:../../shared/icons/copilot.svg",
16
63
  group: ["transform"],
17
64
  version: 1,
18
- description: "GitHub Copilot chat model for AI workflows - access GPT-5, Claude, Gemini and more using your Copilot subscription",
65
+ description: "GitHub Copilot chat model for AI workflows with full support for tools and function calling - access GPT-5, Claude, Gemini and more using your Copilot subscription",
19
66
  defaults: {
20
67
  name: "GitHub Copilot Chat Model",
21
68
  },
@@ -114,6 +161,46 @@ class GitHubCopilotChatModel {
114
161
  },
115
162
  },
116
163
  },
164
+ {
165
+ displayName: "Tools (Function Calling)",
166
+ name: "tools",
167
+ type: "string",
168
+ default: "",
169
+ description: "Optional: Array of tools/functions available to the model (OpenAI format). Leave empty if not using function calling.",
170
+ hint: "JSON array of tool definitions in OpenAI format. Leave this field empty if you don't need function calling.",
171
+ typeOptions: {
172
+ rows: 6,
173
+ },
174
+ },
175
+ {
176
+ displayName: "Tool Choice",
177
+ name: "tool_choice",
178
+ type: "options",
179
+ options: [
180
+ {
181
+ name: "Auto",
182
+ value: "auto",
183
+ description: "Let the model decide when to use tools",
184
+ },
185
+ {
186
+ name: "Required",
187
+ value: "required",
188
+ description: "Force the model to use at least one tool",
189
+ },
190
+ {
191
+ name: "None",
192
+ value: "none",
193
+ description: "Disable tool usage",
194
+ },
195
+ ],
196
+ default: "auto",
197
+ description: "Control how the model uses tools",
198
+ displayOptions: {
199
+ show: {
200
+ tools: ["/.+/"],
201
+ },
202
+ },
203
+ },
117
204
  ],
118
205
  },
119
206
  ],
@@ -161,12 +248,32 @@ class GitHubCopilotChatModel {
161
248
  const minVSCodeVersion = (0, ModelVersionRequirements_1.getMinVSCodeVersion)(safeModel);
162
249
  const additionalHeaders = (0, ModelVersionRequirements_1.getAdditionalHeaders)(safeModel);
163
250
  console.log(`🔧 Model: ${safeModel} requires VS Code version: ${minVSCodeVersion}`);
251
+ let parsedTools = [];
252
+ if (options.tools && options.tools.trim()) {
253
+ try {
254
+ const parsed = JSON.parse(options.tools);
255
+ if (Array.isArray(parsed) && parsed.length > 0) {
256
+ parsedTools = parsed;
257
+ console.log(`🔧 Parsed ${parsedTools.length} tools for function calling`);
258
+ }
259
+ else {
260
+ console.log(`⚠️ Tools field parsed but not a valid array`);
261
+ }
262
+ }
263
+ catch (error) {
264
+ console.log(`⚠️ Failed to parse tools JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
265
+ }
266
+ }
164
267
  const modelConfig = {
165
268
  model: safeModel,
166
269
  temperature: options.temperature || 0.7,
167
270
  maxTokens: Math.min(options.maxTokens || 1000, (safeModelInfo === null || safeModelInfo === void 0 ? void 0 : safeModelInfo.capabilities.maxOutputTokens) || 4096),
168
271
  topP: options.topP || 1,
169
272
  maxRetries: options.enableRetry !== false ? options.maxRetries || 3 : 0,
273
+ ...(parsedTools.length > 0 && {
274
+ tools: parsedTools,
275
+ tool_choice: options.tool_choice || "auto",
276
+ }),
170
277
  configuration: {
171
278
  baseURL: GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.BASE_URL,
172
279
  apiKey: token,
@@ -185,7 +292,7 @@ class GitHubCopilotChatModel {
185
292
  },
186
293
  },
187
294
  };
188
- const chatModel = new openai_1.ChatOpenAI(modelConfig);
295
+ const chatModel = new GitHubCopilotChatOpenAI(this, options, modelConfig);
189
296
  return {
190
297
  response: chatModel,
191
298
  };
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.38.20",
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",
3
+ "version": "3.38.22",
4
+ "description": "n8n community node for GitHub Copilot with CLI integration, Chat API access, and AI Chat Model for workflows with full tools and function calling support - 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",
7
7
  "author": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.38.20",
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",
3
+ "version": "3.38.22",
4
+ "description": "n8n community node for GitHub Copilot with CLI integration, Chat API access, and AI Chat Model for workflows with full tools and function calling support - 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",
7
7
  "author": {