vibeostheog 0.25.7 → 0.25.8

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.
@@ -1 +1,5 @@
1
+ <<<<<<< HEAD
1
2
  window.__VIBEOS_DASHBOARD_BASE__ = "http://127.0.0.1:53142";
3
+ =======
4
+ window.__VIBEOS_DASHBOARD_BASE__ = "http://127.0.0.1:60078";
5
+ >>>>>>> fix/flash-icon
package/dist/vibeOS.js CHANGED
@@ -458,7 +458,6 @@ function getRuntimeState() {
458
458
  apiConnected: true,
459
459
  apiFallbackMode: false,
460
460
  apiFallbackSince: null,
461
- apiEnabled: true,
462
461
  sessionId: "opencode-" + (process.pid || "x") + "-" + Date.now()
463
462
  };
464
463
  }
@@ -486,33 +485,6 @@ function resetApiConnection() {
486
485
  state.apiFallbackMode = false;
487
486
  state.apiFallbackSince = null;
488
487
  }
489
- function isApiConnected() {
490
- const state = getRuntimeState();
491
- return state.apiEnabled;
492
- }
493
- function isApiFallbackMode() {
494
- return getRuntimeState().apiFallbackMode;
495
- }
496
- function getApiFallbackSince() {
497
- return getRuntimeState().apiFallbackSince;
498
- }
499
- function isApiEnabled() {
500
- return getRuntimeState().apiEnabled;
501
- }
502
- function setApiEnabled(enabled) {
503
- getRuntimeState().apiEnabled = enabled;
504
- }
505
- function setApiFallbackSince(since) {
506
- getRuntimeState().apiFallbackSince = since;
507
- }
508
- function setApiFallbackMode(on) {
509
- const state = getRuntimeState();
510
- state.apiFallbackMode = on;
511
- if (on && !state.apiFallbackSince)
512
- state.apiFallbackSince = (/* @__PURE__ */ new Date()).toISOString();
513
- if (!on)
514
- state.apiFallbackSince = null;
515
- }
516
488
  var RUNTIME_KEY;
