@automagik/omni 2.260617.1 → 2.260617.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.260617.1",
124974
+ version: "2.260617.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.260617.1",
225248
+ version: "2.260617.3",
225249
225249
  type: "module",
225250
225250
  exports: {
225251
225251
  ".": {
@@ -285014,18 +285014,23 @@ function readBodyTargets(body) {
285014
285014
  chatId: str(b3.chatId)
285015
285015
  };
285016
285016
  }
285017
- function extractLockTargets(method, rawPath, body) {
285017
+ function readHeaderTargets(c) {
285018
+ const norm = (v2) => v2 && v2.length > 0 ? v2 : null;
285019
+ return {
285020
+ instance: norm(c.req.header("x-omni-instance")),
285021
+ chat: norm(c.req.header("x-omni-chat"))
285022
+ };
285023
+ }
285024
+ function extractLockTargets(method, rawPath, body, headers) {
285018
285025
  const cleanPath2 = normalizePath2(rawPath);
285019
285026
  const { instanceId, to, chatId } = readBodyTargets(body);
285020
- let instance4 = instanceId;
285021
- let chat = chatId;
285022
- let recipient = null;
285023
285027
  const pathInstance = PATH_INSTANCE_PREFIXES.map((p2) => firstPathSegment(cleanPath2, p2)).find((v2) => v2 != null) ?? null;
285024
285028
  const pathChat = PATH_CHAT_PREFIXES.map((p2) => firstPathSegment(cleanPath2, p2)).find((v2) => v2 != null) ?? null;
285025
- if (!instance4 && pathInstance)
285026
- instance4 = pathInstance;
285027
- if (!chat && pathChat)
285028
- chat = pathChat;
285029
+ const headerInstance = headers?.instance && headers.instance.length > 0 ? headers.instance : null;
285030
+ const headerChat = headers?.chat && headers.chat.length > 0 ? headers.chat : null;
285031
+ const instance4 = pathInstance ?? headerInstance ?? instanceId;
285032
+ let chat = pathChat ?? headerChat ?? chatId;
285033
+ let recipient = null;
285029
285034
  if (isOutboundSendRoute(cleanPath2)) {
285030
285035
  recipient = to;
285031
285036
  if (!chat)
@@ -285135,7 +285140,7 @@ var init_scope_enforcer = __esm(() => {
285135
285140
  }
285136
285141
  }
285137
285142
  const body = await safeReadJsonBody(c);
285138
- const targets = extractLockTargets(method, path2, body);
285143
+ const targets = extractLockTargets(method, path2, body, readHeaderTargets(c));
285139
285144
  const instanceResult = enforceInstanceAllowlist(apiKey, targets.instance);
285140
285145
  if (!instanceResult.allowed) {
285141
285146
  log59.warn(`DENIED: key=${apiKey.id} route=${method} ${path2} lock=instanceAllowlist attempted=${instanceResult.attempted}`);
@@ -285194,7 +285199,7 @@ var init_require_signed_instance = __esm(() => {
285194
285199
  const method = c.req.method.toUpperCase();
285195
285200
  const path2 = c.req.path;
285196
285201
  const body = await safeReadJsonBody2(c);
285197
- const targets = extractLockTargets(method, path2, body);
285202
+ const targets = extractLockTargets(method, path2, body, readHeaderTargets(c));
285198
285203
  if (!targets.instance) {
285199
285204
  return next();
285200
285205
  }
@@ -350892,7 +350897,11 @@ var init_chats2 = __esm(() => {
350892
350897
  const isAgentPaused = dbChat.settings?.agentPaused === true;
350893
350898
  if (isAgentPaused) {
350894
350899
  await services.chats.update(dbChat.id, {
350895
- settings: { agentPaused: false, agentResumedAt: new Date().toISOString() }
350900
+ settings: {
350901
+ ...dbChat.settings ?? {},
350902
+ agentPaused: false,
350903
+ agentResumedAt: new Date().toISOString()
350904
+ }
350896
350905
  });
350897
350906
  }
350898
350907
  }
@@ -357377,8 +357386,9 @@ var init_messages5 = __esm(() => {
357377
357386
  operation: "send handoff"
357378
357387
  });
357379
357388
  }
357389
+ const handoffChat = await services.chats.getById(data.chatId);
357380
357390
  await services.chats.update(data.chatId, {
357381
- settings: { agentPaused: true }
357391
+ settings: { ...handoffChat?.settings ?? {}, agentPaused: true }
357382
357392
  });
357383
357393
  await services.followUpLifecycle.disarm({
357384
357394
  chatId: data.chatId,
@@ -357476,8 +357486,10 @@ var init_messages5 = __esm(() => {
357476
357486
  const { terminal, escalated, closeUntil } = await computeCloseContactTerminalState(db2, data.chatId, outcome, auditRow?.id ?? null);
357477
357487
  const shouldPauseAgent = outcome === "lost";
357478
357488
  const closedAt = new Date;
357489
+ const closeChat = await services.chats.getById(data.chatId);
357479
357490
  await services.chats.update(data.chatId, {
357480
357491
  settings: {
357492
+ ...closeChat?.settings ?? {},
357481
357493
  ...shouldPauseAgent ? { agentPaused: true } : {},
357482
357494
  closed: terminal,
357483
357495
  closeUntil: closeUntil?.toISOString() ?? null,
@@ -357496,7 +357508,7 @@ var init_messages5 = __esm(() => {
357496
357508
  agentId: instance4.agentId ?? null,
357497
357509
  outcome,
357498
357510
  reason: data.reason ?? null,
357499
- escalated: terminal,
357511
+ escalated,
357500
357512
  closedFields: data.closeFields ?? null,
357501
357513
  closedAt: closedAt.toISOString()
357502
357514
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260617.1",
3
+ "version": "2.260617.3",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {