@automagik/omni 2.260520.15 → 2.260520.17
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,KAAK,MAAM,EACX,KAAK,YAAY,EAKlB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,6BAA6B,CAAC;AAcrC,8CAA8C;AAC9C,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhD,kDAAkD;AAClD,MAAM,MAAM,OAAO,GACf,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,eAAe,GACf,YAAY,GACZ,kBAAkB,GAClB,yBAAyB,GACzB,sCAAsC,GACtC,mBAAmB,GACnB,sBAAsB,GACtB,wBAAwB,CAAC;AAE7B,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAA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AO,CAAC;IAChC;;;;OAIG;IACH,qBAAqB,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACpD;;;;;OAKG;IACH,cAAc,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC5E;;;;OAIG;IACH,0BAA0B,EAAE,CAC1B,IAAI,EAAE,kBAAkB,EACxB,oBAAoB,EAAE,MAAM,KACzB,OAAO,CAAC;QAAE,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxE,6EAA6E;IAC7E,0BAA0B,EAAE,MAAM,MAAM,CAAC;IACzC;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAC3D;;;;;OAKG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACxD;;;;;OAKG;IACH,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,KAAK,OAAO,CAAC;CACtE;AAujCD;;;GAGG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAiBxG;AA2BD,wBAAgB,mBAAmB,IAAI,OAAO,CAiD7C"}
|
package/dist/index.js
CHANGED
|
@@ -4660,6 +4660,277 @@ var require_cli_spinners = __commonJS((exports, module) => {
|
|
|
4660
4660
|
module.exports = spinners;
|
|
4661
4661
|
});
|
|
4662
4662
|
|
|
4663
|
+
// src/lib/embedded-canonical-migration.ts
|
|
4664
|
+
var exports_embedded_canonical_migration = {};
|
|
4665
|
+
__export(exports_embedded_canonical_migration, {
|
|
4666
|
+
migrateUnmountedEmbeddedToCanonical: () => migrateUnmountedEmbeddedToCanonical,
|
|
4667
|
+
compareEmbeddedVsCanonicalCounts: () => compareEmbeddedVsCanonicalCounts,
|
|
4668
|
+
EMBEDDED_PGSERVE_DATA_DIR: () => EMBEDDED_PGSERVE_DATA_DIR
|
|
4669
|
+
});
|
|
4670
|
+
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
4671
|
+
import { existsSync as existsSync9, mkdtempSync } from "fs";
|
|
4672
|
+
import { createServer } from "net";
|
|
4673
|
+
import { homedir as homedir7, tmpdir } from "os";
|
|
4674
|
+
import { join as join11 } from "path";
|
|
4675
|
+
import { setTimeout as sleep2 } from "timers/promises";
|
|
4676
|
+
function defaultLog(line) {
|
|
4677
|
+
process.stdout.write(`${line}
|
|
4678
|
+
`);
|
|
4679
|
+
}
|
|
4680
|
+
function findAutopgPostgresBinary() {
|
|
4681
|
+
const autopgRoot = join11(homedir7(), ".local", "share", "autopg");
|
|
4682
|
+
if (!existsSync9(autopgRoot))
|
|
4683
|
+
return null;
|
|
4684
|
+
let bestPath = null;
|
|
4685
|
+
for (const entry of safeReaddir(autopgRoot)) {
|
|
4686
|
+
const candidate = join11(autopgRoot, entry, "postgres", "bin", "postgres");
|
|
4687
|
+
if (existsSync9(candidate))
|
|
4688
|
+
bestPath = candidate;
|
|
4689
|
+
}
|
|
4690
|
+
return bestPath;
|
|
4691
|
+
}
|
|
4692
|
+
function safeReaddir(path) {
|
|
4693
|
+
try {
|
|
4694
|
+
const { readdirSync: readdirSync2 } = __require("fs");
|
|
4695
|
+
return readdirSync2(path);
|
|
4696
|
+
} catch {
|
|
4697
|
+
return [];
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
async function findFreePort() {
|
|
4701
|
+
return new Promise((resolve, reject) => {
|
|
4702
|
+
const server = createServer();
|
|
4703
|
+
server.unref();
|
|
4704
|
+
server.on("error", reject);
|
|
4705
|
+
server.listen(0, "127.0.0.1", () => {
|
|
4706
|
+
const addr = server.address();
|
|
4707
|
+
if (!addr || typeof addr === "string") {
|
|
4708
|
+
server.close();
|
|
4709
|
+
reject(new Error("failed to discover free port"));
|
|
4710
|
+
return;
|
|
4711
|
+
}
|
|
4712
|
+
const port = addr.port;
|
|
4713
|
+
server.close(() => resolve(port));
|
|
4714
|
+
});
|
|
4715
|
+
});
|
|
4716
|
+
}
|
|
4717
|
+
async function spawnTempPostmaster(binary, dataDir, port, log) {
|
|
4718
|
+
const socketDir = mkdtempSync(join11(tmpdir(), "omni-migrate-pg-"));
|
|
4719
|
+
log(` spawning temp postmaster: pid=\u2026 port=${port} socket=${socketDir}`);
|
|
4720
|
+
const child = spawn(binary, [
|
|
4721
|
+
"-D",
|
|
4722
|
+
dataDir,
|
|
4723
|
+
"-p",
|
|
4724
|
+
String(port),
|
|
4725
|
+
"-c",
|
|
4726
|
+
"listen_addresses=127.0.0.1",
|
|
4727
|
+
"-c",
|
|
4728
|
+
`unix_socket_directories=${socketDir}`
|
|
4729
|
+
], {
|
|
4730
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
4731
|
+
detached: false
|
|
4732
|
+
});
|
|
4733
|
+
let started = false;
|
|
4734
|
+
let crashed = null;
|
|
4735
|
+
child.stderr?.on("data", (chunk) => {
|
|
4736
|
+
const line = chunk.toString("utf-8");
|
|
4737
|
+
if (!started && /database system is ready to accept connections/.test(line))
|
|
4738
|
+
started = true;
|
|
4739
|
+
});
|
|
4740
|
+
child.on("exit", (code) => {
|
|
4741
|
+
if (!started) {
|
|
4742
|
+
crashed = new Error(`temp postmaster exited with code ${code} before ready`);
|
|
4743
|
+
}
|
|
4744
|
+
});
|
|
4745
|
+
for (let i = 0;i < 200; i++) {
|
|
4746
|
+
if (started)
|
|
4747
|
+
break;
|
|
4748
|
+
if (crashed)
|
|
4749
|
+
throw crashed;
|
|
4750
|
+
await sleep2(100);
|
|
4751
|
+
}
|
|
4752
|
+
if (!started) {
|
|
4753
|
+
child.kill("SIGTERM");
|
|
4754
|
+
throw new Error("temp postmaster failed to become ready within 20s");
|
|
4755
|
+
}
|
|
4756
|
+
log(` temp postmaster ready (pid=${child.pid})`);
|
|
4757
|
+
return {
|
|
4758
|
+
pid: child.pid ?? -1,
|
|
4759
|
+
socketDir,
|
|
4760
|
+
async stop() {
|
|
4761
|
+
log(" stopping temp postmaster (SIGTERM)");
|
|
4762
|
+
child.kill("SIGTERM");
|
|
4763
|
+
await new Promise((resolve) => {
|
|
4764
|
+
const onExit2 = () => resolve();
|
|
4765
|
+
child.once("exit", onExit2);
|
|
4766
|
+
setTimeout(() => {
|
|
4767
|
+
child.kill("SIGKILL");
|
|
4768
|
+
onExit2();
|
|
4769
|
+
}, 1e4);
|
|
4770
|
+
});
|
|
4771
|
+
}
|
|
4772
|
+
};
|
|
4773
|
+
}
|
|
4774
|
+
function psqlCapture(args) {
|
|
4775
|
+
const result = spawnSync2("psql", args, {
|
|
4776
|
+
encoding: "utf-8",
|
|
4777
|
+
env: { ...process.env, PGPASSWORD: "postgres" },
|
|
4778
|
+
timeout: 60000
|
|
4779
|
+
});
|
|
4780
|
+
if (result.status !== 0) {
|
|
4781
|
+
throw new Error(`psql exited ${result.status}: ${result.stderr?.trim() ?? ""}`);
|
|
4782
|
+
}
|
|
4783
|
+
return result.stdout ?? "";
|
|
4784
|
+
}
|
|
4785
|
+
async function copyTable(table, srcArgs, dstArgs, log) {
|
|
4786
|
+
const src = spawn("psql", [...srcArgs, "-c", `\\copy public.${table} TO STDOUT`], {
|
|
4787
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
4788
|
+
env: { ...process.env, PGPASSWORD: "postgres" }
|
|
4789
|
+
});
|
|
4790
|
+
const dst = spawn("psql", [...dstArgs, "-c", `SET session_replication_role='replica';`, "-c", `\\copy public.${table} FROM STDIN`], {
|
|
4791
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
4792
|
+
env: { ...process.env, PGPASSWORD: "postgres" }
|
|
4793
|
+
});
|
|
4794
|
+
if (!src.stdout || !dst.stdin)
|
|
4795
|
+
throw new Error(`copy stream not available for ${table}`);
|
|
4796
|
+
src.stdout.pipe(dst.stdin);
|
|
4797
|
+
let dstErr = "";
|
|
4798
|
+
dst.stderr?.on("data", (b) => {
|
|
4799
|
+
dstErr += b.toString("utf-8");
|
|
4800
|
+
});
|
|
4801
|
+
const srcExited = new Promise((resolve) => src.once("exit", (code) => resolve(code ?? -1)));
|
|
4802
|
+
const dstExited = new Promise((resolve) => dst.once("exit", (code) => resolve(code ?? -1)));
|
|
4803
|
+
const [sc, dc] = await Promise.all([srcExited, dstExited]);
|
|
4804
|
+
if (sc !== 0 || dc !== 0) {
|
|
4805
|
+
throw new Error(`copy ${table} failed (src=${sc} dst=${dc}): ${dstErr.trim()}`);
|
|
4806
|
+
}
|
|
4807
|
+
log(` copied ${table}`);
|
|
4808
|
+
}
|
|
4809
|
+
function resetSequences(dstArgs, log) {
|
|
4810
|
+
const script = `
|
|
4811
|
+
SELECT format(
|
|
4812
|
+
'SELECT setval(%L::regclass, GREATEST(COALESCE((SELECT max(%I) FROM %I.%I), 1), 1));',
|
|
4813
|
+
pg_get_serial_sequence(c.table_schema || '.' || c.table_name, c.column_name),
|
|
4814
|
+
c.column_name, c.table_schema, c.table_name
|
|
4815
|
+
)
|
|
4816
|
+
FROM information_schema.columns c
|
|
4817
|
+
WHERE pg_get_serial_sequence(c.table_schema || '.' || c.table_name, c.column_name) IS NOT NULL
|
|
4818
|
+
AND c.table_schema = 'public';
|
|
4819
|
+
`.trim();
|
|
4820
|
+
const lines = psqlCapture([...dstArgs, "-tAc", script]).split(`
|
|
4821
|
+
`).map((l) => l.trim()).filter(Boolean);
|
|
4822
|
+
if (lines.length === 0)
|
|
4823
|
+
return;
|
|
4824
|
+
log(` resetting ${lines.length} sequence(s)`);
|
|
4825
|
+
psqlCapture([...dstArgs, "-c", lines.join(`
|
|
4826
|
+
`)]);
|
|
4827
|
+
}
|
|
4828
|
+
async function compareEmbeddedVsCanonicalCounts(opts = {}) {
|
|
4829
|
+
const canonicalPort = opts.canonicalPort ?? 5432;
|
|
4830
|
+
if (!existsSync9(EMBEDDED_DIR) || !existsSync9(join11(EMBEDDED_DIR, "PG_VERSION"))) {
|
|
4831
|
+
return { kind: "skipped", reason: "embedded dir absent" };
|
|
4832
|
+
}
|
|
4833
|
+
const binary = findAutopgPostgresBinary();
|
|
4834
|
+
if (!binary)
|
|
4835
|
+
return { kind: "skipped", reason: "autopg postgres binary not found" };
|
|
4836
|
+
const tempPort = await findFreePort();
|
|
4837
|
+
let temp = null;
|
|
4838
|
+
try {
|
|
4839
|
+
temp = await spawnTempPostmaster(binary, EMBEDDED_DIR, tempPort, () => {});
|
|
4840
|
+
const srcArgs = ["-h", "127.0.0.1", "-p", String(tempPort), "-U", "postgres", "-d", "omni"];
|
|
4841
|
+
const dstArgs = ["-h", "127.0.0.1", "-p", String(canonicalPort), "-U", "postgres", "-d", "omni"];
|
|
4842
|
+
const tablesRaw = psqlCapture([
|
|
4843
|
+
...srcArgs,
|
|
4844
|
+
"-tAc",
|
|
4845
|
+
`SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename`
|
|
4846
|
+
]);
|
|
4847
|
+
const tables = tablesRaw.split(`
|
|
4848
|
+
`).map((s) => s.trim()).filter(Boolean);
|
|
4849
|
+
if (tables.length === 0)
|
|
4850
|
+
return { kind: "skipped", reason: "embedded has no public tables" };
|
|
4851
|
+
const divergent = [];
|
|
4852
|
+
let totalExtra = 0;
|
|
4853
|
+
for (const t of tables) {
|
|
4854
|
+
try {
|
|
4855
|
+
const em = Number.parseInt(psqlCapture([...srcArgs, "-tAc", `SELECT count(*) FROM public.${t}`]).trim(), 10);
|
|
4856
|
+
const ca = Number.parseInt(psqlCapture([...dstArgs, "-tAc", `SELECT count(*) FROM public.${t}`]).trim(), 10);
|
|
4857
|
+
if (Number.isFinite(em) && Number.isFinite(ca) && em > ca) {
|
|
4858
|
+
divergent.push(t);
|
|
4859
|
+
totalExtra += em - ca;
|
|
4860
|
+
}
|
|
4861
|
+
} catch {
|
|
4862
|
+
divergent.push(t);
|
|
4863
|
+
}
|
|
4864
|
+
}
|
|
4865
|
+
if (divergent.length === 0)
|
|
4866
|
+
return { kind: "in-sync" };
|
|
4867
|
+
return { kind: "embedded-has-more", divergentTables: divergent, embeddedRows: totalExtra };
|
|
4868
|
+
} catch (err) {
|
|
4869
|
+
return { kind: "skipped", reason: err instanceof Error ? err.message : String(err) };
|
|
4870
|
+
} finally {
|
|
4871
|
+
if (temp)
|
|
4872
|
+
await temp.stop();
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
async function migrateUnmountedEmbeddedToCanonical(opts = {}) {
|
|
4876
|
+
const log = opts.log ?? defaultLog;
|
|
4877
|
+
const canonicalPort = opts.canonicalPort ?? 5432;
|
|
4878
|
+
if (!existsSync9(EMBEDDED_DIR)) {
|
|
4879
|
+
return { status: "skipped", reason: "no embedded data dir" };
|
|
4880
|
+
}
|
|
4881
|
+
if (!existsSync9(join11(EMBEDDED_DIR, "PG_VERSION"))) {
|
|
4882
|
+
return { status: "skipped", reason: "embedded dir missing PG_VERSION" };
|
|
4883
|
+
}
|
|
4884
|
+
const binary = findAutopgPostgresBinary();
|
|
4885
|
+
if (!binary) {
|
|
4886
|
+
return { status: "skipped", reason: "autopg postgres binary not found \u2014 install autopg first" };
|
|
4887
|
+
}
|
|
4888
|
+
log(` using postgres binary: ${binary}`);
|
|
4889
|
+
log(" stopping omni-api during data copy");
|
|
4890
|
+
spawnSync2("pm2", ["stop", "omni-api"], { stdio: "inherit" });
|
|
4891
|
+
const tempPort = await findFreePort();
|
|
4892
|
+
const t0 = Date.now();
|
|
4893
|
+
const temp = await spawnTempPostmaster(binary, EMBEDDED_DIR, tempPort, log);
|
|
4894
|
+
let apiRestarted = false;
|
|
4895
|
+
try {
|
|
4896
|
+
const srcBaseArgs = ["-h", "127.0.0.1", "-p", String(tempPort), "-U", "postgres", "-d", "omni"];
|
|
4897
|
+
const dstBaseArgs = ["-h", "127.0.0.1", "-p", String(canonicalPort), "-U", "postgres", "-d", "omni"];
|
|
4898
|
+
const tablesRaw = psqlCapture([
|
|
4899
|
+
...srcBaseArgs,
|
|
4900
|
+
"-tAc",
|
|
4901
|
+
`SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename`
|
|
4902
|
+
]);
|
|
4903
|
+
const tables = tablesRaw.split(`
|
|
4904
|
+
`).map((s) => s.trim()).filter(Boolean);
|
|
4905
|
+
if (tables.length === 0) {
|
|
4906
|
+
return { status: "skipped", reason: "embedded omni has no public tables" };
|
|
4907
|
+
}
|
|
4908
|
+
log(` ${tables.length} tables to migrate`);
|
|
4909
|
+
const truncateList = tables.map((t) => `public.${t}`).join(",");
|
|
4910
|
+
psqlCapture([
|
|
4911
|
+
...dstBaseArgs,
|
|
4912
|
+
"-c",
|
|
4913
|
+
`SET session_replication_role='replica'; TRUNCATE ${truncateList} RESTART IDENTITY CASCADE;`
|
|
4914
|
+
]);
|
|
4915
|
+
log(" truncated canonical (CASCADE)");
|
|
4916
|
+
for (const t of tables) {
|
|
4917
|
+
await copyTable(t, srcBaseArgs, dstBaseArgs, log);
|
|
4918
|
+
}
|
|
4919
|
+
resetSequences(dstBaseArgs, log);
|
|
4920
|
+
return { status: "migrated", tables: tables.length, durationMs: Date.now() - t0 };
|
|
4921
|
+
} finally {
|
|
4922
|
+
await temp.stop();
|
|
4923
|
+
log(" restarting omni-api");
|
|
4924
|
+
spawnSync2("pm2", ["start", "omni-api"], { stdio: "inherit" });
|
|
4925
|
+
apiRestarted = true;
|
|
4926
|
+
}
|
|
4927
|
+
}
|
|
4928
|
+
var EMBEDDED_DIR, EMBEDDED_PGSERVE_DATA_DIR;
|
|
4929
|
+
var init_embedded_canonical_migration = __esm(() => {
|
|
4930
|
+
EMBEDDED_DIR = join11(homedir7(), ".omni", "data", "pgserve");
|
|
4931
|
+
EMBEDDED_PGSERVE_DATA_DIR = EMBEDDED_DIR;
|
|
4932
|
+
});
|
|
4933
|
+
|
|
4663
4934
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js
|
|
4664
4935
|
var require_QRMode = __commonJS((exports, module) => {
|
|
4665
4936
|
module.exports = {
|
|
@@ -124067,7 +124338,7 @@ import { fileURLToPath } from "url";
|
|
|
124067
124338
|
// package.json
|
|
124068
124339
|
var package_default = {
|
|
124069
124340
|
name: "@automagik/omni",
|
|
124070
|
-
version: "2.260520.
|
|
124341
|
+
version: "2.260520.17",
|
|
124071
124342
|
description: "LLM-optimized CLI for Omni",
|
|
124072
124343
|
type: "module",
|
|
124073
124344
|
bin: {
|
|
@@ -129286,216 +129557,8 @@ function formatBytes(n) {
|
|
|
129286
129557
|
return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`;
|
|
129287
129558
|
}
|
|
129288
129559
|
|
|
129289
|
-
// src/lib/embedded-canonical-migration.ts
|
|
129290
|
-
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
129291
|
-
import { existsSync as existsSync9, mkdtempSync } from "fs";
|
|
129292
|
-
import { createServer } from "net";
|
|
129293
|
-
import { homedir as homedir7, tmpdir } from "os";
|
|
129294
|
-
import { join as join11 } from "path";
|
|
129295
|
-
import { setTimeout as sleep2 } from "timers/promises";
|
|
129296
|
-
var EMBEDDED_DIR = join11(homedir7(), ".omni", "data", "pgserve");
|
|
129297
|
-
function defaultLog(line) {
|
|
129298
|
-
process.stdout.write(`${line}
|
|
129299
|
-
`);
|
|
129300
|
-
}
|
|
129301
|
-
function findAutopgPostgresBinary() {
|
|
129302
|
-
const autopgRoot = join11(homedir7(), ".local", "share", "autopg");
|
|
129303
|
-
if (!existsSync9(autopgRoot))
|
|
129304
|
-
return null;
|
|
129305
|
-
let bestPath = null;
|
|
129306
|
-
for (const entry of safeReaddir(autopgRoot)) {
|
|
129307
|
-
const candidate = join11(autopgRoot, entry, "postgres", "bin", "postgres");
|
|
129308
|
-
if (existsSync9(candidate))
|
|
129309
|
-
bestPath = candidate;
|
|
129310
|
-
}
|
|
129311
|
-
return bestPath;
|
|
129312
|
-
}
|
|
129313
|
-
function safeReaddir(path) {
|
|
129314
|
-
try {
|
|
129315
|
-
const { readdirSync: readdirSync2 } = __require("fs");
|
|
129316
|
-
return readdirSync2(path);
|
|
129317
|
-
} catch {
|
|
129318
|
-
return [];
|
|
129319
|
-
}
|
|
129320
|
-
}
|
|
129321
|
-
async function findFreePort() {
|
|
129322
|
-
return new Promise((resolve, reject) => {
|
|
129323
|
-
const server = createServer();
|
|
129324
|
-
server.unref();
|
|
129325
|
-
server.on("error", reject);
|
|
129326
|
-
server.listen(0, "127.0.0.1", () => {
|
|
129327
|
-
const addr = server.address();
|
|
129328
|
-
if (!addr || typeof addr === "string") {
|
|
129329
|
-
server.close();
|
|
129330
|
-
reject(new Error("failed to discover free port"));
|
|
129331
|
-
return;
|
|
129332
|
-
}
|
|
129333
|
-
const port = addr.port;
|
|
129334
|
-
server.close(() => resolve(port));
|
|
129335
|
-
});
|
|
129336
|
-
});
|
|
129337
|
-
}
|
|
129338
|
-
async function spawnTempPostmaster(binary, dataDir, port, log) {
|
|
129339
|
-
const socketDir = mkdtempSync(join11(tmpdir(), "omni-migrate-pg-"));
|
|
129340
|
-
log(` spawning temp postmaster: pid=\u2026 port=${port} socket=${socketDir}`);
|
|
129341
|
-
const child = spawn(binary, [
|
|
129342
|
-
"-D",
|
|
129343
|
-
dataDir,
|
|
129344
|
-
"-p",
|
|
129345
|
-
String(port),
|
|
129346
|
-
"-c",
|
|
129347
|
-
"listen_addresses=127.0.0.1",
|
|
129348
|
-
"-c",
|
|
129349
|
-
`unix_socket_directories=${socketDir}`
|
|
129350
|
-
], {
|
|
129351
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
129352
|
-
detached: false
|
|
129353
|
-
});
|
|
129354
|
-
let started = false;
|
|
129355
|
-
let crashed = null;
|
|
129356
|
-
child.stderr?.on("data", (chunk) => {
|
|
129357
|
-
const line = chunk.toString("utf-8");
|
|
129358
|
-
if (!started && /database system is ready to accept connections/.test(line))
|
|
129359
|
-
started = true;
|
|
129360
|
-
});
|
|
129361
|
-
child.on("exit", (code) => {
|
|
129362
|
-
if (!started) {
|
|
129363
|
-
crashed = new Error(`temp postmaster exited with code ${code} before ready`);
|
|
129364
|
-
}
|
|
129365
|
-
});
|
|
129366
|
-
for (let i = 0;i < 200; i++) {
|
|
129367
|
-
if (started)
|
|
129368
|
-
break;
|
|
129369
|
-
if (crashed)
|
|
129370
|
-
throw crashed;
|
|
129371
|
-
await sleep2(100);
|
|
129372
|
-
}
|
|
129373
|
-
if (!started) {
|
|
129374
|
-
child.kill("SIGTERM");
|
|
129375
|
-
throw new Error("temp postmaster failed to become ready within 20s");
|
|
129376
|
-
}
|
|
129377
|
-
log(` temp postmaster ready (pid=${child.pid})`);
|
|
129378
|
-
return {
|
|
129379
|
-
pid: child.pid ?? -1,
|
|
129380
|
-
socketDir,
|
|
129381
|
-
async stop() {
|
|
129382
|
-
log(" stopping temp postmaster (SIGTERM)");
|
|
129383
|
-
child.kill("SIGTERM");
|
|
129384
|
-
await new Promise((resolve) => {
|
|
129385
|
-
const onExit2 = () => resolve();
|
|
129386
|
-
child.once("exit", onExit2);
|
|
129387
|
-
setTimeout(() => {
|
|
129388
|
-
child.kill("SIGKILL");
|
|
129389
|
-
onExit2();
|
|
129390
|
-
}, 1e4);
|
|
129391
|
-
});
|
|
129392
|
-
}
|
|
129393
|
-
};
|
|
129394
|
-
}
|
|
129395
|
-
function psqlCapture(args) {
|
|
129396
|
-
const result = spawnSync2("psql", args, {
|
|
129397
|
-
encoding: "utf-8",
|
|
129398
|
-
env: { ...process.env, PGPASSWORD: "postgres" },
|
|
129399
|
-
timeout: 60000
|
|
129400
|
-
});
|
|
129401
|
-
if (result.status !== 0) {
|
|
129402
|
-
throw new Error(`psql exited ${result.status}: ${result.stderr?.trim() ?? ""}`);
|
|
129403
|
-
}
|
|
129404
|
-
return result.stdout ?? "";
|
|
129405
|
-
}
|
|
129406
|
-
async function copyTable(table, srcArgs, dstArgs, log) {
|
|
129407
|
-
const src = spawn("psql", [...srcArgs, "-c", `\\copy public.${table} TO STDOUT`], {
|
|
129408
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
129409
|
-
env: { ...process.env, PGPASSWORD: "postgres" }
|
|
129410
|
-
});
|
|
129411
|
-
const dst = spawn("psql", [...dstArgs, "-c", `SET session_replication_role='replica';`, "-c", `\\copy public.${table} FROM STDIN`], {
|
|
129412
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
129413
|
-
env: { ...process.env, PGPASSWORD: "postgres" }
|
|
129414
|
-
});
|
|
129415
|
-
if (!src.stdout || !dst.stdin)
|
|
129416
|
-
throw new Error(`copy stream not available for ${table}`);
|
|
129417
|
-
src.stdout.pipe(dst.stdin);
|
|
129418
|
-
let dstErr = "";
|
|
129419
|
-
dst.stderr?.on("data", (b) => {
|
|
129420
|
-
dstErr += b.toString("utf-8");
|
|
129421
|
-
});
|
|
129422
|
-
const srcExited = new Promise((resolve) => src.once("exit", (code) => resolve(code ?? -1)));
|
|
129423
|
-
const dstExited = new Promise((resolve) => dst.once("exit", (code) => resolve(code ?? -1)));
|
|
129424
|
-
const [sc, dc] = await Promise.all([srcExited, dstExited]);
|
|
129425
|
-
if (sc !== 0 || dc !== 0) {
|
|
129426
|
-
throw new Error(`copy ${table} failed (src=${sc} dst=${dc}): ${dstErr.trim()}`);
|
|
129427
|
-
}
|
|
129428
|
-
log(` copied ${table}`);
|
|
129429
|
-
}
|
|
129430
|
-
function resetSequences(dstArgs, log) {
|
|
129431
|
-
const script = `
|
|
129432
|
-
SELECT format(
|
|
129433
|
-
'SELECT setval(%L::regclass, GREATEST(COALESCE((SELECT max(%I) FROM %I.%I), 1), 1));',
|
|
129434
|
-
pg_get_serial_sequence(c.table_schema || '.' || c.table_name, c.column_name),
|
|
129435
|
-
c.column_name, c.table_schema, c.table_name
|
|
129436
|
-
)
|
|
129437
|
-
FROM information_schema.columns c
|
|
129438
|
-
WHERE pg_get_serial_sequence(c.table_schema || '.' || c.table_name, c.column_name) IS NOT NULL
|
|
129439
|
-
AND c.table_schema = 'public';
|
|
129440
|
-
`.trim();
|
|
129441
|
-
const lines = psqlCapture([...dstArgs, "-tAc", script]).split(`
|
|
129442
|
-
`).map((l) => l.trim()).filter(Boolean);
|
|
129443
|
-
if (lines.length === 0)
|
|
129444
|
-
return;
|
|
129445
|
-
log(` resetting ${lines.length} sequence(s)`);
|
|
129446
|
-
psqlCapture([...dstArgs, "-c", lines.join(`
|
|
129447
|
-
`)]);
|
|
129448
|
-
}
|
|
129449
|
-
async function migrateUnmountedEmbeddedToCanonical(opts = {}) {
|
|
129450
|
-
const log = opts.log ?? defaultLog;
|
|
129451
|
-
const canonicalPort = opts.canonicalPort ?? 5432;
|
|
129452
|
-
if (!existsSync9(EMBEDDED_DIR)) {
|
|
129453
|
-
return { status: "skipped", reason: "no embedded data dir" };
|
|
129454
|
-
}
|
|
129455
|
-
if (!existsSync9(join11(EMBEDDED_DIR, "PG_VERSION"))) {
|
|
129456
|
-
return { status: "skipped", reason: "embedded dir missing PG_VERSION" };
|
|
129457
|
-
}
|
|
129458
|
-
const binary = findAutopgPostgresBinary();
|
|
129459
|
-
if (!binary) {
|
|
129460
|
-
return { status: "skipped", reason: "autopg postgres binary not found \u2014 install autopg first" };
|
|
129461
|
-
}
|
|
129462
|
-
log(` using postgres binary: ${binary}`);
|
|
129463
|
-
const tempPort = await findFreePort();
|
|
129464
|
-
const t0 = Date.now();
|
|
129465
|
-
const temp = await spawnTempPostmaster(binary, EMBEDDED_DIR, tempPort, log);
|
|
129466
|
-
try {
|
|
129467
|
-
const srcBaseArgs = ["-h", "127.0.0.1", "-p", String(tempPort), "-U", "postgres", "-d", "omni"];
|
|
129468
|
-
const dstBaseArgs = ["-h", "127.0.0.1", "-p", String(canonicalPort), "-U", "postgres", "-d", "omni"];
|
|
129469
|
-
const tablesRaw = psqlCapture([
|
|
129470
|
-
...srcBaseArgs,
|
|
129471
|
-
"-tAc",
|
|
129472
|
-
`SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename`
|
|
129473
|
-
]);
|
|
129474
|
-
const tables = tablesRaw.split(`
|
|
129475
|
-
`).map((s) => s.trim()).filter(Boolean);
|
|
129476
|
-
if (tables.length === 0) {
|
|
129477
|
-
return { status: "skipped", reason: "embedded omni has no public tables" };
|
|
129478
|
-
}
|
|
129479
|
-
log(` ${tables.length} tables to migrate`);
|
|
129480
|
-
const truncateList = tables.map((t) => `public.${t}`).join(",");
|
|
129481
|
-
psqlCapture([
|
|
129482
|
-
...dstBaseArgs,
|
|
129483
|
-
"-c",
|
|
129484
|
-
`SET session_replication_role='replica'; TRUNCATE ${truncateList} RESTART IDENTITY CASCADE;`
|
|
129485
|
-
]);
|
|
129486
|
-
log(" truncated canonical (CASCADE)");
|
|
129487
|
-
for (const t of tables) {
|
|
129488
|
-
await copyTable(t, srcBaseArgs, dstBaseArgs, log);
|
|
129489
|
-
}
|
|
129490
|
-
resetSequences(dstBaseArgs, log);
|
|
129491
|
-
return { status: "migrated", tables: tables.length, durationMs: Date.now() - t0 };
|
|
129492
|
-
} finally {
|
|
129493
|
-
await temp.stop();
|
|
129494
|
-
}
|
|
129495
|
-
}
|
|
129496
|
-
var EMBEDDED_PGSERVE_DATA_DIR = EMBEDDED_DIR;
|
|
129497
|
-
|
|
129498
129560
|
// src/commands/doctor.ts
|
|
129561
|
+
init_embedded_canonical_migration();
|
|
129499
129562
|
init_output();
|
|
129500
129563
|
|
|
129501
129564
|
// src/server-bundle.ts
|
|
@@ -129778,25 +129841,30 @@ async function checkEmbeddedDataOrphaned(deps) {
|
|
|
129778
129841
|
};
|
|
129779
129842
|
}
|
|
129780
129843
|
try {
|
|
129781
|
-
const
|
|
129782
|
-
|
|
129783
|
-
|
|
129784
|
-
|
|
129785
|
-
const
|
|
129786
|
-
|
|
129844
|
+
const { existsSync: fsExists } = await import("fs");
|
|
129845
|
+
if (!fsExists(EMBEDDED_PGSERVE_DATA_DIR)) {
|
|
129846
|
+
return { id: "embedded-data-orphaned", level: "OK", detail: "no embedded data to compare" };
|
|
129847
|
+
}
|
|
129848
|
+
const { compareEmbeddedVsCanonicalCounts: compareEmbeddedVsCanonicalCounts2 } = await Promise.resolve().then(() => (init_embedded_canonical_migration(), exports_embedded_canonical_migration));
|
|
129849
|
+
const cmp = await compareEmbeddedVsCanonicalCounts2({ canonicalPort: 5432 });
|
|
129850
|
+
if (cmp.kind === "embedded-has-more") {
|
|
129787
129851
|
return {
|
|
129788
129852
|
id: "embedded-data-orphaned",
|
|
129789
129853
|
level: "FAIL",
|
|
129790
|
-
detail: `embedded
|
|
129854
|
+
detail: `embedded has ${cmp.embeddedRows} rows in ${cmp.divergentTables.length} tables canonical lacks (${cmp.divergentTables.slice(0, 3).join(", ")}${cmp.divergentTables.length > 3 ? "\u2026" : ""}) \u2014 run \`omni doctor --fix\` to migrate`
|
|
129791
129855
|
};
|
|
129792
129856
|
}
|
|
129793
129857
|
return {
|
|
129794
129858
|
id: "embedded-data-orphaned",
|
|
129795
129859
|
level: "OK",
|
|
129796
|
-
detail:
|
|
129860
|
+
detail: cmp.kind === "in-sync" ? "embedded \u2194 canonical row counts match" : `compare unavailable: ${cmp.reason}`
|
|
129861
|
+
};
|
|
129862
|
+
} catch (err) {
|
|
129863
|
+
return {
|
|
129864
|
+
id: "embedded-data-orphaned",
|
|
129865
|
+
level: "OK",
|
|
129866
|
+
detail: `compare unavailable: ${err instanceof Error ? err.message : String(err)}`
|
|
129797
129867
|
};
|
|
129798
|
-
} catch {
|
|
129799
|
-
return { id: "embedded-data-orphaned", level: "OK", detail: "health endpoint unreachable \u2014 defer" };
|
|
129800
129868
|
}
|
|
129801
129869
|
}
|
|
129802
129870
|
async function fixEmbeddedDataOrphaned(_deps) {
|
|
@@ -70,6 +70,33 @@ export interface MigrateOptions {
|
|
|
70
70
|
* so callers can present an actionable diagnostic without aborting the
|
|
71
71
|
* larger --fix run.
|
|
72
72
|
*/
|
|
73
|
+
/**
|
|
74
|
+
* Result of comparing embedded vs canonical row counts. Used by the
|
|
75
|
+
* doctor `embedded-data-orphaned` check to detect partial migrations
|
|
76
|
+
* (e.g. Baileys re-attach copies instance rows but the bulk historical
|
|
77
|
+
* tables stay empty until the ETL runs).
|
|
78
|
+
*/
|
|
79
|
+
export type CompareResult = {
|
|
80
|
+
kind: 'in-sync';
|
|
81
|
+
} | {
|
|
82
|
+
kind: 'embedded-has-more';
|
|
83
|
+
divergentTables: string[];
|
|
84
|
+
embeddedRows: number;
|
|
85
|
+
} | {
|
|
86
|
+
kind: 'skipped';
|
|
87
|
+
reason: string;
|
|
88
|
+
};
|
|
89
|
+
export interface CompareOptions {
|
|
90
|
+
canonicalPort?: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Count rows in every public table on both the embedded data dir and the
|
|
94
|
+
* canonical postmaster, return which tables have MORE rows on embedded.
|
|
95
|
+
* Boots a temp postmaster against the embedded dir (5s ready window),
|
|
96
|
+
* runs two count queries, shuts it down. Best-effort: any spawn / query
|
|
97
|
+
* failure returns `{ kind: 'skipped' }`.
|
|
98
|
+
*/
|
|
99
|
+
export declare function compareEmbeddedVsCanonicalCounts(opts?: CompareOptions): Promise<CompareResult>;
|
|
73
100
|
export declare function migrateUnmountedEmbeddedToCanonical(opts?: MigrateOptions): Promise<MigrationResult>;
|
|
74
101
|
/** Re-export the constant so callers / tests can probe the same path. */
|
|
75
102
|
export declare const EMBEDDED_PGSERVE_DATA_DIR: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded-canonical-migration.d.ts","sourceRoot":"","sources":["../../src/lib/embedded-canonical-migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAWH,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC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CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAiDxG;AAED,wBAAsB,mCAAmC,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,CA6E7G;AAED,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,QAAe,CAAC"}
|
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.17",
|
|
230141
230141
|
type: "module",
|
|
230142
230142
|
exports: {
|
|
230143
230143
|
".": {
|