@automagik/omni 2.260523.1 → 2.260524.1
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 +1 -1
- package/dist/server/index.js +136 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -124460,7 +124460,7 @@ import { fileURLToPath } from "url";
|
|
|
124460
124460
|
// package.json
|
|
124461
124461
|
var package_default = {
|
|
124462
124462
|
name: "@automagik/omni",
|
|
124463
|
-
version: "2.
|
|
124463
|
+
version: "2.260524.1",
|
|
124464
124464
|
description: "LLM-optimized CLI for Omni",
|
|
124465
124465
|
type: "module",
|
|
124466
124466
|
bin: {
|
package/dist/server/index.js
CHANGED
|
@@ -230186,7 +230186,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
230186
230186
|
var require_package8 = __commonJS((exports, module) => {
|
|
230187
230187
|
module.exports = {
|
|
230188
230188
|
name: "@omni/api",
|
|
230189
|
-
version: "2.
|
|
230189
|
+
version: "2.260524.1",
|
|
230190
230190
|
type: "module",
|
|
230191
230191
|
exports: {
|
|
230192
230192
|
".": {
|
|
@@ -331824,6 +331824,40 @@ function buildChatPreview(payload, rawPayload) {
|
|
|
331824
331824
|
}
|
|
331825
331825
|
return preview.substring(0, 500);
|
|
331826
331826
|
}
|
|
331827
|
+
function compactRecord(record) {
|
|
331828
|
+
const compacted = Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
331829
|
+
return Object.keys(compacted).length > 0 ? compacted : undefined;
|
|
331830
|
+
}
|
|
331831
|
+
function isSentMediaContent(content) {
|
|
331832
|
+
return OUTBOUND_MEDIA_TYPES.has(content.type) || !!content.mediaUrl || !!content.localPath || !!content.mimeType;
|
|
331833
|
+
}
|
|
331834
|
+
function buildSentMediaMetadata(content, rawPayload) {
|
|
331835
|
+
if (!isSentMediaContent(content))
|
|
331836
|
+
return;
|
|
331837
|
+
const rawSource = typeof rawPayload?.mediaSource === "string" ? rawPayload.mediaSource : undefined;
|
|
331838
|
+
return compactRecord({
|
|
331839
|
+
caption: content.caption,
|
|
331840
|
+
filename: content.filename,
|
|
331841
|
+
voiceNote: content.isVoiceNote === true ? true : undefined,
|
|
331842
|
+
source: rawSource ?? (content.mediaUrl ? "url" : content.localPath ? "localPath" : "inline")
|
|
331843
|
+
});
|
|
331844
|
+
}
|
|
331845
|
+
function buildSentMessageContentFields(payload) {
|
|
331846
|
+
return {
|
|
331847
|
+
textContent: sanitizeText(payload.content.text ?? payload.content.caption),
|
|
331848
|
+
hasMedia: isSentMediaContent(payload.content),
|
|
331849
|
+
mediaMimeType: truncate3(payload.content.mimeType, 100),
|
|
331850
|
+
mediaUrl: payload.content.mediaUrl,
|
|
331851
|
+
mediaLocalPath: payload.content.localPath,
|
|
331852
|
+
mediaMetadata: buildSentMediaMetadata(payload.content, payload.rawPayload),
|
|
331853
|
+
rawPayload: payload.rawPayload ? deepSanitize(payload.rawPayload) : undefined
|
|
331854
|
+
};
|
|
331855
|
+
}
|
|
331856
|
+
function buildSentChatPreview(payload) {
|
|
331857
|
+
const text3 = payload.content.text ?? payload.content.caption ?? "";
|
|
331858
|
+
const badge = payload.content.type !== "text" ? MEDIA_BADGES2[payload.content.type] ?? `[${payload.content.type}]` : "";
|
|
331859
|
+
return badge ? text3 ? `${badge} ${text3}` : badge : text3;
|
|
331860
|
+
}
|
|
331827
331861
|
function extractPhoneFromSender(senderId, channel5) {
|
|
331828
331862
|
if (!channel5.startsWith("whatsapp"))
|
|
331829
331863
|
return;
|
|
@@ -332115,17 +332149,22 @@ async function setupMessagePersistence(eventBus, services) {
|
|
|
332115
332149
|
chatType: inferChatType(payload.chatId),
|
|
332116
332150
|
channel: metadata.channelType ?? "whatsapp"
|
|
332117
332151
|
});
|
|
332152
|
+
const sentContent = buildSentMessageContentFields(payload);
|
|
332118
332153
|
const { message: message2, created } = await services.messages.findOrCreate(chat2.id, messageExternalId, {
|
|
332119
332154
|
source: "realtime",
|
|
332120
332155
|
messageType: mapContentType(payload.content.type),
|
|
332121
|
-
textContent:
|
|
332156
|
+
textContent: sentContent.textContent,
|
|
332122
332157
|
platformTimestamp: new Date(event.timestamp),
|
|
332123
332158
|
senderPersonId: metadata.personId,
|
|
332124
332159
|
senderPlatformIdentityId: metadata.platformIdentityId,
|
|
332125
332160
|
isFromMe: true,
|
|
332126
332161
|
senderAgentId: payload.senderAgentId ?? null,
|
|
332127
|
-
hasMedia:
|
|
332128
|
-
|
|
332162
|
+
hasMedia: sentContent.hasMedia,
|
|
332163
|
+
mediaMimeType: sentContent.mediaMimeType,
|
|
332164
|
+
mediaUrl: sentContent.mediaUrl,
|
|
332165
|
+
mediaLocalPath: sentContent.mediaLocalPath,
|
|
332166
|
+
mediaMetadata: sentContent.mediaMetadata,
|
|
332167
|
+
rawPayload: sentContent.rawPayload,
|
|
332129
332168
|
replyToExternalId: truncate3(payload.replyToId, 255)
|
|
332130
332169
|
});
|
|
332131
332170
|
if (created) {
|
|
@@ -332135,7 +332174,7 @@ async function setupMessagePersistence(eventBus, services) {
|
|
|
332135
332174
|
chatId: chat2.id
|
|
332136
332175
|
});
|
|
332137
332176
|
}
|
|
332138
|
-
services.chats.updateLastMessage(chat2.id, sanitizeText(payload
|
|
332177
|
+
services.chats.updateLastMessage(chat2.id, sanitizeText(buildSentChatPreview(payload)) ?? "", new Date(event.timestamp), true).catch((err) => log93.debug("Failed to update chat recency (sent)", { error: String(err) }));
|
|
332139
332178
|
if (metadata.streamSequence) {
|
|
332140
332179
|
await services.consumerOffsets.updateOffset("message-persistence-sent", "MESSAGE", metadata.streamSequence, event.id);
|
|
332141
332180
|
}
|
|
@@ -332304,7 +332343,7 @@ async function detectStartupGaps(services) {
|
|
|
332304
332343
|
}
|
|
332305
332344
|
}
|
|
332306
332345
|
}
|
|
332307
|
-
var log93, CONTENT_TYPE_MAP, INTERNAL_JID_SUFFIXES, MEDIA_BADGES2;
|
|
332346
|
+
var log93, CONTENT_TYPE_MAP, INTERNAL_JID_SUFFIXES, MEDIA_BADGES2, OUTBOUND_MEDIA_TYPES;
|
|
332308
332347
|
var init_message_persistence = __esm(() => {
|
|
332309
332348
|
init_src();
|
|
332310
332349
|
init_esm5();
|
|
@@ -332334,6 +332373,7 @@ var init_message_persistence = __esm(() => {
|
|
|
332334
332373
|
location: "[Location]",
|
|
332335
332374
|
poll: "[Poll]"
|
|
332336
332375
|
};
|
|
332376
|
+
OUTBOUND_MEDIA_TYPES = new Set(["audio", "image", "video", "document", "sticker"]);
|
|
332337
332377
|
});
|
|
332338
332378
|
|
|
332339
332379
|
// ../api/src/plugins/session-storage.ts
|
|
@@ -333954,7 +333994,8 @@ function createClaudeCodeProviderInstance(provider, instance4, db2) {
|
|
|
333954
333994
|
model: schemaConfig.model,
|
|
333955
333995
|
systemPrompt: schemaConfig.systemPrompt,
|
|
333956
333996
|
mcpServers: schemaConfig.mcpServers,
|
|
333957
|
-
maxTurns: schemaConfig.maxTurns
|
|
333997
|
+
maxTurns: schemaConfig.maxTurns,
|
|
333998
|
+
pathToClaudeCodeExecutable: schemaConfig.pathToClaudeCodeExecutable
|
|
333958
333999
|
}, createSessionStorage(db2, provider.id), {
|
|
333959
334000
|
timeoutMs: (instance4.agentTimeout ?? provider.defaultTimeout ?? 120) * 1000,
|
|
333960
334001
|
enableAutoSplit: instance4.enableAutoSplit ?? true,
|
|
@@ -342723,6 +342764,9 @@ function buildA2AAgentCard(params) {
|
|
|
342723
342764
|
const providerOverride = isRecord(override.provider) ? override.provider : undefined;
|
|
342724
342765
|
if (providerOverride)
|
|
342725
342766
|
card.provider = providerOverride;
|
|
342767
|
+
const metadataOverride = isRecord(override.metadata) ? override.metadata : undefined;
|
|
342768
|
+
if (metadataOverride)
|
|
342769
|
+
card.metadata = metadataOverride;
|
|
342726
342770
|
const iconUrl = stringOverride(override.iconUrl);
|
|
342727
342771
|
if (iconUrl)
|
|
342728
342772
|
card.iconUrl = iconUrl;
|
|
@@ -349590,7 +349634,15 @@ var init__close_contact_config = __esm(() => {
|
|
|
349590
349634
|
|
|
349591
349635
|
// ../api/src/routes/v2/messages.ts
|
|
349592
349636
|
import { existsSync as existsSync7 } from "fs";
|
|
349593
|
-
import { join as join22 } from "path";
|
|
349637
|
+
import { extname as extname3, join as join22 } from "path";
|
|
349638
|
+
function inferMediaMimeType(type, filename) {
|
|
349639
|
+
if (filename) {
|
|
349640
|
+
const fromExtension = MIME_BY_EXTENSION[extname3(filename).toLowerCase()];
|
|
349641
|
+
if (fromExtension)
|
|
349642
|
+
return fromExtension;
|
|
349643
|
+
}
|
|
349644
|
+
return DEFAULT_MIME_BY_MEDIA_TYPE[type];
|
|
349645
|
+
}
|
|
349594
349646
|
function isUUID(value) {
|
|
349595
349647
|
return UUID_REGEX2.test(value);
|
|
349596
349648
|
}
|
|
@@ -349748,7 +349800,7 @@ async function verifyMessageInstanceOwnership(services, message2, instanceId) {
|
|
|
349748
349800
|
});
|
|
349749
349801
|
}
|
|
349750
349802
|
}
|
|
349751
|
-
var log105, mediaDownloadLog, messagesRoutes, UUID_REGEX2, MessageSourceSchema, MessageTypeSchema, MessageStatusSchema, DeliveryStatusSchema, listQuerySchema14, createMessageSchema, updateMessageSchema, recordEditSchema, addReactionSchema, removeReactionSchema, updateDeliveryStatusSchema, MentionSchema, sendTextSchema, sendMediaSchema, sendReactionSchema, sendStickerSchema, sendContactSchema, sendLocationSchema, sendHandoffSchema, sendCloseContactSchema, messageRefSchema, _mediaStorageForDownload = null, sendTtsSchema, forwardMessageSchema, sendPresenceSchema, markMessageReadSchema, markBatchReadSchema, sendPollSchema, sendEmbedSchema, editMessageChannelSchema, deleteMessageChannelSchema, starMessageSchema;
|
|
349803
|
+
var log105, mediaDownloadLog, messagesRoutes, MIME_BY_EXTENSION, DEFAULT_MIME_BY_MEDIA_TYPE, UUID_REGEX2, MessageSourceSchema, MessageTypeSchema, MessageStatusSchema, DeliveryStatusSchema, listQuerySchema14, createMessageSchema, updateMessageSchema, recordEditSchema, addReactionSchema, removeReactionSchema, updateDeliveryStatusSchema, MentionSchema, sendTextSchema, sendMediaSchema, sendReactionSchema, sendStickerSchema, sendContactSchema, sendLocationSchema, sendHandoffSchema, sendCloseContactSchema, messageRefSchema, _mediaStorageForDownload = null, sendTtsSchema, forwardMessageSchema, sendPresenceSchema, markMessageReadSchema, markBatchReadSchema, sendPollSchema, sendEmbedSchema, editMessageChannelSchema, deleteMessageChannelSchema, starMessageSchema;
|
|
349752
349804
|
var init_messages5 = __esm(() => {
|
|
349753
349805
|
init_dist6();
|
|
349754
349806
|
init_src2();
|
|
@@ -349766,6 +349818,29 @@ var init_messages5 = __esm(() => {
|
|
|
349766
349818
|
log105 = createLogger("routes:messages");
|
|
349767
349819
|
mediaDownloadLog = createLogger("routes:messages:media-download");
|
|
349768
349820
|
messagesRoutes = new Hono2;
|
|
349821
|
+
MIME_BY_EXTENSION = {
|
|
349822
|
+
".jpg": "image/jpeg",
|
|
349823
|
+
".jpeg": "image/jpeg",
|
|
349824
|
+
".png": "image/png",
|
|
349825
|
+
".gif": "image/gif",
|
|
349826
|
+
".webp": "image/webp",
|
|
349827
|
+
".mp3": "audio/mpeg",
|
|
349828
|
+
".ogg": "audio/ogg",
|
|
349829
|
+
".opus": "audio/opus",
|
|
349830
|
+
".wav": "audio/wav",
|
|
349831
|
+
".m4a": "audio/mp4",
|
|
349832
|
+
".mp4": "video/mp4",
|
|
349833
|
+
".webm": "video/webm",
|
|
349834
|
+
".mov": "video/quicktime",
|
|
349835
|
+
".avi": "video/x-msvideo",
|
|
349836
|
+
".pdf": "application/pdf"
|
|
349837
|
+
};
|
|
349838
|
+
DEFAULT_MIME_BY_MEDIA_TYPE = {
|
|
349839
|
+
image: "image/jpeg",
|
|
349840
|
+
audio: "audio/ogg",
|
|
349841
|
+
video: "video/mp4",
|
|
349842
|
+
document: "application/octet-stream"
|
|
349843
|
+
};
|
|
349769
349844
|
UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
349770
349845
|
MessageSourceSchema = exports_external.enum(["realtime", "sync", "api", "import"]);
|
|
349771
349846
|
MessageTypeSchema = exports_external.enum([
|
|
@@ -350240,6 +350315,7 @@ var init_messages5 = __esm(() => {
|
|
|
350240
350315
|
});
|
|
350241
350316
|
}
|
|
350242
350317
|
const resolvedTo = await resolveRecipient(data.to, instance4.channel, services);
|
|
350318
|
+
const mediaMimeType = data.mimeType ?? inferMediaMimeType(data.type, data.filename);
|
|
350243
350319
|
const outgoingMessage = {
|
|
350244
350320
|
to: resolvedTo,
|
|
350245
350321
|
threadId: data.threadId,
|
|
@@ -350248,7 +350324,7 @@ var init_messages5 = __esm(() => {
|
|
|
350248
350324
|
mediaUrl: data.url,
|
|
350249
350325
|
caption: data.caption,
|
|
350250
350326
|
filename: data.filename,
|
|
350251
|
-
mimeType:
|
|
350327
|
+
mimeType: mediaMimeType
|
|
350252
350328
|
},
|
|
350253
350329
|
metadata: {
|
|
350254
350330
|
base64: data.base64,
|
|
@@ -353059,16 +353135,20 @@ async function setupEventPersistence(eventBus, db2) {
|
|
|
353059
353135
|
eventType: "message.sent",
|
|
353060
353136
|
direction: "outbound",
|
|
353061
353137
|
contentType: mapContentType2(payload.content.type),
|
|
353062
|
-
textContent: sanitizeText(payload.content.text),
|
|
353138
|
+
textContent: sanitizeText(payload.content.text ?? payload.content.caption),
|
|
353063
353139
|
mediaUrl: payload.content.mediaUrl,
|
|
353140
|
+
mediaMimeType: payload.content.mimeType,
|
|
353064
353141
|
chatId: payload.chatId,
|
|
353065
353142
|
replyToExternalId: payload.replyToId,
|
|
353066
353143
|
status: "completed",
|
|
353067
353144
|
receivedAt: new Date(event.timestamp),
|
|
353068
353145
|
processedAt: new Date,
|
|
353146
|
+
rawPayload: payload.rawPayload ? deepSanitize(payload.rawPayload) : undefined,
|
|
353069
353147
|
metadata: {
|
|
353070
353148
|
correlationId: metadata.correlationId,
|
|
353071
|
-
to: payload.to
|
|
353149
|
+
to: payload.to,
|
|
353150
|
+
filename: payload.content.filename,
|
|
353151
|
+
voiceNote: payload.content.isVoiceNote
|
|
353072
353152
|
},
|
|
353073
353153
|
agentId: metadata.agentId ?? null,
|
|
353074
353154
|
conversationId: null,
|
|
@@ -479098,6 +479178,49 @@ class WhatsAppPlugin extends BaseChannelPlugin {
|
|
|
479098
479178
|
}
|
|
479099
479179
|
return phoneJid;
|
|
479100
479180
|
}
|
|
479181
|
+
getSentMediaSource(message2) {
|
|
479182
|
+
if (message2.content.mediaUrl)
|
|
479183
|
+
return "url";
|
|
479184
|
+
if (message2.content.localPath)
|
|
479185
|
+
return "localPath";
|
|
479186
|
+
if (message2.metadata?.base64)
|
|
479187
|
+
return "base64";
|
|
479188
|
+
return;
|
|
479189
|
+
}
|
|
479190
|
+
buildSentRawPayload(externalId, originalMessage, processedMessage) {
|
|
479191
|
+
const mediaSource = this.getSentMediaSource(processedMessage);
|
|
479192
|
+
return {
|
|
479193
|
+
externalId,
|
|
479194
|
+
isFromMe: true,
|
|
479195
|
+
to: originalMessage.to,
|
|
479196
|
+
...processedMessage.content.caption ? { caption: processedMessage.content.caption } : {},
|
|
479197
|
+
...processedMessage.content.filename ? { filename: processedMessage.content.filename } : {},
|
|
479198
|
+
...processedMessage.content.mimeType ? { mimeType: processedMessage.content.mimeType } : {},
|
|
479199
|
+
...processedMessage.metadata?.ptt === true ? { voiceNote: true } : {},
|
|
479200
|
+
...mediaSource ? { mediaSource } : {}
|
|
479201
|
+
};
|
|
479202
|
+
}
|
|
479203
|
+
buildSentEventPayload(instanceId, externalId, chatId, originalMessage, processedMessage) {
|
|
479204
|
+
return {
|
|
479205
|
+
instanceId,
|
|
479206
|
+
externalId,
|
|
479207
|
+
chatId,
|
|
479208
|
+
to: originalMessage.to,
|
|
479209
|
+
content: {
|
|
479210
|
+
type: processedMessage.content.type,
|
|
479211
|
+
text: processedMessage.content.text ?? processedMessage.content.caption,
|
|
479212
|
+
caption: processedMessage.content.caption,
|
|
479213
|
+
mediaUrl: processedMessage.content.mediaUrl,
|
|
479214
|
+
localPath: processedMessage.content.localPath,
|
|
479215
|
+
mimeType: processedMessage.content.mimeType,
|
|
479216
|
+
filename: processedMessage.content.filename,
|
|
479217
|
+
isVoiceNote: processedMessage.metadata?.ptt === true
|
|
479218
|
+
},
|
|
479219
|
+
replyToId: originalMessage.replyTo,
|
|
479220
|
+
rawPayload: this.buildSentRawPayload(externalId, originalMessage, processedMessage),
|
|
479221
|
+
senderAgentId: originalMessage.metadata?.senderAgentId
|
|
479222
|
+
};
|
|
479223
|
+
}
|
|
479101
479224
|
async sendMessage(instanceId, message2) {
|
|
479102
479225
|
const sock = this.getSocket(instanceId);
|
|
479103
479226
|
const jid = await this.resolveSendTarget(sock, instanceId, message2.to);
|
|
@@ -479124,18 +479247,7 @@ class WhatsAppPlugin extends BaseChannelPlugin {
|
|
|
479124
479247
|
this.trackRecentSentMessage(instanceId, externalId, result.message);
|
|
479125
479248
|
}
|
|
479126
479249
|
}
|
|
479127
|
-
await this.emitMessageSent(
|
|
479128
|
-
instanceId,
|
|
479129
|
-
externalId,
|
|
479130
|
-
chatId: jid,
|
|
479131
|
-
to: message2.to,
|
|
479132
|
-
content: {
|
|
479133
|
-
type: message2.content.type,
|
|
479134
|
-
text: message2.content.text
|
|
479135
|
-
},
|
|
479136
|
-
replyToId: message2.replyTo,
|
|
479137
|
-
senderAgentId: message2.metadata?.senderAgentId
|
|
479138
|
-
});
|
|
479250
|
+
await this.emitMessageSent(this.buildSentEventPayload(instanceId, externalId, jid, message2, processedMessage));
|
|
479139
479251
|
rateLimiter.reset();
|
|
479140
479252
|
return {
|
|
479141
479253
|
success: true,
|