n8n-nodes-github-copilot 3.31.23 → 3.31.25

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.
@@ -40,10 +40,22 @@ class GitHubCopilotOpenAI {
40
40
  const temperature = this.getNodeParameter("temperature", i, 1);
41
41
  const tools = this.getNodeParameter("tools", i, "");
42
42
  let messages = [];
43
+ let requestBodyFromJson = undefined;
43
44
  if (messagesInputMode === "json") {
44
45
  const messagesJson = this.getNodeParameter("messagesJson", i, "[]");
45
46
  try {
46
- messages = JSON.parse(messagesJson);
47
+ const parsed = JSON.parse(messagesJson);
48
+ if (Array.isArray(parsed)) {
49
+ messages = parsed;
50
+ }
51
+ else if (parsed.messages && Array.isArray(parsed.messages)) {
52
+ messages = parsed.messages;
53
+ requestBodyFromJson = parsed;
54
+ console.log('šŸ“„ Full OpenAI request body received:', JSON.stringify(parsed, null, 2));
55
+ }
56
+ else {
57
+ messages = parsed;
58
+ }
47
59
  }
48
60
  catch (error) {
49
61
  throw new Error(`Failed to parse messages JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
@@ -81,13 +93,26 @@ class GitHubCopilotOpenAI {
81
93
  const seed = this.getNodeParameter("seed", i, 0);
82
94
  const advancedOptions = this.getNodeParameter("advancedOptions", i, {});
83
95
  let response_format = undefined;
84
- if (advancedOptions.response_format && typeof advancedOptions.response_format === 'string') {
96
+ if (requestBodyFromJson === null || requestBodyFromJson === void 0 ? void 0 : requestBodyFromJson.response_format) {
97
+ response_format = requestBodyFromJson.response_format;
98
+ console.log('šŸ“‹ response_format from JSON request body:', JSON.stringify(response_format));
99
+ }
100
+ else if (advancedOptions.response_format && typeof advancedOptions.response_format === 'string') {
85
101
  try {
86
102
  response_format = JSON.parse(advancedOptions.response_format);
103
+ console.log('šŸ“‹ response_format from advancedOptions:', JSON.stringify(response_format));
87
104
  }
88
105
  catch {
106
+ console.log('āš ļø Failed to parse response_format from advancedOptions');
89
107
  }
90
108
  }
109
+ if (response_format) {
110
+ console.log('āœ… Final response_format:', JSON.stringify(response_format));
111
+ console.log('šŸ” response_format.type:', response_format.type);
112
+ }
113
+ else {
114
+ console.log('ā„¹ļø No response_format specified');
115
+ }
91
116
  const modelMapping = {
92
117
  "gpt-4": "gpt-4o",
93
118
  "gpt-4o": "gpt-4o",
@@ -117,41 +142,67 @@ class GitHubCopilotOpenAI {
117
142
  requestBody.seed = seed;
118
143
  }
119
144
  const response = await (0, utils_1.makeApiRequest)(this, GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ENDPOINTS.CHAT_COMPLETIONS, requestBody, false);
120
- const cleanJsonContent = (content) => {
145
+ const parseJsonContent = (content) => {
121
146
  if (!content)
122
147
  return content;
123
- const trimmed = content.trim();
124
- console.log('šŸ” cleanJsonContent - Original length:', content.length);
125
- console.log('šŸ” cleanJsonContent - Starts with:', trimmed.substring(0, 20));
126
- console.log('šŸ” cleanJsonContent - Ends with:', trimmed.substring(trimmed.length - 20));
127
- const jsonBlockRegex = /^```(?:json)?\s*\n([\s\S]*?)\n```\s*$/;
128
- const match = trimmed.match(jsonBlockRegex);
129
- if (match && match[1]) {
130
- const cleaned = match[1].trim();
131
- console.log('āœ… cleanJsonContent - Cleaned JSON (first 100 chars):', cleaned.substring(0, 100));
132
- return cleaned;
148
+ try {
149
+ const trimmed = content.trim();
150
+ console.log('šŸ” parseJsonContent - Original length:', content.length);
151
+ console.log('šŸ” parseJsonContent - First 50 chars:', trimmed.substring(0, 50));
152
+ const jsonBlockRegex = /^```(?:json)?\s*\n([\s\S]*?)\n```\s*$/;
153
+ const match = trimmed.match(jsonBlockRegex);
154
+ let jsonString = trimmed;
155
+ if (match && match[1]) {
156
+ jsonString = match[1].trim();
157
+ console.log('āœ… parseJsonContent - Extracted from markdown block');
158
+ }
159
+ const parsed = JSON.parse(jsonString);
160
+ console.log('āœ… parseJsonContent - Successfully parsed to object:', typeof parsed);
161
+ return parsed;
162
+ }
163
+ catch (error) {
164
+ console.error('āŒ parseJsonContent - Parse error:', error);
165
+ console.log('āš ļø parseJsonContent - Returning original string');
166
+ return content;
133
167
  }
134
- console.log('āš ļø cleanJsonContent - No markdown block found, returning original');
135
- return content;
136
168
  };
169
+ console.log('šŸ”Ø Building OpenAI response...');
170
+ 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');
137
171
  const openAIResponse = {
138
172
  id: response.id || `chatcmpl-${Date.now()}`,
139
173
  object: response.object || "chat.completion",
140
174
  created: response.created || Math.floor(Date.now() / 1000),
141
175
  model: model,
142
- choices: response.choices.map((choice) => ({
143
- index: choice.index,
144
- message: {
145
- role: choice.message.role,
146
- ...(choice.message.content !== null && choice.message.content !== undefined && {
147
- content: (response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object'
148
- ? cleanJsonContent(choice.message.content)
149
- : choice.message.content
150
- }),
151
- ...(choice.message.tool_calls && { tool_calls: choice.message.tool_calls }),
152
- },
153
- finish_reason: choice.finish_reason,
154
- })),
176
+ choices: response.choices.map((choice, choiceIndex) => {
177
+ var _a;
178
+ console.log(`\nšŸ“ Processing choice ${choiceIndex}:`);
179
+ console.log(' - role:', choice.message.role);
180
+ console.log(' - content type:', typeof choice.message.content);
181
+ console.log(' - content length:', ((_a = choice.message.content) === null || _a === void 0 ? void 0 : _a.length) || 0);
182
+ console.log(' - has tool_calls:', !!choice.message.tool_calls);
183
+ let processedContent = choice.message.content;
184
+ if (choice.message.content !== null && choice.message.content !== undefined) {
185
+ if ((response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object') {
186
+ console.log(' šŸ”„ Applying parseJsonContent...');
187
+ processedContent = parseJsonContent(choice.message.content);
188
+ console.log(' āœ… Processed content type:', typeof processedContent);
189
+ }
190
+ else {
191
+ console.log(' ā„¹ļø Keeping content as string');
192
+ }
193
+ }
194
+ return {
195
+ index: choice.index,
196
+ message: {
197
+ role: choice.message.role,
198
+ ...(choice.message.content !== null && choice.message.content !== undefined && {
199
+ content: processedContent
200
+ }),
201
+ ...(choice.message.tool_calls && { tool_calls: choice.message.tool_calls }),
202
+ },
203
+ finish_reason: choice.finish_reason,
204
+ };
205
+ }),
155
206
  usage: response.usage || {
156
207
  prompt_tokens: 0,
157
208
  completion_tokens: 0,
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.31.23",
3
+ "version": "3.31.25",
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.23",
3
+ "version": "3.31.25",
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",