omnius 1.0.200 → 1.0.201
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 +795 -677
- package/npm-shrinkwrap.json +22 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -258385,9 +258385,9 @@ print("${sentinel}")
|
|
|
258385
258385
|
if (!this.proc || this.proc.killed) {
|
|
258386
258386
|
return { success: false, path: "" };
|
|
258387
258387
|
}
|
|
258388
|
-
const { mkdirSync:
|
|
258388
|
+
const { mkdirSync: mkdirSync89, writeFileSync: writeFileSync80 } = await import("node:fs");
|
|
258389
258389
|
const sessionDir2 = join36(this.cwd, ".omnius", "rlm");
|
|
258390
|
-
|
|
258390
|
+
mkdirSync89(sessionDir2, { recursive: true });
|
|
258391
258391
|
const sessionPath2 = join36(sessionDir2, "session.json");
|
|
258392
258392
|
try {
|
|
258393
258393
|
const inspectCode = `
|
|
@@ -258411,7 +258411,7 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
258411
258411
|
trajectoryCount: this.trajectory.length,
|
|
258412
258412
|
subCallCount: this.subCallCount
|
|
258413
258413
|
};
|
|
258414
|
-
|
|
258414
|
+
writeFileSync80(sessionPath2, JSON.stringify(sessionData, null, 2), "utf8");
|
|
258415
258415
|
return { success: true, path: sessionPath2 };
|
|
258416
258416
|
}
|
|
258417
258417
|
} catch {
|
|
@@ -259020,7 +259020,7 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
259020
259020
|
/** Update memory scores based on task outcome. Called after task completion.
|
|
259021
259021
|
* Memories used in successful tasks get boosted. Memories present during failures get decayed. */
|
|
259022
259022
|
updateFromOutcomeSync(surfacedMemoryText, succeeded) {
|
|
259023
|
-
const { readFileSync: readFileSync117, writeFileSync:
|
|
259023
|
+
const { readFileSync: readFileSync117, writeFileSync: writeFileSync80, existsSync: existsSync144, mkdirSync: mkdirSync89 } = __require("node:fs");
|
|
259024
259024
|
const metaDir = join37(this.cwd, ".omnius", "memory", "metabolism");
|
|
259025
259025
|
const storeFile = join37(metaDir, "store.json");
|
|
259026
259026
|
if (!existsSync144(storeFile))
|
|
@@ -259051,8 +259051,8 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
259051
259051
|
updated = true;
|
|
259052
259052
|
}
|
|
259053
259053
|
if (updated) {
|
|
259054
|
-
|
|
259055
|
-
|
|
259054
|
+
mkdirSync89(metaDir, { recursive: true });
|
|
259055
|
+
writeFileSync80(storeFile, JSON.stringify(store2, null, 2));
|
|
259056
259056
|
}
|
|
259057
259057
|
}
|
|
259058
259058
|
// ── Storage ──────────────────────────────────────────────────────────
|
|
@@ -259498,7 +259498,7 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
259498
259498
|
}
|
|
259499
259499
|
/** Archive a strategy variant synchronously (for task completion path) */
|
|
259500
259500
|
archiveVariantSync(strategy, outcome, tags = []) {
|
|
259501
|
-
const { readFileSync: readFileSync117, writeFileSync:
|
|
259501
|
+
const { readFileSync: readFileSync117, writeFileSync: writeFileSync80, existsSync: existsSync144, mkdirSync: mkdirSync89 } = __require("node:fs");
|
|
259502
259502
|
const dir = join39(this.cwd, ".omnius", "arche");
|
|
259503
259503
|
const archiveFile = join39(dir, "variants.json");
|
|
259504
259504
|
let variants = [];
|
|
@@ -259519,8 +259519,8 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
259519
259519
|
});
|
|
259520
259520
|
if (variants.length > 50)
|
|
259521
259521
|
variants = variants.slice(-50);
|
|
259522
|
-
|
|
259523
|
-
|
|
259522
|
+
mkdirSync89(dir, { recursive: true });
|
|
259523
|
+
writeFileSync80(archiveFile, JSON.stringify(variants, null, 2));
|
|
259524
259524
|
}
|
|
259525
259525
|
async saveArchive(variants) {
|
|
259526
259526
|
const dir = join39(this.cwd, ".omnius", "arche");
|
|
@@ -550166,12 +550166,12 @@ var init_reflectionBuffer = __esm({
|
|
|
550166
550166
|
if (!this.persistPath)
|
|
550167
550167
|
return;
|
|
550168
550168
|
try {
|
|
550169
|
-
const { writeFileSync:
|
|
550169
|
+
const { writeFileSync: writeFileSync80, mkdirSync: mkdirSync89, existsSync: existsSync144 } = __require("node:fs");
|
|
550170
550170
|
const { join: join160 } = __require("node:path");
|
|
550171
550171
|
const dir = join160(this.persistPath, "..");
|
|
550172
550172
|
if (!existsSync144(dir))
|
|
550173
|
-
|
|
550174
|
-
|
|
550173
|
+
mkdirSync89(dir, { recursive: true });
|
|
550174
|
+
writeFileSync80(this.persistPath, JSON.stringify(this.state, null, 2));
|
|
550175
550175
|
} catch {
|
|
550176
550176
|
}
|
|
550177
550177
|
}
|
|
@@ -550385,15 +550385,17 @@ function loadMessagePairsFromLog(omniusDir, opts) {
|
|
|
550385
550385
|
const now = Date.now();
|
|
550386
550386
|
const norm = (s2) => s2.toLowerCase().replace(/\s+/g, " ").replace(/[.!?,;:]+$/g, "").trim();
|
|
550387
550387
|
const taskNorm = norm(opts.currentTask.slice(0, 500));
|
|
550388
|
+
const eligible = records.filter((rec) => now - rec.recordedAt <= ttl && norm(rec.handoff.priorGoal) !== taskNorm);
|
|
550389
|
+
const signature = (rec) => `${norm(rec.handoff.priorGoal)}|${[...rec.handoff.filesTouched].sort().join(",")}`;
|
|
550390
|
+
const lastIndexBySig = /* @__PURE__ */ new Map();
|
|
550391
|
+
eligible.forEach((rec, i2) => lastIndexBySig.set(signature(rec), i2));
|
|
550388
550392
|
const out = [];
|
|
550389
|
-
|
|
550390
|
-
if (
|
|
550391
|
-
|
|
550392
|
-
if (norm(rec.handoff.priorGoal) === taskNorm)
|
|
550393
|
-
continue;
|
|
550393
|
+
eligible.forEach((rec, i2) => {
|
|
550394
|
+
if (lastIndexBySig.get(signature(rec)) !== i2)
|
|
550395
|
+
return;
|
|
550394
550396
|
const pair = buildHandoffMessagePair(rec.handoff);
|
|
550395
550397
|
out.push(pair[0], pair[1]);
|
|
550396
|
-
}
|
|
550398
|
+
});
|
|
550397
550399
|
return out;
|
|
550398
550400
|
}
|
|
550399
550401
|
function trimLog(omniusDir) {
|
|
@@ -554703,7 +554705,8 @@ var init_agenticRunner = __esm({
|
|
|
554703
554705
|
// Phase 4 — sub-agent isolation flag (defaults false). When true, this
|
|
554704
554706
|
// runner skips cross-task handoff inheritance from the parent's
|
|
554705
554707
|
// session.
|
|
554706
|
-
subAgent: options2?.subAgent ?? false
|
|
554708
|
+
subAgent: options2?.subAgent ?? false,
|
|
554709
|
+
skipCrossTaskHandoff: options2?.skipCrossTaskHandoff ?? false
|
|
554707
554710
|
};
|
|
554708
554711
|
this._observerMode = this.options.observerMode;
|
|
554709
554712
|
}
|
|
@@ -558459,6 +558462,10 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
558459
558462
|
try {
|
|
558460
558463
|
if (this.options.subAgent)
|
|
558461
558464
|
throw "skip-handoff-subagent";
|
|
558465
|
+
if (this.options.skipCrossTaskHandoff)
|
|
558466
|
+
throw "skip-handoff-caller-optout";
|
|
558467
|
+
if (/<task-handoff>|<session-recap>/.test(task))
|
|
558468
|
+
throw "skip-handoff-restore-supplied";
|
|
558462
558469
|
if (process.env["OMNIUS_FRESH_SESSION"] === "1")
|
|
558463
558470
|
throw "skip-handoff-fresh";
|
|
558464
558471
|
const omniusDir = this._workingDirectory ? _pathJoin(this._workingDirectory, ".omnius") : _pathJoin(process.cwd(), ".omnius");
|
|
@@ -563807,10 +563814,10 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
563807
563814
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
563808
563815
|
});
|
|
563809
563816
|
try {
|
|
563810
|
-
const { mkdirSync:
|
|
563817
|
+
const { mkdirSync: mkdirSync89, readdirSync: readdirSync53, statSync: statSync53, unlinkSync: unlinkSync31, writeFileSync: writeFileSync80 } = __require("node:fs");
|
|
563811
563818
|
const { join: join160 } = __require("node:path");
|
|
563812
563819
|
const contextDir = join160(this._workingDirectory || process.cwd(), ".omnius", "context");
|
|
563813
|
-
|
|
563820
|
+
mkdirSync89(contextDir, { recursive: true });
|
|
563814
563821
|
const topEntities = this._temporalGraph.nodesByType("entity", 3);
|
|
563815
563822
|
const topFiles = this._temporalGraph.nodesByType("file", 3);
|
|
563816
563823
|
const topConcepts = this._temporalGraph.nodesByType("concept", 3);
|
|
@@ -563851,17 +563858,17 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
563851
563858
|
section("Top Concepts", topConcepts);
|
|
563852
563859
|
lines.push("(Use file_read on this file for quick recall. See provenance JSON for full edge detail.)");
|
|
563853
563860
|
const kgSummaryDir = join160(contextDir, "kg-summary");
|
|
563854
|
-
|
|
563861
|
+
mkdirSync89(kgSummaryDir, { recursive: true });
|
|
563855
563862
|
const summaryFilename = `kg-summary-${this._sessionId}.md`;
|
|
563856
563863
|
const outPath = join160(kgSummaryDir, summaryFilename);
|
|
563857
|
-
|
|
563858
|
-
|
|
563859
|
-
|
|
563864
|
+
writeFileSync80(outPath, lines.join("\n"), "utf-8");
|
|
563865
|
+
writeFileSync80(join160(kgSummaryDir, "latest.md"), lines.join("\n"), "utf-8");
|
|
563866
|
+
writeFileSync80(join160(contextDir, `kg-summary-latest.md`), [
|
|
563860
563867
|
"Latest KG summary moved to `.omnius/context/kg-summary/latest.md`.",
|
|
563861
563868
|
"",
|
|
563862
563869
|
lines.join("\n")
|
|
563863
563870
|
].join("\n"), "utf-8");
|
|
563864
|
-
|
|
563871
|
+
writeFileSync80(join160(kgSummaryDir, "index.json"), JSON.stringify({
|
|
563865
563872
|
schema: "omnius.kg-summary-index.v1",
|
|
563866
563873
|
latest: "latest.md",
|
|
563867
563874
|
latestSessionFile: summaryFilename,
|
|
@@ -564151,11 +564158,11 @@ ${errOutput}`);
|
|
|
564151
564158
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
564152
564159
|
});
|
|
564153
564160
|
try {
|
|
564154
|
-
const { mkdirSync:
|
|
564161
|
+
const { mkdirSync: mkdirSync89, writeFileSync: writeFileSync80 } = __require("node:fs");
|
|
564155
564162
|
const { join: join160 } = __require("node:path");
|
|
564156
564163
|
const resultsDir = join160(this.omniusStateDir(), "tool-results");
|
|
564157
|
-
|
|
564158
|
-
|
|
564164
|
+
mkdirSync89(resultsDir, { recursive: true });
|
|
564165
|
+
writeFileSync80(join160(resultsDir, `${handleId}.txt`), `# Tool: ${toolName}
|
|
564159
564166
|
# Turn: ${turn}
|
|
564160
564167
|
# Timestamp: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
564161
564168
|
# Size: ${result.output.length} chars, ${lineCount} lines
|
|
@@ -564548,10 +564555,10 @@ Actions: (1) list_directory on the parent directory to see what's there, (2) Che
|
|
|
564548
564555
|
if (!this._workingDirectory)
|
|
564549
564556
|
return;
|
|
564550
564557
|
try {
|
|
564551
|
-
const { mkdirSync:
|
|
564558
|
+
const { mkdirSync: mkdirSync89, writeFileSync: writeFileSync80 } = __require("node:fs");
|
|
564552
564559
|
const { join: join160 } = __require("node:path");
|
|
564553
564560
|
const sessionDir2 = this.options.stateDir ? join160(this.omniusStateDir(), "session", this._sessionId) : join160(this._workingDirectory, ".omnius", "session", this._sessionId);
|
|
564554
|
-
|
|
564561
|
+
mkdirSync89(sessionDir2, { recursive: true });
|
|
564555
564562
|
const checkpoint = {
|
|
564556
564563
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
564557
564564
|
sessionId: this._sessionId,
|
|
@@ -564563,7 +564570,7 @@ Actions: (1) list_directory on the parent directory to see what's there, (2) Che
|
|
|
564563
564570
|
memexEntryCount: this._memexArchive.size,
|
|
564564
564571
|
fileRegistrySize: this._fileRegistry.size
|
|
564565
564572
|
};
|
|
564566
|
-
|
|
564573
|
+
writeFileSync80(join160(sessionDir2, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
|
|
564567
564574
|
} catch {
|
|
564568
564575
|
}
|
|
564569
564576
|
}
|
|
@@ -566976,12 +566983,12 @@ ${result}`
|
|
|
566976
566983
|
let resizedBase64 = null;
|
|
566977
566984
|
try {
|
|
566978
566985
|
const { execSync: execSync62 } = await import("node:child_process");
|
|
566979
|
-
const { writeFileSync:
|
|
566986
|
+
const { writeFileSync: writeFileSync80, readFileSync: readFileSync117, unlinkSync: unlinkSync31 } = await import("node:fs");
|
|
566980
566987
|
const { join: join160 } = await import("node:path");
|
|
566981
566988
|
const { tmpdir: tmpdir23 } = await import("node:os");
|
|
566982
566989
|
const tmpIn = join160(tmpdir23(), `omnius_img_in_${Date.now()}.png`);
|
|
566983
566990
|
const tmpOut = join160(tmpdir23(), `omnius_img_out_${Date.now()}.jpg`);
|
|
566984
|
-
|
|
566991
|
+
writeFileSync80(tmpIn, buffer2);
|
|
566985
566992
|
const pyBin = process.platform === "win32" ? "python" : "python3";
|
|
566986
566993
|
const escapedIn = tmpIn.replace(/\\/g, "\\\\");
|
|
566987
566994
|
const escapedOut = tmpOut.replace(/\\/g, "\\\\");
|
|
@@ -609736,13 +609743,13 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
609736
609743
|
try {
|
|
609737
609744
|
const { randomBytes: randomBytes29 } = await import("node:crypto");
|
|
609738
609745
|
const { homedir: homedir56 } = await import("node:os");
|
|
609739
|
-
const { mkdirSync:
|
|
609746
|
+
const { mkdirSync: mkdirSync89, writeFileSync: writeFileSync80 } = await import("node:fs");
|
|
609740
609747
|
const { join: join160 } = await import("node:path");
|
|
609741
609748
|
const newKey = randomBytes29(16).toString("hex");
|
|
609742
609749
|
process.env["OMNIUS_API_KEY"] = newKey;
|
|
609743
609750
|
const dir = join160(homedir56(), ".omnius");
|
|
609744
|
-
|
|
609745
|
-
|
|
609751
|
+
mkdirSync89(dir, { recursive: true });
|
|
609752
|
+
writeFileSync80(join160(dir, "api.key"), newKey + "\n", "utf8");
|
|
609746
609753
|
renderInfo(`New API key: ${c3.bold(c3.yellow(newKey))}`);
|
|
609747
609754
|
renderInfo(
|
|
609748
609755
|
"Restart the daemon to apply if needed. Use /access any to restart quickly."
|
|
@@ -610007,11 +610014,11 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
610007
610014
|
);
|
|
610008
610015
|
try {
|
|
610009
610016
|
const { homedir: homedir57 } = await import("node:os");
|
|
610010
|
-
const { mkdirSync:
|
|
610017
|
+
const { mkdirSync: mkdirSync90, writeFileSync: writeFileSync81 } = await import("node:fs");
|
|
610011
610018
|
const { join: join161 } = await import("node:path");
|
|
610012
610019
|
const dir = join161(homedir57(), ".omnius");
|
|
610013
|
-
|
|
610014
|
-
|
|
610020
|
+
mkdirSync90(dir, { recursive: true });
|
|
610021
|
+
writeFileSync81(join161(dir, "api.key"), apiKey + "\n", "utf8");
|
|
610015
610022
|
} catch {
|
|
610016
610023
|
}
|
|
610017
610024
|
}
|
|
@@ -610023,11 +610030,11 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
610023
610030
|
const port2 = parseInt(process.env["OMNIUS_PORT"] || "11435", 10);
|
|
610024
610031
|
try {
|
|
610025
610032
|
const { homedir: homedir57 } = await import("node:os");
|
|
610026
|
-
const { mkdirSync:
|
|
610033
|
+
const { mkdirSync: mkdirSync90, writeFileSync: writeFileSync81 } = await import("node:fs");
|
|
610027
610034
|
const { join: join161 } = await import("node:path");
|
|
610028
610035
|
const dir = join161(homedir57(), ".omnius");
|
|
610029
|
-
|
|
610030
|
-
|
|
610036
|
+
mkdirSync90(dir, { recursive: true });
|
|
610037
|
+
writeFileSync81(join161(dir, "access"), `${val2}
|
|
610031
610038
|
`, "utf8");
|
|
610032
610039
|
} catch {
|
|
610033
610040
|
}
|
|
@@ -610127,11 +610134,11 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
610127
610134
|
);
|
|
610128
610135
|
try {
|
|
610129
610136
|
const { homedir: homedir57 } = await import("node:os");
|
|
610130
|
-
const { mkdirSync:
|
|
610137
|
+
const { mkdirSync: mkdirSync90, writeFileSync: writeFileSync81 } = await import("node:fs");
|
|
610131
610138
|
const { join: join161 } = await import("node:path");
|
|
610132
610139
|
const dir = join161(homedir57(), ".omnius");
|
|
610133
|
-
|
|
610134
|
-
|
|
610140
|
+
mkdirSync90(dir, { recursive: true });
|
|
610141
|
+
writeFileSync81(join161(dir, "api.key"), apiKey + "\n", "utf8");
|
|
610135
610142
|
} catch {
|
|
610136
610143
|
}
|
|
610137
610144
|
}
|
|
@@ -610142,12 +610149,12 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
610142
610149
|
}
|
|
610143
610150
|
const port = parseInt(process.env["OMNIUS_PORT"] || "11435", 10);
|
|
610144
610151
|
const { homedir: homedir56 } = await import("node:os");
|
|
610145
|
-
const { mkdirSync:
|
|
610152
|
+
const { mkdirSync: mkdirSync89, writeFileSync: writeFileSync80 } = await import("node:fs");
|
|
610146
610153
|
const { join: join160 } = await import("node:path");
|
|
610147
610154
|
try {
|
|
610148
610155
|
const dir = join160(homedir56(), ".omnius");
|
|
610149
|
-
|
|
610150
|
-
|
|
610156
|
+
mkdirSync89(dir, { recursive: true });
|
|
610157
|
+
writeFileSync80(join160(dir, "access"), `${val}
|
|
610151
610158
|
`, "utf8");
|
|
610152
610159
|
} catch (e2) {
|
|
610153
610160
|
renderWarning(
|
|
@@ -618111,7 +618118,7 @@ async function handleVoiceMenu(ctx3, save2, hasLocal) {
|
|
|
618111
618118
|
const { basename: basename38, join: pathJoin } = await import("node:path");
|
|
618112
618119
|
const {
|
|
618113
618120
|
copyFileSync: copyFileSync5,
|
|
618114
|
-
mkdirSync:
|
|
618121
|
+
mkdirSync: mkdirSync89,
|
|
618115
618122
|
existsSync: exists2
|
|
618116
618123
|
} = await import("node:fs");
|
|
618117
618124
|
const { homedir: homedir56 } = await import("node:os");
|
|
@@ -618126,7 +618133,7 @@ async function handleVoiceMenu(ctx3, save2, hasLocal) {
|
|
|
618126
618133
|
"models",
|
|
618127
618134
|
modelName
|
|
618128
618135
|
);
|
|
618129
|
-
if (!exists2(destDir))
|
|
618136
|
+
if (!exists2(destDir)) mkdirSync89(destDir, { recursive: true });
|
|
618130
618137
|
copyFileSync5(onnxDrop.path, pathJoin(destDir, "model.onnx"));
|
|
618131
618138
|
copyFileSync5(jsonDrop.path, pathJoin(destDir, "config.json"));
|
|
618132
618139
|
const { registerCustomOnnxModel: registerCustomOnnxModel2 } = await Promise.resolve().then(() => (init_voice(), voice_exports));
|
|
@@ -619597,13 +619604,13 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
619597
619604
|
sponsors.push(...verified);
|
|
619598
619605
|
if (verified.length > 0) {
|
|
619599
619606
|
try {
|
|
619600
|
-
const { mkdirSync:
|
|
619601
|
-
|
|
619607
|
+
const { mkdirSync: mkdirSync89, writeFileSync: writeFileSync80 } = __require("node:fs");
|
|
619608
|
+
mkdirSync89(sponsorDir2, { recursive: true });
|
|
619602
619609
|
const cached = verified.map((s2) => ({
|
|
619603
619610
|
...s2,
|
|
619604
619611
|
lastVerified: Date.now()
|
|
619605
619612
|
}));
|
|
619606
|
-
|
|
619613
|
+
writeFileSync80(knownFile, JSON.stringify(cached, null, 2));
|
|
619607
619614
|
} catch {
|
|
619608
619615
|
}
|
|
619609
619616
|
}
|
|
@@ -619807,7 +619814,7 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels
|
|
|
619807
619814
|
}
|
|
619808
619815
|
if (models.length > 0) {
|
|
619809
619816
|
try {
|
|
619810
|
-
const { writeFileSync:
|
|
619817
|
+
const { writeFileSync: writeFileSync80, mkdirSync: mkdirSync89 } = await import("node:fs");
|
|
619811
619818
|
const { join: join160, dirname: dirname46 } = await import("node:path");
|
|
619812
619819
|
const cachePath = join160(
|
|
619813
619820
|
ctx3.repoRoot || process.cwd(),
|
|
@@ -619815,8 +619822,8 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels
|
|
|
619815
619822
|
"nexus",
|
|
619816
619823
|
"peer-models-cache.json"
|
|
619817
619824
|
);
|
|
619818
|
-
|
|
619819
|
-
|
|
619825
|
+
mkdirSync89(dirname46(cachePath), { recursive: true });
|
|
619826
|
+
writeFileSync80(
|
|
619820
619827
|
cachePath,
|
|
619821
619828
|
JSON.stringify(
|
|
619822
619829
|
{
|
|
@@ -619888,7 +619895,7 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels
|
|
|
619888
619895
|
}));
|
|
619889
619896
|
renderWarning("Live model probe failed; using sponsor directory model advertisement.");
|
|
619890
619897
|
try {
|
|
619891
|
-
const { writeFileSync:
|
|
619898
|
+
const { writeFileSync: writeFileSync80, mkdirSync: mkdirSync89 } = await import("node:fs");
|
|
619892
619899
|
const { join: join160, dirname: dirname46 } = await import("node:path");
|
|
619893
619900
|
const cachePath = join160(
|
|
619894
619901
|
ctx3.repoRoot || process.cwd(),
|
|
@@ -619896,8 +619903,8 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels
|
|
|
619896
619903
|
"nexus",
|
|
619897
619904
|
"peer-models-cache.json"
|
|
619898
619905
|
);
|
|
619899
|
-
|
|
619900
|
-
|
|
619906
|
+
mkdirSync89(dirname46(cachePath), { recursive: true });
|
|
619907
|
+
writeFileSync80(
|
|
619901
619908
|
cachePath,
|
|
619902
619909
|
JSON.stringify({
|
|
619903
619910
|
peerId,
|
|
@@ -622499,13 +622506,13 @@ var init_commands = __esm({
|
|
|
622499
622506
|
try {
|
|
622500
622507
|
const { randomBytes: randomBytes29 } = await import("node:crypto");
|
|
622501
622508
|
const { homedir: homedir56 } = await import("node:os");
|
|
622502
|
-
const { mkdirSync:
|
|
622509
|
+
const { mkdirSync: mkdirSync89, writeFileSync: writeFileSync80 } = await import("node:fs");
|
|
622503
622510
|
const { join: join160 } = await import("node:path");
|
|
622504
622511
|
const apiKey = randomBytes29(16).toString("hex");
|
|
622505
622512
|
process.env["OMNIUS_API_KEY"] = apiKey;
|
|
622506
622513
|
const dir = join160(homedir56(), ".omnius");
|
|
622507
|
-
|
|
622508
|
-
|
|
622514
|
+
mkdirSync89(dir, { recursive: true });
|
|
622515
|
+
writeFileSync80(join160(dir, "api.key"), apiKey + "\n", "utf8");
|
|
622509
622516
|
renderInfo(`Generated API key: ${c3.bold(c3.yellow(apiKey))}`);
|
|
622510
622517
|
renderInfo(
|
|
622511
622518
|
"Use Authorization: Bearer <key> or click 'key' in the Web UI header to paste it."
|
|
@@ -622524,11 +622531,11 @@ var init_commands = __esm({
|
|
|
622524
622531
|
const port = parseInt(process.env["OMNIUS_PORT"] || "11435", 10);
|
|
622525
622532
|
try {
|
|
622526
622533
|
const { homedir: homedir56 } = await import("node:os");
|
|
622527
|
-
const { mkdirSync:
|
|
622534
|
+
const { mkdirSync: mkdirSync89, writeFileSync: writeFileSync80 } = await import("node:fs");
|
|
622528
622535
|
const { join: join160 } = await import("node:path");
|
|
622529
622536
|
const dir = join160(homedir56(), ".omnius");
|
|
622530
|
-
|
|
622531
|
-
|
|
622537
|
+
mkdirSync89(dir, { recursive: true });
|
|
622538
|
+
writeFileSync80(join160(dir, "access"), `${val}
|
|
622532
622539
|
`, "utf8");
|
|
622533
622540
|
} catch {
|
|
622534
622541
|
}
|
|
@@ -622819,22 +622826,47 @@ function loadMemoryContext(repoRoot) {
|
|
|
622819
622826
|
}
|
|
622820
622827
|
const buckets = /* @__PURE__ */ new Map();
|
|
622821
622828
|
for (const e2 of deduped) {
|
|
622822
|
-
const
|
|
622823
|
-
const
|
|
622824
|
-
|
|
622825
|
-
|
|
622829
|
+
const family = topicFamily(e2.topic);
|
|
622830
|
+
const bucketKey = `${e2.scope}/${family}`;
|
|
622831
|
+
const bucket = buckets.get(bucketKey) ?? { family, multiTopic: false, entries: [] };
|
|
622832
|
+
if (bucket.entries.length > 0 && bucket.entries[0].topic !== e2.topic) bucket.multiTopic = true;
|
|
622833
|
+
bucket.entries.push(e2);
|
|
622834
|
+
buckets.set(bucketKey, bucket);
|
|
622826
622835
|
}
|
|
622827
622836
|
const lines = [];
|
|
622828
|
-
for (const [bucketKey,
|
|
622829
|
-
const sorted = entries.sort((a2, b) => b.ts.localeCompare(a2.ts))
|
|
622830
|
-
|
|
622831
|
-
|
|
622837
|
+
for (const [bucketKey, bucket] of buckets) {
|
|
622838
|
+
const sorted = bucket.entries.sort((a2, b) => b.ts.localeCompare(a2.ts));
|
|
622839
|
+
const seenValues = /* @__PURE__ */ new Set();
|
|
622840
|
+
const kept = [];
|
|
622832
622841
|
for (const e2 of sorted) {
|
|
622833
|
-
|
|
622842
|
+
const sig = normalizeValueSignature(e2.value);
|
|
622843
|
+
if (seenValues.has(sig)) continue;
|
|
622844
|
+
seenValues.add(sig);
|
|
622845
|
+
kept.push(e2);
|
|
622846
|
+
if (kept.length >= 5) break;
|
|
622847
|
+
}
|
|
622848
|
+
if (kept.length === 0) continue;
|
|
622849
|
+
const dropped = bucket.entries.length - kept.length;
|
|
622850
|
+
const header = bucket.multiTopic ? `[${bucketKey}* (${bucket.entries.length} entries in series${dropped > 0 ? `, ${dropped} redundant collapsed` : ""})]` : `[${bucketKey}]`;
|
|
622851
|
+
lines.push(header);
|
|
622852
|
+
for (const e2 of kept) {
|
|
622853
|
+
const label = bucket.multiTopic ? `${e2.topic}.${e2.key}` : e2.key;
|
|
622854
|
+
lines.push(` ${label}: ${truncateProjectContextText(trimMemoryValueMetadata(e2.value), 200, "")}`);
|
|
622834
622855
|
}
|
|
622835
622856
|
}
|
|
622836
622857
|
return lines.join("\n");
|
|
622837
622858
|
}
|
|
622859
|
+
function topicFamily(topic) {
|
|
622860
|
+
const m2 = topic.match(/^(.*?)[_-]?\d+$/);
|
|
622861
|
+
if (!m2 || !m2[1]) return topic;
|
|
622862
|
+
return m2[1].length >= 3 ? m2[1] : topic;
|
|
622863
|
+
}
|
|
622864
|
+
function normalizeValueSignature(value2) {
|
|
622865
|
+
return value2.toLowerCase().replace(/\d+(\.\d+)?/g, "#").replace(/\s+/g, " ").trim().slice(0, 160);
|
|
622866
|
+
}
|
|
622867
|
+
function trimMemoryValueMetadata(value2) {
|
|
622868
|
+
return value2.replace(/\b(?:confidence|weight|salience|score|noise_score|relevance)\s*[=:]\s*\d*\.?\d+\b/gi, "").replace(/\b(?:evidence|sources?|refs?)\s*[=:]\s*[\d,\s]+\b/gi, "").replace(/\bvalue_?hash\s*[=:]\s*[0-9a-f]{8,}\b/gi, "").replace(/[ \t]{2,}/g, " ").replace(/\s+([,.;])/g, "$1").trim();
|
|
622869
|
+
}
|
|
622838
622870
|
function loadSessionHistory2(repoRoot) {
|
|
622839
622871
|
const sessions3 = loadRecentSessions(repoRoot, 5);
|
|
622840
622872
|
const lines = ["Recent tasks in this project:"];
|
|
@@ -626234,18 +626266,471 @@ var init_edit_history = __esm({
|
|
|
626234
626266
|
}
|
|
626235
626267
|
});
|
|
626236
626268
|
|
|
626269
|
+
// packages/cli/src/tui/snr-engine.ts
|
|
626270
|
+
import { existsSync as existsSync120, readdirSync as readdirSync42, readFileSync as readFileSync96, writeFileSync as writeFileSync61, mkdirSync as mkdirSync69, rmSync as rmSync7 } from "node:fs";
|
|
626271
|
+
import { join as join133, basename as basename31 } from "node:path";
|
|
626272
|
+
function computeDPrime(signalScores, noiseScores) {
|
|
626273
|
+
if (signalScores.length === 0 || noiseScores.length === 0) return 0;
|
|
626274
|
+
const mean = (arr) => arr.reduce((s2, v) => s2 + v, 0) / arr.length;
|
|
626275
|
+
const variance = (arr, mu) => arr.reduce((s2, v) => s2 + (v - mu) ** 2, 0) / Math.max(1, arr.length - 1);
|
|
626276
|
+
const muSignal = mean(signalScores);
|
|
626277
|
+
const muNoise = mean(noiseScores);
|
|
626278
|
+
const varSignal = variance(signalScores, muSignal);
|
|
626279
|
+
const varNoise = variance(noiseScores, muNoise);
|
|
626280
|
+
const pooledStd = Math.sqrt((varSignal + varNoise) / 2);
|
|
626281
|
+
if (pooledStd === 0) return muSignal > muNoise ? 3 : 0;
|
|
626282
|
+
return (muSignal - muNoise) / pooledStd;
|
|
626283
|
+
}
|
|
626284
|
+
function computeSparsity(entries) {
|
|
626285
|
+
if (entries.length <= 1) return 1;
|
|
626286
|
+
const ngramSets = entries.map((e2) => {
|
|
626287
|
+
const words = e2.toLowerCase().split(/\s+/).filter((w) => w.length > 2);
|
|
626288
|
+
const ngrams = /* @__PURE__ */ new Set();
|
|
626289
|
+
for (let i2 = 0; i2 < words.length - 1; i2++) {
|
|
626290
|
+
ngrams.add(`${words[i2]} ${words[i2 + 1]}`);
|
|
626291
|
+
}
|
|
626292
|
+
return ngrams;
|
|
626293
|
+
});
|
|
626294
|
+
let totalPairs = 0;
|
|
626295
|
+
let totalJaccard = 0;
|
|
626296
|
+
for (let i2 = 0; i2 < ngramSets.length; i2++) {
|
|
626297
|
+
for (let j = i2 + 1; j < ngramSets.length; j++) {
|
|
626298
|
+
const a2 = ngramSets[i2];
|
|
626299
|
+
const b = ngramSets[j];
|
|
626300
|
+
if (a2.size === 0 && b.size === 0) continue;
|
|
626301
|
+
const intersection = new Set([...a2].filter((x) => b.has(x)));
|
|
626302
|
+
const union = /* @__PURE__ */ new Set([...a2, ...b]);
|
|
626303
|
+
totalJaccard += union.size > 0 ? intersection.size / union.size : 0;
|
|
626304
|
+
totalPairs++;
|
|
626305
|
+
}
|
|
626306
|
+
}
|
|
626307
|
+
if (totalPairs === 0) return 1;
|
|
626308
|
+
const avgOverlap = totalJaccard / totalPairs;
|
|
626309
|
+
return Math.max(0, Math.min(1, 1 - avgOverlap));
|
|
626310
|
+
}
|
|
626311
|
+
function adaptTool2(tool) {
|
|
626312
|
+
return {
|
|
626313
|
+
name: tool.name,
|
|
626314
|
+
description: tool.description,
|
|
626315
|
+
parameters: tool.parameters,
|
|
626316
|
+
async execute(args) {
|
|
626317
|
+
const result = await tool.execute(args);
|
|
626318
|
+
return { success: result.success, output: result.output, error: result.error };
|
|
626319
|
+
}
|
|
626320
|
+
};
|
|
626321
|
+
}
|
|
626322
|
+
var SNREngine;
|
|
626323
|
+
var init_snr_engine = __esm({
|
|
626324
|
+
"packages/cli/src/tui/snr-engine.ts"() {
|
|
626325
|
+
"use strict";
|
|
626326
|
+
init_dist8();
|
|
626327
|
+
init_dist5();
|
|
626328
|
+
init_project_context();
|
|
626329
|
+
init_render();
|
|
626330
|
+
SNREngine = class {
|
|
626331
|
+
constructor(config, repoRoot) {
|
|
626332
|
+
this.config = config;
|
|
626333
|
+
this.repoRoot = repoRoot;
|
|
626334
|
+
}
|
|
626335
|
+
config;
|
|
626336
|
+
repoRoot;
|
|
626337
|
+
lastScore = null;
|
|
626338
|
+
evaluationCount = 0;
|
|
626339
|
+
get score() {
|
|
626340
|
+
return this.lastScore;
|
|
626341
|
+
}
|
|
626342
|
+
/**
|
|
626343
|
+
* Quick local-only SNR estimation (no LLM calls, fast).
|
|
626344
|
+
* @param contextSlots — total context window tokens (for Hopfield capacity warning)
|
|
626345
|
+
*/
|
|
626346
|
+
computeLocalSNR(currentTask, contextEntries, contextSlots) {
|
|
626347
|
+
if (contextEntries.length === 0) {
|
|
626348
|
+
return this.makeScore(1, 3, 0, 0, 0, 1, ["local-empty"]);
|
|
626349
|
+
}
|
|
626350
|
+
const taskTerms = new Set(
|
|
626351
|
+
currentTask.toLowerCase().split(/\s+/).filter((w) => w.length > 3).map((w) => w.replace(/[^a-z0-9]/g, ""))
|
|
626352
|
+
);
|
|
626353
|
+
const scores = contextEntries.map((entry) => {
|
|
626354
|
+
const entryTerms = entry.toLowerCase().split(/\s+/).filter((w) => w.length > 3).map((w) => w.replace(/[^a-z0-9]/g, ""));
|
|
626355
|
+
const matchCount = entryTerms.filter((t2) => taskTerms.has(t2)).length;
|
|
626356
|
+
const score2 = entryTerms.length > 0 ? matchCount / Math.sqrt(entryTerms.length) : 0;
|
|
626357
|
+
return { entry, score: score2 };
|
|
626358
|
+
});
|
|
626359
|
+
const allScores = scores.map((s2) => s2.score);
|
|
626360
|
+
const mean = allScores.reduce((a2, b) => a2 + b, 0) / allScores.length;
|
|
626361
|
+
const std = Math.sqrt(allScores.reduce((a2, v) => a2 + (v - mean) ** 2, 0) / allScores.length);
|
|
626362
|
+
const threshold = mean + 0.5 * std;
|
|
626363
|
+
const signalScores = allScores.filter((s2) => s2 >= threshold);
|
|
626364
|
+
const noiseScores = allScores.filter((s2) => s2 < threshold);
|
|
626365
|
+
const dPrime = computeDPrime(
|
|
626366
|
+
signalScores.length > 0 ? signalScores : [mean],
|
|
626367
|
+
noiseScores.length > 0 ? noiseScores : [0]
|
|
626368
|
+
);
|
|
626369
|
+
const sparsity = computeSparsity(contextEntries);
|
|
626370
|
+
const signalProportion = signalScores.length / allScores.length;
|
|
626371
|
+
const dPrimeNorm = Math.min(1, Math.max(0, dPrime / 3));
|
|
626372
|
+
const ratio = 0.5 * signalProportion + 0.3 * dPrimeNorm + 0.2 * sparsity;
|
|
626373
|
+
const capacityWarning = contextSlots ? contextEntries.length > Math.floor(contextSlots * 0.138) : false;
|
|
626374
|
+
const score = this.makeScore(
|
|
626375
|
+
ratio,
|
|
626376
|
+
dPrime,
|
|
626377
|
+
contextEntries.length,
|
|
626378
|
+
signalScores.length,
|
|
626379
|
+
noiseScores.length,
|
|
626380
|
+
sparsity,
|
|
626381
|
+
["local-keyword"],
|
|
626382
|
+
capacityWarning
|
|
626383
|
+
);
|
|
626384
|
+
this.lastScore = score;
|
|
626385
|
+
this.evaluationCount++;
|
|
626386
|
+
return score;
|
|
626387
|
+
}
|
|
626388
|
+
/**
|
|
626389
|
+
* Full SNR evaluation using parallel LLM evaluator agents.
|
|
626390
|
+
* Mirrors PFC gating + multi-agent debate (Du et al. 2023).
|
|
626391
|
+
*
|
|
626392
|
+
* Spawns 2 lightweight agents with different evaluation perspectives:
|
|
626393
|
+
* - "Relevance Evaluator" — scores entries by task relevance (PFC role)
|
|
626394
|
+
* - "Noise Detector" — identifies redundant/stale/irrelevant entries (DG role)
|
|
626395
|
+
*
|
|
626396
|
+
* Their consensus determines the final SNR.
|
|
626397
|
+
*/
|
|
626398
|
+
async evaluateWithAgents(currentTask, memoryTopics, onEvent) {
|
|
626399
|
+
const entries = this.loadMemoryEntries(memoryTopics);
|
|
626400
|
+
if (entries.length === 0) {
|
|
626401
|
+
const score2 = this.makeScore(1, 3, 0, 0, 0, 1, ["agents-empty"]);
|
|
626402
|
+
this.lastScore = score2;
|
|
626403
|
+
return score2;
|
|
626404
|
+
}
|
|
626405
|
+
const entrySummaries = entries.map(
|
|
626406
|
+
(e2, i2) => `[${i2}] topic=${e2.topic} key=${e2.key}: ${e2.value.slice(0, 200)}${e2.value.length > 200 ? "..." : ""}`
|
|
626407
|
+
);
|
|
626408
|
+
const entriesBlock = entrySummaries.join("\n");
|
|
626409
|
+
const [relevanceResult, noiseResult] = await Promise.allSettled([
|
|
626410
|
+
this.runEvaluatorAgent(
|
|
626411
|
+
"relevance",
|
|
626412
|
+
`You are a Prefrontal Cortex Gating Evaluator. Your role is to assess which
|
|
626413
|
+
memory entries are RELEVANT to the current task.
|
|
626414
|
+
|
|
626415
|
+
CURRENT TASK: ${currentTask}
|
|
626416
|
+
|
|
626417
|
+
MEMORY ENTRIES TO EVALUATE:
|
|
626418
|
+
${entriesBlock}
|
|
626419
|
+
|
|
626420
|
+
For each entry, output a JSON array of objects:
|
|
626421
|
+
[{"index": 0, "score": 0.8, "reason": "directly related to task"}, ...]
|
|
626422
|
+
|
|
626423
|
+
Score 0-1 where:
|
|
626424
|
+
- 1.0 = directly relevant to the current task
|
|
626425
|
+
- 0.7 = supporting context (useful background)
|
|
626426
|
+
- 0.4 = marginally relevant
|
|
626427
|
+
- 0.1 = not relevant to current task
|
|
626428
|
+
|
|
626429
|
+
Call task_complete with the JSON array when done.`,
|
|
626430
|
+
onEvent
|
|
626431
|
+
),
|
|
626432
|
+
this.runEvaluatorAgent(
|
|
626433
|
+
"noise",
|
|
626434
|
+
`You are a Dentate Gyrus Pattern Separation Evaluator. Your role is to identify
|
|
626435
|
+
NOISE in the memory context — entries that are redundant, stale, or interfering.
|
|
626436
|
+
|
|
626437
|
+
CURRENT TASK: ${currentTask}
|
|
626438
|
+
|
|
626439
|
+
MEMORY ENTRIES TO EVALUATE:
|
|
626440
|
+
${entriesBlock}
|
|
626441
|
+
|
|
626442
|
+
For each entry, output a JSON array of objects:
|
|
626443
|
+
[{"index": 0, "noise_score": 0.2, "reason": "unique, not redundant"}, ...]
|
|
626444
|
+
|
|
626445
|
+
Noise score 0-1 where:
|
|
626446
|
+
- 1.0 = pure noise (completely redundant, stale, or interfering with task)
|
|
626447
|
+
- 0.7 = mostly noise (outdated or largely redundant with another entry)
|
|
626448
|
+
- 0.4 = moderate noise (some overlap with other entries)
|
|
626449
|
+
- 0.1 = clean signal (unique, fresh, non-interfering)
|
|
626450
|
+
|
|
626451
|
+
Look for: duplicate information, outdated facts, entries that contradict
|
|
626452
|
+
newer entries, entries about completely unrelated topics.
|
|
626453
|
+
|
|
626454
|
+
Call task_complete with the JSON array when done.`,
|
|
626455
|
+
onEvent
|
|
626456
|
+
)
|
|
626457
|
+
]);
|
|
626458
|
+
const relevanceScores = this.parseEvaluatorResult(
|
|
626459
|
+
relevanceResult.status === "fulfilled" ? relevanceResult.value : "",
|
|
626460
|
+
entries.length,
|
|
626461
|
+
0.5
|
|
626462
|
+
// default relevance
|
|
626463
|
+
);
|
|
626464
|
+
const noiseScores = this.parseEvaluatorResult(
|
|
626465
|
+
noiseResult.status === "fulfilled" ? noiseResult.value : "",
|
|
626466
|
+
entries.length,
|
|
626467
|
+
0.5
|
|
626468
|
+
// default noise
|
|
626469
|
+
);
|
|
626470
|
+
const combinedScores = entries.map((_, i2) => {
|
|
626471
|
+
const rel = relevanceScores[i2] ?? 0.5;
|
|
626472
|
+
const noise2 = noiseScores[i2] ?? 0.5;
|
|
626473
|
+
const votes = [rel, 1 - noise2].sort((a2, b) => a2 - b);
|
|
626474
|
+
return (votes[0] + votes[1]) / 2;
|
|
626475
|
+
});
|
|
626476
|
+
const mean = combinedScores.reduce((a2, b) => a2 + b, 0) / combinedScores.length;
|
|
626477
|
+
const std = Math.sqrt(combinedScores.reduce((a2, v) => a2 + (v - mean) ** 2, 0) / combinedScores.length);
|
|
626478
|
+
const threshold = Math.max(0.3, mean);
|
|
626479
|
+
const signalEntries = combinedScores.filter((s2) => s2 >= threshold);
|
|
626480
|
+
const noiseEntries = combinedScores.filter((s2) => s2 < threshold);
|
|
626481
|
+
const dPrime = computeDPrime(
|
|
626482
|
+
signalEntries.length > 0 ? signalEntries : [mean],
|
|
626483
|
+
noiseEntries.length > 0 ? noiseEntries : [0.1]
|
|
626484
|
+
);
|
|
626485
|
+
const sparsity = computeSparsity(entries.map((e2) => e2.value));
|
|
626486
|
+
const signalProportion = signalEntries.length / combinedScores.length;
|
|
626487
|
+
const dPrimeNorm = Math.min(1, Math.max(0, dPrime / 3));
|
|
626488
|
+
const ratio = 0.5 * signalProportion + 0.3 * dPrimeNorm + 0.2 * sparsity;
|
|
626489
|
+
const evaluators = [
|
|
626490
|
+
relevanceResult.status === "fulfilled" ? "relevance-agent" : "relevance-failed",
|
|
626491
|
+
noiseResult.status === "fulfilled" ? "noise-agent" : "noise-failed"
|
|
626492
|
+
];
|
|
626493
|
+
const score = this.makeScore(
|
|
626494
|
+
ratio,
|
|
626495
|
+
dPrime,
|
|
626496
|
+
entries.length,
|
|
626497
|
+
signalEntries.length,
|
|
626498
|
+
noiseEntries.length,
|
|
626499
|
+
sparsity,
|
|
626500
|
+
evaluators
|
|
626501
|
+
);
|
|
626502
|
+
this.lastScore = score;
|
|
626503
|
+
this.evaluationCount++;
|
|
626504
|
+
return score;
|
|
626505
|
+
}
|
|
626506
|
+
// ── Evaluator agent ──────────────────────────────────────────────────
|
|
626507
|
+
async runEvaluatorAgent(name10, prompt, onEvent) {
|
|
626508
|
+
const backend = new OllamaAgenticBackend(
|
|
626509
|
+
this.config.backendUrl,
|
|
626510
|
+
this.config.model,
|
|
626511
|
+
this.config.apiKey
|
|
626512
|
+
);
|
|
626513
|
+
const modelTier = getModelTier(this.config.model);
|
|
626514
|
+
const runner = new AgenticRunner(backend, {
|
|
626515
|
+
maxTurns: 5,
|
|
626516
|
+
// Evaluators are very focused — 5 turns max
|
|
626517
|
+
maxTokens: 4096,
|
|
626518
|
+
temperature: 0,
|
|
626519
|
+
// Deterministic scoring
|
|
626520
|
+
requestTimeoutMs: this.config.timeoutMs,
|
|
626521
|
+
taskTimeoutMs: this.config.timeoutMs,
|
|
626522
|
+
compactionThreshold: modelTier === "small" ? 8e3 : 16e3,
|
|
626523
|
+
modelTier
|
|
626524
|
+
});
|
|
626525
|
+
const tools = [
|
|
626526
|
+
new MemoryReadTool(this.repoRoot),
|
|
626527
|
+
new MemorySearchTool(this.repoRoot)
|
|
626528
|
+
];
|
|
626529
|
+
runner.registerTools([
|
|
626530
|
+
...tools.map(adaptTool2),
|
|
626531
|
+
{
|
|
626532
|
+
name: "task_complete",
|
|
626533
|
+
description: "Signal evaluation is complete with your scored results.",
|
|
626534
|
+
parameters: {
|
|
626535
|
+
type: "object",
|
|
626536
|
+
properties: {
|
|
626537
|
+
summary: { type: "string", description: "JSON array of scored entries" }
|
|
626538
|
+
},
|
|
626539
|
+
required: ["summary"]
|
|
626540
|
+
},
|
|
626541
|
+
async execute(args) {
|
|
626542
|
+
return { success: true, output: args["summary"] || "[]" };
|
|
626543
|
+
}
|
|
626544
|
+
}
|
|
626545
|
+
]);
|
|
626546
|
+
if (onEvent) runner.onEvent(onEvent);
|
|
626547
|
+
const result = await runner.run(
|
|
626548
|
+
prompt,
|
|
626549
|
+
`SNR Evaluator (${name10}). Working directory: ${this.repoRoot}`
|
|
626550
|
+
);
|
|
626551
|
+
return result.summary || "[]";
|
|
626552
|
+
}
|
|
626553
|
+
// ── Memory loading ───────────────────────────────────────────────────
|
|
626554
|
+
loadMemoryEntries(topics) {
|
|
626555
|
+
const entries = [];
|
|
626556
|
+
const dirs = [.../* @__PURE__ */ new Set([
|
|
626557
|
+
join133(this.repoRoot, ".omnius", "memory")
|
|
626558
|
+
])];
|
|
626559
|
+
for (const dir of dirs) {
|
|
626560
|
+
if (!existsSync120(dir)) continue;
|
|
626561
|
+
try {
|
|
626562
|
+
const files = readdirSync42(dir).filter((f2) => f2.endsWith(".json"));
|
|
626563
|
+
for (const f2 of files) {
|
|
626564
|
+
const topic = basename31(f2, ".json");
|
|
626565
|
+
if (topics.length > 0 && !topics.includes(topic)) continue;
|
|
626566
|
+
try {
|
|
626567
|
+
const data = JSON.parse(readFileSync96(join133(dir, f2), "utf-8"));
|
|
626568
|
+
for (const [key, val] of Object.entries(data)) {
|
|
626569
|
+
const value2 = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
626570
|
+
entries.push({ topic, key, value: value2 });
|
|
626571
|
+
}
|
|
626572
|
+
} catch {
|
|
626573
|
+
}
|
|
626574
|
+
}
|
|
626575
|
+
} catch {
|
|
626576
|
+
}
|
|
626577
|
+
}
|
|
626578
|
+
return entries;
|
|
626579
|
+
}
|
|
626580
|
+
// ── Result parsing ───────────────────────────────────────────────────
|
|
626581
|
+
parseEvaluatorResult(summary, entryCount, defaultScore) {
|
|
626582
|
+
const scores = new Array(entryCount).fill(defaultScore);
|
|
626583
|
+
try {
|
|
626584
|
+
const jsonMatch = summary.match(/\[[\s\S]*\]/);
|
|
626585
|
+
if (!jsonMatch) return scores;
|
|
626586
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
626587
|
+
for (const item of parsed) {
|
|
626588
|
+
const idx = typeof item.index === "number" ? item.index : -1;
|
|
626589
|
+
const score = typeof item.score === "number" ? item.score : typeof item.noise_score === "number" ? item.noise_score : defaultScore;
|
|
626590
|
+
if (idx >= 0 && idx < entryCount) {
|
|
626591
|
+
scores[idx] = Math.max(0, Math.min(1, score));
|
|
626592
|
+
}
|
|
626593
|
+
}
|
|
626594
|
+
} catch {
|
|
626595
|
+
}
|
|
626596
|
+
return scores;
|
|
626597
|
+
}
|
|
626598
|
+
// ── Memory pruning recommendations ──────────────────────────────────
|
|
626599
|
+
/**
|
|
626600
|
+
* Identify low-SNR memory entries that should be pruned.
|
|
626601
|
+
* Mirrors synaptic downscaling during slow-wave sleep — weak connections
|
|
626602
|
+
* (low-relevance, high-redundancy entries) are depotentiated.
|
|
626603
|
+
*
|
|
626604
|
+
* Returns topics+keys of entries scoring below the noise threshold.
|
|
626605
|
+
* Does NOT delete anything — the caller decides what to do with the list.
|
|
626606
|
+
*/
|
|
626607
|
+
getPruningCandidates(currentTask, noiseThreshold = 0.3) {
|
|
626608
|
+
const entries = this.loadMemoryEntries([]);
|
|
626609
|
+
if (entries.length === 0) return [];
|
|
626610
|
+
const taskTerms = new Set(
|
|
626611
|
+
currentTask.toLowerCase().split(/\s+/).filter((w) => w.length > 3).map((w) => w.replace(/[^a-z0-9]/g, ""))
|
|
626612
|
+
);
|
|
626613
|
+
const candidates = [];
|
|
626614
|
+
for (const entry of entries) {
|
|
626615
|
+
const entryTerms = entry.value.toLowerCase().split(/\s+/).filter((w) => w.length > 3).map((w) => w.replace(/[^a-z0-9]/g, ""));
|
|
626616
|
+
const matchCount = entryTerms.filter((t2) => taskTerms.has(t2)).length;
|
|
626617
|
+
const relevance = entryTerms.length > 0 ? matchCount / Math.sqrt(entryTerms.length) : 0;
|
|
626618
|
+
if (relevance < noiseThreshold) {
|
|
626619
|
+
candidates.push({
|
|
626620
|
+
topic: entry.topic,
|
|
626621
|
+
key: entry.key,
|
|
626622
|
+
score: relevance,
|
|
626623
|
+
reason: relevance === 0 ? "no keyword overlap with current task" : `low relevance (${(relevance * 100).toFixed(0)}% < ${(noiseThreshold * 100).toFixed(0)}% threshold)`
|
|
626624
|
+
});
|
|
626625
|
+
}
|
|
626626
|
+
}
|
|
626627
|
+
return candidates.sort((a2, b) => a2.score - b.score);
|
|
626628
|
+
}
|
|
626629
|
+
/**
|
|
626630
|
+
* Act on the pruning recommendations: move low-SNR entries OUT of the active
|
|
626631
|
+
* memory topic files and into `.omnius/memory/.archive/<topic>.json`.
|
|
626632
|
+
*
|
|
626633
|
+
* This is the missing half of the Dentate Gyrus loop — `getPruningCandidates`
|
|
626634
|
+
* only ever produced a list that nothing consumed, so flagged-noise entries
|
|
626635
|
+
* kept loading into every context window (agent self-audit 2026-05-28).
|
|
626636
|
+
*
|
|
626637
|
+
* Safety properties:
|
|
626638
|
+
* - Reversible: entries are moved to an archive file, never deleted.
|
|
626639
|
+
* - Bounded: at most `maxArchive` entries removed per call.
|
|
626640
|
+
* - Guarded: refuses to run against a trivial focus string (which would
|
|
626641
|
+
* score every entry as irrelevant and archive the whole store).
|
|
626642
|
+
* - Conservative threshold (0.15) — only entries with near-zero relevance
|
|
626643
|
+
* to the focus are eligible.
|
|
626644
|
+
*
|
|
626645
|
+
* Intended caller: the deliberate slow-wave consolidation cycle, passing the
|
|
626646
|
+
* consolidation summary as `focus` (what the agent just decided matters).
|
|
626647
|
+
*/
|
|
626648
|
+
archiveNoiseEntries(focus, opts = {}) {
|
|
626649
|
+
const noiseThreshold = opts.noiseThreshold ?? 0.15;
|
|
626650
|
+
const maxArchive = opts.maxArchive ?? 25;
|
|
626651
|
+
const focusTerms = focus.toLowerCase().split(/\s+/).filter((w) => w.length > 3);
|
|
626652
|
+
if (focusTerms.length < 3) return { archived: 0, topics: [] };
|
|
626653
|
+
const candidates = this.getPruningCandidates(focus, noiseThreshold).slice(0, maxArchive);
|
|
626654
|
+
if (candidates.length === 0) return { archived: 0, topics: [] };
|
|
626655
|
+
const byTopic = /* @__PURE__ */ new Map();
|
|
626656
|
+
for (const cand of candidates) {
|
|
626657
|
+
const set = byTopic.get(cand.topic) ?? /* @__PURE__ */ new Set();
|
|
626658
|
+
set.add(cand.key);
|
|
626659
|
+
byTopic.set(cand.topic, set);
|
|
626660
|
+
}
|
|
626661
|
+
const memDir = join133(this.repoRoot, ".omnius", "memory");
|
|
626662
|
+
const archiveDir = join133(memDir, ".archive");
|
|
626663
|
+
let archived = 0;
|
|
626664
|
+
const touchedTopics = [];
|
|
626665
|
+
for (const [topic, keys] of byTopic) {
|
|
626666
|
+
const file = join133(memDir, `${topic}.json`);
|
|
626667
|
+
if (!existsSync120(file)) continue;
|
|
626668
|
+
try {
|
|
626669
|
+
const data = JSON.parse(readFileSync96(file, "utf-8"));
|
|
626670
|
+
const moved = {};
|
|
626671
|
+
for (const key of keys) {
|
|
626672
|
+
if (key in data) {
|
|
626673
|
+
moved[key] = data[key];
|
|
626674
|
+
delete data[key];
|
|
626675
|
+
archived++;
|
|
626676
|
+
}
|
|
626677
|
+
}
|
|
626678
|
+
if (Object.keys(moved).length === 0) continue;
|
|
626679
|
+
mkdirSync69(archiveDir, { recursive: true });
|
|
626680
|
+
const archiveFile = join133(archiveDir, `${topic}.json`);
|
|
626681
|
+
let archiveData = {};
|
|
626682
|
+
if (existsSync120(archiveFile)) {
|
|
626683
|
+
try {
|
|
626684
|
+
archiveData = JSON.parse(readFileSync96(archiveFile, "utf-8"));
|
|
626685
|
+
} catch {
|
|
626686
|
+
}
|
|
626687
|
+
}
|
|
626688
|
+
Object.assign(archiveData, moved);
|
|
626689
|
+
writeFileSync61(archiveFile, JSON.stringify(archiveData, null, 2));
|
|
626690
|
+
if (Object.keys(data).length === 0) {
|
|
626691
|
+
try {
|
|
626692
|
+
rmSync7(file);
|
|
626693
|
+
} catch {
|
|
626694
|
+
}
|
|
626695
|
+
} else {
|
|
626696
|
+
writeFileSync61(file, JSON.stringify(data, null, 2));
|
|
626697
|
+
}
|
|
626698
|
+
touchedTopics.push(topic);
|
|
626699
|
+
} catch {
|
|
626700
|
+
}
|
|
626701
|
+
}
|
|
626702
|
+
return { archived, topics: touchedTopics };
|
|
626703
|
+
}
|
|
626704
|
+
// ── Helpers ──────────────────────────────────────────────────────────
|
|
626705
|
+
makeScore(ratio, dPrime, total, signal, noise2, sparsity, evaluators, capacityWarning = false) {
|
|
626706
|
+
return {
|
|
626707
|
+
ratio: Math.max(0, Math.min(1, ratio)),
|
|
626708
|
+
dPrime: Math.max(0, dPrime),
|
|
626709
|
+
entriesEvaluated: total,
|
|
626710
|
+
signalCount: signal,
|
|
626711
|
+
noiseCount: noise2,
|
|
626712
|
+
sparsity: Math.max(0, Math.min(1, sparsity)),
|
|
626713
|
+
evaluatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
626714
|
+
evaluators,
|
|
626715
|
+
capacityWarning
|
|
626716
|
+
};
|
|
626717
|
+
}
|
|
626718
|
+
};
|
|
626719
|
+
}
|
|
626720
|
+
});
|
|
626721
|
+
|
|
626237
626722
|
// packages/cli/src/tui/promptLoader.ts
|
|
626238
|
-
import { readFileSync as
|
|
626239
|
-
import { join as
|
|
626723
|
+
import { readFileSync as readFileSync97, existsSync as existsSync121 } from "node:fs";
|
|
626724
|
+
import { join as join134, dirname as dirname38 } from "node:path";
|
|
626240
626725
|
import { fileURLToPath as fileURLToPath17 } from "node:url";
|
|
626241
626726
|
function loadPrompt3(promptPath, vars) {
|
|
626242
626727
|
let content = cache7.get(promptPath);
|
|
626243
626728
|
if (content === void 0) {
|
|
626244
|
-
const fullPath =
|
|
626245
|
-
if (!
|
|
626729
|
+
const fullPath = join134(PROMPTS_DIR3, promptPath);
|
|
626730
|
+
if (!existsSync121(fullPath)) {
|
|
626246
626731
|
throw new Error(`Prompt file not found: ${fullPath}`);
|
|
626247
626732
|
}
|
|
626248
|
-
content =
|
|
626733
|
+
content = readFileSync97(fullPath, "utf-8");
|
|
626249
626734
|
cache7.set(promptPath, content);
|
|
626250
626735
|
}
|
|
626251
626736
|
if (!vars) return content;
|
|
@@ -626257,16 +626742,16 @@ var init_promptLoader3 = __esm({
|
|
|
626257
626742
|
"use strict";
|
|
626258
626743
|
__filename5 = fileURLToPath17(import.meta.url);
|
|
626259
626744
|
__dirname6 = dirname38(__filename5);
|
|
626260
|
-
devPath2 =
|
|
626261
|
-
publishedPath2 =
|
|
626262
|
-
PROMPTS_DIR3 =
|
|
626745
|
+
devPath2 = join134(__dirname6, "..", "..", "prompts");
|
|
626746
|
+
publishedPath2 = join134(__dirname6, "..", "prompts");
|
|
626747
|
+
PROMPTS_DIR3 = existsSync121(devPath2) ? devPath2 : publishedPath2;
|
|
626263
626748
|
cache7 = /* @__PURE__ */ new Map();
|
|
626264
626749
|
}
|
|
626265
626750
|
});
|
|
626266
626751
|
|
|
626267
626752
|
// packages/cli/src/tui/dream-engine.ts
|
|
626268
|
-
import { mkdirSync as
|
|
626269
|
-
import { join as
|
|
626753
|
+
import { mkdirSync as mkdirSync70, writeFileSync as writeFileSync62, readFileSync as readFileSync98, existsSync as existsSync122, readdirSync as readdirSync43 } from "node:fs";
|
|
626754
|
+
import { join as join135, basename as basename32 } from "node:path";
|
|
626270
626755
|
import { execSync as execSync56 } from "node:child_process";
|
|
626271
626756
|
function setDreamWriteContent(fn) {
|
|
626272
626757
|
_dreamWriteContent = fn;
|
|
@@ -626279,10 +626764,10 @@ function dreamWrite(fn) {
|
|
|
626279
626764
|
}
|
|
626280
626765
|
}
|
|
626281
626766
|
function loadAutoresearchMemory(repoRoot) {
|
|
626282
|
-
const memoryPath =
|
|
626283
|
-
if (!
|
|
626767
|
+
const memoryPath = join135(repoRoot, ".omnius", "memory", "autoresearch.json");
|
|
626768
|
+
if (!existsSync122(memoryPath)) return "";
|
|
626284
626769
|
try {
|
|
626285
|
-
const raw =
|
|
626770
|
+
const raw = readFileSync98(memoryPath, "utf-8");
|
|
626286
626771
|
const data = JSON.parse(raw);
|
|
626287
626772
|
const sections = [];
|
|
626288
626773
|
for (const key of AUTORESEARCH_MEMORY_KEYS) {
|
|
@@ -626301,7 +626786,7 @@ ${sections.join("\n\n")}`;
|
|
|
626301
626786
|
return "";
|
|
626302
626787
|
}
|
|
626303
626788
|
}
|
|
626304
|
-
function
|
|
626789
|
+
function adaptTool3(tool) {
|
|
626305
626790
|
return {
|
|
626306
626791
|
name: tool.name,
|
|
626307
626792
|
description: tool.description,
|
|
@@ -626448,6 +626933,7 @@ var init_dream_engine = __esm({
|
|
|
626448
626933
|
init_dist8();
|
|
626449
626934
|
init_dist5();
|
|
626450
626935
|
init_project_context();
|
|
626936
|
+
init_snr_engine();
|
|
626451
626937
|
init_setup();
|
|
626452
626938
|
init_render();
|
|
626453
626939
|
init_promptLoader3();
|
|
@@ -626479,14 +626965,14 @@ var init_dream_engine = __esm({
|
|
|
626479
626965
|
const rawPath = String(args["path"] ?? "");
|
|
626480
626966
|
const content = String(args["content"] ?? "");
|
|
626481
626967
|
if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
|
|
626482
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ?
|
|
626968
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join135(this.autoresearchDir, basename32(rawPath)) : join135(this.autoresearchDir, rawPath);
|
|
626483
626969
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
626484
626970
|
return { success: false, output: "", error: "Autoresearch mode: writes are confined to .omnius/autoresearch/", durationMs: Date.now() - start2 };
|
|
626485
626971
|
}
|
|
626486
626972
|
try {
|
|
626487
|
-
const dir =
|
|
626488
|
-
|
|
626489
|
-
|
|
626973
|
+
const dir = join135(targetPath, "..");
|
|
626974
|
+
mkdirSync70(dir, { recursive: true });
|
|
626975
|
+
writeFileSync62(targetPath, content, "utf-8");
|
|
626490
626976
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start2 };
|
|
626491
626977
|
} catch (err) {
|
|
626492
626978
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -626514,20 +627000,20 @@ var init_dream_engine = __esm({
|
|
|
626514
627000
|
const rawPath = String(args["path"] ?? "");
|
|
626515
627001
|
const oldStr = String(args["old_string"] ?? "");
|
|
626516
627002
|
const newStr = String(args["new_string"] ?? "");
|
|
626517
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ?
|
|
627003
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/autoresearch") ? join135(this.autoresearchDir, basename32(rawPath)) : join135(this.autoresearchDir, rawPath);
|
|
626518
627004
|
if (!targetPath.startsWith(this.autoresearchDir)) {
|
|
626519
627005
|
return { success: false, output: "", error: "Autoresearch mode: edits are confined to .omnius/autoresearch/", durationMs: Date.now() - start2 };
|
|
626520
627006
|
}
|
|
626521
627007
|
try {
|
|
626522
|
-
if (!
|
|
627008
|
+
if (!existsSync122(targetPath)) {
|
|
626523
627009
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
|
|
626524
627010
|
}
|
|
626525
|
-
let content =
|
|
627011
|
+
let content = readFileSync98(targetPath, "utf-8");
|
|
626526
627012
|
if (!content.includes(oldStr)) {
|
|
626527
627013
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start2 };
|
|
626528
627014
|
}
|
|
626529
627015
|
content = content.replace(oldStr, newStr);
|
|
626530
|
-
|
|
627016
|
+
writeFileSync62(targetPath, content, "utf-8");
|
|
626531
627017
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start2 };
|
|
626532
627018
|
} catch (err) {
|
|
626533
627019
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -626567,14 +627053,14 @@ var init_dream_engine = __esm({
|
|
|
626567
627053
|
const rawPath = String(args["path"] ?? "");
|
|
626568
627054
|
const content = String(args["content"] ?? "");
|
|
626569
627055
|
if (!rawPath) return { success: false, output: "", error: "path is required", durationMs: Date.now() - start2 };
|
|
626570
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ?
|
|
627056
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join135(this.dreamsDir, basename32(rawPath)) : join135(this.dreamsDir, rawPath);
|
|
626571
627057
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
626572
627058
|
return { success: false, output: "", error: "Dream mode: writes are confined to .omnius/dreams/", durationMs: Date.now() - start2 };
|
|
626573
627059
|
}
|
|
626574
627060
|
try {
|
|
626575
|
-
const dir =
|
|
626576
|
-
|
|
626577
|
-
|
|
627061
|
+
const dir = join135(targetPath, "..");
|
|
627062
|
+
mkdirSync70(dir, { recursive: true });
|
|
627063
|
+
writeFileSync62(targetPath, content, "utf-8");
|
|
626578
627064
|
return { success: true, output: `Wrote ${content.length} bytes to ${rawPath}`, durationMs: Date.now() - start2 };
|
|
626579
627065
|
} catch (err) {
|
|
626580
627066
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -626602,20 +627088,20 @@ var init_dream_engine = __esm({
|
|
|
626602
627088
|
const rawPath = String(args["path"] ?? "");
|
|
626603
627089
|
const oldStr = String(args["old_string"] ?? "");
|
|
626604
627090
|
const newStr = String(args["new_string"] ?? "");
|
|
626605
|
-
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ?
|
|
627091
|
+
const targetPath = rawPath.startsWith("/") || rawPath.startsWith(".omnius/dreams") ? join135(this.dreamsDir, basename32(rawPath)) : join135(this.dreamsDir, rawPath);
|
|
626606
627092
|
if (!targetPath.startsWith(this.dreamsDir)) {
|
|
626607
627093
|
return { success: false, output: "", error: "Dream mode: edits are confined to .omnius/dreams/", durationMs: Date.now() - start2 };
|
|
626608
627094
|
}
|
|
626609
627095
|
try {
|
|
626610
|
-
if (!
|
|
627096
|
+
if (!existsSync122(targetPath)) {
|
|
626611
627097
|
return { success: false, output: "", error: `File not found: ${rawPath}`, durationMs: Date.now() - start2 };
|
|
626612
627098
|
}
|
|
626613
|
-
let content =
|
|
627099
|
+
let content = readFileSync98(targetPath, "utf-8");
|
|
626614
627100
|
if (!content.includes(oldStr)) {
|
|
626615
627101
|
return { success: false, output: "", error: "old_string not found in file", durationMs: Date.now() - start2 };
|
|
626616
627102
|
}
|
|
626617
627103
|
content = content.replace(oldStr, newStr);
|
|
626618
|
-
|
|
627104
|
+
writeFileSync62(targetPath, content, "utf-8");
|
|
626619
627105
|
return { success: true, output: `Edited ${rawPath}`, durationMs: Date.now() - start2 };
|
|
626620
627106
|
} catch (err) {
|
|
626621
627107
|
return { success: false, output: "", error: String(err), durationMs: Date.now() - start2 };
|
|
@@ -626664,7 +627150,7 @@ var init_dream_engine = __esm({
|
|
|
626664
627150
|
constructor(config, repoRoot) {
|
|
626665
627151
|
this.config = config;
|
|
626666
627152
|
this.repoRoot = repoRoot;
|
|
626667
|
-
this.dreamsDir =
|
|
627153
|
+
this.dreamsDir = join135(repoRoot, ".omnius", "dreams");
|
|
626668
627154
|
this.state = {
|
|
626669
627155
|
mode: "default",
|
|
626670
627156
|
active: false,
|
|
@@ -626703,7 +627189,7 @@ var init_dream_engine = __esm({
|
|
|
626703
627189
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
626704
627190
|
results: []
|
|
626705
627191
|
};
|
|
626706
|
-
|
|
627192
|
+
mkdirSync70(this.dreamsDir, { recursive: true });
|
|
626707
627193
|
this.saveDreamState();
|
|
626708
627194
|
try {
|
|
626709
627195
|
for (let cycle = 1; cycle <= totalCycles; cycle++) {
|
|
@@ -626775,8 +627261,8 @@ ${result.summary}`;
|
|
|
626775
627261
|
if (mode !== "default" || cycle === totalCycles) {
|
|
626776
627262
|
renderDreamContraction(cycle);
|
|
626777
627263
|
const cycleSummary = this.buildCycleSummary(cycle, previousFindings);
|
|
626778
|
-
const summaryPath =
|
|
626779
|
-
|
|
627264
|
+
const summaryPath = join135(this.dreamsDir, `cycle-${cycle}-summary.md`);
|
|
627265
|
+
writeFileSync62(summaryPath, cycleSummary, "utf-8");
|
|
626780
627266
|
}
|
|
626781
627267
|
if (mode === "lucid" && !this.abortController.signal.aborted) {
|
|
626782
627268
|
this.saveVersionCheckpoint(cycle);
|
|
@@ -627015,7 +627501,7 @@ After synthesis, call task_complete with the final prioritized summary.`,
|
|
|
627015
627501
|
}
|
|
627016
627502
|
/** Build role-specific tool sets for swarm agents */
|
|
627017
627503
|
buildSwarmTools(role, _workspace) {
|
|
627018
|
-
const autoresearchDir =
|
|
627504
|
+
const autoresearchDir = join135(this.repoRoot, ".omnius", "autoresearch");
|
|
627019
627505
|
const taskComplete = this.createSwarmTaskCompleteTool(role);
|
|
627020
627506
|
switch (role) {
|
|
627021
627507
|
case "researcher": {
|
|
@@ -627030,7 +627516,7 @@ After synthesis, call task_complete with the final prioritized summary.`,
|
|
|
627030
627516
|
new MemorySearchTool(this.repoRoot),
|
|
627031
627517
|
new MemoryWriteTool(this.repoRoot)
|
|
627032
627518
|
];
|
|
627033
|
-
return [...tools.map(
|
|
627519
|
+
return [...tools.map(adaptTool3), this.createDreamTodoWriteTool(), this.createDreamWorkingNotesTool(), taskComplete];
|
|
627034
627520
|
}
|
|
627035
627521
|
case "monitor": {
|
|
627036
627522
|
const tools = [
|
|
@@ -627041,7 +627527,7 @@ After synthesis, call task_complete with the final prioritized summary.`,
|
|
|
627041
627527
|
// status-only in prompt
|
|
627042
627528
|
new MemoryReadTool(this.repoRoot)
|
|
627043
627529
|
];
|
|
627044
|
-
return [...tools.map(
|
|
627530
|
+
return [...tools.map(adaptTool3), this.createDreamTodoWriteTool(), taskComplete];
|
|
627045
627531
|
}
|
|
627046
627532
|
case "evaluator": {
|
|
627047
627533
|
const tools = [
|
|
@@ -627053,7 +627539,7 @@ After synthesis, call task_complete with the final prioritized summary.`,
|
|
|
627053
627539
|
new MemoryWriteTool(this.repoRoot),
|
|
627054
627540
|
new GrepSearchTool(this.repoRoot)
|
|
627055
627541
|
];
|
|
627056
|
-
return [...tools.map(
|
|
627542
|
+
return [...tools.map(adaptTool3), this.createDreamTodoWriteTool(), this.createDreamWorkingNotesTool(), taskComplete];
|
|
627057
627543
|
}
|
|
627058
627544
|
case "critic": {
|
|
627059
627545
|
const tools = [
|
|
@@ -627062,7 +627548,7 @@ After synthesis, call task_complete with the final prioritized summary.`,
|
|
|
627062
627548
|
new MemorySearchTool(this.repoRoot),
|
|
627063
627549
|
new GrepSearchTool(this.repoRoot)
|
|
627064
627550
|
];
|
|
627065
|
-
return [...tools.map(
|
|
627551
|
+
return [...tools.map(adaptTool3), this.createDreamTodoWriteTool(), taskComplete];
|
|
627066
627552
|
}
|
|
627067
627553
|
case "flow_maintainer": {
|
|
627068
627554
|
const tools = [
|
|
@@ -627070,7 +627556,7 @@ After synthesis, call task_complete with the final prioritized summary.`,
|
|
|
627070
627556
|
new MemoryWriteTool(this.repoRoot),
|
|
627071
627557
|
new MemorySearchTool(this.repoRoot)
|
|
627072
627558
|
];
|
|
627073
|
-
return [...tools.map(
|
|
627559
|
+
return [...tools.map(adaptTool3), this.createDreamTodoWriteTool(), this.createDreamWorkingNotesTool(), taskComplete];
|
|
627074
627560
|
}
|
|
627075
627561
|
}
|
|
627076
627562
|
}
|
|
@@ -627416,7 +627902,7 @@ Call task_complete with a human-readable summary of the autoresearch session.`,
|
|
|
627416
627902
|
workspace,
|
|
627417
627903
|
onEvent
|
|
627418
627904
|
);
|
|
627419
|
-
const reportPath =
|
|
627905
|
+
const reportPath = join135(this.dreamsDir, `cycle-${cycleNum}-autoresearch-report.md`);
|
|
627420
627906
|
const report2 = `# Autoresearch Swarm Report — Cycle ${cycleNum}
|
|
627421
627907
|
|
|
627422
627908
|
**Date**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
@@ -627438,8 +627924,8 @@ ${summaryResult}
|
|
|
627438
627924
|
*Generated by omnius autoresearch swarm*
|
|
627439
627925
|
`;
|
|
627440
627926
|
try {
|
|
627441
|
-
|
|
627442
|
-
|
|
627927
|
+
mkdirSync70(this.dreamsDir, { recursive: true });
|
|
627928
|
+
writeFileSync62(reportPath, report2, "utf-8");
|
|
627443
627929
|
} catch {
|
|
627444
627930
|
}
|
|
627445
627931
|
renderSwarmComplete(workspace);
|
|
@@ -627451,7 +627937,7 @@ ${summaryResult}
|
|
|
627451
627937
|
new MemoryReadTool(this.repoRoot),
|
|
627452
627938
|
new MemoryWriteTool(this.repoRoot),
|
|
627453
627939
|
new MemorySearchTool(this.repoRoot)
|
|
627454
|
-
].map(
|
|
627940
|
+
].map(adaptTool3);
|
|
627455
627941
|
const todoWriteTool = this.createDreamTodoWriteTool();
|
|
627456
627942
|
const workingNotesTool = this.createDreamWorkingNotesTool();
|
|
627457
627943
|
if (toolMode === "full") {
|
|
@@ -627470,7 +627956,7 @@ ${summaryResult}
|
|
|
627470
627956
|
new WebSearchTool()
|
|
627471
627957
|
];
|
|
627472
627958
|
return [
|
|
627473
|
-
...tools.map(
|
|
627959
|
+
...tools.map(adaptTool3),
|
|
627474
627960
|
...memoryAndPlanTools,
|
|
627475
627961
|
todoWriteTool,
|
|
627476
627962
|
workingNotesTool,
|
|
@@ -627492,8 +627978,8 @@ ${summaryResult}
|
|
|
627492
627978
|
new DreamShellTool(this.repoRoot)
|
|
627493
627979
|
];
|
|
627494
627980
|
return [
|
|
627495
|
-
...readTools.map(
|
|
627496
|
-
...dreamWriteTools.map(
|
|
627981
|
+
...readTools.map(adaptTool3),
|
|
627982
|
+
...dreamWriteTools.map(adaptTool3),
|
|
627497
627983
|
...memoryAndPlanTools,
|
|
627498
627984
|
todoWriteTool,
|
|
627499
627985
|
workingNotesTool,
|
|
@@ -627502,7 +627988,7 @@ ${summaryResult}
|
|
|
627502
627988
|
}
|
|
627503
627989
|
/** Dream-scoped todo_write — persists to .omnius/dreams/todo-state.json */
|
|
627504
627990
|
createDreamTodoWriteTool() {
|
|
627505
|
-
const todoPath3 =
|
|
627991
|
+
const todoPath3 = join135(this.dreamsDir, "todo-state.json");
|
|
627506
627992
|
return {
|
|
627507
627993
|
name: "todo_write",
|
|
627508
627994
|
description: "Update the task checklist for this dream session. Mark items in_progress/completed/pending as you work through stages.",
|
|
@@ -627531,7 +628017,7 @@ ${summaryResult}
|
|
|
627531
628017
|
return { success: false, output: "", error: "todos must be an array" };
|
|
627532
628018
|
}
|
|
627533
628019
|
try {
|
|
627534
|
-
|
|
628020
|
+
writeFileSync62(todoPath3, JSON.stringify({ todos, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), "utf-8");
|
|
627535
628021
|
const summary = todos.map(
|
|
627536
628022
|
(t2, i2) => ` ${t2.status === "completed" ? "✓" : t2.status === "in_progress" ? "▶" : "◯"} ${i2 + 1}: ${t2.content || "(untitled)"}`
|
|
627537
628023
|
).join("\n");
|
|
@@ -627545,7 +628031,7 @@ ${summary}` };
|
|
|
627545
628031
|
}
|
|
627546
628032
|
/** Dream-scoped working_notes — persists to .omnius/dreams/working-notes.json */
|
|
627547
628033
|
createDreamWorkingNotesTool() {
|
|
627548
|
-
const notesPath =
|
|
628034
|
+
const notesPath = join135(this.dreamsDir, "working-notes.json");
|
|
627549
628035
|
return {
|
|
627550
628036
|
name: "working_notes",
|
|
627551
628037
|
description: "Track discoveries, decisions, and findings across dream stages. Notes persist within this dream session.",
|
|
@@ -627569,8 +628055,8 @@ ${summary}` };
|
|
|
627569
628055
|
const action = args["action"] || "list";
|
|
627570
628056
|
try {
|
|
627571
628057
|
let notes = [];
|
|
627572
|
-
if (
|
|
627573
|
-
notes = JSON.parse(
|
|
628058
|
+
if (existsSync122(notesPath)) {
|
|
628059
|
+
notes = JSON.parse(readFileSync98(notesPath, "utf-8"));
|
|
627574
628060
|
}
|
|
627575
628061
|
if (action === "add") {
|
|
627576
628062
|
const note = {
|
|
@@ -627579,11 +628065,11 @@ ${summary}` };
|
|
|
627579
628065
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
627580
628066
|
};
|
|
627581
628067
|
notes.push(note);
|
|
627582
|
-
|
|
628068
|
+
writeFileSync62(notesPath, JSON.stringify(notes, null, 2), "utf-8");
|
|
627583
628069
|
return { success: true, output: `Note added: [${note.category}] ${note.content.slice(0, 80)}` };
|
|
627584
628070
|
}
|
|
627585
628071
|
if (action === "clear") {
|
|
627586
|
-
|
|
628072
|
+
writeFileSync62(notesPath, "[]", "utf-8");
|
|
627587
628073
|
return { success: true, output: "All notes cleared." };
|
|
627588
628074
|
}
|
|
627589
628075
|
if (action === "search") {
|
|
@@ -627619,9 +628105,9 @@ ${summary}` };
|
|
|
627619
628105
|
}
|
|
627620
628106
|
/** Save workspace backup for lucid mode */
|
|
627621
628107
|
saveVersionCheckpoint(cycle) {
|
|
627622
|
-
const checkpointDir3 =
|
|
628108
|
+
const checkpointDir3 = join135(this.dreamsDir, "checkpoints", `cycle-${cycle}`);
|
|
627623
628109
|
try {
|
|
627624
|
-
|
|
628110
|
+
mkdirSync70(checkpointDir3, { recursive: true });
|
|
627625
628111
|
try {
|
|
627626
628112
|
const gitStatus = execSync56("git status --porcelain", {
|
|
627627
628113
|
cwd: this.repoRoot,
|
|
@@ -627638,11 +628124,11 @@ ${summary}` };
|
|
|
627638
628124
|
encoding: "utf-8",
|
|
627639
628125
|
timeout: 5e3
|
|
627640
628126
|
}).trim();
|
|
627641
|
-
|
|
627642
|
-
|
|
627643
|
-
|
|
627644
|
-
|
|
627645
|
-
|
|
628127
|
+
writeFileSync62(join135(checkpointDir3, "git-status.txt"), gitStatus, "utf-8");
|
|
628128
|
+
writeFileSync62(join135(checkpointDir3, "git-diff.patch"), gitDiff, "utf-8");
|
|
628129
|
+
writeFileSync62(join135(checkpointDir3, "git-hash.txt"), gitHash, "utf-8");
|
|
628130
|
+
writeFileSync62(
|
|
628131
|
+
join135(checkpointDir3, "checkpoint.json"),
|
|
627646
628132
|
JSON.stringify({
|
|
627647
628133
|
cycle,
|
|
627648
628134
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -627653,8 +628139,8 @@ ${summary}` };
|
|
|
627653
628139
|
);
|
|
627654
628140
|
renderInfo(`Checkpoint saved: cycle ${cycle} (${gitHash.slice(0, 8)})`);
|
|
627655
628141
|
} catch {
|
|
627656
|
-
|
|
627657
|
-
|
|
628142
|
+
writeFileSync62(
|
|
628143
|
+
join135(checkpointDir3, "checkpoint.json"),
|
|
627658
628144
|
JSON.stringify({ cycle, timestamp: (/* @__PURE__ */ new Date()).toISOString(), mode: this.state.mode }, null, 2),
|
|
627659
628145
|
"utf-8"
|
|
627660
628146
|
);
|
|
@@ -627694,7 +628180,7 @@ Each proposal includes implementation entrypoints and estimated effort.
|
|
|
627694
628180
|
/** Update the master proposal index */
|
|
627695
628181
|
updateProposalIndex() {
|
|
627696
628182
|
try {
|
|
627697
|
-
const files =
|
|
628183
|
+
const files = readdirSync43(this.dreamsDir).filter((f2) => f2.endsWith(".md") && f2 !== "PROPOSAL-INDEX.md" && f2 !== "dream-state.json").sort();
|
|
627698
628184
|
const index = `# Dream Proposals Index
|
|
627699
628185
|
|
|
627700
628186
|
**Last updated**: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
|
|
@@ -627715,7 +628201,7 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
627715
628201
|
---
|
|
627716
628202
|
*Auto-generated by omnius dream engine*
|
|
627717
628203
|
`;
|
|
627718
|
-
|
|
628204
|
+
writeFileSync62(join135(this.dreamsDir, "PROPOSAL-INDEX.md"), index, "utf-8");
|
|
627719
628205
|
} catch {
|
|
627720
628206
|
}
|
|
627721
628207
|
}
|
|
@@ -627736,8 +628222,8 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
627736
628222
|
results: []
|
|
627737
628223
|
};
|
|
627738
628224
|
renderInfo("Memory consolidation starting — Phase 1: Orient → Phase 2: Gather → Phase 3: Consolidate → Phase 4: Prune");
|
|
627739
|
-
const memoryDir =
|
|
627740
|
-
|
|
628225
|
+
const memoryDir = join135(this.repoRoot, ".omnius", "memory");
|
|
628226
|
+
mkdirSync70(memoryDir, { recursive: true });
|
|
627741
628227
|
let prompt;
|
|
627742
628228
|
try {
|
|
627743
628229
|
prompt = loadPrompt3("tui/dream-consolidate.md", {
|
|
@@ -627803,14 +628289,25 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
627803
628289
|
durationMs
|
|
627804
628290
|
});
|
|
627805
628291
|
try {
|
|
627806
|
-
|
|
627807
|
-
|
|
628292
|
+
writeFileSync62(
|
|
628293
|
+
join135(memoryDir, ".last-consolidation"),
|
|
627808
628294
|
JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), summary: result.summary?.slice(0, 500) }) + "\n"
|
|
627809
628295
|
);
|
|
627810
628296
|
} catch {
|
|
627811
628297
|
}
|
|
627812
628298
|
renderInfo(`Consolidation complete: ${result.turns} turns, ${result.toolCalls} tool calls, ${(durationMs / 1e3).toFixed(1)}s`);
|
|
627813
628299
|
if (result.summary) renderInfo(`Summary: ${result.summary.slice(0, 200)}`);
|
|
628300
|
+
if (result.summary && result.summary.trim().length > 40) {
|
|
628301
|
+
try {
|
|
628302
|
+
const snr = new SNREngine(this.config, this.repoRoot);
|
|
628303
|
+
const { archived, topics } = snr.archiveNoiseEntries(result.summary);
|
|
628304
|
+
if (archived > 0) {
|
|
628305
|
+
renderInfo(`Pruned ${archived} low-SNR memory entr${archived === 1 ? "y" : "ies"} to .archive (topics: ${topics.join(", ")})`);
|
|
628306
|
+
}
|
|
628307
|
+
} catch (pruneErr) {
|
|
628308
|
+
renderWarning(`Noise pruning skipped: ${pruneErr instanceof Error ? pruneErr.message : String(pruneErr)}`);
|
|
628309
|
+
}
|
|
628310
|
+
}
|
|
627814
628311
|
} catch (err) {
|
|
627815
628312
|
renderWarning(`Consolidation failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
627816
628313
|
}
|
|
@@ -627821,8 +628318,8 @@ ${files.map((f2) => `- [\`${f2}\`](./${f2})`).join("\n")}
|
|
|
627821
628318
|
/** Save dream state for resume/inspection */
|
|
627822
628319
|
saveDreamState() {
|
|
627823
628320
|
try {
|
|
627824
|
-
|
|
627825
|
-
|
|
628321
|
+
writeFileSync62(
|
|
628322
|
+
join135(this.dreamsDir, "dream-state.json"),
|
|
627826
628323
|
JSON.stringify(this.state, null, 2) + "\n",
|
|
627827
628324
|
"utf-8"
|
|
627828
628325
|
);
|
|
@@ -628202,8 +628699,8 @@ var init_bless_engine = __esm({
|
|
|
628202
628699
|
});
|
|
628203
628700
|
|
|
628204
628701
|
// packages/cli/src/tui/dmn-engine.ts
|
|
628205
|
-
import { existsSync as
|
|
628206
|
-
import { join as
|
|
628702
|
+
import { existsSync as existsSync123, readFileSync as readFileSync99, writeFileSync as writeFileSync63, mkdirSync as mkdirSync71, readdirSync as readdirSync44, unlinkSync as unlinkSync24 } from "node:fs";
|
|
628703
|
+
import { join as join136, basename as basename33 } from "node:path";
|
|
628207
628704
|
function buildDMNGatherPrompt(recentTaskSummaries, dueReminders, attentionItems, memoryTopics, capabilities, competence, reflectionBuffer) {
|
|
628208
628705
|
const competenceReport = competence.length > 0 ? competence.map((c8) => {
|
|
628209
628706
|
const rate = c8.attempts > 0 ? Math.round(c8.successes / c8.attempts * 100) : 0;
|
|
@@ -628227,7 +628724,7 @@ ${competenceReport}
|
|
|
628227
628724
|
Reflect on what went well and what could improve.`;
|
|
628228
628725
|
}
|
|
628229
628726
|
}
|
|
628230
|
-
function
|
|
628727
|
+
function adaptTool4(tool) {
|
|
628231
628728
|
return {
|
|
628232
628729
|
name: tool.name,
|
|
628233
628730
|
description: tool.description,
|
|
@@ -628308,9 +628805,9 @@ var init_dmn_engine = __esm({
|
|
|
628308
628805
|
constructor(config, repoRoot) {
|
|
628309
628806
|
this.config = config;
|
|
628310
628807
|
this.repoRoot = repoRoot;
|
|
628311
|
-
this.stateDir =
|
|
628312
|
-
this.historyDir =
|
|
628313
|
-
|
|
628808
|
+
this.stateDir = join136(repoRoot, ".omnius", "dmn");
|
|
628809
|
+
this.historyDir = join136(repoRoot, ".omnius", "dmn", "cycles");
|
|
628810
|
+
mkdirSync71(this.historyDir, { recursive: true });
|
|
628314
628811
|
this.loadState();
|
|
628315
628812
|
}
|
|
628316
628813
|
config;
|
|
@@ -628525,7 +629022,7 @@ DMN state directory: ${this.stateDir}`
|
|
|
628525
629022
|
new ShellTool(this.repoRoot)
|
|
628526
629023
|
];
|
|
628527
629024
|
return [
|
|
628528
|
-
...tools.map(
|
|
629025
|
+
...tools.map(adaptTool4),
|
|
628529
629026
|
this.createTaskCompleteTool()
|
|
628530
629027
|
];
|
|
628531
629028
|
}
|
|
@@ -628802,7 +629299,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
628802
629299
|
];
|
|
628803
629300
|
tools.push(new MemoryWriteTool(this.repoRoot));
|
|
628804
629301
|
runner.registerTools([
|
|
628805
|
-
...tools.map(
|
|
629302
|
+
...tools.map(adaptTool4),
|
|
628806
629303
|
{
|
|
628807
629304
|
name: "task_complete",
|
|
628808
629305
|
description: `Signal that the ${role} analysis is complete.`,
|
|
@@ -628946,15 +629443,15 @@ OUTPUT: Call task_complete with JSON:
|
|
|
628946
629443
|
async gatherMemoryTopics() {
|
|
628947
629444
|
const topics = [];
|
|
628948
629445
|
const dirs = [
|
|
628949
|
-
|
|
628950
|
-
|
|
629446
|
+
join136(this.repoRoot, ".omnius", "memory"),
|
|
629447
|
+
join136(this.repoRoot, ".omnius", "memory")
|
|
628951
629448
|
];
|
|
628952
629449
|
for (const dir of dirs) {
|
|
628953
|
-
if (!
|
|
629450
|
+
if (!existsSync123(dir)) continue;
|
|
628954
629451
|
try {
|
|
628955
|
-
const files =
|
|
629452
|
+
const files = readdirSync44(dir).filter((f2) => f2.endsWith(".json"));
|
|
628956
629453
|
for (const f2 of files) {
|
|
628957
|
-
const topic =
|
|
629454
|
+
const topic = basename33(f2, ".json");
|
|
628958
629455
|
if (!topics.includes(topic)) topics.push(topic);
|
|
628959
629456
|
}
|
|
628960
629457
|
} catch {
|
|
@@ -628964,18 +629461,18 @@ OUTPUT: Call task_complete with JSON:
|
|
|
628964
629461
|
}
|
|
628965
629462
|
// ── State persistence ─────────────────────────────────────────────────
|
|
628966
629463
|
loadState() {
|
|
628967
|
-
const path12 =
|
|
628968
|
-
if (
|
|
629464
|
+
const path12 = join136(this.stateDir, "state.json");
|
|
629465
|
+
if (existsSync123(path12)) {
|
|
628969
629466
|
try {
|
|
628970
|
-
this.state = JSON.parse(
|
|
629467
|
+
this.state = JSON.parse(readFileSync99(path12, "utf-8"));
|
|
628971
629468
|
} catch {
|
|
628972
629469
|
}
|
|
628973
629470
|
}
|
|
628974
629471
|
}
|
|
628975
629472
|
saveState() {
|
|
628976
629473
|
try {
|
|
628977
|
-
|
|
628978
|
-
|
|
629474
|
+
writeFileSync63(
|
|
629475
|
+
join136(this.stateDir, "state.json"),
|
|
628979
629476
|
JSON.stringify(this.state, null, 2) + "\n",
|
|
628980
629477
|
"utf-8"
|
|
628981
629478
|
);
|
|
@@ -628985,8 +629482,8 @@ OUTPUT: Call task_complete with JSON:
|
|
|
628985
629482
|
saveCycleResult(result) {
|
|
628986
629483
|
try {
|
|
628987
629484
|
const filename = `cycle-${result.cycleNumber}-${Date.now()}.json`;
|
|
628988
|
-
|
|
628989
|
-
|
|
629485
|
+
writeFileSync63(
|
|
629486
|
+
join136(this.historyDir, filename),
|
|
628990
629487
|
JSON.stringify(result, null, 2) + "\n",
|
|
628991
629488
|
"utf-8"
|
|
628992
629489
|
);
|
|
@@ -628995,13 +629492,13 @@ OUTPUT: Call task_complete with JSON:
|
|
|
628995
629492
|
}
|
|
628996
629493
|
}
|
|
628997
629494
|
pruneCycleHistory() {
|
|
628998
|
-
const files =
|
|
629495
|
+
const files = readdirSync44(this.historyDir).filter((f2) => f2.startsWith("cycle-") && f2.endsWith(".json")).sort();
|
|
628999
629496
|
if (files.length <= 2) return;
|
|
629000
629497
|
const keep = /* @__PURE__ */ new Set([files[0], files[files.length - 1]]);
|
|
629001
629498
|
const latestByFingerprint = /* @__PURE__ */ new Map();
|
|
629002
629499
|
for (const file of files) {
|
|
629003
629500
|
try {
|
|
629004
|
-
const parsed = JSON.parse(
|
|
629501
|
+
const parsed = JSON.parse(readFileSync99(join136(this.historyDir, file), "utf-8"));
|
|
629005
629502
|
latestByFingerprint.set(this.fingerprintCycle(parsed), file);
|
|
629006
629503
|
} catch {
|
|
629007
629504
|
keep.add(file);
|
|
@@ -629019,7 +629516,7 @@ OUTPUT: Call task_complete with JSON:
|
|
|
629019
629516
|
for (const file of files) {
|
|
629020
629517
|
if (!keep.has(file)) {
|
|
629021
629518
|
try {
|
|
629022
|
-
unlinkSync24(
|
|
629519
|
+
unlinkSync24(join136(this.historyDir, file));
|
|
629023
629520
|
} catch {
|
|
629024
629521
|
}
|
|
629025
629522
|
}
|
|
@@ -629045,385 +629542,6 @@ ${result.reasoning}`).toLowerCase().replace(/\d+/g, "#").replace(/\s+/g, " ").tr
|
|
|
629045
629542
|
}
|
|
629046
629543
|
});
|
|
629047
629544
|
|
|
629048
|
-
// packages/cli/src/tui/snr-engine.ts
|
|
629049
|
-
import { existsSync as existsSync123, readdirSync as readdirSync44, readFileSync as readFileSync99 } from "node:fs";
|
|
629050
|
-
import { join as join136, basename as basename33 } from "node:path";
|
|
629051
|
-
function computeDPrime(signalScores, noiseScores) {
|
|
629052
|
-
if (signalScores.length === 0 || noiseScores.length === 0) return 0;
|
|
629053
|
-
const mean = (arr) => arr.reduce((s2, v) => s2 + v, 0) / arr.length;
|
|
629054
|
-
const variance = (arr, mu) => arr.reduce((s2, v) => s2 + (v - mu) ** 2, 0) / Math.max(1, arr.length - 1);
|
|
629055
|
-
const muSignal = mean(signalScores);
|
|
629056
|
-
const muNoise = mean(noiseScores);
|
|
629057
|
-
const varSignal = variance(signalScores, muSignal);
|
|
629058
|
-
const varNoise = variance(noiseScores, muNoise);
|
|
629059
|
-
const pooledStd = Math.sqrt((varSignal + varNoise) / 2);
|
|
629060
|
-
if (pooledStd === 0) return muSignal > muNoise ? 3 : 0;
|
|
629061
|
-
return (muSignal - muNoise) / pooledStd;
|
|
629062
|
-
}
|
|
629063
|
-
function computeSparsity(entries) {
|
|
629064
|
-
if (entries.length <= 1) return 1;
|
|
629065
|
-
const ngramSets = entries.map((e2) => {
|
|
629066
|
-
const words = e2.toLowerCase().split(/\s+/).filter((w) => w.length > 2);
|
|
629067
|
-
const ngrams = /* @__PURE__ */ new Set();
|
|
629068
|
-
for (let i2 = 0; i2 < words.length - 1; i2++) {
|
|
629069
|
-
ngrams.add(`${words[i2]} ${words[i2 + 1]}`);
|
|
629070
|
-
}
|
|
629071
|
-
return ngrams;
|
|
629072
|
-
});
|
|
629073
|
-
let totalPairs = 0;
|
|
629074
|
-
let totalJaccard = 0;
|
|
629075
|
-
for (let i2 = 0; i2 < ngramSets.length; i2++) {
|
|
629076
|
-
for (let j = i2 + 1; j < ngramSets.length; j++) {
|
|
629077
|
-
const a2 = ngramSets[i2];
|
|
629078
|
-
const b = ngramSets[j];
|
|
629079
|
-
if (a2.size === 0 && b.size === 0) continue;
|
|
629080
|
-
const intersection = new Set([...a2].filter((x) => b.has(x)));
|
|
629081
|
-
const union = /* @__PURE__ */ new Set([...a2, ...b]);
|
|
629082
|
-
totalJaccard += union.size > 0 ? intersection.size / union.size : 0;
|
|
629083
|
-
totalPairs++;
|
|
629084
|
-
}
|
|
629085
|
-
}
|
|
629086
|
-
if (totalPairs === 0) return 1;
|
|
629087
|
-
const avgOverlap = totalJaccard / totalPairs;
|
|
629088
|
-
return Math.max(0, Math.min(1, 1 - avgOverlap));
|
|
629089
|
-
}
|
|
629090
|
-
function adaptTool4(tool) {
|
|
629091
|
-
return {
|
|
629092
|
-
name: tool.name,
|
|
629093
|
-
description: tool.description,
|
|
629094
|
-
parameters: tool.parameters,
|
|
629095
|
-
async execute(args) {
|
|
629096
|
-
const result = await tool.execute(args);
|
|
629097
|
-
return { success: result.success, output: result.output, error: result.error };
|
|
629098
|
-
}
|
|
629099
|
-
};
|
|
629100
|
-
}
|
|
629101
|
-
var SNREngine;
|
|
629102
|
-
var init_snr_engine = __esm({
|
|
629103
|
-
"packages/cli/src/tui/snr-engine.ts"() {
|
|
629104
|
-
"use strict";
|
|
629105
|
-
init_dist8();
|
|
629106
|
-
init_dist5();
|
|
629107
|
-
init_project_context();
|
|
629108
|
-
init_render();
|
|
629109
|
-
SNREngine = class {
|
|
629110
|
-
constructor(config, repoRoot) {
|
|
629111
|
-
this.config = config;
|
|
629112
|
-
this.repoRoot = repoRoot;
|
|
629113
|
-
}
|
|
629114
|
-
config;
|
|
629115
|
-
repoRoot;
|
|
629116
|
-
lastScore = null;
|
|
629117
|
-
evaluationCount = 0;
|
|
629118
|
-
get score() {
|
|
629119
|
-
return this.lastScore;
|
|
629120
|
-
}
|
|
629121
|
-
/**
|
|
629122
|
-
* Quick local-only SNR estimation (no LLM calls, fast).
|
|
629123
|
-
* @param contextSlots — total context window tokens (for Hopfield capacity warning)
|
|
629124
|
-
*/
|
|
629125
|
-
computeLocalSNR(currentTask, contextEntries, contextSlots) {
|
|
629126
|
-
if (contextEntries.length === 0) {
|
|
629127
|
-
return this.makeScore(1, 3, 0, 0, 0, 1, ["local-empty"]);
|
|
629128
|
-
}
|
|
629129
|
-
const taskTerms = new Set(
|
|
629130
|
-
currentTask.toLowerCase().split(/\s+/).filter((w) => w.length > 3).map((w) => w.replace(/[^a-z0-9]/g, ""))
|
|
629131
|
-
);
|
|
629132
|
-
const scores = contextEntries.map((entry) => {
|
|
629133
|
-
const entryTerms = entry.toLowerCase().split(/\s+/).filter((w) => w.length > 3).map((w) => w.replace(/[^a-z0-9]/g, ""));
|
|
629134
|
-
const matchCount = entryTerms.filter((t2) => taskTerms.has(t2)).length;
|
|
629135
|
-
const score2 = entryTerms.length > 0 ? matchCount / Math.sqrt(entryTerms.length) : 0;
|
|
629136
|
-
return { entry, score: score2 };
|
|
629137
|
-
});
|
|
629138
|
-
const allScores = scores.map((s2) => s2.score);
|
|
629139
|
-
const mean = allScores.reduce((a2, b) => a2 + b, 0) / allScores.length;
|
|
629140
|
-
const std = Math.sqrt(allScores.reduce((a2, v) => a2 + (v - mean) ** 2, 0) / allScores.length);
|
|
629141
|
-
const threshold = mean + 0.5 * std;
|
|
629142
|
-
const signalScores = allScores.filter((s2) => s2 >= threshold);
|
|
629143
|
-
const noiseScores = allScores.filter((s2) => s2 < threshold);
|
|
629144
|
-
const dPrime = computeDPrime(
|
|
629145
|
-
signalScores.length > 0 ? signalScores : [mean],
|
|
629146
|
-
noiseScores.length > 0 ? noiseScores : [0]
|
|
629147
|
-
);
|
|
629148
|
-
const sparsity = computeSparsity(contextEntries);
|
|
629149
|
-
const signalProportion = signalScores.length / allScores.length;
|
|
629150
|
-
const dPrimeNorm = Math.min(1, Math.max(0, dPrime / 3));
|
|
629151
|
-
const ratio = 0.5 * signalProportion + 0.3 * dPrimeNorm + 0.2 * sparsity;
|
|
629152
|
-
const capacityWarning = contextSlots ? contextEntries.length > Math.floor(contextSlots * 0.138) : false;
|
|
629153
|
-
const score = this.makeScore(
|
|
629154
|
-
ratio,
|
|
629155
|
-
dPrime,
|
|
629156
|
-
contextEntries.length,
|
|
629157
|
-
signalScores.length,
|
|
629158
|
-
noiseScores.length,
|
|
629159
|
-
sparsity,
|
|
629160
|
-
["local-keyword"],
|
|
629161
|
-
capacityWarning
|
|
629162
|
-
);
|
|
629163
|
-
this.lastScore = score;
|
|
629164
|
-
this.evaluationCount++;
|
|
629165
|
-
return score;
|
|
629166
|
-
}
|
|
629167
|
-
/**
|
|
629168
|
-
* Full SNR evaluation using parallel LLM evaluator agents.
|
|
629169
|
-
* Mirrors PFC gating + multi-agent debate (Du et al. 2023).
|
|
629170
|
-
*
|
|
629171
|
-
* Spawns 2 lightweight agents with different evaluation perspectives:
|
|
629172
|
-
* - "Relevance Evaluator" — scores entries by task relevance (PFC role)
|
|
629173
|
-
* - "Noise Detector" — identifies redundant/stale/irrelevant entries (DG role)
|
|
629174
|
-
*
|
|
629175
|
-
* Their consensus determines the final SNR.
|
|
629176
|
-
*/
|
|
629177
|
-
async evaluateWithAgents(currentTask, memoryTopics, onEvent) {
|
|
629178
|
-
const entries = this.loadMemoryEntries(memoryTopics);
|
|
629179
|
-
if (entries.length === 0) {
|
|
629180
|
-
const score2 = this.makeScore(1, 3, 0, 0, 0, 1, ["agents-empty"]);
|
|
629181
|
-
this.lastScore = score2;
|
|
629182
|
-
return score2;
|
|
629183
|
-
}
|
|
629184
|
-
const entrySummaries = entries.map(
|
|
629185
|
-
(e2, i2) => `[${i2}] topic=${e2.topic} key=${e2.key}: ${e2.value.slice(0, 200)}${e2.value.length > 200 ? "..." : ""}`
|
|
629186
|
-
);
|
|
629187
|
-
const entriesBlock = entrySummaries.join("\n");
|
|
629188
|
-
const [relevanceResult, noiseResult] = await Promise.allSettled([
|
|
629189
|
-
this.runEvaluatorAgent(
|
|
629190
|
-
"relevance",
|
|
629191
|
-
`You are a Prefrontal Cortex Gating Evaluator. Your role is to assess which
|
|
629192
|
-
memory entries are RELEVANT to the current task.
|
|
629193
|
-
|
|
629194
|
-
CURRENT TASK: ${currentTask}
|
|
629195
|
-
|
|
629196
|
-
MEMORY ENTRIES TO EVALUATE:
|
|
629197
|
-
${entriesBlock}
|
|
629198
|
-
|
|
629199
|
-
For each entry, output a JSON array of objects:
|
|
629200
|
-
[{"index": 0, "score": 0.8, "reason": "directly related to task"}, ...]
|
|
629201
|
-
|
|
629202
|
-
Score 0-1 where:
|
|
629203
|
-
- 1.0 = directly relevant to the current task
|
|
629204
|
-
- 0.7 = supporting context (useful background)
|
|
629205
|
-
- 0.4 = marginally relevant
|
|
629206
|
-
- 0.1 = not relevant to current task
|
|
629207
|
-
|
|
629208
|
-
Call task_complete with the JSON array when done.`,
|
|
629209
|
-
onEvent
|
|
629210
|
-
),
|
|
629211
|
-
this.runEvaluatorAgent(
|
|
629212
|
-
"noise",
|
|
629213
|
-
`You are a Dentate Gyrus Pattern Separation Evaluator. Your role is to identify
|
|
629214
|
-
NOISE in the memory context — entries that are redundant, stale, or interfering.
|
|
629215
|
-
|
|
629216
|
-
CURRENT TASK: ${currentTask}
|
|
629217
|
-
|
|
629218
|
-
MEMORY ENTRIES TO EVALUATE:
|
|
629219
|
-
${entriesBlock}
|
|
629220
|
-
|
|
629221
|
-
For each entry, output a JSON array of objects:
|
|
629222
|
-
[{"index": 0, "noise_score": 0.2, "reason": "unique, not redundant"}, ...]
|
|
629223
|
-
|
|
629224
|
-
Noise score 0-1 where:
|
|
629225
|
-
- 1.0 = pure noise (completely redundant, stale, or interfering with task)
|
|
629226
|
-
- 0.7 = mostly noise (outdated or largely redundant with another entry)
|
|
629227
|
-
- 0.4 = moderate noise (some overlap with other entries)
|
|
629228
|
-
- 0.1 = clean signal (unique, fresh, non-interfering)
|
|
629229
|
-
|
|
629230
|
-
Look for: duplicate information, outdated facts, entries that contradict
|
|
629231
|
-
newer entries, entries about completely unrelated topics.
|
|
629232
|
-
|
|
629233
|
-
Call task_complete with the JSON array when done.`,
|
|
629234
|
-
onEvent
|
|
629235
|
-
)
|
|
629236
|
-
]);
|
|
629237
|
-
const relevanceScores = this.parseEvaluatorResult(
|
|
629238
|
-
relevanceResult.status === "fulfilled" ? relevanceResult.value : "",
|
|
629239
|
-
entries.length,
|
|
629240
|
-
0.5
|
|
629241
|
-
// default relevance
|
|
629242
|
-
);
|
|
629243
|
-
const noiseScores = this.parseEvaluatorResult(
|
|
629244
|
-
noiseResult.status === "fulfilled" ? noiseResult.value : "",
|
|
629245
|
-
entries.length,
|
|
629246
|
-
0.5
|
|
629247
|
-
// default noise
|
|
629248
|
-
);
|
|
629249
|
-
const combinedScores = entries.map((_, i2) => {
|
|
629250
|
-
const rel = relevanceScores[i2] ?? 0.5;
|
|
629251
|
-
const noise2 = noiseScores[i2] ?? 0.5;
|
|
629252
|
-
const votes = [rel, 1 - noise2].sort((a2, b) => a2 - b);
|
|
629253
|
-
return (votes[0] + votes[1]) / 2;
|
|
629254
|
-
});
|
|
629255
|
-
const mean = combinedScores.reduce((a2, b) => a2 + b, 0) / combinedScores.length;
|
|
629256
|
-
const std = Math.sqrt(combinedScores.reduce((a2, v) => a2 + (v - mean) ** 2, 0) / combinedScores.length);
|
|
629257
|
-
const threshold = Math.max(0.3, mean);
|
|
629258
|
-
const signalEntries = combinedScores.filter((s2) => s2 >= threshold);
|
|
629259
|
-
const noiseEntries = combinedScores.filter((s2) => s2 < threshold);
|
|
629260
|
-
const dPrime = computeDPrime(
|
|
629261
|
-
signalEntries.length > 0 ? signalEntries : [mean],
|
|
629262
|
-
noiseEntries.length > 0 ? noiseEntries : [0.1]
|
|
629263
|
-
);
|
|
629264
|
-
const sparsity = computeSparsity(entries.map((e2) => e2.value));
|
|
629265
|
-
const signalProportion = signalEntries.length / combinedScores.length;
|
|
629266
|
-
const dPrimeNorm = Math.min(1, Math.max(0, dPrime / 3));
|
|
629267
|
-
const ratio = 0.5 * signalProportion + 0.3 * dPrimeNorm + 0.2 * sparsity;
|
|
629268
|
-
const evaluators = [
|
|
629269
|
-
relevanceResult.status === "fulfilled" ? "relevance-agent" : "relevance-failed",
|
|
629270
|
-
noiseResult.status === "fulfilled" ? "noise-agent" : "noise-failed"
|
|
629271
|
-
];
|
|
629272
|
-
const score = this.makeScore(
|
|
629273
|
-
ratio,
|
|
629274
|
-
dPrime,
|
|
629275
|
-
entries.length,
|
|
629276
|
-
signalEntries.length,
|
|
629277
|
-
noiseEntries.length,
|
|
629278
|
-
sparsity,
|
|
629279
|
-
evaluators
|
|
629280
|
-
);
|
|
629281
|
-
this.lastScore = score;
|
|
629282
|
-
this.evaluationCount++;
|
|
629283
|
-
return score;
|
|
629284
|
-
}
|
|
629285
|
-
// ── Evaluator agent ──────────────────────────────────────────────────
|
|
629286
|
-
async runEvaluatorAgent(name10, prompt, onEvent) {
|
|
629287
|
-
const backend = new OllamaAgenticBackend(
|
|
629288
|
-
this.config.backendUrl,
|
|
629289
|
-
this.config.model,
|
|
629290
|
-
this.config.apiKey
|
|
629291
|
-
);
|
|
629292
|
-
const modelTier = getModelTier(this.config.model);
|
|
629293
|
-
const runner = new AgenticRunner(backend, {
|
|
629294
|
-
maxTurns: 5,
|
|
629295
|
-
// Evaluators are very focused — 5 turns max
|
|
629296
|
-
maxTokens: 4096,
|
|
629297
|
-
temperature: 0,
|
|
629298
|
-
// Deterministic scoring
|
|
629299
|
-
requestTimeoutMs: this.config.timeoutMs,
|
|
629300
|
-
taskTimeoutMs: this.config.timeoutMs,
|
|
629301
|
-
compactionThreshold: modelTier === "small" ? 8e3 : 16e3,
|
|
629302
|
-
modelTier
|
|
629303
|
-
});
|
|
629304
|
-
const tools = [
|
|
629305
|
-
new MemoryReadTool(this.repoRoot),
|
|
629306
|
-
new MemorySearchTool(this.repoRoot)
|
|
629307
|
-
];
|
|
629308
|
-
runner.registerTools([
|
|
629309
|
-
...tools.map(adaptTool4),
|
|
629310
|
-
{
|
|
629311
|
-
name: "task_complete",
|
|
629312
|
-
description: "Signal evaluation is complete with your scored results.",
|
|
629313
|
-
parameters: {
|
|
629314
|
-
type: "object",
|
|
629315
|
-
properties: {
|
|
629316
|
-
summary: { type: "string", description: "JSON array of scored entries" }
|
|
629317
|
-
},
|
|
629318
|
-
required: ["summary"]
|
|
629319
|
-
},
|
|
629320
|
-
async execute(args) {
|
|
629321
|
-
return { success: true, output: args["summary"] || "[]" };
|
|
629322
|
-
}
|
|
629323
|
-
}
|
|
629324
|
-
]);
|
|
629325
|
-
if (onEvent) runner.onEvent(onEvent);
|
|
629326
|
-
const result = await runner.run(
|
|
629327
|
-
prompt,
|
|
629328
|
-
`SNR Evaluator (${name10}). Working directory: ${this.repoRoot}`
|
|
629329
|
-
);
|
|
629330
|
-
return result.summary || "[]";
|
|
629331
|
-
}
|
|
629332
|
-
// ── Memory loading ───────────────────────────────────────────────────
|
|
629333
|
-
loadMemoryEntries(topics) {
|
|
629334
|
-
const entries = [];
|
|
629335
|
-
const dirs = [
|
|
629336
|
-
join136(this.repoRoot, ".omnius", "memory"),
|
|
629337
|
-
join136(this.repoRoot, ".omnius", "memory")
|
|
629338
|
-
];
|
|
629339
|
-
for (const dir of dirs) {
|
|
629340
|
-
if (!existsSync123(dir)) continue;
|
|
629341
|
-
try {
|
|
629342
|
-
const files = readdirSync44(dir).filter((f2) => f2.endsWith(".json"));
|
|
629343
|
-
for (const f2 of files) {
|
|
629344
|
-
const topic = basename33(f2, ".json");
|
|
629345
|
-
if (topics.length > 0 && !topics.includes(topic)) continue;
|
|
629346
|
-
try {
|
|
629347
|
-
const data = JSON.parse(readFileSync99(join136(dir, f2), "utf-8"));
|
|
629348
|
-
for (const [key, val] of Object.entries(data)) {
|
|
629349
|
-
const value2 = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
629350
|
-
entries.push({ topic, key, value: value2 });
|
|
629351
|
-
}
|
|
629352
|
-
} catch {
|
|
629353
|
-
}
|
|
629354
|
-
}
|
|
629355
|
-
} catch {
|
|
629356
|
-
}
|
|
629357
|
-
}
|
|
629358
|
-
return entries;
|
|
629359
|
-
}
|
|
629360
|
-
// ── Result parsing ───────────────────────────────────────────────────
|
|
629361
|
-
parseEvaluatorResult(summary, entryCount, defaultScore) {
|
|
629362
|
-
const scores = new Array(entryCount).fill(defaultScore);
|
|
629363
|
-
try {
|
|
629364
|
-
const jsonMatch = summary.match(/\[[\s\S]*\]/);
|
|
629365
|
-
if (!jsonMatch) return scores;
|
|
629366
|
-
const parsed = JSON.parse(jsonMatch[0]);
|
|
629367
|
-
for (const item of parsed) {
|
|
629368
|
-
const idx = typeof item.index === "number" ? item.index : -1;
|
|
629369
|
-
const score = typeof item.score === "number" ? item.score : typeof item.noise_score === "number" ? item.noise_score : defaultScore;
|
|
629370
|
-
if (idx >= 0 && idx < entryCount) {
|
|
629371
|
-
scores[idx] = Math.max(0, Math.min(1, score));
|
|
629372
|
-
}
|
|
629373
|
-
}
|
|
629374
|
-
} catch {
|
|
629375
|
-
}
|
|
629376
|
-
return scores;
|
|
629377
|
-
}
|
|
629378
|
-
// ── Memory pruning recommendations ──────────────────────────────────
|
|
629379
|
-
/**
|
|
629380
|
-
* Identify low-SNR memory entries that should be pruned.
|
|
629381
|
-
* Mirrors synaptic downscaling during slow-wave sleep — weak connections
|
|
629382
|
-
* (low-relevance, high-redundancy entries) are depotentiated.
|
|
629383
|
-
*
|
|
629384
|
-
* Returns topics+keys of entries scoring below the noise threshold.
|
|
629385
|
-
* Does NOT delete anything — the caller decides what to do with the list.
|
|
629386
|
-
*/
|
|
629387
|
-
getPruningCandidates(currentTask, noiseThreshold = 0.3) {
|
|
629388
|
-
const entries = this.loadMemoryEntries([]);
|
|
629389
|
-
if (entries.length === 0) return [];
|
|
629390
|
-
const taskTerms = new Set(
|
|
629391
|
-
currentTask.toLowerCase().split(/\s+/).filter((w) => w.length > 3).map((w) => w.replace(/[^a-z0-9]/g, ""))
|
|
629392
|
-
);
|
|
629393
|
-
const candidates = [];
|
|
629394
|
-
for (const entry of entries) {
|
|
629395
|
-
const entryTerms = entry.value.toLowerCase().split(/\s+/).filter((w) => w.length > 3).map((w) => w.replace(/[^a-z0-9]/g, ""));
|
|
629396
|
-
const matchCount = entryTerms.filter((t2) => taskTerms.has(t2)).length;
|
|
629397
|
-
const relevance = entryTerms.length > 0 ? matchCount / Math.sqrt(entryTerms.length) : 0;
|
|
629398
|
-
if (relevance < noiseThreshold) {
|
|
629399
|
-
candidates.push({
|
|
629400
|
-
topic: entry.topic,
|
|
629401
|
-
key: entry.key,
|
|
629402
|
-
score: relevance,
|
|
629403
|
-
reason: relevance === 0 ? "no keyword overlap with current task" : `low relevance (${(relevance * 100).toFixed(0)}% < ${(noiseThreshold * 100).toFixed(0)}% threshold)`
|
|
629404
|
-
});
|
|
629405
|
-
}
|
|
629406
|
-
}
|
|
629407
|
-
return candidates.sort((a2, b) => a2.score - b.score);
|
|
629408
|
-
}
|
|
629409
|
-
// ── Helpers ──────────────────────────────────────────────────────────
|
|
629410
|
-
makeScore(ratio, dPrime, total, signal, noise2, sparsity, evaluators, capacityWarning = false) {
|
|
629411
|
-
return {
|
|
629412
|
-
ratio: Math.max(0, Math.min(1, ratio)),
|
|
629413
|
-
dPrime: Math.max(0, dPrime),
|
|
629414
|
-
entriesEvaluated: total,
|
|
629415
|
-
signalCount: signal,
|
|
629416
|
-
noiseCount: noise2,
|
|
629417
|
-
sparsity: Math.max(0, Math.min(1, sparsity)),
|
|
629418
|
-
evaluatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
629419
|
-
evaluators,
|
|
629420
|
-
capacityWarning
|
|
629421
|
-
};
|
|
629422
|
-
}
|
|
629423
|
-
};
|
|
629424
|
-
}
|
|
629425
|
-
});
|
|
629426
|
-
|
|
629427
629545
|
// packages/cli/src/tui/emotion-engine.ts
|
|
629428
629546
|
function labelFromCoordinates(valence, arousal) {
|
|
629429
629547
|
if (valence > 0.6 && arousal > 0.6) return { label: "exhilarated", emoji: "🤩" };
|
|
@@ -631022,11 +631140,11 @@ var init_telegram_command_menu = __esm({
|
|
|
631022
631140
|
import { createCipheriv as createCipheriv5, createDecipheriv as createDecipheriv5, randomBytes as randomBytes24 } from "node:crypto";
|
|
631023
631141
|
import {
|
|
631024
631142
|
existsSync as existsSync124,
|
|
631025
|
-
mkdirSync as
|
|
631143
|
+
mkdirSync as mkdirSync72,
|
|
631026
631144
|
readFileSync as readFileSync100,
|
|
631027
631145
|
statSync as statSync45,
|
|
631028
631146
|
unlinkSync as unlinkSync25,
|
|
631029
|
-
writeFileSync as
|
|
631147
|
+
writeFileSync as writeFileSync64
|
|
631030
631148
|
} from "node:fs";
|
|
631031
631149
|
import { mkdir as mkdir20 } from "node:fs/promises";
|
|
631032
631150
|
import {
|
|
@@ -631043,7 +631161,7 @@ function telegramCreativeWorkspaceRoot(repoRoot, chatId) {
|
|
|
631043
631161
|
const raw = chatId === void 0 ? "unknown" : String(chatId);
|
|
631044
631162
|
const key = raw.replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 96) || "unknown";
|
|
631045
631163
|
const root = join137(repoRoot, ".omnius", "telegram-creative", key);
|
|
631046
|
-
|
|
631164
|
+
mkdirSync72(root, { recursive: true });
|
|
631047
631165
|
return root;
|
|
631048
631166
|
}
|
|
631049
631167
|
function formatTelegramCreativeWorkspacePrompt(root) {
|
|
@@ -631216,8 +631334,8 @@ function scopedTool(base3, root, mode) {
|
|
|
631216
631334
|
if (mode === "edit" && !existsSync124(guarded.path.abs)) {
|
|
631217
631335
|
const materialized = materializeTelegramCreativeArtifactForSend(rootAbs, guarded.path.rel);
|
|
631218
631336
|
if (!materialized.ok) return denied(materialized.error);
|
|
631219
|
-
|
|
631220
|
-
|
|
631337
|
+
mkdirSync72(dirname39(guarded.path.abs), { recursive: true });
|
|
631338
|
+
writeFileSync64(guarded.path.abs, readFileSync100(materialized.path));
|
|
631221
631339
|
materialized.cleanup?.();
|
|
631222
631340
|
restoredEditPath = guarded.path.abs;
|
|
631223
631341
|
}
|
|
@@ -631309,10 +631427,10 @@ function manifestPath(root) {
|
|
|
631309
631427
|
return join137(root, MANIFEST_FILE);
|
|
631310
631428
|
}
|
|
631311
631429
|
function ensureManifest(root) {
|
|
631312
|
-
|
|
631430
|
+
mkdirSync72(root, { recursive: true });
|
|
631313
631431
|
const path12 = manifestPath(root);
|
|
631314
631432
|
if (!existsSync124(path12)) {
|
|
631315
|
-
|
|
631433
|
+
writeFileSync64(path12, JSON.stringify({ files: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n", "utf8");
|
|
631316
631434
|
}
|
|
631317
631435
|
}
|
|
631318
631436
|
function readManifest(root) {
|
|
@@ -631338,7 +631456,7 @@ function readManifest(root) {
|
|
|
631338
631456
|
}
|
|
631339
631457
|
function writeManifest(root, manifest) {
|
|
631340
631458
|
ensureManifest(root);
|
|
631341
|
-
|
|
631459
|
+
writeFileSync64(manifestPath(root), JSON.stringify(manifest, null, 2) + "\n", "utf8");
|
|
631342
631460
|
}
|
|
631343
631461
|
function manifestHas(root, relPath) {
|
|
631344
631462
|
const rel = relPath.replace(/\\/g, "/");
|
|
@@ -631362,7 +631480,7 @@ function rememberCreated(root, absPath) {
|
|
|
631362
631480
|
}
|
|
631363
631481
|
}
|
|
631364
631482
|
}
|
|
631365
|
-
|
|
631483
|
+
mkdirSync72(join137(root, OBJECTS_DIR), { recursive: true });
|
|
631366
631484
|
const data = readFileSync100(guarded.path.abs);
|
|
631367
631485
|
const prefix = randomBytes24(48);
|
|
631368
631486
|
const key = randomBytes24(32);
|
|
@@ -631372,7 +631490,7 @@ function rememberCreated(root, absPath) {
|
|
|
631372
631490
|
const tag = cipher.getAuthTag();
|
|
631373
631491
|
const storedRel = join137(OBJECTS_DIR, `${Date.now()}-${randomBytes24(12).toString("hex")}.blob`).replace(/\\/g, "/");
|
|
631374
631492
|
const storedAbs = join137(root, storedRel);
|
|
631375
|
-
|
|
631493
|
+
writeFileSync64(storedAbs, Buffer.concat([prefix, encrypted]));
|
|
631376
631494
|
try {
|
|
631377
631495
|
unlinkSync25(guarded.path.abs);
|
|
631378
631496
|
} catch {
|
|
@@ -631431,9 +631549,9 @@ function materializeTelegramCreativeArtifactForSend(root, rawPath) {
|
|
|
631431
631549
|
payload = Buffer.concat([decipher.update(payload), decipher.final()]);
|
|
631432
631550
|
}
|
|
631433
631551
|
const stageDir = join137(rootAbs, SEND_DIR, `${Date.now()}-${randomBytes24(8).toString("hex")}`);
|
|
631434
|
-
|
|
631552
|
+
mkdirSync72(stageDir, { recursive: true });
|
|
631435
631553
|
const staged = join137(stageDir, object.originalName || basename34(rel));
|
|
631436
|
-
|
|
631554
|
+
writeFileSync64(staged, payload);
|
|
631437
631555
|
return {
|
|
631438
631556
|
ok: true,
|
|
631439
631557
|
path: staged,
|
|
@@ -632114,7 +632232,7 @@ var init_soul_observations = __esm({
|
|
|
632114
632232
|
});
|
|
632115
632233
|
|
|
632116
632234
|
// packages/cli/src/tui/telegram-channel-dmn.ts
|
|
632117
|
-
import { existsSync as existsSync125, mkdirSync as
|
|
632235
|
+
import { existsSync as existsSync125, mkdirSync as mkdirSync73, readdirSync as readdirSync45, readFileSync as readFileSync101, writeFileSync as writeFileSync65 } from "node:fs";
|
|
632118
632236
|
import { join as join138 } from "node:path";
|
|
632119
632237
|
import { createHash as createHash30 } from "node:crypto";
|
|
632120
632238
|
function safeFilePart(value2) {
|
|
@@ -632674,12 +632792,12 @@ ${artifact.personaContext}
|
|
|
632674
632792
|
}
|
|
632675
632793
|
function writeTelegramChannelDaydream(repoRoot, artifact) {
|
|
632676
632794
|
const dir = sessionDir(repoRoot, artifact.sessionKey);
|
|
632677
|
-
|
|
632795
|
+
mkdirSync73(dir, { recursive: true });
|
|
632678
632796
|
const base3 = `${artifact.generatedAt.replace(/[:.]/g, "-")}-${artifact.id}`;
|
|
632679
632797
|
const jsonPath = join138(dir, `${base3}.json`);
|
|
632680
632798
|
const markdownPath = join138(dir, `${base3}.md`);
|
|
632681
|
-
|
|
632682
|
-
|
|
632799
|
+
writeFileSync65(jsonPath, JSON.stringify(artifact, null, 2) + "\n", "utf8");
|
|
632800
|
+
writeFileSync65(markdownPath, formatTelegramChannelDaydreamMarkdown(artifact), "utf8");
|
|
632683
632801
|
return { dir, jsonPath, markdownPath };
|
|
632684
632802
|
}
|
|
632685
632803
|
function latestTelegramChannelDaydream(repoRoot, sessionKey) {
|
|
@@ -634433,7 +634551,7 @@ var init_vision_ingress = __esm({
|
|
|
634433
634551
|
});
|
|
634434
634552
|
|
|
634435
634553
|
// packages/cli/src/tui/telegram-bridge.ts
|
|
634436
|
-
import { mkdirSync as
|
|
634554
|
+
import { mkdirSync as mkdirSync74, existsSync as existsSync127, unlinkSync as unlinkSync27, readdirSync as readdirSync46, statSync as statSync46, statfsSync as statfsSync5, readFileSync as readFileSync103, writeFileSync as writeFileSync67, appendFileSync as appendFileSync10 } from "node:fs";
|
|
634437
634555
|
import { join as join140, resolve as resolve53, basename as basename35, relative as relative14, isAbsolute as isAbsolute9, extname as extname19 } from "node:path";
|
|
634438
634556
|
import { homedir as homedir44 } from "node:os";
|
|
634439
634557
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
@@ -638824,7 +638942,7 @@ Model: <code>${escapeTelegramHTML(model.id)}</code>`
|
|
|
638824
638942
|
appendTelegramConversationLedger(sessionKey, entry) {
|
|
638825
638943
|
if (!this.repoRoot) return;
|
|
638826
638944
|
try {
|
|
638827
|
-
|
|
638945
|
+
mkdirSync74(this.telegramConversationDir, { recursive: true });
|
|
638828
638946
|
appendFileSync10(
|
|
638829
638947
|
this.telegramConversationLedgerPath(sessionKey),
|
|
638830
638948
|
JSON.stringify({ sessionKey, ...entry }) + "\n",
|
|
@@ -639073,7 +639191,7 @@ ${mediaContext}` : ""
|
|
|
639073
639191
|
return null;
|
|
639074
639192
|
}
|
|
639075
639193
|
try {
|
|
639076
|
-
|
|
639194
|
+
mkdirSync74(resolve53(this.repoRoot, ".omnius"), { recursive: true });
|
|
639077
639195
|
const db = initDb(this.telegramSqlitePath);
|
|
639078
639196
|
db.exec(`
|
|
639079
639197
|
CREATE TABLE IF NOT EXISTS telegram_messages (
|
|
@@ -639840,7 +639958,7 @@ ${mediaContext}` : ""
|
|
|
639840
639958
|
saveTelegramConversationState(sessionKey) {
|
|
639841
639959
|
if (!this.repoRoot) return;
|
|
639842
639960
|
try {
|
|
639843
|
-
|
|
639961
|
+
mkdirSync74(this.telegramConversationDir, { recursive: true });
|
|
639844
639962
|
const participants = [...this.chatParticipants.get(sessionKey)?.values() ?? []].map((profile) => ({
|
|
639845
639963
|
...profile,
|
|
639846
639964
|
toneTags: [...profile.toneTags]
|
|
@@ -639857,7 +639975,7 @@ ${mediaContext}` : ""
|
|
|
639857
639975
|
stimulation: this.stimulation.getState(sessionKey),
|
|
639858
639976
|
reflection: this.channelReflectionState.get(sessionKey) ?? { autoFollowup: false }
|
|
639859
639977
|
};
|
|
639860
|
-
|
|
639978
|
+
writeFileSync67(this.telegramConversationPath(sessionKey), JSON.stringify(payload, null, 2) + "\n", "utf8");
|
|
639861
639979
|
} catch {
|
|
639862
639980
|
}
|
|
639863
639981
|
}
|
|
@@ -643482,7 +643600,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`);
|
|
|
643482
643600
|
this.startTelegramSubAgentWatchdog();
|
|
643483
643601
|
await this.prepareTelegramLongPolling();
|
|
643484
643602
|
try {
|
|
643485
|
-
|
|
643603
|
+
mkdirSync74(this.mediaCacheDir, { recursive: true });
|
|
643486
643604
|
} catch {
|
|
643487
643605
|
}
|
|
643488
643606
|
try {
|
|
@@ -643599,7 +643717,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`);
|
|
|
643599
643717
|
this.refreshActiveTelegramInteractionCount();
|
|
643600
643718
|
}
|
|
643601
643719
|
claimTelegramOwnerLock(lockDir, botUserId, botUsername) {
|
|
643602
|
-
|
|
643720
|
+
mkdirSync74(lockDir, { recursive: true });
|
|
643603
643721
|
const lockFile = join140(lockDir, `bot-${botUserId}.owner.lock`);
|
|
643604
643722
|
if (existsSync127(lockFile)) {
|
|
643605
643723
|
try {
|
|
@@ -643614,7 +643732,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`);
|
|
|
643614
643732
|
if (e2 instanceof Error && e2.message.startsWith("Telegram bot @")) throw e2;
|
|
643615
643733
|
}
|
|
643616
643734
|
}
|
|
643617
|
-
|
|
643735
|
+
writeFileSync67(
|
|
643618
643736
|
lockFile,
|
|
643619
643737
|
JSON.stringify({
|
|
643620
643738
|
pid: process.pid,
|
|
@@ -647090,8 +647208,8 @@ Scoped workspace: ${scopedRoot}`,
|
|
|
647090
647208
|
return join140(this.telegramToolButtonDir, `${safe}.json`);
|
|
647091
647209
|
}
|
|
647092
647210
|
writeTelegramToolButtonState(state) {
|
|
647093
|
-
|
|
647094
|
-
|
|
647211
|
+
mkdirSync74(this.telegramToolButtonDir, { recursive: true });
|
|
647212
|
+
writeFileSync67(this.telegramToolButtonPath(state.nonce), JSON.stringify(state, null, 2) + "\n", "utf-8");
|
|
647095
647213
|
}
|
|
647096
647214
|
readTelegramToolButtonState(nonce) {
|
|
647097
647215
|
try {
|
|
@@ -649214,9 +649332,9 @@ import {
|
|
|
649214
649332
|
existsSync as existsSync128,
|
|
649215
649333
|
readFileSync as readFileSync104,
|
|
649216
649334
|
readdirSync as readdirSync47,
|
|
649217
|
-
writeFileSync as
|
|
649335
|
+
writeFileSync as writeFileSync68,
|
|
649218
649336
|
renameSync as renameSync8,
|
|
649219
|
-
mkdirSync as
|
|
649337
|
+
mkdirSync as mkdirSync75,
|
|
649220
649338
|
unlinkSync as unlinkSync28,
|
|
649221
649339
|
appendFileSync as appendFileSync11
|
|
649222
649340
|
} from "node:fs";
|
|
@@ -649235,20 +649353,20 @@ function inFlightPath(id) {
|
|
|
649235
649353
|
}
|
|
649236
649354
|
function persistSession(s2) {
|
|
649237
649355
|
try {
|
|
649238
|
-
|
|
649356
|
+
mkdirSync75(sessionsDir(), { recursive: true });
|
|
649239
649357
|
const final2 = sessionPath(s2.id);
|
|
649240
649358
|
const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
|
|
649241
|
-
|
|
649359
|
+
writeFileSync68(tmp, JSON.stringify(s2, null, 2), "utf-8");
|
|
649242
649360
|
renameSync8(tmp, final2);
|
|
649243
649361
|
} catch {
|
|
649244
649362
|
}
|
|
649245
649363
|
}
|
|
649246
649364
|
function persistInFlight(j) {
|
|
649247
649365
|
try {
|
|
649248
|
-
|
|
649366
|
+
mkdirSync75(sessionsDir(), { recursive: true });
|
|
649249
649367
|
const final2 = inFlightPath(j.sessionId);
|
|
649250
649368
|
const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
|
|
649251
|
-
|
|
649369
|
+
writeFileSync68(tmp, JSON.stringify(j, null, 2), "utf-8");
|
|
649252
649370
|
renameSync8(tmp, final2);
|
|
649253
649371
|
} catch {
|
|
649254
649372
|
}
|
|
@@ -649280,7 +649398,7 @@ function loadPersistedSessions() {
|
|
|
649280
649398
|
parsed.error = "Daemon restart while subprocess was running";
|
|
649281
649399
|
parsed.completedAt = Date.now();
|
|
649282
649400
|
try {
|
|
649283
|
-
|
|
649401
|
+
writeFileSync68(fp, JSON.stringify(parsed, null, 2), "utf-8");
|
|
649284
649402
|
} catch {
|
|
649285
649403
|
}
|
|
649286
649404
|
report2.staleInFlight++;
|
|
@@ -649463,7 +649581,7 @@ function checkinPath(sessionId) {
|
|
|
649463
649581
|
}
|
|
649464
649582
|
function appendCheckin(sessionId, steering) {
|
|
649465
649583
|
try {
|
|
649466
|
-
|
|
649584
|
+
mkdirSync75(sessionsDir(), { recursive: true });
|
|
649467
649585
|
const fp = checkinPath(sessionId);
|
|
649468
649586
|
const entry = JSON.stringify({ ts: Date.now(), steering }) + "\n";
|
|
649469
649587
|
appendFileSync11(fp, entry, "utf-8");
|
|
@@ -649861,7 +649979,7 @@ __export(projects_exports, {
|
|
|
649861
649979
|
setCurrentProject: () => setCurrentProject,
|
|
649862
649980
|
unregisterProject: () => unregisterProject
|
|
649863
649981
|
});
|
|
649864
|
-
import { readFileSync as readFileSync105, writeFileSync as
|
|
649982
|
+
import { readFileSync as readFileSync105, writeFileSync as writeFileSync69, mkdirSync as mkdirSync76, existsSync as existsSync129, statSync as statSync47, renameSync as renameSync9 } from "node:fs";
|
|
649865
649983
|
import { homedir as homedir46 } from "node:os";
|
|
649866
649984
|
import { basename as basename36, join as join142, resolve as resolve54 } from "node:path";
|
|
649867
649985
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
@@ -649877,9 +649995,9 @@ function readAll2() {
|
|
|
649877
649995
|
}
|
|
649878
649996
|
}
|
|
649879
649997
|
function writeAll(file) {
|
|
649880
|
-
|
|
649998
|
+
mkdirSync76(OMNIUS_DIR3, { recursive: true });
|
|
649881
649999
|
const tmp = `${PROJECTS_FILE}.${randomUUID15().slice(0, 8)}.tmp`;
|
|
649882
|
-
|
|
650000
|
+
writeFileSync69(tmp, JSON.stringify(file, null, 2), "utf8");
|
|
649883
650001
|
renameSync9(tmp, PROJECTS_FILE);
|
|
649884
650002
|
}
|
|
649885
650003
|
function listProjects() {
|
|
@@ -649961,8 +650079,8 @@ function setCurrentProject(root) {
|
|
|
649961
650079
|
if (!entry) return null;
|
|
649962
650080
|
currentRoot = canonical;
|
|
649963
650081
|
try {
|
|
649964
|
-
|
|
649965
|
-
|
|
650082
|
+
mkdirSync76(OMNIUS_DIR3, { recursive: true });
|
|
650083
|
+
writeFileSync69(CURRENT_FILE, `${canonical}
|
|
649966
650084
|
`, "utf8");
|
|
649967
650085
|
} catch {
|
|
649968
650086
|
}
|
|
@@ -650855,7 +650973,7 @@ var init_access_policy = __esm({
|
|
|
650855
650973
|
|
|
650856
650974
|
// packages/cli/src/api/project-preferences.ts
|
|
650857
650975
|
import { createHash as createHash34 } from "node:crypto";
|
|
650858
|
-
import { existsSync as existsSync130, mkdirSync as
|
|
650976
|
+
import { existsSync as existsSync130, mkdirSync as mkdirSync77, readFileSync as readFileSync106, renameSync as renameSync10, writeFileSync as writeFileSync70, unlinkSync as unlinkSync29 } from "node:fs";
|
|
650859
650977
|
import { homedir as homedir47 } from "node:os";
|
|
650860
650978
|
import { join as join143, resolve as resolve55 } from "node:path";
|
|
650861
650979
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
@@ -650874,11 +650992,11 @@ function rootSentinelPath(root) {
|
|
|
650874
650992
|
}
|
|
650875
650993
|
function ensureDir(root) {
|
|
650876
650994
|
const dir = projectDir(root);
|
|
650877
|
-
|
|
650995
|
+
mkdirSync77(dir, { recursive: true });
|
|
650878
650996
|
const sentinel = rootSentinelPath(root);
|
|
650879
650997
|
try {
|
|
650880
650998
|
if (!existsSync130(sentinel)) {
|
|
650881
|
-
|
|
650999
|
+
writeFileSync70(sentinel, `${resolve55(root)}
|
|
650882
651000
|
`, "utf8");
|
|
650883
651001
|
}
|
|
650884
651002
|
} catch {
|
|
@@ -650907,12 +651025,12 @@ function writeProjectPreferences(root, partial) {
|
|
|
650907
651025
|
};
|
|
650908
651026
|
const file = prefsPath(root);
|
|
650909
651027
|
const tmp = `${file}.${randomUUID16().slice(0, 8)}.tmp`;
|
|
650910
|
-
|
|
651028
|
+
writeFileSync70(tmp, JSON.stringify(merged, null, 2), "utf8");
|
|
650911
651029
|
try {
|
|
650912
651030
|
renameSync10(tmp, file);
|
|
650913
651031
|
} catch (err) {
|
|
650914
651032
|
try {
|
|
650915
|
-
|
|
651033
|
+
writeFileSync70(file, JSON.stringify(merged, null, 2), "utf8");
|
|
650916
651034
|
} catch {
|
|
650917
651035
|
}
|
|
650918
651036
|
try {
|
|
@@ -651839,13 +651957,13 @@ __export(audit_log_exports, {
|
|
|
651839
651957
|
recordAudit: () => recordAudit,
|
|
651840
651958
|
sanitizeBody: () => sanitizeBody
|
|
651841
651959
|
});
|
|
651842
|
-
import { mkdirSync as
|
|
651960
|
+
import { mkdirSync as mkdirSync78, appendFileSync as appendFileSync12, readFileSync as readFileSync107, existsSync as existsSync131 } from "node:fs";
|
|
651843
651961
|
import { join as join144 } from "node:path";
|
|
651844
651962
|
function initAuditLog(omniusDir) {
|
|
651845
651963
|
auditDir = join144(omniusDir, "audit");
|
|
651846
651964
|
auditFile = join144(auditDir, "audit.jsonl");
|
|
651847
651965
|
try {
|
|
651848
|
-
|
|
651966
|
+
mkdirSync78(auditDir, { recursive: true });
|
|
651849
651967
|
initialized = true;
|
|
651850
651968
|
} catch {
|
|
651851
651969
|
}
|
|
@@ -651913,7 +652031,7 @@ var init_audit_log = __esm({
|
|
|
651913
652031
|
|
|
651914
652032
|
// packages/cli/src/api/disk-task-output.ts
|
|
651915
652033
|
import { open } from "node:fs/promises";
|
|
651916
|
-
import { existsSync as existsSync132, mkdirSync as
|
|
652034
|
+
import { existsSync as existsSync132, mkdirSync as mkdirSync79, statSync as statSync48 } from "node:fs";
|
|
651917
652035
|
import { dirname as dirname41 } from "node:path";
|
|
651918
652036
|
import * as fsConstants from "node:constants";
|
|
651919
652037
|
var O_NOFOLLOW2, O_APPEND2, O_CREAT2, O_WRONLY2, OPEN_FLAGS_WRITE, OPEN_MODE, DiskTaskOutput;
|
|
@@ -651933,7 +652051,7 @@ var init_disk_task_output = __esm({
|
|
|
651933
652051
|
fileSize = 0;
|
|
651934
652052
|
constructor(outputPath3) {
|
|
651935
652053
|
this.path = outputPath3;
|
|
651936
|
-
|
|
652054
|
+
mkdirSync79(dirname41(outputPath3), { recursive: true });
|
|
651937
652055
|
}
|
|
651938
652056
|
/** Queue content for async append. Non-blocking. */
|
|
651939
652057
|
append(chunk) {
|
|
@@ -653103,13 +653221,13 @@ __export(runtime_keys_exports, {
|
|
|
653103
653221
|
mintKey: () => mintKey,
|
|
653104
653222
|
revokeByPrefix: () => revokeByPrefix
|
|
653105
653223
|
});
|
|
653106
|
-
import { existsSync as existsSync134, readFileSync as readFileSync109, writeFileSync as
|
|
653224
|
+
import { existsSync as existsSync134, readFileSync as readFileSync109, writeFileSync as writeFileSync71, mkdirSync as mkdirSync80, chmodSync as chmodSync3 } from "node:fs";
|
|
653107
653225
|
import { join as join146 } from "node:path";
|
|
653108
653226
|
import { homedir as homedir49 } from "node:os";
|
|
653109
653227
|
import { randomBytes as randomBytes26 } from "node:crypto";
|
|
653110
653228
|
function ensureDir2() {
|
|
653111
653229
|
const dir = join146(homedir49(), ".omnius");
|
|
653112
|
-
if (!existsSync134(dir))
|
|
653230
|
+
if (!existsSync134(dir)) mkdirSync80(dir, { recursive: true });
|
|
653113
653231
|
}
|
|
653114
653232
|
function loadAll() {
|
|
653115
653233
|
if (!existsSync134(KEYS_FILE)) return [];
|
|
@@ -653124,7 +653242,7 @@ function loadAll() {
|
|
|
653124
653242
|
}
|
|
653125
653243
|
function persistAll(records) {
|
|
653126
653244
|
ensureDir2();
|
|
653127
|
-
|
|
653245
|
+
writeFileSync71(KEYS_FILE, JSON.stringify(records, null, 2), "utf-8");
|
|
653128
653246
|
try {
|
|
653129
653247
|
chmodSync3(KEYS_FILE, 384);
|
|
653130
653248
|
} catch {
|
|
@@ -653358,7 +653476,7 @@ __export(graphical_sudo_exports, {
|
|
|
653358
653476
|
runGraphicalSudo: () => runGraphicalSudo
|
|
653359
653477
|
});
|
|
653360
653478
|
import { spawn as spawn29 } from "node:child_process";
|
|
653361
|
-
import { existsSync as existsSync136, mkdirSync as
|
|
653479
|
+
import { existsSync as existsSync136, mkdirSync as mkdirSync81, writeFileSync as writeFileSync72, chmodSync as chmodSync4 } from "node:fs";
|
|
653362
653480
|
import { join as join148 } from "node:path";
|
|
653363
653481
|
import { tmpdir as tmpdir21 } from "node:os";
|
|
653364
653482
|
function detectSudoHelper() {
|
|
@@ -653382,7 +653500,7 @@ function which2(cmd) {
|
|
|
653382
653500
|
}
|
|
653383
653501
|
function ensureAskpassShim(helper, description) {
|
|
653384
653502
|
const shimDir = join148(tmpdir21(), "omnius-askpass");
|
|
653385
|
-
|
|
653503
|
+
mkdirSync81(shimDir, { recursive: true });
|
|
653386
653504
|
const shim = join148(shimDir, `${helper}.sh`);
|
|
653387
653505
|
let body;
|
|
653388
653506
|
if (helper === "zenity") {
|
|
@@ -653394,7 +653512,7 @@ exec zenity --password --title="Omnius needs sudo" --text="${description.replace
|
|
|
653394
653512
|
exec kdialog --password "${description.replace(/"/g, '\\"')}" 2>/dev/null
|
|
653395
653513
|
`;
|
|
653396
653514
|
}
|
|
653397
|
-
|
|
653515
|
+
writeFileSync72(shim, body, "utf-8");
|
|
653398
653516
|
chmodSync4(shim, 493);
|
|
653399
653517
|
return shim;
|
|
653400
653518
|
}
|
|
@@ -656090,8 +656208,8 @@ function readAimsFile(name10, fallback) {
|
|
|
656090
656208
|
}
|
|
656091
656209
|
function writeAimsFile(name10, data) {
|
|
656092
656210
|
const dir = aimsDir();
|
|
656093
|
-
const { mkdirSync:
|
|
656094
|
-
|
|
656211
|
+
const { mkdirSync: mkdirSync89, writeFileSync: wf, renameSync: rn } = __require("node:fs");
|
|
656212
|
+
mkdirSync89(dir, { recursive: true });
|
|
656095
656213
|
const finalPath = join149(dir, name10);
|
|
656096
656214
|
const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}`;
|
|
656097
656215
|
try {
|
|
@@ -665931,11 +666049,11 @@ var init_auth_oidc = __esm({
|
|
|
665931
666049
|
});
|
|
665932
666050
|
|
|
665933
666051
|
// packages/cli/src/api/usage-tracker.ts
|
|
665934
|
-
import { mkdirSync as
|
|
666052
|
+
import { mkdirSync as mkdirSync82, readFileSync as readFileSync112, writeFileSync as writeFileSync73, existsSync as existsSync138 } from "node:fs";
|
|
665935
666053
|
import { join as join150 } from "node:path";
|
|
665936
666054
|
function initUsageTracker(omniusDir) {
|
|
665937
666055
|
const dir = join150(omniusDir, "usage");
|
|
665938
|
-
|
|
666056
|
+
mkdirSync82(dir, { recursive: true });
|
|
665939
666057
|
usageFile = join150(dir, "token-usage.json");
|
|
665940
666058
|
try {
|
|
665941
666059
|
if (existsSync138(usageFile)) {
|
|
@@ -665975,7 +666093,7 @@ function flush2() {
|
|
|
665975
666093
|
if (!initialized2 || !dirty) return;
|
|
665976
666094
|
try {
|
|
665977
666095
|
store.lastSaved = (/* @__PURE__ */ new Date()).toISOString();
|
|
665978
|
-
|
|
666096
|
+
writeFileSync73(usageFile, JSON.stringify(store, null, 2), "utf-8");
|
|
665979
666097
|
dirty = false;
|
|
665980
666098
|
} catch {
|
|
665981
666099
|
}
|
|
@@ -666004,7 +666122,7 @@ var init_usage_tracker = __esm({
|
|
|
666004
666122
|
|
|
666005
666123
|
// packages/cli/src/docker.ts
|
|
666006
666124
|
import { execSync as execSync58, spawn as spawn30 } from "node:child_process";
|
|
666007
|
-
import { existsSync as existsSync139, mkdirSync as
|
|
666125
|
+
import { existsSync as existsSync139, mkdirSync as mkdirSync83, writeFileSync as writeFileSync74 } from "node:fs";
|
|
666008
666126
|
import { join as join151, resolve as resolve56, dirname as dirname42 } from "node:path";
|
|
666009
666127
|
import { homedir as homedir52 } from "node:os";
|
|
666010
666128
|
import { fileURLToPath as fileURLToPath18 } from "node:url";
|
|
@@ -666155,7 +666273,7 @@ async function ensureOmniusImage(force = false) {
|
|
|
666155
666273
|
buildContext = dockerDir;
|
|
666156
666274
|
} else {
|
|
666157
666275
|
buildContext = join151(homedir52(), ".omnius", "docker-build");
|
|
666158
|
-
|
|
666276
|
+
mkdirSync83(buildContext, { recursive: true });
|
|
666159
666277
|
writeDockerfiles(buildContext);
|
|
666160
666278
|
}
|
|
666161
666279
|
try {
|
|
@@ -666229,8 +666347,8 @@ chown -R node:node /workspace /home/node/.omnius 2>/dev/null || true
|
|
|
666229
666347
|
if [ "$1" = "omnius" ]; then shift; exec su - node -c "cd /workspace && omnius $*"; fi
|
|
666230
666348
|
exec "$@"
|
|
666231
666349
|
`;
|
|
666232
|
-
|
|
666233
|
-
|
|
666350
|
+
writeFileSync74(join151(dir, "Dockerfile"), dockerfile);
|
|
666351
|
+
writeFileSync74(join151(dir, "docker-entrypoint.sh"), entrypoint, { mode: 493 });
|
|
666234
666352
|
}
|
|
666235
666353
|
function hasNvidiaGpu() {
|
|
666236
666354
|
try {
|
|
@@ -666488,7 +666606,7 @@ import { fileURLToPath as fileURLToPath19 } from "node:url";
|
|
|
666488
666606
|
import { dirname as dirname43, join as join153, resolve as resolve57 } from "node:path";
|
|
666489
666607
|
import { homedir as homedir53 } from "node:os";
|
|
666490
666608
|
import { spawn as spawn31, execSync as execSync59 } from "node:child_process";
|
|
666491
|
-
import { mkdirSync as
|
|
666609
|
+
import { mkdirSync as mkdirSync84, writeFileSync as writeFileSync75, readFileSync as readFileSync113, readdirSync as readdirSync50, existsSync as existsSync140, watch as fsWatch4, renameSync as renameSync11, unlinkSync as unlinkSync30, statSync as statSync51, openSync as openSync4, readSync as readSync2, closeSync as closeSync4 } from "node:fs";
|
|
666492
666610
|
import { randomBytes as randomBytes27, randomUUID as randomUUID17 } from "node:crypto";
|
|
666493
666611
|
import { createHash as createHash36 } from "node:crypto";
|
|
666494
666612
|
function memoryDbPaths3(baseDir = process.cwd()) {
|
|
@@ -667468,7 +667586,7 @@ function ollamaStream(ollamaUrl, path12, method, body, onData, onEnd, onError, t
|
|
|
667468
667586
|
function jobsDir() {
|
|
667469
667587
|
const root = resolve57(process.cwd());
|
|
667470
667588
|
const dir = join153(root, ".omnius", "jobs");
|
|
667471
|
-
|
|
667589
|
+
mkdirSync84(dir, { recursive: true });
|
|
667472
667590
|
return dir;
|
|
667473
667591
|
}
|
|
667474
667592
|
function loadJob(id) {
|
|
@@ -667813,11 +667931,11 @@ function atomicJobWrite(dir, id, job) {
|
|
|
667813
667931
|
const finalPath = join153(dir, `${id}.json`);
|
|
667814
667932
|
const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}`;
|
|
667815
667933
|
try {
|
|
667816
|
-
|
|
667934
|
+
writeFileSync75(tmpPath, JSON.stringify(job, null, 2), "utf-8");
|
|
667817
667935
|
renameSync11(tmpPath, finalPath);
|
|
667818
667936
|
} catch {
|
|
667819
667937
|
try {
|
|
667820
|
-
|
|
667938
|
+
writeFileSync75(finalPath, JSON.stringify(job, null, 2), "utf-8");
|
|
667821
667939
|
} catch {
|
|
667822
667940
|
}
|
|
667823
667941
|
try {
|
|
@@ -669353,10 +669471,10 @@ function readUpdateState() {
|
|
|
669353
669471
|
function writeUpdateState(state) {
|
|
669354
669472
|
try {
|
|
669355
669473
|
const dir = join153(homedir53(), ".omnius");
|
|
669356
|
-
|
|
669474
|
+
mkdirSync84(dir, { recursive: true });
|
|
669357
669475
|
const finalPath = updateStateFile();
|
|
669358
669476
|
const tmpPath = `${finalPath}.tmp.${process.pid}`;
|
|
669359
|
-
|
|
669477
|
+
writeFileSync75(tmpPath, JSON.stringify(state, null, 2), "utf-8");
|
|
669360
669478
|
renameSync11(tmpPath, finalPath);
|
|
669361
669479
|
} catch {
|
|
669362
669480
|
}
|
|
@@ -669665,7 +669783,7 @@ async function handleV1Run(req2, res) {
|
|
|
669665
669783
|
cwd4 = resolve57(workingDir);
|
|
669666
669784
|
} else if (isolate) {
|
|
669667
669785
|
const wsDir = join153(dir, "..", "workspaces", id);
|
|
669668
|
-
|
|
669786
|
+
mkdirSync84(wsDir, { recursive: true });
|
|
669669
669787
|
cwd4 = wsDir;
|
|
669670
669788
|
} else {
|
|
669671
669789
|
cwd4 = resolve57(process.cwd());
|
|
@@ -671137,10 +671255,10 @@ async function handleRequest(req2, res, ollamaUrl, verbose, runtimeDefaults = {}
|
|
|
671137
671255
|
return;
|
|
671138
671256
|
}
|
|
671139
671257
|
const { tmpdir: tmpdir23 } = await import("node:os");
|
|
671140
|
-
const { writeFileSync:
|
|
671258
|
+
const { writeFileSync: writeFileSync80, unlinkSync: unlinkSync31 } = await import("node:fs");
|
|
671141
671259
|
const { join: pjoin } = await import("node:path");
|
|
671142
671260
|
const tmpPath = pjoin(tmpdir23(), `omnius-clone-upload-${Date.now()}-${safeName3}`);
|
|
671143
|
-
|
|
671261
|
+
writeFileSync80(tmpPath, buf);
|
|
671144
671262
|
try {
|
|
671145
671263
|
const ve = getVoiceEngine();
|
|
671146
671264
|
const msg = await ve.setCloneVoice(tmpPath);
|
|
@@ -671732,7 +671850,7 @@ data: ${JSON.stringify(data)}
|
|
|
671732
671850
|
}
|
|
671733
671851
|
for (const f2 of seenFiles) {
|
|
671734
671852
|
try {
|
|
671735
|
-
|
|
671853
|
+
writeFileSync75(f2, JSON.stringify({ tasks: [] }, null, 2));
|
|
671736
671854
|
deleted++;
|
|
671737
671855
|
} catch {
|
|
671738
671856
|
}
|
|
@@ -672952,11 +673070,11 @@ function setScheduledEnabled(id, enabled2) {
|
|
|
672952
673070
|
arr[target.index].enabled = enabled2;
|
|
672953
673071
|
if (Array.isArray(json?.tasks)) {
|
|
672954
673072
|
json.tasks = arr;
|
|
672955
|
-
|
|
673073
|
+
writeFileSync75(target.file, JSON.stringify(json, null, 2));
|
|
672956
673074
|
} else if (Array.isArray(json)) {
|
|
672957
|
-
|
|
673075
|
+
writeFileSync75(target.file, JSON.stringify(arr, null, 2));
|
|
672958
673076
|
} else {
|
|
672959
|
-
|
|
673077
|
+
writeFileSync75(target.file, JSON.stringify({ tasks: arr }, null, 2));
|
|
672960
673078
|
}
|
|
672961
673079
|
if (!enabled2) {
|
|
672962
673080
|
try {
|
|
@@ -672986,11 +673104,11 @@ function deleteScheduledById(id) {
|
|
|
672986
673104
|
arr.splice(target.index, 1);
|
|
672987
673105
|
if (Array.isArray(json?.tasks)) {
|
|
672988
673106
|
json.tasks = arr;
|
|
672989
|
-
|
|
673107
|
+
writeFileSync75(target.file, JSON.stringify(json, null, 2));
|
|
672990
673108
|
} else if (Array.isArray(json)) {
|
|
672991
|
-
|
|
673109
|
+
writeFileSync75(target.file, JSON.stringify(arr, null, 2));
|
|
672992
673110
|
} else {
|
|
672993
|
-
|
|
673111
|
+
writeFileSync75(target.file, JSON.stringify({ tasks: arr }, null, 2));
|
|
672994
673112
|
}
|
|
672995
673113
|
const candidates = [];
|
|
672996
673114
|
if (id) candidates.push(id);
|
|
@@ -673258,9 +673376,9 @@ function reconcileScheduledTasks(apply) {
|
|
|
673258
673376
|
const entry = { task: f2.task || `legacy ${f2.id}`, schedule: f2.cron, enabled: true };
|
|
673259
673377
|
arr.push(entry);
|
|
673260
673378
|
const toWrite = Array.isArray(json?.tasks) ? { ...json, tasks: arr } : Array.isArray(json) ? arr : { tasks: arr };
|
|
673261
|
-
|
|
673262
|
-
|
|
673263
|
-
|
|
673379
|
+
mkdirSync84(join153(wdir, ".omnius", "scheduled"), { recursive: true });
|
|
673380
|
+
mkdirSync84(join153(wdir, ".omnius", "scheduled", "logs"), { recursive: true });
|
|
673381
|
+
writeFileSync75(file, JSON.stringify(toWrite, null, 2));
|
|
673264
673382
|
adopted.push({ file, index: arr.length - 1 });
|
|
673265
673383
|
}
|
|
673266
673384
|
} else {
|
|
@@ -673393,9 +673511,9 @@ Persistent=true
|
|
|
673393
673511
|
WantedBy=timers.target
|
|
673394
673512
|
`;
|
|
673395
673513
|
if (!dryRun) {
|
|
673396
|
-
|
|
673397
|
-
|
|
673398
|
-
|
|
673514
|
+
mkdirSync84(unitDir, { recursive: true });
|
|
673515
|
+
writeFileSync75(svc, svcText);
|
|
673516
|
+
writeFileSync75(tim, timText);
|
|
673399
673517
|
try {
|
|
673400
673518
|
const { execSync: es } = require4("node:child_process");
|
|
673401
673519
|
es("systemctl --user daemon-reload", { stdio: "pipe" });
|
|
@@ -673539,7 +673657,7 @@ function startApiServer(options2 = {}) {
|
|
|
673539
673657
|
if (!apiTestMode) try {
|
|
673540
673658
|
const dir = todoDir();
|
|
673541
673659
|
try {
|
|
673542
|
-
|
|
673660
|
+
mkdirSync84(dir, { recursive: true });
|
|
673543
673661
|
} catch {
|
|
673544
673662
|
}
|
|
673545
673663
|
const cache8 = /* @__PURE__ */ new Map();
|
|
@@ -673717,8 +673835,8 @@ function startApiServer(options2 = {}) {
|
|
|
673717
673835
|
runtimeAccessMode = requested;
|
|
673718
673836
|
try {
|
|
673719
673837
|
const dir = join153(homedir53(), ".omnius");
|
|
673720
|
-
|
|
673721
|
-
|
|
673838
|
+
mkdirSync84(dir, { recursive: true });
|
|
673839
|
+
writeFileSync75(join153(dir, "access"), `${runtimeAccessMode}
|
|
673722
673840
|
`, "utf8");
|
|
673723
673841
|
} catch {
|
|
673724
673842
|
}
|
|
@@ -674023,7 +674141,7 @@ function startApiServer(options2 = {}) {
|
|
|
674023
674141
|
return;
|
|
674024
674142
|
}
|
|
674025
674143
|
try {
|
|
674026
|
-
const { writeFileSync:
|
|
674144
|
+
const { writeFileSync: writeFileSync80, mkdirSync: mkdirSync89, existsSync: _exists, readFileSync: _rfs } = require4("node:fs");
|
|
674027
674145
|
const { join: _join } = require4("node:path");
|
|
674028
674146
|
const { homedir: _homedir } = require4("node:os");
|
|
674029
674147
|
const apiHint = JSON.stringify({
|
|
@@ -674052,8 +674170,8 @@ function startApiServer(options2 = {}) {
|
|
|
674052
674170
|
let written = 0;
|
|
674053
674171
|
for (const dir of dirSet) {
|
|
674054
674172
|
try {
|
|
674055
|
-
if (!_exists(dir))
|
|
674056
|
-
|
|
674173
|
+
if (!_exists(dir)) mkdirSync89(dir, { recursive: true });
|
|
674174
|
+
writeFileSync80(_join(dir, "api-port.json"), apiHint);
|
|
674057
674175
|
written++;
|
|
674058
674176
|
} catch {
|
|
674059
674177
|
}
|
|
@@ -674338,9 +674456,9 @@ async function handleChatAttachmentUpload(req2, res) {
|
|
|
674338
674456
|
}
|
|
674339
674457
|
const safeName3 = filename.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 180) || `attachment-${Date.now()}.bin`;
|
|
674340
674458
|
const dir = join153(process.cwd(), ".omnius", "gui-attachments");
|
|
674341
|
-
|
|
674459
|
+
mkdirSync84(dir, { recursive: true });
|
|
674342
674460
|
const localPath = join153(dir, `${Date.now()}-${randomUUID17().slice(0, 8)}-${safeName3}`);
|
|
674343
|
-
|
|
674461
|
+
writeFileSync75(localPath, Buffer.from(base642, "base64"));
|
|
674344
674462
|
const mimeType = typeof b.mimeType === "string" ? b.mimeType : typeof b.mime_type === "string" ? b.mime_type : "";
|
|
674345
674463
|
const isImage = mimeType.toLowerCase().startsWith("image/") || /\.(png|jpe?g|gif|webp|bmp|tiff?)$/i.test(safeName3);
|
|
674346
674464
|
const sessionId = typeof b.sessionId === "string" ? b.sessionId : typeof b.session_id === "string" ? b.session_id : void 0;
|
|
@@ -674711,15 +674829,15 @@ __export(clipboard_media_exports, {
|
|
|
674711
674829
|
pasteClipboardImageToFile: () => pasteClipboardImageToFile
|
|
674712
674830
|
});
|
|
674713
674831
|
import { execFileSync as execFileSync9, execSync as execSync60 } from "node:child_process";
|
|
674714
|
-
import { mkdirSync as
|
|
674832
|
+
import { mkdirSync as mkdirSync85, readFileSync as readFileSync114, rmSync as rmSync9, writeFileSync as writeFileSync76 } from "node:fs";
|
|
674715
674833
|
import { join as join154 } from "node:path";
|
|
674716
674834
|
function pasteClipboardImageToFile(repoRoot) {
|
|
674717
674835
|
const image = readClipboardImage();
|
|
674718
674836
|
if (!image) return null;
|
|
674719
674837
|
const dir = join154(repoRoot, ".omnius", "clipboard");
|
|
674720
|
-
|
|
674838
|
+
mkdirSync85(dir, { recursive: true });
|
|
674721
674839
|
const path12 = join154(dir, `clipboard-${Date.now()}${image.ext}`);
|
|
674722
|
-
|
|
674840
|
+
writeFileSync76(path12, image.buffer);
|
|
674723
674841
|
return { path: path12, buffer: image.buffer, mime: image.mime };
|
|
674724
674842
|
}
|
|
674725
674843
|
function readClipboardImage() {
|
|
@@ -674730,7 +674848,7 @@ function readClipboardImage() {
|
|
|
674730
674848
|
execFileSync9("pngpaste", [tmp], { timeout: 3e3 });
|
|
674731
674849
|
const buffer2 = readFileSync114(tmp);
|
|
674732
674850
|
try {
|
|
674733
|
-
|
|
674851
|
+
rmSync9(tmp);
|
|
674734
674852
|
} catch {
|
|
674735
674853
|
}
|
|
674736
674854
|
if (buffer2.length > 0) return { buffer: buffer2, mime: "image/png", ext: ".png" };
|
|
@@ -674788,11 +674906,11 @@ import { createRequire as createRequire8 } from "node:module";
|
|
|
674788
674906
|
import { fileURLToPath as fileURLToPath20 } from "node:url";
|
|
674789
674907
|
import {
|
|
674790
674908
|
readFileSync as readFileSync115,
|
|
674791
|
-
writeFileSync as
|
|
674909
|
+
writeFileSync as writeFileSync77,
|
|
674792
674910
|
appendFileSync as appendFileSync13,
|
|
674793
|
-
rmSync as
|
|
674911
|
+
rmSync as rmSync10,
|
|
674794
674912
|
readdirSync as readdirSync51,
|
|
674795
|
-
mkdirSync as
|
|
674913
|
+
mkdirSync as mkdirSync86
|
|
674796
674914
|
} from "node:fs";
|
|
674797
674915
|
import { existsSync as existsSync141 } from "node:fs";
|
|
674798
674916
|
import { execSync as execSync61 } from "node:child_process";
|
|
@@ -677826,7 +677944,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
677826
677944
|
if (existsSync141(ikFile)) {
|
|
677827
677945
|
ikState = JSON.parse(readFileSync115(ikFile, "utf8"));
|
|
677828
677946
|
} else {
|
|
677829
|
-
|
|
677947
|
+
mkdirSync86(ikDir, { recursive: true });
|
|
677830
677948
|
const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
677831
677949
|
ikState = {
|
|
677832
677950
|
self_id: `omnius-${machineId}`,
|
|
@@ -677936,7 +678054,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
677936
678054
|
}
|
|
677937
678055
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
677938
678056
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
677939
|
-
|
|
678057
|
+
writeFileSync77(ikFile, JSON.stringify(ikState, null, 2));
|
|
677940
678058
|
} catch (ikErr) {
|
|
677941
678059
|
try {
|
|
677942
678060
|
console.error("[IK-OBSERVE]", ikErr);
|
|
@@ -677992,7 +678110,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
677992
678110
|
ikState.version_history = ikState.version_history.slice(-200);
|
|
677993
678111
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
677994
678112
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
677995
|
-
|
|
678113
|
+
writeFileSync77(ikFile, JSON.stringify(ikState, null, 2));
|
|
677996
678114
|
}
|
|
677997
678115
|
} catch {
|
|
677998
678116
|
}
|
|
@@ -679566,12 +679684,12 @@ This is an independent background session started from /background.`
|
|
|
679566
679684
|
function persistHistoryLine(line) {
|
|
679567
679685
|
if (!line.trim()) return;
|
|
679568
679686
|
try {
|
|
679569
|
-
|
|
679687
|
+
mkdirSync86(HISTORY_DIR, { recursive: true });
|
|
679570
679688
|
appendFileSync13(HISTORY_FILE, line + "\n", "utf8");
|
|
679571
679689
|
if (Math.random() < 0.02) {
|
|
679572
679690
|
const all2 = readFileSync115(HISTORY_FILE, "utf8").trim().split("\n");
|
|
679573
679691
|
if (all2.length > MAX_HISTORY_LINES) {
|
|
679574
|
-
|
|
679692
|
+
writeFileSync77(
|
|
679575
679693
|
HISTORY_FILE,
|
|
679576
679694
|
all2.slice(-MAX_HISTORY_LINES).join("\n") + "\n",
|
|
679577
679695
|
"utf8"
|
|
@@ -680474,8 +680592,8 @@ Log: ${nexusLogPath}`)
|
|
|
680474
680592
|
setSessionTitle(title) {
|
|
680475
680593
|
sessionTitle = title.trim() || null;
|
|
680476
680594
|
try {
|
|
680477
|
-
|
|
680478
|
-
|
|
680595
|
+
mkdirSync86(join155(repoRoot, ".omnius"), { recursive: true });
|
|
680596
|
+
writeFileSync77(join155(repoRoot, ".omnius", "session-title"), `${sessionTitle ?? ""}
|
|
680479
680597
|
`, "utf8");
|
|
680480
680598
|
} catch {
|
|
680481
680599
|
}
|
|
@@ -682265,7 +682383,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
682265
682383
|
let deleted = false;
|
|
682266
682384
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
682267
682385
|
try {
|
|
682268
|
-
|
|
682386
|
+
rmSync10(omniusPath, { recursive: true, force: true });
|
|
682269
682387
|
deleted = true;
|
|
682270
682388
|
break;
|
|
682271
682389
|
} catch (err) {
|
|
@@ -683676,7 +683794,7 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
683676
683794
|
if (existsSync141(ikFile)) {
|
|
683677
683795
|
ikState = JSON.parse(readFileSync115(ikFile, "utf8"));
|
|
683678
683796
|
} else {
|
|
683679
|
-
|
|
683797
|
+
mkdirSync86(ikDir, { recursive: true });
|
|
683680
683798
|
ikState = {
|
|
683681
683799
|
self_id: `omnius-${Date.now().toString(36)}`,
|
|
683682
683800
|
version: 1,
|
|
@@ -683729,7 +683847,7 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
683729
683847
|
);
|
|
683730
683848
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
683731
683849
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
683732
|
-
|
|
683850
|
+
writeFileSync77(ikFile, JSON.stringify(ikState, null, 2));
|
|
683733
683851
|
} catch (ikErr) {
|
|
683734
683852
|
}
|
|
683735
683853
|
try {
|
|
@@ -683761,8 +683879,8 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
683761
683879
|
tags: ["general"]
|
|
683762
683880
|
});
|
|
683763
683881
|
if (variants.length > 50) variants = variants.slice(-50);
|
|
683764
|
-
|
|
683765
|
-
|
|
683882
|
+
mkdirSync86(archeDir, { recursive: true });
|
|
683883
|
+
writeFileSync77(archeFile, JSON.stringify(variants, null, 2));
|
|
683766
683884
|
} catch {
|
|
683767
683885
|
}
|
|
683768
683886
|
}
|
|
@@ -683793,7 +683911,7 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
683793
683911
|
updated = true;
|
|
683794
683912
|
}
|
|
683795
683913
|
if (updated) {
|
|
683796
|
-
|
|
683914
|
+
writeFileSync77(metaFile2, JSON.stringify(store2, null, 2));
|
|
683797
683915
|
}
|
|
683798
683916
|
}
|
|
683799
683917
|
} catch {
|
|
@@ -683852,7 +683970,7 @@ Rules:
|
|
|
683852
683970
|
const { initDb: initDb2 } = __require("@omnius/memory");
|
|
683853
683971
|
const { ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@omnius/memory");
|
|
683854
683972
|
const dbDir = join155(repoRoot, ".omnius", "memory");
|
|
683855
|
-
|
|
683973
|
+
mkdirSync86(dbDir, { recursive: true });
|
|
683856
683974
|
const db = initDb2(join155(dbDir, "structured.db"));
|
|
683857
683975
|
const memStore = new ProceduralMemoryStore2(db);
|
|
683858
683976
|
memStore.createWithEmbedding(
|
|
@@ -683901,8 +684019,8 @@ Rules:
|
|
|
683901
684019
|
accessCount: 0
|
|
683902
684020
|
});
|
|
683903
684021
|
if (store2.length > 100) store2 = store2.slice(-100);
|
|
683904
|
-
|
|
683905
|
-
|
|
684022
|
+
mkdirSync86(metaDir, { recursive: true });
|
|
684023
|
+
writeFileSync77(storeFile, JSON.stringify(store2, null, 2));
|
|
683906
684024
|
}
|
|
683907
684025
|
}
|
|
683908
684026
|
} catch {
|
|
@@ -683966,7 +684084,7 @@ Rules:
|
|
|
683966
684084
|
);
|
|
683967
684085
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
683968
684086
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
683969
|
-
|
|
684087
|
+
writeFileSync77(ikFile, JSON.stringify(ikState, null, 2));
|
|
683970
684088
|
}
|
|
683971
684089
|
const metaFile2 = join155(
|
|
683972
684090
|
repoRoot,
|
|
@@ -683994,7 +684112,7 @@ Rules:
|
|
|
683994
684112
|
(item.scores.confidence || 0.5) - 0.02
|
|
683995
684113
|
);
|
|
683996
684114
|
}
|
|
683997
|
-
|
|
684115
|
+
writeFileSync77(metaFile2, JSON.stringify(store2, null, 2));
|
|
683998
684116
|
}
|
|
683999
684117
|
try {
|
|
684000
684118
|
const archeDir = join155(repoRoot, ".omnius", "arche");
|
|
@@ -684016,8 +684134,8 @@ Rules:
|
|
|
684016
684134
|
tags: ["general"]
|
|
684017
684135
|
});
|
|
684018
684136
|
if (variants.length > 50) variants = variants.slice(-50);
|
|
684019
|
-
|
|
684020
|
-
|
|
684137
|
+
mkdirSync86(archeDir, { recursive: true });
|
|
684138
|
+
writeFileSync77(archeFile, JSON.stringify(variants, null, 2));
|
|
684021
684139
|
} catch {
|
|
684022
684140
|
}
|
|
684023
684141
|
} catch {
|
|
@@ -684123,13 +684241,13 @@ __export(run_exports, {
|
|
|
684123
684241
|
});
|
|
684124
684242
|
import { resolve as resolve59 } from "node:path";
|
|
684125
684243
|
import { spawn as spawn32 } from "node:child_process";
|
|
684126
|
-
import { mkdirSync as
|
|
684244
|
+
import { mkdirSync as mkdirSync87, writeFileSync as writeFileSync78, readFileSync as readFileSync116, readdirSync as readdirSync52, existsSync as existsSync142 } from "node:fs";
|
|
684127
684245
|
import { randomBytes as randomBytes28 } from "node:crypto";
|
|
684128
684246
|
import { join as join156 } from "node:path";
|
|
684129
684247
|
function jobsDir2(repoPath2) {
|
|
684130
684248
|
const root = resolve59(repoPath2 ?? process.cwd());
|
|
684131
684249
|
const dir = join156(root, ".omnius", "jobs");
|
|
684132
|
-
|
|
684250
|
+
mkdirSync87(dir, { recursive: true });
|
|
684133
684251
|
return dir;
|
|
684134
684252
|
}
|
|
684135
684253
|
async function runCommand2(opts, config) {
|
|
@@ -684251,7 +684369,7 @@ async function runBackground(task, config, opts) {
|
|
|
684251
684369
|
}
|
|
684252
684370
|
});
|
|
684253
684371
|
job.pid = child.pid ?? 0;
|
|
684254
|
-
|
|
684372
|
+
writeFileSync78(join156(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
684255
684373
|
let output = "";
|
|
684256
684374
|
child.stdout?.on("data", (chunk) => {
|
|
684257
684375
|
output += chunk.toString();
|
|
@@ -684267,7 +684385,7 @@ async function runBackground(task, config, opts) {
|
|
|
684267
684385
|
job.summary = result.summary;
|
|
684268
684386
|
job.durationMs = result.durationMs;
|
|
684269
684387
|
job.error = result.error;
|
|
684270
|
-
|
|
684388
|
+
writeFileSync78(join156(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
684271
684389
|
} catch {
|
|
684272
684390
|
}
|
|
684273
684391
|
});
|
|
@@ -684902,7 +685020,7 @@ __export(eval_exports, {
|
|
|
684902
685020
|
evalCommand: () => evalCommand
|
|
684903
685021
|
});
|
|
684904
685022
|
import { tmpdir as tmpdir22 } from "node:os";
|
|
684905
|
-
import { mkdirSync as
|
|
685023
|
+
import { mkdirSync as mkdirSync88, writeFileSync as writeFileSync79 } from "node:fs";
|
|
684906
685024
|
import { join as join158 } from "node:path";
|
|
684907
685025
|
async function evalCommand(opts, config) {
|
|
684908
685026
|
const suiteName = opts.suite ?? "basic";
|
|
@@ -685033,8 +685151,8 @@ async function evalCommand(opts, config) {
|
|
|
685033
685151
|
}
|
|
685034
685152
|
function createTempEvalRepo() {
|
|
685035
685153
|
const dir = join158(tmpdir22(), `omnius-eval-${Date.now()}`);
|
|
685036
|
-
|
|
685037
|
-
|
|
685154
|
+
mkdirSync88(dir, { recursive: true });
|
|
685155
|
+
writeFileSync79(
|
|
685038
685156
|
join158(dir, "package.json"),
|
|
685039
685157
|
JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n",
|
|
685040
685158
|
"utf8"
|
|
@@ -685561,11 +685679,11 @@ function crashLog(label, err) {
|
|
|
685561
685679
|
const logLine = `[${timestamp}] ${label}: ${msg}
|
|
685562
685680
|
`;
|
|
685563
685681
|
try {
|
|
685564
|
-
const { appendFileSync: appendFileSync14, mkdirSync:
|
|
685682
|
+
const { appendFileSync: appendFileSync14, mkdirSync: mkdirSync89 } = __require("node:fs");
|
|
685565
685683
|
const { join: join160 } = __require("node:path");
|
|
685566
685684
|
const { homedir: homedir56 } = __require("node:os");
|
|
685567
685685
|
const logDir = join160(homedir56(), ".omnius");
|
|
685568
|
-
|
|
685686
|
+
mkdirSync89(logDir, { recursive: true });
|
|
685569
685687
|
appendFileSync14(join160(logDir, "crash.log"), logLine);
|
|
685570
685688
|
} catch {
|
|
685571
685689
|
}
|