UNPKG

n8n

Version:

n8n Workflow Automation Tool

43 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.contentPartToDto = contentPartToDto; exports.messageToDto = messageToDto; exports.messagesToDto = messagesToDto; function contentPartToDto(part) { const dto = { type: part.type }; if ('text' in part && typeof part.text === 'string') dto.text = part.text; if ('toolName' in part && typeof part.toolName === 'string') dto.toolName = part.toolName; if ('toolCallId' in part && typeof part.toolCallId === 'string') { dto.toolCallId = part.toolCallId; } if ('input' in part) dto.input = part.input; if ('state' in part && typeof part.state === 'string') dto.state = part.state; if ('output' in part) dto.output = part.output; if ('error' in part && typeof part.error === 'string') dto.error = part.error; return dto; } function messageToDto(msg) { if (!('role' in msg) || !Array.isArray(msg.content)) return null; return { id: msg.id, role: msg.role, content: msg.content.map(contentPartToDto), }; } function messagesToDto(msgs) { const out = []; for (const m of msgs) { const dto = messageToDto(m); if (dto) out.push(dto); } return out; } //# sourceMappingURL=agent-message-mapper.js.map