@automagik/omni 2.260531.6 → 2.260602.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/commands/persons.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/server/index.js +124 -30
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persons.d.ts","sourceRoot":"","sources":["../../src/commands/persons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"persons.d.ts","sourceRoot":"","sources":["../../src/commands/persons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,IAAI,OAAO,CAyL9C"}
|
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.260602.1",
|
|
124971
124971
|
description: "LLM-optimized CLI for Omni",
|
|
124972
124972
|
type: "module",
|
|
124973
124973
|
bin: {
|
|
@@ -134834,8 +134834,8 @@ function createPersonsCommand() {
|
|
|
134834
134834
|
const items = persons3.map((p11) => ({
|
|
134835
134835
|
id: p11.id,
|
|
134836
134836
|
displayName: p11.displayName ?? "-",
|
|
134837
|
-
email: p11.email ?? "-",
|
|
134838
|
-
phone: p11.phone ?? "-"
|
|
134837
|
+
email: p11.primaryEmail ?? p11.email ?? "-",
|
|
134838
|
+
phone: p11.primaryPhone ?? p11.phone ?? "-"
|
|
134839
134839
|
}));
|
|
134840
134840
|
list(items, { emptyMessage: "No persons found." });
|
|
134841
134841
|
} catch (err2) {
|
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.260602.1",
|
|
225245
225245
|
type: "module",
|
|
225246
225246
|
exports: {
|
|
225247
225247
|
".": {
|
|
@@ -336171,7 +336171,66 @@ class PersonService {
|
|
|
336171
336171
|
}
|
|
336172
336172
|
async search(query, limit2 = 20) {
|
|
336173
336173
|
const searchPattern = `%${query}%`;
|
|
336174
|
-
|
|
336174
|
+
const result = await this.db.execute(sql`
|
|
336175
|
+
WITH candidates AS (
|
|
336176
|
+
SELECT
|
|
336177
|
+
p.id,
|
|
336178
|
+
CASE
|
|
336179
|
+
WHEN p.display_name ILIKE ${searchPattern} ESCAPE '' THEN p.display_name
|
|
336180
|
+
WHEN pi.platform_username ILIKE ${searchPattern} ESCAPE '' THEN pi.platform_username
|
|
336181
|
+
WHEN cp.display_name ILIKE ${searchPattern} ESCAPE '' THEN cp.display_name
|
|
336182
|
+
ELSE COALESCE(NULLIF(p.display_name, ''), NULLIF(pi.platform_username, ''), NULLIF(cp.display_name, ''))
|
|
336183
|
+
END AS "displayName",
|
|
336184
|
+
p.primary_phone AS "primaryPhone",
|
|
336185
|
+
p.primary_email AS "primaryEmail",
|
|
336186
|
+
p.avatar_url AS "avatarUrl",
|
|
336187
|
+
p.metadata,
|
|
336188
|
+
p.created_at AS "createdAt",
|
|
336189
|
+
p.updated_at AS "updatedAt",
|
|
336190
|
+
GREATEST(
|
|
336191
|
+
COALESCE(pi.last_seen_at, 'epoch'::timestamptz),
|
|
336192
|
+
COALESCE(cp.last_seen_at, 'epoch'::timestamptz),
|
|
336193
|
+
COALESCE(p.updated_at, 'epoch'::timestamptz)
|
|
336194
|
+
) AS rank_ts
|
|
336195
|
+
FROM persons p
|
|
336196
|
+
LEFT JOIN platform_identities pi ON pi.person_id = p.id
|
|
336197
|
+
LEFT JOIN chat_participants cp ON cp.person_id = p.id OR cp.platform_identity_id = pi.id
|
|
336198
|
+
WHERE
|
|
336199
|
+
p.display_name ILIKE ${searchPattern} ESCAPE ''
|
|
336200
|
+
OR p.primary_email ILIKE ${searchPattern} ESCAPE ''
|
|
336201
|
+
OR p.primary_phone ILIKE ${searchPattern} ESCAPE ''
|
|
336202
|
+
OR pi.platform_username ILIKE ${searchPattern} ESCAPE ''
|
|
336203
|
+
OR pi.platform_user_id ILIKE ${searchPattern} ESCAPE ''
|
|
336204
|
+
OR cp.display_name ILIKE ${searchPattern} ESCAPE ''
|
|
336205
|
+
OR cp.platform_user_id ILIKE ${searchPattern} ESCAPE ''
|
|
336206
|
+
), distinct_candidates AS (
|
|
336207
|
+
SELECT DISTINCT ON (id)
|
|
336208
|
+
id,
|
|
336209
|
+
"displayName",
|
|
336210
|
+
"primaryPhone",
|
|
336211
|
+
"primaryEmail",
|
|
336212
|
+
"avatarUrl",
|
|
336213
|
+
metadata,
|
|
336214
|
+
"createdAt",
|
|
336215
|
+
"updatedAt",
|
|
336216
|
+
rank_ts
|
|
336217
|
+
FROM candidates
|
|
336218
|
+
ORDER BY id, rank_ts DESC
|
|
336219
|
+
)
|
|
336220
|
+
SELECT
|
|
336221
|
+
id,
|
|
336222
|
+
"displayName",
|
|
336223
|
+
"primaryPhone",
|
|
336224
|
+
"primaryEmail",
|
|
336225
|
+
"avatarUrl",
|
|
336226
|
+
metadata,
|
|
336227
|
+
"createdAt",
|
|
336228
|
+
"updatedAt"
|
|
336229
|
+
FROM distinct_candidates
|
|
336230
|
+
ORDER BY rank_ts DESC
|
|
336231
|
+
LIMIT ${limit2}
|
|
336232
|
+
`);
|
|
336233
|
+
return result;
|
|
336175
336234
|
}
|
|
336176
336235
|
async getById(id) {
|
|
336177
336236
|
const [result] = await this.db.select().from(persons).where(eq(persons.id, id)).limit(1);
|
|
@@ -355670,6 +355729,67 @@ function extractReactionTargetParticipant(rawPayload) {
|
|
|
355670
355729
|
const participant = key?.participant;
|
|
355671
355730
|
return typeof participant === "string" && participant.length > 0 ? participant : undefined;
|
|
355672
355731
|
}
|
|
355732
|
+
async function resolveReactionTarget(services, instanceId, resolvedTo, messageId) {
|
|
355733
|
+
const metadata = {};
|
|
355734
|
+
const chat2 = await services.chats.findByExternalIdSmart(instanceId, resolvedTo);
|
|
355735
|
+
if (!chat2) {
|
|
355736
|
+
if (isUUID(messageId)) {
|
|
355737
|
+
throw new OmniError({
|
|
355738
|
+
code: ERROR_CODES.NOT_FOUND,
|
|
355739
|
+
message: `Reaction target message not found: ${messageId}`,
|
|
355740
|
+
context: { instanceId, resolvedTo, messageId },
|
|
355741
|
+
recoverable: false
|
|
355742
|
+
});
|
|
355743
|
+
}
|
|
355744
|
+
log110.warn("Reaction target chat not found in DB; deferring fromMe to channel plugin fallback (#386)", {
|
|
355745
|
+
instanceId,
|
|
355746
|
+
resolvedTo,
|
|
355747
|
+
messageId,
|
|
355748
|
+
fallback: "plugin-heuristic"
|
|
355749
|
+
});
|
|
355750
|
+
return { targetMessageId: messageId, metadata };
|
|
355751
|
+
}
|
|
355752
|
+
const target = isUUID(messageId) ? await getReactionTargetByOmniId(services, instanceId, chat2.id, messageId) : await services.messages.getByExternalId(chat2.id, messageId);
|
|
355753
|
+
if (!target) {
|
|
355754
|
+
log110.warn("Reaction target message not found in DB; deferring fromMe to channel plugin fallback (#386)", {
|
|
355755
|
+
instanceId,
|
|
355756
|
+
chatId: chat2.id,
|
|
355757
|
+
messageId,
|
|
355758
|
+
fallback: "plugin-heuristic"
|
|
355759
|
+
});
|
|
355760
|
+
return { targetMessageId: messageId, metadata };
|
|
355761
|
+
}
|
|
355762
|
+
metadata.fromMe = target.isFromMe === true;
|
|
355763
|
+
if (target.isFromMe !== true) {
|
|
355764
|
+
const participant = extractReactionTargetParticipant(target.rawPayload);
|
|
355765
|
+
if (participant)
|
|
355766
|
+
metadata.targetParticipant = participant;
|
|
355767
|
+
}
|
|
355768
|
+
return { targetMessageId: target.externalId, metadata };
|
|
355769
|
+
}
|
|
355770
|
+
async function getReactionTargetByOmniId(services, instanceId, chatId, messageId) {
|
|
355771
|
+
let target;
|
|
355772
|
+
try {
|
|
355773
|
+
target = await services.messages.getById(messageId);
|
|
355774
|
+
} catch (error3) {
|
|
355775
|
+
if (error3 instanceof NotFoundError) {
|
|
355776
|
+
throw reactionTargetNotFound(instanceId, chatId, messageId);
|
|
355777
|
+
}
|
|
355778
|
+
throw error3;
|
|
355779
|
+
}
|
|
355780
|
+
if (target.chatId !== chatId) {
|
|
355781
|
+
throw reactionTargetNotFound(instanceId, chatId, messageId);
|
|
355782
|
+
}
|
|
355783
|
+
return target;
|
|
355784
|
+
}
|
|
355785
|
+
function reactionTargetNotFound(instanceId, chatId, messageId) {
|
|
355786
|
+
return new OmniError({
|
|
355787
|
+
code: ERROR_CODES.NOT_FOUND,
|
|
355788
|
+
message: `Reaction target message not found: ${messageId}`,
|
|
355789
|
+
context: { instanceId, chatId, messageId },
|
|
355790
|
+
recoverable: false
|
|
355791
|
+
});
|
|
355792
|
+
}
|
|
355673
355793
|
async function resolveRecipient(to, channelType, services) {
|
|
355674
355794
|
if (!isUUID(to))
|
|
355675
355795
|
return to;
|
|
@@ -356426,39 +356546,13 @@ var init_messages5 = __esm(() => {
|
|
|
356426
356546
|
});
|
|
356427
356547
|
}
|
|
356428
356548
|
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
|
-
}
|
|
356549
|
+
const { targetMessageId, metadata: reactionMetadata } = await resolveReactionTarget(services, instanceId, resolvedTo, messageId);
|
|
356456
356550
|
const outgoingMessage = {
|
|
356457
356551
|
to: resolvedTo,
|
|
356458
356552
|
content: {
|
|
356459
356553
|
type: "reaction",
|
|
356460
356554
|
emoji,
|
|
356461
|
-
targetMessageId
|
|
356555
|
+
targetMessageId
|
|
356462
356556
|
},
|
|
356463
356557
|
metadata: reactionMetadata
|
|
356464
356558
|
};
|