bloby-bot 0.36.0 → 0.37.0
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
|
@@ -27,11 +27,25 @@ import { startBlobyAgentQuery, startConversation, pushMessage, hasConversation,
|
|
|
27
27
|
import { WhatsAppChannel } from './whatsapp.js';
|
|
28
28
|
import type { ChannelConfig, ChannelProvider, ChannelStatus, ChannelType, InboundMessage, InboundMessageAttachment, SenderRole } from './types.js';
|
|
29
29
|
import type { AgentAttachment } from '../bloby-agent.js';
|
|
30
|
+
import { saveAttachment, type SavedFile } from '../file-saver.js';
|
|
30
31
|
|
|
31
32
|
const MAX_CONCURRENT_AGENTS = 5;
|
|
32
33
|
const MAX_BUFFER_MESSAGES = 30;
|
|
33
34
|
const DEBOUNCE_MS = 4000; // 4s — wait for the user to finish typing
|
|
34
35
|
|
|
36
|
+
/** Persist channel-inbound attachments to disk so harnesses that consume file
|
|
37
|
+
* paths (Codex's `localImage`) can see them. Failures are logged and the
|
|
38
|
+
* attachment is dropped — text-only delivery is still useful. */
|
|
39
|
+
function saveInboundAttachments(attachments?: AgentAttachment[]): SavedFile[] {
|
|
40
|
+
if (!attachments?.length) return [];
|
|
41
|
+
const saved: SavedFile[] = [];
|
|
42
|
+
for (const att of attachments) {
|
|
43
|
+
try { saved.push(saveAttachment(att)); }
|
|
44
|
+
catch (err: any) { log.warn(`[channels] Failed to save inbound attachment: ${err.message}`); }
|
|
45
|
+
}
|
|
46
|
+
return saved;
|
|
47
|
+
}
|
|
48
|
+
|
|
35
49
|
interface ChannelManagerOpts {
|
|
36
50
|
broadcastBloby: (type: string, data: any) => void;
|
|
37
51
|
workerApi: (path: string, method?: string, body?: any) => Promise<any>;
|
|
@@ -120,9 +134,9 @@ export class ChannelManager {
|
|
|
120
134
|
let provider = this.providers.get('whatsapp');
|
|
121
135
|
if (!provider) {
|
|
122
136
|
const whatsapp = new WhatsAppChannel(
|
|
123
|
-
(sender, senderName, text, fromMe, isSelfChat, images) => {
|
|
137
|
+
(sender, senderName, text, fromMe, isSelfChat, chatJid, isGroup, images) => {
|
|
124
138
|
const attachments = images?.map((img) => ({ type: 'image' as const, mediaType: img.mediaType, data: img.data }));
|
|
125
|
-
this.handleInboundMessage('whatsapp', sender, senderName, text, fromMe, isSelfChat, attachments);
|
|
139
|
+
this.handleInboundMessage('whatsapp', sender, senderName, text, fromMe, isSelfChat, chatJid, isGroup, attachments);
|
|
126
140
|
},
|
|
127
141
|
(status) => this.handleStatusChange(status),
|
|
128
142
|
(audioBase64) => this.transcribeAudio(audioBase64),
|
|
@@ -693,6 +707,10 @@ export class ChannelManager {
|
|
|
693
707
|
mediaType: att.mediaType,
|
|
694
708
|
data: att.data,
|
|
695
709
|
}));
|
|
710
|
+
// Save to disk so providers that consume file paths (Codex → localImage)
|
|
711
|
+
// can see the attachment. Claude consumes raw base64 from `agentAttachments`
|
|
712
|
+
// directly, but the on-disk copy is still useful for the path mention.
|
|
713
|
+
const savedFiles = saveInboundAttachments(agentAttachments);
|
|
696
714
|
|
|
697
715
|
// Show "typing..." in the correct chat
|
|
698
716
|
this.startTyping(msg.channel, msg.rawSender);
|
|
@@ -740,7 +758,7 @@ export class ChannelManager {
|
|
|
740
758
|
|
|
741
759
|
// Push the message into the live conversation
|
|
742
760
|
const channelContent = channelContext + msg.text;
|
|
743
|
-
pushMessage(convId, channelContent, agentAttachments);
|
|
761
|
+
pushMessage(convId, channelContent, agentAttachments, savedFiles);
|
|
744
762
|
}
|
|
745
763
|
|
|
746
764
|
/** Handle message from a customer — runs support agent in parallel with conversation context */
|
|
@@ -809,6 +827,7 @@ export class ChannelManager {
|
|
|
809
827
|
mediaType: att.mediaType,
|
|
810
828
|
data: att.data,
|
|
811
829
|
}));
|
|
830
|
+
const savedFiles = saveInboundAttachments(agentAttachments);
|
|
812
831
|
|
|
813
832
|
// Stable convId per customer (not per message)
|
|
814
833
|
const convId = `channel-${agentKey}`;
|
|
@@ -869,7 +888,7 @@ export class ChannelManager {
|
|
|
869
888
|
}
|
|
870
889
|
},
|
|
871
890
|
agentAttachments,
|
|
872
|
-
|
|
891
|
+
savedFiles,
|
|
873
892
|
{ botName, humanName },
|
|
874
893
|
recentMessages,
|
|
875
894
|
enrichedScript,
|