bloby-bot 0.25.4 → 0.25.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bloby-bot",
3
- "version": "0.25.4",
3
+ "version": "0.25.6",
4
4
  "releaseNotes": [
5
5
  "1. new stuff",
6
6
  "2. ",
@@ -70,8 +70,8 @@ export class ChannelManager {
70
70
  private customerBuffers = new Map<string, BufferedMessage[]>();
71
71
  /** Debounce buffers per sender (keyed by "channel:sender") */
72
72
  private debounceBuffers = new Map<string, DebounceEntry>();
73
- /** Dynamic reply target for the admin live conversation (updated before each pushMessage) */
74
- private waReplyTarget: { channel: ChannelType; rawSender: string; assistantBufferKey?: string } | null = null;
73
+ /** FIFO queue of reply targets one per pushMessage, consumed on each bot:response */
74
+ private waReplyQueue: { channel: ChannelType; rawSender: string; assistantBufferKey?: string }[] = [];
75
75
 
76
76
  constructor(opts: ChannelManagerOpts) {
77
77
  this.opts = opts;
@@ -547,8 +547,8 @@ export class ChannelManager {
547
547
  waChunkBuf += eventData.token;
548
548
  }
549
549
 
550
- // Use dynamic reply target (self-chat or contact's chat depending on latest push)
551
- const target = this.waReplyTarget;
550
+ // Peek at the front of the reply queue (the target for the current response)
551
+ const target = this.waReplyQueue[0];
552
552
  if (!target) return;
553
553
 
554
554
  // Agent paused to use a tool — send accumulated text as an intermediate WhatsApp message
@@ -560,6 +560,9 @@ export class ChannelManager {
560
560
  }
561
561
 
562
562
  if (type === 'bot:response' && eventData.content) {
563
+ // Consume this target from the queue — this response is for it
564
+ this.waReplyQueue.shift();
565
+
563
566
  // Send remaining text to the correct chat
564
567
  const remaining = waChunkBuf.trim();
565
568
  if (remaining) {
@@ -599,12 +602,12 @@ export class ChannelManager {
599
602
  }, { botName, humanName }, recentMessages);
600
603
  }
601
604
 
602
- // Set reply target BEFORE pushing — callback reads this to know where to send
603
- this.waReplyTarget = {
605
+ // Enqueue reply target BEFORE pushing — callback consumes in FIFO order
606
+ this.waReplyQueue.push({
604
607
  channel: msg.channel,
605
608
  rawSender: msg.rawSender,
606
609
  assistantBufferKey: msg.role === 'assistant' ? `${msg.channel}:${msg.sender}` : undefined,
607
- };
610
+ });
608
611
 
609
612
  // Push the message into the live conversation
610
613
  const channelContent = channelContext + msg.text;