vibeostheog 0.24.21 → 0.24.23

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.24.23
2
+ - fix: heal stale vibelitex reconnect state
3
+
4
+
5
+ ## 0.24.22
6
+ - fix: restore bootstrap token and install regression (#149)
7
+
8
+
1
9
  ## 0.24.21
2
10
  - feat: pass user_text to RF prediction engine via control-vector API (#146)
3
11
  - feat: pass user_text to RF prediction engine via control-vector API
package/dist/vibeOS.js CHANGED
@@ -1734,6 +1734,10 @@ function normalizeApiToken(token, fallback2 = "") {
1734
1734
  const clean = String(token || "").trim();
1735
1735
  return API_TOKEN_RE.test(clean) ? clean : fallback2;
1736
1736
  }
1737
+ function normalizeDirectApiToken(token) {
1738
+ const clean = normalizeApiToken(token, "");
1739
+ return clean && clean !== EMBEDDED_API_TOKEN ? clean : "";
1740
+ }
1737
1741
  function isTruthyFlag(value) {
1738
1742
  return API_DISABLED_RE.test(String(value || "").trim());
1739
1743
  }
@@ -2095,7 +2099,7 @@ function readTokenFromDisk() {
2095
2099
  const env = readFileSync2(dir + "/.env.production", "utf8");
2096
2100
  const m = env.match(/^VIBEOS_API_TOKEN=(.+)$/m);
2097
2101
  if (m) {
2098
- const clean = normalizeApiToken(m[1], "");
2102
+ const clean = normalizeDirectApiToken(m[1]);
2099
2103
  if (clean)
2100
2104
  return clean;
2101
2105
  }
@@ -2104,6 +2108,16 @@ function readTokenFromDisk() {
2104
2108
  }
2105
2109
  return "";
2106
2110
  }
2111
+ function hasPrimaryTokenOnDisk() {
2112
+ if (readApiDisabledFromDisk())
2113
+ return false;
2114
+ try {
2115
+ const env = readFileSync2(_envPaths[0] + "/.env.production", "utf8");
2116
+ return /^VIBEOS_API_TOKEN=/m.test(env);
2117
+ } catch {
2118
+ return false;
2119
+ }
2120
+ }
2107
2121
  function readBootstrapTokenFromDisk() {
2108
2122
  if (readApiDisabledFromDisk())
2109
2123
  return "";
@@ -2117,7 +2131,7 @@ function readBootstrapTokenFromDisk() {
2117
2131
  return "";
2118
2132
  }
2119
2133
  var VIBEOS_API_DISABLED = readApiDisabledFromDisk() || isTruthyFlag(process.env.VIBEOS_API_DISABLED);
2120
- var VIBEOS_API_TOKEN = VIBEOS_API_DISABLED ? "" : readTokenFromDisk() || normalizeApiToken(process.env.VIBEOS_API_TOKEN, "");
2134
+ var VIBEOS_API_TOKEN = VIBEOS_API_DISABLED ? "" : readTokenFromDisk() || normalizeDirectApiToken(process.env.VIBEOS_API_TOKEN) || (!hasPrimaryTokenOnDisk() ? EMBEDDED_API_TOKEN : "");
2121
2135
  var VIBEOS_API_BOOTSTRAP_TOKEN = VIBEOS_API_DISABLED ? "" : readBootstrapTokenFromDisk() || process.env.VIBEOS_API_BOOTSTRAP_TOKEN || EMBEDDED_API_TOKEN;
2122
2136
  var VIBEOS_API_ENABLED = !VIBEOS_API_DISABLED && process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
2123
2137
  var _anomalyDetector = null;
@@ -2149,7 +2163,7 @@ function persistBootstrapToken(token) {
2149
2163
  function setApiToken(newToken) {
2150
2164
  try {
2151
2165
  VIBEOS_API_DISABLED = false;
2152
- VIBEOS_API_TOKEN = normalizeApiToken(newToken, EMBEDDED_API_TOKEN);
2166
+ VIBEOS_API_TOKEN = normalizeDirectApiToken(newToken);
2153
2167
  VIBEOS_API_BOOTSTRAP_TOKEN = readBootstrapTokenFromDisk() || VIBEOS_API_BOOTSTRAP_TOKEN;
2154
2168
  VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
2155
2169
  _apiClient = null;
@@ -2241,7 +2255,7 @@ function syncApiTokenFromDisk() {
2241
2255
  const diskDisabled = readApiDisabledFromDisk() || isTruthyFlag(process.env.VIBEOS_API_DISABLED);
2242
2256
  const diskToken = readTokenFromDisk() || "";
2243
2257
  const diskBootstrapToken = readBootstrapTokenFromDisk() || "";
2244
- const envToken = normalizeApiToken(process.env.VIBEOS_API_TOKEN, "");
2258
+ const envToken = normalizeDirectApiToken(process.env.VIBEOS_API_TOKEN);
2245
2259
  if (diskDisabled) {
2246
2260
  if (!VIBEOS_API_DISABLED || VIBEOS_API_TOKEN || VIBEOS_API_BOOTSTRAP_TOKEN || VIBEOS_API_ENABLED) {
2247
2261
  VIBEOS_API_DISABLED = true;
@@ -2284,6 +2298,9 @@ function syncApiTokenFromDisk() {
2284
2298
  console.error("[vibeOS] API token loaded from VIBEOS_API_TOKEN env var");
2285
2299
  } else {
2286
2300
  VIBEOS_API_DISABLED = false;
2301
+ if (!VIBEOS_API_TOKEN && !hasPrimaryTokenOnDisk()) {
2302
+ VIBEOS_API_TOKEN = EMBEDDED_API_TOKEN;
2303
+ }
2287
2304
  VIBEOS_API_BOOTSTRAP_TOKEN ||= EMBEDDED_API_TOKEN;
2288
2305
  VIBEOS_API_ENABLED = process.env.VIBEOS_API_ENABLED !== "false" && (!!VIBEOS_API_TOKEN || !!VIBEOS_API_BOOTSTRAP_TOKEN);
2289
2306
  }
@@ -2395,7 +2412,7 @@ function safeJsonParse2(raw) {
2395
2412
  throw e;
2396
2413
  }
2397
2414
  }
2398
- var DFLT_SEL = { enabled: true, active_slot: null, slot_locked: false, thinking_level: "off", flow_enabled: true, tdd_enforce: false, tdd_strict: false, tdd_quality: true, flow_enforce: true, delegation_enforce: true, onboarding_mode: null, selected_provider: null, selected_quality_tier: null, selected_model: null, executed_provider: null, executed_quality_tier: null, executed_model: null, previous_default_agent: null };
2415
+ var DFLT_SEL = { enabled: true, active_slot: null, slot_locked: false, thinking_level: "off", flow_enabled: true, tdd_enforce: false, tdd_strict: false, tdd_quality: true, flow_enforce: true, delegation_enforce: true, onboarding_mode: null, selected_provider: null, selected_quality_tier: null, selected_model: null, executed_provider: null, executed_quality_tier: null, executed_model: null, previous_default_agent: null, previous_optimization_mode: null };
2399
2416
  function loadSelection() {
2400
2417
  const TIERS_FILE3 = join3(getVibeOSHome2(), "model-tiers.json");
2401
2418
  try {
@@ -2427,7 +2444,8 @@ function loadSelection() {
2427
2444
  executed_provider: j?.selection?.executed_provider || null,
2428
2445
  executed_quality_tier: j?.selection?.executed_quality_tier || null,
2429
2446
  executed_model: j?.selection?.executed_model || null,
2430
- previous_default_agent: j?.selection?.previous_default_agent || null
2447
+ previous_default_agent: j?.selection?.previous_default_agent || null,
2448
+ previous_optimization_mode: j?.selection?.previous_optimization_mode || null
2431
2449
  };
2432
2450
  } catch {
2433
2451
  _handleStateCorruption2(TIERS_FILE3);
@@ -2503,7 +2521,7 @@ function loadGlobalOptMode() {
2503
2521
  function saveGlobalOptMode(mode) {
2504
2522
  return writeSelection("optimization_mode", mode);
2505
2523
  }
2506
- function writeSessionOptMode(sid, mode) {
2524
+ function writeSessionOptMode2(sid, mode) {
2507
2525
  const BLACKBOX_FILE = join3(getVibeOSHome2(), "blackbox-state.json");
2508
2526
  try {
2509
2527
  const j = existsSync4(BLACKBOX_FILE) ? safeJsonParse2(readFileSync3(BLACKBOX_FILE, "utf-8")) : {};
@@ -7246,8 +7264,45 @@ function setBlackboxEnabled2(val) {
7246
7264
  setBlackboxEnabled(val);
7247
7265
  }
7248
7266
  var DFLT_OPTIMIZATION_MODE = "budget";
7267
+ function recoverOptimizationModeFromSelection(sel) {
7268
+ const slot = String(sel?.active_slot || "").toLowerCase();
7269
+ if (slot === "brain")
7270
+ return "quality";
7271
+ if (slot === "medium")
7272
+ return "vibemax";
7273
+ if (slot === "cheap")
7274
+ return "budget";
7275
+ return "budget";
7276
+ }
7249
7277
  function loadOptimizationMode() {
7250
7278
  try {
7279
+ const sel = loadSelection();
7280
+ const persistedMode = sel.optimization_mode || null;
7281
+ if (persistedMode === "vibelitex") {
7282
+ const prevKey = `${_OC_SID}_prev_opt`;
7283
+ const sessionMode = loadSessionOptMode(_OC_SID);
7284
+ const globalMode = loadGlobalOptMode();
7285
+ const recoveryMode = sel.previous_optimization_mode || loadSessionOptMode(prevKey) || (sessionMode && sessionMode !== "vibelitex" ? sessionMode : "") || (globalMode && globalMode !== "vibelitex" ? globalMode : "") || recoverOptimizationModeFromSelection(sel);
7286
+ if (recoveryMode && recoveryMode !== "vibelitex") {
7287
+ try {
7288
+ writeSelection("optimization_mode", recoveryMode);
7289
+ } catch {
7290
+ }
7291
+ try {
7292
+ writeSelection("previous_optimization_mode", null);
7293
+ } catch {
7294
+ }
7295
+ try {
7296
+ writeSessionOptMode2(_OC_SID, recoveryMode);
7297
+ } catch {
7298
+ }
7299
+ try {
7300
+ writeSessionOptMode2(prevKey, "");
7301
+ } catch {
7302
+ }
7303
+ return recoveryMode;
7304
+ }
7305
+ }
7251
7306
  const mode = loadSessionOptMode(_OC_SID);
7252
7307
  if (mode && mode !== "auto")
7253
7308
  return mode;
@@ -7261,7 +7316,7 @@ function loadOptimizationMode() {
7261
7316
  }
7262
7317
  function saveOptimizationMode(mode) {
7263
7318
  try {
7264
- writeSessionOptMode(_OC_SID, mode);
7319
+ writeSessionOptMode2(_OC_SID, mode);
7265
7320
  } catch (e) {
7266
7321
  console.error("[vibeOS] saveOptimizationMode session write failed: " + e.message);
7267
7322
  }
@@ -10753,9 +10808,28 @@ function syncControlSettings(cv, options = {}) {
10753
10808
  writeIf("thinking_level", nextThinking);
10754
10809
  }
10755
10810
  if (persistOptimizationMode && cv.optimization_mode && userOptMode !== "auto") {
10756
- const fallbackPinned = isApiFallback() && cv.optimization_mode === "vibelitex" && currentSel.optimization_mode !== "vibelitex";
10757
- if (!fallbackPinned && userOptMode !== cv.optimization_mode) {
10811
+ const fallbackPinned = isApiFallback() && cv.optimization_mode === "vibelitex";
10812
+ const previousOptMode2 = typeof currentSel.previous_optimization_mode === "string" ? currentSel.previous_optimization_mode : null;
10813
+ const prevSessionKey2 = `${sid}_prev_opt`;
10814
+ const sessionPreviousOptMode = loadSessionOptMode(prevSessionKey2);
10815
+ const liveSlot = String(currentSel.active_slot || cv.tier_bias || "").toLowerCase();
10816
+ const inferredRecoveryMode = liveSlot === "brain" ? "quality" : liveSlot === "medium" ? "vibemax" : "budget";
10817
+ const restoreMode = sessionPreviousOptMode || previousOptMode2 || inferredRecoveryMode;
10818
+ const canRestorePrevious = !!restoreMode && cv.optimization_mode !== "vibelitex" && (previousOptMode2 !== null || sessionPreviousOptMode !== null);
10819
+ if (fallbackPinned) {
10820
+ if (currentSel.optimization_mode !== "vibelitex") {
10821
+ writeIf("previous_optimization_mode", currentSel.optimization_mode);
10822
+ writeSessionOptMode(prevSessionKey2, currentSel.optimization_mode || "");
10823
+ }
10824
+ } else if (canRestorePrevious) {
10825
+ writeIf("optimization_mode", restoreMode);
10826
+ writeIf("previous_optimization_mode", null);
10827
+ writeSessionOptMode(sid, restoreMode);
10828
+ writeSessionOptMode(prevSessionKey2, "");
10829
+ } else if (userOptMode !== cv.optimization_mode) {
10758
10830
  writeIf("optimization_mode", cv.optimization_mode);
10831
+ if (previousOptMode2)
10832
+ writeIf("previous_optimization_mode", null);
10759
10833
  }
10760
10834
  }
10761
10835
  const slot = cv.tier_bias;
@@ -10803,6 +10877,19 @@ function syncControlSettings(cv, options = {}) {
10803
10877
  } catch {
10804
10878
  }
10805
10879
  }
10880
+ if (cv.optimization_mode && cv.optimization_mode !== "vibelitex") {
10881
+ const finalSel = loadSelection();
10882
+ if (finalSel.optimization_mode === "vibelitex") {
10883
+ const liveSlot = String(finalSel.active_slot || currentSel.active_slot || cv.tier_bias || "").toLowerCase();
10884
+ const restoreCandidate = finalSel.previous_optimization_mode || loadSessionOptMode(prevSessionKey) || previousOptMode || (liveSlot === "brain" ? "quality" : liveSlot === "medium" ? "vibemax" : "budget");
10885
+ if (restoreCandidate && restoreCandidate !== "vibelitex") {
10886
+ writeSelection("optimization_mode", restoreCandidate);
10887
+ writeSelection("previous_optimization_mode", null);
10888
+ writeSessionOptMode(sid, restoreCandidate);
10889
+ writeSessionOptMode(prevSessionKey, "");
10890
+ }
10891
+ }
10892
+ }
10806
10893
  } catch {
10807
10894
  }
10808
10895
  }
@@ -11634,9 +11721,9 @@ async function _appendFooter(input, output, directory3) {
11634
11721
  const ltTotal = ltTasks + ltCache;
11635
11722
  const activeSlot = selNowFooter.active_slot || "brain";
11636
11723
  const optMode = (resolvedMode || "budget").toLowerCase();
11637
- const vibeBrand = resolveBrand(optModeFooter, activeSlot);
11638
11724
  const flashIcon = isApiConnected2() ? " \u26A1" : "";
11639
- const displayMode = selNowFooter?.optimization_mode || optMode || "auto";
11725
+ const displayMode = resolvedMode || optModeFooter || optMode || selNowFooter?.optimization_mode || "auto";
11726
+ const vibeBrand = resolveBrand(displayMode, activeSlot);
11640
11727
  const currentSubRegime = _latestBlackboxState?.sub_regime || classifyTurnSimple2(latestUserIntent || "");
11641
11728
  const vibeLine = buildFooterLine({
11642
11729
  activeSlot,
@@ -14638,7 +14725,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
14638
14725
  saveReportsIndex: saveReportsIndexStable,
14639
14726
  backupFile: backupFileStable,
14640
14727
  writeSessionSlot: writeSessionSlot2,
14641
- writeSessionOptMode,
14728
+ writeSessionOptMode: writeSessionOptMode2,
14642
14729
  _refreshModel,
14643
14730
  setApiToken,
14644
14731
  setApiBootstrapToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibeostheog",
3
- "version": "0.24.21",
3
+ "version": "0.24.23",
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",