vibeostheog 0.26.1 → 0.26.2
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 +25 -0
- package/dist/assets/dashboard/assets/index-CspnmA46.js +3 -0
- package/dist/assets/dashboard/index.html +1 -1
- package/dist/assets/dashboard/vibeos-dashboard-config.js +1 -1
- package/dist/vibeOS.js +581 -486
- package/package.json +1 -1
- package/dist/assets/dashboard/assets/index-BAFoSUYT.css +0 -1
- package/dist/assets/dashboard/assets/index-BC32ZQ0q.css +0 -1
- package/dist/assets/dashboard/assets/index-BFPdi_Ph.css +0 -1
- package/dist/assets/dashboard/assets/index-BHjsjrCc.js +0 -5
- package/dist/assets/dashboard/assets/index-BUDvTrCq.css +0 -1
- package/dist/assets/dashboard/assets/index-BY7bffmm.js +0 -3
- package/dist/assets/dashboard/assets/index-BZu3dyXH.css +0 -1
- package/dist/assets/dashboard/assets/index-Brj9Ui6Z.js +0 -3
- package/dist/assets/dashboard/assets/index-C-ScsrcN.js +0 -3
- package/dist/assets/dashboard/assets/index-C5VfzSA8.js +0 -3
- package/dist/assets/dashboard/assets/index-C5tPTUjx.js +0 -3
- package/dist/assets/dashboard/assets/index-Cb3hwMDH.css +0 -1
- package/dist/assets/dashboard/assets/index-CjHF2vTf.css +0 -1
- package/dist/assets/dashboard/assets/index-CkX-loOf.js +0 -3
- package/dist/assets/dashboard/assets/index-D3bLrmaq.css +0 -1
- package/dist/assets/dashboard/assets/index-DGIMdqp_.css +0 -1
- package/dist/assets/dashboard/assets/index-DK4e4oaB.js +0 -3
- package/dist/assets/dashboard/assets/index-DhtwzMRd.js +0 -3
- package/dist/assets/dashboard/assets/index-DnK3sBqN.js +0 -3
- package/dist/assets/dashboard/assets/index-Dwg0W0mM.js +0 -3
- package/dist/assets/dashboard/assets/index-H09FCi_1.js +0 -5
- package/dist/assets/dashboard/assets/index-IZRaK1J1.js +0 -3
- package/dist/assets/dashboard/assets/index-VITT_Lum.js +0 -3
- package/dist/assets/dashboard/assets/index-Xf82CCxe.css +0 -1
- package/dist/assets/dashboard/assets/index-ZWfKo4FL.js +0 -3
- package/dist/assets/dashboard/assets/index-fhy-rD-W.css +0 -1
- package/dist/assets/dashboard/assets/index-mizr4ifp.js +0 -5
- package/dist/assets/dashboard/assets/index-rDxjSA11.css +0 -1
- package/dist/assets/dashboard/assets/index-xMN9Z-Zy.js +0 -3
package/dist/vibeOS.js
CHANGED
|
@@ -10,7 +10,29 @@ var __export = (target, all) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/utils/fs-helpers.ts
|
|
13
|
-
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
13
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
14
|
+
function ensureDir(dirPath) {
|
|
15
|
+
if (!existsSync(dirPath)) mkdirSync(dirPath, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
function appendJsonlWithRotation(filePath, lines, maxLines = 5e3, checkEveryLines = 200) {
|
|
18
|
+
ensureDir(filePath.slice(0, filePath.lastIndexOf("/")));
|
|
19
|
+
const payload = Array.isArray(lines) ? lines.join("") : lines;
|
|
20
|
+
appendFileSync(filePath, payload);
|
|
21
|
+
const count = (_rotationCounters.get(filePath) || 0) + 1;
|
|
22
|
+
if (count < checkEveryLines) {
|
|
23
|
+
_rotationCounters.set(filePath, count);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
_rotationCounters.set(filePath, 0);
|
|
27
|
+
try {
|
|
28
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
29
|
+
const allLines = raw.split("\n").filter(Boolean);
|
|
30
|
+
if (allLines.length > maxLines) {
|
|
31
|
+
writeFileSync(filePath, allLines.slice(-maxLines).join("\n") + "\n");
|
|
32
|
+
}
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
14
36
|
function safeJsonParse(raw) {
|
|
15
37
|
if (raw == null || raw === "") return null;
|
|
16
38
|
try {
|
|
@@ -24,14 +46,16 @@ function safeJsonParse(raw) {
|
|
|
24
46
|
return null;
|
|
25
47
|
}
|
|
26
48
|
}
|
|
49
|
+
var _rotationCounters;
|
|
27
50
|
var init_fs_helpers = __esm({
|
|
28
51
|
"src/utils/fs-helpers.ts"() {
|
|
29
52
|
"use strict";
|
|
53
|
+
_rotationCounters = /* @__PURE__ */ new Map();
|
|
30
54
|
}
|
|
31
55
|
});
|
|
32
56
|
|
|
33
57
|
// src/lib/selection-manager.ts
|
|
34
|
-
import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync2, statSync, renameSync } from "node:fs";
|
|
58
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2, statSync, renameSync } from "node:fs";
|
|
35
59
|
import { join } from "node:path";
|
|
36
60
|
import { homedir, tmpdir } from "node:os";
|
|
37
61
|
function _resetSelectionCacheForTest() {
|
|
@@ -115,7 +139,7 @@ function writeSelection(key, value) {
|
|
|
115
139
|
for (const shadowKey of SHADOW_SELECTION_KEYS) delete j.selection[shadowKey];
|
|
116
140
|
j.selection[key] = value;
|
|
117
141
|
const tmp = TIERS_FILE2 + ".tmp." + Date.now() + "." + Math.random().toString(36).slice(2, 8);
|
|
118
|
-
|
|
142
|
+
writeFileSync2(tmp, JSON.stringify(j, null, 2) + "\n");
|
|
119
143
|
renameSync(tmp, TIERS_FILE2);
|
|
120
144
|
return true;
|
|
121
145
|
});
|
|
@@ -148,7 +172,7 @@ function writeSessionRecord(sid, updater) {
|
|
|
148
172
|
if (!j.sessions[sid]) j.sessions[sid] = {};
|
|
149
173
|
updater(j.sessions[sid]);
|
|
150
174
|
const tmp = BLACKBOX_FILE + ".tmp";
|
|
151
|
-
|
|
175
|
+
writeFileSync2(tmp, JSON.stringify(j, null, 2) + "\n");
|
|
152
176
|
renameSync(tmp, BLACKBOX_FILE);
|
|
153
177
|
return true;
|
|
154
178
|
} catch (err) {
|
|
@@ -202,7 +226,7 @@ function writeAxisOverride(name, value) {
|
|
|
202
226
|
if (!j.selection.axis_overrides || typeof j.selection.axis_overrides !== "object") j.selection.axis_overrides = {};
|
|
203
227
|
j.selection.axis_overrides[name] = value;
|
|
204
228
|
const tmp = TIERS_FILE2 + ".tmp." + Date.now() + "." + Math.random().toString(36).slice(2, 8);
|
|
205
|
-
|
|
229
|
+
writeFileSync2(tmp, JSON.stringify(j, null, 2) + "\n");
|
|
206
230
|
renameSync(tmp, TIERS_FILE2);
|
|
207
231
|
return true;
|
|
208
232
|
});
|
|
@@ -684,7 +708,7 @@ var init_runtime_paths = __esm({
|
|
|
684
708
|
});
|
|
685
709
|
|
|
686
710
|
// src/lib/state/scratchpad-cache.ts
|
|
687
|
-
import { readFileSync as readFileSync3, writeFileSync as
|
|
711
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, appendFileSync as appendFileSync2, existsSync as existsSync4, mkdirSync as mkdirSync2, statSync as statSync2, readdirSync, rmSync, copyFileSync, renameSync as renameSync2 } from "node:fs";
|
|
688
712
|
import { join as join3, dirname } from "node:path";
|
|
689
713
|
import { spawn } from "node:child_process";
|
|
690
714
|
import { createHash } from "node:crypto";
|
|
@@ -757,8 +781,8 @@ function indexAppend(hash, tool2, size, extra) {
|
|
|
757
781
|
const sessionIndex = getSessionIndexPath();
|
|
758
782
|
mkdirSync2(dirname(globalIndex), { recursive: true });
|
|
759
783
|
mkdirSync2(dirname(sessionIndex), { recursive: true });
|
|
760
|
-
|
|
761
|
-
|
|
784
|
+
appendFileSync2(globalIndex, entry);
|
|
785
|
+
appendFileSync2(sessionIndex, entry);
|
|
762
786
|
} catch (err) {
|
|
763
787
|
console.error(`[vibeOS] index write failed: ${err.message}`);
|
|
764
788
|
}
|
|
@@ -867,12 +891,12 @@ function _pruneScratchpadDir(targetDir, opts = {}) {
|
|
|
867
891
|
const summaryPath = join3(targetDir, hash + ".summary.txt");
|
|
868
892
|
if (!existsSync4(summaryPath)) try {
|
|
869
893
|
const content = readFileSync3(fullPath, "utf-8");
|
|
870
|
-
|
|
894
|
+
writeFileSync3(summaryPath, content.slice(0, 200).replace(/\n+/g, " ").trim() + (content.length > 200 ? "\u2026" : ""));
|
|
871
895
|
} catch {
|
|
872
896
|
}
|
|
873
897
|
const head = _readHead(fullPath);
|
|
874
898
|
if (!head.includes("[cold-storage]")) try {
|
|
875
|
-
|
|
899
|
+
writeFileSync3(fullPath, `[cold-storage] ${st.size}B original \u2192 ${hash}.summary.txt`);
|
|
876
900
|
rotated++;
|
|
877
901
|
} catch {
|
|
878
902
|
}
|
|
@@ -882,12 +906,12 @@ function _pruneScratchpadDir(targetDir, opts = {}) {
|
|
|
882
906
|
const summaryPath = join3(targetDir, hash + ".summary.txt");
|
|
883
907
|
if (!existsSync4(summaryPath)) try {
|
|
884
908
|
const content = readFileSync3(fullPath, "utf-8");
|
|
885
|
-
|
|
909
|
+
writeFileSync3(summaryPath, content.slice(0, SUMMARY_HEAD_TRUNCATE).replace(/\n+/g, " ").trim() + (content.length > SUMMARY_HEAD_TRUNCATE ? "\u2026" : ""));
|
|
886
910
|
} catch {
|
|
887
911
|
}
|
|
888
912
|
const head = _readHead(fullPath);
|
|
889
913
|
if (!head.includes("[warm-storage]") && !head.includes("[cold-storage]")) try {
|
|
890
|
-
|
|
914
|
+
writeFileSync3(fullPath, `[warm-storage] ${st.size}B original at ${hash}.summary.txt`);
|
|
891
915
|
rotated++;
|
|
892
916
|
} catch {
|
|
893
917
|
}
|
|
@@ -1920,7 +1944,7 @@ var init_session_orchestrator = __esm({
|
|
|
1920
1944
|
});
|
|
1921
1945
|
|
|
1922
1946
|
// src/lib/state.ts
|
|
1923
|
-
import { readFileSync as readFileSync4, writeFileSync as
|
|
1947
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync4, appendFileSync as appendFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync3, statSync as statSync3, readdirSync as readdirSync2, openSync, readSync, closeSync, rmSync as rmSync2, copyFileSync as copyFileSync2, renameSync as renameSync3 } from "node:fs";
|
|
1924
1948
|
import { join as join4, dirname as dirname2, basename as basename2 } from "node:path";
|
|
1925
1949
|
import { createHash as createHash3 } from "node:crypto";
|
|
1926
1950
|
function loadGlobalLearning() {
|
|
@@ -1953,7 +1977,7 @@ function updateGlobalLearning(mutator) {
|
|
|
1953
1977
|
next.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1954
1978
|
mkdirSync3(dirname2(globalLearningFile), { recursive: true });
|
|
1955
1979
|
const tmp = globalLearningFile + ".tmp";
|
|
1956
|
-
|
|
1980
|
+
writeFileSync4(tmp, JSON.stringify(next, null, 2));
|
|
1957
1981
|
renameSync3(tmp, globalLearningFile);
|
|
1958
1982
|
return next;
|
|
1959
1983
|
});
|
|
@@ -1977,7 +2001,7 @@ function saveTodos(todos) {
|
|
|
1977
2001
|
const todosFile = getTodosFile();
|
|
1978
2002
|
mkdirSync3(dirname2(todosFile), { recursive: true });
|
|
1979
2003
|
const tmp = todosFile + ".tmp." + Date.now();
|
|
1980
|
-
|
|
2004
|
+
writeFileSync4(tmp, JSON.stringify(todos, null, 2), "utf-8");
|
|
1981
2005
|
renameSync3(tmp, todosFile);
|
|
1982
2006
|
} catch {
|
|
1983
2007
|
}
|
|
@@ -2038,7 +2062,7 @@ function saveProjectState(state) {
|
|
|
2038
2062
|
withFileLock(projectStateFile, () => {
|
|
2039
2063
|
mkdirSync3(dirname2(projectStateFile), { recursive: true });
|
|
2040
2064
|
const _tmp = projectStateFile + ".tmp." + Date.now();
|
|
2041
|
-
|
|
2065
|
+
writeFileSync4(_tmp, JSON.stringify(state, null, 2) + "\n", "utf-8");
|
|
2042
2066
|
renameSync3(_tmp, projectStateFile);
|
|
2043
2067
|
});
|
|
2044
2068
|
} catch (err) {
|
|
@@ -2197,7 +2221,7 @@ function ensureCascadeAuditFiles() {
|
|
|
2197
2221
|
for (const file of ["claim-audit.jsonl", "cascade-audit.jsonl"]) {
|
|
2198
2222
|
const path = join4(dir, file);
|
|
2199
2223
|
if (!existsSync5(path)) {
|
|
2200
|
-
|
|
2224
|
+
writeFileSync4(path, "");
|
|
2201
2225
|
}
|
|
2202
2226
|
}
|
|
2203
2227
|
} catch {
|
|
@@ -2251,6 +2275,7 @@ function setCurrentProjectName(v) {
|
|
|
2251
2275
|
}
|
|
2252
2276
|
function setCurrentSessionId(v) {
|
|
2253
2277
|
currentSessionId = String(v || _OC_SID);
|
|
2278
|
+
setOcSessionId(currentSessionId);
|
|
2254
2279
|
}
|
|
2255
2280
|
function getCurrentSessionId() {
|
|
2256
2281
|
return currentSessionId || _OC_SID;
|
|
@@ -2403,7 +2428,7 @@ function _handleStateCorruption2(path) {
|
|
|
2403
2428
|
}
|
|
2404
2429
|
const logPath = join4(VIBEOS_HOME, ".state-corruption-log.jsonl");
|
|
2405
2430
|
try {
|
|
2406
|
-
|
|
2431
|
+
appendFileSync3(logPath, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), path, backup: backupPath }) + "\n");
|
|
2407
2432
|
} catch {
|
|
2408
2433
|
}
|
|
2409
2434
|
_pruneCorruptionBackups(backupDir);
|
|
@@ -2423,7 +2448,7 @@ function withFileLock(filePath, fn, opts = {}) {
|
|
|
2423
2448
|
mkdirSync3(FILE_LOCK_DIR, { recursive: true });
|
|
2424
2449
|
const fd = openSync(lockPath, "wx");
|
|
2425
2450
|
try {
|
|
2426
|
-
|
|
2451
|
+
writeFileSync4(fd, `${process.pid}
|
|
2427
2452
|
${Date.now()}
|
|
2428
2453
|
`);
|
|
2429
2454
|
} catch {
|
|
@@ -2532,7 +2557,7 @@ function appendLoopTransitionAudit(previousSession, nextSession, sid) {
|
|
|
2532
2557
|
loop_detector_confidence: Number.isFinite(Number(next.loop_detector_confidence)) ? Number(next.loop_detector_confidence) : null,
|
|
2533
2558
|
reason: String(next.loop_source_reason || next.resolution_reason || "")
|
|
2534
2559
|
};
|
|
2535
|
-
|
|
2560
|
+
appendJsonlWithRotation(auditPath, JSON.stringify(payload) + "\n");
|
|
2536
2561
|
} catch {
|
|
2537
2562
|
}
|
|
2538
2563
|
}
|
|
@@ -2559,7 +2584,7 @@ function updateState(mutator) {
|
|
|
2559
2584
|
validateState(next, delegationStateFile);
|
|
2560
2585
|
mkdirSync3(dirname2(delegationStateFile), { recursive: true });
|
|
2561
2586
|
const tmp = delegationStateFile + ".tmp";
|
|
2562
|
-
|
|
2587
|
+
writeFileSync4(tmp, JSON.stringify(next, null, 2) + "\n");
|
|
2563
2588
|
renameSync3(tmp, delegationStateFile);
|
|
2564
2589
|
invalidateSavingsCache();
|
|
2565
2590
|
return next;
|
|
@@ -2707,7 +2732,7 @@ function saveBlackboxState(state) {
|
|
|
2707
2732
|
_mirrorLiveControlVector(next);
|
|
2708
2733
|
mkdirSync3(dirname2(blackboxFile), { recursive: true });
|
|
2709
2734
|
const tmp = blackboxFile + ".tmp";
|
|
2710
|
-
|
|
2735
|
+
writeFileSync4(tmp, JSON.stringify(next, null, 2) + "\n");
|
|
2711
2736
|
renameSync3(tmp, blackboxFile);
|
|
2712
2737
|
} catch (err) {
|
|
2713
2738
|
console.error(`[vibeOS] saveBlackboxState failed: ${err.message}`);
|
|
@@ -3271,7 +3296,7 @@ function _flushLedgerBuffer() {
|
|
|
3271
3296
|
const lines = batch.map((e) => typeof e === "string" ? e.trimEnd() : String(e).trimEnd());
|
|
3272
3297
|
const joined = lines.filter(Boolean).map((l) => l + "\n").join("");
|
|
3273
3298
|
try {
|
|
3274
|
-
|
|
3299
|
+
appendFileSync3(SAVINGS_LEDGER_FILE, joined);
|
|
3275
3300
|
_compactSavingsLedgerIfNeeded();
|
|
3276
3301
|
} catch {
|
|
3277
3302
|
}
|
|
@@ -3415,7 +3440,7 @@ function _writeActiveJobsRaw(jobs) {
|
|
|
3415
3440
|
try {
|
|
3416
3441
|
mkdirSync3(dirname2(ACTIVE_JOBS_FILE), { recursive: true });
|
|
3417
3442
|
const tmp = ACTIVE_JOBS_FILE + ".tmp";
|
|
3418
|
-
|
|
3443
|
+
writeFileSync4(tmp, JSON.stringify(jobs, null, 2) + "\n");
|
|
3419
3444
|
renameSync3(tmp, ACTIVE_JOBS_FILE);
|
|
3420
3445
|
} catch {
|
|
3421
3446
|
}
|
|
@@ -3690,7 +3715,7 @@ function _compactSavingsLedgerIfNeeded() {
|
|
|
3690
3715
|
const compacted = kept.reverse().join("\n") + "\n";
|
|
3691
3716
|
if (compacted.trim() && compacted !== raw) {
|
|
3692
3717
|
const tmp = SAVINGS_LEDGER_FILE + ".tmp." + Date.now();
|
|
3693
|
-
|
|
3718
|
+
writeFileSync4(tmp, compacted, "utf-8");
|
|
3694
3719
|
renameSync3(tmp, SAVINGS_LEDGER_FILE);
|
|
3695
3720
|
}
|
|
3696
3721
|
}, { timeoutMs: 4e3 });
|
|
@@ -3878,7 +3903,7 @@ function saveSessionCheckpoint() {
|
|
|
3878
3903
|
const cpPath = join4(getSessionRoot(), "checkpoint.json");
|
|
3879
3904
|
mkdirSync3(dirname2(cpPath), { recursive: true });
|
|
3880
3905
|
const tmp = cpPath + ".tmp";
|
|
3881
|
-
|
|
3906
|
+
writeFileSync4(tmp, JSON.stringify(cp, null, 2) + "\n");
|
|
3882
3907
|
renameSync3(tmp, cpPath);
|
|
3883
3908
|
} catch {
|
|
3884
3909
|
}
|
|
@@ -4132,6 +4157,7 @@ __export(api_client_exports, {
|
|
|
4132
4157
|
VibeOSAuthError: () => VibeOSAuthError,
|
|
4133
4158
|
VibeOSNetworkError: () => VibeOSNetworkError,
|
|
4134
4159
|
VibeOSTimeoutError: () => VibeOSTimeoutError,
|
|
4160
|
+
clearRejectedToken: () => clearRejectedToken,
|
|
4135
4161
|
ensureBootstrapExchange: () => ensureBootstrapExchange,
|
|
4136
4162
|
getApiClient: () => getApiClient,
|
|
4137
4163
|
getApiFallbackSince: () => getApiFallbackSince,
|
|
@@ -4149,7 +4175,7 @@ __export(api_client_exports, {
|
|
|
4149
4175
|
setApiToken: () => setApiToken,
|
|
4150
4176
|
syncApiTokenFromDisk: () => syncApiTokenFromDisk
|
|
4151
4177
|
});
|
|
4152
|
-
import { readFileSync as readFileSync6, writeFileSync as
|
|
4178
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync3 } from "node:fs";
|
|
4153
4179
|
import { dirname as dirname4 } from "node:path";
|
|
4154
4180
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4155
4181
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -4195,7 +4221,7 @@ function persistPrimaryApiEnvState(next) {
|
|
|
4195
4221
|
const parentDir = _primaryApiEnvPath();
|
|
4196
4222
|
if (!existsSync7(parentDir)) mkdirSync5(parentDir, { recursive: true });
|
|
4197
4223
|
const nextContent = envContent.trim() ? envContent.endsWith("\n") ? envContent : envContent + "\n" : "\n";
|
|
4198
|
-
|
|
4224
|
+
writeFileSync6(primaryPath, nextContent, "utf8");
|
|
4199
4225
|
} catch (diskErr) {
|
|
4200
4226
|
console.error("[vibeOS] Failed to persist API env state:", diskErr.message);
|
|
4201
4227
|
}
|
|
@@ -4273,7 +4299,7 @@ function persistBootstrapToken(token) {
|
|
|
4273
4299
|
const bootstrapPath = _bootstrapEnvPath();
|
|
4274
4300
|
const parentDir = dirname4(bootstrapPath);
|
|
4275
4301
|
if (!existsSync7(parentDir)) mkdirSync5(parentDir, { recursive: true });
|
|
4276
|
-
|
|
4302
|
+
writeFileSync6(bootstrapPath, `VIBEOS_API_BOOTSTRAP_TOKEN=${clean}
|
|
4277
4303
|
`, "utf8");
|
|
4278
4304
|
} catch (diskErr) {
|
|
4279
4305
|
console.error("[vibeOS] Failed to persist alpha bootstrap token:", diskErr.message);
|
|
@@ -4312,6 +4338,14 @@ function invalidateApiToken() {
|
|
|
4312
4338
|
console.error("[vibeOS] Failed to invalidate API token:", e.message);
|
|
4313
4339
|
}
|
|
4314
4340
|
}
|
|
4341
|
+
function clearRejectedToken() {
|
|
4342
|
+
VIBEOS_API_TOKEN = "";
|
|
4343
|
+
_apiClientGen++;
|
|
4344
|
+
_apiClientHolder = { client: null, gen: _apiClientGen, tokenSnapshot: "" };
|
|
4345
|
+
_apiFallbackMode = false;
|
|
4346
|
+
persistPrimaryApiEnvState({ token: "" });
|
|
4347
|
+
console.warn("[vibeOS] Rejected API token cleared; will retry bootstrap exchange");
|
|
4348
|
+
}
|
|
4315
4349
|
function setApiBootstrapToken(newToken) {
|
|
4316
4350
|
try {
|
|
4317
4351
|
VIBEOS_API_BOOTSTRAP_TOKEN = String(newToken || "").trim();
|
|
@@ -4479,6 +4513,7 @@ async function remoteCall(method, args, fallbackFn) {
|
|
|
4479
4513
|
}
|
|
4480
4514
|
if (status === 401 || status === 403) {
|
|
4481
4515
|
console.warn(`[vibeOS] API auth failed (${method}): server reachable but token rejected`);
|
|
4516
|
+
clearRejectedToken();
|
|
4482
4517
|
}
|
|
4483
4518
|
if (fallbackFn) {
|
|
4484
4519
|
try {
|
|
@@ -4951,7 +4986,7 @@ __export(pricing_exports, {
|
|
|
4951
4986
|
shortModelName: () => shortModelName,
|
|
4952
4987
|
trendDisplay: () => trendDisplay
|
|
4953
4988
|
});
|
|
4954
|
-
import { readFileSync as readFileSync10, writeFileSync as
|
|
4989
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync9, existsSync as existsSync12, mkdirSync as mkdirSync10, statSync as statSync6, renameSync as renameSync5, readdirSync as readdirSync3 } from "node:fs";
|
|
4955
4990
|
import { join as join11, dirname as dirname7, resolve } from "node:path";
|
|
4956
4991
|
import { homedir as homedir5, tmpdir as tmpdir3 } from "node:os";
|
|
4957
4992
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -5253,7 +5288,7 @@ function _writeDynamicPricingCache(modelsMap) {
|
|
|
5253
5288
|
}
|
|
5254
5289
|
merged = { ...merged, ...modelsMap };
|
|
5255
5290
|
const tmp = PRICING_CACHE_FILE2 + ".tmp";
|
|
5256
|
-
|
|
5291
|
+
writeFileSync9(tmp, JSON.stringify({
|
|
5257
5292
|
ts: Date.now(),
|
|
5258
5293
|
source: "dynamic-model-pricing",
|
|
5259
5294
|
models: merged
|
|
@@ -5493,7 +5528,7 @@ function clearWorkspaceFollowupPauseForSession(sessionId = "") {
|
|
|
5493
5528
|
}
|
|
5494
5529
|
if (!touched) continue;
|
|
5495
5530
|
outer["workspace:followup"] = JSON.stringify(followup);
|
|
5496
|
-
|
|
5531
|
+
writeFileSync9(file, JSON.stringify(outer, null, 2) + "\n");
|
|
5497
5532
|
changed = true;
|
|
5498
5533
|
} catch {
|
|
5499
5534
|
}
|
|
@@ -5683,7 +5718,7 @@ function applySlot(slot, projectDir = "", opts = {}) {
|
|
|
5683
5718
|
sanitizeSelection(j.selection || (j.selection = {}));
|
|
5684
5719
|
j.selection.active_slot = slot;
|
|
5685
5720
|
const _tmp = TIERS_FILE2 + ".tmp." + Date.now();
|
|
5686
|
-
|
|
5721
|
+
writeFileSync9(_tmp, JSON.stringify(j, null, 2) + "\n", "utf-8");
|
|
5687
5722
|
renameSync5(_tmp, TIERS_FILE2);
|
|
5688
5723
|
return { ok: true, ocModel };
|
|
5689
5724
|
});
|
|
@@ -6310,7 +6345,7 @@ var init_resolution_tracker = __esm({
|
|
|
6310
6345
|
reason: "repeated negative outcomes"
|
|
6311
6346
|
};
|
|
6312
6347
|
}
|
|
6313
|
-
if (pollSignal && repeatSignal >=
|
|
6348
|
+
if (pollSignal && repeatSignal >= 4) {
|
|
6314
6349
|
return {
|
|
6315
6350
|
isLooping: true,
|
|
6316
6351
|
authority: "authoritative-local",
|
|
@@ -6347,6 +6382,15 @@ var init_resolution_tracker = __esm({
|
|
|
6347
6382
|
};
|
|
6348
6383
|
}
|
|
6349
6384
|
if (repeatSignal >= 2 || repeatSignal >= 3 && (activityRepeat >= 3 || targetRepeat >= 3)) {
|
|
6385
|
+
if (pollSignal) {
|
|
6386
|
+
return {
|
|
6387
|
+
isLooping: false,
|
|
6388
|
+
authority: "advisory-local",
|
|
6389
|
+
kind: "poll-repeat-low",
|
|
6390
|
+
confidence: 0.4,
|
|
6391
|
+
reason: "routine polling below runaway threshold"
|
|
6392
|
+
};
|
|
6393
|
+
}
|
|
6350
6394
|
return {
|
|
6351
6395
|
isLooping: true,
|
|
6352
6396
|
authority: "authoritative-local",
|
|
@@ -6741,8 +6785,12 @@ var init_crew_constants = __esm({
|
|
|
6741
6785
|
});
|
|
6742
6786
|
|
|
6743
6787
|
// src/vibeOS-lib/blackbox/pivot-cache.ts
|
|
6744
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync11, readFileSync as readFileSync11, writeFileSync as
|
|
6788
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync11, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
|
|
6745
6789
|
import { join as join12, dirname as dirname8 } from "node:path";
|
|
6790
|
+
function pivotCacheDirForSession(sessionId) {
|
|
6791
|
+
const sid = sessionId || getCurrentSessionId() || "default";
|
|
6792
|
+
return join12(getVibeOSHome(), "pivot-cache", sid);
|
|
6793
|
+
}
|
|
6746
6794
|
var PIVOT_INDEX_VERSION, MAX_INDEXED_PIVOTS, PIVOT_TTL_MS, PivotCache;
|
|
6747
6795
|
var init_pivot_cache = __esm({
|
|
6748
6796
|
"src/vibeOS-lib/blackbox/pivot-cache.ts"() {
|
|
@@ -6867,7 +6915,7 @@ var init_pivot_cache = __esm({
|
|
|
6867
6915
|
const p = this._indexPath();
|
|
6868
6916
|
const dir = dirname8(p);
|
|
6869
6917
|
if (!existsSync13(dir)) mkdirSync11(dir, { recursive: true });
|
|
6870
|
-
|
|
6918
|
+
writeFileSync10(p, JSON.stringify(index), "utf-8");
|
|
6871
6919
|
} catch {
|
|
6872
6920
|
}
|
|
6873
6921
|
}
|
|
@@ -6917,7 +6965,7 @@ var init_pivot_cache = __esm({
|
|
|
6917
6965
|
const dir = dirname8(p);
|
|
6918
6966
|
if (!existsSync13(dir)) mkdirSync11(dir, { recursive: true });
|
|
6919
6967
|
store.sequence = [...this.index.sequence];
|
|
6920
|
-
|
|
6968
|
+
writeFileSync10(p, JSON.stringify(store, null, 2), "utf-8");
|
|
6921
6969
|
this._saveIndex(this.index);
|
|
6922
6970
|
} catch {
|
|
6923
6971
|
}
|
|
@@ -7099,7 +7147,7 @@ __export(vibemax_exports, {
|
|
|
7099
7147
|
vibemaxPipeline: () => vibemaxPipeline,
|
|
7100
7148
|
vibemaxSelectMode: () => vibemaxSelectMode
|
|
7101
7149
|
});
|
|
7102
|
-
import { existsSync as existsSync14, mkdirSync as mkdirSync12, readFileSync as readFileSync12, writeFileSync as
|
|
7150
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync12, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
|
|
7103
7151
|
import { resolve as resolve2, dirname as dirname9 } from "node:path";
|
|
7104
7152
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
7105
7153
|
function fallback(sr, text) {
|
|
@@ -7162,7 +7210,11 @@ function predictTree(tree, features) {
|
|
|
7162
7210
|
return features[tree.column] <= tree.value ? predictTree(tree.left, features) : predictTree(tree.right, features);
|
|
7163
7211
|
}
|
|
7164
7212
|
function getPivotCache() {
|
|
7165
|
-
|
|
7213
|
+
const sid = getCurrentSessionId();
|
|
7214
|
+
if (!pivotCache || pivotCacheSessionId !== sid) {
|
|
7215
|
+
pivotCache = new PivotCache(pivotCacheDirForSession(sid));
|
|
7216
|
+
pivotCacheSessionId = sid;
|
|
7217
|
+
}
|
|
7166
7218
|
return pivotCache;
|
|
7167
7219
|
}
|
|
7168
7220
|
function resetVibeMaXPipeline() {
|
|
@@ -7367,24 +7419,26 @@ function loadVibeMaXModel() {
|
|
|
7367
7419
|
}
|
|
7368
7420
|
function saveVibeMaXModel(model) {
|
|
7369
7421
|
mkdirSync12(dirname9(MODEL_PATH), { recursive: true });
|
|
7370
|
-
|
|
7422
|
+
writeFileSync11(MODEL_PATH, JSON.stringify(model, null, 2) + "\n", "utf-8");
|
|
7371
7423
|
}
|
|
7372
7424
|
function getVibeMaXModelMeta() {
|
|
7373
7425
|
const m = loadVibeMaXModel();
|
|
7374
7426
|
if (!m) return { available: false, path: MODEL_PATH, message: "not trained" };
|
|
7375
7427
|
return { available: true, path: MODEL_PATH, trained_at: m.trained_at, accuracy: m.metrics?.accuracy, samples: m.samples, trees: m.trees?.length, classes: m.classes };
|
|
7376
7428
|
}
|
|
7377
|
-
var __dirname3, MODEL_PATH, BUDGET_CFG, VIBEMAX_MAP, pivotCache, prevMessage;
|
|
7429
|
+
var __dirname3, MODEL_PATH, BUDGET_CFG, VIBEMAX_MAP, pivotCache, pivotCacheSessionId, prevMessage;
|
|
7378
7430
|
var init_vibemax = __esm({
|
|
7379
7431
|
"src/vibeOS-lib/blackbox/vibemax.ts"() {
|
|
7380
7432
|
"use strict";
|
|
7381
7433
|
init_cascade();
|
|
7434
|
+
init_state();
|
|
7382
7435
|
init_pivot_cache();
|
|
7383
7436
|
__dirname3 = dirname9(fileURLToPath4(import.meta.url));
|
|
7384
7437
|
MODEL_PATH = process.env.VIBEOS_VIBEMAX_MODEL_PATH || resolve2(__dirname3, "..", "..", "..", "data", "vibemax-model.json");
|
|
7385
7438
|
BUDGET_CFG = { tier: "cheap", thinking: "off", tdd: "normal", flow: "audit", enforcement: "relaxed", wbp: "minimal", c7: "skippable", kp: [1, 3], tc: 0.1, amode: "build" };
|
|
7386
7439
|
VIBEMAX_MAP = { quality: "optimized", longrun: "optimized", audit: "optimized", speed: "budget", budget: "budget" };
|
|
7387
7440
|
pivotCache = null;
|
|
7441
|
+
pivotCacheSessionId = null;
|
|
7388
7442
|
prevMessage = "";
|
|
7389
7443
|
}
|
|
7390
7444
|
});
|
|
@@ -7962,7 +8016,11 @@ function profileFromCascade(decision) {
|
|
|
7962
8016
|
return { profile: "direct", cascade_depth: 1, pipeline_root: VIBEULTRAX_ROOT, route_path: ["cheap"], tier_bias: "cheap", selected_slot: "cheap" };
|
|
7963
8017
|
}
|
|
7964
8018
|
function getPivotCache2() {
|
|
7965
|
-
|
|
8019
|
+
const sid = getCurrentSessionId();
|
|
8020
|
+
if (!globalThis.__vibeultraxPivotCache || globalThis.__vibeultraxPivotCacheSessionId !== sid) {
|
|
8021
|
+
globalThis.__vibeultraxPivotCache = new PivotCache(pivotCacheDirForSession(sid));
|
|
8022
|
+
globalThis.__vibeultraxPivotCacheSessionId = sid;
|
|
8023
|
+
}
|
|
7966
8024
|
return globalThis.__vibeultraxPivotCache;
|
|
7967
8025
|
}
|
|
7968
8026
|
function vibeultraxControlVector(input = {}) {
|
|
@@ -8055,6 +8113,7 @@ var init_vibeultrax = __esm({
|
|
|
8055
8113
|
"src/vibeOS-lib/blackbox/vibeultrax.ts"() {
|
|
8056
8114
|
"use strict";
|
|
8057
8115
|
init_ml_router();
|
|
8116
|
+
init_state();
|
|
8058
8117
|
init_pivot_cache();
|
|
8059
8118
|
CHEAP = 1e-4;
|
|
8060
8119
|
MEDIUM = 1e-3;
|
|
@@ -8302,7 +8361,7 @@ var init_mode_table = __esm({
|
|
|
8302
8361
|
});
|
|
8303
8362
|
|
|
8304
8363
|
// src/lib/cascade.ts
|
|
8305
|
-
import { readFileSync as readFileSync13, writeFileSync as
|
|
8364
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync12, existsSync as existsSync15, mkdirSync as mkdirSync13, renameSync as renameSync6 } from "node:fs";
|
|
8306
8365
|
import { join as join13, dirname as dirname10 } from "node:path";
|
|
8307
8366
|
function detectOutcomeSignal(text) {
|
|
8308
8367
|
if (!text) return null;
|
|
@@ -9067,8 +9126,15 @@ function mergeAuthoritativeBlackboxState(localState, apiResult) {
|
|
|
9067
9126
|
}
|
|
9068
9127
|
async function fetchBlackboxEnrichment(sessionId, userText2, localState) {
|
|
9069
9128
|
try {
|
|
9070
|
-
|
|
9071
|
-
if (!client2
|
|
9129
|
+
let client2 = getApiClient();
|
|
9130
|
+
if (!client2) {
|
|
9131
|
+
await ensureBootstrapExchange();
|
|
9132
|
+
client2 = getApiClient();
|
|
9133
|
+
}
|
|
9134
|
+
if (!client2 || isApiFallback()) {
|
|
9135
|
+
console.warn(`[vibeOS] blackbox enrichment skipped: client=${!!client2} apiFallback=${isApiFallback()}`);
|
|
9136
|
+
return null;
|
|
9137
|
+
}
|
|
9072
9138
|
const analyze = client2.blackboxAnalyze(sessionId, {
|
|
9073
9139
|
userText: typeof userText2 === "string" ? userText2 : "",
|
|
9074
9140
|
features: localState.features || {},
|
|
@@ -9083,7 +9149,11 @@ async function fetchBlackboxEnrichment(sessionId, userText2, localState) {
|
|
|
9083
9149
|
_latestBlackboxPivotMsg = result.pivot_directive || null;
|
|
9084
9150
|
return mergeAuthoritativeBlackboxState(localState, result);
|
|
9085
9151
|
}
|
|
9086
|
-
} catch {
|
|
9152
|
+
} catch (err) {
|
|
9153
|
+
const status = err?.statusCode || err?.status || 0;
|
|
9154
|
+
const detail = status ? `status=${status}` : `message=${err?.message || err}`;
|
|
9155
|
+
console.warn(`[vibeOS] blackbox enrichment failed, falling back to local: ${detail}`);
|
|
9156
|
+
if (status === 401 || status === 403) clearRejectedToken();
|
|
9087
9157
|
}
|
|
9088
9158
|
return null;
|
|
9089
9159
|
}
|
|
@@ -9688,13 +9758,13 @@ var init_cascade = __esm({
|
|
|
9688
9758
|
});
|
|
9689
9759
|
|
|
9690
9760
|
// src/index.ts
|
|
9691
|
-
import { readFileSync as readFileSync30, writeFileSync as
|
|
9761
|
+
import { readFileSync as readFileSync30, writeFileSync as writeFileSync24, existsSync as existsSync32, mkdirSync as mkdirSync23, copyFileSync as copyFileSync4, renameSync as renameSync10, statSync as statSync11, appendFileSync as appendFileSync9 } from "node:fs";
|
|
9692
9762
|
import { join as join30, dirname as dirname18, basename as basename6 } from "node:path";
|
|
9693
9763
|
|
|
9694
9764
|
// src/vibeOS-lib/flow-enforcer.ts
|
|
9695
9765
|
init_state();
|
|
9696
9766
|
init_fs_helpers();
|
|
9697
|
-
import { readFileSync as readFileSync5, existsSync as existsSync6, mkdirSync as mkdirSync4, writeFileSync as
|
|
9767
|
+
import { readFileSync as readFileSync5, existsSync as existsSync6, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5, statSync as statSync4, appendFileSync as appendFileSync4, renameSync as renameSync4 } from "node:fs";
|
|
9698
9768
|
import { join as join5, dirname as dirname3 } from "node:path";
|
|
9699
9769
|
import { fileURLToPath } from "node:url";
|
|
9700
9770
|
var VIBEOS_STDERR_DEBUG = process.env.VIBEOS_DEBUG_STDERR === "1" || process.env.VIBEOS_DEBUG_LOGS === "1";
|
|
@@ -9798,7 +9868,7 @@ function ensureProjectDocs(dir, techStack) {
|
|
|
9798
9868
|
try {
|
|
9799
9869
|
if (!existsSync6(agentsPath)) {
|
|
9800
9870
|
try {
|
|
9801
|
-
|
|
9871
|
+
writeFileSync5(agentsPath, GUARD_AGENTS_TEMPLATE, "utf-8");
|
|
9802
9872
|
created.push("AGENTS.md");
|
|
9803
9873
|
console.error("[vibeOS] Project Guard: created AGENTS.md");
|
|
9804
9874
|
} catch (err) {
|
|
@@ -9815,7 +9885,7 @@ function ensureProjectDocs(dir, techStack) {
|
|
|
9815
9885
|
const stack = techStack || [];
|
|
9816
9886
|
const content = GUARD_README_TEMPLATE(name, stack);
|
|
9817
9887
|
try {
|
|
9818
|
-
|
|
9888
|
+
writeFileSync5(readmePath, content, "utf-8");
|
|
9819
9889
|
created.push("README.md");
|
|
9820
9890
|
console.error("[vibeOS] Project Guard: created README.md");
|
|
9821
9891
|
} catch (err) {
|
|
@@ -9869,7 +9939,7 @@ function persistFlowDedupKey(key) {
|
|
|
9869
9939
|
if (!keys.includes(key)) {
|
|
9870
9940
|
keys.push(key);
|
|
9871
9941
|
if (keys.length > 1e3) keys = keys.slice(-500);
|
|
9872
|
-
|
|
9942
|
+
writeFileSync5(FLOW_DEDUP_FILE2, JSON.stringify(keys), "utf-8");
|
|
9873
9943
|
}
|
|
9874
9944
|
} catch {
|
|
9875
9945
|
}
|
|
@@ -10069,7 +10139,7 @@ function recordFlowWarn(hit) {
|
|
|
10069
10139
|
const existing = safeJsonParse(existsSync6(stateFile2) ? readFileSync5(stateFile2, "utf-8") : "{}");
|
|
10070
10140
|
const merged = Object.assign({}, existing, fp3);
|
|
10071
10141
|
const tmpFile = stateFile2 + ".tmp." + Date.now();
|
|
10072
|
-
|
|
10142
|
+
writeFileSync5(tmpFile, JSON.stringify(merged, null, 2));
|
|
10073
10143
|
renameSync4(tmpFile, stateFile2);
|
|
10074
10144
|
}
|
|
10075
10145
|
} catch {
|
|
@@ -10145,11 +10215,11 @@ function recordFlowTodo({ filePath, content }) {
|
|
|
10145
10215
|
filePath,
|
|
10146
10216
|
todos
|
|
10147
10217
|
}) + "\n";
|
|
10148
|
-
|
|
10218
|
+
appendFileSync4(flowTodoFile, entry);
|
|
10149
10219
|
try {
|
|
10150
10220
|
const lines = readFileSync5(flowTodoFile, "utf-8").trim().split("\n").filter(Boolean);
|
|
10151
10221
|
if (lines.length > MAX_FLOW_TODOS) {
|
|
10152
|
-
|
|
10222
|
+
writeFileSync5(flowTodoFile, lines.slice(-Math.floor(MAX_FLOW_TODOS / 2)).join("\n") + "\n");
|
|
10153
10223
|
}
|
|
10154
10224
|
} catch {
|
|
10155
10225
|
}
|
|
@@ -10355,14 +10425,14 @@ function computeSessionMetrics(state, sessionId) {
|
|
|
10355
10425
|
// src/lib/vibeos-mcp-server.ts
|
|
10356
10426
|
import http from "node:http";
|
|
10357
10427
|
import { parse as parseUrl } from "node:url";
|
|
10358
|
-
import { createReadStream, existsSync as existsSync11, mkdirSync as mkdirSync9, statSync as statSync5, writeFileSync as
|
|
10428
|
+
import { createReadStream, existsSync as existsSync11, mkdirSync as mkdirSync9, statSync as statSync5, writeFileSync as writeFileSync8 } from "node:fs";
|
|
10359
10429
|
import { extname, join as join10, dirname as dirname6 } from "node:path";
|
|
10360
10430
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
10361
10431
|
|
|
10362
10432
|
// src/lib/dashboard-bridge.ts
|
|
10363
10433
|
init_api_client();
|
|
10364
10434
|
init_state();
|
|
10365
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as
|
|
10435
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
10366
10436
|
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
10367
10437
|
import { dirname as dirname5, join as join6 } from "node:path";
|
|
10368
10438
|
var DASHBOARD_BRIDGE_FILE = ".dashboard-bridge.json";
|
|
@@ -10405,7 +10475,7 @@ function saveBridgeState(state) {
|
|
|
10405
10475
|
try {
|
|
10406
10476
|
const file = bridgeFile();
|
|
10407
10477
|
mkdirSync6(dirname5(file), { recursive: true });
|
|
10408
|
-
|
|
10478
|
+
writeFileSync7(file, JSON.stringify(state, null, 2), "utf8");
|
|
10409
10479
|
} catch {
|
|
10410
10480
|
}
|
|
10411
10481
|
}
|
|
@@ -10553,14 +10623,15 @@ init_api_client();
|
|
|
10553
10623
|
|
|
10554
10624
|
// src/lib/session-health.ts
|
|
10555
10625
|
init_state();
|
|
10556
|
-
import {
|
|
10626
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync8, readFileSync as readFileSync9 } from "node:fs";
|
|
10557
10627
|
import { homedir as homedir4 } from "node:os";
|
|
10558
10628
|
import { join as join8 } from "node:path";
|
|
10559
10629
|
import { execFileSync } from "node:child_process";
|
|
10560
10630
|
|
|
10561
10631
|
// src/lib/turn-ledger.ts
|
|
10562
10632
|
init_state();
|
|
10563
|
-
|
|
10633
|
+
init_fs_helpers();
|
|
10634
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync8 } from "node:fs";
|
|
10564
10635
|
import { createHash as createHash5 } from "node:crypto";
|
|
10565
10636
|
import { join as join7 } from "node:path";
|
|
10566
10637
|
function ledgerFile() {
|
|
@@ -10655,7 +10726,7 @@ function recordTurnRoute(input) {
|
|
|
10655
10726
|
};
|
|
10656
10727
|
try {
|
|
10657
10728
|
ensureLedgerDir();
|
|
10658
|
-
|
|
10729
|
+
appendJsonlWithRotation(ledgerFile(), JSON.stringify(event) + "\n");
|
|
10659
10730
|
} catch {
|
|
10660
10731
|
}
|
|
10661
10732
|
return { sessionId, turnId };
|
|
@@ -10674,7 +10745,7 @@ function recordTurnFinalize(input) {
|
|
|
10674
10745
|
};
|
|
10675
10746
|
try {
|
|
10676
10747
|
ensureLedgerDir();
|
|
10677
|
-
|
|
10748
|
+
appendJsonlWithRotation(ledgerFile(), JSON.stringify(event) + "\n");
|
|
10678
10749
|
} catch {
|
|
10679
10750
|
}
|
|
10680
10751
|
return { sessionId, turnId };
|
|
@@ -10721,6 +10792,7 @@ function getLatestTurnTruth(sessionId = getCurrentSessionId()) {
|
|
|
10721
10792
|
}
|
|
10722
10793
|
|
|
10723
10794
|
// src/lib/session-health.ts
|
|
10795
|
+
init_fs_helpers();
|
|
10724
10796
|
var CLAIM_PATTERNS = [
|
|
10725
10797
|
/(?:I|we|the)\s+(?:pushed|released|merged|deployed|fixed|wrote|implemented|completed|committed)\b/i,
|
|
10726
10798
|
/(?:tests?|build|CI|checks?|suite|output|result)\s+(?:is\s+|are\s+)?(?:pass(?:ing|ed|es)?|green|clean|succeed|stable|positive)/i,
|
|
@@ -11069,7 +11141,7 @@ function getSessionHealthSnapshot(input = {}) {
|
|
|
11069
11141
|
function persistSessionHealthSnapshot(snapshot, vibeHome = getVibeOSHome()) {
|
|
11070
11142
|
try {
|
|
11071
11143
|
mkdirSync8(vibeHome, { recursive: true });
|
|
11072
|
-
|
|
11144
|
+
appendJsonlWithRotation(join8(vibeHome, "session-health.jsonl"), JSON.stringify(snapshot) + "\n");
|
|
11073
11145
|
} catch {
|
|
11074
11146
|
}
|
|
11075
11147
|
}
|
|
@@ -11206,7 +11278,7 @@ function writeDashboardBaseConfig(baseUrl) {
|
|
|
11206
11278
|
const payload = `window.__VIBEOS_DASHBOARD_BASE__ = ${b};
|
|
11207
11279
|
window.__VIBEOS_BACKEND_API_BASE__ = ${b};
|
|
11208
11280
|
`;
|
|
11209
|
-
|
|
11281
|
+
writeFileSync8(DASHBOARD_CONFIG_PATH, payload, "utf-8");
|
|
11210
11282
|
return DASHBOARD_CONFIG_PATH;
|
|
11211
11283
|
} catch {
|
|
11212
11284
|
return null;
|
|
@@ -12326,7 +12398,7 @@ init_pricing();
|
|
|
12326
12398
|
// src/lib/runtime-config.ts
|
|
12327
12399
|
init_state();
|
|
12328
12400
|
init_runtime_paths();
|
|
12329
|
-
import { existsSync as existsSync17, mkdirSync as mkdirSync14, readFileSync as readFileSync15, writeFileSync as
|
|
12401
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync14, readFileSync as readFileSync15, writeFileSync as writeFileSync13, renameSync as renameSync7, readdirSync as readdirSync4, rmSync as rmSync4 } from "node:fs";
|
|
12330
12402
|
import { basename as basename3, dirname as dirname11, join as join15 } from "node:path";
|
|
12331
12403
|
var FALLBACK_SLOT_MODELS = {
|
|
12332
12404
|
cheap: "deepseek/deepseek-v4-flash",
|
|
@@ -12431,7 +12503,7 @@ function readOpenCodeConfig(path) {
|
|
|
12431
12503
|
function writeOpenCodeConfig(path, config) {
|
|
12432
12504
|
mkdirSync14(dirname11(path), { recursive: true });
|
|
12433
12505
|
const tmp = `${path}.tmp.${process.pid}.${Date.now()}`;
|
|
12434
|
-
|
|
12506
|
+
writeFileSync13(tmp, JSON.stringify(config, null, 2) + "\n");
|
|
12435
12507
|
renameSync7(tmp, path);
|
|
12436
12508
|
}
|
|
12437
12509
|
function installVibeTierAgentsInConfig(config, trinity, activeSlot = null) {
|
|
@@ -12776,7 +12848,7 @@ init_templates();
|
|
|
12776
12848
|
// src/lib/reporting.ts
|
|
12777
12849
|
init_state();
|
|
12778
12850
|
init_runtime_state();
|
|
12779
|
-
import { readFileSync as readFileSync16, writeFileSync as
|
|
12851
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync14, existsSync as existsSync18, mkdirSync as mkdirSync15, statSync as statSync7, rmSync as rmSync5 } from "node:fs";
|
|
12780
12852
|
import { join as join16 } from "node:path";
|
|
12781
12853
|
function getReportsDir() {
|
|
12782
12854
|
return join16(getVibeOSHome(), "reports");
|
|
@@ -12814,7 +12886,7 @@ function saveReportsIndex(idx) {
|
|
|
12814
12886
|
const reportsDir = getReportsDir();
|
|
12815
12887
|
withFileLock(reportsIndexPath, () => {
|
|
12816
12888
|
mkdirSync15(reportsDir, { recursive: true });
|
|
12817
|
-
|
|
12889
|
+
writeFileSync14(reportsIndexPath, JSON.stringify(idx, null, 2) + "\n");
|
|
12818
12890
|
});
|
|
12819
12891
|
} catch (err) {
|
|
12820
12892
|
console.error(`[vibeOS] reports index write failed: ${err.message}`);
|
|
@@ -12855,11 +12927,19 @@ function _pruneReports() {
|
|
|
12855
12927
|
}
|
|
12856
12928
|
keep.push(r);
|
|
12857
12929
|
}
|
|
12858
|
-
const
|
|
12930
|
+
const sorted = keep.sort((a, b) => b.created.localeCompare(a.created));
|
|
12931
|
+
const pruned = sorted.slice(0, 200);
|
|
12932
|
+
const dropped = sorted.slice(200);
|
|
12859
12933
|
if (pruned.length !== idx.reports.length) {
|
|
12934
|
+
for (const r of dropped) {
|
|
12935
|
+
try {
|
|
12936
|
+
rmSync5(join16(getReportsDir(), `${r.id}.json`));
|
|
12937
|
+
} catch {
|
|
12938
|
+
}
|
|
12939
|
+
}
|
|
12860
12940
|
idx.reports = pruned;
|
|
12861
12941
|
saveReportsIndex(idx);
|
|
12862
|
-
console.
|
|
12942
|
+
console.warn(`[vibeOS] reports pruned: ${idx.reports.length} kept (from ${keep.length}), ${dropped.length} over-cap files deleted`);
|
|
12863
12943
|
}
|
|
12864
12944
|
} catch (err) {
|
|
12865
12945
|
console.error(`[vibeOS] reports prune failed: ${err.message}`);
|
|
@@ -12984,11 +13064,11 @@ function saveReport({ type = "manual", summary = "", findings = null, metrics =
|
|
|
12984
13064
|
const reportsDir = getReportsDir();
|
|
12985
13065
|
withFileLock(reportsIndexPath, () => {
|
|
12986
13066
|
mkdirSync15(reportsDir, { recursive: true });
|
|
12987
|
-
|
|
13067
|
+
writeFileSync14(join16(reportsDir, `${id2}.json`), JSON.stringify(report, null, 2) + "\n");
|
|
12988
13068
|
const idx = reportsIndex();
|
|
12989
13069
|
const _sum = (summary || "").slice(0, 80);
|
|
12990
13070
|
idx.reports.push({ id: id2, type, project: report.meta.project, fingerprint: fp3, created: report.meta.created, summary: _sum });
|
|
12991
|
-
|
|
13071
|
+
writeFileSync14(reportsIndexPath, JSON.stringify(idx, null, 2) + "\n");
|
|
12992
13072
|
});
|
|
12993
13073
|
try {
|
|
12994
13074
|
if (fp3 && fp3 !== "unknown") {
|
|
@@ -13041,7 +13121,7 @@ init_selection_manager();
|
|
|
13041
13121
|
init_pricing();
|
|
13042
13122
|
init_state();
|
|
13043
13123
|
init_fs_helpers();
|
|
13044
|
-
import { readFileSync as readFileSync17, writeFileSync as
|
|
13124
|
+
import { readFileSync as readFileSync17, writeFileSync as writeFileSync15, existsSync as existsSync19 } from "node:fs";
|
|
13045
13125
|
import { join as join17 } from "node:path";
|
|
13046
13126
|
var BALANCE_APIS = {
|
|
13047
13127
|
deepseek: {
|
|
@@ -13093,7 +13173,7 @@ async function _snapshot() {
|
|
|
13093
13173
|
}
|
|
13094
13174
|
}
|
|
13095
13175
|
try {
|
|
13096
|
-
|
|
13176
|
+
writeFileSync15(CREDIT_CACHE_F, JSON.stringify({ total, providers: provs, ts: Date.now() }));
|
|
13097
13177
|
} catch {
|
|
13098
13178
|
}
|
|
13099
13179
|
}
|
|
@@ -15316,21 +15396,22 @@ async function probeModel(modelId, auth, providers = null) {
|
|
|
15316
15396
|
// src/lib/hooks/footer.ts
|
|
15317
15397
|
init_pricing();
|
|
15318
15398
|
import { createHash as createHash9 } from "node:crypto";
|
|
15319
|
-
import { appendFileSync as
|
|
15399
|
+
import { appendFileSync as appendFileSync6, mkdirSync as mkdirSync19, readFileSync as readFileSync24, existsSync as existsSync26 } from "node:fs";
|
|
15320
15400
|
import { join as join25 } from "node:path";
|
|
15321
15401
|
|
|
15322
15402
|
// src/lib/hooks/chat-transform.ts
|
|
15323
15403
|
init_state();
|
|
15324
15404
|
init_cascade();
|
|
15405
|
+
init_fs_helpers();
|
|
15325
15406
|
init_loop_state();
|
|
15326
15407
|
init_turn_memo();
|
|
15327
|
-
import { readFileSync as readFileSync23, writeFileSync as
|
|
15408
|
+
import { readFileSync as readFileSync23, writeFileSync as writeFileSync20, existsSync as existsSync25, mkdirSync as mkdirSync18, rmSync as rmSync6, readdirSync as readdirSync5, statSync as statSync9, renameSync as renameSync9 } from "node:fs";
|
|
15328
15409
|
import { join as join24, dirname as dirname14, basename as basename4 } from "node:path";
|
|
15329
15410
|
import { createHash as createHash8 } from "node:crypto";
|
|
15330
15411
|
|
|
15331
15412
|
// src/lib/project-tree.ts
|
|
15332
15413
|
init_state();
|
|
15333
|
-
import { readFileSync as readFileSync20, writeFileSync as
|
|
15414
|
+
import { readFileSync as readFileSync20, writeFileSync as writeFileSync16, existsSync as existsSync22, renameSync as renameSync8, statSync as statSync8 } from "node:fs";
|
|
15334
15415
|
import { join as join20 } from "node:path";
|
|
15335
15416
|
var MAX_BRANCHES_PER_PROJECT = 24;
|
|
15336
15417
|
var MAX_FACTS_PER_BRANCH = 12;
|
|
@@ -15382,7 +15463,7 @@ function recordProjectFact(fp3, projectName, branch, kind, text) {
|
|
|
15382
15463
|
proj.updated_at = Date.now();
|
|
15383
15464
|
j.projects[fp3] = proj;
|
|
15384
15465
|
const tmp = f + ".tmp." + Date.now();
|
|
15385
|
-
|
|
15466
|
+
writeFileSync16(tmp, JSON.stringify(j, null, 2) + "\n");
|
|
15386
15467
|
renameSync8(tmp, f);
|
|
15387
15468
|
return true;
|
|
15388
15469
|
});
|
|
@@ -15421,18 +15502,18 @@ init_selection_manager();
|
|
|
15421
15502
|
|
|
15422
15503
|
// src/lib/index-helpers.ts
|
|
15423
15504
|
import { join as join23 } from "node:path";
|
|
15424
|
-
import { writeFileSync as
|
|
15505
|
+
import { writeFileSync as writeFileSync19 } from "node:fs";
|
|
15425
15506
|
|
|
15426
15507
|
// src/vibeOS-lib/semantic-observer.ts
|
|
15427
15508
|
init_state();
|
|
15428
15509
|
init_pattern_helpers();
|
|
15429
15510
|
init_pattern_helpers();
|
|
15430
15511
|
import { join as join22 } from "node:path";
|
|
15431
|
-
import { mkdirSync as mkdirSync17, writeFileSync as
|
|
15512
|
+
import { mkdirSync as mkdirSync17, writeFileSync as writeFileSync18, readFileSync as readFileSync22, existsSync as existsSync24 } from "node:fs";
|
|
15432
15513
|
|
|
15433
15514
|
// src/lib/pattern-store.ts
|
|
15434
15515
|
init_state();
|
|
15435
|
-
import { existsSync as existsSync23, mkdirSync as mkdirSync16, readFileSync as readFileSync21, writeFileSync as
|
|
15516
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync16, readFileSync as readFileSync21, writeFileSync as writeFileSync17, appendFileSync as appendFileSync5 } from "node:fs";
|
|
15436
15517
|
import { join as join21, dirname as dirname13 } from "node:path";
|
|
15437
15518
|
import { homedir as homedir6 } from "node:os";
|
|
15438
15519
|
function upsertProjectPattern(kind, key, summary, meta = {}) {
|
|
@@ -15508,7 +15589,7 @@ function writeEvent(sid, event) {
|
|
|
15508
15589
|
}
|
|
15509
15590
|
lines.push(JSON.stringify(event));
|
|
15510
15591
|
if (lines.length > 200) lines = lines.slice(-200);
|
|
15511
|
-
|
|
15592
|
+
writeFileSync18(path, lines.join("\n") + "\n");
|
|
15512
15593
|
}
|
|
15513
15594
|
function readRecentEvents(sid, n) {
|
|
15514
15595
|
const path = getSessionEventLogPath(sid);
|
|
@@ -15689,7 +15770,7 @@ function sessionCompact(sid, fingerprint) {
|
|
|
15689
15770
|
ses.resolution_reason = summary || "looping friction detected";
|
|
15690
15771
|
ses.live_next_action = patterns.length > 0 ? `Address friction: ${topPattern?.summary || "review the repeated loop"}` : "Review the repeated loop and reduce friction";
|
|
15691
15772
|
ses.live_updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
15692
|
-
|
|
15773
|
+
writeFileSync18(bbPath, JSON.stringify(bb, null, 2));
|
|
15693
15774
|
}
|
|
15694
15775
|
}
|
|
15695
15776
|
}
|
|
@@ -15903,7 +15984,7 @@ function recordSaving(tool2, reason, saveEst, meta = {}) {
|
|
|
15903
15984
|
if (sd) {
|
|
15904
15985
|
const sp = join23(sd, "delegation-state-hint.txt");
|
|
15905
15986
|
try {
|
|
15906
|
-
|
|
15987
|
+
writeFileSync19(sp, JSON.stringify({ sid, total_savings: s.lifetime.total_savings_usd, last_reason: reason }), "utf8");
|
|
15907
15988
|
} catch {
|
|
15908
15989
|
}
|
|
15909
15990
|
}
|
|
@@ -16033,7 +16114,7 @@ function updateOpenCodeConfig(mutator) {
|
|
|
16033
16114
|
const result = mutator(oc);
|
|
16034
16115
|
if (result === false) return false;
|
|
16035
16116
|
const tmp = `${OC_CONFIG}.tmp.${process.pid}.${Date.now()}`;
|
|
16036
|
-
|
|
16117
|
+
writeFileSync20(tmp, JSON.stringify(oc, null, 2) + "\n");
|
|
16037
16118
|
renameSync9(tmp, OC_CONFIG);
|
|
16038
16119
|
return true;
|
|
16039
16120
|
} catch {
|
|
@@ -16440,7 +16521,7 @@ function ensureProjectSkill(dir, fp3) {
|
|
|
16440
16521
|
}
|
|
16441
16522
|
try {
|
|
16442
16523
|
mkdirSync18(skillDir, { recursive: true });
|
|
16443
|
-
|
|
16524
|
+
writeFileSync20(skillPath, content, "utf-8");
|
|
16444
16525
|
console.error(`[vibeOS] Project Guard: created .opencode/skills/${projectName}/SKILL.md`);
|
|
16445
16526
|
return { created: true, path: skillPath, skipped: false };
|
|
16446
16527
|
} catch (err) {
|
|
@@ -16721,7 +16802,7 @@ ${raw}
|
|
|
16721
16802
|
mkdirSync18(globalDir, { recursive: true });
|
|
16722
16803
|
ensureSessionScratchpadDirs();
|
|
16723
16804
|
if (!existsSync25(globalPath)) {
|
|
16724
|
-
|
|
16805
|
+
writeFileSync20(globalPath, raw);
|
|
16725
16806
|
indexAppend(hash, part.tool, raw.length);
|
|
16726
16807
|
if (existsSync25(sessPath)) rmSync6(sessPath, { force: true });
|
|
16727
16808
|
}
|
|
@@ -16736,7 +16817,7 @@ ${stableJson(invPart.state.input)}
|
|
|
16736
16817
|
`).digest("hex").slice(0, 16);
|
|
16737
16818
|
const ptrPath = join24(getSessionScratchpadDir(), `${inputHash}.ptr`);
|
|
16738
16819
|
try {
|
|
16739
|
-
|
|
16820
|
+
writeFileSync20(ptrPath, JSON.stringify({ contentHash: hash, tool: part.tool }));
|
|
16740
16821
|
} catch {
|
|
16741
16822
|
}
|
|
16742
16823
|
}
|
|
@@ -17465,7 +17546,7 @@ var onSystemTransform = async (_input, output) => {
|
|
|
17465
17546
|
try {
|
|
17466
17547
|
const calFile = join24(getVibeOSHome(), "calibration-data.jsonl");
|
|
17467
17548
|
mkdirSync18(getVibeOSHome(), { recursive: true });
|
|
17468
|
-
|
|
17549
|
+
appendJsonlWithRotation(calFile, _calBuffer.join(""));
|
|
17469
17550
|
_calBuffer.length = 0;
|
|
17470
17551
|
} catch {
|
|
17471
17552
|
}
|
|
@@ -17657,14 +17738,14 @@ function resolveActiveCascadeTier(opts) {
|
|
|
17657
17738
|
if (tier2) return { tier: tier2, depth, source: "route" };
|
|
17658
17739
|
}
|
|
17659
17740
|
}
|
|
17660
|
-
const legacyDepth = Number(opts.legacyDepth)
|
|
17741
|
+
const legacyDepth = opts.legacyDepth !== void 0 && opts.legacyDepth !== null && Number.isFinite(Number(opts.legacyDepth)) ? Number(opts.legacyDepth) : null;
|
|
17661
17742
|
const m = opts.liveModel || "";
|
|
17662
|
-
if (opts.trinityCheap && m === opts.trinityCheap) return { tier: "cheap", depth: legacyDepth
|
|
17663
|
-
if (opts.trinityMedium && m === opts.trinityMedium) return { tier: "medium", depth: legacyDepth
|
|
17664
|
-
if (opts.trinityBrain && m === opts.trinityBrain) return { tier: "brain", depth: legacyDepth
|
|
17743
|
+
if (opts.trinityCheap && m === opts.trinityCheap) return { tier: "cheap", depth: legacyDepth ?? 1, source: "model" };
|
|
17744
|
+
if (opts.trinityMedium && m === opts.trinityMedium) return { tier: "medium", depth: legacyDepth ?? 2, source: "model" };
|
|
17745
|
+
if (opts.trinityBrain && m === opts.trinityBrain) return { tier: "brain", depth: legacyDepth ?? 3, source: "model" };
|
|
17665
17746
|
const c = String((opts.classify ? opts.classify(m) : "") || "").toLowerCase();
|
|
17666
17747
|
const tier = c === "high" || c === "brain" ? "brain" : c === "mid" || c === "medium" ? "medium" : "cheap";
|
|
17667
|
-
return { tier, depth: legacyDepth
|
|
17748
|
+
return { tier, depth: legacyDepth ?? (tier === "brain" ? 3 : tier === "medium" ? 2 : 1), source: "model" };
|
|
17668
17749
|
}
|
|
17669
17750
|
function resolveRegimeIcon(subRegime) {
|
|
17670
17751
|
return REGIME_ICON[String(subRegime || "").toUpperCase()] || "\u25E6";
|
|
@@ -18078,7 +18159,7 @@ function recordSessionBridge(bridge) {
|
|
|
18078
18159
|
try {
|
|
18079
18160
|
const dir = getVibeOSHome();
|
|
18080
18161
|
mkdirSync19(dir, { recursive: true });
|
|
18081
|
-
|
|
18162
|
+
appendFileSync6(join25(dir, ".session-bridges.jsonl"), JSON.stringify({ _ts: (/* @__PURE__ */ new Date()).toISOString(), ...bridge }) + "\n");
|
|
18082
18163
|
} catch {
|
|
18083
18164
|
}
|
|
18084
18165
|
return true;
|
|
@@ -18236,7 +18317,7 @@ function recordFooterProbe(input) {
|
|
|
18236
18317
|
if (!sid) return;
|
|
18237
18318
|
const dir = join25(getVibeOSHome(), "session-events");
|
|
18238
18319
|
mkdirSync19(dir, { recursive: true });
|
|
18239
|
-
|
|
18320
|
+
appendFileSync6(join25(dir, `${sid}.jsonl`), JSON.stringify({
|
|
18240
18321
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18241
18322
|
kind: "footer-probe",
|
|
18242
18323
|
hook: input.hook,
|
|
@@ -18260,7 +18341,7 @@ function recordFooterError(input) {
|
|
|
18260
18341
|
if (!sid) return;
|
|
18261
18342
|
const dir = join25(getVibeOSHome(), "session-events");
|
|
18262
18343
|
mkdirSync19(dir, { recursive: true });
|
|
18263
|
-
|
|
18344
|
+
appendFileSync6(join25(dir, `${sid}.jsonl`), JSON.stringify({
|
|
18264
18345
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18265
18346
|
kind: "footer-error",
|
|
18266
18347
|
hook: input.hook || "",
|
|
@@ -18271,438 +18352,446 @@ function recordFooterError(input) {
|
|
|
18271
18352
|
} catch {
|
|
18272
18353
|
}
|
|
18273
18354
|
}
|
|
18274
|
-
|
|
18355
|
+
function _payload(obj) {
|
|
18356
|
+
if (obj?.message && typeof obj.message === "object") return obj.message;
|
|
18357
|
+
return obj;
|
|
18358
|
+
}
|
|
18359
|
+
function _extractText(obj) {
|
|
18360
|
+
const payload = _payload(obj);
|
|
18361
|
+
if (typeof payload?.text === "string") return payload.text;
|
|
18362
|
+
if (typeof payload?.result === "string") return payload.result;
|
|
18363
|
+
if (typeof payload?.content === "string") return payload.content;
|
|
18364
|
+
if (Array.isArray(payload?.content)) return payload.content.filter((p) => p?.type === "text").map((p) => p.text).filter(Boolean).join("\n");
|
|
18365
|
+
if (Array.isArray(payload?.parts)) return payload.parts.filter((p) => p?.type === "text").map((p) => p.text).filter(Boolean).join("\n");
|
|
18366
|
+
return "";
|
|
18367
|
+
}
|
|
18368
|
+
function _setFooter(obj, text) {
|
|
18369
|
+
const target = _payload(obj);
|
|
18370
|
+
if (typeof target?.text === "string") target.text = text;
|
|
18371
|
+
else if (typeof target?.result === "string") target.result = text;
|
|
18372
|
+
else if (typeof target?.content === "string") target.content = text;
|
|
18373
|
+
else if (Array.isArray(target?.content)) {
|
|
18374
|
+
const textParts = target.content.filter((p) => p?.type === "text");
|
|
18375
|
+
if (textParts.length > 0) textParts[textParts.length - 1].text = text;
|
|
18376
|
+
else target.content.push({ type: "text", text });
|
|
18377
|
+
} else if (Array.isArray(target?.parts)) {
|
|
18378
|
+
const textParts = target.parts.filter((p) => p?.type === "text");
|
|
18379
|
+
if (textParts.length > 0) textParts[textParts.length - 1].text = text;
|
|
18380
|
+
else target.parts.push({ type: "text", text });
|
|
18381
|
+
} else target.text = text;
|
|
18382
|
+
}
|
|
18383
|
+
async function resolveFooterDisplayState(directory3, text, hookModel = "", lastModelError, hookName = "experimental.text.complete") {
|
|
18275
18384
|
_refreshModel(directory3);
|
|
18276
|
-
let _footerStage = "init";
|
|
18277
18385
|
let _footerStress = 0;
|
|
18278
18386
|
const quietIntent = isGreetingLike2(latestUserIntent || "");
|
|
18279
18387
|
if (latestUserIntent) _footerStress = scoreStress(latestUserIntent);
|
|
18280
18388
|
let liveBlackboxState = quietIntent ? null : getLatestBlackboxState();
|
|
18281
18389
|
const diskBlackboxState = quietIntent ? null : loadBlackboxState();
|
|
18390
|
+
const _footerSid = getSessionId();
|
|
18391
|
+
const diskSessionState = diskBlackboxState?.sessions?.[_footerSid] || null;
|
|
18282
18392
|
try {
|
|
18283
18393
|
const liveCascadeDepth = Number(
|
|
18284
18394
|
liveBlackboxState?.control_vector?.cascade_depth ?? liveBlackboxState?.cascade_depth ?? 0
|
|
18285
18395
|
) || 0;
|
|
18286
18396
|
const diskCascadeDepth = Number(
|
|
18287
|
-
|
|
18397
|
+
diskSessionState?.control_vector?.cascade_depth ?? diskSessionState?.cascade_depth ?? 0
|
|
18288
18398
|
) || 0;
|
|
18289
|
-
if (
|
|
18290
|
-
liveBlackboxState =
|
|
18399
|
+
if (diskSessionState && (!liveBlackboxState || diskCascadeDepth > liveCascadeDepth || diskSessionState?.sub_regime && !liveBlackboxState?.sub_regime)) {
|
|
18400
|
+
liveBlackboxState = diskSessionState;
|
|
18291
18401
|
}
|
|
18292
18402
|
} catch {
|
|
18293
18403
|
}
|
|
18294
18404
|
let liveModelSetting = readLiveOpenCodeModel(directory3) || "";
|
|
18295
|
-
const hookModel = String(input?.args?.model || input?.model || output?.args?.model || "").trim();
|
|
18296
18405
|
if (hookModel) liveModelSetting = hookModel;
|
|
18297
|
-
|
|
18298
|
-
|
|
18299
|
-
|
|
18300
|
-
|
|
18301
|
-
|
|
18302
|
-
|
|
18303
|
-
|
|
18304
|
-
|
|
18305
|
-
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
|
|
18320
|
-
|
|
18321
|
-
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18328
|
-
|
|
18329
|
-
|
|
18330
|
-
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
|
|
18335
|
-
|
|
18336
|
-
|
|
18337
|
-
|
|
18338
|
-
|
|
18339
|
-
|
|
18340
|
-
|
|
18341
|
-
|
|
18342
|
-
|
|
18343
|
-
|
|
18344
|
-
|
|
18345
|
-
const _cacheEvt = getLatestCacheEvent(sid);
|
|
18346
|
-
const _perTurnCacheDelta = _cacheEvt.hit ? _cacheEvt.est_savings_usd : 0;
|
|
18347
|
-
const _cacheMiss = !_cacheEvt.hit;
|
|
18348
|
-
let liveModel = liveModelSetting;
|
|
18349
|
-
if (!liveModel) {
|
|
18350
|
-
liveModel = readConfig(directory3) || readConfig(join25(process.env.HOME || "", ".config", "opencode")) || process?.env?.OPENCODE_MODEL || "";
|
|
18351
|
-
}
|
|
18352
|
-
const displayModel = latestFinalized?.finalVisibleModel || (latestRouteDrivesVisibleAnswer ? latestExecutedRoute?.selectedModel : "") || liveModelSetting || liveModel || currentModel || "";
|
|
18353
|
-
const resolvedModel = displayModel || liveModelSetting || liveModel || currentModel || "";
|
|
18354
|
-
if (resolvedModel && resolvedModel !== currentModel) {
|
|
18355
|
-
setCurrentModel(resolvedModel);
|
|
18356
|
-
setCurrentTier(classify(resolvedModel));
|
|
18357
|
-
}
|
|
18358
|
-
const backendMode = String(
|
|
18359
|
-
loadSelection().requested_optimization_mode || loadSelection().optimization_mode || loadOptimizationMode2() || liveBlackboxState?.optimization_mode || ""
|
|
18360
|
-
).trim().toLowerCase();
|
|
18361
|
-
const displayMode = backendMode || (quietIntent ? regimeToMode("INIT", _footerStress) : isApiConnected() ? await apiAutoSelectMode(liveBlackboxState?.sub_regime || classifyTurnSimple(latestUserIntent || ""), _footerStress) : autoSelectMode(liveBlackboxState?.sub_regime || classifyTurnSimple(latestUserIntent || ""), _footerStress));
|
|
18362
|
-
const ultraLiveModel = displayModel || liveModel || currentModel || TRINITY_CHEAP || TRINITY_MEDIUM || TRINITY_BRAIN || "";
|
|
18363
|
-
const ultraCascadeResolution = resolveActiveCascadeTier({
|
|
18364
|
-
liveSession: liveBlackboxState?.sessions?.[sid],
|
|
18365
|
-
diskSession: diskBlackboxState?.sessions?.[sid],
|
|
18366
|
-
legacyDepth: liveBlackboxState?.control_vector?.cascade_depth ?? liveBlackboxState?.cascade_depth ?? diskBlackboxState?.control_vector?.cascade_depth ?? diskBlackboxState?.cascade_depth ?? 0,
|
|
18367
|
-
liveModel: ultraLiveModel,
|
|
18368
|
-
trinityCheap: TRINITY_CHEAP,
|
|
18369
|
-
trinityMedium: TRINITY_MEDIUM,
|
|
18370
|
-
trinityBrain: TRINITY_BRAIN,
|
|
18371
|
-
classify
|
|
18372
|
-
});
|
|
18373
|
-
const ultraResolvedTier = ultraCascadeResolution.tier;
|
|
18374
|
-
const ultraCascadeDepth = latestRouteDrivesVisibleAnswer && Array.isArray(latestExecutedRoute?.routePath) && latestExecutedRoute.routePath.length ? latestExecutedRoute.routePath.length : (latestFinalized?.cascadeDepth ?? ultraCascadeResolution.depth) || 0;
|
|
18375
|
-
const cascadeModel = (ultraCascadeResolution.source === "route" && ultraResolvedTier === "brain" ? TRINITY_BRAIN : ultraCascadeResolution.source === "route" && ultraResolvedTier === "medium" ? TRINITY_MEDIUM : null) || displayModel || (ultraResolvedTier === "brain" ? TRINITY_BRAIN : ultraResolvedTier === "medium" ? TRINITY_MEDIUM : TRINITY_CHEAP) || "";
|
|
18376
|
-
_footerStage = "execution";
|
|
18377
|
-
const execution = resolveCurrentExecution({
|
|
18378
|
-
directory: directory3,
|
|
18379
|
-
activeSlot: displayMode === "vibeultrax" ? ultraResolvedTier : slot || "brain",
|
|
18380
|
-
currentModel,
|
|
18381
|
-
liveModel: displayMode === "vibeultrax" ? cascadeModel : displayModel || liveModel || currentModel || "",
|
|
18382
|
-
tiersData: {
|
|
18383
|
-
trinity: {
|
|
18384
|
-
brain: { oc: TRINITY_BRAIN || currentModel },
|
|
18385
|
-
medium: { oc: TRINITY_MEDIUM || currentModel },
|
|
18386
|
-
cheap: { oc: TRINITY_CHEAP || currentModel }
|
|
18387
|
-
}
|
|
18388
|
-
}
|
|
18389
|
-
});
|
|
18390
|
-
const _executionSlot = displayMode === "vibeultrax" ? ultraResolvedTier : execution.quality === "brain" ? "brain" : execution.quality === "mid" ? "medium" : "cheap";
|
|
18391
|
-
let _modelTag = `[${shortModelName(cascadeModel)}]`;
|
|
18392
|
-
const _workerModel = slot === "brain" ? TRINITY_MEDIUM : null;
|
|
18393
|
-
const totalTurns = (sesModelTurns?.brain || 0) + (sesModelTurns?.worker || 0);
|
|
18394
|
-
if (_workerModel && _workerModel !== brainModel) {
|
|
18395
|
-
const brainPct = Math.round((sesModelTurns?.brain || 0) / (totalTurns || 1) * 100);
|
|
18396
|
-
_modelTag = `[${shortModelName(cascadeModel)} ${brainPct}% \u2192 ${shortModelName(_workerModel)} ${100 - brainPct}%]`;
|
|
18397
|
-
}
|
|
18398
|
-
_autoReportCount = (_autoReportCount || 0) + 1;
|
|
18399
|
-
if (_autoReportCount % 5 === 0) {
|
|
18400
|
-
try {
|
|
18401
|
-
saveReport({
|
|
18402
|
-
type: "session",
|
|
18403
|
-
summary: "Session cost: $" + formatUsd(ltCost) + " | cache saved: $" + formatUsd(ltCache) + " | delegation saved: $" + formatUsd(Number(sesTasks || 0)) + " | task delegations: " + Number(sesTaskDelegations || 0),
|
|
18404
|
-
metrics: {
|
|
18405
|
-
sessionId: sid,
|
|
18406
|
-
projectFingerprint: currentProjectFingerprint || "unknown",
|
|
18407
|
-
projectName: currentProjectName || "unknown",
|
|
18408
|
-
sessionCost: ltCost,
|
|
18409
|
-
cacheSavings: ltCache,
|
|
18410
|
-
delegationSavingsUsd: sesTasks,
|
|
18411
|
-
taskDelegationCount: sesTaskDelegations,
|
|
18412
|
-
tasksDelegated: sesTaskDelegations,
|
|
18413
|
-
model: resolvedModel || currentModel,
|
|
18414
|
-
slot: loadSelection().active_slot || "unknown",
|
|
18415
|
-
editSavings: sesEdit,
|
|
18416
|
-
creditSavings: sesCredit,
|
|
18417
|
-
context7Savings: sesC7,
|
|
18418
|
-
quotaSavings: sesQuota
|
|
18419
|
-
},
|
|
18420
|
-
tags: ["auto", "cost"]
|
|
18421
|
-
});
|
|
18422
|
-
} catch (e) {
|
|
18423
|
-
footerDebug("[vibeOS] auto-report:", e.message);
|
|
18406
|
+
const sid = getSessionId();
|
|
18407
|
+
const { ltTasks, ltCache, ltCost, _count, sesTasks, sesEdit, sesCredit, sesC7, sesQuota, sesTaskDelegations, _sesDuration, _sesRatePerHour, sesTrend, _sesToolBreakdown, sesModelTurns, _quality_avg } = readLifetimeSavings();
|
|
18408
|
+
const { _stableStreak, _problemStreak } = readRewardSignals();
|
|
18409
|
+
const latestTurnTruth = getLatestTurnTruth(sid);
|
|
18410
|
+
const latestExecutedRoute = latestTurnTruth?.executedRoute || null;
|
|
18411
|
+
const latestRouteDrivesVisibleAnswer = latestExecutedRoute?.contributedToFinalAnswer === true;
|
|
18412
|
+
const latestFinalized = latestTurnTruth?.finalized || null;
|
|
18413
|
+
const turnTruthSlot = (latestRouteDrivesVisibleAnswer ? latestExecutedRoute?.selectedSlot : "") || latestFinalized?.finalVisibleSlot || "";
|
|
18414
|
+
const sessionSlot = turnTruthSlot || loadBlackboxState()?.sessions?.[sid]?.active_slot || loadSessionSlot(sid);
|
|
18415
|
+
const slot = loadSelection().active_slot || sessionSlot || "brain";
|
|
18416
|
+
const brainModel = slot === "brain" ? TRINITY_BRAIN || currentModel : slot === "medium" ? TRINITY_MEDIUM || currentModel : TRINITY_CHEAP || currentModel || "";
|
|
18417
|
+
const _cacheEvt = getLatestCacheEvent(sid);
|
|
18418
|
+
const _perTurnCacheDelta = _cacheEvt.hit ? _cacheEvt.est_savings_usd : 0;
|
|
18419
|
+
const _cacheMiss = !_cacheEvt.hit;
|
|
18420
|
+
let liveModel = liveModelSetting;
|
|
18421
|
+
if (!liveModel) {
|
|
18422
|
+
liveModel = readConfig(directory3) || readConfig(join25(process.env.HOME || "", ".config", "opencode")) || process?.env?.OPENCODE_MODEL || "";
|
|
18423
|
+
}
|
|
18424
|
+
const displayModel = latestFinalized?.finalVisibleModel || (latestRouteDrivesVisibleAnswer ? latestExecutedRoute?.selectedModel : "") || liveModelSetting || liveModel || currentModel || "";
|
|
18425
|
+
const resolvedModel = displayModel || liveModelSetting || liveModel || currentModel || "";
|
|
18426
|
+
const backendMode = String(
|
|
18427
|
+
loadSelection().requested_optimization_mode || loadSelection().optimization_mode || loadOptimizationMode2() || liveBlackboxState?.optimization_mode || ""
|
|
18428
|
+
).trim().toLowerCase();
|
|
18429
|
+
const displayMode = backendMode || (quietIntent ? regimeToMode("INIT", _footerStress) : isApiConnected() ? await apiAutoSelectMode(liveBlackboxState?.sub_regime || classifyTurnSimple(latestUserIntent || ""), _footerStress) : autoSelectMode(liveBlackboxState?.sub_regime || classifyTurnSimple(latestUserIntent || ""), _footerStress));
|
|
18430
|
+
const ultraLiveModel = displayModel || liveModel || currentModel || TRINITY_CHEAP || TRINITY_MEDIUM || TRINITY_BRAIN || "";
|
|
18431
|
+
const ultraCascadeResolution = resolveActiveCascadeTier({
|
|
18432
|
+
liveSession: liveBlackboxState?.sessions?.[sid],
|
|
18433
|
+
diskSession: diskBlackboxState?.sessions?.[sid],
|
|
18434
|
+
legacyDepth: liveBlackboxState?.control_vector?.cascade_depth ?? liveBlackboxState?.cascade_depth ?? diskSessionState?.control_vector?.cascade_depth ?? diskSessionState?.cascade_depth ?? 0,
|
|
18435
|
+
liveModel: ultraLiveModel,
|
|
18436
|
+
trinityCheap: TRINITY_CHEAP,
|
|
18437
|
+
trinityMedium: TRINITY_MEDIUM,
|
|
18438
|
+
trinityBrain: TRINITY_BRAIN,
|
|
18439
|
+
classify
|
|
18440
|
+
});
|
|
18441
|
+
const ultraResolvedTier = ultraCascadeResolution.tier;
|
|
18442
|
+
const ultraCascadeDepth = latestRouteDrivesVisibleAnswer && Array.isArray(latestExecutedRoute?.routePath) && latestExecutedRoute.routePath.length ? latestExecutedRoute.routePath.length : (latestFinalized?.cascadeDepth ?? ultraCascadeResolution.depth) || 0;
|
|
18443
|
+
const cascadeModel = (ultraCascadeResolution.source === "route" && ultraResolvedTier === "brain" ? TRINITY_BRAIN : ultraCascadeResolution.source === "route" && ultraResolvedTier === "medium" ? TRINITY_MEDIUM : null) || displayModel || (ultraResolvedTier === "brain" ? TRINITY_BRAIN : ultraResolvedTier === "medium" ? TRINITY_MEDIUM : TRINITY_CHEAP) || "";
|
|
18444
|
+
const execution = resolveCurrentExecution({
|
|
18445
|
+
directory: directory3,
|
|
18446
|
+
activeSlot: displayMode === "vibeultrax" ? ultraResolvedTier : slot || "brain",
|
|
18447
|
+
currentModel,
|
|
18448
|
+
liveModel: displayMode === "vibeultrax" ? cascadeModel : displayModel || liveModel || currentModel || "",
|
|
18449
|
+
tiersData: {
|
|
18450
|
+
trinity: {
|
|
18451
|
+
brain: { oc: TRINITY_BRAIN || currentModel },
|
|
18452
|
+
medium: { oc: TRINITY_MEDIUM || currentModel },
|
|
18453
|
+
cheap: { oc: TRINITY_CHEAP || currentModel }
|
|
18424
18454
|
}
|
|
18425
18455
|
}
|
|
18426
|
-
|
|
18427
|
-
|
|
18428
|
-
|
|
18429
|
-
|
|
18430
|
-
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
18434
|
-
|
|
18435
|
-
|
|
18436
|
-
|
|
18437
|
-
|
|
18438
|
-
|
|
18439
|
-
|
|
18440
|
-
|
|
18441
|
-
|
|
18442
|
-
|
|
18443
|
-
|
|
18444
|
-
|
|
18445
|
-
|
|
18446
|
-
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18451
|
-
|
|
18452
|
-
|
|
18453
|
-
|
|
18454
|
-
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
|
|
18458
|
-
|
|
18459
|
-
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
|
|
18468
|
-
|
|
18469
|
-
|
|
18470
|
-
|
|
18471
|
-
|
|
18472
|
-
|
|
18473
|
-
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18479
|
-
|
|
18480
|
-
const
|
|
18481
|
-
|
|
18482
|
-
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
|
|
18488
|
-
|
|
18489
|
-
const
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18493
|
-
|
|
18494
|
-
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
18501
|
-
|
|
18502
|
-
|
|
18503
|
-
|
|
18504
|
-
|
|
18505
|
-
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18512
|
-
|
|
18513
|
-
const
|
|
18514
|
-
|
|
18515
|
-
|
|
18516
|
-
if (rewardResult.credits !== 0) {
|
|
18517
|
-
const suppressPositive = rewardResult.credits > 0 && !XP_SHOW_REGIMES.has(String(currentSubRegime || "").toUpperCase());
|
|
18518
|
-
if (!suppressPositive) {
|
|
18519
|
-
_rewardTag = rewardResult.credits > 0 ? `+${rewardResult.credits} XP` : `${rewardResult.credits} XP`;
|
|
18520
|
-
}
|
|
18456
|
+
});
|
|
18457
|
+
const selNowFooter = loadSelection();
|
|
18458
|
+
const normalizedIntent = classifyTurnSimple(latestUserIntent || "");
|
|
18459
|
+
const currentSubRegime = quietIntent ? "INIT" : liveBlackboxState?.sub_regime || normalizedIntent;
|
|
18460
|
+
const bbMode = resolveEnforcementMode();
|
|
18461
|
+
const CODING_REGIMES = /* @__PURE__ */ new Set(["REFINING", "IMPLEMENTING", "CONVERGING", "REVIEWING"]);
|
|
18462
|
+
const enfTags = buildEnforcementTags({
|
|
18463
|
+
delegationEnforce: selNowFooter.delegation_enforce,
|
|
18464
|
+
flowEnforce: selNowFooter.flow_enforce,
|
|
18465
|
+
tddEnforce: selNowFooter.tdd_enforce && CODING_REGIMES.has(currentSubRegime),
|
|
18466
|
+
bbMode,
|
|
18467
|
+
modelLocked: _modelLocked,
|
|
18468
|
+
quietIntent: isGreetingLike2(latestUserIntent || "")
|
|
18469
|
+
});
|
|
18470
|
+
const prevAssistantTexts = typeof _prevAssistantTexts !== "undefined" && Array.isArray(_prevAssistantTexts) ? _prevAssistantTexts : [];
|
|
18471
|
+
const claimStatus = evaluateClaimEvidence({
|
|
18472
|
+
text,
|
|
18473
|
+
vibeHome: getVibeOSHome(),
|
|
18474
|
+
sessionId: sid,
|
|
18475
|
+
turnId: latestTurnTruth?.turnId || "",
|
|
18476
|
+
userText: latestUserIntent || "",
|
|
18477
|
+
prevAssistantTexts
|
|
18478
|
+
});
|
|
18479
|
+
const sessionHealth = getSessionHealthSnapshot({
|
|
18480
|
+
sessionId: sid,
|
|
18481
|
+
projectFingerprint: currentProjectFingerprint || "",
|
|
18482
|
+
userText: latestUserIntent || "",
|
|
18483
|
+
assistantText: text,
|
|
18484
|
+
prevAssistantTexts,
|
|
18485
|
+
turnId: latestTurnTruth?.turnId || ""
|
|
18486
|
+
});
|
|
18487
|
+
const claimTag = claimStatus.claimTag || "";
|
|
18488
|
+
const ltTotal = ltTasks + ltCache;
|
|
18489
|
+
const sessionCacheSavings = getSessionCacheSavings(readFullState()?.sessions?.[sid] || {});
|
|
18490
|
+
const sessionTotal = Number(sesTasks || 0) + Number(sessionCacheSavings || 0);
|
|
18491
|
+
const footerSavingsTotal = sessionTotal > 0 ? sessionTotal : ltTotal;
|
|
18492
|
+
const activeSlot = turnTruthSlot || ultraResolvedTier;
|
|
18493
|
+
const flashIcon = isApiConnected() ? " \u26A1" : "";
|
|
18494
|
+
const rawMode = displayMode;
|
|
18495
|
+
const cv = computeControlVector({ sub_regime: currentSubRegime, latest_stress_multiplier: _footerStress, user_text: latestUserIntent || "" }, void 0, rawMode);
|
|
18496
|
+
const SUPPRESS_SYNC_MODES = /* @__PURE__ */ new Set(["quality", "auto"]);
|
|
18497
|
+
const isSuppressedMode = SUPPRESS_SYNC_MODES.has(String(displayMode || "").toLowerCase());
|
|
18498
|
+
const vibeBrand = isSuppressedMode ? "vibeOS" : resolveBrand(displayMode, activeSlot);
|
|
18499
|
+
const XP_SHOW_REGIMES = /* @__PURE__ */ new Set(["CONVERGING", "CLOSED", "REVIEWING"]);
|
|
18500
|
+
let _rewardTag = "";
|
|
18501
|
+
let _rewardOutcome = null;
|
|
18502
|
+
let _rewardCredits = 0;
|
|
18503
|
+
let _rewardBreakdown = null;
|
|
18504
|
+
if (_blackboxEnabled) {
|
|
18505
|
+
try {
|
|
18506
|
+
const prevText = _prevOutputText2;
|
|
18507
|
+
if (prevText) {
|
|
18508
|
+
const outcome = detectOutcomeSignal(prevText);
|
|
18509
|
+
const regime = liveBlackboxState?.sub_regime || classifyTurnSimple(latestUserIntent || "");
|
|
18510
|
+
const stress = _footerStress;
|
|
18511
|
+
const isLooping = String(regime || "").toUpperCase() === "LOOPING";
|
|
18512
|
+
const isStressed = Number(stress || 0) > 0.3;
|
|
18513
|
+
const passiveNegative = isLooping && isStressed && !outcome ? "negative" : null;
|
|
18514
|
+
const finalOutcome = outcome || passiveNegative;
|
|
18515
|
+
if (finalOutcome) {
|
|
18516
|
+
_rewardOutcome = finalOutcome;
|
|
18517
|
+
}
|
|
18518
|
+
if (outcome) {
|
|
18519
|
+
const tracker = getBlackboxTracker();
|
|
18520
|
+
tracker.recordOutcome(outcome);
|
|
18521
|
+
try {
|
|
18522
|
+
syncOutcomeToApi(outcome);
|
|
18523
|
+
} catch {
|
|
18524
|
+
}
|
|
18525
|
+
try {
|
|
18526
|
+
const rewardInput = buildRewardInput({
|
|
18527
|
+
finalOutcome: outcome,
|
|
18528
|
+
assistantText: prevText,
|
|
18529
|
+
userText: latestUserIntent || "",
|
|
18530
|
+
prevAssistantTexts,
|
|
18531
|
+
savingsUsd: _perTurnCacheDelta,
|
|
18532
|
+
isBrainTier: String(currentTier || "").toLowerCase() === "high",
|
|
18533
|
+
sessionId: sid,
|
|
18534
|
+
turnId: latestTurnTruth?.turnId || "",
|
|
18535
|
+
projectFingerprint: currentProjectFingerprint || "",
|
|
18536
|
+
cacheHit: _cacheEvt.hit,
|
|
18537
|
+
cacheMiss: _cacheMiss
|
|
18538
|
+
});
|
|
18539
|
+
const rewardResult = computeReward(rewardInput);
|
|
18540
|
+
_rewardCredits = rewardResult.credits;
|
|
18541
|
+
_rewardBreakdown = rewardResult.breakdown;
|
|
18542
|
+
if (rewardResult.credits !== 0) {
|
|
18543
|
+
const suppressPositive = rewardResult.credits > 0 && !XP_SHOW_REGIMES.has(String(currentSubRegime || "").toUpperCase());
|
|
18544
|
+
if (!suppressPositive) {
|
|
18545
|
+
_rewardTag = rewardResult.credits > 0 ? `+${rewardResult.credits} XP` : `${rewardResult.credits} XP`;
|
|
18521
18546
|
}
|
|
18522
|
-
} catch {
|
|
18523
|
-
}
|
|
18524
|
-
try {
|
|
18525
|
-
mkdirSync19(getVibeOSHome(), { recursive: true });
|
|
18526
|
-
appendFileSync8(
|
|
18527
|
-
join25(getVibeOSHome(), "calibration-data.jsonl"),
|
|
18528
|
-
JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), event: "outcome", sid: getSessionId(), outcome: finalOutcome }) + "\n"
|
|
18529
|
-
);
|
|
18530
|
-
} catch {
|
|
18531
18547
|
}
|
|
18548
|
+
} catch {
|
|
18532
18549
|
}
|
|
18533
18550
|
}
|
|
18534
|
-
} catch {
|
|
18535
18551
|
}
|
|
18552
|
+
} catch {
|
|
18536
18553
|
}
|
|
18537
|
-
|
|
18538
|
-
|
|
18539
|
-
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
|
|
18544
|
-
|
|
18545
|
-
|
|
18546
|
-
|
|
18547
|
-
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
18551
|
-
|
|
18552
|
-
|
|
18553
|
-
|
|
18554
|
-
_rewardBreakdown = rewardResult.breakdown;
|
|
18555
|
-
if (rewardResult.credits !== 0) {
|
|
18556
|
-
const suppressPositive = rewardResult.credits > 0 && !XP_SHOW_REGIMES.has(String(currentSubRegime || "").toUpperCase());
|
|
18557
|
-
if (!suppressPositive) {
|
|
18558
|
-
_rewardTag = rewardResult.credits > 0 ? `+${rewardResult.credits} XP` : `${rewardResult.credits} XP`;
|
|
18559
|
-
}
|
|
18560
|
-
}
|
|
18561
|
-
} catch {
|
|
18562
|
-
}
|
|
18554
|
+
}
|
|
18555
|
+
const _expectedModel = slot === "brain" ? TRINITY_BRAIN : slot === "medium" ? TRINITY_MEDIUM : TRINITY_CHEAP;
|
|
18556
|
+
const _cascadeTierModels = new Set([TRINITY_CHEAP, TRINITY_MEDIUM, TRINITY_BRAIN].filter(Boolean));
|
|
18557
|
+
const _expectedForAlert = displayMode === "vibeultrax" && liveModelSetting && _cascadeTierModels.has(liveModelSetting) ? liveModelSetting : _expectedModel;
|
|
18558
|
+
let _alertTag = "";
|
|
18559
|
+
try {
|
|
18560
|
+
const pendingSwitch = getPendingLiveSwitch();
|
|
18561
|
+
_alertTag = buildFooterAlert({
|
|
18562
|
+
apiDegraded: isApiFallback(),
|
|
18563
|
+
apiSlow: false,
|
|
18564
|
+
liveModel: liveModelSetting || void 0,
|
|
18565
|
+
expectedModel: _expectedForAlert || void 0,
|
|
18566
|
+
lastModelError,
|
|
18567
|
+
pendingLiveModel: pendingSwitch?.model || void 0
|
|
18568
|
+
});
|
|
18569
|
+
if (!_alertTag && sessionHealth.risk !== "low" && sessionHealth.metaWorkDrift) {
|
|
18570
|
+
_alertTag = "\u21BB recover";
|
|
18563
18571
|
}
|
|
18564
|
-
|
|
18572
|
+
} catch {
|
|
18573
|
+
}
|
|
18574
|
+
const TIER_RANK = { cheap: 0, medium: 1, brain: 2 };
|
|
18575
|
+
const sessionRank = TIER_RANK[sessionSlot || ""] ?? -1;
|
|
18576
|
+
const activeRankVal = TIER_RANK[activeSlot || ""] ?? -1;
|
|
18577
|
+
const showDowngrade = Boolean(sessionSlot && sessionSlot !== activeSlot && sessionRank > activeRankVal);
|
|
18578
|
+
const downgradeWorkerSlot = showDowngrade ? `\u2193 ${sessionSlot}` : void 0;
|
|
18579
|
+
return {
|
|
18580
|
+
activeSlot,
|
|
18581
|
+
sessionSlot,
|
|
18582
|
+
workerSlot: downgradeWorkerSlot,
|
|
18583
|
+
providerLabel: execution.provider_label,
|
|
18584
|
+
modelName: modelDisplayName(execution.model),
|
|
18585
|
+
savingsTotal: footerSavingsTotal,
|
|
18586
|
+
ltTrend: sesTrend,
|
|
18587
|
+
vibeBrand,
|
|
18588
|
+
optMode: isSuppressedMode ? "" : displayMode,
|
|
18589
|
+
flashIcon,
|
|
18590
|
+
enfTags,
|
|
18591
|
+
subRegime: currentSubRegime,
|
|
18592
|
+
stressGauge: formatStressGauge(_footerStress),
|
|
18593
|
+
cascadeIcon: ultraCascadeDepth >= 3 ? "\u25B8\u25B8\u25B8" : ultraCascadeDepth >= 2 ? "\u25B8\u25B8" : ultraCascadeDepth >= 1 ? "\u25B8" : "",
|
|
18594
|
+
cascadeLabel: "",
|
|
18595
|
+
rewardTag: _rewardTag || void 0,
|
|
18596
|
+
alertTag: _alertTag || void 0,
|
|
18597
|
+
sid,
|
|
18598
|
+
messageID: null,
|
|
18599
|
+
execution,
|
|
18600
|
+
liveModelSetting,
|
|
18601
|
+
resolvedModel,
|
|
18602
|
+
displayMode,
|
|
18603
|
+
displayModel,
|
|
18604
|
+
currentSubRegime,
|
|
18605
|
+
_footerStress,
|
|
18606
|
+
liveBlackboxState,
|
|
18607
|
+
diskBlackboxState,
|
|
18608
|
+
latestTurnTruth,
|
|
18609
|
+
latestExecutedRoute,
|
|
18610
|
+
turnTruthSlot,
|
|
18611
|
+
slot,
|
|
18612
|
+
brainModel,
|
|
18613
|
+
_cacheEvt,
|
|
18614
|
+
_perTurnCacheDelta,
|
|
18615
|
+
_cacheMiss,
|
|
18616
|
+
cv,
|
|
18617
|
+
isSuppressedMode,
|
|
18618
|
+
_rewardOutcome,
|
|
18619
|
+
_rewardCredits,
|
|
18620
|
+
_rewardBreakdown,
|
|
18621
|
+
claimTag: claimTag || "",
|
|
18622
|
+
downgradeWorkerSlot,
|
|
18623
|
+
cascadeDepthForIcon: Number(ultraCascadeDepth) || 0,
|
|
18624
|
+
footerSavingsTotal,
|
|
18625
|
+
sesTrend,
|
|
18626
|
+
ltTotal,
|
|
18627
|
+
ltCost,
|
|
18628
|
+
ltCache,
|
|
18629
|
+
sesTasks,
|
|
18630
|
+
sesEdit,
|
|
18631
|
+
sesCredit,
|
|
18632
|
+
sesC7,
|
|
18633
|
+
sesQuota,
|
|
18634
|
+
sesTaskDelegations,
|
|
18635
|
+
sesModelTurns,
|
|
18636
|
+
claimStatus,
|
|
18637
|
+
sessionHealth,
|
|
18638
|
+
stripped: ""
|
|
18639
|
+
};
|
|
18640
|
+
}
|
|
18641
|
+
async function _appendFooter(input, output, directory3, lastModelError, hookName = "experimental.text.complete") {
|
|
18642
|
+
_refreshModel(directory3);
|
|
18643
|
+
let _footerStage = "init";
|
|
18644
|
+
try {
|
|
18645
|
+
const text = _extractText(output);
|
|
18646
|
+
if (!text) return;
|
|
18647
|
+
_footerStage = "resolve";
|
|
18648
|
+
const hookModel = String(input?.args?.model || input?.model || output?.args?.model || "").trim();
|
|
18649
|
+
const state = await resolveFooterDisplayState(directory3, text, hookModel, lastModelError, hookName);
|
|
18650
|
+
state.messageID = input?.messageID || input?.messageId || input?.message?.id || output?.messageID || output?.messageId || output?.message?.id || null;
|
|
18651
|
+
const footerSuffix = /\n\n\u2014 [^\n]+\u2014\s*$/;
|
|
18652
|
+
const hasExistingFooter = footerSuffix.test(text);
|
|
18653
|
+
const stripped = hasExistingFooter ? text.replace(footerSuffix, "").trimEnd() : text;
|
|
18654
|
+
state.stripped = stripped;
|
|
18655
|
+
const prevText = _prevOutputText2;
|
|
18656
|
+
_prevOutputText2 = text;
|
|
18657
|
+
if (_blackboxEnabled && _prevOutputText2 && prevText && _prevOutputText2 !== prevText) {
|
|
18565
18658
|
try {
|
|
18566
|
-
const rewardText = _prevOutputText2
|
|
18659
|
+
const rewardText = _prevOutputText2;
|
|
18567
18660
|
const rewardOutcome = detectOutcomeSignal(rewardText);
|
|
18568
|
-
const rewardRegime = liveBlackboxState?.sub_regime || classifyTurnSimple(latestUserIntent || "");
|
|
18569
|
-
const rewardStress = _footerStress;
|
|
18661
|
+
const rewardRegime = state.liveBlackboxState?.sub_regime || classifyTurnSimple(latestUserIntent || "");
|
|
18662
|
+
const rewardStress = state._footerStress;
|
|
18570
18663
|
const rewardPassiveNegative = String(rewardRegime || "").toUpperCase() === "LOOPING" && Number(rewardStress || 0) > 0.3 && !rewardOutcome ? "negative" : null;
|
|
18571
18664
|
const finalRewardOutcome = rewardOutcome || rewardPassiveNegative;
|
|
18572
18665
|
if (finalRewardOutcome) {
|
|
18666
|
+
state._rewardOutcome = finalRewardOutcome;
|
|
18667
|
+
}
|
|
18668
|
+
if (rewardOutcome) {
|
|
18669
|
+
const tracker = getBlackboxTracker();
|
|
18670
|
+
tracker.recordOutcome(rewardOutcome);
|
|
18671
|
+
try {
|
|
18672
|
+
syncOutcomeToApi(rewardOutcome);
|
|
18673
|
+
} catch {
|
|
18674
|
+
}
|
|
18573
18675
|
const rewardResult = computeReward(buildRewardInput({
|
|
18574
|
-
finalOutcome:
|
|
18676
|
+
finalOutcome: rewardOutcome,
|
|
18575
18677
|
assistantText: rewardText,
|
|
18576
18678
|
userText: latestUserIntent || "",
|
|
18577
|
-
prevAssistantTexts,
|
|
18578
|
-
savingsUsd: _perTurnCacheDelta,
|
|
18679
|
+
prevAssistantTexts: typeof _prevAssistantTexts !== "undefined" && Array.isArray(_prevAssistantTexts) ? _prevAssistantTexts : [],
|
|
18680
|
+
savingsUsd: state._perTurnCacheDelta,
|
|
18579
18681
|
isBrainTier: String(currentTier || "").toLowerCase() === "high",
|
|
18580
|
-
sessionId: sid,
|
|
18581
|
-
turnId: latestTurnTruth?.turnId || "",
|
|
18682
|
+
sessionId: state.sid,
|
|
18683
|
+
turnId: state.latestTurnTruth?.turnId || "",
|
|
18582
18684
|
projectFingerprint: currentProjectFingerprint || "",
|
|
18583
|
-
cacheHit: _cacheEvt.hit,
|
|
18584
|
-
cacheMiss: _cacheMiss
|
|
18685
|
+
cacheHit: state._cacheEvt.hit,
|
|
18686
|
+
cacheMiss: state._cacheMiss
|
|
18585
18687
|
}));
|
|
18586
|
-
_rewardCredits = rewardResult.credits;
|
|
18587
|
-
_rewardBreakdown = rewardResult.breakdown;
|
|
18688
|
+
state._rewardCredits = rewardResult.credits;
|
|
18689
|
+
state._rewardBreakdown = rewardResult.breakdown;
|
|
18588
18690
|
if (rewardResult.credits !== 0) {
|
|
18589
|
-
const
|
|
18691
|
+
const XP_SHOW_REGIMES = /* @__PURE__ */ new Set(["CONVERGING", "CLOSED", "REVIEWING"]);
|
|
18692
|
+
const suppressPositive = rewardResult.credits > 0 && !XP_SHOW_REGIMES.has(String(state.currentSubRegime || "").toUpperCase());
|
|
18590
18693
|
if (!suppressPositive) {
|
|
18591
|
-
|
|
18694
|
+
state.rewardTag = rewardResult.credits > 0 ? `+${rewardResult.credits} XP` : `${rewardResult.credits} XP`;
|
|
18592
18695
|
}
|
|
18593
18696
|
}
|
|
18594
18697
|
}
|
|
18595
18698
|
} catch {
|
|
18596
18699
|
}
|
|
18597
18700
|
}
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
|
|
18609
|
-
|
|
18610
|
-
|
|
18611
|
-
|
|
18612
|
-
|
|
18613
|
-
|
|
18614
|
-
|
|
18701
|
+
_autoReportCount = (_autoReportCount || 0) + 1;
|
|
18702
|
+
if (_autoReportCount % 5 === 0) {
|
|
18703
|
+
try {
|
|
18704
|
+
saveReport({
|
|
18705
|
+
type: "session",
|
|
18706
|
+
summary: "Session cost: $" + formatUsd(state.ltCost) + " | cache saved: $" + formatUsd(state.ltCache) + " | delegation saved: $" + formatUsd(Number(state.sesTasks || 0)) + " | task delegations: " + Number(state.sesTaskDelegations || 0),
|
|
18707
|
+
metrics: {
|
|
18708
|
+
sessionId: state.sid,
|
|
18709
|
+
projectFingerprint: currentProjectFingerprint || "unknown",
|
|
18710
|
+
projectName: currentProjectName || "unknown",
|
|
18711
|
+
sessionCost: state.ltCost,
|
|
18712
|
+
cacheSavings: state.ltCache,
|
|
18713
|
+
delegationSavingsUsd: state.sesTasks,
|
|
18714
|
+
taskDelegationCount: state.sesTaskDelegations,
|
|
18715
|
+
tasksDelegated: state.sesTaskDelegations,
|
|
18716
|
+
model: state.resolvedModel || currentModel,
|
|
18717
|
+
slot: loadSelection().active_slot || "unknown",
|
|
18718
|
+
editSavings: state.sesEdit,
|
|
18719
|
+
creditSavings: state.sesCredit,
|
|
18720
|
+
context7Savings: state.sesC7,
|
|
18721
|
+
quotaSavings: state.sesQuota
|
|
18722
|
+
},
|
|
18723
|
+
tags: ["auto", "cost"]
|
|
18724
|
+
});
|
|
18725
|
+
} catch (e) {
|
|
18726
|
+
footerDebug("[vibeOS] auto-report:", e.message);
|
|
18615
18727
|
}
|
|
18616
|
-
} catch {
|
|
18617
18728
|
}
|
|
18618
18729
|
_footerStage = "build";
|
|
18619
|
-
const
|
|
18620
|
-
const TIER_RANK = { cheap: 0, medium: 1, brain: 2 };
|
|
18621
|
-
const sessionRank = TIER_RANK[sessionSlot || ""] ?? -1;
|
|
18622
|
-
const activeRankVal = TIER_RANK[activeSlot || ""] ?? -1;
|
|
18623
|
-
const showDowngrade = Boolean(sessionSlot && sessionSlot !== activeSlot && sessionRank > activeRankVal);
|
|
18624
|
-
const downgradeWorkerSlot = showDowngrade ? `\u2193 ${sessionSlot}` : void 0;
|
|
18625
|
-
const vibeLine = buildFooterLine({
|
|
18626
|
-
activeSlot,
|
|
18627
|
-
providerLabel: execution.provider_label,
|
|
18628
|
-
modelName: modelDisplayName(execution.model),
|
|
18629
|
-
workerSlot: downgradeWorkerSlot,
|
|
18630
|
-
savingsTotal: footerSavingsTotal,
|
|
18631
|
-
ltTrend: sesTrend,
|
|
18632
|
-
vibeBrand,
|
|
18633
|
-
optMode: isSuppressedMode ? "" : displayMode,
|
|
18634
|
-
flashIcon,
|
|
18635
|
-
enfTags,
|
|
18636
|
-
subRegime: currentSubRegime,
|
|
18637
|
-
stressGauge: formatStressGauge(_footerStress),
|
|
18638
|
-
cascadeIcon: cascadeDepthForIcon >= 3 ? "\u25B8\u25B8\u25B8" : cascadeDepthForIcon >= 2 ? "\u25B8\u25B8" : cascadeDepthForIcon >= 1 ? "\u25B8" : "",
|
|
18639
|
-
cascadeLabel: "",
|
|
18640
|
-
claimTag: claimTag || void 0,
|
|
18641
|
-
rewardTag: _rewardTag || void 0,
|
|
18642
|
-
alertTag: _alertTag || void 0
|
|
18643
|
-
});
|
|
18730
|
+
const vibeLine = buildFooterLine(state);
|
|
18644
18731
|
recordFooterProbe({
|
|
18645
18732
|
hook: hookName,
|
|
18646
18733
|
builder: "rich",
|
|
18647
|
-
providerLabel: execution.provider_label,
|
|
18648
|
-
provider: execution.provider,
|
|
18649
|
-
modelId: execution.model,
|
|
18650
|
-
modelName: modelDisplayName(execution.model),
|
|
18651
|
-
activeSlot,
|
|
18652
|
-
sessionSlot,
|
|
18653
|
-
mode: displayMode,
|
|
18654
|
-
messageID,
|
|
18734
|
+
providerLabel: state.execution.provider_label,
|
|
18735
|
+
provider: state.execution.provider,
|
|
18736
|
+
modelId: state.execution.model,
|
|
18737
|
+
modelName: modelDisplayName(state.execution.model),
|
|
18738
|
+
activeSlot: state.activeSlot,
|
|
18739
|
+
sessionSlot: state.sessionSlot,
|
|
18740
|
+
mode: state.displayMode,
|
|
18741
|
+
messageID: state.messageID,
|
|
18655
18742
|
footerLine: vibeLine
|
|
18656
18743
|
});
|
|
18657
|
-
if (stripped === _lastStrippedText && !claimTag) return;
|
|
18658
|
-
if (messageID && textCompletePainted.has(messageID)) {
|
|
18659
|
-
const paintedLen = textCompletePainted.get(messageID);
|
|
18660
|
-
if (stripped.length <= paintedLen && !claimTag) return;
|
|
18744
|
+
if (stripped === _lastStrippedText && !state.claimTag) return;
|
|
18745
|
+
if (state.messageID && textCompletePainted.has(state.messageID)) {
|
|
18746
|
+
const paintedLen = textCompletePainted.get(state.messageID);
|
|
18747
|
+
if (stripped.length <= paintedLen && !state.claimTag) return;
|
|
18661
18748
|
}
|
|
18749
|
+
_footerStage = "snapshot";
|
|
18662
18750
|
try {
|
|
18663
18751
|
recordLiveSessionSnapshot({
|
|
18664
|
-
sessionId: sid,
|
|
18752
|
+
sessionId: state.sid,
|
|
18665
18753
|
projectFingerprint: currentProjectFingerprint || "",
|
|
18666
18754
|
projectName: currentProjectName || "",
|
|
18667
|
-
outcome: _rewardOutcome,
|
|
18668
|
-
rewardCredits: _rewardCredits,
|
|
18669
|
-
rewardBreakdown: _rewardBreakdown,
|
|
18670
|
-
savingsUsd: _perTurnCacheDelta,
|
|
18755
|
+
outcome: state._rewardOutcome,
|
|
18756
|
+
rewardCredits: state._rewardCredits,
|
|
18757
|
+
rewardBreakdown: state._rewardBreakdown,
|
|
18758
|
+
savingsUsd: state._perTurnCacheDelta,
|
|
18671
18759
|
footerLine: vibeLine,
|
|
18672
|
-
control: cv,
|
|
18673
|
-
subRegime: currentSubRegime,
|
|
18674
|
-
resolutionState: _rewardOutcome === "positive" ? "working" : _rewardOutcome === "negative" ? "needs_attention" : liveBlackboxState?.resolution_state || liveBlackboxState?.resolution || "unresolved",
|
|
18675
|
-
resolutionReason: _rewardOutcome ? _rewardOutcome === "positive" ? "positive outcome" : "negative outcome" : "no outcome yet",
|
|
18676
|
-
nextAction: _rewardOutcome === "negative" ? getLatestBlackboxLoopMsg() || getLatestBlackboxPivotMsg() || (Array.isArray(cv?.directives) ? cv.directives[0] : "") || "" : sessionHealth.recommendedAction || getLatestBlackboxPivotMsg() || (Array.isArray(cv?.directives) ? cv.directives[0] : "") || "",
|
|
18677
|
-
loopInterventionLevel: liveBlackboxState?.loop_intervention_level || cv?.loop_intervention_level || "none",
|
|
18678
|
-
pivotDetected: Boolean(liveBlackboxState?.pivot_detected || sessionHealth.metaWorkDrift),
|
|
18679
|
-
stress: _footerStress,
|
|
18760
|
+
control: state.cv,
|
|
18761
|
+
subRegime: state.currentSubRegime,
|
|
18762
|
+
resolutionState: state._rewardOutcome === "positive" ? "working" : state._rewardOutcome === "negative" ? "needs_attention" : state.liveBlackboxState?.resolution_state || state.liveBlackboxState?.resolution || "unresolved",
|
|
18763
|
+
resolutionReason: state._rewardOutcome ? state._rewardOutcome === "positive" ? "positive outcome" : "negative outcome" : "no outcome yet",
|
|
18764
|
+
nextAction: state._rewardOutcome === "negative" ? getLatestBlackboxLoopMsg() || getLatestBlackboxPivotMsg() || (Array.isArray(state.cv?.directives) ? state.cv.directives[0] : "") || "" : state.sessionHealth.recommendedAction || getLatestBlackboxPivotMsg() || (Array.isArray(state.cv?.directives) ? state.cv.directives[0] : "") || "",
|
|
18765
|
+
loopInterventionLevel: state.liveBlackboxState?.loop_intervention_level || state.cv?.loop_intervention_level || "none",
|
|
18766
|
+
pivotDetected: Boolean(state.liveBlackboxState?.pivot_detected || state.sessionHealth.metaWorkDrift),
|
|
18767
|
+
stress: state._footerStress,
|
|
18680
18768
|
source: "footer"
|
|
18681
18769
|
});
|
|
18682
18770
|
} catch (innerErr) {
|
|
18683
18771
|
console.error("[vibeOS] footer recordLiveSessionSnapshot error:", innerErr?.message || innerErr);
|
|
18684
18772
|
}
|
|
18773
|
+
_footerStage = "finalize";
|
|
18685
18774
|
try {
|
|
18686
|
-
if (latestTurnTruth?.turnId) {
|
|
18775
|
+
if (state.latestTurnTruth?.turnId) {
|
|
18687
18776
|
recordTurnFinalize({
|
|
18688
|
-
sessionId: sid,
|
|
18689
|
-
turnId: latestTurnTruth.turnId,
|
|
18777
|
+
sessionId: state.sid,
|
|
18778
|
+
turnId: state.latestTurnTruth.turnId,
|
|
18690
18779
|
finalized: {
|
|
18691
|
-
finalVisibleModel: execution.model,
|
|
18692
|
-
finalVisibleSlot: activeSlot,
|
|
18693
|
-
finalVisibleProvider: execution.provider,
|
|
18694
|
-
finalVisibleProviderLabel: execution.provider_label,
|
|
18695
|
-
finalVisibleModelName: modelDisplayName(execution.model),
|
|
18780
|
+
finalVisibleModel: state.execution.model,
|
|
18781
|
+
finalVisibleSlot: state.activeSlot,
|
|
18782
|
+
finalVisibleProvider: state.execution.provider,
|
|
18783
|
+
finalVisibleProviderLabel: state.execution.provider_label,
|
|
18784
|
+
finalVisibleModelName: modelDisplayName(state.execution.model),
|
|
18696
18785
|
footerLine: vibeLine,
|
|
18697
|
-
claimTag: claimTag || "",
|
|
18698
|
-
rewardTag:
|
|
18699
|
-
rewardCredits: _rewardCredits,
|
|
18700
|
-
rewardOutcome: _rewardOutcome || "",
|
|
18701
|
-
subRegime: currentSubRegime,
|
|
18702
|
-
enforcementMode: cv?.enforcement_mode || "",
|
|
18703
|
-
flowMode: cv?.flow_mode || "",
|
|
18704
|
-
tddMode: cv?.tdd_mode || "",
|
|
18705
|
-
cascadeDepth: cascadeDepthForIcon
|
|
18786
|
+
claimTag: state.claimTag || "",
|
|
18787
|
+
rewardTag: state.rewardTag || "",
|
|
18788
|
+
rewardCredits: state._rewardCredits,
|
|
18789
|
+
rewardOutcome: state._rewardOutcome || "",
|
|
18790
|
+
subRegime: state.currentSubRegime,
|
|
18791
|
+
enforcementMode: state.cv?.enforcement_mode || "",
|
|
18792
|
+
flowMode: state.cv?.flow_mode || "",
|
|
18793
|
+
tddMode: state.cv?.tdd_mode || "",
|
|
18794
|
+
cascadeDepth: state.cascadeDepthForIcon
|
|
18706
18795
|
}
|
|
18707
18796
|
});
|
|
18708
18797
|
}
|
|
@@ -18716,13 +18805,13 @@ ${vibeLine}`;
|
|
|
18716
18805
|
|
|
18717
18806
|
${vibeLine}`;
|
|
18718
18807
|
_footerCacheTs = Date.now();
|
|
18719
|
-
|
|
18808
|
+
_setFooter(output, footerText);
|
|
18720
18809
|
_lastStrippedText = stripped;
|
|
18721
18810
|
if (!process.stdout?.isTTY) {
|
|
18722
18811
|
console.error(`
|
|
18723
18812
|
${vibeLine} \u2014`);
|
|
18724
18813
|
}
|
|
18725
|
-
if (messageID) textCompletePainted.set(messageID, stripped.length);
|
|
18814
|
+
if (state.messageID) textCompletePainted.set(state.messageID, stripped.length);
|
|
18726
18815
|
if (textCompletePainted.size > 500) {
|
|
18727
18816
|
const it = textCompletePainted.keys();
|
|
18728
18817
|
for (let i = 0; i < 100; i++) textCompletePainted.delete(it.next().value);
|
|
@@ -18739,7 +18828,7 @@ function didTextCompletePainted(messageID) {
|
|
|
18739
18828
|
// src/lib/hooks/tool-execute.ts
|
|
18740
18829
|
init_state();
|
|
18741
18830
|
init_pricing();
|
|
18742
|
-
import { readFileSync as readFileSync26, writeFileSync as
|
|
18831
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync22, appendFileSync as appendFileSync8, existsSync as existsSync28, mkdirSync as mkdirSync21, copyFileSync as copyFileSync3 } from "node:fs";
|
|
18743
18832
|
import { join as join27, dirname as dirname16, basename as basename5 } from "node:path";
|
|
18744
18833
|
import { createHash as createHash11 } from "node:crypto";
|
|
18745
18834
|
init_selection_manager();
|
|
@@ -18752,7 +18841,7 @@ init_smart_cache();
|
|
|
18752
18841
|
|
|
18753
18842
|
// src/lib/tdd-enforcer.ts
|
|
18754
18843
|
init_state();
|
|
18755
|
-
import { readFileSync as readFileSync25, writeFileSync as
|
|
18844
|
+
import { readFileSync as readFileSync25, writeFileSync as writeFileSync21, appendFileSync as appendFileSync7, existsSync as existsSync27, mkdirSync as mkdirSync20, statSync as statSync10, readdirSync as readdirSync6, rmSync as rmSync7, openSync as openSync2 } from "node:fs";
|
|
18756
18845
|
import { join as join26, dirname as dirname15 } from "node:path";
|
|
18757
18846
|
import { createHash as createHash10 } from "node:crypto";
|
|
18758
18847
|
|
|
@@ -19917,10 +20006,10 @@ function _recordCooldown(testPath) {
|
|
|
19917
20006
|
mkdirSync20(dirname15(ENFORCEMENT_COOLDOWN_FILE2), { recursive: true });
|
|
19918
20007
|
const hash = createHash10("sha256").update(testPath).digest("hex").slice(0, 16);
|
|
19919
20008
|
const entry = JSON.stringify({ h: hash, ts: Date.now() }) + "\n";
|
|
19920
|
-
|
|
20009
|
+
appendFileSync7(ENFORCEMENT_COOLDOWN_FILE2, entry);
|
|
19921
20010
|
const lines = readFileSync25(ENFORCEMENT_COOLDOWN_FILE2, "utf-8").trim().split("\n").filter(Boolean);
|
|
19922
20011
|
if (lines.length > 500) {
|
|
19923
|
-
|
|
20012
|
+
writeFileSync21(ENFORCEMENT_COOLDOWN_FILE2, lines.slice(-200).join("\n") + "\n");
|
|
19924
20013
|
}
|
|
19925
20014
|
} catch {
|
|
19926
20015
|
}
|
|
@@ -20008,7 +20097,7 @@ function enforceTestFile(filePath) {
|
|
|
20008
20097
|
if (!_acquireLock(skeleton.path)) return null;
|
|
20009
20098
|
try {
|
|
20010
20099
|
mkdirSync20(skeleton.dir, { recursive: true });
|
|
20011
|
-
|
|
20100
|
+
writeFileSync21(skeleton.path, skeleton.content);
|
|
20012
20101
|
_enforcementCooldown.add(skeleton.path);
|
|
20013
20102
|
_recordCooldown(skeleton.path);
|
|
20014
20103
|
try {
|
|
@@ -20377,7 +20466,7 @@ function _writeCascadeAudit(prompt, slot, model, decision, meta = {}) {
|
|
|
20377
20466
|
mkdirSync21(dir, { recursive: true });
|
|
20378
20467
|
const path = join27(dir, "cascade-audit.jsonl");
|
|
20379
20468
|
if (!existsSync28(path)) {
|
|
20380
|
-
|
|
20469
|
+
appendFileSync8(path, "");
|
|
20381
20470
|
}
|
|
20382
20471
|
const difficulty = computeDifficulty(prompt);
|
|
20383
20472
|
const line = JSON.stringify({
|
|
@@ -20405,7 +20494,7 @@ function _writeCascadeAudit(prompt, slot, model, decision, meta = {}) {
|
|
|
20405
20494
|
confidence: Number(decision?.confidence || 0),
|
|
20406
20495
|
reason: String(decision?.reason || "")
|
|
20407
20496
|
});
|
|
20408
|
-
|
|
20497
|
+
appendFileSync8(path, line + "\n");
|
|
20409
20498
|
} catch (err) {
|
|
20410
20499
|
if (DEBUG_INTERNALS2) console.error(`[vibeOS] cascade-audit write error: ${err.message}`);
|
|
20411
20500
|
}
|
|
@@ -20479,7 +20568,7 @@ ${inputJson}
|
|
|
20479
20568
|
ensureSessionScratchpadDirs();
|
|
20480
20569
|
copyFileSync3(sourcePath, targetPath);
|
|
20481
20570
|
const ptrPath = join27(sessionDir, `${hash}.ptr`);
|
|
20482
|
-
|
|
20571
|
+
writeFileSync22(ptrPath, JSON.stringify({
|
|
20483
20572
|
contentHash: sourceHash,
|
|
20484
20573
|
tool: titleCase,
|
|
20485
20574
|
warmed: true,
|
|
@@ -20573,7 +20662,7 @@ ${argsJson}
|
|
|
20573
20662
|
const globalFile = join27(globalDir, `${targetHash}.txt`);
|
|
20574
20663
|
if (existsSync28(cachedFile) || existsSync28(globalFile)) {
|
|
20575
20664
|
ensureSessionScratchpadDirs();
|
|
20576
|
-
|
|
20665
|
+
writeFileSync22(ptrPath, JSON.stringify({
|
|
20577
20666
|
contentHash: targetHash,
|
|
20578
20667
|
tool: titleCase,
|
|
20579
20668
|
warmed: true,
|
|
@@ -20906,7 +20995,7 @@ ${argsJson}
|
|
|
20906
20995
|
if (!existsSync28(CONTEXT7_INSTALL_FLAG)) {
|
|
20907
20996
|
try {
|
|
20908
20997
|
mkdirSync21(dirname16(CONTEXT7_INSTALL_FLAG), { recursive: true });
|
|
20909
|
-
|
|
20998
|
+
writeFileSync22(CONTEXT7_INSTALL_FLAG, "");
|
|
20910
20999
|
} catch (c7FlagErr) {
|
|
20911
21000
|
if (DEBUG_INTERNALS2) console.error(`[vibeOS] context7 flag write error: ${c7FlagErr.message}`);
|
|
20912
21001
|
}
|
|
@@ -21035,7 +21124,7 @@ var onToolExecuteAfter = async (input, output) => {
|
|
|
21035
21124
|
cascadeIcon: cascadeDepth >= 3 ? "\u25B8\u25B8\u25B8" : cascadeDepth >= 2 ? "\u25B8\u25B8" : cascadeDepth >= 1 ? "\u25B8" : "",
|
|
21036
21125
|
cascadeLabel: cascadeDepth >= 2 ? modelDisplayName(execution.model) : ""
|
|
21037
21126
|
}) + "\n\n";
|
|
21038
|
-
_prependFooterAlert(
|
|
21127
|
+
_prependFooterAlert(_payload2(output), _footerText);
|
|
21039
21128
|
_autoReportCount2 = (_autoReportCount2 || 0) + 1;
|
|
21040
21129
|
if (_autoReportCount2 % 5 === 0 && ltTotal > 0) {
|
|
21041
21130
|
setTimeout(() => {
|
|
@@ -21114,7 +21203,7 @@ var onToolExecuteAfter = async (input, output) => {
|
|
|
21114
21203
|
const taskPrompt = input?.args?.prompt || input?.args?.description || "";
|
|
21115
21204
|
const quality = scoreTaskQuality(taskOutput, taskPrompt);
|
|
21116
21205
|
try {
|
|
21117
|
-
|
|
21206
|
+
appendFileSync8(SAVINGS_LEDGER_FILE, JSON.stringify({
|
|
21118
21207
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21119
21208
|
kind: "quality",
|
|
21120
21209
|
score: quality,
|
|
@@ -21133,12 +21222,12 @@ var onToolExecuteAfter = async (input, output) => {
|
|
|
21133
21222
|
return s;
|
|
21134
21223
|
});
|
|
21135
21224
|
}
|
|
21136
|
-
function
|
|
21225
|
+
function _payload2(obj) {
|
|
21137
21226
|
if (obj?.message && typeof obj.message === "object") return obj.message;
|
|
21138
21227
|
return obj;
|
|
21139
21228
|
}
|
|
21140
21229
|
if (enforcementBlocked) {
|
|
21141
|
-
const target =
|
|
21230
|
+
const target = _payload2(output);
|
|
21142
21231
|
const blockMsg = pendingUiNote || `[delegation] ${String(input?.tool || "tool")} blocked by enforcement`;
|
|
21143
21232
|
const replaceIfNeeded = (key) => {
|
|
21144
21233
|
if (typeof target?.[key] === "string" && /oldString not found/i.test(target[key])) target[key] = blockMsg;
|
|
@@ -21149,7 +21238,7 @@ var onToolExecuteAfter = async (input, output) => {
|
|
|
21149
21238
|
replaceIfNeeded("content");
|
|
21150
21239
|
}
|
|
21151
21240
|
if (pendingUiNote) {
|
|
21152
|
-
const target =
|
|
21241
|
+
const target = _payload2(output);
|
|
21153
21242
|
if (enforcementBlocked) {
|
|
21154
21243
|
const note = pendingUiNote;
|
|
21155
21244
|
if (typeof target?.result === "string") target.result += `
|
|
@@ -21550,7 +21639,7 @@ init_cascade();
|
|
|
21550
21639
|
|
|
21551
21640
|
// src/lib/bootstrap-paths.ts
|
|
21552
21641
|
init_runtime_paths();
|
|
21553
|
-
import { existsSync as existsSync31, mkdirSync as mkdirSync22, readFileSync as readFileSync29, writeFileSync as
|
|
21642
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync22, readFileSync as readFileSync29, writeFileSync as writeFileSync23 } from "node:fs";
|
|
21554
21643
|
import { dirname as dirname17, join as join29 } from "node:path";
|
|
21555
21644
|
function safeJsonParse2(raw) {
|
|
21556
21645
|
try {
|
|
@@ -21603,7 +21692,7 @@ function publishMcpRuntime(port, baseUrl) {
|
|
|
21603
21692
|
const normalizedBase = String(baseUrl || `http://127.0.0.1:${resolvedPort}`).trim().replace(/\/$/, "");
|
|
21604
21693
|
const file = getMcpRuntimeFile();
|
|
21605
21694
|
mkdirSync22(dirname17(file), { recursive: true });
|
|
21606
|
-
|
|
21695
|
+
writeFileSync23(file, JSON.stringify({
|
|
21607
21696
|
port: resolvedPort,
|
|
21608
21697
|
baseUrl: normalizedBase,
|
|
21609
21698
|
pid: process.pid,
|
|
@@ -21676,7 +21765,7 @@ function scanClaimsInOutput(output) {
|
|
|
21676
21765
|
totalClaims: claims.length,
|
|
21677
21766
|
responseHash: ""
|
|
21678
21767
|
});
|
|
21679
|
-
|
|
21768
|
+
appendFileSync9(auditFile, entry + String.fromCharCode(10));
|
|
21680
21769
|
} catch {
|
|
21681
21770
|
}
|
|
21682
21771
|
}
|
|
@@ -21752,7 +21841,7 @@ ${buildResilientFooterLine({
|
|
|
21752
21841
|
if (sid) {
|
|
21753
21842
|
const eventsDir = join30(getVibeOSHome(), "session-events");
|
|
21754
21843
|
mkdirSync23(eventsDir, { recursive: true });
|
|
21755
|
-
|
|
21844
|
+
appendFileSync9(join30(eventsDir, `${sid}.jsonl`), JSON.stringify({
|
|
21756
21845
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21757
21846
|
kind: "footer-probe",
|
|
21758
21847
|
hook: hookName,
|
|
@@ -22063,7 +22152,7 @@ async function _seedOrRepairModelTiers(directory3) {
|
|
|
22063
22152
|
trinity: nextTrinity
|
|
22064
22153
|
};
|
|
22065
22154
|
mkdirSync23(dirname18(TIERS_FILE2), { recursive: true });
|
|
22066
|
-
|
|
22155
|
+
writeFileSync24(TIERS_FILE2, JSON.stringify(tiers, null, 2) + "\n", "utf-8");
|
|
22067
22156
|
return true;
|
|
22068
22157
|
}
|
|
22069
22158
|
function _parseJsonc(raw) {
|
|
@@ -22136,7 +22225,7 @@ function persistMcpPort(port) {
|
|
|
22136
22225
|
delete tiers.mcp_port;
|
|
22137
22226
|
mkdirSync23(dirname18(getTiersFile()), { recursive: true });
|
|
22138
22227
|
const tmp = getTiersFile() + ".tmp." + Date.now();
|
|
22139
|
-
|
|
22228
|
+
writeFileSync24(tmp, JSON.stringify(tiers, null, 2) + "\n", "utf-8");
|
|
22140
22229
|
renameSync10(tmp, getTiersFile());
|
|
22141
22230
|
} catch {
|
|
22142
22231
|
}
|
|
@@ -22561,7 +22650,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
|
|
|
22561
22650
|
try {
|
|
22562
22651
|
mkdirSync23(dirname18(hookProjectStateFile), { recursive: true });
|
|
22563
22652
|
const tmp = hookProjectStateFile + ".tmp";
|
|
22564
|
-
|
|
22653
|
+
writeFileSync24(tmp, JSON.stringify(state, null, 2) + "\n");
|
|
22565
22654
|
renameSync10(tmp, hookProjectStateFile);
|
|
22566
22655
|
} catch {
|
|
22567
22656
|
}
|
|
@@ -22579,7 +22668,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
|
|
|
22579
22668
|
const saveReportsIndexStable = (idx) => {
|
|
22580
22669
|
try {
|
|
22581
22670
|
mkdirSync23(hookReportsDir, { recursive: true });
|
|
22582
|
-
|
|
22671
|
+
writeFileSync24(hookReportsIndex, JSON.stringify(idx, null, 2) + "\n");
|
|
22583
22672
|
} catch {
|
|
22584
22673
|
}
|
|
22585
22674
|
};
|
|
@@ -22624,7 +22713,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
|
|
|
22624
22713
|
directory: directory3,
|
|
22625
22714
|
safeJsonParse,
|
|
22626
22715
|
readFileSync: readFileSync30,
|
|
22627
|
-
writeFileSync:
|
|
22716
|
+
writeFileSync: writeFileSync24,
|
|
22628
22717
|
existsSync: existsSync32,
|
|
22629
22718
|
renameSync: renameSync10,
|
|
22630
22719
|
mkdirSync: mkdirSync23,
|
|
@@ -22754,6 +22843,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
|
|
|
22754
22843
|
};
|
|
22755
22844
|
const pluginHooks = {
|
|
22756
22845
|
"tool.execute.before": async (input, output) => {
|
|
22846
|
+
if (input?.sessionID) setCurrentSessionId(input.sessionID);
|
|
22757
22847
|
setVibeOSHomeContext2(hookVibeHome);
|
|
22758
22848
|
if (hookFp) {
|
|
22759
22849
|
setCurrentProjectFingerprint(hookFp);
|
|
@@ -22771,6 +22861,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
|
|
|
22771
22861
|
return onToolExecuteBefore(input, output);
|
|
22772
22862
|
},
|
|
22773
22863
|
"tool.execute.after": async (input, output) => {
|
|
22864
|
+
if (input?.sessionID) setCurrentSessionId(input.sessionID);
|
|
22774
22865
|
setVibeOSHomeContext2(hookVibeHome);
|
|
22775
22866
|
if (hookFp) {
|
|
22776
22867
|
setCurrentProjectFingerprint(hookFp);
|
|
@@ -22780,6 +22871,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
|
|
|
22780
22871
|
return onToolExecuteAfter(input, output);
|
|
22781
22872
|
},
|
|
22782
22873
|
"chat.params": async (_input, output) => {
|
|
22874
|
+
if (_input?.sessionID) setCurrentSessionId(_input.sessionID);
|
|
22783
22875
|
setVibeOSHomeContext2(hookVibeHome);
|
|
22784
22876
|
syncApiTokenFromDisk();
|
|
22785
22877
|
if (typeof setChatParamsDirectory === "function") setChatParamsDirectory(directory3 || "");
|
|
@@ -22797,9 +22889,11 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
|
|
|
22797
22889
|
return onMessagesTransform(_input, output);
|
|
22798
22890
|
},
|
|
22799
22891
|
"experimental.session.compacting": async (_input, output) => {
|
|
22892
|
+
if (_input?.sessionID) setCurrentSessionId(_input.sessionID);
|
|
22800
22893
|
return onSessionCompacting(_input, output);
|
|
22801
22894
|
},
|
|
22802
22895
|
"experimental.chat.system.transform": async (_input, output) => {
|
|
22896
|
+
if (_input?.sessionID) setCurrentSessionId(_input.sessionID);
|
|
22803
22897
|
setVibeOSHomeContext2(hookVibeHome);
|
|
22804
22898
|
if (hookFp) {
|
|
22805
22899
|
setCurrentProjectFingerprint(hookFp);
|
|
@@ -22822,6 +22916,7 @@ async function DelegationEnforcer({ client: client2, directory: directory3 } = {
|
|
|
22822
22916
|
return onShellEnv(_input, output);
|
|
22823
22917
|
},
|
|
22824
22918
|
"experimental.text.complete": async (_input, output) => {
|
|
22919
|
+
if (_input?.sessionID) setCurrentSessionId(_input.sessionID);
|
|
22825
22920
|
setVibeOSHomeContext2(hookVibeHome);
|
|
22826
22921
|
if (hookFp) {
|
|
22827
22922
|
setCurrentProjectFingerprint(hookFp);
|