@automagik/omni 2.260910.4 → 2.260910.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/dist/commands/events.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/sdk/client.d.ts +3 -0
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/types.generated.d.ts +1 -0
- package/dist/sdk/types.generated.d.ts.map +1 -1
- package/dist/server/index.js +58 -13
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -76924,7 +76924,7 @@ var require_ClientVoiceManager = __commonJS((exports, module) => {
|
|
|
76924
76924
|
|
|
76925
76925
|
// ../../node_modules/.bun/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist/index.js
|
|
76926
76926
|
var require_dist9 = __commonJS((exports, module) => {
|
|
76927
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
76927
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist";
|
|
76928
76928
|
var __create2 = Object.create;
|
|
76929
76929
|
var __defProp2 = Object.defineProperty;
|
|
76930
76930
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -162204,7 +162204,7 @@ var require_indexes = __commonJS((exports, module) => {
|
|
|
162204
162204
|
|
|
162205
162205
|
// ../../node_modules/.bun/thread-stream@3.1.0/node_modules/thread-stream/index.js
|
|
162206
162206
|
var require_thread_stream = __commonJS((exports, module) => {
|
|
162207
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
162207
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/thread-stream@3.1.0/node_modules/thread-stream";
|
|
162208
162208
|
var { version } = require_package5();
|
|
162209
162209
|
var { EventEmitter: EventEmitter3 } = __require("events");
|
|
162210
162210
|
var { Worker } = __require("worker_threads");
|
|
@@ -162625,7 +162625,7 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
162625
162625
|
|
|
162626
162626
|
// ../../node_modules/.bun/pino@9.14.0/node_modules/pino/lib/transport.js
|
|
162627
162627
|
var require_transport2 = __commonJS((exports, module) => {
|
|
162628
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
162628
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/pino@9.14.0/node_modules/pino/lib";
|
|
162629
162629
|
var { createRequire: createRequire2 } = __require("module");
|
|
162630
162630
|
var getCallers = require_caller();
|
|
162631
162631
|
var { join: join8, isAbsolute, sep: sep2 } = __require("path");
|
|
@@ -244369,7 +244369,7 @@ var require_client3 = __commonJS((exports) => {
|
|
|
244369
244369
|
|
|
244370
244370
|
// ../../node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js
|
|
244371
244371
|
var require_esmLoader = __commonJS((exports) => {
|
|
244372
|
-
var __filename = "/home/runner/work/omni/omni
|
|
244372
|
+
var __filename = "/home/runner/work/omni/omni/node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js";
|
|
244373
244373
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
244374
244374
|
var core3 = require_cjs6();
|
|
244375
244375
|
var importInTheMiddle = require_import_in_the_middle();
|
|
@@ -251595,7 +251595,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
251595
251595
|
var require_package7 = __commonJS((exports, module) => {
|
|
251596
251596
|
module.exports = {
|
|
251597
251597
|
name: "@omni/api",
|
|
251598
|
-
version: "2.260910.
|
|
251598
|
+
version: "2.260910.6",
|
|
251599
251599
|
private: true,
|
|
251600
251600
|
type: "module",
|
|
251601
251601
|
exports: {
|
|
@@ -278697,7 +278697,7 @@ var require_src45 = __commonJS((exports) => {
|
|
|
278697
278697
|
|
|
278698
278698
|
// ../../node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src/channelz.js
|
|
278699
278699
|
var require_channelz = __commonJS((exports) => {
|
|
278700
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
278700
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src";
|
|
278701
278701
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
278702
278702
|
exports.registerChannelzSocket = exports.registerChannelzServer = exports.registerChannelzSubchannel = exports.registerChannelzChannel = exports.ChannelzCallTrackerStub = exports.ChannelzCallTracker = exports.ChannelzChildrenTrackerStub = exports.ChannelzChildrenTracker = exports.ChannelzTrace = exports.ChannelzTraceStub = undefined;
|
|
278703
278703
|
exports.unregisterChannelzRef = unregisterChannelzRef;
|
|
@@ -284100,7 +284100,7 @@ var require_duration = __commonJS((exports) => {
|
|
|
284100
284100
|
|
|
284101
284101
|
// ../../node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src/orca.js
|
|
284102
284102
|
var require_orca = __commonJS((exports) => {
|
|
284103
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
284103
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src";
|
|
284104
284104
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
284105
284105
|
exports.OrcaOobMetricsSubchannelWrapper = exports.GRPC_METRICS_HEADER = exports.ServerMetricRecorder = exports.PerRequestMetricRecorder = undefined;
|
|
284106
284106
|
exports.createOrcaClient = createOrcaClient;
|
|
@@ -370406,6 +370406,7 @@ class EventService {
|
|
|
370406
370406
|
channel: channel5,
|
|
370407
370407
|
instanceId,
|
|
370408
370408
|
personId,
|
|
370409
|
+
chatId,
|
|
370409
370410
|
eventType,
|
|
370410
370411
|
contentType,
|
|
370411
370412
|
direction,
|
|
@@ -370427,6 +370428,9 @@ class EventService {
|
|
|
370427
370428
|
if (personId) {
|
|
370428
370429
|
conditions3.push(eq(omniEvents.personId, personId));
|
|
370429
370430
|
}
|
|
370431
|
+
if (chatId) {
|
|
370432
|
+
conditions3.push(eq(omniEvents.chatUuid, chatId));
|
|
370433
|
+
}
|
|
370430
370434
|
if (eventType?.length) {
|
|
370431
370435
|
const exact = eventType.filter((t) => !t.endsWith("*"));
|
|
370432
370436
|
const prefixes = eventType.filter((t) => t.endsWith("*")).map((t) => t.slice(0, -1));
|
|
@@ -380074,6 +380078,7 @@ function registerEventSchemas(registry4) {
|
|
|
380074
380078
|
channel: exports_external.string().optional().openapi({ description: "Channel types (comma-separated)" }),
|
|
380075
380079
|
instanceId: exports_external.string().uuid().optional().openapi({ description: "Filter by instance" }),
|
|
380076
380080
|
personId: exports_external.string().uuid().optional().openapi({ description: "Filter by person" }),
|
|
380081
|
+
chatId: exports_external.string().uuid().optional().openapi({ description: "Filter by chat UUID" }),
|
|
380077
380082
|
eventType: exports_external.string().optional().openapi({ description: "Event types (comma-separated)" }),
|
|
380078
380083
|
contentType: exports_external.string().optional().openapi({ description: "Content types (comma-separated)" }),
|
|
380079
380084
|
direction: exports_external.enum(["inbound", "outbound"]).optional().openapi({ description: "Direction" }),
|
|
@@ -386583,6 +386588,7 @@ var init_events4 = __esm(() => {
|
|
|
386583
386588
|
channel: exports_external.string().optional().transform((v2) => v2?.split(",")),
|
|
386584
386589
|
instanceId: exports_external.string().uuid().optional(),
|
|
386585
386590
|
personId: exports_external.string().uuid().optional(),
|
|
386591
|
+
chatId: exports_external.string().uuid().optional(),
|
|
386586
386592
|
eventType: exports_external.string().optional().transform((v2) => v2?.split(",")),
|
|
386587
386593
|
contentType: exports_external.string().optional().transform((v2) => v2?.split(",")),
|
|
386588
386594
|
direction: exports_external.enum(["inbound", "outbound"]).optional(),
|
|
@@ -397994,6 +398000,42 @@ async function setupEventPersistence(eventBus, db2) {
|
|
|
397994
398000
|
});
|
|
397995
398001
|
}
|
|
397996
398002
|
}, { ...CONSUMER_OPTIONS, durable: "event-persistence-failed" });
|
|
398003
|
+
for (const type of ["reaction.received", "reaction.removed"]) {
|
|
398004
|
+
await eventBus.subscribe(type, async (event) => {
|
|
398005
|
+
const payload = event.payload;
|
|
398006
|
+
const metadata = event.metadata;
|
|
398007
|
+
try {
|
|
398008
|
+
await runConsumerInTenantContext(db2, event, async () => {
|
|
398009
|
+
const sdb = scopedHandle(db2);
|
|
398010
|
+
const chatLink = await resolveChatLink(sdb, metadata.instanceId, payload.chatId);
|
|
398011
|
+
const personId = await resolvePersonId2(sdb, metadata.personId);
|
|
398012
|
+
const newEvent = {
|
|
398013
|
+
...eventIdInsert(event.id),
|
|
398014
|
+
externalId: payload.messageId,
|
|
398015
|
+
channel: mapChannelType(metadata.channelType),
|
|
398016
|
+
instanceId: metadata.instanceId,
|
|
398017
|
+
personId,
|
|
398018
|
+
eventType: type,
|
|
398019
|
+
chatId: payload.chatId,
|
|
398020
|
+
contentType: "reaction",
|
|
398021
|
+
textContent: sanitizeText(payload.emoji),
|
|
398022
|
+
direction: payload.rawPayload?.isFromMe === true ? "outbound" : "inbound",
|
|
398023
|
+
status: "completed",
|
|
398024
|
+
receivedAt: new Date(event.timestamp),
|
|
398025
|
+
rawPayload: deepSanitize({ ...payload, rawPayload: payload.rawPayload ?? null }),
|
|
398026
|
+
metadata: { correlationId: metadata.correlationId, from: payload.from, emoji: payload.emoji },
|
|
398027
|
+
causationId: metadata.causationId ?? null,
|
|
398028
|
+
conversationId: null,
|
|
398029
|
+
...chatLink
|
|
398030
|
+
};
|
|
398031
|
+
await sdb.insert(omniEvents).values(newEvent).onConflictDoNothing({ target: omniEvents.id });
|
|
398032
|
+
});
|
|
398033
|
+
log125.debug(`Persisted ${type}`, { messageId: payload.messageId, emoji: payload.emoji });
|
|
398034
|
+
} catch (error3) {
|
|
398035
|
+
log125.error(`Failed to persist ${type}`, { messageId: payload.messageId, error: String(error3) });
|
|
398036
|
+
}
|
|
398037
|
+
}, { ...CONSUMER_OPTIONS, durable: `event-persistence-${type.replace(".", "-")}` });
|
|
398038
|
+
}
|
|
397997
398039
|
await eventBus.subscribePattern("custom.>", async (event) => {
|
|
397998
398040
|
const metadata = event.metadata;
|
|
397999
398041
|
try {
|
|
@@ -407526,7 +407568,8 @@ class DiscordPlugin extends BaseChannelPlugin {
|
|
|
407526
407568
|
rawPayload: {
|
|
407527
407569
|
deletedMessageId: messageId,
|
|
407528
407570
|
deletedAt: Date.now(),
|
|
407529
|
-
deletedByMe: fromMe
|
|
407571
|
+
deletedByMe: fromMe,
|
|
407572
|
+
isFromMe: fromMe
|
|
407530
407573
|
}
|
|
407531
407574
|
});
|
|
407532
407575
|
this.logger.debug("Message deleted", { instanceId, messageId, chatId });
|
|
@@ -528280,7 +528323,7 @@ async function handleSpecialMessage(plugin10, instanceId, content, externalId, c
|
|
|
528280
528323
|
return true;
|
|
528281
528324
|
}
|
|
528282
528325
|
if (content.type === "edit" && content.targetMessageId) {
|
|
528283
|
-
await plugin10.handleMessageEdited(instanceId, content.targetMessageId, chatId, content.editedText || content.text || "");
|
|
528326
|
+
await plugin10.handleMessageEdited(instanceId, content.targetMessageId, chatId, content.editedText || content.text || "", isFromMe(msg));
|
|
528284
528327
|
return true;
|
|
528285
528328
|
}
|
|
528286
528329
|
if (content.type === "delete" && content.targetMessageId) {
|
|
@@ -528458,7 +528501,7 @@ function setupMessageHandlers4(sock, plugin10, instanceId, decryptTracker, dedup
|
|
|
528458
528501
|
const editedContent = update.update.message;
|
|
528459
528502
|
const newText = editedContent.conversation || editedContent.extendedTextMessage?.text || editedContent.imageMessage?.caption || editedContent.videoMessage?.caption || null;
|
|
528460
528503
|
if (newText) {
|
|
528461
|
-
await plugin10.handleMessageEdited(instanceId, update.key.id || "", update.key.remoteJid || "", newText);
|
|
528504
|
+
await plugin10.handleMessageEdited(instanceId, update.key.id || "", update.key.remoteJid || "", newText, update.key.fromMe || false);
|
|
528462
528505
|
}
|
|
528463
528506
|
}
|
|
528464
528507
|
}
|
|
@@ -531391,7 +531434,7 @@ class WhatsAppPlugin extends BaseChannelPlugin {
|
|
|
531391
531434
|
retryable: false
|
|
531392
531435
|
});
|
|
531393
531436
|
}
|
|
531394
|
-
async handleMessageEdited(instanceId, externalId, chatId, newText) {
|
|
531437
|
+
async handleMessageEdited(instanceId, externalId, chatId, newText, fromMe = false) {
|
|
531395
531438
|
await this.emitMessageReceived({
|
|
531396
531439
|
instanceId,
|
|
531397
531440
|
externalId: `${externalId}-edit-${Date.now()}`,
|
|
@@ -531404,7 +531447,8 @@ class WhatsAppPlugin extends BaseChannelPlugin {
|
|
|
531404
531447
|
rawPayload: {
|
|
531405
531448
|
editedMessageId: externalId,
|
|
531406
531449
|
newText,
|
|
531407
|
-
editedAt: Date.now()
|
|
531450
|
+
editedAt: Date.now(),
|
|
531451
|
+
isFromMe: fromMe
|
|
531408
531452
|
}
|
|
531409
531453
|
});
|
|
531410
531454
|
this.logger.debug("Message edited", { instanceId, externalId, chatId, newText: newText.substring(0, 50) });
|
|
@@ -531419,7 +531463,8 @@ class WhatsAppPlugin extends BaseChannelPlugin {
|
|
|
531419
531463
|
rawPayload: {
|
|
531420
531464
|
deletedMessageId: externalId,
|
|
531421
531465
|
deletedAt: Date.now(),
|
|
531422
|
-
deletedByMe: fromMe
|
|
531466
|
+
deletedByMe: fromMe,
|
|
531467
|
+
isFromMe: fromMe
|
|
531423
531468
|
}
|
|
531424
531469
|
});
|
|
531425
531470
|
this.logger.debug("Message deleted", { instanceId, externalId, chatId, fromMe });
|