@automagik/omni 2.260525.1 → 2.260525.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.
package/dist/index.js CHANGED
@@ -4665,15 +4665,17 @@ var exports_embedded_canonical_migration = {};
4665
4665
  __export(exports_embedded_canonical_migration, {
4666
4666
  readDataDirMajor: () => readDataDirMajor,
4667
4667
  migrateUnmountedEmbeddedToCanonical: () => migrateUnmountedEmbeddedToCanonical,
4668
+ embeddedPostgresPackage: () => embeddedPostgresPackage,
4668
4669
  compareVersionDesc: () => compareVersionDesc,
4669
4670
  compareEmbeddedVsCanonicalCounts: () => compareEmbeddedVsCanonicalCounts,
4671
+ MIGRATION_SKIP_TABLES: () => MIGRATION_SKIP_TABLES,
4670
4672
  EMBEDDED_PGSERVE_DATA_DIR: () => EMBEDDED_PGSERVE_DATA_DIR
4671
4673
  });
4672
4674
  import { execFileSync as execFileSync3, spawn, spawnSync as spawnSync2 } from "child_process";
4673
- import { existsSync as existsSync9, mkdtempSync, readFileSync as readFileSync6 } from "fs";
4675
+ import { existsSync as existsSync9, mkdirSync as mkdirSync6, mkdtempSync, readFileSync as readFileSync6, readdirSync as readdirSync2, symlinkSync } from "fs";
4674
4676
  import { createServer } from "net";
4675
- import { homedir as homedir7, tmpdir } from "os";
4676
- import { join as join11 } from "path";
4677
+ import { arch, homedir as homedir7, platform, tmpdir } from "os";
4678
+ import { dirname as dirname2, join as join11 } from "path";
4677
4679
  import { setTimeout as sleep2 } from "timers/promises";
