@automagik/omni 2.260609.2 → 2.260609.3

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.3",
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.3",
225249
225249
  type: "module",
225250
225250
  exports: {
225251
225251
  ".": {
@@ -353168,27 +353168,6 @@ async function enrichContactNames(contacts, services, instanceId) {
353168
353168
  contact.name = dbName;
353169
353169
  }
353170
353170
  }
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
353171
  function parseDuration(duration) {
353193
353172
  const match2 = duration.match(/^(\d+)(s|m|h|d)$/);
353194
353173
  if (!match2?.[1] || !match2[2])
@@ -353228,7 +353207,7 @@ function getCacheKey(instanceId, guildId) {
353228
353207
  function invalidateGuildCache(instanceId, guildId) {
353229
353208
  guildConfigCache.delete(getCacheKey(instanceId, guildId));
353230
353209
  }
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;
353210
+ 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
353211
  var init_instances3 = __esm(() => {
353233
353212
  init_dist6();
353234
353213
  init_src();
@@ -354330,30 +354309,6 @@ var init_instances3 = __esm(() => {
354330
354309
  return c.json({ error: { code: "REMOVE_FAILED", message: message2 } }, 500);
354331
354310
  }
354332
354311
  });
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
354312
  instancesRoutes.post("/:id/groups", instanceAccess2, zValidator("json", exports_external.object({
354358
354313
  subject: exports_external.string().min(1).max(100).describe("Group name/subject"),
354359
354314
  participants: exports_external.array(exports_external.string().min(1)).min(1).describe("Phone numbers or JIDs to add")
@@ -354373,218 +354328,6 @@ var init_instances3 = __esm(() => {
354373
354328
  const result = await plugin7.groupCreate(id, subject, participants);
354374
354329
  return c.json({ data: result }, 201);
354375
354330
  });
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
354331
  instancesRoutes.get("/:id/chats/:chatId/invite", instanceAccess2, async (c) => {
354589
354332
  const id = c.req.param("id");
354590
354333
  const chatId = c.req.param("chatId");
@@ -483061,12 +482804,6 @@ function toJid(identifier, lidCache) {
483061
482804
  }
483062
482805
  return phoneJid;
483063
482806
  }
483064
- function toGroupJid(groupId) {
483065
- if (groupId.endsWith(JID_SUFFIX.GROUP)) {
483066
- return groupId;
483067
- }
483068
- return `${groupId}${JID_SUFFIX.GROUP}`;
483069
- }
483070
482807
  function fromJid(jid) {
483071
482808
  const isGroup = jid.endsWith(JID_SUFFIX.GROUP);
483072
482809
  const isBroadcast = jid.endsWith(JID_SUFFIX.BROADCAST);
@@ -486682,85 +486419,6 @@ class WhatsAppPlugin extends BaseChannelPlugin {
486682
486419
  throw waError;
486683
486420
  }
486684
486421
  }
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
486422
  async handleQrCode(instanceId, qrCode, expiresAt) {
486765
486423
  await this.emitQrCode(instanceId, qrCode, expiresAt);
486766
486424
  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.3",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {