omnius 1.0.428 → 1.0.430
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +703 -552
- package/dist/scripts/live-whisper.py +7 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1129,10 +1129,10 @@ var init_model_broker = __esm({
|
|
|
1129
1129
|
return null;
|
|
1130
1130
|
const data = await res.json();
|
|
1131
1131
|
const info = data.model_info ?? {};
|
|
1132
|
-
const
|
|
1132
|
+
const arch4 = info["general.architecture"];
|
|
1133
1133
|
let trainCtx;
|
|
1134
|
-
if (
|
|
1135
|
-
trainCtx = info[`${
|
|
1134
|
+
if (arch4 && typeof info[`${arch4}.context_length`] === "number") {
|
|
1135
|
+
trainCtx = info[`${arch4}.context_length`];
|
|
1136
1136
|
} else {
|
|
1137
1137
|
for (const [k, v] of Object.entries(info)) {
|
|
1138
1138
|
if (k.endsWith(".context_length") && typeof v === "number") {
|
|
@@ -274861,9 +274861,9 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
274861
274861
|
* what was previously computed. */
|
|
274862
274862
|
async loadSessionInfo() {
|
|
274863
274863
|
try {
|
|
274864
|
-
const { readFileSync: readFileSync140, existsSync:
|
|
274864
|
+
const { readFileSync: readFileSync140, existsSync: existsSync172 } = await import("node:fs");
|
|
274865
274865
|
const sessionPath2 = join44(this.cwd, ".omnius", "rlm", "session.json");
|
|
274866
|
-
if (!
|
|
274866
|
+
if (!existsSync172(sessionPath2))
|
|
274867
274867
|
return null;
|
|
274868
274868
|
return JSON.parse(readFileSync140(sessionPath2, "utf8"));
|
|
274869
274869
|
} catch {
|
|
@@ -275439,10 +275439,10 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
275439
275439
|
* Optionally filter by task type for phase-aware context (FSM paper insight).
|
|
275440
275440
|
*/
|
|
275441
275441
|
getTopMemoriesSync(k = 5, taskType) {
|
|
275442
|
-
const { readFileSync: readFileSync140, existsSync:
|
|
275442
|
+
const { readFileSync: readFileSync140, existsSync: existsSync172 } = __require("node:fs");
|
|
275443
275443
|
const metaDir = join45(this.cwd, ".omnius", "memory", "metabolism");
|
|
275444
275444
|
const storeFile = join45(metaDir, "store.json");
|
|
275445
|
-
if (!
|
|
275445
|
+
if (!existsSync172(storeFile))
|
|
275446
275446
|
return "";
|
|
275447
275447
|
let store2 = [];
|
|
275448
275448
|
try {
|
|
@@ -275468,10 +275468,10 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
275468
275468
|
/** Update memory scores based on task outcome. Called after task completion.
|
|
275469
275469
|
* Memories used in successful tasks get boosted. Memories present during failures get decayed. */
|
|
275470
275470
|
updateFromOutcomeSync(surfacedMemoryText, succeeded) {
|
|
275471
|
-
const { readFileSync: readFileSync140, writeFileSync: writeFileSync95, existsSync:
|
|
275471
|
+
const { readFileSync: readFileSync140, writeFileSync: writeFileSync95, existsSync: existsSync172, mkdirSync: mkdirSync112 } = __require("node:fs");
|
|
275472
275472
|
const metaDir = join45(this.cwd, ".omnius", "memory", "metabolism");
|
|
275473
275473
|
const storeFile = join45(metaDir, "store.json");
|
|
275474
|
-
if (!
|
|
275474
|
+
if (!existsSync172(storeFile))
|
|
275475
275475
|
return;
|
|
275476
275476
|
let store2 = [];
|
|
275477
275477
|
try {
|
|
@@ -275922,9 +275922,9 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
275922
275922
|
// Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
|
|
275923
275923
|
/** Retrieve top-K strategies for context injection. Returns "" if none. */
|
|
275924
275924
|
getRelevantStrategiesSync(k = 3, taskType) {
|
|
275925
|
-
const { readFileSync: readFileSync140, existsSync:
|
|
275925
|
+
const { readFileSync: readFileSync140, existsSync: existsSync172 } = __require("node:fs");
|
|
275926
275926
|
const archiveFile = join47(this.cwd, ".omnius", "arche", "variants.json");
|
|
275927
|
-
if (!
|
|
275927
|
+
if (!existsSync172(archiveFile))
|
|
275928
275928
|
return "";
|
|
275929
275929
|
let variants = [];
|
|
275930
275930
|
try {
|
|
@@ -275946,12 +275946,12 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
275946
275946
|
}
|
|
275947
275947
|
/** Archive a strategy variant synchronously (for task completion path) */
|
|
275948
275948
|
archiveVariantSync(strategy, outcome, tags = []) {
|
|
275949
|
-
const { readFileSync: readFileSync140, writeFileSync: writeFileSync95, existsSync:
|
|
275949
|
+
const { readFileSync: readFileSync140, writeFileSync: writeFileSync95, existsSync: existsSync172, mkdirSync: mkdirSync112 } = __require("node:fs");
|
|
275950
275950
|
const dir = join47(this.cwd, ".omnius", "arche");
|
|
275951
275951
|
const archiveFile = join47(dir, "variants.json");
|
|
275952
275952
|
let variants = [];
|
|
275953
275953
|
try {
|
|
275954
|
-
if (
|
|
275954
|
+
if (existsSync172(archiveFile))
|
|
275955
275955
|
variants = JSON.parse(readFileSync140(archiveFile, "utf8"));
|
|
275956
275956
|
} catch {
|
|
275957
275957
|
}
|
|
@@ -564504,7 +564504,7 @@ function recommendMaxParallelFromVram(minFreeMB) {
|
|
|
564504
564504
|
return 1;
|
|
564505
564505
|
}
|
|
564506
564506
|
async function getHardwareSnapshot() {
|
|
564507
|
-
const { totalmem: totalmem10, freemem:
|
|
564507
|
+
const { totalmem: totalmem10, freemem: freemem9, cpus: cpus6 } = await import("node:os");
|
|
564508
564508
|
const gpus = await detectGpus();
|
|
564509
564509
|
const diskPath = discoverSystemOllamaModelStore() ?? homedir33();
|
|
564510
564510
|
const disk = snapshotDisk(diskPath);
|
|
@@ -564513,7 +564513,7 @@ async function getHardwareSnapshot() {
|
|
|
564513
564513
|
gpus,
|
|
564514
564514
|
cpuCores: cpus6().length,
|
|
564515
564515
|
ramTotalMB: Math.round(totalmem10() / (1024 * 1024)),
|
|
564516
|
-
ramFreeMB: Math.round(
|
|
564516
|
+
ramFreeMB: Math.round(freemem9() / (1024 * 1024)),
|
|
564517
564517
|
disk,
|
|
564518
564518
|
network,
|
|
564519
564519
|
takenAtMs: Date.now()
|
|
@@ -568950,8 +568950,8 @@ var init_reflectionBuffer = __esm({
|
|
|
568950
568950
|
this.persistPath = persistPath ?? null;
|
|
568951
568951
|
if (this.persistPath) {
|
|
568952
568952
|
try {
|
|
568953
|
-
const { readFileSync: readFileSync140, existsSync:
|
|
568954
|
-
if (
|
|
568953
|
+
const { readFileSync: readFileSync140, existsSync: existsSync172 } = __require("node:fs");
|
|
568954
|
+
if (existsSync172(this.persistPath)) {
|
|
568955
568955
|
this.state = JSON.parse(readFileSync140(this.persistPath, "utf-8"));
|
|
568956
568956
|
return;
|
|
568957
568957
|
}
|
|
@@ -569246,10 +569246,10 @@ var init_reflectionBuffer = __esm({
|
|
|
569246
569246
|
if (!this.persistPath)
|
|
569247
569247
|
return;
|
|
569248
569248
|
try {
|
|
569249
|
-
const { writeFileSync: writeFileSync95, mkdirSync: mkdirSync112, existsSync:
|
|
569249
|
+
const { writeFileSync: writeFileSync95, mkdirSync: mkdirSync112, existsSync: existsSync172 } = __require("node:fs");
|
|
569250
569250
|
const { join: join188 } = __require("node:path");
|
|
569251
569251
|
const dir = join188(this.persistPath, "..");
|
|
569252
|
-
if (!
|
|
569252
|
+
if (!existsSync172(dir))
|
|
569253
569253
|
mkdirSync112(dir, { recursive: true });
|
|
569254
569254
|
writeFileSync95(this.persistPath, JSON.stringify(this.state, null, 2));
|
|
569255
569255
|
} catch {
|
|
@@ -573202,8 +573202,8 @@ var init_adversaryStream = __esm({
|
|
|
573202
573202
|
if (!this.persistPath)
|
|
573203
573203
|
return;
|
|
573204
573204
|
try {
|
|
573205
|
-
const { readFileSync: readFileSync140, existsSync:
|
|
573206
|
-
if (
|
|
573205
|
+
const { readFileSync: readFileSync140, existsSync: existsSync172 } = __require("node:fs");
|
|
573206
|
+
if (existsSync172(this.persistPath)) {
|
|
573207
573207
|
const data = JSON.parse(readFileSync140(this.persistPath, "utf-8"));
|
|
573208
573208
|
if (Array.isArray(data?.ledger))
|
|
573209
573209
|
this.ledger = data.ledger.slice(-100);
|
|
@@ -573215,10 +573215,10 @@ var init_adversaryStream = __esm({
|
|
|
573215
573215
|
if (!this.persistPath)
|
|
573216
573216
|
return;
|
|
573217
573217
|
try {
|
|
573218
|
-
const { writeFileSync: writeFileSync95, mkdirSync: mkdirSync112, existsSync:
|
|
573218
|
+
const { writeFileSync: writeFileSync95, mkdirSync: mkdirSync112, existsSync: existsSync172 } = __require("node:fs");
|
|
573219
573219
|
const { dirname: dirname56 } = __require("node:path");
|
|
573220
573220
|
const dir = dirname56(this.persistPath);
|
|
573221
|
-
if (!
|
|
573221
|
+
if (!existsSync172(dir))
|
|
573222
573222
|
mkdirSync112(dir, { recursive: true });
|
|
573223
573223
|
writeFileSync95(this.persistPath, JSON.stringify({ ledger: this.ledger }, null, 2));
|
|
573224
573224
|
} catch {
|
|
@@ -603651,6 +603651,7 @@ var init_listen = __esm({
|
|
|
603651
603651
|
case "vad": {
|
|
603652
603652
|
lastHardwareVadAt = Date.now();
|
|
603653
603653
|
const doa = Number(evt.doa);
|
|
603654
|
+
this.emit("status", `Whisper VAD: ${evt.speech === true ? "speech" : "silence"}`);
|
|
603654
603655
|
updateListenLiveState({
|
|
603655
603656
|
speechActive: evt.speech === true,
|
|
603656
603657
|
doa: Number.isFinite(doa) ? doa : null
|
|
@@ -604540,6 +604541,28 @@ var init_live_vlm = __esm({
|
|
|
604540
604541
|
if (this.config.apiKey) headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
604541
604542
|
return headers;
|
|
604542
604543
|
}
|
|
604544
|
+
async unloadModel() {
|
|
604545
|
+
if (!this.config.backendUrl || !this.model) return false;
|
|
604546
|
+
try {
|
|
604547
|
+
const res = await fetch(`${this.baseUrl()}/api/generate`, {
|
|
604548
|
+
method: "POST",
|
|
604549
|
+
headers: this.headers(),
|
|
604550
|
+
signal: AbortSignal.timeout(1e4),
|
|
604551
|
+
body: JSON.stringify({
|
|
604552
|
+
model: this.model,
|
|
604553
|
+
prompt: "",
|
|
604554
|
+
stream: false,
|
|
604555
|
+
keep_alive: 0,
|
|
604556
|
+
options: { num_predict: 0 }
|
|
604557
|
+
})
|
|
604558
|
+
});
|
|
604559
|
+
this.modelReady = null;
|
|
604560
|
+
return res.ok;
|
|
604561
|
+
} catch {
|
|
604562
|
+
this.modelReady = null;
|
|
604563
|
+
return false;
|
|
604564
|
+
}
|
|
604565
|
+
}
|
|
604543
604566
|
/**
|
|
604544
604567
|
* Ensure the VLM is present on the ollama backend, pulling it when missing
|
|
604545
604568
|
* (auto-pull). Single-flight; the pull can take minutes on first run.
|
|
@@ -604618,6 +604641,7 @@ var init_live_vlm = __esm({
|
|
|
604618
604641
|
model: this.model,
|
|
604619
604642
|
stream: false,
|
|
604620
604643
|
format: "json",
|
|
604644
|
+
keep_alive: String(process.env["OMNIUS_LIVE_VLM_KEEP_ALIVE"] ?? "30s"),
|
|
604621
604645
|
options: { temperature: 0.1, num_predict: 260 },
|
|
604622
604646
|
messages: [
|
|
604623
604647
|
{ role: "system", content: VLM_SYSTEM_PROMPT },
|
|
@@ -604680,7 +604704,8 @@ var init_live_vlm = __esm({
|
|
|
604680
604704
|
});
|
|
604681
604705
|
|
|
604682
604706
|
// packages/cli/src/tui/live-sensors.ts
|
|
604683
|
-
import { mkdirSync as mkdirSync70, readFileSync as readFileSync91, writeFileSync as writeFileSync58 } from "node:fs";
|
|
604707
|
+
import { existsSync as existsSync113, mkdirSync as mkdirSync70, readFileSync as readFileSync91, writeFileSync as writeFileSync58 } from "node:fs";
|
|
604708
|
+
import { arch as arch3, freemem as freemem4 } from "node:os";
|
|
604684
604709
|
import { basename as basename23, join as join128, relative as relative11 } from "node:path";
|
|
604685
604710
|
function liveDir(repoRoot) {
|
|
604686
604711
|
return join128(repoRoot, ".omnius", "live");
|
|
@@ -606374,6 +606399,17 @@ function rankLiveAudioInputDevices(devices, configured) {
|
|
|
606374
606399
|
}
|
|
606375
606400
|
return ranked.sort((a2, b) => liveAudioDeviceRank(a2, configured) - liveAudioDeviceRank(b, configured));
|
|
606376
606401
|
}
|
|
606402
|
+
function isJetsonUnifiedMemoryHost() {
|
|
606403
|
+
if (process.platform !== "linux") return false;
|
|
606404
|
+
if (!["arm64", "aarch64"].includes(arch3())) return false;
|
|
606405
|
+
if (existsSync113("/etc/nv_tegra_release")) return true;
|
|
606406
|
+
try {
|
|
606407
|
+
const model = readFileSync91("/proc/device-tree/model", "utf8");
|
|
606408
|
+
return /nvidia|jetson|orin|tegra/i.test(model);
|
|
606409
|
+
} catch {
|
|
606410
|
+
return false;
|
|
606411
|
+
}
|
|
606412
|
+
}
|
|
606377
606413
|
function getLiveSensorManager(repoRoot) {
|
|
606378
606414
|
const key = repoRoot;
|
|
606379
606415
|
let manager = managers.get(key);
|
|
@@ -606474,6 +606510,8 @@ var init_live_sensors = __esm({
|
|
|
606474
606510
|
previewTickInFlight = false;
|
|
606475
606511
|
lastStreamFrameMtime = /* @__PURE__ */ new Map();
|
|
606476
606512
|
lastStreamPersistAt = 0;
|
|
606513
|
+
videoGeneration = 0;
|
|
606514
|
+
liveGpuYieldUntil = 0;
|
|
606477
606515
|
videoInFlight = false;
|
|
606478
606516
|
audioInFlight = false;
|
|
606479
606517
|
audioActivityInFlight = false;
|
|
@@ -606530,6 +606568,12 @@ var init_live_sensors = __esm({
|
|
|
606530
606568
|
*/
|
|
606531
606569
|
setLiveVlmConfig(config) {
|
|
606532
606570
|
this.liveVlm.configure(config);
|
|
606571
|
+
if (config?.backendUrl) {
|
|
606572
|
+
try {
|
|
606573
|
+
getModelBroker().setOllamaBaseUrl(config.backendUrl.replace(/\/v1\/?$/, ""));
|
|
606574
|
+
} catch {
|
|
606575
|
+
}
|
|
606576
|
+
}
|
|
606533
606577
|
if (this.config.videoEnabled && this.liveVlm.enabled) {
|
|
606534
606578
|
void this.liveVlm.ensureModel((message2) => {
|
|
606535
606579
|
this.emitFeedbackThrottled("live-vlm-status", {
|
|
@@ -606556,6 +606600,7 @@ var init_live_sensors = __esm({
|
|
|
606556
606600
|
*/
|
|
606557
606601
|
async runLiveVlm(source, framePath) {
|
|
606558
606602
|
if (!framePath || !this.liveVlm.enabled) return;
|
|
606603
|
+
if (await this.yieldLiveGpuVideoIfNeeded("vlm")) return;
|
|
606559
606604
|
const intervalMs = Math.max(1500, Number(process.env["OMNIUS_LIVE_VLM_INTERVAL_MS"] ?? 4e3));
|
|
606560
606605
|
const last2 = this.lastVlmAt.get(source) ?? 0;
|
|
606561
606606
|
const now2 = Date.now();
|
|
@@ -606676,7 +606721,66 @@ var init_live_sensors = __esm({
|
|
|
606676
606721
|
const next = (current + delta) % 360;
|
|
606677
606722
|
return this.setCameraRotation(device, next, "manual", `manual ${direction === "cw" ? "clockwise" : "counter-clockwise"} dashboard override`);
|
|
606678
606723
|
}
|
|
606724
|
+
isVideoWorkCurrent(generation) {
|
|
606725
|
+
return this.config.videoEnabled && generation === this.videoGeneration;
|
|
606726
|
+
}
|
|
606727
|
+
liveVideoGpuPolicy() {
|
|
606728
|
+
const raw = String(process.env["OMNIUS_LIVE_VIDEO_GPU_POLICY"] ?? "").trim().toLowerCase();
|
|
606729
|
+
if (raw === "aggressive" || raw === "force" || raw === "on") return "aggressive";
|
|
606730
|
+
if (raw === "balanced" || raw === "auto") return "balanced";
|
|
606731
|
+
if (raw === "yield" || raw === "off" || raw === "cpu" || raw === "passive") return "yield";
|
|
606732
|
+
return isJetsonUnifiedMemoryHost() ? "yield" : "balanced";
|
|
606733
|
+
}
|
|
606734
|
+
async shouldYieldLiveGpuVideo(kind) {
|
|
606735
|
+
const policy = this.liveVideoGpuPolicy();
|
|
606736
|
+
if (policy === "aggressive") return { yield: false, reason: "" };
|
|
606737
|
+
if (policy === "yield") {
|
|
606738
|
+
return {
|
|
606739
|
+
yield: true,
|
|
606740
|
+
reason: `live video ${kind} yields to Ollama GPU allocation on unified-memory ARM`
|
|
606741
|
+
};
|
|
606742
|
+
}
|
|
606743
|
+
try {
|
|
606744
|
+
const broker = getModelBroker();
|
|
606745
|
+
const snap = await broker.pollOnce().catch(() => broker.snapshot());
|
|
606746
|
+
const liveVlmModel = this.liveVlm.model;
|
|
606747
|
+
const nonLiveOllama = snap.loaded.filter((model) => model.host === "ollama" && model.name !== liveVlmModel);
|
|
606748
|
+
const activeSlots = snap.slots.inUse + snap.slots.queueDepth;
|
|
606749
|
+
const vramLow = snap.vramPerDevice.some((gpu) => gpu.free < Math.max(1024, broker.vramHeadroomMB));
|
|
606750
|
+
const ramLow = snap.ramMB.free < Math.max(4096, broker.ramHeadroomMB);
|
|
606751
|
+
if (nonLiveOllama.length > 0 || activeSlots > 0 || vramLow || ramLow) {
|
|
606752
|
+
return {
|
|
606753
|
+
yield: true,
|
|
606754
|
+
reason: `live video ${kind} yielded: ollama=${nonLiveOllama.length}, slots=${activeSlots}, ramFree=${snap.ramMB.free}MB`
|
|
606755
|
+
};
|
|
606756
|
+
}
|
|
606757
|
+
} catch {
|
|
606758
|
+
if (isJetsonUnifiedMemoryHost() || freemem4() < 6 * 1024 * 1024 * 1024) {
|
|
606759
|
+
return { yield: true, reason: `live video ${kind} yielded: memory pressure unknown` };
|
|
606760
|
+
}
|
|
606761
|
+
}
|
|
606762
|
+
return { yield: false, reason: "" };
|
|
606763
|
+
}
|
|
606764
|
+
async yieldLiveGpuVideoIfNeeded(kind) {
|
|
606765
|
+
const decision2 = await this.shouldYieldLiveGpuVideo(kind);
|
|
606766
|
+
if (!decision2.yield) return false;
|
|
606767
|
+
const now2 = Date.now();
|
|
606768
|
+
if (now2 >= this.liveGpuYieldUntil) {
|
|
606769
|
+
this.liveGpuYieldUntil = now2 + 15e3;
|
|
606770
|
+
void this.liveVlm.unloadModel().catch(() => false);
|
|
606771
|
+
this.emitFeedbackThrottled(`live-video-gpu-yield:${kind}`, {
|
|
606772
|
+
kind: "status",
|
|
606773
|
+
title: "Live video GPU yield",
|
|
606774
|
+
observedAt: now2,
|
|
606775
|
+
message: `${decision2.reason}. Camera capture/ASCII preview stays active; GPU video inference is skipped. Set OMNIUS_LIVE_VIDEO_GPU_POLICY=aggressive to override.`
|
|
606776
|
+
}, 3e4);
|
|
606777
|
+
}
|
|
606778
|
+
return true;
|
|
606779
|
+
}
|
|
606679
606780
|
async autoOrientCamera(device = this.config.selectedCamera, options2 = {}) {
|
|
606781
|
+
const generation = this.videoGeneration;
|
|
606782
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
606783
|
+
if (await this.yieldLiveGpuVideoIfNeeded("orientation")) return "Camera orientation skipped while yielding GPU to Ollama.";
|
|
606680
606784
|
const target = device || this.config.selectedCamera || firstDeviceId(this.devices.video);
|
|
606681
606785
|
if (!target) return "No camera selected. Use /live camera <device> or select a camera in /live.";
|
|
606682
606786
|
if (options2.onlyIfUnset && this.getCameraOrientation(target)) {
|
|
@@ -606693,17 +606797,20 @@ var init_live_sensors = __esm({
|
|
|
606693
606797
|
framePath = streamFrame.path;
|
|
606694
606798
|
}
|
|
606695
606799
|
if (!framePath) {
|
|
606800
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
606696
606801
|
const captured = await new CameraCaptureTool().execute({
|
|
606697
606802
|
action: "capture",
|
|
606698
606803
|
device: target,
|
|
606699
606804
|
rotate_degrees: 0
|
|
606700
606805
|
});
|
|
606806
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
606701
606807
|
if (!captured.success) {
|
|
606702
606808
|
return `Camera orientation detection could not capture ${target}: ${captured.error || captured.output || "unknown error"}`;
|
|
606703
606809
|
}
|
|
606704
606810
|
framePath = extractSavedImagePath(captured.output, this.repoRoot);
|
|
606705
606811
|
}
|
|
606706
606812
|
if (!framePath) return `Camera orientation detection captured ${target}, but no frame path was returned.`;
|
|
606813
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
606707
606814
|
const cvScores = await scoreCameraOrientationWithOpenCv(framePath);
|
|
606708
606815
|
const cvDecision = cvScores ? chooseCameraOrientationFromScores(cvScores) : null;
|
|
606709
606816
|
const prompt = [
|
|
@@ -606721,6 +606828,7 @@ var init_live_sensors = __esm({
|
|
|
606721
606828
|
prompt,
|
|
606722
606829
|
model: "moondream3-preview"
|
|
606723
606830
|
});
|
|
606831
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
606724
606832
|
if (!vision.success) {
|
|
606725
606833
|
if (cvDecision) {
|
|
606726
606834
|
const orientation2 = this.setCameraRotation(target, cvDecision.rotation, "auto", cvDecision.reason, cvDecision.confidence);
|
|
@@ -606774,12 +606882,19 @@ var init_live_sensors = __esm({
|
|
|
606774
606882
|
return this.devices;
|
|
606775
606883
|
}
|
|
606776
606884
|
configure(patch) {
|
|
606885
|
+
const wasVideoEnabled = this.config.videoEnabled;
|
|
606777
606886
|
this.config = {
|
|
606778
606887
|
...this.config,
|
|
606779
606888
|
...patch,
|
|
606780
606889
|
videoIntervalMs: Math.max(MIN_VIDEO_INTERVAL_MS, Number(patch.videoIntervalMs ?? this.config.videoIntervalMs)),
|
|
606781
606890
|
audioIntervalMs: Math.max(MIN_AUDIO_INTERVAL_MS, Number(patch.audioIntervalMs ?? this.config.audioIntervalMs))
|
|
606782
606891
|
};
|
|
606892
|
+
if (wasVideoEnabled && !this.config.videoEnabled) {
|
|
606893
|
+
this.videoGeneration++;
|
|
606894
|
+
this.lastStreamFrameMtime.clear();
|
|
606895
|
+
this.cameraStreamers?.stopAll();
|
|
606896
|
+
void this.liveVlm.unloadModel().catch(() => false);
|
|
606897
|
+
}
|
|
606783
606898
|
this.persist();
|
|
606784
606899
|
this.clearLoopTimers();
|
|
606785
606900
|
this.ensureLoops();
|
|
@@ -606812,6 +606927,7 @@ var init_live_sensors = __esm({
|
|
|
606812
606927
|
videoIntervalMs: options2.lowLatency === false ? this.config.videoIntervalMs : Math.min(this.config.videoIntervalMs, LOW_LATENCY_VIDEO_INTERVAL_MS),
|
|
606813
606928
|
audioIntervalMs: options2.lowLatency === false ? this.config.audioIntervalMs : Math.min(this.config.audioIntervalMs, LOW_LATENCY_AUDIO_INTERVAL_MS)
|
|
606814
606929
|
});
|
|
606930
|
+
void this.yieldLiveGpuVideoIfNeeded("startup").catch(() => false);
|
|
606815
606931
|
for (const source of this.activeVideoSources()) {
|
|
606816
606932
|
const current = this.getCameraOrientation(source);
|
|
606817
606933
|
if (current?.source === "manual") continue;
|
|
@@ -606858,6 +606974,8 @@ var init_live_sensors = __esm({
|
|
|
606858
606974
|
return options2.agent ? "Live PFC run enabled: visual/audio feedback is active and significant events can launch background agent review." : "Live run enabled: visual/audio feedback is active and live context will update each turn.";
|
|
606859
606975
|
}
|
|
606860
606976
|
async previewCamera(device = this.config.selectedCamera, options2 = {}) {
|
|
606977
|
+
const generation = options2.generation ?? this.videoGeneration;
|
|
606978
|
+
if (!this.isVideoWorkCurrent(generation)) return { ok: false, message: "Video context is disabled." };
|
|
606861
606979
|
const source = device || firstDeviceId(this.devices.video);
|
|
606862
606980
|
if (!source) return { ok: false, message: "No camera selected. Use /live to select a camera after device discovery." };
|
|
606863
606981
|
const orientation = this.getCameraOrientation(source);
|
|
@@ -606867,6 +606985,7 @@ var init_live_sensors = __esm({
|
|
|
606867
606985
|
const displayPath2 = relative11(this.repoRoot, streamFrame.path).startsWith("..") ? streamFrame.path : relative11(this.repoRoot, streamFrame.path);
|
|
606868
606986
|
const previewWidth2 = Math.max(42, Math.min(120, Math.floor(Number(options2.previewWidth ?? (process.stdout.columns || 100) - 14))));
|
|
606869
606987
|
const preview2 = await buildImageAsciiPreview(streamFrame.path, { width: previewWidth2 });
|
|
606988
|
+
if (!this.isVideoWorkCurrent(generation)) return { ok: false, message: "Video context is disabled." };
|
|
606870
606989
|
if (preview2?.ascii || preview2?.plainAscii) {
|
|
606871
606990
|
const observedAt2 = Date.now();
|
|
606872
606991
|
const cameraView2 = {
|
|
@@ -606909,6 +607028,7 @@ var init_live_sensors = __esm({
|
|
|
606909
607028
|
device: source,
|
|
606910
607029
|
rotate_degrees: rotation
|
|
606911
607030
|
});
|
|
607031
|
+
if (!this.isVideoWorkCurrent(generation)) return { ok: false, message: "Video context is disabled." };
|
|
606912
607032
|
if (!result.success) {
|
|
606913
607033
|
const error = result.error || result.output || "camera capture failed";
|
|
606914
607034
|
const observedAt2 = Date.now();
|
|
@@ -606953,6 +607073,7 @@ var init_live_sensors = __esm({
|
|
|
606953
607073
|
const displayPath = relative11(this.repoRoot, framePath).startsWith("..") ? framePath : relative11(this.repoRoot, framePath);
|
|
606954
607074
|
const previewWidth = Math.max(42, Math.min(120, Math.floor(Number(options2.previewWidth ?? (process.stdout.columns || 100) - 14))));
|
|
606955
607075
|
const preview = await buildImageAsciiPreview(framePath, { width: previewWidth });
|
|
607076
|
+
if (!this.isVideoWorkCurrent(generation)) return { ok: false, message: "Video context is disabled." };
|
|
606956
607077
|
const asciiContext = preview ? formatImageAsciiContext(preview, displayPath) : void 0;
|
|
606957
607078
|
const observedAt = Date.now();
|
|
606958
607079
|
const cameraView = {
|
|
@@ -607061,7 +607182,10 @@ var init_live_sensors = __esm({
|
|
|
607061
607182
|
}
|
|
607062
607183
|
}
|
|
607063
607184
|
async sampleSingleVideoNow(source, forceInfer, previewWidth, options2 = {}) {
|
|
607064
|
-
const
|
|
607185
|
+
const generation = options2.generation ?? this.videoGeneration;
|
|
607186
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
607187
|
+
const preview = await this.previewCamera(source, { emit: false, previewWidth, generation });
|
|
607188
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
607065
607189
|
void this.runLiveVlm(source, preview.ok ? preview.framePath : void 0).catch(() => {
|
|
607066
607190
|
});
|
|
607067
607191
|
let inference = "";
|
|
@@ -607071,7 +607195,7 @@ var init_live_sensors = __esm({
|
|
|
607071
607195
|
const inferenceThrottleMs = Math.max(0, Number(options2.inferThrottleMs ?? 2500));
|
|
607072
607196
|
const lastInferenceAt = this.lastInferenceAt.get(source) ?? 0;
|
|
607073
607197
|
const shouldInfer = Boolean(forceInfer && source && (options2.forceInferenceNow || sampledAt - lastInferenceAt >= inferenceThrottleMs));
|
|
607074
|
-
if (shouldInfer) {
|
|
607198
|
+
if (shouldInfer && !await this.yieldLiveGpuVideoIfNeeded("inference")) {
|
|
607075
607199
|
this.lastInferenceAt.set(source, sampledAt);
|
|
607076
607200
|
const loop = new LiveMediaLoopTool(this.repoRoot);
|
|
607077
607201
|
const inferFromCapturedFrame = preview.ok && Boolean(preview.framePath);
|
|
@@ -607096,6 +607220,7 @@ var init_live_sensors = __esm({
|
|
|
607096
607220
|
crop_faces: true,
|
|
607097
607221
|
recognize_faces: true
|
|
607098
607222
|
});
|
|
607223
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
607099
607224
|
inference = result.success ? String(result.output || result.llmContent || "") : `Video inference failed: ${result.error || result.output || "unknown error"}`;
|
|
607100
607225
|
const livePayload = result.success ? parseLiveMediaPayload(result.llmContent || result.output) : null;
|
|
607101
607226
|
if (livePayload) livePayload.source = source;
|
|
@@ -607165,9 +607290,10 @@ var init_live_sensors = __esm({
|
|
|
607165
607290
|
}
|
|
607166
607291
|
}
|
|
607167
607292
|
const lastClip = this.lastClipAt.get(source) ?? 0;
|
|
607168
|
-
if (this.config.clipEnabled && preview.ok && preview.framePath && source && sampledAt - lastClip >= 5e3) {
|
|
607293
|
+
if (this.config.clipEnabled && preview.ok && preview.framePath && source && sampledAt - lastClip >= 5e3 && !await this.yieldLiveGpuVideoIfNeeded("clip")) {
|
|
607169
607294
|
this.lastClipAt.set(source, sampledAt);
|
|
607170
607295
|
clipSummary = await this.recognizeFrameObjects(preview.framePath, source, sampledAt, { emit: false });
|
|
607296
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
607171
607297
|
const current = this.snapshot.cameras?.[source];
|
|
607172
607298
|
if (current) {
|
|
607173
607299
|
const clipLine = formatClipDashboardSummary(clipSummary);
|
|
@@ -607196,9 +607322,12 @@ ${clipSummary}` : ""].filter(Boolean).join("\n");
|
|
|
607196
607322
|
return result;
|
|
607197
607323
|
}
|
|
607198
607324
|
async sampleVideoNow(forceInfer = this.config.inferEnabled, options2 = {}) {
|
|
607325
|
+
const generation = options2.generation ?? this.videoGeneration;
|
|
607326
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
607199
607327
|
if (this.videoInFlight) return "Video sampler is already running.";
|
|
607200
607328
|
this.videoInFlight = true;
|
|
607201
607329
|
try {
|
|
607330
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
607202
607331
|
const allSources = this.activeVideoSources();
|
|
607203
607332
|
if (allSources.length === 0) return "No camera selected. Use /live refresh after connecting hardware.";
|
|
607204
607333
|
const sources = options2.mode === "round-robin" ? [allSources[this.nextVideoSourceIndex++ % allSources.length]] : allSources;
|
|
@@ -607206,8 +607335,10 @@ ${clipSummary}` : ""].filter(Boolean).join("\n");
|
|
|
607206
607335
|
const outputs = [];
|
|
607207
607336
|
const previewWidth = liveDashboardPreviewWidthForSources(allSources.length);
|
|
607208
607337
|
for (const source of sources) {
|
|
607209
|
-
|
|
607338
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
607339
|
+
outputs.push(await this.sampleSingleVideoNow(source, forceInfer, previewWidth, { ...options2, generation }));
|
|
607210
607340
|
}
|
|
607341
|
+
if (!this.isVideoWorkCurrent(generation)) return "Video context is disabled.";
|
|
607211
607342
|
this.emitDashboard();
|
|
607212
607343
|
return outputs.map((output, index) => `## Camera ${sources[index]}
|
|
607213
607344
|
${output}`).join("\n\n");
|
|
@@ -607888,7 +608019,7 @@ var init_tool_adapter = __esm({
|
|
|
607888
608019
|
});
|
|
607889
608020
|
|
|
607890
608021
|
// packages/cli/src/tui/runtime-verification.ts
|
|
607891
|
-
import { existsSync as
|
|
608022
|
+
import { existsSync as existsSync114, readFileSync as readFileSync92, readdirSync as readdirSync36 } from "node:fs";
|
|
607892
608023
|
import { dirname as dirname38, extname as extname14, join as join129, relative as relative12, resolve as resolve54 } from "node:path";
|
|
607893
608024
|
function safeRelative(root, file) {
|
|
607894
608025
|
const rel = relative12(root, file);
|
|
@@ -607937,7 +608068,7 @@ function resolveScriptSource(root, htmlFile, src2) {
|
|
|
607937
608068
|
const abs = clean5.startsWith("/") ? resolve54(root, `.${clean5}`) : resolve54(dirname38(htmlFile), clean5);
|
|
607938
608069
|
const rel = relative12(root, abs);
|
|
607939
608070
|
if (rel.startsWith("..") || rel === "") return null;
|
|
607940
|
-
return
|
|
608071
|
+
return existsSync114(abs) ? abs : null;
|
|
607941
608072
|
}
|
|
607942
608073
|
function referencedScriptAssets(root, htmlFile) {
|
|
607943
608074
|
let html = "";
|
|
@@ -607972,7 +608103,7 @@ async function syntaxCheckJavaScriptModule(source) {
|
|
|
607972
608103
|
}
|
|
607973
608104
|
async function runStaticRuntimeAssetSyntaxCheck(projectRoot, options2 = {}) {
|
|
607974
608105
|
const root = resolve54(projectRoot);
|
|
607975
|
-
if (!
|
|
608106
|
+
if (!existsSync114(root)) {
|
|
607976
608107
|
return { ok: true, checkedAssets: 0, htmlFiles: 0, issues: [], skippedReason: "project root missing" };
|
|
607977
608108
|
}
|
|
607978
608109
|
const htmlFiles = collectHtmlFiles(root, options2.maxHtmlFiles ?? 80);
|
|
@@ -614242,15 +614373,15 @@ async function fetchOllamaModels(baseUrl2) {
|
|
|
614242
614373
|
}
|
|
614243
614374
|
if (show.model_info) {
|
|
614244
614375
|
const info = show.model_info;
|
|
614245
|
-
const
|
|
614376
|
+
const arch4 = info["general.architecture"];
|
|
614246
614377
|
const paramCount = info["general.parameter_count"];
|
|
614247
614378
|
const fileSizeGB = result[i2].sizeBytes > 0 ? result[i2].sizeBytes / 1024 ** 3 : paramCount ? paramCount * 0.6 / 1024 ** 3 : 4;
|
|
614248
|
-
if (
|
|
614249
|
-
const archMax = info[`${
|
|
614250
|
-
const nLayers = info[`${
|
|
614251
|
-
const nKVHeads = info[`${
|
|
614252
|
-
const keyDim = info[`${
|
|
614253
|
-
const valDim = info[`${
|
|
614379
|
+
if (arch4) {
|
|
614380
|
+
const archMax = info[`${arch4}.context_length`];
|
|
614381
|
+
const nLayers = info[`${arch4}.block_count`];
|
|
614382
|
+
const nKVHeads = info[`${arch4}.attention.head_count_kv`] ?? info[`${arch4}.attention.head_count`];
|
|
614383
|
+
const keyDim = info[`${arch4}.attention.key_length`];
|
|
614384
|
+
const valDim = info[`${arch4}.attention.value_length`] ?? keyDim;
|
|
614254
614385
|
if (archMax && nLayers && nKVHeads && keyDim && valDim) {
|
|
614255
614386
|
const kvBytesPerToken = nLayers * nKVHeads * (keyDim + valDim) * 2;
|
|
614256
614387
|
result[i2].contextLength = estimateRealisticContext(kvBytesPerToken, archMax, fileSizeGB);
|
|
@@ -614322,7 +614453,7 @@ async function fetchOpenAIModels(baseUrl2, apiKey) {
|
|
|
614322
614453
|
async function fetchPeerModels(peerId, authKey) {
|
|
614323
614454
|
try {
|
|
614324
614455
|
const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports2));
|
|
614325
|
-
const { existsSync:
|
|
614456
|
+
const { existsSync: existsSync172, readFileSync: readFileSync140 } = await import("node:fs");
|
|
614326
614457
|
const { join: join188 } = await import("node:path");
|
|
614327
614458
|
const cwd4 = process.cwd();
|
|
614328
614459
|
const nexusTool = new NexusTool2(cwd4);
|
|
@@ -614330,7 +614461,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
614330
614461
|
let isLocalPeer = false;
|
|
614331
614462
|
try {
|
|
614332
614463
|
const statusPath = join188(nexusDir, "status.json");
|
|
614333
|
-
if (
|
|
614464
|
+
if (existsSync172(statusPath)) {
|
|
614334
614465
|
const status = JSON.parse(readFileSync140(statusPath, "utf8"));
|
|
614335
614466
|
if (status.peerId === peerId) isLocalPeer = true;
|
|
614336
614467
|
}
|
|
@@ -614338,7 +614469,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
614338
614469
|
}
|
|
614339
614470
|
if (isLocalPeer) {
|
|
614340
614471
|
const pricingPath = join188(nexusDir, "pricing.json");
|
|
614341
|
-
if (
|
|
614472
|
+
if (existsSync172(pricingPath)) {
|
|
614342
614473
|
try {
|
|
614343
614474
|
const pricing = JSON.parse(readFileSync140(pricingPath, "utf8"));
|
|
614344
614475
|
const localModels = (pricing.models || []).map((m2) => ({
|
|
@@ -614354,7 +614485,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
614354
614485
|
}
|
|
614355
614486
|
}
|
|
614356
614487
|
const cachePath2 = join188(nexusDir, "peer-models-cache.json");
|
|
614357
|
-
if (
|
|
614488
|
+
if (existsSync172(cachePath2)) {
|
|
614358
614489
|
try {
|
|
614359
614490
|
const cache8 = JSON.parse(readFileSync140(cachePath2, "utf8"));
|
|
614360
614491
|
if (cache8.peerId === peerId && cache8.models?.length > 0) {
|
|
@@ -614469,7 +614600,7 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
614469
614600
|
}
|
|
614470
614601
|
if (isLocalPeer) {
|
|
614471
614602
|
const pricingPath = join188(nexusDir, "pricing.json");
|
|
614472
|
-
if (
|
|
614603
|
+
if (existsSync172(pricingPath)) {
|
|
614473
614604
|
try {
|
|
614474
614605
|
const pricing = JSON.parse(readFileSync140(pricingPath, "utf8"));
|
|
614475
614606
|
return (pricing.models || []).map((m2) => ({
|
|
@@ -614547,15 +614678,15 @@ async function queryModelContextSize(baseUrl2, modelName) {
|
|
|
614547
614678
|
if (explicitNumCtx) return explicitNumCtx;
|
|
614548
614679
|
if (data.model_info) {
|
|
614549
614680
|
const info = data.model_info;
|
|
614550
|
-
const
|
|
614681
|
+
const arch4 = info["general.architecture"];
|
|
614551
614682
|
const paramCount = info["general.parameter_count"];
|
|
614552
614683
|
const modelSizeGB2 = paramCount ? paramCount * 0.6 / 1024 ** 3 : 4;
|
|
614553
|
-
if (
|
|
614554
|
-
const archMax = info[`${
|
|
614555
|
-
const nLayers = info[`${
|
|
614556
|
-
const nKVHeads = info[`${
|
|
614557
|
-
const keyDim = info[`${
|
|
614558
|
-
const valDim = info[`${
|
|
614684
|
+
if (arch4) {
|
|
614685
|
+
const archMax = info[`${arch4}.context_length`];
|
|
614686
|
+
const nLayers = info[`${arch4}.block_count`];
|
|
614687
|
+
const nKVHeads = info[`${arch4}.attention.head_count_kv`] ?? info[`${arch4}.attention.head_count`];
|
|
614688
|
+
const keyDim = info[`${arch4}.attention.key_length`];
|
|
614689
|
+
const valDim = info[`${arch4}.attention.value_length`] ?? keyDim;
|
|
614559
614690
|
if (archMax && nLayers && nKVHeads && keyDim && valDim) {
|
|
614560
614691
|
const kvBytesPerToken = nLayers * nKVHeads * (keyDim + valDim) * 2;
|
|
614561
614692
|
return estimateRealisticContext(kvBytesPerToken, archMax, modelSizeGB2);
|
|
@@ -618120,7 +618251,7 @@ var init_voice_session = __esm({
|
|
|
618120
618251
|
|
|
618121
618252
|
// packages/cli/src/tui/scoped-personality.ts
|
|
618122
618253
|
import { createHash as createHash32 } from "node:crypto";
|
|
618123
|
-
import { appendFileSync as appendFileSync12, existsSync as
|
|
618254
|
+
import { appendFileSync as appendFileSync12, existsSync as existsSync115, mkdirSync as mkdirSync71, readFileSync as readFileSync93, writeFileSync as writeFileSync59 } from "node:fs";
|
|
618124
618255
|
import { join as join130, resolve as resolve55 } from "node:path";
|
|
618125
618256
|
function safeName(input) {
|
|
618126
618257
|
return input.replace(/[^A-Za-z0-9_.-]/g, "-").slice(0, 80) || "default";
|
|
@@ -618273,7 +618404,7 @@ function updateScopedPersonalityReplyPreference(scope, preference) {
|
|
|
618273
618404
|
}
|
|
618274
618405
|
function loadScopedPersonality(scope) {
|
|
618275
618406
|
const paths = scopedPersonalityPaths(scope);
|
|
618276
|
-
if (!
|
|
618407
|
+
if (!existsSync115(paths.json)) return newDocument(scope);
|
|
618277
618408
|
try {
|
|
618278
618409
|
const parsed = JSON.parse(readFileSync93(paths.json, "utf8"));
|
|
618279
618410
|
if (parsed.version !== PROFILE_VERSION) return newDocument(scope);
|
|
@@ -618499,7 +618630,7 @@ var init_scoped_personality = __esm({
|
|
|
618499
618630
|
|
|
618500
618631
|
// packages/cli/src/tui/voice-soul.ts
|
|
618501
618632
|
import { createHash as createHash33 } from "node:crypto";
|
|
618502
|
-
import { existsSync as
|
|
618633
|
+
import { existsSync as existsSync116, readdirSync as readdirSync37, readFileSync as readFileSync94 } from "node:fs";
|
|
618503
618634
|
import { basename as basename24, join as join131, resolve as resolve56 } from "node:path";
|
|
618504
618635
|
function compactText(text2, limit) {
|
|
618505
618636
|
const compact4 = text2.replace(/\s+/g, " ").trim();
|
|
@@ -618524,7 +618655,7 @@ function soulRuntimeStatePath(input) {
|
|
|
618524
618655
|
}
|
|
618525
618656
|
function loadSoulRuntimeState(input) {
|
|
618526
618657
|
const path12 = soulRuntimeStatePath(input);
|
|
618527
|
-
if (!
|
|
618658
|
+
if (!existsSync116(path12)) return { version: 1 };
|
|
618528
618659
|
try {
|
|
618529
618660
|
const parsed = JSON.parse(readFileSync94(path12, "utf8"));
|
|
618530
618661
|
if (!parsed || parsed.version !== 1) return { version: 1 };
|
|
@@ -618642,7 +618773,7 @@ function findProjectSoul(scope) {
|
|
|
618642
618773
|
resolve56(scope.repoRoot, "SOUL.md"),
|
|
618643
618774
|
resolve56(scope.repoRoot, ".aiwg", "SOUL.md")
|
|
618644
618775
|
]) {
|
|
618645
|
-
if (!
|
|
618776
|
+
if (!existsSync116(candidate)) continue;
|
|
618646
618777
|
try {
|
|
618647
618778
|
return { path: candidate, content: readFileSync94(candidate, "utf8") };
|
|
618648
618779
|
} catch {
|
|
@@ -618653,7 +618784,7 @@ function findProjectSoul(scope) {
|
|
|
618653
618784
|
}
|
|
618654
618785
|
function findProjectVoice(scope) {
|
|
618655
618786
|
const voiceDir3 = resolve56(scope.repoRoot, ".aiwg", "voices");
|
|
618656
|
-
if (!
|
|
618787
|
+
if (!existsSync116(voiceDir3)) return null;
|
|
618657
618788
|
try {
|
|
618658
618789
|
const files = readdirSync37(voiceDir3).filter((name10) => /\.ya?ml$/i.test(name10)).sort((a2, b) => {
|
|
618659
618790
|
const ap = /^(default|omnius|project)\.ya?ml$/i.test(a2) ? 0 : 1;
|
|
@@ -618927,8 +619058,8 @@ import { spawn as spawn32, exec as exec3 } from "node:child_process";
|
|
|
618927
619058
|
import { EventEmitter as EventEmitter8 } from "node:events";
|
|
618928
619059
|
import { randomBytes as randomBytes22, timingSafeEqual } from "node:crypto";
|
|
618929
619060
|
import { URL as URL2 } from "node:url";
|
|
618930
|
-
import { loadavg, cpus as cpus3, totalmem as totalmem6, freemem as
|
|
618931
|
-
import { existsSync as
|
|
619061
|
+
import { loadavg, cpus as cpus3, totalmem as totalmem6, freemem as freemem5 } from "node:os";
|
|
619062
|
+
import { existsSync as existsSync117, readFileSync as readFileSync95, writeFileSync as writeFileSync60, unlinkSync as unlinkSync20, mkdirSync as mkdirSync72, readdirSync as readdirSync38, statSync as statSync45, statfsSync as statfsSync7 } from "node:fs";
|
|
618932
619063
|
import { join as join132 } from "node:path";
|
|
618933
619064
|
function cleanForwardHeaders(raw, targetHost) {
|
|
618934
619065
|
const out = {};
|
|
@@ -619098,7 +619229,7 @@ function nextSponsorDailyReset(now2 = Date.now()) {
|
|
|
619098
619229
|
function readSponsorUsageState(stateDir) {
|
|
619099
619230
|
try {
|
|
619100
619231
|
const path12 = join132(stateDir, "sponsor", SPONSOR_USAGE_FILE_NAME);
|
|
619101
|
-
if (!
|
|
619232
|
+
if (!existsSync117(path12)) return null;
|
|
619102
619233
|
const parsed = JSON.parse(readFileSync95(path12, "utf8"));
|
|
619103
619234
|
const dailyTokensUsed = safeNonNegativeInt(parsed.dailyTokensUsed);
|
|
619104
619235
|
const dailyTokensResetAt = safeNonNegativeInt(parsed.dailyTokensResetAt);
|
|
@@ -619123,7 +619254,7 @@ function writeSponsorUsageState(stateDir, state) {
|
|
|
619123
619254
|
function readExposeState(stateDir) {
|
|
619124
619255
|
try {
|
|
619125
619256
|
const path12 = join132(stateDir, STATE_FILE_NAME);
|
|
619126
|
-
if (!
|
|
619257
|
+
if (!existsSync117(path12)) return null;
|
|
619127
619258
|
const raw = readFileSync95(path12, "utf8");
|
|
619128
619259
|
const data = JSON.parse(raw);
|
|
619129
619260
|
if (!data.pid || !data.tunnelUrl || !data.authKey || !data.proxyPort) return null;
|
|
@@ -619188,7 +619319,7 @@ async function collectSystemMetricsAsync() {
|
|
|
619188
619319
|
const [l1, l5, l15] = loadavg();
|
|
619189
619320
|
const cores = cpus3().length;
|
|
619190
619321
|
const totalMem = totalmem6();
|
|
619191
|
-
const freeMem =
|
|
619322
|
+
const freeMem = freemem5();
|
|
619192
619323
|
const usedMem = totalMem - freeMem;
|
|
619193
619324
|
let disk = {
|
|
619194
619325
|
path: process.cwd(),
|
|
@@ -619261,7 +619392,7 @@ async function collectSystemMetricsAsync() {
|
|
|
619261
619392
|
function readP2PExposeState(stateDir) {
|
|
619262
619393
|
try {
|
|
619263
619394
|
const path12 = join132(stateDir, P2P_STATE_FILE_NAME);
|
|
619264
|
-
if (!
|
|
619395
|
+
if (!existsSync117(path12)) return null;
|
|
619265
619396
|
const raw = readFileSync95(path12, "utf8");
|
|
619266
619397
|
const data = JSON.parse(raw);
|
|
619267
619398
|
if (!data.peerId || !data.authKey) return null;
|
|
@@ -620698,7 +620829,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
620698
620829
|
}
|
|
620699
620830
|
try {
|
|
620700
620831
|
const invocDir = join132(nexusDir, "invocations");
|
|
620701
|
-
if (
|
|
620832
|
+
if (existsSync117(invocDir)) {
|
|
620702
620833
|
this._prevInvocCount = readdirSync38(invocDir).filter((f2) => f2.endsWith(".json")).length;
|
|
620703
620834
|
this._stats.totalRequests = this._prevInvocCount;
|
|
620704
620835
|
}
|
|
@@ -620727,7 +620858,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
620727
620858
|
const nexusDir = nexusTool.getNexusDir();
|
|
620728
620859
|
const statusPath = join132(nexusDir, "status.json");
|
|
620729
620860
|
try {
|
|
620730
|
-
if (!
|
|
620861
|
+
if (!existsSync117(statusPath)) {
|
|
620731
620862
|
removeP2PExposeState(stateDir);
|
|
620732
620863
|
return null;
|
|
620733
620864
|
}
|
|
@@ -620785,7 +620916,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
620785
620916
|
this._activityPollTimer = setInterval(() => {
|
|
620786
620917
|
try {
|
|
620787
620918
|
const invocDir = join132(nexusDir, "invocations");
|
|
620788
|
-
if (!
|
|
620919
|
+
if (!existsSync117(invocDir)) return;
|
|
620789
620920
|
const files = readdirSync38(invocDir).filter((f2) => f2.endsWith(".json"));
|
|
620790
620921
|
const invocCount = files.length;
|
|
620791
620922
|
const newRequests = invocCount - this._prevInvocCount;
|
|
@@ -620808,7 +620939,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
620808
620939
|
const meteringFile = join132(nexusDir, "metering.jsonl");
|
|
620809
620940
|
let meteringLines = lastMeteringLineCount;
|
|
620810
620941
|
try {
|
|
620811
|
-
if (
|
|
620942
|
+
if (existsSync117(meteringFile)) {
|
|
620812
620943
|
const content = readFileSync95(meteringFile, "utf8");
|
|
620813
620944
|
meteringLines = content.split("\n").filter((l2) => l2.trim()).length;
|
|
620814
620945
|
}
|
|
@@ -620837,7 +620968,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
620837
620968
|
this._pollTimer = setInterval(() => {
|
|
620838
620969
|
try {
|
|
620839
620970
|
const statusPath = join132(nexusDir, "status.json");
|
|
620840
|
-
if (
|
|
620971
|
+
if (existsSync117(statusPath)) {
|
|
620841
620972
|
const status = JSON.parse(readFileSync95(statusPath, "utf8"));
|
|
620842
620973
|
if (status.peerId && !this._peerId) {
|
|
620843
620974
|
this._peerId = status.peerId;
|
|
@@ -620848,7 +620979,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
620848
620979
|
}
|
|
620849
620980
|
try {
|
|
620850
620981
|
const invocDir = join132(nexusDir, "invocations");
|
|
620851
|
-
if (
|
|
620982
|
+
if (existsSync117(invocDir)) {
|
|
620852
620983
|
const files = readdirSync38(invocDir);
|
|
620853
620984
|
const invocCount = files.filter((f2) => f2.endsWith(".json")).length;
|
|
620854
620985
|
if (invocCount > this._stats.totalRequests) {
|
|
@@ -620860,7 +620991,7 @@ ${this.formatConnectionInfo()}`);
|
|
|
620860
620991
|
}
|
|
620861
620992
|
try {
|
|
620862
620993
|
const meteringFile = join132(nexusDir, "metering.jsonl");
|
|
620863
|
-
if (
|
|
620994
|
+
if (existsSync117(meteringFile)) {
|
|
620864
620995
|
const content = readFileSync95(meteringFile, "utf8");
|
|
620865
620996
|
if (content.length > lastMeteringSize) {
|
|
620866
620997
|
const newContent = content.slice(lastMeteringSize);
|
|
@@ -621158,7 +621289,7 @@ var init_types3 = __esm({
|
|
|
621158
621289
|
|
|
621159
621290
|
// packages/cli/src/tui/p2p/secret-vault.ts
|
|
621160
621291
|
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes23, scryptSync as scryptSync2, createHash as createHash34 } from "node:crypto";
|
|
621161
|
-
import { readFileSync as readFileSync96, writeFileSync as writeFileSync61, existsSync as
|
|
621292
|
+
import { readFileSync as readFileSync96, writeFileSync as writeFileSync61, existsSync as existsSync118, mkdirSync as mkdirSync73 } from "node:fs";
|
|
621162
621293
|
import { dirname as dirname39 } from "node:path";
|
|
621163
621294
|
var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
|
|
621164
621295
|
var init_secret_vault = __esm({
|
|
@@ -621367,7 +621498,7 @@ var init_secret_vault = __esm({
|
|
|
621367
621498
|
const tag = cipher.getAuthTag();
|
|
621368
621499
|
const blob = Buffer.concat([salt, iv, tag, encrypted]);
|
|
621369
621500
|
const dir = dirname39(this.storePath);
|
|
621370
|
-
if (!
|
|
621501
|
+
if (!existsSync118(dir)) mkdirSync73(dir, { recursive: true });
|
|
621371
621502
|
writeFileSync61(this.storePath, blob, { mode: 384 });
|
|
621372
621503
|
}
|
|
621373
621504
|
/**
|
|
@@ -621375,7 +621506,7 @@ var init_secret_vault = __esm({
|
|
|
621375
621506
|
* Returns the number of secrets loaded.
|
|
621376
621507
|
*/
|
|
621377
621508
|
load(passphrase) {
|
|
621378
|
-
if (!this.storePath || !
|
|
621509
|
+
if (!this.storePath || !existsSync118(this.storePath)) return 0;
|
|
621379
621510
|
const blob = readFileSync96(this.storePath);
|
|
621380
621511
|
if (blob.length < SALT_LEN + IV_LEN + 16) {
|
|
621381
621512
|
throw new Error("Vault file is corrupted (too small)");
|
|
@@ -622414,7 +622545,7 @@ ${activitySummary}
|
|
|
622414
622545
|
});
|
|
622415
622546
|
|
|
622416
622547
|
// packages/cli/src/api/profiles.ts
|
|
622417
|
-
import { existsSync as
|
|
622548
|
+
import { existsSync as existsSync119, readFileSync as readFileSync97, writeFileSync as writeFileSync62, mkdirSync as mkdirSync74, readdirSync as readdirSync39, unlinkSync as unlinkSync21 } from "node:fs";
|
|
622418
622549
|
import { join as join134 } from "node:path";
|
|
622419
622550
|
import { homedir as homedir41 } from "node:os";
|
|
622420
622551
|
import { createCipheriv as createCipheriv4, createDecipheriv as createDecipheriv4, randomBytes as randomBytes25, scryptSync as scryptSync3 } from "node:crypto";
|
|
@@ -622431,7 +622562,7 @@ function listProfiles(projectDir2) {
|
|
|
622431
622562
|
const result = [];
|
|
622432
622563
|
const seen = /* @__PURE__ */ new Set();
|
|
622433
622564
|
const projDir = projectProfileDir(projectDir2);
|
|
622434
|
-
if (
|
|
622565
|
+
if (existsSync119(projDir)) {
|
|
622435
622566
|
for (const f2 of readdirSync39(projDir).filter((f3) => f3.endsWith(".json"))) {
|
|
622436
622567
|
try {
|
|
622437
622568
|
const raw = JSON.parse(readFileSync97(join134(projDir, f2), "utf8"));
|
|
@@ -622448,7 +622579,7 @@ function listProfiles(projectDir2) {
|
|
|
622448
622579
|
}
|
|
622449
622580
|
}
|
|
622450
622581
|
const globDir = globalProfileDir();
|
|
622451
|
-
if (
|
|
622582
|
+
if (existsSync119(globDir)) {
|
|
622452
622583
|
for (const f2 of readdirSync39(globDir).filter((f3) => f3.endsWith(".json"))) {
|
|
622453
622584
|
const name10 = f2.replace(".json", "");
|
|
622454
622585
|
if (seen.has(name10)) continue;
|
|
@@ -622488,7 +622619,7 @@ function loadProfileWithMeta(name10, password, projectDir2) {
|
|
|
622488
622619
|
{ source: "global", path: globPath }
|
|
622489
622620
|
];
|
|
622490
622621
|
for (const candidate of candidates) {
|
|
622491
|
-
if (!
|
|
622622
|
+
if (!existsSync119(candidate.path)) continue;
|
|
622492
622623
|
const raw = JSON.parse(readFileSync97(candidate.path, "utf8"));
|
|
622493
622624
|
if (raw.encrypted === true) {
|
|
622494
622625
|
if (!password) return null;
|
|
@@ -622517,7 +622648,7 @@ function deleteProfile(name10, scope = "global", projectDir2) {
|
|
|
622517
622648
|
const sanitized = name10.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
622518
622649
|
const dir = scope === "project" ? projectProfileDir(projectDir2) : globalProfileDir();
|
|
622519
622650
|
const filePath = join134(dir, `${sanitized}.json`);
|
|
622520
|
-
if (
|
|
622651
|
+
if (existsSync119(filePath)) {
|
|
622521
622652
|
unlinkSync21(filePath);
|
|
622522
622653
|
return true;
|
|
622523
622654
|
}
|
|
@@ -622796,20 +622927,20 @@ __export(omnius_directory_exports, {
|
|
|
622796
622927
|
writeIndexMeta: () => writeIndexMeta,
|
|
622797
622928
|
writeTaskHandoff: () => writeTaskHandoff2
|
|
622798
622929
|
});
|
|
622799
|
-
import { appendFileSync as appendFileSync13, cpSync as cpSync2, existsSync as
|
|
622930
|
+
import { appendFileSync as appendFileSync13, cpSync as cpSync2, existsSync as existsSync120, mkdirSync as mkdirSync75, readFileSync as readFileSync98, writeFileSync as writeFileSync63, readdirSync as readdirSync40, statSync as statSync46, unlinkSync as unlinkSync22, openSync as openSync2, closeSync as closeSync2, renameSync as renameSync11, watch as fsWatch2 } from "node:fs";
|
|
622800
622931
|
import { join as join135, relative as relative13, basename as basename25, dirname as dirname40, resolve as resolve57 } from "node:path";
|
|
622801
622932
|
import { homedir as homedir42 } from "node:os";
|
|
622802
622933
|
import { createHash as createHash37 } from "node:crypto";
|
|
622803
622934
|
function isGitRoot(dir) {
|
|
622804
622935
|
const gitPath = join135(dir, ".git");
|
|
622805
|
-
if (!
|
|
622936
|
+
if (!existsSync120(gitPath)) return false;
|
|
622806
622937
|
try {
|
|
622807
622938
|
const stat9 = statSync46(gitPath);
|
|
622808
622939
|
if (stat9.isFile()) {
|
|
622809
622940
|
return readFileSync98(gitPath, "utf-8").trim().startsWith("gitdir:");
|
|
622810
622941
|
}
|
|
622811
622942
|
if (!stat9.isDirectory()) return false;
|
|
622812
|
-
return
|
|
622943
|
+
return existsSync120(join135(gitPath, "HEAD")) || existsSync120(join135(gitPath, "config")) || existsSync120(join135(gitPath, "commondir"));
|
|
622813
622944
|
} catch {
|
|
622814
622945
|
return false;
|
|
622815
622946
|
}
|
|
@@ -622832,7 +622963,7 @@ function findNearestExistingGitignore(startDir, gitRoot) {
|
|
|
622832
622963
|
while (dir && !visited.has(dir)) {
|
|
622833
622964
|
visited.add(dir);
|
|
622834
622965
|
const candidate = join135(dir, ".gitignore");
|
|
622835
|
-
if (
|
|
622966
|
+
if (existsSync120(candidate)) return candidate;
|
|
622836
622967
|
if (dir === gitRoot) break;
|
|
622837
622968
|
const parent = join135(dir, "..");
|
|
622838
622969
|
if (parent === dir) break;
|
|
@@ -622949,7 +623080,7 @@ function stopOmniusGitignoreWatcher(repoRoot) {
|
|
|
622949
623080
|
function migrateLegacyDirectories(repoRoot, omniusPath) {
|
|
622950
623081
|
for (const legacyDir of LEGACY_DIRS) {
|
|
622951
623082
|
const legacyPath = join135(repoRoot, legacyDir);
|
|
622952
|
-
if (!
|
|
623083
|
+
if (!existsSync120(legacyPath) || legacyPath === omniusPath) continue;
|
|
622953
623084
|
try {
|
|
622954
623085
|
cpSync2(legacyPath, omniusPath, {
|
|
622955
623086
|
recursive: true,
|
|
@@ -622982,12 +623113,12 @@ function initOmniusDirectory(repoRoot) {
|
|
|
622982
623113
|
return omniusPath;
|
|
622983
623114
|
}
|
|
622984
623115
|
function hasOmniusDirectory(repoRoot) {
|
|
622985
|
-
return
|
|
623116
|
+
return existsSync120(join135(repoRoot, OMNIUS_DIR, "index"));
|
|
622986
623117
|
}
|
|
622987
623118
|
function loadProjectSettings(repoRoot) {
|
|
622988
623119
|
const settingsPath = join135(repoRoot, OMNIUS_DIR, "settings.json");
|
|
622989
623120
|
try {
|
|
622990
|
-
if (
|
|
623121
|
+
if (existsSync120(settingsPath)) {
|
|
622991
623122
|
return JSON.parse(readFileSync98(settingsPath, "utf-8"));
|
|
622992
623123
|
}
|
|
622993
623124
|
} catch {
|
|
@@ -623004,7 +623135,7 @@ function saveProjectSettings(repoRoot, settings) {
|
|
|
623004
623135
|
function loadGlobalSettings() {
|
|
623005
623136
|
const settingsPath = join135(homedir42(), ".omnius", "settings.json");
|
|
623006
623137
|
try {
|
|
623007
|
-
if (
|
|
623138
|
+
if (existsSync120(settingsPath)) {
|
|
623008
623139
|
return JSON.parse(readFileSync98(settingsPath, "utf-8"));
|
|
623009
623140
|
}
|
|
623010
623141
|
} catch {
|
|
@@ -623033,7 +623164,7 @@ function discoverContextFiles(repoRoot, maxContentLen = 8e3) {
|
|
|
623033
623164
|
for (const name10 of CONTEXT_FILES) {
|
|
623034
623165
|
const filePath = join135(dir, name10);
|
|
623035
623166
|
const normalizedName = name10.toLowerCase();
|
|
623036
|
-
if (
|
|
623167
|
+
if (existsSync120(filePath) && !seen.has(filePath)) {
|
|
623037
623168
|
seen.add(filePath);
|
|
623038
623169
|
try {
|
|
623039
623170
|
let content = readFileSync98(filePath, "utf-8");
|
|
@@ -623153,7 +623284,7 @@ function saveSession(repoRoot, session) {
|
|
|
623153
623284
|
}
|
|
623154
623285
|
function loadRecentSessions(repoRoot, limit = 5) {
|
|
623155
623286
|
const historyDir = join135(repoRoot, OMNIUS_DIR, "history");
|
|
623156
|
-
if (!
|
|
623287
|
+
if (!existsSync120(historyDir)) return [];
|
|
623157
623288
|
try {
|
|
623158
623289
|
const files = readdirSync40(historyDir).filter((f2) => f2.endsWith(".json") && f2 !== "pending-task.json").map((f2) => {
|
|
623159
623290
|
const stat9 = statSync46(join135(historyDir, f2));
|
|
@@ -623184,7 +623315,7 @@ function savePendingTask(repoRoot, task) {
|
|
|
623184
623315
|
function loadPendingTask(repoRoot) {
|
|
623185
623316
|
const filePath = join135(repoRoot, OMNIUS_DIR, "history", PENDING_TASK_FILE);
|
|
623186
623317
|
try {
|
|
623187
|
-
if (!
|
|
623318
|
+
if (!existsSync120(filePath)) return null;
|
|
623188
623319
|
const data = JSON.parse(readFileSync98(filePath, "utf-8"));
|
|
623189
623320
|
try {
|
|
623190
623321
|
unlinkSync22(filePath);
|
|
@@ -623214,7 +623345,7 @@ function writeTaskHandoff2(repoRoot, handoff) {
|
|
|
623214
623345
|
function readTaskHandoff2(repoRoot) {
|
|
623215
623346
|
const filePath = join135(repoRoot, OMNIUS_DIR, "context", HANDOFF_FILE);
|
|
623216
623347
|
try {
|
|
623217
|
-
if (!
|
|
623348
|
+
if (!existsSync120(filePath)) return null;
|
|
623218
623349
|
const data = JSON.parse(readFileSync98(filePath, "utf-8"));
|
|
623219
623350
|
const handoffTime = new Date(data.handoffAt).getTime();
|
|
623220
623351
|
const now2 = Date.now();
|
|
@@ -623231,7 +623362,7 @@ function readTaskHandoff2(repoRoot) {
|
|
|
623231
623362
|
function clearTaskHandoff(repoRoot) {
|
|
623232
623363
|
const filePath = join135(repoRoot, OMNIUS_DIR, "context", HANDOFF_FILE);
|
|
623233
623364
|
try {
|
|
623234
|
-
if (
|
|
623365
|
+
if (existsSync120(filePath)) {
|
|
623235
623366
|
unlinkSync22(filePath);
|
|
623236
623367
|
}
|
|
623237
623368
|
} catch {
|
|
@@ -623299,7 +623430,7 @@ function acquireLock(lockPath) {
|
|
|
623299
623430
|
closeSync2(fd);
|
|
623300
623431
|
return true;
|
|
623301
623432
|
} catch (err) {
|
|
623302
|
-
if (
|
|
623433
|
+
if (existsSync120(lockPath)) {
|
|
623303
623434
|
try {
|
|
623304
623435
|
const lockContent = readFileSync98(lockPath, "utf-8");
|
|
623305
623436
|
const lock = JSON.parse(lockContent);
|
|
@@ -623326,7 +623457,7 @@ function acquireLock(lockPath) {
|
|
|
623326
623457
|
}
|
|
623327
623458
|
function releaseLock(lockPath) {
|
|
623328
623459
|
try {
|
|
623329
|
-
if (
|
|
623460
|
+
if (existsSync120(lockPath)) {
|
|
623330
623461
|
const lockContent = readFileSync98(lockPath, "utf-8");
|
|
623331
623462
|
const lock = JSON.parse(lockContent);
|
|
623332
623463
|
if (lock.pid === process.pid) {
|
|
@@ -623416,7 +623547,7 @@ function mergeSessionContextEntry(previous, incoming) {
|
|
|
623416
623547
|
}
|
|
623417
623548
|
function pruneContextLedger(ledgerPath) {
|
|
623418
623549
|
try {
|
|
623419
|
-
if (!
|
|
623550
|
+
if (!existsSync120(ledgerPath)) return;
|
|
623420
623551
|
const st = statSync46(ledgerPath);
|
|
623421
623552
|
if (st.size <= MAX_CONTEXT_LEDGER_BYTES) return;
|
|
623422
623553
|
const lines = readFileSync98(ledgerPath, "utf-8").split(/\r?\n/).filter((line) => line.trim().length > 0);
|
|
@@ -623446,7 +623577,7 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
623446
623577
|
try {
|
|
623447
623578
|
let ctx3;
|
|
623448
623579
|
try {
|
|
623449
|
-
if (
|
|
623580
|
+
if (existsSync120(filePath)) {
|
|
623450
623581
|
ctx3 = JSON.parse(readFileSync98(filePath, "utf-8"));
|
|
623451
623582
|
} else {
|
|
623452
623583
|
ctx3 = { entries: [], maxEntries: MAX_CONTEXT_ENTRIES, updatedAt: "" };
|
|
@@ -623608,7 +623739,7 @@ function renderSessionDiary(entries) {
|
|
|
623608
623739
|
function loadSessionContext(repoRoot) {
|
|
623609
623740
|
const filePath = join135(repoRoot, OMNIUS_DIR, "context", CONTEXT_SAVE_FILE);
|
|
623610
623741
|
try {
|
|
623611
|
-
if (!
|
|
623742
|
+
if (!existsSync120(filePath)) return null;
|
|
623612
623743
|
return JSON.parse(readFileSync98(filePath, "utf-8"));
|
|
623613
623744
|
} catch {
|
|
623614
623745
|
return null;
|
|
@@ -623616,7 +623747,7 @@ function loadSessionContext(repoRoot) {
|
|
|
623616
623747
|
}
|
|
623617
623748
|
function readJsonOrNull(filePath) {
|
|
623618
623749
|
try {
|
|
623619
|
-
if (!
|
|
623750
|
+
if (!existsSync120(filePath)) return null;
|
|
623620
623751
|
return JSON.parse(readFileSync98(filePath, "utf-8"));
|
|
623621
623752
|
} catch {
|
|
623622
623753
|
return null;
|
|
@@ -623683,7 +623814,7 @@ function scoreRestoreLedger(ledger, workboard) {
|
|
|
623683
623814
|
function selectActiveTaskAnchor(repoRoot) {
|
|
623684
623815
|
const ledgerDir = join135(repoRoot, OMNIUS_DIR, "completion-ledgers");
|
|
623685
623816
|
try {
|
|
623686
|
-
if (!
|
|
623817
|
+
if (!existsSync120(ledgerDir)) return null;
|
|
623687
623818
|
const candidates = readdirSync40(ledgerDir).filter((name10) => name10.endsWith(".json")).map((name10) => {
|
|
623688
623819
|
const filePath = join135(ledgerDir, name10);
|
|
623689
623820
|
const ledger = readJsonOrNull(filePath);
|
|
@@ -623827,7 +623958,7 @@ function getLastTaskSummary(repoRoot) {
|
|
|
623827
623958
|
function updateSessionEntry(repoRoot, sessionId, patch) {
|
|
623828
623959
|
const indexPath = join135(repoRoot, OMNIUS_DIR, SESSIONS_DIR, SESSIONS_INDEX);
|
|
623829
623960
|
try {
|
|
623830
|
-
if (!
|
|
623961
|
+
if (!existsSync120(indexPath)) return false;
|
|
623831
623962
|
const index = JSON.parse(readFileSync98(indexPath, "utf-8"));
|
|
623832
623963
|
const idx = index.findIndex((e2) => e2.id === sessionId);
|
|
623833
623964
|
if (idx < 0) return false;
|
|
@@ -623876,7 +624007,7 @@ function saveSessionHistory(repoRoot, sessionId, contentLines, meta) {
|
|
|
623876
624007
|
const indexPath = join135(sessDir, SESSIONS_INDEX);
|
|
623877
624008
|
let index = [];
|
|
623878
624009
|
try {
|
|
623879
|
-
if (
|
|
624010
|
+
if (existsSync120(indexPath)) {
|
|
623880
624011
|
index = JSON.parse(readFileSync98(indexPath, "utf-8"));
|
|
623881
624012
|
}
|
|
623882
624013
|
} catch {
|
|
@@ -623908,7 +624039,7 @@ function saveSessionHistory(repoRoot, sessionId, contentLines, meta) {
|
|
|
623908
624039
|
function listSessions(repoRoot) {
|
|
623909
624040
|
const indexPath = join135(repoRoot, OMNIUS_DIR, SESSIONS_DIR, SESSIONS_INDEX);
|
|
623910
624041
|
try {
|
|
623911
|
-
if (!
|
|
624042
|
+
if (!existsSync120(indexPath)) return [];
|
|
623912
624043
|
const index = JSON.parse(readFileSync98(indexPath, "utf-8"));
|
|
623913
624044
|
return index.map((entry) => sanitizeSessionHistoryEntry(repoRoot, entry)).sort((a2, b) => b.updatedAt.localeCompare(a2.updatedAt));
|
|
623914
624045
|
} catch {
|
|
@@ -623918,7 +624049,7 @@ function listSessions(repoRoot) {
|
|
|
623918
624049
|
function loadSessionHistory(repoRoot, sessionId) {
|
|
623919
624050
|
const contentPath = join135(repoRoot, OMNIUS_DIR, SESSIONS_DIR, `${sessionId}.jsonl`);
|
|
623920
624051
|
try {
|
|
623921
|
-
if (!
|
|
624052
|
+
if (!existsSync120(contentPath)) return null;
|
|
623922
624053
|
return readFileSync98(contentPath, "utf-8").split("\n");
|
|
623923
624054
|
} catch {
|
|
623924
624055
|
return null;
|
|
@@ -623929,8 +624060,8 @@ function deleteSession(repoRoot, sessionId) {
|
|
|
623929
624060
|
const indexPath = join135(sessDir, SESSIONS_INDEX);
|
|
623930
624061
|
try {
|
|
623931
624062
|
const contentPath = join135(sessDir, `${sessionId}.jsonl`);
|
|
623932
|
-
if (
|
|
623933
|
-
if (
|
|
624063
|
+
if (existsSync120(contentPath)) unlinkSync22(contentPath);
|
|
624064
|
+
if (existsSync120(indexPath)) {
|
|
623934
624065
|
let index = JSON.parse(readFileSync98(indexPath, "utf-8"));
|
|
623935
624066
|
index = index.filter((s2) => s2.id !== sessionId);
|
|
623936
624067
|
writeFileSync63(indexPath, JSON.stringify(index, null, 2), "utf-8");
|
|
@@ -623984,7 +624115,7 @@ function detectManifests(repoRoot) {
|
|
|
623984
624115
|
];
|
|
623985
624116
|
for (const check of checks) {
|
|
623986
624117
|
const filePath = join135(repoRoot, check.file);
|
|
623987
|
-
if (
|
|
624118
|
+
if (existsSync120(filePath)) {
|
|
623988
624119
|
let name10;
|
|
623989
624120
|
if (check.nameField) {
|
|
623990
624121
|
try {
|
|
@@ -624017,7 +624148,7 @@ function findKeyFiles(repoRoot) {
|
|
|
624017
624148
|
{ pattern: "CLAUDE.md", description: "Claude Code context" }
|
|
624018
624149
|
];
|
|
624019
624150
|
for (const check of checks) {
|
|
624020
|
-
if (
|
|
624151
|
+
if (existsSync120(join135(repoRoot, check.pattern))) {
|
|
624021
624152
|
keyFiles.push({ path: check.pattern, description: check.description });
|
|
624022
624153
|
}
|
|
624023
624154
|
}
|
|
@@ -624058,7 +624189,7 @@ function buildDirTree(root, maxDepth, prefix = "", depth = 0) {
|
|
|
624058
624189
|
}
|
|
624059
624190
|
function loadUsageFile(filePath) {
|
|
624060
624191
|
try {
|
|
624061
|
-
if (
|
|
624192
|
+
if (existsSync120(filePath)) {
|
|
624062
624193
|
return JSON.parse(readFileSync98(filePath, "utf-8"));
|
|
624063
624194
|
}
|
|
624064
624195
|
} catch {
|
|
@@ -624386,14 +624517,14 @@ var init_session_summary = __esm({
|
|
|
624386
624517
|
|
|
624387
624518
|
// packages/cli/src/tui/cad-model-viewer.ts
|
|
624388
624519
|
import { createServer as createServer7 } from "node:http";
|
|
624389
|
-
import { existsSync as
|
|
624520
|
+
import { existsSync as existsSync121, readFileSync as readFileSync99, statSync as statSync47 } from "node:fs";
|
|
624390
624521
|
import { basename as basename26, extname as extname16, resolve as resolve58 } from "node:path";
|
|
624391
624522
|
function getCurrentCadModelViewer() {
|
|
624392
624523
|
return currentViewer;
|
|
624393
624524
|
}
|
|
624394
624525
|
async function startCadModelViewer(filePath) {
|
|
624395
624526
|
const resolved = filePath ? resolve58(filePath) : void 0;
|
|
624396
|
-
if (resolved && (!
|
|
624527
|
+
if (resolved && (!existsSync121(resolved) || !statSync47(resolved).isFile())) {
|
|
624397
624528
|
throw new Error(`3D model file not found: ${resolved}`);
|
|
624398
624529
|
}
|
|
624399
624530
|
if (currentViewer) {
|
|
@@ -624850,14 +624981,14 @@ var init_render2 = __esm({
|
|
|
624850
624981
|
});
|
|
624851
624982
|
|
|
624852
624983
|
// packages/prompts/dist/promptLoader.js
|
|
624853
|
-
import { readFileSync as readFileSync101, existsSync as
|
|
624984
|
+
import { readFileSync as readFileSync101, existsSync as existsSync123 } from "node:fs";
|
|
624854
624985
|
import { join as join137, dirname as dirname41 } from "node:path";
|
|
624855
624986
|
import { fileURLToPath as fileURLToPath17 } from "node:url";
|
|
624856
624987
|
function loadPrompt2(promptPath, vars) {
|
|
624857
624988
|
let content = cache6.get(promptPath);
|
|
624858
624989
|
if (content === void 0) {
|
|
624859
624990
|
const fullPath = join137(PROMPTS_DIR2, promptPath);
|
|
624860
|
-
if (!
|
|
624991
|
+
if (!existsSync123(fullPath)) {
|
|
624861
624992
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
624862
624993
|
}
|
|
624863
624994
|
content = readFileSync101(fullPath, "utf-8");
|
|
@@ -624875,7 +625006,7 @@ var init_promptLoader2 = __esm({
|
|
|
624875
625006
|
__dirname5 = dirname41(__filename4);
|
|
624876
625007
|
devPath = join137(__dirname5, "..", "templates");
|
|
624877
625008
|
publishedPath = join137(__dirname5, "..", "prompts", "templates");
|
|
624878
|
-
PROMPTS_DIR2 =
|
|
625009
|
+
PROMPTS_DIR2 = existsSync123(devPath) ? devPath : publishedPath;
|
|
624879
625010
|
cache6 = /* @__PURE__ */ new Map();
|
|
624880
625011
|
}
|
|
624881
625012
|
});
|
|
@@ -625359,7 +625490,7 @@ __export(system_metrics_exports, {
|
|
|
625359
625490
|
getInstantSnapshot: () => getInstantSnapshot,
|
|
625360
625491
|
instantaneousCpuPct: () => instantaneousCpuPct
|
|
625361
625492
|
});
|
|
625362
|
-
import { loadavg as loadavg2, cpus as cpus4, totalmem as totalmem7, freemem as
|
|
625493
|
+
import { loadavg as loadavg2, cpus as cpus4, totalmem as totalmem7, freemem as freemem6, platform as platform4 } from "node:os";
|
|
625363
625494
|
import { exec as exec4 } from "node:child_process";
|
|
625364
625495
|
import { readFile as readFile24 } from "node:fs/promises";
|
|
625365
625496
|
function formatRate(bytesPerSec) {
|
|
@@ -625550,7 +625681,7 @@ function collectCpuRam() {
|
|
|
625550
625681
|
const cores = cpus4().length;
|
|
625551
625682
|
const cpuModel = cpus4()[0]?.model ?? "";
|
|
625552
625683
|
const totalMem = totalmem7();
|
|
625553
|
-
const usedMem = totalMem -
|
|
625684
|
+
const usedMem = totalMem - freemem6();
|
|
625554
625685
|
let cpuUtil = instantaneousCpuPct();
|
|
625555
625686
|
if (cpuUtil < 0) {
|
|
625556
625687
|
const [l1] = loadavg2();
|
|
@@ -625957,7 +626088,7 @@ __export(tui_tasks_renderer_exports, {
|
|
|
625957
626088
|
setTuiTasksSession: () => setTuiTasksSession,
|
|
625958
626089
|
teardownTuiTasks: () => teardownTuiTasks
|
|
625959
626090
|
});
|
|
625960
|
-
import { existsSync as
|
|
626091
|
+
import { existsSync as existsSync124, readFileSync as readFileSync102, watch as fsWatch3 } from "node:fs";
|
|
625961
626092
|
import { join as join139 } from "node:path";
|
|
625962
626093
|
import { homedir as homedir44 } from "node:os";
|
|
625963
626094
|
function setTasksRendererWriter(writer) {
|
|
@@ -626080,7 +626211,7 @@ function loadTodos() {
|
|
|
626080
626211
|
}
|
|
626081
626212
|
try {
|
|
626082
626213
|
const fp = todoPath2(_activeSessionId);
|
|
626083
|
-
if (!
|
|
626214
|
+
if (!existsSync124(fp)) {
|
|
626084
626215
|
_lastTodos = [];
|
|
626085
626216
|
return;
|
|
626086
626217
|
}
|
|
@@ -627223,6 +627354,9 @@ var init_status_bar = __esm({
|
|
|
627223
627354
|
const identity3 = this.buildHeaderIdentityRender();
|
|
627224
627355
|
const modelLabel = this.summarizeHeaderModelName() || "model";
|
|
627225
627356
|
const endpointLabel = this.summarizeHeaderTransport() || "endpoint";
|
|
627357
|
+
const headerLiveMediaActive = this._liveMediaStatus.audio || this._liveMediaStatus.video;
|
|
627358
|
+
const headerLiveDot = headerLiveMediaActive ? Math.floor(Date.now() / 500) % 2 === 0 ? "●" : "○" : "";
|
|
627359
|
+
const headerLiveLabel = headerLiveMediaActive ? `${headerLiveDot}live` : "live";
|
|
627226
627360
|
const menuBtns = [
|
|
627227
627361
|
{ cmd: "help", label: "help", w: "help".length + 2 },
|
|
627228
627362
|
// +2 for spaces
|
|
@@ -627232,7 +627366,7 @@ var init_status_bar = __esm({
|
|
|
627232
627366
|
w: (this._voiceActive ? this._voiceModelId || "voice" : "voice").length + 2
|
|
627233
627367
|
},
|
|
627234
627368
|
// +2 for spaces
|
|
627235
|
-
{ cmd: "
|
|
627369
|
+
{ cmd: "live", label: headerLiveLabel, w: headerLiveLabel.length + 2 },
|
|
627236
627370
|
// +2 for spaces
|
|
627237
627371
|
{ cmd: "model", label: modelLabel, w: modelLabel.length + 2 },
|
|
627238
627372
|
// +2 for spaces
|
|
@@ -627335,7 +627469,7 @@ var init_status_bar = __esm({
|
|
|
627335
627469
|
w: telegramLabel.length + 2
|
|
627336
627470
|
});
|
|
627337
627471
|
const liveMediaActive = this._liveMediaStatus.audio || this._liveMediaStatus.video;
|
|
627338
|
-
const liveMediaDot = liveMediaActive ? "●" : "○";
|
|
627472
|
+
const liveMediaDot = liveMediaActive ? Math.floor(Date.now() / 500) % 2 === 0 ? "●" : "○" : "○";
|
|
627339
627473
|
const liveMediaLabel = liveMediaActive ? ` ${this._liveMediaStatus.audio ? "aud" : ""}${this._liveMediaStatus.audio && this._liveMediaStatus.video ? "+" : ""}${this._liveMediaStatus.video ? "vid" : ""} ` : " av ";
|
|
627340
627474
|
sysItems.push({
|
|
627341
627475
|
render: () => renderBtn("live", `${liveMediaDot}${liveMediaLabel}`) + " ",
|
|
@@ -631954,7 +632088,7 @@ __export(personaplex_exports, {
|
|
|
631954
632088
|
startPersonaPlexDaemon: () => startPersonaPlexDaemon,
|
|
631955
632089
|
stopPersonaPlex: () => stopPersonaPlex
|
|
631956
632090
|
});
|
|
631957
|
-
import { existsSync as
|
|
632091
|
+
import { existsSync as existsSync125, writeFileSync as writeFileSync65, readFileSync as readFileSync103, mkdirSync as mkdirSync77, copyFileSync as copyFileSync5, readdirSync as readdirSync41, statSync as statSync48 } from "node:fs";
|
|
631958
632092
|
import { join as join140, dirname as dirname43 } from "node:path";
|
|
631959
632093
|
import { homedir as homedir45 } from "node:os";
|
|
631960
632094
|
import { spawn as spawn33 } from "node:child_process";
|
|
@@ -632069,7 +632203,7 @@ function fileLink2(filePath, label) {
|
|
|
632069
632203
|
return `\x1B]8;;${url}\x1B\\${text2}\x1B]8;;\x1B\\`;
|
|
632070
632204
|
}
|
|
632071
632205
|
async function isPersonaPlexRunning() {
|
|
632072
|
-
if (!
|
|
632206
|
+
if (!existsSync125(PID_FILE)) return false;
|
|
632073
632207
|
const pid = parseInt(readFileSync103(PID_FILE, "utf8").trim(), 10);
|
|
632074
632208
|
if (isNaN(pid) || pid <= 0) return false;
|
|
632075
632209
|
try {
|
|
@@ -632081,17 +632215,17 @@ async function isPersonaPlexRunning() {
|
|
|
632081
632215
|
}
|
|
632082
632216
|
async function getPersonaPlexWSUrl() {
|
|
632083
632217
|
if (!await isPersonaPlexRunning()) return null;
|
|
632084
|
-
if (!
|
|
632218
|
+
if (!existsSync125(PORT_FILE)) return null;
|
|
632085
632219
|
const port = parseInt(readFileSync103(PORT_FILE, "utf8").trim(), 10);
|
|
632086
632220
|
return isNaN(port) ? null : `wss://127.0.0.1:${port}`;
|
|
632087
632221
|
}
|
|
632088
632222
|
function isPersonaPlexInstalled() {
|
|
632089
|
-
return
|
|
632223
|
+
return existsSync125(join140(PERSONAPLEX_DIR, "model_ready"));
|
|
632090
632224
|
}
|
|
632091
632225
|
async function getWeightTier() {
|
|
632092
632226
|
const detected = await detectPersonaPlexCapability();
|
|
632093
632227
|
const tierFile = join140(PERSONAPLEX_DIR, "weight_tier");
|
|
632094
|
-
if (
|
|
632228
|
+
if (existsSync125(tierFile)) {
|
|
632095
632229
|
const saved = readFileSync103(tierFile, "utf8").trim();
|
|
632096
632230
|
if (saved in WEIGHT_REPOS) {
|
|
632097
632231
|
const vram = detected.vramGB;
|
|
@@ -632111,15 +632245,15 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
632111
632245
|
const log22 = onInfo ?? (() => {
|
|
632112
632246
|
});
|
|
632113
632247
|
mkdirSync77(PERSONAPLEX_DIR, { recursive: true });
|
|
632114
|
-
let
|
|
632248
|
+
let arch4 = "";
|
|
632115
632249
|
try {
|
|
632116
|
-
|
|
632250
|
+
arch4 = (await execAsync("uname -m", { timeout: 3e3 })).trim();
|
|
632117
632251
|
} catch {
|
|
632118
632252
|
}
|
|
632119
|
-
const isAarch64 =
|
|
632120
|
-
if (isAarch64) log22(`Detected ARM64 platform (${
|
|
632253
|
+
const isAarch64 = arch4 === "aarch64" || arch4 === "arm64";
|
|
632254
|
+
if (isAarch64) log22(`Detected ARM64 platform (${arch4}) — Jetson/ARM install path`);
|
|
632121
632255
|
const venvDir = join140(PERSONAPLEX_DIR, "venv");
|
|
632122
|
-
if (!
|
|
632256
|
+
if (!existsSync125(venvDir)) {
|
|
632123
632257
|
log22("Creating Python virtual environment...");
|
|
632124
632258
|
try {
|
|
632125
632259
|
const ssp = isAarch64 ? " --system-site-packages" : "";
|
|
@@ -632162,7 +632296,7 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
632162
632296
|
log22("Installing PersonaPlex (moshi package)...");
|
|
632163
632297
|
const repoDir = join140(PERSONAPLEX_DIR, "personaplex-repo");
|
|
632164
632298
|
try {
|
|
632165
|
-
if (!
|
|
632299
|
+
if (!existsSync125(repoDir)) {
|
|
632166
632300
|
await execAsync(
|
|
632167
632301
|
`git clone https://github.com/NVIDIA/personaplex.git "${repoDir}"`,
|
|
632168
632302
|
{ timeout: 12e4 }
|
|
@@ -632221,7 +632355,7 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
632221
632355
|
env: personaplexPythonEnv()
|
|
632222
632356
|
})).trim();
|
|
632223
632357
|
const serverFile = join140(sitePackages, "server.py");
|
|
632224
|
-
if (
|
|
632358
|
+
if (existsSync125(serverFile)) {
|
|
632225
632359
|
let src2 = readFileSync103(serverFile, "utf8");
|
|
632226
632360
|
if (src2.includes('int(request["seed"])')) {
|
|
632227
632361
|
src2 = src2.replace('int(request["seed"])', 'int(request.query["seed"])');
|
|
@@ -632237,7 +632371,7 @@ async function installPersonaPlex(onInfo, weightTier) {
|
|
|
632237
632371
|
env: personaplexPythonEnv()
|
|
632238
632372
|
})).trim();
|
|
632239
632373
|
const loadersFile = join140(sitePackages, "models", "loaders.py");
|
|
632240
|
-
if (
|
|
632374
|
+
if (existsSync125(loadersFile)) {
|
|
632241
632375
|
let src2 = readFileSync103(loadersFile, "utf8");
|
|
632242
632376
|
if (!src2.includes("_dequantize_2bit_state_dict")) {
|
|
632243
632377
|
const dequantPatch = `
|
|
@@ -632341,14 +632475,14 @@ $2if filename.endswith(".safetensors"):`
|
|
|
632341
632475
|
})).trim();
|
|
632342
632476
|
const hybridDest = join140(sitePackages2, "hybrid_agent.py");
|
|
632343
632477
|
const serverDest = join140(sitePackages2, "server.py");
|
|
632344
|
-
if (!
|
|
632478
|
+
if (!existsSync125(hybridDest) || !readFileSync103(hybridDest, "utf8").includes("OMNIUS_API_BASE")) {
|
|
632345
632479
|
log22("Deploying hybrid_agent.py (Omnius API integration)...");
|
|
632346
632480
|
try {
|
|
632347
632481
|
await execAsync(
|
|
632348
632482
|
`curl -sL "https://raw.githubusercontent.com/robit-man/personaplex/main/personaplex-setup/moshi/moshi/hybrid_agent.py" -o "${hybridDest}"`,
|
|
632349
632483
|
{ timeout: 3e4 }
|
|
632350
632484
|
);
|
|
632351
|
-
if (
|
|
632485
|
+
if (existsSync125(hybridDest) && readFileSync103(hybridDest, "utf8").includes("OMNIUS_API_BASE")) {
|
|
632352
632486
|
log22("hybrid_agent.py deployed (Omnius API + Ollama fallback).");
|
|
632353
632487
|
}
|
|
632354
632488
|
} catch {
|
|
@@ -632473,8 +632607,8 @@ async function startPersonaPlexDaemon(onInfo) {
|
|
|
632473
632607
|
`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', '${repoInfo.file}', token=False))"`,
|
|
632474
632608
|
{ timeout: 6e4, env: personaplexPythonEnv() }
|
|
632475
632609
|
)).trim();
|
|
632476
|
-
if (
|
|
632477
|
-
if (!
|
|
632610
|
+
if (existsSync125(weightPath)) {
|
|
632611
|
+
if (!existsSync125(cachedBf16)) {
|
|
632478
632612
|
log22("Converting .pt checkpoint to safetensors (one-time)...");
|
|
632479
632613
|
await execAsync(
|
|
632480
632614
|
`"${venvPython2}" -c "
|
|
@@ -632487,7 +632621,7 @@ print('Converted')
|
|
|
632487
632621
|
{ timeout: 18e4, env: personaplexPythonEnv() }
|
|
632488
632622
|
);
|
|
632489
632623
|
}
|
|
632490
|
-
if (
|
|
632624
|
+
if (existsSync125(cachedBf16)) {
|
|
632491
632625
|
extraArgs.push("--moshi-weight", cachedBf16);
|
|
632492
632626
|
log22(`Using distilled weights: ${(statSync48(cachedBf16).size / 1024 ** 3).toFixed(1)}GB`);
|
|
632493
632627
|
} else {
|
|
@@ -632500,11 +632634,11 @@ print('Converted')
|
|
|
632500
632634
|
} else {
|
|
632501
632635
|
log22(`Weight tier: ${tier} (${repoInfo.sizeGB}GB) — dequantizing to bf16 cache...`);
|
|
632502
632636
|
const dequantScript = join140(PERSONAPLEX_DIR, "dequant-loader.py");
|
|
632503
|
-
if (!
|
|
632637
|
+
if (!existsSync125(dequantScript)) {
|
|
632504
632638
|
const shipped = getShippedVoicesDir();
|
|
632505
632639
|
if (shipped) {
|
|
632506
632640
|
const src2 = join140(shipped, "dequant-loader.py");
|
|
632507
|
-
if (
|
|
632641
|
+
if (existsSync125(src2)) copyFileSync5(src2, dequantScript);
|
|
632508
632642
|
}
|
|
632509
632643
|
}
|
|
632510
632644
|
try {
|
|
@@ -632512,13 +632646,13 @@ print('Converted')
|
|
|
632512
632646
|
`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', '${repoInfo.file}'${repoInfo.needsToken ? "" : ", token=False"}))"`,
|
|
632513
632647
|
{ timeout: 3e4, env: personaplexPythonEnv() }
|
|
632514
632648
|
)).trim();
|
|
632515
|
-
if (
|
|
632649
|
+
if (existsSync125(dequantScript) && existsSync125(weightPath)) {
|
|
632516
632650
|
try {
|
|
632517
632651
|
await execAsync(
|
|
632518
632652
|
`"${venvPython2}" "${dequantScript}" --input "${weightPath}" --output "${cachedBf16}"`,
|
|
632519
632653
|
{ timeout: 3e5, env: personaplexPythonEnv() }
|
|
632520
632654
|
);
|
|
632521
|
-
if (
|
|
632655
|
+
if (existsSync125(cachedBf16)) {
|
|
632522
632656
|
extraArgs.push("--moshi-weight", cachedBf16);
|
|
632523
632657
|
log22(`Using dequantized cache: ${(statSync48(cachedBf16).size / 1024 ** 3).toFixed(1)}GB`);
|
|
632524
632658
|
}
|
|
@@ -632531,7 +632665,7 @@ print('Converted')
|
|
|
632531
632665
|
`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', 'tokenizer-e351c8d8-checkpoint125.safetensors', token=False))"`,
|
|
632532
632666
|
{ timeout: 3e4, env: personaplexPythonEnv() }
|
|
632533
632667
|
)).trim();
|
|
632534
|
-
if (
|
|
632668
|
+
if (existsSync125(mimiPath)) extraArgs.push("--mimi-weight", mimiPath);
|
|
632535
632669
|
} catch {
|
|
632536
632670
|
}
|
|
632537
632671
|
try {
|
|
@@ -632539,7 +632673,7 @@ print('Converted')
|
|
|
632539
632673
|
`"${venvPython2}" -c "from huggingface_hub import hf_hub_download; print(hf_hub_download('${repoInfo.repo}', 'tokenizer_spm_32k_3.model', token=False))"`,
|
|
632540
632674
|
{ timeout: 3e4, env: personaplexPythonEnv() }
|
|
632541
632675
|
)).trim();
|
|
632542
|
-
if (
|
|
632676
|
+
if (existsSync125(tokPath)) extraArgs.push("--tokenizer", tokPath);
|
|
632543
632677
|
} catch {
|
|
632544
632678
|
}
|
|
632545
632679
|
} catch {
|
|
@@ -632646,7 +632780,7 @@ print('Converted')
|
|
|
632646
632780
|
return null;
|
|
632647
632781
|
}
|
|
632648
632782
|
async function stopPersonaPlex() {
|
|
632649
|
-
if (!
|
|
632783
|
+
if (!existsSync125(PID_FILE)) return;
|
|
632650
632784
|
const pid = parseInt(readFileSync103(PID_FILE, "utf8").trim(), 10);
|
|
632651
632785
|
if (isNaN(pid) || pid <= 0) return;
|
|
632652
632786
|
try {
|
|
@@ -632683,7 +632817,7 @@ function listPersonaPlexVoices() {
|
|
|
632683
632817
|
for (const name10 of builtins) {
|
|
632684
632818
|
voices.push({ name: name10, type: "builtin", path: `${name10}.pt` });
|
|
632685
632819
|
}
|
|
632686
|
-
if (
|
|
632820
|
+
if (existsSync125(CUSTOM_VOICES_DIR)) {
|
|
632687
632821
|
try {
|
|
632688
632822
|
for (const f2 of readdirSync41(CUSTOM_VOICES_DIR)) {
|
|
632689
632823
|
if (f2.endsWith(".pt")) {
|
|
@@ -632703,19 +632837,19 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
|
|
|
632703
632837
|
log22("PersonaPlex not installed. Run /voice personaplex first.");
|
|
632704
632838
|
return null;
|
|
632705
632839
|
}
|
|
632706
|
-
if (!
|
|
632840
|
+
if (!existsSync125(inputWav)) {
|
|
632707
632841
|
log22(`Input WAV not found: ${inputWav}`);
|
|
632708
632842
|
return null;
|
|
632709
632843
|
}
|
|
632710
632844
|
mkdirSync77(CUSTOM_VOICES_DIR, { recursive: true });
|
|
632711
632845
|
const outputPt = join140(CUSTOM_VOICES_DIR, `${voiceName}.pt`);
|
|
632712
|
-
if (
|
|
632846
|
+
if (existsSync125(outputPt)) {
|
|
632713
632847
|
log22(`Voice "${voiceName}" already exists. Delete ${outputPt} to re-clone.`);
|
|
632714
632848
|
return outputPt;
|
|
632715
632849
|
}
|
|
632716
632850
|
const venvPython2 = process.platform === "win32" ? join140(PERSONAPLEX_DIR, "venv", "Scripts", "python.exe") : join140(PERSONAPLEX_DIR, "venv", "bin", "python3");
|
|
632717
632851
|
const cloneScript = join140(PERSONAPLEX_DIR, "clone-voice.py");
|
|
632718
|
-
if (!
|
|
632852
|
+
if (!existsSync125(cloneScript)) {
|
|
632719
632853
|
log22("clone-voice.py not found. Reinstall PersonaPlex.");
|
|
632720
632854
|
return null;
|
|
632721
632855
|
}
|
|
@@ -632747,7 +632881,7 @@ async function clonePersonaPlexVoice(inputWav, voiceName, onInfo) {
|
|
|
632747
632881
|
output += d2.toString();
|
|
632748
632882
|
});
|
|
632749
632883
|
onChildClose(child, (code8) => {
|
|
632750
|
-
if (code8 === 0 &&
|
|
632884
|
+
if (code8 === 0 && existsSync125(outputPt)) {
|
|
632751
632885
|
log22(`Voice "${voiceName}" cloned successfully.`);
|
|
632752
632886
|
resolve76(outputPt);
|
|
632753
632887
|
} else {
|
|
@@ -632771,7 +632905,7 @@ function getShippedVoicesDir() {
|
|
|
632771
632905
|
} catch {
|
|
632772
632906
|
}
|
|
632773
632907
|
for (const dir of candidates) {
|
|
632774
|
-
if (
|
|
632908
|
+
if (existsSync125(dir)) {
|
|
632775
632909
|
try {
|
|
632776
632910
|
const files = readdirSync41(dir);
|
|
632777
632911
|
if (files.some((f2) => f2.endsWith(".pt"))) return dir;
|
|
@@ -632793,12 +632927,12 @@ function provisionShippedVoices(onInfo) {
|
|
|
632793
632927
|
for (const f2 of readdirSync41(shippedDir)) {
|
|
632794
632928
|
if (!f2.endsWith(".pt")) continue;
|
|
632795
632929
|
const customDst = join140(CUSTOM_VOICES_DIR, f2);
|
|
632796
|
-
if (!
|
|
632930
|
+
if (!existsSync125(customDst)) {
|
|
632797
632931
|
copyFileSync5(join140(shippedDir, f2), customDst);
|
|
632798
632932
|
}
|
|
632799
632933
|
if (hfVoicesDir) {
|
|
632800
632934
|
const hfDst = join140(hfVoicesDir, f2);
|
|
632801
|
-
if (!
|
|
632935
|
+
if (!existsSync125(hfDst)) {
|
|
632802
632936
|
copyFileSync5(join140(shippedDir, f2), hfDst);
|
|
632803
632937
|
log22(`Deployed voice: ${f2.replace(".pt", "")}`);
|
|
632804
632938
|
deployed++;
|
|
@@ -632809,7 +632943,7 @@ function provisionShippedVoices(onInfo) {
|
|
|
632809
632943
|
}
|
|
632810
632944
|
const shippedScript = join140(shippedDir, "clone-voice.py");
|
|
632811
632945
|
const targetScript = join140(PERSONAPLEX_DIR, "clone-voice.py");
|
|
632812
|
-
if (
|
|
632946
|
+
if (existsSync125(shippedScript) && !existsSync125(targetScript)) {
|
|
632813
632947
|
try {
|
|
632814
632948
|
copyFileSync5(shippedScript, targetScript);
|
|
632815
632949
|
} catch {
|
|
@@ -632819,13 +632953,13 @@ function provisionShippedVoices(onInfo) {
|
|
|
632819
632953
|
}
|
|
632820
632954
|
function getHFVoicesDir() {
|
|
632821
632955
|
const hfBase = join140(homedir45(), ".cache", "huggingface", "hub", "models--nvidia--personaplex-7b-v1");
|
|
632822
|
-
if (!
|
|
632956
|
+
if (!existsSync125(hfBase)) return null;
|
|
632823
632957
|
try {
|
|
632824
632958
|
const snapshots = join140(hfBase, "snapshots");
|
|
632825
|
-
if (!
|
|
632959
|
+
if (!existsSync125(snapshots)) return null;
|
|
632826
632960
|
for (const snap of readdirSync41(snapshots)) {
|
|
632827
632961
|
const voicesDir = join140(snapshots, snap, "voices");
|
|
632828
|
-
if (
|
|
632962
|
+
if (existsSync125(voicesDir)) return voicesDir;
|
|
632829
632963
|
}
|
|
632830
632964
|
} catch {
|
|
632831
632965
|
}
|
|
@@ -632835,18 +632969,18 @@ function patchFrontendVoiceList(onInfo) {
|
|
|
632835
632969
|
const log22 = onInfo ?? (() => {
|
|
632836
632970
|
});
|
|
632837
632971
|
const hfBase = join140(homedir45(), ".cache", "huggingface", "hub", "models--nvidia--personaplex-7b-v1");
|
|
632838
|
-
if (!
|
|
632972
|
+
if (!existsSync125(hfBase)) return;
|
|
632839
632973
|
try {
|
|
632840
632974
|
const snapshots = join140(hfBase, "snapshots");
|
|
632841
632975
|
for (const snap of readdirSync41(snapshots)) {
|
|
632842
632976
|
const distDir = join140(snapshots, snap, "dist", "assets");
|
|
632843
|
-
if (!
|
|
632977
|
+
if (!existsSync125(distDir)) continue;
|
|
632844
632978
|
for (const f2 of readdirSync41(distDir)) {
|
|
632845
632979
|
if (!f2.startsWith("index-") || !f2.endsWith(".js")) continue;
|
|
632846
632980
|
const jsPath = join140(distDir, f2);
|
|
632847
632981
|
let js = readFileSync103(jsPath, "utf8");
|
|
632848
632982
|
const customVoices = [];
|
|
632849
|
-
if (
|
|
632983
|
+
if (existsSync125(CUSTOM_VOICES_DIR)) {
|
|
632850
632984
|
for (const vf of readdirSync41(CUSTOM_VOICES_DIR)) {
|
|
632851
632985
|
if (vf.endsWith(".pt")) {
|
|
632852
632986
|
const name10 = vf.replace(".pt", "");
|
|
@@ -632964,9 +633098,9 @@ __export(setup_exports, {
|
|
|
632964
633098
|
import * as readline from "node:readline";
|
|
632965
633099
|
import { spawn as spawn34, exec as exec5 } from "node:child_process";
|
|
632966
633100
|
import { promisify as promisify7 } from "node:util";
|
|
632967
|
-
import { existsSync as
|
|
633101
|
+
import { existsSync as existsSync126, writeFileSync as writeFileSync66, readFileSync as readFileSync104, appendFileSync as appendFileSync14, mkdirSync as mkdirSync78, chmodSync as chmodSync3 } from "node:fs";
|
|
632968
633102
|
import { delimiter as pathDelimiter, join as join141 } from "node:path";
|
|
632969
|
-
import { freemem as
|
|
633103
|
+
import { freemem as freemem7, homedir as homedir46, platform as platform5, totalmem as totalmem8 } from "node:os";
|
|
632970
633104
|
function wrapText2(value2, width) {
|
|
632971
633105
|
const words = value2.split(/\s+/).filter(Boolean);
|
|
632972
633106
|
const lines = [];
|
|
@@ -633015,18 +633149,18 @@ function detectUnifiedMemory(hasDiscreteGpu = false) {
|
|
|
633015
633149
|
if (process.platform === "darwin" && process.arch === "arm64") return true;
|
|
633016
633150
|
if (process.platform === "linux") {
|
|
633017
633151
|
try {
|
|
633018
|
-
if (
|
|
633152
|
+
if (existsSync126("/etc/nv_tegra_release")) return true;
|
|
633019
633153
|
} catch {
|
|
633020
633154
|
}
|
|
633021
633155
|
try {
|
|
633022
|
-
if (
|
|
633156
|
+
if (existsSync126("/sys/devices/soc0/family")) {
|
|
633023
633157
|
const family = readFileSync104("/sys/devices/soc0/family", "utf8").trim().toLowerCase();
|
|
633024
633158
|
if (family.includes("tegra")) return true;
|
|
633025
633159
|
}
|
|
633026
633160
|
} catch {
|
|
633027
633161
|
}
|
|
633028
633162
|
try {
|
|
633029
|
-
if (
|
|
633163
|
+
if (existsSync126("/proc/device-tree/model")) {
|
|
633030
633164
|
const model = readFileSync104("/proc/device-tree/model", "utf8").replace(/\0+$/, "").toLowerCase();
|
|
633031
633165
|
if (/jetson|tegra|orin|xavier|nano|raspberry|rockchip|rk\d{4}|mt\d{4}/.test(model)) {
|
|
633032
633166
|
return true;
|
|
@@ -633080,7 +633214,7 @@ function parseRocmSmi(stdout) {
|
|
|
633080
633214
|
}
|
|
633081
633215
|
function detectSystemSpecs() {
|
|
633082
633216
|
let totalRamGB = totalmem8() / 1024 ** 3;
|
|
633083
|
-
let availableRamGB =
|
|
633217
|
+
let availableRamGB = freemem7() / 1024 ** 3;
|
|
633084
633218
|
let gpuVramGB = 0;
|
|
633085
633219
|
let availableVramGB = 0;
|
|
633086
633220
|
const gpuName = "";
|
|
@@ -633438,7 +633572,7 @@ function detectAskpassHelper() {
|
|
|
633438
633572
|
if (process.platform === "linux") {
|
|
633439
633573
|
for (const path12 of linuxHelpers) {
|
|
633440
633574
|
try {
|
|
633441
|
-
if (
|
|
633575
|
+
if (existsSync126(path12)) return path12;
|
|
633442
633576
|
} catch {
|
|
633443
633577
|
}
|
|
633444
633578
|
}
|
|
@@ -633717,7 +633851,7 @@ async function installOllamaMac(_rl) {
|
|
|
633717
633851
|
);
|
|
633718
633852
|
if (!hasCmd("brew")) {
|
|
633719
633853
|
try {
|
|
633720
|
-
const brewPrefix =
|
|
633854
|
+
const brewPrefix = existsSync126("/opt/homebrew/bin/brew") ? "/opt/homebrew" : "/usr/local";
|
|
633721
633855
|
process.env["PATH"] = `${brewPrefix}/bin:${process.env["PATH"]}`;
|
|
633722
633856
|
} catch {
|
|
633723
633857
|
}
|
|
@@ -634751,7 +634885,7 @@ async function isModelAvailable(config) {
|
|
|
634751
634885
|
}
|
|
634752
634886
|
function isFirstRun() {
|
|
634753
634887
|
try {
|
|
634754
|
-
return !
|
|
634888
|
+
return !existsSync126(join141(homedir46(), ".omnius", "config.json"));
|
|
634755
634889
|
} catch {
|
|
634756
634890
|
return true;
|
|
634757
634891
|
}
|
|
@@ -634762,7 +634896,7 @@ function hasCmd(cmd) {
|
|
|
634762
634896
|
function findCommandPath(cmd) {
|
|
634763
634897
|
if (!cmd) return null;
|
|
634764
634898
|
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
634765
|
-
return
|
|
634899
|
+
return existsSync126(cmd) ? cmd : null;
|
|
634766
634900
|
}
|
|
634767
634901
|
const pathValue = process.env.PATH || "";
|
|
634768
634902
|
const dirs = pathValue.split(pathDelimiter).filter(Boolean);
|
|
@@ -634770,7 +634904,7 @@ function findCommandPath(cmd) {
|
|
|
634770
634904
|
for (const dir of dirs) {
|
|
634771
634905
|
for (const ext of extensions) {
|
|
634772
634906
|
const candidate = join141(dir, process.platform === "win32" ? cmd + ext : cmd);
|
|
634773
|
-
if (
|
|
634907
|
+
if (existsSync126(candidate)) return candidate;
|
|
634774
634908
|
}
|
|
634775
634909
|
}
|
|
634776
634910
|
return null;
|
|
@@ -634825,7 +634959,7 @@ async function ensureVenv2(log22) {
|
|
|
634825
634959
|
const pipPath = isWin2 ? join141(venvDir, "Scripts", "pip.exe") : join141(venvDir, "bin", "pip");
|
|
634826
634960
|
const venvPyPath = isWin2 ? join141(venvDir, "Scripts", "python.exe") : join141(venvDir, "bin", "python3");
|
|
634827
634961
|
const pythonCmd = isWin2 ? "python" : "python3";
|
|
634828
|
-
if (
|
|
634962
|
+
if (existsSync126(pipPath)) {
|
|
634829
634963
|
try {
|
|
634830
634964
|
await runShellCommandAsync(`"${venvPyPath}" -m pip --version`, { timeoutMs: 1e4 });
|
|
634831
634965
|
return venvDir;
|
|
@@ -634980,7 +635114,7 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
634980
635114
|
const _visionMarkerFile = join141(_visionMarkerDir, "vision-deps-installed.json");
|
|
634981
635115
|
let _visionPreviouslyInstalled = /* @__PURE__ */ new Set();
|
|
634982
635116
|
try {
|
|
634983
|
-
if (
|
|
635117
|
+
if (existsSync126(_visionMarkerFile)) {
|
|
634984
635118
|
const _vm = JSON.parse(readFileSync104(_visionMarkerFile, "utf8"));
|
|
634985
635119
|
_visionPreviouslyInstalled = new Set(_vm.installed || []);
|
|
634986
635120
|
}
|
|
@@ -635152,12 +635286,12 @@ async function ensureVisionDeps(onInfo, getSudoPassword) {
|
|
|
635152
635286
|
const venvBin = join141(venvDir, isWin2 ? "Scripts" : "bin");
|
|
635153
635287
|
const venvMoondream = join141(venvBin, isWin2 ? "moondream-station.exe" : "moondream-station");
|
|
635154
635288
|
const venv = await ensureVenv2(log22);
|
|
635155
|
-
if (venv && !hasCmd("moondream-station") && !
|
|
635289
|
+
if (venv && !hasCmd("moondream-station") && !existsSync126(venvMoondream)) {
|
|
635156
635290
|
const venvPip2 = join141(venvBin, "pip");
|
|
635157
635291
|
log22("Installing moondream-station in ~/.omnius/venv...");
|
|
635158
635292
|
try {
|
|
635159
635293
|
await runShellCommandAsync(`"${venvPip2}" install moondream-station`, { timeoutMs: 3e5 });
|
|
635160
|
-
if (
|
|
635294
|
+
if (existsSync126(venvMoondream)) {
|
|
635161
635295
|
log22("moondream-station installed successfully.");
|
|
635162
635296
|
} else {
|
|
635163
635297
|
try {
|
|
@@ -635220,7 +635354,7 @@ function ensureCloudflaredBackground(onInfo) {
|
|
|
635220
635354
|
});
|
|
635221
635355
|
log22("Installing cloudflared for live voice sessions...");
|
|
635222
635356
|
_cloudflaredInstallPromise = (async () => {
|
|
635223
|
-
const
|
|
635357
|
+
const arch4 = process.arch;
|
|
635224
635358
|
const os9 = platform5();
|
|
635225
635359
|
if (os9 !== "win32" && !await ensureCurl()) {
|
|
635226
635360
|
log22("curl not available — cannot install cloudflared.");
|
|
@@ -635228,7 +635362,7 @@ function ensureCloudflaredBackground(onInfo) {
|
|
|
635228
635362
|
}
|
|
635229
635363
|
if (os9 === "linux") {
|
|
635230
635364
|
const archMap = { x64: "amd64", arm64: "arm64", arm: "arm" };
|
|
635231
|
-
const cfArch = archMap[
|
|
635365
|
+
const cfArch = archMap[arch4] ?? "amd64";
|
|
635232
635366
|
try {
|
|
635233
635367
|
await runShellCommandAsync(
|
|
635234
635368
|
`curl -fsSL "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${cfArch}" -o /tmp/cloudflared && chmod +x /tmp/cloudflared && mkdir -p "${homedir46()}/.local/bin" && mv /tmp/cloudflared "${homedir46()}/.local/bin/cloudflared"`,
|
|
@@ -635339,8 +635473,8 @@ function modelSizeGB(models, modelName) {
|
|
|
635339
635473
|
const known = QWEN_VARIANTS.find((v) => modelName.includes(v.tag.split(":")[1] ?? ""));
|
|
635340
635474
|
return known?.sizeGB ?? 4;
|
|
635341
635475
|
}
|
|
635342
|
-
function defaultLayersForArch(
|
|
635343
|
-
const a2 =
|
|
635476
|
+
function defaultLayersForArch(arch4) {
|
|
635477
|
+
const a2 = arch4.toLowerCase();
|
|
635344
635478
|
if (a2.includes("qwen")) return 36;
|
|
635345
635479
|
if (a2.includes("llama")) return 32;
|
|
635346
635480
|
if (a2.includes("mistral")) return 32;
|
|
@@ -635363,17 +635497,17 @@ async function queryModelKVInfo(backendUrl2, modelName) {
|
|
|
635363
635497
|
const data = await res.json();
|
|
635364
635498
|
if (!data.model_info) return null;
|
|
635365
635499
|
const info = data.model_info;
|
|
635366
|
-
const
|
|
635367
|
-
if (!
|
|
635368
|
-
const nLayersRaw = info[`${
|
|
635369
|
-
const nKVHeadsRaw = info[`${
|
|
635370
|
-
const keyDimRaw = info[`${
|
|
635371
|
-
const valDimRaw = info[`${
|
|
635372
|
-
const archMax = info[`${
|
|
635500
|
+
const arch4 = info["general.architecture"];
|
|
635501
|
+
if (!arch4) return null;
|
|
635502
|
+
const nLayersRaw = info[`${arch4}.block_count`];
|
|
635503
|
+
const nKVHeadsRaw = info[`${arch4}.attention.head_count_kv`];
|
|
635504
|
+
const keyDimRaw = info[`${arch4}.attention.key_length`];
|
|
635505
|
+
const valDimRaw = info[`${arch4}.attention.value_length`] ?? keyDimRaw;
|
|
635506
|
+
const archMax = info[`${arch4}.context_length`];
|
|
635373
635507
|
if (!archMax) return null;
|
|
635374
635508
|
const keyDim = keyDimRaw ?? 128;
|
|
635375
635509
|
const valDim = valDimRaw ?? 128;
|
|
635376
|
-
const nLayers = nLayersRaw ?? defaultLayersForArch(
|
|
635510
|
+
const nLayers = nLayersRaw ?? defaultLayersForArch(arch4);
|
|
635377
635511
|
const nKVHeads = nKVHeadsRaw ?? 8;
|
|
635378
635512
|
if (!nLayers) return { archMax };
|
|
635379
635513
|
const kvBytesPerToken = nLayers * nKVHeads * (keyDim + valDim) * 2;
|
|
@@ -635725,7 +635859,7 @@ async function ensureNeovim() {
|
|
|
635725
635859
|
const existingNvim = findCommandPath("nvim");
|
|
635726
635860
|
if (existingNvim) return existingNvim;
|
|
635727
635861
|
const platform7 = process.platform;
|
|
635728
|
-
const
|
|
635862
|
+
const arch4 = process.arch;
|
|
635729
635863
|
if (platform7 === "linux") {
|
|
635730
635864
|
const binDir = join141(homedir46(), ".local", "bin");
|
|
635731
635865
|
const nvimDest = join141(binDir, "nvim");
|
|
@@ -635733,7 +635867,7 @@ async function ensureNeovim() {
|
|
|
635733
635867
|
mkdirSync78(binDir, { recursive: true });
|
|
635734
635868
|
} catch {
|
|
635735
635869
|
}
|
|
635736
|
-
const appImageName =
|
|
635870
|
+
const appImageName = arch4 === "arm64" ? "nvim-linux-arm64.appimage" : "nvim-linux-x86_64.appimage";
|
|
635737
635871
|
const url = `https://github.com/neovim/neovim/releases/latest/download/${appImageName}`;
|
|
635738
635872
|
console.log(` Downloading Neovim (${appImageName})...`);
|
|
635739
635873
|
try {
|
|
@@ -635813,7 +635947,7 @@ function ensurePathInShellRc(binDir) {
|
|
|
635813
635947
|
const shell = process.env.SHELL ?? "";
|
|
635814
635948
|
const rcFile = shell.includes("zsh") ? join141(homedir46(), ".zshrc") : join141(homedir46(), ".bashrc");
|
|
635815
635949
|
try {
|
|
635816
|
-
const rcContent =
|
|
635950
|
+
const rcContent = existsSync126(rcFile) ? readFileSync104(rcFile, "utf8") : "";
|
|
635817
635951
|
if (rcContent.includes(binDir)) return;
|
|
635818
635952
|
const exportLine = `
|
|
635819
635953
|
export PATH="${binDir}:$PATH" # Added by omnius for nvim
|
|
@@ -636025,7 +636159,7 @@ var init_registry3 = __esm({
|
|
|
636025
636159
|
});
|
|
636026
636160
|
|
|
636027
636161
|
// packages/cli/src/tui/media-routing.ts
|
|
636028
|
-
import { existsSync as
|
|
636162
|
+
import { existsSync as existsSync127 } from "node:fs";
|
|
636029
636163
|
import { homedir as homedir47 } from "node:os";
|
|
636030
636164
|
function extractMediaReferences(text2) {
|
|
636031
636165
|
const masked = maskCode(text2);
|
|
@@ -636158,7 +636292,7 @@ function looksLikeLocalMedia(value2) {
|
|
|
636158
636292
|
if (!value2.startsWith("/") && !value2.startsWith("~/")) return false;
|
|
636159
636293
|
const expanded = expandHome2(value2);
|
|
636160
636294
|
const kind = classifyMedia(expanded);
|
|
636161
|
-
return !!kind && (
|
|
636295
|
+
return !!kind && (existsSync127(expanded) || value2.startsWith("~/") || value2.startsWith("/"));
|
|
636162
636296
|
}
|
|
636163
636297
|
function expandHome2(value2) {
|
|
636164
636298
|
return value2.startsWith("~/") ? `${homedir47()}${value2.slice(1)}` : value2;
|
|
@@ -636593,7 +636727,7 @@ var init_platforms = __esm({
|
|
|
636593
636727
|
});
|
|
636594
636728
|
|
|
636595
636729
|
// packages/cli/src/tui/workspace-explorer.ts
|
|
636596
|
-
import { existsSync as
|
|
636730
|
+
import { existsSync as existsSync128, readdirSync as readdirSync42, readFileSync as readFileSync105, statSync as statSync49 } from "node:fs";
|
|
636597
636731
|
import { basename as basename27, extname as extname17, join as join142, relative as relative14, resolve as resolve59 } from "node:path";
|
|
636598
636732
|
function exploreWorkspace(root, options2 = {}) {
|
|
636599
636733
|
const query = (options2.query ?? "").trim().toLowerCase();
|
|
@@ -636681,7 +636815,7 @@ function previewWorkspaceFile(root, relPath, options2 = {}) {
|
|
|
636681
636815
|
if (!full.startsWith(rootResolved + "/") && full !== rootResolved) {
|
|
636682
636816
|
throw new Error("File path escapes workspace root");
|
|
636683
636817
|
}
|
|
636684
|
-
if (!
|
|
636818
|
+
if (!existsSync128(full)) throw new Error(`File not found: ${relPath}`);
|
|
636685
636819
|
const st = statSync49(full);
|
|
636686
636820
|
if (!st.isFile()) throw new Error(`Not a file: ${relPath}`);
|
|
636687
636821
|
if (st.size > maxBytes) {
|
|
@@ -636868,7 +637002,7 @@ var init_pricing = __esm({
|
|
|
636868
637002
|
});
|
|
636869
637003
|
|
|
636870
637004
|
// packages/cli/src/insights/engine.ts
|
|
636871
|
-
import { readdirSync as readdirSync43, readFileSync as readFileSync106, existsSync as
|
|
637005
|
+
import { readdirSync as readdirSync43, readFileSync as readFileSync106, existsSync as existsSync129 } from "node:fs";
|
|
636872
637006
|
import { join as join143 } from "node:path";
|
|
636873
637007
|
function formatDuration5(seconds) {
|
|
636874
637008
|
if (seconds < 60) return `${Math.round(seconds)}s`;
|
|
@@ -636938,7 +637072,7 @@ var init_engine = __esm({
|
|
|
636938
637072
|
};
|
|
636939
637073
|
}
|
|
636940
637074
|
loadSessions(cutoff) {
|
|
636941
|
-
if (!
|
|
637075
|
+
if (!existsSync129(this.historyDir)) return [];
|
|
636942
637076
|
try {
|
|
636943
637077
|
return readdirSync43(this.historyDir).filter((f2) => f2.endsWith(".json") && f2 !== "pending-task.json").map((f2) => {
|
|
636944
637078
|
try {
|
|
@@ -636960,7 +637094,7 @@ var init_engine = __esm({
|
|
|
636960
637094
|
}
|
|
636961
637095
|
loadUsageStore() {
|
|
636962
637096
|
try {
|
|
636963
|
-
if (
|
|
637097
|
+
if (existsSync129(this.usageFile)) {
|
|
636964
637098
|
return JSON.parse(readFileSync106(this.usageFile, "utf-8"));
|
|
636965
637099
|
}
|
|
636966
637100
|
} catch {
|
|
@@ -637387,7 +637521,7 @@ var init_format = __esm({
|
|
|
637387
637521
|
});
|
|
637388
637522
|
|
|
637389
637523
|
// packages/cli/src/tui/drop-panel.ts
|
|
637390
|
-
import { existsSync as
|
|
637524
|
+
import { existsSync as existsSync130 } from "node:fs";
|
|
637391
637525
|
import { extname as extname18, resolve as resolve60 } from "node:path";
|
|
637392
637526
|
function ansi4(code8, text2) {
|
|
637393
637527
|
return isTTY4 ? `\x1B[${code8}m${text2}\x1B[0m` : text2;
|
|
@@ -637508,7 +637642,7 @@ function showDropPanel(opts) {
|
|
|
637508
637642
|
filePath = decodeURIComponent(filePath.slice(7));
|
|
637509
637643
|
}
|
|
637510
637644
|
filePath = resolve60(filePath);
|
|
637511
|
-
if (!
|
|
637645
|
+
if (!existsSync130(filePath)) {
|
|
637512
637646
|
errorMsg = `File not found: ${filePath}`;
|
|
637513
637647
|
render2();
|
|
637514
637648
|
return;
|
|
@@ -639861,7 +639995,7 @@ var init_audio_waveform = __esm({
|
|
|
639861
639995
|
});
|
|
639862
639996
|
|
|
639863
639997
|
// packages/cli/src/tui/neovim-mode.ts
|
|
639864
|
-
import { existsSync as
|
|
639998
|
+
import { existsSync as existsSync132, unlinkSync as unlinkSync24 } from "node:fs";
|
|
639865
639999
|
import { tmpdir as tmpdir22 } from "node:os";
|
|
639866
640000
|
import { join as join145 } from "node:path";
|
|
639867
640001
|
function isNeovimActive() {
|
|
@@ -639910,7 +640044,7 @@ async function startNeovimMode(opts) {
|
|
|
639910
640044
|
}
|
|
639911
640045
|
const socketPath = join145(tmpdir22(), `omnius-nvim-${process.pid}-${Date.now()}.sock`);
|
|
639912
640046
|
try {
|
|
639913
|
-
if (
|
|
640047
|
+
if (existsSync132(socketPath)) unlinkSync24(socketPath);
|
|
639914
640048
|
} catch {
|
|
639915
640049
|
}
|
|
639916
640050
|
const ptyCols = opts.cols;
|
|
@@ -640157,12 +640291,12 @@ function resizeNeovim(cols, contentRows) {
|
|
|
640157
640291
|
}
|
|
640158
640292
|
async function connectRPC(state, neovimPkg, cols) {
|
|
640159
640293
|
let attempts = 0;
|
|
640160
|
-
while (!
|
|
640294
|
+
while (!existsSync132(state.socketPath) && attempts < 30) {
|
|
640161
640295
|
await new Promise((r2) => setTimeout(r2, 200));
|
|
640162
640296
|
attempts++;
|
|
640163
640297
|
if (state.cleanedUp) return;
|
|
640164
640298
|
}
|
|
640165
|
-
if (!
|
|
640299
|
+
if (!existsSync132(state.socketPath)) return;
|
|
640166
640300
|
const nvim = neovimPkg.attach({ socket: state.socketPath });
|
|
640167
640301
|
state.nvim = nvim;
|
|
640168
640302
|
await new Promise((r2) => setTimeout(r2, 300));
|
|
@@ -640299,7 +640433,7 @@ function doCleanup(state) {
|
|
|
640299
640433
|
state.pty = null;
|
|
640300
640434
|
}
|
|
640301
640435
|
try {
|
|
640302
|
-
if (
|
|
640436
|
+
if (existsSync132(state.socketPath)) unlinkSync24(state.socketPath);
|
|
640303
640437
|
} catch {
|
|
640304
640438
|
}
|
|
640305
640439
|
if (state.stdinHandler) {
|
|
@@ -640374,7 +640508,7 @@ __export(daemon_exports, {
|
|
|
640374
640508
|
stopDaemon: () => stopDaemon
|
|
640375
640509
|
});
|
|
640376
640510
|
import { spawn as spawn35 } from "node:child_process";
|
|
640377
|
-
import { existsSync as
|
|
640511
|
+
import { existsSync as existsSync133, readFileSync as readFileSync108, writeFileSync as writeFileSync67, mkdirSync as mkdirSync79, unlinkSync as unlinkSync25, openSync as openSync3, closeSync as closeSync3 } from "node:fs";
|
|
640378
640512
|
import { join as join146 } from "node:path";
|
|
640379
640513
|
import { homedir as homedir48 } from "node:os";
|
|
640380
640514
|
import { fileURLToPath as fileURLToPath20 } from "node:url";
|
|
@@ -640404,7 +640538,7 @@ function getLocalCliVersion() {
|
|
|
640404
640538
|
const here = dirname44(fileURLToPath20(import.meta.url));
|
|
640405
640539
|
for (const rel of ["../package.json", "../../package.json", "./package.json", "../../../package.json"]) {
|
|
640406
640540
|
const p2 = join146(here, rel);
|
|
640407
|
-
if (
|
|
640541
|
+
if (existsSync133(p2)) {
|
|
640408
640542
|
const v = JSON.parse(readFileSync108(p2, "utf8"))?.version;
|
|
640409
640543
|
if (v) return String(v);
|
|
640410
640544
|
}
|
|
@@ -640442,7 +640576,7 @@ async function restartDaemon(port) {
|
|
|
640442
640576
|
await startDaemon();
|
|
640443
640577
|
}
|
|
640444
640578
|
function getDaemonPid() {
|
|
640445
|
-
if (!
|
|
640579
|
+
if (!existsSync133(PID_FILE2)) return null;
|
|
640446
640580
|
try {
|
|
640447
640581
|
const pid = parseInt(readFileSync108(PID_FILE2, "utf8").trim(), 10);
|
|
640448
640582
|
if (!pid || pid <= 0) return null;
|
|
@@ -640491,7 +640625,7 @@ async function resolveDaemonCommand(nodeExe) {
|
|
|
640491
640625
|
for (const candidate of candidates) {
|
|
640492
640626
|
if (!candidate || seen.has(candidate)) continue;
|
|
640493
640627
|
seen.add(candidate);
|
|
640494
|
-
if (!
|
|
640628
|
+
if (!existsSync133(candidate)) continue;
|
|
640495
640629
|
return commandForEntrypoint(candidate, nodeExe);
|
|
640496
640630
|
}
|
|
640497
640631
|
return null;
|
|
@@ -640715,7 +640849,7 @@ var mem_metabolize_exports = {};
|
|
|
640715
640849
|
__export(mem_metabolize_exports, {
|
|
640716
640850
|
handleMetabolize: () => handleMetabolize
|
|
640717
640851
|
});
|
|
640718
|
-
import { existsSync as
|
|
640852
|
+
import { existsSync as existsSync134 } from "node:fs";
|
|
640719
640853
|
import { join as join147 } from "node:path";
|
|
640720
640854
|
function getStateDir() {
|
|
640721
640855
|
const omniusDir = join147(process.cwd(), ".omnius");
|
|
@@ -640729,7 +640863,7 @@ async function handleMetabolize(options2 = {}) {
|
|
|
640729
640863
|
vacuum: options2.vacuum ?? true
|
|
640730
640864
|
};
|
|
640731
640865
|
const stateDir = getStateDir();
|
|
640732
|
-
if (!
|
|
640866
|
+
if (!existsSync134(stateDir)) {
|
|
640733
640867
|
return `No .omnius state directory found at ${stateDir}. Run the agent first to create session data.`;
|
|
640734
640868
|
}
|
|
640735
640869
|
const result = runMemoryMaintenance({
|
|
@@ -640866,7 +641000,7 @@ __export(kg_prune_exports, {
|
|
|
640866
641000
|
pruneKnowledgeGraph: () => pruneKnowledgeGraph,
|
|
640867
641001
|
pruneKnowledgeGraphWithInference: () => pruneKnowledgeGraphWithInference
|
|
640868
641002
|
});
|
|
640869
|
-
import { existsSync as
|
|
641003
|
+
import { existsSync as existsSync135, statSync as statSync51 } from "node:fs";
|
|
640870
641004
|
import { join as join148 } from "node:path";
|
|
640871
641005
|
function stateDirFor(workingDir) {
|
|
640872
641006
|
return join148(workingDir, ".omnius");
|
|
@@ -640877,7 +641011,7 @@ function knowledgeGraphStats(workingDir) {
|
|
|
640877
641011
|
const archivePath = join148(stateDir, "knowledge.archive.db");
|
|
640878
641012
|
const stats = {
|
|
640879
641013
|
dbPath,
|
|
640880
|
-
exists:
|
|
641014
|
+
exists: existsSync135(dbPath),
|
|
640881
641015
|
sizeBytes: 0,
|
|
640882
641016
|
archiveSizeBytes: 0,
|
|
640883
641017
|
nodes: 0,
|
|
@@ -640890,7 +641024,7 @@ function knowledgeGraphStats(workingDir) {
|
|
|
640890
641024
|
} catch {
|
|
640891
641025
|
}
|
|
640892
641026
|
}
|
|
640893
|
-
if (
|
|
641027
|
+
if (existsSync135(archivePath)) {
|
|
640894
641028
|
try {
|
|
640895
641029
|
stats.archiveSizeBytes = statSync51(archivePath).size;
|
|
640896
641030
|
} catch {
|
|
@@ -640918,7 +641052,7 @@ function knowledgeGraphStats(workingDir) {
|
|
|
640918
641052
|
}
|
|
640919
641053
|
function pruneKnowledgeGraph(opts) {
|
|
640920
641054
|
const stateDir = stateDirFor(opts.workingDir);
|
|
640921
|
-
if (!
|
|
641055
|
+
if (!existsSync135(join148(stateDir, "knowledge.db"))) {
|
|
640922
641056
|
return {
|
|
640923
641057
|
report: `No knowledge.db found at ${stateDir}. Nothing to prune.`,
|
|
640924
641058
|
result: null
|
|
@@ -640957,7 +641091,7 @@ function pruneKnowledgeGraph(opts) {
|
|
|
640957
641091
|
async function pruneKnowledgeGraphWithInference(opts) {
|
|
640958
641092
|
const stateDir = stateDirFor(opts.workingDir);
|
|
640959
641093
|
const knowledgePath = join148(stateDir, "knowledge.db");
|
|
640960
|
-
if (!
|
|
641094
|
+
if (!existsSync135(knowledgePath)) {
|
|
640961
641095
|
return {
|
|
640962
641096
|
report: `No knowledge.db found at ${stateDir}. Nothing to prune.`,
|
|
640963
641097
|
result: null
|
|
@@ -641137,7 +641271,7 @@ import {
|
|
|
641137
641271
|
writeFileSync as writeFileSync68,
|
|
641138
641272
|
mkdirSync as mkdirSync80,
|
|
641139
641273
|
chmodSync as chmodSync4,
|
|
641140
|
-
existsSync as
|
|
641274
|
+
existsSync as existsSync136,
|
|
641141
641275
|
unlinkSync as unlinkSync26,
|
|
641142
641276
|
readdirSync as readdirSync44
|
|
641143
641277
|
} from "node:fs";
|
|
@@ -641164,7 +641298,7 @@ function secureDir(path12) {
|
|
|
641164
641298
|
}
|
|
641165
641299
|
function secureFile(path12) {
|
|
641166
641300
|
try {
|
|
641167
|
-
if (
|
|
641301
|
+
if (existsSync136(path12)) chmodSync4(path12, 384);
|
|
641168
641302
|
} catch {
|
|
641169
641303
|
}
|
|
641170
641304
|
}
|
|
@@ -641318,7 +641452,7 @@ function normalizeSkills(skill, skills) {
|
|
|
641318
641452
|
function loadJobs() {
|
|
641319
641453
|
ensureDirs();
|
|
641320
641454
|
const path12 = jobsFilePath();
|
|
641321
|
-
if (!
|
|
641455
|
+
if (!existsSync136(path12)) return [];
|
|
641322
641456
|
try {
|
|
641323
641457
|
const data = JSON.parse(readFileSync109(path12, "utf-8"));
|
|
641324
641458
|
return data.jobs || [];
|
|
@@ -641531,7 +641665,7 @@ function saveJobOutput(jobId, output) {
|
|
|
641531
641665
|
}
|
|
641532
641666
|
function listJobOutputs(jobId) {
|
|
641533
641667
|
const jobOutDir = join149(outputDir(), jobId);
|
|
641534
|
-
if (!
|
|
641668
|
+
if (!existsSync136(jobOutDir)) return [];
|
|
641535
641669
|
try {
|
|
641536
641670
|
return readdirSync44(jobOutDir).filter((f2) => f2.endsWith(".md")).sort().map((f2) => join149(jobOutDir, f2));
|
|
641537
641671
|
} catch {
|
|
@@ -641682,7 +641816,7 @@ var init_delivery2 = __esm({
|
|
|
641682
641816
|
|
|
641683
641817
|
// packages/cli/src/cron/scheduler.ts
|
|
641684
641818
|
import {
|
|
641685
|
-
existsSync as
|
|
641819
|
+
existsSync as existsSync137,
|
|
641686
641820
|
mkdirSync as mkdirSync81,
|
|
641687
641821
|
openSync as openSync5,
|
|
641688
641822
|
closeSync as closeSync5,
|
|
@@ -641704,7 +641838,7 @@ function acquireTickLock() {
|
|
|
641704
641838
|
const lockPath = lockFilePath();
|
|
641705
641839
|
mkdirSync81(cronDir2(), { recursive: true });
|
|
641706
641840
|
try {
|
|
641707
|
-
if (
|
|
641841
|
+
if (existsSync137(lockPath)) {
|
|
641708
641842
|
const content = readFileSync110(lockPath, "utf-8").trim();
|
|
641709
641843
|
if (content) {
|
|
641710
641844
|
const lock = JSON.parse(content);
|
|
@@ -642073,7 +642207,7 @@ __export(sponsor_wizard_exports, {
|
|
|
642073
642207
|
selectedModelsForEndpoint: () => selectedModelsForEndpoint,
|
|
642074
642208
|
showSponsorDashboard: () => showSponsorDashboard
|
|
642075
642209
|
});
|
|
642076
|
-
import { existsSync as
|
|
642210
|
+
import { existsSync as existsSync138, readFileSync as readFileSync111, writeFileSync as writeFileSync70, mkdirSync as mkdirSync82 } from "node:fs";
|
|
642077
642211
|
import { join as join151 } from "node:path";
|
|
642078
642212
|
function fmtTokens2(n2) {
|
|
642079
642213
|
if (n2 < 1e3) return String(Math.max(0, Math.floor(n2)));
|
|
@@ -642092,7 +642226,7 @@ function configPath(projectDir2) {
|
|
|
642092
642226
|
}
|
|
642093
642227
|
function loadSponsorConfig(projectDir2) {
|
|
642094
642228
|
const p2 = configPath(projectDir2);
|
|
642095
|
-
if (!
|
|
642229
|
+
if (!existsSync138(p2)) return null;
|
|
642096
642230
|
try {
|
|
642097
642231
|
return JSON.parse(readFileSync111(p2, "utf8"));
|
|
642098
642232
|
} catch {
|
|
@@ -643438,7 +643572,7 @@ __export(voice_exports, {
|
|
|
643438
643572
|
resetNarrationContext: () => resetNarrationContext
|
|
643439
643573
|
});
|
|
643440
643574
|
import {
|
|
643441
|
-
existsSync as
|
|
643575
|
+
existsSync as existsSync139,
|
|
643442
643576
|
mkdirSync as mkdirSync83,
|
|
643443
643577
|
writeFileSync as writeFileSync71,
|
|
643444
643578
|
readFileSync as readFileSync112,
|
|
@@ -643569,7 +643703,7 @@ function misottsInferScript2() {
|
|
|
643569
643703
|
return join152(voiceDir2(), "misotts-infer.py");
|
|
643570
643704
|
}
|
|
643571
643705
|
function mergeDir2(src2, dst) {
|
|
643572
|
-
if (!
|
|
643706
|
+
if (!existsSync139(src2)) return;
|
|
643573
643707
|
mkdirSync83(dst, { recursive: true });
|
|
643574
643708
|
for (const entry of readdirSync45(src2, { withFileTypes: true })) {
|
|
643575
643709
|
const s2 = join152(src2, entry.name);
|
|
@@ -643578,7 +643712,7 @@ function mergeDir2(src2, dst) {
|
|
|
643578
643712
|
if (entry.isDirectory()) {
|
|
643579
643713
|
mergeDir2(s2, d2);
|
|
643580
643714
|
} else if (entry.isFile()) {
|
|
643581
|
-
if (!
|
|
643715
|
+
if (!existsSync139(d2) || statSync52(s2).mtimeMs > statSync52(d2).mtimeMs) {
|
|
643582
643716
|
copyFileSync6(s2, d2);
|
|
643583
643717
|
}
|
|
643584
643718
|
}
|
|
@@ -643591,7 +643725,7 @@ function consolidateVoiceDirs2() {
|
|
|
643591
643725
|
let migrated = 0;
|
|
643592
643726
|
let cleaned = 0;
|
|
643593
643727
|
const oldVoice = join152(homedir51(), ".open-agents", "voice");
|
|
643594
|
-
if (
|
|
643728
|
+
if (existsSync139(oldVoice)) {
|
|
643595
643729
|
mergeDir2(join152(oldVoice, "clone-refs"), join152(globalVoice, "clone-refs"));
|
|
643596
643730
|
mergeDir2(join152(oldVoice, "models"), join152(globalVoice, "models"));
|
|
643597
643731
|
try {
|
|
@@ -643606,18 +643740,18 @@ function consolidateVoiceDirs2() {
|
|
|
643606
643740
|
let prev = "";
|
|
643607
643741
|
while (dir !== prev) {
|
|
643608
643742
|
const c9 = join152(dir, ".omnius", "voice");
|
|
643609
|
-
if (
|
|
643743
|
+
if (existsSync139(c9) && c9 !== globalVoice) candidates.add(c9);
|
|
643610
643744
|
prev = dir;
|
|
643611
643745
|
dir = dirname45(dir);
|
|
643612
643746
|
}
|
|
643613
643747
|
for (const root of COMMON_PROJECT_ROOTS) {
|
|
643614
643748
|
const rootDir = join152(homedir51(), root);
|
|
643615
|
-
if (!
|
|
643749
|
+
if (!existsSync139(rootDir)) continue;
|
|
643616
643750
|
try {
|
|
643617
643751
|
for (const entry of readdirSync45(rootDir, { withFileTypes: true })) {
|
|
643618
643752
|
if (!entry.isDirectory()) continue;
|
|
643619
643753
|
const c9 = join152(rootDir, entry.name, ".omnius", "voice");
|
|
643620
|
-
if (
|
|
643754
|
+
if (existsSync139(c9) && c9 !== globalVoice) candidates.add(c9);
|
|
643621
643755
|
}
|
|
643622
643756
|
} catch {
|
|
643623
643757
|
}
|
|
@@ -643801,7 +643935,7 @@ function insertTagAfterOpeningClause(text2, tag) {
|
|
|
643801
643935
|
return `<${tag}> ${text2}`;
|
|
643802
643936
|
}
|
|
643803
643937
|
function writeDetectTorchScript(targetPath) {
|
|
643804
|
-
if (
|
|
643938
|
+
if (existsSync139(targetPath)) return;
|
|
643805
643939
|
try {
|
|
643806
643940
|
mkdirSync83(dirname45(targetPath), { recursive: true });
|
|
643807
643941
|
} catch {
|
|
@@ -644809,7 +644943,7 @@ except Exception as exc:
|
|
|
644809
644943
|
const targets = ["glados", "overwatch"];
|
|
644810
644944
|
for (const modelId of targets) {
|
|
644811
644945
|
const refFile = join152(refsDir, `${modelId}-ref.wav`);
|
|
644812
|
-
if (
|
|
644946
|
+
if (existsSync139(refFile)) continue;
|
|
644813
644947
|
try {
|
|
644814
644948
|
await this.generateCloneRef(modelId);
|
|
644815
644949
|
const meta = this.loadCloneMeta();
|
|
@@ -644929,13 +645063,13 @@ except Exception as exc:
|
|
|
644929
645063
|
if (p2.startsWith("~/") || p2 === "~") {
|
|
644930
645064
|
p2 = join152(homedir51(), p2.slice(1));
|
|
644931
645065
|
}
|
|
644932
|
-
if (!
|
|
645066
|
+
if (!existsSync139(p2)) {
|
|
644933
645067
|
return `File not found: ${p2}
|
|
644934
645068
|
(original input: ${audioPath})`;
|
|
644935
645069
|
}
|
|
644936
645070
|
audioPath = p2;
|
|
644937
645071
|
const refsDir = luxttsCloneRefsDir();
|
|
644938
|
-
if (!
|
|
645072
|
+
if (!existsSync139(refsDir)) mkdirSync83(refsDir, { recursive: true });
|
|
644939
645073
|
const ext = audioPath.split(".").pop() || "wav";
|
|
644940
645074
|
const srcName = (audioPath.split("/").pop() ?? "clone").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
644941
645075
|
const ts = Date.now().toString(36);
|
|
@@ -644994,7 +645128,7 @@ except Exception as exc:
|
|
|
644994
645128
|
return `Failed to synthesize reference audio from ${source.label}.`;
|
|
644995
645129
|
}
|
|
644996
645130
|
const refsDir = luxttsCloneRefsDir();
|
|
644997
|
-
if (!
|
|
645131
|
+
if (!existsSync139(refsDir)) mkdirSync83(refsDir, { recursive: true });
|
|
644998
645132
|
const destPath = join152(refsDir, `${sourceModelId}-ref.wav`);
|
|
644999
645133
|
const sampleRate = this.config?.audio?.sample_rate ?? 22050;
|
|
645000
645134
|
this.writeWav(audioData, sampleRate, destPath);
|
|
@@ -645015,7 +645149,7 @@ except Exception as exc:
|
|
|
645015
645149
|
}
|
|
645016
645150
|
loadCloneMeta() {
|
|
645017
645151
|
const p2 = _VoiceEngine.cloneMetaFile();
|
|
645018
|
-
if (!
|
|
645152
|
+
if (!existsSync139(p2)) return {};
|
|
645019
645153
|
try {
|
|
645020
645154
|
const raw = JSON.parse(readFileSync112(p2, "utf8"));
|
|
645021
645155
|
if (typeof Object.values(raw)[0] === "string") {
|
|
@@ -645032,7 +645166,7 @@ except Exception as exc:
|
|
|
645032
645166
|
}
|
|
645033
645167
|
saveCloneMeta(meta) {
|
|
645034
645168
|
const dir = luxttsCloneRefsDir();
|
|
645035
|
-
if (!
|
|
645169
|
+
if (!existsSync139(dir)) mkdirSync83(dir, { recursive: true });
|
|
645036
645170
|
writeFileSync71(_VoiceEngine.cloneMetaFile(), JSON.stringify(meta, null, 2));
|
|
645037
645171
|
}
|
|
645038
645172
|
/** Audio file extensions recognized as clone references */
|
|
@@ -645051,7 +645185,7 @@ except Exception as exc:
|
|
|
645051
645185
|
*/
|
|
645052
645186
|
listCloneRefs() {
|
|
645053
645187
|
const dir = luxttsCloneRefsDir();
|
|
645054
|
-
if (!
|
|
645188
|
+
if (!existsSync139(dir)) return [];
|
|
645055
645189
|
const meta = this.loadCloneMeta();
|
|
645056
645190
|
const files = readdirSync45(dir).filter((f2) => {
|
|
645057
645191
|
const ext = f2.split(".").pop()?.toLowerCase() ?? "";
|
|
@@ -645078,7 +645212,7 @@ except Exception as exc:
|
|
|
645078
645212
|
/** Delete a clone reference file by filename. Returns true if deleted. */
|
|
645079
645213
|
deleteCloneRef(filename) {
|
|
645080
645214
|
const p2 = join152(luxttsCloneRefsDir(), filename);
|
|
645081
|
-
if (!
|
|
645215
|
+
if (!existsSync139(p2)) return false;
|
|
645082
645216
|
try {
|
|
645083
645217
|
unlinkSync28(p2);
|
|
645084
645218
|
const meta = this.loadCloneMeta();
|
|
@@ -645106,7 +645240,7 @@ except Exception as exc:
|
|
|
645106
645240
|
/** Set the active clone reference by filename. */
|
|
645107
645241
|
setActiveCloneRef(filename) {
|
|
645108
645242
|
const p2 = join152(luxttsCloneRefsDir(), filename);
|
|
645109
|
-
if (!
|
|
645243
|
+
if (!existsSync139(p2)) return `File not found: ${filename}`;
|
|
645110
645244
|
this.luxttsCloneRef = p2;
|
|
645111
645245
|
this.misottsCloneRef = p2;
|
|
645112
645246
|
return `Active clone voice set to: ${filename}`;
|
|
@@ -645958,7 +646092,7 @@ except Exception as exc:
|
|
|
645958
646092
|
}
|
|
645959
646093
|
const venvDir = supertonicVenvDir();
|
|
645960
646094
|
const venvPy = supertonicVenvPy2();
|
|
645961
|
-
if (!
|
|
646095
|
+
if (!existsSync139(venvPy)) {
|
|
645962
646096
|
renderInfo("Creating Supertonic3 Python virtual environment...");
|
|
645963
646097
|
await this.asyncShell(`${py} -m venv ${JSON.stringify(venvDir)}`, 6e4);
|
|
645964
646098
|
}
|
|
@@ -645979,7 +646113,7 @@ except Exception as exc:
|
|
|
645979
646113
|
async checkSupertonicInstalled() {
|
|
645980
646114
|
if (this.supertonicInstalled !== null) return this.supertonicInstalled;
|
|
645981
646115
|
const venvPy = supertonicVenvPy2();
|
|
645982
|
-
if (!
|
|
646116
|
+
if (!existsSync139(venvPy)) {
|
|
645983
646117
|
this.supertonicInstalled = false;
|
|
645984
646118
|
return false;
|
|
645985
646119
|
}
|
|
@@ -646070,7 +646204,7 @@ except Exception as exc:
|
|
|
646070
646204
|
speed: settings.speed * speedFactor,
|
|
646071
646205
|
total_step: settings.totalStep
|
|
646072
646206
|
});
|
|
646073
|
-
return
|
|
646207
|
+
return existsSync139(wavPath) ? wavPath : null;
|
|
646074
646208
|
} catch {
|
|
646075
646209
|
return null;
|
|
646076
646210
|
}
|
|
@@ -646157,7 +646291,7 @@ except Exception as exc:
|
|
|
646157
646291
|
async checkMlxInstalled() {
|
|
646158
646292
|
if (this.mlxInstalled !== null) return this.mlxInstalled;
|
|
646159
646293
|
const py = mlxVenvPy2();
|
|
646160
|
-
if (!
|
|
646294
|
+
if (!existsSync139(py)) {
|
|
646161
646295
|
this.mlxInstalled = false;
|
|
646162
646296
|
return false;
|
|
646163
646297
|
}
|
|
@@ -646239,7 +646373,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646239
646373
|
return;
|
|
646240
646374
|
}
|
|
646241
646375
|
}
|
|
646242
|
-
if (!
|
|
646376
|
+
if (!existsSync139(wavPath)) return;
|
|
646243
646377
|
if (volume !== 1) {
|
|
646244
646378
|
try {
|
|
646245
646379
|
const wavData = readFileSync112(wavPath);
|
|
@@ -646320,7 +646454,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646320
646454
|
return null;
|
|
646321
646455
|
}
|
|
646322
646456
|
}
|
|
646323
|
-
if (!
|
|
646457
|
+
if (!existsSync139(wavPath)) return null;
|
|
646324
646458
|
try {
|
|
646325
646459
|
const data = readFileSync112(wavPath);
|
|
646326
646460
|
unlinkSync28(wavPath);
|
|
@@ -646347,7 +646481,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646347
646481
|
}
|
|
646348
646482
|
const venvDir = luxttsVenvDir2();
|
|
646349
646483
|
const venvPy = luxttsVenvPy2();
|
|
646350
|
-
if (
|
|
646484
|
+
if (existsSync139(venvPy)) {
|
|
646351
646485
|
try {
|
|
646352
646486
|
const quotedPy = `"${venvPy}"`;
|
|
646353
646487
|
const repoPath2 = luxttsRepoDir2().replace(/\\/g, "/");
|
|
@@ -646403,7 +646537,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646403
646537
|
renderInfo(
|
|
646404
646538
|
"Setting up LuxTTS voice cloning (first-time setup, this takes several minutes)..."
|
|
646405
646539
|
);
|
|
646406
|
-
if (!
|
|
646540
|
+
if (!existsSync139(venvDir)) {
|
|
646407
646541
|
renderInfo(" Creating Python virtual environment...");
|
|
646408
646542
|
try {
|
|
646409
646543
|
await this.asyncShell(
|
|
@@ -646435,8 +646569,8 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646435
646569
|
pipArgsStr = "torch torchaudio --index-url https://download.pytorch.org/whl/cu124";
|
|
646436
646570
|
torchDesc = "CUDA (fallback)";
|
|
646437
646571
|
} catch {
|
|
646438
|
-
const
|
|
646439
|
-
if (
|
|
646572
|
+
const arch4 = process.arch;
|
|
646573
|
+
if (arch4 === "arm64" || arch4 === "arm") {
|
|
646440
646574
|
pipArgsStr = "torch torchaudio";
|
|
646441
646575
|
torchDesc = "ARM CPU (generic PyPI)";
|
|
646442
646576
|
} else {
|
|
@@ -646465,10 +646599,10 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646465
646599
|
}
|
|
646466
646600
|
}
|
|
646467
646601
|
const repoDir = luxttsRepoDir2();
|
|
646468
|
-
if (!
|
|
646602
|
+
if (!existsSync139(join152(repoDir, "zipvoice", "luxvoice.py"))) {
|
|
646469
646603
|
renderInfo(" Cloning LuxTTS repository...");
|
|
646470
646604
|
try {
|
|
646471
|
-
if (
|
|
646605
|
+
if (existsSync139(repoDir)) {
|
|
646472
646606
|
const rmCmd = process.platform === "win32" ? `rmdir /s /q ${JSON.stringify(repoDir)}` : `rm -rf ${JSON.stringify(repoDir)}`;
|
|
646473
646607
|
await this.asyncShell(rmCmd, 3e4);
|
|
646474
646608
|
}
|
|
@@ -646559,7 +646693,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646559
646693
|
);
|
|
646560
646694
|
}
|
|
646561
646695
|
}
|
|
646562
|
-
const isJetson = isArm && (
|
|
646696
|
+
const isJetson = isArm && (existsSync139("/etc/nv_tegra_release") || existsSync139("/usr/local/cuda/targets/aarch64-linux") || (process.env.JETSON_L4T_VERSION ?? "") !== "");
|
|
646563
646697
|
const installSteps = isArm ? [
|
|
646564
646698
|
// ARM: install individually so we get clear error messages per package.
|
|
646565
646699
|
// ALL are fatal because LuxTTS hard-imports them (no lazy/optional imports).
|
|
@@ -646576,7 +646710,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646576
646710
|
...isJetson ? (() => {
|
|
646577
646711
|
let jpVer = "v60";
|
|
646578
646712
|
try {
|
|
646579
|
-
const tegra =
|
|
646713
|
+
const tegra = existsSync139("/etc/nv_tegra_release") ? readFileSync112("/etc/nv_tegra_release", "utf8").trim() : "";
|
|
646580
646714
|
const ver = process.env.JETSON_L4T_VERSION || "";
|
|
646581
646715
|
if (ver.startsWith("5.") || tegra.includes("R35") || tegra.includes("R34"))
|
|
646582
646716
|
jpVer = "v51";
|
|
@@ -646756,7 +646890,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646756
646890
|
const venvDir = misottsVenvDir2();
|
|
646757
646891
|
const venvPy = misottsVenvPy2();
|
|
646758
646892
|
const repoDir = misottsRepoDir2();
|
|
646759
|
-
if (
|
|
646893
|
+
if (existsSync139(venvPy)) {
|
|
646760
646894
|
try {
|
|
646761
646895
|
const repoPath2 = repoDir.replace(/\\/g, "/");
|
|
646762
646896
|
await this.asyncShell(
|
|
@@ -646786,7 +646920,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646786
646920
|
renderInfo(
|
|
646787
646921
|
"Setting up MisoTTS 8B voice cloning (first-time setup, ~30-40GB download, takes several minutes)..."
|
|
646788
646922
|
);
|
|
646789
|
-
if (!
|
|
646923
|
+
if (!existsSync139(venvDir)) {
|
|
646790
646924
|
renderInfo(" Creating Python virtual environment...");
|
|
646791
646925
|
try {
|
|
646792
646926
|
await this.asyncShell(
|
|
@@ -646843,10 +646977,10 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646843
646977
|
}
|
|
646844
646978
|
}
|
|
646845
646979
|
}
|
|
646846
|
-
if (!
|
|
646980
|
+
if (!existsSync139(join152(repoDir, "generator.py"))) {
|
|
646847
646981
|
renderInfo(" Cloning MisoTTS repository...");
|
|
646848
646982
|
try {
|
|
646849
|
-
if (
|
|
646983
|
+
if (existsSync139(repoDir)) {
|
|
646850
646984
|
await this.asyncShell(`rm -rf ${JSON.stringify(repoDir)}`, 3e4);
|
|
646851
646985
|
}
|
|
646852
646986
|
await this.asyncShell(
|
|
@@ -646933,13 +647067,13 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646933
647067
|
}
|
|
646934
647068
|
/** Auto-detect an existing clone reference for MisoTTS */
|
|
646935
647069
|
autoDetectMisottsCloneRef() {
|
|
646936
|
-
if (this.misottsCloneRef &&
|
|
647070
|
+
if (this.misottsCloneRef && existsSync139(this.misottsCloneRef)) return;
|
|
646937
647071
|
const refsDir = luxttsCloneRefsDir();
|
|
646938
|
-
if (!
|
|
647072
|
+
if (!existsSync139(refsDir)) return;
|
|
646939
647073
|
const files = readdirSync45(refsDir).filter((f2) => /\.(wav|mp3|flac|ogg|m4a)$/i.test(f2)).sort();
|
|
646940
647074
|
for (const f2 of files) {
|
|
646941
647075
|
const p2 = join152(refsDir, f2);
|
|
646942
|
-
if (
|
|
647076
|
+
if (existsSync139(p2)) {
|
|
646943
647077
|
this.misottsCloneRef = p2;
|
|
646944
647078
|
return;
|
|
646945
647079
|
}
|
|
@@ -646947,9 +647081,9 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646947
647081
|
}
|
|
646948
647082
|
/** Auto-detect an existing clone reference in the refs directory */
|
|
646949
647083
|
autoDetectCloneRef() {
|
|
646950
|
-
if (this.luxttsCloneRef &&
|
|
647084
|
+
if (this.luxttsCloneRef && existsSync139(this.luxttsCloneRef)) return;
|
|
646951
647085
|
const refsDir = luxttsCloneRefsDir();
|
|
646952
|
-
if (!
|
|
647086
|
+
if (!existsSync139(refsDir)) return;
|
|
646953
647087
|
for (const name10 of [
|
|
646954
647088
|
"custom-clone.wav",
|
|
646955
647089
|
"custom-clone.mp3",
|
|
@@ -646957,7 +647091,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
646957
647091
|
"overwatch-ref.wav"
|
|
646958
647092
|
]) {
|
|
646959
647093
|
const p2 = join152(refsDir, name10);
|
|
646960
|
-
if (
|
|
647094
|
+
if (existsSync139(p2)) {
|
|
646961
647095
|
this.luxttsCloneRef = p2;
|
|
646962
647096
|
return;
|
|
646963
647097
|
}
|
|
@@ -647068,7 +647202,7 @@ if __name__ == '__main__':
|
|
|
647068
647202
|
async ensureLuxttsDaemon() {
|
|
647069
647203
|
if (this._luxttsDaemon && !this._luxttsDaemon.killed) return true;
|
|
647070
647204
|
const venvPy = luxttsVenvPy2();
|
|
647071
|
-
if (!
|
|
647205
|
+
if (!existsSync139(venvPy)) return false;
|
|
647072
647206
|
return new Promise((resolve76) => {
|
|
647073
647207
|
const env2 = voicePythonEnv({ LUXTTS_REPO_PATH: luxttsRepoDir2() });
|
|
647074
647208
|
const daemon = nodeSpawn(venvPy, [luxttsInferScript2()], {
|
|
@@ -647157,7 +647291,7 @@ if __name__ == '__main__':
|
|
|
647157
647291
|
* Used by drainQueue's pre-fetch pipeline for gapless back-to-back playback.
|
|
647158
647292
|
*/
|
|
647159
647293
|
async synthesizeLuxttsWav(text2, speedFactor = 1) {
|
|
647160
|
-
if (!this.luxttsCloneRef || !
|
|
647294
|
+
if (!this.luxttsCloneRef || !existsSync139(this.luxttsCloneRef)) return null;
|
|
647161
647295
|
const cleaned = text2.replace(/\*/g, "").trim();
|
|
647162
647296
|
if (!cleaned) return null;
|
|
647163
647297
|
const ready = await this.ensureLuxttsDaemon();
|
|
@@ -647177,14 +647311,14 @@ if __name__ == '__main__':
|
|
|
647177
647311
|
} catch {
|
|
647178
647312
|
return null;
|
|
647179
647313
|
}
|
|
647180
|
-
return
|
|
647314
|
+
return existsSync139(wavPath) ? wavPath : null;
|
|
647181
647315
|
}
|
|
647182
647316
|
/**
|
|
647183
647317
|
* Post-process (fade-in, volume, pitch, stereo) and play a LuxTTS WAV file.
|
|
647184
647318
|
* Cleans up the WAV file after playback.
|
|
647185
647319
|
*/
|
|
647186
647320
|
async postProcessAndPlayLuxtts(wavPath, volume = 1, pitchFactor = 1, stereoDelayMs = 0.6) {
|
|
647187
|
-
if (!
|
|
647321
|
+
if (!existsSync139(wavPath)) return;
|
|
647188
647322
|
try {
|
|
647189
647323
|
const wavData = readFileSync112(wavPath);
|
|
647190
647324
|
if (wavData.length > 44) {
|
|
@@ -647299,7 +647433,7 @@ if __name__ == '__main__':
|
|
|
647299
647433
|
* Used for Telegram voice messages and WebSocket streaming.
|
|
647300
647434
|
*/
|
|
647301
647435
|
async synthesizeLuxttsToBuffer(text2) {
|
|
647302
|
-
if (!this.luxttsCloneRef || !
|
|
647436
|
+
if (!this.luxttsCloneRef || !existsSync139(this.luxttsCloneRef)) return null;
|
|
647303
647437
|
const cleaned = text2.replace(/\*/g, "").trim();
|
|
647304
647438
|
if (!cleaned) return null;
|
|
647305
647439
|
const ready = await this.ensureLuxttsDaemon();
|
|
@@ -647316,7 +647450,7 @@ if __name__ == '__main__':
|
|
|
647316
647450
|
} catch {
|
|
647317
647451
|
return null;
|
|
647318
647452
|
}
|
|
647319
|
-
if (!
|
|
647453
|
+
if (!existsSync139(wavPath)) return null;
|
|
647320
647454
|
try {
|
|
647321
647455
|
const data = readFileSync112(wavPath);
|
|
647322
647456
|
unlinkSync28(wavPath);
|
|
@@ -647430,7 +647564,7 @@ if __name__ == "__main__":
|
|
|
647430
647564
|
async ensureMisottsDaemon() {
|
|
647431
647565
|
if (this._misottsDaemon && !this._misottsDaemon.killed) return true;
|
|
647432
647566
|
const venvPy = misottsVenvPy2();
|
|
647433
|
-
if (!
|
|
647567
|
+
if (!existsSync139(venvPy)) return false;
|
|
647434
647568
|
return new Promise((resolve76) => {
|
|
647435
647569
|
const env2 = voicePythonEnv({
|
|
647436
647570
|
MISO_TTS_REPO_PATH: misottsRepoDir2(),
|
|
@@ -647516,7 +647650,7 @@ if __name__ == "__main__":
|
|
|
647516
647650
|
* Returns the WAV file path or null on failure.
|
|
647517
647651
|
*/
|
|
647518
647652
|
async synthesizeMisottsWav(text2, maxAudioLengthMs) {
|
|
647519
|
-
if (!this.misottsCloneRef || !
|
|
647653
|
+
if (!this.misottsCloneRef || !existsSync139(this.misottsCloneRef)) return null;
|
|
647520
647654
|
const cleaned = text2.replace(/\*/g, "").trim();
|
|
647521
647655
|
if (!cleaned) return null;
|
|
647522
647656
|
const ready = await this.ensureMisottsDaemon();
|
|
@@ -647544,14 +647678,14 @@ if __name__ == "__main__":
|
|
|
647544
647678
|
} catch {
|
|
647545
647679
|
return null;
|
|
647546
647680
|
}
|
|
647547
|
-
return
|
|
647681
|
+
return existsSync139(wavPath) ? wavPath : null;
|
|
647548
647682
|
}
|
|
647549
647683
|
/**
|
|
647550
647684
|
* Post-process (fade-in, volume, pitch, stereo) and play a MisoTTS WAV file.
|
|
647551
647685
|
* MisoTTS outputs 24kHz mono via Mimi codec.
|
|
647552
647686
|
*/
|
|
647553
647687
|
async postProcessAndPlayMisotts(wavPath, volume = 1, pitchFactor = 1, stereoDelayMs = 0.6) {
|
|
647554
|
-
if (!
|
|
647688
|
+
if (!existsSync139(wavPath)) return;
|
|
647555
647689
|
try {
|
|
647556
647690
|
const wavData = readFileSync112(wavPath);
|
|
647557
647691
|
if (wavData.length > 44) {
|
|
@@ -647667,7 +647801,7 @@ if __name__ == "__main__":
|
|
|
647667
647801
|
* Used for Telegram voice messages and WebSocket streaming.
|
|
647668
647802
|
*/
|
|
647669
647803
|
async synthesizeMisottsToBuffer(text2) {
|
|
647670
|
-
if (!this.misottsCloneRef || !
|
|
647804
|
+
if (!this.misottsCloneRef || !existsSync139(this.misottsCloneRef)) return null;
|
|
647671
647805
|
const cleaned = text2.replace(/\*/g, "").trim();
|
|
647672
647806
|
if (!cleaned) return null;
|
|
647673
647807
|
const ready = await this.ensureMisottsDaemon();
|
|
@@ -647692,7 +647826,7 @@ if __name__ == "__main__":
|
|
|
647692
647826
|
} catch {
|
|
647693
647827
|
return null;
|
|
647694
647828
|
}
|
|
647695
|
-
if (!
|
|
647829
|
+
if (!existsSync139(wavPath)) return null;
|
|
647696
647830
|
try {
|
|
647697
647831
|
const data = readFileSync112(wavPath);
|
|
647698
647832
|
unlinkSync28(wavPath);
|
|
@@ -647706,14 +647840,14 @@ if __name__ == "__main__":
|
|
|
647706
647840
|
// -------------------------------------------------------------------------
|
|
647707
647841
|
async ensureRuntime() {
|
|
647708
647842
|
if (this.ort) return;
|
|
647709
|
-
const
|
|
647843
|
+
const arch4 = process.arch;
|
|
647710
647844
|
mkdirSync83(voiceDir2(), { recursive: true });
|
|
647711
647845
|
const pkgPath = join152(voiceDir2(), "package.json");
|
|
647712
647846
|
const expectedDeps = {
|
|
647713
647847
|
"onnxruntime-node": "^1.21.0",
|
|
647714
647848
|
phonemizer: "^1.2.1"
|
|
647715
647849
|
};
|
|
647716
|
-
if (
|
|
647850
|
+
if (existsSync139(pkgPath)) {
|
|
647717
647851
|
try {
|
|
647718
647852
|
const existing = JSON.parse(readFileSync112(pkgPath, "utf8"));
|
|
647719
647853
|
if (!existing.dependencies?.["phonemizer"]) {
|
|
@@ -647723,7 +647857,7 @@ if __name__ == "__main__":
|
|
|
647723
647857
|
} catch {
|
|
647724
647858
|
}
|
|
647725
647859
|
}
|
|
647726
|
-
if (!
|
|
647860
|
+
if (!existsSync139(pkgPath)) {
|
|
647727
647861
|
writeFileSync71(
|
|
647728
647862
|
pkgPath,
|
|
647729
647863
|
JSON.stringify(
|
|
@@ -647754,10 +647888,10 @@ if __name__ == "__main__":
|
|
|
647754
647888
|
"node_modules",
|
|
647755
647889
|
"onnxruntime-node"
|
|
647756
647890
|
);
|
|
647757
|
-
const onnxInstalled =
|
|
647891
|
+
const onnxInstalled = existsSync139(onnxNodeModules);
|
|
647758
647892
|
if (onnxInstalled && !await probeOnnx()) {
|
|
647759
647893
|
throw new Error(
|
|
647760
|
-
`Voice synthesis unavailable: ONNX runtime crashes on this CPU (${process.platform}-${
|
|
647894
|
+
`Voice synthesis unavailable: ONNX runtime crashes on this CPU (${process.platform}-${arch4}). This is a known issue with some ARM SoCs where the CPU vendor is not recognized. Voice feedback will be disabled but all other features work normally.`
|
|
647761
647895
|
);
|
|
647762
647896
|
}
|
|
647763
647897
|
try {
|
|
@@ -647770,7 +647904,7 @@ if __name__ == "__main__":
|
|
|
647770
647904
|
12e4
|
|
647771
647905
|
);
|
|
647772
647906
|
} catch (err) {
|
|
647773
|
-
const archHint =
|
|
647907
|
+
const archHint = arch4 !== "x64" ? ` onnxruntime-node may not have prebuilt binaries for ${process.platform}-${arch4}.` : "";
|
|
647774
647908
|
throw new Error(
|
|
647775
647909
|
`Failed to install voice dependencies.${archHint} Try manually: cd ${voiceDir2()} && npm install
|
|
647776
647910
|
Error: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -647778,7 +647912,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
647778
647912
|
}
|
|
647779
647913
|
if (!await probeOnnx()) {
|
|
647780
647914
|
throw new Error(
|
|
647781
|
-
`Voice synthesis unavailable: ONNX runtime crashes on this CPU (${process.platform}-${
|
|
647915
|
+
`Voice synthesis unavailable: ONNX runtime crashes on this CPU (${process.platform}-${arch4}). This is a known issue with some ARM SoCs where the CPU vendor is not recognized. Voice feedback will be disabled but all other features work normally.`
|
|
647782
647916
|
);
|
|
647783
647917
|
}
|
|
647784
647918
|
try {
|
|
@@ -647802,7 +647936,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
647802
647936
|
const phonemizerMod = voiceRequire("phonemizer");
|
|
647803
647937
|
this.phonemizeFn = phonemizerMod.phonemize ?? phonemizerMod.default?.phonemize ?? phonemizerMod;
|
|
647804
647938
|
} catch (err) {
|
|
647805
|
-
const archHint =
|
|
647939
|
+
const archHint = arch4 !== "x64" ? ` phonemizer WASM may not support ${process.platform}-${arch4}.` : "";
|
|
647806
647940
|
throw new Error(
|
|
647807
647941
|
`Failed to install phonemizer.${archHint} Try manually: cd ${voiceDir2()} && npm install
|
|
647808
647942
|
Error: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -647819,9 +647953,9 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
647819
647953
|
const dir = modelDir(id2);
|
|
647820
647954
|
const onnxPath = modelOnnxPath(id2);
|
|
647821
647955
|
const configPath2 = modelConfigPath(id2);
|
|
647822
|
-
if (
|
|
647956
|
+
if (existsSync139(onnxPath) && existsSync139(configPath2)) return;
|
|
647823
647957
|
mkdirSync83(dir, { recursive: true });
|
|
647824
|
-
if (!
|
|
647958
|
+
if (!existsSync139(configPath2)) {
|
|
647825
647959
|
renderInfo(`Downloading ${model.label} voice config...`);
|
|
647826
647960
|
const configResp = await fetch(model.configUrl);
|
|
647827
647961
|
if (!configResp.ok)
|
|
@@ -647829,7 +647963,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
647829
647963
|
const configText = await configResp.text();
|
|
647830
647964
|
writeFileSync71(configPath2, configText);
|
|
647831
647965
|
}
|
|
647832
|
-
if (!
|
|
647966
|
+
if (!existsSync139(onnxPath)) {
|
|
647833
647967
|
renderInfo(
|
|
647834
647968
|
`Downloading ${model.label} voice model (this may take a minute)...`
|
|
647835
647969
|
);
|
|
@@ -647872,7 +648006,7 @@ Error: ${err instanceof Error ? err.message : String(err)}`
|
|
|
647872
648006
|
if (!this.ort) throw new Error("ONNX runtime not loaded");
|
|
647873
648007
|
const onnxPath = modelOnnxPath(this.modelId);
|
|
647874
648008
|
const configPath2 = modelConfigPath(this.modelId);
|
|
647875
|
-
if (!
|
|
648009
|
+
if (!existsSync139(onnxPath) || !existsSync139(configPath2)) {
|
|
647876
648010
|
throw new Error(`Model files not found for ${this.modelId}`);
|
|
647877
648011
|
}
|
|
647878
648012
|
this.config = JSON.parse(readFileSync112(configPath2, "utf8"));
|
|
@@ -648034,7 +648168,7 @@ import * as nodeOs from "node:os";
|
|
|
648034
648168
|
import { spawn as nodeSpawn2 } from "node:child_process";
|
|
648035
648169
|
import { createHash as createHash38 } from "node:crypto";
|
|
648036
648170
|
import {
|
|
648037
|
-
existsSync as
|
|
648171
|
+
existsSync as existsSync140,
|
|
648038
648172
|
readFileSync as readFileSync113,
|
|
648039
648173
|
writeFileSync as writeFileSync72,
|
|
648040
648174
|
mkdirSync as mkdirSync84,
|
|
@@ -648475,9 +648609,9 @@ async function ensureVoiceDeps(ctx3) {
|
|
|
648475
648609
|
}
|
|
648476
648610
|
if (typeof mod3.getVenvPython === "function") {
|
|
648477
648611
|
const { dirname: dirname56 } = await import("node:path");
|
|
648478
|
-
const { existsSync:
|
|
648612
|
+
const { existsSync: existsSync172 } = await import("node:fs");
|
|
648479
648613
|
const venvPy = mod3.getVenvPython();
|
|
648480
|
-
if (
|
|
648614
|
+
if (existsSync172(venvPy)) {
|
|
648481
648615
|
process.env.TRANSCRIBE_PYTHON = venvPy;
|
|
648482
648616
|
const venvBin = dirname56(venvPy);
|
|
648483
648617
|
const sep6 = process.platform === "win32" ? ";" : ":";
|
|
@@ -649356,10 +649490,10 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
649356
649490
|
if (!key) {
|
|
649357
649491
|
try {
|
|
649358
649492
|
const { homedir: homedir66 } = await import("node:os");
|
|
649359
|
-
const { readFileSync: readFileSync140, existsSync:
|
|
649493
|
+
const { readFileSync: readFileSync140, existsSync: existsSync172 } = await import("node:fs");
|
|
649360
649494
|
const { join: join188 } = await import("node:path");
|
|
649361
649495
|
const p2 = join188(homedir66(), ".omnius", "api.key");
|
|
649362
|
-
if (
|
|
649496
|
+
if (existsSync172(p2)) key = readFileSync140(p2, "utf8").trim();
|
|
649363
649497
|
} catch {
|
|
649364
649498
|
}
|
|
649365
649499
|
}
|
|
@@ -650262,7 +650396,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650262
650396
|
renderInfo(out.split("\n").slice(0, 4).join("\n"));
|
|
650263
650397
|
try {
|
|
650264
650398
|
const pidFile = join153(nexus.getNexusDir(), "daemon.pid");
|
|
650265
|
-
if (
|
|
650399
|
+
if (existsSync140(pidFile)) {
|
|
650266
650400
|
const pid = parseInt(readFileSync113(pidFile, "utf8").trim(), 10);
|
|
650267
650401
|
if (pid > 0 && !registry2.daemons.has("Nexus")) {
|
|
650268
650402
|
registry2.register({
|
|
@@ -650682,7 +650816,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650682
650816
|
toolDir,
|
|
650683
650817
|
shareName.endsWith(".json") ? shareName : `${shareName}.json`
|
|
650684
650818
|
);
|
|
650685
|
-
if (!
|
|
650819
|
+
if (!existsSync140(toolFile)) {
|
|
650686
650820
|
renderWarning(`Tool not found: ${toolFile}`);
|
|
650687
650821
|
return "handled";
|
|
650688
650822
|
}
|
|
@@ -650691,7 +650825,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650691
650825
|
} else if (shareType === "skill") {
|
|
650692
650826
|
const skillDir = join153(ctx3.repoRoot, ".omnius", "skills", shareName);
|
|
650693
650827
|
const skillFile = join153(skillDir, "SKILL.md");
|
|
650694
|
-
if (!
|
|
650828
|
+
if (!existsSync140(skillFile)) {
|
|
650695
650829
|
renderWarning(`Skill not found: ${skillFile}`);
|
|
650696
650830
|
return "handled";
|
|
650697
650831
|
}
|
|
@@ -650767,7 +650901,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650767
650901
|
"cid-registry",
|
|
650768
650902
|
"learning-cids.json"
|
|
650769
650903
|
);
|
|
650770
|
-
if (
|
|
650904
|
+
if (existsSync140(regFile)) {
|
|
650771
650905
|
const reg2 = JSON.parse(readFileSync113(regFile, "utf8"));
|
|
650772
650906
|
const pinned = Object.values(reg2).some(
|
|
650773
650907
|
(e2) => e2.cid === importCid && e2.pinned
|
|
@@ -650839,7 +650973,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650839
650973
|
let heliaBlocks = 0;
|
|
650840
650974
|
let heliaBytes = 0;
|
|
650841
650975
|
try {
|
|
650842
|
-
if (
|
|
650976
|
+
if (existsSync140(ipfsLocalDir)) {
|
|
650843
650977
|
const files = readdirSync46(ipfsLocalDir).filter(
|
|
650844
650978
|
(f2) => f2.endsWith(".json")
|
|
650845
650979
|
);
|
|
@@ -650852,7 +650986,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650852
650986
|
}
|
|
650853
650987
|
}
|
|
650854
650988
|
const heliaBlockDir = join153(ipfsDir, "blocks");
|
|
650855
|
-
if (
|
|
650989
|
+
if (existsSync140(heliaBlockDir)) {
|
|
650856
650990
|
const walkDir = (dir) => {
|
|
650857
650991
|
for (const entry of readdirSync46(dir, { withFileTypes: true })) {
|
|
650858
650992
|
if (entry.isDirectory()) walkDir(join153(dir, entry.name));
|
|
@@ -650885,7 +651019,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650885
651019
|
ctx3.repoRoot ?? process.cwd()
|
|
650886
651020
|
).getNexusDir();
|
|
650887
651021
|
const statusFile = join153(nexusDir, "status.json");
|
|
650888
|
-
if (
|
|
651022
|
+
if (existsSync140(statusFile)) {
|
|
650889
651023
|
const status = JSON.parse(readFileSync113(statusFile, "utf8"));
|
|
650890
651024
|
if (status.peerId) {
|
|
650891
651025
|
lines.push(`
|
|
@@ -650910,7 +651044,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650910
651044
|
const idDir = join153(ctx3.repoRoot, ".omnius", "identity");
|
|
650911
651045
|
try {
|
|
650912
651046
|
const stateFile = join153(idDir, "self-state.json");
|
|
650913
|
-
if (
|
|
651047
|
+
if (existsSync140(stateFile)) {
|
|
650914
651048
|
const state = JSON.parse(readFileSync113(stateFile, "utf8"));
|
|
650915
651049
|
lines.push(
|
|
650916
651050
|
` Version: ${c3.bold("v" + (state.version ?? "?"))} Sessions: ${c3.bold(String(state.session_count ?? 0))}`
|
|
@@ -650925,7 +651059,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650925
651059
|
lines.push(` Traits: ${c3.dim(traits.slice(0, 60))}`);
|
|
650926
651060
|
}
|
|
650927
651061
|
const cidFile = join153(idDir, "cids.json");
|
|
650928
|
-
if (
|
|
651062
|
+
if (existsSync140(cidFile)) {
|
|
650929
651063
|
const cids = JSON.parse(readFileSync113(cidFile, "utf8"));
|
|
650930
651064
|
const lastCid = Array.isArray(cids) ? cids[cids.length - 1] : cids.latest;
|
|
650931
651065
|
if (lastCid)
|
|
@@ -650950,7 +651084,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650950
651084
|
"metabolism",
|
|
650951
651085
|
"store.json"
|
|
650952
651086
|
);
|
|
650953
|
-
if (
|
|
651087
|
+
if (existsSync140(metaFile2)) {
|
|
650954
651088
|
const store2 = JSON.parse(readFileSync113(metaFile2, "utf8"));
|
|
650955
651089
|
const active = store2.filter((m2) => m2.type !== "quarantine");
|
|
650956
651090
|
const recoveries = active.filter(
|
|
@@ -650990,7 +651124,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
650990
651124
|
}
|
|
650991
651125
|
try {
|
|
650992
651126
|
const dbPath = join153(ctx3.repoRoot, ".omnius", "memory", "structured.db");
|
|
650993
|
-
if (
|
|
651127
|
+
if (existsSync140(dbPath)) {
|
|
650994
651128
|
const {
|
|
650995
651129
|
initDb: initDb2,
|
|
650996
651130
|
closeDb: cDb,
|
|
@@ -651018,7 +651152,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
651018
651152
|
${c3.bold("Storage Overview")}
|
|
651019
651153
|
`);
|
|
651020
651154
|
const omniusDir = join153(ctx3.repoRoot, ".omnius");
|
|
651021
|
-
if (!
|
|
651155
|
+
if (!existsSync140(omniusDir)) {
|
|
651022
651156
|
lines.push(` ${c3.dim("No .omnius/ directory found.")}`);
|
|
651023
651157
|
safeLog(lines.join("\n") + "\n");
|
|
651024
651158
|
return "handled";
|
|
@@ -651117,7 +651251,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
651117
651251
|
return "handled";
|
|
651118
651252
|
}
|
|
651119
651253
|
const resolvedPath = join153(ctx3.repoRoot, filePath);
|
|
651120
|
-
if (!
|
|
651254
|
+
if (!existsSync140(resolvedPath)) {
|
|
651121
651255
|
renderWarning(`File not found: ${resolvedPath}`);
|
|
651122
651256
|
return "handled";
|
|
651123
651257
|
}
|
|
@@ -651229,7 +651363,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
651229
651363
|
const fortemiSubCmd = (arg || "").trim().toLowerCase();
|
|
651230
651364
|
const fortemiDir = join153(ctx3.repoRoot, "..", "fortemi-react");
|
|
651231
651365
|
const altFortemiDir = join153(nodeOs.homedir(), "fortemi-react");
|
|
651232
|
-
const fDir =
|
|
651366
|
+
const fDir = existsSync140(fortemiDir) ? fortemiDir : existsSync140(altFortemiDir) ? altFortemiDir : null;
|
|
651233
651367
|
if (fortemiSubCmd === "start" || fortemiSubCmd === "") {
|
|
651234
651368
|
if (!fDir) {
|
|
651235
651369
|
renderWarning(
|
|
@@ -651293,7 +651427,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
651293
651427
|
}
|
|
651294
651428
|
if (fortemiSubCmd === "status") {
|
|
651295
651429
|
const bridgeFile = join153(ctx3.repoRoot, ".omnius", "fortemi-bridge.json");
|
|
651296
|
-
if (!
|
|
651430
|
+
if (!existsSync140(bridgeFile)) {
|
|
651297
651431
|
renderInfo("Fortemi bridge: not connected. Run /fortemi start");
|
|
651298
651432
|
return "handled";
|
|
651299
651433
|
}
|
|
@@ -651324,7 +651458,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
651324
651458
|
);
|
|
651325
651459
|
lines.push(` Started: ${bridge.startedAt}`);
|
|
651326
651460
|
lines.push(
|
|
651327
|
-
` JWT: ${
|
|
651461
|
+
` JWT: ${existsSync140(bridge.jwtFile) ? c3.green("valid") : c3.yellow("missing")}`
|
|
651328
651462
|
);
|
|
651329
651463
|
lines.push("");
|
|
651330
651464
|
safeLog(lines.join("\n"));
|
|
@@ -651332,7 +651466,7 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
651332
651466
|
}
|
|
651333
651467
|
if (fortemiSubCmd === "stop") {
|
|
651334
651468
|
const bridgeFile = join153(ctx3.repoRoot, ".omnius", "fortemi-bridge.json");
|
|
651335
|
-
if (
|
|
651469
|
+
if (existsSync140(bridgeFile)) {
|
|
651336
651470
|
const bridge = JSON.parse(readFileSync113(bridgeFile, "utf8"));
|
|
651337
651471
|
try {
|
|
651338
651472
|
process.kill(bridge.pid, "SIGTERM");
|
|
@@ -653359,10 +653493,10 @@ sleep 1
|
|
|
653359
653493
|
const checkedNexusDir = new NexusTool(projectDir2).getNexusDir();
|
|
653360
653494
|
_spLog(`nexusDir checked: ${checkedNexusDir}`);
|
|
653361
653495
|
_spLog(
|
|
653362
|
-
`status.json exists: ${
|
|
653496
|
+
`status.json exists: ${existsSync140(join153(checkedNexusDir, "status.json"))}`
|
|
653363
653497
|
);
|
|
653364
653498
|
_spLog(
|
|
653365
|
-
`daemon.pid exists: ${
|
|
653499
|
+
`daemon.pid exists: ${existsSync140(join153(checkedNexusDir, "daemon.pid"))}`
|
|
653366
653500
|
);
|
|
653367
653501
|
try {
|
|
653368
653502
|
const _statusRaw = readFileSync113(
|
|
@@ -653408,7 +653542,7 @@ sleep 1
|
|
|
653408
653542
|
".omnius",
|
|
653409
653543
|
"agent-name"
|
|
653410
653544
|
);
|
|
653411
|
-
if (
|
|
653545
|
+
if (existsSync140(namePath))
|
|
653412
653546
|
sponsorName = readFileSync113(namePath, "utf8").trim();
|
|
653413
653547
|
} catch {
|
|
653414
653548
|
}
|
|
@@ -653511,7 +653645,7 @@ sleep 1
|
|
|
653511
653645
|
new NexusTool(projectDir2).getNexusDir(),
|
|
653512
653646
|
"daemon.pid"
|
|
653513
653647
|
);
|
|
653514
|
-
if (
|
|
653648
|
+
if (existsSync140(nexusPidFile)) {
|
|
653515
653649
|
const nPid = parseInt(
|
|
653516
653650
|
readFileSync113(nexusPidFile, "utf8").trim(),
|
|
653517
653651
|
10
|
|
@@ -654196,7 +654330,7 @@ sleep 1
|
|
|
654196
654330
|
if (parts[0] === "disable" || parts[0] === "disabled") {
|
|
654197
654331
|
const hasGlobalFlagDisable = parts.includes("--global");
|
|
654198
654332
|
const projectRootDisable = ctx3.repoRoot || process.cwd();
|
|
654199
|
-
const projectHasOmniusDisable =
|
|
654333
|
+
const projectHasOmniusDisable = existsSync140(
|
|
654200
654334
|
join153(projectRootDisable, ".omnius")
|
|
654201
654335
|
);
|
|
654202
654336
|
const wantsLocalDisable = hasGlobalFlagDisable ? false : isLocal || projectHasOmniusDisable;
|
|
@@ -654214,7 +654348,7 @@ sleep 1
|
|
|
654214
654348
|
if (parts[0] === "enable" || parts[0] === "enabled") {
|
|
654215
654349
|
const hasGlobalFlagEnable = parts.includes("--global");
|
|
654216
654350
|
const projectRootEnable = ctx3.repoRoot || process.cwd();
|
|
654217
|
-
const projectHasOmniusEnable =
|
|
654351
|
+
const projectHasOmniusEnable = existsSync140(
|
|
654218
654352
|
join153(projectRootEnable, ".omnius")
|
|
654219
654353
|
);
|
|
654220
654354
|
const wantsLocalEnable = hasGlobalFlagEnable ? false : isLocal || projectHasOmniusEnable;
|
|
@@ -654264,7 +654398,7 @@ sleep 1
|
|
|
654264
654398
|
}
|
|
654265
654399
|
const hasGlobalFlagMode = parts.includes("--global");
|
|
654266
654400
|
const projectRootMode = ctx3.repoRoot || process.cwd();
|
|
654267
|
-
const projectHasOmniusMode =
|
|
654401
|
+
const projectHasOmniusMode = existsSync140(
|
|
654268
654402
|
join153(projectRootMode, ".omnius")
|
|
654269
654403
|
);
|
|
654270
654404
|
const wantsLocalMode = hasGlobalFlagMode ? false : isLocal || projectHasOmniusMode;
|
|
@@ -654295,7 +654429,7 @@ sleep 1
|
|
|
654295
654429
|
const limit = Math.max(1, Math.min(5, Math.floor(parsed)));
|
|
654296
654430
|
const hasGlobalFlagSubAgents = parts.includes("--global");
|
|
654297
654431
|
const projectRootSubAgents = ctx3.repoRoot || process.cwd();
|
|
654298
|
-
const projectHasOmniusSubAgents =
|
|
654432
|
+
const projectHasOmniusSubAgents = existsSync140(
|
|
654299
654433
|
join153(projectRootSubAgents, ".omnius")
|
|
654300
654434
|
);
|
|
654301
654435
|
const wantsLocalSubAgents = hasGlobalFlagSubAgents ? false : isLocal || projectHasOmniusSubAgents;
|
|
@@ -654312,7 +654446,7 @@ sleep 1
|
|
|
654312
654446
|
if (parts[0] === "model" || parts[0] === "models") {
|
|
654313
654447
|
const hasGlobalFlagModel = parts.includes("--global");
|
|
654314
654448
|
const projectRootTgModel = ctx3.repoRoot || process.cwd();
|
|
654315
|
-
const projectHasOmniusTgModel =
|
|
654449
|
+
const projectHasOmniusTgModel = existsSync140(
|
|
654316
654450
|
join153(projectRootTgModel, ".omnius")
|
|
654317
654451
|
);
|
|
654318
654452
|
const wantsLocalTgModel = hasGlobalFlagModel ? false : isLocal || projectHasOmniusTgModel;
|
|
@@ -654324,7 +654458,7 @@ sleep 1
|
|
|
654324
654458
|
if (parts[0] === "endpoint" || parts[0] === "ep") {
|
|
654325
654459
|
const hasGlobalFlagEp = parts.includes("--global");
|
|
654326
654460
|
const projectRootTgEp = ctx3.repoRoot || process.cwd();
|
|
654327
|
-
const projectHasOmniusTgEp =
|
|
654461
|
+
const projectHasOmniusTgEp = existsSync140(
|
|
654328
654462
|
join153(projectRootTgEp, ".omnius")
|
|
654329
654463
|
);
|
|
654330
654464
|
const wantsLocalTgEp = hasGlobalFlagEp ? false : isLocal || projectHasOmniusTgEp;
|
|
@@ -654688,7 +654822,7 @@ sleep 1
|
|
|
654688
654822
|
const adminIdx = parts.indexOf("--admin");
|
|
654689
654823
|
const hasGlobalFlag = parts.includes("--global");
|
|
654690
654824
|
const projectRoot = ctx3.repoRoot || process.cwd();
|
|
654691
|
-
const projectHasOmnius =
|
|
654825
|
+
const projectHasOmnius = existsSync140(join153(projectRoot, ".omnius"));
|
|
654692
654826
|
const wantsLocal = hasGlobalFlag ? false : isLocal || projectHasOmnius;
|
|
654693
654827
|
if (keyIdx !== -1 || adminIdx !== -1) {
|
|
654694
654828
|
const settings = {
|
|
@@ -654802,14 +654936,14 @@ sleep 1
|
|
|
654802
654936
|
}
|
|
654803
654937
|
try {
|
|
654804
654938
|
const startProjectRoot = ctx3.repoRoot || process.cwd();
|
|
654805
|
-
if (
|
|
654939
|
+
if (existsSync140(join153(startProjectRoot, ".omnius"))) {
|
|
654806
654940
|
const projectSettingsPath = join153(
|
|
654807
654941
|
startProjectRoot,
|
|
654808
654942
|
".omnius",
|
|
654809
654943
|
"settings.json"
|
|
654810
654944
|
);
|
|
654811
654945
|
let projectHasKey = false;
|
|
654812
|
-
if (
|
|
654946
|
+
if (existsSync140(projectSettingsPath)) {
|
|
654813
654947
|
try {
|
|
654814
654948
|
const projectJson = JSON.parse(
|
|
654815
654949
|
readFileSync113(projectSettingsPath, "utf8")
|
|
@@ -656596,7 +656730,7 @@ function directorySizeBytes2(path12, seen = /* @__PURE__ */ new Set()) {
|
|
|
656596
656730
|
}
|
|
656597
656731
|
function cachedModelDiskStats(root, model) {
|
|
656598
656732
|
const paths = cacheCandidatePaths(root, model).filter(
|
|
656599
|
-
(path12) =>
|
|
656733
|
+
(path12) => existsSync140(path12)
|
|
656600
656734
|
);
|
|
656601
656735
|
const bytes = paths.reduce((sum, path12) => sum + directorySizeBytes2(path12), 0);
|
|
656602
656736
|
return { downloaded: paths.length > 0, bytes, paths };
|
|
@@ -656607,7 +656741,7 @@ function downloadedModelSuffix(stats) {
|
|
|
656607
656741
|
function removeCachedModelPaths(root, model) {
|
|
656608
656742
|
const removed = [];
|
|
656609
656743
|
for (const path12 of cacheCandidatePaths(root, model)) {
|
|
656610
|
-
if (!
|
|
656744
|
+
if (!existsSync140(path12)) continue;
|
|
656611
656745
|
rmSync12(path12, { recursive: true, force: true });
|
|
656612
656746
|
removed.push(path12);
|
|
656613
656747
|
}
|
|
@@ -657358,7 +657492,7 @@ async function handleVideoCommand(ctx3, arg, hasLocal) {
|
|
|
657358
657492
|
const { buildImageAsciiPreview: buildImageAsciiPreview2 } = await Promise.resolve().then(() => (init_image_ascii_preview(), image_ascii_preview_exports));
|
|
657359
657493
|
const { video, thumbnail } = extractSavedVideoPath(result.output);
|
|
657360
657494
|
const thumbAbs = thumbnail ? thumbnail.startsWith("/") ? thumbnail : join153(ctx3.repoRoot, thumbnail) : video ? `${video.startsWith("/") ? video : join153(ctx3.repoRoot, video)}.png` : null;
|
|
657361
|
-
if (thumbAbs &&
|
|
657495
|
+
if (thumbAbs && existsSync140(thumbAbs)) {
|
|
657362
657496
|
const preview = await buildImageAsciiPreview2(thumbAbs);
|
|
657363
657497
|
const displayPath = video ?? thumbAbs;
|
|
657364
657498
|
if (preview) {
|
|
@@ -658185,7 +658319,7 @@ async function showCohereDashboard(ctx3) {
|
|
|
658185
658319
|
"identity",
|
|
658186
658320
|
"snapshots"
|
|
658187
658321
|
);
|
|
658188
|
-
if (
|
|
658322
|
+
if (existsSync140(snapDir)) {
|
|
658189
658323
|
const snaps = readdirSync46(snapDir).filter((f2) => f2.endsWith(".json")).sort().reverse();
|
|
658190
658324
|
const snapItems = snaps.slice(0, 20).map((f2) => ({
|
|
658191
658325
|
key: f2,
|
|
@@ -658564,6 +658698,12 @@ async function handleLiveCommand(ctx3, arg) {
|
|
|
658564
658698
|
if (sub2 === "stop" || sub2 === "off" || sub2 === "disable") {
|
|
658565
658699
|
manager.stopAll();
|
|
658566
658700
|
manager.setAgentActionSink(void 0);
|
|
658701
|
+
if (ctx3.isVoiceChatActive?.()) {
|
|
658702
|
+
try {
|
|
658703
|
+
await ctx3.voiceChatStop?.();
|
|
658704
|
+
} catch {
|
|
658705
|
+
}
|
|
658706
|
+
}
|
|
658567
658707
|
renderInfo("Live sensor streams disabled.");
|
|
658568
658708
|
return;
|
|
658569
658709
|
}
|
|
@@ -658924,6 +659064,13 @@ Previewing microphone activity...`);
|
|
|
658924
659064
|
continue;
|
|
658925
659065
|
case "stop":
|
|
658926
659066
|
manager.stopAll();
|
|
659067
|
+
manager.setAgentActionSink(void 0);
|
|
659068
|
+
if (ctx3.isVoiceChatActive?.()) {
|
|
659069
|
+
try {
|
|
659070
|
+
await ctx3.voiceChatStop?.();
|
|
659071
|
+
} catch {
|
|
659072
|
+
}
|
|
659073
|
+
}
|
|
658927
659074
|
renderInfo("Live sensor streams disabled.");
|
|
658928
659075
|
continue;
|
|
658929
659076
|
default:
|
|
@@ -660552,7 +660699,7 @@ async function discoverSponsorMediaCandidates(ctx3, modality) {
|
|
|
660552
660699
|
"sponsor",
|
|
660553
660700
|
"known-sponsors.json"
|
|
660554
660701
|
);
|
|
660555
|
-
if (
|
|
660702
|
+
if (existsSync140(knownFile)) {
|
|
660556
660703
|
const saved = JSON.parse(readFileSync113(knownFile, "utf8"));
|
|
660557
660704
|
if (Array.isArray(saved)) rawSponsors.push(...saved);
|
|
660558
660705
|
}
|
|
@@ -660702,7 +660849,7 @@ async function collectSponsorMediaStream(args) {
|
|
|
660702
660849
|
const deadline = Date.now() + 30 * 60 * 1e3;
|
|
660703
660850
|
while (!done && Date.now() < deadline) {
|
|
660704
660851
|
await new Promise((resolve76) => setTimeout(resolve76, 250));
|
|
660705
|
-
if (!
|
|
660852
|
+
if (!existsSync140(args.streamFile)) continue;
|
|
660706
660853
|
const raw = readFileSync113(args.streamFile, "utf8");
|
|
660707
660854
|
if (raw.length <= offset) continue;
|
|
660708
660855
|
pending2 += raw.slice(offset);
|
|
@@ -661025,7 +661172,7 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
661025
661172
|
const sponsorDir2 = join153(ctx3.repoRoot ?? process.cwd(), ".omnius", "sponsor");
|
|
661026
661173
|
const knownFile = join153(sponsorDir2, "known-sponsors.json");
|
|
661027
661174
|
try {
|
|
661028
|
-
if (
|
|
661175
|
+
if (existsSync140(knownFile)) {
|
|
661029
661176
|
const saved = JSON.parse(
|
|
661030
661177
|
readFileSync113(knownFile, "utf8")
|
|
661031
661178
|
);
|
|
@@ -661203,7 +661350,7 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
661203
661350
|
const saveKey = selected.url || selected.peerId || selected.name;
|
|
661204
661351
|
try {
|
|
661205
661352
|
mkdirSync84(sponsorDir2, { recursive: true });
|
|
661206
|
-
const existing =
|
|
661353
|
+
const existing = existsSync140(knownFile) ? JSON.parse(readFileSync113(knownFile, "utf8")) : [];
|
|
661207
661354
|
const updated = existing.filter(
|
|
661208
661355
|
(s2) => (s2.url || s2.peerId || s2.name) !== saveKey
|
|
661209
661356
|
);
|
|
@@ -662409,7 +662556,7 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
662409
662556
|
const { createRequire: createRequire11 } = await import("node:module");
|
|
662410
662557
|
const { fileURLToPath: fileURLToPath26 } = await import("node:url");
|
|
662411
662558
|
const { dirname: dirname56, join: join188 } = await import("node:path");
|
|
662412
|
-
const { existsSync:
|
|
662559
|
+
const { existsSync: existsSync172 } = await import("node:fs");
|
|
662413
662560
|
const req3 = createRequire11(import.meta.url);
|
|
662414
662561
|
const thisDir = dirname56(fileURLToPath26(import.meta.url));
|
|
662415
662562
|
const candidates = [
|
|
@@ -662418,7 +662565,7 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
662418
662565
|
join188(thisDir, "..", "..", "..", "package.json")
|
|
662419
662566
|
];
|
|
662420
662567
|
for (const pkgPath of candidates) {
|
|
662421
|
-
if (
|
|
662568
|
+
if (existsSync172(pkgPath)) {
|
|
662422
662569
|
const pkg = req3(pkgPath);
|
|
662423
662570
|
if (pkg.name === "omnius" || pkg.name === "@omnius/cli") {
|
|
662424
662571
|
currentVersion = pkg.version ?? "0.0.0";
|
|
@@ -664309,7 +664456,7 @@ var init_commands = __esm({
|
|
|
664309
664456
|
});
|
|
664310
664457
|
|
|
664311
664458
|
// packages/cli/src/tui/project-context.ts
|
|
664312
|
-
import { existsSync as
|
|
664459
|
+
import { existsSync as existsSync141, readFileSync as readFileSync114, readdirSync as readdirSync47, mkdirSync as mkdirSync85, statSync as statSync54, writeFileSync as writeFileSync73 } from "node:fs";
|
|
664313
664460
|
import { dirname as dirname47, join as join154, basename as basename29, resolve as resolve62 } from "node:path";
|
|
664314
664461
|
import { homedir as homedir53 } from "node:os";
|
|
664315
664462
|
function projectContextUrlSpanAt(text2, index) {
|
|
@@ -664358,7 +664505,7 @@ function loadProjectMap(repoRoot) {
|
|
|
664358
664505
|
initOmniusDirectory(repoRoot);
|
|
664359
664506
|
}
|
|
664360
664507
|
const mapPath2 = join154(repoRoot, OMNIUS_DIR, "context", "project-map.md");
|
|
664361
|
-
if (
|
|
664508
|
+
if (existsSync141(mapPath2)) {
|
|
664362
664509
|
try {
|
|
664363
664510
|
const content = readFileSync114(mapPath2, "utf-8");
|
|
664364
664511
|
return content;
|
|
@@ -664371,7 +664518,7 @@ function findGitDir(repoRoot) {
|
|
|
664371
664518
|
let dir = resolve62(repoRoot);
|
|
664372
664519
|
for (; ; ) {
|
|
664373
664520
|
const gitPath = join154(dir, ".git");
|
|
664374
|
-
if (
|
|
664521
|
+
if (existsSync141(gitPath)) {
|
|
664375
664522
|
try {
|
|
664376
664523
|
const raw = readFileSync114(gitPath, "utf8").trim();
|
|
664377
664524
|
const match = raw.match(/^gitdir:\s*(.+)$/i);
|
|
@@ -664409,7 +664556,7 @@ function getGitInfo(repoRoot) {
|
|
|
664409
664556
|
}
|
|
664410
664557
|
try {
|
|
664411
664558
|
const indexPath = join154(gitDir, "index");
|
|
664412
|
-
if (
|
|
664559
|
+
if (existsSync141(indexPath)) lines.push("Working tree: status not probed during prompt assembly");
|
|
664413
664560
|
} catch {
|
|
664414
664561
|
}
|
|
664415
664562
|
return lines.join("\n");
|
|
@@ -664418,7 +664565,7 @@ function emptyMemoryContextBundle() {
|
|
|
664418
664565
|
return { text: "", memoryPrefix: "", prefixHash: "" };
|
|
664419
664566
|
}
|
|
664420
664567
|
function countJsonMemoryEntries(dir) {
|
|
664421
|
-
if (!
|
|
664568
|
+
if (!existsSync141(dir)) return { topics: 0, entries: 0 };
|
|
664422
664569
|
let topics = 0;
|
|
664423
664570
|
let entries = 0;
|
|
664424
664571
|
try {
|
|
@@ -664440,7 +664587,7 @@ function countJsonMemoryEntries(dir) {
|
|
|
664440
664587
|
}
|
|
664441
664588
|
function countReflectionBuffer(repoRoot) {
|
|
664442
664589
|
const path12 = join154(repoRoot, OMNIUS_DIR, "memory", "reflections.json");
|
|
664443
|
-
if (!
|
|
664590
|
+
if (!existsSync141(path12)) return 0;
|
|
664444
664591
|
try {
|
|
664445
664592
|
const parsed = JSON.parse(readFileSync114(path12, "utf8"));
|
|
664446
664593
|
return Array.isArray(parsed.reflections) ? parsed.reflections.length : 0;
|
|
@@ -664449,7 +664596,7 @@ function countReflectionBuffer(repoRoot) {
|
|
|
664449
664596
|
}
|
|
664450
664597
|
}
|
|
664451
664598
|
function countJsonlLines(path12, maxBytes = 1e6) {
|
|
664452
|
-
if (!
|
|
664599
|
+
if (!existsSync141(path12)) return 0;
|
|
664453
664600
|
try {
|
|
664454
664601
|
const text2 = readFileSync114(path12, "utf8").slice(-maxBytes);
|
|
664455
664602
|
return text2.split(/\r?\n/).filter((line) => line.trim()).length;
|
|
@@ -664465,9 +664612,9 @@ function buildWorkspaceMemorySubstrateCensus(repoRoot) {
|
|
|
664465
664612
|
const globalMemory = countJsonMemoryEntries(join154(homedir53(), ".omnius", "memory"));
|
|
664466
664613
|
const reflectionCount = countReflectionBuffer(repoRoot);
|
|
664467
664614
|
const evidenceCount = countJsonlLines(join154(repoRoot, ".omnius", "evidence", "events.jsonl"));
|
|
664468
|
-
const unifiedPresent =
|
|
664469
|
-
const episodesPresent =
|
|
664470
|
-
const knowledgePresent =
|
|
664615
|
+
const unifiedPresent = existsSync141(join154(repoRoot, OMNIUS_DIR, "unified-memory.db"));
|
|
664616
|
+
const episodesPresent = existsSync141(join154(repoRoot, OMNIUS_DIR, "episodes.db"));
|
|
664617
|
+
const knowledgePresent = existsSync141(join154(repoRoot, OMNIUS_DIR, "knowledge.db"));
|
|
664471
664618
|
const topicCount = projectMemory.topics + legacyMemory.topics + globalMemory.topics;
|
|
664472
664619
|
const entryCount = projectMemory.entries + legacyMemory.entries + globalMemory.entries;
|
|
664473
664620
|
const hasMemory = topicCount + entryCount + reflectionCount + evidenceCount > 0 || unifiedPresent || episodesPresent || knowledgePresent;
|
|
@@ -664490,7 +664637,7 @@ function loadMemoryContextBundle(repoRoot, task = "", taskEmbedding) {
|
|
|
664490
664637
|
if (unified.text) return unified;
|
|
664491
664638
|
const all2 = [];
|
|
664492
664639
|
const collect = (dir, scope) => {
|
|
664493
|
-
if (!
|
|
664640
|
+
if (!existsSync141(dir)) return;
|
|
664494
664641
|
try {
|
|
664495
664642
|
const files = readdirSync47(dir).filter((f2) => f2.endsWith(".json"));
|
|
664496
664643
|
for (const file of files.slice(0, 10)) {
|
|
@@ -664602,7 +664749,7 @@ function loadMemoryContextBundle(repoRoot, task = "", taskEmbedding) {
|
|
|
664602
664749
|
}
|
|
664603
664750
|
function loadUnifiedMemoryContextBundle(repoRoot, task = "", taskEmbedding) {
|
|
664604
664751
|
const dbPath = join154(repoRoot, OMNIUS_DIR, "unified-memory.db");
|
|
664605
|
-
if (!
|
|
664752
|
+
if (!existsSync141(dbPath)) return emptyMemoryContextBundle();
|
|
664606
664753
|
let db = null;
|
|
664607
664754
|
try {
|
|
664608
664755
|
db = initDb(dbPath);
|
|
@@ -664921,9 +665068,9 @@ function inspectPythonBootstrap(repoRoot, task = "") {
|
|
|
664921
665068
|
const rootEntries = safeReadDir(repoRoot);
|
|
664922
665069
|
const scriptsEntries = safeReadDir(join154(repoRoot, "scripts"));
|
|
664923
665070
|
const binEntries = safeReadDir(join154(repoRoot, "bin"));
|
|
664924
|
-
const relExists = (rel) =>
|
|
665071
|
+
const relExists = (rel) => existsSync141(join154(repoRoot, rel));
|
|
664925
665072
|
const venvs = [".venv", "venv", "env"].filter((rel) => isDirectory2(join154(repoRoot, rel))).filter(
|
|
664926
|
-
(rel) =>
|
|
665073
|
+
(rel) => existsSync141(join154(repoRoot, rel, process.platform === "win32" ? "Scripts" : "bin")) || existsSync141(join154(repoRoot, rel, "pyvenv.cfg"))
|
|
664927
665074
|
);
|
|
664928
665075
|
const requirements = rootEntries.filter((name10) => /^requirements(?:[-_.][A-Za-z0-9_-]+)?\.txt$/.test(name10)).sort();
|
|
664929
665076
|
const managers2 = [
|
|
@@ -664982,7 +665129,7 @@ function findBootstrapEntries(entries, prefix) {
|
|
|
664982
665129
|
).map((name10) => prefix ? `${prefix}/${name10}` : name10).sort();
|
|
664983
665130
|
}
|
|
664984
665131
|
function extractMakeBootstrapTargets(repoRoot) {
|
|
664985
|
-
const makefile = ["Makefile", "makefile"].find((name10) =>
|
|
665132
|
+
const makefile = ["Makefile", "makefile"].find((name10) => existsSync141(join154(repoRoot, name10)));
|
|
664986
665133
|
if (!makefile) return [];
|
|
664987
665134
|
try {
|
|
664988
665135
|
const text2 = readFileSync114(join154(repoRoot, makefile), "utf8");
|
|
@@ -665128,7 +665275,7 @@ function loadCustomToolsContext(repoRoot) {
|
|
|
665128
665275
|
try {
|
|
665129
665276
|
const registryPath = join154(repoRoot, ".omnius", "tools", "registry.json");
|
|
665130
665277
|
const indexPath = join154(repoRoot, ".omnius", "tools", "README.md");
|
|
665131
|
-
if (!
|
|
665278
|
+
if (!existsSync141(registryPath)) return "";
|
|
665132
665279
|
const registry4 = JSON.parse(readFileSync114(registryPath, "utf-8"));
|
|
665133
665280
|
const tools = (registry4.tools ?? []).filter((tool) => tool.qualityGate?.lastTest?.status === "passed").sort((a2, b) => {
|
|
665134
665281
|
const byRate = (b.analytics?.successRate ?? 0) - (a2.analytics?.successRate ?? 0);
|
|
@@ -665144,7 +665291,7 @@ function loadCustomToolsContext(repoRoot) {
|
|
|
665144
665291
|
const bits = [
|
|
665145
665292
|
`- ${tool.name} v${tool.version ?? 1}: ${truncateProjectContextText(String(tool.description ?? ""), 140, "")}`,
|
|
665146
665293
|
`docs=${tool.docsPath ?? "missing"}`,
|
|
665147
|
-
|
|
665294
|
+
existsSync141(indexPath) ? `index=${indexPath}` : "",
|
|
665148
665295
|
`test=${tested}${schema ? `, schema=${schema}` : ""}`,
|
|
665149
665296
|
`success=${successRate}`,
|
|
665150
665297
|
example?.args ? `example=${tool.name}(${JSON.stringify(example.args)})` : "",
|
|
@@ -665305,7 +665452,7 @@ var init_project_context = __esm({
|
|
|
665305
665452
|
});
|
|
665306
665453
|
|
|
665307
665454
|
// packages/cli/src/realtime.ts
|
|
665308
|
-
import { existsSync as
|
|
665455
|
+
import { existsSync as existsSync142, readFileSync as readFileSync115, readdirSync as readdirSync48 } from "node:fs";
|
|
665309
665456
|
import { basename as basename30, join as join155, resolve as resolve63 } from "node:path";
|
|
665310
665457
|
function clampInt2(value2, fallback, min, max) {
|
|
665311
665458
|
const n2 = typeof value2 === "number" ? value2 : Number.parseInt(String(value2 ?? ""), 10);
|
|
@@ -665325,7 +665472,7 @@ function blockText2(text2, limit) {
|
|
|
665325
665472
|
}
|
|
665326
665473
|
function firstReadable(candidates) {
|
|
665327
665474
|
for (const path12 of candidates) {
|
|
665328
|
-
if (!
|
|
665475
|
+
if (!existsSync142(path12)) continue;
|
|
665329
665476
|
try {
|
|
665330
665477
|
return { path: path12, content: readFileSync115(path12, "utf8") };
|
|
665331
665478
|
} catch {
|
|
@@ -665342,7 +665489,7 @@ function projectSoul(repoRoot) {
|
|
|
665342
665489
|
}
|
|
665343
665490
|
function projectVoice(repoRoot) {
|
|
665344
665491
|
const voiceDir3 = resolve63(repoRoot, ".aiwg", "voices");
|
|
665345
|
-
if (!
|
|
665492
|
+
if (!existsSync142(voiceDir3)) return null;
|
|
665346
665493
|
try {
|
|
665347
665494
|
const files = readdirSync48(voiceDir3).filter((name10) => name10.endsWith(".yaml") || name10.endsWith(".yml")).sort((a2, b) => {
|
|
665348
665495
|
const ap = a2 === "default.yaml" || a2 === "default.yml" || a2 === "omnius.yaml" || a2 === "omnius.yml" ? 0 : 1;
|
|
@@ -665537,7 +665684,7 @@ __export(chat_session_exports, {
|
|
|
665537
665684
|
});
|
|
665538
665685
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
665539
665686
|
import {
|
|
665540
|
-
existsSync as
|
|
665687
|
+
existsSync as existsSync143,
|
|
665541
665688
|
readFileSync as readFileSync116,
|
|
665542
665689
|
readdirSync as readdirSync49,
|
|
665543
665690
|
writeFileSync as writeFileSync74,
|
|
@@ -665582,7 +665729,7 @@ function persistInFlight(j) {
|
|
|
665582
665729
|
function deleteInFlightFile(id2) {
|
|
665583
665730
|
try {
|
|
665584
665731
|
const p2 = inFlightPath(id2);
|
|
665585
|
-
if (
|
|
665732
|
+
if (existsSync143(p2)) unlinkSync29(p2);
|
|
665586
665733
|
} catch {
|
|
665587
665734
|
}
|
|
665588
665735
|
}
|
|
@@ -665659,7 +665806,7 @@ function allKnownSessions() {
|
|
|
665659
665806
|
for (const s2 of sessions2.values()) merged.set(s2.id, normalizeLoadedSession(s2));
|
|
665660
665807
|
try {
|
|
665661
665808
|
const dir = sessionsDir();
|
|
665662
|
-
if (
|
|
665809
|
+
if (existsSync143(dir)) {
|
|
665663
665810
|
for (const f2 of readdirSync49(dir)) {
|
|
665664
665811
|
if (!f2.endsWith(".json") || f2.endsWith(".inflight.json") || f2.includes(".tmp.")) continue;
|
|
665665
665812
|
const loaded = readSessionFile(join156(dir, f2));
|
|
@@ -665674,7 +665821,7 @@ function loadPersistedSessions() {
|
|
|
665674
665821
|
const report2 = { restored: 0, staleInFlight: 0 };
|
|
665675
665822
|
try {
|
|
665676
665823
|
const dir = sessionsDir();
|
|
665677
|
-
if (!
|
|
665824
|
+
if (!existsSync143(dir)) return report2;
|
|
665678
665825
|
const cutoff = Date.now() - SESSION_TTL_MS;
|
|
665679
665826
|
for (const f2 of readdirSync49(dir)) {
|
|
665680
665827
|
if (!f2.endsWith(".json") || f2.includes(".tmp.")) continue;
|
|
@@ -665720,7 +665867,7 @@ function buildSystemPrompt(cwd4) {
|
|
|
665720
665867
|
`\\nEnvironment: ${process.platform}, Node ${process.version}, CWD: ${cwd4}`
|
|
665721
665868
|
);
|
|
665722
665869
|
const diaryPath = join156(cwd4, ".omnius", "context", "session-diary.md");
|
|
665723
|
-
if (
|
|
665870
|
+
if (existsSync143(diaryPath)) {
|
|
665724
665871
|
try {
|
|
665725
665872
|
const diary = readFileSync116(diaryPath, "utf-8").slice(0, 1e3);
|
|
665726
665873
|
parts.push(`\\nPrevious session history:\\n${diary}`);
|
|
@@ -665728,7 +665875,7 @@ function buildSystemPrompt(cwd4) {
|
|
|
665728
665875
|
}
|
|
665729
665876
|
}
|
|
665730
665877
|
const memDir = join156(cwd4, ".omnius", "memory");
|
|
665731
|
-
if (
|
|
665878
|
+
if (existsSync143(memDir)) {
|
|
665732
665879
|
try {
|
|
665733
665880
|
const files = readdirSync49(memDir).filter((f2) => f2.endsWith(".json")).slice(0, 5);
|
|
665734
665881
|
if (files.length > 0) {
|
|
@@ -665755,7 +665902,7 @@ function buildSystemPrompt(cwd4) {
|
|
|
665755
665902
|
}
|
|
665756
665903
|
for (const name10 of ["AGENTS.md", "Omnius.md", ".omnius.md"]) {
|
|
665757
665904
|
const p2 = join156(cwd4, name10);
|
|
665758
|
-
if (
|
|
665905
|
+
if (existsSync143(p2)) {
|
|
665759
665906
|
try {
|
|
665760
665907
|
const content = readFileSync116(p2, "utf-8").slice(0, 500);
|
|
665761
665908
|
parts.push(`\\nProject instructions (${name10}):\\n${content}`);
|
|
@@ -665778,7 +665925,7 @@ function getSession2(sessionId, model, cwd4) {
|
|
|
665778
665925
|
if (sessionId) {
|
|
665779
665926
|
try {
|
|
665780
665927
|
const fp = sessionPath(sessionId);
|
|
665781
|
-
if (
|
|
665928
|
+
if (existsSync143(fp)) {
|
|
665782
665929
|
const parsed = normalizeLoadedSession(JSON.parse(readFileSync116(fp, "utf-8")));
|
|
665783
665930
|
if (parsed && parsed.id === sessionId) {
|
|
665784
665931
|
parsed.lastActivity = Date.now();
|
|
@@ -665964,7 +666111,7 @@ function appendCheckin(sessionId, steering) {
|
|
|
665964
666111
|
}
|
|
665965
666112
|
function drainCheckins(sessionId) {
|
|
665966
666113
|
const fp = checkinPath(sessionId);
|
|
665967
|
-
if (!
|
|
666114
|
+
if (!existsSync143(fp)) return [];
|
|
665968
666115
|
try {
|
|
665969
666116
|
const raw = readFileSync116(fp, "utf-8");
|
|
665970
666117
|
try {
|
|
@@ -666015,7 +666162,7 @@ function deleteSession2(id2) {
|
|
|
666015
666162
|
let removed = false;
|
|
666016
666163
|
try {
|
|
666017
666164
|
const p2 = sessionPath(id2);
|
|
666018
|
-
if (
|
|
666165
|
+
if (existsSync143(p2)) {
|
|
666019
666166
|
unlinkSync29(p2);
|
|
666020
666167
|
removed = true;
|
|
666021
666168
|
}
|
|
@@ -666031,7 +666178,7 @@ function lookupSession(id2) {
|
|
|
666031
666178
|
if (cached) return cached;
|
|
666032
666179
|
try {
|
|
666033
666180
|
const fp = sessionPath(id2);
|
|
666034
|
-
if (
|
|
666181
|
+
if (existsSync143(fp)) {
|
|
666035
666182
|
const parsed = normalizeLoadedSession(JSON.parse(readFileSync116(fp, "utf-8")));
|
|
666036
666183
|
if (parsed && parsed.id === id2) {
|
|
666037
666184
|
sessions2.set(id2, parsed);
|
|
@@ -666084,7 +666231,7 @@ function getInFlightChat(sessionId) {
|
|
|
666084
666231
|
if (cached) return cached;
|
|
666085
666232
|
try {
|
|
666086
666233
|
const p2 = inFlightPath(sessionId);
|
|
666087
|
-
if (
|
|
666234
|
+
if (existsSync143(p2)) {
|
|
666088
666235
|
const parsed = JSON.parse(readFileSync116(p2, "utf-8"));
|
|
666089
666236
|
if (parsed && parsed.sessionId === sessionId) {
|
|
666090
666237
|
return parsed;
|
|
@@ -666656,7 +666803,7 @@ var init_visual_identity_association = __esm({
|
|
|
666656
666803
|
});
|
|
666657
666804
|
|
|
666658
666805
|
// packages/cli/src/tui/identity-memory-tool.ts
|
|
666659
|
-
import { existsSync as
|
|
666806
|
+
import { existsSync as existsSync144 } from "node:fs";
|
|
666660
666807
|
import { basename as basename32, extname as extname19, resolve as resolve65 } from "node:path";
|
|
666661
666808
|
function personKey2(name10) {
|
|
666662
666809
|
return `person:${name10.trim().toLowerCase().replace(/\s+/g, " ")}`;
|
|
@@ -666719,7 +666866,7 @@ async function resolveMediaFromArgs(args, opts) {
|
|
|
666719
666866
|
return null;
|
|
666720
666867
|
}
|
|
666721
666868
|
const path12 = resolve65(ref);
|
|
666722
|
-
if (!
|
|
666869
|
+
if (!existsSync144(path12)) return null;
|
|
666723
666870
|
const mediaType = inferMediaTypeFromPath(path12);
|
|
666724
666871
|
const media = { path: path12, mediaType };
|
|
666725
666872
|
return {
|
|
@@ -667490,7 +667637,7 @@ __export(banner_exports, {
|
|
|
667490
667637
|
setBannerWriter: () => setBannerWriter,
|
|
667491
667638
|
setGridText: () => setGridText
|
|
667492
667639
|
});
|
|
667493
|
-
import { existsSync as
|
|
667640
|
+
import { existsSync as existsSync145, readFileSync as readFileSync117, writeFileSync as writeFileSync75, mkdirSync as mkdirSync87 } from "node:fs";
|
|
667494
667641
|
import { join as join157 } from "node:path";
|
|
667495
667642
|
function setBannerWriter(writer) {
|
|
667496
667643
|
chromeWrite3 = writer;
|
|
@@ -667630,7 +667777,7 @@ function saveBannerDesign(workDir, design) {
|
|
|
667630
667777
|
}
|
|
667631
667778
|
function loadBannerDesign(workDir, id2) {
|
|
667632
667779
|
const file = join157(workDir, ".omnius", "banners", `${id2}.json`);
|
|
667633
|
-
if (!
|
|
667780
|
+
if (!existsSync145(file)) return null;
|
|
667634
667781
|
try {
|
|
667635
667782
|
return JSON.parse(readFileSync117(file, "utf8"));
|
|
667636
667783
|
} catch {
|
|
@@ -667639,7 +667786,7 @@ function loadBannerDesign(workDir, id2) {
|
|
|
667639
667786
|
}
|
|
667640
667787
|
function listBannerDesigns(workDir) {
|
|
667641
667788
|
const dir = join157(workDir, ".omnius", "banners");
|
|
667642
|
-
if (!
|
|
667789
|
+
if (!existsSync145(dir)) return [];
|
|
667643
667790
|
try {
|
|
667644
667791
|
const { readdirSync: readdirSync61 } = __require("node:fs");
|
|
667645
667792
|
return readdirSync61(dir).filter((f2) => f2.endsWith(".json")).map((f2) => f2.replace(".json", ""));
|
|
@@ -667962,12 +668109,12 @@ var init_banner = __esm({
|
|
|
667962
668109
|
});
|
|
667963
668110
|
|
|
667964
668111
|
// packages/cli/src/tui/carousel-descriptors.ts
|
|
667965
|
-
import { existsSync as
|
|
668112
|
+
import { existsSync as existsSync146, readFileSync as readFileSync118, writeFileSync as writeFileSync76, mkdirSync as mkdirSync88, readdirSync as readdirSync50 } from "node:fs";
|
|
667966
668113
|
import { join as join158, basename as basename33 } from "node:path";
|
|
667967
668114
|
function loadToolProfile(repoRoot) {
|
|
667968
668115
|
const filePath = join158(repoRoot, OMNIUS_DIR, "context", TOOL_PROFILE_FILE);
|
|
667969
668116
|
try {
|
|
667970
|
-
if (!
|
|
668117
|
+
if (!existsSync146(filePath)) return null;
|
|
667971
668118
|
return JSON.parse(readFileSync118(filePath, "utf-8"));
|
|
667972
668119
|
} catch {
|
|
667973
668120
|
return null;
|
|
@@ -668033,7 +668180,7 @@ function weightedColor(profile) {
|
|
|
668033
668180
|
function loadCachedDescriptors(repoRoot) {
|
|
668034
668181
|
const filePath = join158(repoRoot, OMNIUS_DIR, "context", DESCRIPTOR_FILE);
|
|
668035
668182
|
try {
|
|
668036
|
-
if (!
|
|
668183
|
+
if (!existsSync146(filePath)) return null;
|
|
668037
668184
|
const cached = JSON.parse(readFileSync118(filePath, "utf-8"));
|
|
668038
668185
|
return cached.phrases.length > 0 ? cached.phrases : null;
|
|
668039
668186
|
} catch {
|
|
@@ -668097,7 +668244,7 @@ function generateDescriptors(repoRoot) {
|
|
|
668097
668244
|
function extractFromPackageJson(repoRoot, tags) {
|
|
668098
668245
|
const pkgPath = join158(repoRoot, "package.json");
|
|
668099
668246
|
try {
|
|
668100
|
-
if (!
|
|
668247
|
+
if (!existsSync146(pkgPath)) return;
|
|
668101
668248
|
const pkg = JSON.parse(readFileSync118(pkgPath, "utf-8"));
|
|
668102
668249
|
if (pkg.name && typeof pkg.name === "string") {
|
|
668103
668250
|
const parts = pkg.name.replace(/^@/, "").split("/");
|
|
@@ -668139,7 +668286,7 @@ function extractFromManifests(repoRoot, tags) {
|
|
|
668139
668286
|
{ file: ".github/workflows", tag: "ci/cd" }
|
|
668140
668287
|
];
|
|
668141
668288
|
for (const check of manifestChecks) {
|
|
668142
|
-
if (
|
|
668289
|
+
if (existsSync146(join158(repoRoot, check.file))) {
|
|
668143
668290
|
tags.push(check.tag);
|
|
668144
668291
|
}
|
|
668145
668292
|
}
|
|
@@ -668163,7 +668310,7 @@ function extractFromSessions(repoRoot, tags) {
|
|
|
668163
668310
|
function extractFromMemory(repoRoot, tags) {
|
|
668164
668311
|
const memoryDir = join158(repoRoot, OMNIUS_DIR, "memory");
|
|
668165
668312
|
try {
|
|
668166
|
-
if (!
|
|
668313
|
+
if (!existsSync146(memoryDir)) return;
|
|
668167
668314
|
const files = readdirSync50(memoryDir).filter((f2) => f2.endsWith(".json"));
|
|
668168
668315
|
for (const file of files) {
|
|
668169
668316
|
const topic = file.replace(/\.json$/, "").replace(/[-_]/g, " ");
|
|
@@ -669212,7 +669359,7 @@ var init_edit_history = __esm({
|
|
|
669212
669359
|
});
|
|
669213
669360
|
|
|
669214
669361
|
// packages/cli/src/tui/snr-engine.ts
|
|
669215
|
-
import { existsSync as
|
|
669362
|
+
import { existsSync as existsSync147, readdirSync as readdirSync51, readFileSync as readFileSync119, writeFileSync as writeFileSync77, mkdirSync as mkdirSync90, rmSync as rmSync13 } from "node:fs";
|
|
669216
669363
|
import { join as join160, basename as basename34 } from "node:path";
|
|
669217
669364
|
function computeDPrime(signalScores, noiseScores) {
|
|
669218
669365
|
if (signalScores.length === 0 || noiseScores.length === 0) return 0;
|
|
@@ -669512,7 +669659,7 @@ Call task_complete with the JSON array when done.`,
|
|
|
669512
669659
|
join160(this.repoRoot, ".omnius", "memory")
|
|
669513
669660
|
])];
|
|
669514
669661
|
for (const dir of dirs) {
|
|
669515
|
-
if (!
|
|
669662
|
+
if (!existsSync147(dir)) continue;
|
|
669516
669663
|
try {
|
|
669517
669664
|
const files = readdirSync51(dir).filter((f2) => f2.endsWith(".json"));
|
|
669518
669665
|
for (const f2 of files) {
|
|
@@ -669619,7 +669766,7 @@ Call task_complete with the JSON array when done.`,
|
|
|
669619
669766
|
const touchedTopics = [];
|
|
669620
669767
|
for (const [topic, keys] of byTopic) {
|
|
669621
669768
|
const file = join160(memDir, `${topic}.json`);
|
|
669622
|
-
if (!
|
|
669769
|
+
if (!existsSync147(file)) continue;
|
|
669623
669770
|
try {
|
|
669624
669771
|
const data = JSON.parse(readFileSync119(file, "utf-8"));
|
|
669625
669772
|
const moved = {};
|
|
@@ -669634,7 +669781,7 @@ Call task_complete with the JSON array when done.`,
|
|
|
669634
669781
|
mkdirSync90(archiveDir, { recursive: true });
|
|
669635
669782
|
const archiveFile = join160(archiveDir, `${topic}.json`);
|
|
669636
669783
|
let archiveData = {};
|
|
669637
|
-
if (
|
|
669784
|
+
if (existsSync147(archiveFile)) {
|
|
669638
669785
|
try {
|
|
669639
669786
|
archiveData = JSON.parse(readFileSync119(archiveFile, "utf-8"));
|
|
669640
669787
|
} catch {
|
|
@@ -669675,14 +669822,14 @@ Call task_complete with the JSON array when done.`,
|
|
|
669675
669822
|
});
|
|
669676
669823
|
|
|
669677
669824
|
// packages/cli/src/tui/promptLoader.ts
|
|
669678
|
-
import { readFileSync as readFileSync120, existsSync as
|
|
669825
|
+
import { readFileSync as readFileSync120, existsSync as existsSync148 } from "node:fs";
|
|
669679
669826
|
import { join as join161, dirname as dirname49 } from "node:path";
|
|
669680
669827
|
import { fileURLToPath as fileURLToPath21 } from "node:url";
|
|
669681
669828
|
function loadPrompt3(promptPath, vars) {
|
|
669682
669829
|
let content = cache7.get(promptPath);
|
|
669683
669830
|
if (content === void 0) {
|
|
669684
669831
|
const fullPath = join161(PROMPTS_DIR3, promptPath);
|
|
669685
|
-
if (!
|
|
669832
|
+
if (!existsSync148(fullPath)) {
|
|
669686
669833
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
669687
669834
|
}
|
|
669688
669835
|
content = readFileSync120(fullPath, "utf-8");
|
|
@@ -669699,13 +669846,13 @@ var init_promptLoader3 = __esm({
|
|
|
669699
669846
|
__dirname6 = dirname49(__filename5);
|
|
669700
669847
|
devPath2 = join161(__dirname6, "..", "..", "prompts");
|
|
669701
669848
|
publishedPath2 = join161(__dirname6, "..", "prompts");
|
|
669702
|
-
PROMPTS_DIR3 =
|
|
669849
|
+
PROMPTS_DIR3 = existsSync148(devPath2) ? devPath2 : publishedPath2;
|
|
669703
669850
|
cache7 = /* @__PURE__ */ new Map();
|
|
669704
669851
|
}
|
|
669705
669852
|
});
|
|
669706
669853
|
|
|
669707
669854
|
// packages/cli/src/tui/dream-engine.ts
|
|
669708
|
-
import { mkdirSync as mkdirSync91, writeFileSync as writeFileSync78, readFileSync as readFileSync121, existsSync as
|
|
669855
|
+
import { mkdirSync as mkdirSync91, writeFileSync as writeFileSync78, readFileSync as readFileSync121, existsSync as existsSync149, readdirSync as readdirSync52 } from "node:fs";
|
|
669709
669856
|
import { join as join162, basename as basename35 } from "node:path";
|
|
669710
669857
|
function setDreamWriteContent(fn) {
|
|
669711
669858
|
_dreamWriteContent = fn;
|
|
@@ -669719,7 +669866,7 @@ function dreamWrite(fn) {
|
|
|
669719
669866
|
}
|
|
669720
669867
|
function loadAutoresearchMemory(repoRoot) {
|
|
669721
669868
|
const memoryPath = join162(repoRoot, ".omnius", "memory", "autoresearch.json");
|
|
669722
|
-
if (!
|
|
669869
|
+
if (!existsSync149(memoryPath)) return "";
|
|
669723
669870
|
try {
|
|
669724
669871
|
const raw = readFileSync121(memoryPath, "utf-8");
|
|
669725
669872
|
const data = JSON.parse(raw);
|
|
@@ -669953,7 +670100,7 @@ var init_dream_engine = __esm({
|
|
|
669953
670100
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .omnius/autoresearch/", durationMs: Date.now() - start2 };
|
|
669954
670101
|
}
|
|
669955
670102
|
try {
|
|
669956
|
-
if (!
|
|
670103
|
+
if (!existsSync149(targetPath)) {
|
|
669957
670104
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
|
|
669958
670105
|
}
|
|
669959
670106
|
let content = readFileSync121(targetPath, "utf-8");
|
|
@@ -670041,7 +670188,7 @@ var init_dream_engine = __esm({
|
|
|
670041
670188
|
return { success: false, output: "", error: "Dream mode: edits are confined to .omnius/dreams/", durationMs: Date.now() - start2 };
|
|
670042
670189
|
}
|
|
670043
670190
|
try {
|
|
670044
|
-
if (!
|
|
670191
|
+
if (!existsSync149(targetPath)) {
|
|
670045
670192
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
|
|
670046
670193
|
}
|
|
670047
670194
|
let content = readFileSync121(targetPath, "utf-8");
|
|
@@ -671007,7 +671154,7 @@ ${summary}` };
|
|
|
671007
671154
|
const action = args["action"] || "list";
|
|
671008
671155
|
try {
|
|
671009
671156
|
let notes = [];
|
|
671010
|
-
if (
|
|
671157
|
+
if (existsSync149(notesPath)) {
|
|
671011
671158
|
notes = JSON.parse(readFileSync121(notesPath, "utf-8"));
|
|
671012
671159
|
}
|
|
671013
671160
|
if (action === "add") {
|
|
@@ -671648,7 +671795,7 @@ var init_bless_engine = __esm({
|
|
|
671648
671795
|
});
|
|
671649
671796
|
|
|
671650
671797
|
// packages/cli/src/tui/dmn-engine.ts
|
|
671651
|
-
import { existsSync as
|
|
671798
|
+
import { existsSync as existsSync150, readFileSync as readFileSync122, writeFileSync as writeFileSync79, mkdirSync as mkdirSync92, readdirSync as readdirSync53, unlinkSync as unlinkSync30 } from "node:fs";
|
|
671652
671799
|
import { join as join163, basename as basename36 } from "node:path";
|
|
671653
671800
|
import { exec as exec6 } from "node:child_process";
|
|
671654
671801
|
import { promisify as promisify8 } from "node:util";
|
|
@@ -672468,7 +672615,7 @@ If decision is GO, selectedTask MUST be a fully-populated object (NEVER null)
|
|
|
672468
672615
|
const root = this.repoRoot;
|
|
672469
672616
|
try {
|
|
672470
672617
|
const plansDir = join163(root, ".aiwg", "plans");
|
|
672471
|
-
if (
|
|
672618
|
+
if (existsSync150(plansDir)) {
|
|
672472
672619
|
for (const f2 of readdirSync53(plansDir).filter((p2) => p2.endsWith(".md")).slice(0, 8)) {
|
|
672473
672620
|
out.push(`Plan backlog: implement .aiwg/plans/${f2}`);
|
|
672474
672621
|
}
|
|
@@ -672516,7 +672663,7 @@ If decision is GO, selectedTask MUST be a fully-populated object (NEVER null)
|
|
|
672516
672663
|
join163(this.repoRoot, ".omnius", "memory")
|
|
672517
672664
|
];
|
|
672518
672665
|
for (const dir of dirs) {
|
|
672519
|
-
if (!
|
|
672666
|
+
if (!existsSync150(dir)) continue;
|
|
672520
672667
|
try {
|
|
672521
672668
|
const files = readdirSync53(dir).filter((f2) => f2.endsWith(".json"));
|
|
672522
672669
|
for (const f2 of files) {
|
|
@@ -672531,7 +672678,7 @@ If decision is GO, selectedTask MUST be a fully-populated object (NEVER null)
|
|
|
672531
672678
|
// ── State persistence ─────────────────────────────────────────────────
|
|
672532
672679
|
loadState() {
|
|
672533
672680
|
const path12 = join163(this.stateDir, "state.json");
|
|
672534
|
-
if (
|
|
672681
|
+
if (existsSync150(path12)) {
|
|
672535
672682
|
try {
|
|
672536
672683
|
this.state = JSON.parse(readFileSync122(path12, "utf-8"));
|
|
672537
672684
|
} catch {
|
|
@@ -674243,7 +674390,7 @@ var init_telegram_command_menu = __esm({
|
|
|
674243
674390
|
// packages/cli/src/tui/telegram-creative-tools.ts
|
|
674244
674391
|
import { createCipheriv as createCipheriv5, createDecipheriv as createDecipheriv5, randomBytes as randomBytes26 } from "node:crypto";
|
|
674245
674392
|
import {
|
|
674246
|
-
existsSync as
|
|
674393
|
+
existsSync as existsSync151,
|
|
674247
674394
|
mkdirSync as mkdirSync93,
|
|
674248
674395
|
readFileSync as readFileSync123,
|
|
674249
674396
|
statSync as statSync55,
|
|
@@ -674301,7 +674448,7 @@ function collectGeneratedArtifactPathsFromText(text2, root) {
|
|
|
674301
674448
|
const value2 = match[1];
|
|
674302
674449
|
if (!value2) continue;
|
|
674303
674450
|
const guarded = guardPath(rootAbs, value2);
|
|
674304
|
-
if (guarded.ok && (isManifestArtifact(rootAbs, guarded.path.rel) ||
|
|
674451
|
+
if (guarded.ok && (isManifestArtifact(rootAbs, guarded.path.rel) || existsSync151(guarded.path.abs) && safeStatFile(guarded.path.abs))) {
|
|
674305
674452
|
paths.add(guarded.path.abs);
|
|
674306
674453
|
}
|
|
674307
674454
|
}
|
|
@@ -674312,7 +674459,7 @@ function collectGeneratedArtifactPathsFromText(text2, root) {
|
|
|
674312
674459
|
const value2 = marker?.[1]?.trim().replace(/^["']|["']$/g, "");
|
|
674313
674460
|
if (!value2) continue;
|
|
674314
674461
|
const guarded = guardPath(rootAbs, value2);
|
|
674315
|
-
if (guarded.ok && (isManifestArtifact(rootAbs, guarded.path.rel) ||
|
|
674462
|
+
if (guarded.ok && (isManifestArtifact(rootAbs, guarded.path.rel) || existsSync151(guarded.path.abs) && safeStatFile(guarded.path.abs))) {
|
|
674316
674463
|
paths.add(guarded.path.abs);
|
|
674317
674464
|
}
|
|
674318
674465
|
}
|
|
@@ -674386,7 +674533,7 @@ function scopedTool(base3, root, mode) {
|
|
|
674386
674533
|
if (output) {
|
|
674387
674534
|
const guardedOutput = guardPath(rootAbs, output);
|
|
674388
674535
|
if (!guardedOutput.ok) return denied(guardedOutput.error);
|
|
674389
|
-
if (
|
|
674536
|
+
if (existsSync151(guardedOutput.path.abs) && !manifestHas(rootAbs, guardedOutput.path.rel)) {
|
|
674390
674537
|
return denied(
|
|
674391
674538
|
`Refusing to overwrite a file that is not owned by this chat workspace manifest: ${guardedOutput.path.rel}`
|
|
674392
674539
|
);
|
|
@@ -674421,7 +674568,7 @@ function scopedTool(base3, root, mode) {
|
|
|
674421
674568
|
const rawOutput = typeof next["output"] === "string" && String(next["output"]).trim() ? String(next["output"]) : typeof next["output_path"] === "string" && String(next["output_path"]).trim() ? String(next["output_path"]) : `tts-${Date.now()}.wav`;
|
|
674422
674569
|
const guardedOutput = guardPath(rootAbs, rawOutput);
|
|
674423
674570
|
if (!guardedOutput.ok) return denied(guardedOutput.error);
|
|
674424
|
-
if (
|
|
674571
|
+
if (existsSync151(guardedOutput.path.abs) && !manifestHas(rootAbs, guardedOutput.path.rel)) {
|
|
674425
674572
|
return denied(
|
|
674426
674573
|
`Refusing to overwrite a file that is not owned by this chat workspace manifest: ${guardedOutput.path.rel}`
|
|
674427
674574
|
);
|
|
@@ -674468,7 +674615,7 @@ function scopedTool(base3, root, mode) {
|
|
|
674468
674615
|
`Public Telegram creative tools can only edit files created in this chat workspace: ${guarded.path.rel}`
|
|
674469
674616
|
);
|
|
674470
674617
|
}
|
|
674471
|
-
if (mode === "edit" && !
|
|
674618
|
+
if (mode === "edit" && !existsSync151(guarded.path.abs)) {
|
|
674472
674619
|
const materialized = materializeTelegramCreativeArtifactForSend(
|
|
674473
674620
|
rootAbs,
|
|
674474
674621
|
guarded.path.rel
|
|
@@ -674479,7 +674626,7 @@ function scopedTool(base3, root, mode) {
|
|
|
674479
674626
|
materialized.cleanup?.();
|
|
674480
674627
|
restoredEditPath = guarded.path.abs;
|
|
674481
674628
|
}
|
|
674482
|
-
if (mode === "create" &&
|
|
674629
|
+
if (mode === "create" && existsSync151(guarded.path.abs) && !manifestHas(rootAbs, guarded.path.rel)) {
|
|
674483
674630
|
return denied(
|
|
674484
674631
|
`Refusing to overwrite a file that is not owned by this chat workspace manifest: ${guarded.path.rel}`
|
|
674485
674632
|
);
|
|
@@ -674583,7 +674730,7 @@ function manifestPath(root) {
|
|
|
674583
674730
|
function ensureManifest(root) {
|
|
674584
674731
|
mkdirSync93(root, { recursive: true });
|
|
674585
674732
|
const path12 = manifestPath(root);
|
|
674586
|
-
if (!
|
|
674733
|
+
if (!existsSync151(path12)) {
|
|
674587
674734
|
writeFileSync80(
|
|
674588
674735
|
path12,
|
|
674589
674736
|
JSON.stringify(
|
|
@@ -674639,11 +674786,11 @@ function rememberCreated(root, absPath) {
|
|
|
674639
674786
|
const manifest = readManifest(root);
|
|
674640
674787
|
const rel = guarded.path.rel.replace(/\\/g, "/");
|
|
674641
674788
|
if (publicCreativeArtifactPolicyError(guarded.path.abs)) return;
|
|
674642
|
-
if (
|
|
674789
|
+
if (existsSync151(guarded.path.abs) && safeStatFile(guarded.path.abs)) {
|
|
674643
674790
|
const previous = manifest.objects?.[rel];
|
|
674644
674791
|
if (previous) {
|
|
674645
674792
|
const previousPath = resolve66(root, previous.storedRel);
|
|
674646
|
-
if (isInside(resolve66(root), previousPath) &&
|
|
674793
|
+
if (isInside(resolve66(root), previousPath) && existsSync151(previousPath)) {
|
|
674647
674794
|
try {
|
|
674648
674795
|
unlinkSync31(previousPath);
|
|
674649
674796
|
} catch {
|
|
@@ -674701,7 +674848,7 @@ function materializeTelegramCreativeArtifactForSend(root, rawPath) {
|
|
|
674701
674848
|
const object = manifest.objects?.[rel];
|
|
674702
674849
|
if (object) {
|
|
674703
674850
|
const storedAbs = resolve66(rootAbs, object.storedRel);
|
|
674704
|
-
if (!isInside(rootAbs, storedAbs) || !
|
|
674851
|
+
if (!isInside(rootAbs, storedAbs) || !existsSync151(storedAbs) || !safeStatFile(storedAbs)) {
|
|
674705
674852
|
return {
|
|
674706
674853
|
ok: false,
|
|
674707
674854
|
error: `Scoped artifact storage is missing for ${rel}.`
|
|
@@ -674749,7 +674896,7 @@ function materializeTelegramCreativeArtifactForSend(root, rawPath) {
|
|
|
674749
674896
|
}
|
|
674750
674897
|
};
|
|
674751
674898
|
}
|
|
674752
|
-
if (
|
|
674899
|
+
if (existsSync151(guarded.path.abs) && safeStatFile(guarded.path.abs)) {
|
|
674753
674900
|
return { ok: true, path: guarded.path.abs };
|
|
674754
674901
|
}
|
|
674755
674902
|
return {
|
|
@@ -674953,7 +675100,7 @@ var init_telegram_creative_tools = __esm({
|
|
|
674953
675100
|
const rawPath = typeof args["path"] === "string" && args["path"].trim() ? String(args["path"]) : `speech-${Date.now()}.wav`;
|
|
674954
675101
|
const guarded = guardPath(this.root, rawPath);
|
|
674955
675102
|
if (!guarded.ok) return denied(guarded.error);
|
|
674956
|
-
if (
|
|
675103
|
+
if (existsSync151(guarded.path.abs) && !manifestHas(this.root, guarded.path.rel)) {
|
|
674957
675104
|
return denied(
|
|
674958
675105
|
`Refusing to overwrite a file that is not owned by this chat workspace manifest: ${guarded.path.rel}`
|
|
674959
675106
|
);
|
|
@@ -675018,7 +675165,7 @@ var init_telegram_creative_tools = __esm({
|
|
|
675018
675165
|
model: args["model"],
|
|
675019
675166
|
speed: args["speed"]
|
|
675020
675167
|
});
|
|
675021
|
-
if (!result.success || !
|
|
675168
|
+
if (!result.success || !existsSync151(guarded.path.abs)) {
|
|
675022
675169
|
return {
|
|
675023
675170
|
success: false,
|
|
675024
675171
|
output: "",
|
|
@@ -675675,7 +675822,7 @@ var init_visual_object_association = __esm({
|
|
|
675675
675822
|
|
|
675676
675823
|
// packages/cli/src/tui/telegram-channel-dmn.ts
|
|
675677
675824
|
import {
|
|
675678
|
-
existsSync as
|
|
675825
|
+
existsSync as existsSync152,
|
|
675679
675826
|
mkdirSync as mkdirSync94,
|
|
675680
675827
|
readdirSync as readdirSync54,
|
|
675681
675828
|
readFileSync as readFileSync124,
|
|
@@ -676411,7 +676558,7 @@ function formatTelegramChannelDaydreamMetadataMarkdown(artifact) {
|
|
|
676411
676558
|
}
|
|
676412
676559
|
function pruneTelegramChannelDaydreams(repoRoot, sessionKey, keep = DAYDREAM_ARTIFACT_RETENTION_LIMIT) {
|
|
676413
676560
|
const dir = sessionDir(repoRoot, sessionKey);
|
|
676414
|
-
if (!
|
|
676561
|
+
if (!existsSync152(dir)) return 0;
|
|
676415
676562
|
const files = readdirSync54(dir).filter((f2) => f2.endsWith(".json") || f2.endsWith(".md")).sort();
|
|
676416
676563
|
if (files.length <= keep * 2) return 0;
|
|
676417
676564
|
const toRemove = files.slice(0, files.length - keep * 2);
|
|
@@ -676442,7 +676589,7 @@ function writeTelegramChannelDaydream(repoRoot, artifact) {
|
|
|
676442
676589
|
}
|
|
676443
676590
|
function latestTelegramChannelDaydream(repoRoot, sessionKey) {
|
|
676444
676591
|
const dir = sessionDir(repoRoot, sessionKey);
|
|
676445
|
-
if (!
|
|
676592
|
+
if (!existsSync152(dir)) return null;
|
|
676446
676593
|
const files = readdirSync54(dir).filter((file) => file.endsWith(".json")).sort();
|
|
676447
676594
|
for (const file of files.reverse()) {
|
|
676448
676595
|
try {
|
|
@@ -678185,7 +678332,7 @@ __export(vision_ingress_exports, {
|
|
|
678185
678332
|
resolveVisionModel: () => resolveVisionModel,
|
|
678186
678333
|
runVisionIngress: () => runVisionIngress
|
|
678187
678334
|
});
|
|
678188
|
-
import { existsSync as
|
|
678335
|
+
import { existsSync as existsSync153, readFileSync as readFileSync125, unlinkSync as unlinkSync33 } from "node:fs";
|
|
678189
678336
|
import { join as join166 } from "node:path";
|
|
678190
678337
|
async function isTesseractAvailable() {
|
|
678191
678338
|
try {
|
|
@@ -678220,7 +678367,7 @@ function isVisionModel(modelName) {
|
|
|
678220
678367
|
}
|
|
678221
678368
|
async function advancedOcr(imagePath) {
|
|
678222
678369
|
if (!await isTesseractAvailable()) return "";
|
|
678223
|
-
if (!
|
|
678370
|
+
if (!existsSync153(imagePath)) return "";
|
|
678224
678371
|
const tmpBase = join166(
|
|
678225
678372
|
imagePath.replace(/\.[^.]+$/, ""),
|
|
678226
678373
|
`_ocr_${Date.now()}`
|
|
@@ -678239,7 +678386,7 @@ async function advancedOcr(imagePath) {
|
|
|
678239
678386
|
"eng"
|
|
678240
678387
|
], { timeout: 15e3 });
|
|
678241
678388
|
const txtFile = `${outFile}.txt`;
|
|
678242
|
-
if (
|
|
678389
|
+
if (existsSync153(txtFile)) {
|
|
678243
678390
|
const text2 = readFileSync125(txtFile, "utf-8").trim();
|
|
678244
678391
|
if (text2.length > 0) results.push(text2);
|
|
678245
678392
|
try {
|
|
@@ -678256,7 +678403,7 @@ async function advancedOcr(imagePath) {
|
|
|
678256
678403
|
}
|
|
678257
678404
|
async function queryVisionModel(modelName, imagePath, prompt = "Describe what you see in this image in detail. Include any text, UI elements, code, diagrams, or visual content.") {
|
|
678258
678405
|
if (!isVisionModel(modelName)) return "";
|
|
678259
|
-
if (!
|
|
678406
|
+
if (!existsSync153(imagePath)) return "";
|
|
678260
678407
|
try {
|
|
678261
678408
|
const tool = new VisionTool(process.cwd());
|
|
678262
678409
|
const result = await tool.execute({
|
|
@@ -678309,7 +678456,7 @@ function formatVisualFamiliarityContext(result) {
|
|
|
678309
678456
|
return lines.join("\n");
|
|
678310
678457
|
}
|
|
678311
678458
|
async function queryVisualFamiliarity(imagePath, options2 = {}) {
|
|
678312
|
-
if (!
|
|
678459
|
+
if (!existsSync153(imagePath)) {
|
|
678313
678460
|
return {
|
|
678314
678461
|
attempted: false,
|
|
678315
678462
|
recognizedObjects: [],
|
|
@@ -678421,7 +678568,7 @@ var init_vision_ingress = __esm({
|
|
|
678421
678568
|
// packages/cli/src/tui/telegram-bridge.ts
|
|
678422
678569
|
import {
|
|
678423
678570
|
mkdirSync as mkdirSync95,
|
|
678424
|
-
existsSync as
|
|
678571
|
+
existsSync as existsSync154,
|
|
678425
678572
|
unlinkSync as unlinkSync34,
|
|
678426
678573
|
readdirSync as readdirSync55,
|
|
678427
678574
|
statSync as statSync56,
|
|
@@ -683413,7 +683560,7 @@ Model: <code>${escapeTelegramHTML(model.id)}</code>`
|
|
|
683413
683560
|
}
|
|
683414
683561
|
let sent = 0;
|
|
683415
683562
|
for (const path12 of paths) {
|
|
683416
|
-
if (!
|
|
683563
|
+
if (!existsSync154(path12) || !statSync56(path12).isFile()) continue;
|
|
683417
683564
|
const kind = classifyMedia(path12) ?? "document";
|
|
683418
683565
|
const messageId = await this.sendMediaReference(
|
|
683419
683566
|
msg.chatId,
|
|
@@ -684570,7 +684717,7 @@ ${mediaContext}` : ""
|
|
|
684570
684717
|
if (this.loadedConversationState.has(sessionKey)) return;
|
|
684571
684718
|
this.loadedConversationState.add(sessionKey);
|
|
684572
684719
|
const path12 = this.telegramConversationPath(sessionKey);
|
|
684573
|
-
if (!
|
|
684720
|
+
if (!existsSync154(path12)) return;
|
|
684574
684721
|
try {
|
|
684575
684722
|
const parsed = JSON.parse(readFileSync126(path12, "utf8"));
|
|
684576
684723
|
const loadedHistory = Array.isArray(parsed.history) ? parsed.history : [];
|
|
@@ -684780,7 +684927,7 @@ ${mediaContext}` : ""
|
|
|
684780
684927
|
ensureAllTelegramConversationsLoaded() {
|
|
684781
684928
|
if (this.loadedAllConversationState) return;
|
|
684782
684929
|
this.loadedAllConversationState = true;
|
|
684783
|
-
if (!
|
|
684930
|
+
if (!existsSync154(this.telegramConversationDir)) return;
|
|
684784
684931
|
const sessionsNeedingFlush = [];
|
|
684785
684932
|
try {
|
|
684786
684933
|
for (const file of readdirSync55(this.telegramConversationDir)) {
|
|
@@ -685684,7 +685831,7 @@ ${mediaContext}` : ""
|
|
|
685684
685831
|
});
|
|
685685
685832
|
if (matchingEntry) return { ok: true, path: matchingEntry.localPath };
|
|
685686
685833
|
const creativeCandidate = isAbsolute14(raw) ? resolve67(raw) : resolve67(creativeRoot, raw);
|
|
685687
|
-
if (isPathInside(creativeRoot, creativeCandidate) &&
|
|
685834
|
+
if (isPathInside(creativeRoot, creativeCandidate) && existsSync154(creativeCandidate)) {
|
|
685688
685835
|
return { ok: true, path: creativeCandidate };
|
|
685689
685836
|
}
|
|
685690
685837
|
return {
|
|
@@ -686349,7 +686496,7 @@ ${lines.join("\n")}`;
|
|
|
686349
686496
|
if (!this.repoRoot) return "";
|
|
686350
686497
|
if (interactiveInlineProjectMemoryBlocked()) return "";
|
|
686351
686498
|
const paths = omniusMemoryDbPaths(this.repoRoot);
|
|
686352
|
-
if (!
|
|
686499
|
+
if (!existsSync154(paths.episodes)) return "";
|
|
686353
686500
|
let episodes = [];
|
|
686354
686501
|
const graph = new TemporalGraph(paths.knowledge);
|
|
686355
686502
|
const store2 = new EpisodeStore(paths.episodes, graph);
|
|
@@ -686728,7 +686875,7 @@ ${lines.join("\n")}`;
|
|
|
686728
686875
|
if (!this.repoRoot || !query.trim()) return [];
|
|
686729
686876
|
if (interactiveInlineProjectMemoryBlocked()) return [];
|
|
686730
686877
|
const paths = omniusMemoryDbPaths(this.repoRoot);
|
|
686731
|
-
if (!
|
|
686878
|
+
if (!existsSync154(paths.episodes)) return [];
|
|
686732
686879
|
const graph = new TemporalGraph(paths.knowledge);
|
|
686733
686880
|
const store2 = new EpisodeStore(paths.episodes, graph);
|
|
686734
686881
|
try {
|
|
@@ -686789,7 +686936,7 @@ ${lines.join("\n")}`;
|
|
|
686789
686936
|
if (this.repoRoot && chatId !== void 0) {
|
|
686790
686937
|
try {
|
|
686791
686938
|
const memDir = resolve67(this.repoRoot, ".omnius", "memory");
|
|
686792
|
-
if (
|
|
686939
|
+
if (existsSync154(memDir)) {
|
|
686793
686940
|
const prefix = this.telegramScopedMemoryPrefix(chatId);
|
|
686794
686941
|
for (const file of readdirSync55(memDir)) {
|
|
686795
686942
|
if (file.endsWith(".json") && file.startsWith(prefix)) topicCount++;
|
|
@@ -689471,7 +689618,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
689471
689618
|
claimTelegramOwnerLock(lockDir, botUserId, botUsername) {
|
|
689472
689619
|
mkdirSync95(lockDir, { recursive: true });
|
|
689473
689620
|
const lockFile = join167(lockDir, `bot-${botUserId}.owner.lock`);
|
|
689474
|
-
if (
|
|
689621
|
+
if (existsSync154(lockFile)) {
|
|
689475
689622
|
try {
|
|
689476
689623
|
const prior = JSON.parse(readFileSync126(lockFile, "utf8"));
|
|
689477
689624
|
const priorAlive = typeof prior.pid === "number" && prior.pid !== process.pid ? this.processIsAlive(prior.pid) : false;
|
|
@@ -689504,7 +689651,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
689504
689651
|
}
|
|
689505
689652
|
releaseTelegramOwnerLock(lockFile) {
|
|
689506
689653
|
try {
|
|
689507
|
-
if (!
|
|
689654
|
+
if (!existsSync154(lockFile)) return;
|
|
689508
689655
|
try {
|
|
689509
689656
|
const prior = JSON.parse(readFileSync126(lockFile, "utf8"));
|
|
689510
689657
|
if (prior.pid !== process.pid) return;
|
|
@@ -695740,7 +695887,7 @@ ${knownList}` : "Private-user telegram_send_file target must be this DM or a kno
|
|
|
695740
695887
|
return { ...materialized, logicalPath };
|
|
695741
695888
|
}
|
|
695742
695889
|
const abs = isAbsolute14(trimmed) ? resolve67(trimmed) : resolve67(base3, trimmed);
|
|
695743
|
-
if (!
|
|
695890
|
+
if (!existsSync154(abs))
|
|
695744
695891
|
return { ok: false, error: `File does not exist: ${trimmed}` };
|
|
695745
695892
|
if (!statSync56(abs).isFile())
|
|
695746
695893
|
return { ok: false, error: `Path is not a file: ${trimmed}` };
|
|
@@ -695839,7 +695986,7 @@ ${knownList}` : "Private-user telegram_send_file target must be this DM or a kno
|
|
|
695839
695986
|
const safeCaption = caption ? ` — caption: ${telegramContextJsonString(caption, 220)}` : "";
|
|
695840
695987
|
const cacheKey = `${String(msg.chatId)}:${String(sourceMessageId ?? 0)}:${fileUniqueId}`;
|
|
695841
695988
|
const existingEntry = this.mediaCache.get(cacheKey);
|
|
695842
|
-
let cacheEntry = existingEntry &&
|
|
695989
|
+
let cacheEntry = existingEntry && existsSync154(existingEntry.localPath) ? existingEntry : void 0;
|
|
695843
695990
|
let localPath = cacheEntry?.localPath;
|
|
695844
695991
|
if (cacheEntry) {
|
|
695845
695992
|
cacheEntry.cachedAt = Date.now();
|
|
@@ -696256,7 +696403,7 @@ ${text2}`.trim()
|
|
|
696256
696403
|
}
|
|
696257
696404
|
async sendTelegramFileToChat(chatId, path12, options2) {
|
|
696258
696405
|
const abs = resolve67(path12);
|
|
696259
|
-
if (!
|
|
696406
|
+
if (!existsSync154(abs) || !statSync56(abs).isFile()) {
|
|
696260
696407
|
throw new Error(`File does not exist or is not a regular file: ${path12}`);
|
|
696261
696408
|
}
|
|
696262
696409
|
return this.sendMediaReferenceStrict(
|
|
@@ -696296,7 +696443,7 @@ ${text2}`.trim()
|
|
|
696296
696443
|
this.state.messagesSent++;
|
|
696297
696444
|
return result2.result?.message_id ?? null;
|
|
696298
696445
|
}
|
|
696299
|
-
if (!
|
|
696446
|
+
if (!existsSync154(media.value))
|
|
696300
696447
|
throw new Error(`File does not exist: ${media.value}`);
|
|
696301
696448
|
const buffer2 = readFileSync126(media.value);
|
|
696302
696449
|
const boundary = `----omnius-media-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
@@ -696410,7 +696557,7 @@ Content-Type: ${contentType}\r
|
|
|
696410
696557
|
}
|
|
696411
696558
|
readGeneratedImagePromptInfo(imagePath) {
|
|
696412
696559
|
const sidecarPath2 = `${imagePath}.json`;
|
|
696413
|
-
if (!
|
|
696560
|
+
if (!existsSync154(sidecarPath2)) return null;
|
|
696414
696561
|
try {
|
|
696415
696562
|
const raw = readFileSync126(sidecarPath2, "utf8");
|
|
696416
696563
|
const parsed = JSON.parse(raw);
|
|
@@ -696470,7 +696617,7 @@ Content-Type: ${contentType}\r
|
|
|
696470
696617
|
}
|
|
696471
696618
|
readGeneratedVideoPromptInfo(videoPath) {
|
|
696472
696619
|
const sidecarPath2 = `${videoPath}.json`;
|
|
696473
|
-
if (!
|
|
696620
|
+
if (!existsSync154(sidecarPath2)) return null;
|
|
696474
696621
|
try {
|
|
696475
696622
|
const raw = readFileSync126(sidecarPath2, "utf8");
|
|
696476
696623
|
const parsed = JSON.parse(raw);
|
|
@@ -696526,7 +696673,7 @@ Content-Type: ${contentType}\r
|
|
|
696526
696673
|
for (const path12 of paths) {
|
|
696527
696674
|
const abs = resolve67(path12);
|
|
696528
696675
|
if (subAgent.deliveredArtifacts.includes(abs)) continue;
|
|
696529
|
-
if (!
|
|
696676
|
+
if (!existsSync154(abs) || !statSync56(abs).isFile()) continue;
|
|
696530
696677
|
subAgent.deliveredArtifacts.push(abs);
|
|
696531
696678
|
await this.sendMediaReference(
|
|
696532
696679
|
msg.chatId,
|
|
@@ -696568,7 +696715,7 @@ Content-Type: ${contentType}\r
|
|
|
696568
696715
|
abs
|
|
696569
696716
|
);
|
|
696570
696717
|
if (!materialized.ok) continue;
|
|
696571
|
-
if (!
|
|
696718
|
+
if (!existsSync154(materialized.path) || !statSync56(materialized.path).isFile()) {
|
|
696572
696719
|
materialized.cleanup?.();
|
|
696573
696720
|
continue;
|
|
696574
696721
|
}
|
|
@@ -696613,7 +696760,7 @@ Content-Type: ${contentType}\r
|
|
|
696613
696760
|
addField(name10, value2);
|
|
696614
696761
|
}
|
|
696615
696762
|
for (const [field, pathOrFileId] of Object.entries(files)) {
|
|
696616
|
-
if (!
|
|
696763
|
+
if (!existsSync154(pathOrFileId)) {
|
|
696617
696764
|
addField(field, pathOrFileId);
|
|
696618
696765
|
continue;
|
|
696619
696766
|
}
|
|
@@ -696805,7 +696952,7 @@ Content-Type: ${mimeForPath(pathOrFileId, field === "photo" ? "image" : "video")
|
|
|
696805
696952
|
return result.result?.message_id ?? null;
|
|
696806
696953
|
}
|
|
696807
696954
|
async sendLivePhoto(chatId, livePhoto, photo, options2 = {}) {
|
|
696808
|
-
if (!
|
|
696955
|
+
if (!existsSync154(livePhoto) && !existsSync154(photo)) {
|
|
696809
696956
|
const result2 = await this.apiCall("sendLivePhoto", {
|
|
696810
696957
|
chat_id: chatId,
|
|
696811
696958
|
live_photo: livePhoto,
|
|
@@ -698689,13 +698836,13 @@ __export(projects_exports, {
|
|
|
698689
698836
|
setCurrentProject: () => setCurrentProject,
|
|
698690
698837
|
unregisterProject: () => unregisterProject
|
|
698691
698838
|
});
|
|
698692
|
-
import { readFileSync as readFileSync127, writeFileSync as writeFileSync83, mkdirSync as mkdirSync96, existsSync as
|
|
698839
|
+
import { readFileSync as readFileSync127, writeFileSync as writeFileSync83, mkdirSync as mkdirSync96, existsSync as existsSync155, statSync as statSync57, renameSync as renameSync14 } from "node:fs";
|
|
698693
698840
|
import { homedir as homedir56 } from "node:os";
|
|
698694
698841
|
import { basename as basename40, join as join168, resolve as resolve68 } from "node:path";
|
|
698695
698842
|
import { randomUUID as randomUUID19 } from "node:crypto";
|
|
698696
698843
|
function readAll2() {
|
|
698697
698844
|
try {
|
|
698698
|
-
if (!
|
|
698845
|
+
if (!existsSync155(PROJECTS_FILE)) return { projects: [], schemaVersion: 1 };
|
|
698699
698846
|
const raw = readFileSync127(PROJECTS_FILE, "utf8");
|
|
698700
698847
|
const parsed = JSON.parse(raw);
|
|
698701
698848
|
if (!parsed || !Array.isArray(parsed.projects)) return { projects: [], schemaVersion: 1 };
|
|
@@ -698772,7 +698919,7 @@ function renameProject(root, name10) {
|
|
|
698772
698919
|
function getCurrentProject() {
|
|
698773
698920
|
if (!currentRoot) {
|
|
698774
698921
|
try {
|
|
698775
|
-
if (
|
|
698922
|
+
if (existsSync155(CURRENT_FILE)) {
|
|
698776
698923
|
const persisted = readFileSync127(CURRENT_FILE, "utf8").trim();
|
|
698777
698924
|
if (persisted) currentRoot = persisted;
|
|
698778
698925
|
}
|
|
@@ -699687,7 +699834,7 @@ var init_access_policy = __esm({
|
|
|
699687
699834
|
|
|
699688
699835
|
// packages/cli/src/api/project-preferences.ts
|
|
699689
699836
|
import { createHash as createHash43 } from "node:crypto";
|
|
699690
|
-
import { existsSync as
|
|
699837
|
+
import { existsSync as existsSync156, mkdirSync as mkdirSync97, readFileSync as readFileSync128, renameSync as renameSync15, writeFileSync as writeFileSync84, unlinkSync as unlinkSync35 } from "node:fs";
|
|
699691
699838
|
import { homedir as homedir57 } from "node:os";
|
|
699692
699839
|
import { join as join169, resolve as resolve69 } from "node:path";
|
|
699693
699840
|
import { randomUUID as randomUUID20 } from "node:crypto";
|
|
@@ -699709,7 +699856,7 @@ function ensureDir(root) {
|
|
|
699709
699856
|
mkdirSync97(dir, { recursive: true });
|
|
699710
699857
|
const sentinel = rootSentinelPath(root);
|
|
699711
699858
|
try {
|
|
699712
|
-
if (!
|
|
699859
|
+
if (!existsSync156(sentinel)) {
|
|
699713
699860
|
writeFileSync84(sentinel, `${resolve69(root)}
|
|
699714
699861
|
`, "utf8");
|
|
699715
699862
|
}
|
|
@@ -699719,7 +699866,7 @@ function ensureDir(root) {
|
|
|
699719
699866
|
function readProjectPreferences(root) {
|
|
699720
699867
|
try {
|
|
699721
699868
|
const file = prefsPath(root);
|
|
699722
|
-
if (!
|
|
699869
|
+
if (!existsSync156(file)) return { ...DEFAULT_PREFS };
|
|
699723
699870
|
const raw = readFileSync128(file, "utf8");
|
|
699724
699871
|
const parsed = JSON.parse(raw);
|
|
699725
699872
|
if (!parsed || parsed.v !== SCHEMA_VERSION) return { ...DEFAULT_PREFS };
|
|
@@ -699758,7 +699905,7 @@ function writeProjectPreferences(root, partial) {
|
|
|
699758
699905
|
function deleteProjectPreferences(root) {
|
|
699759
699906
|
try {
|
|
699760
699907
|
const file = prefsPath(root);
|
|
699761
|
-
if (!
|
|
699908
|
+
if (!existsSync156(file)) return false;
|
|
699762
699909
|
unlinkSync35(file);
|
|
699763
699910
|
return true;
|
|
699764
699911
|
} catch {
|
|
@@ -699787,7 +699934,7 @@ __export(audit_log_exports, {
|
|
|
699787
699934
|
recordAudit: () => recordAudit,
|
|
699788
699935
|
sanitizeBody: () => sanitizeBody
|
|
699789
699936
|
});
|
|
699790
|
-
import { mkdirSync as mkdirSync98, appendFileSync as appendFileSync19, readFileSync as readFileSync129, existsSync as
|
|
699937
|
+
import { mkdirSync as mkdirSync98, appendFileSync as appendFileSync19, readFileSync as readFileSync129, existsSync as existsSync157 } from "node:fs";
|
|
699791
699938
|
import { join as join170 } from "node:path";
|
|
699792
699939
|
function initAuditLog(omniusDir) {
|
|
699793
699940
|
auditDir = join170(omniusDir, "audit");
|
|
@@ -699822,7 +699969,7 @@ function sanitizeBody(body, maxLen = 200) {
|
|
|
699822
699969
|
return safe.length > maxLen ? safe.slice(0, maxLen) + "..." : safe;
|
|
699823
699970
|
}
|
|
699824
699971
|
function queryAudit(opts) {
|
|
699825
|
-
if (!initialized || !
|
|
699972
|
+
if (!initialized || !existsSync157(auditFile)) return [];
|
|
699826
699973
|
try {
|
|
699827
699974
|
const raw = readFileSync129(auditFile, "utf-8");
|
|
699828
699975
|
const lines = raw.split("\n").filter(Boolean);
|
|
@@ -699861,7 +700008,7 @@ var init_audit_log = __esm({
|
|
|
699861
700008
|
|
|
699862
700009
|
// packages/cli/src/api/disk-task-output.ts
|
|
699863
700010
|
import { open } from "node:fs/promises";
|
|
699864
|
-
import { existsSync as
|
|
700011
|
+
import { existsSync as existsSync158, mkdirSync as mkdirSync99, statSync as statSync58 } from "node:fs";
|
|
699865
700012
|
import { dirname as dirname51 } from "node:path";
|
|
699866
700013
|
import * as fsConstants from "node:constants";
|
|
699867
700014
|
var O_NOFOLLOW2, O_APPEND2, O_CREAT2, O_WRONLY2, OPEN_FLAGS_WRITE, OPEN_MODE, DiskTaskOutput;
|
|
@@ -699957,7 +700104,7 @@ var init_disk_task_output = __esm({
|
|
|
699957
700104
|
async readFrom(offset, limit = 65536) {
|
|
699958
700105
|
let handle2 = null;
|
|
699959
700106
|
try {
|
|
699960
|
-
if (!
|
|
700107
|
+
if (!existsSync158(this.path)) {
|
|
699961
700108
|
return { content: "", nextOffset: offset, eof: true, size: 0 };
|
|
699962
700109
|
}
|
|
699963
700110
|
const st = statSync58(this.path);
|
|
@@ -700148,7 +700295,7 @@ data: ${JSON.stringify(ev)}
|
|
|
700148
700295
|
});
|
|
700149
700296
|
|
|
700150
700297
|
// packages/cli/src/api/routes-media.ts
|
|
700151
|
-
import { existsSync as
|
|
700298
|
+
import { existsSync as existsSync159, mkdirSync as mkdirSync100, statSync as statSync59, copyFileSync as copyFileSync7, createReadStream } from "node:fs";
|
|
700152
700299
|
import { basename as basename41, join as join171, resolve as pathResolve2 } from "node:path";
|
|
700153
700300
|
function mediaWorkDir() {
|
|
700154
700301
|
return join171(omniusHomeDir(), "media", "_work");
|
|
@@ -700177,7 +700324,7 @@ function publishToGallery(srcPath, kind) {
|
|
|
700177
700324
|
if (pathResolve2(srcPath) !== pathResolve2(dest)) {
|
|
700178
700325
|
copyFileSync7(srcPath, dest);
|
|
700179
700326
|
try {
|
|
700180
|
-
if (
|
|
700327
|
+
if (existsSync159(`${srcPath}.json`)) copyFileSync7(`${srcPath}.json`, `${dest}.json`);
|
|
700181
700328
|
} catch {
|
|
700182
700329
|
}
|
|
700183
700330
|
}
|
|
@@ -700359,7 +700506,7 @@ async function handleAvAnalyze(ctx3) {
|
|
|
700359
700506
|
return true;
|
|
700360
700507
|
}
|
|
700361
700508
|
const filePath = raw.startsWith("file://") ? raw.slice(7) : raw;
|
|
700362
|
-
if (!
|
|
700509
|
+
if (!existsSync159(filePath)) {
|
|
700363
700510
|
sendProblem(ctx3.res, problemDetails({ type: P.notFound, status: 404, title: "Media not found", detail: filePath, instance: ctx3.requestId }));
|
|
700364
700511
|
return true;
|
|
700365
700512
|
}
|
|
@@ -700436,7 +700583,7 @@ async function runGeneration(ctx3, kind, buildTool, buildArgs) {
|
|
|
700436
700583
|
return true;
|
|
700437
700584
|
}
|
|
700438
700585
|
const srcPath = extractGeneratedPath(result.output);
|
|
700439
|
-
if (!srcPath || !
|
|
700586
|
+
if (!srcPath || !existsSync159(srcPath)) {
|
|
700440
700587
|
sendProblem(ctx3.res, problemDetails({
|
|
700441
700588
|
type: P.upstreamFailure,
|
|
700442
700589
|
status: 502,
|
|
@@ -700543,7 +700690,7 @@ function handleFile(ctx3) {
|
|
|
700543
700690
|
}
|
|
700544
700691
|
const dir = globalMediaDir(kind);
|
|
700545
700692
|
const full = pathResolve2(dir, basename41(name10));
|
|
700546
|
-
if (!full.startsWith(pathResolve2(dir)) || !
|
|
700693
|
+
if (!full.startsWith(pathResolve2(dir)) || !existsSync159(full)) {
|
|
700547
700694
|
sendProblem(ctx3.res, problemDetails({
|
|
700548
700695
|
type: P.notFound,
|
|
700549
700696
|
status: 404,
|
|
@@ -700797,14 +700944,14 @@ var init_direct_tool_registry = __esm({
|
|
|
700797
700944
|
});
|
|
700798
700945
|
|
|
700799
700946
|
// packages/cli/src/api/external-tool-registry.ts
|
|
700800
|
-
import { existsSync as
|
|
700947
|
+
import { existsSync as existsSync160, mkdirSync as mkdirSync101, readFileSync as readFileSync130, writeFileSync as writeFileSync85, renameSync as renameSync16 } from "node:fs";
|
|
700801
700948
|
import { join as join172 } from "node:path";
|
|
700802
700949
|
function externalToolStorePath(workingDir) {
|
|
700803
700950
|
return join172(workingDir, ".omnius", "external-tools.json");
|
|
700804
700951
|
}
|
|
700805
700952
|
function loadExternalTools(workingDir) {
|
|
700806
700953
|
const path12 = externalToolStorePath(workingDir);
|
|
700807
|
-
if (!
|
|
700954
|
+
if (!existsSync160(path12)) return [];
|
|
700808
700955
|
try {
|
|
700809
700956
|
const parsed = JSON.parse(readFileSync130(path12, "utf-8"));
|
|
700810
700957
|
if (!parsed || !Array.isArray(parsed.tools)) return [];
|
|
@@ -701145,19 +701292,19 @@ __export(aiwg_exports, {
|
|
|
701145
701292
|
resolveAiwgRoot: () => resolveAiwgRoot,
|
|
701146
701293
|
tryRouteAiwg: () => tryRouteAiwg
|
|
701147
701294
|
});
|
|
701148
|
-
import { existsSync as
|
|
701295
|
+
import { existsSync as existsSync161, readFileSync as readFileSync131, readdirSync as readdirSync56, statSync as statSync60 } from "node:fs";
|
|
701149
701296
|
import { join as join173 } from "node:path";
|
|
701150
701297
|
import { homedir as homedir58 } from "node:os";
|
|
701151
701298
|
import { execSync as execSync38 } from "node:child_process";
|
|
701152
701299
|
function resolveAiwgRoot() {
|
|
701153
701300
|
if (_cachedAiwgRoot !== void 0) return _cachedAiwgRoot;
|
|
701154
701301
|
const envRoot = process.env["OMNIUS_AIWG_ROOT"];
|
|
701155
|
-
if (envRoot &&
|
|
701302
|
+
if (envRoot && existsSync161(join173(envRoot, "package.json"))) {
|
|
701156
701303
|
_cachedAiwgRoot = envRoot;
|
|
701157
701304
|
return envRoot;
|
|
701158
701305
|
}
|
|
701159
701306
|
const shareDir = join173(homedir58(), ".local", "share", "ai-writing-guide");
|
|
701160
|
-
if (
|
|
701307
|
+
if (existsSync161(join173(shareDir, "agentic"))) {
|
|
701161
701308
|
_cachedAiwgRoot = shareDir;
|
|
701162
701309
|
return shareDir;
|
|
701163
701310
|
}
|
|
@@ -701168,7 +701315,7 @@ function resolveAiwgRoot() {
|
|
|
701168
701315
|
stdio: ["pipe", "pipe", "pipe"]
|
|
701169
701316
|
}).trim();
|
|
701170
701317
|
const candidate = join173(globalRoot, "aiwg");
|
|
701171
|
-
if (
|
|
701318
|
+
if (existsSync161(join173(candidate, "package.json"))) {
|
|
701172
701319
|
_cachedAiwgRoot = candidate;
|
|
701173
701320
|
return candidate;
|
|
701174
701321
|
}
|
|
@@ -701179,7 +701326,7 @@ function resolveAiwgRoot() {
|
|
|
701179
701326
|
"/usr/lib/node_modules/aiwg",
|
|
701180
701327
|
"/opt/homebrew/lib/node_modules/aiwg"
|
|
701181
701328
|
]) {
|
|
701182
|
-
if (
|
|
701329
|
+
if (existsSync161(join173(p2, "package.json"))) {
|
|
701183
701330
|
_cachedAiwgRoot = p2;
|
|
701184
701331
|
return p2;
|
|
701185
701332
|
}
|
|
@@ -701189,12 +701336,12 @@ function resolveAiwgRoot() {
|
|
|
701189
701336
|
join173(homedir58(), ".local", "share", "fnm", "node-versions")
|
|
701190
701337
|
];
|
|
701191
701338
|
for (const vdir of versionDirs) {
|
|
701192
|
-
if (!
|
|
701339
|
+
if (!existsSync161(vdir)) continue;
|
|
701193
701340
|
try {
|
|
701194
701341
|
for (const ver of readdirSync56(vdir)) {
|
|
701195
701342
|
for (const prefix of ["lib/node_modules/aiwg", "installation/lib/node_modules/aiwg"]) {
|
|
701196
701343
|
const cand = join173(vdir, ver, prefix);
|
|
701197
|
-
if (
|
|
701344
|
+
if (existsSync161(join173(cand, "package.json"))) {
|
|
701198
701345
|
_cachedAiwgRoot = cand;
|
|
701199
701346
|
return cand;
|
|
701200
701347
|
}
|
|
@@ -701214,7 +701361,7 @@ function resolveAiwgRoot() {
|
|
|
701214
701361
|
for (let i2 = 0; i2 < 8; i2++) {
|
|
701215
701362
|
cur = join173(cur, "..");
|
|
701216
701363
|
const pj = join173(cur, "package.json");
|
|
701217
|
-
if (
|
|
701364
|
+
if (existsSync161(pj)) {
|
|
701218
701365
|
try {
|
|
701219
701366
|
const pkg = JSON.parse(readFileSync131(pj, "utf-8"));
|
|
701220
701367
|
if (pkg.name === "aiwg") {
|
|
@@ -701239,7 +701386,7 @@ function listAiwgFrameworks() {
|
|
|
701239
701386
|
return _cachedFrameworks;
|
|
701240
701387
|
}
|
|
701241
701388
|
const frameworksDir = join173(root, "agentic", "code", "frameworks");
|
|
701242
|
-
if (!
|
|
701389
|
+
if (!existsSync161(frameworksDir)) {
|
|
701243
701390
|
_cachedFrameworks = [];
|
|
701244
701391
|
return _cachedFrameworks;
|
|
701245
701392
|
}
|
|
@@ -701304,7 +701451,7 @@ function aggregateDir(dir, depth = 0) {
|
|
|
701304
701451
|
function readFirstLineDescription(dir) {
|
|
701305
701452
|
for (const candidate of ["README.md", "SKILL.md", "INDEX.md"]) {
|
|
701306
701453
|
const p2 = join173(dir, candidate);
|
|
701307
|
-
if (!
|
|
701454
|
+
if (!existsSync161(p2)) continue;
|
|
701308
701455
|
try {
|
|
701309
701456
|
const txt = readFileSync131(p2, "utf-8");
|
|
701310
701457
|
const descMatch = txt.match(/^description:\s*(.+)$/m);
|
|
@@ -701333,7 +701480,7 @@ function listAiwgItems() {
|
|
|
701333
701480
|
join173(root, "plugins")
|
|
701334
701481
|
];
|
|
701335
701482
|
for (const wr of walkRoots) {
|
|
701336
|
-
if (!
|
|
701483
|
+
if (!existsSync161(wr)) continue;
|
|
701337
701484
|
walkForItems(wr, out, 0);
|
|
701338
701485
|
}
|
|
701339
701486
|
_cachedItems = out;
|
|
@@ -701395,7 +701542,7 @@ function deriveSource(p2) {
|
|
|
701395
701542
|
}
|
|
701396
701543
|
function loadAiwgItemContent(path12, maxBytes = 2e4) {
|
|
701397
701544
|
try {
|
|
701398
|
-
if (!
|
|
701545
|
+
if (!existsSync161(path12)) return null;
|
|
701399
701546
|
const raw = readFileSync131(path12, "utf-8");
|
|
701400
701547
|
return raw.length > maxBytes ? raw.slice(0, maxBytes) + "\n\n...(truncated for context budget)" : raw;
|
|
701401
701548
|
} catch {
|
|
@@ -701410,7 +701557,7 @@ function listAiwgAddons() {
|
|
|
701410
701557
|
return _cachedAddons;
|
|
701411
701558
|
}
|
|
701412
701559
|
const addonsDir = join173(root, "agentic", "code", "addons");
|
|
701413
|
-
if (!
|
|
701560
|
+
if (!existsSync161(addonsDir)) {
|
|
701414
701561
|
_cachedAddons = [];
|
|
701415
701562
|
return _cachedAddons;
|
|
701416
701563
|
}
|
|
@@ -701932,16 +702079,16 @@ __export(runtime_keys_exports, {
|
|
|
701932
702079
|
mintKey: () => mintKey,
|
|
701933
702080
|
revokeByPrefix: () => revokeByPrefix
|
|
701934
702081
|
});
|
|
701935
|
-
import { existsSync as
|
|
702082
|
+
import { existsSync as existsSync162, readFileSync as readFileSync132, writeFileSync as writeFileSync86, mkdirSync as mkdirSync102, chmodSync as chmodSync5 } from "node:fs";
|
|
701936
702083
|
import { join as join174 } from "node:path";
|
|
701937
702084
|
import { homedir as homedir59 } from "node:os";
|
|
701938
702085
|
import { randomBytes as randomBytes28 } from "node:crypto";
|
|
701939
702086
|
function ensureDir2() {
|
|
701940
702087
|
const dir = join174(homedir59(), ".omnius");
|
|
701941
|
-
if (!
|
|
702088
|
+
if (!existsSync162(dir)) mkdirSync102(dir, { recursive: true });
|
|
701942
702089
|
}
|
|
701943
702090
|
function loadAll() {
|
|
701944
|
-
if (!
|
|
702091
|
+
if (!existsSync162(KEYS_FILE)) return [];
|
|
701945
702092
|
try {
|
|
701946
702093
|
const raw = readFileSync132(KEYS_FILE, "utf-8");
|
|
701947
702094
|
const parsed = JSON.parse(raw);
|
|
@@ -702029,7 +702176,7 @@ __export(tor_fallback_exports, {
|
|
|
702029
702176
|
torIsReachable: () => torIsReachable,
|
|
702030
702177
|
tunnelViaTor: () => tunnelViaTor
|
|
702031
702178
|
});
|
|
702032
|
-
import { existsSync as
|
|
702179
|
+
import { existsSync as existsSync163, readFileSync as readFileSync133 } from "node:fs";
|
|
702033
702180
|
import { homedir as homedir60 } from "node:os";
|
|
702034
702181
|
import { join as join175 } from "node:path";
|
|
702035
702182
|
import { createConnection as createConnection3 } from "node:net";
|
|
@@ -702041,7 +702188,7 @@ function getLocalOnion() {
|
|
|
702041
702188
|
];
|
|
702042
702189
|
for (const p2 of candidates) {
|
|
702043
702190
|
try {
|
|
702044
|
-
if (
|
|
702191
|
+
if (existsSync163(p2)) {
|
|
702045
702192
|
const v = readFileSync133(p2, "utf-8").trim();
|
|
702046
702193
|
if (v && v.endsWith(".onion")) return v;
|
|
702047
702194
|
}
|
|
@@ -702187,7 +702334,7 @@ __export(graphical_sudo_exports, {
|
|
|
702187
702334
|
runGraphicalSudo: () => runGraphicalSudo
|
|
702188
702335
|
});
|
|
702189
702336
|
import { spawn as spawn36 } from "node:child_process";
|
|
702190
|
-
import { existsSync as
|
|
702337
|
+
import { existsSync as existsSync164, mkdirSync as mkdirSync103, writeFileSync as writeFileSync87, chmodSync as chmodSync6 } from "node:fs";
|
|
702191
702338
|
import { join as join176 } from "node:path";
|
|
702192
702339
|
import { tmpdir as tmpdir24 } from "node:os";
|
|
702193
702340
|
function detectSudoHelper() {
|
|
@@ -702205,7 +702352,7 @@ function which2(cmd) {
|
|
|
702205
702352
|
for (const dir of path12.split(":")) {
|
|
702206
702353
|
if (!dir) continue;
|
|
702207
702354
|
const full = join176(dir, cmd);
|
|
702208
|
-
if (
|
|
702355
|
+
if (existsSync164(full)) return full;
|
|
702209
702356
|
}
|
|
702210
702357
|
return null;
|
|
702211
702358
|
}
|
|
@@ -702303,7 +702450,7 @@ var init_graphical_sudo = __esm({
|
|
|
702303
702450
|
});
|
|
702304
702451
|
|
|
702305
702452
|
// packages/cli/src/api/routes-v1.ts
|
|
702306
|
-
import { existsSync as
|
|
702453
|
+
import { existsSync as existsSync165, mkdirSync as mkdirSync104, readFileSync as readFileSync134, readdirSync as readdirSync57, statSync as statSync61 } from "node:fs";
|
|
702307
702454
|
import { join as join177, resolve as pathResolve3 } from "node:path";
|
|
702308
702455
|
import { homedir as homedir61 } from "node:os";
|
|
702309
702456
|
async function tryRouteV1(ctx3) {
|
|
@@ -702571,7 +702718,7 @@ async function fallbackDiscoverSkills() {
|
|
|
702571
702718
|
];
|
|
702572
702719
|
const out = [];
|
|
702573
702720
|
for (const root of roots) {
|
|
702574
|
-
if (!
|
|
702721
|
+
if (!existsSync165(root)) continue;
|
|
702575
702722
|
walkForSkills(root, out, 0);
|
|
702576
702723
|
}
|
|
702577
702724
|
return out;
|
|
@@ -703511,7 +703658,7 @@ async function handleFilesRead(ctx3) {
|
|
|
703511
703658
|
}));
|
|
703512
703659
|
return true;
|
|
703513
703660
|
}
|
|
703514
|
-
if (!
|
|
703661
|
+
if (!existsSync165(resolved)) {
|
|
703515
703662
|
sendProblem(res, problemDetails({
|
|
703516
703663
|
type: P2.notFound,
|
|
703517
703664
|
status: 404,
|
|
@@ -703843,7 +703990,7 @@ async function handleNexusStatus(ctx3) {
|
|
|
703843
703990
|
];
|
|
703844
703991
|
const states2 = [];
|
|
703845
703992
|
for (const p2 of statePaths) {
|
|
703846
|
-
if (!
|
|
703993
|
+
if (!existsSync165(p2)) continue;
|
|
703847
703994
|
try {
|
|
703848
703995
|
const raw = readFileSync134(p2, "utf-8");
|
|
703849
703996
|
states2.push({ source: p2, data: JSON.parse(raw) });
|
|
@@ -703873,7 +704020,7 @@ async function handleNexusStatus(ctx3) {
|
|
|
703873
704020
|
function loadAgentName() {
|
|
703874
704021
|
try {
|
|
703875
704022
|
const p2 = join177(homedir61(), ".omnius", "agent-name");
|
|
703876
|
-
if (
|
|
704023
|
+
if (existsSync165(p2)) return readFileSync134(p2, "utf-8").trim();
|
|
703877
704024
|
} catch {
|
|
703878
704025
|
}
|
|
703879
704026
|
return null;
|
|
@@ -703887,7 +704034,7 @@ async function handleSponsors(ctx3) {
|
|
|
703887
704034
|
];
|
|
703888
704035
|
let sponsors = [];
|
|
703889
704036
|
for (const p2 of candidates) {
|
|
703890
|
-
if (!
|
|
704037
|
+
if (!existsSync165(p2)) continue;
|
|
703891
704038
|
try {
|
|
703892
704039
|
const raw = JSON.parse(readFileSync134(p2, "utf-8"));
|
|
703893
704040
|
if (Array.isArray(raw)) {
|
|
@@ -703959,7 +704106,7 @@ async function handleEvaluate(ctx3) {
|
|
|
703959
704106
|
return true;
|
|
703960
704107
|
}
|
|
703961
704108
|
const jobPath = join177(process.cwd(), ".omnius", "jobs", `${runId}.json`);
|
|
703962
|
-
if (!
|
|
704109
|
+
if (!existsSync165(jobPath)) {
|
|
703963
704110
|
sendProblem(res, problemDetails({
|
|
703964
704111
|
type: P2.notFound,
|
|
703965
704112
|
status: 404,
|
|
@@ -704107,7 +704254,7 @@ async function handleMintKey(ctx3) {
|
|
|
704107
704254
|
return true;
|
|
704108
704255
|
}
|
|
704109
704256
|
function _readStatusFile(p2) {
|
|
704110
|
-
if (!
|
|
704257
|
+
if (!existsSync165(p2)) return null;
|
|
704111
704258
|
try {
|
|
704112
704259
|
const data = JSON.parse(readFileSync134(p2, "utf-8"));
|
|
704113
704260
|
if (data?.connected && typeof data.peerId === "string" && data.peerId.length > 10) {
|
|
@@ -704151,7 +704298,7 @@ function resolveLocalPeerId() {
|
|
|
704151
704298
|
}
|
|
704152
704299
|
try {
|
|
704153
704300
|
const regPath = join177(homedir61(), ".omnius", "nexus-registry.json");
|
|
704154
|
-
if (
|
|
704301
|
+
if (existsSync165(regPath)) {
|
|
704155
704302
|
const reg = JSON.parse(readFileSync134(regPath, "utf-8"));
|
|
704156
704303
|
const entries = Array.isArray(reg?.dirs) ? reg.dirs : [];
|
|
704157
704304
|
for (const entry of entries) {
|
|
@@ -704199,13 +704346,13 @@ function locateTorScript(filename) {
|
|
|
704199
704346
|
join177(process.cwd(), "scripts", "tor", filename)
|
|
704200
704347
|
];
|
|
704201
704348
|
for (const p2 of candidates) {
|
|
704202
|
-
if (
|
|
704349
|
+
if (existsSync165(p2)) return p2;
|
|
704203
704350
|
}
|
|
704204
704351
|
try {
|
|
704205
704352
|
const { execSync: execSync41 } = __require("node:child_process");
|
|
704206
704353
|
const root = execSync41("npm root -g", { encoding: "utf-8", timeout: 5e3 }).trim();
|
|
704207
704354
|
const p2 = join177(root, "omnius", "dist", "scripts", "tor", filename);
|
|
704208
|
-
if (
|
|
704355
|
+
if (existsSync165(p2)) return p2;
|
|
704209
704356
|
} catch {
|
|
704210
704357
|
}
|
|
704211
704358
|
return null;
|
|
@@ -704485,7 +704632,7 @@ async function handleRemoteProxy(ctx3) {
|
|
|
704485
704632
|
];
|
|
704486
704633
|
let nexusDirPath = null;
|
|
704487
704634
|
for (const p2 of nexusCandidates) {
|
|
704488
|
-
if (
|
|
704635
|
+
if (existsSync165(join177(p2, "status.json"))) {
|
|
704489
704636
|
nexusDirPath = p2;
|
|
704490
704637
|
break;
|
|
704491
704638
|
}
|
|
@@ -705665,7 +705812,7 @@ function aimsDir() {
|
|
|
705665
705812
|
function readAimsFile(name10, fallback) {
|
|
705666
705813
|
try {
|
|
705667
705814
|
const p2 = join177(aimsDir(), name10);
|
|
705668
|
-
if (
|
|
705815
|
+
if (existsSync165(p2)) return JSON.parse(readFileSync134(p2, "utf-8"));
|
|
705669
705816
|
} catch {
|
|
705670
705817
|
}
|
|
705671
705818
|
return fallback;
|
|
@@ -706040,7 +706187,7 @@ async function handleAimsSuppliers(ctx3) {
|
|
|
706040
706187
|
join177(homedir61(), ".omnius", "sponsor-cache.json")
|
|
706041
706188
|
];
|
|
706042
706189
|
for (const p2 of sponsorPaths) {
|
|
706043
|
-
if (!
|
|
706190
|
+
if (!existsSync165(p2)) continue;
|
|
706044
706191
|
try {
|
|
706045
706192
|
const raw = JSON.parse(readFileSync134(p2, "utf-8"));
|
|
706046
706193
|
const list = Array.isArray(raw) ? raw : raw?.sponsors ?? [];
|
|
@@ -717998,14 +718145,14 @@ var init_auth_oidc = __esm({
|
|
|
717998
718145
|
});
|
|
717999
718146
|
|
|
718000
718147
|
// packages/cli/src/api/usage-tracker.ts
|
|
718001
|
-
import { mkdirSync as mkdirSync105, readFileSync as readFileSync135, writeFileSync as writeFileSync88, existsSync as
|
|
718148
|
+
import { mkdirSync as mkdirSync105, readFileSync as readFileSync135, writeFileSync as writeFileSync88, existsSync as existsSync166 } from "node:fs";
|
|
718002
718149
|
import { join as join178 } from "node:path";
|
|
718003
718150
|
function initUsageTracker(omniusDir) {
|
|
718004
718151
|
const dir = join178(omniusDir, "usage");
|
|
718005
718152
|
mkdirSync105(dir, { recursive: true });
|
|
718006
718153
|
usageFile = join178(dir, "token-usage.json");
|
|
718007
718154
|
try {
|
|
718008
|
-
if (
|
|
718155
|
+
if (existsSync166(usageFile)) {
|
|
718009
718156
|
store = JSON.parse(readFileSync135(usageFile, "utf-8"));
|
|
718010
718157
|
}
|
|
718011
718158
|
} catch {
|
|
@@ -718217,7 +718364,7 @@ var init_chat_followup = __esm({
|
|
|
718217
718364
|
|
|
718218
718365
|
// packages/cli/src/docker.ts
|
|
718219
718366
|
import { execSync as execSync39, spawn as spawn37 } from "node:child_process";
|
|
718220
|
-
import { existsSync as
|
|
718367
|
+
import { existsSync as existsSync167, mkdirSync as mkdirSync106, writeFileSync as writeFileSync89 } from "node:fs";
|
|
718221
718368
|
import { join as join179, resolve as resolve70, dirname as dirname52 } from "node:path";
|
|
718222
718369
|
import { homedir as homedir62 } from "node:os";
|
|
718223
718370
|
import { fileURLToPath as fileURLToPath22 } from "node:url";
|
|
@@ -718364,7 +718511,7 @@ async function ensureOmniusImage(force = false) {
|
|
|
718364
718511
|
}
|
|
718365
718512
|
let buildContext;
|
|
718366
718513
|
const dockerDir = getDockerDir();
|
|
718367
|
-
if (
|
|
718514
|
+
if (existsSync167(join179(dockerDir, "Dockerfile"))) {
|
|
718368
718515
|
buildContext = dockerDir;
|
|
718369
718516
|
} else {
|
|
718370
718517
|
buildContext = join179(homedir62(), ".omnius", "docker-build");
|
|
@@ -718707,7 +718854,7 @@ import {
|
|
|
718707
718854
|
writeFileSync as writeFileSync90,
|
|
718708
718855
|
readFileSync as readFileSync136,
|
|
718709
718856
|
readdirSync as readdirSync58,
|
|
718710
|
-
existsSync as
|
|
718857
|
+
existsSync as existsSync168,
|
|
718711
718858
|
watch as fsWatch4,
|
|
718712
718859
|
renameSync as renameSync17,
|
|
718713
718860
|
unlinkSync as unlinkSync36,
|
|
@@ -718736,7 +718883,7 @@ function getVersion3() {
|
|
|
718736
718883
|
];
|
|
718737
718884
|
for (const pkgPath of candidates) {
|
|
718738
718885
|
try {
|
|
718739
|
-
if (!
|
|
718886
|
+
if (!existsSync168(pkgPath)) continue;
|
|
718740
718887
|
const pkg = JSON.parse(readFileSync136(pkgPath, "utf8"));
|
|
718741
718888
|
if (pkg.name === "omnius" || pkg.name === "@omnius/cli" || pkg.name === "@omnius/monorepo") {
|
|
718742
718889
|
return pkg.version ?? "0.0.0";
|
|
@@ -719152,7 +719299,7 @@ function isOriginAllowed(origin) {
|
|
|
719152
719299
|
let accessMode = (process.env["OMNIUS_ACCESS"] || "").toLowerCase().trim();
|
|
719153
719300
|
try {
|
|
719154
719301
|
const accessFile = join181(homedir63(), ".omnius", "access");
|
|
719155
|
-
if (
|
|
719302
|
+
if (existsSync168(accessFile)) {
|
|
719156
719303
|
const persisted = readFileSync136(accessFile, "utf8").trim().toLowerCase();
|
|
719157
719304
|
if (persisted === "any" || persisted === "lan" || persisted === "loopback") {
|
|
719158
719305
|
accessMode = persisted;
|
|
@@ -720003,7 +720150,7 @@ function jobsDir() {
|
|
|
720003
720150
|
}
|
|
720004
720151
|
function loadJob(id2) {
|
|
720005
720152
|
const file = join181(jobsDir(), `${id2}.json`);
|
|
720006
|
-
if (!
|
|
720153
|
+
if (!existsSync168(file)) return null;
|
|
720007
720154
|
try {
|
|
720008
720155
|
return JSON.parse(readFileSync136(file, "utf-8"));
|
|
720009
720156
|
} catch {
|
|
@@ -720012,7 +720159,7 @@ function loadJob(id2) {
|
|
|
720012
720159
|
}
|
|
720013
720160
|
function listJobs2() {
|
|
720014
720161
|
const dir = jobsDir();
|
|
720015
|
-
if (!
|
|
720162
|
+
if (!existsSync168(dir)) return [];
|
|
720016
720163
|
const files = readdirSync58(dir).filter((f2) => f2.endsWith(".json")).sort();
|
|
720017
720164
|
const jobs = [];
|
|
720018
720165
|
for (const file of files) {
|
|
@@ -720029,7 +720176,7 @@ function pruneOldJobs() {
|
|
|
720029
720176
|
const retentionH = parseFloat(process.env["OMNIUS_RUN_RETENTION_H"] || "24");
|
|
720030
720177
|
const cutoffMs = Date.now() - (Number.isFinite(retentionH) && retentionH > 0 ? retentionH : 24) * 36e5;
|
|
720031
720178
|
const dir = jobsDir();
|
|
720032
|
-
if (!
|
|
720179
|
+
if (!existsSync168(dir)) return { pruned: 0, kept: 0 };
|
|
720033
720180
|
let pruned = 0;
|
|
720034
720181
|
let kept = 0;
|
|
720035
720182
|
for (const file of readdirSync58(dir)) {
|
|
@@ -720049,7 +720196,7 @@ function pruneOldJobs() {
|
|
|
720049
720196
|
} catch {
|
|
720050
720197
|
}
|
|
720051
720198
|
const outFile = path12.replace(/\.json$/, ".output");
|
|
720052
|
-
if (
|
|
720199
|
+
if (existsSync168(outFile)) {
|
|
720053
720200
|
try {
|
|
720054
720201
|
unlinkSync36(outFile);
|
|
720055
720202
|
} catch {
|
|
@@ -722191,7 +722338,7 @@ function updateLogPath() {
|
|
|
722191
722338
|
function readUpdateState() {
|
|
722192
722339
|
try {
|
|
722193
722340
|
const p2 = updateStateFile();
|
|
722194
|
-
if (!
|
|
722341
|
+
if (!existsSync168(p2)) return null;
|
|
722195
722342
|
return JSON.parse(readFileSync136(p2, "utf-8"));
|
|
722196
722343
|
} catch {
|
|
722197
722344
|
return null;
|
|
@@ -722252,7 +722399,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
722252
722399
|
const isWin2 = process.platform === "win32";
|
|
722253
722400
|
let npmBin = "";
|
|
722254
722401
|
for (const candidate of isWin2 ? [join181(nodeDir, "npm.cmd"), join181(nodeDir, "npm")] : [join181(nodeDir, "npm"), "/usr/local/bin/npm", "/usr/bin/npm"]) {
|
|
722255
|
-
if (
|
|
722402
|
+
if (existsSync168(candidate)) {
|
|
722256
722403
|
npmBin = candidate;
|
|
722257
722404
|
break;
|
|
722258
722405
|
}
|
|
@@ -722296,7 +722443,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
722296
722443
|
let npmCli = "";
|
|
722297
722444
|
for (const c9 of npmCliCandidates) {
|
|
722298
722445
|
try {
|
|
722299
|
-
if (
|
|
722446
|
+
if (existsSync168(c9)) {
|
|
722300
722447
|
npmCli = c9;
|
|
722301
722448
|
break;
|
|
722302
722449
|
}
|
|
@@ -722356,7 +722503,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
722356
722503
|
let npmCli = "";
|
|
722357
722504
|
for (const c9 of npmCliCandidates) {
|
|
722358
722505
|
try {
|
|
722359
|
-
if (
|
|
722506
|
+
if (existsSync168(c9)) {
|
|
722360
722507
|
npmCli = c9;
|
|
722361
722508
|
break;
|
|
722362
722509
|
}
|
|
@@ -722496,7 +722643,7 @@ function handleV1UpdateStatus(res) {
|
|
|
722496
722643
|
let logTail = "";
|
|
722497
722644
|
let exitCode = null;
|
|
722498
722645
|
try {
|
|
722499
|
-
if (
|
|
722646
|
+
if (existsSync168(logPath3)) {
|
|
722500
722647
|
const raw = readFileSync136(logPath3, "utf-8");
|
|
722501
722648
|
const m2 = raw.match(/__EXIT_CODE=(\d+)/);
|
|
722502
722649
|
if (m2) exitCode = parseInt(m2[1], 10);
|
|
@@ -723083,7 +723230,7 @@ function handleV1RunsById(res, id2) {
|
|
|
723083
723230
|
}
|
|
723084
723231
|
const outputFile = job.outputFile;
|
|
723085
723232
|
const enriched = { ...job };
|
|
723086
|
-
if (outputFile &&
|
|
723233
|
+
if (outputFile && existsSync168(outputFile)) {
|
|
723087
723234
|
try {
|
|
723088
723235
|
const size = statSync62(outputFile).size;
|
|
723089
723236
|
const tailSize = Math.min(size, 4096);
|
|
@@ -724055,7 +724202,7 @@ async function handleRequest(req3, res, ollamaUrl, verbose, runtimeDefaults = {}
|
|
|
724055
724202
|
}
|
|
724056
724203
|
try {
|
|
724057
724204
|
const target = resolve71(rawPath);
|
|
724058
|
-
if (!
|
|
724205
|
+
if (!existsSync168(target)) {
|
|
724059
724206
|
jsonResponse(res, 404, { error: "File not found", path: target });
|
|
724060
724207
|
return;
|
|
724061
724208
|
}
|
|
@@ -727730,7 +727877,7 @@ function startApiServer(options2 = {}) {
|
|
|
727730
727877
|
const fp = join181(dir, fname);
|
|
727731
727878
|
let next = [];
|
|
727732
727879
|
try {
|
|
727733
|
-
if (!
|
|
727880
|
+
if (!existsSync168(fp)) {
|
|
727734
727881
|
const old = cache8.get(sid);
|
|
727735
727882
|
if (old) {
|
|
727736
727883
|
for (const t2 of old.values()) {
|
|
@@ -727804,7 +727951,7 @@ function startApiServer(options2 = {}) {
|
|
|
727804
727951
|
if (!apiTestMode && retentionDays > 0) {
|
|
727805
727952
|
try {
|
|
727806
727953
|
const jobsDir3 = join181(cwd4, ".omnius", "jobs");
|
|
727807
|
-
if (
|
|
727954
|
+
if (existsSync168(jobsDir3)) {
|
|
727808
727955
|
const cutoff = Date.now() - retentionDays * 864e5;
|
|
727809
727956
|
for (const f2 of readdirSync58(jobsDir3)) {
|
|
727810
727957
|
if (!f2.endsWith(".json")) continue;
|
|
@@ -727845,7 +727992,7 @@ function startApiServer(options2 = {}) {
|
|
|
727845
727992
|
let runtimeAccessMode = resolveAccessMode(process.env["OMNIUS_ACCESS"], host);
|
|
727846
727993
|
try {
|
|
727847
727994
|
const accessFile = join181(homedir63(), ".omnius", "access");
|
|
727848
|
-
if (
|
|
727995
|
+
if (existsSync168(accessFile)) {
|
|
727849
727996
|
const persisted = readFileSync136(accessFile, "utf8").trim();
|
|
727850
727997
|
const resolved = resolveAccessMode(persisted, host);
|
|
727851
727998
|
if (resolved) runtimeAccessMode = resolved;
|
|
@@ -728276,7 +728423,7 @@ function startApiServer(options2 = {}) {
|
|
|
728276
728423
|
const here = dirname53(fileURLToPath23(import.meta.url));
|
|
728277
728424
|
for (const rel of ["../package.json", "../../package.json", "../../../package.json", "../../../../package.json"]) {
|
|
728278
728425
|
const p2 = join181(here, rel);
|
|
728279
|
-
if (
|
|
728426
|
+
if (existsSync168(p2)) {
|
|
728280
728427
|
const pkg = JSON.parse(readFileSync136(p2, "utf8"));
|
|
728281
728428
|
if (pkg.name === "omnius" || pkg.name === "@omnius/cli" || pkg.name === "@omnius/monorepo") {
|
|
728282
728429
|
return pkg.version ?? null;
|
|
@@ -729378,7 +729525,7 @@ import {
|
|
|
729378
729525
|
statSync as statSync63,
|
|
729379
729526
|
mkdirSync as mkdirSync109
|
|
729380
729527
|
} from "node:fs";
|
|
729381
|
-
import { existsSync as
|
|
729528
|
+
import { existsSync as existsSync169 } from "node:fs";
|
|
729382
729529
|
import {
|
|
729383
729530
|
readFile as readFileAsync2,
|
|
729384
729531
|
writeFile as writeFileAsync2,
|
|
@@ -729433,7 +729580,7 @@ function getVersion4() {
|
|
|
729433
729580
|
join183(thisDir, "..", "..", "..", "package.json")
|
|
729434
729581
|
];
|
|
729435
729582
|
for (const pkgPath of candidates) {
|
|
729436
|
-
if (
|
|
729583
|
+
if (existsSync169(pkgPath)) {
|
|
729437
729584
|
const pkg = require5(pkgPath);
|
|
729438
729585
|
if (pkg.name === "omnius" || pkg.name === "@omnius/cli" || pkg.name === "@omnius/monorepo") {
|
|
729439
729586
|
return pkg.version ?? "0.0.0";
|
|
@@ -730848,7 +730995,7 @@ function gatherMemorySnippets(root) {
|
|
|
730848
730995
|
join183(root, ".omnius", "memory")
|
|
730849
730996
|
];
|
|
730850
730997
|
for (const dir of dirs) {
|
|
730851
|
-
if (!
|
|
730998
|
+
if (!existsSync169(dir)) continue;
|
|
730852
730999
|
try {
|
|
730853
731000
|
for (const f2 of readdirSync59(dir).filter((f3) => f3.endsWith(".json"))) {
|
|
730854
731001
|
const data = JSON.parse(readFileSync138(join183(dir, f2), "utf-8"));
|
|
@@ -731322,7 +731469,7 @@ ${metabolismMemories}
|
|
|
731322
731469
|
if (!realtimeEnabled)
|
|
731323
731470
|
try {
|
|
731324
731471
|
const archeFile = join183(repoRoot, ".omnius", "arche", "variants.json");
|
|
731325
|
-
if (
|
|
731472
|
+
if (existsSync169(archeFile)) {
|
|
731326
731473
|
const variants = JSON.parse(readFileSync138(archeFile, "utf8"));
|
|
731327
731474
|
if (variants.length > 0) {
|
|
731328
731475
|
let filtered = variants;
|
|
@@ -731513,7 +731660,7 @@ ${skillPack}`;
|
|
|
731513
731660
|
"identity",
|
|
731514
731661
|
"self-state.json"
|
|
731515
731662
|
);
|
|
731516
|
-
if (
|
|
731663
|
+
if (existsSync169(ikStateFile)) {
|
|
731517
731664
|
const selfState = JSON.parse(readFileSync138(ikStateFile, "utf8"));
|
|
731518
731665
|
const lines = [
|
|
731519
731666
|
`[Identity State v${selfState.version}]`,
|
|
@@ -731853,10 +732000,10 @@ Review its full output via sub_agent(action='output', id='${id2}')`
|
|
|
731853
732000
|
}
|
|
731854
732001
|
}
|
|
731855
732002
|
try {
|
|
731856
|
-
const { readdirSync: readdirSync61, readFileSync: readFileSync140, existsSync:
|
|
732003
|
+
const { readdirSync: readdirSync61, readFileSync: readFileSync140, existsSync: existsSync172 } = await import("node:fs");
|
|
731857
732004
|
const { join: pathJoin } = await import("node:path");
|
|
731858
732005
|
const chunksDir = pathJoin(cwd(), ".omnius", "todo-chunks");
|
|
731859
|
-
if (
|
|
732006
|
+
if (existsSync172(chunksDir)) {
|
|
731860
732007
|
const files = readdirSync61(chunksDir).filter(
|
|
731861
732008
|
(f2) => f2.endsWith(".json")
|
|
731862
732009
|
);
|
|
@@ -731929,11 +732076,11 @@ ${lines.join("\n")}`
|
|
|
731929
732076
|
const expand2 = args.expand === true;
|
|
731930
732077
|
if (expand2 && id2.startsWith("todo-ctx-")) {
|
|
731931
732078
|
try {
|
|
731932
|
-
const { readFileSync: readFileSync140, existsSync:
|
|
732079
|
+
const { readFileSync: readFileSync140, existsSync: existsSync172 } = await import("node:fs");
|
|
731933
732080
|
const { join: pathJoin } = await import("node:path");
|
|
731934
732081
|
const chunksDir = pathJoin(cwd(), ".omnius", "todo-chunks");
|
|
731935
732082
|
const todoIdSuffix = id2.replace("todo-ctx-", "");
|
|
731936
|
-
const files =
|
|
732083
|
+
const files = existsSync172(chunksDir) ? (await import("node:fs")).readdirSync(chunksDir).filter((f2) => f2.endsWith(".json")) : [];
|
|
731937
732084
|
let chunkData = null;
|
|
731938
732085
|
for (const f2 of files) {
|
|
731939
732086
|
try {
|
|
@@ -732956,7 +733103,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
732956
733103
|
const ikDir = join183(repoRoot, ".omnius", "identity");
|
|
732957
733104
|
const ikFile = join183(ikDir, "self-state.json");
|
|
732958
733105
|
let ikState;
|
|
732959
|
-
if (
|
|
733106
|
+
if (existsSync169(ikFile)) {
|
|
732960
733107
|
ikState = JSON.parse(await readFileAsync2(ikFile, "utf8"));
|
|
732961
733108
|
} else {
|
|
732962
733109
|
await mkdirAsync(ikDir, { recursive: true });
|
|
@@ -733116,7 +733263,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
733116
733263
|
"identity",
|
|
733117
733264
|
"self-state.json"
|
|
733118
733265
|
);
|
|
733119
|
-
if (
|
|
733266
|
+
if (existsSync169(ikFile)) {
|
|
733120
733267
|
const ikState = JSON.parse(await readFileAsync2(ikFile, "utf8"));
|
|
733121
733268
|
if (!ikState.stats) ikState.stats = { queries_served: 0 };
|
|
733122
733269
|
ikState.stats.queries_served = (ikState.stats.queries_served || 0) + 1;
|
|
@@ -733443,7 +733590,7 @@ async function startInteractive(config, repoPath2) {
|
|
|
733443
733590
|
try {
|
|
733444
733591
|
const omniusDir = join183(repoRoot, ".omnius");
|
|
733445
733592
|
const nexusPidFile = join183(omniusDir, "nexus", "daemon.pid");
|
|
733446
|
-
if (
|
|
733593
|
+
if (existsSync169(nexusPidFile)) {
|
|
733447
733594
|
const pid = parseInt(readFileSync138(nexusPidFile, "utf8").trim(), 10);
|
|
733448
733595
|
if (pid > 0) {
|
|
733449
733596
|
try {
|
|
@@ -734530,7 +734677,7 @@ Respond to the scoped Telegram target when complete.`
|
|
|
734530
734677
|
const out = [];
|
|
734531
734678
|
const pushJsonFiles = (dir, prefix) => {
|
|
734532
734679
|
try {
|
|
734533
|
-
if (!
|
|
734680
|
+
if (!existsSync169(dir)) return;
|
|
734534
734681
|
for (const file of readdirSync59(dir)) {
|
|
734535
734682
|
if (!file.endsWith(".json")) continue;
|
|
734536
734683
|
const id2 = file.replace(/\.json$/, "");
|
|
@@ -734542,10 +734689,10 @@ Respond to the scoped Telegram target when complete.`
|
|
|
734542
734689
|
pushJsonFiles(join183(repoRoot, ".omnius", "checkpoints"), "turn");
|
|
734543
734690
|
try {
|
|
734544
734691
|
const sessionDir2 = join183(repoRoot, ".omnius", "session");
|
|
734545
|
-
if (
|
|
734692
|
+
if (existsSync169(sessionDir2)) {
|
|
734546
734693
|
for (const entry of readdirSync59(sessionDir2)) {
|
|
734547
734694
|
const cp2 = join183(sessionDir2, entry, "checkpoint.json");
|
|
734548
|
-
if (
|
|
734695
|
+
if (existsSync169(cp2))
|
|
734549
734696
|
out.push({ id: `session:${entry}`, label: entry, path: cp2 });
|
|
734550
734697
|
}
|
|
734551
734698
|
}
|
|
@@ -734637,7 +734784,7 @@ This is an independent background session started from /background.`
|
|
|
734637
734784
|
};
|
|
734638
734785
|
try {
|
|
734639
734786
|
const titleFile = join183(repoRoot, ".omnius", "session-title");
|
|
734640
|
-
if (
|
|
734787
|
+
if (existsSync169(titleFile))
|
|
734641
734788
|
sessionTitle = readFileSync138(titleFile, "utf8").trim() || null;
|
|
734642
734789
|
} catch {
|
|
734643
734790
|
}
|
|
@@ -734752,7 +734899,7 @@ This is an independent background session started from /background.`
|
|
|
734752
734899
|
const MAX_HISTORY_LINES = 500;
|
|
734753
734900
|
let savedHistory = [];
|
|
734754
734901
|
try {
|
|
734755
|
-
if (
|
|
734902
|
+
if (existsSync169(HISTORY_FILE)) {
|
|
734756
734903
|
const raw = readFileSync138(HISTORY_FILE, "utf8").trim();
|
|
734757
734904
|
if (raw) savedHistory = raw.split("\n").reverse();
|
|
734758
734905
|
}
|
|
@@ -734871,16 +735018,20 @@ This is an independent background session started from /background.`
|
|
|
734871
735018
|
headerBtnQueue = command;
|
|
734872
735019
|
return;
|
|
734873
735020
|
}
|
|
735021
|
+
const commandToRun = command === "live" ? isLiveSensorActiveForRepo(repoRoot) ? "live stop" : "live run" : command;
|
|
734874
735022
|
if (headerBtnActive && headerBtnActive !== command) {
|
|
734875
735023
|
headerBtnQueue = command;
|
|
734876
735024
|
return;
|
|
734877
735025
|
}
|
|
734878
|
-
if (headerBtnActive === command)
|
|
735026
|
+
if (headerBtnActive === command) {
|
|
735027
|
+
if (command === "live") headerBtnQueue = command;
|
|
735028
|
+
return;
|
|
735029
|
+
}
|
|
734879
735030
|
headerBtnActive = command;
|
|
734880
735031
|
(async () => {
|
|
734881
735032
|
try {
|
|
734882
735033
|
await writeContentAsync(
|
|
734883
|
-
() => handleSlashCommand(
|
|
735034
|
+
() => handleSlashCommand(commandToRun, commandCtxRef)
|
|
734884
735035
|
);
|
|
734885
735036
|
} catch {
|
|
734886
735037
|
}
|
|
@@ -735122,7 +735273,7 @@ This is an independent background session started from /background.`
|
|
|
735122
735273
|
join183(repoRoot, ".omnius", "nexus", "nexus-daemon.mjs"),
|
|
735123
735274
|
join183(_hdir(), ".omnius", "nexus", "nexus-daemon.mjs")
|
|
735124
735275
|
]) {
|
|
735125
|
-
if (
|
|
735276
|
+
if (existsSync169(dp))
|
|
735126
735277
|
try {
|
|
735127
735278
|
_rmStale(dp);
|
|
735128
735279
|
} catch {
|
|
@@ -735135,7 +735286,7 @@ This is an independent background session started from /background.`
|
|
|
735135
735286
|
const _registerNexusDaemon = () => {
|
|
735136
735287
|
try {
|
|
735137
735288
|
const nexusPidFile = join183(autoNexus.getNexusDir(), "daemon.pid");
|
|
735138
|
-
if (
|
|
735289
|
+
if (existsSync169(nexusPidFile)) {
|
|
735139
735290
|
const nPid = parseInt(
|
|
735140
735291
|
readFileSync138(nexusPidFile, "utf8").trim(),
|
|
735141
735292
|
10
|
|
@@ -735318,7 +735469,7 @@ Log: ${nexusLogPath}`
|
|
|
735318
735469
|
const globalNamePath = join183(_hd(), ".omnius", "agent-name");
|
|
735319
735470
|
let agName = "";
|
|
735320
735471
|
try {
|
|
735321
|
-
if (
|
|
735472
|
+
if (existsSync169(globalNamePath))
|
|
735322
735473
|
agName = readFileSync138(globalNamePath, "utf8").trim();
|
|
735323
735474
|
} catch {
|
|
735324
735475
|
}
|
|
@@ -735358,7 +735509,7 @@ Log: ${nexusLogPath}`
|
|
|
735358
735509
|
);
|
|
735359
735510
|
let savedSponsors = [];
|
|
735360
735511
|
try {
|
|
735361
|
-
if (
|
|
735512
|
+
if (existsSync169(savedSponsorsPath)) {
|
|
735362
735513
|
savedSponsors = JSON.parse(
|
|
735363
735514
|
readFileSync138(savedSponsorsPath, "utf8")
|
|
735364
735515
|
);
|
|
@@ -737161,7 +737312,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
737161
737312
|
statusBar.setMicActivity(evt.speechActive, evt.levelDb);
|
|
737162
737313
|
});
|
|
737163
737314
|
listenEng.on("info", (msg) => {
|
|
737164
|
-
if (/consensus rejected|loading whisper|whisper model loaded/i.test(msg)) {
|
|
737315
|
+
if (/consensus rejected|loading whisper|whisper model loaded|Whisper VAD|no accepted speech text|very short utterance/i.test(msg)) {
|
|
737165
737316
|
writeContent(() => renderInfo(`[voicechat/asr] ${msg}`));
|
|
737166
737317
|
}
|
|
737167
737318
|
});
|
|
@@ -737539,7 +737690,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
737539
737690
|
if (!result.success) throw new Error(result.error || "Connect failed");
|
|
737540
737691
|
try {
|
|
737541
737692
|
const nexusPidFile = join183(nexusTool.getNexusDir(), "daemon.pid");
|
|
737542
|
-
if (
|
|
737693
|
+
if (existsSync169(nexusPidFile)) {
|
|
737543
737694
|
const pid = parseInt(readFileSync138(nexusPidFile, "utf8").trim(), 10);
|
|
737544
737695
|
if (pid > 0) {
|
|
737545
737696
|
registry2.register({
|
|
@@ -737752,7 +737903,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
737752
737903
|
try {
|
|
737753
737904
|
const nexusDir = join183(repoRoot, OMNIUS_DIR, "nexus");
|
|
737754
737905
|
const pidFile = join183(nexusDir, "daemon.pid");
|
|
737755
|
-
if (
|
|
737906
|
+
if (existsSync169(pidFile)) {
|
|
737756
737907
|
const pid = parseInt(readFileSync138(pidFile, "utf8").trim(), 10);
|
|
737757
737908
|
if (pid > 0) {
|
|
737758
737909
|
try {
|
|
@@ -737781,7 +737932,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
737781
737932
|
const voicePidFiles = ["luxtts-daemon.pid", "piper-daemon.pid"];
|
|
737782
737933
|
for (const pf of voicePidFiles) {
|
|
737783
737934
|
const pidPath = join183(voiceDir3, pf);
|
|
737784
|
-
if (
|
|
737935
|
+
if (existsSync169(pidPath)) {
|
|
737785
737936
|
try {
|
|
737786
737937
|
const pid = parseInt(readFileSync138(pidPath, "utf8").trim(), 10);
|
|
737787
737938
|
if (pid > 0) {
|
|
@@ -737805,7 +737956,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
737805
737956
|
}
|
|
737806
737957
|
await delay3(process.platform === "win32" ? 1e3 : 500);
|
|
737807
737958
|
const omniusPath = join183(repoRoot, OMNIUS_DIR);
|
|
737808
|
-
if (
|
|
737959
|
+
if (existsSync169(omniusPath)) {
|
|
737809
737960
|
let deleted = false;
|
|
737810
737961
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
737811
737962
|
try {
|
|
@@ -737923,9 +738074,9 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
737923
738074
|
"personaplex",
|
|
737924
738075
|
"daemon.port"
|
|
737925
738076
|
);
|
|
737926
|
-
if (
|
|
738077
|
+
if (existsSync169(ppPidFile)) {
|
|
737927
738078
|
const ppPid = parseInt(readFileSync138(ppPidFile, "utf8").trim(), 10);
|
|
737928
|
-
const ppPort =
|
|
738079
|
+
const ppPort = existsSync169(ppPortFile) ? parseInt(readFileSync138(ppPortFile, "utf8").trim(), 10) : void 0;
|
|
737929
738080
|
if (ppPid > 0 && !registry2.daemons.has("PersonaPlex")) {
|
|
737930
738081
|
registry2.register({
|
|
737931
738082
|
name: "PersonaPlex",
|
|
@@ -737941,7 +738092,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
737941
738092
|
new NexusTool(repoRoot).getNexusDir(),
|
|
737942
738093
|
"daemon.pid"
|
|
737943
738094
|
);
|
|
737944
|
-
if (
|
|
738095
|
+
if (existsSync169(nexusPidFile)) {
|
|
737945
738096
|
const nPid = parseInt(readFileSync138(nexusPidFile, "utf8").trim(), 10);
|
|
737946
738097
|
if (nPid > 0 && !registry2.daemons.has("Nexus")) {
|
|
737947
738098
|
try {
|
|
@@ -738375,9 +738526,9 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
738375
738526
|
}
|
|
738376
738527
|
}
|
|
738377
738528
|
const cleanPath = input.replace(/^['"]|['"]$/g, "").trim();
|
|
738378
|
-
const isImage = isImagePath(cleanPath) &&
|
|
738379
|
-
const isMedia = !isImage && isTranscribablePath(cleanPath) &&
|
|
738380
|
-
const isMarkdown = !isImage && !isMedia && /\.(md|markdown)$/i.test(cleanPath) &&
|
|
738529
|
+
const isImage = isImagePath(cleanPath) && existsSync169(resolve72(repoRoot, cleanPath));
|
|
738530
|
+
const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync169(resolve72(repoRoot, cleanPath));
|
|
738531
|
+
const isMarkdown = !isImage && !isMedia && /\.(md|markdown)$/i.test(cleanPath) && existsSync169(resolve72(repoRoot, cleanPath));
|
|
738381
738532
|
if (activeTask) {
|
|
738382
738533
|
if ((isImage || isMedia) && activeTask.runner.isPaused) {
|
|
738383
738534
|
activeTask.runner.resume();
|
|
@@ -739316,7 +739467,7 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
739316
739467
|
const ikDir = join183(repoRoot, ".omnius", "identity");
|
|
739317
739468
|
const ikFile = join183(ikDir, "self-state.json");
|
|
739318
739469
|
let ikState;
|
|
739319
|
-
if (
|
|
739470
|
+
if (existsSync169(ikFile)) {
|
|
739320
739471
|
ikState = JSON.parse(readFileSync138(ikFile, "utf8"));
|
|
739321
739472
|
} else {
|
|
739322
739473
|
mkdirSync109(ikDir, { recursive: true });
|
|
@@ -739389,7 +739540,7 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
739389
739540
|
const archeFile = join183(archeDir, "variants.json");
|
|
739390
739541
|
let variants = [];
|
|
739391
739542
|
try {
|
|
739392
|
-
if (
|
|
739543
|
+
if (existsSync169(archeFile))
|
|
739393
739544
|
variants = JSON.parse(readFileSync138(archeFile, "utf8"));
|
|
739394
739545
|
} catch {
|
|
739395
739546
|
}
|
|
@@ -739417,7 +739568,7 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
739417
739568
|
"metabolism",
|
|
739418
739569
|
"store.json"
|
|
739419
739570
|
);
|
|
739420
|
-
if (
|
|
739571
|
+
if (existsSync169(metaFile2)) {
|
|
739421
739572
|
const store2 = JSON.parse(readFileSync138(metaFile2, "utf8"));
|
|
739422
739573
|
const surfaced = store2.filter(
|
|
739423
739574
|
(m2) => m2.type !== "quarantine" && m2.scores?.confidence > 0.15
|
|
@@ -739520,7 +739671,7 @@ Rules:
|
|
|
739520
739671
|
const storeFile = join183(metaDir, "store.json");
|
|
739521
739672
|
let store2 = [];
|
|
739522
739673
|
try {
|
|
739523
|
-
if (
|
|
739674
|
+
if (existsSync169(storeFile))
|
|
739524
739675
|
store2 = JSON.parse(readFileSync138(storeFile, "utf8"));
|
|
739525
739676
|
} catch {
|
|
739526
739677
|
}
|
|
@@ -739554,7 +739705,7 @@ Rules:
|
|
|
739554
739705
|
const cohereSettingsFile = join183(repoRoot, ".omnius", "settings.json");
|
|
739555
739706
|
let cohereActive = false;
|
|
739556
739707
|
try {
|
|
739557
|
-
if (
|
|
739708
|
+
if (existsSync169(cohereSettingsFile)) {
|
|
739558
739709
|
const settings = JSON.parse(readFileSync138(cohereSettingsFile, "utf8"));
|
|
739559
739710
|
cohereActive = settings.cohere === true;
|
|
739560
739711
|
}
|
|
@@ -739568,7 +739719,7 @@ Rules:
|
|
|
739568
739719
|
"metabolism",
|
|
739569
739720
|
"store.json"
|
|
739570
739721
|
);
|
|
739571
|
-
if (
|
|
739722
|
+
if (existsSync169(metaFile2)) {
|
|
739572
739723
|
const store2 = JSON.parse(readFileSync138(metaFile2, "utf8"));
|
|
739573
739724
|
const latest = store2.filter(
|
|
739574
739725
|
(m2) => m2.sourceTrace === "trajectory-extraction" || m2.sourceTrace === "llm-trajectory-extraction"
|
|
@@ -739601,7 +739752,7 @@ Rules:
|
|
|
739601
739752
|
}
|
|
739602
739753
|
try {
|
|
739603
739754
|
const ikFile = join183(repoRoot, ".omnius", "identity", "self-state.json");
|
|
739604
|
-
if (
|
|
739755
|
+
if (existsSync169(ikFile)) {
|
|
739605
739756
|
const ikState = JSON.parse(readFileSync138(ikFile, "utf8"));
|
|
739606
739757
|
ikState.homeostasis.uncertainty = Math.min(
|
|
739607
739758
|
1,
|
|
@@ -739622,7 +739773,7 @@ Rules:
|
|
|
739622
739773
|
"metabolism",
|
|
739623
739774
|
"store.json"
|
|
739624
739775
|
);
|
|
739625
|
-
if (
|
|
739776
|
+
if (existsSync169(metaFile2)) {
|
|
739626
739777
|
const store2 = JSON.parse(readFileSync138(metaFile2, "utf8"));
|
|
739627
739778
|
const surfaced = store2.filter(
|
|
739628
739779
|
(m2) => m2.type !== "quarantine" && m2.scores?.confidence > 0.15
|
|
@@ -739648,7 +739799,7 @@ Rules:
|
|
|
739648
739799
|
const archeFile = join183(archeDir, "variants.json");
|
|
739649
739800
|
let variants = [];
|
|
739650
739801
|
try {
|
|
739651
|
-
if (
|
|
739802
|
+
if (existsSync169(archeFile))
|
|
739652
739803
|
variants = JSON.parse(readFileSync138(archeFile, "utf8"));
|
|
739653
739804
|
} catch {
|
|
739654
739805
|
}
|
|
@@ -739790,7 +739941,7 @@ import {
|
|
|
739790
739941
|
writeFileSync as writeFileSync93,
|
|
739791
739942
|
readFileSync as readFileSync139,
|
|
739792
739943
|
readdirSync as readdirSync60,
|
|
739793
|
-
existsSync as
|
|
739944
|
+
existsSync as existsSync170
|
|
739794
739945
|
} from "node:fs";
|
|
739795
739946
|
import { randomBytes as randomBytes30 } from "node:crypto";
|
|
739796
739947
|
import { join as join184 } from "node:path";
|
|
@@ -739991,7 +740142,7 @@ async function runBackground(task, config, opts) {
|
|
|
739991
740142
|
function statusCommand(jobId, repoPath2) {
|
|
739992
740143
|
const dir = jobsDir2(repoPath2);
|
|
739993
740144
|
const file = join184(dir, `${jobId}.json`);
|
|
739994
|
-
if (!
|
|
740145
|
+
if (!existsSync170(file)) {
|
|
739995
740146
|
console.error(`Job not found: ${jobId}`);
|
|
739996
740147
|
console.log(`Available jobs: omnius jobs`);
|
|
739997
740148
|
process.exit(1);
|
|
@@ -740045,13 +740196,13 @@ __export(index_repo_exports, {
|
|
|
740045
740196
|
indexRepoCommand: () => indexRepoCommand
|
|
740046
740197
|
});
|
|
740047
740198
|
import { resolve as resolve74 } from "node:path";
|
|
740048
|
-
import { existsSync as
|
|
740199
|
+
import { existsSync as existsSync171, statSync as statSync64 } from "node:fs";
|
|
740049
740200
|
import { cwd as cwd2 } from "node:process";
|
|
740050
740201
|
async function indexRepoCommand(opts, _config3) {
|
|
740051
740202
|
const repoRoot = resolve74(opts.repoPath ?? cwd2());
|
|
740052
740203
|
printHeader("Index Repository");
|
|
740053
740204
|
printInfo(`Indexing: ${repoRoot}`);
|
|
740054
|
-
if (!
|
|
740205
|
+
if (!existsSync171(repoRoot)) {
|
|
740055
740206
|
printError(`Path does not exist: ${repoRoot}`);
|
|
740056
740207
|
process.exit(1);
|
|
740057
740208
|
}
|