mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
wording and overseer tool embeds
This commit is contained in:
@@ -100,6 +100,21 @@ function buildRoverCtxSnapshot(roverId) {
|
||||
function buildMessage(socket, text, meta = {}) {
|
||||
const roverId = meta.roverId || resolveRoverId(socket?.id);
|
||||
const roverColor = meta.roverColor ?? resolveRoverColor(roverId);
|
||||
const toolCalls = Array.isArray(meta.toolCalls)
|
||||
? meta.toolCalls
|
||||
.map((entry) => {
|
||||
if (!entry || typeof entry !== 'object') return null;
|
||||
return {
|
||||
tool: String(entry.tool || '').trim() || 'unknown',
|
||||
status: String(entry.status || '').trim() || 'unknown',
|
||||
args: entry.args && typeof entry.args === 'object' ? entry.args : {},
|
||||
result: entry.result && typeof entry.result === 'object' ? entry.result : null,
|
||||
error: entry.error ? String(entry.error) : null,
|
||||
durationMs: Number.isFinite(entry.durationMs) ? Math.max(0, Math.round(entry.durationMs)) : null,
|
||||
};
|
||||
})
|
||||
.filter(Boolean)
|
||||
: null;
|
||||
return {
|
||||
id: uuidv4(),
|
||||
ts: Date.now(),
|
||||
@@ -119,6 +134,7 @@ function buildMessage(socket, text, meta = {}) {
|
||||
profileImage: normalizeProfileImageUrl(meta.profileImage),
|
||||
roverCtx: meta.roverCtx || null,
|
||||
text,
|
||||
toolCalls,
|
||||
tts: meta.tts || null,
|
||||
bot: Boolean(meta.bot),
|
||||
};
|
||||
|
||||
@@ -11,7 +11,8 @@ const { registerChatSocketHooks } = require('./socketHooks');
|
||||
function sendSystemMessage(text, options = {}) {
|
||||
const normalized = normalizeUserText(text);
|
||||
const clean = normalized.trim();
|
||||
if (!clean) return null;
|
||||
const hasToolCalls = Array.isArray(options.toolCalls) && options.toolCalls.length > 0;
|
||||
if (!clean && !hasToolCalls) return null;
|
||||
const safe = clean;
|
||||
const message = buildMessage(null, safe, {
|
||||
nickname: String(options.nickname || 'The Overseer'),
|
||||
@@ -19,6 +20,7 @@ function sendSystemMessage(text, options = {}) {
|
||||
fromDiscord: false,
|
||||
bot: options.bot !== false,
|
||||
profileImage: options.profileImage || null,
|
||||
toolCalls: hasToolCalls ? options.toolCalls : null,
|
||||
});
|
||||
broadcastMessage(message);
|
||||
return message;
|
||||
|
||||
Reference in New Issue
Block a user