@automagik/omni 2.260501.1 → 2.260501.2
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.
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
*/
|
|
39
39
|
import { Command } from 'commander';
|
|
40
40
|
import { type Config, type ServerConfig } from '../config.js';
|
|
41
|
+
import { type EmbeddedDumpResult } from '../lib/canonical-pgserve.js';
|
|
41
42
|
/** Severity levels reported by each check. */
|
|
42
43
|
export type CheckLevel = 'OK' | 'WARN' | 'FAIL';
|
|
43
44
|
/** Identifier used in tests and --json output. */
|
|
@@ -141,6 +142,24 @@ export interface DoctorDeps {
|
|
|
141
142
|
* failure. Stubbed in tests.
|
|
142
143
|
*/
|
|
143
144
|
setupCanonicalPgserve: () => Promise<string | null>;
|
|
145
|
+
/**
|
|
146
|
+
* `pg_dump` the embedded omni DB → gzip → snapshot file. Called BEFORE
|
|
147
|
+
* the caller stops omni-api so the embedded pgserve is still live for
|
|
148
|
+
* pg_dump to connect. Returns a status so the caller can decide whether
|
|
149
|
+
* to attempt a restore later. Stubbed in tests.
|
|
150
|
+
*/
|
|
151
|
+
dumpEmbeddedDb: (currentDatabaseUrl: string) => Promise<EmbeddedDumpResult>;
|
|
152
|
+
/**
|
|
153
|
+
* Pipe a dumped snapshot into the canonical pgserve via `psql`. Called
|
|
154
|
+
* AFTER `pgserve install` has brought canonical online. No-op when the
|
|
155
|
+
* dump status was anything but `dumped`. Stubbed in tests.
|
|
156
|
+
*/
|
|
157
|
+
restoreSnapshotToCanonical: (dump: EmbeddedDumpResult, canonicalDatabaseUrl: string) => Promise<{
|
|
158
|
+
status: 'restored' | 'skipped';
|
|
159
|
+
snapshotPath?: string;
|
|
160
|
+
}>;
|
|
161
|
+
/** Resolve canonical pgserve's on-disk data dir for operator-facing logs. */
|
|
162
|
+
getCanonicalPgserveDataDir: () => string;
|
|
144
163
|
/**
|
|
145
164
|
* Persist a partial server config (merges with existing). Stubbed in
|
|
146
165
|
* tests so the canonical-pgserve fix can be validated without writing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,KAAK,MAAM,EACX,KAAK,YAAY,EAKlB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -21292,7 +21292,7 @@ var require_node_transport = __commonJS((exports) => {
|
|
|
21292
21292
|
var util_1 = require_util();
|
|
21293
21293
|
var tls_1 = __require("tls");
|
|
21294
21294
|
var { resolve: resolve2 } = __require("path");
|
|
21295
|
-
var { readFile, existsSync:
|
|
21295
|
+
var { readFile, existsSync: existsSync10 } = __require("fs");
|
|
21296
21296
|
var dns = __require("dns");
|
|
21297
21297
|
var VERSION2 = "2.29.3";
|
|
21298
21298
|
var LANG = "nats.js";
|
|
@@ -21408,7 +21408,7 @@ var require_node_transport = __commonJS((exports) => {
|
|
|
21408
21408
|
const d = (0, nats_base_client_1.deferred)();
|
|
21409
21409
|
try {
|
|
21410
21410
|
fn = resolve2(fn);
|
|
21411
|
-
if (!
|
|
21411
|
+
if (!existsSync10(fn)) {
|
|
21412
21412
|
d.reject(new Error(`${fn} doesn't exist`));
|
|
21413
21413
|
}
|
|
21414
21414
|
readFile(fn, (err, data2) => {
|
|
@@ -27204,11 +27204,11 @@ var init_dead_letter = __esm(() => {
|
|
|
27204
27204
|
});
|
|
27205
27205
|
|
|
27206
27206
|
// ../core/src/events/payload-store.ts
|
|
27207
|
-
import { gunzipSync, gzipSync } from "zlib";
|
|
27207
|
+
import { gunzipSync as gunzipSync2, gzipSync as gzipSync2 } from "zlib";
|
|
27208
27208
|
function compressPayload(payload) {
|
|
27209
27209
|
const jsonString = JSON.stringify(payload);
|
|
27210
27210
|
const originalSize = Buffer.byteLength(jsonString, "utf8");
|
|
27211
|
-
const compressed =
|
|
27211
|
+
const compressed = gzipSync2(jsonString);
|
|
27212
27212
|
const base64 = compressed.toString("base64");
|
|
27213
27213
|
const compressedSize = compressed.length;
|
|
27214
27214
|
return {
|
|
@@ -27220,7 +27220,7 @@ function compressPayload(payload) {
|
|
|
27220
27220
|
}
|
|
27221
27221
|
function decompressPayload(compressedBase64) {
|
|
27222
27222
|
const buffer2 = Buffer.from(compressedBase64, "base64");
|
|
27223
|
-
const decompressed =
|
|
27223
|
+
const decompressed = gunzipSync2(buffer2);
|
|
27224
27224
|
const jsonString = decompressed.toString("utf8");
|
|
27225
27225
|
return JSON.parse(jsonString);
|
|
27226
27226
|
}
|
|
@@ -30758,7 +30758,7 @@ var require_pushgateway = __commonJS((exports, module) => {
|
|
|
30758
30758
|
var url = __require("url");
|
|
30759
30759
|
var http = __require("http");
|
|
30760
30760
|
var https = __require("https");
|
|
30761
|
-
var { gzipSync:
|
|
30761
|
+
var { gzipSync: gzipSync3 } = __require("zlib");
|
|
30762
30762
|
var { globalRegistry } = require_registry();
|
|
30763
30763
|
|
|
30764
30764
|
class Pushgateway {
|
|
@@ -30832,7 +30832,7 @@ var require_pushgateway = __commonJS((exports, module) => {
|
|
|
30832
30832
|
if (method !== "DELETE") {
|
|
30833
30833
|
this.registry.metrics().then((metrics) => {
|
|
30834
30834
|
if (options.headers && options.headers["Content-Encoding"] === "gzip") {
|
|
30835
|
-
metrics =
|
|
30835
|
+
metrics = gzipSync3(metrics);
|
|
30836
30836
|
}
|
|
30837
30837
|
req.write(metrics);
|
|
30838
30838
|
req.end();
|
|
@@ -52201,8 +52201,8 @@ var init_a2a_provider = __esm(() => {
|
|
|
52201
52201
|
|
|
52202
52202
|
// ../core/src/providers/nats-genie-provider.ts
|
|
52203
52203
|
import { mkdir, writeFile } from "fs/promises";
|
|
52204
|
-
import { homedir as
|
|
52205
|
-
import { join as
|
|
52204
|
+
import { homedir as homedir8 } from "os";
|
|
52205
|
+
import { join as join13 } from "path";
|
|
52206
52206
|
|
|
52207
52207
|
class NatsGenieProvider {
|
|
52208
52208
|
id;
|
|
@@ -52392,10 +52392,10 @@ class NatsGenieProvider {
|
|
|
52392
52392
|
}
|
|
52393
52393
|
async writeDeadLetter(payload, error2) {
|
|
52394
52394
|
try {
|
|
52395
|
-
const dlDir =
|
|
52395
|
+
const dlDir = join13(homedir8(), ".omni", "dead-letters");
|
|
52396
52396
|
await mkdir(dlDir, { recursive: true });
|
|
52397
52397
|
const filename = `nats-genie-${Date.now()}-${payload.chatId}.json`;
|
|
52398
|
-
await writeFile(
|
|
52398
|
+
await writeFile(join13(dlDir, filename), JSON.stringify({
|
|
52399
52399
|
payload,
|
|
52400
52400
|
error: error2 instanceof Error ? error2.message : String(error2),
|
|
52401
52401
|
timestamp: new Date().toISOString()
|
|
@@ -54258,7 +54258,7 @@ var init_sql = __esm(() => {
|
|
|
54258
54258
|
return new SQL([new StringChunk(str)]);
|
|
54259
54259
|
}
|
|
54260
54260
|
sql2.raw = raw2;
|
|
54261
|
-
function
|
|
54261
|
+
function join14(chunks, separator) {
|
|
54262
54262
|
const result = [];
|
|
54263
54263
|
for (const [i2, chunk] of chunks.entries()) {
|
|
54264
54264
|
if (i2 > 0 && separator !== undefined) {
|
|
@@ -54268,7 +54268,7 @@ var init_sql = __esm(() => {
|
|
|
54268
54268
|
}
|
|
54269
54269
|
return new SQL(result);
|
|
54270
54270
|
}
|
|
54271
|
-
sql2.join =
|
|
54271
|
+
sql2.join = join14;
|
|
54272
54272
|
function identifier(value) {
|
|
54273
54273
|
return new Name(value);
|
|
54274
54274
|
}
|
|
@@ -57495,7 +57495,7 @@ var init_select2 = __esm(() => {
|
|
|
57495
57495
|
return (table2, on) => {
|
|
57496
57496
|
const baseTableName = this.tableName;
|
|
57497
57497
|
const tableName = getTableLikeName(table2);
|
|
57498
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
57498
|
+
if (typeof tableName === "string" && this.config.joins?.some((join14) => join14.alias === tableName)) {
|
|
57499
57499
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
57500
57500
|
}
|
|
57501
57501
|
if (!this.isPartialSelect) {
|
|
@@ -58006,7 +58006,7 @@ var init_update = __esm(() => {
|
|
|
58006
58006
|
createJoin(joinType) {
|
|
58007
58007
|
return (table2, on) => {
|
|
58008
58008
|
const tableName = getTableLikeName(table2);
|
|
58009
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
58009
|
+
if (typeof tableName === "string" && this.config.joins.some((join14) => join14.alias === tableName)) {
|
|
58010
58010
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
58011
58011
|
}
|
|
58012
58012
|
if (typeof on === "function") {
|
|
@@ -58056,10 +58056,10 @@ var init_update = __esm(() => {
|
|
|
58056
58056
|
const fromFields = this.getTableLikeFields(this.config.from);
|
|
58057
58057
|
fields[tableName] = fromFields;
|
|
58058
58058
|
}
|
|
58059
|
-
for (const
|
|
58060
|
-
const tableName2 = getTableLikeName(
|
|
58061
|
-
if (typeof tableName2 === "string" && !is(
|
|
58062
|
-
const fromFields = this.getTableLikeFields(
|
|
58059
|
+
for (const join14 of this.config.joins) {
|
|
58060
|
+
const tableName2 = getTableLikeName(join14.table);
|
|
58061
|
+
if (typeof tableName2 === "string" && !is(join14.table, SQL)) {
|
|
58062
|
+
const fromFields = this.getTableLikeFields(join14.table);
|
|
58063
58063
|
fields[tableName2] = fromFields;
|
|
58064
58064
|
}
|
|
58065
58065
|
}
|
|
@@ -78195,7 +78195,7 @@ var require_path = __commonJS((exports) => {
|
|
|
78195
78195
|
function isAbsolute(path) {
|
|
78196
78196
|
return path.charAt(0) === "/";
|
|
78197
78197
|
}
|
|
78198
|
-
function
|
|
78198
|
+
function join16(...args) {
|
|
78199
78199
|
return normalizePath(args.join("/"));
|
|
78200
78200
|
}
|
|
78201
78201
|
function dirname6(path) {
|
|
@@ -78220,7 +78220,7 @@ var require_path = __commonJS((exports) => {
|
|
|
78220
78220
|
exports.basename = basename6;
|
|
78221
78221
|
exports.dirname = dirname6;
|
|
78222
78222
|
exports.isAbsolute = isAbsolute;
|
|
78223
|
-
exports.join =
|
|
78223
|
+
exports.join = join16;
|
|
78224
78224
|
exports.normalizePath = normalizePath;
|
|
78225
78225
|
exports.relative = relative;
|
|
78226
78226
|
exports.resolve = resolve4;
|
|
@@ -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.2",
|
|
114181
114181
|
description: "LLM-optimized CLI for Omni",
|
|
114182
114182
|
type: "module",
|
|
114183
114183
|
bin: {
|
|
@@ -117717,9 +117717,9 @@ function createDeadLettersCommand() {
|
|
|
117717
117717
|
}
|
|
117718
117718
|
|
|
117719
117719
|
// src/commands/doctor.ts
|
|
117720
|
-
import { existsSync as
|
|
117721
|
-
import { homedir as
|
|
117722
|
-
import { join as
|
|
117720
|
+
import { existsSync as existsSync7, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
117721
|
+
import { homedir as homedir6 } from "os";
|
|
117722
|
+
import { join as join10, resolve } from "path";
|
|
117723
117723
|
init_config();
|
|
117724
117724
|
|
|
117725
117725
|
// src/health.ts
|
|
@@ -118830,6 +118830,11 @@ WantedBy=multi-user.target
|
|
|
118830
118830
|
// src/lib/canonical-pgserve.ts
|
|
118831
118831
|
init_config();
|
|
118832
118832
|
init_output();
|
|
118833
|
+
import { spawnSync } from "child_process";
|
|
118834
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync4, renameSync, statSync, writeFileSync as writeFileSync5 } from "fs";
|
|
118835
|
+
import { homedir as homedir5 } from "os";
|
|
118836
|
+
import { join as join8 } from "path";
|
|
118837
|
+
import { gunzipSync, gzipSync } from "zlib";
|
|
118833
118838
|
var PGSERVE_REQUIRED_VERSION = "^2.1.0";
|
|
118834
118839
|
async function isPgserveInstalled() {
|
|
118835
118840
|
try {
|
|
@@ -118923,30 +118928,148 @@ async function resolveCanonicalPgservePreference(isReinstall, cfg) {
|
|
|
118923
118928
|
raw("");
|
|
118924
118929
|
return true;
|
|
118925
118930
|
}
|
|
118931
|
+
var OMNI_EMBEDDED_PGSERVE_DATA_DIR = join8(homedir5(), ".omni", "data", "pgserve");
|
|
118932
|
+
var PGSERVE_DEFAULT_DATA_DIR = join8(homedir5(), ".pgserve", "data");
|
|
118933
|
+
var PGSERVE_CONFIG_PATH = join8(homedir5(), ".pgserve", "config.json");
|
|
118934
|
+
var OMNI_BACKUPS_DIR = join8(homedir5(), ".omni", "backups");
|
|
118935
|
+
function getEmbeddedPgserveDataDir() {
|
|
118936
|
+
return OMNI_EMBEDDED_PGSERVE_DATA_DIR;
|
|
118937
|
+
}
|
|
118938
|
+
function getCanonicalPgserveDataDir() {
|
|
118939
|
+
if (!existsSync6(PGSERVE_CONFIG_PATH))
|
|
118940
|
+
return PGSERVE_DEFAULT_DATA_DIR;
|
|
118941
|
+
try {
|
|
118942
|
+
const raw2 = readFileSync4(PGSERVE_CONFIG_PATH, "utf8");
|
|
118943
|
+
const parsed = JSON.parse(raw2);
|
|
118944
|
+
return typeof parsed.dataDir === "string" && parsed.dataDir.length > 0 ? parsed.dataDir : PGSERVE_DEFAULT_DATA_DIR;
|
|
118945
|
+
} catch {
|
|
118946
|
+
return PGSERVE_DEFAULT_DATA_DIR;
|
|
118947
|
+
}
|
|
118948
|
+
}
|
|
118949
|
+
function looksLikePgDataDir(path) {
|
|
118950
|
+
return existsSync6(join8(path, "PG_VERSION")) && existsSync6(join8(path, "base"));
|
|
118951
|
+
}
|
|
118952
|
+
function getSnapshotPath(timestamp = new Date) {
|
|
118953
|
+
const ts = timestamp.toISOString().replace(/[:.]/g, "-");
|
|
118954
|
+
return join8(OMNI_BACKUPS_DIR, `embedded-migration-${ts}.sql.gz`);
|
|
118955
|
+
}
|
|
118956
|
+
function commandIsAvailable(cmd) {
|
|
118957
|
+
try {
|
|
118958
|
+
const result = spawnSync(cmd, ["--version"], { stdio: ["ignore", "pipe", "pipe"], timeout: 3000 });
|
|
118959
|
+
return result.status === 0;
|
|
118960
|
+
} catch {
|
|
118961
|
+
return false;
|
|
118962
|
+
}
|
|
118963
|
+
}
|
|
118964
|
+
function pgEnvFromUrl(url) {
|
|
118965
|
+
const parsed = new URL(url);
|
|
118966
|
+
const env2 = {
|
|
118967
|
+
PGHOST: parsed.hostname,
|
|
118968
|
+
PGUSER: decodeURIComponent(parsed.username || "postgres"),
|
|
118969
|
+
PGDATABASE: parsed.pathname.replace(/^\//, "") || "omni"
|
|
118970
|
+
};
|
|
118971
|
+
if (parsed.port)
|
|
118972
|
+
env2.PGPORT = parsed.port;
|
|
118973
|
+
if (parsed.password)
|
|
118974
|
+
env2.PGPASSWORD = decodeURIComponent(parsed.password);
|
|
118975
|
+
return env2;
|
|
118976
|
+
}
|
|
118977
|
+
async function dumpEmbeddedDb(currentDatabaseUrl) {
|
|
118978
|
+
const embeddedDir = getEmbeddedPgserveDataDir();
|
|
118979
|
+
if (!existsSync6(embeddedDir)) {
|
|
118980
|
+
return { status: "no-embedded-data", embeddedDir };
|
|
118981
|
+
}
|
|
118982
|
+
if (!looksLikePgDataDir(embeddedDir)) {
|
|
118983
|
+
warn(`Embedded pgserve dir at ${embeddedDir} is missing PG_VERSION or base/ \u2014 does not look like a Postgres data dir. Skipping dump; canonical will start empty.`);
|
|
118984
|
+
return { status: "embedded-data-invalid", embeddedDir };
|
|
118985
|
+
}
|
|
118986
|
+
if (!commandIsAvailable("pg_dump")) {
|
|
118987
|
+
throw new Error("pg_dump not found in PATH \u2014 install postgresql-client (apt install postgresql-client / brew install postgresql) and retry");
|
|
118988
|
+
}
|
|
118989
|
+
const snapshotPath = getSnapshotPath();
|
|
118990
|
+
mkdirSync4(OMNI_BACKUPS_DIR, { recursive: true, mode: 448 });
|
|
118991
|
+
raw(" Dumping embedded database via pg_dump...");
|
|
118992
|
+
raw(` source data dir: ${embeddedDir}`);
|
|
118993
|
+
raw(` snapshot: ${snapshotPath}`);
|
|
118994
|
+
const result = spawnSync("pg_dump", ["--no-owner", "--no-acl", "--clean", "--if-exists"], {
|
|
118995
|
+
env: { ...process.env, ...pgEnvFromUrl(currentDatabaseUrl) },
|
|
118996
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
118997
|
+
timeout: 600000,
|
|
118998
|
+
maxBuffer: 1024 * 1024 * 1024 * 4
|
|
118999
|
+
});
|
|
119000
|
+
if (result.status !== 0) {
|
|
119001
|
+
const stderr = result.stderr?.toString().trim() || "unknown error";
|
|
119002
|
+
throw new Error(`pg_dump failed (exit ${result.status}): ${stderr}`);
|
|
119003
|
+
}
|
|
119004
|
+
const compressed = gzipSync(result.stdout);
|
|
119005
|
+
const tmpPath = `${snapshotPath}.tmp`;
|
|
119006
|
+
writeFileSync5(tmpPath, compressed, { mode: 384 });
|
|
119007
|
+
renameSync(tmpPath, snapshotPath);
|
|
119008
|
+
const bytes = statSync(snapshotPath).size;
|
|
119009
|
+
raw(` snapshot size: ${formatBytes(bytes)}`);
|
|
119010
|
+
await Promise.resolve();
|
|
119011
|
+
return { status: "dumped", embeddedDir, snapshotPath, bytes };
|
|
119012
|
+
}
|
|
119013
|
+
async function restoreSnapshotToCanonical(dump, canonicalDatabaseUrl) {
|
|
119014
|
+
if (dump.status !== "dumped") {
|
|
119015
|
+
return { status: "skipped" };
|
|
119016
|
+
}
|
|
119017
|
+
if (!commandIsAvailable("psql")) {
|
|
119018
|
+
throw new Error("psql not found in PATH \u2014 install postgresql-client (apt install postgresql-client / brew install postgresql) and retry");
|
|
119019
|
+
}
|
|
119020
|
+
raw(" Restoring snapshot into canonical pgserve via psql...");
|
|
119021
|
+
raw(` snapshot: ${dump.snapshotPath}`);
|
|
119022
|
+
raw(` canonical data dir: ${getCanonicalPgserveDataDir()}`);
|
|
119023
|
+
raw(` canonical URL: ${canonicalDatabaseUrl}`);
|
|
119024
|
+
const compressed = readFileSync4(dump.snapshotPath);
|
|
119025
|
+
const sql = gunzipSync(compressed);
|
|
119026
|
+
const result = spawnSync("psql", ["-v", "ON_ERROR_STOP=1"], {
|
|
119027
|
+
env: { ...process.env, ...pgEnvFromUrl(canonicalDatabaseUrl) },
|
|
119028
|
+
input: sql,
|
|
119029
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
119030
|
+
timeout: 600000,
|
|
119031
|
+
maxBuffer: 1024 * 1024 * 1024 * 4
|
|
119032
|
+
});
|
|
119033
|
+
if (result.status !== 0) {
|
|
119034
|
+
const stderr = result.stderr?.toString().trim() || "unknown error";
|
|
119035
|
+
throw new Error(`psql restore failed (exit ${result.status}): ${stderr}`);
|
|
119036
|
+
}
|
|
119037
|
+
await Promise.resolve();
|
|
119038
|
+
return { status: "restored", snapshotPath: dump.snapshotPath };
|
|
119039
|
+
}
|
|
119040
|
+
function formatBytes(n) {
|
|
119041
|
+
if (n < 1024)
|
|
119042
|
+
return `${n} B`;
|
|
119043
|
+
if (n < 1024 * 1024)
|
|
119044
|
+
return `${(n / 1024).toFixed(1)} KB`;
|
|
119045
|
+
if (n < 1024 * 1024 * 1024)
|
|
119046
|
+
return `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
119047
|
+
return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`;
|
|
119048
|
+
}
|
|
118926
119049
|
|
|
118927
119050
|
// src/commands/doctor.ts
|
|
118928
119051
|
init_output();
|
|
118929
119052
|
|
|
118930
119053
|
// src/server-bundle.ts
|
|
118931
119054
|
init_output();
|
|
118932
|
-
import { dirname as dirname2, join as
|
|
119055
|
+
import { dirname as dirname2, join as join9 } from "path";
|
|
118933
119056
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
118934
119057
|
function getServerBundlePath() {
|
|
118935
119058
|
try {
|
|
118936
119059
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
118937
119060
|
const distDir = dirname2(thisFile);
|
|
118938
|
-
return
|
|
119061
|
+
return join9(distDir, "server", "index.js");
|
|
118939
119062
|
} catch {
|
|
118940
|
-
return
|
|
119063
|
+
return join9(process.cwd(), "dist", "server", "index.js");
|
|
118941
119064
|
}
|
|
118942
119065
|
}
|
|
118943
119066
|
function getServerLauncherPath() {
|
|
118944
119067
|
try {
|
|
118945
119068
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
118946
119069
|
const distDir = dirname2(thisFile);
|
|
118947
|
-
return
|
|
119070
|
+
return join9(distDir, "..", "bin", "omni-server");
|
|
118948
119071
|
} catch {
|
|
118949
|
-
return
|
|
119072
|
+
return join9(process.cwd(), "bin", "omni-server");
|
|
118950
119073
|
}
|
|
118951
119074
|
}
|
|
118952
119075
|
function bundleNotFoundError(bundlePath) {
|
|
@@ -119011,10 +119134,10 @@ function productionDeps() {
|
|
|
119011
119134
|
}
|
|
119012
119135
|
},
|
|
119013
119136
|
findOrphanedDataDirs: () => {
|
|
119014
|
-
const roots = [process.cwd(),
|
|
119137
|
+
const roots = [process.cwd(), join10(homedir6(), "workspace"), join10(homedir6(), "repos")];
|
|
119015
119138
|
const found = [];
|
|
119016
119139
|
for (const root of roots) {
|
|
119017
|
-
if (!
|
|
119140
|
+
if (!existsSync7(root))
|
|
119018
119141
|
continue;
|
|
119019
119142
|
try {
|
|
119020
119143
|
scanForOrphans(root, found, 0);
|
|
@@ -119080,6 +119203,9 @@ function productionDeps() {
|
|
|
119080
119203
|
},
|
|
119081
119204
|
cliHasSigningKey: () => loadSigningContext() !== null,
|
|
119082
119205
|
setupCanonicalPgserve,
|
|
119206
|
+
dumpEmbeddedDb,
|
|
119207
|
+
restoreSnapshotToCanonical,
|
|
119208
|
+
getCanonicalPgserveDataDir,
|
|
119083
119209
|
saveServerConfig
|
|
119084
119210
|
};
|
|
119085
119211
|
}
|
|
@@ -119095,10 +119221,10 @@ function scanForOrphans(dir, acc, depth, maxDepth = 4) {
|
|
|
119095
119221
|
for (const name of entries) {
|
|
119096
119222
|
if (name === "node_modules" || name === ".git")
|
|
119097
119223
|
continue;
|
|
119098
|
-
const full =
|
|
119224
|
+
const full = join10(dir, name);
|
|
119099
119225
|
let stats;
|
|
119100
119226
|
try {
|
|
119101
|
-
stats =
|
|
119227
|
+
stats = statSync2(full);
|
|
119102
119228
|
} catch {
|
|
119103
119229
|
continue;
|
|
119104
119230
|
}
|
|
@@ -119351,12 +119477,26 @@ async function fixCliKeyValid(deps) {
|
|
|
119351
119477
|
}
|
|
119352
119478
|
async function fixPgserveCanonical(deps) {
|
|
119353
119479
|
const { serverConfig, cliConfig } = deps.loadState();
|
|
119480
|
+
let dumpResult;
|
|
119481
|
+
try {
|
|
119482
|
+
dumpResult = await deps.dumpEmbeddedDb(serverConfig.databaseUrl);
|
|
119483
|
+
} catch (err) {
|
|
119484
|
+
throw new Error(`pg_dump of embedded omni DB failed (${err instanceof Error ? err.message : String(err)}); omni-api still running on embedded \u2014 install postgresql-client (apt install postgresql-client) if pg_dump is missing, then retry`);
|
|
119485
|
+
}
|
|
119354
119486
|
await deps.runPm2(["stop", PM2_PROCESSES.api]);
|
|
119355
119487
|
const url = await deps.setupCanonicalPgserve();
|
|
119356
119488
|
if (!url) {
|
|
119357
119489
|
await deps.runPm2(["start", PM2_PROCESSES.api]);
|
|
119358
119490
|
throw new Error("canonical pgserve setup failed (pgserve binary unavailable or install failed) \u2014 install manually: bun add -g pgserve@^2.1.0");
|
|
119359
119491
|
}
|
|
119492
|
+
let restoreOutcome;
|
|
119493
|
+
try {
|
|
119494
|
+
restoreOutcome = await deps.restoreSnapshotToCanonical(dumpResult, url);
|
|
119495
|
+
} catch (err) {
|
|
119496
|
+
await deps.runPm2(["start", PM2_PROCESSES.api]);
|
|
119497
|
+
const snapshotHint = dumpResult.status === "dumped" ? ` snapshot preserved at ${dumpResult.snapshotPath}` : "";
|
|
119498
|
+
throw new Error(`psql restore into canonical pgserve failed (${err instanceof Error ? err.message : String(err)}); omni-api restarted on embedded \u2014${snapshotHint} retry by replaying the dump manually or re-running \`omni doctor --fix\``);
|
|
119499
|
+
}
|
|
119360
119500
|
deps.saveServerConfig({ databaseUrl: url, useCanonicalPgserve: true });
|
|
119361
119501
|
const env2 = buildRuntimeEnv({ ...serverConfig, databaseUrl: url, useCanonicalPgserve: true }, cliConfig);
|
|
119362
119502
|
await deps.runPm2(["delete", PM2_PROCESSES.api], env2);
|
|
@@ -119370,7 +119510,9 @@ async function fixPgserveCanonical(deps) {
|
|
|
119370
119510
|
if (startCode !== 0) {
|
|
119371
119511
|
throw new Error(`pm2 start ${PM2_PROCESSES.api} exited ${startCode} after canonical migration`);
|
|
119372
119512
|
}
|
|
119373
|
-
|
|
119513
|
+
const canonicalDir = deps.getCanonicalPgserveDataDir();
|
|
119514
|
+
const dataNote = dumpResult.status === "dumped" && restoreOutcome.status === "restored" ? `restored ${dumpResult.snapshotPath} into ${canonicalDir} (omni-api \u2192 ${url})` : dumpResult.status === "no-embedded-data" ? `no embedded data to migrate; canonical started empty at ${canonicalDir} (omni-api \u2192 ${url})` : `embedded data dir invalid; canonical started empty at ${canonicalDir} (omni-api \u2192 ${url})`;
|
|
119515
|
+
return `migrated to canonical pgserve@^2.1.0; ${dataNote}`;
|
|
119374
119516
|
}
|
|
119375
119517
|
function fixOrphanedDataDirs(deps) {
|
|
119376
119518
|
const found = deps.findOrphanedDataDirs();
|
|
@@ -119570,7 +119712,7 @@ Safety:
|
|
|
119570
119712
|
}
|
|
119571
119713
|
|
|
119572
119714
|
// src/commands/done.ts
|
|
119573
|
-
import { existsSync as
|
|
119715
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
|
|
119574
119716
|
import { basename, extname } from "path";
|
|
119575
119717
|
|
|
119576
119718
|
// src/context.ts
|
|
@@ -119679,12 +119821,12 @@ async function handleReact(client, ctx, emoji) {
|
|
|
119679
119821
|
await closeTurn(client, "react", `Reacted ${emoji} + turn closed`);
|
|
119680
119822
|
}
|
|
119681
119823
|
async function handleMedia(client, ctx, mediaPath, caption) {
|
|
119682
|
-
if (!
|
|
119824
|
+
if (!existsSync8(mediaPath)) {
|
|
119683
119825
|
return error(`File not found: ${mediaPath}`);
|
|
119684
119826
|
}
|
|
119685
119827
|
try {
|
|
119686
119828
|
const mediaType = getMediaType(mediaPath);
|
|
119687
|
-
const buffer =
|
|
119829
|
+
const buffer = readFileSync5(mediaPath);
|
|
119688
119830
|
const base64 = buffer.toString("base64");
|
|
119689
119831
|
const filename = basename(mediaPath);
|
|
119690
119832
|
await client.messages.sendMedia({
|
|
@@ -120116,7 +120258,7 @@ function createEventsCommand() {
|
|
|
120116
120258
|
}
|
|
120117
120259
|
|
|
120118
120260
|
// src/commands/film.ts
|
|
120119
|
-
import { writeFileSync as
|
|
120261
|
+
import { writeFileSync as writeFileSync6 } from "fs";
|
|
120120
120262
|
import { resolve as resolvePath } from "path";
|
|
120121
120263
|
init_output();
|
|
120122
120264
|
function createFilmCommand() {
|
|
@@ -120180,7 +120322,7 @@ function createFilmCommand() {
|
|
|
120180
120322
|
const videoBuffer = Buffer.from(result.videoBase64, "base64");
|
|
120181
120323
|
if (options.output) {
|
|
120182
120324
|
const outPath = resolvePath(options.output);
|
|
120183
|
-
|
|
120325
|
+
writeFileSync6(outPath, videoBuffer);
|
|
120184
120326
|
success("Video saved", { path: outPath, sizeBytes: videoBuffer.length });
|
|
120185
120327
|
return;
|
|
120186
120328
|
}
|
|
@@ -120204,7 +120346,7 @@ function createFilmCommand() {
|
|
|
120204
120346
|
}
|
|
120205
120347
|
|
|
120206
120348
|
// src/commands/follow-up.ts
|
|
120207
|
-
import { readFileSync as
|
|
120349
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
120208
120350
|
init_output();
|
|
120209
120351
|
var VALID_SCOPES = ["agents", "instances", "chats"];
|
|
120210
120352
|
function assertScope(scope) {
|
|
@@ -120222,9 +120364,9 @@ async function resolveScopedId(scope, id) {
|
|
|
120222
120364
|
function readJsonArg(raw2) {
|
|
120223
120365
|
let body = raw2;
|
|
120224
120366
|
if (body === "-") {
|
|
120225
|
-
body =
|
|
120367
|
+
body = readFileSync6(0, "utf8");
|
|
120226
120368
|
} else if (body.startsWith("@")) {
|
|
120227
|
-
body =
|
|
120369
|
+
body = readFileSync6(body.slice(1), "utf8");
|
|
120228
120370
|
}
|
|
120229
120371
|
try {
|
|
120230
120372
|
return JSON.parse(body);
|
|
@@ -120376,8 +120518,8 @@ function createHistoryCommand() {
|
|
|
120376
120518
|
}
|
|
120377
120519
|
|
|
120378
120520
|
// src/commands/imagine.ts
|
|
120379
|
-
import { writeFileSync as
|
|
120380
|
-
import { basename as basename2, dirname as dirname3, extname as extname2, join as
|
|
120521
|
+
import { writeFileSync as writeFileSync7 } from "fs";
|
|
120522
|
+
import { basename as basename2, dirname as dirname3, extname as extname2, join as join11 } from "path";
|
|
120381
120523
|
init_output();
|
|
120382
120524
|
var ALLOWED_ASPECT_RATIOS = ["1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3"];
|
|
120383
120525
|
function extensionForMime(mimeType) {
|
|
@@ -120392,9 +120534,9 @@ function buildOutputPath(outputBase, index, total, mimeType) {
|
|
|
120392
120534
|
const ext = extname2(outputBase) || extensionForMime(mimeType);
|
|
120393
120535
|
const stem = basename2(outputBase, extname2(outputBase));
|
|
120394
120536
|
if (total <= 1) {
|
|
120395
|
-
return
|
|
120537
|
+
return join11(dir, `${stem}${ext}`);
|
|
120396
120538
|
}
|
|
120397
|
-
return
|
|
120539
|
+
return join11(dir, `${stem}-${index + 1}${ext}`);
|
|
120398
120540
|
}
|
|
120399
120541
|
function parseAspectRatio(value) {
|
|
120400
120542
|
if (!value)
|
|
@@ -120467,7 +120609,7 @@ function createImagineCommand() {
|
|
|
120467
120609
|
continue;
|
|
120468
120610
|
const path = buildOutputPath(options.output, i, result.images.length, image.mimeType);
|
|
120469
120611
|
try {
|
|
120470
|
-
|
|
120612
|
+
writeFileSync7(path, Buffer.from(image.base64, "base64"));
|
|
120471
120613
|
savedPaths.push(path);
|
|
120472
120614
|
} catch (err) {
|
|
120473
120615
|
const message = err instanceof Error ? err.message : "Unknown error";
|
|
@@ -120512,12 +120654,12 @@ function createImagineCommand() {
|
|
|
120512
120654
|
}
|
|
120513
120655
|
|
|
120514
120656
|
// src/commands/install.ts
|
|
120515
|
-
import { existsSync as
|
|
120516
|
-
import { homedir as
|
|
120517
|
-
import { join as
|
|
120657
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync5 } from "fs";
|
|
120658
|
+
import { homedir as homedir7 } from "os";
|
|
120659
|
+
import { join as join12 } from "path";
|
|
120518
120660
|
init_config();
|
|
120519
120661
|
init_output();
|
|
120520
|
-
var DEFAULT_DATA_DIR2 =
|
|
120662
|
+
var DEFAULT_DATA_DIR2 = join12(homedir7(), ".omni", "data");
|
|
120521
120663
|
function computeDefaultDatabaseUrl() {
|
|
120522
120664
|
return buildEmbeddedDatabaseUrl();
|
|
120523
120665
|
}
|
|
@@ -120616,13 +120758,13 @@ async function startServices(cfg, forceCleanup, forceSystemd, useCanonicalPgserv
|
|
|
120616
120758
|
return false;
|
|
120617
120759
|
}
|
|
120618
120760
|
const bundlePath = getServerBundlePath();
|
|
120619
|
-
if (!
|
|
120761
|
+
if (!existsSync9(bundlePath)) {
|
|
120620
120762
|
warn(`Server bundle not found at: ${bundlePath}
|
|
120621
120763
|
Install @automagik/omni from npm: bun add -g @automagik/omni
|
|
120622
120764
|
Or build locally: make cli-build-full`);
|
|
120623
120765
|
return false;
|
|
120624
120766
|
}
|
|
120625
|
-
|
|
120767
|
+
mkdirSync5(getPm2LogDir(), { recursive: true });
|
|
120626
120768
|
await installPm2Logrotate();
|
|
120627
120769
|
const runtimeEnv = buildInstallRuntimeEnv(cfg, forceCleanup, useCanonicalPgserve);
|
|
120628
120770
|
await runPm2(["delete", PM2_PROCESSES.api]);
|
|
@@ -120640,10 +120782,10 @@ async function startServices(cfg, forceCleanup, forceSystemd, useCanonicalPgserv
|
|
|
120640
120782
|
return false;
|
|
120641
120783
|
}
|
|
120642
120784
|
apiSpinner.succeed(`${PM2_PROCESSES.api} started`);
|
|
120643
|
-
if (
|
|
120785
|
+
if (existsSync9(NATS_BINARY_PATH)) {
|
|
120644
120786
|
const natsSpinner = ora(`Starting ${PM2_PROCESSES.nats}...`).start();
|
|
120645
|
-
const natsDataDir =
|
|
120646
|
-
|
|
120787
|
+
const natsDataDir = join12(cfg.dataDir, "nats");
|
|
120788
|
+
mkdirSync5(natsDataDir, { recursive: true });
|
|
120647
120789
|
const natsArgs = buildPm2StartArgs({
|
|
120648
120790
|
kind: "nats",
|
|
120649
120791
|
script: NATS_BINARY_PATH,
|
|
@@ -122319,7 +122461,7 @@ function createLogsCommand() {
|
|
|
122319
122461
|
}
|
|
122320
122462
|
|
|
122321
122463
|
// src/commands/media.ts
|
|
122322
|
-
import { createWriteStream as createWriteStream2, existsSync as
|
|
122464
|
+
import { createWriteStream as createWriteStream2, existsSync as existsSync11, mkdirSync as mkdirSync7, statSync as statSync4 } from "fs";
|
|
122323
122465
|
import { basename as basename4, dirname as dirname4, resolve as resolve2 } from "path";
|
|
122324
122466
|
import { Readable } from "stream";
|
|
122325
122467
|
import { pipeline } from "stream/promises";
|
|
@@ -122382,14 +122524,14 @@ function resolveOutputPath(outputPath, result) {
|
|
|
122382
122524
|
const resolved = resolve2(outputPath);
|
|
122383
122525
|
if (isDirHint)
|
|
122384
122526
|
return resolve2(resolved, filename);
|
|
122385
|
-
if (
|
|
122527
|
+
if (existsSync11(resolved) && statSync4(resolved).isDirectory())
|
|
122386
122528
|
return resolve2(resolved, filename);
|
|
122387
122529
|
return resolved;
|
|
122388
122530
|
}
|
|
122389
122531
|
async function downloadToFile(url, apiKey, destinationPath) {
|
|
122390
122532
|
const destDir = dirname4(destinationPath);
|
|
122391
|
-
if (!
|
|
122392
|
-
|
|
122533
|
+
if (!existsSync11(destDir))
|
|
122534
|
+
mkdirSync7(destDir, { recursive: true });
|
|
122393
122535
|
const resp = await fetch(url, {
|
|
122394
122536
|
method: "GET",
|
|
122395
122537
|
headers: apiKey ? { "x-api-key": apiKey } : undefined
|
|
@@ -123342,8 +123484,8 @@ init_output();
|
|
|
123342
123484
|
init_src();
|
|
123343
123485
|
import { execFileSync as execFileSync2, execSync } from "child_process";
|
|
123344
123486
|
import * as nodeCrypto2 from "crypto";
|
|
123345
|
-
import { existsSync as
|
|
123346
|
-
import { homedir as
|
|
123487
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "fs";
|
|
123488
|
+
import { homedir as homedir9 } from "os";
|
|
123347
123489
|
import { dirname as dirname5, resolve as resolve3 } from "path";
|
|
123348
123490
|
import { createInterface as createInterface2 } from "readline";
|
|
123349
123491
|
init_config();
|
|
@@ -123570,19 +123712,19 @@ async function pairDevice(gatewayUrl, gatewayToken, keypair, spinner) {
|
|
|
123570
123712
|
ws.close(1000, "pairing complete");
|
|
123571
123713
|
}
|
|
123572
123714
|
}
|
|
123573
|
-
var OPENCLAW_CONFIG_PATH = resolve3(
|
|
123715
|
+
var OPENCLAW_CONFIG_PATH = resolve3(homedir9(), ".openclaw", "openclaw.json");
|
|
123574
123716
|
var PLUGIN_MARKER = "plugin-openclaw/omni.ts";
|
|
123575
123717
|
function readOpenClawConfig(configPath) {
|
|
123576
|
-
if (!
|
|
123718
|
+
if (!existsSync12(configPath))
|
|
123577
123719
|
return {};
|
|
123578
|
-
const raw2 =
|
|
123720
|
+
const raw2 = readFileSync8(configPath, "utf-8").trim();
|
|
123579
123721
|
if (!raw2)
|
|
123580
123722
|
return {};
|
|
123581
123723
|
return JSON.parse(raw2);
|
|
123582
123724
|
}
|
|
123583
123725
|
function writeOpenClawConfig(configPath, config2) {
|
|
123584
|
-
|
|
123585
|
-
|
|
123726
|
+
mkdirSync8(dirname5(configPath), { recursive: true, mode: 448 });
|
|
123727
|
+
writeFileSync8(configPath, `${JSON.stringify(config2, null, 2)}
|
|
123586
123728
|
`, { mode: 384 });
|
|
123587
123729
|
}
|
|
123588
123730
|
function isPluginRegistered(config2, marker, pluginPath) {
|
|
@@ -123614,10 +123756,10 @@ function isValidUuid2(value) {
|
|
|
123614
123756
|
}
|
|
123615
123757
|
function resolvePluginPath(explicit) {
|
|
123616
123758
|
if (explicit) {
|
|
123617
|
-
return
|
|
123759
|
+
return existsSync12(explicit) ? resolve3(explicit) : null;
|
|
123618
123760
|
}
|
|
123619
123761
|
const cwdCandidate = resolve3(process.cwd(), "packages/plugin-openclaw/omni.ts");
|
|
123620
|
-
return
|
|
123762
|
+
return existsSync12(cwdCandidate) ? cwdCandidate : null;
|
|
123621
123763
|
}
|
|
123622
123764
|
function registerPlugin(config2, pluginPath, configPath) {
|
|
123623
123765
|
if (hasOpenClawCli()) {
|
|
@@ -124506,7 +124648,7 @@ function createSayCommand() {
|
|
|
124506
124648
|
}
|
|
124507
124649
|
|
|
124508
124650
|
// src/commands/see.ts
|
|
124509
|
-
import { existsSync as
|
|
124651
|
+
import { existsSync as existsSync13, readFileSync as readFileSync9, statSync as statSync5 } from "fs";
|
|
124510
124652
|
import { extname as extname4 } from "path";
|
|
124511
124653
|
init_output();
|
|
124512
124654
|
var MIME_BY_EXT = {
|
|
@@ -124538,10 +124680,10 @@ function parseMaxTokens(value) {
|
|
|
124538
124680
|
return n3;
|
|
124539
124681
|
}
|
|
124540
124682
|
function loadMedia(file) {
|
|
124541
|
-
if (!
|
|
124683
|
+
if (!existsSync13(file)) {
|
|
124542
124684
|
error(`File not found: ${file}`);
|
|
124543
124685
|
}
|
|
124544
|
-
const stat =
|
|
124686
|
+
const stat = statSync5(file);
|
|
124545
124687
|
if (!stat.isFile()) {
|
|
124546
124688
|
error(`Not a regular file: ${file}`);
|
|
124547
124689
|
}
|
|
@@ -124549,7 +124691,7 @@ function loadMedia(file) {
|
|
|
124549
124691
|
error(`File is empty: ${file}`);
|
|
124550
124692
|
}
|
|
124551
124693
|
try {
|
|
124552
|
-
return { buffer:
|
|
124694
|
+
return { buffer: readFileSync9(file), mimeType: guessMimeType(file) };
|
|
124553
124695
|
} catch (err2) {
|
|
124554
124696
|
const message2 = err2 instanceof Error ? err2.message : "Unknown error";
|
|
124555
124697
|
return error(`Failed to read ${file}: ${message2}`);
|
|
@@ -124624,7 +124766,7 @@ function createSeeCommand() {
|
|
|
124624
124766
|
}
|
|
124625
124767
|
|
|
124626
124768
|
// src/commands/send.ts
|
|
124627
|
-
import { existsSync as
|
|
124769
|
+
import { existsSync as existsSync14, readFileSync as readFileSync10 } from "fs";
|
|
124628
124770
|
import { basename as basename5, extname as extname5 } from "path";
|
|
124629
124771
|
init_source();
|
|
124630
124772
|
init_config();
|
|
@@ -124644,7 +124786,7 @@ function getMediaType2(path) {
|
|
|
124644
124786
|
return "document";
|
|
124645
124787
|
}
|
|
124646
124788
|
function readFileAsBase64(path) {
|
|
124647
|
-
const buffer3 =
|
|
124789
|
+
const buffer3 = readFileSync10(path);
|
|
124648
124790
|
return buffer3.toString("base64");
|
|
124649
124791
|
}
|
|
124650
124792
|
var messageSenders = {
|
|
@@ -124665,7 +124807,7 @@ var messageSenders = {
|
|
|
124665
124807
|
const { to, media } = options3;
|
|
124666
124808
|
if (!to || !media)
|
|
124667
124809
|
return;
|
|
124668
|
-
if (!
|
|
124810
|
+
if (!existsSync14(media)) {
|
|
124669
124811
|
error(`File not found: ${media}`);
|
|
124670
124812
|
return;
|
|
124671
124813
|
}
|
|
@@ -125197,9 +125339,9 @@ function pickFilename(mimeType, provider) {
|
|
|
125197
125339
|
}
|
|
125198
125340
|
|
|
125199
125341
|
// src/commands/start.ts
|
|
125200
|
-
import { existsSync as
|
|
125201
|
-
import { homedir as
|
|
125202
|
-
import { join as
|
|
125342
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync9 } from "fs";
|
|
125343
|
+
import { homedir as homedir10 } from "os";
|
|
125344
|
+
import { join as join14 } from "path";
|
|
125203
125345
|
init_config();
|
|
125204
125346
|
init_output();
|
|
125205
125347
|
var START_HEALTH_TIMEOUT_MS = 1e4;
|
|
@@ -125208,12 +125350,12 @@ async function runStart() {
|
|
|
125208
125350
|
pm2NotFoundError();
|
|
125209
125351
|
}
|
|
125210
125352
|
const bundlePath = getServerBundlePath();
|
|
125211
|
-
if (!
|
|
125353
|
+
if (!existsSync15(bundlePath)) {
|
|
125212
125354
|
bundleNotFoundError(bundlePath);
|
|
125213
125355
|
}
|
|
125214
125356
|
const serverConfig = loadServerConfig();
|
|
125215
125357
|
const apiPort = serverConfig.port;
|
|
125216
|
-
|
|
125358
|
+
mkdirSync9(getPm2LogDir(), { recursive: true });
|
|
125217
125359
|
info(`Starting ${PM2_PROCESSES.api} (port ${apiPort})...`);
|
|
125218
125360
|
const cliConfig = loadConfig();
|
|
125219
125361
|
const env2 = buildRuntimeEnv(serverConfig, cliConfig);
|
|
@@ -125229,11 +125371,11 @@ async function runStart() {
|
|
|
125229
125371
|
error(`Failed to start ${PM2_PROCESSES.api} (pm2 exit code ${apiCode})`, undefined, 1);
|
|
125230
125372
|
return;
|
|
125231
125373
|
}
|
|
125232
|
-
const natsPath =
|
|
125233
|
-
if (
|
|
125374
|
+
const natsPath = join14(homedir10(), ".omni", "nats-server");
|
|
125375
|
+
if (existsSync15(natsPath)) {
|
|
125234
125376
|
info(`Starting ${PM2_PROCESSES.nats}...`);
|
|
125235
|
-
const natsDataDir =
|
|
125236
|
-
|
|
125377
|
+
const natsDataDir = join14(serverConfig.dataDir, "nats");
|
|
125378
|
+
mkdirSync9(natsDataDir, { recursive: true });
|
|
125237
125379
|
const natsArgs = buildPm2StartArgs({
|
|
125238
125380
|
kind: "nats",
|
|
125239
125381
|
script: natsPath,
|
|
@@ -126240,9 +126382,9 @@ function createVoiceCommand() {
|
|
|
126240
126382
|
const startTime = Date.now();
|
|
126241
126383
|
let saveDir = "";
|
|
126242
126384
|
if (opts.save) {
|
|
126243
|
-
const { mkdirSync:
|
|
126385
|
+
const { mkdirSync: mkdirSync10 } = await import("fs");
|
|
126244
126386
|
saveDir = opts.save;
|
|
126245
|
-
|
|
126387
|
+
mkdirSync10(saveDir, { recursive: true });
|
|
126246
126388
|
info(`Saving audio to: ${saveDir}`);
|
|
126247
126389
|
}
|
|
126248
126390
|
ws.onopen = () => {
|
|
@@ -126466,17 +126608,17 @@ init_config();
|
|
|
126466
126608
|
init_output();
|
|
126467
126609
|
|
|
126468
126610
|
// src/manifest-pin.ts
|
|
126469
|
-
import { existsSync as
|
|
126470
|
-
import { homedir as
|
|
126471
|
-
import { join as
|
|
126611
|
+
import { existsSync as existsSync16, readFileSync as readFileSync11, renameSync as renameSync3, writeFileSync as writeFileSync9 } from "fs";
|
|
126612
|
+
import { homedir as homedir11 } from "os";
|
|
126613
|
+
import { join as join15 } from "path";
|
|
126472
126614
|
var PACKAGE_NAME2 = "@automagik/omni";
|
|
126473
|
-
var BUN_GLOBAL_MANIFEST =
|
|
126615
|
+
var BUN_GLOBAL_MANIFEST = join15(homedir11(), ".bun", "install", "global", "package.json");
|
|
126474
126616
|
function pinManifestEntry(manifestPath, exactVersion) {
|
|
126475
|
-
if (!
|
|
126617
|
+
if (!existsSync16(manifestPath))
|
|
126476
126618
|
return false;
|
|
126477
126619
|
let manifest;
|
|
126478
126620
|
try {
|
|
126479
|
-
manifest = JSON.parse(
|
|
126621
|
+
manifest = JSON.parse(readFileSync11(manifestPath, "utf-8"));
|
|
126480
126622
|
} catch {
|
|
126481
126623
|
return false;
|
|
126482
126624
|
}
|
|
@@ -126502,9 +126644,9 @@ function pinManifestEntry(manifestPath, exactVersion) {
|
|
|
126502
126644
|
return false;
|
|
126503
126645
|
const tmp = `${manifestPath}.tmp.${process.pid}`;
|
|
126504
126646
|
try {
|
|
126505
|
-
|
|
126647
|
+
writeFileSync9(tmp, `${JSON.stringify(manifest, null, 2)}
|
|
126506
126648
|
`, { mode: 420 });
|
|
126507
|
-
|
|
126649
|
+
renameSync3(tmp, manifestPath);
|
|
126508
126650
|
} catch {
|
|
126509
126651
|
return false;
|
|
126510
126652
|
}
|
|
@@ -47,4 +47,59 @@ export declare function setupCanonicalPgserve(): Promise<string | null>;
|
|
|
47
47
|
export declare function resolveCanonicalPgservePreference(isReinstall: boolean, cfg: {
|
|
48
48
|
databaseUrl: string;
|
|
49
49
|
}): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the canonical pgserve data dir from `~/.pgserve/config.json`.
|
|
52
|
+
* pgserve writes `{dataDir, port, registeredAt}` during `pgserve install`.
|
|
53
|
+
* Falls back to `~/.pgserve/data` (pgserve's documented default) when the
|
|
54
|
+
* config file doesn't exist yet.
|
|
55
|
+
*
|
|
56
|
+
* Surfaced in operator output so the migration's destination is explicit:
|
|
57
|
+
* the operator can `du -sh` and `ls` that path post-migration to verify
|
|
58
|
+
* the cluster is on disk where they expect.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getCanonicalPgserveDataDir(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Outcome of the dump step. Caller decides whether to proceed with restore.
|
|
63
|
+
*/
|
|
64
|
+
export type EmbeddedDumpResult = {
|
|
65
|
+
status: 'no-embedded-data';
|
|
66
|
+
embeddedDir: string;
|
|
67
|
+
} | {
|
|
68
|
+
status: 'embedded-data-invalid';
|
|
69
|
+
embeddedDir: string;
|
|
70
|
+
} | {
|
|
71
|
+
status: 'dumped';
|
|
72
|
+
embeddedDir: string;
|
|
73
|
+
snapshotPath: string;
|
|
74
|
+
bytes: number;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Dump the embedded `omni` database to a gzipped SQL snapshot. Called BEFORE
|
|
78
|
+
* the caller stops omni-api — embedded pgserve must still be live so pg_dump
|
|
79
|
+
* can connect.
|
|
80
|
+
*
|
|
81
|
+
* Returns:
|
|
82
|
+
* - `no-embedded-data` when there's no embedded data dir (fresh install
|
|
83
|
+
* case — caller proceeds with an empty canonical).
|
|
84
|
+
* - `embedded-data-invalid` when the dir exists but isn't a Postgres data
|
|
85
|
+
* dir (corrupt / partial init — caller warns + proceeds empty).
|
|
86
|
+
* - `dumped` with snapshot path + size on success.
|
|
87
|
+
*
|
|
88
|
+
* Throws when pg_dump is missing from PATH or exits non-zero. Caller is
|
|
89
|
+
* responsible for catching and rolling back omni-api to embedded.
|
|
90
|
+
*/
|
|
91
|
+
export declare function dumpEmbeddedDb(currentDatabaseUrl: string): Promise<EmbeddedDumpResult>;
|
|
92
|
+
/**
|
|
93
|
+
* Restore a dumped snapshot into the canonical pgserve. Called AFTER the
|
|
94
|
+
* caller has run `pgserve install` and confirmed canonical is reachable
|
|
95
|
+
* at the URL. No-op when the snapshot status was anything but `dumped`.
|
|
96
|
+
*
|
|
97
|
+
* Uses `psql ON_ERROR_STOP=1` so a partial failure surfaces a non-zero exit
|
|
98
|
+
* instead of leaving the canonical DB half-restored. Throws on any psql
|
|
99
|
+
* error — caller rolls back to embedded.
|
|
100
|
+
*/
|
|
101
|
+
export declare function restoreSnapshotToCanonical(dump: EmbeddedDumpResult, canonicalDatabaseUrl: string): Promise<{
|
|
102
|
+
status: 'restored' | 'skipped';
|
|
103
|
+
snapshotPath?: string;
|
|
104
|
+
}>;
|
|
50
105
|
//# sourceMappingURL=canonical-pgserve.d.ts.map
|
|
@@ -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;AA2IH;;;;;;GAMG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASpE;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
|
@@ -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.2",
|
|
224658
224658
|
type: "module",
|
|
224659
224659
|
exports: {
|
|
224660
224660
|
".": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automagik/omni",
|
|
3
|
-
"version": "2.260501.
|
|
3
|
+
"version": "2.260501.2",
|
|
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.
|
|
55
|
-
"@omni/channel-discord": "2.
|
|
56
|
-
"@omni/channel-gupshup": "2.
|
|
57
|
-
"@omni/channel-sdk": "2.
|
|
58
|
-
"@omni/channel-slack": "2.
|
|
59
|
-
"@omni/channel-telegram": "2.
|
|
60
|
-
"@omni/channel-whatsapp": "2.
|
|
61
|
-
"@omni/core": "2.
|
|
62
|
-
"@omni/sdk": "2.
|
|
54
|
+
"@omni/api": "2.260501.1",
|
|
55
|
+
"@omni/channel-discord": "2.260501.1",
|
|
56
|
+
"@omni/channel-gupshup": "2.260501.1",
|
|
57
|
+
"@omni/channel-sdk": "2.260501.1",
|
|
58
|
+
"@omni/channel-slack": "2.260501.1",
|
|
59
|
+
"@omni/channel-telegram": "2.260501.1",
|
|
60
|
+
"@omni/channel-whatsapp": "2.260501.1",
|
|
61
|
+
"@omni/core": "2.260501.1",
|
|
62
|
+
"@omni/sdk": "2.260501.1",
|
|
63
63
|
"@types/node": "^22.10.3",
|
|
64
64
|
"@types/qrcode-terminal": "^0.12.2",
|
|
65
65
|
"typescript": "^5.7.3"
|