@automagik/omni 2.260520.14 → 2.260520.15
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.
|
@@ -49,7 +49,7 @@ import { type EmbeddedDumpResult } from '../lib/canonical-pgserve.js';
|
|
|
49
49
|
/** Severity levels reported by each check. */
|
|
50
50
|
export type CheckLevel = 'OK' | 'WARN' | 'FAIL';
|
|
51
51
|
/** Identifier used in tests and --json output. */
|
|
52
|
-
export type CheckId = 'pm2-env-drift' | 'cli-key-valid' | 'pgserve-reachable' | 'omni-db-exists' | 'orphaned-data-dirs' | 'version-match' | 'pm2-status' | 'pm2-max-restarts' | 'pm2-logrotate-installed' | 'cli-signing-key-for-locked-instances' | 'pgserve-canonical' | 'port-canonical-owner';
|
|
52
|
+
export type CheckId = 'pm2-env-drift' | 'cli-key-valid' | 'pgserve-reachable' | 'omni-db-exists' | 'orphaned-data-dirs' | 'version-match' | 'pm2-status' | 'pm2-max-restarts' | 'pm2-logrotate-installed' | 'cli-signing-key-for-locked-instances' | 'pgserve-canonical' | 'port-canonical-owner' | 'embedded-data-orphaned';
|
|
53
53
|
export interface CheckResult {
|
|
54
54
|
id: CheckId;
|
|
55
55
|
level: CheckLevel;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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,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;AA0iCD;;;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
|
@@ -13153,10 +13153,10 @@ var require_nkeys = __commonJS((exports) => {
|
|
|
13153
13153
|
return createPair(Prefix.Cluster);
|
|
13154
13154
|
}
|
|
13155
13155
|
exports.createCluster = createCluster;
|
|
13156
|
-
function
|
|
13156
|
+
function createServer2() {
|
|
13157
13157
|
return createPair(Prefix.Server);
|
|
13158
13158
|
}
|
|
13159
|
-
exports.createServer =
|
|
13159
|
+
exports.createServer = createServer2;
|
|
13160
13160
|
function createCurve() {
|
|
13161
13161
|
return createPair(Prefix.Curve);
|
|
13162
13162
|
}
|
|
@@ -22772,7 +22772,7 @@ var require_node_transport = __commonJS((exports) => {
|
|
|
22772
22772
|
var util_1 = require_util();
|
|
22773
22773
|
var tls_1 = __require("tls");
|
|
22774
22774
|
var { resolve: resolve2 } = __require("path");
|
|
22775
|
-
var { readFile, existsSync:
|
|
22775
|
+
var { readFile, existsSync: existsSync13 } = __require("fs");
|
|
22776
22776
|
var dns = __require("dns");
|
|
22777
22777
|
var VERSION2 = "2.29.3";
|
|
22778
22778
|
var LANG = "nats.js";
|
|
@@ -22888,7 +22888,7 @@ var require_node_transport = __commonJS((exports) => {
|
|
|
22888
22888
|
const d = (0, nats_base_client_1.deferred)();
|
|
22889
22889
|
try {
|
|
22890
22890
|
fn = resolve2(fn);
|
|
22891
|
-
if (!
|
|
22891
|
+
if (!existsSync13(fn)) {
|
|
22892
22892
|
d.reject(new Error(`${fn} doesn't exist`));
|
|
22893
22893
|
}
|
|
22894
22894
|
readFile(fn, (err, data2) => {
|
|
@@ -61798,12 +61798,12 @@ class A2AClient {
|
|
|
61798
61798
|
if (state === "completed" || state === "failed") {
|
|
61799
61799
|
return this.taskToProviderResponse(task, taskId, startMs);
|
|
61800
61800
|
}
|
|
61801
|
-
await
|
|
61801
|
+
await sleep3(POLL_INTERVAL_MS);
|
|
61802
61802
|
}
|
|
61803
61803
|
throw new ProviderError("A2A task polling exhausted", "TIMEOUT", undefined, { taskId });
|
|
61804
61804
|
}
|
|
61805
61805
|
}
|
|
61806
|
-
function
|
|
61806
|
+
function sleep3(ms) {
|
|
61807
61807
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
61808
61808
|
}
|
|
61809
61809
|
function createA2AClient(config2) {
|
|
@@ -61931,8 +61931,8 @@ var init_a2a_provider = __esm(() => {
|
|
|
61931
61931
|
|
|
61932
61932
|
// ../core/src/providers/nats-genie-provider.ts
|
|
61933
61933
|
import { mkdir, writeFile } from "fs/promises";
|
|
61934
|
-
import { homedir as
|
|
61935
|
-
import { join as
|
|
61934
|
+
import { homedir as homedir10 } from "os";
|
|
61935
|
+
import { join as join16 } from "path";
|
|
61936
61936
|
|
|
61937
61937
|
class NatsGenieProvider {
|
|
61938
61938
|
id;
|
|
@@ -62122,10 +62122,10 @@ class NatsGenieProvider {
|
|
|
62122
62122
|
}
|
|
62123
62123
|
async writeDeadLetter(payload, error2) {
|
|
62124
62124
|
try {
|
|
62125
|
-
const dlDir =
|
|
62125
|
+
const dlDir = join16(homedir10(), ".omni", "dead-letters");
|
|
62126
62126
|
await mkdir(dlDir, { recursive: true });
|
|
62127
62127
|
const filename = `nats-genie-${Date.now()}-${payload.chatId}.json`;
|
|
62128
|
-
await writeFile(
|
|
62128
|
+
await writeFile(join16(dlDir, filename), JSON.stringify({
|
|
62129
62129
|
payload,
|
|
62130
62130
|
error: error2 instanceof Error ? error2.message : String(error2),
|
|
62131
62131
|
timestamp: new Date().toISOString()
|
|
@@ -64004,7 +64004,7 @@ var init_sql = __esm(() => {
|
|
|
64004
64004
|
return new SQL([new StringChunk(str)]);
|
|
64005
64005
|
}
|
|
64006
64006
|
sql2.raw = raw2;
|
|
64007
|
-
function
|
|
64007
|
+
function join17(chunks, separator) {
|
|
64008
64008
|
const result = [];
|
|
64009
64009
|
for (const [i6, chunk] of chunks.entries()) {
|
|
64010
64010
|
if (i6 > 0 && separator !== undefined) {
|
|
@@ -64014,7 +64014,7 @@ var init_sql = __esm(() => {
|
|
|
64014
64014
|
}
|
|
64015
64015
|
return new SQL(result);
|
|
64016
64016
|
}
|
|
64017
|
-
sql2.join =
|
|
64017
|
+
sql2.join = join17;
|
|
64018
64018
|
function identifier(value) {
|
|
64019
64019
|
return new Name(value);
|
|
64020
64020
|
}
|
|
@@ -67241,7 +67241,7 @@ var init_select2 = __esm(() => {
|
|
|
67241
67241
|
return (table2, on) => {
|
|
67242
67242
|
const baseTableName = this.tableName;
|
|
67243
67243
|
const tableName = getTableLikeName(table2);
|
|
67244
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
67244
|
+
if (typeof tableName === "string" && this.config.joins?.some((join17) => join17.alias === tableName)) {
|
|
67245
67245
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
67246
67246
|
}
|
|
67247
67247
|
if (!this.isPartialSelect) {
|
|
@@ -67752,7 +67752,7 @@ var init_update = __esm(() => {
|
|
|
67752
67752
|
createJoin(joinType) {
|
|
67753
67753
|
return (table2, on) => {
|
|
67754
67754
|
const tableName = getTableLikeName(table2);
|
|
67755
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
67755
|
+
if (typeof tableName === "string" && this.config.joins.some((join17) => join17.alias === tableName)) {
|
|
67756
67756
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
67757
67757
|
}
|
|
67758
67758
|
if (typeof on === "function") {
|
|
@@ -67802,10 +67802,10 @@ var init_update = __esm(() => {
|
|
|
67802
67802
|
const fromFields = this.getTableLikeFields(this.config.from);
|
|
67803
67803
|
fields[tableName] = fromFields;
|
|
67804
67804
|
}
|
|
67805
|
-
for (const
|
|
67806
|
-
const tableName2 = getTableLikeName(
|
|
67807
|
-
if (typeof tableName2 === "string" && !is(
|
|
67808
|
-
const fromFields = this.getTableLikeFields(
|
|
67805
|
+
for (const join17 of this.config.joins) {
|
|
67806
|
+
const tableName2 = getTableLikeName(join17.table);
|
|
67807
|
+
if (typeof tableName2 === "string" && !is(join17.table, SQL)) {
|
|
67808
|
+
const fromFields = this.getTableLikeFields(join17.table);
|
|
67809
67809
|
fields[tableName2] = fromFields;
|
|
67810
67810
|
}
|
|
67811
67811
|
}
|
|
@@ -82474,7 +82474,7 @@ var require_path = __commonJS((exports) => {
|
|
|
82474
82474
|
function isAbsolute(path) {
|
|
82475
82475
|
return path.charAt(0) === "/";
|
|
82476
82476
|
}
|
|
82477
|
-
function
|
|
82477
|
+
function join21(...args) {
|
|
82478
82478
|
return normalizePath(args.join("/"));
|
|
82479
82479
|
}
|
|
82480
82480
|
function dirname6(path) {
|
|
@@ -82499,7 +82499,7 @@ var require_path = __commonJS((exports) => {
|
|
|
82499
82499
|
exports.basename = basename6;
|
|
82500
82500
|
exports.dirname = dirname6;
|
|
82501
82501
|
exports.isAbsolute = isAbsolute;
|
|
82502
|
-
exports.join =
|
|
82502
|
+
exports.join = join21;
|
|
82503
82503
|
exports.normalizePath = normalizePath;
|
|
82504
82504
|
exports.relative = relative;
|
|
82505
82505
|
exports.resolve = resolve4;
|
|
@@ -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.15",
|
|
124071
124071
|
description: "LLM-optimized CLI for Omni",
|
|
124072
124072
|
type: "module",
|
|
124073
124073
|
bin: {
|
|
@@ -127889,9 +127889,9 @@ function createDeadLettersCommand() {
|
|
|
127889
127889
|
}
|
|
127890
127890
|
|
|
127891
127891
|
// src/commands/doctor.ts
|
|
127892
|
-
import { existsSync as
|
|
127893
|
-
import { homedir as
|
|
127894
|
-
import { join as
|
|
127892
|
+
import { existsSync as existsSync10, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
127893
|
+
import { homedir as homedir8 } from "os";
|
|
127894
|
+
import { join as join13, resolve } from "path";
|
|
127895
127895
|
init_config();
|
|
127896
127896
|
|
|
127897
127897
|
// src/health.ts
|
|
@@ -129286,29 +129286,238 @@ function formatBytes(n) {
|
|
|
129286
129286
|
return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`;
|
|
129287
129287
|
}
|
|
129288
129288
|
|
|
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
|
+
|
|
129289
129498
|
// src/commands/doctor.ts
|
|
129290
129499
|
init_output();
|
|
129291
129500
|
|
|
129292
129501
|
// src/server-bundle.ts
|
|
129293
129502
|
init_output();
|
|
129294
|
-
import { dirname as dirname2, join as
|
|
129503
|
+
import { dirname as dirname2, join as join12 } from "path";
|
|
129295
129504
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
129296
129505
|
function getServerBundlePath() {
|
|
129297
129506
|
try {
|
|
129298
129507
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
129299
129508
|
const distDir = dirname2(thisFile);
|
|
129300
|
-
return
|
|
129509
|
+
return join12(distDir, "server", "index.js");
|
|
129301
129510
|
} catch {
|
|
129302
|
-
return
|
|
129511
|
+
return join12(process.cwd(), "dist", "server", "index.js");
|
|
129303
129512
|
}
|
|
129304
129513
|
}
|
|
129305
129514
|
function getServerLauncherPath() {
|
|
129306
129515
|
try {
|
|
129307
129516
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
129308
129517
|
const distDir = dirname2(thisFile);
|
|
129309
|
-
return
|
|
129518
|
+
return join12(distDir, "..", "bin", "omni-server");
|
|
129310
129519
|
} catch {
|
|
129311
|
-
return
|
|
129520
|
+
return join12(process.cwd(), "bin", "omni-server");
|
|
129312
129521
|
}
|
|
129313
129522
|
}
|
|
129314
129523
|
function bundleNotFoundError(bundlePath) {
|
|
@@ -129373,10 +129582,10 @@ function productionDeps() {
|
|
|
129373
129582
|
}
|
|
129374
129583
|
},
|
|
129375
129584
|
findOrphanedDataDirs: () => {
|
|
129376
|
-
const roots = [process.cwd(),
|
|
129585
|
+
const roots = [process.cwd(), join13(homedir8(), "workspace"), join13(homedir8(), "repos")];
|
|
129377
129586
|
const found = [];
|
|
129378
129587
|
for (const root of roots) {
|
|
129379
|
-
if (!
|
|
129588
|
+
if (!existsSync10(root))
|
|
129380
129589
|
continue;
|
|
129381
129590
|
try {
|
|
129382
129591
|
scanForOrphans(root, found, 0);
|
|
@@ -129484,7 +129693,7 @@ function scanForOrphans(dir, acc, depth, maxDepth = 4) {
|
|
|
129484
129693
|
for (const name of entries) {
|
|
129485
129694
|
if (name === "node_modules" || name === ".git")
|
|
129486
129695
|
continue;
|
|
129487
|
-
const full =
|
|
129696
|
+
const full = join13(dir, name);
|
|
129488
129697
|
let stats;
|
|
129489
129698
|
try {
|
|
129490
129699
|
stats = statSync2(full);
|
|
@@ -129553,6 +129762,55 @@ async function checkOmniDbExists(deps) {
|
|
|
129553
129762
|
}
|
|
129554
129763
|
return { id: "omni-db-exists", level: "FAIL", detail: "omni database is not reachable" };
|
|
129555
129764
|
}
|
|
129765
|
+
async function checkEmbeddedDataOrphaned(deps) {
|
|
129766
|
+
const { serverConfig } = deps.loadState();
|
|
129767
|
+
if (serverConfig.useCanonicalPgserve !== true) {
|
|
129768
|
+
return { id: "embedded-data-orphaned", level: "OK", detail: "embedded mode \u2014 no orphan check needed" };
|
|
129769
|
+
}
|
|
129770
|
+
if (!existsSync10(join13(EMBEDDED_PGSERVE_DATA_DIR, "PG_VERSION"))) {
|
|
129771
|
+
return { id: "embedded-data-orphaned", level: "OK", detail: "no embedded data dir present" };
|
|
129772
|
+
}
|
|
129773
|
+
if (!await deps.omniDbExists()) {
|
|
129774
|
+
return {
|
|
129775
|
+
id: "embedded-data-orphaned",
|
|
129776
|
+
level: "OK",
|
|
129777
|
+
detail: "canonical not reachable yet \u2014 embedded check deferred"
|
|
129778
|
+
};
|
|
129779
|
+
}
|
|
129780
|
+
try {
|
|
129781
|
+
const resp = await fetch(`http://127.0.0.1:${serverConfig.port}/api/v2/health`, {
|
|
129782
|
+
signal: AbortSignal.timeout(2000)
|
|
129783
|
+
});
|
|
129784
|
+
const body = await resp.json();
|
|
129785
|
+
const total = body?.instances?.total ?? 0;
|
|
129786
|
+
if (total === 0) {
|
|
129787
|
+
return {
|
|
129788
|
+
id: "embedded-data-orphaned",
|
|
129789
|
+
level: "FAIL",
|
|
129790
|
+
detail: `embedded dir at ${EMBEDDED_PGSERVE_DATA_DIR} holds data but canonical omni is empty \u2014 run \`omni doctor --fix\` to migrate`
|
|
129791
|
+
};
|
|
129792
|
+
}
|
|
129793
|
+
return {
|
|
129794
|
+
id: "embedded-data-orphaned",
|
|
129795
|
+
level: "OK",
|
|
129796
|
+
detail: `canonical omni already has ${total} instance(s)`
|
|
129797
|
+
};
|
|
129798
|
+
} catch {
|
|
129799
|
+
return { id: "embedded-data-orphaned", level: "OK", detail: "health endpoint unreachable \u2014 defer" };
|
|
129800
|
+
}
|
|
129801
|
+
}
|
|
129802
|
+
async function fixEmbeddedDataOrphaned(_deps) {
|
|
129803
|
+
raw(" Migrating unmounted embedded pgserve \u2192 canonical autopg...");
|
|
129804
|
+
const result = await migrateUnmountedEmbeddedToCanonical({
|
|
129805
|
+
log: (line) => raw(line)
|
|
129806
|
+
});
|
|
129807
|
+
if (result.status === "skipped") {
|
|
129808
|
+
throw new Error(`migration skipped: ${result.reason}`);
|
|
129809
|
+
}
|
|
129810
|
+
raw(` \u2713 migrated ${result.tables} tables in ${result.durationMs}ms`);
|
|
129811
|
+
raw(" Re-run `omni install --non-interactive` to re-apply scoped-role grants on the restored data.");
|
|
129812
|
+
return `migrated ${result.tables} tables from embedded to canonical (${result.durationMs}ms)`;
|
|
129813
|
+
}
|
|
129556
129814
|
function checkOrphanedDataDirs(deps) {
|
|
129557
129815
|
const found = deps.findOrphanedDataDirs();
|
|
129558
129816
|
if (found.length === 0) {
|
|
@@ -129969,7 +130227,8 @@ async function runAllChecks(deps) {
|
|
|
129969
130227
|
await checkPm2LogrotateInstalled(deps),
|
|
129970
130228
|
await checkSigningKeyForLockedInstances(deps),
|
|
129971
130229
|
checkPgserveCanonical(deps),
|
|
129972
|
-
await checkPortCanonicalOwner(deps)
|
|
130230
|
+
await checkPortCanonicalOwner(deps),
|
|
130231
|
+
await checkEmbeddedDataOrphaned(deps)
|
|
129973
130232
|
];
|
|
129974
130233
|
}
|
|
129975
130234
|
async function applyFix(deps, check) {
|
|
@@ -129990,6 +130249,8 @@ async function applyFix(deps, check) {
|
|
|
129990
130249
|
return await fixPortCanonicalOwner(deps);
|
|
129991
130250
|
if (check.id === "pm2-status")
|
|
129992
130251
|
return await fixPm2Status(deps);
|
|
130252
|
+
if (check.id === "embedded-data-orphaned")
|
|
130253
|
+
return await fixEmbeddedDataOrphaned(deps);
|
|
129993
130254
|
return null;
|
|
129994
130255
|
} catch (err) {
|
|
129995
130256
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -130107,7 +130368,7 @@ Safety:
|
|
|
130107
130368
|
}
|
|
130108
130369
|
|
|
130109
130370
|
// src/commands/done.ts
|
|
130110
|
-
import { existsSync as
|
|
130371
|
+
import { existsSync as existsSync11, readFileSync as readFileSync6 } from "fs";
|
|
130111
130372
|
import { basename, extname } from "path";
|
|
130112
130373
|
|
|
130113
130374
|
// src/context.ts
|
|
@@ -130216,7 +130477,7 @@ async function handleReact(client, ctx, emoji) {
|
|
|
130216
130477
|
await closeTurn(client, "react", `Reacted ${emoji} + turn closed`);
|
|
130217
130478
|
}
|
|
130218
130479
|
async function handleMedia(client, ctx, mediaPath, caption) {
|
|
130219
|
-
if (!
|
|
130480
|
+
if (!existsSync11(mediaPath)) {
|
|
130220
130481
|
return error(`File not found: ${mediaPath}`);
|
|
130221
130482
|
}
|
|
130222
130483
|
try {
|
|
@@ -130914,7 +131175,7 @@ function createHistoryCommand() {
|
|
|
130914
131175
|
|
|
130915
131176
|
// src/commands/imagine.ts
|
|
130916
131177
|
import { writeFileSync as writeFileSync8 } from "fs";
|
|
130917
|
-
import { basename as basename2, dirname as dirname3, extname as extname2, join as
|
|
131178
|
+
import { basename as basename2, dirname as dirname3, extname as extname2, join as join14 } from "path";
|
|
130918
131179
|
init_output();
|
|
130919
131180
|
var ALLOWED_ASPECT_RATIOS = ["1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3"];
|
|
130920
131181
|
function extensionForMime(mimeType) {
|
|
@@ -130929,9 +131190,9 @@ function buildOutputPath(outputBase, index, total, mimeType) {
|
|
|
130929
131190
|
const ext = extname2(outputBase) || extensionForMime(mimeType);
|
|
130930
131191
|
const stem = basename2(outputBase, extname2(outputBase));
|
|
130931
131192
|
if (total <= 1) {
|
|
130932
|
-
return
|
|
131193
|
+
return join14(dir, `${stem}${ext}`);
|
|
130933
131194
|
}
|
|
130934
|
-
return
|
|
131195
|
+
return join14(dir, `${stem}-${index + 1}${ext}`);
|
|
130935
131196
|
}
|
|
130936
131197
|
function parseAspectRatio(value) {
|
|
130937
131198
|
if (!value)
|
|
@@ -131049,12 +131310,12 @@ function createImagineCommand() {
|
|
|
131049
131310
|
}
|
|
131050
131311
|
|
|
131051
131312
|
// src/commands/install.ts
|
|
131052
|
-
import { existsSync as
|
|
131053
|
-
import { homedir as
|
|
131054
|
-
import { join as
|
|
131313
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync6 } from "fs";
|
|
131314
|
+
import { homedir as homedir9 } from "os";
|
|
131315
|
+
import { join as join15 } from "path";
|
|
131055
131316
|
init_config();
|
|
131056
131317
|
init_output();
|
|
131057
|
-
var DEFAULT_DATA_DIR2 =
|
|
131318
|
+
var DEFAULT_DATA_DIR2 = join15(homedir9(), ".omni", "data");
|
|
131058
131319
|
function computeDefaultDatabaseUrl() {
|
|
131059
131320
|
return buildEmbeddedDatabaseUrl();
|
|
131060
131321
|
}
|
|
@@ -131153,7 +131414,7 @@ async function startServices(cfg, forceCleanup, forceSystemd, useCanonicalPgserv
|
|
|
131153
131414
|
return false;
|
|
131154
131415
|
}
|
|
131155
131416
|
const bundlePath = getServerBundlePath();
|
|
131156
|
-
if (!
|
|
131417
|
+
if (!existsSync12(bundlePath)) {
|
|
131157
131418
|
warn(`Server bundle not found at: ${bundlePath}
|
|
131158
131419
|
Install @automagik/omni from npm: bun add -g @automagik/omni
|
|
131159
131420
|
Or build locally: make cli-build-full`);
|
|
@@ -131177,9 +131438,9 @@ async function startServices(cfg, forceCleanup, forceSystemd, useCanonicalPgserv
|
|
|
131177
131438
|
return false;
|
|
131178
131439
|
}
|
|
131179
131440
|
apiSpinner.succeed(`${PM2_PROCESSES.api} started`);
|
|
131180
|
-
if (
|
|
131441
|
+
if (existsSync12(NATS_BINARY_PATH)) {
|
|
131181
131442
|
const natsSpinner = ora(`Starting ${PM2_PROCESSES.nats}...`).start();
|
|
131182
|
-
const natsDataDir =
|
|
131443
|
+
const natsDataDir = join15(cfg.dataDir, "nats");
|
|
131183
131444
|
mkdirSync6(natsDataDir, { recursive: true });
|
|
131184
131445
|
const natsArgs = buildPm2StartArgs({
|
|
131185
131446
|
kind: "nats",
|
|
@@ -132856,7 +133117,7 @@ function createLogsCommand() {
|
|
|
132856
133117
|
}
|
|
132857
133118
|
|
|
132858
133119
|
// src/commands/media.ts
|
|
132859
|
-
import { createWriteStream as createWriteStream2, existsSync as
|
|
133120
|
+
import { createWriteStream as createWriteStream2, existsSync as existsSync14, mkdirSync as mkdirSync8, statSync as statSync4 } from "fs";
|
|
132860
133121
|
import { basename as basename4, dirname as dirname4, resolve as resolve2 } from "path";
|
|
132861
133122
|
import { Readable } from "stream";
|
|
132862
133123
|
import { pipeline } from "stream/promises";
|
|
@@ -132919,13 +133180,13 @@ function resolveOutputPath(outputPath, result) {
|
|
|
132919
133180
|
const resolved = resolve2(outputPath);
|
|
132920
133181
|
if (isDirHint)
|
|
132921
133182
|
return resolve2(resolved, filename);
|
|
132922
|
-
if (
|
|
133183
|
+
if (existsSync14(resolved) && statSync4(resolved).isDirectory())
|
|
132923
133184
|
return resolve2(resolved, filename);
|
|
132924
133185
|
return resolved;
|
|
132925
133186
|
}
|
|
132926
133187
|
async function downloadToFile(url, apiKey, destinationPath) {
|
|
132927
133188
|
const destDir = dirname4(destinationPath);
|
|
132928
|
-
if (!
|
|
133189
|
+
if (!existsSync14(destDir))
|
|
132929
133190
|
mkdirSync8(destDir, { recursive: true });
|
|
132930
133191
|
const resp = await fetch(url, {
|
|
132931
133192
|
method: "GET",
|
|
@@ -133879,8 +134140,8 @@ init_output();
|
|
|
133879
134140
|
init_src();
|
|
133880
134141
|
import { execFileSync as execFileSync3, execSync } from "child_process";
|
|
133881
134142
|
import * as nodeCrypto2 from "crypto";
|
|
133882
|
-
import { existsSync as
|
|
133883
|
-
import { homedir as
|
|
134143
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync9, readFileSync as readFileSync9, writeFileSync as writeFileSync9 } from "fs";
|
|
134144
|
+
import { homedir as homedir11 } from "os";
|
|
133884
134145
|
import { dirname as dirname5, resolve as resolve3 } from "path";
|
|
133885
134146
|
import { createInterface as createInterface2 } from "readline";
|
|
133886
134147
|
init_config();
|
|
@@ -134107,10 +134368,10 @@ async function pairDevice(gatewayUrl, gatewayToken, keypair, spinner) {
|
|
|
134107
134368
|
ws.close(1000, "pairing complete");
|
|
134108
134369
|
}
|
|
134109
134370
|
}
|
|
134110
|
-
var OPENCLAW_CONFIG_PATH = resolve3(
|
|
134371
|
+
var OPENCLAW_CONFIG_PATH = resolve3(homedir11(), ".openclaw", "openclaw.json");
|
|
134111
134372
|
var PLUGIN_MARKER = "plugin-openclaw/omni.ts";
|
|
134112
134373
|
function readOpenClawConfig(configPath) {
|
|
134113
|
-
if (!
|
|
134374
|
+
if (!existsSync15(configPath))
|
|
134114
134375
|
return {};
|
|
134115
134376
|
const raw2 = readFileSync9(configPath, "utf-8").trim();
|
|
134116
134377
|
if (!raw2)
|
|
@@ -134151,10 +134412,10 @@ function isValidUuid2(value) {
|
|
|
134151
134412
|
}
|
|
134152
134413
|
function resolvePluginPath(explicit) {
|
|
134153
134414
|
if (explicit) {
|
|
134154
|
-
return
|
|
134415
|
+
return existsSync15(explicit) ? resolve3(explicit) : null;
|
|
134155
134416
|
}
|
|
134156
134417
|
const cwdCandidate = resolve3(process.cwd(), "packages/plugin-openclaw/omni.ts");
|
|
134157
|
-
return
|
|
134418
|
+
return existsSync15(cwdCandidate) ? cwdCandidate : null;
|
|
134158
134419
|
}
|
|
134159
134420
|
function registerPlugin(config2, pluginPath, configPath) {
|
|
134160
134421
|
if (hasOpenClawCli()) {
|
|
@@ -134864,7 +135125,7 @@ ${formatExamples(examples)}`);
|
|
|
134864
135125
|
}
|
|
134865
135126
|
|
|
134866
135127
|
// src/lib/requirements.ts
|
|
134867
|
-
import { spawn } from "child_process";
|
|
135128
|
+
import { spawn as spawn2 } from "child_process";
|
|
134868
135129
|
var REQUIREMENTS = Object.freeze({
|
|
134869
135130
|
pgserve: ">=2.3",
|
|
134870
135131
|
genie: ">=5.0"
|
|
@@ -134908,7 +135169,7 @@ function fetchPeerVersion(binary) {
|
|
|
134908
135169
|
let settled = false;
|
|
134909
135170
|
let stdout = "";
|
|
134910
135171
|
let stderr = "";
|
|
134911
|
-
const proc =
|
|
135172
|
+
const proc = spawn2(binary, ["--version"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
134912
135173
|
const timer2 = setTimeout(() => {
|
|
134913
135174
|
if (settled)
|
|
134914
135175
|
return;
|
|
@@ -135204,7 +135465,7 @@ function createSayCommand() {
|
|
|
135204
135465
|
}
|
|
135205
135466
|
|
|
135206
135467
|
// src/commands/see.ts
|
|
135207
|
-
import { existsSync as
|
|
135468
|
+
import { existsSync as existsSync16, readFileSync as readFileSync10, statSync as statSync5 } from "fs";
|
|
135208
135469
|
import { extname as extname4 } from "path";
|
|
135209
135470
|
init_output();
|
|
135210
135471
|
var MIME_BY_EXT = {
|
|
@@ -135236,7 +135497,7 @@ function parseMaxTokens(value) {
|
|
|
135236
135497
|
return n2;
|
|
135237
135498
|
}
|
|
135238
135499
|
function loadMedia(file) {
|
|
135239
|
-
if (!
|
|
135500
|
+
if (!existsSync16(file)) {
|
|
135240
135501
|
error(`File not found: ${file}`);
|
|
135241
135502
|
}
|
|
135242
135503
|
const stat = statSync5(file);
|
|
@@ -135322,7 +135583,7 @@ function createSeeCommand() {
|
|
|
135322
135583
|
}
|
|
135323
135584
|
|
|
135324
135585
|
// src/commands/send.ts
|
|
135325
|
-
import { existsSync as
|
|
135586
|
+
import { existsSync as existsSync17, readFileSync as readFileSync11 } from "fs";
|
|
135326
135587
|
import { basename as basename5, extname as extname5 } from "path";
|
|
135327
135588
|
init_source();
|
|
135328
135589
|
init_config();
|
|
@@ -135363,7 +135624,7 @@ var messageSenders = {
|
|
|
135363
135624
|
const { to, media } = options3;
|
|
135364
135625
|
if (!to || !media)
|
|
135365
135626
|
return;
|
|
135366
|
-
if (!
|
|
135627
|
+
if (!existsSync17(media)) {
|
|
135367
135628
|
error(`File not found: ${media}`);
|
|
135368
135629
|
return;
|
|
135369
135630
|
}
|
|
@@ -135895,9 +136156,9 @@ function pickFilename(mimeType, provider) {
|
|
|
135895
136156
|
}
|
|
135896
136157
|
|
|
135897
136158
|
// src/commands/start.ts
|
|
135898
|
-
import { existsSync as
|
|
135899
|
-
import { homedir as
|
|
135900
|
-
import { join as
|
|
136159
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync10 } from "fs";
|
|
136160
|
+
import { homedir as homedir12 } from "os";
|
|
136161
|
+
import { join as join17 } from "path";
|
|
135901
136162
|
init_config();
|
|
135902
136163
|
init_output();
|
|
135903
136164
|
var START_HEALTH_TIMEOUT_MS = 1e4;
|
|
@@ -135906,7 +136167,7 @@ async function runStart() {
|
|
|
135906
136167
|
pm2NotFoundError();
|
|
135907
136168
|
}
|
|
135908
136169
|
const bundlePath = getServerBundlePath();
|
|
135909
|
-
if (!
|
|
136170
|
+
if (!existsSync18(bundlePath)) {
|
|
135910
136171
|
bundleNotFoundError(bundlePath);
|
|
135911
136172
|
}
|
|
135912
136173
|
const serverConfig = loadServerConfig();
|
|
@@ -135927,10 +136188,10 @@ async function runStart() {
|
|
|
135927
136188
|
error(`Failed to start ${PM2_PROCESSES.api} (pm2 exit code ${apiCode})`, undefined, 1);
|
|
135928
136189
|
return;
|
|
135929
136190
|
}
|
|
135930
|
-
const natsPath =
|
|
135931
|
-
if (
|
|
136191
|
+
const natsPath = join17(homedir12(), ".omni", "nats-server");
|
|
136192
|
+
if (existsSync18(natsPath)) {
|
|
135932
136193
|
info(`Starting ${PM2_PROCESSES.nats}...`);
|
|
135933
|
-
const natsDataDir =
|
|
136194
|
+
const natsDataDir = join17(serverConfig.dataDir, "nats");
|
|
135934
136195
|
mkdirSync10(natsDataDir, { recursive: true });
|
|
135935
136196
|
const natsArgs = buildPm2StartArgs({
|
|
135936
136197
|
kind: "nats",
|
|
@@ -136351,8 +136612,8 @@ function createTurnsCommand() {
|
|
|
136351
136612
|
}
|
|
136352
136613
|
|
|
136353
136614
|
// src/commands/update.ts
|
|
136354
|
-
import { existsSync as
|
|
136355
|
-
import { join as
|
|
136615
|
+
import { existsSync as existsSync20 } from "fs";
|
|
136616
|
+
import { join as join19 } from "path";
|
|
136356
136617
|
import { createInterface as createInterface3 } from "readline";
|
|
136357
136618
|
init_source();
|
|
136358
136619
|
init_config();
|
|
@@ -136634,9 +136895,9 @@ async function cleanupLegacyArtifacts(skipList) {
|
|
|
136634
136895
|
init_output();
|
|
136635
136896
|
|
|
136636
136897
|
// src/update-diagnostics.ts
|
|
136637
|
-
import { existsSync as
|
|
136638
|
-
import { homedir as
|
|
136639
|
-
import { join as
|
|
136898
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
|
|
136899
|
+
import { homedir as homedir13 } from "os";
|
|
136900
|
+
import { join as join18 } from "path";
|
|
136640
136901
|
var UPDATE_DIAGNOSTICS_SCHEMA_VERSION = 1;
|
|
136641
136902
|
function createDiagnostics(args) {
|
|
136642
136903
|
const startedAt = new Date().toISOString();
|
|
@@ -136658,15 +136919,15 @@ function createDiagnostics(args) {
|
|
|
136658
136919
|
};
|
|
136659
136920
|
}
|
|
136660
136921
|
function getDiagnosticsDir() {
|
|
136661
|
-
const base = process.env.OMNI_CONFIG_DIR ??
|
|
136662
|
-
return
|
|
136922
|
+
const base = process.env.OMNI_CONFIG_DIR ?? join18(homedir13(), ".omni");
|
|
136923
|
+
return join18(base, "logs");
|
|
136663
136924
|
}
|
|
136664
136925
|
function getDiagnosticsPath(startedAt) {
|
|
136665
136926
|
const safe = startedAt.replace(/:/g, "-");
|
|
136666
|
-
return
|
|
136927
|
+
return join18(getDiagnosticsDir(), `update-diagnostics-${safe}.json`);
|
|
136667
136928
|
}
|
|
136668
136929
|
function tailFileLines(path, maxLines) {
|
|
136669
|
-
if (!
|
|
136930
|
+
if (!existsSync19(path))
|
|
136670
136931
|
return [];
|
|
136671
136932
|
try {
|
|
136672
136933
|
const raw2 = readFileSync12(path, "utf8");
|
|
@@ -136702,7 +136963,7 @@ function writeDiagnostics(state, exitCode) {
|
|
|
136702
136963
|
const dir = getDiagnosticsDir();
|
|
136703
136964
|
const path = getDiagnosticsPath(state.startedAt);
|
|
136704
136965
|
try {
|
|
136705
|
-
if (!
|
|
136966
|
+
if (!existsSync19(dir)) {
|
|
136706
136967
|
mkdirSync11(dir, { recursive: true, mode: 448 });
|
|
136707
136968
|
}
|
|
136708
136969
|
writeFileSync10(path, `${JSON.stringify(state, null, 2)}
|
|
@@ -136876,7 +137137,7 @@ function printVerifySkippedBanner(latest) {
|
|
|
136876
137137
|
}
|
|
136877
137138
|
function detectParallelNpmGlobalInstall(deps) {
|
|
136878
137139
|
const npmRootFn = deps?.npmRoot ?? defaultNpmRoot;
|
|
136879
|
-
const existsFn = deps?.exists ??
|
|
137140
|
+
const existsFn = deps?.exists ?? existsSync20;
|
|
136880
137141
|
let root;
|
|
136881
137142
|
try {
|
|
136882
137143
|
root = npmRootFn();
|
|
@@ -136886,7 +137147,7 @@ function detectParallelNpmGlobalInstall(deps) {
|
|
|
136886
137147
|
if (root === null || root.length === 0) {
|
|
136887
137148
|
return { detected: false, skipped: "npm-not-on-path" };
|
|
136888
137149
|
}
|
|
136889
|
-
const candidate =
|
|
137150
|
+
const candidate = join19(root, "@automagik", "omni");
|
|
136890
137151
|
if (existsFn(candidate)) {
|
|
136891
137152
|
return { detected: true, path: candidate };
|
|
136892
137153
|
}
|
|
@@ -137509,13 +137770,13 @@ init_config();
|
|
|
137509
137770
|
init_output();
|
|
137510
137771
|
|
|
137511
137772
|
// src/manifest-pin.ts
|
|
137512
|
-
import { existsSync as
|
|
137513
|
-
import { homedir as
|
|
137514
|
-
import { join as
|
|
137773
|
+
import { existsSync as existsSync21, readFileSync as readFileSync13, renameSync as renameSync3, writeFileSync as writeFileSync11 } from "fs";
|
|
137774
|
+
import { homedir as homedir14 } from "os";
|
|
137775
|
+
import { join as join20 } from "path";
|
|
137515
137776
|
var PACKAGE_NAME2 = "@automagik/omni";
|
|
137516
|
-
var BUN_GLOBAL_MANIFEST =
|
|
137777
|
+
var BUN_GLOBAL_MANIFEST = join20(homedir14(), ".bun", "install", "global", "package.json");
|
|
137517
137778
|
function pinManifestEntry(manifestPath, exactVersion) {
|
|
137518
|
-
if (!
|
|
137779
|
+
if (!existsSync21(manifestPath))
|
|
137519
137780
|
return false;
|
|
137520
137781
|
let manifest;
|
|
137521
137782
|
try {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedded → canonical migration for the "unmounted embedded dir" path.
|
|
3
|
+
*
|
|
4
|
+
* Background
|
|
5
|
+
* ----------
|
|
6
|
+
* The original `fixPgserveCanonical` flow (canonical-pgserve.ts +
|
|
7
|
+
* doctor.ts) assumes the embedded pgserve is LIVE: omni-api is running
|
|
8
|
+
* against it, pg_dump connects to the live instance, then we stop
|
|
9
|
+
* omni-api, set up canonical, restore, restart on canonical. That
|
|
10
|
+
* worked through the singleton-no-proxy cutover when omni-api could
|
|
11
|
+
* still spawn embedded.
|
|
12
|
+
*
|
|
13
|
+
* Phase 3 (`pgserve-singleton-no-proxy` G2) deleted omni-api's
|
|
14
|
+
* embedded-spawn code. That leaves a regression for any operator who:
|
|
15
|
+
* - Has `useCanonicalPgserve: true` in config (cutover already
|
|
16
|
+
* "succeeded" structurally) but
|
|
17
|
+
* - Never actually moved data — their 8.4 GB sits at
|
|
18
|
+
* `~/.omni/data/pgserve/` as an unmounted postmaster data dir
|
|
19
|
+
* - The canonical `omni` database on autopg is empty
|
|
20
|
+
*
|
|
21
|
+
* Found during Felipe's 2026-05-20 dogfood: omni-api boots cleanly on
|
|
22
|
+
* canonical but `omni instances list` returns nothing — the data is
|
|
23
|
+
* stranded.
|
|
24
|
+
*
|
|
25
|
+
* Solution
|
|
26
|
+
* --------
|
|
27
|
+
* Spawn autopg's bundled `postgres` binary against the unmounted embedded
|
|
28
|
+
* data dir on a free TCP port, copy every public-schema table over to
|
|
29
|
+
* canonical via psql `COPY ... TO STDOUT | COPY ... FROM STDIN` pipes
|
|
30
|
+
* (psql 17 happily connects to a PG18 server — only pg_dump is strict),
|
|
31
|
+
* then shut the temp postmaster down. Postgres version compatibility is
|
|
32
|
+
* sidestepped: both embedded and canonical use the same autopg-bundled
|
|
33
|
+
* postgres binary on this host.
|
|
34
|
+
*
|
|
35
|
+
* Idempotency: caller is expected to gate on `canonical omni DB is
|
|
36
|
+
* empty + embedded dir has data` so re-running this isn't destructive.
|
|
37
|
+
* Within this function: TRUNCATE CASCADE before COPY, sequence reset
|
|
38
|
+
* after.
|
|
39
|
+
*
|
|
40
|
+
* Safety:
|
|
41
|
+
* - Temp postmaster binds 127.0.0.1 only, on a free ephemeral port
|
|
42
|
+
* - Spawned with `unix_socket_directories=/tmp/<unique>` to avoid
|
|
43
|
+
* colliding with canonical's socket dir
|
|
44
|
+
* - Caller takes a snapshot of `~/.omni/data/pgserve/` before invoking
|
|
45
|
+
* (recommended) — this code does NOT mutate the embedded dir
|
|
46
|
+
* - Temp postmaster gets SIGTERM in `finally`; on hard crash the
|
|
47
|
+
* leftover postmaster.pid is recovered by the next spawn attempt
|
|
48
|
+
* (postgres self-heals stale pidfiles on startup)
|
|
49
|
+
*/
|
|
50
|
+
export type MigrationResult = {
|
|
51
|
+
status: 'migrated';
|
|
52
|
+
tables: number;
|
|
53
|
+
durationMs: number;
|
|
54
|
+
} | {
|
|
55
|
+
status: 'skipped';
|
|
56
|
+
reason: string;
|
|
57
|
+
};
|
|
58
|
+
export interface MigrateOptions {
|
|
59
|
+
/** TCP port the canonical postmaster is bound on (autopg default 5432). */
|
|
60
|
+
canonicalPort?: number;
|
|
61
|
+
/** Logger sink — defaults to writing prefixed lines to process.stdout. */
|
|
62
|
+
log?: (line: string) => void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Public entry point — call this from `omni doctor --fix` when the
|
|
66
|
+
* `embedded-data-orphaned` check FAILs (canonical omni DB empty AND
|
|
67
|
+
* embedded dir has valid pg data).
|
|
68
|
+
*
|
|
69
|
+
* Returns `{ status: 'skipped', reason }` for any precondition mismatch
|
|
70
|
+
* so callers can present an actionable diagnostic without aborting the
|
|
71
|
+
* larger --fix run.
|
|
72
|
+
*/
|
|
73
|
+
export declare function migrateUnmountedEmbeddedToCanonical(opts?: MigrateOptions): Promise<MigrationResult>;
|
|
74
|
+
/** Re-export the constant so callers / tests can probe the same path. */
|
|
75
|
+
export declare const EMBEDDED_PGSERVE_DATA_DIR: string;
|
|
76
|
+
//# sourceMappingURL=embedded-canonical-migration.d.ts.map
|
|
@@ -0,0 +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,GAC1D;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AA0MD;;;;;;;;GAQG;AACH,wBAAsB,mCAAmC,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,CA+D7G;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.15",
|
|
230141
230141
|
type: "module",
|
|
230142
230142
|
exports: {
|
|
230143
230143
|
".": {
|