@automagik/omni 2.260523.1 → 2.260525.1

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
@@ -4663,12 +4663,14 @@ var require_cli_spinners = __commonJS((exports, module) => {
4663
4663
  // src/lib/embedded-canonical-migration.ts
4664
4664
  var exports_embedded_canonical_migration = {};
4665
4665
  __export(exports_embedded_canonical_migration, {
4666
+ readDataDirMajor: () => readDataDirMajor,
4666
4667
  migrateUnmountedEmbeddedToCanonical: () => migrateUnmountedEmbeddedToCanonical,
4668
+ compareVersionDesc: () => compareVersionDesc,
4667
4669
  compareEmbeddedVsCanonicalCounts: () => compareEmbeddedVsCanonicalCounts,
4668
4670
  EMBEDDED_PGSERVE_DATA_DIR: () => EMBEDDED_PGSERVE_DATA_DIR
4669
4671
  });
4670
- import { spawn, spawnSync as spawnSync2 } from "child_process";
4671
- import { existsSync as existsSync9, mkdtempSync } from "fs";
4672
+ import { execFileSync as execFileSync3, spawn, spawnSync as spawnSync2 } from "child_process";
4673
+ import { existsSync as existsSync9, mkdtempSync, readFileSync as readFileSync6 } from "fs";
4672
4674
  import { createServer } from "net";
4673
4675
  import { homedir as homedir7, tmpdir } from "os";
4674
4676
  import { join as join11 } from "path";
@@ -4677,17 +4679,48 @@ function defaultLog(line) {
4677
4679
  process.stdout.write(`${line}
4678
4680
  `);
4679
4681
  }
4680
- function findAutopgPostgresBinary() {
4682
+ function readDataDirMajor(dataDir) {
4683
+ try {
4684
+ const major = Number.parseInt(readFileSync6(join11(dataDir, "PG_VERSION"), "utf8").trim(), 10);
4685
+ return Number.isFinite(major) ? major : null;
4686
+ } catch {
4687
+ return null;
4688
+ }
4689
+ }
4690
+ function binaryMajor(binary) {
4691
+ try {
4692
+ const out = execFileSync3(binary, ["--version"], { encoding: "utf8", timeout: 5000 });
4693
+ const m = out.match(/(\d+)(?:[.\s]|$)/);
4694
+ return m ? Number.parseInt(m[1], 10) : null;
4695
+ } catch {
4696
+ return null;
4697
+ }
4698
+ }
4699
+ function findAutopgPostgresBinary(wantMajor) {
4681
4700
  const autopgRoot = join11(homedir7(), ".local", "share", "autopg");
4682
4701
  if (!existsSync9(autopgRoot))
4683
4702
  return null;
4684
- let bestPath = null;
4685
- for (const entry of safeReaddir(autopgRoot)) {
4686
- const candidate = join11(autopgRoot, entry, "postgres", "bin", "postgres");
4687
- if (existsSync9(candidate))
4688
- bestPath = candidate;
4703
+ const candidates = safeReaddir(autopgRoot).sort((a, b) => compareVersionDesc(a, b)).map((entry) => join11(autopgRoot, entry, "postgres", "bin", "postgres")).filter((candidate) => existsSync9(candidate));
4704
+ if (candidates.length === 0)
4705
+ return null;
4706
+ if (wantMajor === null)
4707
+ return candidates[0];
4708
+ for (const candidate of candidates) {
4709
+ if (binaryMajor(candidate) === wantMajor)
4710
+ return candidate;
4689
4711
  }
4690
- return bestPath;
4712
+ return null;
4713
+ }
4714
+ function compareVersionDesc(a, b) {
4715
+ const parse = (s) => (s.match(/\d+/g) ?? []).map(Number);
4716
+ const pa = parse(a);
4717
+ const pb = parse(b);
4718
+ for (let i = 0;i < Math.max(pa.length, pb.length); i++) {
4719
+ const diff = (pb[i] ?? 0) - (pa[i] ?? 0);
4720
+ if (diff !== 0)
4721
+ return diff;
4722
+ }
4723
+ return b.localeCompare(a);
4691
4724
  }
4692
4725
  function safeReaddir(path) {
4693
4726
  try {
@@ -4841,9 +4874,14 @@ async function compareEmbeddedVsCanonicalCounts(opts = {}) {
4841
4874
  if (!existsSync9(EMBEDDED_DIR) || !existsSync9(join11(EMBEDDED_DIR, "PG_VERSION"))) {
4842
4875
  return { kind: "skipped", reason: "embedded dir absent" };
4843
4876
  }
4844
- const binary = findAutopgPostgresBinary();
4845
- if (!binary)
4846
- return { kind: "skipped", reason: "autopg postgres binary not found" };
4877
+ const wantMajor = readDataDirMajor(EMBEDDED_DIR);
4878
+ const binary = findAutopgPostgresBinary(wantMajor);
4879
+ if (!binary) {
4880
+ return {
4881
+ kind: "skipped",
4882
+ reason: wantMajor ? `no PostgreSQL ${wantMajor} reader under ~/.local/share/autopg (embedded dir is PG ${wantMajor})` : "autopg postgres binary not found"
4883
+ };
4884
+ }
4847
4885
  const tempPort = await findFreePort();
4848
4886
  let temp = null;
4849
4887
  try {
@@ -4892,11 +4930,15 @@ async function migrateUnmountedEmbeddedToCanonical(opts = {}) {
4892
4930
  if (!existsSync9(join11(EMBEDDED_DIR, "PG_VERSION"))) {
4893
4931
  return { status: "skipped", reason: "embedded dir missing PG_VERSION" };
4894
4932
  }
4895
- const binary = findAutopgPostgresBinary();
4933
+ const wantMajor = readDataDirMajor(EMBEDDED_DIR);
4934
+ const binary = findAutopgPostgresBinary(wantMajor);
4896
4935
  if (!binary) {
4897
- return { status: "skipped", reason: "autopg postgres binary not found \u2014 install autopg first" };
4936
+ return {
4937
+ 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"
4939
+ };
4898
4940
  }
4899
- log(` using postgres binary: ${binary}`);
4941
+ log(` using postgres binary: ${binary} (matched PG ${wantMajor ?? "?"})`);
4900
4942
  log(" stopping omni-api during data copy");
4901
4943
  spawnSync2("pm2", ["stop", "omni-api"], { stdio: "inherit" });
4902
4944
  const tempPort = await findFreePort();
@@ -124460,7 +124502,7 @@ import { fileURLToPath } from "url";
124460
124502
  // package.json
124461
124503
  var package_default = {
124462
124504
  name: "@automagik/omni",
124463
- version: "2.260523.1",
124505
+ version: "2.260525.1",
124464
124506
  description: "LLM-optimized CLI for Omni",
124465
124507
  type: "module",
124466
124508
  bin: {
@@ -125965,7 +126007,7 @@ function resolveOmniScopedCredentials() {
125965
126007
  // src/runtime-env.ts
125966
126008
  var LEGACY_DEFAULT_DATABASE_URL = "postgresql://postgres:postgres@localhost:5432/omni";
125967
126009
  var LEGACY_PHASE2_DATABASE_URL = "postgresql://postgres:postgres@localhost:8432/omni";
125968
- var DEFAULT_PGSERVE_PORT = 8432;
126010
+ var DEFAULT_PGSERVE_PORT = CANONICAL_PG_PORT;
125969
126011
  function buildEmbeddedDatabaseUrl(pgservePort = DEFAULT_PGSERVE_PORT) {
125970
126012
  return `postgresql://postgres:postgres@localhost:${pgservePort}/omni`;
125971
126013
  }
@@ -130607,7 +130649,7 @@ Safety:
130607
130649
  }
130608
130650
 
130609
130651
  // src/commands/done.ts
130610
- import { existsSync as existsSync11, readFileSync as readFileSync6 } from "fs";
130652
+ import { existsSync as existsSync11, readFileSync as readFileSync7 } from "fs";
130611
130653
  import { basename, extname } from "path";
130612
130654
 
130613
130655
  // src/context.ts
@@ -130721,7 +130763,7 @@ async function handleMedia(client, ctx, mediaPath, caption) {
130721
130763
  }
130722
130764
  try {
130723
130765
  const mediaType = getMediaType(mediaPath);
130724
- const buffer = readFileSync6(mediaPath);
130766
+ const buffer = readFileSync7(mediaPath);
130725
130767
  const base64 = buffer.toString("base64");
130726
130768
  const filename = basename(mediaPath);
130727
130769
  await client.messages.sendMedia({
@@ -131241,7 +131283,7 @@ function createFilmCommand() {
131241
131283
  }
131242
131284
 
131243
131285
  // src/commands/follow-up.ts
131244
- import { readFileSync as readFileSync7 } from "fs";
131286
+ import { readFileSync as readFileSync8 } from "fs";
131245
131287
  init_output();
131246
131288
  var VALID_SCOPES = ["agents", "instances", "chats"];
131247
131289
  function assertScope(scope) {
@@ -131259,9 +131301,9 @@ async function resolveScopedId(scope, id) {
131259
131301
  function readJsonArg(raw2) {
131260
131302
  let body = raw2;
131261
131303
  if (body === "-") {
131262
- body = readFileSync7(0, "utf8");
131304
+ body = readFileSync8(0, "utf8");
131263
131305
  } else if (body.startsWith("@")) {
131264
- body = readFileSync7(body.slice(1), "utf8");
131306
+ body = readFileSync8(body.slice(1), "utf8");
131265
131307
  }
131266
131308
  try {
131267
131309
  return JSON.parse(body);
@@ -134378,9 +134420,9 @@ init_output();
134378
134420
 
134379
134421
  // src/commands/providers-setup.ts
134380
134422
  init_src();
134381
- import { execFileSync as execFileSync3, execSync } from "child_process";
134423
+ import { execFileSync as execFileSync4, execSync } from "child_process";
134382
134424
  import * as nodeCrypto2 from "crypto";
134383
- import { existsSync as existsSync15, mkdirSync as mkdirSync9, readFileSync as readFileSync9, writeFileSync as writeFileSync9 } from "fs";
134425
+ import { existsSync as existsSync15, mkdirSync as mkdirSync9, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
134384
134426
  import { homedir as homedir11 } from "os";
134385
134427
  import { dirname as dirname5, resolve as resolve3 } from "path";
134386
134428
  import { createInterface as createInterface2 } from "readline";
@@ -134613,7 +134655,7 @@ var PLUGIN_MARKER = "plugin-openclaw/omni.ts";
134613
134655
  function readOpenClawConfig(configPath) {
134614
134656
  if (!existsSync15(configPath))
134615
134657
  return {};
134616
- const raw2 = readFileSync9(configPath, "utf-8").trim();
134658
+ const raw2 = readFileSync10(configPath, "utf-8").trim();
134617
134659
  if (!raw2)
134618
134660
  return {};
134619
134661
  return JSON.parse(raw2);
@@ -134660,7 +134702,7 @@ function resolvePluginPath(explicit) {
134660
134702
  function registerPlugin(config2, pluginPath, configPath) {
134661
134703
  if (hasOpenClawCli()) {
134662
134704
  try {
134663
- execFileSync3("openclaw", ["plugins", "install", "--link", pluginPath], { stdio: "ignore" });
134705
+ execFileSync4("openclaw", ["plugins", "install", "--link", pluginPath], { stdio: "ignore" });
134664
134706
  try {
134665
134707
  return { config: readOpenClawConfig(configPath), registered: true };
134666
134708
  } catch {
@@ -135705,7 +135747,7 @@ function createSayCommand() {
135705
135747
  }
135706
135748
 
135707
135749
  // src/commands/see.ts
135708
- import { existsSync as existsSync16, readFileSync as readFileSync10, statSync as statSync5 } from "fs";
135750
+ import { existsSync as existsSync16, readFileSync as readFileSync11, statSync as statSync5 } from "fs";
135709
135751
  import { extname as extname4 } from "path";
135710
135752
  init_output();
135711
135753
  var MIME_BY_EXT = {
@@ -135748,7 +135790,7 @@ function loadMedia(file) {
135748
135790
  error(`File is empty: ${file}`);
135749
135791
  }
135750
135792
  try {
135751
- return { buffer: readFileSync10(file), mimeType: guessMimeType(file) };
135793
+ return { buffer: readFileSync11(file), mimeType: guessMimeType(file) };
135752
135794
  } catch (err2) {
135753
135795
  const message2 = err2 instanceof Error ? err2.message : "Unknown error";
135754
135796
  return error(`Failed to read ${file}: ${message2}`);
@@ -135823,7 +135865,7 @@ function createSeeCommand() {
135823
135865
  }
135824
135866
 
135825
135867
  // src/commands/send.ts
135826
- import { existsSync as existsSync17, readFileSync as readFileSync11 } from "fs";
135868
+ import { existsSync as existsSync17, readFileSync as readFileSync12 } from "fs";
135827
135869
  import { basename as basename5, extname as extname5 } from "path";
135828
135870
  init_source();
135829
135871
  init_config();
@@ -135843,7 +135885,7 @@ function getMediaType2(path) {
135843
135885
  return "document";
135844
135886
  }
135845
135887
  function readFileAsBase64(path) {
135846
- const buffer3 = readFileSync11(path);
135888
+ const buffer3 = readFileSync12(path);
135847
135889
  return buffer3.toString("base64");
135848
135890
  }
135849
135891
  var messageSenders = {
@@ -137135,7 +137177,7 @@ async function cleanupLegacyArtifacts(skipList) {
137135
137177
  init_output();
137136
137178
 
137137
137179
  // src/update-diagnostics.ts
137138
- import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
137180
+ import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
137139
137181
  import { homedir as homedir13 } from "os";
137140
137182
  import { join as join18 } from "path";
137141
137183
  var UPDATE_DIAGNOSTICS_SCHEMA_VERSION = 1;
@@ -137170,7 +137212,7 @@ function tailFileLines(path, maxLines) {
137170
137212
  if (!existsSync19(path))
137171
137213
  return [];
137172
137214
  try {
137173
- const raw2 = readFileSync12(path, "utf8");
137215
+ const raw2 = readFileSync13(path, "utf8");
137174
137216
  const lines = raw2.split(/\r?\n/);
137175
137217
  if (lines.length > 0 && lines[lines.length - 1] === "")
137176
137218
  lines.pop();
@@ -138010,7 +138052,7 @@ init_config();
138010
138052
  init_output();
138011
138053
 
138012
138054
  // src/manifest-pin.ts
138013
- import { existsSync as existsSync21, readFileSync as readFileSync13, renameSync as renameSync3, writeFileSync as writeFileSync11 } from "fs";
138055
+ import { existsSync as existsSync21, readFileSync as readFileSync14, renameSync as renameSync3, writeFileSync as writeFileSync11 } from "fs";
138014
138056
  import { homedir as homedir14 } from "os";
138015
138057
  import { join as join20 } from "path";
138016
138058
  var PACKAGE_NAME2 = "@automagik/omni";
@@ -138020,7 +138062,7 @@ function pinManifestEntry(manifestPath, exactVersion) {
138020
138062
  return false;
138021
138063
  let manifest;
138022
138064
  try {
138023
- manifest = JSON.parse(readFileSync13(manifestPath, "utf-8"));
138065
+ manifest = JSON.parse(readFileSync14(manifestPath, "utf-8"));
138024
138066
  } catch {
138025
138067
  return false;
138026
138068
  }
@@ -61,6 +61,10 @@ export interface MigrateOptions {
61
61
  /** Logger sink — defaults to writing prefixed lines to process.stdout. */
62
62
  log?: (line: string) => void;
63
63
  }
64
+ /** Read the catalog major (e.g. 17, 18) recorded in a data dir's PG_VERSION. */
65
+ export declare function readDataDirMajor(dataDir: string): number | null;
66
+ /** Compare two `vX.Y.Z`-ish dir names numerically, newest first. */
67
+ export declare function compareVersionDesc(a: string, b: string): number;
64
68
  /**
65
69
  * Public entry point — call this from `omni doctor --fix` when the
66
70
  * `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,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;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M,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAMD,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO/D;AAoDD,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAS/D;AA4ND;;;;;;;;GAQG;AACH;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,eAAe,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAyDxG;AAED,wBAAsB,mCAAmC,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,CA6F7G;AAED,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,QAAe,CAAC"}
@@ -46,20 +46,20 @@ export type RuntimeEnv = {
46
46
  LOG_LEVEL: string;
47
47
  };
48
48
  /**
49
- * Default pgserve port when none is set explicitly.
49
+ * Default pgserve port when none is set explicitly — the CANONICAL port.
50
50
  *
51
51
  * Phase 2 of the canonical-pgserve cutover (omni#595/#596/#597) used the
52
52
  * bun-bridge port `8432`. Phase 3 (`pgserve-singleton-no-proxy`) lands the
53
- * postmaster directly on **5432** (canonical postgres port) and listens
54
- * on the canonical UDS at `$XDG_RUNTIME_DIR/pgserve/.s.PGSQL.5432`.
55
- *
56
- * Kept as the module-level default for backwards compatibility with the
57
- * stored `~/.omni/config.json` entries that still record `8432`. Use
58
- * {@link resolveDatabaseUrl} as the entry point it prefers the canonical
59
- * UDS when available and falls back to the legacy port only when the
60
- * socket is missing AND the operator hasn't migrated their config.
53
+ * postmaster directly on **5432** (the canonical postgres port) and listens
54
+ * on the canonical UDS at `$XDG_RUNTIME_DIR/pgserve/.s.PGSQL.5432`. There is
55
+ * no embedded 8432 listener anymore, so the default MUST be canonical — a
56
+ * hardcoded 8432 here leaked into `resolvePgservePort` (→ the `PGSERVE_PORT`
57
+ * env that `omni doctor`'s `pgserve-reachable` check probes), making doctor
58
+ * false-FAIL "cannot connect to pgserve on :8432" on every healthy host.
59
+ * Stored `8432` entries in `~/.omni/config.json` are treated as a stale
60
+ * default and re-resolved by {@link resolveDatabaseUrl} (UDS-first).
61
61
  */
62
- export declare const DEFAULT_PGSERVE_PORT = 8432;
62
+ export declare const DEFAULT_PGSERVE_PORT = 5432;
63
63
  /** Canonical postgres TCP port the postmaster binds in singleton mode. */
64
64
  export { CANONICAL_PG_PORT } from './lib/pgserve-transport.js';
65
65
  /**
@@ -77,9 +77,13 @@ export declare function buildEmbeddedDatabaseUrl(pgservePort?: number): string;
77
77
  export declare function buildCanonicalSocketDatabaseUrl(): string;
78
78
  /**
79
79
  * Extract the effective pgserve port. Honors an explicit override on the
80
- * server config first (`server.pgservePort`, if ever added), then the
81
- * hard-coded default. This function intentionally does NOT read
82
- * `process.env.PGSERVE_PORT` env pollution is the bug we're fixing.
80
+ * server config first (`server.pgservePort`), then falls back to
81
+ * {@link DEFAULT_PGSERVE_PORT} which is now the CANONICAL port (5432), not
82
+ * the legacy 8432. This value feeds the runtime `PGSERVE_PORT` env that
83
+ * `omni doctor`'s `pgserve-reachable` check probes.
84
+ *
85
+ * This function intentionally does NOT read `process.env.PGSERVE_PORT` —
86
+ * env pollution is the bug we're fixing.
83
87
  */
84
88
  export declare function resolvePgservePort(serverConfig: ServerConfig): number;
85
89
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-env.d.ts","sourceRoot":"","sources":["../src/runtime-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AASxD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IAQrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAQF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,0EAA0E;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,GAAE,MAA6B,GAAG,MAAM,CAE3F;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAKxD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAMrE;AAgBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAiBrE;AAoBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAA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AY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAqCzF"}
@@ -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.260523.1",
230189
+ version: "2.260525.1",
230190
230190
  type: "module",
230191
230191
  exports: {
230192
230192
  ".": {
@@ -331824,6 +331824,40 @@ function buildChatPreview(payload, rawPayload) {
331824
331824
  }
331825
331825
  return preview.substring(0, 500);
331826
331826
  }
331827
+ function compactRecord(record) {
331828
+ const compacted = Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
331829
+ return Object.keys(compacted).length > 0 ? compacted : undefined;
331830
+ }
331831
+ function isSentMediaContent(content) {
331832
+ return OUTBOUND_MEDIA_TYPES.has(content.type) || !!content.mediaUrl || !!content.localPath || !!content.mimeType;
331833
+ }
331834
+ function buildSentMediaMetadata(content, rawPayload) {
331835
+ if (!isSentMediaContent(content))
331836
+ return;
331837
+ const rawSource = typeof rawPayload?.mediaSource === "string" ? rawPayload.mediaSource : undefined;
331838
+ return compactRecord({
331839
+ caption: content.caption,
331840
+ filename: content.filename,
331841
+ voiceNote: content.isVoiceNote === true ? true : undefined,
331842
+ source: rawSource ?? (content.mediaUrl ? "url" : content.localPath ? "localPath" : "inline")
331843
+ });
331844
+ }
331845
+ function buildSentMessageContentFields(payload) {
331846
+ return {
331847
+ textContent: sanitizeText(payload.content.text ?? payload.content.caption),
331848
+ hasMedia: isSentMediaContent(payload.content),
331849
+ mediaMimeType: truncate3(payload.content.mimeType, 100),
331850
+ mediaUrl: payload.content.mediaUrl,
331851
+ mediaLocalPath: payload.content.localPath,
331852
+ mediaMetadata: buildSentMediaMetadata(payload.content, payload.rawPayload),
331853
+ rawPayload: payload.rawPayload ? deepSanitize(payload.rawPayload) : undefined
331854
+ };
331855
+ }
331856
+ function buildSentChatPreview(payload) {
331857
+ const text3 = payload.content.text ?? payload.content.caption ?? "";
331858
+ const badge = payload.content.type !== "text" ? MEDIA_BADGES2[payload.content.type] ?? `[${payload.content.type}]` : "";
331859
+ return badge ? text3 ? `${badge} ${text3}` : badge : text3;
331860
+ }
331827
331861
  function extractPhoneFromSender(senderId, channel5) {
331828
331862
  if (!channel5.startsWith("whatsapp"))
331829
331863
  return;
@@ -332115,17 +332149,22 @@ async function setupMessagePersistence(eventBus, services) {
332115
332149
  chatType: inferChatType(payload.chatId),
332116
332150
  channel: metadata.channelType ?? "whatsapp"
332117
332151
  });
332152
+ const sentContent = buildSentMessageContentFields(payload);
332118
332153
  const { message: message2, created } = await services.messages.findOrCreate(chat2.id, messageExternalId, {
332119
332154
  source: "realtime",
332120
332155
  messageType: mapContentType(payload.content.type),
332121
- textContent: sanitizeText(payload.content.text),
332156
+ textContent: sentContent.textContent,
332122
332157
  platformTimestamp: new Date(event.timestamp),
332123
332158
  senderPersonId: metadata.personId,
332124
332159
  senderPlatformIdentityId: metadata.platformIdentityId,
332125
332160
  isFromMe: true,
332126
332161
  senderAgentId: payload.senderAgentId ?? null,
332127
- hasMedia: !!payload.content.mediaUrl,
332128
- mediaUrl: payload.content.mediaUrl,
332162
+ hasMedia: sentContent.hasMedia,
332163
+ mediaMimeType: sentContent.mediaMimeType,
332164
+ mediaUrl: sentContent.mediaUrl,
332165
+ mediaLocalPath: sentContent.mediaLocalPath,
332166
+ mediaMetadata: sentContent.mediaMetadata,
332167
+ rawPayload: sentContent.rawPayload,
332129
332168
  replyToExternalId: truncate3(payload.replyToId, 255)
332130
332169
  });
332131
332170
  if (created) {
@@ -332135,7 +332174,7 @@ async function setupMessagePersistence(eventBus, services) {
332135
332174
  chatId: chat2.id
332136
332175
  });
332137
332176
  }
332138
- services.chats.updateLastMessage(chat2.id, sanitizeText(payload.content.text ?? "") ?? "", new Date(event.timestamp), true).catch((err) => log93.debug("Failed to update chat recency (sent)", { error: String(err) }));
332177
+ services.chats.updateLastMessage(chat2.id, sanitizeText(buildSentChatPreview(payload)) ?? "", new Date(event.timestamp), true).catch((err) => log93.debug("Failed to update chat recency (sent)", { error: String(err) }));
332139
332178
  if (metadata.streamSequence) {
332140
332179
  await services.consumerOffsets.updateOffset("message-persistence-sent", "MESSAGE", metadata.streamSequence, event.id);
332141
332180
  }
@@ -332304,7 +332343,7 @@ async function detectStartupGaps(services) {
332304
332343
  }
332305
332344
  }
332306
332345
  }
332307
- var log93, CONTENT_TYPE_MAP, INTERNAL_JID_SUFFIXES, MEDIA_BADGES2;
332346
+ var log93, CONTENT_TYPE_MAP, INTERNAL_JID_SUFFIXES, MEDIA_BADGES2, OUTBOUND_MEDIA_TYPES;
332308
332347
  var init_message_persistence = __esm(() => {
332309
332348
  init_src();
332310
332349
  init_esm5();
@@ -332334,6 +332373,7 @@ var init_message_persistence = __esm(() => {
332334
332373
  location: "[Location]",
332335
332374
  poll: "[Poll]"
332336
332375
  };
332376
+ OUTBOUND_MEDIA_TYPES = new Set(["audio", "image", "video", "document", "sticker"]);
332337
332377
  });
332338
332378
 
332339
332379
  // ../api/src/plugins/session-storage.ts
@@ -333954,7 +333994,8 @@ function createClaudeCodeProviderInstance(provider, instance4, db2) {
333954
333994
  model: schemaConfig.model,
333955
333995
  systemPrompt: schemaConfig.systemPrompt,
333956
333996
  mcpServers: schemaConfig.mcpServers,
333957
- maxTurns: schemaConfig.maxTurns
333997
+ maxTurns: schemaConfig.maxTurns,
333998
+ pathToClaudeCodeExecutable: schemaConfig.pathToClaudeCodeExecutable
333958
333999
  }, createSessionStorage(db2, provider.id), {
333959
334000
  timeoutMs: (instance4.agentTimeout ?? provider.defaultTimeout ?? 120) * 1000,
333960
334001
  enableAutoSplit: instance4.enableAutoSplit ?? true,
@@ -342723,6 +342764,9 @@ function buildA2AAgentCard(params) {
342723
342764
  const providerOverride = isRecord(override.provider) ? override.provider : undefined;
342724
342765
  if (providerOverride)
342725
342766
  card.provider = providerOverride;
342767
+ const metadataOverride = isRecord(override.metadata) ? override.metadata : undefined;
342768
+ if (metadataOverride)
342769
+ card.metadata = metadataOverride;
342726
342770
  const iconUrl = stringOverride(override.iconUrl);
342727
342771
  if (iconUrl)
342728
342772
  card.iconUrl = iconUrl;
@@ -349590,7 +349634,15 @@ var init__close_contact_config = __esm(() => {
349590
349634
 
349591
349635
  // ../api/src/routes/v2/messages.ts
349592
349636
  import { existsSync as existsSync7 } from "fs";
349593
- import { join as join22 } from "path";
349637
+ import { extname as extname3, join as join22 } from "path";
349638
+ function inferMediaMimeType(type, filename) {
349639
+ if (filename) {
349640
+ const fromExtension = MIME_BY_EXTENSION[extname3(filename).toLowerCase()];
349641
+ if (fromExtension)
349642
+ return fromExtension;
349643
+ }
349644
+ return DEFAULT_MIME_BY_MEDIA_TYPE[type];
349645
+ }
349594
349646
  function isUUID(value) {
349595
349647
  return UUID_REGEX2.test(value);
349596
349648
  }
@@ -349748,7 +349800,7 @@ async function verifyMessageInstanceOwnership(services, message2, instanceId) {
349748
349800
  });
349749
349801
  }
349750
349802
  }
349751
- var log105, mediaDownloadLog, messagesRoutes, UUID_REGEX2, MessageSourceSchema, MessageTypeSchema, MessageStatusSchema, DeliveryStatusSchema, listQuerySchema14, createMessageSchema, updateMessageSchema, recordEditSchema, addReactionSchema, removeReactionSchema, updateDeliveryStatusSchema, MentionSchema, sendTextSchema, sendMediaSchema, sendReactionSchema, sendStickerSchema, sendContactSchema, sendLocationSchema, sendHandoffSchema, sendCloseContactSchema, messageRefSchema, _mediaStorageForDownload = null, sendTtsSchema, forwardMessageSchema, sendPresenceSchema, markMessageReadSchema, markBatchReadSchema, sendPollSchema, sendEmbedSchema, editMessageChannelSchema, deleteMessageChannelSchema, starMessageSchema;
349803
+ var log105, mediaDownloadLog, messagesRoutes, MIME_BY_EXTENSION, DEFAULT_MIME_BY_MEDIA_TYPE, UUID_REGEX2, MessageSourceSchema, MessageTypeSchema, MessageStatusSchema, DeliveryStatusSchema, listQuerySchema14, createMessageSchema, updateMessageSchema, recordEditSchema, addReactionSchema, removeReactionSchema, updateDeliveryStatusSchema, MentionSchema, sendTextSchema, sendMediaSchema, sendReactionSchema, sendStickerSchema, sendContactSchema, sendLocationSchema, sendHandoffSchema, sendCloseContactSchema, messageRefSchema, _mediaStorageForDownload = null, sendTtsSchema, forwardMessageSchema, sendPresenceSchema, markMessageReadSchema, markBatchReadSchema, sendPollSchema, sendEmbedSchema, editMessageChannelSchema, deleteMessageChannelSchema, starMessageSchema;
349752
349804
  var init_messages5 = __esm(() => {
349753
349805
  init_dist6();
349754
349806
  init_src2();
@@ -349766,6 +349818,29 @@ var init_messages5 = __esm(() => {
349766
349818
  log105 = createLogger("routes:messages");
349767
349819
  mediaDownloadLog = createLogger("routes:messages:media-download");
349768
349820
  messagesRoutes = new Hono2;
349821
+ MIME_BY_EXTENSION = {
349822
+ ".jpg": "image/jpeg",
349823
+ ".jpeg": "image/jpeg",
349824
+ ".png": "image/png",
349825
+ ".gif": "image/gif",
349826
+ ".webp": "image/webp",
349827
+ ".mp3": "audio/mpeg",
349828
+ ".ogg": "audio/ogg",
349829
+ ".opus": "audio/opus",
349830
+ ".wav": "audio/wav",
349831
+ ".m4a": "audio/mp4",
349832
+ ".mp4": "video/mp4",
349833
+ ".webm": "video/webm",
349834
+ ".mov": "video/quicktime",
349835
+ ".avi": "video/x-msvideo",
349836
+ ".pdf": "application/pdf"
349837
+ };
349838
+ DEFAULT_MIME_BY_MEDIA_TYPE = {
349839
+ image: "image/jpeg",
349840
+ audio: "audio/ogg",
349841
+ video: "video/mp4",
349842
+ document: "application/octet-stream"
349843
+ };
349769
349844
  UUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
349770
349845
  MessageSourceSchema = exports_external.enum(["realtime", "sync", "api", "import"]);
349771
349846
  MessageTypeSchema = exports_external.enum([
@@ -350240,6 +350315,7 @@ var init_messages5 = __esm(() => {
350240
350315
  });
350241
350316
  }
350242
350317
  const resolvedTo = await resolveRecipient(data.to, instance4.channel, services);
350318
+ const mediaMimeType = data.mimeType ?? inferMediaMimeType(data.type, data.filename);
350243
350319
  const outgoingMessage = {
350244
350320
  to: resolvedTo,
350245
350321
  threadId: data.threadId,
@@ -350248,7 +350324,7 @@ var init_messages5 = __esm(() => {
350248
350324
  mediaUrl: data.url,
350249
350325
  caption: data.caption,
350250
350326
  filename: data.filename,
350251
- mimeType: data.mimeType
350327
+ mimeType: mediaMimeType
350252
350328
  },
350253
350329
  metadata: {
350254
350330
  base64: data.base64,
@@ -353059,16 +353135,20 @@ async function setupEventPersistence(eventBus, db2) {
353059
353135
  eventType: "message.sent",
353060
353136
  direction: "outbound",
353061
353137
  contentType: mapContentType2(payload.content.type),
353062
- textContent: sanitizeText(payload.content.text),
353138
+ textContent: sanitizeText(payload.content.text ?? payload.content.caption),
353063
353139
  mediaUrl: payload.content.mediaUrl,
353140
+ mediaMimeType: payload.content.mimeType,
353064
353141
  chatId: payload.chatId,
353065
353142
  replyToExternalId: payload.replyToId,
353066
353143
  status: "completed",
353067
353144
  receivedAt: new Date(event.timestamp),
353068
353145
  processedAt: new Date,
353146
+ rawPayload: payload.rawPayload ? deepSanitize(payload.rawPayload) : undefined,
353069
353147
  metadata: {
353070
353148
  correlationId: metadata.correlationId,
353071
- to: payload.to
353149
+ to: payload.to,
353150
+ filename: payload.content.filename,
353151
+ voiceNote: payload.content.isVoiceNote
353072
353152
  },
353073
353153
  agentId: metadata.agentId ?? null,
353074
353154
  conversationId: null,
@@ -479098,6 +479178,49 @@ class WhatsAppPlugin extends BaseChannelPlugin {
479098
479178
  }
479099
479179
  return phoneJid;
479100
479180
  }
479181
+ getSentMediaSource(message2) {
479182
+ if (message2.content.mediaUrl)
479183
+ return "url";
479184
+ if (message2.content.localPath)
479185
+ return "localPath";
479186
+ if (message2.metadata?.base64)
479187
+ return "base64";
479188
+ return;
479189
+ }
479190
+ buildSentRawPayload(externalId, originalMessage, processedMessage) {
479191
+ const mediaSource = this.getSentMediaSource(processedMessage);
479192
+ return {
479193
+ externalId,
479194
+ isFromMe: true,
479195
+ to: originalMessage.to,
479196
+ ...processedMessage.content.caption ? { caption: processedMessage.content.caption } : {},
479197
+ ...processedMessage.content.filename ? { filename: processedMessage.content.filename } : {},
479198
+ ...processedMessage.content.mimeType ? { mimeType: processedMessage.content.mimeType } : {},
479199
+ ...processedMessage.metadata?.ptt === true ? { voiceNote: true } : {},
479200
+ ...mediaSource ? { mediaSource } : {}
479201
+ };
479202
+ }
479203
+ buildSentEventPayload(instanceId, externalId, chatId, originalMessage, processedMessage) {
479204
+ return {
479205
+ instanceId,
479206
+ externalId,
479207
+ chatId,
479208
+ to: originalMessage.to,
479209
+ content: {
479210
+ type: processedMessage.content.type,
479211
+ text: processedMessage.content.text ?? processedMessage.content.caption,
479212
+ caption: processedMessage.content.caption,
479213
+ mediaUrl: processedMessage.content.mediaUrl,
479214
+ localPath: processedMessage.content.localPath,
479215
+ mimeType: processedMessage.content.mimeType,
479216
+ filename: processedMessage.content.filename,
479217
+ isVoiceNote: processedMessage.metadata?.ptt === true
479218
+ },
479219
+ replyToId: originalMessage.replyTo,
479220
+ rawPayload: this.buildSentRawPayload(externalId, originalMessage, processedMessage),
479221
+ senderAgentId: originalMessage.metadata?.senderAgentId
479222
+ };
479223
+ }
479101
479224
  async sendMessage(instanceId, message2) {
479102
479225
  const sock = this.getSocket(instanceId);
479103
479226
  const jid = await this.resolveSendTarget(sock, instanceId, message2.to);
@@ -479124,18 +479247,7 @@ class WhatsAppPlugin extends BaseChannelPlugin {
479124
479247
  this.trackRecentSentMessage(instanceId, externalId, result.message);
479125
479248
  }
479126
479249
  }
479127
- await this.emitMessageSent({
479128
- instanceId,
479129
- externalId,
479130
- chatId: jid,
479131
- to: message2.to,
479132
- content: {
479133
- type: message2.content.type,
479134
- text: message2.content.text
479135
- },
479136
- replyToId: message2.replyTo,
479137
- senderAgentId: message2.metadata?.senderAgentId
479138
- });
479250
+ await this.emitMessageSent(this.buildSentEventPayload(instanceId, externalId, jid, message2, processedMessage));
479139
479251
  rateLimiter.reset();
479140
479252
  return {
479141
479253
  success: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260523.1",
3
+ "version": "2.260525.1",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {