omnius 1.0.30 → 1.0.31

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
@@ -89,7 +89,7 @@ function loadConfigFile() {
89
89
  }
90
90
  function loadConfig() {
91
91
  const fromFile = loadConfigFile();
92
- const backendUrl = process.env["OMNIUS_BACKEND_URL"] ?? process.env["VLLM_BASE_URL"] ?? fromFile.backendUrl ?? DEFAULT_CONFIG.backendUrl;
92
+ const backendUrl2 = process.env["OMNIUS_BACKEND_URL"] ?? process.env["VLLM_BASE_URL"] ?? fromFile.backendUrl ?? DEFAULT_CONFIG.backendUrl;
93
93
  const model = process.env["OMNIUS_MODEL"] ?? fromFile.model ?? DEFAULT_CONFIG.model;
94
94
  const backendType = parseBackendType(process.env["OMNIUS_BACKEND_TYPE"]) ?? fromFile.backendType ?? DEFAULT_CONFIG.backendType;
95
95
  const apiKey = process.env["OMNIUS_API_KEY"] ?? process.env["VLLM_API_KEY"] ?? fromFile.apiKey ?? DEFAULT_CONFIG.apiKey;
@@ -104,7 +104,7 @@ function loadConfig() {
104
104
  const dryRun = process.env["OMNIUS_DRY_RUN"] !== void 0 ? parseBool(process.env["OMNIUS_DRY_RUN"]) : fromFile.dryRun ?? DEFAULT_CONFIG.dryRun;
105
105
  const verbose = process.env["OMNIUS_VERBOSE"] !== void 0 ? parseBool(process.env["OMNIUS_VERBOSE"]) : fromFile.verbose ?? DEFAULT_CONFIG.verbose;
106
106
  const dbPath = process.env["OMNIUS_DB_PATH"] ?? fromFile.dbPath ?? DEFAULT_CONFIG.dbPath;
107
- return { backendUrl, model, backendType, apiKey, maxRetries, timeoutMs, dryRun, verbose, dbPath };
107
+ return { backendUrl: backendUrl2, model, backendType, apiKey, maxRetries, timeoutMs, dryRun, verbose, dbPath };
108
108
  }
109
109
  function mergeConfig(base3, overrides) {
110
110
  return { ...base3, ...overrides };
@@ -5587,11 +5587,11 @@ function searchFile(repoRoot, fullPath, query, snippetChars) {
5587
5587
  if (positions.length === 0)
5588
5588
  return null;
5589
5589
  const snippets = positions.slice(0, 3).map((pos) => buildSnippet(haystack, pos, query.length, snippetChars));
5590
- const stat5 = statSync3(fullPath);
5590
+ const stat6 = statSync3(fullPath);
5591
5591
  return {
5592
5592
  file: relative(repoRoot, fullPath),
5593
5593
  score: positions.length,
5594
- modifiedAt: stat5.mtime.toISOString(),
5594
+ modifiedAt: stat6.mtime.toISOString(),
5595
5595
  snippets
5596
5596
  };
5597
5597
  }
@@ -7816,9 +7816,9 @@ var nexus_exports = {};
7816
7816
  __export(nexus_exports, {
7817
7817
  NexusTool: () => NexusTool
7818
7818
  });
7819
- import { readFile as readFile9, writeFile as writeFile6, mkdir as mkdir3, chmod, unlink, readdir as readdir2, open as fsOpen, copyFile as copyFile2 } from "node:fs/promises";
7819
+ import { readFile as readFile9, writeFile as writeFile6, mkdir as mkdir3, chmod, unlink, readdir as readdir2, open as fsOpen, copyFile as copyFile2, rm, stat } from "node:fs/promises";
7820
7820
  import { existsSync as existsSync17, readFileSync as readFileSync14, watch as fsWatchLocal } from "node:fs";
7821
- import { resolve as resolve13, join as join21 } from "node:path";
7821
+ import { basename as basename2, dirname as dirname3, resolve as resolve13, join as join21 } from "node:path";
7822
7822
  import { randomBytes as randomBytes6, createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, scryptSync, createHash as createHash4 } from "node:crypto";
7823
7823
  import { execSync as execSync8, spawn as spawn3 } from "node:child_process";
7824
7824
  import { hostname, userInfo, homedir as homedir5 } from "node:os";
@@ -7839,6 +7839,49 @@ function readBundledDependencySpec(packageName, fallback) {
7839
7839
  }
7840
7840
  return fallback;
7841
7841
  }
7842
+ function truthyEnv(value2) {
7843
+ const normalized = (value2 || "").toLowerCase();
7844
+ return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
7845
+ }
7846
+ function projectScopedNexusEnabled() {
7847
+ const scope = (process.env["OMNIUS_NEXUS_SCOPE"] || "").toLowerCase();
7848
+ return truthyEnv(process.env["OMNIUS_NEXUS_PROJECT_SCOPE"]) || scope === "project" || scope === "local";
7849
+ }
7850
+ function isKnownNexusDir(path11) {
7851
+ const resolved = resolve13(path11);
7852
+ const parent = basename2(dirname3(resolved));
7853
+ return basename2(resolved) === "nexus" && (parent === ".omnius" || parent === ".oa");
7854
+ }
7855
+ function projectNexusDir(repoRoot) {
7856
+ const resolved = resolve13(repoRoot);
7857
+ if (isKnownNexusDir(resolved))
7858
+ return resolved;
7859
+ return resolve13(resolved, ".omnius", "nexus");
7860
+ }
7861
+ function resolveNexusDir(repoRoot) {
7862
+ const override = process.env["OMNIUS_NEXUS_DIR"];
7863
+ if (override && override.trim())
7864
+ return resolve13(override.trim());
7865
+ if (projectScopedNexusEnabled())
7866
+ return projectNexusDir(repoRoot);
7867
+ return resolve13(homedir5(), ".omnius", "nexus");
7868
+ }
7869
+ function sleep(ms) {
7870
+ return new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
7871
+ }
7872
+ function escapeRegExp(value2) {
7873
+ return value2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7874
+ }
7875
+ function processAlive(pid) {
7876
+ if (!Number.isFinite(pid) || pid <= 0)
7877
+ return false;
7878
+ try {
7879
+ process.kill(pid, 0);
7880
+ return true;
7881
+ } catch {
7882
+ return false;
7883
+ }
7884
+ }
7842
7885
  function containsKeyMaterial(input) {
7843
7886
  for (const pattern of KEY_PATTERNS) {
7844
7887
  if (pattern.test(input))
@@ -7846,13 +7889,14 @@ function containsKeyMaterial(input) {
7846
7889
  }
7847
7890
  return false;
7848
7891
  }
7849
- var OPEN_AGENTS_NEXUS_FALLBACK_SPEC, OPEN_AGENTS_NEXUS_BUNDLED_SPEC, DAEMON_SCRIPT, KEY_PATTERNS, NexusTool;
7892
+ var OPEN_AGENTS_NEXUS_FALLBACK_SPEC, OPEN_AGENTS_NEXUS_BUNDLED_SPEC, NEXUS_CONNECT_LOCK_TTL_MS, DAEMON_SCRIPT, KEY_PATTERNS, NexusTool;
7850
7893
  var init_nexus = __esm({
7851
7894
  "packages/execution/dist/tools/nexus.js"() {
7852
7895
  "use strict";
7853
7896
  init_jibberlink();
7854
7897
  OPEN_AGENTS_NEXUS_FALLBACK_SPEC = "1.17.3";
7855
7898
  OPEN_AGENTS_NEXUS_BUNDLED_SPEC = readBundledDependencySpec("open-agents-nexus", OPEN_AGENTS_NEXUS_FALLBACK_SPEC);
7899
+ NEXUS_CONNECT_LOCK_TTL_MS = 9e4;
7856
7900
  DAEMON_SCRIPT = `#!/usr/bin/env node
7857
7901
  /**
7858
7902
  * nexus-daemon.mjs — Standalone nexus process with real TCP/UDP sockets.
@@ -12803,8 +12847,8 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
12803
12847
  repoRoot;
12804
12848
  nexusDir;
12805
12849
  constructor(repoRoot) {
12806
- this.repoRoot = repoRoot;
12807
- this.nexusDir = resolve13(repoRoot, ".omnius", "nexus");
12850
+ this.repoRoot = resolve13(repoRoot);
12851
+ this.nexusDir = resolveNexusDir(this.repoRoot);
12808
12852
  }
12809
12853
  async ensureDir() {
12810
12854
  if (!existsSync17(this.nexusDir)) {
@@ -13134,16 +13178,69 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
13134
13178
  // =========================================================================
13135
13179
  async doConnect(args) {
13136
13180
  await this.ensureDir();
13181
+ const releaseLock2 = await this.acquireConnectLock();
13182
+ try {
13183
+ return await this.doConnectLocked(args);
13184
+ } finally {
13185
+ await releaseLock2();
13186
+ }
13187
+ }
13188
+ async acquireConnectLock() {
13189
+ const lockDir = join21(this.nexusDir, "connect.lock");
13190
+ const ownerFile = join21(lockDir, "owner.json");
13191
+ const deadline = Date.now() + NEXUS_CONNECT_LOCK_TTL_MS;
13192
+ while (Date.now() < deadline) {
13193
+ try {
13194
+ await mkdir3(lockDir);
13195
+ await writeFile6(ownerFile, JSON.stringify({
13196
+ pid: process.pid,
13197
+ repoRoot: this.repoRoot,
13198
+ nexusDir: this.nexusDir,
13199
+ startedAt: (/* @__PURE__ */ new Date()).toISOString()
13200
+ }, null, 2));
13201
+ return async () => {
13202
+ await rm(lockDir, { recursive: true, force: true }).catch(() => {
13203
+ });
13204
+ };
13205
+ } catch (err) {
13206
+ if (err?.code !== "EEXIST")
13207
+ throw err;
13208
+ }
13209
+ let stale = false;
13210
+ try {
13211
+ const owner = JSON.parse(await readFile9(ownerFile, "utf8"));
13212
+ const ownerPid = Number(owner?.pid);
13213
+ if (ownerPid && !processAlive(ownerPid))
13214
+ stale = true;
13215
+ } catch {
13216
+ try {
13217
+ const st = await stat(lockDir);
13218
+ if (Date.now() - st.mtimeMs > NEXUS_CONNECT_LOCK_TTL_MS)
13219
+ stale = true;
13220
+ } catch {
13221
+ stale = true;
13222
+ }
13223
+ }
13224
+ if (stale) {
13225
+ await rm(lockDir, { recursive: true, force: true }).catch(() => {
13226
+ });
13227
+ continue;
13228
+ }
13229
+ await sleep(150);
13230
+ }
13231
+ throw new Error(`Timed out waiting for nexus connect lock at ${lockDir}`);
13232
+ }
13233
+ async doConnectLocked(args) {
13137
13234
  const currentScriptHash = createHash4("sha256").update(DAEMON_SCRIPT).digest("hex").slice(0, 16);
13138
13235
  const existingPid = this.getDaemonPid();
13139
13236
  if (existingPid) {
13140
- let processAlive = false;
13237
+ let processAlive2 = false;
13141
13238
  try {
13142
13239
  process.kill(existingPid, 0);
13143
- processAlive = true;
13240
+ processAlive2 = true;
13144
13241
  } catch {
13145
13242
  }
13146
- if (processAlive) {
13243
+ if (processAlive2) {
13147
13244
  const statusFile2 = join21(this.nexusDir, "status.json");
13148
13245
  if (existsSync17(statusFile2)) {
13149
13246
  try {
@@ -13203,9 +13300,9 @@ process.on('SIGINT', () => process.emit('SIGTERM'));
13203
13300
  try {
13204
13301
  const { execSync: es } = __require("node:child_process");
13205
13302
  const psOut = es("ps aux 2>/dev/null", { encoding: "utf8", timeout: 5e3 }).trim();
13206
- const nexusDirEscaped = this.nexusDir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
13303
+ const nexusDirArg = new RegExp(`(?:^|\\s)${escapeRegExp(this.nexusDir)}(?:\\s|$)`);
13207
13304
  for (const line of psOut.split("\n")) {
13208
- if (line.includes("nexus-daemon") && line.includes(this.nexusDir)) {
13305
+ if (line.includes("nexus-daemon") && nexusDirArg.test(line)) {
13209
13306
  const pidMatch = line.match(/^\S+\s+(\d+)/);
13210
13307
  if (pidMatch) {
13211
13308
  const orphanPid = parseInt(pidMatch[1], 10);
@@ -13357,7 +13454,7 @@ ${failures.join("\n")}`;
13357
13454
  ${errTail}`)) {
13358
13455
  const repair = await tryRepairNodeDataChannel();
13359
13456
  if (/^Repaired /.test(repair)) {
13360
- return this.doConnect({ ...args, __native_repair_attempted: true });
13457
+ return this.doConnectLocked({ ...args, __native_repair_attempted: true });
13361
13458
  }
13362
13459
  return `Nexus daemon failed to connect: ${statusError}
13363
13460
  ${repair}${errTail ? "\n" + errTail : ""}`;
@@ -13394,7 +13491,7 @@ ${earlyOutput}`;
13394
13491
  if (!args.__native_repair_attempted && isNativeDataChannelError(earlyCombined)) {
13395
13492
  const repair = await tryRepairNodeDataChannel();
13396
13493
  if (/^Repaired /.test(repair)) {
13397
- return this.doConnect({ ...args, __native_repair_attempted: true });
13494
+ return this.doConnectLocked({ ...args, __native_repair_attempted: true });
13398
13495
  }
13399
13496
  return `Daemon failed to start.
13400
13497
  ${repair}
@@ -15104,7 +15201,7 @@ var init_image_resize = __esm({
15104
15201
 
15105
15202
  // packages/execution/dist/tools/image.js
15106
15203
  import { existsSync as existsSync18, readFileSync as readFileSync16, statSync as statSync7 } from "node:fs";
15107
- import { resolve as resolve14, extname as extname2, basename as basename2 } from "node:path";
15204
+ import { resolve as resolve14, extname as extname2, basename as basename3 } from "node:path";
15108
15205
  import { execSync as execSync11 } from "node:child_process";
15109
15206
  import { tmpdir as tmpdir3 } from "node:os";
15110
15207
  import { join as join23 } from "node:path";
@@ -15233,12 +15330,12 @@ var init_image = __esm({
15233
15330
  if (!existsSync18(fullPath)) {
15234
15331
  return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
15235
15332
  }
15236
- const stat5 = statSync7(fullPath);
15237
- if (stat5.size > maxSizeKb * 1024) {
15333
+ const stat6 = statSync7(fullPath);
15334
+ if (stat6.size > maxSizeKb * 1024) {
15238
15335
  return {
15239
15336
  success: false,
15240
15337
  output: "",
15241
- error: `File too large: ${(stat5.size / 1024).toFixed(0)}KB (max: ${maxSizeKb}KB)`,
15338
+ error: `File too large: ${(stat6.size / 1024).toFixed(0)}KB (max: ${maxSizeKb}KB)`,
15242
15339
  durationMs: Date.now() - start2
15243
15340
  };
15244
15341
  }
@@ -15248,9 +15345,9 @@ var init_image = __esm({
15248
15345
  const base642 = imageToBase64(fullPath);
15249
15346
  const mime = getMimeType(fullPath);
15250
15347
  const dims = getImageDimensions(fullPath);
15251
- const sizeKb = (stat5.size / 1024).toFixed(1);
15348
+ const sizeKb = (stat6.size / 1024).toFixed(1);
15252
15349
  const parts = [
15253
- `File: ${basename2(fullPath)}`,
15350
+ `File: ${basename3(fullPath)}`,
15254
15351
  `Size: ${sizeKb}KB`,
15255
15352
  `Format: ${mime}`
15256
15353
  ];
@@ -15340,12 +15437,12 @@ ${ocrText}`);
15340
15437
  if (!existsSync18(outputPath2)) {
15341
15438
  return { success: false, output: "", error: "Screenshot file not created", durationMs: Date.now() - start2 };
15342
15439
  }
15343
- const stat5 = statSync7(outputPath2);
15440
+ const stat6 = statSync7(outputPath2);
15344
15441
  const base642 = imageToBase64(outputPath2);
15345
15442
  const dims = getImageDimensions(outputPath2);
15346
15443
  const parts = [
15347
15444
  `Screenshot saved: ${outputPath2}`,
15348
- `Size: ${(stat5.size / 1024).toFixed(1)}KB`
15445
+ `Size: ${(stat6.size / 1024).toFixed(1)}KB`
15349
15446
  ];
15350
15447
  if (dims)
15351
15448
  parts.push(`Dimensions: ${dims.width}x${dims.height}`);
@@ -15491,7 +15588,7 @@ ${ocrText}`);
15491
15588
  const lineCount = text.split("\n").length;
15492
15589
  return {
15493
15590
  success: true,
15494
- output: `OCR extracted ${lineCount} lines from ${basename2(fullPath)}${region ? ` (region: ${region})` : ""}:
15591
+ output: `OCR extracted ${lineCount} lines from ${basename3(fullPath)}${region ? ` (region: ${region})` : ""}:
15495
15592
 
15496
15593
  ${text}`,
15497
15594
  durationMs: Date.now() - start2
@@ -16045,7 +16142,7 @@ var init_tool_creator = __esm({
16045
16142
 
16046
16143
  // packages/execution/dist/tools/skill-tools.js
16047
16144
  import { existsSync as existsSync20, readdirSync as readdirSync9, readFileSync as readFileSync18 } from "node:fs";
16048
- import { join as join25, basename as basename3, dirname as dirname3 } from "node:path";
16145
+ import { join as join25, basename as basename4, dirname as dirname4 } from "node:path";
16049
16146
  import { homedir as homedir7 } from "node:os";
16050
16147
  import { execSync as execSync12 } from "node:child_process";
16051
16148
  function getAiwgPaths() {
@@ -16256,7 +16353,7 @@ function loadCommandsFromDir(dir, source, out) {
16256
16353
  }
16257
16354
  }
16258
16355
  function loadSkillProvenance(skillPath) {
16259
- const provenance = readProvenanceFile(join25(dirname3(skillPath), "PROVENANCE.json"));
16356
+ const provenance = readProvenanceFile(join25(dirname4(skillPath), "PROVENANCE.json"));
16260
16357
  return provenance ? summarizeProvenance(provenance) : void 0;
16261
16358
  }
16262
16359
  function parseCommandDescription(filePath) {
@@ -16513,15 +16610,15 @@ ${content}`,
16513
16610
 
16514
16611
  // packages/execution/dist/tools/skill-builder.js
16515
16612
  import { existsSync as existsSync21, mkdirSync as mkdirSync8, readFileSync as readFileSync19, writeFileSync as writeFileSync10 } from "node:fs";
16516
- import { join as join26, dirname as dirname4 } from "node:path";
16613
+ import { join as join26, dirname as dirname5 } from "node:path";
16517
16614
  function loadBuilderPrompt(name10, vars) {
16518
16615
  const candidates = [
16519
16616
  // Dev layout: execution/dist/tools/ → orchestrator/prompts/
16520
- join26(dirname4(dirname4(dirname4(__dirname))), "orchestrator", "prompts", "skill-builder", name10),
16617
+ join26(dirname5(dirname5(dirname5(__dirname))), "orchestrator", "prompts", "skill-builder", name10),
16521
16618
  // Published layout: publish/dist/ → publish/prompts/
16522
- join26(dirname4(dirname4(__dirname)), "prompts", "skill-builder", name10),
16619
+ join26(dirname5(dirname5(__dirname)), "prompts", "skill-builder", name10),
16523
16620
  // Monorepo root fallback
16524
- join26(dirname4(dirname4(dirname4(dirname4(__dirname)))), "packages", "orchestrator", "prompts", "skill-builder", name10)
16621
+ join26(dirname5(dirname5(dirname5(dirname5(__dirname)))), "packages", "orchestrator", "prompts", "skill-builder", name10)
16525
16622
  ];
16526
16623
  let content;
16527
16624
  for (const p2 of candidates) {
@@ -16803,7 +16900,7 @@ ${content}`
16803
16900
 
16804
16901
  // packages/execution/dist/tools/transcribe-tool.js
16805
16902
  import { existsSync as existsSync22, mkdirSync as mkdirSync9, writeFileSync as writeFileSync11, readFileSync as readFileSync20, unlinkSync as unlinkSync2 } from "node:fs";
16806
- import { join as join27, basename as basename4, extname as extname3, resolve as resolve15 } from "node:path";
16903
+ import { join as join27, basename as basename5, extname as extname3, resolve as resolve15 } from "node:path";
16807
16904
  import { homedir as homedir8 } from "node:os";
16808
16905
  import { execSync as execSync13, spawn as spawn6 } from "node:child_process";
16809
16906
  function isTranscribable(path11) {
@@ -16959,7 +17056,7 @@ var init_transcribe_tool = __esm({
16959
17056
  });
16960
17057
  const transcriptDir = join27(this.workingDir, ".omnius", "transcripts");
16961
17058
  mkdirSync9(transcriptDir, { recursive: true });
16962
- const fileBase = basename4(filePath).replace(/\.[^.]+$/, "");
17059
+ const fileBase = basename5(filePath).replace(/\.[^.]+$/, "");
16963
17060
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
16964
17061
  const txtFile = join27(transcriptDir, `${fileBase}-${timestamp}.txt`);
16965
17062
  writeFileSync11(txtFile, result.text, "utf-8");
@@ -16991,7 +17088,7 @@ var init_transcribe_tool = __esm({
16991
17088
  } catch {
16992
17089
  }
16993
17090
  memEntries.push({
16994
- source: basename4(filePath),
17091
+ source: basename5(filePath),
16995
17092
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16996
17093
  duration: result.duration,
16997
17094
  wordCount: result.wordCount,
@@ -17006,7 +17103,7 @@ var init_transcribe_tool = __esm({
17006
17103
  } catch {
17007
17104
  }
17008
17105
  const lines = [
17009
- `Transcription of: ${basename4(filePath)}`,
17106
+ `Transcription of: ${basename5(filePath)}`,
17010
17107
  `Model: ${model} | Language: ${result.language} | Duration: ${result.duration ? `${result.duration.toFixed(1)}s` : "unknown"}`,
17011
17108
  `Words: ${result.wordCount} | Segments: ${result.segments.length}`,
17012
17109
  `Saved: ${txtFile} (text) + ${jsonFile} (structured with timestamps)`,
@@ -17122,7 +17219,7 @@ var init_transcribe_tool = __esm({
17122
17219
  if (!existsSync22(tmpFile)) {
17123
17220
  const { readdirSync: rd } = __require("node:fs");
17124
17221
  const files = rd(tmpDir).filter((f2) => f2.startsWith(`download-`) && f2 !== ".gitkeep");
17125
- const match = files.find((f2) => f2.includes(basename4(tmpBase)));
17222
+ const match = files.find((f2) => f2.includes(basename5(tmpBase)));
17126
17223
  if (match)
17127
17224
  tmpFile = join27(tmpDir, match);
17128
17225
  }
@@ -17278,7 +17375,7 @@ Format: mp3`,
17278
17375
 
17279
17376
  // packages/execution/dist/tools/structured-file.js
17280
17377
  import { writeFile as writeFile7, mkdir as mkdir4 } from "node:fs/promises";
17281
- import { resolve as resolve16, dirname as dirname5, extname as extname4 } from "node:path";
17378
+ import { resolve as resolve16, dirname as dirname6, extname as extname4 } from "node:path";
17282
17379
  function jsonToCSV(data, separator = ",") {
17283
17380
  if (!Array.isArray(data) || data.length === 0)
17284
17381
  return "";
@@ -17393,7 +17490,7 @@ var init_structured_file = __esm({
17393
17490
  }
17394
17491
  try {
17395
17492
  const fullPath = resolve16(this.workingDir, filePath);
17396
- await mkdir4(dirname5(fullPath), { recursive: true });
17493
+ await mkdir4(dirname6(fullPath), { recursive: true });
17397
17494
  let content;
17398
17495
  let byteInfo = "";
17399
17496
  switch (format3) {
@@ -17458,7 +17555,7 @@ var init_structured_file = __esm({
17458
17555
 
17459
17556
  // packages/execution/dist/tools/code-sandbox.js
17460
17557
  import { spawn as spawn7 } from "node:child_process";
17461
- import { writeFile as writeFile8, mkdtemp, rm, readdir as readdir3, stat } from "node:fs/promises";
17558
+ import { writeFile as writeFile8, mkdtemp, rm as rm2, readdir as readdir3, stat as stat2 } from "node:fs/promises";
17462
17559
  import { join as join28 } from "node:path";
17463
17560
  import { tmpdir as tmpdir4 } from "node:os";
17464
17561
  function runProcess(cmd, args, options2) {
@@ -17528,7 +17625,7 @@ async function listCreatedFiles(dir) {
17528
17625
  if (entry.startsWith("_sandbox_script"))
17529
17626
  continue;
17530
17627
  const fullPath = join28(dir, entry);
17531
- const s2 = await stat(fullPath);
17628
+ const s2 = await stat2(fullPath);
17532
17629
  if (s2.isFile()) {
17533
17630
  files.push(entry);
17534
17631
  }
@@ -17670,7 +17767,7 @@ ${result.filesCreated.join("\n")}`);
17670
17767
  result.filesCreated = await listCreatedFiles(sandboxDir);
17671
17768
  return result;
17672
17769
  } finally {
17673
- await rm(sandboxDir, { recursive: true, force: true }).catch(() => {
17770
+ await rm2(sandboxDir, { recursive: true, force: true }).catch(() => {
17674
17771
  });
17675
17772
  }
17676
17773
  }
@@ -17714,7 +17811,7 @@ ${result.filesCreated.join("\n")}`);
17714
17811
  result.filesCreated = await listCreatedFiles(sandboxDir);
17715
17812
  return result;
17716
17813
  } finally {
17717
- await rm(sandboxDir, { recursive: true, force: true }).catch(() => {
17814
+ await rm2(sandboxDir, { recursive: true, force: true }).catch(() => {
17718
17815
  });
17719
17816
  }
17720
17817
  }
@@ -85692,12 +85789,12 @@ var require_form_data = __commonJS({
85692
85789
  if (value2.end != void 0 && value2.end != Infinity && value2.start != void 0) {
85693
85790
  callback(null, value2.end + 1 - (value2.start ? value2.start : 0));
85694
85791
  } else {
85695
- fs10.stat(value2.path, function(err, stat5) {
85792
+ fs10.stat(value2.path, function(err, stat6) {
85696
85793
  if (err) {
85697
85794
  callback(err);
85698
85795
  return;
85699
85796
  }
85700
- var fileSize = stat5.size - (value2.start ? value2.start : 0);
85797
+ var fileSize = stat6.size - (value2.start ? value2.start : 0);
85701
85798
  callback(null, fileSize);
85702
85799
  });
85703
85800
  }
@@ -127346,7 +127443,7 @@ var require_snapshot_recorder = __commonJS({
127346
127443
  "../node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
127347
127444
  "use strict";
127348
127445
  var { writeFile: writeFile22, readFile: readFile23, mkdir: mkdir18 } = __require("node:fs/promises");
127349
- var { dirname: dirname40, resolve: resolve48 } = __require("node:path");
127446
+ var { dirname: dirname41, resolve: resolve48 } = __require("node:path");
127350
127447
  var { setTimeout: setTimeout3, clearTimeout: clearTimeout3 } = __require("node:timers");
127351
127448
  var { InvalidArgumentError, UndiciError } = require_errors2();
127352
127449
  var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
@@ -127577,7 +127674,7 @@ var require_snapshot_recorder = __commonJS({
127577
127674
  throw new InvalidArgumentError("Snapshot path is required");
127578
127675
  }
127579
127676
  const resolvedPath = resolve48(path11);
127580
- await mkdir18(dirname40(resolvedPath), { recursive: true });
127677
+ await mkdir18(dirname41(resolvedPath), { recursive: true });
127581
127678
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
127582
127679
  hash,
127583
127680
  snapshot
@@ -230833,7 +230930,7 @@ async function pWaitFor(condition, options2 = {}) {
230833
230930
  const timeoutSignal = timeoutMs === Number.POSITIVE_INFINITY ? void 0 : AbortSignal.timeout(timeoutMs);
230834
230931
  const combinedSignal = timeoutSignal && signal ? AbortSignal.any([timeoutSignal, signal]) : timeoutSignal ?? signal;
230835
230932
  if (!before) {
230836
- await sleep(interval, combinedSignal);
230933
+ await sleep2(interval, combinedSignal);
230837
230934
  }
230838
230935
  if (combinedSignal?.aborted) {
230839
230936
  return handleAbortError(timeoutSignal, timeout2, signal);
@@ -230848,7 +230945,7 @@ async function pWaitFor(condition, options2 = {}) {
230848
230945
  return;
230849
230946
  }
230850
230947
  if (value2 === false) {
230851
- await sleep(interval, combinedSignal);
230948
+ await sleep2(interval, combinedSignal);
230852
230949
  continue;
230853
230950
  }
230854
230951
  throw new TypeError("Expected condition to return a boolean");
@@ -230860,11 +230957,11 @@ async function pWaitFor(condition, options2 = {}) {
230860
230957
  }
230861
230958
  }
230862
230959
  }
230863
- var resolveValue, sleep, validateOptions, createTimeoutError, handleFallback, handleAbortError, TimeoutError3;
230960
+ var resolveValue, sleep2, validateOptions, createTimeoutError, handleFallback, handleAbortError, TimeoutError3;
230864
230961
  var init_p_wait_for = __esm({
230865
230962
  "../node_modules/p-wait-for/index.js"() {
230866
230963
  resolveValue = /* @__PURE__ */ Symbol("resolveValue");
230867
- sleep = (ms, signal) => new Promise((resolve48, reject) => {
230964
+ sleep2 = (ms, signal) => new Promise((resolve48, reject) => {
230868
230965
  if (signal?.aborted) {
230869
230966
  reject(signal.reason);
230870
230967
  return;
@@ -241239,15 +241336,15 @@ var init_ls = __esm({
241239
241336
  });
241240
241337
 
241241
241338
  // ../node_modules/@helia/unixfs/dist/src/commands/mkdir.js
241242
- async function mkdir5(parentCid, dirname40, blockstore, options2 = {}) {
241243
- if (dirname40.includes("/")) {
241339
+ async function mkdir5(parentCid, dirname41, blockstore, options2 = {}) {
241340
+ if (dirname41.includes("/")) {
241244
241341
  throw new InvalidParametersError4("Path must not have slashes");
241245
241342
  }
241246
241343
  const entry = await exporter2(parentCid, blockstore, options2);
241247
241344
  if (entry.type !== "directory") {
241248
241345
  throw new NotADirectoryError(`${parentCid.toString()} was not a UnixFS directory`);
241249
241346
  }
241250
- log16("creating %s", dirname40);
241347
+ log16("creating %s", dirname41);
241251
241348
  const metadata = new UnixFS({
241252
241349
  type: "directory",
241253
241350
  mode: options2.mode,
@@ -241263,9 +241360,9 @@ async function mkdir5(parentCid, dirname40, blockstore, options2 = {}) {
241263
241360
  await blockstore.put(emptyDirCid, buf);
241264
241361
  const [directory, pblink] = await Promise.all([
241265
241362
  cidToDirectory(parentCid, blockstore, options2),
241266
- cidToPBLink(emptyDirCid, dirname40, blockstore, options2)
241363
+ cidToPBLink(emptyDirCid, dirname41, blockstore, options2)
241267
241364
  ]);
241268
- log16("adding empty dir called %s to %c", dirname40, parentCid);
241365
+ log16("adding empty dir called %s to %c", dirname41, parentCid);
241269
241366
  const result = await addLink(directory, pblink, blockstore, {
241270
241367
  ...options2,
241271
241368
  allowOverwriting: options2.force
@@ -241418,7 +241515,7 @@ var init_remove_link = __esm({
241418
241515
  });
241419
241516
 
241420
241517
  // ../node_modules/@helia/unixfs/dist/src/commands/rm.js
241421
- async function rm2(target, name10, blockstore, options2 = {}) {
241518
+ async function rm3(target, name10, blockstore, options2 = {}) {
241422
241519
  if (name10.includes("/")) {
241423
241520
  throw new InvalidParametersError4("Name must not have slashes");
241424
241521
  }
@@ -241442,7 +241539,7 @@ var init_rm = __esm({
241442
241539
  });
241443
241540
 
241444
241541
  // ../node_modules/@helia/unixfs/dist/src/commands/stat.js
241445
- async function stat2(cid, blockstore, options2 = {}) {
241542
+ async function stat3(cid, blockstore, options2 = {}) {
241446
241543
  const resolved = await resolve17(cid, options2.path, blockstore, options2);
241447
241544
  log19("stat %c", resolved.cid);
241448
241545
  const result = await exporter2(resolved.cid, blockstore, options2);
@@ -241764,14 +241861,14 @@ var init_unixfs2 = __esm({
241764
241861
  async *ls(cid, options2 = {}) {
241765
241862
  yield* ls(cid, this.components.blockstore, options2);
241766
241863
  }
241767
- async mkdir(cid, dirname40, options2 = {}) {
241768
- return mkdir5(cid, dirname40, this.components.blockstore, options2);
241864
+ async mkdir(cid, dirname41, options2 = {}) {
241865
+ return mkdir5(cid, dirname41, this.components.blockstore, options2);
241769
241866
  }
241770
241867
  async rm(cid, path11, options2 = {}) {
241771
- return rm2(cid, path11, this.components.blockstore, options2);
241868
+ return rm3(cid, path11, this.components.blockstore, options2);
241772
241869
  }
241773
241870
  async stat(cid, options2 = {}) {
241774
- return stat2(cid, this.components.blockstore, options2);
241871
+ return stat3(cid, this.components.blockstore, options2);
241775
241872
  }
241776
241873
  async touch(cid, options2 = {}) {
241777
241874
  return touch(cid, this.components.blockstore, options2);
@@ -245162,8 +245259,8 @@ var require_pattern = __commonJS({
245162
245259
  }
245163
245260
  exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
245164
245261
  function isAffectDepthOfReadingPattern(pattern) {
245165
- const basename26 = path11.basename(pattern);
245166
- return endsWithSlashGlobStar(pattern) || isStaticPattern(basename26);
245262
+ const basename27 = path11.basename(pattern);
245263
+ return endsWithSlashGlobStar(pattern) || isStaticPattern(basename27);
245167
245264
  }
245168
245265
  exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
245169
245266
  function expandPatternsWithBraceExpansion(patterns) {
@@ -245520,7 +245617,7 @@ var require_async2 = __commonJS({
245520
245617
  callSuccessCallback(callback, lstat);
245521
245618
  return;
245522
245619
  }
245523
- settings.fs.stat(path11, (statError, stat5) => {
245620
+ settings.fs.stat(path11, (statError, stat6) => {
245524
245621
  if (statError !== null) {
245525
245622
  if (settings.throwErrorOnBrokenSymbolicLink) {
245526
245623
  callFailureCallback(callback, statError);
@@ -245530,9 +245627,9 @@ var require_async2 = __commonJS({
245530
245627
  return;
245531
245628
  }
245532
245629
  if (settings.markSymbolicLink) {
245533
- stat5.isSymbolicLink = () => true;
245630
+ stat6.isSymbolicLink = () => true;
245534
245631
  }
245535
- callSuccessCallback(callback, stat5);
245632
+ callSuccessCallback(callback, stat6);
245536
245633
  });
245537
245634
  });
245538
245635
  }
@@ -245558,11 +245655,11 @@ var require_sync = __commonJS({
245558
245655
  return lstat;
245559
245656
  }
245560
245657
  try {
245561
- const stat5 = settings.fs.statSync(path11);
245658
+ const stat6 = settings.fs.statSync(path11);
245562
245659
  if (settings.markSymbolicLink) {
245563
- stat5.isSymbolicLink = () => true;
245660
+ stat6.isSymbolicLink = () => true;
245564
245661
  }
245565
- return stat5;
245662
+ return stat6;
245566
245663
  } catch (error) {
245567
245664
  if (!settings.throwErrorOnBrokenSymbolicLink) {
245568
245665
  return lstat;
@@ -245629,14 +245726,14 @@ var require_out = __commonJS({
245629
245726
  var sync = require_sync();
245630
245727
  var settings_1 = require_settings();
245631
245728
  exports.Settings = settings_1.default;
245632
- function stat5(path11, optionsOrSettingsOrCallback, callback) {
245729
+ function stat6(path11, optionsOrSettingsOrCallback, callback) {
245633
245730
  if (typeof optionsOrSettingsOrCallback === "function") {
245634
245731
  async.read(path11, getSettings(), optionsOrSettingsOrCallback);
245635
245732
  return;
245636
245733
  }
245637
245734
  async.read(path11, getSettings(optionsOrSettingsOrCallback), callback);
245638
245735
  }
245639
- exports.stat = stat5;
245736
+ exports.stat = stat6;
245640
245737
  function statSync42(path11, optionsOrSettings) {
245641
245738
  const settings = getSettings(optionsOrSettings);
245642
245739
  return sync.read(path11, settings);
@@ -247617,18 +247714,18 @@ async function* globSource(cwd4, pattern, options2 = {}) {
247617
247714
  if (Path.basename(p2).startsWith(".") && options2.hidden !== true) {
247618
247715
  continue;
247619
247716
  }
247620
- const stat5 = await fsp.stat(p2);
247717
+ const stat6 = await fsp.stat(p2);
247621
247718
  let mode = options2.mode;
247622
247719
  if (options2.preserveMode === true) {
247623
- mode = stat5.mode;
247720
+ mode = stat6.mode;
247624
247721
  }
247625
247722
  let mtime = options2.mtime;
247626
247723
  if (options2.preserveMtime === true) {
247627
- mtime = stat5.mtime;
247724
+ mtime = stat6.mtime;
247628
247725
  }
247629
247726
  yield {
247630
247727
  path: p2.replace(cwd4, ""),
247631
- content: stat5.isFile() ? fs2.createReadStream(p2) : void 0,
247728
+ content: stat6.isFile() ? fs2.createReadStream(p2) : void 0,
247632
247729
  mode,
247633
247730
  mtime: toMtime(mtime)
247634
247731
  };
@@ -247698,11 +247795,11 @@ var init_src107 = __esm({
247698
247795
 
247699
247796
  // ../node_modules/steno/lib/index.js
247700
247797
  import { rename as rename2, writeFile as writeFile9 } from "node:fs/promises";
247701
- import { basename as basename5, dirname as dirname6, join as join29 } from "node:path";
247798
+ import { basename as basename6, dirname as dirname7, join as join29 } from "node:path";
247702
247799
  import { fileURLToPath as fileURLToPath2 } from "node:url";
247703
247800
  function getTempFilename(file) {
247704
247801
  const f2 = file instanceof URL ? fileURLToPath2(file) : file.toString();
247705
- return join29(dirname6(f2), `.${basename5(f2)}.tmp`);
247802
+ return join29(dirname7(f2), `.${basename6(f2)}.tmp`);
247706
247803
  }
247707
247804
  async function retryAsyncOperation(fn, maxRetries, delayMs) {
247708
247805
  for (let i2 = 0; i2 < maxRetries; i2++) {
@@ -252150,10 +252247,10 @@ function directorySizeBytes(path11) {
252150
252247
  if (!path11 || !existsSync24(path11))
252151
252248
  return 0;
252152
252249
  try {
252153
- const stat5 = statSync9(path11);
252154
- if (stat5.isFile())
252155
- return stat5.size;
252156
- if (!stat5.isDirectory())
252250
+ const stat6 = statSync9(path11);
252251
+ if (stat6.isFile())
252252
+ return stat6.size;
252253
+ if (!stat6.isDirectory())
252157
252254
  return 0;
252158
252255
  let total = 0;
252159
252256
  for (const entry of readdirSync10(path11, { withFileTypes: true })) {
@@ -253835,7 +253932,7 @@ if __name__ == "__main__":
253835
253932
  });
253836
253933
 
253837
253934
  // packages/execution/dist/tools/structured-read.js
253838
- import { readFile as readFile15, stat as stat3 } from "node:fs/promises";
253935
+ import { readFile as readFile15, stat as stat4 } from "node:fs/promises";
253839
253936
  import { resolve as resolve19, extname as extname5 } from "node:path";
253840
253937
  function parseCSV(text, separator = ",") {
253841
253938
  const lines = text.split("\n").filter((l2) => l2.trim() !== "");
@@ -253979,7 +254076,7 @@ var init_structured_read = __esm({
253979
254076
  }
253980
254077
  const fullPath = resolve19(this.workingDir, filePath);
253981
254078
  try {
253982
- const fileStat = await stat3(fullPath);
254079
+ const fileStat = await stat4(fullPath);
253983
254080
  if (!fileStat.isFile()) {
253984
254081
  return {
253985
254082
  success: false,
@@ -254177,7 +254274,7 @@ __export(vision_exports, {
254177
254274
  });
254178
254275
  import { readFileSync as readFileSync21, existsSync as existsSync25, statSync as statSync10 } from "node:fs";
254179
254276
  import { execSync as execSync14, spawn as spawn11 } from "node:child_process";
254180
- import { resolve as resolve20, extname as extname6, basename as basename6, dirname as dirname7, join as join38 } from "node:path";
254277
+ import { resolve as resolve20, extname as extname6, basename as basename7, dirname as dirname8, join as join38 } from "node:path";
254181
254278
  import { fileURLToPath as fileURLToPath3 } from "node:url";
254182
254279
  async function probeStation(endpoint) {
254183
254280
  try {
@@ -254206,7 +254303,7 @@ function findStationBinary() {
254206
254303
  const omniusVenvBin = isWin2 ? join38(venvBase, "Scripts", "moondream-station.exe") : join38(venvBase, "bin", "moondream-station");
254207
254304
  if (existsSync25(omniusVenvBin))
254208
254305
  return omniusVenvBin;
254209
- const thisDir = dirname7(fileURLToPath3(import.meta.url));
254306
+ const thisDir = dirname8(fileURLToPath3(import.meta.url));
254210
254307
  const pyBin = isWin2 ? "Scripts/python.exe" : "bin/python";
254211
254308
  const localVenvPaths = [
254212
254309
  resolve20(thisDir, `../../../../.moondream-venv/${pyBin}`),
@@ -254233,7 +254330,7 @@ async function autoLaunchStation(port = 2020) {
254233
254330
  const pythonBin = findStationBinary();
254234
254331
  if (!pythonBin)
254235
254332
  return false;
254236
- const thisDir = dirname7(fileURLToPath3(import.meta.url));
254333
+ const thisDir = dirname8(fileURLToPath3(import.meta.url));
254237
254334
  const launcherScript = resolve20(thisDir, "../../scripts/start-moondream.py");
254238
254335
  if (!existsSync25(launcherScript))
254239
254336
  return false;
@@ -254337,9 +254434,9 @@ function loadImageBuffer(workingDir, rawPath) {
254337
254434
  if (!existsSync25(fullPath)) {
254338
254435
  throw new Error(`File not found: ${rawPath}`);
254339
254436
  }
254340
- const stat5 = statSync10(fullPath);
254341
- if (stat5.size > 20 * 1024 * 1024) {
254342
- throw new Error(`Image too large: ${(stat5.size / 1024 / 1024).toFixed(1)}MB (max 20MB)`);
254437
+ const stat6 = statSync10(fullPath);
254438
+ if (stat6.size > 20 * 1024 * 1024) {
254439
+ throw new Error(`Image too large: ${(stat6.size / 1024 / 1024).toFixed(1)}MB (max 20MB)`);
254343
254440
  }
254344
254441
  const ext = extname6(fullPath).toLowerCase();
254345
254442
  if (!IMAGE_EXTENSIONS2.has(ext)) {
@@ -254432,7 +254529,7 @@ var init_vision = __esm({
254432
254529
  });
254433
254530
  } catch {
254434
254531
  }
254435
- const filename = basename6(fullPath);
254532
+ const filename = basename7(fullPath);
254436
254533
  let client = null;
254437
254534
  try {
254438
254535
  client = await getMoondreamClient();
@@ -254654,7 +254751,7 @@ ${response}`, durationMs: performance.now() - start2 };
254654
254751
  import { readFileSync as readFileSync22, existsSync as existsSync26 } from "node:fs";
254655
254752
  import { execSync as execSync15 } from "node:child_process";
254656
254753
  import { tmpdir as tmpdir6 } from "node:os";
254657
- import { join as join39, dirname as dirname8 } from "node:path";
254754
+ import { join as join39, dirname as dirname9 } from "node:path";
254658
254755
  import { fileURLToPath as fileURLToPath4 } from "node:url";
254659
254756
  function hasCommand2(cmd) {
254660
254757
  try {
@@ -254807,7 +254904,7 @@ var init_desktop_click = __esm({
254807
254904
  "packages/execution/dist/tools/desktop-click.js"() {
254808
254905
  "use strict";
254809
254906
  init_system_deps();
254810
- __dirname3 = dirname8(fileURLToPath4(import.meta.url));
254907
+ __dirname3 = dirname9(fileURLToPath4(import.meta.url));
254811
254908
  DesktopClickTool = class {
254812
254909
  workingDir;
254813
254910
  name = "desktop_click";
@@ -255209,7 +255306,7 @@ Screen: ${dims.width}x${dims.height}`);
255209
255306
 
255210
255307
  // packages/execution/dist/tools/ocr-pdf.js
255211
255308
  import { existsSync as existsSync27, statSync as statSync11 } from "node:fs";
255212
- import { resolve as resolve21, basename as basename7 } from "node:path";
255309
+ import { resolve as resolve21, basename as basename8 } from "node:path";
255213
255310
  import { execSync as execSync16 } from "node:child_process";
255214
255311
  var OcrPdfTool;
255215
255312
  var init_ocr_pdf = __esm({
@@ -255263,9 +255360,9 @@ var init_ocr_pdf = __esm({
255263
255360
  if (!existsSync27(inputPath)) {
255264
255361
  return { success: false, output: "", error: `File not found: ${rawInput}`, durationMs: performance.now() - start2 };
255265
255362
  }
255266
- const stat5 = statSync11(inputPath);
255267
- if (stat5.size > 500 * 1024 * 1024) {
255268
- return { success: false, output: "", error: `PDF too large: ${(stat5.size / 1024 / 1024).toFixed(0)}MB (max 500MB)`, durationMs: performance.now() - start2 };
255363
+ const stat6 = statSync11(inputPath);
255364
+ if (stat6.size > 500 * 1024 * 1024) {
255365
+ return { success: false, output: "", error: `PDF too large: ${(stat6.size / 1024 / 1024).toFixed(0)}MB (max 500MB)`, durationMs: performance.now() - start2 };
255269
255366
  }
255270
255367
  const deps = ["ocrmypdf", "tesseract", "gs"];
255271
255368
  const missing = [];
@@ -255308,7 +255405,7 @@ var init_ocr_pdf = __esm({
255308
255405
  const sizeMB = (outputStat.size / 1024 / 1024).toFixed(1);
255309
255406
  return {
255310
255407
  success: true,
255311
- output: `OCR completed for ${basename7(inputPath)}
255408
+ output: `OCR completed for ${basename8(inputPath)}
255312
255409
  Output: ${outputPath2 === inputPath ? "(in-place)" : outputPath2}
255313
255410
  Size: ${sizeMB}MB
255314
255411
  Language: ${language}
@@ -255332,7 +255429,7 @@ Language: ${language}
255332
255429
 
255333
255430
  // packages/execution/dist/tools/pdf-to-text.js
255334
255431
  import { existsSync as existsSync28, statSync as statSync12, readFileSync as readFileSync23, unlinkSync as unlinkSync4 } from "node:fs";
255335
- import { resolve as resolve22, basename as basename8, join as join40 } from "node:path";
255432
+ import { resolve as resolve22, basename as basename9, join as join40 } from "node:path";
255336
255433
  import { execSync as execSync17 } from "node:child_process";
255337
255434
  import { tmpdir as tmpdir7 } from "node:os";
255338
255435
  var PdfToTextTool;
@@ -255442,7 +255539,7 @@ var init_pdf_to_text = __esm({
255442
255539
  const pageInfo2 = pages ? ` (pages: ${pages})` : "";
255443
255540
  return {
255444
255541
  success: true,
255445
- output: `Extracted ${lineCount2} lines from ${basename8(fullPath)}${pageInfo2} (via OCR):
255542
+ output: `Extracted ${lineCount2} lines from ${basename9(fullPath)}${pageInfo2} (via OCR):
255446
255543
 
255447
255544
  ${text}`,
255448
255545
  durationMs: performance.now() - start2
@@ -255450,14 +255547,14 @@ ${text}`,
255450
255547
  }
255451
255548
  return {
255452
255549
  success: true,
255453
- output: `No text found in ${basename8(fullPath)} — appears to be a scanned/image PDF with no extractable text. OCR also returned no results.`,
255550
+ output: `No text found in ${basename9(fullPath)} — appears to be a scanned/image PDF with no extractable text. OCR also returned no results.`,
255454
255551
  durationMs: performance.now() - start2
255455
255552
  };
255456
255553
  }
255457
255554
  if (!text) {
255458
255555
  return {
255459
255556
  success: true,
255460
- output: `No text found in ${basename8(fullPath)} — may be a scanned/image PDF. Use ocr_pdf tool to add a text layer first.`,
255557
+ output: `No text found in ${basename9(fullPath)} — may be a scanned/image PDF. Use ocr_pdf tool to add a text layer first.`,
255461
255558
  durationMs: performance.now() - start2
255462
255559
  };
255463
255560
  }
@@ -255465,7 +255562,7 @@ ${text}`,
255465
255562
  const pageInfo = pages ? ` (pages: ${pages})` : "";
255466
255563
  return {
255467
255564
  success: true,
255468
- output: `Extracted ${lineCount} lines from ${basename8(fullPath)}${pageInfo}:
255565
+ output: `Extracted ${lineCount} lines from ${basename9(fullPath)}${pageInfo}:
255469
255566
 
255470
255567
  ${text}`,
255471
255568
  durationMs: performance.now() - start2
@@ -255517,12 +255614,12 @@ ${text}`,
255517
255614
 
255518
255615
  // packages/execution/dist/tools/ocr-image-advanced.js
255519
255616
  import { existsSync as existsSync29, statSync as statSync13 } from "node:fs";
255520
- import { resolve as resolve23, basename as basename9, dirname as dirname9, join as join41 } from "node:path";
255617
+ import { resolve as resolve23, basename as basename10, dirname as dirname10, join as join41 } from "node:path";
255521
255618
  import { execSync as execSync18 } from "node:child_process";
255522
255619
  import { fileURLToPath as fileURLToPath5 } from "node:url";
255523
255620
  import { homedir as homedir9, tmpdir as tmpdir8 } from "node:os";
255524
255621
  function findOcrScript() {
255525
- const thisDir = dirname9(fileURLToPath5(import.meta.url));
255622
+ const thisDir = dirname10(fileURLToPath5(import.meta.url));
255526
255623
  const devPath3 = resolve23(thisDir, "../../scripts/ocr-advanced.py");
255527
255624
  if (existsSync29(devPath3))
255528
255625
  return devPath3;
@@ -255625,12 +255722,12 @@ var init_ocr_image_advanced = __esm({
255625
255722
  return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: performance.now() - start2 };
255626
255723
  }
255627
255724
  if (!batch2) {
255628
- const stat5 = statSync13(fullPath);
255629
- if (stat5.isDirectory()) {
255725
+ const stat6 = statSync13(fullPath);
255726
+ if (stat6.isDirectory()) {
255630
255727
  return this.executeBatchOrSingle(fullPath, language, doRegions, region, psm, debug, outputDir, true, start2);
255631
255728
  }
255632
- if (stat5.size > 50 * 1024 * 1024) {
255633
- return { success: false, output: "", error: `Image too large: ${(stat5.size / 1024 / 1024).toFixed(0)}MB (max 50MB)`, durationMs: performance.now() - start2 };
255729
+ if (stat6.size > 50 * 1024 * 1024) {
255730
+ return { success: false, output: "", error: `Image too large: ${(stat6.size / 1024 / 1024).toFixed(0)}MB (max 50MB)`, durationMs: performance.now() - start2 };
255634
255731
  }
255635
255732
  }
255636
255733
  return this.executeBatchOrSingle(fullPath, language, doRegions, region, psm, debug, outputDir, batch2, start2);
@@ -255722,7 +255819,7 @@ var init_ocr_image_advanced = __esm({
255722
255819
  };
255723
255820
  }
255724
255821
  const parts = [];
255725
- parts.push(`OCR extracted from ${basename9(imagePath)} (${result.image_size})`);
255822
+ parts.push(`OCR extracted from ${basename10(imagePath)} (${result.image_size})`);
255726
255823
  parts.push(`Best variant: ${result.variant} (confidence: ${result.confidence}%, ${result.chars} chars, ${result.lines} lines, score: ${result.score})`);
255727
255824
  parts.push(`Variants tested: ${result.variants_tested}`);
255728
255825
  if (result.output_files) {
@@ -255793,14 +255890,14 @@ var init_ocr_image_advanced = __esm({
255793
255890
  if (!text) {
255794
255891
  return {
255795
255892
  success: true,
255796
- output: `(no text detected in ${basename9(imagePath)} — try the advanced Python OCR pipeline for better results)`,
255893
+ output: `(no text detected in ${basename10(imagePath)} — try the advanced Python OCR pipeline for better results)`,
255797
255894
  durationMs: performance.now() - start2
255798
255895
  };
255799
255896
  }
255800
255897
  const lineCount = text.split("\n").length;
255801
255898
  return {
255802
255899
  success: true,
255803
- output: `OCR extracted ${lineCount} lines from ${basename9(imagePath)} (basic tesseract, PSM ${psmArg}):
255900
+ output: `OCR extracted ${lineCount} lines from ${basename10(imagePath)} (basic tesseract, PSM ${psmArg}):
255804
255901
  Note: Advanced Python pipeline not available — install pytesseract, opencv-python-headless, Pillow, numpy for better results.
255805
255902
 
255806
255903
  ` + text,
@@ -255822,7 +255919,7 @@ Note: Advanced Python pipeline not available — install pytesseract, opencv-pyt
255822
255919
  // packages/execution/dist/tools/browser-action.js
255823
255920
  import { execSync as execSync19, spawn as spawn12 } from "node:child_process";
255824
255921
  import { existsSync as existsSync30, readFileSync as readFileSync24 } from "node:fs";
255825
- import { join as join42, dirname as dirname10 } from "node:path";
255922
+ import { join as join42, dirname as dirname11 } from "node:path";
255826
255923
  import { fileURLToPath as fileURLToPath6 } from "node:url";
255827
255924
  function findScrapeScript() {
255828
255925
  const candidates = [
@@ -256055,7 +256152,7 @@ var __dirname4, DEFAULT_PORT, SCRAPE_SCRIPT, BASE_URL, serviceProcess, activeSes
256055
256152
  var init_browser_action = __esm({
256056
256153
  "packages/execution/dist/tools/browser-action.js"() {
256057
256154
  "use strict";
256058
- __dirname4 = dirname10(fileURLToPath6(import.meta.url));
256155
+ __dirname4 = dirname11(fileURLToPath6(import.meta.url));
256059
256156
  DEFAULT_PORT = 8130;
256060
256157
  SCRAPE_SCRIPT = findScrapeScript();
256061
256158
  BASE_URL = `http://localhost:${DEFAULT_PORT}`;
@@ -256366,7 +256463,7 @@ var init_browser_action = __esm({
256366
256463
  // packages/execution/dist/tools/playwright-browser.js
256367
256464
  import { execSync as execSync20, exec } from "node:child_process";
256368
256465
  import { existsSync as existsSync31, writeFileSync as writeFileSync12, mkdirSync as mkdirSync10 } from "node:fs";
256369
- import { join as join43, dirname as dirname11 } from "node:path";
256466
+ import { join as join43, dirname as dirname12 } from "node:path";
256370
256467
  import { homedir as homedir10 } from "node:os";
256371
256468
  function pushBounded(buf, item) {
256372
256469
  buf.push(item);
@@ -256961,10 +257058,10 @@ ${JSON.stringify(data, null, 2)}`, start2);
256961
257058
  // packages/execution/dist/tools/autoresearch.js
256962
257059
  import { execSync as execSync21, spawn as spawn13 } from "node:child_process";
256963
257060
  import { existsSync as existsSync32, readFileSync as readFileSync25, writeFileSync as writeFileSync13, mkdirSync as mkdirSync11, appendFileSync, copyFileSync } from "node:fs";
256964
- import { join as join44, resolve as resolve24, dirname as dirname12 } from "node:path";
257061
+ import { join as join44, resolve as resolve24, dirname as dirname13 } from "node:path";
256965
257062
  import { fileURLToPath as fileURLToPath7 } from "node:url";
256966
257063
  function findAutoresearchScript(scriptName) {
256967
- const thisDir = dirname12(fileURLToPath7(import.meta.url));
257064
+ const thisDir = dirname13(fileURLToPath7(import.meta.url));
256968
257065
  const devPath3 = resolve24(thisDir, "../../scripts", scriptName);
256969
257066
  if (existsSync32(devPath3))
256970
257067
  return devPath3;
@@ -261608,10 +261705,10 @@ var init_todo_write = __esm({
261608
261705
 
261609
261706
  // packages/execution/dist/tools/repo-map.js
261610
261707
  import { readdirSync as readdirSync12, readFileSync as readFileSync27, statSync as statSync14, existsSync as existsSync36 } from "node:fs";
261611
- import { join as join52, relative as relative3, extname as extname7, dirname as dirname13, basename as basename10 } from "node:path";
261708
+ import { join as join52, relative as relative3, extname as extname7, dirname as dirname14, basename as basename11 } from "node:path";
261612
261709
  function parseJSImports(content, filePath) {
261613
261710
  const imports = [];
261614
- const dir = dirname13(filePath);
261711
+ const dir = dirname14(filePath);
261615
261712
  const esRegex = /(?:import|export)\s+(?:[\s\S]*?)\s+from\s+['"]([^'"]+)['"]/g;
261616
261713
  let m2;
261617
261714
  while ((m2 = esRegex.exec(content)) !== null) {
@@ -261714,15 +261811,15 @@ function buildGraph(rootDir, maxFiles = 2e3) {
261714
261811
  if (entry.startsWith("."))
261715
261812
  continue;
261716
261813
  const full = join52(dir, entry);
261717
- let stat5;
261814
+ let stat6;
261718
261815
  try {
261719
- stat5 = statSync14(full);
261816
+ stat6 = statSync14(full);
261720
261817
  } catch {
261721
261818
  continue;
261722
261819
  }
261723
- if (stat5.isDirectory()) {
261820
+ if (stat6.isDirectory()) {
261724
261821
  scan(full, depth + 1);
261725
- } else if (stat5.isFile() && SOURCE_EXTS.has(extname7(entry))) {
261822
+ } else if (stat6.isFile() && SOURCE_EXTS.has(extname7(entry))) {
261726
261823
  if (allPaths.length >= maxFiles)
261727
261824
  return;
261728
261825
  const relPath = relative3(rootDir, full).replace(/\\/g, "/");
@@ -261834,7 +261931,7 @@ function serializeMap(graph, tokenBudget, focusPath) {
261834
261931
  fileLines.push(symLine);
261835
261932
  }
261836
261933
  if (node.importedBy.length > 0 && node.score > 1e-3) {
261837
- const importedByStr = ` ← imported by: ${node.importedBy.slice(0, 5).map((p2) => basename10(p2, extname7(p2))).join(", ")}${node.importedBy.length > 5 ? ` +${node.importedBy.length - 5} more` : ""}`;
261934
+ const importedByStr = ` ← imported by: ${node.importedBy.slice(0, 5).map((p2) => basename11(p2, extname7(p2))).join(", ")}${node.importedBy.length > 5 ? ` +${node.importedBy.length - 5} more` : ""}`;
261838
261935
  fileTokens += importedByStr.length / charsPerToken;
261839
261936
  fileLines.push(importedByStr);
261840
261937
  }
@@ -262074,9 +262171,9 @@ var init_import_graph = __esm({
262074
262171
  // packages/indexer/dist/codebase-indexer.js
262075
262172
  import { createRequire as __createRequireGlob } from "node:module";
262076
262173
  import ignore from "ignore";
262077
- import { readFile as readFile21, stat as stat4 } from "node:fs/promises";
262174
+ import { readFile as readFile21, stat as stat5 } from "node:fs/promises";
262078
262175
  import { createHash as createHash6 } from "node:crypto";
262079
- import { join as join53, relative as relative5, extname as extname8, basename as basename11 } from "node:path";
262176
+ import { join as join53, relative as relative5, extname as extname8, basename as basename12 } from "node:path";
262080
262177
  var __requireGlob, glob2, DEFAULT_EXCLUDE, LANGUAGE_MAP, CodebaseIndexer;
262081
262178
  var init_codebase_indexer = __esm({
262082
262179
  "packages/indexer/dist/codebase-indexer.js"() {
@@ -262139,7 +262236,7 @@ var init_codebase_indexer = __esm({
262139
262236
  continue;
262140
262237
  const fullPath = join53(this.config.rootDir, relativePath);
262141
262238
  try {
262142
- const fileStat = await stat4(fullPath);
262239
+ const fileStat = await stat5(fullPath);
262143
262240
  if (fileStat.size > this.config.maxFileSize)
262144
262241
  continue;
262145
262242
  const content = await readFile21(fullPath);
@@ -262160,7 +262257,7 @@ var init_codebase_indexer = __esm({
262160
262257
  }
262161
262258
  buildTree(files) {
262162
262259
  const root = {
262163
- name: basename11(this.config.rootDir),
262260
+ name: basename12(this.config.rootDir),
262164
262261
  path: this.config.rootDir,
262165
262262
  type: "directory",
262166
262263
  children: []
@@ -273170,9 +273267,9 @@ ${lanes.join("\n")}
273170
273267
  return process.memoryUsage().heapUsed;
273171
273268
  },
273172
273269
  getFileSize(path11) {
273173
- const stat5 = statSync42(path11);
273174
- if (stat5 == null ? void 0 : stat5.isFile()) {
273175
- return stat5.size;
273270
+ const stat6 = statSync42(path11);
273271
+ if (stat6 == null ? void 0 : stat6.isFile()) {
273272
+ return stat6.size;
273176
273273
  }
273177
273274
  return 0;
273178
273275
  },
@@ -273390,19 +273487,19 @@ ${lanes.join("\n")}
273390
273487
  if (entry === "." || entry === "..") {
273391
273488
  continue;
273392
273489
  }
273393
- let stat5;
273490
+ let stat6;
273394
273491
  if (typeof dirent === "string" || dirent.isSymbolicLink()) {
273395
273492
  const name10 = combinePaths(path11, entry);
273396
- stat5 = statSync42(name10);
273397
- if (!stat5) {
273493
+ stat6 = statSync42(name10);
273494
+ if (!stat6) {
273398
273495
  continue;
273399
273496
  }
273400
273497
  } else {
273401
- stat5 = dirent;
273498
+ stat6 = dirent;
273402
273499
  }
273403
- if (stat5.isFile()) {
273500
+ if (stat6.isFile()) {
273404
273501
  files.push(entry);
273405
- } else if (stat5.isDirectory()) {
273502
+ } else if (stat6.isDirectory()) {
273406
273503
  directories.push(entry);
273407
273504
  }
273408
273505
  }
@@ -273417,15 +273514,15 @@ ${lanes.join("\n")}
273417
273514
  return matchFiles(path11, extensions, excludes, includes, useCaseSensitiveFileNames2, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
273418
273515
  }
273419
273516
  function fileSystemEntryExists(path11, entryKind) {
273420
- const stat5 = statSync42(path11);
273421
- if (!stat5) {
273517
+ const stat6 = statSync42(path11);
273518
+ if (!stat6) {
273422
273519
  return false;
273423
273520
  }
273424
273521
  switch (entryKind) {
273425
273522
  case 0:
273426
- return stat5.isFile();
273523
+ return stat6.isFile();
273427
273524
  case 1:
273428
- return stat5.isDirectory();
273525
+ return stat6.isDirectory();
273429
273526
  default:
273430
273527
  return false;
273431
273528
  }
@@ -401647,9 +401744,9 @@ ${lanes.join("\n")}
401647
401744
  /*ignoreCase*/
401648
401745
  false
401649
401746
  )) {
401650
- const basename26 = getBaseFileName(a2.fileName);
401651
- if (basename26 === "lib.d.ts" || basename26 === "lib.es6.d.ts") return 0;
401652
- const name10 = removeSuffix(removePrefix(basename26, "lib."), ".d.ts");
401747
+ const basename27 = getBaseFileName(a2.fileName);
401748
+ if (basename27 === "lib.d.ts" || basename27 === "lib.es6.d.ts") return 0;
401749
+ const name10 = removeSuffix(removePrefix(basename27, "lib."), ".d.ts");
401653
401750
  const index = libs.indexOf(name10);
401654
401751
  if (index !== -1) return index + 1;
401655
401752
  }
@@ -429154,7 +429251,7 @@ ${newComment.split("\n").map((c9) => ` * ${c9}`).join("\n")}
429154
429251
  }
429155
429252
  }
429156
429253
  return result;
429157
- function escapeRegExp(str) {
429254
+ function escapeRegExp2(str) {
429158
429255
  return str.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
429159
429256
  }
429160
429257
  function getTodoCommentsRegExp() {
@@ -429162,7 +429259,7 @@ ${newComment.split("\n").map((c9) => ` * ${c9}`).join("\n")}
429162
429259
  const multiLineCommentStart = /(?:\/\*+\s*)/.source;
429163
429260
  const anyNumberOfSpacesAndAsterisksAtStartOfLine = /(?:^(?:\s|\*)*)/.source;
429164
429261
  const preamble = "(" + anyNumberOfSpacesAndAsterisksAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")";
429165
- const literals = "(?:" + map2(descriptors, (d2) => "(" + escapeRegExp(d2.text) + ")").join("|") + ")";
429262
+ const literals = "(?:" + map2(descriptors, (d2) => "(" + escapeRegExp2(d2.text) + ")").join("|") + ")";
429166
429263
  const endOfLineOrEndOfComment = /(?:$|\*\/)/.source;
429167
429264
  const messageRemainder = /(?:.*?)/.source;
429168
429265
  const messagePortion = "(" + literals + messageRemainder + ")";
@@ -465575,8 +465672,8 @@ ${options2.prefix}` : "\n" : options2.prefix
465575
465672
  }
465576
465673
  };
465577
465674
  for (const file of files) {
465578
- const basename26 = getBaseFileName(file);
465579
- if (basename26 === "package.json" || basename26 === "bower.json") {
465675
+ const basename27 = getBaseFileName(file);
465676
+ if (basename27 === "package.json" || basename27 === "bower.json") {
465580
465677
  createProjectWatcher(
465581
465678
  file,
465582
465679
  "FileWatcher"
@@ -469260,8 +469357,8 @@ All files are: ${JSON.stringify(names)}`,
469260
469357
  var _a;
469261
469358
  const fileOrDirectoryPath = removeIgnoredPath(this.toPath(fileOrDirectory));
469262
469359
  if (!fileOrDirectoryPath) return;
469263
- const basename26 = getBaseFileName(fileOrDirectoryPath);
469264
- if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename26 === "package.json" || basename26 === "node_modules")) {
469360
+ const basename27 = getBaseFileName(fileOrDirectoryPath);
469361
+ if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename27 === "package.json" || basename27 === "node_modules")) {
469265
469362
  result.affectedModuleSpecifierCacheProjects.forEach((project) => {
469266
469363
  var _a2;
469267
469364
  (_a2 = project.getModuleSpecifierCache()) == null ? void 0 : _a2.clear();
@@ -478142,7 +478239,7 @@ var require_path_browserify = __commonJS({
478142
478239
  _makeLong: function _makeLong(path11) {
478143
478240
  return path11;
478144
478241
  },
478145
- dirname: function dirname40(path11) {
478242
+ dirname: function dirname41(path11) {
478146
478243
  assertPath(path11);
478147
478244
  if (path11.length === 0) return ".";
478148
478245
  var code8 = path11.charCodeAt(0);
@@ -478164,7 +478261,7 @@ var require_path_browserify = __commonJS({
478164
478261
  if (hasRoot && end === 1) return "//";
478165
478262
  return path11.slice(0, end);
478166
478263
  },
478167
- basename: function basename26(path11, ext) {
478264
+ basename: function basename27(path11, ext) {
478168
478265
  if (ext !== void 0 && typeof ext !== "string") throw new TypeError('"ext" argument must be a string');
478169
478266
  assertPath(path11);
478170
478267
  var start2 = 0;
@@ -480220,10 +480317,10 @@ var require_dist2 = __commonJS({
480220
480317
  queue.enqueue();
480221
480318
  fs$1.realpath(path$1, (error, resolvedPath) => {
480222
480319
  if (error) return queue.dequeue(suppressErrors ? null : error, state);
480223
- fs$1.stat(resolvedPath, (error$1, stat5) => {
480320
+ fs$1.stat(resolvedPath, (error$1, stat6) => {
480224
480321
  if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
480225
- if (stat5.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
480226
- callback$1(stat5, resolvedPath);
480322
+ if (stat6.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
480323
+ callback$1(stat6, resolvedPath);
480227
480324
  queue.dequeue(null, state);
480228
480325
  });
480229
480326
  });
@@ -480233,9 +480330,9 @@ var require_dist2 = __commonJS({
480233
480330
  queue.enqueue();
480234
480331
  try {
480235
480332
  const resolvedPath = fs$1.realpathSync(path$1);
480236
- const stat5 = fs$1.statSync(resolvedPath);
480237
- if (stat5.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
480238
- callback$1(stat5, resolvedPath);
480333
+ const stat6 = fs$1.statSync(resolvedPath);
480334
+ if (stat6.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
480335
+ callback$1(stat6, resolvedPath);
480239
480336
  } catch (e2) {
480240
480337
  if (!suppressErrors) throw e2;
480241
480338
  }
@@ -480432,8 +480529,8 @@ var require_dist2 = __commonJS({
480432
480529
  this.walkDirectory(this.state, path$1, path$1, depth - 1, this.walk);
480433
480530
  } else if (this.resolveSymlink && entry.isSymbolicLink()) {
480434
480531
  let path$1 = joinPathWithBasePath(entry.name, directoryPath);
480435
- this.resolveSymlink(path$1, this.state, (stat5, resolvedPath) => {
480436
- if (stat5.isDirectory()) {
480532
+ this.resolveSymlink(path$1, this.state, (stat6, resolvedPath) => {
480533
+ if (stat6.isDirectory()) {
480437
480534
  resolvedPath = normalizePath(resolvedPath, this.state.options);
480438
480535
  if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;
480439
480536
  this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth - 1, this.walk);
@@ -482282,14 +482379,14 @@ ${nodeLocation}` : message2;
482282
482379
  }
482283
482380
  stat(path12) {
482284
482381
  return new Promise((resolve48, reject) => {
482285
- fs__namespace.stat(path12, (err, stat5) => {
482382
+ fs__namespace.stat(path12, (err, stat6) => {
482286
482383
  if (err) {
482287
482384
  if (err.code === "ENOENT" || err.code === "ENOTDIR")
482288
482385
  resolve48(void 0);
482289
482386
  else
482290
482387
  reject(err);
482291
482388
  } else {
482292
- resolve48(stat5);
482389
+ resolve48(stat6);
482293
482390
  }
482294
482391
  });
482295
482392
  });
@@ -506457,7 +506554,7 @@ var init_ts_morph_parser = __esm({
506457
506554
  import { createRequire as createRequire2 } from "node:module";
506458
506555
  import { createHash as createHash7 } from "node:crypto";
506459
506556
  import { mkdirSync as mkdirSync13, readFileSync as readFileSync28 } from "node:fs";
506460
- import { join as join54, dirname as dirname14, extname as extname9 } from "node:path";
506557
+ import { join as join54, dirname as dirname15, extname as extname9 } from "node:path";
506461
506558
  function loadDatabaseCtor() {
506462
506559
  if (_DatabaseCtor)
506463
506560
  return _DatabaseCtor;
@@ -506507,7 +506604,7 @@ function extractFileSymbols(content, filePath) {
506507
506604
  }
506508
506605
  function extractFileImports(content, filePath) {
506509
506606
  const imports = [];
506510
- const dir = dirname14(filePath);
506607
+ const dir = dirname15(filePath);
506511
506608
  const esRe = /(?:import|export)\s+(?:[\s\S]*?)\s+from\s+['"]([^'"]+)['"]/g;
506512
506609
  let m2;
506513
506610
  while ((m2 = esRe.exec(content)) !== null) {
@@ -506577,7 +506674,7 @@ var init_code_graph_db = __esm({
506577
506674
  constructor(rootDir, dbPath) {
506578
506675
  this.rootDir = rootDir;
506579
506676
  const resolvedPath = dbPath ?? join54(rootDir, ".omnius", "index", "code-graph.db");
506580
- mkdirSync13(dirname14(resolvedPath), { recursive: true });
506677
+ mkdirSync13(dirname15(resolvedPath), { recursive: true });
506581
506678
  const Database = loadDatabaseCtor();
506582
506679
  this.db = new Database(resolvedPath);
506583
506680
  this.db.pragma("journal_mode = WAL");
@@ -506673,7 +506770,7 @@ var init_code_graph_db = __esm({
506673
506770
  for (const sym of astGraph.symbols) {
506674
506771
  this.stmts.insertSymbol.run(relPath, sym.name, sym.kind, sym.startLine, sym.endLine, sym.signature, sym.docstring, sym.exported ? 1 : 0);
506675
506772
  }
506676
- const dir = dirname14(relPath);
506773
+ const dir = dirname15(relPath);
506677
506774
  for (const edge of astGraph.edges) {
506678
506775
  if (edge.kind === "imports") {
506679
506776
  let target = edge.target;
@@ -508381,7 +508478,7 @@ Saved to: ${tempFile}`,
508381
508478
  // packages/execution/dist/tools/audio-playback.js
508382
508479
  import { execFileSync as execFileSync3, execSync as execSync29, spawn as spawn16 } from "node:child_process";
508383
508480
  import { copyFileSync as copyFileSync2, existsSync as existsSync40, statSync as statSync18, writeFileSync as writeFileSync16, mkdirSync as mkdirSync16, readdirSync as readdirSync14 } from "node:fs";
508384
- import { basename as basename12, extname as extname10, isAbsolute, join as join58 } from "node:path";
508481
+ import { basename as basename13, extname as extname10, isAbsolute, join as join58 } from "node:path";
508385
508482
  import { homedir as homedir14, tmpdir as tmpdir11 } from "node:os";
508386
508483
  function hasCommand3(command) {
508387
508484
  try {
@@ -508729,7 +508826,7 @@ function saveCloneRefFromSample(sample, cloneName) {
508729
508826
  if (!/\.(wav|mp3|flac|ogg|m4a)$/.test(ext)) {
508730
508827
  throw new Error("Clone sample must be an audio file: wav, mp3, flac, ogg, or m4a.");
508731
508828
  }
508732
- const safeName2 = (cloneName || basename12(source, ext)).replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80) || "clone";
508829
+ const safeName2 = (cloneName || basename13(source, ext)).replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80) || "clone";
508733
508830
  mkdirSync16(cloneRefsDir(), { recursive: true });
508734
508831
  const dest = join58(cloneRefsDir(), `${safeName2}${ext}`);
508735
508832
  copyFileSync2(source, dest);
@@ -509227,7 +509324,7 @@ ${tried.map((line) => `- ${line}`).join("\n")}`,
509227
509324
  if (daemonReady) {
509228
509325
  await luxttsSynthesize(text, cloneRef, outputPath2, speed);
509229
509326
  if (existsSync40(outputPath2))
509230
- return `${basename12(cloneRef)} (LuxTTS daemon)`;
509327
+ return `${basename13(cloneRef)} (LuxTTS daemon)`;
509231
509328
  }
509232
509329
  const venvPy = luxttsVenvPy();
509233
509330
  const repoDir = luxttsRepoDir();
@@ -509249,7 +509346,7 @@ ${tried.map((line) => `- ${line}`).join("\n")}`,
509249
509346
  timeout: 12e4,
509250
509347
  env: { ...process.env, LUXTTS_REPO_PATH: repoDir }
509251
509348
  });
509252
- return `${basename12(cloneRef)} (LuxTTS standalone)`;
509349
+ return `${basename13(cloneRef)} (LuxTTS standalone)`;
509253
509350
  }
509254
509351
  synthesizeSupertonic(text, outputPath2, args) {
509255
509352
  const venvPy = ensureSupertonicInstalled();
@@ -509297,7 +509394,7 @@ ${tried.map((line) => `- ${line}`).join("\n")}`,
509297
509394
  if (!existsSync40(modelPath))
509298
509395
  throw new Error(`Piper/ONNX model file not found: ${rawModel}`);
509299
509396
  argv.unshift("--model", modelPath);
509300
- summary = basename12(modelPath);
509397
+ summary = basename13(modelPath);
509301
509398
  } else {
509302
509399
  throw new Error(`${requireModel ? "Raw ONNX" : "Piper"} TTS requires model=<path.onnx> or voice=<path.onnx>.`);
509303
509400
  }
@@ -512977,13 +513074,13 @@ ${lines.join("\n")}`,
512977
513074
  // packages/execution/dist/tools/asr-listen.js
512978
513075
  import { execSync as execSync39, spawnSync as spawnSync5 } from "node:child_process";
512979
513076
  import { existsSync as existsSync47, mkdirSync as mkdirSync22, writeFileSync as writeFileSync21, readFileSync as readFileSync36, unlinkSync as unlinkSync9 } from "node:fs";
512980
- import { dirname as dirname15, join as join64, resolve as resolve31 } from "node:path";
513077
+ import { dirname as dirname16, join as join64, resolve as resolve31 } from "node:path";
512981
513078
  import { tmpdir as tmpdir17, homedir as homedir19 } from "node:os";
512982
513079
  import { fileURLToPath as fileURLToPath8 } from "node:url";
512983
513080
  function _findNemotronScript() {
512984
513081
  const candidates = [];
512985
513082
  try {
512986
- const here = dirname15(fileURLToPath8(import.meta.url));
513083
+ const here = dirname16(fileURLToPath8(import.meta.url));
512987
513084
  candidates.push(resolve31(here, "../../scripts/live-nemotron.py"));
512988
513085
  candidates.push(resolve31(here, "../../../scripts/live-nemotron.py"));
512989
513086
  } catch {
@@ -513530,10 +513627,10 @@ var init_full_sub_agent = __esm({
513530
513627
  this.onViewStatus = callbacks.onViewStatus;
513531
513628
  this.onComplete = callbacks.onComplete;
513532
513629
  }
513533
- constructor(workingDir, model, backendUrl, callbacks) {
513630
+ constructor(workingDir, model, backendUrl2, callbacks) {
513534
513631
  this.workingDir = workingDir;
513535
513632
  this.model = model ?? "";
513536
- this.backendUrl = backendUrl ?? "http://localhost:11434";
513633
+ this.backendUrl = backendUrl2 ?? "http://localhost:11434";
513537
513634
  this.onViewRegister = callbacks?.onViewRegister;
513538
513635
  this.onViewWrite = callbacks?.onViewWrite;
513539
513636
  this.onViewStatus = callbacks?.onViewStatus;
@@ -514796,7 +514893,7 @@ var init_client3 = __esm({
514796
514893
 
514797
514894
  // packages/execution/dist/mcp/manager.js
514798
514895
  import { existsSync as existsSync49, readFileSync as readFileSync37, writeFileSync as writeFileSync22, mkdirSync as mkdirSync24 } from "node:fs";
514799
- import { join as join66, dirname as dirname16 } from "node:path";
514896
+ import { join as join66, dirname as dirname17 } from "node:path";
514800
514897
  import { homedir as homedir20 } from "node:os";
514801
514898
  function loadMcpConfig(repoRoot) {
514802
514899
  const servers = {};
@@ -514859,7 +514956,7 @@ function saveMcpServerToConfig(repoRoot, serverName, config, scope = "project")
514859
514956
  }
514860
514957
  }
514861
514958
  existing.mcpServers[serverName] = config;
514862
- mkdirSync24(dirname16(path11), { recursive: true });
514959
+ mkdirSync24(dirname17(path11), { recursive: true });
514863
514960
  writeFileSync22(path11, JSON.stringify(existing, null, 2) + "\n");
514864
514961
  return path11;
514865
514962
  }
@@ -515870,7 +515967,7 @@ var init_environment_snapshot = __esm({
515870
515967
  // packages/execution/dist/tools/video-understand.js
515871
515968
  import { execSync as execSync42 } from "node:child_process";
515872
515969
  import { existsSync as existsSync52, mkdirSync as mkdirSync25, writeFileSync as writeFileSync24, readFileSync as readFileSync40, readdirSync as readdirSync17, unlinkSync as unlinkSync10 } from "node:fs";
515873
- import { join as join68, basename as basename13 } from "node:path";
515970
+ import { join as join68, basename as basename14 } from "node:path";
515874
515971
  import { createHash as createHash8 } from "node:crypto";
515875
515972
  function isYouTubeUrl2(url) {
515876
515973
  return /(?:youtube\.com\/(?:watch|shorts|live|embed|v\/)|youtu\.be\/)/i.test(url);
@@ -516037,7 +516134,7 @@ var init_video_understand = __esm({
516037
516134
  const permanentDir = join68(outDir, `frames-${Date.now()}`);
516038
516135
  mkdirSync25(permanentDir, { recursive: true });
516039
516136
  for (const frame of frames.filter((f2) => !f2.isDuplicate)) {
516040
- const dest = join68(permanentDir, basename13(frame.path));
516137
+ const dest = join68(permanentDir, basename14(frame.path));
516041
516138
  try {
516042
516139
  writeFileSync24(dest, readFileSync40(frame.path));
516043
516140
  frame.path = dest;
@@ -516107,7 +516204,7 @@ var init_video_understand = __esm({
516107
516204
  transcriptEntries = JSON.parse(readFileSync40(transcriptFile, "utf-8"));
516108
516205
  } catch {
516109
516206
  }
516110
- const videoLabel = title || basename13(url || localPath || "unknown");
516207
+ const videoLabel = title || basename14(url || localPath || "unknown");
516111
516208
  const chunks = /* @__PURE__ */ new Map();
516112
516209
  for (const seg of segments) {
516113
516210
  const chunkIdx = Math.floor(seg.start / CHUNK_WINDOW);
@@ -516147,7 +516244,7 @@ Topic: ${segments.slice(0, 5).map((s2) => s2.text).join(" ").slice(0, 300)}`,
516147
516244
  lines.push("");
516148
516245
  lines.push(`## Frames (${uniqueFrames.length} unique, ${frames.length - uniqueFrames.length} duplicates removed)`);
516149
516246
  for (const frame of uniqueFrames) {
516150
- lines.push(` [${formatTime2(frame.timestamp)}] ${basename13(frame.path)}${frame.description ? ` — ${frame.description}` : ""}`);
516247
+ lines.push(` [${formatTime2(frame.timestamp)}] ${basename14(frame.path)}${frame.description ? ` — ${frame.description}` : ""}`);
516151
516248
  }
516152
516249
  }
516153
516250
  try {
@@ -516429,7 +516526,7 @@ var init_gitWorktree = __esm({
516429
516526
 
516430
516527
  // packages/execution/dist/patchApplier.js
516431
516528
  import { readFileSync as readFileSync42, writeFileSync as writeFileSync25, existsSync as existsSync54, mkdirSync as mkdirSync26 } from "node:fs";
516432
- import { dirname as dirname17 } from "node:path";
516529
+ import { dirname as dirname18 } from "node:path";
516433
516530
  import { spawn as spawn20 } from "node:child_process";
516434
516531
  async function applyPatch(patch) {
516435
516532
  switch (patch.type) {
@@ -516458,7 +516555,7 @@ function applyNewFile(patch) {
516458
516555
  if (existsSync54(patch.filePath)) {
516459
516556
  throw new Error(`Cannot create new file: "${patch.filePath}" already exists.`);
516460
516557
  }
516461
- mkdirSync26(dirname17(patch.filePath), { recursive: true });
516558
+ mkdirSync26(dirname18(patch.filePath), { recursive: true });
516462
516559
  writeFileSync25(patch.filePath, patch.newContent, "utf-8");
516463
516560
  }
516464
516561
  async function applyUnifiedDiff(patch) {
@@ -516470,7 +516567,7 @@ async function applyUnifiedDiff(patch) {
516470
516567
  "-p1",
516471
516568
  filePath
516472
516569
  ],
516473
- cwd: dirname17(filePath),
516570
+ cwd: dirname18(filePath),
516474
516571
  stdin: diff
516475
516572
  });
516476
516573
  if (!result.success) {
@@ -518197,7 +518294,7 @@ var init_dist6 = __esm({
518197
518294
 
518198
518295
  // packages/orchestrator/dist/promptLoader.js
518199
518296
  import { readFileSync as readFileSync44, existsSync as existsSync56 } from "node:fs";
518200
- import { join as join71, dirname as dirname18 } from "node:path";
518297
+ import { join as join71, dirname as dirname19 } from "node:path";
518201
518298
  import { fileURLToPath as fileURLToPath9 } from "node:url";
518202
518299
  function loadPrompt(promptPath, vars) {
518203
518300
  let content = cache5.get(promptPath);
@@ -518218,7 +518315,7 @@ var init_promptLoader = __esm({
518218
518315
  "packages/orchestrator/dist/promptLoader.js"() {
518219
518316
  "use strict";
518220
518317
  __filename3 = fileURLToPath9(import.meta.url);
518221
- __dirname5 = dirname18(__filename3);
518318
+ __dirname5 = dirname19(__filename3);
518222
518319
  PROMPTS_DIR = join71(__dirname5, "..", "prompts");
518223
518320
  cache5 = /* @__PURE__ */ new Map();
518224
518321
  }
@@ -519948,7 +520045,7 @@ var init_artifact_inspector = __esm({
519948
520045
 
519949
520046
  // packages/orchestrator/dist/lesson-bank.js
519950
520047
  import { existsSync as existsSync58, mkdirSync as mkdirSync28, appendFileSync as appendFileSync2, readFileSync as readFileSync45 } from "node:fs";
519951
- import { join as join72, dirname as dirname19 } from "node:path";
520048
+ import { join as join72, dirname as dirname20 } from "node:path";
519952
520049
  import { createHash as createHash9 } from "node:crypto";
519953
520050
  function tokenize2(text) {
519954
520051
  if (!text)
@@ -519985,7 +520082,7 @@ function lessonBankPath(workingDir) {
519985
520082
  }
519986
520083
  function bank(lesson, workingDir) {
519987
520084
  const path11 = lessonBankPath(workingDir);
519988
- mkdirSync28(dirname19(path11), { recursive: true });
520085
+ mkdirSync28(dirname20(path11), { recursive: true });
519989
520086
  appendFileSync2(path11, JSON.stringify(lesson) + "\n", "utf-8");
519990
520087
  }
519991
520088
  function readAll(workingDir) {
@@ -520051,7 +520148,7 @@ var init_lesson_bank = __esm({
520051
520148
 
520052
520149
  // packages/orchestrator/dist/intervention-replay.js
520053
520150
  import { existsSync as existsSync59, mkdirSync as mkdirSync29, readFileSync as readFileSync46, writeFileSync as writeFileSync27, readdirSync as readdirSync18 } from "node:fs";
520054
- import { join as join73, dirname as dirname20 } from "node:path";
520151
+ import { join as join73, dirname as dirname21 } from "node:path";
520055
520152
  function checkpointDir2(workingDir) {
520056
520153
  return workingDir ? join73(workingDir, ".omnius", "checkpoints") : join73(process.env["HOME"] || ".", ".omnius", "checkpoints");
520057
520154
  }
@@ -520068,7 +520165,7 @@ function writeCheckpoint(args) {
520068
520165
  notes: args.notes
520069
520166
  };
520070
520167
  const path11 = checkpointPath(args.workingDir, args.turn);
520071
- mkdirSync29(dirname20(path11), { recursive: true });
520168
+ mkdirSync29(dirname21(path11), { recursive: true });
520072
520169
  writeFileSync27(path11, JSON.stringify(snap), "utf-8");
520073
520170
  } catch {
520074
520171
  }
@@ -520110,7 +520207,7 @@ var init_intervention_replay = __esm({
520110
520207
 
520111
520208
  // packages/orchestrator/dist/world-state-disk-scan.js
520112
520209
  import { existsSync as existsSync60, readFileSync as readFileSync47, readdirSync as readdirSync19, statSync as statSync21 } from "node:fs";
520113
- import { join as join74, relative as relative7, basename as basename14 } from "node:path";
520210
+ import { join as join74, relative as relative7, basename as basename15 } from "node:path";
520114
520211
  function loadIgnoreFile(path11) {
520115
520212
  if (!existsSync60(path11))
520116
520213
  return [];
@@ -520190,7 +520287,7 @@ function scanWorkspace(opts) {
520190
520287
  }
520191
520288
  const abs = join74(dir, entry);
520192
520289
  const rel = relative7(root, abs);
520193
- const base3 = basename14(abs);
520290
+ const base3 = basename15(abs);
520194
520291
  if (shouldIgnore(rel, base3, patterns))
520195
520292
  continue;
520196
520293
  let st;
@@ -520466,7 +520563,7 @@ var init_world_state_plan_reconciler = __esm({
520466
520563
 
520467
520564
  // packages/orchestrator/dist/world-state-drift-detector.js
520468
520565
  import { existsSync as existsSync62, readFileSync as readFileSync48, statSync as statSync23 } from "node:fs";
520469
- import { dirname as dirname21, isAbsolute as isAbsolute4, join as join76, resolve as pathResolve } from "node:path";
520566
+ import { dirname as dirname22, isAbsolute as isAbsolute4, join as join76, resolve as pathResolve } from "node:path";
520470
520567
  function parseImports(source) {
520471
520568
  const out = [];
520472
520569
  const lines = source.split(/\r?\n/);
@@ -520664,7 +520761,7 @@ function resolveImportPath2(importingFile, source, workingDir, aliases) {
520664
520761
  }
520665
520762
  if (bestAlias)
520666
520763
  resolvedSpec = aliases[bestAlias] + source.slice(bestAlias.length);
520667
- const importerDir = dirname21(importingFile);
520764
+ const importerDir = dirname22(importingFile);
520668
520765
  const base3 = resolvedSpec.startsWith(".") ? pathResolve(importerDir, resolvedSpec) : resolvedSpec.startsWith("/") ? resolvedSpec : pathResolve(workingDir, resolvedSpec);
520669
520766
  const candidates = [];
520670
520767
  for (const ext of FILE_EXTENSIONS)
@@ -545458,14 +545555,14 @@ var init_nexusBackend = __esm({
545458
545555
  finish();
545459
545556
  }, 50);
545460
545557
  });
545461
- const stat5 = statSync27(streamFile, { throwIfNoEntry: false });
545462
- if (!stat5 || stat5.size <= position)
545558
+ const stat6 = statSync27(streamFile, { throwIfNoEntry: false });
545559
+ if (!stat6 || stat6.size <= position)
545463
545560
  continue;
545464
545561
  const fd = openSync(streamFile, "r");
545465
- const buf = Buffer.allocUnsafe(stat5.size - position);
545562
+ const buf = Buffer.allocUnsafe(stat6.size - position);
545466
545563
  readSync(fd, buf, 0, buf.length, position);
545467
545564
  closeSync(fd);
545468
- position = stat5.size;
545565
+ position = stat6.size;
545469
545566
  for (const line of buf.toString("utf8").split("\n")) {
545470
545567
  if (!line.trim())
545471
545568
  continue;
@@ -549375,7 +549472,7 @@ __export(listen_exports, {
549375
549472
  });
549376
549473
  import { spawn as spawn21, execSync as execSync46 } from "node:child_process";
549377
549474
  import { existsSync as existsSync78, mkdirSync as mkdirSync43, writeFileSync as writeFileSync40, readdirSync as readdirSync24 } from "node:fs";
549378
- import { join as join94, dirname as dirname24 } from "node:path";
549475
+ import { join as join94, dirname as dirname25 } from "node:path";
549379
549476
  import { homedir as homedir26 } from "node:os";
549380
549477
  import { fileURLToPath as fileURLToPath10 } from "node:url";
549381
549478
  import { EventEmitter as EventEmitter4 } from "node:events";
@@ -549459,7 +549556,7 @@ function findMicCaptureCommand() {
549459
549556
  return null;
549460
549557
  }
549461
549558
  function findTranscribeFileScript() {
549462
- const thisDir = dirname24(fileURLToPath10(import.meta.url));
549559
+ const thisDir = dirname25(fileURLToPath10(import.meta.url));
549463
549560
  const candidates = [
549464
549561
  join94(thisDir, "../../../../packages/execution/scripts/transcribe-file.py"),
549465
549562
  join94(thisDir, "../../../packages/execution/scripts/transcribe-file.py"),
@@ -549544,7 +549641,7 @@ async function transcribeFileViaWhisper(filePath, model) {
549544
549641
  });
549545
549642
  }
549546
549643
  function findLiveWhisperScript() {
549547
- const thisDir = dirname24(fileURLToPath10(import.meta.url));
549644
+ const thisDir = dirname25(fileURLToPath10(import.meta.url));
549548
549645
  const candidates = [
549549
549646
  join94(thisDir, "../../../../packages/execution/scripts/live-whisper.py"),
549550
549647
  join94(thisDir, "../../../packages/execution/scripts/live-whisper.py"),
@@ -549913,7 +550010,7 @@ var init_listen = __esm({
549913
550010
  if (TranscribeLive) {
549914
550011
  let tcUpToDate = false;
549915
550012
  try {
549916
- const tcPkgPath = join94(dirname24(__require.resolve?.("transcribe-cli/package.json") || ""), "package.json");
550013
+ const tcPkgPath = join94(dirname25(__require.resolve?.("transcribe-cli/package.json") || ""), "package.json");
549917
550014
  if (existsSync78(tcPkgPath)) {
549918
550015
  const tcPkg = JSON.parse(__require("fs").readFileSync(tcPkgPath, "utf8"));
549919
550016
  tcUpToDate = tcPkg.version && tcPkg.version >= "2.0.1";
@@ -550255,10 +550352,10 @@ transcribe-cli error: ${transcribeCliError}` : "";
550255
550352
  wordTimestamps: false
550256
550353
  });
550257
550354
  if (outputDir) {
550258
- const { basename: basename26 } = await import("node:path");
550355
+ const { basename: basename27 } = await import("node:path");
550259
550356
  const transcriptDir = join94(outputDir, ".omnius", "transcripts");
550260
550357
  mkdirSync43(transcriptDir, { recursive: true });
550261
- const outFile = join94(transcriptDir, `${basename26(filePath)}.txt`);
550358
+ const outFile = join94(transcriptDir, `${basename27(filePath)}.txt`);
550262
550359
  writeFileSync40(outFile, result.text, "utf-8");
550263
550360
  }
550264
550361
  return {
@@ -550274,10 +550371,10 @@ transcribe-cli error: ${transcribeCliError}` : "";
550274
550371
  const fb = await transcribeFileViaWhisper(filePath, this.config.model);
550275
550372
  if (fb) {
550276
550373
  if (outputDir) {
550277
- const { basename: basename26 } = await import("node:path");
550374
+ const { basename: basename27 } = await import("node:path");
550278
550375
  const transcriptDir = join94(outputDir, ".omnius", "transcripts");
550279
550376
  mkdirSync43(transcriptDir, { recursive: true });
550280
- const outFile = join94(transcriptDir, `${basename26(filePath)}.txt`);
550377
+ const outFile = join94(transcriptDir, `${basename27(filePath)}.txt`);
550281
550378
  writeFileSync40(outFile, fb.text, "utf-8");
550282
550379
  }
550283
550380
  return fb;
@@ -558931,7 +559028,7 @@ var init_types = __esm({
558931
559028
  // packages/cli/src/tui/p2p/secret-vault.ts
558932
559029
  import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes19, scryptSync as scryptSync2, createHash as createHash16 } from "node:crypto";
558933
559030
  import { readFileSync as readFileSync64, writeFileSync as writeFileSync43, existsSync as existsSync81, mkdirSync as mkdirSync46 } from "node:fs";
558934
- import { dirname as dirname25 } from "node:path";
559031
+ import { dirname as dirname26 } from "node:path";
558935
559032
  var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
558936
559033
  var init_secret_vault = __esm({
558937
559034
  "packages/cli/src/tui/p2p/secret-vault.ts"() {
@@ -559138,7 +559235,7 @@ var init_secret_vault = __esm({
559138
559235
  const encrypted = Buffer.concat([cipher.update(data, "utf8"), cipher.final()]);
559139
559236
  const tag = cipher.getAuthTag();
559140
559237
  const blob = Buffer.concat([salt, iv, tag, encrypted]);
559141
- const dir = dirname25(this.storePath);
559238
+ const dir = dirname26(this.storePath);
559142
559239
  if (!existsSync81(dir)) mkdirSync46(dir, { recursive: true });
559143
559240
  writeFileSync43(this.storePath, blob, { mode: 384 });
559144
559241
  }
@@ -560736,7 +560833,7 @@ var init_render2 = __esm({
560736
560833
 
560737
560834
  // packages/prompts/dist/promptLoader.js
560738
560835
  import { readFileSync as readFileSync65, existsSync as existsSync82 } from "node:fs";
560739
- import { join as join98, dirname as dirname26 } from "node:path";
560836
+ import { join as join98, dirname as dirname27 } from "node:path";
560740
560837
  import { fileURLToPath as fileURLToPath11 } from "node:url";
560741
560838
  function loadPrompt2(promptPath, vars) {
560742
560839
  let content = cache6.get(promptPath);
@@ -560757,7 +560854,7 @@ var init_promptLoader2 = __esm({
560757
560854
  "packages/prompts/dist/promptLoader.js"() {
560758
560855
  "use strict";
560759
560856
  __filename4 = fileURLToPath11(import.meta.url);
560760
- __dirname6 = dirname26(__filename4);
560857
+ __dirname6 = dirname27(__filename4);
560761
560858
  devPath = join98(__dirname6, "..", "templates");
560762
560859
  publishedPath = join98(__dirname6, "..", "prompts", "templates");
560763
560860
  PROMPTS_DIR2 = existsSync82(devPath) ? devPath : publishedPath;
@@ -560871,7 +560968,7 @@ var init_task_templates = __esm({
560871
560968
  });
560872
560969
 
560873
560970
  // packages/prompts/dist/index.js
560874
- import { join as join99, dirname as dirname27 } from "node:path";
560971
+ import { join as join99, dirname as dirname28 } from "node:path";
560875
560972
  import { fileURLToPath as fileURLToPath12 } from "node:url";
560876
560973
  var _dir, _packageRoot;
560877
560974
  var init_dist9 = __esm({
@@ -560881,7 +560978,7 @@ var init_dist9 = __esm({
560881
560978
  init_render2();
560882
560979
  init_task_templates();
560883
560980
  init_render2();
560884
- _dir = dirname27(fileURLToPath12(import.meta.url));
560981
+ _dir = dirname28(fileURLToPath12(import.meta.url));
560885
560982
  _packageRoot = join99(_dir, "..");
560886
560983
  }
560887
560984
  });
@@ -560927,7 +561024,7 @@ __export(omnius_directory_exports, {
560927
561024
  writeTaskHandoff: () => writeTaskHandoff2
560928
561025
  });
560929
561026
  import { cpSync, existsSync as existsSync83, mkdirSync as mkdirSync47, readFileSync as readFileSync66, writeFileSync as writeFileSync44, readdirSync as readdirSync26, statSync as statSync29, unlinkSync as unlinkSync14, openSync as openSync2, closeSync as closeSync2, renameSync as renameSync3 } from "node:fs";
560930
- import { join as join100, relative as relative9, basename as basename15, dirname as dirname28 } from "node:path";
561027
+ import { join as join100, relative as relative9, basename as basename16, dirname as dirname29 } from "node:path";
560931
561028
  import { homedir as homedir27 } from "node:os";
560932
561029
  import { createHash as createHash18 } from "node:crypto";
560933
561030
  function findGitRoot(startDir) {
@@ -560964,7 +561061,7 @@ function ensureOmniusIgnored(repoRoot) {
560964
561061
  if (!gitRoot) return;
560965
561062
  const gitignorePath = findNearestExistingGitignore(repoRoot, gitRoot);
560966
561063
  if (!gitignorePath) return;
560967
- const gitignoreDir = dirname28(gitignorePath);
561064
+ const gitignoreDir = dirname29(gitignorePath);
560968
561065
  const relDir = relative9(gitignoreDir || ".", repoRoot).replace(/\\/g, "/");
560969
561066
  const ignorePattern = relDir && relDir !== "." ? `${relDir}/.omnius/` : ".omnius/";
560970
561067
  const content = readFileSync66(gitignorePath, "utf-8");
@@ -561123,7 +561220,7 @@ function writeIndexData(repoRoot, filename, data) {
561123
561220
  }
561124
561221
  function generateProjectMap(repoRoot) {
561125
561222
  const sections = [];
561126
- const repoName2 = basename15(repoRoot);
561223
+ const repoName2 = basename16(repoRoot);
561127
561224
  sections.push(`# Project Map: ${repoName2}
561128
561225
  `);
561129
561226
  sections.push(`> Auto-generated by omnius. Updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
@@ -561185,8 +561282,8 @@ function loadRecentSessions(repoRoot, limit = 5) {
561185
561282
  if (!existsSync83(historyDir)) return [];
561186
561283
  try {
561187
561284
  const files = readdirSync26(historyDir).filter((f2) => f2.endsWith(".json") && f2 !== "pending-task.json").map((f2) => {
561188
- const stat5 = statSync29(join100(historyDir, f2));
561189
- return { file: f2, mtime: stat5.mtimeMs };
561285
+ const stat6 = statSync29(join100(historyDir, f2));
561286
+ return { file: f2, mtime: stat6.mtimeMs };
561190
561287
  }).sort((a2, b) => b.mtime - a2.mtime).slice(0, limit);
561191
561288
  return files.map((f2) => {
561192
561289
  try {
@@ -564024,12 +564121,12 @@ var init_status_bar = __esm({
564024
564121
  }
564025
564122
  summarizeHeaderTransport() {
564026
564123
  const backendType = this._headerBackendType;
564027
- const backendUrl = this._headerBackendUrl;
564028
- if (backendType === "nexus" || backendUrl.startsWith("peer://"))
564124
+ const backendUrl2 = this._headerBackendUrl;
564125
+ if (backendType === "nexus" || backendUrl2.startsWith("peer://"))
564029
564126
  return "p2p";
564030
564127
  if (backendType === "fake") return "fake";
564031
- if (!backendUrl) return "";
564032
- if (backendUrl.includes("127.0.0.1") || backendUrl.includes("localhost") || backendUrl.includes("0.0.0.0")) {
564128
+ if (!backendUrl2) return "";
564129
+ if (backendUrl2.includes("127.0.0.1") || backendUrl2.includes("localhost") || backendUrl2.includes("0.0.0.0")) {
564033
564130
  return "local";
564034
564131
  }
564035
564132
  return "remote";
@@ -564071,15 +564168,15 @@ var init_status_bar = __esm({
564071
564168
  }
564072
564169
  return { text, width, separatorOffsets };
564073
564170
  }
564074
- setBackendInfo(backendType, backendUrl) {
564171
+ setBackendInfo(backendType, backendUrl2) {
564075
564172
  this._headerBackendType = backendType;
564076
- this._headerBackendUrl = backendUrl;
564173
+ this._headerBackendUrl = backendUrl2;
564077
564174
  this.refreshHeaderAndFooter();
564078
564175
  }
564079
- setHeaderIdentity(modelName, backendType, backendUrl) {
564176
+ setHeaderIdentity(modelName, backendType, backendUrl2) {
564080
564177
  this._modelName = modelName;
564081
564178
  this._headerBackendType = backendType;
564082
- this._headerBackendUrl = backendUrl;
564179
+ this._headerBackendUrl = backendUrl2;
564083
564180
  this.refreshHeaderAndFooter();
564084
564181
  }
564085
564182
  /** Set sponsor header data for unicode box injection */
@@ -566327,7 +566424,7 @@ ${CONTENT_BG_SEQ}`);
566327
566424
  }
566328
566425
  {
566329
566426
  const um = this._unifiedMetrics ?? getInstantSnapshot();
566330
- const rm3 = um.hardware;
566427
+ const rm4 = um.hardware;
566331
566428
  const isLocal = um.source === "local";
566332
566429
  const srcTag = isLocal ? pastel2(120, "L") : pastel2(117, "R");
566333
566430
  const srcW = 1;
@@ -566335,48 +566432,48 @@ ${CONTENT_BG_SEQ}`);
566335
566432
  let hwCompStr = "";
566336
566433
  let hwExpW = 0;
566337
566434
  let hwCompW = 0;
566338
- if (rm3.cpuUtil >= 0) {
566339
- const cpuColor = rm3.cpuUtil > 80 ? c3.red : rm3.cpuUtil > 50 ? c3.yellow : c3.green;
566340
- const cpuCoresInfo = rm3.cpuCores > 0 ? ` (${rm3.cpuCores}c` + (rm3.cpuModel ? " " + rm3.cpuModel.replace(/\s+/g, " ").slice(0, 30) : "") + ")" : "";
566341
- hwExpStr += `CPU ${cpuColor(rm3.cpuUtil + "%")}${c3.dim(cpuCoresInfo)}`;
566342
- hwCompStr += `CPU ${cpuColor(rm3.cpuUtil + "%")}`;
566343
- hwExpW += 4 + `${rm3.cpuUtil}%`.length + cpuCoresInfo.length;
566344
- hwCompW += 4 + `${rm3.cpuUtil}%`.length;
566345
- }
566346
- if (rm3.memUtil >= 0) {
566347
- const memColor = rm3.memUtil > 80 ? c3.red : rm3.memUtil > 50 ? c3.yellow : c3.green;
566348
- const memDetail = rm3.memTotalGB > 0 ? ` (${rm3.memUsedGB}/${rm3.memTotalGB}GB)` : "";
566349
- hwExpStr += ` RAM ${memColor(rm3.memUtil + "%")}${c3.dim(memDetail)}`;
566350
- hwCompStr += ` RAM ${memColor(rm3.memUtil + "%")}`;
566351
- hwExpW += 5 + `${rm3.memUtil}%`.length + memDetail.length;
566352
- hwCompW += 5 + `${rm3.memUtil}%`.length;
566353
- }
566354
- if (rm3.diskUtil >= 0) {
566355
- const diskColor = rm3.diskUtil > 90 ? c3.red : rm3.diskUtil > 75 ? c3.yellow : c3.green;
566356
- const diskDetail = rm3.diskTotalGB > 0 ? ` (${rm3.diskFreeGB.toFixed(rm3.diskFreeGB < 10 ? 1 : 0)}GB free)` : "";
566357
- hwExpStr += ` Disk ${diskColor(rm3.diskUtil + "%")}${c3.dim(diskDetail)}`;
566358
- hwCompStr += ` Disk ${diskColor(rm3.diskUtil + "%")}`;
566359
- hwExpW += 6 + `${rm3.diskUtil}%`.length + diskDetail.length;
566360
- hwCompW += 6 + `${rm3.diskUtil}%`.length;
566361
- }
566362
- if (rm3.gpuUtil >= 0) {
566363
- const gpuColor = rm3.gpuUtil > 80 ? c3.red : rm3.gpuUtil > 50 ? c3.yellow : c3.green;
566364
- const gpuNameShort = rm3.gpuName ? ` (${rm3.gpuName.slice(0, 20)})` : "";
566365
- hwExpStr += ` GPU ${gpuColor(rm3.gpuUtil + "%")}${c3.dim(gpuNameShort)}`;
566366
- hwCompStr += ` GPU ${gpuColor(rm3.gpuUtil + "%")}`;
566367
- hwExpW += 5 + `${rm3.gpuUtil}%`.length + gpuNameShort.length;
566368
- hwCompW += 5 + `${rm3.gpuUtil}%`.length;
566369
- }
566370
- if (rm3.vramUtil >= 0) {
566371
- const vramColor = rm3.vramUtil > 80 ? c3.red : rm3.vramUtil > 50 ? c3.yellow : c3.green;
566372
- const vramDetail = rm3.vramTotalMB > 0 ? ` (${rm3.vramUsedMB}/${rm3.vramTotalMB}MB)` : "";
566373
- hwExpStr += ` VRAM ${vramColor(rm3.vramUtil + "%")}${c3.dim(vramDetail)}`;
566374
- hwCompStr += ` VRAM ${vramColor(rm3.vramUtil + "%")}`;
566375
- hwExpW += 6 + `${rm3.vramUtil}%`.length + vramDetail.length;
566376
- hwCompW += 6 + `${rm3.vramUtil}%`.length;
566435
+ if (rm4.cpuUtil >= 0) {
566436
+ const cpuColor = rm4.cpuUtil > 80 ? c3.red : rm4.cpuUtil > 50 ? c3.yellow : c3.green;
566437
+ const cpuCoresInfo = rm4.cpuCores > 0 ? ` (${rm4.cpuCores}c` + (rm4.cpuModel ? " " + rm4.cpuModel.replace(/\s+/g, " ").slice(0, 30) : "") + ")" : "";
566438
+ hwExpStr += `CPU ${cpuColor(rm4.cpuUtil + "%")}${c3.dim(cpuCoresInfo)}`;
566439
+ hwCompStr += `CPU ${cpuColor(rm4.cpuUtil + "%")}`;
566440
+ hwExpW += 4 + `${rm4.cpuUtil}%`.length + cpuCoresInfo.length;
566441
+ hwCompW += 4 + `${rm4.cpuUtil}%`.length;
566442
+ }
566443
+ if (rm4.memUtil >= 0) {
566444
+ const memColor = rm4.memUtil > 80 ? c3.red : rm4.memUtil > 50 ? c3.yellow : c3.green;
566445
+ const memDetail = rm4.memTotalGB > 0 ? ` (${rm4.memUsedGB}/${rm4.memTotalGB}GB)` : "";
566446
+ hwExpStr += ` RAM ${memColor(rm4.memUtil + "%")}${c3.dim(memDetail)}`;
566447
+ hwCompStr += ` RAM ${memColor(rm4.memUtil + "%")}`;
566448
+ hwExpW += 5 + `${rm4.memUtil}%`.length + memDetail.length;
566449
+ hwCompW += 5 + `${rm4.memUtil}%`.length;
566450
+ }
566451
+ if (rm4.diskUtil >= 0) {
566452
+ const diskColor = rm4.diskUtil > 90 ? c3.red : rm4.diskUtil > 75 ? c3.yellow : c3.green;
566453
+ const diskDetail = rm4.diskTotalGB > 0 ? ` (${rm4.diskFreeGB.toFixed(rm4.diskFreeGB < 10 ? 1 : 0)}GB free)` : "";
566454
+ hwExpStr += ` Disk ${diskColor(rm4.diskUtil + "%")}${c3.dim(diskDetail)}`;
566455
+ hwCompStr += ` Disk ${diskColor(rm4.diskUtil + "%")}`;
566456
+ hwExpW += 6 + `${rm4.diskUtil}%`.length + diskDetail.length;
566457
+ hwCompW += 6 + `${rm4.diskUtil}%`.length;
566458
+ }
566459
+ if (rm4.gpuUtil >= 0) {
566460
+ const gpuColor = rm4.gpuUtil > 80 ? c3.red : rm4.gpuUtil > 50 ? c3.yellow : c3.green;
566461
+ const gpuNameShort = rm4.gpuName ? ` (${rm4.gpuName.slice(0, 20)})` : "";
566462
+ hwExpStr += ` GPU ${gpuColor(rm4.gpuUtil + "%")}${c3.dim(gpuNameShort)}`;
566463
+ hwCompStr += ` GPU ${gpuColor(rm4.gpuUtil + "%")}`;
566464
+ hwExpW += 5 + `${rm4.gpuUtil}%`.length + gpuNameShort.length;
566465
+ hwCompW += 5 + `${rm4.gpuUtil}%`.length;
566466
+ }
566467
+ if (rm4.vramUtil >= 0) {
566468
+ const vramColor = rm4.vramUtil > 80 ? c3.red : rm4.vramUtil > 50 ? c3.yellow : c3.green;
566469
+ const vramDetail = rm4.vramTotalMB > 0 ? ` (${rm4.vramUsedMB}/${rm4.vramTotalMB}MB)` : "";
566470
+ hwExpStr += ` VRAM ${vramColor(rm4.vramUtil + "%")}${c3.dim(vramDetail)}`;
566471
+ hwCompStr += ` VRAM ${vramColor(rm4.vramUtil + "%")}`;
566472
+ hwExpW += 6 + `${rm4.vramUtil}%`.length + vramDetail.length;
566473
+ hwCompW += 6 + `${rm4.vramUtil}%`.length;
566377
566474
  }
566378
566475
  if (!isLocal && hwExpW === 0) {
566379
- const statusMsg = rm3.gpuName && rm3.gpuName !== "peer" ? rm3.gpuName : "awaiting metrics...";
566476
+ const statusMsg = rm4.gpuName && rm4.gpuName !== "peer" ? rm4.gpuName : "awaiting metrics...";
566380
566477
  hwExpStr = c3.dim(statusMsg);
566381
566478
  hwCompStr = c3.dim(statusMsg.slice(0, 20));
566382
566479
  hwExpW = statusMsg.length;
@@ -567793,7 +567890,7 @@ __export(personaplex_exports, {
567793
567890
  stopPersonaPlex: () => stopPersonaPlex
567794
567891
  });
567795
567892
  import { existsSync as existsSync85, writeFileSync as writeFileSync45, readFileSync as readFileSync69, mkdirSync as mkdirSync48, copyFileSync as copyFileSync3, readdirSync as readdirSync27, statSync as statSync30 } from "node:fs";
567796
- import { join as join102, dirname as dirname29 } from "node:path";
567893
+ import { join as join102, dirname as dirname30 } from "node:path";
567797
567894
  import { homedir as homedir29 } from "node:os";
567798
567895
  import { execSync as execSync49, spawn as spawn24 } from "node:child_process";
567799
567896
  import { fileURLToPath as fileURLToPath13 } from "node:url";
@@ -568607,7 +568704,7 @@ function getShippedVoicesDir() {
568607
568704
  // repo root
568608
568705
  ];
568609
568706
  try {
568610
- const modDir = dirname29(fileURLToPath13(import.meta.url));
568707
+ const modDir = dirname30(fileURLToPath13(import.meta.url));
568611
568708
  candidates.push(join102(modDir, "..", "..", "..", "voices", "personaplex"));
568612
568709
  candidates.push(join102(modDir, "..", "..", "..", "..", "voices", "personaplex"));
568613
568710
  } catch {
@@ -568822,10 +568919,10 @@ function wrapText(value2, width) {
568822
568919
  if (line) lines.push(line);
568823
568920
  return lines.length > 0 ? lines : [""];
568824
568921
  }
568825
- async function checkToolSupport(modelName, backendUrl = "http://localhost:11434") {
568922
+ async function checkToolSupport(modelName, backendUrl2 = "http://localhost:11434") {
568826
568923
  if (_toolSupportCache.has(modelName)) return _toolSupportCache.get(modelName);
568827
568924
  try {
568828
- const resp = await fetch(`${backendUrl.replace(/\/+$/, "")}/api/chat`, {
568925
+ const resp = await fetch(`${backendUrl2.replace(/\/+$/, "")}/api/chat`, {
568829
568926
  method: "POST",
568830
568927
  headers: { "Content-Type": "application/json" },
568831
568928
  body: JSON.stringify({
@@ -568845,8 +568942,8 @@ async function checkToolSupport(modelName, backendUrl = "http://localhost:11434"
568845
568942
  return true;
568846
568943
  }
568847
568944
  }
568848
- async function needsTextToolMode(modelName, backendUrl) {
568849
- const hasTools = await checkToolSupport(modelName, backendUrl);
568945
+ async function needsTextToolMode(modelName, backendUrl2) {
568946
+ const hasTools = await checkToolSupport(modelName, backendUrl2);
568850
568947
  return !hasTools;
568851
568948
  }
568852
568949
  function detectSystemSpecs() {
@@ -569452,7 +569549,7 @@ function installOllamaWindows() {
569452
569549
  return false;
569453
569550
  }
569454
569551
  }
569455
- async function ensureOllamaRunning(backendUrl, rl) {
569552
+ async function ensureOllamaRunning(backendUrl2, rl) {
569456
569553
  const ollamaInstalled = hasCmd("ollama");
569457
569554
  if (!ollamaInstalled) {
569458
569555
  if (rl) {
@@ -569492,7 +569589,7 @@ async function ensureOllamaRunning(backendUrl, rl) {
569492
569589
  for (let i2 = 0; i2 < 5; i2++) {
569493
569590
  await new Promise((resolve48) => setTimeout(resolve48, 2e3));
569494
569591
  try {
569495
- const resp = await fetch(`${backendUrl}/api/tags`, {
569592
+ const resp = await fetch(`${backendUrl2}/api/tags`, {
569496
569593
  signal: AbortSignal.timeout(3e3)
569497
569594
  });
569498
569595
  if (resp.ok) {
@@ -570076,11 +570173,11 @@ ${c3.cyan(OMNIUS_FIRST_RUN_BANNER)}
570076
570173
 
570077
570174
  `);
570078
570175
  if (models.length > 0) {
570079
- const backendUrl = config.backendUrl || "http://localhost:11434";
570176
+ const backendUrl2 = config.backendUrl || "http://localhost:11434";
570080
570177
  const modelChecks = await Promise.all(
570081
570178
  models.slice(0, 15).map(async (m2) => ({
570082
570179
  ...m2,
570083
- hasTools: await checkToolSupport(m2.name, backendUrl)
570180
+ hasTools: await checkToolSupport(m2.name, backendUrl2)
570084
570181
  }))
570085
570182
  );
570086
570183
  const modelItems = modelChecks.map((m2) => {
@@ -570734,10 +570831,10 @@ function parseShowNumCtx2(show) {
570734
570831
  }
570735
570832
  return 0;
570736
570833
  }
570737
- async function checkExpandedVariant(modelName, backendUrl) {
570834
+ async function checkExpandedVariant(modelName, backendUrl2) {
570738
570835
  if (modelName.startsWith("omnius-")) return null;
570739
570836
  try {
570740
- const models = await fetchOllamaModels(backendUrl);
570837
+ const models = await fetchOllamaModels(backendUrl2);
570741
570838
  for (const candidate of expandedModelCandidates(modelName)) {
570742
570839
  const found = models.find((m2) => m2.name === candidate || m2.name.startsWith(candidate + ":"));
570743
570840
  if (found) return found.name;
@@ -570753,9 +570850,9 @@ function modelSizeGB(models, modelName) {
570753
570850
  const known = QWEN_VARIANTS.find((v) => modelName.includes(v.tag.split(":")[1] ?? ""));
570754
570851
  return known?.sizeGB ?? 4;
570755
570852
  }
570756
- async function queryModelKVInfo(backendUrl, modelName) {
570853
+ async function queryModelKVInfo(backendUrl2, modelName) {
570757
570854
  try {
570758
- const normalized = backendUrl.replace(/\/+$/, "");
570855
+ const normalized = backendUrl2.replace(/\/+$/, "");
570759
570856
  const res = await fetch(`${normalized}/api/show`, {
570760
570857
  method: "POST",
570761
570858
  headers: { "Content-Type": "application/json" },
@@ -570781,9 +570878,9 @@ async function queryModelKVInfo(backendUrl, modelName) {
570781
570878
  return null;
570782
570879
  }
570783
570880
  }
570784
- async function readExpandedVariantState(backendUrl, modelName) {
570881
+ async function readExpandedVariantState(backendUrl2, modelName) {
570785
570882
  try {
570786
- const normalized = backendUrl.replace(/\/+$/, "");
570883
+ const normalized = backendUrl2.replace(/\/+$/, "");
570787
570884
  const showRes = await fetch(`${normalized}/api/show`, {
570788
570885
  method: "POST",
570789
570886
  headers: { "Content-Type": "application/json" },
@@ -570854,8 +570951,8 @@ async function createExpandedVariantNamedAsync(targetModel, baseModel, specs, si
570854
570951
  return null;
570855
570952
  }
570856
570953
  }
570857
- async function repairExpandedVariantIfStale(variantModel, fallbackBaseModel, backendUrl, specs, sizeGB, targetNumCtx, kvBytesPerToken, archMax) {
570858
- const state = await readExpandedVariantState(backendUrl, variantModel);
570954
+ async function repairExpandedVariantIfStale(variantModel, fallbackBaseModel, backendUrl2, specs, sizeGB, targetNumCtx, kvBytesPerToken, archMax) {
570955
+ const state = await readExpandedVariantState(backendUrl2, variantModel);
570859
570956
  const variantName = stripVariantTag(variantModel);
570860
570957
  if (!state) return { repaired: false, currentNumCtx: 0, baseModel: null, resolvedModel: variantName };
570861
570958
  const baseModel = state.baseModel && !state.baseModel.startsWith("omnius-") ? state.baseModel : fallbackBaseModel;
@@ -570902,17 +570999,17 @@ async function createExpandedVariantAsync(baseModel, specs, sizeGB, kvBytesPerTo
570902
570999
  archMax
570903
571000
  );
570904
571001
  }
570905
- async function ensureExpandedContext(modelName, backendUrl) {
571002
+ async function ensureExpandedContext(modelName, backendUrl2) {
570906
571003
  if (modelName.includes("cloud") || modelName.includes(":cloud")) {
570907
571004
  return { model: modelName, created: false, contextLabel: "remote", numCtx: 0 };
570908
571005
  }
570909
571006
  const specs = await detectSystemSpecsAsync();
570910
- const variantState = modelName.startsWith("omnius-") ? await readExpandedVariantState(backendUrl, modelName).catch(() => null) : null;
571007
+ const variantState = modelName.startsWith("omnius-") ? await readExpandedVariantState(backendUrl2, modelName).catch(() => null) : null;
570911
571008
  const targetModelName = variantState?.baseModel && !variantState.baseModel.startsWith("omnius-") ? variantState.baseModel : modelName;
570912
- const kvInfo = await queryModelKVInfo(backendUrl, targetModelName);
571009
+ const kvInfo = await queryModelKVInfo(backendUrl2, targetModelName);
570913
571010
  let sizeGB = 4;
570914
571011
  try {
570915
- const models = await fetchOllamaModels(backendUrl);
571012
+ const models = await fetchOllamaModels(backendUrl2);
570916
571013
  sizeGB = modelSizeGB(models, targetModelName);
570917
571014
  } catch {
570918
571015
  }
@@ -570921,7 +571018,7 @@ async function ensureExpandedContext(modelName, backendUrl) {
570921
571018
  const repair = await repairExpandedVariantIfStale(
570922
571019
  modelName,
570923
571020
  null,
570924
- backendUrl,
571021
+ backendUrl2,
570925
571022
  specs,
570926
571023
  sizeGB,
570927
571024
  ctx3.numCtx,
@@ -570930,12 +571027,12 @@ async function ensureExpandedContext(modelName, backendUrl) {
570930
571027
  ).catch(() => ({ repaired: false, currentNumCtx: 0, baseModel: null, resolvedModel: modelName }));
570931
571028
  return { model: repair.resolvedModel, created: false, contextLabel: ctx3.label, numCtx: ctx3.numCtx };
570932
571029
  }
570933
- const existing = await checkExpandedVariant(modelName, backendUrl);
571030
+ const existing = await checkExpandedVariant(modelName, backendUrl2);
570934
571031
  if (existing === null) {
570935
571032
  return { model: modelName, created: false, contextLabel: "", numCtx: 0 };
570936
571033
  }
570937
571034
  if (typeof existing === "string") {
570938
- const lostTools = await wrapperLacksToolsCapability(backendUrl, existing).catch(() => false);
571035
+ const lostTools = await wrapperLacksToolsCapability(backendUrl2, existing).catch(() => false);
570939
571036
  if (lostTools) {
570940
571037
  try {
570941
571038
  const rebuilt = await createExpandedVariantNamedAsync(
@@ -570955,7 +571052,7 @@ async function ensureExpandedContext(modelName, backendUrl) {
570955
571052
  const repair = await repairExpandedVariantIfStale(
570956
571053
  existing,
570957
571054
  modelName,
570958
- backendUrl,
571055
+ backendUrl2,
570959
571056
  specs,
570960
571057
  sizeGB,
570961
571058
  ctx3.numCtx,
@@ -570981,9 +571078,9 @@ function guessBaseFromVariant(variantName, models) {
570981
571078
  }
570982
571079
  return null;
570983
571080
  }
570984
- async function wrapperLacksToolsCapability(backendUrl, modelName) {
571081
+ async function wrapperLacksToolsCapability(backendUrl2, modelName) {
570985
571082
  try {
570986
- const normalized = backendUrl.replace(/\/+$/, "");
571083
+ const normalized = backendUrl2.replace(/\/+$/, "");
570987
571084
  const showRes = await fetch(`${normalized}/api/show`, {
570988
571085
  method: "POST",
570989
571086
  headers: { "Content-Type": "application/json" },
@@ -571002,9 +571099,9 @@ async function wrapperLacksToolsCapability(backendUrl, modelName) {
571002
571099
  return false;
571003
571100
  }
571004
571101
  }
571005
- async function repairAllExpandedVariants(backendUrl) {
571102
+ async function repairAllExpandedVariants(backendUrl2) {
571006
571103
  const specs = await detectSystemSpecsAsync();
571007
- const models = await fetchOllamaModels(backendUrl);
571104
+ const models = await fetchOllamaModels(backendUrl2);
571008
571105
  const variants = models.filter((model) => /^omnius-/i.test(model.name));
571009
571106
  const summary = {
571010
571107
  scanned: 0,
@@ -571014,7 +571111,7 @@ async function repairAllExpandedVariants(backendUrl) {
571014
571111
  };
571015
571112
  for (const variant of variants) {
571016
571113
  summary.scanned += 1;
571017
- const state = await readExpandedVariantState(backendUrl, variant.name);
571114
+ const state = await readExpandedVariantState(backendUrl2, variant.name);
571018
571115
  if (!state) {
571019
571116
  summary.failed.push({ model: variant.name, reason: "missing-state" });
571020
571117
  continue;
@@ -571028,9 +571125,9 @@ async function repairAllExpandedVariants(backendUrl) {
571028
571125
  continue;
571029
571126
  }
571030
571127
  const sizeGB = modelSizeGB(models, baseModel);
571031
- const kvInfo = await queryModelKVInfo(backendUrl, baseModel);
571128
+ const kvInfo = await queryModelKVInfo(backendUrl2, baseModel);
571032
571129
  const target = calculateExpandedVariantContextWindow(specs, sizeGB, kvInfo?.kvBytesPerToken, kvInfo?.archMax);
571033
- const lostTools = await wrapperLacksToolsCapability(backendUrl, variant.name);
571130
+ const lostTools = await wrapperLacksToolsCapability(backendUrl2, variant.name);
571034
571131
  try {
571035
571132
  let result;
571036
571133
  if (lostTools) {
@@ -571052,7 +571149,7 @@ async function repairAllExpandedVariants(backendUrl) {
571052
571149
  result = await repairExpandedVariantIfStale(
571053
571150
  variant.name,
571054
571151
  baseModel,
571055
- backendUrl,
571152
+ backendUrl2,
571056
571153
  specs,
571057
571154
  sizeGB,
571058
571155
  target.numCtx,
@@ -571943,7 +572040,7 @@ var init_platforms = __esm({
571943
572040
 
571944
572041
  // packages/cli/src/tui/workspace-explorer.ts
571945
572042
  import { existsSync as existsSync88, readdirSync as readdirSync28, readFileSync as readFileSync71, statSync as statSync31 } from "node:fs";
571946
- import { basename as basename16, extname as extname12, join as join104, relative as relative10, resolve as resolve35 } from "node:path";
572043
+ import { basename as basename17, extname as extname12, join as join104, relative as relative10, resolve as resolve35 } from "node:path";
571947
572044
  function exploreWorkspace(root, options2 = {}) {
571948
572045
  const query = (options2.query ?? "").trim().toLowerCase();
571949
572046
  const maxResults = options2.maxResults ?? 80;
@@ -572060,7 +572157,7 @@ function classifyWorkspaceFile(path11) {
572060
572157
  if (lower.includes(".test.") || lower.includes(".spec.") || lower.includes("/tests/")) return "test";
572061
572158
  if (SOURCE_EXT.has(ext)) return "source";
572062
572159
  if (DOC_EXT2.has(ext)) return "doc";
572063
- if (CONFIG_EXT.has(ext) || basename16(lower).startsWith("dockerfile")) return "config";
572160
+ if (CONFIG_EXT.has(ext) || basename17(lower).startsWith("dockerfile")) return "config";
572064
572161
  if (ASSET_EXT.has(ext)) return "asset";
572065
572162
  return "other";
572066
572163
  }
@@ -572072,7 +572169,7 @@ function scoreWorkspaceFile(entry, query) {
572072
572169
  if (entry.path.startsWith("packages/cli/src/")) score += 5;
572073
572170
  if (query) {
572074
572171
  const lower = entry.path.toLowerCase();
572075
- const name10 = basename16(lower);
572172
+ const name10 = basename17(lower);
572076
572173
  if (name10.startsWith(query)) score += 20;
572077
572174
  if (lower.includes(`/${query}`)) score += 12;
572078
572175
  if (lower.includes(query)) score += 8;
@@ -575119,7 +575216,7 @@ import { existsSync as existsSync92, readFileSync as readFileSync73, writeFileSy
575119
575216
  import { join as join107 } from "node:path";
575120
575217
  import { homedir as homedir32 } from "node:os";
575121
575218
  import { fileURLToPath as fileURLToPath14 } from "node:url";
575122
- import { dirname as dirname30 } from "node:path";
575219
+ import { dirname as dirname31 } from "node:path";
575123
575220
  function getDaemonPort() {
575124
575221
  const env2 = process.env["OMNIUS_HOST"];
575125
575222
  if (env2) {
@@ -575184,7 +575281,7 @@ async function resolveDaemonCommand(nodeExe) {
575184
575281
  if (first2) candidates.push(first2);
575185
575282
  } catch {
575186
575283
  }
575187
- const thisDir = dirname30(fileURLToPath14(import.meta.url));
575284
+ const thisDir = dirname31(fileURLToPath14(import.meta.url));
575188
575285
  candidates.push(join107(thisDir, "index.js"));
575189
575286
  const seen = /* @__PURE__ */ new Set();
575190
575287
  for (const candidate of candidates) {
@@ -576929,6 +577026,7 @@ __export(voice_exports, {
576929
577026
  describeTaskComplete: () => describeTaskComplete,
576930
577027
  describeToolCall: () => describeToolCall,
576931
577028
  describeToolResult: () => describeToolResult,
577029
+ getSupertonicVoiceOptions: () => getSupertonicVoiceOptions,
576932
577030
  listVoiceModels: () => listVoiceModels,
576933
577031
  registerCustomOnnxModel: () => registerCustomOnnxModel,
576934
577032
  resetNarrationContext: () => resetNarrationContext
@@ -576942,7 +577040,7 @@ import {
576942
577040
  readdirSync as readdirSync29,
576943
577041
  statSync as statSync33
576944
577042
  } from "node:fs";
576945
- import { join as join109, dirname as dirname31 } from "node:path";
577043
+ import { join as join109, dirname as dirname32 } from "node:path";
576946
577044
  import { homedir as homedir33, tmpdir as tmpdir20, platform as platform5 } from "node:os";
576947
577045
  import {
576948
577046
  execSync as execSync52,
@@ -576966,9 +577064,35 @@ function listVoiceModels() {
576966
577064
  return Object.values(VOICE_MODELS).map((m2) => ({
576967
577065
  id: m2.id,
576968
577066
  label: m2.label,
576969
- backend: m2.backend ?? "onnx"
577067
+ backend: m2.backend ?? "onnx",
577068
+ ...m2.mlxModelId ? { modelId: m2.mlxModelId } : {},
577069
+ ...m2.mlxVoice ? { voice: m2.mlxVoice } : {},
577070
+ ...m2.mlxLangCode ? { lang: m2.mlxLangCode } : {},
577071
+ ...m2.supertonicVoice ? { voice: m2.supertonicVoice } : {},
577072
+ ...m2.supertonicLang ? { lang: m2.supertonicLang } : {},
577073
+ ...m2.backend === "luxtts" ? { supportsCloneRefs: true } : {},
577074
+ ...m2.backend === "supertonic" ? { supportsSupertonicSettings: true } : {}
576970
577075
  }));
576971
577076
  }
577077
+ function getSupertonicVoiceOptions() {
577078
+ return {
577079
+ voices: [...SUPERTONIC_VOICES],
577080
+ langs: [...SUPERTONIC_LANGS],
577081
+ expressions: ["auto", "none", "laugh", "breath", "sigh"],
577082
+ speed: {
577083
+ min: 0.7,
577084
+ max: 1.8,
577085
+ step: 0.05,
577086
+ default: DEFAULT_SUPERTONIC_SETTINGS.speed
577087
+ },
577088
+ totalStep: {
577089
+ min: 4,
577090
+ max: 16,
577091
+ step: 1,
577092
+ default: DEFAULT_SUPERTONIC_SETTINGS.totalStep
577093
+ }
577094
+ };
577095
+ }
576972
577096
  function voiceDir2() {
576973
577097
  return join109(homedir33(), ".omnius", "voice");
576974
577098
  }
@@ -577157,7 +577281,7 @@ function insertTagAfterOpeningClause(text, tag) {
577157
577281
  function writeDetectTorchScript(targetPath) {
577158
577282
  if (existsSync95(targetPath)) return;
577159
577283
  try {
577160
- mkdirSync52(dirname31(targetPath), { recursive: true });
577284
+ mkdirSync52(dirname32(targetPath), { recursive: true });
577161
577285
  } catch {
577162
577286
  }
577163
577287
  const script = `#!/usr/bin/env python3
@@ -580575,7 +580699,7 @@ __export(key_pool_menu_exports, {
580575
580699
  showKeyPoolMenu: () => showKeyPoolMenu
580576
580700
  });
580577
580701
  async function showKeyPoolMenu(options2) {
580578
- const { pool: pool3, backendUrl, providerLabel, rl, availableRows, onSave, onSetKeyPool } = options2;
580702
+ const { pool: pool3, backendUrl: backendUrl2, providerLabel, rl, availableRows, onSave, onSetKeyPool } = options2;
580579
580703
  if (pool3.length === 0) {
580580
580704
  renderInfo("No key pool configured. Use /endpoint add <url> --auth <key> to add keys.");
580581
580705
  return;
@@ -580603,7 +580727,7 @@ async function showKeyPoolMenu(options2) {
580603
580727
  const result = await tuiSelect({
580604
580728
  items,
580605
580729
  activeKey: pool3[0]?.suffix,
580606
- title: "Key Pool: " + backendUrl,
580730
+ title: "Key Pool: " + backendUrl2,
580607
580731
  rl,
580608
580732
  availableRows,
580609
580733
  onDelete: (item, done) => {
@@ -580764,11 +580888,13 @@ function startSponsorHeartbeat(payload, getExposeGateway) {
580764
580888
  try {
580765
580889
  const { existsSync: _fe, readFileSync: _rf } = __require("node:fs");
580766
580890
  const { join: _pj } = __require("node:path");
580767
- for (const base3 of [
580768
- process.cwd(),
580769
- __require("node:os").homedir() + "/.omnius"
580770
- ]) {
580771
- const sf = _pj(base3, ".omnius", "nexus", "status.json");
580891
+ const nexusDirs = [
580892
+ new NexusTool(process.cwd()).getNexusDir(),
580893
+ _pj(process.cwd(), ".omnius", "nexus"),
580894
+ _pj(__require("node:os").homedir(), ".omnius", "nexus")
580895
+ ];
580896
+ for (const dir of Array.from(new Set(nexusDirs))) {
580897
+ const sf = _pj(dir, "status.json");
580772
580898
  if (_fe(sf)) {
580773
580899
  const st = JSON.parse(_rf(sf, "utf8"));
580774
580900
  if (st.connected && st.peerId && st.peerId.startsWith("12D3KooW")) {
@@ -580967,12 +581093,12 @@ async function ensureVoiceDeps(ctx3) {
580967
581093
  renderInfo(res.log.split("\n").slice(-3).join(" ").slice(0, 200));
580968
581094
  }
580969
581095
  if (typeof mod2.getVenvPython === "function") {
580970
- const { dirname: dirname40 } = await import("node:path");
581096
+ const { dirname: dirname41 } = await import("node:path");
580971
581097
  const { existsSync: existsSync124 } = await import("node:fs");
580972
581098
  const venvPy = mod2.getVenvPython();
580973
581099
  if (existsSync124(venvPy)) {
580974
581100
  process.env.TRANSCRIBE_PYTHON = venvPy;
580975
- const venvBin = dirname40(venvPy);
581101
+ const venvBin = dirname41(venvPy);
580976
581102
  const sep3 = process.platform === "win32" ? ";" : ":";
580977
581103
  const cur = process.env.PATH || "";
580978
581104
  if (!cur.split(sep3).includes(venvBin)) {
@@ -582096,10 +582222,11 @@ async function handleSlashCommand(input, ctx3) {
582096
582222
  const sub = arg?.split(/\s+/)[0] ?? "";
582097
582223
  const rest2 = arg?.slice(sub.length).trim() ?? "";
582098
582224
  if (!sub || sub === "status") {
582099
- const nexusDir = ctx3.repoRoot ? __require("node:path").join(ctx3.repoRoot, ".omnius", "nexus") : null;
582100
- const statusFile = nexusDir ? __require("node:path").join(nexusDir, "status.json") : null;
582225
+ const nexus = new NexusTool(ctx3.repoRoot ?? process.cwd());
582226
+ const nexusDir = nexus.getNexusDir();
582227
+ const statusFile = __require("node:path").join(nexusDir, "status.json");
582101
582228
  const { existsSync: ex, readFileSync: rf } = __require("node:fs");
582102
- if (statusFile && ex(statusFile)) {
582229
+ if (ex(statusFile)) {
582103
582230
  try {
582104
582231
  const status = JSON.parse(rf(statusFile, "utf8"));
582105
582232
  if (status.connected && status.peerId) {
@@ -582180,9 +582307,7 @@ async function handleSlashCommand(input, ctx3) {
582180
582307
  renderInfo(out.split("\n").slice(0, 4).join("\n"));
582181
582308
  try {
582182
582309
  const pidFile = join110(
582183
- ctx3.repoRoot ?? process.cwd(),
582184
- ".omnius",
582185
- "nexus",
582310
+ nexus.getNexusDir(),
582186
582311
  "daemon.pid"
582187
582312
  );
582188
582313
  if (existsSync96(pidFile)) {
@@ -582207,10 +582332,11 @@ async function handleSlashCommand(input, ctx3) {
582207
582332
  );
582208
582333
  }
582209
582334
  } else if (sub === "wallet") {
582210
- const nexusDir = ctx3.repoRoot ? __require("node:path").join(ctx3.repoRoot, ".omnius", "nexus") : null;
582211
- const walletFile = nexusDir ? __require("node:path").join(nexusDir, "wallet.enc") : null;
582335
+ const nexus = new NexusTool(ctx3.repoRoot ?? process.cwd());
582336
+ const nexusDir = nexus.getNexusDir();
582337
+ const walletFile = __require("node:path").join(nexusDir, "wallet.enc");
582212
582338
  const { existsSync: ex, readFileSync: rf } = __require("node:fs");
582213
- if (walletFile && ex(walletFile)) {
582339
+ if (ex(walletFile)) {
582214
582340
  try {
582215
582341
  const w = JSON.parse(rf(walletFile, "utf8"));
582216
582342
  process.stdout.write(`
@@ -582273,11 +582399,8 @@ async function handleSlashCommand(input, ctx3) {
582273
582399
  renderInfo(`Set a custom name: /nexus name <your-name>`);
582274
582400
  }
582275
582401
  } else if (sub === "restart" || sub === "disconnect" || sub === "kill") {
582276
- const nexusDir = ctx3.repoRoot ? __require("node:path").join(ctx3.repoRoot, ".omnius", "nexus") : null;
582277
- if (!nexusDir) {
582278
- renderError("No repo root found — cannot locate nexus daemon.");
582279
- return "handled";
582280
- }
582402
+ const nexus = new NexusTool(ctx3.repoRoot ?? process.cwd());
582403
+ const nexusDir = nexus.getNexusDir();
582281
582404
  const {
582282
582405
  existsSync: ex,
582283
582406
  readFileSync: rf,
@@ -582770,7 +582893,8 @@ async function handleSlashCommand(input, ctx3) {
582770
582893
  ` Backend: ${heliaBlocks > 0 ? c3.green("helia-ipfs") : c3.yellow("sha256-local (Helia not initialized)")}`
582771
582894
  );
582772
582895
  try {
582773
- const statusFile = join110(ctx3.repoRoot, ".omnius", "nexus", "status.json");
582896
+ const nexusDir = new NexusTool(ctx3.repoRoot ?? process.cwd()).getNexusDir();
582897
+ const statusFile = join110(nexusDir, "status.json");
582774
582898
  if (existsSync96(statusFile)) {
582775
582899
  const status = JSON.parse(readFileSync77(statusFile, "utf8"));
582776
582900
  if (status.peerId) {
@@ -585056,16 +585180,17 @@ sleep 1
585056
585180
  }
585057
585181
  if (!sponsorUrl && !sponsorPeerId) {
585058
585182
  _spLog("FAILED — no tunnelUrl and no peerId");
585059
- _spLog(`nexusDir checked: ${join110(projectDir2, ".omnius", "nexus")}`);
585183
+ const checkedNexusDir = new NexusTool(projectDir2).getNexusDir();
585184
+ _spLog(`nexusDir checked: ${checkedNexusDir}`);
585060
585185
  _spLog(
585061
- `status.json exists: ${existsSync96(join110(projectDir2, ".omnius", "nexus", "status.json"))}`
585186
+ `status.json exists: ${existsSync96(join110(checkedNexusDir, "status.json"))}`
585062
585187
  );
585063
585188
  _spLog(
585064
- `daemon.pid exists: ${existsSync96(join110(projectDir2, ".omnius", "nexus", "daemon.pid"))}`
585189
+ `daemon.pid exists: ${existsSync96(join110(checkedNexusDir, "daemon.pid"))}`
585065
585190
  );
585066
585191
  try {
585067
585192
  const _statusRaw = readFileSync77(
585068
- join110(projectDir2, ".omnius", "nexus", "status.json"),
585193
+ join110(checkedNexusDir, "status.json"),
585069
585194
  "utf8"
585070
585195
  );
585071
585196
  _spLog(`status.json content: ${_statusRaw.slice(0, 300)}`);
@@ -585074,7 +585199,7 @@ sleep 1
585074
585199
  }
585075
585200
  try {
585076
585201
  const _errRaw = readFileSync77(
585077
- join110(projectDir2, ".omnius", "nexus", "daemon.err"),
585202
+ join110(checkedNexusDir, "daemon.err"),
585078
585203
  "utf8"
585079
585204
  );
585080
585205
  _spLog(`daemon.err (last 500): ${_errRaw.slice(-500)}`);
@@ -585200,7 +585325,7 @@ sleep 1
585200
585325
  if (result) {
585201
585326
  renderInfo("Sponsor wizard completed.");
585202
585327
  try {
585203
- const nexusPidFile = join110(projectDir2, ".omnius", "nexus", "daemon.pid");
585328
+ const nexusPidFile = join110(new NexusTool(projectDir2).getNexusDir(), "daemon.pid");
585204
585329
  if (existsSync96(nexusPidFile)) {
585205
585330
  const nPid = parseInt(
585206
585331
  readFileSync77(nexusPidFile, "utf8").trim(),
@@ -587504,11 +587629,11 @@ function cacheCandidatePaths(root, model) {
587504
587629
  }
587505
587630
  function directorySizeBytes2(path11, seen = /* @__PURE__ */ new Set()) {
587506
587631
  try {
587507
- const stat5 = lstatSync(path11);
587508
- if (stat5.isSymbolicLink()) return 0;
587509
- if (stat5.isFile()) return stat5.size;
587510
- if (!stat5.isDirectory()) return 0;
587511
- const realKey = `${stat5.dev}:${stat5.ino}`;
587632
+ const stat6 = lstatSync(path11);
587633
+ if (stat6.isSymbolicLink()) return 0;
587634
+ if (stat6.isFile()) return stat6.size;
587635
+ if (!stat6.isDirectory()) return 0;
587636
+ const realKey = `${stat6.dev}:${stat6.ino}`;
587512
587637
  if (seen.has(realKey)) return 0;
587513
587638
  seen.add(realKey);
587514
587639
  let total = 0;
@@ -588809,14 +588934,14 @@ async function handleVoiceMenu(ctx3, save2, hasLocal) {
588809
588934
  if (!jsonDrop.confirmed || !jsonDrop.path) {
588810
588935
  continue;
588811
588936
  }
588812
- const { basename: basename26, join: pathJoin } = await import("node:path");
588937
+ const { basename: basename27, join: pathJoin } = await import("node:path");
588813
588938
  const {
588814
588939
  copyFileSync: copyFileSync4,
588815
588940
  mkdirSync: mkdirSync76,
588816
588941
  existsSync: exists2
588817
588942
  } = await import("node:fs");
588818
588943
  const { homedir: homedir48 } = await import("node:os");
588819
- const modelName = basename26(onnxDrop.path, ".onnx").replace(
588944
+ const modelName = basename27(onnxDrop.path, ".onnx").replace(
588820
588945
  /[^a-zA-Z0-9_-]/g,
588821
588946
  "-"
588822
588947
  );
@@ -589203,7 +589328,7 @@ async function handleVoiceList(ctx3, focusFilename) {
589203
589328
  copyFileSync: cpf,
589204
589329
  mkdirSync: mkd
589205
589330
  } = __require("node:fs");
589206
- const { basename: basename26, join: pjoin } = __require("node:path");
589331
+ const { basename: basename27, join: pjoin } = __require("node:path");
589207
589332
  if (!fe(src2)) {
589208
589333
  renderError(`File not found: ${src2}`);
589209
589334
  helpers.render();
@@ -589216,7 +589341,7 @@ async function handleVoiceList(ctx3, focusFilename) {
589216
589341
  "clone-refs"
589217
589342
  );
589218
589343
  mkd(refsDir, { recursive: true });
589219
- const destName = basename26(src2);
589344
+ const destName = basename27(src2);
589220
589345
  const dest = pjoin(refsDir, destName);
589221
589346
  cpf(src2, dest);
589222
589347
  renderInfo(`Imported "${destName}" → ${dest}`);
@@ -590100,14 +590225,14 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local) {
590100
590225
  if (models.length > 0) {
590101
590226
  try {
590102
590227
  const { writeFileSync: writeFileSync71, mkdirSync: mkdirSync76 } = await import("node:fs");
590103
- const { join: join142, dirname: dirname40 } = await import("node:path");
590228
+ const { join: join142, dirname: dirname41 } = await import("node:path");
590104
590229
  const cachePath = join142(
590105
590230
  ctx3.repoRoot || process.cwd(),
590106
590231
  ".omnius",
590107
590232
  "nexus",
590108
590233
  "peer-models-cache.json"
590109
590234
  );
590110
- mkdirSync76(dirname40(cachePath), { recursive: true });
590235
+ mkdirSync76(dirname41(cachePath), { recursive: true });
590111
590236
  writeFileSync71(
590112
590237
  cachePath,
590113
590238
  JSON.stringify(
@@ -590880,10 +591005,10 @@ async function handleUpdate(subcommand, ctx3) {
590880
591005
  try {
590881
591006
  const { createRequire: createRequire10 } = await import("node:module");
590882
591007
  const { fileURLToPath: fileURLToPath20 } = await import("node:url");
590883
- const { dirname: dirname40, join: join142 } = await import("node:path");
591008
+ const { dirname: dirname41, join: join142 } = await import("node:path");
590884
591009
  const { existsSync: existsSync124 } = await import("node:fs");
590885
591010
  const req2 = createRequire10(import.meta.url);
590886
- const thisDir = dirname40(fileURLToPath20(import.meta.url));
591011
+ const thisDir = dirname41(fileURLToPath20(import.meta.url));
590887
591012
  const candidates = [
590888
591013
  join142(thisDir, "..", "package.json"),
590889
591014
  join142(thisDir, "..", "..", "package.json"),
@@ -591633,11 +591758,12 @@ async function handleUpdate(subcommand, ctx3) {
591633
591758
  const { join: _pj } = await import("node:path");
591634
591759
  const { homedir: _hd } = await import("node:os");
591635
591760
  const daemonPaths = [
591761
+ _pj(new NexusTool(process.cwd()).getNexusDir(), "nexus-daemon.mjs"),
591636
591762
  _pj(_hd(), ".omnius", "nexus", "nexus-daemon.mjs"),
591637
591763
  _pj(process.cwd(), ".omnius", "nexus", "nexus-daemon.mjs")
591638
591764
  ];
591639
591765
  let cleaned = 0;
591640
- for (const dp of daemonPaths) {
591766
+ for (const dp of Array.from(new Set(daemonPaths))) {
591641
591767
  if (_fe(dp)) {
591642
591768
  try {
591643
591769
  _ul(dp);
@@ -591648,10 +591774,11 @@ async function handleUpdate(subcommand, ctx3) {
591648
591774
  }
591649
591775
  try {
591650
591776
  const pidPaths = [
591777
+ _pj(new NexusTool(process.cwd()).getNexusDir(), "daemon.pid"),
591651
591778
  _pj(_hd(), ".omnius", "nexus", "daemon.pid"),
591652
591779
  _pj(process.cwd(), ".omnius", "nexus", "daemon.pid")
591653
591780
  ];
591654
- for (const pp of pidPaths) {
591781
+ for (const pp of Array.from(new Set(pidPaths))) {
591655
591782
  if (_fe(pp)) {
591656
591783
  const { readFileSync: _rf } = await import("node:fs");
591657
591784
  const pid = parseInt(_rf(pp, "utf8").trim(), 10);
@@ -592539,7 +592666,7 @@ var init_commands = __esm({
592539
592666
 
592540
592667
  // packages/cli/src/tui/project-context.ts
592541
592668
  import { existsSync as existsSync97, readFileSync as readFileSync78, readdirSync as readdirSync31 } from "node:fs";
592542
- import { join as join111, basename as basename17 } from "node:path";
592669
+ import { join as join111, basename as basename18 } from "node:path";
592543
592670
  import { execSync as execSync53 } from "node:child_process";
592544
592671
  import { homedir as homedir35 } from "node:os";
592545
592672
  function getModelTier(modelName) {
@@ -592620,7 +592747,7 @@ function loadMemoryContext(repoRoot) {
592620
592747
  try {
592621
592748
  const raw = readFileSync78(join111(dir, file), "utf-8");
592622
592749
  const entries = JSON.parse(raw);
592623
- const topic = basename17(file, ".json");
592750
+ const topic = basename18(file, ".json");
592624
592751
  for (const [k, v] of Object.entries(entries)) {
592625
592752
  if (!v?.value) continue;
592626
592753
  all2.push({ topic, key: k, value: String(v.value), scope, ts: v.timestamp ?? "" });
@@ -593638,7 +593765,7 @@ var init_banner = __esm({
593638
593765
 
593639
593766
  // packages/cli/src/tui/carousel-descriptors.ts
593640
593767
  import { existsSync as existsSync99, readFileSync as readFileSync80, writeFileSync as writeFileSync52, mkdirSync as mkdirSync55, readdirSync as readdirSync32 } from "node:fs";
593641
- import { join as join113, basename as basename18 } from "node:path";
593768
+ import { join as join113, basename as basename19 } from "node:path";
593642
593769
  function loadToolProfile(repoRoot) {
593643
593770
  const filePath = join113(repoRoot, OMNIUS_DIR, "context", TOOL_PROFILE_FILE);
593644
593771
  try {
@@ -593734,7 +593861,7 @@ function generateDescriptors(repoRoot) {
593734
593861
  extractFromSessions(repoRoot, tags);
593735
593862
  extractFromMemory(repoRoot, tags);
593736
593863
  extractFromToolProfile(profile, tags);
593737
- const repoName2 = basename18(repoRoot);
593864
+ const repoName2 = basename19(repoRoot);
593738
593865
  if (repoName2 && !tags.includes(repoName2)) {
593739
593866
  tags.push(repoName2);
593740
593867
  }
@@ -594724,7 +594851,7 @@ var init_edit_history = __esm({
594724
594851
 
594725
594852
  // packages/cli/src/tui/promptLoader.ts
594726
594853
  import { readFileSync as readFileSync81, existsSync as existsSync100 } from "node:fs";
594727
- import { join as join115, dirname as dirname32 } from "node:path";
594854
+ import { join as join115, dirname as dirname33 } from "node:path";
594728
594855
  import { fileURLToPath as fileURLToPath15 } from "node:url";
594729
594856
  function loadPrompt3(promptPath, vars) {
594730
594857
  let content = cache7.get(promptPath);
@@ -594744,7 +594871,7 @@ var init_promptLoader3 = __esm({
594744
594871
  "packages/cli/src/tui/promptLoader.ts"() {
594745
594872
  "use strict";
594746
594873
  __filename5 = fileURLToPath15(import.meta.url);
594747
- __dirname7 = dirname32(__filename5);
594874
+ __dirname7 = dirname33(__filename5);
594748
594875
  devPath2 = join115(__dirname7, "..", "..", "prompts");
594749
594876
  publishedPath2 = join115(__dirname7, "..", "prompts");
594750
594877
  PROMPTS_DIR3 = existsSync100(devPath2) ? devPath2 : publishedPath2;
@@ -594754,7 +594881,7 @@ var init_promptLoader3 = __esm({
594754
594881
 
594755
594882
  // packages/cli/src/tui/dream-engine.ts
594756
594883
  import { mkdirSync as mkdirSync57, writeFileSync as writeFileSync53, readFileSync as readFileSync82, existsSync as existsSync101, readdirSync as readdirSync33 } from "node:fs";
594757
- import { join as join116, basename as basename19 } from "node:path";
594884
+ import { join as join116, basename as basename20 } from "node:path";
594758
594885
  import { execSync as execSync54 } from "node:child_process";
594759
594886
  function setDreamWriteContent(fn) {
594760
594887
  _dreamWriteContent = fn;
@@ -594967,7 +595094,7 @@ var init_dream_engine = __esm({
594967
595094
  const rawPath = String(args["path"] ?? "");
594968
595095
  const content = String(args["content"] ?? "");
594969
595096
  if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
594970
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join116(this.autoresearchDir, basename19(rawPath)) : join116(this.autoresearchDir, rawPath);
595097
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join116(this.autoresearchDir, basename20(rawPath)) : join116(this.autoresearchDir, rawPath);
594971
595098
  if (!targetPath.startsWith(this.autoresearchDir)) {
594972
595099
  return { success: false, output: "", error: "Autoresearch mode: writes are confined to .omnius/autoresearch/", durationMs: Date.now() - start2 };
594973
595100
  }
@@ -595002,7 +595129,7 @@ var init_dream_engine = __esm({
595002
595129
  const rawPath = String(args["path"] ?? "");
595003
595130
  const oldStr = String(args["old_string"] ?? "");
595004
595131
  const newStr = String(args["new_string"] ?? "");
595005
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join116(this.autoresearchDir, basename19(rawPath)) : join116(this.autoresearchDir, rawPath);
595132
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join116(this.autoresearchDir, basename20(rawPath)) : join116(this.autoresearchDir, rawPath);
595006
595133
  if (!targetPath.startsWith(this.autoresearchDir)) {
595007
595134
  return { success: false, output: "", error: "Autoresearch mode: edits are confined to .omnius/autoresearch/", durationMs: Date.now() - start2 };
595008
595135
  }
@@ -595055,7 +595182,7 @@ var init_dream_engine = __esm({
595055
595182
  const rawPath = String(args["path"] ?? "");
595056
595183
  const content = String(args["content"] ?? "");
595057
595184
  if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
595058
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join116(this.dreamsDir, basename19(rawPath)) : join116(this.dreamsDir, rawPath);
595185
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join116(this.dreamsDir, basename20(rawPath)) : join116(this.dreamsDir, rawPath);
595059
595186
  if (!targetPath.startsWith(this.dreamsDir)) {
595060
595187
  return { success: false, output: "", error: "Dream mode: writes are confined to .omnius/dreams/", durationMs: Date.now() - start2 };
595061
595188
  }
@@ -595090,7 +595217,7 @@ var init_dream_engine = __esm({
595090
595217
  const rawPath = String(args["path"] ?? "");
595091
595218
  const oldStr = String(args["old_string"] ?? "");
595092
595219
  const newStr = String(args["new_string"] ?? "");
595093
- const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join116(this.dreamsDir, basename19(rawPath)) : join116(this.dreamsDir, rawPath);
595220
+ const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join116(this.dreamsDir, basename20(rawPath)) : join116(this.dreamsDir, rawPath);
595094
595221
  if (!targetPath.startsWith(this.dreamsDir)) {
595095
595222
  return { success: false, output: "", error: "Dream mode: edits are confined to .omnius/dreams/", durationMs: Date.now() - start2 };
595096
595223
  }
@@ -596687,7 +596814,7 @@ var init_bless_engine = __esm({
596687
596814
 
596688
596815
  // packages/cli/src/tui/dmn-engine.ts
596689
596816
  import { existsSync as existsSync102, readFileSync as readFileSync83, writeFileSync as writeFileSync54, mkdirSync as mkdirSync58, readdirSync as readdirSync34, unlinkSync as unlinkSync18 } from "node:fs";
596690
- import { join as join117, basename as basename20 } from "node:path";
596817
+ import { join as join117, basename as basename21 } from "node:path";
596691
596818
  function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
596692
596819
  const competenceReport = competence.length > 0 ? competence.map((c9) => {
596693
596820
  const rate = c9.attempts > 0 ? Math.round(c9.successes / c9.attempts * 100) : 0;
@@ -597438,7 +597565,7 @@ OUTPUT: Call task_complete with JSON:
597438
597565
  try {
597439
597566
  const files = readdirSync34(dir).filter((f2) => f2.endsWith(".json"));
597440
597567
  for (const f2 of files) {
597441
- const topic = basename20(f2, ".json");
597568
+ const topic = basename21(f2, ".json");
597442
597569
  if (!topics.includes(topic)) topics.push(topic);
597443
597570
  }
597444
597571
  } catch {
@@ -597492,7 +597619,7 @@ OUTPUT: Call task_complete with JSON:
597492
597619
 
597493
597620
  // packages/cli/src/tui/snr-engine.ts
597494
597621
  import { existsSync as existsSync103, readdirSync as readdirSync35, readFileSync as readFileSync84 } from "node:fs";
597495
- import { join as join118, basename as basename21 } from "node:path";
597622
+ import { join as join118, basename as basename22 } from "node:path";
597496
597623
  function computeDPrime(signalScores, noiseScores) {
597497
597624
  if (signalScores.length === 0 || noiseScores.length === 0) return 0;
597498
597625
  const mean = (arr) => arr.reduce((s2, v) => s2 + v, 0) / arr.length;
@@ -597786,7 +597913,7 @@ Call task_complete with the JSON array when done.`,
597786
597913
  try {
597787
597914
  const files = readdirSync35(dir).filter((f2) => f2.endsWith(".json"));
597788
597915
  for (const f2 of files) {
597789
- const topic = basename21(f2, ".json");
597916
+ const topic = basename22(f2, ".json");
597790
597917
  if (topics.length > 0 && !topics.includes(topic)) continue;
597791
597918
  try {
597792
597919
  const data = JSON.parse(readFileSync84(join118(dir, f2), "utf-8"));
@@ -598414,8 +598541,8 @@ import {
598414
598541
  } from "node:fs";
598415
598542
  import { mkdir as mkdir17 } from "node:fs/promises";
598416
598543
  import {
598417
- basename as basename22,
598418
- dirname as dirname33,
598544
+ basename as basename23,
598545
+ dirname as dirname34,
598419
598546
  extname as extname14,
598420
598547
  isAbsolute as isAbsolute6,
598421
598548
  join as join119,
@@ -598438,7 +598565,7 @@ function formatTelegramCreativeWorkspacePrompt(root) {
598438
598565
  "Allowed: create and send non-executable creative artifacts in this workspace.",
598439
598566
  "At rest, artifacts are stored as random internal blobs with random header bytes; requested filenames are logical names restored only during Telegram upload.",
598440
598567
  "Forbidden: delete files, create scripts/executables, access paths outside this workspace, mutate the project tree, run shell/Python/code commands, or touch system state.",
598441
- "When a user asks for an artifact to be sent, create it here and then call telegram_send_file. The bridge also auto-attaches recorded artifacts as a fallback. Refer to the attachment naturally; do not expose filesystem paths unless the admin explicitly asks."
598568
+ "Freshly generated/created artifacts are recorded for automatic Telegram attachment when the turn completes. Do not call telegram_send_file for the same fresh artifact unless the user asked for a specific caption, existing/unrecorded file, or non-default target. Refer to the attachment naturally; do not expose filesystem paths unless the admin explicitly asks."
598442
598569
  ].join("\n");
598443
598570
  }
598444
598571
  function publicCreativeArtifactPolicyError(path11) {
@@ -598478,14 +598605,14 @@ function collectGeneratedArtifactPathsFromText(text, root) {
598478
598605
  }
598479
598606
  return [...paths];
598480
598607
  }
598481
- function buildTelegramCreativeTools(repoRoot, chatId, backendUrl, imageDefaults = {}, audioDefaults = {}) {
598608
+ function buildTelegramCreativeTools(repoRoot, chatId, backendUrl2, imageDefaults = {}, audioDefaults = {}) {
598482
598609
  const root = telegramCreativeWorkspaceRoot(repoRoot, chatId);
598483
598610
  ensureManifest(root);
598484
598611
  return [
598485
598612
  scopedTool(new FileWriteTool(root), root, "create"),
598486
598613
  scopedTool(new FileEditTool(root), root, "edit"),
598487
598614
  scopedTool(new StructuredFileTool(root), root, "create"),
598488
- scopedTool(new ImageGenerateTool(root, backendUrl, imageDefaults), root, "generate"),
598615
+ scopedTool(new ImageGenerateTool(root, backendUrl2, imageDefaults), root, "generate"),
598489
598616
  scopedTool(new AudioGenerateTool(root, audioDefaults), root, "generate"),
598490
598617
  scopedTool(new TtsGenerateTool(), root, "generate"),
598491
598618
  new CreativeAudioFileTool(root)
@@ -598536,15 +598663,18 @@ function scopedTool(base3, root, mode) {
598536
598663
  }
598537
598664
  try {
598538
598665
  const result2 = await base3.execute(next);
598666
+ const recordedPaths2 = /* @__PURE__ */ new Set();
598539
598667
  if (result2.success) {
598540
598668
  if (base3.name === "generate_tts" && typeof next["output"] === "string") {
598541
598669
  rememberCreated(rootAbs, String(next["output"]));
598670
+ recordedPaths2.add(resolve38(String(next["output"])));
598542
598671
  }
598543
598672
  for (const path11 of collectGeneratedArtifactPathsFromText(result2.output, rootAbs)) {
598544
598673
  rememberCreated(rootAbs, path11);
598674
+ recordedPaths2.add(resolve38(path11));
598545
598675
  }
598546
598676
  }
598547
- return result2;
598677
+ return withTelegramAutoAttachmentNotice(result2, recordedPaths2.size);
598548
598678
  } finally {
598549
598679
  for (const fn of cleanup) fn();
598550
598680
  }
@@ -598564,7 +598694,7 @@ function scopedTool(base3, root, mode) {
598564
598694
  if (mode === "edit" && !existsSync104(guarded.path.abs)) {
598565
598695
  const materialized = materializeTelegramCreativeArtifactForSend(rootAbs, guarded.path.rel);
598566
598696
  if (!materialized.ok) return denied(materialized.error);
598567
- mkdirSync59(dirname33(guarded.path.abs), { recursive: true });
598697
+ mkdirSync59(dirname34(guarded.path.abs), { recursive: true });
598568
598698
  writeFileSync55(guarded.path.abs, readFileSync85(materialized.path));
598569
598699
  materialized.cleanup?.();
598570
598700
  restoredEditPath = guarded.path.abs;
@@ -598577,9 +598707,13 @@ function scopedTool(base3, root, mode) {
598577
598707
  return denied(`${base3.name} requires a path inside the public creative workspace.`);
598578
598708
  }
598579
598709
  const result = await base3.execute(next);
598710
+ const recordedPaths = /* @__PURE__ */ new Set();
598580
598711
  if (result.success && (mode === "create" || mode === "edit") && pathKey) {
598581
598712
  const guarded = guardPath(rootAbs, String(args[pathKey]));
598582
- if (guarded.ok) rememberCreated(rootAbs, guarded.path.abs);
598713
+ if (guarded.ok) {
598714
+ rememberCreated(rootAbs, guarded.path.abs);
598715
+ recordedPaths.add(resolve38(guarded.path.abs));
598716
+ }
598583
598717
  } else if (restoredEditPath) {
598584
598718
  try {
598585
598719
  unlinkSync19(restoredEditPath);
@@ -598589,12 +598723,23 @@ function scopedTool(base3, root, mode) {
598589
598723
  if (result.success) {
598590
598724
  for (const path11 of collectGeneratedArtifactPathsFromText(result.output, rootAbs)) {
598591
598725
  rememberCreated(rootAbs, path11);
598726
+ recordedPaths.add(resolve38(path11));
598592
598727
  }
598593
598728
  }
598594
- return result;
598729
+ return withTelegramAutoAttachmentNotice(result, recordedPaths.size);
598595
598730
  }
598596
598731
  };
598597
598732
  }
598733
+ function withTelegramAutoAttachmentNotice(result, artifactCount) {
598734
+ if (!result.success || artifactCount <= 0) return result;
598735
+ const notice = artifactCount === 1 ? "Telegram delivery: this artifact is recorded for automatic attachment to the current chat when the turn completes. Do not call telegram_send_file for the same fresh artifact unless a specific caption, existing/unrecorded file, or non-default target is required." : "Telegram delivery: these artifacts are recorded for automatic attachment to the current chat when the turn completes. Do not call telegram_send_file for the same fresh artifacts unless a specific caption, existing/unrecorded file, or non-default target is required.";
598736
+ const output = result.output?.trim() ? `${result.output}
598737
+ ${notice}` : notice;
598738
+ const llmBase = typeof result.llmContent === "string" && result.llmContent.trim() ? result.llmContent : result.output;
598739
+ const llmContent = llmBase?.trim() ? `${llmBase}
598740
+ ${notice}` : notice;
598741
+ return { ...result, output, llmContent };
598742
+ }
598598
598743
  function guardPath(root, rawPath) {
598599
598744
  const rootAbs = resolve38(root);
598600
598745
  const trimmed = rawPath.trim().replace(/^["']|["']$/g, "");
@@ -598613,7 +598758,7 @@ function guardPath(root, rawPath) {
598613
598758
  error: `Path escapes the public creative workspace. Use a relative path under ${rootAbs}.`
598614
598759
  };
598615
598760
  }
598616
- if (basename22(abs) === MANIFEST_FILE) {
598761
+ if (basename23(abs) === MANIFEST_FILE) {
598617
598762
  return { ok: false, error: "The creative workspace manifest is internal and cannot be edited." };
598618
598763
  }
598619
598764
  return { ok: true, path: { abs, rel } };
@@ -598705,7 +598850,7 @@ function rememberCreated(root, absPath) {
598705
598850
  manifest.objects[rel] = {
598706
598851
  logicalRel: rel,
598707
598852
  storedRel,
598708
- originalName: basename22(guarded.path.abs),
598853
+ originalName: basename23(guarded.path.abs),
598709
598854
  prefixBytes: prefix.length,
598710
598855
  encrypted: true,
598711
598856
  key: key.toString("base64"),
@@ -598756,7 +598901,7 @@ function materializeTelegramCreativeArtifactForSend(root, rawPath) {
598756
598901
  }
598757
598902
  const stageDir = join119(rootAbs, SEND_DIR, `${Date.now()}-${randomBytes21(8).toString("hex")}`);
598758
598903
  mkdirSync59(stageDir, { recursive: true });
598759
- const staged = join119(stageDir, object.originalName || basename22(rel));
598904
+ const staged = join119(stageDir, object.originalName || basename23(rel));
598760
598905
  writeFileSync55(staged, payload);
598761
598906
  return {
598762
598907
  ok: true,
@@ -598923,7 +599068,7 @@ var init_telegram_creative_tools = __esm({
598923
599068
  }
598924
599069
  let result;
598925
599070
  try {
598926
- await mkdir17(dirname33(guarded.path.abs), { recursive: true });
599071
+ await mkdir17(dirname34(guarded.path.abs), { recursive: true });
598927
599072
  const tts = new TtsGenerateTool();
598928
599073
  result = await tts.execute({
598929
599074
  text,
@@ -598957,7 +599102,7 @@ ${(result.error || result.output || "").slice(0, 1200)}`,
598957
599102
  }
598958
599103
  rememberCreated(this.root, guarded.path.abs);
598959
599104
  const sizeKB = Math.round(statSync35(guarded.path.abs).size / 1024);
598960
- return {
599105
+ return withTelegramAutoAttachmentNotice({
598961
599106
  success: true,
598962
599107
  output: `Created audio file: ${guarded.path.abs} (${sizeKB}KB WAV)
598963
599108
  ${result.output}`,
@@ -598965,7 +599110,7 @@ ${result.output}`,
598965
599110
  durationMs: performance.now() - start2,
598966
599111
  mutated: true,
598967
599112
  mutatedFiles: [guarded.path.rel]
598968
- };
599113
+ }, 1);
598969
599114
  }
598970
599115
  };
598971
599116
  }
@@ -599302,7 +599447,7 @@ var init_vision_ingress = __esm({
599302
599447
 
599303
599448
  // packages/cli/src/tui/telegram-bridge.ts
599304
599449
  import { mkdirSync as mkdirSync60, existsSync as existsSync106, unlinkSync as unlinkSync21, readdirSync as readdirSync36, statSync as statSync36, statfsSync as statfsSync3, readFileSync as readFileSync87, writeFileSync as writeFileSync57 } from "node:fs";
599305
- import { join as join121, resolve as resolve39, basename as basename23, relative as relative13, isAbsolute as isAbsolute7, extname as extname15 } from "node:path";
599450
+ import { join as join121, resolve as resolve39, basename as basename24, relative as relative13, isAbsolute as isAbsolute7, extname as extname15 } from "node:path";
599306
599451
  import { writeFile as writeFileAsync } from "node:fs/promises";
599307
599452
  import { createHash as createHash19, randomInt } from "node:crypto";
599308
599453
  function parseTelegramInteractionDecision(text, forcedRoute, options2 = {}) {
@@ -600862,7 +601007,7 @@ Telegram response contract:
600862
601007
  }
600863
601008
  const matchingEntry = mediaEntries.find((entry) => {
600864
601009
  if (resolve39(entry.localPath) === resolve39(raw)) return true;
600865
- if (basename23(entry.localPath) === raw) return true;
601010
+ if (basename24(entry.localPath) === raw) return true;
600866
601011
  if (entry.fileUniqueId === raw || entry.fileId === raw) return true;
600867
601012
  if (entry.messageId && String(entry.messageId) === raw) return true;
600868
601013
  return false;
@@ -601069,7 +601214,7 @@ ${cardLines.join("\n")}`);
601069
601214
  const caption = entry.caption ? ` caption:${truncateTelegramContextLine(entry.caption, 120)}` : "";
601070
601215
  const extracted = entry.extractedContent ? `
601071
601216
  ${truncateTelegramContextLine(entry.extractedContent.replace(/\s+/g, " "), 220)}` : "";
601072
- return `- message_id ${entry.messageId}${replyMark}: ${kind}; path ${entry.localPath}; file ${basename23(entry.localPath)}${caption}${extracted}`;
601217
+ return `- message_id ${entry.messageId}${replyMark}: ${kind}; path ${entry.localPath}; file ${basename24(entry.localPath)}${caption}${extracted}`;
601073
601218
  });
601074
601219
  sections.push([
601075
601220
  "### Recent Chat Media",
@@ -601376,7 +601521,7 @@ Checklist unavailable: ${reason}`;
601376
601521
  const list = this.formatTelegramSendTargetList(targets, 18);
601377
601522
  return [
601378
601523
  "## Telegram Send Targets",
601379
- "telegram_send_file is the only supported way to send generated/existing files to Telegram. Never look for or reveal the bot token; the bridge already owns upload auth.",
601524
+ "telegram_send_file is the only supported way to manually send generated or existing files to Telegram. Never look for or reveal the bot token; the bridge already owns upload auth.",
601380
601525
  "Use target with one of these known chat ids when the admin asks to send a file to a group/private chat:",
601381
601526
  list || "- No known prior Telegram chats are loaded yet. Numeric chat_id or @username can still be used if the admin provides one."
601382
601527
  ].join("\n");
@@ -601386,7 +601531,7 @@ Checklist unavailable: ${reason}`;
601386
601531
  const list = this.formatTelegramSendTargetList(targets, 10);
601387
601532
  return [
601388
601533
  "## Telegram Send Targets",
601389
- "This private user may send generated files to this DM or to shared public groups where this sender has been observed by the bot. Public groups can never target private DMs.",
601534
+ "Freshly generated artifacts are queued for automatic delivery to this DM at turn completion. Use telegram_send_file only for an existing/unrecorded workspace file, a specific caption, or an explicit shared-group target. Public groups can never target private DMs.",
601390
601535
  list ? `Allowed shared group targets:
601391
601536
  ${list}` : "No shared group target is currently known for this sender. Ask in the group once or provide a numeric group chat_id the bot already participates in."
601392
601537
  ].join("\n");
@@ -601877,6 +602022,7 @@ ${mediaContext}`;
601877
602022
  pendingMessages: [],
601878
602023
  creativeWorkspaceRoot: this.creativeWorkspaceRootForMessage(msg, toolContext),
601879
602024
  generatedArtifacts: [],
602025
+ deliveredArtifacts: [],
601880
602026
  surfacedToolCallFingerprints: /* @__PURE__ */ new Set()
601881
602027
  };
601882
602028
  this.subAgents.set(sessionKey, subAgent);
@@ -601978,6 +602124,7 @@ ${mediaContext}`;
601978
602124
  pendingMessages: [],
601979
602125
  creativeWorkspaceRoot: this.creativeWorkspaceRootForMessage(msg, toolContext),
601980
602126
  generatedArtifacts: [],
602127
+ deliveredArtifacts: [],
601981
602128
  surfacedToolCallFingerprints: /* @__PURE__ */ new Set()
601982
602129
  };
601983
602130
  this.subAgents.set(sessionKey, subAgent);
@@ -602436,7 +602583,7 @@ ${msg.text}`;
602436
602583
  "memory_search may use scope=group/current_chat for this group or scope=user with user_id/username for a participant in this same group. Other groups, admin chats, and private DMs are not accessible here.",
602437
602584
  "You can remember facts about users and retrieve them later. You also have web_search and web_fetch to look up information.",
602438
602585
  reminderToolContract,
602439
- "If the user asks you to create or send a file, image, or audio artifact, create it with the scoped creative tools and call telegram_send_file to upload it. The bridge still auto-attaches generated files as a fallback when tool results record them.",
602586
+ "If the user asks you to create an image, audio file, or document artifact, create it with the scoped creative tools. Freshly generated artifacts are recorded and automatically attached to this Telegram chat when the turn completes, so do not call telegram_send_file for those same artifacts unless the user asked for a specific caption, existing/unrecorded file, or non-default target.",
602440
602587
  "For image generation requests, decide from the conversation whether generate_image is appropriate; do not ask the user to use a hardcoded shortcut when the request is clear.",
602441
602588
  creativeWorkspace
602442
602589
  ].filter(Boolean).join("\n\n");
@@ -603041,7 +603188,7 @@ Scoped workspace: ${scopedRoot}`,
603041
603188
  `${index + 1}. message_id ${entry.messageId || "unknown"}`,
603042
603189
  currentMsg?.replyToMessageId === entry.messageId ? "replied-to" : "",
603043
603190
  telegramCachedMediaIsImage(entry) ? "image" : telegramCachedMediaIsPdf(entry) ? "pdf" : telegramCachedMediaIsAudio(entry) ? "audio" : telegramCachedMediaIsVideo(entry) ? "video" : entry.mediaType,
603044
- `file=${basename23(entry.localPath)}`,
603191
+ `file=${basename24(entry.localPath)}`,
603045
603192
  `path=${entry.localPath}`,
603046
603193
  entry.caption ? `caption=${truncateTelegramContextLine(entry.caption, 140)}` : ""
603047
603194
  ].filter(Boolean);
@@ -603083,7 +603230,7 @@ Scoped workspace: ${scopedRoot}`,
603083
603230
  const scopedRoot = adminDm ? void 0 : telegramCreativeWorkspaceRoot(repoRoot, currentChatId);
603084
603231
  return {
603085
603232
  name: "telegram_send_file",
603086
- description: adminDm ? "Upload an existing local file to a Telegram target. Use target=<chat_id|user_id|@username> to send to a specific group/user the bot can message. This only sends the file; it does not create, edit, delete, or inspect bot tokens." : currentMsg?.chatType === "private" ? `Upload an existing file from this private chat's scoped creative workspace. target may be omitted for this DM or set to a known shared group chat_id for this sender. It cannot target other private users and cannot send files outside ${scopedRoot}.` : `Upload an existing file from this chat's scoped creative workspace to the current Telegram chat. Public/group scope cannot target private DMs or other chats and cannot send files outside ${scopedRoot}.`,
603233
+ description: adminDm ? "Upload an existing local file to a Telegram target. Use target=<chat_id|user_id|@username> to send to a specific group/user the bot can message. This only sends the file; it does not create, edit, delete, or inspect bot tokens." : currentMsg?.chatType === "private" ? `Upload an existing/unrecorded file from this private chat's scoped creative workspace, or send a generated artifact with a specific caption/target. Fresh generated artifacts are already queued for this DM at turn completion. target may be omitted for this DM or set to a known shared group chat_id for this sender. It cannot target other private users and cannot send files outside ${scopedRoot}.` : `Upload an existing/unrecorded file from this chat's scoped creative workspace, or send a generated artifact with a specific caption. Fresh generated artifacts are already queued for this chat at turn completion. Public/group scope cannot target private DMs or other chats and cannot send files outside ${scopedRoot}.`,
603087
603234
  parameters: {
603088
603235
  type: "object",
603089
603236
  properties: {
@@ -603150,10 +603297,11 @@ Scoped workspace: ${scopedRoot}`,
603150
603297
  caption: caption || void 0,
603151
603298
  replyToMessageId: Number.isFinite(replyTo) && replyTo > 0 ? Math.floor(replyTo) : void 0
603152
603299
  });
603300
+ bridge.rememberTelegramDeliveredArtifactForMessage(currentMsg, file.logicalPath ?? file.path);
603153
603301
  return {
603154
603302
  success: true,
603155
- output: `Sent Telegram file: ${basename23(file.path)} as ${kind} to ${String(target.chatId)}${messageId ? ` (message_id ${messageId})` : ""}`,
603156
- llmContent: `Sent ${basename23(file.path)} to Telegram as ${kind}.`,
603303
+ output: `Sent Telegram file: ${basename24(file.path)} as ${kind} to ${String(target.chatId)}${messageId ? ` (message_id ${messageId})` : ""}`,
603304
+ llmContent: `Sent ${basename24(file.path)} to Telegram as ${kind}.`,
603157
603305
  durationMs: performance.now() - start2,
603158
603306
  mutated: false,
603159
603307
  mutatedFiles: []
@@ -603221,15 +603369,32 @@ ${knownList}` : "Private-user telegram_send_file target must be this DM or a kno
603221
603369
  const base3 = scopedRoot ? resolve39(scopedRoot) : resolve39(repoRoot);
603222
603370
  const trimmed = rawPath.trim().replace(/^["']|["']$/g, "");
603223
603371
  if (scopedRoot) {
603372
+ const logicalPath = isAbsolute7(trimmed) ? resolve39(trimmed) : resolve39(base3, trimmed);
603373
+ if (!isPathInside(base3, logicalPath)) {
603374
+ return { ok: false, error: `Path escapes the scoped Telegram creative workspace: ${trimmed}` };
603375
+ }
603224
603376
  const materialized = materializeTelegramCreativeArtifactForSend(base3, trimmed);
603225
603377
  if (!materialized.ok) return materialized;
603226
- return materialized;
603378
+ return { ...materialized, logicalPath };
603227
603379
  }
603228
603380
  const abs = isAbsolute7(trimmed) ? resolve39(trimmed) : resolve39(base3, trimmed);
603229
603381
  if (!existsSync106(abs)) return { ok: false, error: `File does not exist: ${trimmed}` };
603230
603382
  if (!statSync36(abs).isFile()) return { ok: false, error: `Path is not a file: ${trimmed}` };
603231
603383
  return { ok: true, path: abs };
603232
603384
  }
603385
+ rememberTelegramDeliveredArtifact(subAgent, path11) {
603386
+ const abs = resolve39(path11);
603387
+ subAgent.deliveredArtifacts ??= [];
603388
+ if (!subAgent.deliveredArtifacts.some((existing) => resolve39(existing) === abs)) {
603389
+ subAgent.deliveredArtifacts.push(abs);
603390
+ }
603391
+ }
603392
+ rememberTelegramDeliveredArtifactForMessage(msg, path11) {
603393
+ if (!msg || !path11) return;
603394
+ const subAgent = this.subAgents.get(this.sessionKeyForMessage(msg));
603395
+ if (!subAgent) return;
603396
+ this.rememberTelegramDeliveredArtifact(subAgent, path11);
603397
+ }
603233
603398
  /** Check if a message is from the admin user (uses fromUserId, NOT chatId) */
603234
603399
  isAdminUser(msg) {
603235
603400
  if (!this.adminUserId) return false;
@@ -603517,7 +603682,7 @@ ${text}`.trim());
603517
603682
  if (!existsSync106(media.value)) throw new Error(`File does not exist: ${media.value}`);
603518
603683
  const buffer2 = readFileSync87(media.value);
603519
603684
  const boundary = `----omnius-media-${Date.now()}-${Math.random().toString(36).slice(2)}`;
603520
- const filename = basename23(media.value);
603685
+ const filename = basename24(media.value);
603521
603686
  const contentType = mimeForPath(media.value, media.kind);
603522
603687
  const parts = [];
603523
603688
  const addField = (name10, value2) => {
@@ -603572,9 +603737,11 @@ Content-Type: ${contentType}\r
603572
603737
  const alreadySentByText = new Set(
603573
603738
  extractMediaReferences(finalText).media.filter((media) => media.source === "file").map((media) => resolve39(media.value))
603574
603739
  );
603740
+ const alreadyDelivered = new Set((subAgent.deliveredArtifacts ?? []).map((path11) => resolve39(path11)));
603575
603741
  for (const path11 of paths) {
603576
603742
  const abs = resolve39(path11);
603577
603743
  if (!isPathInside(rootAbs, abs)) continue;
603744
+ if (alreadyDelivered.has(abs)) continue;
603578
603745
  if (!includeMentioned && alreadySentByText.has(abs)) continue;
603579
603746
  const materialized = materializeTelegramCreativeArtifactForSend(rootAbs, abs);
603580
603747
  if (!materialized.ok) continue;
@@ -603589,6 +603756,11 @@ Content-Type: ${contentType}\r
603589
603756
  kind,
603590
603757
  source: "file",
603591
603758
  audioAsVoice: kind === "voice"
603759
+ }).then((messageId) => {
603760
+ if (messageId !== null) {
603761
+ this.rememberTelegramDeliveredArtifact(subAgent, abs);
603762
+ alreadyDelivered.add(abs);
603763
+ }
603592
603764
  }).catch(() => null).finally(() => {
603593
603765
  materialized.cleanup?.();
603594
603766
  });
@@ -603615,7 +603787,7 @@ Content-Type: ${contentType}\r
603615
603787
  continue;
603616
603788
  }
603617
603789
  const buffer2 = readFileSync87(pathOrFileId);
603618
- const filename = basename23(pathOrFileId);
603790
+ const filename = basename24(pathOrFileId);
603619
603791
  parts.push(Buffer.from(`--${boundary}\r
603620
603792
  `));
603621
603793
  parts.push(Buffer.from(
@@ -604679,7 +604851,7 @@ __export(projects_exports, {
604679
604851
  });
604680
604852
  import { readFileSync as readFileSync89, writeFileSync as writeFileSync59, mkdirSync as mkdirSync62, existsSync as existsSync108, statSync as statSync37, renameSync as renameSync6 } from "node:fs";
604681
604853
  import { homedir as homedir37 } from "node:os";
604682
- import { basename as basename24, join as join123, resolve as resolve40 } from "node:path";
604854
+ import { basename as basename25, join as join123, resolve as resolve40 } from "node:path";
604683
604855
  import { randomUUID as randomUUID14 } from "node:crypto";
604684
604856
  function readAll2() {
604685
604857
  try {
@@ -604727,7 +604899,7 @@ function registerProject(root, pid) {
604727
604899
  } else {
604728
604900
  entry = {
604729
604901
  root: canonical,
604730
- name: basename24(canonical) || canonical,
604902
+ name: basename25(canonical) || canonical,
604731
604903
  firstSeen: now,
604732
604904
  lastSeen: now,
604733
604905
  pid: pid ?? null,
@@ -606556,7 +606728,7 @@ var init_audit_log = __esm({
606556
606728
  // packages/cli/src/api/disk-task-output.ts
606557
606729
  import { open } from "node:fs/promises";
606558
606730
  import { existsSync as existsSync111, mkdirSync as mkdirSync65, statSync as statSync38 } from "node:fs";
606559
- import { dirname as dirname35 } from "node:path";
606731
+ import { dirname as dirname36 } from "node:path";
606560
606732
  import * as fsConstants from "node:constants";
606561
606733
  var O_NOFOLLOW2, O_APPEND2, O_CREAT2, O_WRONLY2, OPEN_FLAGS_WRITE, OPEN_MODE, DiskTaskOutput;
606562
606734
  var init_disk_task_output = __esm({
@@ -606575,7 +606747,7 @@ var init_disk_task_output = __esm({
606575
606747
  fileSize = 0;
606576
606748
  constructor(outputPath2) {
606577
606749
  this.path = outputPath2;
606578
- mkdirSync65(dirname35(outputPath2), { recursive: true });
606750
+ mkdirSync65(dirname36(outputPath2), { recursive: true });
606579
606751
  }
606580
606752
  /** Queue content for async append. Non-blocking. */
606581
606753
  append(chunk) {
@@ -609221,6 +609393,14 @@ function _readStatusFile(p2) {
609221
609393
  try {
609222
609394
  const data = JSON.parse(readFileSync95(p2, "utf-8"));
609223
609395
  if (data?.connected && typeof data.peerId === "string" && data.peerId.length > 10) {
609396
+ const pid = Number(data.pid);
609397
+ if (pid > 0) {
609398
+ try {
609399
+ process.kill(pid, 0);
609400
+ } catch {
609401
+ return null;
609402
+ }
609403
+ }
609224
609404
  return {
609225
609405
  peerId: data.peerId,
609226
609406
  agentName: typeof data.agentName === "string" ? data.agentName : null,
@@ -609237,6 +609417,20 @@ function resolveLocalPeerId() {
609237
609417
  const r2 = _readStatusFile(join130(override, "status.json"));
609238
609418
  if (r2) return r2;
609239
609419
  }
609420
+ const scope = (process.env["OMNIUS_NEXUS_SCOPE"] || "").toLowerCase();
609421
+ const projectScopeFlag = (process.env["OMNIUS_NEXUS_PROJECT_SCOPE"] || "").toLowerCase();
609422
+ const projectScoped = scope === "project" || scope === "local" || projectScopeFlag === "1" || projectScopeFlag === "true" || projectScopeFlag === "yes";
609423
+ const candidates = projectScoped ? [
609424
+ join130(process.cwd(), ".omnius", "nexus", "status.json"),
609425
+ join130(homedir42(), ".omnius", "nexus", "status.json")
609426
+ ] : [
609427
+ join130(homedir42(), ".omnius", "nexus", "status.json"),
609428
+ join130(process.cwd(), ".omnius", "nexus", "status.json")
609429
+ ];
609430
+ for (const p2 of candidates) {
609431
+ const r2 = _readStatusFile(p2);
609432
+ if (r2) return r2;
609433
+ }
609240
609434
  try {
609241
609435
  const regPath = join130(homedir42(), ".omnius", "nexus-registry.json");
609242
609436
  if (existsSync116(regPath)) {
@@ -609252,15 +609446,6 @@ function resolveLocalPeerId() {
609252
609446
  }
609253
609447
  } catch {
609254
609448
  }
609255
- const candidates = [
609256
- join130(process.cwd(), ".omnius", "nexus", "status.json"),
609257
- join130(homedir42(), ".omnius", "nexus", "status.json"),
609258
- join130(homedir42(), ".omnius", "nexus", "status.json")
609259
- ];
609260
- for (const p2 of candidates) {
609261
- const r2 = _readStatusFile(p2);
609262
- if (r2) return r2;
609263
- }
609264
609449
  const now = Date.now();
609265
609450
  if (_peerIdScanCache && now - _peerIdScanCache.ts < 6e4) {
609266
609451
  return _peerIdScanCache.result;
@@ -609571,10 +609756,14 @@ async function handleRemoteProxy(ctx3) {
609571
609756
  }));
609572
609757
  return true;
609573
609758
  }
609574
- const nexusCandidates = [
609759
+ const tunnelScope = (process.env["OMNIUS_NEXUS_SCOPE"] || "").toLowerCase();
609760
+ const tunnelProjectScope = tunnelScope === "project" || tunnelScope === "local" || ["1", "true", "yes"].includes((process.env["OMNIUS_NEXUS_PROJECT_SCOPE"] || "").toLowerCase());
609761
+ const nexusCandidates = tunnelProjectScope ? [
609575
609762
  join130(process.cwd(), ".omnius", "nexus"),
609576
- join130(homedir42(), ".omnius", "nexus"),
609577
609763
  join130(homedir42(), ".omnius", "nexus")
609764
+ ] : [
609765
+ join130(homedir42(), ".omnius", "nexus"),
609766
+ join130(process.cwd(), ".omnius", "nexus")
609578
609767
  ];
609579
609768
  let nexusDirPath = null;
609580
609769
  for (const p2 of nexusCandidates) {
@@ -609713,14 +609902,14 @@ data: ${JSON.stringify({ error: err instanceof Error ? err.message : String(err)
609713
609902
  while (!stopped) {
609714
609903
  try {
609715
609904
  if (_exists(streamFile)) {
609716
- const stat5 = (await import("node:fs")).statSync(streamFile);
609717
- if (stat5.size > lastSize) {
609905
+ const stat6 = (await import("node:fs")).statSync(streamFile);
609906
+ if (stat6.size > lastSize) {
609718
609907
  const fd = (await import("node:fs")).openSync(streamFile, "r");
609719
- const len = stat5.size - lastSize;
609908
+ const len = stat6.size - lastSize;
609720
609909
  const buf = Buffer.alloc(len);
609721
609910
  (await import("node:fs")).readSync(fd, buf, 0, len, lastSize);
609722
609911
  (await import("node:fs")).closeSync(fd);
609723
- lastSize = stat5.size;
609912
+ lastSize = stat6.size;
609724
609913
  const txt = leftover + buf.toString("utf-8");
609725
609914
  const parts = txt.split("\n");
609726
609915
  leftover = parts.pop() ?? "";
@@ -612423,22 +612612,13 @@ body { display:flex; flex-direction:column; height:100vh; margin:0; overflow:hid
612423
612612
  <div style="margin-bottom:18px">
612424
612613
  <div style="color:var(--color-brand);font-size:0.85rem;margin-bottom:4px">voice model</div>
612425
612614
  <div style="display:flex;gap:8px;align-items:center">
612426
- <select id="voice-model-select" style="background:var(--color-bg);border:1px solid var(--color-border);color:var(--color-fg);padding:5px 10px;border-radius:3px;font-family:inherit;font-size:0.7rem;flex:1"></select>
612615
+ <select id="voice-model-select" onchange="renderVoiceModelOptions()" style="background:var(--color-bg);border:1px solid var(--color-border);color:var(--color-fg);padding:5px 10px;border-radius:3px;font-family:inherit;font-size:0.7rem;flex:1"></select>
612427
612616
  <button onclick="switchVoiceModel()" style="background:var(--color-bg-input);border:1px solid var(--color-border);color:var(--color-brand);padding:5px 12px;border-radius:3px;font-family:inherit;font-size:0.7rem;cursor:pointer">switch</button>
612428
612617
  </div>
612429
612618
  </div>
612430
612619
 
612431
- <div style="margin-bottom:18px">
612432
- <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">
612433
- <div style="color:var(--color-brand);font-size:0.85rem">voice clone references</div>
612434
- <button onclick="document.getElementById('clone-upload-input').click()" style="background:var(--color-bg-input);border:1px solid var(--color-border);color:var(--color-brand);padding:4px 10px;border-radius:3px;font-family:inherit;font-size:0.65rem;cursor:pointer">+ upload</button>
612435
- <input type="file" id="clone-upload-input" accept="audio/wav,audio/mp3,audio/mpeg,audio/ogg,audio/flac,audio/m4a,audio/aac,audio/opus,.wav,.mp3,.ogg,.flac,.m4a,.aac,.opus" style="display:none" onchange="uploadCloneRef(this.files)">
612436
- </div>
612437
- <div style="font-size:0.6rem;color:var(--color-fg-subtle);margin-bottom:8px">
612438
- LuxTTS clones a voice from a 3+ second reference clip. Upload a clean WAV/MP3 sample,
612439
- then activate it. Active reference is used whenever the LuxTTS voice model is selected.
612440
- </div>
612441
- <div id="clone-refs-list" style="font-size:0.7rem"></div>
612620
+ <div id="voice-model-options-panel" style="margin-bottom:18px">
612621
+ <div id="voice-model-options-content" style="font-size:0.7rem;color:var(--color-fg-muted)"></div>
612442
612622
  </div>
612443
612623
 
612444
612624
  <div style="margin-bottom:18px">
@@ -617298,11 +617478,12 @@ let _voiceMicStream = null;
617298
617478
  let _voiceMicNode = null;
617299
617479
  let _voicePlayingTts = false;
617300
617480
  let _voicePendingTtsHeader = null;
617481
+ let _voiceModels = [];
617301
617482
 
617302
- function loadVoiceTab() {
617303
- refreshVoiceState();
617304
- loadVoiceModels();
617305
- loadCloneRefs();
617483
+ async function loadVoiceTab() {
617484
+ await refreshVoiceState();
617485
+ await loadVoiceModels();
617486
+ renderVoiceModelOptions();
617306
617487
  }
617307
617488
 
617308
617489
  async function refreshVoiceState() {
@@ -617328,11 +617509,14 @@ async function loadVoiceModels() {
617328
617509
  const r = await fetch('/v1/voice/models', { headers: headers() });
617329
617510
  if (!r.ok) { sel.innerHTML = '<option>(failed)</option>'; return; }
617330
617511
  const data = await r.json();
617512
+ _voiceModels = data.models || [];
617331
617513
  const current = $voiceState.get()?.voiceModelId;
617332
- sel.innerHTML = (data.models || []).map(m =>
617514
+ sel.innerHTML = _voiceModels.map(m =>
617333
617515
  '<option value="' + m.id + '"' + (m.id === current ? ' selected' : '') + '>' +
617334
617516
  escHtml(m.label) + ' (' + escHtml(m.backend) + ')</option>'
617335
617517
  ).join('');
617518
+ if (current && !_voiceModels.some(m => m.id === current) && _voiceModels.length) sel.value = _voiceModels[0].id;
617519
+ renderVoiceModelOptions();
617336
617520
  } catch (e) { sel.innerHTML = '<option>error</option>'; }
617337
617521
  }
617338
617522
 
@@ -617347,12 +617531,143 @@ async function switchVoiceModel() {
617347
617531
  });
617348
617532
  const data = await r.json();
617349
617533
  if (!r.ok) { alert('Switch failed: ' + (data.message || data.error)); return; }
617350
- refreshVoiceState();
617351
- loadCloneRefs();
617534
+ await refreshVoiceState();
617535
+ await loadVoiceModels();
617536
+ renderVoiceModelOptions();
617352
617537
  } catch (e) { alert('Switch failed: ' + e.message); }
617353
617538
  }
617354
617539
  window.switchVoiceModel = switchVoiceModel;
617355
617540
 
617541
+ function selectedVoiceModel() {
617542
+ const sel = document.getElementById('voice-model-select');
617543
+ const id = sel?.value || $voiceState.get()?.voiceModelId || '';
617544
+ return _voiceModels.find(m => m.id === id) || null;
617545
+ }
617546
+
617547
+ function renderVoiceModelOptions() {
617548
+ const host = document.getElementById('voice-model-options-content');
617549
+ if (!host) return;
617550
+ const model = selectedVoiceModel();
617551
+ if (!model) {
617552
+ host.innerHTML = '<div style="color:var(--color-fg-subtle);padding:12px;border:1px dashed var(--color-border);border-radius:4px">No voice model selected.</div>';
617553
+ return;
617554
+ }
617555
+ if (model.backend === 'luxtts') {
617556
+ host.innerHTML =
617557
+ '<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">' +
617558
+ '<div style="color:var(--color-brand);font-size:0.85rem">voice clone references</div>' +
617559
+ '<button onclick="document.getElementById(\\'clone-upload-input\\').click()" style="background:var(--color-bg-input);border:1px solid var(--color-border);color:var(--color-brand);padding:4px 10px;border-radius:3px;font-family:inherit;font-size:0.65rem;cursor:pointer">+ upload</button>' +
617560
+ '<input type="file" id="clone-upload-input" accept="audio/wav,audio/mp3,audio/mpeg,audio/ogg,audio/flac,audio/m4a,audio/aac,audio/opus,.wav,.mp3,.ogg,.flac,.m4a,.aac,.opus" style="display:none" onchange="uploadCloneRef(this.files)">' +
617561
+ '</div>' +
617562
+ '<div style="font-size:0.6rem;color:var(--color-fg-subtle);margin-bottom:8px">LuxTTS uses the active reference when this voice model is selected.</div>' +
617563
+ '<div id="clone-refs-list" style="font-size:0.7rem"></div>';
617564
+ loadCloneRefs();
617565
+ return;
617566
+ }
617567
+ if (model.backend === 'supertonic') {
617568
+ host.innerHTML =
617569
+ '<div style="color:var(--color-brand);font-size:0.85rem;margin-bottom:8px">Supertonic3 voice settings</div>' +
617570
+ '<div id="supertonic-settings-host" style="font-size:0.7rem;color:var(--color-fg-subtle)">loading...</div>';
617571
+ loadSupertonicSettings();
617572
+ return;
617573
+ }
617574
+ if (model.backend === 'mlx') {
617575
+ renderMlxVoiceOptions(host, model);
617576
+ return;
617577
+ }
617578
+ host.innerHTML =
617579
+ '<div style="color:var(--color-brand);font-size:0.85rem;margin-bottom:8px">Piper ONNX voice</div>' +
617580
+ '<div style="background:var(--color-bg);border-left:2px solid var(--color-border);padding:8px 12px">' +
617581
+ '<div style="color:var(--color-fg)">' + escHtml(model.label) + '</div>' +
617582
+ '<div style="color:var(--color-fg-subtle);font-size:0.6rem;margin-top:2px">No secondary model controls for this backend.</div>' +
617583
+ '</div>';
617584
+ }
617585
+ window.renderVoiceModelOptions = renderVoiceModelOptions;
617586
+
617587
+ function renderMlxVoiceOptions(host, model) {
617588
+ const variants = _voiceModels.filter(m => m.backend === 'mlx' && (m.modelId || '') === (model.modelId || ''));
617589
+ const options = variants.map(m =>
617590
+ '<option value="' + escAttr(m.id) + '"' + (m.id === model.id ? ' selected' : '') + '>' +
617591
+ escHtml(m.label) + (m.voice ? ' - ' + escHtml(m.voice) : '') + '</option>'
617592
+ ).join('');
617593
+ host.innerHTML =
617594
+ '<div style="color:var(--color-brand);font-size:0.85rem;margin-bottom:8px">MLX voice variant</div>' +
617595
+ '<div style="display:flex;gap:8px;align-items:center;margin-bottom:8px">' +
617596
+ '<select id="mlx-voice-variant-select" style="background:var(--color-bg);border:1px solid var(--color-border);color:var(--color-fg);padding:5px 10px;border-radius:3px;font-family:inherit;font-size:0.7rem;flex:1">' + options + '</select>' +
617597
+ '<button onclick="switchMlxVoiceVariant()" style="background:var(--color-bg-input);border:1px solid var(--color-border);color:var(--color-brand);padding:5px 12px;border-radius:3px;font-family:inherit;font-size:0.7rem;cursor:pointer">switch</button>' +
617598
+ '</div>' +
617599
+ '<div style="background:var(--color-bg);border-left:2px solid var(--color-border);padding:8px 12px;color:var(--color-fg-subtle);font-size:0.6rem">' +
617600
+ escHtml(model.modelId || 'mlx-audio') + (model.lang ? ' / lang ' + escHtml(model.lang) : '') +
617601
+ '</div>';
617602
+ }
617603
+
617604
+ function switchMlxVoiceVariant() {
617605
+ const variant = document.getElementById('mlx-voice-variant-select');
617606
+ const top = document.getElementById('voice-model-select');
617607
+ if (!variant || !top || !variant.value) return;
617608
+ top.value = variant.value;
617609
+ switchVoiceModel();
617610
+ }
617611
+ window.switchMlxVoiceVariant = switchMlxVoiceVariant;
617612
+
617613
+ async function loadSupertonicSettings() {
617614
+ const host = document.getElementById('supertonic-settings-host');
617615
+ if (!host) return;
617616
+ try {
617617
+ const r = await fetch('/v1/voice/supertonic-settings', { headers: headers() });
617618
+ if (!r.ok) { host.innerHTML = '<div style="color:var(--color-error)">failed to load Supertonic settings</div>'; return; }
617619
+ const data = await r.json();
617620
+ renderSupertonicSettingsForm(data.settings || {}, data.options || {});
617621
+ } catch (e) {
617622
+ host.innerHTML = '<div style="color:var(--color-error)">failed: ' + escHtml(e?.message || e) + '</div>';
617623
+ }
617624
+ }
617625
+
617626
+ function renderSupertonicSettingsForm(settings, options) {
617627
+ const host = document.getElementById('supertonic-settings-host');
617628
+ if (!host) return;
617629
+ const voices = options.voices || ['M4'];
617630
+ const langs = options.langs || ['en'];
617631
+ const expressions = options.expressions || ['auto', 'none', 'laugh', 'breath', 'sigh'];
617632
+ const speed = options.speed || { min: 0.7, max: 1.8, step: 0.05 };
617633
+ const totalStep = options.totalStep || { min: 4, max: 16, step: 1 };
617634
+ host.innerHTML =
617635
+ '<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin-bottom:8px">' +
617636
+ '<label style="display:flex;flex-direction:column;gap:4px;color:var(--color-fg-subtle);font-size:0.6rem">voice style' +
617637
+ '<select id="supertonic-voice-name" style="background:var(--color-bg);border:1px solid var(--color-border);color:var(--color-fg);padding:5px 8px;border-radius:3px;font-family:inherit;font-size:0.7rem">' + voices.map(v => '<option value="' + escAttr(v) + '"' + (v === settings.voiceName ? ' selected' : '') + '>' + escHtml(v) + '</option>').join('') + '</select></label>' +
617638
+ '<label style="display:flex;flex-direction:column;gap:4px;color:var(--color-fg-subtle);font-size:0.6rem">language' +
617639
+ '<select id="supertonic-lang" style="background:var(--color-bg);border:1px solid var(--color-border);color:var(--color-fg);padding:5px 8px;border-radius:3px;font-family:inherit;font-size:0.7rem">' + langs.map(v => '<option value="' + escAttr(v) + '"' + (v === settings.lang ? ' selected' : '') + '>' + escHtml(v) + '</option>').join('') + '</select></label>' +
617640
+ '<label style="display:flex;flex-direction:column;gap:4px;color:var(--color-fg-subtle);font-size:0.6rem">expression' +
617641
+ '<select id="supertonic-expression" style="background:var(--color-bg);border:1px solid var(--color-border);color:var(--color-fg);padding:5px 8px;border-radius:3px;font-family:inherit;font-size:0.7rem">' + expressions.map(v => '<option value="' + escAttr(v) + '"' + (v === settings.expression ? ' selected' : '') + '>' + escHtml(v) + '</option>').join('') + '</select></label>' +
617642
+ '<label style="display:flex;flex-direction:column;gap:4px;color:var(--color-fg-subtle);font-size:0.6rem">speed' +
617643
+ '<input id="supertonic-speed" type="number" min="' + speed.min + '" max="' + speed.max + '" step="' + speed.step + '" value="' + escAttr(settings.speed ?? 1.05) + '" style="background:var(--color-bg);border:1px solid var(--color-border);color:var(--color-fg);padding:5px 8px;border-radius:3px;font-family:inherit;font-size:0.7rem"></label>' +
617644
+ '<label style="display:flex;flex-direction:column;gap:4px;color:var(--color-fg-subtle);font-size:0.6rem">steps' +
617645
+ '<input id="supertonic-total-step" type="number" min="' + totalStep.min + '" max="' + totalStep.max + '" step="' + totalStep.step + '" value="' + escAttr(settings.totalStep ?? 8) + '" style="background:var(--color-bg);border:1px solid var(--color-border);color:var(--color-fg);padding:5px 8px;border-radius:3px;font-family:inherit;font-size:0.7rem"></label>' +
617646
+ '</div>' +
617647
+ '<button onclick="saveSupertonicSettings()" style="background:var(--color-bg-input);border:1px solid var(--color-border);color:var(--color-brand);padding:5px 12px;border-radius:3px;font-family:inherit;font-size:0.7rem;cursor:pointer">apply</button>';
617648
+ }
617649
+
617650
+ async function saveSupertonicSettings() {
617651
+ const body = {
617652
+ voiceName: document.getElementById('supertonic-voice-name')?.value,
617653
+ lang: document.getElementById('supertonic-lang')?.value,
617654
+ expression: document.getElementById('supertonic-expression')?.value,
617655
+ speed: Number(document.getElementById('supertonic-speed')?.value),
617656
+ totalStep: Number(document.getElementById('supertonic-total-step')?.value),
617657
+ };
617658
+ try {
617659
+ const r = await fetch('/v1/voice/supertonic-settings', {
617660
+ method: 'POST',
617661
+ headers: { 'Content-Type': 'application/json', ...headers() },
617662
+ body: JSON.stringify(body),
617663
+ });
617664
+ const data = await r.json();
617665
+ if (!r.ok) { alert('Supertonic update failed: ' + (data.message || data.error)); return; }
617666
+ renderSupertonicSettingsForm(data.settings || {}, data.options || {});
617667
+ } catch (e) { alert('Supertonic update failed: ' + e.message); }
617668
+ }
617669
+ window.saveSupertonicSettings = saveSupertonicSettings;
617670
+
617356
617671
  async function loadCloneRefs() {
617357
617672
  const list = document.getElementById('clone-refs-list');
617358
617673
  if (!list) return;
@@ -617412,7 +617727,10 @@ async function uploadCloneRef(files) {
617412
617727
  if (!r.ok) { alert('Upload failed: ' + (data.message || data.error)); loadCloneRefs(); return; }
617413
617728
  loadCloneRefs(); refreshVoiceState();
617414
617729
  } catch (e) { alert('Upload failed: ' + e.message); loadCloneRefs(); }
617415
- finally { document.getElementById('clone-upload-input').value = ''; }
617730
+ finally {
617731
+ const input = document.getElementById('clone-upload-input');
617732
+ if (input) input.value = '';
617733
+ }
617416
617734
  }
617417
617735
  window.uploadCloneRef = uploadCloneRef;
617418
617736
 
@@ -618318,10 +618636,11 @@ async function loadSettingsConnections() {
618318
618636
  const bt = (epR && epR.backendType) || liveCfg.backendType || persistedCfg.backendType || '';
618319
618637
  const authSet = (epR && epR.auth === '[set]') || (liveCfg.apiKey && liveCfg.apiKey !== '[redacted]');
618320
618638
  const safeEp = String(ep).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
618321
- const safeBt = String(bt).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
618639
+ const safeBt = String(bt === 'openai' ? 'vllm' : bt).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
618322
618640
  // Endpoint history — recently-used endpoints with use counts. Click a row
618323
618641
  // to load it into the editor below. Delete button per row.
618324
618642
  const history = (histR && Array.isArray(histR.endpoints)) ? histR.endpoints : [];
618643
+ window.__omniusAuthAlreadySet = Boolean(authSet);
618325
618644
  const histHTML = history.length === 0
618326
618645
  ? '<p style="font-size:0.74rem;color:var(--color-fg-muted);margin:4px 0">No history yet. After you save and use an endpoint, it appears here for quick re-selection.</p>'
618327
618646
  : '<div style="display:flex;flex-direction:column;gap:6px;max-height:200px;overflow-y:auto;border:1px solid var(--color-border);border-radius:var(--radius-sm);padding:6px">' +
@@ -618385,7 +618704,7 @@ async function loadSettingsConnections() {
618385
618704
  '<div>' +
618386
618705
  '<label style="display:block;font-size:0.78rem;font-weight:500;margin-bottom:6px">Backend type</label>' +
618387
618706
  '<select id="settings-conn-backend-type" style="width:200px;background:var(--color-bg-input);border:1px solid var(--color-border);color:var(--color-fg);padding:6px 10px;border-radius:var(--radius-sm);font-size:0.78rem">' +
618388
- ['ollama','vllm','openai','unknown'].map(t => '<option value="' + t + '"' + (t===safeBt?' selected':'') + '>' + t + '</option>').join('') +
618707
+ ['ollama','vllm','nexus','unknown'].map(t => '<option value="' + t + '"' + (t===safeBt?' selected':'') + '>' + t + '</option>').join('') +
618389
618708
  '</select>' +
618390
618709
  '<p style="font-size:0.7rem;color:var(--color-fg-muted);margin:4px 0 0">Auto-detected from URL on input. Override if needed.</p>' +
618391
618710
  '</div>' +
@@ -618415,12 +618734,12 @@ const _OMNIUS_ENDPOINT_PRESETS = {
618415
618734
  'ollama': { url: 'http://127.0.0.1:11434', backendType: 'ollama' },
618416
618735
  'ollama-lan': { url: 'http://0.0.0.0:11434', backendType: 'ollama' },
618417
618736
  'vllm': { url: 'http://127.0.0.1:8000/v1', backendType: 'vllm' },
618418
- 'lmstudio': { url: 'http://127.0.0.1:1234/v1', backendType: 'openai' },
618419
- 'openai': { url: 'https://api.openai.com/v1', backendType: 'openai', requiresAuth: true },
618420
- 'anthropic': { url: 'https://api.anthropic.com/v1', backendType: 'openai', requiresAuth: true },
618737
+ 'lmstudio': { url: 'http://127.0.0.1:1234/v1', backendType: 'vllm' },
618738
+ 'openai': { url: 'https://api.openai.com/v1', backendType: 'vllm', requiresAuth: true },
618739
+ 'anthropic': { url: 'https://api.anthropic.com/v1', backendType: 'vllm', requiresAuth: true },
618421
618740
  'chutes': { url: 'https://llm.chutes.ai/v1', backendType: 'vllm', requiresAuth: true },
618422
- 'groq': { url: 'https://api.groq.com/openai/v1', backendType: 'openai', requiresAuth: true },
618423
- 'deepinfra': { url: 'https://api.deepinfra.com/v1/openai', backendType: 'openai', requiresAuth: true },
618741
+ 'groq': { url: 'https://api.groq.com/openai/v1', backendType: 'vllm', requiresAuth: true },
618742
+ 'deepinfra': { url: 'https://api.deepinfra.com/v1/openai', backendType: 'vllm', requiresAuth: true },
618424
618743
  };
618425
618744
 
618426
618745
  // One-click endpoint switcher. apply=true saves directly (no typing
@@ -618541,38 +618860,41 @@ function autoDetectBackendType(url) {
618541
618860
  const u = String(url || '').toLowerCase();
618542
618861
  let detected = 'unknown';
618543
618862
  if (u.includes('11434') || u.includes('ollama')) detected = 'ollama';
618544
- else if (u.includes('openai.com') || u.includes('api.anthropic.com')) detected = 'openai';
618545
- else if (u.includes('vllm') || u.includes('chutes') || u.includes('groq') || u.includes('deepinfra') || u.includes('/v1')) detected = 'vllm';
618863
+ else if (u.startsWith('peer://')) detected = 'nexus';
618864
+ else if (u.includes('vllm') || u.includes('openai.com') || u.includes('api.anthropic.com') || u.includes('chutes') || u.includes('groq') || u.includes('deepinfra') || u.includes('/v1')) detected = 'vllm';
618546
618865
  if (sel.value === '' || sel.value === 'unknown') sel.value = detected;
618547
618866
  }
618548
618867
 
618549
618868
  async function testSettingsConnections() {
618550
618869
  const inp = document.getElementById('settings-conn-endpoint');
618870
+ const bt = document.getElementById('settings-conn-backend-type');
618551
618871
  const auth = document.getElementById('settings-conn-auth');
618552
618872
  const status = document.getElementById('settings-conn-status');
618553
618873
  if (!inp || !status) return;
618554
618874
  status.textContent = 'testing...';
618555
618875
  status.style.color = 'var(--color-fg-muted)';
618556
- // Strip /v1/chat/completions or /v1/* path so we can hit /v1/models — same as normalizeBaseUrl.
618557
- let base = String(inp.value || '').trim().replace(/\\/$/, '');
618558
- base = base.replace(/\\/v1\\/chat\\/completions$/i, '').replace(/\\/v1\\/models$/i, '');
618559
- const url = base.endsWith('/v1') ? base + '/models' : base + '/v1/models';
618560
618876
  try {
618561
- const opts = { headers: { 'Accept': 'application/json' } };
618562
- const a = auth && auth.value ? auth.value : '';
618563
- if (a) opts.headers['Authorization'] = 'Bearer ' + a;
618564
- const r = await fetch(url, opts);
618565
- if (r.status === 200) {
618566
- const j = await r.json().catch(() => ({}));
618567
- const data = (j && j.data) || (j && j.models) || (Array.isArray(j) ? j : []);
618568
- const count = Array.isArray(data) ? data.length : 0;
618569
- status.textContent = '✓ ok — ' + count + ' model(s) reachable';
618877
+ const body = {
618878
+ url: String(inp.value || '').trim(),
618879
+ backendType: bt && bt.value && bt.value !== 'unknown' ? bt.value : undefined,
618880
+ auth: auth && auth.value ? auth.value : undefined,
618881
+ };
618882
+ const r = await fetch('/v1/config/endpoint/test', {
618883
+ method: 'POST',
618884
+ headers: { ...headers(), 'Content-Type': 'application/json' },
618885
+ body: JSON.stringify(body),
618886
+ });
618887
+ const data = await r.json().catch(() => ({}));
618888
+ if (r.ok && data.ok) {
618889
+ status.textContent = '✓ ok — ' + data.modelCount + ' model(s) reachable via ' + data.provider;
618570
618890
  status.style.color = 'var(--color-success)';
618571
- } else if (r.status === 401 || r.status === 403) {
618572
- status.textContent = '✗ unauthorized (' + r.status + ') auth key required or wrong';
618891
+ inp.value = data.url || inp.value;
618892
+ if (bt && data.backendType) bt.value = data.backendType;
618893
+ } else if (data.status === 401 || data.status === 403) {
618894
+ status.textContent = '✗ unauthorized (' + data.status + ') — auth key required or wrong';
618573
618895
  status.style.color = 'var(--color-error)';
618574
618896
  } else {
618575
- status.textContent = '✗ HTTP ' + r.status;
618897
+ status.textContent = '✗ ' + (data.error || ('HTTP ' + r.status));
618576
618898
  status.style.color = 'var(--color-error)';
618577
618899
  }
618578
618900
  } catch (e) {
@@ -618601,10 +618923,16 @@ async function saveSettingsConnections() {
618601
618923
  body: JSON.stringify(body),
618602
618924
  });
618603
618925
  if (r.status === 200) {
618604
- status.textContent = '✓ saved refresh model list to pick up the change';
618926
+ const data = await r.json().catch(() => ({}));
618927
+ if (data.url) inp.value = data.url;
618928
+ if (bt && data.backendType) bt.value = data.backendType;
618929
+ status.textContent = '✓ saved — endpoint reloaded; refreshing models...';
618605
618930
  status.style.color = 'var(--color-success)';
618931
+ window.__omniusAuthAlreadySet = Boolean((auth && auth.value) || window.__omniusAuthAlreadySet);
618606
618932
  // Clear the auth input so it doesn't visually persist after save.
618607
618933
  if (auth) auth.value = '';
618934
+ try { await loadModels(); } catch {}
618935
+ try { await loadSettingsModels(); } catch {}
618608
618936
  } else {
618609
618937
  const errBody = await r.json().catch(() => ({}));
618610
618938
  status.textContent = '✗ failed (' + r.status + ')' + (errBody.error ? ': ' + errBody.error : '');
@@ -619358,7 +619686,8 @@ function getOpenApiSpec() {
619358
619686
  }
619359
619687
  },
619360
619688
  "/v1/config/model": { get: { summary: "Current model", tags: ["Config"], responses: { 200: { description: "Model name" } } }, put: { summary: "Switch model", tags: ["Config"], responses: { 200: { description: "Switched" } } } },
619361
- "/v1/config/endpoint": { get: { summary: "Current backend endpoint", tags: ["Config"], responses: { 200: { description: "Endpoint URL" } } }, put: { summary: "Switch endpoint", tags: ["Config"], responses: { 200: { description: "Switched" } } } },
619689
+ "/v1/config/endpoint": { get: { summary: "Current backend endpoint", tags: ["Config"], responses: { 200: { description: "Endpoint URL" } } }, put: { summary: "Switch endpoint using TUI-compatible normalization", tags: ["Config"], responses: { 200: { description: "Switched" } } } },
619690
+ "/v1/config/endpoint/test": { post: { summary: "Test backend endpoint from the daemon process", tags: ["Config"], responses: { 200: { description: "Endpoint probe result" }, 400: { description: "Invalid endpoint" } } } },
619362
619691
  "/v1/usage": { get: { summary: "Token usage and rate limits", tags: ["Metering"], responses: { 200: { description: "Usage stats" } } } },
619363
619692
  "/v1/audit": { get: { summary: "Query audit log", tags: ["Audit"], responses: { 200: { description: "Audit records" } } } },
619364
619693
  "/v1/commands": { get: { summary: "List available slash commands", tags: ["Commands"], responses: { 200: { description: "Command registry" } } } },
@@ -619497,8 +619826,12 @@ function getOpenApiSpec() {
619497
619826
  "/v1/engines": { get: { summary: "List long-running engines", tags: ["Engines"], responses: { 200: { description: "Engine status + state files" } } } },
619498
619827
  // ───── Voice / Audio surface (live) ─────
619499
619828
  "/v1/voice/state": { get: { summary: "Voice runtime status (engine load state, active model, current clone ref, client count)", tags: ["Voice"], responses: { 200: { description: "Runtime status snapshot" } } } },
619500
- "/v1/voice/models": { get: { summary: "List TTS voice models (id, label, backend)", tags: ["Voice"], responses: { 200: { description: "Voice model list" } } } },
619829
+ "/v1/voice/models": { get: { summary: "List TTS voice models with backend-specific metadata", tags: ["Voice"], responses: { 200: { description: "Voice model list" } } } },
619501
619830
  "/v1/voice/models/switch": { post: { summary: "Switch active TTS model — body {modelId}", tags: ["Voice"], responses: { 200: { description: "Switched" }, 400: { description: "Missing modelId" }, 500: { description: "Switch failed" } } } },
619831
+ "/v1/voice/supertonic-settings": {
619832
+ get: { summary: "Read Supertonic3 voice style settings and options", tags: ["Voice"], responses: { 200: { description: "Supertonic3 settings" } } },
619833
+ post: { summary: "Update Supertonic3 voice style settings", tags: ["Voice"], responses: { 200: { description: "Updated" }, 400: { description: "Missing settings" } } }
619834
+ },
619502
619835
  "/v1/voice/asr-models": { get: { summary: "List Whisper ASR models with active highlight", tags: ["Voice"], responses: { 200: { description: "ASR model list" } } } },
619503
619836
  "/v1/voice/asr-models/switch": { post: { summary: "Switch active Whisper model — body {modelId}", tags: ["Voice"], responses: { 200: { description: "Switched" }, 400: { description: "Missing modelId" } } } },
619504
619837
  "/v1/voice/tts": {
@@ -620254,7 +620587,7 @@ var init_profiles = __esm({
620254
620587
  // packages/cli/src/docker.ts
620255
620588
  import { execSync as execSync56, spawn as spawn28 } from "node:child_process";
620256
620589
  import { existsSync as existsSync119, mkdirSync as mkdirSync70, writeFileSync as writeFileSync65 } from "node:fs";
620257
- import { join as join133, resolve as resolve42, dirname as dirname36 } from "node:path";
620590
+ import { join as join133, resolve as resolve42, dirname as dirname37 } from "node:path";
620258
620591
  import { homedir as homedir44 } from "node:os";
620259
620592
  import { fileURLToPath as fileURLToPath16 } from "node:url";
620260
620593
  function getDockerDir() {
@@ -620265,7 +620598,7 @@ function getDockerDir() {
620265
620598
  } catch {
620266
620599
  }
620267
620600
  try {
620268
- const thisDir = dirname36(fileURLToPath16(import.meta.url));
620601
+ const thisDir = dirname37(fileURLToPath16(import.meta.url));
620269
620602
  return join133(thisDir, "..", "..", "..", "docker");
620270
620603
  } catch {
620271
620604
  }
@@ -620552,7 +620885,7 @@ __export(embedding_workers_exports, {
620552
620885
  startEmbeddingWorkers: () => startEmbeddingWorkers,
620553
620886
  stopEmbeddingWorkers: () => stopEmbeddingWorkers
620554
620887
  });
620555
- import { basename as basename25, join as join134 } from "node:path";
620888
+ import { basename as basename26, join as join134 } from "node:path";
620556
620889
  function startEmbeddingWorkers(opts) {
620557
620890
  if (_running) return;
620558
620891
  _running = true;
@@ -620618,7 +620951,7 @@ async function runEmbeddingTask(modality, episodeId, taskId, opts) {
620618
620951
  try {
620619
620952
  if (!_aligner) {
620620
620953
  const stateRoot = process.env.OMNIUS_DIR || process.cwd();
620621
- const omniusDir = basename25(stateRoot) === ".omnius" ? stateRoot : join134(stateRoot, ".omnius");
620954
+ const omniusDir = basename26(stateRoot) === ".omnius" ? stateRoot : join134(stateRoot, ".omnius");
620622
620955
  const memDir = join134(omniusDir, "memory");
620623
620956
  _aligner = new EmbeddingAligner(
620624
620957
  `${modality}-${emb.length}`,
@@ -620734,7 +621067,7 @@ import * as http5 from "node:http";
620734
621067
  import * as https3 from "node:https";
620735
621068
  import { createRequire as createRequire7 } from "node:module";
620736
621069
  import { fileURLToPath as fileURLToPath17 } from "node:url";
620737
- import { dirname as dirname37, join as join135, resolve as resolve43 } from "node:path";
621070
+ import { dirname as dirname38, join as join135, resolve as resolve43 } from "node:path";
620738
621071
  import { homedir as homedir45 } from "node:os";
620739
621072
  import { spawn as spawn29, execSync as execSync57 } from "node:child_process";
620740
621073
  import { mkdirSync as mkdirSync71, writeFileSync as writeFileSync66, readFileSync as readFileSync98, readdirSync as readdirSync41, existsSync as existsSync120, watch as fsWatch3, renameSync as renameSync8, unlinkSync as unlinkSync25 } from "node:fs";
@@ -620742,7 +621075,7 @@ import { randomBytes as randomBytes24, randomUUID as randomUUID16 } from "node:c
620742
621075
  import { createHash as createHash23 } from "node:crypto";
620743
621076
  function getVersion3() {
620744
621077
  try {
620745
- const thisDir = dirname37(fileURLToPath17(import.meta.url));
621078
+ const thisDir = dirname38(fileURLToPath17(import.meta.url));
620746
621079
  const candidates = [
620747
621080
  join135(thisDir, "..", "package.json"),
620748
621081
  join135(thisDir, "..", "..", "package.json"),
@@ -620763,6 +621096,42 @@ function getVersion3() {
620763
621096
  }
620764
621097
  return "0.0.0";
620765
621098
  }
621099
+ function normalizeLocalhostForDaemon(url) {
621100
+ if (process.env["OMNIUS_KEEP_LOCALHOST"] === "1") return url;
621101
+ return url.replace(/^(https?:\/\/)localhost(:|\/|$)/i, "$1127.0.0.1$2");
621102
+ }
621103
+ function coerceEndpointBackendType(rawUrl, requested) {
621104
+ const requestedText = typeof requested === "string" ? requested.trim().toLowerCase() : "";
621105
+ if (requestedText === "ollama" || requestedText === "vllm" || requestedText === "nexus") {
621106
+ return requestedText;
621107
+ }
621108
+ const provider = detectProvider(rawUrl);
621109
+ return provider.id === "ollama" ? "ollama" : "vllm";
621110
+ }
621111
+ function canonicalEndpointInput(rawUrl, requestedBackendType) {
621112
+ const normalized = normalizeLocalhostForDaemon(normalizeBaseUrl(rawUrl));
621113
+ const provider = detectProvider(normalized);
621114
+ return {
621115
+ url: normalized,
621116
+ backendType: coerceEndpointBackendType(normalized, requestedBackendType),
621117
+ provider
621118
+ };
621119
+ }
621120
+ function endpointAuthHeaders(provider, authKey) {
621121
+ const key = authKey?.trim();
621122
+ if (!key) return {};
621123
+ if (provider.id === "anthropic") {
621124
+ return {
621125
+ "x-api-key": key,
621126
+ "anthropic-version": "2023-06-01"
621127
+ };
621128
+ }
621129
+ return { Authorization: `Bearer ${key}` };
621130
+ }
621131
+ function endpointModelsPath(endpoint, provider) {
621132
+ if (endpoint.type === "ollama") return "/api/tags";
621133
+ return provider?.modelsPath ?? "/v1/models";
621134
+ }
620766
621135
  function getEndpointUsage(label) {
620767
621136
  let u = endpointUsage.get(label);
620768
621137
  const today2 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
@@ -620856,8 +621225,8 @@ async function fetchAggregatedModels() {
620856
621225
  if (/^https?:\/\/localhost(:|\/|$)/i.test(ep.url)) diag.ipv6Trap = true;
620857
621226
  try {
620858
621227
  const isOllama = ep.type === "ollama";
620859
- const modelsPath = isOllama ? "/api/tags" : "/v1/models";
620860
- const result = await ollamaRequest(ep.url, modelsPath, "GET");
621228
+ const modelsPath = endpointModelsPath(ep, detectProvider(ep.url));
621229
+ const result = await ollamaRequest(ep.url, modelsPath, "GET", void 0, void 0, ep);
620861
621230
  diag.status = result.status;
620862
621231
  if (result.status !== 200) {
620863
621232
  diag.error = `HTTP ${result.status}`;
@@ -621181,7 +621550,7 @@ async function directChatBackend(opts) {
621181
621550
  "X-API-Version": API_VERSION
621182
621551
  });
621183
621552
  let acc = "";
621184
- const url = new URL("/v1/chat/completions", ollamaUrl);
621553
+ const url = backendUrl(ollamaUrl, "/v1/chat/completions");
621185
621554
  const transport = url.protocol === "https:" ? https3 : http5;
621186
621555
  await new Promise((resolve48, reject) => {
621187
621556
  const proxyReq = transport.request({
@@ -621367,9 +621736,18 @@ function backendAuthHeaders(endpoint) {
621367
621736
  if (key) return { Authorization: `Bearer ${key}` };
621368
621737
  return {};
621369
621738
  }
621370
- function ollamaRequest(ollamaUrl, path11, method, body, timeoutMs) {
621739
+ function backendUrl(baseUrl, path11) {
621740
+ const url = new URL(baseUrl);
621741
+ const [rawPath, rawQuery = ""] = path11.split("?", 2);
621742
+ const basePath = url.pathname.replace(/\/+$/, "");
621743
+ const nextPath = (rawPath || "").replace(/^\/+/, "");
621744
+ url.pathname = `${basePath}/${nextPath}`.replace(/\/{2,}/g, "/");
621745
+ url.search = rawQuery ? `?${rawQuery}` : "";
621746
+ return url;
621747
+ }
621748
+ function ollamaRequest(ollamaUrl, path11, method, body, timeoutMs, endpoint) {
621371
621749
  return new Promise((resolve48, reject) => {
621372
- const url = new URL(path11, ollamaUrl);
621750
+ const url = backendUrl(ollamaUrl, path11);
621373
621751
  const isHttps = url.protocol === "https:";
621374
621752
  const options2 = {
621375
621753
  hostname: url.hostname,
@@ -621379,7 +621757,7 @@ function ollamaRequest(ollamaUrl, path11, method, body, timeoutMs) {
621379
621757
  headers: {
621380
621758
  "Content-Type": "application/json",
621381
621759
  ...body ? { "Content-Length": Buffer.byteLength(body) } : {},
621382
- ...backendAuthHeaders()
621760
+ ...backendAuthHeaders(endpoint)
621383
621761
  }
621384
621762
  };
621385
621763
  const transport = isHttps ? https3 : http5;
@@ -621411,8 +621789,8 @@ function ollamaRequest(ollamaUrl, path11, method, body, timeoutMs) {
621411
621789
  proxyReq.end();
621412
621790
  });
621413
621791
  }
621414
- function ollamaStream(ollamaUrl, path11, method, body, onData, onEnd, onError, timeoutMs) {
621415
- const url = new URL(path11, ollamaUrl);
621792
+ function ollamaStream(ollamaUrl, path11, method, body, onData, onEnd, onError, timeoutMs, endpoint) {
621793
+ const url = backendUrl(ollamaUrl, path11);
621416
621794
  const isHttps = url.protocol === "https:";
621417
621795
  const options2 = {
621418
621796
  hostname: url.hostname,
@@ -621422,7 +621800,7 @@ function ollamaStream(ollamaUrl, path11, method, body, onData, onEnd, onError, t
621422
621800
  headers: {
621423
621801
  "Content-Type": "application/json",
621424
621802
  ...body ? { "Content-Length": Buffer.byteLength(body) } : {},
621425
- ...backendAuthHeaders()
621803
+ ...backendAuthHeaders(endpoint)
621426
621804
  }
621427
621805
  };
621428
621806
  const transport = isHttps ? https3 : http5;
@@ -622034,7 +622412,8 @@ function handleHelp(req2, res) {
622034
622412
  "GET /v1/config/model": "Current model",
622035
622413
  "PUT /v1/config/model": "Set model — body: {model}",
622036
622414
  "GET /v1/config/endpoint": "Current backend endpoint",
622037
- "PUT /v1/config/endpoint": "Set backend endpoint — body: {endpoint}"
622415
+ "PUT /v1/config/endpoint": "Set backend endpoint — body: {url, backendType?, auth?}",
622416
+ "POST /v1/config/endpoint/test": "Test backend endpoint server-side — body: {url, backendType?, auth?}"
622038
622417
  },
622039
622418
  monitoring: {
622040
622419
  "GET /v1/events": "Server-Sent Events stream (task lifecycle, todo changes)",
@@ -622181,8 +622560,8 @@ async function fetchAggregatedOllamaTags() {
622181
622560
  const fetches = endpointRegistry.map(async (ep) => {
622182
622561
  try {
622183
622562
  const isOllama = ep.type === "ollama";
622184
- const path11 = isOllama ? "/api/tags" : "/v1/models";
622185
- const result = await ollamaRequest(ep.url, path11, "GET", void 0, getModelListTimeoutMs());
622563
+ const path11 = endpointModelsPath(ep, detectProvider(ep.url));
622564
+ const result = await ollamaRequest(ep.url, path11, "GET", void 0, getModelListTimeoutMs(), ep);
622186
622565
  if (result.status !== 200) return;
622187
622566
  const body = JSON.parse(result.body);
622188
622567
  if (isOllama) {
@@ -622388,7 +622767,7 @@ ${messages2[firstSystemIdx].content}`
622388
622767
  let parsed;
622389
622768
  try {
622390
622769
  const path11 = targetType === "vllm" || targetType === "openai" ? "/v1/chat/completions" : "/v1/chat/completions";
622391
- const result = await ollamaRequest(targetUrl, path11, "POST", JSON.stringify(turnBody), reqTimeoutMs);
622770
+ const result = await ollamaRequest(targetUrl, path11, "POST", JSON.stringify(turnBody), reqTimeoutMs, route?.endpoint);
622392
622771
  if (result.status !== 200) {
622393
622772
  jsonResponse(res, result.status, {
622394
622773
  error: "Backend request failed during agent_loop",
@@ -622585,11 +622964,12 @@ async function handleV1ChatCompletions(req2, res, ollamaUrl) {
622585
622964
  }
622586
622965
  res.end();
622587
622966
  },
622588
- reqTimeoutMs
622967
+ reqTimeoutMs,
622968
+ route?.endpoint
622589
622969
  );
622590
622970
  } else {
622591
622971
  try {
622592
- const result = await ollamaRequest(targetUrl, "/v1/chat/completions", "POST", payload, reqTimeoutMs);
622972
+ const result = await ollamaRequest(targetUrl, "/v1/chat/completions", "POST", payload, reqTimeoutMs, route?.endpoint);
622593
622973
  if (result.status !== 200) {
622594
622974
  jsonResponse(res, result.status, { error: "Backend request failed", details: result.body });
622595
622975
  return;
@@ -622730,11 +623110,12 @@ async function handleV1ChatCompletions(req2, res, ollamaUrl) {
622730
623110
  }
622731
623111
  res.end();
622732
623112
  },
622733
- reqTimeoutMs
623113
+ reqTimeoutMs,
623114
+ route?.endpoint
622734
623115
  );
622735
623116
  } else {
622736
623117
  try {
622737
- const result = await ollamaRequest(targetUrl, "/api/chat", "POST", ollamaPayload, reqTimeoutMs);
623118
+ const result = await ollamaRequest(targetUrl, "/api/chat", "POST", ollamaPayload, reqTimeoutMs, route?.endpoint);
622738
623119
  if (result.status !== 200) {
622739
623120
  jsonResponse(res, result.status, {
622740
623121
  error: "Ollama request failed",
@@ -623286,7 +623667,7 @@ async function handleV1Update(req2, res, requestId) {
623286
623667
  }, { subject: req2._authUser ?? "anonymous" });
623287
623668
  const fs10 = require4("node:fs");
623288
623669
  const nodeBin = process.execPath;
623289
- const nodeDir = dirname37(nodeBin);
623670
+ const nodeDir = dirname38(nodeBin);
623290
623671
  const { execSync: es } = require4("node:child_process");
623291
623672
  const isWin2 = process.platform === "win32";
623292
623673
  let npmBin = "";
@@ -623301,7 +623682,7 @@ async function handleV1Update(req2, res, requestId) {
623301
623682
  const dir = join135(homedir45(), ".omnius");
623302
623683
  fs10.mkdirSync(dir, { recursive: true });
623303
623684
  const logFd = fs10.openSync(logPath3, "w");
623304
- const npmPrefix = dirname37(nodeDir);
623685
+ const npmPrefix = dirname38(nodeDir);
623305
623686
  let globalBinDir = "";
623306
623687
  try {
623307
623688
  if (isWin2) {
@@ -624100,26 +624481,104 @@ async function handlePutConfigEndpoint(req2, res) {
624100
624481
  jsonResponse(res, 400, { error: "Missing required field: url" });
624101
624482
  return;
624102
624483
  }
624103
- const url = process.env["OMNIUS_KEEP_LOCALHOST"] === "1" ? rawUrl : rawUrl.replace(/^(https?:\/\/)localhost(:|\/|$)/i, "$1127.0.0.1$2");
624104
- const settings = { backendUrl: url };
624484
+ let endpoint;
624485
+ try {
624486
+ endpoint = canonicalEndpointInput(rawUrl, requestBody["backendType"]);
624487
+ new URL(endpoint.url);
624488
+ } catch {
624489
+ jsonResponse(res, 400, { error: "Invalid endpoint URL" });
624490
+ return;
624491
+ }
624492
+ const settings = {
624493
+ backendUrl: endpoint.url,
624494
+ backendType: endpoint.backendType
624495
+ };
624105
624496
  if (typeof requestBody["auth"] === "string") settings.apiKey = requestBody["auth"];
624106
- if (typeof requestBody["backendType"] === "string") settings.backendType = requestBody["backendType"];
624497
+ setConfigValue("backendUrl", endpoint.url);
624498
+ setConfigValue("backendType", endpoint.backendType);
624499
+ if (typeof requestBody["auth"] === "string") setConfigValue("apiKey", requestBody["auth"]);
624107
624500
  saveGlobalSettings(settings);
624108
624501
  try {
624109
- const meta = {};
624110
- if (typeof requestBody["backendType"] === "string") meta.backendType = requestBody["backendType"];
624502
+ const meta = {
624503
+ provider: endpoint.provider.label,
624504
+ backendType: endpoint.backendType
624505
+ };
624111
624506
  if (typeof requestBody["auth"] === "string" && requestBody["auth"]) {
624112
624507
  meta.authHint = String(requestBody["auth"]).slice(0, 4) + "…";
624113
624508
  meta.authKey = requestBody["auth"];
624114
624509
  }
624115
- recordUsage("endpoint", url, { meta });
624510
+ recordUsage("endpoint", endpoint.url, { meta });
624116
624511
  } catch {
624117
624512
  }
624118
624513
  try {
624119
624514
  await refreshEndpointRegistry();
624120
624515
  } catch {
624121
624516
  }
624122
- jsonResponse(res, 200, { url, status: "updated", reloaded: true });
624517
+ jsonResponse(res, 200, {
624518
+ url: endpoint.url,
624519
+ backendType: endpoint.backendType,
624520
+ provider: endpoint.provider.label,
624521
+ status: "updated",
624522
+ reloaded: true
624523
+ });
624524
+ }
624525
+ async function handlePostConfigEndpointTest(req2, res) {
624526
+ const body = await parseJsonBody(req2);
624527
+ if (!body || typeof body !== "object") {
624528
+ jsonResponse(res, 400, { error: "Invalid request body" });
624529
+ return;
624530
+ }
624531
+ const requestBody = body;
624532
+ const rawUrl = requestBody["url"];
624533
+ if (typeof rawUrl !== "string" || !rawUrl) {
624534
+ jsonResponse(res, 400, { error: "Missing required field: url" });
624535
+ return;
624536
+ }
624537
+ let endpoint;
624538
+ try {
624539
+ endpoint = canonicalEndpointInput(rawUrl, requestBody["backendType"]);
624540
+ new URL(endpoint.url);
624541
+ } catch {
624542
+ jsonResponse(res, 400, { error: "Invalid endpoint URL" });
624543
+ return;
624544
+ }
624545
+ const current = loadConfig();
624546
+ const explicitAuth = typeof requestBody["auth"] === "string" && requestBody["auth"].trim() ? requestBody["auth"].trim() : void 0;
624547
+ const authKey = explicitAuth ?? (current.backendUrl === endpoint.url ? current.apiKey : void 0);
624548
+ const modelsPath = endpointModelsPath({ type: endpoint.backendType }, endpoint.provider);
624549
+ const target = backendUrl(endpoint.url, modelsPath);
624550
+ try {
624551
+ const response = await fetch(target, {
624552
+ method: "GET",
624553
+ headers: {
624554
+ Accept: "application/json",
624555
+ ...endpointAuthHeaders(endpoint.provider, authKey)
624556
+ },
624557
+ signal: AbortSignal.timeout(1e4)
624558
+ });
624559
+ const payload = await response.json().catch(() => ({}));
624560
+ const rawModels = endpoint.backendType === "ollama" ? payload["models"] : payload["data"] ?? payload["models"];
624561
+ const modelCount = Array.isArray(rawModels) ? rawModels.length : 0;
624562
+ jsonResponse(res, 200, {
624563
+ ok: response.ok,
624564
+ status: response.status,
624565
+ url: endpoint.url,
624566
+ backendType: endpoint.backendType,
624567
+ provider: endpoint.provider.label,
624568
+ modelCount,
624569
+ modelsPath,
624570
+ error: response.ok ? void 0 : `HTTP ${response.status}`
624571
+ });
624572
+ } catch (err) {
624573
+ jsonResponse(res, 200, {
624574
+ ok: false,
624575
+ url: endpoint.url,
624576
+ backendType: endpoint.backendType,
624577
+ provider: endpoint.provider.label,
624578
+ modelsPath,
624579
+ error: err instanceof Error ? err.message : String(err)
624580
+ });
624581
+ }
624123
624582
  }
624124
624583
  function handleGetCommands(res) {
624125
624584
  const commands = getRestCommandEntries({ includePlanned: true }).map((cmd) => ({
@@ -624284,10 +624743,10 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
624284
624743
  const dir = path11.dirname(cssEntry);
624285
624744
  const fullPath = path11.join(dir, entry.path);
624286
624745
  if (fs10.existsSync(fullPath)) {
624287
- const stat5 = fs10.statSync(fullPath);
624746
+ const stat6 = fs10.statSync(fullPath);
624288
624747
  res.writeHead(200, {
624289
624748
  "Content-Type": entry.ct,
624290
- "Content-Length": String(stat5.size),
624749
+ "Content-Length": String(stat6.size),
624291
624750
  "Cache-Control": "public, max-age=86400, immutable"
624292
624751
  });
624293
624752
  fs10.createReadStream(fullPath).pipe(res);
@@ -624679,6 +625138,35 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
624679
625138
  jsonResponse(res, 200, { models: listVoiceModels() });
624680
625139
  return;
624681
625140
  }
625141
+ if (pathname === "/v1/voice/supertonic-settings" && method === "GET") {
625142
+ const ve = getVoiceEngine();
625143
+ jsonResponse(res, 200, {
625144
+ settings: ve.getSupertonicSettings(),
625145
+ options: getSupertonicVoiceOptions()
625146
+ });
625147
+ return;
625148
+ }
625149
+ if (pathname === "/v1/voice/supertonic-settings" && (method === "POST" || method === "PATCH")) {
625150
+ const body = await parseJsonBody(req2);
625151
+ if (!body || typeof body !== "object") {
625152
+ jsonResponse(res, 400, { error: "missing_settings" });
625153
+ return;
625154
+ }
625155
+ const ve = getVoiceEngine();
625156
+ const settings = ve.setSupertonicSettings({
625157
+ voiceName: typeof body["voiceName"] === "string" ? body["voiceName"] : void 0,
625158
+ lang: typeof body["lang"] === "string" ? body["lang"] : void 0,
625159
+ speed: typeof body["speed"] === "number" || typeof body["speed"] === "string" ? Number(body["speed"]) : void 0,
625160
+ totalStep: typeof body["totalStep"] === "number" || typeof body["totalStep"] === "string" ? Number(body["totalStep"]) : void 0,
625161
+ expression: typeof body["expression"] === "string" ? body["expression"] : void 0
625162
+ });
625163
+ jsonResponse(res, 200, {
625164
+ ok: true,
625165
+ settings,
625166
+ options: getSupertonicVoiceOptions()
625167
+ });
625168
+ return;
625169
+ }
624682
625170
  if (pathname === "/v1/voice/models/switch" && method === "POST") {
624683
625171
  const body = await parseJsonBody(req2);
624684
625172
  const modelId = typeof body?.modelId === "string" ? body.modelId.trim() : "";
@@ -626214,6 +626702,10 @@ ${steering}`;
626214
626702
  await handlePutConfigEndpoint(req2, res);
626215
626703
  return;
626216
626704
  }
626705
+ if (pathname === "/v1/config/endpoint/test" && method === "POST") {
626706
+ await handlePostConfigEndpointTest(req2, res);
626707
+ return;
626708
+ }
626217
626709
  if (pathname === "/v1/config/endpoint/history" && method === "GET") {
626218
626710
  try {
626219
626711
  const records = loadUsageHistory("endpoint");
@@ -627603,7 +628095,6 @@ function startApiServer(options2 = {}) {
627603
628095
  if (process.env["OMNIUS_NEXUS_DIR"]) dirSet.add(process.env["OMNIUS_NEXUS_DIR"]);
627604
628096
  dirSet.add(_join(process.cwd(), ".omnius", "nexus"));
627605
628097
  dirSet.add(_join(_homedir(), ".omnius", "nexus"));
627606
- dirSet.add(_join(_homedir(), ".omnius", "nexus"));
627607
628098
  let written = 0;
627608
628099
  for (const dir of dirSet) {
627609
628100
  try {
@@ -627623,48 +628114,11 @@ function startApiServer(options2 = {}) {
627623
628114
  (async () => {
627624
628115
  try {
627625
628116
  const { join: _j } = require4("node:path");
627626
- const { homedir: _hd } = require4("node:os");
627627
- const { existsSync: _ex, readFileSync: _rf, statSync: _st } = require4("node:fs");
627628
- const { execSync: _ex2 } = require4("node:child_process");
627629
- let chosenNexusDir = null;
627630
- if (process.env["OMNIUS_NEXUS_DIR"]) chosenNexusDir = process.env["OMNIUS_NEXUS_DIR"];
627631
- if (!chosenNexusDir) {
627632
- try {
627633
- const regPath = _j(_hd(), ".omnius", "nexus-registry.json");
627634
- if (_ex(regPath)) {
627635
- const reg = JSON.parse(_rf(regPath, "utf-8"));
627636
- for (const e2 of reg?.dirs || []) {
627637
- const d2 = typeof e2 === "string" ? e2 : e2?.dir;
627638
- if (typeof d2 === "string" && _ex(d2)) {
627639
- chosenNexusDir = d2;
627640
- break;
627641
- }
627642
- }
627643
- }
627644
- } catch {
627645
- }
627646
- }
627647
- if (!chosenNexusDir) {
627648
- try {
627649
- const cmd = `find "${_hd()}" -maxdepth 4 -path '*/.omnius/nexus' -type d 2>/dev/null | head -10`;
627650
- const out = _ex2(cmd, { encoding: "utf-8", timeout: 2e3 }).trim();
627651
- for (const ln of out.split("\n").filter(Boolean)) {
627652
- if (_ex(_j(ln, "status.json"))) {
627653
- chosenNexusDir = ln;
627654
- break;
627655
- }
627656
- }
627657
- if (!chosenNexusDir && out) chosenNexusDir = out.split("\n")[0]?.trim() || null;
627658
- } catch {
627659
- }
627660
- }
627661
- const finalNexusDir = chosenNexusDir ?? _j(_hd(), ".omnius", "nexus");
627662
- chosenNexusDir = finalNexusDir;
627663
- const repoRoot = finalNexusDir.replace(/[\\/]\.omnius[\\/]nexus$/, "");
628117
+ const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports));
628118
+ const tool = new NexusTool2(process.cwd());
628119
+ const finalNexusDir = tool.getNexusDir();
627664
628120
  log22(` Nexus auto-recover: target ${finalNexusDir}
627665
628121
  `);
627666
- const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports));
627667
- const tool = new NexusTool2(repoRoot);
627668
628122
  const result = await tool.execute({ action: "connect" });
627669
628123
  const status = result?.success ? "ok" : "fail";
627670
628124
  const detail = result?.output || result?.error || "";
@@ -627681,7 +628135,7 @@ function startApiServer(options2 = {}) {
627681
628135
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
627682
628136
  version: version4
627683
628137
  }, null, 2);
627684
- const dirOut = chosenNexusDir;
628138
+ const dirOut = finalNexusDir;
627685
628139
  if (!_exf(dirOut)) _mks(dirOut, { recursive: true });
627686
628140
  _wfs2(_j(dirOut, "api-port.json"), apiHint2);
627687
628141
  } catch {
@@ -628068,6 +628522,7 @@ var init_serve = __esm({
628068
628522
  "packages/cli/src/api/serve.ts"() {
628069
628523
  "use strict";
628070
628524
  init_config();
628525
+ init_dist();
628071
628526
  init_access_policy();
628072
628527
  init_projects();
628073
628528
  init_project_preferences();
@@ -628191,7 +628646,7 @@ var init_clipboard_media = __esm({
628191
628646
 
628192
628647
  // packages/cli/src/tui/interactive.ts
628193
628648
  import { cwd } from "node:process";
628194
- import { resolve as resolve44, join as join137, dirname as dirname38, extname as extname16, relative as relative14 } from "node:path";
628649
+ import { resolve as resolve44, join as join137, dirname as dirname39, extname as extname16, relative as relative14 } from "node:path";
628195
628650
  import { createRequire as createRequire8 } from "node:module";
628196
628651
  import { fileURLToPath as fileURLToPath18 } from "node:url";
628197
628652
  import {
@@ -628218,7 +628673,7 @@ function formatTimeAgo2(date) {
628218
628673
  function getVersion4() {
628219
628674
  try {
628220
628675
  const require5 = createRequire8(import.meta.url);
628221
- const thisDir = dirname38(fileURLToPath18(import.meta.url));
628676
+ const thisDir = dirname39(fileURLToPath18(import.meta.url));
628222
628677
  const candidates = [
628223
628678
  join137(thisDir, "..", "package.json"),
628224
628679
  join137(thisDir, "..", "..", "package.json"),
@@ -628532,8 +628987,8 @@ function imageGenerationDefaultsForRepo(repoRoot) {
628532
628987
  backend: settings.imageBackend
628533
628988
  };
628534
628989
  }
628535
- function createConfiguredImageGenerateTool(repoRoot, backendUrl) {
628536
- return new ImageGenerateTool(repoRoot, backendUrl, imageGenerationDefaultsForRepo(repoRoot));
628990
+ function createConfiguredImageGenerateTool(repoRoot, backendUrl2) {
628991
+ return new ImageGenerateTool(repoRoot, backendUrl2, imageGenerationDefaultsForRepo(repoRoot));
628537
628992
  }
628538
628993
  function audioGenerationDefaultsForRepo(repoRoot) {
628539
628994
  const settings = resolveSettings(repoRoot);
@@ -631831,8 +632286,8 @@ ${result.summary}`
631831
632286
  );
631832
632287
  const formatCtxLabel = (tokens) => tokens >= 1024 ? `${Math.floor(tokens / 1024)}K` : String(tokens);
631833
632288
  let expandedVariantSweepPromise = null;
631834
- const startExpandedVariantRepairSweep = (backendType, backendUrl) => {
631835
- const normalizedUrl = normalizeBaseUrl(backendUrl);
632289
+ const startExpandedVariantRepairSweep = (backendType, backendUrl2) => {
632290
+ const normalizedUrl = normalizeBaseUrl(backendUrl2);
631836
632291
  const isLocalOllama = backendType === "ollama" && (normalizedUrl.includes("127.0.0.1") || normalizedUrl.includes("localhost") || normalizedUrl.includes("0.0.0.0"));
631837
632292
  if (!isLocalOllama || expandedVariantSweepPromise) return;
631838
632293
  expandedVariantSweepPromise = repairAllExpandedVariants(normalizedUrl).then(async (summary) => {
@@ -632818,7 +633273,7 @@ This is an independent background session started from /background.`
632818
633273
  const autoNexus = new NexusTool(repoRoot);
632819
633274
  const _registerNexusDaemon = () => {
632820
633275
  try {
632821
- const nexusPidFile = join137(repoRoot, ".omnius", "nexus", "daemon.pid");
633276
+ const nexusPidFile = join137(autoNexus.getNexusDir(), "daemon.pid");
632822
633277
  if (existsSync121(nexusPidFile)) {
632823
633278
  const nPid = parseInt(
632824
633279
  readFileSync100(nexusPidFile, "utf8").trim(),
@@ -632852,7 +633307,7 @@ This is an independent background session started from /background.`
632852
633307
  await new Promise((r3) => setTimeout(r3, 5e3));
632853
633308
  return _tryNexusConnect(attempt + 1);
632854
633309
  }
632855
- const nexusLogPath = join137(repoRoot, ".omnius", "nexus", "daemon.err");
633310
+ const nexusLogPath = join137(autoNexus.getNexusDir(), "daemon.err");
632856
633311
  const visibleOut = out.length > 1200 ? `${out.slice(0, 1200)}...` : out;
632857
633312
  writeContent(
632858
633313
  () => renderWarning(`Nexus auto-connect failed:
@@ -634813,7 +635268,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
634813
635268
  });
634814
635269
  if (!result.success) throw new Error(result.error || "Connect failed");
634815
635270
  try {
634816
- const nexusPidFile = join137(repoRoot, ".omnius", "nexus", "daemon.pid");
635271
+ const nexusPidFile = join137(nexusTool.getNexusDir(), "daemon.pid");
634817
635272
  if (existsSync121(nexusPidFile)) {
634818
635273
  const pid = parseInt(readFileSync100(nexusPidFile, "utf8").trim(), 10);
634819
635274
  if (pid > 0) {
@@ -635217,7 +635672,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
635217
635672
  }
635218
635673
  }
635219
635674
  }
635220
- const nexusPidFile = join137(repoRoot, ".omnius", "nexus", "daemon.pid");
635675
+ const nexusPidFile = join137(new NexusTool(repoRoot).getNexusDir(), "daemon.pid");
635221
635676
  if (existsSync121(nexusPidFile)) {
635222
635677
  const nPid = parseInt(readFileSync100(nexusPidFile, "utf8").trim(), 10);
635223
635678
  if (nPid > 0 && !registry2.daemons.has("Nexus")) {
@@ -637071,8 +637526,8 @@ async function indexRepoCommand(opts, _config3) {
637071
637526
  printError(`Path does not exist: ${repoRoot}`);
637072
637527
  process.exit(1);
637073
637528
  }
637074
- const stat5 = statSync41(repoRoot);
637075
- if (!stat5.isDirectory()) {
637529
+ const stat6 = statSync41(repoRoot);
637530
+ if (!stat6.isDirectory()) {
637076
637531
  printError(`Path is not a directory: ${repoRoot}`);
637077
637532
  process.exit(1);
637078
637533
  }
@@ -637823,7 +638278,7 @@ init_typed_node_events();
637823
638278
  import { parseArgs as nodeParseArgs2 } from "node:util";
637824
638279
  import { createRequire as createRequire9 } from "node:module";
637825
638280
  import { fileURLToPath as fileURLToPath19 } from "node:url";
637826
- import { dirname as dirname39, join as join141 } from "node:path";
638281
+ import { dirname as dirname40, join as join141 } from "node:path";
637827
638282
 
637828
638283
  // packages/cli/src/cli.ts
637829
638284
  init_typed_node_events();
@@ -637963,7 +638418,7 @@ init_output();
637963
638418
  function getVersion5() {
637964
638419
  try {
637965
638420
  const require5 = createRequire9(import.meta.url);
637966
- const pkgPath = join141(dirname39(fileURLToPath19(import.meta.url)), "..", "package.json");
638421
+ const pkgPath = join141(dirname40(fileURLToPath19(import.meta.url)), "..", "package.json");
637967
638422
  const pkg = require5(pkgPath);
637968
638423
  return pkg.version;
637969
638424
  } catch {