@automagik/omni 2.260501.2 → 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 +1 -1
- package/dist/server/index.js +245 -86
- package/package.json +10 -10
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.
|
|
114180
|
+
version: "2.260501.4",
|
|
114181
114181
|
description: "LLM-optimized CLI for Omni",
|
|
114182
114182
|
type: "module",
|
|
114183
114183
|
bin: {
|
package/dist/server/index.js
CHANGED
|
@@ -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.
|
|
224657
|
+
version: "2.260501.4",
|
|
224658
224658
|
type: "module",
|
|
224659
224659
|
exports: {
|
|
224660
224660
|
".": {
|
|
@@ -233824,7 +233824,7 @@ var init_src5 = __esm(() => {
|
|
|
233824
233824
|
init_schema2();
|
|
233825
233825
|
});
|
|
233826
233826
|
|
|
233827
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
233827
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/postgres.js
|
|
233828
233828
|
import { EventEmitter as EventEmitter4 } from "events";
|
|
233829
233829
|
import os6 from "os";
|
|
233830
233830
|
import path2 from "path";
|
|
@@ -234797,7 +234797,7 @@ Output: ${startupOutput}`));
|
|
|
234797
234797
|
};
|
|
234798
234798
|
});
|
|
234799
234799
|
|
|
234800
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
234800
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/logger.js
|
|
234801
234801
|
function formatTime2() {
|
|
234802
234802
|
const now = new Date;
|
|
234803
234803
|
return `${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}:${String(now.getSeconds()).padStart(2, "0")}`;
|
|
@@ -234861,7 +234861,7 @@ var init_logger4 = __esm(() => {
|
|
|
234861
234861
|
LEVELS = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
234862
234862
|
});
|
|
234863
234863
|
|
|
234864
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
234864
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/sync.js
|
|
234865
234865
|
var {SQL: SQL2 } = globalThis.Bun;
|
|
234866
234866
|
function matchesPattern2(dbName, patterns) {
|
|
234867
234867
|
if (!patterns || patterns.length === 0)
|
|
@@ -235078,7 +235078,7 @@ var init_sync = __esm(() => {
|
|
|
235078
235078
|
init_logger4();
|
|
235079
235079
|
});
|
|
235080
235080
|
|
|
235081
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
235081
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/pg-wire.js
|
|
235082
235082
|
import { createHash as createHash7 } from "crypto";
|
|
235083
235083
|
|
|
235084
235084
|
class PgWireClient {
|
|
@@ -235650,7 +235650,7 @@ var init_pg_wire = __esm(() => {
|
|
|
235650
235650
|
};
|
|
235651
235651
|
});
|
|
235652
235652
|
|
|
235653
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
235653
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/restore.js
|
|
235654
235654
|
function matchesPattern3(dbName, patterns) {
|
|
235655
235655
|
if (!patterns || patterns.length === 0)
|
|
235656
235656
|
return true;
|
|
@@ -236003,7 +236003,7 @@ var init_restore = __esm(() => {
|
|
|
236003
236003
|
init_logger4();
|
|
236004
236004
|
});
|
|
236005
236005
|
|
|
236006
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
236006
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/dashboard.js
|
|
236007
236007
|
import { readFileSync as readFileSync3 } from "fs";
|
|
236008
236008
|
import { join as join14, dirname as dirname5 } from "path";
|
|
236009
236009
|
import { fileURLToPath } from "url";
|
|
@@ -236147,7 +236147,7 @@ var init_dashboard = __esm(() => {
|
|
|
236147
236147
|
};
|
|
236148
236148
|
});
|
|
236149
236149
|
|
|
236150
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
236150
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/protocol.js
|
|
236151
236151
|
function parseStartupMessage(data, fastPath = true) {
|
|
236152
236152
|
const length = data.readInt32BE(0);
|
|
236153
236153
|
const version4 = data.readInt32BE(4);
|
|
@@ -236300,7 +236300,7 @@ function buildErrorResponse({ severity = "FATAL", sqlstate, message: message2 })
|
|
|
236300
236300
|
var PROTOCOL_VERSION_3 = 196608;
|
|
236301
236301
|
var init_protocol = () => {};
|
|
236302
236302
|
|
|
236303
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
236303
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/router.js
|
|
236304
236304
|
import fs10 from "fs";
|
|
236305
236305
|
import { EventEmitter as EventEmitter5 } from "events";
|
|
236306
236306
|
function flushPending(target, pending) {
|
|
@@ -236636,7 +236636,7 @@ var init_router = __esm(() => {
|
|
|
236636
236636
|
};
|
|
236637
236637
|
});
|
|
236638
236638
|
|
|
236639
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
236639
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/stats-collector.js
|
|
236640
236640
|
class StatsCollector {
|
|
236641
236641
|
constructor(options = {}) {
|
|
236642
236642
|
this.pgManager = options.pgManager;
|
|
@@ -236955,7 +236955,7 @@ class StatsCollector {
|
|
|
236955
236955
|
}
|
|
236956
236956
|
var CPU_SAMPLE_MIN_INTERVAL_MS = 100, PROC_DISKSTATS_MIN_FIELDS = 14;
|
|
236957
236957
|
|
|
236958
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
236958
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/stats-dashboard.js
|
|
236959
236959
|
class StatsDashboard {
|
|
236960
236960
|
constructor(options = {}) {
|
|
236961
236961
|
this.enabled = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
@@ -237219,7 +237219,7 @@ var init_stats_dashboard = __esm(() => {
|
|
|
237219
237219
|
};
|
|
237220
237220
|
});
|
|
237221
237221
|
|
|
237222
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
237222
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/audit.js
|
|
237223
237223
|
import fs11 from "fs";
|
|
237224
237224
|
import os7 from "os";
|
|
237225
237225
|
import path3 from "path";
|
|
@@ -237315,7 +237315,7 @@ var init_audit = __esm(() => {
|
|
|
237315
237315
|
});
|
|
237316
237316
|
});
|
|
237317
237317
|
|
|
237318
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
237318
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/fingerprint.js
|
|
237319
237319
|
import crypto6 from "crypto";
|
|
237320
237320
|
import { execFileSync } from "child_process";
|
|
237321
237321
|
import fs12 from "fs";
|
|
@@ -237594,7 +237594,7 @@ var init_fingerprint = __esm(() => {
|
|
|
237594
237594
|
init_audit();
|
|
237595
237595
|
});
|
|
237596
237596
|
|
|
237597
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
237597
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/tokens.js
|
|
237598
237598
|
import crypto7 from "crypto";
|
|
237599
237599
|
function mintToken() {
|
|
237600
237600
|
const id = crypto7.randomBytes(TOKEN_ID_BYTES).toString("hex");
|
|
@@ -237648,7 +237648,7 @@ var init_tokens = __esm(() => {
|
|
|
237648
237648
|
FP_RE = /^[0-9a-f]{12}$/;
|
|
237649
237649
|
});
|
|
237650
237650
|
|
|
237651
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
237651
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/control-db.js
|
|
237652
237652
|
function query(client, text3, params = [], opts = {}) {
|
|
237653
237653
|
if (client.supportsQueryOptions && opts && Object.keys(opts).length > 0) {
|
|
237654
237654
|
return client.query(text3, params, opts);
|
|
@@ -237785,7 +237785,7 @@ var init_control_db = __esm(() => {
|
|
|
237785
237785
|
init_tokens();
|
|
237786
237786
|
});
|
|
237787
237787
|
|
|
237788
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
237788
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/admin-client.js
|
|
237789
237789
|
var {SQL: SQL3 } = globalThis.Bun;
|
|
237790
237790
|
import fs13 from "fs";
|
|
237791
237791
|
import path5 from "path";
|
|
@@ -237928,7 +237928,7 @@ function removeAdminDiscovery(controlSocketDir) {
|
|
|
237928
237928
|
}
|
|
237929
237929
|
var init_admin_client = () => {};
|
|
237930
237930
|
|
|
237931
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
237931
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/tenancy.js
|
|
237932
237932
|
function sanitizeName(name) {
|
|
237933
237933
|
const raw = (typeof name === "string" ? name : "").toLowerCase();
|
|
237934
237934
|
const collapsed = raw.replace(/[^a-z0-9]+/g, "_");
|
|
@@ -237952,7 +237952,7 @@ function isFingerprintEnforcementDisabled(env2 = process.env) {
|
|
|
237952
237952
|
}
|
|
237953
237953
|
var KILL_SWITCH_ENV = "PGSERVE_DISABLE_FINGERPRINT_ENFORCEMENT", NAME_TRUNCATE = 30, MAX_DB_IDENT = 63;
|
|
237954
237954
|
|
|
237955
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
237955
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/daemon-shared.js
|
|
237956
237956
|
function flushPending2(target, pending) {
|
|
237957
237957
|
const written = target.write(pending);
|
|
237958
237958
|
if (written === pending.byteLength)
|
|
@@ -237962,7 +237962,7 @@ function flushPending2(target, pending) {
|
|
|
237962
237962
|
return pending.subarray(written);
|
|
237963
237963
|
}
|
|
237964
237964
|
|
|
237965
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
237965
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/daemon-control.js
|
|
237966
237966
|
import fs14 from "fs";
|
|
237967
237967
|
function attachControlHandlers(PgserveDaemon) {
|
|
237968
237968
|
PgserveDaemon.prototype.handleSocketOpen = handleSocketOpen;
|
|
@@ -238297,7 +238297,7 @@ var init_daemon_control = __esm(() => {
|
|
|
238297
238297
|
MAX_STARTUP_BUFFER_SIZE2 = 1024 * 1024;
|
|
238298
238298
|
});
|
|
238299
238299
|
|
|
238300
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
238300
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/daemon-tcp.js
|
|
238301
238301
|
import fs15 from "fs";
|
|
238302
238302
|
function attachTcpHandlers(PgserveDaemon) {
|
|
238303
238303
|
PgserveDaemon.prototype.bindTcpListener = bindTcpListener;
|
|
@@ -238566,7 +238566,7 @@ var init_daemon_tcp = __esm(() => {
|
|
|
238566
238566
|
MAX_STARTUP_BUFFER_SIZE3 = 1024 * 1024;
|
|
238567
238567
|
});
|
|
238568
238568
|
|
|
238569
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
238569
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/gc.js
|
|
238570
238570
|
function defaultIsProcessAlive(pid) {
|
|
238571
238571
|
if (!Number.isInteger(pid) || pid <= 0)
|
|
238572
238572
|
return false;
|
|
@@ -238782,7 +238782,7 @@ var init_gc = __esm(() => {
|
|
|
238782
238782
|
HOURLY_MS = 60 * 60 * 1000;
|
|
238783
238783
|
});
|
|
238784
238784
|
|
|
238785
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
238785
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/daemon.js
|
|
238786
238786
|
import fs16 from "fs";
|
|
238787
238787
|
import path6 from "path";
|
|
238788
238788
|
import { EventEmitter as EventEmitter6 } from "events";
|
|
@@ -239279,7 +239279,7 @@ var init_daemon = __esm(() => {
|
|
|
239279
239279
|
attachTcpHandlers(PgserveDaemon);
|
|
239280
239280
|
});
|
|
239281
239281
|
|
|
239282
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
239282
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/sdk.js
|
|
239283
239283
|
import { spawn as spawn4 } from "child_process";
|
|
239284
239284
|
import fs17 from "fs";
|
|
239285
239285
|
import path7 from "path";
|
|
@@ -239402,7 +239402,7 @@ var init_sdk4 = __esm(() => {
|
|
|
239402
239402
|
__dirname2 = path7.dirname(fileURLToPath2(import.meta.url));
|
|
239403
239403
|
});
|
|
239404
239404
|
|
|
239405
|
-
// ../../node_modules/.bun/pgserve@2.1.
|
|
239405
|
+
// ../../node_modules/.bun/pgserve@2.1.3/node_modules/pgserve/src/index.js
|
|
239406
239406
|
var exports_src2 = {};
|
|
239407
239407
|
__export(exports_src2, {
|
|
239408
239408
|
stopDaemon: () => stopDaemon,
|
|
@@ -284827,6 +284827,9 @@ function buildWhatsAppMessageContext(rawPayload, chatId, instance4, text3) {
|
|
|
284827
284827
|
}
|
|
284828
284828
|
|
|
284829
284829
|
// ../api/src/services/turn-events.ts
|
|
284830
|
+
function getTurnEventsConnection() {
|
|
284831
|
+
return nc && !nc.isClosed() ? nc : null;
|
|
284832
|
+
}
|
|
284830
284833
|
async function initTurnEvents(natsUrl) {
|
|
284831
284834
|
if (nc && !nc.isClosed())
|
|
284832
284835
|
return;
|
|
@@ -297323,6 +297326,35 @@ function checkInstanceAccess(apiKey, instanceId) {
|
|
|
297323
297326
|
});
|
|
297324
297327
|
}
|
|
297325
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
|
+
}
|
|
297326
297358
|
async function getPluginForInstance(services, channelRegistry2, instanceId, requiredCapability) {
|
|
297327
297359
|
const instance4 = await services.instances.getById(instanceId);
|
|
297328
297360
|
if (!channelRegistry2) {
|
|
@@ -297390,16 +297422,19 @@ function resolveContactName2(chat2, contactNames) {
|
|
|
297390
297422
|
}
|
|
297391
297423
|
return;
|
|
297392
297424
|
}
|
|
297393
|
-
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;
|
|
297394
297426
|
var init_chats2 = __esm(() => {
|
|
297395
297427
|
init_dist6();
|
|
297396
297428
|
init_src();
|
|
297429
|
+
init_schema2();
|
|
297430
|
+
init_drizzle_orm();
|
|
297397
297431
|
init_dist2();
|
|
297398
297432
|
init_zod();
|
|
297399
297433
|
init_session_cleaner();
|
|
297400
297434
|
init_date_query();
|
|
297401
297435
|
init_api_keys();
|
|
297402
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;
|
|
297403
297438
|
ChatTypeSchema = exports_external.enum([
|
|
297404
297439
|
"dm",
|
|
297405
297440
|
"group",
|
|
@@ -297483,20 +297518,29 @@ var init_chats2 = __esm(() => {
|
|
|
297483
297518
|
return c.json({ data: chat2 }, 201);
|
|
297484
297519
|
});
|
|
297485
297520
|
chatsRoutes.get("/:id", async (c) => {
|
|
297486
|
-
const
|
|
297521
|
+
const raw2 = c.req.param("id");
|
|
297522
|
+
const id = await resolveChatIdParam(c, raw2);
|
|
297523
|
+
if (id === null)
|
|
297524
|
+
return chatNotFoundResponse(c, raw2);
|
|
297487
297525
|
const services = c.get("services");
|
|
297488
297526
|
const chat2 = await services.chats.getById(id);
|
|
297489
297527
|
return c.json({ data: chat2 });
|
|
297490
297528
|
});
|
|
297491
297529
|
chatsRoutes.patch("/:id", zValidator("json", updateChatSchema), async (c) => {
|
|
297492
|
-
const
|
|
297530
|
+
const raw2 = c.req.param("id");
|
|
297531
|
+
const id = await resolveChatIdParam(c, raw2);
|
|
297532
|
+
if (id === null)
|
|
297533
|
+
return chatNotFoundResponse(c, raw2);
|
|
297493
297534
|
const body = c.req.valid("json");
|
|
297494
297535
|
const services = c.get("services");
|
|
297495
297536
|
const chat2 = await services.chats.update(id, body);
|
|
297496
297537
|
return c.json({ data: chat2 });
|
|
297497
297538
|
});
|
|
297498
297539
|
chatsRoutes.delete("/:id", async (c) => {
|
|
297499
|
-
const
|
|
297540
|
+
const raw2 = c.req.param("id");
|
|
297541
|
+
const id = await resolveChatIdParam(c, raw2);
|
|
297542
|
+
if (id === null)
|
|
297543
|
+
return chatNotFoundResponse(c, raw2);
|
|
297500
297544
|
const services = c.get("services");
|
|
297501
297545
|
await services.chats.delete(id);
|
|
297502
297546
|
return c.json({ success: true });
|
|
@@ -297612,7 +297656,10 @@ var init_chats2 = __esm(() => {
|
|
|
297612
297656
|
return c.json({ success: true, data: { chatId: id, action: "unmute" } });
|
|
297613
297657
|
});
|
|
297614
297658
|
chatsRoutes.get("/:id/participants", async (c) => {
|
|
297615
|
-
const
|
|
297659
|
+
const raw2 = c.req.param("id");
|
|
297660
|
+
const id = await resolveChatIdParam(c, raw2);
|
|
297661
|
+
if (id === null)
|
|
297662
|
+
return chatNotFoundResponse(c, raw2);
|
|
297616
297663
|
const services = c.get("services");
|
|
297617
297664
|
const participants = await services.chats.getParticipants(id);
|
|
297618
297665
|
return c.json({ items: participants });
|
|
@@ -297649,7 +297696,10 @@ var init_chats2 = __esm(() => {
|
|
|
297649
297696
|
mediaOnly: exports_external.string().optional().transform((v2) => v2 === "true")
|
|
297650
297697
|
});
|
|
297651
297698
|
chatsRoutes.get("/:id/messages", zValidator("query", listMessagesQuerySchema), async (c) => {
|
|
297652
|
-
const
|
|
297699
|
+
const raw2 = c.req.param("id");
|
|
297700
|
+
const chatId = await resolveChatIdParam(c, raw2);
|
|
297701
|
+
if (chatId === null)
|
|
297702
|
+
return chatNotFoundResponse(c, raw2);
|
|
297653
297703
|
const { limit: limit2, before, after, mediaOnly } = c.req.valid("query");
|
|
297654
297704
|
const services = c.get("services");
|
|
297655
297705
|
const messages4 = await services.messages.getChatMessages(chatId, {
|
|
@@ -302794,7 +302844,7 @@ var init__close_contact_config = __esm(() => {
|
|
|
302794
302844
|
import { existsSync as existsSync8 } from "fs";
|
|
302795
302845
|
import { join as join24 } from "path";
|
|
302796
302846
|
function isUUID(value) {
|
|
302797
|
-
return
|
|
302847
|
+
return UUID_REGEX2.test(value);
|
|
302798
302848
|
}
|
|
302799
302849
|
function extractReactionTargetParticipant(rawPayload) {
|
|
302800
302850
|
const key = rawPayload?.key;
|
|
@@ -302950,7 +303000,7 @@ async function verifyMessageInstanceOwnership(services, message2, instanceId) {
|
|
|
302950
303000
|
});
|
|
302951
303001
|
}
|
|
302952
303002
|
}
|
|
302953
|
-
var log106, mediaDownloadLog, messagesRoutes,
|
|
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;
|
|
302954
303004
|
var init_messages5 = __esm(() => {
|
|
302955
303005
|
init_dist6();
|
|
302956
303006
|
init_src2();
|
|
@@ -302968,7 +303018,7 @@ var init_messages5 = __esm(() => {
|
|
|
302968
303018
|
log106 = createLogger("routes:messages");
|
|
302969
303019
|
mediaDownloadLog = createLogger("routes:messages:media-download");
|
|
302970
303020
|
messagesRoutes = new Hono2;
|
|
302971
|
-
|
|
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;
|
|
302972
303022
|
MessageSourceSchema = exports_external.enum(["realtime", "sync", "api", "import"]);
|
|
302973
303023
|
MessageTypeSchema = exports_external.enum([
|
|
302974
303024
|
"text",
|
|
@@ -305785,10 +305835,10 @@ function createApp(db2, eventBus = null, channelRegistry2 = null) {
|
|
|
305785
305835
|
}
|
|
305786
305836
|
return plugin7.handleWebhook(c.req.raw);
|
|
305787
305837
|
});
|
|
305788
|
-
const
|
|
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;
|
|
305789
305839
|
app.post("/a2a/:instanceId", authMiddleware, requireInstanceAccess((c) => c.req.param("instanceId")), rateLimitMiddleware, async (c) => {
|
|
305790
305840
|
const instanceId = c.req.param("instanceId");
|
|
305791
|
-
if (!
|
|
305841
|
+
if (!UUID_REGEX3.test(instanceId)) {
|
|
305792
305842
|
return c.json({ error: "Invalid instance ID format" }, 400);
|
|
305793
305843
|
}
|
|
305794
305844
|
const channelRegistry3 = c.get("channelRegistry");
|
|
@@ -308184,6 +308234,102 @@ var init_scheduler2 = __esm(() => {
|
|
|
308184
308234
|
log111 = createLogger("scheduler:setup");
|
|
308185
308235
|
});
|
|
308186
308236
|
|
|
308237
|
+
// ../api/src/services/agent-heartbeat.ts
|
|
308238
|
+
class AgentHeartbeatConsumer {
|
|
308239
|
+
subscription = null;
|
|
308240
|
+
loop = null;
|
|
308241
|
+
start(options) {
|
|
308242
|
+
if (this.subscription)
|
|
308243
|
+
return;
|
|
308244
|
+
const { natsConnection, turnService } = options;
|
|
308245
|
+
if (natsConnection.isClosed()) {
|
|
308246
|
+
log112.warn("Cannot start agent-heartbeat: NATS connection is closed");
|
|
308247
|
+
return;
|
|
308248
|
+
}
|
|
308249
|
+
this.subscription = natsConnection.subscribe(HEARTBEAT_SUBJECT);
|
|
308250
|
+
log112.info("Agent heartbeat consumer started", { subject: HEARTBEAT_SUBJECT });
|
|
308251
|
+
const sub = this.subscription;
|
|
308252
|
+
this.loop = (async () => {
|
|
308253
|
+
for await (const msg of sub) {
|
|
308254
|
+
try {
|
|
308255
|
+
const raw2 = sc3.decode(msg.data);
|
|
308256
|
+
const parsed = parseHeartbeat(raw2);
|
|
308257
|
+
if (!parsed) {
|
|
308258
|
+
log112.warn("Discarded malformed agent heartbeat", {
|
|
308259
|
+
subject: msg.subject,
|
|
308260
|
+
raw: raw2.slice(0, 200)
|
|
308261
|
+
});
|
|
308262
|
+
continue;
|
|
308263
|
+
}
|
|
308264
|
+
turnService.recordActivity(parsed.turnId).catch((error2) => {
|
|
308265
|
+
log112.warn("recordActivity failed for heartbeat (turn likely closed)", {
|
|
308266
|
+
turnId: parsed.turnId,
|
|
308267
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
308268
|
+
});
|
|
308269
|
+
});
|
|
308270
|
+
log112.debug("Agent heartbeat applied", {
|
|
308271
|
+
turnId: parsed.turnId,
|
|
308272
|
+
instanceId: parsed.instanceId,
|
|
308273
|
+
chatId: parsed.chatId
|
|
308274
|
+
});
|
|
308275
|
+
} catch (error2) {
|
|
308276
|
+
log112.warn("Failed to process agent heartbeat", {
|
|
308277
|
+
subject: msg.subject,
|
|
308278
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
308279
|
+
});
|
|
308280
|
+
}
|
|
308281
|
+
}
|
|
308282
|
+
})();
|
|
308283
|
+
}
|
|
308284
|
+
async stop() {
|
|
308285
|
+
if (!this.subscription)
|
|
308286
|
+
return;
|
|
308287
|
+
this.subscription.unsubscribe();
|
|
308288
|
+
this.subscription = null;
|
|
308289
|
+
try {
|
|
308290
|
+
await this.loop;
|
|
308291
|
+
} catch {} finally {
|
|
308292
|
+
this.loop = null;
|
|
308293
|
+
log112.info("Agent heartbeat consumer stopped");
|
|
308294
|
+
}
|
|
308295
|
+
}
|
|
308296
|
+
}
|
|
308297
|
+
function parseHeartbeat(raw2) {
|
|
308298
|
+
let value;
|
|
308299
|
+
try {
|
|
308300
|
+
value = JSON.parse(raw2);
|
|
308301
|
+
} catch {
|
|
308302
|
+
return null;
|
|
308303
|
+
}
|
|
308304
|
+
if (!value || typeof value !== "object")
|
|
308305
|
+
return null;
|
|
308306
|
+
const obj = value;
|
|
308307
|
+
const { turnId, instanceId, chatId, timestamp: timestamp3 } = obj;
|
|
308308
|
+
if (typeof turnId !== "string" || turnId.length === 0 || typeof instanceId !== "string" || instanceId.length === 0 || typeof chatId !== "string" || chatId.length === 0 || typeof timestamp3 !== "string" || timestamp3.length === 0) {
|
|
308309
|
+
return null;
|
|
308310
|
+
}
|
|
308311
|
+
return { turnId, instanceId, chatId, timestamp: timestamp3 };
|
|
308312
|
+
}
|
|
308313
|
+
function initAgentHeartbeat(options) {
|
|
308314
|
+
if (consumer)
|
|
308315
|
+
return;
|
|
308316
|
+
consumer = new AgentHeartbeatConsumer;
|
|
308317
|
+
consumer.start(options);
|
|
308318
|
+
}
|
|
308319
|
+
async function closeAgentHeartbeat() {
|
|
308320
|
+
if (!consumer)
|
|
308321
|
+
return;
|
|
308322
|
+
await consumer.stop();
|
|
308323
|
+
consumer = null;
|
|
308324
|
+
}
|
|
308325
|
+
var import_nats8, log112, sc3, HEARTBEAT_SUBJECT = "omni.agent.heartbeat.>", consumer = null;
|
|
308326
|
+
var init_agent_heartbeat = __esm(() => {
|
|
308327
|
+
init_src();
|
|
308328
|
+
import_nats8 = __toESM(require_mod4(), 1);
|
|
308329
|
+
log112 = createLogger("agent-heartbeat");
|
|
308330
|
+
sc3 = import_nats8.StringCodec();
|
|
308331
|
+
});
|
|
308332
|
+
|
|
308187
308333
|
// ../api/src/services/turn-monitor.ts
|
|
308188
308334
|
class TurnMonitor {
|
|
308189
308335
|
deps;
|
|
@@ -308195,7 +308341,7 @@ class TurnMonitor {
|
|
|
308195
308341
|
start() {
|
|
308196
308342
|
if (this.intervalId)
|
|
308197
308343
|
return;
|
|
308198
|
-
|
|
308344
|
+
log113.info("Turn monitor started", {
|
|
308199
308345
|
pollIntervalMs: POLL_INTERVAL_MS2,
|
|
308200
308346
|
nudgeMs: NUDGE_THRESHOLD_MS,
|
|
308201
308347
|
defaultStalledMs: DEFAULT_STALLED_THRESHOLD_MS,
|
|
@@ -308207,7 +308353,7 @@ class TurnMonitor {
|
|
|
308207
308353
|
if (this.intervalId) {
|
|
308208
308354
|
clearInterval(this.intervalId);
|
|
308209
308355
|
this.intervalId = null;
|
|
308210
|
-
|
|
308356
|
+
log113.info("Turn monitor stopped");
|
|
308211
308357
|
}
|
|
308212
308358
|
}
|
|
308213
308359
|
async tick() {
|
|
@@ -308235,7 +308381,7 @@ class TurnMonitor {
|
|
|
308235
308381
|
}
|
|
308236
308382
|
}
|
|
308237
308383
|
} catch (error2) {
|
|
308238
|
-
|
|
308384
|
+
log113.error("Turn monitor tick failed", { error: String(error2) });
|
|
308239
308385
|
} finally {
|
|
308240
308386
|
this.running = false;
|
|
308241
308387
|
}
|
|
@@ -308248,13 +308394,13 @@ class TurnMonitor {
|
|
|
308248
308394
|
idleSec,
|
|
308249
308395
|
message: `Turn idle for ${idleSec}s. Are you still working?`
|
|
308250
308396
|
});
|
|
308251
|
-
|
|
308397
|
+
log113.info("Turn nudge emitted", { turnId, nudgeCount, idleSec });
|
|
308252
308398
|
}
|
|
308253
308399
|
async handleStalled(turnId, instanceId, chatId, stalledAtMs, threshold) {
|
|
308254
308400
|
await this.deps.turnService.incrementNudge(turnId);
|
|
308255
308401
|
const payload = { turnId, instanceId, chatId, stalledAtMs, threshold };
|
|
308256
308402
|
publishTurnStalled(instanceId, chatId, payload);
|
|
308257
|
-
|
|
308403
|
+
log113.warn("Turn stalled \u2014 internal event emitted (no channel message sent)", payload);
|
|
308258
308404
|
}
|
|
308259
308405
|
async handleTimeout(turnId, instanceId, chatId, idleSec, nudgeCount) {
|
|
308260
308406
|
const closed = await this.deps.turnService.close(turnId, {
|
|
@@ -308277,14 +308423,14 @@ class TurnMonitor {
|
|
|
308277
308423
|
nudgeCount,
|
|
308278
308424
|
messagesSent: closed.messagesSent
|
|
308279
308425
|
});
|
|
308280
|
-
|
|
308426
|
+
log113.info("Turn force-closed (timeout)", { turnId, duration, nudgeCount });
|
|
308281
308427
|
}
|
|
308282
308428
|
}
|
|
308283
|
-
var
|
|
308429
|
+
var log113, NUDGE_THRESHOLD_MS = 120000, DEFAULT_STALLED_THRESHOLD_MS = 600000, TIMEOUT_THRESHOLD_MS = 1800000, POLL_INTERVAL_MS2 = 1e4;
|
|
308284
308430
|
var init_turn_monitor = __esm(() => {
|
|
308285
308431
|
init_src();
|
|
308286
308432
|
init_turn_events();
|
|
308287
|
-
|
|
308433
|
+
log113 = createLogger("turn-monitor");
|
|
308288
308434
|
});
|
|
308289
308435
|
|
|
308290
308436
|
// ../api/src/utils/startup-banner.ts
|
|
@@ -308358,12 +308504,12 @@ function printStartupBanner(options) {
|
|
|
308358
308504
|
process.stdout.write(`${line3}
|
|
308359
308505
|
`);
|
|
308360
308506
|
}
|
|
308361
|
-
|
|
308507
|
+
log114.info("Server ready", { host, port, version: version4 });
|
|
308362
308508
|
}
|
|
308363
|
-
var
|
|
308509
|
+
var log114, COLORS3, BOX, ANSI_ESCAPE_PATTERN;
|
|
308364
308510
|
var init_startup_banner = __esm(() => {
|
|
308365
308511
|
init_src();
|
|
308366
|
-
|
|
308512
|
+
log114 = createLogger("api:startup");
|
|
308367
308513
|
COLORS3 = {
|
|
308368
308514
|
reset: "\x1B[0m",
|
|
308369
308515
|
dim: "\x1B[2m",
|
|
@@ -308421,7 +308567,7 @@ class VoiceStreamRegistry {
|
|
|
308421
308567
|
clients = new Map;
|
|
308422
308568
|
add(ws, client) {
|
|
308423
308569
|
this.clients.set(ws, client);
|
|
308424
|
-
|
|
308570
|
+
log115.info("Voice WS client connected", {
|
|
308425
308571
|
sessionId: client.params.sessionId,
|
|
308426
308572
|
format: client.params.format,
|
|
308427
308573
|
filterUser: client.params.filterUserId ?? "all"
|
|
@@ -308486,11 +308632,11 @@ function parseVoiceStreamParams(url) {
|
|
|
308486
308632
|
return null;
|
|
308487
308633
|
return { sessionId, apiKey, format: format === "pcm" ? "pcm" : "opus", filterUserId };
|
|
308488
308634
|
}
|
|
308489
|
-
var
|
|
308635
|
+
var log115, opusCodec = null;
|
|
308490
308636
|
var init_voice3 = __esm(() => {
|
|
308491
308637
|
init_src();
|
|
308492
308638
|
init_src3();
|
|
308493
|
-
|
|
308639
|
+
log115 = createLogger("ws:voice");
|
|
308494
308640
|
});
|
|
308495
308641
|
|
|
308496
308642
|
// ../api/src/index.ts
|
|
@@ -308684,6 +308830,8 @@ function setupShutdownHandlers(server, earlyShutdown) {
|
|
|
308684
308830
|
shutdownLog.info("Stopping turn monitor");
|
|
308685
308831
|
globalTurnMonitor.stop();
|
|
308686
308832
|
}
|
|
308833
|
+
shutdownLog.info("Stopping agent heartbeat consumer");
|
|
308834
|
+
await closeAgentHeartbeat();
|
|
308687
308835
|
shutdownLog.info("Closing turn events NATS");
|
|
308688
308836
|
await closeTurnEvents();
|
|
308689
308837
|
if (globalInstanceMonitor) {
|
|
@@ -308724,7 +308872,7 @@ async function resolveCallAgentChatIds(services, ctx) {
|
|
|
308724
308872
|
senderId: ctx.senderId === ctx.chatId ? chat2.externalId : ctx.senderId
|
|
308725
308873
|
};
|
|
308726
308874
|
} catch {
|
|
308727
|
-
|
|
308875
|
+
log116.warn("call_agent: chat UUID not resolvable, using raw value (session may diverge)", {
|
|
308728
308876
|
chatId: ctx.chatId,
|
|
308729
308877
|
instanceId: ctx.instanceId
|
|
308730
308878
|
});
|
|
@@ -308733,23 +308881,23 @@ async function resolveCallAgentChatIds(services, ctx) {
|
|
|
308733
308881
|
}
|
|
308734
308882
|
async function setupEventBusServices(eventBus, services, db3) {
|
|
308735
308883
|
if (!eventBus) {
|
|
308736
|
-
|
|
308884
|
+
log116.warn("Skipping event bus services (no event bus)");
|
|
308737
308885
|
return;
|
|
308738
308886
|
}
|
|
308739
308887
|
try {
|
|
308740
308888
|
await setupMessagePersistence(eventBus, services);
|
|
308741
308889
|
} catch (error2) {
|
|
308742
|
-
|
|
308890
|
+
log116.error("Failed to set up message persistence", { error: String(error2) });
|
|
308743
308891
|
}
|
|
308744
308892
|
try {
|
|
308745
308893
|
await setupMediaProcessor(eventBus, db3, services);
|
|
308746
308894
|
} catch (error2) {
|
|
308747
|
-
|
|
308895
|
+
log116.error("Failed to set up media processor", { error: String(error2) });
|
|
308748
308896
|
}
|
|
308749
308897
|
try {
|
|
308750
308898
|
globalDispatcherCleanup = await setupAgentResponder(eventBus, services, db3);
|
|
308751
308899
|
} catch (error2) {
|
|
308752
|
-
|
|
308900
|
+
log116.error("Failed to set up agent dispatcher", { error: String(error2) });
|
|
308753
308901
|
}
|
|
308754
308902
|
try {
|
|
308755
308903
|
await services.automations.startEngine({
|
|
@@ -308825,34 +308973,44 @@ async function setupEventBusServices(eventBus, services, db3) {
|
|
|
308825
308973
|
}
|
|
308826
308974
|
});
|
|
308827
308975
|
} catch (error2) {
|
|
308828
|
-
|
|
308976
|
+
log116.error("Failed to start automation engine", { error: String(error2) });
|
|
308829
308977
|
}
|
|
308830
308978
|
try {
|
|
308831
308979
|
await setupSessionCleaner(eventBus, services, db3);
|
|
308832
308980
|
} catch (error2) {
|
|
308833
|
-
|
|
308981
|
+
log116.error("Failed to set up session cleaner", { error: String(error2) });
|
|
308834
308982
|
}
|
|
308835
308983
|
try {
|
|
308836
308984
|
await setupFollowUpHooks(eventBus, services);
|
|
308837
308985
|
} catch (error2) {
|
|
308838
|
-
|
|
308986
|
+
log116.error("Failed to set up follow-up hooks", { error: String(error2) });
|
|
308839
308987
|
}
|
|
308840
308988
|
if (globalChannelRegistry) {
|
|
308841
308989
|
try {
|
|
308842
308990
|
await setupSyncWorker(eventBus, services, globalChannelRegistry, db3);
|
|
308843
308991
|
} catch (error2) {
|
|
308844
|
-
|
|
308992
|
+
log116.error("Failed to set up sync worker", { error: String(error2) });
|
|
308845
308993
|
}
|
|
308846
308994
|
}
|
|
308847
308995
|
try {
|
|
308848
308996
|
await setupHistoryPushTracker(eventBus, services);
|
|
308849
308997
|
} catch (error2) {
|
|
308850
|
-
|
|
308998
|
+
log116.error("Failed to set up history-push tracker", { error: String(error2) });
|
|
308851
308999
|
}
|
|
308852
309000
|
try {
|
|
308853
309001
|
await initTurnEvents(NATS_URL);
|
|
308854
309002
|
} catch (error2) {
|
|
308855
|
-
|
|
309003
|
+
log116.error("Failed to initialize turn events", { error: String(error2) });
|
|
309004
|
+
}
|
|
309005
|
+
try {
|
|
309006
|
+
const turnEventsConn = getTurnEventsConnection();
|
|
309007
|
+
if (turnEventsConn) {
|
|
309008
|
+
initAgentHeartbeat({ natsConnection: turnEventsConn, turnService: services.turns });
|
|
309009
|
+
} else {
|
|
309010
|
+
log116.warn("Skipping agent heartbeat consumer: no NATS connection");
|
|
309011
|
+
}
|
|
309012
|
+
} catch (error2) {
|
|
309013
|
+
log116.error("Failed to initialize agent heartbeat consumer", { error: String(error2) });
|
|
308856
309014
|
}
|
|
308857
309015
|
try {
|
|
308858
309016
|
globalTurnMonitor = new TurnMonitor({
|
|
@@ -308860,42 +309018,42 @@ async function setupEventBusServices(eventBus, services, db3) {
|
|
|
308860
309018
|
instanceService: services.instances
|
|
308861
309019
|
});
|
|
308862
309020
|
globalTurnMonitor.start();
|
|
308863
|
-
|
|
309021
|
+
log116.info("Turn monitor started");
|
|
308864
309022
|
} catch (error2) {
|
|
308865
|
-
|
|
309023
|
+
log116.error("Failed to start turn monitor", { error: String(error2) });
|
|
308866
309024
|
}
|
|
308867
309025
|
}
|
|
308868
309026
|
async function waitForDatabaseReady(db3, maxAttempts = 30) {
|
|
308869
|
-
|
|
309027
|
+
log116.info("Waiting for database readiness");
|
|
308870
309028
|
for (let attempt = 1;attempt <= maxAttempts; attempt++) {
|
|
308871
309029
|
try {
|
|
308872
309030
|
await db3.execute(sql`SELECT 1`);
|
|
308873
|
-
|
|
309031
|
+
log116.info("Database ready", { attempt });
|
|
308874
309032
|
return;
|
|
308875
309033
|
} catch {
|
|
308876
309034
|
if (attempt === maxAttempts) {
|
|
308877
309035
|
throw new Error(`Database not ready after ${maxAttempts} attempts`);
|
|
308878
309036
|
}
|
|
308879
|
-
|
|
309037
|
+
log116.warn("Database not ready, retrying...", { attempt });
|
|
308880
309038
|
await new Promise((resolve4) => setTimeout(resolve4, 1000));
|
|
308881
309039
|
}
|
|
308882
309040
|
}
|
|
308883
309041
|
}
|
|
308884
309042
|
async function main() {
|
|
308885
|
-
|
|
309043
|
+
log116.info("Starting Omni API v2");
|
|
308886
309044
|
enableDefaultMetrics();
|
|
308887
309045
|
const pgserveConfig = resolvePgserveConfig();
|
|
308888
309046
|
const databaseUrl = await startEmbeddedPgserve(pgserveConfig);
|
|
308889
|
-
|
|
309047
|
+
log116.info("Connecting to database");
|
|
308890
309048
|
const db3 = createDb({ url: databaseUrl });
|
|
308891
309049
|
globalDbRef = db3;
|
|
308892
309050
|
const earlyShutdown = async () => {
|
|
308893
|
-
|
|
309051
|
+
log116.info("Shutdown during startup \u2014 cleaning up");
|
|
308894
309052
|
try {
|
|
308895
309053
|
await closeDb();
|
|
308896
309054
|
await stopEmbeddedPgserve();
|
|
308897
309055
|
} catch (err) {
|
|
308898
|
-
|
|
309056
|
+
log116.error("Cleanup failed during early shutdown", { error: String(err) });
|
|
308899
309057
|
} finally {
|
|
308900
309058
|
process.exit(1);
|
|
308901
309059
|
}
|
|
@@ -308909,7 +309067,7 @@ async function main() {
|
|
|
308909
309067
|
await stopEmbeddedPgserve();
|
|
308910
309068
|
throw error2;
|
|
308911
309069
|
}
|
|
308912
|
-
|
|
309070
|
+
log116.info("Running database migrations");
|
|
308913
309071
|
const migrationStart = Date.now();
|
|
308914
309072
|
const MIGRATION_TIMEOUT_MS = 60000;
|
|
308915
309073
|
try {
|
|
@@ -308922,17 +309080,17 @@ async function main() {
|
|
|
308922
309080
|
await stopEmbeddedPgserve();
|
|
308923
309081
|
throw error2;
|
|
308924
309082
|
}
|
|
308925
|
-
|
|
309083
|
+
log116.info("Database migrations complete", { durationMs: Date.now() - migrationStart });
|
|
308926
309084
|
try {
|
|
308927
309085
|
const driftReport = await verifyCriticalColumns(db3, API_CRITICAL_COLUMNS);
|
|
308928
309086
|
if (!driftReport.ok) {
|
|
308929
|
-
|
|
309087
|
+
log116.error(formatDriftReport(driftReport), { drift: driftReport.drift });
|
|
308930
309088
|
await closeDb();
|
|
308931
309089
|
await stopEmbeddedPgserve();
|
|
308932
309090
|
process.exit(1);
|
|
308933
309091
|
}
|
|
308934
309092
|
} catch (error2) {
|
|
308935
|
-
|
|
309093
|
+
log116.error("Schema drift check failed", { error: String(error2) });
|
|
308936
309094
|
await closeDb();
|
|
308937
309095
|
await stopEmbeddedPgserve();
|
|
308938
309096
|
process.exit(1);
|
|
@@ -308940,12 +309098,12 @@ async function main() {
|
|
|
308940
309098
|
try {
|
|
308941
309099
|
const [countRow] = await db3.select({ count: sql`count(*)::int` }).from(instances);
|
|
308942
309100
|
const rowCount = countRow?.count ?? 0;
|
|
308943
|
-
|
|
309101
|
+
log116.info("Post-migration content snapshot", { DB_ROW_COUNT_INSTANCES: rowCount });
|
|
308944
309102
|
if (rowCount === 0 && pgserveConfig.requireExisting) {
|
|
308945
|
-
|
|
309103
|
+
log116.error("PGSERVE_REQUIRE_EXISTING=true but instances table is empty after boot \u2014 verify PGSERVE_DATA points at the correct cluster (see #412).");
|
|
308946
309104
|
}
|
|
308947
309105
|
} catch (error2) {
|
|
308948
|
-
|
|
309106
|
+
log116.warn("Failed to read instances row count (non-fatal)", { error: String(error2) });
|
|
308949
309107
|
}
|
|
308950
309108
|
const eventBus = await connectToNats(db3);
|
|
308951
309109
|
if (eventBus) {
|
|
@@ -308963,9 +309121,9 @@ async function main() {
|
|
|
308963
309121
|
try {
|
|
308964
309122
|
await services.settings.seedDefaults();
|
|
308965
309123
|
} catch (error2) {
|
|
308966
|
-
|
|
309124
|
+
log116.error("Failed to seed default settings", { error: String(error2) });
|
|
308967
309125
|
}
|
|
308968
|
-
|
|
309126
|
+
log116.info("Initializing API key");
|
|
308969
309127
|
let apiKeyInfo;
|
|
308970
309128
|
try {
|
|
308971
309129
|
const keyResult = await services.apiKeys.initializePrimaryKey();
|
|
@@ -308975,17 +309133,17 @@ async function main() {
|
|
|
308975
309133
|
isFromEnv: keyResult.isFromEnv
|
|
308976
309134
|
};
|
|
308977
309135
|
if (keyResult.isNew) {
|
|
308978
|
-
|
|
309136
|
+
log116.info("Generated new primary API key");
|
|
308979
309137
|
} else if (keyResult.isFromEnv) {
|
|
308980
|
-
|
|
309138
|
+
log116.info("Using primary API key from environment");
|
|
308981
309139
|
} else {
|
|
308982
|
-
|
|
309140
|
+
log116.info("Using existing primary API key");
|
|
308983
309141
|
}
|
|
308984
309142
|
} catch (error2) {
|
|
308985
|
-
|
|
309143
|
+
log116.error("Failed to initialize primary API key", { error: String(error2) });
|
|
308986
309144
|
}
|
|
308987
309145
|
await setupEventBusServices(eventBus, services, db3);
|
|
308988
|
-
|
|
309146
|
+
log116.info("Starting scheduler");
|
|
308989
309147
|
setupScheduler(services, globalChannelRegistry);
|
|
308990
309148
|
const server = startBunServer(app);
|
|
308991
309149
|
printStartupBanner({
|
|
@@ -308999,7 +309157,7 @@ async function main() {
|
|
|
308999
309157
|
});
|
|
309000
309158
|
setupShutdownHandlers(server, earlyShutdown);
|
|
309001
309159
|
}
|
|
309002
|
-
var import__package3,
|
|
309160
|
+
var import__package3, log116, natsLog, pluginLog, shutdownLog, PORT, HOST, NATS_URL, voiceStreamRegistry, globalEventBus = null, globalChannelRegistry = null, globalInstanceMonitor = null, globalDispatcherCleanup = null, globalTurnMonitor = null, globalDbRef = null, UUID_RE3;
|
|
309003
309161
|
var init_src8 = __esm(() => {
|
|
309004
309162
|
init_instrument2();
|
|
309005
309163
|
init_src2();
|
|
@@ -309012,6 +309170,7 @@ var init_src8 = __esm(() => {
|
|
|
309012
309170
|
init_plugins2();
|
|
309013
309171
|
init_loader2();
|
|
309014
309172
|
init_scheduler2();
|
|
309173
|
+
init_agent_heartbeat();
|
|
309015
309174
|
init_api_keys();
|
|
309016
309175
|
init_turn_events();
|
|
309017
309176
|
init_turn_monitor();
|
|
@@ -309024,7 +309183,7 @@ var init_src8 = __esm(() => {
|
|
|
309024
309183
|
level: process.env.LOG_LEVEL ?? "info",
|
|
309025
309184
|
format: process.env.LOG_FORMAT ?? "auto"
|
|
309026
309185
|
});
|
|
309027
|
-
|
|
309186
|
+
log116 = createLogger("api:startup");
|
|
309028
309187
|
natsLog = createLogger("api:nats");
|
|
309029
309188
|
pluginLog = createLogger("api:plugins");
|
|
309030
309189
|
shutdownLog = createLogger("api:shutdown");
|
|
@@ -309034,7 +309193,7 @@ var init_src8 = __esm(() => {
|
|
|
309034
309193
|
voiceStreamRegistry = new VoiceStreamRegistry;
|
|
309035
309194
|
UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
309036
309195
|
main().catch((error2) => {
|
|
309037
|
-
|
|
309196
|
+
log116.error("Failed to start API server", { error: String(error2) });
|
|
309038
309197
|
process.exit(1);
|
|
309039
309198
|
});
|
|
309040
309199
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automagik/omni",
|
|
3
|
-
"version": "2.260501.
|
|
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.
|
|
55
|
-
"@omni/channel-discord": "2.260501.
|
|
56
|
-
"@omni/channel-gupshup": "2.260501.
|
|
57
|
-
"@omni/channel-sdk": "2.260501.
|
|
58
|
-
"@omni/channel-slack": "2.260501.
|
|
59
|
-
"@omni/channel-telegram": "2.260501.
|
|
60
|
-
"@omni/channel-whatsapp": "2.260501.
|
|
61
|
-
"@omni/core": "2.260501.
|
|
62
|
-
"@omni/sdk": "2.260501.
|
|
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"
|