n8n-nodes-github-copilot 3.31.26 โ†’ 3.31.28

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.
@@ -44,7 +44,15 @@ class GitHubCopilotOpenAI {
44
44
  if (messagesInputMode === "json") {
45
45
  const messagesJson = this.getNodeParameter("messagesJson", i, "[]");
46
46
  try {
47
- const parsed = JSON.parse(messagesJson);
47
+ let parsed;
48
+ if (typeof messagesJson === 'object') {
49
+ parsed = messagesJson;
50
+ console.log('๐Ÿ“ฅ Received messages as direct object/array (no parsing needed)');
51
+ }
52
+ else {
53
+ parsed = JSON.parse(messagesJson);
54
+ console.log('๐Ÿ“ฅ Parsed messages from JSON string');
55
+ }
48
56
  if (Array.isArray(parsed)) {
49
57
  messages = parsed;
50
58
  }
@@ -81,9 +89,16 @@ class GitHubCopilotOpenAI {
81
89
  });
82
90
  }
83
91
  let parsedTools = [];
84
- if (tools && tools.trim()) {
92
+ if (tools) {
85
93
  try {
86
- parsedTools = JSON.parse(tools);
94
+ if (typeof tools === 'object' && Array.isArray(tools)) {
95
+ parsedTools = tools;
96
+ console.log('๐Ÿ“ฅ Received tools as direct array (no parsing needed)');
97
+ }
98
+ else if (typeof tools === 'string' && tools.trim()) {
99
+ parsedTools = JSON.parse(tools);
100
+ console.log('๐Ÿ“ฅ Parsed tools from JSON string');
101
+ }
87
102
  }
88
103
  catch (error) {
89
104
  throw new Error(`Failed to parse tools JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
@@ -147,32 +162,30 @@ class GitHubCopilotOpenAI {
147
162
  requestBody.seed = seed;
148
163
  }
149
164
  const response = await (0, utils_1.makeApiRequest)(this, GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ENDPOINTS.CHAT_COMPLETIONS, requestBody, false);
150
- const parseJsonContent = (content) => {
151
- if (!content)
165
+ const cleanJsonFromMarkdown = (content) => {
166
+ if (!content || typeof content !== 'string') {
152
167
  return content;
168
+ }
153
169
  try {
154
170
  const trimmed = content.trim();
155
- console.log('๐Ÿ” parseJsonContent - Original length:', content.length);
156
- console.log('๐Ÿ” parseJsonContent - First 50 chars:', trimmed.substring(0, 50));
171
+ console.log('๐Ÿงน cleanJsonFromMarkdown - Input length:', trimmed.length);
157
172
  const jsonBlockRegex = /^```(?:json)?\s*\n([\s\S]*?)\n```\s*$/;
158
173
  const match = trimmed.match(jsonBlockRegex);
159
- let jsonString = trimmed;
160
174
  if (match && match[1]) {
161
- jsonString = match[1].trim();
162
- console.log('โœ… parseJsonContent - Extracted from markdown block');
175
+ const extracted = match[1].trim();
176
+ console.log('โœ… cleanJsonFromMarkdown - Extracted from markdown block');
177
+ return extracted;
163
178
  }
164
- const parsed = JSON.parse(jsonString);
165
- console.log('โœ… parseJsonContent - Successfully parsed to object:', typeof parsed);
166
- return parsed;
179
+ console.log('โ„น๏ธ cleanJsonFromMarkdown - No markdown block found, returning as is');
180
+ return trimmed;
167
181
  }
168
182
  catch (error) {
169
- console.error('โŒ parseJsonContent - Parse error:', error);
170
- console.log('โš ๏ธ parseJsonContent - Returning original string');
183
+ console.error('โŒ cleanJsonFromMarkdown - Error:', error);
171
184
  return content;
172
185
  }
173
186
  };
174
187
  console.log('๐Ÿ”จ Building OpenAI response...');
175
- console.log('๐Ÿ” response_format check:', (response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object' ? 'WILL PARSE JSON' : 'WILL KEEP AS STRING');
188
+ console.log('๐Ÿ” response_format check:', (response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object' ? 'WILL CLEAN MARKDOWN' : 'WILL KEEP AS IS');
176
189
  const openAIResponse = {
177
190
  id: response.id || `chatcmpl-${Date.now()}`,
178
191
  object: response.object || "chat.completion",
@@ -188,12 +201,12 @@ class GitHubCopilotOpenAI {
188
201
  let processedContent = choice.message.content;
189
202
  if (choice.message.content !== null && choice.message.content !== undefined) {
190
203
  if ((response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object') {
191
- console.log(' ๐Ÿ”„ Applying parseJsonContent...');
192
- processedContent = parseJsonContent(choice.message.content);
204
+ console.log(' ๐Ÿงน Applying cleanJsonFromMarkdown (keeping as string)...');
205
+ processedContent = cleanJsonFromMarkdown(choice.message.content);
193
206
  console.log(' โœ… Processed content type:', typeof processedContent);
194
207
  }
195
208
  else {
196
- console.log(' โ„น๏ธ Keeping content as string');
209
+ console.log(' โ„น๏ธ Keeping content as is');
197
210
  }
198
211
  }
199
212
  return {
@@ -203,8 +216,11 @@ class GitHubCopilotOpenAI {
203
216
  ...(choice.message.content !== null && choice.message.content !== undefined && {
204
217
  content: processedContent
205
218
  }),
219
+ refusal: choice.message.refusal || null,
220
+ annotations: choice.message.annotations || [],
206
221
  ...(choice.message.tool_calls && { tool_calls: choice.message.tool_calls }),
207
222
  },
223
+ logprobs: choice.logprobs || null,
208
224
  finish_reason: choice.finish_reason,
209
225
  };
210
226
  }),
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.31.26",
3
+ "version": "3.31.28",
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.31.26",
3
+ "version": "3.31.28",
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",