@automagik/omni 2.260501.3 → 2.260501.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
@@ -114177,7 +114177,7 @@ import { fileURLToPath } from "url";
114177
114177
  // package.json
114178
114178
  var package_default = {
114179
114179
  name: "@automagik/omni",
114180
- version: "2.260501.3",
114180
+ version: "2.260501.4",
114181
114181
  description: "LLM-optimized CLI for Omni",
114182
114182
  type: "module",
114183
114183
  bin: {
@@ -224654,7 +224654,7 @@ var init_sentry_scrub = __esm(() => {
224654
224654
  var require_package8 = __commonJS((exports, module) => {
224655
224655
  module.exports = {
224656
224656
  name: "@omni/api",
224657
- version: "2.260501.3",
224657
+ version: "2.260501.4",
224658
224658
  type: "module",
224659
224659
  exports: {
224660
224660
  ".": {
@@ -297326,6 +297326,35 @@ function checkInstanceAccess(apiKey, instanceId) {
297326
297326
  });
297327
297327
  }
297328
297328
  }
297329
+ async function getActiveInstanceId(c) {
297330
+ const keyData = c.get("apiKey");
297331
+ if (!keyData)
297332
+ return null;
297333
+ const db2 = c.get("db");
297334
+ const [row] = await db2.select({
297335
+ activeInstanceId: apiKeys.activeInstanceId,
297336
+ contextInstanceId: apiKeys.contextInstanceId
297337
+ }).from(apiKeys).where(eq(apiKeys.id, keyData.id)).limit(1);
297338
+ return row?.contextInstanceId ?? row?.activeInstanceId ?? null;
297339
+ }
297340
+ async function resolveChatIdParam(c, raw2, explicitInstanceId) {
297341
+ if (UUID_REGEX.test(raw2))
297342
+ return raw2;
297343
+ const instanceId = explicitInstanceId ?? await getActiveInstanceId(c);
297344
+ if (!instanceId)
297345
+ return null;
297346
+ const services = c.get("services");
297347
+ const chat2 = await services.chats.findByExternalIdSmart(instanceId, raw2);
297348
+ return chat2?.id ?? null;
297349
+ }
297350
+ function chatNotFoundResponse(c, raw2) {
297351
+ return c.json({
297352
+ error: {
297353
+ code: ERROR_CODES.NOT_FOUND,
297354
+ message: `Chat not found: ${raw2}. Pass either a chat UUID or set the API key's active instance via POST /api/v2/context/use first.`
297355
+ }
297356
+ }, 404);
297357
+ }
297329
297358
  async function getPluginForInstance(services, channelRegistry2, instanceId, requiredCapability) {
297330
297359
  const instance4 = await services.instances.getById(instanceId);
297331
297360
  if (!channelRegistry2) {
@@ -297393,16 +297422,19 @@ function resolveContactName2(chat2, contactNames) {
297393
297422
  }
297394
297423
  return;
297395
297424
  }
297396
- var chatsRoutes, ChatTypeSchema, listQuerySchema6, createChatSchema, updateChatSchema, addParticipantSchema, updateParticipantRoleSchema, chatChannelActionSchema, muteActionSchema, labelBodySchema, listMessagesQuerySchema, markChatReadSchema, disappearingSchema, DISAPPEARING_DURATIONS, syncNamesSchema, clearSessionSchema;
297425
+ var chatsRoutes, UUID_REGEX, ChatTypeSchema, listQuerySchema6, createChatSchema, updateChatSchema, addParticipantSchema, updateParticipantRoleSchema, chatChannelActionSchema, muteActionSchema, labelBodySchema, listMessagesQuerySchema, markChatReadSchema, disappearingSchema, DISAPPEARING_DURATIONS, syncNamesSchema, clearSessionSchema;
297397
297426
  var init_chats2 = __esm(() => {
297398
297427
  init_dist6();
297399
297428
  init_src();
297429
+ init_schema2();
297430
+ init_drizzle_orm();
297400
297431
  init_dist2();
297401
297432
  init_zod();
297402
297433
  init_session_cleaner();
297403
297434
  init_date_query();
297404
297435
  init_api_keys();
297405
297436
  chatsRoutes = new Hono2;
297437
+ UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
297406
297438
  ChatTypeSchema = exports_external.enum([
297407
297439
  "dm",
297408
297440
  "group",
@@ -297486,20 +297518,29 @@ var init_chats2 = __esm(() => {
297486
297518
  return c.json({ data: chat2 }, 201);
297487
297519
  });
297488
297520
  chatsRoutes.get("/:id", async (c) => {
297489
- const id = c.req.param("id");
297521
+ const raw2 = c.req.param("id");
297522
+ const id = await resolveChatIdParam(c, raw2);
297523
+ if (id === null)
297524
+ return chatNotFoundResponse(c, raw2);
297490
297525
  const services = c.get("services");
297491
297526
  const chat2 = await services.chats.getById(id);
297492
297527
  return c.json({ data: chat2 });
297493
297528
  });
297494
297529
  chatsRoutes.patch("/:id", zValidator("json", updateChatSchema), async (c) => {
297495
- const id = c.req.param("id");
297530
+ const raw2 = c.req.param("id");
297531
+ const id = await resolveChatIdParam(c, raw2);
297532
+ if (id === null)
297533
+ return chatNotFoundResponse(c, raw2);
297496
297534
  const body = c.req.valid("json");
297497
297535
  const services = c.get("services");
297498
297536
  const chat2 = await services.chats.update(id, body);
297499
297537
  return c.json({ data: chat2 });
297500
297538
  });
297501
297539
  chatsRoutes.delete("/:id", async (c) => {
297502
- const id = c.req.param("id");
297540
+ const raw2 = c.req.param("id");
297541
+ const id = await resolveChatIdParam(c, raw2);
297542
+ if (id === null)
297543
+ return chatNotFoundResponse(c, raw2);
297503
297544
  const services = c.get("services");
297504
297545
  await services.chats.delete(id);
297505
297546
  return c.json({ success: true });
@@ -297615,7 +297656,10 @@ var init_chats2 = __esm(() => {
297615
297656
  return c.json({ success: true, data: { chatId: id, action: "unmute" } });
297616
297657
  });
297617
297658
  chatsRoutes.get("/:id/participants", async (c) => {
297618
- const id = c.req.param("id");
297659
+ const raw2 = c.req.param("id");
297660
+ const id = await resolveChatIdParam(c, raw2);
297661
+ if (id === null)
297662
+ return chatNotFoundResponse(c, raw2);
297619
297663
  const services = c.get("services");
297620
297664
  const participants = await services.chats.getParticipants(id);
297621
297665
  return c.json({ items: participants });
@@ -297652,7 +297696,10 @@ var init_chats2 = __esm(() => {
297652
297696
  mediaOnly: exports_external.string().optional().transform((v2) => v2 === "true")
297653
297697
  });
297654
297698
  chatsRoutes.get("/:id/messages", zValidator("query", listMessagesQuerySchema), async (c) => {
297655
- const chatId = c.req.param("id");
297699
+ const raw2 = c.req.param("id");
297700
+ const chatId = await resolveChatIdParam(c, raw2);
297701
+ if (chatId === null)
297702
+ return chatNotFoundResponse(c, raw2);
297656
297703
  const { limit: limit2, before, after, mediaOnly } = c.req.valid("query");
297657
297704
  const services = c.get("services");
297658
297705
  const messages4 = await services.messages.getChatMessages(chatId, {
@@ -302797,7 +302844,7 @@ var init__close_contact_config = __esm(() => {
302797
302844
  import { existsSync as existsSync8 } from "fs";
302798
302845
  import { join as join24 } from "path";
302799
302846
  function isUUID(value) {
302800
- return UUID_REGEX.test(value);
302847
+ return UUID_REGEX2.test(value);
302801
302848
  }
302802
302849
  function extractReactionTargetParticipant(rawPayload) {
302803
302850
  const key = rawPayload?.key;
@@ -302953,7 +303000,7 @@ async function verifyMessageInstanceOwnership(services, message2, instanceId) {
302953
303000
  });
302954
303001
  }
302955
303002
  }
302956
- var log106, mediaDownloadLog, messagesRoutes, UUID_REGEX, MessageSourceSchema, MessageTypeSchema, MessageStatusSchema, DeliveryStatusSchema, listQuerySchema13, createMessageSchema, updateMessageSchema, recordEditSchema, addReactionSchema, removeReactionSchema, updateDeliveryStatusSchema, MentionSchema, sendTextSchema, sendMediaSchema, sendReactionSchema, sendStickerSchema, sendContactSchema, sendLocationSchema, sendHandoffSchema, sendCloseContactSchema, messageRefSchema, _mediaStorageForDownload = null, sendTtsSchema, forwardMessageSchema, sendPresenceSchema, markMessageReadSchema, markBatchReadSchema, sendPollSchema, sendEmbedSchema, editMessageChannelSchema, deleteMessageChannelSchema, starMessageSchema;
303003
+ var log106, mediaDownloadLog, messagesRoutes, UUID_REGEX2, MessageSourceSchema, MessageTypeSchema, MessageStatusSchema, DeliveryStatusSchema, listQuerySchema13, createMessageSchema, updateMessageSchema, recordEditSchema, addReactionSchema, removeReactionSchema, updateDeliveryStatusSchema, MentionSchema, sendTextSchema, sendMediaSchema, sendReactionSchema, sendStickerSchema, sendContactSchema, sendLocationSchema, sendHandoffSchema, sendCloseContactSchema, messageRefSchema, _mediaStorageForDownload = null, sendTtsSchema, forwardMessageSchema, sendPresenceSchema, markMessageReadSchema, markBatchReadSchema, sendPollSchema, sendEmbedSchema, editMessageChannelSchema, deleteMessageChannelSchema, starMessageSchema;
302957
303004
  var init_messages5 = __esm(() => {
302958
303005
  init_dist6();
302959
303006
  init_src2();
@@ -302971,7 +303018,7 @@ var init_messages5 = __esm(() => {
302971
303018
  log106 = createLogger("routes:messages");
302972
303019
  mediaDownloadLog = createLogger("routes:messages:media-download");
302973
303020
  messagesRoutes = new Hono2;
302974
- UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
303021
+ UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
302975
303022
  MessageSourceSchema = exports_external.enum(["realtime", "sync", "api", "import"]);
302976
303023
  MessageTypeSchema = exports_external.enum([
302977
303024
  "text",
@@ -305788,10 +305835,10 @@ function createApp(db2, eventBus = null, channelRegistry2 = null) {
305788
305835
  }
305789
305836
  return plugin7.handleWebhook(c.req.raw);
305790
305837
  });
305791
- const UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
305838
+ const UUID_REGEX3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
305792
305839
  app.post("/a2a/:instanceId", authMiddleware, requireInstanceAccess((c) => c.req.param("instanceId")), rateLimitMiddleware, async (c) => {
305793
305840
  const instanceId = c.req.param("instanceId");
305794
- if (!UUID_REGEX2.test(instanceId)) {
305841
+ if (!UUID_REGEX3.test(instanceId)) {
305795
305842
  return c.json({ error: "Invalid instance ID format" }, 400);
305796
305843
  }
305797
305844
  const channelRegistry3 = c.get("channelRegistry");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260501.3",
3
+ "version": "2.260501.4",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,15 +51,15 @@
51
51
  "qrcode-terminal": "^0.12.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@omni/api": "2.260501.2",
55
- "@omni/channel-discord": "2.260501.2",
56
- "@omni/channel-gupshup": "2.260501.2",
57
- "@omni/channel-sdk": "2.260501.2",
58
- "@omni/channel-slack": "2.260501.2",
59
- "@omni/channel-telegram": "2.260501.2",
60
- "@omni/channel-whatsapp": "2.260501.2",
61
- "@omni/core": "2.260501.2",
62
- "@omni/sdk": "2.260501.2",
54
+ "@omni/api": "2.260501.3",
55
+ "@omni/channel-discord": "2.260501.3",
56
+ "@omni/channel-gupshup": "2.260501.3",
57
+ "@omni/channel-sdk": "2.260501.3",
58
+ "@omni/channel-slack": "2.260501.3",
59
+ "@omni/channel-telegram": "2.260501.3",
60
+ "@omni/channel-whatsapp": "2.260501.3",
61
+ "@omni/core": "2.260501.3",
62
+ "@omni/sdk": "2.260501.3",
63
63
  "@types/node": "^22.10.3",
64
64
  "@types/qrcode-terminal": "^0.12.2",
65
65
  "typescript": "^5.7.3"