4678
4680
  function defaultLog(line) {
4679
4681
  process.stdout.write(`${line}
@@ -4724,12 +4726,94 @@ function compareVersionDesc(a, b) {
4724
4726
  }
4725
4727
  function safeReaddir(path) {
4726
4728
  try {
4727
- const { readdirSync: readdirSync2 } = __require("fs");
4728
4729
  return readdirSync2(path);
4729
4730
  } catch {
4730
4731
  return [];
4731
4732
  }
4732
4733
  }
4734
+ function embeddedPostgresPackage() {
4735
+ const a = arch() === "arm64" ? "arm64" : arch() === "x64" ? "x64" : null;
4736
+ if (!a)
4737
+ return null;
4738
+ if (platform() === "linux")
4739
+ return `@embedded-postgres/linux-${a}`;
4740
+ if (platform() === "darwin")
4741
+ return `@embedded-postgres/darwin-${a}`;
4742
+ if (platform() === "win32" && a === "x64")
4743
+ return "@embedded-postgres/windows-x64";
4744
+ return null;
4745
+ }
4746
+ function latestReaderVersion(pkg, major) {
4747
+ try {
4748
+ const raw2 = execFileSync3("npm", ["view", pkg, "versions", "--json"], { encoding: "utf8", timeout: 30000 });
4749
+ const versions = JSON.parse(raw2);
4750
+ const list2 = Array.isArray(versions) ? versions : [versions];
4751
+ const matching = list2.filter((v) => v.startsWith(`${major}.`)).sort(compareVersionDesc);
4752
+ return matching.length ? matching[0] : null;
4753
+ } catch {
4754
+ return null;
4755
+ }
4756
+ }
4757
+ function materializeReaderLibs(nativeDir) {
4758
+ const libDir = join11(nativeDir, "lib");
4759
+ try {
4760
+ const pkgRoot = dirname2(nativeDir);
4761
+ const pairs = JSON.parse(readFileSync6(join11(nativeDir, "pg-symlinks.json"), "utf8"));
4762
+ for (const { source, target } of pairs) {
4763
+ const tgt = join11(pkgRoot, target);
4764
+ if (!existsSync9(tgt)) {
4765
+ try {
4766
+ symlinkSync(join11(pkgRoot, source), tgt);
4767
+ } catch {}
4768
+ }
4769
+ }
4770
+ } catch {}
4771
+ for (const f of safeReaddir(libDir)) {
4772
+ const m = f.match(/^(.*\.so\.\d+)\.\d+/);
4773
+ if (!m)
4774
+ continue;
4775
+ const base = join11(libDir, m[1]);
4776
+ if (!existsSync9(base)) {
4777
+ try {
4778
+ symlinkSync(join11(libDir, f), base);
4779
+ } catch {}
4780
+ }
4781
+ }
4782
+ }
4783
+ function fetchEmbeddedReader(major, log) {
4784
+ const pkg = embeddedPostgresPackage();
4785
+ if (!pkg)
4786
+ return null;
4787
+ const cacheDir = join11(homedir7(), ".omni", "cache", `pg-reader-${major}`);
4788
+ const nativeDir = join11(cacheDir, "node_modules", pkg, "native");
4789
+ const binary = join11(nativeDir, "bin", "postgres");
4790
+ if (existsSync9(binary) && binaryMajor(binary) === major) {
4791
+ materializeReaderLibs(nativeDir);
4792
+ return { binary, libDir: join11(nativeDir, "lib") };
4793
+ }
4794
+ const version = latestReaderVersion(pkg, major);
4795
+ if (!version)
4796
+ return null;
4797
+ log(` fetching PG ${major} reader (${pkg}@${version}) \u2014 one-time, cached at ${cacheDir}`);
4798
+ try {
4799
+ mkdirSync6(cacheDir, { recursive: true });
4800
+ const res = spawnSync2("bun", ["add", `${pkg}@${version}`], { cwd: cacheDir, encoding: "utf8", timeout: 180000 });
4801
+ if (res.status !== 0 || !existsSync9(binary))
4802
+ return null;
4803
+ materializeReaderLibs(nativeDir);
4804
+ return binaryMajor(binary) === major ? { binary, libDir: join11(nativeDir, "lib") } : null;
4805
+ } catch {
4806
+ return null;
4807
+ }
4808
+ }
4809
+ function resolveReaderForMajor(wantMajor, log) {
4810
+ const installed = findAutopgPostgresBinary(wantMajor);
4811
+ if (installed)
4812
+ return { binary: installed };
4813
+ if (wantMajor === null)
4814
+ return null;
4815
+ return fetchEmbeddedReader(wantMajor, log);
4816
+ }
4733
4817
  async function findFreePort() {
4734
4818
  return new Promise((resolve, reject) => {
4735
4819
  const server = createServer();
@@ -4747,10 +4831,17 @@ async function findFreePort() {
4747
4831
  });
4748
4832
  });
4749
4833
  }
4750
- async function spawnTempPostmaster(binary, dataDir, port, log) {
4834
+ async function spawnTempPostmaster(reader, dataDir, port, log) {
4751
4835
  const socketDir = mkdtempSync(join11(tmpdir(), "omni-migrate-pg-"));
4752
4836
  log(` spawning temp postmaster: pid=\u2026 port=${port} socket=${socketDir}`);
4753
- const child = spawn(binary, [
4837
+ let env2 = process.env;
4838
+ if (reader.libDir) {
4839
+ const loaderVar = platform() === "darwin" ? "DYLD_LIBRARY_PATH" : platform() === "win32" ? "PATH" : "LD_LIBRARY_PATH";
4840
+ const sep = platform() === "win32" ? ";" : ":";
4841
+ const prev = process.env[loaderVar];
4842
+ env2 = { ...process.env, [loaderVar]: prev ? `${reader.libDir}${sep}${prev}` : reader.libDir };
4843
+ }
4844
+ const child = spawn(reader.binary, [
4754
4845
  "-D",
4755
4846
  dataDir,
4756
4847
  "-p",
@@ -4761,7 +4852,8 @@ async function spawnTempPostmaster(binary, dataDir, port, log) {
4761
4852
  `unix_socket_directories=${socketDir}`
4762
4853
  ], {
4763
4854
  stdio: ["ignore", "pipe", "pipe"],
4764
- detached: false
4855
+ detached: false,
4856
+ env: env2
4765
4857
  });
4766
4858
  let started = false;
4767
4859
  let crashed = null;
@@ -4804,6 +4896,19 @@ async function spawnTempPostmaster(binary, dataDir, port, log) {
4804
4896
  }
4805
4897
  };
4806
4898
  }
4899
+ function listTables(args) {
4900
+ return psqlCapture([...args, "-tAc", `SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename`]).split(`
4901
+ `).map((s) => s.trim()).filter(Boolean);
4902
+ }
4903
+ function listColumns(args, table, insertableOnly = false) {
4904
+ const filter = insertableOnly ? `AND is_generated <> 'ALWAYS'` : "";
4905
+ return psqlCapture([
4906
+ ...args,
4907
+ "-tAc",
4908
+ `SELECT column_name FROM information_schema.columns WHERE table_schema='public' AND table_name='${table}' ${filter} ORDER BY ordinal_position`
4909
+ ]).split(`
4910
+ `).map((s) => s.trim()).filter(Boolean);
4911
+ }
4807
4912
  function psqlCapture(args) {
4808
4913
  const result = spawnSync2("psql", args, {
4809
4914
  encoding: "utf-8",
@@ -4815,10 +4920,15 @@ function psqlCapture(args) {
4815
4920
  }
4816
4921
  return result.stdout ?? "";
4817
4922
  }
4818
- async function copyTable(table, srcArgs, dstArgs, log) {
4923
+ async function copyTable(table, columns, srcArgs, dstArgs, log) {
4924
+ if (columns.length === 0) {
4925
+ log(` skip ${table} (no shared columns)`);
4926
+ return;
4927
+ }
4928
+ const colList = columns.map((c2) => `"${c2}"`).join(", ");
4819
4929
  const tmpFile = join11(tmpdir(), `omni-migrate-${table}-${process.pid}.copy`);
4820
4930
  try {
4821
- const srcResult = spawnSync2("psql", [...srcArgs, "-c", `\\copy public.${table} TO '${tmpFile}' WITH (FORMAT binary)`], {
4931
+ const srcResult = spawnSync2("psql", [...srcArgs, "-c", `\\copy public."${table}" (${colList}) TO '${tmpFile}' WITH (FORMAT text)`], {
4822
4932
  stdio: ["ignore", "pipe", "pipe"],
4823
4933
  env: { ...process.env, PGPASSWORD: "postgres" },
4824
4934
  timeout: 600000,
@@ -4832,7 +4942,7 @@ async function copyTable(table, srcArgs, dstArgs, log) {
4832
4942
  "-c",
4833
4943
  `SET session_replication_role='replica';`,
4834
4944
  "-c",
4835
- `\\copy public.${table} FROM '${tmpFile}' WITH (FORMAT binary)`
4945
+ `\\copy public."${table}" (${colList}) FROM '${tmpFile}' WITH (FORMAT text)`
4836
4946
  ], {
4837
4947
  stdio: ["ignore", "pipe", "pipe"],
4838
4948
  env: { ...process.env, PGPASSWORD: "postgres" },
@@ -4875,17 +4985,17 @@ async function compareEmbeddedVsCanonicalCounts(opts = {}) {
4875
4985
  return { kind: "skipped", reason: "embedded dir absent" };
4876
4986
  }
4877
4987
  const wantMajor = readDataDirMajor(EMBEDDED_DIR);
4878
- const binary = findAutopgPostgresBinary(wantMajor);
4879
- if (!binary) {
4988
+ const reader = resolveReaderForMajor(wantMajor, () => {});
4989
+ if (!reader) {
4880
4990
  return {
4881
4991
  kind: "skipped",
4882
- reason: wantMajor ? `no PostgreSQL ${wantMajor} reader under ~/.local/share/autopg (embedded dir is PG ${wantMajor})` : "autopg postgres binary not found"
4992
+ reason: wantMajor ? `no PostgreSQL ${wantMajor} reader available (autopg or fetchable embedded-postgres) for the PG ${wantMajor} embedded dir` : "autopg postgres binary not found"
4883
4993
  };
4884
4994
  }
4885
4995
  const tempPort = await findFreePort();
4886
4996
  let temp = null;
4887
4997
  try {
4888
- temp = await spawnTempPostmaster(binary, EMBEDDED_DIR, tempPort, () => {});
4998
+ temp = await spawnTempPostmaster(reader, EMBEDDED_DIR, tempPort, () => {});
4889
4999
  const srcArgs = ["-h", "127.0.0.1", "-p", String(tempPort), "-U", "postgres", "-d", "omni"];
4890
5000
  const dstArgs = ["-h", "127.0.0.1", "-p", String(canonicalPort), "-U", "postgres", "-d", "omni"];
4891
5001
  const tablesRaw = psqlCapture([
@@ -4901,8 +5011,8 @@ async function compareEmbeddedVsCanonicalCounts(opts = {}) {
4901
5011
  let totalExtra = 0;
4902
5012
  for (const t of tables) {
4903
5013
  try {
4904
- const em = Number.parseInt(psqlCapture([...srcArgs, "-tAc", `SELECT count(*) FROM public.${t}`]).trim(), 10);
4905
- const ca = Number.parseInt(psqlCapture([...dstArgs, "-tAc", `SELECT count(*) FROM public.${t}`]).trim(), 10);
5014
+ const em = Number.parseInt(psqlCapture([...srcArgs, "-tAc", `SELECT count(*) FROM public."${t}"`]).trim(), 10);
5015
+ const ca = Number.parseInt(psqlCapture([...dstArgs, "-tAc", `SELECT count(*) FROM public."${t}"`]).trim(), 10);
4906
5016
  if (Number.isFinite(em) && Number.isFinite(ca) && em > ca) {
4907
5017
  divergent.push(t);
4908
5018
  totalExtra += em - ca;
@@ -4931,40 +5041,42 @@ async function migrateUnmountedEmbeddedToCanonical(opts = {}) {
4931
5041
  return { status: "skipped", reason: "embedded dir missing PG_VERSION" };
4932
5042
  }
4933
5043
  const wantMajor = readDataDirMajor(EMBEDDED_DIR);
4934
- const binary = findAutopgPostgresBinary(wantMajor);
4935
- if (!binary) {
5044
+ const reader = resolveReaderForMajor(wantMajor, log);
5045
+ if (!reader) {
4936
5046
  return {
4937
5047
  status: "skipped",
4938
- reason: wantMajor ? `no PostgreSQL ${wantMajor} reader installed under ~/.local/share/autopg \u2014 your data is PG ${wantMajor}; install a matching autopg/reader so it can be dumped into the canonical cluster` : "autopg postgres binary not found \u2014 install autopg first"
5048
+ reason: wantMajor ? `could not obtain a PostgreSQL ${wantMajor} reader (no installed autopg match and embedded-postgres fetch unavailable \u2014 unsupported platform or offline)` : "autopg postgres binary not found \u2014 install autopg first"
4939
5049
  };
4940
5050
  }
4941
- log(` using postgres binary: ${binary} (matched PG ${wantMajor ?? "?"})`);
5051
+ log(` using postgres binary: ${reader.binary} (matched PG ${wantMajor ?? "?"}${reader.libDir ? ", fetched reader" : ""})`);
4942
5052
  log(" stopping omni-api during data copy");
4943
5053
  spawnSync2("pm2", ["stop", "omni-api"], { stdio: "inherit" });
4944
5054
  const tempPort = await findFreePort();
4945
5055
  const t0 = Date.now();
4946
- const temp = await spawnTempPostmaster(binary, EMBEDDED_DIR, tempPort, log);
5056
+ const temp = await spawnTempPostmaster(reader, EMBEDDED_DIR, tempPort, log);
4947
5057
  let apiRestarted = false;
4948
5058
  try {
4949
5059
  const srcBaseArgs = ["-h", "127.0.0.1", "-p", String(tempPort), "-U", "postgres", "-d", "omni"];
4950
5060
  const dstBaseArgs = ["-h", "127.0.0.1", "-p", String(canonicalPort), "-U", "postgres", "-d", "omni"];
4951
- const tablesRaw = psqlCapture([
4952
- ...srcBaseArgs,
4953
- "-tAc",
4954
- `SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename`
4955
- ]);
4956
- const tables = tablesRaw.split(`
4957
- `).map((s) => s.trim()).filter(Boolean);
4958
- if (tables.length === 0) {
5061
+ const srcTables = new Set(listTables(srcBaseArgs));
5062
+ if (srcTables.size === 0) {
4959
5063
  return { status: "skipped", reason: "embedded omni has no public tables" };
4960
5064
  }
4961
- const SKIP_TABLES = new Set(["media_content"]);
4962
- const filteredTables = tables.filter((t) => !SKIP_TABLES.has(t));
4963
- const skipped = tables.filter((t) => SKIP_TABLES.has(t));
5065
+ const dstTables = listTables(dstBaseArgs);
5066
+ const tables = dstTables.filter((t) => srcTables.has(t));
5067
+ const onlyEmbedded = [...srcTables].filter((t) => !dstTables.includes(t));
5068
+ if (onlyEmbedded.length > 0) {
5069
+ log(` ${onlyEmbedded.length} obsolete embedded-only table(s) skipped: ${onlyEmbedded.join(", ")}`);
5070
+ }
5071
+ if (tables.length === 0) {
5072
+ return { status: "skipped", reason: "no tables shared between embedded and canonical schemas" };
5073
+ }
5074
+ const filteredTables = tables.filter((t) => !MIGRATION_SKIP_TABLES.has(t));
5075
+ const skipped = tables.filter((t) => MIGRATION_SKIP_TABLES.has(t));
4964
5076
  if (skipped.length > 0)
4965
5077
  log(` skipping ${skipped.length} table(s) (rebuilt at runtime): ${skipped.join(", ")}`);
4966
5078
  log(` ${filteredTables.length} tables to migrate`);
4967
- const truncateList = filteredTables.map((t) => `public.${t}`).join(",");
5079
+ const truncateList = filteredTables.map((t) => `public."${t}"`).join(",");
4968
5080
  psqlCapture([
4969
5081
  ...dstBaseArgs,
4970
5082
  "-c",
@@ -4972,7 +5084,9 @@ async function migrateUnmountedEmbeddedToCanonical(opts = {}) {
4972
5084
  ]);
4973
5085
  log(" truncated canonical (CASCADE)");
4974
5086
  for (const t of filteredTables) {
4975
- await copyTable(t, srcBaseArgs, dstBaseArgs, log);
5087
+ const srcCols = new Set(listColumns(srcBaseArgs, t));
5088
+ const sharedCols = listColumns(dstBaseArgs, t, true).filter((c2) => srcCols.has(c2));
5089
+ await copyTable(t, sharedCols, srcBaseArgs, dstBaseArgs, log);
4976
5090
  }
4977
5091
  resetSequences(dstBaseArgs, log);
4978
5092
  return { status: "migrated", tables: filteredTables.length, durationMs: Date.now() - t0 };
@@ -4983,9 +5097,10 @@ async function migrateUnmountedEmbeddedToCanonical(opts = {}) {
4983
5097
  apiRestarted = true;
4984
5098
  }
4985
5099
  }
4986
- var EMBEDDED_DIR, EMBEDDED_PGSERVE_DATA_DIR;
5100
+ var EMBEDDED_DIR, MIGRATION_SKIP_TABLES, EMBEDDED_PGSERVE_DATA_DIR;
4987
5101
  var init_embedded_canonical_migration = __esm(() => {
4988
5102
  EMBEDDED_DIR = join11(homedir7(), ".omni", "data", "pgserve");
5103
+ MIGRATION_SKIP_TABLES = new Set(["media_content", "api_keys", "api_key_audit_logs"]);
4989
5104
  EMBEDDED_PGSERVE_DATA_DIR = EMBEDDED_DIR;
4990
5105
  });
4991
5106
 
@@ -35975,10 +36090,10 @@ var init_agno_client = __esm(() => {
35975
36090
  // ../core/src/providers/claude-code-executable.ts
35976
36091
  import { existsSync as nodeExistsSync } from "fs";
35977
36092
  import { createRequire } from "module";
35978
- function archLinkerNames(arch) {
35979
- if (arch === "x64")
36093
+ function archLinkerNames(arch2) {
36094
+ if (arch2 === "x64")
35980
36095
  return { musl: "x86_64", glibc: "x86-64" };
35981
- if (arch === "arm64")
36096
+ if (arch2 === "arm64")
35982
36097
  return { musl: "aarch64", glibc: "aarch64" };
35983
36098
  return null;
35984
36099
  }
@@ -35991,41 +36106,41 @@ function glibcLinkerCandidates(glibcName, muslName, nodeArch) {
35991
36106
  return [`/lib64/${fileName}`, `/lib/${muslName}-linux-gnu/${fileName}`, `/lib/${fileName}`];
35992
36107
  }
35993
36108
  function detectLinuxLibc(options = {}) {
35994
- const platform = options.platform ?? process.platform;
35995
- if (platform !== "linux")
36109
+ const platform2 = options.platform ?? process.platform;
36110
+ if (platform2 !== "linux")
35996
36111
  return "unknown";
35997
- const arch = options.arch ?? process.arch;
35998
- const names = archLinkerNames(arch);
36112
+ const arch2 = options.arch ?? process.arch;
36113
+ const names = archLinkerNames(arch2);
35999
36114
  if (!names)
36000
36115
  return "unknown";
36001
36116
  const exists = options.existsSync ?? nodeExistsSync;
36002
36117
  if (exists(muslLinkerPath(names.musl)))
36003
36118
  return "musl";
36004
- if (glibcLinkerCandidates(names.glibc, names.musl, arch).some(exists))
36119
+ if (glibcLinkerCandidates(names.glibc, names.musl, arch2).some(exists))
36005
36120
  return "glibc";
36006
36121
  return "unknown";
36007
36122
  }
36008
36123
  function resolveClaudeCodeExecutable(options = {}) {
36009
- const platform = options.platform ?? process.platform;
36010
- if (platform !== "linux")
36124
+ const platform2 = options.platform ?? process.platform;
36125
+ if (platform2 !== "linux")
36011
36126
  return;
36012
- const libc = options.libc ?? detectLinuxLibc({ platform, arch: options.arch });
36127
+ const libc = options.libc ?? detectLinuxLibc({ platform: platform2, arch: options.arch });
36013
36128
  if (libc === "unknown")
36014
36129
  return;
36015
- const arch = options.arch ?? process.arch;
36016
- if (arch !== "x64" && arch !== "arm64")
36130
+ const arch2 = options.arch ?? process.arch;
36131
+ if (arch2 !== "x64" && arch2 !== "arm64")
36017
36132
  return;
36018
- const suffix = libc === "musl" ? `-${arch}-musl` : `-${arch}`;
36133
+ const suffix = libc === "musl" ? `-${arch2}-musl` : `-${arch2}`;
36019
36134
  const specifier = `@anthropic-ai/claude-agent-sdk-linux${suffix}/claude`;
36020
36135
  const resolve2 = options.resolve ?? createRequire(import.meta.url).resolve;
36021
36136
  try {
36022
36137
  const resolved = resolve2(specifier);
36023
- log6.debug("Resolved Claude Code executable for host libc", { libc, arch, resolved });
36138
+ log6.debug("Resolved Claude Code executable for host libc", { libc, arch: arch2, resolved });
36024
36139
  return resolved;
36025
36140
  } catch (error2) {
36026
36141
  log6.debug("Claude Code subpackage not installed; falling back to SDK default", {
36027
36142
  libc,
36028
- arch,
36143
+ arch: arch2,
36029
36144
  specifier,
36030
36145
  error: String(error2)
36031
36146
  });
@@ -36034,9 +36149,9 @@ function resolveClaudeCodeExecutable(options = {}) {
36034
36149
  }
36035
36150
  function describeClaudeCodeStartupError(error2, options = {}) {
36036
36151
  const raw2 = String(error2);
36037
- const platform = options.platform ?? process.platform;
36152
+ const platform2 = options.platform ?? process.platform;
36038
36153
  const isStartupCrash = /process exited with code 1/i.test(raw2);
36039
- if (!isStartupCrash || platform !== "linux")
36154
+ if (!isStartupCrash || platform2 !== "linux")
36040
36155
  return raw2;
36041
36156
  const configuredHint = options.explicitExecutablePath ? `Configured pathToClaudeCodeExecutable=${options.explicitExecutablePath} did not launch \u2014 verify the binary is executable on this host.` : "Set `pathToClaudeCodeExecutable` on the provider to the correct SDK binary for this host, " + "or remove the mismatched optional subpackage " + "(e.g. `bun remove @anthropic-ai/claude-agent-sdk-linux-x64-musl` on glibc).";
36042
36157
  return `${raw2} \u2014 Claude Code binary failed to start. This is typically a glibc/musl ABI mismatch: the SDK resolved an optional subpackage whose native binary cannot execute on this host's dynamic linker. ${configuredHint}`;
@@ -82855,7 +82970,7 @@ var require_path = __commonJS((exports) => {
82855
82970
  function join21(...args) {
82856
82971
  return normalizePath(args.join("/"));
82857
82972
  }
82858
- function dirname6(path) {
82973
+ function dirname7(path) {
82859
82974
  const result = splitPath(path);
82860
82975
  const root = result[0] || "";
82861
82976
  let dir = result[1];
@@ -82875,7 +82990,7 @@ var require_path = __commonJS((exports) => {
82875
82990
  return f10;
82876
82991
  }
82877
82992
  exports.basename = basename6;
82878
- exports.dirname = dirname6;
82993
+ exports.dirname = dirname7;
82879
82994
  exports.isAbsolute = isAbsolute;
82880
82995
  exports.join = join21;
82881
82996
  exports.normalizePath = normalizePath;
@@ -124502,7 +124617,7 @@ import { fileURLToPath } from "url";
124502
124617
  // package.json
124503
124618
  var package_default = {
124504
124619
  name: "@automagik/omni",
124505
- version: "2.260525.1",
124620
+ version: "2.260525.2",
124506
124621
  description: "LLM-optimized CLI for Omni",
124507
124622
  type: "module",
124508
124623
  bin: {
@@ -128373,7 +128488,7 @@ function createDeadLettersCommand() {
128373
128488
  }
128374
128489
 
128375
128490
  // src/commands/doctor.ts
128376
- import { existsSync as existsSync10, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
128491
+ import { existsSync as existsSync10, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
128377
128492
  import { homedir as homedir8 } from "os";
128378
128493
  import { join as join13, resolve } from "path";
128379
128494
  init_config();
@@ -129776,12 +129891,12 @@ init_output();
129776
129891
 
129777
129892
  // src/server-bundle.ts
129778
129893
  init_output();
129779
- import { dirname as dirname2, join as join12 } from "path";
129894
+ import { dirname as dirname3, join as join12 } from "path";
129780
129895
  import { fileURLToPath as fileURLToPath2 } from "url";
129781
129896
  function getServerBundlePath() {
129782
129897
  try {
129783
129898
  const thisFile = fileURLToPath2(import.meta.url);
129784
- const distDir = dirname2(thisFile);
129899
+ const distDir = dirname3(thisFile);
129785
129900
  return join12(distDir, "server", "index.js");
129786
129901
  } catch {
129787
129902
  return join12(process.cwd(), "dist", "server", "index.js");
@@ -129790,7 +129905,7 @@ function getServerBundlePath() {
129790
129905
  function getServerLauncherPath() {
129791
129906
  try {
129792
129907
  const thisFile = fileURLToPath2(import.meta.url);
129793
- const distDir = dirname2(thisFile);
129908
+ const distDir = dirname3(thisFile);
129794
129909
  return join12(distDir, "..", "bin", "omni-server");
129795
129910
  } catch {
129796
129911
  return join12(process.cwd(), "bin", "omni-server");
@@ -129962,7 +130077,7 @@ function scanForOrphans(dir, acc, depth, maxDepth = 4) {
129962
130077
  return;
129963
130078
  let entries;
129964
130079
  try {
129965
- entries = readdirSync2(dir);
130080
+ entries = readdirSync3(dir);
129966
130081
  } catch {
129967
130082
  return;
129968
130083
  }
@@ -131456,7 +131571,7 @@ function createHistoryCommand() {
131456
131571
 
131457
131572
  // src/commands/imagine.ts
131458
131573
  import { writeFileSync as writeFileSync8 } from "fs";
131459
- import { basename as basename2, dirname as dirname3, extname as extname2, join as join14 } from "path";
131574
+ import { basename as basename2, dirname as dirname4, extname as extname2, join as join14 } from "path";
131460
131575
  init_output();
131461
131576
  var ALLOWED_ASPECT_RATIOS = ["1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3"];
131462
131577
  function extensionForMime(mimeType) {
@@ -131467,7 +131582,7 @@ function extensionForMime(mimeType) {
131467
131582
  return ".png";
131468
131583
  }
131469
131584
  function buildOutputPath(outputBase, index, total, mimeType) {
131470
- const dir = dirname3(outputBase);
131585
+ const dir = dirname4(outputBase);
131471
131586
  const ext = extname2(outputBase) || extensionForMime(mimeType);
131472
131587
  const stem = basename2(outputBase, extname2(outputBase));
131473
131588
  if (total <= 1) {
@@ -131591,7 +131706,7 @@ function createImagineCommand() {
131591
131706
  }
131592
131707
 
131593
131708
  // src/commands/install.ts
131594
- import { existsSync as existsSync12, mkdirSync as mkdirSync6 } from "fs";
131709
+ import { existsSync as existsSync12, mkdirSync as mkdirSync7 } from "fs";
131595
131710
  import { homedir as homedir9 } from "os";
131596
131711
  import { join as join15 } from "path";
131597
131712
  init_config();
@@ -131701,7 +131816,7 @@ async function startServices(cfg, forceCleanup, forceSystemd, useCanonicalPgserv
131701
131816
  Or build locally: make cli-build-full`);
131702
131817
  return false;
131703
131818
  }
131704
- mkdirSync6(getPm2LogDir(), { recursive: true });
131819
+ mkdirSync7(getPm2LogDir(), { recursive: true });
131705
131820
  await installPm2Logrotate();
131706
131821
  const runtimeEnv = buildInstallRuntimeEnv(cfg, forceCleanup, useCanonicalPgserve);
131707
131822
  await runPm2(["delete", PM2_PROCESSES.api]);
@@ -131722,7 +131837,7 @@ async function startServices(cfg, forceCleanup, forceSystemd, useCanonicalPgserv
131722
131837
  if (existsSync12(NATS_BINARY_PATH)) {
131723
131838
  const natsSpinner = ora(`Starting ${PM2_PROCESSES.nats}...`).start();
131724
131839
  const natsDataDir = join15(cfg.dataDir, "nats");
131725
- mkdirSync6(natsDataDir, { recursive: true });
131840
+ mkdirSync7(natsDataDir, { recursive: true });
131726
131841
  const natsArgs = buildPm2StartArgs({
131727
131842
  kind: "nats",
131728
131843
  script: NATS_BINARY_PATH,
@@ -133399,8 +133514,8 @@ function createLogsCommand() {
133399
133514
  }
133400
133515
 
133401
133516
  // src/commands/media.ts
133402
- import { createWriteStream as createWriteStream2, existsSync as existsSync14, mkdirSync as mkdirSync8, statSync as statSync4 } from "fs";
133403
- import { basename as basename4, dirname as dirname4, resolve as resolve2 } from "path";
133517
+ import { createWriteStream as createWriteStream2, existsSync as existsSync14, mkdirSync as mkdirSync9, statSync as statSync4 } from "fs";
133518
+ import { basename as basename4, dirname as dirname5, resolve as resolve2 } from "path";
133404
133519
  import { Readable } from "stream";
133405
133520
  import { pipeline } from "stream/promises";
133406
133521
  init_config();
@@ -133467,9 +133582,9 @@ function resolveOutputPath(outputPath, result) {
133467
133582
  return resolved;
133468
133583
  }
133469
133584
  async function downloadToFile(url, apiKey, destinationPath) {
133470
- const destDir = dirname4(destinationPath);
133585
+ const destDir = dirname5(destinationPath);
133471
133586
  if (!existsSync14(destDir))
133472
- mkdirSync8(destDir, { recursive: true });
133587
+ mkdirSync9(destDir, { recursive: true });
133473
133588
  const resp = await fetch(url, {
133474
133589
  method: "GET",
133475
133590
  headers: apiKey ? { "x-api-key": apiKey } : undefined
@@ -134422,9 +134537,9 @@ init_output();
134422
134537
  init_src();
134423
134538
  import { execFileSync as execFileSync4, execSync } from "child_process";
134424
134539
  import * as nodeCrypto2 from "crypto";
134425
- import { existsSync as existsSync15, mkdirSync as mkdirSync9, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
134540
+ import { existsSync as existsSync15, mkdirSync as mkdirSync10, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
134426
134541
  import { homedir as homedir11 } from "os";
134427
- import { dirname as dirname5, resolve as resolve3 } from "path";
134542
+ import { dirname as dirname6, resolve as resolve3 } from "path";
134428
134543
  import { createInterface as createInterface2 } from "readline";
134429
134544
  init_config();
134430
134545
  init_output();
@@ -134661,7 +134776,7 @@ function readOpenClawConfig(configPath) {
134661
134776
  return JSON.parse(raw2);
134662
134777
  }
134663
134778
  function writeOpenClawConfig(configPath, config2) {
134664
- mkdirSync9(dirname5(configPath), { recursive: true, mode: 448 });
134779
+ mkdirSync10(dirname6(configPath), { recursive: true, mode: 448 });
134665
134780
  writeFileSync9(configPath, `${JSON.stringify(config2, null, 2)}
134666
134781
  `, { mode: 384 });
134667
134782
  }
@@ -136438,7 +136553,7 @@ function pickFilename(mimeType, provider) {
136438
136553
  }
136439
136554
 
136440
136555
  // src/commands/start.ts
136441
- import { existsSync as existsSync18, mkdirSync as mkdirSync10 } from "fs";
136556
+ import { existsSync as existsSync18, mkdirSync as mkdirSync11 } from "fs";
136442
136557
  import { homedir as homedir12 } from "os";
136443
136558
  import { join as join17 } from "path";
136444
136559
  init_config();
@@ -136454,7 +136569,7 @@ async function runStart() {
136454
136569
  }
136455
136570
  const serverConfig = loadServerConfig();
136456
136571
  const apiPort = serverConfig.port;
136457
- mkdirSync10(getPm2LogDir(), { recursive: true });
136572
+ mkdirSync11(getPm2LogDir(), { recursive: true });
136458
136573
  info(`Starting ${PM2_PROCESSES.api} (port ${apiPort})...`);
136459
136574
  const cliConfig = loadConfig();
136460
136575
  const env2 = buildRuntimeEnv(serverConfig, cliConfig);
@@ -136474,7 +136589,7 @@ async function runStart() {
136474
136589
  if (existsSync18(natsPath)) {
136475
136590
  info(`Starting ${PM2_PROCESSES.nats}...`);
136476
136591
  const natsDataDir = join17(serverConfig.dataDir, "nats");
136477
- mkdirSync10(natsDataDir, { recursive: true });
136592
+ mkdirSync11(natsDataDir, { recursive: true });
136478
136593
  const natsArgs = buildPm2StartArgs({
136479
136594
  kind: "nats",
136480
136595
  script: natsPath,
@@ -137177,7 +137292,7 @@ async function cleanupLegacyArtifacts(skipList) {
137177
137292
  init_output();
137178
137293
 
137179
137294
  // src/update-diagnostics.ts
137180
- import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
137295
+ import { existsSync as existsSync19, mkdirSync as mkdirSync12, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
137181
137296
  import { homedir as homedir13 } from "os";
137182
137297
  import { join as join18 } from "path";
137183
137298
  var UPDATE_DIAGNOSTICS_SCHEMA_VERSION = 1;
@@ -137246,7 +137361,7 @@ function writeDiagnostics(state, exitCode) {
137246
137361
  const path = getDiagnosticsPath(state.startedAt);
137247
137362
  try {
137248
137363
  if (!existsSync19(dir)) {
137249
- mkdirSync11(dir, { recursive: true, mode: 448 });
137364
+ mkdirSync12(dir, { recursive: true, mode: 448 });
137250
137365
  }
137251
137366
  writeFileSync10(path, `${JSON.stringify(state, null, 2)}
137252
137367
  `, { mode: 384 });
@@ -137826,9 +137941,9 @@ function createVoiceCommand() {
137826
137941
  const startTime = Date.now();
137827
137942
  let saveDir = "";
137828
137943
  if (opts.save) {
137829
- const { mkdirSync: mkdirSync12 } = await import("fs");
137944
+ const { mkdirSync: mkdirSync13 } = await import("fs");
137830
137945
  saveDir = opts.save;
137831
- mkdirSync12(saveDir, { recursive: true });
137946
+ mkdirSync13(saveDir, { recursive: true });
137832
137947
  info(`Saving audio to: ${saveDir}`);
137833
137948
  }
137834
137949
  ws.onopen = () => {
@@ -138137,7 +138252,7 @@ function getConfigSummary() {
138137
138252
 
138138
138253
  // src/telemetry.ts
138139
138254
  init_config();
138140
- import { arch, platform, release } from "os";
138255
+ import { arch as arch2, platform as platform2, release } from "os";
138141
138256
  var OMNI_SENTRY_DSN = "https://2b2ca6f407e3d13409aa7dd8d12483f2@o4509714066571264.ingest.us.sentry.io/4510982636371968";
138142
138257
  var SENSITIVE_FLAGS = new Set([
138143
138258
  "--api-key",
@@ -138219,8 +138334,8 @@ function ensureSentry() {
138219
138334
  }
138220
138335
  });
138221
138336
  Sentry.setTag("cli.version", VERSION);
138222
- Sentry.setTag("os.platform", platform());
138223
- Sentry.setTag("os.arch", arch());
138337
+ Sentry.setTag("os.platform", platform2());
138338
+ Sentry.setTag("os.arch", arch2());
138224
138339
  Sentry.setTag("os.release", release());
138225
138340
  Sentry.setTag("runtime", `bun/${process.versions.bun ?? "unknown"}`);
138226
138341
  sentryModule = Sentry;
@@ -24,13 +24,20 @@
24
24
  *
25
25
  * Solution
26
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.
27
+ * Spawn a matching-major `postgres` reader against the unmounted embedded
28
+ * data dir on a free TCP port, copy the shared public-schema tables over to
29
+ * canonical via psql `\copy`, then shut the temp postmaster down.
30
+ *
31
+ * Cross-major + cross-schema seamless: a PostgreSQL server can only open a
32
+ * data dir of its OWN major, so the reader major MUST match the embedded
33
+ * cluster (e.g. legacy PG17 data → reader PG17 even though canonical is PG18).
34
+ * {@link resolveReaderForMajor} finds an installed autopg binary of that major
35
+ * or AUTO-FETCHES one (`@embedded-postgres/<platform>@<major>`, cached under
36
+ * `~/.omni/cache/`) — the operator never deals with PG versions. The copy is
37
+ * TEXT format over the INTERSECTION of each table's columns, so it survives
38
+ * both the major-version wire gap and schema drift between an old embedded
39
+ * schema and the current canonical one. Install-local auth tables are
40
+ * preserved (see SKIP_TABLES) so the live CLI key keeps working.
34
41
  *
35
42
  * Idempotency: caller is expected to gate on `canonical omni DB is
36
43
  * empty + embedded dir has data` so re-running this isn't destructive.
@@ -65,6 +72,18 @@ export interface MigrateOptions {
65
72
  export declare function readDataDirMajor(dataDir: string): number | null;
66
73
  /** Compare two `vX.Y.Z`-ish dir names numerically, newest first. */
67
74
  export declare function compareVersionDesc(a: string, b: string): number;
75
+ /**
76
+ * Tables NOT copied embedded→canonical.
77
+ * - media_content: large blobs that overflow the COPY pipe; omni-api re-syncs
78
+ * media from the source channel on next message.
79
+ * - api_keys / api_key_audit_logs: INSTALL-LOCAL auth state the canonical
80
+ * install created fresh (the operator's live CLI key). Overwriting them with
81
+ * the stale embedded `__primary__` key breaks `omni` CLI auth immediately,
82
+ * and copying the audit logs would violate their FK to the preserved keys.
83
+ */
84
+ export declare const MIGRATION_SKIP_TABLES: Set<string>;
85
+ /** Map the host to its `@embedded-postgres/<platform>` package name. */
86
+ export declare function embeddedPostgresPackage(): string | null;
68
87
  /**
69
88
  * Public entry point — call this from `omni doctor --fix` when the
70
89
  * `embedded-data-orphaned` check FAILs (canonical omni DB empty AND
@@ -1 +1 @@
1
- {"version":3,"file":"embedded-canonical-migration.d.ts","sourceRoot":"","sources":["../../src/lib/embedded-canonical-migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAWH,MAAM,MA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AAC,aAAa,CAAC,CAyDxG;AAED,wBAAsB,mCAAmC,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,CAwG7G;AAED,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,QAAe,CAAC"}
@@ -230186,7 +230186,7 @@ var init_sentry_scrub = __esm(() => {
230186
230186
  var require_package8 = __commonJS((exports, module) => {
230187
230187
  module.exports = {
230188
230188
  name: "@omni/api",
230189
- version: "2.260525.1",
230189
+ version: "2.260525.2",
230190
230190
  type: "module",
230191
230191
  exports: {
230192
230192
  ".": {
@@ -330333,6 +330333,7 @@ class MessageService {
330333
330333
  status,
330334
330334
  hasMedia,
330335
330335
  senderPersonId,
330336
+ externalId,
330336
330337
  since,
330337
330338
  until,
330338
330339
  search,
@@ -330357,6 +330358,8 @@ class MessageService {
330357
330358
  conditions3.push(eq(messages2.hasMedia, hasMedia));
330358
330359
  if (senderPersonId)
330359
330360
  conditions3.push(eq(messages2.senderPersonId, senderPersonId));
330361
+ if (externalId)
330362
+ conditions3.push(eq(messages2.externalId, externalId));
330360
330363
  if (since)
330361
330364
  conditions3.push(gte(messages2.platformTimestamp, since));
330362
330365
  if (until)
@@ -349864,6 +349867,7 @@ var init_messages5 = __esm(() => {
349864
349867
  status: exports_external.string().optional().transform((v2) => v2?.split(",")),
349865
349868
  hasMedia: exports_external.coerce.boolean().optional(),
349866
349869
  senderPersonId: exports_external.string().uuid().optional(),
349870
+ externalId: exports_external.string().min(1).optional(),
349867
349871
  since: optionalDateParam("since"),
349868
349872
  until: optionalDateParam("until"),
349869
349873
  search: exports_external.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260525.1",
3
+ "version": "2.260525.2",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {