@automagik/omni 2.260704.7 → 2.260704.9

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
@@ -125010,7 +125010,7 @@ import { fileURLToPath } from "url";
125010
125010
  // package.json
125011
125011
  var package_default = {
125012
125012
  name: "@automagik/omni",
125013
- version: "2.260704.7",
125013
+ version: "2.260704.9",
125014
125014
  description: "LLM-optimized CLI for Omni",
125015
125015
  type: "module",
125016
125016
  bin: {
@@ -35059,52 +35059,80 @@ var init_download_guard = __esm(() => {
35059
35059
  });
35060
35060
 
35061
35061
  // ../channel-sdk/src/media-backends/config.ts
35062
- function parseBool(value, defaultValue) {
35063
- if (value === undefined)
35062
+ function boolFromEnv(defaultValue) {
35063
+ return exports_external.string().optional().transform((value) => {
35064
+ if (value === undefined)
35065
+ return defaultValue;
35066
+ const normalized = value.trim().toLowerCase();
35067
+ if (["1", "true", "yes", "on"].includes(normalized))
35068
+ return true;
35069
+ if (["0", "false", "no", "off"].includes(normalized))
35070
+ return false;
35064
35071
  return defaultValue;
35065
- const normalized = value.trim().toLowerCase();
35066
- if (["1", "true", "yes", "on"].includes(normalized))
35067
- return true;
35068
- if (["0", "false", "no", "off"].includes(normalized))
35069
- return false;
35070
- return defaultValue;
35072
+ });
35071
35073
  }
35072
- function parseTtl(value, defaultValue) {
35073
- if (value === undefined)
35074
- return defaultValue;
35075
- const parsed = Number.parseInt(value.trim(), 10);
35076
- return Number.isFinite(parsed) && parsed > 0 ? parsed : defaultValue;
35074
+ function ttlFromEnv(defaultValue) {
35075
+ return exports_external.string().optional().transform((value) => {
35076
+ if (value === undefined)
35077
+ return defaultValue;
35078
+ const parsed = Number.parseInt(value.trim(), 10);
35079
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : defaultValue;
35080
+ });
35077
35081
  }
35078
35082
  function resolveMediaBackendConfig(env = process.env) {
35079
- const mode = (env.OMNI_MEDIA_MODE ?? "local").trim().toLowerCase();
35080
- if (mode !== "remote") {
35083
+ const parsed = MediaEnvSchema.safeParse(env);
35084
+ if (!parsed.success) {
35085
+ throw new Error(parsed.error.issues.map((issue) => issue.message).join("; "));
35086
+ }
35087
+ const vars = parsed.data;
35088
+ if (vars.OMNI_MEDIA_MODE !== "remote") {
35081
35089
  return { mode: "local" };
35082
35090
  }
35083
- const bucket = env.OMNI_MEDIA_S3_BUCKET?.trim();
35084
- const accessKeyId = env.OMNI_MEDIA_S3_ACCESS_KEY?.trim();
35085
- const secretKey = env.OMNI_MEDIA_S3_SECRET_KEY?.trim();
35086
- const missing = [
35087
- ["OMNI_MEDIA_S3_BUCKET", bucket],
35088
- ["OMNI_MEDIA_S3_ACCESS_KEY", accessKeyId],
35089
- ["OMNI_MEDIA_S3_SECRET_KEY", secretKey]
35090
- ].filter(([, value]) => !value).map(([name]) => name);
35091
- if (missing.length > 0) {
35091
+ const bucket = vars.OMNI_MEDIA_S3_BUCKET;
35092
+ const accessKeyId = vars.OMNI_MEDIA_S3_ACCESS_KEY;
35093
+ const secretKey = vars.OMNI_MEDIA_S3_SECRET_KEY;
35094
+ if (!bucket || !accessKeyId || !secretKey) {
35095
+ const missing = [
35096
+ ["OMNI_MEDIA_S3_BUCKET", bucket],
35097
+ ["OMNI_MEDIA_S3_ACCESS_KEY", accessKeyId],
35098
+ ["OMNI_MEDIA_S3_SECRET_KEY", secretKey]
35099
+ ].filter(([, value]) => !value).map(([name]) => name);
35092
35100
  throw new Error(`OMNI_MEDIA_MODE=remote requires these env vars: ${missing.join(", ")}`);
35093
35101
  }
35094
35102
  return {
35095
35103
  mode: "remote",
35096
35104
  s3: {
35097
- endpoint: env.OMNI_MEDIA_S3_ENDPOINT?.trim() || undefined,
35105
+ endpoint: vars.OMNI_MEDIA_S3_ENDPOINT,
35106
+ publicEndpoint: vars.OMNI_MEDIA_S3_PUBLIC_ENDPOINT,
35098
35107
  bucket,
35099
- region: env.OMNI_MEDIA_S3_REGION?.trim() || DEFAULT_REGION,
35108
+ region: vars.OMNI_MEDIA_S3_REGION ?? DEFAULT_REGION,
35100
35109
  accessKeyId,
35101
35110
  secretKey,
35102
- forcePathStyle: parseBool(env.OMNI_MEDIA_S3_FORCE_PATH_STYLE, true),
35103
- presignTtlSeconds: parseTtl(env.OMNI_MEDIA_S3_PRESIGN_TTL_SECONDS, DEFAULT_PRESIGN_TTL_SECONDS)
35111
+ forcePathStyle: vars.OMNI_MEDIA_S3_FORCE_PATH_STYLE,
35112
+ presignTtlSeconds: vars.OMNI_MEDIA_S3_PRESIGN_TTL_SECONDS
35104
35113
  }
35105
35114
  };
35106
35115
  }
35107
- var DEFAULT_PRESIGN_TTL_SECONDS = 3600, DEFAULT_REGION = "us-east-1";
35116
+ var DEFAULT_PRESIGN_TTL_SECONDS = 3600, DEFAULT_REGION = "us-east-1", optionalTrimmedString, MediaEnvSchema;
35117
+ var init_config = __esm(() => {
35118
+ init_zod();
35119
+ optionalTrimmedString = exports_external.string().optional().transform((value) => value?.trim() || undefined);
35120
+ MediaEnvSchema = exports_external.object({
35121
+ OMNI_MEDIA_MODE: exports_external.string().optional().transform((value) => (value ?? "local").trim().toLowerCase()).pipe(exports_external.enum(["local", "remote"], {
35122
+ errorMap: (_issue, ctx) => ({
35123
+ message: `Invalid OMNI_MEDIA_MODE="${String(ctx.data)}" \u2014 expected "local" or "remote" (unset defaults to local). Refusing to silently fall back to local disk.`
35124
+ })
35125
+ })),
35126
+ OMNI_MEDIA_S3_ENDPOINT: optionalTrimmedString,
35127
+ OMNI_MEDIA_S3_PUBLIC_ENDPOINT: optionalTrimmedString,
35128
+ OMNI_MEDIA_S3_BUCKET: optionalTrimmedString,
35129
+ OMNI_MEDIA_S3_REGION: optionalTrimmedString,
35130
+ OMNI_MEDIA_S3_ACCESS_KEY: optionalTrimmedString,
35131
+ OMNI_MEDIA_S3_SECRET_KEY: optionalTrimmedString,
35132
+ OMNI_MEDIA_S3_FORCE_PATH_STYLE: boolFromEnv(true),
35133
+ OMNI_MEDIA_S3_PRESIGN_TTL_SECONDS: ttlFromEnv(DEFAULT_PRESIGN_TTL_SECONDS)
35134
+ });
35135
+ });
35108
35136
 
35109
35137
  // ../channel-sdk/src/media-backends/local-backend.ts
35110
35138
  import { createWriteStream, existsSync, mkdirSync, writeFileSync } from "fs";
@@ -35176,20 +35204,26 @@ var init_local_backend = __esm(() => {
35176
35204
  class S3MediaBackend {
35177
35205
  mode = "remote";
35178
35206
  client;
35207
+ presignClient;
35179
35208
  presignTtlSeconds;
35180
35209
  constructor(config2) {
35181
35210
  this.presignTtlSeconds = config2.presignTtlSeconds;
35182
- this.client = new Bun.S3Client({
35211
+ const clientOptions = {
35183
35212
  accessKeyId: config2.accessKeyId,
35184
35213
  secretAccessKey: config2.secretKey,
35185
35214
  bucket: config2.bucket,
35186
35215
  region: config2.region,
35187
- ...config2.endpoint ? { endpoint: config2.endpoint } : {},
35188
35216
  ...config2.forcePathStyle ? {} : { virtualHostedStyle: true }
35217
+ };
35218
+ this.client = new Bun.S3Client({
35219
+ ...clientOptions,
35220
+ ...config2.endpoint ? { endpoint: config2.endpoint } : {}
35189
35221
  });
35222
+ this.presignClient = config2.publicEndpoint ? new Bun.S3Client({ ...clientOptions, endpoint: config2.publicEndpoint }) : this.client;
35190
35223
  log19.info("Initialized S3 media backend", {
35191
35224
  bucket: config2.bucket,
35192
35225
  endpoint: config2.endpoint ?? "aws",
35226
+ publicEndpoint: config2.publicEndpoint ?? config2.endpoint ?? "aws",
35193
35227
  forcePathStyle: config2.forcePathStyle
35194
35228
  });
35195
35229
  }
@@ -35212,19 +35246,32 @@ class S3MediaBackend {
35212
35246
  }
35213
35247
  } catch (error) {
35214
35248
  await Promise.resolve(writer.end(error)).catch(() => {});
35249
+ await this.deleteQuietly(key);
35215
35250
  throw error;
35216
35251
  }
35217
35252
  await writer.end();
35253
+ if (size === 0) {
35254
+ await this.deleteQuietly(key);
35255
+ log19.debug("Removed empty media object from S3", { key });
35256
+ return { reference: key, size, mimeType };
35257
+ }
35218
35258
  log19.debug("Streamed media to S3", { key, size });
35219
35259
  return { reference: key, size, mimeType };
35220
35260
  }
35261
+ async deleteQuietly(key) {
35262
+ try {
35263
+ await this.client.delete(key);
35264
+ } catch (error) {
35265
+ log19.warn("Failed to delete orphaned S3 object", { key, error: String(error) });
35266
+ }
35267
+ }
35221
35268
  async read(key) {
35222
35269
  const bytes = await this.client.file(key).arrayBuffer();
35223
35270
  log19.debug("Read media from S3", { key, size: bytes.byteLength });
35224
35271
  return Buffer.from(bytes);
35225
35272
  }
35226
35273
  async presignedUrl(key, ttlSeconds = this.presignTtlSeconds) {
35227
- return this.client.presign(key, { expiresIn: ttlSeconds, method: "GET" });
35274
+ return this.presignClient.presign(key, { expiresIn: ttlSeconds, method: "GET" });
35228
35275
  }
35229
35276
  }
35230
35277
  var log19;
@@ -35242,8 +35289,10 @@ function createMediaBackend(basePath, config2 = resolveMediaBackendConfig()) {
35242
35289
  return new LocalMediaBackend(basePath);
35243
35290
  }
35244
35291
  var init_media_backends = __esm(() => {
35292
+ init_config();
35245
35293
  init_local_backend();
35246
35294
  init_s3_backend();
35295
+ init_config();
35247
35296
  init_local_backend();
35248
35297
  init_s3_backend();
35249
35298
  });
@@ -225489,7 +225538,7 @@ var init_sentry_scrub = __esm(() => {
225489
225538
  var require_package7 = __commonJS((exports, module) => {
225490
225539
  module.exports = {
225491
225540
  name: "@omni/api",
225492
- version: "2.260704.7",
225541
+ version: "2.260704.9",
225493
225542
  type: "module",
225494
225543
  exports: {
225495
225544
  ".": {
@@ -281330,15 +281379,20 @@ function countMigrationFiles(migrationsFolder) {
281330
281379
  }
281331
281380
  async function applyMigrations(db2, migrationsFolder) {
281332
281381
  const fileCount = countMigrationFiles(migrationsFolder);
281333
- await migrate(db2, { migrationsFolder });
281334
- const result = await db2.execute(sql`SELECT count(*) AS count FROM drizzle.__drizzle_migrations`);
281335
- const appliedCount = Number(result[0].count);
281336
- if (appliedCount < fileCount) {
281337
- throw new Error(`Migration count mismatch: ${appliedCount} applied, ${fileCount} files. ${fileCount - appliedCount} migration(s) were silently skipped. Ensure _journal.json "when" timestamps are strictly increasing.`);
281338
- }
281339
- log56.info("All migrations applied", { appliedCount, fileCount });
281382
+ await db2.transaction(async (tx) => {
281383
+ log56.info("Acquiring migration advisory lock", { lockId: MIGRATION_LOCK_ID });
281384
+ await tx.execute(sql`SELECT pg_advisory_xact_lock(${MIGRATION_LOCK_ID})`);
281385
+ log56.info("Migration advisory lock acquired");
281386
+ await migrate(db2, { migrationsFolder });
281387
+ const result = await db2.execute(sql`SELECT count(*) AS count FROM drizzle.__drizzle_migrations`);
281388
+ const appliedCount = Number(result[0].count);
281389
+ if (appliedCount < fileCount) {
281390
+ throw new Error(`Migration count mismatch: ${appliedCount} applied, ${fileCount} files. ${fileCount - appliedCount} migration(s) were silently skipped. Ensure _journal.json "when" timestamps are strictly increasing.`);
281391
+ }
281392
+ log56.info("All migrations applied", { appliedCount, fileCount });
281393
+ });
281340
281394
  }
281341
- var log56;
281395
+ var log56, MIGRATION_LOCK_ID = 772005770;
281342
281396
  var init_migrate = __esm(() => {
281343
281397
  init_src();
281344
281398
  init_drizzle_orm();
@@ -316249,7 +316303,7 @@ var init_audio2 = __esm(() => {
316249
316303
  return [
316250
316304
  () => this.transcribeWithOpenAiAudioChat(language, options, preferredModel ?? OPENAI_AUDIO_CHAT_MODEL, getNormalizedAudio),
316251
316305
  () => this.transcribeWithOpenAiTranscriptions(language, options, OPENAI_TRANSCRIBE_MODEL, getNormalizedAudio),
316252
- () => this.transcribeWithGemini(language, options, GEMINI_AUDIO_MODEL, getNormalizedAudio),
316306
+ () => this.transcribeWithGemini(language, options, this.resolveGeminiAudioModel(undefined), getNormalizedAudio),
316253
316307
  () => this.transcribeWithGroq(language, getNormalizedAudio)
316254
316308
  ];
316255
316309
  }
@@ -333162,7 +333216,10 @@ var init_batch_pricing = __esm(() => {
333162
333216
  });
333163
333217
 
333164
333218
  // ../api/src/services/media-storage.ts
333219
+ import { randomUUID as randomUUID2 } from "crypto";
333165
333220
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync6, statSync as statSync3 } from "fs";
333221
+ import { rm as rm3, writeFile as writeFile5 } from "fs/promises";
333222
+ import { tmpdir as tmpdir11 } from "os";
333166
333223
  import { extname as extname2, join as join21 } from "path";
333167
333224
  function normalizeMimeType2(value) {
333168
333225
  return value?.split(";")[0]?.trim().toLowerCase() || undefined;
@@ -333398,6 +333455,26 @@ class MediaStorageService {
333398
333455
  async presignedUrl(reference, ttlSeconds) {
333399
333456
  return this.backend.presignedUrl(reference, ttlSeconds);
333400
333457
  }
333458
+ async materializeForProcessing(reference) {
333459
+ if (this.backend.mode === "local") {
333460
+ return { path: join21(this.basePath, reference), cleanup: async () => {} };
333461
+ }
333462
+ const buffer3 = await this.backend.read(reference);
333463
+ const ext = extname2(reference) || ".bin";
333464
+ const tempPath = join21(tmpdir11(), `omni-media-${randomUUID2()}${ext}`);
333465
+ try {
333466
+ await writeFile5(tempPath, buffer3);
333467
+ } catch (error3) {
333468
+ await rm3(tempPath, { force: true }).catch(() => {});
333469
+ throw error3;
333470
+ }
333471
+ return {
333472
+ path: tempPath,
333473
+ cleanup: async () => {
333474
+ await rm3(tempPath, { force: true });
333475
+ }
333476
+ };
333477
+ }
333401
333478
  }
333402
333479
  var log83, DEFAULT_MEDIA_PATH = "./data/media";
333403
333480
  var init_media_storage = __esm(() => {
@@ -333409,8 +333486,6 @@ var init_media_storage = __esm(() => {
333409
333486
  });
333410
333487
 
333411
333488
  // ../api/src/services/batch-jobs.ts
333412
- import { join as join22 } from "path";
333413
-
333414
333489
  class BatchJobService {
333415
333490
  db;
333416
333491
  eventBus;
@@ -333837,10 +333912,15 @@ class BatchJobService {
333837
333912
  if (!resolved.ok) {
333838
333913
  return this.failedResult(resolved.reason);
333839
333914
  }
333840
- const fullPath = join22(this.mediaStorage.getBasePath(), resolved.path);
333841
- const result = await mediaService.process(fullPath, mimeType, {
333842
- caption: message2.textContent ?? undefined
333843
- });
333915
+ const materialized = await this.mediaStorage.materializeForProcessing(resolved.path);
333916
+ let result;
333917
+ try {
333918
+ result = await mediaService.process(materialized.path, mimeType, {
333919
+ caption: message2.textContent ?? undefined
333920
+ });
333921
+ } finally {
333922
+ await materialized.cleanup();
333923
+ }
333844
333924
  if (result.success && result.content) {
333845
333925
  await this.persistProcessingResult(message2.id, result, batchJobId);
333846
333926
  }
@@ -337596,12 +337676,12 @@ var init_context3 = __esm(() => {
337596
337676
 
337597
337677
  // ../api/src/plugins/loader.ts
337598
337678
  import { existsSync as existsSync4 } from "fs";
337599
- import { dirname as dirname6, join as join23 } from "path";
337679
+ import { dirname as dirname6, join as join22 } from "path";
337600
337680
  import { fileURLToPath } from "url";
337601
337681
  function findMonorepoRoot(startDir) {
337602
337682
  let current = startDir;
337603
337683
  while (current !== dirname6(current)) {
337604
- if (existsSync4(join23(current, "turbo.json"))) {
337684
+ if (existsSync4(join22(current, "turbo.json"))) {
337605
337685
  return current;
337606
337686
  }
337607
337687
  current = dirname6(current);
@@ -337620,7 +337700,7 @@ function getMonorepoPackagesDir() {
337620
337700
  if (!monorepoRoot) {
337621
337701
  throw new Error("Could not find monorepo root (no turbo.json found). " + "Ensure you run from repo root or set OMNI_PACKAGES_DIR env var.");
337622
337702
  }
337623
- return join23(monorepoRoot, "packages");
337703
+ return join22(monorepoRoot, "packages");
337624
337704
  }
337625
337705
  async function loadChannelPlugins2(options) {
337626
337706
  const { eventBus, db: db2 } = options;
@@ -338509,9 +338589,9 @@ var init_session_storage = __esm(() => {
338509
338589
 
338510
338590
  // ../api/src/plugins/agent-dispatcher.ts
338511
338591
  import { createHash as createHash10 } from "crypto";
338512
- import { unlink, writeFile as writeFile5 } from "fs/promises";
338513
- import { tmpdir as tmpdir11 } from "os";
338514
- import { join as join24, resolve as resolve3 } from "path";
338592
+ import { unlink, writeFile as writeFile6 } from "fs/promises";
338593
+ import { tmpdir as tmpdir12 } from "os";
338594
+ import { join as join23, resolve as resolve3 } from "path";
338515
338595
  function sha256Digest(value) {
338516
338596
  return `sha256:${createHash10("sha256").update(value).digest("hex")}`;
338517
338597
  }
@@ -338962,7 +339042,7 @@ async function resolveDispatchMediaPath(mediaStorage, reference) {
338962
339042
  return null;
338963
339043
  }
338964
339044
  }
338965
- return resolve3(join24(MEDIA_BASE_PATH3, reference));
339045
+ return resolve3(join23(MEDIA_BASE_PATH3, reference));
338966
339046
  }
338967
339047
  async function remoteMediaFile(m2, mimeType, mediaStorage, allowedTypes) {
338968
339048
  const key = m2.payload.rawPayload?.mediaLocalPath;
@@ -339021,7 +339101,7 @@ function checkProcessedColumn(msg, column2) {
339021
339101
  if (typeof processed === "string" && processed.startsWith("[error"))
339022
339102
  return "error";
339023
339103
  if (processed) {
339024
- const localPath = msg.mediaLocalPath ? resolve3(join24(MEDIA_BASE_PATH3, msg.mediaLocalPath)) : null;
339104
+ const localPath = msg.mediaLocalPath ? resolve3(join23(MEDIA_BASE_PATH3, msg.mediaLocalPath)) : null;
339025
339105
  return {
339026
339106
  content: processed,
339027
339107
  localPath
@@ -340193,8 +340273,8 @@ async function downloadToTempFile(url, mimeType) {
340193
340273
  return null;
340194
340274
  const buffer3 = Buffer.from(await res.arrayBuffer());
340195
340275
  const ext = (mimeType.split("/")[1]?.split(";")[0] ?? "bin").replace(/[^a-z0-9]/gi, "");
340196
- const tmpPath = join24(tmpdir11(), `omni-hist-${Date.now()}-${Math.random().toString(36).slice(2)}.${ext}`);
340197
- await writeFile5(tmpPath, buffer3);
340276
+ const tmpPath = join23(tmpdir12(), `omni-hist-${Date.now()}-${Math.random().toString(36).slice(2)}.${ext}`);
340277
+ await writeFile6(tmpPath, buffer3);
340198
340278
  return tmpPath;
340199
340279
  } catch {
340200
340280
  return null;
@@ -342655,8 +342735,8 @@ var init_sync_jobs = __esm(() => {
342655
342735
  // ../api/src/services/tts.ts
342656
342736
  import { spawn as spawn5 } from "child_process";
342657
342737
  import { promises as fs15 } from "fs";
342658
- import { tmpdir as tmpdir12 } from "os";
342659
- import { join as join25 } from "path";
342738
+ import { tmpdir as tmpdir13 } from "os";
342739
+ import { join as join24 } from "path";
342660
342740
  function spawnWithEvents5(command, args) {
342661
342741
  return spawn5(command, args);
342662
342742
  }
@@ -342764,8 +342844,8 @@ var init_tts3 = __esm(() => {
342764
342844
  return Buffer.from(await response.arrayBuffer());
342765
342845
  }
342766
342846
  async convertToOggOpus(mp3Buffer) {
342767
- const inputPath = join25(tmpdir12(), `omni-tts-${Date.now()}-input.mp3`);
342768
- const outputPath = join25(tmpdir12(), `omni-tts-${Date.now()}-output.ogg`);
342847
+ const inputPath = join24(tmpdir13(), `omni-tts-${Date.now()}-input.mp3`);
342848
+ const outputPath = join24(tmpdir13(), `omni-tts-${Date.now()}-output.ogg`);
342769
342849
  try {
342770
342850
  await fs15.writeFile(inputPath, mp3Buffer);
342771
342851
  await new Promise((resolve4, reject) => {
@@ -342811,7 +342891,7 @@ var init_tts3 = __esm(() => {
342811
342891
  }
342812
342892
  }
342813
342893
  async getAudioDurationMs(audioBuffer) {
342814
- const tempPath = join25(tmpdir12(), `omni-tts-${Date.now()}-duration.ogg`);
342894
+ const tempPath = join24(tmpdir13(), `omni-tts-${Date.now()}-duration.ogg`);
342815
342895
  try {
342816
342896
  await fs15.writeFile(tempPath, audioBuffer);
342817
342897
  return await new Promise((resolve4) => {
@@ -343632,12 +343712,12 @@ var init_timeout = __esm(() => {
343632
343712
 
343633
343713
  // ../api/src/middleware/version-headers.ts
343634
343714
  import { existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
343635
- import { join as join26 } from "path";
343715
+ import { join as join25 } from "path";
343636
343716
  function loadRepoPackageVersion() {
343637
343717
  try {
343638
343718
  for (const candidate of [
343639
- join26(import.meta.dir, "..", "..", "..", "..", "package.json"),
343640
- join26(process.cwd(), "package.json")
343719
+ join25(import.meta.dir, "..", "..", "..", "..", "package.json"),
343720
+ join25(process.cwd(), "package.json")
343641
343721
  ]) {
343642
343722
  if (!existsSync5(candidate))
343643
343723
  continue;
@@ -343659,8 +343739,8 @@ function resolveFallbackVersion() {
343659
343739
  function loadServerVersionInfo() {
343660
343740
  try {
343661
343741
  for (const candidate of [
343662
- join26(import.meta.dir, "..", "..", "..", "..", "version.json"),
343663
- join26(process.cwd(), "version.json")
343742
+ join25(import.meta.dir, "..", "..", "..", "..", "version.json"),
343743
+ join25(process.cwd(), "version.json")
343664
343744
  ]) {
343665
343745
  if (!existsSync5(candidate)) {
343666
343746
  continue;
@@ -356969,7 +357049,7 @@ var init__close_contact_config = __esm(() => {
356969
357049
 
356970
357050
  // ../api/src/routes/v2/messages.ts
356971
357051
  import { existsSync as existsSync6 } from "fs";
356972
- import { extname as extname3, join as join27 } from "path";
357052
+ import { extname as extname3, join as join26 } from "path";
356973
357053
  function inferMediaMimeType(type, filename) {
356974
357054
  if (filename) {
356975
357055
  const fromExtension = MIME_BY_EXTENSION[extname3(filename).toLowerCase()];
@@ -357528,7 +357608,7 @@ var init_messages5 = __esm(() => {
357528
357608
  let mediaLocalPath = message2.mediaLocalPath;
357529
357609
  let cached = false;
357530
357610
  if (mediaLocalPath) {
357531
- const fullPath = join27(mediaStorage2.getBasePath(), mediaLocalPath);
357611
+ const fullPath = join26(mediaStorage2.getBasePath(), mediaLocalPath);
357532
357612
  if (existsSync6(fullPath)) {
357533
357613
  cached = true;
357534
357614
  } else {
@@ -360766,10 +360846,6 @@ var init_event_persistence = __esm(() => {
360766
360846
  });
360767
360847
 
360768
360848
  // ../api/src/plugins/media-processor.ts
360769
- import { randomUUID as randomUUID2 } from "crypto";
360770
- import { rm as rm3, writeFile as writeFile6 } from "fs/promises";
360771
- import { tmpdir as tmpdir13 } from "os";
360772
- import { extname as extname4, join as join28 } from "path";
360773
360849
  function getContentFieldForType(processingType, contentType) {
360774
360850
  switch (processingType) {
360775
360851
  case "transcription":
@@ -360880,26 +360956,6 @@ async function resolveMediaPath2(ctx, instanceId, chatId, externalId, content, m
360880
360956
  filePath
360881
360957
  };
360882
360958
  }
360883
- async function materializeForProcessing(ctx, filePath) {
360884
- if (ctx.mediaStorage.getStorageMode() === "local") {
360885
- return { path: join28(ctx.mediaStorage.getBasePath(), filePath), cleanup: async () => {} };
360886
- }
360887
- const buffer3 = await ctx.mediaStorage.read(filePath);
360888
- const ext = extname4(filePath) || ".bin";
360889
- const tempPath = join28(tmpdir13(), `omni-media-${randomUUID2()}${ext}`);
360890
- try {
360891
- await writeFile6(tempPath, buffer3);
360892
- } catch (error3) {
360893
- await rm3(tempPath, { force: true }).catch(() => {});
360894
- throw error3;
360895
- }
360896
- return {
360897
- path: tempPath,
360898
- cleanup: async () => {
360899
- await rm3(tempPath, { force: true });
360900
- }
360901
- };
360902
- }
360903
360959
  async function resolveSafeMediaContentEventId(ctx, eventId) {
360904
360960
  if (!isUuid(eventId))
360905
360961
  return null;
@@ -360973,7 +361029,7 @@ async function processMessageMedia(ctx, payload, metadata) {
360973
361029
  const media = await resolveMediaPath2(ctx, instanceId, payload.chatId, externalId, content, mimeType, metadata.channelType);
360974
361030
  if (!media)
360975
361031
  return;
360976
- const processable = await materializeForProcessing(ctx, media.filePath);
361032
+ const processable = await ctx.mediaStorage.materializeForProcessing(media.filePath);
360977
361033
  log113.info("Processing media", { messageId: media.messageId, mimeType, filePath: processable.path });
360978
361034
  let result;
360979
361035
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260704.7",
3
+ "version": "2.260704.9",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {