@hileeon/mcc 0.1.7 → 0.1.8
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.
|
@@ -240,13 +240,33 @@ function transformMessages(messagesValue) {
|
|
|
240
240
|
messagesValue.forEach((message, messageIndex) => {
|
|
241
241
|
const parsedMessage = assertObject(message, `messages[${messageIndex}]`);
|
|
242
242
|
const role = parsedMessage.role;
|
|
243
|
+
const content = parsedMessage.content;
|
|
244
|
+
if (role === 'system') {
|
|
245
|
+
// System messages: pass through as-is for OpenAI compatibility.
|
|
246
|
+
if (typeof content === 'string') {
|
|
247
|
+
translatedMessages.push({ role: 'system', content });
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (Array.isArray(content)) {
|
|
251
|
+
const textParts = [];
|
|
252
|
+
for (const block of content) {
|
|
253
|
+
if (block.type === 'text') {
|
|
254
|
+
textParts.push(typeof block.text === 'string' ? block.text : '');
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (textParts.length > 0) {
|
|
258
|
+
translatedMessages.push({ role: 'system', content: textParts.join('') });
|
|
259
|
+
}
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
243
264
|
if (role !== 'user' && role !== 'assistant') {
|
|
244
265
|
throw new Error(`messages[${messageIndex}].role must be "user" or "assistant"`);
|
|
245
266
|
}
|
|
246
267
|
if (pendingToolUseIds && pendingToolUseIds.size > 0 && role !== 'user') {
|
|
247
268
|
throw new Error(`messages[${messageIndex}].role must be "user" with tool_result blocks after assistant tool_use`);
|
|
248
269
|
}
|
|
249
|
-
const content = parsedMessage.content;
|
|
250
270
|
if (typeof content === 'string') {
|
|
251
271
|
if (pendingToolUseIds && pendingToolUseIds.size > 0) {
|
|
252
272
|
throw new Error(`messages[${messageIndex}].content must start with tool_result blocks for pending tool_use ids`);
|