517
489
  var init_runtime_state = __esm({
518
490
  "src/lib/runtime-state.js"() {
@@ -522,7 +494,7 @@ var init_runtime_state = __esm({
522
494
  });
523
495
 
524
496
  // src/lib/selection-manager.js
525
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync4, existsSync as existsSync4, statSync as statSync3, renameSync as renameSync2 } from "node:fs";
497
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync4, statSync as statSync3, renameSync as renameSync2 } from "node:fs";
526
498
  import { join as join3 } from "node:path";
527
499
  import { homedir as homedir2, tmpdir } from "node:os";
528
500
  function getVibeOSHome2() {
@@ -591,7 +563,7 @@ function writeSelection(key, value) {
591
563
  j.selection = {};
592
564
  j.selection[key] = value;
593
565
  const tmp = TIERS_FILE3 + ".tmp." + Date.now() + "." + Math.random().toString(36).slice(2, 8);
594
- writeFileSync4(tmp, JSON.stringify(j, null, 2) + "\n");
566
+ writeFileSync3(tmp, JSON.stringify(j, null, 2) + "\n");
595
567
  renameSync2(tmp, TIERS_FILE3);
596
568
  return true;
597
569
  });
@@ -621,7 +593,7 @@ function writeSessionSlot2(sid, slot) {
621
593
  j.sessions[sid] = {};
622
594
  j.sessions[sid].active_slot = slot;
623
595
  const tmp = BLACKBOX_FILE + ".tmp";
624
- writeFileSync4(tmp, JSON.stringify(j, null, 2) + "\n");
596
+ writeFileSync3(tmp, JSON.stringify(j, null, 2) + "\n");
625
597
  renameSync2(tmp, BLACKBOX_FILE);
626
598
  return true;
627
599
  } catch (err) {
@@ -661,7 +633,7 @@ function writeSessionOptMode2(sid, mode) {
661
633
  j.sessions[sid] = {};
662
634
  j.sessions[sid].optimization_mode = mode;
663
635
  const tmp = BLACKBOX_FILE + ".tmp";
664
- writeFileSync4(tmp, JSON.stringify(j, null, 2) + "\n");
636
+ writeFileSync3(tmp, JSON.stringify(j, null, 2) + "\n");
665
637
  renameSync2(tmp, BLACKBOX_FILE);
666
638
  return true;
667
639
  } catch (err) {
@@ -1419,7 +1391,7 @@ var init_smart_cache = __esm({
1419
1391
  });
1420
1392
 
1421
1393
  // src/lib/state.js
1422
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync5, appendFileSync as appendFileSync2, existsSync as existsSync5, mkdirSync as mkdirSync4, statSync as statSync4, readdirSync, openSync, readSync, closeSync, rmSync as rmSync2, copyFileSync, renameSync as renameSync3 } from "node:fs";
1394
+ import { readFileSync as readFileSync4, writeFileSync as writeFileSync4, appendFileSync as appendFileSync2, existsSync as existsSync5, mkdirSync as mkdirSync3, statSync as statSync4, readdirSync, openSync, readSync, closeSync, rmSync as rmSync2, copyFileSync, renameSync as renameSync3 } from "node:fs";
1423
1395
  import { join as join4, dirname as dirname4, basename as basename2 } from "node:path";
1424
1396
  import { spawn } from "node:child_process";
1425
1397
  import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
@@ -1523,14 +1495,14 @@ function runStartupMaintenanceOnce() {
1523
1495
  function _ensureVibeOSHomeDir() {
1524
1496
  try {
1525
1497
  if (!existsSync5(VIBEOS_HOME)) {
1526
- mkdirSync4(VIBEOS_HOME, { recursive: true });
1498
+ mkdirSync3(VIBEOS_HOME, { recursive: true });
1527
1499
  return VIBEOS_HOME;
1528
1500
  }
1529
1501
  const st = statSync4(VIBEOS_HOME);
1530
1502
  if (!st.isDirectory()) {
1531
1503
  const backup = VIBEOS_HOME + ".backup." + Date.now();
1532
1504
  renameSync3(VIBEOS_HOME, backup);
1533
- mkdirSync4(VIBEOS_HOME, { recursive: true });
1505
+ mkdirSync3(VIBEOS_HOME, { recursive: true });
1534
1506
  }
1535
1507
  return VIBEOS_HOME;
1536
1508
  } catch {
@@ -1541,7 +1513,7 @@ function _handleStateCorruption2(path) {
1541
1513
  _ensureVibeOSHomeDir();
1542
1514
  const backupDir = join4(VIBEOS_HOME, ".backups");
1543
1515
  try {
1544
- mkdirSync4(backupDir, { recursive: true });
1516
+ mkdirSync3(backupDir, { recursive: true });
1545
1517
  } catch {
1546
1518
  }
1547
1519
  const backupPath = join4(backupDir, basename2(path) + ".corrupted." + Date.now());
@@ -1568,10 +1540,10 @@ function withFileLock(filePath, fn, opts = {}) {
1568
1540
  const start = Date.now();
1569
1541
  while (Date.now() - start < timeoutMs) {
1570
1542
  try {
1571
- mkdirSync4(FILE_LOCK_DIR, { recursive: true });
1543
+ mkdirSync3(FILE_LOCK_DIR, { recursive: true });
1572
1544
  const fd = openSync(lockPath, "wx");
1573
1545
  try {
1574
- writeFileSync5(fd, `${process.pid}
1546
+ writeFileSync4(fd, `${process.pid}
1575
1547
  ${Date.now()}
1576
1548
  `);
1577
1549
  } catch {
@@ -1676,9 +1648,9 @@ function updateState(mutator) {
1676
1648
  state._gen = preGen + 1;
1677
1649
  const next = mutator(state) ?? state;
1678
1650
  validateState(next, delegationStateFile);
1679
- mkdirSync4(dirname4(delegationStateFile), { recursive: true });
1651
+ mkdirSync3(dirname4(delegationStateFile), { recursive: true });
1680
1652
  const tmp = delegationStateFile + ".tmp";
1681
- writeFileSync5(tmp, JSON.stringify(next, null, 2) + "\n");
1653
+ writeFileSync4(tmp, JSON.stringify(next, null, 2) + "\n");
1682
1654
  renameSync3(tmp, delegationStateFile);
1683
1655
  invalidateSavingsCache();
1684
1656
  return next;
@@ -1767,9 +1739,9 @@ function updateGlobalLearning(mutator) {
1767
1739
  const s = loadGlobalLearning();
1768
1740
  const next = mutator(s) ?? s;
1769
1741
  next.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1770
- mkdirSync4(dirname4(globalLearningFile), { recursive: true });
1742
+ mkdirSync3(dirname4(globalLearningFile), { recursive: true });
1771
1743
  const tmp = globalLearningFile + ".tmp";
1772
- writeFileSync5(tmp, JSON.stringify(next, null, 2));
1744
+ writeFileSync4(tmp, JSON.stringify(next, null, 2));
1773
1745
  renameSync3(tmp, globalLearningFile);
1774
1746
  return next;
1775
1747
  });
@@ -1857,9 +1829,9 @@ function saveBlackboxState(state) {
1857
1829
  continue;
1858
1830
  next.sessions[sid] = normalizeBlackboxRecord(session, sid, now).record;
1859
1831
  }
1860
- mkdirSync4(dirname4(blackboxFile), { recursive: true });
1832
+ mkdirSync3(dirname4(blackboxFile), { recursive: true });
1861
1833
  const tmp = blackboxFile + ".tmp";
1862
- writeFileSync5(tmp, JSON.stringify(next, null, 2) + "\n");
1834
+ writeFileSync4(tmp, JSON.stringify(next, null, 2) + "\n");
1863
1835
  renameSync3(tmp, blackboxFile);
1864
1836
  } catch (err) {
1865
1837
  console.error(`[vibeOS] saveBlackboxState failed: ${err.message}`);
@@ -1954,7 +1926,7 @@ function getGlobalIndexPath() {
1954
1926
  }
1955
1927
  function ensureSessionScratchpadDirs() {
1956
1928
  try {
1957
- mkdirSync4(getSessionScratchpadDir(), { recursive: true });
1929
+ mkdirSync3(getSessionScratchpadDir(), { recursive: true });
1958
1930
  return true;
1959
1931
  } catch {
1960
1932
  return false;
@@ -2146,8 +2118,8 @@ function indexAppend(hash, tool2, size, extra) {
2146
2118
  const entry = JSON.stringify(entryObj) + "\n";
2147
2119
  const globalIndex = getGlobalIndexPath();
2148
2120
  const sessionIndex = getSessionIndexPath();
2149
- mkdirSync4(dirname4(globalIndex), { recursive: true });
2150
- mkdirSync4(dirname4(sessionIndex), { recursive: true });
2121
+ mkdirSync3(dirname4(globalIndex), { recursive: true });
2122
+ mkdirSync3(dirname4(sessionIndex), { recursive: true });
2151
2123
  appendFileSync2(globalIndex, entry);
2152
2124
  appendFileSync2(sessionIndex, entry);
2153
2125
  } catch (err) {
@@ -2319,13 +2291,13 @@ function _pruneScratchpadDir(targetDir, opts = {}) {
2319
2291
  if (!existsSync5(summaryPath))
2320
2292
  try {
2321
2293
  const content = readFileSync4(fullPath, "utf-8");
2322
- writeFileSync5(summaryPath, content.slice(0, 200).replace(/\n+/g, " ").trim() + (content.length > 200 ? "\u2026" : ""));
2294
+ writeFileSync4(summaryPath, content.slice(0, 200).replace(/\n+/g, " ").trim() + (content.length > 200 ? "\u2026" : ""));
2323
2295
  } catch {
2324
2296
  }
2325
2297
  const head = _readHead(fullPath);
2326
2298
  if (!head.includes("[cold-storage]"))
2327
2299
  try {
2328
- writeFileSync5(fullPath, `[cold-storage] ${st.size}B original \u2192 ${hash}.summary.txt`);
2300
+ writeFileSync4(fullPath, `[cold-storage] ${st.size}B original \u2192 ${hash}.summary.txt`);
2329
2301
  rotated++;
2330
2302
  } catch {
2331
2303
  }
@@ -2336,13 +2308,13 @@ function _pruneScratchpadDir(targetDir, opts = {}) {
2336
2308
  if (!existsSync5(summaryPath))
2337
2309
  try {
2338
2310
  const content = readFileSync4(fullPath, "utf-8");
2339
- writeFileSync5(summaryPath, content.slice(0, SUMMARY_HEAD_TRUNCATE).replace(/\n+/g, " ").trim() + (content.length > SUMMARY_HEAD_TRUNCATE ? "\u2026" : ""));
2311
+ writeFileSync4(summaryPath, content.slice(0, SUMMARY_HEAD_TRUNCATE).replace(/\n+/g, " ").trim() + (content.length > SUMMARY_HEAD_TRUNCATE ? "\u2026" : ""));
2340
2312
  } catch {
2341
2313
  }
2342
2314
  const head = _readHead(fullPath);
2343
2315
  if (!head.includes("[warm-storage]") && !head.includes("[cold-storage]"))
2344
2316
  try {
2345
- writeFileSync5(fullPath, `[warm-storage] ${st.size}B original at ${hash}.summary.txt`);
2317
+ writeFileSync4(fullPath, `[warm-storage] ${st.size}B original at ${hash}.summary.txt`);
2346
2318
  rotated++;
2347
2319
  } catch {
2348
2320
  }
@@ -2414,9 +2386,9 @@ function _readActiveJobsRaw() {
2414
2386
  }
2415
2387
  function _writeActiveJobsRaw(jobs) {
2416
2388
  try {
2417
- mkdirSync4(dirname4(ACTIVE_JOBS_FILE), { recursive: true });
2389
+ mkdirSync3(dirname4(ACTIVE_JOBS_FILE), { recursive: true });
2418
2390
  const tmp = ACTIVE_JOBS_FILE + ".tmp";
2419
- writeFileSync5(tmp, JSON.stringify(jobs, null, 2) + "\n");
2391
+ writeFileSync4(tmp, JSON.stringify(jobs, null, 2) + "\n");
2420
2392
  renameSync3(tmp, ACTIVE_JOBS_FILE);
2421
2393
  } catch {
2422
2394
  }
@@ -2524,9 +2496,9 @@ function saveProjectState(state) {
2524
2496
  const projectStateFile = join4(getVibeOSHome3(), "project-states.json");
2525
2497
  try {
2526
2498
  withFileLock(projectStateFile, () => {
2527
- mkdirSync4(dirname4(projectStateFile), { recursive: true });
2499
+ mkdirSync3(dirname4(projectStateFile), { recursive: true });
2528
2500
  const _tmp = projectStateFile + ".tmp." + Date.now();
2529
- writeFileSync5(_tmp, JSON.stringify(state, null, 2) + "\n", "utf-8");
2501
+ writeFileSync4(_tmp, JSON.stringify(state, null, 2) + "\n", "utf-8");
2530
2502
  renameSync3(_tmp, projectStateFile);
2531
2503
  });
2532
2504
  } catch (err) {
@@ -2817,9 +2789,9 @@ function loadTodos() {
2817
2789
  }
2818
2790
  function saveTodos(todos) {
2819
2791
  try {
2820
- mkdirSync4(dirname4(TODOS_FILE), { recursive: true });
2792
+ mkdirSync3(dirname4(TODOS_FILE), { recursive: true });
2821
2793
  const tmp = TODOS_FILE + ".tmp." + Date.now();
2822
- writeFileSync5(tmp, JSON.stringify(todos, null, 2), "utf-8");
2794
+ writeFileSync4(tmp, JSON.stringify(todos, null, 2), "utf-8");
2823
2795
  renameSync3(tmp, TODOS_FILE);
2824
2796
  } catch {
2825
2797
  }
@@ -2900,7 +2872,7 @@ function _compactSavingsLedgerIfNeeded() {
2900
2872
  const compacted = kept.reverse().join("\n") + "\n";
2901
2873
  if (compacted.trim() && compacted !== raw) {
2902
2874
  const tmp = SAVINGS_LEDGER_FILE + ".tmp." + Date.now();
2903
- writeFileSync5(tmp, compacted, "utf-8");
2875
+ writeFileSync4(tmp, compacted, "utf-8");
2904
2876
  renameSync3(tmp, SAVINGS_LEDGER_FILE);
2905
2877
  }
2906
2878
  }, { timeoutMs: 4e3 });
@@ -3098,9 +3070,9 @@ function saveSessionCheckpoint() {
3098
3070
  model: session.model || ""
3099
3071
  };
3100
3072
  const cpPath = join4(getSessionRoot(), "checkpoint.json");
3101
- mkdirSync4(dirname4(cpPath), { recursive: true });
3073
+ mkdirSync3(dirname4(cpPath), { recursive: true });
3102
3074
  const tmp = cpPath + ".tmp";
3103
- writeFileSync5(tmp, JSON.stringify(cp, null, 2) + "\n");
3075
+ writeFileSync4(tmp, JSON.stringify(cp, null, 2) + "\n");
3104
3076
  renameSync3(tmp, cpPath);
3105
3077
  } catch {
3106
3078
  }
@@ -3454,7 +3426,7 @@ var init_meta_controller = __esm({
3454
3426
  });
3455
3427
 
3456
3428
  // src/vibeOS-lib/blackbox/pivot-cache.js
3457
- import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "node:fs";
3429
+ import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "node:fs";
3458
3430
  import { join as join6, dirname as dirname6 } from "node:path";
3459
3431
  import { homedir as homedir5 } from "node:os";
3460
3432
  var PivotCache;
@@ -3492,8 +3464,8 @@ var init_pivot_cache = __esm({
3492
3464
  const p = this._storePath();
3493
3465
  const dir = dirname6(p);
3494
3466
  if (!existsSync7(dir))
3495
- mkdirSync6(dir, { recursive: true });
3496
- writeFileSync7(p, JSON.stringify(this.store, null, 2), "utf-8");
3467
+ mkdirSync5(dir, { recursive: true });
3468
+ writeFileSync6(p, JSON.stringify(this.store, null, 2), "utf-8");
3497
3469
  } catch {
3498
3470
  }
3499
3471
  }
@@ -3663,7 +3635,7 @@ __export(vibemax_exports, {
3663
3635
  vibemaxPipeline: () => vibemaxPipeline,
3664
3636
  vibemaxSelectMode: () => vibemaxSelectMode
3665
3637
  });
3666
- import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync7, writeFileSync as writeFileSync8 } from "node:fs";
3638
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
3667
3639
  import { resolve as resolve2, dirname as dirname7 } from "node:path";
3668
3640
  import { fileURLToPath as fileURLToPath4 } from "node:url";
3669
3641
  function fallback(sr, text) {
@@ -3945,8 +3917,8 @@ function loadVibeMaXModel() {
3945
3917
  return null;
3946
3918
  }
3947
3919
  function saveVibeMaXModel(model) {
3948
- mkdirSync7(dirname7(MODEL_PATH), { recursive: true });
3949
- writeFileSync8(MODEL_PATH, JSON.stringify(model, null, 2) + "\n", "utf-8");
3920
+ mkdirSync6(dirname7(MODEL_PATH), { recursive: true });
3921
+ writeFileSync7(MODEL_PATH, JSON.stringify(model, null, 2) + "\n", "utf-8");
3950
3922
  }
3951
3923
  function getVibeMaXModelMeta() {
3952
3924
  const m = loadVibeMaXModel();
@@ -4114,7 +4086,7 @@ var init_vibeultrax = __esm({
4114
4086
 
4115
4087
  // src/index.ts
4116
4088
  init_flow_enforcer();
4117
- import { readFileSync as readFileSync17, writeFileSync as writeFileSync16, existsSync as existsSync18, mkdirSync as mkdirSync14, copyFileSync as copyFileSync2, renameSync as renameSync6, statSync as statSync9 } from "node:fs";
4089
+ import { readFileSync as readFileSync17, writeFileSync as writeFileSync15, existsSync as existsSync18, mkdirSync as mkdirSync13, copyFileSync as copyFileSync2, renameSync as renameSync6, statSync as statSync9 } from "node:fs";
4118
4090
  import { join as join18, dirname as dirname13, basename as basename5 } from "node:path";
4119
4091
 
4120
4092
  // src/vibeOS-lib/session-metrics.js
@@ -4260,7 +4232,7 @@ function computeSessionMetrics(state, sessionId) {
4260
4232
  // src/lib/vibeos-mcp-server.js
4261
4233
  import http from "node:http";
4262
4234
  import { parse as parseUrl } from "node:url";
4263
- import { createReadStream, existsSync as existsSync2, mkdirSync as mkdirSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
4235
+ import { createReadStream, existsSync as existsSync2, statSync as statSync2 } from "node:fs";
4264
4236
  import { extname, join as join2, dirname as dirname2 } from "node:path";
4265
4237
  import { fileURLToPath as fileURLToPath2 } from "node:url";
4266
4238
  var MIME_MAP = {
@@ -4306,9 +4278,7 @@ var _MCP_FILENAME = fileURLToPath2(import.meta.url);
4306
4278
  var _MCP_DIR = dirname2(_MCP_FILENAME);
4307
4279
  function resolveDashboardDir() {
4308
4280
  const c = [
4309
- join2(_MCP_DIR, "dashboard", "dist"),
4310
- join2(_MCP_DIR, "assets", "dashboard"),
4311
- join2(_MCP_DIR, "assets", "dashboard", "dist")
4281
+ join2(_MCP_DIR, "dashboard", "dist")
4312
4282
  ];
4313
4283
  for (const p of c) {
4314
4284
  if (existsSync2(join2(p, "index.html")))
@@ -4317,20 +4287,6 @@ function resolveDashboardDir() {
4317
4287
  return c[0];
4318
4288
  }
4319
4289
  var DASHBOARD_DIR = resolveDashboardDir();
4320
- var DASHBOARD_CONFIG_PATH = join2(DASHBOARD_DIR, "vibeos-dashboard-config.js");
4321
- function writeDashboardBaseConfig(baseUrl) {
4322
- try {
4323
- if (!baseUrl)
4324
- return null;
4325
- mkdirSync2(DASHBOARD_DIR, { recursive: true });
4326
- const payload = `window.__VIBEOS_DASHBOARD_BASE__ = ${JSON.stringify(baseUrl.replace(/\/$/, ""))};
4327
- `;
4328
- writeFileSync2(DASHBOARD_CONFIG_PATH, payload, "utf-8");
4329
- return DASHBOARD_CONFIG_PATH;
4330
- } catch {
4331
- return null;
4332
- }
4333
- }
4334
4290
  function resolveBackendHealthUrl() {
4335
4291
  const explicit = process.env.VIBEOS_BACKEND_HEALTH_URL?.trim();
4336
4292
  if (explicit)
@@ -4657,7 +4613,7 @@ function createMcpServer(deps) {
4657
4613
 
4658
4614
  // src/lib/api-client.js
4659
4615
  init_runtime_state();
4660
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync3, existsSync as existsSync3, mkdirSync as mkdirSync3, rmSync } from "node:fs";
4616
+ import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync3, mkdirSync as mkdirSync2, rmSync } from "node:fs";
4661
4617
  import { dirname as dirname3 } from "node:path";
4662
4618
  import { fileURLToPath as fileURLToPath3 } from "node:url";
4663
4619
  import { homedir } from "node:os";
@@ -4665,11 +4621,9 @@ var DEFAULT_API_URL = "https://api.vibetheog.com";
4665
4621
  var EMBEDDED_API_TOKEN = "vos_8d73804b13bb46711b9a47f036dba7b4d026fd9583d96960e663716e62815a69";
4666
4622
  var API_TOKEN_RE = /^vos_[a-f0-9]{64}$/i;
4667
4623
  var API_DISABLED_RE = /^(1|true|yes|on)$/i;
4668
- var IS_TEST_RUNTIME = process.env.VIBEOS_TEST_MODE === "1" || process.env.NODE_ENV === "test" || process.env.CI === "true";
4669
- var REQUEST_TIMEOUT = IS_TEST_RUNTIME ? 2e3 : 1e4;
4670
- var MAX_RETRIES = IS_TEST_RUNTIME ? 1 : 3;
4671
- var BASE_RETRY_DELAY = IS_TEST_RUNTIME ? 100 : 1e3;
4672
- var PROBE_TIMEOUT = IS_TEST_RUNTIME ? 2e3 : 5e3;
4624
+ var REQUEST_TIMEOUT = 1e4;
4625
+ var MAX_RETRIES = 3;
4626
+ var BASE_RETRY_DELAY = 1e3;
4673
4627
  var ALPHA_BUILD_CHANNEL = String(process.env.VIBEOS_BUILD_CHANNEL || "alpha").toLowerCase();
4674
4628
  var BOOTSTRAP_EXCHANGE_PATH = "/api/v1/auth/bootstrap/exchange";
4675
4629
  var BOOTSTRAP_RETRY_COOLDOWN_MS = 6e4;
@@ -4805,8 +4759,8 @@ function persistPrimaryApiEnvState(next) {
4805
4759
  }
4806
4760
  const parentDir = _envPaths[0];
4807
4761
  if (!existsSync3(parentDir))
4808
- mkdirSync3(parentDir, { recursive: true });
4809
- writeFileSync3(primaryPath, envContent.endsWith("\n") ? envContent : envContent + "\n", "utf8");
4762
+ mkdirSync2(parentDir, { recursive: true });
4763
+ writeFileSync2(primaryPath, envContent.endsWith("\n") ? envContent : envContent + "\n", "utf8");
4810
4764
  } catch (diskErr) {
4811
4765
  console.error("[vibeOS] Failed to persist API env state:", diskErr.message);
4812
4766
  }
@@ -5135,6 +5089,16 @@ function readTokenFromDisk() {
5135
5089
  }
5136
5090
  return "";
5137
5091
  }
5092
+ function hasPrimaryTokenOnDisk() {
5093
+ if (readApiDisabledFromDisk())
5094
+ return false;
5095
+ try {
5096
+ const env = readFileSync2(_envPaths[0] + "/.env.production", "utf8");
5097
+ return /^VIBEOS_API_TOKEN=/m.test(env);
5098
+ } catch {
5099
+ return false;
5100
+ }
5101
+ }
5138
5102
  function readBootstrapTokenFromDisk() {
5139
5103
  if (readApiDisabledFromDisk())
5140
5104
  return "";
@@ -5148,9 +5112,9 @@ function readBootstrapTokenFromDisk() {
5148
5112
  return "";
5149
5113
  }
5150
5114
  var VIBEOS_API_DISABLED = readApiDisabledFromDisk() || isTruthyFlag(process.env.VIBEOS_API_DISABLED);
5151
- var VIBEOS_API_TOKEN = VIBEOS_API_DISABLED ? "" : readTokenFromDisk() || normalizeDirectApiToken(process.env.VIBEOS_API_TOKEN);
5115
+ var VIBEOS_API_TOKEN = VIBEOS_API_DISABLED ? "" : readTokenFromDisk() || normalizeDirectApiToken(process.env.VIBEOS_API_TOKEN) || (!hasPrimaryTokenOnDisk() ? EMBEDDED_API_TOKEN : "");
5152
5116
  var VIBEOS_API_BOOTSTRAP_TOKEN = VIBEOS_API_DISABLED ? "" : readBootstrapTokenFromDisk() || process.env.VIBEOS_API_BOOTSTRAP_TOKEN || EMBEDDED_API_TOKEN;
5153
- setApiEnabled(!VIBEOS_API_DISABLED && process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN));
5117
+ var VIBEOS_API_ENABLED = !VIBEOS_API_DISABLED && process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
5154
5118
  var _anomalyDetector = null;
5155
5119
  function getAnomalyDetector() {
5156
5120
  if (!_anomalyDetector)
@@ -5170,8 +5134,8 @@ function persistBootstrapToken(token) {
5170
5134
  }
5171
5135
  const parentDir = _envPaths[0];
5172
5136
  if (!existsSync3(parentDir))
5173
- mkdirSync3(parentDir, { recursive: true });
5174
- writeFileSync3(_bootstrapEnvPath, `VIBEOS_API_BOOTSTRAP_TOKEN=${clean}
5137
+ mkdirSync2(parentDir, { recursive: true });
5138
+ writeFileSync2(_bootstrapEnvPath, `VIBEOS_API_BOOTSTRAP_TOKEN=${clean}
5175
5139
  `, "utf8");
5176
5140
  } catch (diskErr) {
5177
5141
  console.error("[vibeOS] Failed to persist alpha bootstrap token:", diskErr.message);
@@ -5182,10 +5146,10 @@ function setApiToken(newToken) {
5182
5146
  VIBEOS_API_DISABLED = false;
5183
5147
  VIBEOS_API_TOKEN = normalizeDirectApiToken(newToken);
5184
5148
  VIBEOS_API_BOOTSTRAP_TOKEN = readBootstrapTokenFromDisk() || VIBEOS_API_BOOTSTRAP_TOKEN;
5185
- setApiEnabled(process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN));
5149
+ VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
5186
5150
  _apiClient = null;
5187
- setApiFallbackMode(false);
5188
- setApiFallbackSince(null);
5151
+ _apiFallbackMode = false;
5152
+ _apiFallbackSince = null;
5189
5153
  persistPrimaryApiEnvState({ token: VIBEOS_API_TOKEN, disabled: false });
5190
5154
  if (_anomalyDetector)
5191
5155
  _anomalyDetector.reset();
@@ -5200,10 +5164,10 @@ function invalidateApiToken() {
5200
5164
  VIBEOS_API_DISABLED = true;
5201
5165
  VIBEOS_API_TOKEN = "";
5202
5166
  VIBEOS_API_BOOTSTRAP_TOKEN = "";
5203
- setApiEnabled(false);
5167
+ VIBEOS_API_ENABLED = false;
5204
5168
  _apiClient = null;
5205
- setApiFallbackMode(false);
5206
- setApiFallbackSince(null);
5169
+ _apiFallbackMode = false;
5170
+ _apiFallbackSince = null;
5207
5171
  if (_anomalyDetector)
5208
5172
  _anomalyDetector.reset();
5209
5173
  persistBootstrapToken("");
@@ -5218,7 +5182,7 @@ function setApiBootstrapToken(newToken) {
5218
5182
  try {
5219
5183
  VIBEOS_API_DISABLED = false;
5220
5184
  VIBEOS_API_BOOTSTRAP_TOKEN = String(newToken || "").trim();
5221
- setApiEnabled(process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN));
5185
+ VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
5222
5186
  persistPrimaryApiEnvState({ disabled: false });
5223
5187
  persistBootstrapToken(VIBEOS_API_BOOTSTRAP_TOKEN);
5224
5188
  console.error("[vibeOS] Alpha bootstrap token updated");
@@ -5227,27 +5191,24 @@ function setApiBootstrapToken(newToken) {
5227
5191
  }
5228
5192
  }
5229
5193
  var _apiClient = null;
5230
- var _startupProbeDone = false;
5194
+ var _apiFallbackMode = false;
5195
+ var _apiFallbackSince = null;
5231
5196
  var _bootstrapExchangeInFlight = null;
5232
5197
  var _bootstrapExchangeFailedAt = 0;
5233
5198
  var _backendVersion = "";
5234
5199
  var FALLBACK_COOLDOWN_MS = 6e4;
5235
5200
  function tryResetFallbackCooldown() {
5236
- if (!isApiFallbackMode() || !getApiFallbackSince())
5201
+ if (!_apiFallbackMode || !_apiFallbackSince)
5237
5202
  return false;
5238
- const elapsed = Date.now() - new Date(getApiFallbackSince()).getTime();
5203
+ const elapsed = Date.now() - new Date(_apiFallbackSince).getTime();
5239
5204
  if (elapsed > FALLBACK_COOLDOWN_MS) {
5240
- setApiFallbackMode(false);
5241
- setApiFallbackSince(null);
5205
+ _apiFallbackMode = false;
5206
+ _apiFallbackSince = null;
5242
5207
  markApiConnected();
5243
5208
  return true;
5244
5209
  }
5245
5210
  return false;
5246
5211
  }
5247
- function denyReconnection(detail) {
5248
- setApiFallbackSince((/* @__PURE__ */ new Date()).toISOString());
5249
- console.warn(`[vibeOS] API health probe failed during reconnect: ${detail} \u2014 staying in fallback`);
5250
- }
5251
5212
  function recordBackendVersion(payload) {
5252
5213
  if (!payload || typeof payload !== "object")
5253
5214
  return;
@@ -5274,7 +5235,7 @@ async function ensureBootstrapExchange() {
5274
5235
  try {
5275
5236
  const client2 = new VibeOSApiClient({
5276
5237
  baseUrl: VIBEOS_API_URL,
5277
- timeout: PROBE_TIMEOUT
5238
+ timeout: 5e3
5278
5239
  });
5279
5240
  const apiToken = await client2.exchangeBootstrapToken(VIBEOS_API_BOOTSTRAP_TOKEN, ALPHA_BUILD_CHANNEL);
5280
5241
  if (!apiToken)
@@ -5298,14 +5259,14 @@ function syncApiTokenFromDisk() {
5298
5259
  const diskBootstrapToken = readBootstrapTokenFromDisk() || "";
5299
5260
  const envToken = normalizeDirectApiToken(process.env.VIBEOS_API_TOKEN);
5300
5261
  if (diskDisabled) {
5301
- if (!VIBEOS_API_DISABLED || VIBEOS_API_TOKEN || VIBEOS_API_BOOTSTRAP_TOKEN || isApiEnabled()) {
5262
+ if (!VIBEOS_API_DISABLED || VIBEOS_API_TOKEN || VIBEOS_API_BOOTSTRAP_TOKEN || VIBEOS_API_ENABLED) {
5302
5263
  VIBEOS_API_DISABLED = true;
5303
5264
  VIBEOS_API_TOKEN = "";
5304
5265
  VIBEOS_API_BOOTSTRAP_TOKEN = "";
5305
- setApiEnabled(false);
5266
+ VIBEOS_API_ENABLED = false;
5306
5267
  _apiClient = null;
5307
- setApiFallbackMode(false);
5308
- setApiFallbackSince(null);
5268
+ _apiFallbackMode = false;
5269
+ _apiFallbackSince = null;
5309
5270
  resetApiConnection();
5310
5271
  console.error("[vibeOS] API token disabled from disk (alpha kill switch active)");
5311
5272
  }
@@ -5314,107 +5275,69 @@ function syncApiTokenFromDisk() {
5314
5275
  if (diskToken && diskToken !== VIBEOS_API_TOKEN) {
5315
5276
  VIBEOS_API_DISABLED = false;
5316
5277
  VIBEOS_API_TOKEN = diskToken;
5317
- setApiEnabled(process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN));
5278
+ VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
5318
5279
  _apiClient = null;
5319
- setApiFallbackMode(false);
5320
- setApiFallbackSince(null);
5280
+ _apiFallbackMode = false;
5281
+ _apiFallbackSince = null;
5321
5282
  resetApiConnection();
5322
5283
  console.error("[vibeOS] API token synced from disk (disk is newer)");
5323
5284
  } else if (diskBootstrapToken && diskBootstrapToken !== VIBEOS_API_BOOTSTRAP_TOKEN) {
5324
5285
  VIBEOS_API_DISABLED = false;
5325
5286
  VIBEOS_API_BOOTSTRAP_TOKEN = diskBootstrapToken;
5326
- setApiEnabled(process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN));
5327
- setApiFallbackMode(false);
5328
- setApiFallbackSince(null);
5287
+ VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
5288
+ _apiFallbackMode = false;
5289
+ _apiFallbackSince = null;
5329
5290
  resetApiConnection();
5330
5291
  console.error("[vibeOS] Alpha bootstrap token synced from disk (disk is newer)");
5331
5292
  } else if (!diskToken && VIBEOS_API_TOKEN) {
5332
5293
  persistPrimaryApiEnvState({ token: VIBEOS_API_TOKEN, disabled: false });
5333
5294
  console.error("[vibeOS] API token persisted to disk from memory (disk was empty)");
5334
- setApiEnabled(process.env.VIBEOS_API_ENABLED !== "false" && !!VIBEOS_API_TOKEN);
5295
+ VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && !!VIBEOS_API_TOKEN;
5335
5296
  } else if (envToken && !diskToken && !VIBEOS_API_TOKEN) {
5336
5297
  VIBEOS_API_DISABLED = false;
5337
5298
  VIBEOS_API_TOKEN = envToken;
5338
- setApiEnabled(process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN));
5299
+ VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
5339
5300
  console.error("[vibeOS] API token loaded from VIBEOS_API_TOKEN env var");
5340
5301
  } else {
5341
5302
  VIBEOS_API_DISABLED = false;
5303
+ if (!VIBEOS_API_TOKEN && !hasPrimaryTokenOnDisk()) {
5304
+ VIBEOS_API_TOKEN = EMBEDDED_API_TOKEN;
5305
+ }
5342
5306
  VIBEOS_API_BOOTSTRAP_TOKEN ||= EMBEDDED_API_TOKEN;
5343
- setApiEnabled(process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN));
5307
+ VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
5344
5308
  }
5345
5309
  }
5346
5310
  function getApiClient2() {
5347
5311
  syncApiTokenFromDisk();
5348
- if (!_apiClient && isApiEnabled() && VIBEOS_API_TOKEN) {
5312
+ if (!_apiClient && VIBEOS_API_ENABLED && VIBEOS_API_TOKEN) {
5349
5313
  _apiClient = new VibeOSApiClient({
5350
5314
  baseUrl: VIBEOS_API_URL,
5351
5315
  apiToken: VIBEOS_API_TOKEN,
5352
- timeout: PROBE_TIMEOUT
5316
+ timeout: 5e3
5353
5317
  });
5354
5318
  }
5355
5319
  return _apiClient;
5356
5320
  }
5357
5321
  function isApiFallback2() {
5358
- return isApiFallbackMode() || !isApiEnabled();
5322
+ return _apiFallbackMode || !VIBEOS_API_ENABLED;
5359
5323
  }
5360
- function isApiConnected2() {
5324
+ function isApiConnected() {
5361
5325
  tryResetFallbackCooldown();
5362
- return isApiConnected();
5326
+ return VIBEOS_API_ENABLED;
5363
5327
  }
5364
5328
  function getBackendVersion() {
5365
5329
  return _backendVersion;
5366
5330
  }
5367
- function getApiFallbackSince2() {
5368
- return getApiFallbackSince();
5369
- }
5370
5331
  async function remoteCall(method, args, fallbackFn) {
5371
- if (!_startupProbeDone && !isApiFallbackMode()) {
5372
- _startupProbeDone = true;
5373
- try {
5374
- syncApiTokenFromDisk();
5375
- if (isApiEnabled()) {
5376
- const probeClient = getApiClient2();
5377
- if (probeClient) {
5378
- await probeClient.health();
5379
- markApiConnected();
5380
- }
5381
- }
5382
- } catch {
5383
- }
5384
- }
5385
5332
  syncApiTokenFromDisk();
5386
5333
  if (!VIBEOS_API_TOKEN && VIBEOS_API_BOOTSTRAP_TOKEN) {
5387
5334
  await ensureBootstrapExchange();
5388
5335
  syncApiTokenFromDisk();
5389
- if (VIBEOS_API_TOKEN)
5390
- markApiConnected();
5391
5336
  }
5392
- if (isApiFallbackMode() && getApiFallbackSince()) {
5393
- const elapsed = Date.now() - new Date(getApiFallbackSince()).getTime();
5394
- if (elapsed > FALLBACK_COOLDOWN_MS) {
5395
- try {
5396
- const probeClient = getApiClient2();
5397
- if (probeClient) {
5398
- await probeClient.health();
5399
- markApiConnected();
5400
- } else {
5401
- denyReconnection("no client");
5402
- if (fallbackFn)
5403
- return fallbackFn();
5404
- return null;
5405
- }
5406
- } catch (probeErr) {
5407
- const probeStatus = probeErr?.statusCode || probeErr?.status || 0;
5408
- const probeBody = probeErr?.response?.body || probeErr?.body || "";
5409
- const probePreview = typeof probeBody === "string" ? probeBody.substring(0, 80) : String(probeBody).substring(0, 80);
5410
- denyReconnection(probeStatus ? `status=${probeStatus} body=${probePreview}` : `message=${probeErr?.message || probeErr}`);
5411
- if (fallbackFn)
5412
- return fallbackFn();
5413
- return null;
5414
- }
5415
- }
5337
+ if (tryResetFallbackCooldown()) {
5338
+ console.warn("[vibeOS] API fallback cooldown expired \u2014 retrying API");
5416
5339
  }
5417
- if (!isApiEnabled() || isApiFallbackMode()) {
5340
+ if (!VIBEOS_API_ENABLED || _apiFallbackMode) {
5418
5341
  if (fallbackFn)
5419
5342
  return fallbackFn();
5420
5343
  return null;
@@ -5436,12 +5359,13 @@ async function remoteCall(method, args, fallbackFn) {
5436
5359
  const result = await client2[method](...args);
5437
5360
  if (method === "health")
5438
5361
  recordBackendVersion(result);
5439
- if (isApiFallbackMode()) {
5440
- setApiFallbackMode(false);
5441
- setApiFallbackSince(null);
5362
+ if (_apiFallbackMode) {
5363
+ _apiFallbackMode = false;
5364
+ _apiFallbackSince = null;
5365
+ console.warn(`[vibeOS] API reconnected \u2014 ${method} OK`);
5442
5366
  }
5443
- setApiFallbackMode(false);
5444
- setApiFallbackSince(null);
5367
+ _apiFallbackMode = false;
5368
+ _apiFallbackSince = null;
5445
5369
  markApiConnected();
5446
5370
  return result;
5447
5371
  } catch (err) {
@@ -5449,9 +5373,9 @@ async function remoteCall(method, args, fallbackFn) {
5449
5373
  const body = err?.response?.body || err?.body || "";
5450
5374
  const bodyPreview = typeof body === "string" ? body.substring(0, 120) : String(body).substring(0, 120);
5451
5375
  const detail = status ? `status=${status} body=${bodyPreview}` : `message=${err?.message || err}`;
5452
- if (!isApiFallbackMode()) {
5453
- setApiFallbackMode(true);
5454
- setApiFallbackSince((/* @__PURE__ */ new Date()).toISOString());
5376
+ if (!_apiFallbackMode) {
5377
+ _apiFallbackMode = true;
5378
+ _apiFallbackSince = (/* @__PURE__ */ new Date()).toISOString();
5455
5379
  console.error(`[vibeOS] API fallback activated (${method}): ${detail}`);
5456
5380
  }
5457
5381
  if (status === 401 || status === 403) {
@@ -5472,7 +5396,7 @@ async function remoteCall(method, args, fallbackFn) {
5472
5396
 
5473
5397
  // src/lib/pricing.js
5474
5398
  init_state();
5475
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync6, existsSync as existsSync6, mkdirSync as mkdirSync5, statSync as statSync5, renameSync as renameSync4, openSync as openSync2, closeSync as closeSync2, rmSync as rmSync3, readdirSync as readdirSync2 } from "node:fs";
5399
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, existsSync as existsSync6, mkdirSync as mkdirSync4, statSync as statSync5, renameSync as renameSync4, openSync as openSync2, closeSync as closeSync2, rmSync as rmSync3, readdirSync as readdirSync2 } from "node:fs";
5476
5400
  import { join as join5, dirname as dirname5, resolve } from "node:path";
5477
5401
  import { homedir as homedir4, tmpdir as tmpdir3 } from "node:os";
5478
5402
  import { createHash as createHash2 } from "node:crypto";
@@ -5519,10 +5443,10 @@ function withFileLock2(filePath, fn, opts = {}) {
5519
5443
  const start = Date.now();
5520
5444
  while (Date.now() - start < timeoutMs) {
5521
5445
  try {
5522
- mkdirSync5(join5(getVibeOSHome4(), ".vibeOS-locks"), { recursive: true });
5446
+ mkdirSync4(join5(getVibeOSHome4(), ".vibeOS-locks"), { recursive: true });
5523
5447
  const fd = openSync2(lockPath, "wx");
5524
5448
  try {
5525
- writeFileSync6(fd, `${process.pid}
5449
+ writeFileSync5(fd, `${process.pid}
5526
5450
  ${Date.now()}
5527
5451
  `);
5528
5452
  } catch {
@@ -6088,7 +6012,7 @@ function _writeDynamicPricingCache(modelsMap) {
6088
6012
  const PRICING_CACHE_FILE2 = join5(getVibeOSHome4(), "model-pricing-cache.json");
6089
6013
  try {
6090
6014
  withFileLock2(PRICING_CACHE_FILE2, () => {
6091
- mkdirSync5(dirname5(PRICING_CACHE_FILE2), { recursive: true });
6015
+ mkdirSync4(dirname5(PRICING_CACHE_FILE2), { recursive: true });
6092
6016
  let merged = {};
6093
6017
  try {
6094
6018
  if (existsSync6(PRICING_CACHE_FILE2)) {
@@ -6100,7 +6024,7 @@ function _writeDynamicPricingCache(modelsMap) {
6100
6024
  }
6101
6025
  merged = { ...merged, ...modelsMap };
6102
6026
  const tmp = PRICING_CACHE_FILE2 + ".tmp";
6103
- writeFileSync6(tmp, JSON.stringify({
6027
+ writeFileSync5(tmp, JSON.stringify({
6104
6028
  ts: Date.now(),
6105
6029
  source: "dynamic-model-pricing",
6106
6030
  models: merged
@@ -6428,7 +6352,7 @@ function clearWorkspaceFollowupPauseForSession(sessionId = "") {
6428
6352
  if (!touched)
6429
6353
  continue;
6430
6354
  outer["workspace:followup"] = JSON.stringify(followup);
6431
- writeFileSync6(file, JSON.stringify(outer, null, 2) + "\n");
6355
+ writeFileSync5(file, JSON.stringify(outer, null, 2) + "\n");
6432
6356
  changed = true;
6433
6357
  } catch {
6434
6358
  }
@@ -6638,7 +6562,7 @@ function _refreshModel(directory3) {
6638
6562
  if (t?.trinity?.[s]?.oc === cfgModel) {
6639
6563
  t.selection.active_slot = s;
6640
6564
  const _tmp = TIERS_FILE3 + ".tmp." + Date.now() + "." + Math.random().toString(36).slice(2, 8);
6641
- writeFileSync6(_tmp, JSON.stringify(t, null, 2) + "\n", "utf-8");
6565
+ writeFileSync5(_tmp, JSON.stringify(t, null, 2) + "\n", "utf-8");
6642
6566
  renameSync4(_tmp, TIERS_FILE3);
6643
6567
  if (DEBUG_INTERNALS)
6644
6568
  console.error(`[vibeOS] model refresh (config fallback): synced active_slot \u2192 ${s}`);
@@ -6665,7 +6589,7 @@ function applySlot2(slot, projectDir = "") {
6665
6589
  return { ok: false, reason: `slot '${slot}' has no oc model` };
6666
6590
  j.selection.active_slot = slot;
6667
6591
  const _tmp = TIERS_FILE3 + ".tmp." + Date.now();
6668
- writeFileSync6(_tmp, JSON.stringify(j, null, 2) + "\n", "utf-8");
6592
+ writeFileSync5(_tmp, JSON.stringify(j, null, 2) + "\n", "utf-8");
6669
6593
  renameSync4(_tmp, TIERS_FILE3);
6670
6594
  const dir = projectDir || process.cwd();
6671
6595
  const localOcConfig = join5(dir, "opencode.json");
@@ -6673,7 +6597,7 @@ function applySlot2(slot, projectDir = "") {
6673
6597
  if (existsSync6(ocConfig)) {
6674
6598
  const oc = safeJsonParse3(readFileSync5(ocConfig, "utf-8"));
6675
6599
  oc.model = ocModel;
6676
- writeFileSync6(ocConfig, JSON.stringify(oc, null, 2) + "\n");
6600
+ writeFileSync5(ocConfig, JSON.stringify(oc, null, 2) + "\n");
6677
6601
  }
6678
6602
  clearWorkspaceFollowupPauseForSession(getCurrentSessionId());
6679
6603
  _refreshModel(dir);
@@ -6685,7 +6609,7 @@ function applySlot2(slot, projectDir = "") {
6685
6609
  }
6686
6610
 
6687
6611
  // src/lib/turn-classify.js
6688
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync9, existsSync as existsSync9, mkdirSync as mkdirSync8, renameSync as renameSync5 } from "node:fs";
6612
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync8, existsSync as existsSync9, mkdirSync as mkdirSync7, renameSync as renameSync5 } from "node:fs";
6689
6613
  import { join as join7, dirname as dirname8 } from "node:path";
6690
6614
 
6691
6615
  // src/vibeOS-lib/blackbox/resolution-tracker.js
@@ -8363,7 +8287,7 @@ function projectStructuredFromText(raw, selection, creditPercent = 0) {
8363
8287
  // src/lib/reporting.js
8364
8288
  init_state();
8365
8289
  init_runtime_state();
8366
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync10, existsSync as existsSync11, mkdirSync as mkdirSync9, statSync as statSync6, rmSync as rmSync4 } from "node:fs";
8290
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync9, existsSync as existsSync11, mkdirSync as mkdirSync8, statSync as statSync6, rmSync as rmSync4 } from "node:fs";
8367
8291
  import { join as join9 } from "node:path";
8368
8292
  function getVibeOSHome7() {
8369
8293
  return process.env.VIBEOS_HOME || join9(process.env.HOME || "", ".claude");
@@ -8405,8 +8329,8 @@ function saveReportsIndex(idx) {
8405
8329
  const reportsIndexPath = getReportsIndexPath();
8406
8330
  const reportsDir = getReportsDir();
8407
8331
  withFileLock(reportsIndexPath, () => {
8408
- mkdirSync9(reportsDir, { recursive: true });
8409
- writeFileSync10(reportsIndexPath, JSON.stringify(idx, null, 2) + "\n");
8332
+ mkdirSync8(reportsDir, { recursive: true });
8333
+ writeFileSync9(reportsIndexPath, JSON.stringify(idx, null, 2) + "\n");
8410
8334
  });
8411
8335
  } catch (err) {
8412
8336
  console.error(`[vibeOS] reports index write failed: ${err.message}`);
@@ -8577,12 +8501,12 @@ function saveReport({ type = "manual", summary = "", findings = null, metrics =
8577
8501
  const reportsIndexPath = getReportsIndexPath();
8578
8502
  const reportsDir = getReportsDir();
8579
8503
  withFileLock(reportsIndexPath, () => {
8580
- mkdirSync9(reportsDir, { recursive: true });
8581
- writeFileSync10(join9(reportsDir, `${id2}.json`), JSON.stringify(report, null, 2) + "\n");
8504
+ mkdirSync8(reportsDir, { recursive: true });
8505
+ writeFileSync9(join9(reportsDir, `${id2}.json`), JSON.stringify(report, null, 2) + "\n");
8582
8506
  const idx = reportsIndex();
8583
8507
  const _sum = (summary || "").slice(0, 80);
8584
8508
  idx.reports.push({ id: id2, type, project: report.meta.project, fingerprint: fp2, created: report.meta.created, summary: _sum });
8585
- writeFileSync10(reportsIndexPath, JSON.stringify(idx, null, 2) + "\n");
8509
+ writeFileSync9(reportsIndexPath, JSON.stringify(idx, null, 2) + "\n");
8586
8510
  });
8587
8511
  try {
8588
8512
  if (fp2 && fp2 !== "unknown") {
@@ -8639,7 +8563,7 @@ function readReport(id2) {
8639
8563
  init_selection_manager();
8640
8564
 
8641
8565
  // src/lib/credit-api.js
8642
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync11, existsSync as existsSync12 } from "node:fs";
8566
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync10, existsSync as existsSync12 } from "node:fs";
8643
8567
  import { join as join10 } from "node:path";
8644
8568
  init_state();
8645
8569
  function getVibeOSHome8() {
@@ -8710,7 +8634,7 @@ async function _snapshot() {
8710
8634
  }
8711
8635
  }
8712
8636
  try {
8713
- writeFileSync11(CREDIT_CACHE_F, JSON.stringify({ total, providers: provs, ts: Date.now() }));
8637
+ writeFileSync10(CREDIT_CACHE_F, JSON.stringify({ total, providers: provs, ts: Date.now() }));
8714
8638
  } catch {
8715
8639
  }
8716
8640
  }
@@ -9120,7 +9044,7 @@ function createTrinityTool(deps) {
9120
9044
  `Model: ${activeSlot} (${tiers?.[activeSlot]?.oc || deps.currentModel || "(unset)"})`,
9121
9045
  `Provider: ${execution.provider_label}`,
9122
9046
  `Quality: ${execution.quality_label}`,
9123
- ...isApiConnected2() ? [`Backend: connected${getBackendVersion() ? ` (${getBackendVersion()})` : ""}`] : [`Backend: offline`],
9047
+ ...isApiConnected() ? [`Backend: connected${getBackendVersion() ? ` (${getBackendVersion()})` : ""}`] : [`Backend: offline`],
9124
9048
  ...sel.requested_optimization_mode ? [`Requested mode: ${sel.requested_optimization_mode}`] : [],
9125
9049
  ...totalTurns > 0 ? [`Split: brain ${brainPct}% / worker ${workerPct}% (${totalTurns} total)`] : [],
9126
9050
  `Thinking: ${effectiveLevel}`,
@@ -10586,12 +10510,12 @@ async function probeModel(modelId, auth, providers = null) {
10586
10510
  }
10587
10511
 
10588
10512
  // src/lib/hooks/footer.js
10589
- import { readFileSync as readFileSync14, appendFileSync as appendFileSync4, mkdirSync as mkdirSync11 } from "node:fs";
10513
+ import { readFileSync as readFileSync14, appendFileSync as appendFileSync4, mkdirSync as mkdirSync10 } from "node:fs";
10590
10514
  import { join as join15 } from "node:path";
10591
10515
 
10592
10516
  // src/lib/hooks/chat-transform.js
10593
10517
  init_state();
10594
- import { readFileSync as readFileSync13, writeFileSync as writeFileSync13, appendFileSync as appendFileSync3, existsSync as existsSync14, mkdirSync as mkdirSync10, rmSync as rmSync5, readdirSync as readdirSync3, statSync as statSync7 } from "node:fs";
10518
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync12, appendFileSync as appendFileSync3, existsSync as existsSync14, mkdirSync as mkdirSync9, rmSync as rmSync5, readdirSync as readdirSync3, statSync as statSync7 } from "node:fs";
10595
10519
  import { join as join14, dirname as dirname10, basename as basename3 } from "node:path";
10596
10520
  import { createHash as createHash3 } from "node:crypto";
10597
10521
 
@@ -10788,7 +10712,7 @@ init_selection_manager();
10788
10712
  init_state();
10789
10713
  init_pattern_helpers();
10790
10714
  import { join as join13 } from "node:path";
10791
- import { writeFileSync as writeFileSync12 } from "node:fs";
10715
+ import { writeFileSync as writeFileSync11 } from "node:fs";
10792
10716
 
10793
10717
  // src/lib/text-compress.js
10794
10718
  var VERBOSE_LINE_RE = [
@@ -11146,7 +11070,7 @@ function recordSaving(tool2, reason, saveEst, meta = {}) {
11146
11070
  if (sd) {
11147
11071
  const sp = join13(sd, "delegation-state-hint.txt");
11148
11072
  try {
11149
- writeFileSync12(sp, JSON.stringify({ sid, total_savings: s.lifetime.total_savings_usd, last_reason: reason }), "utf8");
11073
+ writeFileSync11(sp, JSON.stringify({ sid, total_savings: s.lifetime.total_savings_usd, last_reason: reason }), "utf8");
11150
11074
  } catch {
11151
11075
  }
11152
11076
  }
@@ -11499,8 +11423,8 @@ function ensureProjectSkill(dir, fp2) {
11499
11423
  content += "\n";
11500
11424
  }
11501
11425
  try {
11502
- mkdirSync10(skillDir, { recursive: true });
11503
- writeFileSync13(skillPath, content, "utf-8");
11426
+ mkdirSync9(skillDir, { recursive: true });
11427
+ writeFileSync12(skillPath, content, "utf-8");
11504
11428
  console.error(`[vibeOS] Project Guard: created .opencode/skills/${projectName}/SKILL.md`);
11505
11429
  return { created: true, path: skillPath, skipped: false };
11506
11430
  } catch (err) {
@@ -11617,7 +11541,7 @@ function syncControlSettings(cv, options = {}) {
11617
11541
  writeSelection("previous_default_agent", oc.default_agent);
11618
11542
  }
11619
11543
  oc.default_agent = cv.agent_mode;
11620
- writeFileSync13(OC_CONFIG, JSON.stringify(oc, null, 2) + "\n");
11544
+ writeFileSync12(OC_CONFIG, JSON.stringify(oc, null, 2) + "\n");
11621
11545
  }
11622
11546
  }
11623
11547
  } catch {
@@ -11630,7 +11554,7 @@ function syncControlSettings(cv, options = {}) {
11630
11554
  const restoreAgent = oc.default_agent === "plan" ? resolveRestorableOpenCodeAgent(currentSel) : null;
11631
11555
  if (restoreAgent && oc.default_agent === "plan") {
11632
11556
  oc.default_agent = restoreAgent;
11633
- writeFileSync13(OC_CONFIG, JSON.stringify(oc, null, 2) + "\n");
11557
+ writeFileSync12(OC_CONFIG, JSON.stringify(oc, null, 2) + "\n");
11634
11558
  if (currentSel.previous_default_agent)
11635
11559
  writeSelection("previous_default_agent", null);
11636
11560
  }
@@ -11692,10 +11616,10 @@ ${raw}
11692
11616
  const sessPath = join14(getSessionScratchpadDir(), `${hash}.txt`);
11693
11617
  const globalPath = join14(globalDir, `${hash}.txt`);
11694
11618
  try {
11695
- mkdirSync10(globalDir, { recursive: true });
11619
+ mkdirSync9(globalDir, { recursive: true });
11696
11620
  ensureSessionScratchpadDirs();
11697
11621
  if (!existsSync14(globalPath)) {
11698
- writeFileSync13(globalPath, raw);
11622
+ writeFileSync12(globalPath, raw);
11699
11623
  indexAppend(hash, part.tool, raw.length);
11700
11624
  if (existsSync14(sessPath))
11701
11625
  rmSync5(sessPath, { force: true });
@@ -11708,7 +11632,7 @@ ${stableJson(invPart.state.input)}
11708
11632
  `).digest("hex").slice(0, 16);
11709
11633
  const ptrPath = join14(getSessionScratchpadDir(), `${inputHash}.ptr`);
11710
11634
  try {
11711
- writeFileSync13(ptrPath, JSON.stringify({ contentHash: hash, tool: part.tool }));
11635
+ writeFileSync12(ptrPath, JSON.stringify({ contentHash: hash, tool: part.tool }));
11712
11636
  } catch {
11713
11637
  }
11714
11638
  }
@@ -11988,7 +11912,7 @@ var onSystemTransform = async (_input, output) => {
11988
11912
  const system = output?.system;
11989
11913
  if (!Array.isArray(system))
11990
11914
  return;
11991
- if (isApiConnected2()) {
11915
+ if (isApiConnected()) {
11992
11916
  try {
11993
11917
  const bb = loadBlackboxState();
11994
11918
  if (!bb.enabled || _blackboxEnabled === false) {
@@ -12148,7 +12072,7 @@ var onSystemTransform = async (_input, output) => {
12148
12072
  fp: currentProjectFingerprint || ""
12149
12073
  }) + "\n";
12150
12074
  try {
12151
- mkdirSync10(calDir, { recursive: true });
12075
+ mkdirSync9(calDir, { recursive: true });
12152
12076
  appendFileSync3(calFile, calRecord);
12153
12077
  } catch {
12154
12078
  }
@@ -12330,8 +12254,8 @@ function buildFooterLine(input) {
12330
12254
 
12331
12255
  // src/lib/hooks/footer.js
12332
12256
  var IS_CLI_RUNTIME = Boolean(process.stdout?.isTTY || process.stderr?.isTTY || process.stdin?.isTTY);
12333
- var IS_TEST_RUNTIME2 = process.env.VIBEOS_MCP_PORT === "0" || process.env.NODE_ENV === "test" || process.env.CI === "true";
12334
- var FOOTER_DEBUG_STDERR = process.env.VIBEOS_DEBUG_FOOTER === "1" || !IS_CLI_RUNTIME && !IS_TEST_RUNTIME2;
12257
+ var IS_TEST_RUNTIME = process.env.VIBEOS_MCP_PORT === "0" || process.env.NODE_ENV === "test" || process.env.CI === "true";
12258
+ var FOOTER_DEBUG_STDERR = process.env.VIBEOS_DEBUG_FOOTER === "1" || !IS_CLI_RUNTIME && !IS_TEST_RUNTIME;
12335
12259
  function footerDebug(...args) {
12336
12260
  if (FOOTER_DEBUG_STDERR)
12337
12261
  console.error(...args);
@@ -12572,7 +12496,7 @@ async function _appendFooter(input, output, directory3) {
12572
12496
  return;
12573
12497
  const ltTotal = ltTasks + ltCache;
12574
12498
  const activeSlot = selNowFooter.active_slot || "brain";
12575
- const flashIcon = isApiConnected2() ? " \u26A1" : "";
12499
+ const flashIcon = isApiConnected() ? " \u26A1" : "";
12576
12500
  const displayMode2 = autoSelectMode2(currentSubRegime2, _footerStress);
12577
12501
  const vibeBrand = resolveBrand(loadOptimizationMode() || displayMode2, activeSlot);
12578
12502
  const vibeLine = buildFooterLine({
@@ -12614,7 +12538,7 @@ ${vibeLine}`;
12614
12538
  tracker.recordOutcome(finalOutcome);
12615
12539
  syncOutcomeToApi(finalOutcome);
12616
12540
  try {
12617
- mkdirSync11(getVibeOSHome10(), { recursive: true });
12541
+ mkdirSync10(getVibeOSHome10(), { recursive: true });
12618
12542
  appendFileSync4(join15(getVibeOSHome10(), "calibration-data.jsonl"), JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), event: "outcome", sid: getSessionId(), outcome: finalOutcome }) + "\n");
12619
12543
  } catch {
12620
12544
  }
@@ -12642,7 +12566,7 @@ ${vibeLine} \u2014`);
12642
12566
 
12643
12567
  // src/lib/hooks/tool-execute.js
12644
12568
  init_state();
12645
- import { writeFileSync as writeFileSync15, appendFileSync as appendFileSync6, existsSync as existsSync16, mkdirSync as mkdirSync13 } from "node:fs";
12569
+ import { writeFileSync as writeFileSync14, appendFileSync as appendFileSync6, existsSync as existsSync16, mkdirSync as mkdirSync12 } from "node:fs";
12646
12570
  import { join as join17, dirname as dirname12, basename as basename4 } from "node:path";
12647
12571
  import { createHash as createHash5 } from "node:crypto";
12648
12572
  init_selection_manager();
@@ -12711,7 +12635,7 @@ init_smart_cache();
12711
12635
 
12712
12636
  // src/lib/tdd-enforcer.js
12713
12637
  init_state();
12714
- import { readFileSync as readFileSync15, writeFileSync as writeFileSync14, appendFileSync as appendFileSync5, existsSync as existsSync15, mkdirSync as mkdirSync12, statSync as statSync8, readdirSync as readdirSync4, rmSync as rmSync6, openSync as openSync3 } from "node:fs";
12638
+ import { readFileSync as readFileSync15, writeFileSync as writeFileSync13, appendFileSync as appendFileSync5, existsSync as existsSync15, mkdirSync as mkdirSync11, statSync as statSync8, readdirSync as readdirSync4, rmSync as rmSync6, openSync as openSync3 } from "node:fs";
12715
12639
  import { join as join16, dirname as dirname11 } from "node:path";
12716
12640
  import { createHash as createHash4 } from "node:crypto";
12717
12641
 
@@ -13814,7 +13738,7 @@ var COOLDOWN_MS = 6e4;
13814
13738
  var _enforcementCooldown = /* @__PURE__ */ new Set();
13815
13739
  function _acquireLock(testPath) {
13816
13740
  try {
13817
- mkdirSync12(ENFORCEMENT_LOCK_DIR, { recursive: true });
13741
+ mkdirSync11(ENFORCEMENT_LOCK_DIR, { recursive: true });
13818
13742
  const hash = createHash4("sha256").update(testPath).digest("hex").slice(0, 16);
13819
13743
  const lockPath = join16(ENFORCEMENT_LOCK_DIR, `${hash}.lock`);
13820
13744
  try {
@@ -13871,13 +13795,13 @@ function _isInCooldown(testPath) {
13871
13795
  }
13872
13796
  function _recordCooldown(testPath) {
13873
13797
  try {
13874
- mkdirSync12(dirname11(ENFORCEMENT_COOLDOWN_FILE2), { recursive: true });
13798
+ mkdirSync11(dirname11(ENFORCEMENT_COOLDOWN_FILE2), { recursive: true });
13875
13799
  const hash = createHash4("sha256").update(testPath).digest("hex").slice(0, 16);
13876
13800
  const entry = JSON.stringify({ h: hash, ts: Date.now() }) + "\n";
13877
13801
  appendFileSync5(ENFORCEMENT_COOLDOWN_FILE2, entry);
13878
13802
  const lines = readFileSync15(ENFORCEMENT_COOLDOWN_FILE2, "utf-8").trim().split("\n").filter(Boolean);
13879
13803
  if (lines.length > 500) {
13880
- writeFileSync14(ENFORCEMENT_COOLDOWN_FILE2, lines.slice(-200).join("\n") + "\n");
13804
+ writeFileSync13(ENFORCEMENT_COOLDOWN_FILE2, lines.slice(-200).join("\n") + "\n");
13881
13805
  }
13882
13806
  } catch {
13883
13807
  }
@@ -13963,8 +13887,8 @@ function enforceTestFile(filePath) {
13963
13887
  if (!_acquireLock(skeleton.path))
13964
13888
  return null;
13965
13889
  try {
13966
- mkdirSync12(skeleton.dir, { recursive: true });
13967
- writeFileSync14(skeleton.path, skeleton.content);
13890
+ mkdirSync11(skeleton.dir, { recursive: true });
13891
+ writeFileSync13(skeleton.path, skeleton.content);
13968
13892
  _enforcementCooldown.add(skeleton.path);
13969
13893
  _recordCooldown(skeleton.path);
13970
13894
  try {
@@ -14307,7 +14231,7 @@ ${argsJson}
14307
14231
  const globalFile = join17(globalDir, `${targetHash}.txt`);
14308
14232
  if (existsSync16(cachedFile) || existsSync16(globalFile)) {
14309
14233
  ensureSessionScratchpadDirs();
14310
- writeFileSync15(ptrPath, JSON.stringify({
14234
+ writeFileSync14(ptrPath, JSON.stringify({
14311
14235
  contentHash: targetHash,
14312
14236
  tool: titleCase,
14313
14237
  warmed: true,
@@ -14606,8 +14530,8 @@ ${argsJson}
14606
14530
  const missed = recordMissedContext7(_estC7);
14607
14531
  if (!existsSync16(CONTEXT7_INSTALL_FLAG)) {
14608
14532
  try {
14609
- mkdirSync13(dirname12(CONTEXT7_INSTALL_FLAG), { recursive: true });
14610
- writeFileSync15(CONTEXT7_INSTALL_FLAG, "");
14533
+ mkdirSync12(dirname12(CONTEXT7_INSTALL_FLAG), { recursive: true });
14534
+ writeFileSync14(CONTEXT7_INSTALL_FLAG, "");
14611
14535
  } catch {
14612
14536
  }
14613
14537
  console.error(`[vibeOS] Small win: install context7 MCP to save about ~$0.06/turn on docs: \`claude mcp add context7 npx @upstash/context7-mcp\``);
@@ -14698,7 +14622,7 @@ var onToolExecuteAfter = async (input, output) => {
14698
14622
  const displayMode2 = autoSelectMode2(currentSubRegime2, latestUserIntent ? scoreStress(latestUserIntent) : 0);
14699
14623
  const vibeBrand = resolveBrand(displayMode2, activeSlot);
14700
14624
  const sessionSlot = loadSessionSlot(currentSid);
14701
- const flashIcon = isApiConnected2() ? " \u26A1" : "";
14625
+ const flashIcon = isApiConnected() ? " \u26A1" : "";
14702
14626
  _footerText = buildFooterLine({
14703
14627
  activeSlot,
14704
14628
  providerLabel: execution.provider_label,
@@ -15154,6 +15078,7 @@ function ensureDeferredBootstrap() {
15154
15078
  } catch {
15155
15079
  }
15156
15080
  }
15081
+ var _apiFallbackSince2 = null;
15157
15082
  var activeJob2 = null;
15158
15083
  var fp = "";
15159
15084
  var _mcpServerRuntime = null;
@@ -15314,8 +15239,8 @@ async function _seedOrRepairModelTiers(directory3) {
15314
15239
  },
15315
15240
  trinity: nextTrinity
15316
15241
  };
15317
- mkdirSync14(dirname13(TIERS_FILE3), { recursive: true });
15318
- writeFileSync16(TIERS_FILE3, JSON.stringify(tiers, null, 2) + "\n", "utf-8");
15242
+ mkdirSync13(dirname13(TIERS_FILE3), { recursive: true });
15243
+ writeFileSync15(TIERS_FILE3, JSON.stringify(tiers, null, 2) + "\n", "utf-8");
15319
15244
  return true;
15320
15245
  }
15321
15246
  function _parseJsonc(raw) {
@@ -15370,7 +15295,9 @@ function loadMcpPort() {
15370
15295
  }
15371
15296
  } catch {
15372
15297
  }
15373
- return null;
15298
+ if (process.env.VIBEOS_TEST_CONTEXT)
15299
+ return 0;
15300
+ return 3001;
15374
15301
  }
15375
15302
  function persistMcpPort(port) {
15376
15303
  try {
@@ -15383,9 +15310,9 @@ function persistMcpPort(port) {
15383
15310
  tiers.selection.mcp_port = port;
15384
15311
  if ("mcp_port" in tiers)
15385
15312
  delete tiers.mcp_port;
15386
- mkdirSync14(dirname13(getTiersFile()), { recursive: true });
15313
+ mkdirSync13(dirname13(getTiersFile()), { recursive: true });
15387
15314
  const tmp = getTiersFile() + ".tmp." + Date.now();
15388
- writeFileSync16(tmp, JSON.stringify(tiers, null, 2) + "\n", "utf-8");
15315
+ writeFileSync15(tmp, JSON.stringify(tiers, null, 2) + "\n", "utf-8");
15389
15316
  renameSync6(tmp, getTiersFile());
15390
15317
  } catch {
15391
15318
  }
@@ -15405,7 +15332,6 @@ function scheduleMcpServerRestart() {
15405
15332
  _mcpServerRestartTimer = null;
15406
15333
  void ensureMcpServerRunning();
15407
15334
  }, 500);
15408
- if (typeof _mcpServerRestartTimer.unref === "function") _mcpServerRestartTimer.unref();
15409
15335
  }
15410
15336
  function attachMcpServerWatchdog(server2) {
15411
15337
  server2?.once?.("close", () => {
@@ -15450,11 +15376,11 @@ async function ensureMcpServerRunning() {
15450
15376
  version: readPackageVersion(),
15451
15377
  todos: loadTodos(),
15452
15378
  fallbackThinking: thinkingLevel(loadCredit()),
15453
- backendConnected: isApiConnected2(),
15379
+ backendConnected: isApiConnected(),
15454
15380
  backendHealthUrl: `${VIBEOS_API_URL}/health`,
15455
15381
  backendVersion: getBackendVersion(),
15456
15382
  apiFallbackMode: isApiFallback2(),
15457
- apiFallbackSince: getApiFallbackSince2(),
15383
+ apiFallbackSince: _apiFallbackSince2,
15458
15384
  modelLocked: _modelLocked,
15459
15385
  lockedSlot: _lockedSlot,
15460
15386
  lockedModel: _lockedModel
@@ -15571,13 +15497,10 @@ async function ensureMcpServerRunning() {
15571
15497
  }
15572
15498
  });
15573
15499
  }
15574
- const requestedPort = port == null ? 0 : port;
15575
- const mcpServer = await _mcpServerRuntime.start(requestedPort);
15576
- const actualPort = Number(mcpServer?.address?.()?.port || requestedPort);
15577
- if (actualPort && actualPort !== requestedPort)
15500
+ const mcpServer = await _mcpServerRuntime.start(port);
15501
+ const actualPort = Number(mcpServer?.address?.()?.port || port);
15502
+ if (actualPort && actualPort !== port)
15578
15503
  persistMcpPort(actualPort);
15579
- if (actualPort)
15580
- writeDashboardBaseConfig(`http://127.0.0.1:${actualPort}`);
15581
15504
  console.error(`[vibeOS] MCP server on http://127.0.0.1:${actualPort}`);
15582
15505
  if (actualPort)
15583
15506
  console.error(`[vibeOS] Dashboard at http://127.0.0.1:${actualPort}/`);
@@ -15717,9 +15640,9 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
15717
15640
  };
15718
15641
  const saveProjectStateStable = (state) => {
15719
15642
  try {
15720
- mkdirSync14(dirname13(hookProjectStateFile), { recursive: true });
15643
+ mkdirSync13(dirname13(hookProjectStateFile), { recursive: true });
15721
15644
  const tmp = hookProjectStateFile + ".tmp";
15722
- writeFileSync16(tmp, JSON.stringify(state, null, 2) + "\n");
15645
+ writeFileSync15(tmp, JSON.stringify(state, null, 2) + "\n");
15723
15646
  renameSync6(tmp, hookProjectStateFile);
15724
15647
  } catch {
15725
15648
  }
@@ -15736,8 +15659,8 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
15736
15659
  };
15737
15660
  const saveReportsIndexStable = (idx) => {
15738
15661
  try {
15739
- mkdirSync14(hookReportsDir, { recursive: true });
15740
- writeFileSync16(hookReportsIndex, JSON.stringify(idx, null, 2) + "\n");
15662
+ mkdirSync13(hookReportsDir, { recursive: true });
15663
+ writeFileSync15(hookReportsIndex, JSON.stringify(idx, null, 2) + "\n");
15741
15664
  } catch {
15742
15665
  }
15743
15666
  };
@@ -15746,7 +15669,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
15746
15669
  if (!existsSync18(path))
15747
15670
  return null;
15748
15671
  const bkDir = join18(hookVibeHome, ".backups");
15749
- mkdirSync14(bkDir, { recursive: true });
15672
+ mkdirSync13(bkDir, { recursive: true });
15750
15673
  const bk = join18(bkDir, `${basename5(path)}.${label}.${Date.now()}.bak`);
15751
15674
  copyFileSync2(path, bk);
15752
15675
  return bk;
@@ -15782,10 +15705,10 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
15782
15705
  directory: directory3,
15783
15706
  safeJsonParse: safeJsonParse3,
15784
15707
  readFileSync: readFileSync17,
15785
- writeFileSync: writeFileSync16,
15708
+ writeFileSync: writeFileSync15,
15786
15709
  existsSync: existsSync18,
15787
15710
  renameSync: renameSync6,
15788
- mkdirSync: mkdirSync14,
15711
+ mkdirSync: mkdirSync13,
15789
15712
  get TIERS_FILE() {
15790
15713
  return hookTiersFile;
15791
15714
  },
@@ -15841,7 +15764,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
15841
15764
  saveBlackboxState,
15842
15765
  isApiFallback: () => isApiFallback2(),
15843
15766
  get _apiFallbackSince() {
15844
- return getApiFallbackSince2();
15767
+ return _apiFallbackSince2;
15845
15768
  },
15846
15769
  reportsIndex: reportsIndexStable,
15847
15770
  saveReportsIndex: saveReportsIndexStable,
@@ -16086,7 +16009,7 @@ ${report.narrative}`);
16086
16009
  }
16087
16010
  };
16088
16011
  _pluginHooksRuntime = pluginHooks;
16089
- const _inTestEnv = process.env.VIBEOS_MCP_PORT === "0" || process.env.NODE_ENV === "test" || process.execArgv.some((arg) => arg === "--test" || arg.startsWith("--test="));
16012
+ const _inTestEnv = process.env.VIBEOS_MCP_PORT === "0";
16090
16013
  if (!_inTestEnv)
16091
16014
  void ensureMcpServerRunning();
16092
16015
  return pluginHooks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibeostheog",
3
- "version": "0.25.7",
3
+ "version": "0.25.8",
4
4
  "description": "Cost-aware delegation enforcer for OpenCode. Tracks model usage, routes Task subagents to cheaper tiers, surfaces cumulative savings in chat. Includes research audit, reporting framework, project memory, progressive scratchpad decadence, and trinity CLI for brain/medium/cheap slot switching.",
5
5
  "scripts": {
6
6
  "release": "node scripts/release.mjs",