@automagik/omni 2.260609.2 → 2.260609.4

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 CHANGED
@@ -124971,7 +124971,7 @@ import { fileURLToPath } from "url";
124971
124971
  // package.json
124972
124972
  var package_default = {
124973
124973
  name: "@automagik/omni",
124974
- version: "2.260609.2",
124974
+ version: "2.260609.4",
124975
124975
  description: "LLM-optimized CLI for Omni",
124976
124976
  type: "module",
124977
124977
  bin: {
@@ -225245,7 +225245,7 @@ var init_sentry_scrub = __esm(() => {
225245
225245
  var require_package7 = __commonJS((exports, module) => {
225246
225246
  module.exports = {
225247
225247
  name: "@omni/api",
225248
- version: "2.260609.2",
225248
+ version: "2.260609.4",
225249
225249
  type: "module",
225250
225250
  exports: {
225251
225251
  ".": {
@@ -335748,6 +335748,28 @@ class MessageService {
335748
335748
  const [result] = await this.db.select().from(messages2).where(and2(eq(messages2.chatId, chatId), eq(messages2.isFromMe, true), or2(...aliasConditions))).orderBy(desc(messages2.platformTimestamp)).limit(1);
335749
335749
  return result ?? null;
335750
335750
  }
335751
+ async findRecentOutboundBefore(chatId, before, inboundText) {
335752
+ const upperBound = new Date(before.getTime() + 2000);
335753
+ const rows = await this.db.select().from(messages2).where(and2(eq(messages2.chatId, chatId), eq(messages2.isFromMe, true), lte(messages2.platformTimestamp, upperBound), sql`${messages2.deletedAt} IS NULL`)).orderBy(desc(messages2.platformTimestamp)).limit(8);
335754
+ if (rows.length === 0)
335755
+ return null;
335756
+ const hint = (inboundText ?? "").toLocaleLowerCase("pt-BR");
335757
+ const wantsPlanLikeTarget = /\b(esse|essa|este|esta|op[c\u00E7][a\u00E3]o|plano|quero|gostei)\b/i.test(hint);
335758
+ if (!wantsPlanLikeTarget)
335759
+ return rows[0] ?? null;
335760
+ const score = (message2) => {
335761
+ const text3 = (message2.textContent ?? "").toLocaleLowerCase("pt-BR");
335762
+ let value = 0;
335763
+ if (/op[c\u00E7][a\u00E3]o|plano/.test(text3))
335764
+ value += 4;
335765
+ if (/r\$|mensal|coparticipa|enfermaria|apartamento|ambulatorial|notrelife|hapvida/.test(text3))
335766
+ value += 3;
335767
+ if (/\?\s*$/.test(text3) && !/r\$/.test(text3))
335768
+ value -= 2;
335769
+ return value;
335770
+ };
335771
+ return rows.map((message2) => ({ message: message2, score: score(message2) })).sort((a, b3) => b3.score - a.score || b3.message.platformTimestamp.getTime() - a.message.platformTimestamp.getTime())[0]?.message ?? null;
335772
+ }
335751
335773
  async getByExternalIds(chatId, externalIds) {
335752
335774
  if (externalIds.length === 0)
335753
335775
  return [];
@@ -338454,7 +338476,7 @@ function getMessageContentText(msg) {
338454
338476
  function uniqueNonEmpty(values2) {
338455
338477
  return [...new Set(values2.filter((value) => typeof value === "string" && value.length > 0))];
338456
338478
  }
338457
- async function lookupQuotedMessage(messages4, chatDbId, replyToId, aliases) {
338479
+ async function lookupQuotedMessage(messages4, chatDbId, replyToId, aliases, options = {}) {
338458
338480
  const quoted = await messages4.getByExternalId(chatDbId, replyToId);
338459
338481
  if (quoted)
338460
338482
  return quoted;
@@ -338472,14 +338494,19 @@ async function lookupQuotedMessage(messages4, chatDbId, replyToId, aliases) {
338472
338494
  if (byExternalId)
338473
338495
  return byExternalId;
338474
338496
  }
338497
+ if (options.inboundAt && aliasLookup.findRecentOutboundBefore) {
338498
+ const fallback = await aliasLookup.findRecentOutboundBefore(chatDbId, options.inboundAt, options.inboundText);
338499
+ if (fallback)
338500
+ return fallback;
338501
+ }
338475
338502
  return null;
338476
338503
  }
338477
- async function resolveQuotedMessage(services, instanceId, chatId, replyToId, providerAliases = []) {
338504
+ async function resolveQuotedMessage(services, instanceId, chatId, replyToId, providerAliases = [], options = {}) {
338478
338505
  try {
338479
338506
  const chat2 = await services.chats.findByExternalIdSmart(instanceId, chatId);
338480
338507
  if (!chat2)
338481
338508
  return null;
338482
- const quoted = await lookupQuotedMessage(services.messages, chat2.id, replyToId, providerAliases);
338509
+ const quoted = await lookupQuotedMessage(services.messages, chat2.id, replyToId, providerAliases, options);
338483
338510
  if (!quoted)
338484
338511
  return null;
338485
338512
  const sender = quoted.senderDisplayName ?? quoted.senderPlatformUserId ?? (quoted.isFromMe ? "You" : "unknown");
@@ -338560,13 +338587,27 @@ function extractQuotedProviderAliases(rawPayload) {
338560
338587
  topContext?.id
338561
338588
  ]);
338562
338589
  }
338590
+ function extractInboundPlatformDate(rawPayload) {
338591
+ if (!rawPayload)
338592
+ return;
338593
+ const messageObj = isRecord(rawPayload.messageobj) ? rawPayload.messageobj : undefined;
338594
+ const timestamp3 = messageObj?.timestamp;
338595
+ if (typeof timestamp3 === "number" && Number.isFinite(timestamp3) && timestamp3 > 0) {
338596
+ return new Date(timestamp3 * 1000);
338597
+ }
338598
+ return;
338599
+ }
338563
338600
  async function prependQuotedContext(services, instanceId, chatId, messages4, entries, messageKeyByIndex) {
338564
338601
  for (const [index2, m2] of messages4.entries()) {
338565
338602
  const replyToId = m2.payload.replyToId;
338566
338603
  if (!replyToId)
338567
338604
  continue;
338568
- const providerAliases = extractQuotedProviderAliases(m2.payload.rawPayload);
338569
- const quotedText = await resolveQuotedMessage(services, instanceId, chatId, replyToId, providerAliases);
338605
+ const rawPayload = m2.payload.rawPayload;
338606
+ const providerAliases = extractQuotedProviderAliases(rawPayload);
338607
+ const quotedText = await resolveQuotedMessage(services, instanceId, chatId, replyToId, providerAliases, {
338608
+ inboundAt: extractInboundPlatformDate(rawPayload),
338609
+ inboundText: m2.payload.content?.text
338610
+ });
338570
338611
  if (!quotedText)
338571
338612
  continue;
338572
338613
  const messageKey = messageKeyByIndex.get(index2);
@@ -353168,27 +353209,6 @@ async function enrichContactNames(contacts, services, instanceId) {
353168
353209
  contact.name = dbName;
353169
353210
  }
353170
353211
  }
353171
- async function resolveInstancePlugin(services, channelRegistry2, instanceId) {
353172
- const instance4 = await services.instances.getById(instanceId);
353173
- if (!channelRegistry2) {
353174
- return { ok: false, status: 503, error: { code: "NO_REGISTRY", message: "Channel registry not available" } };
353175
- }
353176
- const plugin7 = channelRegistry2.get(instance4.channel);
353177
- if (!plugin7) {
353178
- return {
353179
- ok: false,
353180
- status: 400,
353181
- error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` }
353182
- };
353183
- }
353184
- return { ok: true, plugin: plugin7 };
353185
- }
353186
- function participantUpdateResponse(result) {
353187
- return {
353188
- ...result,
353189
- changedCount: result.participants.length
353190
- };
353191
- }
353192
353212
  function parseDuration(duration) {
353193
353213
  const match2 = duration.match(/^(\d+)(s|m|h|d)$/);
353194
353214
  if (!match2?.[1] || !match2[2])
@@ -353228,7 +353248,7 @@ function getCacheKey(instanceId, guildId) {
353228
353248
  function invalidateGuildCache(instanceId, guildId) {
353229
353249
  guildConfigCache.delete(getCacheKey(instanceId, guildId));
353230
353250
  }
353231
- var log108, instancesRoutes, instanceAccess2, listQuerySchema12, agentReplyFilterSchema, createInstanceSchema, updateInstanceSchema, DEFAULT_AGENT_REPLY_FILTER, SENSITIVE_INSTANCE_FIELDS, pairingCodeSchema, connectInstanceSchema, syncRequestSchema, listContactsQuerySchema, listGroupsQuerySchema, checkNumberSchema, updateBioSchema, blockContactSchema, groupParticipantActionSchema, groupSettingSchema, groupParticipantsSchema, groupParticipantsPatchSchema, updateGroupSubjectSchema, updateGroupDescriptionSchema, updateGroupSettingsSchema, patchGroupSchema, resyncSchema, replaySchema, pairingActionSchema, guildConfigOverrideSchema, guildConfigCache, GUILD_CONFIG_TTL, presenceSchema;
353251
+ var log108, instancesRoutes, instanceAccess2, listQuerySchema12, agentReplyFilterSchema, createInstanceSchema, updateInstanceSchema, DEFAULT_AGENT_REPLY_FILTER, SENSITIVE_INSTANCE_FIELDS, pairingCodeSchema, connectInstanceSchema, syncRequestSchema, listContactsQuerySchema, listGroupsQuerySchema, checkNumberSchema, updateBioSchema, blockContactSchema, resyncSchema, replaySchema, pairingActionSchema, guildConfigOverrideSchema, guildConfigCache, GUILD_CONFIG_TTL, presenceSchema;
353232
353252
  var init_instances3 = __esm(() => {
353233
353253
  init_dist6();
353234
353254
  init_src();
@@ -354330,30 +354350,6 @@ var init_instances3 = __esm(() => {
354330
354350
  return c.json({ error: { code: "REMOVE_FAILED", message: message2 } }, 500);
354331
354351
  }
354332
354352
  });
354333
- groupParticipantActionSchema = exports_external.enum(["add", "remove", "promote", "demote"]);
354334
- groupSettingSchema = exports_external.enum(["announcement", "not_announcement", "locked", "unlocked"]);
354335
- groupParticipantsSchema = exports_external.object({
354336
- participants: exports_external.array(exports_external.string().min(1)).min(1).describe("Phone numbers or JIDs to mutate")
354337
- });
354338
- groupParticipantsPatchSchema = groupParticipantsSchema.extend({
354339
- action: groupParticipantActionSchema.describe("Participant mutation action")
354340
- });
354341
- updateGroupSubjectSchema = exports_external.object({
354342
- subject: exports_external.string().min(1).max(100).describe("New group name/subject")
354343
- });
354344
- updateGroupDescriptionSchema = exports_external.object({
354345
- description: exports_external.string().max(2048).describe("New group description. Empty string clears the description.")
354346
- });
354347
- updateGroupSettingsSchema = exports_external.object({
354348
- setting: groupSettingSchema.describe("Group setting to apply")
354349
- });
354350
- patchGroupSchema = exports_external.object({
354351
- subject: exports_external.string().min(1).max(100).optional(),
354352
- description: exports_external.string().max(2048).optional(),
354353
- setting: groupSettingSchema.optional()
354354
- }).refine((value) => value.subject !== undefined || value.description !== undefined || value.setting !== undefined, {
354355
- message: "At least one of subject, description, or setting is required"
354356
- });
354357
354353
  instancesRoutes.post("/:id/groups", instanceAccess2, zValidator("json", exports_external.object({
354358
354354
  subject: exports_external.string().min(1).max(100).describe("Group name/subject"),
354359
354355
  participants: exports_external.array(exports_external.string().min(1)).min(1).describe("Phone numbers or JIDs to add")
@@ -354373,218 +354369,6 @@ var init_instances3 = __esm(() => {
354373
354369
  const result = await plugin7.groupCreate(id, subject, participants);
354374
354370
  return c.json({ data: result }, 201);
354375
354371
  });
354376
- instancesRoutes.post("/:id/groups/:groupJid/participants", instanceAccess2, zValidator("json", groupParticipantsSchema), async (c) => {
354377
- const id = c.req.param("id");
354378
- const groupJid = c.req.param("groupJid");
354379
- const { participants } = c.req.valid("json");
354380
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354381
- if (!resolved.ok)
354382
- return c.json({ error: resolved.error }, resolved.status);
354383
- if (typeof resolved.plugin.updateGroupParticipants !== "function") {
354384
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group participant updates" } }, 400);
354385
- }
354386
- try {
354387
- const result = await resolved.plugin.updateGroupParticipants(id, groupJid, participants, "add");
354388
- return c.json({ success: true, data: participantUpdateResponse(result) });
354389
- } catch (error3) {
354390
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354391
- return c.json({ error: { code: "GROUP_PARTICIPANTS_UPDATE_FAILED", message: message2 } }, 500);
354392
- }
354393
- });
354394
- instancesRoutes.post("/:id/groups/:groupJid/participants/:action", instanceAccess2, zValidator("json", groupParticipantsSchema), async (c) => {
354395
- const id = c.req.param("id");
354396
- const groupJid = c.req.param("groupJid");
354397
- const parsedAction = groupParticipantActionSchema.safeParse(c.req.param("action"));
354398
- const { participants } = c.req.valid("json");
354399
- if (!parsedAction.success) {
354400
- return c.json({
354401
- error: {
354402
- code: "VALIDATION_ERROR",
354403
- message: "Invalid group participant action. Expected add, remove, promote, or demote."
354404
- }
354405
- }, 400);
354406
- }
354407
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354408
- if (!resolved.ok)
354409
- return c.json({ error: resolved.error }, resolved.status);
354410
- if (typeof resolved.plugin.updateGroupParticipants !== "function") {
354411
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group participant updates" } }, 400);
354412
- }
354413
- try {
354414
- const result = await resolved.plugin.updateGroupParticipants(id, groupJid, participants, parsedAction.data);
354415
- return c.json({ success: true, data: participantUpdateResponse(result) });
354416
- } catch (error3) {
354417
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354418
- return c.json({ error: { code: "GROUP_PARTICIPANTS_UPDATE_FAILED", message: message2 } }, 500);
354419
- }
354420
- });
354421
- instancesRoutes.patch("/:id/groups/:groupJid/participants", instanceAccess2, zValidator("json", groupParticipantsPatchSchema), async (c) => {
354422
- const id = c.req.param("id");
354423
- const groupJid = c.req.param("groupJid");
354424
- const { action, participants } = c.req.valid("json");
354425
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354426
- if (!resolved.ok)
354427
- return c.json({ error: resolved.error }, resolved.status);
354428
- if (typeof resolved.plugin.updateGroupParticipants !== "function") {
354429
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group participant updates" } }, 400);
354430
- }
354431
- try {
354432
- const result = await resolved.plugin.updateGroupParticipants(id, groupJid, participants, action);
354433
- return c.json({ success: true, data: participantUpdateResponse(result) });
354434
- } catch (error3) {
354435
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354436
- return c.json({ error: { code: "GROUP_PARTICIPANTS_UPDATE_FAILED", message: message2 } }, 500);
354437
- }
354438
- });
354439
- instancesRoutes.patch("/:id/groups/:groupJid", instanceAccess2, zValidator("json", patchGroupSchema), async (c) => {
354440
- const id = c.req.param("id");
354441
- const groupJid = c.req.param("groupJid");
354442
- const body = c.req.valid("json");
354443
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354444
- if (!resolved.ok)
354445
- return c.json({ error: resolved.error }, resolved.status);
354446
- if (body.subject !== undefined && typeof resolved.plugin.updateGroupSubject !== "function") {
354447
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group rename" } }, 400);
354448
- }
354449
- if (body.description !== undefined && typeof resolved.plugin.updateGroupDescription !== "function") {
354450
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group description updates" } }, 400);
354451
- }
354452
- if (body.setting !== undefined && typeof resolved.plugin.updateGroupSettings !== "function") {
354453
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group settings updates" } }, 400);
354454
- }
354455
- try {
354456
- const updated = [];
354457
- if (body.subject !== undefined) {
354458
- await resolved.plugin.updateGroupSubject?.(id, groupJid, body.subject);
354459
- updated.push("subject");
354460
- }
354461
- if (body.description !== undefined) {
354462
- await resolved.plugin.updateGroupDescription?.(id, groupJid, body.description);
354463
- updated.push("description");
354464
- }
354465
- if (body.setting !== undefined) {
354466
- await resolved.plugin.updateGroupSettings?.(id, groupJid, body.setting);
354467
- updated.push("settings");
354468
- }
354469
- return c.json({ success: true, data: { instanceId: id, groupJid, updated, ...body } });
354470
- } catch (error3) {
354471
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354472
- return c.json({ error: { code: "GROUP_UPDATE_FAILED", message: message2 } }, 500);
354473
- }
354474
- });
354475
- instancesRoutes.put("/:id/groups/:groupJid/subject", instanceAccess2, zValidator("json", updateGroupSubjectSchema), async (c) => {
354476
- const id = c.req.param("id");
354477
- const groupJid = c.req.param("groupJid");
354478
- const { subject } = c.req.valid("json");
354479
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354480
- if (!resolved.ok)
354481
- return c.json({ error: resolved.error }, resolved.status);
354482
- if (typeof resolved.plugin.updateGroupSubject !== "function") {
354483
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group rename" } }, 400);
354484
- }
354485
- try {
354486
- await resolved.plugin.updateGroupSubject(id, groupJid, subject);
354487
- return c.json({ success: true, data: { instanceId: id, groupJid, subject, action: "group_subject_updated" } });
354488
- } catch (error3) {
354489
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354490
- return c.json({ error: { code: "GROUP_RENAME_FAILED", message: message2 } }, 500);
354491
- }
354492
- });
354493
- instancesRoutes.post("/:id/groups/:groupJid/subject", instanceAccess2, zValidator("json", updateGroupSubjectSchema), async (c) => {
354494
- const id = c.req.param("id");
354495
- const groupJid = c.req.param("groupJid");
354496
- const { subject } = c.req.valid("json");
354497
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354498
- if (!resolved.ok)
354499
- return c.json({ error: resolved.error }, resolved.status);
354500
- if (typeof resolved.plugin.updateGroupSubject !== "function") {
354501
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group rename" } }, 400);
354502
- }
354503
- try {
354504
- await resolved.plugin.updateGroupSubject(id, groupJid, subject);
354505
- return c.json({ success: true, data: { instanceId: id, groupJid, subject, action: "group_subject_updated" } });
354506
- } catch (error3) {
354507
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354508
- return c.json({ error: { code: "GROUP_RENAME_FAILED", message: message2 } }, 500);
354509
- }
354510
- });
354511
- instancesRoutes.put("/:id/groups/:groupJid/description", instanceAccess2, zValidator("json", updateGroupDescriptionSchema), async (c) => {
354512
- const id = c.req.param("id");
354513
- const groupJid = c.req.param("groupJid");
354514
- const { description } = c.req.valid("json");
354515
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354516
- if (!resolved.ok)
354517
- return c.json({ error: resolved.error }, resolved.status);
354518
- if (typeof resolved.plugin.updateGroupDescription !== "function") {
354519
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group description updates" } }, 400);
354520
- }
354521
- try {
354522
- await resolved.plugin.updateGroupDescription(id, groupJid, description);
354523
- return c.json({
354524
- success: true,
354525
- data: { instanceId: id, groupJid, description, action: "group_description_updated" }
354526
- });
354527
- } catch (error3) {
354528
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354529
- return c.json({ error: { code: "GROUP_DESCRIPTION_FAILED", message: message2 } }, 500);
354530
- }
354531
- });
354532
- instancesRoutes.post("/:id/groups/:groupJid/description", instanceAccess2, zValidator("json", updateGroupDescriptionSchema), async (c) => {
354533
- const id = c.req.param("id");
354534
- const groupJid = c.req.param("groupJid");
354535
- const { description } = c.req.valid("json");
354536
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354537
- if (!resolved.ok)
354538
- return c.json({ error: resolved.error }, resolved.status);
354539
- if (typeof resolved.plugin.updateGroupDescription !== "function") {
354540
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group description updates" } }, 400);
354541
- }
354542
- try {
354543
- await resolved.plugin.updateGroupDescription(id, groupJid, description);
354544
- return c.json({
354545
- success: true,
354546
- data: { instanceId: id, groupJid, description, action: "group_description_updated" }
354547
- });
354548
- } catch (error3) {
354549
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354550
- return c.json({ error: { code: "GROUP_DESCRIPTION_FAILED", message: message2 } }, 500);
354551
- }
354552
- });
354553
- instancesRoutes.post("/:id/groups/:groupJid/settings", instanceAccess2, zValidator("json", updateGroupSettingsSchema), async (c) => {
354554
- const id = c.req.param("id");
354555
- const groupJid = c.req.param("groupJid");
354556
- const { setting } = c.req.valid("json");
354557
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354558
- if (!resolved.ok)
354559
- return c.json({ error: resolved.error }, resolved.status);
354560
- if (typeof resolved.plugin.updateGroupSettings !== "function") {
354561
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group settings updates" } }, 400);
354562
- }
354563
- try {
354564
- await resolved.plugin.updateGroupSettings(id, groupJid, setting);
354565
- return c.json({ success: true, data: { instanceId: id, groupJid, setting, action: "group_settings_updated" } });
354566
- } catch (error3) {
354567
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354568
- return c.json({ error: { code: "GROUP_SETTINGS_FAILED", message: message2 } }, 500);
354569
- }
354570
- });
354571
- instancesRoutes.post("/:id/groups/:groupJid/leave", instanceAccess2, async (c) => {
354572
- const id = c.req.param("id");
354573
- const groupJid = c.req.param("groupJid");
354574
- const resolved = await resolveInstancePlugin(c.get("services"), c.get("channelRegistry"), id);
354575
- if (!resolved.ok)
354576
- return c.json({ error: resolved.error }, resolved.status);
354577
- if (typeof resolved.plugin.leaveGroup !== "function") {
354578
- return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support leaving groups" } }, 400);
354579
- }
354580
- try {
354581
- await resolved.plugin.leaveGroup(id, groupJid);
354582
- return c.json({ success: true, data: { instanceId: id, groupJid, left: true } });
354583
- } catch (error3) {
354584
- const message2 = error3 instanceof Error ? error3.message : "Unknown error";
354585
- return c.json({ error: { code: "GROUP_LEAVE_FAILED", message: message2 } }, 500);
354586
- }
354587
- });
354588
354372
  instancesRoutes.get("/:id/chats/:chatId/invite", instanceAccess2, async (c) => {
354589
354373
  const id = c.req.param("id");
354590
354374
  const chatId = c.req.param("chatId");
@@ -483061,12 +482845,6 @@ function toJid(identifier, lidCache) {
483061
482845
  }
483062
482846
  return phoneJid;
483063
482847
  }
483064
- function toGroupJid(groupId) {
483065
- if (groupId.endsWith(JID_SUFFIX.GROUP)) {
483066
- return groupId;
483067
- }
483068
- return `${groupId}${JID_SUFFIX.GROUP}`;
483069
- }
483070
482848
  function fromJid(jid) {
483071
482849
  const isGroup = jid.endsWith(JID_SUFFIX.GROUP);
483072
482850
  const isBroadcast = jid.endsWith(JID_SUFFIX.BROADCAST);
@@ -486682,85 +486460,6 @@ class WhatsAppPlugin extends BaseChannelPlugin {
486682
486460
  throw waError;
486683
486461
  }
486684
486462
  }
486685
- async updateGroupParticipants(instanceId, groupJid, participants, action) {
486686
- await this.humanDelay(instanceId);
486687
- const sock = this.getSocket(instanceId);
486688
- const jid = toGroupJid(groupJid);
486689
- const participantJids = participants.map((participant) => toJid(participant));
486690
- try {
486691
- const result = await sock.groupParticipantsUpdate(jid, participantJids, action);
486692
- this.invalidateGroupMetadataCache(instanceId, jid);
486693
- this.logger.info("Group participants updated", {
486694
- instanceId,
486695
- groupJid: jid,
486696
- action,
486697
- participantCount: participantJids.length
486698
- });
486699
- return {
486700
- groupJid: jid,
486701
- action,
486702
- participants: result.map((participant) => ({
486703
- jid: participant.jid,
486704
- status: participant.status
486705
- }))
486706
- };
486707
- } catch (error) {
486708
- const waError = mapBaileysError(error);
486709
- throw waError;
486710
- }
486711
- }
486712
- async updateGroupSubject(instanceId, groupJid, subject) {
486713
- await this.humanDelay(instanceId);
486714
- const sock = this.getSocket(instanceId);
486715
- const jid = toGroupJid(groupJid);
486716
- try {
486717
- await sock.groupUpdateSubject(jid, subject);
486718
- this.invalidateGroupMetadataCache(instanceId, jid);
486719
- this.logger.info("Group subject updated", { instanceId, groupJid: jid });
486720
- } catch (error) {
486721
- const waError = mapBaileysError(error);
486722
- throw waError;
486723
- }
486724
- }
486725
- async updateGroupDescription(instanceId, groupJid, description) {
486726
- await this.humanDelay(instanceId);
486727
- const sock = this.getSocket(instanceId);
486728
- const jid = toGroupJid(groupJid);
486729
- try {
486730
- await sock.groupUpdateDescription(jid, description);
486731
- this.invalidateGroupMetadataCache(instanceId, jid);
486732
- this.logger.info("Group description updated", { instanceId, groupJid: jid, cleared: !description });
486733
- } catch (error) {
486734
- const waError = mapBaileysError(error);
486735
- throw waError;
486736
- }
486737
- }
486738
- async updateGroupSettings(instanceId, groupJid, setting) {
486739
- await this.humanDelay(instanceId);
486740
- const sock = this.getSocket(instanceId);
486741
- const jid = toGroupJid(groupJid);
486742
- try {
486743
- await sock.groupSettingUpdate(jid, setting);
486744
- this.invalidateGroupMetadataCache(instanceId, jid);
486745
- this.logger.info("Group settings updated", { instanceId, groupJid: jid, setting });
486746
- } catch (error) {
486747
- const waError = mapBaileysError(error);
486748
- throw waError;
486749
- }
486750
- }
486751
- async leaveGroup(instanceId, groupJid) {
486752
- await this.humanDelay(instanceId);
486753
- const sock = this.getSocket(instanceId);
486754
- const jid = toGroupJid(groupJid);
486755
- try {
486756
- await sock.groupLeave(jid);
486757
- this.invalidateGroupMetadataCache(instanceId, jid);
486758
- this.logger.info("Left group", { instanceId, groupJid: jid });
486759
- } catch (error) {
486760
- const waError = mapBaileysError(error);
486761
- throw waError;
486762
- }
486763
- }
486764
486463
  async handleQrCode(instanceId, qrCode, expiresAt) {
486765
486464
  await this.emitQrCode(instanceId, qrCode, expiresAt);
486766
486465
  const config2 = this.instances.get(instanceId)?.config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260609.2",
3
+ "version": "2.260609.4",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {