@automagik/omni 2.260520.5 → 2.260520.7
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
|
@@ -124067,7 +124067,7 @@ import { fileURLToPath } from "url";
|
|
|
124067
124067
|
// package.json
|
|
124068
124068
|
var package_default = {
|
|
124069
124069
|
name: "@automagik/omni",
|
|
124070
|
-
version: "2.260520.
|
|
124070
|
+
version: "2.260520.7",
|
|
124071
124071
|
description: "LLM-optimized CLI for Omni",
|
|
124072
124072
|
type: "module",
|
|
124073
124073
|
bin: {
|
|
@@ -128831,12 +128831,30 @@ async function ensurePgserveBinary() {
|
|
|
128831
128831
|
}
|
|
128832
128832
|
return false;
|
|
128833
128833
|
}
|
|
128834
|
+
var CANONICAL_PM2_PROCESS_NAMES = ["autopg-server", "pgserve"];
|
|
128835
|
+
async function isCanonicalPgservePm2Online() {
|
|
128836
|
+
try {
|
|
128837
|
+
const proc = Bun.spawn({ cmd: ["pm2", "jlist"], stdout: "pipe", stderr: "pipe" });
|
|
128838
|
+
const text = await new Response(proc.stdout).text();
|
|
128839
|
+
const code = await proc.exited;
|
|
128840
|
+
if (code !== 0)
|
|
128841
|
+
return false;
|
|
128842
|
+
const list2 = JSON.parse(text);
|
|
128843
|
+
return list2.some((p) => typeof p.name === "string" && CANONICAL_PM2_PROCESS_NAMES.includes(p.name) && p.pm2_env?.status === "online");
|
|
128844
|
+
} catch {
|
|
128845
|
+
return false;
|
|
128846
|
+
}
|
|
128847
|
+
}
|
|
128834
128848
|
async function runPgserveInstall() {
|
|
128835
128849
|
const bin = resolvePgserveBinary();
|
|
128836
128850
|
if (!bin) {
|
|
128837
128851
|
warn("Canonical pgserve binary unavailable for install step.");
|
|
128838
128852
|
return false;
|
|
128839
128853
|
}
|
|
128854
|
+
if (await isCanonicalPgservePm2Online()) {
|
|
128855
|
+
raw(` Canonical pgserve already pm2-managed and online \u2014 skipping ${bin} install.`);
|
|
128856
|
+
return true;
|
|
128857
|
+
}
|
|
128840
128858
|
raw(` Registering canonical pgserve under pm2 via \`${bin} install\` (idempotent)...`);
|
|
128841
128859
|
const installCode = await Bun.spawn({ cmd: [bin, "install"], stdout: "inherit", stderr: "inherit" }).exited;
|
|
128842
128860
|
if (installCode !== 0) {
|
|
@@ -128867,6 +128885,37 @@ async function readPgservePort() {
|
|
|
128867
128885
|
function buildOmniDatabaseUrl(port) {
|
|
128868
128886
|
return `postgresql://postgres:postgres@localhost:${port}/${OMNI_DATABASE_NAME}`;
|
|
128869
128887
|
}
|
|
128888
|
+
async function ensureOmniDatabaseExists(port) {
|
|
128889
|
+
const psqlArgs = [
|
|
128890
|
+
"-h",
|
|
128891
|
+
"127.0.0.1",
|
|
128892
|
+
"-p",
|
|
128893
|
+
String(port),
|
|
128894
|
+
"-U",
|
|
128895
|
+
"postgres",
|
|
128896
|
+
"-d",
|
|
128897
|
+
"postgres",
|
|
128898
|
+
"-tAc",
|
|
128899
|
+
`CREATE DATABASE ${OMNI_DATABASE_NAME}`
|
|
128900
|
+
];
|
|
128901
|
+
const proc = Bun.spawn({
|
|
128902
|
+
cmd: ["psql", ...psqlArgs],
|
|
128903
|
+
stdout: "pipe",
|
|
128904
|
+
stderr: "pipe",
|
|
128905
|
+
env: { ...process.env, PGPASSWORD: "postgres" }
|
|
128906
|
+
});
|
|
128907
|
+
const stderr = await new Response(proc.stderr).text();
|
|
128908
|
+
const code = await proc.exited;
|
|
128909
|
+
if (code === 0) {
|
|
128910
|
+
raw(` Created \`${OMNI_DATABASE_NAME}\` database on canonical postmaster.`);
|
|
128911
|
+
return true;
|
|
128912
|
+
}
|
|
128913
|
+
if (stderr.includes("42P04") || stderr.includes("already exists")) {
|
|
128914
|
+
return true;
|
|
128915
|
+
}
|
|
128916
|
+
warn(`Could not ensure \`${OMNI_DATABASE_NAME}\` database exists (psql exit ${code}): ${stderr.trim()}`);
|
|
128917
|
+
return false;
|
|
128918
|
+
}
|
|
128870
128919
|
async function setupCanonicalPgserve() {
|
|
128871
128920
|
if (!await ensurePgserveBinary()) {
|
|
128872
128921
|
warn("Canonical pgserve setup skipped \u2014 staying on embedded mode.");
|
|
@@ -128877,6 +128926,7 @@ async function setupCanonicalPgserve() {
|
|
|
128877
128926
|
const port = await readPgservePort();
|
|
128878
128927
|
if (port === null)
|
|
128879
128928
|
return null;
|
|
128929
|
+
await ensureOmniDatabaseExists(port);
|
|
128880
128930
|
return buildOmniDatabaseUrl(port);
|
|
128881
128931
|
}
|
|
128882
128932
|
async function resolveCanonicalPgservePreference(isReinstall, cfg) {
|
|
@@ -24,10 +24,20 @@
|
|
|
24
24
|
*/
|
|
25
25
|
/**
|
|
26
26
|
* Full canonical pgserve setup: ensure binary → `pgserve install` → read
|
|
27
|
-
* the canonical url. Returns the URL on success,
|
|
27
|
+
* the canonical url → ensure `omni` DB exists. Returns the URL on success,
|
|
28
|
+
* null on any failure.
|
|
28
29
|
*
|
|
29
30
|
* The caller (omni install) writes this URL into serverConfig.databaseUrl
|
|
30
31
|
* so omni-api connects there with `PGSERVE_EMBEDDED=false`.
|
|
32
|
+
*
|
|
33
|
+
* Self-healing contract (post 2026-05-20 dogfood findings):
|
|
34
|
+
* 1. If autopg-server is already pm2-online, skip the EADDRINUSE-prone
|
|
35
|
+
* shell-out (see {@link isCanonicalPgservePm2Online}).
|
|
36
|
+
* 2. ALWAYS refresh the URL from the actual canonical port, never trust
|
|
37
|
+
* the operator's prior databaseUrl after canonical detection.
|
|
38
|
+
* 3. Auto-create the `omni` database (idempotent CREATE DATABASE).
|
|
39
|
+
* autopg v3 doesn't auto-provision DBs like pgserve v2 did, so this
|
|
40
|
+
* step is critical for any operator upgrading from v2 → v3.
|
|
31
41
|
*/
|
|
32
42
|
export declare function setupCanonicalPgserve(): Promise<string | null>;
|
|
33
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical-pgserve.d.ts","sourceRoot":"","sources":["../../src/lib/canonical-pgserve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"canonical-pgserve.d.ts","sourceRoot":"","sources":["../../src/lib/canonical-pgserve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AA4OH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAepE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iCAAiC,CACrD,WAAW,EAAE,OAAO,EACpB,GAAG,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,OAAO,CAAC,CA6BlB;AAwDD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CASnD;AAuCD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,MAAM,EAAE,kBAAkB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,MAAM,EAAE,uBAAuB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6D5F;AAED;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,kBAAkB,EACxB,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC;IAAE,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAoCpE"}
|
package/dist/server/index.js
CHANGED
|
@@ -230137,7 +230137,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
230137
230137
|
var require_package8 = __commonJS((exports, module) => {
|
|
230138
230138
|
module.exports = {
|
|
230139
230139
|
name: "@omni/api",
|
|
230140
|
-
version: "2.260520.
|
|
230140
|
+
version: "2.260520.7",
|
|
230141
230141
|
type: "module",
|
|
230142
230142
|
exports: {
|
|
230143
230143
|
".": {
|