@automagik/omni 2.260424.1 → 2.260424.2

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
@@ -113929,7 +113929,7 @@ import { fileURLToPath } from "url";
113929
113929
  // package.json
113930
113930
  var package_default = {
113931
113931
  name: "@automagik/omni",
113932
- version: "2.260424.1",
113932
+ version: "2.260424.2",
113933
113933
  description: "LLM-optimized CLI for Omni",
113934
113934
  type: "module",
113935
113935
  bin: {
@@ -224554,7 +224554,7 @@ var init_sentry_scrub = __esm(() => {
224554
224554
  var require_package8 = __commonJS((exports, module) => {
224555
224555
  module.exports = {
224556
224556
  name: "@omni/api",
224557
- version: "2.260424.1",
224557
+ version: "2.260424.2",
224558
224558
  type: "module",
224559
224559
  exports: {
224560
224560
  ".": {
@@ -280785,7 +280785,7 @@ class FollowUpSweeperService {
280785
280785
  lastInboundCustomerMessageAt: chatFollowUpState.lastInboundCustomerMessageAt,
280786
280786
  chatName: chats.name,
280787
280787
  channelType: instances.channel
280788
- }).from(chatFollowUpState).leftJoin(chats, eq(chatFollowUpState.chatId, chats.id)).leftJoin(instances, eq(chatFollowUpState.instanceId, instances.id)).where(and2(isNull2(chatFollowUpState.disarmReason), lte(chatFollowUpState.nextFireAt, now), sql`(${chats.settings}->>'agentPaused')::boolean IS DISTINCT FROM true`)).orderBy(chatFollowUpState.nextFireAt).limit(limit2).for("update", { of: chatFollowUpState, skipLocked: true });
280788
+ }).from(chatFollowUpState).leftJoin(chats, eq(chatFollowUpState.chatId, chats.id)).leftJoin(instances, eq(chatFollowUpState.instanceId, instances.id)).where(and2(isNull2(chatFollowUpState.disarmReason), lte(chatFollowUpState.nextFireAt, now), sql`(${chats.settings}->>'agentPaused') IS DISTINCT FROM 'true'`)).orderBy(chatFollowUpState.nextFireAt).limit(limit2).for("update", { of: chatFollowUpState, skipLocked: true });
280789
280789
  return claimed;
280790
280790
  });
280791
280791
  return rows.map((r) => ({
@@ -300693,9 +300693,6 @@ var init_messages5 = __esm(() => {
300693
300693
  const channelRegistry2 = c.get("channelRegistry");
300694
300694
  checkInstanceAccess2(c.get("apiKey"), data.instanceId);
300695
300695
  const instance4 = await services.instances.getById(data.instanceId);
300696
- if (instance4.channel !== "gupshup") {
300697
- return c.json({ error: "Handoff is only supported on Gupshup instances" }, 400);
300698
- }
300699
300696
  if (!channelRegistry2) {
300700
300697
  throw new OmniError({
300701
300698
  code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
@@ -300713,18 +300710,26 @@ var init_messages5 = __esm(() => {
300713
300710
  });
300714
300711
  }
300715
300712
  const resolvedTo = await resolveRecipient(data.to, instance4.channel, services);
300716
- const outgoingMessage = {
300717
- to: resolvedTo,
300718
- content: { type: "text", text: data.text },
300719
- metadata: {
300720
- isHandoff: true,
300721
- dadosLead: data.dadosLead ?? data.extraInfo,
300722
- motivoHandoff: data.motivoHandoff,
300723
- handoffFields: data.handoffFields
300724
- }
300725
- };
300726
- const result = await plugin7.sendMessage(data.instanceId, outgoingMessage);
300727
- handleSendResult(result, { channelType: instance4.channel, instanceId: data.instanceId, operation: "send handoff" });
300713
+ const hasNativeHandoff = plugin7.capabilities?.canHandoff === true;
300714
+ let channelSendResult = null;
300715
+ if (hasNativeHandoff) {
300716
+ const outgoingMessage = {
300717
+ to: resolvedTo,
300718
+ content: { type: "text", text: data.text },
300719
+ metadata: {
300720
+ isHandoff: true,
300721
+ dadosLead: data.dadosLead ?? data.extraInfo,
300722
+ motivoHandoff: data.motivoHandoff,
300723
+ handoffFields: data.handoffFields
300724
+ }
300725
+ };
300726
+ channelSendResult = await plugin7.sendMessage(data.instanceId, outgoingMessage);
300727
+ handleSendResult(channelSendResult, {
300728
+ channelType: instance4.channel,
300729
+ instanceId: data.instanceId,
300730
+ operation: "send handoff"
300731
+ });
300732
+ }
300728
300733
  await services.chats.update(data.chatId, {
300729
300734
  settings: { agentPaused: true }
300730
300735
  });
@@ -300736,24 +300741,25 @@ var init_messages5 = __esm(() => {
300736
300741
  db2.insert(handoffLogs).values({
300737
300742
  instanceId: data.instanceId,
300738
300743
  chatUuid: data.chatId,
300739
- chatId: data.to,
300740
- toPhone: data.to,
300744
+ chatId: resolvedTo,
300745
+ toPhone: resolvedTo,
300741
300746
  text: data.text,
300742
300747
  extraInfo: data.dadosLead ?? data.extraInfo ?? null,
300743
300748
  agentId: instance4.agentId ?? null,
300744
- externalMessageId: result.messageId ?? null,
300749
+ externalMessageId: channelSendResult?.messageId ?? null,
300745
300750
  handoffFields: data.handoffFields ?? null,
300746
300751
  sentAt: new Date,
300747
300752
  metadata: {
300748
300753
  instanceChannel: instance4.channel,
300754
+ channelHandoffSupported: hasNativeHandoff,
300749
300755
  ...data.motivoHandoff ? { motivoHandoff: data.motivoHandoff } : {}
300750
300756
  }
300751
300757
  }).catch((err) => log103.warn("Failed to persist handoff log", { error: String(err) }));
300752
300758
  return c.json({
300753
300759
  data: {
300754
- messageId: result.messageId,
300755
- status: "sent",
300756
- timestamp: result.timestamp
300760
+ messageId: channelSendResult?.messageId ?? null,
300761
+ status: hasNativeHandoff ? "sent" : "paused",
300762
+ timestamp: channelSendResult?.timestamp ?? Date.now()
300757
300763
  }
300758
300764
  }, 201);
300759
300765
  });
@@ -309235,6 +309241,7 @@ var GUPSHUP_CAPABILITIES = {
309235
309241
  canDeleteMessage: false,
309236
309242
  canReplyToMessage: true,
309237
309243
  canForwardMessage: false,
309244
+ canHandoff: true,
309238
309245
  canSendContact: false,
309239
309246
  canSendLocation: true,
309240
309247
  canSendSticker: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260424.1",
3
+ "version": "2.260424.2",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {
@@ -39,15 +39,15 @@
39
39
  "qrcode-terminal": "^0.12.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@omni/api": "2.260423.10",
43
- "@omni/channel-discord": "2.260423.10",
44
- "@omni/channel-gupshup": "2.260423.10",
45
- "@omni/channel-sdk": "2.260423.10",
46
- "@omni/channel-slack": "2.260423.10",
47
- "@omni/channel-telegram": "2.260423.10",
48
- "@omni/channel-whatsapp": "2.260423.10",
49
- "@omni/core": "2.260423.10",
50
- "@omni/sdk": "2.260423.10",
42
+ "@omni/api": "2.260424.1",
43
+ "@omni/channel-discord": "2.260424.1",
44
+ "@omni/channel-gupshup": "2.260424.1",
45
+ "@omni/channel-sdk": "2.260424.1",
46
+ "@omni/channel-slack": "2.260424.1",
47
+ "@omni/channel-telegram": "2.260424.1",
48
+ "@omni/channel-whatsapp": "2.260424.1",
49
+ "@omni/core": "2.260424.1",
50
+ "@omni/sdk": "2.260424.1",
51
51
  "@types/node": "^22.10.3",
52
52
  "@types/qrcode-terminal": "^0.12.2",
53
53
  "typescript": "^5.7.3"