omnius 1.0.342 → 1.0.343
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/README.md +41 -1
- package/dist/index.js +1357 -642
- package/docs/reference/rest-api.md +4 -1
- package/npm-shrinkwrap.json +13 -12
- package/package.json +17 -2
package/dist/index.js
CHANGED
|
@@ -150501,9 +150501,9 @@ var require_mock_utils = __commonJS({
|
|
|
150501
150501
|
if (mockDispatch2.data.callback) {
|
|
150502
150502
|
mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) };
|
|
150503
150503
|
}
|
|
150504
|
-
const { data: { statusCode, data, headers, trailers, error }, delay: delay3, persist:
|
|
150504
|
+
const { data: { statusCode, data, headers, trailers, error }, delay: delay3, persist: persist4 } = mockDispatch2;
|
|
150505
150505
|
const { timesInvoked, times } = mockDispatch2;
|
|
150506
|
-
mockDispatch2.consumed = !
|
|
150506
|
+
mockDispatch2.consumed = !persist4 && timesInvoked >= times;
|
|
150507
150507
|
mockDispatch2.pending = timesInvoked < times;
|
|
150508
150508
|
if (error !== null) {
|
|
150509
150509
|
deleteMockDispatch(this[kDispatches], key);
|
|
@@ -151150,14 +151150,14 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
151150
151150
|
}
|
|
151151
151151
|
format(pendingInterceptors) {
|
|
151152
151152
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
151153
|
-
({ method, path: path12, data: { statusCode }, persist:
|
|
151153
|
+
({ method, path: path12, data: { statusCode }, persist: persist4, times, timesInvoked, origin }) => ({
|
|
151154
151154
|
Method: method,
|
|
151155
151155
|
Origin: origin,
|
|
151156
151156
|
Path: path12,
|
|
151157
151157
|
"Status code": statusCode,
|
|
151158
|
-
Persistent:
|
|
151158
|
+
Persistent: persist4 ? PERSISTENT : NOT_PERSISTENT,
|
|
151159
151159
|
Invocations: timesInvoked,
|
|
151160
|
-
Remaining:
|
|
151160
|
+
Remaining: persist4 ? Infinity : times - timesInvoked
|
|
151161
151161
|
})
|
|
151162
151162
|
);
|
|
151163
151163
|
this.logger.table(withPrettyHeaders);
|
|
@@ -273135,9 +273135,9 @@ print("${sentinel}")
|
|
|
273135
273135
|
if (!this.proc || this.proc.killed) {
|
|
273136
273136
|
return { success: false, path: "" };
|
|
273137
273137
|
}
|
|
273138
|
-
const { mkdirSync:
|
|
273138
|
+
const { mkdirSync: mkdirSync106, writeFileSync: writeFileSync91 } = await import("node:fs");
|
|
273139
273139
|
const sessionDir2 = join43(this.cwd, ".omnius", "rlm");
|
|
273140
|
-
|
|
273140
|
+
mkdirSync106(sessionDir2, { recursive: true });
|
|
273141
273141
|
const sessionPath2 = join43(sessionDir2, "session.json");
|
|
273142
273142
|
try {
|
|
273143
273143
|
const inspectCode = `
|
|
@@ -273161,7 +273161,7 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
273161
273161
|
trajectoryCount: this.trajectory.length,
|
|
273162
273162
|
subCallCount: this.subCallCount
|
|
273163
273163
|
};
|
|
273164
|
-
|
|
273164
|
+
writeFileSync91(sessionPath2, JSON.stringify(sessionData, null, 2), "utf8");
|
|
273165
273165
|
return { success: true, path: sessionPath2 };
|
|
273166
273166
|
}
|
|
273167
273167
|
} catch {
|
|
@@ -273173,11 +273173,11 @@ print("__SESSION__" + json.dumps(_session) + "__SESSION__")
|
|
|
273173
273173
|
* what was previously computed. */
|
|
273174
273174
|
async loadSessionInfo() {
|
|
273175
273175
|
try {
|
|
273176
|
-
const { readFileSync:
|
|
273176
|
+
const { readFileSync: readFileSync134, existsSync: existsSync164 } = await import("node:fs");
|
|
273177
273177
|
const sessionPath2 = join43(this.cwd, ".omnius", "rlm", "session.json");
|
|
273178
|
-
if (!
|
|
273178
|
+
if (!existsSync164(sessionPath2))
|
|
273179
273179
|
return null;
|
|
273180
|
-
return JSON.parse(
|
|
273180
|
+
return JSON.parse(readFileSync134(sessionPath2, "utf8"));
|
|
273181
273181
|
} catch {
|
|
273182
273182
|
return null;
|
|
273183
273183
|
}
|
|
@@ -273364,10 +273364,10 @@ var init_memory_metabolism = __esm({
|
|
|
273364
273364
|
const trajDir = join44(this.cwd, ".omnius", "rlm-trajectories");
|
|
273365
273365
|
let lessons = [];
|
|
273366
273366
|
try {
|
|
273367
|
-
const { readdirSync: readdirSync59, readFileSync:
|
|
273367
|
+
const { readdirSync: readdirSync59, readFileSync: readFileSync134 } = await import("node:fs");
|
|
273368
273368
|
const files = readdirSync59(trajDir).filter((f2) => f2.endsWith(".jsonl")).sort().reverse().slice(0, 3);
|
|
273369
273369
|
for (const file of files) {
|
|
273370
|
-
const lines =
|
|
273370
|
+
const lines = readFileSync134(join44(trajDir, file), "utf8").split("\n").filter((l2) => l2.trim());
|
|
273371
273371
|
for (const line of lines) {
|
|
273372
273372
|
try {
|
|
273373
273373
|
const entry = JSON.parse(line);
|
|
@@ -273751,14 +273751,14 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
273751
273751
|
* Optionally filter by task type for phase-aware context (FSM paper insight).
|
|
273752
273752
|
*/
|
|
273753
273753
|
getTopMemoriesSync(k = 5, taskType) {
|
|
273754
|
-
const { readFileSync:
|
|
273754
|
+
const { readFileSync: readFileSync134, existsSync: existsSync164 } = __require("node:fs");
|
|
273755
273755
|
const metaDir = join44(this.cwd, ".omnius", "memory", "metabolism");
|
|
273756
273756
|
const storeFile = join44(metaDir, "store.json");
|
|
273757
|
-
if (!
|
|
273757
|
+
if (!existsSync164(storeFile))
|
|
273758
273758
|
return "";
|
|
273759
273759
|
let store2 = [];
|
|
273760
273760
|
try {
|
|
273761
|
-
store2 = JSON.parse(
|
|
273761
|
+
store2 = JSON.parse(readFileSync134(storeFile, "utf8"));
|
|
273762
273762
|
} catch {
|
|
273763
273763
|
return "";
|
|
273764
273764
|
}
|
|
@@ -273780,14 +273780,14 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
273780
273780
|
/** Update memory scores based on task outcome. Called after task completion.
|
|
273781
273781
|
* Memories used in successful tasks get boosted. Memories present during failures get decayed. */
|
|
273782
273782
|
updateFromOutcomeSync(surfacedMemoryText, succeeded) {
|
|
273783
|
-
const { readFileSync:
|
|
273783
|
+
const { readFileSync: readFileSync134, writeFileSync: writeFileSync91, existsSync: existsSync164, mkdirSync: mkdirSync106 } = __require("node:fs");
|
|
273784
273784
|
const metaDir = join44(this.cwd, ".omnius", "memory", "metabolism");
|
|
273785
273785
|
const storeFile = join44(metaDir, "store.json");
|
|
273786
|
-
if (!
|
|
273786
|
+
if (!existsSync164(storeFile))
|
|
273787
273787
|
return;
|
|
273788
273788
|
let store2 = [];
|
|
273789
273789
|
try {
|
|
273790
|
-
store2 = JSON.parse(
|
|
273790
|
+
store2 = JSON.parse(readFileSync134(storeFile, "utf8"));
|
|
273791
273791
|
} catch {
|
|
273792
273792
|
return;
|
|
273793
273793
|
}
|
|
@@ -273811,8 +273811,8 @@ ${issues.map((i2) => ` - ${i2}`).join("\n")}` : " No issues found."),
|
|
|
273811
273811
|
updated = true;
|
|
273812
273812
|
}
|
|
273813
273813
|
if (updated) {
|
|
273814
|
-
|
|
273815
|
-
|
|
273814
|
+
mkdirSync106(metaDir, { recursive: true });
|
|
273815
|
+
writeFileSync91(storeFile, JSON.stringify(store2, null, 2));
|
|
273816
273816
|
}
|
|
273817
273817
|
}
|
|
273818
273818
|
// ── Storage ──────────────────────────────────────────────────────────
|
|
@@ -274234,13 +274234,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
274234
274234
|
// Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
|
|
274235
274235
|
/** Retrieve top-K strategies for context injection. Returns "" if none. */
|
|
274236
274236
|
getRelevantStrategiesSync(k = 3, taskType) {
|
|
274237
|
-
const { readFileSync:
|
|
274237
|
+
const { readFileSync: readFileSync134, existsSync: existsSync164 } = __require("node:fs");
|
|
274238
274238
|
const archiveFile = join46(this.cwd, ".omnius", "arche", "variants.json");
|
|
274239
|
-
if (!
|
|
274239
|
+
if (!existsSync164(archiveFile))
|
|
274240
274240
|
return "";
|
|
274241
274241
|
let variants = [];
|
|
274242
274242
|
try {
|
|
274243
|
-
variants = JSON.parse(
|
|
274243
|
+
variants = JSON.parse(readFileSync134(archiveFile, "utf8"));
|
|
274244
274244
|
} catch {
|
|
274245
274245
|
return "";
|
|
274246
274246
|
}
|
|
@@ -274258,13 +274258,13 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
274258
274258
|
}
|
|
274259
274259
|
/** Archive a strategy variant synchronously (for task completion path) */
|
|
274260
274260
|
archiveVariantSync(strategy, outcome, tags = []) {
|
|
274261
|
-
const { readFileSync:
|
|
274261
|
+
const { readFileSync: readFileSync134, writeFileSync: writeFileSync91, existsSync: existsSync164, mkdirSync: mkdirSync106 } = __require("node:fs");
|
|
274262
274262
|
const dir = join46(this.cwd, ".omnius", "arche");
|
|
274263
274263
|
const archiveFile = join46(dir, "variants.json");
|
|
274264
274264
|
let variants = [];
|
|
274265
274265
|
try {
|
|
274266
|
-
if (
|
|
274267
|
-
variants = JSON.parse(
|
|
274266
|
+
if (existsSync164(archiveFile))
|
|
274267
|
+
variants = JSON.parse(readFileSync134(archiveFile, "utf8"));
|
|
274268
274268
|
} catch {
|
|
274269
274269
|
}
|
|
274270
274270
|
variants.push({
|
|
@@ -274279,8 +274279,8 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
|
|
|
274279
274279
|
});
|
|
274280
274280
|
if (variants.length > 50)
|
|
274281
274281
|
variants = variants.slice(-50);
|
|
274282
|
-
|
|
274283
|
-
|
|
274282
|
+
mkdirSync106(dir, { recursive: true });
|
|
274283
|
+
writeFileSync91(archiveFile, JSON.stringify(variants, null, 2));
|
|
274284
274284
|
}
|
|
274285
274285
|
async saveArchive(variants) {
|
|
274286
274286
|
const dir = join46(this.cwd, ".omnius", "arche");
|
|
@@ -296166,7 +296166,7 @@ var require_util9 = __commonJS({
|
|
|
296166
296166
|
return path12;
|
|
296167
296167
|
}
|
|
296168
296168
|
exports.normalize = normalize2;
|
|
296169
|
-
function
|
|
296169
|
+
function join179(aRoot, aPath) {
|
|
296170
296170
|
if (aRoot === "") {
|
|
296171
296171
|
aRoot = ".";
|
|
296172
296172
|
}
|
|
@@ -296198,7 +296198,7 @@ var require_util9 = __commonJS({
|
|
|
296198
296198
|
}
|
|
296199
296199
|
return joined;
|
|
296200
296200
|
}
|
|
296201
|
-
exports.join =
|
|
296201
|
+
exports.join = join179;
|
|
296202
296202
|
exports.isAbsolute = function(aPath) {
|
|
296203
296203
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
296204
296204
|
};
|
|
@@ -296371,7 +296371,7 @@ var require_util9 = __commonJS({
|
|
|
296371
296371
|
parsed.path = parsed.path.substring(0, index + 1);
|
|
296372
296372
|
}
|
|
296373
296373
|
}
|
|
296374
|
-
sourceURL =
|
|
296374
|
+
sourceURL = join179(urlGenerate(parsed), sourceURL);
|
|
296375
296375
|
}
|
|
296376
296376
|
return normalize2(sourceURL);
|
|
296377
296377
|
}
|
|
@@ -511784,7 +511784,7 @@ var require_path_browserify = __commonJS({
|
|
|
511784
511784
|
assertPath(path12);
|
|
511785
511785
|
return path12.length > 0 && path12.charCodeAt(0) === 47;
|
|
511786
511786
|
},
|
|
511787
|
-
join: function
|
|
511787
|
+
join: function join179() {
|
|
511788
511788
|
if (arguments.length === 0)
|
|
511789
511789
|
return ".";
|
|
511790
511790
|
var joined;
|
|
@@ -563673,9 +563673,9 @@ var init_reflectionBuffer = __esm({
|
|
|
563673
563673
|
this.persistPath = persistPath ?? null;
|
|
563674
563674
|
if (this.persistPath) {
|
|
563675
563675
|
try {
|
|
563676
|
-
const { readFileSync:
|
|
563677
|
-
if (
|
|
563678
|
-
this.state = JSON.parse(
|
|
563676
|
+
const { readFileSync: readFileSync134, existsSync: existsSync164 } = __require("node:fs");
|
|
563677
|
+
if (existsSync164(this.persistPath)) {
|
|
563678
|
+
this.state = JSON.parse(readFileSync134(this.persistPath, "utf-8"));
|
|
563679
563679
|
return;
|
|
563680
563680
|
}
|
|
563681
563681
|
} catch {
|
|
@@ -563954,12 +563954,12 @@ var init_reflectionBuffer = __esm({
|
|
|
563954
563954
|
if (!this.persistPath)
|
|
563955
563955
|
return;
|
|
563956
563956
|
try {
|
|
563957
|
-
const { writeFileSync:
|
|
563958
|
-
const { join:
|
|
563959
|
-
const dir =
|
|
563960
|
-
if (!
|
|
563961
|
-
|
|
563962
|
-
|
|
563957
|
+
const { writeFileSync: writeFileSync91, mkdirSync: mkdirSync106, existsSync: existsSync164 } = __require("node:fs");
|
|
563958
|
+
const { join: join179 } = __require("node:path");
|
|
563959
|
+
const dir = join179(this.persistPath, "..");
|
|
563960
|
+
if (!existsSync164(dir))
|
|
563961
|
+
mkdirSync106(dir, { recursive: true });
|
|
563962
|
+
writeFileSync91(this.persistPath, JSON.stringify(this.state, null, 2));
|
|
563963
563963
|
} catch {
|
|
563964
563964
|
}
|
|
563965
563965
|
}
|
|
@@ -568654,19 +568654,27 @@ function isOllamaModelNotFoundResponse(status, text2, model) {
|
|
|
568654
568654
|
function isBackendConnectionError(err) {
|
|
568655
568655
|
if (err instanceof Error && err.name === "AbortError")
|
|
568656
568656
|
return false;
|
|
568657
|
+
return /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EHOSTUNREACH|ENOTFOUND|EPIPE|socket hang up|UND_ERR/i.test(flattenErrorText(err));
|
|
568658
|
+
}
|
|
568659
|
+
function flattenErrorText(err) {
|
|
568657
568660
|
const parts = [];
|
|
568658
|
-
|
|
568659
|
-
|
|
568660
|
-
|
|
568661
|
-
|
|
568662
|
-
|
|
568663
|
-
|
|
568664
|
-
|
|
568665
|
-
|
|
568666
|
-
|
|
568667
|
-
|
|
568668
|
-
|
|
568669
|
-
|
|
568661
|
+
let cur = err;
|
|
568662
|
+
for (let depth = 0; depth < 5 && cur != null; depth++) {
|
|
568663
|
+
if (cur instanceof Error) {
|
|
568664
|
+
if (cur.message)
|
|
568665
|
+
parts.push(cur.message);
|
|
568666
|
+
const code8 = cur.code;
|
|
568667
|
+
if (typeof code8 === "string")
|
|
568668
|
+
parts.push(code8);
|
|
568669
|
+
cur = cur.cause;
|
|
568670
|
+
} else if (typeof cur === "string") {
|
|
568671
|
+
parts.push(cur);
|
|
568672
|
+
break;
|
|
568673
|
+
} else {
|
|
568674
|
+
break;
|
|
568675
|
+
}
|
|
568676
|
+
}
|
|
568677
|
+
return parts.join(" ");
|
|
568670
568678
|
}
|
|
568671
568679
|
function computeEffectiveThink(params) {
|
|
568672
568680
|
if (process.env["OMNIUS_FORCE_NO_THINK"] === "1")
|
|
@@ -580166,10 +580174,10 @@ ${this._completionCaveat}` : this._completionCaveat;
|
|
|
580166
580174
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
580167
580175
|
});
|
|
580168
580176
|
try {
|
|
580169
|
-
const { mkdirSync:
|
|
580170
|
-
const { join:
|
|
580171
|
-
const contextDir =
|
|
580172
|
-
|
|
580177
|
+
const { mkdirSync: mkdirSync106, readdirSync: readdirSync59, statSync: statSync59, unlinkSync: unlinkSync35, writeFileSync: writeFileSync91 } = __require("node:fs");
|
|
580178
|
+
const { join: join179 } = __require("node:path");
|
|
580179
|
+
const contextDir = join179(this._workingDirectory || process.cwd(), ".omnius", "context");
|
|
580180
|
+
mkdirSync106(contextDir, { recursive: true });
|
|
580173
580181
|
const topEntities = this._temporalGraph.nodesByType("entity", 3);
|
|
580174
580182
|
const topFiles = this._temporalGraph.nodesByType("file", 3);
|
|
580175
580183
|
const topConcepts = this._temporalGraph.nodesByType("concept", 3);
|
|
@@ -580209,18 +580217,18 @@ ${this._completionCaveat}` : this._completionCaveat;
|
|
|
580209
580217
|
section("Top Files", topFiles);
|
|
580210
580218
|
section("Top Concepts", topConcepts);
|
|
580211
580219
|
lines.push("(Use file_read on this file for quick recall. See provenance JSON for full edge detail.)");
|
|
580212
|
-
const kgSummaryDir =
|
|
580213
|
-
|
|
580220
|
+
const kgSummaryDir = join179(contextDir, "kg-summary");
|
|
580221
|
+
mkdirSync106(kgSummaryDir, { recursive: true });
|
|
580214
580222
|
const summaryFilename = `kg-summary-${this._sessionId}.md`;
|
|
580215
|
-
const outPath =
|
|
580216
|
-
|
|
580217
|
-
|
|
580218
|
-
|
|
580223
|
+
const outPath = join179(kgSummaryDir, summaryFilename);
|
|
580224
|
+
writeFileSync91(outPath, lines.join("\n"), "utf-8");
|
|
580225
|
+
writeFileSync91(join179(kgSummaryDir, "latest.md"), lines.join("\n"), "utf-8");
|
|
580226
|
+
writeFileSync91(join179(contextDir, `kg-summary-latest.md`), [
|
|
580219
580227
|
"Latest KG summary moved to `.omnius/context/kg-summary/latest.md`.",
|
|
580220
580228
|
"",
|
|
580221
580229
|
lines.join("\n")
|
|
580222
580230
|
].join("\n"), "utf-8");
|
|
580223
|
-
|
|
580231
|
+
writeFileSync91(join179(kgSummaryDir, "index.json"), JSON.stringify({
|
|
580224
580232
|
schema: "omnius.kg-summary-index.v1",
|
|
580225
580233
|
latest: "latest.md",
|
|
580226
580234
|
latestSessionFile: summaryFilename,
|
|
@@ -580232,7 +580240,7 @@ ${this._completionCaveat}` : this._completionCaveat;
|
|
|
580232
580240
|
const maxFiles = parseInt(process.env["OMNIUS_KG_SUMMARY_MAX_FILES"] || "60", 10) || 60;
|
|
580233
580241
|
const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1e3;
|
|
580234
580242
|
const summaries = readdirSync59(kgSummaryDir).filter((name10) => name10.startsWith("kg-summary-") && name10.endsWith(".md")).map((name10) => {
|
|
580235
|
-
const filePath =
|
|
580243
|
+
const filePath = join179(kgSummaryDir, name10);
|
|
580236
580244
|
const stat8 = statSync59(filePath);
|
|
580237
580245
|
return { filePath, mtimeMs: stat8.mtimeMs };
|
|
580238
580246
|
}).sort((a2, b) => b.mtimeMs - a2.mtimeMs);
|
|
@@ -580519,11 +580527,11 @@ ${errOutput}`);
|
|
|
580519
580527
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
580520
580528
|
});
|
|
580521
580529
|
try {
|
|
580522
|
-
const { mkdirSync:
|
|
580523
|
-
const { join:
|
|
580524
|
-
const resultsDir =
|
|
580525
|
-
|
|
580526
|
-
|
|
580530
|
+
const { mkdirSync: mkdirSync106, writeFileSync: writeFileSync91 } = __require("node:fs");
|
|
580531
|
+
const { join: join179 } = __require("node:path");
|
|
580532
|
+
const resultsDir = join179(this.omniusStateDir(), "tool-results");
|
|
580533
|
+
mkdirSync106(resultsDir, { recursive: true });
|
|
580534
|
+
writeFileSync91(join179(resultsDir, `${handleId}.txt`), `# Tool: ${toolName}
|
|
580527
580535
|
# Turn: ${turn}
|
|
580528
580536
|
# Timestamp: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
580529
580537
|
# Size: ${result.output.length} chars, ${lineCount} lines
|
|
@@ -580916,10 +580924,10 @@ Actions: (1) list_directory on the parent directory to see what's there, (2) Che
|
|
|
580916
580924
|
if (!this._workingDirectory)
|
|
580917
580925
|
return;
|
|
580918
580926
|
try {
|
|
580919
|
-
const { mkdirSync:
|
|
580920
|
-
const { join:
|
|
580921
|
-
const sessionDir2 = this.options.stateDir ?
|
|
580922
|
-
|
|
580927
|
+
const { mkdirSync: mkdirSync106, writeFileSync: writeFileSync91 } = __require("node:fs");
|
|
580928
|
+
const { join: join179 } = __require("node:path");
|
|
580929
|
+
const sessionDir2 = this.options.stateDir ? join179(this.omniusStateDir(), "session", this._sessionId) : join179(this._workingDirectory, ".omnius", "session", this._sessionId);
|
|
580930
|
+
mkdirSync106(sessionDir2, { recursive: true });
|
|
580923
580931
|
const checkpoint = {
|
|
580924
580932
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
580925
580933
|
sessionId: this._sessionId,
|
|
@@ -580931,7 +580939,7 @@ Actions: (1) list_directory on the parent directory to see what's there, (2) Che
|
|
|
580931
580939
|
memexEntryCount: this._memexArchive.size,
|
|
580932
580940
|
fileRegistrySize: this._fileRegistry.size
|
|
580933
580941
|
};
|
|
580934
|
-
|
|
580942
|
+
writeFileSync91(join179(sessionDir2, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
|
|
580935
580943
|
} catch {
|
|
580936
580944
|
}
|
|
580937
580945
|
}
|
|
@@ -581620,8 +581628,8 @@ ${telegramPersonaHead}` : stripped
|
|
|
581620
581628
|
let recoveredTokens = 0;
|
|
581621
581629
|
for (const [filePath, entry] of entries) {
|
|
581622
581630
|
try {
|
|
581623
|
-
const { readFileSync:
|
|
581624
|
-
const content =
|
|
581631
|
+
const { readFileSync: readFileSync134 } = await import("node:fs");
|
|
581632
|
+
const content = readFileSync134(filePath, "utf8");
|
|
581625
581633
|
const tokenEst = Math.ceil(content.length / 4);
|
|
581626
581634
|
if (recoveredTokens + tokenEst > fileRecoveryBudget)
|
|
581627
581635
|
break;
|
|
@@ -583445,14 +583453,16 @@ ${result}`
|
|
|
583445
583453
|
isTransientError(err) {
|
|
583446
583454
|
if (err instanceof Error && err.fatal)
|
|
583447
583455
|
return false;
|
|
583448
|
-
const msg =
|
|
583456
|
+
const msg = flattenErrorText(err);
|
|
583457
|
+
if (this.isRecoverableAuthError(err))
|
|
583458
|
+
return true;
|
|
583449
583459
|
if (/HTTP 402|402 Payment|payment required|insufficient (credits|funds|balance)/i.test(msg))
|
|
583450
583460
|
return true;
|
|
583451
583461
|
if (/HTTP 429|429 Too Many|rate.?limit|too many requests/i.test(msg))
|
|
583452
583462
|
return true;
|
|
583453
583463
|
if (/Backend HTTP (502|503|504)/i.test(msg))
|
|
583454
583464
|
return true;
|
|
583455
|
-
if (/fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EPIPE|socket hang up/i.test(msg))
|
|
583465
|
+
if (/fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EPIPE|socket hang up|UND_ERR|other side closed/i.test(msg))
|
|
583456
583466
|
return true;
|
|
583457
583467
|
if (/received HTML error page/i.test(msg))
|
|
583458
583468
|
return true;
|
|
@@ -583472,6 +583482,16 @@ ${result}`
|
|
|
583472
583482
|
const msg = err instanceof Error ? err.message : String(err);
|
|
583473
583483
|
return /No GPU slot available after 30s\. All slots occupied\./i.test(msg);
|
|
583474
583484
|
}
|
|
583485
|
+
/**
|
|
583486
|
+
* Recoverable authentication/session error (HTTP 401/403). Distinguished
|
|
583487
|
+
* from a hard config error: this fires when a previously-working backend
|
|
583488
|
+
* loses its session (e.g. "No cookie auth credentials found" after a socket
|
|
583489
|
+
* reset). The fix is to re-authenticate and retry, not to abort the task.
|
|
583490
|
+
*/
|
|
583491
|
+
isRecoverableAuthError(err) {
|
|
583492
|
+
const msg = flattenErrorText(err);
|
|
583493
|
+
return /Backend HTTP 401|Backend HTTP 403|HTTP 401|HTTP 403|\b401\b|\b403\b|No cookie auth|cookie auth credentials|unauthor(?:ized|ised)|session (?:expired|invalid|not found)|invalid session|credentials (?:not found|expired|missing)/i.test(msg);
|
|
583494
|
+
}
|
|
583475
583495
|
/** Detect 402 payment-required errors that should trigger key rotation */
|
|
583476
583496
|
isPaymentRequiredError(err) {
|
|
583477
583497
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -583523,17 +583543,17 @@ ${result}`
|
|
|
583523
583543
|
let resizedBase64 = null;
|
|
583524
583544
|
try {
|
|
583525
583545
|
const { execSync: execSync63 } = await import("node:child_process");
|
|
583526
|
-
const { writeFileSync:
|
|
583527
|
-
const { join:
|
|
583546
|
+
const { writeFileSync: writeFileSync91, readFileSync: readFileSync134, unlinkSync: unlinkSync35 } = await import("node:fs");
|
|
583547
|
+
const { join: join179 } = await import("node:path");
|
|
583528
583548
|
const { tmpdir: tmpdir24 } = await import("node:os");
|
|
583529
|
-
const tmpIn =
|
|
583530
|
-
const tmpOut =
|
|
583531
|
-
|
|
583549
|
+
const tmpIn = join179(tmpdir24(), `omnius_img_in_${Date.now()}.png`);
|
|
583550
|
+
const tmpOut = join179(tmpdir24(), `omnius_img_out_${Date.now()}.jpg`);
|
|
583551
|
+
writeFileSync91(tmpIn, buffer2);
|
|
583532
583552
|
const pyBin = process.platform === "win32" ? "python" : "python3";
|
|
583533
583553
|
const escapedIn = tmpIn.replace(/\\/g, "\\\\");
|
|
583534
583554
|
const escapedOut = tmpOut.replace(/\\/g, "\\\\");
|
|
583535
583555
|
execSync63(`${pyBin} -c "from PIL import Image; img = Image.open('${escapedIn}'); img.thumbnail((512, 512), Image.LANCZOS); img = img.convert('RGB'); img.save('${escapedOut}', 'JPEG', quality=75)"`, { timeout: 1e4, stdio: "pipe" });
|
|
583536
|
-
const resizedBuf =
|
|
583556
|
+
const resizedBuf = readFileSync134(tmpOut);
|
|
583537
583557
|
resizedBase64 = `data:image/jpeg;base64,${resizedBuf.toString("base64")}`;
|
|
583538
583558
|
try {
|
|
583539
583559
|
unlinkSync35(tmpIn);
|
|
@@ -583686,10 +583706,11 @@ ${description}`
|
|
|
583686
583706
|
async retryOnTransient(initialErr, chatRequest, turn) {
|
|
583687
583707
|
if (!this.isTransientError(initialErr))
|
|
583688
583708
|
return null;
|
|
583689
|
-
const errMsg =
|
|
583690
|
-
const isNetworkError2 = /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|socket hang up/i.test(errMsg);
|
|
583709
|
+
const errMsg = flattenErrorText(initialErr);
|
|
583710
|
+
const isNetworkError2 = /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|socket hang up|UND_ERR|other side closed/i.test(errMsg);
|
|
583711
|
+
const isAuthError = this.isRecoverableAuthError(initialErr);
|
|
583691
583712
|
const isGpuSlotUnavailable = this.isGpuSlotUnavailableError(initialErr);
|
|
583692
|
-
const maxRetries = isNetworkError2 || isGpuSlotUnavailable ? Infinity : 3;
|
|
583713
|
+
const maxRetries = isNetworkError2 || isGpuSlotUnavailable || isAuthError ? Infinity : 3;
|
|
583693
583714
|
const baseDelayMs = isGpuSlotUnavailable ? 1e3 : isNetworkError2 ? 5e3 : 3e3;
|
|
583694
583715
|
const maxDelayMs = 6e4;
|
|
583695
583716
|
const backend = this.backend;
|
|
@@ -583728,6 +583749,22 @@ ${description}`
|
|
|
583728
583749
|
return null;
|
|
583729
583750
|
}
|
|
583730
583751
|
}
|
|
583752
|
+
if (isAuthError) {
|
|
583753
|
+
try {
|
|
583754
|
+
const reauthed = await backend.reauth?.();
|
|
583755
|
+
this.emit({
|
|
583756
|
+
type: "status",
|
|
583757
|
+
content: reauthed === false ? `Session lost (auth) — retrying (re-auth unavailable, re-presenting credentials)` : `Session lost (auth) — re-authenticating and retrying`,
|
|
583758
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
583759
|
+
});
|
|
583760
|
+
} catch {
|
|
583761
|
+
this.emit({
|
|
583762
|
+
type: "status",
|
|
583763
|
+
content: `Session lost (auth) — retrying`,
|
|
583764
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
583765
|
+
});
|
|
583766
|
+
}
|
|
583767
|
+
}
|
|
583731
583768
|
const delay3 = isGpuSlotUnavailable ? baseDelayMs : Math.min(baseDelayMs * Math.pow(2, attempt - 1), maxDelayMs);
|
|
583732
583769
|
const attemptLabel = maxRetries === Infinity ? `${attempt}` : `${attempt}/${maxRetries}`;
|
|
583733
583770
|
if (isGpuSlotUnavailable) {
|
|
@@ -598727,25 +598764,25 @@ async function fetchOpenAIModels(baseUrl2, apiKey) {
|
|
|
598727
598764
|
async function fetchPeerModels(peerId, authKey) {
|
|
598728
598765
|
try {
|
|
598729
598766
|
const { NexusTool: NexusTool2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports2));
|
|
598730
|
-
const { existsSync:
|
|
598731
|
-
const { join:
|
|
598767
|
+
const { existsSync: existsSync164, readFileSync: readFileSync134 } = await import("node:fs");
|
|
598768
|
+
const { join: join179 } = await import("node:path");
|
|
598732
598769
|
const cwd4 = process.cwd();
|
|
598733
598770
|
const nexusTool = new NexusTool2(cwd4);
|
|
598734
598771
|
const nexusDir = nexusTool.getNexusDir();
|
|
598735
598772
|
let isLocalPeer = false;
|
|
598736
598773
|
try {
|
|
598737
|
-
const statusPath =
|
|
598738
|
-
if (
|
|
598739
|
-
const status = JSON.parse(
|
|
598774
|
+
const statusPath = join179(nexusDir, "status.json");
|
|
598775
|
+
if (existsSync164(statusPath)) {
|
|
598776
|
+
const status = JSON.parse(readFileSync134(statusPath, "utf8"));
|
|
598740
598777
|
if (status.peerId === peerId) isLocalPeer = true;
|
|
598741
598778
|
}
|
|
598742
598779
|
} catch {
|
|
598743
598780
|
}
|
|
598744
598781
|
if (isLocalPeer) {
|
|
598745
|
-
const pricingPath =
|
|
598746
|
-
if (
|
|
598782
|
+
const pricingPath = join179(nexusDir, "pricing.json");
|
|
598783
|
+
if (existsSync164(pricingPath)) {
|
|
598747
598784
|
try {
|
|
598748
|
-
const pricing = JSON.parse(
|
|
598785
|
+
const pricing = JSON.parse(readFileSync134(pricingPath, "utf8"));
|
|
598749
598786
|
const localModels = (pricing.models || []).map((m2) => ({
|
|
598750
598787
|
name: m2.model || "unknown",
|
|
598751
598788
|
size: m2.parameterSize || "",
|
|
@@ -598758,10 +598795,10 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
598758
598795
|
}
|
|
598759
598796
|
}
|
|
598760
598797
|
}
|
|
598761
|
-
const cachePath2 =
|
|
598762
|
-
if (
|
|
598798
|
+
const cachePath2 = join179(nexusDir, "peer-models-cache.json");
|
|
598799
|
+
if (existsSync164(cachePath2)) {
|
|
598763
598800
|
try {
|
|
598764
|
-
const cache8 = JSON.parse(
|
|
598801
|
+
const cache8 = JSON.parse(readFileSync134(cachePath2, "utf8"));
|
|
598765
598802
|
if (cache8.peerId === peerId && cache8.models?.length > 0) {
|
|
598766
598803
|
const age = Date.now() - new Date(cache8.cachedAt).getTime();
|
|
598767
598804
|
if (age < 5 * 60 * 1e3) {
|
|
@@ -598873,10 +598910,10 @@ async function fetchPeerModels(peerId, authKey) {
|
|
|
598873
598910
|
} catch {
|
|
598874
598911
|
}
|
|
598875
598912
|
if (isLocalPeer) {
|
|
598876
|
-
const pricingPath =
|
|
598877
|
-
if (
|
|
598913
|
+
const pricingPath = join179(nexusDir, "pricing.json");
|
|
598914
|
+
if (existsSync164(pricingPath)) {
|
|
598878
598915
|
try {
|
|
598879
|
-
const pricing = JSON.parse(
|
|
598916
|
+
const pricing = JSON.parse(readFileSync134(pricingPath, "utf8"));
|
|
598880
598917
|
return (pricing.models || []).map((m2) => ({
|
|
598881
598918
|
name: m2.model || "unknown",
|
|
598882
598919
|
size: m2.parameterSize || "",
|
|
@@ -632332,9 +632369,9 @@ async function ensureVoiceDeps(ctx3) {
|
|
|
632332
632369
|
}
|
|
632333
632370
|
if (typeof mod3.getVenvPython === "function") {
|
|
632334
632371
|
const { dirname: dirname54 } = await import("node:path");
|
|
632335
|
-
const { existsSync:
|
|
632372
|
+
const { existsSync: existsSync164 } = await import("node:fs");
|
|
632336
632373
|
const venvPy = mod3.getVenvPython();
|
|
632337
|
-
if (
|
|
632374
|
+
if (existsSync164(venvPy)) {
|
|
632338
632375
|
process.env.TRANSCRIBE_PYTHON = venvPy;
|
|
632339
632376
|
const venvBin = dirname54(venvPy);
|
|
632340
632377
|
const sep6 = process.platform === "win32" ? ";" : ":";
|
|
@@ -633220,10 +633257,10 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
633220
633257
|
if (!key) {
|
|
633221
633258
|
try {
|
|
633222
633259
|
const { homedir: homedir62 } = await import("node:os");
|
|
633223
|
-
const { readFileSync:
|
|
633224
|
-
const { join:
|
|
633225
|
-
const p2 =
|
|
633226
|
-
if (
|
|
633260
|
+
const { readFileSync: readFileSync134, existsSync: existsSync164 } = await import("node:fs");
|
|
633261
|
+
const { join: join179 } = await import("node:path");
|
|
633262
|
+
const p2 = join179(homedir62(), ".omnius", "api.key");
|
|
633263
|
+
if (existsSync164(p2)) key = readFileSync134(p2, "utf8").trim();
|
|
633227
633264
|
} catch {
|
|
633228
633265
|
}
|
|
633229
633266
|
}
|
|
@@ -633266,13 +633303,13 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
633266
633303
|
try {
|
|
633267
633304
|
const { randomBytes: randomBytes30 } = await import("node:crypto");
|
|
633268
633305
|
const { homedir: homedir62 } = await import("node:os");
|
|
633269
|
-
const { mkdirSync:
|
|
633270
|
-
const { join:
|
|
633306
|
+
const { mkdirSync: mkdirSync106, writeFileSync: writeFileSync91 } = await import("node:fs");
|
|
633307
|
+
const { join: join179 } = await import("node:path");
|
|
633271
633308
|
const newKey = randomBytes30(16).toString("hex");
|
|
633272
633309
|
process.env["OMNIUS_API_KEY"] = newKey;
|
|
633273
|
-
const dir =
|
|
633274
|
-
|
|
633275
|
-
|
|
633310
|
+
const dir = join179(homedir62(), ".omnius");
|
|
633311
|
+
mkdirSync106(dir, { recursive: true });
|
|
633312
|
+
writeFileSync91(join179(dir, "api.key"), newKey + "\n", "utf8");
|
|
633276
633313
|
renderInfo(`New API key: ${c3.bold(c3.yellow(newKey))}`);
|
|
633277
633314
|
renderInfo(
|
|
633278
633315
|
"Restart the daemon to apply if needed. Use /access any to restart quickly."
|
|
@@ -633543,11 +633580,11 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
633543
633580
|
);
|
|
633544
633581
|
try {
|
|
633545
633582
|
const { homedir: homedir63 } = await import("node:os");
|
|
633546
|
-
const { mkdirSync:
|
|
633547
|
-
const { join:
|
|
633548
|
-
const dir =
|
|
633549
|
-
|
|
633550
|
-
|
|
633583
|
+
const { mkdirSync: mkdirSync107, writeFileSync: writeFileSync92 } = await import("node:fs");
|
|
633584
|
+
const { join: join180 } = await import("node:path");
|
|
633585
|
+
const dir = join180(homedir63(), ".omnius");
|
|
633586
|
+
mkdirSync107(dir, { recursive: true });
|
|
633587
|
+
writeFileSync92(join180(dir, "api.key"), apiKey + "\n", "utf8");
|
|
633551
633588
|
} catch {
|
|
633552
633589
|
}
|
|
633553
633590
|
}
|
|
@@ -633559,11 +633596,11 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
633559
633596
|
const port2 = parseInt(process.env["OMNIUS_PORT"] || "11435", 10);
|
|
633560
633597
|
try {
|
|
633561
633598
|
const { homedir: homedir63 } = await import("node:os");
|
|
633562
|
-
const { mkdirSync:
|
|
633563
|
-
const { join:
|
|
633564
|
-
const dir =
|
|
633565
|
-
|
|
633566
|
-
|
|
633599
|
+
const { mkdirSync: mkdirSync107, writeFileSync: writeFileSync92 } = await import("node:fs");
|
|
633600
|
+
const { join: join180 } = await import("node:path");
|
|
633601
|
+
const dir = join180(homedir63(), ".omnius");
|
|
633602
|
+
mkdirSync107(dir, { recursive: true });
|
|
633603
|
+
writeFileSync92(join180(dir, "access"), `${val2}
|
|
633567
633604
|
`, "utf8");
|
|
633568
633605
|
} catch {
|
|
633569
633606
|
}
|
|
@@ -633663,11 +633700,11 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
633663
633700
|
);
|
|
633664
633701
|
try {
|
|
633665
633702
|
const { homedir: homedir63 } = await import("node:os");
|
|
633666
|
-
const { mkdirSync:
|
|
633667
|
-
const { join:
|
|
633668
|
-
const dir =
|
|
633669
|
-
|
|
633670
|
-
|
|
633703
|
+
const { mkdirSync: mkdirSync107, writeFileSync: writeFileSync92 } = await import("node:fs");
|
|
633704
|
+
const { join: join180 } = await import("node:path");
|
|
633705
|
+
const dir = join180(homedir63(), ".omnius");
|
|
633706
|
+
mkdirSync107(dir, { recursive: true });
|
|
633707
|
+
writeFileSync92(join180(dir, "api.key"), apiKey + "\n", "utf8");
|
|
633671
633708
|
} catch {
|
|
633672
633709
|
}
|
|
633673
633710
|
}
|
|
@@ -633678,12 +633715,12 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
633678
633715
|
}
|
|
633679
633716
|
const port = parseInt(process.env["OMNIUS_PORT"] || "11435", 10);
|
|
633680
633717
|
const { homedir: homedir62 } = await import("node:os");
|
|
633681
|
-
const { mkdirSync:
|
|
633682
|
-
const { join:
|
|
633718
|
+
const { mkdirSync: mkdirSync106, writeFileSync: writeFileSync91 } = await import("node:fs");
|
|
633719
|
+
const { join: join179 } = await import("node:path");
|
|
633683
633720
|
try {
|
|
633684
|
-
const dir =
|
|
633685
|
-
|
|
633686
|
-
|
|
633721
|
+
const dir = join179(homedir62(), ".omnius");
|
|
633722
|
+
mkdirSync106(dir, { recursive: true });
|
|
633723
|
+
writeFileSync91(join179(dir, "access"), `${val}
|
|
633687
633724
|
`, "utf8");
|
|
633688
633725
|
} catch (e2) {
|
|
633689
633726
|
renderWarning(
|
|
@@ -642522,7 +642559,7 @@ async function handleVoiceMenu(ctx3, save3, hasLocal) {
|
|
|
642522
642559
|
const { basename: basename39, join: pathJoin } = await import("node:path");
|
|
642523
642560
|
const {
|
|
642524
642561
|
copyFileSync: copyFileSync8,
|
|
642525
|
-
mkdirSync:
|
|
642562
|
+
mkdirSync: mkdirSync106,
|
|
642526
642563
|
existsSync: exists2
|
|
642527
642564
|
} = await import("node:fs");
|
|
642528
642565
|
const { homedir: homedir62 } = await import("node:os");
|
|
@@ -642537,7 +642574,7 @@ async function handleVoiceMenu(ctx3, save3, hasLocal) {
|
|
|
642537
642574
|
"models",
|
|
642538
642575
|
modelName
|
|
642539
642576
|
);
|
|
642540
|
-
if (!exists2(destDir))
|
|
642577
|
+
if (!exists2(destDir)) mkdirSync106(destDir, { recursive: true });
|
|
642541
642578
|
copyFileSync8(onnxDrop.path, pathJoin(destDir, "model.onnx"));
|
|
642542
642579
|
copyFileSync8(jsonDrop.path, pathJoin(destDir, "config.json"));
|
|
642543
642580
|
const { registerCustomOnnxModel: registerCustomOnnxModel2 } = await Promise.resolve().then(() => (init_voice(), voice_exports));
|
|
@@ -644316,13 +644353,13 @@ async function handleSponsoredEndpoint(ctx3, local) {
|
|
|
644316
644353
|
sponsors.push(...verified);
|
|
644317
644354
|
if (verified.length > 0) {
|
|
644318
644355
|
try {
|
|
644319
|
-
const { mkdirSync:
|
|
644320
|
-
|
|
644356
|
+
const { mkdirSync: mkdirSync106, writeFileSync: writeFileSync91 } = __require("node:fs");
|
|
644357
|
+
mkdirSync106(sponsorDir2, { recursive: true });
|
|
644321
644358
|
const cached = verified.map((s2) => ({
|
|
644322
644359
|
...s2,
|
|
644323
644360
|
lastVerified: Date.now()
|
|
644324
644361
|
}));
|
|
644325
|
-
|
|
644362
|
+
writeFileSync91(knownFile, JSON.stringify(cached, null, 2));
|
|
644326
644363
|
} catch {
|
|
644327
644364
|
}
|
|
644328
644365
|
}
|
|
@@ -644526,16 +644563,16 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels
|
|
|
644526
644563
|
}
|
|
644527
644564
|
if (models.length > 0) {
|
|
644528
644565
|
try {
|
|
644529
|
-
const { writeFileSync:
|
|
644530
|
-
const { join:
|
|
644531
|
-
const cachePath2 =
|
|
644566
|
+
const { writeFileSync: writeFileSync91, mkdirSync: mkdirSync106 } = await import("node:fs");
|
|
644567
|
+
const { join: join179, dirname: dirname54 } = await import("node:path");
|
|
644568
|
+
const cachePath2 = join179(
|
|
644532
644569
|
ctx3.repoRoot || process.cwd(),
|
|
644533
644570
|
".omnius",
|
|
644534
644571
|
"nexus",
|
|
644535
644572
|
"peer-models-cache.json"
|
|
644536
644573
|
);
|
|
644537
|
-
|
|
644538
|
-
|
|
644574
|
+
mkdirSync106(dirname54(cachePath2), { recursive: true });
|
|
644575
|
+
writeFileSync91(
|
|
644539
644576
|
cachePath2,
|
|
644540
644577
|
JSON.stringify(
|
|
644541
644578
|
{
|
|
@@ -644609,16 +644646,16 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels
|
|
|
644609
644646
|
"Live model probe failed; using sponsor directory model advertisement."
|
|
644610
644647
|
);
|
|
644611
644648
|
try {
|
|
644612
|
-
const { writeFileSync:
|
|
644613
|
-
const { join:
|
|
644614
|
-
const cachePath2 =
|
|
644649
|
+
const { writeFileSync: writeFileSync91, mkdirSync: mkdirSync106 } = await import("node:fs");
|
|
644650
|
+
const { join: join179, dirname: dirname54 } = await import("node:path");
|
|
644651
|
+
const cachePath2 = join179(
|
|
644615
644652
|
ctx3.repoRoot || process.cwd(),
|
|
644616
644653
|
".omnius",
|
|
644617
644654
|
"nexus",
|
|
644618
644655
|
"peer-models-cache.json"
|
|
644619
644656
|
);
|
|
644620
|
-
|
|
644621
|
-
|
|
644657
|
+
mkdirSync106(dirname54(cachePath2), { recursive: true });
|
|
644658
|
+
writeFileSync91(
|
|
644622
644659
|
cachePath2,
|
|
644623
644660
|
JSON.stringify(
|
|
644624
644661
|
{
|
|
@@ -645632,17 +645669,17 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
645632
645669
|
try {
|
|
645633
645670
|
const { createRequire: createRequire11 } = await import("node:module");
|
|
645634
645671
|
const { fileURLToPath: fileURLToPath23 } = await import("node:url");
|
|
645635
|
-
const { dirname: dirname54, join:
|
|
645636
|
-
const { existsSync:
|
|
645672
|
+
const { dirname: dirname54, join: join179 } = await import("node:path");
|
|
645673
|
+
const { existsSync: existsSync164 } = await import("node:fs");
|
|
645637
645674
|
const req3 = createRequire11(import.meta.url);
|
|
645638
645675
|
const thisDir = dirname54(fileURLToPath23(import.meta.url));
|
|
645639
645676
|
const candidates = [
|
|
645640
|
-
|
|
645641
|
-
|
|
645642
|
-
|
|
645677
|
+
join179(thisDir, "..", "package.json"),
|
|
645678
|
+
join179(thisDir, "..", "..", "package.json"),
|
|
645679
|
+
join179(thisDir, "..", "..", "..", "package.json")
|
|
645643
645680
|
];
|
|
645644
645681
|
for (const pkgPath of candidates) {
|
|
645645
|
-
if (
|
|
645682
|
+
if (existsSync164(pkgPath)) {
|
|
645646
645683
|
const pkg = req3(pkgPath);
|
|
645647
645684
|
if (pkg.name === "omnius" || pkg.name === "@omnius/cli") {
|
|
645648
645685
|
currentVersion = pkg.version ?? "0.0.0";
|
|
@@ -647316,13 +647353,13 @@ var init_commands = __esm({
|
|
|
647316
647353
|
try {
|
|
647317
647354
|
const { randomBytes: randomBytes30 } = await import("node:crypto");
|
|
647318
647355
|
const { homedir: homedir62 } = await import("node:os");
|
|
647319
|
-
const { mkdirSync:
|
|
647320
|
-
const { join:
|
|
647356
|
+
const { mkdirSync: mkdirSync106, writeFileSync: writeFileSync91 } = await import("node:fs");
|
|
647357
|
+
const { join: join179 } = await import("node:path");
|
|
647321
647358
|
const apiKey = randomBytes30(16).toString("hex");
|
|
647322
647359
|
process.env["OMNIUS_API_KEY"] = apiKey;
|
|
647323
|
-
const dir =
|
|
647324
|
-
|
|
647325
|
-
|
|
647360
|
+
const dir = join179(homedir62(), ".omnius");
|
|
647361
|
+
mkdirSync106(dir, { recursive: true });
|
|
647362
|
+
writeFileSync91(join179(dir, "api.key"), apiKey + "\n", "utf8");
|
|
647326
647363
|
renderInfo(`Generated API key: ${c3.bold(c3.yellow(apiKey))}`);
|
|
647327
647364
|
renderInfo(
|
|
647328
647365
|
"Use Authorization: Bearer <key> or click 'key' in the Web UI header to paste it."
|
|
@@ -647341,11 +647378,11 @@ var init_commands = __esm({
|
|
|
647341
647378
|
const port = parseInt(process.env["OMNIUS_PORT"] || "11435", 10);
|
|
647342
647379
|
try {
|
|
647343
647380
|
const { homedir: homedir62 } = await import("node:os");
|
|
647344
|
-
const { mkdirSync:
|
|
647345
|
-
const { join:
|
|
647346
|
-
const dir =
|
|
647347
|
-
|
|
647348
|
-
|
|
647381
|
+
const { mkdirSync: mkdirSync106, writeFileSync: writeFileSync91 } = await import("node:fs");
|
|
647382
|
+
const { join: join179 } = await import("node:path");
|
|
647383
|
+
const dir = join179(homedir62(), ".omnius");
|
|
647384
|
+
mkdirSync106(dir, { recursive: true });
|
|
647385
|
+
writeFileSync91(join179(dir, "access"), `${val}
|
|
647349
647386
|
`, "utf8");
|
|
647350
647387
|
} catch {
|
|
647351
647388
|
}
|
|
@@ -682548,6 +682585,343 @@ var init_direct_tool_registry = __esm({
|
|
|
682548
682585
|
}
|
|
682549
682586
|
});
|
|
682550
682587
|
|
|
682588
|
+
// packages/cli/src/api/external-tool-registry.ts
|
|
682589
|
+
import { existsSync as existsSync152, mkdirSync as mkdirSync95, readFileSync as readFileSync124, writeFileSync as writeFileSync81, renameSync as renameSync14 } from "node:fs";
|
|
682590
|
+
import { join as join163 } from "node:path";
|
|
682591
|
+
function externalToolStorePath(workingDir) {
|
|
682592
|
+
return join163(workingDir, ".omnius", "external-tools.json");
|
|
682593
|
+
}
|
|
682594
|
+
function loadExternalTools(workingDir) {
|
|
682595
|
+
const path12 = externalToolStorePath(workingDir);
|
|
682596
|
+
if (!existsSync152(path12)) return [];
|
|
682597
|
+
try {
|
|
682598
|
+
const parsed = JSON.parse(readFileSync124(path12, "utf-8"));
|
|
682599
|
+
if (!parsed || !Array.isArray(parsed.tools)) return [];
|
|
682600
|
+
return parsed.tools.filter(
|
|
682601
|
+
(t2) => t2 && typeof t2.name === "string" && t2.transport != null
|
|
682602
|
+
);
|
|
682603
|
+
} catch {
|
|
682604
|
+
return [];
|
|
682605
|
+
}
|
|
682606
|
+
}
|
|
682607
|
+
function persist3(workingDir, tools) {
|
|
682608
|
+
const path12 = externalToolStorePath(workingDir);
|
|
682609
|
+
mkdirSync95(join163(workingDir, ".omnius"), { recursive: true });
|
|
682610
|
+
const file = { version: STORE_VERSION, tools };
|
|
682611
|
+
const tmp = `${path12}.tmp`;
|
|
682612
|
+
writeFileSync81(tmp, JSON.stringify(file, null, 2), { mode: 384 });
|
|
682613
|
+
renameSync14(tmp, path12);
|
|
682614
|
+
}
|
|
682615
|
+
function validateManifest2(input, existing) {
|
|
682616
|
+
if (!input || typeof input !== "object") {
|
|
682617
|
+
return { ok: false, error: "Body must be a JSON object." };
|
|
682618
|
+
}
|
|
682619
|
+
const m2 = input;
|
|
682620
|
+
const name10 = typeof m2["name"] === "string" ? m2["name"].trim() : "";
|
|
682621
|
+
if (!NAME_RE.test(name10)) {
|
|
682622
|
+
return {
|
|
682623
|
+
ok: false,
|
|
682624
|
+
error: "`name` must match /^[a-zA-Z][a-zA-Z0-9_]{0,63}$/ (letters, digits, underscore; start with a letter)."
|
|
682625
|
+
};
|
|
682626
|
+
}
|
|
682627
|
+
const description = typeof m2["description"] === "string" ? m2["description"].trim() : "";
|
|
682628
|
+
if (!description) {
|
|
682629
|
+
return { ok: false, error: "`description` is required and must be non-empty." };
|
|
682630
|
+
}
|
|
682631
|
+
const parametersRaw = m2["parameters"];
|
|
682632
|
+
let parameters;
|
|
682633
|
+
if (parametersRaw == null) {
|
|
682634
|
+
parameters = { type: "object", properties: {} };
|
|
682635
|
+
} else if (typeof parametersRaw === "object" && !Array.isArray(parametersRaw)) {
|
|
682636
|
+
parameters = parametersRaw;
|
|
682637
|
+
if (parameters["type"] !== "object") {
|
|
682638
|
+
return {
|
|
682639
|
+
ok: false,
|
|
682640
|
+
error: '`parameters` must be a JSON schema object with `type: "object"`.'
|
|
682641
|
+
};
|
|
682642
|
+
}
|
|
682643
|
+
} else {
|
|
682644
|
+
return { ok: false, error: "`parameters` must be a JSON schema object." };
|
|
682645
|
+
}
|
|
682646
|
+
const transportResult = validateTransport(m2["transport"]);
|
|
682647
|
+
if (!transportResult.ok) return { ok: false, error: transportResult.error };
|
|
682648
|
+
const transport = transportResult.transport;
|
|
682649
|
+
const security = normalizeSecurity(m2["security"], transport);
|
|
682650
|
+
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
682651
|
+
const record = {
|
|
682652
|
+
name: name10,
|
|
682653
|
+
description,
|
|
682654
|
+
parameters,
|
|
682655
|
+
security,
|
|
682656
|
+
transport,
|
|
682657
|
+
source: "external",
|
|
682658
|
+
created_at: existing?.created_at ?? now2,
|
|
682659
|
+
updated_at: now2
|
|
682660
|
+
};
|
|
682661
|
+
return { ok: true, record };
|
|
682662
|
+
}
|
|
682663
|
+
function validateTransport(raw) {
|
|
682664
|
+
if (!raw || typeof raw !== "object") {
|
|
682665
|
+
return {
|
|
682666
|
+
ok: false,
|
|
682667
|
+
error: '`transport` is required: {type:"http",callback_url} or {type:"mcp",server,tool}.'
|
|
682668
|
+
};
|
|
682669
|
+
}
|
|
682670
|
+
const t2 = raw;
|
|
682671
|
+
if (t2["type"] === "http") {
|
|
682672
|
+
const url = typeof t2["callback_url"] === "string" ? t2["callback_url"].trim() : "";
|
|
682673
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
682674
|
+
return { ok: false, error: "http transport requires an absolute http(s) `callback_url`." };
|
|
682675
|
+
}
|
|
682676
|
+
const transport = { type: "http", callback_url: url };
|
|
682677
|
+
if (typeof t2["auth_header"] === "string") transport.auth_header = t2["auth_header"];
|
|
682678
|
+
if (t2["headers"] && typeof t2["headers"] === "object") {
|
|
682679
|
+
transport.headers = t2["headers"];
|
|
682680
|
+
}
|
|
682681
|
+
if (typeof t2["timeout_ms"] === "number") transport.timeout_ms = t2["timeout_ms"];
|
|
682682
|
+
if (typeof t2["result_path"] === "string") transport.result_path = t2["result_path"].trim();
|
|
682683
|
+
return { ok: true, transport };
|
|
682684
|
+
}
|
|
682685
|
+
if (t2["type"] === "mcp") {
|
|
682686
|
+
const server2 = typeof t2["server"] === "string" ? t2["server"].trim() : "";
|
|
682687
|
+
const tool = typeof t2["tool"] === "string" ? t2["tool"].trim() : "";
|
|
682688
|
+
if (!server2 || !tool) {
|
|
682689
|
+
return { ok: false, error: "mcp transport requires non-empty `server` and `tool`." };
|
|
682690
|
+
}
|
|
682691
|
+
const transport = { type: "mcp", server: server2, tool };
|
|
682692
|
+
if (t2["connect"] && typeof t2["connect"] === "object") {
|
|
682693
|
+
transport.connect = t2["connect"];
|
|
682694
|
+
}
|
|
682695
|
+
return { ok: true, transport };
|
|
682696
|
+
}
|
|
682697
|
+
return { ok: false, error: '`transport.type` must be "http" or "mcp".' };
|
|
682698
|
+
}
|
|
682699
|
+
function normalizeSecurity(raw, transport) {
|
|
682700
|
+
const s2 = raw && typeof raw === "object" ? raw : {};
|
|
682701
|
+
const categories = Array.isArray(s2["categories"]) ? s2["categories"].filter((c8) => typeof c8 === "string") : ["network"];
|
|
682702
|
+
const risk = ["low", "medium", "high", "critical"].includes(s2["risk"]) ? s2["risk"] : "medium";
|
|
682703
|
+
const requires_scope = ["read", "run", "admin"].includes(s2["requires_scope"]) ? s2["requires_scope"] : "run";
|
|
682704
|
+
const off_device_allowed = s2["off_device_allowed"] === true;
|
|
682705
|
+
const rationale = typeof s2["rationale"] === "string" && s2["rationale"].trim() ? s2["rationale"].trim() : transport.type === "http" ? `External HTTP tool; Omnius forwards args to ${transport.callback_url}.` : `External MCP tool; proxies to ${transport.server}:${transport.tool}.`;
|
|
682706
|
+
return { categories: categories.length ? categories : ["network"], risk, requires_scope, off_device_allowed, rationale };
|
|
682707
|
+
}
|
|
682708
|
+
function upsertExternalTool(workingDir, record) {
|
|
682709
|
+
const tools = loadExternalTools(workingDir);
|
|
682710
|
+
const idx = tools.findIndex((t2) => t2.name === record.name);
|
|
682711
|
+
const replaced = idx >= 0;
|
|
682712
|
+
if (replaced) tools[idx] = record;
|
|
682713
|
+
else tools.push(record);
|
|
682714
|
+
tools.sort((a2, b) => a2.name.localeCompare(b.name));
|
|
682715
|
+
persist3(workingDir, tools);
|
|
682716
|
+
return { replaced };
|
|
682717
|
+
}
|
|
682718
|
+
function removeExternalTool(workingDir, name10) {
|
|
682719
|
+
const tools = loadExternalTools(workingDir);
|
|
682720
|
+
const next = tools.filter((t2) => t2.name !== name10);
|
|
682721
|
+
if (next.length === tools.length) return false;
|
|
682722
|
+
persist3(workingDir, next);
|
|
682723
|
+
return true;
|
|
682724
|
+
}
|
|
682725
|
+
function getExternalTool(workingDir, name10) {
|
|
682726
|
+
return loadExternalTools(workingDir).find((t2) => t2.name === name10) ?? null;
|
|
682727
|
+
}
|
|
682728
|
+
var STORE_VERSION, NAME_RE;
|
|
682729
|
+
var init_external_tool_registry = __esm({
|
|
682730
|
+
"packages/cli/src/api/external-tool-registry.ts"() {
|
|
682731
|
+
"use strict";
|
|
682732
|
+
STORE_VERSION = 1;
|
|
682733
|
+
NAME_RE = /^[a-zA-Z][a-zA-Z0-9_]{0,63}$/;
|
|
682734
|
+
}
|
|
682735
|
+
});
|
|
682736
|
+
|
|
682737
|
+
// packages/cli/src/api/external-tool-dispatch.ts
|
|
682738
|
+
function clampTimeout(ms, def) {
|
|
682739
|
+
if (typeof ms !== "number" || !Number.isFinite(ms)) return def;
|
|
682740
|
+
return Math.min(Math.max(Math.round(ms), 1e3), 12e4);
|
|
682741
|
+
}
|
|
682742
|
+
function readPath(obj, path12) {
|
|
682743
|
+
let cur = obj;
|
|
682744
|
+
for (const seg of path12.split(".")) {
|
|
682745
|
+
if (cur == null || typeof cur !== "object") return void 0;
|
|
682746
|
+
cur = cur[seg];
|
|
682747
|
+
}
|
|
682748
|
+
return cur;
|
|
682749
|
+
}
|
|
682750
|
+
async function dispatchHttp(transport, record, args, sessionId, fetchImpl) {
|
|
682751
|
+
const start2 = performance.now();
|
|
682752
|
+
const controller = new AbortController();
|
|
682753
|
+
const timeout2 = clampTimeout(transport.timeout_ms, 3e4);
|
|
682754
|
+
const timer = setTimeout(() => controller.abort(), timeout2);
|
|
682755
|
+
try {
|
|
682756
|
+
const headers = {
|
|
682757
|
+
"content-type": "application/json",
|
|
682758
|
+
...transport.headers ?? {}
|
|
682759
|
+
};
|
|
682760
|
+
if (transport.auth_header) headers["authorization"] = transport.auth_header;
|
|
682761
|
+
const resp = await fetchImpl(transport.callback_url, {
|
|
682762
|
+
method: "POST",
|
|
682763
|
+
headers,
|
|
682764
|
+
body: JSON.stringify({ name: record.name, args, session_id: sessionId }),
|
|
682765
|
+
signal: controller.signal
|
|
682766
|
+
});
|
|
682767
|
+
const text2 = await resp.text();
|
|
682768
|
+
if (!resp.ok) {
|
|
682769
|
+
return {
|
|
682770
|
+
success: false,
|
|
682771
|
+
output: "",
|
|
682772
|
+
error: `External tool HTTP ${resp.status}: ${text2.slice(0, 500)}`,
|
|
682773
|
+
durationMs: performance.now() - start2,
|
|
682774
|
+
transport: "http"
|
|
682775
|
+
};
|
|
682776
|
+
}
|
|
682777
|
+
let output = text2;
|
|
682778
|
+
if (transport.result_path) {
|
|
682779
|
+
try {
|
|
682780
|
+
const json = JSON.parse(text2);
|
|
682781
|
+
const extracted = readPath(json, transport.result_path);
|
|
682782
|
+
output = typeof extracted === "string" ? extracted : JSON.stringify(extracted ?? null);
|
|
682783
|
+
} catch {
|
|
682784
|
+
}
|
|
682785
|
+
}
|
|
682786
|
+
return {
|
|
682787
|
+
success: true,
|
|
682788
|
+
output,
|
|
682789
|
+
durationMs: performance.now() - start2,
|
|
682790
|
+
transport: "http"
|
|
682791
|
+
};
|
|
682792
|
+
} catch (err) {
|
|
682793
|
+
const aborted = err instanceof Error && err.name === "AbortError";
|
|
682794
|
+
return {
|
|
682795
|
+
success: false,
|
|
682796
|
+
output: "",
|
|
682797
|
+
error: aborted ? `External tool call timed out after ${timeout2}ms` : `External tool call failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
682798
|
+
durationMs: performance.now() - start2,
|
|
682799
|
+
transport: "http"
|
|
682800
|
+
};
|
|
682801
|
+
} finally {
|
|
682802
|
+
clearTimeout(timer);
|
|
682803
|
+
}
|
|
682804
|
+
}
|
|
682805
|
+
async function dispatchMcp(transport, args, workingDir, deps) {
|
|
682806
|
+
const start2 = performance.now();
|
|
682807
|
+
const mgr = await deps.getMcpManager(workingDir);
|
|
682808
|
+
if (!mgr) {
|
|
682809
|
+
return {
|
|
682810
|
+
success: false,
|
|
682811
|
+
output: "",
|
|
682812
|
+
error: "MCP module unavailable — cannot dispatch mcp transport.",
|
|
682813
|
+
durationMs: performance.now() - start2,
|
|
682814
|
+
transport: "mcp"
|
|
682815
|
+
};
|
|
682816
|
+
}
|
|
682817
|
+
const client = mgr.clients?.get(transport.server);
|
|
682818
|
+
if (!client) {
|
|
682819
|
+
return {
|
|
682820
|
+
success: false,
|
|
682821
|
+
output: "",
|
|
682822
|
+
error: `MCP server '${transport.server}' is not connected.`,
|
|
682823
|
+
durationMs: performance.now() - start2,
|
|
682824
|
+
transport: "mcp"
|
|
682825
|
+
};
|
|
682826
|
+
}
|
|
682827
|
+
try {
|
|
682828
|
+
const result = await client.callTool(transport.tool, args);
|
|
682829
|
+
return {
|
|
682830
|
+
success: true,
|
|
682831
|
+
output: typeof result === "string" ? result : JSON.stringify(result),
|
|
682832
|
+
durationMs: performance.now() - start2,
|
|
682833
|
+
transport: "mcp"
|
|
682834
|
+
};
|
|
682835
|
+
} catch (err) {
|
|
682836
|
+
return {
|
|
682837
|
+
success: false,
|
|
682838
|
+
output: "",
|
|
682839
|
+
error: `MCP tool '${transport.server}:${transport.tool}' failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
682840
|
+
durationMs: performance.now() - start2,
|
|
682841
|
+
transport: "mcp"
|
|
682842
|
+
};
|
|
682843
|
+
}
|
|
682844
|
+
}
|
|
682845
|
+
async function executeExternalTool(record, args, workingDir, sessionId, deps) {
|
|
682846
|
+
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
682847
|
+
if (record.transport.type === "http") {
|
|
682848
|
+
return dispatchHttp(record.transport, record, args, sessionId, fetchImpl);
|
|
682849
|
+
}
|
|
682850
|
+
return dispatchMcp(record.transport, args, workingDir, deps);
|
|
682851
|
+
}
|
|
682852
|
+
var init_external_tool_dispatch = __esm({
|
|
682853
|
+
"packages/cli/src/api/external-tool-dispatch.ts"() {
|
|
682854
|
+
"use strict";
|
|
682855
|
+
}
|
|
682856
|
+
});
|
|
682857
|
+
|
|
682858
|
+
// packages/cli/src/api/external-tool-eval.ts
|
|
682859
|
+
function scoreCase(expect, result) {
|
|
682860
|
+
const failures = [];
|
|
682861
|
+
if (!expect) {
|
|
682862
|
+
if (!result.success) failures.push(`expected success but tool failed: ${result.error ?? "unknown"}`);
|
|
682863
|
+
return failures;
|
|
682864
|
+
}
|
|
682865
|
+
if (typeof expect.success === "boolean" && result.success !== expect.success) {
|
|
682866
|
+
failures.push(`expected success=${expect.success} but got ${result.success}${result.error ? ` (${result.error})` : ""}`);
|
|
682867
|
+
}
|
|
682868
|
+
if (typeof expect.output_contains === "string" && !result.output.includes(expect.output_contains)) {
|
|
682869
|
+
failures.push(`output did not contain ${JSON.stringify(expect.output_contains)}`);
|
|
682870
|
+
}
|
|
682871
|
+
if (typeof expect.output_equals === "string" && result.output.trim() !== expect.output_equals.trim()) {
|
|
682872
|
+
failures.push(`output did not equal ${JSON.stringify(expect.output_equals)}`);
|
|
682873
|
+
}
|
|
682874
|
+
if (typeof expect.output_matches === "string") {
|
|
682875
|
+
let re = null;
|
|
682876
|
+
try {
|
|
682877
|
+
re = new RegExp(expect.output_matches);
|
|
682878
|
+
} catch {
|
|
682879
|
+
failures.push(`invalid output_matches regex ${JSON.stringify(expect.output_matches)}`);
|
|
682880
|
+
}
|
|
682881
|
+
if (re && !re.test(result.output)) {
|
|
682882
|
+
failures.push(`output did not match /${expect.output_matches}/`);
|
|
682883
|
+
}
|
|
682884
|
+
}
|
|
682885
|
+
return failures;
|
|
682886
|
+
}
|
|
682887
|
+
async function evaluateExternalTool(record, cases, workingDir, deps) {
|
|
682888
|
+
const start2 = performance.now();
|
|
682889
|
+
const results = [];
|
|
682890
|
+
for (let i2 = 0; i2 < cases.length; i2++) {
|
|
682891
|
+
const c8 = cases[i2];
|
|
682892
|
+
const result = await executeExternalTool(
|
|
682893
|
+
record,
|
|
682894
|
+
c8.args ?? {},
|
|
682895
|
+
workingDir,
|
|
682896
|
+
null,
|
|
682897
|
+
deps
|
|
682898
|
+
);
|
|
682899
|
+
const failures = scoreCase(c8.expect, result);
|
|
682900
|
+
results.push({
|
|
682901
|
+
name: c8.name ?? `case_${i2 + 1}`,
|
|
682902
|
+
passed: failures.length === 0,
|
|
682903
|
+
failures,
|
|
682904
|
+
result
|
|
682905
|
+
});
|
|
682906
|
+
}
|
|
682907
|
+
const passed = results.filter((r2) => r2.passed).length;
|
|
682908
|
+
return {
|
|
682909
|
+
tool: record.name,
|
|
682910
|
+
total: results.length,
|
|
682911
|
+
passed,
|
|
682912
|
+
failed: results.length - passed,
|
|
682913
|
+
pass_rate: results.length ? passed / results.length : 0,
|
|
682914
|
+
duration_ms: performance.now() - start2,
|
|
682915
|
+
cases: results
|
|
682916
|
+
};
|
|
682917
|
+
}
|
|
682918
|
+
var init_external_tool_eval = __esm({
|
|
682919
|
+
"packages/cli/src/api/external-tool-eval.ts"() {
|
|
682920
|
+
"use strict";
|
|
682921
|
+
init_external_tool_dispatch();
|
|
682922
|
+
}
|
|
682923
|
+
});
|
|
682924
|
+
|
|
682551
682925
|
// packages/cli/src/api/aiwg.ts
|
|
682552
682926
|
var aiwg_exports = {};
|
|
682553
682927
|
__export(aiwg_exports, {
|
|
@@ -682560,19 +682934,19 @@ __export(aiwg_exports, {
|
|
|
682560
682934
|
resolveAiwgRoot: () => resolveAiwgRoot,
|
|
682561
682935
|
tryRouteAiwg: () => tryRouteAiwg
|
|
682562
682936
|
});
|
|
682563
|
-
import { existsSync as
|
|
682564
|
-
import { join as
|
|
682937
|
+
import { existsSync as existsSync153, readFileSync as readFileSync125, readdirSync as readdirSync54, statSync as statSync54 } from "node:fs";
|
|
682938
|
+
import { join as join164 } from "node:path";
|
|
682565
682939
|
import { homedir as homedir54 } from "node:os";
|
|
682566
682940
|
import { execSync as execSync58 } from "node:child_process";
|
|
682567
682941
|
function resolveAiwgRoot() {
|
|
682568
682942
|
if (_cachedAiwgRoot !== void 0) return _cachedAiwgRoot;
|
|
682569
682943
|
const envRoot = process.env["OMNIUS_AIWG_ROOT"];
|
|
682570
|
-
if (envRoot &&
|
|
682944
|
+
if (envRoot && existsSync153(join164(envRoot, "package.json"))) {
|
|
682571
682945
|
_cachedAiwgRoot = envRoot;
|
|
682572
682946
|
return envRoot;
|
|
682573
682947
|
}
|
|
682574
|
-
const shareDir =
|
|
682575
|
-
if (
|
|
682948
|
+
const shareDir = join164(homedir54(), ".local", "share", "ai-writing-guide");
|
|
682949
|
+
if (existsSync153(join164(shareDir, "agentic"))) {
|
|
682576
682950
|
_cachedAiwgRoot = shareDir;
|
|
682577
682951
|
return shareDir;
|
|
682578
682952
|
}
|
|
@@ -682582,8 +682956,8 @@ function resolveAiwgRoot() {
|
|
|
682582
682956
|
timeout: 5e3,
|
|
682583
682957
|
stdio: ["pipe", "pipe", "pipe"]
|
|
682584
682958
|
}).trim();
|
|
682585
|
-
const candidate =
|
|
682586
|
-
if (
|
|
682959
|
+
const candidate = join164(globalRoot, "aiwg");
|
|
682960
|
+
if (existsSync153(join164(candidate, "package.json"))) {
|
|
682587
682961
|
_cachedAiwgRoot = candidate;
|
|
682588
682962
|
return candidate;
|
|
682589
682963
|
}
|
|
@@ -682594,22 +682968,22 @@ function resolveAiwgRoot() {
|
|
|
682594
682968
|
"/usr/lib/node_modules/aiwg",
|
|
682595
682969
|
"/opt/homebrew/lib/node_modules/aiwg"
|
|
682596
682970
|
]) {
|
|
682597
|
-
if (
|
|
682971
|
+
if (existsSync153(join164(p2, "package.json"))) {
|
|
682598
682972
|
_cachedAiwgRoot = p2;
|
|
682599
682973
|
return p2;
|
|
682600
682974
|
}
|
|
682601
682975
|
}
|
|
682602
682976
|
const versionDirs = [
|
|
682603
|
-
|
|
682604
|
-
|
|
682977
|
+
join164(homedir54(), ".nvm", "versions", "node"),
|
|
682978
|
+
join164(homedir54(), ".local", "share", "fnm", "node-versions")
|
|
682605
682979
|
];
|
|
682606
682980
|
for (const vdir of versionDirs) {
|
|
682607
|
-
if (!
|
|
682981
|
+
if (!existsSync153(vdir)) continue;
|
|
682608
682982
|
try {
|
|
682609
682983
|
for (const ver of readdirSync54(vdir)) {
|
|
682610
682984
|
for (const prefix of ["lib/node_modules/aiwg", "installation/lib/node_modules/aiwg"]) {
|
|
682611
|
-
const cand =
|
|
682612
|
-
if (
|
|
682985
|
+
const cand = join164(vdir, ver, prefix);
|
|
682986
|
+
if (existsSync153(join164(cand, "package.json"))) {
|
|
682613
682987
|
_cachedAiwgRoot = cand;
|
|
682614
682988
|
return cand;
|
|
682615
682989
|
}
|
|
@@ -682627,11 +683001,11 @@ function resolveAiwgRoot() {
|
|
|
682627
683001
|
if (whichAiwg) {
|
|
682628
683002
|
let cur = whichAiwg;
|
|
682629
683003
|
for (let i2 = 0; i2 < 8; i2++) {
|
|
682630
|
-
cur =
|
|
682631
|
-
const pj =
|
|
682632
|
-
if (
|
|
683004
|
+
cur = join164(cur, "..");
|
|
683005
|
+
const pj = join164(cur, "package.json");
|
|
683006
|
+
if (existsSync153(pj)) {
|
|
682633
683007
|
try {
|
|
682634
|
-
const pkg = JSON.parse(
|
|
683008
|
+
const pkg = JSON.parse(readFileSync125(pj, "utf-8"));
|
|
682635
683009
|
if (pkg.name === "aiwg") {
|
|
682636
683010
|
_cachedAiwgRoot = cur;
|
|
682637
683011
|
return cur;
|
|
@@ -682653,14 +683027,14 @@ function listAiwgFrameworks() {
|
|
|
682653
683027
|
_cachedFrameworks = [];
|
|
682654
683028
|
return _cachedFrameworks;
|
|
682655
683029
|
}
|
|
682656
|
-
const frameworksDir =
|
|
682657
|
-
if (!
|
|
683030
|
+
const frameworksDir = join164(root, "agentic", "code", "frameworks");
|
|
683031
|
+
if (!existsSync153(frameworksDir)) {
|
|
682658
683032
|
_cachedFrameworks = [];
|
|
682659
683033
|
return _cachedFrameworks;
|
|
682660
683034
|
}
|
|
682661
683035
|
const out = [];
|
|
682662
683036
|
for (const name10 of readdirSync54(frameworksDir)) {
|
|
682663
|
-
const p2 =
|
|
683037
|
+
const p2 = join164(frameworksDir, name10);
|
|
682664
683038
|
try {
|
|
682665
683039
|
const st = statSync54(p2);
|
|
682666
683040
|
if (!st.isDirectory()) continue;
|
|
@@ -682688,7 +683062,7 @@ function aggregateDir(dir, depth = 0) {
|
|
|
682688
683062
|
try {
|
|
682689
683063
|
for (const e2 of readdirSync54(dir, { withFileTypes: true })) {
|
|
682690
683064
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
682691
|
-
const p2 =
|
|
683065
|
+
const p2 = join164(dir, e2.name);
|
|
682692
683066
|
if (e2.isDirectory()) {
|
|
682693
683067
|
const sub2 = aggregateDir(p2, depth + 1);
|
|
682694
683068
|
out.files += sub2.files;
|
|
@@ -682718,10 +683092,10 @@ function aggregateDir(dir, depth = 0) {
|
|
|
682718
683092
|
}
|
|
682719
683093
|
function readFirstLineDescription(dir) {
|
|
682720
683094
|
for (const candidate of ["README.md", "SKILL.md", "INDEX.md"]) {
|
|
682721
|
-
const p2 =
|
|
682722
|
-
if (!
|
|
683095
|
+
const p2 = join164(dir, candidate);
|
|
683096
|
+
if (!existsSync153(p2)) continue;
|
|
682723
683097
|
try {
|
|
682724
|
-
const txt =
|
|
683098
|
+
const txt = readFileSync125(p2, "utf-8");
|
|
682725
683099
|
const descMatch = txt.match(/^description:\s*(.+)$/m);
|
|
682726
683100
|
if (descMatch) return descMatch[1].trim().slice(0, 200);
|
|
682727
683101
|
for (const line of txt.split("\n")) {
|
|
@@ -682743,12 +683117,12 @@ function listAiwgItems() {
|
|
|
682743
683117
|
}
|
|
682744
683118
|
const out = [];
|
|
682745
683119
|
const walkRoots = [
|
|
682746
|
-
|
|
682747
|
-
|
|
682748
|
-
|
|
683120
|
+
join164(root, "agentic", "code", "frameworks"),
|
|
683121
|
+
join164(root, "agentic", "code", "addons"),
|
|
683122
|
+
join164(root, "plugins")
|
|
682749
683123
|
];
|
|
682750
683124
|
for (const wr of walkRoots) {
|
|
682751
|
-
if (!
|
|
683125
|
+
if (!existsSync153(wr)) continue;
|
|
682752
683126
|
walkForItems(wr, out, 0);
|
|
682753
683127
|
}
|
|
682754
683128
|
_cachedItems = out;
|
|
@@ -682759,7 +683133,7 @@ function walkForItems(dir, out, depth) {
|
|
|
682759
683133
|
try {
|
|
682760
683134
|
for (const e2 of readdirSync54(dir, { withFileTypes: true })) {
|
|
682761
683135
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
682762
|
-
const p2 =
|
|
683136
|
+
const p2 = join164(dir, e2.name);
|
|
682763
683137
|
if (e2.isDirectory()) {
|
|
682764
683138
|
walkForItems(p2, out, depth + 1);
|
|
682765
683139
|
} else if (e2.isFile() && e2.name.endsWith(".md")) {
|
|
@@ -682772,7 +683146,7 @@ function walkForItems(dir, out, depth) {
|
|
|
682772
683146
|
}
|
|
682773
683147
|
function parseItem(p2) {
|
|
682774
683148
|
try {
|
|
682775
|
-
const raw =
|
|
683149
|
+
const raw = readFileSync125(p2, "utf-8");
|
|
682776
683150
|
const header = raw.slice(0, 3e3);
|
|
682777
683151
|
const nameMatch = header.match(/^name:\s*(.+)$/m);
|
|
682778
683152
|
const descMatch = header.match(/^description:\s*(.+)$/m);
|
|
@@ -682810,8 +683184,8 @@ function deriveSource(p2) {
|
|
|
682810
683184
|
}
|
|
682811
683185
|
function loadAiwgItemContent(path12, maxBytes = 2e4) {
|
|
682812
683186
|
try {
|
|
682813
|
-
if (!
|
|
682814
|
-
const raw =
|
|
683187
|
+
if (!existsSync153(path12)) return null;
|
|
683188
|
+
const raw = readFileSync125(path12, "utf-8");
|
|
682815
683189
|
return raw.length > maxBytes ? raw.slice(0, maxBytes) + "\n\n...(truncated for context budget)" : raw;
|
|
682816
683190
|
} catch {
|
|
682817
683191
|
return null;
|
|
@@ -682824,14 +683198,14 @@ function listAiwgAddons() {
|
|
|
682824
683198
|
_cachedAddons = [];
|
|
682825
683199
|
return _cachedAddons;
|
|
682826
683200
|
}
|
|
682827
|
-
const addonsDir =
|
|
682828
|
-
if (!
|
|
683201
|
+
const addonsDir = join164(root, "agentic", "code", "addons");
|
|
683202
|
+
if (!existsSync153(addonsDir)) {
|
|
682829
683203
|
_cachedAddons = [];
|
|
682830
683204
|
return _cachedAddons;
|
|
682831
683205
|
}
|
|
682832
683206
|
const out = [];
|
|
682833
683207
|
for (const name10 of readdirSync54(addonsDir)) {
|
|
682834
|
-
const p2 =
|
|
683208
|
+
const p2 = join164(addonsDir, name10);
|
|
682835
683209
|
try {
|
|
682836
683210
|
const st = statSync54(p2);
|
|
682837
683211
|
if (!st.isDirectory()) continue;
|
|
@@ -683347,18 +683721,18 @@ __export(runtime_keys_exports, {
|
|
|
683347
683721
|
mintKey: () => mintKey,
|
|
683348
683722
|
revokeByPrefix: () => revokeByPrefix
|
|
683349
683723
|
});
|
|
683350
|
-
import { existsSync as
|
|
683351
|
-
import { join as
|
|
683724
|
+
import { existsSync as existsSync154, readFileSync as readFileSync126, writeFileSync as writeFileSync82, mkdirSync as mkdirSync96, chmodSync as chmodSync4 } from "node:fs";
|
|
683725
|
+
import { join as join165 } from "node:path";
|
|
683352
683726
|
import { homedir as homedir55 } from "node:os";
|
|
683353
683727
|
import { randomBytes as randomBytes27 } from "node:crypto";
|
|
683354
683728
|
function ensureDir2() {
|
|
683355
|
-
const dir =
|
|
683356
|
-
if (!
|
|
683729
|
+
const dir = join165(homedir55(), ".omnius");
|
|
683730
|
+
if (!existsSync154(dir)) mkdirSync96(dir, { recursive: true });
|
|
683357
683731
|
}
|
|
683358
683732
|
function loadAll() {
|
|
683359
|
-
if (!
|
|
683733
|
+
if (!existsSync154(KEYS_FILE)) return [];
|
|
683360
683734
|
try {
|
|
683361
|
-
const raw =
|
|
683735
|
+
const raw = readFileSync126(KEYS_FILE, "utf-8");
|
|
683362
683736
|
const parsed = JSON.parse(raw);
|
|
683363
683737
|
if (!Array.isArray(parsed)) return [];
|
|
683364
683738
|
return parsed;
|
|
@@ -683368,7 +683742,7 @@ function loadAll() {
|
|
|
683368
683742
|
}
|
|
683369
683743
|
function persistAll(records) {
|
|
683370
683744
|
ensureDir2();
|
|
683371
|
-
|
|
683745
|
+
writeFileSync82(KEYS_FILE, JSON.stringify(records, null, 2), "utf-8");
|
|
683372
683746
|
try {
|
|
683373
683747
|
chmodSync4(KEYS_FILE, 384);
|
|
683374
683748
|
} catch {
|
|
@@ -683433,7 +683807,7 @@ var KEYS_FILE;
|
|
|
683433
683807
|
var init_runtime_keys = __esm({
|
|
683434
683808
|
"packages/cli/src/api/runtime-keys.ts"() {
|
|
683435
683809
|
"use strict";
|
|
683436
|
-
KEYS_FILE =
|
|
683810
|
+
KEYS_FILE = join165(homedir55(), ".omnius", "keys.json");
|
|
683437
683811
|
}
|
|
683438
683812
|
});
|
|
683439
683813
|
|
|
@@ -683444,20 +683818,20 @@ __export(tor_fallback_exports, {
|
|
|
683444
683818
|
torIsReachable: () => torIsReachable,
|
|
683445
683819
|
tunnelViaTor: () => tunnelViaTor
|
|
683446
683820
|
});
|
|
683447
|
-
import { existsSync as
|
|
683821
|
+
import { existsSync as existsSync155, readFileSync as readFileSync127 } from "node:fs";
|
|
683448
683822
|
import { homedir as homedir56 } from "node:os";
|
|
683449
|
-
import { join as
|
|
683823
|
+
import { join as join166 } from "node:path";
|
|
683450
683824
|
import { createConnection as createConnection3 } from "node:net";
|
|
683451
683825
|
function getLocalOnion() {
|
|
683452
683826
|
const candidates = [
|
|
683453
|
-
|
|
683454
|
-
|
|
683827
|
+
join166(homedir56(), "hidden_service_hostname"),
|
|
683828
|
+
join166(homedir56(), ".omnius", "tor", "hostname"),
|
|
683455
683829
|
"/var/lib/tor/hidden_service/hostname"
|
|
683456
683830
|
];
|
|
683457
683831
|
for (const p2 of candidates) {
|
|
683458
683832
|
try {
|
|
683459
|
-
if (
|
|
683460
|
-
const v =
|
|
683833
|
+
if (existsSync155(p2)) {
|
|
683834
|
+
const v = readFileSync127(p2, "utf-8").trim();
|
|
683461
683835
|
if (v && v.endsWith(".onion")) return v;
|
|
683462
683836
|
}
|
|
683463
683837
|
} catch {
|
|
@@ -683602,8 +683976,8 @@ __export(graphical_sudo_exports, {
|
|
|
683602
683976
|
runGraphicalSudo: () => runGraphicalSudo
|
|
683603
683977
|
});
|
|
683604
683978
|
import { spawn as spawn31 } from "node:child_process";
|
|
683605
|
-
import { existsSync as
|
|
683606
|
-
import { join as
|
|
683979
|
+
import { existsSync as existsSync156, mkdirSync as mkdirSync97, writeFileSync as writeFileSync83, chmodSync as chmodSync5 } from "node:fs";
|
|
683980
|
+
import { join as join167 } from "node:path";
|
|
683607
683981
|
import { tmpdir as tmpdir22 } from "node:os";
|
|
683608
683982
|
function detectSudoHelper() {
|
|
683609
683983
|
if (process.platform === "win32") return null;
|
|
@@ -683619,15 +683993,15 @@ function which2(cmd) {
|
|
|
683619
683993
|
const path12 = process.env["PATH"] || "/usr/bin:/bin:/usr/local/bin";
|
|
683620
683994
|
for (const dir of path12.split(":")) {
|
|
683621
683995
|
if (!dir) continue;
|
|
683622
|
-
const full =
|
|
683623
|
-
if (
|
|
683996
|
+
const full = join167(dir, cmd);
|
|
683997
|
+
if (existsSync156(full)) return full;
|
|
683624
683998
|
}
|
|
683625
683999
|
return null;
|
|
683626
684000
|
}
|
|
683627
684001
|
function ensureAskpassShim(helper, description) {
|
|
683628
|
-
const shimDir =
|
|
683629
|
-
|
|
683630
|
-
const shim =
|
|
684002
|
+
const shimDir = join167(tmpdir22(), "omnius-askpass");
|
|
684003
|
+
mkdirSync97(shimDir, { recursive: true });
|
|
684004
|
+
const shim = join167(shimDir, `${helper}.sh`);
|
|
683631
684005
|
let body;
|
|
683632
684006
|
if (helper === "zenity") {
|
|
683633
684007
|
body = `#!/bin/sh
|
|
@@ -683638,7 +684012,7 @@ exec zenity --password --title="Omnius needs sudo" --text="${description.replace
|
|
|
683638
684012
|
exec kdialog --password "${description.replace(/"/g, '\\"')}" 2>/dev/null
|
|
683639
684013
|
`;
|
|
683640
684014
|
}
|
|
683641
|
-
|
|
684015
|
+
writeFileSync83(shim, body, "utf-8");
|
|
683642
684016
|
chmodSync5(shim, 493);
|
|
683643
684017
|
return shim;
|
|
683644
684018
|
}
|
|
@@ -683718,8 +684092,8 @@ var init_graphical_sudo = __esm({
|
|
|
683718
684092
|
});
|
|
683719
684093
|
|
|
683720
684094
|
// packages/cli/src/api/routes-v1.ts
|
|
683721
|
-
import { existsSync as
|
|
683722
|
-
import { join as
|
|
684095
|
+
import { existsSync as existsSync157, mkdirSync as mkdirSync98, readFileSync as readFileSync128, readdirSync as readdirSync55, statSync as statSync55 } from "node:fs";
|
|
684096
|
+
import { join as join168, resolve as pathResolve3 } from "node:path";
|
|
683723
684097
|
import { homedir as homedir57 } from "node:os";
|
|
683724
684098
|
async function tryRouteV1(ctx3) {
|
|
683725
684099
|
const { pathname, method } = ctx3;
|
|
@@ -683827,18 +684201,23 @@ async function tryRouteV1(ctx3) {
|
|
|
683827
684201
|
if (pathname === "/v1/tools" && method === "GET") {
|
|
683828
684202
|
return handleListTools(ctx3);
|
|
683829
684203
|
}
|
|
684204
|
+
if (pathname === "/v1/tools/register" && method === "POST") {
|
|
684205
|
+
return handleRegisterTool(ctx3);
|
|
684206
|
+
}
|
|
683830
684207
|
{
|
|
683831
|
-
const m2 = /^\/v1\/tools\/([^/]+)(\/call)?$/.exec(pathname);
|
|
684208
|
+
const m2 = /^\/v1\/tools\/([^/]+)(\/call|\/eval)?$/.exec(pathname);
|
|
683832
684209
|
if (m2) {
|
|
683833
684210
|
const toolName = decodeURIComponent(m2[1]);
|
|
683834
|
-
const
|
|
683835
|
-
if (
|
|
683836
|
-
if (
|
|
684211
|
+
const suffix = m2[2];
|
|
684212
|
+
if (suffix === "/call" && method === "POST") return handleCallTool(ctx3, toolName);
|
|
684213
|
+
if (suffix === "/eval" && method === "POST") return handleEvalTool(ctx3, toolName);
|
|
684214
|
+
if (!suffix && method === "GET") return handleGetTool(ctx3, toolName);
|
|
684215
|
+
if (!suffix && method === "DELETE") return handleDeleteTool(ctx3, toolName);
|
|
683837
684216
|
sendProblem(ctx3.res, problemDetails({
|
|
683838
684217
|
type: P2.methodNotAllowed,
|
|
683839
684218
|
status: 405,
|
|
683840
684219
|
title: `Method ${method} not allowed for ${pathname}`,
|
|
683841
|
-
detail:
|
|
684220
|
+
detail: suffix === "/call" ? "POST /v1/tools/{name}/call to execute the tool." : suffix === "/eval" ? "POST /v1/tools/{name}/eval to evaluate the tool." : "GET /v1/tools/{name} for schema, DELETE to unregister an external tool.",
|
|
683842
684221
|
instance: ctx3.requestId
|
|
683843
684222
|
}));
|
|
683844
684223
|
return true;
|
|
@@ -683970,11 +684349,11 @@ async function handleGetSkill(ctx3, name10) {
|
|
|
683970
684349
|
async function fallbackDiscoverSkills() {
|
|
683971
684350
|
return (_root) => {
|
|
683972
684351
|
const roots = [
|
|
683973
|
-
|
|
684352
|
+
join168(homedir57(), ".local", "share", "ai-writing-guide")
|
|
683974
684353
|
];
|
|
683975
684354
|
const out = [];
|
|
683976
684355
|
for (const root of roots) {
|
|
683977
|
-
if (!
|
|
684356
|
+
if (!existsSync157(root)) continue;
|
|
683978
684357
|
walkForSkills(root, out, 0);
|
|
683979
684358
|
}
|
|
683980
684359
|
return out;
|
|
@@ -683985,12 +684364,12 @@ function walkForSkills(dir, out, depth) {
|
|
|
683985
684364
|
try {
|
|
683986
684365
|
for (const e2 of readdirSync55(dir, { withFileTypes: true })) {
|
|
683987
684366
|
if (e2.name.startsWith(".") || e2.name === "node_modules") continue;
|
|
683988
|
-
const p2 =
|
|
684367
|
+
const p2 = join168(dir, e2.name);
|
|
683989
684368
|
if (e2.isDirectory()) {
|
|
683990
684369
|
walkForSkills(p2, out, depth + 1);
|
|
683991
684370
|
} else if (e2.isFile() && e2.name === "SKILL.md") {
|
|
683992
684371
|
try {
|
|
683993
|
-
const content =
|
|
684372
|
+
const content = readFileSync128(p2, "utf-8").slice(0, 2e3);
|
|
683994
684373
|
const nameMatch = content.match(/^name:\s*(.+)$/m);
|
|
683995
684374
|
const descMatch = content.match(/^description:\s*(.+)$/m);
|
|
683996
684375
|
out.push({
|
|
@@ -684273,19 +684652,19 @@ async function handleOllamaPoolCleanup(ctx3) {
|
|
|
684273
684652
|
}
|
|
684274
684653
|
}
|
|
684275
684654
|
function memoryDbPaths2(baseDir = process.cwd()) {
|
|
684276
|
-
const dir =
|
|
684655
|
+
const dir = join168(baseDir, ".omnius");
|
|
684277
684656
|
return {
|
|
684278
|
-
episodes:
|
|
684279
|
-
knowledge:
|
|
684657
|
+
episodes: join168(dir, "episodes.db"),
|
|
684658
|
+
knowledge: join168(dir, "knowledge.db")
|
|
684280
684659
|
};
|
|
684281
684660
|
}
|
|
684282
684661
|
function unifiedMemoryDbPath(baseDir = process.cwd()) {
|
|
684283
|
-
const dir =
|
|
684662
|
+
const dir = join168(baseDir, ".omnius");
|
|
684284
684663
|
try {
|
|
684285
|
-
|
|
684664
|
+
mkdirSync98(dir, { recursive: true });
|
|
684286
684665
|
} catch {
|
|
684287
684666
|
}
|
|
684288
|
-
return
|
|
684667
|
+
return join168(dir, "unified-memory.db");
|
|
684289
684668
|
}
|
|
684290
684669
|
function withUnifiedMemory(fn) {
|
|
684291
684670
|
const db = initDb(unifiedMemoryDbPath());
|
|
@@ -684914,7 +685293,7 @@ async function handleFilesRead(ctx3) {
|
|
|
684914
685293
|
}));
|
|
684915
685294
|
return true;
|
|
684916
685295
|
}
|
|
684917
|
-
if (!
|
|
685296
|
+
if (!existsSync157(resolved)) {
|
|
684918
685297
|
sendProblem(res, problemDetails({
|
|
684919
685298
|
type: P2.notFound,
|
|
684920
685299
|
status: 404,
|
|
@@ -684946,7 +685325,7 @@ async function handleFilesRead(ctx3) {
|
|
|
684946
685325
|
}));
|
|
684947
685326
|
return true;
|
|
684948
685327
|
}
|
|
684949
|
-
const content =
|
|
685328
|
+
const content = readFileSync128(resolved, "utf-8");
|
|
684950
685329
|
const offset = typeof body.offset === "number" && body.offset >= 0 ? body.offset : 0;
|
|
684951
685330
|
const limit = typeof body.limit === "number" && body.limit > 0 ? body.limit : content.length;
|
|
684952
685331
|
const slice2 = content.slice(offset, offset + limit);
|
|
@@ -685179,14 +685558,14 @@ async function handleNexusStatus(ctx3) {
|
|
|
685179
685558
|
const { res, requestId } = ctx3;
|
|
685180
685559
|
try {
|
|
685181
685560
|
const statePaths = [
|
|
685182
|
-
|
|
685183
|
-
|
|
685561
|
+
join168(process.cwd(), ".omnius", "nexus-peer-state.json"),
|
|
685562
|
+
join168(homedir57(), ".omnius", "nexus-peer-cache.json")
|
|
685184
685563
|
];
|
|
685185
685564
|
const states2 = [];
|
|
685186
685565
|
for (const p2 of statePaths) {
|
|
685187
|
-
if (!
|
|
685566
|
+
if (!existsSync157(p2)) continue;
|
|
685188
685567
|
try {
|
|
685189
|
-
const raw =
|
|
685568
|
+
const raw = readFileSync128(p2, "utf-8");
|
|
685190
685569
|
states2.push({ source: p2, data: JSON.parse(raw) });
|
|
685191
685570
|
} catch (e2) {
|
|
685192
685571
|
states2.push({ source: p2, error: String(e2) });
|
|
@@ -685213,8 +685592,8 @@ async function handleNexusStatus(ctx3) {
|
|
|
685213
685592
|
}
|
|
685214
685593
|
function loadAgentName() {
|
|
685215
685594
|
try {
|
|
685216
|
-
const p2 =
|
|
685217
|
-
if (
|
|
685595
|
+
const p2 = join168(homedir57(), ".omnius", "agent-name");
|
|
685596
|
+
if (existsSync157(p2)) return readFileSync128(p2, "utf-8").trim();
|
|
685218
685597
|
} catch {
|
|
685219
685598
|
}
|
|
685220
685599
|
return null;
|
|
@@ -685223,14 +685602,14 @@ async function handleSponsors(ctx3) {
|
|
|
685223
685602
|
const { req: req3, res, url, requestId } = ctx3;
|
|
685224
685603
|
try {
|
|
685225
685604
|
const candidates = [
|
|
685226
|
-
|
|
685227
|
-
|
|
685605
|
+
join168(homedir57(), ".omnius", "sponsor-cache.json"),
|
|
685606
|
+
join168(homedir57(), ".omnius", "sponsors.json")
|
|
685228
685607
|
];
|
|
685229
685608
|
let sponsors = [];
|
|
685230
685609
|
for (const p2 of candidates) {
|
|
685231
|
-
if (!
|
|
685610
|
+
if (!existsSync157(p2)) continue;
|
|
685232
685611
|
try {
|
|
685233
|
-
const raw = JSON.parse(
|
|
685612
|
+
const raw = JSON.parse(readFileSync128(p2, "utf-8"));
|
|
685234
685613
|
if (Array.isArray(raw)) {
|
|
685235
685614
|
sponsors = raw;
|
|
685236
685615
|
break;
|
|
@@ -685299,8 +685678,8 @@ async function handleEvaluate(ctx3) {
|
|
|
685299
685678
|
}));
|
|
685300
685679
|
return true;
|
|
685301
685680
|
}
|
|
685302
|
-
const jobPath =
|
|
685303
|
-
if (!
|
|
685681
|
+
const jobPath = join168(process.cwd(), ".omnius", "jobs", `${runId}.json`);
|
|
685682
|
+
if (!existsSync157(jobPath)) {
|
|
685304
685683
|
sendProblem(res, problemDetails({
|
|
685305
685684
|
type: P2.notFound,
|
|
685306
685685
|
status: 404,
|
|
@@ -685310,7 +685689,7 @@ async function handleEvaluate(ctx3) {
|
|
|
685310
685689
|
}));
|
|
685311
685690
|
return true;
|
|
685312
685691
|
}
|
|
685313
|
-
const job = JSON.parse(
|
|
685692
|
+
const job = JSON.parse(readFileSync128(jobPath, "utf-8"));
|
|
685314
685693
|
sendJson2(res, 200, {
|
|
685315
685694
|
run_id: runId,
|
|
685316
685695
|
task: job.task,
|
|
@@ -685448,9 +685827,9 @@ async function handleMintKey(ctx3) {
|
|
|
685448
685827
|
return true;
|
|
685449
685828
|
}
|
|
685450
685829
|
function _readStatusFile(p2) {
|
|
685451
|
-
if (!
|
|
685830
|
+
if (!existsSync157(p2)) return null;
|
|
685452
685831
|
try {
|
|
685453
|
-
const data = JSON.parse(
|
|
685832
|
+
const data = JSON.parse(readFileSync128(p2, "utf-8"));
|
|
685454
685833
|
if (data?.connected && typeof data.peerId === "string" && data.peerId.length > 10) {
|
|
685455
685834
|
const pid = Number(data.pid);
|
|
685456
685835
|
if (pid > 0) {
|
|
@@ -685473,32 +685852,32 @@ function _readStatusFile(p2) {
|
|
|
685473
685852
|
function resolveLocalPeerId() {
|
|
685474
685853
|
const override = process.env["OMNIUS_NEXUS_DIR"];
|
|
685475
685854
|
if (override) {
|
|
685476
|
-
const r2 = _readStatusFile(
|
|
685855
|
+
const r2 = _readStatusFile(join168(override, "status.json"));
|
|
685477
685856
|
if (r2) return r2;
|
|
685478
685857
|
}
|
|
685479
685858
|
const scope = (process.env["OMNIUS_NEXUS_SCOPE"] || "").toLowerCase();
|
|
685480
685859
|
const projectScopeFlag = (process.env["OMNIUS_NEXUS_PROJECT_SCOPE"] || "").toLowerCase();
|
|
685481
685860
|
const projectScoped = scope === "project" || scope === "local" || projectScopeFlag === "1" || projectScopeFlag === "true" || projectScopeFlag === "yes";
|
|
685482
685861
|
const candidates = projectScoped ? [
|
|
685483
|
-
|
|
685484
|
-
|
|
685862
|
+
join168(process.cwd(), ".omnius", "nexus", "status.json"),
|
|
685863
|
+
join168(homedir57(), ".omnius", "nexus", "status.json")
|
|
685485
685864
|
] : [
|
|
685486
|
-
|
|
685487
|
-
|
|
685865
|
+
join168(homedir57(), ".omnius", "nexus", "status.json"),
|
|
685866
|
+
join168(process.cwd(), ".omnius", "nexus", "status.json")
|
|
685488
685867
|
];
|
|
685489
685868
|
for (const p2 of candidates) {
|
|
685490
685869
|
const r2 = _readStatusFile(p2);
|
|
685491
685870
|
if (r2) return r2;
|
|
685492
685871
|
}
|
|
685493
685872
|
try {
|
|
685494
|
-
const regPath =
|
|
685495
|
-
if (
|
|
685496
|
-
const reg = JSON.parse(
|
|
685873
|
+
const regPath = join168(homedir57(), ".omnius", "nexus-registry.json");
|
|
685874
|
+
if (existsSync157(regPath)) {
|
|
685875
|
+
const reg = JSON.parse(readFileSync128(regPath, "utf-8"));
|
|
685497
685876
|
const entries = Array.isArray(reg?.dirs) ? reg.dirs : [];
|
|
685498
685877
|
for (const entry of entries) {
|
|
685499
685878
|
const dir = typeof entry === "string" ? entry : entry?.dir;
|
|
685500
685879
|
if (typeof dir === "string") {
|
|
685501
|
-
const r2 = _readStatusFile(
|
|
685880
|
+
const r2 = _readStatusFile(join168(dir, "status.json"));
|
|
685502
685881
|
if (r2) return r2;
|
|
685503
685882
|
}
|
|
685504
685883
|
}
|
|
@@ -685532,21 +685911,21 @@ function locateTorScript(filename) {
|
|
|
685532
685911
|
const candidates = [
|
|
685533
685912
|
// npm-installed layout: build-publish.mjs copies scripts to
|
|
685534
685913
|
// publish/dist/scripts/tor/ which lands at <install>/dist/scripts/tor/.
|
|
685535
|
-
|
|
685536
|
-
|
|
685537
|
-
|
|
685914
|
+
join168(__dirname, "scripts", "tor", filename),
|
|
685915
|
+
join168(__dirname, "..", "scripts", "tor", filename),
|
|
685916
|
+
join168(__dirname, "..", "..", "scripts", "tor", filename),
|
|
685538
685917
|
// Workspace dev: cli package's source tree.
|
|
685539
|
-
|
|
685540
|
-
|
|
685918
|
+
join168(process.cwd(), "packages", "cli", "scripts", "tor", filename),
|
|
685919
|
+
join168(process.cwd(), "scripts", "tor", filename)
|
|
685541
685920
|
];
|
|
685542
685921
|
for (const p2 of candidates) {
|
|
685543
|
-
if (
|
|
685922
|
+
if (existsSync157(p2)) return p2;
|
|
685544
685923
|
}
|
|
685545
685924
|
try {
|
|
685546
685925
|
const { execSync: execSync63 } = __require("node:child_process");
|
|
685547
685926
|
const root = execSync63("npm root -g", { encoding: "utf-8", timeout: 5e3 }).trim();
|
|
685548
|
-
const p2 =
|
|
685549
|
-
if (
|
|
685927
|
+
const p2 = join168(root, "omnius", "dist", "scripts", "tor", filename);
|
|
685928
|
+
if (existsSync157(p2)) return p2;
|
|
685550
685929
|
} catch {
|
|
685551
685930
|
}
|
|
685552
685931
|
return null;
|
|
@@ -685818,15 +686197,15 @@ async function handleRemoteProxy(ctx3) {
|
|
|
685818
686197
|
const tunnelScope = (process.env["OMNIUS_NEXUS_SCOPE"] || "").toLowerCase();
|
|
685819
686198
|
const tunnelProjectScope = tunnelScope === "project" || tunnelScope === "local" || ["1", "true", "yes"].includes((process.env["OMNIUS_NEXUS_PROJECT_SCOPE"] || "").toLowerCase());
|
|
685820
686199
|
const nexusCandidates = tunnelProjectScope ? [
|
|
685821
|
-
|
|
685822
|
-
|
|
686200
|
+
join168(process.cwd(), ".omnius", "nexus"),
|
|
686201
|
+
join168(homedir57(), ".omnius", "nexus")
|
|
685823
686202
|
] : [
|
|
685824
|
-
|
|
685825
|
-
|
|
686203
|
+
join168(homedir57(), ".omnius", "nexus"),
|
|
686204
|
+
join168(process.cwd(), ".omnius", "nexus")
|
|
685826
686205
|
];
|
|
685827
686206
|
let nexusDirPath = null;
|
|
685828
686207
|
for (const p2 of nexusCandidates) {
|
|
685829
|
-
if (
|
|
686208
|
+
if (existsSync157(join168(p2, "status.json"))) {
|
|
685830
686209
|
nexusDirPath = p2;
|
|
685831
686210
|
break;
|
|
685832
686211
|
}
|
|
@@ -685922,7 +686301,7 @@ async function handleRemoteProxy(ctx3) {
|
|
|
685922
686301
|
}));
|
|
685923
686302
|
return true;
|
|
685924
686303
|
}
|
|
685925
|
-
const streamFile =
|
|
686304
|
+
const streamFile = join168(nexusDirPath, `tunnel-${requestId}-${Date.now()}.jsonl`);
|
|
685926
686305
|
try {
|
|
685927
686306
|
const { writeFileSync: _wfs } = await import("node:fs");
|
|
685928
686307
|
_wfs(streamFile, "");
|
|
@@ -686284,11 +686663,16 @@ async function handleListTools(ctx3) {
|
|
|
686284
686663
|
default_exposure: entry.defaultExposure,
|
|
686285
686664
|
availability: entry.availability,
|
|
686286
686665
|
direct_callable: entry.directCallable,
|
|
686666
|
+
source: "builtin",
|
|
686287
686667
|
endpoints: {
|
|
686288
686668
|
call: `/v1/tools/${encodeURIComponent(entry.name)}/call`,
|
|
686289
686669
|
schema: `/v1/tools/${encodeURIComponent(entry.name)}`
|
|
686290
686670
|
}
|
|
686291
686671
|
}));
|
|
686672
|
+
for (const ext of loadExternalTools(workingDir)) {
|
|
686673
|
+
if (profile.loaded && !isToolAllowed(profile.loaded.profile, ext.name)) continue;
|
|
686674
|
+
tools.push(externalToolToListEntry(ext));
|
|
686675
|
+
}
|
|
686292
686676
|
tools.sort((a2, b) => a2.name.localeCompare(b.name));
|
|
686293
686677
|
const filterCat = url.searchParams.get("category");
|
|
686294
686678
|
const filterScope = url.searchParams.get("scope");
|
|
@@ -686352,11 +686736,33 @@ async function handleGetTool(ctx3, name10) {
|
|
|
686352
686736
|
}
|
|
686353
686737
|
const found = registry4.byName.get(name10);
|
|
686354
686738
|
if (!found) {
|
|
686739
|
+
const ext = getExternalTool(workingDir, name10);
|
|
686740
|
+
if (ext) {
|
|
686741
|
+
if (profile.loaded && !isToolAllowed(profile.loaded.profile, name10)) {
|
|
686742
|
+
sendProblem(res, problemDetails({
|
|
686743
|
+
type: P2.forbidden,
|
|
686744
|
+
status: 403,
|
|
686745
|
+
title: "Tool denied by profile",
|
|
686746
|
+
detail: `Tool '${name10}' is not allowed by profile '${profile.loaded.profile.name}'.`,
|
|
686747
|
+
instance: requestId
|
|
686748
|
+
}));
|
|
686749
|
+
return true;
|
|
686750
|
+
}
|
|
686751
|
+
sendJson2(res, 200, {
|
|
686752
|
+
...externalToolToListEntry(ext),
|
|
686753
|
+
call_body_shape: {
|
|
686754
|
+
args: "<object matching the `parameters` JSON schema>",
|
|
686755
|
+
session_id: "<optional stable workflow id; also accepted as X-Omnius-Session-Id or env.OMNIUS_SESSION_ID>"
|
|
686756
|
+
},
|
|
686757
|
+
active_profile: profile.loaded ? profileMetadata(profile.loaded, registry4.entries.map((entry) => entry.name)) : null
|
|
686758
|
+
});
|
|
686759
|
+
return true;
|
|
686760
|
+
}
|
|
686355
686761
|
sendProblem(res, problemDetails({
|
|
686356
686762
|
type: P2.notFound,
|
|
686357
686763
|
status: 404,
|
|
686358
686764
|
title: `Tool '${name10}' not found`,
|
|
686359
|
-
detail: "No direct-callable tool with that name
|
|
686765
|
+
detail: "No direct-callable or registered external tool with that name.",
|
|
686360
686766
|
instance: requestId
|
|
686361
686767
|
}));
|
|
686362
686768
|
return true;
|
|
@@ -686473,6 +686879,10 @@ async function handleCallTool(ctx3, name10) {
|
|
|
686473
686879
|
const registry4 = await buildDirectToolRegistry(workingDir);
|
|
686474
686880
|
const entry = registry4.byName.get(name10);
|
|
686475
686881
|
if (!entry) {
|
|
686882
|
+
const ext = getExternalTool(workingDir, name10);
|
|
686883
|
+
if (ext) {
|
|
686884
|
+
return callExternalTool(ctx3, ext, args, workingDir, origin, scope, body);
|
|
686885
|
+
}
|
|
686476
686886
|
sendProblem(res, problemDetails({
|
|
686477
686887
|
type: P2.notFound,
|
|
686478
686888
|
status: 404,
|
|
@@ -686570,6 +686980,268 @@ async function handleCallTool(ctx3, name10) {
|
|
|
686570
686980
|
return true;
|
|
686571
686981
|
}
|
|
686572
686982
|
}
|
|
686983
|
+
function externalToolToListEntry(ext) {
|
|
686984
|
+
return {
|
|
686985
|
+
name: ext.name,
|
|
686986
|
+
class: "ExternalTool",
|
|
686987
|
+
description: ext.description,
|
|
686988
|
+
parameters: ext.parameters,
|
|
686989
|
+
security: ext.security,
|
|
686990
|
+
default_exposure: ext.security.off_device_allowed ? "trusted-default" : "local-default",
|
|
686991
|
+
availability: { available: true, cached: false, checkedAt: ext.updated_at },
|
|
686992
|
+
direct_callable: true,
|
|
686993
|
+
source: "external",
|
|
686994
|
+
transport: ext.transport.type,
|
|
686995
|
+
endpoints: {
|
|
686996
|
+
call: `/v1/tools/${encodeURIComponent(ext.name)}/call`,
|
|
686997
|
+
schema: `/v1/tools/${encodeURIComponent(ext.name)}`,
|
|
686998
|
+
eval: `/v1/tools/${encodeURIComponent(ext.name)}/eval`
|
|
686999
|
+
},
|
|
687000
|
+
created_at: ext.created_at,
|
|
687001
|
+
updated_at: ext.updated_at
|
|
687002
|
+
};
|
|
687003
|
+
}
|
|
687004
|
+
function externalDispatchDeps() {
|
|
687005
|
+
return { getMcpManager: (workingDir) => getMcpManager(workingDir) };
|
|
687006
|
+
}
|
|
687007
|
+
async function callExternalTool(ctx3, ext, args, workingDir, origin, scope, body) {
|
|
687008
|
+
const { res, requestId, user } = ctx3;
|
|
687009
|
+
const scopeRank = { read: 0, run: 1, admin: 2 };
|
|
687010
|
+
if (scopeRank[scope] < scopeRank[ext.security.requires_scope]) {
|
|
687011
|
+
sendProblem(res, problemDetails({
|
|
687012
|
+
type: P2.forbidden,
|
|
687013
|
+
status: 403,
|
|
687014
|
+
title: "Tool invocation denied",
|
|
687015
|
+
detail: `Tool '${ext.name}' requires '${ext.security.requires_scope}' scope; caller has '${scope}'.`,
|
|
687016
|
+
instance: requestId
|
|
687017
|
+
}));
|
|
687018
|
+
return true;
|
|
687019
|
+
}
|
|
687020
|
+
if (origin === "remote" && !ext.security.off_device_allowed && scope !== "admin") {
|
|
687021
|
+
sendProblem(res, problemDetails({
|
|
687022
|
+
type: P2.forbidden,
|
|
687023
|
+
status: 403,
|
|
687024
|
+
title: "Tool invocation denied",
|
|
687025
|
+
detail: `Tool '${ext.name}' is not off_device_allowed; remote callers need admin scope.`,
|
|
687026
|
+
instance: requestId
|
|
687027
|
+
}));
|
|
687028
|
+
return true;
|
|
687029
|
+
}
|
|
687030
|
+
const sessionId = resolveDirectToolSessionId(ctx3, body, args);
|
|
687031
|
+
const result = await executeExternalTool(ext, args, workingDir, sessionId, externalDispatchDeps());
|
|
687032
|
+
publishEvent("tool.called", { tool: ext.name, transport: ext.transport.type, source: "external" }, {
|
|
687033
|
+
subject: user ?? "anonymous",
|
|
687034
|
+
aimsControl: "A.6.2.6"
|
|
687035
|
+
// ISO 42001 — AI system operation record
|
|
687036
|
+
});
|
|
687037
|
+
sendJson2(res, result.success ? 200 : 502, {
|
|
687038
|
+
tool: ext.name,
|
|
687039
|
+
class: "ExternalTool",
|
|
687040
|
+
result,
|
|
687041
|
+
security: ext.security,
|
|
687042
|
+
session_id: sessionId ?? null,
|
|
687043
|
+
origin,
|
|
687044
|
+
scope
|
|
687045
|
+
});
|
|
687046
|
+
return true;
|
|
687047
|
+
}
|
|
687048
|
+
async function handleRegisterTool(ctx3) {
|
|
687049
|
+
const { req: req3, res, requestId, user } = ctx3;
|
|
687050
|
+
const scope = requestScope(ctx3);
|
|
687051
|
+
if (scope === "read") {
|
|
687052
|
+
sendProblem(res, problemDetails({
|
|
687053
|
+
type: P2.forbidden,
|
|
687054
|
+
status: 403,
|
|
687055
|
+
title: "run scope required",
|
|
687056
|
+
detail: "Registering a tool requires 'run' or 'admin' scope.",
|
|
687057
|
+
instance: requestId
|
|
687058
|
+
}));
|
|
687059
|
+
return true;
|
|
687060
|
+
}
|
|
687061
|
+
let body;
|
|
687062
|
+
try {
|
|
687063
|
+
body = await parseJsonBodyStrict(req3);
|
|
687064
|
+
} catch {
|
|
687065
|
+
sendProblem(res, problemDetails({
|
|
687066
|
+
type: P2.invalidRequest,
|
|
687067
|
+
status: 400,
|
|
687068
|
+
title: "Body must be JSON",
|
|
687069
|
+
detail: "POST a tool manifest: {name, description, parameters, security?, transport}.",
|
|
687070
|
+
instance: requestId
|
|
687071
|
+
}));
|
|
687072
|
+
return true;
|
|
687073
|
+
}
|
|
687074
|
+
const workingDir = resolveToolWorkingDirFromRequest(ctx3);
|
|
687075
|
+
const origin = requestOrigin(ctx3);
|
|
687076
|
+
if (origin === "remote" && scope !== "admin") {
|
|
687077
|
+
sendProblem(res, problemDetails({
|
|
687078
|
+
type: P2.forbidden,
|
|
687079
|
+
status: 403,
|
|
687080
|
+
title: "Admin scope required",
|
|
687081
|
+
detail: "Remote callers must use admin scope to register tools.",
|
|
687082
|
+
instance: requestId
|
|
687083
|
+
}));
|
|
687084
|
+
return true;
|
|
687085
|
+
}
|
|
687086
|
+
const builtins = await buildDirectToolRegistry(workingDir);
|
|
687087
|
+
const manifestName = typeof body?.name === "string" ? body.name.trim() : "";
|
|
687088
|
+
if (manifestName && builtins.byName.has(manifestName)) {
|
|
687089
|
+
sendProblem(res, problemDetails({
|
|
687090
|
+
type: P2.invalidRequest,
|
|
687091
|
+
status: 409,
|
|
687092
|
+
title: "Name collides with built-in tool",
|
|
687093
|
+
detail: `'${manifestName}' is a built-in tool; choose a different name.`,
|
|
687094
|
+
instance: requestId
|
|
687095
|
+
}));
|
|
687096
|
+
return true;
|
|
687097
|
+
}
|
|
687098
|
+
const existing = getExternalTool(workingDir, manifestName) ?? void 0;
|
|
687099
|
+
const validation = validateManifest2(body, existing);
|
|
687100
|
+
if (!validation.ok || !validation.record) {
|
|
687101
|
+
sendProblem(res, problemDetails({
|
|
687102
|
+
type: P2.invalidRequest,
|
|
687103
|
+
status: 400,
|
|
687104
|
+
title: "Invalid tool manifest",
|
|
687105
|
+
detail: validation.error ?? "Manifest failed validation.",
|
|
687106
|
+
instance: requestId
|
|
687107
|
+
}));
|
|
687108
|
+
return true;
|
|
687109
|
+
}
|
|
687110
|
+
const record = validation.record;
|
|
687111
|
+
if (record.transport.type === "mcp" && record.transport.connect?.url) {
|
|
687112
|
+
try {
|
|
687113
|
+
const mgr = await getMcpManager(workingDir);
|
|
687114
|
+
if (mgr && typeof mgr.addServer === "function") {
|
|
687115
|
+
const c8 = record.transport.connect;
|
|
687116
|
+
await mgr.addServer(record.transport.server, {
|
|
687117
|
+
transport: c8.transport ?? "streamable-http",
|
|
687118
|
+
url: c8.url,
|
|
687119
|
+
headers: c8.headers,
|
|
687120
|
+
command: c8.command,
|
|
687121
|
+
args: c8.args
|
|
687122
|
+
});
|
|
687123
|
+
}
|
|
687124
|
+
} catch (err) {
|
|
687125
|
+
sendProblem(res, problemDetails({
|
|
687126
|
+
type: P2.upstreamFailure,
|
|
687127
|
+
status: 502,
|
|
687128
|
+
title: "MCP server connect failed",
|
|
687129
|
+
detail: `Registered tool but could not connect MCP server '${record.transport.server}': ${err instanceof Error ? err.message : String(err)}`,
|
|
687130
|
+
instance: requestId
|
|
687131
|
+
}));
|
|
687132
|
+
return true;
|
|
687133
|
+
}
|
|
687134
|
+
}
|
|
687135
|
+
const { replaced } = upsertExternalTool(workingDir, record);
|
|
687136
|
+
publishEvent("tool.registered", { tool: record.name, transport: record.transport.type, replaced }, {
|
|
687137
|
+
subject: user ?? "anonymous",
|
|
687138
|
+
aimsControl: "A.6.2.4"
|
|
687139
|
+
// ISO 42001 — AI system change/control record
|
|
687140
|
+
});
|
|
687141
|
+
sendJson2(res, replaced ? 200 : 201, {
|
|
687142
|
+
registered: record.name,
|
|
687143
|
+
replaced,
|
|
687144
|
+
working_directory: workingDir,
|
|
687145
|
+
tool: externalToolToListEntry(record)
|
|
687146
|
+
});
|
|
687147
|
+
return true;
|
|
687148
|
+
}
|
|
687149
|
+
async function handleDeleteTool(ctx3, name10) {
|
|
687150
|
+
const { res, requestId, user } = ctx3;
|
|
687151
|
+
const scope = requestScope(ctx3);
|
|
687152
|
+
if (scope === "read") {
|
|
687153
|
+
sendProblem(res, problemDetails({
|
|
687154
|
+
type: P2.forbidden,
|
|
687155
|
+
status: 403,
|
|
687156
|
+
title: "run scope required",
|
|
687157
|
+
detail: "Unregistering a tool requires 'run' or 'admin' scope.",
|
|
687158
|
+
instance: requestId
|
|
687159
|
+
}));
|
|
687160
|
+
return true;
|
|
687161
|
+
}
|
|
687162
|
+
const workingDir = resolveToolWorkingDirFromRequest(ctx3);
|
|
687163
|
+
const removed = removeExternalTool(workingDir, name10);
|
|
687164
|
+
if (!removed) {
|
|
687165
|
+
sendProblem(res, problemDetails({
|
|
687166
|
+
type: P2.notFound,
|
|
687167
|
+
status: 404,
|
|
687168
|
+
title: `External tool '${name10}' not found`,
|
|
687169
|
+
detail: "Only externally-registered tools can be deleted; built-ins are immutable.",
|
|
687170
|
+
instance: requestId
|
|
687171
|
+
}));
|
|
687172
|
+
return true;
|
|
687173
|
+
}
|
|
687174
|
+
publishEvent("tool.unregistered", { tool: name10 }, {
|
|
687175
|
+
subject: user ?? "anonymous",
|
|
687176
|
+
aimsControl: "A.6.2.4"
|
|
687177
|
+
});
|
|
687178
|
+
sendJson2(res, 200, { unregistered: name10, working_directory: workingDir });
|
|
687179
|
+
return true;
|
|
687180
|
+
}
|
|
687181
|
+
async function handleEvalTool(ctx3, name10) {
|
|
687182
|
+
const { req: req3, res, requestId } = ctx3;
|
|
687183
|
+
const scope = requestScope(ctx3);
|
|
687184
|
+
if (scope === "read") {
|
|
687185
|
+
sendProblem(res, problemDetails({
|
|
687186
|
+
type: P2.forbidden,
|
|
687187
|
+
status: 403,
|
|
687188
|
+
title: "run scope required",
|
|
687189
|
+
detail: "Evaluating a tool requires 'run' or 'admin' scope.",
|
|
687190
|
+
instance: requestId
|
|
687191
|
+
}));
|
|
687192
|
+
return true;
|
|
687193
|
+
}
|
|
687194
|
+
let body;
|
|
687195
|
+
try {
|
|
687196
|
+
body = await parseJsonBodyStrict(req3);
|
|
687197
|
+
} catch {
|
|
687198
|
+
sendProblem(res, problemDetails({
|
|
687199
|
+
type: P2.invalidRequest,
|
|
687200
|
+
status: 400,
|
|
687201
|
+
title: "Body must be JSON",
|
|
687202
|
+
detail: "POST {cases: [{name?, args, expect?}]}.",
|
|
687203
|
+
instance: requestId
|
|
687204
|
+
}));
|
|
687205
|
+
return true;
|
|
687206
|
+
}
|
|
687207
|
+
const cases = Array.isArray(body?.cases) ? body.cases : null;
|
|
687208
|
+
if (!cases || cases.length === 0) {
|
|
687209
|
+
sendProblem(res, problemDetails({
|
|
687210
|
+
type: P2.invalidRequest,
|
|
687211
|
+
status: 400,
|
|
687212
|
+
title: "Missing 'cases'",
|
|
687213
|
+
detail: "Provide a non-empty `cases` array: [{args, expect?}].",
|
|
687214
|
+
instance: requestId
|
|
687215
|
+
}));
|
|
687216
|
+
return true;
|
|
687217
|
+
}
|
|
687218
|
+
const workingDir = resolveToolWorkingDirFromRequest(ctx3);
|
|
687219
|
+
const ext = getExternalTool(workingDir, name10);
|
|
687220
|
+
if (!ext) {
|
|
687221
|
+
sendProblem(res, problemDetails({
|
|
687222
|
+
type: P2.notFound,
|
|
687223
|
+
status: 404,
|
|
687224
|
+
title: `External tool '${name10}' not found`,
|
|
687225
|
+
detail: "Tool-level eval is available for externally-registered tools.",
|
|
687226
|
+
instance: requestId
|
|
687227
|
+
}));
|
|
687228
|
+
return true;
|
|
687229
|
+
}
|
|
687230
|
+
try {
|
|
687231
|
+
const report2 = await evaluateExternalTool(ext, cases, workingDir, externalDispatchDeps());
|
|
687232
|
+
sendJson2(res, 200, report2);
|
|
687233
|
+
return true;
|
|
687234
|
+
} catch (err) {
|
|
687235
|
+
sendProblem(res, problemDetails({
|
|
687236
|
+
type: P2.internalError,
|
|
687237
|
+
status: 500,
|
|
687238
|
+
title: "Tool eval failed",
|
|
687239
|
+
detail: err instanceof Error ? err.message : String(err),
|
|
687240
|
+
instance: requestId
|
|
687241
|
+
}));
|
|
687242
|
+
return true;
|
|
687243
|
+
}
|
|
687244
|
+
}
|
|
686573
687245
|
async function handleListHooks(ctx3) {
|
|
686574
687246
|
const { res } = ctx3;
|
|
686575
687247
|
sendJson2(res, 200, {
|
|
@@ -686617,14 +687289,14 @@ async function handleListEngines(ctx3) {
|
|
|
686617
687289
|
const home = homedir57();
|
|
686618
687290
|
sendJson2(res, 200, {
|
|
686619
687291
|
engines: [
|
|
686620
|
-
{ name: "dream", state_file:
|
|
686621
|
-
{ name: "bless", state_file:
|
|
686622
|
-
{ name: "call", state_file:
|
|
686623
|
-
{ name: "listen", state_file:
|
|
686624
|
-
{ name: "telegram", state_file:
|
|
686625
|
-
{ name: "expose", state_file:
|
|
686626
|
-
{ name: "nexus", state_file:
|
|
686627
|
-
{ name: "ipfs", state_file:
|
|
687292
|
+
{ name: "dream", state_file: join168(process.cwd(), ".omnius", "dreams"), controllable_via: "SSE + slash commands" },
|
|
687293
|
+
{ name: "bless", state_file: join168(process.cwd(), ".omnius", "bless-state.json"), controllable_via: "slash commands" },
|
|
687294
|
+
{ name: "call", state_file: join168(process.cwd(), ".omnius", "call-state.json"), controllable_via: "slash commands" },
|
|
687295
|
+
{ name: "listen", state_file: join168(process.cwd(), ".omnius", "listen-state.json"), controllable_via: "slash commands" },
|
|
687296
|
+
{ name: "telegram", state_file: join168(home, ".omnius", "telegram-state.json"), controllable_via: "slash commands" },
|
|
687297
|
+
{ name: "expose", state_file: join168(process.cwd(), ".omnius", "expose-state.json"), controllable_via: "/expose commands" },
|
|
687298
|
+
{ name: "nexus", state_file: join168(home, ".omnius", "nexus-peer-cache.json"), controllable_via: "/nexus commands" },
|
|
687299
|
+
{ name: "ipfs", state_file: join168(process.cwd(), ".omnius", "ipfs"), controllable_via: "slash commands" }
|
|
686628
687300
|
],
|
|
686629
687301
|
note: "Engine instrumentation lives in the running TUI process. Full status + control requires the daemon↔TUI bridge (PT-07). See parity audit WO-PARITY-04."
|
|
686630
687302
|
});
|
|
@@ -686707,21 +687379,21 @@ async function tryAimsRoute(ctx3) {
|
|
|
686707
687379
|
return false;
|
|
686708
687380
|
}
|
|
686709
687381
|
function aimsDir() {
|
|
686710
|
-
return
|
|
687382
|
+
return join168(homedir57(), ".omnius", "aims");
|
|
686711
687383
|
}
|
|
686712
687384
|
function readAimsFile(name10, fallback) {
|
|
686713
687385
|
try {
|
|
686714
|
-
const p2 =
|
|
686715
|
-
if (
|
|
687386
|
+
const p2 = join168(aimsDir(), name10);
|
|
687387
|
+
if (existsSync157(p2)) return JSON.parse(readFileSync128(p2, "utf-8"));
|
|
686716
687388
|
} catch {
|
|
686717
687389
|
}
|
|
686718
687390
|
return fallback;
|
|
686719
687391
|
}
|
|
686720
687392
|
function writeAimsFile(name10, data) {
|
|
686721
687393
|
const dir = aimsDir();
|
|
686722
|
-
const { mkdirSync:
|
|
686723
|
-
|
|
686724
|
-
const finalPath =
|
|
687394
|
+
const { mkdirSync: mkdirSync106, writeFileSync: wf, renameSync: rn } = __require("node:fs");
|
|
687395
|
+
mkdirSync106(dir, { recursive: true });
|
|
687396
|
+
const finalPath = join168(dir, name10);
|
|
686725
687397
|
const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}`;
|
|
686726
687398
|
try {
|
|
686727
687399
|
wf(tmpPath, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
@@ -687084,12 +687756,12 @@ async function handleAimsSuppliers(ctx3) {
|
|
|
687084
687756
|
}
|
|
687085
687757
|
];
|
|
687086
687758
|
const sponsorPaths = [
|
|
687087
|
-
|
|
687759
|
+
join168(homedir57(), ".omnius", "sponsor-cache.json")
|
|
687088
687760
|
];
|
|
687089
687761
|
for (const p2 of sponsorPaths) {
|
|
687090
|
-
if (!
|
|
687762
|
+
if (!existsSync157(p2)) continue;
|
|
687091
687763
|
try {
|
|
687092
|
-
const raw = JSON.parse(
|
|
687764
|
+
const raw = JSON.parse(readFileSync128(p2, "utf-8"));
|
|
687093
687765
|
const list = Array.isArray(raw) ? raw : raw?.sponsors ?? [];
|
|
687094
687766
|
for (const s2 of list) {
|
|
687095
687767
|
suppliers.push({
|
|
@@ -687242,6 +687914,9 @@ var init_routes_v1 = __esm({
|
|
|
687242
687914
|
init_command_registry();
|
|
687243
687915
|
init_profiles();
|
|
687244
687916
|
init_direct_tool_registry();
|
|
687917
|
+
init_external_tool_registry();
|
|
687918
|
+
init_external_tool_dispatch();
|
|
687919
|
+
init_external_tool_eval();
|
|
687245
687920
|
init_dist();
|
|
687246
687921
|
PROBLEM_BASE2 = "https://omnius.nexus/problems";
|
|
687247
687922
|
P2 = {
|
|
@@ -697850,15 +698525,55 @@ function getOpenApiSpec() {
|
|
|
697850
698525
|
responses: { 200: { description: "Paginated tools with security metadata" } }
|
|
697851
698526
|
}
|
|
697852
698527
|
},
|
|
698528
|
+
"/v1/tools/register": {
|
|
698529
|
+
post: {
|
|
698530
|
+
summary: "Register an application-specific external tool (run scope)",
|
|
698531
|
+
tags: ["Tools"],
|
|
698532
|
+
description: 'Unified registration contract for agents integrating Omnius into their stack. Body: {name, description, parameters (JSON schema, type:object), security?, transport}. `transport` is discriminated: {type:"http", callback_url, auth_header?, headers?, timeout_ms?, result_path?} — Omnius POSTs {name, args, session_id} to callback_url; OR {type:"mcp", server, tool, connect?:{url, transport, headers}} — proxies to a named tool on an MCP server, auto-connecting when `connect` is supplied. Registered tools are persisted per working directory (.omnius/external-tools.json) and appear in GET /v1/tools alongside built-ins. Names that collide with built-ins are rejected (409). Remote callers require admin scope.',
|
|
698533
|
+
responses: {
|
|
698534
|
+
201: { description: "Registered (new)" },
|
|
698535
|
+
200: { description: "Registered (replaced existing)" },
|
|
698536
|
+
400: { description: "Invalid manifest" },
|
|
698537
|
+
403: { description: "Forbidden — run/admin scope required" },
|
|
698538
|
+
409: { description: "Name collides with a built-in tool" },
|
|
698539
|
+
502: { description: "MCP server connect failed" }
|
|
698540
|
+
}
|
|
698541
|
+
}
|
|
698542
|
+
},
|
|
697853
698543
|
"/v1/tools/{name}": {
|
|
697854
698544
|
get: {
|
|
697855
698545
|
summary: "Single tool schema + security policy",
|
|
697856
698546
|
tags: ["Tools"],
|
|
697857
698547
|
parameters: [{ name: "name", in: "path", required: true, schema: { type: "string" }, description: "Tool name (snake_case, e.g. file_read)" }],
|
|
697858
698548
|
responses: {
|
|
697859
|
-
200: { description: "Tool entry with security info" },
|
|
698549
|
+
200: { description: "Tool entry with security info (built-in or external)" },
|
|
697860
698550
|
404: { description: "Unknown tool name" }
|
|
697861
698551
|
}
|
|
698552
|
+
},
|
|
698553
|
+
delete: {
|
|
698554
|
+
summary: "Unregister an external tool (run scope)",
|
|
698555
|
+
tags: ["Tools"],
|
|
698556
|
+
description: "Removes an externally-registered tool from the per-working-directory registry. Built-in tools are immutable and return 404.",
|
|
698557
|
+
parameters: [{ name: "name", in: "path", required: true, schema: { type: "string" } }],
|
|
698558
|
+
responses: {
|
|
698559
|
+
200: { description: "Unregistered" },
|
|
698560
|
+
403: { description: "Forbidden — run/admin scope required" },
|
|
698561
|
+
404: { description: "No external tool with that name" }
|
|
698562
|
+
}
|
|
698563
|
+
}
|
|
698564
|
+
},
|
|
698565
|
+
"/v1/tools/{name}/eval": {
|
|
698566
|
+
post: {
|
|
698567
|
+
summary: "Evaluate an external tool against test cases (dev cycle)",
|
|
698568
|
+
tags: ["Tools"],
|
|
698569
|
+
description: "Runs the registered tool for each case and scores it — the dev-cycle complement to /v1/evaluate (which scores agent runs). Body: {cases: [{name?, args, expect?}]}. `expect` supports {success, output_contains, output_equals, output_matches}. Returns per-case pass/fail plus {total, passed, failed, pass_rate, duration_ms}.",
|
|
698570
|
+
parameters: [{ name: "name", in: "path", required: true, schema: { type: "string" } }],
|
|
698571
|
+
responses: {
|
|
698572
|
+
200: { description: "Eval report" },
|
|
698573
|
+
400: { description: "Missing/empty cases" },
|
|
698574
|
+
403: { description: "Forbidden — run/admin scope required" },
|
|
698575
|
+
404: { description: "No external tool with that name" }
|
|
698576
|
+
}
|
|
697862
698577
|
}
|
|
697863
698578
|
},
|
|
697864
698579
|
"/v1/tools/{name}/call": {
|
|
@@ -698333,15 +699048,15 @@ var init_auth_oidc = __esm({
|
|
|
698333
699048
|
});
|
|
698334
699049
|
|
|
698335
699050
|
// packages/cli/src/api/usage-tracker.ts
|
|
698336
|
-
import { mkdirSync as
|
|
698337
|
-
import { join as
|
|
699051
|
+
import { mkdirSync as mkdirSync99, readFileSync as readFileSync129, writeFileSync as writeFileSync84, existsSync as existsSync158 } from "node:fs";
|
|
699052
|
+
import { join as join169 } from "node:path";
|
|
698338
699053
|
function initUsageTracker(omniusDir) {
|
|
698339
|
-
const dir =
|
|
698340
|
-
|
|
698341
|
-
usageFile =
|
|
699054
|
+
const dir = join169(omniusDir, "usage");
|
|
699055
|
+
mkdirSync99(dir, { recursive: true });
|
|
699056
|
+
usageFile = join169(dir, "token-usage.json");
|
|
698342
699057
|
try {
|
|
698343
|
-
if (
|
|
698344
|
-
store = JSON.parse(
|
|
699058
|
+
if (existsSync158(usageFile)) {
|
|
699059
|
+
store = JSON.parse(readFileSync129(usageFile, "utf-8"));
|
|
698345
699060
|
}
|
|
698346
699061
|
} catch {
|
|
698347
699062
|
store = { providers: {}, lastSaved: "" };
|
|
@@ -698377,7 +699092,7 @@ function flush2() {
|
|
|
698377
699092
|
if (!initialized2 || !dirty) return;
|
|
698378
699093
|
try {
|
|
698379
699094
|
store.lastSaved = (/* @__PURE__ */ new Date()).toISOString();
|
|
698380
|
-
|
|
699095
|
+
writeFileSync84(usageFile, JSON.stringify(store, null, 2), "utf-8");
|
|
698381
699096
|
dirty = false;
|
|
698382
699097
|
} catch {
|
|
698383
699098
|
}
|
|
@@ -698552,23 +699267,23 @@ var init_chat_followup = __esm({
|
|
|
698552
699267
|
|
|
698553
699268
|
// packages/cli/src/docker.ts
|
|
698554
699269
|
import { execSync as execSync59, spawn as spawn32 } from "node:child_process";
|
|
698555
|
-
import { existsSync as
|
|
698556
|
-
import { join as
|
|
699270
|
+
import { existsSync as existsSync159, mkdirSync as mkdirSync100, writeFileSync as writeFileSync85 } from "node:fs";
|
|
699271
|
+
import { join as join170, resolve as resolve65, dirname as dirname50 } from "node:path";
|
|
698557
699272
|
import { homedir as homedir58 } from "node:os";
|
|
698558
699273
|
import { fileURLToPath as fileURLToPath19 } from "node:url";
|
|
698559
699274
|
function getDockerDir() {
|
|
698560
699275
|
try {
|
|
698561
699276
|
if (typeof __dirname !== "undefined") {
|
|
698562
|
-
return
|
|
699277
|
+
return join170(__dirname, "..", "..", "..", "docker");
|
|
698563
699278
|
}
|
|
698564
699279
|
} catch {
|
|
698565
699280
|
}
|
|
698566
699281
|
try {
|
|
698567
699282
|
const thisDir = dirname50(fileURLToPath19(import.meta.url));
|
|
698568
|
-
return
|
|
699283
|
+
return join170(thisDir, "..", "..", "..", "docker");
|
|
698569
699284
|
} catch {
|
|
698570
699285
|
}
|
|
698571
|
-
return
|
|
699286
|
+
return join170(process.cwd(), "docker");
|
|
698572
699287
|
}
|
|
698573
699288
|
function isDockerAvailable() {
|
|
698574
699289
|
try {
|
|
@@ -698699,11 +699414,11 @@ async function ensureOmniusImage(force = false) {
|
|
|
698699
699414
|
}
|
|
698700
699415
|
let buildContext;
|
|
698701
699416
|
const dockerDir = getDockerDir();
|
|
698702
|
-
if (
|
|
699417
|
+
if (existsSync159(join170(dockerDir, "Dockerfile"))) {
|
|
698703
699418
|
buildContext = dockerDir;
|
|
698704
699419
|
} else {
|
|
698705
|
-
buildContext =
|
|
698706
|
-
|
|
699420
|
+
buildContext = join170(homedir58(), ".omnius", "docker-build");
|
|
699421
|
+
mkdirSync100(buildContext, { recursive: true });
|
|
698707
699422
|
writeDockerfiles(buildContext);
|
|
698708
699423
|
}
|
|
698709
699424
|
try {
|
|
@@ -698777,8 +699492,8 @@ chown -R node:node /workspace /home/node/.omnius 2>/dev/null || true
|
|
|
698777
699492
|
if [ "$1" = "omnius" ]; then shift; exec su - node -c "cd /workspace && omnius $*"; fi
|
|
698778
699493
|
exec "$@"
|
|
698779
699494
|
`;
|
|
698780
|
-
|
|
698781
|
-
|
|
699495
|
+
writeFileSync85(join170(dir, "Dockerfile"), dockerfile);
|
|
699496
|
+
writeFileSync85(join170(dir, "docker-entrypoint.sh"), entrypoint, { mode: 493 });
|
|
698782
699497
|
}
|
|
698783
699498
|
function hasNvidiaGpu() {
|
|
698784
699499
|
try {
|
|
@@ -698851,7 +699566,7 @@ __export(embedding_workers_exports, {
|
|
|
698851
699566
|
startEmbeddingWorkers: () => startEmbeddingWorkers,
|
|
698852
699567
|
stopEmbeddingWorkers: () => stopEmbeddingWorkers
|
|
698853
699568
|
});
|
|
698854
|
-
import { basename as basename38, join as
|
|
699569
|
+
import { basename as basename38, join as join171 } from "node:path";
|
|
698855
699570
|
function startEmbeddingWorkers(opts) {
|
|
698856
699571
|
if (_running) return;
|
|
698857
699572
|
_running = true;
|
|
@@ -698917,8 +699632,8 @@ async function runEmbeddingTask(modality, episodeId, taskId, opts) {
|
|
|
698917
699632
|
try {
|
|
698918
699633
|
if (!_aligner) {
|
|
698919
699634
|
const stateRoot = process.env.OMNIUS_DIR || process.cwd();
|
|
698920
|
-
const omniusDir = basename38(stateRoot) === ".omnius" ? stateRoot :
|
|
698921
|
-
const memDir =
|
|
699635
|
+
const omniusDir = basename38(stateRoot) === ".omnius" ? stateRoot : join171(stateRoot, ".omnius");
|
|
699636
|
+
const memDir = join171(omniusDir, "memory");
|
|
698922
699637
|
_aligner = new EmbeddingAligner(
|
|
698923
699638
|
`${modality}-${emb.length}`,
|
|
698924
699639
|
// e.g. "visual-512"
|
|
@@ -699033,18 +699748,18 @@ import * as http5 from "node:http";
|
|
|
699033
699748
|
import * as https3 from "node:https";
|
|
699034
699749
|
import { createRequire as createRequire8 } from "node:module";
|
|
699035
699750
|
import { fileURLToPath as fileURLToPath20 } from "node:url";
|
|
699036
|
-
import { dirname as dirname51, join as
|
|
699751
|
+
import { dirname as dirname51, join as join172, resolve as resolve66 } from "node:path";
|
|
699037
699752
|
import { homedir as homedir59 } from "node:os";
|
|
699038
699753
|
import { spawn as spawn33, execSync as execSync60 } from "node:child_process";
|
|
699039
699754
|
import {
|
|
699040
699755
|
createReadStream as createReadStream2,
|
|
699041
|
-
mkdirSync as
|
|
699042
|
-
writeFileSync as
|
|
699043
|
-
readFileSync as
|
|
699756
|
+
mkdirSync as mkdirSync101,
|
|
699757
|
+
writeFileSync as writeFileSync86,
|
|
699758
|
+
readFileSync as readFileSync130,
|
|
699044
699759
|
readdirSync as readdirSync56,
|
|
699045
|
-
existsSync as
|
|
699760
|
+
existsSync as existsSync160,
|
|
699046
699761
|
watch as fsWatch4,
|
|
699047
|
-
renameSync as
|
|
699762
|
+
renameSync as renameSync15,
|
|
699048
699763
|
unlinkSync as unlinkSync34,
|
|
699049
699764
|
statSync as statSync56,
|
|
699050
699765
|
openSync as openSync6,
|
|
@@ -699054,25 +699769,25 @@ import {
|
|
|
699054
699769
|
import { randomBytes as randomBytes28, randomUUID as randomUUID21, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
699055
699770
|
import { createHash as createHash43 } from "node:crypto";
|
|
699056
699771
|
function memoryDbPaths3(baseDir = process.cwd()) {
|
|
699057
|
-
const dir =
|
|
699772
|
+
const dir = join172(baseDir, ".omnius");
|
|
699058
699773
|
return {
|
|
699059
699774
|
dir,
|
|
699060
|
-
episodes:
|
|
699061
|
-
knowledge:
|
|
699775
|
+
episodes: join172(dir, "episodes.db"),
|
|
699776
|
+
knowledge: join172(dir, "knowledge.db")
|
|
699062
699777
|
};
|
|
699063
699778
|
}
|
|
699064
699779
|
function getVersion3() {
|
|
699065
699780
|
try {
|
|
699066
699781
|
const thisDir = dirname51(fileURLToPath20(import.meta.url));
|
|
699067
699782
|
const candidates = [
|
|
699068
|
-
|
|
699069
|
-
|
|
699070
|
-
|
|
699783
|
+
join172(thisDir, "..", "package.json"),
|
|
699784
|
+
join172(thisDir, "..", "..", "package.json"),
|
|
699785
|
+
join172(thisDir, "..", "..", "..", "package.json")
|
|
699071
699786
|
];
|
|
699072
699787
|
for (const pkgPath of candidates) {
|
|
699073
699788
|
try {
|
|
699074
|
-
if (!
|
|
699075
|
-
const pkg = JSON.parse(
|
|
699789
|
+
if (!existsSync160(pkgPath)) continue;
|
|
699790
|
+
const pkg = JSON.parse(readFileSync130(pkgPath, "utf8"));
|
|
699076
699791
|
if (pkg.name === "omnius" || pkg.name === "@omnius/cli" || pkg.name === "@omnius/monorepo") {
|
|
699077
699792
|
return pkg.version ?? "0.0.0";
|
|
699078
699793
|
}
|
|
@@ -699486,9 +700201,9 @@ function isOriginAllowed(origin) {
|
|
|
699486
700201
|
if (!origin) return true;
|
|
699487
700202
|
let accessMode = (process.env["OMNIUS_ACCESS"] || "").toLowerCase().trim();
|
|
699488
700203
|
try {
|
|
699489
|
-
const accessFile =
|
|
699490
|
-
if (
|
|
699491
|
-
const persisted =
|
|
700204
|
+
const accessFile = join172(homedir59(), ".omnius", "access");
|
|
700205
|
+
if (existsSync160(accessFile)) {
|
|
700206
|
+
const persisted = readFileSync130(accessFile, "utf8").trim().toLowerCase();
|
|
699492
700207
|
if (persisted === "any" || persisted === "lan" || persisted === "loopback") {
|
|
699493
700208
|
accessMode = persisted;
|
|
699494
700209
|
}
|
|
@@ -700332,28 +701047,28 @@ function ollamaStream(ollamaUrl, path12, method, body, onData, onEnd, onError, t
|
|
|
700332
701047
|
}
|
|
700333
701048
|
function jobsDir() {
|
|
700334
701049
|
const root = resolve66(process.cwd());
|
|
700335
|
-
const dir =
|
|
700336
|
-
|
|
701050
|
+
const dir = join172(root, ".omnius", "jobs");
|
|
701051
|
+
mkdirSync101(dir, { recursive: true });
|
|
700337
701052
|
return dir;
|
|
700338
701053
|
}
|
|
700339
701054
|
function loadJob(id) {
|
|
700340
|
-
const file =
|
|
700341
|
-
if (!
|
|
701055
|
+
const file = join172(jobsDir(), `${id}.json`);
|
|
701056
|
+
if (!existsSync160(file)) return null;
|
|
700342
701057
|
try {
|
|
700343
|
-
return JSON.parse(
|
|
701058
|
+
return JSON.parse(readFileSync130(file, "utf-8"));
|
|
700344
701059
|
} catch {
|
|
700345
701060
|
return null;
|
|
700346
701061
|
}
|
|
700347
701062
|
}
|
|
700348
701063
|
function listJobs2() {
|
|
700349
701064
|
const dir = jobsDir();
|
|
700350
|
-
if (!
|
|
701065
|
+
if (!existsSync160(dir)) return [];
|
|
700351
701066
|
const files = readdirSync56(dir).filter((f2) => f2.endsWith(".json")).sort();
|
|
700352
701067
|
const jobs = [];
|
|
700353
701068
|
for (const file of files) {
|
|
700354
701069
|
try {
|
|
700355
701070
|
jobs.push(
|
|
700356
|
-
JSON.parse(
|
|
701071
|
+
JSON.parse(readFileSync130(join172(dir, file), "utf-8"))
|
|
700357
701072
|
);
|
|
700358
701073
|
} catch {
|
|
700359
701074
|
}
|
|
@@ -700364,14 +701079,14 @@ function pruneOldJobs() {
|
|
|
700364
701079
|
const retentionH = parseFloat(process.env["OMNIUS_RUN_RETENTION_H"] || "24");
|
|
700365
701080
|
const cutoffMs = Date.now() - (Number.isFinite(retentionH) && retentionH > 0 ? retentionH : 24) * 36e5;
|
|
700366
701081
|
const dir = jobsDir();
|
|
700367
|
-
if (!
|
|
701082
|
+
if (!existsSync160(dir)) return { pruned: 0, kept: 0 };
|
|
700368
701083
|
let pruned = 0;
|
|
700369
701084
|
let kept = 0;
|
|
700370
701085
|
for (const file of readdirSync56(dir)) {
|
|
700371
701086
|
if (!file.endsWith(".json")) continue;
|
|
700372
|
-
const path12 =
|
|
701087
|
+
const path12 = join172(dir, file);
|
|
700373
701088
|
try {
|
|
700374
|
-
const job = JSON.parse(
|
|
701089
|
+
const job = JSON.parse(readFileSync130(path12, "utf-8"));
|
|
700375
701090
|
if (job.status === "running") {
|
|
700376
701091
|
kept++;
|
|
700377
701092
|
continue;
|
|
@@ -700384,7 +701099,7 @@ function pruneOldJobs() {
|
|
|
700384
701099
|
} catch {
|
|
700385
701100
|
}
|
|
700386
701101
|
const outFile = path12.replace(/\.json$/, ".output");
|
|
700387
|
-
if (
|
|
701102
|
+
if (existsSync160(outFile)) {
|
|
700388
701103
|
try {
|
|
700389
701104
|
unlinkSync34(outFile);
|
|
700390
701105
|
} catch {
|
|
@@ -700697,14 +701412,14 @@ function autoSeedTodosFromPrompt(prompt) {
|
|
|
700697
701412
|
return [];
|
|
700698
701413
|
}
|
|
700699
701414
|
function atomicJobWrite(dir, id, job) {
|
|
700700
|
-
const finalPath =
|
|
701415
|
+
const finalPath = join172(dir, `${id}.json`);
|
|
700701
701416
|
const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}`;
|
|
700702
701417
|
try {
|
|
700703
|
-
|
|
700704
|
-
|
|
701418
|
+
writeFileSync86(tmpPath, JSON.stringify(job, null, 2), "utf-8");
|
|
701419
|
+
renameSync15(tmpPath, finalPath);
|
|
700705
701420
|
} catch {
|
|
700706
701421
|
try {
|
|
700707
|
-
|
|
701422
|
+
writeFileSync86(finalPath, JSON.stringify(job, null, 2), "utf-8");
|
|
700708
701423
|
} catch {
|
|
700709
701424
|
}
|
|
700710
701425
|
try {
|
|
@@ -702516,28 +703231,28 @@ ${task}` : task;
|
|
|
702516
703231
|
});
|
|
702517
703232
|
}
|
|
702518
703233
|
function updateStateFile() {
|
|
702519
|
-
return
|
|
703234
|
+
return join172(homedir59(), ".omnius", "update-state.json");
|
|
702520
703235
|
}
|
|
702521
703236
|
function updateLogPath() {
|
|
702522
|
-
return
|
|
703237
|
+
return join172(homedir59(), ".omnius", "update.log");
|
|
702523
703238
|
}
|
|
702524
703239
|
function readUpdateState() {
|
|
702525
703240
|
try {
|
|
702526
703241
|
const p2 = updateStateFile();
|
|
702527
|
-
if (!
|
|
702528
|
-
return JSON.parse(
|
|
703242
|
+
if (!existsSync160(p2)) return null;
|
|
703243
|
+
return JSON.parse(readFileSync130(p2, "utf-8"));
|
|
702529
703244
|
} catch {
|
|
702530
703245
|
return null;
|
|
702531
703246
|
}
|
|
702532
703247
|
}
|
|
702533
703248
|
function writeUpdateState(state) {
|
|
702534
703249
|
try {
|
|
702535
|
-
const dir =
|
|
702536
|
-
|
|
703250
|
+
const dir = join172(homedir59(), ".omnius");
|
|
703251
|
+
mkdirSync101(dir, { recursive: true });
|
|
702537
703252
|
const finalPath = updateStateFile();
|
|
702538
703253
|
const tmpPath = `${finalPath}.tmp.${process.pid}`;
|
|
702539
|
-
|
|
702540
|
-
|
|
703254
|
+
writeFileSync86(tmpPath, JSON.stringify(state, null, 2), "utf-8");
|
|
703255
|
+
renameSync15(tmpPath, finalPath);
|
|
702541
703256
|
} catch {
|
|
702542
703257
|
}
|
|
702543
703258
|
}
|
|
@@ -702584,15 +703299,15 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
702584
703299
|
const { execSync: es } = require4("node:child_process");
|
|
702585
703300
|
const isWin2 = process.platform === "win32";
|
|
702586
703301
|
let npmBin = "";
|
|
702587
|
-
for (const candidate of isWin2 ? [
|
|
702588
|
-
if (
|
|
703302
|
+
for (const candidate of isWin2 ? [join172(nodeDir, "npm.cmd"), join172(nodeDir, "npm")] : [join172(nodeDir, "npm"), "/usr/local/bin/npm", "/usr/bin/npm"]) {
|
|
703303
|
+
if (existsSync160(candidate)) {
|
|
702589
703304
|
npmBin = candidate;
|
|
702590
703305
|
break;
|
|
702591
703306
|
}
|
|
702592
703307
|
}
|
|
702593
703308
|
if (!npmBin) npmBin = isWin2 ? "npm.cmd" : "npm";
|
|
702594
703309
|
const pkgSpec = `omnius@${targetVersion}`;
|
|
702595
|
-
const dir =
|
|
703310
|
+
const dir = join172(homedir59(), ".omnius");
|
|
702596
703311
|
fs11.mkdirSync(dir, { recursive: true });
|
|
702597
703312
|
const logFd = fs11.openSync(logPath3, "w");
|
|
702598
703313
|
const npmPrefix = dirname51(nodeDir);
|
|
@@ -702606,7 +703321,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
702606
703321
|
}).trim();
|
|
702607
703322
|
} else {
|
|
702608
703323
|
const npmCliCandidates = [
|
|
702609
|
-
|
|
703324
|
+
join172(
|
|
702610
703325
|
nodeDir,
|
|
702611
703326
|
"..",
|
|
702612
703327
|
"lib",
|
|
@@ -702615,7 +703330,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
702615
703330
|
"bin",
|
|
702616
703331
|
"npm-cli.js"
|
|
702617
703332
|
),
|
|
702618
|
-
|
|
703333
|
+
join172(
|
|
702619
703334
|
npmBin,
|
|
702620
703335
|
"..",
|
|
702621
703336
|
"..",
|
|
@@ -702629,7 +703344,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
702629
703344
|
let npmCli = "";
|
|
702630
703345
|
for (const c8 of npmCliCandidates) {
|
|
702631
703346
|
try {
|
|
702632
|
-
if (
|
|
703347
|
+
if (existsSync160(c8)) {
|
|
702633
703348
|
npmCli = c8;
|
|
702634
703349
|
break;
|
|
702635
703350
|
}
|
|
@@ -702674,8 +703389,8 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
702674
703389
|
);
|
|
702675
703390
|
} else {
|
|
702676
703391
|
const npmCliCandidates = [
|
|
702677
|
-
|
|
702678
|
-
|
|
703392
|
+
join172(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
|
|
703393
|
+
join172(
|
|
702679
703394
|
npmBin,
|
|
702680
703395
|
"..",
|
|
702681
703396
|
"..",
|
|
@@ -702689,7 +703404,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
702689
703404
|
let npmCli = "";
|
|
702690
703405
|
for (const c8 of npmCliCandidates) {
|
|
702691
703406
|
try {
|
|
702692
|
-
if (
|
|
703407
|
+
if (existsSync160(c8)) {
|
|
702693
703408
|
npmCli = c8;
|
|
702694
703409
|
break;
|
|
702695
703410
|
}
|
|
@@ -702829,8 +703544,8 @@ function handleV1UpdateStatus(res) {
|
|
|
702829
703544
|
let logTail = "";
|
|
702830
703545
|
let exitCode = null;
|
|
702831
703546
|
try {
|
|
702832
|
-
if (
|
|
702833
|
-
const raw =
|
|
703547
|
+
if (existsSync160(logPath3)) {
|
|
703548
|
+
const raw = readFileSync130(logPath3, "utf-8");
|
|
702834
703549
|
const m2 = raw.match(/__EXIT_CODE=(\d+)/);
|
|
702835
703550
|
if (m2) exitCode = parseInt(m2[1], 10);
|
|
702836
703551
|
logTail = raw.slice(-2e3);
|
|
@@ -702954,8 +703669,8 @@ async function handleV1Run(req3, res) {
|
|
|
702954
703669
|
if (workingDir) {
|
|
702955
703670
|
cwd4 = resolve66(workingDir);
|
|
702956
703671
|
} else if (isolate) {
|
|
702957
|
-
const wsDir =
|
|
702958
|
-
|
|
703672
|
+
const wsDir = join172(dir, "..", "workspaces", id);
|
|
703673
|
+
mkdirSync101(wsDir, { recursive: true });
|
|
702959
703674
|
cwd4 = wsDir;
|
|
702960
703675
|
} else {
|
|
702961
703676
|
cwd4 = resolve66(process.cwd());
|
|
@@ -703190,7 +703905,7 @@ async function handleV1Run(req3, res) {
|
|
|
703190
703905
|
let output = "";
|
|
703191
703906
|
let tailBytes = 0;
|
|
703192
703907
|
const TAIL_BUDGET = 1048576;
|
|
703193
|
-
const outputWriter = new DiskTaskOutput(
|
|
703908
|
+
const outputWriter = new DiskTaskOutput(join172(dir, `${id}.output`));
|
|
703194
703909
|
job.outputFile = outputWriter.path;
|
|
703195
703910
|
atomicJobWrite(dir, id, job);
|
|
703196
703911
|
child.stdout?.on("data", (chunk) => {
|
|
@@ -703416,7 +704131,7 @@ function handleV1RunsById(res, id) {
|
|
|
703416
704131
|
}
|
|
703417
704132
|
const outputFile = job.outputFile;
|
|
703418
704133
|
const enriched = { ...job };
|
|
703419
|
-
if (outputFile &&
|
|
704134
|
+
if (outputFile && existsSync160(outputFile)) {
|
|
703420
704135
|
try {
|
|
703421
704136
|
const size = statSync56(outputFile).size;
|
|
703422
704137
|
const tailSize = Math.min(size, 4096);
|
|
@@ -704387,7 +705102,7 @@ async function handleRequest(req3, res, ollamaUrl, verbose, runtimeDefaults = {}
|
|
|
704387
705102
|
}
|
|
704388
705103
|
try {
|
|
704389
705104
|
const target = resolve66(rawPath);
|
|
704390
|
-
if (!
|
|
705105
|
+
if (!existsSync160(target)) {
|
|
704391
705106
|
jsonResponse(res, 404, { error: "File not found", path: target });
|
|
704392
705107
|
return;
|
|
704393
705108
|
}
|
|
@@ -704614,12 +705329,12 @@ async function handleRequest(req3, res, ollamaUrl, verbose, runtimeDefaults = {}
|
|
|
704614
705329
|
}
|
|
704615
705330
|
for (const e2 of entries) {
|
|
704616
705331
|
if (!e2.isDirectory()) continue;
|
|
704617
|
-
const child =
|
|
704618
|
-
const omniusDir =
|
|
705332
|
+
const child = join172(dir, e2.name);
|
|
705333
|
+
const omniusDir = join172(child, ".omnius");
|
|
704619
705334
|
try {
|
|
704620
705335
|
if (statSync56(omniusDir).isDirectory()) {
|
|
704621
705336
|
const name10 = e2.name;
|
|
704622
|
-
const prefsFile =
|
|
705337
|
+
const prefsFile = join172(omniusDir, "config.json");
|
|
704623
705338
|
let lastSeen = 0;
|
|
704624
705339
|
try {
|
|
704625
705340
|
lastSeen = statSync56(prefsFile).mtimeMs;
|
|
@@ -704673,12 +705388,12 @@ async function handleRequest(req3, res, ollamaUrl, verbose, runtimeDefaults = {}
|
|
|
704673
705388
|
}
|
|
704674
705389
|
for (const e2 of entries) {
|
|
704675
705390
|
if (!e2.isDirectory()) continue;
|
|
704676
|
-
const child =
|
|
704677
|
-
const omniusDir =
|
|
705391
|
+
const child = join172(dir, e2.name);
|
|
705392
|
+
const omniusDir = join172(child, ".omnius");
|
|
704678
705393
|
try {
|
|
704679
705394
|
if (statSync56(omniusDir).isDirectory()) {
|
|
704680
705395
|
const name10 = e2.name;
|
|
704681
|
-
const prefsFile =
|
|
705396
|
+
const prefsFile = join172(omniusDir, "config.json");
|
|
704682
705397
|
let lastSeen = 0;
|
|
704683
705398
|
try {
|
|
704684
705399
|
lastSeen = statSync56(prefsFile).mtimeMs;
|
|
@@ -704886,13 +705601,13 @@ async function handleRequest(req3, res, ollamaUrl, verbose, runtimeDefaults = {}
|
|
|
704886
705601
|
return;
|
|
704887
705602
|
}
|
|
704888
705603
|
const { tmpdir: tmpdir24 } = await import("node:os");
|
|
704889
|
-
const { writeFileSync:
|
|
705604
|
+
const { writeFileSync: writeFileSync91, unlinkSync: unlinkSync35 } = await import("node:fs");
|
|
704890
705605
|
const { join: pjoin } = await import("node:path");
|
|
704891
705606
|
const tmpPath = pjoin(
|
|
704892
705607
|
tmpdir24(),
|
|
704893
705608
|
`omnius-clone-upload-${Date.now()}-${safeName3}`
|
|
704894
705609
|
);
|
|
704895
|
-
|
|
705610
|
+
writeFileSync91(tmpPath, buf);
|
|
704896
705611
|
try {
|
|
704897
705612
|
const ve = getVoiceEngine();
|
|
704898
705613
|
const msg = await ve.setCloneVoice(tmpPath);
|
|
@@ -705616,7 +706331,7 @@ data: ${JSON.stringify(data)}
|
|
|
705616
706331
|
}
|
|
705617
706332
|
for (const f2 of seenFiles) {
|
|
705618
706333
|
try {
|
|
705619
|
-
|
|
706334
|
+
writeFileSync86(f2, JSON.stringify({ tasks: [] }, null, 2));
|
|
705620
706335
|
deleted++;
|
|
705621
706336
|
} catch {
|
|
705622
706337
|
}
|
|
@@ -707292,7 +708007,7 @@ ${historyLines}
|
|
|
707292
708007
|
function getScheduleRoots() {
|
|
707293
708008
|
const rootsEnv = process.env["OMNIUS_SCHEDULE_ROOTS"] || "";
|
|
707294
708009
|
const roots = rootsEnv.split(rootsEnv.includes(";") ? ";" : ":").filter(Boolean);
|
|
707295
|
-
const defaults3 = [process.cwd(),
|
|
708010
|
+
const defaults3 = [process.cwd(), join172(homedir59(), "Documents")];
|
|
707296
708011
|
const set = /* @__PURE__ */ new Set([...defaults3, ...roots]);
|
|
707297
708012
|
return [...set];
|
|
707298
708013
|
}
|
|
@@ -707307,10 +708022,10 @@ function listScheduledTasks() {
|
|
|
707307
708022
|
root,
|
|
707308
708023
|
0,
|
|
707309
708024
|
(dir) => {
|
|
707310
|
-
if (dir.endsWith(`${
|
|
707311
|
-
const file =
|
|
708025
|
+
if (dir.endsWith(`${join172(".omnius", "scheduled")}`) || dir.includes(`${join172(".omnius", "scheduled")}`)) {
|
|
708026
|
+
const file = join172(dir, "tasks.json");
|
|
707312
708027
|
try {
|
|
707313
|
-
const raw =
|
|
708028
|
+
const raw = readFileSync130(file, "utf-8");
|
|
707314
708029
|
const json = JSON.parse(raw);
|
|
707315
708030
|
const tasks = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
|
|
707316
708031
|
tasks.forEach((t2, i2) => {
|
|
@@ -707399,7 +708114,7 @@ function walk(dir, depth, onDir, maxDepth) {
|
|
|
707399
708114
|
if (e2.name === "node_modules" || e2.name.startsWith(".")) {
|
|
707400
708115
|
if (e2.name !== ".omnius") continue;
|
|
707401
708116
|
}
|
|
707402
|
-
const child =
|
|
708117
|
+
const child = join172(dir, e2.name);
|
|
707403
708118
|
walk(child, depth + 1, onDir, maxDepth);
|
|
707404
708119
|
}
|
|
707405
708120
|
}
|
|
@@ -707408,18 +708123,18 @@ function setScheduledEnabled(id, enabled2) {
|
|
|
707408
708123
|
const target = tasks.find((t2) => t2.id === id);
|
|
707409
708124
|
if (!target) return false;
|
|
707410
708125
|
try {
|
|
707411
|
-
const raw =
|
|
708126
|
+
const raw = readFileSync130(target.file, "utf-8");
|
|
707412
708127
|
const json = JSON.parse(raw);
|
|
707413
708128
|
const arr = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
|
|
707414
708129
|
if (!arr[target.index]) return false;
|
|
707415
708130
|
arr[target.index].enabled = enabled2;
|
|
707416
708131
|
if (Array.isArray(json?.tasks)) {
|
|
707417
708132
|
json.tasks = arr;
|
|
707418
|
-
|
|
708133
|
+
writeFileSync86(target.file, JSON.stringify(json, null, 2));
|
|
707419
708134
|
} else if (Array.isArray(json)) {
|
|
707420
|
-
|
|
708135
|
+
writeFileSync86(target.file, JSON.stringify(arr, null, 2));
|
|
707421
708136
|
} else {
|
|
707422
|
-
|
|
708137
|
+
writeFileSync86(target.file, JSON.stringify({ tasks: arr }, null, 2));
|
|
707423
708138
|
}
|
|
707424
708139
|
if (!enabled2) {
|
|
707425
708140
|
try {
|
|
@@ -707441,7 +708156,7 @@ function deleteScheduledById(id) {
|
|
|
707441
708156
|
const target = tasks.find((t2) => t2.id === id);
|
|
707442
708157
|
if (!target) return false;
|
|
707443
708158
|
try {
|
|
707444
|
-
const raw =
|
|
708159
|
+
const raw = readFileSync130(target.file, "utf-8");
|
|
707445
708160
|
const json = JSON.parse(raw);
|
|
707446
708161
|
const arr = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
|
|
707447
708162
|
if (!arr[target.index]) return false;
|
|
@@ -707449,11 +708164,11 @@ function deleteScheduledById(id) {
|
|
|
707449
708164
|
arr.splice(target.index, 1);
|
|
707450
708165
|
if (Array.isArray(json?.tasks)) {
|
|
707451
708166
|
json.tasks = arr;
|
|
707452
|
-
|
|
708167
|
+
writeFileSync86(target.file, JSON.stringify(json, null, 2));
|
|
707453
708168
|
} else if (Array.isArray(json)) {
|
|
707454
|
-
|
|
708169
|
+
writeFileSync86(target.file, JSON.stringify(arr, null, 2));
|
|
707455
708170
|
} else {
|
|
707456
|
-
|
|
708171
|
+
writeFileSync86(target.file, JSON.stringify({ tasks: arr }, null, 2));
|
|
707457
708172
|
}
|
|
707458
708173
|
const candidates = [];
|
|
707459
708174
|
if (id) candidates.push(id);
|
|
@@ -707662,11 +708377,11 @@ function reconcileScheduledTasks(apply) {
|
|
|
707662
708377
|
const errors = [];
|
|
707663
708378
|
for (const f2 of found) {
|
|
707664
708379
|
const wdir = f2.workingDir || process.cwd();
|
|
707665
|
-
const file =
|
|
708380
|
+
const file = join172(wdir, ".omnius", "scheduled", "tasks.json");
|
|
707666
708381
|
try {
|
|
707667
708382
|
let json = { tasks: [] };
|
|
707668
708383
|
try {
|
|
707669
|
-
const raw =
|
|
708384
|
+
const raw = readFileSync130(file, "utf-8");
|
|
707670
708385
|
json = JSON.parse(raw);
|
|
707671
708386
|
} catch {
|
|
707672
708387
|
}
|
|
@@ -707683,11 +708398,11 @@ function reconcileScheduledTasks(apply) {
|
|
|
707683
708398
|
};
|
|
707684
708399
|
arr.push(entry);
|
|
707685
708400
|
const toWrite = Array.isArray(json?.tasks) ? { ...json, tasks: arr } : Array.isArray(json) ? arr : { tasks: arr };
|
|
707686
|
-
|
|
707687
|
-
|
|
708401
|
+
mkdirSync101(join172(wdir, ".omnius", "scheduled"), { recursive: true });
|
|
708402
|
+
mkdirSync101(join172(wdir, ".omnius", "scheduled", "logs"), {
|
|
707688
708403
|
recursive: true
|
|
707689
708404
|
});
|
|
707690
|
-
|
|
708405
|
+
writeFileSync86(file, JSON.stringify(toWrite, null, 2));
|
|
707691
708406
|
adopted.push({ file, index: arr.length - 1 });
|
|
707692
708407
|
}
|
|
707693
708408
|
} else {
|
|
@@ -707760,32 +708475,32 @@ function writeCrontabLines(lines) {
|
|
|
707760
708475
|
}
|
|
707761
708476
|
function canonicalCronLine(rec) {
|
|
707762
708477
|
const omniusBin = findOmniusBinary4();
|
|
707763
|
-
const logDir =
|
|
707764
|
-
const logFile =
|
|
707765
|
-
const storeFile =
|
|
708478
|
+
const logDir = join172(rec.workingDir, ".omnius", "scheduled", "logs");
|
|
708479
|
+
const logFile = join172(logDir, `${rec.id}.log`);
|
|
708480
|
+
const storeFile = join172(rec.workingDir, ".omnius", "scheduled", "tasks.json");
|
|
707766
708481
|
const taskEsc = rec.task.replace(/'/g, "'\\''");
|
|
707767
|
-
const lockDir =
|
|
707768
|
-
const lockPath =
|
|
708482
|
+
const lockDir = join172(rec.workingDir, ".omnius", "run");
|
|
708483
|
+
const lockPath = join172(lockDir, `${rec.id}.lock`);
|
|
707769
708484
|
const wrapper = [
|
|
707770
708485
|
`cd ${JSON.stringify(rec.workingDir)}`,
|
|
707771
708486
|
`mkdir -p ${JSON.stringify(logDir)}`,
|
|
707772
708487
|
`mkdir -p ${JSON.stringify(lockDir)}`,
|
|
707773
708488
|
`if mkdir ${JSON.stringify(lockPath)} 2>/dev/null; then`,
|
|
707774
|
-
` echo $$ > ${JSON.stringify(
|
|
708489
|
+
` echo $$ > ${JSON.stringify(join172(lockPath, "pid"))}`,
|
|
707775
708490
|
` trap 'rm -rf ${lockPath}' EXIT`,
|
|
707776
708491
|
`else`,
|
|
707777
|
-
` if [ -f ${JSON.stringify(
|
|
707778
|
-
` oldpid=$(cat ${JSON.stringify(
|
|
708492
|
+
` if [ -f ${JSON.stringify(join172(lockPath, "pid"))} ]; then`,
|
|
708493
|
+
` oldpid=$(cat ${JSON.stringify(join172(lockPath, "pid"))} 2>/dev/null || echo)`,
|
|
707779
708494
|
` if [ -n "$oldpid" ] && kill -0 "$oldpid" 2>/dev/null; then`,
|
|
707780
708495
|
` echo "[omnius-scheduler] ${rec.id} already running as PID $oldpid; skipping" >> ${JSON.stringify(logFile)}`,
|
|
707781
708496
|
` exit 0`,
|
|
707782
708497
|
` else`,
|
|
707783
708498
|
` rm -rf ${JSON.stringify(lockPath)} 2>/dev/null || true`,
|
|
707784
|
-
` mkdir -p ${JSON.stringify(lockPath)} && echo $$ > ${JSON.stringify(
|
|
708499
|
+
` mkdir -p ${JSON.stringify(lockPath)} && echo $$ > ${JSON.stringify(join172(lockPath, "pid"))} && trap 'rm -rf ${lockPath}' EXIT`,
|
|
707785
708500
|
` fi`,
|
|
707786
708501
|
` else`,
|
|
707787
708502
|
` rm -rf ${JSON.stringify(lockPath)} 2>/dev/null || true`,
|
|
707788
|
-
` mkdir -p ${JSON.stringify(lockPath)} && echo $$ > ${JSON.stringify(
|
|
708503
|
+
` mkdir -p ${JSON.stringify(lockPath)} && echo $$ > ${JSON.stringify(join172(lockPath, "pid"))} && trap 'rm -rf ${lockPath}' EXIT`,
|
|
707789
708504
|
` fi`,
|
|
707790
708505
|
`fi`,
|
|
707791
708506
|
`lease_id="cron-agent-$(date +%s)-$$"`,
|
|
@@ -707827,9 +708542,9 @@ function fixupOrMigrateScheduled(mode, dryRun) {
|
|
|
707827
708542
|
try {
|
|
707828
708543
|
if (!f2.workingDir || !f2.task) continue;
|
|
707829
708544
|
const unitBase = `omnius-${f2.id}`;
|
|
707830
|
-
const unitDir =
|
|
707831
|
-
const svc =
|
|
707832
|
-
const tim =
|
|
708545
|
+
const unitDir = join172(homedir59(), ".config", "systemd", "user");
|
|
708546
|
+
const svc = join172(unitDir, `${unitBase}.service`);
|
|
708547
|
+
const tim = join172(unitDir, `${unitBase}.timer`);
|
|
707833
708548
|
const omniusBin = findOmniusBinary4();
|
|
707834
708549
|
const rec = {
|
|
707835
708550
|
id: f2.id,
|
|
@@ -707864,9 +708579,9 @@ Persistent=true
|
|
|
707864
708579
|
WantedBy=timers.target
|
|
707865
708580
|
`;
|
|
707866
708581
|
if (!dryRun) {
|
|
707867
|
-
|
|
707868
|
-
|
|
707869
|
-
|
|
708582
|
+
mkdirSync101(unitDir, { recursive: true });
|
|
708583
|
+
writeFileSync86(svc, svcText);
|
|
708584
|
+
writeFileSync86(tim, timText);
|
|
707870
708585
|
try {
|
|
707871
708586
|
const { execSync: es } = require4("node:child_process");
|
|
707872
708587
|
es("systemctl --user daemon-reload", { stdio: "pipe" });
|
|
@@ -707981,8 +708696,8 @@ function startApiServer(options2 = {}) {
|
|
|
707981
708696
|
const config = loadConfig();
|
|
707982
708697
|
const ollamaUrl = options2.ollamaUrl ?? config.backendUrl;
|
|
707983
708698
|
const cwd4 = process.cwd();
|
|
707984
|
-
initAuditLog(
|
|
707985
|
-
initUsageTracker(
|
|
708699
|
+
initAuditLog(join172(cwd4, ".omnius"));
|
|
708700
|
+
initUsageTracker(join172(cwd4, ".omnius"));
|
|
707986
708701
|
try {
|
|
707987
708702
|
const taskMgr = getSharedTaskManager();
|
|
707988
708703
|
taskMgr.setEventPublisher((type, data, opts) => {
|
|
@@ -708035,7 +708750,7 @@ function startApiServer(options2 = {}) {
|
|
|
708035
708750
|
try {
|
|
708036
708751
|
const dir = todoDir();
|
|
708037
708752
|
try {
|
|
708038
|
-
|
|
708753
|
+
mkdirSync101(dir, { recursive: true });
|
|
708039
708754
|
} catch {
|
|
708040
708755
|
}
|
|
708041
708756
|
const cache8 = /* @__PURE__ */ new Map();
|
|
@@ -708045,7 +708760,7 @@ function startApiServer(options2 = {}) {
|
|
|
708045
708760
|
const sid = f2.replace(/\.json$/, "");
|
|
708046
708761
|
try {
|
|
708047
708762
|
const items = JSON.parse(
|
|
708048
|
-
|
|
708763
|
+
readFileSync130(join172(dir, f2), "utf-8")
|
|
708049
708764
|
);
|
|
708050
708765
|
if (Array.isArray(items)) {
|
|
708051
708766
|
cache8.set(sid, new Map(items.map((t2) => [t2.id, t2])));
|
|
@@ -708059,10 +708774,10 @@ function startApiServer(options2 = {}) {
|
|
|
708059
708774
|
if (!fname || !fname.endsWith(".json") || fname.includes(".tmp."))
|
|
708060
708775
|
return;
|
|
708061
708776
|
const sid = fname.replace(/\.json$/, "");
|
|
708062
|
-
const fp =
|
|
708777
|
+
const fp = join172(dir, fname);
|
|
708063
708778
|
let next = [];
|
|
708064
708779
|
try {
|
|
708065
|
-
if (!
|
|
708780
|
+
if (!existsSync160(fp)) {
|
|
708066
708781
|
const old = cache8.get(sid);
|
|
708067
708782
|
if (old) {
|
|
708068
708783
|
for (const t2 of old.values()) {
|
|
@@ -708079,7 +708794,7 @@ function startApiServer(options2 = {}) {
|
|
|
708079
708794
|
}
|
|
708080
708795
|
return;
|
|
708081
708796
|
}
|
|
708082
|
-
next = JSON.parse(
|
|
708797
|
+
next = JSON.parse(readFileSync130(fp, "utf-8"));
|
|
708083
708798
|
if (!Array.isArray(next)) return;
|
|
708084
708799
|
} catch {
|
|
708085
708800
|
return;
|
|
@@ -708135,14 +708850,14 @@ function startApiServer(options2 = {}) {
|
|
|
708135
708850
|
);
|
|
708136
708851
|
if (!apiTestMode && retentionDays > 0) {
|
|
708137
708852
|
try {
|
|
708138
|
-
const jobsDir3 =
|
|
708139
|
-
if (
|
|
708853
|
+
const jobsDir3 = join172(cwd4, ".omnius", "jobs");
|
|
708854
|
+
if (existsSync160(jobsDir3)) {
|
|
708140
708855
|
const cutoff = Date.now() - retentionDays * 864e5;
|
|
708141
708856
|
for (const f2 of readdirSync56(jobsDir3)) {
|
|
708142
708857
|
if (!f2.endsWith(".json")) continue;
|
|
708143
708858
|
try {
|
|
708144
|
-
const jobPath =
|
|
708145
|
-
const job = JSON.parse(
|
|
708859
|
+
const jobPath = join172(jobsDir3, f2);
|
|
708860
|
+
const job = JSON.parse(readFileSync130(jobPath, "utf-8"));
|
|
708146
708861
|
const jobTime = new Date(
|
|
708147
708862
|
job.startedAt ?? job.completedAt ?? 0
|
|
708148
708863
|
).getTime();
|
|
@@ -708164,8 +708879,8 @@ function startApiServer(options2 = {}) {
|
|
|
708164
708879
|
if (useTls) {
|
|
708165
708880
|
try {
|
|
708166
708881
|
tlsOpts = {
|
|
708167
|
-
cert:
|
|
708168
|
-
key:
|
|
708882
|
+
cert: readFileSync130(resolve66(tlsCert)),
|
|
708883
|
+
key: readFileSync130(resolve66(tlsKey))
|
|
708169
708884
|
};
|
|
708170
708885
|
} catch (e2) {
|
|
708171
708886
|
log22(`
|
|
@@ -708176,9 +708891,9 @@ function startApiServer(options2 = {}) {
|
|
|
708176
708891
|
}
|
|
708177
708892
|
let runtimeAccessMode = resolveAccessMode(process.env["OMNIUS_ACCESS"], host);
|
|
708178
708893
|
try {
|
|
708179
|
-
const accessFile =
|
|
708180
|
-
if (
|
|
708181
|
-
const persisted =
|
|
708894
|
+
const accessFile = join172(homedir59(), ".omnius", "access");
|
|
708895
|
+
if (existsSync160(accessFile)) {
|
|
708896
|
+
const persisted = readFileSync130(accessFile, "utf8").trim();
|
|
708182
708897
|
const resolved = resolveAccessMode(persisted, host);
|
|
708183
708898
|
if (resolved) runtimeAccessMode = resolved;
|
|
708184
708899
|
}
|
|
@@ -708248,10 +708963,10 @@ function startApiServer(options2 = {}) {
|
|
|
708248
708963
|
const previous = runtimeAccessMode;
|
|
708249
708964
|
runtimeAccessMode = requested;
|
|
708250
708965
|
try {
|
|
708251
|
-
const dir =
|
|
708252
|
-
|
|
708253
|
-
|
|
708254
|
-
|
|
708966
|
+
const dir = join172(homedir59(), ".omnius");
|
|
708967
|
+
mkdirSync101(dir, { recursive: true });
|
|
708968
|
+
writeFileSync86(
|
|
708969
|
+
join172(dir, "access"),
|
|
708255
708970
|
`${runtimeAccessMode}
|
|
708256
708971
|
`,
|
|
708257
708972
|
"utf8"
|
|
@@ -708607,9 +709322,9 @@ function startApiServer(options2 = {}) {
|
|
|
708607
709322
|
try {
|
|
708608
709323
|
const here = dirname51(fileURLToPath20(import.meta.url));
|
|
708609
709324
|
for (const rel of ["../package.json", "../../package.json", "../../../package.json", "../../../../package.json"]) {
|
|
708610
|
-
const p2 =
|
|
708611
|
-
if (
|
|
708612
|
-
const pkg = JSON.parse(
|
|
709325
|
+
const p2 = join172(here, rel);
|
|
709326
|
+
if (existsSync160(p2)) {
|
|
709327
|
+
const pkg = JSON.parse(readFileSync130(p2, "utf8"));
|
|
708613
709328
|
if (pkg.name === "omnius" || pkg.name === "@omnius/cli" || pkg.name === "@omnius/monorepo") {
|
|
708614
709329
|
return pkg.version ?? null;
|
|
708615
709330
|
}
|
|
@@ -708663,8 +709378,8 @@ function startApiServer(options2 = {}) {
|
|
|
708663
709378
|
}
|
|
708664
709379
|
try {
|
|
708665
709380
|
const {
|
|
708666
|
-
writeFileSync:
|
|
708667
|
-
mkdirSync:
|
|
709381
|
+
writeFileSync: writeFileSync91,
|
|
709382
|
+
mkdirSync: mkdirSync106,
|
|
708668
709383
|
existsSync: _exists,
|
|
708669
709384
|
readFileSync: _rfs
|
|
708670
709385
|
} = require4("node:fs");
|
|
@@ -708701,8 +709416,8 @@ function startApiServer(options2 = {}) {
|
|
|
708701
709416
|
let written = 0;
|
|
708702
709417
|
for (const dir of dirSet) {
|
|
708703
709418
|
try {
|
|
708704
|
-
if (!_exists(dir))
|
|
708705
|
-
|
|
709419
|
+
if (!_exists(dir)) mkdirSync106(dir, { recursive: true });
|
|
709420
|
+
writeFileSync91(_join(dir, "api-port.json"), apiHint);
|
|
708706
709421
|
written++;
|
|
708707
709422
|
} catch {
|
|
708708
709423
|
}
|
|
@@ -709065,13 +709780,13 @@ async function handleChatAttachmentUpload(req3, res) {
|
|
|
709065
709780
|
return;
|
|
709066
709781
|
}
|
|
709067
709782
|
const safeName3 = filename.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 180) || `attachment-${Date.now()}.bin`;
|
|
709068
|
-
const dir =
|
|
709069
|
-
|
|
709070
|
-
const localPath =
|
|
709783
|
+
const dir = join172(process.cwd(), ".omnius", "gui-attachments");
|
|
709784
|
+
mkdirSync101(dir, { recursive: true });
|
|
709785
|
+
const localPath = join172(
|
|
709071
709786
|
dir,
|
|
709072
709787
|
`${Date.now()}-${randomUUID21().slice(0, 8)}-${safeName3}`
|
|
709073
709788
|
);
|
|
709074
|
-
|
|
709789
|
+
writeFileSync86(localPath, Buffer.from(base642, "base64"));
|
|
709075
709790
|
const mimeType = typeof b.mimeType === "string" ? b.mimeType : typeof b.mime_type === "string" ? b.mime_type : "";
|
|
709076
709791
|
const isImage = mimeType.toLowerCase().startsWith("image/") || /\.(png|jpe?g|gif|webp|bmp|tiff?)$/i.test(safeName3);
|
|
709077
709792
|
const sessionId = typeof b.sessionId === "string" ? b.sessionId : typeof b.session_id === "string" ? b.session_id : void 0;
|
|
@@ -709557,15 +710272,15 @@ __export(clipboard_media_exports, {
|
|
|
709557
710272
|
pasteClipboardImageToFile: () => pasteClipboardImageToFile
|
|
709558
710273
|
});
|
|
709559
710274
|
import { execFileSync as execFileSync11, execSync as execSync61 } from "node:child_process";
|
|
709560
|
-
import { mkdirSync as
|
|
709561
|
-
import { join as
|
|
710275
|
+
import { mkdirSync as mkdirSync102, readFileSync as readFileSync131, rmSync as rmSync13, writeFileSync as writeFileSync87 } from "node:fs";
|
|
710276
|
+
import { join as join173 } from "node:path";
|
|
709562
710277
|
function pasteClipboardImageToFile(repoRoot) {
|
|
709563
710278
|
const image = readClipboardImage();
|
|
709564
710279
|
if (!image) return null;
|
|
709565
|
-
const dir =
|
|
709566
|
-
|
|
709567
|
-
const path12 =
|
|
709568
|
-
|
|
710280
|
+
const dir = join173(repoRoot, ".omnius", "clipboard");
|
|
710281
|
+
mkdirSync102(dir, { recursive: true });
|
|
710282
|
+
const path12 = join173(dir, `clipboard-${Date.now()}${image.ext}`);
|
|
710283
|
+
writeFileSync87(path12, image.buffer);
|
|
709569
710284
|
return { path: path12, buffer: image.buffer, mime: image.mime };
|
|
709570
710285
|
}
|
|
709571
710286
|
function readClipboardImage() {
|
|
@@ -709574,7 +710289,7 @@ function readClipboardImage() {
|
|
|
709574
710289
|
execSync61("command -v pngpaste", { stdio: "ignore", timeout: 1e3 });
|
|
709575
710290
|
const tmp = `/tmp/omnius-clipboard-${Date.now()}.png`;
|
|
709576
710291
|
execFileSync11("pngpaste", [tmp], { timeout: 3e3 });
|
|
709577
|
-
const buffer2 =
|
|
710292
|
+
const buffer2 = readFileSync131(tmp);
|
|
709578
710293
|
try {
|
|
709579
710294
|
rmSync13(tmp);
|
|
709580
710295
|
} catch {
|
|
@@ -709629,19 +710344,19 @@ var init_clipboard_media = __esm({
|
|
|
709629
710344
|
|
|
709630
710345
|
// packages/cli/src/tui/interactive.ts
|
|
709631
710346
|
import { cwd } from "node:process";
|
|
709632
|
-
import { resolve as resolve67, join as
|
|
710347
|
+
import { resolve as resolve67, join as join174, dirname as dirname52, extname as extname22, relative as relative17, sep as sep5 } from "node:path";
|
|
709633
710348
|
import { createRequire as createRequire9 } from "node:module";
|
|
709634
710349
|
import { fileURLToPath as fileURLToPath21 } from "node:url";
|
|
709635
710350
|
import {
|
|
709636
|
-
readFileSync as
|
|
709637
|
-
writeFileSync as
|
|
710351
|
+
readFileSync as readFileSync132,
|
|
710352
|
+
writeFileSync as writeFileSync88,
|
|
709638
710353
|
appendFileSync as appendFileSync17,
|
|
709639
710354
|
rmSync as rmSync14,
|
|
709640
710355
|
readdirSync as readdirSync57,
|
|
709641
710356
|
statSync as statSync57,
|
|
709642
|
-
mkdirSync as
|
|
710357
|
+
mkdirSync as mkdirSync103
|
|
709643
710358
|
} from "node:fs";
|
|
709644
|
-
import { existsSync as
|
|
710359
|
+
import { existsSync as existsSync161 } from "node:fs";
|
|
709645
710360
|
import { execSync as execSync62 } from "node:child_process";
|
|
709646
710361
|
import { homedir as homedir60 } from "node:os";
|
|
709647
710362
|
function formatTimeAgo2(date) {
|
|
@@ -709659,12 +710374,12 @@ function getVersion4() {
|
|
|
709659
710374
|
const require5 = createRequire9(import.meta.url);
|
|
709660
710375
|
const thisDir = dirname52(fileURLToPath21(import.meta.url));
|
|
709661
710376
|
const candidates = [
|
|
709662
|
-
|
|
709663
|
-
|
|
709664
|
-
|
|
710377
|
+
join174(thisDir, "..", "package.json"),
|
|
710378
|
+
join174(thisDir, "..", "..", "package.json"),
|
|
710379
|
+
join174(thisDir, "..", "..", "..", "package.json")
|
|
709665
710380
|
];
|
|
709666
710381
|
for (const pkgPath of candidates) {
|
|
709667
|
-
if (
|
|
710382
|
+
if (existsSync161(pkgPath)) {
|
|
709668
710383
|
const pkg = require5(pkgPath);
|
|
709669
710384
|
if (pkg.name === "omnius" || pkg.name === "@omnius/cli" || pkg.name === "@omnius/monorepo") {
|
|
709670
710385
|
return pkg.version ?? "0.0.0";
|
|
@@ -710684,7 +711399,7 @@ function createFanoutExploreTool(config, repoRoot, ctxWindowSize) {
|
|
|
710684
711399
|
if (regions.length === 0) {
|
|
710685
711400
|
const listDir = (rel) => {
|
|
710686
711401
|
try {
|
|
710687
|
-
return readdirSync57(
|
|
711402
|
+
return readdirSync57(join174(repoRoot, rel), { withFileTypes: true }).map(
|
|
710688
711403
|
(d2) => ({ name: d2.name, isDir: d2.isDirectory() })
|
|
710689
711404
|
);
|
|
710690
711405
|
} catch {
|
|
@@ -710755,8 +711470,8 @@ function createFanoutExploreTool(config, repoRoot, ctxWindowSize) {
|
|
|
710755
711470
|
);
|
|
710756
711471
|
if (debug) {
|
|
710757
711472
|
try {
|
|
710758
|
-
|
|
710759
|
-
|
|
711473
|
+
writeFileSync88(
|
|
711474
|
+
join174(repoRoot, ".omnius", "fanout-debug.json"),
|
|
710760
711475
|
JSON.stringify({ objective, regions, rawReturns, digests }, null, 2)
|
|
710761
711476
|
);
|
|
710762
711477
|
} catch {
|
|
@@ -711016,14 +711731,14 @@ Meta-critique: quality ${meta.quality}/5, thorough: ${meta.thorough}`;
|
|
|
711016
711731
|
function gatherMemorySnippets(root) {
|
|
711017
711732
|
const snippets = [];
|
|
711018
711733
|
const dirs = [
|
|
711019
|
-
|
|
711020
|
-
|
|
711734
|
+
join174(root, ".omnius", "memory"),
|
|
711735
|
+
join174(root, ".omnius", "memory")
|
|
711021
711736
|
];
|
|
711022
711737
|
for (const dir of dirs) {
|
|
711023
|
-
if (!
|
|
711738
|
+
if (!existsSync161(dir)) continue;
|
|
711024
711739
|
try {
|
|
711025
711740
|
for (const f2 of readdirSync57(dir).filter((f3) => f3.endsWith(".json"))) {
|
|
711026
|
-
const data = JSON.parse(
|
|
711741
|
+
const data = JSON.parse(readFileSync132(join174(dir, f2), "utf-8"));
|
|
711027
711742
|
for (const val of Object.values(data)) {
|
|
711028
711743
|
const v = typeof val === "object" && val !== null && "value" in val ? String(val.value) : String(val);
|
|
711029
711744
|
if (v.length > 10) snippets.push(v);
|
|
@@ -711279,7 +711994,7 @@ function extractGeneratedAudioPath(output, repoRoot) {
|
|
|
711279
711994
|
const match = output.match(/(?:Sound|Music|TTS) generated:\s+([^\n\r]+)/i);
|
|
711280
711995
|
const raw = match?.[1]?.trim().replace(/^["']|["']$/g, "");
|
|
711281
711996
|
if (!raw) return null;
|
|
711282
|
-
return raw.startsWith("/") || raw.startsWith("~") ? raw.replace(/^~(?=\/)/, homedir60()) :
|
|
711997
|
+
return raw.startsWith("/") || raw.startsWith("~") ? raw.replace(/^~(?=\/)/, homedir60()) : join174(repoRoot, raw);
|
|
711283
711998
|
}
|
|
711284
711999
|
async function playGeneratedAudioForToolResult(toolName, output, repoRoot, writer) {
|
|
711285
712000
|
if (!toolName || !["generate_audio", "generate_tts", "audio_playback"].includes(toolName) || !output)
|
|
@@ -711457,9 +712172,9 @@ ${metabolismMemories}
|
|
|
711457
712172
|
}
|
|
711458
712173
|
if (!realtimeEnabled)
|
|
711459
712174
|
try {
|
|
711460
|
-
const archeFile =
|
|
711461
|
-
if (
|
|
711462
|
-
const variants = JSON.parse(
|
|
712175
|
+
const archeFile = join174(repoRoot, ".omnius", "arche", "variants.json");
|
|
712176
|
+
if (existsSync161(archeFile)) {
|
|
712177
|
+
const variants = JSON.parse(readFileSync132(archeFile, "utf8"));
|
|
711463
712178
|
if (variants.length > 0) {
|
|
711464
712179
|
let filtered = variants;
|
|
711465
712180
|
if (taskType) {
|
|
@@ -711709,14 +712424,14 @@ RULES:
|
|
|
711709
712424
|
const compactionThreshold = Number.isFinite(envOverride) && envOverride > 0 ? envOverride : modelTier2 === "small" ? 12e3 : modelTier2 === "medium" ? 24e3 : 4e4;
|
|
711710
712425
|
let identityInjection = "";
|
|
711711
712426
|
try {
|
|
711712
|
-
const ikStateFile =
|
|
712427
|
+
const ikStateFile = join174(
|
|
711713
712428
|
repoRoot,
|
|
711714
712429
|
".omnius",
|
|
711715
712430
|
"identity",
|
|
711716
712431
|
"self-state.json"
|
|
711717
712432
|
);
|
|
711718
|
-
if (
|
|
711719
|
-
const selfState = JSON.parse(
|
|
712433
|
+
if (existsSync161(ikStateFile)) {
|
|
712434
|
+
const selfState = JSON.parse(readFileSync132(ikStateFile, "utf8"));
|
|
711720
712435
|
const lines = [
|
|
711721
712436
|
`[Identity State v${selfState.version}]`,
|
|
711722
712437
|
`Self: ${selfState.narrative_summary}`,
|
|
@@ -712054,17 +712769,17 @@ Review its full output via sub_agent(action='output', id='${id}')`
|
|
|
712054
712769
|
}
|
|
712055
712770
|
}
|
|
712056
712771
|
try {
|
|
712057
|
-
const { readdirSync: readdirSync59, readFileSync:
|
|
712772
|
+
const { readdirSync: readdirSync59, readFileSync: readFileSync134, existsSync: existsSync164 } = await import("node:fs");
|
|
712058
712773
|
const { join: pathJoin } = await import("node:path");
|
|
712059
712774
|
const chunksDir = pathJoin(cwd(), ".omnius", "todo-chunks");
|
|
712060
|
-
if (
|
|
712775
|
+
if (existsSync164(chunksDir)) {
|
|
712061
712776
|
const files = readdirSync59(chunksDir).filter(
|
|
712062
712777
|
(f2) => f2.endsWith(".json")
|
|
712063
712778
|
);
|
|
712064
712779
|
for (const f2 of files) {
|
|
712065
712780
|
try {
|
|
712066
712781
|
const data = JSON.parse(
|
|
712067
|
-
|
|
712782
|
+
readFileSync134(pathJoin(chunksDir, f2), "utf-8")
|
|
712068
712783
|
);
|
|
712069
712784
|
if (data._deleted) continue;
|
|
712070
712785
|
if ((data.functionalSummary || "").toLowerCase().includes(q) || (data.detailSummary || "").toLowerCase().includes(q) || (data.keyFiles || []).some(
|
|
@@ -712130,11 +712845,11 @@ ${lines.join("\n")}`
|
|
|
712130
712845
|
const expand2 = args.expand === true;
|
|
712131
712846
|
if (expand2 && id.startsWith("todo-ctx-")) {
|
|
712132
712847
|
try {
|
|
712133
|
-
const { readFileSync:
|
|
712848
|
+
const { readFileSync: readFileSync134, existsSync: existsSync164 } = await import("node:fs");
|
|
712134
712849
|
const { join: pathJoin } = await import("node:path");
|
|
712135
712850
|
const chunksDir = pathJoin(cwd(), ".omnius", "todo-chunks");
|
|
712136
712851
|
const todoIdSuffix = id.replace("todo-ctx-", "");
|
|
712137
|
-
const files =
|
|
712852
|
+
const files = existsSync164(chunksDir) ? (await import("node:fs")).readdirSync(chunksDir).filter((f2) => f2.endsWith(".json")) : [];
|
|
712138
712853
|
let chunkData = null;
|
|
712139
712854
|
for (const f2 of files) {
|
|
712140
712855
|
try {
|
|
@@ -713135,13 +713850,13 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
713135
713850
|
});
|
|
713136
713851
|
}
|
|
713137
713852
|
try {
|
|
713138
|
-
const ikDir =
|
|
713139
|
-
const ikFile =
|
|
713853
|
+
const ikDir = join174(repoRoot, ".omnius", "identity");
|
|
713854
|
+
const ikFile = join174(ikDir, "self-state.json");
|
|
713140
713855
|
let ikState;
|
|
713141
|
-
if (
|
|
713142
|
-
ikState = JSON.parse(
|
|
713856
|
+
if (existsSync161(ikFile)) {
|
|
713857
|
+
ikState = JSON.parse(readFileSync132(ikFile, "utf8"));
|
|
713143
713858
|
} else {
|
|
713144
|
-
|
|
713859
|
+
mkdirSync103(ikDir, { recursive: true });
|
|
713145
713860
|
const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
713146
713861
|
ikState = {
|
|
713147
713862
|
self_id: `omnius-${machineId}`,
|
|
@@ -713257,7 +713972,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
713257
713972
|
}
|
|
713258
713973
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
713259
713974
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
713260
|
-
|
|
713975
|
+
writeFileSync88(ikFile, JSON.stringify(ikState, null, 2));
|
|
713261
713976
|
} catch (ikErr) {
|
|
713262
713977
|
try {
|
|
713263
713978
|
console.error("[IK-OBSERVE]", ikErr);
|
|
@@ -713289,14 +714004,14 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
713289
714004
|
tokens
|
|
713290
714005
|
);
|
|
713291
714006
|
try {
|
|
713292
|
-
const ikFile =
|
|
714007
|
+
const ikFile = join174(
|
|
713293
714008
|
repoRoot,
|
|
713294
714009
|
".omnius",
|
|
713295
714010
|
"identity",
|
|
713296
714011
|
"self-state.json"
|
|
713297
714012
|
);
|
|
713298
|
-
if (
|
|
713299
|
-
const ikState = JSON.parse(
|
|
714013
|
+
if (existsSync161(ikFile)) {
|
|
714014
|
+
const ikState = JSON.parse(readFileSync132(ikFile, "utf8"));
|
|
713300
714015
|
if (!ikState.stats) ikState.stats = { queries_served: 0 };
|
|
713301
714016
|
ikState.stats.queries_served = (ikState.stats.queries_served || 0) + 1;
|
|
713302
714017
|
ikState.homeostasis.uncertainty = Math.min(
|
|
@@ -713318,7 +714033,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
713318
714033
|
ikState.version_history = ikState.version_history.slice(-200);
|
|
713319
714034
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
713320
714035
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
713321
|
-
|
|
714036
|
+
writeFileSync88(ikFile, JSON.stringify(ikState, null, 2));
|
|
713322
714037
|
}
|
|
713323
714038
|
} catch {
|
|
713324
714039
|
}
|
|
@@ -713618,10 +714333,10 @@ async function startInteractive(config, repoPath2) {
|
|
|
713618
714333
|
process.stdin.pause();
|
|
713619
714334
|
}
|
|
713620
714335
|
try {
|
|
713621
|
-
const omniusDir =
|
|
713622
|
-
const nexusPidFile =
|
|
713623
|
-
if (
|
|
713624
|
-
const pid = parseInt(
|
|
714336
|
+
const omniusDir = join174(repoRoot, ".omnius");
|
|
714337
|
+
const nexusPidFile = join174(omniusDir, "nexus", "daemon.pid");
|
|
714338
|
+
if (existsSync161(nexusPidFile)) {
|
|
714339
|
+
const pid = parseInt(readFileSync132(nexusPidFile, "utf8").trim(), 10);
|
|
713625
714340
|
if (pid > 0) {
|
|
713626
714341
|
try {
|
|
713627
714342
|
process.kill(pid, 0);
|
|
@@ -714340,7 +715055,7 @@ ${result.summary}`
|
|
|
714340
715055
|
let p2pGateway = null;
|
|
714341
715056
|
let peerMesh = null;
|
|
714342
715057
|
let inferenceRouter = null;
|
|
714343
|
-
const secretVault = new SecretVault(
|
|
715058
|
+
const secretVault = new SecretVault(join174(repoRoot, ".omnius", "vault.enc"));
|
|
714344
715059
|
let adminSessionKey = null;
|
|
714345
715060
|
const callSubAgents = /* @__PURE__ */ new Map();
|
|
714346
715061
|
void Promise.resolve().then(() => (init_syntax_highlight(), syntax_highlight_exports)).then((m2) => m2.prewarm()).catch(() => {
|
|
@@ -714663,22 +715378,22 @@ Respond to the scoped Telegram target when complete.`
|
|
|
714663
715378
|
const out = [];
|
|
714664
715379
|
const pushJsonFiles = (dir, prefix) => {
|
|
714665
715380
|
try {
|
|
714666
|
-
if (!
|
|
715381
|
+
if (!existsSync161(dir)) return;
|
|
714667
715382
|
for (const file of readdirSync57(dir)) {
|
|
714668
715383
|
if (!file.endsWith(".json")) continue;
|
|
714669
715384
|
const id = file.replace(/\.json$/, "");
|
|
714670
|
-
out.push({ id: `${prefix}:${id}`, label: id, path:
|
|
715385
|
+
out.push({ id: `${prefix}:${id}`, label: id, path: join174(dir, file) });
|
|
714671
715386
|
}
|
|
714672
715387
|
} catch {
|
|
714673
715388
|
}
|
|
714674
715389
|
};
|
|
714675
|
-
pushJsonFiles(
|
|
715390
|
+
pushJsonFiles(join174(repoRoot, ".omnius", "checkpoints"), "turn");
|
|
714676
715391
|
try {
|
|
714677
|
-
const sessionDir2 =
|
|
714678
|
-
if (
|
|
715392
|
+
const sessionDir2 = join174(repoRoot, ".omnius", "session");
|
|
715393
|
+
if (existsSync161(sessionDir2)) {
|
|
714679
715394
|
for (const entry of readdirSync57(sessionDir2)) {
|
|
714680
|
-
const cp2 =
|
|
714681
|
-
if (
|
|
715395
|
+
const cp2 = join174(sessionDir2, entry, "checkpoint.json");
|
|
715396
|
+
if (existsSync161(cp2))
|
|
714682
715397
|
out.push({ id: `session:${entry}`, label: entry, path: cp2 });
|
|
714683
715398
|
}
|
|
714684
715399
|
}
|
|
@@ -714768,9 +715483,9 @@ This is an independent background session started from /background.`
|
|
|
714768
715483
|
return id;
|
|
714769
715484
|
};
|
|
714770
715485
|
try {
|
|
714771
|
-
const titleFile =
|
|
714772
|
-
if (
|
|
714773
|
-
sessionTitle =
|
|
715486
|
+
const titleFile = join174(repoRoot, ".omnius", "session-title");
|
|
715487
|
+
if (existsSync161(titleFile))
|
|
715488
|
+
sessionTitle = readFileSync132(titleFile, "utf8").trim() || null;
|
|
714774
715489
|
} catch {
|
|
714775
715490
|
}
|
|
714776
715491
|
let carouselRetired = isResumed;
|
|
@@ -714848,7 +715563,7 @@ This is an independent background session started from /background.`
|
|
|
714848
715563
|
const completions = [];
|
|
714849
715564
|
for (const entry of entries) {
|
|
714850
715565
|
if (!entry.startsWith(partialName)) continue;
|
|
714851
|
-
const full =
|
|
715566
|
+
const full = join174(searchDir, entry);
|
|
714852
715567
|
try {
|
|
714853
715568
|
const st = statSync57(full);
|
|
714854
715569
|
const suffix = st.isDirectory() ? "/" : "";
|
|
@@ -714879,13 +715594,13 @@ This is an independent background session started from /background.`
|
|
|
714879
715594
|
);
|
|
714880
715595
|
return [hits, line];
|
|
714881
715596
|
}
|
|
714882
|
-
const HISTORY_DIR =
|
|
714883
|
-
const HISTORY_FILE =
|
|
715597
|
+
const HISTORY_DIR = join174(homedir60(), ".omnius");
|
|
715598
|
+
const HISTORY_FILE = join174(HISTORY_DIR, "repl-history");
|
|
714884
715599
|
const MAX_HISTORY_LINES = 500;
|
|
714885
715600
|
let savedHistory = [];
|
|
714886
715601
|
try {
|
|
714887
|
-
if (
|
|
714888
|
-
const raw =
|
|
715602
|
+
if (existsSync161(HISTORY_FILE)) {
|
|
715603
|
+
const raw = readFileSync132(HISTORY_FILE, "utf8").trim();
|
|
714889
715604
|
if (raw) savedHistory = raw.split("\n").reverse();
|
|
714890
715605
|
}
|
|
714891
715606
|
} catch {
|
|
@@ -715037,12 +715752,12 @@ This is an independent background session started from /background.`
|
|
|
715037
715752
|
function persistHistoryLine(line) {
|
|
715038
715753
|
if (!line.trim()) return;
|
|
715039
715754
|
try {
|
|
715040
|
-
|
|
715755
|
+
mkdirSync103(HISTORY_DIR, { recursive: true });
|
|
715041
715756
|
appendFileSync17(HISTORY_FILE, line + "\n", "utf8");
|
|
715042
715757
|
if (Math.random() < 0.02) {
|
|
715043
|
-
const all2 =
|
|
715758
|
+
const all2 = readFileSync132(HISTORY_FILE, "utf8").trim().split("\n");
|
|
715044
715759
|
if (all2.length > MAX_HISTORY_LINES) {
|
|
715045
|
-
|
|
715760
|
+
writeFileSync88(
|
|
715046
715761
|
HISTORY_FILE,
|
|
715047
715762
|
all2.slice(-MAX_HISTORY_LINES).join("\n") + "\n",
|
|
715048
715763
|
"utf8"
|
|
@@ -715251,10 +715966,10 @@ This is an independent background session started from /background.`
|
|
|
715251
715966
|
const { unlinkSync: _rmStale } = await import("node:fs");
|
|
715252
715967
|
const { homedir: _hdir } = await import("node:os");
|
|
715253
715968
|
for (const dp of [
|
|
715254
|
-
|
|
715255
|
-
|
|
715969
|
+
join174(repoRoot, ".omnius", "nexus", "nexus-daemon.mjs"),
|
|
715970
|
+
join174(_hdir(), ".omnius", "nexus", "nexus-daemon.mjs")
|
|
715256
715971
|
]) {
|
|
715257
|
-
if (
|
|
715972
|
+
if (existsSync161(dp))
|
|
715258
715973
|
try {
|
|
715259
715974
|
_rmStale(dp);
|
|
715260
715975
|
} catch {
|
|
@@ -715266,10 +715981,10 @@ This is an independent background session started from /background.`
|
|
|
715266
715981
|
const autoNexus = new NexusTool(repoRoot);
|
|
715267
715982
|
const _registerNexusDaemon = () => {
|
|
715268
715983
|
try {
|
|
715269
|
-
const nexusPidFile =
|
|
715270
|
-
if (
|
|
715984
|
+
const nexusPidFile = join174(autoNexus.getNexusDir(), "daemon.pid");
|
|
715985
|
+
if (existsSync161(nexusPidFile)) {
|
|
715271
715986
|
const nPid = parseInt(
|
|
715272
|
-
|
|
715987
|
+
readFileSync132(nexusPidFile, "utf8").trim(),
|
|
715273
715988
|
10
|
|
715274
715989
|
);
|
|
715275
715990
|
if (nPid > 0 && !registry2.daemons.has("Nexus")) {
|
|
@@ -715300,7 +716015,7 @@ This is an independent background session started from /background.`
|
|
|
715300
716015
|
await new Promise((r3) => setTimeout(r3, 5e3));
|
|
715301
716016
|
return _tryNexusConnect(attempt + 1);
|
|
715302
716017
|
}
|
|
715303
|
-
const nexusLogPath =
|
|
716018
|
+
const nexusLogPath = join174(autoNexus.getNexusDir(), "daemon.err");
|
|
715304
716019
|
const visibleOut = out.length > 1200 ? `${out.slice(0, 1200)}...` : out;
|
|
715305
716020
|
writeContent(
|
|
715306
716021
|
() => renderWarning(
|
|
@@ -715343,7 +716058,7 @@ Log: ${nexusLogPath}`
|
|
|
715343
716058
|
} catch {
|
|
715344
716059
|
}
|
|
715345
716060
|
try {
|
|
715346
|
-
const omniusDir =
|
|
716061
|
+
const omniusDir = join174(repoRoot, ".omnius");
|
|
715347
716062
|
const reconnected = await ExposeGateway.checkAndReconnect(omniusDir, {
|
|
715348
716063
|
onInfo: (msg) => writeContent(() => renderInfo(msg)),
|
|
715349
716064
|
onError: (msg) => writeContent(() => renderWarning(msg))
|
|
@@ -715382,7 +716097,7 @@ Log: ${nexusLogPath}`
|
|
|
715382
716097
|
} catch {
|
|
715383
716098
|
}
|
|
715384
716099
|
try {
|
|
715385
|
-
const omniusDir =
|
|
716100
|
+
const omniusDir = join174(repoRoot, ".omnius");
|
|
715386
716101
|
const reconnectedP2P = await ExposeP2PGateway.checkAndReconnect(
|
|
715387
716102
|
omniusDir,
|
|
715388
716103
|
new NexusTool(repoRoot),
|
|
@@ -715447,11 +716162,11 @@ Log: ${nexusLogPath}`
|
|
|
715447
716162
|
hostname: _hn,
|
|
715448
716163
|
userInfo: _ui
|
|
715449
716164
|
} = await import("node:os");
|
|
715450
|
-
const globalNamePath =
|
|
716165
|
+
const globalNamePath = join174(_hd(), ".omnius", "agent-name");
|
|
715451
716166
|
let agName = "";
|
|
715452
716167
|
try {
|
|
715453
|
-
if (
|
|
715454
|
-
agName =
|
|
716168
|
+
if (existsSync161(globalNamePath))
|
|
716169
|
+
agName = readFileSync132(globalNamePath, "utf8").trim();
|
|
715455
716170
|
} catch {
|
|
715456
716171
|
}
|
|
715457
716172
|
if (!agName) {
|
|
@@ -715482,7 +716197,7 @@ Log: ${nexusLogPath}`
|
|
|
715482
716197
|
}
|
|
715483
716198
|
if (!ollamaAlive) {
|
|
715484
716199
|
try {
|
|
715485
|
-
const savedSponsorsPath =
|
|
716200
|
+
const savedSponsorsPath = join174(
|
|
715486
716201
|
repoRoot,
|
|
715487
716202
|
".omnius",
|
|
715488
716203
|
"sponsor",
|
|
@@ -715490,9 +716205,9 @@ Log: ${nexusLogPath}`
|
|
|
715490
716205
|
);
|
|
715491
716206
|
let savedSponsors = [];
|
|
715492
716207
|
try {
|
|
715493
|
-
if (
|
|
716208
|
+
if (existsSync161(savedSponsorsPath)) {
|
|
715494
716209
|
savedSponsors = JSON.parse(
|
|
715495
|
-
|
|
716210
|
+
readFileSync132(savedSponsorsPath, "utf8")
|
|
715496
716211
|
);
|
|
715497
716212
|
const oneHourAgo = Date.now() - 36e5;
|
|
715498
716213
|
savedSponsors = savedSponsors.filter(
|
|
@@ -715982,9 +716697,9 @@ Log: ${nexusLogPath}`
|
|
|
715982
716697
|
setSessionTitle(title) {
|
|
715983
716698
|
sessionTitle = title.trim() || null;
|
|
715984
716699
|
try {
|
|
715985
|
-
|
|
715986
|
-
|
|
715987
|
-
|
|
716700
|
+
mkdirSync103(join174(repoRoot, ".omnius"), { recursive: true });
|
|
716701
|
+
writeFileSync88(
|
|
716702
|
+
join174(repoRoot, ".omnius", "session-title"),
|
|
715988
716703
|
`${sessionTitle ?? ""}
|
|
715989
716704
|
`,
|
|
715990
716705
|
"utf8"
|
|
@@ -717376,10 +718091,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
717376
718091
|
if (name10 === "voice_list_files") {
|
|
717377
718092
|
const baseDir = String(args?.dir ?? ".");
|
|
717378
718093
|
const { readdirSync: readdirSync59, statSync: statSync59 } = __require("node:fs");
|
|
717379
|
-
const { join:
|
|
717380
|
-
const base3 = baseDir.startsWith("/") ? baseDir : resolve71(
|
|
718094
|
+
const { join: join179, resolve: resolve71 } = __require("node:path");
|
|
718095
|
+
const base3 = baseDir.startsWith("/") ? baseDir : resolve71(join179(repoRoot, baseDir));
|
|
717381
718096
|
const items = readdirSync59(base3).slice(0, 200).map((f2) => {
|
|
717382
|
-
const s2 = statSync59(
|
|
718097
|
+
const s2 = statSync59(join179(base3, f2));
|
|
717383
718098
|
return { name: f2, dir: s2.isDirectory(), size: s2.size };
|
|
717384
718099
|
});
|
|
717385
718100
|
return JSON.stringify({ dir: base3, items }, null, 2);
|
|
@@ -717482,7 +718197,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
717482
718197
|
kind,
|
|
717483
718198
|
targetUrl,
|
|
717484
718199
|
authKey,
|
|
717485
|
-
stateDir:
|
|
718200
|
+
stateDir: join174(repoRoot, ".omnius"),
|
|
717486
718201
|
passthrough: passthrough ?? false,
|
|
717487
718202
|
loadbalance: loadbalance ?? false,
|
|
717488
718203
|
endpointAuth: passthrough ? endpointAuth ?? currentConfig.apiKey : void 0,
|
|
@@ -717538,7 +718253,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
717538
718253
|
targetUrl,
|
|
717539
718254
|
authKey,
|
|
717540
718255
|
fullAccess,
|
|
717541
|
-
stateDir:
|
|
718256
|
+
stateDir: join174(repoRoot, ".omnius"),
|
|
717542
718257
|
endpointAuth: endpointAuth ?? (passthrough ? currentConfig.apiKey : void 0)
|
|
717543
718258
|
});
|
|
717544
718259
|
newTunnel.on("stats", (stats) => {
|
|
@@ -717630,9 +718345,9 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
717630
718345
|
});
|
|
717631
718346
|
if (!result.success) throw new Error(result.error || "Connect failed");
|
|
717632
718347
|
try {
|
|
717633
|
-
const nexusPidFile =
|
|
717634
|
-
if (
|
|
717635
|
-
const pid = parseInt(
|
|
718348
|
+
const nexusPidFile = join174(nexusTool.getNexusDir(), "daemon.pid");
|
|
718349
|
+
if (existsSync161(nexusPidFile)) {
|
|
718350
|
+
const pid = parseInt(readFileSync132(nexusPidFile, "utf8").trim(), 10);
|
|
717636
718351
|
if (pid > 0) {
|
|
717637
718352
|
registry2.register({
|
|
717638
718353
|
name: "Nexus",
|
|
@@ -717842,10 +718557,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
717842
718557
|
);
|
|
717843
718558
|
}
|
|
717844
718559
|
try {
|
|
717845
|
-
const nexusDir =
|
|
717846
|
-
const pidFile =
|
|
717847
|
-
if (
|
|
717848
|
-
const pid = parseInt(
|
|
718560
|
+
const nexusDir = join174(repoRoot, OMNIUS_DIR, "nexus");
|
|
718561
|
+
const pidFile = join174(nexusDir, "daemon.pid");
|
|
718562
|
+
if (existsSync161(pidFile)) {
|
|
718563
|
+
const pid = parseInt(readFileSync132(pidFile, "utf8").trim(), 10);
|
|
717849
718564
|
if (pid > 0) {
|
|
717850
718565
|
try {
|
|
717851
718566
|
if (process.platform === "win32") {
|
|
@@ -717872,13 +718587,13 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
717872
718587
|
} catch {
|
|
717873
718588
|
}
|
|
717874
718589
|
try {
|
|
717875
|
-
const voiceDir3 =
|
|
718590
|
+
const voiceDir3 = join174(homedir60(), ".omnius", "voice");
|
|
717876
718591
|
const voicePidFiles = ["luxtts-daemon.pid", "piper-daemon.pid"];
|
|
717877
718592
|
for (const pf of voicePidFiles) {
|
|
717878
|
-
const pidPath =
|
|
717879
|
-
if (
|
|
718593
|
+
const pidPath = join174(voiceDir3, pf);
|
|
718594
|
+
if (existsSync161(pidPath)) {
|
|
717880
718595
|
try {
|
|
717881
|
-
const pid = parseInt(
|
|
718596
|
+
const pid = parseInt(readFileSync132(pidPath, "utf8").trim(), 10);
|
|
717882
718597
|
if (pid > 0) {
|
|
717883
718598
|
if (process.platform === "win32") {
|
|
717884
718599
|
try {
|
|
@@ -717908,8 +718623,8 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
717908
718623
|
);
|
|
717909
718624
|
} catch {
|
|
717910
718625
|
}
|
|
717911
|
-
const omniusPath =
|
|
717912
|
-
if (
|
|
718626
|
+
const omniusPath = join174(repoRoot, OMNIUS_DIR);
|
|
718627
|
+
if (existsSync161(omniusPath)) {
|
|
717913
718628
|
let deleted = false;
|
|
717914
718629
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
717915
718630
|
try {
|
|
@@ -718020,23 +718735,23 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
718020
718735
|
try {
|
|
718021
718736
|
const { isPersonaPlexRunning: isPersonaPlexRunning2 } = await Promise.resolve().then(() => (init_personaplex(), personaplex_exports));
|
|
718022
718737
|
if (isPersonaPlexRunning2()) {
|
|
718023
|
-
const ppPidFile =
|
|
718738
|
+
const ppPidFile = join174(
|
|
718024
718739
|
homedir60(),
|
|
718025
718740
|
".omnius",
|
|
718026
718741
|
"voice",
|
|
718027
718742
|
"personaplex",
|
|
718028
718743
|
"daemon.pid"
|
|
718029
718744
|
);
|
|
718030
|
-
const ppPortFile =
|
|
718745
|
+
const ppPortFile = join174(
|
|
718031
718746
|
homedir60(),
|
|
718032
718747
|
".omnius",
|
|
718033
718748
|
"voice",
|
|
718034
718749
|
"personaplex",
|
|
718035
718750
|
"daemon.port"
|
|
718036
718751
|
);
|
|
718037
|
-
if (
|
|
718038
|
-
const ppPid = parseInt(
|
|
718039
|
-
const ppPort =
|
|
718752
|
+
if (existsSync161(ppPidFile)) {
|
|
718753
|
+
const ppPid = parseInt(readFileSync132(ppPidFile, "utf8").trim(), 10);
|
|
718754
|
+
const ppPort = existsSync161(ppPortFile) ? parseInt(readFileSync132(ppPortFile, "utf8").trim(), 10) : void 0;
|
|
718040
718755
|
if (ppPid > 0 && !registry2.daemons.has("PersonaPlex")) {
|
|
718041
718756
|
registry2.register({
|
|
718042
718757
|
name: "PersonaPlex",
|
|
@@ -718048,12 +718763,12 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
718048
718763
|
}
|
|
718049
718764
|
}
|
|
718050
718765
|
}
|
|
718051
|
-
const nexusPidFile =
|
|
718766
|
+
const nexusPidFile = join174(
|
|
718052
718767
|
new NexusTool(repoRoot).getNexusDir(),
|
|
718053
718768
|
"daemon.pid"
|
|
718054
718769
|
);
|
|
718055
|
-
if (
|
|
718056
|
-
const nPid = parseInt(
|
|
718770
|
+
if (existsSync161(nexusPidFile)) {
|
|
718771
|
+
const nPid = parseInt(readFileSync132(nexusPidFile, "utf8").trim(), 10);
|
|
718057
718772
|
if (nPid > 0 && !registry2.daemons.has("Nexus")) {
|
|
718058
718773
|
try {
|
|
718059
718774
|
process.kill(nPid, 0);
|
|
@@ -718483,9 +719198,9 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
718483
719198
|
}
|
|
718484
719199
|
}
|
|
718485
719200
|
const cleanPath = input.replace(/^['"]|['"]$/g, "").trim();
|
|
718486
|
-
const isImage = isImagePath(cleanPath) &&
|
|
718487
|
-
const isMedia = !isImage && isTranscribablePath(cleanPath) &&
|
|
718488
|
-
const isMarkdown = !isImage && !isMedia && /\.(md|markdown)$/i.test(cleanPath) &&
|
|
719201
|
+
const isImage = isImagePath(cleanPath) && existsSync161(resolve67(repoRoot, cleanPath));
|
|
719202
|
+
const isMedia = !isImage && isTranscribablePath(cleanPath) && existsSync161(resolve67(repoRoot, cleanPath));
|
|
719203
|
+
const isMarkdown = !isImage && !isMedia && /\.(md|markdown)$/i.test(cleanPath) && existsSync161(resolve67(repoRoot, cleanPath));
|
|
718489
719204
|
if (activeTask) {
|
|
718490
719205
|
if ((isImage || isMedia) && activeTask.runner.isPaused) {
|
|
718491
719206
|
activeTask.runner.resume();
|
|
@@ -718494,7 +719209,7 @@ Execute this skill now. Follow the behavioral guidance above.`;
|
|
|
718494
719209
|
if (isImage) {
|
|
718495
719210
|
try {
|
|
718496
719211
|
const imgPath = resolve67(repoRoot, cleanPath);
|
|
718497
|
-
const imgBuffer =
|
|
719212
|
+
const imgBuffer = readFileSync132(imgPath);
|
|
718498
719213
|
const base642 = imgBuffer.toString("base64");
|
|
718499
719214
|
const ext = extname22(cleanPath).toLowerCase();
|
|
718500
719215
|
const mime = ext === ".png" ? "image/png" : ext === ".gif" ? "image/gif" : ext === ".webp" ? "image/webp" : "image/jpeg";
|
|
@@ -718727,7 +719442,7 @@ Read it with image_read or vision if more detail is needed. Describe what you se
|
|
|
718727
719442
|
if (isMarkdown && fullInput === input) {
|
|
718728
719443
|
try {
|
|
718729
719444
|
const mdPath = resolve67(repoRoot, cleanPath);
|
|
718730
|
-
const mdContent =
|
|
719445
|
+
const mdContent = readFileSync132(mdPath, "utf8");
|
|
718731
719446
|
const { parseMcpMarkdown: parseMcpMarkdown2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports2));
|
|
718732
719447
|
const result = parseMcpMarkdown2(mdContent);
|
|
718733
719448
|
if (result.servers.length > 0) {
|
|
@@ -719364,13 +720079,13 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
719364
720079
|
const handle2 = startTask(task, config, repoRoot);
|
|
719365
720080
|
await handle2.promise;
|
|
719366
720081
|
try {
|
|
719367
|
-
const ikDir =
|
|
719368
|
-
const ikFile =
|
|
720082
|
+
const ikDir = join174(repoRoot, ".omnius", "identity");
|
|
720083
|
+
const ikFile = join174(ikDir, "self-state.json");
|
|
719369
720084
|
let ikState;
|
|
719370
|
-
if (
|
|
719371
|
-
ikState = JSON.parse(
|
|
720085
|
+
if (existsSync161(ikFile)) {
|
|
720086
|
+
ikState = JSON.parse(readFileSync132(ikFile, "utf8"));
|
|
719372
720087
|
} else {
|
|
719373
|
-
|
|
720088
|
+
mkdirSync103(ikDir, { recursive: true });
|
|
719374
720089
|
ikState = {
|
|
719375
720090
|
self_id: `omnius-${Date.now().toString(36)}`,
|
|
719376
720091
|
version: 1,
|
|
@@ -719423,7 +720138,7 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
719423
720138
|
);
|
|
719424
720139
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
719425
720140
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
719426
|
-
|
|
720141
|
+
writeFileSync88(ikFile, JSON.stringify(ikState, null, 2));
|
|
719427
720142
|
} catch (ikErr) {
|
|
719428
720143
|
}
|
|
719429
720144
|
try {
|
|
@@ -719436,12 +720151,12 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
719436
720151
|
);
|
|
719437
720152
|
} catch {
|
|
719438
720153
|
try {
|
|
719439
|
-
const archeDir =
|
|
719440
|
-
const archeFile =
|
|
720154
|
+
const archeDir = join174(repoRoot, ".omnius", "arche");
|
|
720155
|
+
const archeFile = join174(archeDir, "variants.json");
|
|
719441
720156
|
let variants = [];
|
|
719442
720157
|
try {
|
|
719443
|
-
if (
|
|
719444
|
-
variants = JSON.parse(
|
|
720158
|
+
if (existsSync161(archeFile))
|
|
720159
|
+
variants = JSON.parse(readFileSync132(archeFile, "utf8"));
|
|
719445
720160
|
} catch {
|
|
719446
720161
|
}
|
|
719447
720162
|
variants.push({
|
|
@@ -719455,21 +720170,21 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
719455
720170
|
tags: ["general"]
|
|
719456
720171
|
});
|
|
719457
720172
|
if (variants.length > 50) variants = variants.slice(-50);
|
|
719458
|
-
|
|
719459
|
-
|
|
720173
|
+
mkdirSync103(archeDir, { recursive: true });
|
|
720174
|
+
writeFileSync88(archeFile, JSON.stringify(variants, null, 2));
|
|
719460
720175
|
} catch {
|
|
719461
720176
|
}
|
|
719462
720177
|
}
|
|
719463
720178
|
try {
|
|
719464
|
-
const metaFile2 =
|
|
720179
|
+
const metaFile2 = join174(
|
|
719465
720180
|
repoRoot,
|
|
719466
720181
|
".omnius",
|
|
719467
720182
|
"memory",
|
|
719468
720183
|
"metabolism",
|
|
719469
720184
|
"store.json"
|
|
719470
720185
|
);
|
|
719471
|
-
if (
|
|
719472
|
-
const store2 = JSON.parse(
|
|
720186
|
+
if (existsSync161(metaFile2)) {
|
|
720187
|
+
const store2 = JSON.parse(readFileSync132(metaFile2, "utf8"));
|
|
719473
720188
|
const surfaced = store2.filter(
|
|
719474
720189
|
(m2) => m2.type !== "quarantine" && m2.scores?.confidence > 0.15
|
|
719475
720190
|
).sort(
|
|
@@ -719487,7 +720202,7 @@ async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
|
719487
720202
|
updated = true;
|
|
719488
720203
|
}
|
|
719489
720204
|
if (updated) {
|
|
719490
|
-
|
|
720205
|
+
writeFileSync88(metaFile2, JSON.stringify(store2, null, 2));
|
|
719491
720206
|
}
|
|
719492
720207
|
}
|
|
719493
720208
|
} catch {
|
|
@@ -719545,9 +720260,9 @@ Rules:
|
|
|
719545
720260
|
try {
|
|
719546
720261
|
const { initDb: initDb2 } = __require("@omnius/memory");
|
|
719547
720262
|
const { ProceduralMemoryStore: ProceduralMemoryStore2 } = __require("@omnius/memory");
|
|
719548
|
-
const dbDir =
|
|
719549
|
-
|
|
719550
|
-
const db = initDb2(
|
|
720263
|
+
const dbDir = join174(repoRoot, ".omnius", "memory");
|
|
720264
|
+
mkdirSync103(dbDir, { recursive: true });
|
|
720265
|
+
const db = initDb2(join174(dbDir, "structured.db"));
|
|
719551
720266
|
const memStore = new ProceduralMemoryStore2(db);
|
|
719552
720267
|
memStore.createWithEmbedding(
|
|
719553
720268
|
{
|
|
@@ -719567,12 +720282,12 @@ Rules:
|
|
|
719567
720282
|
db.close();
|
|
719568
720283
|
} catch {
|
|
719569
720284
|
}
|
|
719570
|
-
const metaDir =
|
|
719571
|
-
const storeFile =
|
|
720285
|
+
const metaDir = join174(repoRoot, ".omnius", "memory", "metabolism");
|
|
720286
|
+
const storeFile = join174(metaDir, "store.json");
|
|
719572
720287
|
let store2 = [];
|
|
719573
720288
|
try {
|
|
719574
|
-
if (
|
|
719575
|
-
store2 = JSON.parse(
|
|
720289
|
+
if (existsSync161(storeFile))
|
|
720290
|
+
store2 = JSON.parse(readFileSync132(storeFile, "utf8"));
|
|
719576
720291
|
} catch {
|
|
719577
720292
|
}
|
|
719578
720293
|
store2.push({
|
|
@@ -719595,32 +720310,32 @@ Rules:
|
|
|
719595
720310
|
accessCount: 0
|
|
719596
720311
|
});
|
|
719597
720312
|
if (store2.length > 100) store2 = store2.slice(-100);
|
|
719598
|
-
|
|
719599
|
-
|
|
720313
|
+
mkdirSync103(metaDir, { recursive: true });
|
|
720314
|
+
writeFileSync88(storeFile, JSON.stringify(store2, null, 2));
|
|
719600
720315
|
}
|
|
719601
720316
|
}
|
|
719602
720317
|
} catch {
|
|
719603
720318
|
}
|
|
719604
720319
|
try {
|
|
719605
|
-
const cohereSettingsFile =
|
|
720320
|
+
const cohereSettingsFile = join174(repoRoot, ".omnius", "settings.json");
|
|
719606
720321
|
let cohereActive = false;
|
|
719607
720322
|
try {
|
|
719608
|
-
if (
|
|
719609
|
-
const settings = JSON.parse(
|
|
720323
|
+
if (existsSync161(cohereSettingsFile)) {
|
|
720324
|
+
const settings = JSON.parse(readFileSync132(cohereSettingsFile, "utf8"));
|
|
719610
720325
|
cohereActive = settings.cohere === true;
|
|
719611
720326
|
}
|
|
719612
720327
|
} catch {
|
|
719613
720328
|
}
|
|
719614
720329
|
if (cohereActive) {
|
|
719615
|
-
const metaFile2 =
|
|
720330
|
+
const metaFile2 = join174(
|
|
719616
720331
|
repoRoot,
|
|
719617
720332
|
".omnius",
|
|
719618
720333
|
"memory",
|
|
719619
720334
|
"metabolism",
|
|
719620
720335
|
"store.json"
|
|
719621
720336
|
);
|
|
719622
|
-
if (
|
|
719623
|
-
const store2 = JSON.parse(
|
|
720337
|
+
if (existsSync161(metaFile2)) {
|
|
720338
|
+
const store2 = JSON.parse(readFileSync132(metaFile2, "utf8"));
|
|
719624
720339
|
const latest = store2.filter(
|
|
719625
720340
|
(m2) => m2.sourceTrace === "trajectory-extraction" || m2.sourceTrace === "llm-trajectory-extraction"
|
|
719626
720341
|
).slice(-1)[0];
|
|
@@ -719647,9 +720362,9 @@ Rules:
|
|
|
719647
720362
|
}
|
|
719648
720363
|
} catch (err) {
|
|
719649
720364
|
try {
|
|
719650
|
-
const ikFile =
|
|
719651
|
-
if (
|
|
719652
|
-
const ikState = JSON.parse(
|
|
720365
|
+
const ikFile = join174(repoRoot, ".omnius", "identity", "self-state.json");
|
|
720366
|
+
if (existsSync161(ikFile)) {
|
|
720367
|
+
const ikState = JSON.parse(readFileSync132(ikFile, "utf8"));
|
|
719653
720368
|
ikState.homeostasis.uncertainty = Math.min(
|
|
719654
720369
|
1,
|
|
719655
720370
|
ikState.homeostasis.uncertainty + 0.1
|
|
@@ -719660,17 +720375,17 @@ Rules:
|
|
|
719660
720375
|
);
|
|
719661
720376
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
719662
720377
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
719663
|
-
|
|
720378
|
+
writeFileSync88(ikFile, JSON.stringify(ikState, null, 2));
|
|
719664
720379
|
}
|
|
719665
|
-
const metaFile2 =
|
|
720380
|
+
const metaFile2 = join174(
|
|
719666
720381
|
repoRoot,
|
|
719667
720382
|
".omnius",
|
|
719668
720383
|
"memory",
|
|
719669
720384
|
"metabolism",
|
|
719670
720385
|
"store.json"
|
|
719671
720386
|
);
|
|
719672
|
-
if (
|
|
719673
|
-
const store2 = JSON.parse(
|
|
720387
|
+
if (existsSync161(metaFile2)) {
|
|
720388
|
+
const store2 = JSON.parse(readFileSync132(metaFile2, "utf8"));
|
|
719674
720389
|
const surfaced = store2.filter(
|
|
719675
720390
|
(m2) => m2.type !== "quarantine" && m2.scores?.confidence > 0.15
|
|
719676
720391
|
).sort(
|
|
@@ -719688,15 +720403,15 @@ Rules:
|
|
|
719688
720403
|
(item.scores.confidence || 0.5) - 0.02
|
|
719689
720404
|
);
|
|
719690
720405
|
}
|
|
719691
|
-
|
|
720406
|
+
writeFileSync88(metaFile2, JSON.stringify(store2, null, 2));
|
|
719692
720407
|
}
|
|
719693
720408
|
try {
|
|
719694
|
-
const archeDir =
|
|
719695
|
-
const archeFile =
|
|
720409
|
+
const archeDir = join174(repoRoot, ".omnius", "arche");
|
|
720410
|
+
const archeFile = join174(archeDir, "variants.json");
|
|
719696
720411
|
let variants = [];
|
|
719697
720412
|
try {
|
|
719698
|
-
if (
|
|
719699
|
-
variants = JSON.parse(
|
|
720413
|
+
if (existsSync161(archeFile))
|
|
720414
|
+
variants = JSON.parse(readFileSync132(archeFile, "utf8"));
|
|
719700
720415
|
} catch {
|
|
719701
720416
|
}
|
|
719702
720417
|
variants.push({
|
|
@@ -719710,8 +720425,8 @@ Rules:
|
|
|
719710
720425
|
tags: ["general"]
|
|
719711
720426
|
});
|
|
719712
720427
|
if (variants.length > 50) variants = variants.slice(-50);
|
|
719713
|
-
|
|
719714
|
-
|
|
720428
|
+
mkdirSync103(archeDir, { recursive: true });
|
|
720429
|
+
writeFileSync88(archeFile, JSON.stringify(variants, null, 2));
|
|
719715
720430
|
} catch {
|
|
719716
720431
|
}
|
|
719717
720432
|
} catch {
|
|
@@ -719822,18 +720537,18 @@ __export(run_exports, {
|
|
|
719822
720537
|
import { resolve as resolve68 } from "node:path";
|
|
719823
720538
|
import { spawn as spawn34 } from "node:child_process";
|
|
719824
720539
|
import {
|
|
719825
|
-
mkdirSync as
|
|
719826
|
-
writeFileSync as
|
|
719827
|
-
readFileSync as
|
|
720540
|
+
mkdirSync as mkdirSync104,
|
|
720541
|
+
writeFileSync as writeFileSync89,
|
|
720542
|
+
readFileSync as readFileSync133,
|
|
719828
720543
|
readdirSync as readdirSync58,
|
|
719829
|
-
existsSync as
|
|
720544
|
+
existsSync as existsSync162
|
|
719830
720545
|
} from "node:fs";
|
|
719831
720546
|
import { randomBytes as randomBytes29 } from "node:crypto";
|
|
719832
|
-
import { join as
|
|
720547
|
+
import { join as join175 } from "node:path";
|
|
719833
720548
|
function jobsDir2(repoPath2) {
|
|
719834
720549
|
const root = resolve68(repoPath2 ?? process.cwd());
|
|
719835
|
-
const dir =
|
|
719836
|
-
|
|
720550
|
+
const dir = join175(root, ".omnius", "jobs");
|
|
720551
|
+
mkdirSync104(dir, { recursive: true });
|
|
719837
720552
|
return dir;
|
|
719838
720553
|
}
|
|
719839
720554
|
async function runCommand2(opts, config) {
|
|
@@ -719963,7 +720678,7 @@ async function runBackground(task, config, opts) {
|
|
|
719963
720678
|
}
|
|
719964
720679
|
});
|
|
719965
720680
|
job.pid = child.pid ?? 0;
|
|
719966
|
-
|
|
720681
|
+
writeFileSync89(join175(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
719967
720682
|
let output = "";
|
|
719968
720683
|
child.stdout?.on("data", (chunk) => {
|
|
719969
720684
|
output += chunk.toString();
|
|
@@ -719979,7 +720694,7 @@ async function runBackground(task, config, opts) {
|
|
|
719979
720694
|
job.summary = result.summary;
|
|
719980
720695
|
job.durationMs = result.durationMs;
|
|
719981
720696
|
job.error = result.error;
|
|
719982
|
-
|
|
720697
|
+
writeFileSync89(join175(dir, `${id}.json`), JSON.stringify(job, null, 2));
|
|
719983
720698
|
} catch {
|
|
719984
720699
|
}
|
|
719985
720700
|
});
|
|
@@ -719995,13 +720710,13 @@ async function runBackground(task, config, opts) {
|
|
|
719995
720710
|
}
|
|
719996
720711
|
function statusCommand(jobId, repoPath2) {
|
|
719997
720712
|
const dir = jobsDir2(repoPath2);
|
|
719998
|
-
const file =
|
|
719999
|
-
if (!
|
|
720713
|
+
const file = join175(dir, `${jobId}.json`);
|
|
720714
|
+
if (!existsSync162(file)) {
|
|
720000
720715
|
console.error(`Job not found: ${jobId}`);
|
|
720001
720716
|
console.log(`Available jobs: omnius jobs`);
|
|
720002
720717
|
process.exit(1);
|
|
720003
720718
|
}
|
|
720004
|
-
const job = JSON.parse(
|
|
720719
|
+
const job = JSON.parse(readFileSync133(file, "utf-8"));
|
|
720005
720720
|
const runtime = job.completedAt ? `${((new Date(job.completedAt).getTime() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s` : `${((Date.now() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s`;
|
|
720006
720721
|
const icon = job.status === "completed" ? "✓" : job.status === "failed" ? "✗" : "●";
|
|
720007
720722
|
console.log(`${icon} ${job.id} [${job.status}] ${runtime}`);
|
|
@@ -720023,7 +720738,7 @@ function jobsCommand(repoPath2) {
|
|
|
720023
720738
|
console.log("Jobs:");
|
|
720024
720739
|
for (const file of files) {
|
|
720025
720740
|
try {
|
|
720026
|
-
const job = JSON.parse(
|
|
720741
|
+
const job = JSON.parse(readFileSync133(join175(dir, file), "utf-8"));
|
|
720027
720742
|
const icon = job.status === "completed" ? "✓" : job.status === "failed" ? "✗" : "●";
|
|
720028
720743
|
const runtime = job.completedAt ? `${((new Date(job.completedAt).getTime() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s` : `${((Date.now() - new Date(job.startedAt).getTime()) / 1e3).toFixed(0)}s`;
|
|
720029
720744
|
const cleanListTask = cleanForStorage(job.task) || job.task;
|
|
@@ -720050,13 +720765,13 @@ __export(index_repo_exports, {
|
|
|
720050
720765
|
indexRepoCommand: () => indexRepoCommand
|
|
720051
720766
|
});
|
|
720052
720767
|
import { resolve as resolve69 } from "node:path";
|
|
720053
|
-
import { existsSync as
|
|
720768
|
+
import { existsSync as existsSync163, statSync as statSync58 } from "node:fs";
|
|
720054
720769
|
import { cwd as cwd2 } from "node:process";
|
|
720055
720770
|
async function indexRepoCommand(opts, _config3) {
|
|
720056
720771
|
const repoRoot = resolve69(opts.repoPath ?? cwd2());
|
|
720057
720772
|
printHeader("Index Repository");
|
|
720058
720773
|
printInfo(`Indexing: ${repoRoot}`);
|
|
720059
|
-
if (!
|
|
720774
|
+
if (!existsSync163(repoRoot)) {
|
|
720060
720775
|
printError(`Path does not exist: ${repoRoot}`);
|
|
720061
720776
|
process.exit(1);
|
|
720062
720777
|
}
|
|
@@ -720308,7 +721023,7 @@ var config_exports2 = {};
|
|
|
720308
721023
|
__export(config_exports2, {
|
|
720309
721024
|
configCommand: () => configCommand
|
|
720310
721025
|
});
|
|
720311
|
-
import { join as
|
|
721026
|
+
import { join as join176, resolve as resolve70 } from "node:path";
|
|
720312
721027
|
import { homedir as homedir61 } from "node:os";
|
|
720313
721028
|
import { cwd as cwd3 } from "node:process";
|
|
720314
721029
|
function redactIfSensitive(key, value2) {
|
|
@@ -720392,7 +721107,7 @@ function handleShow(opts, config) {
|
|
|
720392
721107
|
}
|
|
720393
721108
|
}
|
|
720394
721109
|
printSection("Config File");
|
|
720395
|
-
printInfo(`~/.omnius/config.json (${
|
|
721110
|
+
printInfo(`~/.omnius/config.json (${join176(homedir61(), ".omnius", "config.json")})`);
|
|
720396
721111
|
printSection("Priority Chain");
|
|
720397
721112
|
printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
|
|
720398
721113
|
printInfo(" 2. Project .omnius/settings.json (--local)");
|
|
@@ -720431,7 +721146,7 @@ function handleSet(opts, _config3) {
|
|
|
720431
721146
|
const coerced = coerceForSettings(key, value2);
|
|
720432
721147
|
saveProjectSettings(repoRoot, { [key]: coerced });
|
|
720433
721148
|
printSuccess(`Project override set: ${key} = ${redactIfSensitive(key, value2)}`);
|
|
720434
|
-
printInfo(`Saved to ${
|
|
721149
|
+
printInfo(`Saved to ${join176(repoRoot, ".omnius", "settings.json")}`);
|
|
720435
721150
|
printInfo("This override applies only when running in this workspace.");
|
|
720436
721151
|
} catch (err) {
|
|
720437
721152
|
printError(`Failed to save: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -720618,8 +721333,8 @@ __export(eval_exports, {
|
|
|
720618
721333
|
evalCommand: () => evalCommand
|
|
720619
721334
|
});
|
|
720620
721335
|
import { tmpdir as tmpdir23 } from "node:os";
|
|
720621
|
-
import { mkdirSync as
|
|
720622
|
-
import { join as
|
|
721336
|
+
import { mkdirSync as mkdirSync105, writeFileSync as writeFileSync90 } from "node:fs";
|
|
721337
|
+
import { join as join177 } from "node:path";
|
|
720623
721338
|
async function evalCommand(opts, config) {
|
|
720624
721339
|
const suiteName = opts.suite ?? "basic";
|
|
720625
721340
|
const suite = SUITES[suiteName];
|
|
@@ -720748,10 +721463,10 @@ async function evalCommand(opts, config) {
|
|
|
720748
721463
|
process.exit(failed > 0 ? 1 : 0);
|
|
720749
721464
|
}
|
|
720750
721465
|
function createTempEvalRepo() {
|
|
720751
|
-
const dir =
|
|
720752
|
-
|
|
720753
|
-
|
|
720754
|
-
|
|
721466
|
+
const dir = join177(tmpdir23(), `omnius-eval-${Date.now()}`);
|
|
721467
|
+
mkdirSync105(dir, { recursive: true });
|
|
721468
|
+
writeFileSync90(
|
|
721469
|
+
join177(dir, "package.json"),
|
|
720755
721470
|
JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n",
|
|
720756
721471
|
"utf8"
|
|
720757
721472
|
);
|
|
@@ -720826,7 +721541,7 @@ init_typed_node_events();
|
|
|
720826
721541
|
init_dist5();
|
|
720827
721542
|
import { parseArgs as nodeParseArgs2 } from "node:util";
|
|
720828
721543
|
import { fileURLToPath as fileURLToPath22 } from "node:url";
|
|
720829
|
-
import { dirname as dirname53, join as
|
|
721544
|
+
import { dirname as dirname53, join as join178 } from "node:path";
|
|
720830
721545
|
import { createRequire as createRequire10 } from "node:module";
|
|
720831
721546
|
|
|
720832
721547
|
// packages/cli/src/cli.ts
|
|
@@ -720974,7 +721689,7 @@ init_output();
|
|
|
720974
721689
|
function getVersion5() {
|
|
720975
721690
|
try {
|
|
720976
721691
|
const require5 = createRequire10(import.meta.url);
|
|
720977
|
-
const pkgPath =
|
|
721692
|
+
const pkgPath = join178(dirname53(fileURLToPath22(import.meta.url)), "..", "package.json");
|
|
720978
721693
|
const pkg = require5(pkgPath);
|
|
720979
721694
|
return pkg.version;
|
|
720980
721695
|
} catch {
|
|
@@ -721356,12 +722071,12 @@ function crashLog(label, err) {
|
|
|
721356
722071
|
const logLine = `[${timestamp}] ${label}: ${msg}
|
|
721357
722072
|
`;
|
|
721358
722073
|
try {
|
|
721359
|
-
const { appendFileSync: appendFileSync18, mkdirSync:
|
|
721360
|
-
const { join:
|
|
722074
|
+
const { appendFileSync: appendFileSync18, mkdirSync: mkdirSync106 } = __require("node:fs");
|
|
722075
|
+
const { join: join179 } = __require("node:path");
|
|
721361
722076
|
const { homedir: homedir62 } = __require("node:os");
|
|
721362
|
-
const logDir =
|
|
721363
|
-
|
|
721364
|
-
appendFileSync18(
|
|
722077
|
+
const logDir = join179(homedir62(), ".omnius");
|
|
722078
|
+
mkdirSync106(logDir, { recursive: true });
|
|
722079
|
+
appendFileSync18(join179(logDir, "crash.log"), logLine);
|
|
721365
722080
|
} catch {
|
|
721366
722081
|
}
|
|
721367
722082
|
try {
|