@automagik/omni 2.260531.6 → 2.260601.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 +64 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -124967,7 +124967,7 @@ import { fileURLToPath } from "url";
|
|
|
124967
124967
|
// package.json
|
|
124968
124968
|
var package_default = {
|
|
124969
124969
|
name: "@automagik/omni",
|
|
124970
|
-
version: "2.
|
|
124970
|
+
version: "2.260601.1",
|
|
124971
124971
|
description: "LLM-optimized CLI for Omni",
|
|
124972
124972
|
type: "module",
|
|
124973
124973
|
bin: {
|
package/dist/server/index.js
CHANGED
|
@@ -225241,7 +225241,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
225241
225241
|
var require_package7 = __commonJS((exports, module) => {
|
|
225242
225242
|
module.exports = {
|
|
225243
225243
|
name: "@omni/api",
|
|
225244
|
-
version: "2.
|
|
225244
|
+
version: "2.260601.1",
|
|
225245
225245
|
type: "module",
|
|
225246
225246
|
exports: {
|
|
225247
225247
|
".": {
|
|
@@ -355670,6 +355670,67 @@ function extractReactionTargetParticipant(rawPayload) {
|
|
|
355670
355670
|
const participant = key?.participant;
|
|
355671
355671
|
return typeof participant === "string" && participant.length > 0 ? participant : undefined;
|
|
355672
355672
|
}
|
|
355673
|
+
async function resolveReactionTarget(services, instanceId, resolvedTo, messageId) {
|
|
355674
|
+
const metadata = {};
|
|
355675
|
+
const chat2 = await services.chats.findByExternalIdSmart(instanceId, resolvedTo);
|
|
355676
|
+
if (!chat2) {
|
|
355677
|
+
if (isUUID(messageId)) {
|
|
355678
|
+
throw new OmniError({
|
|
355679
|
+
code: ERROR_CODES.NOT_FOUND,
|
|
355680
|
+
message: `Reaction target message not found: ${messageId}`,
|
|
355681
|
+
context: { instanceId, resolvedTo, messageId },
|
|
355682
|
+
recoverable: false
|
|
355683
|
+
});
|
|
355684
|
+
}
|
|
355685
|
+
log110.warn("Reaction target chat not found in DB; deferring fromMe to channel plugin fallback (#386)", {
|
|
355686
|
+
instanceId,
|
|
355687
|
+
resolvedTo,
|
|
355688
|
+
messageId,
|
|
355689
|
+
fallback: "plugin-heuristic"
|
|
355690
|
+
});
|
|
355691
|
+
return { targetMessageId: messageId, metadata };
|
|
355692
|
+
}
|
|
355693
|
+
const target = isUUID(messageId) ? await getReactionTargetByOmniId(services, instanceId, chat2.id, messageId) : await services.messages.getByExternalId(chat2.id, messageId);
|
|
355694
|
+
if (!target) {
|
|
355695
|
+
log110.warn("Reaction target message not found in DB; deferring fromMe to channel plugin fallback (#386)", {
|
|
355696
|
+
instanceId,
|
|
355697
|
+
chatId: chat2.id,
|
|
355698
|
+
messageId,
|
|
355699
|
+
fallback: "plugin-heuristic"
|
|
355700
|
+
});
|
|
355701
|
+
return { targetMessageId: messageId, metadata };
|
|
355702
|
+
}
|
|
355703
|
+
metadata.fromMe = target.isFromMe === true;
|
|
355704
|
+
if (target.isFromMe !== true) {
|
|
355705
|
+
const participant = extractReactionTargetParticipant(target.rawPayload);
|
|
355706
|
+
if (participant)
|
|
355707
|
+
metadata.targetParticipant = participant;
|
|
355708
|
+
}
|
|
355709
|
+
return { targetMessageId: target.externalId, metadata };
|
|
355710
|
+
}
|
|
355711
|
+
async function getReactionTargetByOmniId(services, instanceId, chatId, messageId) {
|
|
355712
|
+
let target;
|
|
355713
|
+
try {
|
|
355714
|
+
target = await services.messages.getById(messageId);
|
|
355715
|
+
} catch (error3) {
|
|
355716
|
+
if (error3 instanceof NotFoundError) {
|
|
355717
|
+
throw reactionTargetNotFound(instanceId, chatId, messageId);
|
|
355718
|
+
}
|
|
355719
|
+
throw error3;
|
|
355720
|
+
}
|
|
355721
|
+
if (target.chatId !== chatId) {
|
|
355722
|
+
throw reactionTargetNotFound(instanceId, chatId, messageId);
|
|
355723
|
+
}
|
|
355724
|
+
return target;
|
|
355725
|
+
}
|
|
355726
|
+
function reactionTargetNotFound(instanceId, chatId, messageId) {
|
|
355727
|
+
return new OmniError({
|
|
355728
|
+
code: ERROR_CODES.NOT_FOUND,
|
|
355729
|
+
message: `Reaction target message not found: ${messageId}`,
|
|
355730
|
+
context: { instanceId, chatId, messageId },
|
|
355731
|
+
recoverable: false
|
|
355732
|
+
});
|
|
355733
|
+
}
|
|
355673
355734
|
async function resolveRecipient(to, channelType, services) {
|
|
355674
355735
|
if (!isUUID(to))
|
|
355675
355736
|
return to;
|
|
@@ -356426,39 +356487,13 @@ var init_messages5 = __esm(() => {
|
|
|
356426
356487
|
});
|
|
356427
356488
|
}
|
|
356428
356489
|
const resolvedTo = await resolveRecipient(to, instance4.channel, services);
|
|
356429
|
-
const reactionMetadata =
|
|
356430
|
-
const chat2 = await services.chats.findByExternalIdSmart(instanceId, resolvedTo);
|
|
356431
|
-
if (chat2) {
|
|
356432
|
-
const target = await services.messages.getByExternalId(chat2.id, messageId);
|
|
356433
|
-
if (target) {
|
|
356434
|
-
reactionMetadata.fromMe = target.isFromMe === true;
|
|
356435
|
-
if (target.isFromMe !== true) {
|
|
356436
|
-
const participant = extractReactionTargetParticipant(target.rawPayload);
|
|
356437
|
-
if (participant)
|
|
356438
|
-
reactionMetadata.targetParticipant = participant;
|
|
356439
|
-
}
|
|
356440
|
-
} else {
|
|
356441
|
-
log110.warn("Reaction target message not found in DB; deferring fromMe to channel plugin fallback (#386)", {
|
|
356442
|
-
instanceId,
|
|
356443
|
-
chatId: chat2.id,
|
|
356444
|
-
messageId,
|
|
356445
|
-
fallback: "plugin-heuristic"
|
|
356446
|
-
});
|
|
356447
|
-
}
|
|
356448
|
-
} else {
|
|
356449
|
-
log110.warn("Reaction target chat not found in DB; deferring fromMe to channel plugin fallback (#386)", {
|
|
356450
|
-
instanceId,
|
|
356451
|
-
resolvedTo,
|
|
356452
|
-
messageId,
|
|
356453
|
-
fallback: "plugin-heuristic"
|
|
356454
|
-
});
|
|
356455
|
-
}
|
|
356490
|
+
const { targetMessageId, metadata: reactionMetadata } = await resolveReactionTarget(services, instanceId, resolvedTo, messageId);
|
|
356456
356491
|
const outgoingMessage = {
|
|
356457
356492
|
to: resolvedTo,
|
|
356458
356493
|
content: {
|
|
356459
356494
|
type: "reaction",
|
|
356460
356495
|
emoji,
|
|
356461
|
-
targetMessageId
|
|
356496
|
+
targetMessageId
|
|
356462
356497
|
},
|
|
356463
356498
|
metadata: reactionMetadata
|
|
356464
356499
|
};
|