n8n-nodes-github-copilot 3.38.19 → 3.38.21

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.
@@ -15,7 +15,7 @@ class GitHubCopilotChatModel {
15
15
  icon: "file:../../shared/icons/copilot.svg",
16
16
  group: ["transform"],
17
17
  version: 1,
18
- description: "GitHub Copilot chat model for AI workflows - access GPT-5, Claude, Gemini and more using your Copilot subscription",
18
+ 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
19
  defaults: {
20
20
  name: "GitHub Copilot Chat Model",
21
21
  },
@@ -114,6 +114,46 @@ class GitHubCopilotChatModel {
114
114
  },
115
115
  },
116
116
  },
117
+ {
118
+ displayName: "Tools (Function Calling)",
119
+ name: "tools",
120
+ type: "string",
121
+ default: "",
122
+ description: "Optional: Array of tools/functions available to the model (OpenAI format). Leave empty if not using function calling.",
123
+ hint: "JSON array of tool definitions in OpenAI format. Leave this field empty if you don't need function calling.",
124
+ typeOptions: {
125
+ rows: 6,
126
+ },
127
+ },
128
+ {
129
+ displayName: "Tool Choice",
130
+ name: "tool_choice",
131
+ type: "options",
132
+ options: [
133
+ {
134
+ name: "Auto",
135
+ value: "auto",
136
+ description: "Let the model decide when to use tools",
137
+ },
138
+ {
139
+ name: "Required",
140
+ value: "required",
141
+ description: "Force the model to use at least one tool",
142
+ },
143
+ {
144
+ name: "None",
145
+ value: "none",
146
+ description: "Disable tool usage",
147
+ },
148
+ ],
149
+ default: "auto",
150
+ description: "Control how the model uses tools",
151
+ displayOptions: {
152
+ show: {
153
+ tools: ["/.+/"],
154
+ },
155
+ },
156
+ },
117
157
  ],
118
158
  },
119
159
  ],
@@ -161,12 +201,32 @@ class GitHubCopilotChatModel {
161
201
  const minVSCodeVersion = (0, ModelVersionRequirements_1.getMinVSCodeVersion)(safeModel);
162
202
  const additionalHeaders = (0, ModelVersionRequirements_1.getAdditionalHeaders)(safeModel);
163
203
  console.log(`🔧 Model: ${safeModel} requires VS Code version: ${minVSCodeVersion}`);
204
+ let parsedTools = [];
205
+ if (options.tools && options.tools.trim()) {
206
+ try {
207
+ const parsed = JSON.parse(options.tools);
208
+ if (Array.isArray(parsed) && parsed.length > 0) {
209
+ parsedTools = parsed;
210
+ console.log(`🔧 Parsed ${parsedTools.length} tools for function calling`);
211
+ }
212
+ else {
213
+ console.log(`⚠️ Tools field parsed but not a valid array`);
214
+ }
215
+ }
216
+ catch (error) {
217
+ console.log(`⚠️ Failed to parse tools JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
218
+ }
219
+ }
164
220
  const modelConfig = {
165
221
  model: safeModel,
166
222
  temperature: options.temperature || 0.7,
167
223
  maxTokens: Math.min(options.maxTokens || 1000, (safeModelInfo === null || safeModelInfo === void 0 ? void 0 : safeModelInfo.capabilities.maxOutputTokens) || 4096),
168
224
  topP: options.topP || 1,
169
225
  maxRetries: options.enableRetry !== false ? options.maxRetries || 3 : 0,
226
+ ...(parsedTools.length > 0 && {
227
+ tools: parsedTools,
228
+ tool_choice: options.tool_choice || "auto",
229
+ }),
170
230
  configuration: {
171
231
  baseURL: GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.BASE_URL,
172
232
  apiKey: token,
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.38.19",
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.21",
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": {
@@ -12,11 +12,13 @@ exports.truncateToTokenLimit = truncateToTokenLimit;
12
12
  const GitHubCopilotEndpoints_1 = require("./GitHubCopilotEndpoints");
13
13
  const OAuthTokenManager_1 = require("./OAuthTokenManager");
14
14
  const DynamicModelsManager_1 = require("./DynamicModelsManager");
15
+ const ModelVersionRequirements_1 = require("../models/ModelVersionRequirements");
15
16
  async function makeGitHubCopilotRequest(context, endpoint, body, hasMedia = false, retryConfig) {
16
17
  var _a, _b, _c;
17
18
  const MAX_RETRIES = (_a = retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.maxRetries) !== null && _a !== void 0 ? _a : 3;
18
19
  const BASE_DELAY = (_b = retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.baseDelay) !== null && _b !== void 0 ? _b : 500;
19
20
  const RETRY_ON_403 = (_c = retryConfig === null || retryConfig === void 0 ? void 0 : retryConfig.retryOn403) !== null && _c !== void 0 ? _c : true;
21
+ const model = body.model;
20
22
  let credentialType = "githubCopilotApi";
21
23
  try {
22
24
  credentialType = context.getNodeParameter("credentialType", 0, "githubCopilotApi");
@@ -60,11 +62,17 @@ async function makeGitHubCopilotRequest(context, endpoint, body, hasMedia = fals
60
62
  if (!token.startsWith("gho_") && !token.startsWith("ghu_") && !token.startsWith("github_pat_")) {
61
63
  console.warn(`⚠️ Unexpected token format: ${tokenPrefix}...${tokenSuffix}. Trying API call anyway.`);
62
64
  }
65
+ const minVSCodeVersion = model ? (0, ModelVersionRequirements_1.getMinVSCodeVersion)(model) : "1.95.0";
66
+ const additionalHeaders = model ? (0, ModelVersionRequirements_1.getAdditionalHeaders)(model) : {};
67
+ if (model) {
68
+ console.log(`🔧 Model: ${model} requires VS Code version: ${minVSCodeVersion}`);
69
+ }
63
70
  const headers = {
64
71
  ...GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.HEADERS.WITH_AUTH(token),
65
72
  "User-Agent": "GitHub-Copilot/1.0 (n8n-node)",
66
- "Editor-Version": "vscode/1.95.0",
73
+ "Editor-Version": `vscode/${minVSCodeVersion}`,
67
74
  "Editor-Plugin-Version": "copilot/1.0.0",
75
+ ...additionalHeaders,
68
76
  };
69
77
  if (hasMedia) {
70
78
  headers["Copilot-Vision-Request"] = "true";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.38.19",
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.21",
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": {