open-agents-ai 0.103.77 → 0.103.78
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.
- package/dist/index.js +33 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12224,6 +12224,21 @@ async function handleCmd(cmd) {
|
|
|
12224
12224
|
const room = rooms.get(args.room_id);
|
|
12225
12225
|
if (!room) { writeResp(id, { ok: false, output: 'Not in room: ' + args.room_id + '. Join it first.' }); return; }
|
|
12226
12226
|
const msgId = await room.send(args.message, { format: 'text/plain' });
|
|
12227
|
+
// Relay to NATS for frontend visibility (public room messages)
|
|
12228
|
+
if (_natsConn && _natsCodec) {
|
|
12229
|
+
try {
|
|
12230
|
+
_natsConn.publish('nexus.rooms.chat', _natsCodec.encode(JSON.stringify({
|
|
12231
|
+
type: 'nexus.room.message',
|
|
12232
|
+
roomId: args.room_id,
|
|
12233
|
+
peerId: nexus.peerId,
|
|
12234
|
+
agentName: agentName,
|
|
12235
|
+
content: String(args.message).slice(0, 500),
|
|
12236
|
+
timestamp: Date.now(),
|
|
12237
|
+
})));
|
|
12238
|
+
} catch (natsRelayErr) {
|
|
12239
|
+
dlog('NATS chat relay error: ' + (natsRelayErr.message || natsRelayErr));
|
|
12240
|
+
}
|
|
12241
|
+
}
|
|
12227
12242
|
writeResp(id, { ok: true, output: 'Message sent (id: ' + msgId + ')' });
|
|
12228
12243
|
break;
|
|
12229
12244
|
}
|
|
@@ -13478,6 +13493,24 @@ process.on('unhandledRejection', (reason) => {
|
|
|
13478
13493
|
nexus.on('message', ({ roomId, message }) => {
|
|
13479
13494
|
// Already handled by per-room listener, but log globally
|
|
13480
13495
|
console.log('[msg] ' + roomId + ' from ' + (message?.sender || '?').slice(0, 16));
|
|
13496
|
+
// Relay received messages to NATS for frontend visibility
|
|
13497
|
+
if (_natsConn && _natsCodec && message && message.sender !== nexus.peerId) {
|
|
13498
|
+
try {
|
|
13499
|
+
var _msgContent = '';
|
|
13500
|
+
if (message.payload && message.payload.content) _msgContent = String(message.payload.content).slice(0, 500);
|
|
13501
|
+
else if (typeof message.content === 'string') _msgContent = message.content.slice(0, 500);
|
|
13502
|
+
if (_msgContent) {
|
|
13503
|
+
_natsConn.publish('nexus.rooms.chat', _natsCodec.encode(JSON.stringify({
|
|
13504
|
+
type: 'nexus.room.message',
|
|
13505
|
+
roomId: roomId,
|
|
13506
|
+
peerId: message.sender || '',
|
|
13507
|
+
agentName: message.senderName || (message.sender ? message.sender.slice(0, 12) : 'anon'),
|
|
13508
|
+
content: _msgContent,
|
|
13509
|
+
timestamp: message.timestamp || Date.now(),
|
|
13510
|
+
})));
|
|
13511
|
+
}
|
|
13512
|
+
} catch {}
|
|
13513
|
+
}
|
|
13481
13514
|
});
|
|
13482
13515
|
nexus.on('dm', ({ from, content, format, messageId }) => {
|
|
13483
13516
|
// Log DMs to inbox/dm/
|
package/package.json
CHANGED