@automagik/omni 2.260303.2 → 2.260303.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 +1 -1
- package/dist/server/index.js +104 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27673,7 +27673,7 @@ import { fileURLToPath } from "url";
|
|
|
27673
27673
|
// package.json
|
|
27674
27674
|
var package_default = {
|
|
27675
27675
|
name: "@automagik/omni",
|
|
27676
|
-
version: "2.260303.
|
|
27676
|
+
version: "2.260303.3",
|
|
27677
27677
|
description: "LLM-optimized CLI for Omni v2",
|
|
27678
27678
|
type: "module",
|
|
27679
27679
|
bin: {
|
package/dist/server/index.js
CHANGED
|
@@ -168736,6 +168736,8 @@ var init_src5 = __esm(() => {
|
|
|
168736
168736
|
});
|
|
168737
168737
|
|
|
168738
168738
|
// ../api/src/pgserve.ts
|
|
168739
|
+
import { execFileSync } from "child_process";
|
|
168740
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
168739
168741
|
import { homedir as homedir2 } from "os";
|
|
168740
168742
|
import { join as join12 } from "path";
|
|
168741
168743
|
function resolvePgserveConfig() {
|
|
@@ -168769,6 +168771,51 @@ async function tryStartOnPort(startFn, port, config2) {
|
|
|
168769
168771
|
throw error;
|
|
168770
168772
|
}
|
|
168771
168773
|
}
|
|
168774
|
+
async function killOrphanedPostgres(dataDir) {
|
|
168775
|
+
const pidFile = join12(dataDir, "postmaster.pid");
|
|
168776
|
+
if (!existsSync3(pidFile))
|
|
168777
|
+
return;
|
|
168778
|
+
let pid;
|
|
168779
|
+
try {
|
|
168780
|
+
pid = Number.parseInt(readFileSync3(pidFile, "utf-8").trim().split(`
|
|
168781
|
+
`)[0] ?? "", 10);
|
|
168782
|
+
if (Number.isNaN(pid) || pid <= 0)
|
|
168783
|
+
return;
|
|
168784
|
+
process.kill(pid, 0);
|
|
168785
|
+
} catch {
|
|
168786
|
+
return;
|
|
168787
|
+
}
|
|
168788
|
+
try {
|
|
168789
|
+
const cmd = execFileSync("ps", ["-o", "command=", "-p", String(pid)], { encoding: "utf-8" }).trim();
|
|
168790
|
+
if (!/\bpostgres\b/i.test(cmd)) {
|
|
168791
|
+
log52.warn("PID from postmaster.pid is not a postgres process, skipping kill", {
|
|
168792
|
+
pid,
|
|
168793
|
+
dataDir,
|
|
168794
|
+
cmd: cmd.slice(0, 80)
|
|
168795
|
+
});
|
|
168796
|
+
return;
|
|
168797
|
+
}
|
|
168798
|
+
} catch {
|
|
168799
|
+
return;
|
|
168800
|
+
}
|
|
168801
|
+
log52.info("Killing orphaned postgres from previous run", { pid, dataDir });
|
|
168802
|
+
try {
|
|
168803
|
+
process.kill(pid, "SIGTERM");
|
|
168804
|
+
} catch {
|
|
168805
|
+
return;
|
|
168806
|
+
}
|
|
168807
|
+
for (let i = 0;i < 50; i++) {
|
|
168808
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
168809
|
+
try {
|
|
168810
|
+
process.kill(pid, 0);
|
|
168811
|
+
} catch {
|
|
168812
|
+
return;
|
|
168813
|
+
}
|
|
168814
|
+
}
|
|
168815
|
+
try {
|
|
168816
|
+
process.kill(pid, "SIGKILL");
|
|
168817
|
+
} catch {}
|
|
168818
|
+
}
|
|
168772
168819
|
async function startEmbeddedPgserve(config2) {
|
|
168773
168820
|
if (!config2.enabled) {
|
|
168774
168821
|
const url = process.env.DATABASE_URL ?? getDefaultDatabaseUrl();
|
|
@@ -168780,6 +168827,9 @@ async function startEmbeddedPgserve(config2) {
|
|
|
168780
168827
|
mode: config2.dataDir ? "persistent" : "memory",
|
|
168781
168828
|
dataDir: config2.dataDir ?? "(in-memory)"
|
|
168782
168829
|
});
|
|
168830
|
+
if (config2.dataDir) {
|
|
168831
|
+
await killOrphanedPostgres(config2.dataDir);
|
|
168832
|
+
}
|
|
168783
168833
|
const { startMultiTenantServer: startMultiTenantServer2 } = await Promise.resolve().then(() => (init_src5(), exports_src2));
|
|
168784
168834
|
for (let offset = 0;offset <= MAX_PORT_RETRIES; offset++) {
|
|
168785
168835
|
const port = config2.port + offset;
|
|
@@ -168822,7 +168872,7 @@ var package_default;
|
|
|
168822
168872
|
var init_package = __esm(() => {
|
|
168823
168873
|
package_default = {
|
|
168824
168874
|
name: "@omni/api",
|
|
168825
|
-
version: "2.260303.
|
|
168875
|
+
version: "2.260303.3",
|
|
168826
168876
|
type: "module",
|
|
168827
168877
|
exports: {
|
|
168828
168878
|
".": {
|
|
@@ -181775,7 +181825,7 @@ Messages:
|
|
|
181775
181825
|
var init_prompts = () => {};
|
|
181776
181826
|
|
|
181777
181827
|
// ../media-processing/src/processors/image.ts
|
|
181778
|
-
import { readFileSync as
|
|
181828
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
181779
181829
|
var MAX_RETRIES4 = 3, ImageProcessor;
|
|
181780
181830
|
var init_image = __esm(() => {
|
|
181781
181831
|
init_dist2();
|
|
@@ -181822,7 +181872,7 @@ var init_image = __esm(() => {
|
|
|
181822
181872
|
const prompt = options?.caption ? `${basePrompt}
|
|
181823
181873
|
|
|
181824
181874
|
Additional context (caption): ${options.caption}` : basePrompt;
|
|
181825
|
-
const imageData =
|
|
181875
|
+
const imageData = readFileSync4(filePath);
|
|
181826
181876
|
let result = await this.describeWithGemini(imageData, mimeType, prompt);
|
|
181827
181877
|
if (!result.success && this.config.openaiApiKey) {
|
|
181828
181878
|
this.log.info("Gemini description failed, trying OpenAI fallback...");
|
|
@@ -181968,7 +182018,7 @@ Additional context (caption): ${options.caption}` : basePrompt;
|
|
|
181968
182018
|
});
|
|
181969
182019
|
|
|
181970
182020
|
// ../media-processing/src/processors/video.ts
|
|
181971
|
-
import { readFileSync as
|
|
182021
|
+
import { readFileSync as readFileSync5, statSync as statSync2 } from "fs";
|
|
181972
182022
|
var MAX_RETRIES5 = 3, MAX_VIDEO_SIZE_MB = 20, VideoProcessor;
|
|
181973
182023
|
var init_video = __esm(() => {
|
|
181974
182024
|
init_dist2();
|
|
@@ -182011,7 +182061,7 @@ var init_video = __esm(() => {
|
|
|
182011
182061
|
const prompt = options?.caption ? `${basePrompt}
|
|
182012
182062
|
|
|
182013
182063
|
Additional context: ${options.caption}` : basePrompt;
|
|
182014
|
-
const videoData =
|
|
182064
|
+
const videoData = readFileSync5(filePath);
|
|
182015
182065
|
const result = await this.describeWithGemini(videoData, mimeType, prompt);
|
|
182016
182066
|
result.processingTimeMs = Math.round(performance.now() - startTime2);
|
|
182017
182067
|
if (result.success) {
|
|
@@ -251877,7 +251927,7 @@ var require_excel = __commonJS((exports, module) => {
|
|
|
251877
251927
|
});
|
|
251878
251928
|
|
|
251879
251929
|
// ../media-processing/src/processors/document.ts
|
|
251880
|
-
import { readFileSync as
|
|
251930
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
251881
251931
|
var MIN_TEXT_LENGTH = 50, JSON_SUMMARIZE_THRESHOLD, JSON_MAX_ARRAY_EXAMPLES = 3, DocumentProcessor;
|
|
251882
251932
|
var init_document = __esm(() => {
|
|
251883
251933
|
init_dist2();
|
|
@@ -251943,7 +251993,7 @@ var init_document = __esm(() => {
|
|
|
251943
251993
|
async processPdf(filePath, ocrPrompt) {
|
|
251944
251994
|
try {
|
|
251945
251995
|
const pdfParse = (await Promise.resolve().then(() => __toESM(require_pdf_parse2(), 1))).default;
|
|
251946
|
-
const dataBuffer =
|
|
251996
|
+
const dataBuffer = readFileSync6(filePath);
|
|
251947
251997
|
const data = await pdfParse(dataBuffer);
|
|
251948
251998
|
const text3 = data.text?.trim() ?? "";
|
|
251949
251999
|
if (text3.length < MIN_TEXT_LENGTH) {
|
|
@@ -252044,7 +252094,7 @@ ${csv}`);
|
|
|
252044
252094
|
}
|
|
252045
252095
|
async processCsv(filePath) {
|
|
252046
252096
|
try {
|
|
252047
|
-
const content =
|
|
252097
|
+
const content = readFileSync6(filePath, "utf-8");
|
|
252048
252098
|
return {
|
|
252049
252099
|
success: true,
|
|
252050
252100
|
content,
|
|
@@ -252062,7 +252112,7 @@ ${csv}`);
|
|
|
252062
252112
|
}
|
|
252063
252113
|
async processText(filePath, isMarkdown) {
|
|
252064
252114
|
try {
|
|
252065
|
-
const content =
|
|
252115
|
+
const content = readFileSync6(filePath, "utf-8");
|
|
252066
252116
|
return {
|
|
252067
252117
|
success: true,
|
|
252068
252118
|
content,
|
|
@@ -252080,7 +252130,7 @@ ${csv}`);
|
|
|
252080
252130
|
}
|
|
252081
252131
|
async processJson(filePath) {
|
|
252082
252132
|
try {
|
|
252083
|
-
const content =
|
|
252133
|
+
const content = readFileSync6(filePath, "utf-8");
|
|
252084
252134
|
const data = JSON.parse(content);
|
|
252085
252135
|
if (content.length < JSON_SUMMARIZE_THRESHOLD) {
|
|
252086
252136
|
return {
|
|
@@ -252198,7 +252248,7 @@ ${csv}`);
|
|
|
252198
252248
|
return this.createFailedResult("Gemini not configured for OCR fallback (missing API key)", "local", "pdf-parse");
|
|
252199
252249
|
}
|
|
252200
252250
|
try {
|
|
252201
|
-
const pdfData =
|
|
252251
|
+
const pdfData = readFileSync6(filePath);
|
|
252202
252252
|
const result = await model.generateContent([
|
|
252203
252253
|
{
|
|
252204
252254
|
inlineData: {
|
|
@@ -252379,7 +252429,7 @@ var init_src6 = __esm(() => {
|
|
|
252379
252429
|
});
|
|
252380
252430
|
|
|
252381
252431
|
// ../api/src/services/media-storage.ts
|
|
252382
|
-
import { existsSync as
|
|
252432
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync7, statSync as statSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
252383
252433
|
import { dirname as dirname5, extname as extname2, join as join14, relative } from "path";
|
|
252384
252434
|
function getExtensionFromMime2(mimeType) {
|
|
252385
252435
|
const mimeToExt = {
|
|
@@ -252428,7 +252478,7 @@ class MediaStorageService {
|
|
|
252428
252478
|
constructor(db2, basePath) {
|
|
252429
252479
|
this.db = db2;
|
|
252430
252480
|
this.basePath = basePath ?? process.env.MEDIA_STORAGE_PATH ?? DEFAULT_MEDIA_PATH;
|
|
252431
|
-
if (!
|
|
252481
|
+
if (!existsSync4(this.basePath)) {
|
|
252432
252482
|
mkdirSync3(this.basePath, { recursive: true });
|
|
252433
252483
|
log59.info("Created media storage directory", { path: this.basePath });
|
|
252434
252484
|
}
|
|
@@ -252442,7 +252492,7 @@ class MediaStorageService {
|
|
|
252442
252492
|
async storeFromBase64(instanceId, messageId, base64Data, mimeType, timestamp3) {
|
|
252443
252493
|
const localPath = this.buildPath(instanceId, messageId, mimeType, timestamp3);
|
|
252444
252494
|
const dir = dirname5(localPath);
|
|
252445
|
-
if (!
|
|
252495
|
+
if (!existsSync4(dir)) {
|
|
252446
252496
|
mkdirSync3(dir, { recursive: true });
|
|
252447
252497
|
}
|
|
252448
252498
|
const buffer3 = Buffer.from(base64Data, "base64");
|
|
@@ -252457,7 +252507,7 @@ class MediaStorageService {
|
|
|
252457
252507
|
async storeFromBuffer(instanceId, messageId, buffer3, mimeType, timestamp3) {
|
|
252458
252508
|
const localPath = this.buildPath(instanceId, messageId, mimeType, timestamp3);
|
|
252459
252509
|
const dir = dirname5(localPath);
|
|
252460
|
-
if (!
|
|
252510
|
+
if (!existsSync4(dir)) {
|
|
252461
252511
|
mkdirSync3(dir, { recursive: true });
|
|
252462
252512
|
}
|
|
252463
252513
|
writeFileSync3(localPath, buffer3);
|
|
@@ -252482,11 +252532,11 @@ class MediaStorageService {
|
|
|
252482
252532
|
}
|
|
252483
252533
|
readMedia(relativePath) {
|
|
252484
252534
|
const fullPath = join14(this.basePath, relativePath);
|
|
252485
|
-
if (!
|
|
252535
|
+
if (!existsSync4(fullPath)) {
|
|
252486
252536
|
return null;
|
|
252487
252537
|
}
|
|
252488
252538
|
try {
|
|
252489
|
-
const buffer3 =
|
|
252539
|
+
const buffer3 = readFileSync7(fullPath);
|
|
252490
252540
|
const stat4 = statSync3(fullPath);
|
|
252491
252541
|
return {
|
|
252492
252542
|
buffer: buffer3,
|
|
@@ -256866,7 +256916,7 @@ var init_timeout = __esm(() => {
|
|
|
256866
256916
|
});
|
|
256867
256917
|
|
|
256868
256918
|
// ../api/src/middleware/version-headers.ts
|
|
256869
|
-
import { existsSync as
|
|
256919
|
+
import { existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
|
|
256870
256920
|
import { join as join17 } from "path";
|
|
256871
256921
|
function loadRepoPackageVersion() {
|
|
256872
256922
|
try {
|
|
@@ -256874,9 +256924,9 @@ function loadRepoPackageVersion() {
|
|
|
256874
256924
|
join17(import.meta.dir, "..", "..", "..", "..", "package.json"),
|
|
256875
256925
|
join17(process.cwd(), "package.json")
|
|
256876
256926
|
]) {
|
|
256877
|
-
if (!
|
|
256927
|
+
if (!existsSync5(candidate))
|
|
256878
256928
|
continue;
|
|
256879
|
-
const parsed = JSON.parse(
|
|
256929
|
+
const parsed = JSON.parse(readFileSync8(candidate, "utf-8"));
|
|
256880
256930
|
if (parsed.version)
|
|
256881
256931
|
return parsed.version;
|
|
256882
256932
|
}
|
|
@@ -256895,10 +256945,10 @@ function loadServerVersionInfo() {
|
|
|
256895
256945
|
join17(import.meta.dir, "..", "..", "..", "..", "version.json"),
|
|
256896
256946
|
join17(process.cwd(), "version.json")
|
|
256897
256947
|
]) {
|
|
256898
|
-
if (!
|
|
256948
|
+
if (!existsSync5(candidate)) {
|
|
256899
256949
|
continue;
|
|
256900
256950
|
}
|
|
256901
|
-
const parsed = JSON.parse(
|
|
256951
|
+
const parsed = JSON.parse(readFileSync8(candidate, "utf-8"));
|
|
256902
256952
|
return {
|
|
256903
256953
|
version: parsed.version ?? resolveFallbackVersion(),
|
|
256904
256954
|
commit: parsed.commit ?? FALLBACK_COMMIT
|
|
@@ -260641,6 +260691,7 @@ var init_instances2 = __esm(() => {
|
|
|
260641
260691
|
profilePicUrl: exports_external.string().nullable().openapi({ description: "Profile picture URL" }),
|
|
260642
260692
|
ownerIdentifier: exports_external.string().nullable().openapi({ description: "Owner identifier" }),
|
|
260643
260693
|
agentId: exports_external.string().uuid().nullable().optional().openapi({ description: "Agent UUID (agents table)" }),
|
|
260694
|
+
agentProviderId: exports_external.string().uuid().nullable().optional().openapi({ description: "Provider ID (agent provider)" }),
|
|
260644
260695
|
agentTimeout: exports_external.number().openapi({ description: "Agent timeout in seconds" }),
|
|
260645
260696
|
agentStreamMode: exports_external.boolean().openapi({ description: "Whether streaming is enabled" }),
|
|
260646
260697
|
createdAt: exports_external.string().datetime().openapi({ description: "Creation timestamp" }),
|
|
@@ -267451,7 +267502,7 @@ var init_media = __esm(() => {
|
|
|
267451
267502
|
});
|
|
267452
267503
|
|
|
267453
267504
|
// ../api/src/routes/v2/messages.ts
|
|
267454
|
-
import { existsSync as
|
|
267505
|
+
import { existsSync as existsSync6 } from "fs";
|
|
267455
267506
|
import { join as join18 } from "path";
|
|
267456
267507
|
function isUUID(value) {
|
|
267457
267508
|
return UUID_REGEX.test(value);
|
|
@@ -267793,7 +267844,7 @@ var init_messages5 = __esm(() => {
|
|
|
267793
267844
|
let cached = false;
|
|
267794
267845
|
if (mediaLocalPath) {
|
|
267795
267846
|
const fullPath = join18(mediaStorage2.getBasePath(), mediaLocalPath);
|
|
267796
|
-
if (
|
|
267847
|
+
if (existsSync6(fullPath)) {
|
|
267797
267848
|
cached = true;
|
|
267798
267849
|
} else {
|
|
267799
267850
|
mediaDownloadLog.warn("mediaLocalPath set but file missing, re-downloading", {
|
|
@@ -269607,7 +269658,7 @@ var init_v2 = __esm(() => {
|
|
|
269607
269658
|
});
|
|
269608
269659
|
|
|
269609
269660
|
// ../api/src/app.ts
|
|
269610
|
-
import { existsSync as
|
|
269661
|
+
import { existsSync as existsSync7 } from "fs";
|
|
269611
269662
|
import path3 from "path";
|
|
269612
269663
|
function getAllowedOrigins() {
|
|
269613
269664
|
const envOrigins = process.env.OMNI_CORS_ORIGINS;
|
|
@@ -269717,8 +269768,8 @@ function createApp(db2, eventBus = null, channelRegistry2 = null) {
|
|
|
269717
269768
|
app.route("/api/v2", protectedApp);
|
|
269718
269769
|
const cwdUiPath = path3.resolve(process.cwd(), "apps/ui/dist");
|
|
269719
269770
|
const packagesUiPath = process.env.OMNI_PACKAGES_DIR ? path3.resolve(process.env.OMNI_PACKAGES_DIR, "..", "apps/ui/dist") : null;
|
|
269720
|
-
const uiDistPath =
|
|
269721
|
-
const serveUI =
|
|
269771
|
+
const uiDistPath = existsSync7(cwdUiPath) ? cwdUiPath : packagesUiPath && existsSync7(packagesUiPath) ? packagesUiPath : cwdUiPath;
|
|
269772
|
+
const serveUI = existsSync7(uiDistPath);
|
|
269722
269773
|
if (serveUI) {
|
|
269723
269774
|
httpLog.info("Serving UI from apps/ui/dist");
|
|
269724
269775
|
app.use("/assets/*", serveStatic2({
|
|
@@ -270000,13 +270051,13 @@ var init_context3 = __esm(() => {
|
|
|
270000
270051
|
});
|
|
270001
270052
|
|
|
270002
270053
|
// ../api/src/plugins/loader.ts
|
|
270003
|
-
import { existsSync as
|
|
270054
|
+
import { existsSync as existsSync8 } from "fs";
|
|
270004
270055
|
import { dirname as dirname6, join as join19 } from "path";
|
|
270005
270056
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
270006
270057
|
function findMonorepoRoot(startDir) {
|
|
270007
270058
|
let current = startDir;
|
|
270008
270059
|
while (current !== dirname6(current)) {
|
|
270009
|
-
if (
|
|
270060
|
+
if (existsSync8(join19(current, "turbo.json"))) {
|
|
270010
270061
|
return current;
|
|
270011
270062
|
}
|
|
270012
270063
|
current = dirname6(current);
|
|
@@ -391589,6 +391640,28 @@ async function createStorageAuthState(storage, instanceId) {
|
|
|
391589
391640
|
return deserialize(value);
|
|
391590
391641
|
return JSON.parse(JSON.stringify(value), bufferReviver);
|
|
391591
391642
|
}
|
|
391643
|
+
function isBlockedPhoneSenderKey(type, id, value, botPhone) {
|
|
391644
|
+
if (type !== "sender-key" || !botPhone || value == null)
|
|
391645
|
+
return false;
|
|
391646
|
+
const parts = id.split("::");
|
|
391647
|
+
return parts.length >= 2 && parts[1] === botPhone;
|
|
391648
|
+
}
|
|
391649
|
+
function processSignalKeyEntry(type, id, value, botPhone) {
|
|
391650
|
+
const key = `${keyPrefix}:${type}:${id}`;
|
|
391651
|
+
if (isBlockedPhoneSenderKey(type, id, value, botPhone)) {
|
|
391652
|
+
const parts = id.split("::");
|
|
391653
|
+
log46.warn("Blocked phone-JID sender key (LID-first enforced)", {
|
|
391654
|
+
instanceId,
|
|
391655
|
+
group: parts[0]?.slice(-20),
|
|
391656
|
+
participant: parts[1]?.replace(/\d(?=\d{4})/g, "*")
|
|
391657
|
+
});
|
|
391658
|
+
setCachedValue(key, DELETED);
|
|
391659
|
+
backgroundPersist(type, id, key, null);
|
|
391660
|
+
return;
|
|
391661
|
+
}
|
|
391662
|
+
setCachedValue(key, value !== null && value !== undefined ? value : DELETED);
|
|
391663
|
+
backgroundPersist(type, id, key, value);
|
|
391664
|
+
}
|
|
391592
391665
|
function backgroundPersist(type, id, key, value) {
|
|
391593
391666
|
const previousPersist = persistQueues.get(key) ?? Promise.resolve();
|
|
391594
391667
|
const nextPersist = previousPersist.catch(() => {}).then(async () => {
|
|
@@ -391635,13 +391708,12 @@ async function createStorageAuthState(storage, instanceId) {
|
|
|
391635
391708
|
return data;
|
|
391636
391709
|
},
|
|
391637
391710
|
set: async (data) => {
|
|
391711
|
+
const botPhone = creds.me?.id?.split(":")[0]?.split("@")[0];
|
|
391638
391712
|
for (const [type, entries] of Object.entries(data)) {
|
|
391639
391713
|
if (!entries)
|
|
391640
391714
|
continue;
|
|
391641
391715
|
for (const [id, value] of Object.entries(entries)) {
|
|
391642
|
-
|
|
391643
|
-
setCachedValue(key, value !== null && value !== undefined ? value : DELETED);
|
|
391644
|
-
backgroundPersist(type, id, key, value);
|
|
391716
|
+
processSignalKeyEntry(type, id, value, botPhone);
|
|
391645
391717
|
}
|
|
391646
391718
|
}
|
|
391647
391719
|
}
|