@automagik/omni 2.260616.1 → 2.260617.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 +1 -1
- package/dist/server/index.js +27 -12
- package/package.json +1 -1
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.
|
|
124974
|
+
version: "2.260617.2",
|
|
124975
124975
|
description: "LLM-optimized CLI for Omni",
|
|
124976
124976
|
type: "module",
|
|
124977
124977
|
bin: {
|
package/dist/server/index.js
CHANGED
|
@@ -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.
|
|
225248
|
+
version: "2.260617.2",
|
|
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
|
|
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
|
-
|
|
285026
|
-
|
|
285027
|
-
|
|
285028
|
-
|
|
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
|
}
|
|
@@ -366524,11 +366529,21 @@ function toUnixSeconds(ts) {
|
|
|
366524
366529
|
return Math.floor(Date.now() / 1000);
|
|
366525
366530
|
return Math.floor(n2 > 1000000000000 ? n2 / 1000 : n2);
|
|
366526
366531
|
}
|
|
366532
|
+
function textDigest(text) {
|
|
366533
|
+
let h2 = 2166136261;
|
|
366534
|
+
for (let i = 0;i < text.length; i++) {
|
|
366535
|
+
h2 ^= text.charCodeAt(i);
|
|
366536
|
+
h2 = Math.imul(h2, 16777619);
|
|
366537
|
+
}
|
|
366538
|
+
return (h2 >>> 0).toString(36);
|
|
366539
|
+
}
|
|
366527
366540
|
function normalizeSimplifiedWebhook(p2) {
|
|
366528
366541
|
const phone = p2.sender.id;
|
|
366529
366542
|
const text = p2.message?.text;
|
|
366543
|
+
if (!text)
|
|
366544
|
+
return null;
|
|
366530
366545
|
const tsSeconds = toUnixSeconds(p2.message?.timestamp);
|
|
366531
|
-
const id = p2.message?.id ?? `gs-simplified-${phone}-${tsSeconds}-${text
|
|
366546
|
+
const id = p2.message?.id ?? `gs-simplified-${phone}-${tsSeconds}-${textDigest(text)}`;
|
|
366532
366547
|
return {
|
|
366533
366548
|
source: "gupshup-hv-entry-flow-simplified",
|
|
366534
366549
|
sender: phone,
|